From 0be537cab6cbdd71a7114e3b60bfc0fa56271b71 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sat, 27 Sep 2014 16:50:08 +0400 Subject: [PATCH] Update app.js Updated dc address --- js/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/app.js b/js/app.js index 9d5db8a8..3160986f 100644 --- a/js/app.js +++ b/js/app.js @@ -9,10 +9,10 @@ d&&(a=L(d,i)>=0,a&&(F(d,i),u--,0===d.length&&delete s.$pending[e]));var h=s.$pen },i):h.$commitViewValue(t)},e.$watch(function(){var t=u(e);if(h.$options&&h.$options.getterSetter&&C(t)&&(t=t()),h.$modelValue!==t&&(v(h.$$invalidModelValue)||h.$$invalidModelValue!=t)){for(var n=h.$formatters,i=n.length,a=t;i--;)a=n[i](a);h.$$runValidators(t,a),h.$viewValue!==a&&(h.$viewValue=h.$$lastCommittedViewValue=a,h.$render())}return t})}],So=function(){return{restrict:"A",require:["ngModel","^?form","^?ngModelOptions"],controller:Co,link:{pre:function(e,t,n,i){var a=i[0],o=i[1]||Qa;a.$$setOptions(i[2]&&i[2].$options),o.$addControl(a),e.$on("$destroy",function(){o.$removeControl(a)})},post:function(e,t,n,i){var a=i[0];a.$options&&a.$options.updateOn&&t.on(a.$options.updateOn,function(t){e.$apply(function(){a.$$debounceViewValueCommit(t&&t.type)})}),t.on("blur",function(){a.$touched||e.$apply(function(){a.$setTouched()})})}}}},ko=m({restrict:"A",require:"ngModel",link:function(e,t,n,i){i.$viewChangeListeners.push(function(){e.$eval(n.ngChange)})}}),xo=function(){return{restrict:"A",require:"?ngModel",link:function(e,t,n,i){i&&(n.required=!0,i.$validators.required=function(e,t){return!n.required||!i.$isEmpty(t)},n.$observe("required",function(){i.$validate()}))}}},Mo=function(){return{restrict:"A",require:"?ngModel",link:function(e,t,a,o){if(o){var r,s=a.ngPattern||a.pattern;a.$observe("pattern",function(e){if(b(e)&&e.length>0&&(e=new RegExp(e)),e&&!e.test)throw i("ngPattern")("noregexp","Expected {0} to be a RegExp but was {1}. Element: {2}",s,e,W(t));r=e||n,o.$validate()}),o.$validators.pattern=function(e){return o.$isEmpty(e)||v(r)||r.test(e)}}}}},To=function(){return{restrict:"A",require:"?ngModel",link:function(e,t,n,i){if(i){var a=0;n.$observe("maxlength",function(e){a=p(e)||0,i.$validate()}),i.$validators.maxlength=function(e,t){return i.$isEmpty(t)||t.length<=a}}}}},Eo=function(){return{restrict:"A",require:"?ngModel",link:function(e,t,n,i){if(i){var a=0;n.$observe("minlength",function(e){a=p(e)||0,i.$validate()}),i.$validators.minlength=function(e,t){return i.$isEmpty(t)||t.length>=a}}}}},Ao=function(){return{restrict:"A",priority:100,require:"ngModel",link:function(e,t,i,a){var r=t.attr(i.$attr.ngList)||", ",s="false"!==i.ngTrim,c=s?Xi(r):r,l=function(e){if(!v(e)){var t=[];return e&&o(e.split(c),function(e){e&&t.push(s?Xi(e):e)}),t}};a.$parsers.push(l),a.$formatters.push(function(e){return Ki(e)?e.join(r):n}),a.$isEmpty=function(e){return!e||!e.length}}}},Do=/^(true|false|\d+)$/,Io=function(){return{restrict:"A",priority:100,compile:function(e,t){return Do.test(t.ngValue)?function(e,t,n){n.$set("value",e.$eval(n.ngValue))}:function(e,t,n){e.$watch(n.ngValue,function(e){n.$set("value",e)})}}}},Po=function(){return{restrict:"A",controller:["$scope","$attrs",function(e,t){var i=this;this.$options=e.$eval(t.ngModelOptions),this.$options.updateOn!==n?(this.$options.updateOnDefault=!1,this.$options.updateOn=Xi(this.$options.updateOn.replace(po,function(){return i.$options.updateOnDefault=!0," "}))):this.$options.updateOnDefault=!0}]}},No=["$compile",function(e){return{restrict:"AC",compile:function(t){return e.$$addBindingClass(t),function(t,i,a){e.$$addBindingInfo(i,a.ngBind),t.$watch(a.ngBind,function(e){i.text(e==n?"":e)})}}}}],Lo=["$interpolate","$compile",function(e,t){return{compile:function(n){return t.$$addBindingClass(n),function(n,i,a){var o=e(i.attr(a.$attr.ngBindTemplate));t.$$addBindingInfo(i,o.expressions),a.$observe("ngBindTemplate",function(e){i.text(e)})}}}}],Fo=["$sce","$parse","$compile",function(e,t,n){return{restrict:"A",compile:function(i,a){var o=t(a.ngBindHtml),r=t(a.ngBindHtml,function(e){return(e||"").toString()});return n.$$addBindingClass(i),function(t,i,a){n.$$addBindingInfo(i,a.ngBindHtml),t.$watch(r,function(){i.html(e.getTrustedHtml(o(t))||"")})}}}}],Bo=Ei("",!0),Oo=Ei("Odd",0),Uo=Ei("Even",1),Ro=fi({compile:function(e,t){t.$set("ngCloak",n),e.removeClass("ng-cloak")}}),qo=[function(){return{restrict:"A",scope:!0,controller:"@",priority:500}}],Ho={},jo={blur:!0,focus:!0};o("click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress submit focus blur copy cut paste".split(" "),function(e){var t=Xt("ng-"+e);Ho[t]=["$parse",function(n){return{restrict:"A",compile:function(i,a){var o=n(a[t]);return function(t,n){var i=Ii(e);n.on(i,function(e){var n=function(){o(t,{$event:e})};jo[i]&&t.$$phase?t.$evalAsync(n):t.$apply(n)})}}}}]});var Vo=["$animate",function(e){return{multiElement:!0,transclude:"element",priority:600,terminal:!0,restrict:"A",$$tlb:!0,link:function(n,i,a,o,r){var s,c,l;n.$watch(a.ngIf,function(n){n?c||r(function(n,o){c=o,n[n.length++]=t.createComment(" end ngIf: "+a.ngIf+" "),s={clone:n},e.enter(n,i.parent(),i)}):(l&&(l.remove(),l=null),c&&(c.$destroy(),c=null),s&&(l=lt(s.clone),e.leave(l).then(function(){l=null}),s=null))})}}}],zo=["$templateRequest","$anchorScroll","$animate","$sce",function(e,t,n,i){return{restrict:"ECA",priority:400,terminal:!0,transclude:"element",controller:zi.noop,compile:function(a,o){var r=o.ngInclude||o.src,s=o.onload||"",c=o.autoscroll;return function(a,o,l,u,d){var p,h,f,g=0,m=function(){h&&(h.remove(),h=null),p&&(p.$destroy(),p=null),f&&(n.leave(f).then(function(){h=null}),h=f,f=null)};a.$watch(i.parseAsResourceUrl(r),function(i){var r=function(){!y(c)||c&&!a.$eval(c)||t()},l=++g;i?(e(i,!0).then(function(e){if(l===g){var t=a.$new();u.template=e;var i=d(t,function(e){m(),n.enter(e,null,o).then(r)});p=t,f=i,p.$emit("$includeContentLoaded"),a.$eval(s)}},function(){l===g&&(m(),a.$emit("$includeContentError"))}),a.$emit("$includeContentRequested")):(m(),u.template=null)})}}}}],Wo=["$compile",function(e){return{restrict:"ECA",priority:-400,require:"ngInclude",link:function(t,n,i,a){n.html(a.template),e(n.contents())(t)}}}],Go=fi({priority:450,compile:function(){return{pre:function(e,t,n){e.$eval(n.ngInit)}}}}),Ko=fi({terminal:!0,priority:1e3}),Xo=["$locale","$interpolate",function(e,t){var n=/{}/g;return{restrict:"EA",link:function(i,a,r){var s=r.count,c=r.$attr.when&&a.attr(r.$attr.when),l=r.offset||0,u=i.$eval(c)||{},d={},p=t.startSymbol(),h=t.endSymbol(),f=/^when(Minus)?(.+)$/;o(r,function(e,t){f.test(t)&&(u[Ii(t.replace("when","").replace("Minus","-"))]=a.attr(r.$attr[t]))}),o(u,function(e,i){d[i]=t(e.replace(n,p+s+"-"+l+h))}),i.$watch(function(){var t=parseFloat(i.$eval(s));return isNaN(t)?"":(t in u||(t=e.pluralCat(t-l)),d[t](i))},function(e){a.text(e)})}}}],Yo=["$parse","$animate",function(e,r){var s="$$NG_REMOVED",c=i("ngRepeat"),l=function(e,t,n,i,a,o,r){e[n]=i,a&&(e[a]=o),e.$index=t,e.$first=0===t,e.$last=t===r-1,e.$middle=!(e.$first||e.$last),e.$odd=!(e.$even=0===(1&t))},u=function(e){return e.clone[0]},d=function(e){return e.clone[e.clone.length-1]};return{restrict:"A",multiElement:!0,transclude:"element",priority:1e3,terminal:!0,$$tlb:!0,compile:function(i,p){var h=p.ngRepeat,f=t.createComment(" end ngRepeat: "+h+" "),g=h.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);if(!g)throw c("iexp","Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.",h);var m=g[1],v=g[2],y=g[3],_=g[4];if(g=m.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/),!g)throw c("iidexp","'_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got '{0}'.",m);var b=g[3]||g[1],w=g[2];if(y&&(!/^[$a-zA-Z_][$a-zA-Z0-9_]*$/.test(y)||/^(null|undefined|this|\$index|\$first|\$middle|\$last|\$even|\$odd|\$parent)$/.test(y)))throw c("badident","alias '{0}' is invalid --- must be a valid JS identifier which is not a reserved name.",y);var $,C,S,k,x={$id:Bt};return _?$=e(_):(S=function(e,t){return Bt(t)},k=function(e){return e}),function(e,t,i,p,g){$&&(C=function(t,n,i){return w&&(x[w]=t),x[b]=n,x.$index=i,$(e,x)});var m=ut();e.$watchCollection(v,function(i){var p,v,_,$,x,M,T,E,A,D,I,P,N=t[0],L=ut();if(y&&(e[y]=i),a(i))A=i,E=C||S;else{E=C||k,A=[];for(var F in i)i.hasOwnProperty(F)&&"$"!=F.charAt(0)&&A.push(F);A.sort()}for($=A.length,I=new Array($),p=0;$>p;p++)if(x=i===A?p:A[p],M=i[x],T=E(x,M,p),m[T])D=m[T],delete m[T],L[T]=D,I[p]=D;else{if(L[T])throw o(I,function(e){e&&e.scope&&(m[e.id]=e)}),c("dupes","Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: {0}, Duplicate key: {1}, Duplicate value: {2}",h,T,V(M));I[p]={id:T,scope:n,clone:n},L[T]=!0}for(var B in m){if(D=m[B],P=lt(D.clone),r.leave(P),P[0].parent)for(p=0,v=P.length;v>p;p++)P[p][s]=!0;D.scope.$destroy()}for(p=0;$>p;p++)if(x=i===A?p:A[p],M=i[x],D=I[p],D.scope){_=N;do _=_.nextSibling;while(_&&_[s]);u(D)!=_&&r.move(lt(D.clone),null,Oi(N)),N=d(D),l(D.scope,p,b,M,w,x,$)}else g(function(e,t){D.scope=t;var n=f.cloneNode();e[e.length++]=n,r.enter(e,null,Oi(N)),N=n,D.clone=e,L[D.id]=D,l(D.scope,p,b,M,w,x,$)});m=L})}}}}],Zo=["$animate",function(e){return{restrict:"A",multiElement:!0,link:function(t,n,i){t.$watch(i.ngShow,function(t){e[t?"removeClass":"addClass"](n,"ng-hide")})}}}],Qo=["$animate",function(e){return{restrict:"A",multiElement:!0,link:function(t,n,i){t.$watch(i.ngHide,function(t){e[t?"addClass":"removeClass"](n,"ng-hide")})}}}],Jo=fi(function(e,t,n){e.$watch(n.ngStyle,function(e,n){n&&e!==n&&o(n,function(e,n){t.css(n,"")}),e&&t.css(e)},!0)}),er=["$animate",function(e){return{restrict:"EA",require:"ngSwitch",controller:["$scope",function(){this.cases={}}],link:function(n,i,a,r){var s=a.ngSwitch||a.on,c=[],l=[],u=[],d=[];n.$watch(s,function(i){var s,p;for(s=0,p=u.length;p>s;++s)e.cancel(u[s]);for(u.length=0,s=0,p=d.length;p>s;++s){var h=lt(l[s].clone);d[s].$destroy();var f=u[s]=e.leave(h);f.then(function(){u.splice(s,1)})}l.length=0,d.length=0,(c=r.cases["!"+i]||r.cases["?"])&&(n.$eval(a.change),o(c,function(n){n.transclude(function(i,a){d.push(a);var o=n.element;i[i.length++]=t.createComment(" end ngSwitchWhen: ");var r={clone:i};l.push(r),e.enter(i,o.parent(),o)})}))})}}}],tr=fi({transclude:"element",priority:1200,require:"^ngSwitch",multiElement:!0,link:function(e,t,n,i,a){i.cases["!"+n.ngSwitchWhen]=i.cases["!"+n.ngSwitchWhen]||[],i.cases["!"+n.ngSwitchWhen].push({transclude:a,element:t})}}),nr=fi({transclude:"element",priority:1200,require:"^ngSwitch",multiElement:!0,link:function(e,t,n,i,a){i.cases["?"]=i.cases["?"]||[],i.cases["?"].push({transclude:a,element:t})}}),ir=fi({restrict:"EAC",link:function(e,t,n,a,o){if(!o)throw i("ngTransclude")("orphan","Illegal use of ngTransclude directive in the template! No parent directive that requires a transclusion found. Element: {0}",W(t));o(function(e){t.empty(),t.append(e)})}}),ar=["$templateCache",function(e){return{restrict:"E",terminal:!0,compile:function(t,n){if("text/ng-template"==n.type){var i=n.id,a=t[0].text;e.put(i,a)}}}}],or=i("ngOptions"),rr=m({restrict:"A",terminal:!0}),sr=["$compile","$parse",function(e,i){var a=/^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+group\s+by\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?$/,s={$setViewValue:f};return{restrict:"E",require:["select","?ngModel"],controller:["$element","$scope","$attrs",function(e,t,n){var i,a,o=this,r={},c=s;o.databound=n.ngModel,o.init=function(e,t,n){c=e,i=t,a=n},o.addOption=function(t,n){st(t,'"option value"'),r[t]=!0,c.$viewValue==t&&(e.val(t),a.parent()&&a.remove()),n[0].hasAttribute("selected")&&(n[0].selected=!0)},o.removeOption=function(e){this.hasOption(e)&&(delete r[e],c.$viewValue==e&&this.renderUnknownOption(e))},o.renderUnknownOption=function(t){var n="? "+Bt(t)+" ?";a.val(n),e.prepend(a),e.val(n),a.prop("selected",!0)},o.hasOption=function(e){return r.hasOwnProperty(e)},t.$on("$destroy",function(){o.renderUnknownOption=f})}],link:function(s,c,l,u){function d(e,t,n,i){n.$render=function(){var e=n.$viewValue;i.hasOption(e)?(k.parent()&&k.remove(),t.val(e),""===e&&f.prop("selected",!0)):v(e)&&f?t.val(""):i.renderUnknownOption(e)},t.on("change",function(){e.$apply(function(){k.parent()&&k.remove(),n.$setViewValue(t.val())})})}function p(e,t,n){var i;n.$render=function(){var e=new Ot(n.$viewValue);o(t.find("option"),function(t){t.selected=y(e.get(t.value))})},e.$watch(function(){U(i,n.$viewValue)||(i=O(n.$viewValue),n.$render())}),t.on("change",function(){e.$apply(function(){var e=[];o(t.find("option"),function(t){t.selected&&e.push(t.value)}),n.$setViewValue(e)})})}function h(t,o,s){function c(){var e=!1;if(_){var n=s.$modelValue;if(k&&Ki(n)){e=new Ot([]);for(var i={},a=0;aE;E++){if(v=E,h){if(v=O[E],"$"===v.charAt(0))continue;U[h]=v}if(U[p]=B[v],e=f(t,U)||"",(n=N[e])||(n=N[e]=[],L.push(e)),_)A=y(R.remove(k?k(t,U):g(t,U)));else{if(k){var q={};q[p]=F,A=k(t,q)===k(t,U)}else A=F===g(t,U);R=R||A}P=d(t,U),P=y(P)?P:"",n.push({id:k?k(t,U):h?O[E]:E,label:P,selected:A})}for(_||(w||null===F?N[""].unshift({id:"",label:"",selected:!R}):R||N[""].unshift({id:"?",label:"",selected:!0})),T=0,b=L.length;b>T;T++){for(e=L[T],n=N[e],x.length<=T?(a={element:S.clone().attr("label",e),label:n.label},l=[a],x.push(l),o.append(a.element)):(l=x[T],a=l[0],a.label!=e&&a.element.attr("label",a.label=e)),D=null,E=0,M=n.length;M>E;E++)i=n[E],(u=l[E+1])?(D=u.element,u.label!==i.label&&D.text(u.label=i.label),u.id!==i.id&&D.val(u.id=i.id),D[0].selected!==i.selected&&(D.prop("selected",u.selected=i.selected),Bi&&D.prop("selected",u.selected))):(""===i.id&&w?I=w:(I=C.clone()).val(i.id).prop("selected",i.selected).attr("selected",i.selected).text(i.label),l.push(u={element:I,label:i.label,id:i.id,selected:i.selected}),D?D.after(I):a.element.append(I),D=I);for(E++;l.length>E;)l.pop().element.remove()}for(;x.length>T;)x.pop()[0].element.remove()}var u;if(!(u=b.match(a)))throw or("iexp","Expected expression in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_' but got '{0}'. Element: {1}",b,W(o));var d=i(u[2]||u[1]),p=u[4]||u[6],h=u[5],f=i(u[3]||""),g=i(u[2]?u[1]:p),m=i(u[7]),v=u[8],k=v?i(u[8]):null,x=[[{element:o,label:""}]];w&&(e(w)(t),w.removeClass("ng-scope"),w.remove()),o.empty(),o.on("change",function(){t.$apply(function(){var e,i,a,r,c,u,d,f,v,y=m(t)||[],b={};if(_){for(a=[],u=0,f=x.length;f>u;u++)for(e=x[u],c=1,d=e.length;d>c;c++)if((r=e[c].element)[0].selected){if(i=r.val(),h&&(b[h]=i),k)for(v=0;vx;x++)if(""===M[x].value){f=w=M.eq(x);break}g.init(m,w,k),_&&(m.$isEmpty=function(e){return!e||0===e.length}),b?h(s,c,m):_?p(s,c,m):d(s,c,m,g)}}}}],cr=["$interpolate",function(e){var t={addOption:f,removeOption:f};return{restrict:"E",priority:100,compile:function(n,i){if(v(i.value)){var a=e(n.text(),!0);a||i.$set("value",n.text())}return function(e,n,i){var o="$selectController",r=n.parent(),s=r.data(o)||r.parent().data(o);s&&s.databound?n.prop("selected",!1):s=t,a?e.$watch(a,function(e,t){i.$set("value",e),t!==e&&s.removeOption(t),s.addOption(e,n)}):s.addOption(i.value,n),n.on("$destroy",function(){s.removeOption(i.value)})}}}}],lr=m({restrict:"E",terminal:!1});return e.angular.bootstrap?void console.log("WARNING: Tried to load angular more than once."):(at(),pt(zi),void Oi(t).ready(function(){J(t,et)}))}(window,document),!window.angular.$$csp()&&window.angular.element(document).find("head").prepend(''),function(e,t){"use strict";function n(){function e(e,n){return t.extend(new(t.extend(function(){},{prototype:e})),n)}function n(e,t){var n=t.caseInsensitiveMatch,i={originalPath:e,regexp:e},a=i.keys=[];return e=e.replace(/([().])/g,"\\$1").replace(/(\/)?:(\w+)([\?\*])?/g,function(e,t,n,i){var o="?"===i?i:null,r="*"===i?i:null;return a.push({name:n,optional:!!o}),t=t||"",""+(o?"":t)+"(?:"+(o?t:"")+(r&&"(.+?)"||"([^/]+)")+(o||"")+")"+(o||"")}).replace(/([\/$\*])/g,"\\$1"),i.regexp=new RegExp("^"+e+"$",n?"i":""),i}var i={};this.when=function(e,a){if(i[e]=t.extend({reloadOnSearch:!0},a,e&&n(e,a)),e){var o="/"==e[e.length-1]?e.substr(0,e.length-1):e+"/";i[o]=t.extend({redirectTo:e},n(o,a))}return this},this.otherwise=function(e){return"string"==typeof e&&(e={redirectTo:e}),this.when(null,e),this},this.$get=["$rootScope","$location","$routeParams","$q","$injector","$templateRequest","$sce",function(n,a,o,r,c,l,u){function d(e,t){var n=t.keys,i={};if(!t.regexp)return null;var a=t.regexp.exec(e);if(!a)return null;for(var o=1,r=a.length;r>o;++o){var s=n[o-1],c=a[o];s&&c&&(i[s.name]=c)}return i}function p(){var e=h(),i=m.current;e&&i&&e.$$route===i.$$route&&t.equals(e.pathParams,i.pathParams)&&!e.reloadOnSearch&&!g?(i.params=e.params,t.copy(i.params,o),n.$broadcast("$routeUpdate",i)):(e||i)&&(g=!1,n.$broadcast("$routeChangeStart",e,i),m.current=e,e&&e.redirectTo&&(t.isString(e.redirectTo)?a.path(f(e.redirectTo,e.params)).search(e.params).replace():a.url(e.redirectTo(e.pathParams,a.path(),a.search())).replace()),r.when(e).then(function(){if(e){var n,i,a=t.extend({},e.resolve);return t.forEach(a,function(e,n){a[n]=t.isString(e)?c.get(e):c.invoke(e,null,null,n)}),t.isDefined(n=e.template)?t.isFunction(n)&&(n=n(e.params)):t.isDefined(i=e.templateUrl)&&(t.isFunction(i)&&(i=i(e.params)),i=u.getTrustedResourceUrl(i),t.isDefined(i)&&(e.loadedTemplateUrl=i,n=l(i))),t.isDefined(n)&&(a.$template=n),r.all(a)}}).then(function(a){e==m.current&&(e&&(e.locals=a,t.copy(e.params,o)),n.$broadcast("$routeChangeSuccess",e,i))},function(t){e==m.current&&n.$broadcast("$routeChangeError",e,i,t)}))}function h(){var n,o;return t.forEach(i,function(i){!o&&(n=d(a.path(),i))&&(o=e(i,{params:t.extend({},a.search(),n),pathParams:n}),o.$$route=i)}),o||i[null]&&e(i[null],{params:{},pathParams:{}})}function f(e,n){var i=[];return t.forEach((e||"").split(":"),function(e,t){if(0===t)i.push(e);else{var a=e.match(/(\w+)(.*)/),o=a[1];i.push(n[o]),i.push(a[2]||""),delete n[o]}}),i.join("")}var g=!1,m={routes:i,reload:function(){g=!0,n.$evalAsync(p)},updateParams:function(e){if(!this.current||!this.current.$$route)throw s("norout","Tried updating route when with no current route");var n={},i=this;t.forEach(Object.keys(e),function(t){i.current.pathParams[t]||(n[t]=e[t])}),e=t.extend({},this.current.params,e),a.path(f(this.current.$$route.originalPath,e)),a.search(t.extend({},a.search(),n))}};return n.$on("$locationChangeSuccess",p),m}]}function i(){this.$get=function(){return{}}}function a(e,n,i){return{restrict:"ECA",terminal:!0,priority:400,transclude:"element",link:function(a,o,r,s,c){function l(){h&&(h.remove(),h=null),d&&(d.$destroy(),d=null),p&&(i.leave(p).then(function(){h=null}),h=p,p=null)}function u(){var r=e.current&&e.current.locals,s=r&&r.$template;if(t.isDefined(s)){var u=a.$new(),h=e.current,m=c(u,function(e){i.enter(e,null,p||o).then(function(){!t.isDefined(f)||f&&!a.$eval(f)||n()}),l()});p=m,d=h.scope=u,d.$emit("$viewContentLoaded"),d.$eval(g)}else l()}var d,p,h,f=r.autoscroll,g=r.onload||"";a.$on("$routeChangeSuccess",u),u()}}}function o(e,t,n){return{restrict:"ECA",priority:-400,link:function(i,a){var o=n.current,r=o.locals;a.html(r.$template);var s=e(a.contents());if(o.controller){r.$scope=i;var c=t(o.controller,r);o.controllerAs&&(i[o.controllerAs]=c),a.data("$ngControllerController",c),a.children().data("$ngControllerController",c)}s(i)}}}var r=t.module("ngRoute",["ng"]).provider("$route",n),s=t.$$minErr("ngRoute");r.provider("$routeParams",i),r.directive("ngView",a),r.directive("ngView",o),a.$inject=["$route","$anchorScroll","$animate"],o.$inject=["$compile","$controller","$route"]}(window,window.angular),function(e,t,n){"use strict";t.module("ngAnimate",["ng"]).directive("ngAnimateChildren",function(){var e="$$ngAnimateChildren";return function(n,i,a){var o=a.ngAnimateChildren;t.isString(o)&&0===o.length?i.data(e,!0):n.$watch(o,function(t){i.data(e,!!t)})}}).factory("$$animateReflow",["$$rAF","$document",function(e,t){var n=t[0].body;return function(t){return e(function(){n.offsetWidth+1;t()})}}]).config(["$provide","$animateProvider",function(i,a){function o(e){for(var t=0;tt?(i||"addClass"==s.event)&&r.push(n):t>0&&(i&&"removeClass"!=s.event||o.push(n))}),o.length+r.length>0&&[o.join(" "),r.join(" ")]}function x(e){if(e){var t=[],n={},a=e.substr(1).split(".");(h.transitions||h.animations)&&t.push(i.get(d[""]));for(var o=0;o0&&_(function(){i.triggerHandler(a,{event:e,className:n})})}function d(){c("before")}function p(){c("after")}function h(){c("close"),s()}function g(){g.hasBeenRun||(g.hasBeenRun=!0,r())}function v(){if(!v.hasBeenRun){v.hasBeenRun=!0;var t=i.data(f);t&&(b&&b.isClassBased?A(i,n):(_(function(){var t=i.data(f)||{};N==t.index&&A(i,n,e)}),i.data(f,t))),h()}}var y=l,b=M(i,e,n);if(!b)return g(),d(),p(),v(),y;e=b.event,n=b.className;var w=t.element._data(b.node);if(w=w&&w.events,a||(a=o?o.parent():i.parent()),D(i,a))return g(),d(),p(),v(),y;var $=i.data(f)||{},C=$.active||{},S=$.totalActive||0,k=$.last,x=!1;if(S>0){var T=[];if(b.isClassBased){if("setClass"==k.event)T.push(k),A(i,n);else if(C[n]){var E=C[n];E.event==e?x=!0:(T.push(E),A(i,n))}}else if("leave"==e&&C["ng-leave"])x=!0;else{for(var I in C)T.push(C[I]);$={},A(i,!0)}T.length>0&&u(T,function(e){e.cancel()})}if(!b.isClassBased||b.isSetClassOperation||x||(x="addClass"==e==i.hasClass(n)),x)return g(),d(),p(),h(),y;C=$.active||{},S=$.totalActive||0,"leave"==e&&i.one("$destroy",function(){var e=t.element(this),n=e.data(f);if(n){var i=n.active["ng-leave"];i&&(i.cancel(),A(e,"ng-leave"))}}),i.addClass(m);var N=P++;return S++,C[n]=b,i.data(f,{last:b,active:C,index:N,totalActive:S}),d(),b.before(function(t){var a=i.data(f);t=t||!a||!a.active[n]||b.isClassBased&&a.active[n].event!=e,g(),t===!0?v():(p(),b.after(v))}),b.cancel}function E(e){var n=o(e);if(n){var i=t.isFunction(n.getElementsByClassName)?n.getElementsByClassName(m):n.querySelectorAll("."+m);u(i,function(e){e=t.element(e);var n=e.data(f);n&&n.active&&u(n.active,function(e){e.cancel()})})}}function A(e,t){if(c(e,y))v.disabled||(v.running=!1,v.structural=!1);else if(t){var n=e.data(f)||{},i=t===!0;!i&&n.active&&n.active[t]&&(n.totalActive--,delete n.active[t]),(i||!n.totalActive)&&(e.removeClass(m),e.removeData(f))}}function D(e,n){if(v.disabled)return!0;if(c(e,y))return v.running;var i,a,o;do{if(0===n.length)break;var r=c(n,y),s=r?v:n.data(f)||{};if(s.disabled)return!0;if(r&&(o=!0),i!==!1){var l=n.data(g);t.isDefined(l)&&(i=l)}a=a||s.running||s.last&&!s.last.isClassBased}while(n=n.parent());return!o||!i&&a}y.data(f,v);var I=b.$watch(function(){return $.totalPendingRequests},function(e){0===e&&(I(),b.$$postDigest(function(){b.$$postDigest(function(){v.running=!1})}))}),P=0,N=a.classNameFilter(),L=N?function(e){return N.test(e)}:function(){return!0};return{enter:function(n,i,a){return n=t.element(n),i=r(i),a=r(a),C(n,!0),e.enter(n,i,a),S(function(e){return T("enter","ng-enter",s(n),i,a,l,e)})},leave:function(n){return n=t.element(n),E(n),C(n,!0),this.enabled(!1,n),S(function(t){return T("leave","ng-leave",s(n),null,null,function(){e.leave(n)},t)})},move:function(n,i,a){return n=t.element(n),i=r(i),a=r(a),E(n),C(n,!0),e.move(n,i,a),S(function(e){return T("move","ng-move",s(n),i,a,l,e)})},addClass:function(e,t){return this.setClass(e,t,[])},removeClass:function(e,t){return this.setClass(e,[],t)},setClass:function(n,i,a){var o="$$animateClasses";if(n=t.element(n),n=s(n),C(n))return e.setClass(n,i,a);i=p(i)?i:i.split(" "),a=p(a)?a:a.split(" ");var r=n.data(o);return r?(r.add=r.add.concat(i),r.remove=r.remove.concat(a),r.promise):(n.data(o,r={add:i,remove:a}),r.promise=S(function(t){var i=n.data(o);n.removeData(o);var a=n.data(f)||{},r=k(n,i,a.active);return r?T("setClass",r,n,null,null,function(){e.setClass(n,r[0],r[1])},t):t()}))},cancel:function(e){e.$$cancelFn()},enabled:function(e,t){switch(arguments.length){case 2:if(e)A(t);else{var n=t.data(f)||{};n.disabled=!0,t.data(f,n)}break;case 1:v.disabled=!e;break;default:e=!v.disabled}return!!e}}}]),a.register("",["$window","$sniffer","$timeout","$$animateReflow",function(i,a,r,s){function c(e,t){I&&I(),z.push(t),I=s(function(){u(z,function(e){e()}),z=[],I=null,j={}})}function d(e,n){var i=o(e);e=t.element(i),K.push(e);var a=Date.now()+n;G>=a||(r.cancel(W),G=a,W=r(function(){f(K),K=[]},n,!1))}function f(e){u(e,function(e){var t=e.data(U);t&&u(t.closeAnimationFns,function(e){e()})})}function g(e,t){var n=t?j[t]:null;if(!n){var a=0,o=0,r=0,s=0;u(e,function(e){if(e.nodeType==h){var t=i.getComputedStyle(e)||{},n=t[M+P];a=Math.max(m(n),a);var c=t[M+L];o=Math.max(m(c),o);{t[E+L]}s=Math.max(m(t[E+L]),s);var l=m(t[E+P]);l>0&&(l*=parseInt(t[E+F],10)||1),r=Math.max(l,r)}}),n={total:0,transitionDelay:o,transitionDuration:a,animationDelay:s,animationDuration:r},t&&(j[t]=n)}return n}function m(e){var n=0,i=t.isString(e)?e.split(/\s*,\s*/):[];return u(i,function(e){n=Math.max(parseFloat(e)||0,n)}),n}function v(e){var t=e.parent(),n=t.data(O);return n||(t.data(O,++V),n=V),n+"-"+o(e).getAttribute("class")}function y(e,t,n){var i=["ng-enter","ng-leave","ng-move"].indexOf(n)>=0,a=v(t),r=a+" "+n,s=j[r]?++j[r].total:0,c={};if(s>0){var l=n+"-stagger",u=a+" "+l,d=!j[u];d&&t.addClass(l),c=g(t,u),d&&t.removeClass(l)}t.addClass(n);var p=t.data(U)||{},h=g(t,r),f=h.transitionDuration,m=h.animationDuration;if(i&&0===f&&0===m)return t.removeClass(n),!1;var y=i&&f>0,_=m>0&&c.animationDelay>0&&0===c.animationDuration,$=p.closeAnimationFns||[];t.data(U,{stagger:c,cacheKey:r,running:p.running||0,itemIndex:s,blockTransition:y,closeAnimationFns:$});var C=o(t);return y&&b(C,!0),_&&w(C,!0),!0}function _(e,t,n,i){function a(){t.off(F,s),t.removeClass(p),t.removeClass(h),N&&r.cancel(N),k(t,n);var e=o(t);for(var i in m)e.style.removeProperty(m[i])}function s(e){e.stopPropagation();var t=e.originalEvent||e,n=t.$manualTimeStamp||t.timeStamp||Date.now(),a=parseFloat(t.elapsedTime.toFixed(R));Math.max(n-L,0)>=I&&a>=M&&i()}var c=o(t),l=t.data(U);if(-1==c.getAttribute("class").indexOf(n)||!l)return void i();l.blockTransition&&b(c,!1);var p="",h="";u(n.split(" "),function(e,t){var n=(t>0?" ":"")+e;p+=n+"-active",h+=n+"-pending"});var f="",m=[],v=l.itemIndex,y=l.stagger,_=0;if(v>0){var $=0;y.transitionDelay>0&&0===y.transitionDuration&&($=y.transitionDelay*v);var C=0;y.animationDelay>0&&0===y.animationDuration&&(C=y.animationDelay*v,m.push(D+"animation-play-state")),_=Math.round(100*Math.max($,C))/100}_||t.addClass(p);var S=l.cacheKey+" "+p,x=g(t,S),M=Math.max(x.transitionDuration,x.animationDuration);if(0===M)return t.removeClass(p),k(t,n),void i();var E=Math.max(x.transitionDelay,x.animationDelay),I=E*H;if(m.length>0){var P=c.getAttribute("style")||"";";"!==P.charAt(P.length-1)&&(P+=";"),c.setAttribute("style",P+" "+f)}var N,L=Date.now(),F=A+" "+T,B=(E+M)*q,O=(_+B)*H;return _>0&&(t.addClass(h),N=r(function(){N=null,t.addClass(p),t.removeClass(h),x.animationDuration>0&&w(c,!1)},_*H,!1)),t.on(F,s),l.closeAnimationFns.push(function(){a(),i()}),l.running++,d(t,O),a}function b(e,t){e.style[M+N]=t?"none":""}function w(e,t){e.style[E+B]=t?"paused":""}function $(e,t,n,i){return y(e,t,n,i)?function(e){e&&k(t,n)}:void 0}function C(e,t,n,i){return t.data(U)?_(e,t,n,i):(k(t,n),void i())}function S(e,t,n,i){var a=$(e,t,n);if(!a)return void i();var o=a;return c(t,function(){o=C(e,t,n,i)}),function(e){(o||l)(e)}}function k(e,t){e.removeClass(t);var n=e.data(U);n&&(n.running&&n.running--,n.running&&0!==n.running||e.removeData(U))}function x(e,t){var n="";return e=p(e)?e:e.split(/\s+/),u(e,function(e,i){e&&e.length>0&&(n+=(i>0?" ":"")+e+t)}),n}var M,T,E,A,D="";e.ontransitionend===n&&e.onwebkittransitionend!==n?(D="-webkit-",M="WebkitTransition",T="webkitTransitionEnd transitionend"):(M="transition",T="transitionend"),e.onanimationend===n&&e.onwebkitanimationend!==n?(D="-webkit-",E="WebkitAnimation",A="webkitAnimationEnd animationend"):(E="animation",A="animationend");var I,P="Duration",N="Property",L="Delay",F="IterationCount",B="PlayState",O="$$ngAnimateKey",U="$$ngAnimateCSS3Data",R=3,q=1.5,H=1e3,j={},V=0,z=[],W=null,G=0,K=[];return{enter:function(e,t){return S("enter",e,"ng-enter",t)},leave:function(e,t){return S("leave",e,"ng-leave",t)},move:function(e,t){return S("move",e,"ng-move",t)},beforeSetClass:function(e,t,n,i){var a=x(n,"-remove")+" "+x(t,"-add"),o=$("setClass",e,a);return o?(c(e,i),o):void i()},beforeAddClass:function(e,t,n){var i=$("addClass",e,x(t,"-add"));return i?(c(e,n),i):void n()},beforeRemoveClass:function(e,t,n){var i=$("removeClass",e,x(t,"-remove"));return i?(c(e,n),i):void n()},setClass:function(e,t,n,i){n=x(n,"-remove"),t=x(t,"-add");var a=n+" "+t;return C("setClass",e,a,i)},addClass:function(e,t,n){return C("addClass",e,x(t,"-add"),n)},removeClass:function(e,t,n){return C("removeClass",e,x(t,"-remove"),n)}}}])}])}(window,window.angular),function(e,t){"use strict";function n(){this.$get=["$$sanitizeUri",function(e){return function(t){var n=[];return o(t,c(n,function(t,n){return!/^unsafe/.test(e(t,n))})),n.join("")}}]}function i(e){var n=[],i=c(n,t.noop); return i.chars(e),n.join("")}function a(e){var t,n={},i=e.split(",");for(t=0;t=0&&_[o]!=i;o--);if(o>=0){for(a=_.length-1;a>=o;a--)n.end&&n.end(_[a]);_.length=o}}"string"!=typeof e&&(e=null===e||"undefined"==typeof e?"":""+e);var o,s,c,y,_=[],w=e;for(_.last=function(){return _[_.length-1]};e;){if(y="",s=!0,_.last()&&x[_.last()]?(e=e.replace(new RegExp("(.*)<\\s*\\/\\s*"+_.last()+"[^>]*>","i"),function(e,t){return t=t.replace(g,"$1").replace(v,"$1"),n.chars&&n.chars(r(t)),""}),a("",_.last())):(0===e.indexOf("",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)):f.test(e)?(c=e.match(d),c&&(e=e.substring(c[0].length),c[0].replace(d,a),s=!1)):h.test(e)&&(c=e.match(u),c?(c[4]&&(e=e.substring(c[0].length),c[0].replace(u,i)),s=!1):(y+="<",e=e.substring(1))),s&&(o=e.indexOf("<"),y+=0>o?e:e.substring(0,o),e=0>o?"":e.substring(o),n.chars&&n.chars(r(y)))),e==w)throw l("badparse","The sanitizer was unable to parse the following block of html: {0}",e);w=e}a()}function r(e){if(!e)return"";var t=D.exec(e),n=t[1],i=t[3],a=t[2];return a&&(A.innerHTML=a.replace(//g,">")}function c(e,n){var i=!1,a=t.bind(e,e.push);return{start:function(e,o,r){e=t.lowercase(e),!i&&x[e]&&(i=e),i||M[e]!==!0||(a("<"),a(e),t.forEach(o,function(i,o){var r=t.lowercase(o),c="img"===e&&"src"===r||"background"===r;E[r]!==!0||T[r]===!0&&!n(i,c)||(a(" "),a(o),a('="'),a(s(i)),a('"'))}),a(r?"/>":">"))},end:function(e){e=t.lowercase(e),i||M[e]!==!0||(a("")),e==i&&(i=!1)},chars:function(e){i||a(s(e))}}}var l=t.$$minErr("$sanitize"),u=/^<((?:[a-zA-Z])[\w:-]*)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*(>?)/,d=/^<\/\s*([\w:-]+)[^>]*>/,p=/([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g,h=/^/g,m=/]*?)>/i,v=//g,y=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,_=/([^\#-~| |!])/g,b=a("area,br,col,hr,img,wbr"),w=a("colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr"),$=a("rp,rt"),C=t.extend({},$,w),S=t.extend({},w,a("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")),k=t.extend({},$,a("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")),x=a("script,style"),M=t.extend({},b,S,k,C),T=a("background,cite,href,longdesc,src,usemap"),E=t.extend({},T,a("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")),A=document.createElement("pre"),D=/^(\s*)([\s\S]*?)(\s*)$/;t.module("ngSanitize",[]).provider("$sanitize",n),t.module("ngSanitize").filter("linky",["$sanitize",function(e){var n=/((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"]/,a=/^mailto:/;return function(o,r){function s(e){e&&h.push(i(e))}function c(e,n){h.push("'),s(n),h.push("")}if(!o)return o;for(var l,u,d,p=o,h=[];l=p.match(n);)u=l[0],l[2]==l[3]&&(u="mailto:"+u),d=l.index,s(p.substr(0,d)),c(u,l[0].replace(a,"")),p=p.substring(d+l[0].length);return s(p),e(h.join(""))}}])}(window,window.angular),function(e,t){"use strict";function n(e,n,a){i.directive(e,["$parse","$swipe",function(i,o){var r=75,s=.3,c=30;return function(l,u,d){function p(e){if(!h)return!1;var t=Math.abs(e.y-h.y),i=(e.x-h.x)*n;return f&&r>t&&i>0&&i>c&&s>t/i}var h,f,g=i(d[e]),m=["touch"];t.isDefined(d.ngSwipeDisableMouse)||m.push("mouse"),o.bind(u,{start:function(e){h=e,f=!0},cancel:function(){f=!1},end:function(e,t){p(e)&&l.$apply(function(){u.triggerHandler(a),g(l,{$event:t})})}},m)}}])}var i=t.module("ngTouch",[]);i.factory("$swipe",[function(){function e(e){var t=e.touches&&e.touches.length?e.touches:[e],n=e.changedTouches&&e.changedTouches[0]||e.originalEvent&&e.originalEvent.changedTouches&&e.originalEvent.changedTouches[0]||t[0].originalEvent||t[0];return{x:n.clientX,y:n.clientY}}function n(e,n){var i=[];return t.forEach(e,function(e){var t=a[e][n];t&&i.push(t)}),i.join(" ")}var i=10,a={mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},touch:{start:"touchstart",move:"touchmove",end:"touchend",cancel:"touchcancel"}};return{bind:function(t,a,o){var r,s,c,l,u=!1;o=o||["mouse","touch"],t.on(n(o,"start"),function(t){c=e(t),u=!0,r=0,s=0,l=c,a.start&&a.start(c,t)});var d=n(o,"cancel");d&&t.on(d,function(e){u=!1,a.cancel&&a.cancel(e)}),t.on(n(o,"move"),function(t){if(u&&c){var n=e(t);if(r+=Math.abs(n.x-l.x),s+=Math.abs(n.y-l.y),l=n,!(i>r&&i>s))return s>r?(u=!1,void(a.cancel&&a.cancel(t))):(t.preventDefault(),void(a.move&&a.move(n,t)))}}),t.on(n(o,"end"),function(t){u&&(u=!1,a.end&&a.end(e(t),t))})}}}]),i.config(["$provide",function(e){e.decorator("ngClickDirective",["$delegate",function(e){return e.shift(),e}])}]),i.directive("ngClick",["$parse","$timeout","$rootElement",function(e,n,i){function a(e,t,n,i){return Math.abs(e-n)f)){var t=e.touches&&e.touches.length?e.touches:[e],n=t[0].clientX,i=t[0].clientY;1>n&&1>i||d&&d[0]===n&&d[1]===i||(d&&(d=null),"label"===e.target.tagName.toLowerCase()&&(d=[n,i]),o(u,n,i)||(e.stopPropagation(),e.preventDefault(),e.target&&e.target.blur()))}}function s(e){var t=e.touches&&e.touches.length?e.touches:[e],i=t[0].clientX,a=t[0].clientY;u.push(i,a),n(function(){for(var e=0;en&&h>y&&(c(m,v),r&&r.blur(),t.isDefined(a.disabled)&&a.disabled!==!1||i.triggerHandler("click",[e])),o()}),i.onclick=function(){},i.on("click",function(e,t){n.$apply(function(){d(n,{$event:t||e})})}),i.on("mousedown",function(){i.addClass(m)}),i.on("mousemove mouseup",function(){i.removeClass(m)})}}]),n("ngSwipeLeft",-1,"swipeleft"),n("ngSwipeRight",1,"swiperight")}(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.transition",[]).factory("$transition",["$q","$timeout","$rootScope",function(e,t,n){function i(e){for(var t in e)if(void 0!==o.style[t])return e[t]}var a=function(i,o,r){r=r||{};var s=e.defer(),c=a[r.animation?"animationEndEventName":"transitionEndEventName"],l=function(){n.$apply(function(){i.unbind(c,l),s.resolve(i)})};return c&&i.bind(c,l),t(function(){angular.isString(o)?i.addClass(o):angular.isFunction(o)?o(i):angular.isObject(o)&&i.css(o),c||s.resolve(i)}),s.promise.cancel=function(){c&&i.unbind(c,l),s.reject("Transition cancelled")},s.promise},o=document.createElement("trans"),r={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",transition:"transitionend"},s={WebkitTransition:"webkitAnimationEnd",MozTransition:"animationend",OTransition:"oAnimationEnd",transition:"animationend"};return a.transitionEndEventName=i(r),a.animationEndEventName=i(s),a}]),angular.module("ui.bootstrap.collapse",["ui.bootstrap.transition"]).directive("collapse",["$transition",function(e){return{link:function(t,n,i){function a(t){function i(){l===a&&(l=void 0)}var a=e(n,t);return l&&l.cancel(),l=a,a.then(i,i),a}function o(){u?(u=!1,r()):(n.removeClass("collapse").addClass("collapsing"),a({height:n[0].scrollHeight+"px"}).then(r))}function r(){n.removeClass("collapsing"),n.addClass("collapse in"),n.css({height:"auto"})}function s(){if(u)u=!1,c(),n.css({height:0});else{n.css({height:n[0].scrollHeight+"px"});{n[0].offsetWidth}n.removeClass("collapse in").addClass("collapsing"),a({height:0}).then(c)}}function c(){n.removeClass("collapsing"),n.addClass("collapse")}var l,u=!0;t.$watch(i.collapse,function(e){e?s():o()})}}}]),angular.module("ui.bootstrap.dropdownToggle",[]).directive("dropdownToggle",["$document","$location",function(e){var t=null,n=angular.noop;return{restrict:"CA",link:function(i,a){i.$watch("$location.path",function(){n()}),a.parent().bind("click",function(){n()}),a.bind("click",function(i){var o=a===t;i.preventDefault(),i.stopPropagation(),t&&n(),o||a.hasClass("disabled")||a.prop("disabled")||(a.parent().addClass("open"),t=a,n=function(i){i&&(i.preventDefault(),i.stopPropagation()),e.unbind("click",n),a.parent().removeClass("open"),n=angular.noop,t=null},e.bind("click",n))})}}}]),angular.module("ui.bootstrap.modal",["ui.bootstrap.transition"]).factory("$$stackedMap",function(){return{createNew:function(){var e=[];return{add:function(t,n){e.push({key:t,value:n})},get:function(t){for(var n=0;n0)}function c(){if(u&&-1==r()){var e=d;l(u,d,0,function(){e.$destroy(),e=null}),u=void 0,d=void 0}}function l(n,i,a,o){function r(){r.done||(r.done=!0,n.remove(),o&&o())}i.animate=!1;var s=e.transitionEndEventName;if(s){var c=t(r,a);n.bind(s,function(){t.cancel(c),r(),i.$apply()})}else t(r,0)}var u,d,p="modal-open",h=o.createNew(),f={};return a.$watch(r,function(e){d&&(d.index=e)}),n.bind("keydown",function(e){var t;27===e.which&&(t=h.top(),t&&t.value.keyboard&&a.$apply(function(){f.dismiss(t.key)}))}),f.open=function(e,t){h.add(e,{deferred:t.deferred,modalScope:t.scope,backdrop:t.backdrop,keyboard:t.keyboard});var o=n.find("body").eq(0),s=r();s>=0&&!u&&(d=a.$new(!0),d.index=s,u=i("
")(d),o.append(u));var c=angular.element("
");c.attr("window-class",t.windowClass),c.attr("index",h.length()-1),c.attr("animate","animate"),c.attr("nav","nav"),c.html(t.content);var l=i(c)(t.scope);h.top().value.modalDomEl=l,o.append(l),o.addClass(p)},f.close=function(e,t){var n=h.get(e).value;n&&(n.deferred.resolve(t),s(e))},f.dismiss=function(e,t){var n=h.get(e).value;n&&(n.deferred.reject(t),s(e))},f.dismissAll=function(e){for(var t=this.getTop();t;)this.dismiss(t.key,e),t=this.getTop()},f.getTop=function(){return h.top()},f}]).provider("$modal",function(){var e={options:{backdrop:!0,keyboard:!0},$get:["$injector","$rootScope","$q","$http","$templateCache","$controller","$modalStack",function(t,n,i,a,o,r,s){function c(e){return e.template?i.when(e.template):a.get(e.templateUrl,{cache:o}).then(function(e){return e.data})}function l(e){var n=[];return angular.forEach(e,function(e){(angular.isFunction(e)||angular.isArray(e))&&n.push(i.when(t.invoke(e)))}),n}var u={};return u.open=function(t){var a=i.defer(),o=i.defer(),u={result:a.promise,opened:o.promise,close:function(e){s.close(u,e)},dismiss:function(e){s.dismiss(u,e)}};if(t=angular.extend({},e.options,t),t.resolve=t.resolve||{},!t.template&&!t.templateUrl)throw new Error("One of template or templateUrl options is required.");var d=i.all([c(t)].concat(l(t.resolve)));return d.then(function(e){var i=(t.scope||n).$new();i.$close=u.close,i.$dismiss=u.dismiss;var o,c={},l=1;t.controller&&(c.$scope=i,c.$modalInstance=u,angular.forEach(t.resolve,function(t,n){c[n]=e[l++]}),o=r(t.controller,c)),s.open(u,{scope:i,deferred:a,content:e[0],backdrop:t.backdrop,keyboard:t.keyboard,windowClass:t.windowClass})},function(e){a.reject(e)}),d.then(function(){o.resolve(!0)},function(){o.reject(!1)}),u},u}]};return e}),angular.module("ui.bootstrap.position",[]).factory("$position",["$document","$window",function(e,t){function n(e,n){return e.currentStyle?e.currentStyle[n]:t.getComputedStyle?t.getComputedStyle(e)[n]:e.style[n]}function i(e){return"static"===(n(e,"position")||"static")}var a=function(t){for(var n=e[0],a=t.offsetParent||n;a&&a!==n&&i(a);)a=a.offsetParent;return a||n};return{position:function(t){var n=this.offset(t),i={top:0,left:0},o=a(t[0]);o!=e[0]&&(i=this.offset(angular.element(o)),i.top+=o.clientTop-o.scrollTop,i.left+=o.clientLeft-o.scrollLeft);var r=t[0].getBoundingClientRect();return{width:r.width||t.prop("offsetWidth"),height:r.height||t.prop("offsetHeight"),top:n.top-i.top,left:n.left-i.left}},offset:function(n){var i=n[0].getBoundingClientRect();return{width:i.width||n.prop("offsetWidth"),height:i.height||n.prop("offsetHeight"),top:i.top+(t.pageYOffset||e[0].body.scrollTop||e[0].documentElement.scrollTop),left:i.left+(t.pageXOffset||e[0].body.scrollLeft||e[0].documentElement.scrollLeft)}}}}]),angular.module("ui.bootstrap.bindHtml",[]).directive("bindHtmlUnsafe",function(){return function(e,t,n){t.addClass("ng-binding").data("$binding",n.bindHtmlUnsafe),e.$watch(n.bindHtmlUnsafe,function(e){t.html(e||"")})}}),angular.module("ui.bootstrap.tooltip",["ui.bootstrap.position","ui.bootstrap.bindHtml"]).provider("$tooltip",function(){function e(e){var t=/[A-Z]/g,n="-";return e.replace(t,function(e,t){return(t?n:"")+e.toLowerCase()})}var t={placement:"top",animation:!0,popupDelay:0},n={mouseenter:"mouseleave",click:"click",focus:"blur"},i={};this.options=function(e){angular.extend(i,e)},this.setTriggers=function(e){angular.extend(n,e)},this.$get=["$window","$compile","$timeout","$parse","$document","$position","$interpolate",function(a,o,r,s,c,l,u){return function(a,d,p){function h(e){var t=e||f.trigger||p,i=n[t]||t;return{show:t,hide:i}}var f=angular.extend({},t,i),g=e(a),m=u.startSymbol(),v=u.endSymbol(),y="
';return{restrict:"EA",scope:!0,compile:function(){var e=o(y);return function(t,n,i){function o(){t.tt_isOpen?p():u()}function u(){(!k||t.$eval(i[d+"Enable"]))&&(t.tt_popupDelay?(w=r(g,t.tt_popupDelay,!1),w.then(function(e){e()})):g()())}function p(){t.$apply(function(){m()})}function g(){return t.tt_content?(v(),b&&r.cancel(b),_.css({top:0,left:0,display:"block"}),$?c.find("body").append(_):n.after(_),x(),t.tt_isOpen=!0,t.$digest(),x):angular.noop}function m(){t.tt_isOpen=!1,r.cancel(w),t.tt_animation?b=r(y,500):y()}function v(){_&&y(),_=e(t,function(){}),t.$digest()}function y(){_&&(_.remove(),_=null)}var _,b,w,$=angular.isDefined(f.appendToBody)?f.appendToBody:!1,C=h(void 0),S=!1,k=angular.isDefined(i[d+"Enable"]),x=function(){var e,i,a,o;switch(e=$?l.offset(n):l.position(n),i=_.prop("offsetWidth"),a=_.prop("offsetHeight"),t.tt_placement){case"right":o={top:e.top+e.height/2-a/2,left:e.left+e.width};break;case"bottom":o={top:e.top+e.height,left:e.left+e.width/2-i/2};break;case"left":o={top:e.top+e.height/2-a/2,left:e.left-i};break;default:o={top:e.top-a,left:e.left+e.width/2-i/2}}o.top+="px",o.left+="px",_.css(o)};t.tt_isOpen=!1,i.$observe(a,function(e){t.tt_content=e,!e&&t.tt_isOpen&&m()}),i.$observe(d+"Title",function(e){t.tt_title=e}),i.$observe(d+"Placement",function(e){t.tt_placement=angular.isDefined(e)?e:f.placement}),i.$observe(d+"PopupDelay",function(e){var n=parseInt(e,10);t.tt_popupDelay=isNaN(n)?f.popupDelay:n});var M=function(){S&&(n.unbind(C.show,u),n.unbind(C.hide,p))};i.$observe(d+"Trigger",function(e){M(),C=h(e),C.show===C.hide?n.bind(C.show,o):(n.bind(C.show,u),n.bind(C.hide,p)),S=!0});var T=t.$eval(i[d+"Animation"]);t.tt_animation=angular.isDefined(T)?!!T:f.animation,i.$observe(d+"AppendToBody",function(e){$=angular.isDefined(e)?s(e)(t):$}),$&&t.$on("$locationChangeSuccess",function(){t.tt_isOpen&&m()}),t.$on("$destroy",function(){r.cancel(b),r.cancel(w),M(),y()})}}}}}]}).directive("tooltipPopup",function(){return{restrict:"EA",replace:!0,scope:{content:"@",placement:"@",animation:"&",isOpen:"&"},templateUrl:"template/tooltip/tooltip-popup.html"}}).directive("tooltip",["$tooltip",function(e){return e("tooltip","tooltip","mouseenter")}]).directive("tooltipHtmlUnsafePopup",function(){return{restrict:"EA",replace:!0,scope:{content:"@",placement:"@",animation:"&",isOpen:"&"},templateUrl:"template/tooltip/tooltip-html-unsafe-popup.html"}}).directive("tooltipHtmlUnsafe",["$tooltip",function(e){return e("tooltipHtmlUnsafe","tooltip","mouseenter")}]),angular.module("template/modal/backdrop.html",[]).run(["$templateCache",function(e){e.put("template/modal/backdrop.html",'')}]),angular.module("template/modal/window.html",[]).run(["$templateCache",function(e){e.put("template/modal/window.html",'')}]),angular.module("template/tooltip/tooltip-html-unsafe-popup.html",[]).run(["$templateCache",function(e){e.put("template/tooltip/tooltip-html-unsafe-popup.html",'
\n
\n
\n
\n')}]),angular.module("template/tooltip/tooltip-popup.html",[]).run(["$templateCache",function(e){e.put("template/tooltip/tooltip-popup.html",'
\n
\n
\n
\n')}]);var dbits,canary=0xdeadbeefcafe,j_lm=15715070==(16777215&canary);j_lm&&"Microsoft Internet Explorer"==navigator.appName?(BigInteger.prototype.am=am2,dbits=30):j_lm&&"Netscape"!=navigator.appName?(BigInteger.prototype.am=am1,dbits=26):(BigInteger.prototype.am=am3,dbits=28),BigInteger.prototype.DB=dbits,BigInteger.prototype.DM=(1<=vv;++vv)BI_RC[rr++]=vv;for(rr="a".charCodeAt(0),vv=10;36>vv;++vv)BI_RC[rr++]=vv;for(rr="A".charCodeAt(0),vv=10;36>vv;++vv)BI_RC[rr++]=vv;Classic.prototype.convert=cConvert,Classic.prototype.revert=cRevert,Classic.prototype.reduce=cReduce,Classic.prototype.mulTo=cMulTo,Classic.prototype.sqrTo=cSqrTo,Montgomery.prototype.convert=montConvert,Montgomery.prototype.revert=montRevert,Montgomery.prototype.reduce=montReduce,Montgomery.prototype.mulTo=montMulTo,Montgomery.prototype.sqrTo=montSqrTo,BigInteger.prototype.copyTo=bnpCopyTo,BigInteger.prototype.fromInt=bnpFromInt,BigInteger.prototype.fromString=bnpFromString,BigInteger.prototype.clamp=bnpClamp,BigInteger.prototype.dlShiftTo=bnpDLShiftTo,BigInteger.prototype.drShiftTo=bnpDRShiftTo,BigInteger.prototype.lShiftTo=bnpLShiftTo,BigInteger.prototype.rShiftTo=bnpRShiftTo,BigInteger.prototype.subTo=bnpSubTo,BigInteger.prototype.multiplyTo=bnpMultiplyTo,BigInteger.prototype.squareTo=bnpSquareTo,BigInteger.prototype.divRemTo=bnpDivRemTo,BigInteger.prototype.invDigit=bnpInvDigit,BigInteger.prototype.isEven=bnpIsEven,BigInteger.prototype.exp=bnpExp,BigInteger.prototype.toString=bnToString,BigInteger.prototype.negate=bnNegate,BigInteger.prototype.abs=bnAbs,BigInteger.prototype.compareTo=bnCompareTo,BigInteger.prototype.bitLength=bnBitLength,BigInteger.prototype.mod=bnMod,BigInteger.prototype.modPowInt=bnModPowInt,BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=nMulTo,NullExp.prototype.sqrTo=nSqrTo,Barrett.prototype.convert=barrettConvert,Barrett.prototype.revert=barrettRevert,Barrett.prototype.reduce=barrettReduce,Barrett.prototype.mulTo=barrettMulTo,Barrett.prototype.sqrTo=barrettSqrTo;var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],lplim=(1<<26)/lowprimes[lowprimes.length-1];BigInteger.prototype.chunkSize=bnpChunkSize,BigInteger.prototype.toRadix=bnpToRadix,BigInteger.prototype.fromRadix=bnpFromRadix,BigInteger.prototype.fromNumber=bnpFromNumber,BigInteger.prototype.bitwiseTo=bnpBitwiseTo,BigInteger.prototype.changeBit=bnpChangeBit,BigInteger.prototype.addTo=bnpAddTo,BigInteger.prototype.dMultiply=bnpDMultiply,BigInteger.prototype.dAddOffset=bnpDAddOffset,BigInteger.prototype.multiplyLowerTo=bnpMultiplyLowerTo,BigInteger.prototype.multiplyUpperTo=bnpMultiplyUpperTo,BigInteger.prototype.modInt=bnpModInt,BigInteger.prototype.millerRabin=bnpMillerRabin,BigInteger.prototype.clone=bnClone,BigInteger.prototype.intValue=bnIntValue,BigInteger.prototype.byteValue=bnByteValue,BigInteger.prototype.shortValue=bnShortValue,BigInteger.prototype.signum=bnSigNum,BigInteger.prototype.toByteArray=bnToByteArray,BigInteger.prototype.equals=bnEquals,BigInteger.prototype.min=bnMin,BigInteger.prototype.max=bnMax,BigInteger.prototype.and=bnAnd,BigInteger.prototype.or=bnOr,BigInteger.prototype.xor=bnXor,BigInteger.prototype.andNot=bnAndNot,BigInteger.prototype.not=bnNot,BigInteger.prototype.shiftLeft=bnShiftLeft,BigInteger.prototype.shiftRight=bnShiftRight,BigInteger.prototype.getLowestSetBit=bnGetLowestSetBit,BigInteger.prototype.bitCount=bnBitCount,BigInteger.prototype.testBit=bnTestBit,BigInteger.prototype.setBit=bnSetBit,BigInteger.prototype.clearBit=bnClearBit,BigInteger.prototype.flipBit=bnFlipBit,BigInteger.prototype.add=bnAdd,BigInteger.prototype.subtract=bnSubtract,BigInteger.prototype.multiply=bnMultiply,BigInteger.prototype.divide=bnDivide,BigInteger.prototype.remainder=bnRemainder,BigInteger.prototype.divideAndRemainder=bnDivideAndRemainder,BigInteger.prototype.modPow=bnModPow,BigInteger.prototype.modInverse=bnModInverse,BigInteger.prototype.pow=bnPow,BigInteger.prototype.gcd=bnGCD,BigInteger.prototype.isProbablePrime=bnIsProbablePrime,BigInteger.prototype.square=bnSquare;var rng_state,rng_pool,rng_pptr;if(null==rng_pool){rng_pool=new Array,rng_pptr=0;var global="undefined"!=typeof window?window:this,t;if(global&&global.crypto&&global.crypto.getRandomValues){var ua=new Uint8Array(32);for(global.crypto.getRandomValues(ua),t=0;32>t;++t)rng_pool[rng_pptr++]=ua[t]}if("Netscape"==navigator.appName&&navigator.appVersion<"5"&&global&&global.crypto){var z=global.crypto.random(32);for(t=0;trng_pptr;)t=Math.floor(65536*Math.random()),rng_pool[rng_pptr++]=t>>>8,rng_pool[rng_pptr++]=255&t;rng_pptr=0,rng_seed_time()}SecureRandom.prototype.nextBytes=rng_get_bytes,Arcfour.prototype.init=ARC4init,Arcfour.prototype.next=ARC4next;var rng_psize=256,CryptoJS=CryptoJS||function(e,t){var n={},i=n.lib={},a=i.Base=function(){function e(){}return{extend:function(t){e.prototype=this;var n=new e;return t&&n.mixIn(t),n.hasOwnProperty("init")||(n.init=function(){n.$super.init.apply(this,arguments)}),n.init.prototype=n,n.$super=this,n},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),o=i.WordArray=a.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||s).stringify(this)},concat:function(e){var t=this.words,n=e.words,i=this.sigBytes,a=e.sigBytes;if(this.clamp(),i%4)for(var o=0;a>o;o++){var r=n[o>>>2]>>>24-o%4*8&255;t[i+o>>>2]|=r<<24-(i+o)%4*8}else if(n.length>65535)for(var o=0;a>o;o+=4)t[i+o>>>2]=n[o>>>2];else for(var o=0;o>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],i=0;t>i;i+=4)n.push(4294967296*e.random()|0);return new o.init(n,t)}}),r=n.enc={},s=r.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,i=[],a=0;n>a;a++){var o=t[a>>>2]>>>24-a%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,n=[],i=0;t>i;i+=2)n[i>>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new o.init(n,t/2)}},c=r.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,i=[],a=0;n>a;a++){var o=t[a>>>2]>>>24-a%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(e){for(var t=e.length,n=[],i=0;t>i;i++)n[i>>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new o.init(n,t)}},l=r.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},u=i.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,i=n.words,a=n.sigBytes,r=this.blockSize,s=4*r,c=a/s;c=t?e.ceil(c):e.max((0|c)-this._minBufferSize,0);var l=c*r,u=e.min(4*l,a);if(l){for(var d=0;l>d;d+=r)this._doProcessBlock(i,d);var p=i.splice(0,l);n.sigBytes-=u}return new o.init(p,u)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),d=(i.Hasher=u.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){u.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){e&&this._append(e);var t=this._doFinalize();return t},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new d.HMAC.init(e,n).finalize(t)}}}),n.algo={});return n}(Math);CryptoJS.lib.Cipher||function(e){var t=CryptoJS,n=t.lib,i=n.Base,a=n.WordArray,o=n.BufferedBlockAlgorithm,r=t.enc,s=(r.Utf8,r.Base64),c=t.algo,l=c.EvpKDF,u=n.Cipher=o.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,n){this.cfg=this.cfg.extend(n),this._xformMode=e,this._key=t,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){e&&this._append(e);var t=this._doFinalize();return t},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?$:_}return function(t){return{encrypt:function(n,i,a){return e(i).encrypt(t,n,i,a)},decrypt:function(n,i,a){return e(i).decrypt(t,n,i,a)}}}}()}),d=(n.StreamCipher=u.extend({_doFinalize:function(){var e=this._process(!0);return e},blockSize:1}),t.mode={}),p=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),h=d.CBC=function(){function t(t,n,i){var a=this._iv;if(a){var o=a;this._iv=e}else var o=this._prevBlock;for(var r=0;i>r;r++)t[n+r]^=o[r]}var n=p.extend();return n.Encryptor=n.extend({processBlock:function(e,n){var i=this._cipher,a=i.blockSize;t.call(this,e,n,a),i.encryptBlock(e,n),this._prevBlock=e.slice(n,n+a)}}),n.Decryptor=n.extend({processBlock:function(e,n){var i=this._cipher,a=i.blockSize,o=e.slice(n,n+a);i.decryptBlock(e,n),t.call(this,e,n,a),this._prevBlock=o}}),n}(),f=(d.IGE=function(){function t(e,t,n,i){for(var a=0;i>a;a++)e[n+a]^=t[a]}var n=p.extend();return n.Encryptor=n.extend({processBlock:function(n,i){var a=this._cipher,o=a.blockSize;this._ivp===e&&(this._ivp=this._iv.slice(0,o),this._iv2p=this._iv.slice(o,o+o));var r=n.slice(i,i+o);t(n,this._ivp,i,o),a.encryptBlock(n,i),t(n,this._iv2p,i,o),this._ivp=n.slice(i,i+o),this._iv2p=r}}),n.Decryptor=n.extend({processBlock:function(n,i){var a=this._cipher,o=a.blockSize;this._ivp===e&&(this._ivp=this._iv.slice(0,o),this._iv2p=this._iv.slice(o,2*o));var r=n.slice(i,i+o);t(n,this._iv2p,i,o),a.decryptBlock(n,i),t(n,this._ivp,i,o),this._ivp=r,this._iv2p=n.slice(i,i+o) }}),n}(),t.pad={}),g=f.Pkcs7={pad:function(e,t){for(var n=4*t,i=n-e.sigBytes%n,o=i<<24|i<<16|i<<8|i,r=[],s=0;i>s;s+=4)r.push(o);var c=a.create(r,i);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},m=(f.NoPadding={pad:function(){},unpad:function(){}},n.BlockCipher=u.extend({cfg:u.cfg.extend({mode:h,padding:g}),reset:function(){u.reset.call(this);var e=this.cfg,t=e.iv,n=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=n.createEncryptor;else{var i=n.createDecryptor;this._minBufferSize=1}this._mode=i.call(n,this,t&&t.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else{var t=this._process(!0);e.unpad(t)}return t},blockSize:4}),n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}})),v=t.format={},y=v.OpenSSL={stringify:function(e){var t=e.ciphertext,n=e.salt;if(n)var i=a.create([1398893684,1701076831]).concat(n).concat(t);else var i=t;return i.toString(s)},parse:function(e){var t=s.parse(e),n=t.words;if(1398893684==n[0]&&1701076831==n[1]){var i=a.create(n.slice(2,4));n.splice(0,4),t.sigBytes-=16}return m.create({ciphertext:t,salt:i})}},_=n.SerializableCipher=i.extend({cfg:i.extend({format:y}),encrypt:function(e,t,n,i){i=this.cfg.extend(i);var a=e.createEncryptor(n,i),o=a.finalize(t),r=a.cfg;return m.create({ciphertext:o,key:n,iv:r.iv,algorithm:e,mode:r.mode,padding:r.padding,blockSize:e.blockSize,formatter:i.format})},decrypt:function(e,t,n,i){i=this.cfg.extend(i),t=this._parse(t,i.format);var a=e.createDecryptor(n,i).finalize(t.ciphertext);return a},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),b=t.kdf={},w=b.OpenSSL={execute:function(e,t,n,i){i||(i=a.random(8));var o=l.create({keySize:t+n}).compute(e,i),r=a.create(o.words.slice(t),4*n);return o.sigBytes=4*t,m.create({key:o,iv:r,salt:i})}},$=n.PasswordBasedCipher=_.extend({cfg:_.cfg.extend({kdf:w}),encrypt:function(e,t,n,i){i=this.cfg.extend(i);var a=i.kdf.execute(n,e.keySize,e.ivSize);i.iv=a.iv;var o=_.encrypt.call(this,e,t,a.key,i);return o.mixIn(a),o},decrypt:function(e,t,n,i){i=this.cfg.extend(i),t=this._parse(t,i.format);var a=i.kdf.execute(n,e.keySize,e.ivSize,t.salt);i.iv=a.iv;var o=_.decrypt.call(this,e,t,a.key,i);return o}})}(),function(){var e=CryptoJS,t=e.lib,n=t.BlockCipher,i=e.algo,a=[],o=[],r=[],s=[],c=[],l=[],u=[],d=[],p=[],h=[];!function(){for(var e=[],t=0;256>t;t++)e[t]=128>t?t<<1:t<<1^283;for(var n=0,i=0,t=0;256>t;t++){var f=i^i<<1^i<<2^i<<3^i<<4;f=f>>>8^255&f^99,a[n]=f,o[f]=n;var g=e[n],m=e[g],v=e[m],y=257*e[f]^16843008*f;r[n]=y<<24|y>>>8,s[n]=y<<16|y>>>16,c[n]=y<<8|y>>>24,l[n]=y;var y=16843009*v^65537*m^257*g^16843008*n;u[f]=y<<24|y>>>8,d[f]=y<<16|y>>>16,p[f]=y<<8|y>>>24,h[f]=y,n?(n=g^e[e[e[v^g]]],i^=e[e[i]]):n=i=1}}();var f=[0,1,2,4,8,16,32,64,128,27,54],g=i.AES=n.extend({_doReset:function(){for(var e=this._key,t=e.words,n=e.sigBytes/4,i=this._nRounds=n+6,o=4*(i+1),r=this._keySchedule=[],s=0;o>s;s++)if(n>s)r[s]=t[s];else{var c=r[s-1];s%n?n>6&&s%n==4&&(c=a[c>>>24]<<24|a[c>>>16&255]<<16|a[c>>>8&255]<<8|a[255&c]):(c=c<<8|c>>>24,c=a[c>>>24]<<24|a[c>>>16&255]<<16|a[c>>>8&255]<<8|a[255&c],c^=f[s/n|0]<<24),r[s]=r[s-n]^c}for(var l=this._invKeySchedule=[],g=0;o>g;g++){var s=o-g;if(g%4)var c=r[s];else var c=r[s-4];l[g]=4>g||4>=s?c:u[a[c>>>24]]^d[a[c>>>16&255]]^p[a[c>>>8&255]]^h[a[255&c]]}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,r,s,c,l,a)},decryptBlock:function(e,t){var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n,this._doCryptBlock(e,t,this._invKeySchedule,u,d,p,h,o);var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,i,a,o,r,s){for(var c=this._nRounds,l=e[t]^n[0],u=e[t+1]^n[1],d=e[t+2]^n[2],p=e[t+3]^n[3],h=4,f=1;c>f;f++){var g=i[l>>>24]^a[u>>>16&255]^o[d>>>8&255]^r[255&p]^n[h++],m=i[u>>>24]^a[d>>>16&255]^o[p>>>8&255]^r[255&l]^n[h++],v=i[d>>>24]^a[p>>>16&255]^o[l>>>8&255]^r[255&u]^n[h++],y=i[p>>>24]^a[l>>>16&255]^o[u>>>8&255]^r[255&d]^n[h++];l=g,u=m,d=v,p=y}var g=(s[l>>>24]<<24|s[u>>>16&255]<<16|s[d>>>8&255]<<8|s[255&p])^n[h++],m=(s[u>>>24]<<24|s[d>>>16&255]<<16|s[p>>>8&255]<<8|s[255&l])^n[h++],v=(s[d>>>24]<<24|s[p>>>16&255]<<16|s[l>>>8&255]<<8|s[255&u])^n[h++],y=(s[p>>>24]<<24|s[l>>>16&255]<<16|s[u>>>8&255]<<8|s[255&d])^n[h++];e[t]=g,e[t+1]=m,e[t+2]=v,e[t+3]=y},keySize:8});e.AES=n._createHelper(g)}();var sha1;!function(e){function t(e){for(var t,n="",i=7;i>=0;--i)t=e>>>(i<<2)&15,n+=t.toString(16);return n}function n(e){for(var t,n=[],i=3;i>=0;--i)t=e>>8*i&255,n.push(t);return n}function i(e,t){return e<>>32-t}function a(e){e=e.replace(/[\u0080-\u07ff]/g,function(e){var t=e.charCodeAt(0);return String.fromCharCode(192|t>>6,128|63&t)}),e=e.replace(/[\u0080-\uffff]/g,function(e){var t=e.charCodeAt(0);return String.fromCharCode(224|t>>12,128|t>>6&63,128|63&t)});for(var t=e.length,n=new Uint8Array(t),i=0;t>i;++i)n[i]=e.charCodeAt(i);return n.buffer}function o(e){for(var t=e.length,n=new Uint8Array(t),i=0;t>i;++i)n[i]=e[i];return n.buffer}function r(e,r){var s;s=e instanceof ArrayBuffer?e:"[object Array]"==Object.prototype.toString.apply(e)?o(e):a(String(e));var u,d,p=1732584193,h=4023233417,f=2562383102,g=271733878,m=3285377520,v=s.byteLength,y=v<<3,_=y+65,b=Math.ceil(_/512)<<9,w=b>>>3,$=w>>>2,C=new l($),S=C.bytes,k=new Uint32Array(80),x=new Uint8Array(s);for(u=0;v>u;++u)S[u]=x[u];for(S[v]=128,C.set($-2,Math.floor(y/c)),C.set($-1,4294967295&y),u=0;$>u;u+=16){for(d=0;16>d;++d)k[d]=C.get(u+d);for(;80>d;++d)k[d]=i(k[d-3]^k[d-8]^k[d-14]^k[d-16],1);var M,T,E,A=p,D=h,I=f,P=g,N=m;for(d=0;80>d;++d)20>d?(M=D&I|~D&P,T=1518500249):40>d?(M=D^I^P,T=1859775393):60>d?(M=D&I^D&P^I&P,T=2400959708):(M=D^I^P,T=3395469782),E=i(A,5)+M+N+T+k[d]&4294967295,N=P,P=I,I=i(D,30),D=A,A=E;p=p+A&4294967295,h=h+D&4294967295,f=f+I&4294967295,g=g+P&4294967295,m=m+N&4294967295}return r?n(p).concat(n(h),n(f),n(g),n(m)):t(p)+t(h)+t(f)+t(g)+t(m)}var s=Math.pow(2,24),c=Math.pow(2,32),l=function(){function e(e){this.bytes=new Uint8Array(e<<2)}return e.prototype.get=function(e){return e<<=2,this.bytes[e]*s+(this.bytes[e+1]<<16|this.bytes[e+2]<<8|this.bytes[e+3])},e.prototype.set=function(e,t){var n=Math.floor(t/s),i=t-n*s;e<<=2,this.bytes[e]=n,this.bytes[e+1]=i>>16,this.bytes[e+2]=i>>8&255,this.bytes[e+3]=255&i},e}();e.hash=r}(sha1||(sha1={})),function(){"use strict";function e(e){throw e}function t(e,t){var n=e.split("."),i=d;!(n[0]in i)&&i.execScript&&i.execScript("var "+n[0]);for(var a;n.length&&(a=n.shift());)n.length||t===u?i=i[a]?i[a]:i[a]={}:i[a]=t}function n(e,t,n){var i,a="number"==typeof t?t:t=0,o="number"==typeof n?n:e.length;for(i=-1,a=7&o;a--;++t)i=i>>>8^v[255&(i^e[t])];for(a=o>>3;a--;t+=8)i=i>>>8^v[255&(i^e[t])],i=i>>>8^v[255&(i^e[t+1])],i=i>>>8^v[255&(i^e[t+2])],i=i>>>8^v[255&(i^e[t+3])],i=i>>>8^v[255&(i^e[t+4])],i=i>>>8^v[255&(i^e[t+5])],i=i>>>8^v[255&(i^e[t+6])],i=i>>>8^v[255&(i^e[t+7])];return(4294967295^i)>>>0}function i(){}function a(e){var t,n,i,a,o,r,s,c,l,u=e.length,d=0,h=Number.POSITIVE_INFINITY;for(c=0;u>c;++c)e[c]>d&&(d=e[c]),e[c]=i;){for(c=0;u>c;++c)if(e[c]===i){for(r=0,s=a,l=0;i>l;++l)r=r<<1|1&s,s>>=1;for(l=r;t>l;l+=o)n[l]=i<<16|c;++a}++i,a<<=1,o<<=1}return[n,d,h]}function o(t,n){switch(this.i=[],this.j=32768,this.d=this.f=this.c=this.n=0,this.input=p?new Uint8Array(t):t,this.o=!1,this.k=$,this.w=!1,(n||!(n={}))&&(n.index&&(this.c=n.index),n.bufferSize&&(this.j=n.bufferSize),n.bufferType&&(this.k=n.bufferType),n.resize&&(this.w=n.resize)),this.k){case w:this.a=32768,this.b=new(p?Uint8Array:Array)(32768+this.j+258);break;case $:this.a=0,this.b=new(p?Uint8Array:Array)(this.j),this.e=this.D,this.q=this.A,this.l=this.C;break;default:e(Error("invalid inflate mode"))}}function r(t,n){for(var i,a=t.f,o=t.d,r=t.input,s=t.c;n>o;)i=r[s++],i===u&&e(Error("input buffer is broken")),a|=i<>>n,t.d=o-n,t.c=s,i}function s(e,t){for(var n,i,a,o=e.f,r=e.d,s=e.input,c=e.c,l=t[0],d=t[1];d>r&&(n=s[c++],n!==u);)o|=n<>>16,e.f=o>>a,e.d=r-a,e.c=c,65535&i}function c(e){function t(e,t,n){var i,a,o,c;for(c=0;e>c;)switch(i=s(this,t)){case 16:for(o=3+r(this,2);o--;)n[c++]=a;break;case 17:for(o=3+r(this,3);o--;)n[c++]=0;a=0;break;case 18:for(o=11+r(this,7);o--;)n[c++]=0;a=0;break;default:a=n[c++]=i}return n}var n,i,o,c,l=r(e,5)+257,u=r(e,5)+1,d=r(e,4)+4,h=new(p?Uint8Array:Array)(x.length);for(c=0;d>c;++c)h[x[c]]=r(e,3);n=a(h),i=new(p?Uint8Array:Array)(l),o=new(p?Uint8Array:Array)(u),e.l(a(t.call(e,l,n,i)),a(t.call(e,u,n,o)))}function l(e){this.input=e,this.c=0,this.m=[],this.s=!1}var u=void 0,d=this,p="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array;new(p?Uint8Array:Array)(256);var h;for(h=0;256>h;++h)for(var f=h,g=7,f=f>>>1;f;f>>>=1)--g;var m=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],v=p?new Uint32Array(m):m;i.prototype.getName=function(){return this.name},i.prototype.getData=function(){return this.data},i.prototype.G=function(){return this.H},t("Zlib.GunzipMember",i),t("Zlib.GunzipMember.prototype.getName",i.prototype.getName),t("Zlib.GunzipMember.prototype.getData",i.prototype.getData),t("Zlib.GunzipMember.prototype.getMtime",i.prototype.G);var y,_=[];for(y=0;288>y;y++)switch(!0){case 143>=y:_.push([y+48,8]);break;case 255>=y:_.push([y-144+400,9]);break;case 279>=y:_.push([y-256+0,7]);break;case 287>=y:_.push([y-280+192,8]);break;default:e("invalid literal: "+y)}var b=function(){function t(t){switch(!0){case 3===t:return[257,t-3,0];case 4===t:return[258,t-4,0];case 5===t:return[259,t-5,0];case 6===t:return[260,t-6,0];case 7===t:return[261,t-7,0];case 8===t:return[262,t-8,0];case 9===t:return[263,t-9,0];case 10===t:return[264,t-10,0];case 12>=t:return[265,t-11,1];case 14>=t:return[266,t-13,1];case 16>=t:return[267,t-15,1];case 18>=t:return[268,t-17,1];case 22>=t:return[269,t-19,2];case 26>=t:return[270,t-23,2];case 30>=t:return[271,t-27,2];case 34>=t:return[272,t-31,2];case 42>=t:return[273,t-35,3];case 50>=t:return[274,t-43,3];case 58>=t:return[275,t-51,3];case 66>=t:return[276,t-59,3];case 82>=t:return[277,t-67,4];case 98>=t:return[278,t-83,4];case 114>=t:return[279,t-99,4];case 130>=t:return[280,t-115,4];case 162>=t:return[281,t-131,5];case 194>=t:return[282,t-163,5];case 226>=t:return[283,t-195,5];case 257>=t:return[284,t-227,5];case 258===t:return[285,t-258,0];default:e("invalid length: "+t)}}var n,i,a=[];for(n=3;258>=n;n++)i=t(n),a[n]=i[2]<<24|i[1]<<16|i[0];return a}();p&&new Uint32Array(b);var w=0,$=1;o.prototype.g=function(){for(;!this.o;){var t=r(this,3);switch(1&t&&(this.o=!0),t>>>=1){case 0:var n=this.input,i=this.c,a=this.b,o=this.a,s=u,l=u,d=u,h=a.length,f=u;switch(this.d=this.f=0,s=n[i++],s===u&&e(Error("invalid uncompressed block header: LEN (first byte)")),l=s,s=n[i++],s===u&&e(Error("invalid uncompressed block header: LEN (second byte)")),l|=s<<8,s=n[i++],s===u&&e(Error("invalid uncompressed block header: NLEN (first byte)")),d=s,s=n[i++],s===u&&e(Error("invalid uncompressed block header: NLEN (second byte)")),d|=s<<8,l===~d&&e(Error("invalid uncompressed block header: length verify")),i+l>n.length&&e(Error("input buffer is broken")),this.k){case w:for(;o+l>a.length;){if(f=h-o,l-=f,p)a.set(n.subarray(i,i+f),o),o+=f,i+=f;else for(;f--;)a[o++]=n[i++];this.a=o,a=this.e(),o=this.a}break;case $:for(;o+l>a.length;)a=this.e({t:2});break;default:e(Error("invalid inflate mode"))}if(p)a.set(n.subarray(i,i+l),o),o+=l,i+=l;else for(;l--;)a[o++]=n[i++];this.c=i,this.a=o,this.b=a;break;case 1:this.l(O,R);break;case 2:c(this);break;default:e(Error("unknown BTYPE: "+t))}}return this.q()};var C,S,k=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],x=p?new Uint16Array(k):k,M=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],T=p?new Uint16Array(M):M,E=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],A=p?new Uint8Array(E):E,D=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],I=p?new Uint16Array(D):D,P=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],N=p?new Uint8Array(P):P,L=new(p?Uint8Array:Array)(288);for(C=0,S=L.length;S>C;++C)L[C]=143>=C?8:255>=C?9:279>=C?7:8;var F,B,O=a(L),U=new(p?Uint8Array:Array)(30);for(F=0,B=U.length;B>F;++F)U[F]=5;var R=a(U);o.prototype.l=function(e,t){var n=this.b,i=this.a;this.r=e;for(var a,o,c,l,u=n.length-258;256!==(a=s(this,e));)if(256>a)i>=u&&(this.a=i,n=this.e(),i=this.a),n[i++]=a;else for(o=a-257,l=T[o],0=u&&(this.a=i,n=this.e(),i=this.a);l--;)n[i]=n[i++-c];for(;8<=this.d;)this.d-=8,this.c--;this.a=i},o.prototype.C=function(e,t){var n=this.b,i=this.a;this.r=e;for(var a,o,c,l,u=n.length;256!==(a=s(this,e));)if(256>a)i>=u&&(n=this.e(),u=n.length),n[i++]=a;else for(o=a-257,l=T[o],0u&&(n=this.e(),u=n.length);l--;)n[i]=n[i++-c];for(;8<=this.d;)this.d-=8,this.c--;this.a=i},o.prototype.e=function(){var e,t,n=new(p?Uint8Array:Array)(this.a-32768),i=this.a-32768,a=this.b;if(p)n.set(a.subarray(32768,n.length));else for(e=0,t=n.length;t>e;++e)n[e]=a[e+32768];if(this.i.push(n),this.n+=n.length,p)a.set(a.subarray(i,i+32768));else for(e=0;32768>e;++e)a[e]=a[i+e];return this.a=32768,a},o.prototype.D=function(e){var t,n,i,a,o=this.input.length/this.c+1|0,r=this.input,s=this.b;return e&&("number"==typeof e.t&&(o=e.t),"number"==typeof e.z&&(o+=e.z)),2>o?(n=(r.length-this.c)/this.r[2],a=258*(n/2)|0,i=at;++t)for(e=s[t],i=0,a=e.length;a>i;++i)c[o++]=e[i];for(t=32768,n=this.a;n>t;++t)c[o++]=r[t];return this.i=[],this.buffer=c},o.prototype.A=function(){var e,t=this.a;return p?this.w?(e=new Uint8Array(t),e.set(this.b.subarray(0,t))):e=this.b.subarray(0,t):(this.b.length>t&&(this.b.length=t),e=this.b),this.buffer=e},l.prototype.F=function(){return this.s||this.g(),this.m.slice()},l.prototype.g=function(){for(var t=this.input.length;this.c>>0,n(c,u,u)!==m&&e(Error("invalid CRC-32 checksum: 0x"+n(c,u,u).toString(16)+" / 0x"+m.toString(16))),a.L=r=(v[y++]|v[y++]<<8|v[y++]<<16|v[y++]<<24)>>>0,(4294967295&c.length)!==r&&e(Error("invalid input size: "+(4294967295&c.length)+" / "+r)),this.m.push(a),this.c=y}this.s=!0;var _,b,w,$=this.m,C=0,S=0;for(_=0,b=$.length;b>_;++_)S+=$[_].data.length;if(p)for(w=new Uint8Array(S),_=0;b>_;++_)w.set($[_].data,C),C+=$[_].data.length;else{for(w=[],_=0;b>_;++_)w[_]=$[_].data;w=Array.prototype.concat.apply([],w)}return w},t("Zlib.Gunzip",l),t("Zlib.Gunzip.prototype.decompress",l.prototype.g),t("Zlib.Gunzip.prototype.getMembers",l.prototype.F)}.call(this),this.goog={provide:function(){},math:{}},goog.provide("goog.math.Long"),goog.math.Long=function(e,t){this.low_=0|e,this.high_=0|t},goog.math.Long.IntCache_={},goog.math.Long.fromInt=function(e){if(e>=-128&&128>e){var t=goog.math.Long.IntCache_[e];if(t)return t}var n=new goog.math.Long(0|e,0>e?-1:0);return e>=-128&&128>e&&(goog.math.Long.IntCache_[e]=n),n},goog.math.Long.fromNumber=function(e){return isNaN(e)||!isFinite(e)?goog.math.Long.ZERO:e<=-goog.math.Long.TWO_PWR_63_DBL_?goog.math.Long.MIN_VALUE:e+1>=goog.math.Long.TWO_PWR_63_DBL_?goog.math.Long.MAX_VALUE:0>e?goog.math.Long.fromNumber(-e).negate():new goog.math.Long(e%goog.math.Long.TWO_PWR_32_DBL_|0,e/goog.math.Long.TWO_PWR_32_DBL_|0)},goog.math.Long.fromBits=function(e,t){return new goog.math.Long(e,t)},goog.math.Long.fromString=function(e,t){if(0==e.length)throw Error("number format error: empty string");var n=t||10;if(2>n||n>36)throw Error("radix out of range: "+n);if("-"==e.charAt(0))return goog.math.Long.fromString(e.substring(1),n).negate();if(e.indexOf("-")>=0)throw Error('number format error: interior "-" character: '+e);for(var i=goog.math.Long.fromNumber(Math.pow(n,8)),a=goog.math.Long.ZERO,o=0;or){var c=goog.math.Long.fromNumber(Math.pow(n,r));a=a.multiply(c).add(goog.math.Long.fromNumber(s))}else a=a.multiply(i),a=a.add(goog.math.Long.fromNumber(s))}return a},goog.math.Long.TWO_PWR_16_DBL_=65536,goog.math.Long.TWO_PWR_24_DBL_=1<<24,goog.math.Long.TWO_PWR_32_DBL_=goog.math.Long.TWO_PWR_16_DBL_*goog.math.Long.TWO_PWR_16_DBL_,goog.math.Long.TWO_PWR_31_DBL_=goog.math.Long.TWO_PWR_32_DBL_/2,goog.math.Long.TWO_PWR_48_DBL_=goog.math.Long.TWO_PWR_32_DBL_*goog.math.Long.TWO_PWR_16_DBL_,goog.math.Long.TWO_PWR_64_DBL_=goog.math.Long.TWO_PWR_32_DBL_*goog.math.Long.TWO_PWR_32_DBL_,goog.math.Long.TWO_PWR_63_DBL_=goog.math.Long.TWO_PWR_64_DBL_/2,goog.math.Long.ZERO=goog.math.Long.fromInt(0),goog.math.Long.ONE=goog.math.Long.fromInt(1),goog.math.Long.NEG_ONE=goog.math.Long.fromInt(-1),goog.math.Long.MAX_VALUE=goog.math.Long.fromBits(-1,2147483647),goog.math.Long.MIN_VALUE=goog.math.Long.fromBits(0,-2147483648),goog.math.Long.TWO_PWR_24_=goog.math.Long.fromInt(1<<24),goog.math.Long.prototype.toInt=function(){return this.low_},goog.math.Long.prototype.toNumber=function(){return this.high_*goog.math.Long.TWO_PWR_32_DBL_+this.getLowBitsUnsigned()},goog.math.Long.prototype.toString=function(e){var t=e||10;if(2>t||t>36)throw Error("radix out of range: "+t);if(this.isZero())return"0";if(this.isNegative()){if(this.equals(goog.math.Long.MIN_VALUE)){var n=goog.math.Long.fromNumber(t),i=this.div(n),a=i.multiply(n).subtract(this);return i.toString(t)+a.toInt().toString(t)}return"-"+this.negate().toString(t)}for(var o=goog.math.Long.fromNumber(Math.pow(t,6)),a=this,r="";;){var s=a.div(o),c=a.subtract(s.multiply(o)).toInt(),l=c.toString(t);if(a=s,a.isZero())return l+r;for(;l.length<6;)l="0"+l;r=""+l+r}},goog.math.Long.prototype.getHighBits=function(){return this.high_},goog.math.Long.prototype.getLowBits=function(){return this.low_},goog.math.Long.prototype.getLowBitsUnsigned=function(){return this.low_>=0?this.low_:goog.math.Long.TWO_PWR_32_DBL_+this.low_},goog.math.Long.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(goog.math.Long.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var e=0!=this.high_?this.high_:this.low_,t=31;t>0&&0==(e&1<0},goog.math.Long.prototype.greaterThanOrEqual=function(e){return this.compare(e)>=0},goog.math.Long.prototype.compare=function(e){if(this.equals(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.subtract(e).isNegative()?-1:1},goog.math.Long.prototype.negate=function(){return this.equals(goog.math.Long.MIN_VALUE)?goog.math.Long.MIN_VALUE:this.not().add(goog.math.Long.ONE)},goog.math.Long.prototype.add=function(e){var t=this.high_>>>16,n=65535&this.high_,i=this.low_>>>16,a=65535&this.low_,o=e.high_>>>16,r=65535&e.high_,s=e.low_>>>16,c=65535&e.low_,l=0,u=0,d=0,p=0;return p+=a+c,d+=p>>>16,p&=65535,d+=i+s,u+=d>>>16,d&=65535,u+=n+r,l+=u>>>16,u&=65535,l+=t+o,l&=65535,goog.math.Long.fromBits(d<<16|p,l<<16|u)},goog.math.Long.prototype.subtract=function(e){return this.add(e.negate())},goog.math.Long.prototype.multiply=function(e){if(this.isZero())return goog.math.Long.ZERO;if(e.isZero())return goog.math.Long.ZERO;if(this.equals(goog.math.Long.MIN_VALUE))return e.isOdd()?goog.math.Long.MIN_VALUE:goog.math.Long.ZERO;if(e.equals(goog.math.Long.MIN_VALUE))return this.isOdd()?goog.math.Long.MIN_VALUE:goog.math.Long.ZERO;if(this.isNegative())return e.isNegative()?this.negate().multiply(e.negate()):this.negate().multiply(e).negate();if(e.isNegative())return this.multiply(e.negate()).negate();if(this.lessThan(goog.math.Long.TWO_PWR_24_)&&e.lessThan(goog.math.Long.TWO_PWR_24_))return goog.math.Long.fromNumber(this.toNumber()*e.toNumber());var t=this.high_>>>16,n=65535&this.high_,i=this.low_>>>16,a=65535&this.low_,o=e.high_>>>16,r=65535&e.high_,s=e.low_>>>16,c=65535&e.low_,l=0,u=0,d=0,p=0;return p+=a*c,d+=p>>>16,p&=65535,d+=i*c,u+=d>>>16,d&=65535,d+=a*s,u+=d>>>16,d&=65535,u+=n*c,l+=u>>>16,u&=65535,u+=i*s,l+=u>>>16,u&=65535,u+=a*r,l+=u>>>16,u&=65535,l+=t*c+n*s+i*r+a*o,l&=65535,goog.math.Long.fromBits(d<<16|p,l<<16|u)},goog.math.Long.prototype.div=function(e){if(e.isZero())throw Error("division by zero");if(this.isZero())return goog.math.Long.ZERO;if(this.equals(goog.math.Long.MIN_VALUE)){if(e.equals(goog.math.Long.ONE)||e.equals(goog.math.Long.NEG_ONE))return goog.math.Long.MIN_VALUE;if(e.equals(goog.math.Long.MIN_VALUE))return goog.math.Long.ONE;var t=this.shiftRight(1),n=t.div(e).shiftLeft(1);if(n.equals(goog.math.Long.ZERO))return e.isNegative()?goog.math.Long.ONE:goog.math.Long.NEG_ONE;var i=this.subtract(e.multiply(n)),a=n.add(i.div(e));return a}if(e.equals(goog.math.Long.MIN_VALUE))return goog.math.Long.ZERO;if(this.isNegative())return e.isNegative()?this.negate().div(e.negate()):this.negate().div(e).negate();if(e.isNegative())return this.div(e.negate()).negate();for(var o=goog.math.Long.ZERO,i=this;i.greaterThanOrEqual(e);){for(var n=Math.max(1,Math.floor(i.toNumber()/e.toNumber())),r=Math.ceil(Math.log(n)/Math.LN2),s=48>=r?1:Math.pow(2,r-48),c=goog.math.Long.fromNumber(n),l=c.multiply(e);l.isNegative()||l.greaterThan(i);)n-=s,c=goog.math.Long.fromNumber(n),l=c.multiply(e);c.isZero()&&(c=goog.math.Long.ONE),o=o.add(c),i=i.subtract(l)}return o},goog.math.Long.prototype.modulo=function(e){return this.subtract(this.div(e).multiply(e))},goog.math.Long.prototype.not=function(){return goog.math.Long.fromBits(~this.low_,~this.high_)},goog.math.Long.prototype.and=function(e){return goog.math.Long.fromBits(this.low_&e.low_,this.high_&e.high_)},goog.math.Long.prototype.or=function(e){return goog.math.Long.fromBits(this.low_|e.low_,this.high_|e.high_)},goog.math.Long.prototype.xor=function(e){return goog.math.Long.fromBits(this.low_^e.low_,this.high_^e.high_)},goog.math.Long.prototype.shiftLeft=function(e){if(e&=63,0==e)return this;var t=this.low_;if(32>e){var n=this.high_;return goog.math.Long.fromBits(t<>>32-e)}return goog.math.Long.fromBits(0,t<e){var n=this.low_;return goog.math.Long.fromBits(n>>>e|t<<32-e,t>>e)}return goog.math.Long.fromBits(t>>e-32,t>=0?0:-1)},goog.math.Long.prototype.shiftRightUnsigned=function(e){if(e&=63,0==e)return this;var t=this.high_;if(32>e){var n=this.low_;return goog.math.Long.fromBits(n>>>e|t<<32-e,t>>>e)}return 32==e?goog.math.Long.fromBits(t,0):goog.math.Long.fromBits(t>>>e-32,0)};var _logTimer=(new Date).getTime();Function.prototype.bind||(Function.prototype.bind=function(e){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),n=this,i=function(){},a=function(){return n.apply(this instanceof i&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))};return i.prototype=this.prototype,a.prototype=new i,a}),TLSerialization.prototype.createBuffer=function(){this.buffer=new ArrayBuffer(this.maxLength),this.intView=new Int32Array(this.buffer),this.byteView=new Uint8Array(this.buffer)},TLSerialization.prototype.getArray=function(){var e=new ArrayBuffer(this.offset),t=new Int32Array(e);return t.set(this.intView.subarray(0,this.offset/4)),t},TLSerialization.prototype.getBuffer=function(){return this.getArray().buffer},TLSerialization.prototype.getBytes=function(){for(var e=[],t=0;t>>",e.toString(16),e,t),this.checkLength(4),this.intView[this.offset/4]=e,this.offset+=4},TLSerialization.prototype.storeInt=function(e,t){this.writeInt(e,(t||"")+":int")},TLSerialization.prototype.storeBool=function(e,t){e?this.writeInt(2574415285,(t||"")+":bool"):this.writeInt(3162085175,(t||"")+":bool")},TLSerialization.prototype.storeLongP=function(e,t,n){this.writeInt(t,(n||"")+":long[low]"),this.writeInt(e,(n||"")+":long[high]")},TLSerialization.prototype.storeLong=function(e,t){if(angular.isArray(e))return 2==e.length?this.storeLongP(e[0],e[1],t):this.storeIntBytes(e,64,t);var n=bigStringInt(e).divideAndRemainder(bigint(4294967296));this.writeInt(intToUint(n[1].intValue()),(t||"")+":long[low]"),this.writeInt(intToUint(n[0].intValue()),(t||"")+":long[high]")},TLSerialization.prototype.storeDouble=function(e){var t=new ArrayBuffer(8),n=new Int32Array(t),i=new Float64Array(t);i[0]=e,this.writeInt(n[0],(field||"")+":double[low]"),this.writeInt(n[1],(field||"")+":double[high]")},TLSerialization.prototype.storeString=function(e,t){this.debug&&console.log(">>>",e,(t||"")+":string");var n=unescape(encodeURIComponent(e));this.checkLength(n.length+8);var i=n.length;253>=i?this.byteView[this.offset++]=i:(this.byteView[this.offset++]=254,this.byteView[this.offset++]=255&i,this.byteView[this.offset++]=(65280&i)>>8,this.byteView[this.offset++]=(16711680&i)>>16);for(var a=0;i>a;a++)this.byteView[this.offset++]=n.charCodeAt(a);for(;this.offset%4;)this.byteView[this.offset++]=0},TLSerialization.prototype.storeBytes=function(e,t){this.debug&&console.log(">>>",bytesToHex(e),(t||"")+":bytes"),this.checkLength(e.length+8);var n=e.length;253>=n?this.byteView[this.offset++]=n:(this.byteView[this.offset++]=254,this.byteView[this.offset++]=255&n,this.byteView[this.offset++]=(65280&n)>>8,this.byteView[this.offset++]=(16711680&n)>>16);for(var i=0;n>i;i++)this.byteView[this.offset++]=e[i];for(;this.offset%4;)this.byteView[this.offset++]=0},TLSerialization.prototype.storeIntBytes=function(e,t,n){var i=e.length;if(t%32||8*i!=t)throw new Error("Invalid bits: "+t+", "+e.length);this.debug&&console.log(">>>",bytesToHex(e),(n||"")+":int"+t),this.checkLength(i);for(var a=0;i>a;a++)this.byteView[this.offset++]=e[a]},TLSerialization.prototype.storeRawBytes=function(e,t){var n=e.length;this.debug&&console.log(">>>",bytesToHex(e),t||""),this.checkLength(n);for(var i=0;n>i;i++)this.byteView[this.offset++]=e[i]},TLSerialization.prototype.storeMethod=function(e,t){var n,i=this.mtproto?Config.Schema.MTProto:Config.Schema.API,a=!1;for(n=0;n=4*this.intView.length)throw new Error("Nothing to fetch: "+e);var t=this.intView[this.offset/4];return this.debug&&console.log("<<<",t.toString(16),t,e),this.offset+=4,t},TLDeserialization.prototype.fetchInt=function(e){return this.readInt((e||"")+":int")},TLDeserialization.prototype.fetchDouble=function(e){var t=new ArrayBuffer(8),n=new Int32Array(t),i=new Float64Array(t);return n[0]=this.readInt((e||"")+":double[low]"),n[1]=this.readInt((e||"")+":double[high]"),i[0]},TLDeserialization.prototype.fetchLong=function(e){var t=this.readInt((e||"")+":long[low]"),n=this.readInt((e||"")+":long[high]"),i=bigint(n).shiftLeft(32).add(bigint(t)).toString();return i},TLDeserialization.prototype.fetchBool=function(e){var t=this.readInt((e||"")+":bool");return 2574415285==t?!0:3162085175==t?!1:(this.offset-=4,this.fetchObject("Object",e))},TLDeserialization.prototype.fetchString=function(e){var t=this.byteView[this.offset++];if(254==t)var t=this.byteView[this.offset++]|this.byteView[this.offset++]<<8|this.byteView[this.offset++]<<16;for(var n="",i=0;t>i;i++)n+=String.fromCharCode(this.byteView[this.offset++]);for(;this.offset%4;)this.offset++;try{var a=decodeURIComponent(escape(n))}catch(o){var a=n}return this.debug&&console.log("<<<",a,(e||"")+":string"),a},TLDeserialization.prototype.fetchBytes=function(e){var t=this.byteView[this.offset++];if(254==t)var t=this.byteView[this.offset++]|this.byteView[this.offset++]<<8|this.byteView[this.offset++]<<16;for(var n=[],i=0;t>i;i++)n.push(this.byteView[this.offset++]);for(;this.offset%4;)this.offset++;return this.debug&&console.log("<<<",bytesToHex(n),(e||"")+":bytes"),n},TLDeserialization.prototype.fetchIntBytes=function(e,t){if(e%32)throw new Error("Invalid bits: "+e);for(var n=e/8,i=[],a=0;n>a;a++)i.push(this.byteView[this.offset++]);return this.debug&&console.log("<<<",bytesToHex(i),(t||"")+":int"+e),i},TLDeserialization.prototype.fetchRawBytes=function(e,t){e===!1&&(e=this.readInt((t||"")+"_length"));for(var n=[],i=0;e>i;i++)n.push(this.byteView[this.offset++]);return this.debug&&console.log("<<<",bytesToHex(n),t||""),n},TLDeserialization.prototype.fetchObject=function(e,t){switch(e){case"int":return this.fetchInt(t);case"long":return this.fetchLong(t);case"int128":return this.fetchIntBytes(128,t);case"int256":return this.fetchIntBytes(256,t);case"int512":return this.fetchIntBytes(512,t);case"string":return this.fetchString(t);case"bytes":return this.fetchBytes(t);case"double":return this.fetchDouble(t);case"Bool":return this.fetchBool(t)}if(t=t||e||"Object","Vector"==e.substr(0,6)||"vector"==e.substr(0,6)){if("V"==e.charAt(0)){var n=this.readInt(t+"[id]");if(481674261!=n)throw new Error("Invalid vector constructor "+n)}var i=this.readInt(t+"[count]"),a=[];if(i>0)for(var o=e.substr(7,e.length-8),r=0;i>r;r++)a.push(this.fetchObject(o,t+"["+r+"]"));return a}var s=this.mtproto?Config.Schema.MTProto:Config.Schema.API,c=!1,l=!1;if("%"==e.charAt(0)){var u=e.substr(1);for(r=0;r=97&&e.charAt(0)<=122){for(r=0;rDownload").css({position:"absolute",top:1,left:1}).attr("href",e).attr("target","_blank").attr("download",i).appendTo("body");a[0].dataset.downloadurl=[n,i,e].join(":"),a[0].click(),t(function(){a.remove()},100)}e.URL=e.URL||e.webkitURL,e.BlobBuilder=e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder;var p=!0;try{o([],"")}catch(h){p=!1}return{isAvailable:i,copy:a,write:r,getFileWriter:c,getFakeFileWriter:l,chooseSave:s,getUrl:u,download:d}}]).service("IdbFileStorage",["$q","$window","FileManager",function(e,t,n){function i(){return p}function a(){if(c)return c;try{var t=indexedDB.open(l,d),n=e.defer(),i=function(e){e.createObjectStore(u)}}catch(a){return p=!1,e.reject(a)}return t.onsuccess=function(){db=t.result,db.onerror=function(e){p=!1,console.error("Error creating/accessing IndexedDB database",e),n.reject(e)},db.setVersion&&db.version!=d?db.setVersion(d).onsuccess=function(){i(db),n.resolve(db)}:n.resolve(db)},t.onerror=function(e){p=!1,console.error("Error creating/accessing IndexedDB database",e),n.reject(e)},t.onupgradeneeded=function(e){i(e.target.result)},c=n.promise}function o(t,n){return a().then(function(i){try{var a=e.defer(),o=i.transaction([u],IDBTransaction.READ_WRITE||"readwrite").objectStore(u),r=o.put(n,t)}catch(s){return p=!1,e.reject(s)}return r.onsuccess=function(){a.resolve(n)},r.onerror=function(e){a.reject(e)},a.promise})}function r(t){return a().then(function(n){var i=e.defer(),a=n.transaction([u],IDBTransaction.READ||"readonly").objectStore(u),o=a.get(t);return o.onsuccess=function(e){void 0===e.target.result?i.reject():i.resolve(e.target.result)},o.onerror=function(e){i.reject(e)},i.promise})}function s(t,i){var a=n.getFakeFileWriter(i,function(e){o(t,e)});return e.when(a)}t.indexedDB=t.indexedDB||t.webkitIndexedDB||t.mozIndexedDB||t.OIndexedDB||t.msIndexedDB,t.IDBTransaction=t.IDBTransaction||t.webkitIDBTransaction||t.OIDBTransaction||t.msIDBTransaction;var c,l="cachedFiles",u="files",d=1,p=void 0!==t.indexedDB&&void 0!==t.IDBTransaction;return a(),{isAvailable:i,saveFile:o,getFile:r,getFileWriter:s}}]).service("TmpfsFileStorage",["$q","$window","FileManager",function(e,t,n){function i(){if(c)return c;if(!t.requestFileSystem)return c=e.reject({type:"FS_BROWSER_UNSUPPORTED",description:"requestFileSystem not present"});var n=e.defer();return t.requestFileSystem(t.TEMPORARY,5242880,function(e){cachedFs=e,n.resolve()},function(e){l=!1,n.reject(e)}),c=n.promise}function a(){return l}function o(t,n){return n=n||1,i().then(function(){var i=e.defer();return cachedFs.root.getFile(t,{create:!1},function(e){e.file(function(t){t.size>=n?i.resolve(e):i.reject(new Error("FILE_NOT_FOUND"))},function(e){console.log(dT(),"error",e),i.reject(e)})},function(){i.reject(new Error("FILE_NOT_FOUND"))}),i.promise})}function r(e,t){return s(e).then(function(e){return n.write(e,t).then(function(){return e.finalize()})})}function s(t){return i().then(function(){var i=e.defer();return cachedFs.root.getFile(t,{create:!0},function(e){n.getFileWriter(e).then(function(t){t.finalize=function(){return e},i.resolve(t)},function(e){i.reject(e)})},function(e){i.reject(e)}),i.promise})}t.requestFileSystem=t.requestFileSystem||t.webkitRequestFileSystem;var c,l=void 0!==t.requestFileSystem;return i(),{isAvailable:a,saveFile:r,getFile:o,getFileWriter:s}}]).service("MemoryFileStorage",["$q","FileManager",function(e,t){function n(){return!0}function i(t){return r[t]?e.when(r[t]):e.reject(new Error("FILE_NOT_FOUND"))}function a(t,n){return e.when(r[t]=n)}function o(n,i){var o=t.getFakeFileWriter(i,function(e){a(n,e)});return e.when(o)}var r={};return{isAvailable:n,saveFile:a,getFile:i,getFileWriter:o}}]).service("CryptoWorker",["$timeout","$q",function(e,t){function n(e,n){console.log(dT(),"CW start",e);var r=t.defer();return o[a]=r,n.task=e,n.taskID=a,i.postMessage(n),a++,r.promise}var i=window.Worker&&new Worker("js/lib/crypto_worker.js")||!1,a=0,o={};return i&&(i.onmessage=function(e){var t=o[e.data.taskID];void 0!==t&&(console.log(dT(),"CW done"),t.resolve(e.data.result),delete o[e.data.taskID])},i.onerror=function(e){console.log("CW error",e,e.stack)}),{sha1Hash:function(t){return e(function(){return sha1Hash(t)})},aesEncrypt:function(t,n,i){return e(function(){return aesEncrypt(t,n,i)})},aesDecrypt:function(t,n,i){return e(function(){return aesDecrypt(t,n,i)})},factorize:function(t){return i?n("factorize",{bytes:t}):e(function(){return pqPrimeFactorization(t)})},modPow:function(t,a,o){return i?n("mod-pow",{x:t,y:a,m:o}):e(function(){return bytesModPow(t,a,o)})}}}]),angular.module("izhukov.mtproto",["izhukov.utils"]).factory("MtpDcConfigurator",function(){function e(e){if(void 0===n[e]){var i,a,o=!1;for(i=0;ir[0]||i[0]==r[0]&&i[1]>=r[1])&&(r=[i[0],i[1]+4]),i=r,longFromInts(r[0],r[1])}function n(t,n){var o=t-Math.floor((n||tsNow())/1e3),r=Math.abs(a-o)>10;return e.set({server_time_offset:o}),i=[0,0],a=o,console.log(dT(),"Apply server time",t,n,o,r),r}var i=[0,0],a=0;return e.get("server_time_offset").then(function(e){e&&(a=e)}),{generateID:t,applyServerTime:n}}]).factory("MtpAuthorizer",["MtpDcConfigurator","MtpRsaKeysManager","MtpSecureRandom","MtpTimeManager","CryptoWorker","$http","$q","$timeout",function(e,t,n,i,a,o,r,s){function c(t,n){var a=n.byteLength,s=new Int32Array(n),c=new TLSerialization;c.storeLongP(0,0,"auth_key_id"),c.storeLong(i.generateID(),"msg_id"),c.storeInt(a,"request_length");var l=c.getBuffer(),u=new Int32Array(l),d=l.byteLength,p=new ArrayBuffer(d+a),h=new Int32Array(p);return h.set(u),h.set(s,u.length),delete o.defaults.headers.post["Content-Type"],delete o.defaults.headers.common.Accept,"ArrayBufferView"in window||g&&!(30>g)||(h=h.buffer),o.post("http://"+e.chooseServer(t)+"/apiw1",h,{responseType:"arraybuffer",transformRequest:null}).then(function(e){if(!e.data||!e.data.byteLength)return r.reject({code:406,type:"NETWORK_BAD_RESPONSE"});try{{var t=new TLDeserialization(e.data,{mtproto:!0});t.fetchLong("auth_key_id"),t.fetchLong("msg_id"),t.fetchInt("msg_len")}}catch(n){return r.reject({code:406,type:"NETWORK_BAD_RESPONSE",originalError:n})}return rng_seed_time(),t},function(e){return e.message||e.type||(e={code:406,type:"NETWORK_BAD_REQUEST",originalError:e}),r.reject(e)})}function l(e){var n=e.deferred,i=new TLSerialization({mtproto:!0});i.storeMethod("req_pq",{nonce:e.nonce}),console.log(dT(),"Send req_pq",bytesToHex(e.nonce)),c(e.dcID,i.getBuffer()).then(function(i){var o=i.fetchObject("ResPQ");if("resPQ"!=o._)throw new Error("resPQ response invalid: "+o._);if(!bytesCmp(e.nonce,o.nonce))throw new Error("resPQ nonce mismatch");if(e.serverNonce=o.server_nonce,e.pq=o.pq,e.fingerprints=o.server_public_key_fingerprints,console.log(dT(),"Got ResPQ",bytesToHex(e.serverNonce),bytesToHex(e.pq),e.fingerprints),e.publicKey=t.select(e.fingerprints),!e.publicKey)throw new Error("No public key found");console.log(dT(),"PQ factorization start",e.pq),a.factorize(e.pq).then(function(t){e.p=t[0],e.q=t[1],console.log(dT(),"PQ factorization done",t[2]),u(e)},function(e){console.log("Worker error",e,e.stack),n.reject(e)})},function(e){console.log(dT(),"req_pq error",e.message),n.reject(e)}),s(function(){t.prepare()})}function u(e){var t=e.deferred;e.newNonce=new Array(32),n.nextBytes(e.newNonce);var i=new TLSerialization({mtproto:!0});i.storeObject({_:"p_q_inner_data",pq:e.pq,p:e.p,q:e.q,nonce:e.nonce,server_nonce:e.serverNonce,new_nonce:e.newNonce},"P_Q_inner_data","DECRYPTED_DATA");var a=sha1Hash(i.getBuffer()).concat(i.getBytes()),o=new TLSerialization({mtproto:!0});o.storeMethod("req_DH_params",{nonce:e.nonce,server_nonce:e.serverNonce,p:e.p,q:e.q,public_key_fingerprint:e.publicKey.fingerprint,encrypted_data:rsaEncrypt(e.publicKey,a)}),console.log(dT(),"Send req_DH_params"),c(e.dcID,o.getBuffer()).then(function(n){var i=n.fetchObject("Server_DH_Params","RESPONSE");if("server_DH_params_fail"!=i._&&"server_DH_params_ok"!=i._)return t.reject(new Error("Server_DH_Params response invalid: "+i._)),!1;if(!bytesCmp(e.nonce,i.nonce))return t.reject(new Error("Server_DH_Params nonce mismatch")),!1;if(!bytesCmp(e.serverNonce,i.server_nonce))return t.reject(new Error("Server_DH_Params server_nonce mismatch")),!1;if("server_DH_params_fail"==i._){var a=sha1Hash(e.newNonce).slice(-16);return bytesCmp(a,i.new_nonce_hash)?(t.reject(new Error("server_DH_params_fail")),!1):(t.reject(new Error("server_DH_params_fail new_nonce_hash mismatch")),!1)}try{d(e,i.encrypted_answer)}catch(o){return t.reject(o),!1}p(e)},function(e){t.reject(e)})}function d(e,t){e.localTime=tsNow(),e.tmpAesKey=sha1Hash(e.newNonce.concat(e.serverNonce)).concat(sha1Hash(e.serverNonce.concat(e.newNonce)).slice(0,12)),e.tmpAesIv=sha1Hash(e.serverNonce.concat(e.newNonce)).slice(12).concat(sha1Hash([].concat(e.newNonce,e.newNonce)),e.newNonce.slice(0,4));var n=aesDecrypt(t,e.tmpAesKey,e.tmpAesIv),a=n.slice(0,20),o=n.slice(20),r=bytesToArrayBuffer(o),s=new TLDeserialization(r,{mtproto:!0}),c=s.fetchObject("Server_DH_inner_data");if("server_DH_inner_data"!=c._)throw new Error("server_DH_inner_data response invalid: "+constructor);if(!bytesCmp(e.nonce,c.nonce))throw new Error("server_DH_inner_data nonce mismatch");if(!bytesCmp(e.serverNonce,c.server_nonce))throw new Error("server_DH_inner_data serverNonce mismatch");console.log(dT(),"Done decrypting answer"),e.g=c.g,e.dhPrime=c.dh_prime,e.gA=c.g_a,e.serverTime=c.server_time,e.retry=0;var l=s.getOffset();if(!bytesCmp(a,sha1Hash(o.slice(0,l))))throw new Error("server_DH_inner_data SHA1-hash mismatch");i.applyServerTime(e.serverTime,e.localTime)}function p(e){var t=e.deferred,i=bytesFromHex(e.g.toString(16));e.b=new Array(256),n.nextBytes(e.b),a.modPow(i,e.b,e.dhPrime).then(function(n){var i=new TLSerialization({mtproto:!0});i.storeObject({_:"client_DH_inner_data",nonce:e.nonce,server_nonce:e.serverNonce,retry_id:[0,e.retry++],g_b:n},"Client_DH_Inner_Data");var o=sha1Hash(i.getBuffer()).concat(i.getBytes()),r=aesEncrypt(o,e.tmpAesKey,e.tmpAesIv),s=new TLSerialization({mtproto:!0});s.storeMethod("set_client_DH_params",{nonce:e.nonce,server_nonce:e.serverNonce,encrypted_data:r}),console.log(dT(),"Send set_client_DH_params"),c(e.dcID,s.getBuffer()).then(function(n){var i=n.fetchObject("Set_client_DH_params_answer");return"dh_gen_ok"!=i._&&"dh_gen_retry"!=i._&&"dh_gen_fail"!=i._?(t.reject(new Error("Set_client_DH_params_answer response invalid: "+i._)),!1):bytesCmp(e.nonce,i.nonce)?bytesCmp(e.serverNonce,i.server_nonce)?void a.modPow(e.gA,e.b,e.dhPrime).then(function(n){var a=sha1Hash(n),o=a.slice(0,8),r=a.slice(-8);switch(console.log(dT(),"Got Set_client_DH_params_answer",i._),i._){case"dh_gen_ok":var s=sha1Hash(e.newNonce.concat([1],o)).slice(-16);if(!bytesCmp(s,i.new_nonce_hash1))return t.reject(new Error("Set_client_DH_params_answer new_nonce_hash1 mismatch")),!1;var c=bytesXor(e.newNonce.slice(0,8),e.serverNonce.slice(0,8));e.authKeyID=r,e.authKey=n,e.serverSalt=c,t.resolve(e);break;case"dh_gen_retry":var l=sha1Hash(e.newNonce.concat([2],o)).slice(-16);return bytesCmp(l,i.new_nonce_hash2)?p(e):(t.reject(new Error("Set_client_DH_params_answer new_nonce_hash2 mismatch")),!1);case"dh_gen_fail":var u=sha1Hash(e.newNonce.concat([3],o)).slice(-16);return bytesCmp(u,i.new_nonce_hash3)?(t.reject(new Error("Set_client_DH_params_answer fail")),!1):(t.reject(new Error("Set_client_DH_params_answer new_nonce_hash3 mismatch")),!1)}},function(e){t.reject(e)}):(t.reject(new Error("Set_client_DH_params_answer server_nonce mismatch")),!1):(t.reject(new Error("Set_client_DH_params_answer nonce mismatch")),!1)},function(e){t.reject(e)})},function(e){t.reject(e)})}function h(t){if(void 0!==m[t])return m[t];for(var n=[],i=0;16>i;i++)n.push(nextRandomInt(255));if(!e.chooseServer(t))return r.reject(new Error("No server found for dc "+t));var a={dcID:t,nonce:n,deferred:r.defer()};return s(function(){l(a)}),m[t]=a.deferred.promise,m[t]["catch"](function(){delete m[t]}),m[t]}var f=navigator.userAgent.match(/Chrome\/(\d+(\.\d+)?)/),g=f&&parseFloat(f[1])||!1,m={};return{auth:h}}]).factory("MtpNetworkerFactory",["MtpDcConfigurator","MtpTimeManager","MtpSecureRandom","Storage","CryptoWorker","$http","$q","$timeout","$interval","$rootScope",function(e,t,n,i,a,o,r,s,c,l){function u(e,t,n,i){i=i||{},this.dcID=e,this.iii=p++,this.authKey=t,this.authKeyID=sha1Hash(t).slice(-8),this.serverSalt=n,this.upload=i.fileUpload||i.fileDownload||!1,this.updateSession(),this.currentRequests=0,this.checkConnectionPeriod=0,this.sentMessages={},this.serverMessages=[],this.clientMessages=[],this.pendingMessages={},this.pendingAcks=[],this.pendingResends=[],this.connectionInited=!1,this.pendingTimeouts=[],this.longPollInt=c(this.checkLongPoll.bind(this),1e4),this.checkLongPoll(),h||(h=!0,l.offline=!0,l.offlineConnecting=!0),Config.Navigator.mobile&&this.setupMobileSleep()}var d,p=0,h=!1,f=navigator.userAgent.match(/Chrome\/(\d+(\.\d+)?)/),g=f&&parseFloat(f[1])||!1;return l.retryOnline=function(){$(document.body).trigger("online")},u.prototype.updateSession=function(){this.seqNo=0,this.sessionID=new Array(8),n.nextBytes(this.sessionID)},u.prototype.setupMobileSleep=function(){var e=this;l.$watch("idle.isIDLE",function(t){t?e.sleepAfter=tsNow()+3e4:(delete e.sleepAfter,e.checkLongPoll())}),l.$on("push_received",function(){e.sleepAfter&&(e.sleepAfter=tsNow()+3e4,e.checkLongPoll())})},u.prototype.updateSentMessage=function(e){var n=this.sentMessages[e];if(!n)return!1;var i=this;if(n.container){var a=[];angular.forEach(n.inner,function(e){var t=i.updateSentMessage(e);t&&a.push(t.msg_id)}),n.inner=a}return n.msg_id=t.generateID(),n.seq_no=this.generateSeqNo(n.notContentRelated||n.container),this.sentMessages[n.msg_id]=n,delete i.sentMessages[e],n},u.prototype.generateSeqNo=function(e){var t=2*this.seqNo;return e||(t++,this.seqNo++),t},u.prototype.wrapMtpCall=function(e,n,i){var a=new TLSerialization({mtproto:!0});a.storeMethod(e,n);var o=t.generateID(),r=this.generateSeqNo(),s={msg_id:o,seq_no:r,body:a.getBytes()};return Config.Modes.debug&&console.log(dT(),"MT call",e,n,o,r),this.pushMessage(s,i)},u.prototype.wrapMtpMessage=function(e,n){n=n||{};var i=new TLSerialization({mtproto:!0});i.storeObject(e,"Object");var a=t.generateID(),o=this.generateSeqNo(n.notContentRelated),r={msg_id:a,seq_no:o,body:i.getBytes()};return Config.Modes.debug&&console.log(dT(),"MT message",e,a,o),this.pushMessage(r,n)},u.prototype.wrapApiCall=function(e,n,i){var a=new TLSerialization(i);this.connectionInited||(a.storeInt(3479112071,"invokeWithLayer16"),a.storeInt(1769565673,"initConnection"),a.storeInt(Config.App.id,"api_id"),a.storeString(navigator.userAgent||"Unknown UserAgent","device_model"),a.storeString(navigator.platform||"Unknown Platform","system_version"),a.storeString(Config.App.version,"app_version"),a.storeString(navigator.language||"en","lang_code")),i.afterMessageID&&(a.storeInt(3416209197,"invokeAfterMsg"),a.storeLong(i.afterMessageID,"msg_id")),i.resultType=a.storeMethod(e,n);var o=t.generateID(),r=this.generateSeqNo(),s={msg_id:o,seq_no:r,body:a.getBytes(),isAPI:!0};return Config.Modes.debug?console.log(dT(),"Api call",e,n,o,r,i):console.log(dT(),"Api call",e),this.pushMessage(s,i)},u.prototype.checkLongPoll=function(){var e=this.cleanupSent();if(this.longPollPending&&tsNow()t.sleepAfter)||t.sendLongPoll()})},u.prototype.sendLongPoll=function(){var e=25e3,t=this;this.longPollPending=tsNow()+e,this.wrapMtpCall("http_wait",{max_delay:0,wait_after:0,max_wait:e},{noResponse:!0,longPoll:!0}).then(function(){delete t.longPollPending,s(t.checkLongPoll.bind(t),0)},function(){console.log("Long-poll failed")})},u.prototype.pushMessage=function(e,t){var n=r.defer();return this.sentMessages[e.msg_id]=angular.extend(e,t||{},{deferred:n}),this.pendingMessages[e.msg_id]=0,t&&t.noShedule||this.sheduleRequest(),angular.isObject(t)&&(t.messageID=e.msg_id),n.promise},u.prototype.pushResend=function(e,t){var n=t?tsNow()+t:0,i=this.sentMessages[e];if(i.container)for(var a=0;a=c)&&((o=d.sentMessages[t])&&(r.push(o),s+=o.body.length+32,o.isAPI?l=!0:o.longPoll&&(u=!0)),delete d.pendingMessages[t])}),l&&!u){var p=new TLSerialization({mtproto:!0});p.storeMethod("http_wait",{max_delay:0,wait_after:0,max_wait:1e3}),r.push({msg_id:t.generateID(),seq_no:this.generateSeqNo(),body:p.getBytes()})}if(r.length){var h=[];if(r.length>1){var f=new TLSerialization({mtproto:!0,startMaxLength:s+64});f.storeInt(1945237724,"CONTAINER[id]"),f.storeInt(r.length,"CONTAINER[count]");for(var g=[],n=0;ng)||(a=a.buffer),o.post("http://"+e.chooseServer(n.dcID)+"/apiw1",a,{responseType:"arraybuffer",transformRequest:null}).then(function(e){return e.data&&e.data.byteLength?e:r.reject({code:406,type:"NETWORK_BAD_RESPONSE"})},function(e){return e.message||e.type||(e={code:406,type:"NETWORK_BAD_REQUEST"}),r.reject(e)})})},u.prototype.parseResponse=function(e){var t=this,n=new TLDeserialization(e),i=n.fetchIntBytes(64,"auth_key_id");if(!bytesCmp(i,this.authKeyID))throw new Error("Invalid server auth_key_id: "+bytesToHex(i));var o=n.fetchIntBytes(128,"msg_key"),r=e.byteLength-n.getOffset(),s=n.fetchRawBytes(r,"encrypted_data");return this.getDecryptedMessage(o,s).then(function(e){var n=bytesToArrayBuffer(e),i=new TLDeserialization(n,{mtproto:!0}),r=(i.fetchIntBytes(64,"salt"),i.fetchIntBytes(64,"session_id")),s=i.fetchLong("message_id"),c=i.fetchInt("seq_no"),l=i.fetchRawBytes(!1,"message_data"),u=i.getOffset(); +var a,o=this.mtproto?Config.Schema.MTProto:Config.Schema.API,r=e._,s=!1,c=!1;for((s="%"==t.charAt(0))&&(t=t.substr(1)),a=0;a=4*this.intView.length)throw new Error("Nothing to fetch: "+e);var t=this.intView[this.offset/4];return this.debug&&console.log("<<<",t.toString(16),t,e),this.offset+=4,t},TLDeserialization.prototype.fetchInt=function(e){return this.readInt((e||"")+":int")},TLDeserialization.prototype.fetchDouble=function(e){var t=new ArrayBuffer(8),n=new Int32Array(t),i=new Float64Array(t);return n[0]=this.readInt((e||"")+":double[low]"),n[1]=this.readInt((e||"")+":double[high]"),i[0]},TLDeserialization.prototype.fetchLong=function(e){var t=this.readInt((e||"")+":long[low]"),n=this.readInt((e||"")+":long[high]"),i=bigint(n).shiftLeft(32).add(bigint(t)).toString();return i},TLDeserialization.prototype.fetchBool=function(e){var t=this.readInt((e||"")+":bool");return 2574415285==t?!0:3162085175==t?!1:(this.offset-=4,this.fetchObject("Object",e))},TLDeserialization.prototype.fetchString=function(e){var t=this.byteView[this.offset++];if(254==t)var t=this.byteView[this.offset++]|this.byteView[this.offset++]<<8|this.byteView[this.offset++]<<16;for(var n="",i=0;t>i;i++)n+=String.fromCharCode(this.byteView[this.offset++]);for(;this.offset%4;)this.offset++;try{var a=decodeURIComponent(escape(n))}catch(o){var a=n}return this.debug&&console.log("<<<",a,(e||"")+":string"),a},TLDeserialization.prototype.fetchBytes=function(e){var t=this.byteView[this.offset++];if(254==t)var t=this.byteView[this.offset++]|this.byteView[this.offset++]<<8|this.byteView[this.offset++]<<16;for(var n=[],i=0;t>i;i++)n.push(this.byteView[this.offset++]);for(;this.offset%4;)this.offset++;return this.debug&&console.log("<<<",bytesToHex(n),(e||"")+":bytes"),n},TLDeserialization.prototype.fetchIntBytes=function(e,t){if(e%32)throw new Error("Invalid bits: "+e);for(var n=e/8,i=[],a=0;n>a;a++)i.push(this.byteView[this.offset++]);return this.debug&&console.log("<<<",bytesToHex(i),(t||"")+":int"+e),i},TLDeserialization.prototype.fetchRawBytes=function(e,t){e===!1&&(e=this.readInt((t||"")+"_length"));for(var n=[],i=0;e>i;i++)n.push(this.byteView[this.offset++]);return this.debug&&console.log("<<<",bytesToHex(n),t||""),n},TLDeserialization.prototype.fetchObject=function(e,t){switch(e){case"int":return this.fetchInt(t);case"long":return this.fetchLong(t);case"int128":return this.fetchIntBytes(128,t);case"int256":return this.fetchIntBytes(256,t);case"int512":return this.fetchIntBytes(512,t);case"string":return this.fetchString(t);case"bytes":return this.fetchBytes(t);case"double":return this.fetchDouble(t);case"Bool":return this.fetchBool(t)}if(t=t||e||"Object","Vector"==e.substr(0,6)||"vector"==e.substr(0,6)){if("V"==e.charAt(0)){var n=this.readInt(t+"[id]");if(481674261!=n)throw new Error("Invalid vector constructor "+n)}var i=this.readInt(t+"[count]"),a=[];if(i>0)for(var o=e.substr(7,e.length-8),r=0;i>r;r++)a.push(this.fetchObject(o,t+"["+r+"]"));return a}var s=this.mtproto?Config.Schema.MTProto:Config.Schema.API,c=!1,l=!1;if("%"==e.charAt(0)){var u=e.substr(1);for(r=0;r=97&&e.charAt(0)<=122){for(r=0;rDownload").css({position:"absolute",top:1,left:1}).attr("href",e).attr("target","_blank").attr("download",i).appendTo("body");a[0].dataset.downloadurl=[n,i,e].join(":"),a[0].click(),t(function(){a.remove()},100)}e.URL=e.URL||e.webkitURL,e.BlobBuilder=e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder;var p=!0;try{o([],"")}catch(h){p=!1}return{isAvailable:i,copy:a,write:r,getFileWriter:c,getFakeFileWriter:l,chooseSave:s,getUrl:u,download:d}}]).service("IdbFileStorage",["$q","$window","FileManager",function(e,t,n){function i(){return p}function a(){if(c)return c;try{var t=indexedDB.open(l,d),n=e.defer(),i=function(e){e.createObjectStore(u)}}catch(a){return p=!1,e.reject(a)}return t.onsuccess=function(){db=t.result,db.onerror=function(e){p=!1,console.error("Error creating/accessing IndexedDB database",e),n.reject(e)},db.setVersion&&db.version!=d?db.setVersion(d).onsuccess=function(){i(db),n.resolve(db)}:n.resolve(db)},t.onerror=function(e){p=!1,console.error("Error creating/accessing IndexedDB database",e),n.reject(e)},t.onupgradeneeded=function(e){i(e.target.result)},c=n.promise}function o(t,n){return a().then(function(i){try{var a=e.defer(),o=i.transaction([u],IDBTransaction.READ_WRITE||"readwrite").objectStore(u),r=o.put(n,t)}catch(s){return p=!1,e.reject(s)}return r.onsuccess=function(){a.resolve(n)},r.onerror=function(e){a.reject(e)},a.promise})}function r(t){return a().then(function(n){var i=e.defer(),a=n.transaction([u],IDBTransaction.READ||"readonly").objectStore(u),o=a.get(t);return o.onsuccess=function(e){void 0===e.target.result?i.reject():i.resolve(e.target.result)},o.onerror=function(e){i.reject(e)},i.promise})}function s(t,i){var a=n.getFakeFileWriter(i,function(e){o(t,e)});return e.when(a)}t.indexedDB=t.indexedDB||t.webkitIndexedDB||t.mozIndexedDB||t.OIndexedDB||t.msIndexedDB,t.IDBTransaction=t.IDBTransaction||t.webkitIDBTransaction||t.OIDBTransaction||t.msIDBTransaction;var c,l="cachedFiles",u="files",d=1,p=void 0!==t.indexedDB&&void 0!==t.IDBTransaction;return a(),{isAvailable:i,saveFile:o,getFile:r,getFileWriter:s}}]).service("TmpfsFileStorage",["$q","$window","FileManager",function(e,t,n){function i(){if(c)return c;if(!t.requestFileSystem)return c=e.reject({type:"FS_BROWSER_UNSUPPORTED",description:"requestFileSystem not present"});var n=e.defer();return t.requestFileSystem(t.TEMPORARY,5242880,function(e){cachedFs=e,n.resolve()},function(e){l=!1,n.reject(e)}),c=n.promise}function a(){return l}function o(t,n){return n=n||1,i().then(function(){var i=e.defer();return cachedFs.root.getFile(t,{create:!1},function(e){e.file(function(t){t.size>=n?i.resolve(e):i.reject(new Error("FILE_NOT_FOUND"))},function(e){console.log(dT(),"error",e),i.reject(e)})},function(){i.reject(new Error("FILE_NOT_FOUND"))}),i.promise})}function r(e,t){return s(e).then(function(e){return n.write(e,t).then(function(){return e.finalize()})})}function s(t){return i().then(function(){var i=e.defer();return cachedFs.root.getFile(t,{create:!0},function(e){n.getFileWriter(e).then(function(t){t.finalize=function(){return e},i.resolve(t)},function(e){i.reject(e)})},function(e){i.reject(e)}),i.promise})}t.requestFileSystem=t.requestFileSystem||t.webkitRequestFileSystem;var c,l=void 0!==t.requestFileSystem;return i(),{isAvailable:a,saveFile:r,getFile:o,getFileWriter:s}}]).service("MemoryFileStorage",["$q","FileManager",function(e,t){function n(){return!0}function i(t){return r[t]?e.when(r[t]):e.reject(new Error("FILE_NOT_FOUND"))}function a(t,n){return e.when(r[t]=n)}function o(n,i){var o=t.getFakeFileWriter(i,function(e){a(n,e)});return e.when(o)}var r={};return{isAvailable:n,saveFile:a,getFile:i,getFileWriter:o}}]).service("CryptoWorker",["$timeout","$q",function(e,t){function n(e,n){console.log(dT(),"CW start",e);var r=t.defer();return o[a]=r,n.task=e,n.taskID=a,i.postMessage(n),a++,r.promise}var i=window.Worker&&new Worker("js/lib/crypto_worker.js")||!1,a=0,o={};return i&&(i.onmessage=function(e){var t=o[e.data.taskID];void 0!==t&&(console.log(dT(),"CW done"),t.resolve(e.data.result),delete o[e.data.taskID])},i.onerror=function(e){console.log("CW error",e,e.stack)}),{sha1Hash:function(t){return e(function(){return sha1Hash(t)})},aesEncrypt:function(t,n,i){return e(function(){return aesEncrypt(t,n,i)})},aesDecrypt:function(t,n,i){return e(function(){return aesDecrypt(t,n,i)})},factorize:function(t){return i?n("factorize",{bytes:t}):e(function(){return pqPrimeFactorization(t)})},modPow:function(t,a,o){return i?n("mod-pow",{x:t,y:a,m:o}):e(function(){return bytesModPow(t,a,o)})}}}]),angular.module("izhukov.mtproto",["izhukov.utils"]).factory("MtpDcConfigurator",function(){function e(e){if(void 0===n[e]){var i,a,o=!1;for(i=0;ir[0]||i[0]==r[0]&&i[1]>=r[1])&&(r=[i[0],i[1]+4]),i=r,longFromInts(r[0],r[1])}function n(t,n){var o=t-Math.floor((n||tsNow())/1e3),r=Math.abs(a-o)>10;return e.set({server_time_offset:o}),i=[0,0],a=o,console.log(dT(),"Apply server time",t,n,o,r),r}var i=[0,0],a=0;return e.get("server_time_offset").then(function(e){e&&(a=e)}),{generateID:t,applyServerTime:n}}]).factory("MtpAuthorizer",["MtpDcConfigurator","MtpRsaKeysManager","MtpSecureRandom","MtpTimeManager","CryptoWorker","$http","$q","$timeout",function(e,t,n,i,a,o,r,s){function c(t,n){var a=n.byteLength,s=new Int32Array(n),c=new TLSerialization;c.storeLongP(0,0,"auth_key_id"),c.storeLong(i.generateID(),"msg_id"),c.storeInt(a,"request_length");var l=c.getBuffer(),u=new Int32Array(l),d=l.byteLength,p=new ArrayBuffer(d+a),h=new Int32Array(p);return h.set(u),h.set(s,u.length),delete o.defaults.headers.post["Content-Type"],delete o.defaults.headers.common.Accept,"ArrayBufferView"in window||g&&!(30>g)||(h=h.buffer),o.post("http://"+e.chooseServer(t)+"/apiw1",h,{responseType:"arraybuffer",transformRequest:null}).then(function(e){if(!e.data||!e.data.byteLength)return r.reject({code:406,type:"NETWORK_BAD_RESPONSE"});try{{var t=new TLDeserialization(e.data,{mtproto:!0});t.fetchLong("auth_key_id"),t.fetchLong("msg_id"),t.fetchInt("msg_len")}}catch(n){return r.reject({code:406,type:"NETWORK_BAD_RESPONSE",originalError:n})}return rng_seed_time(),t},function(e){return e.message||e.type||(e={code:406,type:"NETWORK_BAD_REQUEST",originalError:e}),r.reject(e)})}function l(e){var n=e.deferred,i=new TLSerialization({mtproto:!0});i.storeMethod("req_pq",{nonce:e.nonce}),console.log(dT(),"Send req_pq",bytesToHex(e.nonce)),c(e.dcID,i.getBuffer()).then(function(i){var o=i.fetchObject("ResPQ");if("resPQ"!=o._)throw new Error("resPQ response invalid: "+o._);if(!bytesCmp(e.nonce,o.nonce))throw new Error("resPQ nonce mismatch");if(e.serverNonce=o.server_nonce,e.pq=o.pq,e.fingerprints=o.server_public_key_fingerprints,console.log(dT(),"Got ResPQ",bytesToHex(e.serverNonce),bytesToHex(e.pq),e.fingerprints),e.publicKey=t.select(e.fingerprints),!e.publicKey)throw new Error("No public key found");console.log(dT(),"PQ factorization start",e.pq),a.factorize(e.pq).then(function(t){e.p=t[0],e.q=t[1],console.log(dT(),"PQ factorization done",t[2]),u(e)},function(e){console.log("Worker error",e,e.stack),n.reject(e)})},function(e){console.log(dT(),"req_pq error",e.message),n.reject(e)}),s(function(){t.prepare()})}function u(e){var t=e.deferred;e.newNonce=new Array(32),n.nextBytes(e.newNonce);var i=new TLSerialization({mtproto:!0});i.storeObject({_:"p_q_inner_data",pq:e.pq,p:e.p,q:e.q,nonce:e.nonce,server_nonce:e.serverNonce,new_nonce:e.newNonce},"P_Q_inner_data","DECRYPTED_DATA");var a=sha1Hash(i.getBuffer()).concat(i.getBytes()),o=new TLSerialization({mtproto:!0});o.storeMethod("req_DH_params",{nonce:e.nonce,server_nonce:e.serverNonce,p:e.p,q:e.q,public_key_fingerprint:e.publicKey.fingerprint,encrypted_data:rsaEncrypt(e.publicKey,a)}),console.log(dT(),"Send req_DH_params"),c(e.dcID,o.getBuffer()).then(function(n){var i=n.fetchObject("Server_DH_Params","RESPONSE");if("server_DH_params_fail"!=i._&&"server_DH_params_ok"!=i._)return t.reject(new Error("Server_DH_Params response invalid: "+i._)),!1;if(!bytesCmp(e.nonce,i.nonce))return t.reject(new Error("Server_DH_Params nonce mismatch")),!1;if(!bytesCmp(e.serverNonce,i.server_nonce))return t.reject(new Error("Server_DH_Params server_nonce mismatch")),!1;if("server_DH_params_fail"==i._){var a=sha1Hash(e.newNonce).slice(-16);return bytesCmp(a,i.new_nonce_hash)?(t.reject(new Error("server_DH_params_fail")),!1):(t.reject(new Error("server_DH_params_fail new_nonce_hash mismatch")),!1)}try{d(e,i.encrypted_answer)}catch(o){return t.reject(o),!1}p(e)},function(e){t.reject(e)})}function d(e,t){e.localTime=tsNow(),e.tmpAesKey=sha1Hash(e.newNonce.concat(e.serverNonce)).concat(sha1Hash(e.serverNonce.concat(e.newNonce)).slice(0,12)),e.tmpAesIv=sha1Hash(e.serverNonce.concat(e.newNonce)).slice(12).concat(sha1Hash([].concat(e.newNonce,e.newNonce)),e.newNonce.slice(0,4));var n=aesDecrypt(t,e.tmpAesKey,e.tmpAesIv),a=n.slice(0,20),o=n.slice(20),r=bytesToArrayBuffer(o),s=new TLDeserialization(r,{mtproto:!0}),c=s.fetchObject("Server_DH_inner_data");if("server_DH_inner_data"!=c._)throw new Error("server_DH_inner_data response invalid: "+constructor);if(!bytesCmp(e.nonce,c.nonce))throw new Error("server_DH_inner_data nonce mismatch");if(!bytesCmp(e.serverNonce,c.server_nonce))throw new Error("server_DH_inner_data serverNonce mismatch");console.log(dT(),"Done decrypting answer"),e.g=c.g,e.dhPrime=c.dh_prime,e.gA=c.g_a,e.serverTime=c.server_time,e.retry=0;var l=s.getOffset();if(!bytesCmp(a,sha1Hash(o.slice(0,l))))throw new Error("server_DH_inner_data SHA1-hash mismatch");i.applyServerTime(e.serverTime,e.localTime)}function p(e){var t=e.deferred,i=bytesFromHex(e.g.toString(16));e.b=new Array(256),n.nextBytes(e.b),a.modPow(i,e.b,e.dhPrime).then(function(n){var i=new TLSerialization({mtproto:!0});i.storeObject({_:"client_DH_inner_data",nonce:e.nonce,server_nonce:e.serverNonce,retry_id:[0,e.retry++],g_b:n},"Client_DH_Inner_Data");var o=sha1Hash(i.getBuffer()).concat(i.getBytes()),r=aesEncrypt(o,e.tmpAesKey,e.tmpAesIv),s=new TLSerialization({mtproto:!0});s.storeMethod("set_client_DH_params",{nonce:e.nonce,server_nonce:e.serverNonce,encrypted_data:r}),console.log(dT(),"Send set_client_DH_params"),c(e.dcID,s.getBuffer()).then(function(n){var i=n.fetchObject("Set_client_DH_params_answer");return"dh_gen_ok"!=i._&&"dh_gen_retry"!=i._&&"dh_gen_fail"!=i._?(t.reject(new Error("Set_client_DH_params_answer response invalid: "+i._)),!1):bytesCmp(e.nonce,i.nonce)?bytesCmp(e.serverNonce,i.server_nonce)?void a.modPow(e.gA,e.b,e.dhPrime).then(function(n){var a=sha1Hash(n),o=a.slice(0,8),r=a.slice(-8);switch(console.log(dT(),"Got Set_client_DH_params_answer",i._),i._){case"dh_gen_ok":var s=sha1Hash(e.newNonce.concat([1],o)).slice(-16);if(!bytesCmp(s,i.new_nonce_hash1))return t.reject(new Error("Set_client_DH_params_answer new_nonce_hash1 mismatch")),!1;var c=bytesXor(e.newNonce.slice(0,8),e.serverNonce.slice(0,8));e.authKeyID=r,e.authKey=n,e.serverSalt=c,t.resolve(e);break;case"dh_gen_retry":var l=sha1Hash(e.newNonce.concat([2],o)).slice(-16);return bytesCmp(l,i.new_nonce_hash2)?p(e):(t.reject(new Error("Set_client_DH_params_answer new_nonce_hash2 mismatch")),!1);case"dh_gen_fail":var u=sha1Hash(e.newNonce.concat([3],o)).slice(-16);return bytesCmp(u,i.new_nonce_hash3)?(t.reject(new Error("Set_client_DH_params_answer fail")),!1):(t.reject(new Error("Set_client_DH_params_answer new_nonce_hash3 mismatch")),!1)}},function(e){t.reject(e)}):(t.reject(new Error("Set_client_DH_params_answer server_nonce mismatch")),!1):(t.reject(new Error("Set_client_DH_params_answer nonce mismatch")),!1)},function(e){t.reject(e)})},function(e){t.reject(e)})}function h(t){if(void 0!==m[t])return m[t];for(var n=[],i=0;16>i;i++)n.push(nextRandomInt(255));if(!e.chooseServer(t))return r.reject(new Error("No server found for dc "+t));var a={dcID:t,nonce:n,deferred:r.defer()};return s(function(){l(a)}),m[t]=a.deferred.promise,m[t]["catch"](function(){delete m[t]}),m[t]}var f=navigator.userAgent.match(/Chrome\/(\d+(\.\d+)?)/),g=f&&parseFloat(f[1])||!1,m={};return{auth:h}}]).factory("MtpNetworkerFactory",["MtpDcConfigurator","MtpTimeManager","MtpSecureRandom","Storage","CryptoWorker","$http","$q","$timeout","$interval","$rootScope",function(e,t,n,i,a,o,r,s,c,l){function u(e,t,n,i){i=i||{},this.dcID=e,this.iii=p++,this.authKey=t,this.authKeyID=sha1Hash(t).slice(-8),this.serverSalt=n,this.upload=i.fileUpload||i.fileDownload||!1,this.updateSession(),this.currentRequests=0,this.checkConnectionPeriod=0,this.sentMessages={},this.serverMessages=[],this.clientMessages=[],this.pendingMessages={},this.pendingAcks=[],this.pendingResends=[],this.connectionInited=!1,this.pendingTimeouts=[],this.longPollInt=c(this.checkLongPoll.bind(this),1e4),this.checkLongPoll(),h||(h=!0,l.offline=!0,l.offlineConnecting=!0),Config.Navigator.mobile&&this.setupMobileSleep()}var d,p=0,h=!1,f=navigator.userAgent.match(/Chrome\/(\d+(\.\d+)?)/),g=f&&parseFloat(f[1])||!1;return l.retryOnline=function(){$(document.body).trigger("online")},u.prototype.updateSession=function(){this.seqNo=0,this.sessionID=new Array(8),n.nextBytes(this.sessionID)},u.prototype.setupMobileSleep=function(){var e=this;l.$watch("idle.isIDLE",function(t){t?e.sleepAfter=tsNow()+3e4:(delete e.sleepAfter,e.checkLongPoll())}),l.$on("push_received",function(){e.sleepAfter&&(e.sleepAfter=tsNow()+3e4,e.checkLongPoll())})},u.prototype.updateSentMessage=function(e){var n=this.sentMessages[e];if(!n)return!1;var i=this;if(n.container){var a=[];angular.forEach(n.inner,function(e){var t=i.updateSentMessage(e);t&&a.push(t.msg_id)}),n.inner=a}return n.msg_id=t.generateID(),n.seq_no=this.generateSeqNo(n.notContentRelated||n.container),this.sentMessages[n.msg_id]=n,delete i.sentMessages[e],n},u.prototype.generateSeqNo=function(e){var t=2*this.seqNo;return e||(t++,this.seqNo++),t},u.prototype.wrapMtpCall=function(e,n,i){var a=new TLSerialization({mtproto:!0});a.storeMethod(e,n);var o=t.generateID(),r=this.generateSeqNo(),s={msg_id:o,seq_no:r,body:a.getBytes()};return Config.Modes.debug&&console.log(dT(),"MT call",e,n,o,r),this.pushMessage(s,i)},u.prototype.wrapMtpMessage=function(e,n){n=n||{};var i=new TLSerialization({mtproto:!0});i.storeObject(e,"Object");var a=t.generateID(),o=this.generateSeqNo(n.notContentRelated),r={msg_id:a,seq_no:o,body:i.getBytes()};return Config.Modes.debug&&console.log(dT(),"MT message",e,a,o),this.pushMessage(r,n)},u.prototype.wrapApiCall=function(e,n,i){var a=new TLSerialization(i);this.connectionInited||(a.storeInt(3479112071,"invokeWithLayer16"),a.storeInt(1769565673,"initConnection"),a.storeInt(Config.App.id,"api_id"),a.storeString(navigator.userAgent||"Unknown UserAgent","device_model"),a.storeString(navigator.platform||"Unknown Platform","system_version"),a.storeString(Config.App.version,"app_version"),a.storeString(navigator.language||"en","lang_code")),i.afterMessageID&&(a.storeInt(3416209197,"invokeAfterMsg"),a.storeLong(i.afterMessageID,"msg_id")),i.resultType=a.storeMethod(e,n);var o=t.generateID(),r=this.generateSeqNo(),s={msg_id:o,seq_no:r,body:a.getBytes(),isAPI:!0};return Config.Modes.debug?console.log(dT(),"Api call",e,n,o,r,i):console.log(dT(),"Api call",e),this.pushMessage(s,i)},u.prototype.checkLongPoll=function(){var e=this.cleanupSent();if(this.longPollPending&&tsNow()t.sleepAfter)||t.sendLongPoll()})},u.prototype.sendLongPoll=function(){var e=25e3,t=this;this.longPollPending=tsNow()+e,this.wrapMtpCall("http_wait",{max_delay:0,wait_after:0,max_wait:e},{noResponse:!0,longPoll:!0}).then(function(){delete t.longPollPending,s(t.checkLongPoll.bind(t),0)},function(){console.log("Long-poll failed")})},u.prototype.pushMessage=function(e,t){var n=r.defer();return this.sentMessages[e.msg_id]=angular.extend(e,t||{},{deferred:n}),this.pendingMessages[e.msg_id]=0,t&&t.noShedule||this.sheduleRequest(),angular.isObject(t)&&(t.messageID=e.msg_id),n.promise},u.prototype.pushResend=function(e,t){var n=t?tsNow()+t:0,i=this.sentMessages[e];if(i.container)for(var a=0;a=c)&&((o=d.sentMessages[t])&&(r.push(o),s+=o.body.length+32,o.isAPI?l=!0:o.longPoll&&(u=!0)),delete d.pendingMessages[t])}),l&&!u){var p=new TLSerialization({mtproto:!0});p.storeMethod("http_wait",{max_delay:0,wait_after:0,max_wait:1e3}),r.push({msg_id:t.generateID(),seq_no:this.generateSeqNo(),body:p.getBytes()})}if(r.length){var h=[];if(r.length>1){var f=new TLSerialization({mtproto:!0,startMaxLength:s+64});f.storeInt(1945237724,"CONTAINER[id]"),f.storeInt(r.length,"CONTAINER[count]");for(var g=[],n=0;ng)||(a=a.buffer),o.post("http://"+e.chooseServer(n.dcID)+"/apiw1",a,{responseType:"arraybuffer",transformRequest:null}).then(function(e){return e.data&&e.data.byteLength?e:r.reject({code:406,type:"NETWORK_BAD_RESPONSE"})},function(e){return e.message||e.type||(e={code:406,type:"NETWORK_BAD_REQUEST"}),r.reject(e)})})},u.prototype.parseResponse=function(e){var t=this,n=new TLDeserialization(e),i=n.fetchIntBytes(64,"auth_key_id");if(!bytesCmp(i,this.authKeyID))throw new Error("Invalid server auth_key_id: "+bytesToHex(i));var o=n.fetchIntBytes(128,"msg_key"),r=e.byteLength-n.getOffset(),s=n.fetchRawBytes(r,"encrypted_data");return this.getDecryptedMessage(o,s).then(function(e){var n=bytesToArrayBuffer(e),i=new TLDeserialization(n,{mtproto:!0}),r=(i.fetchIntBytes(64,"salt"),i.fetchIntBytes(64,"session_id")),s=i.fetchLong("message_id"),c=i.fetchInt("seq_no"),l=i.fetchRawBytes(!1,"message_data"),u=i.getOffset(); return a.sha1Hash(e.slice(0,u)).then(function(e){if(!bytesCmp(o,e.slice(-16)))throw new Error("server msgKey mismatch");var n=bytesToArrayBuffer(l),i={mtproto:!0,override:{mt_message:function(e,t){e.msg_id=this.fetchLong(t+"[msg_id]"),e.seqno=this.fetchInt(t+"[seqno]"),e.bytes=this.fetchInt(t+"[bytes]");var n=this.getOffset();try{e.body=this.fetchObject("Object",t+"[body]")}catch(i){console.error(dT(),"parse error",i.message,i.stack),e.body={_:"parse_error",error:i}}this.offset!=n+e.bytes&&(console.warn(dT(),"set offset",this.offset,n,e.bytes),console.log(dT(),e),this.offset=n+e.bytes)},mt_rpc_result:function(e,n){e.req_msg_id=this.fetchLong(n+"[req_msg_id]");var i=t.sentMessages[e.req_msg_id],a=i&&i.resultType||"Object";e.result=this.fetchObject(a,n+"[result]")}}},a=new TLDeserialization(n,i),u=a.fetchObject("","INPUT");return{response:u,messageID:s,sessionID:r,seqNo:c}})})},u.prototype.applyServerSalt=function(e){var t=longToBytes(e),n={};return n["dc"+this.dcID+"_server_salt"]=bytesToHex(t),i.set(n),this.serverSalt=t,!0},u.prototype.sheduleRequest=function(e){this.offline&&this.checkConnection("forced shedule");var t=tsNow()+e;return e&&this.nextReq&&this.nextReq<=t?!1:(s.cancel(this.nextReqPromise),this.nextReqPromise=s(this.performSheduledRequest.bind(this),e||0),void(this.nextReq=t))},u.prototype.onSessionCreate=function(){},u.prototype.ackMessage=function(e){this.pendingAcks.push(e),this.sheduleRequest(3e4)},u.prototype.reqResendMessage=function(e){console.log(dT(),"Req resend",e),this.pendingResends.push(e),this.sheduleRequest(100)},u.prototype.cleanupSent=function(){var e=this,t=!1;return angular.forEach(this.sentMessages,function(n,i){if(n.notContentRelated&&void 0===e.pendingMessages[i])delete e.sentMessages[i];else if(n.container){for(var a=0;ao;o++)this.processMessage(e.messages[o],n,i);break;case"bad_server_salt":console.log(dT(),"Bad server salt",e);var r=this.sentMessages[e.bad_msg_id];if(!r||r.seq_no!=e.bad_msg_seqno)throw console.log(e.bad_msg_id,e.bad_msg_seqno),new Error("Bad server salt for invalid message");this.applyServerSalt(e.new_server_salt),this.pushResend(e.bad_msg_id),this.ackMessage(n);break;case"bad_msg_notification":console.log(dT(),"Bad msg notification",e);var r=this.sentMessages[e.bad_msg_id];if(!r||r.seq_no!=e.bad_msg_seqno)throw console.log(e.bad_msg_id,e.bad_msg_seqno),new Error("Bad msg notification for invalid message");if(16==e.error_code||17==e.error_code){t.applyServerTime(bigStringInt(n).shiftRight(32).toString(10))&&(console.log(dT(),"Update session"),this.updateSession());var s=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(var o=0;o5?"[.."+e.result.length+"..]":e.result),console.log(dT(),"Rpc response",f)}r.deferred.resolve(e.result)}r.isAPI&&(this.connectionInited=!0)}delete this.sentMessages[u]}break;default:this.ackMessage(n),d&&d(e)}},{getNetworker:function(e,t,n,i){return new u(e,t,n,i)},setUpdatesProcessor:function(e){d=e}}}]),angular.module("izhukov.mtproto.wrapper",["izhukov.utils","izhukov.mtproto"]).factory("MtpApiManager",["Storage","MtpAuthorizer","MtpNetworkerFactory","ErrorService","$q",function(e,t,n,i,a){function o(t,n){e.set({dc:t,user_auth:angular.extend({dcID:t},n)}),f=t}function r(){return c("auth.logOut").then(function(){e.remove("dc","user_auth"),f=!1},function(t){e.remove("dc","user_auth"),t&&401!=t.code&&e.remove("dc"+f+"_auth_key"),f=!1,t.handled=!0})}function s(i,o){o=o||{};var r=o.fileUpload||o.fileDownload?p:d;if(!i)throw new Exception("get Networker without dcID");if(void 0!==r[i])return a.when(r[i]);var s="dc"+i+"_auth_key",c="dc"+i+"_server_salt";return e.get(s,c).then(function(l){if(void 0!==r[i])return r[i];var u=l[0],d=l[1];if(u&&512==u.length){var p=bytesFromHex(u),h=bytesFromHex(d);return r[i]=n.getNetworker(i,p,h,o)}return o.createNetworker?t.auth(i).then(function(t){var a={};return a[s]=bytesToHex(t.authKey),a[c]=bytesToHex(t.serverSalt),e.set(a),r[i]=n.getNetworker(i,t.authKey,t.serverSalt,o)},function(e){return console.log("Get networker error",e,e.stack),a.reject(e)}):a.reject({type:"AUTH_KEY_EMPTY",code:401})})}function c(t,n,o){o=o||{};var r,l,u=a.defer(),d=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||(new Error).stack,setTimeout(function(){e.handled||(i.show({error:e}),e.handled=!0)},100))};l=(r=o.dcID)?s(r,o):e.get("dc").then(function(e){return s(r=e||2,o)});var p,g=!1;if(l.then(function(i){return(p=i).wrapApiCall(t,n,o).then(function(e){u.resolve(e)},function(l){if(console.error(dT(),"Error",l.code,l.type,f,r),401==l.code&&f==r)e.remove("dc","user_auth");else if(401==l.code&&f&&r!=f){if(void 0===h[r]){var g=a.defer();c("auth.exportAuthorization",{dc_id:r},{noErrorBox:!0}).then(function(e){c("auth.importAuthorization",{id:e.id,bytes:e.bytes},{dcID:r,noErrorBox:!0}).then(function(){g.resolve()},function(e){g.reject(e)})},function(e){g.reject(e)}),h[r]=g.promise}h[r].then(function(){(p=i).wrapApiCall(t,n,o).then(function(e){u.resolve(e)},function(e){d(e)})},function(e){d(e)})}else if(303==l.code){var m=l.type.match(/^(PHONE_MIGRATE_|NETWORK_MIGRATE_)(\d+)/)[2];m!=r&&(o.dcID?o.dcID=m:e.set({dc:f=m}),s(m,o).then(function(e){e.wrapApiCall(t,n,o).then(function(e){u.resolve(e)},function(e){d(e)})}))}else d(l)})},function(e){d(e)}),!(g=g||(new Error).stack))try{window.unexistingFunction()}catch(m){g=m.stack||""}return u.promise}function l(){return e.get("user_auth").then(function(e){return e.id||0})}function u(){return f||!1}var d={},p={},h={},f=!1;return e.get("dc").then(function(e){e&&(f=e)}),{getBaseDcID:u,getUserID:l,invokeApi:c,getNetworker:s,setUserAuth:o,logOut:r}}]).factory("MtpApiFileManager",["MtpApiManager","$q","FileManager","IdbFileStorage","TmpfsFileStorage","MemoryFileStorage",function(e,t,n,i,a,o){function r(e,n,i){void 0===_[e]&&(_[e]=[],b[e]=0);var a=_[e],o=t.defer();return a.push({cb:n,deferred:o,activeDelta:i}),s(e),o.promise}function s(e){var t=_[e];if(b[e]>=w||!t||!t.length)return!1;var n=t.shift(),i=n.activeDelta||1;b[e]+=i;$++;n.cb().then(function(t){b[e]-=i,s(e),n.deferred.resolve(t)},function(t){b[e]-=i,s(e),n.deferred.reject(t)})}function c(e){switch(e._){case"inputVideoFileLocation":return"video"+e.id+".mp4";case"inputDocumentFileLocation":return"doc"+e.id;case"inputAudioFileLocation":return"audio"+e.id}return e.volume_id||console.trace("Empty location",e),e.volume_id+"_"+e.local_id+"_"+e.secret+".jpg"}function l(e){if(!e)return!1;var t=c(e);return y[t]||!1}function u(){return a.isAvailable()?a:i.isAvailable()?i:o}function d(e,t){var i=c(e),a="image/jpeg";return m[i]||(m[i]=u().saveFile(i,t).then(function(e){return y[i]=n.getUrl(e,a)})),m[i]}function p(i){if(!n.isAvailable())return t.reject({type:"BROWSER_BLOB_NOT_SUPPORTED"});var a=c(i),o="image/jpeg",s=m[a]||v[a];if(s)return s;var l=u();return v[a]=l.getFile(a).then(function(e){return y[a]=n.getUrl(e,o)},function(){var t=r(i.dc_id,function(){return e.invokeApi("upload.getFile",{location:angular.extend({},i,{_:"inputFileLocation"}),offset:0,limit:0},{dcID:i.dc_id,fileDownload:!0,createNetworker:!0})});return l.getFileWriter(a,o).then(function(e){return t.then(function(t){return n.write(e,t.bytes).then(function(){return y[a]=n.getUrl(e.finalize(),o)})})})})}function h(i,a,o,s){if(!n.isAvailable())return t.reject({type:"BROWSER_BLOB_NOT_SUPPORTED"});s=s||{};var l=c(a),d=s.toFileEntry||null,p=m[l]||v[l],h=u();if(p)return d?p.then(function(){return h.getFile(l).then(function(e){return n.copy(e,d)})}):p;var f,g=t.defer(),_=!1,b=!1,w=s.mime||"image/jpeg",$=function(e){g.reject(e),$=angular.noop,f&&f.truncate(0)};return h.getFile(l).then(function(e){d?n.copy(e,d).then(function(){g.resolve()},$):g.resolve(y[l]=n.getUrl(e,w))},function(){var s=d?n.getFileWriter(d):h.getFileWriter(l,w);s.then(function(s){f=s;for(var c,u=524288,p=t.when(),h=0;o>h;h+=u)c=t.defer(),function(c,p,h,f){return r(i,function(){return _?t.when():e.invokeApi("upload.getFile",{location:a,offset:p,limit:u},{dcID:i,fileDownload:!0,createNetworker:!0})},6).then(function(e){f.then(function(){return _?t.when():n.write(s,e.bytes).then(function(){h.resolve()},$).then(function(){c?(b=!0,d?g.resolve():g.resolve(y[l]=n.getUrl(s.finalize(),w))):g.notify({done:p+u,total:o})})})})}(h+u>=o,h,c,p),p=c.promise})}),g.promise.cancel=function(){_||b||(_=!0,delete v[l],$({type:"DOWNLOAD_CANCELED"}))},d||(v[l]=g.promise),g.promise}function f(n){var i=n.size,a=i>102400?524288:32768,o=i>=10485760,r=Math.ceil(i/a),s=!1,c=!1,l=0;if(r>1500)return t.reject({type:"FILE_TOO_BIG"});var u,d=[nextRandomInt(4294967295),nextRandomInt(4294967295)],p=t.defer(),h=function(e){p.reject(e),h=angular.noop},f=0,m={_:o?"inputFileBig":"inputFile",id:d,parts:r,name:n.name,md5_checksum:""},v=t.when();for(u=0;i>u;u+=a)!function(u,f){v=v.then(function(){var v=t.defer(),y=new FileReader,_=n.slice(u,u+a);return y.onloadend=function(t){if(!s&&t.target.readyState==FileReader.DONE){var n=g=g.then(function(){return e.invokeApi(o?"upload.saveBigFilePart":"upload.saveFilePart",{file_id:d,file_part:f,file_total_parts:r,bytes:bytesFromArrayBuffer(t.target.result)},{startMaxLength:a+256,fileUpload:!0})},h);n.then(function(){l++,v.resolve(),l>=r?(p.resolve(m),c=!0):(console.log(dT(),"Progress",l*a/i),p.notify({done:l*a,total:i}))},h)}},y.readAsArrayBuffer(_),v.promise})}(u,f++);return p.promise.cancel=function(){console.log("cancel upload",s,c),s||c||(s=!0,h({type:"UPLOAD_CANCELED"}))},p.promise}var g=t.when(),m={},v={},y={},_={},b={},w=5,$=0;return{getCachedFile:l,downloadFile:h,downloadSmallFile:p,saveSmallFile:d,uploadFile:f}}]),angular.module("myApp",["ngRoute","ngSanitize","ngTouch","ui.bootstrap","izhukov.utils","izhukov.mtproto","izhukov.mtproto.wrapper","myApp.filters","myApp.services","myApp.templates","myApp.directives","myApp.controllers"]).config(["$locationProvider","$routeProvider","$compileProvider","StorageProvider",function(e,t,n,i){var a,o,r,s,c,l,u,d={},p={};for(o=0;o=1e3?void o.resolve(r):void this.continue()},t.onerror=function(e){console.log("phonebook error",e,e.type,e.message),o.reject(e)},o.promise}return{isAvailable:a,openPhonebookImport:o,getPhonebookContacts:r}}]).service("AppChatsManager",["$rootScope","$modal","MtpApiFileManager","MtpApiManager","AppUsersManager","RichTextProcessor",function(e,t,n,i,a,o){function r(e){angular.forEach(e,s)}function s(e){angular.isObject(e)&&(e.rTitle=o.wrapRichText(e.title,{noLinks:!0,noLinebreaks:!0})||"DELETED",void 0===f[e.id]?f[e.id]=e:safeReplaceObject(f[e.id],e),void 0!==g[e.id]&&safeReplaceObject(g[e.id],e&&e.photo&&e.photo.photo_small||{empty:!0}))}function c(e){return f[e]||{id:e,deleted:!0}}function l(e){return angular.isObject(f[e])}function u(e,t){var n=c(e);return void 0===g[e]&&(g[e]=n&&n.photo&&n.photo.photo_small||{empty:!0}),{placeholder:"img/placeholders/"+t+"Avatar"+(Math.abs(e)%4+1)+"@2x.png",location:g[e]}}function d(e){c(e);return"g"+e}function p(e,t){var n=angular.copy(t),o=c(e);return n.participants&&"chatParticipants"==n.participants._&&i.getUserID().then(function(e){angular.forEach(n.participants.participants,function(t){t.user=a.getUser(t.user_id),t.inviter=a.getUser(t.inviter_id),t.canKick=e!=t.user_id&&(e==n.participants.admin_id||e==t.inviter_id)})}),n.thumb={placeholder:"img/placeholders/GroupAvatar"+(Math.abs(e)%4+1)+"@2x.png",location:o&&o.photo&&o.photo.photo_small,width:120,height:120,size:0},n.peerString=d(e),n.chat=o,n}function h(n){var i=e.$new();i.chatID=n;var a="partials/chat_modal.html",o="chat_modal_window page_modal";Config.Navigator.mobile&&(a="partials/mobile/chat_modal.html",o+=" mobile_modal");t.open({templateUrl:a,controller:"ChatModalController",scope:i,windowClass:o})}var f={},g={};return e.openChat=h,{saveApiChats:r,saveApiChat:s,getChat:c,getChatPhoto:u,getChatString:d,hasChat:l,wrapForFull:p,openChat:h}}]).service("AppPeersManager",["AppUsersManager","AppChatsManager",function(e,t){return{getInputPeer:function(e){var t="u"==e.charAt(0),n=e.substr(1).split("_");return t?{_:"inputPeerForeign",user_id:n[0],access_hash:n[1]}:{_:"inputPeerChat",chat_id:n[0]}},getInputPeerByID:function(t){return t>0?{_:"inputPeerForeign",user_id:t,access_hash:e.getUser(t).access_hash||0}:0>t?{_:"inputPeerChat",chat_id:-t}:void 0},getPeerSearchText:function(n){var i;if(n>0)i=e.getUserSearchText(n);else if(0>n){var a=t.getChat(-n);i=a.title||""}return i},getOutputPeer:function(e){return e>0?{_:"peerUser",user_id:e}:{_:"peerChat",chat_id:-e}},getPeerID:function(e){if(angular.isObject(e))return e.user_id?e.user_id:-e.chat_id;var t="u"==e.charAt(0),n=e.substr(1).split("_");return t?n[0]:-n[0]||0},getPeer:function(n){return n>0?e.getUser(n):t.getChat(-n)},getPeerPhoto:function(n,i,a){return n>0?e.getUserPhoto(n,i):t.getChatPhoto(-n,a)}}}]).service("SearchIndexManager",function(){function e(){return{shortIndexes:{},fullTexts:{}}}function t(e){e=e.replace(a," ").replace(o,"").toLowerCase();for(var t in r)r.hasOwnProperty(t)&&(e=e.replace(r[t],t));return e}function n(e,n,i){if(void 0!==i.fullTexts[e])return!1;if(n=t(n),!n.length)return!1;var a=i.shortIndexes;i.fullTexts[e]=n,angular.forEach(n.split(" "),function(t){var n,i,o=Math.min(t.length,3);for(i=1;o>=i;i++)n=t.substr(0,i),void 0===a[n]?a[n]=[e]:a[n].push(e)})}function i(e,n){var i=n.shortIndexes,a=n.fullTexts;e=t(e);var o,r,s,c,l,u=e.split(" "),d=!1;for(r=0;ro.length)&&(d=o)}for(o={},s=0;s,<\s]+/g,o=/^\s+|\s$/g,r={a:/[åáâäà]/g,e:/[éêëè]/g,i:/[íîïì]/g,o:/[óôöò]/g,u:/[úûüù]/g,c:/ç/g,ss:/ß/g};return{createIndex:e,indexObject:n,cleanSearchText:t,search:i}}).service("AppMessagesManager",["$q","$rootScope","$location","$filter","ApiUpdatesManager","AppUsersManager","AppChatsManager","AppPeersManager","AppPhotosManager","AppVideoManager","AppDocsManager","AppAudioManager","MtpApiManager","MtpApiFileManager","RichTextProcessor","NotificationsManager","SearchIndexManager","PeersSelectService","Storage",function(e,t,n,i,a,o,r,s,c,l,u,d,p,h,f,g,m,v,y){function _(t,n,i){var a=G;if(angular.isString(t)&&t.length){if(!i||et.query!==t){et.query=t;var c=m.search(t,J);et.dialogs=[],angular.forEach(G.dialogs,function(e){c[e.peerID]&&et.dialogs.push(e)}),et.count=et.dialogs.length}a=et}else et.query=!1;var l=0;if(n>0)for(l=0;la.dialogs[l].top_message);l++);return null!==a.count&&a.dialogs.length==a.count||a.dialogs.length>=l+(i||1)?e.when({count:a.count,dialogs:a.dialogs.slice(l,l+(i||20))}):(i=i||20,p.invokeApi("messages.getDialogs",{offset:l,limit:i,max_id:n||0}).then(function(e){if(o.saveApiUsers(e.users),r.saveApiChats(e.chats),E(e.messages),n>0)for(l=0;la.dialogs[l].top_message);l++);return a.count=e.count||e.dialogs.length,a.dialogs.splice(l,a.dialogs.length-l),angular.forEach(e.dialogs,function(e){var t=s.getPeerID(e.peer),n=s.getPeerSearchText(t);m.indexObject(t,n,J),a.dialogs.push({peerID:t,top_message:e.top_message,unread_count:e.unread_count}),void 0===W[t]&&(W[t]={count:null,history:[e.top_message],pending:[]}),g.savePeerSettings(t,e.notify_settings)}),{count:a.count,dialogs:a.dialogs.slice(l,l+i)}}))}function b(e,t,n,i){return p.invokeApi("messages.getHistory",{peer:e,offset:i||0,limit:n||0,max_id:t||0}).then(function(e){return o.saveApiUsers(e.users),r.saveApiChats(e.chats),E(e.messages),e})}function w(e,t,n,i){return b(e,t,n).then(function(a){i.count=a.count||a.messages.length;var o=0;if(t>0)for(o=0;oi.history[o]);o++);return i.history.splice(o,i.history.length-o),angular.forEach(a.messages,function(e){i.history.push(e.id)}),n-=a.messages.length,n>0&&i.history.length0)for(u=!0,l=0;lc.history[l]){u=!1;break}}else{var f=R(r);if(f&&f[0]&&f[0].unread_count>1){var g=f[0].unread_count;(p=g>50)?(i=10,d=6,l=g-d):(i=Math.max(10,o,g+2),d=g)}}return!u&&(null!==c.count&&c.history.length==c.count||c.history.length>=l+(i||1))?(a?(a=Math.min(l,a),l=Math.max(0,l-a),i+=a):i=i||(l?20:o||5),e.when({count:c.count,history:h.concat(c.history.slice(l,l+i)),unreadOffset:d,unreadSkip:p})):(a||i||(i=o||20),u&&(l=0),a||p||n&&-1==c.history.indexOf(n)?(a&&(l=-a,i+=a),b(t,n,i,l).then(function(e){c.count=e.count||e.messages.length;var t=[];return angular.forEach(e.messages,function(e){t.push(e.id)}),{count:c.count,history:h.concat(t),unreadOffset:d,unreadSkip:p}})):w(t,n,i,c).then(function(){if(l=0,n>0)for(l=0;lc.history[l]);l++);return{count:c.count,history:h.concat(c.history.slice(l,l+i)),unreadOffset:d,unreadSkip:p}}))}function C(t,n,i,a,c){var l=[],u=!n,d=s.getPeerID(t),h={peer:d,filter:i},f=u&&angular.equals(tt,h);if(u&&!f&&(tt=h,nt=[]),!a&&!n){var g=W[d];if(void 0!==g&&g.history.length){var m,v,y={},_=c||20;switch(i._){case"inputMessagesFilterPhotos":y.messageMediaPhoto=!0;break;case"inputMessagesFilterVideo":y.messageMediaVideo=!0;break;case"inputMessagesFilterPhotoVideo":y.messageMediaPhoto=!0,y.messageMediaVideo=!0;break;case"inputMessagesFilterDocument":y.messageMediaDocument=!0;break;case"inputMessagesFilterAudio":y.messageMediaAudio=!0}for(m=0;m=_)));m++);}if(l.length<_&&nt.length&&f)for(var b=l.length?l[l.length-1]:4294967295,m=0;m=_));m++);}return l.length||1e3==c?(u&&(nt=listMergeSorted(nt,l)),e.when({count:null,history:l})):p.invokeApi("messages.search",{peer:t,q:n||"",filter:i||{_:"inputMessagesFilterEmpty"},min_date:0,max_date:0,limit:c||20,max_id:a||0}).then(function(e){o.saveApiUsers(e.users),r.saveApiChats(e.chats),E(e.messages);var t=e.count||e.messages.length;return l=[],angular.forEach(e.messages,function(e){l.push(e.id)}),u&&(nt=listMergeSorted(nt,l)),{count:t,history:l}})}function S(e){return j[e]||{deleted:!0}}function k(e){return p.invokeApi("messages.deleteMessages",{id:e}).then(function(e){return a.processUpdateMessage({_:"updateShort",update:{_:"updateDeleteMessages",messages:e}}),e})}function x(t,n,i){return a.processUpdateMessage({_:"updates",seq:n.seq,updates:[]})?n.offset?p.invokeApi(i,{peer:t,offset:n.offset,max_id:0}).then(function(e){return x(t,e,i)}):e.when():!1}function M(e){var n=s.getPeerID(e),i=W[n],a=R(n);if(!a[0]||!a[0].unread_count){if(!i||!i.history.length)return!1;var o,r,c=!1;for(l=i.history.length;l>=0;l--)if(o=i.history[l],r=j[o],r&&!r.out&&r.unread){c=!0;break}if(!c)return!1}if(i.readPromise)return i.readPromise;if(i.readPromise=p.invokeApi("messages.readHistory",{peer:e,offset:0,max_id:0}).then(function(t){return x(e,t,"messages.readHistory")}).then(function(){a[0]&&(a[0].unread_count=0,t.$broadcast("dialog_unread",{peerID:n,count:0}),t.$broadcast("messages_read"))})["finally"](function(){delete i.readPromise}),i&&i.history.length){var o,r,l,n,a;for(l=0;l=0?(r="photo",c="photo."+i.type.split("/")[1]):"video/"==i.type.substr(0,6)?(r="video",c="video.mp4"):"audio/"==i.type.substr(0,6)?(r="audio",c="audio."+i.type.split("/")[1]||"mp3"):(r="document",c="document."+i.type.split("/")[1]):(r="document",c="document."+i.type.split("/")[1]),i.name||(i.name=c),void 0===f&&(f=W[n]={count:null,history:[],pending:[]}),p.getUserID().then(function(o){var c={_:"messageMediaPending",type:r,file_name:i.name,size:i.size,progress:{percent:1,total:i.size}},m={_:"message",id:l,from_id:o,to_id:s.getOutputPeer(n),out:!0,unread:!0,date:tsNow(!0)+it,message:"",media:c,random_id:d,pending:!0},v=function(e){var n=V[l];e?(m.error=!0,n&&(n.error=!0)):(delete m.error,n&&delete n.error),t.$broadcast("messages_pending")};m.send=function(){var o=e.defer();Z.then(function(){var e=!1,s=h.uploadFile(i);s.then(function(t){e=!0;var n;switch(r){case"photo":n={_:"inputMediaUploadedPhoto",file:t};break;case"video":n={_:"inputMediaUploadedVideo",file:t,duration:0,w:0,h:0,mime_type:i.type};break;case"audio":n={_:"inputMediaUploadedAudio",file:t,duration:0,mime_type:i.type};break;case"document":default:n={_:"inputMediaUploadedDocument",file:t,file_name:i.name,mime_type:i.type}}p.invokeApi("messages.sendMedia",{peer:g,media:n,random_id:u}).then(function(e){m.date=e.message.date,m.id=e.message.id,m.media=e.message.media,a.processUpdateMessage({_:"updates",users:e.users,chats:e.chats,seq:e.seq,updates:[{_:"updateMessageID",random_id:d,id:e.message.id},{_:"updateNewMessage",message:m,pts:e.pts}]})},function(){v(!0)})},function(){v(!0)},function(e){c.progress.done=e.done,c.progress.percent=Math.max(1,Math.floor(100*e.done/e.total)),t.$broadcast("history_update",{peerID:n}) }),c.progress.cancel=function(){e||(o.resolve(),s.cancel(),N(d))},s["finally"](function(){o.resolve()})}),Z=o.promise},E([m]),f.pending.unshift(l),t.$broadcast("history_append",{peerID:n,messageID:l,my:!0}),m.send()}),K[d]=[n,l]}function I(e,n){var i=Q--,o=[nextRandomInt(4294967295),nextRandomInt(4294967295)],r=bigint(o[0]).shiftLeft(32).add(bigint(o[1])).toString(),l=W[e],u=s.getInputPeerByID(e);void 0===l&&(l=W[e]={count:null,history:[],pending:[]}),p.getUserID().then(function(d){var h;switch(n._){case"inputMediaContact":h=angular.extend({},n,{_:"messageMediaContact"});break;case"inputMediaPhoto":h={photo:c.getPhoto(n.id.id)}}var f={_:"message",id:i,from_id:d,to_id:s.getOutputPeer(e),out:!0,unread:!0,date:tsNow(!0)+it,message:"",media:h,random_id:r,pending:!0},g=function(e){var n=V[i];e?(f.error=!0,n&&(n.error=!0)):(delete f.error,n&&delete n.error),t.$broadcast("messages_pending")};f.send=function(){p.invokeApi("messages.sendMedia",{peer:u,media:n,random_id:o}).then(function(e){f.date=e.message.date,f.id=e.message.id,f.media=e.message.media,a.processUpdateMessage({_:"updates",users:e.users,chats:e.chats,seq:e.seq,updates:[{_:"updateMessageID",random_id:r,id:e.message.id},{_:"updateNewMessage",message:f,pts:e.pts}]})},function(){g(!0)})},E([f]),l.pending.unshift(i),t.$broadcast("history_append",{peerID:e,messageID:i,my:!0}),f.send()}),K[r]=[e,i]}function P(e,t){return t=t.sort(),p.invokeApi("messages.forwardMessages",{peer:s.getInputPeerByID(e),id:t}).then(function(e){var t=[];angular.forEach(e.messages,function(n){t.push({_:"updateNewMessage",message:n,pts:e.pts})}),a.processUpdateMessage({_:"updates",users:e.users,chats:e.chats,seq:e.seq,updates:t})})}function N(e){var t=K[e];if(console.log("pending",e,t),t){var n,i=t[0],o=t[1],r=W[i];for(a.processUpdateMessage({_:"updateShort",update:{_:"updateDeleteMessages",messages:[o]}}),n=0;nt?t:e.out?t:e.from_id}function B(e,t){var n=-1!=t;if(n&&void 0!==z[e])return z[e];var i=angular.copy(j[e])||{id:e};return i.fromUser=o.getUser(i.from_id),(i.chatID=i.to_id.chat_id)?(i.peerID=-i.chatID,i.peerData=r.getChat(i.chatID),i.peerString=r.getChatString(i.chatID)):(i.peerID=i.out?i.to_id.user_id:i.from_id,i.peerData=o.getUser(i.peerID),i.peerString=o.getUserString(i.peerID)),i.peerPhoto=s.getPeerPhoto(i.peerID,"User","Group"),i.unreadCount=t,"messageService"==i._&&i.action.user_id&&(i.action.user=o.getUser(i.action.user_id)),i.message&&i.message.length&&(i.richMessage=f.wrapRichText(i.message.substr(0,64),{noLinks:!0,noLinebreaks:!0})),i.dateText=st(i.date),n&&(z[e]=i),i}function O(e){if(void 0!==V[e])return V[e];var t=angular.copy(j[e])||{id:e};if(t.media&&void 0!==t.media.progress&&(t.media.progress=j[e].media.progress),t.media)switch(t.media._){case"messageMediaPhoto":t.media.photo=c.wrapForHistory(t.media.photo.id);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=d.wrapForHistory(t.media.audio.id);break;case"messageMediaContact":t.media.rFullName=f.wrapRichText(t.media.first_name+" "+(t.media.last_name||""),{noLinks:!0,noLinebreaks:!0})}else if(t.action)switch(t.action._){case"messageActionChatEditPhoto":t.action.photo=c.wrapForHistory(t.action.photo.id);break;case"messageActionChatCreate":case"messageActionChatEditTitle":t.action.rTitle=f.wrapRichText(t.action.title,{noLinks:!0,noLinebreaks:!0})||"DELETED"}return t.message&&t.message.length&&(t.richMessage=f.wrapRichText(t.message)),V[e]=t}function U(e,t){if(!e||!e.length)return!1;var n,i,a,o,r,s,c,l=0,u=e.length,d=u,p=!1;for(t>0?d=Math.min(t,u):0>t&&(l=Math.max(0,d+t)),n=l;d>n;n++){if(o=e[n],i=Math.floor((o.date+H)/86400),c=r&&r.grouped,s=o.grouped,i===a?o.needDate&&(delete o.needDate,p=!0):(!n||r)&&(o.needDate||(o.needDate=!0,p=!0)),r&&o.from_id==r.from_id&&!r.fwd_from_id==!o.fwd_from_id&&!r.action&&!o.action&&o.date0?(l.title=(s.first_name||"")+(s.first_name&&s.last_name?" ":"")+(s.last_name||""),i=c,n=o.getUserString(a)):(l.title=(s.first_name||s.last_name||"Somebody")+" @ "+(r.getChat(-a).title||"Unknown chat"),i=r.getChatPhoto(-a,"Group"),n=r.getChatString(-a)),l.title=f.wrapPlainText(l.title),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?h.downloadSmallFile(i.location,i.size).then(function(t){l.image=t,e.unread&&g.notify(l)}):g.notify(l)}var H,j={},V={},z={},W={},G={count:null,dialogs:[]},K={},X={},Y={},Z=e.when(),Q=-1,J=m.createIndex(),et={query:!1},tt={},nt=[],it=0,at=tsNow(!0),ot=at-at%86400,rt=new Date;y.get("server_time_offset").then(function(e){e&&(it=e)});var st=i("dateOrTime");return rt.setHours(0),rt.setMinutes(0),rt.setSeconds(0),H=ot-Math.floor(+rt/1e3),g.start(),window.navigator.mozSetMessageHandler&&window.navigator.mozSetMessageHandler("activity",function(e){var n=e.source;console.log(dT(),"Received activity",n.name,n.data),"share"===n.name&&n.data.blobs.length>0&&v.selectPeer({confirm_type:"EXT_SHARE_PEER"}).then(function(e){var i=s.getPeerID(e);angular.forEach(n.data.blobs,function(e){D(i,e,{isMedia:!0})}),t.$broadcast("history_focus",{peerString:e})})}),t.$on("apiUpdate",function(e,n){switch(n._){case"updateMessageID":X[n.id]=n.random_id;break;case"updateNewMessage":var i=n.message,a=F(i),r=W[a];if(i.out||o.forceUserOnline(i.from_id),void 0!==r){{W[a].history[0]}if(-1!=W[a].history.indexOf(i.id))return!1;r.history.unshift(i.id),r.history.sort(function(e,t){return t-e})}else r=W[a]={count:null,history:[i.id],pending:[]};E([i]),null!==r.count&&r.count++;var c,l=X[i.id];l&&((c=L(l,i))&&t.$broadcast("history_update",{peerID:a}),delete X[i.id]),c||t.$broadcast("history_append",{peerID:a,messageID:i.id});var u,d=R(a);d.length?(u=d[0],G.dialogs.splice(d[1],1)):u={peerID:a,unread_count:0,top_message:!1},!i.out&&i.unread&&u.unread_count++,u.top_message=i.id,m.indexObject(a,s.getPeerSearchText(a),J),G.dialogs.unshift(u),t.$broadcast("dialogs_update",u),(t.idle.isIDLE||Config.Mobile&&t.selectedPeerID!=a)&&!i.out&&i.unread&&g.getPeerMuted(a).then(function(e){i.unread&&!e&&q(i)});break;case"updateReadMessages":var p,i,h,a,d,u,f={},v=!1;for(h=0;h0&&o.forceUserOnline(a):(d=R(a),d&&(f[a]=--d[0].unread_count),g.cancel("msg"+p)));angular.forEach(f,function(e,n){t.$broadcast("dialog_unread",{peerID:n,count:e})}),v&&t.$broadcast("messages_read");break;case"updateDeleteMessages":var p,i,h,a,d,u,y,f={},_={};for(h=0;ho&&(i=e,a=o)}),i}function u(e,t,n){return a.invokeApi("photos.getUserPhotos",{user_id:e,offset:0,limit:n||20,max_id:t||0}).then(function(e){r.saveApiUsers(e.users);for(var t=[],n=0;nn/i?o.height=parseInt(a.h*n/a.w):(o.width=parseInt(a.w*i/a.h),o.width>n&&(o.height=parseInt(o.height*n/o.width),o.width=n)),o.location=a.location,o.size=a.size):(o.width=100,o.height=100),t.thumb=o,t}function f(e){var n=h(e),i=$(window).width()-(Config.Navigator.mobile?20:36),a=$(t).height()-150,o=l(n,i,a),s={placeholder:"img/placeholders/PhotoThumbModal.gif"};return i>800&&(i-=200),s.width=i,s.height=a,o&&"photoSizeEmpty"!=o._&&(o.w/o.h>i/a?s.height=parseInt(o.h*i/o.w):(s.width=parseInt(o.w*a/o.h),s.width>i&&(s.height=parseInt(s.height*i/s.width),s.width=i)),!Config.Navigator.mobile&&s.width>=o.w&&s.height>=o.h&&(s.width=o.w,s.height=o.h),s.modalWidth=Math.max(s.width,Math.min(400,i)),s.location=o.location,s.size=o.size),n.full=s,n.fromUser=r.getUser(n.user_id),n}function g(t,n){if(!t||"0"===t)return!1;var a=i.$new(!0);a.photoID=t,0>n?a.userID=-n:a.messageID=n;e.open({templateUrl:"partials/photo_modal.html",controller:a.userID?"UserpicModalController":"PhotoModalController",scope:a,windowClass:"photo_modal_window"})}function m(e){var n=v[e],i="jpg",a="image/jpeg",r="photo"+e+"."+i,c=$(window).width()-36,u=$(t).height()-150,d=l(n,c,u),p={_:"inputFileLocation",volume_id:d.location.volume_id,local_id:d.location.local_id,secret:d.location.secret};s.chooseSave(r,i,a).then(function(e){o.downloadFile(d.location.dc_id,p,d.size,{mime:a,toFileEntry:e}).then(function(){console.log("file save done")},function(e){console.log("photo download failed",e)})},function(){o.downloadFile(d.location.dc_id,p,d.size,{mime:a}).then(function(e){s.download(e,a,r)},function(e){console.log("photo download failed",e)})})}var v={},y=$(window).width(),_=$(window).height();return i.preloadPhoto=d,i.openPhoto=g,{savePhoto:c,preloadPhoto:d,getUserPhotos:u,getPhoto:p,wrapForHistory:h,wrapForFull:f,openPhoto:g,downloadPhoto:m}}]).service("AppVideoManager",["$rootScope","$modal","$window","$timeout","MtpApiFileManager","AppUsersManager","FileManager",function(e,t,n,i,a,o,r){function s(e){p[e.id]=e,e.thumb&&"photoCachedSize"==e.thumb._&&(a.saveSmallFile(e.thumb.location,e.thumb.bytes),e.thumb.size=e.thumb.bytes.length,delete e.thumb.bytes,e.thumb._="photoSize")}function c(e){if(void 0!==h[e])return h[e];var t=angular.copy(p[e]),n=Math.min(f-80,479>=f?260:200),i=Math.min(g-100,479>=f?260:200),a=t.thumb,o={placeholder:"img/placeholders/VideoThumbConversation.gif",width:n,height:i};return a&&"photoSizeEmpty"!=a._&&(a.w/a.h>n/i?o.height=parseInt(a.h*n/a.w):(o.width=parseInt(a.w*i/a.h),o.width>n&&(o.height=parseInt(o.height*n/o.width),o.width=n)),o.location=a.location,o.size=a.size),t.thumb=o,h[e]=t}function l(e){var t=c(e),i=Math.min($(window).width()-60,542),a=$(n).height()-150,r={placeholder:"img/placeholders/VideoThumbModal.gif",width:i,height:a};return t.w&&t.h?t.w>t.h?r.height=parseInt(t.h*i/t.w):(r.width=parseInt(t.w*a/t.h),r.width>i&&(r.height=parseInt(r.height*i/r.width),r.width=i)):r.height=r.width=Math.min(i,a),t.full=r,t.fullThumb=angular.copy(t.thumb),t.fullThumb.width=r.width,t.fullThumb.height=r.height,t.fromUser=o.getUser(t.user_id),t}function u(n,i){var a=e.$new(!0);a.videoID=n,a.messageID=i;t.open({templateUrl:"partials/video_modal.html",controller:"VideoModalController",scope:a,windowClass:"video_modal_window"})}function d(t,n,i){function o(t){console.log("dl progress",t),c.progress.done=t.done,c.progress.percent=Math.max(1,Math.floor(100*t.done/t.total)),e.$broadcast("history_update")}var s=p[t],c=h[t]||s||{},l={_:"inputVideoFileLocation",id:t,access_hash:n||s.access_hash};c.progress={enabled:!0,percent:1,total:s.size};var u="mp4",d="video/mpeg4",f="video"+t+"."+u;r.chooseSave(f,u,d).then(function(e){var t=a.downloadFile(s.dc_id,l,s.size,{mime:d,toFileEntry:e});t.then(function(){delete c.progress,console.log("file save done")},function(e){console.log("video download failed",e),c.progress.enabled=!1},o),c.progress.cancel=t.cancel},function(){var e=a.downloadFile(s.dc_id,l,s.size,{mime:d});e.then(function(e){return delete c.progress,i?void window.open(e,"_blank"):void r.download(e,d,f)},function(e){console.log("video download failed",e),c.progress.enabled=!1},o),c.progress.cancel=e.cancel})}var p={},h={},f=$(window).width(),g=$(window).height();return e.openVideo=u,e.downloadVideo=d,{saveVideo:s,wrapForHistory:c,wrapForFull:l,openVideo:u}}]).service("AppDocsManager",["$rootScope","$modal","$window","$timeout","MtpApiFileManager","FileManager",function(e,t,n,i,a,o){function r(e){l[e.id]=e,e.thumb&&"photoCachedSize"==e.thumb._&&(a.saveSmallFile(e.thumb.location,e.thumb.bytes),e.thumb.size=e.thumb.bytes.length,delete e.thumb.bytes,e.thumb._="photoSize")}function s(e){if(void 0!==u[e])return u[e];var t=angular.copy(l[e]),n="image/gif"==t.mime_type,i=n?Math.min(d-80,260):100,a=n?Math.min(p-100,260):100,o=t.thumb,r={width:i,height:a};return o&&"photoSizeEmpty"!=o._?(o.w/o.h>i/a?r.height=parseInt(o.h*i/o.w):(r.width=parseInt(o.w*a/o.h),r.width>i&&(r.height=parseInt(r.height*i/r.width),r.width=i)),r.location=o.location,r.size=o.size):r=!1,t.thumb=r,t.canDownload=!(window.chrome&&chrome.fileSystem&&chrome.fileSystem.chooseEntry),t.withPreview=t.canDownload&&t.thumb&&t.mime_type.match(/^(image\/|application\/pdf)/)?1:0,t.withPreview&&n&&(t.isSpecial="gif"),u[e]=t}function c(t,n){function i(t){console.log("dl progress",t),s.progress.done=t.done,s.progress.percent=Math.max(1,Math.floor(100*t.done/t.total)),e.$broadcast("history_update")}var r=l[t],s=u[t]||r||{},c={_:"inputDocumentFileLocation",id:t,access_hash:r.access_hash};s.progress={enabled:!0,percent:1,total:r.size};var d=(r.file_name.split(".",2)||[])[1]||"";o.chooseSave(r.file_name,d,r.mime_type).then(function(e){var t=a.downloadFile(r.dc_id,c,r.size,{mime:r.mime_type,toFileEntry:e});t.then(function(){delete s.progress,console.log("file save done")},function(e){console.log("document download failed",e),s.progress.enabled=!1},i),s.progress.cancel=t.cancel},function(){var e=a.downloadFile(r.dc_id,c,r.size,{mime:r.mime_type});e.then(function(e){switch(delete s.progress,s.url=e,n){case 1:window.open(e,"_blank");break;default:o.download(e,r.mime_type,r.file_name)}},function(e){console.log("document download failed",e),s.progress.enabled=!1},i),s.progress.cancel=e.cancel})}var l={},u={},d=$(window).width(),p=$(window).height();return e.downloadDoc=c,{saveDoc:r,wrapForHistory:s,downloadDoc:c}}]).service("AppAudioManager",["$rootScope","$modal","$window","$timeout","$sce","MtpApiFileManager",function(e,t,n,i,a,o){function r(e){l[e.id]=e}function s(e){if(void 0!==u[e])return u[e];var t=angular.copy(l[e]);return u[e]=t}function c(t,n){function r(t){console.log("dl progress",t),c.progress.done=t.done,c.progress.percent=Math.max(1,Math.floor(100*t.done/t.total)),e.$broadcast("history_update")}var s=l[t],c=u[t]||s||{},d={_:"inputAudioFileLocation",id:t,access_hash:n||s.access_hash};c.progress={enabled:!0,percent:1,total:s.size};var p=o.downloadFile(s.dc_id,d,s.size,{mime:"audio/ogg"});p.then(function(t){delete c.progress,c.url=a.trustAsResourceUrl(t),c.autoplay=!0,i(function(){console.log("disable autoplay"),delete c.autoplay,e.$broadcast("history_update")},1e3)},function(e){console.log("audio download failed",e),c.progress.enabled=!1},r),c.progress.cancel=p.cancel}var l={},u={};return e.openAudio=c,{saveAudio:r,wrapForHistory:s,openAudio:c}}]).service("ExternalResourcesManager",["$q","$http",function(e,t){function n(e){return void 0!==i[e]?i[e]:i[e]=t.get(e,{responseType:"blob",transformRequest:null}).then(function(e){return window.URL=window.URL||window.webkitURL,window.URL.createObjectURL(e.data)})}var i={};return{downloadImage:n}}]).service("ApiUpdatesManager",["$rootScope","MtpNetworkerFactory","AppUsersManager","AppChatsManager","AppPeersManager","MtpApiManager",function(e,t,n,i,a,o){function r(){var e=g.seq+1,t=m[e];t&&(console.log(dT(),"pop pending update",e,t),c(t)&&delete m[e])}function s(){h||l()}function c(e){if(e.seq){if(!d(e.seq,e.seq_start))return m[e.seq_start||e.seq]=e,!1;e.date&&(g.date=e.date)}switch(e._){case"updatesTooLong":s();break;case"updateShort":u(e.update);break;case"updateShortMessage":if(!n.hasUser(e.from_id)){console.log("User not found",e.from_id,"getDiff"),s();break}u({_:"updateNewMessage",message:{_:"message",id:e.id,from_id:e.from_id,to_id:a.getOutputPeer(o.getUserID()),out:!1,unread:!0,date:e.date,message:e.message,media:{_:"messageMediaEmpty"}},pts:e.pts});break;case"updateShortChatMessage":if(!n.hasUser(e.from_id)||!i.hasChat(e.chat_id)){console.log("User or chat not found",e.from_id,e.chat_id,"getDiff"),s();break}u({_:"updateNewMessage",message:{_:"message",id:e.id,from_id:e.from_id,to_id:a.getOutputPeer(-e.chat_id),out:!1,unread:!0,date:e.date,message:e.message,media:{_:"messageMediaEmpty"}},pts:e.pts});break;case"updatesCombined":case"updates":n.saveApiUsers(e.users),i.saveApiChats(e.chats);for(var t,c,l,t=0;t=f.seqAwaiting&&(console.log(dT(),"cancel pending getDiff",f.seqAwaiting),clearTimeout(f.timeout),f=!1),!0}function l(){h=!0,f&&(clearTimeout(f.timeout),f=!1),o.invokeApi("updates.getDifference",{pts:g.pts,date:g.date,qts:0}).then(function(e){if("updates.differenceEmpty"==e._)return console.log(dT(),"apply empty diff",e.seq),g.date=e.date,g.seq=e.seq,h=!1,r(),!1;n.saveApiUsers(e.users),i.saveApiChats(e.chats),angular.forEach(e.other_updates,function(e){u(e)}),angular.forEach(e.new_messages,function(e){u({_:"updateNewMessage",message:e,pts:g.pts})});var t=e.intermediate_state||e.state;g.seq=t.seq,g.pts=t.pts,g.date=t.date,console.log(dT(),"apply diff",g.seq,g.pts),"updates.differenceSlice"==e._?l(!0):h=!1})}function u(t){t.pts&&(g.pts=t.pts),e.$broadcast("apiUpdate",t)}function d(e,t){return(t=t||e)?h?(console.log(dT(),"Seq decline",t),!1):t!=g.seq+1?(t>g.seq&&(console.warn(dT(),"Seq hole",t,f&&f.seqAwaiting),f||(f={seqAwaiting:t,timeout:setTimeout(function(){l()},5e3)})),!1):(g.seq=e,!0):!0}function p(){t.setUpdatesProcessor(c),o.invokeApi("updates.getState").then(function(e){g.seq=e.seq,g.pts=e.pts,g.date=e.date,h=!1})}var h=!0,f=!1,g={},m={};return{processUpdateMessage:c,attach:p}}]).service("RichTextProcessor",["$sce","$sanitize",function(e,t){function n(e){return e.replace(/&/g,"&").replace(/([^\#-~| |!])/g,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(//g,">")}function i(e){for(var t,n,i,a,o=0;o-1)return n=Math.floor(t/a),i=t%a,{category:o,row:n,column:i};return console.error("emoji not found in spritesheet",e),null}function a(a,o){if(!a||!a.length)return"";o=o||{},a=a.replace(/\ufe0f/g,"",a);for(var s,d,p,h=a,m=[],v=!1;s=h.match(f);)m.push(n(h.substr(0,s.index))),s[1]?o.noLinks?m.push(n(s[0])):s[3]?m.push('',n(s[3]+s[4]),""):m.push('',n(s[2]+"://"+s[4]),""):s[5]?m.push(o.noLinebreaks?" ":"
"):s[6]?(r=c[s[6]])&&(p=i(r))?(d=n(l[r][1][0]),v=!0,m.push('',":",d,":")):m.push(n(s[6])):s[8]&&(o.noLinks?m.push(s[7],n(s[8])):m.push(s[7],'',n(s[8]),"")),h=h.substr(s.index+s[0].length);if(m.push(n(h)),a=t(m.join("")),v&&(a=a.replace(//g,'')),!o.noLinks){var y=a.match(g),_=y&&y[1];if(_){var b=Config.Modes.chrome_packed?"webview":"iframe";a=a+'
<'+b+' type="text/html" frameborder="0" src="http://www.youtube.com/embed/'+_+'?autoplay=0&controls=2">
"}}return e.trustAs("html",a)}function o(e,t){if(d)return e;if(!e||!e.length)return"";t=t||{},e=e.replace(/\ufe0f/g,"",e);for(var n,i,a=e,e=[];n=a.match(f);)e.push(a.substr(0,n.index)),e.push(n[6]?(r=c[n[6]])&&(i=l[r][1][0])?":"+i+":":n[0]:n[0]),a=a.substr(n.index+n[0].length);return e.push(a),e.join("")}var r,s=[],c={},l=Config.Emoji,u=18,d=-1!=navigator.userAgent.search(/OS X|iPhone|iPad|iOS|Android/i);for(r in l)s.push(l[r][0]),c[l[r][0]]=r;var p="a-z\\u00c0-\\u00d6\\u00d8-\\u00f6\\u00f8-\\u00ff\\u0100-\\u024f\\u0253\\u0254\\u0256\\u0257\\u0259\\u025b\\u0263\\u0268\\u026f\\u0272\\u0289\\u028b\\u02bb\\u0300-\\u036f\\u1e00-\\u1eff\\u0400-\\u04ff\\u0500-\\u0527\\u2de0-\\u2dff\\ua640-\\ua69f\\u0591-\\u05bf\\u05c1-\\u05c2\\u05c4-\\u05c5\\u05c7\\u05d0-\\u05ea\\u05f0-\\u05f4\\ufb1d-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40-\\ufb41\\ufb43-\\ufb44\\ufb46-\\ufb4f\\u0610-\\u061a\\u0620-\\u065f\\u066e-\\u06d3\\u06d5-\\u06dc\\u06de-\\u06e8\\u06ea-\\u06ef\\u06fa-\\u06fc\\u06ff\\u0750-\\u077f\\u08a0\\u08a2-\\u08ac\\u08e4-\\u08fe\\ufb50-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\u200c\\u0e01-\\u0e3a\\u0e40-\\u0e4e\\u1100-\\u11ff\\u3130-\\u3185\\uA960-\\uA97F\\uAC00-\\uD7AF\\uD7B0-\\uD7FF\\u3003\\u3005\\u303b\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uff9f\\uffa1-\\uffdc",h="0-9._"+p,f=new RegExp("((?:(ftp|https?)://|(?:mailto:)?([A-Za-z0-9._%+-]+@))(\\S*\\.\\S*[^\\s.;,(){}<>\"']))|(\\n)|("+s.join("|")+")|(^|\\s)(#["+h+"]{3,20})","i"),g=/(?:https?:\/\/)?(?:www\.)?youtu(?:|.be|be.com|.b)(?:\/v\/|\/watch\\?v=|e\/|\/watch(?:.+)v=)(.{11})(?:\&[^\s]*)?/;return{wrapRichText:a,wrapPlainText:o}}]).service("IdleManager",["$rootScope","$window","$timeout",function(e,t,n){function i(){r||(r=!0,$(t).on("blur focus keydown mousedown touchstart",a),setTimeout(function(){a({type:"blur"})},0))}function a(i){"mousemove"==i.type&&$(t).off("mousemove",a);var r="blur"==i.type||"timeout"==i.type?!0:!1;n.cancel(o),r||(o=n(function(){a({type:"timeout"})},3e4)),e.idle.isIDLE!=r&&(e.$apply(function(){e.idle.isIDLE=r}),r&&"timeout"==i.type&&$(t).on("mousemove",a))}e.idle={isIDLE:!1};var o,r=!1;return{start:i}}]).service("StatusManager",["$timeout","$rootScope","MtpApiManager","IdleManager",function(e,t,n){function i(){c||(c=!0,t.$watch("idle.isIDLE",o),t.$watch("offline",o))}function a(e){var i=tsNow();if(!(e&&!s||!e&&5e4>i-s||t.offline))return s=e?0:i,n.invokeApi("account.updateStatus",{offline:e},{noErrorBox:!0})}function o(){r&&e.cancel(r),t.idle.isIDLE?r=e(function(){a(!0)},5e3):(a(!1),r=e(o,6e4))}var r,s=0,c=!1;return{start:i}}]).service("NotificationsManager",["$rootScope","$window","$timeout","$interval","$q","MtpApiManager","AppPeersManager","IdleManager","Storage",function(e,t,n,i,a,o,r,s,c){function l(e){return void 0!==T[e]?T[e]:T[e]=o.invokeApi("account.getNotifySettings",{peer:{_:"inputNotifyPeer",peer:r.getInputPeerByID(e)}})}function u(e,t){T[e]=a.when(t)}function d(e,t){u(e,t);var n=angular.copy(t);return n._="inputPeerNotifySettings",o.invokeApi("account.updateNotifySettings",{peer:{_:"inputNotifyPeer",peer:r.getInputPeerByID(e)},settings:n})}function p(e){return l(e).then(function(e){return"peerNotifySettings"==e._&&1e3*e.mute_until>tsNow()})}function h(){if(_(),!C)return!1;"Notification"in window&&"granted"!==Notification.permission&&"denied"!==Notification.permission&&$(t).on("click",f);try{$(t).on("beforeunload",y)}catch(e){}}function f(){Notification.requestPermission(),$(t).off("click",f)}function g(e){return Config.Navigator.ffos&&(e.image="https://raw.githubusercontent.com/zhukov/webogram/master/app/img/icons/icon60.png"),x++,!C||"Notification"in window&&"granted"!==Notification.permission?!1:(c.get("notify_nosound","notify_volume").then(function(e){(!e[0]&&e[1]===!1||e[1]>0)&&m(e[1]||.5)}),void c.get("notify_nodesktop","notify_novibrate").then(function(t){if(t[0]){if(M&&!t[1])return void navigator.vibrate([200,100,200])}else{var n,i=++k,a=e.key||"k"+i;if("Notification"in window)n=new Notification(e.title,{icon:e.image||"",body:e.message||"",tag:e.tag||""});else{if(!("mozNotification"in navigator))return;n=navigator.mozNotification.createNotification(e.title,e.message||"",e.image||"")}n.onclick=function(){n.close(),window.navigator.mozApps&&document.hidden?window.navigator.mozApps.getSelf().onsuccess=function(){this.result.launch()}:(window.chrome&&chrome.app&&chrome.app.window&&chrome.app.window.current().focus(),window.focus()),y(),e.onclick&&e.onclick()},n.onclose=function(){delete S[a],y()},n.show&&n.show(),S[a]=n}}))}function m(e){var t="img/sound_a.wav",n=$("#notify_sound").html('');n.find("audio")[0].volume=e}function v(e){var t=S[e];if(t){x>0&&x--;try{t.close&&t.close()}catch(n){}delete x[e]}}function y(){angular.forEach(S,function(e){try{e.close&&e.close()}catch(t){}}),S={},x=0}function _(){if(I)return!1;if(navigator.push&&Config.Navigator.ffos&&Config.Modes.packed){var e=navigator.push.register();e.onsuccess=function(){clearTimeout(N),console.log(dT(),"Push registered",e.result),I=e.result,o.invokeApi("account.registerDevice",{token_type:4,token:I,device_model:navigator.userAgent||"Unknown UserAgent",system_version:navigator.platform||"Unknown Platform",app_version:Config.App.version,app_sandbox:!1,lang_code:navigator.language||"en"})},e.onerror=function(e){console.error("Push register error",e,e.toString()),N=setTimeout(_,P),P=Math.min(3e4,1.5*P)}}}function b(){return M}navigator.vibrate=navigator.vibrate||navigator.mozVibrate||navigator.webkitVibrate;var w,C="Notification"in window||"mozNotification"in navigator,S={},k=0,x=0,M=!!navigator.vibrate,T={},E=$('link[rel="icon"]'),A=$(''),D=document.title;e.$watch("idle.isIDLE",function(e){i.cancel(w),e?(D=document.title,w=i(function(){var e=tsNow();if(!x||e%2e3>1e3){document.title=D;var t=$('link[rel="icon"]');-1!=t.attr("href").indexOf("favicon_unread")&&t.replaceWith(E)}else document.title=x>1?x+" notifications":"1 notification",$('link[rel="icon"]').replaceWith(A)},1e3)):(document.title=D,$('link[rel="icon"]').replaceWith(E),y())}),e.$on("apiUpdate",function(e,t){switch(t._){case"updateNotifySettings":if("notifyPeer"==t.peer._){var n=r.getPeerID(t.peer.peer);u(n,t.notify_settings)}}});var I=!1;return window.navigator.mozSetMessageHandler&&(window.navigator.mozSetMessageHandler("push",function(t){console.log(dT(),"received push",t),e.$broadcast("push_received")}),window.navigator.mozSetMessageHandler("push-register",function(e){console.log(dT(),"received push",e),I=!1,_()})),{start:h,notify:g,cancel:v,clear:y,getPeerSettings:l,getPeerMuted:p,savePeerSettings:u,updatePeerSettings:d,getVibrateSupport:b,testSound:m};var P,N}]).service("ErrorService",["$rootScope","$modal","$window",function(e,t,n){function i(n,i){if(r>=2)return console.log("Skip error box, too many open",r,n,i),!1;i=i||{};var a=e.$new();angular.extend(a,n),r++;var o=t.open({templateUrl:"partials/error_modal.html",scope:a,windowClass:i.windowClass||"error_modal_window"});return o.result["finally"](function(){r--}),o}function a(e,t){return i({title:e,description:t})}function o(n,i){i=i||{};var a=e.$new();angular.extend(a,n);var o=t.open({templateUrl:"partials/confirm_modal.html",scope:a,windowClass:i.windowClass||"confirm_modal_window"});return o.result}var r=0;return n.safeConfirm=function(e,t){"string"==typeof e&&(e={message:e}),o(e).then(function(e){t(e||!0)},function(){t(!1)})},{show:i,alert:a,confirm:o}}]).service("PeersSelectService",["$rootScope","$modal",function(e,t){function n(n){var i=e.$new();n&&angular.extend(i,n);var a="partials/peer_select.html",o="peer_select_window page_modal";return Config.Navigator.mobile&&(a="partials/mobile/peer_select.html",o+=" mobile_modal"),t.open({templateUrl:a,controller:"PeerSelectController",scope:i,windowClass:o}).result}return{selectPeer:n}}]).service("ContactsSelectService",["$rootScope","$modal",function(e,t){function n(n,i){i=i||{};var a=e.$new();a.multiSelect=n,angular.extend(a,i),!a.action&&n&&(a.action="select");var o="partials/contacts_modal.html",r="contacts_modal_window page_modal";return Config.Navigator.mobile&&(o="partials/mobile/contacts_modal.html",r+=" mobile_modal"),t.open({templateUrl:o,controller:"ContactsModalController",scope:a,windowClass:r}).result}return{selectContacts:function(e){return n(!0,e)},selectContact:function(e){return n(!1,e)}}}]).service("ChangelogNotifyService",["Storage","$rootScope","$http","$modal",function(e,t,n,i){function a(e,t){"string"!=typeof e&&(e=""),"string"!=typeof t&&(t=""),e=e.replace(/^\s+|\s+$/g,"").split("."),t=t.replace(/^\s+|\s+$/g,"").split("."); var n,i=Math.max(e.length,t.length);for(n=0;i>n;n++)if(e[n]!=t[n])return e[n]>t[n]?1:-1;return 0}function o(){e.get("last_version").then(function(t){t!=Config.App.version&&(t&&r(t),e.set({last_version:Config.App.version}))})}function r(e){var n=t.$new();n.lastVersion=e,n.canShowVersion=function(t){return n.lastVersion===!1||void 0===n.lastVersion?!0:a(t,e)>=0},i.open({templateUrl:"partials/changelog_modal.html",scope:n,windowClass:"changelog_modal_window page_modal"})}return{checkUpdate:o,showChangelog:r}}]),angular.module("myApp.controllers",[]).controller("AppWelcomeController",["$scope","$location","MtpApiManager","ErrorService","ChangelogNotifyService",function(e,t,n,i,a){n.getUserID().then(function(n){n?t.url("/im"):e.showWelcome=!0}),a.checkUpdate()}]).controller("AppLoginController",["$scope","$location","$timeout","$modal","$modalStack","MtpApiManager","ErrorService","ChangelogNotifyService",function(e,t,n,i,a,o,r,s){function c(){var t=(navigator.language||"").toLowerCase(),n=Config.LangCountries[t],i=!Config.Navigator.mobile;if(l(-1==["en","en-us","en-uk"].indexOf(t)?void 0!==n?n:t.indexOf("-")>0?t.split("-")[1].toUpperCase():"US":"US"),i){var a=e.credentials.phone_country;o.invokeApi("help.getNearestDc",{},{dcID:4,createNetworker:!0}).then(function(t){a==e.credentials.phone_country&&l(t.country),t.nearest_dc!=t.this_dc&&o.getNetworker(t.nearest_dc,{createNetworker:!0})})}}function l(e){var t,n;for(t=0;to&&!a.indexOf(i)&&(o=i.length,r=Config.CountryCodes[t][1]);e.credentials.phone_full=a,e.credentials.phone_country_name=r||"Unknown"}function p(e){o.setUserAuth(f.dcID,{expires:e.expires,id:e.user.id}),n.cancel(m),t.url("/im")}function h(){n.cancel(m),e.credentials.viaApp||(--e.callPending.remaining?m=n(h,1e3):(e.callPending.success=!1,o.invokeApi("auth.sendCall",{phone_number:e.credentials.phone_full,phone_code_hash:e.credentials.phone_code_hash},f).then(function(){e.callPending.success=!0})))}a.dismissAll(),o.getUserID().then(function(e){return e?void t.url("/im"):void 0});var f={dcID:2,createNetworker:!0},g=!1;e.credentials={phone_country:"",phone_country_name:"",phone_number:"",phone_full:""},e.progress={},e.callPending={},e.chooseCountry=function(){var e="partials/country_select_modal.html",t="countries_modal_window page_modal";Config.Navigator.mobile&&(e="partials/mobile/country_select_modal.html",t+=" mobile_modal");var n=i.open({templateUrl:e,controller:"CountrySelectModalController",windowClass:t});n.result.then(u)},e.$watch("credentials.phone_country",d),e.$watch("credentials.phone_number",d),c();var m;e.sendCode=function(){n.cancel(m),r.confirm({type:"LOGIN_PHONE_CORRECT",country_code:e.credentials.phone_country,phone_number:e.credentials.phone_number}).then(function(){e.progress.enabled=!0,o.invokeApi("auth.sendCode",{phone_number:e.credentials.phone_full,sms_type:5,api_id:Config.App.id,api_hash:Config.App.hash},f).then(function(t){e.progress.enabled=!1,e.credentials.phone_code_hash=t.phone_code_hash,e.credentials.phone_occupied=t.phone_registered,e.credentials.viaApp="auth.sentAppCode"==t._,e.callPending.remaining=t.send_call_timeout||60,e.error={},h()},function(t){switch(e.progress.enabled=!1,console.log("sendCode error",t),t.type){case"NETWORK_BAD_REQUEST":"https:"==location.protocol&&(r.confirm({type:"HTTPS_MIXED_FAIL"}).then(function(){location=location.toString().replace(/^https:/,"http:")}),t.handled=!0);break;case"PHONE_NUMBER_INVALID":e.error={field:"phone"},t.handled=!0}})})},e.sendSms=function(){e.credentials.viaApp&&(delete e.credentials.viaApp,o.invokeApi("auth.sendSms",{phone_number:e.credentials.phone_full,phone_code_hash:e.credentials.phone_code_hash},f).then(h))},e.editPhone=function(){n.cancel(m),delete e.credentials.phone_code_hash,delete e.credentials.phone_unoccupied,delete e.credentials.phone_code_valid,delete e.credentials.viaApp,delete e.callPending.remaining,delete e.callPending.success},e.logIn=function(t){var n="auth.signIn",i={phone_number:e.credentials.phone_full,phone_code_hash:e.credentials.phone_code_hash,phone_code:e.credentials.phone_code};t&&(n="auth.signUp",angular.extend(i,{first_name:e.credentials.first_name,last_name:e.credentials.last_name})),e.progress.enabled=!0,o.invokeApi(n,i,f).then(p,function(t){if(e.progress.enabled=!1,400==t.code&&"PHONE_NUMBER_UNOCCUPIED"==t.type)return t.handled=!0,e.credentials.phone_code_valid=!0,void(e.credentials.phone_unoccupied=!0);if(400==t.code&&"PHONE_NUMBER_OCCUPIED"==t.type)return t.handled=!0,e.logIn(!1);switch(t.type){case"FIRSTNAME_INVALID":e.error={field:"first_name"},t.handled=!0;break;case"LASTNAME_INVALID":e.error={field:"last_name"},t.handled=!0;break;case"PHONE_CODE_INVALID":e.error={field:"phone_code"},delete e.credentials.phone_code_valid,t.handled=!0}})},s.checkUpdate()}]).controller("AppIMController",["$scope","$location","$routeParams","$modal","$rootScope","$modalStack","MtpApiManager","AppUsersManager","ContactsSelectService","ChangelogNotifyService","ErrorService",function(e,t,n,i,a,o,r,s,c,l,u){function d(){if(n.q){if(n.q!==p&&(e.search.query=p=n.q,e.search.messages=!0,void 0!==e.curDialog))return!1}else p=!1;e.curDialog={peer:n.p||!1,messageID:n.m||!1}}e.$on("$routeUpdate",d),e.$on("history_focus",function(n,i){o.dismissAll(),i.peerString==e.curDialog.peer&&i.messageID==e.curDialog.messageID?e.$broadcast(i.messageID?"ui_history_change_scroll":"ui_history_focus"):t.url("/im?p="+i.peerString+(i.messageID?"&m="+i.messageID:""))}),e.isLoggedIn=!0,e.isEmpty={},e.search={},e.historyFilter={mediaType:!1},e.historyPeer={},e.historyState={selectActions:!1,typing:[]},e.openSettings=function(){var e="partials/settings_modal.html",t="settings_modal_window page_modal";Config.Navigator.mobile&&(e="partials/mobile/settings_modal.html",t+=" mobile_modal"),i.open({templateUrl:e,controller:"SettingsModalController",windowClass:t})},e.openContacts=function(){c.selectContact().then(function(t){e.dialogSelect(s.getUserString(t))})},e.openGroup=function(){c.selectContacts({action:"new_group"}).then(function(t){if(1==t.length)e.dialogSelect(s.getUserString(t[0]));else if(t.length>1){var n=a.$new();n.userIDs=t,i.open({templateUrl:"partials/chat_create_modal.html",controller:"ChatCreateModalController",scope:n,windowClass:"group_edit_modal_window"})}})},e.importContact=function(){s.openImportContact().then(function(t){t&&e.$broadcast("contact_imported")})},e.dialogSelect=function(e,t){var n={peerString:e};t&&(n.messageID=t),a.$broadcast("history_focus",n)},e.logOut=function(){u.confirm({type:"LOGOUT"}).then(function(){r.logOut().then(function(){location.hash="/login",location.reload()})})},e.showPeerInfo=function(){e.curDialog.peerID>0?a.openUser(e.curDialog.peerID):e.curDialog.peerID<0&&a.openChat(-e.curDialog.peerID)},e.toggleEdit=function(){e.$broadcast("history_edit_toggle")},e.selectedFlush=function(){e.$broadcast("history_edit_flush")},e.toggleMedia=function(t){e.$broadcast("history_media_toggle",t)},e.returnToRecent=function(){e.$broadcast("history_return_recent")},e.toggleSearch=function(){e.$broadcast("dialogs_search_toggle")},d();var p=!1;l.checkUpdate()}]).controller("AppImDialogsController",["$scope","$location","$q","$timeout","$routeParams","MtpApiManager","AppUsersManager","AppChatsManager","AppMessagesManager","AppPeersManager","PhonebookContactsService","ErrorService",function(e,t,n,i,a,o,r,s,c,l,u,d){function p(a){var r,s=e.search.messages&&e.search.query.length>0,l=++_;return i.cancel($),s?($=a?n.when():i(angular.noop,500),r=$.then(function(){return c.getSearch({_:"inputPeerEmpty"},e.search.query,{_:"inputMessagesFilterEmpty"},v)})):r=c.getDialogs(e.search.query,v),r.then(function(e){if(l!=_)return n.reject();if(s){var t=[];angular.forEach(e.history,function(e){var n=c.getMessage(e),i=c.getMessagePeer(n);t.push({peerID:i,top_message:e,unread_count:-1})}),e={count:e.count,dialogs:t}}return e},function(e){return"NETWORK_BAD_REQUEST"==e.type&&"https:"==location.protocol&&(d.confirm({type:"HTTPS_MIXED_FAIL"}).then(function(){location=location.toString().replace(/^https:/,"http:")}),e.handled=!0),401==e.code&&(o.logOut()["finally"](function(){t.url("/login")}),e.handled=!0),n.reject()})}function h(t){m=0,v=0,y=!1,b={},g=!1,p(t).then(function(t){e.dialogs=[],e.contacts=[],t.dialogs.length&&(m+=t.dialogs.length,v=t.dialogs[t.dialogs.length-1].top_message,y=null===t.count||m-1?(i=e.peerHistories[o],o&&(e.peerHistories.splice(o,1),e.peerHistories.unshift(i)),i):(i={peerID:t,messages:[]},e.peerHistories.unshift(i),a=e.peerHistories.length-r,a>0&&e.peerHistories.splice(r-1,a),i)}function m(t){var n;for(n=0;n=0;o--)r=i.history[o],r>B&&P.messages.push(s.wrapForHistory(r));i.history.length?(B=i.history.length>=a?i.history[0]:0,s.regroupWrappedHistory(P.messages,-a)&&e.$broadcast("messages_regroup"),delete e.state.empty,e.$broadcast("ui_history_append")):B=0,e.skippedHistory=L=B>0,j&&b()}})}}function b(){if(N){if(z)return void(j=!0);j=!1,H=!0;var t=R,n=q,i=e.historyFilter.mediaType&&{_:U[e.historyFilter.mediaType]},a=Config.Navigator.mobile?20:0,o=i?s.getSearch(e.curDialog.inputPeer,"",i,F,a):s.getHistory(e.curDialog.inputPeer,F,a);o.then(function(i){H=!1,t==R&&n==q&&(angular.forEach(i.history,function(e){P.messages.unshift(s.wrapForHistory(e))}),N=null===i.count||i.history.length&&P.messages.length=i-1?t.history[0]:0,F=t.history[t.history.length-1],e.skippedHistory=L=B>0,N=null===t.count||n&&nt;for(o=0;o0){var t=[];angular.forEach(e.selectedMsgs,function(e,n){t.push(n)}),s.deleteMessages(t).then(function(){k()})}}function T(){if(e.selectedCount>0){var t=[];angular.forEach(e.selectedMsgs,function(e,n){t.push(n)}),u.selectPeer({confirm_type:"FORWARD_PEER"}).then(function(e){var n=c.getPeerID(e);s.forwardMessages(n,t).then(function(){k(),i.$broadcast("history_focus",{peerString:e})})})}}function E(){e.historyState.selectActions?k():(e.historyState.selectActions=!0,e.$broadcast("ui_panel_update"))}function A(t){e.historyFilter.mediaType=t||!1,P.messages=[],e.state.empty=!0,w()}function D(){e.historyFilter.mediaType?A():e.curDialog.messageID?i.$broadcast("history_focus",{peerString:e.curDialog.peer}):w(!0)}e.$watch("curDialog",f),l.attach(),d.start(),p.start(),e.peerHistories=[],e.skippedHistory=!1,e.selectedMsgs={},e.selectedCount=0,e.historyState.selectActions=!1,e.missedCount=0,e.state={},e.toggleMessage=S,e.selectedDelete=M,e.selectedForward=T,e.selectedCancel=k,e.selectedFlush=x,e.toggleEdit=E,e.toggleMedia=A,e.returnToRecent=D,e.$on("history_edit_toggle",E),e.$on("history_edit_flush",x),e.$on("history_media_toggle",function(e,t){A(t)}),e.$on("history_return_recent",D);var I,P=!1,N=!1,L=!1,F=0,B=0,O=!1,U={photos:"inputMessagesFilterPhotos",video:"inputMessagesFilterVideo",documents:"inputMessagesFilterDocument",audio:"inputMessagesFilterAudio"},R=0,q=0,H=!1,j=!1,V=0,z=!1,W=!1;e.$on("history_update",angular.noop);var G={};e.$on("history_append",function(t,a){var o=m(a.peerID);if(o){var r=a.peerID==e.curDialog.peerID;if(r){if(e.historyFilter.mediaType||e.skippedHistory)return void(a.my?D():e.missedCount++);delete e.state.empty}o.messages.push(s.wrapForHistory(a.messageID)),s.regroupWrappedHistory(o.messages,-3)&&e.$broadcast("messages_regroup"),r&&(e.historyState.typing.splice(0,e.historyState.typing.length),e.$broadcast("ui_history_append_new",{my:a.my}),a.my&&e.historyUnreadAfter&&(delete e.historyUnreadAfter,e.$broadcast("messages_unread_after")),i.idle.isIDLE||n(function(){s.readHistory(e.curDialog.inputPeer)}))}}),e.$on("history_delete",function(t,n){var i=m(n.peerID);if(i){var a,o=[];for(a=0;a=0?i+n:0,s=++_,c=r>=m.length?u():e.when();c.then(function(){s==_&&(t.messageID=m[r],t.photoID=o.getMessage(t.messageID).media.photo.id,t.photo=a.wrapForFull(t.photoID),d())})}function u(){return b?b:b=o.getSearch(h,f,g,v).then(function(e){e.history.length?(v=e.history[e.history.length-1],m=m.concat(e.history),y=m.length0,t.nav.hasPrev=y||e0}if(t.photo=a.wrapForFull(t.photoID),t.nav={},t.download=function(){a.downloadPhoto(t.photoID)},(!t.messageID||Config.Navigator.mobile)&&(t.nav.next=function(){i.close()}),t.messageID){if(t.forward=function(){var e=t.messageID;s.selectPeer({confirm_type:"FORWARD_PEER"}).then(function(t){var i=r.getPeerID(t);o.forwardMessages(i,[e]).then(function(){n.$broadcast("history_focus",{peerString:t})})})},Config.Navigator.mobile)return t.canForward=!0,void(t.canDelete=!0);t.delete=function(){var e=t.messageID;c.confirm({type:"MESSAGE_DELETE"}).then(function(){o.deleteMessages([e])})};var p=o.getMessagePeer(o.getMessage(t.messageID)),h=r.getInputPeerByID(p),f="",g={_:"inputMessagesFilterPhotos"},m=[t.messageID],v=t.messageID,y=!0;d(),o.getSearch(h,f,g,0,1e3).then(function(e){e.history.indexOf(t.messageID)>=0&&(m=e.history,v=m[m.length-1],d())});var _=0,b=!1;t.nav.next=function(){return t.nav.hasNext?void l(-1):!1},t.nav.prev=function(){return t.nav.hasPrev?void l(1):!1},t.$on("history_delete",function(e,n){if(n.peerID==p){if(n.msgs[t.messageID])if(t.nav.hasNext)t.nav.next();else{if(!t.nav.hasPrev)return i.dismiss();t.nav.prev()}for(var a=[],o=0;o=0?i+n:0,r=++v,s=o>=f.length?d():e.when();s.then(function(){r==v&&(t.photoID=f[o],t.photo=a.wrapForFull(t.photoID),p())})}function d(){return y?y:y=a.getUserPhotos(h,g).then(function(e){g=e.photos[e.photos.length-1],f=f.concat(e.photos),m=f.length0,t.nav.hasPrev=m||e=0&&(f=e.photos,g=f[f.length-1],m=f.length0&&Math.ceil(10*i[3])||0:5,t.notify.canVibrate=l.getVibrateSupport(),t.notify.vibrate=!i[4],t.notify.volumeOf4=function(){return 1+Math.ceil((t.notify.volume-1)/3.3)},t.toggleSound=function(){t.notify.volume=t.notify.volume?0:5};var a;t.$watch("notify.volume",function(e,t){if(e!==t){var i=e/10;c.set({notify_volume:i}),c.remove("notify_nosound"),l.clear(),a&&n.cancel(a),a=n(function(){l.testSound(i)},500)}}),t.toggleDesktop=function(){t.notify.desktop=!t.notify.desktop,t.notify.desktop?c.remove("notify_nodesktop"):c.set({notify_nodesktop:!0})},t.toggleVibrate=function(){t.notify.vibrate=!t.notify.vibrate,t.notify.vibrate?c.remove("notify_novibrate"):c.set({notify_novibrate:!0})},t.toggleCtrlEnter=function(n){t.send.enter=n,t.send.enter?c.remove("send_ctrlenter"):c.set({send_ctrlenter:!0}),e.$broadcast("settings_changed")}}),t.openChangelog=function(){p.showChangelog(!1)}}]).controller("ProfileEditModalController",["$rootScope","$scope","$timeout","$modal","$modalInstance","AppUsersManager","AppChatsManager","MtpApiManager","Storage","NotificationsManager","MtpApiFileManager","ApiUpdatesManager",function(e,t,n,i,a,o,r,s){t.profile={},t.error={},s.getUserID().then(function(e){t.profile=o.getUser(e)}),t.updateProfile=function(){t.profile.updating=!0,s.invokeApi("account.updateProfile",{first_name:t.profile.first_name||"",last_name:t.profile.last_name||""}).then(function(e){t.error={},o.saveApiUser(e),a.close()},function(e){switch(e.type){case"FIRSTNAME_INVALID":t.error={field:"first_name"},e.handled=!0;break;case"LASTNAME_INVALID":t.error={field:"last_name"},e.handled=!0;break;case"NAME_NOT_MODIFIED":e.handled=!0,a.close()}})["finally"](function(){delete t.profile.updating})}}]).controller("ContactsModalController",["$scope","$modal","$modalInstance","AppUsersManager","ErrorService",function(e,t,n,i){function a(){e.selectedContacts={},e.selectedCount=0}function o(t){i.getContacts(t).then(function(n){e.contacts=[],e.slice.limit=20,angular.forEach(n,function(t){var n={userID:t,user:i.getUser(t),userPhoto:i.getUserPhoto(t,"User")};e.contacts.push(n)}),e.contactsEmpty=t?!1:!e.contacts.length,e.$broadcast("contacts_change")})}if(e.contacts=[],e.search={},e.slice={limit:20,limitDelta:20},a(),e.disabledContacts={},e.disabled)for(var r=0;r0){var t=[];return angular.forEach(e.selectedContacts,function(e,n){t.push(n)}),n.close(t)}},e.deleteSelected=function(){if(e.selectedCount>0){var t=[];angular.forEach(e.selectedContacts,function(e,n){t.push(n)}),i.deleteContacts(t).then(function(){a(),o(e.search.query)})}},e.importContact=function(){i.openImportContact().then(function(){o(e.search&&e.search.query||"")})}}]).controller("PeerSelectController",["$scope","$modalInstance","$q","AppPeersManager","ErrorService",function(e,t,n,i,a){e.dialogSelect=function(o){var r;if(e.confirm_type){var s=i.getPeerID(o),c=i.getPeer(s);r=a.confirm({type:e.confirm_type,peer_id:s,peer_data:c})}else r=n.when();r.then(function(){t.close(o)})},e.toggleSearch=function(){e.$broadcast("dialogs_search_toggle")}}]).controller("ChatCreateModalController",["$scope","$modalInstance","$rootScope","MtpApiManager","AppUsersManager","AppChatsManager","ApiUpdatesManager",function(e,t,n,i,a,o,r){e.group={name:""},e.createGroup=function(){if(e.group.name){e.group.creating=!0;var t=[];return angular.forEach(e.userIDs,function(e){t.push({_:"inputUserContact",user_id:e})}),i.invokeApi("messages.createChat",{title:e.group.name,users:t}).then(function(e){r.processUpdateMessage({_:"updates",seq:e.seq,users:e.users,chats:e.chats,updates:[{_:"updateNewMessage",message:e.message,pts:e.pts}]});var t=o.getChatString(e.message.to_id.chat_id);n.$broadcast("history_focus",{peerString:t})})["finally"](function(){delete e.group.creating})}}}]).controller("ChatEditModalController",["$scope","$modalInstance","$rootScope","MtpApiManager","AppUsersManager","AppChatsManager","ApiUpdatesManager",function(e,t,n,i,a,o,r){var s=o.getChat(e.chatID);e.group={name:s.title},e.updateGroup=function(){return e.group.name?e.group.name==s.title?t.close():(e.group.updating=!0,i.invokeApi("messages.editChatTitle",{chat_id:e.chatID,title:e.group.name}).then(function(t){r.processUpdateMessage({_:"updates",seq:t.seq,users:t.users,chats:t.chats,updates:[{_:"updateNewMessage",message:t.message,pts:t.pts}]});var i=o.getChatString(e.chatID);n.$broadcast("history_focus",{peerString:i})})["finally"](function(){delete e.group.updating})):void 0}}]).controller("ImportContactModalController",["$scope","$modalInstance","$rootScope","AppUsersManager","ErrorService","PhonebookContactsService",function(e,t,n,i,a,o){void 0===e.importContact&&(e.importContact={}),e.phonebookAvailable=o.isAvailable(),e.doImport=function(){e.importContact&&e.importContact.phone&&(e.progress={enabled:!0},i.importContact(e.importContact.phone,e.importContact.first_name||"",e.importContact.last_name||"").then(function(e){e||a.show({error:{code:404,type:"USER_NOT_USING_TELEGRAM"}}),t.close(e)})["finally"](function(){delete e.progress.enabled}))},e.importPhonebook=function(){o.openPhonebookImport().result.then(function(e){e?t.close(e[0]):t.dismiss()})}}]).controller("CountrySelectModalController",["$scope","$modalInstance","$rootScope","SearchIndexManager",function(e,t,n,i){e.search={},e.slice={limit:20,limitDelta:20};for(var a=i.createIndex(),o=0;o5184e5?o="shortDate":a>432e5&&(o="EEE"),t[e]=n(i,o)}}]).filter("time",["$filter",function(e){var t={},n=e("date"),i=Config.Navigator.mobile?"HH:mm":"HH:mm:ss";return function(e){return t[e]?t[e]:t[e]=n(1e3*e,i)}}]).filter("myDate",["$filter",function(e){var t={},n=e("date");return function(e){return t[e]?t[e]:t[e]=n(1e3*e,"fullDate")}}]).filter("duration",[function(){return function(e){var t=e%60,n=Math.floor((e-t)/60);return 10>t&&(t="0"+t),n+":"+t}}]).filter("phoneNumber",[function(){return function(e){var t=" ";return e=(e||"").replace(/\D/g,""),"7"==e.charAt(0)&&11==e.length?"+"+e.charAt(0)+t+"("+e.substr(1,3)+")"+t+e.substr(4,3)+"-"+e.substr(7,2)+"-"+e.substr(9,2):"+"+e}}]).filter("formatSize",[function(){return function(e){return e?1024>e?e+" b":1048576>e?Math.round(e/1024*10)/10+" Kb":Math.round(e/1048576*100)/100+" Mb":"0"}}]).filter("formatSizeProgress",["$filter",function(e){return function(t){var n=e("formatSize")(t.done),i=n.split(" "),a=e("formatSize")(t.total),o=a.split(" ");return o[1]===i[1]?i[0]+" of "+o[0]+" "+(i[1]||""):n+" of "+a}}]).filter("nl2br",[function(){return function(e){return e.replace(/\n/g,"
")}}]).filter("richText",["$filter",function(e){return function(t){return e("linky")(t,"_blank").replace(/\n| /g,"
")}}]).filter("relativeTime",["$filter",function(e){var t={one:"minute ago",many:"minutes ago"},n={one:"hour ago",many:"hours ago"};return function(i){var a=1e3*i,o=Math.abs(tsNow()-a);if(6e4>o)return"just now";if(3e6>o){var r=Math.ceil(o/6e4);return r+" "+t[r>1?"many":"one"]}if(1e7>o){var s=Math.ceil(o/36e5);return s+" "+n[s>1?"many":"one"]}return e("dateOrTime")(i)}}]),angular.module("myApp.templates",[]).run(["$templateCache",function(e){e.put("partials/changelog_modal.html",'
\n\n \n\n \n\n
'),e.put("partials/chat_create_modal.html",'
\n\n \n\n \n\n \n\n
'),e.put("partials/chat_edit_modal.html",'
\n\n \n\n \n\n \n\n
'),e.put("partials/chat_modal.html",'
\n\n \n\n \n\n
\n'),e.put("partials/confirm_modal.html",'
\n\n \n\n \n\n \n\n
'),e.put("partials/contacts_modal.html",'
\n\n \n\n \n\n \n\n
'),e.put("partials/country_select_modal.html",'
\n\n \n\n \n\n
'),e.put("partials/dialog.html",'\n\n
\n
\n \n \n
\n\n
\n \n
\n\n
\n\n
\n \n \n \n \n
\n\n
\n
\n deleted message\n
\n
\n \n You{{((dialogMessage.out || dialogMessage.peerID < 0) && (dialogMessage.message.length || dialogMessage.media && dialogMessage.media._ != \'messageMediaEmpty\')) ? \':\' : \'\'}}\n \n\n \n Photo\n Video\n Document\n Audio\n Location\n Contact\n \n\n \n created the group\n changed group name\n changed group photo\n removed group photo\n\n \n \n returned to group\n \n \n invited \n \n \n\n \n \n left group\n \n \n kicked \n \n \n \n\n \n
\n
\n\n
\n
\n'),e.put("partials/edit_contact_modal.html",'
\n\n \n\n \n\n \n\n
'),e.put("partials/error_modal.html",'
\n\n \n\n \n\n
'),e.put("partials/full_gif.html",'\n\n
\n\n \n \n\n
\n\n
\n\n
\n
\n
\n
\n
\n\n
\n
GIF
\n
\n
\n\n
\n\n
'),e.put("partials/full_photo.html",'
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n \n \n
\n
\n
\n
\n
\n
'),e.put("partials/full_video.html",'
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n \n \n
\n
\n
\n
\n
\n
'),e.put("partials/head.html",'
\n \n
\n'),e.put("partials/im.html",'
\n\n
\n\n
\n\n
\n
\n \n \n\n
\n \n
\n
\n\n
\n
\n
\n\n
\n

No contacts yet

\n

Get started by adding a contact to chat with

\n \n \n
\n\n
\n \n \n
\n\n
\n
Contacts
\n \n
\n\n
\n
\n
\n
\n\n
\n
\n
\n

Get started

\n

Welcome to Telegram Web. You can always set your profile photo and change your name in Settings.

\n \n
\n
\n Please select a chat to start messaging\n
\n
\n
\n Loading history\n
\n\n
\n
\n\n
\n\n
\n
\n\n Info\n Edit\n\n \n \n Show recent messages\n Show all messages\n \n \n\n
\n

Photos

\n

Videos

\n

Documents

\n

Voice messages

\n\n

\n
\n \n \n
\n
\n \n \n \n \n \n
\n

\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n
\n
\n Loading history\n No messages here yet...\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n\n
\n \n is typing\n \n \n and are typing\n \n \n , and {{historyState.typing.length - 2}} more are typing\n \n
\n
\n\n
\n\n
\n\n
\n\n
\n\n \n\n
\n\n
\n\n
\n
\n \n \n
\n
\n \n
\n
\n\n
\n
Drop photos here to send
\n \n
\n\n
\n \n \n
\n\n
\n \n \n
\n\n
\n \n
\n\n \n
\n
\n\n
\n\n
\n\n
\n\n
\n
\n\n
\n\n
\n\n\n
\n\n\n\n
\n'),e.put("partials/import_contact_modal.html",'
\n\n \n\n \n\n \n\n
'),e.put("partials/login.html",'
\n\n\n\n'),e.put("partials/message.html",'
\n\n\n
\n\n
\n
\n \n \n
\n\n \n \n \n\n
\n\n
\n
\n \n
\n\n \n \n \n\n \n\n \n\n
\n \n \n
\n\n
\n\n \n\n
\n
Forwarded message
\n \n
\n \n
\n
\n\n
\n\n
\n
\n
\n
\n
\n
\n
\n\n
\n\n
\n
\n\n
\n
\n\n
\n\n'),e.put("partials/message_attach_audio.html",'
\n \n \n \n \n\n
\n
\n \n Voice message\n \n \n \n
\n
\n Play\n
\n
\n Cancel\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n
'),e.put("partials/message_attach_contact.html",'
\n \n
\n \n \n
\n
\n
'),e.put("partials/message_attach_document.html",'
\n\n
\n\n
\n\n \n \n
\n \n
\n
\n\n
\n
\n \n \n \n
\n
\n Download\n Open\n
\n
\n Cancel\n
\n
\n
\n
\n
\n
\n
\n\n
\n
'),e.put("partials/message_attach_map.html",'\n \n'),e.put("partials/message_attach_pending.html",'
\n \n
\n
\n \n \n
\n
\n Cancel\n
\n
\n
\n
\n
\n
\n
\n
'),e.put("partials/message_attach_photo.html",'\n \n'),e.put("partials/message_attach_video.html",'
\n \n \n \n \n \n\n
\n
\n Video\n \n \n
\n \n
\n Cancel\n
\n
\n
\n
\n
\n
\n
\n
'),e.put("partials/message_service.html",'\n \n created the group «»\n \n \n changed group name to «»\n \n \n changed group photo\n \n \n removed group photo\n \n \n \n invited \n \n \n returned to group\n \n \n \n \n kicked \n \n \n left group\n \n \n\n \n'),e.put("partials/peer_select.html",'
\n\n \n\n \n\n
'),e.put("partials/photo_modal.html",'
\n\n \n\n
'),e.put("partials/profile_edit_modal.html",'
\n\n \n\n \n\n \n\n
'),e.put("partials/settings_modal.html",'\n'),e.put("partials/user_modal.html",'
\n\n \n\n \n\n
'),e.put("partials/video_modal.html",'
\n\n \n\n
'),e.put("partials/welcome.html",'
\n\n
\n\n
\n \n\n

Telegram Web

\n\n
\n

This is an unofficial web-client for the Telegram Messenger.

\n

It\'s still an alpha-version and may not be 200% reliable

\n
\n \n
\n\n \n\n\n\n
\n'),e.put("partials/mobile/chat_modal.html",'
\n\n
\n \n
\n\n \n\n
\n'),e.put("partials/mobile/contacts_modal.html",'
\n\n
\n \n
\n\n \n\n \n\n
'),e.put("partials/mobile/country_select_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/peer_select.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/phonebook_modal.html",'
\n\n
\n \n
\n\n \n\n \n\n
'),e.put("partials/mobile/settings_modal.html",'\n'),e.put("partials/mobile/user_modal.html",'
\n\n
\n \n
\n\n \n\n
') }]),angular.module("myApp.directives",["myApp.filters"]).directive("myHead",function(){return{restrict:"AE",templateUrl:"partials/head.html"}}).directive("myDialog",function(){return{restrict:"AE",templateUrl:"partials/dialog.html"}}).directive("myMessage",["$filter",function(e){function t(e,t){var u,d,p=!1,h=!1,f=!1,g=!1,m=!1,v=!1,y=!1,_=function(){p!=(e.selectedMsgs[e.historyMessage.id]||!1)&&(p=!p,t.toggleClass(o,p))},b=function(){h!=e.historyMessage.grouped&&(h&&t.removeClass(h),h=e.historyMessage.grouped,h&&t.addClass(h)),v!=(e.historyMessage.needDate||!1)&&(v=!v,v?u?u.show():(u=$(i),$(u[0].firstChild).text(n(e.historyMessage.date)),d?u.insertBefore(d):u.prependTo(t)):u.hide())};if(_(),b(),e.$on("messages_select",_),e.$on("messages_regroup",b),e.$on("messages_focus",function(n,i){i==e.historyMessage.id!=f&&(f=!f,t.toggleClass(r,f))}),e.historyMessage.unread){var w;if(!e.historyMessage.out){var C=function(){y!=(e.historyUnreadAfter==e.historyMessage.id)&&(y=!y,y?d?d.show():d=$(a).prependTo(t):(d.hide(),w&&w()))};C(),w=e.$on("messages_unread_after",C)}t.addClass(s);var S=e.$on("messages_read",function(){e.historyMessage.unread||(t.removeClass(s),S(),w&&!y&&w())})}if(e.historyMessage.error||e.historyMessage.pending){var k=function(){m!=(e.historyMessage.pending||!1)&&(m=!m,t.toggleClass(l,m)),g!=(e.historyMessage.error||!1)&&(g=!g,t.toggleClass(c,g)),g||m||x()},x=e.$on("messages_pending",k);k()}}var n=e("myDate"),i='
',a='
Unread messages
',o="im_message_selected",r="im_message_focus",s="im_message_unread",c="im_message_error",l="im_message_pending";return{link:t,templateUrl:"partials/message.html"}}]).directive("myServiceMessage",function(){return{templateUrl:"partials/message_service.html"}}).directive("myMessagePhoto",function(){return{templateUrl:"partials/message_attach_photo.html"}}).directive("myMessageVideo",function(){return{templateUrl:"partials/message_attach_video.html"}}).directive("myMessageDocument",function(){return{templateUrl:"partials/message_attach_document.html"}}).directive("myMessageAudio",function(){return{templateUrl:"partials/message_attach_audio.html"}}).directive("myMessageMap",function(){return{templateUrl:"partials/message_attach_map.html"}}).directive("myMessageContact",function(){return{templateUrl:"partials/message_attach_contact.html"}}).directive("myMessagePending",function(){return{templateUrl:"partials/message_attach_pending.html"}}).directive("myDialogs",["$modalStack","$transition","$window","$timeout",function(e,t,n,i){function a(t,a,o){function r(t){if(!p&&e.getTop())return!0;if(36==t.keyCode&&!t.shiftKey&&!t.ctrlKey&&t.altKey){var n=$(c).find(".im_dialog_wrap a");return n.length&&(n.trigger("mousedown"),c.scrollTop=0,$(s).nanoScroller({flash:!0})),cancelEvent(t)}if(27==t.keyCode||9==t.keyCode&&t.shiftKey&&!t.ctrlKey&&!t.metaKey)return p||(l.focus(),l.value&&l.select()),cancelEvent(t);if(p&&13==t.keyCode){var n=$(c).find(".im_dialog_selected")[0]||$(c).find(".im_dialog_wrap a")[0];return n&&$(n).trigger("mousedown"),cancelEvent(t)}if(38==t.keyCode||40==t.keyCode){var i=!t.shiftKey&&t.altKey;if(!i&&(!p||t.metaKey))return!0;var a,o=40==t.keyCode,n=!i&&$(c).find(".im_dialog_selected")[0]||$(c).find(".active a.im_dialog")[0],r=n&&n.parentNode;if(r){var a=n[o?"nextSibling":"previousSibling"];if(!a||!a.className||-1==a.className.indexOf("im_dialog_wrap")){var u=$(c).find(".im_dialog_wrap"),d=u.index(n.parentNode),h=d+(o?1:-1);a=u[h]}}else{var u=$(c).find(".im_dialog_wrap");a=o?u[0]:u[u.length-1]}if(i?a&&$(a).find("a").trigger("mousedown"):(r&&a&&$(r).find("a").removeClass("im_dialog_selected"),a&&$(a).find("a").addClass("im_dialog_selected")),a){var f=a.offsetTop,g=a.offsetHeight,m=c.scrollTop,v=c.clientHeight;m>f?(c.scrollTop=f,$(s).nanoScroller({flash:!0})):f+g-v>m&&(c.scrollTop=f+g-v,$(s).nanoScroller({flash:!0}))}return cancelEvent(t)}}var s=$(".im_dialogs_wrap",a)[0],c=$(".im_dialogs_scrollable_wrap",a)[0],l=$(".im_dialogs_search_field",a)[0],u=$(".im_dialogs_panel",a)[0],d=$(".im_dialogs_tabs_wrap",a)[0],p=!1;$(l).on("focus blur",function(e){p="focus"==e.type,p||($(c).find(".im_dialog_selected").removeClass("im_dialog_selected"),l.value||t.$emit("ui_dialogs_search_clear"))}),t.$on("dialogs_search_toggle",function(){$(u).addClass("im_dialogs_panel_search"),t.$broadcast("ui_dialogs_search"),$(n).scrollTop(0),i(function(){l.focus()})}),t.$on("search_clear",function(){$(u).removeClass("im_dialogs_panel_search"),t.$broadcast("ui_dialogs_search")}),o.$observe("hasTabs",function(e){e="true"==e,$(d).toggle(e),t.$broadcast("ui_dialogs_tabs",e)}),$(document).on("keydown",r),t.$on("$destroy",function(){$(document).off("keydown",r)})}return{link:a}}]).directive("myDialogsList",["$window","$timeout",function(e,t){function n(n,i,a){function o(){return d&&d.offsetHeight||(d=$(u)[0]),a.modal?($(i).css({height:$(e).height()-(d?d.offsetHeight:58)-(Config.Navigator.mobile?46:200)}),void g()):(l&&l.offsetHeight||(l=$(".tg_page_head")[0]),p&&p.offsetHeight||(p=$(".im_page_footer")[0]),s&&s.offsetHeight||(s=$(".im_dialogs_col_wrap")[0]),$(i).css({height:$(e).height()-p.offsetHeight-(l?l.offsetHeight:44)-(d?d.offsetHeight:58)-parseInt($(s).css("paddingBottom")||0)}),void g())}var r=$(".im_dialogs_wrap",i)[0],s=$(".im_dialogs_col_wrap")[0],c=$(".im_dialogs_scrollable_wrap",i)[0],l=$(".tg_page_head")[0],u=Config.Navigator.mobile&&a.modal?".mobile_modal_body .im_dialogs_panel":".im_dialogs_panel",d=$(u)[0],p=$(".im_page_footer")[0],h=!1,f=!1;onContentLoaded(function(){$(r).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0})});var g=function(){onContentLoaded(function(){$(r).nanoScroller()})};n.$on("ui_dialogs_prepend",g),n.$on("ui_dialogs_tabs",function(e,t){h=t,o()}),n.$on("ui_dialogs_search",o),n.$on("ui_dialogs_update",o),n.$on("ui_dialogs_append",function(){onContentLoaded(function(){g(),f=!1,t(function(){$(c).trigger("scroll")})})}),n.$on("ui_dialogs_change",function(){onContentLoaded(function(){g(),f=!1,t(function(){$(c).trigger("scroll")})})}),$(c).on("scroll",function(){i.is(":visible")&&!f&&c.scrollTop>=c.scrollHeight-c.clientHeight-300&&(n.$emit("dialogs_need_more"),f=!0)}),$(e).on("resize",o),o(),setTimeout(o,1e3)}return{link:n}}]).directive("myContactsList",["$window","$timeout",function(e){function t(t,n){function i(){$(n).css({height:$(e).height()-(o&&o.offsetHeight||0)-(a&&a.offsetHeight||0)-(Config.Navigator.mobile?64:200)}),$(r).nanoScroller()}var a=$(".contacts_modal_search")[0],o=$(".contacts_modal_panel")[0],r=$(".contacts_wrap",n)[0];onContentLoaded(function(){$(r).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0}),i()}),$(e).on("resize",i),t.$on("contacts_change",function(){onContentLoaded(i)})}return{link:t}}]).directive("myCountriesList",["$window","$timeout",function(e){function t(t,n){function i(){$(n).css({height:$(e).height()-(o&&o.offsetHeight||0)-(a&&a.offsetHeight||0)-(Config.Navigator.mobile?64:200)}),$(r).nanoScroller()}var a=$(".countries_modal_search")[0],o=$(".countries_modal_panel")[0],r=$(".countries_wrap",n)[0];onContentLoaded(function(){$(r).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0}),i()}),$(e).on("resize",i),t.$on("contacts_change",function(){onContentLoaded(i)})}return{link:t}}]).directive("myHistory",["$window","$timeout","$rootScope","$transition",function(e,t,n,i){function a(a,o){function r(){var e,n;if(n=$(".im_message_focus:visible",d)[0]){var i=d.clientHeight,a=d.scrollTop,o=n.offsetTop,r=n.clientHeight;(!a||o>a+i||a>o+r)&&(d.scrollTop=Math.max(0,o-Math.floor(i/2)+26)),T=!1}else(e=$(".im_message_unread_split:visible",d)[0])?(d.scrollTop=Math.max(0,e.offsetTop-52),T=!1):(d.scrollTop=d.scrollHeight,T=!0);C(),t(function(){$(d).trigger("scroll"),E=d.scrollTop})}function s(t){if(o.is(":visible")||$(o[0].parentNode.parentNode).is(":visible")){$(g).is(":visible")&&$(g).css({height:$(y).height()}),m&&m.offsetHeight||(m=$(".tg_page_head")[0]),v&&v.offsetHeight||(v=$(".im_page_footer")[0]);var n=$(e).height()-h.offsetHeight-f.offsetHeight-(m?m.offsetHeight:44)-v.offsetHeight;$(l).css({height:n}),c(),t!==!0&&(T&&onContentLoaded(function(){d.scrollTop=d.scrollHeight,C()}),C(100))}}function c(){$(u).css({marginTop:0});var e=d.offsetHeight-u.offsetHeight-20-(Config.Navigator.mobile?0:49);u.offsetHeight>0&&e>0&&$(u).css({marginTop:e}),$(l).nanoScroller()}var l=$(".im_history_wrap",o)[0],u=$(".im_history_messages",o)[0],d=($(".im_history",o)[0],$(".im_history_scrollable_wrap",o)[0]),p=$(".im_history_scrollable",o)[0],h=$(".im_history_panel_wrap",o)[0],f=$(".im_bottom_panel_wrap",o)[0],g=$(".im_send_form_wrap",o)[0],m=$(".tg_page_head")[0],v=$(".im_page_footer")[0],y=$(".im_send_form",o)[0],_=!1,b=!1;onContentLoaded(function(){d.scrollTop=d.scrollHeight}),$(l).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0});var w,C=function(e){t(function(){$(d).hasClass("im_history_to_bottom")||$(l).nanoScroller()},e||0)},S=!1,k=["transform","webkitTransform","MozTransform","msTransform","OTransform"];for(w=0;w0;o?a=d.scrollHeight:($(p).css({bottom:0}),$(d).addClass("im_history_to_bottom")),onContentLoaded(function(){if(o){M=!0,$(u).removeClass("im_history_appending"),d.scrollTop=d.scrollHeight,$(u).css(S,"translate(0px, "+(d.scrollHeight-a)+"px)"),$(l).nanoScroller();var e={};e[S]="translate(0px, 0px)",$(u).addClass("im_history_appending"),i($(u),e).then(function(){M=!1,$(u).removeClass("im_history_appending"),c()})}else $(d).removeClass("im_history_to_bottom"),$(p).css({bottom:""}),d.scrollTop=d.scrollHeight,c()})}}),a.$on("ui_history_change",function(){var e=parseInt($(d).css("paddingRight"));$(d).addClass("im_history_to_bottom"),d.scrollHeight,$(p).css({bottom:0,marginLeft:-Math.ceil(e/2)}),onContentLoaded(function(){$(d).removeClass("im_history_to_bottom"),$(p).css({bottom:"",marginLeft:""}),s(!0),_=!1,b=!1,r()})}),a.$on("ui_history_change_scroll",function(){onContentLoaded(r)}),a.$on("ui_history_focus",function(){T||(d.scrollTop=d.scrollHeight,C(),T=!0)}),a.$on("ui_history_prepend",function(){var e=d.scrollHeight,n=d.scrollTop,i=parseInt($(d).css("paddingRight")),o=d.clientHeight;$(d).addClass("im_history_to_bottom"),d.scrollHeight,$(p).css({bottom:-(e-n-o),marginLeft:-Math.ceil(i/2)});var s=function(){$(d).removeClass("im_history_to_bottom"),$(p).css({bottom:"",marginLeft:""}),E>=0?r():d.scrollTop=n+d.scrollHeight-e,c(),_=!1,t(function(){d.scrollHeight!=e&&$(d).trigger("scroll")}),clearTimeout(l),u()},l=setTimeout(s,0),u=a.$on("$viewContentLoaded",s)}),a.$on("ui_history_append",function(){var e=d.scrollHeight;onContentLoaded(function(){T=!1,c(),b=!1,E>=0&&r(),t(function(){d.scrollHeight!=e&&$(d).trigger("scroll")})})}),a.$on("ui_panel_update",function(){onContentLoaded(function(){s(),a.$broadcast("ui_message_send"),t(function(){$(d).trigger("scroll")})})}),a.$on("ui_selection_clear",function(){window.getSelection?window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().removeAllRanges():document.selection&&document.selection.empty()}),a.$on("ui_editor_resize",s),a.$on("ui_height",function(){onContentLoaded(s)});var T=!0,E=-1;$(d).on("scroll",function(){if(o.is(":visible")&&!$(d).hasClass("im_history_to_bottom")&&!M){var e=d.scrollTop;T=e>=d.scrollHeight-d.clientHeight,E>=0&&E!=e&&(E=-1),!_&&300>=e?(_=!0,a.$emit("history_need_more")):!b&&e>=d.scrollHeight-d.clientHeight-300&&(b=!0,a.$emit("history_need_less"))}}),$(e).on("resize",s),s(),onContentLoaded(s)}return{link:a}}]).directive("mySendForm",["$timeout","$modalStack","Storage","ErrorService",function(e,t,n,i){function a(a,o){function r(){E=0,T=0}function s(){if(S){e.cancel(k);var t=$("
").text(a.draftMessage.text||"").html();t=t.replace(/\n/g,"
"),$(S).html(t),l()}}function c(){S&&($(S).trigger("change"),l())}function l(){var e=S.offsetHeight;A!=e&&(A=e,a.$emit("ui_editor_resize"))}function u(e){return 9!=e.keyCode||e.shiftKey||e.ctrlKey||e.metaKey||t.getTop()?void 0:(w.focus(),cancelEvent(e))}function d(){onContentLoaded(function(){w.focus()})}function p(e){var t,n=e&&e.target;if(n&&(t=n.src)&&0===t.indexOf("data")){n.parentNode.removeChild(n),t=t.substr(5).split(";");for(var o=t[0],r=atob(t[1].split(",")[1]),s=new Uint8Array(r.length),c=0;c0&&i.confirm({type:"FILES_CLIPBOARD_PASTE",files:r}).then(function(){a.draftMessage.files=r,a.draftMessage.isMedia=!0})}function f(e){var t=!1;return g&&1!=g||(g=checkDragEvent(e)?2:1,t=!0),2==g&&(m&&setTimeout(function(){clearTimeout(m),m=!1},0),"dragenter"==e.type||"dragover"==e.type?t&&$(_).css({height:$(w).height()+12,width:$(w).width()+12}).show():("drop"==e.type&&a.$apply(function(){a.draftMessage.files=Array.prototype.slice.call(e.originalEvent.dataTransfer.files),a.draftMessage.isMedia=!0}),m=setTimeout(function(){$(_).hide(),g=!1,m=!1},300))),cancelEvent(e)}var g,m,v=$("textarea",o)[0],y=$("input",o),_=$(".im_send_dropbox_wrap",o)[0],b=$(".im_emoji_btn",o)[0],w=v,C=($(v).emojiarea({button:b,norealTime:!0}),$(".emoji-menu",o)[0],$(".im_submit",o)[0]),S=$(".emoji-wysiwyg-editor",o)[0];if(S){w=S,$(S).addClass("form-control"),$(S).attr("placeholder",$(v).attr("placeholder"));var k;$(S).on("DOMNodeInserted",p).on("keyup",function(){l(),a.$apply(function(){a.draftMessage.text=S.textContent}),e.cancel(k),k=e(c,1e3)})}e(function(){y.on("change",function(){var e=this;a.$apply(function(){a.draftMessage.files=Array.prototype.slice.call(e.files),a.draftMessage.isMedia=$(e).hasClass("im_media_attach_input")||Config.Navigator.mobile,setTimeout(function(){try{e.value=""}catch(t){}},1e3)})})},1e3);var x=!0,M=function(){n.get("send_ctrlenter").then(function(e){x=!e})};a.$on("settings_changed",M),M(),$(w).on("keydown",function(t){if(S&&l(),13==t.keyCode){var n=!1;if(x&&!t.shiftKey?n=!0:x||!t.ctrlKey&&!t.metaKey||(n=!0),n)return e.cancel(k),c(),$(o).trigger("submit"),$(o).trigger("message_send"),r(),cancelEvent(t)}}),$(C).on("mousedown touchstart",function(t){return e.cancel(k),c(),$(o).trigger("submit"),$(o).trigger("message_send"),r(),cancelEvent(t)});var T,E=0;$(w).on("keyup",function(){var e=tsNow(),t=w[S?"textContent":"value"].length;e-E>5e3&&t!=T&&(E=e,T=t,a.$emit("ui_typing"))});var A=S.offsetHeight;$(document).on("keydown",u),$("body").on("dragenter dragleave dragover drop",f),$(document).on("paste",h),Config.Navigator.touch||(a.$on("ui_peer_change",d),a.$on("ui_history_focus",d),a.$on("ui_history_change",d)),a.$on("ui_message_send",d),a.$on("ui_peer_draft",s),a.$on("ui_message_before_send",c),a.$on("$destroy",function(){$("body").off("dragenter dragleave dragover drop",f),$(document).off("paste",h),$(document).off("keydown",u),$(C).off("mousedown"),y.off("change"),S&&$(S).off("DOMNodeInserted keyup",p),$(w).off("keydown")}),Config.Navigator.touch||d()}return{link:a,scope:{draftMessage:"="}}}]).directive("myLoadThumb",["MtpApiFileManager",function(e){function t(t,n,i){var a=0,o=e.getCachedFile(t.thumb&&t.thumb.location&&!t.thumb.location.empty&&t.thumb.location);o&&n.attr("src",o),t.thumb&&t.thumb.width&&t.thumb.height&&(n.attr("width",t.thumb.width),n.attr("height",t.thumb.height));var r=t.$watchCollection("thumb.location",function(i){t.thumb&&t.thumb.width&&t.thumb.height&&(n.attr("width",t.thumb.width),n.attr("height",t.thumb.height),t.$emit("ui_height"));var o=++a;if(!i||i.empty)return n.attr("src",t.thumb&&t.thumb.placeholder||"img/blank.gif"),void s();var r=e.getCachedFile(i);return r?(n.attr("src",r),void s()):(n.attr("src")||n.attr("src",t.thumb.placeholder||"img/blank.gif"),void e.downloadSmallFile(t.thumb.location).then(function(e){o==a&&(n.attr("src",e),s())},function(e){console.log("Download image failed",e,t.thumb.location,n[0]),o==a&&(n.attr("src",t.thumb.placeholder||"img/blank.gif"),s())}))}),s=i.watch?angular.noop:function(){setTimeout(function(){t.$destroy(),r()},0)}}return{link:t,scope:{thumb:"="}}}]).directive("myLoadFullPhoto",["MtpApiFileManager",function(e){function t(t,n){var i=$("img",n)[0],a=$(".img_fullsize_with_progress_wrap",n).add(".img_fullsize_progress_wrap",n).add($(i)),o=function(){a.css({width:t.fullPhoto.width,height:t.fullPhoto.height}),t.$emit("ui_height")},r=0;t.$watchCollection("fullPhoto.location",function(){var n=e.getCachedFile(t.thumbLocation),a=++r;if(n?(i.src=n,o()):i.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",t.fullPhoto.location){var s;if(t.fullPhoto.size){var c={_:"inputFileLocation",volume_id:t.fullPhoto.location.volume_id,local_id:t.fullPhoto.location.local_id,secret:t.fullPhoto.location.secret};s=e.downloadFile(t.fullPhoto.location.dc_id,c,t.fullPhoto.size)}else s=e.downloadSmallFile(t.fullPhoto.location);t.progress={enabled:!0,percent:0},s.then(function(e){a==r&&(t.progress.enabled=!1,i.src=e,o())},function(e){console.log("Download image failed",e,t.fullPhoto.location),t.progress.enabled=!1,t.error=e&&"FS_BROWSER_UNSUPPORTED"==e.type?{html:'Your browser doesn\'t support LocalFileSystem feature which is needed to display this image.
Please, install Google Chrome or use mobile app instead.'}:{text:"Download failed",error:e}},function(e){t.progress.percent=Math.max(1,Math.floor(100*e.done/e.total))})}}),o()}return{link:t,transclude:!0,templateUrl:"partials/full_photo.html",scope:{fullPhoto:"=",thumbLocation:"="}}}]).directive("myLoadVideo",["$sce","MtpApiFileManager",function(e,t){function n(n){n.progress={enabled:!0,percent:1},n.player={};var i,a={_:"inputVideoFileLocation",id:n.video.id,access_hash:n.video.access_hash},o=!1;if(navigator.plugins)for(i=0;i=0&&(o=!0);var r=t.downloadFile(n.video.dc_id,a,n.video.size,{mime:"video/mp4"});r.then(function(t){n.progress.enabled=!1,n.player.hasQuicktime=o,n.player.quicktime=!1,n.player.src=e.trustAsResourceUrl(t),n.$emit("ui_height")},function(e){console.log("Download video failed",e,n.video),n.progress.enabled=!1,n.player.src="",n.error=e&&"FS_BROWSER_UNSUPPORTED"==e.type?{html:'Your browser doesn\'t support LocalFileSystem feature which is needed to play this video.
Please, install Google Chrome or use mobile app instead.'}:{text:"Video download failed",error:e}},function(e){n.progress.percent=Math.max(1,Math.floor(100*e.done/e.total))}),n.$emit("ui_height"),n.$on("$destroy",function(){r.cancel()})}return{link:n,transclude:!0,templateUrl:"partials/full_video.html",scope:{video:"="}}}]).directive("myLoadGif",["MtpApiFileManager",function(e){function t(t){var n=!1,i={_:"inputDocumentFileLocation",id:t.document.id,access_hash:t.document.access_hash};t.isActive=!1,t.document.url=e.getCachedFile(i),t.toggle=function(){return t.document.url?(t.isActive=!t.isActive,void t.$emit("ui_height")):n?(n.cancel(),void(n=!1)):(t.document.progress={enabled:!0,percent:1,total:t.document.size},n=e.downloadFile(t.document.dc_id,i,t.document.size,null,{mime:t.document.mime_type}),void n.then(function(e){t.document.url=e,t.isActive=!0,delete t.document.progress,console.log("file save done"),t.$emit("ui_height")},function(){t.document.progress.enabled=!1},function(e){console.log("dl progress",e),t.document.progress.done=e.done,t.document.progress.percent=Math.max(1,Math.floor(100*e.done/e.total))}))}}return{link:t,templateUrl:"partials/full_gif.html",scope:{document:"="}}}]).directive("myMapPoint",["ExternalResourcesManager",function(e){function t(t,n){var i="AIzaSyC32ij28dCa0YzEV_HqbWfIwTZQql-RNS0",a="https://maps.googleapis.com/maps/api/staticmap?sensor=false¢er="+t.point.lat+","+t.point["long"]+"&zoom=13&size=200x100&scale=2&key="+i;e.downloadImage(a).then(function(e){n.append('')}),n.attr("href","https://maps.google.com/?q="+t.point.lat+","+t.point["long"]),n.attr("target","_blank")}return{link:t,scope:{point:"="}}}]).directive("myLoadingDots",["$interval",function(){function e(e,n){n.html(t(n[0])?'
':"...")}function t(e){if(void 0===n&&(n=void 0!==e.style.animationName,n===!1)){var t,i="Webkit Moz O ms Khtml".split(" ");for(t=0;t=n.scrollHeight-n.clientHeight-300&&(i=!0,e.$apply(function(){e.slice.limit+=e.slice.limitDelta||20}),onContentLoaded(function(){i=!1,$(t).nanoScroller()}))})}return{link:e,scope:!0}}).directive("myModalPosition",["$window","$timeout",function(e,t){function n(n,i,a){var o=function(){if(!Config.Navigator.mobile||!$(i[0].parentNode.parentNode.parentNode).hasClass("page_modal")){var e=i[0].parentNode.offsetHeight,n=i[0].parentNode.parentNode.parentNode.offsetHeight;n>e?$(i[0].parentNode).css("marginTop",(n-e)/2):$(i[0].parentNode).css("marginTop",""),"no"!=a.animation&&t(function(){$(i[0].parentNode).addClass("modal-content-animated")},300)}};onContentLoaded(o),$(e).on("resize",o),n.$on("ui_height",function(){onContentLoaded(o)})}return{link:n}}]).directive("myVerticalPosition",["$window","$timeout",function(e){function t(t,n,i){var a="true"===i.padding,o=0,r=function(){var r=n[0].offsetHeight,s=r-(r&&a?2*o:0),c=$(e).height(),l=i.myVerticalPosition&&parseFloat(i.myVerticalPosition)||.5,u=c>s?parseInt((c-s)*l):"",d=a?{paddingTop:u,paddingBottom:u}:{marginTop:u,marginBottom:u};n.css(d),n.addClass("vertical-aligned"),o!==u&&t.$emit("ui_height"),o=u};onContentLoaded(r),$(e).on("resize",r),t.$on("ui_height",function(){onContentLoaded(r)})}return{link:t}}]).directive("myUserLink",["$timeout","$rootScope","AppUsersManager",function(e,t,n){function i(e,i,a){var o=e.$eval(a.myUserLink),r=n.getUser(o);i.html((r[a.short&&e.$eval(a.short)?"rFirstName":"rFullName"]||"").valueOf()),"A"==i[0].tagName&&i.on("click",function(){t.openUser(o)}),a.color&&e.$eval(a.color)&&i.addClass("user_color_"+r.num)}return{link:i}}]).directive("myUserStatus",["$filter","$rootScope","AppUsersManager",function(e,t,n){function i(){angular.forEach(s,function(e){e()})}function a(e,i,a){var c,l=r++,u=function(){var e=n.getUser(c);i.html(o(e)).toggleClass("status_online",e.status&&"userStatusOnline"==e.status._)};e.$watch(a.myUserStatus,function(e){c=e,u()}),t.$on("user_update",function(e,t){c==t&&u()}),s[l]=u,e.$on("$destroy",function(){delete s[l]})}var o=e("userStatus"),r=0,s={};return setInterval(i,9e4),{link:a}}]).directive("myUserPhotolink",["$rootScope","AppUsersManager",function(e,t){function n(n,i,a){n.photo=t.getUserPhoto(n.userID,"User"),(n.showStatus=a.status&&n.$eval(a.status))&&(n.user=t.getUser(n.userID)),"A"==i[0].tagName&&i.on("click",function(){e.openUser(n.userID)}),a.imgClass&&$(i[0].firstChild).addClass(a.imgClass)}return{link:n,scope:{userID:"=myUserPhotolink"},template:''}}]); -//# sourceMappingURL=js/app.js.map \ No newline at end of file +//# sourceMappingURL=js/app.js.map