!function(e){"use strict";Drupal.behaviors.shadePickerV1={isCustomPalette:e(".page--spp__custom_palette").length>0,initShadeTools:function(s){var i=this,t=s.find(".shade-picker__tools"),a=t.find(".shade-picker__tools-sort-toggle"),d=t.find(".shade-picker__tools-sort-items");a.once().click((function(){var s=e(this);d.hasClass("hidden")?(d.hide().removeClass("hidden").slideDown(300),s.addClass("active")):d.slideUp(300,(function(){d.addClass("hidden"),s.removeClass("active")}))}));var o=t.find(".shade-picker__tools-filters-toggle"),n=t.find(".shade-picker__tools-filters-clear"),l=t.find(".shade-picker__tools-filters"),c=l.find(".shade-picker__tools-title"),r=l.find(".shade-picker__tools-filters-items"),h=r.find("a"),f=i.isCustomPalette?e('.shade-picker__colors-insert[data-insert="'+t.data("insert")+'"]').find(".shade-picker__colors-item"):e(".content .site-container .js-shade-picker--v1").find(".shade-picker__color");o.once().click((function(){l.hasClass("hidden")?(o.addClass("active"),r.addClass("hidden"),l.hide().removeClass("hidden").slideDown(300)):(o.removeClass("active"),c.removeClass("active"),l.show().slideUp(300),setTimeout((function(){l.addClass("hidden")}),300))})),c.once().click((function(){var s=e(this),i=s.siblings(".shade-picker__tools-filters-items");i.hasClass("hidden")?(e(this).addClass("active"),i.hide().removeClass("hidden").slideDown(300),r.not(i).slideUp(300,(function(){r.not(i).addClass("hidden"),c.not(s).removeClass("active")}))):r.slideUp(300,(function(){e(this).addClass("hidden"),c.removeClass("active")}))}));var v=[];f.each((function(){var s=e(this).data("filters"),t=i.isCustomPalette?e(this).find(".shade-picker__color").data("product"):e(this).data("product"),a=e.extend({},t,s);v.push(a)}));var p=[];h.each((function(){var s=e(this).data("filter");_.isObject(s)&&p.push(s)}));var u=[];h.once().click((function(){var s=e(this),t=e(this).parents(".shade-picker__tools-filter").find(".shade-picker__tools-title--count"),a=s.data("facet"),d=0;if(1===r.find(".active").length&&s.hasClass("active"))s.removeClass("active"),t.html(""),n.addClass("hidden"),o.removeClass("hidden"),f.removeClass("hidden");else{s.toggleClass("active"),n.removeClass("hidden"),o.addClass("hidden");var l=r.find(".active"),c=[];l.each((function(){var s=e(this).data("filter");c.push(s)})),u=[],e(c).each((function(){var s=e(this)[0],i=_.keys(s);_.filter(v,(function(e){e[i].toUpperCase().replace(" ","-")===s[i].toUpperCase()&&(u.push(e),a==i[0]&&d++)}))})),n.hide().removeClass("hidden").slideDown(300),t.html(0!=d?"("+d+")":""),i.filterShades(f,u)}return!1})),n.once().click((function(){o.removeClass("hidden"),c.removeClass("active"),n.addClass("hidden"),l.slideUp(300,(function(){l.addClass("hidden"),e(".shade-picker__tools-title--count").html("")})),h.removeClass("active"),f.removeClass("hidden")}))},filterShades:function(s,i){s.addClass("hidden"),e(i).each((function(){var i=e(this)[0];s.each((function(){var s=self.isCustomPalette?e(this).find(".shade-picker__color"):e(this);s.data("product").SKU_BASE_ID===i.SKU_BASE_ID&&(self.isCustomPalette?s.parents(".shade-picker__colors-item").removeClass("hidden"):s.removeClass("hidden"))}))}))},attach:function(s,i){var t=e(".js-shade-picker--v1",s);this.initShadeTools(t);var a=function(e){var s=e.siblings(".shade-picker__color-texture");if(s.length){var i=s.data("bg-image");i&&i.length>0&&s.css("background-image","url("+i+")")}};e(".shade-picker__color-chip",t).once("shade-picker__color-chip").hover((function(){a(e(this))}),(function(){})).first().map((function(){a(e(this))}))}}}(jQuery); //# sourceMappingURL=shade_picker_v1.js.map