!function(){["toonify-project"].includes(Shopify?.shop?.replace(".myshopify.com",""))||console.log("%cLinkedOption Combined Listings %cLink Separate Products with Size, Color, and More. Versatile Support for Buttons, Swatches, Dropdown. see: https://apps.shopify.com/linked-options?utm_source=console","color: #5e17ec; font-family: sans-serif; font-size: 2em; font-weight: bold; line-height: 2;","color: blue; line-height: 1.5"),"1"===new URLSearchParams(window.location.search).get("debug")&&localStorage.setItem("king-linked-options-debug","1");const i="1"===localStorage.getItem("king-linked-options-debug");u("GLOBAL","Debug mode enabled");function u(t,e,...o){i&&("GLOBAL"===t?console.log("[LinkedOption] "+e,...o):console.log(`[LinkedOption] [${t}] `+e,...o))}function h(t,e,...o){"GLOBAL"===t?console.error("[LinkedOption] "+e,...o):console.error(`[LinkedOption] [${t}] `+e,...o)}function r(t,e){let o=0,i=0,r=!1;t.addEventListener("touchstart",function(t){o=Date.now(),r=!1}),t.addEventListener("touchmove",function(){r=!0}),t.addEventListener("touchend",function(t){(i=Date.now())-o<300&&!r&&e(t)})}const n={XS:24,SMALL:30,MEDIUM:48,LARGE:60,XL:100,XXL:140};function a(t){let e=t.swatchSize??0;var o;return e<=0&&((o=n[t.size.toUpperCase()])?e=o:"IMAGE_SWATCH"===t.type?e=48:"COLOR_SWATCH"===t.type&&(e=30)),e}function s(t){return"16:9"===t||"4:3"===t}function d(t){return t?String(t).trim().split(":").join("/"):"1/1"}function g(t,e){return 1==t.colorType?{background:t.color}:2==t.colorType?{background:`linear-gradient(to ${e}, ${t.color} 50%, ${t.color1} 50%)`}:{backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundImage:`url(${t.colorImage})`}}function c(t){return 1==t?"":""}function l(t,e){let o=null;for(const i of t)if(function(e,o){let i=!0;for(let t=0;tt.option[e]==o[e]);if(0t.option[e]==o[e]);i=0t.option[e]==i[0].option[e])}return u("GLOBAL","findClosestProduct availableProducts",i,e,o,t),i?.[0]}return t[0]}function m(t,e){var o;for(o of[...t.getElementsByTagName("*"),t])if(function(t){if(!t||"string"==typeof t)return;var e=window.getComputedStyle(t),t=t.getBoundingClientRect();return"none"!==e.display&&"0px"!==e.width&&"0px"!==e.height&&0!==t.width&&0!==t.height}(o)&&o.textContent.trim().toLowerCase()===e.toLowerCase())return o;return!1}function R(o){let i=o.parentElement;for(;i;){let t=o.nextSibling,e=!1;for(;t;){if(t.textContent.trim()){e=!0;break}t=t.nextSibling}if(e)return i;i=(o=i).parentElement}return null}function v(t){const e={"&":"&","<":"<",">":">",'"':""","'":"'"};return t.replace(/[&<>"']/g,function(t){return e[t]})}function D(){var t,e;if((window.kingLinkedOptionConfig||(t=document.querySelector(".linked-option-variants-container"),window.linkedOptionsVariants||t?(e=window.linkedOptionsVariants.shop||t.dataset.shopOrigin,t=window.linkedOptionsVariants.productId||t.dataset.pid,window.kingLinkedOptionConfig={enabled:!0,version:"v1",shop:e,country:"",language:"",languageIso:"",currency:"",shopDomain:"",pageType:"/"==(e=window.location.pathname)?"index":e.includes("/collections/")?"collection":e.includes("/search")?"search":e.includes("/products/")?"product":e.includes("/cart")?"cart":e.includes("/blogs/")?e.match(/\/blogs\/[^/]+\/[^/]+/)?"article":"blog":e.includes("/pages/")?"page":"",moneyFormat:"",moneyFormatWithCurrency:"",prefix:"",namespace:"",hide:!0,remove:!1,storefrontAccessToken:"",cartAttributeEnabled:!0,hideDuplicate:!1,subcategoryInCardMode:"FULL_OPTION",enableSeamlessOptionSwitching:!1,seamlessSectionIds:[],themeConfig:{},product:{id:t,active:!0,groupType:"",autoScroll:!1,anchor:""},productCard:{enabled:!1,multiOptionEnabled:!1,hideOptions:"",applyPages:["collection","search"],customize:{}}}):h("GLOBAL","InitConfig failed, can not read any config")),window.kingLinkedOptionConfig)&&(window.kingLinkedOptionConfig.language&&(window.kingLinkedOptionConfig.languageIso=!(e=(e=window.kingLinkedOptionConfig.language).replace("-","_").toUpperCase()).includes("_")||["ZH_TW","ZH_CN","PT_PT","PT_BR"].includes(e)?e:e.split("_")[0]),window.kingLinkedOptionConfig?.themeConfigV2)){const o=Shopify?.theme?.id?.toString()??window.kingLinkedOptionConfig.themeConfigV2.liveThemeId.toString();u("GLOBAL","Current theme id: "+o),window.kingLinkedOptionConfig.themeConfig=window.kingLinkedOptionConfig.themeConfigV2.themes.find(t=>t.themeIds?.includes(o))??{product:{exclude:"",hide:"",points:[],variant:""},productCard:{exclude:"",hide:"",item:{card:"",link:"",price:"",compareAtPrice:"",title:"",image_1:"",image_1_type:"",image_2:"",image_2_type:""},points:[],quickAddForm:{product:{id:"",type:""},variant:{id:"",type:""}}},quickView:{}},u("GLOBAL","Config",window.kingLinkedOptionConfig)}}function f(t){for(const e of document.getElementsByTagName("script"))if(e?.src&&e.src.includes(t))return e.src;return null}function B(t){var e,o=function(t){var e=f("linked_options_variants.min.js")||f("linked_options_variants.js");if(!e)return t;try{return new URL(t,e).toString()}catch{return t}}(t);document.querySelector(`link[href="${o}"]`)||document.querySelector(`link[href*="/${t}"]`)||((e=document.createElement("link")).rel="stylesheet",e.href=o,e.dataset.kingLinkedOptions=t,document.head.appendChild(e))}function b(t,e){var o,i,r,e="with_currency"==e?window.kingLinkedOptionConfig.moneyFormatWithCurrency:window.kingLinkedOptionConfig.moneyFormat;if(o=e,i="*",(r=document.createElement("div")).innerHTML=o,o=r.textContent||"",(r=document.createElement("div")).innerHTML=o,e=(o="*"===i?r.firstChild:r.querySelector(i))?o.textContent:"",null==t)return"";let n="";return n=e.includes("no_decimals")?Math.round(t).toString():Number(t).toFixed(2),n=e.includes("with_comma_separator")?n.replace(".",",").replace(/\B(?=(\d{3})+(?!\d))/g,"."):e.includes("with_apostrophe_separator")?n.replace(/\B(?=(\d{3})+(?!\d))/g,"'"):e.includes("with_space_separator")?n.replace(".",",").replace(/\B(?=(\d{3})+(?!\d))/g," "):e.includes("with_period_and_space_separator")?n.replace(/\B(?=(\d{3})+(?!\d))/g," "):n.replace(/\B(?=(\d{3})+(?!\d))/g,","),e.replace(/{{\s*amount\s*}}/g,n).replace(/{{\s*amount_no_decimals\s*}}/g,n).replace(/{{\s*amount_with_comma_separator\s*}}/g,n).replace(/{{\s*amount_no_decimals_with_comma_separator\s*}}/g,n).replace(/{{\s*amount_with_apostrophe_separator\s*}}/g,n).replace(/{{\s*amount_no_decimals_with_space_separator\s*}}/g,n).replace(/{{\s*amount_with_space_separator\s*}}/g,n).replace(/{{\s*amount_with_period_and_space_separator\s*}}/g,n)}function w(t,e,o){var i={BEFORE:"beforebegin",AFTER:"afterend",INSIDE:"beforeend"};let r=i[e]?i[e]:e;o.insertAdjacentElement(r,t)}function y(t){var e;return!!t&&!!document.body.contains(t)&&"none"!==(e=window.getComputedStyle(t)).display&&"hidden"!==e.visibility&&"0"!==e.opacity&&0!==(e=t.getBoundingClientRect()).width&&0!==e.height&&0<=e.top+e.height&&0<=e.left+e.width&&e.bottom-e.height<=(window.innerHeight||document.documentElement.clientHeight)&&e.right-e.width<=(window.innerWidth||document.documentElement.clientWidth)}function C(t){if(null===t||"object"!=typeof t)return t;if(Array.isArray(t))return t.map(t=>C(t));var e={};for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())]=C(t[o]));return e}async function O(t){var e=t.querySelectorAll(".lv-price-loading"),o=[];for(const s of e)o.includes(s.dataset.pid)||o.push(s.dataset.pid);if(0t.id===l.dataset.pid);if(a){let t="-";a&&(t="RANGE"==l.dataset.priceType?Number(a.minPrice)==Number(a.maxPrice)?`${b(a.minPrice,l.dataset.priceFormat)}`:`${b(a.minPrice,l.dataset.priceFormat)+" - "+b(a.maxPrice,l.dataset.priceFormat)}`:l.dataset.showCompareAtPrice&&a.compareAtPrice?`${b(a.compareAtPrice,l.dataset.priceFormat)}${b(a.price,l.dataset.priceFormat)}`:`${b(a.price,l.dataset.priceFormat)}`),l.innerHTML=t,l.classList.remove("lv-price-loading")}}}}}let o={};function S(t){let e=o[t];return e&&document.body.contains(e)||(e=document.querySelector(t))&&(o[t]=e),e}function z(e,o){for(let t=0;tthis.cachedGroups[t].exists(e));if(!o){t=await this.queryGroupByProductIds([e]);if(!(0void 0===this.cachedProducts[t]);return(0{this.cachedProducts[t.id]=t}),t.map(t=>this.cachedProducts[t])}async queryProductByIds(o){var t=await e(`{${o.map((t,e)=>`product${e}: product(id: "gid://shopify/Product/${t}") {id handle title images(first: 2) { nodes { url altText } } variants(first: 1) { nodes { id price { amount } compareAtPrice { amount } } } priceRange { maxVariantPrice { amount } minVariantPrice { amount } } }`).join("\n")}}`);return t?Object.values(t.data).map((t,e)=>t?{id:t.id.replace("gid://shopify/Product/",""),handle:t.handle,title:t.title,images:t.images.nodes,price:t.variants.nodes[0].price?.amount,compareAtPrice:t.variants.nodes[0].compareAtPrice?.amount,minPrice:t.priceRange.minVariantPrice?.amount,maxPrice:t.priceRange.maxVariantPrice?.amount,variantId:t.variants.nodes[0].id.replace("gid://shopify/ProductVariant/","")}:{id:o[e],handle:"",title:"",images:[],price:null,compareAtPrice:null,minPrice:null,maxPrice:null,variantId:null}):(h("GroupDataManager","queryProductByIds failed, data is null"),[])}async queryGroupByProductIds(t){return this.config.storefrontAccessToken?(t=await e(`{${t.map((t,e)=>`product${e}: product(id: "gid://shopify/Product/${t}") { id handle title group: metafield(namespace:"$app:king-linked-options", key:"group") { reference { ... on Metaobject { templates: field(key: "templates") { references(first: 10) { nodes { ... on Metaobject { field(key: "value") { value } } } } } value: field(key: "value") { value } trans: field(key: "trans") { value } active: field(key: "active") { value } } } } }`).join("\n")}}`))?((t=this.formatGroupData(t.data)).forEach(t=>{this.cachedProductGroupMap[t.productId]=t.groupId}),t):(h("GroupDataManager","queryGroupByProductIds failed, result is null"),[]):[]}async queryGroupByProductHandles(t){return this.config.storefrontAccessToken?(t=await e(`{${t.map((t,e)=>`product${e}: product(handle: "${t}") { id handle title group: metafield(namespace:"$app:king-linked-options", key:"group") { reference { ... on Metaobject { templates: field(key: "templates") { references(first: 10) { nodes { ... on Metaobject { field(key: "value") { value } } } } } value: field(key: "value") { value } trans: field(key: "trans") { value } active: field(key: "active") { value } } } } }`).join("\n")}}`))?((t=this.formatGroupData(t.data)).forEach(t=>{this.cachedProductGroupMap[t.productId]=t.groupId,this.cachedProductHandleToProductIdMap[t.handle]=t.productId}),t):(h("GroupDataManager","queryGroupByProductHandles failed, result is null"),[]):[]}formatGroupData(t){let l=[];return Object.values(t).forEach(o=>{if(o){let t=0;const r=o.id?.replace("gid://shopify/Product/","");if(o?.group?.reference){const n=JSON.parse(o.group.reference.value.value);var e=JSON.parse(o.group.reference?.active?.value??"true"),i=(n.active=e,o.group.reference.templates?.references?.nodes?.map(t=>JSON.parse(t.field.value))),e=JSON.parse(o.group.reference?.trans?.value??"{}");if("SINGLE"===n.type)n.products=n.products.map(t=>{var e=!(void 0!==t.published&&!t.published);return{productId:t.id,handle:(t.id==r?o:t).handle,image:t.image,colorType:t.color_type,color:t.color,color1:t.color1,colorImage:t.color_image,status:t.status,published:e,value:t.value,outOfStock:t.out_of_stock,unavailable:1!=t.status||t.out_of_stock||!e,badge:t.badge}}).filter(t=>!this.config.hide||1==t.status&&t.published),n.template=i[0];else if("MULTI"===n.type){n.products=n.products.map(t=>{var e=!(void 0!==t.published&&!t.published);return{productId:t.id,handle:t.handle,badge:t.badge,status:t.status,published:e,outOfStock:t.out_of_stock,unavailable:1!=t.status||t.out_of_stock||!e,option:t.option}}).filter(t=>!this.config.hide||1==t.status&&t.published);for(const a of i)a.id,a.type;for(const s in n.options)n.options[s].template=i.find(t=>t.id==n.options[s].tpl_id);n.options=C(n.options)}else if("SUBGROUP"===n.type){const l=[];for(const d of n.sub_groups)d.products=d.products.map(t=>{var e=!(void 0!==t.published&&!t.published);return{productId:t.id,handle:t.handle,image:t.image,colorType:t.color_type,color:t.color,color1:t.color1,colorImage:t.color_image,status:t.status,published:e,value:t.value,outOfStock:t.out_of_stock,unavailable:1!=t.status||t.out_of_stock||!e,badge:t.badge}}).filter(t=>!this.config.hide||1==t.status&&t.published),l.push(...d.products);n.products=l,n.template=i[0]}n.trans=e,t=n.id,this.cacheGroup(n.id,n)}l.push({productId:r,handle:o.handle,title:o.title,groupId:t})}}),l}formatGroupDataFromLiquid(t,e){let o=t.value;if(o.active=t.active,o.trans=t.trans,"SINGLE"===o.type)o.products=o.products.filter(t=>!this.config.hide||1==t.status),o.template=e[0];else if("MULTI"===o.type){o.products=o.products.filter(t=>1==t.status);for(const i in o.options)o.options[i].template=e.find(t=>t.id==o.options[i].tpl_id)}else"SUBGROUP"===o.type&&(o.products=o.sub_groups.map(t=>t.products.filter(t=>!this.config.hide||1==t.status)).flat(2),o.template=e[0]);["SINGLE","SUBGROUP"].includes(o.type)?o.products=o.products.map(t=>({productId:t.id,handle:t.handle,image:t.image,colorType:t.color_type,color:t.color,color1:t.color1,colorImage:t.color_image,status:t.status,value:t.value,unavailable:1!=t.status||t.out_of_stock,badge:t.badge})):(o.products=o.products.map(t=>({productId:t.id,handle:t.handle,badge:t.badge,status:t.status,unavailable:1!=t.status||t.out_of_stock,option:t.option})),o.options=C(o.options));t=new I(o);return this.cachedGroups[t.id]=t}}class H{constructor(t){this.group=t}render(t,e){var o=document.createElement("king-linked-options-product");return o.id="king-linked-options-section",o.dataset.render="API",o.dataset.groupType=this.group.type,o.dataset.pid=t,o.dataset.gid=this.group.id,o.dataset.renderContext=e,"SINGLE"==this.group.type?o.appendChild(this.renderSingleOption(t)):"MULTI"==this.group.type?o.appendChild(this.renderMultiOptions(t)):"SUBGROUP"==this.group.type&&this.renderSubGroup(o,t),O(o),o}renderSingleOption(e){var t=this.group.getProduct(e);let o=[];if(this.group.value.template.displayActiveFirst){let t=null;var i=[];for(const r of this.group.products)r.productId==e?t=r:i.push(r);o=t?[t,...i]:i}else o=this.group.products;return o=o.map(t=>({...t,active:t.productId==e,disabled:1!=t.status||t.unavailable&&!this.group.value.template.outOfStockRedirect})),"HIDE"==this.group.value.template.unavailableStyle&&(o=o.filter(t=>!t.unavailable)),this.group.value.template.hideActiveProduct&&(o=o.filter(t=>!t.active)),u("ProductOptionRenderer","Render single option",{title:this.group.title,items:o}),this.renderOption(t,this.group.value.template,this.group.title,o,0)}renderMultiOptions(o){var e=this.group.getProduct(o),i=document.createElement("div");i.className="lv-option-multi-box";let r=0;for(const a of this.group.value.options){const s=[...e.option];let t=a.values.map(t=>{s[r]=t.value;var e=l(this.group.products,s);return e?{...e,value:t.value,image:t.image,images:t.images??[],colorType:t.colorType,color:t.color,color1:t.color1,colorImage:t.colorImage,disabled:!1,unavailable:1!=e.status||e.outOfStock,outOfStock:e.outOfStock,matched:!0,active:e.productId==o,badge:t.badge}:{badge:t.badge,productId:0,handle:"",status:0,value:t.value,image:t.image,images:t.images??[],colorType:t.colorType,color:t.color,color1:t.color1,colorImage:t.colorImage,disabled:!1,unavailable:!0,outOfStock:!1,matched:!1,active:!1}});"HIDE"==a.template.unavailableStyle&&(t=t.filter(t=>!t.disabled&&!t.unavailable)),a.template.hideUnmatchedVariant&&(t=t.filter(t=>t.matched));var n=this.renderOption(e,a.template,a.name,t,r);i.appendChild(n),r++}return i}renderSubGroup(t,o){var i=this.group.getProduct(o);if("DROPDOWN"==this.group.value.template.type){for(const a of this.group.value.sub_groups){var e=[];for(const s of a.products){var r=1!=s.status||s.out_of_stock,r={...s,productId:s.id,unavailable:r,active:s.id==o,disabled:1!=s.status||r&&!this.group.value.template.outOfStockRedirect};"HIDE"==this.group.value.template.unavailableStyle&&r.unavailable||e.push(r)}a.products=e}t.appendChild(this.renderSubGroupDropdown(this.group.value.template,this.group.value.sub_groups,o))}else for(const d of this.group.value.sub_groups){let e=[];if(this.group.value.template.displayActiveFirst){let t=null;var n=[];for(const l of d.products)l.id==this.config.product.id?t=l:n.push(l);e=t?[t,...n]:n}else e=d.products;e=e.map(t=>{var e=1!=t.status||t.out_of_stock;return{...t,productId:t.id,unavailable:e,active:t.id==o,disabled:1!=t.status||e&&!this.group.value.template.outOfStockRedirect}}),"HIDE"==this.group.value.template.unavailableStyle&&(e=e.filter(t=>!t.unavailable)),this.group.value.template.hideActiveProduct&&(e=e.filter(t=>!t.active)),t.appendChild(this.renderOption(i,this.group.value.template,d.name,e,0))}}renderOption(e,t,o,i,r){var n=document.createElement("div"),o=(n.className="lv-option-box",n.dataset.tpl=t.name,n.dataset.tplId=t.id,n.style.marginTop=t.marginTop+"px",n.style.marginBottom=t.marginBottom+"px",n.style.flexDirection="INLINE"==t.labelLayout?"row":"column",n.style.gap="INLINE"==t.labelLayout?"0px":t.labelSpace+"px",n.dataset.optionIndex=r,this.group.trans[o]??o);let a;var s=document.createElement("div"),d=(s.className="lv-option-label",s.style.fontSize=t.titleFontSize+"px",s.style.lineHeight=t.titleLineHeight+"px",s.style.textAlign=t.align,s.style.width="INLINE"==t.labelLayout?t.labelWidth+"px":"auto",t.hideLabel&&(s.style.display="none"),document.createElement("span"));if(d.style.fontWeight=t.titleFontWeight||400,d.innerText=o,s.appendChild(d),t.showSelectedTitle){d=document.createElement("span"),d=(d.style.fontWeight="normal",d.style.marginRight="2px",d.innerText=":",s.appendChild(d),document.createElement("span"));if(d.style.fontWeight=t.selectedTitleFontWeight||400,"SINGLE"==this.group.type)a=this.group.trans[e.value]??e.value;else if("MULTI"===this.group.type)a=this.group.trans[e.option[r]]??e.option[r];else if("SUBGROUP"==this.group.type){let t=!1;for(const c of i)if(c.productId==e.productId){t=!0;break}a=t?this.group.trans[e.value]??e.value:""}d.innerText=a,s.appendChild(d)}n.dataset.optionName=o,n.dataset.optionValue=a,n.appendChild(s);let l;return"DROPDOWN"==t.type?l=this.renderDropdownOption(t,i,r):"BUTTON"==t.type?l=this.renderButtonOption(t,i,r):"IMAGE_SWATCH"==t.type?l=this.renderImageSwatchOption(t,i,r):"COLOR_SWATCH"==t.type&&(l=this.renderColorSwatchOption(t,i,r)),n.appendChild(l),n}renderSubGroupDropdown(t,e,o){var i=document.createElement("div");i.className="lv-option-box",i.dataset.tpl=t.name;let r="",n="";for(const a of e)for(const s of a.products){if(s.productId==o){r=a.name,n=s.value;break}if(n)break}return i.dataset.optionName=this.group.trans[r]??r,i.dataset.optionValue=this.group.trans[n]??n,i.style.marginTop=t.marginTop+"px",i.style.marginBottom=t.marginBottom+"px",i.dataset.optionIndex=0,i.appendChild(this.renderDropdownOption(t,[],0,e)),i}renderDropdownOption(r,t,o,e=[]){var i=document.createElement("div"),n=(i.className="lv-option-dropdown-options-tpl",i.style.display="none",document.createElement("div")),a=(n.className="lv-option-dropdown-options",L(n,{"--border-width":r.borderWidth+"px","--border-color":r.borderColorNormal,"--bg-color":r.buttonColorNormal,"--text-color":r.textColorNormal,"--border-radius":r.borderRadius+"px","--dropdown-padding-y":r.paddingY+"px","--dropdown-padding-x":("SUBGROUP"==this.groupType?r.paddingX+10:r.paddingX)+"px","--bg-color-normal":r.buttonColorNormal,"--text-color-normal":r.textColorNormal,"--bg-color-active":r.bgColorHover,"--text-color-active":r.textColorHover,"--price-position":r.pricePosition,"--price-space":r.priceSpace+"px","--text-align":"row"==r.pricePosition?"center":"start","--price-font-size":r.priceFontSize+"px","--price-color":r.priceColor,"--price-font-weight":r.priceFontWeight,"--swatch-size":r.swatchSize+"px","--swatch-border-radius":r.swatchBorderRadius+"px","--space-after-swatch":r.spaceAfterSwatch+"px"}),{"--badge-bg-color":r.badgeBgColor,"--badge-text-color":r.badgeTextColor,"--badge-font-size":r.badgeFontSize+"px","--badge-font-weight":r.badgeFontWeight,"--badge-padding-y":r.badgePaddingY+"px","--badge-padding-x":r.badgePaddingX+"px","--badge-border-radius":r.badgeBorderRadius+"px","--badge-opacity":r.badgeOpacity+"%"});r.showBadge&&L(n,a),i.appendChild(n);let s;if("SUBGROUP"==this.group.type){const d=document.createElement("ul");d.className="lv-option-dropdown-group",e.forEach(t=>{var e=document.createElement("li"),o=(e.className="lv-option-dropdown-group-item",document.createElement("div"));o.className="lv-option-dropdown-group-label",o.style.padding=`${r.paddingY+3}px ${r.paddingX}px`,o.innerText=t.name,e.appendChild(o);const i=document.createElement("ul");i.className="lv-option-dropdown-group-options",t.products.forEach((t,e)=>{var o;t&&(t.active&&(s=t),(o=document.createElement("li")).className="lv-option-dropdown-option"+(t.active?" lv-option-dropdown-option__selected":"")+(t.unavailable?" lv-option-dropdown-option__unavailable lv-option-dropdown-unavailable__"+r.unavailableStyle.toLowerCase():"")+("MULTI"!==this.groupType&&1!=t.status?" lv-option-item__inactive":""),t.active&&o.setAttribute("selected",""),t.disabled&&o.setAttribute("disabled",""),o.dataset.pid=t.productId,o.dataset.handle=t.handle,o.dataset.status=t.status,o.dataset.value=t.value,o.dataset.optionId=e,o.appendChild(this.renderDropdownItem(t,r)),i.appendChild(o))}),e.appendChild(i),d.appendChild(e)}),n.appendChild(d)}else{const l=document.createElement("ul");l.className="lv-option-dropdown-option-set",n.appendChild(l),t.forEach(t=>{var e=document.createElement("li");e.className="lv-option-dropdown-option"+(t.active?" lv-option-dropdown-option__selected":"")+(t.unavailable?" lv-option-dropdown-option__unavailable lv-option-dropdown-unavailable__"+r.unavailableStyle.toLowerCase():"")+("MULTI"!==this.groupType&&1!=t.status?" lv-option-item__inactive":""),e.dataset.pid=t.productId,e.dataset.handle=t.handle,e.dataset.status=t.status,e.dataset.value=t.value,e.dataset.optionId=o,t.active&&e.setAttribute("selected",""),t.disabled&&e.setAttribute("disabled",""),e.appendChild(this.renderDropdownItem(t,r)),l.appendChild(e),t.active&&(s=t)})}e=document.createElement("lv-option-dropdown"),e.className="lv-option-dropdown-box",L(e,{"--dropdown-width":r.width+"%","--price-font-size":r.priceFontSize+"px","--price-color":r.priceColor,"--price-font-weight":r.priceFontWeight,"--swatch-size":r.swatchSize+"px","--swatch-border-radius":r.swatchBorderRadius+"px","--space-after-swatch":r.spaceAfterSwatch+"px","--border-color":r.borderColorNormal,"--border-width":r.borderWidth+"px","--border-radius":r.borderRadius+"px","--bg-color":r.buttonColorNormal,"--text-color":r.textColorNormal,"--padding":r.paddingY+"px "+r.paddingX+"px","--price-position":r.pricePosition,"--price-space":r.priceSpace+"px","--text-align":"row"==r.pricePosition?"center":"start"}),"INLINE"==r.labelLayout&&L(e,{flex:1}),r.showBadge&&L(e,a),n=document.createElement("div"),n.className="lv-option-dropdown",n.style.boxShadow=r.shadow,n.dataset.optionId=o,n.appendChild(this.renderDropdownItem(s,r)),t=document.createElement("div");return t.className="lv-option-dropdown-arrow",t.innerHTML=c(r.dropdownIcon),n.appendChild(t),e.appendChild(n),e.appendChild(i),e}renderButtonOption(s,t,d){const l=document.createElement("div");l.className="lv-option-group","INLINE"==s.labelLayout&&(l.style.flex=1);var e=s.align.toLowerCase();return L(l,{"--align":e,"--item-gap":s.gap+"px","--flex-direction":"right"===e?"row-reverse":"row","--shadow":s.shadow,"--border-radius":s.borderRadius<0?0:s.borderRadius+"px","--price-font-weight":s.priceFontWeight||400,"--price-color":s.priceFontColorNormal??s.textColorNormal,"--price-color-active":s.priceFontColorActive??s.textColorActive,"--border-width":s.borderWidth+"px","--border-color":s.borderColorNormal,"--border-color-active":s.borderColorActive,"--border-color-hover":s.borderColorHover??s.borderColorNormal,"--bg-color":s.buttonColorNormal,"--bg-color-active":s.buttonColorActive,"--bg-color-hover":s.buttonColorHover??s.buttonColorNormal,"--text-color":s.textColorNormal,"--text-color-active":s.textColorActive,"--text-color-hover":s.textColorHover??s.textColorNormal}),s.showBadge&&L(l,{"--badge-top":s.badgePosition.includes("top")?`-${s.badgeOffsetY}px`:"auto","--badge-bottom":s.badgePosition.includes("bottom")?`-${s.badgeOffsetY}px`:"auto","--badge-left":s.badgePosition.includes("center")?"50%":s.badgePosition.includes("left")?`-${s.badgeOffsetX}px`:"auto","--badge-right":s.badgePosition.includes("right")?s.badgeOffsetX+"px":"auto","--badge-transform":s.badgePosition.includes("center")?"translateX(-50%)":"none","--badge-bg-color":s.badgeBgColor,"--badge-text-color":s.badgeTextColor,"--badge-font-size":s.badgeFontSize+"px","--badge-font-weight":s.badgeFontWeight,"--badge-padding":s.badgePaddingY+"px "+s.badgePaddingX+"px","--badge-border-radius":s.badgeBorderRadius+"px","--badge-opacity":s.badgeOpacity+"%"}),t.forEach(t=>{var e=document.createElement("div"),o=(e.className="lv-option-wrapper",document.createElement("a"));let i=!0,r="";t.handle?(r=this.group.config.prefix+"/products/"+t.handle,this.group.config.product.autoScroll&&this.group.config.product.anchor&&(r=r+"#"+this.group.config.product.anchor),"MULTI"==this.groupType?1!=t.status&&(r="#",i=!1):t.disabled&&(r="#",i=!1)):(r="#",i=!1),o.href=r,i||(o.role="button",o.setAttribute("onclick","event.preventDefault();")),o.className="lv-option-item"+(i?" lv-option-item-link":""),t.active&&o.classList.add("lv-option-item__active"),t.unavailable&&(o.classList.add("lv-option-item-unavailable"),"NONE"!=s.unavailableStyle)&&o.classList.add("lv-option-item-unavailable__"+s.unavailableStyle.toLowerCase()),"MULTI"!==this.groupType&&1!=t.status&&o.classList.add("lv-option-item__inactive"),"ZOOM"===s.hoverEffect&&o.classList.add("lv-option-hover-effect__zoom"),o.dataset.value=t.value,o.dataset.optionId=d,o.dataset.handle=t.handle,o.dataset.pid=t.productId,o.dataset.status=t.status,t.disabled&&o.setAttribute("disabled","");var n,a=document.createElement("div");a.className="lv-option-button lv-option-button-size__"+s.size.toLowerCase(),t.active&&a.classList.add("lv-option-button__active"),t.disabled&&a.classList.add("lv-option-item-unavailable__"+s.unavailableStyle.toLowerCase()),a.innerText=this.group.trans[t.value]??t.value,s.showPrice&&t.productId&&((n=document.createElement("div")).className="lv-option-price",t.productId&&n.classList.add("lv-price-loading"),n.dataset.pid=t.productId,n.dataset.priceType=s.priceType,n.dataset.priceFormat=s.priceFormat,n.dataset.showCompareAtPrice=s.showCompareAtPrice,L(n,{"--price-color":s.priceFontColor}),"hyphen"==s.priceSeparator?(a.appendChild(document.createTextNode(" - ")),a.appendChild(n)):"round-bracket"==s.priceSeparator&&(a.appendChild(document.createTextNode(" (")),a.appendChild(n),a.appendChild(document.createTextNode(")")))),o.appendChild(a),e.appendChild(o),s.showBadge&&t.badge&&((n=document.createElement("div")).className="lv-option-badge",n.innerText=this.group.trans[t.badge]??t.badge,e.appendChild(n)),l.appendChild(e)}),l}renderImageSwatchOption(d,t,l){var e,o,i=document.createElement("div");i.className="lv-option-group","INLINE"==d.labelLayout&&(i.style.flex=1),L(i,this.getSwatchStyles(d));const c=parseInt(d.maxShowNum??200);let p=0,u=!1,h=i;return"SLIDE"==d.layoutType&&([e,o]=this.createSlide(d),h=o,i.appendChild(e)),t.forEach(t=>{let e=t.image;"MULTI"==this.group.type&&(e=this.getSwatchImage(t));var o=document.createElement("div"),i=(o.className="lv-option-wrapper","SLIDE"!=d.layoutType&&p+1>c&&(o.classList.add("lv-option-hidden"),u=!0),"NAME"==d.hoverEffect?(o.dataset.lvTooltip=!0,o.dataset.name=this.group.trans[t.value]??t.value):"IMAGE"==d.hoverEffect&&(o.dataset.lvPopover=!0,o.dataset.name=this.group.trans[t.value]??t.value,o.dataset.image=e),document.createElement("a"));let r=!0,n="";t.handle?(n=this.group.config.prefix+"/products/"+t.handle,this.group.config.product.autoScroll&&this.group.config.product.anchor&&(n=n+"#"+this.group.config.product.anchor),"MULTI"==this.groupType?1!=t.status&&(n="#",r=!1):t.disabled&&(n="#",r=!1)):(n="#",r=!1),i.href=n,r||(i.role="button",i.setAttribute("onclick","event.preventDefault();")),i.className="lv-option-item lv-option-item-outer"+(r?" lv-option-item-link":""),"ZOOM"===d.hoverEffect&&i.classList.add("lv-option-hover-effect__zoom"),t.active&&i.classList.add("lv-option-item__active"),"MULTI"!==this.groupType&&1!=t.status&&i.classList.add("lv-option-item__inactive");var a=d.outerBorderWidth??0,s=(0{var e=document.createElement("div"),o=(e.className="lv-option-wrapper","SLIDE"!=s.layoutType&&c+1>l&&(e.classList.add("lv-option-hidden"),p=!0),"NAME"==s.hoverEffect&&(e.dataset.lvTooltip=!0,e.dataset.name=this.group.trans[t.value]??t.value),document.createElement("a"));let i=!0,r="";t.handle?(r=this.group.config.prefix+"/products/"+t.handle,this.group.config.product.autoScroll&&this.group.config.product.anchor&&(r=r+"#"+this.group.config.product.anchor),"MULTI"==this.groupType?1!=t.status&&(r="#",i=!1):t.disabled&&(r="#",i=!1)):(r="#",i=!1),o.href=r,i||(o.role="button",o.setAttribute("onclick","event.preventDefault();")),o.className="lv-option-item lv-option-item-outer"+(i?" lv-option-item-link":""),"ZOOM"===s.hoverEffect&&o.classList.add("lv-option-hover-effect__zoom"),t.active&&o.classList.add("lv-option-item__active"),"MULTI"!==this.groupType&&1!=t.status&&o.classList.add("lv-option-item__inactive");var n=s.outerBorderWidth??0,a=(0t.name);let t=o.image;if(o.images&&0{e.dataset.pid==t.dataset.pid?t.setAttribute("selected",""):t.removeAttribute("selected")}),e.classList.contains("lv-option-collection-dropdown-option")&&e.closest("lv-option-dropdown").onChange(e.getAttribute("key"))):(t=e.dataset.pid,this.group.getProduct(t)&&(t=this.render(t),o.parentElement.replaceChildren(t.children?.[0]))))}renderSingleOptions(e){var t=document.createElement("div"),o=(t.className="lv-option-collection-block",this.group.title&&(t.dataset.optionName=this.group.title),this.group.products.map(t=>({...t,trans:this.group.trans[t.value]??t.value,disabled:1!=t.status,active:t.handle===e.handle})));let i=this.group.value.template.type;this.group.value.collection_type&&"DEFAULT"!=this.group.value.collection_type&&(i=this.group.value.collection_type);var r=this.group.trans[this.group.title]??this.group.title;return this.renderOption(t,i,r,o),t}renderMultiOptions(t){var e=document.createElement("div");e.className="lv-option-collection-blocks";const r=this.group.getProduct(t.productId)?.option;if(r){let i=0;for(const s of this.group.value.options){var o=document.createElement("div");o.className="lv-option-collection-block",o.dataset.optionName=s.name,this.group.config.productCard.hideOptions?.split(",")?.includes(s.name)&&(o.style.display="none");const d=this.group.products.filter(t=>1==t.status);var n=s.values.map(t=>{var e=[...r],o=(e[i]=t.value,l(d,e));return o?{...o,...t,trans:this.group.trans[t.value]??t.value,unavailable:1!=o.status||o.unavailable,active:t.value===r[i],matched:!0,disabled:!1}:{...p(i,e,d),...t,trans:this.group.trans[t.value]??t.value,unavailable:!0,active:!1,matched:!1,disabled:!1}});let t=s.template.type;s.collectionType&&"DEFAULT"!=s.collectionType&&(t=s.collectionType);var a=this.group.trans[s.name]??s.name;this.renderOption(o,t,a,n,i),e.appendChild(o),i++}}else u("ProductCardOptionRenderer","Can not found current variant",t);return e}renderSubcategoryOptions(e,t=0){var o=document.createElement("div");o.className="lv-option-collection-block";let i=null;for(const a of this.group.value.sub_groups)for(const s of a.products)if(e.productId==s.productId){i=a;break}if(i){o.dataset.optionName=i.name;var r=i.products.map(t=>({...t,trans:this.group.trans[t.value]??t.value,disabled:1!=t.status,active:t.handle===e.handle}));let t=this.group.value.template.type;this.group.value.collection_type&&"DEFAULT"!=this.group.value.collection_type&&(t=this.group.value.collection_type);var n=this.group.trans[i.name]??i.name;this.renderOption(o,t,n,r)}return o}renderOption(e,o,i,r,n=0){if(0!=r.length)if("COUNT"==this.group.config.productCard.customize.display){var t=document.createElement("span"),a=(t.className="lv-option-collection-count",this.group.config.appTranslations.countText??this.group.config.productCard.customize?.countText);t.innerText=a?.replace("{{count}}",r.length),e.appendChild(t)}else{if(i&&this.group.config.productCard.customize.showLabel){a=document.createElement("legend");a.className="lv-option-collection-label";let t=i;this.group.config.productCard.customize.showSeparator&&(t=i+":"),a.innerText=t,e.appendChild(a)}let t;"BUTTON"===o?t=this.renderButtonOptions(r,n):"COLOR_SWATCH"===o?t=this.renderColorSwatchOptions(r,n):"IMAGE_SWATCH"===o?t=this.renderImageSwatchOptions(r,n):"DROPDOWN"===o&&(t=this.renderDropdownOptions(r,n)),t&&e.appendChild(t)}}renderButtonOptions(t,r=0){const e=document.createElement("div");e.dataset.type="BUTTON",e.className="lv-option-collection-items",e.style.justifyContent=this.group.config.productCard.customize.align,"HIDE"==this.group.config.productCard.customize.buttonUnavailableStyle&&(t=t.filter(t=>!t.disabled));let o=this.group.config.productCard.customize.buttonLimit;k()&&this.group.config.productCard.customize.buttonLimitMobile&&(o=this.group.config.productCard.customize.buttonLimitMobile);t=t.map(t=>{var e=document.createElement("div"),o=(e.dataset.index=r,e.dataset.value=v(t.value),t.handle&&(e.dataset.handle=t.handle),e.dataset.pid=t.productId,["lv-option-collection-button","lv-option-collection-item"]);if(!1!==t.matched||!this.group.config.productCard.customize.buttonHideUnmatchedVariant){if(t.unavailable){if("HIDE"==this.group.config.productCard.customize.buttonUnavailableStyle)return;var i=this.group.config.productCard.customize.buttonUnavailableStyle||"CROSS";o.push("lv-option-collection-unavailable__"+i.toLowerCase())}return t.disabled&&e.setAttribute("disabled",""),t.active&&e.setAttribute("selected",""),"ROUND"===this.group.config.productCard.customize.buttonStyle&&o.push("lv-option-collection-round"),e.className=o.join(" "),e.innerText=t.trans,e}});let i=0;var n,t=t.filter(t=>t);return t.forEach(t=>{io&&((n=document.createElement("div")).className="lv-option-collection-swatch-more",n.style.padding=this.group.config.productCard.customize.buttonPadding,n.style.color=this.group.config.productCard.customize.buttonTextColorNormal,n.innerText="+"+(t.length-o),e.appendChild(n)),e}renderColorSwatchOptions(t,n=0){const e=document.createElement("div");e.dataset.type="COLOR_SWATCH",e.className="lv-option-collection-items",e.style.justifyContent=this.group.config.productCard.customize.align,"HIDE"==this.group.config.productCard.customize.colorSwatchUnavailableStyle&&(t=t.filter(t=>!t.unavailable));let o=this.group.config.productCard.customize.colorSwatchLimit;k()&&this.group.config.productCard.customize.colorSwatchLimitMobile&&(o=this.group.config.productCard.customize.colorSwatchLimitMobile);t=t.map(t=>{var e=document.createElement("div"),o=(e.className="lv-option-collection-wrapper",this.group.config.productCard.customize.colorSwatchTooltips&&(e.dataset.lvTooltip=1,e.dataset.tooltipText=t.trans),document.createElement("div")),i=(o.dataset.index=n,o.dataset.value=v(t.value),t.handle&&(o.dataset.handle=t.handle),o.dataset.pid=t.productId,["lv-option-collection-color-swatch","lv-option-collection-item"]);if(!1!==t.matched||!this.group.config.productCard.customize.colorSwatchHideUnmatchedVariant){if(t.unavailable){if("HIDE"==this.group.config.productCard.customize.colorSwatchUnavailableStyle)return;var r=this.group.config.productCard.customize.colorSwatchUnavailableStyle||"CROSS";i.push("lv-option-collection-unavailable__"+r.toLowerCase())}return t.active&&o.setAttribute("selected",""),t.disabled&&o.setAttribute("disabled",""),"ROUND"===this.group.config.productCard.customize.colorSwatchStyle&&i.push("lv-option-collection-round"),o.className=i.join(" "),o.appendChild(this.renderColorSwatch(t)),e.appendChild(o),e}});let i=0;var r,t=t.filter(t=>t);return t.forEach(t=>{io&&((r=document.createElement("div")).className="lv-option-collection-swatch-more",r.style.height=this.group.config.productCard.customize.colorSwatchSize+"px",r.innerText="+"+(t.length-o),e.appendChild(r)),e}renderImageSwatchOptions(t,a=0){const e=document.createElement("div");e.dataset.type="IMAGE_SWATCH",e.className="lv-option-collection-items",e.style.justifyContent=this.group.config.productCard.customize.align,"HIDE"==this.group.config.productCard.customize.imageSwatchUnavailableStyle&&(t=t.filter(t=>!t.unavailable));let o=this.group.config.productCard.customize.imageSwatchLimit;k()&&this.group.config.productCard.customize.imageSwatchLimitMobile&&(o=this.group.config.productCard.customize.imageSwatchLimitMobile);t=t.map(t=>{let e=t.image;"MULTI"==this.group.type&&(e=this.getSwatchImage(t));var o=document.createElement("div"),i=(o.className="lv-option-collection-wrapper",this.group.config.productCard.customize.imageSwatchTooltips&&(o.dataset.lvTooltip=1,o.dataset.tooltipText=t.trans),document.createElement("div")),r=(i.dataset.index=a,i.dataset.value=v(t.value),t.handle&&(i.dataset.handle=t.handle),i.dataset.pid=t.productId,["lv-option-collection-image-swatch","lv-option-collection-item"]);if(!1!==t.matched||!this.group.config.productCard.customize.imageSwatchHideUnmatchedVariant){if(t.unavailable){if("HIDE"==this.group.config.productCard.customize.imageSwatchUnavailableStyle)return;var n=this.group.config.productCard.customize.imageSwatchUnavailableStyle||"CROSS";r.push("lv-option-collection-unavailable__"+n.toLowerCase())}return t.active&&i.setAttribute("selected",""),t.disabled&&i.setAttribute("disabled",""),"ROUND"===this.group.config.productCard.customize.imageSwatchStyle&&r.push("lv-option-collection-round"),i.className=r.join(" "),i.innerHTML=`
${t.trans}
`,o.appendChild(i),o}});let i=0;var r,t=t.filter(t=>t);return t.forEach(t=>{io&&((r=document.createElement("div")).className="lv-option-collection-swatch-more",r.style.height=this.group.config.productCard.customize.imageSwatchSize+"px",r.innerText="+"+(t.length-o),e.appendChild(r)),e}renderDropdownOptions(t,e){var o=document.createElement("lv-option-dropdown"),i=(o.className="lv-option-dropdown-box",o.style.setProperty("--dropdown-width","100%"),"HIDE"==this.group.config.productCard.customize.dropdownUnavailableStyle&&(t=t.filter(t=>!t.unavailable)),document.createElement("div"));i.dataset.type="DROPDOWN",i.className="lv-option-dropdown lv-option-collection-dropdown",i.dataset.index=e;let r;e=document.createElement("div");e.className="lv-option-dropdown-options-tpl",e.style.display="none";const n=document.createElement("div");n.className="lv-option-dropdown-options lv-option-collection-dropdown-options",n.dataset.gid=this.group.id,e.appendChild(n),t.forEach(t=>{var e;t.active&&(r=t),!1===t.matched&&this.group.config.productCard.customize.dropdownHideUnmatchedVariant||t.disabled&&"HIDE"==this.group.config.productCard.customize.dropdownUnavailableStyle||((e=document.createElement("div")).className="lv-option-collection-dropdown-option"+(t.unavailable?" lv-option-dropdown-unavailable__"+this.group.config.productCard.customize.dropdownUnavailableStyle.toLowerCase():""),t.active&&e.setAttribute("selected",""),t.disabled&&e.setAttribute("disabled",""),e.dataset.value=v(t.value),e.dataset.handle=t.handle,e.dataset.pid=t.productId,e.innerText=t.trans,n.appendChild(e))});t=document.createElement("div"),t.className="lv-option-collection-dropdown-selected",t.innerText=r?.trans??"",i.appendChild(t),t=document.createElement("div");return t.className="lv-option-dropdown-arrow",t.style.color=this.group.config.productCard.customize.dropdownTextColor,t.innerHTML=c(this.group.config.productCard.customize.dropdownIcon),i.appendChild(t),o.appendChild(i),o.appendChild(e),o}renderColorSwatch(t){var e,o=document.createElement("div");return o.className="lv-option-collection-swatch-inner","ROUND"===this.group.config.productCard.customize.colorSwatchStyle&&o.classList.add("lv-option-collection-round"),o.style.setProperty("display","block","important"),1==t.colorType?o.style.background=t.color:2==t.colorType?(e=this.group.config.productCard.customize.twoColorStyle||"bottom right",o.style.background=`linear-gradient(to ${e}, ${t.color} 50%, ${t.color1} 50%)`):3==t.colorType&&(o.style.backgroundSize="cover",o.style.backgroundRepeat="no-repeat",o.style.backgroundImage=`url(${t.colorImage})`),o}addEventListener(t,e){t.querySelectorAll(".lv-option-collection-wrapper[data-lv-tooltip='1']").forEach(o=>{o.addEventListener("mouseenter",()=>{var t=this.getTooltipElement(),e=o.getBoundingClientRect();t.style.top=e.top+window.scrollY-6+"px",t.style.left=e.left+e.width/2+"px",t.innerText=o.dataset.tooltipText,t.classList.add("show")}),o.addEventListener("mouseleave",()=>{this.getTooltipElement().classList.remove("show")})});t=t.querySelector(".king-linked-options-collection__container"),t.querySelectorAll(".lv-option-collection-item").forEach(t=>{t.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation();let e=t.target;(e=t.target.matches(".lv-option-collection-item")?e:t.target.closest(".lv-option-collection-item"))?this.handleItemClick(e):h("ProductCardOptionRenderer","Can not find item element target")})}),t=t.querySelectorAll(".lv-option-dropdown-options-tpl .lv-option-dropdown-options");for(const o of t)o.addEventListener("lv-option-dropdown-option-click",t=>{t.preventDefault(),t.stopPropagation();t=o.querySelector(`.lv-option-collection-dropdown-option[key="${t.detail.key}"]`);t?this.handleItemClick(t):h("ProductCardOptionRenderer","Can not find item element target")})}getTooltipElement(){return this.tooltip||(this.tooltip=document.querySelector(".lv-option-tooltip"),this.tooltip)||(this.tooltip=document.createElement("div"),this.tooltip.className="lv-option-tooltip",document.body.appendChild(this.tooltip)),this.tooltip}async handleItemClick(t){t.hasAttribute("disabled")||("SWITCH_PRODUCT"==this.group.config.productCard.clickBehavior?this.handleSwitchProduct(t):this.handleRedirect(t))}async handleSwitchProduct(t){var e=this.group.config.themeConfig.productCard,o=t.dataset.pid,o=await E.getInstance().getProductDetails(o),e=t.closest(e.item.card);e&&o?(this.replaceProduct(e,o),this.rerender(t),u("ProductCardOptionRenderer",'Custom event "king-linked-options:product-card-seamless-switched" fired.',{card:e,product:o}),t=new CustomEvent("king-linked-options:product-card-seamless-switched",{detail:{card:e,product:o}}),document.dispatchEvent(t)):u("ProductCardOptionRenderer","Can not switch product",{card:e,product:o})}replaceProduct(t,e){var o=this.group.config.themeConfig.productCard,i=t.querySelector(o.item.title);i&&(i.innerText=e.title);let r,n,a;if((r=o.item.image_1?t.querySelector(o.item.image_1):r)&&("image"==o.item.image_1_type?(r.src=e.images[0].url,r.alt=e.images[0].altText,r.srcset=e.images[0].url):r.style.backgroundImage=`url(${e.images[0].url})`),(n=o.item.image_2?t.querySelector(o.item.image_2):n)&&("image"==o.item.image_2_type?(n.src=e.images?.[1]?.url??e.images?.[0]?.url,n.alt=e.images?.[1]?.altText??e.images?.[0]?.altText,n.srcset=e.images?.[1]?.url??e.images?.[0]?.url):n.style.backgroundImage=`url(${e.images?.[1]?.url??e.images?.[0]?.url})`),o.item.link&&t.querySelectorAll(o.item.link).forEach(t=>{t.href=this.group.config.prefix+"/products/"+e.handle}),o.item.price&&(i=t.querySelector(o.item.price))&&e.price&&(i.innerText.includes(this.group.config.currency)?i.innerHTML=b(e.price,"with_currency"):i.innerHTML=b(e.price,"without_currency")),(a=o.item.compareAtPrice?t.querySelector(o.item.compareAtPrice):a)&&(e.compareAtPrice&&e.price!=e.compareAtPrice?a.innerText.includes(this.group.config.currency)?a.innerHTML=b(e.compareAtPrice??"","with_currency"):a.innerHTML=b(e.compareAtPrice??"","without_currency"):a.innerHTML=""),o.quickAddForm?.variant?.id&&((i=t.querySelector(o.quickAddForm?.variant?.id))&&"value"==o.quickAddForm?.variant?.type&&(i.value=e.variantId),i=t.querySelector(o.quickAddForm?.product?.id))&&"value"==o.quickAddForm?.product?.type&&(i.value=e.id),o.callback)try{u("ProductCardOptionRenderer","Execute callback function",o.callback),new Function("card","product",o.callback)(t,e)}catch(t){t("ProductCardOptionRenderer","replaceProduct Can not execute callback function",t)}}handleRedirect(t){window.location=this.group.config.prefix+"/products/"+t.dataset.handle}ifAvailableForCard(){return this.group.value.hide_in_collection?(u("ProductCardOptionRenderer","Group hide in collection, ignored",this.group),!1):!("MULTI"===this.group.type&&!this.group.config.productCard.multiOptionEnabled&&(u("ProductCardOptionRenderer","Multi option group disabled in collection page"),1))}getSwatchImage(o){var i=this.group.value.options.map(t=>t.name);let t=o.image;if(o.images&&0t.productId==e)}getProduct(e){return this.group.products.find(t=>t.productId==e)}renderProductOption(t,e="product-page"){return this.productOptionRenderer.render(t,e)}renderProductCardOption(t){return this.productCardOptionRenderer.render(t)}getOptions(){let t=[];return"SINGLE"==this.group.type?t.push(this.group.trans[this.group.title]??this.group.title):"MULTI"==this.group.type?t=this.group.options.map(t=>this.group.trans[t.name]??t.name):"SUBGROUP"==this.group.type&&(t=this.group.sub_groups.map(t=>this.group.trans[t.name]??t.name)),t}}class x{static instance;isObserving=!1;isRendering=!1;container;variantSelectors="[data-dynamic-variants-enabled],variant-selects,variant-radios,variant-picker,[data-product-form-variant-container],product-options-root,.product-options,.product-swatches,.product__variants-swatches,.product-form product-variants,.product__block__variants,.product__selectors,.product-detail__options,.product-form__variants,.product-info__variant-picker,product-selector,.product-variant-picker-block,.option-selectors,.ProductForm__Variants,product-variant-selector,product-variants,.product__variants-wrapper,variant-selection,.selector-wrapper.product-form__item,.product-form__variants";formExcludesSelectors="[data-oke-reviews-widget],.site-navigation,#nosto-bundle-pdp,.breadcrumbs,predictive-search,search-modal,.predictive-search-results,header,.section-cart-drawer,.shopify-section--main-cart,cart-drawer,.mm-ajaxcart,essential-upsell-frequently-bought-together-app-block,.product-form__buttons-group,.cart-drawer,.product-add-to-cart-container,.product-form--atc,.product-sticky-cart";customExcludedSelectors="";cachedEls={};products=[];trans={};currentProduct=[];static load(){this.instance||(this.instance=new x,this.instance.createProductCache()),this.instance.load()}static getInstance(){return this.instance||(this.instance=new x),this.instance}get excludedSelectors(){var t=this.formExcludesSelectors;return this.customExcludedSelectors?this.customExcludedSelectors+","+t:t}get config(){return window.kingLinkedOptionConfig}get groupType(){return window.kingLinkedOptionConfig.product.groupType}constructor(){u("ProductOptionManager","Instance created",this)}async createProductCache(){var e=document.querySelector("#lv-option-product-group-data");if(e){let t=[];var o=document.querySelector("#lv-option-product-templates-data"),e=JSON.parse(e.textContent);e&&(o&&(t=(t=JSON.parse(o.textContent)).map(t=>t.value)),E.getInstance().formatGroupDataFromLiquid(e,t))}}async load(){var t;this.container=this.config.themeConfig?.product?.container?S(this.config.themeConfig?.product?.container):document.body,this.isRendering||(this.isRendering=!0,this.config&&this.config.shop&&this.config.product.id&&this.config.product.active&&(this.customExcludedSelectors=this.config.themeConfig?.product?.exclude??"",this.searchTargetPosition(),this.position.el)&&(t=await this.render(),this.position.loaded?this.position.els.forEach(t=>this.handleEl(t)):this.handleEl(t),this.isRendering=!1))}searchTargetPosition(){var t={el:null,pos:""},e=S("king-linked-options-product");if(e)t.el=e.parentElement,t.pos="INSIDE";else{e=S(".linked-option-variants-container");if(e)t.el=e,t.pos="INSIDE";else{var e=this.config.themeConfig?.product;if(e&&e.points)for(const i of e.points)if(i.id){var o=S(i.id);if(o){t.el=o,t.pos=i.pos;break}}t.el||(e=document.querySelectorAll('form[action*="/cart/add"]'),0<(e=Array.from(e).filter(t=>!t.closest(this.excludedSelectors))).length?(t.el=e[0],t.pos="BEFORE"):h("ProductOptionManager","Can not find any form"))}}this.position=t}getTargetPositionFromTemplate(t){let e;var o=t.querySelector(".linked-option-variants-container");if(o)e={el:o,pos:"INSIDE"};else{var o=this.config.themeConfig?.product;if(o&&o.points)for(const r of o.points)if(r.id){var i=t.querySelector(r.id);if(i){e={el:i,pos:r.pos};break}}e||(o=t.querySelectorAll('form[action*="/cart/add"]'),0<(o=Array.from(o).filter(t=>!t.closest(this.excludedSelectors))).length&&(e={el:o[0],pos:"BEFORE"}))}return e}async handleEl(t){this.hideDuplicateOption(t),this.hideDuplicate(t),this.autoScroll(),t&&(this.hideEls(),Shopify.designMode||this.isObserving||this.startObserving(),this.initCartAttribute(t),this.fireEvent(),O(t))}async render(){var e=S("king-linked-options-product");if(e)return e;var e=S("#king-linked-option-product-tpl");if(e)return u("ProductOptionManager","Load data from app embed block"),e=document.importNode(e.content,!0),"INSIDE"===this.position.pos?this.position.el.appendChild(e):"BEFORE"===this.position.pos?this.position.el.parentNode.insertBefore(e,this.position.el):this.position.el.parentNode.insertBefore(e,this.position.el.nextSibling),document.querySelector("king-linked-options-product");{e=E.getInstance();let t;if(t=this.config.storefrontAccessToken?(u("ProductOptionManager","Load data from Storefront API"),await e.getGroupByProductId(this.config.product.id)):(u("ProductOptionManager","Load data from API"),await this.loadFromAPI()))return w(e=t.renderProductOption(this.config.product.id),this.position.pos,this.position.el),e}}async loadFromAPI(){var t=await fetch(`/apps/king-linked-options/variants?shop=${this.config.shop}&productId=`+this.config.product.id,{headers:{"Content-Type":"application/json"},timeout:6e4});if(t.ok){var e=await t.json();if(u("ProductOptionManager","API response",e),"{}"===JSON.stringify(e.data))u("ProductOptionManager","No group was matched");else if(e.data.enable){e=e.data;if(1==e?.enable){if(e.trans={},e.active=!0,"MULTI"===e.type){for(const i of e.options)i.template.showPrice=!1,i.values=C(i.values);e.products=e.products.filter(t=>1==t.status).map(t=>(t.unavailable=1!=t.status||t.outOfStock,t.option=t.variant,delete t.variant,t))}else"SUBGROUP"===e.type?(e.template.showPrice=!1,e.products=e.subGroups.map(t=>t.products.map(t=>(t.unavailable=1!=t.status||t.outOfStock,t.value=t.name,delete t.name,C(t)))).flat(2),e.sub_groups=e.subGroups,delete e.subGroups):(e.template.showPrice=!1,e.products=e.products.map(t=>(t.unavailable=1!=t.status||t.outOfStock,t.value=t.name,delete t.name,C(t))));var o=new I(e);return E.getInstance().cacheGroup(e.id,o),o}}else u("ProductOptionManager","Option disabled")}else h("ProductOptionManager","Load data from api failed, status: "+t.status)}startObserving(){new MutationObserver(t=>{t.forEach(t=>{"childList"!==t.type&&"subtree"!==t.type||(0{i.includes(t.dataset.value)?r.includes(t.dataset.value)||r.push(t.dataset.value):i.push(t.dataset.value)});for(const n of t.querySelectorAll(".lv-option-wrapper")){var o=n.querySelector(".lv-option-item");o.classList.contains("lv-option-item__active")||r.includes(o.dataset.value)&&(n.style.display="none")}}}hideDuplicateOption(t){T.getInstance().hideProductOption(this.container)}querySelector(t){let e=this.cachedEls[t];return e&&document.body.contains(e)||(e=document.querySelector(t))&&(this.cachedEls[t]=e),e}fireEvent(){var t=new CustomEvent("king-linked-option-product-loaded");document.dispatchEvent(t),u("ProductOptionManager",'Custom event "king-linked-option-product-loaded" fired.')}autoScroll(){var t=sessionStorage.getItem("king-linked-options-position");t&&(window.scrollTo({top:t,behavior:"instant"}),sessionStorage.removeItem("king-linked-options-position"))}initCartAttribute(e){if(this.config.cartAttributeEnabled){var o=[];for(const d of e.querySelectorAll(".lv-option-box")){var i=d.dataset.optionName,r=d.dataset.optionValue;i&&r&&o.push({name:i,value:r})}window.kingLinkedOptionConfig.product.cartAttributes=o;let t=!1;if(this.config.cartAttributeSelector){var n=document.querySelector(this.config.cartAttributeSelector);if(n){u("ProductOptionManager","Cart attribute selector",n,o),t=!0;for(const l of o){var a=document.createElement("input");a.type="hidden",a.name=`properties[${l.name}]`,a.value=l.value,n.appendChild(a),u("ProductOptionManager","Cart attribute",a)}}else h("ProductOptionManager","Cart attribute selector is not valid")}if(!t){e=e.closest(".shopify-section");if(e){e=e.querySelectorAll('form[action*="/cart/add"]'),e=Array.from(e).filter(t=>!t.closest(this.excludedSelectors));if(0==e.length)u('ProductOptionManager", "Can not found any form[action*="/cart/add"]');else{u("ProductOptionManager","Cart attributes forms",e);for(const c of e)for(const p of o){var s=document.createElement("input");s.type="hidden",s.name=`properties[${p.name}]`,s.value=p.value,c.appendChild(s)}}}else u("ProductOptionManager","Can not found product info section")}}}}class _{static instance;enabled=!0;handles=[];productIds=[];cachedProducts=[];manualSelector="[king-linked-options-collection-manually]";builtInSelectors=[{card:".product-grid .grid__item",position:".card-information",target:"INSIDE"}];linkSelector='a[href*="/products"]:not(.king-linked-options-collection__link)';defaultExcludedSelectors="[data-oke-reviews-widget],.site-navigation,#nosto-bundle-pdp,.breadcrumbs,predictive-search,search-modal,.predictive-search-results,header,.section-cart-drawer,.shopify-section--main-cart,cart-drawer,.cart-drawer,#bundle-recent_sales,product-quick-add,#shopify-section-theme__cart,.product-description,cy-add-on,.cbb-frequently-bought-container,#productBoughtTogether,.globoRecommendationsBottom,#livesearch,.livesearch-results,[data-oke-widget],nav,#rbr-container-element-true,#rbr-container-element-false,#rbr-container-element-fbt,.subify-widget-container,.drawer__content,#ewck-combo-products-block,#ewck-product-add-ons-block,#ewck-product-cross-sell-block,.wt__quick-buy__container";type={server:!1,manual:!1,builtIn:!1,auto:!1};usedSelector={card:"",position:"",target:"",item:{}};positionType="";groupDataManager;static load(){this.instance||(this.instance=new _),this.instance.load()}constructor(){u("ProductCardOptionManager","Instance created",this),this.config.productCard.enabled||u("ProductCardOptionManager","Card option disabled"),this.groupDataManager=E.getInstance()}get excludedSelectors(){var t=this.config.themeConfig.productCard.exclude,e=this.defaultExcludedSelectors;return t?t+","+e:e}get config(){return window.kingLinkedOptionConfig}initSelector(){var t;if(document.querySelector(this.manualSelector))t=Array.from(document.querySelectorAll(this.manualSelector)).filter(t=>!t.dataset.loaded),this.productIds=Array.from(new Set(t.map(t=>t.dataset.productId))).filter(t=>""!==t),this.positionType="manual",this.usedSelector.item=this.config.themeConfig.productCard?.item??{},this.usedSelector.card=this.config.themeConfig.productCard?.item?.card??"",this.usedSelector.positions=[{id:this.manualSelector,pos:"INSIDE"}];else{if(this.config.themeConfig?.productCard?.item?.card){var e=document.querySelector(this.config.themeConfig.productCard.item.card);if(e){for(const i of this.config.themeConfig.productCard.points)if(e.querySelector(i.id))return this.usedSelector={card:this.config.themeConfig.productCard?.item?.card??"",item:this.config.themeConfig.productCard?.item??{},positions:this.config.themeConfig.productCard?.points??[]},void(this.positionType="server")}else u("ProductCardOptionManager","Can not find card element",this.config.themeConfig.productCard.item.card)}for(const r of this.builtInSelectors){var o=document.querySelector(r.card);if(o)if(o.querySelector(r.position))return this.usedSelector={card:r.card,item:{},positions:[{id:r.position,pos:r.target}]},void(this.positionType="builtIn")}this.positionType="auto"}}parseProductLinks(){this.links=[...document.querySelectorAll(this.linkSelector)].filter(t=>!t.closest(this.excludedSelectors)).filter(t=>!this.usedSelector.card||t.closest(this.usedSelector.card));var t=this.links.map(t=>this.parseHandle(t.getAttribute("href")));this.handles=Array.from(new Set(t))}async load(){if(this.initSelector(),this.parseProductLinks(),0!==this.handles.length||0!==this.productIds.length){let t=[],e=[],o=this.cachedProducts.map(t=>t.productId),i=this.cachedProducts.map(t=>t.handle),r=(0!o.includes(t))),0!i.includes(t))),[...this.cachedProducts]);try{var n,a;00!==t.groupId)).length?u("ProductCardOptionManager","No groups in this page"):this.render(r)}catch(t){u("ProductCardOptionManager","Failed to load collection options",t)}}}render(r){if("server"===this.positionType)u("ProductCardOptionManager","Rendering using server selectors"),this.renderWithSelectors(r,this.usedSelector.card,this.usedSelector.positions);else if("manual"===this.positionType)u("ProductCardOptionManager","Rendering using manual tags"),document.querySelectorAll(this.manualSelector).forEach(e=>{var t=e.parentElement;if(!t.dataset.kingLinkedOptionsLoaded&&!t.closest("[data-king-linked-options-loaded]")){t.dataset.kingLinkedOptionsLoaded=!0;const o=e.dataset.productId,i=r.find(t=>t.productId==o);i&&this.renderOptions(i).then(t=>{t&&(e.appendChild(t),this.fireLoadedEvent(i,t))})}});else if("builtIn"===this.positionType)u("ProductCardOptionManager","Rendering using builtIn selectors"),this.renderWithSelectors(r,this.usedSelector.card,this.usedSelector.positions);else if("auto"===this.positionType){u("ProductCardOptionManager","Rendering with auto-detection");for(const e of this.links){const o=this.parseHandle(e.getAttribute("href")),i=r.find(t=>t.handle==o);if(i){var t=m(e,i.title);if(t){const n=R(t);t=n.parentElement;t.dataset.kingLinkedOptionsLoaded||t.closest("[data-king-linked-options-loaded]")||(t.dataset.kingLinkedOptionsLoaded=!0,this.renderOptions(i).then(t=>{t&&(n.appendChild(t),this.fireLoadedEvent(i,t))}))}else u("ProductCardOptionManager","Auto target position failed, can not find title element",i.title)}}}}async renderWithSelectors(t,e,o){e=[...document.querySelectorAll(e)].filter(t=>{return!t.closest('form[action*="/cart"]')&&!t.closest(this.excludedSelectors)});u("ProductCardOptionManager","Filtered cards",e);for(const a of e)if(a.dataset.kingLinkedOptionsLoaded)u("ProductCardOptionManager","Product card data loaded, ignored",a);else{var i=a.querySelector(this.linkSelector);if(i?.hasAttribute("href")){i=i.getAttribute("href");const s=this.parseHandle(i);var r,n,i=t.find(t=>t.handle==s);if(i){let t,e;for(const d of o)if(t=a.querySelector(d.id),e=d.pos,t)break;t?(r=await this.renderOptions(i))&&(w(r,e,t),this.config.themeConfig.productCard.hide&&(n=a.querySelectorAll(this.config.themeConfig.productCard.hide),u("ProductCardOptionManager","Auto hide elements for selector"+this.config.themeConfig.productCard.hide,n),n.forEach(t=>t.style.display="none")),a.dataset.kingLinkedOptionsLoaded=!0,this.fireLoadedEvent(i,r)):u("ProductCardOptionManager","Target element not found",a,o)}else u("ProductCardOptionManager","Product does not belong any product group",s)}else u("ProductCardOptionManager","Link selector not found or has no href attribute",a,this.linkSelector)}}async renderOptions(t){var e=await this.groupDataManager.getGroupById(t.groupId);return e?.isActive()?e?.renderProductCardOption(t.productId):null}parseHandle(t){t=t.split("?")[0].split("/").pop();return decodeURIComponent(t)}fireLoadedEvent(t,e){var o=new CustomEvent("king-linked-options-collection-loaded",{detail:{product:t,target:e}});document.dispatchEvent(o),u("ProductCardOptionManager",'Custom event "king-linked-options-collection-loaded" fired.',{product:t,target:e})}}class P{constructor(){this.callback=null,this.containerObserver=null,this.productIdObserver=null,this.timeout=null,this.isMonitoring=!1,this.maxWaitTime=1e4,this.currentProductId=null,this.container=null}get config(){return window.kingLinkedOptionConfig}static getInstance(){return P.instance||(P.instance=new P),P.instance}startMonitoring(t,e){this.isMonitoring&&this.stopMonitoring(),this.callback=e,this.isMonitoring=!0,this.timeout=setTimeout(()=>{this.stopMonitoring(),u("QuickViewMonitor","Timeout: QuickView elements not found")},this.maxWaitTime);let o=null;(o="separate"===this.config.themeConfig.quickView.type?t.closest(this.config.themeConfig.productCard.item.card):document.querySelector(this.config.themeConfig.quickView.container))?(this.container=o,this.monitorProductIdElement(o)):this.monitorContainerElement()}monitorContainerElement(){this.containerObserver=new MutationObserver(t=>{for(const o of t)if("childList"===o.type){var e=document.querySelector(this.config.themeConfig.quickView.container);if(e)return this.container=e,this.monitorProductIdElement(e),void this.monitorContainerVisibility(e)}}),this.containerObserver.observe(document.body,{childList:!0,subtree:!0})}monitorProductIdElement(i){var t=i.querySelector(this.config.themeConfig.quickView.productId.id);t?this.processProductIdElement(t,i):(this.productIdObserver&&this.productIdObserver.disconnect(),this.productIdObserver=new MutationObserver(t=>{for(const o of t)if("childList"===o.type){var e=i.querySelector(this.config.themeConfig.quickView.productId.id);if(e)return void this.processProductIdElement(e,i)}}),this.productIdObserver.observe(i,{childList:!0,subtree:!0}))}processProductIdElement(t,e){this.productIdElement=t;let o;var i;o="value"===this.config.themeConfig.quickView.productId.type?t.value:t.dataset.productId,(this.currentProductId=o)&&(i=this.findInsertPoint(e),this.callback(o,i,e)),this.monitorProductIdValueChanges(t,e),this.monitorProductIdElementRemoval(t,e)}monitorProductIdElementRemoval(r,n){const a=new MutationObserver(t=>{for(const i of t)if("childList"===i.type){if(0{let t;var e;(t="value"===this.config.themeConfig.quickView.productId.type?o.value:o.dataset.productId)&&t!==this.currentProductId&&(this.currentProductId=t,e=this.findInsertPoint(i),this.callback(t,e,i))}),this.productIdValueObserver.observe(o,{attributes:!0,attributeFilter:"value"===this.config.themeConfig.quickView.productId.type?["value"]:["data-product-id"],characterData:!0,childList:!0})}stopMonitoring(){this.isMonitoring&&(this.isMonitoring=!1,this.isActivelyMonitoring=!1,this.container=null,this.productIdElement=null,this.currentProductId=null,this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.containerObserver&&(this.containerObserver.disconnect(),this.containerObserver=null),this.productIdObserver&&(this.productIdObserver.disconnect(),this.productIdObserver=null),this.productIdValueObserver&&(this.productIdValueObserver.disconnect(),this.productIdValueObserver=null),this.productIdRemovalObserver&&(this.productIdRemovalObserver.disconnect(),this.productIdRemovalObserver=null),this.clearVisibilityChecks&&(this.clearVisibilityChecks(),this.clearVisibilityChecks=null),this.contentObserver&&(this.contentObserver.disconnect(),this.contentObserver=null),this.reappearanceObserver&&(this.reappearanceObserver.disconnect(),this.reappearanceObserver=null),u("QuickViewMonitor","Monitoring stopped"))}monitorContainerVisibility(o){const e=o.getBoundingClientRect(),i=y(o),r=new MutationObserver(t=>{for(const e of t)"childList"===e.type&&0{t=t[0];!t.isIntersecting&&i?(this.pauseMonitoring(),this.monitorContainerReappearance(o)):t.isIntersecting&&!this.isActivelyMonitoring&&this.resumeMonitoring(o)},{threshold:.1})),a=(n.observe(o),setInterval(()=>{var t;document.body.contains(o)?(!y(o)&&i||(t=o.getBoundingClientRect(),50{clearInterval(a),n.disconnect(),r.disconnect()},this.contentObserver=r,this.isActivelyMonitoring=!0}monitorContainerReappearance(e){var t=new MutationObserver(t=>{y(e)&&this.resumeMonitoring(e)});t.observe(e,{attributes:!0,attributeFilter:["style","class","aria-hidden","hidden"]});let o=e.parentElement;for(;o&&o!==document.body;)t.observe(o,{attributes:!0,attributeFilter:["style","class","aria-hidden","hidden"]}),o=o.parentElement;this.reappearanceObserver=t,this.isActivelyMonitoring=!1}pauseMonitoring(){this.isActivelyMonitoring&&(this.isActivelyMonitoring=!1,this.productIdObserver&&this.productIdObserver.disconnect(),this.productIdValueObserver&&this.productIdValueObserver.disconnect(),u("QuickViewMonitor","Monitoring paused"))}resumeMonitoring(t){this.isMonitoring&&(this.isActivelyMonitoring=!0,this.reappearanceObserver&&(this.reappearanceObserver.disconnect(),this.reappearanceObserver=null),this.monitorProductIdElement(t),u("QuickViewMonitor","Monitoring resumed"))}findInsertPoint(t){for(const i of this.config.themeConfig.quickView.points||[]){var e=t.querySelector(i.id);if(e)return{element:e,pos:i.pos||"before"}}var o=t.querySelector('.quickview-product-form, .product-form, form[action*="/cart/add"]');return o?{element:o,pos:"beforebegin"}:{element:t,pos:"append"}}}class T{static instance=null;static ROOT_SELECTORS=["variant-selects","variant-radios","variant-picker","product-selector","variant-selection",".variant-picker",".product-form__inputs",".product-form__variants",".ProductForm__Options",".product-single__options",".product-single__variants",".product-options",".product__variant-picker",".product-options",".swatch",".swatches",".variant-swatch",".variant-input",".variant-options",".product-card__variants",".form__selectors",".product-form__controls-group","[data-product-form]",".product-form",".ProductForm",'form[action^="/cart/add"]','form[action*="/cart/add"]'];static OPTION_CONTAINER_SELECTORS=["[data-option]","[data-option-slug]","[data-select-label]","[data-option-group]","fieldset",".option-selector",".product-form__option-selector",".product-form__input",".product-form__item",".selector-wrapper",".variant-picker__option",".ProductForm__Option",".product-option",".product-options > li",".swatch","[data-option-index]","[data-product-option]",".variant-input-wrap"];static LABEL_SELECTORS=[".options-selection__option-name",".product-form__option-name",".label-product-info","legend","label",".form__label",".product-form__label",".variant-picker__label","[data-option-label]",".option-label"];static getInstance(){return this.instance||(this.instance=new T),this.instance}constructor(){this.observer=null,this.root=null,this.linkedOptionNames=[],this.isProcessing=!1,this.debounceTimer=null,this.initialized=!1}get config(){return window.kingLinkedOptionConfig}get enabled(){return this.config?.hideDuplicateOption}get version(){return this.config?.version||"v1"}async init(){this.enabled&&"product"===this.config?.pageType?this.initialized||(this.initialized=!0,document.addEventListener("king-linked-options:product-seamless-switched",()=>{u("OptionDeduplicator",'Custom event "king-linked-options:product-seamless-switched" received, try to re-hide.'),this.onSeamlessSwitch()}),"v2"===this.version&&await this.initV2()):u("OptionDeduplicator","Disabled or not product page")}async hideProductOption(t){this.enabled&&"v2"!==this.version&&await this.hideProductOptionV1(t)}async hideQuickViewOption(t,e){this.enabled&&("v2"===this.version?await this.hideQuickViewOptionV2(t,e):await this.hideQuickViewOptionV1(t,e))}async onSeamlessSwitch(){"v2"===this.version&&(await this.loadLinkedOptionNames(),this.restartObserver(),this.hideMatchingOptions())}async hideProductOptionV1(t){if(0!==this.config.product.options.length&&this.config.themeConfig?.product?.variant?.id&&this.config.themeConfig?.product?.variant?.option?.id){let e=this.config.themeConfig.product.variant.id+" "+this.config.themeConfig.product.variant.option.id;!this.config.themeConfig?.product?.container||e.startsWith(this.config.themeConfig.product.container)||(e=this.config.themeConfig.product.container+" "+e),t.querySelectorAll(e).forEach((t,e)=>{e=this.config.product.options[e];e&&(t.dataset.lvShopifyOption=e.toLowerCase())});t=await E.getInstance().getGroupByProductId(this.config.product.id);if(t){var o,i=t.getOptions().map(t=>t.toLowerCase()),r=(u("OptionDeduplicator","V1 Group options",i),[]);for(let t=0;tt.toLowerCase().trim()):[]):this.linkedOptionNames=[]}findRoot(t){var e=t||document,t=this.config?.themeConfig?.product?.variant?.id;if(t){t=e.querySelector(t);if(t)return t}for(const i of T.ROOT_SELECTORS){var o=e.querySelector(i);if(o)return o}return null}findOptionContainers(t){const i=[];var e=this.config?.themeConfig?.product?.variant?.option?.id;if(e){e=t.querySelectorAll(e);if(0{var t=i.some(t=>t.contains(e)),o=i.some(t=>e.contains(t));t||o?o&&-1!==(t=i.findIndex(t=>e.contains(t)))&&i.splice(t,1,e):i.push(e)})}return i}extractLabelText(t){var o=t.dataset?.option||t.dataset?.optionSlug||t.dataset?.selectLabel;if(o)return o.toLowerCase().trim();o=t.querySelector('input[type="radio"][name], select[name]');if(o?.name){let e=o.name.trim();o=e.match(/^options\[([^\]]+)\]$/i);if(o)return o[1].toLowerCase();var i,o=e.match(/^option-([a-z][a-z0-9-]*)$/i);if(o)return o[1].toLowerCase();if(!(/^\d+-option\[\d+\]$/i.test(e)||/^option\[\d+\]$/i.test(e)||/^option-\d+$/i.test(e)||/^product-form-.*-option\d+$/i.test(e)||/^product-.*-modal-[A-Za-z]+$/i.test(e))){let t=e;for(;(t=(t=(t=(t=(t=(i=t).replace(/-option$/i,"")).replace(/-\d+$/,"")).replace(/^template--\d+__\w+-/i,"")).replace(/-(?:quickadd-)?template--\d+__\w+$/,"")).replace(/-[A-Za-z][A-Za-z0-9]*(__[A-Za-z0-9_]+)+$/,""))!==i&&t.includes("-"););if((e=t.trim())&&!/^option\d+$/i.test(e)&&!/^\d+$/.test(e))return e.toLowerCase()}}o=this.config?.themeConfig?.product?.variant?.option?.label;if(o){o=t.querySelector(o);if(o)return this.cleanLabelText(o)}for(const r of T.LABEL_SELECTORS){var e=t.querySelector(r);if(e)return this.cleanLabelText(e)}return null}cleanLabelText(t){let e="";for(const o of t.childNodes)o.nodeType===Node.TEXT_NODE&&(e+=o.textContent);return(e=e.trim())||((t=t.cloneNode(!0)).querySelectorAll(".selected-value, [data-selected-value], [data-selected], [data-selected-variant], .product-form__input--selected, span").forEach(t=>t.remove()),e=t.textContent.trim()),(e=e.replace(/[::]\s*.*$/,"").trim()).toLowerCase()}hideMatchingOptions(t){if(!this.isProcessing){this.isProcessing=!0;try{var e=this.findRoot(t);if(e){this.root=e;var o,i=this.findOptionContainers(e);u("OptionDeduplicator","V2 Found containers",i);for(const r of i)r.closest("king-linked-options-product")||(u("OptionDeduplicator","V2 Detected label text:",o=this.extractLabelText(r),r),o&&(this.linkedOptionNames.includes(o)?(u("OptionDeduplicator","V2 Hiding option",o,r),r.style.display="none",r.dataset.lvHidden="true"):"true"===r.dataset.lvHidden&&(r.style.display="",delete r.dataset.lvHidden)))}else u("OptionDeduplicator","V2 Root not found")}finally{this.isProcessing=!1}}}async hideQuickViewOptionV2(e,o){o=await E.getInstance().getGroupByProductId(o);if(o){var i,r=o.getOptions().map(t=>t.toLowerCase().trim()),o=this.config?.themeConfig?.quickView?.variant;let t=null;if(t=(t=o?e.querySelector(o):t)||this.findRoot(e))for(const n of this.findOptionContainers(t))n.closest("king-linked-options-product")||(u("OptionDeduplicator","V2 QuickView Detected label text",i=this.extractLabelText(n),n),i&&r.includes(i)&&(u("OptionDeduplicator","V2 Hiding option",i,n),n.style.display="none",n.dataset.lvHidden="true"))}}debouncedHide(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.hideMatchingOptions()},100)}startObserver(){this.observer&&this.observer.disconnect();var t=this.findRoot();t&&(this.observer=new MutationObserver(t=>{t.every(t=>"attributes"===t.type&&("style"===t.attributeName||"data-lv-hidden"===t.attributeName))||this.debouncedHide()}),t=t.closest(".shopify-section")||t,this.observer.observe(t,{childList:!0,subtree:!0,attributes:!1}),u("OptionDeduplicator","V2 Observer started on",t))}restartObserver(){this.observer&&this.observer.disconnect(),setTimeout(()=>{this.startObserver()},200)}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.debounceTimer&&clearTimeout(this.debounceTimer),this.initialized=!1}}if(!customElements.get("lv-option-dropdown")){class N extends HTMLElement{constructor(){super(),this.boundToggleDropdown=this.toggleDropdown.bind(this)}connectedCallback(){this.expanded=!1,this.trigger=this.querySelector(".lv-option-dropdown"),this.arrow=this.trigger.querySelector(".lv-option-dropdown-arrow"),this.selectedText=this.querySelector(".lv-option-collection-dropdown-selected,.lv-option-dropdown-value"),this.trigger&&(this.trigger.removeEventListener("click",this.boundToggleDropdown),this.trigger.addEventListener("click",this.boundToggleDropdown)),this.optionsTpl=this.querySelector(".lv-option-dropdown-options-tpl")?.firstElementChild;var e=this.optionsTpl.querySelectorAll(".lv-option-dropdown-option,.lv-option-collection-dropdown-option");for(let t=0;t{requestAnimationFrame(()=>this.updatePosition())}),window.addEventListener("resize",()=>{requestAnimationFrame(()=>this.updatePosition())}),this.scrollElements=[];let t=this.parentElement;for(;t&&t!==document.body;)(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&(t.addEventListener("scroll",()=>{requestAnimationFrame(()=>this.updatePosition())}),this.scrollElements.push(t)),t=t.parentElement;document.addEventListener("click",this.handleDocumentClick.bind(this))}toggleDropdown(t){t.preventDefault(),t.stopPropagation(),this.expanded?this.close():(this.constructor.closeOtherDropdowns(this),this.open())}open(){this.expanded=!0,this.createPopover(),this.updatePosition(),this.dropdownPopover.querySelector(".lv-option-dropdown-options").classList.add("show"),this.arrow.classList.add("active")}close(){this.expanded=!1,this.dropdownPopover&&this.dropdownPopover.querySelector(".lv-option-dropdown-options").classList.remove("show"),this.arrow.classList.remove("active")}createPopover(){this.dropdownPopover=document.querySelector(".lv-option-dropdown-options-popover"),this.dropdownPopover&&document.body.contains(this.dropdownPopover)||(this.dropdownPopover=document.createElement("div"),this.dropdownPopover.className="lv-option-dropdown-options-popover",document.body.append(this.dropdownPopover));var t=this.optionsTpl.cloneNode(!0);for(t.addEventListener("click",t=>{var e=t.target.closest(".lv-option-dropdown-option,.lv-option-collection-dropdown-option");e&&(e.hasAttribute("disabled")?t.stopPropagation():(t=e.getAttribute("key"),e=new CustomEvent("lv-option-dropdown-option-click",{detail:{key:t},bubbles:!0,cancelable:!0}),this.optionsTpl.dispatchEvent(e)))});this.dropdownPopover.firstChild;)this.dropdownPopover.removeChild(this.dropdownPopover.firstChild);this.dropdownPopover.appendChild(t)}updatePosition(){if(this.expanded&&this.dropdownPopover&&this.trigger){var o=this.trigger.getBoundingClientRect(),i=this.dropdownPopover,r=window.innerHeight,n=window.innerWidth,a=i.offsetHeight,s=i.offsetWidth;i.style.position="fixed";let t=o.bottom,e=o.left;t+a>r?(t=o.top-a)<0&&(t=0,i.style.maxHeight=r-o.bottom+"px"):i.style.maxHeight="",e+s>n&&(e=n-s)<0&&(e=0),i.style.top=t+"px",i.style.left=e+"px",i.style.width=o.width+"px"}}handleDocumentClick(t){!this.contains(t.target)&&this.expanded&&this.close()}onChange(e){var t=this.optionsTpl.querySelector(`.lv-option-dropdown-option[key="${e}"],.lv-option-collection-dropdown-option[key="${e}"]`);t&&(this.selectedText.innerText=t.dataset.value,this.optionsTpl.querySelectorAll(".lv-option-collection-dropdown-option").forEach(t=>{t.getAttribute("key")==e?t.setAttribute("selected",""):t.removeAttribute("selected")}))}static closeOtherDropdowns(e){document.querySelectorAll("lv-option-dropdown").forEach(t=>{t!==e&&t.expanded&&t.close()})}disconnectedCallback(){this.scrollElements.forEach(t=>t.removeEventListener("scroll",()=>this.updatePosition())),window.removeEventListener("scroll",()=>this.updatePosition()),window.removeEventListener("resize",()=>this.updatePosition()),this.trigger&&this.trigger.removeEventListener("click",this.boundToggleDropdown),document.removeEventListener("click",this.handleDocumentClick.bind(this))}}customElements.define("lv-option-dropdown",N)}if(!customElements.get("lv-option-slide")){class M extends HTMLElement{connectedCallback(){this.slideOffset=0,this.slideType=this.dataset.slideType,this.arrowSize=this.dataset.arrowSize,this.slideMode=this.dataset.slideMode||"ALL",this.autoScrollToActive=!0,this.slideContent=this.querySelector(".lv-option-slide-items"),this.arrowLeft=this.querySelector('.lv-option-navigation[data-navigation="left"]'),this.arrowRight=this.querySelector('.lv-option-navigation[data-navigation="right"]'),this.isFirstInit=!0,this.OVERFLOW_THRESHOLD=5,this.ARROW_SPACING="FLOAT"===this.slideType?0:4,this.boundHandleLeftClick=this.handleNavigation.bind(this,"LEFT"),this.boundHandleRightClick=this.handleNavigation.bind(this,"RIGHT"),this.boundHandleTouchStart=this.handleTouchStart.bind(this),this.boundHandleTouchMove=this.handleTouchMove.bind(this),this.arrowLeft&&this.arrowLeft.addEventListener("click",this.boundHandleLeftClick),this.arrowRight&&this.arrowRight.addEventListener("click",this.boundHandleRightClick),this.slideContent&&(this.slideContent.addEventListener("touchstart",this.boundHandleTouchStart,{passive:!1}),this.slideContent.addEventListener("touchmove",this.boundHandleTouchMove,{passive:!1})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.initSlide()})});let t;this.resizeObserver=new ResizeObserver(()=>{clearTimeout(t),t=setTimeout(()=>{this.handleResize()},100)}),this.resizeObserver.observe(this)}shouldEnableSlide(){return"MOBILE_ONLY"!==this.slideMode||k()}calculateDimensions(){var t,e,o,i,r,n,a,s=this.getBoundingClientRect().width,d=getComputedStyle(this.slideContent),d=parseFloat(d.gap)||0,l=this.slideContent.querySelectorAll(".lv-option-wrapper");return!l||0===l.length||0===s?null:(t=l[0].getBoundingClientRect().width+d,e=l.length*t-d,o=this.slideContent.scrollWidth,i=Math.max(e,o),r=Math.floor(s/t)*t,n=Math.max(0,i-s),a=i-s>this.OVERFLOW_THRESHOLD,u("LvOptionSlide","V2 Calculate dimensions",{containerWidth:s.toFixed(2),calculatedWidth:e.toFixed(2),scrollWidth:o.toFixed(2),actualContentWidth:i.toFixed(2),itemCount:l.length,itemWidth:t.toFixed(2),gap:d,exceeds:n.toFixed(2),shouldShowArrows:a,threshold:this.OVERFLOW_THRESHOLD}),{containerWidth:s,slideContentWidth:i,itemWidth:t,slideStep:r,exceeds:n,shouldShowArrows:a})}initSlide(){var t,e,o,i,r=this.calculateDimensions();r&&({containerWidth:r,itemWidth:t,slideStep:e,exceeds:o,shouldShowArrows:i}=r,this.slideStep=e,this.exceeds=o,this.shouldShowArrows=i,this.slideOffset=0,this.shouldEnableSlide()?this.isFirstInit&&this.autoScrollToActive&&(this.scrollToActiveItem(r,t),this.isFirstInit=!1):this.isFirstInit=!1,this.updateArrowsState())}handleResize(){var t,e,o=this.calculateDimensions();o&&({slideStep:o,exceeds:t,shouldShowArrows:e}=o,this.slideStep=o,this.exceeds=t,this.shouldShowArrows=e,this.shouldEnableSlide()?(o=0=this.exceeds&&this.arrowRight.classList.add("lv-option-navigation__disabled"),t=12+2*this.ARROW_SPACING,this.style.width=`calc(100% - ${2*this.arrowSize+t}px)`):this.style.width=""):(this.style.width="",this.slideContent.style.transform="",this.slideContent.style.flexWrap="wrap",this.style.overflowX="visible",this.style.flexWrap="wrap"))}scrollToActiveItem(t,e){var o=this.slideContent.querySelector(".lv-option-item__active");o&&(o=o.closest(".lv-option-wrapper"))&&-1!==(o=Array.from(this.slideContent.querySelectorAll(".lv-option-wrapper")).indexOf(o))&&(o=o*e-t/2+e/2,o=Math.max(0,Math.min(o,this.exceeds)),this.slideOffset=o,this.slideContent.style.transition="none",this.slideContent.style.transform=`translateX(-${this.slideOffset}px)`,this.slideContent.offsetHeight,requestAnimationFrame(()=>{this.slideContent.style.transition=""}))}handleNavigation(t){if(this.shouldEnableSlide()){var e=this.calculateDimensions();if(e){e=e["itemWidth"];if("LEFT"===t){if(this.slideOffset<=0)return;this.slideOffset=this.slideOffset-Math.min(this.slideOffset,this.slideStep);var o=this.slideOffset%e;0=this.exceeds)return;(this.exceeds-this.slideOffset<=this.slideStep||(this.slideOffset=this.slideOffset+this.slideStep,0<(o=this.slideOffset%e)&&(this.slideOffset=oMath.abs(r)&&t.preventDefault(),30{this.products=t.products.filter(t=>1==t.status)})),"product-page"==this.dataset.renderContext&&"seamless"==this.switchMode?this.items=this.querySelectorAll(".lv-option-item"):this.items=this.querySelectorAll(".lv-option-item:not(.lv-option-item-link)"),0{t.addEventListener("mouseenter",this.showTooltip.bind(this,t)),t.addEventListener("mouseleave",this.hideTooltip.bind(this,t))})),0{t.addEventListener("mouseenter",this.showPopover.bind(this,t)),t.addEventListener("mouseleave",this.hidePopover.bind(this,t))}));var t=this.querySelectorAll(".lv-option-dropdown-options-tpl .lv-option-dropdown-options");if(0{e.addEventListener("lv-option-dropdown-option-click",t=>{t=e.querySelector(`.lv-option-dropdown-option[key="${t.detail.key}"]`);t&&this.handleItemClick(t)})}),this.config.product.autoScroll&&!this.config.product.anchor){let t=!1;window.addEventListener("scroll",()=>{t||(window.requestAnimationFrame(()=>{sessionStorage.setItem("king-linked-options-position",window.scrollY||document.documentElement.scrollTop),t=!1}),t=!0)})}}createTooltip(){var t=document.createElement("div");return t.className="lv-option-tooltip",document.body.appendChild(t),t}showTooltip(t){var e=t.getBoundingClientRect();this.tooltipEl.style.top=e.top+window.scrollY-6+"px",this.tooltipEl.style.left=e.left+e.width/2+"px",this.tooltipEl.innerText=t.getAttribute("data-name"),this.tooltipEl.classList.add("show")}hideTooltip(t){this.tooltipEl.classList.remove("show")}createPopover(){var t=document.createElement("div");return t.className="lv-option-popover",document.body.appendChild(t),t}showPopover(t){var e=t.getBoundingClientRect(),o=document.createElement("div"),i=document.createElement("img"),i=(i.src=t.getAttribute("data-image"),i.className="lv-option-popover__image",i.alt=t.getAttribute("data-name"),o.appendChild(i),document.createElement("div"));i.className="lv-option-popover__name",i.innerText=t.getAttribute("data-name"),o.appendChild(i),this.popoverEl.innerHTML="",this.popoverEl.appendChild(o),this.popoverEl.style.top=e.top+window.scrollY-6+"px",this.popoverEl.style.left=e.left+e.width/2+"px",this.popoverEl.classList.add("show")}hidePopover(t){this.popoverEl.classList.remove("show")}handleExpand(){var t=this.closest(".lv-option-group");t&&(t.querySelectorAll(".lv-option-hidden").forEach(t=>{t.classList.remove("lv-option-hidden")}),t.querySelector(".lv-option-stack-more-container").classList.add("lv-option-hidden"))}handleItemClick(o,i){if("product-page"==this.dataset.renderContext&&"seamless"==this.switchMode&&i&&i.preventDefault(),!o.hasAttribute("disabled")){var i=o.dataset.value,r=o.dataset.optionId;let e=o.dataset.handle,t=o.dataset.pid;if(1!=o.dataset.status){if("MULTI"!=this.dataset.groupType)return;e=""}if(!e){if("MULTI"!=this.dataset.groupType)return;o=[...this.products.find(t=>t.productId==this.dataset.pid)?.option],i=(o[r]=i,p(r,o,this.products));e=i.handle,t=i.productId,u("KingLinkedOptionsProduct","Find related product",i)}e&&t&&("product-page"==this.dataset.renderContext&&"seamless"==this.switchMode?this.handleSwitchProduct(e,t).then(t=>{t||this.handleRedirect(e)}):this.handleRedirect(e))}}async handleSwitchProduct(t,e){var o=this.closest(".shopify-section");if(!o)return!1;var i=o.id.replace("shopify-section-",""),r=[i],n=this.config.seamlessSectionIds;if(0{t.removeEventListener("mouseenter",this.showTooltip.bind(this,t)),t.removeEventListener("mouseleave",this.hideTooltip.bind(this,t))}),this.tooltipEl&&this.tooltipEl.classList.remove("show"),0{t.removeEventListener("mouseenter",this.showPopover.bind(this,t)),t.removeEventListener("mouseleave",this.hidePopover.bind(this,t))}),this.popoverEl&&this.popoverEl.classList.remove("show"),0{clearTimeout(i),e(...t)},o)}}(function(t=[]){u("GLOBAL","Loading collection options, changes:",t),_.load()},200),V=new MutationObserver(t=>{let r=!1,n=[];t.forEach(t=>{"childList"===t.type&&0{var e="A"===t.nodeName&&t.href?.includes("/products/"),o=t.querySelector&&t.querySelector('a[href*="/products/"]'),i="KING-LINKED-OPTIONS-COLLECTION"===t.nodeName;!e&&!o||i||(r=!0,n.push(t))})}),r&&A(n)});function t(){for(const e of document.querySelectorAll("king-linked-options-product"))e instanceof customElements.get("king-linked-options-product")||(u("GLOBAL","Script delayed by other app, re-render king-linked-options-product component",e),e.parentNode.replaceChild(e.cloneNode(!0),e));if(D(),window.kingLinkedOptionConfig){if("product"===window.kingLinkedOptionConfig.pageType&&x.load(),window.kingLinkedOptionConfig.productCard.enabled&&((t=window.kingLinkedOptionConfig.productCard.applyPages).includes("collection")&&t.push("list-collections"),t.includes(window.kingLinkedOptionConfig.pageType)?(B("product-card.min.css"),V.observe(document.body,{childList:!0,subtree:!0}),A()):u("GLOBAL","Current page not in applyPages, skip loading",window.kingLinkedOptionConfig.pageType,t)),window.kingLinkedOptionConfig.themeConfig?.quickView?.trigger&&!document.__linkedOptionQuickViewDelegatedBound){document.__linkedOptionQuickViewDelegatedBound=!0;const o=window.kingLinkedOptionConfig?.themeConfig?.quickView?.trigger;o&&document.addEventListener("click",t=>{t=t.target&&t.target.closest?t.target.closest(o):null;t&&(u("GLOBAL","QuickView Triggered",t),P.getInstance().startMonitoring(t,async(t,e,o)=>{u("GLOBAL","QuickView Triggered for product",t,e,o);var i=await E.getInstance().getGroupByProductId(t);i&&(await T.getInstance().hideQuickViewOption(o,t),(o=o.querySelector("king-linked-options-product"))?o.dataset.pid!=t&&(o.remove(),w(i.renderProductOption(t,"quickview"),e.pos,e.element)):w(i.renderProductOption(t,"quickview"),e.pos,e.element))}))},{passive:!0})}if(window.kingLinkedOptionConfig.featuredProductEnabled){var t=document.querySelectorAll(".linkedoption-featured-product");if(u("GLOBAL","Featured Product Els",t),0{var e,o=t.dataset.productId;o&&(u("GLOBAL","Featured Product Group",e=await i.getGroupByProductId(o)),e)&&w(e.renderProductOption(o,"featured-product"),"INSIDE",t)})}}"product"===window.kingLinkedOptionConfig?.pageType&&T.getInstance().init()}}"loading"===document.readyState?(u("GLOBAL","DOM is loading"),document.addEventListener("DOMContentLoaded",function(){u("GLOBAL","DOMContentLoaded event triggered"),t()})):(u("GLOBAL","DOMContentLoaded"),t())}();