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

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

'+a.name+"

":'

'+a.name+"

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