define(["components/chat/module"],function(a){"use strict";a.registerFactory("ChatApi",["$q","$rootScope","User","$http",function(a,b,c,d){var e,f=a.defer(),g={initialized:f.promise,users:[],messages:[],statuses:["Online","Busy","Away","Log Off"],status:"Online",setUser:function(a){-1!=g.users.indexOf(e)&&g.users.splice(g.users.indexOf(e),1),e=a,g.users.push(e)},sendMessage:function(a){var b={user:e,body:a,date:new Date};this.messages.push(b)}};return d.get("api/chat.json").then(function(a){g.messages=a.data.messages,g.users=a.data.users,f.resolve()}),g.initialized.then(function(){c.initialized.then(function(){g.setUser({username:c.username,picture:c.picture,status:g.status})}),b.$watch(function(){return c.username},function(a,b){a!=b&&g.setUser({username:c.username,picture:c.picture,status:g.status})})}),g}])});