"use strict";function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,a=Array(e.length);tt&&(t=e.offsetWidth),e.style.minWidth=t+"px"}},{key:"clickToScroll",value:function(e,t){var a=arguments.length<=2||arguments[2]===undefined||arguments[2],i='[swatch-slider="true"]';this.resSlider(e,i,t,a)}},{key:"resSlider",value:function(e,t,a,i){var n=arguments.length<=4||arguments[4]===undefined?0:arguments[4],r=t+' [navigation="left"]',s=t+' [navigation="right"]',o=JSON.parse(a.dataset.sliderData),l=a.querySelector(t+".swatch-navigable ul");a.sliderInitialized||(this.initSlider(t,a),a.sliderInitialized=!0),l.style.transition=0!==n?"0.6s cubic-bezier(0.215, 0.610, 0.355, 1.000)":i?"0.3s ease-out":"none";var c=l.style.transform.match(/-?[\d\.]+/g)||[0],u=parseFloat(c[0])||0;if(0!==n)return this.applyMomentum(.25*n,u,l,a,r,s,o);if(0==e)a.querySelector(s).classList.remove("star-disabled"),"mode_0"!=o.arrowMode&&a.querySelector(s).classList.add("star-show"),"swatch-pill"==o.swatchType||"button"==o.assocViewType?(u+=.8*o.sliderWidth)>=-o.firstSwatchWidth/2&&(u=0,this.handleEdge(a,r,"left",o)):(u+=this.calculateSlideCount(o)*(o.swatchSliderItemWidth+o.marginRight),"half"===o.lastSwatchPreview&&(u+=o.swatchSliderItemWidth-o.lastSwatchWidth),u>=-o.swatchSliderItemWidth/3&&(u=0,this.handleEdge(a,r,"left",o)));else if(1==e)if(a.querySelector(r).classList.remove("star-disabled"),"mode_0"!=o.arrowMode&&a.querySelector(r).classList.add("star-show"),"swatch-pill"==o.swatchType||"button"==o.assocViewType){var d=u;u-=.8*o.sliderWidth,o.totalScrollWidth<=-(u-o.sliderWidth)&&(u=d+(-o.totalScrollWidth-(d-o.sliderWidth))-1,this.handleEdge(a,s,"right",o))}else{d=u;u-=this.calculateSlideCount(o)*(o.swatchSliderItemWidth+o.marginRight),"half"===o.lastSwatchPreview&&(u-=o.swatchSliderItemWidth-o.lastSwatchWidth),Number(o.totalScrollWidth.toFixed(3))<=Number((-(u-o.sliderWidth)).toFixed(3))&&(u=Number((d+(-o.totalScrollWidth-(d-o.sliderWidth))).toFixed(3)),this.handleEdge(a,s,"right",o))}return l.style.transform="translateX("+u+"px)",u}},{key:"applyMomentum",value:function(e,t,a,i,n,r,s){var o=t+e,l=-s.totalScrollWidth+s.sliderWidth;return o>0?(o=0,this.handleEdge(i,n,"left",s)):ol&&(i.querySelector(r).classList.remove("star-disabled"),"mode_0"!=s.arrowMode&&i.querySelector(r).classList.add("star-show")),a.style.transform="translateX("+o+"px)",o}},{key:"calculateSlideCount",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:"handleEdge",value:function(e,t,a,i){"mode_1"==i.arrowMode?setTimeout(function(){e.querySelector(t).classList.remove("star-show")},500):e.querySelector(t).classList.add("star-disabled")}},{key:"initSlider",value:function(e,t){var a=this,i=t.querySelector(e+".swatch-navigable ul"),n=undefined,r=0,s=!1,o=0,l=undefined,c=undefined,u=undefined,d=function(e){n=l=e,c=Date.now(),s=!0,i.style.transition="none";var t=i.style.transform;if(t){var a=t.match(/translateX\(([-\d.]+)px\)/);a&&(r=parseFloat(a[1]))}},p=function(e){s&&((u=Date.now())-c>0&&(o=(e-l)/(u-c)),l=e,c=u,i.style.transform="translateX("+(r+(e-n))+"px)")},h=function(){s&&(s=!1,a.resSlider(null,e,t,!0,1e3*(o||.01)))};i.addEventListener("touchstart",function(e){d(e.touches[0].clientX)}),i.addEventListener("touchmove",function(e){e.preventDefault(),p(e.touches[0].clientX)},{passive:!1}),i.addEventListener("touchend",function(){h()})}},{key:"scrollSwatchSlider",value:function(e){var t=e.closest(".swatch-navigable"),a=e.getAttribute("data-navigation");if(t&&t.hasAttribute("data-current-scroll")){var i=Number(t.getAttribute("data-current-scroll")),n=t.querySelectorAll(".swatch-view-item"),r=i;if("right"===a)for(var s=i;sl.left){n[s].scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"}),r=s;break}}else"left"===a&&(r=Math.max(0,i-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"==a?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],a=null,i=null,n=!1,r="bottom";if(this.isInstanceTypeProduct()){if(a="products_"+t+"_root",void 0===(i=this.pInformation[a])||!i.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,!(i=l&&u&&p==d&&this.clientSpecs.getGroupsEnableStatusForProductType()?u:this.currentDocument.querySelector(o))&&this.currentDocument.matches&&this.currentDocument.matches(o)&&(i=this.currentDocument),n=!!i}}else this.isInstanceTypeCollection()&&(a="collections_"+t+"_root",void 0!==(i=this.pInformation[a])&&i.parentNode||function(){var t=e.getInstanceConfig(),a="bottom";i=e.currentDocument,r=a;var s=t.swatch_display_options,o=F.swatch_location;if(s){var l=-1;-1!==(l=s.findIndex(function(e){return e.label===o}))?(r=s[l].position,i=e.currentDocument.querySelector(s[l].selector)):-1!==(l=s.findIndex(function(t){return!!e.currentDocument.querySelector(t.selector)}))&&(r=s[l].position,i=e.currentDocument.querySelector(s[l].selector))}i||(r=a,i=e.currentDocument),n=!0}());if(n){var h=document.createElement("variant-swatch-king");h.style.maxWidth="100%","before"==r?i.parentNode.insertBefore(h,i):"after"==r?i.parentNode.insertBefore(h,i.nextSibling):"top"==r?i.insertBefore(h,i.firstChild):i.appendChild(h),this.pInformation[a]=h,i=h}return i}},{key:"getLabelWidth",value:function(e,t){var a=e.closest(".swatch-drop-down-label");if(a){var i=a.querySelector(".swatch-label-inside");if(i){t=parseFloat(t.match(/[\d\.]+/g));var n=i.getBoundingClientRect().width;e.style.paddingLeft=t+n+"px"}}}},{key:"getPriceMaxWidth",value:function(e){var t=e.querySelectorAll(".swatch-button-price"),a=0;t.forEach(function(e){var t=e.offsetWidth;t>a&&(a=t)}),t.forEach(function(e){e.style.width=a+"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&&["metafield"].includes(this.clientSpecs.getDataUrlSource())&&(f=[],v={},_=1):(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=[],a=0;a=200&&t.status<400){var a=JSON.parse(t.responseText);this.setProductGroupsFromAPI(a,e),i&&i.call(this)}}.bind(a),t.send(null))}},{key:"setProductGroupsFromMetafield",value:function(e,t){function a(e,t,i,n){return Object.entries(e).reduce(function(r,s){var o=_slicedToArray(s,2),l=o[0],c=o[1],u=e.hasOwnProperty("products"),d=t[l]||(u?i[l]:l);return Array.isArray(c)?r[d]=c.map(function(e){return a(e,i,i,n)}):r[d]="object"==typeof c&&null!==c?"group_display_name"===l||"product_display_name"===l?c[n]||null:a(c,t,i,n):c,r},{})}e&&0!=e.length||"undefined"==typeof v[t]&&(v[t]=[]);var i={group_id:"id",group_name:"group_name",group_display_name:"option_name",product_page_style_id:"products_preset_id",product_page_swatch_source:"products_swatch",collection_page_style_id:"collections_preset_id",collection_page_swatch_source:"collections_swatch",group_display_position:"display_position",primary_locale:"primary_locale",products:"option_values"},n={id:"id",product_display_name:"option_value",handle:"handle",published:"published",product_position:"product_position",swatch_src:"swatch_src",swatch_value:"swatch_value"};e.forEach(function(e){f.some(function(t){return t.id==e.group_id})||f.push(a(e,i,n,e.primary_locale))});for(var r=function(e){f[e].option_values.some(function(e){return e.handle==t})&&(v[t]?v[t].some(function(t){return t==e})||v[t].push(e):v[t]=[e])},s=0;s0&&(this.setProductGroupsFromMetafield(r.data,t),i&&i.call(this));else{var s='\n query productGroupsData {\n product(id: "gid://shopify/Product/'+e+'") {\n id\n handle\n metafield(namespace: "vsk", key: "group_data") {\n value\n }\n }\n }\n ';this.executeStorefrontFetch({query:s,isMultiple:!0,callback:function(e){var r=e&&e.product&&e.product.metafield?JSON.parse(e.product.metafield.value):[],s={data:r};r.length>0&&a.setDataToSessionStorage(a.getSessionStorageKey(n,!1,!0,!0),s),a.setProductGroupsFromMetafield(r,t),i&&i.call(a)}})}}},{key:"getProductGroupIndexes",value:function(e){var t=v[e];return void 0!==t?t:m||_?null:[]}},{key:"getGroupSwatchImageURL",value:function(e,t){var a=encodeURIComponent(t);return"cdn"==this.clientSpecs.getSwatchUrlSource()&&(a=encodeURIComponent(a)),"https://"+this.clientSpecs.getSwatchUrlHost()+"/apps/"+this.swatchDir+"/"+this.storeSlug+"/groups/"+e.split("group")[1]+"/"+a+".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 $("Untranslated handle is not found ... calling generateProductGroups method again!");var a=t?this.productInfoTree.getUntranslatedProductHandle():this.productInfoTree.getProductInfo().handle,i=this.productInfoTree.getProductInfo().id,n=this.getProductGroupIndexes(a),r=null;if(m&&null==n)this.getProductGroupsByAPI(a,this.generateProductGroups.bind(this));else if(_&&null==n)this.getProductGroupsByMetafields(i,a,this.generateProductGroups.bind(this));else if(!((r=this.getProductsGroups(n)).length<=0)){var s=this.groupsDisplaySelector?"groups":"options",o=this.getCorrectSwatchRoot(s);this.uiElements.getIsSwatchRootDisplayed(s)||(this.isInstanceTypeProduct()?this.uiElements.renderSwatchRoot(this.uiElements.getSwatchRoot([]),o,s):this.isInstanceTypeCollection()&&this.uiElements.renderSwatchRoot(this.uiElements.getSwatchRoot([]),o));var l=o.querySelector(".swatches.swatches-type-"+this.instanceType),c={top:0,bottom:0},u={top:[],bottom:[]};Object.entries(r).forEach(function(t){var i=_slicedToArray(t,2),r=i[0],s=i[1],o="group"+s.id;if("length"!=r){for(var d=0;d';if("top"==s.display_position){var y=l.querySelector('[sa-group-position="top"]');y.querySelector('[option-target="'+o+'"]')||y.insertBefore(e.uiElements.parseHTML(_)[0],y.children[c.top])}else{var w=l.querySelector('[sa-group-position="bottom"]');if(!w.querySelector('[option-target="'+o+'"]')){var b=w.children.length-1-c.bottom;-1!=c.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==o||(v=n[r],"storefront"==S?(h={},g=[],f=Object.fromEntries(Object.entries(window.sessionStorage)),(g=s.option_values.reduce(function(t,a){var i='"gid://shopify/Product/'+a.id+'"',n=e.getSessionStorageKey(a.id,!1,!1),r=e.getDataFromSessionStorage(n);if((!r||r&&null==r.id)&&(n=e.getSessionStorageKey(a.id,!1,!1,undefined,undefined,undefined,U),r=e.getDataFromSessionStorage(n)),f[n])if(r&&null!==r.id){h[i]=r;var o=s.option_values.findIndex(function(e){return e.id===a.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!==a.id});else t.push(i);return t},[])).length>0?function(){for(var t=R,i=Math.ceil(g.length/t),n=0,r=function(t,i){++n===i&&e.generateProductGroupsUI(v,c,l,o,s,a,h)},u=0;u',a.querySelector('[option-target="'+i+'"]').appendChild(this.uiElements.parseHTML(q)[0]),"smart_hide"==this.clientSpecs.hideSingleValueOption(this.instanceType)&&(P=!1,N=null,M=a.querySelectorAll("ul.swatch-view-image, ul.swatch-view-custom-image"),Object.entries(M).forEach(function(e){var t=_slicedToArray(e,2),a=t[0],i=t[1];if("length"!=a){var n=1==i.children.length?i.closest("div[option-target]"):null;n?(n.classList.add("option-single-value"),null==N&&(N=n)):P=!0,!P&&N&&a==M.length-1&&N.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 V=a.querySelectorAll("div.swatch-drop-down-inner [type='select']");Object.entries(V).forEach(function(e){var t=_slicedToArray(e,2),a=t[0],i=t[1];"length"!=a&&s.getLabelWidth(i,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 R=a.querySelectorAll(".enable-price-alignment");Object.entries(R).forEach(function(e){var t=_slicedToArray(e,2),a=t[0],i=t[1];"length"!=a&&s.getPriceMaxWidth(i)})}this.generateProductGroupsUIHelper(u.view_type_preset,i,a,d,u),this.isInstanceTypeCollection()&&F.switch_on_hover&&this.addFeaturedImageDirectlyIntoDOMElementForGroups(a,u)}}},{key:"createFeaturedImageContainer",value:function(e){var t=e.querySelector(".vsk-product-images-data");if(t)return t;var a=document.createElement("div");return a.className="vsk-product-images-data",a.style.display="none",e.insertBefore(a,e.firstChild),a}},{key:"addFeaturedImageDirectlyIntoDOMElementForGroups",value:function(e,t){for(var a=this.createFeaturedImageContainer(e),i=0;i'+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,a){var i='"gid://shopify/Product/'+e.id+'"';if(t&&t[i]){var n=t[i];switch(a){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[a]}},{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 a=/\.(?:jpg|png|jpeg|gif|tiff|bmp)(?:\?|\s|$)/gm,i=/(?:_\d*x\d*|_medium|_large|_small)(?:_crop_[a-zA-Z]{3,6}){0,1}(?=\.(?:jpg|png|jpeg|gif|tiff|bmp))/gm.exec(e),n=a.exec(t);return i&&n&&(t=t.replace(n[0],i[0]+n[0])),t}},{key:"updateVariantImage",value:function(e,t,a){var i=!1,n=!1,r=a?"featured_image_src":"secondary_image_src";if(a&&t.featured_image?i=!0:!a&&t.featured_image&&t.featured_image.secondary_src&&(i=!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=a?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=a?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,a,i,n){a=this.formatDefaultOption(a,2),i=this.formatDefaultOption(i,","),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(a)).split(".");return s[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+i)+(s[1]&&"00"!=s[1]?n+s[1]:r)}},{key:"insertHTMLAt",value:function(e,t,a){if("replace"!=a){var i=this.uiElements.parseHTML(e)[0];"before"==a?t.parentNode.insertBefore(i,t):"after"==a?t.parentNode.insertBefore(i,t.nextSibling):"top"==a?t.insertBefore(i,t.firstChild):t.appendChild(i)}else t.innerHTML=e}},{key:"updateGridElements",value:function(e){var t=this.getInstanceConfig().grid_updates,a=this.getGridUpdateParams(e);a.is_on_sale?this.currentDocument.classList.add("swatch-variant-onsale"):this.currentDocument.classList.remove("swatch-variant-onsale"),"undefined"!=typeof a.available&&a.available?this.currentDocument.classList.remove("swatch-variant-soldout"):this.currentDocument.classList.add("swatch-variant-soldout");for(var i=0;i0;){var d=c.children[0];u.appendChild(d)}}$("Generating restructured swatch UI..."),this.generateUISwitch()(),this.generateProductGroups()}else setTimeout(this.productChangeRestructure.bind(this,e,t),100)}},{key:"productChangeOperations",value:function(e,t,a){var i=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,i);var c="storefront"==S?e.id.split("Product/")[1]:e.id;this.dispatchCustomEvent(this.currentDocument,"product:changed",{productID:""+c,previousProductID:a});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),a=t[0],i=t[1];"length"!=a&&(i.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),a=t[0],i=t[1];"length"!=a&&(i.hasAttribute("href")&&i.setAttribute("href",h.url),i.hasAttribute("data-href")&&i.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 a=t.minified_display_count,i=Math.ceil(1920/a.length),n=Math.floor(window.screen.width/i);return n>=a.length&&(n=a.length-1),a[n]}return null}},{key:"updateVariantImages",value:function(e){var t=arguments.length<=1||arguments[1]===undefined?null:arguments[1],a=t||this.getInstanceConfig().data_selectors,i=null;""!=a.featured_image&&(i=this.currentDocument.querySelector(a.featured_image),this.updateVariantImage(i,e,!0)),""!=a.featured_image&&""!=a.secondary_image&&(i=this.currentDocument.querySelector(a.secondary_image),this.updateVariantImage(i,e,!1))}},{key:"updateAttributes",value:function(e,t){var a=this;t.attributes.length>0&&function(){var i=a.pInformation.attrs_to_update_selectors;if(void 0===i){i="[data-product-id]";for(var n=0;nr;return a.is_on_sale=o,o&&(n=r/s*100,n=Math.round(100-n),a.percentage_difference=n),a}},{key:"updateGridAttributes",value:function(e){var t=this,a=this.getInstanceConfig().attribute_updates,i=this.getGridUpdateParams(e),n=!!window.$&&!!window.$.fn&&!!window.$.fn.data;a&&a.forEach(function(e){var a=e.selector,r=e.attribute,s=e.template;if(""!=a||""!=r){var o="["+r+"]",l=a?t.currentDocument.querySelectorAll(""+a+o):t.currentDocument.querySelectorAll(o);if(l&&l.length>0)Array.from(l).forEach(function(e){var a=t.getModifiedTemplate(s,i);e.setAttribute(r,a),n&&window.$(e).data(r.replace("data-",""),a)})}})}},{key:"generateUIForCollection",value:function(e){var t=this;if(this.clientSpecs.getEnableStatusForProductGridType()){var a=null,i=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;if(!l.hasAttribute("swatch-option")||u){if(this.pInformation.image_replaced_by_hover){var h=this.getCurrentOptionForCollection(!0),g=this.productInfoTree.getVariantInfoFromOptions(h);if("storefront"==S&&g){var f=g.id.split("ProductVariant/")[1]||g.id;g.id=f}if(!g)if((w=l.getAttribute("swatch-url"))&&l.classList.contains("swatch-selected"))(C=this.getFeaturedProductImageFromDOM(l,w,"featured"))&&(g={featured_image:{src:C,secondary_src:C}}),(x=this.getFeaturedProductImageFromDOM(l,w,"secondary"))&&(g.featured_image.secondary_src=x);else if(w){var v=l.closest("ul.swatch-view");if(v){var m=v.querySelector("li.swatch-view-item .swatch-selected");if(m){var _=m.getAttribute("swatch-url");if(_)(C=this.getFeaturedProductImageFromDOM(l,_,"featured"))&&(g={featured_image:{src:C,secondary_src:C}}),(x=this.getFeaturedProductImageFromDOM(l,_,"secondary"))&&(g.featured_image.secondary_src=x)}}}this.updateVariantImages(g||{}),this.pInformation.image_replaced_by_hover=!1}return}if("SELECT"==l.tagName&&"change"!=e.type)return;if(c&&p){var y=null,w=l.getAttribute("swatch-url");if(n=l.getAttribute("swatch-option"),i=l.getAttribute("orig-value"),w){var k=l.closest("[data-group-index]").getAttribute("data-group-index"),A=this.getProductsGroups([k])[0],I=w.split("/products/");I=I[I.length-1];for(var T=0;T'+t.labelSplitSymbol+" "+a),t.uiElements.selectSwatch(e,l,a)}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 G,"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 D)return D.v}if(!(e&&"SELECT"==l.tagName&&l.options&&l.options.length>1&&this.isClickEvent(e.type))){if(e&&"select"==l.getAttribute("type")){var O=l,L=l.parentNode.querySelector("ul.swatch-drop-down-list"),P="true"==O.getAttribute("aria-expanded");return O.setAttribute("aria-expanded",!P),void L.classList.toggle("swatch-hide")}if(e&&"select_value"==l.getAttribute("type"))(O=l.closest("div.swatch-drop-down-inner").querySelector('div[type="select"]')).style.minWidth&&"0px"!=O.style.minWidth||this.setSelectMinWidth(O),O.innerHTML=l.innerHTML,O.setAttribute("aria-label",l.innerText),O.setAttribute("aria-expanded",!1),l.parentNode.classList.add("swatch-hide");if(e&&l.hasAttribute("swatch-option")){if(n=l.getAttribute("swatch-option"),a=n,this.uiElements.isDropDown(l.tagName))l.hasAttribute("data-selected")&&l.remove(0),i=l.value;else{i=l.getAttribute("orig-value");var N=l.closest("[option-target]").querySelector("span.swatch-variant-name");N&&"null"!=i&&(N.innerHTML=' '+this.labelSplitSymbol+" "+i)}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,i),r=this.getCurrentOptionForCollection(),o=this.productInfoTree.getVariantInfoFromOptions(r),"storefront"==S&&o){f=o.id.split("ProductVariant/")[1]?o.id.split("ProductVariant/")[1]:o.id;o.id=f}var M=!0,q=this.currentDocument.getAttribute("swatch-current-variant")||"0";if(o&&(this.currentDocument.setAttribute("swatch-current-variant",o.id),this.dispatchCustomEvent(this.currentDocument,"variant:changed",{productID:""+this.productInfoTree.getProductInfo().id,variant:""+o.id,previousVariant:q,variantInformation:JSON.stringify(o)})),(o&&q==o.id||this.currentDocument.hasAttribute("sa-manual-update"))&&(M=!1),o&&M){var F=this.getInstanceConfig().data_selectors,V=null,R=null;this.updateVariantImages(o,F),""!=F.url&&function(){V=t.currentDocument.querySelectorAll(F.url);var e=/(?:variant=)[0-9]*/gm;Object.entries(V).forEach(function(t){var a=_slicedToArray(t,2),i=a[0],n=a[1];if("length"!=i&&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 H=this.productInfoTree.getProductInfo().handle;if(this.updateAttributes({handle:H,url:"/products/"+H+"?variant="+o.id,product_id:null,variant_id:o.id},F),this.updateGridElements(_extends({variant_id:o.id},o)),this.updateGridAttributes(_extends({variant_id:o.id},o)),F.form_input&&""!=F.form_input&&(R=this.currentDocument.querySelector(F.form_input))){if("SELECT"==R.tagName&&(R.value=o.id,R.value!=o.id)){var z=document.createElement("option");z.value=o.id,z.text=o.title,R.add(z)}R.value=o.id,this.dispatchEvent("change",R)}}}}if(this.readyToInit()){this.uiElements.getIsSwatchRootDisplayed()||this.uiElements.renderSwatchRoot(this.uiElements.getSwatchRoot(this.productInfoTree.getOptions()),this.getCorrectSwatchRoot()),r=this.getCurrentOptionForCollection();var B=undefined;B=b?b.trim():this.multiLingualInfo.money_format.trim(),s=this.productInfoTree.getNodeByOptions(r,B,this.getMoneyWithFormat.bind(this)),Object.entries(s).forEach(function(e){var i=_slicedToArray(e,2),n=i[0],s=i[1];if(null==a){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"),$("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 i=_slicedToArray(e,2),n=i[0],r=i[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((S=r.closest(".swatch-navigable, variant-swatch-king"))&&"VARIANT-SWATCH-KING"!=S.tagName){S.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"),b=0;b0)return a}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,a){var i=!(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],s=arguments.length<=6||arguments[6]===undefined?null:arguments[6];if(!window.sessionStorage)return null;var l=t?this.getHandleFromURL(e):e,c=this.getMultiLingualInfo(),u=n||(window.Shopify&&window.Shopify.country?window.Shopify.country:"NULL"),d=r||o(a?c.default_language:c.current_language).toUpperCase();return"storefront"===S?s?"starapps_storefront_"+s+"_"+l+"_"+d+"_"+u:"starapps_storefront_detailed_"+l+"_"+d+"_"+u:i?s?"starapps_storefront_"+s+"_"+l+"_"+d+"_"+u:"starapps_storefront_detailed_"+l+"_"+d+"_"+u:"starapps_"+l+"_"+d+"_"+u}},{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 a=function(){var a=(new Date).getTime();null!=t?t.created_at=a:t={id:null,created_at:a};var i=JSON.stringify(t);return setTimeout(function(){try{sessionStorage.setItem(e,i)}catch(t){}},0),{v:!0}}();if("object"==typeof a)return a.v}return!1}},{key:"removeDataToSessionStorage",value:function(e){return!(!window.sessionStorage||"string"!=typeof e)&&(sessionStorage.removeItem(e),!0)}},{key:"handleMultipartResponse",value:async function(e){var t={initial:null,deferred:null},a=e.body?e.body.getReader():e._bodyInit&&e._bodyInit.stream?e._bodyInit.stream().getReader():null;if(!a)return $(["Product data is not fetched... ",e]),t;for(var i=new TextDecoder,n="";;){var r=await a.read(),s=r.done,o=r.value;if(s)break;if((n+=i.decode(o,{stream:!0})).includes("--graphql")){var l=n.split("--graphql");n=l.pop()||"";var c=!0,u=!1,d=undefined;try{for(var p,h=l[Symbol.iterator]();!(c=(p=h.next()).done);c=!0){var g=p.value;if(g.trim()){var f=g.match(/{.*}/s);if(f)try{var v=JSON.parse(f[0]);t.initial?t.deferred=v:t.initial=v}catch(m){console.error("Error parsing chunk:",m)}}}}catch(_){u=!0,d=_}finally{try{!c&&h["return"]&&h["return"]()}finally{if(u)throw d}}}}return t}},{key:"fetchProductData",value:async function(e){for(var t=this,a=[],i=0,n=!0,r=null,s=null,o=null,l=g+"api/"+c+"/graphql.json";n&&i0?m.incremental[m.incremental.length-1].data.variants:null){var _=v.nodes||[];a=[].concat(_toConsumableArray(a),_toConsumableArray(_)),n=v.pageInfo.hasNextPage||!1,r=v.pageInfo.endCursor||null,i=0}else console.log("deferData not found ::: "),n=!1}()}catch(u){i++,console.warn("Attempt "+i+" failed: "+u.message),"function"==typeof window.reportError&&window.reportError(u),i>=j?n=!1:await new Promise(function(e){return setTimeout(e,1e3*Math.pow(2,i-1))})}return{productData:s,allVariants:a,context:o}}},{key:"disableAdd2CartButton",value:function(e,t){var a=this.clientSpecs.getSelectors(),i=this.currentDocument.querySelectorAll(a.add_to_cart_selector);Object.entries(i).forEach(function(i){var n=_slicedToArray(i,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(a.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(),a=this.currentDocument.querySelectorAll(t.add_to_cart_selector);Object.entries(a).forEach(function(a){var i=_slicedToArray(a,2),n=i[0],r=i[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 a=this.clientSpecs.getSelectors().option_index_attributes,i=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],b=r.getAttribute(w);if(b){m=b;break}}}var S=this.themeSupportConfig.index_strategy,k=this.productInfoTree.getOptionKeyByName(m,f,S,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(i.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),a=0;a0)for(var S=0;S0&&c==r.length-1&&(d=!0,u=o[0]);var f=d&&i.value!=u.id;if(d&&this.doNotSelectAnOption.status&&this.doNotSelectAnOption.trusted_event_detected&&(f=!0),f){this.themeSupportConfig.last_variant_id=u.id,i.value=u.id,this.dispatchEvent("change",i);var v=i.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);_&&(""==i.value?_.setAttribute("disabled",!0):_.removeAttribute("disabled"));var y=Z();this.allOptionsData.variantId!=y&&(this.allOptionsData.variantId=y,this.dispatchCustomEvent(i,"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,a=null,i=null,n=null,r=null,s={},o={},l=!1,c=!1,u=undefined,d=undefined,p="optionValueName";d=b?b.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+="&"+w+"="+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,C=u.parentNode.querySelector("ul.swatch-drop-down-list"),x="true"==T.getAttribute("aria-expanded");return T.setAttribute("aria-expanded",!x),void C.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,P=this.clientSpecs.getTriggerActionByOptionName(L),N=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"==P&&N.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 F=u.closest("div.swatch-single").querySelector("label.swatch-label");if(this.uiElements.isDropDown(u.tagName)){var V=document.createElement("option");V.value="",V.innerHTML=q,u.insertBefore(V,u.options[0]),u.selectedIndex=0}else if("select_value"==u.getAttribute("type")){var R=u.closest(".swatch-drop-down-inner");if(R)(R=R.querySelector('[type="select"]')).querySelector("span").innerHTML=q,this.setSelectMinWidth(R)}else F.hasAttribute("original-text")||F.setAttribute("original-text",F.innerHTML),F.innerHTML=''+q;if(!this.doNotSelectAnOption.allow_virtual_trigger){if(this.doNotSelectAnOption.control_add_to_cart)j=(j=this.getTranslation(this.doNotSelectAnOption.make_a_selection_text)).replace(/{{\s*option_name\s*}}/gm,this.doNotSelectAnOption.option_name),this.disableAdd2CartButton(j,this.clientSpecs.getSelectors().add_to_cart_disabled_classes);return}l=!0}else if(!M){this.doNotSelectAnOption.trusted_event_detected=!0,this.restoreAddToCart();var H=(F=u.closest("div.swatch-single").querySelector("label.swatch-label")).getAttribute("original-text");H&&(F.removeAttribute("original-text"),F.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"),a=r,this.uiElements.isDropDown(u.tagName))i=u.value;else{i=u.getAttribute("orig-value"),n=u.getAttribute("option-value-id");var z=u.closest("[option-target]").querySelector("span.swatch-variant-name"),B=u.getAttribute("data-value");z&&"null"!=i&&"none"!=B&&(z.innerHTML=' '+this.labelSplitSymbol+" "+B)}var j;if(l||this.uiElements.selectSwatch(r,u,i),this.changeSwitch(this.themeCode).change(r,i,n),l)if(this.doNotSelectAnOption.control_add_to_cart)j=(j=this.getTranslation(this.doNotSelectAnOption.make_a_selection_text)).replace(/{{\s*option_name\s*}}/gm,this.doNotSelectAnOption.option_name),this.disableAdd2CartButton(j,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 U=this.getCorrectSwatchRoot();if(this.uiElements.getIsSwatchRootDisplayed()||this.uiElements.renderSwatchRoot(this.uiElements.getSwatchRoot(this.productInfoTree.getOptions()),U),s=this.currentOptionSwitch(this.themeCode).get(),$(s),"undefined"==typeof s.option1){$("currentOption was not properly formed!");for(var W=this.productInfoTree.getOptions(),G=0;G0&&v[0].closest&&(v[0].closest("div.swatch-single").style.display="none"),$("Generated UI for - "+i);var m=s[i],_=!1;if(Object.entries(v).forEach(function(e){var i=_slicedToArray(e,2),r=i[0],s=i[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((x=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 b=s.closest(".swatch-drop-down-inner");if(b)if((u=b.querySelectorAll(".swatch-drop-down-list li")).length>0){var S=!1,k=!0,A=!1,I=undefined;try{for(var T,C=u[Symbol.iterator]();!(k=(T=C.next()).done);k=!0){var x;if((x=T.value).getAttribute("value")===m||x.getAttribute("option-value-id")===m){o=m,l=m,S=!0;break}}}catch(y){A=!0,I=y}finally{try{!k&&C["return"]&&C["return"]()}finally{if(A)throw I}}S||(m=u[0].getAttribute("orig-value"),"optionValueName"==p&&(m=u[0].getAttribute("option-value-id")))}else $("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)}a="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){if(!e)return null;var a=e.optionValues[0].id.match(/\d+/)[0],i=e.optionValues.find(function(e){return e.name.toLowerCase()===t.toLowerCase()});return i?i.id.match(/\d+/)[0]:a}},{key:"getMatchingOptionName",value:function(e,t){if(!e)return null;var a=e.optionValues[0].name,i=e.optionValues.find(function(e){return e.name.toLowerCase()===t.toLowerCase()});return i?i.name:a}},{key:"findMatchingOption",value:function(e,t){var a=t.toLowerCase(),i=!0,n=!1,r=undefined;try{for(var s,o=e[Symbol.iterator]();!(i=(s=o.next()).done);i=!0){var l=s.value;if(l.name.toLowerCase()===a)return"optionValueName";if(l.id.match(/\d+/)[0]===t)return"optionValueId"}}catch(c){n=!0,r=c}finally{try{!i&&o["return"]&&o["return"]()}finally{if(n)throw r}}return"optionValueName"}},{key:"resSliderSize",value:function(e,t,a){var i=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,b=undefined,S=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)),C=T;"swatch-pill"==t.swatch_type||"button"==a?(_=0,o.querySelectorAll(s).forEach(function(e,t){e.style.width=e.getBoundingClientRect().width+"px",_=_+e.getBoundingClientRect().width+C,e.firstChild instanceof Element&&null!==e.querySelector(".swatch-selected")&&(b=(_-e.getBoundingClientRect().width)/(.8*d),S=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,_-=C)})):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 a=t.last_swatch_preview ;n.matches&&(a=t.mobile_last_swatch_preview);var i=(d+C)/(v+C);"mode_1"==k&&(i=(p+C)/(v+C));var r=0;if(i>=l&&!I)r=parseInt(i);else{switch(a){case"full":if(i=(d+C)/(v+C),r=parseInt(i),A=d-r*v,(C=Math.max(A/(r>1?r-1:1),T))>A/(r>1?r-1:1)){var c=d-(r-1)*C;r=Math.floor(c/v)}break;case"half":var u=(d-(Math.floor(i)*v+Math.floor(i)*C))/v*100,y=undefined;if((u<20||u>80)&&i>1)if(u<20){y=80,r=Math.floor(i)-1;var w=y/100*v;C=parseFloat(((d-(r*v+w))/r).toFixed(3))}else{w=(y=80)/100*v;var x=Math.floor(i)+w/v;r=Math.floor(x),C=parseFloat(((d-(r*v+w))/r).toFixed(3))}else r=Math.floor(i)}var E=o.querySelector(s+":last-child");E&&(E.style.width=v+"px")}m=r,_=(v+C)*(l-1)+v,o.querySelectorAll(s).forEach(function(e,t){e.firstChild instanceof Element&&null!==e.querySelector(".swatch-selected")&&(b=m>0?(v+C)*t/(m*(v+C)):0,"half"==a?"mode_1"==k&&(b=m>2?(v+C)*t/((m-2)*(v+C)):t-m>=0?t-m+1:0):b=m>2?(v+C)*t/((m-2)*(v+C)):0,S=t),t!=l-1&&(e.style.width=v+"px",e.style.marginRight=C+"px")})}(),o.parentElement.setAttribute("swatch-slider","true");var x={swatchSliderItemWidth:v||0,totalScrollWidth:_,sliderWidth:d,visibleSwatches:m||0,marginRight:C,swatchType:t.swatch_type,firstSwatchWidth:y,lastSwatchWidth:w,assocViewType:a,arrowMode:k};o.style.transform="translateX(0px)",o.style.display="flex";var E=o.closest("[option-name]");if("mode_1"==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"),x.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(x)),!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"),x.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 b=parseInt(b),setTimeout(function(){for(var t=0;t=t.touches[0].clientX?i.clickToScroll(1,e.closest(".swatch-navigable")):i.clickToScroll(0,e.closest(".swatch-navigable")))},{capture:!0}),o.addEventListener("touchend",function(){r=0},{capture:!0}))},200),o.parentElement.setAttribute("data-slider-data",JSON.stringify(x)),!0}},{key:"resStackSize",value:function(e,t,a){if("swatch-pill"!=t.swatch_type&&"button"!=a&&t.adjust_margin_right){var i=window.matchMedia?window.matchMedia("screen and (max-width: 480px)"):screen.width<=480,n=t.adjust_margin_right;if(i.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 a=e.find(function(e){return e.name===t});return a?a.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 a=arguments.length<=2||arguments[2]===undefined?null:arguments[2],i=arguments.length<=3||arguments[3]===undefined?null:arguments[3];return null==a?e[t]!=undefined:null==i?e[t][a]!=undefined:e[t][a]!=undefined&&e[t][a][i]!=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,a){return{min_price:e[t][a].min_price,max_price:e[t][a].max_price,is_equal:e[t][a].min_price==e[t][a].max_price}}},{key:"getOption3Price",value:function(e,t,a,i){return{min_price:e[t][a][i].min_price,max_price:e[t][a][i].max_price,is_equal:e[t][a][i].min_price==e[t][a][i].max_price}}},{key:"getOptionPriceInfo",value:function(e){var t=arguments.length<=1||arguments[1]===undefined?null:arguments[1],a=arguments.length<=2||arguments[2]===undefined?null:arguments[2],i=this.productInfoTree.getOptionValueByOptionId(e),n=this.productInfoTree.getOptionValueByOptionId(t),r=this.productInfoTree.getOptionValueByOptionId(a);b=b?b.trim():this.multiLingualInfo.money_format.trim();var s=this.productInfoTree.getPriceInfoTree(),o=null;if(null==n)o=(u=this.getOption1Price(s,i)).is_equal?this.getMoneyWithFormat(b,u.min_price):this.getMoneyWithFormat(b,u.min_price)+"+";else if(null==r){if(this.checkValidPrice(s,i,n))o=(c=this.getOption2Price(s,i,n)).is_equal?this.getMoneyWithFormat(b,c.min_price):this.getMoneyWithFormat(b,c.min_price)+"+";else o=(u=this.getOption1Price(s,i)).is_equal?this.getMoneyWithFormat(b,u.min_price):this.getMoneyWithFormat(b,u.min_price)+"+"}else if(this.checkValidPrice(s,i,n,r)){var l=this.getOption3Price(s,i,n,r);o=l.is_equal?this.getMoneyWithFormat(b,l.min_price):this.getMoneyWithFormat(b,l.min_price)+"+"}else if(this.checkValidPrice(s,i,n)){var c;o=(c=this.getOption2Price(s,i,n)).is_equal?this.getMoneyWithFormat(b,c.min_price):this.getMoneyWithFormat(b,c.min_price)+"+"}else{var u;o=(u=this.getOption1Price(s,i)).is_equal?this.getMoneyWithFormat(b,u.min_price):this.getMoneyWithFormat(b,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],a=arguments.length<=2||arguments[2]===undefined?null:arguments[2];if("storefront"==S){var i=e.id.match(/\d+/)[0];this.setDataToSessionStorage(this.getSessionStorageKey(e.handle,!1,!1,!1,t,a),e),this.setDataToSessionStorage(this.getSessionStorageKey(i,!1,!1,!1,t,a),e)}else this.setDataToSessionStorage(this.getSessionStorageKey(e.handle,!1,!1),e)}},{key:"processJSONInformation",value:function(e){var t=this,a=arguments.length<=1||arguments[1]===undefined?null:arguments[1],i=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,a){return e[t.id]=a+1,e},{}),u=0;u0&&"undefined"==typeof n[0].merged_options&&this.updateSessionStorageProductData(e,m,_);for(u=0;u=0;J--){var K=f[H][J];if(K!=undefined&&(U=K.name==z&&K.value==n[u][H])){W=G-J;break}}if(U)null!=F&&(q&&(F.available=q),V>=0&&(F.min_price=F.min_price&&V>F.min_price?F.min_price:V,F.max_price=F.max_price&&V1&&(X.featured_image.secondary_src=Z[1],X.featured_image.last_src=Z[Z.length-1])}null!=F&&q&&(F.available=q),null!=F&&V>=0&&(F.min_price=F.min_price&&V>F.min_price?F.min_price:V,F.max_price=F.max_price&&V0&&(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,i,s,P),$(["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,a){t.processJSONInformation(e,a)},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 a=window.decodeURI(window.location.pathname.replace(/\/$/,"")),i=a.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",a),"quick_view"!=this.instanceSubType){if(i&&!n)if("storefront"==S){if("pending"==window.starAppsStudioStorefrontDataRequest)return void this.retryFetchInformationFromJs(100);if("undefined"!=typeof window.starAppsStudioStorefrontData&&window.starAppsStudioStorefrontDataURL==a)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==a)return void setTimeout(function(){window.starAppsStudioJSDataRequest="complete",e.processJSONInformation(window.starAppsStudioJSData)},100);window.starAppsStudioJSDataRequest="pending"}if(i||n)if("storefront"==S){n||(n=a.split("/products/")[1]);var r=window.Shopify.locale;this.executeFetch({handle:n,locale:r,path_name:i&&!n?a:null,allow_processing:!0,translation_request:!1,callback:null})}else{var s=undefined;s=n?this.getMultiLingualInfo().current_url+"/products/"+n+".js":a+".js",$("JS data fetch request initiated for URL: "+s),this.executeFetch({url:s,path_name:i&&!n?a:null,allow_processing:!0,callback:null,translation_request:!1})}else this.productUndefined=!0}}}},{key:"executeFetch",value:async function(e,t){var a,i=this,n=e.path_name,r=e.allow_processing,s=e.callback,l=e.translation_request;if("storefront"==S){var c=e.handle,u=o(e.locale),d=window.Shopify.country,p="\n query productDetails($variantsCursor: String) @inContext(country: "+d.toUpperCase()+", language: "+u+') {\n product(handle:"'+c+'") {\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 compareAtPriceRange {\n maxVariantPrice {\n amount\n }\n minVariantPrice {\n amount\n }\n }\n ... on Product @defer {\n variants(first: 250, after: $variantsCursor) {\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 pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n }\n ';this.clientSpecs.storefront_access_token,JSON.stringify({query:p});if((m=this.getDataFromSessionStorage(this.getSessionStorageKey(c,!1,l)))&&!t)return void(null!==m.id&&(n&&(window.starAppsStudioStorefrontDataRequest="complete",window.starAppsStudioStorefrontDataURL=n,window.starAppsStudioStorefrontData=m),r&&(this.processJSONInformation(m),$("JS data fetch request finished")),s&&s.call(this,m)));if(window.fetch){var h=await this.fetchProductData(p),g=h.productData,f=h.allVariants,v=h.context;g&&(g.variants={nodes:[].concat(_toConsumableArray(f))},n&&(window.starAppsStudioStorefrontDataRequest="complete",window.starAppsStudioStorefrontDataURL=n,window.starAppsStudioStorefrontData=g),r&&(this.processJSONInformation(g,v),$("Storefront data fetch request finished")),s&&s.call(this,g,v))}}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),$("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&&(i.processJSONInformation(e),$("JS data fetch request finished")),s&&s.call(i,e)}):((a=new XMLHttpRequest).open("GET",_,!0),a.onload=function(){if(a.status>=200&&a.status<400){var e=JSON.parse(a.responseText);n&&(window.starAppsStudioJSDataRequest="complete",window.starAppsStudioJSDataURL=n,window.starAppsStudioJSData=e),r&&(this.processJSONInformation(e),$("JS data fetch request finished")),s&&s.call(this,e)}}.bind(i),a.send())}}},{key:"executeStorefrontFetch",value:async function(e){var t=this,a=e.callback,i=g+"api/"+c+"/graphql.json",n=e.query,r=e.isMultiple,s={method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.clientSpecs.storefront_access_token},body:JSON.stringify({query:n})};if(window.fetch)if(r)fetch(i,s).then(function(e){return e.json()}).then(function(e){if(a){var i=e.extensions?e.extensions.context:null;a.call(t,e.data,i)}});else{var o=await this.fetchProductData(n),l=o.productData,u=o.allVariants,d=o.context;l&&(l.variants={nodes:[].concat(_toConsumableArray(u))},a&&a.call(this,{product:l},d))}}},{key:"regenerateSwatches",value:function(t){var a=t.target;if(a.getAttribute("swatch-generated")!=a.getAttribute("sa-groups-generated")){var i=a.querySelector("variant-swatch-king");i&&i.remove(),a.setAttribute("swatch-generated","none"),setTimeout(function(){new e("collections",a,null).initialize()},100)}}},{key:"initialize",value:function(){var e=this;if($("Hey! I have started working with setting - "+this.themeCode),!this.eventsRegistered){var t=function(){var t=["click","change","virtual_click","keyup"];e.isInstanceTypeCollection()&&F.switch_on_hover&&(t.push("mouseover"),t.push("mouseout"));var a=e.getCorrectSwatchRoot(),i=null;if(e.isInstanceTypeProduct()&&e.groupsDisplaySelector&&(i=e.getCorrectSwatchRoot("groups")),!a&&!i)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&&(a&&a.addEventListener(s,e.generateUISwitch()),i?i.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(),document.addEventListener("vkcl:product:changed",e.regenerateSwatches)}();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 a=document.querySelectorAll("ul.swatch-drop-down-list:not(.swatch-hide)"),i=0;i0;e.detectAndInitialize(i),Y(a)}else e.productUndefined&&($("Product not found!"),Y(a))}catch(n){$(["Loading Failed... Retrying.",n]),Q()&&t>=3?Y(a):Q()&&"SelectorNotFoundException"==n&&t++}},250)}}]),e}(),G=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),a=this.getVariantsKeys()||[],i=this.getVariants()||[],n=!1,r=null,s=0;s'+this.theme_setting.custom_css+" "+this.getSizeChartConfig().size_chart_app_css+""}},{key:"getCustomScripts",value:function(){var e=this.theme_setting.custom_scripts;if(0!=e.length){for(var t="",a=0;a"}},{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,a){e=this.cvt2HTMLEntities(e);var i=this.clientSpecs.getSwatchPresentation("collections").minified_template;i=(i=(i=(i=i.replace(RegExp("{count}","gi"),t)).replace(RegExp("{option_name}","gi"),e)).replace(RegExp("{product_id}","gi"),a.id)).replace(RegExp("{product_handle}","gi"),a.handle);var n=g;return n&&""!=n&&(n=n.replace(/\/$/,"")),i=i.replace(RegExp("{routes_root}","gi"),n),this.parseHTML('
  • '+i+"
  • ")[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"]'),a="";if("object"==typeof e||"array"==typeof e)for(var i=0;i",document.querySelector("head").appendChild(this.parseHTML(a)[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(),a=this.clientSpecs.getSizeChartConfig(),i="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 a=this,i=arguments.length<=2||arguments[2]===undefined?"options":arguments[2];if(!this.isSwatchRootDisplayed[i]){var n,r,s=t.querySelector(".swatches.swatches-type-"+this.instanceType);s&&s.querySelector("[option-target]")&&s.parentNode.removeChild(s),t.innerHTML=e,this.isInstanceTypeProduct()&&(n=a.clientSpecs.getSizeChartConfig(),r=[{type:"size_chart",append_to:"span.swatch-size-chart",element_selector:a.clientSpecs.getSizeChartSelector()}],Object.entries(r).forEach(function(e){var t,i,r,s=_slicedToArray(e,2),o=(s[0],s[1]),l=o.append_to,c=o.element_selector;c&&(r=a.currentDocument.querySelector(l))&&(t=5e3,i=setInterval(function(){t-=250;var e=document.querySelector(c);if(e){r.appendChild(e);var a=r.parentElement.querySelector("span.swatch-label-container");if(a){var s="size-chart-"+n.position;a.classList.add(s),a.appendChild(r)}clearInterval(i)}else t<=0&&clearInterval(i)},250))})),this.isSwatchRootDisplayed[i]=!0}}},{key:"renderNormal",value:function(e,t,a){var i=this,n=a.querySelector('[option-target="'+e+'"]'),r=n.querySelector(".swatch-single"),s=n.querySelector(".swatch-size-chart");r&&(s&&n.insertBefore(s,r),n.removeChild(r));var o=this.parseHTML(t)[0];n.appendChild(o),n.classList.remove("swatch-hide");var l,c,u=n.querySelector("label.swatch-label"),d=n.querySelector(".visually-hidden-label"),p=n.querySelector("legend");return this.isInstanceTypeProduct()&&(l=i.clientSpecs.getSizeChartConfig(),c=[{type:"size_chart",append_to:"span.swatch-size-chart"}],Object.entries(c).forEach(function(e){var t=_slicedToArray(e,2),a=(t[0],t[1]),n=i.currentDocument.querySelector(a.append_to);if(n){var r=n.parentElement.querySelector("span.swatch-label-container");if(r){var s="size-chart-"+l.position;r.classList.add(s),p.appendChild(d),r.appendChild(u),r.appendChild(n)}}})),n.querySelectorAll(".swatch-selector")}},{key:"getFlexibleSize",value:function(e){e=parseInt(e.replace("px",""));var t=window.innerWidth,a=t/500;return t>=992&&(a=.4*t/500),a=Math.max(a,.75),e*(a=Math.min(a,1.25))+"px"}},{key:"getLazyResolution",value:function(e,t,a,i){var n=!0;"cover"!=a&&"contain"!=a||("contain"==a&&(n=!1),a="100%"),a=parseInt(a.replace("%","")),a*=2;var r="center";i&&(r=i);var s="",o="width="+parseInt(t[0].replace("px",""))*(a/100)+"&height="+parseInt(t[1].replace("px",""))*(a/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,a={getView:null};switch(e.assoc_view_type){case"swatch":t=e[this.instanceType+"_swatch"],a.getView="custom_swatch"==t?this.getCustomImageView.bind(this,e):this.getVariantImageView.bind(this,e);break;case"drop_down":a.getView=this.getDropDownView.bind(this,e);break;case"swatch_drop_down":a.getView=this.getDropDownViewCustom.bind(this,e);break;case"button":a.getView=this.getButtonView.bind(this,e);break;case"hidden":a.getView=this.getHiddenView.bind(this,e)}return a}},{key:"cvt2HTMLEntities",value:function(e){return e.replace(/&/g,"&").replace(/>/g,">").replace(/
    ";l+='",l+='","swatch-view-slide"==n&&(l+='
    ',l+='
    ',l+=this.getSwatchSlideStyleHTML("left"));var c="tooltip"==e.params.option_value_display,u=this.isInstanceTypeCollection()?"32px":"80px",d=this.isInstanceTypeCollection()?"32px":"80px";l+='
      ';for(var p=e.params.width||e.params.swatch_size||u,h=e.params.height||e.params.swatch_size||d,g=0;g',l+='
      ',"outside_swatch"===e.params.badge_position&&(l+=this.renderBadge(e,a.data[g],r)),l+='
      ";var w=this.defaultFeaturedImage,b=a.data[g].featured_image;b!=undefined&&(w=this.getImageSrc(b,e.products_swatch,e.collections_swatch));var S=w&&"none"!=w;S&&($("Requested background image with URL("+w+")"),w=this.getLazyResolution(w,[p,h],e.params.background_size,e.params.background_position)),l+='
      ',"outside_swatch"!==e.params.badge_position&&(l+=this.renderBadge(e,a.data[g],r)),l+='
      ';var k="adjacent"==e.params.option_value_display;if(l+='

      '+m+"

      ",e.params.price_badge){var A=!!e.params.price_badge.price_enabled;(!s||s&&1==a.show_price&&!V)&&(l+='
      '+a.data[g].price+"
      ")}l+="
      ",c&&(l+='
      \n '+m+'\n
      \n
      '),l+=""}}return l+="
    ","swatch-view-slide"==n&&(l+=this.getSwatchSlideStyleHTML("right"),l+="
    "),l+="
    "}},{key:"generateChecksum",value:function(e){var t=e.length,a=undefined,i="";if(0===t)return 0;for(e=e.replace(new RegExp("\n\ts"),""),a=0;a=300?300:100*Math.ceil(a/100)}},{key:"getSwatchImageURL",value:function(e,t){for(var a=[{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"}],i=0;i
    ";o+='",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+='
      ',"outside_swatch"===e.params.badge_position&&(o+=this.renderBadge(e,a.data[g],w)),o+='
      ";var S=null;if(r)r&&(S=this.getLazyResolution(a.data[g].featured_image.src,[d,p],e.params.background_size,e.params.background_position));else{var k=a.untranslated_name?a.untranslated_name:a.name,A=a.data[g].untranslated_value?a.data[g].untranslated_value:f;S=this.getSwatchImageURL(k,A)}if(this.clientSpecs.app_setting_config.use_optimized_urls){var I=S.split("/");S=I.slice(0,-1).join("/")+"/"+h+"/"+I.pop().replace(".media",".webp")}if(o+='
      ',"outside_swatch"!==e.params.badge_position&&(o+=this.renderBadge(e,a.data[g],w)),o+='
      ',o+='

      '+_+"

      ",e.params.price_badge){var T=!!e.params.price_badge.price_enabled;(!r||r&&1==a.show_price&&!V)&&(o+='
      '+a.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,a){var i="undefined"!=typeof a.product_group_index,n=i?' data-group-index="'+a.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='",c='";"inline"!==e.params.label_display_position&&(o+=l),"inline"===e.params.label_display_position&&(o+="
    ",o+=l),o+=c,"swatch-view-slide"==s&&(o+='
    ',o+='
    ",o+=this.getSwatchSlideStyleHTML("left")),o+='
      ';for(var u=0;u',o+="
      ",o+=" "+(e.params.radio_button?"
      ":""),o+="
      ",o+='
      '+h+"
      ",e.params.price_badge){var m=!!e.params.price_badge.price_enabled;(!i||i&&1==a.show_price&&!V)&&(o+='
      '+a.data[u].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,a){var i="undefined"!=typeof a.product_group_index,n=i?' data-group-index="'+a.product_group_index+'"':"",r='
    ",s="",o="";"default"==e.params.dropdown_type&&(r+='",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,a){ var i="undefined"!=typeof a.product_group_index,n=i?' data-group-index="'+a.product_group_index+'"':"",r='
    ",s="",o="";r+='",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=C+' '+(s=y)+""),r+='
  • ',r+=C,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,a){for(var i="",n=0;n\n \n ",l))break}return i}},{key:"selectSwatch",value:function(e,t,a){var i="swatch-selected";if("undefined"!=typeof this.selectedSwatches[e]){var n,r=this.selectedSwatches[e];if(r.classList.remove(i),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=a),t.classList.add(i),"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,a){var i="",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),c=y.app_setting_config.preset_badge;r&&n>this.clientSpecs.getPresetBadgeOrder(H)&&this.isNewPreset(t.published_at)&&!a&&(i="\n "+this.getTranslation(y.app_setting_config.preset_badge.new_badge_text)+"\n ",n=this.clientSpecs.getPresetBadgeOrder(H)),o&&n>this.clientSpecs.getPresetBadgeOrder(B)&&!t.available&&(i="\n "+this.getTranslation(y.app_setting_config.preset_badge.sold_out_badge_text)+"\n ",n=this.clientSpecs.getPresetBadgeOrder(B)),s&&l&&n>this.clientSpecs.getPresetBadgeOrder(z)&&(i="\n "+l+"\n ",n=this.clientSpecs.getPresetBadgeOrder(z))}return i}},{key:"isNewPreset",value:function(e){var t=new Date(e);return new Date0?a/e*100:0;return e>t&&i>=y.app_setting_config.preset_badge.min_price_diff_for_sale_badge?this.applyReplacements(a,i):""}},{key:"applyReplacements",value:function(e,t){var a={"{{currency_symbol}}":y.currency_symbol,"{{currency_code}}":y.currency,"{{amount_save}}":e.toFixed(2),"{{percentage_save}}":Math.round(t)+"%"};return this.getTranslation(y.app_setting_config.preset_badge.sale_badge_text).replace(/{{(?:currency_symbol|currency_code|amount_save|percentage_save)}}/g,function(e){return a[e]})}},{key:"isAllNewPreset",value:function(e){var t=!0,a=this.clientSpecs.getPresetBadgeOrderList();if(!(a[0]===H))for(var i=a[0],n=0;n"),console.log("Swatch King:",e),console.log("Swatch King:","Timestamp",t.toString()),console.log("<--------------- END ----------------->")}},X=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,a={};if(document.location.search.substr(1).split("&").forEach(function(e){var t=e.split("=");try{a[t[0].toString()]=t[1].toString()}catch(i){}}),isNaN(a.variant)){var i=undefined;e?(i=e.querySelector('[name="id"]'))&&(t=i.value):(i=document.querySelector('[name="id"]'))&&(t=i.value)}else a.variant&&(t=a.variant);return t},Y=function(e){clearInterval(parseInt(e)),$(["Interval Removed...",e])},Q=function(){return"complete"===document.readyState||"loaded"===document.readyState},ee=function(){if(s("VariantSwatchKing")){if(t(),!w)return;(k||I||C||E||O||P||M)&&(te(),document.addEventListener("vsk:product:refresh",function(){setTimeout(function(){te(),$("Refreshing product swatch lookup complete.")},0)})),(A||T||x||D||L||N||q)&&ae()}},te=(setInterval(function(){ee()},500),function ne(){u||(u=new J);var e=u.getSelectors().swatch_root;e.use_section_as_root?function(){var t=!1,a=document.querySelectorAll(e.section_selector);if(!h){var i=window.location.pathname.includes("/products");t=1==a.length&&i}Object.entries(a).forEach(function(e){var a=_slicedToArray(e,2),i=a[0],n=a[1];if("length"!=i&&"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 W("products",n,r).onInstanceActivate()}});var n=Q()?1e3:250;setTimeout(ne.bind(_this26),n)}():new W("products",document,null).onInstanceActivate()}),ae=function(){u||(u=new J);var e=u.getCollectionConfig(),t=u.getCollectionSettings();ie(e,t,!0),document.addEventListener("vsk:render:swatches",function(){setTimeout(function(){ie(e,t,!1)},0)})},ie=function re(e,t,a){var i=document.querySelectorAll(e.swatch_root_selector);Object.entries(i).forEach(function(e){var t=_slicedToArray(e,2),a=t[0],i=t[1];"length"!=a&&("undefined"==typeof i.vsk_initialized&&(i.vsk_initialized=!0,i.setAttribute("swatch-generated","none"),new W("collections",i,null).initialize()))}),a&&t.continuous_lookup>0&&setTimeout(function(){re(e,t,!0)},t.continuous_lookup)}}();