{"version":3,"file":"variants.js","mappings":";AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,wBAAwB,oCAAoC;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,2BAA2B,qBAAqB;AAChD;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA,QAAQ;AACR;AACA;AACA,UAAU;AACV;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,MAAM;AACN;AACA;AACA,QAAQ;AACR;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,oBAAoB,OAAO;AAC5C;AACA,WAAW;AACX;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA,kBAAkB,wBAAwB;AAC1C,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,MAAM;AACN;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;AACA,QAAQ;AACR;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,sBAAsB,qBAAqB;AAC3C;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,uDAAuD;AACpE;AACA,WAAW,YAAY,oDAAoD;AAC3E;AACA,MAAM;AACN;AACA;;AAEA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,MAAM;AACN;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,QAAQ;AACR;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,CAAC","sources":["webpack://build/../vincishoes2/assets/javascripts/variants.js"],"sourcesContent":["var $attributes = $(\"[data-product-attributes]\");\n\nwindow.variants = {\n $sectionProduct: $(\"[data-section-product]\"),\n $wrapperImages: $(\"[data-section-product]\").find(\"[data-product-images]\"),\n $sliderProduct: $(\"[data-section-product]\").find(\n \"[data-product-images] [data-main-slider]\"\n ),\n $thumbsProduct: $(\"[data-section-product]\").find(\n \"[data-product-images] [data-slider-thumbs]\"\n ),\n sliderProduct: [],\n $wrapperProduct: $(\"[data-box-produto]\"),\n config: {\n // pega o elemento que corresponde ao primeiro atributo\n $attr1: \"\",\n attr1Name: \"\",\n // pega o elemento que corresponde ao segundo atributo\n $attr2: \"\",\n attr2Name: \"\",\n // pega o elemento que corresponde ao terceiro atributo\n $attr3: \"\",\n attr3Name: \"\",\n // quantos atributos o produto tem para seleção\n qtdAttributes: 0,\n hasAttribute1: false,\n hasAttribute2: false,\n hasAttribute3: false,\n },\n setConfigDefault: function () {\n var _this = this;\n\n var $attr1 = $attributes.find('[data-attribute=\"1\"]:not(.hidden)');\n var $attr2 = $attributes.find('[data-attribute=\"2\"]:not(.hidden)');\n var $attr3 = $attributes.find('[data-attribute=\"3\"]:not(.hidden)');\n\n var itensAttr1 = \"\";\n var itensAttr2 = \"\";\n var itensAttr3 = \"\";\n\n if ($attr1.length > 0) {\n itensAttr1 = $attr1.data(\"items\");\n itensAttr1 = itensAttr1.split(\" // \");\n }\n\n if ($attr2.length > 0) {\n itensAttr2 = $attr2.data(\"items\");\n itensAttr2 = itensAttr2.split(\" // \");\n }\n\n if ($attr3.length > 0) {\n itensAttr3 = $attr3.data(\"items\");\n itensAttr3 = itensAttr3.split(\" // \");\n }\n\n $.extend(true, _this.config, {\n // pega o elemento que corresponde ao primeiro atributo\n $attr1: $attr1,\n attr1Name: $attr1.data(\"attribute-name\"),\n itemsAttr1: itensAttr1,\n // pega o elemento que corresponde ao segundo atributo\n $attr2: $attr2,\n attr2Name: $attr2.data(\"attribute-name\"),\n itemsAttr2: itensAttr2,\n // pega o elemento que corresponde ao terceiro atributo\n $attr3: $attr3,\n attr3Name: $attr3.data(\"attribute-name\"),\n itemsAttr3: itensAttr3,\n });\n },\n setQtdAttributes: function () {\n // Seta quantos atributos o produto possuí para seleção\n\n var qtdAttributes = 0;\n\n var $input = $attributes.find(\"[data-quantidade-atributos]\");\n\n var $attr1 = this.config.$attr1;\n var $attr2 = this.config.$attr2;\n var $attr3 = this.config.$attr3;\n\n // considerando que o tamanho é o primeiro atributo\n if ($attr1.length > 0) {\n qtdAttributes++;\n this.config.hasAttribute1 = true;\n }\n\n // considerando que a cor é o segundo atributo\n if ($attr2.length > 0) {\n qtdAttributes++;\n this.config.hasAttribute2 = true;\n }\n\n // considerando que o custom é o terceiro atributo\n if ($attr3.length > 0) {\n qtdAttributes++;\n this.config.hasAttribute3 = true;\n }\n\n this.config.qtdAttributes = qtdAttributes;\n },\n setDisponibility: function () {\n var _this = this;\n //console.info('setDisponibility');\n // console.info(_this.config);\n\n if (_this.config.qtdAttributes > 1) {\n // Para quando há o atributo 1 e o atributo 2\n if (_this.config.hasAttribute1 && _this.config.hasAttribute2) {\n // Itera todas as cores para verificar a disponibilidade\n for (var i = 0; i < _this.config.itemsAttr1.length; i++) {\n var cor = _this.config.itemsAttr1[i];\n var $cor = _this.config.$attr1.find(\n '[data-attribute-value=\"' + cor + '\"]'\n );\n var objFind = {};\n var corAvailable = false;\n objFind[_this.config.attr1Name] = cor;\n\n // Busca todas as variações que contém a cor\n var results = vnda.variants.find(objFind);\n\n // Percorre todas as variantes com a cor\n for (var ii = 0; ii < results.length; ii++) {\n // Verifica se alguma variação tem a cor\n if (results[ii].available) {\n corAvailable = true;\n }\n }\n\n $cor.data(\"available\", corAvailable);\n $cor.attr(\"data-available\", corAvailable);\n\n if (corAvailable) {\n $cor.removeClass(\"unavailable\");\n $cor.addClass(\"available\");\n } else {\n $cor.removeClass(\"available\");\n $cor.addClass(\"unavailable\");\n }\n }\n }\n }\n },\n toggleOptionsStyle: function (_$option) {\n /*\n Define se o estilo do atributo passado por parametro é input ou dropdown\n */\n var selecao = _$option.data(\"selecao\");\n var styleType = _$option.data(\"selecao-style\");\n var $optionList = _$option.find(\"[data-attribute-value]\");\n var show = true;\n var showStatusList = [];\n\n // console.info('atributo', selecao, styleType);\n\n $optionList.each(function (index, el) {\n var value = $(el).data(\"attribute-value\");\n\n // console.info(value, value.length);\n if (selecao != \"cor\") {\n if (value.length > 4) {\n showStatusList[index] = true;\n } else {\n showStatusList[index] = false;\n }\n } else {\n if (value.indexOf(\"#\") < 0) {\n showStatusList[index] = true;\n } else {\n showStatusList[index] = false;\n }\n }\n });\n\n if (showStatusList.indexOf(true) >= 0) {\n if (styleType == \"input\") {\n show = false;\n } else if (styleType == \"dropdown\") {\n show = true;\n }\n } else {\n if (styleType == \"input\") {\n show = true;\n } else if (styleType == \"dropdown\") {\n show = false;\n }\n }\n\n if (!show) {\n _$option.addClass(\"hidden\");\n }\n },\n setAttributeValue: function (_value, _$attribute) {\n // console.info('setAttributeValue', _value, _$attribute);\n\n var attrName = _$attribute.data(\"attribute-name\");\n var $input = _$attribute.find(\n 'input[data-attribute-name=\"' + attrName + '\"]'\n );\n\n $input.val(_value);\n },\n setAttributeValueSelected: function (_value, _$attribute) {\n // console.info('setAttributeValueSelected', _value, _$attribute);\n\n var $selected = _$attribute.find(\"[data-selected]\");\n $selected.html(_value);\n },\n markFirstOption: function () {\n var _this = this;\n\n var $attr1 = this.config.$attr1;\n var $attr2 = this.config.$attr2;\n var $attr3 = this.config.$attr3;\n\n //console.log($attr1.find('[data-attribute-value][data-available=true]').first());\n // console.log($attr2.find('[data-attribute-value][data-available=true]').first());\n // console.log($attr3.find('[data-attribute-value][data-available=true]').first());\n\n if (\n $attr1.find(\"[data-attribute-value][data-available=true]\").first()\n .length > 0\n ) {\n $attr1\n .find(\"[data-attribute-value][data-available=true]\")\n .first()\n .trigger(\"click\");\n } else {\n $attr1.find(\"[data-attribute-value]\").first().trigger(\"click\");\n }\n\n // if ($attr2.find('[data-attribute-value][data-available=true]').first().length > 0) {\n // $attr2.find('[data-attribute-value][data-available=true]').first().trigger('click');\n // } else {\n // $attr2.find('[data-attribute-value]').first().trigger('click');\n // }\n\n /*if ($attr3.find('[data-attribute-value][data-available=true]').first().length > 0) {\n $attr3.find('[data-attribute-value][data-available=true]').first().trigger('click');\n } else {\n $attr3.find('[data-attribute-value]').first().trigger('click');\n } */\n },\n getSkuAttributes: function () {\n var _this = this;\n var objFindVariant = {};\n var objVariant;\n\n if (_this.config.hasAttribute1) {\n var nameAttr1 = _this.config.attr1Name;\n var valueAttr1 = _this.config.$attr1\n .find('input[data-attribute-name=\"' + nameAttr1 + '\"]')\n .val();\n objFindVariant[nameAttr1] = valueAttr1;\n }\n\n if (_this.config.hasAttribute2) {\n var nameAttr2 = _this.config.attr2Name;\n var valueAttr2 = _this.config.$attr2\n .find('input[data-attribute-name=\"' + nameAttr2 + '\"]')\n .val();\n objFindVariant[nameAttr2] = valueAttr2;\n }\n\n if (_this.config.hasAttribute3) {\n var nameAttr3 = _this.config.attr3Name;\n var valueAttr3 = _this.config.$attr3\n .find('input[data-attribute-name=\"' + nameAttr3 + '\"]')\n .val();\n objFindVariant[nameAttr3] = valueAttr3;\n }\n\n objVariant = vnda.variants.find(objFindVariant);\n\n //console.info('objFindVariant', objFindVariant);\n //console.info('objVariant', objVariant);\n\n return objVariant;\n },\n updatePrice: function (sale_price, price, installments) {\n if (sale_price != price) {\n var htmlPrice =\n \"\" +\n store.formatMoney(price) +\n \" \" +\n \"\" +\n store.formatMoney(sale_price) +\n \"\";\n } else {\n var htmlPrice = store.formatMoney(price);\n }\n //console.log('aaa', installments)\n if (!!installments) {\n installments = $.grep(installments, function (n, i) {\n return n.interest == false;\n });\n $(\"[data-section-product] .product-infos [data-update-price]\").html(\n htmlPrice\n );\n $(\n \"[data-section-product] .product-infos [data-update-installments]\"\n ).html(\n `ou em ${installments.length}x de ${store.formatMoney(\n installments[installments.length - 1].price\n )} sem juros`\n );\n }\n },\n // COMPORTAMENTO DE QUANDO O USUÁRIO SELECIONA UM ATRIBUTO\n setResultVariants: function () {\n var _this = this;\n // busca a variante\n var objVariant = _this.getSkuAttributes();\n\n // console.info('objVariant', objVariant);\n\n if (objVariant.length > 0) {\n // seta o sku da variante que o usuário selecionou\n _this.$wrapperProduct.find('input[name=\"sku\"]').val(objVariant[0].sku);\n\n const event = new CustomEvent(\"vnda:sku-change\", {\n detail: { sku: objVariant[0].sku },\n });\n const productContainer =\n _this.$wrapperProduct[0].closest(\"[data-product-box]\");\n if (productContainer) productContainer.dispatchEvent(event);\n _this.$wrapperProduct[0].dispatchEvent(event);\n\n productContainer.addEventListener(\"vnda:sku-change\", (event) => {\n console.log(\"SKU changed:\", event.detail.sku);\n });\n\n // atualiza o preço do produto conforme a variante selecionada\n if (window.language == \"pt-BR\") {\n _this.updatePrice(\n objVariant[0].sale_price,\n objVariant[0].price,\n objVariant[0].installments\n );\n } else {\n if (objVariant[0].properties.property3) {\n var internationalPrice = parseFloat(\n objVariant[0].properties.property3.value\n );\n _this.updatePrice(internationalPrice, internationalPrice);\n }\n }\n\n if ($(\"[data-form-notify]\").length > 0) {\n $('[data-form-notify] input[name=\"sku\"]').val(objVariant[0].sku);\n }\n\n // verifica se a variante selecionada está disponível ou não\n if (!objVariant[0].available) {\n _this.setProdutoIndisponivel(objVariant[0]);\n } else {\n _this.setProdutoDisponivel(objVariant[0]);\n }\n } else {\n _this.setProdutoIndisponivel(objVariant[0]);\n }\n\n if (objVariant.length > 0) {\n $attributes.find(\"[data-variant-selected]\").html(objVariant[0].name);\n\n // PARA AS IMAGENS\n _this.setImagesProduct(objVariant[0].sku);\n }\n },\n setProdutoIndisponivel: function (_variant) {\n var _this = this;\n var $btnComprar = _this.$wrapperProduct.find(store.config.selectorBtnBuy);\n var textUnavailable = $btnComprar.data(\"text-unavailable\");\n\n $(\".quantity-text\").addClass(\"hidden\");\n\n $btnComprar.data(\"available\", \"false\");\n $btnComprar.removeClass(\"available\");\n $btnComprar.addClass(\"unavailable\");\n\n if (_variant) {\n $btnComprar.html(textUnavailable);\n } else {\n if (language == \"en\") {\n $btnComprar.html(\"Select size\");\n } else {\n $btnComprar.html(\"Selecione o tamanho\");\n }\n }\n\n // AVISE-ME QUANDO CHEGAR AQUI\n _this.setFormNotify(_variant);\n },\n setFormNotify: function (_variant) {\n $(\"[data-form-notify]\").addClass(\"active\");\n\n setTimeout(function () {\n $(document.body).trigger(\"sticky_kit:recalc\");\n }, 500);\n\n if ($(\"[data-form-notify]\").length > 0) {\n $('[data-form-notify] input[name=\"sku\"]').val(_variant.sku);\n }\n },\n checkCombinations: function (_value, _attributeName) {\n var _this = this;\n var obj = {};\n obj[_attributeName] = String(_value);\n var results = vnda.variants.find(obj);\n\n //console.info('checkCombinations', _attributeName, _value);\n //console.info('results combinations', results);\n\n // Verifica a disponibilidade dos tamanhos quando uma cor é selecionada\n if (_this.config.attr1Name == _attributeName) {\n var tamanhos = _this.config.itemsAttr2;\n var objFind = {};\n objFind[_attributeName] = String(_value);\n\n for (var i = 0; i < tamanhos.length; i++) {\n objFind[_this.config.attr2Name] = String(tamanhos[i]);\n var corTamanhoResults = vnda.variants.find(objFind);\n\n var tamanho = tamanhos[i];\n var $tamanho = $('[data-attribute-value=\"' + tamanho + '\"]');\n\n //console.info('corTamanhoResults', corTamanhoResults);\n\n if (corTamanhoResults.length > 0) {\n var variantResult = corTamanhoResults[0];\n var stock = variantResult.available_quantity;\n\n $tamanho.removeClass(\"disable\");\n\n $tamanho.data(\"stock\", stock);\n $tamanho.attr(\"data-stock\", stock);\n\n if (variantResult.available) {\n $tamanho.data(\"available\", true);\n $tamanho.attr(\"data-available\", true);\n\n $tamanho.removeClass(\"unavailable\");\n $tamanho.addClass(\"available\");\n } else {\n $tamanho.data(\"available\", false);\n $tamanho.attr(\"data-available\", false);\n\n $tamanho.removeClass(\"available\");\n $tamanho.addClass(\"unavailable\");\n }\n } else {\n $tamanho.addClass(\"disable\");\n }\n }\n }\n },\n setProdutoDisponivel: function (_variant) {\n var _this = this;\n var $btnComprar = _this.$wrapperProduct.find(store.config.selectorBtnBuy);\n var textAvailable = $btnComprar.data(\"text-available\");\n var $quantityText = $(\".quantity-text\");\n console.log(\"variant\", $quantityText);\n\n $btnComprar.data(\"available\", \"true\");\n $btnComprar.removeClass(\"unavailable\");\n $btnComprar.addClass(\"available\");\n $btnComprar.html(textAvailable);\n\n if (_variant.available_quantity <= 100) {\n $quantityText.removeClass(\"hidden\");\n $quantityText\n .find(\"span\")\n .html(\n `${_variant.available_quantity == 1 ? \"Resta\" : \"Restam\"} ${\n _variant.available_quantity\n } ${_variant.available_quantity == 1 ? \"item\" : \"itens\"}`\n );\n } else {\n $quantityText.addClass(\"hidden\");\n }\n\n $(\"[data-form-notify]\").removeClass(\"active\");\n },\n /* \n Exibe as imagens que contém o sku passado por parâmetro\n */\n setImagesProduct: function (_sku) {\n var $images = this.$wrapperImages;\n var $mainImages = this.$sliderProduct;\n var $thumbsImages = this.$thumbsProduct;\n var slideProduct = this.sliderProduct[0];\n var slideProductThumbs = this.sliderProduct[1];\n var qtdImagesSku = $mainImages.find(\n '[data-skus-image*=\"' + _sku + ',\"]'\n ).length;\n var $imagesWithoutSkus = $mainImages.find(\".image-without-sku\");\n var $thumbsWithoutSkus = $thumbsImages.find(\".image-without-sku\");\n\n //console.info($mainImages.find('[data-skus-image*=\"' + _sku + ',\"]'));\n //console.info('[data-skus-image*=\"' + _sku + '\"]');\n\n if (qtdImagesSku > 0) {\n // Esconde as imagens que não contém o sku\n $mainImages\n .find(\"[data-image][data-skus-image]\")\n .removeClass(\"active\")\n .addClass(\"inactive\");\n\n $thumbsImages\n .find(\"[data-image-thumb][data-skus-image]\")\n .removeClass(\"active\")\n .addClass(\"inactive\");\n\n // Mostra as imagens que contém o sku\n $mainImages\n .find('[data-image][data-skus-image*=\"' + _sku + ',\"]')\n .addClass(\"active\")\n .removeClass(\"inactive\");\n\n $thumbsImages\n .find('[data-image-thumb][data-skus-image*=\"' + _sku + ',\"]')\n .addClass(\"active\")\n .removeClass(\"inactive\");\n\n // As imagens sem skus selecionados são exibidas sempre\n $imagesWithoutSkus.removeClass(\"inactive\").addClass(\"active\");\n\n $thumbsWithoutSkus.removeClass(\"inactive\").addClass(\"active\");\n\n // $(document.body).trigger(\"sticky_kit:recalc\");\n //console.log('slideProduct', slideProduct);\n slideProduct.update();\n slideProductThumbs.update();\n slideProduct.slideTo(0);\n\n lazyLoadInstance.update();\n } else {\n $mainImages\n .find(\"[data-image][data-skus-image]\")\n .removeClass(\"active\")\n .addClass(\"inactive\");\n\n $thumbsImages\n .find(\"[data-image-thumb][data-skus-image]\")\n .removeClass(\"active\")\n .addClass(\"inactive\");\n\n $imagesWithoutSkus.removeClass(\"inactive\").addClass(\"active\");\n\n $thumbsWithoutSkus.removeClass(\"inactive\").addClass(\"active\");\n }\n },\n execActionAttr: function (_attrName, _valueSelected) {\n var _this = this;\n\n if (_this.config.attr1Name == _attrName) {\n if (typeof attr1Action == \"function\") {\n attr1Action(_valueSelected);\n }\n } else if (_this.config.attr2Name == _attrName) {\n if (typeof attr2Action == \"function\") {\n attr2Action(_valueSelected);\n }\n } else if (_this.config.attr3Name == _attrName) {\n if (typeof attr3Action == \"function\") {\n attr3Action(_valueSelected);\n }\n }\n },\n init: function () {\n var _this = this;\n\n // DEFINE SE O QUE VAI APARECER É A OPÇÃO EM INPUT RADIO OU O DROPDOWN\n $attributes.find(\"[data-prod-option]\").each(function (index, el) {\n // _this.toggleOptionsStyle($(el));\n });\n\n $attributes.on(\n \"click\",\n \"[data-prod-option]:not(.hidden) [data-attribute-value]\",\n function (event) {\n if ($(this).is(\"a\")) {\n event.preventDefault();\n }\n\n var $wrapperAttribute = $(this).closest(\"[data-prod-option]\");\n\n var selecao = $wrapperAttribute.data(\"selecao\");\n var selecaoStyle = $wrapperAttribute.data(\"selecao-style\");\n var attrName = $wrapperAttribute.data(\"attribute-name\");\n var value = $(this).data(\"attribute-value\");\n\n // console.info('selecao value', selecao, attrName, value);\n\n _this.setAttributeValue(value, $wrapperAttribute);\n _this.setAttributeValueSelected(value, $wrapperAttribute);\n\n _this.checkCombinations(value, attrName);\n _this.execActionAttr(attrName, value);\n\n _this.setResultVariants();\n }\n );\n\n if (_this.qtdAttributes == 0) {\n var variant = vnda.variants.all()[0];\n\n if (!variant.available) {\n _this.setProdutoIndisponivel(variant);\n } else {\n _this.setProdutoDisponivel(variant);\n }\n }\n\n _this.setConfigDefault();\n _this.setQtdAttributes();\n _this.setDisponibility();\n _this.markFirstOption();\n },\n};\n\n// function attr1Action(_valueSelected) {\n// var $attr1 = variants.config.$attr1;\n// var $attr2 = variants.config.$attr2;\n// var $attr3 = variants.config.$attr3;\n\n// //console.log($attr1.find('[data-attribute-value][data-available=true]').first());\n// //console.log($attr2.find('[data-attribute-value][data-available=true]').first());\n// //console.log($attr3.find('[data-attribute-value][data-available=true]').first());\n\n// if ($attr2.find('[data-attribute-value][data-available=true]:not(.disable)').first().length > 0) {\n// //console.log('THIS', $attr2.find('[data-attribute-value][data-available=true]:not(.disable)').first())\n// $attr2.find('[data-attribute-value][data-available=true]:not(.disable)').first().trigger('click');\n// } else if ($attr2.find('[data-attribute-value][data-available=true]').first().length > 0) {\n// $attr2.find('[data-attribute-value][data-available=true]').first().trigger('click');\n// } else {\n// $attr2.find('[data-attribute-value]').first().trigger('click');\n// }\n// }\n\nfunction attr2Action(_valueSelected) {\n var $attr1 = variants.config.$attr1;\n var $attr2 = variants.config.$attr2;\n var $attr3 = variants.config.$attr3;\n\n //console.log($attr1.find('[data-attribute-value][data-available=true]').first());\n //console.log($attr2.find('[data-attribute-value][data-available=true]').first());\n //console.log($attr3.find('[data-attribute-value][data-available=true]').first());\n\n if (\n $attr3\n .find(\"[data-attribute-value][data-available=true]:not(.disable)\")\n .first().length > 0\n ) {\n //console.log('THIS', $attr3.find('[data-attribute-value][data-available=true]:not(.disable)').first())\n $attr3\n .find(\"[data-attribute-value][data-available=true]:not(.disable)\")\n .first()\n .trigger(\"click\");\n } else if (\n $attr3.find(\"[data-attribute-value][data-available=true]\").first().length >\n 0\n ) {\n $attr3\n .find(\"[data-attribute-value][data-available=true]\")\n .first()\n .trigger(\"click\");\n } else {\n $attr3.find(\"[data-attribute-value]\").first().trigger(\"click\");\n }\n}\n\n// if (language == \"en\") {\n// $(\".add-to-cart-button\").text(\"SELECT SIZE\");\n// } else {\n// let dataText = $(\".add-to-cart-button\").data(\"text\");\n// if (dataText) {\n// $(\".add-to-cart-button\").text(dataText);\n// } else {\n// $(\".add-to-cart-button\").text(\"SELECIONE UM TAMANHO\");\n// }\n// }\n\n$(function () {\n if (page == \"product\") {\n window.variants.init();\n }\n});\n"],"names":[],"sourceRoot":""}