@salla.sa/twilight-components
Version:
Salla Web Component
11 lines • 780 kB
JavaScript
var __awaiter=this&&this.__awaiter||function(t,i,e,n){function a(t){return t instanceof e?t:new e((function(i){i(t)}))}return new(e||(e=Promise))((function(e,r){function o(t){try{l(n.next(t))}catch(t){r(t)}}function s(t){try{l(n["throw"](t))}catch(t){r(t)}}function l(t){t.done?e(t.value):a(t.value).then(o,s)}l((n=n.apply(t,i||[])).next())}))};var __generator=this&&this.__generator||function(t,i){var e={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(t){return function(i){return l([t,i])}}function l(s){if(n)throw new TypeError("Generator is already executing.");while(o&&(o=0,s[0]&&(e=0)),e)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:e.label++;return{value:s[1],done:false};case 5:e.label++;a=s[1];s=[0];continue;case 7:s=e.ops.pop();e.trys.pop();continue;default:if(!(r=e.trys,r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){e.label=s[1];break}if(s[0]===6&&e.label<r[1]){e.label=r[1];r=s;break}if(r&&e.label<r[2]){e.label=r[2];e.ops.push(s);break}if(r[2])e.ops.pop();e.trys.pop();continue}s=i.call(t,e)}catch(t){s=[6,t];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(t,i,e){if(e||arguments.length===2)for(var n=0,a=i.length,r;n<a;n++){if(r||!(n in i)){if(!r)r=Array.prototype.slice.call(i,0,n);r[n]=i[n]}}return t.concat(r||Array.prototype.slice.call(i))};var _0;
/*!
* Crafted with ❤ by Salla
*/import{r as registerInstance,c as createEvent,h,H as Host,g as getElement,f as getDefaultExportFromCjs,F as Fragment,i as axios}from"./index-DWStDVKB.js";import{a as anime}from"./anime.es-CgtvEd63.js";import{A as ArrowDownIcon,S as SpecialDiscountIcon}from"./special-discount-yRO-ZESF.js";import{I as IconVerified}from"./check-uTyAzPSy.js";import{H as Helper}from"./Helper-CzEjEM5j.js";import{a as arrowLeft}from"./arrow-left-BedNk7k1.js";import{S as ShoppingBag}from"./shopping-bag-DiKTtDW5.js";import{M as MailIcon}from"./mail-DmgxDvXL.js";import{w as whatsapp$1}from"./whatsapp2-DWksgowB.js";import{f as facebook,t as twitter}from"./twitter-Dz7o69vX.js";import{G as GiftIcon}from"./gift-C0JNGIpa.js";import{C as CameraIcon}from"./camera-C6jIkM-X.js";var PendingOrdersIcon='\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 WalletIcon$1='\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 sallaAddProductButtonCss=":host{display:block}salla-add-product-button[width=wide]{width:100%}";var SallaAddProductButton=function(){function t(t){var i=this;registerInstance(this,t);this.success=createEvent(this,"success");this.failed=createEvent(this,"failed");this.hostAttributes={};this.productStatus="sale";this.productType="product";this.selectedOptions=[];this.buyNowText=salla.lang.get("pages.products.buy_now");salla.lang.onLoaded((function(){i.buyNowText=salla.lang.get("pages.products.buy_now")}))}t.prototype.getLabel=function(){if(this.productStatus==="sale"&&this.supportStickyBar&&window.innerWidth<=768&&this.showQuickBuy&&this.isApplePayActive){return PendingOrdersIcon}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")};t.prototype.addProductToCart=function(t){var i=this;var e;if(this.productType==="booking"){t.preventDefault();return this.addBookingProduct()}if(this.hostAttributes.type==="submit"){return false}t.preventDefault();(e=this.btn)===null||e===void 0?void 0:e.disable();var n=Object.entries({id:this.productId,donation_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd"}).reduce((function(t,i){var e=i[0],n=i[1];return n?(t[e]=n,t):t}),{});return salla.cart.addItem(n).then((function(t){var e;i.selectedOptions=[];(e=i.btn)===null||e===void 0?void 0:e.enable();i.success.emit(t)})).catch((function(t){var e;i.failed.emit(t);(e=i.btn)===null||e===void 0?void 0:e.enable()}))};t.prototype.addBookingProduct=function(){var t=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(i){return t.success.emit(i)})).catch((function(i){return t.failed.emit(i)}))};t.prototype.getBtnAttributes=function(){for(var t=0;t<this.host.attributes.length;t++){if(!["id","class"].includes(this.host.attributes[t].name)){this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value}}return this.hostAttributes};t.prototype.getQuickBuyBtnAttributes=function(){return Object.assign(Object.assign({},this.getBtnAttributes()),{type:this.supportStickyBar&&window.innerWidth<=768?"plain":this.productType=="donating"?"donate":"buy"})};t.prototype.miniCheckoutWidget=function(){var t=salla.config.get("store.id");if(!t){return}return h("salla-mini-checkout-widget",{language:salla.lang.locale,"store-id":t,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"},h("div",{slot:"widget-label",class:"s-add-product-button-mini-checkout-content"},h("span",{innerHTML:WalletIcon$1}),this.buyNowText))};t.prototype.componentWillLoad=function(){var t=this;return salla.onReady().then((function(){var i,e,n;document.documentElement.classList.add("hydrated");t.showQuickBuy=t.quickBuy&&salla.config.get("store.settings.buy_now")&&t.productStatus=="sale"&&t.productType!=="booking";t.isApplePayActive=((i=window.ApplePaySession)===null||i===void 0?void 0:i.canMakePayments())&&((e=salla.config.get("store.settings.payments"))===null||e===void 0?void 0:e.includes("apple_pay"))&&salla.config.get("store.settings.is_salla_gateway",false);t.passedLabel=t.host.innerHTML.replace("\x3c!----\x3e","").trim();if(!!t.passedLabel&&window.innerWidth>=768){return(n=t.btn)===null||n===void 0?void 0:n.setText(t.passedLabel)}if(t.host.getAttribute("type")==="submit"&&t.supportStickyBar){window.addEventListener("resize",(function(){var i;return(i=t.btn)===null||i===void 0?void 0:i.setText(window.innerWidth>=768&&!!t.passedLabel?t.passedLabel:t.getLabel())}))}}))};t.prototype.render=function(){var t=this;var i;if((i=this.host.closest(".swiper-slide"))===null||i===void 0?void 0:i.classList.contains("swiper-slide-duplicate")){return""}if(this.hasSubscribedOptions){return h(Host,null,h("salla-product-availability",Object.assign({},this.getBtnAttributes(),{"is-subscribed":true}),h("span",{class:"s-hidden"},h("slot",null))))}if(this.productStatus==="out-and-notify"&&this.channels||this.hasOutOfStockOption){return h(Host,null,h("salla-product-availability",Object.assign({},this.getBtnAttributes()),h("span",{class:"s-hidden"},h("slot",null))))}return h(Host,{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}},h("div",{class:{"s-add-product-button-main":this.showQuickBuy,"w-full":!document.getElementById("fast-checkout-js")||["financial_support","donating"].includes(this.productType)}},h("salla-button",Object.assign({color:this.productStatus==="sale"?"primary":"light",type:"button",fill:this.productStatus==="sale"?"solid":"outline",ref:function(i){return t.btn=i},onClick:function(i){return t.addProductToCart(i)},disabled:this.productStatus!=="sale"},this.getBtnAttributes(),{"loader-position":"center"}),h("slot",null)),this.showQuickBuy&&!!document.getElementById("fast-checkout-js")&&!["financial_support","donating"].includes(this.productType)?this.miniCheckoutWidget():""),this.showQuickBuy&&this.isApplePayActive?h("salla-quick-buy",Object.assign({},this.getQuickBuyBtnAttributes())):"")};t.prototype.componentDidLoad=function(){var t=this;if(!this.notifyOptionsAvailability){return}salla.event.on("product-options::change",(function(i){return __awaiter(t,void 0,void 0,(function(){var t,e,n,a,r,o;var s=this;return __generator(this,(function(l){switch(l.label){case 0:if(!["thumbnail","color","single-option"].includes(i.option.type)){return[2]}this.hasSubscribedOptions=false;n=this;return[4,(t=document.querySelector('salla-product-options[product-id="'.concat(this.productId,'"]')))===null||t===void 0?void 0:t.getSelectedOptions()];case 1:n.selectedOptions=l.sent();a=this;return[4,(e=document.querySelector('salla-product-options[product-id="'.concat(this.productId,'"]')))===null||e===void 0?void 0:e.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(t){return t.split(",").map((function(t){return parseInt(t)}))})):[];this.hasSubscribedOptions=o.length>0&&o.some((function(t){return t.every((function(t){return s.selectedOptions.some((function(i){return i.id===t}))}))}))}else{this.hasSubscribedOptions=this.subscribedOptions&&this.subscribedOptions!=="null"&&this.subscribedOptions!=="[]"?JSON.parse(this.subscribedOptions).some((function(t){return t.every((function(t){return s.selectedOptions.some((function(i){return i.id===t}))}))})):false}return[2]}}))}))}))};t.prototype.componentDidRender=function(){var t=this;var i,e;if(!!this.passedLabel&&(!this.supportStickyBar||window.innerWidth>=768)){(i=this.btn)===null||i===void 0?void 0:i.setText(this.passedLabel);return}(e=this.btn)===null||e===void 0?void 0:e.setText(this.getLabel());salla.lang.onLoaded((function(){var i;return(i=t.btn)===null||i===void 0?void 0:i.setText(t.getLabel())}))};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();SallaAddProductButton.style=sallaAddProductButtonCss;var infoIcon='\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 shoppingBag='\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 sallaBottomAlertCss=":host{display:block}";var SallaBottomAlert=function(){function t(t){var i=this;registerInstance(this,t);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";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)}))}t.prototype.open=function(){var t=this;return this.modal.open().then((function(){return t.handleTemplateRequest()}))};t.prototype.getDefaultMessage=function(){return this.isRtl?this.defaultMessage.substring(0,this.defaultMessage.lastIndexOf(" ")):this.defaultMessage.split(" ").slice(0,-2).join(" ")};t.prototype.handleTemplateRequest=function(){var t=this;if(Object.keys(this.templateData).length){return}this.modal.loading();return salla.api.request("/store/template",{},"get",{"Store-Identifier":this.storeId}).then((function(i){t.modal.setTitle(t.templateInformation);t.templateData=i.data;t.modal.stopLoading()})).catch((function(){t.modal.close()}))};t.prototype.handleAction=function(){if(this.type==="link"){window.location.href=this.actionUrl}if(this.type==="popup"){this.open()}};t.prototype.popup=function(){var t=this;var i,e,n,a,r,o,s,l,u,c,f,d,p,v,g,_,m;return h("salla-modal",{class:"s-bottom-alert-modal",ref:function(i){return t.modal=i},"no-padding":true},Object.keys(this.templateData).length?[h("div",{class:"s-bottom-alert-modal-inner s-scrollbar"},Array.isArray((i=this.templateData)===null||i===void 0?void 0:i.screenshots)&&((n=(e=this.templateData)===null||e===void 0?void 0:e.screenshots)===null||n===void 0?void 0:n.length)?h("div",{class:"s-bottom-alert-modal-cover"},h("img",{src:(a=this.templateData)===null||a===void 0?void 0:a.screenshots[0],alt:""})):"",h("div",{class:{"s-bottom-alert-modal-content":true,"s-bottom-alert-modal-content-extra-padding":this.templateData.price}},((r=this.templateData)===null||r===void 0?void 0:r.description)?[h("div",{class:"s-bottom-alert-modal-content-title"},this.storeDetails),h("div",{class:"s-bottom-alert-modal-content-description",innerHTML:(o=this.templateData)===null||o===void 0?void 0:o.description}),h("hr",null)]:"",((s=this.templateData)===null||s===void 0?void 0:s.features)?[h("div",{class:"s-bottom-alert-modal-content-title"},this.storeFeatures),h("div",{class:"s-bottom-alert-modal-content-features",innerHTML:(l=this.templateData)===null||l===void 0?void 0:l.features})]:"",Array.isArray((u=this.templateData)===null||u===void 0?void 0:u.screenshots)&&((f=(c=this.templateData)===null||c===void 0?void 0:c.screenshots)===null||f===void 0?void 0:f.length)>1?h("salla-slider",{id:"template-screenshots",type:"carousel",class:"s-bottom-alert-modal-content-screenshots"},h("div",{slot:"items"},(d=this.templateData)===null||d===void 0?void 0:d.screenshots.map((function(t){return h("div",{class:"s-bottom-alert-modal-content-screenshot"},h("img",{src:t,alt:""}))})))):"",((p=this.templateData)===null||p===void 0?void 0:p.extra_info)?h("div",{class:"s-bottom-alert-modal-content-description",innerHTML:(v=this.templateData)===null||v===void 0?void 0:v.description}):""),((g=this.templateData)===null||g===void 0?void 0:g.link)?h("div",{class:"s-bottom-alert-modal-content-footer"},this.templateData.price&&h("div",{class:"s-bottom-alert-modal-price-wrapper"},h("div",null,this.storePrice),h("div",{class:"s-bottom-alert-modal-price-wrapper-amount",innerHTML:salla.money((_=this.templateData)===null||_===void 0?void 0:_.price)})),h("salla-button",{color:"primary",size:"medium",width:"wide",href:(m=this.templateData)===null||m===void 0?void 0:m.link},h("i",{innerHTML:shoppingBag}),this.buyTheTemplate)):"")]:"")};t.prototype.render=function(){var t=this;var i=this.template&&typeof this.template==="object"&&Object.keys(this.template).length>0;var e=i&&this.template.developer;var n=e!==undefined;var a=n&&(e===null||e===void 0?void 0:e.name);var r=null;return h(Host,{key:"54afc00bdffa94ff3717f2ba6ddd2ed82534cb4a",class:"s-bottom-alert-wrapper"},h("div",{key:"634f4f43d9ffada203efa37f1e4e56b5afc61c99",class:"s-bottom-alert-content"},h("div",{key:"83796d918d9773926cee99cb6891f5c5a9e1151f",class:"s-bottom-alert-icon"},this.icon?h("i",{class:this.icon}):h("i",{innerHTML:infoIcon})),h("div",{key:"e4f4e9f715868c07c5c425085542ada70aa6f76b",class:"s-bottom-alert-message"},this.message?this.message:i?h("span",null,this.getDefaultMessage()," ",h("a",{href:"#",class:{"s-bottom-alert-message-highlight":true,"s-bottom-alert-message-link":r},target:"","aria-label":"Developer"},a?a:this.theDeveloper)," ",h("span",{class:"s-bottom-alert-message-splitter"},"|")," ",this.storePrice,":"," ",h("span",{class:"s-bottom-alert-message-highlight",innerHTML:salla.money(this.template.price)})):this.defaultMessage),this.type!=="banner"&&h("div",{key:"82e089d7d9a5975cac5476e4dd1adf196b4492fe",class:"s-bottom-alert-action"},h("salla-button",{key:"29f693dfd29da4f8d11e519729738fcd5aaad974",href:this.actionUrl,size:"medium",onClick:function(){return t.handleAction()},width:"normal"},this.actionLabel||this.defaultActionLabel)),this.type==="popup"&&this.popup()))};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();SallaBottomAlert.style=sallaBottomAlertCss;var ArrowLeftIcon='\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 ArrowRightIcon='\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 sallaBreadcrumbCss=":host{display:block}";var SallaBreadcrumb=function(){function t(t){registerInstance(this,t);var i,e;this.sessionStorageKey="breadcrumb_snapshot";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=(e=this.host.querySelector('[slot="icon"]'))===null||e===void 0?void 0:e.outerHTML}t.prototype.componentWillLoad=function(){var t=this;return new Promise((function(t){return salla.onReady((function(){return salla.lang.onLoaded(t)}))})).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 i;var e=salla.config.get("page");if(!e||!e.slug){salla.logger.error('salla-breadcrumbs:: page object not existed on salla.config.get("page")!');t.breadcrumbs=[];return}var n=t.getSessionBreadcrumbs();if(e.slug==="product.single"&&n&&n.length>0){n.push({title:e.title,url:e.url});t.breadcrumbs=t.setBreadcrumbsFromArray(n);t.storeBreadcrumbSnapshot()}else if(n&&n.length>0){if(t.isNewPage(e,n)){t.breadcrumbs=t.generateBreadcrumbs(e);t.storeBreadcrumbSnapshot()}else{t.breadcrumbs=t.setBreadcrumbsFromArray(n)}}else{t.breadcrumbs=t.generateBreadcrumbs(e);t.storeBreadcrumbSnapshot()}if((i=t.breadcrumbs)===null||i===void 0?void 0:i.length){t.breadcrumbs[t.breadcrumbs.length-1].is_last=true}return t.breadcrumbs})).catch((function(i){salla.logger.error("salla-breadcrumb:: unexpected error!",i);t.breadcrumbs=[]}))};t.prototype.getSessionBreadcrumbs=function(){if(new URLSearchParams(window.location.search).get("from")==="search-bar"){return[]}return JSON.parse(sessionStorage.getItem(this.sessionStorageKey)||"[]")};t.prototype.isNewPage=function(t,i){var e=i[i.length-1];return(e===null||e===void 0?void 0:e.url)!==t.url};t.prototype.setBreadcrumbsFromArray=function(t){return t.map((function(i,e){return Object.assign(Object.assign({},i),{is_last:e===t.length-1})}))};t.prototype.sanitizeBreadcrumbTitle=function(t,i){if(i===void 0){i=1}if(!t.includes("|")){return t.trim()}return t.split("|").map((function(t){return t.trim()}))[i]};t.prototype.generateBreadcrumbs=function(t){var i,e;var n=[];if(t.slug==="product.single"){var a=this.getSessionBreadcrumbs();if(a.length>0&&((i=a[1])===null||i===void 0?void 0:i.url)===((e=t.parent)===null||e===void 0?void 0:e.url)){return this.setBreadcrumbsFromArray(__spreadArray(__spreadArray([],a,true),[t],false))}}var r=t;while(r){if(r.title){n.unshift({title:r.title,url:r.url})}r=r.parent}if(t.slug.includes("customer")&&t.slug!=="customer.profile"){n.unshift({title:salla.lang.get("common.titles.profile"),url:salla.url.get("profile")})}if(t.slug.includes("blog")){n.unshift({title:salla.lang.get("blocks.footer.blog"),url:salla.url.get("blog")})}if(t.slug==="brands.single"){n.unshift({title:salla.lang.get("common.titles.brands"),url:salla.url.get("brands")})}if(!t.title&&t.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};t.prototype.storeBreadcrumbSnapshot=function(){try{var t=salla.config.get("page");if((t===null||t===void 0?void 0:t.slug)==="product.single"){return}var i=__spreadArray([],this.breadcrumbs,true);var e=i.length-1;if(e>=0){i[e].url=window.location.href}var n=JSON.stringify(i);sessionStorage.setItem(this.sessionStorageKey,n)}catch(t){salla.logger.error("salla-breadcrumb:: Failed to store breadcrumb snapshot in sessionStorage.",t)}};t.prototype.render=function(){var t=this;if(this.breadcrumbs.length<=1){salla.log("salla-breadcrumb:: There is no breadcrumbs!");return null}return h("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(i){var e=salla.config.get("page.slug")==="product.single";var n=e&&i.is_last?i.title:t.sanitizeBreadcrumbTitle(i.title);var a=t.itemSlot.replace(/\{url\}/g,i.url).replace(/\{title\}/g,n);return[h("div",{class:"s-breadcrumb-slot",innerHTML:a}),t.getArrowDomForItem(i)]})))};t.prototype.getArrowDomForItem=function(t){if(t.is_last){return""}var i=this.iconSlot||(salla.config.get("theme.is_rtl",true)?ArrowLeftIcon:ArrowRightIcon);return h("li",{class:"s-breadcrumb-arrow"},h("div",{class:{"s-breadcrumb-icon-slot":true,"s-breadcrumb-default-icon":!this.iconSlot},innerHTML:i}))};t.prototype.componentDidRender=function(){var t,i,e;this.host.querySelectorAll(".s-breadcrumb-slot").forEach((function(t){return t.replaceWith(t.firstChild)}));this.host.querySelectorAll(".s-breadcrumb-icon-slot.s-breadcrumb-default-icon").forEach((function(t){return t.replaceWith(t.querySelector("svg"))}));(t=this.host.querySelector('[slot="item"]'))===null||t===void 0?void 0:t.remove();(i=this.host.querySelector('[slot="icon"]'))===null||i===void 0?void 0:i.remove();var n=(e=this.host.querySelectorAll(".s-breadcrumb-item")[this.breadcrumbs.length-1])===null||e===void 0?void 0:e.querySelector("a");n&&n.replaceWith(n.firstChild)};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();SallaBreadcrumb.style=sallaBreadcrumbCss;var sallaButtonCss="";var SallaButton=function(){function t(t){registerInstance(this,t);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.type="button"}t.prototype.load=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){if(this.loaderPosition=="center")this.text.classList.add("s-button-hide");this.host.setAttribute("loading","");return[2,this.host]}))}))};t.prototype.stop=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){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]}))}))};t.prototype.setText=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(i){this.text.innerHTML=t;return[2,this.host]}))}))};t.prototype.disable=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.host.setAttribute("disabled","");return[2,this.host]}))}))};t.prototype.enable=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.host.removeAttribute("disabled");return[2,this.host]}))}))};t.prototype.getBtnAttributes=function(){for(var t=0;t<this.host.attributes.length;t++){if(!["color","fill","size","width","id"].includes(this.host.attributes[t].name)){this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].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};t.prototype.button=function(){var t=this;return h("button",Object.assign({},this.getBtnAttributes(),{disabled:this.disabled}),h("span",{class:"s-button-text",ref:function(i){return t.text=i}},h("slot",null)),this.loading?h("span",{class:"s-button-loader"}):"")};t.prototype.render=function(){var t;return((t=this.host.closest(".swiper-slide"))===null||t===void 0?void 0:t.classList.contains("swiper-slide-duplicate"))?"":h(Host,{class:"s-button-wrap"},this.href?h("a",{href:this.href},this.button()):this.button())};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();SallaButton.style=sallaButtonCss;var sallaCartSummaryCss="";var SallaCartSummary=function(){function t(t){var i=this;registerInstance(this,t);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";salla.cart.event.onUpdated((function(t){i.cartSummaryCount=t.count||0;i.cartSummaryTotal=t.total||0}))}t.prototype.animateToCart=function(t){return __awaiter(this,void 0,void 0,(function(){var i,e,n,a,r,o,s,l,u,c,f,d;return __generator(this,(function(h){document.querySelectorAll(".s-cart-thumb").forEach((function(t){return t.remove()}));if(!(t===null||t===void 0?void 0:t.src)){salla.log("Failed to get the img element");return[2]}i=this.host.querySelector("#s-cart-icon"),e=i.getBoundingClientRect(),n=e.top+window.scrollY,a=e.left+window.scrollX;r=t.getBoundingClientRect(),o=t.offsetWidth+"px",s=t.offsetHeight+"px",l=r.top,u=r.left;c=document.createElement("img");c.src=t.getAttribute("src");c.className="s-cart-thumb";c.setAttribute("style","object-fit:cover; width:"+o+"; height:"+s+"; top:"+l+"px; left:"+u+"px;z-index:99999999; ");document.body.append(c);f=document.querySelector(".s-cart-thumb");i.classList.remove("animated","rubberBand");d=new anime.timeline;d.add({targets:f,width:[150,30],height:[150,30],top:[l,window.scrollY>0?n-window.scrollY-40:n-40],left:[u,a],borderRadius:["20%","50%"],easing:"easeOutExpo",duration:1200},"+=200").add({targets:f,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(){i.classList.add("animated","rubberBand");f.remove()}},"-=1700");return[2]}))}))};t.prototype.componentWillLoad=function(){return new Promise((function(t){return salla.onReady(t)}))};t.prototype.render=function(){return h(Host,{key:"f536afae4840b08133a82698fab4b4df6d479e14"},h("a",{key:"26185bdeec4028f6fe936e5a0970fec799761bdd",class:"s-cart-summary-wrapper",href:salla.url.get("cart")},h("div",{key:"817fb77ac1feedd59d23b35a53648382aa3e300c",id:"s-cart-icon"},h("slot",{key:"3d0601960d662d63988b44f1745d222c43f8ecd7",name:"icon"},h("i",{key:"27da6c6fe8da8bd634fad5e39b9b62ec061694b1",class:"s-cart-summary-icon",innerHTML:PendingOrdersIcon}))),h("span",{key:"e1a63ea518c783207d85a657778fb739bc1f386f",class:"s-cart-summary-count"},salla.helpers.number(this.cartSummaryCount)),h("p",{key:"4133fd68ef50ff54609718274f3daa2f87511a3b",class:"s-cart-summary-content"},this.showCartLabel&&h("span",{key:"ec133e448903ec65c42cc7ec35984ca90bbb9a1c",class:"s-cart-summary-label"},this.cartLabel),h("b",{key:"c0e06bab8d8032e37e4059dfce54135f89a6a8d3",class:"s-cart-summary-total",innerHTML:salla.money(this.cartSummaryTotal)}))))};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();SallaCartSummary.style=sallaCartSummaryCss;var vanillaPicker$1={exports:{}};
/*!
* vanilla-picker v2.12.3
* https://vanilla-picker.js.org
*
* Copyright 2017-2024 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate)
* Released under the ISC license.
*/var vanillaPicker=vanillaPicker$1.exports;var hasRequiredVanillaPicker;function requireVanillaPicker(){if(hasRequiredVanillaPicker)return vanillaPicker$1.exports;hasRequiredVanillaPicker=1;(function(t,i){(function(i,e){t.exports=e()})(vanillaPicker,(function(){var t=function(t,i){if(!(t instanceof i)){throw new TypeError("Cannot call a class as a function")}};var i=function(){function t(t,i){for(var e=0;e<i.length;e++){var n=i[e];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(t,n.key,n)}}return function(i,e,n){if(e)t(i.prototype,e);if(n)t(i,n);return i}}();var e=function(){function t(t,i){var e=[];var n=true;var a=false;var r=undefined;try{for(var o=t[Symbol.iterator](),s;!(n=(s=o.next()).done);n=true){e.push(s.value);if(i&&e.length===i)break}}catch(t){a=true;r=t}finally{try{if(!n&&o["return"])o["return"]()}finally{if(a)throw r}}return e}return function(i,e){if(Array.isArray(i)){return i}else if(Symbol.iterator in Object(i)){return t(i,e)}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}}}();String.prototype.startsWith=String.prototype.startsWith||function(t){return this.indexOf(t)===0};String.prototype.padStart=String.prototype.padStart||function(t,i){var e=this;while(e.length<t){e=i+e}return e};var n={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 a(t){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var e=i>0?t.toFixed(i).replace(/0+$/,"").replace(/\.$/,""):t.toString();return e||"0"}var r=function(){function r(i,n,a,o){t(this,r);var s=this;function l(t){if(t.startsWith("hsl")){var i=t.match(/([\-\d\.e]+)/g).map(Number),n=e(i,4),a=n[0],o=n[1],l=n[2],u=n[3];if(u===undefined){u=1}a/=360;o/=100;l/=100;s.hsla=[a,o,l,u]}else if(t.startsWith("rgb")){var c=t.match(/([\-\d\.e]+)/g).map(Number),f=e(c,4),d=f[0],h=f[1],p=f[2],v=f[3];if(v===undefined){v=1}s.rgba=[d,h,p,v]}else{if(t.startsWith("#")){s.rgba=r.hexToRgb(t)}else{s.rgba=r.nameToRgb(t)||r.hexToRgb(t)}}}if(i===undefined);else if(Array.isArray(i)){this.rgba=i}else if(a===undefined){var u=i&&""+i;if(u){l(u.toLowerCase())}}else{this.rgba=[i,n,a,o===undefined?1:o]}}i(r,[{key:"printRGB",value:function t(i){var e=i?this.rgba:this.rgba.slice(0,3),n=e.map((function(t,i){return a(t,i===3?3:0)}));return i?"rgba("+n+")":"rgb("+n+")"}},{key:"printHSL",value:function t(i){var e=[360,100,100,1],n=["","%","%",""];var r=i?this.hsla:this.hsla.slice(0,3),o=r.map((function(t,i){return a(t*e[i],i===3?3:1)+n[i]}));return i?"hsla("+o+")":"hsl("+o+")"}},{key:"printHex",value:function t(i){var e=this.hex;return i?e:e.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=r.hslToRgb(this._hsla)},set:function t(i){if(i.length===3){i[3]=1}this._rgba=i;this._hsla=null}},{key:"rgbString",get:function t(){return this.printRGB()}},{key:"rgbaString",get:function t(){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=r.rgbToHsl(this._rgba)},set:function t(i){if(i.length===3){i[3]=1}this._hsla=i;this._rgba=null}},{key:"hslString",get:function t(){return this.printHSL()}},{key:"hslaString",get:function t(){return this.printHSL(true)}},{key:"hex",get:function t(){var i=this.rgba,e=i.map((function(t,i){return i<3?t.toString(16):Math.round(t*255).toString(16)}));return"#"+e.map((function(t){return t.padStart(2,"0")})).join("")},set:function t(i){this.rgba=r.hexToRgb(i)}}],[{key:"hexToRgb",value:function t(i){var e=(i.startsWith("#")?i.slice(1):i).replace(/^(\w{3})$/,"$1F").replace(/^(\w)(\w)(\w)(\w)$/,"$1$1$2$2$3$3$4$4").replace(/^(\w{6})$/,"$1FF");if(!e.match(/^([0-9a-fA-F]{8})$/)){throw new Error("Unknown hex color; "+i)}var n=e.match(/^(\w\w)(\w\w)(\w\w)(\w\w)$/).slice(1).map((function(t){return parseInt(t,16)}));n[3]=n[3]/255;return n}},{key:"nameToRgb",value:function t(i){var e=i.toLowerCase().replace("at","T").replace(/[aeiouyldf]/g,"").replace("ght","L").replace("rk","D").slice(-5,4),a=n[e];return a===undefined?a:r.hexToRgb(a.replace(/\-/g,"00").padStart(6,"f"))}},{key:"rgbToHsl",value:function t(i){var n=e(i,4),a=n[0],r=n[1],o=n[2],s=n[3];a/=255;r/=255;o/=255;var l=Math.max(a,r,o),u=Math.min(a,r,o);var c=void 0,f=void 0,d=(l+u)/2;if(l===u){c=f=0}else{var h=l-u;f=d>.5?h/(2-l-u):h/(l+u);switch(l){case a:c=(r-o)/h+(r<o?6:0);break;case r:c=(o-a)/h+2;break;case o:c=(a-r)/h+4;break}c/=6}return[c,f,d,s]}},{key:"hslToRgb",value:function t(i){var n=e(i,4),a=n[0],r=n[1],o=n[2],s=n[3];var l=void 0,u=void 0,c=void 0;if(r===0){l=u=c=o}else{var f=function t(i,e,n){if(n<0)n+=1;if(n>1)n-=1;if(n<1/6)return i+(e-i)*6*n;if(n<1/2)return e;if(n<2/3)return i+(e-i)*(2/3-n)*6;return i};var d=o<.5?o*(1+r):o+r-o*r,h=2*o-d;l=f(h,d,a+1/3);u=f(h,d,a);c=f(h,d,a-1/3)}var p=[l*255,u*255,c*255].map(Math.round);p[3]=s;return p}}]);return r}();var o=function(){function e(){t(this,e);this._events=[]}i(e,[{key:"add",value:function t(i,e,n){i.addEventListener(e,n,false);this._events.push({target:i,type:e,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 t(i,e,n){i.removeEventListener(e,n,false)}}]);return e}();function s(t){var i=document.createElement("div");i.innerHTML=t;return i.firstElementChild}function l(t,i,e){var n=false;function a(t,i,e){return Math.max(i,Math.min(t,e))}function r(t,r,o){if(o){n=true}if(!n){return}t.preventDefault();var s=i.getBoundingClientRect(),l=s.width,u=s.height,c=r.clientX,f=r.clientY;var d=a(c-s.left,0,l),h=a(f-s.top,0,u);e(d/l,h/u)}function o(t,i){var e=t.buttons===undefined?t.which:t.buttons;if(e===1){r(t,t,i)}else{n=false}}function s(t,i){if(t.touches.length===1){r(t,t.touches[0],i)}else{n=false}}t.add(i,"mousedown",(function(t){o(t,true)}));t.add(i,"touchstart",(function(t){s(t,true)}));t.add(window,"mousemove",o);t.add(i,"touchmove",s);t.add(window,"mouseup",(function(t){n=false}));t.add(i,"touchend",(function(t){n=false}));t.add(i,"touchcancel",(function(t){n=false}))}var u="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 c=360;var f="keydown",d="mousedown",h="focusin";function p(t,i){return(i||document).querySelector(t)}function v(t){t.preventDefault();t.stopPropagation()}function g(t,i,e,n,a){t.add(i,f,(function(t){if(e.indexOf(t.key)>=0){n(t)}}))}var _=function(){function e(i){t(this,e);this.settings={popup:"right",layout:"default",alpha:true,editor:true,editorFormat:"hex",cancelButton:false,defaultColor:"#0cf"};this._events=new o;this.onChange=null;this.onDone=null;this.onOpen=null;this.onClose=null;this.setOptions(i)}i(e,[{key:"setOptions",value:function t(i){var e=this;if(!i){return}var n=this.settings;function a(t,i,e){for(var n in t){i[n]=t[n]}}if(i instanceof HTMLElement){n.parent=i}else{if(n.parent&&i.parent&&n.parent!==i.parent){this._events.remove(n.parent);this._popupInited=false}a(i,n);if(i.onChange){this.onChange=i.onChange}if(i.onDone){this.onDone=i.onDone}if(i.onOpen){this.onOpen=i.onOpen}if(i.onClose){this.onClose=i.onClose}var r=i.color||i.colour;if(r){this._setColor(r)}}var o=n.parent;if(o&&n.popup&&!this._popupInited){var s=function t(i){return e.openHandler(i)};this._events.add(o,"click",s);g(this._events,o,[" ","Spacebar","Enter"],s);this._popupInited=true}else if(i.parent&&!n.popup){this.show()}}},{key:"openHandler",value:function t(i){if(this.show()){i&&i.preventDefault();this.settings.parent.style.pointerEvents="none";var e=i&&i.type===f?this._domEdit:this.domElement;setTimeout((function(){return e.focus()}),100);if(this.onOpen){this.onOpen(this.colour)}}}},{key:"closeHandler",value:function t(i){var e=i&&i.type;var n=false;if(!i){n=true}else if(e===d||e===h){var a=(this.__containedEvent||0)+100;if(i.timeStamp>a){n=true}}else{v(i);n=true}if(n&&this.hide()){this.settings.parent.style.pointerEvents="";if(e!==d){this.settings.parent.focus()}if(this.onClose){this.onClose(this.colour)}}}},{key:"movePopup",value:function t(i,e){this.closeHandler();this.setOptions(i);if(e){this.openHandler()}}},{key:"setColor",value:function t(i,e){this._setColor(i,{silent:e})}},{key:"_setColor",value:function t(i,e){if(typeof i==="string"){i=i.trim()}if(!i){return}e=e||{};var n=void 0;try{n=new r(i)}catch(t){if(e.failSilently){return}throw t}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,e)}},{key:"setColour",value:function t(i,e){this.setColor(i,e)}},{key:"show",value:function t(){var i=this.settings.parent;if(!i){return false}if(this.domElement){var e=this._toggleDOM(true);this._setPosition();return e}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=s(n);this.domElement=a;this._domH=p(".picker_hue",a);this._domSL=p(".picker_sl",a);this._domA=p(".picker_alpha",a);this._domEdit=p(".picker_editor input",a);this._domSample=p(".picker_sample",a);this._domOkay=p(".picker_done button",a);this._domCancel=p(".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 t(){return this._toggleDOM(false)}},{key:"destroy",value:function t(){this._events.destroy();if(this.domElement){this.settings.parent.removeChild(this.domElement)}}},{key:"_bindEvents",value:function t(){var i=this;var e=this,n=this.domElement,a=this._events;function r(t,i,e){a.add(t,i,e)}r(n,"click",(function(t){return t.preventDefault()}));l(a,this._domH,(function(t,i){return e._setHSLA(t)}));l(a,this._domSL,(function(t,i){return e._setHSLA(null,t,1-i)}));if(this.settings.alpha){l(a,this._domA,(function(t,i){return e._setHSLA(null,null,null,1-i)}))}var o=this._domEdit;{r(o,"input",(function(t){e._setColor(this.value,{fromEditor:true,failSilently:true})}));r(o,"focus",(function(t){var i=this;if(i.selectionStart===i.selectionEnd){i.select()}}))}this._ifPopup((function(){var t=function t(e){return i.closeHandler(e)};r(window,d,t);r(window,h,t);g(a,n,["Esc","Escape"],t);var e=function t(e){i.__containedEvent=e.timeStamp};r(n,d,e);r(n,h,e);r(i._domCancel,"click",t)}));var s=function t(e){i._ifPopup((function(){return i.closeHandler(e)}));if(i.onDone){i.onDone(i.colour)}};r(this._domOkay,"click",s);g(a,n,["Enter"],s)}},{key:"_setPosition",value:function t(){var i=this.settings.parent,e=this.domElement;if(i!==e.parentNode){i.appendChild(e)}this._ifPopup((function(t){if(getComputedStyle(i).position==="static"){i.style.position="relative"}var n=t===true?"popup_right":"popup_"+t;["popup_top","popup_bottom","popup_left","popup_right"].forEach((function(t){if(t===n){e.classList.add(t)}else{e.classList.remove(t)}}));e.classList.add(n)}))}},{key:"_setHSLA",value:function t(i,e,n,a,r){r=r||{};var o=this.colour,s=o.hsla;[i,e,n,a].forEach((function(t,i){if(t||t===0){s[i]=t}}));o.hsla=s;this._updateUI(r);if(this.onChange&&!r.silent){this.onChange(o)}}},{key:"_updateUI",value:function t(i){if(!this.domElement){return}i=i||{};var e=this.colour,n=e.hsla,a="hsl("+n[0]*c+", 100%, 50%)",r=e.hslString,o=e.hslaString;var s=this._domH,l=this._domSL,f=this._domA,d=p(".picker_selector",s),h=p(".picker_selector",l),v=p(".picker_selector",f);function g(t,i,e){i.style.left=e*100+"%"}function _(t,i,e){i.style.top=e*100+"%"}g(s,d,n[0]);this._domSL.style.backgroundColor=this._domH.style.color=a;g(l,h,n[1]);_(l,h,1-n[2]);l.style.color=r;_(f,v,1-n[3]);var m=r,b=m.replace("hsl","hsla").replace(")",", 0)"),w="linear-gradient("+[m,b]+")";this._domA.style.background=w+", "+u;if(!i.fromEditor){var x=this.settings.editorFormat,y=this.settings.alpha;var k=void 0;switch(x){case"rgb":k=e.printRGB(y);break;case"hsl":k=e.printHSL(y);break;default:k=e.printHex(y)}this._domEdit.value=k}this._domSample.style.color=o}},{key:"_ifPopup",value:function t(i,e){if(this.settings.parent&&this.settings.popup){i&&i(this.settings.popup)}else{e&&e()}}},{key:"_toggleDOM",value:function t(i){var e=this.domElement;if(!e){return false}var n=i?"":"none",a=e.style.display!==n;if(a){e.style.display=n}return a}}]);return e}();{var m=document.createElement("style");m.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