!function(){"use strict";function t(t,e){if(!t||""===t)return console.error("addAsset: caminho não definido.");if(t.includes(".js")){const r=document.createElement("script");return r.setAttribute("src",t),e&&"function"==typeof e&&(r.onload=e),document.body.appendChild(r)}if(t.includes(".css")){const e=document.createElement("link");return e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),e.setAttribute("href",t),document.head.appendChild(e)}{const e="addAsset: Erro ao criar o asset. Tipo de script não definido, ou não possui tratamento para este tipo de asset.";return console.error(e,t)}}const e={root:document.querySelector("#component-products-filter-root"),mobileButton:document.querySelector("#open-filter-mobile"),settings:window.filterSettings||!1,showPriceSlider:!1,instance:!1,sortArrayValues:function(t,e){let r=t.sort(((t,r)=>t[e]r[e]?1:0));const s=["pp","p","m","g","gg","xg","xgg"];return r.forEach((t=>{t.sort=99,s.forEach(((r,s)=>{t[e].toLowerCase()===r&&(t.sort=s)}))})),r.sort(((t,e)=>t.sorte.sort?1:0))},setTagTypes:function(){const{settings:t}=e,r=[];if(t.aggregations){const s=t.aggregations;s.types.categoria&&r.push({title:"Categoria",type:"categoria",style:"list",options:e.sortArrayValues(s.types.categoria,"title")})}return r},setPropeties:function(){const{settings:t}=e,r=[];if(t.aggregations){const s=t.aggregations;s.properties.property1.length>0&&r.push({title:"Cor",property:"property1",style:"colors",colorsProps:{showTitle:!0,showColor:!0},options:e.sortArrayValues(s.properties.property1,"value"),patterns:t.patterns}),s.properties.property2.length>0&&r.push({title:"Tamanho",property:"property2",style:"grid",options:e.sortArrayValues(s.properties.property2,"value"),patterns:t.patterns}),s.properties.property3.length>0&&r.push({title:"Fragrância",property:"property3",style:"list",options:e.sortArrayValues(s.properties.property3,"value"),patterns:t.patterns})}return r},setPricesRanges:function(){const{settings:t,showPriceSlider:r}=e;let s={price:!1,priceProps:!1};return r&&(s.price=[t.aggregations.min_price,t.aggregations.max_price]),t.prices_range.length>0&&(s.priceProps={mode:"options",options:t.prices_range},s.price=[t.aggregations.min_price,t.aggregations.max_price]),s},setFilters:function(){const{root:t}=e,r=e.setTagTypes(),s=e.setPropeties(),o=e.setPricesRanges(),n=window.innerWidth<=1024?"drawer":"vertical",i=new Vnda.Component.ProductsFilter({mode:n,hasSort:!0,filterOnClick:!1,resetMode:"all",tags:r,properties:s,price:o.price,priceProps:o.priceProps});i.render(t),e.instance=i,t.dispatchEvent(new Event("vnda:filter-component-loaded"))},loadFilters:function(){const{settings:r}=e;r&&(t(r.script,e.setFilters),t(r.styles))},show:function(){const{root:t}=e;e.instance?e.instance.toggle():(e.loadFilters(),t.addEventListener("vnda:filter-component-loaded",(()=>{e.instance.toggle()})))},init:function(){const{root:t,mobileButton:r}=e;t&&(window.innerWidth<=1024?r&&r.addEventListener("click",(()=>{e.show()})):e.loadFilters())}},r={params:window._pagination,priceProds:{selector:"[data-update-price]",attr:"update-price"},productsWrapper:document.querySelectorAll(".section-list-products")[0],productWrapper:document.querySelectorAll(".list-products")[0],button:document.querySelector("[data-load-more]"),stopLoading:function(){const t=this.button;null!=t&&t.parentElement.removeChild(t)},setCurrentPage:function(t){const e=this.params.totalPages;if(t<=e&&(this.params.currentPage=t,this.params.currentPage>=e&&this.stopLoading(),t0&&n.forEach((t=>{r.setScript(t)})),o.querySelectorAll(".product-block")},updatePrice:function(){window.Vnda.Component.Price.update()},getNextPage:async function(){const t=this.params.currentPage,e=this.productsWrapper,r=this.productWrapper;if(!e.classList.contains("-searching")){this.productsWrapper.classList.add("-searching"),this.button.classList.add("-searching");(await this.loadProducts()).forEach((t=>{r.appendChild(t)})),this.setCurrentPage(t+1),window.ProductPurchase.init(!0),lazyLoadInstance.update(),this.updatePrice(),e.classList.remove("-searching"),this.button.classList.remove("-searching")}},init:function(){const t=this.button;null!=typeof this.params&&null!=t&&t.addEventListener("click",(()=>{this.getNextPage()}),{passive:!0})}};var s=r;const o=function(){e.init(),function(){const t=document.querySelectorAll("[data-init-price]");null!=t&&t.forEach((t=>{const e=t.dataset.discountPercent;t.dispatchEvent(new Event("change")),"0"!=e&&t.style.setProperty("--discount",`'-${e}%'`)}))}(),s.init()};window.addEventListener("DOMContentLoaded",(()=>{o()}))}(); //# sourceMappingURL=tag.js.map