"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _this22=this,_slicedToArray=function(){function e(e,t){var i=[],a=!0,n=!1,r=undefined;try{for(var s,o=e[Symbol.iterator]();!(a=(s=o.next()).done)&&(i.push(s.value),!t||i.length!==t);a=!0);}catch(l){n=!0,r=l}finally{try{!a&&o["return"]&&o["return"]()}finally{if(n)throw r}}return i}return function(t,i){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_extends=Object.assign||function(e){for(var t=1;tt&&(t=e.offsetWidth),e.style.minWidth=t+"px"}},{key:"clickToScroll",value:function(e,t){var i=arguments.length<=2||arguments[2]===undefined||arguments[2],a='[swatch-slider="true"]';this.resSlider(e,a,t,i)}},{key:"resSlider",value:function(e,t,i,a){var n=t+" "+'[navigation="left"]',r=t+" "+'[navigation="right"]',s=JSON.parse(i.dataset.sliderData),o=".swatch-navigable ul";i.querySelector(t+""+o).style.transition=a?"0.3s ease all":"none";var l=i.querySelector(t+""+o).style.transform.match(/-?[\d\.]+/g),c=-Math.abs(l[0]);if(0==e)"mode_0"!=s.arrowMode&&i.querySelector(r).classList.add("star-show"),i.querySelector(r).classList.remove("star-disabled"),"swatch-pill"==s.swatchType||"button"==s.assocViewType?(c+=.8*s.sliderWidth)>=-s.firstSwatchWidth/2&&(c=0,this.handleLeftEdge(i,n,s)):(c+=this.calculateSlideSwatchesCount(s)*(s.swatchSliderItemWidth+s.marginRight),"half"===s.lastSwatchPreview&&(c+=s.swatchSliderItemWidth-s.lastSwatchWidth),c>=-s.swatchSliderItemWidth/3&&(c=0,this.handleLeftEdge(i,n,s)));else if(1==e)if("mode_0"!=s.arrowMode&&i.querySelector(n).classList.add("star-show"),i.querySelector(n).classList.remove("star-disabled"),"swatch-pill"==s.swatchType||"button"==s.assocViewType){var u=c;c-=.8*s.sliderWidth,s.totalScrollWidth<=-(c-s.sliderWidth)&&(c=u+(-s.totalScrollWidth-(u-s.sliderWidth))-1,this.handleRightEdge(i,r,s))}else{u=c;c-=this.calculateSlideSwatchesCount(s)*(s.swatchSliderItemWidth+s.marginRight),"half"===s.lastSwatchPreview&&(c-=s.swatchSliderItemWidth-s.lastSwatchWidth),Number(s.totalScrollWidth.toFixed(3))<=Number((-(c-s.sliderWidth)).toFixed(3))&&(c=Number((u+(-s.totalScrollWidth-(u-s.sliderWidth))).toFixed(3)),this.handleRightEdge(i,r,s))}i.querySelector(t+""+o).style.transform="translateX("+c+"px)"}},{key:"calculateSlideSwatchesCount",value:function(e){var t=e.visibleSwatches>0?e.visibleSwatches:1;return"mode_1"==e.arrowMode&&(t=e.visibleSwatches>2?e.visibleSwatches-2:1),t}},{key:"handleLeftEdge",value:function(e,t,i){"mode_1"==i.arrowMode?setTimeout(function(){e.querySelector(t).classList.remove("star-show")},500):e.querySelector(t).classList.add("star-disabled")}},{key:"handleRightEdge",value:function(e,t,i){"mode_1"==i.arrowMode?setTimeout(function(){e.querySelector(t).classList.remove("star-show")},500):e.querySelector(t).classList.add("star-disabled")}},{key:"scrollSwatchSlider",value:function(e){var t=e.closest(".swatch-navigable"),i=e.getAttribute("data-navigation");if(t&&t.hasAttribute("data-current-scroll")){var a=Number(t.getAttribute("data-current-scroll")),n=t.querySelectorAll(".swatch-view-item"),r=a;if("right"===i)for(var s=a;sl.left){n[s].scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"}),r=s;break}}else"left"===i&&(r=Math.max(0,a-1));var c=r===n.length-1?"end":"start";return n[r].scrollIntoView({behavior:"smooth",block:"nearest",inline:c}),void t.setAttribute("data-current-scroll",r)}"left"==i?this.clickToScroll(0,t):this.clickToScroll(1,t)}},{key:"getCorrectSwatchRoot",value:function(){var e=this,t=arguments.length<=0||arguments[0]===undefined?"options":arguments[0],i=null,a=null,n=!1,r="bottom";if(this.isInstanceTypeProduct()){if(i="products_"+t+"_root",void 0===(a=this.pInformation[i])||!a.parentNode){var s=this.clientSpecs.getSelectors(),o=null,l="groups"==t;r=s.swatch_root.position;var c="div[data-vsk-groups-priority]",u=document.querySelector(c),d=this.productInfoTree.getProductInfo().handle,p=null;u&&(p=u.dataset.vskProductHandle),u&&p==d&&(this.groupsDisplaySelector=c),o=l&&this.groupsDisplaySelector&&this.clientSpecs.getGroupsEnableStatusForProductType()?this.groupsDisplaySelector:s.swatch_root.selector,!(a=l&&u&&p==d&&this.clientSpecs.getGroupsEnableStatusForProductType()?u:this.currentDocument.querySelector(o))&&this.currentDocument.matches&&this.currentDocument.matches(o)&&(a=this.currentDocument),n=!!a}}else this.isInstanceTypeCollection()&&(i="collections_"+t+"_root",void 0!==(a=this.pInformation[i])&&a.parentNode||function(){var t=e.getInstanceConfig(),i="bottom";a=e.currentDocument,r=i;var s=t.swatch_display_options,o=q.swatch_location;if(s){var l=-1;-1!==(l=s.findIndex(function(e){return e.label===o}))?(r=s[l].position,a=e.currentDocument.querySelector(s[l].selector)):-1!==(l=s.findIndex(function(t){return!!e.currentDocument.querySelector(t.selector)}))&&(r=s[l].position,a=e.currentDocument.querySelector(s[l].selector))}a||(r=i,a=e.currentDocument),n=!0}());if(n){var h=document.createElement("variant-swatch-king");h.style.maxWidth="100%","before"==r?a.parentNode.insertBefore(h,a):"after"==r?a.parentNode.insertBefore(h,a.nextSibling):"top"==r?a.insertBefore(h,a.firstChild):a.appendChild(h),this.pInformation[i]=h,a=h}return a}},{key:"getLabelWidth",value:function(e,t){var i=e.closest(".swatch-drop-down-label");if(i){var a=i.querySelector(".swatch-label-inside");if(a){t=parseFloat(t.match(/[\d\.]+/g));var n=a.getBoundingClientRect().width;e.style.paddingLeft=t+n+"px"}}}},{key:"getPriceMaxWidth",value:function(e){var t=e.querySelectorAll(".swatch-button-price"),i=0;t.forEach(function(e){var t=e.offsetWidth;t>i&&(i=t)}),t.forEach(function(e){e.style.width=i+"px"})}},{key:"setProductGroupsObject",value:function(){return f||"undefined"==typeof window.starapps_data?!f&&["lambda"].includes(this.clientSpecs.getDataUrlSource())&&(m=this.clientSpecs.getLambdaCloudFrontUrl(),f=[],v={}):(f=window.starapps_data.product_groups,v=window.starapps_data.product_groups_chart),null!=f&&f!=undefined}},{key:"getProductsGroups",value:function(e){for(var t=[],i=0;i=200&&t.status<400){var i=JSON.parse(t.responseText);this.setProductGroupsFromAPI(i,e),a&&a.call(this)}}.bind(i),t.send(null))}},{key:"getProductGroupIndexes",value:function(e){var t=v[e];return void 0!==t?t:m?null:[]}},{key:"getGroupSwatchImageURL",value:function(e,t){var i=encodeURIComponent(t);return"cdn"==this.clientSpecs.getSwatchUrlSource()&&(i=encodeURIComponent(i)),"https://"+this.clientSpecs.getSwatchUrlHost()+"/apps/"+this.swatchDir+"/"+this.storeSlug+"/groups/"+e.split("group")[1]+"/"+i+".media"}},{key:"generateProductGroups",value:function(){var e=this;if("collections"===this.instanceType?this.clientSpecs.getEnableStatusForProductGridType():"products"===this.instanceType&&this.clientSpecs.getGroupsEnableStatusForProductType())if(this.setProductGroupsObject())if(this.hasOnlyDefaultVariant||this.uiElements.getIsSwatchRootDisplayed()){var t=this.getMultiLingualInfo().translation_status;if(t&&!this.productInfoTree.getUntranslatedProductHandle())return setTimeout(this.generateProductGroups.bind(this),100),void B("Untranslated handle is not found ... calling generateProductGroups method again!");var i=t?this.productInfoTree.getUntranslatedProductHandle():this.productInfoTree.getProductInfo().handle,a=this.getProductGroupIndexes(i),n=null;if(m&&null==a)this.getProductGroupsByAPI(i,this.generateProductGroups.bind(this));else if(!((n=this.getProductsGroups(a)).length<=0)){var r=this.groupsDisplaySelector?"groups":"options",s=this.getCorrectSwatchRoot(r);this.uiElements.getIsSwatchRootDisplayed(r)||(this.isInstanceTypeProduct()?this.uiElements.renderSwatchRoot(this.uiElements.getSwatchRoot([]),s,r):this.isInstanceTypeCollection()&&this.uiElements.renderSwatchRoot(this.uiElements.getSwatchRoot([]),s));var o=s.querySelector(".swatches.swatches-type-"+this.instanceType),l={top:0,bottom:0},c={top:[],bottom:[]};Object.entries(n).forEach(function(t){var n=_slicedToArray(t,2),r=n[0],s=n[1],u="group"+s.id;if("length"!=r){for(var d=0;d';if("top"==s.display_position){var y=o.querySelector('[sa-group-position="top"]');y.querySelector('[option-target="'+u+'"]')||y.insertBefore(e.uiElements.parseHTML(_)[0],y.children[l.top])}else{var w=o.querySelector('[sa-group-position="bottom"]');if(!w.querySelector('[option-target="'+u+'"]')){var b=w.children.length-1-l.bottom;-1!=l.bottom?w.insertBefore(e.uiElements.parseHTML(_)[0],w.children[b]):w.append(e.uiElements.parseHTML(_)[0])}}e.pInformation.selected_product_group&&e.pInformation.selected_product_group==u||(v=a[r],"storefront"==S?(h={},g=[],f=Object.fromEntries(Object.entries(window.sessionStorage)),(g=s.option_values.reduce(function(t,i){var a='"gid://shopify/Product/'+i.id+'"',n=e.getSessionStorageKey(i.id,!1,!1),r=e.getDataFromSessionStorage(n);if(f[n])if(r&&null!==r.id){h[a]=r;var o=s.option_values.findIndex(function(e){return e.id===i.id});-1!==o&&(s.option_values[o]=_extends({},s.option_values[o],{available:r.available,published:!0,published_at:r.publishedAt,compare_at_price:r.compareAtPriceRange}))}else s.option_values=s.option_values.filter(function(e){return e.id!==i.id});else t.push(a);return t},[])).length>0?function(){for(var t=R,a=Math.ceil(g.length/t),n=0,r=function(t,a){++n===a&&e.generateProductGroupsUI(v,l,o,u,s,i,h)},c=0;c',i.querySelector('[option-target="'+a+'"]').appendChild(this.uiElements.parseHTML(P)[0]),"smart_hide"==this.clientSpecs.hideSingleValueOption(this.instanceType)&&(O=!1,L=null,N=i.querySelectorAll("ul.swatch-view-image, ul.swatch-view-custom-image"),Object.entries(N).forEach(function(e){var t=_slicedToArray(e,2),i=t[0],a=t[1];if("length"!=i){var n=1==a.children.length?a.closest("div[option-target]"):null;n?(n.classList.add("option-single-value"),null==L&&(L=n)):O=!0,!O&&L&&i==N.length-1&&L.classList.remove("option-single-value")}})),l){if("drop_down"==u.view_type_preset.assoc_view_type&&"label_inside"==u.view_type_preset.params.dropdown_type){var M=i.querySelectorAll("div.swatch-drop-down-inner [type='select']");Object.entries(M).forEach(function(e){var t=_slicedToArray(e,2),i=t[0],a=t[1];"length"!=i&&s.getLabelWidth(a,u.view_type_preset.params.padding_left)})}if("button"==u.view_type_preset.assoc_view_type&&(u.view_type_preset.params.full_width||u.view_type_preset.params.radio_button)){var q=i.querySelectorAll(".enable-price-alignment");Object.entries(q).forEach(function(e){var t=_slicedToArray(e,2),i=t[0],a=t[1];"length"!=i&&s.getPriceMaxWidth(a)})}this.generateProductGroupsUIHelper(u.view_type_preset,a,i,d,u)}}},{key:"generateProductGroupsUIHelper",value:function(e,t,i,a){var n=i.querySelector('[option-target="'+t+'"] .swatch-group-selector[current-product]');if(n){if(0!=a){var r=n.closest("[option-name]").getAttribute("option-name"),s=this.uiElements.getMinifiedHTML(r,a,this.productInfoTree.getProductInfo());n.closest("ul.swatch-view").appendChild(s)}if(this.uiElements.selectSwatch(t,n,n.getAttribute("orig-value")),"select_value"==n.getAttribute("type")){var o=n.closest("div.swatch-drop-down-inner").querySelector('div[type="select"]');o.style.minWidth&&"0px"!=o.style.minWidth||this.setSelectMinWidth(o),o.innerHTML=n.innerHTML,o.setAttribute("aria-label",n.innerText),o.setAttribute("aria-expanded",!1),n.parentNode.classList.add("swatch-hide")}var l=n.closest("[option-target]"),c=l.querySelector("span.swatch-variant-name");if(c){var u=n.getAttribute("data-value"),d=l.getAttribute("option-name");c&&d&&"empty"!=d.trim()&&"none"!=u&&(c.innerHTML=' '+this.labelSplitSymbol+" "+u)}var p=n.closest(".swatch-navigable, variant-swatch-king"),h=n.closest(".swatch-view-stack, variant-swatch-king");if(p&&"VARIANT-SWATCH-KING"!=p.tagName){var g=n.closest("ul.swatch-view"),f=n.closest("li.swatch-view-item"),v='[data-navigation="left"]',m=!!g&&f.offsetLeft>g.clientWidth;if(m&&(v='[data-navigation="right"]'),p){p.querySelector(".swatch-navigation"+v);var _=n.closest(".swatch-navigable");this.resSliderSize(_,e.params,e.assoc_view_type)}m&&(g.style.scrollBehavior="auto",g.scrollLeft=f.offsetLeft-f.offsetWidth, g.style.scrollBehavior="")}else if(h&&"VARIANT-SWATCH-KING"!=h.tagName){_=n.closest(".swatch-view-stack");this.resStackSize(_,e.params,e.assoc_view_type)}}}},{key:"getTranslatedData",value:function(e,t,i){var a='"gid://shopify/Product/'+e.id+'"';if(t&&t[a]){var n=t[a];switch(i){case"title":return n.title;case"handle":return n.handle;case"minPrice":return parseFloat(n.priceRange.minVariantPrice.amount);case"maxPrice":return parseFloat(n.priceRange.maxVariantPrice.amount);case"available":return n.availableForSale;case"featured_img":return n.featuredImage?n.featuredImage.url:this.clientSpecs.getDefaultSwatchImage();case"secondary_img":return n.images.nodes.length>1?n.images.nodes[1].url:this.clientSpecs.getDefaultSwatchImage();case"last_img":var r=n.images.nodes.length;return r?n.images.nodes[r-1].url:this.clientSpecs.getDefaultSwatchImage()}}return e[i]}},{key:"getInstanceConfig",value:function(){return this.clientSpecs.getCollectionConfig()}},{key:"getInstanceSettings",value:function(){return this.clientSpecs.getCollectionSettings()}},{key:"removeElement",value:function(e){e.parentNode.removeChild(e)}},{key:"generateImageURL",value:function(e,t){var i=/\.(?:jpg|png|jpeg|gif|tiff|bmp)(?:\?|\s|$)/gm,a=/(?:_\d*x\d*|_medium|_large|_small)(?:_crop_[a-zA-Z]{3,6}){0,1}(?=\.(?:jpg|png|jpeg|gif|tiff|bmp))/gm.exec(e),n=i.exec(t);return a&&n&&(t=t.replace(n[0],a[0]+n[0])),t}},{key:"updateVariantImage",value:function(e,t,i){var a=!1,n=!1,r=i?"featured_image_src":"secondary_image_src";if(i&&t.featured_image?a=!0:!i&&t.featured_image&&t.featured_image.secondary_src&&(a=!0),e&&"PICTURE"==e.tagName){for(var s=e.querySelectorAll("source"),o=0;o1)l=c[parseInt((c.length-1)/2)].trim().split(" ")[0];else if(1==c.length){l=c[0].trim().split(" ")[0]}}this.pInformation[r]||(this.pInformation[r]=l);var u=null;u=i?this.generateImageURL(l,t.featured_image.src):this.generateImageURL(l,t.featured_image.secondary_src),e.setAttribute("src",u),e.setAttribute("srcset",u),e.setAttribute("data-srcset",u),n=!0}else{var d=/url\((\S*)\)/gm;(l=e.style.backgroundImage)||(l=e.style.background);var p=d.exec(l);if(p){l=(l=p[1]).trim(),this.pInformation[r]||(this.pInformation[r]=l);u=null;u=i?this.generateImageURL(l,t.featured_image.src):this.generateImageURL(l,t.featured_image.secondary_src),e.setAttribute("data-bgset",u),e.style.backgroundImage?e.style.backgroundImage="url("+u+")":e.style.background="url("+u+")",n=!0}}else if(e)if("IMG"==e.tagName&&this.pInformation[r]){u=this.pInformation[r];e.setAttribute("src",u),e.setAttribute("srcset",u),e.setAttribute("data-srcset",u),n=!0}else if(this.pInformation[r]){u=this.pInformation[r];e.setAttribute("data-bgset",u),e.style.backgroundImage?e.style.backgroundImage="url("+u+")":e.style.background="url("+u+")",n=!0}e&&n&&e.className.includes("lazyload")&&(e.classList.remove("lazyload"),e.classList.remove("lazyloading"),e.classList.remove("lazyloaded"),e.classList.add("lazyload"))}},{key:"formatDefaultOption",value:function(e,t){return void 0===e?t:e}},{key:"formatWithDelimiters",value:function(e,t,i,a,n){i=this.formatDefaultOption(i,2),a=this.formatDefaultOption(a,","),n=this.formatDefaultOption(n,".");var r=(t=this.formatDefaultOption(t,!!this.getInstanceSettings().price_trailing_zeroes))?n+"00":"";if(isNaN(e)||null==e)return 0;var s=(e=(e*("storefront"===S?1:.01)).toFixed(i)).split(".");return s[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+a)+(s[1]&&"00"!=s[1]?n+s[1]:r)}},{key:"insertHTMLAt",value:function(e,t,i){if("replace"!=i){var a=this.uiElements.parseHTML(e)[0];"before"==i?t.parentNode.insertBefore(a,t):"after"==i?t.parentNode.insertBefore(a,t.nextSibling):"top"==i?t.insertBefore(a,t.firstChild):t.appendChild(a)}else t.innerHTML=e}},{key:"updateGridElements",value:function(e){var t=this.getInstanceConfig().grid_updates,i=this.getGridUpdateParams(e);i.is_on_sale?this.currentDocument.classList.add("swatch-variant-onsale"):this.currentDocument.classList.remove("swatch-variant-onsale"),"undefined"!=typeof i.available&&i.available?this.currentDocument.classList.remove("swatch-variant-soldout"):this.currentDocument.classList.add("swatch-variant-soldout");for(var a=0;a0;){var d=c.children[0];u.appendChild(d)}}B("Generating restructured swatch UI..."),this.generateUISwitch()(),this.generateProductGroups()}else setTimeout(this.productChangeRestructure.bind(this,e,t),100)}},{key:"productChangeOperations",value:function(e,t,i){var a=t.getAttribute("option-target"),n=t.parentNode.parentNode,r=this.getFirstAvailableVariant(e),s=r?r.id:null;if("storefront"===S&&s){var o=r.id.split("ProductVariant/");s=o[1]?o[1]:r.id}var l="storefront"==S?"undefined"!=typeof e.availableForSale?e.availableForSale:r.availableForSale:"undefined"!=typeof e.available?e.available:r.available;this.currentDocument.removeAttribute("swatch-current-variant"),null!=this.pInformation.preselect_variant&&("storefront"==S&&(r.id=s,this.pInformation.first_or_available_variant=r),this.pInformation.preselect_variant=r.id),this.currentDocument.setAttribute("swatch-generated",e.handle),this.productChangeRestructure(n,a);var c="storefront"==S?e.id.split("Product/")[1]:e.id;this.dispatchCustomEvent(this.currentDocument,"product:changed",{productID:""+c,previousProductID:i});var u=this.getInstanceConfig().data_selectors,d=null,p=null,h=null;if("storefront"==S?(h={id:c,handle:e.handle,title:e.title,url:e.onlineStoreUrl?e.onlineStoreUrl:this.multiLingualInfo.current_url+"/products/"+e.handle,price:r.price,compareAtPrice:r.compareAtPrice?r.compareAtPrice:null,variant_id:s,sku:r.sku,availableForSale:l,quantityAvailable:r.quantityAvailable,featured_image:{src:null,secondary_src:null}},e.featuredImage?(h.featured_image.src=e.featuredImage.url,h.featured_image.secondary_src=e.featuredImage.url):e.images.nodes&&e.images.nodes.length>=1&&(h.featured_image.src=e.images.nodes[0].url,h.featured_image.secondary_src=e.images.nodes[0].url),e.images.nodes&&e.images.nodes.length>=2&&(h.featured_image.secondary_src=e.images.nodes[1].url)):(h={id:e.id,handle:e.handle,title:e.title,url:e.url,price:r.price,compare_at_price:r.compare_at_price,variant_id:r.id,sku:r.sku,available:l,inventory_policy:r.inventory_policy,inventory_quantity:r.inventory_quantity,featured_image:{src:null,secondary_src:null}},e.featured_image?(h.featured_image.src=e.featured_image,h.featured_image.secondary_src=e.featured_image):e.images&&e.images.length>=1&&(h.featured_image.src=e.images[0],h.featured_image.secondary_src=e.images[0]),e.images&&e.images.length>=2&&(h.featured_image.secondary_src=e.images[1])),""!=u.title&&(p=this.currentDocument.querySelectorAll(u.title),Object.entries(p).forEach(function(e){var t=_slicedToArray(e,2),i=t[0],a=t[1];"length"!=i&&(a.innerHTML=h.title)})),this.updateGridElements(h),this.updateGridAttributes(h),this.updateVariantImages(h,u),""!=u.url&&(p=this.currentDocument.querySelectorAll(u.url),Object.entries(p).forEach(function(e){var t=_slicedToArray(e,2),i=t[0],a=t[1];"length"!=i&&(a.hasAttribute("href")&&a.setAttribute("href",h.url),a.hasAttribute("data-href")&&a.setAttribute("data-href",h.url))})),this.updateAttributes({handle:h.handle,url:h.url,product_id:h.id,variant_id:h.variant_id},u),u.form_input&&""!=u.form_input&&(d=this.currentDocument.querySelector(u.form_input))){if("SELECT"==d.tagName&&(d.value=h.variant_id,d.value!=h.variant_id)){var g=document.createElement("option");g.value=h.variant_id,g.text=h.title,d.add(g)}d.value=h.variant_id,this.dispatchEvent("change",d)}}},{key:"getSwatchMinifiedCount",value:function(e){var t=this.clientSpecs.getSwatchPresentation("collections");if("general"==e&&t.minified||"groups"==e&&t.minified_products){var i=t.minified_display_count,a=Math.ceil(1920/i.length),n=Math.floor(window.screen.width/a);return n>=i.length&&(n=i.length-1),i[n]}return null}},{key:"updateVariantImages",value:function(e){var t=arguments.length<=1||arguments[1]===undefined?null:arguments[1],i=t||this.getInstanceConfig().data_selectors,a=null;""!=i.featured_image&&(a=this.currentDocument.querySelector(i.featured_image),this.updateVariantImage(a,e,!0)),""!=i.featured_image&&""!=i.secondary_image&&(a=this.currentDocument.querySelector(i.secondary_image),this.updateVariantImage(a,e,!1))}},{key:"updateAttributes",value:function(e,t){var i=this;t.attributes.length>0&&function(){var a=i.pInformation.attrs_to_update_selectors;if(void 0===a){a="[data-product-id]";for(var n=0;nr;return i.is_on_sale=o,o&&(n=r/s*100,n=Math.round(100-n),i.percentage_difference=n),i}},{key:"updateGridAttributes",value:function(e){var t=this,i=this.getInstanceConfig().attribute_updates,a=this.getGridUpdateParams(e),n=!!window.$&&!!window.$.fn&&!!window.$.fn.data;i&&i.forEach(function(e){var i=e.selector,r=e.attribute,s=e.template;if(""!=i||""!=r){var o="["+r+"]",l=i?t.currentDocument.querySelectorAll(""+i+o):t.currentDocument.querySelectorAll(o);if(l&&l.length>0)Array.from(l).forEach(function(e){var i=t.getModifiedTemplate(s,a);e.setAttribute(r,i),n&&window.$(e).data(r.replace("data-",""),i)})}})}},{key:"generateUIForCollection",value:function(e){var t=this;if(this.clientSpecs.getEnableStatusForProductGridType()){var i=null,a=null,n=null,r={},s={},o=null,l=undefined;if(e){if("A"!=(l=e.target).tagName&&(e.preventDefault(),e.stopPropagation()),"LI"==l.tagName&&l.hasAttribute("orig-value")&&l.children&&(l=l.children[0]),"keyup"==e.type&&13!==e.keyCode)return;for(;l.hasAttribute("swatch-inside")||"FONT"==l.tagName||"SVG"==l.tagName||"I"==l.tagName;)l=l.parentNode;if(this.isClickEvent(e.type)&&l.hasAttribute("data-navigation"))return void this.scrollSwatchSlider(l,!1);var c="mouseover"==e.type,u="mouseout"==e.type,d=c||u,p=d&&!this.selectionAllowed&&!this.pInformation.product_switched;if(!l.hasAttribute("swatch-option"))return void(u&&p&&this.pInformation.image_replaced_by_hover&&(this.updateVariantImages({}),this.pInformation.image_replaced_by_hover=!1));if("SELECT"==l.tagName&&"change"!=e.type)return;if(c&&p){var h=null,g=l.getAttribute("swatch-url");if(n=l.getAttribute("swatch-option"),a=l.getAttribute("orig-value"),g){var f=l.closest("[data-group-index]").getAttribute("data-group-index"),v=this.getProductsGroups([f])[0],m=g.split("/products/");m=m[m.length-1];for(var _=0;_'+t.labelSplitSymbol+" "+i),t.uiElements.selectSwatch(e,l,i)}t.resetMultiLingualData();var n=l.closest("[option-target]"),r=t.productInfoTree.getProductInfo().id,s="SELECT"==l.tagName?l.value:l.getAttribute("swatch-url");if(t.selectionAllowed=!1,t.hasOnlyDefaultVariant=!1,t.pInformation.product_switched=!0,t.productInfoTree=new H,"storefront"==S){var o=s.split("/products/")[1],c=window.Shopify.locale;t.executeFetch({handle:o,locale:c,path_name:null,allow_processing:!0,callback:function(e){t.productChangeOperations(e,n,r)},translation_request:!1})}else t.executeFetch({url:s+".js",path_name:null,allow_processing:!0,callback:function(e){t.productChangeOperations(e,n,r)},translation_request:!1});return{v:undefined}}();if("object"==typeof A)return A.v}if(!(e&&"SELECT"==l.tagName&&l.options&&l.options.length>1&&this.isClickEvent(e.type))){if(e&&"select"==l.getAttribute("type")){var I=l,T=l.parentNode.querySelector("ul.swatch-drop-down-list"),x="true"==I.getAttribute("aria-expanded");return I.setAttribute("aria-expanded",!x),void T.classList.toggle("swatch-hide")}if(e&&"select_value"==l.getAttribute("type"))(I=l.closest("div.swatch-drop-down-inner").querySelector('div[type="select"]')).style.minWidth&&"0px"!=I.style.minWidth||this.setSelectMinWidth(I),I.innerHTML=l.innerHTML,I.setAttribute("aria-label",l.innerText),I.setAttribute("aria-expanded",!1),l.parentNode.classList.add("swatch-hide");if(e&&l.hasAttribute("swatch-option")){if(n=l.getAttribute("swatch-option"),i=n,this.uiElements.isDropDown(l.tagName))l.hasAttribute("data-selected")&&(l.remove(0),l.removeAttribute("data-selected")),a=l.value;else{a=l.getAttribute("orig-value");var C=l.closest("[option-target]").querySelector("span.swatch-variant-name");C&&"null"!=a&&(C.innerHTML=' '+this.labelSplitSymbol+" "+a)}if(e&&this.pInformation.preselect_variant)"option"+this.productInfoTree.getOptions().length==n&&(this.pInformation.preselect_variant=0),this.selectionAllowed=!0;if(this.selectionAllowed||this.isEventTrusted(e,!0)){if(this.selectionAllowed=!0,this.uiElements.selectSwatch(n,l,a),r=this.getCurrentOptionForCollection(),o=this.productInfoTree.getVariantInfoFromOptions(r),"storefront"==S&&o){b=o.id.split("ProductVariant/")[1]?o.id.split("ProductVariant/")[1]:o.id;o.id=b}var E=!0,D=this.currentDocument.getAttribute("swatch-current-variant");if(D||(D="0"),o&&(this.currentDocument.setAttribute("swatch-current-variant",o.id),this.dispatchCustomEvent(this.currentDocument,"variant:changed",{productID:""+this.productInfoTree.getProductInfo().id,variant:""+o.id,previousVariant:D,variantInformation:JSON.stringify(o)})),(o&&D==o.id||this.currentDocument.hasAttribute("sa-manual-update"))&&(E=!1),o&&E){var O=this.getInstanceConfig().data_selectors,L=null,N=null;this.updateVariantImages(o,O),""!=O.url&&function(){L=t.currentDocument.querySelectorAll(O.url);var e=/(?:variant=)[0-9]*/gm;Object.entries(L).forEach(function(t){var i=_slicedToArray(t,2),a=i[0],n=i[1];if("length"!=a&&n&&o.id){var r=n.hasAttribute("href")?n.getAttribute("href"):"",s=e.exec(r),l="variant="+o.id;s||(s=e.exec(r.toString())),s?r=r.replace(s[0],l):r.includes("?")?r+="&"+l:r+="?"+l,n.hasAttribute("href")&&n.setAttribute("href",r),n.hasAttribute("data-href")&&n.setAttribute("data-href",r)}})}();var P=this.productInfoTree.getProductInfo().handle;if(this.updateAttributes({handle:P,url:"/products/"+P+"?variant="+o.id,product_id:null,variant_id:o.id},O),this.updateGridElements(_extends({variant_id:o.id},o)),this.updateGridAttributes(_extends({variant_id:o.id},o)),O.form_input&&""!=O.form_input&&(N=this.currentDocument.querySelector(O.form_input))){if("SELECT"==N.tagName&&(N.value=o.id,N.value!=o.id)){var M=document.createElement("option");M.value=o.id,M.text=o.title,N.add(M)}N.value=o.id,this.dispatchEvent("change",N)}}}}if(this.readyToInit()){this.uiElements.getIsSwatchRootDisplayed()||this.uiElements.renderSwatchRoot(this.uiElements.getSwatchRoot(this.productInfoTree.getOptions()),this.getCorrectSwatchRoot()),r=this.getCurrentOptionForCollection();var q=undefined;q=w?w.trim():this.multiLingualInfo.money_format.trim(),s=this.productInfoTree.getNodeByOptions(r,q,this.getMoneyWithFormat.bind(this)),Object.entries(s).forEach(function(e){var a=_slicedToArray(e,2),n=a[0],s=a[1];if(null==i){var o=t.uiElements.getViewByType(s.view_type_preset).getView(n,s),l=t.uiElements.renderNormal(n,o,t.getCorrectSwatchRoot());1==s.data.length&&"null"==s.data[0].value&&l.length>0&&l[0].closest&&(l[0].closest("div.swatch-single").style.display="none"),B("Generated UI for - "+n);var c=r[n],u=!1,d=t.getSwatchMinifiedCount("general"),p=s.view_type_preset;Object.entries(l).forEach(function(e){var a=_slicedToArray(e,2),n=a[0],r=a[1];if("length"!=n){var o=n==l.length-1;if(null!=d&&("swatch"==p.assoc_view_type||"button"==p.assoc_view_type)){var h=null;if(n>=d){var g=r.closest("li.swatch-view-item");g&&(h=g)}if(o){var f=l.length-d;if(f>0){var v=r.closest("[option-name]").getAttribute("option-name"),m=t.uiElements.getMinifiedHTML(v,f,t.productInfoTree.getProductInfo());r.closest("ul.swatch-view").appendChild(m)}if((b=r.closest(".swatch-navigable, variant-swatch-king"))&&"VARIANT-SWATCH-KING"!=b.tagName){b.querySelector(".swatch-navigation");var _=r.closest(".swatch-navigable");t.resSliderSize(_,p.params,p.assoc_view_type)}}if(h)return void t.removeElement(h)}var y=null;if(setTimeout(function(){var e="swatch-allow-animation";r.classList.add(e)},128),t.uiElements.isDropDown(r.tagName)||"true"==r.getAttribute("custom-select")){t.getLabelWidth(r,p.params.padding_left),y=r.value;for(var w=r.querySelectorAll("li"),S=0;S0)return i}return e}},{key:"getHandleFromURL",value:function(e){var t=e.split("/");return(t=(t=t[t.length-1]).split(RegExp("\\?|\\#|\\.js","gi")))[0]}},{key:"getSessionStorageKey",value:function(e,t,i){var a=!(arguments.length<=3||arguments[3]===undefined)&&arguments[3],n=arguments.length<=4||arguments[4]===undefined?null:arguments[4],r=arguments.length<=5||arguments[5]===undefined?null:arguments[5];if(window.sessionStorage){var s=t?this.getHandleFromURL(e):e,l=this.getMultiLingualInfo(),c=n;c||(c=window.Shopify&&window.Shopify.country?window.Shopify.country:"NULL");var u=r;return u||(u=(u=o(i?l.default_language:l.current_language)).toUpperCase()),"storefront"==S?"starapps_storefront_"+s+"_"+u+"_"+c:a?"starapps_storefront_"+s+"_"+u+"_"+c:"starapps_"+s+"_"+u+"_"+c}return null}},{key:"getDataFromSessionStorage",value:function(e){if(window.sessionStorage&&"string"==typeof e){var t=sessionStorage.getItem(e);if(t)return JSON.parse(t)}return null}},{key:"setDataToSessionStorage",value:function(e,t){if(window.sessionStorage&&"string"==typeof e&&"object"==typeof t){var i=function(){var i=(new Date).getTime();null!=t?t.created_at=i:t={id:null,created_at:i};var a=JSON.stringify(t);return setTimeout(function(){try{sessionStorage.setItem(e,a)}catch(t){}},0),{v:!0}}();if("object"==typeof i)return i.v}return!1}},{key:"removeDataToSessionStorage",value:function(e){return!(!window.sessionStorage||"string"!=typeof e)&&(sessionStorage.removeItem(e),!0)}},{key:"disableAdd2CartButton",value:function(e,t){var i=this.clientSpecs.getSelectors(),a=this.currentDocument.querySelectorAll(i.add_to_cart_selector);Object.entries(a).forEach(function(a){var n=_slicedToArray(a,2),r=n[0],s=n[1];if("length"!=r)if(s.setAttribute("disabled","disabled"),""!=t.trim()&&(s.className=t),"INPUT"==s.tagName)s.hasAttribute("original-text")||s.setAttribute("original-text",s.value),s.value=e;else if("BUTTON"==s.tagName){var o=s;s.children.length>0&&(o=s.querySelector(i.add_to_cart_text_selector)),o&&(s.hasAttribute("original-text")||s.setAttribute("original-text",o.innerHTML),o.innerHTML=e)}})}},{key:"restoreAddToCart",value:function(){var e=this,t=this.clientSpecs.getSelectors(),i=this.currentDocument.querySelectorAll(t.add_to_cart_selector);Object.entries(i).forEach(function(i){var a=_slicedToArray(i,2),n=a[0],r=a[1];if("length"!=n)if(r.removeAttribute("disabled"),e.clientSpecs.getSelectors().add_to_cart_enabled_classes&&""!=e.clientSpecs.getSelectors().add_to_cart_enabled_classes.trim()&&(r.className=e.clientSpecs.getSelectors().add_to_cart_enabled_classes),"INPUT"==r.tagName&&r.hasAttribute("original-text")){var s=r.getAttribute("original-text");r.removeAttribute("original-text"),r.value=s}else if("BUTTON"==r.tagName){var o=r;if(r.children.length>0&&(o=r.querySelector(t.add_to_cart_text_selector)),o&&r.hasAttribute("original-text")){s=r.getAttribute("original-text");r.removeAttribute("original-text"),o.innerHTML=s}}})}},{key:"getOptionIndexKey",value:function(e,t){ var i=this.clientSpecs.getSelectors().option_index_attributes,a=t;if("undefined"==typeof this.themeSupportConfig.attribute_name||"none"!=this.themeSupportConfig.attribute_name&&e.hasAttribute(this.themeSupportConfig.attribute_name)){for(var n=0;n0)for(var y=0;y<_.length;y++){var w=_[y],S=r.getAttribute(w);if(S){m=S;break}}}var b=this.themeSupportConfig.index_strategy,k=this.productInfoTree.getOptionKeyByName(m,f,b,this.morphValues.bind(this));this.themeSupportConfig.index_strategy=k[1],(g=k[0])==o&&(o=this.productInfoTree.getOptionNameByKey(g)),this.themeSupportConfig.key_mapping[o]=g}else o||(g="option"+(n+1));r.checked||"SELECT"==r.tagName?t[g]=s:l&&r.matches(a.selected_selector)?t[g]=s:"undefined"==typeof t[g]&&(t[g]=s)}return t=this.sortObjectByKeys(t)}},{key:"getCurrentOptionPrestige",value:function(){for(var e={},t=this.currentDocument.querySelectorAll(this.themeSupportConfig.option_selector),i=0;i0)for(var b=0;b0&&c==r.length-1&&(d=!0,u=o[0]);var f=d&&a.value!=u.id;if(d&&this.doNotSelectAnOption.status&&this.doNotSelectAnOption.trusted_event_detected&&(f=!0),f){this.themeSupportConfig.last_variant_id=u.id,a.value=u.id,this.dispatchEvent("change",a);var v=a.closest("[data-section-type]");if(v){var m={variant:n[u.id]};this.dispatchThemeEvent("variantChange",v,m)}var _=this.currentDocument.querySelector(this.clientSpecs.getSelectors().add_to_cart_selector);_&&(""==a.value?_.setAttribute("disabled",!0):_.removeAttribute("disabled"));var y=z();this.allOptionsData.variantId!=y&&(this.allOptionsData.variantId=y,this.dispatchCustomEvent(a,"product:variant:changed",this.allOptionsData));break}if(!f&&d)break}}},{key:"changeSwitch",value:function(e){switch(e){case"common":return{change:this.triggerChange.bind(this)};case"prestige":return{change:this.triggerChangePrestige.bind(this)};case"motion":return{change:this.triggerChangeMotion.bind(this)};case"dawn":return{change:this.triggerChangeDawn.bind(this)}}}},{key:"generateUISwitch",value:function(){return this.isInstanceTypeCollection()?this.generateUIForCollection.bind(this):this.generateUI.bind(this)}},{key:"generateUI",value:function(e){var t=this,i=null,a=null,n=null,r=null,s={},o={},l=!1,c=!1,u=undefined,d=undefined,p="optionValueName";d=w?w.trim():this.multiLingualInfo.money_format.trim();var h=z(this.currentDocument);if(this.allOptionsData.variantId=h,e){if("LI"==(u=e.target).tagName&&u.hasAttribute("orig-value")&&u.children&&(u=u.children[0]),"keyup"==e.type&&13!==e.keyCode)return;for(;u.hasAttribute("swatch-inside")||"FONT"==u.tagName||"SVG"==u.tagName||"I"==u.tagName;)u=u.parentNode;if(this.isClickEvent(e.type)&&u.hasAttribute("data-navigation"))return void this.scrollSwatchSlider(u,!1);if(!u.hasAttribute("swatch-option"))return;if("SELECT"==u.tagName&&"change"!=e.type)return}if(e&&u.hasAttribute("swatch-url")&&this.isEventTrusted(e,!0)&&window.encodeURIComponent&&(this.isClickEvent(e.type)&&"SELECT"!=u.tagName||"change"==e.type&&"SELECT"==u.tagName)){if(u.hasAttribute("current-product"))return;var g="";if(!this.hasOnlyDefaultVariant&&!this.hasOnlySingleVariant){var f=this.currentOptionSwitch(this.themeCode).get(),v=Object.keys(f);if(this.clientSpecs.getPersistGroupVariant()){var m=this.productInfoTree.getVariantByVariantId(h),_=this.productInfoTree.getOptions();"storefront"===S&&f.option1&&_.length>0&&(p=this.findMatchingOption(_[0].optionValues,f.option1));for(var y=0;y0&&(k=m.selectedOptions[y].value),g+="&"+b+"="+encodeURIComponent(k)}""!=g&&(g=g.replace(RegExp("^&","gi"),"?"))}}var A=u.getAttribute("swatch-url");"SELECT"==u.tagName&&(A=u.value);var I=A+g;this.clientSpecs.getHistoryFreeGroupNavigation()?window.location.replace(I):window.location.assign?window.location.assign(I):window.location.href=I}else{if(e&&"select"==u.getAttribute("type")){var T=u,x=u.parentNode.querySelector("ul.swatch-drop-down-list"),C="true"==T.getAttribute("aria-expanded");return T.setAttribute("aria-expanded",!C),void x.classList.toggle("swatch-hide")}if(e&&"select_value"==u.getAttribute("type"))(T=u.closest("div.swatch-drop-down-inner").querySelector('div[type="select"]')).style.minWidth&&"0px"!=T.style.minWidth||this.setSelectMinWidth(T),T.innerHTML=u.innerHTML,T.setAttribute("aria-label",u.innerText),T.setAttribute("aria-expanded",!1),u.parentNode.classList.add("swatch-hide");if(e&&this.doNotSelectAnOption.status){var E=u.getAttribute("swatch-option"),D=parseInt(E[6])-1,O=this.productInfoTree.getOptions()[D],L="undefined"!=typeof O.untranslated_name?O.untranslated_name:O.name,N=this.clientSpecs.getTriggerActionByOptionName(L),P=O.values,M="virtual_click"==e.type||"change"==e.type&&!this.isEventTrusted(e,!0);if(this.doNotSelectAnOption.option_name=O.name,this.doNotSelectAnOption.trusted_event_detected=!1,"manual"==N&&P.length>1){if(this.dispatchCustomEvent(this.currentDocument,"manual:selection:hold",this.allOptionsData),window.starapps_stock_data?window.starapps_stock_data.show_stock_alert=!1:(window.starapps_stock_data={},window.starapps_stock_data.show_stock_alert=!1),!this.doNotSelectAnOption[E]&&M){var q=this.getTranslation(this.doNotSelectAnOption.text);q=q.replace(/{{\s*option_name\s*}}/gm,O.name);var V=u.closest("div.swatch-single").querySelector("label.swatch-label");if(this.uiElements.isDropDown(u.tagName)){var R=document.createElement("option");R.value="",R.innerHTML=q,u.insertBefore(R,u.options[0]),u.selectedIndex=0}else if("select_value"==u.getAttribute("type")){var F=u.closest(".swatch-drop-down-inner");if(F)(F=F.querySelector('[type="select"]')).querySelector("span").innerHTML=q,this.setSelectMinWidth(F)}else V.hasAttribute("original-text")||V.setAttribute("original-text",V.innerHTML),V.innerHTML=''+q;if(!this.doNotSelectAnOption.allow_virtual_trigger){if(this.doNotSelectAnOption.control_add_to_cart)W=(W=this.getTranslation(this.doNotSelectAnOption.make_a_selection_text)).replace(/{{\s*option_name\s*}}/gm,this.doNotSelectAnOption.option_name),this.disableAdd2CartButton(W,this.clientSpecs.getSelectors().add_to_cart_disabled_classes);return}l=!0}else if(!M){this.doNotSelectAnOption.trusted_event_detected=!0,this.restoreAddToCart();var H=(V=u.closest("div.swatch-single").querySelector("label.swatch-label")).getAttribute("original-text");H&&(V.removeAttribute("original-text"),V.innerHTML=H),this.uiElements.isDropDown(u.tagName)&&!this.doNotSelectAnOption[E]&&u.remove(0),this.doNotSelectAnOption[E]||(this.doNotSelectAnOption.count+=1,this.doNotSelectAnOption[E]=!0)}}else this.doNotSelectAnOption[E]||(this.doNotSelectAnOption.count+=1,this.doNotSelectAnOption[E]=!0)}if(!(e&&this.uiElements.isDropDown(u.tagName)&&u.options&&u.options.length>1&&this.isClickEvent(e.type))){if(e&&u.hasAttribute("swatch-option")){if(r=u.getAttribute("swatch-option"),i=r,this.uiElements.isDropDown(u.tagName))a=u.value;else{a=u.getAttribute("orig-value"),n=u.getAttribute("option-value-id");var j=u.closest("[option-target]").querySelector("span.swatch-variant-name"),U=u.getAttribute("data-value");j&&"null"!=a&&"none"!=U&&(j.innerHTML=' '+this.labelSplitSymbol+" "+U)}var W;if(l||this.uiElements.selectSwatch(r,u,a),this.changeSwitch(this.themeCode).change(r,a,n),l)if(this.doNotSelectAnOption.control_add_to_cart)W=(W=this.getTranslation(this.doNotSelectAnOption.make_a_selection_text)).replace(/{{\s*option_name\s*}}/gm,this.doNotSelectAnOption.option_name),this.disableAdd2CartButton(W,this.clientSpecs.getSelectors().add_to_cart_disabled_classes)}if(this.readyToInit()){this.doNotSelectAnOption.status&&this.doNotSelectAnOption.count>=this.productInfoTree.getOptions().length&&(this.doNotSelectAnOption.status=!1,window.starapps_stock_data?window.starapps_stock_data.show_stock_alert=!0:(window.starapps_stock_data={},window.starapps_stock_data.show_stock_alert=!0),this.dispatchCustomEvent(this.currentDocument,"selection:release",this.allOptionsData));var G=this.getCorrectSwatchRoot();if(this.uiElements.getIsSwatchRootDisplayed()||this.uiElements.renderSwatchRoot(this.uiElements.getSwatchRoot(this.productInfoTree.getOptions()),G),s=this.currentOptionSwitch(this.themeCode).get(),B(s),"undefined"==typeof s.option1){B("currentOption was not properly formed!");for(var J=this.productInfoTree.getOptions(),K=0;K0&&v[0].closest&&(v[0].closest("div.swatch-single").style.display="none"),B("Generated UI for - "+a);var m=s[a],_=!1;if(Object.entries(v).forEach(function(e){var a=_slicedToArray(e,2),r=a[0],s=a[1];if("length"!=r){var o=null,l=null;if(setTimeout(function(){var e="swatch-allow-animation";s.classList.add(e)},128),t.uiElements.isDropDown(s.tagName)){t.getLabelWidth(s,n.view_type_preset.params.padding_left),o=s.value;var u=s.querySelectorAll("option"),d=!0,h=!1,g=undefined;try{for(var f,w=u[Symbol.iterator]();!(d=(f=w.next()).done);d=!0){if((C=f.value).getAttribute("value")===m){o=m,s.value=m;break}}}catch(y){h=!0,g=y}finally{try{!d&&w["return"]&&w["return"]()}finally{if(h)throw g}}}else if("true"===s.getAttribute("custom-select")){t.getLabelWidth(s,n.view_type_preset.params.padding_left),o=s.getAttribute("aria-label");var S=s.closest(".swatch-drop-down-inner");if(S)if((u=S.querySelectorAll(".swatch-drop-down-list li")).length>0){var b=!1,k=!0,A=!1,I=undefined;try{for(var T,x=u[Symbol.iterator]();!(k=(T=x.next()).done);k=!0){var C;if((C=T.value).getAttribute("value")===m||C.getAttribute("option-value-id")===m){o=m,l=m,b=!0;break}}}catch(y){A=!0,I=y}finally{try{!k&&x["return"]&&x["return"]()}finally{if(A)throw I}}b||(m=u[0].getAttribute("orig-value"),"optionValueName"==p&&(m=u[0].getAttribute("option-value-id")))}else B("This is custom select, option values are not found!")}else o=s.getAttribute("orig-value"),l=s.getAttribute("option-value-id");if(o!=m&&l!=m||(_=!0,t.uiElements.isDropDown(s.tagName)?t.dispatchEvent("change",s):t.dispatchEvent("virtual_click",s)),r==v.length-1){var E=s.closest(".swatch-navigable, variant-swatch-king"),D=s.closest(".swatch-view-stack, variant-swatch-king");if(E&&"VARIANT-SWATCH-KING"!=E.tagName){E.querySelector(".swatch-navigation");var O=s.closest(".swatch-navigable");t.resSliderSize(O,n.view_type_preset.params,n.view_type_preset.assoc_view_type)}else if(D&&"VARIANT-SWATCH-KING"!=D.tagName){O=s.closest(".swatch-view-stack");t.resStackSize(O,n.view_type_preset.params,n.view_type_preset.assoc_view_type)}i="None",_||(t.uiElements.isDropDown(v[0].tagName)?t.dispatchEvent("change",v[0]):t.dispatchEvent("virtual_click",v[0]),c=!0)}}}),c)return"break"};e:for(var le,ce=Object.entries(o)[Symbol.iterator]();!(ne=(le=ce.next()).done);ne=!0){var ue,de,pe,he,ge;switch(oe()){case"continue":continue;case"break":break e}}}catch(fe){re=!0,se=fe}finally{try{!ne&&ce["return"]&&ce["return"]()}finally{if(re)throw se}}}}}}},{key:"getMatchingOptionId",value:function(e,t){var i=e.optionValues[0].id.match(/\d+/)[0],a=e.optionValues.find(function(e){return e.name.toLowerCase()===t.toLowerCase()});return a?a.id.match(/\d+/)[0]:i}},{key:"getMatchingOptionName",value:function(e,t){var i=e.optionValues[0].name,a=e.optionValues.find(function(e){return e.name.toLowerCase()===t.toLowerCase()});return a?a.name:i}},{key:"findMatchingOption",value:function(e,t){var i=t.toLowerCase(),a=!0,n=!1,r=undefined;try{for(var s,o=e[Symbol.iterator]();!(a=(s=o.next()).done);a=!0){var l=s.value;if(l.name.toLowerCase()===i)return"optionValueName";if(l.id.match(/\d+/)[0]===t)return"optionValueId"}}catch(c){n=!0,r=c}finally{try{!a&&o["return"]&&o["return"]()}finally{if(n)throw r}}return"optionValueName"}},{key:"resSliderSize",value:function(e,t,i){var a=this,n=window.matchMedia?window.matchMedia("screen and (max-width: 768px)"):screen.width<=768,r=e.closest(".swatch-navigable-wrapper"),s="li.swatch-view-item",o=e.querySelector("ul.swatch-view"),l=o.querySelectorAll(s).length,c=e.querySelector('[navigation="left"]'),u=e.querySelector('[navigation="right"]'),d=e.getBoundingClientRect().width,p=r?r.getBoundingClientRect().width:null,h=undefined,g=undefined,f=undefined,v=undefined,m=undefined,_=undefined,y=undefined,w=undefined,S=undefined,b=undefined,k=t.arrow_mode,A=undefined,I=t.adjust_margin_right;n.matches&&(k=t.mobile_arrow_mode,I=t.mobile_adjust_margin_right);var T=parseFloat(t.margin_right.match(/[\d\.]+/g)),x=T;"swatch-pill"==t.swatch_type||"button"==i?(_=0,o.querySelectorAll(s).forEach(function(e,t){e.style.width=e.getBoundingClientRect().width+"px",_=_+e.getBoundingClientRect().width+x,e.firstChild.classList.contains("swatch-selected")&&(S=(_-e.getBoundingClientRect().width)/(.8*d),b=t,"mode_4"==k&&(r.querySelector(".swatch-navigable").setAttribute("data-current-scroll",t),e.scrollIntoView({behavior:"auto",block:"nearest",inline:"start"}))),0==t&&(y=e.getBoundingClientRect().width),t==l-1&&(w=e.getBoundingClientRect().width,_-=x)})):function(){h=parseFloat(t.width.match(/[\d\.]+/g)),g=parseFloat(t.border_width.match(/[\d\.]+/g));var e=t.border_space||t.margin_swatch_horizontal;f=parseFloat(e.match(/[\d\.]+/g)),v=h+2*g+2*f;var i=t.last_swatch_preview;n.matches&&(i=t.mobile_last_swatch_preview);var a=(d+x)/(v+x);"mode_2"!=k&&"mode_3"!=k||(a=(p+x)/(v+x));var r=0;if(a>=l&&!I)r=parseInt(a);else{switch(i){case"full":if(a=(d+x)/(v+x),r=parseInt(a),A=d-r*v,(x=Math.max(A/(r>1?r-1:1),T))>A/(r>1?r-1:1)){var c=d-(r-1)*x;r=Math.floor(c/v)}break;case"half":var u=(d-(Math.floor(a)*v+Math.floor(a)*x))/v*100,y=undefined;if((u<20||u>80)&&a>1)if(u<20){y=80,r=Math.floor(a)-1;var w=y/100*v;x=parseFloat(((d-(r*v+w))/r).toFixed(3))}else{w=(y=80)/100*v;var C=Math.floor(a)+w/v;r=Math.floor(C),x=parseFloat(((d-(r*v+w))/r).toFixed(3))}else r=Math.floor(a)}var E=o.querySelector(s+":last-child");E&&(E.style.width=v+"px")}m=r,_=(v+x)*(l-1)+v,o.querySelectorAll(s).forEach(function(e,t){e.firstChild instanceof Element&&e.firstChild.classList.contains("swatch-selected")&&(S=m>0?(v+x)*t/(m*(v+x)):0,"half"==i?"mode_1"==k&&(S=m>2?(v+x)*t/((m-2)*(v+x)):t-m>=0?t-m+1:0):S=m>2?(v+x)*t/((m-2)*(v+x)):0,b=t),t!=l-1&&(e.style.width=v+"px",e.style.marginRight=x+"px")})}(),o.parentElement.setAttribute("swatch-slider","true");var C={swatchSliderItemWidth:v||0,totalScrollWidth:_,sliderWidth:d,visibleSwatches:m||0,marginRight:x,swatchType:t.swatch_type,firstSwatchWidth:y,lastSwatchWidth:w,assocViewType:i,arrowMode:k};o.style.transform="translateX(0px)",o.style.display="flex";var E=o.closest("[option-name]");if("mode_2"!=k&&"mode_3"!=k&&"mode_4"!=k||(d=p),m>=l||d>=_){if(c.classList.remove("star-show"),u.classList.remove("star-show"),"mode_2"==k||"mode_3"==k)e.classList.add("star-remove-margin"),C.sliderWidth=e.getBoundingClientRect().width;else if("mode_4"==k)return e.closest(".swatch-navigable").style.margin="0px",void(e.closest(".swatch-navigable").style.width="100%");return o.parentElement.setAttribute("data-slider-data",JSON.stringify(C)),!1}if(u.classList.add("star-show"),u.classList.remove("star-disabled"),o.style.setProperty("justify-content","unset"),o.style.setProperty("width",_+"px","important"),"mode_2"==k||"mode_3"==k)c.classList.add("star-show","star-disabled"),e.classList.remove("star-remove-margin"),C.sliderWidth=e.getBoundingClientRect().width;else if("mode_0"==k)c.classList.remove("star-show"),u.classList.remove("star-show");else if("mode_4"==k){e.style.margin="auto",u.classList.add("star-show"),c.classList.add("star-show"),u.classList.remove("star-disabled"),c.classList.remove("star-disabled");var D=c.getBoundingClientRect().width+u.getBoundingClientRect().width;return void(e.closest(".swatch-navigable").style.width="calc(100% - "+D+"px)")}return S=parseInt(S),setTimeout(function(){for(var t=0;t=t.touches[0].clientX?a.clickToScroll(1,e.closest(".swatch-navigable")):a.clickToScroll(0,e.closest(".swatch-navigable")))}),o.addEventListener("touchend",function(){r=0}))},200),o.parentElement.setAttribute("data-slider-data",JSON.stringify(C)),!0}},{key:"resStackSize",value:function(e,t,i){if("swatch-pill"!=t.swatch_type&&"button"!=i&&t.adjust_margin_right){var a=window.matchMedia?window.matchMedia("screen and (max-width: 480px)"):screen.width<=480,n=t.adjust_margin_right;if(a.matches&&(n=t.mobile_adjust_margin_right),n){var r=e.querySelector("ul.swatch-view");r&&(s="li.swatch-view-item",r.querySelectorAll(s).length,o=e.getBoundingClientRect().width,undefined,l=parseFloat(t.width.match(/[\d\.]+/g)),c=parseFloat(t.border_width.match(/[\d\.]+/g)),u=t.border_space||t.margin_swatch_horizontal,d=parseFloat(u.match(/[\d\.]+/g)),p=parseFloat(t.margin_right.match(/[\d\.]+/g)),h=parseInt((o+p)/(l+2*c+2*d+p)),r.querySelectorAll(s).forEach(function(e,t){(t+1)%h==0&&(e.style.marginRight=0)}))}}var s,o,l,c,u,d,p,h}},{key:"getOptionValueId",value:function(e,t){var i=e.find(function(e){return e.name===t});return i?i.id.split("ProductOptionValue/")[1]:null}},{key:"morphValues",value:function(e){return this.clientSpecs.getHandleize()?e=(e=(e=(e=(e=e.toLowerCase()).replace(RegExp("['\"\\(\\)\\{\\}\\[\\]]","gi"),"")).replace(RegExp("[^a-z0-9_]+","gi"),"-")).replace(RegExp("-+","gi"),"-")).replace(RegExp("^-|-$","gi"),""):e}},{key:"checkValidPrice",value:function(e,t){var i=arguments.length<=2||arguments[2]===undefined?null:arguments[2],a=arguments.length<=3||arguments[3]===undefined?null:arguments[3];return null==i?e[t]!=undefined:null==a?e[t][i]!=undefined:e[t][i]!=undefined&&e[t][i][a]!=undefined}},{key:"getOption1Price",value:function(e,t){return{min_price:e[t].min_price,max_price:e[t].max_price,is_equal:e[t].min_price==e[t].max_price}}},{key:"getOption2Price",value:function(e,t,i){return{min_price:e[t][i].min_price,max_price:e[t][i].max_price,is_equal:e[t][i].min_price==e[t][i].max_price}}},{key:"getOption3Price",value:function(e,t,i,a){return{min_price:e[t][i][a].min_price,max_price:e[t][i][a].max_price,is_equal:e[t][i][a].min_price==e[t][i][a].max_price}}},{key:"getOptionPriceInfo",value:function(e){var t=arguments.length<=1||arguments[1]===undefined?null:arguments[1],i=arguments.length<=2||arguments[2]===undefined?null:arguments[2],a=this.productInfoTree.getOptionValueByOptionId(e),n=this.productInfoTree.getOptionValueByOptionId(t),r=this.productInfoTree.getOptionValueByOptionId(i);w=w?w.trim():this.multiLingualInfo.money_format.trim();var s=this.productInfoTree.getPriceInfoTree(),o=null;if(null==n)o=(u=this.getOption1Price(s,a)).is_equal?this.getMoneyWithFormat(w,u.min_price):this.getMoneyWithFormat(w,u.min_price)+"+";else if(null==r){if(this.checkValidPrice(s,a,n))o=(c=this.getOption2Price(s,a,n)).is_equal?this.getMoneyWithFormat(w,c.min_price):this.getMoneyWithFormat(w,c.min_price)+"+";else o=(u=this.getOption1Price(s,a)).is_equal?this.getMoneyWithFormat(w,u.min_price):this.getMoneyWithFormat(w,u.min_price)+"+"}else if(this.checkValidPrice(s,a,n,r)){var l=this.getOption3Price(s,a,n,r);o=l.is_equal?this.getMoneyWithFormat(w,l.min_price):this.getMoneyWithFormat(w,l.min_price)+"+"}else if(this.checkValidPrice(s,a,n)){var c;o=(c=this.getOption2Price(s,a,n)).is_equal?this.getMoneyWithFormat(w,c.min_price):this.getMoneyWithFormat(w,c.min_price)+"+"}else{var u;o=(u=this.getOption1Price(s,a)).is_equal?this.getMoneyWithFormat(w,u.min_price):this.getMoneyWithFormat(w,u.min_price)+"+"}return o}},{key:"updateSecondaryAndLastImage",value:function(e,t){return e.featured_image&&(e.featured_image.secondary_src=e.featured_image.src,e.featured_image.last_src=e.featured_image.src,void 0!==t&&t.length>1&&(e.featured_image.secondary_src=t[1],e.featured_image.last_src=t[t.length-1])),e}},{key:"updateSessionStorageProductData",value:function(e){var t=arguments.length<=1||arguments[1]===undefined?null:arguments[1],i=arguments.length<=2||arguments[2]===undefined?null:arguments[2];if("storefront"==S){var a=e.id.match(/\d+/)[0];this.setDataToSessionStorage(this.getSessionStorageKey(e.handle,!1,!1,!1,t,i),e),this.setDataToSessionStorage(this.getSessionStorageKey(a,!1,!1,!1,t,i),e)}else this.setDataToSessionStorage(this.getSessionStorageKey(e.handle,!1,!1),e)}},{key:"processJSONInformation",value:function(e){var t=this,i=arguments.length<=1||arguments[1]===undefined?null:arguments[1],a=e.options,n=e.variants,r=e.images,s={},o={},l="storefront"==S?e.id.split("Product/")[1]:e.id;if("storefront"==S){if(n=e.variants?e.variants.nodes:null,r=e.images?e.images.nodes.map(function(e){return e.url}):null,n&&r)for(var c=e.images.nodes.reduce(function(e,t,i){return e[t.id]=i+1,e},{}),u=0;u0&&"undefined"==typeof n[0].merged_options&&this.updateSessionStorageProductData(e,m,_) ;for(u=0;u=0;K--){var $=f[H][K];if($!=undefined&&(z=$.name==j&&$.value==n[u][H])){G=J-K;break}}if(z)null!=V&&(q&&(V.available=q),R>=0&&(V.min_price=V.min_price&&R>V.min_price?V.min_price:R,V.max_price=V.max_price&&R1&&(X.featured_image.secondary_src=Z[1],X.featured_image.last_src=Z[Z.length-1])}null!=V&&q&&(V.available=q),null!=V&&R>=0&&(V.min_price=V.min_price&&R>V.min_price?V.min_price:R,V.max_price=V.max_price&&R0&&(ee=e.images.nodes[0].url):(!(ee=e.featured_image)&&e.images&&e.images.length>0&&(ee=e.images[0]),ee&&"object"==typeof ee&&(ee=ee.src)),this.isInstanceTypeCollection()&&(this.currentDocument.hasAttribute("swatch-default-variant")?(this.pInformation.preselect_variant=this.currentDocument.getAttribute("swatch-default-variant"),this.currentDocument.removeAttribute("swatch-default-variant")):this.clientSpecs.getCollectionPreselectVariant()&&(this.pInformation.preselect_variant=this.pInformation.first_or_available_variant.id)),this.uiElements.setDefaultFeaturedImage(ee),this.productInfoTree.setValues(v,a,s,N),B(["Processed JS data structure",this.productInfoTree])}else if(e.handle&&""!=e.handle){var te=window.Shopify.locale;"storefront"==S?this.executeFetch({handle:e.handle,locale:te,path_name:null,allow_processing:!1,callback:function(e,i){t.processJSONInformation(e,i)},translation_request:!1}):this.executeFetch({url:this.getMultiLingualInfo().current_url+"/collections/all/products/"+e.handle+".js",path_name:null,allow_processing:!1,callback:function(e){t.processJSONInformation(e)},translation_request:!1})}}},{key:"hideFormElements",value:function(e,t){t&&this.currentDocument.querySelectorAll(e).forEach(function(e){e.parentNode.style.display="none"});this.uiElements.hideElementStyles(e)}},{key:"retryFetchInformationFromJs",value:function(e){var t=this;setTimeout(function(){t.fetchInformationFromJs()},e)}},{key:"fetchInformationFromJs",value:function(){var e=this;if(this.isInstanceTypeCollection()){var t=this.getProductHandleFromScope();t&&(this.processJSONInformation({id:"0",title:"",handle:decodeURI(t)}),this.currentDocument.setAttribute("swatch-generated",t))}else{var i=window.decodeURI(window.location.pathname.replace(/\/$/,"")),a=i.includes("/products"),n=null;if("sectioned"==this.instanceSubType&&!this.isSectionPrimary?(n=this.getProductHandleFromScope(),this.currentDocument.setAttribute("swatch-generated",n)):this.isSectionPrimary&&this.currentDocument.setAttribute("swatch-generated",i),"quick_view"!=this.instanceSubType){if(a&&!n)if("storefront"==S){if("pending"==window.starAppsStudioStorefrontDataRequest)return void this.retryFetchInformationFromJs(100);if("undefined"!=typeof window.starAppsStudioStorefrontData&&window.starAppsStudioStorefrontDataURL==i)return void setTimeout(function(){window.starAppsStudioStorefrontDataRequest="complete",e.processJSONInformation(window.starAppsStudioStorefrontData)},100);window.starAppsStudioStorefrontDataRequest="pending"}else{if("pending"==window.starAppsStudioJSDataRequest)return void this.retryFetchInformationFromJs(100);if("undefined"!=typeof window.starAppsStudioJSData&&window.starAppsStudioJSDataURL==i)return void setTimeout(function(){window.starAppsStudioJSDataRequest="complete",e.processJSONInformation(window.starAppsStudioJSData)},100);window.starAppsStudioJSDataRequest="pending"}if(a||n)if("storefront"==S){n||(n=i.split("/products/")[1]);var r=window.Shopify.locale;this.executeFetch({handle:n,locale:r,path_name:a&&!n?i:null,allow_processing:!0,translation_request:!1,callback:null})}else{var s=undefined;s=n?this.getMultiLingualInfo().current_url+"/products/"+n+".js":i+".js",B("JS data fetch request initiated for URL: "+s),this.executeFetch({url:s,path_name:a&&!n?i:null,allow_processing:!0,callback:null,translation_request:!1})}else this.productUndefined=!0}}}},{key:"executeFetch",value:function(e,t){var i,a=this,n=e.path_name,r=e.allow_processing,s=e.callback,l=e.translation_request;if("storefront"==S){var u=e.handle,d=o(e.locale),p=window.Shopify.country,h=g+"api/"+c+"/graphql.json",f="\n query productDetails @inContext(country: "+p.toUpperCase()+", language: "+d+') {\n product(handle:"'+u+'") {\n id\n handle\n title\n vendor\n availableForSale\n onlineStoreUrl\n tags\n publishedAt\n priceRange{\n maxVariantPrice{\n amount\n }\n minVariantPrice{\n amount\n }\n }\n featuredImage{\n id\n url\n }\n options{\n id\n name\n values\n optionValues{\n id\n name\n }\n }\n images(first: 250){\n nodes{\n id\n url\n altText\n }\n }\n variants(first:250){\n nodes{\n id\n availableForSale\n quantityAvailable\n compareAtPrice{\n currencyCode\n amount\n }\n selectedOptions{\n name\n value\n }\n currentlyNotInStock\n featured_image: image{\n id\n src: url\n altText\n }\n price{\n currencyCode\n amount\n }\n title\n sku\n compareAtPrice {\n amount\n }\n }\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n }\n minVariantPrice {\n amount\n }\n }\n }\n }\n ',v={method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.clientSpecs.storefront_access_token},body:JSON.stringify({query:f})};if((m=this.getDataFromSessionStorage(this.getSessionStorageKey(u,!1,l)))&&!t)return void(null!==m.id&&(n&&(window.starAppsStudioStorefrontDataRequest="complete",window.starAppsStudioStorefrontDataURL=n,window.starAppsStudioStorefrontData=m),r&&(this.processJSONInformation(m),B("JS data fetch request finished")),s&&s.call(this,m)));window.fetch?fetch(h,v).then(function(e){return e.json()}).then(function(e){var t=e.data.product,i=e.extensions.context;n&&(window.starAppsStudioStorefrontDataRequest="complete",window.starAppsStudioStorefrontDataURL=n,window.starAppsStudioStorefrontData=t),r&&(a.processJSONInformation(t,i),B("Storefront data fetch request finished")),s&&s.call(a,t,i)}):((i=new XMLHttpRequest).open("POST",h,!0),i.setRequestHeader("Content-Type","application/json"),i.setRequestHeader("X-Shopify-Storefront-Access-Token",a.storefront_access_token),i.onload=function(){if(i.status>=200&&i.status<400){var e=JSON.parse(i.responseText),t=e.data.product,a=e.extensions.context;n&&(window.starAppsStudioStorefrontDataRequest="complete",window.starAppsStudioStorefrontDataURL=n,window.starAppsStudioStorefrontData=t),r&&(this.processJSONInformation(t,a),B("Storefront data fetch request finished")),s&&s.call(this,t,a)}}.bind(a),i.send(JSON.stringify({query:f})))}else{var m,_=e.url;if((m=this.getDataFromSessionStorage(this.getSessionStorageKey(_,!0,l)))&&!t)return void(null!==m.id&&(n&&(window.starAppsStudioJSDataRequest="complete",window.starAppsStudioJSDataURL=n,window.starAppsStudioJSData=m),r&&(this.processJSONInformation(m),B("JS data fetch request finished")),s&&s.call(this,m)));window.fetch?fetch(_).then(function(e){return e.json()}).then(function(e){n&&(window.starAppsStudioJSDataRequest="complete",window.starAppsStudioJSDataURL=n,window.starAppsStudioJSData=e),r&&(a.processJSONInformation(e),B("JS data fetch request finished")),s&&s.call(a,e)}):function(){var e=new XMLHttpRequest;e.open("GET",_,!0),e.onload=function(){if(e.status>=200&&e.status<400){var t=JSON.parse(e.responseText);n&&(window.starAppsStudioJSDataRequest="complete",window.starAppsStudioJSDataURL=n,window.starAppsStudioJSData=t),r&&(this.processJSONInformation(t),B("JS data fetch request finished")),s&&s.call(this,t)}}.bind(a),e.send()}()}}},{key:"executeStorefrontFetch",value:function(e){var t,i=this,a=e.callback,n=g+"api/"+c+"/graphql.json",r=e.query,s={method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.clientSpecs.storefront_access_token},body:JSON.stringify({query:r})};window.fetch?fetch(n,s).then(function(e){return e.json()}).then(function(e){a&&a.call(i,e.data,e.extensions)}):((t=new XMLHttpRequest).open("POST",n,!0),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("X-Shopify-Storefront-Access-Token",i.storefront_access_token),t.onload=function(){if(t.status>=200&&t.status<400){var e=JSON.parse(t.responseText);a&&a.call(this,e.data,e.extensions)}}.bind(i),t.send(JSON.stringify({query:r})))}},{key:"initialize",value:function(){var e=this;if(B("Hey! I have started working with setting - "+this.themeCode),!this.eventsRegistered){var t=function(){var t=["click","change","virtual_click","keyup"];e.isInstanceTypeCollection()&&q.switch_on_hover&&(t.push("mouseover"),t.push("mouseout"));var i=e.getCorrectSwatchRoot(),a=null;if(e.isInstanceTypeProduct()&&e.groupsDisplaySelector&&(a=e.getCorrectSwatchRoot("groups")),!i&&!a)return setTimeout(e.initialize.bind(e),250),{v:undefined};Object.entries(t).forEach(function(t){var n=_slicedToArray(t,2),r=n[0],s=n[1];"length"!=r&&(i&&i.addEventListener(s,e.generateUISwitch()),a?a.addEventListener(s,e.generateUISwitch()):e.groupsDisplaySelector=null)}),window.addEventListener("resize",function(){if(this.isInstanceTypeCollection()){var e=this.currentDocument.querySelector("div.swatches-type-collections");if(e){var t=e.parentNode.parentNode;e.style.width=t.offsetWidth+"px"}}}.bind(e)),e.eventsRegistered=!0,e.generateProductGroups()}();if("object"==typeof t)return t.v}!p&&this.isInstanceTypeCollection()&&(this.hideFormElements(this.getInstanceConfig().selectors_to_hide,!1),p=!0),d||(window.document.addEventListener("click",function(e){for(var t=e.target;t.hasAttribute("swatch-inside");)t=t.parentNode;for(var i=document.querySelectorAll("ul.swatch-drop-down-list:not(.swatch-hide)"),a=0;a0;e.detectAndInitialize(a),G(i)}else e.productUndefined&&(B("Product not found!"),G(i))}catch(n){B(["Loading Failed... Retrying.",n]),J()&&t>=3?G(i):J()&&"SelectorNotFoundException"==n&&t++}},250)}}]),e}(),H=function(){function e(){_classCallCheck(this,e),this.tree=null,this.options=null,this.variants=null,this.variantsKeys=null,this.productInfo=null,this.priceInfoTree=null}return _createClass(e,[{key:"getVariantInfoFromOptions",value:function(e){for(var t=Object.keys(e),i=this.getVariantsKeys(),a=this.getVariants(),n=!1,r=null,s=0;s'+this.theme_setting.custom_css+""}},{key:"getCustomScripts",value:function(){var e=this.theme_setting.custom_scripts;if(0!=e.length){for(var t="",i=0;i"}},{key:"getRightNavigationSVG",value:function(){return""!=this.getSwatchPresentation().slide_right_button_svg?this.getSwatchPresentation().slide_right_button_svg.replace(RegExp("<[a-z]+","gi"),' swatch-inside="true"'):''}},{key:"getLeftNavigationSVG",value:function(){return""!=this.getSwatchPresentation().slide_left_button_svg?this.getSwatchPresentation().slide_left_button_svg.replace(RegExp("<[a-z]+","gi"),' swatch-inside="true"'):''}},{key:"getMinifiedHTML",value:function(e,t,i){e=this.cvt2HTMLEntities(e);var a=this.clientSpecs.getSwatchPresentation("collections").minified_template;a=(a=(a=(a=a.replace(RegExp("{count}","gi"),t)).replace(RegExp("{option_name}","gi"),e)).replace(RegExp("{product_id}","gi"),i.id)).replace(RegExp("{product_handle}","gi"),i.handle);var n=g;return n&&""!=n&&(n=n.replace(/\/$/,"")),a=a.replace(RegExp("{routes_root}","gi"),n),this.parseHTML('
  • '+a+"
  • ")[0]}},{key:"parseHTML",value:function(e){var t=document.implementation.createHTMLDocument("");return t.body.innerHTML=e,t.body.children}},{key:"decodeHTML",value:function(e){return(new DOMParser).parseFromString(e,"text/html").documentElement.textContent}},{key:"setDefaultFeaturedImage",value:function(e){var t=this.clientSpecs.getDefaultSwatchImage();this.defaultFeaturedImage=t||e}},{key:"hideElementStyles",value:function(e){ var t=document.querySelector('style[app="vsk"][role="hide_elements"]'),i="";if("object"==typeof e||"array"==typeof e)for(var a=0;a",document.querySelector("head").appendChild(this.parseHTML(i)[0])))}},{key:"getStyleProps",value:function(){if(this.isInstanceTypeCollection()){var e=this.currentDocument.querySelector("variant-swatch-king").parentNode.getBoundingClientRect().width;return'style="width: '+(e?e+"px":"100%")+"; z-index: "+this.clientSpecs.getCollectionSettings().layer_index+';"'}return""}},{key:"getSwatchRoot",value:function(e){var t=this.isInstanceTypeProduct()&&!!this.clientSpecs.getSizeChartSelector(),i=this.clientSpecs.getSizeChartConfig(),a="undefined"==typeof window.matchMedia||window.matchMedia("(hover: hover)").matches,n=this.clientSpecs.getNoTranslate(),r="";r+='
    \n
    ';for(var s=0;s'),"all"==this.clientSpecs.hideSingleValueOption(this.instanceType)&&e[s].values.length<=1&&(l+=" option-single-value"),r+="
    \n '+u+"\n
    "}return r+='
    '}},{key:"renderSwatchRoot",value:function(e,t){var i=this,a=arguments.length<=2||arguments[2]===undefined?"options":arguments[2];if(!this.isSwatchRootDisplayed[a]){var n=t.querySelector(".swatches.swatches-type-"+this.instanceType);if(n&&n.querySelector("[option-target]")&&n.parentNode.removeChild(n),t.innerHTML=e,this.isInstanceTypeProduct()){var r=[{type:"size_chart",append_to:"span.swatch-size-chart",element_selector:this.clientSpecs.getSizeChartSelector()}];Object.entries(r).forEach(function(e){var t,a,n,r=_slicedToArray(e,2),s=(r[0],r[1]),o=s.append_to,l=s.element_selector;l&&(n=i.currentDocument.querySelector(o))&&(t=5e3,a=setInterval(function(){t-=250;var e=document.querySelector(l);e?(n.appendChild(e),clearInterval(a)):t<=0&&clearInterval(a)},250))})}this.isSwatchRootDisplayed[a]=!0}}},{key:"renderNormal",value:function(e,t,i){var a=i.querySelector('[option-target="'+e+'"]'),n=a.querySelector(".swatch-single");n&&a.removeChild(n);var r=this.parseHTML(t)[0];return a.appendChild(r),a.classList.remove("swatch-hide"),a.querySelectorAll(".swatch-selector")}},{key:"getFlexibleSize",value:function(e){e=parseInt(e.replace("px",""));var t=window.innerWidth,i=t/500;return t>=992&&(i=.4*t/500),i=Math.max(i,.75),e*(i=Math.min(i,1.25))+"px"}},{key:"getLazyResolution",value:function(e,t,i,a){var n=!0;"cover"!=i&&"contain"!=i||("contain"==i&&(n=!1),i="100%"),i=parseInt(i.replace("%","")),i*=2;var r="center";a&&(r=a);var s="",o="width="+parseInt(t[0].replace("px",""))*(i/100)+"&height="+parseInt(t[1].replace("px",""))*(i/100)+(n?"&crop="+r:"");return o=e.includes("?")?"&"+o:"?"+o,e.match(/(\.jpg)(?=$|\?)/gm)&&(o+=s),e+o}},{key:"getViewByType",value:function(e){var t=null,i={getView:null};switch(e.assoc_view_type){case"swatch":t=e[this.instanceType+"_swatch"],i.getView="custom_swatch"==t?this.getCustomImageView.bind(this,e):this.getVariantImageView.bind(this,e);break;case"drop_down":i.getView=this.getDropDownView.bind(this,e);break;case"swatch_drop_down":i.getView=this.getDropDownViewCustom.bind(this,e);break;case"button":i.getView=this.getButtonView.bind(this,e);break;case"hidden":i.getView=this.getHiddenView.bind(this,e)}return i}},{key:"cvt2HTMLEntities",value:function(e){return e.replace(/&/g,"&").replace(/>/g,">").replace(/
    ";c+='","swatch-view-slide"==n&&(c+='
    ',c+='
    ',c+=this.getSwatchSlideStyleHTML("left"));var u="tooltip"==e.params.option_value_display,d=this.isInstanceTypeCollection()?"32px":"80px",p=this.isInstanceTypeCollection()?"32px":"80px";c+='
      ';var h=e.params.width||e.params.swatch_size||d,g=e.params.height||e.params.swatch_size||p;for(s=0;s',c+='
      ";var w=this.defaultFeaturedImage,S=i.data[s].featured_image;S!=undefined&&(w=this.getImageSrc(S,e.products_swatch,e.collections_swatch));var b=w&&"none"!=w;b&&(B("Requested background image with URL("+w+")"),w=this.getLazyResolution(w,[h,g],e.params.background_size,e.params.background_position)),c+='
      ',c+=this.renderBadge(e,i.data[s],r),c+='
      ';var k="adjacent"==e.params.option_value_display;if(c+='

      '+m+"

      ",e.params.price_badge){var A=!!e.params.price_badge.price_enabled;(!o||o&&1==i.show_price&&!V)&&(c+='
      '+i.data[s].price+"
      ")}c+="
      ",u&&(c+='
      \n '+m+'\n
      \n
      '),c+=""}}return c+="
    ","swatch-view-slide"==n&&(c+=this.getSwatchSlideStyleHTML("right"),c+="
    "),c+="
    "}},{key:"generateChecksum",value:function(e){var t=e.length,i=undefined,a="";if(0===t)return 0;for(e=e.replace(new RegExp("\n\ts"),""),i=0;i=300?300:100*Math.ceil(i/100)}},{key:"getSwatchImageURL",value:function(e,t){for(var i=[{char:"!",replacer:"~21"},{char:"*",replacer:"~2A"},{char:"'",replacer:"~92"},{char:"(",replacer:"~28"},{char:")",replacer:"~29"},{char:";",replacer:"~3B"},{char:":",replacer:"~3A"},{char:"@",replacer:"~40"},{char:"&",replacer:"~26"},{char:"=",replacer:"~3D"},{char:"+",replacer:"~2B"},{char:"$",replacer:"~24"},{char:",",replacer:"~2C"},{char:"/",replacer:"~2F"},{char:"\\",replacer:"~5C"},{char:"?",replacer:"~3F"},{char:"%",replacer:"~25"},{char:"#",replacer:"~23"},{char:"[",replacer:"~5B"},{char:"]",replacer:"~5D"},{char:"{",replacer:"~7B"},{char:"}",replacer:"~7D"},{char:'"',replacer:"~22"},{char:"<",replacer:"~3C"},{char:">",replacer:"~3E"},{char:"|",replacer:"~7C"},{char:"`",replacer:"~60"},{char:"^",replacer:"~5E"},{char:".",replacer:"~2E"}],a=0;a
    ";o+='","swatch-view-slide"==n&&(o+='
    ',o+='
    ',o+=this.getSwatchSlideStyleHTML("left"));var l="tooltip"==e.params.option_value_display,c=this.isInstanceTypeCollection()?"32px":"80px",u=this.isInstanceTypeCollection()?"32px":"80px";o+='
      ';for(var d=e.params.width||e.params.swatch_size||c,p=e.params.height||e.params.swatch_size||u,h=this.getResizeValue(d,p),g=0;g',o+='
      ";var k=null;if(r)r&&(k=this.getLazyResolution(i.data[g].featured_image.src,[d,p],e.params.background_size,e.params.background_position));else{var A=i.untranslated_name?i.untranslated_name:i.name,I=i.data[g].untranslated_value?i.data[g].untranslated_value:f;k=this.getSwatchImageURL(A,I)}if(this.clientSpecs.app_setting_config.use_optimized_urls){var T=k.split("/");k=T.slice(0,-1).join("/")+"/"+h+"/"+T.pop().replace(".media",".webp")}if(o+='
      ',o+=this.renderBadge(e,i.data[g],w),o+='
      ',o+='

      '+_+"

      ",e.params.price_badge){var x=!!e.params.price_badge.price_enabled;(!r||r&&1==i.show_price&&!V)&&(o+='
      '+i.data[g].price+"
      ")}o+="
      ",l&&(o+='
      \n '+_+'\n
      \n
      '),o+=""}}return o+="
    ","swatch-view-slide"==n&&(o+=this.getSwatchSlideStyleHTML("right"),o+="
    "),o+="
    "}},{key:"getButtonView",value:function(e,t,i){var a="undefined"!=typeof i.product_group_index,n=a?' data-group-index="'+i.product_group_index+'"':"",r=window.matchMedia?window.matchMedia("screen and (max-width: 480px)"):screen.width<=480,s="swatch-view-"+e.params.button_style;r.matches&&(s="swatch-view-"+e.params.mobile_button_style);var o='
    ",l='";"inline"!==e.params.label_display_position&&(o+=l),"inline"===e.params.label_display_position&&(o+="
    ",o+=l),"swatch-view-slide"==s&&(o+='
    ',o+='
    ",o+=this.getSwatchSlideStyleHTML("left")),o+='
      ';for(var c=0;c',o+="
      ",o+=" "+(e.params.radio_button?"
      ":""),o+="
      ",o+='
      '+p+"
      ",e.params.price_badge){var v=!!e.params.price_badge.price_enabled;(!a||a&&1==i.show_price&&!V)&&(o+='
      '+i.data[c].price+"
      ")}o+="
      ",o+="
      ",o+=""}}return o+="
    ","swatch-view-slide"==s&&(o+=this.getSwatchSlideStyleHTML("right"),o+="
    "),"inline"===e.params.label_display_position&&(o+="
    "),o+="
    "}},{key:"getDropDownView",value:function(e,t,i){var a="undefined"!=typeof i.product_group_index,n=a?' data-group-index="'+i.product_group_index+'"':"",r='
    ",s="",o="";"default"==e.params.dropdown_type&&(r+='");r+='
    ',r+='
    ',"label_inside"==e.params.dropdown_type&&(r+='
    "),r+='',r+='
      ';for(var l=0;ls.length&&(o=" "+(s=d)+" "+(e.params.display_price?""+p+" ":"")+" "),r+='
    • ',r+=" "+d+" "+(e.params.display_price?""+p+" ":"")+" ",r+="
    • ")}return r+="
    ",r+="double_triangle"==e.params.icon_style?'':"inverted_triangle"==e.params.icon_style?'':'',r+="
    ",r+="
    ",r=(r=(r+="
    ").replace("{{ option_value_text }}",s)).replace("{{ option_value }}",o)}},{key:"getDropDownViewCustom",value:function(e,t,i){var a="undefined"!=typeof i.product_group_index,n=a?' data-group-index="'+i.product_group_index+'"':"",r='
    ",s="",o="";r+='";var l=e[this.instanceType+"_swatch"],c=this.isInstanceTypeCollection()?"24px":"48px",u=this.isInstanceTypeCollection()?"24px":"48px",d=e.params.swatch_size||c,p=e.params.swatch_size||u,h=this.getResizeValue(d,p);r+='
    ',r+='
    ',r+='',r+='
      ';for(var g=0;g
    ';y.length>s.length&&(o=x+' '+(s=y)+""),r+='
  • ',r+=x,r+=' '+y+" "+(e.params.display_price?""+_+" ":"")+" ",r+="
  • "}}return r+="",r+="double_triangle"==e.params.icon_style?'':"inverted_triangle"==e.params.icon_style?'':'',r+="
    ",r+="
    ",r=(r=(r+="").replace("{{ option_value_text }}",s)).replace("{{ option_value }}",o)}},{key:"getHiddenView",value:function(e,t,i){for(var a="",n=0;n\n \n ",l))break}return a}},{key:"selectSwatch",value:function(e,t,i){var a="swatch-selected";if("undefined"!=typeof this.selectedSwatches[e]){var n,r=this.selectedSwatches[e];if(r.classList.remove(a),r.removeAttribute("current-product"),"SELECT"!=r.tagName)if(n="LI"==r.tagName?r:r.closest("li.swatch-view-item"))"option"==n.getAttribute("role")?n.setAttribute("aria-selected",!1):n.setAttribute("aria-checked",!1)}(this.isDropDown(t.tagName)&&(t.value=i),t.classList.add(a),"SELECT"!=t.tagName)&&((n="LI"==t.tagName?t:t.closest("li.swatch-view-item"))&&("option"==n.getAttribute("role")?n.setAttribute("aria-selected",!0):n.setAttribute("aria-checked",!0)));this.selectedSwatches[e]=t}},{key:"isDropDown",value:function(e){return"SELECT"==e}},{key:"getIsSwatchRootDisplayed",value:function(){var e=arguments.length<=0||arguments[0]===undefined?"options":arguments[0];return this.isSwatchRootDisplayed[e]}},{key:"setIsSwatchRootDisplayed",value:function(e){var t=arguments.length<=1||arguments[1]===undefined?"options":arguments[1];this.isSwatchRootDisplayed[t]=e}},{key:"renderBadge",value:function(e,t,i){var a="",n=Number.MAX_SAFE_INTEGER;if("storefront"==S){var r=!!e.params.new_badge&&e.params.new_badge.enable,s=!!e.params.sale_badge&&e.params.sale_badge.enable,o=!!e.params.sold_out_badge&&e.params.sold_out_badge.enable,l=this.isSalePreset(t.min_compare_at_price,t.min_price);r&&n>this.clientSpecs.getPresetBadgeOrder("new")&&this.isNewPreset(t.published_at)&&!i&&(a+="\n "+this.getTranslation(_.app_setting_config.preset_badge.new_badge_text)+"\n ",n=this.clientSpecs.getPresetBadgeOrder("new")),o&&n>this.clientSpecs.getPresetBadgeOrder("sold_out")&&!t.available&&(a+="\n "+this.getTranslation(_.app_setting_config.preset_badge.sold_out_badge_text)+"\n ",n=this.clientSpecs.getPresetBadgeOrder("sold_out")),s&&l&&n>this.clientSpecs.getPresetBadgeOrder("sale")&&(a+="\n "+l+"\n ",n=this.clientSpecs.getPresetBadgeOrder("sale"))}return a}},{key:"isNewPreset",value:function(e){var t=new Date(e);return new Datet&&a>=_.app_setting_config.preset_badge.min_price_diff_for_sale_badge?this.applyReplacements(i,a):""}},{key:"applyReplacements",value:function(e,t){var i={"{{currency_symbol}}":_.currency_symbol,"{{currency_code}}":_.currency,"{{amount_save}}":e.toFixed(2),"{{percentage_save}}":t.toFixed(2)+"%"};return this.getTranslation(_.app_setting_config.preset_badge.sale_badge_text).replace(/{{(?:currency_symbol|currency_code|amount_save|percentage_save)}}/g,function(e){return i[e]})}}]),e}(),B=function(e){if(u&&u.getDisplayLogs()){var t=Date(Date.now());console.log("<-------------- START ---------------->"),console.log("Swatch King:",e),console.log("Swatch King:","Timestamp",t.toString()),console.log("<--------------- END ----------------->")}},W=function(e){var t=document.implementation.createHTMLDocument("");return t.body.innerHTML=e,t.body.children},z=function(){var e=arguments.length<=0||arguments[0]===undefined?null:arguments[0],t=null,i={};if(document.location.search.substr(1).split("&").forEach(function(e){var t=e.split("=");try{i[t[0].toString()]=t[1].toString()}catch(a){}}),isNaN(i.variant)){var a=undefined;e?(a=e.querySelector('[name="id"]'))&&(t=a.value):(a=document.querySelector('[name="id"]'))&&(t=a.value)}else i.variant&&(t=i.variant);return t},G=function(e){clearInterval(parseInt(e)),B(["Interval Removed...",e])},J=function(){return"complete"===document.readyState||"loaded"===document.readyState},K=function(){if(s("VariantSwatchKing")){if(t(),!y)return;(b||A||T||C||D||L||P)&&($(),document.addEventListener("vsk:product:refresh",function(){setTimeout(function(){$(),B("Refreshing product swatch lookup complete.")},0)})),(k||I||x||E||O||N||M)&&X()}},$=(setInterval(function(){K()},500),function Y(){u||(u=new j);var e=u.getSelectors().swatch_root;e.use_section_as_root?function(){var t=!1,i=document.querySelectorAll(e.section_selector);if(!h){var a=window.location.pathname.includes("/products");t=1==i.length&&a}Object.entries(i).forEach(function(e){var i=_slicedToArray(e,2),a=i[0],n=i[1];if("length"!=a&&"undefined"==typeof n.vsk_initialized){n.vsk_initialized=!0,n.setAttribute("swatch-generated",!0);var r={instance_sub_type:"sectioned"};t&&(r.primary=!0,h=!0),new F("products",n,r).onInstanceActivate()}});var n=J()?1e3:250;setTimeout(Y.bind(_this22),n)}():new F("products",document,null).onInstanceActivate()}),X=function(){u||(u=new j);var e=u.getCollectionConfig(),t=u.getCollectionSettings();Z(e,t,!0),document.addEventListener("vsk:render:swatches",function(){setTimeout(function(){Z(e,t,!1)},0)})},Z=function Q(e,t,i){var a=document.querySelectorAll(e.swatch_root_selector);Object.entries(a).forEach(function(e){var t=_slicedToArray(e,2),i=t[0],a=t[1];"length"!=i&&("undefined"==typeof a.vsk_initialized&&(a.vsk_initialized=!0,a.setAttribute("swatch-generated","none"),new F("collections",a,null).initialize()))}),i&&t.continuous_lookup>0&&setTimeout(function(){Q(e,t,!0)},t.continuous_lookup)}}();