!function(t,o){"function"==typeof define&&define.amd?define(["buoy"],o(t)):"object"==typeof exports?module.exports=o(require("buoy")):t.hullabaloo=o(t,t.buoy)}("undefined"!=typeof global?global:this.window||this.global,function(t){return function(t){var o=function(){this.hullabaloo={},this.hullabaloos=[],this.success=!1,this.options={ele:"body",offset:{from:"top",amount:75},align:"right",width:500,delay:5e3,allow_dismiss:!0,stackup_spacing:10,text:"Notification Message Here",icon:"times-circle",status:"danger",alertClass:"",fnStart:!1,fnEnd:!1,fnEndHide:!1}};return o.prototype.send=function(t,o){"function"==typeof this.options.fnStart&&this.options.fnStart();var e=this,s=1,l=+this.hullabaloos.length-1,a,i=this.generate(t,o);if(this.hullabaloos.length)for(;l>=0&&s;)this.hullabaloos[l].text==i.text&&this.hullabaloos[l].status==i.status&&(a=this.hullabaloos[l],s=0,i.elem.css("top",parseInt(a.elem.css("top"))+4),i.elem.css("right",parseInt(a.elem.css("right"))+4)),l--;i.posTop=parseInt(i.elem.css("top")),"object"==typeof a?(clearTimeout(a.timer),a.timer=setTimeout(function(){e.closed(a)},this.options.delay),a.hullabalooGroup.push(i)):(i.timer=setTimeout(function(){e.closed(i)},this.options.delay),this.hullabaloos.push(i)),i.elem.fadeIn(),"function"==typeof this.options.fnEnd&&this.options.fnEnd()},o.prototype.closed=function(t){var o=this,e,s,l,a;if(null!==this.hullabaloos){if(e=$.inArray(t,this.hullabaloos),"undefined"!==t.hullabalooGroup&&t.hullabalooGroup.length)for(s=0;s<t.hullabalooGroup.length;s++)$(t.hullabalooGroup[s].elem).alert("close");if($(this.hullabaloos[e].elem).alert("close"),-1!==e){if(this.hullabaloos.length>1)for(a=e+1,l=this.hullabaloos[a].posTop-this.hullabaloos[e].posTop,s=e;s<this.hullabaloos.length;s++)this.animate(o.hullabaloos[s],parseInt(o.hullabaloos[s].posTop)-l),o.hullabaloos[s].posTop=parseInt(o.hullabaloos[s].posTop)-l;this.hullabaloos.splice(e,1),"function"==typeof this.options.fnEndHide&&this.options.fnEndHide()}}},o.prototype.animate=function(t,o){function e(){if(l==o)clearInterval(s);else if(l--,t.elem.css("top",l),i)for(a=0;a<i;a++)t.hullabalooGroup[a].elem.css("top",l+5)}var s,l,a,i=0;l=parseInt(t.elem.css("top")),i=t.hullabalooGroup.length,s=setInterval(e,2)},o.prototype.generate=function(t,o){var e={icon:"",status:o||this.options.status,text:t||this.options.text,elem:$("<div>"),hullabalooGroup:[]},s,l,a;switch(s=this.options,e.elem.attr("class","hullabaloo alert "+s.alertClass),e.elem.addClass("alert-"+e.status),s.allow_dismiss&&(e.elem.addClass("alert-dismissible"),e.elem.append('<button  class="close" data-dismiss="alert" type="button" aria-label="Close"><span aria-hidden="true">&times;</span></button>')),"success"==e.status?e.icon="check":"info-circle"==e.status?e.icon="info":"danger"==this.hullabaloo.status?e.icon="times-circle":"warning"==this.hullabaloo.status?e.icon="exclamation-triangle":e.icon=s.icon,e.elem.append('<i class="fa fa-'+e.icon+'"></i> '+e.text),l=s.offset.amount,$(".hullabaloo").each(function(){return l=Math.max(l,parseInt($(this).css(s.offset.from))+$(this).outerHeight()+s.stackup_spacing)}),a={position:"body"===s.ele?"fixed":"absolute",margin:0,"z-index":"9999",display:"none"},a[s.offset.from]=l+"px",e.elem.css(a),"auto"!==s.width&&e.elem.css("width",s.width+"px"),$(s.ele).append(e.elem),s.align){case"center":e.elem.css({left:"50%","margin-left":"-"+e.elem.outerWidth()/2+"px"});break;case"left":e.elem.css("left","20px");break;default:e.elem.css("right","50px")}return e},o}(t)});