!function(e){"use strict";var t=function(){var e=this;this.opened=[],this.excludes=[],this.init=function(){this._setWidgets()&&(this.firstOpen="except_first"===reyParams.js_params.sidebar_toggle__status,this._setExcludes(),this.prepare(),this.events())},this.prepare=function(){this.widgets.forEach((t=>{var i,s=t.getAttribute("id"),r=t.querySelector(".rey-toggleWidget");s&&-1!==e.excludes.indexOf("#"+s)&&(i=!0),s&&-1!==e.opened.indexOf(s)&&(i=!0),e.firstOpen&&rey.validation.matches(t,":first-child")&&(i=!0),t.querySelector("li.chosen")&&(i=!0),i&&r&&r.classList.add("--active")}))},this.events=function(){rey.elements.body.addEventListener("click",(function(t){var i=t.target.closest(".rey-toggleWidget");if(i){t.preventDefault();var s=i.closest(".widget");if(s){var r,n=s.getAttribute("id");i.classList.contains("--active")?(r=!1,i.classList.remove("--active"),e.opened=e.opened.filter((function(e){return e!==n}))):(r=!0,i.classList.add("--active"),e.opened.push(n)),rey.hooks.doAction("sidebars/toggle_widget",i,s,r)}}})),rey.hooks.addAction("ajaxfilters/finished",(function(){e._setWidgets()&&e.prepare()}))},this._setWidgets=function(){return this.widgets=document.querySelectorAll(".rey-toggleWidget-wrapper"),this.widgets.length},this._setExcludes=function(){var e=reyParams.js_params.sidebar_toggle__exclude;e&&(this.excludes=e.trim().replace(/\s/g,"").split(",").filter((function(e){return""!==e&&" "!==e&&"#"===e.charAt(0)})))},this.init()};document.addEventListener("rey-DOMContentLoaded",(function(e){new t}))}(jQuery);