From b5a81c183e24e68368b0e070f2cac527fe728509 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Wed, 8 Apr 2015 23:40:54 +0300 Subject: [PATCH] merged with master --- app.manifest | 4 +-- js/app.js | 2 +- js/locales/de-de.json | 56 +++++++++++++++++++++++++++++++++++++- js/locales/es-es.json | 56 +++++++++++++++++++++++++++++++++++++- js/locales/it-it.json | 62 ++++++++++++++++++++++++++++++++++++++++--- js/locales/nl-nl.json | 56 +++++++++++++++++++++++++++++++++++++- js/locales/pt-br.json | 56 +++++++++++++++++++++++++++++++++++++- js/locales/ru-ru.json | 58 ++++++++++++++++++++++++++++++++++++++-- webogram.appcache | 4 +-- 9 files changed, 339 insertions(+), 15 deletions(-) diff --git a/app.manifest b/app.manifest index 07f1f60b..42041462 100644 --- a/app.manifest +++ b/app.manifest @@ -1,5 +1,5 @@ CACHE MANIFEST -# Time: Wed Apr 08 2015 21:41:28 GMT+0300 (MSK) +# Time: Wed Apr 08 2015 23:37:53 GMT+0300 (MSK) CACHE: @@ -73,8 +73,8 @@ js/locales/pt-br.json js/locales/ru-ru.json vendor/closure/long.js vendor/cryptoJS/crypto.js -vendor/leemon_bigint/bigint.js vendor/jsbn/jsbn_combined.js +vendor/leemon_bigint/bigint.js vendor/rusha/rusha.js vendor/angular/i18n/angular-locale_de-de.js vendor/angular/i18n/angular-locale_en-us.js diff --git a/js/app.js b/js/app.js index 8533dea2..8387bad8 100644 --- a/js/app.js +++ b/js/app.js @@ -18,6 +18,6 @@ c.storeLongP(0,0,"auth_key_id"),c.storeLong(i.generateID(),"msg_id"),c.storeInt( })})},v)}V(i.id);break;case"updateReadHistoryInbox":case"updateReadHistoryOutbox":var y,i,w,$=n.max_id,k="updateReadHistoryOutbox"==n._,a=s.getPeerID(n.peer),m=z(a),S=(X[a]||{}).history||[],C=!1,M=S.length,A=!1;for(a>0&&k&&o.forceUserOnline(a),w=0;M>w;w++)if(y=S[w],!(y>$)&&(i=K[y],i.out==k)){if(!i.unread)break;i&&i.unread&&(i.unread=!1,Z[y]&&(Z[y].unread=!1,A||(A=!0)),Y[y]&&(Y[y].unread=!1),i.out||(m&&(C=--m[0].unread_count),f.cancel("msg"+y)))}C!==!1&&t.$broadcast("dialog_unread",{peerID:a,count:C}),A&&t.$broadcast("messages_read");break;case"updateDeleteMessages":var y,i,w,a,m,S,x={};for(w=0;wo&&(i=e,a=o)}),i}function l(e,t,n){return i.invokeApi("photos.getUserPhotos",{user_id:e,offset:0,limit:n||20,max_id:t||0}).then(function(e){o.saveApiUsers(e.users);for(var t=[],n=0;n800&&(i-=208);var r=c(n,i,o);r&&!r.preloaded&&(r.preloaded=!0,r.size?a.downloadFile(r.location.dc_id,{_:"inputFileLocation",volume_id:r.location.volume_id,local_id:r.location.local_id,secret:r.location.secret},r.size):a.downloadSmallFile(r.location))}}function u(e){return g[e]||{_:"photoEmpty"}}function p(e,t){t=t||{};var n=angular.copy(g[e])||{_:"photoEmpty"},i=t.website?100:Math.min(_-80,Config.Mobile?210:260),a=t.website?100:Math.min(v-100,Config.Mobile?210:260),o=c(n,i,a),r={placeholder:"img/placeholders/PhotoThumbConversation.gif",width:i,height:a};if(o&&"photoSizeEmpty"!=o._){var s=calcImageInBox(o.w,o.h,i,a);r.width=s.w,r.height=s.h,r.location=o.location,r.size=o.size}else r.width=100,r.height=100;return n.thumb=r,n}function m(e){var n=p(e),i=$(window).width()-(Config.Mobile?0:32),a=$(t).height()-(Config.Mobile?0:116);!Config.Mobile&&i>800&&(i-=208);var o=c(n,i,a),r={placeholder:"img/placeholders/PhotoThumbModal.gif"};if(r.width=i,r.height=a,o&&"photoSizeEmpty"!=o._){var s=calcImageInBox(o.w,o.h,i,a,!0);r.width=s.w,r.height=s.h,r.modalWidth=Math.max(r.width,Math.min(400,i)),r.location=o.location,r.size=o.size}return n.full=r,n}function h(t,i){if(!t||"0"===t)return!1;var a=n.$new(!0);a.photoID=t;var o="PhotoModalController";i&&i.p>0?(o="UserpicModalController",a.userID=i.p):i&&i.p<0?(o="ChatpicModalController",a.chatID=-i.p):i&&i.m>0&&(a.messageID=i.m);e.open({templateUrl:templateUrl("photo_modal"),windowTemplateUrl:templateUrl("media_modal_layout"),controller:o,scope:a,windowClass:"photo_modal_window"})}function f(e){var n=g[e],i="jpg",o="image/jpeg",s="photo"+e+"."+i,l=Math.max(screen.width||0,$(window).width()-36,800),d=Math.max(screen.height||0,$(t).height()-150,800),u=c(n,l,d),p={_:"inputFileLocation",volume_id:u.location.volume_id,local_id:u.location.local_id,secret:u.location.secret};r.chooseSave(s,i,o).then(function(e){e&&a.downloadFile(u.location.dc_id,p,u.size,{mime:o,toFileEntry:e}).then(function(){},function(e){console.log("photo download failed",e)})},function(){var e=a.getCachedFile(p);return e?r.download(e,o,s):void a.downloadFile(u.location.dc_id,p,u.size,{mime:o}).then(function(e){r.download(e,o,s)},function(e){console.log("photo download failed",e)})})}var g={},_=$(window).width(),v=$(window).height();return n.preloadPhoto=d,n.openPhoto=h,{savePhoto:s,preloadPhoto:d,getUserPhotos:l,getPhoto:u,choosePhotoSize:c,wrapForHistory:p,wrapForFull:m,openPhoto:h,downloadPhoto:f}}]).service("AppVideoManager",["$sce","$rootScope","$modal","$window","MtpApiFileManager","AppUsersManager","FileManager","qSync",function(e,t,n,i,a,o,r,s){function c(e){f[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 l(e){if(void 0!==g[e])return g[e];var t=angular.copy(f[e]),n=Math.min(_-80,Config.Mobile?210:150),i=Math.min(v-100,Config.Mobile?210:150),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,g[e]=t}function d(e){var t=l(e),n=Math.min($(window).width()-(Config.Mobile?0:60),542),a=$(i).height()-(Config.Mobile?92:150),o={placeholder:"img/placeholders/VideoThumbModal.gif",width:n,height:a};if(t.w&&t.h){var r=calcImageInBox(t.w,t.h,n,a);o.width=r.w,o.height=r.h}else o.height=o.width=Math.min(n,a);return t.full=o,t.fullThumb=angular.copy(t.thumb),t.fullThumb.width=o.width,t.fullThumb.height=o.height,t}function u(e,i){var a=t.$new(!0);return a.videoID=e,a.messageID=i,n.open({templateUrl:templateUrl("video_modal"),windowTemplateUrl:templateUrl("media_modal_layout"),controller:"VideoModalController",scope:a,windowClass:"video_modal_window"})}function p(e){var t=f[e],n=g[e]||t||{},i={_:"inputVideoFileLocation",id:e,access_hash:t.access_hash};void 0===n.downloaded&&a.getDownloadedFile(i,t.size).then(function(){n.downloaded=!0},function(){n.downloaded=!1})}function m(n,i){var o=f[n],c=g[n]||o||{},l=o.mime_type||"video/ogg",d={_:"inputVideoFileLocation",id:n,access_hash:o.access_hash};if(c.downloaded&&!i){var u=a.getCachedFile(d);if(u)return s.when(u)}c.progress={enabled:!c.downloaded,percent:1,total:o.size};var p=a.downloadFile(o.dc_id,d,o.size,{mime:l,toFileEntry:i});return p.then(function(t){r.getFileCorrectUrl(t,l).then(function(t){c.url=e.trustAsResourceUrl(t)}),delete c.progress,c.downloaded=!0,console.log("video save done")},function(e){console.log("video download failed",e),c.progress.enabled=!1},function(e){console.log("dl progress",e),c.progress.enabled=!0,c.progress.done=e.done,c.progress.percent=Math.max(1,Math.floor(100*e.done/e.total)),t.$broadcast("history_update")}),c.progress.cancel=p.cancel,p}function h(e){{var t=f[e],n=t.mime_type||"video/mp4",i=n.split(".")[1]||"mp4",a="t_video"+e+"."+i;g[e]||t||{}}r.chooseSave(a,i,n).then(function(t){t&&m(e,t)},function(){m(e).then(function(e){r.download(e,n,a)})})}var f={},g={},_=$(window).width(),v=$(window).height();return{saveVideo:c,wrapForHistory:l,wrapForFull:d,openVideo:u,updateVideoDownloaded:p,downloadVideo:m,saveVideoFile:h}}]).service("AppDocsManager",["$sce","$rootScope","$modal","$window","$q","RichTextProcessor","MtpApiFileManager","FileManager","qSync",function(e,t,n,i,a,o,r,s,c){function l(e){g[e.id]=e,e.thumb&&"photoCachedSize"==e.thumb._&&(r.saveSmallFile(e.thumb.location,e.thumb.bytes),e.thumb.size=e.thumb.bytes.length,delete e.thumb.bytes,e.thumb._="photoSize"),angular.forEach(e.attributes,function(t){switch(t._){case"documentAttributeFilename":e.file_name=t.file_name;break;case"documentAttributeVideo":case"documentAttributeAudio":e.duration=t.duration;break;case"documentAttributeSticker":e.sticker=1;var n=t.alt||EmojiHelper.stickers[e.id];void 0!==n&&(e.sticker=2,e.stickerEmoji=o.wrapRichText(n,{noLinks:!0,noLinebreaks:!0}));break;case"documentAttributeImageSize":e.w=t.w,e.h=t.h}}),e.file_name=e.file_name||""}function d(e){return g[e]||{_:"documentEmpty"}}function u(e){if(void 0!==_[e])return _[e];var t,n,i=angular.copy(g[e]),a="image/gif"==i.mime_type,o="image/"==i.mime_type.substr(0,6)&&i.sticker,r=i.thumb;a?(t=Math.min(v-80,260),n=Math.min(y-100,260)):o?(t=Math.min(v-80,Config.Mobile?210:260),n=Math.min(y-100,Config.Mobile?210:260)):t=n=100;var s={width:t,height:n};if(r&&"photoSizeEmpty"!=r._){var c=calcImageInBox(r.w,r.h,t,n);s.width=c.w,s.height=c.h,s.location=r.location,s.size=r.size}else if(o){var c=calcImageInBox(i.w,i.h,t,n);s.width=c.w,s.height=c.h}else s=!1;return i.thumb=s,i.withPreview=!Config.Mobile&&i.mime_type.match(/^(image\/)/)?1:0,a&&i.thumb?i.isSpecial="gif":o?i.isSpecial="sticker":"audio/"==i.mime_type.substr(0,6)&&(i.isSpecial="audio"),_[e]=i}function p(e){var t=g[e],n=_[e]||t||{},i={_:"inputDocumentFileLocation",id:e,access_hash:t.access_hash};void 0===n.downloaded&&r.getDownloadedFile(i,t.size).then(function(){n.downloaded=!0},function(){n.downloaded=!1})}function m(n,i){var a=g[n],o=_[n]||a||{},l={_:"inputDocumentFileLocation",id:n,access_hash:a.access_hash};if(o.downloaded&&!i){var d=r.getCachedFile(l);if(d)return c.when(d)}o.progress={enabled:!o.downloaded,percent:1,total:a.size};var u=r.downloadFile(a.dc_id,l,a.size,{mime:a.mime_type||"application/octet-stream",toFileEntry:i});return u.then(function(t){delete o.progress,t&&(s.getFileCorrectUrl(t,a.mime_type).then(function(t){o.url=e.trustAsResourceUrl(t)}),o.downloaded=!0),console.log("file save done")},function(e){console.log("document download failed",e),o.progress.enabled=!1},function(e){console.log("dl progress",e),o.progress.enabled=!0,o.progress.done=e.done,o.progress.percent=Math.max(1,Math.floor(100*e.done/e.total)),t.$broadcast("history_update")}),o.progress.cancel=u.cancel,u}function h(e,i){var a=t.$new(!0);a.docID=e,a.messageID=i;n.open({templateUrl:templateUrl("document_modal"),windowTemplateUrl:templateUrl("media_modal_layout"),controller:"DocumentModalController",scope:a,windowClass:"document_modal_window"})}function f(e){var t=g[e],n=(_[e]||t||{},(t.file_name.split(".",2)||[])[1]||"");s.chooseSave(t.file_name,n,t.mime_type).then(function(t){t&&m(e,t)},function(){m(e).then(function(e){s.download(e,t.mime_type,t.file_name)})})}var g={},_={},v=$(window).width(),y=$(window).height();return{saveDoc:l,getDoc:d,wrapForHistory:u,updateDocDownloaded:p,downloadDoc:m,openDoc:h,saveDocFile:f}}]).service("AppAudioManager",["$sce","$rootScope","$modal","$window","MtpApiFileManager","FileManager","qSync",function(e,t,n,i,a,o,r){function s(e){p[e.id]=e}function c(e){if(void 0!==m[e])return m[e];var t=angular.copy(p[e]);return m[e]=t}function l(e){var t=p[e],n=m[e]||t||{},i={_:"inputAudioFileLocation",id:e,access_hash:t.access_hash};void 0===n.downloaded&&a.getDownloadedFile(i,t.size).then(function(){n.downloaded=!0},function(){n.downloaded=!1})}function d(n,i){var s=p[n],c=m[n]||s||{},l=s.mime_type||"audio/ogg",d={_:"inputAudioFileLocation",id:n,access_hash:s.access_hash};if(c.downloaded&&!i){var u=a.getCachedFile(d);if(u)return r.when(u)}c.progress={enabled:!c.downloaded,percent:1,total:s.size};var h=a.downloadFile(s.dc_id,d,s.size,{mime:l,toFileEntry:i});return h.then(function(t){o.getFileCorrectUrl(t,l).then(function(t){c.url=e.trustAsResourceUrl(t)}),delete c.progress,c.downloaded=!0,console.log("audio save done")},function(e){console.log("audio download failed",e),c.progress.enabled=!1},function(e){console.log("dl progress",e),c.progress.enabled=!0,c.progress.done=e.done,c.progress.percent=Math.max(1,Math.floor(100*e.done/e.total)),t.$broadcast("history_update")}),c.progress.cancel=h.cancel,h}function u(e){{var t=p[e],n=t.mime_type||"audio/ogg",i=n.split(".")[1]||"ogg",a="t_audio"+e+"."+i;m[e]||t||{}}o.chooseSave(a,i,n).then(function(t){t&&d(e,t)},function(){d(e).then(function(e){o.download(e,n,a)})})}var p={},m={};return{saveAudio:s,wrapForHistory:c,updateAudioDownloaded:l,downloadAudio:d,saveAudioFile:u}}]).service("AppStickersManager",["$q","FileManager","MtpApiManager","MtpApiFileManager","AppDocsManager","Storage",function(e,t,n,i,a,o){function r(){h||(h=!0,setTimeout(d,1e3),setInterval(s,9e5))}function s(){d().then(u)}function c(e){return EmojiHelper.stickers[e]||!1}function l(e){if(m!==e.hash){m=e.hash;var t,n,i,o;for(i=e.documents.length,t=0;i>t;t++)a.saveDoc(e.documents[t]);var r,s,c,l={};for(p=[],i=e.packs.length,t=0;i>t;t++)for(r=e.packs[t],s=r.emoticon,o=r.documents.length,n=0;o>n;n++)c=r.documents[n],void 0===EmojiHelper.stickers[c]&&(EmojiHelper.stickers[c]=s),void 0===l[c]&&(l[c]=!0,p.push(c))}return p}function d(){return o.get("all_stickers").then(function(e){var t=Config.Schema.API.layer;return e.layer!=t&&(e=!1),e&&e.date>tsNow(!0)?l(e):n.invokeApi("messages.getAllStickers",{hash:e&&e.hash||""}).then(function(n){return"messages.allStickersNotModified"==n._&&(n=e),n.date=tsNow(!0)+3600,n.layer=t,delete n._,o.set({all_stickers:n}),l(n)})})}function u(){var n=[];return angular.forEach(p,function(e){var o=a.getDoc(e),r=i.downloadSmallFile(o.thumb.location).then(function(n){return WebpManager.isWebpSupported()?{id:e,src:t.getUrl(n,"image/webp")}:t.getByteArray(n).then(function(t){return{id:e,src:WebpManager.getPngUrlFromData(t)}})});n.push(r)}),e.all(n)}var p=[],m=!1,h=!1;return{start:r,getStickerEmoji:c,getStickers:d,getStickersImages:u}}]).service("ApiUpdatesManager",["$rootScope","MtpNetworkerFactory","AppUsersManager","AppChatsManager","AppPeersManager","MtpApiManager",function(e,t,n,i,a,o){function r(){var e=h.seq+1,t=v[e];if(!t)return!1;for(var n,i,a=t.updates,n=0,i=a.length;i>n;n++)p(a[n]);return h.seq=t.seq,t.date&&h.date=g.seqAwaiting&&(g.ptsAwaiting?delete g.seqAwaiting:(clearTimeout(g.timeout),g=!1)),!0}function s(){if(!y.length)return!1;y.sort(function(e,t){return e.pts-t.pts});for(var e,t=h.pts,n=!1,i=!1,a=0,o=y.length;o>a;a++)e=y[a],t+=e.pts_count,t>=e.pts&&(n=e.pts,i=a);if(!n)return!1;for(h.pts=n,a=0;i>=a;a++)e=y[a],p(e);return y.splice(i,o-i),!y.length&&g&&(g.seqAwaiting?delete g.ptsAwaiting:(clearTimeout(g.timeout),g=!1)),!0}function c(){_||d()}function l(e){var t={date:e.date,seq:e.seq,seqStart:e.seq_start};switch(e._){case"updatesTooLong":case"new_session_created":c();break;case"updateShort":u(e.update,t);break;case"updateShortMessage":case"updateShortChatMessage":var o=2&e.flags,r=e.from_id||(o?f:e.user_id),s=e.chat_id?-e.chat_id:o?e.user_id:f;u({_:"updateNewMessage",message:{_:"message",flags:e.flags,id:e.id,from_id:r,to_id:a.getOutputPeer(s),date:e.date,message:e.message,fwd_from_id:e.fwd_from_id,fwd_date:e.fwd_date,reply_to_msg_id:e.reply_to_msg_id},pts:e.pts,pts_count:e.pts_count},t);break;case"updatesCombined":case"updates":n.saveApiUsers(e.users),i.saveApiChats(e.chats),angular.forEach(e.updates,function(e){u(e,t)});break;default:console.warn(dT(),"Unknown update message",e)}}function d(){_||(_=!0,v={},y=[]),g&&(clearTimeout(g.timeout),g=!1),o.invokeApi("updates.getDifference",{pts:h.pts,date:h.date,qts:0}).then(function(e){if("updates.differenceEmpty"==e._)return console.log(dT(),"apply empty diff",e.seq),h.date=e.date,h.seq=e.seq,_=!1,!1;n.saveApiUsers(e.users),i.saveApiChats(e.chats),angular.forEach(e.other_updates,function(e){p(e)}),angular.forEach(e.new_messages,function(e){p({_:"updateNewMessage",message:e,pts:h.pts,pts_count:0})});var t=e.intermediate_state||e.state;h.seq=t.seq,h.pts=t.pts,h.date=t.date,console.log(dT(),"apply diff",h.seq,h.pts),"updates.differenceSlice"==e._?d():_=!1})}function u(e,t){if(_)return!1;if("updateNewMessage"==e._){var a=e.message;if(a.from_id&&!n.hasUser(a.from_id)||a.fwd_from_id&&!n.hasUser(a.fwd_from_id)||a.to_id.user_id&&!n.hasUser(a.to_id.user_id)||a.to_id.chat_id&&!i.hasChat(a.to_id.chat_id))return console.warn(dT(),"Short update not enough data",a),c(),!1}var o,l;if(e.pts){var u=h.pts+(e.pts_count||0);if(u0){var m=t.seq,f=t.seqStart||m;if(f!=h.seq+1&&f>h.seq)return console.warn(dT(),"Seq hole",h,g&&g.seqAwaiting),void 0===v[f]&&(v[f]={seq:m,date:t.date,updates:[]}),v[f].updates.push(e),g||(g={timeout:setTimeout(function(){d()},5e3)}),(!g.seqAwaiting||g.seqAwaiting-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 i(i,r){if(!i||!i.length)return"";r=r||{};for(var u,p,m,h,f=i,v=[],y=!1;u=f.match(g);){if(v.push(encodeEntities(f.substr(0,u.index))),u[3])if(r.noLinks)v.push(u[1],encodeEntities(u[2]+u[3]));else{var b="";r.highlightUsername&&r.highlightUsername.toLowerCase()==u[3].toLowerCase()&&"@"==u[2]&&(b='class="im_message_mymention"'),v.push(u[1],"',encodeEntities(u[2]+u[3]),"")}else if(u[4])if(r.noLinks)v.push(encodeEntities(u[0]));else if(_.test(u[4]))v.push('',encodeEntities(u[4]),"");else{var p=!1,w=u[5],$=u[6],k="";if($){if(w||"xn--"!==$.substr(0,4)&&-1===Config.TLD.indexOf($.toLowerCase())||(w="http://"),w){var S=a(u[4]);S.length!==u[4].length&&(k=u[4].substring(S.length),u[4]=S),p=(u[5]?"":w)+u[4]}}else p=(u[5]?"":"http://")+u[4];p?(v.push('',encodeEntities(u[4]),"",k),r.extractUrlEmbed&&!r.extractedUrlEmbed&&(r.extractedUrlEmbed=o(p))):v.push(encodeEntities(u[0]))}else u[7]?v.push(r.noLinebreaks?" ":"
"):u[8]?(s=c[u[8]])&&(h=n(s))?(m=encodeEntities(l[s][1][0]),y=!0,v.push('',":",m,":")):v.push(encodeEntities(u[8])):u[10]&&(r.noLinks?v.push(encodeEntities(u[9]),encodeEntities(u[10])):v.push(encodeEntities(u[9]),'',encodeEntities(u[10]),""));f=f.substr(u.index+u[0].length)}return v.push(encodeEntities(f)),i=t(v.join("")),y&&(i=i.replace(/\ufe0f|️/g,"",i),i=i.replace(//g,'')),e.trustAs("html",i)}function a(e){for(var t=e.length,n=e.split("(").length-1,i=e.split(")").length-1;i>n&&")"===e.charAt(t-1);)e=e.substr(0,t-1),i--,t--;return n>i&&(e=e.replace(/\)+$/,"")),e}function o(e){var t;if(t=e.match(v))return["youtube",t[1]];if(t=e.match(y))return["vimeo",t[1]];if(t=e.match(b))return["instagram",t[1]];if(t=e.match(w))return["vine",t[1]];if(t=e.match(S)){var n="explore,upload,pages,terms-of-use,mobile,jobs,imprint".split(","),i="sets".split(",");if(-1==n.indexOf(t[1])&&-1==i.indexOf(t[2]))return["soundcloud",t[0]]}else if(t=e.match(C))return["spotify",t[3].replace("/",":")];if(!Config.Modes.chrome_packed){if(t=e.match($))return["twitter",t[0]];if(t=e.match(k))return void 0!=t[2]?["facebook","https://www.facebook.com/"+t[2]+"/posts/"+t[1]]:["facebook",t[0]]}return!1}function r(e,t){if(u)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(g);)e.push(a.substr(0,n.index)),e.push(n[8]?(s=c[n[8]])&&(i=l[s][1][0])?":"+i+":":n[0]:n[0]),a=a.substr(n.index+n[0].length);return e.push(a),e.join("")}var s,c={},l=Config.Emoji,d=18,u=-1!=navigator.userAgent.search(/OS X|iPhone|iPad|iOS|Android/i),p="\\u0023\\u20E3|\\u00a9|\\u00ae|\\u203c|\\u2049|\\u2139|[\\u2194-\\u2199]|\\u21a9|\\u21aa|\\u231a|\\u231b|\\u23e9|[\\u23ea-\\u23ec]|\\u23f0|\\u24c2|\\u25aa|\\u25ab|\\u25b6|\\u2611|\\u2614|\\u26fd|\\u2705|\\u2709|[\\u2795-\\u2797]|\\u27a1|\\u27b0|\\u27bf|\\u2934|\\u2935|[\\u2b05-\\u2b07]|\\u2b1b|\\u2b1c|\\u2b50|\\u2b55|\\u3030|\\u303d|\\u3297|\\u3299|[\\uE000-\\uF8FF\\u270A-\\u2764\\u2122\\u25C0\\u25FB-\\u25FE\\u2615\\u263a\\u2648-\\u2653\\u2660-\\u2668\\u267B\\u267F\\u2693\\u261d\\u26A0-\\u26FA\\u2708\\u2702\\u2601\\u260E]|[\\u2600\\u26C4\\u26BE\\u23F3\\u2764]|\\uD83D[\\uDC00-\\uDFFF]|\\uD83C[\\uDDE8-\\uDDFA�]\\uD83C[\\uDDEA-\\uDDFA�]|[0-9]\\u20e3|\\uD83C[\\uDC00-\\uDFFF]";for(s in l)c[l[s][0]]=s;var m="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._"+m,f="((?:https?|ftp)://|mailto:)?(?:\\S{1,64}(?::\\S{0,64})?@)?(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(?:\\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}|["+m+"0-9]["+m+"0-9-]{0,64}(?:\\.["+m+"0-9]["+m+"0-9-]{1,64}){0,10}(?:\\.(xn--[0-9a-z]{2,16}|["+m+"]{2,24})))(?::\\d{2,5})?(?:/(?:\\S{0,255}[^\\s.;,(\\[\\]{}<>\"'])?)?",g=new RegExp("(^|\\s)((?:https?://)?telegram\\.me/|@)([a-zA-Z\\d_]{5,32})|("+f+")|(\\n)|("+p+")|(^|\\s)(#["+h+"]{2,64})","i"),_=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,v=/^(?:https?:\/\/)?(?:www\.)?youtu(?:|\.be|be\.com|\.b)(?:\/v\/|\/watch\\?v=|e\/|(?:\/\??#)?\/watch(?:.+)v=)(.{11})(?:\&[^\s]*)?/,y=/^(?:https?:\/\/)?(?:www\.)?vimeo\.com\/(\d+)/,b=/^https?:\/\/(?:instagr\.am\/p\/|instagram\.com\/p\/)([a-zA-Z0-9\-\_]+)/i,w=/^https?:\/\/vine\.co\/v\/([a-zA-Z0-9\-\_]+)/i,$=/^https?:\/\/twitter\.com\/.+?\/status\/\d+/i,k=/^https?:\/\/(?:www\.|m\.)?facebook\.com\/(?:.+?\/posts\/\d+|(?:story\.php|permalink\.php)\?story_fbid=(\d+)(?:&substory_index=\d+)?&id=(\d+))/i,S=/^https?:\/\/(?:soundcloud\.com|snd\.sc)\/([a-zA-Z0-9%\-\_]+)\/([a-zA-Z0-9%\-\_]+)/i,C=/(https?:\/\/(open\.spotify\.com|play\.spotify\.com|spoti\.fi)\/(.+)|spotify:(.+))/i;return{wrapRichText:i,wrapPlainText:r}}]).service("StatusManager",["$timeout","$rootScope","MtpApiManager","AppUsersManager","IdleManager",function(e,t,n,i){function a(){d||(d=!0,t.$watch("idle.isIDLE",r),t.$watch("offline",r))}function o(e){var a=tsNow();if(!(e&&!l||!e&&5e4>a-l||t.offline))return l=e?0:a,i.setUserStatus(u,e),n.invokeApi("account.updateStatus",{offline:e},{noErrorBox:!0})}function r(){c&&e.cancel(c),t.idle.isIDLE?c=e(function(){o(!0)},5e3):(o(!1),c=e(r,6e4))}function s(){return p?tsNow()>p?(p=!1,!1):!0:!1}var c,l=0,d=!1,u=0,p=!1;return n.getUserID().then(function(e){u=e}),t.$on("apiUpdate",function(e,t){"updateUserStatus"==t._&&t.user_id==u&&(p=tsNow()+("userStatusOnline"==t.status._?3e5:0))}),{start:a,isOtherDeviceActive:s}}]).service("NotificationsManager",["$rootScope","$window","$interval","$q","_","MtpApiManager","AppPeersManager","IdleManager","Storage","AppRuntimeManager",function(e,t,n,i,a,o,r,s,c,l){function d(e){return void 0!==O[e]?O[e]:O[e]=o.invokeApi("account.getNotifySettings",{peer:{_:"inputNotifyPeer",peer:r.getInputPeerByID(e)}})}function u(e){if(e=e||"favicon.ico",A!==e){var t=document.createElement("link");t.rel="shortcut icon",t.type="image/x-icon",t.href=e,U.parentNode.replaceChild(t,U),U=t,A=e}}function p(e,t){O[e]=i.when(t)}function m(e,t){p(e,t);var n=angular.copy(t);return n._="inputPeerNotifySettings",o.invokeApi("account.updateNotifySettings",{peer:{_:"inputNotifyPeer",peer:r.getInputPeerByID(e)},settings:n})}function h(e){return d(e).then(function(e){return"peerNotifySettings"==e._&&1e3*e.mute_until>tsNow()})}function f(){if(w(),!x)return!1;"Notification"in window&&"granted"!==Notification.permission&&"denied"!==Notification.permission&&$(t).on("click",g);try{"onbeforeunload"in window&&$(t).on("beforeunload",b)}catch(e){}}function g(){Notification.requestPermission(),$(t).off("click",g)}function _(e){return Config.Navigator.ffos?e.image="https://raw.githubusercontent.com/zhukov/webogram/master/app/img/icons/icon60.png":e.image||(e.image="img/icons/icon60.png"),I++,c.get("notify_nosound","notify_volume").then(function(e){(!e[0]&&e[1]===!1||e[1]>0)&&v(e[1]||.5)}),!x||"Notification"in window&&"granted"!==Notification.permission?!1:void c.get("notify_nodesktop","notify_novibrate").then(function(t){if(t[0]){if(D&&!t[1])return void navigator.vibrate([200,100,200])}else{var n,i=++T,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)n=navigator.mozNotification.createNotification(e.title,e.message||"",e.image||"");else{if(!S)return;window.external.msSiteModeClearIconOverlay(),window.external.msSiteModeSetIconOverlay("img/icons/icon16.png",e.title),window.external.msSiteModeActivate(),n={index:i}}n.onclick=function(){n.close(),l.focus(),b(),e.onclick&&e.onclick()},n.onclose=function(){delete E[a],b()},n.show&&n.show(),E[a]=n}})}function v(e){var t=tsNow();if(!(P&&P>t&&N==e)){P=t+1e3,N=e;var n="img/sound_a.mp3",i=$("#notify_sound").html('');i.find("audio")[0].volume=e}}function y(e){var t=E[e];if(t){I>0&&I--;try{t.close?t.close():S&&t.index==T&&window.external.msSiteModeClearIconOverlay()}catch(n){}delete I[e]}}function b(){S?window.external.msSiteModeClearIconOverlay():angular.forEach(E,function(e){try{e.close&&e.close()}catch(t){}}),E={},I=0}function w(){if(F)return!1;if(navigator.push&&Config.Navigator.ffos&&Config.Modes.packed){var e=navigator.push.register();e.onsuccess=function(){clearTimeout(j),console.log(dT(),"Push registered",e.result),F=e.result,o.invokeApi("account.registerDevice",{token_type:4,token:F,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()),j=setTimeout(w,q),q=Math.min(3e4,1.5*q)}}}function k(){return D}navigator.vibrate=navigator.vibrate||navigator.mozVibrate||navigator.webkitVibrate;var S=!1;try{window.external&&window.external.msIsSiteMode()&&(S=!0)}catch(C){}var M,A,x=S||"Notification"in window||"mozNotification"in navigator,E={},T=0,I=0,D=!!navigator.vibrate,P=!1,N=!1,O={},U=$('link[rel="icon"]:first')[0],L=a.pluralize("page_title_pluralize_notifications"),R=document.title,B=!1;e.$watch("idle.isIDLE",function(e){e||b(),Config.Navigator.mobile||(n.cancel(M),e?(R=document.title,M=n(function(){var e=tsNow();!I||e%2e3>1e3?B&&(B=!1,document.title=R,u()):(B=!0,document.title=L(I),u("favicon_unread.ico"))},1e3)):(B=!1,document.title=R,u()))}),e.$on("apiUpdate",function(e,t){switch(t._){case"updateNotifySettings":if("notifyPeer"==t.peer._){var n=r.getPeerID(t.peer.peer);p(n,t.notify_settings)}}});var F=!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),F=!1,w()})),{start:f,notify:_,cancel:y,clear:b,getPeerSettings:d,getPeerMuted:h,savePeerSettings:p,updatePeerSettings:m,getVibrateSupport:k,testSound:v};var q,j}]).service("PasswordManager",["$timeout","$q","$rootScope","MtpApiManager","CryptoWorker","MtpSecureRandom",function(e,t,n,i,a,o){function r(e){return i.invokeApi("account.getPassword",{},e).then(function(e){return e})}function s(e,n){var a,r,s={new_settings:{_:"account.passwordInputSettings",flags:0,hint:n.hint||""}};if(a="string"==typeof n.cur_password&&n.cur_password.length>0?u(e.current_salt,n.cur_password):t.when([]),"string"==typeof n.new_password&&n.new_password.length>0){var c=new Array(8),l=bufferConcat(e.new_salt,c);o.nextBytes(c),r=u(l,n.new_password),s.new_settings.new_salt=l,s.new_settings.flags|=1}else"string"==typeof n.new_password&&(s.new_settings.flags|=1,s.new_settings.new_salt=[]),r=t.when([]);return"string"==typeof n.email&&(s.new_settings.flags|=2,s.new_settings.email=n.email||""),t.all([a,r]).then(function(e){return s.current_password_hash=e[0],s.new_settings.new_password_hash=e[1],i.invokeApi("account.updatePasswordSettings",s)})}function c(e,t,n){return u(e.current_salt,t).then(function(e){return i.invokeApi("auth.checkPassword",{password_hash:e},n)})}function l(e,t){return i.invokeApi("auth.requestPasswordRecovery",{},t)}function d(e,t){return i.invokeApi("auth.recoverPassword",{code:e},t)}function u(e,t){for(var n=unescape(encodeURIComponent(t)),i=new ArrayBuffer(n.length),o=new Uint8Array(i),r=0,s=n.length;s>r;r++)o[r]=n.charCodeAt(r);return i=bufferConcat(bufferConcat(e,o),e),a.sha256Hash(i)}return{check:c,getState:r,requestRecovery:l,recover:d,updateSettings:s}}]).service("ErrorService",["$rootScope","$modal","$window",function(e,t,n){function i(n,i){if(r>=1)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:templateUrl("error_modal"),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:templateUrl("confirm_modal"),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();return i.multiSelect=!1,n&&angular.extend(i,n),t.open({templateUrl:templateUrl("peer_select"),controller:"PeerSelectController",scope:i,windowClass:"peer_select_window mobile_modal"}).result}function i(i){if(Config.Mobile)return n(i).then(function(e){return[e]});var a=e.$new();return a.multiSelect=!0,i&&angular.extend(a,i),t.open({templateUrl:templateUrl("peer_select"),controller:"PeerSelectController",scope:a,windowClass:"peer_select_window mobile_modal"}).result }return{selectPeer:n,selectPeers:i}}]).service("ContactsSelectService",["$rootScope","$modal",function(e,t){function n(n,i){i=i||{};var a=e.$new();return a.multiSelect=n,angular.extend(a,i),!a.action&&n&&(a.action="select"),t.open({templateUrl:templateUrl("contacts_modal"),controller:"ContactsModalController",scope:a,windowClass:"contacts_modal_window mobile_modal"}).result}return{selectContacts:function(e){return n(!0,e)},selectContact:function(e){return n(!1,e)}}}]).service("ChangelogNotifyService",["Storage","$rootScope","$modal",function(e,t,n){function i(){e.get("last_version").then(function(t){t!=Config.App.version&&(t&&a(t),e.set({last_version:Config.App.version}))})}function a(e){var i=t.$new();i.lastVersion=e,n.open({controller:"ChangelogModalController",templateUrl:templateUrl("changelog_modal"),scope:i,windowClass:"changelog_modal_window mobile_modal"})}return{checkUpdate:i,showChangelog:a}}]).service("HttpsMigrateService",["ErrorService","Storage",function(e,t){function n(){t.get("https_dismiss").then(function(n){(!n||tsNow()>n+432e5)&&e.confirm({type:"MIGRATE_TO_HTTPS"}).then(function(){var e;try{e=window.open("https://web.telegram.org","_blank")}catch(t){}e||(location="https://web.telegram.org")},function(){t.set({https_dismiss:tsNow()})})})}function i(){a||"http:"!=location.protocol||Config.Modes.http||-1==Config.App.domains.indexOf(location.hostname)||(a=!0,setTimeout(n,12e4))}var a=!1;return{start:i,check:n}}]).service("LayoutSwitchService",["ErrorService","Storage","AppRuntimeManager","$window",function(e,t,n,i){function a(e){ConfigStorage.noPrefix(),t.set({layout_selected:e?"mobile":"desktop",layout_width:$(window).width()}).then(function(){n.reload()})}function o(n){if(!c){var i=$(window).width(),o=600>i;!i||!n&&(Config.Navigator.mobile?800>=i:o)||o!=Config.Mobile&&(ConfigStorage.noPrefix(),t.get("layout_width").then(function(n){return i==n?!1:(c=!0,void e.confirm({type:o?"SWITCH_MOBILE_VERSION":"SWITCH_DESKTOP_VERSION"}).then(function(){a(o)},function(){ConfigStorage.noPrefix(),t.set({layout_width:i}),c=!1}))}))}}function r(){s||Config.Navigator.mobile||(s=!0,o(),$(i).on("resize",o))}var s=!1,c=!1;return{start:r,switchLayout:a}}]).service("TelegramMeWebService",["Storage",function(e){function t(t){return n?!1:void e.get("tgme_sync").then(function(n){var i=tsNow(!0);if(t&&n&&n.canRedirect==t&&n.ts+86400>i)return!1;e.set({tgme_sync:{canRedirect:t,ts:i}});var a=$("