var tdbFilters={};
(function(){tdbFilters={items:[],init:function(){tdbFilters.items=[]},item:function(){this.jqueryObj=this.blockAtts=this.blockUid=void 0;this._is_initialized=this.enabled_on_mobiles=this.inComposer=!1},_initialize_item:function(a){if(!0!==a._is_initialized){if(!0===a.enabled_on_mobiles){a.jqueryObj.closest(".vc_column_container").addClass("tdb-filters-mobile");a.jqueryObj.removeClass("tdb-filters-mobile-hide");jQuery("body").addClass("tdb-filters");var c=jQuery(".tdb-filters-button-mobile"),d=c.get(0);
d=jQuery._data(d,"events");if(void 0===d||void 0===d.click)c.on("click",function(){jQuery("body").toggleClass("tdb-filters-open")})}else a.jqueryObj.closest(".vc_column_container").removeClass("tdb-filters-mobile"),jQuery("body").removeClass("tdb-filters");!0!==a.inComposer&&(window.onpopstate=function(b){null!==b.state&&window.location.reload()},a.jqueryObj.on("click",".tdb-filters-clear-all",function(b){b.preventDefault();b.stopPropagation();b=new URLSearchParams(window.location.search);var a=window.location.href;
b.forEach(function(b,e){-1!==e.indexOf("tdb_")&&(a=tdbFilters.removeQueryParam(a,e))});window.history.pushState({},"",a);window.location.reload()}),a.jqueryObj.on("click",".tdb-filter-item",function(a){var b=jQuery(this),c=b.parents("ul").data("taxonomy"),d=b.data("term-slug");b.data("term-name");b.hasClass("selected")||b.hasClass("tdb-filter-link")?(b.hasClass("selected")&&b.hasClass("tdb-filter-link")&&a.preventDefault(),window.location.href=tdbFilters.removeQueryParamValue(window.location.href,
c,d)):-1!==c.indexOf("tdb_")?(a=tdbFilters.removeQueryParam(window.location.href,"tdb-loop-page"),window.location.href=tdbFilters.updateQuery(a,c,d)):console.log("invalid filter: "+c)}),a.jqueryObj.on("select2:select",".tdb-filter-item-dropdown",function(a){var b=jQuery(this),c=b.hasClass("multiple");b=b.data("taxonomy");var d=a.params.data,f="";"undefined"!==typeof d.element?(a=jQuery(d.element).data("term-slug"),f=jQuery(d.element).data("filter-link")):a=d.slug;-1!==b.indexOf("tdb_")?(d=tdbFilters.removeQueryParam(window.location.href,
"tdb-loop-page"),window.location.href=c||""===f?"undefined"!==typeof a?tdbFilters.updateQuery(d,b,a):d:f):console.log("invalid filter: "+b)}),a.jqueryObj.on("select2:unselect",".tdb-filter-item-dropdown",function(a){var b=jQuery(this).data("taxonomy");a=a.params.data;a="undefined"!==typeof a.element?jQuery(a.element).data("term-slug"):a.slug;if(-1!==b.indexOf("tdb_")){var c=tdbFilters.removeQueryParam(window.location.href,"tdb-loop-page");window.location.href=a?tdbFilters.removeQueryParamValue(c,
b,a):c}else console.log("invalid filter: "+b)}),jQuery(document).on("tdb_filters_remove_filter",function(b,c){b=c.term;a.jqueryObj.find('[data-taxonomy="'+c.tax+'"]').find("li[data-term-slug="+b+"]").removeClass("selected")}),a._is_initialized=!0)}},addItem:function(a){if("undefined"===typeof a.blockUid)throw"item.blockUid is not defined";tdbFilters.items.push(a);tdbFilters._initialize_item(a)},deleteItem:function(a){for(var c=0;c<tdbFilters.items.length;c++)if(tdbFilters.items[c].blockUid===a)return tdbFilters.items.splice(c,
1),!0;return!1},updateQuery:function(a,c,d){var b=new RegExp("([?&])"+c+"=.*?(&|$)","i"),e=-1!==a.indexOf("?")?"&":"?";return a.match(b)?(e=new URLSearchParams(window.location.search),a.replace(b,"$1"+c+"="+e.get(c)+","+d+"$2")):""===d?a:a+e+c+"="+d},removeQueryParam:function(a,c){return a.replace(new RegExp("([?&])"+c+"=.*?(&|$)","i"),"$1").replace(/[&|?]\s*$/,"")},removeQueryParamValue:function(a,c,d){var b=(new URLSearchParams(window.location.search)).get(c);b=b.replace(new RegExp("(,?)"+d,"i"),
"").replace(/^,/,"");return a=""===b?tdbFilters.removeQueryParam(a,c):a.replace(new RegExp("([?&])"+c+"=.*?(&|$)","i"),"$1"+c+"="+b+"$2")}}})();jQuery().ready(function(){tdbFilters.init();setTimeout(function(){jQuery(".tdb-filter-item-dropdown").each(function(){var a=jQuery(this),c=a.data("taxonomy");a.siblings(".select2").find(".select2-selection--multiple").attr("aria-label",c)})},100)});
