@salla.sa/twilight-components
Version:
Salla Web Component
11 lines • 768 kB
JavaScript
var __awaiter=this&&this.__awaiter||function(e,t,i,n){function a(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n["throw"](e))}catch(e){r(e)}}function l(e){e.done?i(e.value):a(e.value).then(o,s)}l((n=n.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,a,r,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return l([e,t])}}function l(s){if(n)throw new TypeError("Generator is already executing.");while(o&&(o=0,s[0]&&(i=0)),i)try{if(n=1,a&&(r=s[0]&2?a["return"]:s[0]?a["throw"]||((r=a["return"])&&r.call(a),0):a.next)&&!(r=r.call(a,s[1])).done)return r;if(a=0,r)s=[s[0]&2,r.value];switch(s[0]){case 0:case 1:r=s;break;case 4:i.label++;return{value:s[1],done:false};case 5:i.label++;a=s[1];s=[0];continue;case 7:s=i.ops.pop();i.trys.pop();continue;default:if(!(r=i.trys,r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){i=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){i.label=s[1];break}if(s[0]===6&&i.label<r[1]){i.label=r[1];r=s;break}if(r&&i.label<r[2]){i.label=r[2];i.ops.push(s);break}if(r[2])i.ops.pop();i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e];a=0}finally{n=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var n=0,a=t.length,r;n<a;n++){if(r||!(n in t)){if(!r)r=Array.prototype.slice.call(t,0,n);r[n]=t[n]}}return e.concat(r||Array.prototype.slice.call(t))};
/*!
* Crafted with ❤ by Salla
*/System.register(["./p-f422bbf9.system.js","./p-8f7b9e36.system.js","./p-61858adc.system.js","./p-8c9d72f2.system.js","./p-9beb6b7b.system.js","./p-910b705d.system.js","./p-e44f4650.system.js","./p-1a7e80e0.system.js","./p-35e033d4.system.js","./p-70434381.system.js"],(function(e){"use strict";var t,i,n,a,r,o,s,l,c,u,d,p,f,h,g,m,v,_;return{setters:[function(e){t=e.r;i=e.c;n=e.h;a=e.H;r=e.g;o=e.F},function(e){s=e.a},function(e){l=e.C},function(e){c=e.H},function(e){u=e.a;d=e.c;p=e.g},function(e){f=e.a},function(e){h=e.M},function(e){g=e.w},function(e){m=e.f;v=e.t},function(e){_=e.C}],execute:function(){var b=this;var y;var w='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="30" height="32" viewBox="0 0 30 32">\n<title>cart</title>\n<path d="M15.426 28.084c0-1.412-0.85-2.684-2.156-3.226-1.305-0.54-2.807-0.241-3.805 0.758-0.999 0.998-1.298 2.5-0.758 3.805 0.54 1.303 1.815 2.155 3.226 2.155 1.928-0.003 3.49-1.564 3.492-3.492h0.001zM10.597 28.084h0.001c0-0.54 0.326-1.027 0.825-1.235 0.498-0.206 1.074-0.091 1.455 0.29 0.383 0.382 0.497 0.957 0.29 1.456-0.208 0.5-0.695 0.825-1.235 0.825-0.355 0-0.695-0.142-0.944-0.391-0.251-0.251-0.392-0.591-0.392-0.946h-0.001l0.001 0.001zM28.23 28.084c0-1.412-0.85-2.684-2.155-3.226-1.305-0.54-2.807-0.241-3.806 0.758s-1.297 2.5-0.756 3.805c0.54 1.303 1.813 2.155 3.226 2.155 1.927-0.003 3.49-1.564 3.491-3.492zM23.401 28.084c0-0.54 0.326-1.027 0.825-1.235 0.5-0.206 1.075-0.091 1.457 0.29s0.497 0.957 0.289 1.456c-0.206 0.5-0.693 0.825-1.233 0.825-0.738 0-1.337-0.599-1.337-1.337l-0.001 0.001zM1.953 0.234l-0.342-0.059c-0.29-0.064-0.594-0.004-0.839 0.166-0.247 0.169-0.414 0.436-0.463 0.734-0.050 0.3 0.023 0.607 0.201 0.85s0.444 0.402 0.738 0.44l0.341 0.059c1.825 0.324 3.248 1.794 3.548 3.662l1.981 12.369h-0.001c0.218 1.387 0.913 2.651 1.96 3.563s2.379 1.412 3.754 1.41h14.242c0.601 0 1.088-0.498 1.088-1.112s-0.487-1.112-1.088-1.112h-14.242c-1.679-0.001-3.139-1.183-3.525-2.854h11.463c1.614 0.004 3.188-0.518 4.493-1.49 1.305-0.973 2.271-2.346 2.762-3.918l1.298-4.136c0.145-0.455 0.065-0.953-0.213-1.336-0.278-0.385-0.72-0.608-1.187-0.602h-20.467l-0.181-1.141c-0.218-1.367-0.849-2.631-1.802-3.615-0.954-0.983-2.184-1.64-3.518-1.878h-0.001zM26.946 9.096l-0.993 3.169v-0.001c-0.353 1.122-1.044 2.101-1.975 2.796s-2.056 1.067-3.208 1.067h-11.833l-1.125-7.042 19.134 0.011z"></path>\n</svg>\n';var x='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>full-wallet</title>\n<path d="M29 12h-26c-0.668-0.008-1.284-0.226-1.787-0.59l0.009 0.006c-0.744-0.552-1.222-1.428-1.222-2.416 0-1.657 1.343-3 2.999-3h6c0.552 0 1 0.448 1 1s-0.448 1-1 1v0h-6c-0.552 0-1 0.448-1 1 0 0.326 0.156 0.616 0.397 0.798l0.002 0.002c0.167 0.12 0.374 0.194 0.599 0.2l0.001 0h26c0.552 0 1 0.448 1 1s-0.448 1-1 1v0zM27 12c-0.552 0-1-0.448-1-1v0-3h-3c-0.552 0-1-0.448-1-1s0.448-1 1-1v0h4c0.552 0 1 0.448 1 1v0 4c0 0.552-0.448 1-1 1v0zM29 30h-26c-1.657 0-3-1.343-3-3v0-18c0-0.552 0.448-1 1-1s1 0.448 1 1v0 18c0 0.552 0.448 1 1 1v0h25v-5c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM29 18c-0.552 0-1-0.448-1-1v0-6c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM31 24h-7c-2.209 0-4-1.791-4-4s1.791-4 4-4v0h7c0.552 0 1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM24 18c-1.105 0-2 0.895-2 2s0.895 2 2 2v0h6v-4zM25 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-2.306 1.152c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 3.2-1.6c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1v0zM21 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-15.104 7.552c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 16-8c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1-0.001 0-0.001 0-0.002 0h0z"></path>\n</svg>\n';var E=":host{display:block}salla-add-product-button[width=wide]{width:100%}";var k=e("salla_add_product_button",function(){function e(e){var n=this;t(this,e);this.success=i(this,"success",7);this.failed=i(this,"failed",7);this.hostAttributes={};this.channels=undefined;this.subscribedOptions=undefined;this.quickBuy=undefined;this.quantity=undefined;this.donatingAmount=undefined;this.notifyOptionsAvailability=undefined;this.productId=undefined;this.supportStickyBar=undefined;this.productStatus="sale";this.productType="product";this.hasOutOfStockOption=undefined;this.hasSubscribedOptions=undefined;this.selectedOptions=[];this.showQuickBuy=undefined;this.isApplePayActive=undefined;this.buyNowText=salla.lang.get("pages.products.buy_now");salla.lang.onLoaded((function(){n.buyNowText=salla.lang.get("pages.products.buy_now")}))}e.prototype.getLabel=function(){if(this.productStatus==="sale"&&this.supportStickyBar&&window.innerWidth<=768&&this.showQuickBuy&&this.isApplePayActive){return w}if(this.productStatus==="sale"&&this.productType==="booking"){return salla.lang.get("pages.cart.book_now")}if(this.productStatus==="sale"){return salla.lang.get("pages.cart.add_to_cart")}if(this.productType!=="donating"){return salla.lang.get("pages.products.out_of_stock")}return salla.lang.get("pages.products.donation_exceed")};e.prototype.addProductToCart=function(e){var t=this;var i;if(this.productType==="booking"){e.preventDefault();return this.addBookingProduct()}if(this.hostAttributes.type==="submit"){return false}e.preventDefault();(i=this.btn)===null||i===void 0?void 0:i.disable();var n=Object.entries({id:this.productId,donation_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd"}).reduce((function(e,t){var i=t[0],n=t[1];return n?(e[i]=n,e):e}),{});return salla.cart.addItem(n).then((function(e){var i;t.selectedOptions=[];(i=t.btn)===null||i===void 0?void 0:i.enable();t.success.emit(e)})).catch((function(e){var i;t.failed.emit(e);(i=t.btn)===null||i===void 0?void 0:i.enable()}))};e.prototype.addBookingProduct=function(){var e=this;if(salla.config.isGuest()){salla.auth.api.setAfterLoginEvent("booking::add",this.productId);salla.event.dispatch("login::open");return}return salla.booking.add(this.productId).then((function(t){return e.success.emit(t)})).catch((function(t){return e.failed.emit(t)}))};e.prototype.getBtnAttributes=function(){for(var e=0;e<this.host.attributes.length;e++){if(!["id","class"].includes(this.host.attributes[e].name)){this.hostAttributes[this.host.attributes[e].name]=this.host.attributes[e].value}}return this.hostAttributes};e.prototype.getQuickBuyBtnAttributes=function(){return Object.assign(Object.assign({},this.getBtnAttributes()),{type:this.supportStickyBar&&window.innerWidth<=768?"plain":this.productType=="donating"?"donate":"buy"})};e.prototype.miniCheckoutWidget=function(){var e=salla.config.get("store.id");if(!e){return}return n("salla-mini-checkout-widget",{language:salla.lang.locale,"store-id":e,config:{user:salla.config.get("user")},products:[this.productId],api:salla.config.get("store.api"),outline:true,"form-selector":"form.product-form",class:"s-add-product-button-mini-checkout"},n("div",{slot:"widget-label",class:"s-add-product-button-mini-checkout-content"},n("span",{innerHTML:x}),this.buyNowText))};e.prototype.componentWillLoad=function(){var e=this;return salla.onReady().then((function(){var t,i,n;e.showQuickBuy=e.quickBuy&&salla.config.get("store.settings.buy_now")&&e.productStatus=="sale"&&e.productType!=="booking";e.isApplePayActive=((t=window.ApplePaySession)===null||t===void 0?void 0:t.canMakePayments())&&((i=salla.config.get("store.settings.payments"))===null||i===void 0?void 0:i.includes("apple_pay"))&&salla.config.get("store.settings.is_salla_gateway",false);e.passedLabel=e.host.innerHTML.replace("\x3c!----\x3e","").trim();if(!!e.passedLabel&&window.innerWidth>=768){return(n=e.btn)===null||n===void 0?void 0:n.setText(e.passedLabel)}if(e.host.getAttribute("type")==="submit"&&e.supportStickyBar){window.addEventListener("resize",(function(){var t;return(t=e.btn)===null||t===void 0?void 0:t.setText(window.innerWidth>=768&&!!e.passedLabel?e.passedLabel:e.getLabel())}))}}))};e.prototype.render=function(){var e=this;var t;if((t=this.host.closest(".swiper-slide"))===null||t===void 0?void 0:t.classList.contains("swiper-slide-duplicate")){return""}if(this.hasSubscribedOptions){return n(a,null,n("salla-product-availability",Object.assign({},this.getBtnAttributes(),{"is-subscribed":true}),n("span",{class:"s-hidden"},n("slot",null))))}if(this.productStatus==="out-and-notify"&&this.channels||this.hasOutOfStockOption){return n(a,null,n("salla-product-availability",Object.assign({},this.getBtnAttributes()),n("span",{class:"s-hidden"},n("slot",null))))}return n(a,{class:{"s-add-product-button-with-quick-buy":this.showQuickBuy,"s-add-product-button-with-sticky-bar":this.supportStickyBar,"s-add-product-button-with-apple-pay":this.showQuickBuy&&this.isApplePayActive}},n("div",{class:{"s-add-product-button-main":this.showQuickBuy,"w-full":!document.getElementById("fast-checkout-js")||["financial_support","donating"].includes(this.productType)}},n("salla-button",Object.assign({color:this.productStatus==="sale"?"primary":"light",type:"button",fill:this.productStatus==="sale"?"solid":"outline",ref:function(t){return e.btn=t},onClick:function(t){return e.addProductToCart(t)},disabled:this.productStatus!=="sale"},this.getBtnAttributes(),{"loader-position":"center"}),n("slot",null)),this.showQuickBuy&&!!document.getElementById("fast-checkout-js")&&!["financial_support","donating"].includes(this.productType)?this.miniCheckoutWidget():""),this.showQuickBuy&&this.isApplePayActive?n("salla-quick-buy",Object.assign({},this.getQuickBuyBtnAttributes())):"")};e.prototype.componentDidLoad=function(){var e=this;if(!this.notifyOptionsAvailability){return}salla.event.on("product-options::change",(function(t){return __awaiter(e,void 0,void 0,(function(){var e,i,n,a,r,o;var s=this;return __generator(this,(function(l){switch(l.label){case 0:if(!["thumbnail","color","single-option"].includes(t.option.type)){return[2]}this.hasSubscribedOptions=false;n=this;return[4,(e=document.querySelector('salla-product-options[product-id="'.concat(this.productId,'"]')))===null||e===void 0?void 0:e.getSelectedOptions()];case 1:n.selectedOptions=l.sent();a=this;return[4,(i=document.querySelector('salla-product-options[product-id="'.concat(this.productId,'"]')))===null||i===void 0?void 0:i.hasOutOfStockOption()];case 2:a.hasOutOfStockOption=l.sent();r=salla.storage.get("product-".concat(this.productId,"-subscribed-options"));if(!r&&!this.subscribedOptions||!this.hasOutOfStockOption){return[2]}if(salla.config.isGuest()){o=r?r.map((function(e){return e.split(",").map((function(e){return parseInt(e)}))})):[];this.hasSubscribedOptions=o.length>0&&o.some((function(e){return e.every((function(e){return s.selectedOptions.some((function(t){return t.id===e}))}))}))}else{this.hasSubscribedOptions=this.subscribedOptions&&this.subscribedOptions!=="null"&&this.subscribedOptions!=="[]"?JSON.parse(this.subscribedOptions).some((function(e){return e.every((function(e){return s.selectedOptions.some((function(t){return t.id===e}))}))})):false}return[2]}}))}))}))};e.prototype.componentDidRender=function(){var e=this;var t,i;if(!!this.passedLabel&&(!this.supportStickyBar||window.innerWidth>=768)){(t=this.btn)===null||t===void 0?void 0:t.setText(this.passedLabel);return}(i=this.btn)===null||i===void 0?void 0:i.setText(this.getLabel());salla.lang.onLoaded((function(){var t;return(t=e.btn)===null||t===void 0?void 0:t.setText(e.getLabel())}))};Object.defineProperty(e.prototype,"host",{get:function(){return r(this)},enumerable:false,configurable:true});return e}());k.style=E;var I='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>info</title>\n<path d="M16 13.333c-0.737 0-1.333 0.596-1.333 1.333v9.333c0 0.737 0.596 1.333 1.333 1.333s1.333-0.596 1.333-1.333v-9.333c0-0.737-0.596-1.333-1.333-1.333zM16 7.987c-0.737 0-1.333 0.596-1.333 1.333v0.013c0 0.737 0.596 1.327 1.333 1.327s1.333-0.603 1.333-1.34-0.596-1.333-1.333-1.333zM16 0c-8.823 0-16 7.177-16 16s7.177 16 16 16 16-7.177 16-16-7.177-16-16-16zM16 29.333c-7.352 0-13.333-5.981-13.333-13.333s5.981-13.333 13.333-13.333 13.333 5.981 13.333 13.333-5.981 13.333-13.333 13.333z"></path>\n</svg>\n';var T='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>shopping-bag2</title>\n<path d="M29.2 8.133c0 0 0-0.133-0.133-0.133 0 0 0-0.133-0.133-0.133l-4-5.333c-0.133-0.4-0.533-0.533-0.933-0.533h-16c-0.4 0-0.8 0.133-1.067 0.533l-4 5.333c0 0 0 0.133-0.133 0.133 0 0 0 0.133-0.133 0.133 0 0.267 0 0.4 0 0.533v18.667c0 2.267 1.733 4 4 4h18.667c2.267 0 4-1.733 4-4v-18.667c0-0.133 0-0.267-0.133-0.533zM8.667 4.667h14.667l2 2.667h-18.667l2-2.667zM25.333 28.667h-18.667c-0.8 0-1.333-0.533-1.333-1.333v-17.333h21.333v17.333c0 0.8-0.533 1.333-1.333 1.333zM21.333 12.667c-0.8 0-1.333 0.533-1.333 1.333 0 2.267-1.733 4-4 4s-4-1.733-4-4c0-0.8-0.533-1.333-1.333-1.333s-1.333 0.533-1.333 1.333c0 3.733 2.933 6.667 6.667 6.667s6.667-2.933 6.667-6.667c0-0.8-0.533-1.333-1.333-1.333z"></path>\n</svg>\n';var A=":host{display:block}";var S=e("salla_bottom_alert",function(){function e(e){var i=this;t(this,e);this.storeId=salla.config.get("store.id");this.template=salla.config.get("store.template");this.loading=false;this.templateData={};this.defaultMessage=salla.lang.get("common.elements.experimental_and_available_store");this.defaultActionLabel=salla.lang.get("common.elements.know_more");this.storeFeatures=salla.lang.get("common.elements.store_features");this.storeDetails=salla.lang.get("common.elements.store_details");this.storePrice=salla.lang.getWithDefault("common.elements.store_price","سعر المتجر");this.theDeveloper=salla.lang.get("common.elements.the_developer");this.templateInformation=salla.lang.get("common.elements.template_information");this.buyTheTemplate=salla.lang.get("common.elements.buy_the_template");this.isRtl=salla.config.get("theme.is_rtl",true);this.type="popup";this.icon=undefined;this.message=undefined;this.actionUrl=undefined;this.actionLabel=undefined;salla.lang.onLoaded((function(){i.defaultMessage=salla.lang.get("common.elements.experimental_and_available_store");i.defaultActionLabel=salla.lang.get("common.elements.know_more");i.storeFeatures=salla.lang.get("common.elements.store_features");i.storeDetails=salla.lang.get("common.elements.store_details");i.templateInformation=salla.lang.get("common.elements.template_information");i.buyTheTemplate=salla.lang.get("common.elements.buy_the_template");salla.helpers.setNested(salla.lang.messages["ar.trans"],"common.elements.store_price","سعر المتجر");salla.helpers.setNested(salla.lang.messages["en.trans"],"common.elements.store_price","Store Price");salla.helpers.setNested(salla.lang.messages["ar.trans"],"common.elements.the_developer","المطور");salla.helpers.setNested(salla.lang.messages["en.trans"],"common.elements.the_developer","the developer");setTimeout((function(){i.storePrice=salla.lang.get("common.elements.store_price");i.theDeveloper=salla.lang.get("common.elements.the_developer")}),100)}))}e.prototype.open=function(){var e=this;return this.modal.open().then((function(){return e.handleTemplateRequest()}))};e.prototype.getDefaultMessage=function(){return this.isRtl?this.defaultMessage.substring(0,this.defaultMessage.lastIndexOf(" ")):this.defaultMessage.split(" ").slice(0,-2).join(" ")};e.prototype.handleTemplateRequest=function(){var e=this;if(Object.keys(this.templateData).length){return}this.modal.loading();return salla.api.request("/store/template",{},"get",{"Store-Identifier":this.storeId}).then((function(t){e.modal.setTitle(e.templateInformation);e.templateData=t.data;e.modal.stopLoading()})).catch((function(){e.modal.close()}))};e.prototype.handleAction=function(){if(this.type==="link"){window.location.href=this.actionUrl}if(this.type==="popup"){this.open()}};e.prototype.popup=function(){var e=this;var t,i,a,r,o,s,l,c,u,d,p,f,h,g,m,v,_;return n("salla-modal",{class:"s-bottom-alert-modal",ref:function(t){return e.modal=t},"no-padding":true},Object.keys(this.templateData).length?[n("div",{class:"s-bottom-alert-modal-inner s-scrollbar"},Array.isArray((t=this.templateData)===null||t===void 0?void 0:t.screenshots)&&((a=(i=this.templateData)===null||i===void 0?void 0:i.screenshots)===null||a===void 0?void 0:a.length)?n("div",{class:"s-bottom-alert-modal-cover"},n("img",{src:(r=this.templateData)===null||r===void 0?void 0:r.screenshots[0],alt:""})):"",n("div",{class:{"s-bottom-alert-modal-content":true,"s-bottom-alert-modal-content-extra-padding":this.templateData.price}},((o=this.templateData)===null||o===void 0?void 0:o.description)?[n("div",{class:"s-bottom-alert-modal-content-title"},this.storeDetails),n("div",{class:"s-bottom-alert-modal-content-description",innerHTML:(s=this.templateData)===null||s===void 0?void 0:s.description}),n("hr",null)]:"",((l=this.templateData)===null||l===void 0?void 0:l.features)?[n("div",{class:"s-bottom-alert-modal-content-title"},this.storeFeatures),n("div",{class:"s-bottom-alert-modal-content-features",innerHTML:(c=this.templateData)===null||c===void 0?void 0:c.features})]:"",Array.isArray((u=this.templateData)===null||u===void 0?void 0:u.screenshots)&&((p=(d=this.templateData)===null||d===void 0?void 0:d.screenshots)===null||p===void 0?void 0:p.length)>1?n("salla-slider",{id:"template-screenshots",type:"carousel",class:"s-bottom-alert-modal-content-screenshots"},n("div",{slot:"items"},(f=this.templateData)===null||f===void 0?void 0:f.screenshots.map((function(e){return n("div",{class:"s-bottom-alert-modal-content-screenshot"},n("img",{src:e,alt:""}))})))):"",((h=this.templateData)===null||h===void 0?void 0:h.extra_info)?n("div",{class:"s-bottom-alert-modal-content-description",innerHTML:(g=this.templateData)===null||g===void 0?void 0:g.description}):""),((m=this.templateData)===null||m===void 0?void 0:m.link)?n("div",{class:"s-bottom-alert-modal-content-footer"},this.templateData.price&&n("div",{class:"s-bottom-alert-modal-price-wrapper"},n("div",null,this.storePrice),n("div",{class:"s-bottom-alert-modal-price-wrapper-amount"},salla.money((v=this.templateData)===null||v===void 0?void 0:v.price))),n("salla-button",{color:"primary",size:"medium",width:"wide",href:(_=this.templateData)===null||_===void 0?void 0:_.link},n("i",{innerHTML:T}),this.buyTheTemplate)):"")]:"")};e.prototype.render=function(){var e=this;var t=this.template&&typeof this.template==="object"&&Object.keys(this.template).length>0;var i=t&&this.template.developer;var r=i!==undefined;var o=r&&(i===null||i===void 0?void 0:i.name);var s=null;return n(a,{class:"s-bottom-alert-wrapper"},n("div",{class:"s-bottom-alert-content"},n("div",{class:"s-bottom-alert-icon"},this.icon?n("i",{class:this.icon}):n("i",{innerHTML:I})),n("div",{class:"s-bottom-alert-message"},this.message?this.message:t?n("span",null,this.getDefaultMessage()," ",n("a",{href:"#",class:{"s-bottom-alert-message-highlight":true,"s-bottom-alert-message-link":s},target:"","aria-label":"Developer"},o?o:this.theDeveloper)," ",n("span",{class:"s-bottom-alert-message-splitter"},"|")," ",this.storePrice,":"," ",n("span",{class:"s-bottom-alert-message-highlight"},salla.money(this.template.price))):this.defaultMessage),this.type!=="banner"&&n("div",{class:"s-bottom-alert-action"},n("salla-button",{href:this.actionUrl,size:"medium",onClick:function(){return e.handleAction()},width:"normal"},this.actionLabel||this.defaultActionLabel)),this.type==="popup"&&this.popup()))};Object.defineProperty(e.prototype,"host",{get:function(){return r(this)},enumerable:false,configurable:true});return e}());S.style=A;var C='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>keyboard_arrow_left</title>\n<path d="M20.563 22.104l-1.875 1.875-8-8 8-8 1.875 1.875-6.125 6.125z"></path>\n</svg>\n';var M='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>keyboard_arrow_right</title>\n<path d="M11.438 22.479l6.125-6.125-6.125-6.125 1.875-1.875 8 8-8 8z"></path>\n</svg>\n';var D=":host{display:block}";var L=e("salla_breadcrumb",function(){function e(e){t(this,e);var i,n;this.sessionStorageKey="breadcrumb_snapshot";this.breadcrumbs=undefined;this.itemSlot=((i=this.host.querySelector('[slot="item"]'))===null||i===void 0?void 0:i.outerHTML)||'<li class="s-breadcrumb-item"><a href={url}>{title}</a></li>';this.iconSlot=(n=this.host.querySelector('[slot="icon"]'))===null||n===void 0?void 0:n.outerHTML}e.prototype.componentWillLoad=function(){var e=this;return new Promise((function(e){return salla.onReady((function(){return salla.lang.onLoaded(e)}))})).then((function(){if(salla.url.is_page("index")){throw new Error("salla-breadcrumb:: breadcrumb not supported on home page")}})).then((function(){if(!salla.config.get("theme.settings.is_breadcrumbs_enabled",true)){throw new Error("salla-breadcrumb:: merchant disabled the feature")}})).then((function(){var t;var i=salla.config.get("page");if(!i||!i.slug){salla.logger.error('salla-breadcrumbs:: page object not existed on salla.config.get("page")!');e.breadcrumbs=[];return}var n=e.getSessionBreadcrumbs();if(i.slug==="product.single"&&n&&n.length>0){n.push({title:i.title,url:i.url});e.breadcrumbs=e.setBreadcrumbsFromArray(n);e.storeBreadcrumbSnapshot()}else if(n&&n.length>0){if(e.isNewPage(i,n)){e.breadcrumbs=e.generateBreadcrumbs(i);e.storeBreadcrumbSnapshot()}else{e.breadcrumbs=e.setBreadcrumbsFromArray(n)}}else{e.breadcrumbs=e.generateBreadcrumbs(i);e.storeBreadcrumbSnapshot()}if((t=e.breadcrumbs)===null||t===void 0?void 0:t.length){e.breadcrumbs[e.breadcrumbs.length-1].is_last=true}return e.breadcrumbs})).catch((function(t){salla.logger.error("salla-breadcrumb:: unexpected error!",t);e.breadcrumbs=[]}))};e.prototype.getSessionBreadcrumbs=function(){if(new URLSearchParams(window.location.search).get("from")==="search-bar"){return[]}return JSON.parse(sessionStorage.getItem(this.sessionStorageKey)||"[]")};e.prototype.isNewPage=function(e,t){var i=t[t.length-1];return(i===null||i===void 0?void 0:i.url)!==e.url};e.prototype.setBreadcrumbsFromArray=function(e){return e.map((function(t,i){return Object.assign(Object.assign({},t),{is_last:i===e.length-1})}))};e.prototype.sanitizeBreadcrumbTitle=function(e,t){if(t===void 0){t=1}if(!e.includes("|")){return e.trim()}return e.split("|").map((function(e){return e.trim()}))[t]};e.prototype.generateBreadcrumbs=function(e){var t,i;var n=[];if(e.slug==="product.single"){var a=this.getSessionBreadcrumbs();if(a.length>0&&((t=a[1])===null||t===void 0?void 0:t.url)===((i=e.parent)===null||i===void 0?void 0:i.url)){return this.setBreadcrumbsFromArray(__spreadArray(__spreadArray([],a,true),[e],false))}}var r=e;while(r){if(r.title){n.unshift({title:r.title,url:r.url})}r=r.parent}if(e.slug.includes("customer")&&e.slug!=="customer.profile"){n.unshift({title:salla.lang.get("common.titles.profile"),url:salla.url.get("profile")})}if(e.slug.includes("blog")){n.unshift({title:salla.lang.get("blocks.footer.blog"),url:salla.url.get("blog")})}if(e.slug==="brands.single"){n.unshift({title:salla.lang.get("common.titles.brands"),url:salla.url.get("brands")})}if(!e.title&&e.slug==="loyalty"){n.unshift({title:salla.lang.get("common.titles.loyalty_program"),url:salla.url.get("loyalty")})}n.unshift({title:salla.lang.get("common.titles.home"),url:salla.url.get("")});return n};e.prototype.storeBreadcrumbSnapshot=function(){try{var e=salla.config.get("page");if((e===null||e===void 0?void 0:e.slug)==="product.single"){return}var t=__spreadArray([],this.breadcrumbs,true);var i=t.length-1;if(i>=0){t[i].url=window.location.href}var n=JSON.stringify(t);sessionStorage.setItem(this.sessionStorageKey,n)}catch(e){salla.logger.error("salla-breadcrumb:: Failed to store breadcrumb snapshot in sessionStorage.",e)}};e.prototype.render=function(){var e=this;if(this.breadcrumbs.length<=1){salla.log("salla-breadcrumb:: There is no breadcrumbs!");return null}return n("ol",{class:{"s-breadcrumb-wrapper":true,"s-breadcrumb-dark":salla.url.is_page("loyalty"),"s-breadcrumb-primary-reverse":salla.config.get("page.slug").includes("customer")}},this.breadcrumbs.map((function(t){var i=salla.config.get("page.slug")==="product.single";var a=i&&t.is_last?t.title:e.sanitizeBreadcrumbTitle(t.title);var r=e.itemSlot.replace(/\{url\}/g,t.url).replace(/\{title\}/g,a);return[n("div",{class:"s-breadcrumb-slot",innerHTML:r}),e.getArrowDomForItem(t)]})))};e.prototype.getArrowDomForItem=function(e){if(e.is_last){return""}var t=this.iconSlot||(salla.config.get("theme.is_rtl",true)?C:M);return n("li",{class:"s-breadcrumb-arrow"},n("div",{class:{"s-breadcrumb-icon-slot":true,"s-breadcrumb-default-icon":!this.iconSlot},innerHTML:t}))};e.prototype.componentDidRender=function(){var e,t,i;this.host.querySelectorAll(".s-breadcrumb-slot").forEach((function(e){return e.replaceWith(e.firstChild)}));this.host.querySelectorAll(".s-breadcrumb-icon-slot.s-breadcrumb-default-icon").forEach((function(e){return e.replaceWith(e.querySelector("svg"))}));(e=this.host.querySelector('[slot="item"]'))===null||e===void 0?void 0:e.remove();(t=this.host.querySelector('[slot="icon"]'))===null||t===void 0?void 0:t.remove();var n=(i=this.host.querySelectorAll(".s-breadcrumb-item")[this.breadcrumbs.length-1])===null||i===void 0?void 0:i.querySelector("a");n&&n.replaceWith(n.firstChild)};Object.defineProperty(e.prototype,"host",{get:function(){return r(this)},enumerable:false,configurable:true});return e}());L.style=D;var O="";var P=e("salla_button",function(){function e(e){t(this,e);this.hostAttributes={};this.shape="btn";this.color="primary";this.fill="solid";this.size="medium";this.width="normal";this.loading=false;this.disabled=false;this.loaderPosition="after";this.href=undefined;this.type="button"}e.prototype.load=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){if(this.loaderPosition=="center")this.text.classList.add("s-button-hide");this.host.setAttribute("loading","");return[2,this.host]}))}))};e.prototype.stop=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.host.removeAttribute("loading");this.host.querySelector("button").removeAttribute("loading");if(this.loaderPosition=="center")this.text.classList.remove("s-button-hide");return[2,this.host]}))}))};e.prototype.setText=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.text.innerHTML=e;return[2,this.host]}))}))};e.prototype.disable=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.host.setAttribute("disabled","");return[2,this.host]}))}))};e.prototype.enable=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.host.removeAttribute("disabled");return[2,this.host]}))}))};e.prototype.getBtnAttributes=function(){for(var e=0;e<this.host.attributes.length;e++){if(!["color","fill","size","width","id"].includes(this.host.attributes[e].name)){this.hostAttributes[this.host.attributes[e].name]=this.host.attributes[e].value}}this.hostAttributes.type=this.hostAttributes.type||this.type;this.hostAttributes.class+=" s-button-element s-button-"+this.shape+" s-button-"+(this.fill=="none"?"fill-none":this.fill)+(this.size!="medium"?" s-button-"+this.size:"")+(this.width!="normal"?" s-button-"+this.width:"")+(this.shape=="link"?" s-button-"+this.color+"-link":"")+(this.shape!="link"&&this.fill!="outline"?" s-button-"+this.color:"")+(this.fill=="outline"?" s-button-"+this.color+"-outline":"")+(this.disabled?" s-button-disabled ":"")+(this.shape=="icon"?" s-button-loader-center":" s-button-loader-"+this.loaderPosition);return this.hostAttributes};e.prototype.button=function(){var e=this;return n("button",Object.assign({},this.getBtnAttributes(),{disabled:this.disabled}),n("span",{class:"s-button-text",ref:function(t){return e.text=t}},n("slot",null)),this.loading?n("span",{class:"s-button-loader"}):"")};e.prototype.render=function(){var e;return((e=this.host.closest(".swiper-slide"))===null||e===void 0?void 0:e.classList.contains("swiper-slide-duplicate"))?"":n(a,{class:"s-button-wrap"},this.href?n("a",{href:this.href},this.button()):this.button())};Object.defineProperty(e.prototype,"host",{get:function(){return r(this)},enumerable:false,configurable:true});return e}());P.style=O;var R="";var N=e("salla_cart_summary",function(){function e(e){var i=this;t(this,e);this.cartSummaryCount=salla.storage.get("cart.summary.count")||0;this.cartSummaryTotal=salla.storage.get("cart.summary.total")||0;this.cartLabel=salla.config.get("user.language_code")==="ar"?"السلة":"Cart";this.showCartLabel=undefined;salla.cart.event.onUpdated((function(e){i.cartSummaryCount=e.count||0;i.cartSummaryTotal=e.total||0}))}e.prototype.animateToCart=function(e){return __awaiter(this,void 0,void 0,(function(){var t,i,n,a,r,o,l,c,u,d,p,f;return __generator(this,(function(h){document.querySelectorAll(".s-cart-thumb").forEach((function(e){return e.remove()}));if(!(e===null||e===void 0?void 0:e.src)){salla.log("Failed to get the img element");return[2]}t=this.host.querySelector("#s-cart-icon"),i=t.getBoundingClientRect(),n=i.top+window.scrollY,a=i.left+window.scrollX;r=e.getBoundingClientRect(),o=e.offsetWidth+"px",l=e.offsetHeight+"px",c=r.top,u=r.left;d=document.createElement("img");d.src=e.getAttribute("src");d.className="s-cart-thumb";d.setAttribute("style","object-fit:cover; width:"+o+"; height:"+l+"; top:"+c+"px; left:"+u+"px;z-index:99999999; ");document.body.append(d);p=document.querySelector(".s-cart-thumb");t.classList.remove("animated","rubberBand");f=new s.timeline;f.add({targets:p,width:[150,30],height:[150,30],top:[c,window.scrollY>0?n-window.scrollY-40:n-40],left:[u,a],borderRadius:["20%","50%"],easing:"easeOutExpo",duration:1200},"+=200").add({targets:p,width:[30,0],height:[30,0],opacity:[1,0],easing:"easeOutExpo",top:[window.scrollY>0?n-window.scrollY-40:n-40,window.scrollY>0?n-window.scrollY+10:n+10],left:[a,a+10]},"-=500").add({complete:function(){t.classList.add("animated","rubberBand");p.remove()}},"-=1700");return[2]}))}))};e.prototype.componentWillLoad=function(){return new Promise((function(e){return salla.onReady(e)}))};e.prototype.render=function(){return n(a,null,n("a",{class:"s-cart-summary-wrapper",href:salla.url.get("cart")},n("div",{id:"s-cart-icon"},n("slot",{name:"icon"},n("i",{class:"s-cart-summary-icon",innerHTML:w}))),n("span",{class:"s-cart-summary-count"},salla.helpers.number(this.cartSummaryCount)),n("p",{class:"s-cart-summary-content"},this.showCartLabel&&n("span",{class:"s-cart-summary-label"},this.cartLabel),n("b",{class:"s-cart-summary-total",innerHTML:salla.money(this.cartSummaryTotal)}))))};Object.defineProperty(e.prototype,"host",{get:function(){return r(this)},enumerable:false,configurable:true});return e}());N.style=R;
/*!
* vanilla-picker v2.12.1
* https://vanilla-picker.js.org
*
* Copyright 2017-2021 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate)
* Released under the ISC license.
*/var F=function(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}};var z=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}return function(t,i,n){if(i)e(t.prototype,i);if(n)e(t,n);return t}}();var G=function(){function e(e,t){var i=[];var n=true;var a=false;var r=undefined;try{for(var o=e[Symbol.iterator](),s;!(n=(s=o.next()).done);n=true){i.push(s.value);if(t&&i.length===t)break}}catch(e){a=true;r=e}finally{try{if(!n&&o["return"])o["return"]()}finally{if(a)throw r}}return i}return function(t,i){if(Array.isArray(t)){return t}else if(Symbol.iterator in Object(t)){return e(t,i)}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}}}();String.prototype.startsWith=String.prototype.startsWith||function(e){return this.indexOf(e)===0};String.prototype.padStart=String.prototype.padStart||function(e,t){var i=this;while(i.length<e){i=t+i}return i};var B={cb:"0f8ff",tqw:"aebd7",q:"-ffff",qmrn:"7fffd4",zr:"0ffff",bg:"5f5dc",bsq:"e4c4",bck:"---",nch:"ebcd",b:"--ff",bvt:"8a2be2",brwn:"a52a2a",brw:"deb887",ctb:"5f9ea0",hrt:"7fff-",chcT:"d2691e",cr:"7f50",rnw:"6495ed",crns:"8dc",crms:"dc143c",cn:"-ffff",Db:"--8b",Dcn:"-8b8b",Dgnr:"b8860b",Dgr:"a9a9a9",Dgrn:"-64-",Dkhk:"bdb76b",Dmgn:"8b-8b",Dvgr:"556b2f",Drng:"8c-",Drch:"9932cc",Dr:"8b--",Dsmn:"e9967a",Dsgr:"8fbc8f",DsTb:"483d8b",DsTg:"2f4f4f",Dtrq:"-ced1",Dvt:"94-d3",ppnk:"1493",pskb:"-bfff",mgr:"696969",grb:"1e90ff",rbrc:"b22222",rwht:"af0",stg:"228b22",chs:"-ff",gnsb:"dcdcdc",st:"8f8ff",g:"d7-",gnr:"daa520",gr:"808080",grn:"-8-0",grnw:"adff2f",hnw:"0fff0",htpn:"69b4",nnr:"cd5c5c",ng:"4b-82",vr:"0",khk:"0e68c",vnr:"e6e6fa",nrb:"0f5",wngr:"7cfc-",mnch:"acd",Lb:"add8e6",Lcr:"08080",Lcn:"e0ffff",Lgnr:"afad2",Lgr:"d3d3d3",Lgrn:"90ee90",Lpnk:"b6c1",Lsmn:"a07a",Lsgr:"20b2aa",Lskb:"87cefa",LsTg:"778899",Lstb:"b0c4de",Lw:"e0",m:"-ff-",mgrn:"32cd32",nn:"af0e6",mgnt:"-ff",mrn:"8--0",mqm:"66cdaa",mmb:"--cd",mmrc:"ba55d3",mmpr:"9370db",msg:"3cb371",mmsT:"7b68ee","":"-fa9a",mtr:"48d1cc",mmvt:"c71585",mnLb:"191970",ntc:"5fffa",mstr:"e4e1",mccs:"e4b5",vjw:"dead",nv:"--80",c:"df5e6",v:"808-0",vrb:"6b8e23",rng:"a5-",rngr:"45-",rch:"da70d6",pgnr:"eee8aa",pgrn:"98fb98",ptrq:"afeeee",pvtr:"db7093",ppwh:"efd5",pchp:"dab9",pr:"cd853f",pnk:"c0cb",pm:"dda0dd",pwrb:"b0e0e6",prp:"8-080",cc:"663399",r:"--",sbr:"bc8f8f",rb:"4169e1",sbrw:"8b4513",smn:"a8072",nbr:"4a460",sgrn:"2e8b57",ssh:"5ee",snn:"a0522d",svr:"c0c0c0",skb:"87ceeb",sTb:"6a5acd",sTgr:"708090",snw:"afa",n:"-ff7f",stb:"4682b4",tn:"d2b48c",t:"-8080",thst:"d8bfd8",tmT:"6347",trqs:"40e0d0",vt:"ee82ee",whT:"5deb3",wht:"",hts:"5f5f5",w:"-",wgrn:"9acd32"};function q(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var i=t>0?e.toFixed(t).replace(/0+$/,"").replace(/\.$/,""):e.toString();return i||"0"}var U=function(){function e(t,i,n,a){F(this,e);var r=this;function o(t){if(t.startsWith("hsl")){var i=t.match(/([\-\d\.e]+)/g).map(Number),n=G(i,4),a=n[0],o=n[1],s=n[2],l=n[3];if(l===undefined){l=1}a/=360;o/=100;s/=100;r.hsla=[a,o,s,l]}else if(t.startsWith("rgb")){var c=t.match(/([\-\d\.e]+)/g).map(Number),u=G(c,4),d=u[0],p=u[1],f=u[2],h=u[3];if(h===undefined){h=1}r.rgba=[d,p,f,h]}else{if(t.startsWith("#")){r.rgba=e.hexToRgb(t)}else{r.rgba=e.nameToRgb(t)||e.hexToRgb(t)}}}if(t===undefined);else if(Array.isArray(t)){this.rgba=t}else if(n===undefined){var s=t&&""+t;if(s){o(s.toLowerCase())}}else{this.rgba=[t,i,n,a===undefined?1:a]}}z(e,[{key:"printRGB",value:function e(t){var i=t?this.rgba:this.rgba.slice(0,3),n=i.map((function(e,t){return q(e,t===3?3:0)}));return t?"rgba("+n+")":"rgb("+n+")"}},{key:"printHSL",value:function e(t){var i=[360,100,100,1],n=["","%","%",""];var a=t?this.hsla:this.hsla.slice(0,3),r=a.map((function(e,t){return q(e*i[t],t===3?3:1)+n[t]}));return t?"hsla("+r+")":"hsl("+r+")"}},{key:"printHex",value:function e(t){var i=this.hex;return t?i:i.substring(0,7)}},{key:"rgba",get:function t(){if(this._rgba){return this._rgba}if(!this._hsla){throw new Error("No color is set")}return this._rgba=e.hslToRgb(this._hsla)},set:function e(t){if(t.length===3){t[3]=1}this._rgba=t;this._hsla=null}},{key:"rgbString",get:function e(){return this.printRGB()}},{key:"rgbaString",get:function e(){return this.printRGB(true)}},{key:"hsla",get:function t(){if(this._hsla){return this._hsla}if(!this._rgba){throw new Error("No color is set")}return this._hsla=e.rgbToHsl(this._rgba)},set:function e(t){if(t.length===3){t[3]=1}this._hsla=t;this._rgba=null}},{key:"hslString",get:function e(){return this.printHSL()}},{key:"hslaString",get:function e(){return this.printHSL(true)}},{key:"hex",get:function e(){var t=this.rgba,i=t.map((function(e,t){return t<3?e.toString(16):Math.round(e*255).toString(16)}));return"#"+i.map((function(e){return e.padStart(2,"0")})).join("")},set:function t(i){this.rgba=e.hexToRgb(i)}}],[{key:"hexToRgb",value:function e(t){var i=(t.startsWith("#")?t.slice(1):t).replace(/^(\w{3})$/,"$1F").replace(/^(\w)(\w)(\w)(\w)$/,"$1$1$2$2$3$3$4$4").replace(/^(\w{6})$/,"$1FF");if(!i.match(/^([0-9a-fA-F]{8})$/)){throw new Error("Unknown hex color; "+t)}var n=i.match(/^(\w\w)(\w\w)(\w\w)(\w\w)$/).slice(1).map((function(e){return parseInt(e,16)}));n[3]=n[3]/255;return n}},{key:"nameToRgb",value:function t(i){var n=i.toLowerCase().replace("at","T").replace(/[aeiouyldf]/g,"").replace("ght","L").replace("rk","D").slice(-5,4),a=B[n];return a===undefined?a:e.hexToRgb(a.replace(/\-/g,"00").padStart(6,"f"))}},{key:"rgbToHsl",value:function e(t){var i=G(t,4),n=i[0],a=i[1],r=i[2],o=i[3];n/=255;a/=255;r/=255;var s=Math.max(n,a,r),l=Math.min(n,a,r);var c=void 0,u=void 0,d=(s+l)/2;if(s===l){c=u=0}else{var p=s-l;u=d>.5?p/(2-s-l):p/(s+l);switch(s){case n:c=(a-r)/p+(a<r?6:0);break;case a:c=(r-n)/p+2;break;case r:c=(n-a)/p+4;break}c/=6}return[c,u,d,o]}},{key:"hslToRgb",value:function e(t){var i=G(t,4),n=i[0],a=i[1],r=i[2],o=i[3];var s=void 0,l=void 0,c=void 0;if(a===0){s=l=c=r}else{var u=function e(t,i,n){if(n<0)n+=1;if(n>1)n-=1;if(n<1/6)return t+(i-t)*6*n;if(n<1/2)return i;if(n<2/3)return t+(i-t)*(2/3-n)*6;return t};var d=r<.5?r*(1+a):r+a-r*a,p=2*r-d;s=u(p,d,n+1/3);l=u(p,d,n);c=u(p,d,n-1/3)}var f=[s*255,l*255,c*255].map(Math.round);f[3]=o;return f}}]);return e}();var H=function(){function e(){F(this,e);this._events=[]}z(e,[{key:"add",value:function e(t,i,n){t.addEventListener(i,n,false);this._events.push({target:t,type:i,handler:n})}},{key:"remove",value:function t(i,n,a){this._events=this._events.filter((function(t){var r=true;if(i&&i!==t.target){r=false}if(n&&n!==t.type){r=false}if(a&&a!==t.handler){r=false}if(r){e._doRemove(t.target,t.type,t.handler)}return!r}))}},{key:"destroy",value:function t(){this._events.forEach((function(t){return e._doRemove(t.target,t.type,t.handler)}));this._events=[]}}],[{key:"_doRemove",value:function e(t,i,n){t.removeEventListener(i,n,false)}}]);return e}();function j(e){var t=document.createElement("div");t.innerHTML=e;return t.firstElementChild}function V(e,t,i){var n=false;function a(e,t,i){return Math.max(t,Math.min(e,i))}function r(e,r,o){if(o){n=true}if(!n){return}e.preventDefault();var s=t.getBoundingClientRect(),l=s.width,c=s.height,u=r.clientX,d=r.clientY;var p=a(u-s.left,0,l),f=a(d-s.top,0,c);i(p/l,f/c)}function o(e,t){var i=e.buttons===undefined?e.which:e.buttons;if(i===1){r(e,e,t)}else{n=false}}function s(e,t){if(e.touches.length===1){r(e,e.touches[0],t)}else{n=false}}e.add(t,"mousedown",(function(e){o(e,true)}));e.add(t,"touchstart",(function(e){s(e,true)}));e.add(window,"mousemove",o);e.add(t,"touchmove",s);e.add(window,"mouseup",(function(e){n=false}));e.add(t,"touchend",(function(e){n=false}));e.add(t,"touchcancel",(function(e){n=false}))}var W="linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0 / 2em 2em,\n linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em / 2em 2em";var Y=360;var X="keydown",K="mousedown",Z="focusin";function Q(e,t){return(t||document).querySelector(e)}function J(e){e.preventDefault();e.stopPropagation()}function ee(e,t,i,n,a){e.add(t,X,(function(e){if(i.indexOf(e.key)>=0){if(a){J(e)}n(e)}}))}var te=function(){function e(t){F(this,e);this.settings={popup:"right",layout:"default",alpha:true,editor:true,editorFormat:"hex",cancelButton:false,defaultColor:"#0cf"};this._events=new H;this.onChange=null;this.onDone=null;this.onOpen=null;this.onClose=null;this.setOptions(t)}z(e,[{key:"setOptions",value:function e(t){var i=this;if(!t){return}var n=this.settings;function a(e,t,i){for(var n in e){if(i&&i.indexOf(n)>=0){continue}t[n]=e[n]}}if(t instanceof HTMLElement){n.parent=t}else{if(n.parent&&t.parent&&n.parent!==t.parent){this._events.remove(n.parent);this._popupInited=false}a(t,n);if(t.onChange){this.onChange=t.onChange}if(t.onDone){this.onDone=t.onDone}if(t.onOpen){this.onOpen=t.onOpen}if(t.onClose){this.onClose=t.onClose}var r=t.color||t.colour;if(r){this._setColor(r)}}var o=n.parent;if(o&&n.popup&&!this._popupInited){var s=function e(t){return i.openHandler(t)};this._events.add(o,"click",s);ee(this._events,o,[" ","Spacebar","Enter"],s);this._popupInited=true}else if(t.parent&&!n.popup){this.show()}}},{key:"openHandler",value:function e(t){if(this.show()){t&&t.preventDefault();this.settings.parent.style.pointerEvents="none";var i=t&&t.type===X?this._domEdit:this.domElement;setTimeout((function(){return i.focus()}),100);if(this.onOpen){this.onOpen(this.colour)}}}},{key:"closeHandler",value:function e(t){var i=t&&t.type;var n=false;if(!t){n=true}else if(i===K||i===Z){var a=(this.__containedEvent||0)+100;if(t.timeStamp>a){n=true}}else{J(t);n=true}if(n&&this.hide()){this.settings.parent.style.pointerEvents="";if(i!==K){this.settings.parent.focus()}if(this.onClose){this.onClose(this.colour)}}}},{key:"movePopup",value:function e(t,i){this.closeHandler();this.setOptions(t);if(i){this.openHandler()}}},{key:"setColor",value:function e(t,i){this._setColor(t,{silent:i})}},{key:"_setColor",value:function e(t,i){if(typeof t==="string"){t=t.trim()}if(!t){return}i=i||{};var n=void 0;try{n=new U(t)}catch(e){if(i.failSilently){return}throw e}if(!this.settings.alpha){var a=n.hsla;a[3]=1;n.hsla=a}this.colour=this.color=n;this._setHSLA(null,null,null,null,i)}},{key:"setColour",value:function e(t,i){this.setColor(t,i)}},{key:"show",value:function e(){var t=this.settings.parent;if(!t){return false}if(this.domElement){var i=this._toggleDOM(true);this._setPosition();return i}var n=this.settings.template||'<div class="picker_wrapper" tabindex="-1"><div class="picker_arrow"></div><div class="picker_hue picker_slider"><div class="picker_selector"></div></div><div class="picker_sl"><div class="picker_selector"></div></div><div class="picker_alpha picker_slider"><div class="picker_selector"></div></div><div class="picker_editor"><input aria-label="Type a color name or hex value"/></div><div class="picker_sample"></div><div class="picker_done"><button>Ok</button></div><div class="picker_cancel"><button>Cancel</button></div></div>';var a=j(n);this.domElement=a;this._domH=Q(".picker_hue",a);this._domSL=Q(".picker_sl",a);this._domA=Q(".picker_alpha",a);this._domEdit=Q(".picker_editor input",a);this._domSample=Q(".picker_sample",a);this._domOkay=Q(".picker_done button",a);this._domCancel=Q(".picker_cancel button",a);a.classList.add("layout_"+this.settings.layout);if(!this.settings.alpha){a.classList.add("no_alpha")}if(!this.settings.editor){a.classList.add("no_editor")}if(!this.settings.cancelButton){a.classList.add("no_cancel")}this._ifPopup((function(){return a.classList.add("popup")}));this._setPosition();if(this.colour){this._updateUI()}else{this._setColor(this.settings.defaultColor)}this._bindEvents();return true}},{key:"hide",value:function e(){return this._toggleDOM(false)}},{key:"destroy",value:function e(){this._events.destroy();if(this.domElement){this.settings.parent.removeChild(this.domElement)}}},{key:"_bindEvents",value:function e(){var t=this;var i=this,n=this.domElement,a=this._events;function r(e,t,i){a.add(e,t,i)}r(n,"click",(function(e){return e.preventDefault()}));V(a,this._domH,(function(e,t){return i._setHSLA(e)}));V(a,this._domSL,(function(e,t){return i._setHSLA(null,e,1-t)}));if(this.settings.alpha){V(a,this._domA,(function(e,t){return i._setHSLA(null,null,null,1-t)}))}var o=this._domEdit;{r(o,"input",(function(e){i._setColor(this.value,{fromEditor:true,failSilently:true})}));r(o,"focus",(function(e){var t=this;if(t.selectionStart===t.selectionEnd){t.select()}}))}this._ifPopup((function(){var e=function e(i){return t.closeHandler(i)};r(window,K,e);r(window,Z,e);ee(a,n,["Esc","Escape"],e);var i=function e(i){t.__containedEvent=i.timeStamp};r(n,K,i);r(n,Z,i);r(t._domCancel,"click",e)}));var s=function e(i){t._ifPopup((function(){return t.closeHandler(i)}));if(t.onDone){t.onDone(t.colour)}};r(this._domOkay,"click",s);ee(a,n,["Enter"],s)}},{key:"_setPosition",value:function e(){var t=this.settings.parent,i=this.domElement;if(t!==i.parentNode){t.appendChild(i)}this._ifPopup((function(e){if(getComputedStyle(t).position==="static"){t.style.position="relative"}var n=e===true?"popup_right":"popup_"+e;["popup_top","popup_bottom","popup_left","popup_right"].forEach((function(e){if(e===n){i.classList.add(e)}else{i.classList.remove(e)}}));i.classList.add(n)}))}},{key:"_setHSLA",value:function e(t,i,n,a,r){r=r||{};var o=this.colour,s=o.hsla;[t,i,n,a].forEach((function(e,t){if(e||e===0){s[t]=e}}));o.hsla=s;this._updateUI(r);if(this.onChange&&!r.silent){this.onChange(o)}}},{key:"_updateUI",value:function e(t){if(!this.domElement){return}t=t||{};var i=this.colour,n=i.hsla,a="hsl("+n[0]*Y+", 100%, 50%)",r=i.hslString,o=i.hslaString;var s=this._domH,l=this._domSL,c=this._domA,u=Q(".picker_selector",s),d=Q(".picker_selector",l),p=Q(".picker_selector",c);function f(e,t,i){t.style.left=i*100+"%"}function h(e,t,i){t.style.top=i*100+"%"}f(s,u,n[0]);this._domSL.style.backgroundColor=this._domH.style.color=a;f(l,d,n[1]);h(l,d,1-n[2]);l.style.color=r;h(c,p,1-n[3]);var g=r,m=g.replace("hsl","hsla").replace(")",", 0)"),v="linear-gradient("+[g,m]+")";this._domA.style.background=v+", "+W;if(!t.fromEditor){var _=this.settings.editorFormat,b=this.settings.alpha;var y=void 0;switch(_){case"rgb":y=i.printRGB(b);break;case"hsl":y=i.printHSL(b);break;default:y=i.printHex(b)}this._domEdit.value=y}this._domSample.style.color=o}},{key:"_ifPopup",value:function e(t,i){if(this.settings.parent&&this.settings.popup){t&&t(this.settings.popup)}else{i&&i()}}},{key:"_toggleDOM",value:function e(t){var i=this.domElement;if(!i){return false}var n=t?"":"none",a=i.style.display!==n;if(a){i.style.display=n}return a}}]);return e}();{var ie=document.createElement("style");ie.textContent='.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_wrapper.no_editor .picker_editor{position:absolute;z-index:-1;opacity:0}.picker_wrapper.no_cancel .picker_cancel{display:none}.layout_default.picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em}.layout_default.picker_wrapper input,.layout_default.picker_wrapper button{font-size:1rem}.layout_default.picker_wrapper>*{margin:.5em}.layout_default.picker_wrapper::before{content:"";display:block;width:100%;height:0;order:1}.layout_default .picker_slider,.layout_default .picker_selector{padding:1em}.layout_default .picker_hue{width:100%}.layout_default .picker_sl{flex:1 1 auto}.layout_default .picker_sl::before{content:"";display:block;padding-bottom:100%}.layout_default .picker_editor{order:1;width:6.5rem}.layout_default .picker_editor input{width:100%;height:100%}.layout_default .picker_sample{order:1;flex:1 1 auto}.layout_default .picker_done,.layout_default .picker_cancel{order:1}.picker_wrapper{box-sizing:border-box;background:#f2f2f2;box-shadow:0 0 0 1px silver;cursor:default;font-family:sans-serif;color:#444;pointer-events:auto}.picker_wrapper:focus{outline:none}.picker_wrapper button,.picker_wrapper input{box-sizing:border-box;border:none;box-shadow:0 0 0 1px silver;outline:none}.picker_wrapper button:focus,.picker_wrapper button:active,.picker_wrapper input:focus,.picker_wrapper input:active{box-shadow:0 0 2px 1px #1e90ff}.picker_wrapper button{padding:.4em .6em;cursor:pointer;background-color:#f5f5f5;background-image:linear-gradient(0deg, gainsboro, transparent)}.picker_wrapper button:active{background-image:linear-gradient(0deg, transparent, gainsboro)}.picker_wrapper button:hover{backgroun