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