var tnt=tnt||{};tnt.page=tnt.page||{}; tnt.page.pdp={logLabel:"[tnt.page.pdp] ",init:function(){tnt.components.shared.productImageViewer.setUpCarousel(".product-image-viewer");tnt.page.pdp.bindLabelDropdownOptionClick();tnt.components.aem.listPricing.renderListPricing();console.log(this.logLabel+"PDP page-specific code initialized.");var a=$(".pdp-actions .price").data("productid");a&&tnt.page.pdp.renderThresholdForProduct(a)},renderThresholdForProduct:function(a){var c=tntvars.inventoryTresholdURL+tnt.global.addUrlParams("?");c=c.split("{productCode}").join(a); var d={productCodes:a};$(".pdp-inventory-threshold").addClass(" spinner-"+a+" spinner-black").text(Granite.I18n.get("product.check.availablilty"));$.ajax({type:"POST",url:c,dataType:"json",data:d,success:function(b){(b=tnt.components.shared.globalSearch.getSpecifiedProductStatus(b.inventoryThresholds,a))&&("inventorythreshold.statuses.instock"===b.toLowerCase()?$(".pdp-inventory-threshold").text(Granite.I18n.get(b)).removeClass("spinner-black"):$(".pdp-inventory-threshold").text(Granite.I18n.get(b)).removeClass("spinner-black").addClass("not-in-stock"))}, error:function(){console.error("Can't get inventory threshold")},complete:function(){$(".pdp-inventory-threshold").removeClass("spinner-"+a)}})},bindLabelDropdownOptionClick:function(){$(".custom-select-option li").on("click",tnt.page.pdp.labelDropDownOptionClick)},labelDropDownOptionClick:function(){var a=$(this).data("url");a&&(window.location.href=a)},renderProductViewedDataLayer:function(){var a=$(".pdp-actions"),c=$(".pdp-overview").data("code"),d=$(".pdp-overview").data("url"),b=d.match(/\.(\d+)\.html$/); b&&b[1]&&(c=b[1]);b=a.find(".lp-dollars").text().replace(/\s+/g,"").replaceAll(",","").replaceAll(".","")+"."+a.find(".lp-cents").text().replace("\x26nbsp;"," ").split(/\s+/g)[0];var e=a.find(".sp-dollars").text().replace(/\s+/g,"").replaceAll(",","").replaceAll(".","")+"."+a.find(".sp-cents").text().replace("\x26nbsp;"," ").split(/\s+/g)[0];window.appEventData=window.appEventData||[];appEventData.push({event:"Product Viewed",product:[{productInfo:{productCategory:tnt.global.parseProductCategory(d), productStockStatus:a.find(".pdp-inventory-threshold").text(),productID:c+""},price:{productListPrice:"."==b?"":b,productCustomerPrice:"."==e?b:e}}]})}};$(document).ready(function(){tnt.page.pdp.init()});$(window).on("load",function(){tnt.page.pdp.renderProductViewedDataLayer()});