(function(e,t,n,o){e.fn.chat=function(t,n,i){var a=e.extend(!0,{},e.fn.chat.settings,i),r=arguments||!1;return e(this).each(function(){var i,s,c,l,u,d,m=e(this),f=m.find(a.selector.expandButton),p=m.find(a.selector.userListButton),g=m.find(a.selector.userList),v=(m.find(a.selector.room),m.find(a.selector.userCount)),h=m.find(a.selector.log),b=(m.find(a.selector.message),m.find(a.selector.messageInput)),y=m.find(a.selector.messageButton),x=m.data("module"),C=a.className,w=a.namespace,T="",k={};return d={channel:!1,width:{log:h.width(),userList:g.outerWidth()},initialize:function(){return Pusher===o&&d.error(a.errors.pusher),t===o||n===o?(d.error(a.errors.key),!1):a.endpoint.message||a.endpoint.authentication?(u=new Pusher(t),Pusher.channel_auth_endpoint=a.endpoint.authentication,d.channel=u.subscribe(n),d.channel.bind("pusher:subscription_succeeded",d.user.list.create),d.channel.bind("pusher:subscription_error",d.error),d.channel.bind("pusher:member_added",d.user.joined),d.channel.bind("pusher:member_removed",d.user.left),d.channel.bind("update_messages",d.message.receive),e.each(a.customEvents,function(e,t){d.channel.bind(e,t)}),e.fn.hoverClass!==o&&e.fn.downClass!==o&&(f.hoverClass().downClass(),p.hoverClass().downClass(),y.hoverClass().downClass()),p.on("click."+w,d.event.toggleUserList),f.on("click."+w,d.event.toggleExpand),b.on("keydown."+w,d.event.input.keydown).on("keyup."+w,d.event.input.keyup),y.on("mouseenter."+w,d.event.hover).on("mouseleave."+w,d.event.hover).on("click."+w,d.event.submit),h.animate({scrollTop:h.prop("scrollHeight")},400),m.data("module",d).addClass(C.loading),o):(d.error(a.errors.endpoint),!1)},refresh:function(){p.removeClass(C.active),d.width={log:h.width(),userList:g.outerWidth()},p.hasClass(C.active)&&d.user.list.hide(),m.data("module",d)},user:{updateCount:function(){a.userCount&&(k=m.data("users"),c=0,e.each(k,function(){c++}),v.html(a.templates.userCount(c)))},joined:function(t){k=m.data("users"),"anonymous"!=t.id&&k[t.id]===o&&(k[t.id]=t.info,a.randomColor&&t.info.color===o&&(t.info.color=a.templates.color(t.id)),T=a.templates.userList(t.info),t.info.isAdmin?e(T).prependTo(g).preview({type:"user",placement:"left"}):e(T).appendTo(g).preview({type:"user",placement:"left"}),e.fn.preview!==o&&g.children().last().preview({type:"user",placement:"left"}),a.partingMessages&&(h.append(a.templates.joined(t.info)),d.message.scroll.test()),d.user.updateCount())},left:function(e){k=m.data("users"),e!==o&&"anonymous"!==e.id&&(delete k[e.id],m.data("users",k),g.find("[data-id="+e.id+"]").remove(),a.partingMessages&&(h.append(a.templates.left(e.info)),d.message.scroll.test()),d.user.updateCount())},list:{create:function(t){k={},t.each(function(e){"anonymous"!==e.id&&"undefined"!==e.id&&(a.randomColor&&e.info.color===o&&(e.info.color=a.templates.color(e.id)),T=e.info.isAdmin?a.templates.userList(e.info)+T:T+a.templates.userList(e.info),k[e.id]=e.info)}),m.data("users",k).data("user",k[t.me.id]).removeClass(C.loading),g.html(T),e.fn.preview!==o&&g.children().preview({type:"user",placement:"left"}),d.user.updateCount(),e.proxy(a.onJoin,g.children())()},show:function(){h.animate({width:d.width.log-d.width.userList},{duration:a.speed,easing:a.easing,complete:d.message.scroll.move})},hide:function(){h.stop().animate({width:d.width.log},{duration:a.speed,easing:a.easing,complete:d.message.scroll.move})}}},message:{scroll:{test:function(){l=h.prop("scrollHeight")-h.height(),Math.abs(h.scrollTop()-l)'+e.user.name+": ":''+e.user.name+": ",t+=""+e.text+"

"+""},joined:function(e){return typeof e.name!==o?'
'+e.name+" has joined the chat.
":!1},left:function(e){return typeof e.name!==o?'
'+e.name+" has left the chat.
":!1},userList:function(e){var t="";return e.isAdmin&&(e.color="#55356A"),t+='
'+'
'+' '+"
",t+=e.color!==o?'

'+e.name+"

":'

'+e.name+"

",t+="
"}}}})(jQuery,window,document);