!function(e,t){"use strict";"function"==typeof define&&define.amd?define([],function(){return e.colorify=t()}):"object"==typeof exports?module.exports=t():e.colorify=t()}(this,function(){"use strict";var e=function(e){var t=(e.id||1,e.container||"colorify"),r=e.images||!1,a=e.accuracy||100,n=e.lazyReveal||!1,o=e.gradient||!1,i=e.gradientDirection||"to bottom right",l=e.padding||4,c=e.give||!1,s=e.revealOn||!1;if(0==!n)var d=e.lazyReveal.transition||0,g=e.lazyReveal.delay||0,u=e.lazyReveal.steps||!1;if(0==!s)var y=e.revealOn.event||!1,v=e.revealOn.trigger||!1;if(0==!c)var f=e.give.property||!1,b=e.give.target||!1;for(var m=document.querySelectorAll("["+t+"]"),p=0,h=m.length;h>p;p++)var A=e.attr||t+"-"+p;if(0==!r)for(var p=0,h=r.length;h>p;p++)for(var p=([r[p]],0);h>p;p++){var L=document.createElement("img");L.setAttribute(A,""),L.crossOrigin="Anonymous",L.src=r[p];var q=document.createElement("div");q.classList.add("image-container"),q.setAttribute("style","padding: "+l+"px;"),0==!s&&(q.style.opacity="0",q.classList.add("to-reveal")),q.appendChild(L),document.querySelector("["+t+"]").appendChild(q)}for(var E=document.querySelectorAll("["+t+"] img"),p=0,h=E.length;h>p;p++)E[p].setAttribute(A,""),E[p].classList.add("colorify");for(var S=document.querySelectorAll("["+A+"]"),C=S.length,x=0,p=0,h=S.length;h>p;p++){S[p].setAttribute(A,""),S.crossOrigin="Anonymous",S.src=S[p];var q=document.createElement("div");q.classList.add("image-container"),q.setAttribute("style","padding: "+l+"px;"),0==!s&&(q.style.opacity="0",q.classList.add("to-reveal")),q.appendChild(S[p]);var I=document.querySelector("["+t+"]");I.appendChild(q)}if(0==!s){var N=document.querySelectorAll(".to-reveal");document.querySelector(v).addEventListener(y,function(){for(var e=0,t=N.length;t>e;e++)N[e].style.opacity="1"})}setTimeout(function(){function e(e,t){var a=r(e);if(o){var n="rgb("+a[0].r+","+a[0].g+","+a[0].b+"), rgb("+a[1].r+","+a[1].g+","+a[1].b+")";e.parentNode.style.backgroundImage="linear-gradient("+i+","+n+") "}else e.parentNode.style.backgroundColor="rgb("+a[0].r+","+a[0].g+","+a[0].b+")";if(0==!c){var l=b.substring(0,1);if("#"==l||"."==l||"*"==l||"["==l)for(var s=document.querySelectorAll(b),y=0,v=s.length;v>y;y++)s[y].setAttribute("style",f+": rgb("+a[0].r+","+a[0].g+","+a[0].b+")");"parent"==b&&e.parentNode.parentNode.setAttribute("style",f+": rgb("+a[0].r+","+a[0].g+","+a[0].b+") !important"),"child"==b&&e.childNode.setAttribute("style",f+": rgb("+a[0].r+","+a[0].g+","+a[0].b+") !important")}(0==!d&&0==!g||0==!d||0==!g)&&(1==u?e.setAttribute("style","transition: all "+d+"s ease "+g*t+"s;"):e.setAttribute("style","transition: all "+d+"s ease "+g+"s;")),e.classList.add("visible","all-not-loaded"),x>=C&&(e.classList.remove("all-not-loaded"),e.classList.add("all-loaded"))}function t(e,t){var r={r:0,g:0,b:0},a=e.data.length,n=0,o=-4;t=t||{},t.accuracy=t.accuracy||1;for(var i=t.accuracy;(o+=4*i)p;p++)x++,S[p].onload=e(S[p],x)})};return e});