@salla.sa/twilight 2.12.2 → 2.12.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("process"),require("buffer")):"function"==typeof define&&define.amd?define(["process","buffer"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).process$1,e.buffer)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(e),a=function(e,t,n){return alert(e)},i=function(e,t){return a(e,o.error,t)},o={error:"error",success:"success",info:"info"},s={fire:function(e,t,n){return a(e,t,n)},setNotifier:function(e){a=e,salla.event.emit("twilight::notifier.changed")},error:i,success:function(e,t){return a(e,o.success,t)},info:function(e,t){return a(e,o.info,t)},sallaInitiated:function(){var e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&(window.history.replaceState(null,document.title,window.location.pathname),salla.event.once("twilight::notifier.changed",(function(){e.forEach((function(e){i(decodeURI(e.replace("?danger=","").replace("&danger=","")),{})}))})))},types:o},l=function(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(n,r){return"event"===r?t:"api"===r?e:e&&e[r]||n[r]}})},c=function(e,t){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},c(e,t)};function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var d=function(){return d=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},d.apply(this,arguments)};function h(e,t,n,r){return new(n||(n=Promise))((function(a,i){function o(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}l((r=r.apply(e,t||[])).next())}))}function f(e,t){var n,r,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(a=o.trys,(a=a.length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){o.label=s[1];break}if(6===s[0]&&o.label<a[1]){o.label=a[1],a=s;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(s);break}a[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function p(e,t,n){if(n||2===arguments.length)for(var r,a=0,i=t.length;a<i;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){for(var t=this;t;){if(t.matches(e))return t;t=t.parentElement}}),Element.prototype.getElementSallaData=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if(this.getAttribute){if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}var a=this.getAttribute("data-function");if(a&&window[a])return"function"==typeof window[a]?this.getFilteredData((t=window[a]).call.apply(t,p([this],n,!1))):this.getFilteredData(window[a]);var i=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if((i="FORM"===this.tagName?this:i||this.closest("form")||this.closest("[salla-form-data]")||this)&&"FORM"===i.tagName)return this.getFilteredData(new FormData(i),null,i);var o=i.querySelectorAll("[name]");if(!o.length)return this.getFilteredData();var s=Object.assign({},this.dataset);return o.forEach((function(e){if(!["checkbox","radio"].includes(e.type)||e.checked)try{var t=Salla.helpers.inputData(e.name,e.value,s);s[t.name]=t.value}catch(t){Salla.log(e.name+" can't be send")}})),this.getFilteredData(s)}},Element.prototype.canEventFireHook=function(e){return!!this.hasAttribute&&this.hasAttribute(Salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(e,t){e=e.toLowerCase();for(var n=0;n<this.attributes.length;n++){var r=this.attributes[n].name.toLowerCase();if(0===r.indexOf(e))return!t||r}return!1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((function(e){e.files.length||e.setAttribute("disabled","")}));var n=new FormData(this);return t.forEach((function(e){e.files.length||e.removeAttribute("disabled")})),{formData:this.getFilteredData(n,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(e,t,n){var r=this;return void 0===e&&(e=null),void 0===t&&(t=null),void 0===n&&(n=null),e=e||(null==n?void 0:n.dataset)||this.dataset,n&&this.name&&void 0!==this.value&&(e=function(e,t,n){e instanceof FormData?e.append(t,n):e[t]=n;return e}(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((function(a){var i=(null==n?void 0:n.dataset[a])||r.dataset[a];if(i){var o=window[i];if("function"==typeof o){if(!o(e,n||r,t)&&e)throw"Data failed to be pass verify function window.".concat(i,"(formData, element, event)!");return o(e,n||r,t)}Salla.log("window."+i+"() not found!")}})),e},HTMLAnchorElement.prototype.getAjaxFormData=function(e){return{formData:this.getFilteredData(null,e),url:this.getAttribute("href"),method:this.dataset.type||"get",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}};var g=function(){function e(){this.events={},this.namespace="";var e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase()}return e.prototype.after_init=function(){this.createDynamicFunctions()},e.prototype.createDynamicFunctions=function(){var e=this;Object.keys(this.events).forEach((function(t){e.createDynamicEventFuns(t),e.createDynamicListenerFuns(t)}))},e.prototype.createDynamicEventFuns=function(e){if(!this[e]){var t=this;this[e]=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t.dispatch.apply(t,p([e],n,!1))}}},e.prototype.createDynamicListenerFuns=function(e){var t="on"+e.charAt(0).toUpperCase()+e.slice(1);if(!this[t]){var n=this;this[t]=function(t){var r=this;return n.on(e,(function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return h(r,void 0,void 0,(function(){return f(this,(function(n){return[2,t.apply(void 0,e)]}))}))}))}}},e.prototype.getEventName=function(e){return e=this.events[e]||e,!this.namespace||e.includes("::")?e:this.namespace+Salla.event.delimiter+e},e.prototype.dispatch=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return(t=Salla.event).emitAsync.apply(t,p([this.getEventName(e)],n,!1))},e.prototype.on=function(e,t){return Salla.event.addListener(this.getEventName(e),t)},e.prototype.once=function(e,t){return Salla.event.once(this.getEventName(e),t)},e}(),v=function(e){function t(){var t=e.call(this)||this;return t.namespace="auth",t.events={login:"login",logout:"logout",codeSent:"code.sent",codeNotSent:"code.not-sent",verified:"verified",verificationFailed:"verification.failed",loggedIn:"logged.in",registered:"registered",registrationFailed:"registration.failed",loggedOut:"logged.out",failedLogout:"failed.logout",refreshFailed:"refresh.failed",tokenFetched:"token.fetched"},t.after_init(),t}return u(t,e),t.prototype.login=function(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null,this.dispatch.apply(this,p(["login"],arguments,!1))):(this.next_event=null,this.dispatch.apply(this,p(["login"],arguments,!1)))},t.prototype.loggedIn=function(e){var t=this;return Salla.profile.info().finally((function(){return t.dispatch("loggedIn",e)}))},t.prototype.setTypeActionOnVerified=function(e){this.type_action_on_verified=e},t.prototype.getTypeActionOnVerified=function(){return this.type_action_on_verified||"redirect"},t}(g),m=function(e){function t(){var t=e.call(this)||this;return t.namespace="cart",t.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",itemAddedFailed:"item.added.failed",itemDeleted:"item.deleted",itemDeletedFailed:"item.deleted.failed",submitted:"submitted",submitFailed:"submit.failed",imageDeleted:"image.deleted",imageNotDeleted:"image.not.deleted",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",successReset:"success.reset",priceQuoteSucceeded:"price-quote.succeeded",priceQuoteFailed:"price-quote.failed",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed",quickOrderSettingFetched:"quick-order.fetched",quickOrderSettingFailed:"quick-order.failed",quickOrderSucceeded:"quick-order.succeeded",quickOrderFailed:"quick-order.failed"},t.after_init(),t}return u(t,e),t.prototype.updated=function(e){var t;return Salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.product.event.offerExisted(e.offer),e.redirect&&(salla.log("The current cart is purchased!"),salla.cart.api.reset()),e.cart?(salla.storage.set("cart.summary",{total:e.cart.total,sub_total:e.cart.sub_total,discount:e.cart.discount,real_shipping_cost:e.cart.real_shipping_cost,count:e.cart.count,shipping_cost:(null===(t=e.cart.free_shipping_bar)||void 0===t?void 0:t.has_free_shipping)?0:e.cart.real_shipping_cost}),this.dispatch("updated",e.cart)):void salla.log("Failed to get the cart summary!")):(Salla.logger.info("Cart summary not an object!",e),this.dispatch("updated"))},t.prototype.latestFetched=function(e){return this.updated(e.data),this.dispatch("latestFetched",e)},t.prototype.itemAdded=function(e,t){return this.updated(e.data),this.dispatch("itemAdded",e,t)},t.prototype.itemDeleted=function(e,t){return this.updated(e.data),this.dispatch("itemDeleted",e,t)},t.prototype.itemUpdated=function(e,t){return this.updated(e.data),this.dispatch("itemUpdated",e,t)},t.prototype.couponAdded=function(e,t){return this.updated(e.data),this.dispatch("couponAdded",e,t)},t.prototype.couponDeleted=function(e,t){return this.updated(e.data),this.dispatch("couponDeleted",e,t)},t}(g),y=function(e){function t(){var t=e.call(this)||this;return t.namespace="order",t.events={canceled:"canceled",notCanceled:"not.canceled",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",invoiceSent:"invoice.sent",invoiceNotSent:"invoice.not.sent"},t.after_init(),t}return u(t,e),t}(g),b=function(e){function t(){var t=e.call(this)||this;return t.namespace="scope",t.events={fetched:"fetched",notFetched:"not.fetched",productAvailabilityFetched:"product-availability.fetched",productAvailabilityNotFetched:"product-availability.not.fetched",changeSucceeded:"changed",changeFailed:"not.changed"},t.after_init(),t}return u(t,e),t}(g),w=function(e){function t(){var t=e.call(this)||this;return t.namespace="rating",t.events={orderNotFetched:"order.not.fetched",orderFetched:"order.fetched",storeRated:"store.rated",storeFailed:"store.failed",productsRated:"products.rated",productsFailed:"products.failed",shippingRated:"shipping.rated",shippingFailed:"shipping.failed"},t.after_init(),t}return u(t,e),t}(g),S=function(e){function t(){var t=e.call(this)||this;return t.namespace="comment",t.events={added:"added",additionFailed:"addition.failed",fetched:"fetched",fetchFailed:"fetch.failed"},t.after_init(),t}return u(t,e),t}(g),E=function(e){function t(){var t=e.call(this)||this;return t.namespace="loyalty",t.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed",programFetched:"program.fetched",programNotFetched:"program.not.fetched",resetSucceeded:"exchange-reset.succeeded",resetFailed:"exchange-reset.failed"},t.after_init(),t}return u(t,e),t.prototype.exchangeSucceeded=function(e,t){return salla.cart.event.updated(e.data),this.dispatch("exchangeSucceeded",e,t)},t.prototype.resetSucceeded=function(e){return salla.cart.event.updated(e.data),this.dispatch("resetSucceeded",e)},t}(g),_=function(e){function t(){var t=e.call(this)||this;return t.namespace="profile",t.events={updated:"updated",updateFailed:"update.failed",verificationCodeSent:"verification.code.sent",updateContactsFailed:"update.contacts.failed",verified:"verified",unverified:"unverified",infoFetched:"info.fetched",infoNotFetched:"info.not.fetched",settingsUpdated:"settings.updated",updateSettingsFailed:"update.settings.failed",deleted:"deleted",notDeleted:"not.deleted"},t.after_init(),t}return u(t,e),t}(g),F=function(e){function t(){var t=e.call(this)||this;return t.namespace="product",t.events={priceUpdated:"price.updated",priceUpdateFailed:"price.updated.failed",availabilitySubscribed:"availability.subscribed",availabilitySubscribeFailed:"availability.subscribe.failed",categoriesFetched:"categories.fetched",categoriesFailed:"categories.failed",searchFailed:"search.failed",searchResults:"search.results",offerExisted:"offer.existed",fetchOffersFailed:"fetch.offers.failed",offersFetched:"offers.fetched",sizeGuideFetched:"size-guide.fetched",sizeGuideFetchFailed:"size-guide.failed",giftFetched:"gift.fetched",giftFetchFailed:"gift.failed",detailFetched:"detail.fetched",detailFetchFailed:"detail.failed",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed",productListFetchSucceeded:"fetch.succeeded",productListFetchFailed:"fetch.failed"},t.after_init(),t}return u(t,e),t}(g),P=function(e){function t(){var t=e.call(this)||this;return t.namespace="document",t.events={click:"click",change:"change",submit:"submit",keyup:"keyup",leaving:"leaving",request:"request",requestFailed:"request.failed"},t.after_init(),t}return u(t,e),t.prototype.onClick=function(e,t){this.fireCallableFuns("click",e,t)},t.prototype.onChange=function(e,t){this.fireCallableFuns("change",e,t)},t.prototype.onSubmit=function(e,t){this.fireCallableFuns("submit",e,t)},t.prototype.onKeyup=function(e,t){this.fireCallableFuns("keyup",e,t)},t.prototype.fireCallableFuns=function(e,t,n){this.on(e,(function(e){"function"!=typeof t?"function"==typeof n&&e.target.matches(t)&&n(e):t(e)}))},t.prototype.fireEvent=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return this.fireEventForElements.apply(this,p([e,t,!1],n,!1))},t.prototype.fireEventForAll=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return this.fireEventForElements.apply(this,p([e,t,!0],n,!1))},t.prototype.fireEventForElements=function(e,t,n){for(var r=this,a=[],i=3;i<arguments.length;i++)a[i-3]=arguments[i];if("string"==typeof e){if(n)return document.querySelectorAll(e).forEach((function(e){return r.fireEventForElements.apply(r,p([e,t,!1],a,!1))}));e=document.querySelector(e)}if(e){var o=new(CustomEvent.bind.apply(CustomEvent,p([void 0,t],a,!1)));return e.dispatchEvent(o)}salla.log("Failed To get element to fire event: "+t)},t}(g),A=function(e){function t(){var t=e.call(this)||this;return t.namespace="wishlist",t.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed"},t.after_init(),t}return u(t,e),t}(g),x=function(e){function t(){var t=e.call(this)||this;return t.namespace="currency",t.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},t.after_init(),t}return u(t,e),t}(g),C=function(e){function t(){var t=e.call(this)||this;return t.namespace="infiniteScroll",t.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},t.after_init(),t}return u(t,e),t}(g),k=function(e){function t(){var t=e.call(this)||this;return t.namespace="booking",t.events={added:"added",additionFailed:"addition.failed"},t.after_init(),t}return u(t,e),t}(g),O=function(e){function t(){var t=e.call(this)||this;return t.namespace="landing",t.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed"},t.after_init(),t}return u(t,e),t}(g);function q(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}Salla.event.auth=new v,Salla.event.cart=new m,Salla.event.order=new y,Salla.event.scope=new b,Salla.event.rating=new w,Salla.event.booking=new k,Salla.event.comment=new S,Salla.event.landing=new O,Salla.event.loyalty=new E,Salla.event.product=new F,Salla.event.profile=new _,Salla.event.currency=new x,Salla.event.document=new P,Salla.event.wishlist=new A,Salla.event.infiniteScroll=new C,Salla.event.on("twilight::initiated",(function(){Object.keys(Salla).forEach((function(e){"object"==typeof(e=Salla[e])&&(q(e),Object.keys(e).forEach((function(t){q(e[t])})))}))}));var R=void 0;Salla.config.default_properties={debug:"undefined"!=typeof process&&"development"===process.env.NODE_ENV,token:null,fastRequests:!0,canLeave:!0,store:{api:"https://api.salla.dev/store/v1/"},currencies:{SAR:{code:"SAR",name:"ريال سعودي",symbol:"ر.س",amount:1,country_code:"sa"}}},Salla.config.merge(Salla.config.default_properties),Salla.config.triedToGetCurrencies_=!1,Salla.config.triedToGetLanguages_=!1,Salla.config.isUser=function(){return"user"===Salla.config.get("user.type")},Salla.config.isGuest=function(){return!Salla.config.isUser()},Salla.config.languages=function(){return __awaiter(R,void 0,void 0,(function(){var e,t,n,r;return __generator(this,(function(a){switch(a.label){case 0:return Salla.config.triedToGetLanguages_?[2,Salla.config.get("languages")]:(Salla.config.triedToGetLanguages_=!0,e=!0,t=[],[4,salla.document.api.request("languages",null,"get")]);case 1:return null===(r=null===(n=a.sent())||void 0===n?void 0:n.data)||void 0===r||r.map((function(n){e&&(t=[],e=!1),n.code=n.code||n.iso_code,n.url=salla.url.get(n.code),n.is_rtl=n.is_rtl||n.rtl,t.push(n)})),Salla.config.set("languages",t),[2,t]}}))}))},Salla.config.currencies=function(){return __awaiter(R,void 0,void 0,(function(){var e,t,n,r;return __generator(this,(function(a){switch(a.label){case 0:return Salla.config.triedToGetCurrencies_?[2,Salla.config.get("currencies")]:(Salla.config.triedToGetCurrencies_=!0,e=!0,t={},[4,salla.currency.api.list()]);case 1:return null===(r=null===(n=a.sent())||void 0===n?void 0:n.data)||void 0===r||r.map((function(n){e&&(t={},e=!1),n.country_code=n.code.substr(0,2).toLowerCase(),t[n.code]=n})),Salla.config.set("currencies",t),[2,t]}}))}))};var T,I="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},L={exports:{}},D={exports:{}},N={exports:{}};function j(){return T||(T=1,function(e){!function(t,n){e.exports?e.exports=n():t.EvEmitter=n()}("undefined"!=typeof window?window:I,(function(){function e(){}let t=e.prototype;return t.on=function(e,t){if(!e||!t)return this;let n=this._events=this._events||{},r=n[e]=n[e]||[];return r.includes(t)||r.push(t),this},t.once=function(e,t){if(!e||!t)return this;this.on(e,t);let n=this._onceEvents=this._onceEvents||{};return(n[e]=n[e]||{})[t]=!0,this},t.off=function(e,t){let n=this._events&&this._events[e];if(!n||!n.length)return this;let r=n.indexOf(t);return-1!=r&&n.splice(r,1),this},t.emitEvent=function(e,t){let n=this._events&&this._events[e];if(!n||!n.length)return this;n=n.slice(0),t=t||[];let r=this._onceEvents&&this._onceEvents[e];for(let a of n){r&&r[a]&&(this.off(e,a),delete r[a]),a.apply(this,t)}return this},t.allOff=function(){return delete this._events,delete this._onceEvents,this},e}))}(N)),N.exports}var U,H,B={exports:{}};function M(){return U||(U=1,function(e){!function(t,n){e.exports?e.exports=n(t):t.fizzyUIUtils=n(t)}(I,(function(e){let t={extend:function(e,t){return Object.assign(e,t)},modulo:function(e,t){return(e%t+t)%t},makeArray:function(e){if(Array.isArray(e))return e;if(null==e)return[];return"object"==typeof e&&"number"==typeof e.length?[...e]:[e]},removeFrom:function(e,t){let n=e.indexOf(t);-1!=n&&e.splice(n,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){let t="on"+e.type;this[t]&&this[t](e)},filterFindElements:function(e,n){return(e=t.makeArray(e)).filter((e=>e instanceof HTMLElement)).reduce(((e,t)=>{if(!n)return e.push(t),e;t.matches(n)&&e.push(t);let r=t.querySelectorAll(n);return e=e.concat(...r)}),[])},debounceMethod:function(e,t,n){n=n||100;let r=e.prototype[t],a=t+"Timeout";e.prototype[t]=function(){clearTimeout(this[a]);let e=arguments;this[a]=setTimeout((()=>{r.apply(this,e),delete this[a]}),n)}},docReady:function(e){let 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,n){return t+"-"+n})).toLowerCase()}},n=e.console;return t.htmlInit=function(r,a){t.docReady((function(){let i="data-"+t.toDashed(a),o=document.querySelectorAll(`[${i}]`),s=e.jQuery;[...o].forEach((e=>{let t,o=e.getAttribute(i);try{t=o&&JSON.parse(o)}catch(t){return void(n&&n.error(`Error parsing ${i} on ${e.className}: ${t}`))}let l=new r(e,t);s&&s.data(e,a,l)}))}))},t}))}(B)),B.exports}function z(){return H||(H=1,function(e){!function(t,n){e.exports?e.exports=n(t,j(),M()):t.InfiniteScroll=n(t,t.EvEmitter,t.fizzyUIUtils)}(window,(function(e,t,n){let r=e.jQuery,a={};function i(e,t){let o=n.getQueryElement(e);if(o){if((e=o).infiniteScrollGUID){let n=a[e.infiniteScrollGUID];return n.option(t),n}this.element=e,this.options={...i.defaults},this.option(t),r&&(this.$element=r(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(o||e))}i.defaults={},i.create={},i.destroy={};let o=i.prototype;Object.assign(o,t.prototype);let s=0;o.create=function(){let e=this.guid=++s;if(this.element.infiniteScrollGUID=e,a[e]=this,this.pageIndex=1,this.loadCount=0,this.updateGetPath(),this.getPath&&this.getPath()){this.updateGetAbsolutePath(),this.log("initialized",[this.element.className]),this.callOnInit();for(let e in i.create)i.create[e].call(this)}else console.error("Disabling InfiniteScroll")},o.option=function(e){Object.assign(this.options,e)},o.callOnInit=function(){let e=this.options.onInit;e&&e.call(this,this)},o.dispatchEvent=function(e,t,n){this.log(e,n);let a=t?[t].concat(n):n;if(this.emitEvent(e,a),!r||!this.$element)return;let i=e+=".infiniteScroll";if(t){let n=r.Event(t);n.type=e,i=n}this.$element.trigger(i,n)};let l={initialized:e=>`on ${e}`,request:e=>`URL: ${e}`,load:(e,t)=>`${e.title||""}. URL: ${t}`,error:(e,t)=>`${e}. URL: ${t}`,append:(e,t,n)=>`${n.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}`}};o.log=function(e,t){if(!this.options.debug)return;let n=`[InfiniteScroll] ${e}`,r=l[e];r&&(n+=". "+r.apply(this,t)),console.log(n)},o.updateMeasurements=function(){this.windowHeight=e.innerHeight;let t=this.element.getBoundingClientRect();this.top=t.top+e.scrollY},o.updateScroller=function(){let t=this.options.elementScroll;if(t){if(this.scroller=!0===t?this.element:n.getQueryElement(t),!this.scroller)throw new Error(`Unable to find elementScroll: ${t}`)}else this.scroller=e},o.updateGetPath=function(){let e=this.options.path;if(!e)return void console.error(`InfiniteScroll path option required. Set as: ${e}`);let t=typeof e;"function"!=t?"string"==t&&e.match("{{#}}")?this.updateGetPathTemplate(e):this.updateGetPathSelector(e):this.getPath=e},o.updateGetPathTemplate=function(e){this.getPath=()=>{let t=this.pageIndex+1;return e.replace("{{#}}",t)};let t=e.replace(/(\\\?|\?)/,"\\?").replace("{{#}}","(\\d\\d?\\d?)"),n=new RegExp(t),r=location.href.match(n);r&&(this.pageIndex=parseInt(r[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))};let c=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/],u=i.getPathParts=function(e){if(e)for(let t of c){let n=e.match(t);if(n){let[,e,t,r]=n;return{begin:e,index:t,end:r}}}};o.updateGetPathSelector=function(e){let t=document.querySelector(e);if(!t)return void console.error(`Bad InfiniteScroll path option. Next link not found: ${e}`);let n=t.getAttribute("href"),r=u(n);if(!r)return void console.error(`InfiniteScroll unable to parse next link href: ${n}`);let{begin:a,index:i,end:o}=r;this.isPathSelector=!0,this.getPath=()=>a+(this.pageIndex+1)+o,this.pageIndex=parseInt(i,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])},o.updateGetAbsolutePath=function(){let e=this.getPath();if(e.match(/^http/)||e.match(/^\//))return void(this.getAbsolutePath=this.getPath);let{pathname:t}=location,n=e.match(/^\?/),r=t.substring(0,t.lastIndexOf("/")),a=n?t:r+"/";this.getAbsolutePath=()=>a+this.getPath()},i.create.hideNav=function(){let e=n.getQueryElement(this.options.hideNav);e&&(e.style.display="none",this.nav=e)},i.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},o.destroy=function(){this.allOff();for(let e in i.destroy)i.destroy[e].call(this);delete this.element.infiniteScrollGUID,delete a[this.guid],r&&this.$element&&r.removeData(this.element,"infiniteScroll")},i.throttle=function(e,t){let n,r;return t=t||200,function(){let a=+new Date,i=arguments,o=()=>{n=a,e.apply(this,i)};n&&a<n+t?(clearTimeout(r),r=setTimeout(o,t)):o()}},i.data=function(e){let t=(e=n.getQueryElement(e))&&e.infiniteScrollGUID;return t&&a[t]},i.setJQuery=function(e){r=e},n.htmlInit(i,"infinite-scroll"),o._init=function(){};let{jQueryBridget:d}=e;return r&&d&&d("infiniteScroll",i,r),i}))}(D)),D.exports}var G,V={exports:{}};function $(){return G||(G=1,function(e){!function(t,n){e.exports?e.exports=n(t,z()):n(t,t.InfiniteScroll)}(window,(function(e,t){let n=t.prototype;Object.assign(t.defaults,{loadOnScroll:!0,checkLastPage:!0,responseBody:"text",domParseResponse:!0}),t.create.pageLoad=function(){this.canLoad=!0,this.on("scrollThreshold",this.onScrollThresholdLoad),this.on("load",this.checkLastPage),this.options.outlayer&&this.on("append",this.onAppendOutlayer)},n.onScrollThresholdLoad=function(){this.options.loadOnScroll&&this.loadNextPage()};let r=new DOMParser;function a(e){let t=document.createDocumentFragment();return e&&t.append(...e),t}return n.loadNextPage=function(){if(this.isLoading||!this.canLoad)return;let{responseBody:e,domParseResponse:t,fetchOptions:n}=this.options,a=this.getAbsolutePath();this.isLoading=!0,"function"==typeof n&&(n=n());let i=fetch(a,n).then((n=>{if(!n.ok){let e=new Error(n.statusText);return this.onPageError(e,a,n),{response:n}}return n[e]().then((i=>("text"==e&&t&&(i=r.parseFromString(i,"text/html")),204==n.status?(this.lastPageReached(i,a),{body:i,response:n}):this.onPageLoad(i,a,n))))})).catch((e=>{this.onPageError(e,a)}));return this.dispatchEvent("request",null,[a,i]),i},n.onPageLoad=function(e,t,n){return this.options.append||(this.isLoading=!1),this.pageIndex++,this.loadCount++,this.dispatchEvent("load",null,[e,t,n]),this.appendNextPage(e,t,n)},n.appendNextPage=function(e,t,n){let{append:r,responseBody:i,domParseResponse:o}=this.options;if(!("text"==i&&o)||!r)return{body:e,response:n};let s=e.querySelectorAll(r),l={body:e,response:n,items:s};if(!s||!s.length)return this.lastPageReached(e,t),l;let c=a(s),u=()=>(this.appendItems(s,c),this.isLoading=!1,this.dispatchEvent("append",null,[e,t,s,n]),l);return this.options.outlayer?this.appendOutlayerItems(c,u):u()},n.appendItems=function(e,t){e&&e.length&&(function(e){let t=e.querySelectorAll("script");for(let e of t){let t=document.createElement("script"),n=e.attributes;for(let e of n)t.setAttribute(e.name,e.value);t.innerHTML=e.innerHTML,e.parentNode.replaceChild(t,e)}}(t=t||a(e)),this.element.appendChild(t))},n.appendOutlayerItems=function(n,r){let a=t.imagesLoaded||e.imagesLoaded;return a?new Promise((function(e){a(n,(function(){let t=r();e(t)}))})):(console.error("[InfiniteScroll] imagesLoaded required for outlayer option"),void(this.isLoading=!1))},n.onAppendOutlayer=function(e,t,n){this.options.outlayer.appended(n)},n.checkLastPage=function(e,t){let n,{checkLastPage:r,path:a}=this.options;if(r){if("function"==typeof a){if(!this.getPath())return void this.lastPageReached(e,t)}"string"==typeof r?n=r:this.isPathSelector&&(n=a),n&&e.querySelector&&(e.querySelector(n)||this.lastPageReached(e,t))}},n.lastPageReached=function(e,t){this.canLoad=!1,this.dispatchEvent("last",null,[e,t])},n.onPageError=function(e,t,n){return this.isLoading=!1,this.canLoad=!1,this.dispatchEvent("error",null,[e,t,n]),e},t.create.prefill=function(){if(!this.options.prefill)return;let e=this.options.append;e?(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}`)},n.prefill=function(){let e=this.getPrefillDistance();this.isPrefilling=e>=0,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},n.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},n.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},t}))}(V)),V.exports}var Q,W={exports:{}};function J(){return Q||(Q=1,function(e){!function(t,n){e.exports?e.exports=n(t,z(),M()):n(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,n){let r=t.prototype;return Object.assign(t.defaults,{scrollThreshold:400}),t.create.scrollWatch=function(){this.pageScrollHandler=this.onPageScroll.bind(this),this.resizeHandler=this.onResize.bind(this);let e=this.options.scrollThreshold;(e||0===e)&&this.enableScrollWatch()},t.destroy.scrollWatch=function(){this.disableScrollWatch()},r.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},r.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},r.bindScrollWatchEvents=function(t){let n=t?"addEventListener":"removeEventListener";this.scroller[n]("scroll",this.pageScrollHandler),e[n]("resize",this.resizeHandler)},r.onPageScroll=t.throttle((function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")})),r.getBottomDistance=function(){let t,n;return this.options.elementScroll?(t=this.scroller.scrollHeight,n=this.scroller.scrollTop+this.scroller.clientHeight):(t=this.top+this.element.clientHeight,n=e.scrollY+this.windowHeight),t-n},r.onResize=function(){this.updateMeasurements()},n.debounceMethod(t,"onResize",150),t}))}(W)),W.exports}var K,X={exports:{}};function Y(){return K||(K=1,function(e){!function(t,n){e.exports?e.exports=n(t,z(),M()):n(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,n){let r=t.prototype;Object.assign(t.defaults,{history:"replace"});let a=document.createElement("a");return t.create.history=function(){if(!this.options.history)return;a.href=this.getAbsolutePath(),(a.origin||a.protocol+"//"+a.host)==location.origin?this.options.append?this.createHistoryAppend():this.createHistoryPageLoad():console.error(`[InfiniteScroll] cannot set history with different origin: ${a.origin} on ${location.origin} . History behavior disabled.`)},r.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)},r.bindHistoryAppendEvents=function(t){let n=t?"addEventListener":"removeEventListener";this.scroller[n]("scroll",this.scrollHistoryHandler),e[n]("unload",this.unloadHandler)},r.createHistoryPageLoad=function(){this.on("load",this.onPageLoadHistory)},t.destroy.history=r.destroyHistory=function(){this.options.history&&this.options.append&&this.bindHistoryAppendEvents(!1)},r.onAppendHistory=function(e,t,n){if(!n||!n.length)return;let r=n[0],i=this.getElementScrollY(r);a.href=t,this.scrollPages.push({top:i,path:a.href,title:e.title})},r.getElementScrollY=function(t){if(this.options.elementScroll)return t.offsetTop-this.top;return t.getBoundingClientRect().top+e.scrollY},r.onScrollHistory=function(){let e=this.getClosestScrollPage();e!=this.scrollPage&&(this.scrollPage=e,this.setHistory(e.title,e.path))},n.debounceMethod(t,"onScrollHistory",150),r.getClosestScrollPage=function(){let t,n;t=this.options.elementScroll?this.scroller.scrollTop+this.scroller.clientHeight/2:e.scrollY+this.windowHeight/2;for(let e of this.scrollPages){if(e.top>=t)break;n=e}return n},r.setHistory=function(e,t){let n=this.options.history;n&&history[n+"State"]&&(history[n+"State"](null,e,t),this.options.historyTitle&&(document.title=e),this.dispatchEvent("history",null,[e,t]))},r.onUnload=function(){if(0===this.scrollPage.top)return;let t=e.scrollY-this.scrollPage.top+this.top;this.destroyHistory(),scrollTo(0,t)},r.onPageLoadHistory=function(e,t){this.setHistory(e.title,t)},t}))}(X)),X.exports}var Z,ee={exports:{}};function te(){return Z||(Z=1,function(e){!function(t,n){e.exports?e.exports=n(t,z(),M()):n(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,n){class r{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(){let e=n.getQueryElement(this.options.button);e&&(this.button=new r(e,this))},t.destroy.button=function(){this.button&&this.button.destroy()},t.Button=r,t}))}(ee)),ee.exports}var ne,re={exports:{}};function ae(){return ne||(ne=1,function(e){!function(t,n){e.exports?e.exports=n(t,z(),M()):n(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,n){let r=t.prototype;function a(e){o(e,"none")}function i(e){o(e,"block")}function o(e,t){e&&(e.style.display=t)}return t.create.status=function(){let e=n.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"))},r.bindHideStatus=function(e){let t=this.options.append?"append":"load";this[e](t,this.hideAllStatus)},r.showRequestStatus=function(){this.showStatus("request")},r.showErrorStatus=function(){this.showStatus("error")},r.showLastStatus=function(){this.showStatus("last"),this.bindHideStatus("off")},r.showStatus=function(e){i(this.statusElement),this.hideStatusEventElements(),i(this.statusEventElements[e])},r.hideAllStatus=function(){a(this.statusElement),this.hideStatusEventElements()},r.hideStatusEventElements=function(){for(let e in this.statusEventElements){a(this.statusEventElements[e])}},t}))}(re)),re.exports}
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("process"),require("buffer")):"function"==typeof define&&define.amd?define(["process","buffer"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Salla=t(e.process$1,e.buffer)}(this,(function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function n(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(e)}var i=r(e),a="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},o=Array.isArray,l="object"==typeof s&&s&&s.Object===Object&&s,c="object"==typeof self&&self&&self.Object===Object&&self,u=l||c||Function("return this")(),d=u.Symbol,h=d,f=Object.prototype,p=f.hasOwnProperty,g=f.toString,m=h?h.toStringTag:void 0;var v=function(e){var t=p.call(e,m),r=e[m];try{e[m]=void 0;var n=!0}catch(e){}var i=g.call(e);return n&&(t?e[m]=r:delete e[m]),i},y=Object.prototype.toString;var w=v,b=function(e){return y.call(e)},_=d?d.toStringTag:void 0;var S=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":_&&_ in Object(e)?w(e):b(e)};var E=S,x=function(e){return null!=e&&"object"==typeof e};var F=function(e){return"symbol"==typeof e||x(e)&&"[object Symbol]"==E(e)},A=o,P=F,L=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,k=/^\w*$/;var O=function(e,t){if(A(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!P(e))||(k.test(e)||!L.test(e)||null!=t&&e in Object(t))};var T=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},j=S,C=T;var R,q=function(e){if(!C(e))return!1;var t=j(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},I=u["__core-js_shared__"],N=(R=/[^.]+$/.exec(I&&I.keys&&I.keys.IE_PROTO||""))?"Symbol(src)_1."+R:"";var D=function(e){return!!N&&N in e},U=Function.prototype.toString;var H=q,M=D,$=T,z=function(e){if(null!=e){try{return U.call(e)}catch(e){}try{return e+""}catch(e){}}return""},B=/^\[object .+?Constructor\]$/,G=Function.prototype,W=Object.prototype,V=G.toString,Q=W.hasOwnProperty,J=RegExp("^"+V.call(Q).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var K=function(e){return!(!$(e)||M(e))&&(H(e)?J:B).test(z(e))},X=function(e,t){return null==e?void 0:e[t]};var Y=function(e,t){var r=X(e,t);return K(r)?r:void 0},Z=Y(Object,"create"),ee=Z;var te=function(){this.__data__=ee?ee(null):{},this.size=0};var re=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},ne=Z,ie=Object.prototype.hasOwnProperty;var ae=function(e){var t=this.__data__;if(ne){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return ie.call(t,e)?t[e]:void 0},se=Z,oe=Object.prototype.hasOwnProperty;var le=function(e){var t=this.__data__;return se?void 0!==t[e]:oe.call(t,e)},ce=Z;var ue=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=ce&&void 0===t?"__lodash_hash_undefined__":t,this},de=te,he=re,fe=ae,pe=le,ge=ue;function me(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}me.prototype.clear=de,me.prototype.delete=he,me.prototype.get=fe,me.prototype.has=pe,me.prototype.set=ge;var ve=me;var ye=function(){this.__data__=[],this.size=0};var we=function(e,t){return e===t||e!=e&&t!=t};var be=function(e,t){for(var r=e.length;r--;)if(we(e[r][0],t))return r;return-1},_e=be,Se=Array.prototype.splice;var Ee=function(e){var t=this.__data__,r=_e(t,e);return!(r<0)&&(r==t.length-1?t.pop():Se.call(t,r,1),--this.size,!0)},xe=be;var Fe=function(e){var t=this.__data__,r=xe(t,e);return r<0?void 0:t[r][1]},Ae=be;var Pe=be;var Le=function(e,t){var r=this.__data__,n=Pe(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},ke=ye,Oe=Ee,Te=Fe,je=function(e){return Ae(this.__data__,e)>-1},Ce=Le;function Re(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Re.prototype.clear=ke,Re.prototype.delete=Oe,Re.prototype.get=Te,Re.prototype.has=je,Re.prototype.set=Ce;var qe=Re,Ie=Y(u,"Map"),Ne=ve,De=qe,Ue=Ie;var He=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var Me=function(e,t){var r=e.__data__;return He(t)?r["string"==typeof t?"string":"hash"]:r.map},$e=Me;var ze=Me;var Be=Me;var Ge=Me;var We=function(e,t){var r=Ge(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Ve=function(){this.size=0,this.__data__={hash:new Ne,map:new(Ue||De),string:new Ne}},Qe=function(e){var t=$e(this,e).delete(e);return this.size-=t?1:0,t},Je=function(e){return ze(this,e).get(e)},Ke=function(e){return Be(this,e).has(e)},Xe=We;function Ye(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Ye.prototype.clear=Ve,Ye.prototype.delete=Qe,Ye.prototype.get=Je,Ye.prototype.has=Ke,Ye.prototype.set=Xe;var Ze=Ye;function et(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],a=r.cache;if(a.has(i))return a.get(i);var s=e.apply(this,n);return r.cache=a.set(i,s)||a,s};return r.cache=new(et.Cache||Ze),r}et.Cache=Ze;var tt=et;var rt=function(e){var t=tt(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t},nt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,it=/\\(\\)?/g,at=rt((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(nt,(function(e,r,n,i){t.push(n?i.replace(it,"$1"):r||e)})),t}));var st=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i},ot=o,lt=F,ct=d?d.prototype:void 0,ut=ct?ct.toString:void 0;var dt=function e(t){if("string"==typeof t)return t;if(ot(t))return st(t,e)+"";if(lt(t))return ut?ut.call(t):"";var r=t+"";return"0"==r&&1/t==-Infinity?"-0":r},ht=dt;var ft=o,pt=O,gt=at,mt=function(e){return null==e?"":ht(e)};var vt=F;var yt=function(e,t){return ft(e)?e:pt(e,t)?[e]:gt(mt(e))},wt=function(e){if("string"==typeof e||vt(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t};var bt=function(e,t){for(var r=0,n=(t=yt(t,e)).length;null!=e&&r<n;)e=e[wt(t[r++])];return r&&r==n?e:void 0};var _t=function(e,t,r){var n=null==e?void 0:bt(e,t);return void 0===n?r:n},St={exports:{}};!function(e,t){!function(t){var r=Object.hasOwnProperty,n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},a="object"==typeof i.default&&"function"==typeof i.default.nextTick,s="function"==typeof Symbol,o="object"==typeof Reflect,l="function"==typeof setImmediate?setImmediate:setTimeout,c=s?o&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function u(){this._events={},this._conf&&d.call(this,this._conf)}function d(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==t&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function h(e,t){var r="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(r+=" Event name: "+t+"."),void 0!==i.default&&i.default.emitWarning){var n=new Error(r);n.name="MaxListenersExceededWarning",n.emitter=this,n.count=e,i.default.emitWarning(n)}else console.error(r),console.trace&&console.trace()}var f=function(e,t,r){var n=arguments.length;switch(n){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,r];default:for(var i=new Array(n);n--;)i[n]=arguments[n];return i}};function p(e,r){for(var n={},i=e.length,a=r?r.length:0,s=0;s<i;s++)n[e[s]]=s<a?r[s]:t;return n}function g(e,t,r){var n,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(r.on||r.off)&&(n=r.on,i=r.off),t.addEventListener?(n=t.addEventListener,i=t.removeEventListener):t.addListener?(n=t.addListener,i=t.removeListener):t.on&&(n=t.on,i=t.off),!n&&!i)throw Error("target does not implement any known event API");if("function"!=typeof n)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=n,this._off=i;var a=e._observers;a?a.push(this):e._observers=[this]}function m(e,n,i,a){var s=Object.assign({},n);if(!e)return s;if("object"!=typeof e)throw TypeError("options must be an object");var o,l,c,u=Object.keys(e),d=u.length;function h(e){throw Error('Invalid "'+o+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<d;f++){if(o=u[f],!a&&!r.call(n,o))throw Error('Unknown "'+o+'" option');(l=e[o])!==t&&(c=i[o],s[o]=c?c(l,h):l)}return s}function v(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function y(e){var t="value must be type of "+e.join("|"),r=e.length,n=e[0],i=e[1];return 1===r?function(e,r){if(typeof e===n)return e;r(t)}:2===r?function(e,r){var a=typeof e;if(a===n||a===i)return e;r(t)}:function(n,i){for(var a=typeof n,s=r;s-- >0;)if(a===e[s])return n;i(t)}}Object.assign(g.prototype,{subscribe:function(e,t,r){var n=this,i=this._target,a=this._emitter,s=this._listeners,o=function(){var n=f.apply(null,arguments),s={data:n,name:t,original:e};if(r){var o=r.call(i,s);!1!==o&&a.emit.apply(a,[s.name].concat(n))}else a.emit.apply(a,[t].concat(n))};if(s[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,a._newListener&&a._removeListener&&!n._onNewListener?(this._onNewListener=function(r){r===t&&null===s[e]&&(s[e]=o,n._on.call(i,e,o))},a.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===t&&!a.hasListeners(r)&&s[e]&&(s[e]=null,n._off.call(i,e,o))},s[e]=null,a.on("removeListener",this._onRemoveListener)):(s[e]=o,n._on.call(i,e,o))},unsubscribe:function(e){var t,r,n,i=this,a=this._listeners,s=this._emitter,o=this._off,l=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function u(){i._onNewListener&&(s.off("newListener",i._onNewListener),s.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=S.call(s,i);s._observers.splice(e,1)}if(e){if(!(t=a[e]))return;o.call(l,e,t),delete a[e],--this._listenersCount||u()}else{for(n=(r=c(a)).length;n-- >0;)e=r[n],o.call(l,e,a[e]);this._listeners={},this._listenersCount=0,u()}}});var w=y(["function"]),b=y(["object","function"]);function _(e,t,r){var n,i,a,s=0,o=new e((function(l,c,u){function d(){i&&(i=null),s&&(clearTimeout(s),s=0)}r=m(r,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),n=!r.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof u;var h=function(e){d(),l(e)},f=function(e){d(),c(e)};n?t(h,f,u):(i=[function(e){f(e||Error("canceled"))}],t(h,f,(function(e){if(a)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),a=!0),r.timeout>0&&(s=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",s=0,o.cancel(e),c(e)}),r.timeout))}));return n||(o.cancel=function(e){if(i){for(var t=i.length,r=1;r<t;r++)i[r](e);i[0](e),i=null}}),o}function S(e){var t=this._observers;if(!t)return-1;for(var r=t.length,n=0;n<r;n++)if(t[n]._target===e)return n;return-1}function E(e,t,r,n,i){if(!r)return null;if(0===n){var a=typeof t;if("string"===a){var s,o,l=0,u=0,d=this.delimiter,h=d.length;if(-1!==(o=t.indexOf(d))){s=new Array(5);do{s[l++]=t.slice(u,o),u=o+h}while(-1!==(o=t.indexOf(d,u)));s[l++]=t.slice(u),t=s,i=l}else t=[t],i=1}else"object"===a?i=t.length:(t=[t],i=1)}var f,p,g,m,v,y,w,b=null,_=t[n],S=t[n+1];if(n===i)r._listeners&&("function"==typeof r._listeners?(e&&e.push(r._listeners),b=[r]):(e&&e.push.apply(e,r._listeners),b=[r]));else{if("*"===_){for(o=(y=c(r)).length;o-- >0;)"_listeners"!==(f=y[o])&&(w=E(e,t,r[f],n+1,i))&&(b?b.push.apply(b,w):b=w);return b}if("**"===_){for((v=n+1===i||n+2===i&&"*"===S)&&r._listeners&&(b=E(e,t,r,i,i)),o=(y=c(r)).length;o-- >0;)"_listeners"!==(f=y[o])&&("*"===f||"**"===f?(r[f]._listeners&&!v&&(w=E(e,t,r[f],i,i))&&(b?b.push.apply(b,w):b=w),w=E(e,t,r[f],n,i)):w=E(e,t,r[f],f===S?n+2:n,i),w&&(b?b.push.apply(b,w):b=w));return b}r[_]&&(b=E(e,t,r[_],n+1,i))}if((p=r["*"])&&E(e,t,p,n+1,i),g=r["**"])if(n<i)for(g._listeners&&E(e,t,g,i,i),o=(y=c(g)).length;o-- >0;)"_listeners"!==(f=y[o])&&(f===S?E(e,t,g[f],n+2,i):f===_?E(e,t,g[f],n+1,i):((m={})[f]=g[f],E(e,t,{"**":m},n+1,i)));else g._listeners?E(e,t,g,i,i):g["*"]&&g["*"]._listeners&&E(e,t,g["*"],i,i);return b}function x(e,t,r){var n,i,a=0,s=0,o=this.delimiter,l=o.length;if("string"==typeof e)if(-1!==(n=e.indexOf(o))){i=new Array(5);do{i[a++]=e.slice(s,n),s=n+l}while(-1!==(n=e.indexOf(o,s)));i[a++]=e.slice(s)}else i=[e],a=1;else i=e,a=e.length;if(a>1)for(n=0;n+1<a;n++)if("**"===i[n]&&"**"===i[n+1])return;var c,u=this.listenerTree;for(n=0;n<a;n++)if(u=u[c=i[n]]||(u[c]={}),n===a-1)return u._listeners?("function"==typeof u._listeners&&(u._listeners=[u._listeners]),r?u._listeners.unshift(t):u._listeners.push(t),!u._listeners.warned&&this._maxListeners>0&&u._listeners.length>this._maxListeners&&(u._listeners.warned=!0,h.call(this,u._listeners.length,c))):u._listeners=t,!0;return!0}function F(e,t,r,n){for(var i,a,s,o,l=c(e),u=l.length,d=e._listeners;u-- >0;)i=e[a=l[u]],s="_listeners"===a?r:r?r.concat(a):[a],o=n||"symbol"==typeof a,d&&t.push(o?s:s.join(this.delimiter)),"object"==typeof i&&F.call(this,i,t,s,o);return t}function A(e){for(var t,r,n,i=c(e),a=i.length;a-- >0;)(t=e[r=i[a]])&&(n=!0,"_listeners"===r||A(t)||delete e[r]);return n}function P(e,t,r){this.emitter=e,this.event=t,this.listener=r}function L(e,r,n){if(!0===n)o=!0;else if(!1===n)s=!0;else{if(!n||"object"!=typeof n)throw TypeError("options should be an object or true");var s=n.async,o=n.promisify,c=n.nextTick,u=n.objectify}if(s||c||o){var d=r,h=r._origin||r;if(c&&!a)throw Error("process.nextTick is not supported");o===t&&(o="AsyncFunction"===r.constructor.name),r=function(){var e=arguments,t=this,r=this.event;return o?c?Promise.resolve():new Promise((function(e){l(e)})).then((function(){return t.event=r,d.apply(t,e)})):(c?i.default.nextTick:l)((function(){t.event=r,d.apply(t,e)}))},r._async=!0,r._origin=h}return[r,u?new P(this,e,r):this]}function k(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,d.call(this,e)}P.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},k.EventEmitter2=k,k.prototype.listenTo=function(e,r,i){if("object"!=typeof e)throw TypeError("target musts be an object");var a=this;function s(t){if("object"!=typeof t)throw TypeError("events must be an object");var r,n=i.reducers,s=S.call(a,e);r=-1===s?new g(a,e,i):a._observers[s];for(var o,l=c(t),u=l.length,d="function"==typeof n,h=0;h<u;h++)o=l[h],r.subscribe(o,t[o]||o,d?n:n&&n[o])}return i=m(i,{on:t,off:t,reducers:t},{on:w,off:w,reducers:b}),n(r)?s(p(r)):s("string"==typeof r?p(r.split(/\s+/)):r),this},k.prototype.stopListeningTo=function(e,t){var r=this._observers;if(!r)return!1;var n,i=r.length,a=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)n=r[i],e&&n._target!==e||(n.unsubscribe(t),a=!0);return a},k.prototype.delimiter=".",k.prototype.setMaxListeners=function(e){e!==t&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},k.prototype.getMaxListeners=function(){return this._maxListeners},k.prototype.event="",k.prototype.once=function(e,t,r){return this._once(e,t,!1,r)},k.prototype.prependOnceListener=function(e,t,r){return this._once(e,t,!0,r)},k.prototype._once=function(e,t,r,n){return this._many(e,1,t,r,n)},k.prototype.many=function(e,t,r,n){return this._many(e,t,r,!1,n)},k.prototype.prependMany=function(e,t,r,n){return this._many(e,t,r,!0,n)},k.prototype._many=function(e,t,r,n,i){var a=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function s(){return 0==--t&&a.off(e,s),r.apply(this,arguments)}return s._origin=r,this._on(e,s,n,i)},k.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||u.call(this);var e,t,r,n,i,a,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(r=o.length,s)for(n=0;n<r;n++)if("symbol"==typeof o[n]){a=!0;break}a||(o=o.join(this.delimiter))}var c,d=arguments.length;if(this._all&&this._all.length)for(n=0,r=(c=this._all.slice()).length;n<r;n++)switch(this.event=o,d){case 1:c[n].call(this,o);break;case 2:c[n].call(this,o,arguments[1]);break;case 3:c[n].call(this,o,arguments[1],arguments[2]);break;default:c[n].apply(this,arguments)}if(l)c=[],E.call(this,c,e,this.listenerTree,0,r);else{if("function"==typeof(c=this._events[o])){switch(this.event=o,d){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(d-1),i=1;i<d;i++)t[i-1]=arguments[i];c.apply(this,t)}return!0}c&&(c=c.slice())}if(c&&c.length){if(d>3)for(t=new Array(d-1),i=1;i<d;i++)t[i-1]=arguments[i];for(n=0,r=c.length;n<r;n++)switch(this.event=o,d){case 1:c[n].call(this);break;case 2:c[n].call(this,arguments[1]);break;case 3:c[n].call(this,arguments[1],arguments[2]);break;default:c[n].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===o)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},k.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||u.call(this);var e,t,r,n,i,a,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(n=o.length,s)for(i=0;i<n;i++)if("symbol"==typeof o[i]){t=!0;break}t||(o=o.join(this.delimiter))}var c,d=[],h=arguments.length;if(this._all)for(i=0,n=this._all.length;i<n;i++)switch(this.event=o,h){case 1:d.push(this._all[i].call(this,o));break;case 2:d.push(this._all[i].call(this,o,arguments[1]));break;case 3:d.push(this._all[i].call(this,o,arguments[1],arguments[2]));break;default:d.push(this._all[i].apply(this,arguments))}if(l?(c=[],E.call(this,c,e,this.listenerTree,0)):c=this._events[o],"function"==typeof c)switch(this.event=o,h){case 1:d.push(c.call(this));break;case 2:d.push(c.call(this,arguments[1]));break;case 3:d.push(c.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(h-1),a=1;a<h;a++)r[a-1]=arguments[a];d.push(c.apply(this,r))}else if(c&&c.length){if(c=c.slice(),h>3)for(r=new Array(h-1),a=1;a<h;a++)r[a-1]=arguments[a];for(i=0,n=c.length;i<n;i++)switch(this.event=o,h){case 1:d.push(c[i].call(this));break;case 2:d.push(c[i].call(this,arguments[1]));break;case 3:d.push(c[i].call(this,arguments[1],arguments[2]));break;default:d.push(c[i].apply(this,r))}}else if(!this.ignoreErrors&&!this._all&&"error"===o)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(d)},k.prototype.on=function(e,t,r){return this._on(e,t,!1,r)},k.prototype.prependListener=function(e,t,r){return this._on(e,t,!0,r)},k.prototype.onAny=function(e){return this._onAny(e,!1)},k.prototype.prependAny=function(e){return this._onAny(e,!0)},k.prototype.addListener=k.prototype.on,k.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},k.prototype._on=function(e,r,n,i){if("function"==typeof e)return this._onAny(e,r),this;if("function"!=typeof r)throw new Error("on only accepts instances of Function");this._events||u.call(this);var a,s=this;return i!==t&&(r=(a=L.call(this,e,r,i))[0],s=a[1]),this._newListener&&this.emit("newListener",e,r),this.wildcard?(x.call(this,e,r,n),s):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),n?this._events[e].unshift(r):this._events[e].push(r),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,h.call(this,this._events[e].length,e))):this._events[e]=r,s)},k.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,i=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=E.call(this,null,a,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],i.push({_listeners:r})}for(var s=0;s<i.length;s++){var o=i[s];if(r=o._listeners,n(r)){for(var l=-1,c=0,u=r.length;c<u;c++)if(r[c]===t||r[c].listener&&r[c].listener===t||r[c]._origin&&r[c]._origin===t){l=c;break}if(l<0)continue;return this.wildcard?o._listeners.splice(l,1):this._events[e].splice(l,1),0===r.length&&(this.wildcard?delete o._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete o._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&A(this.listenerTree),this},k.prototype.offAny=function(e){var t,r=0,n=0;if(e&&this._all&&this._all.length>0){for(r=0,n=(t=this._all).length;r<n;r++)if(e===t[r])return t.splice(r,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(r=0,n=t.length;r<n;r++)this.emit("removeListenerAny",t[r]);this._all=[]}return this},k.prototype.removeListener=k.prototype.off,k.prototype.removeAllListeners=function(e){if(e===t)return!this._events||u.call(this),this;if(this.wildcard){var r,n=E.call(this,null,e,this.listenerTree,0);if(!n)return this;for(r=0;r<n.length;r++)n[r]._listeners=null;this.listenerTree&&A(this.listenerTree)}else this._events&&(this._events[e]=null);return this},k.prototype.listeners=function(e){var r,n,i,a,s,o=this._events;if(e===t){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!o)return[];for(a=(r=c(o)).length,i=[];a-- >0;)"function"==typeof(n=o[r[a]])?i.push(n):i.push.apply(i,n);return i}if(this.wildcard){if(!(s=this.listenerTree))return[];var l=[],u="string"==typeof e?e.split(this.delimiter):e.slice();return E.call(this,l,u,s,0),l}return o&&(n=o[e])?"function"==typeof n?[n]:n:[]},k.prototype.eventNames=function(e){var t=this._events;return this.wildcard?F.call(this,this.listenerTree,[],null,e):t?c(t):[]},k.prototype.listenerCount=function(e){return this.listeners(e).length},k.prototype.hasListeners=function(e){if(this.wildcard){var r=[],n="string"==typeof e?e.split(this.delimiter):e.slice();return E.call(this,r,n,this.listenerTree,0),r.length>0}var i=this._events,a=this._all;return!!(a&&a.length||i&&(e===t?c(i).length:i[e]))},k.prototype.listenersAny=function(){return this._all?this._all:[]},k.prototype.waitFor=function(e,r){var n=this,i=typeof r;return"number"===i?r={timeout:r}:"function"===i&&(r={filter:r}),_((r=m(r,{timeout:0,filter:t,handleError:!1,Promise:Promise,overload:!1},{filter:w,Promise:v})).Promise,(function(t,i,a){function s(){var a=r.filter;if(!a||a.apply(n,arguments))if(n.off(e,s),r.handleError){var o=arguments[0];o?i(o):t(f.apply(null,arguments).slice(1))}else t(f.apply(null,arguments))}a((function(){n.off(e,s)})),n._on(e,s,!1)}),{timeout:r.timeout,overload:r.overload})};var O=k.prototype;Object.defineProperties(k,{defaultMaxListeners:{get:function(){return O._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");O._maxListeners=e},enumerable:!0},once:{value:function(e,t,r){return _((r=m(r,{Promise:Promise,timeout:0,overload:!1},{Promise:v})).Promise,(function(r,n,i){var a;if("function"==typeof e.addEventListener)return a=function(){r(f.apply(null,arguments))},i((function(){e.removeEventListener(t,a)})),void e.addEventListener(t,a,{once:!0});var s,o=function(){s&&e.removeListener("error",s),r(f.apply(null,arguments))};"error"!==t&&(s=function(r){e.removeListener(t,o),n(r)},e.once("error",s)),i((function(){s&&e.removeListener("error",s),e.removeListener(t,o)})),e.once(t,o)}),{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(O,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),e.exports=k}()}(St);var Et=Object.assign?Object.assign:function(e,t,r,n){for(var i=1;i<arguments.length;i++)kt(Object(arguments[i]),(function(t,r){e[r]=t}));return e},xt=function(){if(Object.create)return function(e,t,r,n){var i=Lt(arguments,1);return Et.apply(this,[Object.create(e)].concat(i))};{function e(){}return function(t,r,n,i){var a=Lt(arguments,1);return e.prototype=t,Et.apply(this,[new e].concat(a))}}}(),Ft=String.prototype.trim?function(e){return String.prototype.trim.call(e)}:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},At="undefined"!=typeof window?window:s,Pt={assign:Et,create:xt,trim:Ft,bind:function(e,t){return function(){return t.apply(e,Array.prototype.slice.call(arguments,0))}},slice:Lt,each:kt,map:function(e,t){var r=Tt(e)?[]:{};return Ot(e,(function(e,n){return r[n]=t(e,n),!1})),r},pluck:Ot,isList:Tt,isFunction:function(e){return e&&"[object Function]"==={}.toString.call(e)},isObject:function(e){return e&&"[object Object]"==={}.toString.call(e)},Global:At};function Lt(e,t){return Array.prototype.slice.call(e,t||0)}function kt(e,t){Ot(e,(function(e,r){return t(e,r),!1}))}function Ot(e,t){if(Tt(e)){for(var r=0;r<e.length;r++)if(t(e[r],r))return e[r]}else for(var n in e)if(e.hasOwnProperty(n)&&t(e[n],n))return e[n]}function Tt(e){return null!=e&&"function"!=typeof e&&"number"==typeof e.length}var jt=Pt.slice,Ct=Pt.pluck,Rt=Pt.each,qt=Pt.bind,It=Pt.create,Nt=Pt.isList,Dt=Pt.isFunction,Ut=Pt.isObject,Ht={createStore:$t},Mt={version:"2.0.12",enabled:!1,get:function(e,t){var r=this.storage.read(this._namespacePrefix+e);return this._deserialize(r,t)},set:function(e,t){return void 0===t?this.remove(e):(this.storage.write(this._namespacePrefix+e,this._serialize(t)),t)},remove:function(e){this.storage.remove(this._namespacePrefix+e)},each:function(e){var t=this;this.storage.each((function(r,n){e.call(t,t._deserialize(r),(n||"").replace(t._namespaceRegexp,""))}))},clearAll:function(){this.storage.clearAll()},hasNamespace:function(e){return this._namespacePrefix=="__storejs_"+e+"_"},createStore:function(){return $t.apply(this,arguments)},addPlugin:function(e){this._addPlugin(e)},namespace:function(e){return $t(this.storage,this.plugins,e)}};function $t(e,t,r){r||(r=""),e&&!Nt(e)&&(e=[e]),t&&!Nt(t)&&(t=[t]);var n=r?"__storejs_"+r+"_":"",i=r?new RegExp("^"+n):null;if(!/^[a-zA-Z0-9_\-]*$/.test(r))throw new Error("store.js namespaces can only have alphanumerics + underscores and dashes");var a={_namespacePrefix:n,_namespaceRegexp:i,_testStorage:function(e){try{var t="__storejs__test__";e.write(t,t);var r=e.read(t)===t;return e.remove(t),r}catch(e){return!1}},_assignPluginFnProp:function(e,t){var r=this[t];this[t]=function(){var t=jt(arguments,0),n=this;function i(){if(r)return Rt(arguments,(function(e,r){t[r]=e})),r.apply(n,t)}var a=[i].concat(t);return e.apply(n,a)}},_serialize:function(e){return JSON.stringify(e)},_deserialize:function(e,t){if(!e)return t;var r="";try{r=JSON.parse(e)}catch(t){r=e}return void 0!==r?r:t},_addStorage:function(e){this.enabled||this._testStorage(e)&&(this.storage=e,this.enabled=!0)},_addPlugin:function(e){var t=this;if(Nt(e))Rt(e,(function(e){t._addPlugin(e)}));else if(!Ct(this.plugins,(function(t){return e===t}))){if(this.plugins.push(e),!Dt(e))throw new Error("Plugins must be function values that return objects");var r=e.call(this);if(!Ut(r))throw new Error("Plugins must return an object of function properties");Rt(r,(function(r,n){if(!Dt(r))throw new Error("Bad plugin property: "+n+" from plugin "+e.name+". Plugins should only return functions.");t._assignPluginFnProp(r,n)}))}},addStorage:function(e){!function(){var e="undefined"==typeof console?null:console;if(e){(e.warn?e.warn:e.log).apply(e,arguments)}}("store.addStorage(storage) is deprecated. Use createStore([storages])"),this._addStorage(e)}},s=It(a,Mt,{plugins:[]});return s.raw={},Rt(s,(function(e,t){Dt(e)&&(s.raw[t]=qt(s,e))})),Rt(e,(function(e){s._addStorage(e)})),Rt(t,(function(e){s._addPlugin(e)})),s}var zt=Pt.Global,Bt={name:"localStorage",read:Wt,write:function(e,t){return Gt().setItem(e,t)},each:function(e){for(var t=Gt().length-1;t>=0;t--){var r=Gt().key(t);e(Wt(r),r)}},remove:function(e){return Gt().removeItem(e)},clearAll:function(){return Gt().clear()}};function Gt(){return zt.localStorage}function Wt(e){return Gt().getItem(e)}var Vt=n({__proto__:null,default:Bt},[Bt]),Qt=Pt.Global,Jt={name:"sessionStorage",read:Xt,write:function(e,t){return Kt().setItem(e,t)},each:function(e){for(var t=Kt().length-1;t>=0;t--){var r=Kt().key(t);e(Xt(r),r)}},remove:function(e){return Kt().removeItem(e)},clearAll:function(){return Kt().clear()}};function Kt(){return Qt.sessionStorage}function Xt(e){return Kt().getItem(e)}var Yt=n({__proto__:null,default:Jt},[Jt]),Zt=Pt.trim,er={name:"cookieStorage",read:function(e){if(!e||!ir(e))return null;var t="(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(tr.cookie.replace(new RegExp(t),"$1"))},write:function(e,t){if(!e)return;tr.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:rr,remove:nr,clearAll:function(){rr((function(e,t){nr(t)}))}},tr=Pt.Global.document;function rr(e){for(var t=tr.cookie.split(/; ?/g),r=t.length-1;r>=0;r--)if(Zt(t[r])){var n=t[r].split("="),i=unescape(n[0]);e(unescape(n[1]),i)}}function nr(e){e&&ir(e)&&(tr.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function ir(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(tr.cookie)}var ar=n({__proto__:null,default:er},[er]),sr={name:"memoryStorage",read:function(e){return or[e]},write:function(e,t){or[e]=t},each:function(e){for(var t in or)or.hasOwnProperty(t)&&e(or[t],t)},remove:function(e){delete or[e]},clearAll:function(e){or={}}},or={};var lr=n({__proto__:null,default:sr},[sr]);function cr(e,t){void 0===t&&(t=!1),e+="";for(var r,n=["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"],i=["0","1","2","3","4","5","6","7","8","9"],a=(t=t||!Salla.config.get("store.settings.arabic_numbers_enabled"))?n:i,s=t?i:n,o=0;o<a.length;o++)r=new RegExp(a[o],"g"),e=e.replace(r,s[o]);return e.replace(t?"٫":".",t?".":"٫")}function ur(e){var t=("".concat(e).match(/\./g)||[]).length;return t&&1!==t?ur(e.replace(/\.(.+)\./g,".$1")):e}function dr(e){return"".concat(e).startsWith("https://")||"".concat(e).startsWith("http://")}function hr(e){if(dr(e))return e;var t=Salla.config.get("store.url");return t||(t=window.location.href.split("/").slice(0,-1).join("/"),Salla.config.set("store.url",t)),t.rtrim("/")+"/"+(null==e?void 0:e.ltrim("/"))}function fr(e,t,r){if(r=r||window.location.href,!t||!e)return r;var n=new RegExp("([?&])"+e+"=[^&]+[&]?","g");return(r=r.replace(n,"$1").split("#")[0].replace(/&$|\?$/,"")).includes("?")?r+="&":r+=(r.endsWith("/")?"":"/")+"?",(r+e+"="+encodeURIComponent(t)).replace(/&$|\?$/,"")}function pr(e){return window.location.origin+"/"+(null==e?void 0:e.ltrim("/"))}function gr(e){return dr(e)?e:Salla.config.get("theme.assets")?Salla.config.get("theme.assets").replace(":path",null==e?void 0:e.ltrim("/")):pr("themes/"+Salla.config.get("theme.name")+"/"+(null==e?void 0:e.ltrim("/")))}function mr(e,t,r){var n,i=e[0];return r&&0==e.length?Array.isArray(r)?(r.push(t),r):[r,t]:Array.isArray(r)?(r.push(t),r):"string"==typeof r?[r,t]:r?(r[i]=mr(e.slice(1),t,r[i]),r):i?((n={})[i]=mr(e.slice(1),t),n):""===i?[t]:t}String.prototype.toStudlyCase=function(){return this.trim().replace(/([^a-zA-Z\d].)/g,(function(e){return e.toUpperCase().replace(/[^a-zA-Z\d]/g,"")}))},String.prototype.toDatasetName=function(){return this.startsWith("data-")?this.substr(5).toStudlyCase():this.toStudlyCase()},String.prototype.toSelector=function(){return this.trim().startsWith(".")||this.trim().startsWith("#")?this.toString():"#"+this.toString()},String.prototype.replaceArray=function(e,t){for(var r,n=this,i=0;i<e.length;i++)r=new RegExp(e[i],"g"),n=n.replace(r,t[i]);return n},String.prototype.rtrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("["+e+"]*$"),"")},String.prototype.ltrim=function(e){return void 0===e&&(e="\\s"),this.replace(new RegExp("^["+e+"]*"),"")},String.prototype.digitsOnly=function(){return Salla.helpers.digitsOnly(this)};var vr={digitsOnly:function(e){return cr(e,!0).replace(/[^0-9.]/g,"").replace("..",".").rtrim(".")},inputDigitsOnly:function e(t,r){if(void 0===r&&(r=!1),"string"==typeof t)return document.querySelectorAll(t).forEach((function(t){return e(t,r)}));if(t){var n=Salla.helpers.digitsOnly(t.value);return t.min&&n<parseInt(t.min)?t.value=t.min:t.max&&n>parseInt(t.max)?t.value=t.max:t.maxLength>=1&&n.toString().length>t.maxLength?t.value=n.toString().substring(0,t.maxLength):t.value=r||t.dataset.hasOwnProperty("digitsWithDecimal")?ur(n):n.replace(/\D/g,"")}Salla.logger.warn("Can't find Object With Id: "+t)},number:cr,money:function(e){var t=Salla.config.currency(null==e?void 0:e.currency).symbol;return cr(e="object"==typeof e?e.amount:e)+" "+t},setNested:function(e,t,r){for(var n=e,i=t.split("."),a=i.length,s=0;s<a-1;s++){var o=i[s];n[o]||(n[o]={}),n=n[o]}return n[i[a-1]]=r,e},getNested:function(e,t,r){var n=_t(e,t);return void 0!==n?n:r},inputData:function(e,t,r){if(void 0===r&&(r={}),e.includes("[")){var n=e.split("]").join("").split("[");return{name:n[0],value:mr(n.slice(1),t,r[n[0]])}}return{name:e,value:t}},url:Object.freeze({__proto__:null,is_full_url:dr,base:function(e){return dr(e)?e:"https://"+new URL(hr("/")).hostname+"/"+(null==e?void 0:e.ltrim("/"))},get:hr,domain:function(e){return dr(e)?e:"".concat(Salla.config.get("store.url",window.location.href.split("/").slice(0,-1).join("/")).rtrim("/"),"/").concat(null==e?void 0:e.ltrim("/"))},addParamToUrl:fr,baseUrl:pr,asset:gr,cdn:function(e){return"https://cdn.salla.network/"+(null==e?void 0:e.ltrim("/"))},api:function(e){var t;return(null===(t=Salla.config.get("store.api",hr("")))||void 0===t?void 0:t.rtrim("/"))+"/"+(null==e?void 0:e.ltrim("/"))},is_page:function(e){return e&&Salla.config.get("page.slug")===e},is_placeholder:function(e){return gr(salla.config.get("theme.settings.placeholder"))===gr(e)}}),addParamToUrl:fr,debounce:function(e,t){t=t||100;var r,n=[];return function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];return clearTimeout(r),r=setTimeout((function(){var t=e.apply(void 0,i);n.forEach((function(e){return e(t)})),n=[]}),t),new Promise((function(e){return n.push(e)}))}}},yr=function(e,t){return yr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},yr(e,t)},wr=function(){return wr=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},wr.apply(this,arguments)};function br(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}var _r,Sr,Er=(_r=console,Sr={log:function(e,t){if(_r&&salla.config.isDebug()){"trace"===salla.config.get("debug")&&(t="trace");var r=_r.log,n=void 0===t?r:this.__dict__[t]||r,i=["%cTwilight","color: #5cd5c4;font-weight:bold; border:1px solid #5cd5c4; padding: 2px 6px; border-radius: 5px;"],a={event:"#CFF680",backend:"#7b68ee"}[t];a&&(i[0]+="%c"+t[0].toUpperCase()+t.substring(1),i.push("margin-left: 5px;color: ".concat(a,";font-weight:bold; border:1px solid ").concat(a,"; padding: 2px 6px; border-radius: 5px;"))),n.call.apply(n,br([_r],i.concat.apply(i,e),!1))}},__dict__:{trace:_r.trace,debug:_r.debug,info:_r.info,warn:_r.warn,error:_r.error}},{event:function(){Sr.log(arguments,"event")},trace:function(){Sr.log(arguments,"trace")},debug:function(){Sr.log(arguments,"debug")},info:function(){Sr.log(arguments,"info")},warn:function(){Sr.log(arguments,"warn")},error:function(){Sr.log(arguments,"error")},log:function(){Sr.log(arguments,void 0)},backend:function(){Sr.log(arguments,"backend")},logs:function(e){[e].flat().forEach((function(e){return e&&Sr.log([e].flat(),"backend")}))}}),xr=function(){function e(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.default_properties=t,this.properties_=wr(wr({},this.default_properties),e)}return e.prototype.merge=function(e){var t;return this.properties_=wr(wr({},this.properties_),e),this.properties_.store=wr(wr({},(null===(t=this.default_properties)||void 0===t?void 0:t.store)||{}),this.properties_.store),this},e.prototype.set=function(e,t){return e.includes(".")?(Salla.helpers.setNested(this.properties_,e,t),this):(this.properties_[e]=t,this)},e.prototype.currency=function(e){return void 0===e&&(e=void 0),e=e||this.get("user.currency_code"),this.get("currencies."+e)||Object.values(this.get("currencies"))[0]},e.prototype.get=function(e,t){return void 0===t&&(t=null),e.includes(".")?Salla.helpers.getNested(this.properties_,e,t):this.properties_.hasOwnProperty(e)?this.properties_[e]||t:t||void 0},e.prototype.all=function(){return this.properties_},e.prototype.isDebug=function(){return this.get("debug")||Salla.storage.get("debug")},e}(),Fr=function(e){function t(){var t=this;return(t=e.call(this,{wildcard:!0,delimiter:"::",newListener:!1,removeListener:!1,maxListeners:10,verboseMemoryLeak:!1,ignoreErrors:!1})||this).delimiter="::","undefined"!=typeof document&&(t.body=document.querySelector("body")),t.logableEvents=["cart::item.added.failed","cart::item.deleted.failed"],t.ingoreLogEvents=["document::click","document::keyup","document::change"],t.noneFireableActions=["document.request"],t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}yr(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.createAndDispatch=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this.dispatch.apply(this,br([e],t,!1))},t.prototype.emit=function(t){for(var r,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var a=t.replace("::",".");if(!this.noneFireableActions.includes(a)&&Salla.call&&"function"==typeof Salla.call(a))return Salla.log("'Salla.".concat(a,"(...)' triggered using event '").concat(t,"'")),a=a.split("."),Array.isArray(n[0])&&(n=n[0]),void(r=salla[a[0]])[a[1]].apply(r,n);e.prototype.emit.apply(this,br([t],n,!1)),this.trackEvents.apply(this,br([t],n,!1))},t.prototype.emitAsync=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=e.prototype.emitAsync.apply(this,br([t],r,!1));try{this.trackEvents.apply(this,br([t],r,!1))}catch(e){Salla.logger.warn("error on tracking event (".concat(t,")"),r,e)}return i},t.prototype.trackEvents=function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("undefined"!=typeof window)try{window.dataLayer=window.dataLayer||[];var i={event:e};r.map((function(e){return"object"==typeof e&&(i=wr(wr({},i),e))})),window.dataLayer.push(i)}catch(e){salla.logger.error(e.message)}Salla.logger&&!this.ingoreLogEvents.includes(e)&&(t=Salla.logger).event.apply(t,br([e],r,!1)),this.dispatchMobileEvent.apply(this,br([e],r,!1))},t.prototype.dispatch=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return this.emit.apply(this,br([e],t,!1))},t.prototype.dispatchEvents=function(e){if(e)if("object"!=typeof e||Array.isArray(e))Salla.log("Events object is wrong, it should be object of {event:payload}",e);else for(var t=0,r=Object.entries(e);t<r.length;t++){var n=r[t],i=n[0],a=n[1];this.dispatch(i,a)}else Salla.log("No Events To Dispatch!",e)},t.prototype.addListener=function(e,t){return this.on(e,t)},t.prototype.addEventListener=function(e,t){return this.on(e,t)},t.prototype.listen=function(e,t){return this.on(e,t)},t.prototype.registerGlobalListener=function(e,t){return this.onAny(t)},t.prototype.dispatchMobileEvent=function(e,t){if(void 0===t&&(t={}),!("undefined"!=typeof window&&window.dataLayer&&window.dataLayer[0]&&window.dataLayer[0].page&&window.dataLayer[0].page.mobileApp))return"";if(window.webkit)try{window.webkit.messageHandlers.callbackHandler.postMessage(JSON.stringify({event:e,details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}else if(void 0!==window.Android)try{window.Android.customEventWithData(e,JSON.stringify({details:t}))}catch(e){Salla.log(e,"The native context does not exist yet")}},t}(St.exports.EventEmitter2),Ar=Ht.createStore([Vt,Yt,ar,lr],[]),Pr=function(){function e(){var e=this;Salla.event.on("storage::item.remove",(function(t){return e.remove(t)})),Salla.event.on("storage::item.set",(function(t,r){return e.set(t,r)})),this.store=Ar}return e.prototype.set=function(e,t){var r;if(e.includes(".")){var n=e.split(".")[0],i=((r={})[n]=this.store.get(n),r);return i=Salla.helpers.setNested(i,e,t),this.store.set(n,i[n])}return this.store.set(e,t)},e.prototype.remove=function(e){return this.store.remove(e)},e.prototype.clearAll=function(){return this.store.clearAll()},e.prototype.get=function(e,t){var r;if(e.includes(".")){var n=e.split(".")[0];return Salla.helpers.getNested(((r={})[n]=this.store.get(n),r),e)}return this.store.get(e,t)},e}(),Lr=function(){function e(){var e=this;Salla.event.on("cookies::remove",(function(t){return e.remove(t)})),Salla.event.on("cookies::add",(function(t,r){return e.set(t,r)}))}return e.prototype.get=function(e){var t;return null===(t=document.cookie.split("; ").find((function(t){return t.startsWith(e+"=")})))||void 0===t?void 0:t.split("=")[1]},e.prototype.set=function(e,t,r){void 0===t&&(t=""),void 0===r&&(r=10);var n="";if(r){var i=new Date;i.setTime(i.getTime()+24*r*60*60*1e3),n="; expires="+i.toUTCString()}return document.cookie="".concat(e,"=").concat(t).concat(n,'"; path=/; secure; SameSite=Lax"'),this},e.prototype.remove=function(e){return document.cookie="".concat(e,"=; Max-Age=0; path=/;"),this},e.prototype.clearAll=function(){for(var e=document.cookie.split(";"),t=0;t<e.length;t++){var r=e[t],n=r.indexOf("="),i=n>-1?r.substr(0,n):r;this.remove(i)}},e}();"undefined"!=typeof window&&(window.salla=window.salla||window.Salla||{},window.Salla=window.salla),void 0!==a&&(a.salla=a.salla||a.Salla||{},a.Salla=a.salla),Salla.status="base",Salla.config=new xr,Salla.logger=Er,Salla.event=new Fr,Salla.helpers=vr,Salla.storage=new Pr,Salla.cookie=new Lr,Salla.log=Salla.logger.log,Salla.money=Salla.helpers.money,Salla.url=Salla.helpers.url,Salla.versions={base:"2.12.3"};var kr=Salla;let Or=function(e,t,r){return alert(e)},Tr=function(e,t){return Or(e,jr.error,t)},jr={error:"error",success:"success",info:"info"};var Cr={fire:function(e,t,r){return Or(e,t,r)},setNotifier:function(e){Or=e,salla.event.emit("twilight::notifier.changed")},error:Tr,success:function(e,t){return Or(e,jr.success,t)},info:function(e,t){return Or(e,jr.info,t)},sallaInitiated:function(){let e=window.location.href.match(/([\?\&]danger=)[^&]+/g);e&&(window.history.replaceState(null,document.title,window.location.pathname),salla.event.once("twilight::notifier.changed",(()=>{e.forEach((e=>{Tr(decodeURI(e.replace("?danger=","").replace("&danger=","")))}))})))},types:jr};class Rr{constructor(e,t){return this.api=e,this.event=t,new Proxy(this,{get:function(r,n){return"event"===n?t:"api"===n?e:e&&e[n]||r[n]}})}}Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){for(var t=this;t;){if(t.matches(e))return t;t=t.parentElement}}),Element.prototype.getElementSallaData=function(e,...t){if(!this.getAttribute)return;if(this.hasAttribute("data-json"))try{return JSON.parse(this.getAttribute("data-json"))}catch(e){}let r=this.getAttribute("data-function");if(r&&window[r])return"function"==typeof window[r]?this.getFilteredData(window[r].call(this,...t)):this.getFilteredData(window[r]);let n=this.hasAttribute("data-form-selector")?document.querySelector(this.dataset.formSelector):void 0;if(n="FORM"===this.tagName?this:n||this.closest("form")||this.closest("[salla-form-data]")||this,n&&"FORM"===n.tagName)return this.getFilteredData(new FormData(n),null,n);let i=n.querySelectorAll("[name]");if(!i.length)return this.getFilteredData();let a=Object.assign({},this.dataset);return i.forEach((e=>{if(!["checkbox","radio"].includes(e.type)||e.checked)try{let t=Salla.helpers.inputData(e.name,e.value,a);a[t.name]=t.value}catch(t){Salla.log(e.name+" can't be send")}})),this.getFilteredData(a)},Element.prototype.canEventFireHook=function(e){return!!this.hasAttribute&&this.hasAttribute(Salla.api.hooksPrefix+e.type)},Element.prototype.hasAttributeStartsWith=function(e,t){e=e.toLowerCase();for(var r=0;r<this.attributes.length;r++){let n=this.attributes[r].name.toLowerCase();if(0===n.indexOf(e))return!t||n}return!1},HTMLFormElement.prototype.getAjaxFormData=function(e){var t=this.querySelectorAll('input[type="file"]');t.forEach((e=>{e.files.length||e.setAttribute("disabled","")}));var r=new FormData(this);return t.forEach((e=>{e.files.length||e.removeAttribute("disabled")})),{formData:this.getFilteredData(r,e),url:this.getAttribute("action"),method:this.getAttribute("method")||"post",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}},Element.prototype.getFilteredData=function(e=null,t=null,r=null){return e=e||r?.dataset||this.dataset,r&&this.name&&void 0!==this.value&&(e=function(e,t,r){e instanceof FormData?e.append(t,r):e[t]=r;return e}(e,this.name,this.value)),["filterBeforeSubmit","filterBeforeSend"].forEach((n=>{let i=r?.dataset[n]||this.dataset[n];if(i){var a=window[i];if("function"==typeof a){if(!a(e,r||this,t)&&e)throw`Data failed to be pass verify function window.${i}(formData, element, event)!`;return a(e,r||this,t)}Salla.log("window."+i+"() not found!")}})),e},HTMLAnchorElement.prototype.getAjaxFormData=function(e){return{formData:this.getFilteredData(null,e),url:this.getAttribute("href"),method:this.dataset.type||"get",events:{success:this.dataset.onSuccess,fail:this.dataset.onFail}}};class qr{constructor(){this.events={},this.namespace="";let e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase()}after_init(){this.createDynamicFunctions()}createDynamicFunctions(){Object.keys(this.events).forEach((e=>{this.createDynamicEventFuns(e),this.createDynamicListenerFuns(e)}))}createDynamicEventFuns(e){if(this[e])return;let t=this;this[e]=function(...r){return t.dispatch(e,...r)}}createDynamicListenerFuns(e){let t="on"+e.charAt(0).toUpperCase()+e.slice(1);if(this[t])return;let r=this;this[t]=function(t){return r.on(e,(async(...e)=>t(...e)))}}getEventName(e){return e=this.events[e]||e,!this.namespace||e.includes("::")?e:this.namespace+Salla.event.delimiter+e}dispatch(e,...t){return Salla.event.emitAsync(this.getEventName(e),...t)}on(e,t){return Salla.event.addListener(this.getEventName(e),t)}once(e,t){return Salla.event.once(this.getEventName(e),t)}}function Ir(e){e&&e.sallaInitiated&&!e.initiated&&(e.sallaInitiated(),e.initiated=!0)}Salla.event.auth=new class extends qr{constructor(){super(),this.namespace="auth",this.events={login:"login",logout:"logout",codeSent:"code.sent",codeNotSent:"code.not-sent",verified:"verified",verificationFailed:"verification.failed",loggedIn:"logged.in",registered:"registered",registrationFailed:"registration.failed",loggedOut:"logged.out",failedLogout:"failed.logout",refreshFailed:"refresh.failed",tokenFetched:"token.fetched"},this.after_init()}login(e){return e?(e.type&&this.setTypeActionOnVerified(e.type),this.next_event=e.next_event||null,this.dispatch("login",...arguments)):(this.next_event=null,this.dispatch("login",...arguments))}loggedIn(e){return Salla.profile.info().finally((()=>this.dispatch("loggedIn",e)))}setTypeActionOnVerified(e){this.type_action_on_verified=e}getTypeActionOnVerified(){return this.type_action_on_verified||"redirect"}},Salla.event.cart=new class extends qr{constructor(){super(),this.namespace="cart",this.events={latestFetched:"latest.fetched",latestFailed:"latest.failed",updated:"updated",itemUpdated:"item.updated",itemUpdatedFailed:"item.updated.failed",itemAdded:"item.added",itemAddedFailed:"item.added.failed",itemDeleted:"item.deleted",itemDeletedFailed:"item.deleted.failed",submitted:"submitted",submitFailed:"submit.failed",imageDeleted:"image.deleted",imageNotDeleted:"image.not.deleted",detailsFetched:"details.fetched",detailsNotFetched:"details.not.fetched",successReset:"success.reset",priceQuoteSucceeded:"price-quote.succeeded",priceQuoteFailed:"price-quote.failed",couponAdded:"coupon.added",couponDeleted:"coupon.deleted",couponAdditionFailed:"coupon.addition.failed",couponDeletionFailed:"coupon.deletion.failed",quickOrderSettingFetched:"quick-order.fetched",quickOrderSettingFailed:"quick-order.failed",quickOrderSucceeded:"quick-order.succeeded",quickOrderFailed:"quick-order.failed"},this.after_init()}updated(e){return Salla.cookie.set("fresh_summary",1),e&&"object"==typeof e?(e.offer&&salla.product.event.offerExisted(e.offer),e.redirect&&(salla.log("The current cart is purchased!"),salla.cart.api.reset()),e.cart?(salla.storage.set("cart.summary",{total:e.cart.total,sub_total:e.cart.sub_total,discount:e.cart.discount,real_shipping_cost:e.cart.real_shipping_cost,count:e.cart.count,shipping_cost:e.cart.free_shipping_bar?.has_free_shipping?0:e.cart.real_shipping_cost}),this.dispatch("updated",e.cart)):void salla.log("Failed to get the cart summary!")):(Salla.logger.info("Cart summary not an object!",e),this.dispatch("updated"))}latestFetched(e){return this.updated(e.data),this.dispatch("latestFetched",e)}itemAdded(e,t){return this.updated(e.data),this.dispatch("itemAdded",e,t)}itemDeleted(e,t){return this.updated(e.data),this.dispatch("itemDeleted",e,t)}itemUpdated(e,t){return this.updated(e.data),this.dispatch("itemUpdated",e,t)}couponAdded(e,t){return this.updated(e.data),this.dispatch("couponAdded",e,t)}couponDeleted(e,t){return this.updated(e.data),this.dispatch("couponDeleted",e,t)}},Salla.event.order=new class extends qr{constructor(){super(),this.namespace="order",this.events={canceled:"canceled",notCanceled:"not.canceled",orderCreated:"order.created",orderCreationFailed:"order.creation.failed",invoiceSent:"invoice.sent",invoiceNotSent:"invoice.not.sent"},this.after_init()}},Salla.event.scope=new class extends qr{constructor(){super(),this.namespace="scope",this.events={fetched:"fetched",notFetched:"not.fetched",productAvailabilityFetched:"product-availability.fetched",productAvailabilityNotFetched:"product-availability.not.fetched",changeSucceeded:"changed",changeFailed:"not.changed"},this.after_init()}},Salla.event.rating=new class extends qr{constructor(){super(),this.namespace="rating",this.events={orderNotFetched:"order.not.fetched",orderFetched:"order.fetched",storeRated:"store.rated",storeFailed:"store.failed",productsRated:"products.rated",productsFailed:"products.failed",shippingRated:"shipping.rated",shippingFailed:"shipping.failed"},this.after_init()}},Salla.event.booking=new class extends qr{constructor(){super(),this.namespace="booking",this.events={added:"added",additionFailed:"addition.failed"},this.after_init()}},Salla.event.comment=new class extends qr{constructor(){super(),this.namespace="comment",this.events={added:"added",additionFailed:"addition.failed",fetched:"fetched",fetchFailed:"fetch.failed"},this.after_init()}},Salla.event.landing=new class extends qr{constructor(){super(),this.namespace="landing",this.events={detailsFetched:"order.fetched",getDetailsFailed:"get.details.failed",orderCreated:"order.created",orderCreationFailed:"order.creation.failed"},this.after_init()}},Salla.event.loyalty=new class extends qr{constructor(){super(),this.namespace="loyalty",this.events={exchangeSucceeded:"exchange.succeeded",exchangeFailed:"exchange.failed",programFetched:"program.fetched",programNotFetched:"program.not.fetched",resetSucceeded:"exchange-reset.succeeded",resetFailed:"exchange-reset.failed"},this.after_init()}exchangeSucceeded(e,t){return salla.cart.event.updated(e.data),this.dispatch("exchangeSucceeded",e,t)}resetSucceeded(e){return salla.cart.event.updated(e.data),this.dispatch("resetSucceeded",e)}},Salla.event.product=new class extends qr{constructor(){super(),this.namespace="product",this.events={priceUpdated:"price.updated",priceUpdateFailed:"price.updated.failed",availabilitySubscribed:"availability.subscribed",availabilitySubscribeFailed:"availability.subscribe.failed",categoriesFetched:"categories.fetched",categoriesFailed:"categories.failed",searchFailed:"search.failed",searchResults:"search.results",offerExisted:"offer.existed",fetchOffersFailed:"fetch.offers.failed",offersFetched:"offers.fetched",sizeGuideFetched:"size-guide.fetched",sizeGuideFetchFailed:"size-guide.failed",giftFetched:"gift.fetched",giftFetchFailed:"gift.failed",detailFetched:"detail.fetched",detailFetchFailed:"detail.failed",addGiftToCartSucceeded:"gift.add-to-cart.succeeded",addGiftToCartFailed:"gift.add-to-cart.failed",giftImageUploadSucceeded:"gift.image-upload.succeeded",giftImageUploadFailed:"gift.image-upload.failed",productListFetchSucceeded:"fetch.succeeded",productListFetchFailed:"fetch.failed"},this.after_init()}},Salla.event.profile=new class extends qr{constructor(){super(),this.namespace="profile",this.events={updated:"updated",updateFailed:"update.failed",verificationCodeSent:"verification.code.sent",updateContactsFailed:"update.contacts.failed",verified:"verified",unverified:"unverified",infoFetched:"info.fetched",infoNotFetched:"info.not.fetched",settingsUpdated:"settings.updated",updateSettingsFailed:"update.settings.failed",deleted:"deleted",notDeleted:"not.deleted"},this.after_init()}},Salla.event.currency=new class extends qr{constructor(){super(),this.namespace="currency",this.events={changed:"changed",failed:"failed",fetched:"fetched",failedToFetch:"failed.to.fetch"},this.after_init()}},Salla.event.document=new class extends qr{constructor(){super(),this.namespace="document",this.events={click:"click",change:"change",submit:"submit",keyup:"keyup",leaving:"leaving",request:"request",requestFailed:"request.failed"},this.after_init()}onClick(e,t){this.fireCallableFuns("click",e,t)}onChange(e,t){this.fireCallableFuns("change",e,t)}onSubmit(e,t){this.fireCallableFuns("submit",e,t)}onKeyup(e,t){this.fireCallableFuns("keyup",e,t)}fireCallableFuns(e,t,r){this.on(e,(e=>{"function"!=typeof t?"function"==typeof r&&e.target.matches(t)&&r(e):t(e)}))}fireEvent(e,t,...r){return this.fireEventForElements(e,t,!1,...r)}fireEventForAll(e,t,...r){return this.fireEventForElements(e,t,!0,...r)}fireEventForElements(e,t,r,...n){if("string"==typeof e){if(r)return document.querySelectorAll(e).forEach((e=>this.fireEventForElements(e,t,!1,...n)));e=document.querySelector(e)}if(!e)return void salla.log("Failed To get element to fire event: "+t);const i=new CustomEvent(t,...n);return e.dispatchEvent(i)}},Salla.event.wishlist=new class extends qr{constructor(){super(),this.namespace="wishlist",this.events={added:"added",removed:"removed",additionFailed:"addition.failed",removingFailed:"removing.failed"},this.after_init()}},Salla.event.infiniteScroll=new class extends qr{constructor(){super(),this.namespace="infiniteScroll",this.events={scrollThreshold:"scroll.threshold",request:"request",load:"load",append:"append",error:"error",last:"last",history:"history"},this.after_init()}},Salla.event.on("twilight::initiated",(()=>{Object.keys(Salla).forEach((e=>{"object"==typeof(e=Salla[e])&&(Ir(e),Object.keys(e).forEach((t=>{Ir(e[t])})))}))})),Salla.config.default_properties={debug:"undefined"!=typeof process&&"development"===process.env.NODE_ENV,token:null,fastRequests:!0,canLeave:!0,store:{api:"https://api.salla.dev/store/v1/"},currencies:{SAR:{code:"SAR",name:"ريال سعودي",symbol:"ر.س",amount:1,country_code:"sa"}}},Salla.config.merge(Salla.config.default_properties),Salla.config.triedToGetCurrencies_=!1,Salla.config.triedToGetLanguages_=!1,Salla.config.isUser=()=>"user"===Salla.config.get("user.type"),Salla.config.isGuest=()=>!Salla.config.isUser(),Salla.config.languages=async()=>{if(Salla.config.triedToGetLanguages_)return Salla.config.get("languages");Salla.config.triedToGetLanguages_=!0;let e=!0,t=[];return(await salla.document.api.request("languages",null,"get"))?.data?.map((r=>{e&&(t=[],e=!1),r.code=r.code||r.iso_code,r.url=salla.url.get(r.code),r.is_rtl=r.is_rtl||r.rtl,t.push(r)})),Salla.config.set("languages",t),t},Salla.config.currencies=async()=>{if(Salla.config.triedToGetCurrencies_)return Salla.config.get("currencies");Salla.config.triedToGetCurrencies_=!0;let e=!0,t={};return(await salla.currency.api.list())?.data?.map((r=>{e&&(t={},e=!1),r.country_code=r.code.substr(0,2).toLowerCase(),t[r.code]=r})),Salla.config.set("currencies",t),t};var Nr,Dr={exports:{}},Ur={exports:{}},Hr={exports:{}};function Mr(){return Nr||(Nr=1,function(e){!function(t,r){e.exports?e.exports=r():t.EvEmitter=r()}("undefined"!=typeof window?window:s,(function(){function e(){}let t=e.prototype;return t.on=function(e,t){if(!e||!t)return this;let r=this._events=this._events||{},n=r[e]=r[e]||[];return n.includes(t)||n.push(t),this},t.once=function(e,t){if(!e||!t)return this;this.on(e,t);let r=this._onceEvents=this._onceEvents||{};return(r[e]=r[e]||{})[t]=!0,this},t.off=function(e,t){let r=this._events&&this._events[e];if(!r||!r.length)return this;let n=r.indexOf(t);return-1!=n&&r.splice(n,1),this},t.emitEvent=function(e,t){let r=this._events&&this._events[e];if(!r||!r.length)return this;r=r.slice(0),t=t||[];let n=this._onceEvents&&this._onceEvents[e];for(let i of r){n&&n[i]&&(this.off(e,i),delete n[i]),i.apply(this,t)}return this},t.allOff=function(){return delete this._events,delete this._onceEvents,this},e}))}(Hr)),Hr.exports}var $r,zr,Br={exports:{}};function Gr(){return $r||($r=1,function(e){!function(t,r){e.exports?e.exports=r(t):t.fizzyUIUtils=r(t)}(s,(function(e){let t={extend:function(e,t){return Object.assign(e,t)},modulo:function(e,t){return(e%t+t)%t},makeArray:function(e){if(Array.isArray(e))return e;if(null==e)return[];return"object"==typeof e&&"number"==typeof e.length?[...e]:[e]},removeFrom:function(e,t){let r=e.indexOf(t);-1!=r&&e.splice(r,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){let t="on"+e.type;this[t]&&this[t](e)},filterFindElements:function(e,r){return(e=t.makeArray(e)).filter((e=>e instanceof HTMLElement)).reduce(((e,t)=>{if(!r)return e.push(t),e;t.matches(r)&&e.push(t);let n=t.querySelectorAll(r);return e=e.concat(...n)}),[])},debounceMethod:function(e,t,r){r=r||100;let n=e.prototype[t],i=t+"Timeout";e.prototype[t]=function(){clearTimeout(this[i]);let e=arguments;this[i]=setTimeout((()=>{n.apply(this,e),delete this[i]}),r)}},docReady:function(e){let 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,r){return t+"-"+r})).toLowerCase()}},r=e.console;return t.htmlInit=function(n,i){t.docReady((function(){let a="data-"+t.toDashed(i),s=document.querySelectorAll(`[${a}]`),o=e.jQuery;[...s].forEach((e=>{let t,s=e.getAttribute(a);try{t=s&&JSON.parse(s)}catch(t){return void(r&&r.error(`Error parsing ${a} on ${e.className}: ${t}`))}let l=new n(e,t);o&&o.data(e,i,l)}))}))},t}))}(Br)),Br.exports}function Wr(){return zr||(zr=1,function(e){!function(t,r){e.exports?e.exports=r(t,Mr(),Gr()):t.InfiniteScroll=r(t,t.EvEmitter,t.fizzyUIUtils)}(window,(function(e,t,r){let n=e.jQuery,i={};function a(e,t){let s=r.getQueryElement(e);if(s){if((e=s).infiniteScrollGUID){let r=i[e.infiniteScrollGUID];return r.option(t),r}this.element=e,this.options={...a.defaults},this.option(t),n&&(this.$element=n(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(s||e))}a.defaults={},a.create={},a.destroy={};let s=a.prototype;Object.assign(s,t.prototype);let o=0;s.create=function(){let e=this.guid=++o;if(this.element.infiniteScrollGUID=e,i[e]=this,this.pageIndex=1,this.loadCount=0,this.updateGetPath(),this.getPath&&this.getPath()){this.updateGetAbsolutePath(),this.log("initialized",[this.element.className]),this.callOnInit();for(let e in a.create)a.create[e].call(this)}else console.error("Disabling InfiniteScroll")},s.option=function(e){Object.assign(this.options,e)},s.callOnInit=function(){let e=this.options.onInit;e&&e.call(this,this)},s.dispatchEvent=function(e,t,r){this.log(e,r);let i=t?[t].concat(r):r;if(this.emitEvent(e,i),!n||!this.$element)return;let a=e+=".infiniteScroll";if(t){let r=n.Event(t);r.type=e,a=r}this.$element.trigger(a,r)};let l={initialized:e=>`on ${e}`,request:e=>`URL: ${e}`,load:(e,t)=>`${e.title||""}. URL: ${t}`,error:(e,t)=>`${e}. URL: ${t}`,append:(e,t,r)=>`${r.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}`}};s.log=function(e,t){if(!this.options.debug)return;let r=`[InfiniteScroll] ${e}`,n=l[e];n&&(r+=". "+n.apply(this,t)),console.log(r)},s.updateMeasurements=function(){this.windowHeight=e.innerHeight;let t=this.element.getBoundingClientRect();this.top=t.top+e.scrollY},s.updateScroller=function(){let t=this.options.elementScroll;if(t){if(this.scroller=!0===t?this.element:r.getQueryElement(t),!this.scroller)throw new Error(`Unable to find elementScroll: ${t}`)}else this.scroller=e},s.updateGetPath=function(){let e=this.options.path;if(!e)return void console.error(`InfiniteScroll path option required. Set as: ${e}`);let t=typeof e;"function"!=t?"string"==t&&e.match("{{#}}")?this.updateGetPathTemplate(e):this.updateGetPathSelector(e):this.getPath=e},s.updateGetPathTemplate=function(e){this.getPath=()=>{let t=this.pageIndex+1;return e.replace("{{#}}",t)};let t=e.replace(/(\\\?|\?)/,"\\?").replace("{{#}}","(\\d\\d?\\d?)"),r=new RegExp(t),n=location.href.match(r);n&&(this.pageIndex=parseInt(n[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))};let c=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/],u=a.getPathParts=function(e){if(e)for(let t of c){let r=e.match(t);if(r){let[,e,t,n]=r;return{begin:e,index:t,end:n}}}};s.updateGetPathSelector=function(e){let t=document.querySelector(e);if(!t)return void console.error(`Bad InfiniteScroll path option. Next link not found: ${e}`);let r=t.getAttribute("href"),n=u(r);if(!n)return void console.error(`InfiniteScroll unable to parse next link href: ${r}`);let{begin:i,index:a,end:s}=n;this.isPathSelector=!0,this.getPath=()=>i+(this.pageIndex+1)+s,this.pageIndex=parseInt(a,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])},s.updateGetAbsolutePath=function(){let e=this.getPath();if(e.match(/^http/)||e.match(/^\//))return void(this.getAbsolutePath=this.getPath);let{pathname:t}=location,r=e.match(/^\?/),n=t.substring(0,t.lastIndexOf("/")),i=r?t:n+"/";this.getAbsolutePath=()=>i+this.getPath()},a.create.hideNav=function(){let e=r.getQueryElement(this.options.hideNav);e&&(e.style.display="none",this.nav=e)},a.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},s.destroy=function(){this.allOff();for(let e in a.destroy)a.destroy[e].call(this);delete this.element.infiniteScrollGUID,delete i[this.guid],n&&this.$element&&n.removeData(this.element,"infiniteScroll")},a.throttle=function(e,t){let r,n;return t=t||200,function(){let i=+new Date,a=arguments,s=()=>{r=i,e.apply(this,a)};r&&i<r+t?(clearTimeout(n),n=setTimeout(s,t)):s()}},a.data=function(e){let t=(e=r.getQueryElement(e))&&e.infiniteScrollGUID;return t&&i[t]},a.setJQuery=function(e){n=e},r.htmlInit(a,"infinite-scroll"),s._init=function(){};let{jQueryBridget:d}=e;return n&&d&&d("infiniteScroll",a,n),a}))}(Ur)),Ur.exports}var Vr,Qr={exports:{}};function Jr(){return Vr||(Vr=1,function(e){!function(t,r){e.exports?e.exports=r(t,Wr()):r(t,t.InfiniteScroll)}(window,(function(e,t){let r=t.prototype;Object.assign(t.defaults,{loadOnScroll:!0,checkLastPage:!0,responseBody:"text",domParseResponse:!0}),t.create.pageLoad=function(){this.canLoad=!0,this.on("scrollThreshold",this.onScrollThresholdLoad),this.on("load",this.checkLastPage),this.options.outlayer&&this.on("append",this.onAppendOutlayer)},r.onScrollThresholdLoad=function(){this.options.loadOnScroll&&this.loadNextPage()};let n=new DOMParser;function i(e){let t=document.createDocumentFragment();return e&&t.append(...e),t}return r.loadNextPage=function(){if(this.isLoading||!this.canLoad)return;let{responseBody:e,domParseResponse:t,fetchOptions:r}=this.options,i=this.getAbsolutePath();this.isLoading=!0,"function"==typeof r&&(r=r());let a=fetch(i,r).then((r=>{if(!r.ok){let e=new Error(r.statusText);return this.onPageError(e,i,r),{response:r}}return r[e]().then((a=>("text"==e&&t&&(a=n.parseFromString(a,"text/html")),204==r.status?(this.lastPageReached(a,i),{body:a,response:r}):this.onPageLoad(a,i,r))))})).catch((e=>{this.onPageError(e,i)}));return this.dispatchEvent("request",null,[i,a]),a},r.onPageLoad=function(e,t,r){return this.options.append||(this.isLoading=!1),this.pageIndex++,this.loadCount++,this.dispatchEvent("load",null,[e,t,r]),this.appendNextPage(e,t,r)},r.appendNextPage=function(e,t,r){let{append:n,responseBody:a,domParseResponse:s}=this.options;if(!("text"==a&&s)||!n)return{body:e,response:r};let o=e.querySelectorAll(n),l={body:e,response:r,items:o};if(!o||!o.length)return this.lastPageReached(e,t),l;let c=i(o),u=()=>(this.appendItems(o,c),this.isLoading=!1,this.dispatchEvent("append",null,[e,t,o,r]),l);return this.options.outlayer?this.appendOutlayerItems(c,u):u()},r.appendItems=function(e,t){e&&e.length&&(function(e){let t=e.querySelectorAll("script");for(let e of t){let t=document.createElement("script"),r=e.attributes;for(let e of r)t.setAttribute(e.name,e.value);t.innerHTML=e.innerHTML,e.parentNode.replaceChild(t,e)}}(t=t||i(e)),this.element.appendChild(t))},r.appendOutlayerItems=function(r,n){let i=t.imagesLoaded||e.imagesLoaded;return i?new Promise((function(e){i(r,(function(){let t=n();e(t)}))})):(console.error("[InfiniteScroll] imagesLoaded required for outlayer option"),void(this.isLoading=!1))},r.onAppendOutlayer=function(e,t,r){this.options.outlayer.appended(r)},r.checkLastPage=function(e,t){let r,{checkLastPage:n,path:i}=this.options;if(n){if("function"==typeof i){if(!this.getPath())return void this.lastPageReached(e,t)}"string"==typeof n?r=n:this.isPathSelector&&(r=i),r&&e.querySelector&&(e.querySelector(r)||this.lastPageReached(e,t))}},r.lastPageReached=function(e,t){this.canLoad=!1,this.dispatchEvent("last",null,[e,t])},r.onPageError=function(e,t,r){return this.isLoading=!1,this.canLoad=!1,this.dispatchEvent("error",null,[e,t,r]),e},t.create.prefill=function(){if(!this.options.prefill)return;let e=this.options.append;e?(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}`)},r.prefill=function(){let e=this.getPrefillDistance();this.isPrefilling=e>=0,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},r.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},r.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},t}))}(Qr)),Qr.exports}var Kr,Xr={exports:{}};function Yr(){return Kr||(Kr=1,function(e){!function(t,r){e.exports?e.exports=r(t,Wr(),Gr()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let n=t.prototype;return Object.assign(t.defaults,{scrollThreshold:400}),t.create.scrollWatch=function(){this.pageScrollHandler=this.onPageScroll.bind(this),this.resizeHandler=this.onResize.bind(this);let e=this.options.scrollThreshold;(e||0===e)&&this.enableScrollWatch()},t.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(t){let r=t?"addEventListener":"removeEventListener";this.scroller[r]("scroll",this.pageScrollHandler),e[r]("resize",this.resizeHandler)},n.onPageScroll=t.throttle((function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")})),n.getBottomDistance=function(){let t,r;return this.options.elementScroll?(t=this.scroller.scrollHeight,r=this.scroller.scrollTop+this.scroller.clientHeight):(t=this.top+this.element.clientHeight,r=e.scrollY+this.windowHeight),t-r},n.onResize=function(){this.updateMeasurements()},r.debounceMethod(t,"onResize",150),t}))}(Xr)),Xr.exports}var Zr,en={exports:{}};function tn(){return Zr||(Zr=1,function(e){!function(t,r){e.exports?e.exports=r(t,Wr(),Gr()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let n=t.prototype;Object.assign(t.defaults,{history:"replace"});let i=document.createElement("a");return t.create.history=function(){if(!this.options.history)return;i.href=this.getAbsolutePath(),(i.origin||i.protocol+"//"+i.host)==location.origin?this.options.append?this.createHistoryAppend():this.createHistoryPageLoad():console.error(`[InfiniteScroll] cannot set history with different origin: ${i.origin} on ${location.origin} . History behavior disabled.`)},n.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)},n.bindHistoryAppendEvents=function(t){let r=t?"addEventListener":"removeEventListener";this.scroller[r]("scroll",this.scrollHistoryHandler),e[r]("unload",this.unloadHandler)},n.createHistoryPageLoad=function(){this.on("load",this.onPageLoadHistory)},t.destroy.history=n.destroyHistory=function(){this.options.history&&this.options.append&&this.bindHistoryAppendEvents(!1)},n.onAppendHistory=function(e,t,r){if(!r||!r.length)return;let n=r[0],a=this.getElementScrollY(n);i.href=t,this.scrollPages.push({top:a,path:i.href,title:e.title})},n.getElementScrollY=function(t){if(this.options.elementScroll)return t.offsetTop-this.top;return t.getBoundingClientRect().top+e.scrollY},n.onScrollHistory=function(){let e=this.getClosestScrollPage();e!=this.scrollPage&&(this.scrollPage=e,this.setHistory(e.title,e.path))},r.debounceMethod(t,"onScrollHistory",150),n.getClosestScrollPage=function(){let t,r;t=this.options.elementScroll?this.scroller.scrollTop+this.scroller.clientHeight/2:e.scrollY+this.windowHeight/2;for(let e of this.scrollPages){if(e.top>=t)break;r=e}return r},n.setHistory=function(e,t){let r=this.options.history;r&&history[r+"State"]&&(history[r+"State"](null,e,t),this.options.historyTitle&&(document.title=e),this.dispatchEvent("history",null,[e,t]))},n.onUnload=function(){if(0===this.scrollPage.top)return;let t=e.scrollY-this.scrollPage.top+this.top;this.destroyHistory(),scrollTo(0,t)},n.onPageLoadHistory=function(e,t){this.setHistory(e.title,t)},t}))}(en)),en.exports}var rn,nn={exports:{}};function an(){return rn||(rn=1,function(e){!function(t,r){e.exports?e.exports=r(t,Wr(),Gr()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){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(){let e=r.getQueryElement(this.options.button);e&&(this.button=new n(e,this))},t.destroy.button=function(){this.button&&this.button.destroy()},t.Button=n,t}))}(nn)),nn.exports}var sn,on={exports:{}};function ln(){return sn||(sn=1,function(e){!function(t,r){e.exports?e.exports=r(t,Wr(),Gr()):r(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(e,t,r){let n=t.prototype;function i(e){s(e,"none")}function a(e){s(e,"block")}function s(e,t){e&&(e.style.display=t)}return t.create.status=function(){let e=r.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){let 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){a(this.statusElement),this.hideStatusEventElements(),a(this.statusEventElements[e])},n.hideAllStatus=function(){i(this.statusElement),this.hideStatusEventElements()},n.hideStatusEventElements=function(){for(let e in this.statusEventElements){i(this.statusEventElements[e])}},t}))}(on)),on.exports}
|
|
2
2
|
/*!
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
* Infinite Scroll v4.0.1
|
|
4
|
+
* Automatically add next page
|
|
5
|
+
*
|
|
6
|
+
* Licensed GPLv3 for open source use
|
|
7
|
+
* or Infinite Scroll Commercial License for commercial use
|
|
8
|
+
*
|
|
9
|
+
* https://infinite-scroll.com
|
|
10
|
+
* Copyright 2018-2020 Metafizzy
|
|
11
|
+
*/!function(e){window,e.exports&&(e.exports=function(e){return e}(Wr(),Jr(),Yr(),tn(),an(),ln()))}(Dr);var cn=Dr.exports;var un={exports:{}};
|
|
12
12
|
/*!
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*/
|
|
20
|
-
!function(e,t){e.exports=function(){function e(){if("undefined"!=typeof document&&document.documentElement)return document.documentElement.lang}function t(e){return"-Inf"===e?-1/0:"+Inf"===e||"Inf"===e||"*"===e?1/0:parseInt(e,10)}var n=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/,r=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/,a={locale:"en"},i=function(t){t=t||{},this.locale=t.locale||e()||a.locale,this.fallback=t.fallback,this.messages=t.messages};return i.prototype.setMessages=function(e){this.messages=e},i.prototype.getLocale=function(){return this.locale||this.fallback},i.prototype.setLocale=function(e){this.locale=e},i.prototype.getFallback=function(){return this.fallback},i.prototype.setFallback=function(e){this.fallback=e},i.prototype.has=function(e,t){return!("string"!=typeof e||!this.messages)&&null!==this._getMessage(e,t)},i.prototype.get=function(e,t,n){if(!this.has(e,n))return e;var r=this._getMessage(e,n);return null===r?e:(t&&(r=this._applyReplacements(r,t)),r)},i.prototype.trans=function(e,t){return this.get(e,t)},i.prototype.choice=function(e,t,n,a){(n=void 0!==n?n:{}).count=t;var i=this.get(e,n,a);if(null==i)return i;for(var o=i.split("|"),s=[],l=0;l<o.length;l++)if(o[l]=o[l].trim(),r.test(o[l])){var c=o[l].split(/\s/);s.push(c.shift()),o[l]=c.join(" ")}if(1===o.length)return i;for(var u=0;u<s.length;u++)if(this._testInterval(t,s[u]))return o[u];return a=a||this._getLocale(e),o[this._getPluralForm(t,a)]},i.prototype.transChoice=function(e,t,n){return this.choice(e,t,n)},i.prototype._parseKey=function(e,t){if("string"!=typeof e||"string"!=typeof t)return null;var n=e.split("."),r=n[0].replace(/\//g,".");return{source:t+"."+r,sourceFallback:this.getFallback()+"."+r,entries:n.slice(1)}},i.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 n=this.messages[e.source],r=e.entries.slice(),a=r.join(".");if("string"!=typeof(n=void 0!==n?this._getValueInKey(n,a):void 0)&&this.messages[e.sourceFallback])for(n=this.messages[e.sourceFallback],r=e.entries.slice(),a="";r.length&&void 0!==n;)n[a=a?a.concat(".",r.shift()):r.shift()]&&(n=n[a],a="");return"string"!=typeof n?null:n},i.prototype._getValueInKey=function(e,t){if("string"==typeof e[t])return e[t];for(var n=(t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),r=0,a=n.length;r<a;++r){var i=n.slice(0,r+1).join("."),o=n.slice(r+1,n.length).join(".");if(e[i])return this._getValueInKey(e[i],o)}return e},i.prototype._getLocale=function(e){return e=this._parseKey(e,this.locale),this.messages[e.source]?this.locale:this.messages[e.sourceFallback]?this.fallback:null},i.prototype._findMessageInTree=function(e,t){for(;e.length&&void 0!==t;){var n=e.join(".");if(t[n]){t=t[n];break}t=t[e.shift()]}return t},i.prototype._sortReplacementKeys=function(e,t){return t.length-e.length},i.prototype._applyReplacements=function(e,t){return Object.keys(t).sort(this._sortReplacementKeys).forEach((function(n){e=e.replace(new RegExp(":"+n,"gi"),(function(e){var r=t[n];return e===e.toUpperCase()?r.toUpperCase():e===e.replace(/\w/i,(function(e){return e.toUpperCase()}))?r.charAt(0).toUpperCase()+r.slice(1):r}))})),e},i.prototype._testInterval=function(e,r){if("string"!=typeof r)throw"Invalid interval: should be a string.";var a=(r=r.trim()).match(n);if(!a)throw"Invalid interval: "+r;if(!a[2]){var i=(a=a.filter((function(e){return!!e})))[1],o=t(a[2]);o===1/0&&(o=-1/0);var s=t(a[3]),l=a[4];return("["===i?e>=o:e>o)&&("]"===l?e<=s:e<s)}for(var c=a[2].split(","),u=0;u<c.length;u++)if(parseInt(c[u],10)===e)return!0;return!1},i.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:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2;case"cs":case"sk":return 1==e?0:e>=2&&e<=4?1:2;case"ga":return 1==e?0:2==e?1:2;case"lt":return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?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||e%100>1&&e%100<11?1:e%100>10&&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:e%10>=2&&e%10<=4&&(e%100<12||e%100>14)?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||e%100>0&&e%100<20?1:2;case"ar":return 0===e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11&&e%100<=99?4:5}},i}()}(le);var ce,ue=function(e){function t(t){var n=this;return(t=t||{}).messages=t.messages||window.translations,t.locale=t.locale||(window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],t.fallback=t.fallback||t.locale,(n=e.call(this,t)||this).translationsLoaded=!1,n}return u(t,e),t.prototype.onLoaded=function(e){if(this.translationsLoaded)return e();Salla.event.once("languages::translations.loaded",e)},t.prototype.loadStoreTranslations=function(){if(this.hash=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),this.messages||(salla.log("try to load translations from localstorage"),this.messages=salla.storage.get("s_translations.".concat(this.hash)),this.messages&&(this.translationsLoaded=!0)&&e.prototype.setMessages.call(this,this.messages)),this.messages)return salla.event.dispatch("languages::translations.loaded"),void salla.logger.info("The messages of transactions is already loaded");salla.url.get("")?this.loadScript(salla.url.get("languages/assets/".concat(this.hash,".js"))):this.loadScript("https://cdn.salla.network/js/translations.js",!1)},t.prototype.setMessages=function(t){e.prototype.setMessages.call(this,t),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0},t.prototype.loadScript=function(e,t){var n=this;void 0===t&&(t=!0);var r=document.createElement("script");r.src=e,r.onload=function(){var e;if(window.translations)return salla.storage.remove("s_translations"),salla.storage.set("s_translations",((e={})[n.hash]=window.translations,e)),n.setMessages(window.translations);r.onerror()},r.onerror=function(){if(t)return salla.logger.warn("Failed to load Translations for store, lets try load it from CDN"),n.loadScript("https://cdn.salla.network/js/translations.js",!1);salla.logger.error("Failed to load Translations, check your network logs for more details\nor: salla.lang.setMessages({....}), see https://docs.salla.dev for more information's.")},document.head.appendChild(r)},t.prototype.getWithDefault=function(e,t,n,r){var a=this.get(e,n,r);return a!==e?a:t},t.prototype.get=function(t,n,r){var a=t;(window.translations||this.translationsLoaded)&&(a="trans."+t);var i=e.prototype.get.call(this,a,n,r);return i!==a?i:e.prototype.get.call(this,a,n,"en").replace(a,t)},t.prototype.set=function(e,t){return salla.helpers.setNested(this.messages[this.getLocale()+".trans"],e,t),this},t}(le.exports),de=function(){function e(){this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};var e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}return e.prototype.after_init=function(){},e.prototype.normalRequest=function(e,t,n){void 0===t&&(t=void 0),void 0===n&&(n=null);var r=Array.isArray(e),a=r?this.getUrl.apply(this,e):this.getUrl(e);e=r?e[0]:e,n=n||this.endpointsMethods[e]||"post";var i=this.endpointsHeaders[e];if("get"===n&&t instanceof FormData){var o={};Array.from(t.entries()).forEach((function(e){o[e[0]]=e[1]})),t={params:o}}return i&&"get"===n&&(t=t?Object.assign(t,i):i),this.webEndpoints.includes(e)?a=salla.url.get(a):"http"!==a.substring(0,4)&&(a=salla.url.api(a)),Salla.api.request(a,t,n,{headers:i})},e.prototype.request=function(e,t,n){return void 0===t&&(t=void 0),void 0===n&&(n=null),!salla.api.isFastRequestsAllowed()&&this.debounce.enabled?(this.debounce.request||(this.debounce.request=salla.helpers.debounce(this.normalRequest.bind(this),this.debounce.time)),this.debounce.request(e,t,n)):this.normalRequest(e,t,n)},e.prototype.getUrl=function(e){for(var t=this.endpoints[e]||e,n=/{[^{}]+}/i,r=1;r<arguments.length;r++)t=t.replace(n,arguments[r]);return t},e.prototype.event=function(){return salla.event[this.className]},e}(),he=function(e){function t(){var t=e.call(this)||this;return t.namespace="cart",t.endpoints={latest:"cart/latest",details:"cart/{cart}",quickAdd:"cart/{cart}/item/{product}/quick-add",addItem:"cart/{cart}/item/{product}/add",deleteItem:"cart/{cart}/item/{item}",updateItem:"cart/{cart}/item/{item}",deleteImage:"cart/{cart}/image/{image}",uploadImage:"cart/{cart}/image",status:"cart/{cart}/status",addCoupon:"cart/{id}/coupon",deleteCoupon:"cart/{id}/coupon",getQuickOrderSettings:"checkout/quick-order",createQuickOrder:"checkout/quick-order",priceQuote:"cart/{cartId}/price-quote"},t.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get"},t.webEndpoints=["latest"],t.latestCart=null,t.after_init(),salla.event.on("api::initiated",(function(){return t.getCurrentCartId()})),t}return u(t,e),t.prototype.getCurrentCartId=function(){return h(this,void 0,void 0,(function(){var e,t;return f(this,(function(n){switch(n.label){case 0:return salla.cart.api.latestCart?[2,salla.cart.api.latestCart.cart.id]:(e=salla.storage.get("cart.id"))?[2,e]:[4,this.latest()];case 1:return t=n.sent(),salla.cart.api.latestCart=t.data,[2,salla.cart.api.latestCart.cart.id]}}))}))},t.prototype.getUploadImageEndpoint=function(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))},t.prototype.latest=function(){return this.request("latest",{params:{source:""}}).then((function(e){return salla.storage.set("cart",e.data.cart),salla.event.cart.latestFetched(e),e})).catch((function(e){throw salla.storage.set("cart",""),salla.event.cart.latestFailed(e),e}))},t.prototype.details=function(e,t){return void 0===t&&(t=[]),h(this,void 0,void 0,(function(){var n;return f(this,(function(r){switch(r.label){case 0:return(n=e)?[3,2]:[4,this.getCurrentCartId()];case 1:n=r.sent(),r.label=2;case 2:return e=n,[2,this.request(["details",e],{params:{with:t}}).then((function(e){return salla.cart.event.detailsFetched(e),e})).catch((function(e){throw salla.cart.event.detailsNotFetched(e),e}))]}}))}))},t.prototype.quickAdd=function(e,t){return h(this,void 0,void 0,(function(){return f(this,(function(n){return[2,this.addItem({id:e,quantity:t,endpoint:"quickAdd"})]}))}))},t.prototype.addItem=function(e){return h(this,void 0,void 0,(function(){var t,n,r,a;return f(this,(function(i){switch(i.label){case 0:return(t=this.getCartPayload(e)).id?((r=salla.form.getPossibleValue(t.payload,["endpoint"]))&&["addItem","quickAdd"].includes(r)||(r=salla.form.getPossibleValue(t.payload,["quantity","donating_amount"])?"addItem":"quickAdd"),[4,this.getCurrentCartId()]):(n='There is no product "id"!',salla.cart.event.itemAddedFailed(n),[2,salla.api.errorPromise(n)]);case 1:return a=i.sent(),[2,this.request([r,a,t.id],t.payload).then((function(e){return salla.cart.event.itemAdded(e,t.id),e})).catch((function(e){throw salla.cart.event.itemAddedFailed(e,t.id),e}))]}}))}))},t.prototype.deleteItem=function(e){return h(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(a){switch(a.label){case 0:return(t=this.getCartPayload(e)).id?[4,this.getCurrentCartId()]:(n='There is no "id"!',salla.cart.event.itemDeletedFailed(n),[2,salla.api.errorPromise(n)]);case 1:return r=a.sent(),[2,this.request(["deleteItem",r,t.id]).then((function(e){return salla.cart.event.itemDeleted(e,t.id),e})).catch((function(e){throw salla.cart.event.itemDeletedFailed(e,t.id),e}))]}}))}))},t.prototype.updateItem=function(e){var t;return h(this,void 0,void 0,(function(){var n,r,a;return f(this,(function(i){switch(i.label){case 0:return(n=this.getCartPayload(e)).id?[4,this.getCurrentCartId()]:(r='There is no "id"!',salla.cart.event.itemUpdatedFailed(r),[2,salla.api.errorPromise(r)]);case 1:return a=i.sent(),"Object"===(null===(t=n.payload.constructor)||void 0===t?void 0:t.name)?n.payload._method="PUT":n.payload.append("_method","PUT"),[2,this.request(["updateItem",a,n.id],n.payload).then((function(e){return salla.cart.event.itemUpdated(e,n.id),e})).catch((function(e){throw salla.cart.event.itemUpdatedFailed(e,n.id),e}))]}}))}))},t.prototype.deleteImage=function(e){return h(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return(e=salla.form.getPossibleValue(e,["id","image_id","photo_id"]))?[4,this.getCurrentCartId()]:(t='There is no "id"!',salla.cart.event.imageNotDeleted(t),[2,salla.api.errorPromise(t)]);case 1:return n=r.sent(),[2,this.request(["deleteImage",n,e]).then((function(t){return salla.cart.event.imageDeleted(t,e),t})).catch((function(t){throw salla.cart.event.imageNotDeleted(t,e),t}))]}}))}))},t.prototype.status=function(e){return h(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(a){switch(a.label){case 0:return t=this.request,n=["status"],(r=e)?[3,2]:[4,this.getCurrentCartId()];case 1:r=a.sent(),a.label=2;case 2:return[2,t.apply(this,[n.concat([r]),{params:{has_apple_pay:!!window.ApplePaySession}}])]}}))}))},t.prototype.submit=function(){return h(this,void 0,void 0,(function(){var e,t=this;return f(this,(function(n){switch(n.label){case 0:return e=this.status,[4,this.getCurrentCartId()];case 1:return e.apply(this,[n.sent()]).then((function(e){var n=e.data.next_step.to;if(!["checkout","refresh","login"].includes(n)){var r="Can't find next_step );";throw salla.cart.event.submitFailed(r),r}if(salla.cart.event.submitted(e),"login"===n)return salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),void salla.auth.event.onLoggedIn((function(e){salla.event.dispatch("login::close"),t.submit()}));"checkout"===n?window.location.href=e.data.next_step.url+(window.ApplePaySession?"?has_apple_pay=true":""):window.location.reload()})).catch((function(e){throw salla.cart.event.submitFailed(e),e})),[2]}}))}))},t.prototype.getCartPayload=function(e){var t=(null==e?void 0:e.data)||("object"==typeof e?e:void 0);return{id:e=t?salla.form.getPossibleValue(t,["prod_id","product_id","item_id","id"]):e,payload:t="object"==typeof t?t:void 0}},t.prototype.normalRequest=function(t,n,r){return void 0===n&&(n=void 0),void 0===r&&(r=null),e.prototype.normalRequest.call(this,t,n,r).catch((function(e){var t;throw 403===(null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.status)&&(salla.cart.api.reset(),salla.error(salla.lang.get("pages.checkout.try_again"))),e}))},t.prototype.reset=function(){salla.api.cart.latestCart=null,salla.storage.remove("cart"),salla.cart.event.successReset()},t.prototype.addCoupon=function(e){return h(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return e=e.data||e,(e=salla.form.getPossibleValue(e,["coupon"]))?[4,salla.cart.api.getCurrentCartId()]:((t=new Error('There is no "Coupon Code"!')).name="EmptyCoupon",salla.event.cart.couponAdditionFailed(t),[2,salla.api.errorPromise(t)]);case 1:return n=r.sent(),[2,this.request(["addCoupon",n],{coupon:e}).then((function(e){return salla.event.cart.couponAdded(e,n),e})).catch((function(e){throw salla.event.cart.couponAdditionFailed(e,n),e}))]}}))}))},t.prototype.deleteCoupon=function(){return h(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:return[4,salla.cart.api.getCurrentCartId()];case 1:return e=t.sent(),[2,this.request(["deleteCoupon",e],{}).then((function(t){return salla.event.cart.couponDeleted(t,e),t})).catch((function(t){throw salla.event.cart.couponDeletionFailed(t,e),t}))]}}))}))},t.prototype.getQuickOrderSettings=function(){return this.request("getQuickOrderSettings").then((function(e){return salla.event.cart.quickOrderSettingFetched(e),e})).catch((function(e){throw salla.event.cart.quickOrderSettingFailed(e),e}))},t.prototype.createQuickOrder=function(e){return this.request("createQuickOrder",e).then((function(e){return salla.event.cart.quickOrderSucceeded(e),e})).catch((function(e){throw salla.event.cart.quickOrderFailed(e),e}))},t.prototype.priceQuote=function(e){return h(this,void 0,void 0,(function(){var t,n,r;return f(this,(function(a){switch(a.label){case 0:return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("cart::priceQuote",e),salla.event.dispatch("login::open"),[2]):(t=this.request,n=["priceQuote"],(r=e)?[3,2]:[4,this.getCurrentCartId()]);case 1:r=a.sent(),a.label=2;case 2:return[2,t.apply(this,[n.concat([r])]).then((function(e){return salla.cart.api.reset(),salla.event.cart.priceQuoteSucceeded(e).then((function(){return setTimeout((function(){return window.location.href=salla.url.get("/")}),1e3),e}))})).catch((function(e){return salla.event.cart.priceQuoteFailed(e).then((function(){var t;throw 404===(null===(t=e.error)||void 0===t?void 0:t.code)&&window.location.reload(),e}))}))]}}))}))},t}(de),fe=function(e){function t(){var t=e.call(this)||this;return t.namespace="loyalty",t.endpoints={getProgram:"loyalty",exchange:"loyalty/exchange",reset:"loyalty/exchange"},t.endpointsMethods={getProgram:"get",reset:"put"},t.after_init(),t}return u(t,e),t.prototype.getProgram=function(){return this.request("getProgram").then((function(e){return salla.loyalty.event.programFetched(e),e})).catch((function(e){throw salla.loyalty.event.programNotFetched(e),e}))},t.prototype.exchange=function(e,t){return void 0===t&&(t=null),h(this,void 0,void 0,(function(){var n,r;return f(this,(function(a){switch(a.label){case 0:return(e=salla.form.getPossibleValue(e,["id","loyalty_prize_id","prize_id"]))?(n=t)?[3,2]:[4,salla.cart.getCurrentCartId()]:(r="Unable to find cart id. Please provide one.",salla.loyalty.event.exchangeFailed(r),[2,salla.api.errorPromise(r)]);case 1:n=a.sent(),a.label=2;case 2:return(t=n)?[2,this.request("exchange",{loyalty_prize_id:e,cart_id:t}).then((function(t){return salla.loyalty.event.exchangeSucceeded(t,e),t})).catch((function(t){throw salla.loyalty.event.exchangeFailed(t,e),t}))]:(r="Unable to find cart id. Please provide one.",salla.loyalty.event.exchangeFailed(r),[2,salla.api.errorPromise(r)])}}))}))},t.prototype.reset=function(e){return void 0===e&&(e=null),h(this,void 0,void 0,(function(){var t,n;return f(this,(function(r){switch(r.label){case 0:return(t=e)?[3,2]:[4,salla.cart.getCurrentCartId()];case 1:t=r.sent(),r.label=2;case 2:return(e=t)?[2,this.request("reset",{cart_id:e}).then((function(e){return salla.loyalty.event.resetSucceeded(e),e})).catch((function(e){throw salla.loyalty.event.resetFailed(e),e}))]:(n="Unable to find cart id. Please provide one.",salla.loyalty.event.resetFailed(n),[2,salla.api.errorPromise(n)])}}))}))},t}(de),pe=function(e){function t(){var t=e.call(this)||this;return t.namespace="auth",t.canRedirect_=!0,t.afterLoginEvent={event:null,payload:null},t.endpoints={login:"auth/{type}/send_verification",resend:"auth/resend_verification",verify:"auth/{type}/verify",register:"auth/register",logout:"logout",refresh:"auth/refresh"},t.webEndpoints=["logout","auth/jwt","refresh"],t.endpointsMethods={logout:"get"},t.after_init(),t}return u(t,e),t.prototype.setAfterLoginEvent=function(e,t){salla.api.auth.afterLoginEvent={event:e,payload:t}},t.prototype.setCanRedirect=function(e){salla.api.auth.canRedirect_=e},t.prototype.canRedirect=function(){return salla.api.auth.canRedirect_&&!salla.api.auth.afterLoginEvent.event},t.prototype.login=function(e){(null==e?void 0:e.data)&&(e=e.data);var t=salla.form.getPossibleValue(e,["type"]);if(!["email","mobile"].includes(t)){var n="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(n),salla.api.errorPromise(n)}return this.request(["login",t],e).then((function(e){return salla.auth.event.codeSent(e,t),e})).catch((function(e){throw salla.auth.event.codeNotSent(e,t),e}))},t.prototype.verify=function(e,t){var n;return void 0===t&&(t=!0),h(this,void 0,void 0,(function(){var r,a,i,o;return f(this,(function(s){switch(s.label){case 0:return(r=salla.form.getPossibleValue(e,["type"]))?(t=!1!==salla.form.getPossibleValue(e,["supportWebAuth"])&&t,salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),[4,salla.auth.api.request(["verify",r],e)]):(a="Failed to know what's login type!",salla.auth.event.verificationFailed(a),[2,salla.api.errorPromise(a)]);case 1:return 200!==(null==(i=s.sent())?void 0:i.status)?(salla.auth.event.verificationFailed(i,r),[2,salla.api.errorPromise(i)]):((o="authenticated"===(null===(n=i.data)||void 0===n?void 0:n.case))&&salla.auth.event.tokenFetched(i.data.token),t?[4,salla.auth.api.request("auth/jwt")]:[3,3]);case 2:s.sent(),s.label=3;case 3:return o&&salla.auth.event.loggedIn(i).then((function(){return salla.auth.api.afterUserLogin()})),salla.auth.event.verified(i,r),[2,salla.api.successPromise(i)]}}))}))},t.prototype.resend=function(e){var t;return(e=e.data||e).type=e.type||"mobile","mobile"!==e.type||e.phone&&e.country_code?"email"!==e.type||e.email?this.request("resend",e).then((function(t){return salla.auth.event.codeSent(t,e),t})).catch((function(t){throw salla.auth.event.codeNotSent(t,e),t})):(salla.auth.event.codeNotSent(t="There is no email!",e),salla.api.errorPromise(t)):(salla.auth.event.codeNotSent(t="There is no phone or country_code!",e),salla.api.errorPromise(t))},t.prototype.register=function(e){var t;return e.data&&(t=e.element,e=e.data),salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),this.request("register",e).then((function(e){var n;return h(this,void 0,void 0,(function(){return f(this,(function(r){switch(r.label){case 0:return salla.auth.event.registered.call(t,e),"authenticated"!==(null===(n=e.data)||void 0===n?void 0:n.case)?[3,2]:(salla.auth.event.tokenFetched(e.data.token),[4,salla.auth.request("auth/jwt")]);case 1:r.sent(),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin(),r.label=2;case 2:return[2,e]}}))}))})).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),e}))},t.prototype.logout=function(){return salla.storage.clearAll(),salla.cookie.clearAll(),salla.auth.event.loggedOut().then((function(){var e=salla.url.get("logout");console.log("Going to ".concat(e,", to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})"));try{location.href=e}catch(e){salla.log(e)}}))},t.prototype.refresh=function(){return this.request("refresh").then((function(e){return salla.auth.event.tokenFetched(e.data.token),e})).catch((function(e){throw salla.auth.event.refreshFailed(e),e}))},t.prototype.afterUserLogin=function(){this.afterLoginEvent.event&&salla.event.emit(this.afterLoginEvent.event,this.afterLoginEvent.payload)},t}(de),ge=function(e){function t(){var t=e.call(this)||this;return t.namespace="order",t.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}"},t.endpointsMethods={createCartFromOrder:"get"},t.after_init(),t}return u(t,e),t.prototype.show=function(e){var t=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:t}),location.href=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["url"])},t.prototype.cancel=function(e){return e=e||Salla.config.get("page.id"),this.request(["cancel",e],{params:{has_apple_pay:!!window.ApplePaySession}}).then((function(t){return salla.event.order.canceled(t,e),t})).catch((function(t){throw salla.event.order.notCanceled(t,e),t}))},t.prototype.createCartFromOrder=function(e){return e=e||salla.config.get("page.id"),this.request(["createCartFromOrder",e]).then((function(t){return salla.cart.reset(),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))},t.prototype.sendInvoice=function(e){var t=salla.form.getPossibleValue(e,["id"])||salla.config.get("page.id");if(!t||isNaN(t)){var n="There is no id!";return salla.order.event.invoiceNotSent(n),salla.api.errorPromise(n)}return this.request(["sendInvoice",t],e).then((function(e){return salla.event.order.invoiceSent(e,t),e})).catch((function(e){throw salla.event.order.invoiceNotSent(e,t),e}))},t}(de),ve=function(e){function t(){var t=e.call(this)||this;return t.namespace="product",t.previousQuery="",t.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",details:"products/{product_id}/details",categories:"products/categories/{?id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftDetail:"products/{product_id}/buy-as-gift",giftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products"},t.endpointsMethods={details:"get",giftDetail:"get",fetch:"get"},t.after_init(),t}return u(t,e),t.prototype.getPrice=function(e){var t=e.data||e,n=salla.form.getPossibleValue(t,["id","prod_id","product_id"]);return this.request(["getPrice",n],"object"==typeof t?t:void 0).then((function(e){return salla.product.event.priceUpdated(e,n),e})).catch((function(e){throw salla.product.event.priceUpdateFailed(e,n),e}))},t.prototype.categories=function(e){return this.request(["categories",e||""],null,"get").then((function(e){return salla.product.event.categoriesFetched(e),e})).catch((function(e){throw salla.product.event.categoriesFailed(e),e}))},t.prototype.availabilitySubscribe=function(e){var t=e.data||e;return e=salla.form.getPossibleValue(t,["id","prod_id"]),this.request(["availabilitySubscribe",e],"object"==typeof t?t:void 0).then((function(t){return salla.product.event.availabilitySubscribed(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))},t.prototype.search=function(e){var t,n=e.data;if(n||(n={params:"string"==typeof e?{query:e}:e}),!(e=n instanceof FormData?n.get("query"):n.query||(null===(t=n.params)||void 0===t?void 0:t.query))){var r='There is no "query"!';return salla.product.event.searchFailed(r),salla.api.errorPromise(r)}if(e===salla.api.product.previousQuery){r="Query is same as previous one!";return salla.product.event.searchFailed(r),salla.api.product.previousQuery=null,salla.api.errorPromise(r)}return salla.api.product.previousQuery=e,this.request("search",n,"get").then((function(t){return salla.product.event.searchResults(t,e),t})).catch((function(t){throw salla.product.event.searchFailed(t,e),t}))},t.prototype.offers=function(e){if(!(e=salla.form.getPossibleValue((null==e?void 0:e.data)|e,["product_id","id"]))){var t='There is no "product_id"!';return salla.product.event.fetchOffersFailed(t),salla.api.errorPromise(t)}return this.request(["offers",e]).then((function(t){return salla.product.event.offersFetched(t,e),t})).catch((function(t){throw salla.product.event.fetchOffersFailed(t,e),t}))},t.prototype.getSizeGuides=function(e){return this.request("products/".concat(e,"/size-guides"),null,"get").then((function(t){return salla.product.event.sizeGuideFetched(t,e),t})).catch((function(t){throw salla.product.event.sizeGuideFetchFailed(t,e),t}))},t.prototype.getGiftDetails=function(e){return this.request(["giftDetail",e]).then((function(t){return salla.product.event.giftFetched(t,e),t})).catch((function(t){throw salla.product.event.giftFetchFailed(t,e),t}))},t.prototype.getDetails=function(e,t){if(void 0===t&&(t=[]),!Array.isArray(t)){var n="withItems should be array.";return salla.product.event.detailFetchFailed(n),salla.api.errorPromise(n)}if(!e){n="productId is not passed.";return salla.product.event.detailFetchFailed(n),salla.api.errorPromise(n)}return this.request(["details",e],{params:{with:t}}).then((function(t){return salla.product.event.detailFetched(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))},t.prototype.addGiftToCart=function(e,t,n){return void 0===n&&(n=!1),this.request(["giftToCart",e],t).then((function(t){return salla.product.event.addGiftToCartSucceeded(t,e),n&&(window.location.href=t.redirect),t})).catch((function(t){throw salla.product.event.addGiftToCartFailed(t,e),t}))},t.prototype.uploadGiftImage=function(e){return this.request("giftImage",e).then((function(e){return salla.product.event.giftImageUploadSucceeded(e),e})).catch((function(e){throw salla.product.event.giftImageUploadFailed(e),e}))},t.prototype.fetch=function(e){if(!e.source){var t="Source can not be empty. Please provide one.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}if(["categories","brands","tags","selected"].includes(e.source)&&!Array.isArray(e.source_value)||"search"===e.source&&"string"!=typeof e.source_value||"related"===e.source&&isNaN(e.source_value)){t="SourceValue type error.";return salla.product.event.productListFetchFailed(t),salla.api.errorPromise(t)}return this.request(this.endpoints.fetch,{params:e},"get").then((function(e){return salla.product.event.productListFetchSucceeded(e),e})).catch((function(e){throw salla.product.event.productListFetchFailed(e),e}))},t}(de),me=function(e){function t(){var t=e.call(this)||this;return t.namespace="profile",t.endpoints={info:"auth/user",update:"profile/update",updateContacts:"profile/contacts/update",updateSettings:"profile/settings",verify:"profile/verify",delete:"profile"},t.endpointsMethods={delete:"delete"},t.after_init(),t}return u(t,e),t.prototype.info=function(){return this.request("info",null,"get").then((function(e){var t={id:e.data.id,type:"user",email:e.data.email,mobile:e.data.phone.code+e.data.phone.number,country_code:e.data.phone.country,language_code:e.data.language,currency_code:e.data.currency,notifications:e.data.notifications,pending_orders:e.data.pending_orders,avatar:e.data.avatar,first_name:e.data.first_name,last_name:e.data.last_name,fetched_at:Date.now()};return salla.config.set("user",t),salla.storage.set("user",t),salla.profile.event.infoFetched(e),e})).catch((function(e){throw salla.profile.event.infoNotFetched(e),e}))},t.prototype.update=function(e){return this.request("update",e).then((function(e){return salla.profile.event.updated(e),e})).catch((function(e){throw salla.event.profile.updateFailed(e),e}))},t.prototype.updateContacts=function(e){return this.request("updateContacts",e).then((function(e){return salla.profile.event.verificationCodeSent(e),e})).catch((function(e){throw salla.event.profile.updateContactsFailed(e),e}))},t.prototype.verify=function(e){return this.request("verify",e).then((function(e){return salla.profile.event.verified(e),e})).catch((function(e){throw salla.event.profile.unverified(e),e}))},t.prototype.updateSettings=function(e){return this.request("updateSettings",e).then((function(e){return salla.event.profile.settingsUpdated(e),e})).catch((function(e){throw salla.event.profile.updateSettingsFailed(e),e}))},t.prototype.delete=function(){return this.request("delete").then((function(e){return salla.storage.clearAll(),salla.cookie.clearAll(),salla.event.profile.deleted(e),window.location.href=salla.url.get("logout"),e})).catch((function(e){throw salla.event.profile.notDeleted(e),e}))},t}(de),ye=function(e){function t(){var t=e.call(this)||this;return t.namespace="comment",t.endpoints={comments:"{type}/{id}/comments"},t.after_init(),t}return u(t,e),t.prototype.add=function(e){if((null==e?void 0:e.data)&&(e=e.data),"string"==typeof(e=this.getCommentPayload(e)))return salla.event.comment.additionFailed(e),salla.api.errorPromise(e);if(!e.comment){var t="can't find comment content!";return salla.event.comment.additionFailed(t),salla.api.errorPromise(t)}return this.request(["comments",e.type,e.id],{comment:e.comment}).then((function(t){return salla.event.comment.added(t,e.id),t})).catch((function(t){throw salla.event.comment.additionFailed(t,e.id),t}))},t.prototype.getCommentPayload=function(e){var t={};return["id","type","comment","per_page","page"].forEach((function(n){var r=salla.form.getPossibleValue(e,[n]);r&&(t[n]=r)})),t.id?t.type&&["products","pages","product","page"].includes(t.type)?(t.type+=["product","page"].includes(t.type)?"s":"",t):"Failed to get type one of:(products, product, page, pages)!":"Failed to get id!"},t.prototype.fetch=function(e){return"string"==typeof(e=this.getCommentPayload(e))?(salla.event.comment.fetchFailed(e),salla.api.errorPromise(e)):this.request(["comments",e.type,e.id],{params:e},"get").then((function(t){return salla.event.comment.fetched(t,e),t})).catch((function(t){throw salla.event.comment.fetchFailed(t,e),t}))},t.prototype.getPageComments=function(e,t,n){return void 0===t&&(t=1),void 0===n&&(n=10),this.fetch({id:e,type:"pages",page:t,per_page:n})},t.prototype.getProductComments=function(e,t,n){return void 0===t&&(t=1),void 0===n&&(n=10),this.fetch({id:e,type:"products",page:t,per_page:n})},t}(de),be=function(e){function t(){var t=e.call(this)||this;return t.namespace="currency",t.endpoints={change:"/",list:"currencies"},t.endpointsMethods={change:"get",list:"get"},t.webEndpoints=["change"],t.after_init(),t}return u(t,e),t.prototype.change=function(e){if(!(e=salla.form.getPossibleValue(e.data||e,["currency","code"]))){var t="Can't find currency code!";return salla.currency.event.failed(t),salla.api.errorPromise(t)}return this.request("change",{params:{change_currency:"",currency:e}}).then((function(t){return salla.cookie.set("fresh_summary",1),salla.storage.set("cart",""),salla.currency.event.changed(t,e),t})).catch((function(t){throw salla.currency.event.failed(t,e),t}))},t.prototype.list=function(){return this.request("list").then((function(e){return salla.currency.event.fetched(e),e})).catch((function(e){throw salla.currency.event.failedToFetch(e),e}))},t}(de),we=function(e){function t(){var t=e.call(this)||this;return t.namespace="document",t}return u(t,e),t}(de),Se=function(e){function t(){var t=e.call(this)||this;return t.namespace="rating",t.endpoints={store:"rating/store",products:"rating/products",shipping:"rating/shipping",order:"rating/{order_id}"},t.endpointsMethods={order:"get"},t.after_init(),t}return u(t,e),t.prototype.order=function(e){var t="object"==typeof e?e:{},n=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["order_id","id"]);if(!n){var r='There is no "order_id"!';return salla.event.rating.orderNotFetched(r),salla.api.errorPromise(r)}return this.request(["order",n],t).then((function(e){return salla.event.rating.orderFetched(e,n),e})).catch((function(e){throw salla.event.rating.orderNotFetched(e,n),e}))},t.prototype.store=function(e){if(!(e=(null==e?void 0:e.data)||e)){var t='There is no "data"!';return salla.event.rating.storeFailed(t),salla.api.errorPromise(t)}return this.request("store",e).then((function(t){return salla.event.rating.storeRated(t,e),t})).catch((function(t){throw salla.event.rating.storeFailed(t,e),t}))},t.prototype.products=function(e){if(!(e=(null==e?void 0:e.data)||e)){var t='There is no "data"!';return salla.event.rating.productsFailed(t),salla.api.errorPromise(t)}return this.request("products",e).then((function(t){return salla.event.rating.productsRated(t,e),t})).catch((function(t){throw salla.event.rating.productsFailed(t,e),t}))},t.prototype.shipping=function(e){if(!(e=(null==e?void 0:e.data)||e)){var t='There is no "data"!';return salla.event.rating.shippingFailed(t),salla.api.errorPromise(t)}return this.request("shipping",e).then((function(t){return salla.event.rating.shippingRated(t,e),t})).catch((function(t){throw salla.event.rating.shippingFailed(t,e),t}))},t}(de),Ee=function(e){function t(){var t=e.call(this)||this;return t.namespace="wishlist",t.endpoints={add:"products/favorites/{id}",remove:"products/favorites/{id}"},t.endpointsMethods={remove:"delete"},t.after_init(),t}return u(t,e),t.prototype.toggle=function(e){return salla.storage.get("salla::wishlist",[]).includes(e)?this.remove(e):this.add(e)},t.prototype.add=function(e){var t,n=this;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(t=salla.lang.get("common.messages.must_login")),salla.error(t),salla.api.errorPromise(t)):(e=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["product_id","id"]))?this.request(["add",e]).then((function(t){return n.updateWishlistStorage(e),salla.wishlist.event.added(t,e),t})).catch((function(t){throw salla.wishlist.event.additionFailed(t,e),t})):(salla.wishlist.event.additionFailed(t="Failed to get product id!"),salla.api.errorPromise(t))},t.prototype.remove=function(e){var t,n=this;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(t=salla.lang.get("common.messages.must_login")),salla.error(t),salla.api.errorPromise(t)):(e=salla.form.getPossibleValue((null==e?void 0:e.data)||e,["product_id","id"]))?this.request(["remove",e]).then((function(t){return n.updateWishlistStorage(e,!1),salla.wishlist.event.removed(t,e),t})).catch((function(t){throw salla.wishlist.event.removingFailed(t,e),t})):(salla.wishlist.event.removingFailed(t="Failed to get id!"),salla.api.errorPromise(t))},t.prototype.updateWishlistStorage=function(e,t){void 0===t&&(t=!0);var n=salla.storage.get("salla::wishlist",[]);t?n.push(e):n.splice(n.indexOf(e),1),salla.storage.set("salla::wishlist",n)},t}(de),_e=function(e){function t(){var t=e.call(this)||this;return t.namespace="scopes",t.endpoints={get:"scopes",change:"scopes",getProductAvailability:"scopes/availability?product_id={id}"},t.after_init(),t}return u(t,e),t.prototype.get=function(){return this.request("scopes",null,"get").then((function(e){return salla.scope.event.fetched(e),e})).catch((function(e){throw salla.scope.event.notFetched(e),e}))},t.prototype.change=function(e){return this.request("scopes",e).then((function(e){return salla.scope.event.changeSucceeded(e),e})).catch((function(e){throw salla.scope.event.changeFailed(e),e}))},t.prototype.getProductAvailability=function(e){return void 0===e&&(e=null),this.request("scopes/availability?product_id=".concat(e),null,"get").then((function(t){return salla.scope.event.productAvailabilityFetched(t,e),t})).catch((function(e){throw salla.scope.event.productAvailabilityNotFetched(e),e}))},t}(de),Fe=function(e){function t(){var t=e.call(this)||this;return t.namespace="booking",t.endpoints={add:"cart/booking/product/{id}"},t.endpointsMethods={add:"get"},t}return u(t,e),t.prototype.add=function(e,t){return void 0===t&&(t=!0),h(this,void 0,void 0,(function(){var n;return f(this,(function(r){return e?[2,this.request(["add",e]).then((function(e){return salla.booking.event.added(e),t&&"booking"===e.data.redirect.to&&(window.location.href=e.data.redirect.url),e})).catch((function(e){throw salla.booking.event.additionFailed(e),e}))]:(n="Please provide product id.",salla.booking.event.additionFailed(n),[2,salla.api.errorPromise(n)])}))}))},t}(de),Pe=function(e){function t(){var t=e.call(this)||this;return t.namespace="landing",t.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}"},t.endpointsMethods={getDetails:"get"},t.after_init(),t}return u(t,e),t.prototype.getDetails=function(e){if(!e){var t="page landing id not passed";return salla.event.landing.getDetailsFailed(t),salla.api.errorPromise(t)}return this.request(["getDetails",e]).then((function(t){return salla.event.landing.detailsFetched(t,e),t})).catch((function(t){throw salla.event.landing.getDetailsFailed(t,e),t}))},t.prototype.createCartFromPage=function(e){if(!e){var t="page landing id not passed";return salla.event.landing.orderCreationFailed(t),salla.api.errorPromise(t)}return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("landing::createCartFromPage",e),salla.event.dispatch("login::open"),salla.api.successPromise("")):this.request(["createCartFromPage",e]).then((function(t){return salla.event.landing.orderCreated(t,e).then((function(){return location.href=t.data.url})),t})).catch((function(t){throw salla.event.landing.orderCreationFailed(t,e),t}))},t}(de),Ae={exports:{}},xe=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},Ce=xe,ke=Object.prototype.toString,Oe=(ce=Object.create(null),function(e){var t=ke.call(e);return ce[t]||(ce[t]=t.slice(8,-1).toLowerCase())});function qe(e){return e=e.toLowerCase(),function(t){return Oe(t)===e}}function Re(e){return Array.isArray(e)}function Te(e){return void 0===e}var Ie=qe("ArrayBuffer");function Le(e){return null!==e&&"object"==typeof e}function De(e){if("object"!==Oe(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var Ne=qe("Date"),je=qe("File"),Ue=qe("Blob"),He=qe("FileList");function Be(e){return"[object Function]"===ke.call(e)}var Me=qe("URLSearchParams");function ze(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),Re(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.call(null,e[a],a,e)}var Ge,Ve=(Ge="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return Ge&&e instanceof Ge}),$e={isArray:Re,isArrayBuffer:Ie,isBuffer:function(e){return null!==e&&!Te(e)&&null!==e.constructor&&!Te(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||ke.call(e)===t||Be(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Ie(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:Le,isPlainObject:De,isUndefined:Te,isDate:Ne,isFile:je,isBlob:Ue,isFunction:Be,isStream:function(e){return Le(e)&&Be(e.pipe)},isURLSearchParams:Me,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:ze,merge:function e(){var t={};function n(n,r){De(t[r])&&De(n)?t[r]=e(t[r],n):De(n)?t[r]=e({},n):Re(n)?t[r]=n.slice():t[r]=n}for(var r=0,a=arguments.length;r<a;r++)ze(arguments[r],n);return t},extend:function(e,t,n){return ze(t,(function(t,r){e[r]=n&&"function"==typeof t?Ce(t,n):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,n,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,n&&Object.assign(e.prototype,n)},toFlatObject:function(e,t,n){var r,a,i,o={};t=t||{};do{for(a=(r=Object.getOwnPropertyNames(e)).length;a-- >0;)o[i=r[a]]||(t[i]=e[i],o[i]=!0);e=Object.getPrototypeOf(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:Oe,kindOfTest:qe,endsWith:function(e,t,n){e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;var r=e.indexOf(t,n);return-1!==r&&r===n},toArray:function(e){if(!e)return null;var t=e.length;if(Te(t))return null;for(var n=new Array(t);t-- >0;)n[t]=e[t];return n},isTypedArray:Ve,isFileList:He},Qe=$e;function We(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Je=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(Qe.isURLSearchParams(t))r=t.toString();else{var a=[];Qe.forEach(t,(function(e,t){null!=e&&(Qe.isArray(e)?t+="[]":e=[e],Qe.forEach(e,(function(e){Qe.isDate(e)?e=e.toISOString():Qe.isObject(e)&&(e=JSON.stringify(e)),a.push(We(t)+"="+We(e))})))})),r=a.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e},Ke=$e;function Xe(){this.handlers=[]}Xe.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},Xe.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},Xe.prototype.forEach=function(e){Ke.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var Ye,Ze,et=Xe,tt=$e;function nt(){if(Ze)return Ye;Ze=1;var e=$e;function t(e,t,n,r,a){Error.call(this),this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),a&&(this.response=a)}e.inherits(t,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var n=t.prototype,r={};return["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach((function(e){r[e]={value:e}})),Object.defineProperties(t,r),Object.defineProperty(n,"isAxiosError",{value:!0}),t.from=function(r,a,i,o,s,l){var c=Object.create(n);return e.toFlatObject(r,c,(function(e){return e!==Error.prototype})),t.call(c,r.message,a,i,o,s),c.name=r.name,l&&Object.assign(c,l),c},Ye=t}var rt,at,it,ot,st,lt,ct={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};function ut(){if(at)return rt;at=1;var e=$e;return rt=function(n,r){r=r||new FormData;var a=[];function i(n){return null===n?"":e.isDate(n)?n.toISOString():e.isArrayBuffer(n)||e.isTypedArray(n)?"function"==typeof Blob?new Blob([n]):t.Buffer.from(n):n}return function t(n,o){if(e.isPlainObject(n)||e.isArray(n)){if(-1!==a.indexOf(n))throw Error("Circular reference detected in "+o);a.push(n),e.forEach(n,(function(n,a){if(!e.isUndefined(n)){var s,l=o?o+"."+a:a;if(n&&!o&&"object"==typeof n)if(e.endsWith(a,"{}"))n=JSON.stringify(n);else if(e.endsWith(a,"[]")&&(s=e.toArray(n)))return void s.forEach((function(t){!e.isUndefined(t)&&r.append(l,i(t))}));t(n,l)}})),a.pop()}else r.append(o,i(n))}(n),r},rt}function dt(){if(ot)return it;ot=1;var e=nt();return it=function(t,n,r){var a=r.config.validateStatus;r.status&&a&&!a(r.status)?n(new e("Request failed with status code "+r.status,[e.ERR_BAD_REQUEST,e.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):t(r)}}function ht(){if(lt)return st;lt=1;var e=$e;return st=e.isStandardBrowserEnv()?{write:function(t,n,r,a,i,o){var s=[];s.push(t+"="+encodeURIComponent(n)),e.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),e.isString(a)&&s.push("path="+a),e.isString(i)&&s.push("domain="+i),!0===o&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}}var ft,pt,gt,vt,mt,yt,bt,wt,St,Et,_t,Ft,Pt=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},At=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},xt=function(e,t){return e&&!Pt(t)?At(e,t):t};function Ct(){if(pt)return ft;pt=1;var e=$e,t=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];return ft=function(n){var r,a,i,o={};return n?(e.forEach(n.split("\n"),(function(n){if(i=n.indexOf(":"),r=e.trim(n.substr(0,i)).toLowerCase(),a=e.trim(n.substr(i+1)),r){if(o[r]&&t.indexOf(r)>=0)return;o[r]="set-cookie"===r?(o[r]?o[r]:[]).concat([a]):o[r]?o[r]+", "+a:a}})),o):o}}function kt(){if(vt)return gt;vt=1;var e=$e;return gt=e.isStandardBrowserEnv()?function(){var t,n=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function a(e){var t=e;return n&&(r.setAttribute("href",t),t=r.href),r.setAttribute("href",t),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return t=a(window.location.href),function(n){var r=e.isString(n)?a(n):n;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0}}function Ot(){if(yt)return mt;yt=1;var e=nt();function t(t){e.call(this,null==t?"canceled":t,e.ERR_CANCELED),this.name="CanceledError"}return $e.inherits(t,e,{__CANCEL__:!0}),mt=t}function qt(){return wt?bt:(wt=1,bt=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""})}function Rt(){if(Et)return St;Et=1;var e=$e,t=dt(),n=ht(),r=Je,a=xt,i=Ct(),o=kt(),s=ct,l=nt(),c=Ot(),u=qt();return St=function(d){return new Promise((function(h,f){var p,g=d.data,v=d.headers,m=d.responseType;function y(){d.cancelToken&&d.cancelToken.unsubscribe(p),d.signal&&d.signal.removeEventListener("abort",p)}e.isFormData(g)&&e.isStandardBrowserEnv()&&delete v["Content-Type"];var b=new XMLHttpRequest;if(d.auth){var w=d.auth.username||"",S=d.auth.password?unescape(encodeURIComponent(d.auth.password)):"";v.Authorization="Basic "+btoa(w+":"+S)}var E=a(d.baseURL,d.url);function _(){if(b){var e="getAllResponseHeaders"in b?i(b.getAllResponseHeaders()):null,n={data:m&&"text"!==m&&"json"!==m?b.response:b.responseText,status:b.status,statusText:b.statusText,headers:e,config:d,request:b};t((function(e){h(e),y()}),(function(e){f(e),y()}),n),b=null}}if(b.open(d.method.toUpperCase(),r(E,d.params,d.paramsSerializer),!0),b.timeout=d.timeout,"onloadend"in b?b.onloadend=_:b.onreadystatechange=function(){b&&4===b.readyState&&(0!==b.status||b.responseURL&&0===b.responseURL.indexOf("file:"))&&setTimeout(_)},b.onabort=function(){b&&(f(new l("Request aborted",l.ECONNABORTED,d,b)),b=null)},b.onerror=function(){f(new l("Network Error",l.ERR_NETWORK,d,b,b)),b=null},b.ontimeout=function(){var e=d.timeout?"timeout of "+d.timeout+"ms exceeded":"timeout exceeded",t=d.transitional||s;d.timeoutErrorMessage&&(e=d.timeoutErrorMessage),f(new l(e,t.clarifyTimeoutError?l.ETIMEDOUT:l.ECONNABORTED,d,b)),b=null},e.isStandardBrowserEnv()){var F=(d.withCredentials||o(E))&&d.xsrfCookieName?n.read(d.xsrfCookieName):void 0;F&&(v[d.xsrfHeaderName]=F)}"setRequestHeader"in b&&e.forEach(v,(function(e,t){void 0===g&&"content-type"===t.toLowerCase()?delete v[t]:b.setRequestHeader(t,e)})),e.isUndefined(d.withCredentials)||(b.withCredentials=!!d.withCredentials),m&&"json"!==m&&(b.responseType=d.responseType),"function"==typeof d.onDownloadProgress&&b.addEventListener("progress",d.onDownloadProgress),"function"==typeof d.onUploadProgress&&b.upload&&b.upload.addEventListener("progress",d.onUploadProgress),(d.cancelToken||d.signal)&&(p=function(e){b&&(f(!e||e&&e.type?new c:e),b.abort(),b=null)},d.cancelToken&&d.cancelToken.subscribe(p),d.signal&&(d.signal.aborted?p():d.signal.addEventListener("abort",p))),g||(g=null);var P=u(E);P&&-1===["http","https","file"].indexOf(P)?f(new l("Unsupported protocol "+P+":",l.ERR_BAD_REQUEST,d)):b.send(g)}))},St}var Tt=$e,It=function(e,t){tt.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},Lt=nt(),Dt=ct,Nt=ut(),jt={"Content-Type":"application/x-www-form-urlencoded"};function Ut(e,t){!Tt.isUndefined(e)&&Tt.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var Ht,Bt={transitional:Dt,adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==r.default&&"[object process]"===Object.prototype.toString.call(r.default))&&(Ht=Rt()),Ht),transformRequest:[function(e,t){if(It(t,"Accept"),It(t,"Content-Type"),Tt.isFormData(e)||Tt.isArrayBuffer(e)||Tt.isBuffer(e)||Tt.isStream(e)||Tt.isFile(e)||Tt.isBlob(e))return e;if(Tt.isArrayBufferView(e))return e.buffer;if(Tt.isURLSearchParams(e))return Ut(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var n,r=Tt.isObject(e),a=t&&t["Content-Type"];if((n=Tt.isFileList(e))||r&&"multipart/form-data"===a){var i=this.env&&this.env.FormData;return Nt(n?{"files[]":e}:e,i&&new i)}return r||"application/json"===a?(Ut(t,"application/json"),function(e,t,n){if(Tt.isString(e))try{return(t||JSON.parse)(e),Tt.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||Bt.transitional,n=t&&t.silentJSONParsing,r=t&&t.forcedJSONParsing,a=!n&&"json"===this.responseType;if(a||r&&Tt.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(a){if("SyntaxError"===e.name)throw Lt.from(e,Lt.ERR_BAD_RESPONSE,this,null,this.response);throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ft?_t:(Ft=1,_t=null)},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};Tt.forEach(["delete","get","head"],(function(e){Bt.headers[e]={}})),Tt.forEach(["post","put","patch"],(function(e){Bt.headers[e]=Tt.merge(jt)}));var Mt,zt,Gt=Bt,Vt=$e,$t=Gt;function Qt(){return zt?Mt:(zt=1,Mt=function(e){return!(!e||!e.__CANCEL__)})}var Wt=$e,Jt=function(e,t,n){var r=this||$t;return Vt.forEach(n,(function(n){e=n.call(r,e,t)})),e},Kt=Qt(),Xt=Gt,Yt=Ot();function Zt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Yt}var en,tn,nn=$e,rn=function(e,t){t=t||{};var n={};function r(e,t){return nn.isPlainObject(e)&&nn.isPlainObject(t)?nn.merge(e,t):nn.isPlainObject(t)?nn.merge({},t):nn.isArray(t)?t.slice():t}function a(n){return nn.isUndefined(t[n])?nn.isUndefined(e[n])?void 0:r(void 0,e[n]):r(e[n],t[n])}function i(e){if(!nn.isUndefined(t[e]))return r(void 0,t[e])}function o(n){return nn.isUndefined(t[n])?nn.isUndefined(e[n])?void 0:r(void 0,e[n]):r(void 0,t[n])}function s(n){return n in t?r(e[n],t[n]):n in e?r(void 0,e[n]):void 0}var l={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s};return nn.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=l[e]||a,r=t(e);nn.isUndefined(r)&&t!==s||(n[e]=r)})),n};function an(){return tn?en:(tn=1,en={version:"0.27.2"})}var on=an().version,sn=nt(),ln={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){ln[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var cn={};ln.transitional=function(e,t,n){function r(e,t){return"[Axios v"+on+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,a,i){if(!1===e)throw new sn(r(a," has been removed"+(t?" in "+t:"")),sn.ERR_DEPRECATED);return t&&!cn[a]&&(cn[a]=!0,console.warn(r(a," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,a,i)}};var un,dn,hn,fn,pn,gn,vn={assertOptions:function(e,t,n){if("object"!=typeof e)throw new sn("options must be an object",sn.ERR_BAD_OPTION_VALUE);for(var r=Object.keys(e),a=r.length;a-- >0;){var i=r[a],o=t[i];if(o){var s=e[i],l=void 0===s||o(s,i,e);if(!0!==l)throw new sn("option "+i+" must be "+l,sn.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new sn("Unknown option "+i,sn.ERR_BAD_OPTION)}},validators:ln},mn=$e,yn=Je,bn=et,wn=function(e){return Zt(e),e.headers=e.headers||{},e.data=Jt.call(e,e.data,e.headers,e.transformRequest),e.headers=Wt.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Wt.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||Xt.adapter)(e).then((function(t){return Zt(e),t.data=Jt.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return Kt(t)||(Zt(e),t&&t.response&&(t.response.data=Jt.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},Sn=rn,En=xt,_n=vn,Fn=_n.validators;function Pn(e){this.defaults=e,this.interceptors={request:new bn,response:new bn}}Pn.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=Sn(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var n=t.transitional;void 0!==n&&_n.assertOptions(n,{silentJSONParsing:Fn.transitional(Fn.boolean),forcedJSONParsing:Fn.transitional(Fn.boolean),clarifyTimeoutError:Fn.transitional(Fn.boolean)},!1);var r=[],a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,r.unshift(e.fulfilled,e.rejected))}));var i,o=[];if(this.interceptors.response.forEach((function(e){o.push(e.fulfilled,e.rejected)})),!a){var s=[wn,void 0];for(Array.prototype.unshift.apply(s,r),s=s.concat(o),i=Promise.resolve(t);s.length;)i=i.then(s.shift(),s.shift());return i}for(var l=t;r.length;){var c=r.shift(),u=r.shift();try{l=c(l)}catch(e){u(e);break}}try{i=wn(l)}catch(e){return Promise.reject(e)}for(;o.length;)i=i.then(o.shift(),o.shift());return i},Pn.prototype.getUri=function(e){e=Sn(this.defaults,e);var t=En(e.baseURL,e.url);return yn(t,e.params,e.paramsSerializer)},mn.forEach(["delete","get","head","options"],(function(e){Pn.prototype[e]=function(t,n){return this.request(Sn(n||{},{method:e,url:t,data:(n||{}).data}))}})),mn.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,a){return this.request(Sn(a||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}Pn.prototype[e]=t(),Pn.prototype[e+"Form"]=t(!0)}));var An=$e,xn=xe,Cn=Pn,kn=rn;var On=function e(t){var n=new Cn(t),r=xn(Cn.prototype.request,n);return An.extend(r,Cn.prototype,n),An.extend(r,n),r.create=function(n){return e(kn(t,n))},r}(Gt);On.Axios=Cn,On.CanceledError=Ot(),On.CancelToken=function(){if(dn)return un;dn=1;var e=Ot();function t(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var n;this.promise=new Promise((function(e){n=e}));var r=this;this.promise.then((function(e){if(r._listeners){var t,n=r._listeners.length;for(t=0;t<n;t++)r._listeners[t](e);r._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},t((function(t){r.reason||(r.reason=new e(t),n(r.reason))}))}return t.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},t.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},t.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},t.source=function(){var e;return{token:new t((function(t){e=t})),cancel:e}},un=t}(),On.isCancel=Qt(),On.VERSION=an().version,On.toFormData=ut(),On.AxiosError=nt(),On.Cancel=On.CanceledError,On.all=function(e){return Promise.all(e)},On.spread=fn?hn:(fn=1,hn=function(e){return function(t){return e.apply(null,t)}}),On.isAxiosError=function(){if(gn)return pn;gn=1;var e=$e;return pn=function(t){return e.isObject(t)&&!0===t.isAxiosError}}(),Ae.exports=On,Ae.exports.default=On;var qn=Ae.exports;function Rn(e){this.message=e}Rn.prototype=new Error,Rn.prototype.name="InvalidCharacterError";var Tn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new Rn("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,a=0,i=0,o="";r=t.charAt(i++);~r&&(n=a%4?64*n+r:r,a++%4)?o+=String.fromCharCode(255&n>>(-2*a&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return o};function In(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 function(e){return decodeURIComponent(Tn(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return Tn(t)}}function Ln(e){this.message=e}Ln.prototype=new Error,Ln.prototype.name="InvalidTokenError";var Dn=function(){function e(){var e=this;salla.event.on("twilight::before.ready",(function(t){return e.initiateRequest(t)})),salla.event.on("profile::info.fetched",(function(t){return e.setCurrencyAndLanguage(t)})),salla.event.on("auth::token.fetched",(function(t){salla.storage.set("token",t),e.setToken(t),salla.cart.api.reset()})),this.notifier_handler_disabled=!1,this.axios=qn.create({headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"v2.0.0","S-APP-OS":"browser"}}})}return e.prototype.getHeaders=function(){return this.axios.defaults.headers.common},e.prototype.setHeaders=function(e){var t=this;return Object.entries(e).forEach((function(e){return t.setHeader(e[0],e[1])})),this},e.prototype.setHeader=function(e,t){return salla.infiniteScroll.fetchOptions.headers[e]=this.axios.defaults.headers.common[e]=t,this},e.prototype.withoutNotifier=function(e){return h(this,void 0,void 0,(function(){var t=this;return f(this,(function(n){switch(n.label){case 0:return this.notifier_handler_disabled=!0,[4,e().finally((function(){t.notifier_handler_disabled=!1}))];case 1:return[2,n.sent()]}}))}))},e.prototype.initiateRequest=function(e){var t,n;this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders({"Store-Identifier":Salla.config.get("store.id"),currency:(null===(t=e.user)||void 0===t?void 0:t.currency_code)||"SAR","accept-language":salla.lang.getLocale(),"s-user-id":null===(n=e.user)||void 0===n?void 0:n.id});var r=salla.storage.get("scope");r&&this.setHeaders({"s-scope-type":r.type,"s-scope-id":r.id}),this.injectTokenToTheRequests(e),salla.storage.get("affiliate_code")&&this.setHeader("s-affiliate-code",salla.storage.get("affiliate_code"))},e.prototype.injectTokenToTheRequests=function(e){var t,n,r,a=salla.storage.get("token"),i="guest"===e.user.type,o=salla.storage.get("cart"),s=null===(t=e.user)||void 0===t?void 0:t.id,l=salla.storage.get("user.id");if(l&&l!==s&&(salla.log("Api:: case1 = >user in localStorage is not same as user in the config"),salla.storage.remove("user")),o&&(o.user_id!==s||o.store_id!==(null===(n=e.store)||void 0===n?void 0:n.id)))return salla.log("cart",{user_id:o.user_id,store_id:o.store_id}),salla.log("current",{user_id:s,store_id:null===(r=e.store)||void 0===r?void 0:r.id}),salla.log("Api:: case2 => The cart is not belong to current "+(o.user_id!==s?"user":"store")+"!"),void salla.cart.api.reset();if(!i||a){if(i&&a)return salla.log("Api:: case4 => there is a token and current user is guest"),salla.log("Auth:: Token without user!"),salla.storage.remove("token"),void salla.cart.api.reset();if(!a)return salla.log("Api:: case5 => current user is logged-in but there is no token"),salla.cart.api.reset(),void salla.auth.api.refresh();var c=function(e,t){if("string"!=typeof e)throw new Ln("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(In(e.split(".")[n]))}catch(e){throw new Ln("Invalid token specified: "+e.message)}}(a);if(Date.now()/1e3>c.exp)return salla.log("Api:: case6 => current user is logged-in and there is a token, but it's expired"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh();if(c.sub!==s)return salla.log("Api:: case7 => The user id is not match the token details"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh();this.setToken(a),salla.log("Api:: case8 => current user is logged-in and there is a token, and it's not expired"),salla.event.emit("api::initiated")}else salla.log("Api:: case3 => current user is a guest and there is no token")},e.prototype.setToken=function(e){return this.setHeader("Authorization","Bearer "+e),salla.event.emit("api::token.injected",e),this.token=e,this},e.prototype.setCurrencyAndLanguage=function(e){return this.setHeaders({currency:e.data.currency,"accept-language":e.data.language})},e.prototype.request=function(e,t,n,r){var a=this;void 0===t&&(t=void 0),void 0===n&&(n="get"),void 0===r&&(r={});var i={endPoint:e,payload:t,method:n,options:r},o="undefined"!=typeof event?event.currentTarget:null,s=!1;return"SALLA-BUTTON"===(null==o?void 0:o.tagName)&&(s=!0),s&&(null==o||o.load()),this.axios[i.method](i.endPoint,i.payload,i.options).then((function(e){return s&&(null==o||o.stop()),e.data&&e.request&&(e=e.data),a.handleAfterResponseActions(e),e})).catch((function(e){throw s&&(null==o||o.stop()),salla.event.document.requestFailed(i,e),a.handleErrorResponse(e),e}))},e.prototype.handleAfterResponseActions=function(e){if(e){var t=e.data,n=e.googleTags,r=void 0===n?null:n,a=t&&t.googleTags?t.googleTags:r;try{window.dataLayer&&a&&window.dataLayer.push(a)}catch(e){salla.logger.error(e.message)}this.fireEventsForResponse(e),this.showAlert(e)}},e.prototype.fireEventsForResponse=function(e){var t,n,r=(null==e?void 0:e.events)||(null===(t=e.data)||void 0===t?void 0:t.events)||(null===(n=e.error)||void 0===n?void 0:n.events);"string"==typeof r&&(r=JSON.parse(r)),r&&Object.keys(r).forEach((function(e){return salla.event.dispatch(e,r[e])}))},e.prototype.handleErrorResponse=function(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields&&!this.notifier_handler_disabled?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)},e.prototype.showAlert=function(e){var t,n;if(e&&!this.notifier_handler_disabled)return e.case&&e.msg?salla.notify.fire(e.msg,e.case,e):e.hasOwnProperty("success")&&(null===(t=e.data)||void 0===t?void 0:t.message)?salla.notify.fire(null===(n=e.data)||void 0===n?void 0:n.message,e.success?salla.notify.types.success:salla.notify.types.error,e):e.error&&e.error.message&&"FORBIDDEN"!==e.error.message?salla.error(e.error.message,e):void 0},e.prototype.handleInvalidFields=function(e){var t=e.response.data.error.fields,n=[];Object.keys(t).forEach((function(e){var r=t[e];Array.isArray(r)?r.forEach((function(e){return n.push(e)})):n.push(r)}));var r=(n.length>1?"* ":"")+n.join("\n* ");salla.error(r,e)},e.prototype.isFastRequestsAllowed=function(){return Salla.config.get("fastRequests")},e.prototype.promise=function(e,t){return void 0===t&&(t=!0),new Promise((function(n,r){return t?n(e):r(e)}))},e.prototype.errorPromise=function(e){return this.promise(e,!1)},e.prototype.successPromise=function(e){return this.promise(e,!0)},e}(),Nn=function(e){function t(){var t=e.call(this)||this;return t.auth=new pe,t.cart=new he,t.loyalty=new fe,t.order=new ge,t.rating=new Se,t.product=new ve,t.profile=new me,t.comment=new ye,t.currency=new be,t.document=new we,t.wishlist=new Ee,t.scope=new _e,t.booking=new Fe,t.landing=new Pe,t}return u(t,e),t}(Dn),jn=function(){function e(e){var t,n;"ready"!==Salla.status?e?(Salla.config.merge(e),(null==e?void 0:e.events)&&Salla.event.dispatchEvents(null==e?void 0:e.events),e._token&&salla.api.setHeader("X-CSRF-TOKEN",e._token),this.injectMaintenanceAlert(),this.injectThemePreviewAlert(),this.injectEditAlert(),(null===(t=null==e?void 0:e.user)||void 0===t?void 0:t.language_code)&&salla.lang.setLocale(null===(n=null==e?void 0:e.user)||void 0===n?void 0:n.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(e)):this.setSallaReady(e):salla.log("Trying to re-initiate Salla, while its status === 'ready'!")}return e.prototype.injectMaintenanceAlert=function(){salla.config.get("maintenance")&&(document.body.classList.add("has-maintenance-bar"),document.querySelector("salla-maintenance-alert")?salla.logger.warn("salla-maintenance-alert element Existed before!"):salla.lang.onLoaded((function(){return document.body.prepend(document.createElement("salla-maintenance-alert"))})))},e.prototype.injectThemePreviewAlert=function(){"preview"===salla.config.get("theme.mode")&&(document.body.classList.add("has-preview-bar"),document.querySelector("#s-theme_preview_bar")?salla.logger.warn("#s-theme_preview_bar element Existed before!"):salla.lang.onLoaded((function(){var e=document.createElement("div");e.id="s-theme_preview_bar",e.setAttribute("style","display: flex; justify-content: space-between; text-align: center; background-color: #232323; color: #fff; padding: 10px; font-size: 0.875rem; line-height: 1.25rem; position: relative;"),e.innerHTML='\n <div style="display:flex; align-items:center;">\n <img width="32" src="https://assets.salla.sa/cp/assets/images/logo-new.png">\n <span style="margin:0 10px;">'.concat(salla.lang.get("blocks.header.preview_mode"),': <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">').concat(salla.config.get("theme.name"),'</span></span>\n </div>\n <a href="').concat(salla.url.get("preview_theme/cancel/preview"),'" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n '),document.body.prepend(e)})))},e.prototype.injectEditAlert=function(){var e=salla.config.get("edit");e&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((function(){var t=document.createElement("div");t.id="s-edit-alert",t.innerHTML='\n <a href="'.concat(e,'" style="display:block; background-color:').concat(salla.config.get("theme.color.primary","#5cd5c4"),"; color:").concat(salla.config.get("theme.color.reverse","#fff"),'; padding: 10px; text-align:center; font-size: 0.875rem; line-height: 1.25rem;">\n <i class="sicon-edit"></i> \n ').concat(salla.lang.get("pages.products.quick_edit"),"\n </a>\n "),document.body.prepend(t)})))},e.prototype.handleElementAjaxRequest=function(e,t){var n=this;if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),!1;e.preventDefault();var r=t.getAjaxFormData(e),a=r.method?r.method.toLowerCase():void 0;salla.api.request(r.url,r.formData,a).then((function(e){return e.data&&e.request&&(e=e.data),salla.api.handleAfterResponseActions(e),n.callAjaxEvent(r.events.success,e,r.formData),e})).catch((function(e){throw salla.api.handleErrorResponse(e),n.callAjaxEvent(r.events.fail,e,r.formData),e}))},e.prototype.callAjaxEvent=function(e,t,n){if(e){if(n instanceof FormData){var r={};Array.from(n.entries()).forEach((function(e){r[e[0]]=e[1]})),n=r}window[e]?window[e](t,n):salla.event.dispatch(e,t,n)}},e.prototype.setSallaReady=function(e){Salla.event.dispatch("twilight::before.ready",e),Salla.status="ready",Salla.event.dispatch("twilight::initiated",e),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:e}))},e}();Salla.status="loading",Salla.notify=s,Salla.lang=new ue,Salla.form=new se,Salla.infiniteScroll=new oe(void 0,salla.event.infiniteScroll),Salla.api=new Nn,["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing"].forEach((function(e){return Salla[e]=new l(Salla.api[e],Salla.event[e])})),Salla.call=function(e){for(var t=Salla,n=e.split(".");n.length&&(t=t[n.shift()]););return t},Salla.init=function(e){return new jn(e)},salla.event.once("twilight::init",salla.init),salla.event.once("twilight::api",(function(e){var t=null==e?void 0:e.events;t&&salla.event.dispatchEvents(t)})),Salla.success=Salla.notify.success,Salla.error=Salla.notify.error,Salla.versions.twilight="2.12.0",Salla.onInitiated=function(e){return salla.event.once("twilight::initiated",e)},Salla.onReady=Salla.onReady||function(e){"ready"!==salla.status?Salla.onInitiated(e):e(salla.config.all())},window.dispatchEvent(new CustomEvent("salla::created"))}));
|
|
13
|
+
* Lang.js for Laravel localization in JavaScript.
|
|
14
|
+
*
|
|
15
|
+
* @version 1.1.12
|
|
16
|
+
* @license MIT https://github.com/rmariuzzo/Lang.js/blob/master/LICENSE
|
|
17
|
+
* @site https://github.com/rmariuzzo/Lang.js
|
|
18
|
+
* @author Rubens Mariuzzo <rubens@mariuzzo.com>
|
|
19
|
+
*/!function(e,t){e.exports=function(){function e(){if("undefined"!=typeof document&&document.documentElement)return document.documentElement.lang}function t(e){return"-Inf"===e?-1/0:"+Inf"===e||"Inf"===e||"*"===e?1/0:parseInt(e,10)}var r=/^({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])$/,n=/({\s*(\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)\s*})|([\[\]])\s*(-Inf|\*|\-?\d+(\.\d+)?)\s*,\s*(\+?Inf|\*|\-?\d+(\.\d+)?)\s*([\[\]])/,i={locale:"en"},a=function(t){t=t||{},this.locale=t.locale||e()||i.locale,this.fallback=t.fallback,this.messages=t.messages};return a.prototype.setMessages=function(e){this.messages=e},a.prototype.getLocale=function(){return this.locale||this.fallback},a.prototype.setLocale=function(e){this.locale=e},a.prototype.getFallback=function(){return this.fallback},a.prototype.setFallback=function(e){this.fallback=e},a.prototype.has=function(e,t){return!("string"!=typeof e||!this.messages)&&null!==this._getMessage(e,t)},a.prototype.get=function(e,t,r){if(!this.has(e,r))return e;var n=this._getMessage(e,r);return null===n?e:(t&&(n=this._applyReplacements(n,t)),n)},a.prototype.trans=function(e,t){return this.get(e,t)},a.prototype.choice=function(e,t,r,i){(r=void 0!==r?r:{}).count=t;var a=this.get(e,r,i);if(null==a)return a;for(var s=a.split("|"),o=[],l=0;l<s.length;l++)if(s[l]=s[l].trim(),n.test(s[l])){var c=s[l].split(/\s/);o.push(c.shift()),s[l]=c.join(" ")}if(1===s.length)return a;for(var u=0;u<o.length;u++)if(this._testInterval(t,o[u]))return s[u];return i=i||this._getLocale(e),s[this._getPluralForm(t,i)]},a.prototype.transChoice=function(e,t,r){return this.choice(e,t,r)},a.prototype._parseKey=function(e,t){if("string"!=typeof e||"string"!=typeof t)return null;var r=e.split("."),n=r[0].replace(/\//g,".");return{source:t+"."+n,sourceFallback:this.getFallback()+"."+n,entries:r.slice(1)}},a.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 r=this.messages[e.source],n=e.entries.slice(),i=n.join(".");if("string"!=typeof(r=void 0!==r?this._getValueInKey(r,i):void 0)&&this.messages[e.sourceFallback])for(r=this.messages[e.sourceFallback],n=e.entries.slice(),i="";n.length&&void 0!==r;)r[i=i?i.concat(".",n.shift()):n.shift()]&&(r=r[i],i="");return"string"!=typeof r?null:r},a.prototype._getValueInKey=function(e,t){if("string"==typeof e[t])return e[t];for(var r=(t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split("."),n=0,i=r.length;n<i;++n){var a=r.slice(0,n+1).join("."),s=r.slice(n+1,r.length).join(".");if(e[a])return this._getValueInKey(e[a],s)}return e},a.prototype._getLocale=function(e){return e=this._parseKey(e,this.locale),this.messages[e.source]?this.locale:this.messages[e.sourceFallback]?this.fallback:null},a.prototype._findMessageInTree=function(e,t){for(;e.length&&void 0!==t;){var r=e.join(".");if(t[r]){t=t[r];break}t=t[e.shift()]}return t},a.prototype._sortReplacementKeys=function(e,t){return t.length-e.length},a.prototype._applyReplacements=function(e,t){return Object.keys(t).sort(this._sortReplacementKeys).forEach((function(r){e=e.replace(new RegExp(":"+r,"gi"),(function(e){var n=t[r];return e===e.toUpperCase()?n.toUpperCase():e===e.replace(/\w/i,(function(e){return e.toUpperCase()}))?n.charAt(0).toUpperCase()+n.slice(1):n}))})),e},a.prototype._testInterval=function(e,n){if("string"!=typeof n)throw"Invalid interval: should be a string.";var i=(n=n.trim()).match(r);if(!i)throw"Invalid interval: "+n;if(!i[2]){var a=(i=i.filter((function(e){return!!e})))[1],s=t(i[2]);s===1/0&&(s=-1/0);var o=t(i[3]),l=i[4];return("["===a?e>=s:e>s)&&("]"===l?e<=o:e<o)}for(var c=i[2].split(","),u=0;u<c.length;u++)if(parseInt(c[u],10)===e)return!0;return!1},a.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:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2;case"cs":case"sk":return 1==e?0:e>=2&&e<=4?1:2;case"ga":return 1==e?0:2==e?1:2;case"lt":return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?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||e%100>1&&e%100<11?1:e%100>10&&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:e%10>=2&&e%10<=4&&(e%100<12||e%100>14)?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||e%100>0&&e%100<20?1:2;case"ar":return 0===e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11&&e%100<=99?4:5}},a}()}(un);var dn=un.exports;class hn{constructor(){this.endpoints={},this.webEndpoints=[],this.namespace="BaseApi",this.endpointsMethods={},this.endpointsHeaders={};let e=/function (.{1,})\(/.exec(this.constructor.toString());this.className=(e&&e.length>1?e[1]:"").toLowerCase(),this.debounce={request:void 0,time:300,enabled:!0,exclude:[]}}after_init(){}normalRequest(e,t,r=null){let n=Array.isArray(e),i=n?this.getUrl(...e):this.getUrl(e);e=n?e[0]:e,r=r||this.endpointsMethods[e]||"post";let a=this.endpointsHeaders[e];if("get"===r&&t instanceof FormData){let e={};Array.from(t.entries()).forEach((function(t){e[t[0]]=t[1]})),t={params:e}}return a&&"get"===r&&(t=t?Object.assign(t,a):a),this.webEndpoints.includes(e)?i=salla.url.get(i):"http"!==i.substring(0,4)&&(i=salla.url.api(i)),Salla.api.request(i,t,r,{headers:a})}request(e,t,r=null){return!salla.api.isFastRequestsAllowed()&&this.debounce.enabled?(this.debounce.request||(this.debounce.request=salla.helpers.debounce(this.normalRequest.bind(this),this.debounce.time)),this.debounce.request(e,t,r)):this.normalRequest(e,t,r)}getUrl(e){let t=this.endpoints[e]||e;const r=/{[^{}]+}/i;for(let e=1;e<arguments.length;e++)t=t.replace(r,arguments[e]);return t}event(){return salla.event[this.className]}}class fn extends hn{constructor(){super(),this.namespace="cart",this.endpoints={latest:"cart/latest",details:"cart/{cart}",quickAdd:"cart/{cart}/item/{product}/quick-add",addItem:"cart/{cart}/item/{product}/add",deleteItem:"cart/{cart}/item/{item}",updateItem:"cart/{cart}/item/{item}",deleteImage:"cart/{cart}/image/{image}",uploadImage:"cart/{cart}/image",status:"cart/{cart}/status",addCoupon:"cart/{id}/coupon",deleteCoupon:"cart/{id}/coupon",getQuickOrderSettings:"checkout/quick-order",createQuickOrder:"checkout/quick-order",priceQuote:"cart/{cartId}/price-quote"},this.endpointsMethods={latest:"get",details:"get",status:"get",updateItem:"post",deleteItem:"delete",deleteImage:"delete",deleteCoupon:"put",getQuickOrderSettings:"get"},this.webEndpoints=["latest"],this.latestCart=null,this.after_init(),salla.event.on("api::initiated",(()=>this.getCurrentCartId()))}async getCurrentCartId(){if(salla.cart.api.latestCart)return salla.cart.api.latestCart.cart.id;let e=salla.storage.get("cart.id");if(e)return e;let t=await this.latest();return salla.cart.api.latestCart=t.data,salla.cart.api.latestCart.cart.id}getUploadImageEndpoint(e){return salla.url.api(this.getUrl("uploadImage",e||salla.storage.get("cart.id")))}latest(){return this.request("latest",{params:{source:""}}).then((e=>(salla.storage.set("cart",e.data.cart),salla.event.cart.latestFetched(e),e))).catch((e=>{throw salla.storage.set("cart",""),salla.event.cart.latestFailed(e),e}))}async details(e,t=[]){return e=e||await this.getCurrentCartId(),this.request(["details",e],{params:{with:t}}).then((function(e){return salla.cart.event.detailsFetched(e),e})).catch((function(e){throw salla.cart.event.detailsNotFetched(e),e}))}async quickAdd(e,t){return this.addItem({id:e,quantity:t,endpoint:"quickAdd"})}async addItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no product "id"!';return salla.cart.event.itemAddedFailed(e),salla.api.errorPromise(e)}let r=salla.form.getPossibleValue(t.payload,["endpoint"]);r&&["addItem","quickAdd"].includes(r)||(r=salla.form.getPossibleValue(t.payload,["quantity","donating_amount"])?"addItem":"quickAdd");let n=await this.getCurrentCartId();return this.request([r,n,t.id],t.payload).then((function(e){return salla.cart.event.itemAdded(e,t.id),e})).catch((function(e){throw salla.cart.event.itemAddedFailed(e,t.id),e}))}async deleteItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no "id"!';return salla.cart.event.itemDeletedFailed(e),salla.api.errorPromise(e)}let r=await this.getCurrentCartId();return this.request(["deleteItem",r,t.id]).then((function(e){return salla.cart.event.itemDeleted(e,t.id),e})).catch((function(e){throw salla.cart.event.itemDeletedFailed(e,t.id),e}))}async updateItem(e){let t=this.getCartPayload(e);if(!t.id){let e='There is no "id"!';return salla.cart.event.itemUpdatedFailed(e),salla.api.errorPromise(e)}let r=await this.getCurrentCartId();return"Object"===t.payload.constructor?.name?t.payload._method="PUT":t.payload.append("_method","PUT"),this.request(["updateItem",r,t.id],t.payload).then((function(e){return salla.cart.event.itemUpdated(e,t.id),e})).catch((function(e){throw salla.cart.event.itemUpdatedFailed(e,t.id),e}))}async deleteImage(e){if(!(e=salla.form.getPossibleValue(e,["id","image_id","photo_id"]))){let e='There is no "id"!';return salla.cart.event.imageNotDeleted(e),salla.api.errorPromise(e)}let t=await this.getCurrentCartId();return this.request(["deleteImage",t,e]).then((function(t){return salla.cart.event.imageDeleted(t,e),t})).catch((function(t){throw salla.cart.event.imageNotDeleted(t,e),t}))}async status(e){return this.request(["status",e||await this.getCurrentCartId()],{params:{has_apple_pay:!!window.ApplePaySession}})}async submit(){this.status(await this.getCurrentCartId()).then((e=>{let t=e.data.next_step.to;if(!["checkout","refresh","login"].includes(t)){let e="Can't find next_step );";throw salla.cart.event.submitFailed(e),e}if(salla.cart.event.submitted(e),"login"===t)return salla.auth.setCanRedirect(!1),salla.event.dispatch("login::open"),void salla.auth.event.onLoggedIn((e=>{salla.event.dispatch("login::close"),this.submit()}));"checkout"===t?window.location.href=e.data.next_step.url+(window.ApplePaySession?"?has_apple_pay=true":""):window.location.reload()})).catch((function(e){throw salla.cart.event.submitFailed(e),e}))}getCartPayload(e){let t=e?.data||("object"==typeof e?e:void 0);return e=t?salla.form.getPossibleValue(t,["prod_id","product_id","item_id","id"]):e,t="object"==typeof t?t:void 0,{id:e,payload:t}}normalRequest(e,t,r=null){return super.normalRequest(e,t,r).catch((e=>{throw 403===e?.response?.status&&(salla.cart.api.reset(),salla.error(salla.lang.get("pages.checkout.try_again"))),e}))}reset(){salla.api.cart.latestCart=null,salla.storage.remove("cart"),salla.cart.event.successReset()}async addCoupon(e){if(e=e.data||e,!(e=salla.form.getPossibleValue(e,["coupon"]))){let e=new Error('There is no "Coupon Code"!');return e.name="EmptyCoupon",salla.event.cart.couponAdditionFailed(e),salla.api.errorPromise(e)}let t=await salla.cart.api.getCurrentCartId();return this.request(["addCoupon",t],{coupon:e}).then((function(e){return salla.event.cart.couponAdded(e,t),e})).catch((function(e){throw salla.event.cart.couponAdditionFailed(e,t),e}))}async deleteCoupon(){let e=await salla.cart.api.getCurrentCartId();return this.request(["deleteCoupon",e],{}).then((function(t){return salla.event.cart.couponDeleted(t,e),t})).catch((function(t){throw salla.event.cart.couponDeletionFailed(t,e),t}))}getQuickOrderSettings(){return this.request("getQuickOrderSettings").then((e=>(salla.event.cart.quickOrderSettingFetched(e),e))).catch((e=>{throw salla.event.cart.quickOrderSettingFailed(e),e}))}createQuickOrder(e){return this.request("createQuickOrder",e).then((e=>(salla.event.cart.quickOrderSucceeded(e),e))).catch((e=>{throw salla.event.cart.quickOrderFailed(e),e}))}async priceQuote(e){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("cart::priceQuote",e),void salla.event.dispatch("login::open")):this.request(["priceQuote",e||await this.getCurrentCartId()]).then((e=>(salla.cart.api.reset(),salla.event.cart.priceQuoteSucceeded(e).then((()=>(setTimeout((()=>window.location.href=salla.url.get("/")),1e3),e)))))).catch((e=>salla.event.cart.priceQuoteFailed(e).then((()=>{throw 404===e.error?.code&&window.location.reload(),e}))))}}class pn extends hn{constructor(){super(),this.namespace="loyalty",this.endpoints={getProgram:"loyalty",exchange:"loyalty/exchange",reset:"loyalty/exchange"},this.endpointsMethods={getProgram:"get",reset:"put"},this.after_init()}getProgram(){return this.request("getProgram").then((e=>(salla.loyalty.event.programFetched(e),e))).catch((e=>{throw salla.loyalty.event.programNotFetched(e),e}))}async exchange(e,t=null){if(!(e=salla.form.getPossibleValue(e,["id","loyalty_prize_id","prize_id"]))){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(e),salla.api.errorPromise(e)}if(!(t=t||await salla.cart.getCurrentCartId())){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.exchangeFailed(e),salla.api.errorPromise(e)}return this.request("exchange",{loyalty_prize_id:e,cart_id:t}).then((function(t){return salla.loyalty.event.exchangeSucceeded(t,e),t})).catch((function(t){throw salla.loyalty.event.exchangeFailed(t,e),t}))}async reset(e=null){if(!(e=e||await salla.cart.getCurrentCartId())){let e="Unable to find cart id. Please provide one.";return salla.loyalty.event.resetFailed(e),salla.api.errorPromise(e)}return this.request("reset",{cart_id:e}).then((e=>(salla.loyalty.event.resetSucceeded(e),e))).catch((e=>{throw salla.loyalty.event.resetFailed(e),e}))}}class gn extends hn{constructor(){super(),this.namespace="auth",this.canRedirect_=!0,this.afterLoginEvent={event:null,payload:null},this.endpoints={login:"auth/{type}/send_verification",resend:"auth/resend_verification",verify:"auth/{type}/verify",register:"auth/register",logout:"logout",refresh:"auth/refresh"},this.webEndpoints=["logout","auth/jwt","refresh"],this.endpointsMethods={logout:"get"},this.after_init()}setAfterLoginEvent(e,t){salla.api.auth.afterLoginEvent={event:e,payload:t}}setCanRedirect(e){salla.api.auth.canRedirect_=e}canRedirect(){return salla.api.auth.canRedirect_&&!salla.api.auth.afterLoginEvent.event}login(e){e?.data&&(e=e.data);let t=salla.form.getPossibleValue(e,["type"]);if(!["email","mobile"].includes(t)){let e="Login type should be in: [email, mobile]";return salla.auth.event.codeNotSent(e),salla.api.errorPromise(e)}return this.request(["login",t],e).then((function(e){return salla.auth.event.codeSent(e,t),e})).catch((function(e){throw salla.auth.event.codeNotSent(e,t),e}))}async verify(e,t=!0){let r=salla.form.getPossibleValue(e,["type"]);if(!r){let e="Failed to know what's login type!";return salla.auth.event.verificationFailed(e),salla.api.errorPromise(e)}t=!1!==salla.form.getPossibleValue(e,["supportWebAuth"])&&t,salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event);let n=await salla.auth.api.request(["verify",r],e);if(200!==n?.status)return salla.auth.event.verificationFailed(n,r),salla.api.errorPromise(n);let i="authenticated"===n.data?.case;return i&&salla.auth.event.tokenFetched(n.data.token),t&&await salla.auth.api.request("auth/jwt"),i&&salla.auth.event.loggedIn(n).then((()=>salla.auth.api.afterUserLogin())),salla.auth.event.verified(n,r),salla.api.successPromise(n)}resend(e){let t;return(e=e.data||e).type=e.type||"mobile","mobile"!==e.type||e.phone&&e.country_code?"email"!==e.type||e.email?this.request("resend",e).then((function(t){return salla.auth.event.codeSent(t,e),t})).catch((function(t){throw salla.auth.event.codeNotSent(t,e),t})):(salla.auth.event.codeNotSent(t="There is no email!",e),salla.api.errorPromise(t)):(salla.auth.event.codeNotSent(t="There is no phone or country_code!",e),salla.api.errorPromise(t))}register(e){let t;return e.data&&(t=e.element,e=e.data),salla.auth.event.next_event&&(e.next_event=salla.auth.event.next_event),this.request("register",e).then((async function(e){return salla.auth.event.registered.call(t,e),"authenticated"===e.data?.case&&(salla.auth.event.tokenFetched(e.data.token),await salla.auth.request("auth/jwt"),salla.auth.event.loggedIn(e),salla.auth.api.afterUserLogin()),e})).catch((function(e){throw salla.auth.event.registrationFailed.call(t,e),e}))}logout(e="twilight"){return salla.storage.clearAll(),salla.cookie.clearAll(),e=encodeURI(e),salla.auth.event.loggedOut().then((()=>{let t=salla.url.get(`logout?from=${e}`);console.log(`Going to ${t}, to do any thing before this action use: salla.auth.even.onLoggedOut(()=>{...})`);try{location.href=t}catch(e){salla.log(e)}}))}refresh(){return this.request("refresh").then((function(e){return salla.auth.event.tokenFetched(e.data.token),e})).catch((function(e){throw salla.auth.event.refreshFailed(e),e}))}afterUserLogin(){this.afterLoginEvent.event&&salla.event.emit(this.afterLoginEvent.event,this.afterLoginEvent.payload)}}class mn extends hn{constructor(){super(),this.namespace="order",this.endpoints={cancel:"orders/cancel/{id}",createCartFromOrder:"reorder/{id}",sendInvoice:"orders/send/{id}"},this.endpointsMethods={createCartFromOrder:"get"},this.after_init()}show(e){let t=salla.form.getPossibleValue(e?.data||e,["id","order_id"]);salla.event.dispatch("mobile::order.placed",{order_id:t}),location.href=salla.form.getPossibleValue(e?.data||e,["url"])}cancel(e){return e=e||Salla.config.get("page.id"),this.request(["cancel",e],{params:{has_apple_pay:!!window.ApplePaySession}}).then((function(t){return salla.event.order.canceled(t,e),t})).catch((function(t){throw salla.event.order.notCanceled(t,e),t}))}createCartFromOrder(e){return e=e||salla.config.get("page.id"),this.request(["createCartFromOrder",e]).then((function(t){return salla.cart.reset(),salla.event.order.orderCreated(t,e),window.location.href=t.data.url,t})).catch((function(t){throw salla.event.order.orderCreationFailed(t,e),t}))}sendInvoice(e){let t=salla.form.getPossibleValue(e,["id"])||salla.config.get("page.id");if(!t||isNaN(t)){let e="There is no id!";return salla.order.event.invoiceNotSent(e),salla.api.errorPromise(e)}return this.request(["sendInvoice",t],e).then((e=>(salla.event.order.invoiceSent(e,t),e))).catch((e=>{throw salla.event.order.invoiceNotSent(e,t),e}))}}class vn extends hn{constructor(){super(),this.namespace="product",this.previousQuery="",this.endpoints={getPrice:"products/{id}/price",availabilitySubscribe:"products/{id}/availability-notify",search:"products/search",details:"products/{product_id}/details",categories:"products/categories/{?id}",offers:"products/{product_id}/specialoffer",getSizeGuides:"products/{prod_id}/size-guides",giftDetail:"products/{product_id}/buy-as-gift",giftToCart:"products/{product_id}/buy-as-gift",giftImage:"products/buy-as-gift/image",buyNow:"products/{product_id}/buy-now",fetch:"products"},this.endpointsMethods={details:"get",giftDetail:"get",fetch:"get"},this.after_init()}getPrice(e){let t=e.data||e,r=salla.form.getPossibleValue(t,["id","prod_id","product_id"]);return this.request(["getPrice",r],"object"==typeof t?t:void 0).then((function(e){return salla.product.event.priceUpdated(e,r),e})).catch((function(e){throw salla.product.event.priceUpdateFailed(e,r),e}))}categories(e){return this.request(["categories",e||""],null,"get").then((function(e){return salla.product.event.categoriesFetched(e),e})).catch((function(e){throw salla.product.event.categoriesFailed(e),e}))}availabilitySubscribe(e){let t=e.data||e;return e=salla.form.getPossibleValue(t,["id","prod_id"]),this.request(["availabilitySubscribe",e],"object"==typeof t?t:void 0).then((function(t){return salla.product.event.availabilitySubscribed(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))}search(e){let t=e.data;if(t||(t={params:"string"==typeof e?{query:e}:e}),!(e=t instanceof FormData?t.get("query"):t.query||t.params?.query)){let e='There is no "query"!';return salla.product.event.searchFailed(e),salla.api.errorPromise(e)}if(e===salla.api.product.previousQuery){let e="Query is same as previous one!";return salla.product.event.searchFailed(e),salla.api.product.previousQuery=null,salla.api.errorPromise(e)}return salla.api.product.previousQuery=e,this.request("search",t,"get").then((function(t){return salla.product.event.searchResults(t,e),t})).catch((function(t){throw salla.product.event.searchFailed(t,e),t}))}offers(e){if(!(e=salla.form.getPossibleValue(e?.data|e,["product_id","id"]))){let e='There is no "product_id"!';return salla.product.event.fetchOffersFailed(e),salla.api.errorPromise(e)}return this.request(["offers",e]).then((function(t){return salla.product.event.offersFetched(t,e),t})).catch((function(t){throw salla.product.event.fetchOffersFailed(t,e),t}))}getSizeGuides(e){return this.request(`products/${e}/size-guides`,null,"get").then((t=>(salla.product.event.sizeGuideFetched(t,e),t))).catch((t=>{throw salla.product.event.sizeGuideFetchFailed(t,e),t}))}getGiftDetails(e){return this.request(["giftDetail",e]).then((t=>(salla.product.event.giftFetched(t,e),t))).catch((t=>{throw salla.product.event.giftFetchFailed(t,e),t}))}getDetails(e,t=[]){if(!Array.isArray(t)){let e="withItems should be array.";return salla.product.event.detailFetchFailed(e),salla.api.errorPromise(e)}if(!e){let e="productId is not passed.";return salla.product.event.detailFetchFailed(e),salla.api.errorPromise(e)}return this.request(["details",e],{params:{with:t}}).then((function(t){return salla.product.event.detailFetched(t,e),t})).catch((function(t){throw salla.product.event.availabilitySubscribeFailed(t,e),t}))}addGiftToCart(e,t,r=!1){return this.request(["giftToCart",e],t).then((t=>(salla.product.event.addGiftToCartSucceeded(t,e),r&&(window.location.href=t.redirect),t))).catch((t=>{throw salla.product.event.addGiftToCartFailed(t,e),t}))}uploadGiftImage(e){return this.request("giftImage",e).then((e=>(salla.product.event.giftImageUploadSucceeded(e),e))).catch((e=>{throw salla.product.event.giftImageUploadFailed(e),e}))}fetch(e){if(!e.source){let e="Source can not be empty. Please provide one.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}if(["categories","brands","tags","selected"].includes(e.source)&&!Array.isArray(e.source_value)||"search"===e.source&&"string"!=typeof e.source_value||"related"===e.source&&isNaN(e.source_value)){let e="SourceValue type error.";return salla.product.event.productListFetchFailed(e),salla.api.errorPromise(e)}return this.request(this.endpoints.fetch,{params:e},"get").then((e=>(salla.product.event.productListFetchSucceeded(e),e))).catch((e=>{throw salla.product.event.productListFetchFailed(e),e}))}}class yn extends hn{constructor(){super(),this.namespace="profile",this.endpoints={info:"auth/user",update:"profile/update",updateContacts:"profile/contacts/update",updateSettings:"profile/settings",verify:"profile/verify",delete:"profile"},this.endpointsMethods={delete:"delete"},this.after_init()}info(){return this.request("info",null,"get").then((e=>{let t={id:e.data.id,type:"user",email:e.data.email,mobile:e.data.phone.code+e.data.phone.number,country_code:e.data.phone.country,language_code:e.data.language,currency_code:e.data.currency,notifications:e.data.notifications,pending_orders:e.data.pending_orders,avatar:e.data.avatar,first_name:e.data.first_name,last_name:e.data.last_name,fetched_at:Date.now()};return salla.config.set("user",t),salla.storage.set("user",t),salla.profile.event.infoFetched(e),e})).catch((e=>{throw salla.profile.event.infoNotFetched(e),e}))}update(e){return this.request("update",e).then((e=>(salla.profile.event.updated(e),e))).catch((e=>{throw salla.event.profile.updateFailed(e),e}))}updateContacts(e){return this.request("updateContacts",e).then((e=>(salla.profile.event.verificationCodeSent(e),e))).catch((e=>{throw salla.event.profile.updateContactsFailed(e),e}))}verify(e){return this.request("verify",e).then((e=>(salla.profile.event.verified(e),e))).catch((e=>{throw salla.event.profile.unverified(e),e}))}updateSettings(e){return this.request("updateSettings",e).then((e=>(salla.event.profile.settingsUpdated(e),e))).catch((e=>{throw salla.event.profile.updateSettingsFailed(e),e}))}delete(){return this.request("delete").then((e=>(salla.storage.clearAll(),salla.cookie.clearAll(),salla.event.profile.deleted(e),window.location.href=salla.url.get("logout"),e))).catch((e=>{throw salla.event.profile.notDeleted(e),e}))}}class wn extends hn{constructor(){super(),this.namespace="comment",this.endpoints={comments:"{type}/{id}/comments"},this.after_init()}add(e){if(e?.data&&(e=e.data),"string"==typeof(e=this.getCommentPayload(e,!0)))return salla.event.comment.additionFailed(e),salla.api.errorPromise(e);if(!e.comment){let e="can't find comment content!";return salla.event.comment.additionFailed(e),salla.api.errorPromise(e)}return this.request(["comments",e.type,e.id],{comment:e.comment}).then((function(t){return salla.event.comment.added(t,e.id),t})).catch((function(t){throw salla.event.comment.additionFailed(t,e.id),t}))}getCommentPayload(e){let t={};return["id","type","comment","per_page","page"].forEach((r=>{let n=salla.form.getPossibleValue(e,[r]);n&&(t[r]=n)})),t.id?t.type&&["products","pages","product","page"].includes(t.type)?(t.type+=["product","page"].includes(t.type)?"s":"",t):"Failed to get type one of:(products, product, page, pages)!":"Failed to get id!"}fetch(e){return"string"==typeof(e=this.getCommentPayload(e))?(salla.event.comment.fetchFailed(e),salla.api.errorPromise(e)):this.request(["comments",e.type,e.id],{params:e},"get").then((function(t){return salla.event.comment.fetched(t,e),t})).catch((function(t){throw salla.event.comment.fetchFailed(t,e),t}))}getPageComments(e,t=1,r=10){return this.fetch({id:e,type:"pages",page:t,per_page:r})}getProductComments(e,t=1,r=10){return this.fetch({id:e,type:"products",page:t,per_page:r})}}class bn extends hn{constructor(){super(),this.namespace="currency",this.endpoints={change:"/",list:"currencies"},this.endpointsMethods={change:"get",list:"get"},this.webEndpoints=["change"],this.after_init()}change(e){if(!(e=salla.form.getPossibleValue(e.data||e,["currency","code"]))){let e="Can't find currency code!";return salla.currency.event.failed(e),salla.api.errorPromise(e)}return this.request("change",{params:{change_currency:"",currency:e}}).then((function(t){return salla.cookie.set("fresh_summary",1),salla.storage.set("cart",""),salla.currency.event.changed(t,e),t})).catch((function(t){throw salla.currency.event.failed(t,e),t}))}list(){return this.request("list").then((function(e){return salla.currency.event.fetched(e),e})).catch((function(e){throw salla.currency.event.failedToFetch(e),e}))}}class _n extends hn{constructor(){super(),this.namespace="document"}}class Sn extends hn{constructor(){super(),this.namespace="rating",this.endpoints={store:"rating/store",products:"rating/products",shipping:"rating/shipping",order:"rating/{order_id}"},this.endpointsMethods={order:"get"},this.after_init()}order(e){let t="object"==typeof e?e:{},r=salla.form.getPossibleValue(e?.data||e,["order_id","id"]);if(!r){let e='There is no "order_id"!';return salla.event.rating.orderNotFetched(e),salla.api.errorPromise(e)}return this.request(["order",r],t).then((function(e){return salla.event.rating.orderFetched(e,r),e})).catch((function(e){throw salla.event.rating.orderNotFetched(e,r),e}))}store(e){if(!(e=e?.data||e)){let e='There is no "data"!';return salla.event.rating.storeFailed(e),salla.api.errorPromise(e)}return this.request("store",e).then((function(t){return salla.event.rating.storeRated(t,e),t})).catch((function(t){throw salla.event.rating.storeFailed(t,e),t}))}products(e){if(!(e=e?.data||e)){let e='There is no "data"!';return salla.event.rating.productsFailed(e),salla.api.errorPromise(e)}return this.request("products",e).then((function(t){return salla.event.rating.productsRated(t,e),t})).catch((function(t){throw salla.event.rating.productsFailed(t,e),t}))}shipping(e){if(!(e=e?.data||e)){let e='There is no "data"!';return salla.event.rating.shippingFailed(e),salla.api.errorPromise(e)}return this.request("shipping",e).then((function(t){return salla.event.rating.shippingRated(t,e),t})).catch((function(t){throw salla.event.rating.shippingFailed(t,e),t}))}}class En extends hn{constructor(){super(),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(e){let t;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(t=salla.lang.get("common.messages.must_login")),salla.error(t),salla.api.errorPromise(t)):(e=salla.form.getPossibleValue(e?.data||e,["product_id","id"]))?this.request(["add",e]).then((t=>(this.updateWishlistStorage(e),salla.wishlist.event.added(t,e),t))).catch((function(t){throw salla.wishlist.event.additionFailed(t,e),t})):(salla.wishlist.event.additionFailed(t="Failed to get product id!"),salla.api.errorPromise(t))}remove(e){let t;return salla.config.isGuest()?(salla.wishlist.event.additionFailed(t=salla.lang.get("common.messages.must_login")),salla.error(t),salla.api.errorPromise(t)):(e=salla.form.getPossibleValue(e?.data||e,["product_id","id"]))?this.request(["remove",e]).then((t=>(this.updateWishlistStorage(e,!1),salla.wishlist.event.removed(t,e),t))).catch((function(t){throw salla.wishlist.event.removingFailed(t,e),t})):(salla.wishlist.event.removingFailed(t="Failed to get id!"),salla.api.errorPromise(t))}updateWishlistStorage(e,t=!0){let r=salla.storage.get("salla::wishlist",[]);t?r.push(e):r.splice(r.indexOf(e),1),salla.storage.set("salla::wishlist",r)}}class xn extends hn{constructor(){super(),this.namespace="scopes",this.endpoints={get:"scopes",change:"scopes",getProductAvailability:"scopes/availability?product_id={id}"},this.after_init()}get(){return this.request("scopes",null,"get").then((e=>(salla.scope.event.fetched(e),e))).catch((e=>{throw salla.scope.event.notFetched(e),e}))}change(e){return this.request("scopes",e).then((e=>(salla.scope.event.changeSucceeded(e),e))).catch((e=>{throw salla.scope.event.changeFailed(e),e}))}getProductAvailability(e=null){return this.request(`scopes/availability?product_id=${e}`,null,"get").then((t=>(salla.scope.event.productAvailabilityFetched(t,e),t))).catch((e=>{throw salla.scope.event.productAvailabilityNotFetched(e),e}))}}class Fn extends hn{constructor(){super(),this.namespace="booking",this.endpoints={add:"cart/booking/product/{id}"},this.endpointsMethods={add:"get"}}async add(e,t=!0){if(!e){let e="Please provide product id.";return salla.booking.event.additionFailed(e),salla.api.errorPromise(e)}return this.request(["add",e]).then((function(e){return salla.booking.event.added(e),t&&"booking"===e.data.redirect.to&&(window.location.href=e.data.redirect.url),e})).catch((function(e){throw salla.booking.event.additionFailed(e),e}))}}class An extends hn{constructor(){super(),this.namespace="landing",this.endpoints={getDetails:"landing/{landing_page_id}",createCartFromPage:"landing/{landing_page_id}"},this.endpointsMethods={getDetails:"get"},this.after_init()}getDetails(e){if(!e){let e="page landing id not passed";return salla.event.landing.getDetailsFailed(e),salla.api.errorPromise(e)}return this.request(["getDetails",e]).then((function(t){return salla.event.landing.detailsFetched(t,e),t})).catch((function(t){throw salla.event.landing.getDetailsFailed(t,e),t}))}createCartFromPage(e){if(!e){let e="page landing id not passed";return salla.event.landing.orderCreationFailed(e),salla.api.errorPromise(e)}return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("landing::createCartFromPage",e),salla.event.dispatch("login::open"),salla.api.successPromise("")):this.request(["createCartFromPage",e]).then((function(t){return salla.event.landing.orderCreated(t,e).then((()=>location.href=t.data.url)),t})).catch((function(t){throw salla.event.landing.orderCreationFailed(t,e),t}))}}var Pn,Ln={exports:{}},kn=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}},On=kn,Tn=Object.prototype.toString,jn=(Pn=Object.create(null),function(e){var t=Tn.call(e);return Pn[t]||(Pn[t]=t.slice(8,-1).toLowerCase())});function Cn(e){return e=e.toLowerCase(),function(t){return jn(t)===e}}function Rn(e){return Array.isArray(e)}function qn(e){return void 0===e}var In=Cn("ArrayBuffer");function Nn(e){return null!==e&&"object"==typeof e}function Dn(e){if("object"!==jn(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var Un=Cn("Date"),Hn=Cn("File"),Mn=Cn("Blob"),$n=Cn("FileList");function zn(e){return"[object Function]"===Tn.call(e)}var Bn=Cn("URLSearchParams");function Gn(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),Rn(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}var Wn,Vn=(Wn="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return Wn&&e instanceof Wn}),Qn={isArray:Rn,isArrayBuffer:In,isBuffer:function(e){return null!==e&&!qn(e)&&null!==e.constructor&&!qn(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||Tn.call(e)===t||zn(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&In(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:Nn,isPlainObject:Dn,isUndefined:qn,isDate:Un,isFile:Hn,isBlob:Mn,isFunction:zn,isStream:function(e){return Nn(e)&&zn(e.pipe)},isURLSearchParams:Bn,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:Gn,merge:function e(){var t={};function r(r,n){Dn(t[n])&&Dn(r)?t[n]=e(t[n],r):Dn(r)?t[n]=e({},r):Rn(r)?t[n]=r.slice():t[n]=r}for(var n=0,i=arguments.length;n<i;n++)Gn(arguments[n],r);return t},extend:function(e,t,r){return Gn(t,(function(t,n){e[n]=r&&"function"==typeof t?On(t,r):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,r,n){e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,r&&Object.assign(e.prototype,r)},toFlatObject:function(e,t,r){var n,i,a,s={};t=t||{};do{for(i=(n=Object.getOwnPropertyNames(e)).length;i-- >0;)s[a=n[i]]||(t[a]=e[a],s[a]=!0);e=Object.getPrototypeOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:jn,kindOfTest:Cn,endsWith:function(e,t,r){e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;var n=e.indexOf(t,r);return-1!==n&&n===r},toArray:function(e){if(!e)return null;var t=e.length;if(qn(t))return null;for(var r=new Array(t);t-- >0;)r[t]=e[t];return r},isTypedArray:Vn,isFileList:$n},Jn=Qn;function Kn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Xn=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(Jn.isURLSearchParams(t))n=t.toString();else{var i=[];Jn.forEach(t,(function(e,t){null!=e&&(Jn.isArray(e)?t+="[]":e=[e],Jn.forEach(e,(function(e){Jn.isDate(e)?e=e.toISOString():Jn.isObject(e)&&(e=JSON.stringify(e)),i.push(Kn(t)+"="+Kn(e))})))})),n=i.join("&")}if(n){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e},Yn=Qn;function Zn(){this.handlers=[]}Zn.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},Zn.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},Zn.prototype.forEach=function(e){Yn.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var ei,ti,ri=Zn,ni=Qn;function ii(){if(ti)return ei;ti=1;var e=Qn;function t(e,t,r,n,i){Error.call(this),this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}e.inherits(t,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var r=t.prototype,n={};return["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach((function(e){n[e]={value:e}})),Object.defineProperties(t,n),Object.defineProperty(r,"isAxiosError",{value:!0}),t.from=function(n,i,a,s,o,l){var c=Object.create(r);return e.toFlatObject(n,c,(function(e){return e!==Error.prototype})),t.call(c,n.message,i,a,s,o),c.name=n.name,l&&Object.assign(c,l),c},ei=t}var ai,si,oi,li,ci,ui,di={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};function hi(){if(si)return ai;si=1;var e=Qn;return ai=function(r,n){n=n||new FormData;var i=[];function a(r){return null===r?"":e.isDate(r)?r.toISOString():e.isArrayBuffer(r)||e.isTypedArray(r)?"function"==typeof Blob?new Blob([r]):t.Buffer.from(r):r}return function t(r,s){if(e.isPlainObject(r)||e.isArray(r)){if(-1!==i.indexOf(r))throw Error("Circular reference detected in "+s);i.push(r),e.forEach(r,(function(r,i){if(!e.isUndefined(r)){var o,l=s?s+"."+i:i;if(r&&!s&&"object"==typeof r)if(e.endsWith(i,"{}"))r=JSON.stringify(r);else if(e.endsWith(i,"[]")&&(o=e.toArray(r)))return void o.forEach((function(t){!e.isUndefined(t)&&n.append(l,a(t))}));t(r,l)}})),i.pop()}else n.append(s,a(r))}(r),n},ai}function fi(){if(li)return oi;li=1;var e=ii();return oi=function(t,r,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?r(new e("Request failed with status code "+n.status,[e.ERR_BAD_REQUEST,e.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):t(n)}}function pi(){if(ui)return ci;ui=1;var e=Qn;return ci=e.isStandardBrowserEnv()?{write:function(t,r,n,i,a,s){var o=[];o.push(t+"="+encodeURIComponent(r)),e.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),e.isString(i)&&o.push("path="+i),e.isString(a)&&o.push("domain="+a),!0===s&&o.push("secure"),document.cookie=o.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}}var gi,mi,vi,yi,wi,bi,_i,Si,Ei,xi,Fi,Ai,Pi=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},Li=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},ki=function(e,t){return e&&!Pi(t)?Li(e,t):t};function Oi(){if(mi)return gi;mi=1;var e=Qn,t=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];return gi=function(r){var n,i,a,s={};return r?(e.forEach(r.split("\n"),(function(r){if(a=r.indexOf(":"),n=e.trim(r.substr(0,a)).toLowerCase(),i=e.trim(r.substr(a+1)),n){if(s[n]&&t.indexOf(n)>=0)return;s[n]="set-cookie"===n?(s[n]?s[n]:[]).concat([i]):s[n]?s[n]+", "+i:i}})),s):s},gi}function Ti(){if(yi)return vi;yi=1;var e=Qn;return vi=e.isStandardBrowserEnv()?function(){var t,r=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(e){var t=e;return r&&(n.setAttribute("href",t),t=n.href),n.setAttribute("href",t),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=i(window.location.href),function(r){var n=e.isString(r)?i(r):r;return n.protocol===t.protocol&&n.host===t.host}}():function(){return!0}}function ji(){if(bi)return wi;bi=1;var e=ii();function t(t){e.call(this,null==t?"canceled":t,e.ERR_CANCELED),this.name="CanceledError"}return Qn.inherits(t,e,{__CANCEL__:!0}),wi=t}function Ci(){return Si?_i:(Si=1,_i=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""})}function Ri(){if(xi)return Ei;xi=1;var e=Qn,t=fi(),r=pi(),n=Xn,i=ki,a=Oi(),s=Ti(),o=di,l=ii(),c=ji(),u=Ci();return Ei=function(d){return new Promise((function(h,f){var p,g=d.data,m=d.headers,v=d.responseType;function y(){d.cancelToken&&d.cancelToken.unsubscribe(p),d.signal&&d.signal.removeEventListener("abort",p)}e.isFormData(g)&&e.isStandardBrowserEnv()&&delete m["Content-Type"];var w=new XMLHttpRequest;if(d.auth){var b=d.auth.username||"",_=d.auth.password?unescape(encodeURIComponent(d.auth.password)):"";m.Authorization="Basic "+btoa(b+":"+_)}var S=i(d.baseURL,d.url);function E(){if(w){var e="getAllResponseHeaders"in w?a(w.getAllResponseHeaders()):null,r={data:v&&"text"!==v&&"json"!==v?w.response:w.responseText,status:w.status,statusText:w.statusText,headers:e,config:d,request:w};t((function(e){h(e),y()}),(function(e){f(e),y()}),r),w=null}}if(w.open(d.method.toUpperCase(),n(S,d.params,d.paramsSerializer),!0),w.timeout=d.timeout,"onloadend"in w?w.onloadend=E:w.onreadystatechange=function(){w&&4===w.readyState&&(0!==w.status||w.responseURL&&0===w.responseURL.indexOf("file:"))&&setTimeout(E)},w.onabort=function(){w&&(f(new l("Request aborted",l.ECONNABORTED,d,w)),w=null)},w.onerror=function(){f(new l("Network Error",l.ERR_NETWORK,d,w,w)),w=null},w.ontimeout=function(){var e=d.timeout?"timeout of "+d.timeout+"ms exceeded":"timeout exceeded",t=d.transitional||o;d.timeoutErrorMessage&&(e=d.timeoutErrorMessage),f(new l(e,t.clarifyTimeoutError?l.ETIMEDOUT:l.ECONNABORTED,d,w)),w=null},e.isStandardBrowserEnv()){var x=(d.withCredentials||s(S))&&d.xsrfCookieName?r.read(d.xsrfCookieName):void 0;x&&(m[d.xsrfHeaderName]=x)}"setRequestHeader"in w&&e.forEach(m,(function(e,t){void 0===g&&"content-type"===t.toLowerCase()?delete m[t]:w.setRequestHeader(t,e)})),e.isUndefined(d.withCredentials)||(w.withCredentials=!!d.withCredentials),v&&"json"!==v&&(w.responseType=d.responseType),"function"==typeof d.onDownloadProgress&&w.addEventListener("progress",d.onDownloadProgress),"function"==typeof d.onUploadProgress&&w.upload&&w.upload.addEventListener("progress",d.onUploadProgress),(d.cancelToken||d.signal)&&(p=function(e){w&&(f(!e||e&&e.type?new c:e),w.abort(),w=null)},d.cancelToken&&d.cancelToken.subscribe(p),d.signal&&(d.signal.aborted?p():d.signal.addEventListener("abort",p))),g||(g=null);var F=u(S);F&&-1===["http","https","file"].indexOf(F)?f(new l("Unsupported protocol "+F+":",l.ERR_BAD_REQUEST,d)):w.send(g)}))},Ei}var qi=Qn,Ii=function(e,t){ni.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},Ni=ii(),Di=di,Ui=hi(),Hi={"Content-Type":"application/x-www-form-urlencoded"};function Mi(e,t){!qi.isUndefined(e)&&qi.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var $i,zi={transitional:Di,adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==i.default&&"[object process]"===Object.prototype.toString.call(i.default))&&($i=Ri()),$i),transformRequest:[function(e,t){if(Ii(t,"Accept"),Ii(t,"Content-Type"),qi.isFormData(e)||qi.isArrayBuffer(e)||qi.isBuffer(e)||qi.isStream(e)||qi.isFile(e)||qi.isBlob(e))return e;if(qi.isArrayBufferView(e))return e.buffer;if(qi.isURLSearchParams(e))return Mi(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var r,n=qi.isObject(e),i=t&&t["Content-Type"];if((r=qi.isFileList(e))||n&&"multipart/form-data"===i){var a=this.env&&this.env.FormData;return Ui(r?{"files[]":e}:e,a&&new a)}return n||"application/json"===i?(Mi(t,"application/json"),function(e,t,r){if(qi.isString(e))try{return(t||JSON.parse)(e),qi.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||zi.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,i=!r&&"json"===this.responseType;if(i||n&&qi.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw Ni.from(e,Ni.ERR_BAD_RESPONSE,this,null,this.response);throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ai?Fi:(Ai=1,Fi=null)},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};qi.forEach(["delete","get","head"],(function(e){zi.headers[e]={}})),qi.forEach(["post","put","patch"],(function(e){zi.headers[e]=qi.merge(Hi)}));var Bi,Gi,Wi=zi,Vi=Qn,Qi=Wi;function Ji(){return Gi?Bi:(Gi=1,Bi=function(e){return!(!e||!e.__CANCEL__)})}var Ki=Qn,Xi=function(e,t,r){var n=this||Qi;return Vi.forEach(r,(function(r){e=r.call(n,e,t)})),e},Yi=Ji(),Zi=Wi,ea=ji();function ta(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ea}var ra,na,ia=Qn,aa=function(e,t){t=t||{};var r={};function n(e,t){return ia.isPlainObject(e)&&ia.isPlainObject(t)?ia.merge(e,t):ia.isPlainObject(t)?ia.merge({},t):ia.isArray(t)?t.slice():t}function i(r){return ia.isUndefined(t[r])?ia.isUndefined(e[r])?void 0:n(void 0,e[r]):n(e[r],t[r])}function a(e){if(!ia.isUndefined(t[e]))return n(void 0,t[e])}function s(r){return ia.isUndefined(t[r])?ia.isUndefined(e[r])?void 0:n(void 0,e[r]):n(void 0,t[r])}function o(r){return r in t?n(e[r],t[r]):r in e?n(void 0,e[r]):void 0}var l={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:o};return ia.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=l[e]||i,n=t(e);ia.isUndefined(n)&&t!==o||(r[e]=n)})),r};function sa(){return na?ra:(na=1,ra={version:"0.27.2"})}var oa=sa().version,la=ii(),ca={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){ca[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var ua={};ca.transitional=function(e,t,r){function n(e,t){return"[Axios v"+oa+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,i,a){if(!1===e)throw new la(n(i," has been removed"+(t?" in "+t:"")),la.ERR_DEPRECATED);return t&&!ua[i]&&(ua[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,a)}};var da,ha,fa,pa,ga,ma,va={assertOptions:function(e,t,r){if("object"!=typeof e)throw new la("options must be an object",la.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(e),i=n.length;i-- >0;){var a=n[i],s=t[a];if(s){var o=e[a],l=void 0===o||s(o,a,e);if(!0!==l)throw new la("option "+a+" must be "+l,la.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new la("Unknown option "+a,la.ERR_BAD_OPTION)}},validators:ca},ya=Qn,wa=Xn,ba=ri,_a=function(e){return ta(e),e.headers=e.headers||{},e.data=Xi.call(e,e.data,e.headers,e.transformRequest),e.headers=Ki.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Ki.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||Zi.adapter)(e).then((function(t){return ta(e),t.data=Xi.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return Yi(t)||(ta(e),t&&t.response&&(t.response.data=Xi.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},Sa=aa,Ea=ki,xa=va,Fa=xa.validators;function Aa(e){this.defaults=e,this.interceptors={request:new ba,response:new ba}}Aa.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=Sa(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var r=t.transitional;void 0!==r&&xa.assertOptions(r,{silentJSONParsing:Fa.transitional(Fa.boolean),forcedJSONParsing:Fa.transitional(Fa.boolean),clarifyTimeoutError:Fa.transitional(Fa.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(i=i&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var a,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!i){var o=[_a,void 0];for(Array.prototype.unshift.apply(o,n),o=o.concat(s),a=Promise.resolve(t);o.length;)a=a.then(o.shift(),o.shift());return a}for(var l=t;n.length;){var c=n.shift(),u=n.shift();try{l=c(l)}catch(e){u(e);break}}try{a=_a(l)}catch(e){return Promise.reject(e)}for(;s.length;)a=a.then(s.shift(),s.shift());return a},Aa.prototype.getUri=function(e){e=Sa(this.defaults,e);var t=Ea(e.baseURL,e.url);return wa(t,e.params,e.paramsSerializer)},ya.forEach(["delete","get","head","options"],(function(e){Aa.prototype[e]=function(t,r){return this.request(Sa(r||{},{method:e,url:t,data:(r||{}).data}))}})),ya.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(Sa(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}Aa.prototype[e]=t(),Aa.prototype[e+"Form"]=t(!0)}));var Pa=Qn,La=kn,ka=Aa,Oa=aa;var Ta=function e(t){var r=new ka(t),n=La(ka.prototype.request,r);return Pa.extend(n,ka.prototype,r),Pa.extend(n,r),n.create=function(r){return e(Oa(t,r))},n}(Wi);Ta.Axios=ka,Ta.CanceledError=ji(),Ta.CancelToken=function(){if(ha)return da;ha=1;var e=ji();function t(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var r;this.promise=new Promise((function(e){r=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,r=n._listeners.length;for(t=0;t<r;t++)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},t((function(t){n.reason||(n.reason=new e(t),r(n.reason))}))}return t.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},t.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},t.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},t.source=function(){var e,r=new t((function(t){e=t}));return{token:r,cancel:e}},da=t}(),Ta.isCancel=Ji(),Ta.VERSION=sa().version,Ta.toFormData=hi(),Ta.AxiosError=ii(),Ta.Cancel=Ta.CanceledError,Ta.all=function(e){return Promise.all(e)},Ta.spread=pa?fa:(pa=1,fa=function(e){return function(t){return e.apply(null,t)}}),Ta.isAxiosError=function(){if(ma)return ga;ma=1;var e=Qn;return ga=function(t){return e.isObject(t)&&!0===t.isAxiosError}}(),Ln.exports=Ta,Ln.exports.default=Ta;var ja=Ln.exports;function Ca(e){this.message=e}Ca.prototype=new Error,Ca.prototype.name="InvalidCharacterError";var Ra="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new Ca("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,a=0,s="";n=t.charAt(a++);~n&&(r=i%4?64*r+n:n,i++%4)?s+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return s};function qa(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 function(e){return decodeURIComponent(Ra(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return Ra(t)}}function Ia(e){this.message=e}Ia.prototype=new Error,Ia.prototype.name="InvalidTokenError";class Na{constructor(){salla.event.on("twilight::before.ready",(e=>this.initiateRequest(e))),salla.event.on("profile::info.fetched",(e=>this.setCurrencyAndLanguage(e))),salla.event.on("auth::token.fetched",(e=>{salla.storage.set("token",e),this.setToken(e),salla.cart.api.reset()})),this.notifier_handler_disabled=!1,this.axios=ja.create({headers:{common:{"X-Requested-With":"XMLHttpRequest","S-SOURCE":"twilight","S-APP-VERSION":"v2.0.0","S-APP-OS":"browser"}}})}getHeaders(){return this.axios.defaults.headers.common}setHeaders(e){return Object.entries(e).forEach((e=>this.setHeader(e[0],e[1]))),this}setHeader(e,t){return salla.infiniteScroll.fetchOptions.headers[e]=this.axios.defaults.headers.common[e]=t,this}async withoutNotifier(e){return this.notifier_handler_disabled=!0,await e().finally((()=>{this.notifier_handler_disabled=!1}))}initiateRequest(e){this.axios.defaults.baseURL=Salla.config.get("store.api",Salla.config.get("store.url")),this.setHeaders({"Store-Identifier":Salla.config.get("store.id"),currency:e.user?.currency_code||"SAR","accept-language":salla.lang.getLocale(),"s-user-id":e.user?.id});let t=salla.storage.get("scope");t&&this.setHeaders({"s-scope-type":t.type,"s-scope-id":t.id}),this.injectTokenToTheRequests(e),salla.storage.get("affiliate_code")&&this.setHeader("s-affiliate-code",salla.storage.get("affiliate_code"))}injectTokenToTheRequests(e){let t=salla.storage.get("token"),r="guest"===e.user.type,n=salla.storage.get("cart"),i=e.user?.id,a=salla.storage.get("user.id");if(a&&a!==i&&(salla.log("Api:: case1 = >user in localStorage is not same as user in the config"),salla.storage.remove("user")),n&&(n.user_id!==i||n.store_id!==e.store?.id))return salla.log("cart",{user_id:n.user_id,store_id:n.store_id}),salla.log("current",{user_id:i,store_id:e.store?.id}),salla.log("Api:: case2 => The cart is not belong to current "+(n.user_id!==i?"user":"store")+"!"),void salla.cart.api.reset();if(r&&!t)return void salla.log("Api:: case3 => current user is a guest and there is no token");if(r&&t)return salla.log("Api:: case4 => there is a token and current user is guest"),salla.log("Auth:: Token without user!"),salla.storage.remove("token"),void salla.cart.api.reset();if(!t)return salla.log("Api:: case5 => current user is logged-in but there is no token"),salla.cart.api.reset(),void salla.auth.api.refresh();let s=function(e,t){if("string"!=typeof e)throw new Ia("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(qa(e.split(".")[r]))}catch(e){throw new Ia("Invalid token specified: "+e.message)}}(t);return Date.now()/1e3>s.exp?(salla.log("Api:: case6 => current user is logged-in and there is a token, but it's expired"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh()):s.sub!==i?(salla.log("Api:: case7 => The user id is not match the token details"),salla.storage.remove("token"),salla.cart.api.reset(),void salla.auth.api.refresh()):(this.setToken(t),salla.log("Api:: case8 => current user is logged-in and there is a token, and it's not expired"),void salla.event.emit("api::initiated"))}setToken(e){return this.setHeader("Authorization","Bearer "+e),salla.event.emit("api::token.injected",e),this.token=e,this}setCurrencyAndLanguage(e){return this.setHeaders({currency:e.data.currency,"accept-language":e.data.language})}request(e,t,r="get",n={}){let i={endPoint:e,payload:t,method:r,options:n},a="undefined"!=typeof event?event.currentTarget:null,s=!1;return"SALLA-BUTTON"===a?.tagName&&(s=!0),s&&a?.load(),this.axios[i.method](i.endPoint,i.payload,i.options).then((e=>(s&&a?.stop(),e.data&&e.request&&(e=e.data),this.handleAfterResponseActions(e),e))).catch((e=>{throw s&&a?.stop(),salla.event.document.requestFailed(i,e),this.handleErrorResponse(e),e}))}handleAfterResponseActions(e){if(!e)return;let{data:t,googleTags:r=null}=e,n=t&&t.googleTags?t.googleTags:r;try{dataLayer&&n&&dataLayer.push(n)}catch(e){salla.logger.error(e.message)}this.fireEventsForResponse(e),this.showAlert(e)}fireEventsForResponse(e){let t=e?.events||e.data?.events||e.error?.events;"string"==typeof t&&(t=JSON.parse(t)),t&&Object.keys(t).forEach((e=>salla.event.dispatch(e,t[e])))}handleErrorResponse(e){if(e.response&&e.response.data)return e.response.data.error&&e.response.data.error.fields&&!this.notifier_handler_disabled?this.handleInvalidFields(e):this.handleAfterResponseActions(e.response.data)}showAlert(e){if(e&&!this.notifier_handler_disabled)return e.case&&e.msg?salla.notify.fire(e.msg,e.case,e):e.hasOwnProperty("success")&&e.data?.message?salla.notify.fire(e.data?.message,e.success?salla.notify.types.success:salla.notify.types.error,e):e.error&&e.error.message&&"FORBIDDEN"!==e.error.message?salla.error(e.error.message,e):void 0}handleInvalidFields(e){let t=e.response.data.error.fields,r=[];Object.keys(t).forEach((e=>{let n=t[e];Array.isArray(n)?n.forEach((e=>r.push(e))):r.push(n)}));let n=(r.length>1?"* ":"")+r.join("\n* ");salla.error(n,e)}isFastRequestsAllowed(){return Salla.config.get("fastRequests")}promise(e,t=!0){return new Promise(((r,n)=>t?r(e):n(e)))}errorPromise(e){return this.promise(e,!1)}successPromise(e){return this.promise(e,!0)}}class Da{constructor(e){"ready"!==kr.status?e?(kr.config.merge(e),e?.events&&kr.event.dispatchEvents(e?.events),e._token&&salla.api.setHeader("X-CSRF-TOKEN",e._token),this.injectMaintenanceAlert(),this.injectThemePreviewAlert(),this.injectEditAlert(),e?.user?.language_code&&salla.lang.setLocale(e?.user?.language_code),salla.lang.loadStoreTranslations(),this.setSallaReady(e)):this.setSallaReady(e):salla.log("Trying to re-initiate Salla, while its status === 'ready'!")}injectMaintenanceAlert(){salla.config.get("maintenance")&&(document.body.classList.add("has-maintenance-bar"),document.querySelector("salla-maintenance-alert")?salla.logger.warn("salla-maintenance-alert element Existed before!"):salla.lang.onLoaded((()=>document.body.prepend(document.createElement("salla-maintenance-alert")))))}injectThemePreviewAlert(){"preview"===salla.config.get("theme.mode")&&(document.body.classList.add("has-preview-bar"),document.querySelector("#s-theme_preview_bar")?salla.logger.warn("#s-theme_preview_bar element Existed before!"):salla.lang.onLoaded((()=>{let e=document.createElement("div");e.id="s-theme_preview_bar",e.setAttribute("style","display: flex; justify-content: space-between; text-align: center; background-color: #232323; color: #fff; padding: 10px; font-size: 0.875rem; line-height: 1.25rem; position: relative;"),e.innerHTML=`\n <div style="display:flex; align-items:center;">\n <img width="32" src="https://assets.salla.sa/cp/assets/images/logo-new.png">\n <span style="margin:0 10px;">${salla.lang.get("blocks.header.preview_mode")}: <span style="background:rgba(255,255,255,0.25);border-radius:15px; padding:2px 15px 4px">${salla.config.get("theme.name")}</span></span>\n </div>\n <a href="${salla.url.get("preview_theme/cancel/preview")}" style="line-height:32px; width:32px;"><i class="sicon-cancel"></i></a>\n `,document.body.prepend(e)})))}injectEditAlert(){let e=salla.config.get("edit");e&&(document.querySelector("#s-edit-alert")?salla.logger.warn("#s-edit-alert element Existed before!"):salla.lang.onLoaded((()=>{let t=document.createElement("div");t.id="s-edit-alert",t.innerHTML=`\n <a href="${e}" style="display:block; background-color:${salla.config.get("theme.color.primary","#5cd5c4")}; color:${salla.config.get("theme.color.reverse","#fff")}; padding: 10px; text-align:center; font-size: 0.875rem; line-height: 1.25rem;">\n <i class="sicon-edit"></i> \n ${salla.lang.get("pages.products.quick_edit")}\n </a>\n `,document.body.prepend(t)})))}handleElementAjaxRequest(e,t){if(!(t instanceof HTMLFormElement||t instanceof HTMLAnchorElement))return salla.logger.warn("trying to call ajax from non Element!!"),!1;e.preventDefault();let r=t.getAjaxFormData(e),n=r.method?r.method.toLowerCase():void 0;salla.api.request(r.url,r.formData,n).then((e=>(e.data&&e.request&&(e=e.data),salla.api.handleAfterResponseActions(e),this.callAjaxEvent(r.events.success,e,r.formData),e))).catch((e=>{throw salla.api.handleErrorResponse(e),this.callAjaxEvent(r.events.fail,e,r.formData),e}))}callAjaxEvent(e,t,r){if(e){if(r instanceof FormData){const e={};Array.from(r.entries()).forEach((function(t){e[t[0]]=t[1]})),r=e}window[e]?window[e](t,r):salla.event.dispatch(e,t,r)}}setSallaReady(e){kr.event.dispatch("twilight::before.ready",e),kr.status="ready",kr.event.dispatch("twilight::initiated",e),window.dispatchEvent(new CustomEvent("twilight::initiated",{detail:e}))}}return kr.status="loading",kr.notify=Cr,kr.lang=new class extends dn{constructor(e){(e=e||{}).messages=e.messages||window.translations,e.locale=e.locale||(window.locale||navigator.language||navigator.userLanguage||"ar").split("-")[0],e.fallback=e.fallback||e.locale,super(e),this.translationsLoaded=!1}onLoaded(e){if(this.translationsLoaded)return e();Salla.event.once("languages::translations.loaded",e)}loadStoreTranslations(){if(this.hash=salla.config.get("theme.translations_hash",salla.config.get("store.id","twilight")),this.message||(salla.log("try to load translations from localstorage"),this.messages=salla.storage.get(`s_translations.${this.hash}`),this.messages&&(this.translationsLoaded=!0)&&super.setMessages(this.messages)),this.messages)return salla.event.dispatch("languages::translations.loaded"),void salla.logger.info("The messages of transactions is already loaded");salla.url.get("")?this.loadScript(salla.url.get(`languages/assets/${this.hash}.js`)):this.loadScript("https://cdn.salla.network/js/translations.js",!1)}setMessages(e){super.setMessages(e),salla.event.dispatch("languages::translations.loaded"),this.translationsLoaded=!0}loadScript(e,t=!0){let r=document.createElement("script");r.src=e,r.onload=()=>{if(window.translations)return salla.storage.remove("s_translations"),salla.storage.set("s_translations",{[this.hash]:window.translations}),this.setMessages(window.translations);r.onerror()},r.onerror=()=>{if(t)return salla.logger.warn("Failed to load Translations for store, lets try load it from CDN"),this.loadScript("https://cdn.salla.network/js/translations.js",!1);salla.logger.error("Failed to load Translations, check your network logs for more details\nor: salla.lang.setMessages({....}), see https://docs.salla.dev for more information's.")},document.head.appendChild(r)}getWithDefault(e,t,r,n){let i=this.get(e,r,n);return i!==e?i:t}get(e,t,r){let n=e;(window.translations||this.translationsLoaded)&&(n="trans."+e);let i=super.get(n,t,r);return i!==n?i:super.get(n,t,"en").replace(n,e)}set(e,t){return salla.helpers.setNested(this.messages[this.getLocale()+".trans"],e,t),this}},kr.form=new class{async submit(e,t=null){let r=t;if("SubmitEvent"===t?.constructor?.name||"submit"===t?.type){if(t.preventDefault(),"FORM"!==t.target?.tagName)return Salla.logger.warn("Failed find the target element for submit action. make sure you submit a form element"),new Promise((()=>{throw"Failed find the target element for submit action. make sure you submit a form element"}));"SALLA-BUTTON"===t?.submitter?.parentElement?.tagName&&t.submitter.parentElement.load(),r=t.target.getElementSallaData(),salla.log("Data from element",r)}if(/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/gm.test(e))return salla.api.request(e,r,"post").finally((()=>{loaderSupported&&t?.submitter?.parentElement.stop()}));let n=e.split("."),i=n.splice(-1);return await salla.call(n.join("."))[i](r).finally((()=>t?.submitter?.parentElement?.stop())).catch((e=>{throw salla.logger.warn(e),e}))}onSubmit(e,t){return salla.form.submit(e,t),!1}onChange(e,t){return t?.currentTarget?"FORM"!==t?.currentTarget?.tagName||t.currentTarget.checkValidity()?(salla.form.submit(e,t.currentTarget.getElementSallaData()),!0):(salla.logger.warn(`Trying to trigger '${e}' without filling required fields!`),!1):(salla.logger.warn(`Trying to trigger '${e}' without event!`),!1)}getPossibleValue(e,t,r=!1){if(!e)return;if("object"!=typeof e)return e;let n;for(let r=0;r<t.length&&!(n=e[t[r]])&&!("undefined"!=typeof FormData&&e instanceof FormData&&(n=e.get(t[r])));r++);return n=n||e,"object"!=typeof n||r?n:void 0}},kr.infiniteScroll=new class extends Rr{constructor(e,t){super(e,t),this.options={path:".infinite-scroll-btn",history:"push",status:".infinite-scroll-status",append:".list-block"},this.fetchOptions={headers:{"S-INFINITE-SCROLL":!0}},this.instances=[]}initiate(e,t,r,n=!1){n?((r=r||{}).fetchOptions={...this.fetchOptions,...r.fetchOptions||{}},r.responseBody="json"):r=this.getCustomOptions(t,r);let i="string"!=typeof e?e:document.querySelector(e),a=r.path;if(!i||!a||"string"==typeof a&&!document.querySelector(a))return void Salla.logger.warn(i?"Path Option (a link that has next page link) Not Existed!":"Container For InfiniteScroll not Existed!");let s=new cn(i,r);return s.on("scrollThreshold",Salla.infiniteScroll.event.scrollThreshold),s.on("request",Salla.infiniteScroll.event.request),s.on("load",Salla.infiniteScroll.event.load),s.on("append",Salla.infiniteScroll.event.append),s.on("error",Salla.infiniteScroll.event.error),s.on("last",Salla.infiniteScroll.event.last),s.on("history",Salla.infiniteScroll.event.history),this.instances.push(s),s}getCustomOptions(e,t){return(t="object"==typeof e&&e||t||this.options).fetchOptions=this.fetchOptions,t.path=t.path||this.options.path,t.button=t.button||t.path,t.status=t.status||this.options.status,t.hasOwnProperty("history")||(t.history=this.options.history),t.nextPage=t.nextPage||t.next_page,t.append="string"==typeof e&&e||t.append||this.options.append,t}loadNextPage(e){("string"!=typeof e?e:document.querySelector(e)).loadNextPage()}destroy(e){("string"!=typeof e?e:document.querySelector(e)).destroy()}}(void 0,salla.event.infiniteScroll),kr.api=new class extends Na{constructor(){super(),this.auth=new gn,this.cart=new fn,this.loyalty=new pn,this.order=new mn,this.rating=new Sn,this.product=new vn,this.profile=new yn,this.comment=new wn,this.currency=new bn,this.document=new _n,this.wishlist=new En,this.scope=new xn,this.booking=new Fn,this.landing=new An}},["cart","auth","order","scope","rating","comment","loyalty","product","profile","currency","document","wishlist","booking","landing"].forEach((e=>kr[e]=new Rr(kr.api[e],kr.event[e]))),kr.call=e=>{let t=kr,r=e.split(".");for(;r.length&&(t=t[r.shift()]););return t},kr.init=e=>new Da(e),salla.event.once("twilight::init",salla.init),salla.event.once("twilight::api",(e=>{let t=e?.events;t&&salla.event.dispatchEvents(t)})),kr.success=kr.notify.success,kr.error=kr.notify.error,kr.versions.twilight="2.12.3",kr.onInitiated=e=>salla.event.once("twilight::initiated",e),kr.onReady=kr.onReady||function(e){"ready"!==salla.status?kr.onInitiated(e):e(salla.config.all())},window.dispatchEvent(new CustomEvent("salla::created")),kr}));
|
|
21
20
|
//# sourceMappingURL=twilight.min.js.map
|