!function(){"use strict";window.kadenceShop={createCookie:function(e,t,o,i){if(o){var a=new Date;"minutes"==i?a.setTime(a.getTime()+60*o*1e3):"hours"==i?a.setTime(a.getTime()+60*o*60*1e3):a.setTime(a.getTime()+24*o*60*60*1e3);var c="; expires="+a.toGMTString()}else c="";document.cookie=kadenceShopConfig.siteSlug+"-"+e+"="+t+c+"; path=/"},getCookie:function(e){var t=("; "+document.cookie).split("; "+kadenceShopConfig.siteSlug+"-"+e+"=");if(2==t.length)return t.pop().split(";").shift()},initShopToggle:function(){if(document.body.classList.contains("woocommerce")||document.body.classList.contains("archive")){var e=document.querySelectorAll(".kadence-toggle-shop-layout");if(e.length){var t=window.kadenceShop.getCookie("shopLayout");if(t&&("grid"===t||"list"===t)){var o=document.querySelector(".kadence-toggle-"+t);window.kadenceShop.toggleShop(o)}for(let t=0;t<e.length;t++)e[t].addEventListener("click",(function(o){o.preventDefault(),window.kadenceShop.toggleShop(e[t])}))}}},toggleShop:function(e){if(e.classList.contains("toggle-active")||(e.classList.add("toggle-active"),window.kadenceShop.createCookie("shopLayout",e.dataset.archiveToggle,30,"days")),"grid"===e.dataset.archiveToggle)var t=document.querySelector(".kadence-toggle-list");else t=document.querySelector(".kadence-toggle-grid");if(t.classList.remove("toggle-active"),"grid"===e.dataset.archiveToggle)var o=document.querySelector(".woo-archive-loop.products-list-view");else o=document.querySelector(".woo-archive-loop.products-grid-view");o||(o=document.querySelector(".woo-archive-loop")),o.classList.remove("products-list-view"),o.classList.remove("products-grid-view"),o.classList.add("products-"+e.dataset.archiveToggle+"-view")},initShopCatToggle:function(){var e=document.querySelectorAll(".widget_product_categories");if(e.length)for(let i=0;i<e.length;i++){var t=e[i].querySelectorAll(".cat-parent");if(t.length)for(let e=0;e<t.length;e++){var o=document.createElement("button");o.setAttribute("aria-label",kadenceConfig.screenReader.expand),o.classList.add("kadence-cat-toggle-sub"),(t[e].classList.contains("current-cat")||t[e].classList.contains("current-cat-parent"))&&(o.classList.add("toggle-active"),o.setAttribute("aria-label",kadenceConfig.screenReader.collapse),t[e].classList.add("sub-toggle-active")),t[e].appendChild(o),o.addEventListener("click",(function(e){e.preventDefault(),window.kadenceShop.toggleCatShop(e)}))}}},toggleCatShop:function(e){var t=e.srcElement;t.classList.contains("toggle-active")?t.classList.remove("toggle-active"):t.classList.add("toggle-active"),t.parentNode.classList.contains("sub-toggle-active")?t.parentNode.classList.remove("sub-toggle-active"):t.parentNode.classList.add("sub-toggle-active")},init:function(){window.kadenceShop.initShopToggle(),window.kadenceShop.initShopCatToggle()}},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",window.kadenceShop.init):window.kadenceShop.init()}();