1import{LitElement,html,nothing}from"@lit";import{formatMoney,t}from"@nova/utils";class NovaCustomCalculatorValues extends LitElement{static properties={shape:{type:String,attribute:"shape"},unitType:{type:String,attribute:"unit-type"},basePrice:{type:Number,attribute:"base-price"},basePrice2:{type:Number,attribute:"base-price-2"},basePrice3:{type:Number,attribute:"base-price-3"},basePrice4:{type:Number,attribute:"base-price-4"},widthRange:{type:Object,attribute:"width-range"},lengthRange:{type:Object,attribute:"length-range"},qty:{type:Number,attribute:"qty"},isB2B:{type:Boolean,attribute:"is-b2b",converter:value=>value==="true"},b2bDiscount:{type:Number,attribute:"b2b-discount"},b2bDiscountPromo:{type:Number,attribute:"b2b-discount-promo"},b2bDiscountPromoStartDate:{type:String,attribute:"b2b-discount-promo-start-date"},b2bDiscountPromoEndDate:{type:String,attribute:"b2b-discount-promo-end-date"},d2cDiscountEnabled:{type:String,attribute:"d2c-discount-enabled"},d2cDiscountStartDate:{type:String,attribute:"d2c-discount-start-date"},d2cDiscountEndDate:{type:String,attribute:"d2c-discount-end-date"},d2cDiscountPercentage:{type:Number,attribute:"d2c-discount-percentage"},d2cDiscountPercentageRaw:{type:Number,attribute:"d2c-discount-percentage-raw"},d2cDiscountEligibleSizes:{type:String,attribute:"d2c-discount-eligible-sizes"},d2cDiscountTargetCategories:{type:String,attribute:"d2c-discount-target-categories"},d2cProductCollectionHandles:{type:String,attribute:"d2c-product-collection-handles"},catalogType:{type:String,attribute:"catalog-type"},discountType:{type:String,attribute:"discount-type"},catalogConfig:{type:Object,attribute:"catalog-config"},minWidthError:{type:String,attribute:"min-width-error"},maxWidthError:{type:String,attribute:"max-width-error"},minLengthError:{type:String,attribute:"min-length-error"},maxLengthError:{type:String,attribute:"max-length-error"},countryCode:{type:String,attribute:"country-code"},currencyCode:{type:String,attribute:"currency-code"},cadMultiplier:{type:Number,attribute:"cad-multiplier"}};connectedCallback(){super.connectedCallback(),this.footToInches=12,this.meterToCentimeter=100,this.inchToCentimeter=2.54,this.$propWidth=document.querySelector('[name="properties[_custom_width]"]'),this.$propLength=document.querySelector('[name="properties[_custom_length]"]'),this.$propShape=document.querySelector('[name="properties[_custom_shape]"]'),this.$propIsCustom=document.querySelector('[name="properties[_is_custom_size]"]'),this.$propType=document.querySelector('[name="properties[_custom_type]"]'),this.$propWidthShow=document.querySelector('[name="properties[Width]"]'),this.$propLengthShow=document.querySelector('[name="properties[Length]"]'),this.$propIsB2B=document.querySelector('[name="properties[_is_b2b]"]'),this.$propB2BDiscount=document.querySelector('[name="properties[_b2b_discount]"]'),this.$propB2BDiscountPromo=document.querySelector('[name="properties[_b2b_discount_promo]"]'),this.$propB2BDiscountPromoStartDate=document.querySelector('[name="properties[_b2b_discount_promo_start_date]"]'),this.$propB2BDiscountPromoEndDate=document.querySelector('[name="properties[_b2b_discount_promo_end_date]"]'),this.$propB2BDiscountPromoActive=document.querySelector('[name="properties[_b2b_discount_promo_active]"]'),this.$propD2CDiscountPercentage=document.querySelector('[name="properties[_d2c_discount_percentage]"]'),this.$propCatalogType=document.querySelector('[name="properties[_catalog_type]"]'),this.$propDiscountType=document.querySelector('[name="properties[_discount_type]"]'),this.$sizeElem=document.querySelector('[name="size"]:checked'),this.refreshPriceElements(),this.$calculatorHost=this.closest("nova-custom-calculator");const initialHandles=String(this.d2cProductCollectionHandles||""),pageKey=this.getD2CBaselineKey(),baselineMap=this.getD2CBaselineMap();baselineMap[pageKey]==null&&initialHandles&&(baselineMap[pageKey]=initialHandles);const resolvedInitialHandles=String(baselineMap[pageKey]||initialHandles||"");this.$calculatorHost&&!this.$calculatorHost.dataset.d2cInitialCollectionHandles&&(this.$calculatorHost.dataset.d2cInitialCollectionHandles=resolvedInitialHandles),this.swapSize=this.swapSize.bind(this),this.lastCustomPriceInfo=null,this.pendingPriceSyncTimers=[]}
1getD2CBaselineKey(){return String(window?.location?.pathname||"unknown-page")}getD2CBaselineMap(){return window.__novaD2CBaselineCollectionsByPage||(window.__novaD2CBaselineCollectionsByPage={}),window.__novaD2CBaselineCollectionsByPage}disconnectedCallback(){super.disconnectedCallback(),this.clearPendingPriceSyncTimers()}refreshPriceElements(){this.$priceWrapper=document.querySelector(".product__info-wrapper .js-price"),this.$priceElems=[...document.querySelectorAll(".product__info-wrapper .js-product-custom-price, .product__info-wrapper .price-item--sale")],this.$priceCompareElem=document.querySelector(".product__info-wrapper .price-item--compare"),this.$priceCompareStandard=document.querySelector(".price-item--compare__standard"),this.$priceCompareCustom=document.querySelector(".price-item--compare__custom"),this.$srpCustomElem=document.querySelector(".js-product-custom-srp"),this.$customPromoCompareElem=document.querySelector(".product__info-wrapper .js-custom-promo-compare")}clearPendingPriceSyncTimers(){this.pendingPriceSyncTimers.forEach(timer=>clearTimeout(timer)),this.pendingPriceSyncTimers=[]}ensureCustomPromoCompareElem(){const saleContainer=this.$priceWrapper?.querySelector(".price__sale");if(!saleContainer)return null;let compareElem=saleContainer.querySelector(".js-custom-promo-compare");if(!compareElem){compareElem=document.createElement("s"),compareElem.className="price-item price-item--regular js-custom-promo-compare",compareElem.style.textDecoration="line-through";const firstDt=saleContainer.querySelector("dt");firstDt?saleContainer.insertBefore(compareElem,firstDt):saleContainer.prepend(compareElem)}return compareElem}queuePriceDisplayResync(){this.clearPendingPriceSyncTimers(),[80,240,600,1200,2e3].forEach(delay=>{const timer=setTimeout(()=>{this.lastCustomPriceInfo&&(this.refreshPriceElements(),this.applyCustomPromoDisplay(this.lastCustomPriceInfo),this.syncInlineB2BPromoCompare(this.lastCustomPriceInfo))},delay);this.pendingPriceSyncTimers.push(timer)})}formatPrice(cents){let formatted=formatMoney(cents);return this.currencyCode&&this.currencyCode!=="USD"&&(formatted+=` ${this.currencyCode}`),formatted}applyCustomPromoDisplay(priceInfo){if(!priceInfo||this.isB2B)return;if(priceInfo.beforePromo>priceInfo.msrp&&!this.isB2B){this.$priceWrapper?.classList.add("price--on-sale"),this.$priceCompareElem&&this.$priceCompareElem.classList.add("hidden"),this.$priceCompareStandard&&this.$priceCompareStandard.classList.add("hidden"),this.$priceCompareCustom&&this.$priceCompareCustom.classList.add("hidden");const customCompare=this.ensureCustomPromoCompareElem();customCompare&&(customCompare.textContent=this.formatPrice(priceInfo.beforePromo),customCompare.style.display="");return}this.$priceCompareElem&&this.$priceCompareElem.classList.add("hidden"),this.$customPromoCompareElem&&(this.$customPromoCompareElem.style.display="none")}ensureSrpBubbleElem(){if(!this.$priceCompareStandard)return null;let elem=document.querySelector(".js-b2b-srp-bubble");return elem||(elem=document.createElement("span"),elem.className="price-item--compare__srp p c-grey-400 bg-grey-100 py-2xs price--chip price--msrp js-b2b-srp-bubble",this.$priceCompareStandard.insertAdjacentElement("afterend",elem)),elem}syncInlineB2BPromoCompare(priceInfo){[...document.querySelectorAll(".js-inline-b2b-promo-compare")].forEach(compareEl=>compareEl.remove());const srpBubble=document.querySelector(".js-b2b-srp-bubble");if(!this.isB2B||!priceInfo||!(priceInfo.beforePromo>priceInfo.msrp)){srpBubble&&srpBubble.remove();return}this.$priceCompareElem&&this.$priceCompareElem.classList.remove("hidden"),this.$priceCompareStandard&&(this.$priceCompareStandard.classList.remove("hidden"),this.$priceCompareStandard.className="price-item--compare__standard p c-grey-400",this.$priceCompareStandard.style.textDecoration="line-through",this.$priceCompareStandard.textContent=this.formatPrice(priceInfo.beforePromo));const srpElem=this.ensureSrpBubbleElem();srpElem&&(srpElem.textContent=`${this.formatPrice(priceInfo.price)} SRP`),this.$priceCompareCustom&&this.$priceCompareCustom.classList.add("hidden")}firstUpdated(){this.initialize()}updated(changedProperties){changedProperties.has("unitType")&&changedProperties.get("unitType")&&(this.requestUpdate(),this.initialize()),changedProperties.has("qty")&&this.$sizeElem&&(this.$sizeElem.value==="custom-placemat"||this.$sizeElem.value==="custom-runner")&&(this.requestUpdate(),this.onCalculatePrice())}initialize(){this.inputFields=[...this.shadowRoot.querySelectorAll("sl-input")],this.inputFields.forEach(item=>{item.value="",item.addEventListener("sl-blur",()=>this.onInputChange(item))}),this.$propWidth&&this.$propWidth.value&&(this.$propWidth.value="",this.$propLength.value="",this.$propShape.value="",this.$propIsCustom.value="",this.$propWidthShow.value="",this.$propLengthShow.value="",this.$propType.value="",this.$propIsB2B.value="",this.$propB2BDiscount.value="",this.$propB2BDiscountPromo.value="",this.$propB2BDiscountPromoStartDate.value="",this.$propB2BDiscountPromoEndDate.value="",this.$propB2BDiscountPromoActive.value="",this.$propD2CDiscountPercentage.value="",this.$propCatalogType.value="",this.$propDiscountType.value="",this.onCalculatePrice())}get typeBySizeOption(){let type="";switch(this.$sizeElem.value){case"custom-placemat":case"custom-runner":type="tabletop";break;case"custom-worktop":type="worktop";break;case"custom-shag-mat":type="shag";break;default:type="rug";break}return type}safeCeil(num,decimals=2){const factor=Math.pow(10,decimals);return Math.ceil(num*factor+Number.EPSILON)/factor}get isD2CPromoEligibleSize(){return(this.$sizeElem?.value||"").startsWith("custom-")}normalizeCategory(value){return String(value||"").trim().toLowerCase().replace(/\s+/g,"-")}get isD2CPromoEligibleCategory(){const targets=(this.d2cDiscountTargetCategories||"").split(",").map(category=>
1this.normalizeCategory(category)).filter(Boolean);if(targets.length===0)return!0;const productCollectionHandles=(this.d2cProductCollectionHandles||"").split(",").map(handle=>this.normalizeCategory(handle)).filter(Boolean),baselineCollectionHandles=(this.$calculatorHost?.dataset?.d2cInitialCollectionHandles||"").split(",").map(handle=>this.normalizeCategory(handle)).filter(Boolean),storedBaselineCollectionHandles=(this.getD2CBaselineMap()[this.getD2CBaselineKey()]||"").split(",").map(handle=>this.normalizeCategory(handle)).filter(Boolean);return productCollectionHandles.length===0&&baselineCollectionHandles.length===0&&storedBaselineCollectionHandles.length===0?!1:targets.some(target=>productCollectionHandles.includes(target)||baselineCollectionHandles.includes(target)||storedBaselineCollectionHandles.includes(target))}get effectiveD2CDiscountPercentage(){if(this.isB2B||!this.isD2CPromoEligibleSize||!this.isD2CPromoEligibleCategory)return 0;const enabledRaw=String(this.d2cDiscountEnabled??"").toLowerCase();if(!(enabledRaw==="true"||enabledRaw==="1"))return 0;const startDate=String(this.d2cDiscountStartDate||"").slice(0,10),endDate=String(this.d2cDiscountEndDate||"").slice(0,10);if(!this.isTodayWithinInclusive(startDate,endDate))return 0;const pctPrimary=Number(this.d2cDiscountPercentage),pctRaw=Number(this.d2cDiscountPercentageRaw);return Number.isFinite(pctPrimary)&&pctPrimary>0?pctPrimary:Number.isFinite(pctRaw)&&pctRaw>0?pctRaw:0}updateDiscountDebug(priceInfo=null){const debugElem=document.querySelector(".js-custom-discount-debug");if(!debugElem)return;const sizeValue=this.$sizeElem?.value||"",customFlag=sizeValue.startsWith("custom-"),categoryEligible=this.isD2CPromoEligibleCategory,effective=this.effectiveD2CDiscountPercentage,targets=this.d2cDiscountTargetCategories||"(all)",productCollections=this.d2cProductCollectionHandles||"(none)",baselineCollections=this.$calculatorHost?.dataset?.d2cInitialCollectionHandles||"(none)",persistedCollections=this.getD2CBaselineMap()[this.getD2CBaselineKey()]||"(none)",base=Number(this.d2cDiscountPercentage)||0,baseRaw=Number(this.d2cDiscountPercentageRaw)||0,enabledRaw=String(this.d2cDiscountEnabled??"").toLowerCase(),isEnabled=enabledRaw==="true"||enabledRaw==="1",startDate=String(this.d2cDiscountStartDate||"").slice(0,10),endDate=String(this.d2cDiscountEndDate||"").slice(0,10),dateActive=this.isTodayWithinInclusive(startDate,endDate);let line=`D2C DEBUG | size=${sizeValue} custom=${customFlag} categoryEligible=${categoryEligible} isB2B=${this.isB2B} enabled=${isEnabled} dateActive=${dateActive} base%=${base} raw%=${baseRaw} effective%=${effective} targets=[${targets}
1] collections=[${productCollections}] baselineCollections=[${baselineCollections}] persistedCollections=[${persistedCollections}]`;priceInfo&&(line+=` | before=${this.formatPrice(priceInfo.beforePromo)} after=${this.formatPrice(priceInfo.msrp)}`),debugElem.textContent=line}applyCalculatedValue(inputFields,type){let calculatedValue=inputFields[0].value*this.footToInches+Number(inputFields[1].value);this.unitType==="metric"&&(calculatedValue=(inputFields[0].value*this.meterToCentimeter+Number(inputFields[1].value))/this.inchToCentimeter,calculatedValue=this.safeCeil(calculatedValue)),type==="w"?(this.$propWidth.value=calculatedValue,this.$propWidthShow.value=`${calculatedValue}${t("products.custom_calculator.units.in")}`,(this.shape==="round"||this.shape==="square")&&(this.$propLength.value=calculatedValue,this.$propLengthShow.value=`${calculatedValue}${t("products.custom_calculator.units.in")}`)):type==="h"&&(this.$propLength.value=calculatedValue,this.$propLengthShow.value=`${calculatedValue}${t("products.custom_calculator.units.in")}`),this.dispatchEvent(new CustomEvent("custom-calculator:values-updated",{detail:{value:calculatedValue,type}}))}onInputChange(item){item.value=item.value.replaceAll("-","");const type=item.dataset.type,$inputs=this.inputFields.filter(input=>input.dataset.type===type);this.applyCalculatedValue($inputs,type),this.$propShape.value=this.shape,this.$propIsCustom.value="true",this.$propType.value=this.typeBySizeOption,this.$propIsB2B.value=this.isB2B?"true":"false",this.$propB2BDiscount.value=this.b2bDiscount||0,this.$propB2BDiscountPromo.value=this.b2bDiscountPromo||0,this.$propB2BDiscountPromoStartDate.value=this.b2bDiscountPromoStartDate,this.$propB2BDiscountPromoEndDate.value=this.b2bDiscountPromoEndDate,this.$propB2BDiscountPromoActive.value=this.isB2B&&Number(this.b2bDiscountPromo)>0&&this.isTodayWithinInclusive(this.b2bDiscountPromoStartDate,this.b2bDiscountPromoEndDate)?"true":"false",this.$propD2CDiscountPercentage.value=this.effectiveD2CDiscountPercentage,this.$propCatalogType.value=this.catalogType||"consumer",this.$propDiscountType.value=this.discountType||"standard",this.onCalculatePrice(),this.updateDiscountDebug(),this.requestUpdate()}calculatedWidth(width){let calWidth=width;if(width)switch(this.$sizeElem.value){case"custom-rug":case"custom-placemat":case"custom-runner":case"custom-worktop":width<=72?calWidth=72:width<=144?calWidth=144:width<=216&&(calWidth=216);break;default:calWidth=width;break}return calWidth}get basePriceByShape(){switch(this.shape){case"rectangle":case"square":return this.basePrice;case"runner":return this.basePrice2;case"oval":case"round":return this.basePrice3;case"special-shape":return this.basePrice4}}calculateDealerPrice(price){return price>0?(price*(1-.4)).toFixed(2):0}calculateMSRP(width,length){const sqft=this.calculatedWidth(width)*length/(this.footToInches*this.footToInches),pricePerSqft=this.basePriceByShape;let price=+(pricePerSqft*sqft*100).toFixed(2);this.countryCode==="CA"&&this.cadMultiplier&&this.cadMultiplier>0&&(price=+(price*this.cadMultiplier).toFixed(2));let total=price;if(this.isB2B&&this.catalogConfig){const discountConfig=this.catalogConfig;if(discountConfig.discount_type?.value==="compound"){const firstDiscount=1-discountConfig.calculator_discount/100,secondDiscount=1-discountConfig.secondary_discount/100;total=+(total*firstDiscount*secondDiscount).toFixed(2)}else if(discountConfig.discount_type?.value==="tiered"){const discountMultiplier=1-(discountConfig.calculator_discount||0)/100;total=+(total*discountMultiplier).toFixed(2)}else{const discount=discountConfig.calculator_discount||0;if(discount>0){const discountMultiplier=1-discount/100;total=+(total*discountMultiplier).toFixed(2)}}}const beforePromo=total;if(this.isB2B&&Number(this.b2bDiscountPromo)>0&&this.isTodayWithinInclusive(this.b2bDiscountPromoStartDate,this.b2bDiscountPromoEndDate)){const promoMultiplier=1-Number(this.b2bDiscountPromo)/100;total=+(total*promoMultiplier).toFixed(2)}if(this.effectiveD2CDiscountPercentage>0){const promoMultiplier=1-this.effectiveD2CDiscountPercentage/100;total=+(total*promoMultiplier).toFixed(2)}const dealerPrice=this.calculateDealerPrice(price);return{sqft:+sqft,pricePerSqft:+pricePerSqft.toFixed(2),price,beforePromo,msrp:total,b2bDiscount:this.isB2B?this.b2bDiscount:0,catalogType:this.catalogType||"consumer",discountType:this.discountType||"standard",dealerPrice}}onCalculatePrice(){this.$sizeElem=document.querySelector('[name="size"]:checked'),this.refreshPriceElements(),this.submitBtn=document.querySelector(".js-product-buy-button");const setPendingState=isPending=>{this.$priceWrapper&&(this.$priceWrapper.classList.toggle("price--custom-pending",!!isPending),this.$priceWrapper.classList.toggle("price--custom-ready",!isPending))};let w=Number(this.$propWidth.value),h=Number(this.$propLength.value);if(w&&h)if(this.widthRange&&(this.widthRange.min>
1w||this.widthRange.max<w)&&(this.$priceElems.forEach(item=>item.textContent="-"),this.submitBtn?.setAttribute("disabled",!0),w=0),this.lengthRange&&(this.lengthRange.min>h||this.lengthRange.max<h)&&(this.$priceElems.forEach(item=>item.textContent="-"),this.submitBtn?.setAttribute("disabled",!0),h=0),w&&h)if(w>h)this.swapSize(w,h);else{const priceInfo=this.calculateMSRP(w,h);setPendingState(!1),this.showSRPForB2B(priceInfo.price),this.updateDealerPriceDisplay(priceInfo),this.submitBtn?.removeAttribute("disabled"),this.$priceElems.forEach(item=>item.textContent=this.formatPrice(priceInfo.msrp)),this.updateDiscountDebug(priceInfo),this.lastCustomPriceInfo=priceInfo,this.applyCustomPromoDisplay(priceInfo),this.syncInlineB2BPromoCompare(priceInfo),this.queuePriceDisplayResync()}else setPendingState(!0),this.$priceElems.forEach(item=>item.textContent="-"),this.$priceCompareElem&&this.$priceCompareElem.classList.add("hidden"),this.submitBtn?.setAttribute("disabled",!0),this.lastCustomPriceInfo=null,this.syncInlineB2BPromoCompare(null),this.updateDiscountDebug();
1else setPendingState(!0),this.$priceElems.forEach(item=>item.textContent="-"),this.$priceCompareElem&&this.$priceCompareElem.classList.add("hidden"),this.submitBtn?.setAttribute("disabled",!0),this.lastCustomPriceInfo=null,this.syncInlineB2BPromoCompare(null),this.updateDiscountDebug();this.shape==="special-shape"&&this.submitBtn?.setAttribute("disabled",!0),document.dispatchEvent(new CustomEvent("nova:product:render-custom-calculator-preview",{detail:{w,h}}))}updateDealerPriceDisplay(priceInfo){const wrap=document.querySelector(".js-product-dealer-price-wrap"),el=document.querySelector(".js-product-dealer-price");if(!wrap||!el)return;const srp=Number(priceInfo?.price||0),dealer=Number(priceInfo?.dealerPrice||0);if(!(srp>0)||!(dealer>0)){wrap.classList.add("hidden"),wrap.setAttribute("aria-hidden","true"),el.textContent="";return}const label=t("products.product.price.dealer_price");el.textContent=label.replace("{{ price }}",this.formatPrice(dealer)),wrap.classList.remove("hidden"),wrap.setAttribute("aria-hidden","false")}showSRPForB2B(price){this.refreshPriceElements(),this.isB2B&&this.b2bDiscount?(this.$priceWrapper?.classList.add("price--on-sale","price--on-msrp"),this.$priceCompareElem&&this.$priceCompareElem.classList.remove("hidden"),this.$priceCompareCustom&&this.$priceCompareCustom.classList.add("hidden"),this.$priceCompareStandard&&(this.$priceCompareStandard.classList.remove("hidden"),this.$priceCompareStandard.style.textDecoration="",this.$priceCompareStandard.textContent=`${this.formatPrice(price)} SRP`)):this.$priceCompareElem&&this.$priceCompareElem.classList.add("hidden")}swapSize(w,h){const $inputsW=this.inputFields.filter(input=>input.dataset.type==="w"),oldW=$inputsW.map(item=>item.value),$inputsH=this.inputFields.filter(input=>input.dataset.type==="h");$inputsH.forEach((item,index)=>{$inputsW[index].value=item.value,item.value=oldW[index]}),this.applyCalculatedValue($inputsW,"w"),this.applyCalculatedValue($inputsH,"h");const priceInfo=this.calculateMSRP(h,w);
1this.$priceElems.forEach(item=>item.textContent=this.formatPrice(priceInfo.msrp)),this.showSRPForB2B(priceInfo.price),this.updateDealerPriceDisplay(priceInfo),this.submitBtn?.removeAttribute("disabled"),this.lastCustomPriceInfo=priceInfo,this.syncInlineB2BPromoCompare(priceInfo),this.dispatchEvent(new CustomEvent("custom-calculator:values-swapped"))}normalizeYmd(dateStr){const normalized=String(dateStr||"").slice(0,10);return/^\d{4}-\d{2}-\d{2}$/.test(normalized)?normalized:""}getTodayYmdInTimeZone(timeZone="America/New_York"){const parts=new Intl.DateTimeFormat("en-CA",{timeZone,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date),year=parts.find(part=>part.type==="year")?.value,month=parts.find(part=>part.type==="month")?.value,day=parts.find(part=>part.type==="day")?.value;return!year||!month||!day?"":`${year}-${month}-${day}`}isTodayWithinInclusive(startStr,endStr){const todayYmd=this.getTodayYmdInTimeZone("America/New_York");if(!todayYmd)return!1;const startYmd=this.normalizeYmd(startStr),endYmd=this.normalizeYmd(endStr);return startYmd&&endYmd?todayYmd>=startYmd&&todayYmd<=endYmd:startYmd&&!endYmd?todayYmd>=startYmd:!startYmd&&endYmd?todayYmd<=endYmd:!0}renderInputs(type){let firstLabel=t("products.custom_calculator.units.feet"),secondLabel=t("products.custom_calculator.units.inches");return this.unitType==="metric"&&(firstLabel=t("products.custom_calculator.units.meter"),secondLabel=t("products.custom_calculator.units.centimeter")),html` 2 <div part="unit-inputs"> 3 <sl-input 4 size="medium" 5 type="number" 6 min="1" 7 no-spin-buttons 8 required 9 part="unit-input" 10 data-type="${type}" 11 name="${type}-1" 12 autocomplete="off" 13 > 14 <span slot="suffix" part="unit-label">${firstLabel}</span> 15 </sl-input> 16 <sl-input 17 size="medium" 18 type="number" 19 min="1" 20 no-spin-buttons 21 part="unit-input" 22 data-type="${type}" 23 name="${type}-2" 24 autocomplete="off" 25 > 26 <span slot="suffix" part="unit-label">${secondLabel}</span> 27 </sl-input> 28 </div> 29 `}showMinMax(range){return range?html`<span part="range">${t("products.custom_calculator.labels.min")} ${range.min}${t("products.custom_calculator.units.in")}, ${t("products.custom_calculator.labels.max")} ${range.max}</span>`:nothing}showError(range,isWidth=!0){const key=isWidth?"w":"h";if(this.classList.remove(`input-error-${key}-min`,`input-error-${key}-max`),range){let value=Number(this.$propWidth.value),minError=this.minWidthError,maxError=this.maxWidthError;if(isWidth||(value=Number(this.$propLength.value),minError=this.minLengthError,maxError=this.maxLengthError),value){if(Number(range.min)&&Number(range.min)>value)return this.classList.add(`input-error-${key}-min`),html`<div part="error">${minError}</div>`;if(Number(range.max)&&Number(range.max)<value)return this.classList.add(`input-error-${key}-max`),html`<div part="error">${maxError}</div>`}}return nothing}renderFields(){switch(this.shape){case"rectangle":case"runner":case"special-shape":case"oval":return html` 30 <div class="" slot="base" part="container"> 31 <div part="block"> 32 <div part="label"> 33 ${t("products.custom_calculator.labels.width")} 34 ${this.showMinMax(this.widthRange)} 35 </div> 36 ${this.showError(this.widthRange)} 37 ${this.renderInputs("w")} 38 </div> 39 <div part="block"> 40 <div part="label"> 41 ${t("products.custom_calculator.labels.length")} 42 ${this.showMinMax(this.lengthRange)} 43 </div> 44 ${this.showError(this.lengthRange,!1)} 45 ${this.renderInputs("h")} 46 </div> 47 </div> 48 `;case"round":case"square":return html` 49 <div class="" slot="base" part="container"> 50 <div part="block"> 51 <div part="label"> 52 ${this.showMinMax(this.widthRange)} 53 </div> 54 ${this.showError(this.widthRange)} 55 ${this.renderInputs("w")} 56 </div> 57 </div> 58 `;default:break}return nothing}render(){return html` 59 <div part="base"> 60 <slot name="base"></slot> 61 ${this.renderFields()} 62 </div> 63 `}}typeof customElements.get("nova-custom-calculator-values")>"u"&&customElements.define("nova-custom-calculator-values",NovaCustomCalculatorValues); 64//# sourceMappingURL=/cdn/shop/t/335/assets/component-custom-calculator-values.js.map?v=10935342968425228871790628819
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.