if(t&&e.hasAttribute&&e.hasAttribute(t)){do{if(!e)throwji("uterdir","Unterminated attribute, found '{0}' but no matching '{1}' found.",t,n);1==e.nodeType&&(e.hasAttribute(t)&&r++,e.hasAttribute(n)&&r--),i.push(e),e=e.nextSibling}while(r>0)}elsei.push(e);returnpi(i)}functionN(e,t,n){returnfunction(i,r,o,a,s){returnr=P(r[0],t,n),e(i,r,o,a,s)}}functionU(e,r,a,s,l,u,p,d,f){functionh(e,t,n,i){e&&(n&&(e=N(e,n,i)),e.require=$.require,(F===$||$.$$isolateScope)&&(e=Y(e,{isolateScope:!0})),p.push(e)),t&&(n&&(t=N(t,n,i)),t.require=$.require,(F===$||$.$$isolateScope)&&(t=Y(t,{isolateScope:!0})),d.push(t))}functiong(e,t,n){vari,r="data",a=!1;if(b(e)){for(;"^"==(i=e.charAt(0))||"?"==i;)e=e.substr(1),"^"==i&&(r="inheritedData"),a=a||"?"==i;if(i=null,n&&"data"===r&&(i=n[e]),i=i||t[r]("$"+e+"Controller"),!i&&!a)throwji("ctreq","Controller '{0}', required by directive '{1}', can't be found!",e,M);returni}returnS(e)&&(i=[],o(e,function(e){i.push(g(e,t,n))})),i}functionm(e,t,s,l,u){functionf(e,t){vari;returnarguments.length<2&&(t=e,e=n),K&&(i=M),u(e,t,i)}varh,m,_,b,w,$,S,C,M={};if(h=r===s?a:L(a,newQ(pi(s),a.$attr)),m=h.$$element,F){vark=/^\s*([@=&])(\??)\s*(\w*)\s*$/,x=pi(s);S=t.$new(!0),q&&q===F.$$originalDirective?x.data("$isolateScope",S):x.data("$isolateScopeNoTemplate",S),E(x,"ng-isolate-scope"),o(F.scope,function(e,n){varr,o,a,s,c=e.match(k)||[],l=c[3]||n,u="?"==c[2],p=c[1];switch(S.$$isolateBindings[n]=p+l,p){case"@":h.$observe(l,function(e){S[n]=e}),h.$$observers[l].$$scope=t,h[l]&&(S[n]=i(h[l])(t));break;case"=":if(u&&!h[l])return;o=y(h[l]),s=o.literal?B:function(e,t){returne===t},a=o.assign||function(){throwr=S[n]=o(t),ji("nonassign","Expression '{0}' used with directive '{1}' is non-assignable!",h[l],F.name)},r=S[n]=o(t),S.$watch(function(){vare=o(t);returns(e,S[n])||(s(e,r)?a(t,e=S[n]):S[n]=e),r=e},null,o.literal);break;case"&":o=y(h[l]),S[n]=function(e){returno(t,e)};break;default:throwji("iscp","Invalid isolate scope definition for directive '{0}'. Definition: {... {1}: '{2}' ...}",F.name,n,e)}})}for(C=u&&f,U&&o(U,function(e){varn,i={$scope:e===F||e.$$isolateScope?S:t,$element:m,$attrs:h,$transclude:C};$=e.controller,"@"==$&&($=h[e.name]),n=v($,i),M[e.name]=n,K||m.data("$"+e.name+"Controller",n),e.controllerAs&&(i.$scope[e.controllerAs]=n)}),_=0,b=p.length;b>_;_++)try{w=p[_],w(w.isolateScope?S:t,m,h,w.require&&g(w.require,m,M),C)}catch(T){c(T,V(m))}varA=t;for(F&&(F.template||null===F.templateUrl)&&(A=S),e&&e(A,s.childNodes,n,u),_=d.length-1;_>=0;_--)try{w=d[_],w(w.isolateScope?S:t,m,h,w.require&&g(w.require,m,M),C)}catch(T){c(T,V(m))}}f=f||{};for(varw,$,M,k,x,A,I=-Number.MAX_VALUE,U=f.controllerDirectives,F=f.newIsolateScopeDirective,q=f.templateDirective,z=f.nonTlbTranscludeDirective,G=!1,K=!1,Z=a.$$element=pi(r),J=u,et=s,tt=0,nt=e.length;nt>tt;tt++){$=e[tt];varrt=$.$$start,ot=$.$$end;if(rt&&(Z=P(r,rt,ot)),k=n,I>$.priority)break;if((A=$.scope)&&(w=w||$,$.templateUrl||(W("new/isolated scope",F,$,Z),_(A)&&(F=$))),M=$.name,!$.templateUrl&&$.controller&&(A=$.controller,U=U||{},W("'"+M+"' controller",U[M],$,Z),U[M]=$),(A=$.transclude)&&(G=!0,$.$$tlb||(W("transclusion",z,$,Z),z=$),"element"==A?(K=!0,I=$.priority,k=P(r,rt,ot),Z=a.$$element=pi(t.createComment(" "+M+": "+a[M]+" ")),r=Z[0],X(l,pi(R(k)),r),et=T(k,s,I,J&&J.name,{nonTlbTranscludeDirective:z})):(k=pi(dt(r)).contents(),Z.empty(),et=T(k,s))),$.template)if(W("template",q,$,Z),q=$,A=C($.template)?$.template(Z,a):$.template,A=it(A),$.replace){if(J=$,k=pi("<div>"+wi(A)+"</div>").contents(),r=k[0],1!=k.length||1!==r.nodeType)throwji("tplrt","Template for directive '{0}' must have exactly one root element. {1}",M,"");X(l,Z,r);varat={$attr:{}},st=D(r,[],at),ct=e.splice(tt+1,e.length-(tt+1));F&&O(st),e=e.concat(st).concat(ct),j(a,at),nt=e.length}elseZ.html(A);if($.templateUrl)W("template",q,$,Z),q=$,$.replace&&(J=$),m=H(e.splice(tt,e.length-tt),Z,a,l,et,p,d,{controllerDirectives:U,newIsolateScopeDirective:F,templateDirective:q,nonTlbTranscludeDirective:z}),nt=e.length;elseif($.compile)try{x=$.compile(Z,a,et),C(x)?h(null,x,rt,ot):x&&h(x.pre,x.post,
}returnc}};vary=newu;returny}]}functionMn(){vare=/^\s*(https?|ftp|mailto|tel|file):/,t=/^\s*(https?|ftp|file):|data:image\//;this.aHrefSanitizationWhitelist=function(t){returnv(t)?(e=t,this):e},this.imgSrcSanitizationWhitelist=function(e){returnv(e)?(t=e,this):t},this.$get=function(){returnfunction(n,i){varr,o=i?t:e;returnui&&!(ui>=8)||(r=Pn(n).href,""===r||r.match(o))?n:"unsafe:"+r}}}functionkn(e){returne.replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g,"\\$1").replace(/\x08/g,"\\x08")}functionxn(e){if("self"===e)returne;if(b(e)){if(e.indexOf("***")>-1)thrownr("iwcard","Illegal sequence *** in string matcher. String: {0}",e);returne=kn(e).replace("\\*\\*",".*").replace("\\*","[^:/.?&;]*"),newRegExp("^"+e+"$")}if(M(e))returnnewRegExp("^"+e.source+"$");thrownr("imatcher",'Matchers may only be "self", string patterns or RegExp objects')}functionTn(e){vart=[];returnv(e)&&o(e,function(e){t.push(xn(e))}),t}functionEn(){this.SCE_CONTEXTS=ir;vare=["self"],t=[];this.resourceUrlWhitelist=function(t){returnarguments.length&&(e=Tn(t)),e},this.resourceUrlBlacklist=function(e){returnarguments.length&&(t=Tn(e)),t},this.$get=["$injector",function(i){functionr(e,t){return"self"===e?Nn(t):!!e.exec(t.href)}functiono(n){vari,o,a=Pn(n.toString()),s=!1;for(i=0,o=e.length;o>i;i++)if(r(e[i],a)){s=!0;break}if(s)for(i=0,o=t.length;o>i;i++)if(r(t[i],a)){s=!1;break}returns}functiona(e){vart=function(e){this.$$unwrapTrustedValue=function(){returne}};returne&&(t.prototype=newe),t.prototype.valueOf=function(){returnthis.$$unwrapTrustedValue()},t.prototype.toString=function(){returnthis.$$unwrapTrustedValue().toString()},t}functions(e,t){vari=d.hasOwnProperty(e)?d[e]:null;if(!i)thrownr("icontext","Attempted to trust a value in invalid context. Context: {0}; Value: {1}",e,t);if(null===t||t===n||""===t)returnt;if("string"!=typeoft)thrownr("itype","Attempted to trust a non-string value in a content requiring a string: Context: {0}",e);returnnewi(t)}functionc(e){returneinstanceofp?e.$$unwrapTrustedValue():e}functionl(e,t){if(null===t||t===n||""===t)returnt;vari=d.hasOwnProperty(e)?d[e]:null;if(i&&tinstanceofi)returnt.$$unwrapTrustedValue();if(e===ir.RESOURCE_URL){if(o(t))returnt;thrownr("insecurl","Blocked loading resource from url not allowed by $sceDelegate policy. URL: {0}",t.toString())}if(e===ir.HTML)returnu(t);thrownr("unsafe","Attempting to use an unsafe value in a safe context.")}varu=function(){thrownr("unsafe","Attempting to use an unsafe value in a safe context.")};i.has("$sanitize")&&(u=i.get("$sanitize"));varp=a(),d={};returnd[ir.HTML]=a(p),d[ir.CSS]=a(p),d[ir.URL]=a(p),d[ir.JS]=a(p),d[ir.RESOURCE_URL]=a(d[ir.URL]),{trustAs:s,getTrusted:l,valueOf:c}}]}functionAn(){vare=!0;this.enabled=function(t){returnarguments.length&&(e=!!t),e},this.$get=["$parse","$sniffer","$sceDelegate",function(t,n,i){if(e&&n.msie&&n.msieDocumentMode<8)thrownr("iequirks","Strict Contextual Escaping does not support Internet Explorer version < 9 in quirks mode. You can fix this by adding the text <!doctype html> to the top of your HTML document. See http://docs.angularjs.org/api/ng.$sce for more information.");varr=N(ir);r.isEnabled=function(){returne},r.trustAs=i.trustAs,r.getTrusted=i.getTrusted,r.valueOf=i.valueOf,e||(r.trustAs=r.getTrusted=function(e,t){returnt},r.valueOf=g),r.parseAs=function(e,n){vari=t(n);returni.literal&&i.constant?i:function(t,n){returnr.getTrusted(e,i(t,n))}};vara=r.parseAs,s=r.getTrusted,c=r.trustAs;returno(ir,function(e,t){varn=ai(t);r[lt("parse_as_"+n)]=function(t){returna(e,t)},r[lt("get_trusted_"+n)]=function(t){returns(e,t)},r[lt("trust_as_"+n)]=function(t){returnc(e,t)}}),r}]}functionIn(){this.$get=["$window","$document",function(e,t){varn,i,r={},o=d((/android (\d+)/.exec(ai((e.navigator||{}).userAgent))||[])[1]),a=/Boxee/i.test((e.navigator||{}).userAgent),s=t[0]||{},c=s.documentMode,l=/^(Moz|webkit|O|ms)(?=[A-Z])/,u=s.body&&s.body.style,p=!1,f=!1;if(u){for(varhinu)if(i=l.exec(h)){n=i[0],n=n.substr(0,1).toUpperCase()+n.substr(1);break}n||(n="WebkitOpacity
c[t]=a(o)}),n.start&&n.start(i,c,s)}functionr(e,i){varr,o=0;if(i=t.lowercase(i))for(o=v.length-1;o>=0&&v[o]!=i;o--);if(o>=0){for(r=v.length-1;r>=o;r--)n.end&&n.end(v[r]);v.length=o}}varo,s,c,v=[],b=e;for(v.last=function(){returnv[v.length-1]};e;){if(s=!0,v.last()&&M[v.last()])e=e.replace(newRegExp("(.*)<\\s*\\/\\s*"+v.last()+"[^>]*>","i"),function(e,t){returnt=t.replace(g,"$1").replace(y,"$1"),n.chars&&n.chars(a(t)),""}),r("",v.last());elseif(0===e.indexOf("<!--")?(o=e.indexOf("--",4),o>=0&&e.lastIndexOf("-->",o)===o&&(n.comment&&n.comment(e.substring(4,o)),e=e.substring(o+3),s=!1)):m.test(e)?(c=e.match(m),c&&(e=e.replace(c[0],""),s=!1)):h.test(e)?(c=e.match(p),c&&(e=e.substring(c[0].length),c[0].replace(p,r),s=!1)):f.test(e)&&(c=e.match(u),c&&(e=e.substring(c[0].length),c[0].replace(u,i),s=!1)),s){o=e.indexOf("<");varw=0>o?e:e.substring(0,o);e=0>o?"":e.substring(o),n.chars&&n.chars(a(w))}if(e==b)throwl("badparse","The sanitizer was unable to parse the following block of html: {0}",e);b=e}r()}functiona(e){if(!e)return"";vart=A.exec(e),n=t[1],i=t[3],r=t[2];returnr&&(E.innerHTML=r.replace(/</g,"<"),r="textContent"inE?E.textContent:E.innerText),n+r+i}functions(e){returne.replace(/&/g,"&").replace(v,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(/</g,"<").replace(/>/g,">")}functionc(e,n){vari=!1,r=t.bind(e,e.push);return{start:function(e,o,a){e=t.lowercase(e),!i&&M[e]&&(i=e),i||k[e]!==!0||(r("<"),r(e),t.forEach(o,function(i,o){vara=t.lowercase(o),c="img"===e&&"src"===a||"background"===a;T[a]!==!0||x[a]===!0&&!n(i,c)||(r(" "),r(o),r('="'),r(s(i)),r('"'))}),r(a?"/>":">"))},end:function(e){e=t.lowercase(e),i||k[e]!==!0||(r("</"),r(e),r(">")),e==i&&(i=!1)},chars:function(e){i||r(s(e))}}}varl=t.$$minErr("$sanitize"),u=/^<\s*([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*>/,p=/^<\s*\/\s*([\w:-]+)[^>]*>/,d=/([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g,f=/^</,h=/^<\s*\//,g=/<!--(.*?)-->/g,m=/<!DOCTYPE([^>]*?)>/i,y=/<!\[CDATA\[(.*?)]]>/g,v=/([^\#-~| |!])/g,_=r("area,br,col,hr,img,wbr"),b=r("colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr"),w=r("rp,rt"),$=t.extend({},w,b),S=t.extend({},b,r("address,article,aside,blockquote,caption,center,del,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5,h6,header,hgroup,hr,ins,map,menu,nav,ol,pre,script,section,table,ul")),C=t.extend({},w,r("a,abbr,acronym,b,bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,q,ruby,rp,rt,s,samp,small,span,strike,strong,sub,sup,time,tt,u,var")),M=r("script,style"),k=t.extend({},_,S,C,$),x=r("background,cite,href,longdesc,src,usemap"),T=t.extend({},x,r("abbr,align,alt,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,compact,coords,dir,face,headers,height,hreflang,hspace,ismap,lang,language,nohref,nowrap,rel,rev,rows,rowspan,rules,scope,scrolling,shape,size,span,start,summary,target,title,type,valign,value,vspace,width")),E=document.createElement("pre"),A=/^(\s*)([\s\S]*?)(\s*)$/;t.module("ngSanitize",[]).provider("$sanitize",n),t.module("ngSanitize").filter("linky",["$sanitize",function(e){varn=/((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>]/,r=/^mailto:/;returnfunction(o,a){functions(e){e&&f.push(i(e))}functionc(e,n){f.push("<a "),t.isDefined(a)&&(f.push('target="'),f.push(a),f.push('" ')),f.push('href="'),f.push(e),f.push('">'),s(n),f.push("</a>")}if(!o)returno;for(varl,u,p,d=o,f=[];l=d.match(n);)u=l[0],l[2]==l[3]&&(u="mailto:"+u),p=l.index,s(d.substr(0,p)),c(u,l[0].replace(r,"")),d=d.substring(p+l[0].length);returns(d),e(f.join(""))}}])}(window,window.angular),angular.module("ui.bootstrap",["ui.bootstrap.tpls","ui.bootstrap.transition","ui.bootstrap.collapse","ui.bootstrap.dropdownToggle","ui.bootstrap.modal","ui.bootstrap.position","ui.bootstrap.bindHtml","ui.bootstrap.tooltip"]),angular.module("ui.bootstrap.tpls",["template/modal/backdrop.html","template/modal/window.html","template/tooltip/tooltip-html-unsafe-popup.html","template/tooltip/tooltip-popup.html"]),angular.module("ui.bootstrap
if(16==e.error_code||17==e.error_code){t.applyServerTime(bigStringInt(n).shiftRight(32).toString(10))&&this.updateSession();vars=this.updateSentMessage(e.bad_msg_id);this.pushResend(s.msg_id),this.ackMessage(n)}break;case"message":this.serverMessages.push(e.msg_id),this.processMessage(e.body,e.msg_id,i);break;case"new_session_created":this.ackMessage(n),this.processMessageAck(e.first_msg_id),this.applyServerSalt(e.server_salt),this.onSessionCreate(i,n);break;case"msgs_ack":for(varo=0;o<e.msg_ids.length;o++)this.processMessageAck(e.msg_ids[o]);break;case"msg_detailed_info":if(!this.sentMessages[e.msg_id]){this.ackMessage(e.answer_msg_id);break}case"msg_new_detailed_info":this.reqResendMessage(e.answer_msg_id);break;case"rpc_result":this.ackMessage(n);varc=e.req_msg_id,a=this.sentMessages[c];if(this.processMessageAck(c),a){varl=a.deferred;if("rpc_error"==e.result._){varu=this.processError(e.result);console.log(dT(),"Rpc error",u),l&&l.reject(u)}elsel&&(Config.Modes.debug?console.log(dT(),"Rpc response",e.result):console.log(dT(),"Rpc response",e.result._),a.deferred.resolve(e.result)),a.isAPI&&(this.connectionInited=!0);deletethis.sentMessages[c]}break;default:this.ackMessage(n),d&&d(e)}},{getNetworker:function(e,t,n,i){returnnewp(e,t,n,i)},setUpdatesProcessor:function(e){d=e}}}]).factory("MtpApiManager",["AppConfigManager","MtpAuthorizer","MtpNetworkerFactory","ErrorService","$q",function(e,t,n,i,r){functiono(t,n){e.set({dc:t,user_auth:angular.extend({dcID:t},n)}),h=t}functiona(){returnc("auth.logOut").then(function(){e.remove("dc","user_auth"),h=!1},function(t){e.remove("dc","user_auth"),t&&401!=t.code&&e.remove("dc"+h+"_auth_key"),h=!1,t.handled=!0})}functions(i,o){o=o||{};vara=o.fileUpload||o.fileDownload?d:p;if(!i)thrownewException("get Networker without dcID");if(void0!==a[i])returnr.when(a[i]);vars="dc"+i+"_auth_key",c="dc"+i+"_server_salt";returne.get(s,c).then(function(l){if(void0!==a[i])returna[i];varu=l[0],p=l[1];if(u&&512==u.length){vard=bytesFromHex(u),f=bytesFromHex(p);returna[i]=n.getNetworker(i,d,f,o)}returno.createNetworker?t.auth(i).then(function(t){varr={};returnr[s]=bytesToHex(t.authKey),r[c]=bytesToHex(t.serverSalt),e.set(r),a[i]=n.getNetworker(i,t.authKey,t.serverSalt,o)},function(e){returnconsole.log("Get networker error",e,e.stack),r.reject(e)}):r.reject({type:"AUTH_KEY_EMPTY",code:401})})}functionc(t,n,o){o=o||{};vara,l,u=r.defer(),p=function(e){e?angular.isObject(e)||(e={message:e}):e={type:"ERROR_EMPTY"},u.reject(e),o.noErrorBox||(e.input=t,e.stack=e.stack||(newError).stack,setTimeout(function(){e.handled||(i.show({error:e}),e.handled=!0)},100))};l=(a=o.dcID)?s(a,o):e.get("dc").then(function(e){returns(a=e||1,o)});vard,g=!1;if(l.then(function(i){return(d=i).wrapApiCall(t,n,o).then(function(e){u.resolve(e)},function(l){if(console.error(dT(),"Error",l.code,l.type,h,a),401==l.code&&h==a)e.remove("dc","user_auth");elseif(401==l.code&&h&&a!=h){if(void0===f[a]){varg=r.defer();c("auth.exportAuthorization",{dc_id:a},{noErrorBox:!0}).then(function(e){c("auth.importAuthorization",{id:e.id,bytes:e.bytes},{dcID:a,noErrorBox:!0}).then(function(){g.resolve()},function(e){g.reject(e)})},function(e){g.reject(e)}),f[a]=g.promise}f[a].then(function(){(d=i).wrapApiCall(t,n,o).then(function(e){u.resolve(e)},function(e){p(e)})},function(e){p(e)})}elseif(303==l.code){varm=l.type.match(/^(PHONE_MIGRATE_|NETWORK_MIGRATE_)(\d+)/)[2];m!=a&&(o.dcID?o.dcID=m:e.set({dc:h=m}),s(m,o).then(function(e){e.wrapApiCall(t,n,o).then(function(e){u.resolve(e)},function(e){p(e)})}))}elsep(l)})},function(e){p(e)}),!(g=g||(newError).stack))try{window.unexistingFunction()}catch(m){g=m.stack||""}returnu.promise}functionl(){returne.get("user_auth").then(function(e){returne.id||0})}functionu(){returnh||!1}varp={},d={},f={},h=!1;returne.get("dc").then(function(e){e&&(h=e)}),{getBaseDcID:u,getUserID:l,invokeApi:c,setUserAuth:o,logOut:a}}]).factory("MtpApiFileManager",["MtpApiManager","$q","$window",function(e,t,n){functioni(e,n,i){void0===b[e]&&(b[e]=[],w[e]=0);varo=b[e],a=t.defer();returno.
break;case"messageMediaVideo":t.media.video=l.wrapForHistory(t.media.video.id);break;case"messageMediaDocument":t.media.document=u.wrapForHistory(t.media.document.id);break;case"messageMediaAudio":t.media.audio=p.wrapForHistory(t.media.audio.id);break;case"messageMediaContact":t.media.rFullName=h.wrapRichText(t.media.first_name+" "+(t.media.last_name||""),{noLinks:!0,noLinebreaks:!0})}t.media.user_id&&(t.media.user=o.getUser(t.media.user_id),t.media.userPhoto=o.getUserPhoto(t.media.user_id,"User"))}elseif(t.action){switch(t.action._){case"messageActionChatEditPhoto":t.action.photo=c.wrapForHistory(t.action.photo.id);break;case"messageActionChatCreate":case"messageActionChatEditTitle":t.action.rTitle=h.wrapRichText(t.action.title,{noLinks:!0,noLinebreaks:!0})||"DELETED"}t.action.user_id&&(t.action.user=o.getUser(t.action.user_id),t.action.userPhoto=o.getUserPhoto(t.action.user_id,"User"))}returnt.message&&t.message.length&&(t.richMessage=h.wrapRichText(t.message)),R[e]=t}functionB(e){for(vart=0;t<j.dialogs.length;t++)if(j.dialogs[t].peerID==e)return[j.dialogs[t],t];return[]}functionU(e){varn,i,r=P(e),s=o.getUser(e.from_id),c=o.getUserPhoto(e.from_id,"User"),l={},u=!1;if(e.message)u=e.message;elseif(e.media&&"messageMediaEmpty"!=e.media._)switch(e.media._){case"messageMediaPhoto":u="Photo";break;case"messageMediaVideo":u="Video";break;case"messageMediaDocument":u="Document";break;case"messageMediaGeo":u="Location";break;case"messageMediaContact":u="Contact";break;default:u="Attachment"}elseif("messageService"==e._)switch(e.action._){case"messageActionChatCreate":u="created the group";break;case"messageActionChatEditTitle":u="changed group name";break;case"messageActionChatEditPhoto":u="changed group photo";break;case"messageActionChatDeletePhoto":u="removed group photo";break;case"messageActionChatAddUser":u="invited user";break;case"messageActionChatDeleteUser":u="kicked user"}r>0?(l.title=(s.first_name||"")+(s.first_name&&s.last_name?" ":"")+(s.last_name||""),i=c,n=o.getUserString(r)):(l.title=(s.first_name||s.last_name||"Somebody")+" @ "+(a.getChat(-r).title||"Unknown chat"),i=a.getChatPhoto(-r,"Group"),n=a.getChatString(-r)),l.onclick=function(){t.$broadcast("history_focus",{peerString:n})},l.message=u,l.image=i.placeholder,l.key="msg"+e.id,l.tag=n,i.location&&!i.location.empty?f.downloadSmallFile(i.location,i.size).then(function(t){l.image=t,e.unread&&g.notify(l)}):g.notify(l)}varO={},R={},F={},q={},j={count:null,dialogs:[]},H={},z={},V={},W=e.when(),G=-1,K=m.createIndex(),Z={query:!1},X={},Y=[];returng.start(),t.$on("apiUpdate",function(e,n){switch(n._){case"updateMessageID":z[n.id]=n.random_id;break;case"updateNewMessage":vari=n.message,r=P(i),o=q[r];if(void0!==o){vara=q[r].history[0];if(i.id<=a)return!1}elseo=q[r]={count:null,history:[],pending:[]};k([i]),null!==o.count&&o.count++,o.history.unshift(i.id);varc,l=z[i.id];l&&((c=D(l,i))&&t.$broadcast("history_update",{peerID:r}),deletez[i.id]),c||t.$broadcast("history_append",{peerID:r,messageID:i.id});varu,p=B(r);p.length?(u=p[0],j.dialogs.splice(p[1],1)):u={peerID:r,unread_count:0,top_message:!1},!i.out&&i.unread&&u.unread_count++,u.top_message=i.id,m.indexObject(r,s.getPeerSearchText(r),K),j.dialogs.unshift(u),t.$broadcast("dialogs_update",u),t.idle.isIDLE&&!i.out&&i.unread&&g.getPeerMuted(r).then(function(e){i.unread&&!e&&U(i)});break;case"updateReadMessages":vard,i,f,r,p,u,h={};for(f=0;f<n.messages.length;f++)d=n.messages[f],i=O[d],i&&i.unread&&(i.unread=!1,R[d]&&(R[d].unread=!1),F[d]&&(F[d].unread=!1),r=P(i),i.out||(p=B(r),p&&(h[r]=--p[0].unread_count),g.cancel("msg"+d)));angular.forEach(h,function(e,n){t.$broadcast("dialog_unread",{peerID:n,count:e})});break;case"updateDeleteMessages":vard,i,f,r,p,u,y,h={},v={};for(f=0;f<n.messages.length;f++)d=n.messages[f],i=O[d],i&&(r=P(i),y=v[r]||(v[r]={count:0,unread:0,msgs:{}}),!i.out&&i.unread&&(y.unread++,g.cancel("msg"+d)),y.count++,y.msgs[d]=!0,R[d]&&(R[d].DELETED=!0,deleteR[d]),F[d]&&(F[d].DELETED=!0,deleteF[d]),i.DELETED=!0,deleteO[d]);angular.forEach(v,function(e,n){vari=B(n);i&&e.unread&&(i