From dc345a1891ee0bb6d9e3aca97e52a8b0916ed859 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Fri, 12 May 2017 00:00:00 +0300 Subject: [PATCH] Update 2017-05-11T20:59:58.163Z --- js/app.js | 18 +++++++++--------- service_worker.js | 2 +- webogram.appcache | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/js/app.js b/js/app.js index 214d0668..7f7dc826 100644 --- a/js/app.js +++ b/js/app.js @@ -28,16 +28,16 @@ t&&f(e,t)},function(){f(e).then(function(e){l.download(e,t.mime_type,n)})})}func if(t?n.push(t):e.selectedCount>0&&angular.forEach(e.selectedMsgs,function(e,t){n.push(t)}),n.length){for(var a=e.curDialog.peerID,i=a>0,s=p.isChannel(a),o=p.isBroadcast(a),r=p.isMegagroup(a),l=!s&&!i,c=!s,u=0;c&&u0&&angular.forEach(e.selectedMsgs,function(e,t){n.push(t)}),n.length&&m.selectPeer({canSend:!0}).then(function(e){B(),i.$broadcast("history_focus",{peerString:e,attachment:{_:"fwd_messages",id:n}})})}function H(t){t||1!=e.selectedCount||angular.forEach(e.selectedMsgs,function(e,n){t=n}),t&&(B(),e.$broadcast("reply_selected",t))}function q(t){t||1!=e.selectedCount||angular.forEach(e.selectedMsgs,function(e,n){t=n}),t&&(B(),e.$broadcast("edit_selected",t))}function V(){e.historyState.selectActions?B():(e.historyState.selectActions="selected",e.$broadcast("ui_panel_update"))}function z(t){return"search"==t?void i.$broadcast("history_search",e.curDialog.peerID):(e.historyFilter.mediaType=t||!1,e.curDialog.messageID=!1,K.messages=[],K.ids=[],e.state.empty=!0,void A())}function W(){e.historyFilter.mediaType?z():e.curDialog.messageID?i.$broadcast("history_focus",{peerString:e.curDialog.peer}):A(!0)}e.$watchCollection("curDialog",y),u.attach(),g.start(),h.start(),e.peerHistories=[],e.selectedMsgs={},e.selectedCount=0,e.historyState.selectActions=!1,e.historyState.botActions=!1,e.historyState.channelActions=!1,e.historyState.canDelete=!1,e.historyState.canReply=!1,e.historyState.missedCount=0,e.historyState.skipped=!1,e.state={},e.toggleMessage=R,e.selectedDelete=O,e.selectedForward=j,e.selectedReply=H,e.selectedEdit=q,e.selectedCancel=B,e.selectedFlush=U,e.selectInlineBot=N,e.startBot=T,e.cancelBot=D,e.joinChannel=P,e.togglePeerMuted=F,e.toggleEdit=V,e.toggleMedia=z,e.returnToRecent=W,e.$on("history_edit_toggle",V),e.$on("history_edit_flush",U),e.$on("history_media_toggle",function(e,t){z(t)}),e.$on("history_return_recent",W);var G,K=!1,Y=!1,Z=!1,X=!1,J=0,Q=0,ee=!1,te={photos:"inputMessagesFilterPhotos",video:"inputMessagesFilterVideo",documents:"inputMessagesFilterDocument",audio:"inputMessagesFilterVoice"},ne=0,ae=0,ie=!1,se=!1,oe=0,re=!1,le=!1;e.$on("history_update",angular.noop);var ce=!1;e.$on("stateSynchronized",function(){ce&&(ce==e.curDialog.peerID&&A(),ce=!1)}),e.$on("reply_button_press",function(t,n){var a=e.historyState.replyKeyboard;if(a){var i={replyToMsgID:G<0&&a.mid};switch(n._){case"keyboardButtonRequestPhone":_.confirm({type:"BOT_ACCESS_PHONE"}).then(function(){var e=l.getSelf();d.sendOther(G,{_:"inputMediaContact",phone_number:e.phone,first_name:e.first_name,last_name:e.last_name},i)});break;case"keyboardButtonRequestGeoLocation":_.confirm({type:"BOT_ACCESS_GEO"}).then(function(){return v.getPosition().then(function(e){d.sendOther(G,{_:"inputMediaGeoPoint",geo_point:{_:"inputGeoPoint",lat:e.lat,"long":e["long"]}},i)},function(e){_.alert(o("error_modal_bad_request_title_raw"),o("error_modal_gelocation_na_raw"))})});break;default:d.sendText(G,n.text,i)}}}),e.$on("history_reload",function(t,n){n==e.curDialog.peerID&&A()}),e.$on("history_forbidden",function(n,a){a==e.curDialog.peerID&&t.url("/im"),k(a)}),e.$on("dialog_migrate",function(t,n){if(n.migrateFrom==e.curDialog.peerID){var a=p.getPeerString(n.migrateTo);i.$broadcast("history_focus",{peerString:a})}k(n.migrateFrom)}),e.$on("notify_settings",function(t,n){n.peerID==e.curDialog.peerID&&S()}),e.$on("channel_settings",function(t,n){n.channelID==-e.curDialog.peerID&&S()});var de={};e.$on("history_append",function(t,a){var s=w(a.peerID);if(s){var o=a.peerID==e.curDialog.peerID;if(o){if(e.historyFilter.mediaType||e.historyState.skipped)return void(a.my?W():e.historyState.missedCount++);e.curDialog.messageID&&a.my&&W(),delete e.state.empty}var r=d.wrapForHistory(a.messageID);s.messages.push(r),s.ids.push(a.messageID),d.regroupWrappedHistory(s.messages,-3)&&e.$broadcast("messages_regroup"),o&&(e.historyState.typing.splice(0,e.historyState.typing.length),e.$broadcast("ui_history_append_new",{my:a.my,idleScroll:Y&&!r.pFlags.out&&i.idle.isIDLE}),a.my&&e.historyUnreadAfter&&(delete e.historyUnreadAfter,e.$broadcast("messages_unread_after")),i.idle.isIDLE?!r.pFlags.unread||r.pFlags.out||(s.messages[s.messages.length-2]||{}).pFlags.unread||(e.historyUnreadAfter=r.mid,Y=!0,e.$broadcast("messages_unread_after")):n(function(){d.readHistory(e.curDialog.peerID)}),C(),S())}}),e.$on("history_multiappend",function(t,a){var s=!1,o=!1,r=i.idle.isIDLE;angular.forEach(a,function(t,a){var i=w(a);if(i){var l=a==e.curDialog.peerID,c=i.messages.length,p=t.length;if(l){if(e.historyFilter.mediaType||e.historyState.skipped)return void(e.historyState.missedCount+=p);delete e.state.empty}if((!l||r)&&c>(p>10?10:100))return console.warn(dT(),"Drop too many messages",p,c,r,l,a),void(l?(Q=i.messages[c-1].mid,e.historyState.skipped=X=Q>0,X&&(ce=a,e.$broadcast("ui_history_append"))):k(a));var u,m,g=!1,h=!1,f=i.messages[i.messages.length-1],_=!f||!f.pFlags.unread;for(m=0;m0){e=f.parseEmojis(e);var t={replyToMsgID:n.draftMessage.replyToMsgID,clearDraft:!0};do u.sendText(n.curDialog.peerID,e.substr(0,4096),t),e=e.substr(4096),t=angular.copy(t),delete t.clearDraft;while(e.length)}E(),H==n.curDialog.peer&&(H=!1),k(),n.$broadcast("ui_message_send")}function y(){var e=n.draftMessage.text;e=f.parseEmojis(e),u.editMessage(q,e).then(function(){q=!1,k(),n.$broadcast("ui_message_send"),a(function(){n.$broadcast("ui_peer_reply")})})}function b(){var e=n.curDialog.peerID;if(!e)return safeReplaceObject(n.mentions,{}),void n.$broadcast("mentions_update");var a,i=[],s=SearchIndexManager.createIndex(),r=m.getPopularBots().then(function(e){var t=[];return angular.forEach(e,function(e){t.push(e.id)}),t});a=e<0?o.getChatFull(-e).then(function(e){var t=(e.participants||{}).participants||[],n=[];return angular.forEach(t,function(e){n.push(e.user_id)}),n}):t.when([]),t.all({pop:r,chat:a}).then(function(e){var t={},a=e.pop.concat(e.chat);angular.forEach(a,function(e){t[e]||(t[e]=!0,i.push(l.getUser(e)),SearchIndexManager.indexObject(e,l.getUserSearchText(e),s))}),safeReplaceObject(n.mentions,{users:i,index:s}),n.$broadcast("mentions_update")})}function w(){var e=n.curDialog.peerID;return e?void o.getPeerBots(e).then(function(t){if(!t.length)return safeReplaceObject(n.commands,{}),void n.$broadcast("mentions_update");var a=e<0,i=[],s=SearchIndexManager.createIndex();angular.forEach(t,function(e){var t="";if(a){var n=l.getUser(e.id);n&&n.username&&(t+="@"+n.username)}var o=l.getUserSearchText(e.id);angular.forEach(e.commands,function(n,a){var r="/"+a+t;i.push({botID:e.id,value:r,rDescription:f.wrapRichText(n,{noLinks:!0,noLineBreaks:!0})}),SearchIndexManager.indexObject(r,o+" "+a+" "+n,s)})}),safeReplaceObject(n.commands,{list:i,index:s}),n.$broadcast("mentions_update")}):(safeReplaceObject(n.commands,{}),void n.$broadcast("mentions_update"))}function k(e,t){var i=t?c.getPeerID(t):0;if(e!=t&&i)return n.$broadcast("ui_message_before_send"),void a(function(){h.syncDraft(i),k()});if(q=!1,b(),w(),I(),D(),delete n.draftMessage.inlineProgress,n.$broadcast("inline_results",!1),H){if(H==n.curDialog.peer)return n.draftMessage.isBroadcast=c.isBroadcast(n.curDialog.peerID),void n.$broadcast("ui_peer_draft");H=!1}A(),$()}function $(){if(n.curDialog.peerID){var e;e=q?u.getMessageEditData(q).then(function(e){return e.replyToMsgID=q,e},function(e){return console.warn(e),q=!1,$(),t.reject()}):h.getDraft(n.curDialog.peerID),e.then(function(e){if(n.draftMessage.type=q?"edit":"new",n.draftMessage.text=e?e.text:"",n.draftMessage.isBroadcast=c.isBroadcast(n.curDialog.peerID),e.replyToMsgID){var t=e.replyToMsgID;S(t)}else I();n.$broadcast("ui_peer_draft")})}else n.draftMessage.text="",n.$broadcast("ui_peer_draft")}function C(e,t){if(console.log(dT(),"apply draft attach",t),t&&t._)if("share_url"==t._){var i=t.url,s=t.text||" ";H=n.curDialog.peer,a(function(){n.draftMessage.text=i+"\n"+s,n.$broadcast("ui_peer_draft",{customSelection:[i+"\n",s,""]})},1e3)}else if("fwd_messages"==t._)H=n.curDialog.peer,a(function(){n.draftMessage.fwdMessages=t.id,n.$broadcast("ui_peer_reply")},100);else if("inline_query"==t._){var o=t.mention,r=t.query;H=n.curDialog.peer,a(function(){n.draftMessage.text=o+" "+r,n.$broadcast("ui_peer_draft",{customSelection:[o+" "+r,"",""]})},1e3)}}function S(e,t){return q&&t?void I():(n.draftMessage.replyToMsgID=e,n.$broadcast("ui_peer_reply"),j=!1,void(t&&!q&&h.changeDraft(n.curDialog.peerID,{text:n.draftMessage.text,replyToMsgID:e})))}function M(e){q=e,$()}function x(){return!(q||!n.curDialog.peerID)&&void u.getHistory(n.curDialog.peerID).then(function(e){for(var t,n=0;n0,t.nav.hasPrev=b||n<_.length-1,t.canForward=t.canDelete=t.messageID>0}function u(n){var a=_.indexOf(t.messageID),o=a>=0?a+n:0,r=++w,l=o>=_.length?m():e.when();l.then(function(){if(r==w){var e=_[o],a=s.getMessage(e),l=a&&a.media&&(a.media.photo&&a.media.photo.id||a.media.webpage&&a.media.webpage.photo&&a.media.webpage.photo.id);if(!l)return void console.error("Invalid photo message",o,_,e,a);t.messageID=e,t.photoID=l,t.photo=i.wrapForFull(t.photoID),v[t.messageID]=!0,p(),n>0&&b&&_.indexOf(e)+1>=_.length?m():d(n)}})}function m(){return k?k:k=s.getSearch(g,h,f,y).then(function(t){return t.history.length?(y=t.history[t.history.length-1],_=_.concat(t.history),b=_.length=0&&(_=e.history,y=_[_.length-1],p(),d(1)),m()},m);var w=0,k=!1}}]).controller("UserpicModalController",["$q","$scope","$rootScope","$modalInstance","MtpApiManager","AppPhotosManager","AppUsersManager","AppPeersManager","AppMessagesManager","ApiUpdatesManager","PeersSelectService","ErrorService",function(e,t,n,a,i,s,o,r,l,c,d,p){function u(n,a){var i=f.indexOf(t.photoID),o=i>=0?i+n:0,r=++w,l=o>=f.length?g():e.when();l.then(function(){if(r==w){t.photoID=f[o],t.photo=s.wrapForFull(t.photoID),t.photo.thumb={location:s.choosePhotoSize(t.photo,0,0).location};var e;a&&(f.splice(i,1),e=t.count-1),h(e),v[t.photoID]=!0,h(),n>0&&b&&f.indexOf(t.photoID)+1>=f.length?g():m(n)}})}function m(e){var n=e<0?[-1,-2]:[1,2],a=f.indexOf(t.photoID);angular.forEach(n,function(e){var t=f[a+e];void 0!==t&&void 0===v[t]&&(v[t]=!0,s.preloadPhoto(t))})}function g(){return k?k:k=s.getUserPhotos(t.userID,_).then(function(t){return t.photos.length?(_=t.photos[t.photos.length-1],f=f.concat(t.photos),b=f.length0,t.nav.hasPrev=b||n=0&&(f=e.photos,_=f[f.length-1]),b=f.length=200,(Config.Modes.test||Config.Modes.debug)&&(e.needMigrate=!0),u.savePeerSettings(-e.chatID,t.notify_settings),u.getPeerMuted(-e.chatID).then(function(t){e.settings.notifications=!t,e.$watch("settings.notifications",function(t,n){return t!==n&&void u.getPeerSettings(-e.chatID).then(function(n){t?n.mute_until=0:n.mute_until=2e9,u.updatePeerSettings(-e.chatID,n)})})})}),e.leaveGroup=function(){_.confirm({type:"HISTORY_LEAVE_AND_FLUSH"}).then(function(){d.invokeApi("messages.deleteChatUser",{chat_id:r.getChatInput(e.chatID),user_id:{_:"inputUserSelf"}}).then(function(a){h.processUpdateMessage(a),m.flushHistory(-e.chatID).then(function(){t.close(),n.url("/im")})})})},e.inviteToGroup=function(){var t=[];angular.forEach(e.chatFull.participants.participants,function(e){t.push(e.user_id)}),f.selectContacts({disabled:t}).then(function(t){angular.forEach(t,function(t){d.invokeApi("messages.addChatUser",{chat_id:r.getChatInput(e.chatID),user_id:o.getUserInput(t),fwd_limit:100}).then(function(e){h.processUpdateMessage(e)})}),i.$broadcast("history_focus",{peerString:e.chatFull.peerString})})},e.migrateToSuperGroup=function(){_.confirm({type:"SUPERGROUP_MIGRATE" }).then(function(){d.invokeApi("messages.migrateChat",{chat_id:r.getChatInput(e.chatID)}).then(v)})},e.kickFromGroup=function(t){d.invokeApi("messages.deleteChatUser",{chat_id:r.getChatInput(e.chatID),user_id:o.getUserInput(t)}).then(v)},e.flushHistory=function(a){_.confirm({type:a?"HISTORY_FLUSH":"HISTORY_FLUSH_AND_DELETE"}).then(function(){m.flushHistory(-e.chatID,a).then(function(){a?i.$broadcast("history_focus",{peerString:e.chatFull.peerString}):(t.close(),n.url("/im"))})})},e.inviteViaLink=function(){var t=i.$new();t.chatID=e.chatID,s.open({templateUrl:templateUrl("chat_invite_link_modal"),controller:"ChatInviteLinkModalController",scope:t,windowClass:"md_simple_modal_window"})},e.photo={},e.$watch("photo.file",y),e.deletePhoto=function(){e.photo.updating=!0,d.invokeApi("messages.editChatPhoto",{chat_id:r.getChatInput(e.chatID),photo:{_:"inputChatPhotoEmpty"}}).then(v)["finally"](function(){e.photo.updating=!1})},e.editTitle=function(){var t=i.$new();t.chatID=e.chatID,s.open({templateUrl:templateUrl("chat_edit_modal"),controller:"ChatEditModalController",scope:t,windowClass:"md_simple_modal_window mobile_modal"})},e.hasRights=function(t){return r.hasRights(e.chatID,t)}}]).controller("ChannelModalController",["$scope","$timeout","$rootScope","$modal","AppUsersManager","AppChatsManager","AppProfileManager","AppPhotosManager","MtpApiManager","MtpApiFileManager","NotificationsManager","AppMessagesManager","AppPeersManager","ApiUpdatesManager","ContactsSelectService","ErrorService",function(e,t,n,a,i,s,o,r,l,c,d,p,u,m,g,h){function f(t){m.processUpdateMessage(t),n.$broadcast("history_focus",{peerString:e.chatFull.peerString})}function _(t){t&&t.type&&0===t.type.indexOf("image")&&(e.photo.updating=!0,c.uploadFile(t).then(function(t){return l.invokeApi("channels.editPhoto",{channel:s.getChannelInput(e.chatID),photo:{_:"inputChatUploadedPhoto",file:t}}).then(f)})["finally"](function(){e.photo.updating=!1}))}e.chatFull=s.wrapForFull(e.chatID,{}),e.settings={notifications:!0},e.isMegagroup=s.isMegagroup(e.chatID),o.getChannelFull(e.chatID,!0).then(function(t){e.chatFull=s.wrapForFull(e.chatID,t),e.$broadcast("ui_height"),d.savePeerSettings(-e.chatID,t.notify_settings),d.getPeerMuted(-e.chatID).then(function(t){e.settings.notifications=!t,e.$watch("settings.notifications",function(t,n){return t!==n&&void d.getPeerSettings(-e.chatID).then(function(n){t?n.mute_until=0:n.mute_until=2e9,d.updatePeerSettings(-e.chatID,n)})})}),e.chatFull.chat&&e.chatFull.chat.pFlags.creator&&e.chatFull.exported_invite&&"chatInviteEmpty"==e.chatFull.exported_invite._&&o.getChatInviteLink(e.chatID,!0).then(function(t){e.chatFull.exported_invite={_:"chatInviteExported",link:t}})}),e.leaveChannel=function(){return h.confirm({type:e.isMegagroup?"MEGAGROUP_LEAVE":"CHANNEL_LEAVE"}).then(function(){l.invokeApi("channels.leaveChannel",{channel:s.getChannelInput(e.chatID)}).then(f)})},e.deleteChannel=function(){return h.confirm({type:e.isMegagroup?"MEGAGROUP_DELETE":"CHANNEL_DELETE"}).then(function(){l.invokeApi("channels.deleteChannel",{channel:s.getChannelInput(e.chatID)}).then(f)})},e.joinChannel=function(){l.invokeApi("channels.joinChannel",{channel:s.getChannelInput(e.chatID)}).then(f)},e.inviteToChannel=function(){var t=[];angular.forEach((e.chatFull.participants||{}).participants||[],function(e){t.push(e.user_id)}),g.selectContacts({disabled:t}).then(function(t){var n=[];angular.forEach(t,function(e){n.push(i.getUserInput(e))}),l.invokeApi("channels.inviteToChannel",{channel:s.getChannelInput(e.chatID),users:n}).then(f)})},e.kickFromChannel=function(t){l.invokeApi("channels.kickFromChannel",{channel:s.getChannelInput(e.chatID),user_id:i.getUserInput(t),kicked:!0}).then(f)},e.shareLink=function(t){var i=n.$new();return i.chatID=e.chatID,a.open({templateUrl:templateUrl("chat_invite_link_modal"),controller:"ChatInviteLinkModalController",scope:i,windowClass:"md_simple_modal_window"}),cancelEvent(t)},e.photo={},e.$watch("photo.file",_),e.deletePhoto=function(){e.photo.updating=!0,l.invokeApi("channels.editPhoto",{channel:s.getChannelInput(e.chatID),photo:{_:"inputChatPhotoEmpty"}}).then(f)["finally"](function(){e.photo.updating=!1})},e.editChannel=function(){var t=n.$new();t.chatID=e.chatID,a.open({templateUrl:templateUrl(e.isMegagroup?"megagroup_edit_modal":"channel_edit_modal"),controller:"ChannelEditModalController",scope:t,windowClass:"md_simple_modal_window mobile_modal"})},e.goToHistory=function(){n.$broadcast("history_focus",{peerString:e.chatFull.peerString})},e.hasRights=function(t){return s.hasRights(e.chatID,t)}}]).controller("SettingsModalController",["$rootScope","$scope","$timeout","$modal","AppUsersManager","AppChatsManager","AppPhotosManager","MtpApiManager","Storage","NotificationsManager","MtpApiFileManager","PasswordManager","ApiUpdatesManager","ChangelogNotifyService","LayoutSwitchService","WebPushApiManager","AppRuntimeManager","ErrorService","_",function(e,t,n,a,i,s,o,r,l,c,d,p,u,m,g,h,f,_,v){function y(){n.cancel(w),w=!1,p.getState().then(function(e){t.password=e,"account.noPassword"==e._&&e.email_unconfirmed_pattern&&!k&&(w=n(y,5e3))})}function b(e){e&&e.type&&0===e.type.indexOf("image")&&(t.photo.updating=!0,d.uploadFile(e).then(function(e){r.invokeApi("photos.uploadProfilePhoto",{file:e,caption:"",geo_point:{_:"inputGeoPointEmpty"}}).then(function(e){i.saveApiUsers(e.users),r.getUserID().then(function(n){o.savePhoto(e.photo,{user_id:n}),u.processUpdateMessage({_:"updateShort",update:{_:"updateUserPhoto",user_id:n,date:tsNow(!0),photo:i.getUser(n).photo,previous:!0}}),t.photo={}})})})["finally"](function(){delete t.photo.updating}))}t.profile={},t.photo={},t.version=Config.App.version,r.getUserID().then(function(e){t.profile=i.getUser(e)}),r.invokeApi("users.getFullUser",{id:{_:"inputUserSelf"}}).then(function(e){i.saveApiUser(e.user),e.profile_photo&&o.savePhoto(e.profile_photo,{user_id:e.user.id})}),t.notify={volume:.5},t.send={},t.$watch("photo.file",b),t.password={_:"account.noPassword"},y();var w=!1,k=!1;t.changePassword=function(n){if(n=n||{},"cancel_email"==n.action)return _.confirm({type:"PASSWORD_ABORT_SETUP"}).then(function(){p.updateSettings(t.password,{email:""}).then(y)});var i=e.$new();i.password=t.password,angular.extend(i,n);var s=a.open({scope:i,templateUrl:templateUrl("password_update_modal"),controller:"PasswordUpdateModalController",windowClass:"md_simple_modal_window mobile_modal"});s.result["finally"](y)},t.showSessions=function(){a.open({templateUrl:templateUrl("sessions_list_modal"),controller:"SessionsListModalController",windowClass:"md_simple_modal_window mobile_modal"})},t.$on("$destroy",function(){n.cancel(w),k=!0}),t.deletePhoto=function(){t.photo.updating=!0,r.invokeApi("photos.updateProfilePhoto",{id:{_:"inputPhotoEmpty"}}).then(function(e){r.getUserID().then(function(n){u.processUpdateMessage({_:"updateShort",update:{_:"updateUserPhoto",user_id:n,date:tsNow(!0),photo:e,previous:!0}}),t.photo={}})})["finally"](function(){delete t.photo.updating})},t.editProfile=function(){a.open({templateUrl:templateUrl("profile_edit_modal"),controller:"ProfileEditModalController",windowClass:"md_simple_modal_window mobile_modal"})},t.changeUsername=function(){a.open({templateUrl:templateUrl("username_edit_modal"),controller:"UsernameEditModalController",windowClass:"md_simple_modal_window mobile_modal"})},t.terminateSessions=function(){_.confirm({type:"TERMINATE_SESSIONS"}).then(function(){r.invokeApi("auth.resetAuthorizations",{})})},l.get("notify_nodesktop","send_ctrlenter","notify_volume","notify_novibrate","notify_nopreview","notify_nopush").then(function(a){t.notify.desktop=!a[0],t.send.enter=a[1]?"":"1",t.notify.pushAvailable=h.isAvailable,t.notify.push=!a[5],a[2]!==!1?t.notify.volume=a[2]>0&&a[2]<=1?a[2]:0:t.notify.volume=.5,t.notify.canVibrate=c.getVibrateSupport(),t.notify.vibrate=!a[3],t.notify.preview=!a[4],t.notify.volumeOf4=function(){return 1+Math.ceil((t.notify.volume-.1)/.33)},t.toggleSound=function(){t.notify.volume?t.notify.volume=0:t.notify.volume=.5};var i;t.$watch("notify.volume",function(t,a){t!==a&&(l.set({notify_volume:t}),e.$broadcast("settings_changed"),c.clear(),i&&n.cancel(i),i=n(function(){c.testSound(t)},500))}),t.toggleDesktop=function(){t.notify.desktop=!t.notify.desktop,t.notify.desktop?l.remove("notify_nodesktop"):l.set({notify_nodesktop:!0}),e.$broadcast("settings_changed")},t.togglePush=function(){t.notify.push=!t.notify.push,t.notify.push?l.remove("notify_nopush"):l.set({notify_nopush:!0}),e.$broadcast("settings_changed")},t.togglePreview=function(){t.notify.preview=!t.notify.preview,t.notify.preview?l.remove("notify_nopreview"):l.set({notify_nopreview:!0}),e.$broadcast("settings_changed")},t.toggleVibrate=function(){t.notify.vibrate=!t.notify.vibrate,t.notify.vibrate?l.remove("notify_novibrate"):l.set({notify_novibrate:!0}),e.$broadcast("settings_changed")},t.toggleCtrlEnter=function(n){t.send.enter=n,t.send.enter?l.remove("send_ctrlenter"):l.set({send_ctrlenter:!0}),e.$broadcast("settings_changed")}}),t.openChangelog=function(){m.showChangelog(!1)},t.logOut=function(){_.confirm({type:"LOGOUT"}).then(function(){r.logOut().then(function(){location.hash="/login",f.reload()})})},t.switchBackToDesktop=Config.Mobile&&!Config.Navigator.mobile,t.switchToDesktop=function(){g.switchLayout(!1)}}]).controller("ChangelogModalController",["$scope","$modal",function(e,t){if(e.currentVersion=Config.App.version,!e.lastVersion){var n=e.currentVersion.split(".");e.lastVersion=n[0]+"."+n[1]+"."+Math.max(0,n[2]-1)}e.changelogHidden=!1,e.changelogShown=!1,e.canShowVersion=function(t){if(e.changelogShown)return!0;var n=versionCompare(t,e.lastVersion)>=0;return n||(e.changelogHidden=!0),n},e.showAllVersions=function(){e.changelogShown=!0,e.changelogHidden=!1,e.$emit("ui_height"),e.$broadcast("ui_height")},e.changeUsername=function(){t.open({templateUrl:templateUrl("username_edit_modal"),controller:"UsernameEditModalController",windowClass:"md_simple_modal_window mobile_modal"})}}]).controller("ProfileEditModalController",["$scope","$modalInstance","AppUsersManager","MtpApiManager",function(e,t,n,a){e.profile={},e.error={},a.getUserID().then(function(t){var a=n.getUser(t);e.profile={first_name:a.first_name,last_name:a.last_name}}),e.updateProfile=function(){e.profile.updating=!0;var i=3;a.invokeApi("account.updateProfile",{flags:i,first_name:e.profile.first_name||"",last_name:e.profile.last_name||""}).then(function(a){e.error={},n.saveApiUser(a),t.close()},function(n){switch(n.type){case"FIRSTNAME_INVALID":e.error={field:"first_name"},n.handled=!0;break;case"LASTNAME_INVALID":e.error={field:"last_name"},n.handled=!0;break;case"NAME_NOT_MODIFIED":n.handled=!0,t.close()}})["finally"](function(){delete e.profile.updating})}}]).controller("UsernameEditModalController",["$scope","$modalInstance","AppUsersManager","MtpApiManager",function(e,t,n,a){e.profile={},e.error={},a.getUserID().then(function(t){var a=n.getUser(t);e.profile={username:a.username}}),e.updateUsername=function(){e.profile.updating=!0,a.invokeApi("account.updateUsername",{username:e.profile.username||""}).then(function(a){e.checked={},n.saveApiUser(a),t.close()},function(e){"USERNAME_NOT_MODIFIED"==e.type&&(e.handled=!0,t.close())})["finally"](function(){delete e.profile.updating})},e.$watch("profile.username",function(t){return t&&t.length?void a.invokeApi("account.checkUsername",{username:t||""}).then(function(n){e.profile.username==t&&(n?e.checked={success:!0}:e.checked={error:!0})},function(n){if(e.profile.username==t)switch(n.type){case"USERNAME_INVALID":e.checked={error:!0},n.handled=!0}}):void(e.checked={})})}]).controller("SessionsListModalController",["$scope","$q","$timeout","_","MtpApiManager","ErrorService","$modalInstance",function(e,t,n,a,i,s,o){function r(){n.cancel(l),i.invokeApi("account.getAuthorizations").then(function(t){e.sessionsLoaded=!0,e.authorizations=t.authorizations;for(var a,i=0,s=e.authorizations.length;i=5&&n(function(){a==p&&s.invokeApi("contacts.search",{q:t,limit:10}).then(function(t){o.saveApiUsers(t.users),a==p&&angular.forEach(t.results,function(t){var n=t.user_id;i.indexOf(n)==-1&&e.contacts.push({userID:n,user:o.getUser(n),peerString:o.getUserString(n),found:!0})})},function(e){400==e.code&&(e.handled=!0)})},500)}e.contacts=[],e.foundPeers=[],e.search={},e.slice={limit:20,limitDelta:20};var d,p=0;if(l(),e.disabledContacts={},e.disabled)for(d=0;d0){var t=[];return angular.forEach(e.selectedContacts,function(e,n){t.push(n)}),i.close(t)}},e.deleteSelected=function(){if(e.selectedCount>0){var t=[];angular.forEach(e.selectedContacts,function(e,n){t.push(n)}),o.deleteContacts(t).then(function(){e.toggleEdit(!1)})}},e.importContact=function(){o.openImportContact().then(function(e){e&&t.$broadcast("history_focus",{peerString:o.getUserString(e)})})}}]).controller("PeerSelectController",["$scope","$modalInstance","$q","AppPeersManager","ErrorService",function(e,t,n,a,i){e.selectedPeers={},e.selectedPeerIDs=[],e.selectedCount=0,e.shareLinkPromise&&(e.shareLink={loading:!0},e.shareLinkPromise.then(function(t){e.shareLink={url:t}},function(){delete e.shareLink})),e.dialogSelect=function(s){var o;if(!e.multiSelect){var r;if(e.confirm_type){o=a.getPeerID(s);var l=a.getPeer(o);r=i.confirm({type:e.confirm_type,peer_id:o,peer_data:l})}else r=n.when();return void r.then(function(){t.close(s)})}if(o=a.getPeerID(s),e.selectedPeers[o]){delete e.selectedPeers[o],e.selectedCount--;var c=e.selectedPeerIDs.indexOf(o);c>=0&&e.selectedPeerIDs.splice(c,1)}else e.selectedPeers[o]=a.getPeer(o),e.selectedCount++,e.selectedPeerIDs.unshift(o)},e.submitSelected=function(){if(e.selectedCount>0){var n=[];return angular.forEach(e.selectedPeers,function(e,t){n.push(a.getPeerString(t))}),t.close(n)}},e.toggleSearch=function(){e.$broadcast("dialogs_search_toggle")}}]).controller("ChatCreateModalController",["$scope","$modalInstance","$rootScope","MtpApiManager","AppUsersManager","AppChatsManager","ApiUpdatesManager",function(e,t,n,a,i,s,o){e.group={name:""},e.createGroup=function(){if(e.group.name){e.group.creating=!0;var r=[];return angular.forEach(e.userIDs,function(e){r.push(i.getUserInput(e))}),a.invokeApi("messages.createChat",{title:e.group.name,users:r}).then(function(e){if(o.processUpdateMessage(e),e.updates&&e.updates.length){for(var a,i=0,r=e.updates.length;i5184e5?s=n?"mediumDate":"shortDate":i>432e5&&(s=n?"EEEE":"EEE"),t(a,s)}}]).filter("time",["$filter",function(e){var t={},n=e("date"),a=Config.Mobile?"shortTime":"mediumTime";return function(e){return t[e]?t[e]:t[e]=n(1e3*e,a)}}]).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){e=parseInt(e),isNaN(e)&&(e=0);var t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=e%60,i=(t?t+":":"")+n+":"+a;return i=i.replace(/:(\d(?::|$))/g,":0$1")}}]).filter("durationRemains",["$filter",function(e){var t=e("duration");return function(e,n){return"-"+t(n-e)}}]).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,t){if(!e)return"0";if(e<1024)return e+" b";if(e<1048576)return Math.round(e/1024)+" KB";var n=e/1048576;return n=t?n.toFixed(1):Math.round(10*n)/10,n+" MB"}}]).filter("formatSizeProgress",["$filter","_",function(e,t){var n=e("formatSize");return function(e){if(!e.total)return"";var a=n(e.done,!0),i=a.split(" "),s=n(e.total),o=s.split(" ");return o[1]===i[1]?t("format_size_progress_mulitple",{done:i[0],total:o[0],parts:i[1]}):t("format_size_progress",{done:a,total:s})}}]).filter("formatShortNumber",[function(){return function(e){var t;return e?e<1e3?e.toString():e<9e5?(t=e>1e4?1:10,Math.round(e/1e3*t)/t+"K"):(t=e>1e7?1:10,Math.round(e/1e6*t)/t+"M"):"0"}}]).filter("nl2br",[function(){return function(e){return e.replace(/\n/g,"
")}}]).filter("shortUrl",[function(){return function(e){return"string"!=typeof e?e:e.replace(/^https?:\/\//,"").replace(/^www\./,"")}}]).filter("richText",["$filter",function(e){var t=e("linky");return function(e){return t(e,"_blank").replace(/\n| /g,"
")}}]).filter("relativeTime",["$filter","_",function(e,t){var n=t.pluralize("relative_time_pluralize_minutes_ago"),a=t.pluralize("relative_time_pluralize_hours_ago"),i=e("dateOrTime");return function(e){var s=Math.abs(tsNow(!0)-e);if(s<60)return t("relative_time_just_now");if(s<3600){var o=Math.floor(s/60);return n(o)}if(s<86400){var r=Math.floor(s/3600);return a(r)}return i(e,!0)}}]),angular.module("myApp.services").service("AppMessagesManager",["$q","$rootScope","$location","$filter","$timeout","$sce","ApiUpdatesManager","AppUsersManager","AppChatsManager","AppPeersManager","AppPhotosManager","AppDocsManager","AppStickersManager","AppMessagesIDsManager","DraftsManager","AppWebPagesManager","AppGamesManager","MtpApiManager","MtpApiFileManager","ServerTimeManager","RichTextProcessor","NotificationsManager","Storage","AppProfileManager","TelegramMeWebService","ErrorService","StatusManager","_",function(e,t,n,a,i,s,o,r,l,c,d,p,u,m,g,h,f,_,v,y,b,w,k,$,C,S,M,x){function I(t,n,a){var i=Fe,s=angular.isString(t)&&t.length;if(s){if(!a||je.query!==t){je.query=t;var o=SearchIndexManager.search(t,Le);je.dialogs=[],angular.forEach(Fe.dialogs,function(e){o[e.peerID]&&je.dialogs.push(e)}),je.count=je.dialogs.length}i=je}else je.query=!1;var r=0;if(n>0)for(r=0;ri.dialogs[r].index);r++);return a=a||20,s||Qe||i.dialogs.length>=r+a?e.when({dialogs:i.dialogs.slice(r,r+a)}):T(a).then(function(){if(r=0,n>0)for(r=0;ri.dialogs[r].index);r++);return{dialogs:i.dialogs.slice(r,r+a)}})}function A(e){for(var t=0;th)&&(h=f.date)}var _=g.saveDraft(n,e.draft);_&&_.date>h&&(h=_.date),e.pFlags.pinned&&(h=D()),e.index=P(h),e.peerID=n,F(e,d);var v=r.pFlags.out?"read_outbox_max_id":"read_inbox_max_id";if(r.mid&&r.mid>e[v]&&(r.pFlags.unread=!0),void 0===Pe[n]&&!r.deleted){var y={count:null,history:[s],pending:[]};Pe[n]=y,H(y,r)&&t.$broadcast("history_reply_markup",{peerID:n})}if(w.savePeerSettings(n,e.notify_settings), a&&e.pts&&o.addChannelState(a,e.pts),Config.Modes.packed&&!a&&e.unread_count>0&&Ye&&e.top_message>Ye&&r.pFlags.unread&&!r.pFlags.out){var b=16&r.flags?r.from_id:n;w.getPeerMuted(b).then(function(e){e||Ce(r)})}}function T(e){var n=Fe.dialogs,a=0,s=0,o=0,d=0;return et&&(a=et+y.serverTimeOffset,d=65536*et),_.invokeApi("messages.getDialogs",{offset_date:a,offset_id:m.getMessageLocalID(s),offset_peer:c.getInputPeerByID(o),limit:e},{timeout:300}).then(function(e){a||C.setAuthorized(!0),r.saveApiUsers(e.users),l.saveApiChats(e.chats),te(e.messages);var s=!!a,o=!1;e.dialogs.reverse(),angular.forEach(e.dialogs,function(e){E(e),d&&e.index>d&&(lt[e.peerID]=e,o=!0),s||c.isChannel(c.getPeerID(e.peer))||($e(e.top_message),s=!0)}),e.dialogs.reverse(),(!e.dialogs.length||!e.count||n.length>=e.count)&&(Qe=!0),o&&!rt?rt=i(Me,0):t.$broadcast("dialogs_multiupdate",{})})}function D(){return 2147483392+(255&tt++)}function P(e){return void 0===e&&(e=tsNow(!0)+y.serverTimeOffset),65536*e+(65535&++nt)}function F(e,t){t&&(!et||t=n[0].index)n.unshift(e);else for(i=0;in[i].index){n.splice(i,0,e);break}}function R(t,n,a,i){var s=c.isChannel(t);s&&c.isMegagroup(t);return _.invokeApi("messages.getHistory",{peer:c.getInputPeerByID(t),offset_id:n?m.getMessageLocalID(n):0,add_offset:i||0,limit:a||0},{timeout:300,noErrorBox:!0}).then(function(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),te(e.messages),s&&o.addChannelState(-t,e.pts);var n=e.messages.length;return n&&e.messages[n-1].deleted&&(e.messages.splice(n-1,1),n--,e.count--),t<0||!r.isBot(t)||n==a&&a0)for(o=0;oi.history[o]);o++);var r=i.history.length;i.history.splice(o,i.history.length-o),angular.forEach(s.messages,function(n){H(i,n)&&t.$broadcast("history_reply_markup",{peerID:e}),i.history.push(n.mid)});var l=i.history.length;a-=l-r;var c=at[e],d=it[e],p=void 0!==c||void 0!==d;if(p&&(i.count=Math.max(i.count,l)+1),a>0){if(n=i.history[l-1],p){if(!s.messages.length){if(!d)return i.count=l,!0;n=0,e=d}return N(e,n,a,i)}if(l=0;i--)if(s=Ee[n.history[i]],s&&!s.pFlags.out&&s.pFlags.unread){n.unreadOffset=i+1;break}}return e.when(n)}function U(e,n){if(!at[e]&&!it[n]&&l.hasChat(-n)){var a=l.getChat(-e);a&&a.migrated_to&&a.migrated_to.channel_id==-n&&(at[e]=n,it[n]=e,i(function(){var a=A(e);a.length&&(Fe.dialogs.splice(a[1],1),t.$broadcast("dialog_drop",{peerID:e})),t.$broadcast("dialog_migrate",{migrateFrom:e,migrateTo:n})},100))}}function O(e){if(at[e])return at[e]}function L(e,t,n,a,i){at[e]&&(e=at[e]);var s=Pe[e],o=0,r=!1,l=!1,c=!1;i=i?Math.min(50,i):0,void 0===s&&(s=Pe[e]={count:null,history:[],pending:[]});var d=!1,p=e;if(it[e]&&(d=!0,t&&t1){var g=u.unread_count;(c=g>50)?u.read_inbox_max_id?(t=u.read_inbox_max_id,a=16,l=16,n=4):(n=20,l=16,o=g-l):(n=Math.max(10,i,g+2),l=g)}else Config.Mobile&&(n=20)}if(t>0)for(r=!0,o=0;os.history[o]){r=!1;break}if(!r&&(null!==s.count&&s.history.length==s.count||s.history.length>=o+(n||1))){a?(a=Math.min(o,a),o=Math.max(0,o-a),n+=a):n=n||(o?20:i||5);var h=s.history.slice(o,o+n);return!t&&s.pending.length&&(h=s.pending.slice().concat(h)),B(e,{count:s.count,history:h,unreadOffset:l,unreadSkip:c})}return a||n||(n=i||20),r&&(o=0),a||c||t&&s.history.indexOf(t)==-1?(a&&(o=-a,n+=a),R(p,t,n,o).then(function(n){s.count=n.count||n.messages.length,d&&s.count++;var a=[];return angular.forEach(n.messages,function(e){a.push(e.mid)}),!t&&s.pending.length&&(a=s.pending.slice().concat(a)),B(e,{count:s.count,history:a,unreadOffset:l,unreadSkip:c})})):N(e,t,n,s).then(function(){if(o=0,t>0)for(o=0;os.history[o]);o++);var a=s.history.slice(o,o+n);return!t&&s.pending.length&&(a=s.pending.slice().concat(a)),B(e,{count:s.count,history:a,unreadOffset:l,unreadSkip:c})})}function j(e){return(Pe[e]||{}).reply_markup||!1}function H(e,t){if(!t.reply_markup&&!t.pFlags.out&&!t.action)return!1;if(t.reply_markup&&"replyInlineMarkup"==t.reply_markup._)return!1;var n=t.reply_markup,a=e.reply_markup;if(n)return!(a&&a.mid>=t.mid)&&(!(n.pFlags.selective&&!(16&t.flags))&&(e.maxOutID&&t.mida.mid||t.mid<0)&&t.message)return a.pFlags.hidden=!0,!0}else(!e.maxOutID||t.mid>e.maxOutID)&&(e.maxOutID=t.mid);return!(!t.action||"messageActionChatDeleteUser"!=t.action._||(a?t.action.user_id!=a.fromID:!r.isBot(t.action.user_id)))&&(e.reply_markup={_:"replyKeyboardHide",mid:t.mid,flags:0,pFlags:{}},!0)}function q(t,n,a,i,s){t=t?parseInt(t):0;var o=[],d=!n,p={peer:t,filter:a},u=d&&angular.equals(He,p);if(d&&!u&&(He=p,qe=[]),t&&!i&&!n){var g=Pe[t];if(void 0!==g&&g.history.length){var h,f,v,b={},w=s||20;switch(a._){case"inputMessagesFilterPhotos":b.messageMediaPhoto=!0;break;case"inputMessagesFilterPhotoVideo":b.messageMediaPhoto=!0,b.messageMediaDocument=!0,h="video";break;case"inputMessagesFilterVideo":b.messageMediaDocument=!0,h="video";break;case"inputMessagesFilterDocument":b.messageMediaDocument=!0,h=!1;break;case"inputMessagesFilterVoice":b.messageMediaDocument=!0,h="voice";break;default:return e.when({count:0,history:[]})}for(f=0;f=w)break}}if(o.length=w));f++);}if(o.length||1e3==s)return d&&(qe=listMergeSorted(qe,o)),e.when({count:null,history:o});var $;if(t||!n)$=_.invokeApi("messages.search",{flags:0,peer:c.getInputPeerByID(t),q:n||"",filter:a||{_:"inputMessagesFilterEmpty"},min_date:0,max_date:0,limit:s||20,max_id:m.getMessageLocalID(i)||0},{timeout:300,noErrorBox:!0});else{var C=0,S=0,M=0,x=i&&V(i);x&&x.date&&(C=x.date+y.serverTimeOffset,M=x.id,S=ue(x)),$=_.invokeApi("messages.searchGlobal",{q:n,offset_date:C,offset_peer:c.getInputPeerByID(S),offset_id:m.getMessageLocalID(M),limit:s||20},{timeout:300,noErrorBox:!0})}return $.then(function(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),te(e.messages);var t=e.count||e.messages.length;return o=[],angular.forEach(e.messages,function(e){var t=ue(e);if(t<0){var n=l.getChat(-t);n.migrated_to&&U(t,-n.migrated_to.channel_id)}o.push(e.mid)}),d&&(!i||u&&qe.indexOf(i)>=0)&&(qe=listMergeSorted(qe,o)),{count:t,history:o}},function(t){return 400==t.code&&(t.handled=!0),e.reject(t)})}function V(e){return Ee[e]||{deleted:!0}}function z(e){var t=["messageMediaPhoto","messageMediaDocument","messageMediaWebPage","messageMediaPending"];return!("message"!=e._||e.deleted||e.fwd_from||e.via_bot_id||e.media&&t.indexOf(e.media._)==-1||e.fromID&&r.isBot(e.fromID))&&(!e.media||"messageMediaDocument"!=e.media._||!e.media.document.sticker)}function W(e){if(e<=0||!Ee[e])return!1;var t=Ee[e];if(!t||!t.canBeEdited||t.date0){var r=l.getChat(t);if(!(r.pFlags.creator||r.pFlags.editor&&r.pFlags.megagroup)){var c=[];if((r.pFlags.editor||r.pFlags.megagroup)&&angular.forEach(e,function(e,n){var i=V(a.mids[t][n]);i.pFlags.out&&c.push(e)}),!c.length)return;e=c}s=_.invokeApi("channels.deleteMessages",{channel:l.getChannelInput(t),id:e}).then(function(n){o.processUpdateMessage({_:"updateShort",update:{_:"updateDeleteChannelMessages",channel_id:t,messages:e,pts:n.pts,pts_count:n.pts_count}})})}else{var d=0;n&&(d|=1),s=_.invokeApi("messages.deleteMessages",{flags:d,id:e}).then(function(t){o.processUpdateMessage({_:"updateShort",update:{_:"updateDeleteMessages",messages:e,pts:t.pts,pts_count:t.pts_count}})})}i.push(s)}),e.all(i)}function Z(t){var n=m.getMessageIDInfo(t),a=n[0],i=n[1];if(!i)return e.reject();var s=V(t),o=l.getChat(i);return s&&s.pFlags&&s.pFlags.post&&o.username?_.invokeApi("channels.exportMessageLink",{channel:l.getChannelInput(i),id:a}).then(function(e){return e.link}):e.reject()}function X(e){var n=c.isChannel(e),a=Pe[e],i=A(e)[0];if(!i||!i.unread_count){if(!a||!a.history.length)return!1;var s,r,d=!1;for(u=a.history.length;u>=0;u--)if(s=a.history[u],r=Ee[s],r&&!r.pFlags.out&&r.pFlags.unread){d=!0;break}if(!d)return!1}if(a.readPromise)return a.readPromise;var p;if(p=n?_.invokeApi("channels.readHistory",{channel:l.getChannelInput(-e),max_id:0}):_.invokeApi("messages.readHistory",{peer:c.getInputPeerByID(e),max_id:0}).then(function(e){o.processUpdateMessage({_:"updateShort",update:{_:"updatePts",pts:e.pts,pts_count:e.pts_count}})}),a.readPromise=p.then(function(){i&&(i.unread_count=0,t.$broadcast("dialog_unread",{peerID:e,count:0}),t.$broadcast("messages_read"),a&&a.history.length&&(i.read_inbox_max_id=a.history[0]))})["finally"](function(){delete a.readPromise}),a&&a.history.length){var s,r,u,e,i;for(u=0;u0){var c=e.pFlags.out?"read_outbox_max_id":"read_inbox_max_id";e.pFlags.unread=o>r[c]}else t.isNew&&(e.pFlags.unread=!0);e.reply_to_msg_id&&(e.reply_to_mid=m.getFullMessageID(e.reply_to_msg_id,i)),e.date-=y.serverTimeOffset;var u=e.fwd_from;u&&(e.fwdFromID=u.channel_id?-u.channel_id:u.from_id,u.date-=y.serverTimeOffset),e.peerID=n,e.fromID=e.pFlags.post?n:e.from_id,e.signID=e.pFlags.post&&e.from_id||u&&u.channel_id&&u.from_id,e.via_bot_id>0&&(e.viaBotID=e.via_bot_id);var g={user_id:e.fromID,date:e.date};if(e.media)switch(e.media._){case"messageMediaEmpty":delete e.media;break;case"messageMediaPhoto":d.savePhoto(e.media.photo,g);break;case"messageMediaDocument":p.saveDoc(e.media.document,g);break;case"messageMediaWebPage":h.saveWebPage(e.media.webpage,e.mid,g);break;case"messageMediaGame":f.saveGame(e.media.game,e.mid,g),e.media.handleMessage=!0}if(e.action){var _,v;switch(e.action._){case"messageActionChatEditPhoto":d.savePhoto(e.action.photo,g),s&&(e.action._="messageActionChannelEditPhoto");break;case"messageActionChatEditTitle":s&&(e.action._="messageActionChannelEditTitle");break;case"messageActionChatDeletePhoto":s&&(e.action._="messageActionChannelDeletePhoto");break;case"messageActionChatAddUser":1==e.action.users.length?(e.action.user_id=e.action.users[0],e.fromID==e.action.user_id&&(a?e.action._="messageActionChatJoined":e.action._="messageActionChatReturn")):e.action.users.length>1&&(e.action._="messageActionChatAddUsers");break;case"messageActionChatDeleteUser":e.fromID==e.action.user_id&&(e.action._="messageActionChatLeave");break;case"messageActionChannelMigrateFrom":_=-e.action.chat_id,v=-i;break;case"messageActionChatMigrateTo":_=-i,v=-e.action.channel_id;break;case"messageActionHistoryClear":e.deleted=!0,e.clear_history=!0,e.pFlags.out=!1,e.pFlags.unread=!1;break;case"messageActionPhoneCall":delete e.fromID,e.action.type=(e.pFlags.out?"out_":"in_")+("phoneCallDiscardReasonMissed"==e.action.reason._||"phoneCallDiscardReasonBusy"==e.action.reason._?"missed":"ok")}_&&v&&!at[_]&&!it[v]&&U(_,v)}if(e.message&&e.message.length){var w=b.parseEntities(e.message),k=e.entities||[];e.totalEntities=b.mergeEntities(w,k,!e.pending)}e.canBeEdited=z(e),t.isEdited||(Ee[o]=e)}})}function ne(e,n,a){if(angular.isString(n)){a=a||{};var i=a.entities||[];if(a.viaBotID||(n=b.parseMarkdown(n,i)),n.length){var s,l=de(i),d=Oe--,p=[nextRandomInt(4294967295),nextRandomInt(4294967295)],u=bigint(p[0]).shiftLeft(32).add(bigint(p[1])).toString(),h=Pe[e],f=0,v={},w=a.replyToMsgID,k=c.isChannel(e),$=k&&c.isMegagroup(e),C=!(!k||$);void 0===h&&(h=Pe[e]={count:null,history:[],pending:[]});var S=r.getSelf().id;e!=S&&(f|=2,v.out=!0,k||r.isBot(e)||(f|=1,v.unread=!0)),w&&(f|=8),C?(S=0,v.post=!0):f|=256,s={_:"message",id:d,from_id:S,to_id:c.getOutputPeer(e),flags:f,pFlags:v,date:tsNow(!0)+y.serverTimeOffset,message:n,random_id:u,reply_to_msg_id:w,via_bot_id:a.viaBotID,reply_markup:a.reply_markup,entities:i,views:C&&1,pending:!0};var M=function(e){var n=Te[d];e?(s.error=!0,n&&(n.error=!0)):(delete s.error,n&&delete n.error),t.$broadcast("messages_pending")};s.send=function(){M(!1);var t={};Be[e]&&(t.afterMessageID=Be[e].messageID);var i=0;w&&(i|=1),C&&(i|=16),a.clearDraft&&(i|=128);var r;a.viaBotID?r=_.invokeApi("messages.sendInlineBotResult",{flags:i,peer:c.getInputPeerByID(e),random_id:p,reply_to_msg_id:m.getMessageLocalID(w),query_id:a.queryID,id:a.resultID},t):(l.length&&(i|=8),r=_.invokeApi("messages.sendMessage",{flags:i,peer:c.getInputPeerByID(e),message:n,random_id:p,reply_to_msg_id:m.getMessageLocalID(w),entities:l},t)),r.then(function(e){"updateShortSentMessage"==e._?(s.flags=e.flags,s.date=e.date,s.id=e.id,s.media=e.media,s.entities=e.entities,e={_:"updates",users:[],chats:[],seq:0,updates:[{_:"updateMessageID",random_id:u,id:e.id},{_:k?"updateNewChannelMessage":"updateNewMessage",message:s,pts:e.pts,pts_count:e.pts_count}]}):e.updates&&angular.forEach(e.updates,function(e){"updateDraftMessage"==e._&&(e.local=!0)}),o.processUpdateMessage(e)},function(e){M(!0)})["finally"](function(){Be[e]===t&&delete Be[e]}),Be[e]=t},te([s]),h.pending.unshift(d),t.$broadcast("history_append",{peerID:e,messageID:d,my:!0}),setZeroTimeout(s.send),a.clearDraft&&g.clearDraft(e),Re[u]=[e,d]}}}function ae(n,a,i){i=i||{};var s,l,d=Oe--,p=[nextRandomInt(4294967295),nextRandomInt(4294967295)],u=bigint(p[0]).shiftLeft(32).add(bigint(p[1])).toString(),g=Pe[n],h=0,f={},b=i.replyToMsgID,w=c.isChannel(n),k=w&&c.isMegagroup(n),$=!(!w||k);i.isMedia?["image/jpeg","image/png","image/bmp"].indexOf(a.type)>=0?(s="photo",l="photo."+a.type.split("/")[1]):"audio/"==a.type.substr(0,6)||["video/ogg"].indexOf(a.type)>=0?(s="audio",l="audio."+("ogg"==a.type.split("/")[1]?"ogg":"mp3")):"video/"==a.type.substr(0,6)?(s="video",l="video.mp4"):(s="document",l="document."+a.type.split("/")[1]):(s="document",l="document."+a.type.split("/")[1]),void 0===g&&(g=Pe[n]={count:null,history:[],pending:[]});var C=r.getSelf().id;n!=C&&(h|=2,f.out=!0,w||r.isBot(n)||(h|=1,f.unread=!0)),b&&(h|=8),$?(C=0,f.post=!0):h|=256;var S,M={_:"messageMediaPending",type:s,file_name:a.name||l,size:a.size,progress:{percent:1,total:a.size}},x={_:"message",id:d,from_id:C,to_id:c.getOutputPeer(n),flags:h,pFlags:f,date:tsNow(!0)+y.serverTimeOffset,message:"",media:M,random_id:u,reply_to_msg_id:b,views:$&&1,pending:!0},I=function(e){var n=Te[d];e?(x.error=!0,n&&(n.error=!0)):(delete x.error,n&&delete n.error),t.$broadcast("messages_pending")},A=!1;x.send=function(){var i=e.defer();Ue.then(function(){A&&!x.error||(A=!1,S=v.uploadFile(a)),S.then(function(e){e.name=l,A=!0;var t;switch(s){case"photo":t={_:"inputMediaUploadedPhoto",flags:0,file:e};break;case"document":default:t={_:"inputMediaUploadedDocument",file:e,mime_type:a.type,caption:"",attributes:[{_:"documentAttributeFilename",file_name:a.name}]}}var i=0;b&&(i|=1),$&&(i|=16),_.invokeApi("messages.sendMedia",{flags:i,peer:c.getInputPeerByID(n),media:t,random_id:p,reply_to_msg_id:m.getMessageLocalID(b)}).then(function(e){o.processUpdateMessage(e)},function(e){return"photo"!=s||400!=e.code||"PHOTO_INVALID_DIMENSIONS"!=e.type&&"PHOTO_SAVE_FILE_INVALID"!=e.type?void I(!0):(e.handled=!0,s="document",void x.send())})},function(e){I(!0)},function(e){M.progress.done=e.done,M.progress.percent=Math.max(1,Math.floor(100*e.done/e.total)),t.$broadcast("history_update",{peerID:n})}),M.progress.cancel=function(){A||(i.resolve(),S.cancel(),le(u))},S["finally"](function(){i.resolve()})}),Ue=i.promise},te([x]),g.pending.unshift(d),t.$broadcast("history_append",{peerID:n,messageID:d,my:!0}),setZeroTimeout(x.send),Re[u]=[n,d]}function ie(e,n,a){a=a||{};var i=Oe--,s=[nextRandomInt(4294967295),nextRandomInt(4294967295)],l=bigint(s[0]).shiftLeft(32).add(bigint(s[1])).toString(),h=Pe[e],f=a.replyToMsgID,v=c.isChannel(e),b=v&&c.isMegagroup(e),w=!(!v||b);void 0===h&&(h=Pe[e]={count:null,history:[],pending:[]});var k,$=r.getSelf().id;switch(n._){case"inputMediaPhoto":k={_:"messageMediaPhoto",photo:d.getPhoto(n.id.id),caption:n.caption||""};break;case"inputMediaDocument":var C=p.getDoc(n.id.id);C.sticker&&C.stickerSetInput&&u.pushPopularSticker(C.id),k={_:"messageMediaDocument",document:C,caption:n.caption||""};break;case"inputMediaContact":k={_:"messageMediaContact",phone_number:n.phone_number,first_name:n.first_name,last_name:n.last_name,user_id:0};break;case"inputMediaGeoPoint":k={_:"messageMediaGeo",geo:{_:"geoPoint",lat:n.geo_point.lat,"long":n.geo_point["long"]}};break;case"inputMediaVenue":k={_:"messageMediaVenue",geo:{_:"geoPoint",lat:n.geo_point.lat,"long":n.geo_point["long"]},title:n.title,address:n.address,provider:n.provider,venue_id:n.venue_id};break;case"messageMediaPending":k=n}var S=0,M={};e!=$&&(S|=2,M.out=!0,r.isBot(e)||(S|=1,M.unread=!0)),f&&(S|=8),w?($=0,M.post=!0):S|=256;var x={_:"message",id:i,from_id:$,to_id:c.getOutputPeer(e),flags:S,pFlags:M,date:tsNow(!0)+y.serverTimeOffset,message:"",media:k,random_id:l,reply_to_msg_id:f,via_bot_id:a.viaBotID,reply_markup:a.reply_markup,views:w&&1,pending:!0},I=function(e){var n=Te[i];e?(x.error=!0,n&&(n.error=!0)):(delete x.error,n&&delete n.error),t.$broadcast("messages_pending")};x.send=function(){var t=0;f&&(t|=1),w&&(t|=16),a.clearDraft&&(t|=128);var i={};Be[e]&&(i.afterMessageID=Be[e].messageID);var r;r=a.viaBotID?_.invokeApi("messages.sendInlineBotResult",{flags:t,peer:c.getInputPeerByID(e),random_id:s,reply_to_msg_id:m.getMessageLocalID(f),query_id:a.queryID,id:a.resultID},i):_.invokeApi("messages.sendMedia",{flags:t,peer:c.getInputPeerByID(e),media:n,random_id:s,reply_to_msg_id:m.getMessageLocalID(f)},i),r.then(function(e){e.updates&&angular.forEach(e.updates,function(e){"updateDraftMessage"==e._&&(e.local=!0)}),o.processUpdateMessage(e)},function(e){I(!0)})["finally"](function(){Be[e]===i&&delete Be[e]}),Be[e]=i},te([x]),h.pending.unshift(i),t.$broadcast("history_append",{peerID:e,messageID:i,my:!0}),setZeroTimeout(x.send),a.clearDraft&&g.clearDraft(e),Re[l]=[e,i]}function se(t,n,a){n=n.sort(),a=a||{};var i=0,s=c.isChannel(t),r=s&&c.isMegagroup(t),l=!(!s||r);l&&(i|=16),a.withMyScore&&(i|=256);var d=m.splitMessageIDsByChannels(n),p=[];return angular.forEach(d.msgIDs,function(e,n){for(var a=e.length,s=[],r=0;r0&&a<=4)||e.pFlags&&e.pFlags.resize||(e.splitCount=a),e.wrapped=!0,angular.forEach(e.rows,function(e){angular.forEach(e.buttons,function(e){if(e.rText=b.wrapRichText(e.text,{noLinks:!0,noLinebreaks:!0}),"keyboardButtonUrl"==e._){var n=r.getUser(t),a=!(n&&n.pFlags&&n.pFlags.verified);e.pUrl=b.wrapUrl(e.url,a)}})}),e}function ve(e){var t=V(e),n=t.from_id&&r.getUser(t.from_id),a=n&&n.pFlags.bot&&n.username||!1,i=c.getPeerID(t.to_id),s=a||c.isBot(i)||c.isAnyGroup(i),o={noCommands:!s,fromBot:a,entities:t.totalEntities};if(t.pFlags.mentioned){var l=r.getSelf();l&&(o.highlightUsername=l.username)}return b.wrapRichText(t.message,o)}function ye(){if(ze!==!1&&(clearTimeout(ze),ze=!1),Ve.length){var e=Ve.slice();Ve=[];var n=m.splitMessageIDsByChannels(e);angular.forEach(n.msgIDs,function(e,a){var i;i=a>0?_.invokeApi("channels.getMessages",{channel:l.getChannelInput(a),id:e}):_.invokeApi("messages.getMessages",{id:e}),i.then(function(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),te(e.messages),t.$broadcast("messages_downloaded",n.mids[a])})})}}function be(){if(Ke!==!1&&(clearTimeout(Ke),Ke=!1),Ge.length){var e=Ge.slice();Ge=[];var t=m.splitMessageIDsByChannels(e);angular.forEach(t.msgIDs,function(e,n){_.invokeApi("messages.getMessagesViews",{peer:c.getInputPeerByID(-n),id:e,increment:!0}).then(function(e){if(n){for(var a=t.mids[n],i=[],s=0;s0?p=Math.min(t,d):t<0&&(c=Math.max(0,p+t)),n=c;nYe))&&(k.set({max_seen_msg:e}),void _.invokeApi("messages.receivedMessages",{max_id:e}))}function Ce(e,n){n=n||{};var a,i,s=ue(e),o={},c=!1,d=w.getNotifySettings();if(e.fwdFromID&&n.fwd_count)c=Xe(n.fwd_count);else if(e.message)c=d.nopreview?x("conversation_message_sent"):b.wrapPlainText(e.message);else if(e.media){var p=!1;switch(e.media._){case"messageMediaPhoto":c=x("conversation_media_photo_raw"),p="🖼";break;case"messageMediaDocument":switch(e.media.document.type){case"gif":c=x("conversation_media_gif_raw"),p="🎬";break;case"sticker":c=x("conversation_media_sticker");var u=e.media.document.stickerEmojiRaw;void 0!==u&&(c=b.wrapPlainText(u)+" "+c);break;case"video":c=x("conversation_media_video_raw"),p="📹";break;case"voice":case"audio":c=x("conversation_media_audio_raw");break;default:e.media.document.file_name?c=b.wrapPlainText("📎 "+e.media.document.file_name):(c=x("conversation_media_document_raw"),p="📎")}break;case"messageMediaGeo":case"messageMediaVenue":c=x("conversation_media_location_raw"),p="📍";break;case"messageMediaContact":c=x("conversation_media_contact_raw");break;case"messageMediaGame":c=b.wrapPlainText("🎮 "+e.media.game.title);break;default:c=x("conversation_media_attachment_raw")}p!==!1&&e.media.caption&&(c=b.wrapPlainText(p+" "+e.media.caption))}else if("messageService"==e._)switch(e.action._){case"messageActionChatCreate":c=x("conversation_group_created_raw");break;case"messageActionChatEditTitle":c=x("conversation_group_renamed_raw");break;case"messageActionChatEditPhoto":c=x("conversation_group_photo_updated_raw");break;case"messageActionChatDeletePhoto":c=x("conversation_group_photo_removed_raw");break;case"messageActionChatAddUser":case"messageActionChatAddUsers":c=x("conversation_invited_user_message_raw"); -break;case"messageActionChatReturn":c=x("conversation_returned_to_group_raw");break;case"messageActionChatJoined":c=x("conversation_joined_group_raw");break;case"messageActionChatDeleteUser":c=x("conversation_kicked_user_message_raw");break;case"messageActionChatLeave":c=x("conversation_left_group_raw");break;case"messageActionChatJoinedByLink":c=x("conversation_joined_by_link_raw");break;case"messageActionChannelCreate":c=x("conversation_created_channel_raw");break;case"messageActionChannelEditTitle":c=x("conversation_changed_channel_name_raw");break;case"messageActionChannelEditPhoto":c=x("conversation_changed_channel_photo_raw");break;case"messageActionChannelDeletePhoto":c=x("conversation_removed_channel_photo_raw");break;case"messageActionPinMessage":c=x("conversation_pinned_message_raw");break;case"messageActionGameScore":c=Je(e.action.score);break;case"messageActionPhoneCall":switch(e.action.type){case"out_missed":c=x("message_service_phonecall_canceled_raw");break;case"in_missed":c=x("message_service_phonecall_missed_raw");break;case"out_ok":c=x("message_service_phonecall_outgoing_raw");break;case"in_ok":c=x("message_service_phonecall_incoming_raw")}}if(s>0){var m=r.getUser(e.from_id),g=r.getUserPhoto(e.from_id);o.title=(m.first_name||"")+(m.first_name&&m.last_name?" ":"")+(m.last_name||""),o.title||(o.title=m.phone||x("conversation_unknown_user_raw")),i=g,a=r.getUserString(s)}else{if(o.title=l.getChat(-s).title||x("conversation_unknown_chat_raw"),e.from_id>0){var m=r.getUser(e.from_id);o.title=(m.first_name||m.last_name||x("conversation_unknown_user_raw"))+" @ "+o.title}i=l.getChatPhoto(-s),a=l.getChatString(-s)}o.title=b.wrapPlainText(o.title),o.onclick=function(){t.$broadcast("history_focus",{peerString:a,messageID:16&e.flags?e.mid:0})},o.message=c,o.key="msg"+e.mid,o.tag=a,o.silent=e.pFlags.silent||!1,i.location&&!i.location.empty?v.downloadSmallFile(i.location,i.size).then(function(t){e.pFlags.unread&&(o.image=t,w.notify(o))}):w.notify(o)}function Se(){i.cancel(st),st=!1,t.$broadcast("history_multiappend",ot),ot={}}function Me(){i.cancel(rt),rt=!1;var e=0;angular.forEach(lt,function(t,n){t.reload?(Ie(n),delete lt[n]):(F(t),c.isChannel(n)||(e=Math.max(e,t.top_message||0)))}),e!==!1&&$e(e),t.$broadcast("dialogs_multiupdate",lt),lt={}}function xe(){i.cancel(ct),ct=!1;var e=t.idle.isIDLE&&M.isOtherDeviceActive()?3e4:1e3;angular.forEach(dt,function(t){t.isMutedPromise.then(function(n){var a=t.top_message;!n&&a.pFlags.unread&&setTimeout(function(){a.pFlags.unread&&Ce(a,{fwd_count:t.fwd_count})},e)})}),dt={}}function Ie(e){return _.invokeApi("messages.getPeerDialogs",{peers:[c.getInputPeerByID(e)]}).then(Ae)}function Ae(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),te(e.messages);var n={},a=!1;angular.forEach(e.dialogs,function(e){if(e.top_message){var i=A(e.peerID).length>0;E(e),i?t.$broadcast("dialog_top",e):(n[e.peerID]=e,a=!0)}else{var s=c.getPeerID(e.peer),o=A(s);o.length&&(Fe.dialogs.splice(o[1],1),t.$broadcast("dialog_drop",{peerID:s}))}}),a&&t.$broadcast("dialogs_multiupdate",n)}var Ee={},Te={},De={},Pe={},Fe={count:null,dialogs:[]},Re={},Ne={},Be={},Ue=e.when(),Oe=-1,Le=SearchIndexManager.createIndex(),je={query:!1},He={},qe=[],Ve=[],ze=!1,We={},Ge=[],Ke=!1,Ye=!1;k.get("max_seen_msg").then(function(e){e&&!m.getMessageIDInfo(e)[1]&&(Ye=e)});var Ze=a("dateOrTime"),Xe=x.pluralize("conversation_forwarded_X_messages"),Je=x.pluralize("conversation_scored_X");w.start();var Qe=!1,et=0,tt=0,nt=0,at={},it={},st=!1,ot={},rt=!1,lt={},ct=!1,dt={};return t.$on("apiUpdate",function(e,n){switch(n._){case"updateMessageID":var a=n.random_id,s=Re[a];if(s){var o=s[0],d=c.isChannel(o)?-o:0;Ne[m.getFullMessageID(n.id,d)]=a}break;case"updateNewMessage":case"updateNewChannelMessage":var p=n.message,o=ue(p),u=Pe[o],g=A(o);if(!g.length){lt[o]={reload:!0},rt||(rt=i(Me,0));break}if("updateNewChannelMessage"==n._){var h=l.getChat(-o);if(h.pFlags&&(h.pFlags.left||h.pFlags.kicked))break}if(te([p],{isNew:!0}),void 0!==u){var f=u.history;if(f.indexOf(p.mid)!=-1)return!1;var v=f[0];f.unshift(p.mid),p.mid>0&&p.mid0&&N&&r.forceUserOnline(o),R=0;RB)&&(p=Ee[F],p.pFlags.out==N)){if(!p.pFlags.unread)break;p&&p.pFlags.unread&&(p.pFlags.unread=!1,Te[F]&&(Te[F].pFlags.unread=!1,L||(L=!0)),De[F]&&(De[F].pFlags.unread=!1),p.pFlags.out||(g[0]&&(U=--g[0].unread_count),w.cancel("msg"+F)))}if(g[0]){!N&&U&&g[0].top_message<=B&&(U=g[0].unread_count=0);var j=N?"read_outbox_max_id":"read_inbox_max_id";g[0][j]=B}U!==!1&&t.$broadcast("dialog_unread",{peerID:o,count:U}),L&&t.$broadcast("messages_read");break;case"updateReadMessagesContents":var R,F,p,q,z=n.messages,W=z.length;for(R=0;R0&&(a.count-=e.count,a.count<0&&(a.count=0));for(var o=0;o0,Q="channel"==Z._&&(Z.username||!Z.pFlags.left&&!Z.pFlags.kicked)&&!0||!1,ee=void 0!==Pe[o];Q!=ee&&(delete Pe[o],t.$broadcast("history_forbidden",o)),J!=X&&(X?Ie(-d):g[0]&&(Fe.dialogs.splice(g[1],1),t.$broadcast("dialog_drop",{peerID:o})));break;case"updateChannelReload":var d=n.channel_id,o=-d,g=A(o);g[0]&&Fe.dialogs.splice(g[1],1),delete Pe[o],Ie(-d).then(function(){t.$broadcast("history_reload",o)});break;case"updateChannelMessageViews":var ne=n.views,M=m.getFullMessageID(n.id,n.channel_id),p=V(M);p&&p.views&&p.viewso)&&(o=d.date)}}s.pFlags.pinned||(s.index=P(o)),F(s),t.$broadcast("dialog_draft",{peerID:a,draft:i,index:s.index})}}),{getConversations:I,getHistory:L,getSearch:q,getMessage:V,getReplyKeyboard:j,readHistory:X,readMessages:J,flushHistory:ee,deleteMessages:Y,sendText:ne,sendFile:ae,sendOther:ie,forwardMessages:se,startBot:oe,shareGame:re,editMessage:pe,convertMigratedPeer:O,getMessagePeer:ue,getMessageThumb:ke,getMessageShareLink:Z,canMessageBeEdited:z,canEditMessage:W,getMessageEditData:G,canRevokeMessage:K,clearDialogCache:he,wrapForDialog:me,wrapForHistory:fe,wrapReplyMarkup:_e,wrapSingleMessage:ge,wrapMessageText:ve,regroupWrappedHistory:we}}]).service("AppMessagesIDsManager",function(){function e(e,t){if(!t||e<=0)return e;e=n(e);var a=i[t];return a||(a=++o*r,s[a]=t,i[t]=a),a+e}function t(e){if(e\n\t\n\t \n\t\n\t
\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t
\n\t
\n \n \n\t
\n\t
\n\t\t
\n\t\t \n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t
\n\t \t
\n\t
\n\t
\n\t\n'),e.put("partials/mobile/changelog_modal.html",'
\n\n \n\n \n\n
\n'), -e.put("partials/mobile/channel_modal.html",'
\n\n
\n \n
\n\n \n\n
\n'),e.put("partials/mobile/chat_create_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/chat_edit_modal.html",'
\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'),e.put("partials/mobile/country_select_modal.html",'
\n\n
\n \n
\n\n \n\n
\n'),e.put("partials/mobile/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
\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/mobile/edit_contact_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/full_gif.html",'\n\n
\n\n
\n
\n \n \n \n \n
\n
\n
GIF
\n
\n\n
\n \n \n
\n \n\n
\n\n
'),e.put("partials/mobile/full_photo.html",'
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n \n \n
\n
\n
\n
\n
\n
'),e.put("partials/mobile/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/mobile/game_modal.html",'
\n\n
\n \n
\n\n \n\n
\n'),e.put("partials/mobile/head.html",'
\n \n
\n'), -e.put("partials/mobile/im.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
\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
\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
\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/mobile/import_contact_modal.html",'
\n\n
\n \n
\n\n \n
'),e.put("partials/mobile/login.html",'
\n \n
\n\n\n\n\n'),e.put("partials/mobile/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\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/mobile/message_actions_modal.html",'
\n\n
\n \n \n \n \n \n \n
\n\n
\n'),e.put("partials/mobile/message_attach_contact.html",'
\n \n
\n \n \n
\n
\n
'),e.put("partials/mobile/message_attach_document.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
\n
\n
\n
\n
\n
\n
\n\n
\n
\n
\n'), -e.put("partials/mobile/message_attach_geo.html",'\n \n'),e.put("partials/mobile/message_attach_pending.html",'
\n
\n \n
\n
\n
\n \n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n'),e.put("partials/mobile/message_attach_photo.html",'\n \n\n
'),e.put("partials/mobile/message_attach_venue.html",'
\n\n \n \n \n\n
\n
\n \n
\n
\n
\n\n
\n'),e.put("partials/mobile/message_attach_webpage.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'),e.put("partials/mobile/message_service.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 \n \n\n \n \n \n \n \n \n \n\n \n \n \n\n'),e.put("partials/mobile/password_recovery_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/password_update_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
\n'),e.put("partials/mobile/phonebook_modal.html",'
\n\n
\n \n
\n\n \n\n \n\n
\n'),e.put("partials/mobile/photo_modal.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'),e.put("partials/mobile/profile_edit_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/sessions_list_modal.html",'
\n\n
\n \n
\n\n \n\n
\n'),e.put("partials/mobile/settings_modal.html",'
\n\n
\n \n
\n\n \n
\n'), -e.put("partials/mobile/stickerset_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/user_modal.html",'
\n\n
\n \n
\n\n \n\n
\n'),e.put("partials/mobile/username_edit_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/video_modal.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'),e.put("partials/desktop/audio_player.html",'
\n\t\n\t \n\t\n\t
\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t\t[ \n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t]\n\t\t\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t
\n\t
\n \n \n\t
\n\t
\n\t\t
\n\t\t \n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t
\n\t \t
\n\t \t
\n\t
\n\t
\n\t\n
'),e.put("partials/desktop/changelog_modal.html",'
\n\n
\n
\n
\n \n
\n
\n
\n\n
\n
\n \n
\n
\n
Telegram Web
\n
Version {{currentVersion}}
\n
\n
\n
\n\n
\n
\n \n \n \n
\n
\n\n
\n\n
\n\n
\n
0.5.6
\n
\n
    \n
  • Unsend Messages: retract any messages within 48 hours of sending them. Check out the Telegram Blog for more info.
  • \n
  • Stickers suggestions by emoji.
  • \n
  • Search for messages in specific chats.
  • \n
  • Edit the text of your messages after sending them. This works across all Telegram chats, including groups and one-on-one conversations. Select a message and click \'Edit\' or just press the up arrow button to edit your last message.
  • \n
  • Pinned chats. Check out the Telegram Blog for more info.
  • \n
  • Background notifications in Chrome and Firefox (can be disabled in Settings)
  • \n
\n\n
\n
\n\n
\n
0.5.5
\n
\n
    \n
  • Introducing Drafts: Seamless syncing for unsent messages on all your devices. Drafts are now visible in your chats list.
  • \n
  • Mention people in groups by typing @ and selecting them from the list — even if they don\'t have a username.
  • \n
  • Share links to specific posts in channels via quick forwarding menu (click on the date in a message to try this out).
  • \n
\n\n
\n
\n\n
\n
0.5.4
\n
\n
    \n
  • Introducing Bot API 2.0, the biggest update to our bot platform since June 2015.
  • \n
  • New inline keyboards with callback, \'open URL\' or \'switch to inline mode\' buttons help create seamless interfaces.
  • \n
  • Bots can now update existing messages on the fly as you interact with them.
  • \n
  • Prepare for the rise of location-based bots: all bots can now ask users to share their location.
  • \n
  • Inline bots can now send all attachments supported in Telegram (videos, music, stickers, files, etc.).
  • \n
  • Try out these sample bots to see what\'s coming your way soon: @music, @sticker, @youtube, @foursquare
  • \n
  • Check out the Telegram Blog for more info.
  • \n
  • New quick forwarding in channels (click on the date in a message to try this out).
  • \n
  • Improved performance.
  • \n
\n\n
\n
\n\n
\n
0.5.3
\n
\n
    \n
  • Inline bots: A new way to add bot content to any chat. Type a bot\'s username and your query in the text field to get instant results and send them to your chat partner. Try typing @gif dog in your next chat. Sample bots: @gif, @wiki, @bing, @vid, @bold.
  • \n
  • Check out the Telegram Blog for more info.
  • \n
  • Improved GIFs: 20x faster sending and downloading, nice animated progress
  • \n
  • Click on message date to reply (or to forward from channels).
  • \n
  • Preview images before sending when pasting from clipboard.
  • \n
  • Improved formatting for copy-pasted history fragments (date, time and sender names inserted automatically).
  • \n
\n
\n
\n\n
\n
0.5.2
\n
\n
    \n
  • Unread counters for muted chats now colored in gray.
  • \n
  • Improved previews for sticker sets: Click on a sticker to view the whole set, click on stickers in a set to send right away, added a \'Share\' button.
  • \n
  • Improved performance.
  • \n
\n
\n
\n\n
\n
0.5.1
\n
\n
    \n
  • Groups that have reached their capacity of 200 users can be upgraded to supergroups of up to 1,000 members.
  • \n
  • Check out the Telegram Blog for more info
  • \n
\n
\n
\n\n
\n
0.5.0
\n
\n
    \n
  • Removed annoying "multiple tabs open" error.
  • \n
  • Improved message forwarding.
  • \n
  • Added view counter to messages from channels.
  • \n
  • Improved image loading in Safari and Firefox.
  • \n
\n
\n
\n\n
\n
0.4.9
\n
\n
    \n
  • New emoji and sticker menu, tabs for sticker packs.
  • \n
\n
\n
\n\n
\n
0.4.8
\n
\n
    \n
  • Introducing Channels – a great new way to broadcast your messages to unlimited audiences.
  • \n
  • Check out the Telegram Blog for more info
  • \n
  • Improved performance in Safari on OS X El Capitan.
  • \n
  • Added formatting for fixed-width code, surround text with `single backticks` for inline text and ```triple backticks``` for blocks of pre-formatted text.
  • \n
\n
\n
\n\n
\n
0.4.7
\n
\n
    \n
  • New bot API, free for everyone. If you\'re an engineer, create your own bots for games, services or integrations.\n
  • \n
  • Check out Telegram Blog for more info
  • \n
  • Improved Stickers support: now stickers are loading much faster.
  • \n
  • Click on any custom stickers in chats to view and add sticker sets.
  • \n
  • [Mobile] Reply to a message easily: tap on any message and select "Reply".
  • \n
\n
\n
\n\n
\n
0.4.6
\n
\n \n
\n
\n\n
\n
0.4.5
\n
\n
    \n
  • \n Invite links for group chats:
    \n Check out Telegram Blog for more info\n
  • \n
  • Smart notifications
  • \n
  • \'Listened\' status for voice messages
  • \n
  • Places in locations (venues, landmarks)
  • \n
\n
\n
\n\n
\n
0.4.4
\n
\n
    \n
  • Link Previews:
    \n Get rich link summaries for tweets, YouTube videos, Instagram photos and other content.
  • \n\n
  • Check out Telegram Blog for more info.
  • \n
\n
\n
\n\n
\n
0.4.3
\n
\n
    \n
  • Sessions List:
    \n View your active Telegram sessions (on desktop, tablet and mobile devices) and close specific sessions remotely.
  • \n\n
  • Two-step verification:
    \n Set up an additional password that will be required to log into your Telegram account.
  • \n\n
  • Check out Telegram Blog for more info.
  • \n
\n
\n
\n\n
\n
0.4.2
\n
\n
    \n
  • Optimization for screens with smaller Y-resolutions.
  • \n
  • Supported Spotify URL embeds.
  • \n
  • Mentions of the current user in group chats are now highlighted.
  • \n
\n
\n
\n\n
\n
0.4.1
\n
\n
    \n
  • Reply to specific messages in groups.
  • \n
  • Mention @usernames in groups to notify multiple users.
  • \n
  • Revised notifications in groups: mentioned users and people you reply to will be notified (private chat notification settings apply in this case instead of group settings). Check out Telegram Blog for more info.
  • \n
  • Setting to disable message preview
  • \n
\n
\n
\n\n
\n
0.4.0
\n
\n
    \n
  • Full stickers support
  • \n
  • Multisearch box: instantly find chats, usernames and messages
  • \n
  • Emoji autocomplete: e.g., type :kiss in the message field to see the list. Full cheat sheet »
  • \n
  • Added \'typing\' notification in chats list
  • \n
  • Online members counter in group headers
  • \n
\n
\n
\n\n
\n
0.3.9
\n
\n
    \n
  • [Desktop] Material design completed
  • \n
\n
\n
\n\n
\n
0.3.8
\n
\n
    \n
  • Telegram.me links open right in Telegram Web when authorized
  • \n
  • @username mentions in messages are clickable and open a conversation with the user
  • \n
\n
\n
\n\n
\n
0.3.7
\n
\n
    \n
  • [Desktop] New material design for modal windows
  • \n
  • [Desktop] Forward messages to multiple recipients
  • \n
\n
\n
\n\n
\n
0.3.6
\n
\n
    \n
  • New viewer for photos, videos, documents.
  • \n
  • [FirefoxOS] Improved media downloads.
  • \n
\n
\n
\n\n
\n
0.3.5
\n
\n
    \n
  • Added embedded Soundcloud tracks and playlists.
  • \n
  • Added global user search to contacts list.
  • \n
  • Added switch to mobile version on window resize.
  • \n
  • Migrate to HTTPS notification
  • \n
  • Bugfixes.
  • \n
\n
\n
\n\n
\n
0.3.4
\n
\n
    \n
  • Added embedded Facebook posts and Vimeo videos.
  • \n
  • Improved IE10+ support: downloading files and style fixes.
  • \n
  • Added unsupported media playback warning.
  • \n
  • Bugfixes.
  • \n
\n
\n
\n\n
\n
0.3.3
\n
\n
    \n
  • Added Native Client module: dramatically improved encryption speed; Download and upload speed is now as high as in native applications.
  • \n
  • HTTPS. We recommend you to use https://web.telegram.org.
  • \n
  • Added multiple open tabs warning. Please note, that only one tab with Telegram Web will work.
  • \n
  • Added embedded Instagram, Twitter, Vine, YouTube links.
  • \n
  • Jump to selected spot when playing back audio.
  • \n
  • Bugfixes
  • \n
\n
\n
\n\n
\n
0.3.2
\n
\n
    \n
  • Usernames support: Choose a username right now!
  • \n
  • Search can now find public users by username.
  • \n
  • Most popular emoticons shown in \'recent\' when empty
  • \n
  • [ChromeApp] Added saving window position and size
  • \n
  • Bugfixes
  • \n
\n
\n
\n\n
\n
0.3.1
\n
\n
    \n
  • New languages: Spanish, German and Italian are now available
  • \n
  • New custom-made audio player
  • \n
  • Bad browser page for IE 6-9
  • \n
  • Perfomance improvements and bugfixes
  • \n
\n
\n
\n\n
\n
0.3.0
\n
\n
    \n
  • Log in codes may be received in other Telegram apps
  • \n
  • Partner\'s online status updates automatically
  • \n
  • Added support for non-english hashtags in messages
  • \n
  • Fixed invalid scrollbar width bug
  • \n
  • [Desktop] Added automatic country code detection
  • \n
  • [FirefoxOS] Improved PUSH-notifications for <= 1.1
  • \n
  • [FirefoxOS] Fixed emoji in notifications
  • \n
  • [FirefoxOS] Fixed attachment bug for <= 1.1
  • \n
  • [FirefoxOS] Added phonebook permissions handling
  • \n
  • [FirefoxOS] Added ability to share Gallery photos in Telegram
  • \n
\n
\n
\n\n
\n\n\n \n\n
\n\n
'), +break;case"messageActionChatReturn":c=x("conversation_returned_to_group_raw");break;case"messageActionChatJoined":c=x("conversation_joined_group_raw");break;case"messageActionChatDeleteUser":c=x("conversation_kicked_user_message_raw");break;case"messageActionChatLeave":c=x("conversation_left_group_raw");break;case"messageActionChatJoinedByLink":c=x("conversation_joined_by_link_raw");break;case"messageActionChannelCreate":c=x("conversation_created_channel_raw");break;case"messageActionChannelEditTitle":c=x("conversation_changed_channel_name_raw");break;case"messageActionChannelEditPhoto":c=x("conversation_changed_channel_photo_raw");break;case"messageActionChannelDeletePhoto":c=x("conversation_removed_channel_photo_raw");break;case"messageActionPinMessage":c=x("conversation_pinned_message_raw");break;case"messageActionGameScore":c=Je(e.action.score);break;case"messageActionPhoneCall":switch(e.action.type){case"out_missed":c=x("message_service_phonecall_canceled_raw");break;case"in_missed":c=x("message_service_phonecall_missed_raw");break;case"out_ok":c=x("message_service_phonecall_outgoing_raw");break;case"in_ok":c=x("message_service_phonecall_incoming_raw")}}if(s>0){var m=r.getUser(e.from_id),g=r.getUserPhoto(e.from_id);o.title=(m.first_name||"")+(m.first_name&&m.last_name?" ":"")+(m.last_name||""),o.title||(o.title=m.phone||x("conversation_unknown_user_raw")),i=g,a=r.getUserString(s)}else{if(o.title=l.getChat(-s).title||x("conversation_unknown_chat_raw"),e.from_id>0){var m=r.getUser(e.from_id);o.title=(m.first_name||m.last_name||x("conversation_unknown_user_raw"))+" @ "+o.title}i=l.getChatPhoto(-s),a=l.getChatString(-s)}o.title=b.wrapPlainText(o.title),o.onclick=function(){t.$broadcast("history_focus",{peerString:a,messageID:16&e.flags?e.mid:0})},o.message=c,o.key="msg"+e.mid,o.tag=a,o.silent=e.pFlags.silent||!1,i.location&&!i.location.empty?v.downloadSmallFile(i.location,i.size).then(function(t){e.pFlags.unread&&(o.image=t,w.notify(o))}):w.notify(o)}function Se(){i.cancel(st),st=!1,t.$broadcast("history_multiappend",ot),ot={}}function Me(){i.cancel(rt),rt=!1;var e=0;angular.forEach(lt,function(t,n){t.reload?(Ie(n),delete lt[n]):(F(t),c.isChannel(n)||(e=Math.max(e,t.top_message||0)))}),e!==!1&&$e(e),t.$broadcast("dialogs_multiupdate",lt),lt={}}function xe(){i.cancel(ct),ct=!1;var e=t.idle.isIDLE&&M.isOtherDeviceActive()?3e4:1e3;angular.forEach(dt,function(t){t.isMutedPromise.then(function(n){var a=t.top_message;!n&&a.pFlags.unread&&setTimeout(function(){a.pFlags.unread&&Ce(a,{fwd_count:t.fwd_count})},e)})}),dt={}}function Ie(e){return _.invokeApi("messages.getPeerDialogs",{peers:[c.getInputPeerByID(e)]}).then(Ae)}function Ae(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),te(e.messages);var n={},a=!1;angular.forEach(e.dialogs,function(e){if(e.top_message){var i=A(e.peerID).length>0;E(e),i?t.$broadcast("dialog_top",e):(n[e.peerID]=e,a=!0)}else{var s=c.getPeerID(e.peer),o=A(s);o.length&&(Fe.dialogs.splice(o[1],1),t.$broadcast("dialog_drop",{peerID:s}))}}),a&&t.$broadcast("dialogs_multiupdate",n)}var Ee={},Te={},De={},Pe={},Fe={count:null,dialogs:[]},Re={},Ne={},Be={},Ue=e.when(),Oe=-1,Le=SearchIndexManager.createIndex(),je={query:!1},He={},qe=[],Ve=[],ze=!1,We={},Ge=[],Ke=!1,Ye=!1;k.get("max_seen_msg").then(function(e){e&&!m.getMessageIDInfo(e)[1]&&(Ye=e)});var Ze=a("dateOrTime"),Xe=x.pluralize("conversation_forwarded_X_messages"),Je=x.pluralize("conversation_scored_X");w.start();var Qe=!1,et=0,tt=0,nt=0,at={},it={},st=!1,ot={},rt=!1,lt={},ct=!1,dt={};return t.$on("apiUpdate",function(e,n){switch(n._){case"updateMessageID":var a=n.random_id,s=Re[a];if(s){var o=s[0],d=c.isChannel(o)?-o:0;Ne[m.getFullMessageID(n.id,d)]=a}break;case"updateNewMessage":case"updateNewChannelMessage":var p=n.message,o=ue(p),u=Pe[o],g=A(o);if(!g.length){lt[o]={reload:!0},rt||(rt=i(Me,0));break}if("updateNewChannelMessage"==n._){var h=l.getChat(-o);if(h.pFlags&&(h.pFlags.left||h.pFlags.kicked))break}if(te([p],{isNew:!0}),void 0!==u){var f=u.history;if(f.indexOf(p.mid)!=-1)return!1;var v=f[0];f.unshift(p.mid),p.mid>0&&p.mid0&&N&&r.forceUserOnline(o),R=0;RB)&&(p=Ee[F],p.pFlags.out==N)){if(!p.pFlags.unread)break;p&&p.pFlags.unread&&(p.pFlags.unread=!1,Te[F]&&(Te[F].pFlags.unread=!1,L||(L=!0)),De[F]&&(De[F].pFlags.unread=!1),p.pFlags.out||(g[0]&&(U=--g[0].unread_count),w.cancel("msg"+F)))}if(g[0]){!N&&U&&g[0].top_message<=B&&(U=g[0].unread_count=0);var j=N?"read_outbox_max_id":"read_inbox_max_id";g[0][j]=B}U!==!1&&t.$broadcast("dialog_unread",{peerID:o,count:U}),L&&t.$broadcast("messages_read");break;case"updateReadMessagesContents":var R,F,p,q,z=n.messages,W=z.length;for(R=0;R0&&(a.count-=e.count,a.count<0&&(a.count=0));for(var o=0;o0,Q="channel"==Z._&&(Z.username||!Z.pFlags.left&&!Z.pFlags.kicked)&&!0||!1,ee=void 0!==Pe[o];Q!=ee&&(delete Pe[o],t.$broadcast("history_forbidden",o)),J!=X&&(X?Ie(-d):g[0]&&(Fe.dialogs.splice(g[1],1),t.$broadcast("dialog_drop",{peerID:o})));break;case"updateChannelReload":var d=n.channel_id,o=-d,g=A(o);g[0]&&Fe.dialogs.splice(g[1],1),delete Pe[o],Ie(-d).then(function(){t.$broadcast("history_reload",o)});break;case"updateChannelMessageViews":var ne=n.views,M=m.getFullMessageID(n.id,n.channel_id),p=V(M);p&&p.views&&p.viewso)&&(o=d.date)}}s.pFlags.pinned||(s.index=P(o)),F(s),t.$broadcast("dialog_draft",{peerID:a,draft:i,index:s.index})}}),{getConversations:I,getHistory:L,getSearch:q,getMessage:V,getReplyKeyboard:j,readHistory:X,readMessages:J,flushHistory:ee,deleteMessages:Y,sendText:ne,sendFile:ae,sendOther:ie,forwardMessages:se,startBot:oe,shareGame:re,editMessage:pe,convertMigratedPeer:O,getMessagePeer:ue,getMessageThumb:ke,getMessageShareLink:Z,canMessageBeEdited:z,canEditMessage:W,getMessageEditData:G,canRevokeMessage:K,clearDialogCache:he,wrapForDialog:me,wrapForHistory:fe,wrapReplyMarkup:_e,wrapSingleMessage:ge,wrapMessageText:ve,regroupWrappedHistory:we}}]).service("AppMessagesIDsManager",function(){function e(e,t){if(!t||e<=0)return e;e=n(e);var a=i[t];return a||(a=++o*r,s[a]=t,i[t]=a),a+e}function t(e){if(e\n\t\n\t \n\t\n\t
\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t\t[ \n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t]\n\t\t\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t
\n\t
\n \n \n\t
\n\t
\n\t\t
\n\t\t \n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t
\n\t \t
\n\t \t
\n\t
\n\t
\n\t\n'),e.put("partials/desktop/changelog_modal.html",'
\n\n
\n
\n
\n \n
\n
\n
\n\n
\n
\n \n
\n
\n
Telegram Web
\n
Version {{currentVersion}}
\n
\n
\n
\n\n
\n
\n \n \n \n
\n
\n\n
\n\n
\n\n
\n
0.5.6
\n
\n
    \n
  • Edit the text of your messages after sending them. This works across all Telegram chats, including groups and one-on-one conversations. Select a message and click \'Edit\' or just press the up arrow button to edit your last message.
  • \n
  • Unsend Messages: retract any messages within 48 hours of sending them. Check out the Telegram Blog for more info.
  • \n
  • Pinned chats. Check out the Telegram Blog for more info.
  • \n
  • Sticker suggestions by emoji.
  • \n
  • Search for messages in specific chats.
  • \n
  • Background notifications in Chrome and Firefox (can be disabled in Settings)
  • \n
\n\n
\n
\n\n
\n
0.5.5
\n
\n
    \n
  • Introducing Drafts: Seamless syncing for unsent messages on all your devices. Drafts are now visible in your chats list.
  • \n
  • Mention people in groups by typing @ and selecting them from the list — even if they don\'t have a username.
  • \n
  • Share links to specific posts in channels via quick forwarding menu (click on the date in a message to try this out).
  • \n
\n\n
\n
\n\n
\n
0.5.4
\n
\n
    \n
  • Introducing Bot API 2.0, the biggest update to our bot platform since June 2015.
  • \n
  • New inline keyboards with callback, \'open URL\' or \'switch to inline mode\' buttons help create seamless interfaces.
  • \n
  • Bots can now update existing messages on the fly as you interact with them.
  • \n
  • Prepare for the rise of location-based bots: all bots can now ask users to share their location.
  • \n
  • Inline bots can now send all attachments supported in Telegram (videos, music, stickers, files, etc.).
  • \n
  • Try out these sample bots to see what\'s coming your way soon: @music, @sticker, @youtube, @foursquare
  • \n
  • Check out the Telegram Blog for more info.
  • \n
  • New quick forwarding in channels (click on the date in a message to try this out).
  • \n
  • Improved performance.
  • \n
\n\n
\n
\n\n
\n
0.5.3
\n
\n
    \n
  • Inline bots: A new way to add bot content to any chat. Type a bot\'s username and your query in the text field to get instant results and send them to your chat partner. Try typing @gif dog in your next chat. Sample bots: @gif, @wiki, @bing, @vid, @bold.
  • \n
  • Check out the Telegram Blog for more info.
  • \n
  • Improved GIFs: 20x faster sending and downloading, nice animated progress
  • \n
  • Click on message date to reply (or to forward from channels).
  • \n
  • Preview images before sending when pasting from clipboard.
  • \n
  • Improved formatting for copy-pasted history fragments (date, time and sender names inserted automatically).
  • \n
\n
\n
\n\n
\n
0.5.2
\n
\n
    \n
  • Unread counters for muted chats now colored in gray.
  • \n
  • Improved previews for sticker sets: Click on a sticker to view the whole set, click on stickers in a set to send right away, added a \'Share\' button.
  • \n
  • Improved performance.
  • \n
\n
\n
\n\n
\n
0.5.1
\n
\n
    \n
  • Groups that have reached their capacity of 200 users can be upgraded to supergroups of up to 1,000 members.
  • \n
  • Check out the Telegram Blog for more info
  • \n
\n
\n
\n\n
\n
0.5.0
\n
\n
    \n
  • Removed annoying "multiple tabs open" error.
  • \n
  • Improved message forwarding.
  • \n
  • Added view counter to messages from channels.
  • \n
  • Improved image loading in Safari and Firefox.
  • \n
\n
\n
\n\n
\n
0.4.9
\n
\n
    \n
  • New emoji and sticker menu, tabs for sticker packs.
  • \n
\n
\n
\n\n
\n
0.4.8
\n
\n
    \n
  • Introducing Channels – a great new way to broadcast your messages to unlimited audiences.
  • \n
  • Check out the Telegram Blog for more info
  • \n
  • Improved performance in Safari on OS X El Capitan.
  • \n
  • Added formatting for fixed-width code, surround text with `single backticks` for inline text and ```triple backticks``` for blocks of pre-formatted text.
  • \n
\n
\n
\n\n
\n
0.4.7
\n
\n
    \n
  • New bot API, free for everyone. If you\'re an engineer, create your own bots for games, services or integrations.\n
  • \n
  • Check out Telegram Blog for more info
  • \n
  • Improved Stickers support: now stickers are loading much faster.
  • \n
  • Click on any custom stickers in chats to view and add sticker sets.
  • \n
  • [Mobile] Reply to a message easily: tap on any message and select "Reply".
  • \n
\n
\n
\n\n
\n
0.4.6
\n
\n \n
\n
\n\n
\n
0.4.5
\n
\n
    \n
  • \n Invite links for group chats:
    \n Check out Telegram Blog for more info\n
  • \n
  • Smart notifications
  • \n
  • \'Listened\' status for voice messages
  • \n
  • Places in locations (venues, landmarks)
  • \n
\n
\n
\n\n
\n
0.4.4
\n
\n
    \n
  • Link Previews:
    \n Get rich link summaries for tweets, YouTube videos, Instagram photos and other content.
  • \n\n
  • Check out Telegram Blog for more info.
  • \n
\n
\n
\n\n
\n
0.4.3
\n
\n
    \n
  • Sessions List:
    \n View your active Telegram sessions (on desktop, tablet and mobile devices) and close specific sessions remotely.
  • \n\n
  • Two-step verification:
    \n Set up an additional password that will be required to log into your Telegram account.
  • \n\n
  • Check out Telegram Blog for more info.
  • \n
\n
\n
\n\n
\n
0.4.2
\n
\n
    \n
  • Optimization for screens with smaller Y-resolutions.
  • \n
  • Supported Spotify URL embeds.
  • \n
  • Mentions of the current user in group chats are now highlighted.
  • \n
\n
\n
\n\n
\n
0.4.1
\n
\n
    \n
  • Reply to specific messages in groups.
  • \n
  • Mention @usernames in groups to notify multiple users.
  • \n
  • Revised notifications in groups: mentioned users and people you reply to will be notified (private chat notification settings apply in this case instead of group settings). Check out Telegram Blog for more info.
  • \n
  • Setting to disable message preview
  • \n
\n
\n
\n\n
\n
0.4.0
\n
\n
    \n
  • Full stickers support
  • \n
  • Multisearch box: instantly find chats, usernames and messages
  • \n
  • Emoji autocomplete: e.g., type :kiss in the message field to see the list. Full cheat sheet »
  • \n
  • Added \'typing\' notification in chats list
  • \n
  • Online members counter in group headers
  • \n
\n
\n
\n\n
\n
0.3.9
\n
\n
    \n
  • [Desktop] Material design completed
  • \n
\n
\n
\n\n
\n
0.3.8
\n
\n
    \n
  • Telegram.me links open right in Telegram Web when authorized
  • \n
  • @username mentions in messages are clickable and open a conversation with the user
  • \n
\n
\n
\n\n
\n
0.3.7
\n
\n
    \n
  • [Desktop] New material design for modal windows
  • \n
  • [Desktop] Forward messages to multiple recipients
  • \n
\n
\n
\n\n
\n
0.3.6
\n
\n
    \n
  • New viewer for photos, videos, documents.
  • \n
  • [FirefoxOS] Improved media downloads.
  • \n
\n
\n
\n\n
\n
0.3.5
\n
\n
    \n
  • Added embedded Soundcloud tracks and playlists.
  • \n
  • Added global user search to contacts list.
  • \n
  • Added switch to mobile version on window resize.
  • \n
  • Migrate to HTTPS notification
  • \n
  • Bugfixes.
  • \n
\n
\n
\n\n
\n
0.3.4
\n
\n
    \n
  • Added embedded Facebook posts and Vimeo videos.
  • \n
  • Improved IE10+ support: downloading files and style fixes.
  • \n
  • Added unsupported media playback warning.
  • \n
  • Bugfixes.
  • \n
\n
\n
\n\n
\n
0.3.3
\n
\n
    \n
  • Added Native Client module: dramatically improved encryption speed; Download and upload speed is now as high as in native applications.
  • \n
  • HTTPS. We recommend you to use https://web.telegram.org.
  • \n
  • Added multiple open tabs warning. Please note, that only one tab with Telegram Web will work.
  • \n
  • Added embedded Instagram, Twitter, Vine, YouTube links.
  • \n
  • Jump to selected spot when playing back audio.
  • \n
  • Bugfixes
  • \n
\n
\n
\n\n
\n
0.3.2
\n
\n
    \n
  • Usernames support: Choose a username right now!
  • \n
  • Search can now find public users by username.
  • \n
  • Most popular emoticons shown in \'recent\' when empty
  • \n
  • [ChromeApp] Added saving window position and size
  • \n
  • Bugfixes
  • \n
\n
\n
\n\n
\n
0.3.1
\n
\n
    \n
  • New languages: Spanish, German and Italian are now available
  • \n
  • New custom-made audio player
  • \n
  • Bad browser page for IE 6-9
  • \n
  • Perfomance improvements and bugfixes
  • \n
\n
\n
\n\n
\n
0.3.0
\n
\n
    \n
  • Log in codes may be received in other Telegram apps
  • \n
  • Partner\'s online status updates automatically
  • \n
  • Added support for non-english hashtags in messages
  • \n
  • Fixed invalid scrollbar width bug
  • \n
  • [Desktop] Added automatic country code detection
  • \n
  • [FirefoxOS] Improved PUSH-notifications for <= 1.1
  • \n
  • [FirefoxOS] Fixed emoji in notifications
  • \n
  • [FirefoxOS] Fixed attachment bug for <= 1.1
  • \n
  • [FirefoxOS] Added phonebook permissions handling
  • \n
  • [FirefoxOS] Added ability to share Gallery photos in Telegram
  • \n
\n
\n
\n\n
\n\n\n \n\n
\n\n
'), e.put("partials/desktop/channel_edit_modal.html",'
\n\n
\n\n \n\n
\n\n \n\n
'),e.put("partials/desktop/channel_modal.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
\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 \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/desktop/chat_create_modal.html",'
\n\n
\n\n \n\n
\n\n \n\n
'),e.put("partials/desktop/chat_edit_modal.html",'
\n\n
\n\n \n\n
\n\n \n\n
'),e.put("partials/desktop/chat_invite_link_modal.html",'
\n\n
\n\n \n\n
\n\n \n\n
'),e.put("partials/desktop/chat_modal.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\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\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/desktop/composer_dropdown.html",'
\n\n \n\n \n\n
    \n\n
    \n\n
    '),e.put("partials/desktop/confirm_modal.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

    \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
    \n
    \n
    \n
    \n\n\n\n \n \n \n \n
    \n\n
    \n\n \n\n
    \n'),e.put("partials/desktop/contacts_modal.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 {0}\n
    \n\n \n\n
    \n
    \n\n
    \n\n
    \n\n \n\n
    \n'), e.put("partials/desktop/country_select_modal.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'),e.put("partials/desktop/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
    \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/desktop/document_modal.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'),e.put("partials/desktop/edit_contact_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/embed_modal.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'),e.put("partials/desktop/emoji_btn_tooltip.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
    '),e.put("partials/desktop/error_modal.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 \n \n \n \n \n \n \n \n \n {0}\n \n \n \n \n \n \n \n {0}\n \n \n \n \n\n\n
    \n \n \n {0}\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/desktop/footer.html",''),e.put("partials/desktop/forwarded_messages.html",'
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n \n \n \n
    \n
    \n
    '),e.put("partials/desktop/full_document.html",'
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n
    \n
    '),e.put("partials/desktop/full_gif.html",'\n\n
    \n\n
    \n
    \n \n \n \n \n
    \n
    \n
    [GIF]
    \n
    \n\n
    \n \n \n
    \n \n\n
    \n\n
    '),e.put("partials/desktop/full_photo.html",'
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    \n
    \n
    '),e.put("partials/desktop/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/desktop/game_modal.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'),e.put("partials/desktop/head.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
    \n\n \n
    \n \n \n \n \n \n
    \n
    \n\n
    \n\n
    \n
    \n
    \n
    '),e.put("partials/desktop/im.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
    \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
    \n
    \n
    \n\n
    \n\n
    \n\n
    \n
    \n
    \n
    \n \n \n \n \n \n \n {{historyState.typing.length - 2}}\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
    \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
    \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/desktop/import_contact_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/inactive.html",'
    \n
    \n
    \n
    \n \n

    \n
    \n
    \n \n
    \n
    \n
    \n
    '),e.put("partials/desktop/inline_results.html",'\n\n'),e.put("partials/desktop/lang_footer.html",''),e.put("partials/desktop/login.html",'\n\n'),e.put("partials/desktop/media_modal_layout.html",''),e.put("partials/desktop/megagroup_edit_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/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
    \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/desktop/message_attach_contact.html",'
    \n \n
    \n \n \n
    \n
    \n
    '),e.put("partials/desktop/message_attach_document.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
    \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/desktop/message_attach_game.html",'
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n'),e.put("partials/desktop/message_attach_geo.html",'\n \n'),e.put("partials/desktop/message_attach_pending.html",'
    \n
    \n \n
    \n
    \n
    \n \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n'), e.put("partials/desktop/message_attach_photo.html",'\n \n\n
    '),e.put("partials/desktop/message_attach_venue.html",'
    \n\n \n \n \n\n
    \n
    \n \n
    \n
    \n
    \n\n
    \n'),e.put("partials/desktop/message_attach_webpage.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 \n
    \n
    \n
    \n
    \n'),e.put("partials/desktop/message_media.html",'
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    '),e.put("partials/desktop/message_service.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 \n \n\n \n \n \n \n \n \n \n\n\n \n \n \n\n'),e.put("partials/desktop/password_recovery_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/password_update_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/peer_select.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\n
    \n'),e.put("partials/desktop/photo_modal.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 \n \n
    \n
    \n
    \n\n\n\n'),e.put("partials/desktop/pinned_message.html",''),e.put("partials/desktop/profile_edit_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    \n'),e.put("partials/desktop/reply_markup.html",'
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    '),e.put("partials/desktop/reply_message.html",'
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n \n \n
    \n
    \n \n \n
    \n
    '),e.put("partials/desktop/sessions_list_modal.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'),e.put("partials/desktop/settings_modal.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\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
    \n
    \n\n
    \n\n
    \n \n\n \n\n
    \n\n \n\n
    \n\n
    \n\n
    \n'), -e.put("partials/desktop/short_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 \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'),e.put("partials/desktop/slider.html",'
    \n\t
    \n\t
    \n\t\t
    \n\t
    \n
    '),e.put("partials/desktop/stickerset_modal.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
    \n \n \n \n
    \n
    \n\n
    \n\n
    \n'),e.put("partials/desktop/user_modal.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
    \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/desktop/username_edit_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/video_modal.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')}]),function(e,t,n,a){function i(e){ConfigStorage.get("emojis_popular",function(t){var n=[];if(t&&t.length){for(var a=0,i=t.length;a41&&(i=i.slice(0,41)),i.push([e,1])),ConfigStorage.set({emojis_popular:i})})}function o(){if(b===!1){b=SearchIndexManager.createIndex();var e;for(e in _)_.hasOwnProperty(e)&&SearchIndexManager.indexObject(_[e],e,b)}}function r(e){o();var t,n=SearchIndexManager.search(e,b),a=[];for(t in n)n.hasOwnProperty(t)&&a.push(t);return a}var l,c,d,p,u,m,g,h,f={},_={},v={},y={},b=!1,w="joy,kissing_heart,heart,heart_eyes,blush,grin,+1,relaxed,pensive,smile,sob,kiss,unamused,flushed,stuck_out_tongue_winking_eye,see_no_evil,wink,smiley,cry,stuck_out_tongue_closed_eyes,scream,rage,smirk,disappointed,sweat_smile,kissing_closed_eyes,speak_no_evil,relieved,grinning,yum,laughing,ok_hand,neutral_face,confused".split(",");for(l=0,g=n.length;l
    '+this.langpack.im_stickers_tab+'
    ';e=e.replace(/>\s+<");var t=this;this.tooltipEl=$(e).appendTo(document.body),this.tabsEl=$(".composer_emoji_tooltip_tabs",this.tooltipEl),this.categoriesEl=$(".composer_emoji_tooltip_categories",this.tooltipEl),this.stickersCategoriesEl=$(".composer_emoji_tooltip_tab_stickers_content .composer_emoji_tooltip_categories",this.tooltipEl),this.contentEl=$(".composer_emoji_tooltip_content",this.tooltipEl),this.emojiContentEl=$(".composer_emoji_tooltip_content_emoji",this.tooltipEl),this.stickersContentEl=$(".composer_emoji_tooltip_content_stickers",this.tooltipEl),angular.forEach(["emoji","stickers"],function(e,n){var a=$(".composer_emoji_tooltip_tab_"+e,t.tabsEl).on("mousedown",function(e){return t.selectTab(n),cancelEvent(e)});Config.Navigator.touch||a.on("mouseenter mouseleave",function(e){clearTimeout(t.selectTabTimeout),"mouseenter"==e.type&&(t.selectTabTimeout=setTimeout(function(){t.selectTab(n)},300))})});var n="mousedown";return Config.Navigator.touch||(n+=" mouseover mouseout"),this.categoriesEl.on(n,function(e){e=e.originalEvent||e;var n=e.target;if("A"!=n.tagName&&(n=n.parentNode),"A"==n.tagName){var a=parseInt(n.getAttribute("data-category"));if("mousedown"==e.type)return t.selectCategory(a),cancelEvent(e);if(!t.tab){var i="mouseover"==e.type;i&&t.selectCategoryIndex==a||(clearTimeout(t.selectCategoryTimeout),delete t.selectCategoryTimeout,i?(t.selectCategoryIndex=a,t.selectCategoryTimeout=setTimeout(function(){delete t.selectCategoryIndex,delete t.selectCategoryTimeout,t.selectCategory(a)},300)):delete t.selectCategoryIndex)}}}),this.emojiScroller=new Scroller(this.emojiContentEl,{classPrefix:"composer_emoji_tooltip"}),this.stickersScroller=new Scroller(this.stickersContentEl,{classPrefix:"composer_emoji_tooltip"}),this.stickersScroller.onScroll(function(e,n){t.onStickersScroll(e,n)}),this.contentEl.on("mousedown",function(e){e=e.originalEvent||e;var n,a,i,s=$(e.target);return"A"!=s[0].tagName&&(s=$(s[0].parentNode)),(n=s.attr("data-code"))&&(t.onEmojiSelected&&t.onEmojiSelected(n),EmojiHelper.pushPopularEmoji(n)),(a=s.attr("data-sticker"))&&(t.onStickerSelected&&t.onStickerSelected(a),Config.Mobile&&t.hide()),(i=s.attr("data-stickerset"))&&(t.onStickersetSelected&&t.onStickersetSelected(i),t.hide()),cancelEvent(e)}),Config.Navigator.touch||this.tooltipEl.on("mouseenter mouseleave",function(e){"mouseenter"==e.type?t.onMouseEnter():t.onMouseLeave()}),this.selectTab(0),$(window).on("resize",this.updatePosition.bind(this)),!0},EmojiTooltip.prototype.selectCategory=function(e,t){return!(!this.tab&&this.cat===e&&!t)&&($(".active",this.categoriesEl).removeClass("active"),this.cat=e,void(this.tab?(this.activateStickerCategory(),this.updateStickersContents(t)):($(this.categoriesEl[this.tab].childNodes[e]).addClass("active"),this.updateEmojiContents())))},EmojiTooltip.prototype.selectTab=function(e,t){if(this.tab===e&&!t)return!1;this.tab=e,this.selectCategory(0,!0);var n=this;setTimeout(function(){$(n.tooltipEl).toggleClass("composer_emoji_tooltip_tabs_stickers_active",1==e)},0)},EmojiTooltip.prototype.updateEmojiContents=function(){var e=[],t=this,n=26,a=function(){t.emojiContentEl.html(e.join("")),t.emojiScroller.reinit()};if(this.cat>0){var i,s,o,r,l,c=this.cat-1,d=Config.EmojiCategories[c],p=Config.EmojiCategorySpritesheetDimens[c][1],u=d.length;for(o=0;o');a()}else EmojiHelper.getPopularEmoji(function(t){var i,s,o,r,l,c,d,p,u=t.length;for(c=0;c'));a()})},EmojiTooltip.prototype.updateStickersContents=function(e){var t=[],n=[],a=this,i=function(){var t=a.cat?a.stickersetPositions[a.cat][0]:0;a.stickersScroller.scrollTo(t,e?0:200)};if(!e&&a.stickersetPositions.length)return void i();var s=function(e){var s,o,r,l,c,d;for(r=0,c=e.length;r'),s.title&&t.push('',encodeEntities(s.title),""),s.id?n.push(''):n.push(''),l=0,d=s.docIDs.length;l');t.push("")}a.stickersContentEl.html(t.join("")),a.stickersCategoriesEl.html(n.join("")),a.stickersScroller.reinit();var p=[];$(".composer_stickerset_wrap",a.stickersContentEl).each(function(e,t){var n=t.offsetHeight,a=t.offsetTop;p.push([a,n])}),a.stickersetPositions=p,i();var u=[];a.contentEl.find(".composer_sticker_btn").each(function(e,t){e<12?a.replaceStickerImage(t):u.push([t.offsetTop,t])}),a.stickersPreload=u,a.stickersCategoriesEl.find(".composer_sticker_btn").each(function(e,t){a.replaceStickerImage(t)})};this.getStickers(s)},EmojiTooltip.prototype.replaceStickerImage=function(e){e=$(e),this.getStickerImage(e,e.attr("data-sticker"))},EmojiTooltip.prototype.onStickersScroll=function(e,t){var n,a,i=e.clientHeight,s=e.scrollHeight,o=this.stickersetPositions.length,r=!1;if(t<20)r=0;else if(t>s-i-20)r=o-1;else for(a=0;a=n[0]&&t=t&&n[0]<=t+i&&(this.replaceStickerImage(n[1]),this.stickersPreload.splice(a,1),a--,o--);this.cat!==r&&r!==!1&&($(".active",this.categoriesEl).removeClass("active"),this.cat=r,this.activateStickerCategory())},EmojiTooltip.prototype.onStickersChanged=function(){this.tab&&this.updateStickersContents(!0)},EmojiTooltip.prototype.activateStickerCategory=function(){var e=this.categoriesEl[1],t=e.childNodes[this.cat];if(t){$(t).addClass("active");var n=t.offsetLeft,a=t.offsetWidth,i=e.clientWidth;$(e).stop(!0).animate({scrollLeft:n-(i-a)/2},200)}},EmojiTooltip.prototype.updatePosition=function(){var e=this.btnEl.offset();this.tooltipEl.css({top:e.top,left:e.left})},EmojiTooltip.prototype.show=function(){this.updatePosition(),this.tab?this.updateStickersContents(!0):this.updateEmojiContents(),this.tooltipEl.addClass("composer_emoji_tooltip_shown"),this.btnEl.addClass("composer_emoji_insert_btn_on"),delete this.showTimeout,this.shown=!0},EmojiTooltip.prototype.hide=function(){this.tooltipEl&&(this.tooltipEl.removeClass("composer_emoji_tooltip_shown"),this.btnEl.removeClass("composer_emoji_insert_btn_on")),delete this.hideTimeout,delete this.shown},EmojiPanel.prototype.update=function(){var e=[],t=this,n=Config.Mobile?26:20;EmojiHelper.getPopularEmoji(function(a){var i,s,o,r,l,c,d,p,u=a.length;for(c=0;c'));t.containerEl.html(e.join(""))})},MessageComposer.autoCompleteRegEx=/(\s|^)(:|@|\/)([\S]*)$/,MessageComposer.prototype.setUpInput=function(){if(this.inlinePlaceholderWrap=$('
    ').prependTo(this.textareaEl[0].parentNode),this.inlinePlaceholderPrefixEl=$('').appendTo(this.inlinePlaceholderWrap),this.inlinePlaceholderEl=$('').appendTo(this.inlinePlaceholderWrap),"contentEditable"in document.body?this.setUpRich():this.setUpPlaintext(),!Config.Mobile){var e=getScrollWidth();e&&(this.richTextareaEl||this.textareaEl).css({left:-e,width:"calc(100% + "+2*e+"px)","padding-left":e+2,"padding-right":e+28})}},MessageComposer.prototype.setInlinePlaceholder=function(e,t){this.inlinePlaceholderPrefix=e,this.inlinePlaceholderPrefixEl.html(encodeEntities(e)),this.inlinePlaceholderEl.html(encodeEntities(t)),this.onChange()},MessageComposer.prototype.updateInlinePlaceholder=function(){var e=this.inlinePlaceholderPrefix;if(e){var t=this.textareaEl.val();this.inlinePlaceholderWrap.toggleClass("active",t==e)}},MessageComposer.prototype.setUpAutoComplete=function(){this.scroller=new Scroller(this.autoCompleteEl,{maxHeight:180});var e=this;this.autoCompleteEl.on("mousedown",function(t){t=t.originalEvent||t;for(var n,a,i,s,o=t.target;o&&"A"!=o.tagName;)o=o.parentNode;return o?(o=$(o),(a=o.attr("data-code"))&&(e.onEmojiSelected&&e.onEmojiSelected(a,!0),EmojiHelper.pushPopularEmoji(a)),n=t.altKey||!o.attr("data-username")?o.attr("data-user-id"):o.attr("data-username"),n&&e.onMentionSelected(n,o.attr("data-name")),(i=o.attr("data-command"))&&(e.onCommandSelected&&e.onCommandSelected(i),e.hideSuggestions()),(s=o.attr("data-inlineid"))&&(e.onInlineResultSend&&e.onInlineResultSend(s),e.hideSuggestions()),cancelEvent(t)):cancelEvent(t)})},MessageComposer.prototype.setUpRich=function(){this.textareaEl.hide(),this.richTextareaEl=$('
    '),this.textareaEl[0].parentNode.insertBefore(this.richTextareaEl[0],this.textareaEl[0]),this.richTextareaEl.on("keyup keydown",this.onKeyEvent.bind(this)),this.richTextareaEl.on("focus blur",this.onFocusBlur.bind(this)),this.richTextareaEl.on("paste",this.onRichPaste.bind(this)),this.richTextareaEl.on("DOMNodeInserted",this.onRichPasteNode.bind(this)),$(document.body).on("keydown",this.backupSelection.bind(this))},MessageComposer.prototype.setUpPlaintext=function(){this.textareaEl.on("keyup keydown",this.onKeyEvent.bind(this)),this.textareaEl.on("focus blur",this.onFocusBlur.bind(this))},MessageComposer.prototype.onKeyEvent=function(e){var t=this;if("keyup"==e.type){this.checkAutocomplete();var n=!1;if(this.richTextareaEl){clearTimeout(this.updateValueTO);var a=tsNow();void 0===this.keyupStarted&&(this.keyupStarted=a),a-this.keyupStarted>3e3,this.onChange()}if(this.onTyping){var a=tsNow();a-this.lastTyping>5e3&&(n===!1&&(n=(this.richTextareaEl?this.richTextareaEl[0].textContent:this.textareaEl[0].value).length),n!=this.lastLength&&(this.lastTyping=a,this.lastLength=n,this.onTyping()))}}if("keydown"==e.type){var i=!this.autocompleteShown;if(this.autocompleteShown){if(38==e.keyCode||40==e.keyCode){var s,o=40==e.keyCode,r=$(this.autoCompleteEl).find("li.composer_autocomplete_option_active"),l=Array.prototype.slice.call($(this.autoCompleteEl).find("li"));if(r.length){var c=l.indexOf(r[0]),d=c+(o?1:-1);if(s=l[d],r.removeClass("composer_autocomplete_option_active"),s)return $(s).addClass("composer_autocomplete_option_active"),this.scroller.scrollToNode(s),cancelEvent(e)}return s=l[o?0:l.length-1],this.scroller.scrollToNode(s),$(s).addClass("composer_autocomplete_option_active"),cancelEvent(e)}if(13==e.keyCode||9==e.keyCode){var r=$(this.autoCompleteEl).find("li.composer_autocomplete_option_active");r.length||9!=e.keyCode||(r=$(this.autoCompleteEl).find("li:first")),r=r.find("a:first");var p,u,m,g;if(p=r.attr("data-code"))return this.onEmojiSelected(p,!0),EmojiHelper.pushPopularEmoji(p),cancelEvent(e);if(u=e.altKey||!r.attr("data-username")?r.attr("data-user-id"):r.attr("data-username"))return this.onMentionSelected(u,r.attr("data-name")), -cancelEvent(e);if(m=r.attr("data-command"))return this.onCommandSelected&&this.onCommandSelected(m,9==e.keyCode),cancelEvent(e);if(g=r.attr("data-inlineid"))return t.onInlineResultSend&&t.onInlineResultSend(g),t.hideSuggestions(),cancelEvent(e);i=!0}}if(i&&13==e.keyCode){var h=!1,f=!0;if(this.getSendOnEnter&&!this.getSendOnEnter()&&(f=!1),f&&!e.shiftKey?h=!0:f||!e.ctrlKey&&!e.metaKey||(h=!0),h)return this.onMessageSubmit(e),cancelEvent(e)}if([33,34,35,36,38,39].indexOf(e.keyCode)!=-1&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&this.richTextareaEl&&!this.richTextareaEl[0].textContent.length)return this.onDirectionKey(e)}},MessageComposer.prototype.backupSelection=function(){if(delete this.selection,this.isActive)if(window.getSelection){var e=window.getSelection();e.getRangeAt&&e.rangeCount&&(this.selection=e.getRangeAt(0))}else document.selection&&document.selection.createRange&&(this.selection=document.selection.createRange())},MessageComposer.prototype.restoreSelection=function(){if(!this.selection)return!1;var e=!1;if(window.getSelection){var t=window.getSelection();t.removeAllRanges(),t.addRange(this.selection),e=!0}else document.selection&&this.selection.select&&(this.selection.select(),e=!0);return delete this.selection,e},MessageComposer.prototype.checkAutocomplete=function(e){var t,n;if(this.richTextareaEl){var a=this.richTextareaEl[0],i=getRichValueWithCaret(a),n=i[0],t=i[1]>=0?i[1]:n.length;t||this.cleanRichTextarea(n,!0)}else var a=this.textareaEl[0],t=getFieldSelection(a),n=a.value;if(n&&this.curInlineResults&&this.curInlineResults.text==n)return void this.showInlineSuggestions(this.curInlineResults);e||(n=n.substr(0,t));var s=n.match(MessageComposer.autoCompleteRegEx);if(s){if(this.previousQuery==s[0])return;this.previousQuery=s[0];var o=SearchIndexManager.cleanSearchText(s[3]);if("@"==s[2])if(this.mentions&&this.mentions.index){if(o.length)for(var r,l=SearchIndexManager.search(o,this.mentions.index),c=[],d=0,p=this.mentions.users.length;d=0)||(i.push(n),t.splice(a,1),t.length));s++);this.showEmojiSuggestions(i.concat(t))}else this.hideSuggestions()}else this.showEmojiSuggestions(e)}.bind(this))}}else if(this.commands&&this.commands.index){if(o.length)for(var u,l=SearchIndexManager.search(o,this.commands.index),m=[],d=0,p=this.commands.list.length;d0&&(this.richTextareaEl.html(""),this.lastLength=0,this.wasEmpty=!0,t))){var n=this;setZeroTimeout(function(){n.focus()})}},MessageComposer.prototype.onRichPasteNode=function(e){var t=(e.originalEvent||e).target,n=(t||{}).src||"",a=!1;if("data:"==n.substr(0,5)){a=!0;var i=dataUrlToBlob(n);this.onFilePaste(i),setZeroTimeout(function(){t.parentNode.replaceChild(document.createTextNode("   "),t)})}else if(n&&!n.match(/img\/blank\.gif/)){var s=document.createTextNode(" "+n+" ");setTimeout(function(){t.parentNode.replaceChild(s,t)},100)}},MessageComposer.prototype.onEmojiSelected=function(e,t){if(this.richTextareaEl){var n=this.richTextareaEl[0];if(this.isActive||this.restoreSelection()||setRichFocus(n),t){var a,i=getRichValueWithCaret(n),s=i[0],o=i[1]>=0?i[1]:s.length,r=s.substr(o),l=s.substr(0,o),c=l.match(/:([\S]*)$/),d=EmojiHelper.emojis[e];a=c&&c[0]?l.substr(0,c.index)+":"+d[1]+":":l+":"+d[1]+":",n.value=f;var p;r.length?(this.selId=(this.selId||0)+1,p=this.getRichHtml(a)+' '+this.getRichHtml(r),this.richTextareaEl.html(p),setRichFocus(n,$("#composer_sel"+this.selId)[0])):(p=this.getRichHtml(a)+" ",this.richTextareaEl.html(p),setRichFocus(n))}else{var p=this.getEmojiHtml(e);if(window.getSelection){var u=window.getSelection();if(u.getRangeAt&&u.rangeCount){var m=document.createElement("div");m.innerHTML=p;var g=m.firstChild,h=u.getRangeAt(0);h.deleteContents(),h.insertNode(document.createTextNode(" ")),h.insertNode(g),h.setStart(g,0),setTimeout(function(){h=document.createRange(),h.setStartAfter(g),h.collapse(!0),u.removeAllRanges(),u.addRange(h)},0)}}else document.selection&&"Control"!=document.selection.type&&document.selection.createRange().pasteHTML(p)}}else{var n=this.textareaEl[0],s=n.value,o=this.isActive?getFieldSelection(n):s.length,r=s.substr(o),l=s.substr(0,o),c=t&&l.match(/:([\S]*)$/),d=EmojiHelper.emojis[e];if(c&&c[0])var f=l.substr(0,c.index)+":"+d[1]+": "+r,_=c.index+d[1].length+3;else var f=l+":"+d[1]+": "+r,_=l.length+d[1].length+3;n.value=f,setFieldSelection(n,_)}this.hideSuggestions(),this.onChange()},MessageComposer.prototype.onMentionsUpdated=function(e){delete this.previousQuery,this.isActive&&this.checkAutocomplete()},MessageComposer.prototype.onMentionSelected=function(e,t){var n=!0;if("#"==e.charAt(0)&&(n=!1,e=e.substr(1),t=t.replace(/\(\)@/,"")),this.richTextareaEl){var a=this.richTextareaEl[0];this.isActive||this.restoreSelection()||setRichFocus(a);var i,s=getRichValueWithCaret(a),o=s[0],r=s[1]>=0?s[1]:o.length,l=o.substr(r),c=o.substr(0,r),d=c.match(/@([\S]*)$/);i=d&&d[0]?c.substr(0,d.index)+"@"+e:c+"@"+e;var p;n?l.length?(this.selId=(this.selId||0)+1,p=this.getRichHtml(i)+' '+this.getRichHtml(l),this.richTextareaEl.html(p),setRichFocus(a,$("#composer_sel"+this.selId)[0])):(p=this.getRichHtml(i)+" ",this.richTextareaEl.html(p),setRichFocus(a)):(this.selId=(this.selId||0)+1,p=this.getRichHtml(i)+' ('+encodeEntities(t)+") "+this.getRichHtml(l),this.richTextareaEl.html(p),setRichFocus(a,$("#composer_sel"+this.selId)[0],!0))}else{var i,u,m,g,a=this.textareaEl[0],o=a.value,r=this.isActive?getFieldSelection(a):o.length,l=o.substr(r),c=o.substr(0,r),d=c.match(/@([\S]*)$/);i=d&&d[0]?c.substr(0,d.index)+"@"+e:c+"@"+e,n?(u=i+"@"+e+" "+l,m=d.index+e.length+2):(u=i+"@"+e+" ("+t+") "+l,m=d.index+e.length+2,g=m+t.length),a.value=u,setFieldSelection(a,m,g)}this.hideSuggestions(),this.onChange()},MessageComposer.prototype.onCommandSelected=function(e,t){if(t)if(this.richTextareaEl)this.richTextareaEl.html(encodeEntities(e)+" "),setRichFocus(this.richTextareaEl[0]);else{var n=this.textareaEl[0];n.value=e+" ",setFieldSelection(n)}else this.onCommandSend(e);this.hideSuggestions(),this.onChange()},MessageComposer.prototype.onChange=function(e){if(this.richTextareaEl){delete this.keyupStarted;var t=getRichValue(this.richTextareaEl[0]);this.textareaEl.val(t).trigger("change")}this.updateInlinePlaceholder()},MessageComposer.prototype.getEmojiHtml=function(e,t){t=t||EmojiHelper.emojis[e];var n=20,a=EmojiHelper.spritesheetPositions[e],i=a[0],s=(a[1],n*a[3]),o=n*a[2];return':'+encodeEntities(t[1])+':'},MessageComposer.prototype.setValue=function(e){this.richTextareaEl?(this.richTextareaEl.html(this.getRichHtml(e)),this.lastLength=e.length,this.wasEmpty=!e.length,this.onKeyEvent({type:"keyup"})):this.textareaEl.val(e)},MessageComposer.prototype.setFocusedValue=function(e){var t=e[0],n=e[1],a=e[2];if(this.richTextareaEl){this.selId=(this.selId||0)+1;var i=this.getRichHtml(t)+''+this.getRichHtml(n)+""+this.getRichHtml(a);this.richTextareaEl.html(i),setRichFocus(this.richTextareaEl[0],$("#composer_sel"+this.selId)[0],!0)}else this.textareaEl.val(t+n+a),setFieldSelection(this.textareaEl[0],t.length,t.length+n.length)},MessageComposer.prototype.getRichHtml=function(e){var t=$("
    ").text(e).html();return t=t.replace(/\n/g,"
    "),t=t.replace(/:([A-Za-z0-9\-\+\*_]+?):/gi,function(e,t){var n=EmojiHelper.shortcuts[t];return void 0!==n?this.getEmojiHtml(n):e}.bind(this)),t=t.replace(/ /g,"  ").replace(/^ | $/g," ")},MessageComposer.prototype.focus=function(){this.richTextareaEl?setZeroTimeout(function(){setRichFocus(this.richTextareaEl[0])}.bind(this)):setFieldSelection(this.textareaEl[0])},MessageComposer.prototype.blur=function(){this.richTextareaEl?this.richTextareaEl[0].blur():this.textareaEl[0].blur()},MessageComposer.prototype.renderSuggestions=function(){this.autoCompleteWrapEl.show(),this.scroller.reinit(),this.updatePosition(),this.autocompleteShown=!0},MessageComposer.prototype.showEmojiSuggestions=function(e){var t=++this.renderToggleCnt,n=this;setZeroTimeout(function(){n.autoCompleteScope.$apply(function(){n.autoCompleteScope.type="emoji",n.autoCompleteScope.emojiCodes=e}),onContentLoaded(function(){t==n.renderToggleCnt&&n.renderSuggestions()})})},MessageComposer.prototype.showMentionSuggestions=function(e){var t=++this.renderToggleCnt,n=this;setZeroTimeout(function(){n.autoCompleteScope.$apply(function(){n.autoCompleteScope.type="mentions",n.autoCompleteScope.mentionUsers=e}),onContentLoaded(function(){t==n.renderToggleCnt&&n.renderSuggestions()})})},MessageComposer.prototype.showCommandsSuggestions=function(e){var t=++this.renderToggleCnt,n=this;setZeroTimeout(function(){n.autoCompleteScope.$apply(function(){n.autoCompleteScope.type="commands",n.autoCompleteScope.commands=e}),onContentLoaded(function(){t==n.renderToggleCnt&&n.renderSuggestions()})})},MessageComposer.prototype.showInlineSuggestions=function(e){if(!e||!e.results.length)return void this.hideSuggestions();var t=++this.renderToggleCnt,n=this;"inline"==n.autoCompleteScope.type&&n.autoCompleteScope.botResults==e&&n.autocompleteShown||setZeroTimeout(function(){n.autoCompleteScope.$apply(function(){n.autoCompleteScope.type="inline",n.autoCompleteScope.botResults=e}),onContentLoaded(function(){t==n.renderToggleCnt&&n.renderSuggestions()})})},MessageComposer.prototype.setInlineSuggestions=function(e){this.curInlineResults=e,this.checkAutocomplete()},MessageComposer.prototype.updatePosition=function(){var e=(this.richTextareaEl||this.textareaEl).offset(),t=this.scroller.updateHeight(),n=$((this.richTextareaEl||this.textareaEl)[0].parentNode).outerWidth();this.autoCompleteWrapEl.css({top:e.top-t,left:Config.Mobile?0:e.left,width:Config.Mobile?"100%":n-2}),this.scroller.update()},MessageComposer.prototype.hideSuggestions=function(){++this.renderToggleCnt;this.autoCompleteWrapEl.hide(),delete this.autocompleteShown},MessageComposer.prototype.resetTyping=function(){this.lastTyping=0,this.lastLength=0},MessageComposer.prototype.setPlaceholder=function(e){(this.richTextareaEl||this.textareaEl).attr("placeholder",e)},Scroller.prototype.setUpNano=function(){this.content.wrap('
    '),this.scrollable=$(this.content[0].parentNode),this.scroller=$(this.scrollable[0].parentNode),this.wrap=$(this.scroller[0].parentNode),this.scroller.nanoScroller({preventPageScrolling:!0,tabIndex:-1})},Scroller.prototype.setUpNative=function(){this.content.wrap('
    '),this.scrollable=$(this.content[0].parentNode),this.scrollable.css({overflow:"auto"}),this.maxHeight&&this.scrollable.css({maxHeight:this.maxHeight}),this.minHeight&&this.scrollable.css({minHeight:this.minHeight})},Scroller.prototype.onScroll=function(e){var t=this,n=this.scrollable[0];this.scrollable.on("scroll",function(a){t.isAnimatedScroll||e(n,n.scrollTop)})},Scroller.prototype.update=function(){this.useNano&&$(this.scroller).nanoScroller()},Scroller.prototype.reinit=function(){this.scrollTo(0),this.useNano&&setTimeout(function(){this.updateHeight()}.bind(this),100)},Scroller.prototype.updateHeight=function(){var e;return this.useNano?(this.maxHeight||this.minHeight?(e=this.content[0].offsetHeight,this.maxHeight&&e>this.maxHeight&&(e=this.maxHeight),this.minHeight&&e0){var a=this;this.isAnimatedScroll=!0,this.scrollable.animate({scrollTop:e},t,function(){delete a.isAnimatedScroll,a.useNano&&$(a.scroller).nanoScroller({flash:!0}),a.scrollable.trigger("scroll"),n&&n()})}else this.scrollable[0].scrollTop=e,this.useNano&&$(this.scroller).nanoScroller({flash:!0}),n&&n()},Scroller.prototype.scrollToNode=function(e){e=e[0]||e;var t=e.offsetTop-15,n=e.offsetHeight+30,a=this.scrollable[0].scrollTop,i=this.scrollable[0].clientHeight;a>t?this.scrollTo(t):a

    --- 
     ---
    ',s='
    '+t("unread_messages_split")+"
    ",o="im_message_selected",r="im_message_focus",l="im_message_unread",c="im_message_error",d="im_message_pending";return{templateUrl:templateUrl("message"),link:n}}]).directive("myMessageBody",["$compile","AppPeersManager","AppChatsManager","AppUsersManager","AppMessagesManager","AppInlineBotsManager","RichTextProcessor",function(e,t,n,a,i,s,o){function r(e,t,n){if(n.media&&n.media.handleMessage||"string"!=typeof n.message||!n.message.length)return void $(".im_message_text",t).hide();var a=i.wrapMessageText(n.mid);$(".im_message_text",t).html(a.valueOf())}function l(e,t,n){if(!n.media)return void $(".im_message_media",t).hide();var a=e.$new(!0);a.media=n.media,a.messageId=n.mid,m(a,function(e){$(".im_message_media",t).replaceWith(e)})}function c(e,t,n){if(!n.signID)return void $(".im_message_sign",t).hide();var a=e.$new(!0);a.signID=n.signID,h(a,function(e){$(".im_message_sign",t).replaceWith(e)})}function d(e,t,n){if(!n.reply_markup||"replyInlineMarkup"!=n.reply_markup._)return void $(".im_message_keyboard",t).hide();var a=e.$new(!0);a.markup=i.wrapReplyMarkup(n.reply_markup,n.fromID),a.messageId=n.mid,g(a,function(e){$(".im_message_keyboard",t).replaceWith(e)}),a.$on("reply_inline_button_press",function(e,t){switch(t._){case"keyboardButtonSwitchInline":s.switchInlineButtonClick(n.mid,t);break;case"keyboardButtonCallback":s.callbackButtonClick(n.mid,t);break;case"keyboardButtonGame":s.gameButtonClick(n.mid)}})}function p(e,t,n){r(e,t,n),l(e,t,n),c(e,t,n),d(e,t,n)}function u(e,t,n){var a=e.message;a.dir=!0;var i=a.mid;if(p(e,t,a),a.pending)var s=e.$on("messages_pending",function(){a.mid!=i&&(p(e,t,a),s())});e.$on("message_edit",function(n,i){i.mid==a.mid&&(i.justMedia?l(e,t,a):p(e,t,a))})}var m=e('
    '),g=e('
    '),h=e('
    ');return{link:u,scope:{message:"=myMessageBody"}}}]).directive("myMessageViews",["$filter","AppMessagesManager",function(e,t){function n(e,t){t.html(i(e))}function a(e,a,i){var s=e.$eval(i.myMessageViews),o=t.getMessage(s).views||0;n(o,a),e.$on("message_views",function(e,t){t.mid==s&&n(t.views,a)})}var i=e("formatShortNumber");return{link:a}}]).directive("myReplyMarkup",function(){function e(e,t,n){var a=$(".reply_markup",t),i=new Scroller(a,{classPrefix:"reply_markup",maxHeight:170});e.buttonClick=function(t){e.$emit("reply_button_press",t)},e.$on("ui_keyboard_update",function(t,n){onContentLoaded(function(){i.updateHeight(),i.scrollTo(0),e.$emit("ui_panel_update",{blur:n&&n.enabled})})}),onContentLoaded(function(){i.updateHeight(),e.$emit("ui_panel_update")})}return{templateUrl:templateUrl("reply_markup"),scope:{replyMarkup:"=myReplyMarkup"},link:e}}).directive("myMessageMedia",function(){return{scope:{media:"=myMessageMedia",messageId:"=messageId"},templateUrl:templateUrl("message_media")}}).directive("myMessagePhoto",["AppPhotosManager",function(e){return{scope:{media:"=myMessagePhoto",messageId:"=messageId"},templateUrl:templateUrl("message_attach_photo"),link:function(t,n,a){t.openPhoto=e.openPhoto,t.preloadPhoto=e.preloadPhoto}}}]).directive("myMessageDocument",["AppDocsManager",function(e){return{scope:{media:"=myMessageDocument",messageId:"=messageId"},templateUrl:templateUrl("message_attach_document"),link:function(t,n,a){if(e.updateDocDownloaded(t.media.document.id),t.docSave=function(){e.saveDocFile(t.media.document.id)},t.docOpen=function(){return t.media.document.withPreview?void e.openDoc(t.media.document.id,t.messageId):t.docSave()},t.videoOpen=function(){e.openVideo(t.media.document.id,t.messageId)},t.media.document.file_name){var i=t.media.document.file_name.split(".");i.length>1?(t.media_file_ext="."+i.pop(),t.media_file_name_without_ext=i.join("."),t.media_file_name_without_ext||(t.media_file_name_without_ext=t.media_file_ext,t.media_file_ext="")):(t.media_file_ext="",t.media_file_name_without_ext=i[0])}}}}]).directive("myMessageGeo",function(){return{scope:{media:"=myMessageGeo"},templateUrl:templateUrl("message_attach_geo")}}).directive("myMessageVenue",function(){return{scope:{media:"=myMessageVenue"},templateUrl:templateUrl("message_attach_venue")}}).directive("myMessageContact",function(){return{scope:{media:"=myMessageContact"},templateUrl:templateUrl("message_attach_contact")}}).directive("myMessageWebpage",["AppWebPagesManager","AppPhotosManager",function(e,t){return{scope:{media:"=myMessageWebpage",messageId:"=messageId"},templateUrl:templateUrl("message_attach_webpage"),link:function(n){n.openPhoto=t.openPhoto,n.openEmbed=function(t){if(n.media.webpage&&n.media.webpage.embed_url)return e.openEmbed(n.media.webpage.id,n.messageId),cancelEvent(t)},n.$on("webpage_updated",function(e,t){n.media.webpage&&n.media.webpage.id==t.id&&n.$emit("ui_height")})}}}]).directive("myMessageGame",["AppInlineBotsManager","AppMessagesManager",function(e,t){return{scope:{media:"=myMessageGame",messageId:"=messageId"},templateUrl:templateUrl("message_attach_game"),link:function(n,a){function i(e){var i=t.getMessage(n.messageId);if(i.message){var s=t.wrapMessageText(n.messageId);$(".im_message_game_message",a).html(s.valueOf()).show(),$(".im_message_game_description",a).hide()}else $(".im_message_game_message",a).html("").hide(),$(".im_message_game_description",a).show()}n.openGame=function(){e.gameButtonClick(n.messageId)},n.$on("message_edit",function(e,t){t.mid==n.messageId&&i()}),i()}}}]).directive("myMessagePending",function(){function e(e,t,n){if(e.media.file_name){var a=e.media.file_name.split(".");a.length>1?(e.media_file_ext="."+a.pop(),e.media_file_name_without_ext=a.join("."),e.media_file_name_without_ext||(e.media_file_name_without_ext=e.media_file_ext,e.media_file_ext="")):(e.media_file_ext="",e.media_file_name_without_ext=a[0])}}return{scope:{media:"=myMessagePending"},templateUrl:templateUrl("message_attach_pending"),link:e}}).directive("myInlineReplyMarkup",function(){function e(e,t,n){e.buttonClick=function(t){e.$emit("reply_inline_button_press",t)}}return{templateUrl:templateUrl("reply_markup"),scope:{replyMarkup:"=myInlineReplyMarkup"},link:e}}).directive("myServiceMessage",["ErrorService","AppMessagesManager",function(e,t){function n(n,a,i){n.phoneCallClick=function(n){var a=t.getMessage(n),i=t.getMessagePeer(a);e.show({error:{type:"PHONECALLS_NOT_SUPPORTED",userID:i}})}}return{templateUrl:templateUrl("message_service"),scope:{historyMessage:"=myServiceMessage"},link:n}}]).directive("myShortMessage",function(){return{scope:{message:"=myShortMessage"},templateUrl:templateUrl("short_message")}}).directive("myReplyMessage",["AppMessagesManager","AppPeersManager","$rootScope",function(e,t,n){function a(e,t,n){if(n.watch)e.$parent.$watch(n.myReplyMessage,function(a){var s=e.$parent.$eval(n.edit);i(e,t,a,s)});else{var a=e.$parent.$eval(n.myReplyMessage),s=e.$parent.$eval(n.edit);i(e,t,a,s)}}function i(t,n,a,i){var o=t.replyMessage=e.wrapSingleMessage(a);if(t.isEdit=i||!1,o.loading)var r=t.$on("messages_downloaded",function(i,o){o.indexOf(a)!=-1&&(t.replyMessage=e.wrapForDialog(a),s(t,n),r())});else s(t,n)}function s(a,i){var s=a.replyMessage;return s&&!s.deleted&&s.to_id?(a.thumb=e.getMessageThumb(s,42,42),"A"==i[0].tagName&&i.on("click",function(){var a=e.getMessagePeer(s),i=t.getPeerString(a);n.$broadcast("history_focus",{peerString:i,messageID:s.mid})}),void onContentLoaded(function(){a.$emit("ui_height")})):void $(i).remove()}return{templateUrl:templateUrl("reply_message"),scope:{},link:a}}]).directive("myPinnedMessage",["AppMessagesManager","AppPeersManager","$rootScope",function(e,t,n){function a(t,n,a){var s=t.$parent.$eval(a.myPinnedMessage),o=t.pinnedMessage=e.wrapSingleMessage(s);if(o.loading)var r=t.$on("messages_downloaded",function(a,o){o.indexOf(s)!=-1&&(t.pinnedMessage=e.wrapForDialog(s),i(t,n),r())});else i(t,n)}function i(a,i){var s=a.pinnedMessage;return s&&!s.deleted&&s.to_id?("A"==i[0].tagName&&i.on("click",function(){var a=e.getMessagePeer(s),i=t.getPeerString(a);n.$broadcast("history_focus",{peerString:i,messageID:s.mid})}),void onContentLoaded(function(){a.$emit("ui_height")})):void $(i).remove()}return{templateUrl:templateUrl("pinned_message"),scope:{},link:a}}]).directive("myForwardedMessages",["AppPhotosManager","AppMessagesManager","AppPeersManager","$rootScope",function(e,t,n,a){function i(e,t,n){n.watch?e.$watch("forwardMessages",function(){s(e,t)}):s(e,t)}function s(e,n){var a=e.forwardMessages,i=a.length,s=!1,o=1==i;e.thumb=!1,e.singleMessage=!1,angular.forEach(a,function(n){var a=t.getMessage(n);s===!1?s=a.fromID:s!==a.fromID&&(s=t.getMessagePeer(a)),o&&(e.thumb=t.getMessageThumb(a,42,42),e.singleMessage=t.wrapForDialog(n))}),e.fromID=s,e.count=i,onContentLoaded(function(){e.$emit("ui_height")})}return{templateUrl:templateUrl("forwarded_messages"),scope:{forwardMessages:"=myForwardedMessages"},link:i}}]).directive("myMessageEdited",["_","$timeout","AppMessagesManager",function(e,t,n){function a(e,t,n){var a=e.$parent.$eval(n.myMessageEdited);i(e,t,a)&&e.$on("message_edit",function(a,s){var o=e.$parent.$eval(n.myMessageEdited);s.mid==o&&i(e,t,o)})}function i(e,a,i){var o=n.getMessage(i);return o.canBeEdited?!o.edit_date||(a.html(s).show(),t(function(){e.$destroy()}),!1):(t(function(){e.$destroy(),a.remove()}),!1)}var s=e("message_edited");return{scope:{},link:a}}]).directive("myDialogs",["$modalStack","$transition","$window","$timeout",function(e,t,n,a){function i(t,i,s){function o(n){if(!u&&e.getTop())return!0;var a,i,s;if(36==n.keyCode&&!n.shiftKey&&!n.ctrlKey&&n.altKey)return a=$(l).find(".im_dialog_wrap a"),a.length&&($(a[0]).trigger("mousedown"),l.scrollTop=0,$(r).nanoScroller({flash:!0})),cancelEvent(n);if(27==n.keyCode||9==n.keyCode&&n.shiftKey&&!n.ctrlKey&&!n.metaKey)return u?c.value?$(p).trigger("click"):(t.$emit("esc_no_more"),setTimeout(function(){c.blur(),setTimeout(function(){c.focus()},0)},100)):(setFieldSelection(c),c.value&&c.select()),cancelEvent(n);if(u&&13==n.keyCode&&!Config.Navigator.mobile)return a=$(l).find(".im_dialog_selected")[0]||$(l).find(".im_dialog_wrap a")[0],a&&!$(a).hasClass("disabled")&&$(a).trigger("mousedown"),cancelEvent(n);if(!Config.Navigator.osX&&n.altKey&&n.shiftKey&&!n.ctrlKey&&!n.metaKey&&n.keyCode>=49&&n.keyCode<=57||Config.Navigator.osX&&n.ctrlKey&&n.shiftKey&&!n.metaKey&&!n.altKey&&n.keyCode>=49&&n.keyCode<=57){var o=n.keyCode-49;return s=$(l).find(".im_dialog_wrap"),i=s[o],i&&($(i).find("a").trigger("mousedown"),scrollToNode(l,i,r)),cancelEvent(n)}var d,m,g,h=Config.Modes.packed;if(40==n.keyCode||38==n.keyCode?(d=40==n.keyCode,m=!d,g=!n.shiftKey&&n.altKey):h&&9==n.keyCode&&n.ctrlKey&&!n.metaKey&&(d=!n.shiftKey,m=!d,g=!0),d||m){if(!g&&(!u||n.metaKey))return!0;a=!g&&$(l).find(".im_dialog_selected")[0]||$(l).find(".active a.im_dialog")[0];var f=a&&a.parentNode;if(f){if(i=a[d?"nextSibling":"previousSibling"],!i||!i.className||i.className.indexOf("im_dialog_wrap")==-1){s=$(l).find(".im_dialog_wrap");var _=s.index(a.parentNode),v=_+(d?1:-1);i=s[v]}}else s=$(l).find(".im_dialog_wrap"),i=d?s[0]:s[s.length-1];return g?i&&$(i).find("a").trigger("mousedown"):(f&&i&&$(f).find("a").removeClass("im_dialog_selected"),i&&$(i).find("a").addClass("im_dialog_selected")),i&&scrollToNode(l,i,r),cancelEvent(n)}}var r=$(".im_dialogs_wrap",i)[0],l=$(".im_dialogs_scrollable_wrap",i)[0],c=$(".im_dialogs_search_field",i)[0],d=$(".im_dialogs_panel",i)[0],p=$(".im_dialogs_search_clear",i)[0],u=!1;$(c).on("focus blur",function(e){u="focus"==e.type,u||($(l).find(".im_dialog_selected").removeClass("im_dialog_selected"),c.value||t.$emit("ui_dialogs_search_clear"))}),t.$on("dialogs_search_toggle",function(){$(d).addClass("im_dialogs_panel_search"),t.$broadcast("ui_dialogs_search"),$(n).scrollTop(0),a(function(){setFieldSelection(c)})}),t.$on("search_clear",function(){$(d).removeClass("im_dialogs_panel_search"),t.$broadcast("ui_dialogs_search")}),$(document).on("keydown",o),t.$on("$destroy",function(){$(document).off("keydown",o)}),t.$on("ui_dialogs_change",function(){onContentLoaded(function(){var e=$(l).find(".active a.im_dialog")[0];e&&scrollToNode(l,e.parentNode,r)})})}return{link:i}}]).directive("myDialogsList",["$window","$timeout",function(e,t){function n(n,a,i){function s(){if(p&&p.offsetHeight||(p=$(d)[0]),i.modal){var t=$(e).height()-(p?p.offsetHeight:49)-(Config.Mobile?46:100);return t=Math.min(Config.Mobile?350:450,t),$(a).css({height:t}),void g()}c&&c.offsetHeight||(c=$(".tg_page_head")[0]),u&&u.offsetHeight||(u=$(".footer_wrap")[0]),r&&r.offsetHeight||(r=$(".im_dialogs_col_wrap")[0]);var n=u?u.offsetHeight:0;n&&n++,$(a).css({height:$(e).height()-n-(c?c.offsetHeight:48)-(p?p.offsetHeight:58)-parseInt($(r).css("paddingBottom")||0)}),g()}var o=$(".im_dialogs_wrap",a)[0],r=$(".im_dialogs_col_wrap")[0],l=$(".im_dialogs_scrollable_wrap",a)[0],c=$(".tg_page_head")[0],d=Config.Mobile&&i.modal?".mobile_modal_body .im_dialogs_panel":".im_dialogs_panel",p=$(d)[0],u=$(".footer_wrap")[0],m=!1;onContentLoaded(function(){$(o).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0})});var g=function(){onContentLoaded(function(){$(o).nanoScroller()})};n.$on("ui_dialogs_prepend",g),n.$on("ui_dialogs_search",s),n.$on("ui_dialogs_update",s),n.$on("ui_dialogs_append",function(){onContentLoaded(function(){g(),m=!1,t(function(){$(l).trigger("scroll")})})}),n.$on("ui_dialogs_change",function(){onContentLoaded(function(){g(),m=!1,t(function(){$(l).trigger("scroll")})})}),$(l).on("scroll",function(e){a.is(":visible")&&!m&&l.scrollTop>=l.scrollHeight-l.clientHeight-300&&(n.$emit("dialogs_need_more"),m=!0)}),$(e).on("resize",s),s(),setTimeout(s,1e3)}return{link:n}}]).directive("myContactsList",["$window","$timeout",function(e,t){function n(t,n,a){function i(){$(n).css({height:$(e).height()-(o&&o.offsetHeight||0)-(s&&s.offsetHeight||0)-(Config.Mobile?64:200)}),$(r).nanoScroller()}var s=$(".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:n}}]).directive("myCountriesList",["$window","$timeout",function(e,t){function n(t,n,a){function i(){$(n).css({height:$(e).height()-(o&&o.offsetHeight||0)-(s&&s.offsetHeight||0)-(Config.Mobile?64:200)}),$(r).nanoScroller()}var s=$(".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:n}}]).directive("mySessionsList",["$window","$timeout",function(e,t){function n(t,n,a){function i(){$(n).css({height:Math.min(760,$(e).height()-(Config.Mobile?64:200))}),$(s).nanoScroller()}var s=$(".sessions_wrap",n)[0];onContentLoaded(function(){$(s).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0}),i()}),$(e).on("resize",i)}return{link:n}}]).directive("myStickersList",["$window","$timeout",function(e,t){function n(t,n,a){function i(){$(n).css({height:Math.min(600,$(e).height()-(Config.Mobile?64:200))}),$(s).nanoScroller()}var s=$(".stickerset_wrap",n)[0];onContentLoaded(function(){$(s).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0}),i()}),$(e).on("resize",i)}return{link:n}}]).directive("myHistory",["$window","$timeout","$rootScope","$transition",function(e,t,n,a){function i(i,s,o){function r(e,n){var a,i,s,o=!1;if(!e&&(i=$(".im_message_focus:visible",u)[0])){var r=u.clientHeight,l=u.scrollTop,c=i.offsetTop,d=i.clientHeight;(!l||l+rc+d||n)&&(o=Math.max(0,c-Math.floor(r/2)+26)),A=!1,s=function(){var e=$(i).data("unfocus_promise");e&&(t.cancel(e),$(i).removeClass("im_message_focus_active")),t(function(){$(i).addClass("im_message_focus_active"), -e=t(function(){$(i).removeClass("im_message_focus_active"),$(i).data("unfocus_promise",!1)},2800),$(i).data("unfocus_promise",e)})}}else(a=$(".im_message_unread_split:visible",u)[0])?(o=Math.max(0,a.offsetTop-52),A=!1):(o=u.scrollHeight,A=!0);if(o!==!1){var p=function(){C(),t(function(){$(u).trigger("scroll"),E=u.scrollTop}),s&&s()};n?$(u).animate({scrollTop:o},200,p):(u.scrollTop=o,p())}}function l(t){if(s.is(":visible")||$(s[0].parentNode.parentNode).is(":visible")){$(f).is(":visible")&&$(f).css({height:$(y).height()}),_&&_.offsetHeight||(_=$(".tg_page_head")[0]),v&&v.offsetHeight||(v=$(".footer_wrap")[0]);var n=v?v.offsetHeight:0;n&&n++;var a=$(e).height()-h.offsetHeight-(_?_.offsetHeight:48)-n;$(d).css({height:a}),c(),t!==!0&&(A&&onContentLoaded(function(){u.scrollTop=u.scrollHeight,C()}),C(100))}}function c(){$(p).css({marginTop:0});var e=u.offsetHeight-p.offsetHeight-g.offsetHeight-(Config.Mobile?0:39);p.offsetHeight>0&&e>0&&$(p).css({marginTop:e}),$(d).nanoScroller()}var d=$(".im_history_wrap",s)[0],p=$(".im_history_messages",s)[0],u=($(".im_history",s)[0],$(".im_history_scrollable_wrap",s)[0]),m=$(".im_history_scrollable",s)[0],g=$(".im_history_empty_wrap",s)[0],h=$(".im_bottom_panel_wrap",s)[0],f=$(".im_send_form_wrap",s)[0],_=$(".tg_page_head")[0],v=$(".footer_wrap")[0],y=$(".im_send_form",s)[0],b=!1,w=!1;onContentLoaded(function(){u.scrollTop=u.scrollHeight}),$(d).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0});var k,C=function(e){t(function(){$(u).hasClass("im_history_to_bottom")||$(d).nanoScroller()},e||0)},S=!1,M=["transform","webkitTransform","MozTransform","msTransform","OTransform"];for(k=0;k0;if(s)i=u.scrollHeight;else{var o=parseInt($(u).css("paddingRight"));$(m).css({bottom:0,paddingRight:o}),$(u).addClass("im_history_to_bottom")}onContentLoaded(function(){if(s){I=!0,$(p).removeClass("im_history_appending"),u.scrollTop=u.scrollHeight,$(p).css(S,"translate(0px, "+(u.scrollHeight-i)+"px)"),$(d).nanoScroller();var e={};e[S]="translate(0px, 0px)",$(p).addClass("im_history_appending"),a($(p),e).then(function(){I=!1,$(p).removeClass("im_history_appending"),c()})}else $(u).removeClass("im_history_to_bottom"),$(m).css({bottom:"",paddingRight:0}),u.scrollTop=u.scrollHeight,c()})}),i.$on("history_direction_key",function(e,t){var n=!1;switch(console.warn("scroll top",t.keyCode),t.keyCode){case 33:n=u.scrollTop-u.clientHeight;break;case 34:n=u.scrollTop+u.clientHeight;break;case 36:n=0;break;case 35:n=u.scrollHeight}n!==!1&&$(u).stop().animate({scrollTop:n},200)}),i.$on("ui_history_change",function(){var e=parseInt($(u).css("paddingRight"));$(u).addClass("im_history_to_bottom"),u.scrollHeight,$(m).css({bottom:0,paddingRight:e}),onContentLoaded(function(){$(u).removeClass("im_history_to_bottom"),$(m).css({bottom:"",paddingRight:""}),l(!0),b=!1,w=!1,r()})}),i.$on("ui_history_change_scroll",function(e,t){onContentLoaded(function(){r(!1,t)})}),i.$on("ui_history_focus",function(){A||(u.scrollTop=u.scrollHeight,C(),A=!0)}),i.$on("ui_history_prepend",function(){var e=u.scrollHeight,n=u.scrollTop,a=parseInt($(u).css("paddingRight")),s=u.clientHeight;$(u).addClass("im_history_to_bottom"),u.scrollHeight,$(m).css({bottom:-(e-n-s),paddingRight:a});var o=function(){$(u).removeClass("im_history_to_bottom"),$(m).css({bottom:"",paddingRight:""}),E>=0?r():u.scrollTop=n+u.scrollHeight-e,c(),b=!1,t(function(){u.scrollHeight!=e&&$(u).trigger("scroll")}),clearTimeout(l),d()},l=setTimeout(o,0),d=i.$on("$viewContentLoaded",o)}),i.$on("ui_history_append",function(){var e=u.scrollHeight;onContentLoaded(function(){A=!1,c(),w=!1,E>=0&&r(),t(function(){u.scrollHeight!=e&&$(u).trigger("scroll")})})}),i.$on("ui_panel_update",function(e,n){l(),onContentLoaded(function(){l(),n&&n.blur?i.$broadcast("ui_message_blur"):getSelectedText()||i.$broadcast("ui_message_send"),t(function(){$(u).trigger("scroll")})})}),i.$on("ui_selection_clear",function(){window.getSelection?window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().removeAllRanges():document.selection&&document.selection.empty()}),i.$on("ui_editor_resize",l),i.$on("ui_height",function(){onContentLoaded(l)});var A=!0,E=-1;$(u).on("scroll",function(e){if(s.is(":visible")&&!$(u).hasClass("im_history_to_bottom")&&!I){var t=u.scrollTop;A=t>=u.scrollHeight-u.clientHeight,E>=0&&E!=t&&(E=-1),!b&&t<=300?(b=!0,i.$emit("history_need_more")):!w&&t>=u.scrollHeight-u.clientHeight-300&&(w=!0,i.$emit("history_need_less"))}}),$(e).on("resize",l),l(),onContentLoaded(l)}return{link:i}}]).directive("mySendForm",["_","$q","$timeout","$compile","$modalStack","$http","$interpolate","Storage","AppStickersManager","AppDocsManager","ErrorService","AppInlineBotsManager","FileManager","shouldFocusOnInteraction",function(e,t,n,a,i,s,o,r,l,c,d,p,u,m){function g(s,o,g){function h(){r.get("send_ctrlenter").then(function(e){H=!e})}function f(e){return n(function(){y(),s.draftMessage.send(),L.resetTyping(),O&&O.update(),L.hideSuggestions()},m?0:100),cancelEvent(e)}function _(e){s.$apply(function(){s.draftMessage.inlineResultID=e})}function v(e){return 38==e.keyCode?(s.$emit("last_message_edit"),cancelEvent(e)):(s.$emit("history_direction_key",e),!0)}function y(){j&&(L.onChange(),b())}function b(){var e=j.offsetHeight;q!=e&&(q=e,s.$emit("ui_editor_resize"))}function w(e){if(!(9!=e.keyCode||e.shiftKey||e.ctrlKey||e.metaKey||i.getTop()))return L.focus(),cancelEvent(e)}function k(){onContentLoaded(function(){L.focus()})}function C(e){var n=e.type||"",a=t.when(!1);["image/jpeg","image/gif","image/png","image/bmp"].indexOf(n)>=0&&(a=u.getFileCorrectUrl(e,n)),a.then(function(t){t=t||!1,d.confirm({type:"FILE_CLIPBOARD_PASTE",fileUrl:t}).then(function(){s.draftMessage.files=[e],s.draftMessage.isMedia=!0})})}function S(e){var t,n,a=(e.originalEvent||e).clipboardData,i=a&&a.items||[],o=[];for(t=0;t0){if(1==o.length)return C(o[0]);d.confirm({type:"FILES_CLIPBOARD_PASTE",files:o}).then(function(){s.draftMessage.files=o,s.draftMessage.isMedia=!0})}}function M(e){var t=!1;return x&&1!=x||(x=checkDragEvent(e)?2:1,t=!0),2==x&&(I&&setTimeout(function(){clearTimeout(I),I=!1},0),"dragenter"==e.type||"dragover"==e.type?t&&(Config.Mobile||$(E).hide(),$(P).css({height:F.offsetHeight+2,width:F.offsetWidth}).show()):("drop"==e.type&&s.$apply(function(){s.draftMessage.files=Array.prototype.slice.call(e.originalEvent.dataTransfer.files),s.draftMessage.isMedia=!0}),I=setTimeout(function(){$(P).hide(),Config.Mobile||$(E).show(),x=!1,I=!1},300))),cancelEvent(e)}var x,I,A=$("textarea",o)[0],E=$(".composer_emoji_insert_btn",o)[0],T=$(".composer_emoji_panel",o)[0],D=$("input",o),P=$(".im_send_dropbox_wrap",o)[0],F=$(".im_send_field_wrap",o)[0],R=$(".im_submit",o)[0],N=a(''),B={},U=new EmojiTooltip(E,{getStickers:function(e){l.getStickers().then(e)},getStickerImage:function(e,t){var n=e.attr("data-category"),a=B[t];if(a&&!isInDOM(a[0]))return a.attr("data-category",n),void e.replaceWith(a);var i=s.$new(!0);i.document=c.getDoc(t),N(i,function(a){B[t]=a,a.attr("data-category",n),e.replaceWith(a)})},onStickersetSelected:function(e){l.openStickersetLink(e)},onEmojiSelected:function(e){s.$apply(function(){L.onEmojiSelected(e)})},onStickerSelected:function(e){s.$apply(function(){s.draftMessage.sticker=e})},langpack:{im_emoji_tab:e("im_emoji_tab"),im_stickers_tab:e("im_stickers_tab")}});s.$on("stickers_changed",function(){U.onStickersChanged()});var O;T&&(O=new EmojiPanel(T,{onEmojiSelected:function(e){L.onEmojiSelected(e)}}));var L=new MessageComposer(A,{onTyping:function(){s.$emit("ui_typing")},getSendOnEnter:function(){return H},dropdownDirective:function(e,t){var n=s.$new(!0);a("
    ")(n,function(n,a){e.replaceWith(n),t(a,n)})},mentions:s.mentions,commands:s.commands,onMessageSubmit:f,onDirectionKey:v,onInlineResultSend:_,onFilePaste:C,onCommandSend:function(e){s.$apply(function(){s.draftMessage.command=e})}}),j=L.richTextareaEl&&L.richTextareaEl[0];j&&$(j).on("keydown keyup",b),s.$on("inline_results",function(e,t){var n=Config.Mobile?$(window).width():(F.offsetWidth||382)-2,a=80;t&&p.regroupWrappedResults(t.results,n,a),setZeroTimeout(function(){L.setInlineSuggestions(t)})}),s.$on("inline_placeholder",function(e,t){L.setInlinePlaceholder(t.prefix,t.placeholder)}),D.on("change",function(){var e=this;s.$apply(function(){s.draftMessage.files=Array.prototype.slice.call(e.files),s.draftMessage.isMedia=$(e).hasClass("im_media_attach_input")||Config.Mobile,setTimeout(function(){try{e.value=""}catch(t){}},1e3)})});var H=!0;s.$on("settings_changed",h),h(),$(R).on("mousedown touchstart",f);var q=j&&j.offsetHeight;$(document).on("keydown",w),$("body").on("dragenter dragleave dragover drop",M),$(document).on("paste",S),m&&(s.$on("ui_peer_change",k),s.$on("ui_history_focus",k),s.$on("ui_history_change",k)),s.$on("ui_peer_change",L.resetTyping.bind(L)),s.$on("ui_peer_draft",function(t,n){n=n||{};var a=s.draftMessage.isBroadcast;L.setPlaceholder(e(a?"im_broadcast_field_placeholder_raw":"im_message_field_placeholder_raw")),n.customSelection?(L.setFocusedValue(n.customSelection),b()):(j&&(L.setValue(s.draftMessage.text||""),b()),(m||n&&n.focus)&&L.focus()),onContentLoaded(function(){L.checkAutocomplete(!0)}),U&&Config.Mobile&&U.hide()}),s.$on("ui_peer_reply",function(){onContentLoaded(function(){s.$emit("ui_editor_resize"),m&&L.focus()})}),s.$on("mentions_update",function(){L.onMentionsUpdated()}),s.$on("ui_message_before_send",function(){y()}),s.$on("ui_message_send",function(){m&&k()}),s.$on("ui_message_blur",function(){L.blur()}),s.$on("$destroy",function(){$(document).off("paste",S),$(document).off("keydown",w),$("body").off("dragenter dragleave dragover drop",M),$(R).off("mousedown touchstart"),D.off("change")}),m&&k()}return{link:g,scope:{draftMessage:"=",mentions:"=",commands:"="}}}]).directive("myLoadThumb",["MtpApiFileManager","FileManager",function(e,t){function n(n,a,i){var s=0,o=e.getCachedFile(n.thumb&&n.thumb.location&&!n.thumb.location.empty&&n.thumb.location);o&&a.attr("src",t.getUrl(o,"image/jpeg")),n.thumb&&n.thumb.width&&n.thumb.height&&(a.attr("width",n.thumb.width),a.attr("height",n.thumb.height));var r=n.$watchCollection("thumb.location",function(i){n.thumb&&n.thumb.width&&n.thumb.height&&(a.attr("width",n.thumb.width),a.attr("height",n.thumb.height),n.$emit("ui_height"));var o=++s;if(!i||i.empty)return a.attr("src",n.thumb&&n.thumb.placeholder||"img/blank.gif"),void l();var r=e.getCachedFile(i);return r?(a.attr("src",t.getUrl(r,"image/jpeg")),void l()):(a.attr("src")||a.attr("src",n.thumb.placeholder||"img/blank.gif"),void e.downloadSmallFile(n.thumb.location).then(function(e){o==s&&(a.attr("src",t.getUrl(e,"image/jpeg")),l())},function(e){console.log("Download image failed",e,n.thumb.location,a[0]),o==s&&(a.attr("src",n.thumb.placeholder||"img/blank.gif"),l())}))}),l=i.watch?angular.noop:function(){setTimeout(function(){n.$destroy(),r()},0)}}return{link:n,scope:{thumb:"="}}}]).directive("myLoadFullPhoto",["MtpApiFileManager","FileManager","_",function(e,t,n){function a(a,i,s){var o=$("img",i)[0],r=$(".img_fullsize_with_progress_wrap",i).add(".img_fullsize_progress_wrap",i).add($(o)),l=function(){r.css({width:a.fullPhoto.width,height:a.fullPhoto.height}),a.$emit("ui_height",!0)},c=0;a.$watchCollection("fullPhoto.location",function(){var i=e.getCachedFile(a.thumbLocation),s=++c;if(i?(o.src=t.getUrl(i,"image/jpeg"),l()):o.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",a.fullPhoto.location){var r;if(a.fullPhoto.size){var d={_:"inputFileLocation",volume_id:a.fullPhoto.location.volume_id,local_id:a.fullPhoto.location.local_id,secret:a.fullPhoto.location.secret};r=e.downloadFile(a.fullPhoto.location.dc_id,d,a.fullPhoto.size)}else r=e.downloadSmallFile(a.fullPhoto.location);a.progress={enabled:!0,percent:0},r.then(function(e){s==c&&(a.progress.enabled=!1,o.src=t.getUrl(e,"image/jpeg"),l())},function(e){console.log("Download image failed",e,a.fullPhoto.location),a.progress.enabled=!1,e&&"FS_BROWSER_UNSUPPORTED"==e.type?a.error={html:n("error_browser_no_local_file_system_image_md",{"moz-link":'{1}',"chrome-link":'{1}',"telegram-link":'{1}'})}:a.error={text:n("error_image_download_failed"),error:e}},function(e){a.progress.percent=Math.max(1,Math.floor(100*e.done/e.total))})}}),l()}return{link:a,transclude:!0,templateUrl:templateUrl("full_photo"),scope:{fullPhoto:"=",thumbLocation:"="}}}]).directive("myLoadVideo",["$sce","AppDocsManager","ErrorService","_",function(e,t,n,a){function i(e,i,s){var o=t.downloadDoc(e.video.id);o.then(function(){e.$emit("ui_height"),onContentLoaded(function(){var e=$("video",i)[0];if(e){var t=!1,a=function(e){t||e.target&&e.target.error&&e.target.error.code!=e.target.error.MEDIA_ERR_DECODE&&e.target.error.code!=e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED||(t=!0,n.show({error:{type:"MEDIA_TYPE_NOT_SUPPORTED",originalError:e.target&&e.target.error}}))};e.addEventListener("error",a,!0),$(e).on("$destroy",function(){t=!0,e.removeEventListener("error",a)})}})},function(t){console.log("Download video failed",t,e.video),t&&"FS_BROWSER_UNSUPPORTED"==t.type?e.error={html:a("error_browser_no_local_file_system_video_md",{"moz-link":'{1}',"chrome-link":'{1}',"telegram-link":'{1}'})}:e.error={text:a("error_video_download_failed"),error:t}}),e.$emit("ui_height"),e.$on("$destroy",function(){o.cancel()})}return{link:i,transclude:!0,templateUrl:templateUrl("full_video"),scope:{video:"="}}}]).directive("myLoadGif",["AppDocsManager","$timeout",function(e,t){function n(n,a,i){var s=$(".img_gif_image_wrap",a);s.css({width:n.document.thumb.width,height:n.document.thumb.height});var o=!1;n.isActive=!1,n.toggle=function(i){return i&&checkClick(i,!0)?(e.saveDocFile(n.document.id),!1):n.document.url?void onContentLoaded(function(){n.isActive=!n.isActive,n.$emit("ui_height");var e=$("video",a)[0];e&&(n.isActive?e.play():(e.pause(),e.currentTime=0))}):o?(o.cancel(),void(o=!1)):(o=e.downloadDoc(n.document.id),void o.then(function(){t(function(){n.isActive=!0},200)}))}}return{link:n,templateUrl:templateUrl("full_gif"),scope:{document:"="}}}]).directive("myLoadSticker",["_","MtpApiFileManager","FileManager","AppStickersManager",function(e,t,n,a){function i(i,o,r){var l=$("").addClass(r.imgClass),c=!1;l.attr("alt","["+(i.document.stickerEmojiRaw||"")+" "+e("conversation_media_sticker")+"]");var d=r.dim&&i.$parent.$eval(r.dim)||i.document.thumb;r.open&&i.document.stickerSetInput&&o.addClass("clickable").on("click",function(){a.openStickerset(i.document.stickerSetInput)});var p=function(e){l.attr("src",n.getUrl(e)),c||(c=!0,l.appendTo(o))};l.css({width:d.width,height:d.height}),o.css({width:d.width,height:d.height});var u=!1;i.document.thumb.location&&(u=angular.copy(i.document.thumb.location),u.sticker=!0);var m={_:"inputDocumentFileLocation",id:i.document.id,access_hash:i.document.access_hash,dc_id:i.document.dc_id,file_name:i.document.file_name,version:i.document.version,sticker:!0},g=t.getCachedFile(m),h=!1;if(g?h=!0:g=t.getCachedFile(u),g){if(p(g),h)return}else c=!0,l.attr("src",s).appendTo(o);r.thumb&&u?t.downloadSmallFile(u).then(function(e){p(e)},function(e){console.log("Download sticker failed",e,m)}):t.downloadFile(i.document.dc_id,m,i.document.size).then(function(e){p(e)},function(e){console.log("Download sticker failed",e,m)})}var s="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";return{link:i,scope:{document:"="}}}]).directive("myLoadDocument",["MtpApiFileManager","AppDocsManager","FileManager",function(e,t,n){function a(e,t){for(;e&&!$(e).hasClass("modal-dialog");)e=e.parentNode;e&&$(e).width(t+(Config.Mobile?0:32))}function i(i,s,o){var r=$(".document_fullsize_with_progress_wrap",s),l=$(".document_fullsize_wrap",s),c=$(".document_fullsize_img",s),d=$(window).width()-(Config.Mobile?20:32),p=$(window).height()-150;d>800&&(d-=208),i.imageWidth=d,i.imageHeight=p;var u=i.document.thumb;if(u&&"photoSizeEmpty"!=u._){var m=calcImageInBox(u.width,u.height,d,p);i.imageWidth=m.w,i.imageHeight=m.h;var g=e.getCachedFile(u.location);g&&(i.thumbSrc=n.getUrl(g,"image/jpeg"))}i.frameWidth=Math.max(i.imageWidth,Math.min(600,d)),i.frameHeight=i.imageHeight,onContentLoaded(function(){i.$emit("ui_height")}),a(s[0],i.frameWidth);var h,f,_;t.downloadDoc(i.document.id).then(function(e){var t=n.getUrl(e,i.document.mime_type),a=new Image,s=100,o=function(e){if(a.height&&a.width||!--s){f=a.width,_=a.height,clearInterval(h);var n=calcImageInBox(a.width,a.height,d,p,!0),o={w:f,h:_};n.w>=o.w&&n.h>=o.h&&(o.w*=4,o.h*=4);var u=!0;i.toggleZoom=function(){u=!u;var e=(u?o:n).w,t=(u?o:n).h;c.css({width:e,height:t,marginTop:i.frameHeight>t?Math.floor((i.frameHeight-t)/2):0}),l.toggleClass("document_fullsize_zoomed",u)},i.toggleZoom(!1),c.attr("src",t),r.hide(),l.css({width:i.frameWidth,height:i.frameHeight}).show()}};h=setInterval(o,20),a.onload=o,a.src=t,setZeroTimeout(o)})}return{link:i,templateUrl:templateUrl("full_document"),scope:{document:"=myLoadDocument"}}}]).directive("myGeoPointMap",["ExternalResourcesManager",function(e){function t(t,n,a){var i=n.attr("width")||200,s=n.attr("height")||200,o=Config.ExtCredentials.gmaps.api_key,r=i>200?15:13;n.attr("src","img/blank.gif");var l="https://maps.googleapis.com/maps/api/staticmap?sensor=false¢er="+t.point.lat+","+t.point["long"]+"&zoom="+r+"&size="+i+"x"+s+"&scale=2&markers=color:red|size:big|"+t.point.lat+","+t.point["long"],c=!0;c&&(l+="&key="+o),e.downloadByURL(l).then(function(e){n.attr("src",e.valueOf())})}return{link:t,scope:{point:"=myGeoPointMap"}}}]).directive("myLoadingDots",["$interval",function(e){function t(e,t,a){t.html(n(t[0])?'
    ':"...")}function n(e){if(void 0===a&&(a=void 0!==e.style.animationName,a===!1)){var t,n="Webkit Moz O ms Khtml".split(" ");for(t=0;t=a.scrollHeight-a.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,a,i){var s=function(){if(!Config.Mobile||!$(a[0].parentNode.parentNode.parentNode).hasClass("mobile_modal")){var e=a[0].parentNode.offsetHeight,n=a[0].parentNode.parentNode.parentNode,s=$(".media_modal_bottom_panel_wrap",n)[0],o=n.offsetHeight-(s&&s.offsetHeight||0);e1||1==n&&!s)&&(e=t("group_modal_participants",{total:e,online:p(n)}))}n||f||(e=""),o.html(e)};n.$watch(r.myChatStatus,function(e){m=e,v()}),e.$on("chat_full_update",function(e,t){m==t&&v()}),e.$on("user_update",function(e,t){_[t]&&y()}),c[g]=y,n.$on("$destroy",function(){delete c[g]})}var l=0,c={},d=t.pluralize("group_modal_pluralize_participants"),p=t.pluralize("group_modal_pluralize_online_participants"),u=0;return n.getUserID().then(function(e){u=e}),setInterval(o,9e4),{link:r}}]).directive("myPeerMuted",["$rootScope","NotificationsManager",function(e,t){function n(t,n,i){var s=t.$eval(i.myPeerMuted),o=i.mutedClass||"muted",r=e.$on("notify_settings",function(e,t){t.peerID==s&&a(s,n,o)});a(s,n,o),t.$on("$destroy",r)}function a(e,n,a){t.getPeerMuted(e).then(function(e){n.toggleClass(a,e)})}return{link:n}}]).directive("myPeerLink",["AppChatsManager","AppUsersManager",function(e,t){function n(n,a,i){var s,o=i.userOverride&&n.$eval(i.userOverride)||{},r=i["short"]&&n.$eval(i["short"]),l=i.username&&n.$eval(i.username),c=function(){if(a[0].className.indexOf("user_color_")!=-1&&(a[0].className=a[0].className.replace(/user_color_\d+/g,"")),s>0){var c=t.getUser(s),d=l?"@":"",p=l?"username":r?"rFirstName":"rFullName";a.html(d+(o[p]||c[p]||"").valueOf()+(i.verified&&c.pFlags&&c.pFlags.verified?' ':"")),i.color&&n.$eval(i.color)&&a.addClass("user_color_"+c.num)}else{var u=e.getChat(-s);a.html((u.rTitle||"").valueOf()+(i.verified&&u.pFlags&&u.pFlags.verified?' ':""))}};"A"!=a[0].tagName||hasOnclick(a[0])||a.on("click",function(){s>0?t.openUser(s,o):e.openChat(-s)}),i.peerWatch?n.$watch(i.myPeerLink,function(e){s=e,c()}):(s=n.$eval(i.myPeerLink),c()),i.noWatch||(n.$on("user_update",function(e,t){s==t&&c()}),n.$on("chat_update",function(e,t){s==-t&&c()}))}return{link:n}}]).directive("myPeerPhotolink",["AppPeersManager","AppUsersManager","AppChatsManager","MtpApiFileManager","FileManager",function(e,t,n,a,i){function s(s,o,r){o.addClass("peer_photo_init");var l,c,d,p=$(''),u=$(''),m=0,g=!1,h=function(t){if(l==t)return!1;l=t,c=e.getPeer(l);var n="user_bgcolor_"+(c.num||1);return n!=g&&(g&&u.removeClass(g),u.addClass(n),g=n),f(),!0},f=function(){var e=++m;d=c.photo&&angular.copy(c.photo.photo_small);var t=void 0!==d;if(t){var n=a.getCachedFile(c.photo.photo_small);if(n)return u.remove(),void p.prependTo(o).attr("src",i.getUrl(n,"image/jpeg"))}u.attr("data-content",c.initials||"").prependTo(o),p.remove(),t&&a.downloadSmallFile(c.photo.photo_small).then(function(t){e==m&&(u.remove(),p.prependTo(o).attr("src",i.getUrl(t,"image/jpeg")))},function(e){console.log("Download image failed",e,c.photo.photo_small,o[0])})};"A"!=o[0].tagName||r.noOpen||o.on("click",function(e){l>0?t.openUser(l,r.userOverride&&s.$eval(r.userOverride)):n.openChat(-l)}),s.$watch(r.myPeerPhotolink,h),h(s.$eval(r.myPeerPhotolink)),r.watch&&(s.$on("user_update",function(t,n){l==n&&(c=e.getPeer(l),angular.equals(c.photo&&c.photo.photo_small,d)&&d||f())}),s.$on("chat_update",function(e,t){l==-t&&(angular.equals(c.photo&&c.photo.photo_small,d)||f())}))}return{link:s}}]).directive("myAudioPlayer",["$timeout","$q","Storage","AppDocsManager","AppMessagesManager","ErrorService",function(e,t,n,a,i,s){function o(e){return e!==l&&(l&&l.pause(),void(l=e))}function r(e,t,r){a.updateDocDownloaded(e.audio.id),e.volume=c,e.mediaPlayer={},e.download=function(){a.saveDocFile(e.audio.id)},e.togglePlay=function(){e.audio.url?(o(e.mediaPlayer.player),e.mediaPlayer.player.playPause()):e.audio.progress&&e.audio.progress.enabled||a.downloadDoc(e.audio.id).then(function(){onContentLoaded(function(){var n=$("audio",t)[0]||t[0];if(n){var a=!1,r=function(e){a||e.target&&e.target.error&&e.target.error.code!=e.target.error.MEDIA_ERR_DECODE&&e.target.error.code!=e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED||(a=!0,s.show({error:{type:"MEDIA_TYPE_NOT_SUPPORTED",originalError:e.target&&e.target.error}}))};n.addEventListener("error",r,!0),e.$on("$destroy",function(){a=!0,n.removeEventListener("error",r)})}setTimeout(function(){o(e.mediaPlayer.player),e.mediaPlayer.player.setVolume(c),e.mediaPlayer.player.play(),e.message&&!e.message.pFlags.out&&e.message.pFlags.media_unread&&i.readMessages([e.message.mid])},300)})})},e.seek=function(t){e.mediaPlayer&&e.mediaPlayer.player?e.mediaPlayer.player.seek(t):e.togglePlay()},e.setVolume=function(t){c=t,n.set({audio_volume:t}),e.mediaPlayer&&e.mediaPlayer.player&&e.mediaPlayer.player.setVolume(t)}}var l=!1,c=.5;n.get("audio_volume").then(function(e){e>0&&e<=1&&(c=e)});return{link:r,scope:{audio:"=",message:"="},templateUrl:templateUrl("audio_player")}}]).directive("mySlider",["$window",function(e){function t(t,n,a){var i=$(".tg_slider_wrap",n),s=$(".tg_slider_track_fill",n),o=$(".tg_slider_thumb",n),r=i.width(),l=Math.ceil(o.width()),c=a.sliderModel,d=a.sliderOnchange,p=0,u=1,m=!1,g=!1;a.sliderMin&&t.$watch(a.sliderMin,function(e){p=e||0}),a.sliderMax&&t.$watch(a.sliderMax,function(e){u=e||1});var h=function(e){e=e.originalEvent||e;var n=(e.touches&&e.touches[0]?e.touches[0].pageX:e.pageX)-g;return n=Math.min(r,Math.max(0,n)),m=p+n/r*(u-p),d?t.$eval(d,{value:m}):t.$eval(c+"="+m),o.css("left",Math.max(0,n-l)),s.css("width",n),cancelEvent(e)},f=function(){$(e).off("mousemove touchmove",h),$(e).off("mouseup touchend touchcancel touchleave",f)};t.$watch(c,function(e){if(e!=m&&void 0!==e){var t=Math.max(0,(e-p)/(u-p));if(r){var n=Math.ceil(r*t);n=Math.min(r,Math.max(0,n)),o.css("left",Math.max(0,n-l)),s.css("width",n)}else o.css("left",100*t+"%"),s.css("width",100*t+"%");m=!1}}),n.on("dragstart selectstart",cancelEvent),n.on("mousedown touchstart",function(a){if(!r&&(r=i.width(),!r))return console.error("empty width"),cancelEvent(a);f(),a=a.originalEvent||a;var _;if(a.touches&&a.touches[0])g=n.position().left,_=a.touches[0].pageX-g;else if(void 0!==a.offsetX)_=a.offsetX,g=a.pageX-_;else{if(void 0===a.layerX)return cancelEvent(a);_=a.layerX,g=a.pageX-_}return m=p+_/r*(u-p),d?t.$eval(d,{value:m}):t.$eval(c+"="+m),o.css("left",Math.max(0,_-l)),s.css("width",_),$(e).on("mousemove touchmove",h),$(e).on("mouseup touchend touchcancel touchleave",f),cancelEvent(a)})}return{link:t,templateUrl:templateUrl("slider")}}]).directive("myLabeledInput",function(){function e(e,t,n){var a=$(".md-input:first",t),i=($(".md-input-label:first",t),a[0]&&"SPAN"==a[0].tagName),s=!1,o=function(){i?t.toggleClass("md-input-has-value",a.html().length>0):t.toggleClass("md-input-has-value",s||a.val().length>0)};o(),onContentLoaded(function(){o(),setZeroTimeout(function(){t.addClass("md-input-animated")})}),i||a.on("blur focus change",function(e){s="focus"==e.type,t.toggleClass("md-input-focused",s),o()}),e.$on("value_updated",function(){setZeroTimeout(function(){o()})})}return{link:e}}).directive("myCopyField",["toaster","_",function(e,t){function n(e,t,n){t.attr("readonly","true"),t[0].readonly=!0,t.on("click",function(){this.select()}),e.selectEvent&&e.$on(e.selectEvent,function(){setTimeout(function(){t[0].focus(),t[0].select()},100)})}return{scope:{selectEvent:"=myCopyField"},link:n}}]).directive("myCopyLink",["$compile","$timeout","_",function(e,t,n){function a(a,i,s){i.attr("tooltip","{{ttLabel}}"),i.removeAttr("my-copy-link"),i.removeAttr("data-my-copy-link");var o=!1,r=function(){t.cancel(o),o=!1,a.ttLabel=n("conversations_modal_share_url_copy_raw")};r(),e(i)(a);var l=new Clipboard(i[0]);l.on("success",function(e){t.cancel(o),a.$apply(function(){a.ttLabel=n("clipboard_copied_raw")}),o=t(r,2e3)}),l.on("error",function(e){t.cancel(o);var i=Config.Navigator.osX?"clipboard_press_cmd_c":"clipboard_press_ctrl_c";a.$apply(function(){a.ttLabel=n(i+"_raw")}),o=t(r,5e3)}),a.$on("$destroy",function(){l.destroy()})}return{restrict:"A",replace:!1,terminal:!0,priority:1e3,link:a}}]).directive("mySubmitOnEnter",function(){function e(e,t,n){t.on("keydown",function(e){if(13==e.keyCode)return t.trigger("submit"),cancelEvent(e)})}return{link:e}}).directive("myArcProgress",function(){function e(e,t,n){t=Math.max(0,Math.min(t,1));var a=.2;t=a+(1-a)*t,e.css({strokeDasharray:t*n+", "+(1-t)*n})}var t=' ',n=0;return{scope:{progress:"=myArcProgress"},link:function(a,i,s){var o=!s.myArcProgress,r=s.width||i.width()||40,l=s.stroke||r/2*.14,c=r/2,d=c-l/2,p=++n;i.html(t.replace("%id%",p)).addClass("progress-arc-wrap").addClass(o?"progress-arc-intermediate":"progress-arc-percent").css({width:r,height:r}),$(i[0].firstChild).attr("width",r).attr("height",r);var u=$(".progress-arc-bar",i);u.attr("cx",c).attr("cy",c).attr("r",d).css({strokeWidth:l});var m=2*Math.PI*d;o?(e(u,.3,m),u.css({stroke:"url(#grad_intermediate"+p+")"})):a.$watch("progress",function(t){e(u,t/100,m)})}}}).directive("myScrollToOn",function(){return{link:function(e,t,n){ -var a=n.myScrollToOn,i=function(){onContentLoaded(function(){$("html, body").animate({scrollTop:t.offset().top},200)})};"$init"==a?i():e.$on(a,i)}}}).directive("myComposerDropdown",function(){return{templateUrl:templateUrl("composer_dropdown")}}).directive("myEmojiSuggestions",function(){return{link:function(e,t,n){e.$watchCollection("emojiCodes",function(e){var n,a,i,s,o,r,l,c,d=[],p=Config.Mobile?26:20,u=Math.min(5,e.length);for(r=0;r:'+encodeEntities(a[1][0])+":"));t.html(d.join("")),console.log(dT(),"emoji done")})}}}).directive("myInlineResults",["AppPhotosManager","ExternalResourcesManager","AppDocsManager",function(e,t,n){return{templateUrl:templateUrl("inline_results"),scope:{botResults:"=myInlineResults"},link:function(a,i,s){a.$watch("botResults.results",function(a){angular.forEach(a,function(a){a.thumb_url&&!a.thumbUrl&&t.downloadByURL(a.thumb_url).then(function(e){a.thumbUrl=e}),"gif"==a.type&&a.content_url&&!a.contentUrl&&t.downloadByURL(a.content_url).then(function(e){a.contentUrl=e}),"gif"!=a.type&&"sticker"!=a.type||!a.document||n.downloadDoc(a.document.id);var i;if("photo"==a.type&&a.photo){i=e.choosePhotoSize(a.photo,a.thumbW,a.thumbH);var s=calcImageInBox(i.w,i.h,a.thumbW,a.thumbH);a.thumb={width:s.w,height:s.h,location:i.location,size:i.size}}"game"==a.type&&a.photo&&(i=e.choosePhotoSize(a.photo,100,100),a.thumb={location:i.location,size:i.size})})})}}}]).directive("myGameCommunication",["$window",function(e){function t(t,n,a){onContentLoaded(function(){var a=$("iframe, webview",n)[0],i=a.contentWindow,s=function(e){if(e=e.originalEvent||e,!e.source||e.source==i){var n=e.data;try{var a=JSON.parse(n)}catch(s){return}a&&a.eventType&&t.$emit("game_frame_event",a)}};$(e).on("message",s),t.$on("$destroy",function(){$(e).off("message",s)})})}return{link:t}}]).directive("myEmojiImage",["RichTextProcessor",function(e){function t(t,n,a){var i=a.myEmojiImage,s=e.wrapRichText(i,{noLinks:!0,noLinebreaks:!0});n.html(s.valueOf())}return{link:t}}]).directive("myExternalEmbed",function(){function e(e,r,l){var c=e.$eval(l.myExternalEmbed);if(c){var d,p="",u=!1;switch(c[0]){case"youtube":d=c[1],p='
    <'+o+' type="text/html" frameborder="0" src="https://www.youtube.com/embed/'+d+'?autoplay=0&controls=2" webkitallowfullscreen mozallowfullscreen allowfullscreen>
    ";break;case"vimeo":d=c[1],p='
    <'+o+' type="text/html" frameborder="0" src="https://player.vimeo.com/video/'+d+'?title=0&byline=0&portrait=0" webkitallowfullscreen mozallowfullscreen allowfullscreen>
    ";break;case"instagram":var m=c[1];p='
    <'+o+' type="text/html" frameborder="0" src="https://instagram.com/p/'+m+'/embed/">
    ";break;case"vine":var g=c[1];p='
    <'+o+' type="text/html" frameborder="0" src="https://vine.co/v/'+g+'/embed/simple">
    ";break;case"soundcloud":var h=c[1];p='
    <'+o+' type="text/html" frameborder="0" src="https://w.soundcloud.com/player/?url='+encodeEntities(encodeURIComponent(h))+'&auto_play=false&hide_related=true&show_comments=false&show_user=true&show_reposts=false&visual=true">
    ";break;case"spotify":var f=c[1];p='
    <'+o+' type="text/html" frameborder="0" allowtransparency="true" src="https://embed.spotify.com/?uri=spotify:'+encodeEntities(encodeURIComponent(f))+'">
    ";break;case"twitter":p='
    ',u=function(){t?window.twttr&&twttr.widgets.load(r[0]):(t=!0,$("