@salla.sa/twilight 2.0.236 → 2.0.237

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.
@@ -9,5 +9,5 @@
9
9
  <i class="sicon-edit"></i>
10
10
  ${salla.lang.get("pages.products.quick_edit")}
11
11
  </a>
12
- `,document.body.prepend(e)}))}handleElementAjaxRequest(e,t){if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.log("trying to call ajax from non Element!!"),!1;e.preventDefault();let i=t.getAjaxFormData(e),n=i.method?i.method.toLowerCase():void 0;salla.api.document.request(i.url,i.formData,n).then(e=>(e.data&&e.request&&(e=e.data),salla.api.document.handleAfterResponseActions(e),this.callAjaxEvent(i.events.success,e,i.formData),e)).catch(e=>{throw salla.api.document.handleErrorResponse(e),this.callAjaxEvent(i.events.fail,e,i.formData),e})}callAjaxEvent(e,t,i){var n;e&&(i instanceof FormData&&(n={},Array.from(i.entries()).forEach(function(e){n[e[0]]=e[1]}),i=n),window[e]?window[e](t,i):salla.event.dispatch(e,t,i))}}class TwilightApi extends BaseApi{constructor(e){super(e),this.namespace="twilight",this.after_init()}init(e){var t=e?.events;return this.initiated||(delete e.events,new SallaInit(e),this.initiated=!0),t&&salla.event.dispatchEvents(t),this.successPromise(e)}api(e){var t=e?.events;return t&&salla.event.dispatchEvents(t),this.successPromise(e)}}class WishlistApi extends BaseApi{constructor(e){super(e),this.namespace="wishlist",this.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},this.endpointsMethods={remove:"delete"},this.after_init()}toggle(e){return salla.storage.get("salla::wishlist",[]).includes(e)?this.remove(e):this.add(e)}add(t){let e;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(e=salla.lang.get("common.messages.must_login")),salla.error(e),this.errorPromise(e)):(t=t&&t.data?this.getPossibleValue(t.data,["product_id","id"]):t)?this.request(["add",t]).then(e=>(this.updateWishlistStorage(t),salla.wishlist.event.added(e,t),e)).catch(function(e){throw salla.wishlist.event.additionFailed(e,t),e}):(salla.wishlist.event.additionFailed(e="Failed to get product id!"),this.errorPromise(e))}remove(t){let e;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(e=salla.lang.get("common.messages.must_login")),salla.error(e),this.errorPromise(e)):(t=t?.data?this.getPossibleValue(t.data,["id","prod_id"]):t)?this.request(["remove",t]).then(e=>(this.updateWishlistStorage(t,!1),salla.wishlist.event.removed(e,t),e)).catch(function(e){throw salla.wishlist.event.removingFailed(e,t),e}):(salla.wishlist.event.removingFailed(e="Failed to get id!"),this.errorPromise(e))}updateWishlistStorage(e,t=!0){let i=salla.storage.get("salla::wishlist",[]);t?i.push(e):i.splice(i.indexOf(e),1),salla.storage.set("salla::wishlist",i)}}class ScopeApi extends BaseApi{constructor(e){super(e),this.namespace="scope",this.endpoints={getAll:"/scopes",submit:"/scope"},this.webEndpoints=["getAll","submit"],this.endpointsMethods={getAll:"get"},this.after_init()}getAll(){return this.request("getAll",{from:"header"}).then(function(e){return console.log(e),e}).catch(function(e){throw e})}submit(e){return this.request("submit",e).then(function(e){return console.log(e),e}).catch(function(e){throw e})}}function e(e){this.message=e}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var i=String(t).replace(/=+$/,"");if(i.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,s=0,a=0,o="";r=i.charAt(a++);~r&&(n=s%4?64*n+r:r,s++%4)&&(o+=String.fromCharCode(255&n>>(-2*s&6))))r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return o};function t(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return decodeURIComponent(r(t).replace(/(.)/g,function(e,t){t=t.charCodeAt(0).toString(16).toUpperCase();return"%"+(t=t.length<2?"0"+t:t)}))}catch(e){return r(t)}}function n(e){this.message=e}function o(e,i){if("string"!=typeof e)throw new n("Invalid token specified");i=!0===(i=i||{}).header?0:1;try{return JSON.parse(t(e.split(".")[i]))}catch(e){throw new n("Invalid token specified: "+e.message)}}n.prototype=new Error,n.prototype.name="InvalidTokenError";const axios=require("axios");class sallaRequest{constructor(e){return e.on("twilight::initiated",()=>this.initiateRequest()),e.on("auth::token.fetched",e=>this.handleToken(e)),axios.create({baseURL:window.baseUrl,headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"","S-APP-OS":""}}})}initiateRequest(){salla.api.defaults.baseURL=salla.config.get("store.url",window.baseUrl),salla.api.defaults.headers.common["Store-Identifier"]=salla.config.get("store.id"),salla.api.defaults.headers.common.currency=salla.config.get("user.currency_code","SAR"),salla.api.defaults.headers.common["accept-language"]=salla.config.languageCode(),this.injectTokenToTheRequests()}injectTokenToTheRequests(){var e=salla.storage.get("token"),t=salla.config.isGuest(),i=salla.storage.get("cart");if(i&&i.user_id!==salla.config.get("user.id"))return salla.log("Auth:: The cart is not belong to current user!"),void salla.cart.api.reset();if(!t||e){if(t&&e)return salla.log("Auth:: Token without user!"),salla.storage.remove("token"),void salla.cart.api.reset();if(!e)return salla.cart.api.reset(),void salla.auth.api.refresh();i=o(e);return Date.now()/1e3>i.exp?(salla.log("Auth:: An expired token!"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh()):i.sub!==salla.config.get("user.id")?(salla.log("Auth:: The user id is not match the token details!"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh()):void this.setToken(e)}}handleToken(e){salla.storage.set("token",e),this.setToken(e),salla.cart.api.reset()}setToken(e){salla.api.defaults.headers.common.Authorization="Bearer "+e}}class SallaApi extends sallaRequest{constructor(e){super(e),this.apis={auth:new AuthApi(this),cart:new CartApi(this),gift:new GiftApi(this),loyalty:new LoyalityApi(this),order:new OrderApi(this),offer:new OfferApi(this),coupon:new CouponApi(this),rating:new RatingApi(this),search:new SearchApi(this),product:new ProductApi(this),profile:new ProfileApi(this),comment:new CommentApi(this),currency:new CurrencyApi(this),document:new DocumentApi(this),twilight:new TwilightApi(this),wishlist:new WishlistApi(this),scope:new ScopeApi(this)},Object.assign(this,this.apis),this.getHeaders=()=>this.defaults.headers.common}}class Action{constructor(i,n){return this.api=i,this.event=n,new Proxy(this,{get:function(e,t){return"event"===t?n:"api"===t?i:i&&i[t]||e[t]}})}}var js={exports:{}},core={exports:{}},evEmitter={exports:{}},utils=(!function(e){var t,i;t="undefined"!=typeof window?window:commonjsGlobal,i=function(){function e(){}let t=e.prototype;return t.on=function(e,t){if(!e||!t)return this;let i=this._events=this._events||{},n=i[e]=i[e]||[];return n.includes(t)||n.push(t),this},t.once=function(e,t){if(!e||!t)return this;this.on(e,t);let i=this._onceEvents=this._onceEvents||{};return(i[e]=i[e]||{})[t]=!0,this},t.off=function(e,t){let i=this._events&&this._events[e];if(!i||!i.length)return this;e=i.indexOf(t);return-1!=e&&i.splice(e,1),this},t.emitEvent=function(e,t){let i=this._events&&this._events[e];if(!i||!i.length)return this;i=i.slice(0),t=t||[];let n=this._onceEvents&&this._onceEvents[e];for(var r of i)n&&n[r]&&(this.off(e,r),delete n[r]),r.apply(this,t);return this},t.allOff=function(){return delete this._events,delete this._onceEvents,this},e},e.exports?e.exports=i():t.EvEmitter=i()}(evEmitter),{exports:{}}),pageLoad=(!function(e){var t,i;t=commonjsGlobal,i=function(t){let n={extend:function(e,t){return Object.assign(e,t)},modulo:function(e,t){return(e%t+t)%t},makeArray:function(e){return Array.isArray(e)?e:null==e?[]:"object"==typeof e&&"number"==typeof e.length?[...e]:[e]},removeFrom:function(e,t){t=e.indexOf(t);-1!=t&&e.splice(t,1)},getParent:function(e,t){for(;e.parentNode&&e!=document.body;)if((e=e.parentNode).matches(t))return e},getQueryElement:function(e){return"string"==typeof e?document.querySelector(e):e},handleEvent:function(e){var t="on"+e.type;this[t]&&this[t](e)},filterFindElements:function(e,i){return(e=n.makeArray(e)).filter(e=>e instanceof HTMLElement).reduce((e,t)=>{if(!i)return e.push(t),e;t.matches(i)&&e.push(t);t=t.querySelectorAll(i);return e.concat(...t)},[])},debounceMethod:function(e,t,i){i=i||100;let n=e.prototype[t],r=t+"Timeout";e.prototype[t]=function(){clearTimeout(this[r]);let e=arguments;this[r]=setTimeout(()=>{n.apply(this,e),delete this[r]},i)}},docReady:function(e){var t=document.readyState;"complete"==t||"interactive"==t?setTimeout(e):document.addEventListener("DOMContentLoaded",e)},toDashed:function(e){return e.replace(/(.)([A-Z])/g,function(e,t,i){return t+"-"+i}).toLowerCase()}},l=t.console;return n.htmlInit=function(a,o){n.docReady(function(){let r="data-"+n.toDashed(o),e=document.querySelectorAll(`[${r}]`),s=t.jQuery;[...e].forEach(e=>{let t,i=e.getAttribute(r);try{t=i&&JSON.parse(i)}catch(t){return void(l&&l.error(`Error parsing ${r} on ${e.className}: `+t))}var n=new a(e,t);s&&s.data(e,o,n)})})},n},e.exports?e.exports=i(t):t.fizzyUIUtils=i(t)}(utils),function(e){var t,i;t=window,i=function(t,e,n){let r=t.jQuery,s={};function a(t,i){var e=n.getQueryElement(t);if(e){if((t=e).infiniteScrollGUID){let e=s[t.infiniteScrollGUID];return e.option(i),e}this.element=t,this.options={...a.defaults},this.option(i),r&&(this.$element=r(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(e||t))}a.defaults={},a.create={},a.destroy={};let i=a.prototype,o=(Object.assign(i,e.prototype),0),l=(i.create=function(){var e=this.guid=++o;if(this.element.infiniteScrollGUID=e,(s[e]=this).pageIndex=1,this.loadCount=0,this.updateGetPath(),this.getPath&&this.getPath())for(var t in this.updateGetAbsolutePath(),this.log("initialized",[this.element.className]),this.callOnInit(),a.create)a.create[t].call(this);else console.error("Disabling InfiniteScroll")},i.option=function(e){Object.assign(this.options,e)},i.callOnInit=function(){let e=this.options.onInit;e&&e.call(this,this)},i.dispatchEvent=function(i,n,e){this.log(i,e);var t=n?[n].concat(e):e;if(this.emitEvent(i,t),r&&this.$element){let t=i+=".infiniteScroll";if(n){let e=r.Event(n);e.type=i,t=e}this.$element.trigger(t,e)}},{initialized:e=>"on "+e,request:e=>"URL: "+e,load:(e,t)=>`${e.title||""}. URL: `+t,error:(e,t)=>e+". URL: "+t,append:(e,t,i)=>i.length+" items. URL: "+t,last:(e,t)=>"URL: "+t,history:(e,t)=>"URL: "+t,pageIndex:function(e,t){return`current page determined to be: ${e} from `+t}}),c=(i.log=function(i,n){if(this.options.debug){let e="[InfiniteScroll] "+i,t=l[i];t&&(e+=". "+t.apply(this,n)),console.log(e)}},i.updateMeasurements=function(){this.windowHeight=t.innerHeight;var e=this.element.getBoundingClientRect();this.top=e.top+t.scrollY},i.updateScroller=function(){var e=this.options.elementScroll;if(e){if(this.scroller=!0===e?this.element:n.getQueryElement(e),!this.scroller)throw new Error("Unable to find elementScroll: "+e)}else this.scroller=t},i.updateGetPath=function(){let e=this.options.path;var t;e?"function"!=(t=typeof e)?"string"==t&&e.match("{{#}}")?this.updateGetPathTemplate(e):this.updateGetPathSelector(e):this.getPath=e:console.error("InfiniteScroll path option required. Set as: "+e)},i.updateGetPathTemplate=function(t){this.getPath=()=>{var e=this.pageIndex+1;return t.replace("{{#}}",e)};var e=t.replace(/(\\\?|\?)/,"\\?").replace("{{#}}","(\\d\\d?\\d?)"),e=new RegExp(e),e=location.href.match(e);e&&(this.pageIndex=parseInt(e[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))},[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/]),u=a.getPathParts=function(e){if(e)for(var t of c){var i,n,t=e.match(t);if(t)return[,t,i,n]=t,{begin:t,index:i,end:n}}},h=(i.updateGetPathSelector=function(e){let t=document.querySelector(e);if(t){var i=t.getAttribute("href"),n=u(i);if(n){let{begin:e,index:t,end:i}=n;this.isPathSelector=!0,this.getPath=()=>e+(this.pageIndex+1)+i,this.pageIndex=parseInt(t,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])}else console.error("InfiniteScroll unable to parse next link href: "+i)}else console.error("Bad InfiniteScroll path option. Next link not found: "+e)},i.updateGetAbsolutePath=function(){let r=this.getPath();if(r.match(/^http/)||r.match(/^\//))this.getAbsolutePath=this.getPath;else{let e=location["pathname"],t=r.match(/^\?/),i=e.substring(0,e.lastIndexOf("/")),n=t?e:i+"/";this.getAbsolutePath=()=>n+this.getPath()}},a.create.hideNav=function(){let e=n.getQueryElement(this.options.hideNav);e&&(e.style.display="none",this.nav=e)},a.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},i.destroy=function(){for(var e in this.allOff(),a.destroy)a.destroy[e].call(this);delete this.element.infiniteScrollGUID,delete s[this.guid],r&&this.$element&&r.removeData(this.element,"infiniteScroll")},a.throttle=function(n,r){let s,a;return r=r||200,function(){let e=+new Date,t=arguments,i=()=>{s=e,n.apply(this,t)};s&&e<s+r?(clearTimeout(a),a=setTimeout(i,r)):i()}},a.data=function(e){e=(e=n.getQueryElement(e))&&e.infiniteScrollGUID;return e&&s[e]},a.setJQuery=function(e){r=e},n.htmlInit(a,"infinite-scroll"),i._init=function(){},t)["jQueryBridget"];return r&&h&&h("infiniteScroll",a,r),a},e.exports?e.exports=i(t,evEmitter.exports,utils.exports):t.InfiniteScroll=i(t,t.EvEmitter,t.fizzyUIUtils)}(core),{exports:{}}),scrollWatch=(!function(e){var t,i;t=window,i=function(t,r){let e=r.prototype,s=(Object.assign(r.defaults,{loadOnScroll:!0,checkLastPage:!0,responseBody:"text",domParseResponse:!0}),r.create.pageLoad=function(){this.canLoad=!0,this.on("scrollThreshold",this.onScrollThresholdLoad),this.on("load",this.checkLastPage),this.options.outlayer&&this.on("append",this.onAppendOutlayer)},e.onScrollThresholdLoad=function(){this.options.loadOnScroll&&this.loadNextPage()},new DOMParser);function u(e){let t=document.createDocumentFragment();return e&&t.append(...e),t}return e.loadNextPage=function(){if(!this.isLoading&&this.canLoad){let{responseBody:i,domParseResponse:n,fetchOptions:e}=this.options,r=this.getAbsolutePath();this.isLoading=!0,"function"==typeof e&&(e=e());var t=fetch(r,e).then(t=>{var e;return t.ok?t[i]().then(e=>("text"==i&&n&&(e=s.parseFromString(e,"text/html")),204==t.status?(this.lastPageReached(e,r),{body:e,response:t}):this.onPageLoad(e,r,t))):(e=new Error(t.statusText),this.onPageError(e,r,t),{response:t})}).catch(e=>{this.onPageError(e,r)});return this.dispatchEvent("request",null,[r,t]),t}},e.onPageLoad=function(e,t,i){return this.options.append||(this.isLoading=!1),this.pageIndex++,this.loadCount++,this.dispatchEvent("load",null,[e,t,i]),this.appendNextPage(e,t,i)},e.appendNextPage=function(e,t,i){var{append:n,responseBody:r,domParseResponse:s}=this.options;if("text"!=r||!s||!n)return{body:e,response:i};let a=e.querySelectorAll(n),o={body:e,response:i,items:a};if(!a||!a.length)return this.lastPageReached(e,t),o;let l=u(a),c=()=>(this.appendItems(a,l),this.isLoading=!1,this.dispatchEvent("append",null,[e,t,a,i]),o);return this.options.outlayer?this.appendOutlayerItems(l,c):c()},e.appendItems=function(e,t){if(e&&e.length){var i;for(i of(t=t||u(e)).querySelectorAll("script")){let e=document.createElement("script"),t=i.attributes;for(var n of t)e.setAttribute(n.name,n.value);e.innerHTML=i.innerHTML,i.parentNode.replaceChild(e,i)}this.element.appendChild(t)}},e.appendOutlayerItems=function(e,i){let n=r.imagesLoaded||t.imagesLoaded;return n?new Promise(function(t){n(e,function(){var e=i();t(e)})}):(console.error("[InfiniteScroll] imagesLoaded required for outlayer option"),void(this.isLoading=!1))},e.onAppendOutlayer=function(e,t,i){this.options.outlayer.appended(i)},e.checkLastPage=function(e,t){let i,{checkLastPage:n,path:r}=this.options;n&&("function"!=typeof r||this.getPath()?("string"==typeof n?i=n:this.isPathSelector&&(i=r),i&&e.querySelector&&(e.querySelector(i)||this.lastPageReached(e,t))):this.lastPageReached(e,t))},e.lastPageReached=function(e,t){this.canLoad=!1,this.dispatchEvent("last",null,[e,t])},e.onPageError=function(e,t,i){return this.isLoading=!1,this.canLoad=!1,this.dispatchEvent("error",null,[e,t,i]),e},r.create.prefill=function(){var e;this.options.prefill&&((e=this.options.append)?(this.updateMeasurements(),this.updateScroller(),this.isPrefilling=!0,this.on("append",this.prefill),this.once("error",this.stopPrefill),this.once("last",this.stopPrefill),this.prefill()):console.error("append option required for prefill. Set as :"+e))},e.prefill=function(){var e=this.getPrefillDistance();this.isPrefilling=0<=e,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},e.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},e.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},r},e.exports?e.exports=i(t,core.exports):i(t,t.InfiniteScroll)}(pageLoad),{exports:{}}),history$1=(!function(e){var t,i;t=window,i=function(i,e,t){let n=e.prototype;return Object.assign(e.defaults,{scrollThreshold:400}),e.create.scrollWatch=function(){this.pageScrollHandler=this.onPageScroll.bind(this),this.resizeHandler=this.onResize.bind(this);var e=this.options.scrollThreshold;!e&&0!==e||this.enableScrollWatch()},e.destroy.scrollWatch=function(){this.disableScrollWatch()},n.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},n.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},n.bindScrollWatchEvents=function(e){e=e?"addEventListener":"removeEventListener";this.scroller[e]("scroll",this.pageScrollHandler),i[e]("resize",this.resizeHandler)},n.onPageScroll=e.throttle(function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")}),n.getBottomDistance=function(){let e,t;return t=this.options.elementScroll?(e=this.scroller.scrollHeight,this.scroller.scrollTop+this.scroller.clientHeight):(e=this.top+this.element.clientHeight,i.scrollY+this.windowHeight),e-t},n.onResize=function(){this.updateMeasurements()},t.debounceMethod(e,"onResize",150),e},e.exports?e.exports=i(t,core.exports,utils.exports):i(t,t.InfiniteScroll,t.fizzyUIUtils)}(scrollWatch),{exports:{}}),button=(!function(e){var t,i;t=window,i=function(n,e,t){let i=e.prototype,r=(Object.assign(e.defaults,{history:"replace"}),document.createElement("a"));return e.create.history=function(){this.options.history&&(r.href=this.getAbsolutePath(),(r.origin||r.protocol+"//"+r.host)==location.origin?this.options.append?this.createHistoryAppend():this.createHistoryPageLoad():console.error(`[InfiniteScroll] cannot set history with different origin: ${r.origin} on ${location.origin} . History behavior disabled.`))},i.createHistoryAppend=function(){this.updateMeasurements(),this.updateScroller(),this.scrollPages=[{top:0,path:location.href,title:document.title}],this.scrollPage=this.scrollPages[0],this.scrollHistoryHandler=this.onScrollHistory.bind(this),this.unloadHandler=this.onUnload.bind(this),this.scroller.addEventListener("scroll",this.scrollHistoryHandler),this.on("append",this.onAppendHistory),this.bindHistoryAppendEvents(!0)},i.bindHistoryAppendEvents=function(e){e=e?"addEventListener":"removeEventListener";this.scroller[e]("scroll",this.scrollHistoryHandler),n[e]("unload",this.unloadHandler)},i.createHistoryPageLoad=function(){this.on("load",this.onPageLoadHistory)},e.destroy.history=i.destroyHistory=function(){this.options.history&&this.options.append&&this.bindHistoryAppendEvents(!1)},i.onAppendHistory=function(e,t,i){i&&i.length&&(i=i[0],i=this.getElementScrollY(i),r.href=t,this.scrollPages.push({top:i,path:r.href,title:e.title}))},i.getElementScrollY=function(e){return this.options.elementScroll?e.offsetTop-this.top:e.getBoundingClientRect().top+n.scrollY},i.onScrollHistory=function(){var e=this.getClosestScrollPage();e!=this.scrollPage&&(this.scrollPage=e,this.setHistory(e.title,e.path))},t.debounceMethod(e,"onScrollHistory",150),i.getClosestScrollPage=function(){let e,t;e=this.options.elementScroll?this.scroller.scrollTop+this.scroller.clientHeight/2:n.scrollY+this.windowHeight/2;for(var i of this.scrollPages){if(i.top>=e)break;t=i}return t},i.setHistory=function(e,t){var i=this.options.history;i&&history[i+"State"]&&(history[i+"State"](null,e,t),this.options.historyTitle&&(document.title=e),this.dispatchEvent("history",null,[e,t]))},i.onUnload=function(){var e;0!==this.scrollPage.top&&(e=n.scrollY-this.scrollPage.top+this.top,this.destroyHistory(),scrollTo(0,e))},i.onPageLoadHistory=function(e,t){this.setHistory(e.title,t)},e},e.exports?e.exports=i(t,core.exports,utils.exports):i(t,t.InfiniteScroll,t.fizzyUIUtils)}(history$1),{exports:{}}),status=(!function(e){var t,i;t=window,i=function(e,t,i){class n{constructor(e,t){this.element=e,this.infScroll=t,this.clickHandler=this.onClick.bind(this),this.element.addEventListener("click",this.clickHandler),t.on("request",this.disable.bind(this)),t.on("load",this.enable.bind(this)),t.on("error",this.hide.bind(this)),t.on("last",this.hide.bind(this))}onClick(e){e.preventDefault(),this.infScroll.loadNextPage()}enable(){this.element.removeAttribute("disabled")}disable(){this.element.disabled="disabled"}hide(){this.element.style.display="none"}destroy(){this.element.removeEventListener("click",this.clickHandler)}}return t.create.button=function(){var e=i.getQueryElement(this.options.button);e&&(this.button=new n(e,this))},t.destroy.button=function(){this.button&&this.button.destroy()},t.Button=n,t},e.exports?e.exports=i(0,core.exports,utils.exports):i(0,t.InfiniteScroll,t.fizzyUIUtils)}(button),{exports:{}}),TheInfiniteScroll=(!function(e){var t,i;t=window,i=function(e,t,i){let n=t.prototype;function r(e){a(e,"none")}function s(e){a(e,"block")}function a(e,t){e&&(e.style.display=t)}return t.create.status=function(){let e=i.getQueryElement(this.options.status);e&&(this.statusElement=e,this.statusEventElements={request:e.querySelector(".infinite-scroll-request"),error:e.querySelector(".infinite-scroll-error"),last:e.querySelector(".infinite-scroll-last")},this.on("request",this.showRequestStatus),this.on("error",this.showErrorStatus),this.on("last",this.showLastStatus),this.bindHideStatus("on"))},n.bindHideStatus=function(e){var t=this.options.append?"append":"load";this[e](t,this.hideAllStatus)},n.showRequestStatus=function(){this.showStatus("request")},n.showErrorStatus=function(){this.showStatus("error")},n.showLastStatus=function(){this.showStatus("last"),this.bindHideStatus("off")},n.showStatus=function(e){s(this.statusElement),this.hideStatusEventElements(),s(this.statusEventElements[e])},n.hideAllStatus=function(){r(this.statusElement),this.hideStatusEventElements()},n.hideStatusEventElements=function(){for(var e in this.statusEventElements)r(this.statusEventElements[e])},t},e.exports?e.exports=i(0,core.exports,utils.exports):i(0,t.InfiniteScroll,t.fizzyUIUtils)}(status),function(e){window,e.exports&&(e.exports=(e=core.exports,pageLoad.exports,scrollWatch.exports,history$1.exports,button.exports,status.exports,e))}(js),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,i){i=this.getCustomOptions(t,i);t="string"!=typeof e?e:document.querySelector(e),e=i.path;if(t&&e&&("string"!=typeof e||document.querySelector(e))){let e=new TheInfiniteScroll(t,i);return e.on("scrollThreshold",salla.infiniteScroll.event.scrollThreshold),e.on("request",salla.infiniteScroll.event.request),e.on("load",salla.infiniteScroll.event.load),e.on("append",salla.infiniteScroll.event.append),e.on("error",salla.infiniteScroll.event.error),e.on("last",salla.infiniteScroll.event.last),e.on("history",salla.infiniteScroll.event.history),this.instances.push(e),e}salla.log(t?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!")}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,i){return e instanceof FormData?e.append(t,i):e[t]=i,e}function number(t,e=!1){t+="";var i,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],r=["0","1","2","3","4","5","6","7","8","9"],s=(e=e||!salla.config.get("store.settings.arabic_numbers_enabled"))?n:r,a=e?r:n;for(let e=0;e<s.length;e++)i=new RegExp(s[e],"g"),t=t.replace(i,a[e]);return t}function digitsOnly(e){return number(e,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")}function inputDigitsOnly(t,i=!1){if("string"==typeof t)return document.querySelectorAll(t).forEach(e=>inputDigitsOnly(e,i));if(t){let e=salla.helpers.digitsOnly(t.value);return t.min&&e<t.min?t.value=t.min:t.max&&e>t.max?t.value=t.max:1<=t.maxLength&&e.toString().length>t.maxLength?t.value=e.toString().substring(0,t.maxLength):t.value=i||t.dataset.hasOwnProperty("digitsWithDecimal")?getOnlyDecimal(e):e.replace(/\D/g,"")}salla.log("Can't find Object With Id: "+t)}function getOnlyDecimal(e){var 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}function debounce(i,t){t=t||100;let n,r=[];return function(...e){return clearTimeout(n),n=setTimeout(()=>{let t=i(...e);r.forEach(e=>e(t)),r=[]},t),new Promise(e=>r.push(e))}}function getInputDataWithName(t,i,n={}){if(t.includes("[")){let e=t.split("]").join("").split("[");return{name:e[0],value:getLeveledData(e.slice(1),i,n[e[0]])}}return{name:t,value:i}}function getLeveledData(e,t,i){var n=e[0];return i&&0==e.length?Array.isArray(i)?(i.push(t),i):[i,t]:Array.isArray(i)?(i.push(t),i):"string"==typeof i?[i,t]:i?(i[n]=getLeveledData(e.slice(1),t,i[n]),i):n?{[n]:getLeveledData(e.slice(1),t)}:""===n?[t]:t}function setNested(e,t,i){let n=e,r=t.split("."),s=r.length;for(let e=0;e<s-1;e++){var a=r[e];n[a]||(n[a]={}),n=n[a]}return n[r[s-1]]=i,e}function getNested(e,t,i){var n;for(n of t.split(".")){try{e=e[n]}catch(t){e=i||void 0}if(!e)return e}return e}function url(e){return salla.config.get("store.url","/")+e}function addParamToUrl(e,t){if(!t||!e)return window.location.href;let i=new RegExp("([?&])"+e+"=[^&]+[&]?","g"),n=window.location.href.replace(i,"$1").replace(/&$|\?$/,"");return(n+=(n.includes("?")?"&":"?")+e+"="+encodeURIComponent(t)).replace(/&$|\?$/,"")}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):this).toStudlyCase()},String.prototype.toSelector=function(){return this.trim().startsWith(".")||this.trim().startsWith("#")?this:"#"+this},String.prototype.replaceArray=function(e,t){for(var i,n=this,r=0;r<e.length;r++)i=new RegExp(e[r],"g"),n=n.replace(i,t[r]);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+"]*"),"")},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(n,...r){if(this.getAttribute){if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(n){}var s=this.getAttribute("data-function");if(s&&window[s])return"function"==typeof window[s]?this.getFilteredData(window[s].call(this,...r)):this.getFilteredData(window[s]);let e=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if((e="FORM"!==this.tagName&&(e||this.closest("form")||this.closest("[salla-form-data]"))||this)&&"FORM"===e.tagName)return this.getFilteredData(new FormData(e),null,e);let t=e.querySelectorAll("[name]");if(!t.length)return this.getFilteredData();let i=Object.assign({},this.dataset);return t.forEach(t=>{if(!["checkbox","radio"].includes(t.type)||t.checked)try{var e=salla.helpers.inputData(t.name,t.value,i);i[e.name]=e.value}catch(e){salla.log(t.name+" can't be send")}}),this.getFilteredData(i)}},Element.prototype.canEventFireHook=function(e){return!!this.hasAttribute&&this.hasAttribute(salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(t,i){t=t.toLowerCase();for(var n=0;n<this.attributes.length;n++){let e=this.attributes[n].name.toLowerCase();if(0===e.indexOf(t))return!i||e}return!1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]'),i=(t.forEach(e=>{e.files.length||e.setAttribute("disabled","")}),new FormData(this));return t.forEach(e=>{e.files.length||e.removeAttribute("disabled")}),{formData:this.getFilteredData(i,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(i=null,n=null,r=null){return i=i||r?.dataset||this.dataset,r&&this.name&&void 0!==this.value&&(i=injectValueToFromData(i,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach(e=>{e=r?.dataset[e]||this.dataset[e];if(e){var t=window[e];if("function"==typeof t){if(!t(i,r||this,n)&&i)throw`Data failed to be pass verify function window.${e}(formData, element, event)!`;return t(i,r||this,n)}salla.log("window."+e+"() not found!")}}),i},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}}},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:url,addParamToUrl:addParamToUrl,debounce:debounce};class AppHelpers{toggleClassIf(e,t,i,n){return document.querySelectorAll(e).forEach(e=>this.toggleElementClassIf(e,t,i,n)),this}toggleElementClassIf(e,t,i,n){t=Array.isArray(t)?t:t.split(" "),i=Array.isArray(i)?i:i.split(" ");n=n(e);return e?.classList.remove(...n?i:t),e?.classList.add(...n?t:i),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(t,e,i,n={}){return"object"==typeof e?this.element(e).addEventListener(t,i,n):document.querySelectorAll(e).forEach(e=>e.addEventListener(t,i,n)),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 i=t;if("SubmitEvent"===t?.constructor?.name){if(t.preventDefault(),"FORM"!==t.target?.tagName)return salla.log("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(),i=t.target.getElementSallaData(),salla.log("Data from element",i)}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,i,"post").finally(()=>{loaderSupported&&t?.submitter?.parentElement.stop()});let n=e.split("."),r=n.splice(-1);return salla.call(n.join("."))[r](i).finally(()=>t?.submitter?.parentElement?.stop()).catch(e=>{throw salla.log(e),e})}}class SallaCookie{constructor(e){e.on("cookies::remove",e=>this.remove(e)),e.on("cookies::add",(e,t)=>this.set(e,t))}get(t){return document.cookie.split("; ").find(e=>e.startsWith(t+"="))?.split("=")[1]}set(e,t="",i=10){let n="";if(i){let e=new Date;e.setTime(e.getTime()+24*i*60*60*1e3),n="; expires="+e.toUTCString()}return document.cookie=`${e}=${t}${n}"; 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.properties_=e||{debug:"development"===process.env.NODE_ENV,token:null,fastRequests:!0,canLeave:!0,currencies:{SAR:{code:"SAR",name:"ريال سعودي",symbol:"ر.س",amount:1,country_code:"sa"}}}}merge(e){return Object.assign(this.properties_,e),this}set(e,t){return e.includes(".")?salla.helpers.setNested(this.properties_,e,t):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||void 0}isUser(){return"user"===this.get("user.type")}isGuest(){return!this.isUser()}async languages(e=!0){if(this.languages_.length||this.triedToGetLanguages_)return this.languages_;if(this.languages_=Object.values(this.get("languages",{})),!e||this.languages_.length)return this.languages_;this.triedToGetLanguages_=!0;let t=await salla.document.api.request("languages",null,"get"),i=salla.url("");return this.languages_=t&&t.data?t.data.map(e=>(e.code=e.code||e.iso_code,e.url=i+e.code,e.is_rtl=e.is_rtl||e.rtl,e)):[]}async currencies(){if(this.triedToGetCurrencies_)return this.currencies_;this.triedToGetCurrencies_=!0;let e=await salla.currency.api.list();return this.currencies_=e&&e.data?e.data.map(e=>(e.country_code=e.code.substr(0,2).toLowerCase(),e)):[]}currency(e){return this.get("currencies."+e)||Object.values(this.get("currencies"))[0]}languageCode(){return this.get("user.language_code",window.locale||navigator.language||navigator.userLanguage||"ar")}}var lang={exports:{}},Lang=(lang.exports=function(){function l(e){return"-Inf"===e?-1/0:"+Inf"===e||"Inf"===e||"*"===e?1/0:parseInt(e,10)}function e(e){this.locale=(e=e||{}).locale||function(){if("undefined"!=typeof document&&document.documentElement)return document.documentElement.lang}()||t,this.fallback=e.fallback,this.messages=e.messages}var c=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/,u=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/,t="en";return e.prototype.setMessages=function(e){this.messages=e},e.prototype.getLocale=function(){return this.locale||this.fallback},e.prototype.setLocale=function(e){this.locale=e},e.prototype.getFallback=function(){return this.fallback},e.prototype.setFallback=function(e){this.fallback=e},e.prototype.has=function(e,t){return!("string"!=typeof e||!this.messages)&&null!==this._getMessage(e,t)},e.prototype.get=function(e,t,i){if(!this.has(e,i))return e;i=this._getMessage(e,i);return null===i?e:i=t?this._applyReplacements(i,t):i},e.prototype.trans=function(e,t){return this.get(e,t)},e.prototype.choice=function(e,t,i,n){(i=void 0!==i?i:{}).count=t;i=this.get(e,i,n);if(null==i)return i;for(var r,s=i.split("|"),a=[],o=0;o<s.length;o++)s[o]=s[o].trim(),u.test(s[o])&&(r=s[o].split(/\s/),a.push(r.shift()),s[o]=r.join(" "));if(1===s.length)return i;for(var l=0;l<a.length;l++)if(this._testInterval(t,a[l]))return s[l];return n=n||this._getLocale(e),s[this._getPluralForm(t,n)]},e.prototype.transChoice=function(e,t,i){return this.choice(e,t,i)},e.prototype._parseKey=function(e,t){if("string"!=typeof e||"string"!=typeof t)return null;var e=e.split("."),i=e[0].replace(/\//g,".");return{source:t+"."+i,sourceFallback:this.getFallback()+"."+i,entries:e.slice(1)}},e.prototype._getMessage=function(e,t){if(t=t||this.getLocale(),e=this._parseKey(e,t),void 0===this.messages[e.source]&&void 0===this.messages[e.sourceFallback])return null;var i=this.messages[e.source],n=e.entries.slice(),r=n.join(".");if("string"!=typeof(i=void 0!==i?this._getValueInKey(i,r):void 0)&&this.messages[e.sourceFallback])for(i=this.messages[e.sourceFallback],n=e.entries.slice(),r="";n.length&&void 0!==i;)i[r=r?r.concat(".",n.shift()):n.shift()]&&(i=i[r],r="");return"string"!=typeof i?null:i},e.prototype._getValueInKey=function(e,t){if("string"==typeof e[t])return e[t];for(var i=(t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),n=0,r=i.length;n<r;++n){var s=i.slice(0,n+1).join("."),a=i.slice(n+1,i.length).join(".");if(e[s])return this._getValueInKey(e[s],a)}return e},e.prototype._getLocale=function(e){return e=this._parseKey(e,this.locale),this.messages[e.source]?this.locale:this.messages[e.sourceFallback]?this.fallback:null},e.prototype._findMessageInTree=function(e,t){for(;e.length&&void 0!==t;){var i=e.join(".");if(t[i]){t=t[i];break}t=t[e.shift()]}return t},e.prototype._sortReplacementKeys=function(e,t){return t.length-e.length},e.prototype._applyReplacements=function(e,n){return Object.keys(n).sort(this._sortReplacementKeys).forEach(function(i){e=e.replace(new RegExp(":"+i,"gi"),function(e){var t=n[i];return e===e.toUpperCase()?t.toUpperCase():e===e.replace(/\w/i,function(e){return e.toUpperCase()})?t.charAt(0).toUpperCase()+t.slice(1):t})}),e},e.prototype._testInterval=function(e,t){if("string"!=typeof t)throw"Invalid interval: should be a string.";var i,n,r,s=(t=t.trim()).match(c);if(!s)throw"Invalid interval: "+t;if(!s[2])return t=(s=s.filter(function(e){return!!e}))[1],(i=l(s[2]))===1/0&&(i=-1/0),n=l(s[3]),r=s[4],("["===t?i<=e:i<e)&&("]"===r?e<=n:e<n);for(var a=s[2].split(","),o=0;o<a.length;o++)if(parseInt(a[o],10)===e)return!0;return!1},e.prototype._getPluralForm=function(e,t){switch(t){case"az":case"bo":case"dz":case"id":case"ja":case"jv":case"ka":case"km":case"kn":case"ko":case"ms":case"th":case"tr":case"vi":case"zh":default:return 0;case"af":case"bn":case"bg":case"ca":case"da":case"de":case"el":case"en":case"eo":case"es":case"et":case"eu":case"fa":case"fi":case"fo":case"fur":case"fy":case"gl":case"gu":case"ha":case"he":case"hu":case"is":case"it":case"ku":case"lb":case"ml":case"mn":case"mr":case"nah":case"nb":case"ne":case"nl":case"nn":case"no":case"om":case"or":case"pa":case"pap":case"ps":case"pt":case"so":case"sq":case"sv":case"sw":case"ta":case"te":case"tk":case"ur":case"zu":return 1==e?0:1;case"am":case"bh":case"fil":case"fr":case"gun":case"hi":case"hy":case"ln":case"mg":case"nso":case"xbr":case"ti":case"wa":return 0===e||1===e?0:1;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return e%10==1&&e%100!=11?0:2<=e%10&&e%10<=4&&(e%100<10||20<=e%100)?1:2;case"cs":case"sk":return 1==e?0:2<=e&&e<=4?1:2;case"ga":return 1==e?0:2==e?1:2;case"lt":return e%10==1&&e%100!=11?0:2<=e%10&&(e%100<10||20<=e%100)?1:2;case"sl":return e%100==1?0:e%100==2?1:e%100==3||e%100==4?2:3;case"mk":return e%10==1?0:1;case"mt":return 1==e?0:0===e||1<e%100&&e%100<11?1:10<e%100&&e%100<20?2:3;case"lv":return 0===e?0:e%10==1&&e%100!=11?1:2;case"pl":return 1==e?0:2<=e%10&&e%10<=4&&(e%100<12||14<e%100)?1:2;case"cy":return 1==e?0:2==e?1:8==e||11==e?2:3;case"ro":return 1==e?0:0===e||0<e%100&&e%100<20?1:2;case"ar":return 0===e?0:1==e?1:2==e?2:3<=e%100&&e%100<=10?3:11<=e%100&&e%100<=99?4:5}},e}(),lang.exports);class SallaLang extends Lang{constructor(e){(e=e||{}).messages=e.messages||window.translations,e.locale=e.locale||window.locale||navigator.language||navigator.userLanguage||"ar",e.fallback=e.fallback||e.locale,super(e),this.translationsLoaded=!1}onLoaded(e){if(this.translationsLoaded)return e();salla.event.on("languages::translations.loaded",e)}loadStoreTranslations(){var e=salla.config.get("store.url")?.rtrim("/");if(this.setLocale(salla.config.languageCode()),!e)return this.messages&&salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0,void salla.log("There is no `store.url` to auto loading translations from it!");let t=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),i=document.createElement("script");i.src=e+`/languages/assets/${t}.js`,i.onload=()=>{if(window.translations)return this.setMessages(window.translations),salla.event.dispatch("languages::translations.loaded"),void(this.translationsLoaded=!0);console.warn('You should load Salla Translations Before!\nUse: <script src="{{ link("languages/assets/{theme.translations_hash}.js") }}"><\/script>\nor: salla.lang.setMessages({....}), see https://github.com/rmariuzzo/Lang.js for more informations.')},document.head.appendChild(i)}get(e,t,i){return window.translations&&(e="trans."+e),super.get(e,t,i)}set(e,t){return salla.helpers.setNested(this.messages[this.getLocale()+".trans"],e,t),this}}var assign=make_assign(),create$1=make_create(),trim$1=make_trim(),Global$5="undefined"!=typeof window?window:commonjsGlobal,util$6={assign:assign,create:create$1,trim:trim$1,bind:bind$1,slice:slice$1,each:each$7,map:map,pluck:pluck$1,isList:isList$1,isFunction:isFunction$1,isObject:isObject$1,Global:Global$5};function make_assign(){return Object.assign||function(i,e,t,n){for(var r=1;r<arguments.length;r++)each$7(Object(arguments[r]),function(e,t){i[t]=e});return i}}function make_create(){return Object.create?function(e,t,i,n){var r=slice$1(arguments,1);return assign.apply(this,[Object.create(e)].concat(r))}:function(e,t,i,n){var r=slice$1(arguments,1);return s.prototype=e,assign.apply(this,[new s].concat(r))};function s(){}}function make_trim(){return String.prototype.trim?function(e){return String.prototype.trim.call(e)}:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}}function bind$1(e,t){return function(){return t.apply(e,Array.prototype.slice.call(arguments,0))}}function slice$1(e,t){return Array.prototype.slice.call(e,t||0)}function each$7(e,i){pluck$1(e,function(e,t){return i(e,t),!1})}function map(e,i){var n=isList$1(e)?[]:{};return pluck$1(e,function(e,t){return n[t]=i(e,t),!1}),n}function pluck$1(e,t){if(isList$1(e)){for(var i=0;i<e.length;i++)if(t(e[i],i))return e[i]}else for(var n in e)if(e.hasOwnProperty(n)&&t(e[n],n))return e[n]}function isList$1(e){return null!=e&&"function"!=typeof e&&"number"==typeof e.length}function isFunction$1(e){return e&&"[object Function]"==={}.toString.call(e)}function isObject$1(e){return e&&"[object Object]"==={}.toString.call(e)}var util$5=util$6,slice=util$5.slice,pluck=util$5.pluck,each$6=util$5.each,bind=util$5.bind,create=util$5.create,isList=util$5.isList,isFunction=util$5.isFunction,isObject=util$5.isObject,storeEngine={createStore:createStore},storeAPI={version:"2.0.12",enabled:!1,get:function(e,t){e=this.storage.read(this._namespacePrefix+e);return this._deserialize(e,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(i){var n=this;this.storage.each(function(e,t){i.call(n,n._deserialize(e),(t||"").replace(n._namespaceRegexp,""))})},clearAll:function(){this.storage.clearAll()},hasNamespace:function(e){return this._namespacePrefix=="__storejs_"+e+"_"},createStore:function(){return createStore.apply(this,arguments)},addPlugin:function(e){this._addPlugin(e)},namespace:function(e){return createStore(this.storage,this.plugins,e)}};function _warn(){var e="undefined"==typeof console?null:console;e&&(e.warn||e.log).apply(e,arguments)}function createStore(e,t,i){i=i||"",e&&!isList(e)&&(e=[e]),t&&!isList(t)&&(t=[t]);var n=i?"__storejs_"+i+"_":"",r=i?new RegExp("^"+n):null;if(!/^[a-zA-Z0-9_\-]*$/.test(i))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var s=create({_namespacePrefix:n,_namespaceRegexp:r,_testStorage:function(e){try{var t="__storejs__test__",i=(e.write(t,t),e.read(t)===t);return e.remove(t),i}catch(e){return!1}},_assignPluginFnProp:function(n,e){var r=this[e];this[e]=function(){var i=slice(arguments,0),e=this;var t=[function(){if(r)return each$6(arguments,function(e,t){i[t]=e}),r.apply(e,i)}].concat(i);return n.apply(e,t)}},_serialize:function(e){return JSON.stringify(e)},_deserialize:function(e,t){if(!e)return t;var i="";try{i=JSON.parse(e)}catch(t){i=e}return void 0!==i?i:t},_addStorage:function(e){this.enabled||this._testStorage(e)&&(this.storage=e,this.enabled=!0)},_addPlugin:function(i){var n=this;if(isList(i))each$6(i,function(e){n._addPlugin(e)});else if(!pluck(this.plugins,function(e){return i===e})){if(this.plugins.push(i),!isFunction(i))throw new Error("Plugins must be function values that return objects");var e=i.call(this);if(!isObject(e))throw new Error("Plugins must return an object of function properties");each$6(e,function(e,t){if(!isFunction(e))throw new Error("Bad plugin property: "+t+" from plugin "+i.name+". Plugins should only return functions.");n._assignPluginFnProp(e,t)})}},addStorage:function(e){_warn("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(e)}},storeAPI,{plugins:[]});return s.raw={},each$6(s,function(e,t){isFunction(e)&&(s.raw[t]=bind(s,e))}),each$6(e,function(e){s._addStorage(e)}),each$6(t,function(e){s._addPlugin(e)}),s}var util$4=util$6,Global$4=util$4.Global,localStorage_1={name:"localStorage",read:read$5,write:write$5,each:each$5,remove:remove$5,clearAll:clearAll$5};function localStorage(){return Global$4.localStorage}function read$5(e){return localStorage().getItem(e)}function write$5(e,t){return localStorage().setItem(e,t)}function each$5(e){for(var t=localStorage().length-1;0<=t;t--){var i=localStorage().key(t);e(read$5(i),i)}}function remove$5(e){return localStorage().removeItem(e)}function clearAll$5(){return localStorage().clear()}var util$3=util$6,Global$3=util$3.Global,oldFFGlobalStorage={name:"oldFF-globalStorage",read:read$4,write:write$4,each:each$4,remove:remove$4,clearAll:clearAll$4},globalStorage=Global$3.globalStorage;function read$4(e){return globalStorage[e]}function write$4(e,t){globalStorage[e]=t}function each$4(e){for(var t=globalStorage.length-1;0<=t;t--){var i=globalStorage.key(t);e(globalStorage[i],i)}}function remove$4(e){return globalStorage.removeItem(e)}function clearAll$4(){each$4(function(e,t){delete globalStorage[e]})}var util$2=util$6,Global$2=util$2.Global,oldIEUserDataStorage={name:"oldIE-userDataStorage",write:write$3,read:read$3,each:each$3,remove:remove$3,clearAll:clearAll$3},storageName="storejs",doc$1=Global$2.document,_withStorageEl=_makeIEStorageElFunction(),disable=(Global$2.navigator?Global$2.navigator.userAgent:"").match(/ (MSIE 8|MSIE 9|MSIE 10)\./);function write$3(e,t){var i;disable||(i=fixKey(e),_withStorageEl(function(e){e.setAttribute(i,t),e.save(storageName)}))}function read$3(e){var t,i;if(!disable)return t=fixKey(e),i=null,_withStorageEl(function(e){i=e.getAttribute(t)}),i}function each$3(r){_withStorageEl(function(e){for(var t=e.XMLDocument.documentElement.attributes,i=t.length-1;0<=i;i--){var n=t[i];r(e.getAttribute(n.name),n.name)}})}function remove$3(e){var t=fixKey(e);_withStorageEl(function(e){e.removeAttribute(t),e.save(storageName)})}function clearAll$3(){_withStorageEl(function(e){var t=e.XMLDocument.documentElement.attributes;e.load(storageName);for(var i=t.length-1;0<=i;i--)e.removeAttribute(t[i].name);e.save(storageName)})}var forbiddenCharsRegex=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g");function fixKey(e){return e.replace(/^\d/,"___$&").replace(forbiddenCharsRegex,"___")}function _makeIEStorageElFunction(){if(!doc$1||!doc$1.documentElement||!doc$1.documentElement.addBehavior)return null;var i,e,n;try{(e=new ActiveXObject("htmlfile")).open(),e.write('<script>document.w=window<\/script><iframe src="/favicon.ico"></iframe>'),e.close(),i=e.w.frames[0].document,n=i.createElement("div")}catch(e){n=doc$1.createElement("div"),i=doc$1.body}return function(e){var t=[].slice.call(arguments,0);t.unshift(n),i.appendChild(n),n.addBehavior("#default#userData"),n.load(storageName),e.apply(this,t),i.removeChild(n)}}var util$1=util$6,Global$1=util$1.Global,trim=util$1.trim,cookieStorage={name:"cookieStorage",read:read$2,write:write$2,each:each$2,remove:remove$2,clearAll:clearAll$2},doc=Global$1.document;function read$2(e){if(!e||!_has(e))return null;e="(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(doc.cookie.replace(new RegExp(e),"$1"))}function each$2(e){for(var t,i,n=doc.cookie.split(/; ?/g),r=n.length-1;0<=r;r--)trim(n[r])&&(t=n[r].split("="),i=unescape(t[0]),e(unescape(t[1]),i))}function write$2(e,t){e&&(doc.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/")}function remove$2(e){e&&_has(e)&&(doc.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function clearAll$2(){each$2(function(e,t){remove$2(t)})}function _has(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(doc.cookie)}var util=util$6,Global=util.Global,sessionStorage_1={name:"sessionStorage",read:read$1,write:write$1,each:each$1,remove:remove$1,clearAll:clearAll$1};function sessionStorage(){return Global.sessionStorage}function read$1(e){return sessionStorage().getItem(e)}function write$1(e,t){return sessionStorage().setItem(e,t)}function each$1(e){for(var t=sessionStorage().length-1;0<=t;t--){var i=sessionStorage().key(t);e(read$1(i),i)}}function remove$1(e){return sessionStorage().removeItem(e)}function clearAll$1(){return sessionStorage().clear()}var memoryStorage_1={name:"memoryStorage",read:read,write:write,each:each,remove:remove,clearAll:clearAll},memoryStorage={};function read(e){return memoryStorage[e]}function write(e,t){memoryStorage[e]=t}function each(e){for(var t in memoryStorage)memoryStorage.hasOwnProperty(t)&&e(memoryStorage[t],t)}function remove(e){delete memoryStorage[e]}function clearAll(e){memoryStorage={}}var all=[localStorage_1,oldFFGlobalStorage,oldIEUserDataStorage,cookieStorage,sessionStorage_1,memoryStorage_1],json2=("object"!=typeof JSON&&(JSON={}),function(){var rx_one=/^[\],:{}\s]*$/,rx_two=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,rx_three=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,rx_four=/(?:^|:|,)(?:\s*\[)+/g,rx_escapable=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,rx_dangerous=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta,rep;function f(e){return e<10?"0"+e:e}function this_value(){return this.valueOf()}function quote(e){return rx_escapable.lastIndex=0,rx_escapable.test(e)?'"'+e.replace(rx_escapable,function(e){var t=meta[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var i,n,r,s,a,o=gap,l=t[e];switch(l&&"object"==typeof l&&"function"==typeof l.toJSON&&(l=l.toJSON(e)),typeof(l="function"==typeof rep?rep.call(t,e,l):l)){case"string":return quote(l);case"number":return isFinite(l)?String(l):"null";case"boolean":case"null":return String(l);case"object":if(!l)return"null";if(gap+=indent,a=[],"[object Array]"===Object.prototype.toString.apply(l)){for(s=l.length,i=0;i<s;i+=1)a[i]=str(i,l)||"null";return r=0===a.length?"[]":gap?"[\n"+gap+a.join(",\n"+gap)+"\n"+o+"]":"["+a.join(",")+"]",gap=o,r}if(rep&&"object"==typeof rep)for(s=rep.length,i=0;i<s;i+=1)"string"==typeof rep[i]&&(r=str(n=rep[i],l))&&a.push(quote(n)+(gap?": ":":")+r);else for(n in l)Object.prototype.hasOwnProperty.call(l,n)&&(r=str(n,l))&&a.push(quote(n)+(gap?": ":":")+r);return r=0===a.length?"{}":gap?"{\n"+gap+a.join(",\n"+gap)+"\n"+o+"}":"{"+a.join(",")+"}",gap=o,r}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},Boolean.prototype.toJSON=this_value,Number.prototype.toJSON=this_value,String.prototype.toJSON=this_value),"function"!=typeof JSON.stringify&&(meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},JSON.stringify=function(e,t,i){var n;if(indent=gap="","number"==typeof i)for(n=0;n<i;n+=1)indent+=" ";else"string"==typeof i&&(indent=i);if(!(rep=t)||"function"==typeof t||"object"==typeof t&&"number"==typeof t.length)return str("",{"":e});throw new Error("JSON.stringify")}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){var j;function walk(e,t){var i,n,r=e[t];if(r&&"object"==typeof r)for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(void 0!==(n=walk(r,i))?r[i]=n:delete r[i]);return reviver.call(e,t,r)}if(text=String(text),rx_dangerous.lastIndex=0,rx_dangerous.test(text)&&(text=text.replace(rx_dangerous,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})),rx_one.test(text.replace(rx_two,"@").replace(rx_three,"]").replace(rx_four,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),json2Plugin);function json2Plugin(){return{}}var engine=storeEngine,storages=all,plugins=[json2],store_legacy=engine.createStore(storages,plugins);class SallaStorage{constructor(e){e.on("storage::item.remove",e=>this.remove(e)),e.on("storage::item.set",(e,t)=>this.set(e,t)),this.store=store_legacy}set(e,t){var i,n;return e.includes(".")?(n={[i=e.split(".")[0]]:store_legacy.get(i)},n=salla.helpers.setNested(n,e,t),store_legacy.set(i,n[i])):store_legacy.set(e,t)}remove(e){return store_legacy.remove(e)}get(e,t){var i;return e.includes(".")?(i=e.split(".")[0],salla.helpers.getNested({[i]:store_legacy.get(i)},e)):store_legacy.get(e,t)}}let event$1=new sallaEmitter,api=new SallaApi(event$1);window.Salla=window.salla={notify:Notify,api:api,event:event$1,helpers:Helpers,config:new SallaConfig,storage:new SallaStorage(event$1),cookie:new SallaCookie(event$1),lang:new SallaLang,form:new SallaForm,cart:new Action(api.cart,event$1.cart),auth:new Action(api.auth,event$1.auth),gift:new Action(api.gift,event$1.gift),order:new Action(api.order,event$1.order),offer:new Action(api.offer,event$1.offer),scope:new Action(api.scope,event$1.scope),search:new Action(api.search,event$1.search),coupon:new Action(api.coupon,event$1.coupon),rating:new Action(api.rating,event$1.rating),comment:new Action(api.comment,event$1.comment),loyalty:new Action(api.loyalty,event$1.loyalty),product:new Action(api.product,event$1.product),profile:new Action(api.profile,event$1.profile),currency:new Action(api.currency,event$1.currency),document:new Action(api.document,event$1.document),twilight:new Action(api.twilight,event$1.twilight),wishlist:new Action(api.wishlist,event$1.wishlist),log:Notify.log,success:Notify.success,error:Notify.error,onReady:e=>document.addEventListener("DOMContentLoaded",e),AppHelpers:AppHelpers,infiniteScroll:new InfiniteScroll(void 0,event$1.infiniteScroll),money:Helpers.money,url:Helpers.url,init:e=>api.twilight.init(e),call:e=>{let t=salla,i=e.split(".");for(;i.length&&(t=t[i.shift()]););return t}};var salla$1=salla;exports.default=salla$1});
12
+ `,document.body.prepend(e)}))}handleElementAjaxRequest(e,t){if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.log("trying to call ajax from non Element!!"),!1;e.preventDefault();let i=t.getAjaxFormData(e),n=i.method?i.method.toLowerCase():void 0;salla.api.document.request(i.url,i.formData,n).then(e=>(e.data&&e.request&&(e=e.data),salla.api.document.handleAfterResponseActions(e),this.callAjaxEvent(i.events.success,e,i.formData),e)).catch(e=>{throw salla.api.document.handleErrorResponse(e),this.callAjaxEvent(i.events.fail,e,i.formData),e})}callAjaxEvent(e,t,i){var n;e&&(i instanceof FormData&&(n={},Array.from(i.entries()).forEach(function(e){n[e[0]]=e[1]}),i=n),window[e]?window[e](t,i):salla.event.dispatch(e,t,i))}}class TwilightApi extends BaseApi{constructor(e){super(e),this.namespace="twilight",this.after_init()}init(e){var t=e?.events;return this.initiated||(delete e.events,new SallaInit(e),this.initiated=!0),t&&salla.event.dispatchEvents(t),this.successPromise(e)}api(e){var t=e?.events;return t&&salla.event.dispatchEvents(t),this.successPromise(e)}}class WishlistApi extends BaseApi{constructor(e){super(e),this.namespace="wishlist",this.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},this.endpointsMethods={remove:"delete"},this.after_init()}toggle(e){return salla.storage.get("salla::wishlist",[]).includes(e)?this.remove(e):this.add(e)}add(t){let e;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(e=salla.lang.get("common.messages.must_login")),salla.error(e),this.errorPromise(e)):(t=t&&t.data?this.getPossibleValue(t.data,["product_id","id"]):t)?this.request(["add",t]).then(e=>(this.updateWishlistStorage(t),salla.wishlist.event.added(e,t),e)).catch(function(e){throw salla.wishlist.event.additionFailed(e,t),e}):(salla.wishlist.event.additionFailed(e="Failed to get product id!"),this.errorPromise(e))}remove(t){let e;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(e=salla.lang.get("common.messages.must_login")),salla.error(e),this.errorPromise(e)):(t=t?.data?this.getPossibleValue(t.data,["id","prod_id"]):t)?this.request(["remove",t]).then(e=>(this.updateWishlistStorage(t,!1),salla.wishlist.event.removed(e,t),e)).catch(function(e){throw salla.wishlist.event.removingFailed(e,t),e}):(salla.wishlist.event.removingFailed(e="Failed to get id!"),this.errorPromise(e))}updateWishlistStorage(e,t=!0){let i=salla.storage.get("salla::wishlist",[]);t?i.push(e):i.splice(i.indexOf(e),1),salla.storage.set("salla::wishlist",i)}}class ScopeApi extends BaseApi{constructor(e){super(e),this.namespace="scope",this.endpoints={getAll:"/scopes",submit:"/scope"},this.webEndpoints=["getAll","submit"],this.endpointsMethods={getAll:"get"},this.after_init()}getAll(){return this.request("getAll",{from:"header"}).then(function(e){return console.log(e),e}).catch(function(e){throw e})}submit(e){return this.request("submit",e).then(function(e){return console.log(e),e}).catch(function(e){throw e})}}function e(e){this.message=e}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var i=String(t).replace(/=+$/,"");if(i.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,s=0,a=0,o="";r=i.charAt(a++);~r&&(n=s%4?64*n+r:r,s++%4)&&(o+=String.fromCharCode(255&n>>(-2*s&6))))r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return o};function t(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return decodeURIComponent(r(t).replace(/(.)/g,function(e,t){t=t.charCodeAt(0).toString(16).toUpperCase();return"%"+(t=t.length<2?"0"+t:t)}))}catch(e){return r(t)}}function n(e){this.message=e}function o(e,i){if("string"!=typeof e)throw new n("Invalid token specified");i=!0===(i=i||{}).header?0:1;try{return JSON.parse(t(e.split(".")[i]))}catch(e){throw new n("Invalid token specified: "+e.message)}}n.prototype=new Error,n.prototype.name="InvalidTokenError";const axios=require("axios");class sallaRequest{constructor(e){return e.on("twilight::initiated",()=>this.initiateRequest()),e.on("auth::token.fetched",e=>this.handleToken(e)),axios.create({baseURL:window.baseUrl,headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"","S-APP-OS":""}}})}initiateRequest(){salla.api.defaults.baseURL=salla.config.get("store.url",window.baseUrl),salla.api.defaults.headers.common["Store-Identifier"]=salla.config.get("store.id"),salla.api.defaults.headers.common.currency=salla.config.get("user.currency_code","SAR"),salla.api.defaults.headers.common["accept-language"]=salla.config.languageCode(),this.injectTokenToTheRequests()}injectTokenToTheRequests(){var e=salla.storage.get("token"),t=salla.config.isGuest(),i=salla.storage.get("cart");if(i&&i.user_id!==salla.config.get("user.id"))return salla.log("Auth:: The cart is not belong to current user!"),void salla.cart.api.reset();if(!t||e){if(t&&e)return salla.log("Auth:: Token without user!"),salla.storage.remove("token"),void salla.cart.api.reset();if(!e)return salla.cart.api.reset(),void salla.auth.api.refresh();i=o(e);return Date.now()/1e3>i.exp?(salla.log("Auth:: An expired token!"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh()):i.sub!==salla.config.get("user.id")?(salla.log("Auth:: The user id is not match the token details!"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh()):void this.setToken(e)}}handleToken(e){salla.storage.set("token",e),this.setToken(e),salla.cart.api.reset()}setToken(e){salla.api.defaults.headers.common.Authorization="Bearer "+e}}class SallaApi extends sallaRequest{constructor(e){super(e),this.apis={auth:new AuthApi(this),cart:new CartApi(this),gift:new GiftApi(this),loyalty:new LoyalityApi(this),order:new OrderApi(this),offer:new OfferApi(this),coupon:new CouponApi(this),rating:new RatingApi(this),search:new SearchApi(this),product:new ProductApi(this),profile:new ProfileApi(this),comment:new CommentApi(this),currency:new CurrencyApi(this),document:new DocumentApi(this),twilight:new TwilightApi(this),wishlist:new WishlistApi(this),scope:new ScopeApi(this)},Object.assign(this,this.apis),this.getHeaders=()=>this.defaults.headers.common}}class Action{constructor(i,n){return this.api=i,this.event=n,new Proxy(this,{get:function(e,t){return"event"===t?n:"api"===t?i:i&&i[t]||e[t]}})}}var js={exports:{}},core={exports:{}},evEmitter={exports:{}},utils=(!function(e){var t,i;t="undefined"!=typeof window?window:commonjsGlobal,i=function(){function e(){}let t=e.prototype;return t.on=function(e,t){if(!e||!t)return this;let i=this._events=this._events||{},n=i[e]=i[e]||[];return n.includes(t)||n.push(t),this},t.once=function(e,t){if(!e||!t)return this;this.on(e,t);let i=this._onceEvents=this._onceEvents||{};return(i[e]=i[e]||{})[t]=!0,this},t.off=function(e,t){let i=this._events&&this._events[e];if(!i||!i.length)return this;e=i.indexOf(t);return-1!=e&&i.splice(e,1),this},t.emitEvent=function(e,t){let i=this._events&&this._events[e];if(!i||!i.length)return this;i=i.slice(0),t=t||[];let n=this._onceEvents&&this._onceEvents[e];for(var r of i)n&&n[r]&&(this.off(e,r),delete n[r]),r.apply(this,t);return this},t.allOff=function(){return delete this._events,delete this._onceEvents,this},e},e.exports?e.exports=i():t.EvEmitter=i()}(evEmitter),{exports:{}}),pageLoad=(!function(e){var t,i;t=commonjsGlobal,i=function(t){let n={extend:function(e,t){return Object.assign(e,t)},modulo:function(e,t){return(e%t+t)%t},makeArray:function(e){return Array.isArray(e)?e:null==e?[]:"object"==typeof e&&"number"==typeof e.length?[...e]:[e]},removeFrom:function(e,t){t=e.indexOf(t);-1!=t&&e.splice(t,1)},getParent:function(e,t){for(;e.parentNode&&e!=document.body;)if((e=e.parentNode).matches(t))return e},getQueryElement:function(e){return"string"==typeof e?document.querySelector(e):e},handleEvent:function(e){var t="on"+e.type;this[t]&&this[t](e)},filterFindElements:function(e,i){return(e=n.makeArray(e)).filter(e=>e instanceof HTMLElement).reduce((e,t)=>{if(!i)return e.push(t),e;t.matches(i)&&e.push(t);t=t.querySelectorAll(i);return e.concat(...t)},[])},debounceMethod:function(e,t,i){i=i||100;let n=e.prototype[t],r=t+"Timeout";e.prototype[t]=function(){clearTimeout(this[r]);let e=arguments;this[r]=setTimeout(()=>{n.apply(this,e),delete this[r]},i)}},docReady:function(e){var t=document.readyState;"complete"==t||"interactive"==t?setTimeout(e):document.addEventListener("DOMContentLoaded",e)},toDashed:function(e){return e.replace(/(.)([A-Z])/g,function(e,t,i){return t+"-"+i}).toLowerCase()}},l=t.console;return n.htmlInit=function(a,o){n.docReady(function(){let r="data-"+n.toDashed(o),e=document.querySelectorAll(`[${r}]`),s=t.jQuery;[...e].forEach(e=>{let t,i=e.getAttribute(r);try{t=i&&JSON.parse(i)}catch(t){return void(l&&l.error(`Error parsing ${r} on ${e.className}: `+t))}var n=new a(e,t);s&&s.data(e,o,n)})})},n},e.exports?e.exports=i(t):t.fizzyUIUtils=i(t)}(utils),function(e){var t,i;t=window,i=function(t,e,n){let r=t.jQuery,s={};function a(t,i){var e=n.getQueryElement(t);if(e){if((t=e).infiniteScrollGUID){let e=s[t.infiniteScrollGUID];return e.option(i),e}this.element=t,this.options={...a.defaults},this.option(i),r&&(this.$element=r(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(e||t))}a.defaults={},a.create={},a.destroy={};let i=a.prototype,o=(Object.assign(i,e.prototype),0),l=(i.create=function(){var e=this.guid=++o;if(this.element.infiniteScrollGUID=e,(s[e]=this).pageIndex=1,this.loadCount=0,this.updateGetPath(),this.getPath&&this.getPath())for(var t in this.updateGetAbsolutePath(),this.log("initialized",[this.element.className]),this.callOnInit(),a.create)a.create[t].call(this);else console.error("Disabling InfiniteScroll")},i.option=function(e){Object.assign(this.options,e)},i.callOnInit=function(){let e=this.options.onInit;e&&e.call(this,this)},i.dispatchEvent=function(i,n,e){this.log(i,e);var t=n?[n].concat(e):e;if(this.emitEvent(i,t),r&&this.$element){let t=i+=".infiniteScroll";if(n){let e=r.Event(n);e.type=i,t=e}this.$element.trigger(t,e)}},{initialized:e=>"on "+e,request:e=>"URL: "+e,load:(e,t)=>`${e.title||""}. URL: `+t,error:(e,t)=>e+". URL: "+t,append:(e,t,i)=>i.length+" items. URL: "+t,last:(e,t)=>"URL: "+t,history:(e,t)=>"URL: "+t,pageIndex:function(e,t){return`current page determined to be: ${e} from `+t}}),c=(i.log=function(i,n){if(this.options.debug){let e="[InfiniteScroll] "+i,t=l[i];t&&(e+=". "+t.apply(this,n)),console.log(e)}},i.updateMeasurements=function(){this.windowHeight=t.innerHeight;var e=this.element.getBoundingClientRect();this.top=e.top+t.scrollY},i.updateScroller=function(){var e=this.options.elementScroll;if(e){if(this.scroller=!0===e?this.element:n.getQueryElement(e),!this.scroller)throw new Error("Unable to find elementScroll: "+e)}else this.scroller=t},i.updateGetPath=function(){let e=this.options.path;var t;e?"function"!=(t=typeof e)?"string"==t&&e.match("{{#}}")?this.updateGetPathTemplate(e):this.updateGetPathSelector(e):this.getPath=e:console.error("InfiniteScroll path option required. Set as: "+e)},i.updateGetPathTemplate=function(t){this.getPath=()=>{var e=this.pageIndex+1;return t.replace("{{#}}",e)};var e=t.replace(/(\\\?|\?)/,"\\?").replace("{{#}}","(\\d\\d?\\d?)"),e=new RegExp(e),e=location.href.match(e);e&&(this.pageIndex=parseInt(e[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))},[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/]),u=a.getPathParts=function(e){if(e)for(var t of c){var i,n,t=e.match(t);if(t)return[,t,i,n]=t,{begin:t,index:i,end:n}}},h=(i.updateGetPathSelector=function(e){let t=document.querySelector(e);if(t){var i=t.getAttribute("href"),n=u(i);if(n){let{begin:e,index:t,end:i}=n;this.isPathSelector=!0,this.getPath=()=>e+(this.pageIndex+1)+i,this.pageIndex=parseInt(t,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])}else console.error("InfiniteScroll unable to parse next link href: "+i)}else console.error("Bad InfiniteScroll path option. Next link not found: "+e)},i.updateGetAbsolutePath=function(){let r=this.getPath();if(r.match(/^http/)||r.match(/^\//))this.getAbsolutePath=this.getPath;else{let e=location["pathname"],t=r.match(/^\?/),i=e.substring(0,e.lastIndexOf("/")),n=t?e:i+"/";this.getAbsolutePath=()=>n+this.getPath()}},a.create.hideNav=function(){let e=n.getQueryElement(this.options.hideNav);e&&(e.style.display="none",this.nav=e)},a.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},i.destroy=function(){for(var e in this.allOff(),a.destroy)a.destroy[e].call(this);delete this.element.infiniteScrollGUID,delete s[this.guid],r&&this.$element&&r.removeData(this.element,"infiniteScroll")},a.throttle=function(n,r){let s,a;return r=r||200,function(){let e=+new Date,t=arguments,i=()=>{s=e,n.apply(this,t)};s&&e<s+r?(clearTimeout(a),a=setTimeout(i,r)):i()}},a.data=function(e){e=(e=n.getQueryElement(e))&&e.infiniteScrollGUID;return e&&s[e]},a.setJQuery=function(e){r=e},n.htmlInit(a,"infinite-scroll"),i._init=function(){},t)["jQueryBridget"];return r&&h&&h("infiniteScroll",a,r),a},e.exports?e.exports=i(t,evEmitter.exports,utils.exports):t.InfiniteScroll=i(t,t.EvEmitter,t.fizzyUIUtils)}(core),{exports:{}}),scrollWatch=(!function(e){var t,i;t=window,i=function(t,r){let e=r.prototype,s=(Object.assign(r.defaults,{loadOnScroll:!0,checkLastPage:!0,responseBody:"text",domParseResponse:!0}),r.create.pageLoad=function(){this.canLoad=!0,this.on("scrollThreshold",this.onScrollThresholdLoad),this.on("load",this.checkLastPage),this.options.outlayer&&this.on("append",this.onAppendOutlayer)},e.onScrollThresholdLoad=function(){this.options.loadOnScroll&&this.loadNextPage()},new DOMParser);function u(e){let t=document.createDocumentFragment();return e&&t.append(...e),t}return e.loadNextPage=function(){if(!this.isLoading&&this.canLoad){let{responseBody:i,domParseResponse:n,fetchOptions:e}=this.options,r=this.getAbsolutePath();this.isLoading=!0,"function"==typeof e&&(e=e());var t=fetch(r,e).then(t=>{var e;return t.ok?t[i]().then(e=>("text"==i&&n&&(e=s.parseFromString(e,"text/html")),204==t.status?(this.lastPageReached(e,r),{body:e,response:t}):this.onPageLoad(e,r,t))):(e=new Error(t.statusText),this.onPageError(e,r,t),{response:t})}).catch(e=>{this.onPageError(e,r)});return this.dispatchEvent("request",null,[r,t]),t}},e.onPageLoad=function(e,t,i){return this.options.append||(this.isLoading=!1),this.pageIndex++,this.loadCount++,this.dispatchEvent("load",null,[e,t,i]),this.appendNextPage(e,t,i)},e.appendNextPage=function(e,t,i){var{append:n,responseBody:r,domParseResponse:s}=this.options;if("text"!=r||!s||!n)return{body:e,response:i};let a=e.querySelectorAll(n),o={body:e,response:i,items:a};if(!a||!a.length)return this.lastPageReached(e,t),o;let l=u(a),c=()=>(this.appendItems(a,l),this.isLoading=!1,this.dispatchEvent("append",null,[e,t,a,i]),o);return this.options.outlayer?this.appendOutlayerItems(l,c):c()},e.appendItems=function(e,t){if(e&&e.length){var i;for(i of(t=t||u(e)).querySelectorAll("script")){let e=document.createElement("script"),t=i.attributes;for(var n of t)e.setAttribute(n.name,n.value);e.innerHTML=i.innerHTML,i.parentNode.replaceChild(e,i)}this.element.appendChild(t)}},e.appendOutlayerItems=function(e,i){let n=r.imagesLoaded||t.imagesLoaded;return n?new Promise(function(t){n(e,function(){var e=i();t(e)})}):(console.error("[InfiniteScroll] imagesLoaded required for outlayer option"),void(this.isLoading=!1))},e.onAppendOutlayer=function(e,t,i){this.options.outlayer.appended(i)},e.checkLastPage=function(e,t){let i,{checkLastPage:n,path:r}=this.options;n&&("function"!=typeof r||this.getPath()?("string"==typeof n?i=n:this.isPathSelector&&(i=r),i&&e.querySelector&&(e.querySelector(i)||this.lastPageReached(e,t))):this.lastPageReached(e,t))},e.lastPageReached=function(e,t){this.canLoad=!1,this.dispatchEvent("last",null,[e,t])},e.onPageError=function(e,t,i){return this.isLoading=!1,this.canLoad=!1,this.dispatchEvent("error",null,[e,t,i]),e},r.create.prefill=function(){var e;this.options.prefill&&((e=this.options.append)?(this.updateMeasurements(),this.updateScroller(),this.isPrefilling=!0,this.on("append",this.prefill),this.once("error",this.stopPrefill),this.once("last",this.stopPrefill),this.prefill()):console.error("append option required for prefill. Set as :"+e))},e.prefill=function(){var e=this.getPrefillDistance();this.isPrefilling=0<=e,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},e.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},e.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},r},e.exports?e.exports=i(t,core.exports):i(t,t.InfiniteScroll)}(pageLoad),{exports:{}}),history$1=(!function(e){var t,i;t=window,i=function(i,e,t){let n=e.prototype;return Object.assign(e.defaults,{scrollThreshold:400}),e.create.scrollWatch=function(){this.pageScrollHandler=this.onPageScroll.bind(this),this.resizeHandler=this.onResize.bind(this);var e=this.options.scrollThreshold;!e&&0!==e||this.enableScrollWatch()},e.destroy.scrollWatch=function(){this.disableScrollWatch()},n.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},n.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},n.bindScrollWatchEvents=function(e){e=e?"addEventListener":"removeEventListener";this.scroller[e]("scroll",this.pageScrollHandler),i[e]("resize",this.resizeHandler)},n.onPageScroll=e.throttle(function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")}),n.getBottomDistance=function(){let e,t;return t=this.options.elementScroll?(e=this.scroller.scrollHeight,this.scroller.scrollTop+this.scroller.clientHeight):(e=this.top+this.element.clientHeight,i.scrollY+this.windowHeight),e-t},n.onResize=function(){this.updateMeasurements()},t.debounceMethod(e,"onResize",150),e},e.exports?e.exports=i(t,core.exports,utils.exports):i(t,t.InfiniteScroll,t.fizzyUIUtils)}(scrollWatch),{exports:{}}),button=(!function(e){var t,i;t=window,i=function(n,e,t){let i=e.prototype,r=(Object.assign(e.defaults,{history:"replace"}),document.createElement("a"));return e.create.history=function(){this.options.history&&(r.href=this.getAbsolutePath(),(r.origin||r.protocol+"//"+r.host)==location.origin?this.options.append?this.createHistoryAppend():this.createHistoryPageLoad():console.error(`[InfiniteScroll] cannot set history with different origin: ${r.origin} on ${location.origin} . History behavior disabled.`))},i.createHistoryAppend=function(){this.updateMeasurements(),this.updateScroller(),this.scrollPages=[{top:0,path:location.href,title:document.title}],this.scrollPage=this.scrollPages[0],this.scrollHistoryHandler=this.onScrollHistory.bind(this),this.unloadHandler=this.onUnload.bind(this),this.scroller.addEventListener("scroll",this.scrollHistoryHandler),this.on("append",this.onAppendHistory),this.bindHistoryAppendEvents(!0)},i.bindHistoryAppendEvents=function(e){e=e?"addEventListener":"removeEventListener";this.scroller[e]("scroll",this.scrollHistoryHandler),n[e]("unload",this.unloadHandler)},i.createHistoryPageLoad=function(){this.on("load",this.onPageLoadHistory)},e.destroy.history=i.destroyHistory=function(){this.options.history&&this.options.append&&this.bindHistoryAppendEvents(!1)},i.onAppendHistory=function(e,t,i){i&&i.length&&(i=i[0],i=this.getElementScrollY(i),r.href=t,this.scrollPages.push({top:i,path:r.href,title:e.title}))},i.getElementScrollY=function(e){return this.options.elementScroll?e.offsetTop-this.top:e.getBoundingClientRect().top+n.scrollY},i.onScrollHistory=function(){var e=this.getClosestScrollPage();e!=this.scrollPage&&(this.scrollPage=e,this.setHistory(e.title,e.path))},t.debounceMethod(e,"onScrollHistory",150),i.getClosestScrollPage=function(){let e,t;e=this.options.elementScroll?this.scroller.scrollTop+this.scroller.clientHeight/2:n.scrollY+this.windowHeight/2;for(var i of this.scrollPages){if(i.top>=e)break;t=i}return t},i.setHistory=function(e,t){var i=this.options.history;i&&history[i+"State"]&&(history[i+"State"](null,e,t),this.options.historyTitle&&(document.title=e),this.dispatchEvent("history",null,[e,t]))},i.onUnload=function(){var e;0!==this.scrollPage.top&&(e=n.scrollY-this.scrollPage.top+this.top,this.destroyHistory(),scrollTo(0,e))},i.onPageLoadHistory=function(e,t){this.setHistory(e.title,t)},e},e.exports?e.exports=i(t,core.exports,utils.exports):i(t,t.InfiniteScroll,t.fizzyUIUtils)}(history$1),{exports:{}}),status=(!function(e){var t,i;t=window,i=function(e,t,i){class n{constructor(e,t){this.element=e,this.infScroll=t,this.clickHandler=this.onClick.bind(this),this.element.addEventListener("click",this.clickHandler),t.on("request",this.disable.bind(this)),t.on("load",this.enable.bind(this)),t.on("error",this.hide.bind(this)),t.on("last",this.hide.bind(this))}onClick(e){e.preventDefault(),this.infScroll.loadNextPage()}enable(){this.element.removeAttribute("disabled")}disable(){this.element.disabled="disabled"}hide(){this.element.style.display="none"}destroy(){this.element.removeEventListener("click",this.clickHandler)}}return t.create.button=function(){var e=i.getQueryElement(this.options.button);e&&(this.button=new n(e,this))},t.destroy.button=function(){this.button&&this.button.destroy()},t.Button=n,t},e.exports?e.exports=i(0,core.exports,utils.exports):i(0,t.InfiniteScroll,t.fizzyUIUtils)}(button),{exports:{}}),TheInfiniteScroll=(!function(e){var t,i;t=window,i=function(e,t,i){let n=t.prototype;function r(e){a(e,"none")}function s(e){a(e,"block")}function a(e,t){e&&(e.style.display=t)}return t.create.status=function(){let e=i.getQueryElement(this.options.status);e&&(this.statusElement=e,this.statusEventElements={request:e.querySelector(".infinite-scroll-request"),error:e.querySelector(".infinite-scroll-error"),last:e.querySelector(".infinite-scroll-last")},this.on("request",this.showRequestStatus),this.on("error",this.showErrorStatus),this.on("last",this.showLastStatus),this.bindHideStatus("on"))},n.bindHideStatus=function(e){var t=this.options.append?"append":"load";this[e](t,this.hideAllStatus)},n.showRequestStatus=function(){this.showStatus("request")},n.showErrorStatus=function(){this.showStatus("error")},n.showLastStatus=function(){this.showStatus("last"),this.bindHideStatus("off")},n.showStatus=function(e){s(this.statusElement),this.hideStatusEventElements(),s(this.statusEventElements[e])},n.hideAllStatus=function(){r(this.statusElement),this.hideStatusEventElements()},n.hideStatusEventElements=function(){for(var e in this.statusEventElements)r(this.statusEventElements[e])},t},e.exports?e.exports=i(0,core.exports,utils.exports):i(0,t.InfiniteScroll,t.fizzyUIUtils)}(status),function(e){window,e.exports&&(e.exports=(e=core.exports,pageLoad.exports,scrollWatch.exports,history$1.exports,button.exports,status.exports,e))}(js),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,i){i=this.getCustomOptions(t,i);t="string"!=typeof e?e:document.querySelector(e),e=i.path;if(t&&e&&("string"!=typeof e||document.querySelector(e))){let e=new TheInfiniteScroll(t,i);return e.on("scrollThreshold",salla.infiniteScroll.event.scrollThreshold),e.on("request",salla.infiniteScroll.event.request),e.on("load",salla.infiniteScroll.event.load),e.on("append",salla.infiniteScroll.event.append),e.on("error",salla.infiniteScroll.event.error),e.on("last",salla.infiniteScroll.event.last),e.on("history",salla.infiniteScroll.event.history),this.instances.push(e),e}salla.log(t?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!")}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,i){return e instanceof FormData?e.append(t,i):e[t]=i,e}function number(t,e=!1){t+="";var i,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],r=["0","1","2","3","4","5","6","7","8","9"],s=(e=e||!salla.config.get("store.settings.arabic_numbers_enabled"))?n:r,a=e?r:n;for(let e=0;e<s.length;e++)i=new RegExp(s[e],"g"),t=t.replace(i,a[e]);return t}function digitsOnly(e){return number(e,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")}function inputDigitsOnly(t,i=!1){if("string"==typeof t)return document.querySelectorAll(t).forEach(e=>inputDigitsOnly(e,i));if(t){let e=salla.helpers.digitsOnly(t.value);return t.min&&e<t.min?t.value=t.min:t.max&&e>t.max?t.value=t.max:1<=t.maxLength&&e.toString().length>t.maxLength?t.value=e.toString().substring(0,t.maxLength):t.value=i||t.dataset.hasOwnProperty("digitsWithDecimal")?getOnlyDecimal(e):e.replace(/\D/g,"")}salla.log("Can't find Object With Id: "+t)}function getOnlyDecimal(e){var 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}function debounce(i,t){t=t||100;let n,r=[];return function(...e){return clearTimeout(n),n=setTimeout(()=>{let t=i(...e);r.forEach(e=>e(t)),r=[]},t),new Promise(e=>r.push(e))}}function getInputDataWithName(t,i,n={}){if(t.includes("[")){let e=t.split("]").join("").split("[");return{name:e[0],value:getLeveledData(e.slice(1),i,n[e[0]])}}return{name:t,value:i}}function getLeveledData(e,t,i){var n=e[0];return i&&0==e.length?Array.isArray(i)?(i.push(t),i):[i,t]:Array.isArray(i)?(i.push(t),i):"string"==typeof i?[i,t]:i?(i[n]=getLeveledData(e.slice(1),t,i[n]),i):n?{[n]:getLeveledData(e.slice(1),t)}:""===n?[t]:t}function setNested(e,t,i){let n=e,r=t.split("."),s=r.length;for(let e=0;e<s-1;e++){var a=r[e];n[a]||(n[a]={}),n=n[a]}return n[r[s-1]]=i,e}function getNested(e,t,i){var n;for(n of t.split(".")){try{e=e[n]}catch(t){e=i||void 0}if(!e)return e}return e}function url(e){return salla.config.get("store.url","/")+e}function addParamToUrl(e,t){if(!t||!e)return window.location.href;let i=new RegExp("([?&])"+e+"=[^&]+[&]?","g"),n=window.location.href.replace(i,"$1").replace(/&$|\?$/,"");return(n+=(n.includes("?")?"&":"?")+e+"="+encodeURIComponent(t)).replace(/&$|\?$/,"")}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):this).toStudlyCase()},String.prototype.toSelector=function(){return this.trim().startsWith(".")||this.trim().startsWith("#")?this:"#"+this},String.prototype.replaceArray=function(e,t){for(var i,n=this,r=0;r<e.length;r++)i=new RegExp(e[r],"g"),n=n.replace(i,t[r]);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+"]*"),"")},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(n,...r){if(this.getAttribute){if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(n){}var s=this.getAttribute("data-function");if(s&&window[s])return"function"==typeof window[s]?this.getFilteredData(window[s].call(this,...r)):this.getFilteredData(window[s]);let e=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if((e="FORM"!==this.tagName&&(e||this.closest("form")||this.closest("[salla-form-data]"))||this)&&"FORM"===e.tagName)return this.getFilteredData(new FormData(e),null,e);let t=e.querySelectorAll("[name]");if(!t.length)return this.getFilteredData();let i=Object.assign({},this.dataset);return t.forEach(t=>{if(!["checkbox","radio"].includes(t.type)||t.checked)try{var e=salla.helpers.inputData(t.name,t.value,i);i[e.name]=e.value}catch(e){salla.log(t.name+" can't be send")}}),this.getFilteredData(i)}},Element.prototype.canEventFireHook=function(e){return!!this.hasAttribute&&this.hasAttribute(salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(t,i){t=t.toLowerCase();for(var n=0;n<this.attributes.length;n++){let e=this.attributes[n].name.toLowerCase();if(0===e.indexOf(t))return!i||e}return!1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]'),i=(t.forEach(e=>{e.files.length||e.setAttribute("disabled","")}),new FormData(this));return t.forEach(e=>{e.files.length||e.removeAttribute("disabled")}),{formData:this.getFilteredData(i,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(i=null,n=null,r=null){return i=i||r?.dataset||this.dataset,r&&this.name&&void 0!==this.value&&(i=injectValueToFromData(i,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach(e=>{e=r?.dataset[e]||this.dataset[e];if(e){var t=window[e];if("function"==typeof t){if(!t(i,r||this,n)&&i)throw`Data failed to be pass verify function window.${e}(formData, element, event)!`;return t(i,r||this,n)}salla.log("window."+e+"() not found!")}}),i},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}}},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:url,addParamToUrl:addParamToUrl,debounce:debounce};class AppHelpers{toggleClassIf(e,t,i,n){return document.querySelectorAll(e).forEach(e=>this.toggleElementClassIf(e,t,i,n)),this}toggleElementClassIf(e,t,i,n){t=Array.isArray(t)?t:t.split(" "),i=Array.isArray(i)?i:i.split(" ");n=n(e);return e?.classList.remove(...n?i:t),e?.classList.add(...n?t:i),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(t,e,i,n={}){return"object"==typeof e?this.element(e).addEventListener(t,i,n):document.querySelectorAll(e).forEach(e=>e.addEventListener(t,i,n)),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 i=t;if("SubmitEvent"===t?.constructor?.name){if(t.preventDefault(),"FORM"!==t.target?.tagName)return salla.log("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(),i=t.target.getElementSallaData(),salla.log("Data from element",i)}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,i,"post").finally(()=>{loaderSupported&&t?.submitter?.parentElement.stop()});let n=e.split("."),r=n.splice(-1);return salla.call(n.join("."))[r](i).finally(()=>t?.submitter?.parentElement?.stop()).catch(e=>{throw salla.log(e),e})}onSubmit(e,t){return salla.form.submit(e,t),!1}}class SallaCookie{constructor(e){e.on("cookies::remove",e=>this.remove(e)),e.on("cookies::add",(e,t)=>this.set(e,t))}get(t){return document.cookie.split("; ").find(e=>e.startsWith(t+"="))?.split("=")[1]}set(e,t="",i=10){let n="";if(i){let e=new Date;e.setTime(e.getTime()+24*i*60*60*1e3),n="; expires="+e.toUTCString()}return document.cookie=`${e}=${t}${n}"; 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.properties_=e||{debug:"development"===process.env.NODE_ENV,token:null,fastRequests:!0,canLeave:!0,currencies:{SAR:{code:"SAR",name:"ريال سعودي",symbol:"ر.س",amount:1,country_code:"sa"}}}}merge(e){return Object.assign(this.properties_,e),this}set(e,t){return e.includes(".")?salla.helpers.setNested(this.properties_,e,t):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||void 0}isUser(){return"user"===this.get("user.type")}isGuest(){return!this.isUser()}async languages(e=!0){if(this.languages_.length||this.triedToGetLanguages_)return this.languages_;if(this.languages_=Object.values(this.get("languages",{})),!e||this.languages_.length)return this.languages_;this.triedToGetLanguages_=!0;let t=await salla.document.api.request("languages",null,"get"),i=salla.url("");return this.languages_=t&&t.data?t.data.map(e=>(e.code=e.code||e.iso_code,e.url=i+e.code,e.is_rtl=e.is_rtl||e.rtl,e)):[]}async currencies(){if(this.triedToGetCurrencies_)return this.currencies_;this.triedToGetCurrencies_=!0;let e=await salla.currency.api.list();return this.currencies_=e&&e.data?e.data.map(e=>(e.country_code=e.code.substr(0,2).toLowerCase(),e)):[]}currency(e){return this.get("currencies."+e)||Object.values(this.get("currencies"))[0]}languageCode(){return this.get("user.language_code",window.locale||navigator.language||navigator.userLanguage||"ar")}}var lang={exports:{}},Lang=(lang.exports=function(){function l(e){return"-Inf"===e?-1/0:"+Inf"===e||"Inf"===e||"*"===e?1/0:parseInt(e,10)}function e(e){this.locale=(e=e||{}).locale||function(){if("undefined"!=typeof document&&document.documentElement)return document.documentElement.lang}()||t,this.fallback=e.fallback,this.messages=e.messages}var c=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/,u=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/,t="en";return e.prototype.setMessages=function(e){this.messages=e},e.prototype.getLocale=function(){return this.locale||this.fallback},e.prototype.setLocale=function(e){this.locale=e},e.prototype.getFallback=function(){return this.fallback},e.prototype.setFallback=function(e){this.fallback=e},e.prototype.has=function(e,t){return!("string"!=typeof e||!this.messages)&&null!==this._getMessage(e,t)},e.prototype.get=function(e,t,i){if(!this.has(e,i))return e;i=this._getMessage(e,i);return null===i?e:i=t?this._applyReplacements(i,t):i},e.prototype.trans=function(e,t){return this.get(e,t)},e.prototype.choice=function(e,t,i,n){(i=void 0!==i?i:{}).count=t;i=this.get(e,i,n);if(null==i)return i;for(var r,s=i.split("|"),a=[],o=0;o<s.length;o++)s[o]=s[o].trim(),u.test(s[o])&&(r=s[o].split(/\s/),a.push(r.shift()),s[o]=r.join(" "));if(1===s.length)return i;for(var l=0;l<a.length;l++)if(this._testInterval(t,a[l]))return s[l];return n=n||this._getLocale(e),s[this._getPluralForm(t,n)]},e.prototype.transChoice=function(e,t,i){return this.choice(e,t,i)},e.prototype._parseKey=function(e,t){if("string"!=typeof e||"string"!=typeof t)return null;var e=e.split("."),i=e[0].replace(/\//g,".");return{source:t+"."+i,sourceFallback:this.getFallback()+"."+i,entries:e.slice(1)}},e.prototype._getMessage=function(e,t){if(t=t||this.getLocale(),e=this._parseKey(e,t),void 0===this.messages[e.source]&&void 0===this.messages[e.sourceFallback])return null;var i=this.messages[e.source],n=e.entries.slice(),r=n.join(".");if("string"!=typeof(i=void 0!==i?this._getValueInKey(i,r):void 0)&&this.messages[e.sourceFallback])for(i=this.messages[e.sourceFallback],n=e.entries.slice(),r="";n.length&&void 0!==i;)i[r=r?r.concat(".",n.shift()):n.shift()]&&(i=i[r],r="");return"string"!=typeof i?null:i},e.prototype._getValueInKey=function(e,t){if("string"==typeof e[t])return e[t];for(var i=(t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),n=0,r=i.length;n<r;++n){var s=i.slice(0,n+1).join("."),a=i.slice(n+1,i.length).join(".");if(e[s])return this._getValueInKey(e[s],a)}return e},e.prototype._getLocale=function(e){return e=this._parseKey(e,this.locale),this.messages[e.source]?this.locale:this.messages[e.sourceFallback]?this.fallback:null},e.prototype._findMessageInTree=function(e,t){for(;e.length&&void 0!==t;){var i=e.join(".");if(t[i]){t=t[i];break}t=t[e.shift()]}return t},e.prototype._sortReplacementKeys=function(e,t){return t.length-e.length},e.prototype._applyReplacements=function(e,n){return Object.keys(n).sort(this._sortReplacementKeys).forEach(function(i){e=e.replace(new RegExp(":"+i,"gi"),function(e){var t=n[i];return e===e.toUpperCase()?t.toUpperCase():e===e.replace(/\w/i,function(e){return e.toUpperCase()})?t.charAt(0).toUpperCase()+t.slice(1):t})}),e},e.prototype._testInterval=function(e,t){if("string"!=typeof t)throw"Invalid interval: should be a string.";var i,n,r,s=(t=t.trim()).match(c);if(!s)throw"Invalid interval: "+t;if(!s[2])return t=(s=s.filter(function(e){return!!e}))[1],(i=l(s[2]))===1/0&&(i=-1/0),n=l(s[3]),r=s[4],("["===t?i<=e:i<e)&&("]"===r?e<=n:e<n);for(var a=s[2].split(","),o=0;o<a.length;o++)if(parseInt(a[o],10)===e)return!0;return!1},e.prototype._getPluralForm=function(e,t){switch(t){case"az":case"bo":case"dz":case"id":case"ja":case"jv":case"ka":case"km":case"kn":case"ko":case"ms":case"th":case"tr":case"vi":case"zh":default:return 0;case"af":case"bn":case"bg":case"ca":case"da":case"de":case"el":case"en":case"eo":case"es":case"et":case"eu":case"fa":case"fi":case"fo":case"fur":case"fy":case"gl":case"gu":case"ha":case"he":case"hu":case"is":case"it":case"ku":case"lb":case"ml":case"mn":case"mr":case"nah":case"nb":case"ne":case"nl":case"nn":case"no":case"om":case"or":case"pa":case"pap":case"ps":case"pt":case"so":case"sq":case"sv":case"sw":case"ta":case"te":case"tk":case"ur":case"zu":return 1==e?0:1;case"am":case"bh":case"fil":case"fr":case"gun":case"hi":case"hy":case"ln":case"mg":case"nso":case"xbr":case"ti":case"wa":return 0===e||1===e?0:1;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return e%10==1&&e%100!=11?0:2<=e%10&&e%10<=4&&(e%100<10||20<=e%100)?1:2;case"cs":case"sk":return 1==e?0:2<=e&&e<=4?1:2;case"ga":return 1==e?0:2==e?1:2;case"lt":return e%10==1&&e%100!=11?0:2<=e%10&&(e%100<10||20<=e%100)?1:2;case"sl":return e%100==1?0:e%100==2?1:e%100==3||e%100==4?2:3;case"mk":return e%10==1?0:1;case"mt":return 1==e?0:0===e||1<e%100&&e%100<11?1:10<e%100&&e%100<20?2:3;case"lv":return 0===e?0:e%10==1&&e%100!=11?1:2;case"pl":return 1==e?0:2<=e%10&&e%10<=4&&(e%100<12||14<e%100)?1:2;case"cy":return 1==e?0:2==e?1:8==e||11==e?2:3;case"ro":return 1==e?0:0===e||0<e%100&&e%100<20?1:2;case"ar":return 0===e?0:1==e?1:2==e?2:3<=e%100&&e%100<=10?3:11<=e%100&&e%100<=99?4:5}},e}(),lang.exports);class SallaLang extends Lang{constructor(e){(e=e||{}).messages=e.messages||window.translations,e.locale=e.locale||window.locale||navigator.language||navigator.userLanguage||"ar",e.fallback=e.fallback||e.locale,super(e),this.translationsLoaded=!1}onLoaded(e){if(this.translationsLoaded)return e();salla.event.on("languages::translations.loaded",e)}loadStoreTranslations(){var e=salla.config.get("store.url")?.rtrim("/");if(this.setLocale(salla.config.languageCode()),!e)return this.messages&&salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0,void salla.log("There is no `store.url` to auto loading translations from it!");let t=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),i=document.createElement("script");i.src=e+`/languages/assets/${t}.js`,i.onload=()=>{if(window.translations)return this.setMessages(window.translations),salla.event.dispatch("languages::translations.loaded"),void(this.translationsLoaded=!0);console.warn('You should load Salla Translations Before!\nUse: <script src="{{ link("languages/assets/{theme.translations_hash}.js") }}"><\/script>\nor: salla.lang.setMessages({....}), see https://github.com/rmariuzzo/Lang.js for more informations.')},document.head.appendChild(i)}get(e,t,i){return window.translations&&(e="trans."+e),super.get(e,t,i)}set(e,t){return salla.helpers.setNested(this.messages[this.getLocale()+".trans"],e,t),this}}var assign=make_assign(),create$1=make_create(),trim$1=make_trim(),Global$5="undefined"!=typeof window?window:commonjsGlobal,util$6={assign:assign,create:create$1,trim:trim$1,bind:bind$1,slice:slice$1,each:each$7,map:map,pluck:pluck$1,isList:isList$1,isFunction:isFunction$1,isObject:isObject$1,Global:Global$5};function make_assign(){return Object.assign||function(i,e,t,n){for(var r=1;r<arguments.length;r++)each$7(Object(arguments[r]),function(e,t){i[t]=e});return i}}function make_create(){return Object.create?function(e,t,i,n){var r=slice$1(arguments,1);return assign.apply(this,[Object.create(e)].concat(r))}:function(e,t,i,n){var r=slice$1(arguments,1);return s.prototype=e,assign.apply(this,[new s].concat(r))};function s(){}}function make_trim(){return String.prototype.trim?function(e){return String.prototype.trim.call(e)}:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}}function bind$1(e,t){return function(){return t.apply(e,Array.prototype.slice.call(arguments,0))}}function slice$1(e,t){return Array.prototype.slice.call(e,t||0)}function each$7(e,i){pluck$1(e,function(e,t){return i(e,t),!1})}function map(e,i){var n=isList$1(e)?[]:{};return pluck$1(e,function(e,t){return n[t]=i(e,t),!1}),n}function pluck$1(e,t){if(isList$1(e)){for(var i=0;i<e.length;i++)if(t(e[i],i))return e[i]}else for(var n in e)if(e.hasOwnProperty(n)&&t(e[n],n))return e[n]}function isList$1(e){return null!=e&&"function"!=typeof e&&"number"==typeof e.length}function isFunction$1(e){return e&&"[object Function]"==={}.toString.call(e)}function isObject$1(e){return e&&"[object Object]"==={}.toString.call(e)}var util$5=util$6,slice=util$5.slice,pluck=util$5.pluck,each$6=util$5.each,bind=util$5.bind,create=util$5.create,isList=util$5.isList,isFunction=util$5.isFunction,isObject=util$5.isObject,storeEngine={createStore:createStore},storeAPI={version:"2.0.12",enabled:!1,get:function(e,t){e=this.storage.read(this._namespacePrefix+e);return this._deserialize(e,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(i){var n=this;this.storage.each(function(e,t){i.call(n,n._deserialize(e),(t||"").replace(n._namespaceRegexp,""))})},clearAll:function(){this.storage.clearAll()},hasNamespace:function(e){return this._namespacePrefix=="__storejs_"+e+"_"},createStore:function(){return createStore.apply(this,arguments)},addPlugin:function(e){this._addPlugin(e)},namespace:function(e){return createStore(this.storage,this.plugins,e)}};function _warn(){var e="undefined"==typeof console?null:console;e&&(e.warn||e.log).apply(e,arguments)}function createStore(e,t,i){i=i||"",e&&!isList(e)&&(e=[e]),t&&!isList(t)&&(t=[t]);var n=i?"__storejs_"+i+"_":"",r=i?new RegExp("^"+n):null;if(!/^[a-zA-Z0-9_\-]*$/.test(i))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var s=create({_namespacePrefix:n,_namespaceRegexp:r,_testStorage:function(e){try{var t="__storejs__test__",i=(e.write(t,t),e.read(t)===t);return e.remove(t),i}catch(e){return!1}},_assignPluginFnProp:function(n,e){var r=this[e];this[e]=function(){var i=slice(arguments,0),e=this;var t=[function(){if(r)return each$6(arguments,function(e,t){i[t]=e}),r.apply(e,i)}].concat(i);return n.apply(e,t)}},_serialize:function(e){return JSON.stringify(e)},_deserialize:function(e,t){if(!e)return t;var i="";try{i=JSON.parse(e)}catch(t){i=e}return void 0!==i?i:t},_addStorage:function(e){this.enabled||this._testStorage(e)&&(this.storage=e,this.enabled=!0)},_addPlugin:function(i){var n=this;if(isList(i))each$6(i,function(e){n._addPlugin(e)});else if(!pluck(this.plugins,function(e){return i===e})){if(this.plugins.push(i),!isFunction(i))throw new Error("Plugins must be function values that return objects");var e=i.call(this);if(!isObject(e))throw new Error("Plugins must return an object of function properties");each$6(e,function(e,t){if(!isFunction(e))throw new Error("Bad plugin property: "+t+" from plugin "+i.name+". Plugins should only return functions.");n._assignPluginFnProp(e,t)})}},addStorage:function(e){_warn("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(e)}},storeAPI,{plugins:[]});return s.raw={},each$6(s,function(e,t){isFunction(e)&&(s.raw[t]=bind(s,e))}),each$6(e,function(e){s._addStorage(e)}),each$6(t,function(e){s._addPlugin(e)}),s}var util$4=util$6,Global$4=util$4.Global,localStorage_1={name:"localStorage",read:read$5,write:write$5,each:each$5,remove:remove$5,clearAll:clearAll$5};function localStorage(){return Global$4.localStorage}function read$5(e){return localStorage().getItem(e)}function write$5(e,t){return localStorage().setItem(e,t)}function each$5(e){for(var t=localStorage().length-1;0<=t;t--){var i=localStorage().key(t);e(read$5(i),i)}}function remove$5(e){return localStorage().removeItem(e)}function clearAll$5(){return localStorage().clear()}var util$3=util$6,Global$3=util$3.Global,oldFFGlobalStorage={name:"oldFF-globalStorage",read:read$4,write:write$4,each:each$4,remove:remove$4,clearAll:clearAll$4},globalStorage=Global$3.globalStorage;function read$4(e){return globalStorage[e]}function write$4(e,t){globalStorage[e]=t}function each$4(e){for(var t=globalStorage.length-1;0<=t;t--){var i=globalStorage.key(t);e(globalStorage[i],i)}}function remove$4(e){return globalStorage.removeItem(e)}function clearAll$4(){each$4(function(e,t){delete globalStorage[e]})}var util$2=util$6,Global$2=util$2.Global,oldIEUserDataStorage={name:"oldIE-userDataStorage",write:write$3,read:read$3,each:each$3,remove:remove$3,clearAll:clearAll$3},storageName="storejs",doc$1=Global$2.document,_withStorageEl=_makeIEStorageElFunction(),disable=(Global$2.navigator?Global$2.navigator.userAgent:"").match(/ (MSIE 8|MSIE 9|MSIE 10)\./);function write$3(e,t){var i;disable||(i=fixKey(e),_withStorageEl(function(e){e.setAttribute(i,t),e.save(storageName)}))}function read$3(e){var t,i;if(!disable)return t=fixKey(e),i=null,_withStorageEl(function(e){i=e.getAttribute(t)}),i}function each$3(r){_withStorageEl(function(e){for(var t=e.XMLDocument.documentElement.attributes,i=t.length-1;0<=i;i--){var n=t[i];r(e.getAttribute(n.name),n.name)}})}function remove$3(e){var t=fixKey(e);_withStorageEl(function(e){e.removeAttribute(t),e.save(storageName)})}function clearAll$3(){_withStorageEl(function(e){var t=e.XMLDocument.documentElement.attributes;e.load(storageName);for(var i=t.length-1;0<=i;i--)e.removeAttribute(t[i].name);e.save(storageName)})}var forbiddenCharsRegex=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g");function fixKey(e){return e.replace(/^\d/,"___$&").replace(forbiddenCharsRegex,"___")}function _makeIEStorageElFunction(){if(!doc$1||!doc$1.documentElement||!doc$1.documentElement.addBehavior)return null;var i,e,n;try{(e=new ActiveXObject("htmlfile")).open(),e.write('<script>document.w=window<\/script><iframe src="/favicon.ico"></iframe>'),e.close(),i=e.w.frames[0].document,n=i.createElement("div")}catch(e){n=doc$1.createElement("div"),i=doc$1.body}return function(e){var t=[].slice.call(arguments,0);t.unshift(n),i.appendChild(n),n.addBehavior("#default#userData"),n.load(storageName),e.apply(this,t),i.removeChild(n)}}var util$1=util$6,Global$1=util$1.Global,trim=util$1.trim,cookieStorage={name:"cookieStorage",read:read$2,write:write$2,each:each$2,remove:remove$2,clearAll:clearAll$2},doc=Global$1.document;function read$2(e){if(!e||!_has(e))return null;e="(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(doc.cookie.replace(new RegExp(e),"$1"))}function each$2(e){for(var t,i,n=doc.cookie.split(/; ?/g),r=n.length-1;0<=r;r--)trim(n[r])&&(t=n[r].split("="),i=unescape(t[0]),e(unescape(t[1]),i))}function write$2(e,t){e&&(doc.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/")}function remove$2(e){e&&_has(e)&&(doc.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function clearAll$2(){each$2(function(e,t){remove$2(t)})}function _has(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(doc.cookie)}var util=util$6,Global=util.Global,sessionStorage_1={name:"sessionStorage",read:read$1,write:write$1,each:each$1,remove:remove$1,clearAll:clearAll$1};function sessionStorage(){return Global.sessionStorage}function read$1(e){return sessionStorage().getItem(e)}function write$1(e,t){return sessionStorage().setItem(e,t)}function each$1(e){for(var t=sessionStorage().length-1;0<=t;t--){var i=sessionStorage().key(t);e(read$1(i),i)}}function remove$1(e){return sessionStorage().removeItem(e)}function clearAll$1(){return sessionStorage().clear()}var memoryStorage_1={name:"memoryStorage",read:read,write:write,each:each,remove:remove,clearAll:clearAll},memoryStorage={};function read(e){return memoryStorage[e]}function write(e,t){memoryStorage[e]=t}function each(e){for(var t in memoryStorage)memoryStorage.hasOwnProperty(t)&&e(memoryStorage[t],t)}function remove(e){delete memoryStorage[e]}function clearAll(e){memoryStorage={}}var all=[localStorage_1,oldFFGlobalStorage,oldIEUserDataStorage,cookieStorage,sessionStorage_1,memoryStorage_1],json2=("object"!=typeof JSON&&(JSON={}),function(){var rx_one=/^[\],:{}\s]*$/,rx_two=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,rx_three=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,rx_four=/(?:^|:|,)(?:\s*\[)+/g,rx_escapable=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,rx_dangerous=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta,rep;function f(e){return e<10?"0"+e:e}function this_value(){return this.valueOf()}function quote(e){return rx_escapable.lastIndex=0,rx_escapable.test(e)?'"'+e.replace(rx_escapable,function(e){var t=meta[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var i,n,r,s,a,o=gap,l=t[e];switch(l&&"object"==typeof l&&"function"==typeof l.toJSON&&(l=l.toJSON(e)),typeof(l="function"==typeof rep?rep.call(t,e,l):l)){case"string":return quote(l);case"number":return isFinite(l)?String(l):"null";case"boolean":case"null":return String(l);case"object":if(!l)return"null";if(gap+=indent,a=[],"[object Array]"===Object.prototype.toString.apply(l)){for(s=l.length,i=0;i<s;i+=1)a[i]=str(i,l)||"null";return r=0===a.length?"[]":gap?"[\n"+gap+a.join(",\n"+gap)+"\n"+o+"]":"["+a.join(",")+"]",gap=o,r}if(rep&&"object"==typeof rep)for(s=rep.length,i=0;i<s;i+=1)"string"==typeof rep[i]&&(r=str(n=rep[i],l))&&a.push(quote(n)+(gap?": ":":")+r);else for(n in l)Object.prototype.hasOwnProperty.call(l,n)&&(r=str(n,l))&&a.push(quote(n)+(gap?": ":":")+r);return r=0===a.length?"{}":gap?"{\n"+gap+a.join(",\n"+gap)+"\n"+o+"}":"{"+a.join(",")+"}",gap=o,r}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},Boolean.prototype.toJSON=this_value,Number.prototype.toJSON=this_value,String.prototype.toJSON=this_value),"function"!=typeof JSON.stringify&&(meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},JSON.stringify=function(e,t,i){var n;if(indent=gap="","number"==typeof i)for(n=0;n<i;n+=1)indent+=" ";else"string"==typeof i&&(indent=i);if(!(rep=t)||"function"==typeof t||"object"==typeof t&&"number"==typeof t.length)return str("",{"":e});throw new Error("JSON.stringify")}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){var j;function walk(e,t){var i,n,r=e[t];if(r&&"object"==typeof r)for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(void 0!==(n=walk(r,i))?r[i]=n:delete r[i]);return reviver.call(e,t,r)}if(text=String(text),rx_dangerous.lastIndex=0,rx_dangerous.test(text)&&(text=text.replace(rx_dangerous,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})),rx_one.test(text.replace(rx_two,"@").replace(rx_three,"]").replace(rx_four,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),json2Plugin);function json2Plugin(){return{}}var engine=storeEngine,storages=all,plugins=[json2],store_legacy=engine.createStore(storages,plugins);class SallaStorage{constructor(e){e.on("storage::item.remove",e=>this.remove(e)),e.on("storage::item.set",(e,t)=>this.set(e,t)),this.store=store_legacy}set(e,t){var i,n;return e.includes(".")?(n={[i=e.split(".")[0]]:store_legacy.get(i)},n=salla.helpers.setNested(n,e,t),store_legacy.set(i,n[i])):store_legacy.set(e,t)}remove(e){return store_legacy.remove(e)}get(e,t){var i;return e.includes(".")?(i=e.split(".")[0],salla.helpers.getNested({[i]:store_legacy.get(i)},e)):store_legacy.get(e,t)}}let event$1=new sallaEmitter,api=new SallaApi(event$1);window.Salla=window.salla={notify:Notify,api:api,event:event$1,helpers:Helpers,config:new SallaConfig,storage:new SallaStorage(event$1),cookie:new SallaCookie(event$1),lang:new SallaLang,form:new SallaForm,cart:new Action(api.cart,event$1.cart),auth:new Action(api.auth,event$1.auth),gift:new Action(api.gift,event$1.gift),order:new Action(api.order,event$1.order),offer:new Action(api.offer,event$1.offer),scope:new Action(api.scope,event$1.scope),search:new Action(api.search,event$1.search),coupon:new Action(api.coupon,event$1.coupon),rating:new Action(api.rating,event$1.rating),comment:new Action(api.comment,event$1.comment),loyalty:new Action(api.loyalty,event$1.loyalty),product:new Action(api.product,event$1.product),profile:new Action(api.profile,event$1.profile),currency:new Action(api.currency,event$1.currency),document:new Action(api.document,event$1.document),twilight:new Action(api.twilight,event$1.twilight),wishlist:new Action(api.wishlist,event$1.wishlist),log:Notify.log,success:Notify.success,error:Notify.error,onReady:e=>document.addEventListener("DOMContentLoaded",e),AppHelpers:AppHelpers,infiniteScroll:new InfiniteScroll(void 0,event$1.infiniteScroll),money:Helpers.money,url:Helpers.url,init:e=>api.twilight.init(e),call:e=>{let t=salla,i=e.split(".");for(;i.length&&(t=t[i.shift()]););return t}};var salla$1=salla;exports.default=salla$1});
13
13
  //# sourceMappingURL=twilight.min.js.map