(function(){function a(d,l,h,k){var e=[];(function n(){if(!d){throw Error("No element supplied.");}if(!h){throw Error("No max rating supplied.");}if(!l){l=0;}if(l<0||l>h){throw Error("Current rating is out of bounds.");}for(var o=0;o<h;o++){var p=document.createElement("li");p.classList.add("c-rating__item");p.setAttribute("data-index",o);if(o<l){p.classList.add("is-active");}d.appendChild(p);e.push(p);m(p);}})();function g(q,r){for(var o=0;o<q.length;o++){var p=q[o];r(p,o);}}function m(o){f(o);i(o);c(o);}function f(o){o.addEventListener("mouseover",function(p){g(e,function(r,q){if(q<=parseInt(o.getAttribute("data-index"))){r.classList.add("is-active");}else{r.classList.remove("is-active");}});});}function i(o){o.addEventListener("mouseout",function(p){if(e.indexOf(p.relatedTarget)===-1){b(null,false);}});}function c(o){o.addEventListener("click",function(p){p.preventDefault();b(parseInt(o.getAttribute("data-index"))+1,true);});}function b(p,o){if(p&&p<0||p>h){return;}if(o===undefined){o=true;}l=p||l;g(e,function(r,q){if(q<l){r.classList.add("is-active");}else{r.classList.remove("is-active");}});if(k&&o){k(j());}}function j(){return l;}return{setRating:b,getRating:j};}window.rating=a;})();