!function(r){var a="data-ab-parent",e="ab-color-found",t={selector:"[data-adaptive-background]",parent:null,exclude:["rgb(0,0,0)","rgb(255,255,255)"],shadeVariation:!1,shadePercentage:0,shadeColors:{light:"rgb(255,255,255)",dark:"rgb(0,0,0)"},normalizeTextColor:!1,normalizedTextColors:{light:"#fff",dark:"#000"},lumaClasses:{light:"ab-light",dark:"ab-dark"},transparent:null};function n(r,a){var e=r.split(","),t=a<0?0:255,n=a<0?-1*a:a,o=parseInt(e[0].slice(4)),s=parseInt(e[1]),c=parseInt(e[2]);return"rgb("+(Math.round((t-o)*n)+o)+","+(Math.round((t-s)*n)+s)+","+(Math.round((t-c)*n)+c)+")"}function o(r,a,e){var t=r.split(","),n=a.split(","),o=parseInt(t[0].slice(4)),s=parseInt(t[1]),c=parseInt(t[2]);return"rgb("+(Math.round((parseInt(n[0].slice(4))-o)*e)+o)+","+(Math.round((parseInt(n[1])-s)*e)+s)+","+(Math.round((parseInt(n[2])-c)*e)+c)+")"}!function(r,a){"use strict";var e=function(r,a){var e=new Image,t=r.src||r;"data:"!==t.substring(0,5)&&(e.crossOrigin="Anonymous"),e.onload=function(){var r=function(r,a){var e=document.createElement("canvas");return e.setAttribute("width",r),e.setAttribute("height",a),e.getContext("2d")}(e.width,e.height);r.drawImage(e,0,0);var t=r.getImageData(0,0,e.width,e.height);a&&a(t.data)},e.src=t},t=function(r){return["rgb(",r,")"].join("")},n=function(r){var a=[];for(var e in r)a.push(s(e,r[e]));return a.sort((function(r,a){return a.count-r.count})),a},o=function(r,a){if(r.length>a)return r.slice(0,a);for(var e=r.length-1;a-1>e;e++)r.push(s("0,0,0",0));return r},s=function(r,a){return{name:t(r),count:a}},c={colors:function(r,a){var s=(a=a||{}).exclude||[],c=a.paletteSize||10;e(r,(function(r){for(var e={},i="",u=[],l=0;l<r.length;l+=4)u[0]=r[l],u[1]=r[l+1],u[2]=r[l+2],i=u.join(","),-1===u.indexOf(undefined)&&0!==r[l+3]&&-1===s.indexOf(t(i))&&(e[i]=i in e?e[i]+1:1);if(a.success){var d=o(n(e),c+1);a.success({dominant:d[0].name,secondary:d[1].name,palette:d.map((function(r){return r.name})).slice(1)})}}))}};r.RGBaster=r.RGBaster||c}(window),r.adaptiveBackground={run:function(s){var c=r.extend({},t,s);r(c.selector).each((function(t,s){var i=r(this),u=function(r){var a=r.match(/\d+/g);return(299*a[0]+587*a[1]+114*a[2])/1e3},l=function(){var r=i.attr("data-ab-css-background");return void 0!==r&&!1!==r},d=function(){var r=i.css("background-image");return/\(([^)]+)\)/.exec(r)[1].replace(/"/g,"")};i.on(e,(function(e,t){var s,d;if(s=c.parent&&i.parents(c.parent).length?i.parents(c.parent):i.attr(a)&&i.parents(i.attr(a)).length?i.parents(i.attr(a)):l()?i:c.parent?i.parents(c.parent):i.parent(),c.shadeVariation&&(t.color=(d=t.color,1==c.shadeVariation?u(d)<=128?n(d,c.shadePercentage):n(d,-c.shadePercentage,c.shadePercentage):"blend"==c.shadeVariation?u(d)>=128?o(d,c.shadeColors.dark,c.shadePercentage):o(d,c.shadeColors.light,c.shadePercentage):void 0)),r.isNumeric(c.transparent)&&null!=c.transparent&&c.transparent>=.01&&c.transparent<=.99){var g=t.color.replace("rgb","rgba").replace(")",", "+c.transparent+")");s.css({backgroundColor:g})}else s.css({backgroundColor:t.color});c.normalizeTextColor&&s.css({color:function(r){return u(r)>=128?c.normalizedTextColors.dark:c.normalizedTextColors.light}(t.color)}),s.addClass(function(r){return u(r)<=128?c.lumaClasses.dark:c.lumaClasses.light}(t.color)).attr("data-ab-yaq",u(t.color)),c.success&&c.success(i,t)})),function(){if("PICTURE"==i[0].tagName){var r=i[0].children;for(var a in r)if("IMG"==r[a].tagName){var t=r[a];break}t.currentSrc&&(t=t.currentSrc)}else t=l()?d():i[0];RGBaster.colors(t,{paletteSize:20,exclude:c.exclude,success:function(r){i.attr("data-ab-color",r.dominant),i.trigger(e,{color:r.dominant,palette:r.palette})}})}()}))}}}(jQuery);