<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">define(['jquery','underscore','mage/template','mage/translate','priceUtils','priceBox','jquery-ui-modules/widget','jquery/jquery.parsequery','fotoramaVideoEvents'],function($,_,mageTemplate,$t,priceUtils){'use strict';$.widget('mage.configurable',{options:{superSelector:'.super-attribute-select',selectSimpleProduct:'[name="selected_configurable_option"]',priceHolderSelector:'.price-box',spConfig:{},state:{},priceFormat:{},optionTemplate:'&lt;%- data.label %&gt;'+'&lt;% if (typeof data.finalPrice.value !== "undefined") { %&gt;'+' &lt;%- data.finalPrice.formatted %&gt;'+'&lt;% } %&gt;',mediaGallerySelector:'[data-gallery-role=gallery-placeholder]',mediaGalleryInitial:null,slyOldPriceSelector:'.sly-old-price',normalPriceLabelSelector:'.product-info-main .normal-price .price-label',gallerySwitchStrategy:'replace',tierPriceTemplateSelector:'#tier-prices-template',tierPriceBlockSelector:'[data-role="tier-price-block"]',tierPriceTemplate:'',selectorProduct:'.product-info-main',selectorProductPrice:'[data-role=priceBox]',qtyInfo:'#qty'},_create:function(){this._initializeOptions();this._overrideDefaults();this._setupChangeEvents();this._fillState();this._setChildSettings();this._configureForValues();$(this.element).trigger('configurable.initialized');$(this.options.qtyInfo).on('input',this._reloadPrice.bind(this));},_initializeOptions:function(){var options=this.options,gallery=$(options.mediaGallerySelector),priceBoxOptions=$(this.options.priceHolderSelector).priceBox('option').priceConfig||null;if(priceBoxOptions&amp;&amp;priceBoxOptions.optionTemplate){options.optionTemplate=priceBoxOptions.optionTemplate;}
if(priceBoxOptions&amp;&amp;priceBoxOptions.priceFormat){options.priceFormat=priceBoxOptions.priceFormat;}
options.optionTemplate=mageTemplate(options.optionTemplate);options.tierPriceTemplate=$(this.options.tierPriceTemplateSelector).html();options.settings=options.spConfig.containerId?$(options.spConfig.containerId).find(options.superSelector):$(options.superSelector);options.values=options.spConfig.defaultValues||{};options.parentImage=$('[data-role=base-image-container] img').attr('src');this.inputSimpleProduct=this.element.find(options.selectSimpleProduct);gallery.data('gallery')?this._onGalleryLoaded(gallery):gallery.on('gallery:loaded',this._onGalleryLoaded.bind(this,gallery));},_overrideDefaults:function(){var hashIndex=window.location.href.indexOf('#');if(hashIndex!==-1){this._parseQueryParams(window.location.href.substr(hashIndex+1));}
if(this.options.spConfig.inputsInitialized){this._setValuesByAttribute();}
this._setInitialOptionsLabels();},_parseQueryParams:function(queryString){var queryParams=$.parseQuery({query:queryString});$.each(queryParams,$.proxy(function(key,value){if(this.options.spConfig.attributes[key]!==undefined&amp;&amp;_.find(this.options.spConfig.attributes[key].options,function(element){return element.id===value;})){this.options.values[key]=value;}},this));},_setValuesByAttribute:function(){this.options.values={};$.each(this.options.settings,$.proxy(function(index,element){var attributeId;if(element.value){attributeId=element.id.replace(/[a-z]*/,'');if(this.options.spConfig.attributes[attributeId]!==undefined&amp;&amp;_.find(this.options.spConfig.attributes[attributeId].options,function(optionElement){return optionElement.id===element.value;})){this.options.values[attributeId]=element.value;}}},this));},_setInitialOptionsLabels:function(){$.each(this.options.spConfig.attributes,$.proxy(function(index,element){$.each(element.options,$.proxy(function(optIndex,optElement){this.options.spConfig.attributes[index].options[optIndex].initialLabel=optElement.label;},this));},this));},_setupChangeEvents:function(){$.each(this.options.settings,$.proxy(function(index,element){$(element).on('change',this,this._configure);},this));},_fillState:function(){$.each(this.options.settings,$.proxy(function(index,element){var attributeId=element.id.replace(/[a-z]*/,'');if(attributeId&amp;&amp;this.options.spConfig.attributes[attributeId]){element.config=this.options.spConfig.attributes[attributeId];element.attributeId=attributeId;this.options.state[attributeId]=false;}},this));},_setChildSettings:function(){var childSettings=[],settings=this.options.settings,index=settings.length,option;while(index--){option=settings[index];if(index){option.disabled=true;}else{this._fillSelect(option);}
_.extend(option,{childSettings:childSettings.slice(),prevSetting:settings[index-1],nextSetting:settings[index+1]});childSettings.push(option);}},_configureForValues:function(){if(this.options.values){this.options.settings.each($.proxy(function(index,element){var attributeId=element.attributeId;element.value=this.options.values[attributeId]||'';this._configureElement(element);},this));}},_configure:function(event){event.data._configureElement(this);},_configureElement:function(element){this.simpleProduct=this._getSimpleProductId(element);if(element.value){this.options.state[element.config.id]=element.value;if(element.nextSetting){element.nextSetting.disabled=false;this._fillSelect(element.nextSetting);this._resetChildren(element.nextSetting);}else{if(!!document.documentMode){this.inputSimpleProduct.val(element.options[element.selectedIndex].config.allowedProducts[0]);}else{this.inputSimpleProduct.val(element.selectedOptions[0].config.allowedProducts[0]);}}}else{this._resetChildren(element);}
this._reloadPrice();this._displayRegularPriceBlock(this.simpleProduct);this._displayTierPriceBlock(this.simpleProduct);this._displayNormalPriceLabel();this._changeProductImage();},_changeProductImage:function(){var images,initialImages=this.options.mediaGalleryInitial,gallery=$(this.options.mediaGallerySelector).data('gallery');if(_.isUndefined(gallery)){$(this.options.mediaGallerySelector).on('gallery:loaded',function(){this._changeProductImage();}.bind(this));return;}
images=this.options.spConfig.images[this.simpleProduct];if(images){images=this._sortImages(images);if(this.options.gallerySwitchStrategy==='prepend'){images=images.concat(initialImages);}
images=$.extend(true,[],images);images=this._setImageIndex(images);gallery.updateData(images);this._addFotoramaVideoEvents(false);}else{gallery.updateData(initialImages);this._addFotoramaVideoEvents(true);}},_addFotoramaVideoEvents:function(isInitial){if(_.isUndefined($.mage.AddFotoramaVideoEvents)){return;}
if(isInitial){$(this.options.mediaGallerySelector).AddFotoramaVideoEvents();return;}
$(this.options.mediaGallerySelector).AddFotoramaVideoEvents({selectedOption:this.simpleProduct,dataMergeStrategy:this.options.gallerySwitchStrategy});},_sortImages:function(images){return _.sortBy(images,function(image){return image.position;});},_setImageIndex:function(images){var length=images.length,i;for(i=0;length&gt;i;i++){images[i].i=i+1;}
return images;},_resetChildren:function(element){if(element.childSettings){_.each(element.childSettings,function(set){set.selectedIndex=0;set.disabled=true;});if(element.config){this.options.state[element.config.id]=false;}}},_fillSelect:function(element){var attributeId=element.id.replace(/[a-z]*/,''),options=this._getAttributeOptions(attributeId),prevConfig,index=1,allowedProducts,allowedProductsByOption,allowedProductsAll,i,j,finalPrice=parseFloat(this.options.spConfig.prices.finalPrice.amount),optionFinalPrice,optionPriceDiff,optionPrices=this.options.spConfig.optionPrices,allowedOptions=[],indexKey,allowedProductMinPrice,allowedProductsAllMinPrice,canDisplayOutOfStockProducts=false,filteredSalableProducts;this._clearSelect(element);element.options[0]=new Option('','');element.options[0].innerHTML=this.options.spConfig.chooseText;prevConfig=false;if(element.prevSetting){prevConfig=element.prevSetting.options[element.prevSetting.selectedIndex];}
if(options){for(indexKey in this.options.spConfig.index){if(this.options.spConfig.index.hasOwnProperty(indexKey)){allowedOptions=allowedOptions.concat(_.values(this.options.spConfig.index[indexKey]));}}
if(prevConfig){allowedProductsByOption={};allowedProductsAll=[];for(i=0;i&lt;options.length;i++){for(j=0;j&lt;options[i].products.length;j++){if(prevConfig.config&amp;&amp;prevConfig.config.allowedProducts&amp;&amp;prevConfig.config.allowedProducts.indexOf(options[i].products[j])&gt;-1){if(!allowedProductsByOption[i]){allowedProductsByOption[i]=[];}
allowedProductsByOption[i].push(options[i].products[j]);allowedProductsAll.push(options[i].products[j]);}}}
if(typeof allowedProductsAll[0]!=='undefined'&amp;&amp;typeof optionPrices[allowedProductsAll[0]]!=='undefined'){allowedProductsAllMinPrice=this._getAllowedProductWithMinPrice(allowedProductsAll);finalPrice=parseFloat(optionPrices[allowedProductsAllMinPrice].finalPrice.amount);}}
for(i=0;i&lt;options.length;i++){if(prevConfig&amp;&amp;typeof allowedProductsByOption[i]==='undefined'){continue;}
allowedProducts=prevConfig?allowedProductsByOption[i]:options[i].products.slice(0);optionPriceDiff=0;if(typeof allowedProducts[0]!=='undefined'&amp;&amp;typeof optionPrices[allowedProducts[0]]!=='undefined'){allowedProductMinPrice=this._getAllowedProductWithMinPrice(allowedProducts);optionFinalPrice=parseFloat(optionPrices[allowedProductMinPrice].finalPrice.amount);optionPriceDiff=optionFinalPrice-finalPrice;options[i].label=options[i].initialLabel;if(optionPriceDiff!==0){options[i].label+=' '+priceUtils.formatPriceLocale(optionPriceDiff,this.options.priceFormat,true);}}
if(allowedProducts.length&gt;0||_.include(allowedOptions,options[i].id)){options[i].allowedProducts=allowedProducts;element.options[index]=new Option(this._getOptionLabel(options[i]),options[i].id);if(this.options.spConfig.canDisplayShowOutOfStockStatus){filteredSalableProducts=$(this.options.spConfig.salable[attributeId][options[i].id]).filter(options[i].allowedProducts);canDisplayOutOfStockProducts=filteredSalableProducts.length===0;}
if(typeof options[i].price!=='undefined'){element.options[index].setAttribute('price',options[i].price);}
if(allowedProducts.length===0||canDisplayOutOfStockProducts){element.options[index].disabled=true;}
element.options[index].config=options[i];index++;}}}},_getOptionLabel:function(option){return option.label;},_clearSelect:function(element){var i;for(i=element.options.length-1;i&gt;=0;i--){element.remove(i);}},_getAttributeOptions:function(attributeId){if(this.options.spConfig.attributes[attributeId]){return this.options.spConfig.attributes[attributeId].options;}},_reloadPrice:function(){$(this.options.priceHolderSelector).trigger('updatePrice',this._getPrices());},_getPrices:function(){var prices={},elements=_.toArray(this.options.settings),allowedProduct;_.each(elements,function(element){var selected=element.options[element.selectedIndex],config=selected&amp;&amp;selected.config,priceValue=this._calculatePrice({});if(config&amp;&amp;config.allowedProducts.length===1){priceValue=this._calculatePrice(config);}else if(element.value){allowedProduct=this._getAllowedProductWithMinPrice(config.allowedProducts);priceValue=this._calculatePrice({'allowedProducts':[allowedProduct]});}
if(!_.isEmpty(priceValue)){prices.prices=priceValue;}},this);return prices;},_getAllowedProductWithMinPrice:function(allowedProducts){var optionPrices=this.options.spConfig.optionPrices,product={},optionMinPrice,optionFinalPrice;_.each(allowedProducts,function(allowedProduct){optionFinalPrice=parseFloat(optionPrices[allowedProduct].finalPrice.amount);if(_.isEmpty(product)||optionFinalPrice&lt;optionMinPrice){optionMinPrice=optionFinalPrice;product=allowedProduct;}},this);return product;},_calculatePrice:function(config){var displayPrices=$(this.options.priceHolderSelector).priceBox('option').prices,newPrices=this.options.spConfig.optionPrices[_.first(config.allowedProducts)]||{};_.each(displayPrices,function(price,code){displayPrices[code].amount=newPrices[code]?newPrices[code].amount-displayPrices[code].amount:0;});return displayPrices;},_getSimpleProductId:function(element){var allOptions=element.config.options,value=element.value,config;config=_.filter(allOptions,function(option){return option.id===value;});config=_.first(config);return _.isEmpty(config)?undefined:_.first(config.allowedProducts);},_displayRegularPriceBlock:function(optionId){var shouldBeShown=true,$priceBox=this.element.parents(this.options.selectorProduct).find(this.options.selectorProductPrice);_.each(this.options.settings,function(element){if(element.value===''){shouldBeShown=false;}});if(shouldBeShown&amp;&amp;this.options.spConfig.optionPrices[optionId].oldPrice.amount!==this.options.spConfig.optionPrices[optionId].finalPrice.amount){$(this.options.slyOldPriceSelector).show();}else{$(this.options.slyOldPriceSelector).hide();}
$(document).trigger('updateMsrpPriceBlock',[optionId,this.options.spConfig.optionPrices,$priceBox]);},_displayNormalPriceLabel:function(){var shouldBeShown=false;_.each(this.options.settings,function(element){if(element.value===''){shouldBeShown=true;}});if(shouldBeShown){$(this.options.normalPriceLabelSelector).show();}else{$(this.options.normalPriceLabelSelector).hide();}},_onGalleryLoaded:function(element){var galleryObject=element.data('gallery');this.options.mediaGalleryInitial=galleryObject.returnCurrentImages();},_displayTierPriceBlock:function(optionId){var tierPrices=typeof optionId!='undefined'&amp;&amp;this.options.spConfig.optionPrices[optionId].tierPrices;if(_.isArray(tierPrices)&amp;&amp;tierPrices.length&gt;0){if(this.options.tierPriceTemplate){$(this.options.tierPriceBlockSelector).html(mageTemplate(this.options.tierPriceTemplate,{'tierPrices':tierPrices,'$t':$t,'currencyFormat':this.options.spConfig.currencyFormat,'priceUtils':priceUtils})).show();}}else{$(this.options.tierPriceBlockSelector).hide();}}});return $.mage.configurable;});</pre></body></html>