"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[87],{4087:(e,t,s)=>{s.r(t),s.d(t,{Main:()=>xo});var n=s(5116),a=s(3716),o=s(4050),r=(s(7895),s(307)),i=s(1638),c=s(735),d=s(2858);function l(e){const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};return t&&s?(e=(0,r.qr)(e,t,s,!1),e=(0,r.Pb)(e,t,s,void 0)):e}(0,n.Q6)("openLocalTextSearch",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};if(t&&s)return(0,r.qr)(e,t,s,!0)})),(0,n.Q6)("closeLocalTextSearch",l),(0,n.Q6)("setLocalTextSearchQuery",((e,t,s)=>{const{chatId:n,threadId:a}=(0,i.Bt)(e)||{};if(!n||!a)return;const{query:o}=s,l=(0,d.uw)(n,a),{query:u}=e.localTextSearch.byChatThreadKey[l]||{};return o!==u&&(e=(0,r.Pb)(e,n,a,c.D)),(0,r.qr)(e,n,a,!0,o)})),(0,n.Q6)("setLocalMediaSearchType",((e,t,s)=>{const{chatId:n}=(0,i.Bt)(e)||{};if(!n)return;const{mediaType:a}=s;return(0,r.z5)(e,n,a)})),(0,n.Q6)("openChat",((e,t,s)=>{const{id:a,threadId:o=-1,type:c="thread",shouldReplaceHistory:d=!1}=s,u=(0,i.Bt)(e);return u&&u.chatId===a&&u.threadId===o&&u.type===c||(e=(0,r.pf)(e,a,o,"replyStack",[]),e=l(e=(0,r.i9)(e)),e={...e,messages:{...e.messages,contentToBeScheduled:void 0},...a!==e.forwardMessages.toChatId&&{forwardMessages:{}}},(0,n.R3)(e)),(0,r.Wy)(e,a,o,c,d)})),(0,n.Q6)("openPreviousChat",(e=>(0,r.Wy)(e,void 0))),(0,n.Q6)("openChatWithInfo",((e,t,s)=>{(0,n.R3)({...e,isChatInfoShown:!0}),t.openChat(s)})),(0,n.Q6)("resetChatCreation",(e=>({...e,chatCreation:void 0}))),(0,n.Q6)("setNewChatMembersDialogState",((e,t,s)=>({...e,newChatMembersProgress:s}))),(0,n.Q6)("openNextChat",((e,t,s)=>{const{targetIndexDelta:n,orderedIds:a}=s,{chatId:o}=(0,i.Bt)(e)||{};if(!o)return void t.openChat({id:a[0]});const r=a.indexOf(o);if(-1===r)return;const c=a[r+n];t.openChat({id:c,shouldReplaceHistory:!0})}));var u=s(6137),m=s(1713),h=s(7361),g=s(782),p=s(2267),f=s(3099);const I=a.ck+a.fK;let v;(0,n.Q6)("setScrollOffset",((e,t,s)=>{const{chatId:n,threadId:a,scrollOffset:o}=s;return(0,r.pf)(e,n,a,"scrollOffset",o)})),(0,n.Q6)("setReplyingToId",((e,t,s)=>{const{messageId:n}=s,a=(0,i.Bt)(e);if(!a)return;const{chatId:o,threadId:c}=a;return(0,r.pf)(e,o,c,"replyingToId",n)})),(0,n.Q6)("setEditingId",((e,t,s)=>{const{messageId:n}=s,a=(0,i.Bt)(e);if(!a)return;const{chatId:o,threadId:c,type:d}=a,l="scheduled"===d?"editingScheduledId":"editingId";return(0,r.pf)(e,o,c,l,n)})),(0,n.Q6)("editLastMessage",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};if(!t||!s)return;const n=(0,i.Zw)(e,t),a=(0,i.Cb)(e,t,s);if(!n||!a)return;const o=(0,g.dF)(a,(t=>Boolean(n[t]&&(0,i._k)(e,n[t],s).canEdit)));return o?(0,r.pf)(e,t,s,"editingId",o):void 0})),(0,n.Q6)("replyToNextMessage",((e,t,s)=>{const{targetIndexDelta:n}=s,{chatId:a,threadId:o}=(0,i.Bt)(e)||{};if(!a||!o)return;const r=(0,i.Zw)(e,a),c=(0,i.Cb)(e,a,o);if(!r||!c)return;const d=(0,i.Yy)(e,a,o);let l;if((0,i.b9)(e,a,o)&&d){const e=Object.keys(r),t=e.indexOf(d.toString())+n;l=t<=e.length+1&&t>=0?Number(e[t]):void 0}else if(o===u._f){var m;const t=(0,i.Z1)(e,a);l=null==t||null===(m=t.lastMessage)||void 0===m?void 0:m.id}else{const t=(0,i.tZ)(e,a,o);l=null==t?void 0:t.lastMessageId}t.setReplyingToId({messageId:l}),t.focusMessage({chatId:a,threadId:o,messageId:l})})),(0,n.Q6)("openMediaViewer",((e,t,s)=>{const{chatId:n,threadId:a,messageId:o,avatarOwnerId:r,profilePhotoIndex:i,origin:c}=s;return{...e,mediaViewer:{chatId:n,threadId:a,messageId:o,avatarOwnerId:r,profilePhotoIndex:i,origin:c},forwardMessages:{}}})),(0,n.Q6)("closeMediaViewer",(e=>({...e,mediaViewer:{}}))),(0,n.Q6)("openAudioPlayer",((e,t,s)=>{const{chatId:n,threadId:a,messageId:o,origin:r,volume:i,playbackRate:c,isMuted:d}=s;return{...e,audioPlayer:{chatId:n,threadId:a,messageId:o,origin:null!=r?r:e.audioPlayer.origin,volume:null!=i?i:e.audioPlayer.volume,playbackRate:c||e.audioPlayer.playbackRate,isMuted:d||e.audioPlayer.isMuted}}})),(0,n.Q6)("setAudioPlayerVolume",((e,t,s)=>{const{volume:n}=s;return{...e,audioPlayer:{...e.audioPlayer,volume:n}}})),(0,n.Q6)("setAudioPlayerPlaybackRate",((e,t,s)=>{const{playbackRate:n}=s;return{...e,audioPlayer:{...e.audioPlayer,playbackRate:n}}})),(0,n.Q6)("setAudioPlayerMuted",((e,t,s)=>{const{isMuted:n}=s;return{...e,audioPlayer:{...e.audioPlayer,isMuted:n}}})),(0,n.Q6)("setAudioPlayerOrigin",((e,t,s)=>{const{origin:n}=s;return{...e,audioPlayer:{...e.audioPlayer,origin:n}}})),(0,n.Q6)("closeAudioPlayer",(e=>({...e,audioPlayer:{volume:e.audioPlayer.volume,playbackRate:e.audioPlayer.playbackRate,isMuted:e.audioPlayer.isMuted}}))),(0,n.Q6)("openPollResults",((e,t,s)=>{const{chatId:a,messageId:o}=s;(0,i.Jf)(e)?a===e.pollResults.chatId&&o===e.pollResults.messageId||(0,n.R3)({...e,pollResults:{chatId:a,messageId:o,voters:{}}}):window.setTimeout((()=>{const e=(0,n.Rd)();(0,n.R3)({...e,pollResults:{chatId:a,messageId:o,voters:{}}})}),450)})),(0,n.Q6)("closePollResults",(e=>{(0,n.R3)({...e,pollResults:{}})})),(0,n.Q6)("focusLastMessage",((e,t)=>{const s=(0,i.Bt)(e);if(!s)return;const{chatId:n,threadId:a}=s;let o;if(a===u._f){var r;const t=(0,i.Z1)(e,n);o=null==t||null===(r=t.lastMessage)||void 0===r?void 0:r.id}else{const t=(0,i.tZ)(e,n,a);o=null==t?void 0:t.lastMessageId}o&&t.focusMessage({chatId:n,threadId:a,messageId:o,noHighlight:!0})})),(0,n.Q6)("focusNextReply",((e,t)=>{const s=(0,i.Bt)(e);if(!s)return;const{chatId:a,threadId:o}=s,c=(0,i.p9)(e,a,o);if(c&&0!==c.length){const s=c.pop();e=(0,r.pf)(e,a,o,"replyStack",[...c]),(0,n.R3)(e),t.focusMessage({chatId:a,threadId:o,messageId:s})}else t.focusLastMessage()})),(0,n.Q6)("focusMessage",((e,t,s)=>{const{chatId:a,threadId:o=u._f,messageListType:c="thread",noHighlight:d,groupedId:l,groupedChatId:h,replyMessageId:g,isResizingContainer:p}=s;let{messageId:f}=s;if(void 0!==l){const t=(0,i.y8)(e,h,l);null!=t&&t.length&&([f]=t)}const y=(0,i.Bt)(e),Z=!y||a!==y.chatId||o!==y.threadId||c!==y.type;if(v&&(clearTimeout(v),v=void 0),v=window.setTimeout((()=>{let e=(0,n.Rd)();e=(0,r.cq)(e),e=(0,r.wV)(e),(0,n.R3)(e)}),d?I:1500),e=(0,r.cq)(e,a,f,d,p),e=(0,r.wV)(e,void 0),g){const t=(0,i.p9)(e,a,o)||[];e=(0,r.pf)(e,a,o,"replyStack",[...t,g])}Z&&(e=(0,r.wV)(e,m.fo.Static));const P=(0,i.Cb)(e,a,o);if(P&&P.includes(f))return(0,n.R3)(e),void t.openChat({id:a,threadId:o});if(Z&&(e=(0,r.pf)(e,a,o,"viewportIds",void 0)),e=(0,r.pf)(e,a,o,"outlyingIds",void 0),P&&!Z){const t=f>P[0]?m.fo.Down:m.fo.Up;e=(0,r.wV)(e,t)}(0,n.R3)(e),t.openChat({id:a,threadId:o}),t.loadViewportMessages()})),(0,n.Q6)("openForwardMenu",((e,t,s)=>{const{fromChatId:n,messageIds:a,groupedId:o}=s;let r;return o&&(r=(0,i.xH)(e,n,o)),{...e,forwardMessages:{fromChatId:n,messageIds:r||a,isModalShown:!0}}})),(0,n.Q6)("exitForwardMode",(e=>{(0,n.R3)({...e,forwardMessages:{}})})),(0,n.Q6)("setForwardChatId",((e,t,s)=>{const{id:a}=s;(0,n.R3)({...e,forwardMessages:{...e.forwardMessages,toChatId:a,isModalShown:!1}}),t.openChat({id:a}),t.closeMediaViewer(),t.exitMessageSelectMode()})),(0,n.Q6)("openForwardMenuForSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:s,messageIds:n}=e.selectedMessages;t.openForwardMenu({fromChatId:s,messageIds:n})})),(0,n.Q6)("cancelMessageMediaDownload",((e,t,s)=>{const{message:a}=s,o=e.activeDownloads.byChatId[a.chatId];o&&o.length&&(0,n.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[a.chatId]:o.filter((e=>e!==a.id))}}})})),(0,n.Q6)("downloadMessageMedia",((e,t,s)=>{const{message:a}=s;a&&(0,n.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[a.chatId]:[...e.activeDownloads.byChatId[a.chatId]||[],a.id]}}})})),(0,n.Q6)("downloadSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:s,messageIds:n}=e.selectedMessages,{threadId:a}=(0,i.Bt)(e)||{},o=(0,i.Zw)(e,s);o&&a&&n.map((e=>o[e])).filter((t=>(0,i._k)(e,t,a).canDownload)).forEach((e=>t.downloadMessageMedia({message:e})))})),(0,n.Q6)("enterMessageSelectMode",((e,t,s)=>{const{messageId:n}=s||{},a=(0,i.jr)(e);return a?(0,r.M6)(e,a.id,n):e})),(0,n.Q6)("toggleMessageSelection",((e,t,s)=>{const{messageId:a,groupedId:o,childMessageIds:c,withShift:d}=s,l=(0,i.Bt)(e);if(!l)return;const{chatId:u,threadId:m,type:g}=l;e=(0,r.Ob)(e,u,m,g,a,o,c,d),(0,n.R3)(e),e.shouldShowContextMenuHint&&(t.disableContextMenuHint(),t.showNotification({message:`To **edit** or **reply**, close this menu. Then ${h.$b?"long tap":"right click"} on a message.`}))})),(0,n.Q6)("disableContextMenuHint",(e=>{if(e.shouldShowContextMenuHint)return{...e,shouldShowContextMenuHint:!1}})),(0,n.Q6)("exitMessageSelectMode",r.i9),(0,n.Q6)("openPollModal",(e=>({...e,isPollModalOpen:!0}))),(0,n.Q6)("closePollModal",(e=>({...e,isPollModalOpen:!1}))),(0,n.Q6)("checkVersionNotification",((e,t)=>{const s=a.Ji.split(".").slice(0,2).join("."),{serviceNotifications:n}=e;if(n.find((({version:e})=>e===s)))return;const o={chatId:a.aw,date:(0,p.b)(e.serverTimeOffset),content:{text:(0,f.Z)('**Telegram Web Z was updated to version 1.28**\n\n👏 **Harder**\n• Support for join requests in groups and channels.\n• Support for more service messages.\n\n🤩 **Better**\n• Easier to select and adjust left column width.\n• Redundant single quotes removed in Spanish and French translations.\n• Support for hotkeys on non-qwerty keyboards.\n• Use Ctrl+Shift+F or Ctrl+F (in PWA mode) to open global or local search.\n• Chat: "Add to folder..." only appears for users with folders.\n• Support for `start` parameter in `tg://resolve` links.\n\n💪 **Stronger**\n• Fixed focusing on messages in a chat that was previously open.\n• Fixed missing stickers in sticker suggestions.\n• Fixed opening chats from user mentions.\n• Fixed various glitches when appearing as a channel in public groups.\n• Removed redundant download and forward options in chats with protected content.\n')},isOutgoing:!1};t.createServiceNotification({message:o,version:s})})),(0,n.Q6)("createServiceNotification",((e,t,s)=>{var o;const{message:r,version:c}=s,{serviceNotifications:d}=e,l=(0,i.Z1)(e,a.aw),u=Math.max((null===(o=l.lastMessage)||void 0===o?void 0:o.id)||0,...d.map((({id:e})=>e))),m=(d.length+1)/1e3,h=Math.floor(u)+m;r.id=h;const g={id:h,message:r,version:c,isUnread:!0};(0,n.R3)({...e,serviceNotifications:[...d.slice(-1e3),g]}),t.apiUpdate({"@type":"newMessage",id:r.id,chatId:r.chatId,message:r})})),(0,n.Q6)("openSeenByModal",((e,t,s)=>{const{chatId:n,messageId:a}=s;return{...e,seenByModal:{chatId:n,messageId:a}}})),(0,n.Q6)("closeSeenByModal",(e=>({...e,seenByModal:void 0}))),(0,n.Q6)("setGlobalSearchQuery",((e,t,s)=>{const{query:n}=s,{chatId:a}=e.globalSearch;return(0,r.No)(e,{globalResults:{},localResults:{},resultsByType:void 0,...n?{fetchingStatus:{chats:!a,messages:!0}}:{fetchingStatus:void 0},query:n})})),(0,n.Q6)("addRecentlyFoundChatId",((e,t,s)=>{const{id:n}=s,{recentlyFoundChatIds:a}=e.globalSearch;if(!a)return(0,r.No)(e,{recentlyFoundChatIds:[n]});const o=a.filter((e=>e!==n));return o.unshift(n),o.length>10&&o.pop(),(0,r.No)(e,{recentlyFoundChatIds:o})})),(0,n.Q6)("clearRecentlyFoundChats",(e=>(0,r.No)(e,{recentlyFoundChatIds:void 0}))),(0,n.Q6)("setGlobalSearchContent",((e,t,s)=>{const{content:n}=s;return(0,r.Og)(e,n)})),(0,n.Q6)("setGlobalSearchChatId",((e,t,s)=>{const{id:n}=s;return(0,r.No)(e,{chatId:n,query:void 0,resultsByType:void 0})})),(0,n.Q6)("setStickerSearchQuery",((e,t,s)=>{const{query:n}=s;return{...e,stickers:{...e.stickers,search:{query:n,resultIds:void 0}}}})),(0,n.Q6)("setGifSearchQuery",((e,t,s)=>{const{query:n}=s;return{...e,gifs:{...e.gifs,search:{query:n,offsetId:void 0,results:void 0}}}})),(0,n.Q6)("openUserInfo",((e,t,s)=>{const{id:n}=s;t.openChat({id:n})})),(0,n.Q6)("openChat",(e=>(0,r.x1)(e,void 0))),(0,n.Q6)("setUserSearchQuery",((e,t,s)=>{const{query:n}=s;return(0,r.Lm)(e,{globalUserIds:void 0,localUserIds:void 0,fetchingStatus:Boolean(n),query:n})})),s(3781);var y=s(1947),Z=s(6926);(0,n.Q6)("toggleChatInfo",(e=>({...e,isChatInfoShown:!e.isChatInfoShown}))),(0,n.Q6)("setLeftColumnWidth",((e,t,s)=>({...e,leftColumnWidth:s}))),(0,n.Q6)("resetLeftColumnWidth",(e=>({...e,leftColumnWidth:void 0}))),(0,n.Q6)("toggleManagement",(e=>{const{chatId:t}=(0,i.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!(e.management.byChatId[t]||{}).isActive}}}}})),(0,n.Q6)("closeManagement",(e=>{const{chatId:t}=(0,i.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!1}}}}})),(0,n.Q6)("openChat",(e=>{if(h.wB||h.p7)return{...e,isLeftColumnShown:0===e.messages.messageLists.length}})),(0,n.Q6)("toggleLeftColumn",(e=>({...e,isLeftColumnShown:!e.isLeftColumnShown}))),(0,n.Q6)("addRecentEmoji",((e,t,s)=>{const{emoji:n}=s,{recentEmojis:a}=e;if(!a)return{...e,recentEmojis:[n]};const o=a.filter((e=>e!==n));return o.unshift(n),o.length>18&&o.pop(),{...e,recentEmojis:o}})),(0,n.Q6)("addRecentSticker",((e,t,s)=>{const{sticker:n}=s,{recent:a}=e.stickers;if(!a)return{...e,stickers:{...e.stickers,recent:{hash:"0",stickers:[n]}}};const o=a.stickers.filter((e=>e.id!==n.id));return o.unshift(n),{...e,stickers:{...e.stickers,recent:{...a,stickers:o}}}})),(0,n.Q6)("showNotification",((e,t,s)=>{const n=s;n.localId=(0,Z.Z)({});const a=[...e.notifications],o=a.findIndex((e=>e.message===n.message));return-1!==o&&a.splice(o,1),a.push(n),{...e,notifications:a}})),(0,n.Q6)("dismissNotification",((e,t,s)=>{const n=e.notifications.filter((({localId:e})=>e!==s.localId));return{...e,notifications:n}})),(0,n.Q6)("showDialog",((e,t,s)=>{const{data:n}=s;if("message"in n&&n.hasErrorKey&&!(0,y.ZP)(n))return e;const a=[...e.dialogs];if("message"in n){const e=a.findIndex((e=>e.message===n.message));-1!==e&&a.splice(e,1)}return a.push(n),{...e,dialogs:a}})),(0,n.Q6)("dismissDialog",(e=>{const t=[...e.dialogs];return t.pop(),{...e,dialogs:t}})),(0,n.Q6)("toggleSafeLinkModal",((e,t,s)=>{const{url:n}=s;return{...e,safeLinkModalUrl:n}})),(0,n.Q6)("openHistoryCalendar",((e,t,s)=>{const{selectedAt:n}=s;return{...e,historyCalendarSelectedAt:n}})),(0,n.Q6)("closeHistoryCalendar",(e=>({...e,historyCalendarSelectedAt:void 0}))),(0,n.Q6)("openPaymentModal",((e,t,s)=>{const{chatId:n,messageId:a}=s;return{...e,payment:{...e.payment,chatId:n,messageId:a,isPaymentModalOpen:!0}}})),(0,n.Q6)("closePaymentModal",(e=>{const t=(0,r.bp)(e);return(0,r.WY)(t)})),(0,n.Q6)("addPaymentError",((e,t,s)=>{const{error:n}=s;return{...e,payment:{...e.payment,error:n}}})),s(1689),s(1363),s(6204);var P=s(1226),C=s(9118);const w=new Map,b=(0,C.Ds)((e=>e()),500,!1);async function S(e,t,s,o,c=!1,d=!1){const l=e.id;let u;switch(o){case m.Uq.Backwards:u=void 0;break;case m.Uq.Around:u=-(Math.round(a.hT/2)+1);break;case m.Uq.Forwards:u=-(a.hT+1)}const h=await(0,P.t9)("fetchMessages",{chat:(0,i.Cm)((0,n.Rd)(),l,t),offsetId:s,addOffset:u,limit:a.hT,threadId:t});if(!h)return;const{messages:p,users:f,chats:I,threadInfos:v}=h;let y=(0,n.Rd)();const Z=l===a.aw?y.serviceNotifications.map((({message:e})=>e)):[],C=[].concat(p,Z),w=(0,g.ee)(C,"id"),b=Object.keys(w).map(Number);y=(0,r.c_)(y,l,w),y=c?(0,r.ff)(y,l,t,b):(0,r.xj)(y,l,t,b),y=(0,r.Sh)(y,(0,g.ee)(f,"id")),y=(0,r.fZ)(y,(0,g.ee)(I,"id")),y=(0,r.j6)(y,l,v);let S=(0,i.gb)(y,l,t);const M=(0,i.qC)(y,l,t);if(c&&S&&M&&(M.length&&!(0,g.YE)(S,M)||(y=(0,r.xj)(y,l,t,M),S=(0,i.gb)(y,l,t),y=(0,r.pf)(y,l,t,"outlyingIds",void 0),c=!1)),!d){const e=c?M:S,{newViewportIds:n}=E(e,s,o);y=(0,r.y9)(y,l,t,n)}(0,n.R3)(y)}function E(e,t,s){const{length:n}=e,o=t?function(e,t){return te[e.length-1]?e.length-1:e.findIndex(((s,n)=>s===t||st))}(e,t):-1,r=s===m.Uq.Backwards?o:o+1||n,i=r-a.hT,c=r+a.hT-1,d=e.slice(Math.max(0,i),c+1);let l,u;switch(s){case m.Uq.Backwards:l=r>0,u=i>=0;break;case m.Uq.Forwards:l=r0,u=d.length===a.hT}return{newViewportIds:d,areSomeLocal:l,areAllLocal:u}}async function M(e){let t;const s=e.attachment?(e,a)=>{w.has(a)||(t=a,w.set(a,s));const o=(0,n.Rd)();(0,n.R3)({...o,fileUploads:{byMessageLocalId:{...o.fileUploads.byMessageLocalId,[a]:{progress:e}}}})}:void 0;(e.replyingTo||h.cj)&&await(0,C.Pn)();const a=(0,n.Rd)();e.serverTimeOffset=a.serverTimeOffset;const o=(0,i.Bt)(a);if(!o)return;const{threadId:r}=o;e.replyingTo||r===u._f||(e.replyingTo=(0,i.qS)(a,e.chat.id,r)),await(0,P.t9)("sendMessage",e,s),s&&t&&w.delete(t)}(0,n.Q6)("loadViewportMessages",((e,t,s)=>{const{direction:n=m.Uq.Around,isBudgetPreload:o=!1}=s||{};let{chatId:c,threadId:d}=s||{};if(!c){const t=(0,i.Bt)(e);if(!t)return;c=t.chatId,d=t.threadId}const l=(0,i.Z1)(e,c);if(!l||l.isRestricted)return;const u=(0,i.Cb)(e,c,d),h=(0,i.gb)(e,c,d),g=(0,i.qC)(e,c,d);if(u&&u.length&&n!==m.Uq.Around){const s=n===m.Uq.Backwards?u[0]:u[u.length-1],a=Boolean(g),i=a?g:h,{newViewportIds:p,areSomeLocal:f,areAllLocal:I}=E(i,s,n);if(f&&(e=(0,r.y9)(e,c,d,p)),async function(e,t,s,n,a,o,r,i){t||await S(a,o,i,r,s,n),n||(await Promise.resolve(),e.loadViewportMessages({chatId:a.id,threadId:o,direction:r,isBudgetPreload:!0}))}(t,I,a,o,l,d,n,s),o)return}else{const t=(0,i.G$)(e,c)||(0,i.rd)(e,c,d),s=Boolean(t&&h&&!h.includes(t)),n=(s?g:h)||[],{newViewportIds:u,areSomeLocal:p,areAllLocal:f}=E(n,t,m.Uq.Around);p&&u.length>=a.hT&&(e=(0,r.y9)(e,c,d,u)),f||S(l,d,t,m.Uq.Around,s,o)}return e})),(0,n.Q6)("loadMessage",((e,t,s)=>{const{chatId:a,messageId:o,replyOriginForId:c,threadUpdate:d}=s,l=(0,i.Z1)(e,a);l&&(async()=>{const e=await async function(e,t,s){const a=await(0,P.t9)("fetchMessage",{chat:e,messageId:t});if(!a)return;if(a===u._Q){if(s){let t=(0,n.Rd)();const a=(0,i.hj)(t,e.id,s);t=(0,r.cY)(t,e.id,s,{...a,replyToMessageId:void 0}),(0,n.R3)(t)}return}let o=(0,n.Rd)();return o=(0,r.cY)(o,e.id,t,a.message),o=(0,r.Sh)(o,(0,g.ee)(a.users,"id")),(0,n.R3)(o),a.message}(l,o,c);if(e&&d){const{lastMessageId:t,isDeleting:s}=d;(0,n.R3)((0,r.lG)((0,n.Rd)(),e,a,t,s))}})()})),(0,n.Q6)("sendMessage",((e,t,s)=>{const n=(0,i.Bt)(e);if(!n)return;const{chatId:o,threadId:r,type:c}=n;if("scheduled"===c&&!s.scheduledAt)return{...e,messages:{...e.messages,contentToBeScheduled:s}};const d=(0,i.Z1)(e,o),l={...s,chat:d,replyingTo:(0,i.Yy)(e,o,r),noWebPage:(0,i.tV)(e,o,r),sendAs:(0,i._5)(e,o)};t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:o,threadId:r,value:!1});const u=!s.attachments||s.attachments.length<=1,m=!u&&s.attachments&&s.attachments.length>1;if(u){const{attachments:e,...t}=l;M({...t,attachment:e?e[0]:void 0})}else if(m){const{text:e,entities:t,attachments:s,...n}=l,o=(0,g.Vl)(s,a.DU);for(let s=0;s0?i:void 0}),r.forEach((e=>{M({...n,attachment:e,groupedId:i})}))}}else{const{text:e,entities:t,attachments:s,replyingTo:n,...a}=l;e&&M({...a,text:e,entities:t,replyingTo:n}),s.forEach((e=>{M({...a,attachment:e})}))}})),(0,n.Q6)("editMessage",((e,t,s)=>{const{serverTimeOffset:n}=e,{text:a,entities:o}=s,r=(0,i.Bt)(e);if(!r)return;const{chatId:c,threadId:d,type:l}=r,u=(0,i.Z1)(e,c),m=(0,i.kK)(e,c,d,l);u&&m&&((0,P.t9)("editMessage",{chat:u,message:m,text:a,entities:o,noWebPage:(0,i.tV)(e,c,d),serverTimeOffset:n}),t.setEditingId({messageId:void 0}))})),(0,n.Q6)("cancelSendingMessage",((e,t,s)=>{const{chatId:n,messageId:a}=s,o=(0,i.hj)(e,n,a),r=o&&w.get(o.previousLocalId||o.id);r&&(0,P.u3)(r),t.apiUpdate({"@type":"deleteMessages",ids:[a],chatId:n})})),(0,n.Q6)("saveDraft",((e,t,s)=>{const{chatId:n,threadId:a,draft:o}=s;if(!o)return;const{text:c,entities:d}=o,l=(0,i.Z1)(e,n);return a===u._f&&(0,P.t9)("saveDraft",{chat:l,text:c,entities:d,replyToMsgId:(0,i.Yy)(e,n,a)}),e=(0,r.pf)(e,n,a,"draft",o),(0,r.a4)(e,n,{draftDate:Math.round(Date.now()/1e3)})})),(0,n.Q6)("clearDraft",((e,t,s)=>{const{chatId:n,threadId:a,localOnly:o}=s;if(!(0,i.Ms)(e,n,a))return;const c=(0,i.Z1)(e,n);return o||a!==u._f||(0,P.t9)("clearDraft",c),e=(0,r.pf)(e,n,a,"draft",void 0),(0,r.a4)(e,n,{draftDate:void 0})})),(0,n.Q6)("toggleMessageWebPage",((e,t,s)=>{const{chatId:n,threadId:a,noWebPage:o}=s;return(0,r.pf)(e,n,a,"noWebPage",o)})),(0,n.Q6)("pinMessage",((e,t,s)=>{const n=(0,i.jr)(e);if(!n)return;const{messageId:a,isUnpin:o,isOneSide:r,isSilent:c}=s;(0,P.t9)("pinMessage",{chat:n,messageId:a,isUnpin:o,isOneSide:r,isSilent:c})})),(0,n.Q6)("unpinAllMessages",((e,t,s)=>{const a=(0,i.Z1)(e,s.chatId);a&&async function(e){await(0,P.t9)("unpinAllMessages",{chat:e});let t=(0,n.Rd)();t=(0,r.pf)(t,e.id,u._f,"pinnedIds",[]),(0,n.R3)(t)}(a)})),(0,n.Q6)("deleteMessages",((e,t,s)=>{const{messageIds:n,shouldDeleteForAll:a}=s,o=(0,i.Bt)(e);if(!o)return;const{chatId:r,threadId:c}=o,d=(0,i.Z1)(e,r);(0,P.t9)("deleteMessages",{chat:d,messageIds:n,shouldDeleteForAll:a});const l=(0,i._$)(e,r,c);n.includes(l)&&t.setEditingId({messageId:void 0})})),(0,n.Q6)("deleteScheduledMessages",((e,t,s)=>{const{messageIds:n}=s,a=(0,i.Bt)(e);if(!a)return;const{chatId:o}=a,r=(0,i.Z1)(e,o);(0,P.t9)("deleteScheduledMessages",{chat:r,messageIds:n});const c=(0,i.wU)(e,o);n.includes(c)&&t.setEditingId({messageId:void 0})})),(0,n.Q6)("deleteHistory",((e,t,s)=>{(async()=>{var n;const{chatId:a,shouldDeleteForAll:o}=s,r=(0,i.Z1)(e,a);if(!r)return;const c=null===(n=r.lastMessage)||void 0===n?void 0:n.id;await(0,P.t9)("deleteHistory",{chat:r,shouldDeleteForAll:o,maxId:c});const d=(0,i.Bt)(e);d&&d.chatId===a&&t.openChat({id:void 0})})()})),(0,n.Q6)("reportMessages",((e,t,s)=>{(async()=>{const{messageIds:n,reason:a,description:o}=s,r=(0,i.Bt)(e);if(!r)return;const{chatId:c}=r,d=(0,i.Z1)(e,c),l=await(0,P.t9)("reportMessages",{peer:d,messageIds:n,reason:a,description:o});t.showNotification({message:l?"Thank you! Your report will be reviewed by our team.":"Error occured while submiting report. Please, try again later."})})()})),(0,n.Q6)("sendMessageAction",((e,t,s)=>{(async()=>{const{action:t,chatId:n,threadId:a}=s;if(n===e.currentUserId)return;const o=(0,i.Z1)(e,n);o&&await(0,P.t9)("sendMessageAction",{peer:o,threadId:a,action:t})})()})),(0,n.Q6)("markMessageListRead",((e,t,s)=>{const{serverTimeOffset:n}=e,o=(0,i.Bt)(e);if(!o)return;const{chatId:c,threadId:d}=o,l=(0,i.Cm)(e,c,d);if(!l)return;const{maxId:m}=s;if(b((()=>{(0,P.t9)("markMessageListRead",{serverTimeOffset:n,chat:l,threadId:d,maxId:m})})),d!==u._f)return;c===a.aw&&(e={...e,serviceNotifications:e.serviceNotifications.map((e=>e.isUnread&&e.id<=m?{...e,isUnread:!1}:e))});const h=(0,i.Cb)(e,c,d),g=(0,i.It)(e,c,d);if(!h||!g||!l.unreadCount)return e;const p=function(e,t,s){let n=0;for(let a=0,o=e.length;a=t&&e[a]<=s&&n++,!(e[a]>=s));a++);return n}(h,g,m);return p?(0,r.a4)(e,c,{lastReadInboxMessageId:m,unreadCount:Math.max(0,l.unreadCount-p)}):e})),(0,n.Q6)("markMessagesRead",((e,t,s)=>{const n=(0,i.jr)(e);if(!n)return;const{messageIds:a}=s;(0,P.t9)("markMessagesRead",{chat:n,messageIds:a})})),(0,n.Q6)("loadWebPagePreview",((e,t,s)=>{const{text:a}=s;!async function(e){const t=await(0,P.t9)("fetchWebPagePreview",{message:e});(0,n.R3)({...(0,n.Rd)(),webPagePreview:t})}(a)})),(0,n.Q6)("clearWebPagePreview",(e=>{if(e.webPagePreview)return{...e,webPagePreview:void 0}})),(0,n.Q6)("sendPollVote",((e,t,s)=>{const{chatId:n,messageId:a,options:o}=s,r=(0,i.Z1)(e,n);r&&(0,P.t9)("sendPollVote",{chat:r,messageId:a,options:o})})),(0,n.Q6)("loadPollOptionResults",((e,t,s)=>{const{chat:a,messageId:o,option:i,offset:c,limit:d,shouldResetVoters:l}=s;!async function(e,t,s,a,o,i){const c=await(0,P.t9)("loadPollOptionResults",{chat:e,messageId:t,option:s,offset:a,limit:o});if(!c)return;let d=(0,n.Rd)();d=(0,r.Sh)(d,(0,g.ee)(c.users,"id"));const{voters:l}=d.pollResults;(0,n.R3)({...d,pollResults:{...d.pollResults,voters:{...l,[s]:(0,g.Tw)([...!i&&l&&l[s]?l[s]:[],...c&&c.users.map((e=>e.id))])},offsets:{...d.pollResults.offsets?d.pollResults.offsets:{},[s]:c.nextOffset||""}}})}(a,o,i,c,d,l)})),(0,n.Q6)("forwardMessages",((e,t,s)=>{const{fromChatId:a,messageIds:o,toChatId:r}=e.forwardMessages,c=a?(0,i.Z1)(e,a):void 0,l=r?(0,i.Z1)(e,r):void 0,u=a&&o?o.sort(((e,t)=>e-t)).map((t=>(0,i.hj)(e,a,t))).filter(Boolean):void 0;if(!c||!l||!u)return;const{isSilent:m,scheduledAt:h}=s,g=(0,i._5)(e,r),p=u.filter((e=>!(0,d.jM)(e)));p.length&&(0,P.t9)("forwardMessages",{fromChat:c,toChat:l,messages:p,serverTimeOffset:(0,n.Rd)().serverTimeOffset,isSilent:m,scheduledAt:h,sendAs:g}),u.filter((e=>(0,d.jM)(e))).forEach((e=>{const{text:t,entities:s}=e.content.text||{},{sticker:n,poll:a}=e.content;M({chat:l,text:t,entities:s,sticker:n,poll:a,isSilent:m,scheduledAt:h,sendAs:g})})),(0,n.R3)({...(0,n.Rd)(),forwardMessages:{}})})),(0,n.Q6)("loadScheduledHistory",((e,t,s)=>{const{chatId:a}=s,o=(0,i.Z1)(e,a);o&&async function(e){const t=await(0,P.t9)("fetchScheduledHistory",{chat:e});if(!t)return;const{messages:s}=t,a=(0,g.ee)(s,"id"),o=Object.keys(a).map(Number).sort(((e,t)=>t-e));let i=(0,n.Rd)();i=(0,r.w3)(i,e.id,a),i=(0,r.pf)(i,e.id,u._f,"scheduledIds",o),(0,n.R3)(i)}(o)})),(0,n.Q6)("sendScheduledMessages",((e,t,s)=>{const{chatId:n,id:a}=s,o=(0,i.Z1)(e,n);o&&(0,P.t9)("sendScheduledMessages",{chat:o,ids:[a]})})),(0,n.Q6)("rescheduleMessage",((e,t,s)=>{const{chatId:n,messageId:a,scheduledAt:o}=s,r=(0,i.Z1)(e,n),c=r&&(0,i.Tm)(e,r.id,a);r&&c&&(0,P.t9)("rescheduleMessage",{chat:r,message:c,scheduledAt:o})})),(0,n.Q6)("requestThreadInfoUpdate",((e,t,s)=>{const{chatId:n,threadId:a}=s,o=(0,i.Cm)(e,n,a);o&&(0,P.t9)("requestThreadInfoUpdate",{chat:o,threadId:a})})),(0,n.Q6)("loadPinnedMessages",((e,t,s)=>{const{chatId:a}=s,o=(0,i.Z1)(e,a);o&&async function(e){const t=await(0,P.t9)("fetchPinnedMessages",{chat:e});if(!t)return;const{messages:s,chats:a,users:o}=t,i=(0,g.ee)(s,"id"),c=Object.keys(i).map(Number).sort(((e,t)=>t-e));let d=(0,n.Rd)();d=(0,r.c_)(d,e.id,i),d=(0,r.pf)(d,e.id,u._f,"pinnedIds",c),d=(0,r.Sh)(d,(0,g.ee)(o,"id")),d=(0,r.fZ)(d,(0,g.ee)(a,"id")),(0,n.R3)(d)}(o)})),(0,n.Q6)("loadSeenBy",((e,t,s)=>{const{chatId:a,messageId:o}=s,c=(0,i.Z1)(e,a);c&&(async()=>{const e=await(0,P.t9)("fetchSeenBy",{chat:c,messageId:o});e&&(0,n.R3)((0,r.cY)((0,n.Rd)(),a,o,{seenByUserIds:e}))})()})),(0,n.Q6)("saveDefaultSendAs",((e,t,s)=>{const{chatId:n,sendAsId:a}=s,o=(0,i.Z1)(e,n),c=(0,i.Z1)(e,a)||(0,i.dy)(e,a);if(o&&c)return(0,P.t9)("saveDefaultSendAs",{sendAs:c,chat:o}),(0,r.a4)(e,n,{fullInfo:{...o.fullInfo,sendAsId:a}})})),(0,n.Q6)("loadSendAs",((e,t,s)=>{const{chatId:a}=s,o=(0,i.Z1)(e,a);o&&(async()=>{const t=await(0,P.t9)("fetchSendAs",{chat:o});if(!t)return e=(0,r.a4)(e,a,{sendAsIds:[]}),void(0,n.R3)(e);e=(0,n.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(t.users,"id")),e=(0,r.fZ)(e,(0,g.ee)(t.chats,"id")),e=(0,r.a4)(e,a,{sendAsIds:t.ids}),(0,n.R3)(e)})()})),(0,n.Q6)("loadSponsoredMessages",((e,t,s)=>{const{chatId:a}=s,o=(0,i.Z1)(e,a);o&&(async()=>{const e=await(0,P.t9)("fetchSponsoredMessages",{chat:o});if(!e)return;let t=(0,r.Fn)((0,n.Rd)(),a,e.messages[0]);t=(0,r.Sh)(t,(0,g.ee)(e.users,"id")),t=(0,r.fZ)(t,(0,g.ee)(e.chats,"id")),(0,n.R3)(t)})()})),(0,n.Q6)("viewSponsoredMessage",((e,t,s)=>{const{chatId:n}=s,a=(0,i.Z1)(e,n),o=(0,i.fS)(e,n);a&&o&&(0,P.t9)("viewSponsoredMessage",{chat:a,random:o.randomId})}));var k=s(5765);const R=(0,C.P2)((e=>e()),500,!1);async function T(e,t){const s=await(0,P.t9)("searchGifs",{query:e,offset:t});s&&(0,n.R3)((0,r.rq)((0,n.Rd)(),!t,s.gifs,s.nextOffset))}(0,n.Q6)("loadStickerSets",(e=>{const{hash:t}=e.stickers.added||{};!async function(e){const t=await(0,P.t9)("fetchStickerSets",{hash:e});t&&(0,n.R3)((0,r.z3)((0,n.Rd)(),"added",t.hash,t.sets))}(t)})),(0,n.Q6)("loadAddedStickers",((e,t)=>{const{setIds:s}=e.stickers.added;s&&s.length&&(async()=>{for(let e=0;e0&&await(0,C.wO)(200)})()})),(0,n.Q6)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};!async function(e){const t=await(0,P.t9)("fetchRecentStickers",{hash:e});if(!t)return;const s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,recent:t}})}(t)})),(0,n.Q6)("loadFavoriteStickers",(e=>{const{hash:t}=e.stickers.favorite||{};!async function(e){const t=await(0,P.t9)("fetchFavoriteStickers",{hash:e});if(!t)return;const s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,favorite:t}})}(t)})),(0,n.Q6)("loadGreetingStickers",(e=>{const{hash:t}=e.stickers.greeting||{};(async()=>{const e=await(0,P.t9)("fetchStickersForEmoji",{emoji:"👋⭐️",hash:t});if(!e)return;const s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,greeting:{hash:e.hash,stickers:e.stickers.filter((e=>"👋"===e.emoji))}}})})()})),(0,n.Q6)("loadFeaturedStickers",(e=>{const{hash:t}=e.stickers.featured||{};!async function(e){const t=await(0,P.t9)("fetchFeaturedStickers",{hash:e});t&&(0,n.R3)((0,r.z3)((0,n.Rd)(),"featured",t.hash,t.sets))}(t)})),(0,n.Q6)("loadStickers",((e,t,s)=>{const{stickerSetId:a,stickerSetShortName:o}=s;let{stickerSetAccessHash:c}=s;if(!c&&!o){const t=(0,i.Ny)(e,a);if(!t)return;c=t.accessHash}!async function(e,t,s){const a=await(0,P.t9)("fetchStickers",{stickerSetShortName:s,stickerSetId:e,accessHash:t});if(!a)return;const{set:o,stickers:i,packs:c}=a;let d=(0,n.Rd)();d=(0,r.Rg)(d,o.id,{...o,stickers:i,packs:c});const l=d.stickers.forEmoji.emoji;l&&c[l]&&(d=(0,r.vy)(d)),(0,n.R3)(d)}(a,c,o)})),(0,n.Q6)("loadAnimatedEmojis",(()=>{!async function(){const e=await(0,P.t9)("fetchAnimatedEmojis");if(!e)return;const{set:t,stickers:s}=e;(0,n.R3)((0,r.g_)((0,n.Rd)(),{...t,stickers:s}))}()})),(0,n.Q6)("loadSavedGifs",(e=>{const{hash:t}=e.gifs.saved;!async function(e){const t=await(0,P.t9)("fetchSavedGifs",{hash:e});if(!t)return;const s=(0,n.Rd)();(0,n.R3)({...s,gifs:{...s.gifs,saved:t}})}(t)})),(0,n.Q6)("faveSticker",((e,t,s)=>{const{sticker:n}=s;n&&(0,P.t9)("faveSticker",{sticker:n})})),(0,n.Q6)("unfaveSticker",((e,t,s)=>{const{sticker:a}=s;a&&function(e){const t=(0,n.Rd)();(0,n.R3)({...t,stickers:{...t.stickers,favorite:{...t.stickers.favorite,stickers:t.stickers.favorite.stickers.filter((({id:t})=>t!==e.id))}}}),(0,P.t9)("faveSticker",{sticker:e,unfave:!0})}(a)})),(0,n.Q6)("toggleStickerSet",((e,t,s)=>{const{stickerSetId:n}=s,a=(0,i.Ny)(e,n);if(!a)return;const{accessHash:o,installedDate:r}=a;(0,P.t9)(r?"uninstallStickerSet":"installStickerSet",{stickerSetId:n,accessHash:o})})),(0,n.Q6)("loadEmojiKeywords",((e,t,s)=>{var a;const{language:o}=s;let r=e.emojiKeywords[o];null!==(a=r)&&void 0!==a&&a.isLoading||((0,n.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...r,isLoading:!0}}}),(async()=>{var t;const s=await(0,P.t9)("fetchEmojiKeywords",{language:o,fromVersion:r?r.version:0});e=(0,n.Rd)(),r=e.emojiKeywords[o],s?(0,n.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{isLoading:!1,version:s.version,keywords:{...null===(t=r)||void 0===t?void 0:t.keywords,...s.keywords}}}}):(0,n.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...r,isLoading:!1}}})})())})),(0,n.Q6)("setStickerSearchQuery",((e,t,s)=>{const{query:a}=s;a&&R((()=>{!async function(e,t){const s=await(0,P.t9)("searchStickers",{query:e,hash:void 0});if(!s)return;const a=(0,n.Rd)(),{setsById:o,added:i}=a.stickers,c=s.sets.map((({id:e})=>e));i.setIds&&i.setIds.forEach((t=>{if(!c.includes(t)){const{title:s}=o[t]||{};s&&(0,k.Z)(s,e)&&c.unshift(t)}})),(0,n.R3)((0,r.z3)(a,"search",s.hash,s.sets,c))}(a)}))})),(0,n.Q6)("setGifSearchQuery",((e,t,s)=>{const{query:n}=s;"string"==typeof n&&R((()=>{T(n)}))})),(0,n.Q6)("searchMoreGifs",(e=>{const{query:t,offset:s}=e.gifs.search;"string"==typeof t&&R((()=>{T(t,s)}))})),(0,n.Q6)("loadStickersForEmoji",((e,t,s)=>{const{emoji:a}=s,{hash:o}=e.stickers.forEmoji;R((()=>{!async function(e,t){let s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,forEmoji:{...s.stickers.forEmoji,emoji:e}}});const a=await(0,P.t9)("fetchStickersForEmoji",{emoji:e,hash:t});s=(0,n.Rd)(),a&&s.stickers.forEmoji.emoji===e&&(s=(0,r.IM)(s,e,a.stickers,a.hash),(0,n.R3)(s))}(a,o)}))})),(0,n.Q6)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,n.Q6)("openStickerSetShortName",((e,t,s)=>{const{stickerSetShortName:n}=s;return{...e,openedStickerSetShortName:n}}));var N=s(790);const B=(0,C.P2)((e=>e()),500,!1);async function A(e="",t,s,o,c,d){let l;if(o){const n=await(0,P.t9)("searchMessagesLocal",{chatOrUser:o,query:e,type:t,limit:a.Hk,offsetId:s,minDate:d,maxDate:c});if(n){const{messages:e,users:t,totalCount:s,nextOffsetId:a}=n;l={messages:e,users:t,chats:[],totalCount:s,nextRate:a}}}else l=await(0,P.t9)("searchMessagesGlobal",{query:e,offsetRate:s,limit:a.Hk,type:t,maxDate:c,minDate:d});let u=(0,n.Rd)();const m=(0,i.JX)(u);if(!l||""!==e&&e!==m)return void(0,n.R3)((0,r.xv)(u,{messages:!1}));const{messages:h,users:p,chats:f,totalCount:I,nextRate:v}=l;f.length&&(u=(0,r.fZ)(u,(0,g.ee)(f,"id"))),p.length&&(u=(0,r.Sh)(u,(0,g.ee)(p,"id"))),h.length&&(u=(0,r.m6)(u,h)),u=(0,r.px)(u,h,I,t,v),(0,n.R3)(u)}(0,n.Q6)("setGlobalSearchQuery",((e,t,s)=>{const{chatId:a}=e.globalSearch,{query:o}=s;o&&!a&&B((()=>{!async function(e){const t=await(0,P.t9)("searchChats",{query:e});let s=(0,n.Rd)();const a=(0,i.JX)(s);if(!t||!a||e!==a)return void(0,n.R3)((0,r.xv)(s,{chats:!1}));const{localChats:o,localUsers:c,globalChats:d,globalUsers:l}=t;(o.length||d.length)&&(s=(0,r.fZ)(s,(0,g.ee)([...o,...d],"id"))),(c.length||l.length)&&(s=(0,r.Sh)(s,(0,g.ee)([...c,...l],"id"))),s=(0,r.xv)(s,{chats:!1}),s=(0,r.No)(s,{localResults:{chatIds:o.map((({id:e})=>e)),userIds:c.map((({id:e})=>e))},globalResults:{...s.globalSearch.globalResults,chatIds:d.map((({id:e})=>e)),userIds:l.map((({id:e})=>e))}}),(0,n.R3)(s)}(o)}))})),(0,n.Q6)("setGlobalSearchDate",((e,t,s)=>{const{date:a}=s,o=a?(0,N.IS)(a):a,c=(0,r.No)(e,{date:a,query:"",resultsByType:{...e.globalSearch.resultsByType,text:{totalCount:void 0,foundIds:[],nextOffsetId:0}}});(0,n.R3)(c);const{chatId:d}=e.globalSearch;A("","text",void 0,d?(0,i.Z1)(e,d):void 0,o,a)})),(0,n.Q6)("searchMessagesGlobal",((e,t,s)=>{var n;const{query:a,resultsByType:o,chatId:r,date:c}=e.globalSearch,d=c?(0,N.IS)(c):c,{type:l}=s;A(a,l,null==o||null===(n=o[l])||void 0===n?void 0:n.nextOffsetId,r?(0,i.Z1)(e,r):void 0,d,c)})),(0,n.Q6)("searchTextMessagesLocal",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{},o=t?(0,i.Z1)(e,t):void 0,c=(0,i.n5)(e);if(!o||!c||!s)return;const{query:d,results:l}=c,m=null==l?void 0:l.nextOffsetId;let h;if(s!==u._f){const n=(0,i.tZ)(e,t,s);h=null==n?void 0:n.topMessageId}!async function(e,t,s,o,c){const d=await(0,P.t9)("searchMessagesLocal",{chatOrUser:e,type:"text",query:o,topMessageId:s,limit:a.pn,offsetId:c});if(!d)return;const{messages:l,users:u,totalCount:m,nextOffsetId:h}=d,p=(0,g.ee)(l,"id"),f=Object.keys(p).map(Number);let I=(0,n.Rd)();const v=(0,i.n5)(I);!v||o&&o!==v.query||(I=(0,r.c_)(I,e.id,p),I=(0,r.Sh)(I,(0,g.ee)(u,"id")),I=(0,r.dx)(I,e.id,t,f,m,h),(0,n.R3)(I))}(o,s,h,d,m)})),(0,n.Q6)("searchMediaMessagesLocal",(e=>{const t=(0,i.og)(e),s=t?e.users.byId[t]||e.chats.byId[t]:void 0,o=(0,i.we)(e);if(!s||!o)return;const{currentType:c,resultsByType:d}=o,l=c&&d&&d[c],u=null==l?void 0:l.nextOffsetId;c&&async function(e,t,s){const o=await(0,P.t9)("searchMessagesLocal",{chatOrUser:e,type:t,limit:a.EN,offsetId:s});if(!o)return;const{messages:c,users:d,totalCount:l,nextOffsetId:u}=o,m=(0,g.ee)(c,"id"),h=Object.keys(m).map(Number);let p=(0,n.Rd)();(0,i.we)(p)&&(p=(0,r.c_)(p,e.id,m),p=(0,r.Sh)(p,(0,g.ee)(d,"id")),p=(0,r.c1)(p,e.id,t,h,l,u),(0,n.R3)(p))}(s,c,u)})),(0,n.Q6)("searchMessagesByDate",((e,t,s)=>{const{timestamp:a}=s,{chatId:o}=(0,i.Bt)(e)||{};if(!o)return;const r=(0,i.Z1)(e,o);r&&async function(e,t){const s=await(0,P.t9)("findFirstMessageIdAfterDate",{chat:e,timestamp:t});s&&(0,n.uC)().focusMessage({chatId:e.id,messageId:s})}(r,a)})),(0,n.Q6)("checkPublicLink",((e,t,s)=>{const{chatId:a}=(0,i.Bt)(e)||{};if(!a)return;if(e.management.progress===m.wv.InProgress)return;const{username:o}=s;(async()=>{e=(0,r.H9)(e,m.wv.InProgress),e=(0,r.fw)(e,a,{isUsernameAvailable:void 0}),(0,n.R3)(e);const t=await(0,P.t9)("checkChatUsername",{username:o});e=(0,n.Rd)(),e=(0,r.H9)(e,t?m.wv.Complete:m.wv.Error),e=(0,r.fw)(e,a,{isUsernameAvailable:t}),(0,n.R3)(e)})()})),(0,n.Q6)("updatePublicLink",((e,t,s)=>{const{chatId:a}=(0,i.Bt)(e)||{};let o=a&&(0,i.Z1)(e,a);if(!a||!o)return;const{username:c}=s;(async()=>{if(e=(0,r.H9)(e,m.wv.InProgress),(0,n.R3)(e),(0,d.G9)(o)){if(o=await(0,P.t9)("migrateChat",o),!o)return;t.openChat({id:o.id})}const s=await(0,P.t9)("setChatUsername",{chat:o,username:c});e=(0,n.Rd)(),e=(0,r.H9)(e,s?m.wv.Complete:m.wv.Error),e=(0,r.fw)(e,a,{isUsernameAvailable:void 0}),(0,n.R3)(e)})()})),(0,n.Q6)("updatePrivateLink",(e=>{const{chatId:t}=(0,i.Bt)(e)||{},s=t&&(0,i.Z1)(e,t);t&&s&&(0,P.t9)("updatePrivateLink",{chat:s})}));var x=s(7358);async function L(){const e=await(0,P.t9)("fetchChats",{limit:a.Ov,archived:!0,withPinned:!0,serverTimeOffset:(0,n.Rd)().serverTimeOffset});if(!e)return;let t=(0,n.Rd)();t=(0,r.eD)(t,(0,g.ee)(e.users,"id")),t=(0,r.zn)(t,e.userStatusesById),t=(0,r.GL)(t,(0,g.ee)(e.chats,"id")),t=(0,r.Mg)(t,"archived",e.chatIds),t=(0,r.vv)(t,"archived",e),(0,n.R3)(t)}async function O(){let e=(0,n.Rd)();const{recentlyFoundChatIds:t}=e.globalSearch,{userIds:s}=e.contactList||{};if(!(s&&s.length||t&&t.length))return;const a=[...t||[],...s||[]].map((t=>(0,i.dy)(e,t))).filter(Boolean),o=await(0,P.t9)("fetchUsers",{users:a});if(!o)return;const{users:c,userStatusesById:d}=o;e=(0,n.Rd)(),e=(0,r.eD)(e,(0,g.ee)(c,"id")),e=(0,r.zn)(e,d),(0,n.R3)(e)}function F(e){return(0,P.t9)("fetchMessages",{chat:e,threadId:u._f,offsetId:e.lastReadInboxMessageId,addOffset:-(Math.round(a.hT/2)+1),limit:a.hT})}(0,n.Q6)("sync",((e,t)=>{!async function(e){a.eM&&console.log(">>> START SYNC"),await(0,P.t9)("fetchCurrentUser");const t=await async function(){var e;let t=(0,n.Rd)();const s=await(0,P.t9)("fetchChats",{limit:a.Ov,withPinned:!0,serverTimeOffset:t.serverTimeOffset,lastLocalServiceMessage:null===(e=(0,i.VF)(t))||void 0===e?void 0:e.message});if(!s)return;t=(0,n.Rd)();const{recentlyFoundChatIds:o}=t.globalSearch,{userIds:c}=t.contactList||{},{currentUserId:l}=t,m=[...o||[],...c||[],...l?[l]:[]],h=m.map((e=>(0,i.dy)(t,e))).filter(Boolean),p=m.map((e=>(0,i.Z1)(t,e))).filter(Boolean),{chatId:f}=(0,i.Bt)(t)||{};if(f){const e=(0,i.Z1)(t,f);if(e&&!m.includes(f)&&p.push(e),(0,d.YC)(f)){const e=(0,i.dy)(t,f);e&&!m.includes(f)&&h.push(e)}}return h.push(...s.users),p.push(...s.chats),t=(0,r.ps)(t,s.userStatusesById),t=(0,r.SL)(t,(0,g.ee)(p,"id")),t=(0,r.Mg)(t,"active",s.chatIds),t=(0,r.vv)(t,"active",s),Object.keys(s.draftsById).forEach((e=>{t=(0,r.pf)(t,e,u._f,"draft",s.draftsById[e])})),Object.keys(s.replyingToById).forEach((e=>{t=(0,r.pf)(t,e,u._f,"replyingToId",s.replyingToById[e])})),(0,n.R3)(t),f&&!t.chats.byId[f]&&(0,n.uC)().openChat({id:void 0}),h}();await async function(e){let t=!1,s=e||[],o=(0,n.Rd)();const{chatId:c,threadId:d}=(0,i.Bt)(o)||{},l=Object.keys(o.messages.byChatId).reduce(((e,t)=>{const s=(0,i.Ms)(o,t,u._f);return s&&(e[t]=s),e}),{});if(c){const e=await F(o.chats.byId[c]);o=(0,n.Rd)();const{chatId:l}=(0,i.Bt)(o)||{},m=d&&(0,i.tZ)(o,c,d);if(e&&l===c){const n=o.messages.byChatId[c],i=c===a.aw?o.serviceNotifications.map((({message:e})=>e)):[],l=[].concat(e.messages,i),h=(0,g.ee)(l,"id"),p=Object.keys(h).map(Number);if(o={...o,messages:{...o.messages,byChatId:{}}},o=(0,r.c_)(o,c,h),o=(0,r.xj)(o,c,u._f,p),o=(0,r.y9)(o,c,u._f,p),d&&m&&m.originChannelId){const{originChannelId:e}=m,t=o.messages.byChatId[e],s=await F(o.chats.byId[e]);if(s){const e=(0,g.ee)(s.messages,"id"),a=Object.keys(e).map(Number);o={...o,messages:{...o.messages,byChatId:{...o.messages.byChatId,[m.originChannelId]:{byId:e,threadsById:{[u._f]:{...null==t?void 0:t.threadsById[u._f],listedIds:a,viewportIds:a,outlyingIds:void 0}}},[c]:{...o.messages.byChatId[c],threadsById:{...o.messages.byChatId[c].threadsById,[d]:{...null==n?void 0:n.threadsById[d],outlyingIds:void 0}}}}}}}}o=(0,r.GL)(o,(0,g.ee)(e.chats,"id")),o=(0,r.j6)(o,c,e.threadInfos),t=!0,s=Array.prototype.concat(s,e.users)}}t||(o={...o,messages:{...o.messages,byChatId:{}}}),Object.keys(l).forEach((e=>{o=(0,r.pf)(o,e,u._f,"draft",l[e])})),e?o=(0,r.s5)(o,(0,g.ee)(s,"id")):s&&(o=(0,r.eD)(o,(0,g.ee)(s,"id"))),(0,n.R3)(o);const{chatId:m,messageId:h}=o.audioPlayer;m&&h&&!(0,i.hj)(o,m,h)&&(0,n.uC)().closeAudioPlayer()}(t),(0,n.R3)({...(0,n.Rd)(),lastSyncTime:Date.now()}),a.eM&&console.log(">>> FINISH SYNC"),e()}(t.afterSync)})),(0,n.Q6)("afterSync",(()=>{!async function(){a.eM&&console.log(">>> START AFTER-SYNC"),await Promise.all([O(),L()]),await(0,P.t9)("fetchCurrentUser"),(0,x.w)((0,i.A1)((0,n.Rd)())),a.eM&&console.log(">>> FINISH AFTER-SYNC")}()}));const U=(0,C.Ds)((e=>e()),500,!1,!0),$=(0,C.P2)((e=>e()),500,!1);function D(e,t,s){return{...e,inlineBots:{...e.inlineBots,byUsername:{...e.inlineBots.byUsername,[t]:s}}}}function q(e,t){return{...e,inlineBots:{...e.inlineBots,isLoading:t}}}(0,n.Q6)("loadFullUser",((e,t,s)=>{const{userId:n}=s,a=(0,i.dy)(e,n);if(!a)return;const{id:o,accessHash:r}=a;U((()=>(0,P.t9)("fetchFullUser",{id:o,accessHash:r})))})),(0,n.Q6)("loadUser",((e,t,s)=>{const{userId:a}=s,o=(0,i.dy)(e,a);o&&(async()=>{const t=await(0,P.t9)("fetchUsers",{users:[o]});if(!t)return;const{users:s,userStatusesById:a}=t;e=(0,n.Rd)(),e=(0,r.eD)(e,(0,g.ee)(s,"id")),(0,n.R3)((0,r.ps)(e,{...e.users.statusesById,...a})),(0,n.R3)(e)})()})),(0,n.Q6)("loadTopUsers",(e=>{const{topPeers:{lastRequestedAt:t}}=e;(!t||(0,p.b)(e.serverTimeOffset)-t>60)&&async function(){const e=await(0,P.t9)("fetchTopUsers");if(!e)return;const{ids:t,users:s}=e;let a=(0,n.Rd)();a=(0,r.Sh)(a,(0,g.ee)(s,"id")),a={...a,topPeers:{...a.topPeers,userIds:t,lastRequestedAt:(0,p.b)(a.serverTimeOffset)}},(0,n.R3)(a)}()})),(0,n.Q6)("loadContactList",(()=>{!async function(){const e=await(0,P.t9)("fetchContactList");if(!e)return;let t=(0,r.Sh)((0,n.Rd)(),(0,g.ee)(e.users,"id"));t=(0,r.fZ)(t,(0,g.ee)(e.chats,"id"));const s=e=>e.lastName||e.firstName||"",a=new Intl.Collator("en-US"),o=e.users.sort(((e,t)=>a.compare(s(e),s(t)))).filter((e=>!e.isSelf));(0,n.R3)({...t,contactList:{userIds:o.map((e=>e.id))}})}()})),(0,n.Q6)("loadCurrentUser",(()=>{(0,P.t9)("fetchCurrentUser")})),(0,n.Q6)("loadCommonChats",(e=>{var t;const{chatId:s}=(0,i.Bt)(e)||{},a=s?(0,i.dy)(e,s):void 0;!a||(0,d.cS)(a)||null!==(t=a.commonChats)&&void 0!==t&&t.isFullyLoaded||(async()=>{var t,s;const o=null===(t=a.commonChats)||void 0===t?void 0:t.maxId,i=await(0,P.t9)("fetchCommonChats",a.id,a.accessHash,o);if(!i)return;const{chats:c,chatIds:d,isFullyLoaded:l}=i;e=(0,n.Rd)(),c.length&&(e=(0,r.fZ)(e,(0,g.ee)(c,"id"))),e=(0,r.Nq)(e,a.id,{commonChats:{maxId:d.length?d[d.length-1]:"0",ids:(0,g.Tw)(((null===(s=a.commonChats)||void 0===s?void 0:s.ids)||[]).concat(d)),isFullyLoaded:l}}),(0,n.R3)(e)})()})),(0,n.Q6)("updateContact",((e,t,s)=>{const{userId:a,isMuted:o,firstName:c,lastName:d}=s;!async function(e,t,s,a){const o=(0,n.Rd)(),c=(0,i.dy)(o,e);if(!c)return;let d;if((0,n.uC)().updateChatMutedState({chatId:e,isMuted:t}),(0,n.R3)((0,r.H9)((0,n.Rd)(),m.wv.InProgress)),c.phoneNumber)d=await(0,P.t9)("updateContact",{phone:c.phoneNumber,firstName:s,lastName:a});else{const{id:e,accessHash:t}=c;d=await(0,P.t9)("addContact",{id:e,accessHash:t,phoneNumber:"",firstName:s,lastName:a})}d&&(0,n.R3)((0,r.Nq)((0,n.Rd)(),c.id,{firstName:s,lastName:a})),(0,n.R3)((0,r.H9)((0,n.Rd)(),m.wv.Complete))}(a,o,c,d)})),(0,n.Q6)("deleteContact",((e,t,s)=>{const{userId:a}=s;!async function(e){const t=(0,n.Rd)(),s=(0,i.dy)(t,e);if(!s)return;const{id:a,accessHash:o}=s;await(0,P.t9)("deleteContact",{id:a,accessHash:o})}(a)})),(0,n.Q6)("loadProfilePhotos",((e,t,s)=>{const{profileId:a}=s,o=(0,d.YC)(a),c=o?(0,i.dy)(e,a):void 0,l=o?void 0:(0,i.Z1)(e,a);(c||l)&&(async()=>{const e=await(0,P.t9)("fetchProfilePhotos",c,l);if(!e||!e.photos)return;let t=(0,n.Rd)();o?t=(0,r.Nq)(t,a,{photos:e.photos}):(t=(0,r.Sh)(t,(0,g.ee)(e.users,"id")),t=(0,r.a4)(t,a,{photos:e.photos})),(0,n.R3)(t)})()})),(0,n.Q6)("setUserSearchQuery",((e,t,s)=>{const{query:a}=s;a&&$((()=>{!async function(e){const t=await(0,P.t9)("searchChats",{query:e});let s=(0,n.Rd)();const a=s.userSearch.query;if(!t||!a||e!==a)return void(0,n.R3)((0,r.Q3)(s,!1));const{localUsers:o,globalUsers:i}=t;let c,d;o.length&&(s=(0,r.Sh)(s,(0,g.ee)(o,"id")),c=o.map((({id:e})=>e))),i.length&&(s=(0,r.Sh)(s,(0,g.ee)(i,"id")),d=i.map((({id:e})=>e))),s=(0,r.Q3)(s,!1),s=(0,r.Lm)(s,{localUserIds:c,globalUserIds:d}),(0,n.R3)(s)}(a)}))})),(0,n.Q6)("addContact",((e,t,s)=>{const{userId:n}=s,a=(0,i.dy)(e,n);a&&(0,P.t9)("addContact",(0,g.ei)(a,["id","accessHash","firstName","lastName","phoneNumber"]))}));const Q=(0,C.Ds)((e=>e()),500,!1);async function G(e,t,s,n,a){await(0,P.t9)("sendMessage",{chat:e,text:s,replyingTo:n,sendAs:a})}(0,n.Q6)("clickInlineButton",((e,t,s)=>{const{button:o}=s;switch(o.type){case"command":t.sendBotCommand({command:o.value});break;case"url":o.value.match(a.FS)||o.value.match(a.g$)?t.openTelegramLink({url:o.value}):t.toggleSafeLinkModal({url:o.value});break;case"callback":{const t=(0,i.jr)(e);if(!t)return;!async function(e,t,s){const a=await(0,P.t9)("answerCallbackButton",{chatId:e.id,accessHash:e.accessHash,messageId:t,data:s});if(!a)return;const{showDialog:o,showNotification:r,toggleSafeLinkModal:i}=(0,n.uC)(),{message:c,alert:d,url:l}=a;d?o({data:{message:c||"Error"}}):c?r({message:c}):l&&i({url:l})}(t,o.messageId,o.value);break}case"requestPoll":t.openPollModal();break;case"requestSelfContact":{const s=e.currentUserId?(0,i.dy)(e,e.currentUserId):void 0;if(!s)return;t.showDialog({data:{phoneNumber:s.phoneNumber,firstName:s.firstName,lastName:s.lastName,userId:s.id}});break}case"buy":{const s=(0,i.jr)(e),{messageId:n,value:a}=o;if(!s)return;a?t.getReceipt({receiptMessageId:a,chatId:s.id,messageId:n}):(t.getPaymentForm({chat:s,messageId:n}),t.setInvoiceMessageInfo((0,i.hj)(e,s.id,n)),t.openPaymentModal({chatId:s.id,messageId:n}));break}}})),(0,n.Q6)("sendBotCommand",((e,t,s)=>{const{command:n,chatId:a}=s,{currentUserId:o}=e,r=a?(0,i.Z1)(e,a):(0,i.jr)(e),c=(0,i.Bt)(e);if(!o||!r||!c)return;const{threadId:d}=c;t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:r.id,threadId:d,value:!1}),G(r,0,n,(0,i.Yy)(e,r.id,d),(0,i._5)(e,a))})),(0,n.Q6)("restartBot",((e,t,s)=>{const{chatId:a}=s,{currentUserId:o}=e,c=(0,i.jr)(e),d=o&&(0,i.IK)(e,a);o&&c&&d&&(async()=>{await(0,P.t9)("unblockContact",d.id,d.accessHash)&&((0,n.R3)((0,r.rB)((0,n.Rd)(),d.id)),G(c,0,"/start",void 0,(0,i._5)(e,a)))})()})),(0,n.Q6)("loadTopInlineBots",(e=>{const{lastRequestedAt:t}=e.topInlineBots;t&&(0,p.b)(e.serverTimeOffset)-t<60||(async()=>{const t=await(0,P.t9)("fetchTopInlineBots");if(!t)return;const{ids:s,users:a}=t;let o=(0,n.Rd)();o=(0,r.Sh)(o,(0,g.ee)(a,"id")),o={...o,topInlineBots:{...o.topInlineBots,userIds:s,lastRequestedAt:(0,p.b)(e.serverTimeOffset)}},(0,n.R3)(o)})()})),(0,n.Q6)("queryInlineBot",((e,t,s)=>{const{chatId:a,username:o,query:c,offset:d}=s;(async()=>{let t=e.inlineBots.byUsername[o];if(!1!==t){if(void 0===t){const{user:s,chat:a}=await(0,P.t9)("fetchInlineBot",{username:o})||{};if(e=(0,n.Rd)(),!s||!a)return void(0,n.R3)(D(e,o,!1));e=(0,r.Sh)(e,{[s.id]:s}),e=(0,r.fZ)(e,{[a.id]:a}),t={id:s.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},e=D(e,o,t),(0,n.R3)(e)}(c!==t.query||t.canLoadMore)&&Q((()=>{!async function({username:e,inlineBotData:t,chatId:s,query:a,offset:o}){let r=(0,n.Rd)();const c=(0,i.dy)(r,t.id),d=(0,i.Z1)(r,s);if(!c||!d)return;const l=t.query!==a;r=q(r,!0),r=D(r,e,{...t,query:a,...l&&{offset:void 0,results:[]}}),(0,n.R3)(r);const u=await(0,P.t9)("fetchInlineBotResults",{bot:c,chat:d,query:a,offset:l?void 0:o}),m=r.inlineBots.byUsername[e];if(r=q((0,n.Rd)(),!1),!u||!m||a!==m.query)return void(0,n.R3)(r);const h=new Set((m.results||[]).map((e=>e.id))),g=u.results.filter((e=>!h.has(e.id)));r=D(r,e,{...m,help:u.help,...g.length&&{isGallery:u.isGallery},...u.switchPm&&{switchPm:u.switchPm},canLoadMore:u.results.length>0&&Boolean(u.nextOffset),results:""===m.offset||m.offset===u.nextOffset?u.results:(m.results||[]).concat(g),offset:g.length?u.nextOffset:""}),(0,n.R3)(r)}({username:o,inlineBotData:t,chatId:a,query:c,offset:d})}))}})()})),(0,n.Q6)("sendInlineBotResult",((e,t,s)=>{const{id:n,queryId:a}=s,o=(0,i.Bt)(e);if(!o||!n)return;const{chatId:r,threadId:c}=o,d=(0,i.Z1)(e,r);t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:r,threadId:c,value:!1}),(0,P.t9)("sendInlineBotResult",{chat:d,resultId:n,queryId:a,replyingTo:(0,i.Yy)(e,r,c),sendAs:(0,i._5)(e,r)})})),(0,n.Q6)("resetInlineBot",((e,t,s)=>{const{username:a}=s;let o=e.inlineBots.byUsername[a];o&&(o={id:o.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},(0,n.R3)(D(e,a,o)))})),(0,n.Q6)("startBot",((e,t,s)=>{const{botId:n,param:a}=s,o=(0,i.dy)(e,n);o&&(async()=>{await(0,P.t9)("startBot",{bot:o,startParam:a})})()})),s(9667),(0,n.Q6)("loadPasswordInfo",(()=>{(async()=>{const e=await(0,P.t9)("getPasswordInfo");if(!e)return;let t=(0,n.Rd)();t=(0,r.BI)(t,{hasPassword:e.hasPassword}),t=(0,r.IE)(t,{hint:e.hint}),(0,n.R3)(t)})()})),(0,n.Q6)("checkPassword",((e,t,s)=>{const{currentPassword:a,onSuccess:o}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,P.t9)("checkPassword",a);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1})),e&&o()})()})),(0,n.Q6)("clearPassword",((e,t,s)=>{const{currentPassword:a,onSuccess:o}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,P.t9)("clearPassword",a);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1})),e&&o()})()})),(0,n.Q6)("updatePassword",((e,t,s)=>{const{currentPassword:a,password:o,hint:i,email:c,onSuccess:d}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,P.t9)("updatePassword",a,o,i,c);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1})),e&&d()})()})),(0,n.Q6)("updateRecoveryEmail",((e,t,s)=>{const{currentPassword:a,email:o,onSuccess:i}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,P.t9)("updateRecoveryEmail",a,o);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1,waitingEmailCodeLength:void 0})),e&&i()})()})),(0,n.Q6)("provideTwoFaEmailCode",((e,t,s)=>{const{code:n}=s;(0,P.t9)("provideRecoveryEmailCode",n)})),(0,n.Q6)("clearTwoFaError",(e=>(0,r.IE)(e,{error:void 0}))),(0,n.Q6)("validateRequestedInfo",((e,t,s)=>{const{requestInfo:a,saveInfo:o}=s,c=(0,i.gx)(e),d=c&&(0,i.Z1)(e,c),l=(0,i.Mz)(e);d&&l&&async function(e,t,s,a){const o=await(0,P.t9)("validateRequestedInfo",{chat:e,messageId:t,requestInfo:s,shouldSave:a});if(!o)return;const{id:i,shippingOptions:c}=o;if(!i)return;let d=(0,r.vT)((0,n.Rd)(),i);c?(d=(0,r.TM)(d,c),d=(0,r.Q$)(d,m.KB.Shipping)):d=(0,r.Q$)(d,m.KB.PaymentInfo),(0,n.R3)(d)}(d,l,a,o)})),(0,n.Q6)("getPaymentForm",((e,t,s)=>{const{chat:a,messageId:o}=s;a&&o&&async function(e,t){const s=await(0,P.t9)("getPaymentForm",{chat:e,messageId:t});if(!s)return;let a=(0,r._7)((0,n.Rd)(),s),o=m.KB.PaymentInfo;a.payment.invoice&&(a.payment.invoice.shippingAddressRequested||a.payment.invoice.nameRequested||a.payment.invoice.phoneRequested||a.payment.invoice.emailRequested)&&(o=m.KB.ShippingInfo),a=(0,r.Q$)(a,o),(0,n.R3)(a)}(a,o)})),(0,n.Q6)("getReceipt",((e,t,s)=>{const{receiptMessageId:a,chatId:o,messageId:c}=s,d=o&&(0,i.Z1)(e,o);c&&a&&d&&async function(e,t,s){const a=await(0,P.t9)("getReceipt",e,s);if(!a)return;let o=(0,n.Rd)();const c=(0,i.hj)(o,e.id,t);o=(0,r.Dq)(o,a,c),(0,n.R3)(o)}(d,c,a)})),(0,n.Q6)("clearPaymentError",(e=>{(0,n.R3)({...e,payment:{...e.payment,error:void 0}})})),(0,n.Q6)("clearReceipt",(e=>{(0,n.R3)({...e,payment:{...e.payment,receipt:void 0}})})),(0,n.Q6)("sendCredentialsInfo",((e,t,s)=>{const a=(0,i.$$)(e);if(!a)return;const{credentials:o}=s,{data:c}=o;!async function(e,t){const s=function(e){const t=Object.keys(e).map((t=>`${t}=${e[t]}`)).join("&");return t.length>0?`?${t}`:""}({"card[number]":e.cardNumber,"card[exp_month]":e.expiryMonth,"card[exp_year]":e.expiryYear,"card[cvc]":e.cvv,"card[address_zip]":e.zip,"card[address_country]":e.country}),a=await fetch(`https://api.stripe.com/v1/tokens${s}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${t}`}}),o=await a.json();if(o.error){const e=(0,d.Ow)(o.error),t=(0,n.Rd)();return void(0,n.R3)({...t,payment:{...t.payment,error:{...e}}})}let i=(0,r.QH)((0,n.Rd)(),{type:o.type,id:o.id});i=(0,r.Q$)(i,m.KB.Checkout),(0,n.R3)(i)}(c,a)})),(0,n.Q6)("sendPaymentForm",((e,t,s)=>{const{shippingOptionId:a,saveCredentials:o}=s,c=(0,i.gx)(e),d=c&&(0,i.Z1)(e,c),l=(0,i.Mz)(e),u=(0,i.eh)(e),m=(0,i.sp)(e),h=(0,i.$$)(e),g=(0,i.i3)(e);d&&l&&h&&u&&async function(e,t,s,a,o,i){if(await(0,P.t9)("sendPaymentForm",{chat:e,messageId:t,formId:s,credentials:a,requestedInfoId:o,shippingOptionId:i})){const e=(0,r.bp)((0,n.Rd)());(0,n.R3)((0,r.WY)(e))}}(d,l,u,{save:o,data:g},m,a)})),(0,n.Q6)("setPaymentStep",((e,t,s={})=>(0,r.Q$)(e,s.step||m.KB.ShippingInfo))),(0,n.Q6)("setInvoiceMessageInfo",((e,t,s)=>(0,r.nA)(e,s))),s(4907);var j=s(8406);const H=(0,C.P2)((e=>e()),500,!0);(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateChat":{s.noTopChatsRequest||(0,i.N)(e,s.id)||t.loadTopChats();const a=(0,r.a4)(e,s.id,s.chat,s.newProfilePhoto);(0,n.R3)(a),H((()=>(0,x.w)((0,i.A1)((0,n.Rd)())))),s.chat.id&&(0,j.Vr)({chatId:s.chat.id,lastReadInboxMessageId:s.chat.lastReadInboxMessageId});break}case"updateChatJoin":{const a=(0,i.Ek)(e,s.id);if(!a)break;e=(0,r.B1)(e,a,[s.id]),e=(0,r.a4)(e,s.id,{isNotJoined:!1}),(0,n.R3)(e);const o=(0,i.Z1)(e,s.id);o&&t.requestChatUpdate({chatId:o.id});break}case"updateChatLeave":(0,n.R3)((0,r.Dd)(e,s.id));break;case"updateChatInbox":(0,n.R3)((0,r.a4)(e,s.id,s.chat)),H((()=>(0,x.w)((0,i.A1)((0,n.Rd)()))));break;case"updateChatTypingStatus":{const{id:t,typingStatus:a}=s;(0,n.R3)((0,r.a4)(e,t,{typingStatus:a})),setTimeout((()=>{const e=(0,n.Rd)(),s=(0,i.Z1)(e,t);s&&a&&s.typingStatus&&s.typingStatus.timestamp===a.timestamp&&(0,n.R3)((0,r.a4)(e,t,{typingStatus:void 0}))}),6e3);break}case"newMessage":{const{message:a}=s,{chatId:o,threadId:c,type:d}=(0,i.Bt)(e)||{};if(a.senderId===e.currentUserId&&!a.isFromScheduled)return;const l=(0,i.Z1)(e,s.chatId);if(!l)return;"thread"===d&&c===u._f&&s.chatId===o?setTimeout((()=>{t.requestChatUpdate({chatId:s.chatId})}),1500):(0,n.R3)((0,r.a4)(e,s.chatId,{unreadCount:l.unreadCount?l.unreadCount+1:1,...s.message.hasUnreadMention&&{unreadMentionsCount:l.unreadMentionsCount?l.unreadMentionsCount+1:1}})),(0,x.w)((0,i.A1)((0,n.Rd)())),(0,j.zP)({chat:l,message:a});break}case"updateCommonBoxMessages":case"updateChannelMessages":{const{ids:t,messageUpdate:a}=s;if(!1!==a.hasUnreadMention)return;t.forEach((t=>{const n="channelId"in s?s.channelId:(0,i.X5)(e,t),a=(0,i.Z1)(e,n);null!=a&&a.unreadMentionsCount&&(e=(0,r.a4)(e,n,{unreadMentionsCount:a.unreadMentionsCount-1}))})),(0,n.R3)(e);break}case"updateChatFullInfo":{const{fullInfo:t}=s,a=e.chats.byId[s.id];if(!a)return;(0,n.R3)((0,r.a4)(e,s.id,{fullInfo:{...a.fullInfo,...t}}));break}case"updatePinnedChatIds":{const{ids:t,folderId:o}=s,r=o===a.WS?"archived":"active";e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[r]:t.length?t:void 0}}},(0,n.R3)(e);break}case"updateChatPinned":{const{id:t,isPinned:o}=s,r=(0,i.Ek)(e,t);if(r){const{[r]:s}=e.chats.orderedPinnedIds;let n=s||[];if(o){if(!n.includes(t)){if("active"===r&&n.length>=a.EG){const t=e.chats.listIds.active;n=n.filter((e=>t&&t.includes(e)))}n=[t,...n]}}else n=n.filter((e=>e!==t));e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[r]:n.length?n:void 0}}}}(0,n.R3)(e);break}case"updateChatListType":{const{id:t,folderId:a}=s;(0,n.R3)((0,r.Pi)(e,t,a));break}case"updateChatFolder":{const{id:t,folder:a}=s,{byId:o,orderedIds:r}=e.chatFolders,i=a?{...o,[t]:a}:(0,g.ei)(o,Object.keys(o).map(Number).filter((e=>e!==t))),c=a?r&&r.includes(t)?r:[...r||[],t]:r?r.filter((e=>e!==t)):void 0;(0,n.R3)({...e,chatFolders:{...e.chatFolders,byId:i,orderedIds:c}});break}case"updateChatFoldersOrder":{const{orderedIds:t}=s;(0,n.R3)({...e,chatFolders:{...e.chatFolders,orderedIds:t}});break}case"updateRecommendedChatFolders":{const{folders:t}=s;(0,n.R3)({...e,chatFolders:{...e.chatFolders,recommended:t}});break}case"updateChatMembers":{var o;const t=e.chats.byId[s.id],{replacedMembers:a,addedMember:i,deletedMemberId:c}=s;if(!t)return;let d=!1,l=null!==(o=t.fullInfo)&&void 0!==o&&o.members?[...t.fullInfo.members]:[];if(a)l=a,d=!0;else if(i)l.length&&l.some((e=>e.userId===i.userId))||(l.push(i),d=!0);else if(l.length&&c){const e=l.findIndex((e=>e.userId===c));e>-1&&(l.slice(e,1),d=!0)}if(d){const a=l.filter((({isOwner:e,isAdmin:t})=>e||t));(0,n.R3)((0,r.a4)(e,s.id,{membersCount:l.length,fullInfo:{...t.fullInfo,members:l,adminMembers:a}}))}break}case"deleteProfilePhotos":{const{chatId:t,ids:a}=s,o=e.chats.byId[t];null!=o&&o.photos&&(0,n.R3)((0,r.a4)(e,t,{photos:o.photos.filter((e=>!a.includes(e.id)))}));break}case"draftMessage":{const{chatId:t,formattedText:a,date:o,replyingToId:i}=s;e.chats.byId[t]&&(e=(0,r.pf)(e,t,u._f,"draft",a),e=(0,r.pf)(e,t,u._f,"replyingToId",i),e=(0,r.a4)(e,t,{draftDate:o}),(0,n.R3)(e));break}case"showInvite":{const{data:e}=s;t.showDialog({data:e});break}}}));const _=350;function z(e,t,s,n,a=!1){const o=a?(0,i.Tm)(e,t,s):(0,i.hj)(e,t,s);if(o&&n.content){const{photo:e,video:t,sticker:s,document:a}=(0,d.qp)(o);e&&n.content.photo?(n.content.photo.blobUrl=e.blobUrl,n.content.photo.thumbnail=e.thumbnail):t&&n.content.video?n.content.video.blobUrl=t.blobUrl:s&&n.content.sticker?n.content.sticker.isPreloadedGlobally=s.isPreloadedGlobally:a&&n.content.document&&(n.content.document.previewBlobUrl=a.previewBlobUrl)}return a?(0,r.P4)(e,t,s,n):(0,r.cY)(e,t,s,n)}function V(e,t,s,n){const{chatId:a}=s,{threadInfo:o}=(0,i.Db)(e,a,s)||{};if(!o&&s.replyToMessageId){const o=(0,i.hj)(e,a,s.replyToMessageId);o?e=(0,r.lG)(e,o,a,s.id,n):t.loadMessage({chatId:a,messageId:s.replyToMessageId,threadUpdate:{isDeleting:n,lastMessageId:s.id}})}return e}function K(e,t,s){const{id:n,chatId:a}=s,{threadInfo:o,firstMessageId:c}=(0,i.Db)(e,a,s)||{},l=(0,i.Z1)(e,a),m=(null==l?void 0:l.unreadCount)&&!(0,i.gb)(e,a,u._f);if(e=V(e,t,s),o&&(!c&&(0,d.CI)(s)||(e=(0,r.xj)(e,a,o.threadId,[n]),(0,i.b9)(e,a,o.threadId)&&(e=(0,r.$S)(e,a,o.threadId,n),c||(e=(0,r.pf)(e,a,o.threadId,"firstMessageId",s.id)))),e=(0,r.pf)(e,a,o.threadId,"threadInfo",{...o,lastMessageId:s.id,messagesCount:o.messagesCount+1})),m)return e;if(e=(0,r.xj)(e,a,u._f,[n]),(0,i.b9)(e,a,u._f)){const t=(0,i.It)(e,a,u._f),s=(0,r.$S)(e,a,u._f,n),o=(0,i.Cb)(s,a,u._f);t&&!o.includes(t)||(e=s)}return e}function Y(e,t,s,n=!1){var a;const{chats:o}=e,i=null===(a=o.byId[t])||void 0===a?void 0:a.lastMessage;return!i||n||i.id===s.id||i.id===s.previousLocalId||s.id>i.id?(0,r.a4)(e,t,{lastMessage:s}):e}function W(e,t){const s=(0,i.Zw)(e,t),n=(0,i.gb)(e,t,u._f);if(!s||!n)return;let a=n.length;for(;a--;){const e=s[n[a]];if(!e.isDeleting)return e}}function X(e,t,s,a){if(e){t.forEach((t=>{const s=W(a=(0,r.cY)(a,e,t,{isDeleting:!0}),e);s&&(a=Y(a,e,s,!0))})),(0,n.R3)(a),s.requestChatUpdate({chatId:e});const o=[];return t.forEach((t=>{const n=(0,i.hj)(a,e,t);if(!n)return;a=V(a,s,n,!0);const{threadInfo:r}=(0,i.Db)(a,e,n)||{};r&&o.push(r.threadId)})),(0,n.R3)(a),void setTimeout((()=>{(0,n.R3)((0,r.K4)((0,n.Rd)(),e,t)),(0,g.Tw)(o).forEach((t=>{s.requestThreadInfoUpdate({chatId:e,threadId:t})}))}),_)}const o=[];t.forEach((e=>{const t=(0,i.X5)(a,e);if(t){o.push(t);const s=W(a=(0,r.cY)(a,t,e,{isDeleting:!0}),t);s&&(a=Y(a,t,s,!0)),setTimeout((()=>{(0,n.R3)((0,r.K4)((0,n.Rd)(),t,[e]))}),_)}})),(0,n.R3)(a),(0,g.Tw)(o).forEach((e=>{s.requestChatUpdate({chatId:e})}))}(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"newMessage":{const{chatId:o,id:c,message:l,shouldForceReply:m}=s;e=K(e=z(e,o,c,l),t,l),l.threadInfo&&(e=(0,r.Xg)(e,l.threadInfo.chatId,l.threadInfo.threadId,l.threadInfo)),(0,n.R3)(e);const h=(0,i.hj)(e,o,c);if((0,i.hg)(e,o,l)){var a;if(l.isOutgoing&&(null===(a=l.content)||void 0===a||!a.action)){const s=(0,i.Bt)(e);s&&t.focusMessage({chatId:o,threadId:s.threadId,messageId:l.id,noHighlight:!0,isResizingContainer:!0})}const{threadInfo:s}=(0,i.Db)(e,o,l)||{};s&&t.requestThreadInfoUpdate({chatId:o,threadId:s.threadId}),(0,d.CI)(l)||setTimeout((()=>{let e=(0,n.Rd)();m&&(e=(0,r.pf)(e,o,u._f,"replyingToId",c)),(0,n.R3)(Y(e,o,h))}),_)}else(0,n.R3)(Y((0,n.Rd)(),o,h));(0,i.N)(e,o)||t.loadTopChats();break}case"newScheduledMessage":{const{chatId:t,id:a,message:o}=s;e=z(e,t,a,o,!0);const c=(0,i.qy)(e,t)||[];e=(0,r.pf)(e,t,u._f,"scheduledIds",(0,g.Tw)([...c,a])),(0,n.R3)(e);break}case"updateMessage":{var o,c;const{chatId:a,id:d,message:l}=s;if(!(0,i.hj)(e,a,d))return;e=z(e,a,d,l);const m=(0,i.hj)(e,a,d);l.threadInfo&&(e=(0,r.Xg)(e,l.threadInfo.chatId,l.threadInfo.threadId,l.threadInfo)),e=Y(e,a,m),(0,n.R3)(e);const h=(0,i.Z1)(e,a);h&&!l.isOutgoing&&(null===(o=h.lastMessage)||void 0===o?void 0:o.id)===l.id&&(0,i.xo)(e,h)&&(0,i.hg)(e,a,l)&&(0,i.b9)(e,a,(null===(c=l.threadInfo)||void 0===c?void 0:c.threadId)||u._f)&&t.focusLastMessage();break}case"updateScheduledMessage":{const{chatId:t,id:a,message:o}=s;if(!(0,i.Tm)(e,t,a))return;e=z(e,t,a,o,!0);const c=Object.keys((0,i.Fn)(e,t)||{}).map(Number).sort(((e,t)=>t-e));e=(0,r.pf)(e,t,u._f,"scheduledIds",c),(0,n.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:a,localId:o,message:c}=s;e=K(e,t,c);const d=(0,i.hj)(e,a,o);e=(0,r.K4)(e,a,[o]),c.isScheduled&&(e=(0,r.bV)(e,a,[o])),e=(0,r.cY)(e,a,c.id,{...d,...c,previousLocalId:o});const l=(0,i.hj)(e,a,c.id);e=Y(e,a,l);const u=(0,i.Db)(e,a,c);null!=u&&u.threadInfo&&(t.markMessageListRead({maxId:c.id}),e=(0,r.pf)(e,a,u.threadInfo.threadId,"threadInfo",{...u.threadInfo,lastMessageId:c.id,lastReadInboxMessageId:c.id})),(0,n.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:a,message:o}=s,c=(0,i.qy)(e,t)||[];e=(0,r.pf)(e,t,u._f,"scheduledIds",[...c,o.id]);const d=(0,i.Tm)(e,t,a);e=(0,r.bV)(e,t,[a]),e=(0,r.P4)(e,t,o.id,{...d,...o,previousLocalId:a}),(0,n.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:a,messageIds:o}=s,c=(0,i.KB)(e,t)||[],d=a?[...c,...o].sort(((e,t)=>t-e)):c.filter((e=>!o.includes(e)));(0,n.R3)((0,r.pf)(e,t,u._f,"pinnedIds",d));break}case"updateThreadInfo":{const{chatId:t,threadId:a,threadInfo:o,firstMessageId:c}=s,d={...(0,i.tZ)(e,t,a),...o};if(!d.threadId)return;e=(0,r.Xg)(e,t,a,d),c&&(e=(0,r.pf)(e,t,a,"firstMessageId",c)),(0,n.R3)(e);break}case"resetMessages":{const{id:a}=s,o=(0,i.Zw)(e,a);o&&!(0,d.YC)(a)&&(e=(0,r.K4)(e,a,Object.keys(o).map(Number)),(0,n.R3)(e),t.loadFullChat({chatId:a,force:!0}));break}case"deleteMessages":{const{ids:n,chatId:a}=s;X(a,n,t,e);break}case"deleteScheduledMessages":{const{ids:t,chatId:a}=s;!function(e,t,s,a){e&&(t.forEach((t=>{a=(0,r.P4)(a,e,t,{isDeleting:!0})})),(0,n.R3)(a),setTimeout((()=>{a=(0,r.bV)((0,n.Rd)(),e,t);const s=(0,i.Fn)(a,e);a=(0,r.pf)(a,e,u._f,"scheduledIds",Object.keys(s||{}).map(Number)),(0,n.R3)(a)}),_))}(a,t,0,e);break}case"deleteHistory":{const{chatId:n}=s,a=e.messages.byChatId[n];a?X(n,Object.keys(a.byId).map(Number),t,e):t.requestChatUpdate({chatId:n});break}case"updateCommonBoxMessages":{const{ids:t,messageUpdate:a}=s;t.forEach((t=>{const s=(0,i.X5)(e,t);s&&(e=(0,r.cY)(e,s,t,a))})),(0,n.R3)(e);break}case"updateChannelMessages":{const{channelId:t,ids:a,messageUpdate:o}=s;a.forEach((s=>{e=(0,r.cY)(e,t,s,o)})),(0,n.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:a}=s,o=(0,i.ZB)(e,t);if(null!=o&&o.content.poll){const t={...o.content.poll,...a},{results:s}=t.results||{};if(s&&!s.some((e=>e.isChosen))){const{results:e}=o.content.poll.results,n=e&&e.filter((e=>e.isChosen));n&&n.forEach((e=>{const n=s.findIndex((t=>t.option===e.option));n>=0&&(t.results.results[n].isChosen=!0)}))}(0,n.R3)((0,r.cY)(e,o.chatId,o.id,{content:{...o.content,poll:t}}))}break}case"updateMessagePollVote":{const{pollId:t,userId:a,options:o}=s,c=(0,i.ZB)(e,t);if(!c||!c.content.poll||!c.content.poll.results)break;const{poll:d}=c.content,{recentVoterIds:l,totalVoters:u,results:m}=d.results,h=l?[...l]:[],g=u?u+1:1,p=m?[...m]:[];h.push(a),o.forEach((t=>{const s=p.find((e=>e.option===t)),n=p.findIndex((e=>e.option===t)),o=s?{...s}:{option:t,votersCount:0};o.votersCount+=1,a===e.currentUserId&&(o.isChosen=!0),n?p[n]=o:p.push(o)})),(0,n.R3)((0,r.cY)(e,c.chatId,c.id,{content:{...c.content,poll:{...d,results:{...d.results,recentVoterIds:h,totalVoters:g,results:p}}}}));break}case"updateServiceNotification":{const{message:n}=s;(0,i.UW)(e)&&t.createServiceNotification({message:n});break}}}));const J=(0,C.P2)((function(){const e=(0,n.Rd)();(0,n.R3)((0,r.ps)(e,{...e.users.statusesById,...ee})),ee={}}),3e3,!0);let ee={};(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"deleteContact":return(0,r.GK)(e,s.id);case"updateUser":return(0,r.Nq)(e,s.id,s.user);case"updateUserStatus":return n=s.userId,a=s.status,ee[n]=a,void J();case"updateUserFullInfo":{const{id:t,fullInfo:n}=s,a=e.users.byId[t];if(!a)return;return(0,r.Nq)(e,t,{fullInfo:{...a.fullInfo,...n}})}}var n,a})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateStickerSet":return(0,r.Rg)(e,s.id,s.stickerSet)}})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updatePeerBlocked":return s.isBlocked?(0,r.O4)((0,n.Rd)(),s.id):(0,r.rB)((0,n.Rd)(),s.id);case"updateResetContactList":(0,n.R3)({...(0,n.Rd)(),contactList:{userIds:[]}});break;case"updateFavoriteStickers":t.loadFavoriteStickers();break;case"updatePrivacy":e.settings.privacy[s.key]=s.rules}})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateNotifySettings":return(0,r.HN)(e,s.peerType,s.isSilent,s.shouldShowPreviews);case"updateNotifyExceptions":{const{chatId:t,isMuted:a,isSilent:o,shouldShowPreviews:i}=s;e.chats.byId[t]&&(e=(0,r.a4)(e,t,{isMuted:a})),(0,n.R3)((0,r.aK)(e,t,{isMuted:a,isSilent:o,shouldShowPreviews:i}));break}}})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateTwoFaStateWaitCode":return{...e,twoFaSettings:{...e.twoFaSettings,isLoading:!1,waitingEmailCodeLength:s.length}};case"updateTwoFaError":return{...e,twoFaSettings:{...e.twoFaSettings,error:s.message}}}}));var te=s(4446);(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateGroupCall":return"discarded"===s.call.connectionState?e.groupCalls.activeGroupCallId?void t.leaveGroupCall({shouldRemove:!0}):(0,te.dc)(e,s.call.id):(0,te.AH)(e,s.call.id,(0,g.CE)(s.call,["connectionState"]),void 0,s.call.participantsCount);case"updateGroupCallChatId":{const t=(0,i.Z1)(e,s.chatId);return t&&(e=(0,r.a4)(e,s.chatId,{fullInfo:{...t.fullInfo,groupCallId:s.call.id}})),e}case"updateGroupCallParticipants":{const{groupCallId:t,participants:a,nextOffset:o}=s,{currentUserId:r}=e;return e=(0,n.Rd)(),a.forEach((s=>{s.id&&(e=(0,te.B6)(e,t,s.id,s,!!o||r===s.id))})),o&&(e=(0,te.AH)(e,t,{nextOffset:o})),e}}}));var se=s(8674),ne=s(6752),ae=s(1279),oe=s(3551),re=s(3227),ie=s(3858),ce=s(1212),de=s(5332);function le(e){(0,o.d4)((()=>(0,C.Gq)(e)),[e])}var ue=s(9290);const me=document.querySelector('meta[name="viewport"]'),he=(null==me?void 0:me.getAttribute("content"))||"";function ge(e){e.preventDefault()}var pe=s(6590),fe=s(3989),Ie=s(7529),ve=s(3455),ye=s(706),Ze=s(2255);function Pe(){const[e,t]=(0,o.eJ)(window.navigator.onLine);return(0,o.d4)((()=>{function e(){t(window.navigator.onLine)}return window.addEventListener("online",e),window.addEventListener("offline",e),()=>{window.removeEventListener("offline",e),window.removeEventListener("online",e)}}),[]),e}var Ce=s(9107),we=s(6917),be=s(7926),Se=s(3106),Ee=s(8964),Me=s(231),ke=s(9589),Re=s(9187),Te=s(3321);const Ne=[0,1,2],Be=(0,o.X$)((0,n.c$)((e=>{const{query:t,fetchingStatus:s,chatId:n,date:a}=e.globalSearch,{currentUserId:o}=e,{byId:r}=e.chats,{animationLevel:c}=e.settings.byKey;return{searchQuery:t,isLoading:!!s&&Boolean(s.chats||s.messages),currentUserId:o,chatsById:r,globalSearchChatId:n,searchDate:a,theme:(0,i.Pu)(e),animationLevel:c}}))((({content:e,contactsFilter:t,onSearchQuery:s,onSelectSettings:r,onSelectContacts:i,onSelectArchived:c,onReset:l,searchQuery:u,isLoading:g,shouldSkipTransition:p,currentUserId:f,globalSearchChatId:I,searchDate:v,theme:y,animationLevel:Z,chatsById:P})=>{const{openChat:C,openTipsChat:w,setGlobalSearchDate:b,setSettingOption:S,setGlobalSearchChatId:E}=(0,n.uC)(),M=(0,Ce.Z)(),k=e===m.du.ChatList,R=(0,o.Ye)((()=>v?(0,N.xH)(new Date(1e3*v)):void 0),[v]),T=(0,o.Ye)((()=>k&&P?Object.values(P).reduce(((e,t)=>(0,d.pE)(t)&&t.unreadCount?e+1:e),0):0),[k,P]),B="web.telegram.org"===window.location.hostname,A=(0,o.Ye)((()=>({onTrigger:e,isOpen:t})=>o.ZP.createElement(Me.Z,{round:!0,ripple:k&&!h.wB,size:"smaller",color:"translucent",className:t?"active":"",onClick:k?e:()=>l(),ariaLabel:k?M("AccDescrOpenMenu2"):"Return to chat list"},o.ZP.createElement("div",{className:(0,ne.Z)("animated-menu-icon",!k&&"state-back",p&&"no-animation")}))),[k,M,l,p]),x=(0,o.I4)((()=>{u||s("")}),[u,s]),L=(0,o.I4)((()=>{C({id:f,shouldReplaceHistory:!0})}),[f,C]),O=(0,o.I4)((e=>{e.stopPropagation();const t="light"===y?"dark":"light";S({theme:t}),S({shouldUseSystemTheme:!1}),(0,we.Z)(t,Z===a.zy)}),[Z,S,y]),F=(0,o.I4)((e=>{e.stopPropagation();const t=0===Z?2:0;Ne.forEach(((e,s)=>{document.body.classList.toggle(`animation-level-${s}`,t===s)})),S({animationLevel:t})}),[Z,S]),U=Boolean(I)||e===m.du.GlobalSearch||e===m.du.Contacts,$=e===m.du.Contacts?M("SearchFriends"):M("Search");return o.ZP.createElement("div",{className:"LeftMainHeader"},o.ZP.createElement("div",{id:"LeftMainHeader",className:"left-header"},o.ZP.createElement(Se.Z,{trigger:A,footer:`${a.iC} ${a.Ji}`},o.ZP.createElement(Ee.Z,{icon:"saved-messages",onClick:L},M("SavedMessages")),o.ZP.createElement(Ee.Z,{icon:"archive",onClick:c},o.ZP.createElement("span",{className:"menu-item-name"},M("ArchivedChats")),T>0&&o.ZP.createElement("div",{className:"archived-badge"},T)),o.ZP.createElement(Ee.Z,{icon:"user",onClick:i},M("Contacts")),o.ZP.createElement(Ee.Z,{icon:"settings",onClick:r},M("Settings")),o.ZP.createElement(Ee.Z,{icon:"darkmode",onClick:O},o.ZP.createElement("span",{className:"menu-item-name"},M("lng_menu_night_mode")),o.ZP.createElement(Te.Z,{id:"darkmode",label:M("dark"===y?"lng_settings_disable_night_theme":"lng_settings_enable_night_theme"),checked:"dark"===y,noAnimation:!0})),o.ZP.createElement(Ee.Z,{icon:"animations",onClick:F},o.ZP.createElement("span",{className:"menu-item-name capitalize"},M("Appearance.Animations").toLowerCase()),o.ZP.createElement(Te.Z,{id:"animations",label:"Toggle Animations",checked:Z>0})),o.ZP.createElement(Ee.Z,{icon:"help",onClick:()=>{w({langCode:M.code})}},M("TelegramFeatures")),o.ZP.createElement(Ee.Z,{icon:"bug",href:a.mU},"Report Bug"),B&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Ee.Z,{icon:"char-K",href:"https://web.telegram.org/k/",onClick:()=>{(0,be.L)("K"),(0,pe.Wv)()}},"Switch to K Version"),o.ZP.createElement(Ee.Z,{icon:"char-W",href:"https://web.telegram.org/?legacy=1",onClick:pe.Wv},"Switch to Old Version"))),o.ZP.createElement(ke.Z,{inputId:"telegram-search-input",parentContainerClassName:"LeftSearch",className:I||v?"with-picker-item":"",value:t||u,focused:U,isLoading:g,placeholder:$,autoComplete:"off",canClose:Boolean(I||v),onChange:s,onReset:l,onFocus:x},R&&o.ZP.createElement(Re.Z,{icon:"calendar",title:R,canClose:!0,isMinimized:Boolean(I),className:"search-date",onClick:b,clickArg:{date:void 0}}),I&&o.ZP.createElement(Re.Z,{chatOrUserId:I,onClick:E,canClose:!0,clickArg:{id:void 0}}))))})));var Ae=s(9204);const xe=(0,o.X$)((()=>{const e=(0,Ce.Z)();return o.ZP.createElement("div",{id:"ConnectionState",dir:e.isRtl?"rtl":void 0},o.ZP.createElement(Ae.Z,{color:"black"}),o.ZP.createElement("div",{className:"state-text"},e("WaitingForNetwork")))}));var Le=s(1174),Oe=s(6071),Fe=s(3133),Ue=s(1080);const $e=(0,o.X$)((0,n.c$)((e=>{const{chats:{listIds:t,byId:s},users:{byId:n},chatFolders:{byId:a,orderedIds:o,activeChatFolder:r},currentUserId:c,lastSyncTime:d,shouldSkipHistoryAnimations:l}=e;return{allListIds:t,chatsById:s,usersById:n,chatFoldersById:a,orderedFolderIds:o,lastSyncTime:d,notifySettings:(0,i.dZ)(e),notifyExceptions:(0,i.NJ)(e),activeChatFolder:r,currentUserId:c,shouldSkipHistoryAnimations:l}}))((({allListIds:e,chatsById:t,usersById:s,chatFoldersById:r,notifySettings:i,notifyExceptions:c,orderedFolderIds:l,activeChatFolder:u,currentUserId:m,lastSyncTime:p,shouldSkipHistoryAnimations:f,foldersDispatch:I,onScreenSelect:v})=>{const{loadChatFolders:y,setActiveChatFolder:Z,openChat:P}=(0,n.uC)(),C=(0,o.sO)(null),w=(0,Ce.Z)();(0,o.d4)((()=>{p&&y()}),[p,y]);const b=(0,o.Ye)((()=>l?l.map((e=>r[e]||{})).filter(Boolean):void 0),[r,l]),S=((n,a,r)=>{const l=(0,Oe.Z)(3e3,!0),[u,m]=(0,o.eJ)(),[h,p,f]=(0,ye.Z)();return(0,se.ZP)(p,f),(0,ue.Z)((()=>{h||l((()=>{m((()=>{if(!b||!b.length)return;const n=b.map((n=>{const{unreadDialogsCount:a,hasActiveDialogs:o}=(0,d.Fu)(e,t,s,n,i,c)||{};return{id:n.id,badgeCount:a,isBadgeActive:o}}));return(0,g.ee)(n,"id")})())}))}),r.concat([h])),u})(0,0,[b,e,t,s,i,c]),E=(0,o.Ye)((()=>{if(b&&b.length)return[{title:"en"===w.code?"All":w("FilterAllChats"),id:a.Nf},...b.map((e=>({title:e.title,...null==S?void 0:S[e.id]})))]}),[b,S,w]),M=(0,o.I4)((e=>{Z(e,{forceOnHeavyAnimation:!0})}),[Z]);(0,o.d4)((()=>{E&&E.length&&u>=E.length&&Z(0)}),[u,E,Z]),(0,o.d4)((()=>{if(C.current&&h.$b&&E&&E.length)return(0,Le.s)(C.current,{selectorToPreventScroll:".chat-list",onSwipe:(e,t)=>t===Le.e.Left?(Z(Math.min(u+1,E.length-1),{forceOnHeavyAnimation:!0}),!0):t===Le.e.Right&&(Z(Math.max(0,u-1),{forceOnHeavyAnimation:!0}),!0)})}),[u,E,Z]);const k=(0,o.sO)();k.current=0!==u,(0,o.d4)((()=>k.current?(0,fe.Z)((()=>{k.current&&Z(0)})):void 0),[u,Z]),(0,pe.ZP)(0!==u,(()=>Z(0,{forceOnHeavyAnimation:!0}))),(0,o.d4)((()=>{const e=e=>{if(e.ctrlKey&&e.shiftKey&&e.code.startsWith("Digit")&&E){const[,t]=e.code.match(/Digit(\d)/)||[];if(!t)return;if("0"===t)return void P({id:m,shouldReplaceHistory:!0});const s=Number(t)-1;if(s>E.length-1)return;Z(s,{forceOnHeavyAnimation:!0}),e.preventDefault()}};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}}));const{shouldRender:R,transitionClassNames:T}=(0,ce.Z)(!l,void 0,!0);function N(e){const t=Object.values(r).find((({id:e})=>e===E[u].id));return t&&0!==u?o.ZP.createElement(Ue.Z,{folderType:"folder",folderId:t.id,isActive:e,onScreenSelect:v,foldersDispatch:I}):o.ZP.createElement(Ue.Z,{folderType:"all",isActive:e,foldersDispatch:I,onScreenSelect:v})}return o.ZP.createElement("div",{className:"ChatFolders"},null!=E&&E.length?o.ZP.createElement(Fe.Z,{tabs:E,activeTab:u,onSwitchTab:M}):R?o.ZP.createElement("div",{className:(0,ne.Z)("tabs-placeholder",T)}):void 0,o.ZP.createElement(Ze.Z,{ref:C,name:f?"none":w.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:u,renderCount:E?E.length:void 0},N))})));var De=s(9203),qe=s(8778),Qe=s(4288);const Ge=(0,o.X$)((e=>{const t=(0,qe.Z)(De.gl.Extra,"LeftSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(Qe.Z,null)})),je=(0,o.X$)((e=>{const t=(0,qe.Z)(De.gl.Extra,"ContactList");return t?o.ZP.createElement(t,e):o.ZP.createElement(Qe.Z,null)}));var He=s(2328);let _e;const ze=(0,o.X$)((({isShown:e,onNewPrivateChat:t,onNewChannel:s,onNewGroup:n})=>{const[a,r]=(0,o.eJ)(!1);(0,o.d4)((()=>{e||r(!1)}),[e]);const i=(0,Ce.Z)(),c=(0,ne.Z)("NewChatButton",e&&"revealed",a&&"menu-is-open"),d=(0,o.I4)((()=>{_e&&(clearTimeout(_e),_e=void 0)}),[]),l=(0,o.I4)((()=>{_e&&(clearTimeout(_e),_e=void 0),_e=window.setTimeout((()=>{r(!1)}),750)}),[]);return o.ZP.createElement("div",{className:c,onMouseEnter:d,onMouseLeave:l},o.ZP.createElement(Me.Z,{round:!0,color:"primary",className:a?"active":"",onClick:()=>{r(!a)},ariaLabel:i(a?"Close":"NewMessageTitle"),tabIndex:-1},o.ZP.createElement("i",{className:"icon-new-chat-filled"}),o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(He.Z,{isOpen:a,positionX:"right",positionY:"bottom",autoClose:!0,onClose:()=>{r(!1)}},o.ZP.createElement(Ee.Z,{icon:"channel",onClick:s},i("NewChannel")),o.ZP.createElement(Ee.Z,{icon:"group",onClick:n},i("NewGroup")),o.ZP.createElement(Ee.Z,{icon:"user",onClick:t},i("NewMessageTitle"))))}));var Ve=s(126);const Ke=Object.keys(m.du).length/2;let Ye;const We=(0,n.c$)((e=>(0,g.ei)(e,["connectionState"])))((({content:e,searchQuery:t,searchDate:s,contactsFilter:n,shouldSkipTransition:a,foldersDispatch:r,onSearchQuery:i,onContentChange:c,onScreenSelect:d,onReset:l,connectionState:u})=>{const[g,p]=(0,o.eJ)(h.$b),f=!Pe()||"connectionStateConnecting"===u,I=(0,o.sO)(!1),v=(0,o.I4)((()=>{c(m.du.Settings)}),[c]),y=(0,o.I4)((()=>{c(m.du.Contacts)}),[c]),Z=(0,o.I4)((()=>{c(m.du.NewChannelStep1)}),[c]),P=(0,o.I4)((()=>{c(m.du.NewGroupStep1)}),[c]),C=(0,o.I4)((()=>{c(m.du.Archived)}),[c]),w=(0,o.I4)((()=>{e===m.du.ChatList&&(I.current=!0,p(!0))}),[e]),b=(0,o.I4)((()=>{I.current=!1,Ye&&(clearTimeout(Ye),Ye=void 0),Ye=window.setTimeout((()=>{I.current||p(!1)}),250)}),[]);(0,o.d4)((()=>{let t;return e!==m.du.ChatList?t=window.setTimeout((()=>{p(!1)}),250):(I.current||h.$b)&&p(!0),()=>{t&&(clearTimeout(t),t=void 0)}}),[e]);const[S,E,M]=function(){const[e,t]=(0,ye.Z)(!1);(0,o.d4)((()=>{const e=window.setTimeout(t,2592e5);return()=>{clearTimeout(e)}}),[t]);const{shouldRender:s,transitionClassNames:n}=(0,ce.Z)(e);return[s,n,()=>{window.location.reload()}]}(),k=(0,Ce.Z)();return o.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:h.$b?void 0:w,onMouseLeave:h.$b?void 0:b},o.ZP.createElement(Be,{content:e,contactsFilter:n,onSearchQuery:i,onSelectSettings:v,onSelectContacts:y,onSelectArchived:C,onReset:l,shouldSkipTransition:a}),o.ZP.createElement(Ve.Z,{isOpen:f,isCustom:!0,className:"connection-state-wrapper opacity-transition slow"},(()=>o.ZP.createElement(xe,null))),o.ZP.createElement(Ze.Z,{name:a?"none":"zoom-fade",renderCount:Ke,activeKey:e,shouldCleanup:!0,cleanupExceptionKey:m.du.ChatList,className:f?"pull-down":void 0},(a=>{switch(e){case m.du.ChatList:return o.ZP.createElement($e,{onScreenSelect:d,foldersDispatch:r});case m.du.GlobalSearch:return o.ZP.createElement(Ge,{searchQuery:t,searchDate:s,isActive:a,onReset:l});case m.du.Contacts:return o.ZP.createElement(je,{filter:n,isActive:a,onReset:l});default:return}})),S&&o.ZP.createElement(Me.Z,{fluid:!0,pill:!0,className:(0,ne.Z)("btn-update",E),onClick:M},k("lng_update_telegram")),o.ZP.createElement(ze,{isShown:g,onNewPrivateChat:y,onNewChannel:Z,onNewGroup:P}))})),Xe=(0,o.X$)((e=>{const t=(0,qe.Z)(De.gl.Extra,"Settings");return t?o.ZP.createElement(t,e):o.ZP.createElement(Qe.Z,null)})),Je=(0,o.X$)((e=>{const t=(0,qe.Z)(De.gl.Extra,"NewChat");return t?o.ZP.createElement(t,e):o.ZP.createElement(Qe.Z,null)})),et=(0,o.X$)((e=>{const t=(0,qe.Z)(De.gl.Extra,"ArchivedChats");return t?o.ZP.createElement(t,e):o.ZP.createElement(Qe.Z,null)}));var tt;!function(e){e[e.Main=0]="Main",e[e.Settings=1]="Settings",e[e.Archived=2]="Archived",e[e.NewGroup=3]="NewGroup",e[e.NewChannel=4]="NewChannel"}(tt||(tt={}));const st=Object.keys(tt).length/2,nt=(0,o.X$)((0,n.c$)((e=>{const{globalSearch:{query:t,date:s},chatFolders:{activeChatFolder:n},shouldSkipHistoryAnimations:a,leftColumnWidth:o}=e;return{searchQuery:t,searchDate:s,activeChatFolder:n,shouldSkipHistoryAnimations:a,leftColumnWidth:o}}))((({searchQuery:e,searchDate:t,activeChatFolder:s,shouldSkipHistoryAnimations:a,leftColumnWidth:r})=>{const{setGlobalSearchQuery:i,setGlobalSearchChatId:c,resetChatCreation:d,setGlobalSearchDate:l,loadPasswordInfo:u,clearTwoFaError:g,setLeftColumnWidth:p,resetLeftColumnWidth:f}=(0,n.uC)(),I=(0,o.sO)(null),[v,y]=(0,o.eJ)(m.du.ChatList),[Z,P]=(0,o.eJ)(m.MT.Main),[C,w]=(0,o.eJ)(""),[b,S]=(0,ve.ZP)(),[E,M]=(0,o.eJ)(0);let k=tt.Main;switch(v){case m.du.Archived:k=tt.Archived;break;case m.du.Settings:k=tt.Settings;break;case m.du.NewChannelStep1:case m.du.NewChannelStep2:k=tt.NewChannel;break;case m.du.NewGroupStep1:case m.du.NewGroupStep2:k=tt.NewGroup}const R=(0,o.I4)((e=>{if(v!==m.du.NewGroupStep2||e)if(v!==m.du.NewChannelStep2||e){if(v===m.du.NewGroupStep1){const e=document.getElementById("new-group-picker-search");e&&e.blur()}if(v===m.du.Settings)switch(Z){case m.MT.EditProfile:case m.MT.Folders:case m.MT.General:case m.MT.Notifications:case m.MT.DataStorage:case m.MT.Privacy:case m.MT.Language:return void P(m.MT.Main);case m.MT.GeneralChatBackground:return void P(m.MT.General);case m.MT.GeneralChatBackgroundColor:return void P(m.MT.GeneralChatBackground);case m.MT.PrivacyPhoneNumber:case m.MT.PrivacyLastSeen:case m.MT.PrivacyProfilePhoto:case m.MT.PrivacyForwarding:case m.MT.PrivacyGroupChats:case m.MT.PrivacyActiveSessions:case m.MT.PrivacyBlockedUsers:case m.MT.TwoFaDisabled:case m.MT.TwoFaEnabled:case m.MT.TwoFaCongratulations:return void P(m.MT.Privacy);case m.MT.PrivacyPhoneNumberAllowedContacts:case m.MT.PrivacyPhoneNumberDeniedContacts:return void P(m.MT.PrivacyPhoneNumber);case m.MT.PrivacyLastSeenAllowedContacts:case m.MT.PrivacyLastSeenDeniedContacts:return void P(m.MT.PrivacyLastSeen);case m.MT.PrivacyProfilePhotoAllowedContacts:case m.MT.PrivacyProfilePhotoDeniedContacts:return void P(m.MT.PrivacyProfilePhoto);case m.MT.PrivacyForwardingAllowedContacts:case m.MT.PrivacyForwardingDeniedContacts:return void P(m.MT.PrivacyForwarding);case m.MT.PrivacyGroupChatsAllowedContacts:case m.MT.PrivacyGroupChatsDeniedContacts:return void P(m.MT.PrivacyGroupChats);case m.MT.TwoFaNewPassword:return void P(m.MT.TwoFaDisabled);case m.MT.TwoFaNewPasswordConfirm:return void P(m.MT.TwoFaNewPassword);case m.MT.TwoFaNewPasswordHint:return void P(m.MT.TwoFaNewPasswordConfirm);case m.MT.TwoFaNewPasswordEmail:return void P(m.MT.TwoFaNewPasswordHint);case m.MT.TwoFaNewPasswordEmailCode:return void P(m.MT.TwoFaNewPasswordEmail);case m.MT.TwoFaChangePasswordCurrent:case m.MT.TwoFaTurnOff:case m.MT.TwoFaRecoveryEmailCurrentPassword:return void P(m.MT.TwoFaEnabled);case m.MT.TwoFaChangePasswordNew:return void P(m.MT.TwoFaChangePasswordCurrent);case m.MT.TwoFaChangePasswordConfirm:return void P(m.MT.TwoFaChangePasswordNew);case m.MT.TwoFaChangePasswordHint:return void P(m.MT.TwoFaChangePasswordConfirm);case m.MT.TwoFaRecoveryEmail:return void P(m.MT.TwoFaRecoveryEmailCurrentPassword);case m.MT.TwoFaRecoveryEmailCode:return void P(m.MT.TwoFaRecoveryEmail);case m.MT.FoldersCreateFolder:case m.MT.FoldersEditFolder:return void P(m.MT.Folders);case m.MT.FoldersIncludedChatsFromChatList:case m.MT.FoldersExcludedChatsFromChatList:return void P(m.MT.FoldersEditFolderFromChatList);case m.MT.FoldersEditFolderFromChatList:return y(m.du.ChatList),void P(m.MT.Main)}v!==m.du.ChatList||0!==s?(y(m.du.ChatList),w(""),i({query:""}),l({date:void 0}),c({id:void 0}),d(),setTimeout((()=>{M(Date.now())}),250)):y(m.du.GlobalSearch)}else y(m.du.NewChannelStep1);else y(m.du.NewGroupStep1)}),[v,s,Z,i,l,c,d]),T=(0,o.I4)((t=>{v!==m.du.Contacts?(y(m.du.GlobalSearch),t!==e&&i({query:t})):w(t)}),[v,e,i]);(0,o.d4)((()=>v!==m.du.ChatList||0===s?(0,fe.Z)((()=>R())):void 0),[s,v,R]),(0,o.d4)((()=>{if(v!==m.du.GlobalSearch)return document.addEventListener("keydown",e,!1),()=>{document.removeEventListener("keydown",e,!1)};function e(e){(h.jm&&e.metaKey||!h.jm&&e.ctrlKey)&&e.shiftKey&&"f"===(0,Ie.Z)(e)&&(e.preventDefault(),y(m.du.GlobalSearch))}}),[v]),(0,o.d4)((()=>{g(),Z===m.MT.Privacy&&u()}),[g,u,Z]);const{initResize:N,resetResize:B,handleMouseUp:A}=((e,t,s,n)=>{const[a,r,i]=(0,ye.Z)(),[c,d]=(0,o.eJ)(),[l,u]=(0,o.eJ)();(0,o.d4)((()=>{e.current&&n&&(e.current.style.width=`${n}px`)}),[e,n]);const m=()=>{document.body.classList.remove("no-selection","cursor-ew-resize")};return(0,o.d4)((()=>{if(!a)return;const s=t=>{const s=Math.ceil(l+t.clientX-c);e.current.style.width=`${s}px`},n=()=>{m(),document.removeEventListener("mousemove",s,!1),document.removeEventListener("mouseup",n,!1),document.removeEventListener("blur",n,!1),t(e.current.offsetWidth),i()};document.addEventListener("mousemove",s,!1),document.addEventListener("mouseup",n,!1),document.addEventListener("blur",n,!1)}),[l,c,e,t,a,i]),{initResize:t=>{document.body.classList.add("no-selection","cursor-ew-resize"),d(t.clientX),u(e.current.offsetWidth),r()},resetResize:t=>{t.preventDefault(),e.current.style.width="",s()},handleMouseUp:m}})(I,p,f,r),x=e=>{y(m.du.Settings),P(e)};return o.ZP.createElement("div",{id:"LeftColumn",ref:I},o.ZP.createElement(Ze.Z,{name:a?"none":h.s0,renderCount:st,activeKey:k,shouldCleanup:!0,cleanupExceptionKey:tt.Main},(s=>{switch(k){case tt.Archived:return o.ZP.createElement(et,{isActive:s,onReset:R,onContentChange:y});case tt.Settings:return o.ZP.createElement(Xe,{isActive:s,currentScreen:Z,foldersState:b,foldersDispatch:S,onScreenSelect:x,onReset:R,shouldSkipTransition:a});case tt.NewChannel:return o.ZP.createElement(Je,{key:E,isActive:s,isChannel:!0,content:v,onContentChange:y,onReset:R});case tt.NewGroup:return o.ZP.createElement(Je,{key:E,isActive:s,content:v,onContentChange:y,onReset:R});default:return o.ZP.createElement(We,{content:v,searchQuery:e,searchDate:t,contactsFilter:C,foldersDispatch:S,onContentChange:y,onSearchQuery:T,onScreenSelect:x,onReset:R,shouldSkipTransition:a})}})),o.ZP.createElement("div",{className:"resize-handle",onMouseDown:N,onMouseUp:A,onDoubleClick:B}))})));var at=s(2420),ot=s(5780),rt=s(9524),it=s(1394);const ct=()=>{const[e,t]=(0,o.eJ)(ie.Z.get());return(0,o.d4)((()=>{const e=(0,C.P2)((()=>{t(ie.Z.get())}),250,!1);return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),e};var dt=s(2678),lt=s(7204),ut=s(5326);const mt=728;var ht=s(3570),gt=s(5790),pt=s(8360),ft=s(2155),It=s(6058),vt=s(8799);const yt=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"HeaderMenuContainer",!t);return s?o.ZP.createElement(s,e):void 0})),Zt=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,messageListType:n})=>{var a;const o=(0,i.Z1)(e,t),r=Boolean(o&&(0,d.eA)(o));if(!o||o.isRestricted||(0,i.CA)(e))return{noMenu:!0};const c=(0,i.IK)(e,t),l=(0,i.FM)(e,t),m="thread"===n&&s===u._f,g="thread"===n&&s!==u._f,p=(0,i.Jf)(e),f=Boolean(c&&(0,i.s4)(e,c.id)),I=!f&&Boolean((0,i.pk)(e,t)),v=Boolean(m&&(r||(0,d.ZV)(o))&&o.isNotJoined);return{noMenu:!1,isChannel:r,isRightColumnShown:p,canStartBot:I,canRestartBot:f,canSubscribe:v,canSearch:m||g,canCall:h.Bi&&(0,d.YC)(o.id)&&!l&&!c,canMute:m&&!l&&!v,canLeave:m&&!v,canEnterVoiceChat:h.Bi&&o.isCallActive,canCreateVoiceChat:h.Bi&&!o.isCallActive&&((null===(a=o.adminRights)||void 0===a?void 0:a.manageCall)||o.isCreator&&(0,d.G9)(o))}}))((({chatId:e,threadId:t,noMenu:s,isChannel:a,canStartBot:r,canRestartBot:i,canSubscribe:c,canSearch:d,canCall:l,canMute:u,canLeave:m,canEnterVoiceChat:g,canCreateVoiceChat:p,isRightColumnShown:f,canExpandActions:I})=>{const{joinChannel:v,sendBotCommand:y,openLocalTextSearch:Z,restartBot:P,openCallFallbackConfirm:C}=(0,n.uC)(),w=(0,o.sO)(null),[b,S]=(0,o.eJ)(!1),[E,M]=(0,o.eJ)(void 0),k=(0,o.I4)((()=>{S(!0);const e=w.current.getBoundingClientRect();M({x:e.right,y:e.bottom})}),[]),R=(0,o.I4)((()=>{S(!1)}),[]),T=(0,o.I4)((()=>{M(void 0)}),[]),N=(0,o.I4)((()=>{v({chatId:e})}),[v,e]),B=(0,o.I4)((()=>{y({command:"/start"})}),[y]),A=(0,o.I4)((()=>{P({chatId:e})}),[e,P]),x=(0,o.I4)((()=>{Z(),h.wB?document.querySelector("#MobileSearch input").focus():setTimeout((()=>{const e=document.querySelector(".RightHeader .SearchInput input");e&&e.focus()}),400)}),[Z]);(0,o.d4)((()=>{if(d)return document.addEventListener("keydown",e,!1),()=>{document.removeEventListener("keydown",e,!1)};function e(e){h.fl&&(h.jm&&e.metaKey||!h.jm&&e.ctrlKey)&&!e.shiftKey&&"f"===(0,Ie.Z)(e)&&(e.preventDefault(),x())}}),[d,x]);const L=(0,Ce.Z)();return o.ZP.createElement("div",{className:"HeaderActions"},!h.wB&&o.ZP.createElement(o.ZP.Fragment,null,I&&c&&o.ZP.createElement(Me.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:N},L(a?"ProfileJoinChannel":"ProfileJoinGroup")),I&&r&&o.ZP.createElement(Me.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:B},L("BotStart")),I&&i&&o.ZP.createElement(Me.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:A},L("BotRestart")),d&&o.ZP.createElement(Me.Z,{round:!0,ripple:f,color:"translucent",size:"smaller",onClick:x,ariaLabel:"Search in this chat"},o.ZP.createElement("i",{className:"icon-search"})),l&&o.ZP.createElement(Me.Z,{round:!0,color:"translucent",size:"smaller",onClick:C,ariaLabel:"Call"},o.ZP.createElement("i",{className:"icon-phone"}))),o.ZP.createElement(Me.Z,{ref:w,className:b?"active":"",round:!0,ripple:!h.wB,size:"smaller",color:"translucent",disabled:s,ariaLabel:"More actions",onClick:k},o.ZP.createElement("i",{className:"icon-more"})),E&&o.ZP.createElement(yt,{chatId:e,threadId:t,isOpen:b,anchor:E,withExtraActions:h.wB||!I,isChannel:a,canStartBot:r,canRestartBot:i,canSubscribe:c,canSearch:d,canCall:l,canMute:u,canLeave:m,canEnterVoiceChat:g,canCreateVoiceChat:p,onSubscribeChannel:N,onSearchClick:x,onClose:R,onCloseAnimationEnd:T}))})));var Pt=s(4399),Ct=s(2340),wt=s(6202),bt=s(862);function St(e){var t;const s=e&&(0,d.DH)(e),n=null==e||null===(t=e.content)||void 0===t?void 0:t.sticker,r=s&&n&&!(0,h.on)()&&s.includes("image/webp"),[i,c]=(0,o.eJ)(bt.Hu),l=null==e?void 0:e.id;return(0,o.bt)((()=>{r&&(0,bt.p6)(`b64-${l}`,s).then(c).catch((e=>{a.eM&&console.error(e)}))}),[l,r,s]),r?i:s}var Et=s(7551),Mt=s(8512);function kt(e,t,s,n,a){return`M${e},${t+a}a${a},${a},0,0,1,\n ${s},0v${n-2*a}a${a},${a},0,0,1,${-s},0Z`}const Rt=(0,o.X$)((({count:e,index:t})=>{const s=(0,o.sO)(null),n=(0,o.Ye)((()=>function(e,t){const s=e-t-1,n=function(e){let t=8;return 1===e?t=36:2===e?t=17:3===e?t=11:(4===e||e>3)&&(t=7.5),t}(e),a=function(e,t){let s=36;return 1===e?s=36:2===e?s=17:3===e?s=1===t?12:11:(4===e||e>3)&&(s=7.5),s}(e,s),o=function(e,t){return e<=3?36:t*e+2*(e-1)}(e,n),r=`clipPath${e}`;return{markHeight:a,clipPath:function(e,t,s){let n="";if(3===s)n=kt(0,0,2,t,1)+kt(0,12,2,t+1,1)+kt(0,25,2,t,1);else for(let e=0;e\n \n `}(r,n,e),markTranslateY:function(e,t,s){return 1===s?0:2===s?0===e?0:t+2:3===s?0===e?0:1===e?12:25:(t+2)*e}(s,n,e),trackTranslateY:function(e,t,s,n){return t<=4||e<=1?0:e>=t-2?n-36:(s+4)/2+(e-2)*(s+2)}(s,e,n,o),trackHeight:o,clipPathId:r}}(e,t)),[e,t]);if((0,o.d4)((()=>{if(!s.current)return;const{trackHeight:e,trackTranslateY:t,markHeight:a,markTranslateY:o,clipPathId:r,clipPath:i}=n,c=s.current.firstElementChild;if(null!=s&&s.current){const n=s.current,{style:d}=n;d.height=`${e}px`,d.transform=`translateY(-${t}px)`,d.clipPath=`url("#${r}")`;const l=n.querySelector("svg"),u=n.querySelector("div"),m=n.querySelector("defs");l||c&&(c.innerHTML=` ${i} `),m&&(m.innerHTML=i),u&&(u.style.height=`${a}px`,u.style.transform=`translateY(${o}px)`)}}),[n]),1===e)return o.ZP.createElement("div",{className:"pinned-message-border"},o.ZP.createElement("div",{className:"pinned-message-border-wrapper-1",ref:s}));const{trackHeight:a,trackTranslateY:r,markHeight:i,markTranslateY:c,clipPathId:d}=n;return o.ZP.createElement("div",{className:(0,ne.Z)("pinned-message-border",e>4&&"pinned-message-border-mask")},o.ZP.createElement("div",{className:"pinned-message-border-wrapper",ref:s,style:`clip-path: url("#${d}"); width: 2px;\n height: ${a}px; transform: translateY(-${r}px);`},o.ZP.createElement("span",null),o.ZP.createElement("div",{className:"pinned-message-border-mark",style:`height: ${i}px; transform: translateY(${c}px);`})))})),Tt=(0,o.X$)((({message:e,count:t,index:s,customTitle:n,className:a,onUnpinMessage:r,onClick:i,onAllPinnedClick:c})=>{const l=(0,Ce.Z)(),u=St(e),m=(0,wt.Z)((0,d.Ti)(e,"pictogram")),h=(0,d.MK)(l,e,Boolean(u)),[g,p,f]=(0,ye.Z)(),I=(0,o.I4)((()=>{f(),r&&r(e.id)}),[f,r,e.id]);return o.ZP.createElement("div",{className:(0,ne.Z)("HeaderPinnedMessage-wrapper",a)},t>1&&o.ZP.createElement(Me.Z,{round:!0,size:"smaller",color:"translucent",className:"pin-list-button",ariaLabel:l("EventLogFilterPinnedMessages"),onClick:c},o.ZP.createElement("i",{className:"icon-pin-list"})),r&&o.ZP.createElement(Me.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:l("UnpinMessageAlertTitle"),className:"unpin-button",onClick:p},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Et.Z,{isOpen:g,onClose:f,text:"Would you like to unpin this message?",confirmLabel:"Unpin",confirmHandler:I}),o.ZP.createElement("div",{className:"HeaderPinnedMessage",onClick:i,dir:l.isRtl?"rtl":void 0},o.ZP.createElement(Rt,{count:t,index:s}),u&&function(e,t){const{width:s,height:n}=(0,Pt.W7)();return o.ZP.createElement("img",{src:t||e,width:s,height:n,alt:""})}(u,m),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("div",{className:"title",dir:"auto"},n||`${l("PinnedMessage")} ${s>0?"#"+(t-s):""}`),o.ZP.createElement("p",{dir:"auto"},(0,Ct.Z)(h))),o.ZP.createElement(Mt.Z,null)))}));var Nt=s(647),Bt=s(396),At=s(4532),xt=s(3186),Lt=s(663);function Ot(e,t,s="image/png"){const n=e instanceof Blob?URL.createObjectURL(e):e,a=new Image;return new Promise((o=>{a.onload=()=>{Ft(a,a.width*t,a.height*t,s).then((e=>URL.createObjectURL(e))).then(o).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(n)}))},a.src=n}))}async function Ft(e,t,s,n="image/png"){if(!("createImageBitmap"in window))return Ut(e,t,s,void 0,n);try{const a=await window.createImageBitmap(e,{resizeWidth:t,resizeHeight:s,resizeQuality:"high"});if(a.height!==s||a.width!==t)throw new Error("Image bitmap resize not supported!");return await new Promise((e=>{const t=document.createElement("canvas");t.width=a.width,t.height=a.height;const s=t.getContext("bitmaprenderer");s?s.transferFromImageBitmap(a):t.getContext("2d").drawImage(a,0,0),t.toBlob(e,n)}))}catch(a){return Ut(e,t,s,void 0,n)}}function Ut(e,t,s,n=.5,a="image/png"){const o=document.createElement("canvas"),r=o.getContext("2d"),i=document.createElement("canvas"),c=i.getContext("2d");if(o.width=t,o.height=s,e.width*n>t){const s=1/n;let a={width:Math.floor(e.width*n),height:Math.floor(e.height*n)};for(i.width=a.width,i.height=a.height,c.drawImage(e,0,0,a.width,a.height);a.width*n>t;)a={width:Math.floor(a.width*n),height:Math.floor(a.height*n)},c.drawImage(i,0,0,a.width*s,a.height*s,0,0,a.width,a.height);r.drawImage(i,0,0,a.width,a.height,0,0,o.width,o.height)}else r.drawImage(e,0,0,o.width,o.height);return new Promise((e=>{o.toBlob(e,a)}))}var $t=s(4524);const Dt={width:200,height:200},qt=115,Qt=(e,t,s)=>{const{audio:n,voice:a}=(0,d.qp)(e),r=n?n.title||n.fileName:a?"Voice message":"",i=n&&n.performer||t&&(0,d.OU)(Lt.i0,t),c=s&&(0,d.U)(Lt.i0,s)||"Telegram",l=n&&(0,d.MR)(n)&&(0,d.Ti)(e,"pictogram"),u=t&&(0,d.RT)(t,"big"),m=n&&l||a&&u,h=(0,wt.Z)(m),g=(0,o.Ye)((()=>function(e,t,s){if(!s)return Dt;if(e){if(!e.thumbnailSizes||0===e.thumbnailSizes.length)return;return e.thumbnailSizes.find((e=>"m"===e.type))||e.thumbnailSizes[0]}return t?Pt.vY:void 0}(n,a,h)),[n,h,a]),{result:p}=((e,t,s)=>{const[n,a]=(0,o.eJ)(!1),[r,i]=(0,o.eJ)(),[c,d]=(0,o.eJ)(s);return(0,o.d4)((()=>{a(!0);let e=!1;return function(e,t){if(!e)return Promise.resolve($t);if(!t)return function(e,t,s,n="image/png"){const a=e instanceof Blob?URL.createObjectURL(e):e,o=new Image;return new Promise((r=>{o.onload=()=>{Ft(o,t,s,n).then((e=>URL.createObjectURL(e))).then(r).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(a)}))},o.src=a}))}(e,qt,qt);const s=Math.min(t.width,t.height);return s{e||(a(!1),d(t))}),(t=>{e||(a(!1),i(t))})),()=>{e=!0}}),t),{isLoading:n,error:r,result:c}})(0,[h,g],$t);return(0,o.Ye)((()=>(0,At.Of)({title:r,artist:i,album:c,artwork:[{src:p}]})),[c,i,r,p])};var Gt=s(8051);const jt=(0,n.c$)(((e,{message:t})=>{const s=(0,i.Ur)(e,t),n=(0,i.Z1)(e,t.chatId),{volume:a,playbackRate:o,isMuted:r}=e.audioPlayer;return{sender:s,chat:n,volume:a,playbackRate:o,isMuted:r}}))((({message:e,className:t,noUi:s,sender:a,chat:r,volume:i,playbackRate:c,isMuted:l})=>{const{setAudioPlayerVolume:u,setAudioPlayerPlaybackRate:m,setAudioPlayerMuted:g,focusMessage:p,closeAudioPlayer:f}=(0,n.uC)(),I=(0,Ce.Z)(),{audio:v,voice:y,video:Z}=(0,d.qp)(e),P=Boolean(y||Z),C=a?(0,d.OU)(I,a):void 0,w=Nt.UV((0,d.Ti)(e,"inline")),b=Qt(e,a,r),{playPause:S,stop:E,isPlaying:M,requestNextTrack:k,requestPreviousTrack:R,isFirst:T,isLast:N,setVolume:B,toggleMuted:A,setPlaybackRate:x}=(0,xt.Z)((0,Bt.An)(e),(0,d.XV)(e),P?"voice":"audio",w,void 0,b,void 0,!0,void 0,void 0,(0,d.CI)(e),!0),L=P&&M;(0,o.d4)((()=>{if(L)return ie.Z.disableRefresh(),()=>{ie.Z.enableRefresh()}}),[L]);const O=(0,o.I4)((()=>{p({chatId:e.chatId,messageId:e.id})}),[p,e.chatId,e.id]),F=(0,o.I4)((()=>{M&&S(),f(),(0,At.Ay)(),E()}),[f,M,S,E]),U=(0,o.I4)((e=>{u({volume:e/100}),g({isMuted:!1}),B(e/100)}),[g,u,B]),$=(0,o.I4)((()=>{h.$b&&!h.cj||(A(),g({isMuted:!l}))}),[l,g,A]),D=(0,o.I4)((()=>{1===c?(x(1.8),m({playbackRate:1.8})):(x(1),m({playbackRate:1}))}),[c,m,x]),q=(0,o.Ye)((()=>0===i||l?"icon-muted":i<.3?"icon-volume-1":i<.6?"icon-volume-2":"icon-volume-3"),[i,l]);if(!s)return o.ZP.createElement("div",{className:(0,ne.Z)("AudioPlayer",t),dir:I.isRtl?"rtl":void 0},o.ZP.createElement(Me.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:T(),onClick:R,ariaLabel:"Previous track"},o.ZP.createElement("i",{className:"icon-skip-previous"})),o.ZP.createElement(Me.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:(0,ne.Z)("toggle-play","player-button",M?"pause":"play"),onClick:S,ariaLabel:M?"Pause audio":"Play audio"},o.ZP.createElement("i",{className:"icon-play"}),o.ZP.createElement("i",{className:"icon-pause"})),o.ZP.createElement(Me.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:N(),onClick:k,ariaLabel:"Next track"},o.ZP.createElement("i",{className:"icon-skip-next"})),o.ZP.createElement("div",{className:"AudioPlayer-content",onClick:O},v?function(e){const{title:t,performer:s,fileName:n}=e;return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},(0,Ct.Z)(t||n)),s&&o.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,Ct.Z)(s)))}(v):function(e,t){return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,Ct.Z)(t)),o.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(I("AttachAudio"),C),o.ZP.createElement(Mt.Z,null)),o.ZP.createElement(Me.Z,{round:!0,className:"player-button volume-button",color:"translucent",size:"smaller",ariaLabel:"Volume",withClickPropagation:!0},o.ZP.createElement("i",{className:q,onClick:$}),!h.cj&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"volume-slider-spacer"}),o.ZP.createElement("div",{className:"volume-slider"},o.ZP.createElement(Gt.Z,{value:l?0:100*i,onChange:U})))),P&&o.ZP.createElement(Me.Z,{round:!0,className:(0,ne.Z)("playback-button",1!==c&&"applied"),color:"translucent",size:"smaller",ariaLabel:"Playback Rate",ripple:!h.wB,onClick:D},o.ZP.createElement("span",{className:"playback-button-inner"},"2Х")),o.ZP.createElement(Me.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:F,ariaLabel:"Close player"},o.ZP.createElement("i",{className:"icon-close"})))}));var Ht=s(2607),_t=s(172);const zt=(0,o.X$)((0,n.c$)(((e,{chatId:t})=>{const s=(0,i.Z1)(e,t),n=(0,Ht.Bj)(e,t);return{groupCall:n,usersById:e.users.byId,chatsById:e.chats.byId,activeGroupCallId:e.groupCalls.activeGroupCallId,isActive:(n?n.participantsCount>0&&n.isLoaded:s&&s.isCallNotEmpty&&s.isCallActive)&&e.groupCalls.activeGroupCallId!==(null==n?void 0:n.id)}}))((({chatId:e,isActive:t,groupCall:s,hasPinnedOffset:a,usersById:r,chatsById:i})=>{const{joinGroupCall:c,subscribeToGroupCallUpdates:d}=(0,n.uC)(),l=(0,Ce.Z)(),u=(0,o.I4)((()=>{c({chatId:e})}),[c,e]),m=null==s?void 0:s.participants,h=(0,o.Ye)((()=>m?Object.values(m).filter(((e,t)=>t<3)).map((({id:e,isUser:t})=>{if(t){if(!r[e])return;return{user:r[e]}}if(i[e])return{chat:i[e]}})).filter(Boolean):[]),[i,m,r]);if((0,o.d4)((()=>{if(null!=s&&s.id&&(t||!s.isLoaded))return d({id:s.id,subscribed:!0}),()=>{d({id:s.id,subscribed:!1})}}),[null==s?void 0:s.id,null==s?void 0:s.isLoaded,t,d]),s)return o.ZP.createElement("div",{className:(0,ne.Z)("GroupCallTopPane",a&&"has-pinned-offset",!t&&"is-hidden"),onClick:u},o.ZP.createElement("div",{className:"info"},o.ZP.createElement("span",{className:"title"},l("VoipGroupVoiceChat")),o.ZP.createElement("span",{className:"participants"},l("Participants",s.participantsCount||0,"i"))),o.ZP.createElement("div",{className:"avatars"},h.map((e=>{if(e)return e.user?o.ZP.createElement(_t.Z,{key:e.user.id,user:e.user}):o.ZP.createElement(_t.Z,{key:e.chat.id,chat:e.chat})}))),o.ZP.createElement(Me.Z,{round:!0,className:"join"},l("VoipChatJoin")))}))),Vt=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,messageListType:n})=>{const{isLeftColumnShown:a,lastSyncTime:o,shouldSkipHistoryAnimations:r}=e,{byId:c}=e.chats,d=(0,i.Z1)(e,t),{typingStatus:l}=d||{},{chatId:m,messageId:h}=e.audioPlayer,g=m&&h?(0,i.hj)(e,m,h):void 0;let p;if("pinned"===n){const s=(0,i.KB)(e,t);p=null==s?void 0:s.length}else if("scheduled"===n){const s=(0,i.qy)(e,t);p=null==s?void 0:s.length}else if("thread"===n&&s!==u._f){const n=(0,i.tZ)(e,t,s);p=(null==n?void 0:n.messagesCount)||0}const f={typingStatus:l,isLeftColumnShown:a,isRightColumnShown:(0,i.Jf)(e),isSelectModeActive:(0,i.CA)(e),audioMessage:g,chat:d,chatsById:c,messagesCount:p,isChatWithSelf:(0,i.FM)(e,t),isChatWithBot:d&&(0,i.xo)(e,d),lastSyncTime:o,shouldSkipHistoryAnimations:r,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1),connectionState:e.connectionState},I=(0,i.Zw)(e,t);if("thread"!==n||!I)return f;if(Object.assign(f,{messagesById:I}),s!==u._f){const n=(0,i.qS)(e,t,s),a=n?(0,i.hj)(e,t,n):void 0,o=a?(0,i.cv)(e,a):void 0;return{...f,pinnedMessageIds:n,canUnpin:!1,topMessageSender:o}}const v=(0,i.KB)(e,t);if(null!=v&&v.length){const t=I[v[0]],{canUnpin:n}=t&&(0,i._k)(e,t,s)||{};return{...f,pinnedMessageIds:v,canUnpin:n}}return f}))((({chatId:e,threadId:t,messageListType:s,isReady:r,pinnedMessageIds:c,messagesById:l,canUnpin:m,topMessageSender:g,typingStatus:p,isSelectModeActive:f,isLeftColumnShown:I,isRightColumnShown:v,audioMessage:y,chat:Z,chatsById:P,messagesCount:C,isChatWithSelf:w,isChatWithBot:b,lastSyncTime:S,shouldSkipHistoryAnimations:E,currentTransitionKey:M,connectionState:k})=>{const{openChatWithInfo:R,pinMessage:T,focusMessage:N,openChat:B,openPreviousChat:A,loadPinnedMessages:x,toggleLeftColumn:L,exitMessageSelectMode:O}=(0,n.uC)(),F=(0,Ce.Z)(),U=(0,o.sO)(!0),[$,D]=(0,o.eJ)(0),q=Array.isArray(c)?c[$]:c,Q=l&&q?l[q]:void 0,G=Array.isArray(c)?c.length:c?1:void 0,j=Z&&(0,d.U)(F,Z).length,H=g?(0,d.OU)(F,g):void 0;(0,o.d4)((()=>{t===u._f&&S&&r&&x({chatId:e})}),[e,x,S,t,r]),(0,o.d4)((()=>{D(0)}),[c]),(0,gt.Z)(e,q,Q);const{width:_}=ct(),z=_<=a.ks,V=h.p7&&I,K=(0,o.sO)(null),Y=(0,o.sO)(!0),W=(0,o.I4)((()=>{R({id:e})}),[R,e]),X=(0,o.I4)((t=>{T({chatId:e,messageId:t,isUnpin:!0})}),[T,e]),J=(0,o.I4)((()=>{if(Q){N({chatId:Q.chatId,threadId:t,messageId:Q.id});const e=(0,ht.Z)(G||1,$+1);D(e)}}),[Q,N,t,G,$]),ee=(0,o.I4)((()=>{B({id:e,threadId:u._f,type:"pinned"})}),[B,e]),te=(0,o.I4)((()=>{setTimeout((()=>{U.current=!0}),450)}),[]),se=(0,o.I4)((e=>{if(U.current){if(U.current=!1,h.wB){const e=document.getElementById(a.R2);e&&e.blur()}if(f)return O(),void te();if(t===u._f&&"thread"===s&&0===M)return h.wB||V?(e.stopPropagation(),B({id:void 0})):L(),void te();A(),te()}}),[t,s,M,f,A,V,B,L,O,te]),ae=(0,o.Ye)((()=>{if(z&&P)return(0,i.A1)((0,n.Rd)())||void 0}),[z,P]),oe=_>=a.ks&&_a.l3&&_30),re=oe||_>a._m&&_{const e=K.current;if(e)return re&&Ie?void(v||oe?(Y.current&&(e.classList.add("tools-stacked","animated"),Y.current=!1),setTimeout((()=>{e.classList.remove("animated")}),350)):(e.classList.remove("tools-stacked"),Y.current=!0)):(e.classList.remove("tools-stacked","animated"),void(Y.current=!0))}),[re,Ie,oe,v]);const ve=(!Pe()||"connectionStateConnecting"===k)&&(h.wB||h.p7&&!V);function ye(){return ve?o.ZP.createElement(o.ZP.Fragment,null,we(),o.ZP.createElement("h3",null,F("WaitingForNetwork"))):"thread"===s&&t===u._f?o.ZP.createElement(o.ZP.Fragment,null,(z||M>0)&&we(V,!0),o.ZP.createElement("div",{className:"chat-info-wrapper",onClick:W},(0,d.YC)(e)?o.ZP.createElement(It.Z,{userId:e,typingStatus:p,withFullInfo:b,withMediaViewer:!0,withUpdatingStatus:!0,noRtl:!0}):o.ZP.createElement(vt.Z,{chatId:e,typingStatus:p,noRtl:!0,withMediaViewer:!0,withFullInfo:!0,withUpdatingStatus:!0}))):"thread"===s?o.ZP.createElement(o.ZP.Fragment,null,we(),o.ZP.createElement("h3",null,F("CommentsCount",C,"i"))):"pinned"===s?o.ZP.createElement(o.ZP.Fragment,null,we(),o.ZP.createElement("h3",null,F("PinnedMessagesCount",C,"i"))):"scheduled"===s?o.ZP.createElement(o.ZP.Fragment,null,we(),o.ZP.createElement("h3",null,w?F("Reminders"):F("messages",C,"i"))):void 0}function we(e=!1,t=!1){return o.ZP.createElement("div",{className:"back-button"},o.ZP.createElement(Me.Z,{round:!0,size:"smaller",color:"translucent",onClick:se,ariaLabel:F(e?"Close":"Back")},o.ZP.createElement("div",{className:(0,ne.Z)("animated-close-icon",!e&&"state-back")})),t&&ae&&o.ZP.createElement("div",{className:"unread-count active"},(0,ft.bi)(ae)))}const be=Boolean(ie&&le);return o.ZP.createElement("div",{className:"MiddleHeader",ref:K},o.ZP.createElement(Ze.Z,{name:E?"none":"slide-fade",activeKey:ve?1/0:M},ye),o.ZP.createElement(zt,{hasPinnedOffset:ue&&!!he||ie&&!!le,chatId:e}),ue&&he&&o.ZP.createElement(Tt,{key:e,message:he,count:ge||0,index:$,customTitle:fe,className:(0,ne.Z)(me,be&&"full-width"),onUnpinMessage:pe?X:void 0,onClick:J,onAllPinnedClick:ee}),o.ZP.createElement("div",{className:"header-tools"},be&&o.ZP.createElement(jt,{key:(0,d.Tp)(le),message:le,className:de}),o.ZP.createElement(Zt,{chatId:e,threadId:t,messageListType:s,canExpandActions:!be})))})));var Kt=s(2645),Yt=s(274);function Wt(e){return"albumId"in e}function Xt(e,t){let s,n=[],a={originalDate:e[0].date,datetime:Number((0,N.$Y)(1e3*e[0].date)),senderGroups:[n]};const o=[a];return e.forEach(((r,i)=>{r.isInAlbum?s?(s.messages.push(r),r.content.text&&(s.mainMessage=r)):s={albumId:r.groupedId,messages:[r],mainMessage:r}:n.push(r);const c=e[i+1];if(!s||c&&c.groupedId&&c.groupedId===s.albumId||(n.push(s),s=void 0),c){const e=Number((0,N.$Y)(1e3*c.date));a.datetime!==e?(a={originalDate:c.date,datetime:e,senderGroups:[]},o.push(a),n=[],a.senderGroups.push(n)):(c.id===t||r.senderId!==c.senderId||r.isOutgoing!==c.isOutgoing||(0,d.Lo)(r)||(0,d.Lo)(c)||r.forwardInfo&&c.forwardInfo&&(r.forwardInfo.senderUserId!==c.forwardInfo.senderUserId||r.forwardInfo.fromChatId!==c.forwardInfo.fromChatId||r.forwardInfo.hiddenUserName!==c.forwardInfo.hiddenUserName)||r.inlineButtons||c.inlineButtons||c.date-r.date>600)&&(n=[],a.senderGroups.push(n))}})),o}var Jt=s(386),es=s(2202);var ts=s(7675),ss=s(539),ns=s(3657);const as=h.wZ?1e3:350,os=h.wB?300:500;var rs=s(7240),is=s(935);function cs(e){return"number"==typeof e}function ds(e,t){return e?t?238:175:t?238:100}function ls(e,t){const s=(0,d.B4)(e),n=(0,d.MF)(e),a=(0,d.O$)(e)||(0,d.F$)(e),o=(0,d.b7)(e),r=Boolean((0,d.F$)(e)),{width:i,height:c}=a?(0,Pt.Eh)(a,s,n,r,t):(0,Pt.GC)(o,s,n,t),l=ds(Boolean((0,d.UD)(e)));let u=1;ie+t),t)}function ms(e,t,s){return es?s:e}function hs(e){const t={width:0,height:0};return e.forEach((({dimensions:e,sides:s})=>{2&s&&(t.width=e.width+e.x),4&s&&(t.height=e.height+e.y)})),t}function gs(e,t,s,n){const a=n.messages.map((e=>{const t=ls(e);return t.width/t.height})),o=function(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}(a),r=function(e){return e.reduce(((e,t)=>t+e),1)/e.length}(a),i=a.length,c=a.some((e=>e>2)),d=(0,Pt.kc)(e,t,!1,s)-(t?2.5:0)*Pt.Gw;let l;const u={ratios:a,proportions:o,averageRatio:r,maxWidth:d,minWidth:100,maxHeight:d,spacing:2};return l=i>=5||c?function({ratios:e,averageRatio:t,maxWidth:s,minWidth:n,spacing:a,maxHeight:o=4*s/3}){const r=function(e,t){return e.map((e=>t>1.1?ms(e,1,2.75):ms(e,.6667,1)))}(e,t),i=e.length,c=new Array(i),d=[],l=e=>{const t=[];let n=0;e.forEach((e=>{t.push(((e,t)=>{const n=us(r.slice(e,e+t),0);return(s-(t-1)*a)/n})(n,e)),n+=e})),d.push({lineCounts:e,heights:t})};for(let e=1;e!==i;++e){const t=i-e;e<=3&&t<=3&&l([e,t])}for(let e=1;e!==i-1;++e)for(let s=1;s!==i-e;++s){const n=i-e-s;e<=3&&s<=(t<.85?4:3)&&n<=3&&l([e,s,n])}for(let e=1;e!==i-1;++e)for(let t=1;t!==i-e;++t)for(let s=1;s!==i-e-t;++s){const n=i-e-t-s;e<=3&&t<=3&&s<=3&&n<=4&&l([e,t,s,n])}let u,m=0;for(let e=0;e{for(let e=1;e!==r;++e)if(s[e-1]>s[e])return 1.5;return 1})(),h=Math.abs(i-o)*c*l;(!u||h1.4&&t[1]-t[0]<.2?function(e){const{ratios:t,maxWidth:s,spacing:n,maxHeight:a}=e,o=Math.round(Math.min(s/t[0],Math.min(s/t[1],(a-n)/2)));return[{dimensions:{x:0,y:0,width:s,height:o},sides:11},{dimensions:{x:0,y:o+n,width:s,height:o},sides:14}]}(e):"ww"===s||"qq"===s?function(e){const{ratios:t,maxWidth:s,spacing:n,maxHeight:a}=e,o=(s-n)/2,r=Math.round(Math.min(o/t[0],Math.min(o/t[1],a)));return[{dimensions:{x:0,y:0,width:o,height:r},sides:13},{dimensions:{x:o+n,y:0,width:o,height:r},sides:7}]}(e):function(e){const{ratios:t,minWidth:s,maxWidth:n,spacing:a,maxHeight:o}=e,r=Math.round(1.5*s),i=Math.min(Math.round(Math.max(.4*(n-a),(n-a)/t[0]/(1/t[0]+1/t[1]))),n-a-r),c=n-i-a,d=Math.min(o,Math.round(Math.min(c/t[0],i/t[1])));return[{dimensions:{x:0,y:0,width:c,height:d},sides:13},{dimensions:{x:c+a,y:0,width:i,height:d},sides:7}]}(e)}(u):3===i?function(e){const{proportions:t}=e;return"n"===t[0]?function(e){const{maxHeight:t,spacing:s,ratios:n,maxWidth:a,minWidth:o}=e,r=t,i=Math.round(Math.min((t-s)/2,n[1]*(a-s)/(n[2]+n[1]))),c=r-i-s,d=Math.max(o,Math.round(Math.min((a-s)/2,Math.min(i*n[2],c*n[1])))),l=Math.min(Math.round(r*n[0]),a-s-d);return[{dimensions:{x:0,y:0,width:l,height:r},sides:13},{dimensions:{x:l+s,y:0,width:d,height:c},sides:3},{dimensions:{x:l+s,y:c+s,width:d,height:i},sides:6}]}(e):function(e){const{maxWidth:t,ratios:s,maxHeight:n,spacing:a}=e,o=t,r=Math.round(Math.min(o/s[0],.66*(n-a))),i=(t-a)/2,c=Math.min(n-r-a,Math.round(Math.min(i/s[1],i/s[2])));return[{dimensions:{x:0,y:0,width:o,height:r},sides:11},{dimensions:{x:0,y:r+a,width:i,height:c},sides:12},{dimensions:{x:i+a,y:r+a,width:o-i-a,height:c},sides:6}]}(e)}(u):function(e){const{proportions:t}=e;return"w"===t[0]?function({maxWidth:e,ratios:t,spacing:s,maxHeight:n,minWidth:a}){const o=e,r=Math.round(Math.min(o/t[0],.66*(n-s))),i=Math.round((e-2*s)/(t[1]+t[2]+t[3])),c=Math.max(a,Math.round(Math.min(.4*(e-2*s),i*t[1]))),d=Math.round(Math.max(Math.max(a,.33*(e-2*s)),i*t[3])),l=o-c-d-2*s,u=Math.min(n-r-s,i);return[{dimensions:{x:0,y:0,width:o,height:r},sides:11},{dimensions:{x:0,y:r+s,width:c,height:u},sides:12},{dimensions:{x:c+s,y:r+s,width:l,height:u},sides:4},{dimensions:{x:c+s+l+s,y:r+s,width:d,height:u},sides:6}]}(e):function({maxHeight:e,ratios:t,maxWidth:s,spacing:n,minWidth:a}){const o=e,r=Math.round(Math.min(o*t[0],.6*(s-n))),i=Math.round((e-2*n)/(1/t[1]+1/t[2]+1/t[3])),c=Math.round(i/t[1]),d=Math.round(i/t[2]),l=o-c-d-2*n,u=Math.max(a,Math.min(s-r-n,i));return[{dimensions:{x:0,y:0,width:r,height:o},sides:13},{dimensions:{x:r+n,y:0,width:u,height:c},sides:3},{dimensions:{x:r+n,y:c+n,width:u,height:d},sides:2},{dimensions:{x:r+n,y:c+d+2*n,width:u,height:l},sides:6}]}(e)}(u),{layout:l,containerStyle:hs(l)}}let ps;function fs(e){return ps||(ps=document.createElement("span"),ps.style.font=h.cj?'400 12px system-ui, -apple-system, BlinkMacSystemFont, "Roboto", "Apple Color Emoji", "Helvetica Neue", sans-serif':'400 12px "Roboto", -apple-system, "Apple Color Emoji", BlinkMacSystemFont, "Helvetica Neue", sans-serif',ps.style.whiteSpace="nowrap",ps.style.position="absolute",ps.style.left="-999px",ps.style.opacity=".01",document.body.appendChild(ps)),ps.innerHTML=e,ps.offsetWidth}function Is(e,t,s,n,a,r){(0,o.bt)((()=>{if(s&&e.current){const t=e.current.closest(".MessageList");(0,ss.Z)(t,e.current,a?"end":"centerOrTop",20,void 0!==n?1e3:void 0,n,void 0,r)}}),[e,t,s,n,a,r])}var vs=s(8005);const ys=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"ContextMenuContainer",!t);return s?o.ZP.createElement(s,e):void 0})),Zs=(0,o.X$)((0,n.c$)(((e,{message:t})=>{const{byId:s}=e.users,n=t.senderId,{targetUserIds:a,targetChatId:o}=t.content.action||{},r=t.replyToMessageId,c=r?(0,i.hj)(e,t.chatId,r):void 0,l=(0,i._X)(e,t),{direction:u,noHighlight:m}=l&&e.focusedMessage||{},h=(0,i.Z1)(e,t.chatId);return{usersById:s,sender:h&&((0,d.eA)(h)||n===t.chatId)?h:n?(0,i.dy)(e,n):void 0,targetChatId:o,targetUserIds:a,targetMessage:c,isFocused:l,...l&&{focusDirection:u,noFocusHighlight:m}}}))((({message:e,observeIntersection:t,isEmbedded:s,appearanceOrder:n=0,isLastInList:a,usersById:r,sender:i,targetUserIds:c,targetMessage:d,targetChatId:l,isFocused:u,focusDirection:m,noFocusHighlight:h})=>{const g=(0,o.sO)(null);(0,ns._N)(g,t),(0,gt.Z)(e.chatId,e.replyToMessageId,d),Is(g,e.chatId,u,m,h);const p=(0,Ce.Z)(),f=n<=0,[I,v]=(0,ye.Z)(f);(0,o.d4)((()=>{f||setTimeout(v,10*n)}),[n,v,f]);const{transitionClassNames:y}=(0,ce.Z)(I,void 0,f,!1),Z=(0,o.Ye)((()=>c?c.map((e=>null==r?void 0:r[e])).filter(Boolean):void 0),[c,r]),P=(0,vs.D)(p,e,i,Z,d,l,s?{isEmbedded:!0,asPlain:!0}:void 0),{isContextMenuOpen:C,contextMenuPosition:w,handleBeforeContextMenu:b,handleContextMenu:S,handleContextMenuClose:E,handleContextMenuHide:M}=(0,rs.Z)(g),k=void 0!==w;if(s)return o.ZP.createElement("span",{className:"embedded-action-message"},(0,Ct.Z)(P));const R=(0,ne.Z)("ActionMessage message-list-item",u&&!h&&"focused",k&&"has-menu-open",a&&"last-in-list",y);return o.ZP.createElement("div",{ref:g,id:`message${e.id}`,className:R,"data-message-id":e.id,onMouseDown:e=>{(0,Jt.q)(e),b(e)},onContextMenu:S},o.ZP.createElement("span",null,P),w&&o.ZP.createElement(ys,{isOpen:C,anchor:w,message:e,messageListType:"thread",onClose:E,onCloseAnimationEnd:M}))}))),Ps=({className:e,message:t,sender:s,title:n,customText:a,isProtected:r,observeIntersection:i,onClick:c})=>{const l=(0,o.sO)(null),u=(0,ns.Op)(l,i),m=(0,wt.Z)(t&&(0,d.Ti)(t,"pictogram"),!u),h=t&&`sticker-reply-thumb${t.id}`,g=St(t),p=Boolean(t&&(0,d.Y5)(t)),f=(0,Ce.Z)(),I=s&&(0,d.OU)(f,s);return o.ZP.createElement("div",{ref:l,className:(0,ne.Z)("EmbeddedMessage",e),onClick:t?c:void 0},g&&function(e,t,s,n,a){const{width:r,height:i}=(0,Pt.W7)();return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("img",{id:e,src:s||t,width:r,height:i,alt:"",className:n?"round":"",draggable:!a}),a&&o.ZP.createElement("span",{className:"protector"}))}(h,g,m,p,r),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("p",{dir:"auto"},t?(0,d.Lo)(t)?o.ZP.createElement(Zs,{message:t,isEmbedded:!0}):(0,Ct.Z)((0,d.MK)(f,t,Boolean(g))):a||" "),o.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,Ct.Z)(I||n||" "))))};var Cs=s(2535),ws=s(4752),bs=s(8018);const Ss=(0,o.X$)((({message:e,outgoingStatus:t,signature:s,onClick:n})=>{const a=(0,Ce.Z)(),[r,i]=(0,ye.Z)(),c=(0,o.Ye)((()=>{if(!r)return;const t=(0,N.SA)(1e3*e.date,a.code),s=e.isEdited&&(0,N.SA)(1e3*e.editDate,a.code),n=e.forwardInfo&&(0,N.SA)(1e3*e.forwardInfo.date,a.code);let o=t;return s&&(o+="\n",o+=a("lng_edited_date").replace("{date}",s)),n&&(o+="\n",o+=a("lng_forwarded_date").replace("{date}",n)),o}),[r,a,e]);return o.ZP.createElement("span",{className:"MessageMeta",dir:a.isRtl?"rtl":"ltr",onClick:n},Boolean(e.views)&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"message-views"},(0,ft.bi)(e.views)),o.ZP.createElement("i",{className:"icon-channelviews"})),s&&o.ZP.createElement("span",{className:"message-signature"},(0,Ct.Z)(s)),o.ZP.createElement("span",{className:"message-time",title:c,onMouseEnter:i},e.isEdited&&`${a("EditedMessage")} `,(0,N.mr)(1e3*e.date,a)),t&&o.ZP.createElement(bs.Z,{status:t}))}));var Es=s(692),Ms=s(7799),ks=s(4851);const Rs=({message:e,observeIntersection:t,observeIntersectionForPlaying:s,shouldLoop:n,lastSyncTime:r})=>{const i=(0,o.sO)(null),[c,l,u]=(0,ye.Z)(),m=e.content.sticker,{isAnimated:h,stickerSetId:g}=m,p=g===a.n,f=(0,ns.Op)(i,t),I=(0,ns.Op)(i,s),v=m.isPreloadedGlobally?`sticker${m.id}`:(0,d.Ti)(e,"inline"),y=St(e),Z=(0,wt.Z)(v,!f,(0,d.kG)(e,"inline",!0),r),P=Boolean(Z),[C,w]=(0,ye.Z)(P),b=h?C:P,S=(0,Es.Z)(b),{width:E,height:M}=(0,Pt.Wr)(m),k=(0,ne.Z)("thumbnail",!y&&"empty"),R=(0,ne.Z)("Sticker media-inner",p&&"inactive");return o.ZP.createElement("div",{ref:i,className:R,onClick:p?void 0:l},!b&&o.ZP.createElement("img",{id:`sticker-thumb-${e.id}`,src:y,width:E,height:M,alt:"",className:k}),!h&&o.ZP.createElement("img",{id:`sticker-${e.id}`,src:Z,width:E,height:M,alt:"",className:(0,ne.Z)("full-media",S)}),h&&P&&o.ZP.createElement(Ms.Z,{key:v,className:(0,ne.Z)("full-media",S),id:v,animationData:Z,size:E,play:I,noLoop:!n,onLoad:w}),o.ZP.createElement(ks.Z,{isOpen:c,fromSticker:m,onClose:u}))};var Ts=s(7854),Ns=s(2566),Bs=s(5866);function As(e,t){return(0,Bs.Z)((0,d.DH)(e),Boolean(t),h.wB&&!h.vX)}const xs={dark:{outgoing:"rgb(135,116,225)",incoming:"rgb(33,33,33)"},light:{outgoing:"rgb(238,255,222)",incoming:"rgb(255,255,255)"}};var Ls=s(9196);const Os=({id:e,message:t,observeIntersection:s,noAvatars:n,canAutoLoad:a,isInSelectMode:r,isSelected:i,uploadProgress:c,size:l="inline",dimensions:u,nonInteractive:m,shouldAffectAppendix:h,isDownloading:g,isProtected:p,theme:f,onClick:I,onCancelUpload:v})=>{const y=(0,o.sO)(null),Z=((0,d.O$)(t)||(0,d.F$)(t)).blobUrl,P=(0,ns.Op)(y,s),[C,w]=(0,o.eJ)(a),b=C&&P,{mediaData:S,loadProgress:E}=(0,Ns.Z)((0,d.Ti)(t,l),!b),M=Z||S,k=As(t,M),{loadProgress:R}=(0,Ns.Z)((0,d.Ti)(t,"download"),!g),{isUploading:T,isTransferring:N,transferProgress:B}=(0,d.Sc)(t,c||(g?R:E),b&&!M),A=!1===(0,lt.Z)(C),x=(0,Es.Z)(M),{shouldRender:L,transitionClassNames:O}=(0,ce.Z)(N,void 0,A,"slow"),{shouldRender:F,transitionClassNames:U}=(0,ce.Z)(!M&&!C),$=(0,o.I4)((()=>{T?v&&v(t):M?I&&I(t.id):w((e=>!e))}),[M,T,t,v,I]),D=(0,d.B4)(t);(0,o.bt)((()=>{if(!h)return;const e=y.current.closest(".message-content");M?function(e,t,s,n,a){return n?Promise.resolve(xs[a||"light"][t?"outgoing":"incoming"]):async function(e,t){const s=new Image;s.src=e,s.width||await new Promise((e=>{s.onload=e}));const n=document.createElement("canvas"),a=n.getContext("2d");n.width=s.width,n.height=s.height,a.drawImage(s,0,0,s.width,s.height);const o=t?s.width-1:0,r=s.height-1;return`rgba(${Array.from(a.getImageData(o,r,1,1).data).join(",")})`}(e,t)}(M,D,0,i,f).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute("data-has-custom-appendix","")})):e.classList.add("has-appendix-thumb")}),[M,D,h,r,i,f]);const{width:q,height:Q,isSmall:G}=u||ls(t,n),j=(0,ne.Z)("media-inner",!T&&!m&&"interactive",G&&"small-image",q===Q&&"square-image"),H=u?`width: ${q}px; height: ${Q}px; left: ${u.x}px; top: ${u.y}px;`:"";return o.ZP.createElement("div",{id:e,ref:y,className:j,style:H,onClick:T?void 0:$},o.ZP.createElement("canvas",{ref:k,className:"thumbnail",style:`width: ${q}px; height: ${Q}px`}),o.ZP.createElement("img",{src:M,className:`full-media ${x}`,width:q,height:Q,alt:"",draggable:!p}),p&&o.ZP.createElement("span",{className:"protector"}),L&&!F&&o.ZP.createElement("div",{className:`media-loading ${O}`},o.ZP.createElement(Ls.Z,{progress:B,onClick:T?$:void 0})),F&&o.ZP.createElement("i",{className:(0,ne.Z)("icon-download",U)}),N&&o.ZP.createElement("span",{className:"message-transfer-progress"},Math.round(100*B),"%"))};var Fs=s(2019),Us=s(6898),$s=s(4753);function Ds(e,t){var s;const n=(0,o.sO)(null===(s=e.current)||void 0===s?void 0:s.paused),a=(0,o.sO)();a.current=t;const r=(0,o.I4)((()=>{e.current&&(n.current=!e.current.paused,n.current&&e.current.pause())}),[e]),i=(0,o.I4)((()=>{e.current&&n.current&&a.current&&document.body.contains(e.current)&&(0,$s.Z)(e.current)}),[e]),c=(0,o.I4)((()=>{(0,C.T2)(i)}),[i]);(0,de.Z)(r,c),(0,se.ZP)(r,i)}function qs(){return(qs=Object.assign||function(e){for(var t=1;t{var I;const v=(0,o.sO)(null),y=(0,o.sO)(null),Z=(0,d.b7)(t)||(0,d.Cg)(t),P=Z.blobUrl,C=(0,ns.Op)(v,s),[w,b]=(0,o.eJ)(r),S=Boolean(w&&C&&l),[E,M]=(0,o.eJ)(i),k=(0,wt.Z)((0,d.Ti)(t,"pictogram"),!(C&&l),(0,d.kG)(t,"pictogram"),l),R=(0,Es.Z)(k),{mediaData:T,loadProgress:B}=(0,Ns.Z)((0,d.Ti)(t,"inline"),!S,(0,d.kG)(t,"inline"),l),A=P||T,x=Boolean(C&&A),L=As(t,k),{loadProgress:O}=(0,Ns.Z)((0,d.Ti)(t,"download"),!p,u.IU.BlobUrl,l),{isBuffered:F,bufferingHandlers:U}=(0,Fs.Z)(!r),{isUploading:$,isTransferring:D,transferProgress:q}=(0,d.Sc)(t,c||(p?O:B),S&&!F||p),Q=!1===(0,lt.Z)(w),{shouldRender:G,transitionClassNames:j}=(0,ce.Z)(D,void 0,Q),{shouldRender:H,transitionClassNames:_}=(0,ce.Z)(w&&!E&&!G),[z,V]=(0,o.eJ)(0),K=(0,o.I4)((e=>{V(Math.max(0,e.currentTarget.currentTime-1))}),[]),Y=(null===(I=y.current)||void 0===I?void 0:I.duration)||Z.duration||0,W=(0,d.B4)(t),X=(0,d.MF)(t),{width:J,height:ee}=m||(0,Pt.GC)(Z,W,X,a);Ds(y,x),(0,Us.Z)(y,[x]);const te=(0,o.I4)((()=>{$?g&&g(t):p?(0,n.uC)().cancelMessageMediaDownload({message:t}):A?A&&!E?(M(!0),y.current.play()):h&&h(t.id):b((e=>!e))}),[$,p,A,E,h,g,t]),se=(0,ne.Z)("media-inner dark",!$&&"interactive"),ae=m?`width: ${J}px; height: ${ee}px; left: ${m.x}px; top: ${m.y}px;`:"";return o.ZP.createElement("div",{ref:v,id:e,className:se,style:ae,onClick:$?void 0:te},o.ZP.createElement("canvas",{ref:L,className:"thumbnail",style:`width: ${J}px; height: ${ee}px;`}),o.ZP.createElement("img",{src:k,className:(0,ne.Z)("thumbnail",R),style:`width: ${J}px; height: ${ee}px;`,alt:"",draggable:!f}),x&&o.ZP.createElement("video",qs({ref:y,className:"full-media",width:J,height:ee,autoPlay:E,muted:!0,loop:!0,playsInline:!0},U,{draggable:!f,onTimeUpdate:K}),o.ZP.createElement("source",{src:A})),f&&o.ZP.createElement("span",{className:"protector"}),H&&o.ZP.createElement("i",{className:(0,ne.Z)("icon-large-play",_)}),G&&o.ZP.createElement("div",{className:(0,ne.Z)("media-loading",j)},o.ZP.createElement(Ls.Z,{progress:q,onClick:te})),!w&&o.ZP.createElement("i",{className:"icon-download"}),D?o.ZP.createElement("span",{className:"message-transfer-progress"},$||p?`${Math.round(100*q)}%`:"..."):o.ZP.createElement("div",{className:"message-media-duration"},Z.isGif?"GIF":(0,N.k9)(Math.max(Y-z,0))))};var Gs=s(6272);const js=(0,n.c$)(((e,{contact:t})=>{const{countryList:{phoneCodes:s}}=e;return{user:(0,i.dy)(e,t.userId),phoneCodeList:s}}))((({contact:e,user:t,phoneCodeList:s})=>{const{openUserInfo:a}=(0,n.uC)(),{firstName:r,lastName:i,phoneNumber:c,userId:d}=e,l=(0,o.I4)((()=>{a({id:d})}),[a,d]);return o.ZP.createElement("div",{className:(0,ne.Z)("Contact",Boolean(d)&&"interactive"),onClick:d?l:void 0},o.ZP.createElement(_t.Z,{size:"large",user:t,text:r||i}),o.ZP.createElement("div",{className:"contact-info"},o.ZP.createElement("div",{className:"contact-name"},r," ",i),o.ZP.createElement("div",{className:"contact-phone"},(0,Gs.WZ)(s,c))))}));var Hs=s(1218),_s=s(4434),zs=s(6937);function Vs(e,t){return t>0?(e/t*100).toFixed():0}const Ks=({answer:e,voteResults:t,totalVoters:s,maxVotersCount:n,correctResults:a,shouldAnimate:r})=>{const i=t&&t.find((t=>t.option===e.option)),c=0===a.length||-1!==a.indexOf(e.option),d=a.length>0&&c||(null==i?void 0:i.isChosen),l=i?Vs(i.votersCount,s||0):0,[u,m]=(0,o.eJ)(r?0:l),h=(0,o.sO)(null),g=i?Vs(i.votersCount,n||0):0,p=u{r&&m(l)}),[r,l]),(0,o.d4)((()=>{const e=h.current;if(e&&r){const t=e.firstElementChild,s=p?"":"stroke-dasharray: 100% 200%; stroke-dashoffset: -44";t?t.setAttribute("style",s):e.innerHTML=`\n \n \n `}}),[p,r]),!t||!i)return;const f=`width: ${g}%; transform:scaleX(${p?0:1})`;return o.ZP.createElement("div",{className:"PollOption",dir:"ltr"},o.ZP.createElement("div",{className:"poll-option-share "+("100"===l?"limit-width":"")},l,"%",d&&o.ZP.createElement("span",{className:(0,ne.Z)("poll-option-chosen",!c&&"wrong",r&&"animate")},o.ZP.createElement("i",{className:c?"icon-check":"icon-close"}))),o.ZP.createElement("div",{className:"poll-option-right"},o.ZP.createElement("div",{className:"poll-option-text",dir:"auto"},(0,Ct.Z)(e.text)),o.ZP.createElement("div",{className:(0,ne.Z)("poll-option-answer",d&&!c&&"wrong")},o.ZP.createElement("div",{className:"poll-option-corner",ref:h}),o.ZP.createElement("div",{className:"poll-option-line",style:f}))))},Ys=(0,o.X$)((0,n.c$)(((e,{poll:t})=>{const{recentVoterIds:s}=t.results,{serverTimeOffset:n,users:{byId:a}}=e;return s&&0!==s.length?{recentVoterIds:s,usersById:a,serverTimeOffset:n}:{}}))((({message:e,poll:t,recentVoterIds:s,usersById:a,onSendVote:r,serverTimeOffset:i})=>{const{loadMessage:c,openPollResults:d}=(0,n.uC)(),{id:l,chatId:u}=e,{summary:m,results:h}=t,[g,p]=(0,o.eJ)(!1),[f,I]=(0,o.eJ)([]),[v,y]=(0,o.eJ)(!1),[Z,P]=(0,o.eJ)(!1),[C,w]=(0,o.eJ)(!m.closed&&m.closeDate&&m.closeDate>0?Math.min(m.closeDate-Math.floor(Date.now()/1e3)+i,m.closePeriod):0),b=(0,o.sO)(null),{results:S,totalVoters:E}=h,M=S&&S.some((e=>e.isChosen)),k=!m.closed&&!M,R=!k&&m.isPublic&&Number(h.totalVoters)>0,T=k&&m.multipleChoice,B=S?Math.max(...S.map((e=>e.votersCount))):E,A=S?S.reduce(((e,t)=>(t.isCorrect&&e.push(t.option),e)),[]):[],x=m.answers.map((e=>({label:e.text,value:e.option,hidden:Boolean(m.quiz&&m.closePeriod&&C<=0)})));(0,o.d4)((()=>{g&&t.results.results&&t.results.results.some((e=>e.isChosen))&&p(!1)}),[g,t.results.results]),(0,o.d4)((()=>{C>0&&setTimeout((()=>w(C-1)),1e3);const e=b.current;if(e){const t=12*Math.PI,s=e.lastElementChild,n=e.firstElementChild;if(C<=5&&e.classList.add("hurry-up"),s&&n){const e=(m.closePeriod-C)/m.closePeriod*t;n.textContent=(0,N.k9)(C),s.firstElementChild.setAttribute("stroke-dashoffset",`-${e}`)}else e.innerHTML=`\n ${(0,N.k9)(C)}\n \n \n `}}),[C,m.closePeriod]),(0,o.d4)((()=>{m.quiz&&(C<=0||M&&!m.closed)&&c({chatId:u,messageId:l})}),[u,C,M,c,l,m.closed,m.quiz]),(0,o.d4)((()=>{let e;return m.quiz&&!m.closed&&m.closePeriod&&m.closePeriod>0&&(e=window.setTimeout((()=>{c({chatId:u,messageId:l})}),1e3*m.closePeriod)),()=>{e&&window.clearTimeout(e)}}),[k,u,c,l,m.closePeriod,m.closed,m.quiz]);const L=(0,o.Ye)((()=>s?s.reduce(((e,t)=>{const s=a[t];return s&&e.push(s),e}),[]):[]),[a,s]),O=(0,o.I4)((e=>{I([e]),p(!0),P(!0),r([e])}),[r]),F=(0,o.I4)((e=>{I(e)}),[]),U=(0,o.I4)((()=>{p(!0),P(!0),r(f)}),[r,f]),$=(0,o.I4)((()=>{d({chatId:u,messageId:l})}),[u,l,d]),D=(0,o.I4)((()=>{y(!0)}),[]),q=(0,o.I4)((()=>{y(!1),P(!1)}),[]);(0,o.d4)((()=>{Z&&M&&m.quiz&&h.results&&t.results.solution&&(h.results.find((e=>e.isChosen&&e.isCorrect))||y(!0))}),[M,Z,h.results,m.quiz,t.results.solution]);const Q=(0,Ce.Z)();return o.ZP.createElement("div",{className:"Poll",dir:Q.isRtl?"auto":"ltr"},v&&t.results.solution&&o.ZP.createElement(zs.Z,{message:(0,is.H)(t.results.solution,t.results.solutionEntities),duration:5e3,onDismiss:q,containerId:"#middle-column-portals"}),o.ZP.createElement("div",{className:"poll-question"},(0,Ct.Z)(m.question,["emoji","br"])),o.ZP.createElement("div",{className:"poll-type"},Q(function(e){return void 0===e.isPublic?" ":e.quiz?e.isPublic?"QuizPoll":"AnonymousQuizPoll":e.closed?"FinalResults":e.isPublic?"PublicPoll":"AnonymousPoll"}(m)),L.length>0&&o.ZP.createElement("div",{className:"poll-recent-voters"},L.map((e=>o.ZP.createElement(_t.Z,{size:"micro",user:e})))),C>0&&k&&o.ZP.createElement("div",{ref:b,className:"poll-countdown"}),m.quiz&&t.results.solution&&!k&&o.ZP.createElement(Me.Z,{round:!0,size:"tiny",color:"translucent",className:"poll-quiz-help",disabled:v,onClick:D,ariaLabel:"Show Solution"},o.ZP.createElement("i",{className:"icon-lamp"}))),k&&o.ZP.createElement("div",{className:"poll-answers"},T?o.ZP.createElement(Hs.Z,{options:x,onChange:F,disabled:e.isScheduled||g,loadingOptions:g?f:void 0,round:!0}):o.ZP.createElement(_s.Z,{name:`poll-${l}`,options:x,onChange:O,disabled:e.isScheduled||g,loadingOption:g?f[0]:void 0})),!k&&o.ZP.createElement("div",{className:"poll-results"},m.answers.map((function(e){return o.ZP.createElement(Ks,{key:e.option,shouldAnimate:Z,answer:e,voteResults:S,totalVoters:E,maxVotersCount:B,correctResults:A})}))),!R&&!T&&o.ZP.createElement("div",{className:"poll-voters-count"},function(e,t,s){return s?e(t?"Answer":"Vote",s,"i"):e(t?"Chat.Quiz.TotalVotesEmpty":"Chat.Poll.TotalVotesResultEmpty")}(Q,m.quiz,h.totalVoters)),T&&o.ZP.createElement(Me.Z,{isText:!0,disabled:0===f.length,size:"tiny",onClick:U},Q("PollSubmitVotes")),R&&o.ZP.createElement(Me.Z,{isText:!0,size:"tiny",onClick:$},Q("PollViewResults")))})));var Ws=s(8035),Xs=s(88);const Js=(0,o.X$)((({message:e,observeIntersection:t,noAvatars:s,canAutoLoad:n,canAutoPlay:a,inPreview:r,lastSyncTime:i,isDownloading:c=!1,isProtected:l,theme:u,onMediaClick:m,onCancelMediaTransfer:h})=>{const g=(0,d.s1)(e);let p=!1;if(null!=g&&g.photo&&!g.video){const{width:t,height:s}=ls(e);p=t===s}const f=(0,o.I4)((()=>{m()}),[m]);if(!g)return;const{siteName:I,url:v,displayUrl:y,title:Z,description:P,photo:C,video:w}=g,b=(C||w)&&m&&!p,S=(0,Ws.Z)(P,170),E=(0,ne.Z)("WebPage",p&&"with-square-photo",!C&&!w&&!r&&"without-media",w&&"with-video");return o.ZP.createElement("div",{className:E,"data-initial":(I||y)[0],dir:"auto"},C&&!w&&o.ZP.createElement(Os,{message:e,observeIntersection:t,noAvatars:s,canAutoLoad:n,size:p?"pictogram":"inline",nonInteractive:!b,onClick:b?f:void 0,onCancelUpload:h,isDownloading:c,isProtected:l,theme:u}),o.ZP.createElement("div",{className:"WebPage-text"},o.ZP.createElement(Xs.Z,{className:"site-name",url:v,text:I||y}),!r&&Z&&o.ZP.createElement("p",{className:"site-title"},(0,Ct.Z)(Z)),S&&o.ZP.createElement("p",{className:"site-description"},(0,Ct.Z)(S,["emoji","br"]))),!r&&w&&o.ZP.createElement(Qs,{message:e,observeIntersection:t,noAvatars:s,canAutoLoad:n,canAutoPlay:a,lastSyncTime:i,onClick:b?f:void 0,onCancelUpload:h,isDownloading:c,isProtected:l}))}));var en=s(9937);const tn=(0,o.X$)((({message:e})=>{const t=(0,Ce.Z)(),s=(0,d.eO)(e),{title:n,text:a,amount:r,currency:i,isTest:c,photoUrl:l}=s;return o.ZP.createElement("div",{className:"Invoice"},n&&o.ZP.createElement("p",{className:"title"},(0,Ct.Z)(n)),a&&o.ZP.createElement("p",null,(0,Ct.Z)(a,["emoji","br"])),o.ZP.createElement("div",{className:"description "+(l?"has-image":"")},l&&o.ZP.createElement("img",{className:"invoice-image",src:l,alt:""}),o.ZP.createElement("p",{className:"description-text"},(0,en.x)(r,i,t.code),c&&o.ZP.createElement("span",null,t("PaymentTestInvoice")))))}));function sn(e){return(0,o.X$)((0,n.c$)(((e,t)=>{const{message:s}=t;return{isInSelectMode:(0,i.CA)(e),isSelected:(0,i.vk)(e,s.id)}}))((t=>{const{isInSelectMode:s,isSelected:a,message:r,dimensions:i}=t,{toggleMessageSelection:c}=(0,n.uC)(),d=(0,o.I4)((e=>{e.stopPropagation(),c({messageId:r.id,withShift:null==e?void 0:e.shiftKey})}),[c,r]),l=(0,o.Ye)((()=>({...t,isInSelectMode:s,isSelected:a,dimensions:{...t.dimensions,x:0,y:0},onClick:s?void 0:t.onClick})),[t,s,a]);return o.ZP.createElement("div",{className:(0,ne.Z)("album-item-select-wrapper",a&&"is-selected"),style:i?`left: ${i.x}px; top: ${i.y}px;`:"",onClick:s?d:void 0},s&&o.ZP.createElement("div",{className:"message-select-control"},a&&o.ZP.createElement("i",{className:"icon-select"})),o.ZP.createElement(e,l))})))}const nn=sn(Os),an=sn(Qs),on=(0,n.c$)(((e,{album:t})=>{const{chatId:s}=t.mainMessage,n=(0,i.Pu)(e),a=(0,i.xs)(e,s);return{theme:n,uploadsById:e.fileUploads.byMessageLocalId,activeDownloadIds:a}}))((({album:e,observeIntersection:t,hasCustomAppendix:s,lastSyncTime:a,isOwn:r,isProtected:c,albumLayout:l,onMediaClick:u,uploadsById:m,activeDownloadIds:h,theme:g})=>{const{cancelSendingMessage:p}=(0,n.uC)(),f=e.messages.length,I=(0,o.I4)((e=>{p({chatId:e.chatId,messageId:e.id})}),[p]),{width:v,height:y}=l.containerStyle;return o.ZP.createElement("div",{className:"Album",style:`width: ${v}px; height: ${y}px;`},e.messages.map((function(e,p){const{photo:v,video:y}=(0,d.qp)(e),Z=m[e.previousLocalId||e.id],P=null==Z?void 0:Z.progress,{dimensions:C,sides:w}=l.layout[p],b=(0,i.bH)((0,n.Rd)(),e),S=(0,i.__)((0,n.Rd)(),e);if(v){const n=s&&(r?p===f-1:Boolean(8&w&&4&w));return o.ZP.createElement(nn,{id:`album-media-${e.id}`,message:e,observeIntersection:t,canAutoLoad:b,shouldAffectAppendix:n,uploadProgress:P,dimensions:C,isProtected:c,onClick:u,onCancelUpload:I,isDownloading:h.includes(e.id),theme:g})}if(y)return o.ZP.createElement(an,{id:`album-media-${e.id}`,message:e,observeIntersection:t,canAutoLoad:b,canAutoPlay:S,uploadProgress:P,lastSyncTime:a,dimensions:C,isProtected:c,onClick:u,onCancelUpload:I,isDownloading:h.includes(e.id),theme:g})})))}));function rn(){return(rn=Object.assign||function(e){for(var t=1;t{const i=(0,o.sO)(null),c=(0,o.sO)(null),l=(0,o.sO)(null),m=e.content.video,h=(0,ns.Op)(i,t),[g,p]=(0,o.eJ)(s),f=Boolean(g&&h&&a),{mediaData:I,loadProgress:v}=(0,Ns.Z)((0,d.Ti)(e,"inline"),!f,(0,d.kG)(e,"inline"),a),{loadProgress:y}=(0,Ns.Z)((0,d.Ti)(e,"download"),!r,u.IU.BlobUrl,a),Z=As(e,I),{isBuffered:P,bufferingHandlers:w}=(0,Fs.Z)(),b=g&&!P||r,S=!1===(0,lt.Z)(g),E=(0,Es.Z)(I),{shouldRender:M,transitionClassNames:k}=(0,ce.Z)(b||!P,void 0,S),[R,T]=(0,o.eJ)(!1),[B,A]=(0,o.eJ)(0);(0,o.d4)((()=>{if(!R)return;const e=Pt.Rj/2,t=2*(e-6)*Math.PI,s=t-B*t,n=l.current,a=c.current,o=a.firstElementChild;o?o.firstElementChild.setAttribute("stroke-dashoffset",s.toString()):a.innerHTML=`\n \n \n `,A(n.currentTime/n.duration)}),[R,B]);const x=Boolean(I&&h),L=()=>{T(!1),A(0),(0,$s.Z)(l.current),(0,C.T2)((()=>{c.current.innerHTML=""}))},O=(F=L,()=>{cn&&cn(),cn=F});var F;(0,o.d4)((()=>{l.current&&(x?(0,$s.Z)(l.current):l.current.pause())}),[x]),Ds(l,x),(0,Us.Z)(l,[I]);const U=(0,o.I4)((()=>{if(!I)return void p((e=>!e));if(r)return void(0,n.uC)().cancelMessageMediaDownload({message:e});const t=l.current;R?t.paused?((0,$s.Z)(t),(0,Bt.Es)()):t.pause():(O(),t.pause(),t.currentTime=0,(0,$s.Z)(t),(0,Bt.Es)(),T(!0))}),[O,R,r,I,e]),$=(0,o.I4)((e=>{const t=e.currentTarget;A(t.currentTime/t.duration)}),[]),D=(0,ne.Z)("full-media",E);return o.ZP.createElement("div",{ref:i,className:"RoundVideo media-inner",onClick:U},o.ZP.createElement("div",{className:"thumbnail-wrapper"},o.ZP.createElement("canvas",{ref:Z,className:"thumbnail",style:`width: ${Pt.Rj}px; height: ${Pt.Rj}px`})),I&&o.ZP.createElement("div",{className:"video-wrapper"},o.ZP.createElement("video",rn({ref:l,className:D,width:Pt.Rj,height:Pt.Rj,autoPlay:!0,muted:!R,loop:!R,playsInline:!0,onEnded:R?L:void 0},w,{onTimeUpdate:R?$:void 0}),o.ZP.createElement("source",{src:I}))),o.ZP.createElement("div",{className:"progress",ref:c}),M&&o.ZP.createElement("div",{className:`media-loading ${k}`},o.ZP.createElement(Ls.Z,{progress:r?y:v})),!I&&!g&&o.ZP.createElement("i",{className:"icon-download"}),o.ZP.createElement("div",{className:"message-media-duration"},R?(0,N.k9)(l.current.currentTime):(0,N.k9)(m.duration),(!R||l.current.paused)&&o.ZP.createElement("i",{className:"icon-muted"})))},ln=({message:e,onClick:t})=>{const s=(0,Ce.Z)();return o.ZP.createElement("div",{className:"InlineButtons"},e.inlineButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(Me.Z,{size:"tiny",ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>t({button:e})},(0,Ct.Z)(s(e.text)),"buy"===e.type&&o.ZP.createElement("i",{className:"icon-card"}),"url"===e.type&&!e.value.match(a.FS)&&o.ZP.createElement("i",{className:"icon-arrow-right"}))))))))},un=(0,o.X$)((({threadInfo:e,disabled:t})=>{const{openChat:s}=(0,n.uC)(),a=(0,Ce.Z)(),{threadId:r,chatId:i,messagesCount:c,lastMessageId:l,lastReadInboxMessageId:u,recentReplierIds:m}=e,h=(0,o.I4)((()=>{s({id:i,threadId:r})}),[s,i,r]),g=(0,o.Ye)((()=>{if(null==m||!m.length)return;const{users:{byId:e},chats:{byId:t}}=(0,n.Rd)();return m.map((s=>(0,d.YC)(s)?e[s]:t[s])).filter(Boolean)}),[m]);if(void 0===c)return;const p=Boolean(u&&l&&u0&&o.ZP.createElement("div",{className:"recent-repliers",dir:a.isRtl?"rtl":"ltr"},g.map((e=>o.ZP.createElement(_t.Z,{key:e.id,size:"small",user:(0,d.YC)(e.id)?e:void 0,chat:(0,d.YC)(e.id)?void 0:e})))),o.ZP.createElement("div",{className:"label",dir:"auto"},c?a("Comments",c,"i"):a("LeaveAComment")),o.ZP.createElement("i",{className:"icon-next"}))})),mn="data-is-document-group-hover",hn={__html:''},gn={__html:''};function pn(e){const t=In(e.currentTarget);t&&t.setAttribute(mn,"")}function fn(e){const t=In(e.currentTarget);t&&t.removeAttribute(mn)}function In(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}const vn=(0,o.X$)((0,n.c$)(((e,t)=>{const{focusedMessage:s,forwardMessages:n,lastSyncTime:a}=e,{message:o,album:r,withSenderName:c,withAvatar:l,threadId:u,messageListType:m}=t,{id:h,chatId:g,viaBotId:p,replyToChatId:f,replyToMessageId:I,isOutgoing:v,threadInfo:y}=o,Z=(0,i.Z1)(e,g),P=(0,i.FM)(e,g),C=(0,d.pK)(g),w=Z&&(0,d.eA)(Z),b=null==Z?void 0:Z.username,S=!P&&(0,d.Ul)(o),E=c||l||S,M=(0,i.Ur)(e,o),k=(0,i.cv)(e,o),R=p?(0,i.dy)(e,p):void 0,T=u?(0,i.qS)(e,g,u):void 0,N=o.id===T,B=I===T,A=I&&!B?(0,i.hj)(e,C&&f?f:g,I):void 0,x=A&&(0,i.Ur)(e,A),L=(0,i.uZ)(e,o),O="thread"===m&&(r?r.messages.some((t=>(0,i._X)(e,t))):(0,i._X)(e,o)),{direction:F,noHighlight:U,isResizingContainer:$}=O&&s||{},D=n.messageIds&&n.messageIds.includes(h),{query:q}=(0,i.n5)(e)||{},Q=(0,d._O)(o);let G;G=null!=r&&r.messages?r.messages.every((({id:t})=>(0,i.vk)(e,t))):(0,i.vk)(e,h);const{canReply:j}="thread"===m&&(0,i._k)(e,o,u)||{},H=(0,i.te)(e,o),_=y?(0,i.tZ)(e,y.chatId,y.threadId)||y:void 0;return{theme:(0,i.Pu)(e),chatUsername:b,forceSenderName:S,sender:E?M:void 0,originSender:k,botSender:R,shouldHideReply:B,isThreadTop:N,replyMessage:A,replyMessageSender:x,isProtected:(0,i.EV)(e,o),isFocused:O,isForwarding:D,isChatWithSelf:P,isRepliesChat:C,isChannel:w,canReply:j,lastSyncTime:a,highlight:q,isSingleEmoji:Boolean(Q),animatedEmoji:Q?(0,i.zB)(e,Q):void 0,isInSelectMode:(0,i.CA)(e),isSelected:G,isGroupSelected:!!o.groupedId&&!o.isInAlbum&&(0,i.a6)(e,g,o.groupedId),threadId:u,isDownloading:H,isPinnedList:"pinned"===m,canAutoLoadMedia:(0,i.bH)(e,o),canAutoPlayMedia:(0,i.__)(e,o),autoLoadFileMaxSizeMb:e.settings.byKey.autoLoadFileMaxSizeMb,shouldLoopStickers:(0,i.yB)(e),threadInfo:_,...v&&{outgoingStatus:(0,i.dT)(e,o,"scheduled"===m)},..."number"==typeof L&&{uploadProgress:L},...O&&{focusDirection:F,noFocusHighlight:U,isResizingContainer:$}}}))((({message:e,chatUsername:t,observeIntersectionForBottom:s,observeIntersectionForMedia:a,observeIntersectionForAnimatedStickers:r,album:i,noAvatars:c,withAvatar:l,withSenderName:g,noComments:p,appearanceOrder:f,isFirstInGroup:I,isLastInGroup:v,isFirstInDocumentGroup:y,isLastInDocumentGroup:Z,isLastInList:P,theme:C,forceSenderName:w,sender:b,originSender:S,botSender:E,isThreadTop:M,shouldHideReply:k,replyMessage:R,replyMessageSender:T,outgoingStatus:N,uploadProgress:B,isProtected:A,isFocused:x,focusDirection:L,noFocusHighlight:O,isResizingContainer:F,isForwarding:U,isChatWithSelf:$,isRepliesChat:D,isChannel:q,canReply:Q,lastSyncTime:G,highlight:j,animatedEmoji:H,isInSelectMode:_,isSelected:z,isGroupSelected:V,threadId:K,messageListType:Y,isPinnedList:W,isDownloading:X,canAutoLoadMedia:J,canAutoPlayMedia:ee,shouldLoopStickers:te,autoLoadFileMaxSizeMb:se,threadInfo:ae})=>{const{toggleMessageSelection:oe,clickInlineButton:de,disableContextMenuHint:le}=(0,n.uC)(),ue=(0,o.sO)(null),me=(0,o.sO)(null),he=(0,Ce.Z)();(0,ns._N)(me,s);const{isContextMenuOpen:ge,contextMenuPosition:pe,handleBeforeContextMenu:fe,handleContextMenu:Ie,handleContextMenuClose:ve,handleContextMenuHide:Ze}=(0,rs.Z)(ue,h.$b&&_,!0,h.wZ);(0,o.d4)((()=>{ge&&le()}),[ge,le]);const Pe=f<=0,[we,be]=(0,ye.Z)(Pe);(0,o.d4)((()=>{Pe||setTimeout(be,10*f)}),[f,be,Pe]);const{transitionClassNames:Se}=(0,ce.Z)(we,void 0,Pe,!1),{id:Ee,chatId:ke}=e,Re=(0,d.CI)(e),Te=(0,d.B4)(e),Ne="scheduled"===Y||e.isScheduled,Be=(0,d.ss)(e)&&!k,Ae=Boolean(ae)&&"thread"===Y,xe=(0,d.$D)(e),{forwardInfo:Oe,viaBotId:Fe}=e,Ue=Oe&&(!$||Ne)&&!D&&!Oe.isLinkedChannelPost&&!xe,$e=Boolean(e.groupedId)&&!e.isInAlbum,De=Boolean(i)&&i.messages.length>1,{text:qe,photo:Qe,video:Ge,audio:je,voice:He,document:_e,sticker:ze,contact:Ve,poll:Ke,webPage:Ye,invoice:We}=(0,d.qp)(e),Xe=(0,is.X)(e,j,cs(xe)),Je=void 0!==pe,et=q&&e.adminTitle||!Ue&&(null==Oe?void 0:Oe.adminTitle)||void 0,tt=(0,o.Ye)((()=>et?fs(et):void 0),[et]),st=!(Je||_||U)&&(!$e||Z),nt=q&&!Ne,at=Boolean(W||Oe&&(Oe.isChannelPost||$&&!Te||D)&&Oe.fromMessageId),ot=Oe&&($||D||!b)?S:b,rt=Oe?S:b,it=(0,o.I4)(((e,t)=>{oe({messageId:Ee,groupedId:t,...(null==e?void 0:e.shiftKey)&&{withShift:!0},...De&&{childMessageIds:i.messages.map((({id:e})=>e))}})}),[oe,Ee,De,i]),{handleMouseDown:ct,handleClick:dt,handleContextMenu:lt,handleDoubleClick:ut,handleContentDoubleClick:mt,isSwiped:ht}=function(e,t,s,a,r,i,c,d,l){const{setReplyingToId:u}=(0,n.uC)(),[m,g,p]=(0,ye.Z)();return(0,o.d4)((()=>{if(!h.$b||r||!i)return;let e;return(0,Le.s)(t.current,{selectorToPreventScroll:".MessageList",onSwipe:(t,s)=>s===Le.e.Left&&(e||(e=Date.now()),g(),!0),onRelease:()=>{e&&(u({messageId:s}),setTimeout(p,Math.max(0,150-(Date.now()-e))),e=void 0)}})}),[t,r,s,u,g,p,i]),{handleMouseDown:r?void 0:function(e){(0,Jt.q)(e),l(e)},handleClick:function(t){if(r)e(t);else if(h.wZ){const e=t.target;if(!e.classList.contains("text-content")&&!e.classList.contains("Message"))return;ie.Z.getIsKeyboardVisible()?setTimeout((()=>{d(t)}),350):d(t)}},handleContextMenu:r?c?re.Z:void 0:function(t){if(h.wZ){if(t.target.matches("a[href]"))return;t.preventDefault(),e()}else d(t)},handleDoubleClick:r?void 0:function(){u({messageId:s})},handleContentDoubleClick:h.$b?void 0:function(e){e.stopPropagation()},isSwiped:m}}(it,ue,Ee,0,Boolean(_),Boolean(Q),Boolean(A),Ie,fe),{handleAvatarClick:pt,handleSenderClick:ft,handleViaBotClick:It,handleReplyClick:vt,handleMediaClick:yt,handleAudioPlay:Zt,handleAlbumMediaClick:wt,handleMetaClick:bt,handleReadMedia:St,handleCancelUpload:Et,handleVoteSend:Mt,handleGroupForward:kt,handleForward:Rt,handleFocus:Tt,handleFocusForwarded:Nt,handleDocumentGroupSelectAll:Bt}=function(e,t,s,a,r,i,c,l,h,g,p,f,I){const{openUserInfo:v,openChat:y,showNotification:Z,focusMessage:P,openMediaViewer:C,openAudioPlayer:w,markMessagesRead:b,cancelSendingMessage:S,sendPollVote:E,openForwardMenu:M,focusMessageInComments:k}=(0,n.uC)(),{id:R,forwardInfo:T,replyToMessageId:N,replyToChatId:B,replyToTopMessageId:A,groupedId:x}=s,L=(0,o.I4)((()=>{p&&((0,d.YC)(p.id)?v({id:p.id}):y({id:p.id}))}),[p,v,y]),O=(0,o.I4)((()=>{f?c&&null!=T&&T.channelPostId?P({chatId:f.id,messageId:T.channelPostId}):(0,d.YC)(f.id)?v({id:f.id}):y({id:f.id}):Z({message:e("HidAccount")})}),[c,P,T,e,y,v,f,Z]),F=(0,o.I4)((()=>{I&&v({id:I.id})}),[I,v]),U=(0,o.I4)((()=>{P({chatId:h&&B?B:a,threadId:r,messageId:N,replyMessageId:h&&B?void 0:R})}),[P,h,B,a,r,N,R]),$=(0,o.I4)((()=>{C({chatId:a,threadId:r,messageId:R,origin:l?m.bZ.ScheduledInline:m.bZ.Inline})}),[a,r,R,C,l]),D=(0,o.I4)((()=>{w({chatId:a,messageId:R})}),[a,R,w]),q=(0,o.I4)((e=>{C({chatId:a,threadId:r,messageId:e,origin:l?m.bZ.ScheduledAlbum:m.bZ.Album})}),[a,r,C,l]),Q=(0,o.I4)((()=>{b({messageIds:[R]})}),[R,b]),G=(0,o.I4)((()=>{S({chatId:a,messageId:R})}),[S,a,R]),j=(0,o.I4)((e=>{E({chatId:a,messageId:R,options:e})}),[a,R,E]),H=(0,o.I4)((()=>{M({fromChatId:a,groupedId:x})}),[M,a,x]),_=(0,o.I4)((()=>{if(g&&g.messages){const e=g.messages.map((({id:e})=>e));M({fromChatId:a,messageIds:e})}else M({fromChatId:a,messageIds:[R]})}),[g,M,a,R]),z=(0,o.I4)((()=>{P({chatId:a,threadId:u._f,messageId:R})}),[P,a,R]),V=(0,o.I4)((()=>{i?P({chatId:T.fromChatId,groupedId:x,groupedChatId:a}):h&&B?k({chatId:B,threadId:A,messageId:T.fromMessageId}):P({chatId:T.fromChatId,messageId:T.fromMessageId})}),[i,h,B,P,T,x,a,k,A]),K=(0,o.I4)((e=>{e.stopPropagation(),t(e,x)}),[t,x]);return{handleAvatarClick:L,handleSenderClick:O,handleViaBotClick:F,handleReplyClick:U,handleMediaClick:$,handleAudioPlay:D,handleAlbumMediaClick:q,handleMetaClick:K,handleReadMedia:Q,handleCancelUpload:G,handleVoteSend:j,handleGroupForward:H,handleForward:_,handleFocus:z,handleFocusForwarded:V,handleDocumentGroupSelectAll:K}}(he,it,e,ke,K,$e,Ue,Ne,D,i,ot,rt,E),At=(0,ne.Z)("Message message-list-item",I&&"first-in-group",A&&"is-protected",v&&"last-in-group",y&&"first-in-document-group",Z&&"last-in-document-group",P&&"last-in-list",Te&&"own",Boolean(e.views)&&"has-views",e.isEdited&&"was-edited",Be&&"has-reply",Je&&"has-menu-open",x&&!O&&"focused",U&&"is-forwarding",e.isDeleting&&"is-deleting",$e&&"is-in-document-group",De&&"is-album",e.hasUnreadMention&&"has-unread-mention",z&&"is-selected",_&&"is-in-selection-mode",M&&"is-thread-top",Boolean(e.inlineButtons)&&"has-inline-buttons",ht&&"is-swiped",Se),xt=function(e,{hasReply:t,customShape:s,isLastInGroup:n,asForwarded:a,hasThread:o,forceSenderName:r,hasComments:i,hasActionButton:c}={}){const{text:l,photo:u,video:m,audio:h,voice:g,document:p,poll:f,webPage:I,contact:v}=(0,d.qp)(e),y=["message-content"],Z=u||m,P=Z&&!l,C=Boolean(e.viaBotId);return cs(s)?y.push(`emoji-only emoji-only-${s}`):l&&y.push("text"),c&&y.push("has-action-button"),s&&(y.push("custom-shape"),null!=m&&m.isRound&&y.push("round"),i&&y.push("has-comments")),u||m?y.push("media"):h?y.push("audio"):g?y.push("voice"):p?y.push("document"):v?y.push("contact"):f?y.push("poll"):I&&(y.push("web-page"),(I.photo||I.video)&&y.push("media")),a&&y.push("is-forwarded"),t&&y.push("is-reply"),o&&y.push("has-replies"),C&&y.push("is-via-bot"),r&&y.push("force-sender-name"),s||(y.push("has-shadow"),Z&&i&&y.push("has-background"),(t||a||!P||C||r)&&y.push("has-solid-background"),!n||!u&&P||y.push("has-appendix")),y.join(" ")}(e,{hasReply:Be,customShape:xe,isLastInGroup:v,asForwarded:Ue,hasThread:Ae,forceSenderName:w,hasComments:ae&&(null==ae?void 0:ae.messagesCount)>0,hasActionButton:nt||at}),Lt=ae&&(!$e||Z)&&"thread"===Y&&!p,Ot=xt.includes("has-appendix");(0,gt.Z)(D&&e.replyToChatId?e.replyToChatId:ke,Be?e.replyToMessageId:void 0,R,e.id),Is(ue,ke,x,L,O,F);let Ft,Ut="",$t=!1;const Dt=(0,o.Ye)((()=>De?gs(Te,Boolean(Ue),Boolean(c),i):void 0),[De,Te,Ue,c,i]),qt=Ue?28:0;if(De||!Qe&&!Ge)Dt&&(Ft=Math.max(ds(Boolean(qe),Lt),Dt.containerStyle.width),Ft-Dt.containerStyle.width>18&&($t=!0));else{let t;Qe?t=ls(e,c).width:Ge&&(t=Ge.isRound?Pt.Rj:ls(e,c).width),t&&(Ft=Math.max(ds(Boolean(qe),Lt),t),Ft-t>18&&($t=!0))}return Ft&&(Ut=`width: ${Ft+qt}px`),o.ZP.createElement("div",{ref:ue,id:`message${Ee}`,className:At,style:tt?`--meta-safe-author-width: ${tt}px`:void 0,"data-message-id":Ee,onMouseDown:ct,onClick:dt,onContextMenu:lt,onDoubleClick:ut,onMouseEnter:$e&&!Z?pn:void 0,onMouseLeave:$e&&!Z?fn:void 0},o.ZP.createElement("div",{ref:me,className:"bottom-marker","data-message-id":Ee,"data-last-message-id":i?i.messages[i.messages.length-1].id:void 0,"data-has-unread-mention":e.hasUnreadMention}),!$e&&o.ZP.createElement("div",{className:"message-select-control"},z&&o.ZP.createElement("i",{className:"icon-select"})),Z&&o.ZP.createElement("div",{className:(0,ne.Z)("message-select-control group-select",V&&"is-selected"),onClick:Bt},V&&o.ZP.createElement("i",{className:"icon-select"})),l&&function(){const e=ot&&(0,d.YC)(ot.id),t=ot&&e?ot:void 0,s=ot&&!e?ot:void 0,n=!ot&&Oe?Oe.hiddenUserName:void 0;return o.ZP.createElement(_t.Z,{size:"small",user:t,chat:s,text:n,lastSyncTime:G,onClick:t||s?pt:void 0})}(),o.ZP.createElement("div",{className:(0,ne.Z)("message-content-wrapper",xt.includes("text")&&"can-select-text")},o.ZP.createElement("div",{className:xt,style:Ut,dir:"auto"},Ue&&(!$e||y)&&o.ZP.createElement("div",{className:"message-title"},he("ForwardedMessage")),function(){const t=(0,ne.Z)("content-inner",Ue&&"forwarded-message",Be&&"reply-message",$t&&"no-media-corners"),s=v&&!Xe&&!Ue&&!Ae,n=!Ye&&!H&&Xe,l=(0,ne.Z)("text-content",n&&"with-meta",N&&"with-outgoing-icon");return o.ZP.createElement("div",{className:t,onDoubleClick:mt,dir:"auto"},function(){if(xe&&!Fe||!(g&&!Qe&&!Ge||Ue||Fe||w)||$e&&!y||Be&&xe)return;let t,s;return!rt||xe&&Fe?null!=Oe&&Oe.hiddenUserName&&(t=Oe.hiddenUserName):(t=(0,d.OU)(he,rt),Ue||(s=`color-${(0,d.Rs)(rt)}`)),o.ZP.createElement("div",{className:"message-title",dir:"ltr"},t?o.ZP.createElement("span",{className:(0,ne.Z)("interactive",s),onClick:ft,dir:"auto"},(0,Ct.Z)(t)):E?void 0:" ",E&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"via"},he("ViaBot")),o.ZP.createElement("span",{className:"interactive",onClick:It},(0,Ct.Z)(`@${E.username}`))),null!=Oe&&Oe.isLinkedChannelPost?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},he("DiscussChannel")):e.adminTitle&&!q?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},e.adminTitle):void 0)}(),Be&&o.ZP.createElement(Ps,{message:R,isProtected:A,sender:T,observeIntersection:a,onClick:vt}),ze&&o.ZP.createElement(Rs,{message:e,observeIntersection:a,observeIntersectionForPlaying:r,shouldLoop:te,lastSyncTime:G}),H&&o.ZP.createElement(Ts.Z,{size:"small",sticker:H,observeIntersection:a,lastSyncTime:G,forceLoadPreview:Re}),De&&o.ZP.createElement(on,{album:i,albumLayout:Dt,observeIntersection:a,isOwn:Te,isProtected:A,hasCustomAppendix:s,lastSyncTime:G,onMediaClick:wt}),!De&&Qe&&o.ZP.createElement(Os,{message:e,observeIntersection:a,noAvatars:c,canAutoLoad:J,uploadProgress:B,shouldAffectAppendix:s,onClick:yt,onCancelUpload:Et,isDownloading:X,isProtected:A,theme:C}),!De&&Ge&&Ge.isRound&&o.ZP.createElement(dn,{message:e,observeIntersection:a,canAutoLoad:J,lastSyncTime:G,isDownloading:X}),!De&&Ge&&!Ge.isRound&&o.ZP.createElement(Qs,{message:e,observeIntersection:a,noAvatars:c,canAutoLoad:J,canAutoPlay:ee,uploadProgress:B,lastSyncTime:G,onClick:yt,onCancelUpload:Et,isDownloading:X,isProtected:A}),(je||He)&&o.ZP.createElement(ws.Z,{theme:C,message:e,origin:m.Cr.Inline,uploadProgress:B,lastSyncTime:G,isSelectable:$e,isSelected:z,onPlay:Zt,onReadMedia:!He||Te&&!$?void 0:St,onCancelUpload:Et,isDownloading:X}),_e&&o.ZP.createElement(Cs.Z,{message:e,observeIntersection:a,canAutoLoad:J,autoLoadFileMaxSizeMb:se,uploadProgress:B,isSelectable:$e,isSelected:z,onMediaClick:yt,onCancelUpload:Et,isDownloading:X}),Ve&&o.ZP.createElement(js,{contact:Ve}),Ke&&o.ZP.createElement(Ys,{message:e,poll:Ke,onSendVote:Mt}),!H&&Xe&&o.ZP.createElement("p",{className:l,dir:"auto"},Xe,n&&o.ZP.createElement(Ss,{message:e,outgoingStatus:N,signature:et,onClick:bt})),Ye&&o.ZP.createElement(Js,{message:e,observeIntersection:a,noAvatars:c,canAutoLoad:J,canAutoPlay:ee,lastSyncTime:G,onMediaClick:yt,onCancelMediaTransfer:Et,isDownloading:X,isProtected:A,theme:C}),We&&o.ZP.createElement(tn,{message:e}))}(),(!$e||Z)&&!(!Ye&&!H&&Xe)&&o.ZP.createElement(Ss,{message:e,outgoingStatus:N,signature:et,onClick:bt}),st&&nt?o.ZP.createElement(Me.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:he("lng_context_forward_msg"),onClick:Z?kt:Rt},o.ZP.createElement("i",{className:"icon-share-filled"})):st&&at?o.ZP.createElement(Me.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:W?Tt:Nt},o.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,Lt&&o.ZP.createElement(un,{threadInfo:ae,disabled:p}),Ot&&o.ZP.createElement("div",{className:"svg-appendix",dangerouslySetInnerHTML:Te?hn:gn})),e.inlineButtons&&o.ZP.createElement(ln,{message:e,onClick:de})),pe&&o.ZP.createElement(ys,{isOpen:ge,anchor:pe,message:e,album:i,chatUsername:t,messageListType:Y,onClose:ve,onCloseAnimationEnd:Ze}))}))),yn=(0,o.X$)((0,n.c$)(((e,{chatId:t})=>{const s=(0,i.fS)(e,t),{chatId:n,isBot:a}=s||{};return{message:s,bot:n&&a?(0,i.dy)(e,n):void 0,channel:!a&&n?(0,i.Z1)(e,n):void 0}}))((({chatId:e,message:t,containerRef:s,bot:a,channel:r})=>{const{viewSponsoredMessage:i,openChat:c,openChatByInvite:l,startBot:u,focusMessage:m}=(0,n.uC)(),h=(0,Ce.Z)(),g=(0,o.sO)(null),p=Boolean(t),{observe:f}=(0,ns.S1)({rootRef:s,debounceMs:200,threshold:1});if((0,o.d4)((()=>p?f(g.current,(t=>{t.isIntersecting&&i({chatId:e})})):void 0),[e,p,f,i]),t)return o.ZP.createElement("div",{className:"SponsoredMessage Message open",key:"sponsored-message"},o.ZP.createElement("div",{className:"message-content has-shadow has-solid-background",dir:"auto"},o.ZP.createElement("div",{className:"content-inner",dir:"auto"},o.ZP.createElement("div",{className:"message-title",dir:"ltr"},a&&(0,Ct.Z)((0,d.Js)(a)||""),r&&(0,Ct.Z)(t.chatInviteTitle||(0,d.U)(h,r,a)||"")),o.ZP.createElement("p",{className:"text-content with-meta",dir:"auto",ref:g},o.ZP.createElement("span",{className:"text-content-inner",dir:"auto"},(0,is.H)(t.text.text,t.text.entities)),o.ZP.createElement("span",{className:"MessageMeta",dir:"ltr"},o.ZP.createElement("span",{className:"message-signature"},h("SponsoredMessage")))),o.ZP.createElement(Me.Z,{color:"secondary",size:"tiny",ripple:!0,onClick:()=>{t.chatInviteHash?l({hash:t.chatInviteHash}):t.channelPostId?m({chatId:t.chatId,messageId:t.channelPostId}):(c({id:t.chatId}),t.startParam&&u({botId:t.chatId,param:t.startParam}))},className:"SponsoredMessage__button"},h(t.isBot?"Conversation.ViewBot":t.channelPostId?"Conversation.ViewPost":"Conversation.ViewChannel")))))}))),Zn=(0,o.X$)((({chatId:e,messageIds:t,messageGroups:s,isViewportNewest:r,isUnread:i,withUsers:c,noAvatars:l,containerRef:u,anchorIdRef:p,memoUnreadDividerBeforeIdRef:f,memoFirstUnreadIdRef:I,threadId:v,type:y,isReady:Z,isScrollingRef:P,isScrollPatchNeededRef:w,threadTopMessageId:b,hasLinkedChat:S,isSchedule:E,noAppearanceAnimation:M,onFabToggle:k,onNotchToggle:R})=>{const{openHistoryCalendar:T}=(0,n.uC)(),{observeIntersectionForMedia:B,observeIntersectionForReading:A,observeIntersectionForAnimatedStickers:x}=function(e,t,s){const{markMessageListRead:a,markMessagesRead:o}=(0,n.uC)(),{observe:r}=(0,ns.S1)({rootRef:t,throttleMs:as,margin:os}),{observe:i,freeze:c,unfreeze:d}=(0,ns.S1)({rootRef:t,throttleMs:150},(t=>{if("thread"!==e)return;let n=0;const r=[];t.forEach((e=>{const{isIntersecting:t,target:s}=e;if(!t)return;const{dataset:a}=s,o=Number(a.lastMessageId||a.messageId);o>n&&(n=o),a.hasUnreadMention&&r.push(o)})),s.current&&n>=s.current&&a({maxId:n}),r.length&&o({messageIds:r})}));(0,de.Z)(c,d);const{observe:l}=(0,ns.S1)({rootRef:t,throttleMs:as});return{observeIntersectionForMedia:r,observeIntersectionForReading:i,observeIntersectionForAnimatedStickers:l}}(y,u,I),{backwardsTriggerRef:L,forwardsTriggerRef:O,fabTriggerRef:F}=function(e,t,s,r,i,c,d,l,u,g){const{loadViewportMessages:p}=(0,n.uC)(),[f,I]=(0,o.Ye)((()=>"thread"===e?[(0,C.Ds)((()=>p({direction:m.Uq.Backwards})),1e3,!0,!1),(0,C.Ds)((()=>p({direction:m.Uq.Forwards})),1e3,!0,!1)]:[]),[p,s]),v=(0,o.sO)(null),y=(0,o.sO)(null),Z=(0,o.sO)(null);function P(){if(!l)return;if(!s||!s.length)return c(!1),void d(!1);if(!r)return c(!0),void d(!0);const{offsetHeight:e,scrollHeight:n,scrollTop:a}=t.current,o=Math.round(n-a-e),u=o<=1;c(i?!u:!(o<=50)),d(!u)}const{observe:w}=(0,ns.S1)({rootRef:t,margin:h.gZ},(e=>{if(!I||!f)return;if(s[0]>=a.AE)return;const t=e.find((({isIntersecting:e})=>e));if(!t)return;const{target:n}=t;"backwards-trigger"===n.className?(h.i4&&u.current&&s.length<=a.hT&&(g.current=!0),f()):"forwards-trigger"===n.className&&I()}));(0,ns._N)(v,w),(0,ns._N)(y,w);const{observe:b,freeze:S,unfreeze:E}=(0,ns.S1)({rootRef:t,margin:100},P);(0,ns._N)(Z,b);const{observe:M,freeze:k,unfreeze:R}=(0,ns.S1)({rootRef:t,margin:1},P);return(0,ns._N)(Z,M),(0,ue.Z)((()=>{l&&P()}),[l]),(0,ue.Z)((()=>{S(),k(),setTimeout((()=>{R(),E()}),250)}),[s]),{backwardsTriggerRef:v,forwardsTriggerRef:y,fabTriggerRef:Z}}(y,u,t,r,i,k,R,Z,P,w),U=(0,Ce.Z)(),$=o.ZP.createElement("div",{className:(0,ne.Z)("unread-divider","local-action-message"),key:"unread-messages"},o.ZP.createElement("span",null,U("UnreadMessages"))),D=M?0:s.reduce(((e,t)=>e+(0,g.xH)(t.senderGroups).length),0);let q=0;const Q=s.map(((e,t,s)=>{const n=e.senderGroups.map(((e,n,a)=>{if(1===e.length&&!Wt(e[0])&&(0,d.Lo)(e[0])){const r=e[0],i=n===a.length-1&&t===s.length-1;return(0,g.oA)([r.id===f.current&&$,o.ZP.createElement(Zs,{key:r.id,message:r,observeIntersection:A,appearanceOrder:D-++q,isLastInList:i})])}let r;return(0,g.xH)(e.map(((i,u)=>{const m=Wt(i)?i.mainMessage:i,h=Wt(i)?i:void 0,I=(0,d.B4)(m),Z=Wt(i),P=e[u+1];m.previousLocalId&&p.current===`message${m.previousLocalId}`&&(p.current=`message${m.id}`);const C=!Z&&m.groupedId?m.groupedId:void 0,w=P&&!Wt(P)?P.groupedId:void 0,E={isFirstInGroup:0===u,isLastInGroup:u===e.length-1,isFirstInDocumentGroup:Boolean(C&&C!==r),isLastInDocumentGroup:Boolean(C&&C!==w),isLastInList:u===e.length-1&&n===a.length-1&&t===s.length-1};r=C;const M=(0,d.KK)(m),k="scheduled"!==y?M:`${m.date}_${M}`;return(0,g.oA)([m.id===f.current&&$,o.ZP.createElement(vn,{key:k,message:m,observeIntersectionForBottom:A,observeIntersectionForMedia:B,observeIntersectionForAnimatedStickers:x,album:h,noAvatars:l,withAvatar:E.isLastInGroup&&c&&!I&&!(m.id===b),withSenderName:E.isFirstInGroup&&c&&!I,threadId:v,messageListType:y,noComments:!1===S,appearanceOrder:D-++q,isFirstInGroup:E.isFirstInGroup,isLastInGroup:E.isLastInGroup,isFirstInDocumentGroup:E.isFirstInDocumentGroup,isLastInDocumentGroup:E.isLastInDocumentGroup,isLastInList:E.isLastInList}),m.id===b&&o.ZP.createElement("div",{className:"local-action-message",key:"discussion-started"},o.ZP.createElement("span",null,U("DiscussionStarted")))])})))}));return o.ZP.createElement("div",{className:"message-date-group",key:e.datetime,onMouseDown:Jt.q,teactFastList:!0},o.ZP.createElement("div",{className:(0,ne.Z)("sticky-date",!E&&"interactive"),key:"date-header",onMouseDown:Jt.q,onClick:E?void 0:()=>T({selectedAt:e.datetime})},o.ZP.createElement("span",{dir:"auto"},E&&e.originalDate===a.t4&&U("MessageScheduledUntilOnline"),E&&e.originalDate!==a.t4&&U("MessageScheduledOn",(0,N.j1)(U,e.datetime,void 0,!0)),!E&&(0,N.j1)(U,e.datetime))),(0,g.xH)(n))}));return o.ZP.createElement("div",{className:"messages-container",teactFastList:!0},o.ZP.createElement("div",{ref:L,key:"backwards-trigger",className:"backwards-trigger"}),(0,g.xH)(Q),r&&o.ZP.createElement(yn,{key:e,chatId:e,containerRef:u}),o.ZP.createElement("div",{ref:O,key:"forwards-trigger",className:"forwards-trigger"}),o.ZP.createElement("div",{ref:F,key:"fab-trigger",className:"fab-trigger"}))}));var Pn=s(3547);const Cn=(0,o.X$)((0,n.c$)(((e,{userId:t})=>{const{stickers:s}=e.stickers.greeting,n=(0,d.db)(t)+(0,d.db)(e.currentUserId),a=null!=s&&s.length?s[n%s.length]:void 0,o=(0,i.Z1)(e,t);return o?{sticker:a,lastUnreadMessageId:o.lastMessage&&o.lastMessage.id!==o.lastReadInboxMessageId?o.lastMessage.id:void 0,connectionState:e.connectionState}:{}}))((({sticker:e,connectionState:t,lastUnreadMessageId:s})=>{const{loadGreetingStickers:a,sendMessage:r,markMessageListRead:i}=(0,n.uC)(),c=(0,Ce.Z)(),d=(0,o.sO)(null),{observe:l}=(0,ns.S1)({rootRef:d,debounceMs:200});(0,o.d4)((()=>{e||"connectionStateReady"!==t||a()}),[t,a,e]),(0,o.d4)((()=>{"connectionStateReady"===t&&s&&i({maxId:s})}),[t,i,s]);const u=(0,o.I4)((e=>{e={...e,isPreloadedGlobally:!0},r({sticker:e})}),[r]);return o.ZP.createElement("div",{className:"ContactGreeting",ref:d},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("p",{className:"title",dir:"auto"},c("Conversation.EmptyPlaceholder")),o.ZP.createElement("p",{className:"description",dir:"auto"},c("Conversation.GreetingText")),o.ZP.createElement("div",{className:"sticker"},e&&o.ZP.createElement(Pn.Z,{sticker:e,onClick:u,clickArg:e,observeIntersection:l,size:160,className:"large"}))))}))),wn=(0,o.X$)((({isChatWithSelf:e,type:t,isGroupChatJustCreated:s})=>{const n=(0,Ce.Z)();return"scheduled"===t?function(e){return o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,e("ScheduledMessages.EmptyPlaceholder")))}(n):e?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("i",{className:"icon icon-cloud-download"}),o.ZP.createElement("h3",{className:"title"},e("Conversation.CloudStorageInfo.Title")),o.ZP.createElement("ul",{className:"description"},o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description1")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description2")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description3")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description4")))))}(n):s?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper",dir:e.isRtl?"rtl":void 0},o.ZP.createElement("h3",{className:"title"},e("EmptyGroupInfo.Title")),o.ZP.createElement("p",{className:"description"},e("EmptyGroupInfo.Subtitle")),o.ZP.createElement("ul",{className:"list-checkmarks"},o.ZP.createElement("li",null,e("EmptyGroupInfo.Line1")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line2")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line3")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line4")))))}(n):o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,n("NoMessages")))})),bn=(0,C.Ds)((e=>e()),200,!1),Sn=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,type:n})=>{const a=(0,i.Z1)(e,t);if(!a)return{};const o=(0,i.$W)(e,t,s,n),r="scheduled"===n?(0,i.Fn)(e,t):(0,i.Zw)(e,t),c=(0,i.qS)(e,t,s);if(s!==u._f&&!(r&&c&&r[c]))return{};const{isRestricted:l,restrictionReason:m,lastMessage:h}=a,g=(0,i.G$)(e,t),p=s===u._f&&!o&&!a.unreadCount&&!g&&h&&!h.groupedId,f=(0,i.IK)(e,t);let I;return(0,i.pk)(e,t)&&(I=f.fullInfo?f.fullInfo.botDescription||"NoMessages":"Updating bot info..."),{isChatLoaded:!0,isRestricted:l,restrictionReason:m,isChannelChat:(0,d.eA)(a),isGroupChat:(0,d.Bf)(a),isCreator:a.isCreator,isChatWithSelf:(0,i.FM)(e,t),isRepliesChat:(0,d.pK)(t),isBot:Boolean(f),messageIds:o,messagesById:r,firstUnreadId:(0,i.It)(e,t,s),isViewportNewest:"thread"!==n||(0,i.b9)(e,t,s),threadFirstMessageId:(0,i.yZ)(e,t,s),focusingId:g,isSelectModeActive:(0,i.CA)(e),botDescription:I,threadTopMessageId:c,hasLinkedChat:a.fullInfo&&"linkedChatId"in a.fullInfo?Boolean(a.fullInfo.linkedChatId):void 0,lastSyncTime:e.lastSyncTime,...p&&{lastMessage:h}}}))((({chatId:e,threadId:t,type:s,hasTools:r,onFabToggle:c,onNotchToggle:l,isChatLoaded:u,isChannelChat:h,isGroupChat:p,canPost:f,isReady:I,isChatWithSelf:v,isRepliesChat:y,isCreator:Z,isBot:P,messageIds:w,messagesById:b,firstUnreadId:S,isViewportNewest:E,threadFirstMessageId:M,isRestricted:k,restrictionReason:R,focusingId:T,isSelectModeActive:N,lastMessage:B,botDescription:A,threadTopMessageId:x,hasLinkedChat:L,lastSyncTime:O,withBottomShift:F})=>{var U,$,D,q,Q,G;const{loadViewportMessages:j,setScrollOffset:H,loadSponsoredMessages:_}=(0,n.uC)(),z=(0,o.sO)(null),V=(0,o.sO)("thread"===s&&(0,i.Vt)((0,n.Rd)(),e,t)||0),K=(0,o.sO)(),Y=(0,o.sO)(),W=(0,o.sO)(),X=(0,o.sO)(),J=(0,o.sO)(),ee=(0,o.sO)(),te=(0,o.sO)(!1),ae=(0,o.sO)(Boolean(B)),[oe,re]=(0,o.eJ)(),ie=Boolean(w);(0,ue.Z)((()=>{ie&&(0,C.R3)((()=>{ae.current=!1}))}),[ie]),(0,ue.Z)((()=>{X.current=S}),[S]),(0,ue.Z)((()=>{h&&I&&O&&_({chatId:e})}),[e,I,h,O]),(0,ue.Z)((()=>{ie&&(J.current=X.current)}),[ie]),(0,ue.Z)((()=>{ee.current=T}),[T]);const ce=(0,o.Ye)((()=>{if(!w||!b)return;const e=!x||w[0]&&M!==w[0]?w:[x,...w];if(!e.length)return;const t=e.map((e=>b[e])).filter(Boolean);return Xt((0,g.Xo)(t,["date","id"]),J.current)}),[w,b,M,x]),de=(0,o.Ye)((()=>{if("thread"===s)return(0,C.Ds)((()=>j({direction:m.Uq.Around})),1e3,!0,!1)}),[j,w]),{isScrolled:le,updateStickyDates:me}=function(){const[e,t]=(0,ye.Z)(!1),s=(0,es.Z)(1e3,!1);return{isScrolled:e,updateStickyDates:(0,o.I4)(((e,n)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,C.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),s((()=>{(0,C.T2)((()=>{const t=document.querySelector(".stuck");t&&t.classList.remove("stuck");const s=function(e,t){const s=e.querySelectorAll(".sticky-date"),n=e.scrollTop;return Array.from(s).find((e=>{const{offsetTop:s,offsetHeight:a}=e,o=s-n;return-a<=o&&o<=(t?60:10)}))}(e,n);s&&s.classList.add("stuck"),document.body.classList.remove("is-scrolling-messages")}))}))}),[t,s])}}(),he=(0,o.sO)(),ge=(0,o.sO)(),pe=(0,o.I4)((()=>{if(te.current)return void(te.current=!1);he.current=!0;const n=z.current;ee.current||me(n,r),bn((()=>{he.current=!1,(0,C.T2)((()=>{n.parentElement&&(V.current=n.scrollHeight-n.scrollTop,"thread"===s&&H({chatId:e,threadId:t,scrollOffset:V.current}))}))}))}),[me,r,s,H,e,t]);(0,o.d4)((()=>{if(!("ResizeObserver"in window))return;const e=new ResizeObserver((([e])=>{e.target.offsetParent&&re(e.contentRect.height)}));return e.observe(z.current),()=>{e.disconnect()}}),[]);const{height:fe}=ct();(0,o.d4)((()=>{I&&(z.current.dataset.normalHeight=String(z.current.offsetHeight))}),[fe,I,f]),(0,o.d4)((()=>{if(!de||!u||k||T)return;if(w&&w[w.length-1]>=a.AE)return;const e=z.current;(!w||w.length{if(!w||!W.current)return;const e=W.current.filter((e=>w.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(K.current=t.id,Y.current=t.getBoundingClientRect().top)}),[w,E,oe,r]),(0,Kt.Z)((([e,t,s])=>{const n=z.current;W.current=Array.from(n.querySelectorAll(".message-list-item"));const o=w&&e&&w[w.length-1]!==e[e.length-1],i=(null==w?void 0:w[0])!==(null==e?void 0:e[0])&&(null==w?void 0:w.length)===a.hT/2+1,c=o&&!i,d=w&&ee.current===w[w.length-1],l=E&&c&&w&&w.length{n.parentElement&&n.parentElement.classList.remove("force-messages-scroll")}),500));const{scrollTop:u,scrollHeight:m,offsetHeight:h}=n,g=V.current,p=W.current[W.current.length-1];let f=g-(s||h);c&&(f-=p?p.offsetHeight:0);const I=E&&t&&f<=20;let v;if(c&&I&&!d&&(p&&(0,C.T2)((()=>{(0,ss.Z)(n,p,"end",20)})),v=m-h,V.current=Math.max(Math.ceil(m-v),h),!l))return;const y=void 0!==s&&s!==oe,Z=K.current&&n.querySelector(`#${K.current}`),P=!Z&&J.current&&n.querySelector(".unread-divider");if(I&&y){if((0,ss.N)())return;v=m-h}else Z?(ge.current&&(ge.current=!1,(0,ts.z)(n)),v=u+(Z.getBoundingClientRect().top-(Y.current||0))):v=P?Math.min(P.offsetTop-(r?60:10),m-g):m-g;(0,ts.Z)(n,Math.ceil(v)),ee.current||(te.current=!0,(0,C.T2)((()=>{te.current=!1}))),V.current=Math.max(Math.ceil(m-v),h)}),[w,E,oe,r]),(0,Yt.Z)((([e])=>{void 0!==e&&(0,se.YW)(200+a.fK)}),[N]);const Ie=(0,Ce.Z)(),ve=Boolean(e&&(0,d.YC)(e)),Ze=Boolean(!ve&&!h||v||y),Pe=Boolean(!Ze||h),we=(0,d.YC)(e)&&!v&&!P&&(!ce&&!B&&w&&(!W.current||0===W.current.length)||1===(null==w?void 0:w.length)&&"contactSignUp"===(null==b||null===(U=b[w[0]])||void 0===U||null===($=U.content.action)||void 0===$?void 0:$.type)||"contactSignUp"===(null==B||null===(D=B.content)||void 0===D||null===(q=D.action)||void 0===q?void 0:q.type)),be=p&&Z&&1===(null==w?void 0:w.length)&&"chatCreate"===(null==b||null===(Q=b[w[0]])||void 0===Q||null===(G=Q.content.action)||void 0===G?void 0:G.type),Se=(0,ne.Z)("MessageList custom-scroll",Pe&&"no-avatars",!f&&"no-composer","pinned"===s&&"type-pinned",F&&"with-bottom-shift",N&&"select-mode-active",le&&"scrolled",!I&&"is-animating");return o.ZP.createElement("div",{ref:z,className:Se,onScroll:pe,onMouseDown:Jt.q},k?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,R?R.text:"This is a private "+(h?"channel":"chat"))):A?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,(0,Ct.Z)(Ie(A),["br","emoji","links"]))):we?o.ZP.createElement(Cn,{userId:e}):!w||ce&&!be?w&&ce||B?o.ZP.createElement(Zn,{chatId:e,messageIds:w||[B.id],messageGroups:ce||Xt([B]),isViewportNewest:Boolean(E),isUnread:Boolean(S),withUsers:Ze,noAvatars:Pe,containerRef:z,anchorIdRef:K,memoUnreadDividerBeforeIdRef:J,memoFirstUnreadIdRef:X,threadId:t,type:s,isReady:I,isScrollingRef:he,isScrollPatchNeededRef:ge,threadTopMessageId:x,hasLinkedChat:L,isSchedule:!!ce&&"scheduled"===s,noAppearanceAnimation:!ce||!ae.current,onFabToggle:c,onNotchToggle:l}):o.ZP.createElement(Qe.Z,{color:"white"}):o.ZP.createElement(wn,{chatId:e,type:s,isChatWithSelf:v,isGroupChatJustCreated:be}))}))),En=(0,o.X$)((0,n.c$)((e=>{const t=(0,i.Bt)(e);if(!t)return{};const{chatId:s,threadId:n,type:a}=t,o=(0,i.Z1)(e,s);return{messageListType:a,unreadCount:o&&n===u._f&&"thread"===a?o.unreadCount:void 0}}))((({isShown:e,canPost:t,messageListType:s,unreadCount:a,withExtraShift:r})=>{const{focusNextReply:i}=(0,n.uC)(),c=(0,Ce.Z)(),d=(0,o.sO)(null),l=(0,o.I4)((()=>{if(e)if("thread"===s)i();else{const e=d.current.parentElement.querySelector(".MessageList"),t=e.querySelectorAll(".message-list-item"),s=t[t.length-1];if(!s)return;(0,ss.Z)(e,s,"end",20)}}),[e,s,i]),u=(0,ne.Z)("ScrollDownButton",e&&"revealed",!t&&"no-composer",r&&"with-extra-shift");return o.ZP.createElement("div",{ref:d,className:u},o.ZP.createElement("div",{className:"ScrollDownButton-inner"},o.ZP.createElement(Me.Z,{color:"secondary",round:!0,onClick:l,ariaLabel:c("AccDescrPageDown")},o.ZP.createElement("i",{className:"icon-arrow-down"})),Boolean(a)&&o.ZP.createElement("div",{className:"unread-count"},(0,ft.bi)(a))))})));var Mn=s(5723);const kn=1280,Rn=/\.[^/.]+$/;async function Tn(e,t,s,n){const o=URL.createObjectURL(t),{type:r,size:i}=t;let c,d;if(a.oG.has(r))if(s){const t=await(0,it.pt)(o),{width:s,height:a}=t;if(s>kn||a>kn||"image/jpeg"!==r){const t=await Ot(o,kn/Math.max(s,a),"image/jpeg");return URL.revokeObjectURL(o),Tn(e,await(0,it.gm)(t),!0,n)}"image/jpeg"===r&&(e=e.replace(Rn,".jpg")),c={width:s,height:a}}else d=o;else if(a.wG.has(r)){const{videoWidth:e,videoHeight:t,duration:s}=await(0,it.jj)(o);c={width:e,height:t,duration:s},d=await(0,it.ud)(o)}return{blobUrl:o,filename:e,mimeType:r,size:i,quick:c,previewBlobUrl:d,...n}}var Nn=s(6391);let Bn;function An(e){Bn.focus(),e.focus()}h.cj&&(Bn=document.createElement("input"),Bn.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(Bn));var xn=s(4784),Ln=s(2400),On=s(6389);const Fn={encoderPath:s.p+"c0155344d336103c2b6a0b28cc510750.js",reuseWorker:!0},Un={type:"audio/ogg"};let $n,Dn,qn;async function Qn(){return $n||($n=s.e(161).then(s.t.bind(s,1161,23)),Dn=(await $n).default,qn=new Dn(Fn)),$n}async function Gn(e){await async function(){await Qn(),await qn.start()}();const t=Date.now();let s;const n=[],a=[];qn.ondataavailable=e=>{n.push(e)};const o=function(t,s){const n=t.sourceNode,o=n.context.createAnalyser();o.fftSize=64,n.connect(o);const r=o.frequencyBinCount,i=new Uint8Array(r);let c=!1;return function t(){if(c)return;o.getByteFrequencyData(i);const s=i.reduce(((e,t)=>e+t),0)/r/255;(t=>{a.push(255*t),e(t)})(s<.1?0:s),requestAnimationFrame(t)}(),()=>{c=!0}}(qn);return{stop:()=>new Promise(((e,r)=>{qn.onstop=()=>{e({blob:new Blob(n,Un),duration:Math.round(((s||Date.now())-t)/1e3),waveform:a})},qn.onerror=r;const i=Math.max(0,t+1e3-Date.now());setTimeout((()=>{qn.stop(),o()}),i)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{qn.pause(),s=Date.now(),o()}),e)}}}const jn=["image/png","image/jpeg","image/gif"];function Hn(e){const{text:t,entities:s}=e||{};if(!t)return"";const n=(0,is.H)(t,s,void 0,void 0,!0);return Array.isArray(n)?n.join(""):n}let _n,zn;var Vn=s(3575),Kn=s(9295);const Yn=document.createElement("div"),Wn=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,Xn=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i;const Jn=(0,C.P2)((e=>e()),500,!0),ea=/^[\w@]{1,32}\s?/i,ta=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"DeleteMessageModal",!t);return s?o.ZP.createElement(s,e):void 0}));function sa(){return(sa=Object.assign||function(e){for(var t=1;t{const s=(0,o.sO)(!1),n=(0,o.I4)((()=>{if(s.current=!0,aa)return aa=!1,void e();na&&(clearTimeout(na),na=void 0),na=window.setTimeout((()=>{s.current&&e()}),200)}),[e]),a=(0,o.I4)((()=>{s.current=!1}),[]);return o.ZP.createElement(Me.Z,sa({},t,{onMouseEnter:h.$b?void 0:n,onMouseLeave:h.$b?void 0:a,onClick:h.$b?e:void 0}))})),ra=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"AttachMenu",!t);return s?o.ZP.createElement(s,e):void 0})),ia=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"SymbolMenu",!t);return s?o.ZP.createElement(s,e):void 0})),ca=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"InlineBotTooltip",!t);return s?o.ZP.createElement(s,e):void 0})),da=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"MentionTooltip",!t);return s?o.ZP.createElement(s,e):void 0})),la=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"CustomSendMenu",!t);return s?o.ZP.createElement(s,e):void 0})),ua=e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"StickerTooltip",!t);return s?o.ZP.createElement(s,e):void 0};var ma=s(9830);const ha=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"BotCommandTooltip",!t);return s?o.ZP.createElement(s,e):void 0}));var ga=s(6503);const pa=(0,o.X$)((0,n.c$)(((e,{messageId:t})=>{const{chatId:s}=(0,i.Bt)(e)||{};return s?{message:(0,i.hj)(e,s,t)}:{}}))((({isOpen:e,message:t,onClose:s})=>{const{clickInlineButton:a}=(0,n.uC)(),[r,i]=(0,ga.Z)(e,s),{isKeyboardSingleUse:c}=t||{},[d,l,u]=(0,ye.Z)(!0),m=()=>{u(),s()};if((0,o.d4)((()=>{l()}),[l,t]),t&&t.keyboardButtons)return o.ZP.createElement(He.Z,{isOpen:e||d,autoClose:c,positionX:"right",positionY:"bottom",onClose:m,className:"BotKeyboardMenu",onCloseAnimationEnd:m,onMouseEnter:h.$b?void 0:r,onMouseLeave:h.$b?void 0:i},o.ZP.createElement("div",{className:"content"},t.keyboardButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(Me.Z,{ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>a({button:e})},e.text))))))))})));var fa=s(3616),Ia=s(7891);const va=(0,o.X$)((0,n.c$)((e=>{const{chatId:t,threadId:s,type:n}=(0,i.Bt)(e)||{};if(!t||!s||!n)return{};const{currentUserId:a,forwardMessages:{fromChatId:o,toChatId:r,messageIds:c}}=e,l=(0,i.Yy)(e,t,s),u="scheduled"===n?(0,i.wU)(e,t):(0,i._$)(e,t,s),m=e.settings.byKey.animationLevel>=1,h=r===t;let g,p;if(l?g=(0,i.hj)(e,t,l):u?g=(0,i.kK)(e,t,s,n):h&&1===c.length&&(g=(0,i.hj)(e,o,c[0])),l&&g){const{forwardInfo:s}=g,n=t===a;s&&(s.isChannelPost||n)&&(p=(0,i.cv)(e,g)),p||(p=(0,i.Ur)(e,g))}else h&&(p=(0,d.YC)(o)?(0,i.dy)(e,o):(0,i.Z1)(e,o));return{replyingToId:l,editingId:u,message:g,sender:p,shouldAnimate:m,forwardedMessagesCount:h?c.length:void 0}}))((({replyingToId:e,editingId:t,message:s,sender:a,shouldAnimate:r,forwardedMessagesCount:i})=>{const{setReplyingToId:c,setEditingId:d,focusMessage:l,exitForwardMode:u}=(0,n.uC)(),m=Boolean((e||t)&&s||a&&i),h=(0,Ia.Z)([i],i?300:void 0),{shouldRender:g,transitionClassNames:p}=(0,ce.Z)(h&&m,void 0,!r,void 0,!r),f=(0,o.I4)((()=>{e?c({messageId:void 0}):t?d({messageId:void 0}):i&&u()}),[e,t,i,c,d,u]);(0,o.d4)((()=>m?(0,fe.Z)(f):void 0),[m,f]);const I=(0,o.I4)((()=>{l({chatId:s.chatId,messageId:s.id})}),[l,s]),v=(0,ne.Z)("ComposerEmbeddedMessage",p),y=i&&i>1?`${i} forwarded messages`:void 0;if(g)return o.ZP.createElement("div",{className:v},o.ZP.createElement("div",null,o.ZP.createElement(Me.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Cancel replying",onClick:f},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Ps,{className:"inside-input",message:s,sender:a,customText:y,title:t?"Edit Message":void 0,onClick:I})))}))),ya=(0,o.X$)((e=>{const{attachments:t}=e,s=(0,qe.Z)(De.gl.Extra,"AttachmentModal",!t.length);return s?o.ZP.createElement(s,e):void 0})),Za=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"BotCommandMenu",!t);return s?o.ZP.createElement(s,e):void 0})),Pa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"PollModal",!t);return s?o.ZP.createElement(s,e):void 0})),Ca=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"DropArea",!t);return s?o.ZP.createElement(s,e):void 0})),wa=new RegExp(a.FM,"i"),ba=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s})=>{const n=(0,i.tV)(e,t,s);return{theme:(0,i.Pu)(e),webPagePreview:e.webPagePreview,noWebPage:n}}))((({chatId:e,threadId:t,messageText:s,disabled:a,webPagePreview:r,noWebPage:i,theme:c})=>{const{loadWebPagePreview:d,clearWebPagePreview:l,toggleMessageWebPage:m}=(0,n.uC)(),h=(0,o.Ye)((()=>{const{text:e,entities:t}=(0,f.Z)(s),n=t&&t.find((({type:e})=>e===u.Vv.TextUrl));if(n)return n.url;const a=e.match(wa);return a?a[0]:void 0}),[s]);(0,o.d4)((()=>{h?d({text:h}):(l(),m({chatId:e,threadId:t}))}),[e,m,l,h,d,t]),(0,ue.Z)((()=>{l(),m({chatId:e,threadId:t})}),[e]);const g=Boolean(r&&s.length&&!i&&!a),{shouldRender:p,transitionClassNames:I}=(0,ce.Z)(g),v=(0,pt.Z)(r,!0);if(!p||!v)return;const{photo:y,...Z}=v,P={content:{webPage:Z}};return o.ZP.createElement("div",{className:(0,ne.Z)("WebPagePreview",I)},o.ZP.createElement("div",null,o.ZP.createElement(Me.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Clear Webpage Preview",onClick:()=>{m({chatId:e,threadId:t,noWebPage:!0})}},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Js,{message:P,inPreview:!0,theme:c})))})));var Sa=s(2898);const Ea=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"CalendarModal",!t);return s?o.ZP.createElement(s,e):void 0})),Ma=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"SendAsMenu",!t);return s?o.ZP.createElement(s,e):void 0}));var ka;!function(e){e.Send="send",e.Record="record",e.Edit="edit"}(ka||(ka={}));const Ra=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,messageListType:n})=>{var o,r,c,l;const m=(0,i.Z1)(e,t),h=m&&(0,i.Dg)(e,m),g=t!==a.FV?(0,i.IK)(e,t):void 0,p=Boolean(g),f=(0,i.FM)(e,t),I=p&&(0,i.FT)(e,t),v=(0,i.qy)(e,t),{language:y,shouldSuggestStickers:Z}=e.settings.byKey,P=e.emojiKeywords[a.pR],C=y!==a.pR?e.emojiKeywords[y]:void 0,w=I?I.id:void 0,b=w?(0,i.hj)(e,t,w):void 0,S=e.users.byId,E=e.chats.byId,{currentUserId:M}=e,k=null!=m&&m.fullInfo?(null==m||null===(o=m.fullInfo)||void 0===o?void 0:o.sendAsId)||M:void 0,R=k?null==S?void 0:S[k]:void 0,T=!R&&k?null==E?void 0:E[k]:void 0;return{editingMessage:(0,i.kK)(e,t,s,n),connectionState:e.connectionState,draft:(0,i.Ms)(e,t,s),chat:m,isChatWithBot:p,isChatWithSelf:f,canScheduleUntilOnline:Boolean(!f&&!p&&m&&h&&(0,d.YC)(t)&&(null===(r=(0,i.ss)(e,t))||void 0===r?void 0:r.wasOnline)),isRightColumnShown:(0,i.Jf)(e),isSelectModeActive:(0,i.CA)(e),withScheduledButton:s===u._f&&"thread"===n&&Boolean(null==v?void 0:v.length),shouldSchedule:"scheduled"===n,botKeyboardMessageId:w,botKeyboardPlaceholder:null==b?void 0:b.keyboardPlaceholder,isForwarding:t===e.forwardMessages.toChatId,isPollModalOpen:e.isPollModalOpen,stickersForEmoji:e.stickers.forEmoji.stickers,groupChatMembers:null==m||null===(c=m.fullInfo)||void 0===c?void 0:c.members,topInlineBotIds:null===(l=e.topInlineBots)||void 0===l?void 0:l.userIds,currentUserId:M,usersById:S,lastSyncTime:e.lastSyncTime,contentToBeScheduled:e.messages.contentToBeScheduled,shouldSuggestStickers:Z,recentEmojis:e.recentEmojis,baseEmojiKeywords:null==P?void 0:P.keywords,emojiKeywords:null==C?void 0:C.keywords,serverTimeOffset:e.serverTimeOffset,inlineBots:e.inlineBots.byUsername,isInlineBotLoading:e.inlineBots.isLoading,chatBotCommands:m&&m.fullInfo&&m.fullInfo.botCommands,botCommands:g&&g.fullInfo?g.fullInfo.botCommands||!1:void 0,sendAsUser:R,sendAsChat:T,sendAsId:k}}))((({dropAreaState:e,shouldSchedule:t,canScheduleUntilOnline:s,isReady:r,onDropHide:i,editingMessage:c,chatId:l,threadId:m,messageListType:g,draft:I,chat:v,connectionState:y,isChatWithBot:Z,isChatWithSelf:P,isRightColumnShown:w,isSelectModeActive:b,isForwarding:S,isPollModalOpen:E,botKeyboardMessageId:M,botKeyboardPlaceholder:k,withScheduledButton:R,stickersForEmoji:T,groupChatMembers:B,topInlineBotIds:A,currentUserId:x,usersById:L,lastSyncTime:O,contentToBeScheduled:F,shouldSuggestStickers:U,baseEmojiKeywords:$,emojiKeywords:D,serverTimeOffset:q,recentEmojis:Q,inlineBots:G,isInlineBotLoading:j,botCommands:H,chatBotCommands:_,sendAsUser:z,sendAsChat:V,sendAsId:K})=>{const{sendMessage:Y,clearDraft:W,showDialog:X,setStickerSearchQuery:J,setGifSearchQuery:ee,forwardMessages:te,openPollModal:se,closePollModal:ae,loadScheduledHistory:oe,openChat:re,addRecentEmoji:ce,sendInlineBotResult:me,loadSendAs:he}=(0,n.uC)(),ge=(0,Ce.Z)(),pe=(0,o.sO)(null),[Ie,ve]=(0,o.eJ)(""),Ze=(0,o.sO)(),Pe=(0,lt.Z)(e),[we,be,Se]=(0,ye.Z)(),[Ee,ke]=(0,o.eJ)(),{width:Re}=ie.Z.get(),Te=null==v?void 0:v.sendAsIds,Ne=(0,On.Z)(l,m),Be=(0,o.sO)(Ie);(0,o.d4)((()=>{Be.current=Ie}),[Ie]),(0,o.d4)((()=>{Ze.current=void 0}),[l]),(0,o.d4)((()=>{l&&O&&m===u._f&&r&&oe({chatId:l})}),[r,l,oe,O,m]),(0,o.d4)((()=>{l&&v&&O&&!Te&&r&&(0,d.ZV)(v)&&he({chatId:l})}),[v,l,r,O,he,Te]);const xe=(0,o.sO)(!1);(0,ue.Z)((([e,t])=>{xe.current=Boolean(l===e&&Te&&!t)}),[l,Te]),(0,o.bt)((()=>{pe.current&&(pe.current.innerHTML='')}),[]),(0,o.d4)((()=>{F&&(ke(F),be())}),[F,be]);const[Le,Oe]=(0,o.eJ)([]),[Fe,Ue,$e]=(0,ye.Z)(),[De,qe,Qe]=(0,ye.Z)(),[Ge,je,He]=(0,ye.Z)(),[_e,ze,Ve]=(0,ye.Z)(),[Ke,Ye,We]=(0,ye.Z)(),[Xe,Je,et]=(0,ye.Z)(),[tt,st]=(0,ye.Z)(),[nt,ot,rt]=(0,ye.Z)(),{startRecordingVoice:it,stopRecordingVoice:ct,pauseRecordingVoice:dt,activeVoiceRecording:ut,currentRecordTime:mt,recordButtonRef:ht,startRecordTimeRef:gt}=(()=>{const e=(0,o.sO)(null),[t,s]=(0,o.eJ)(),n=(0,o.sO)(),[a,r]=(0,o.eJ)();(0,o.d4)((()=>{h.s$&&h.mh&&Qn()}),[]);const i=(0,o.I4)((async()=>{try{const{stop:t,pause:a}=await Gn((t=>{e.current&&(n.current&&Date.now()%4==0&&(e.current.style.boxShadow=`0 0 0 ${50*(t||0)}px rgba(0,0,0,.15)`),r(Date.now()))}));n.current=Date.now(),r(Date.now()),s({stop:t,pause:a})}catch(e){console.error(e)}}),[]),c=(0,o.I4)((()=>{if(t){e.current&&(e.current.style.boxShadow="none");try{return t.pause()}catch(e){return void console.error(e)}}}),[t]),d=(0,o.I4)((()=>{if(t){s(void 0),n.current=void 0,r(void 0),e.current&&(e.current.style.boxShadow="none");try{return t.stop()}catch(e){return void console.error(e)}}}),[t]);return(0,o.d4)((()=>t?(0,fe.Z)(d):void 0),[t,d]),{startRecordingVoice:i,pauseRecordingVoice:c,stopRecordingVoice:d,activeVoiceRecording:t,currentRecordTime:a,recordButtonRef:e,startRecordTimeRef:n}})();(function(e,t,s=!1){const n=(0,o.sO)(e);(0,o.bt)((()=>{n.current=e}),[e]),(0,o.d4)((()=>{if(void 0===t)return;const e=setInterval((()=>n.current()),t);return s||n.current(),()=>clearInterval(e)}),[t,s])})((()=>{Ne({type:"recordAudio"})}),ut&&a.o_),(0,o.d4)((()=>{ut||Ne({type:"cancel"})}),[ut,Ne]);const pt=c?ka.Edit:!h.mh||ut||Ie&&!Le.length||S?ka.Send:ka.Record,ft=!t,{isMentionTooltipOpen:It,closeMentionTooltip:vt,insertMention:yt,mentionFilteredUsers:Zt}=(0,Kn.Z)(!Le.length,Ie,ve,void 0,B,A,x),{isOpen:Pt,id:wt,isGallery:bt,switchPm:St,results:Et,closeTooltip:Mt,help:kt,loadMore:Rt}=function(e,t,s,a){const[r,i,c]=(0,ye.Z)(),d=function(e){return Yn.innerHTML=e.replace(/
/g,"\n"),Yn.innerText}(s),{queryInlineBot:l,resetInlineBot:u}=(0,n.uC)(),{username:m,query:h,canShowHelp:g}=function(e){const t=e.match(Wn);return t?{username:t[1],query:t[2],canShowHelp:""===t[2]&&!e.match(Xn)}:{username:"",query:"",canShowHelp:!1}}(d),p=m.toLowerCase(),f=(0,lt.Z)(h),I=(0,lt.Z)(m),v=null==a?void 0:a[p],{id:y,switchPm:Z,offset:P,results:C,isGallery:w,help:b}=v||{};(0,o.d4)((()=>{f!==h&&c()}),[f,h,c]),(0,o.d4)((()=>{e&&p&&t&&l({chatId:t,username:p,query:h})}),[h,e,l,t,p]);const S=(0,o.I4)((()=>{l({chatId:t,username:p,query:h,offset:P})}),[P,t,h,l,p]);return(0,o.d4)((()=>{e&&y&&(Z||null!=C&&C.length)?i():c()}),[y,e,i,C,Z,c]),I!==m&&u({username:I}),{isOpen:r,closeTooltip:c,loadMore:S,username:m,id:y,isGallery:w,switchPm:Z,results:C,help:g&&b?`@${m} ${b}`:void 0}}(Boolean(!Le.length&&O),l,Ie,G),{isOpen:Tt,close:Nt,filteredBotCommands:Bt}=function(e,t,s,n){const[a,r,i]=(0,ye.Z)(),[c,d]=(0,o.eJ)(),l=(0,o.I4)((e=>{s||n?Jn((()=>{const t=(s||n||[]).filter((({command:t})=>!e||t.includes(e)));d(t&&t.length?t:void 0)})):d(void 0)}),[s,n]);return(0,o.d4)((()=>{if(e&&t.length)if(t.startsWith("/")){const e=(0,Ln._)(t.substr(1)).match(ea);l(e?e[0]:"")}else i();else i()}),[l,t,e,i]),(0,o.d4)((()=>{c&&c.length?r():i()}),[c,r,i]),{isOpen:a,close:i,filteredBotCommands:c}}(Boolean(H&&H.length||_&&_.length),Ie,H,_),{isContextMenuOpen:At,handleContextMenu:xt,handleContextMenuClose:Lt,handleContextMenuHide:Ot}=(0,rs.Z)(ht,!(pt===ka.Send&&ft)),Ft=(0,o.Ye)((()=>(0,d.H5)(v,Z)),[v,Z]),Ut=v&&(0,d.Nl)(v),$t=(0,d.Hd)(v),{isStickerTooltipOpen:Dt,closeStickerTooltip:qt}=function(e,t,s,a=!1){const r=(0,o.Ye)((()=>(0,Ln._)(t).trim()),[t]),{loadStickersForEmoji:i,clearStickersForEmoji:c}=(0,n.uC)(),d=h.op&&1===(0,xn.Z)(r)||!h.op&&Boolean(t.match(/^]*?>$/g)),l=Boolean(s)&&d;return(0,o.d4)((()=>{var t;a||(e&&d?i({emoji:h.op?r:null===(t=r.match(/alt="(.+)"/))||void 0===t?void 0:t[1]}):!l&&d||c())}),[t,d,c,i,e,a]),{isStickerTooltipOpen:l,closeStickerTooltip:c}}(Boolean(U&&Ft.canSendStickers&&!Le.length),Ie,T,!r),{isEmojiTooltipOpen:Qt,closeEmojiTooltip:Gt,filteredEmojis:jt,insertEmoji:Ht}=(0,Vn.Z)(Boolean(U&&Ft.canSendStickers&&!Le.length),Ie,Q,void 0,ve,$,D,!r),zt=(0,o.I4)(((e,t=a.R2)=>{const s=window.getSelection(),n=document.getElementById(t),o=(0,Ct.Z)(e,["escape_html","emoji_html","br_html"]).join("").replace(/\u200b+/g,"​");if(s.rangeCount){const e=s.getRangeAt(0);if((0,Nn.R)(e,t))return function(e){const t=window.getSelection();if(null!=t&&t.getRangeAt&&t.rangeCount){const s=t.getRangeAt(0);s.deleteContents();const n=s.createContextualFragment(e),a=n.lastChild;s.insertNode(n),a?(s.setStartAfter(a),s.setEndAfter(a)):s.collapse(!1),t.removeAllRanges(),t.addRange(s)}}(o),void n.dispatchEvent(new Event("input",{bubbles:!0}))}ve(`${Be.current}${o}`),requestAnimationFrame((()=>{(0,Mn.Z)(n)}))}),[]),Vt=(0,o.I4)((()=>{const e=window.getSelection();if(e.rangeCount){const t=e.getRangeAt(0);if((0,Nn.R)(t,a.R2))return void document.execCommand("delete",!1)}ve(function(e){const t=document.createElement("div");t.contentEditable="true",t.style.position="absolute",t.style.left="-10000px",t.style.top="-10000px",t.innerHTML=e,document.body.appendChild(t);let s=t.lastChild;if(s.lastChild)for(;s.lastChild;)s=s.lastChild;const n=s.textContent.length,a=document.createRange(),o=window.getSelection();a.setStart(s,n),a.setEnd(s,n),o.removeAllRanges(),o.addRange(a),document.execCommand("delete",!1);const r=t.innerHTML;return document.body.removeChild(t),r}(Be.current))}),[]),Kt=(0,o.I4)(((e=!1)=>{e||ve(""),Oe([]),qt(),Se(),ke(void 0),vt(),Gt(),h.wB?setTimeout((()=>Ve()),350):Ve()}),[qt,Se,vt,Gt,Ve]),Yt=(0,o.sO)();Yt.current=ct,(0,o.d4)((()=>()=>{Yt.current(),Kt()}),[l,Kt,Yt]);const Wt=((e,t,s,r,i)=>{const{editMessage:c}=(0,n.uC)();return(0,o.d4)((()=>{s?(t(Hn(s.content.text)),requestAnimationFrame((()=>{const e=document.getElementById(a.R2);(0,Mn.Z)(e,!0)}))):t("")}),[s,t]),(0,o.I4)((()=>{const{text:t,entities:n}=(0,f.Z)(e.current);s&&(t||(0,d.u8)(s)?(c({messageId:s.id,text:t,entities:n}),r()):i())}),[c,s,e,i,r])})(Be,ve,c,Kt,Je);((e,t,s,r,i,c,d)=>{const{saveDraft:l,clearDraft:u}=(0,n.uC)(),m=(0,o.I4)(((e,t)=>{i.current.length&&!d?l({chatId:e,threadId:t,draft:(0,f.Z)(i.current)}):u({chatId:e,threadId:t})}),[u,d,i,l]),g=(0,o.Ye)((()=>(0,C.Ds)((e=>e()),a.r_,!1)),[t]),p=(0,lt.Z)(t),I=(0,lt.Z)(s);(0,o.d4)((()=>(_n=t,zn=s,()=>{_n=void 0,zn=void 0,m(t,s)})),[t,s,m]),(0,o.d4)((()=>{t===p&&s===I||e&&(c(Hn(e)),h.$b||requestAnimationFrame((()=>{const e=document.getElementById(a.R2);(0,Mn.Z)(e,!0)})))}),[t,s,e,c,m,p,I]);const v=(0,lt.Z)(r);(0,o.d4)((()=>{t&&s&&p===t&&I===s&&v!==r&&(r.length?g((()=>{_n===t&&zn===s&&m(t,s)})):m(t,s))}),[t,r,p,v,I,g,s,m]);const y=(0,o.I4)((()=>{t&&s&&m(t,s)}),[t,s,m]);(0,de.Z)(y),le(y)})(I,l,m,Ie,Be,ve,c),((e,t,s)=>{(0,o.d4)((()=>{async function n(n){if(!n.clipboardData)return;const o=document.activeElement;if(o&&![a.R2,a.nY].includes(o.id))return;const{items:r}=n.clipboardData,i=Array.from(r).find((e=>jn.includes(e.type)&&"file"===e.kind)),c=i&&i.getAsFile(),d=n.clipboardData.getData("text").substring(0,4096);if(n.preventDefault(),c||d){if(c&&!s){const e=await Tn(c.name,c,!0);t((t=>[...t,e]))}d&&e(d,null==o?void 0:o.id)}}return document.addEventListener("paste",n,!1),()=>{document.removeEventListener("paste",n,!1)}}),[e,s,t])})(zt,Oe,c);const Xt=(0,o.I4)((async(e,t)=>{Oe(await Promise.all(e.map((e=>Tn(e.name,e,t)))))}),[]),Jt=(0,o.I4)((async(e,t)=>{Oe([...Le,...await Promise.all(e.map((e=>Tn(e.name,e,t))))])}),[Le]),es=(0,o.I4)((()=>{Oe([])}),[]),ts=(0,o.I4)((async(e=!1,t)=>{if("connectionStateReady"!==y)return;let s=Le;if(ut){const e=await ct();if(e){const{blob:t,duration:n,waveform:a}=e;s=[await Tn("wonderful-voice-message.ogg",t,!1,{voice:{duration:n,waveform:a}})]}}const{text:n,entities:o}=(0,f.Z)(Be.current);if(!s.length&&!n&&!S)return;const r=s.length?1024:4096;if((null==n?void 0:n.length)>r){const e=n.length-r;return void X({data:{message:"MESSAGE_TOO_LONG_PLEASE_REMOVE_CHARACTERS",textParams:{"{EXTRA_CHARS_COUNT}":e,"{PLURAL_S}":e>1?"s":""},hasErrorKey:!0}})}const i=document.getElementById(a.R2);if(s.length||n){if($t&&!Ut){const e=(0,p.b)(q),t=Ze.current&&Math.floor(e-Ze.current),s=$t.nextSendDate&&$t.nextSendDate>e;if(t&&t<$t.seconds||s){const n=s?$t.nextSendDate-e:$t.seconds-t;return X({data:{message:ge("SlowModeHint",(0,N.k9)(n)),isSlowMode:!0,hasErrorKey:!1}}),void i.blur()}}Y({text:n,entities:o,attachments:s,scheduledAt:t,isSilent:e})}S&&te({scheduledAt:t,isSilent:e}),Ze.current=(0,p.b)(q),W({chatId:l,localOnly:!0}),h.cj&&i===document.activeElement&&An(i),requestAnimationFrame((()=>{Kt()}))}),[y,Le,ut,S,W,l,q,Kt,ct,X,$t,Ut,Y,te,ge]),ss=(0,o.I4)((()=>{Ve(),qe()}),[Ve,qe]),ns=(0,o.I4)((()=>{Qe(),We(),ze()}),[Qe,We,ze]),as=(0,o.I4)(((e,s=!1)=>{e={...e,isPreloadedGlobally:!0},t?(ke({sticker:e}),be()):(Y({sticker:e}),requestAnimationFrame((()=>{Kt(s)})))}),[t,be,Y,Kt]),os=(0,o.I4)((e=>{t?(ke({gif:e}),be()):(Y({gif:e}),requestAnimationFrame((()=>{Kt(!0)})))}),[t,be,Y,Kt]),is=(0,o.I4)((e=>{if("connectionStateReady"!==y)return;me({id:e.id,queryId:e.queryId});const t=document.getElementById(a.R2);h.cj&&t===document.activeElement&&An(t),W({chatId:l,localOnly:!0}),requestAnimationFrame((()=>{Kt()}))}),[l,W,y,Kt,me]),cs=(0,o.I4)((()=>{W({chatId:l,localOnly:!0}),requestAnimationFrame((()=>{Kt()}))}),[l,W,Kt]),ds=(0,o.I4)((e=>{t?(ke({poll:e}),ae(),be()):(Y({poll:e}),ae())}),[ae,be,Y,t]),ls=(0,o.I4)((()=>{t?(ke({isSilent:!0}),be()):ts(!0)}),[ts,be,t]),us=(0,o.I4)(((e,t=!1)=>{const{isSilent:s,...n}=Ee||{},a=Math.round(Math.max(e.getTime(),Date.now()+6e4)/1e3)+(t?0:q);Ee&&0!==Object.keys(n).length?(Y({...Ee,scheduledAt:a}),requestAnimationFrame((()=>{Kt()}))):ts(!!s,a),Se()}),[Se,ts,Kt,Ee,Y,q]),ms=(0,o.I4)((()=>{us(new Date(1e3*a.t4),!0)}),[us]),hs=(0,o.I4)((()=>{Se(),ke(void 0)}),[Se]),gs=(0,o.I4)((e=>{"stickers"===e?(J({query:""}),ee({query:void 0})):(ee({query:""}),J({query:void 0}))}),[J,ee]),ps=(0,o.I4)((()=>{const e=document.getElementById(a.R2);h.wB&&e===document.activeElement?(e.blur(),setTimeout((()=>{Qe(),ze()}),100)):ze()}),[ze,Qe]),fs=(0,o.I4)((()=>{const e=document.getElementById(a.R2);if(!h.wB||e!==document.activeElement)return Qe(),Ve(),void Ye();e.blur(),setTimeout((()=>{Qe(),Ve(),Ye()}),100)}),[Qe,Ve,Ye]),Is=(0,o.I4)((()=>{re({id:l,threadId:m,type:"scheduled"})}),[re,l,m]);(0,o.d4)((()=>{w&&h.wB&&Ve()}),[w,Ve]),(0,o.d4)((()=>{r&&(b?ot():setTimeout((()=>{rt()}),200))}),[b,rt,ot,r]);const vs=(0,o.I4)((()=>{switch(pt){case ka.Send:t?(ut&&dt(),be()):ts();break;case ka.Record:it();break;case ka.Edit:Wt()}}),[pt,t,it,Wt,ut,be,dt,ts]),ys=pt===ka.Record&&!Ft.canAttachMedia,Zs=(0,lt.Z)(c,!0),Ps=c||Zs,Cs=new Date;Cs.setSeconds(0),Cs.setMilliseconds(0);const ws=new Date;ws.setFullYear(ws.getFullYear()+1);let bs="SendMessage";switch(pt){case ka.Edit:bs="Save edited message";break;case ka.Record:bs=ys?"Conversation.DefaultRestrictedMedia":"AccDescrVoiceMessage"}const Ss=(0,ne.Z)("Composer",!b&&"shown",nt&&"hover-disabled"),Es=(0,ne.Z)("mobile-symbol-menu-button",!r&&"not-ready",tt?_e&&"menu-opened":_e&&"is-loading"),Ms=pt===ka.Edit?Wt:t?be:ts;return o.ZP.createElement("div",{className:Ss},Ft.canAttachMedia&&r&&o.ZP.createElement(Sa.Z,{containerId:"#middle-column-portals"},o.ZP.createElement(Ca,{isOpen:e!==at.t.None,withQuick:[e,Pe].includes(at.t.QuickFile),onHide:i,onFileSelect:Xt})),o.ZP.createElement(ya,{chatId:l,threadId:m,attachments:Le,caption:Le.length?Ie:"",groupChatMembers:B,currentUserId:x,usersById:L,recentEmojis:Q,isReady:r,onCaptionUpdate:ve,baseEmojiKeywords:$,emojiKeywords:D,addRecentEmoji:ce,onSend:t?be:ts,onFileAppend:Jt,onClear:es}),o.ZP.createElement(Pa,{isOpen:Boolean(E),onClear:ae,onSend:ds}),Ps&&o.ZP.createElement(ta,{isOpen:Xe,isSchedule:"scheduled"===g,onClose:et,message:Ps}),o.ZP.createElement(Ma,{isOpen:Ke,onClose:We,chatId:l,selectedSendAsId:K,sendAsIds:Te}),o.ZP.createElement(da,{isOpen:It,onClose:vt,onInsertUserName:yt,filteredUsers:Zt,usersById:L}),o.ZP.createElement(ca,{isOpen:Pt,botId:wt,allowedAttachmentOptions:Ft,isGallery:bt,inlineBotResults:Et,switchPm:St,onSelectResult:is,loadMore:Rt,onClose:Mt}),o.ZP.createElement(ha,{isOpen:Tt,withUsername:Boolean(_),botCommands:Bt,onClick:cs,onClose:Nt}),o.ZP.createElement("div",{id:"message-compose"},o.ZP.createElement("div",{className:"svg-appendix",ref:pe}),o.ZP.createElement(va,null),o.ZP.createElement(ba,{chatId:l,threadId:m,messageText:Le.length?"":Ie,disabled:!Ft.canAttachEmbedLinks}),o.ZP.createElement("div",{className:"message-input-wrapper"},Z&&!1!==H&&!ut&&!c&&o.ZP.createElement(oa,{className:(0,ne.Z)("bot-commands",De&&"activated"),round:!0,disabled:void 0===H,color:"translucent",onActivate:ss,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-commands-filled"})),!(null==Te||!Te.length)&&(z||V)&&o.ZP.createElement(Me.Z,{round:!0,color:"translucent",onClick:Ke?We:fs,ariaLabel:ge("SendMessageAsTitle"),className:(0,ne.Z)("send-as-button",xe.current&&"appear-animation")},o.ZP.createElement(_t.Z,{user:z,chat:V,size:"tiny"})),h.wB?o.ZP.createElement(Me.Z,{className:Es,round:!0,color:"translucent",onClick:_e?Ve:ps,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"}),o.ZP.createElement("i",{className:"icon-keyboard"}),_e&&!tt&&o.ZP.createElement(Ae.Z,{color:"gray"})):o.ZP.createElement(oa,{className:_e?"activated":"",round:!0,color:"translucent",onActivate:ns,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"})),o.ZP.createElement(fa.Z,{id:"message-input-text",chatId:l,threadId:m,html:Le.length?"":Ie,placeholder:ut&&Re<=600?"":k||ge("Message"),forcedPlaceholder:kt,canAutoFocus:r&&!Le.length,shouldSuppressFocus:h.wB&&_e,shouldSuppressTextFormatter:Qt||It||Pt,onUpdate:ve,onSend:Ms,onSuppressedFocus:Ve}),j&&Boolean(wt)&&o.ZP.createElement(Ae.Z,{color:"gray"}),R&&o.ZP.createElement(Me.Z,{round:!0,faded:!0,className:"scheduled-button",color:"translucent",onClick:Is,ariaLabel:"Open scheduled messages"},o.ZP.createElement("i",{className:"icon-schedule"})),M&&!ut&&!c&&o.ZP.createElement(oa,{className:Fe?"activated":"",round:!0,color:"translucent",onActivate:Ue,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-command"})),!ut&&!c&&o.ZP.createElement(oa,{className:Ge?"activated":"",round:!0,color:"translucent",onActivate:je,ariaLabel:"Add an attachment"},o.ZP.createElement("i",{className:"icon-attach"})),ut&&mt&&o.ZP.createElement("span",{className:"recording-state"},(0,N.rM)(mt-gt.current)),o.ZP.createElement(ua,{chatId:l,threadId:m,isOpen:Dt,onStickerSelect:as}),o.ZP.createElement(ma.Z,{isOpen:Qt,emojis:jt,onClose:Gt,onEmojiSelect:Ht,addRecentEmoji:ce}),o.ZP.createElement(ra,{isOpen:Ge,allowedAttachmentOptions:Ft,onFileSelect:Xt,onPollCreate:se,onClose:He}),M&&o.ZP.createElement(pa,{messageId:M,isOpen:Fe,onClose:$e}),H&&o.ZP.createElement(Za,{isOpen:De,botCommands:H,onClose:Qe}),o.ZP.createElement(ia,{chatId:l,threadId:m,isOpen:_e,allowedAttachmentOptions:Ft,onLoad:st,onClose:Ve,onEmojiSelect:zt,onStickerSelect:as,onGifSelect:os,onRemoveSymbol:Vt,onSearchOpen:gs,addRecentEmoji:ce}))),ut&&o.ZP.createElement(Me.Z,{round:!0,color:"danger",className:"cancel",onClick:ct,ariaLabel:"Cancel voice recording"},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(Me.Z,{ref:ht,round:!0,color:"secondary",className:(0,ne.Z)(pt,!r&&"not-ready",ut&&"recording"),disabled:ys,ariaLabel:ge(bs),onClick:vs,onContextMenu:pt===ka.Send&&ft?xt:void 0},o.ZP.createElement("i",{className:"icon-send"}),o.ZP.createElement("i",{className:"icon-microphone-alt"}),o.ZP.createElement("i",{className:"icon-check"})),ft&&o.ZP.createElement(la,{isOpen:At,onSilentSend:P?void 0:ls,onScheduleSend:t?void 0:be,onClose:Lt,onCloseAnimationEnd:Ot}),o.ZP.createElement(Ea,{isOpen:we,withTimePicker:!0,selectedAt:Cs.getTime(),maxAt:(0,N._F)(ws),isFutureMode:!0,secondButtonLabel:s?ge("Schedule.SendWhenOnline"):void 0,onClose:hs,onSubmit:us,onSecondButtonClick:s?ms:void 0}))}))),Ta=(0,o.X$)((e=>{const{isActive:t}=e,s=(0,qe.Z)(De.gl.Extra,"MobileSearch",!t,!0);return s?o.ZP.createElement(s,e):void 0})),Na=(0,o.X$)((e=>{const{isActive:t}=e,s=(0,qe.Z)(De.gl.Extra,"MessageSelectToolbar",!t);return s?o.ZP.createElement(s,e):void 0})),Ba=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"UnpinAllMessagesModal",!t);return s?o.ZP.createElement(s,e):void 0})),Aa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"PaymentModal",!t);return s?o.ZP.createElement(s,e):void 0})),xa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"ReceiptModal",!t);return s?o.ZP.createElement(s,e):void 0})),La=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"SeenByModal",!t);return s?o.ZP.createElement(s,e):void 0})),Oa=h.wB?450+a.fK:void 0;function Fa(e){return"file"===e.kind&&e.type&&a.oG.has(e.type)}const Ua=(0,o.X$)((0,n.c$)((e=>{const t=(0,i.Pu)(e),{isBlurred:s,background:n,backgroundColor:a,patternColor:o}=e.settings.themes[t]||{},{messageLists:r}=e.messages,c=(0,i.Bt)(e),{isLeftColumnShown:l,chats:{listIds:m}}=e,g={theme:t,customBackground:n,backgroundColor:a,patternColor:o,isLeftColumnShown:l,isRightColumnShown:(0,i.Jf)(e),isBackgroundBlurred:s,isMobileSearchActive:Boolean(h.wB&&(0,i.n5)(e)),isSelectModeActive:(0,i.CA)(e),isPaymentModalOpen:e.payment.isPaymentModalOpen,isReceiptModalOpen:Boolean(e.payment.receipt),isSeenByModalOpen:Boolean(e.seenByModal),animationLevel:e.settings.byKey.animationLevel,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1)};if(!c||!m.active)return g;const{chatId:p,threadId:f,type:I}=c,v=(0,i.Z1)(e,p),y=(0,i.IK)(e,p),Z=(0,i.KB)(e,p),{chatId:P,messageId:C}=e.audioPlayer,w=v&&(0,d.Qm)(v,f),b=(0,i.pk)(e,p),S="pinned"===I,E="scheduled"===I,M="thread"===I&&f===u._f,k=Boolean(v&&(0,d.eA)(v)),R=Boolean(v&&M&&(k||(0,d.ZV)(v))&&v.isNotJoined),T=Boolean(y&&(0,i.s4)(e,y.id)),N=!T&&b;return{...g,chatId:p,threadId:f,messageListType:I,isPrivate:(0,d.YC)(p),canPost:!S&&(!v||w)&&!b,isPinnedMessageList:S,isScheduledMessageList:E,currentUserBannedRights:null==v?void 0:v.currentUserBannedRights,defaultBannedRights:null==v?void 0:v.defaultBannedRights,hasPinnedOrAudioPlayer:f!==u._f||Boolean(!S&&(null==Z?void 0:Z.length))||Boolean(P&&C),pinnedMessagesCount:Z?Z.length:0,shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,messageLists:r,isChannel:k,canSubscribe:R,canStartBot:N,canRestartBot:T}}))((({chatId:e,threadId:t,messageListType:s,isPrivate:r,isPinnedMessageList:i,messageLists:c,canPost:l,currentUserBannedRights:u,defaultBannedRights:m,hasPinnedOrAudioPlayer:g,pinnedMessagesCount:p,customBackground:f,theme:I,backgroundColor:v,patternColor:y,isLeftColumnShown:Z,isRightColumnShown:P,isBackgroundBlurred:C,isMobileSearchActive:w,isSelectModeActive:b,isPaymentModalOpen:S,isReceiptModalOpen:E,isSeenByModalOpen:M,animationLevel:k,shouldSkipHistoryAnimations:R,currentTransitionKey:T,isChannel:N,canSubscribe:B,canStartBot:A,canRestartBot:x})=>{const{openChat:L,unpinAllMessages:O,loadUser:F,closeLocalTextSearch:U,exitMessageSelectMode:$,closePaymentModal:D,clearReceipt:q,joinChannel:Q,sendBotCommand:G,restartBot:j}=(0,n.uC)(),{width:H}=ct(),_=(0,Ce.Z)(),[z,V]=(0,o.eJ)(at.t.None),[K,Y]=(0,o.eJ)(),[W,X]=(0,o.eJ)(),[J,ee]=(0,o.eJ)(!1),te=g&&(Ha._m&&H=a.ks&&H{e===a.oB&&i(!0)}),[e]),{isReady:r&&!d,handleOpenEnd:e!==a.oB?function(e){"transform"===e.propertyName&&e.target===e.currentTarget&&i(Boolean(n))}:void 0,handleSlideStop:e!==a.oB?function(){i(!0)}:void 0}}(k,T,ge,e);(0,o.d4)((()=>e?(0,fe.Z)((()=>{L({id:void 0})})):void 0),[e,L]),(0,ue.Z)((()=>{V(at.t.None),Y(void 0),X(void 0)}),[e]),(0,o.d4)((()=>{const{visualViewport:e}=window;if(!e)return;const t=()=>{window.visualViewport.height!==document.documentElement.clientHeight?document.body.classList.add("keyboard-visible"):document.body.classList.remove("keyboard-visible")};return e.addEventListener("resize",t),()=>{e.removeEventListener("resize",t)}}),[]),(0,o.d4)((()=>{r&&F({userId:e})}),[e,r,F]);const we=(0,o.I4)((e=>{if(h.$b)return;const{items:t}=e.dataTransfer||{},s=t&&Array.from(t).filter((e=>"text/uri-list"!==e.type)).every(Fa);V(s?at.t.QuickFile:at.t.Document)}),[]),be=(0,o.I4)((()=>{V(at.t.None)}),[]),Se=(0,o.I4)((()=>{ee(!0)}),[]),Ee=(0,o.I4)((()=>{ee(!1)}),[]),ke=(0,o.I4)((()=>{O({chatId:e}),Ee(),L({id:e})}),[O,L,Ee,e]),Re=(0,o.I4)((()=>{L({id:e})}),[L,e]),Te=(0,o.I4)((()=>{Q({chatId:e})}),[Q,e]),Ne=(0,o.I4)((()=>{G({command:"/start"})}),[G]),Be=(0,o.I4)((()=>{j({chatId:e})}),[e,j]),Ae=((e,t)=>{const[s,n]=(0,o.eJ)(t);return(0,o.d4)((()=>{t&&(t.startsWith("#")?n(t):rt.fetch(a.fo,e,rt.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,it.pt)(t).then((()=>{n(`url(${t})`)}))})))}),[t,e]),t?s:void 0})(I,f),xe=(0,ne.Z)(le&&"has-header-tools",f&&"custom-bg-image",v&&"custom-bg-color",f&&C&&"blurred",h.aZ?"mask-image-disabled":"mask-image-enabled"),Le=(0,ne.Z)("messaging-disabled",!b&&"shown"),Oe=(0,d.q8)(_,u,m),{composerHiddenScale:Fe,toolbarHiddenScale:Ue,composerTranslateX:$e,toolbarTranslateX:De,unpinHiddenScale:qe,toolbarForUnpinHiddenScale:Qe}=(0,o.Ye)((()=>function(e,t){const s=e<=a.l3?16:32,n=function(e){if(e>a._m){const t=Math.min(Math.max(.25*e,288),424),s=Math.min(.25*e,424);return Math.min(e-t-s,mt)}if(e>a.ks){const t=Math.min(Math.max(.4*e,288),424);return Math.min(e-t,mt)}return e>mt?mt:e}(e),o=e<=a.l3?54:64,r=t?n-s-o:n-s,i=e>a.l3?Math.min(n-s,512):n-s,c=i/r,d=r/i;return{composerHiddenScale:c,toolbarHiddenScale:d,composerTranslateX:t?o/2*d:0,toolbarTranslateX:t?o/2*-1*c:0,unpinHiddenScale:i/258,toolbarForUnpinHiddenScale:258/i}}(H,de)),[de,H]),Ge=(0,ne.Z)("middle-column-footer",!de&&"no-composer",de&&W&&!b&&"with-notch");(0,pe.ZP)(se&&ae,(()=>{L({id:void 0},{forceSyncOnIOs:!0})}),void 0,void 0,void 0,(null==c?void 0:c.map(ot.q))||[]),(0,pe.ZP)(w,U),(0,pe.ZP)(b,$);const je=Boolean(!i&&!de&&Oe),He=Boolean(ce||re||ie||i),_e=Boolean(je||b||i);return o.ZP.createElement("div",{id:"MiddleColumn",className:xe,onTransitionEnd:ye,style:`\n --composer-hidden-scale: ${Fe};\n --toolbar-hidden-scale: ${Ue};\n --unpin-hidden-scale: ${qe};\n --toolbar-unpin-hidden-scale: ${Qe};\n --composer-translate-x: ${$e}px;\n --toolbar-translate-x: ${De}px;\n --pattern-color: ${y};\n --theme-background-color:\n ${v||("dark"===I?a.It:a.p3)};\n `,onClick:h.p7&&Z?Re:void 0},o.ZP.createElement("div",{id:"middle-column-bg",style:Ae?`--custom-background: ${Ae}`:void 0}),o.ZP.createElement("div",{id:"middle-column-portals"}),se&&ae&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"messages-layout",onDragEnter:de?we:void 0},o.ZP.createElement(Vt,{chatId:se,threadId:ae,messageListType:oe,isReady:ve}),o.ZP.createElement(Ze.Z,{name:R?"none":k===a.zy?"slide":"fade",activeKey:T,shouldCleanup:!0,cleanupExceptionKey:Ie,onStop:Pe},(()=>o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Sn,{key:`${se}-${ae}-${oe}`,chatId:se,threadId:ae,type:oe,canPost:de,hasTools:le,onFabToggle:Y,onNotchToggle:X,isReady:ve,withBottomShift:He}),o.ZP.createElement("div",{className:Ge},de&&o.ZP.createElement(Ra,{chatId:se,threadId:ae,messageListType:oe,dropAreaState:z,onDropHide:be,isReady:ve}),i&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:_.isRtl?"rtl":void 0},o.ZP.createElement(Me.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:Se},o.ZP.createElement("i",{className:"icon-unpin"}),o.ZP.createElement("span",null,_("Chat.Pinned.UnpinAll",p,"i")))),je&&o.ZP.createElement("div",{className:Le},o.ZP.createElement("div",{className:"messaging-disabled-inner"},o.ZP.createElement("span",null,Oe))),h.wB&&re&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:_.isRtl?"rtl":void 0},o.ZP.createElement(Me.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Te},_(he?"ProfileJoinChannel":"ProfileJoinGroup"))),h.wB&&ie&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:_.isRtl?"rtl":void 0},o.ZP.createElement(Me.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Ne},_("BotStart"))),h.wB&&ce&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:_.isRtl?"rtl":void 0},o.ZP.createElement(Me.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Be},_("BotRestart"))),o.ZP.createElement(Na,{messageListType:oe,isActive:b,canPost:de}),o.ZP.createElement(Aa,{isOpen:Boolean(S),onClose:D}),o.ZP.createElement(xa,{isOpen:Boolean(E),onClose:q}),o.ZP.createElement(La,{isOpen:M}))))),o.ZP.createElement(En,{isShown:me,canPost:de,withExtraShift:_e})),h.wB&&o.ZP.createElement(Ta,{isActive:Boolean(w)})),e&&o.ZP.createElement(Ba,{isOpen:J,chatId:e,pinnedMessagesCount:p,onClose:Ee,onUnpin:ke}))}))),$a=(0,C.Ds)((e=>e()),200,!1);var Da;!function(e){e[e.Profile=0]="Profile",e[e.MemberList=1]="MemberList",e[e.SharedMedia=2]="SharedMedia",e[e.Search=3]="Search",e[e.Management=4]="Management",e[e.ManageInitial=5]="ManageInitial",e[e.ManageChannelSubscribers=6]="ManageChannelSubscribers",e[e.ManageChatAdministrators=7]="ManageChatAdministrators",e[e.ManageChatPrivacyType=8]="ManageChatPrivacyType",e[e.ManageDiscussion=9]="ManageDiscussion",e[e.ManageGroupPermissions=10]="ManageGroupPermissions",e[e.ManageGroupRemovedUsers=11]="ManageGroupRemovedUsers",e[e.ManageGroupUserPermissionsCreate=12]="ManageGroupUserPermissionsCreate",e[e.ManageGroupUserPermissions=13]="ManageGroupUserPermissions",e[e.ManageGroupRecentActions=14]="ManageGroupRecentActions",e[e.ManageGroupAdminRights=15]="ManageGroupAdminRights",e[e.ManageGroupNewAdminRights=16]="ManageGroupNewAdminRights",e[e.ManageGroupMembers=17]="ManageGroupMembers",e[e.ManageGroupAddAdmins=18]="ManageGroupAddAdmins",e[e.StickerSearch=19]="StickerSearch",e[e.GifSearch=20]="GifSearch",e[e.PollResults=21]="PollResults",e[e.AddingMembers=22]="AddingMembers"}(Da||(Da={}));const qa=(0,o.X$)((0,n.c$)(((e,{chatId:t,isProfile:s,isManagement:n})=>{const{query:a}=(0,i.n5)(e)||{},{query:o}=(0,i.y5)(e)||{},{query:r}=(0,i.yN)(e)||{},c=t?(0,i.Z1)(e,t):void 0,l=c&&(0,d.eA)(c),u=s&&t&&(0,d.YC)(t)?(0,i.dy)(e,t):void 0,m=u&&(0,d.kw)(u);return{canManage:Boolean(!n&&s&&!m&&c&&!(0,i.FM)(e,c.id)&&((0,d.YC)(c.id)||((0,d.Nl)(c)||c.isCreator)&&!c.isNotJoined)),canAddContact:m,isChannel:l,userId:null==u?void 0:u.id,messageSearchQuery:a,stickerSearchQuery:o,gifSearchQuery:r}}))((({isColumnOpen:e,isProfile:t,isSearch:s,isManagement:a,isStickerSearch:r,isGifSearch:i,isPollResults:c,isAddingChatMembers:d,profileState:l,managementScreen:u,canAddContact:g,userId:p,canManage:f,isChannel:I,onClose:v,messageSearchQuery:y,stickerSearchQuery:Z,gifSearchQuery:P,shouldSkipAnimation:C})=>{var w;const{setLocalTextSearchQuery:b,setStickerSearchQuery:S,setGifSearchQuery:E,searchTextMessagesLocal:M,toggleManagement:k,openHistoryCalendar:R,addContact:T}=(0,n.uC)(),B=(0,o.sO)(null),A=(0,o.I4)((e=>{b({query:e}),e.length&&$a(M)}),[M,b]),x=(0,o.I4)((e=>{S({query:e})}),[S]),L=(0,o.I4)((e=>{E({query:e})}),[E]),O=(0,o.I4)((()=>{T({userId:p})}),[T,p]),[F,U]=(0,o.eJ)(!e);(0,o.d4)((()=>{setTimeout((()=>{U(!e)}),300)}),[e]);const $=(0,Ce.Z)(),D=t?l===m.vi.Profile?Da.Profile:l===m.vi.SharedMedia?Da.SharedMedia:l===m.vi.MemberList?Da.MemberList:-1:s?Da.Search:c?Da.PollResults:r?Da.StickerSearch:i?Da.GifSearch:d?Da.AddingMembers:a?u===m.u1.Initial?Da.ManageInitial:u===m.u1.ChatPrivacyType?Da.ManageChatPrivacyType:u===m.u1.Discussion?Da.ManageDiscussion:u===m.u1.ChannelSubscribers?Da.ManageChannelSubscribers:u===m.u1.GroupPermissions?Da.ManageGroupPermissions:u===m.u1.ChatAdministrators?Da.ManageChatAdministrators:u===m.u1.GroupRemovedUsers?Da.ManageGroupRemovedUsers:u===m.u1.GroupUserPermissionsCreate?Da.ManageGroupUserPermissionsCreate:u===m.u1.GroupUserPermissions?Da.ManageGroupUserPermissions:u===m.u1.GroupRecentActions?Da.ManageGroupRecentActions:u===m.u1.ChatAdminRights?Da.ManageGroupAdminRights:u===m.u1.ChatNewAdminRights?Da.ManageGroupNewAdminRights:u===m.u1.GroupMembers?Da.ManageGroupMembers:u===m.u1.GroupAddAdmins?Da.ManageGroupAddAdmins:void 0:void 0,q=null!==(w=(0,pt.Z)(D,!0))&&void 0!==w?w:-1;function Q(){if(-1!==q)switch(q){case Da.PollResults:return o.ZP.createElement("h3",null,$("PollResults"));case Da.Search:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(ke.Z,{parentContainerClassName:"RightSearch",value:y,onChange:A}),o.ZP.createElement(Me.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>R({selectedAt:(0,N._F)(Date.now())}),ariaLabel:"Search messages by date"},o.ZP.createElement("i",{className:"icon-calendar"})));case Da.AddingMembers:return o.ZP.createElement("h3",null,$(I?"ChannelAddSubscribers":"GroupAddMembers"));case Da.ManageInitial:return o.ZP.createElement("h3",null,$("Edit"));case Da.ManageChatPrivacyType:return o.ZP.createElement("h3",null,$(I?"ChannelTypeHeader":"GroupTypeHeader"));case Da.ManageDiscussion:return o.ZP.createElement("h3",null,$("Discussion"));case Da.ManageChatAdministrators:return o.ZP.createElement("h3",null,$("ChannelAdministrators"));case Da.ManageGroupRecentActions:return o.ZP.createElement("h3",null,$("Group.Info.AdminLog"));case Da.ManageGroupAdminRights:return o.ZP.createElement("h3",null,$("EditAdminRights"));case Da.ManageGroupNewAdminRights:return o.ZP.createElement("h3",null,$("SetAsAdmin"));case Da.ManageGroupPermissions:return o.ZP.createElement("h3",null,$("ChannelPermissions"));case Da.ManageGroupRemovedUsers:return o.ZP.createElement("h3",null,$("ChannelBlockedUsers"));case Da.ManageGroupUserPermissionsCreate:return o.ZP.createElement("h3",null,$("ChannelAddException"));case Da.ManageGroupUserPermissions:return o.ZP.createElement("h3",null,$("UserRestrictions"));case Da.ManageGroupAddAdmins:return o.ZP.createElement("h3",null,$("Channel.Management.AddModerator"));case Da.StickerSearch:return o.ZP.createElement(ke.Z,{value:Z,placeholder:$("SearchStickersHint"),autoFocusSearch:!0,onChange:x});case Da.GifSearch:return o.ZP.createElement(ke.Z,{value:P,placeholder:$("SearchGifsTitle"),autoFocusSearch:!0,onChange:L});case Da.SharedMedia:return o.ZP.createElement("h3",null,$("SharedMedia"));case Da.ManageChannelSubscribers:return o.ZP.createElement("h3",null,$("ChannelSubscribers"));case Da.MemberList:case Da.ManageGroupMembers:return o.ZP.createElement("h3",null,$("GroupMembers"));default:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,"Profile"),o.ZP.createElement("section",{className:"tools"},g&&o.ZP.createElement(Me.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:$("AddContact"),onClick:O},o.ZP.createElement("i",{className:"icon-add-user"})),f&&o.ZP.createElement(Me.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:$("Edit"),onClick:k},o.ZP.createElement("i",{className:"icon-edit"}))))}}const G=h.wB||D===Da.SharedMedia||D===Da.MemberList||D===Da.AddingMembers||a,j=(0,ne.Z)("animated-close-icon",G&&"state-back",(F||C)&&"no-transition");return o.ZP.createElement("div",{className:"RightHeader"},o.ZP.createElement(Me.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:v,ariaLabel:$(G?"Common.Back":"Common.Close")},o.ZP.createElement("div",{ref:B,className:j})),o.ZP.createElement(Ze.Z,{name:F||C?"none":"slide-fade",activeKey:q},Q))})));var Qa=s(91),Ga=s(7407);function ja(e,t,s,n){const[o,r]=(0,Ga.Z)(s?t:void 0,n,void 0,a.Vk);return[o,r,!(!o||!n||o[0]===n[0])]}function Ha(e,t,s,n,r,i){const c=(0,o.sO)();(0,ue.Z)((()=>{t===e&&r&&i&&(c.current=(0,d.R5)(r,i,e).reverse())}),[r,i,t,e]);const[l,u]=(0,Ga.Z)(n?s:void 0,c.current,void 0,"media"===e?a.EN:a.pn);return[l,u,!(!l||!c.current||l[0]===c.current[0])]}const _a=(0,C.P2)((e=>e()),250,!1);let za=!1;var Va=s(1273),Ka=s(1876),Ya=s(787),Wa=s(180),Xa=s(3709),Ja=s(5418),eo=s(7262),to=s(1151),so=s(2275);const no=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"},{type:"voice",title:"SharedVoiceTab2"}];function ao(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > .Transition__slide--active > .${e}-list > .scroll-item`].join(", ")}const oo=(0,o.X$)((0,n.c$)(((e,{chatId:t,userId:s})=>{var n,a;const o=(0,i.Z1)(e,t),r=(0,i.Zw)(e,s||t),{currentType:c,resultsByType:l}=(0,i.we)(e)||{},{foundIds:u}=l&&c&&l[c]||{},{byId:m,statusesById:h}=e.users,{byId:g}=e.chats,p=o&&(0,d.Bf)(o),f=o&&(0,d.eA)(o),I=p||f&&(0,d.Nl)(o),v=null==o||null===(n=o.fullInfo)||void 0===n?void 0:n.members,y=I&&o&&o.fullInfo&&!o.fullInfo.canViewMembers,Z=I&&o&&((0,d.VE)(o,"inviteUsers")||o.isCreator),P=I&&o&&((0,d.VE)(o,"banUsers")||o.isCreator),C=(0,i.xs)(e,t);let w,b,S;return s?b=s:(0,d.YC)(t)&&(b=t),b&&(S=(0,i.dy)(e,b),w=S&&!S.isSelf&&!(0,d.cS)(S)),{theme:(0,i.Pu)(e),isChannel:f,resolvedUserId:b,chatMessages:r,foundIds:u,mediaSearchType:c,hasCommonChatsTab:w,hasMembersTab:I,areMembersHidden:y,canAddMembers:Z,canDeleteMembers:P,currentUserId:e.currentUserId,isRightColumnShown:(0,i.Jf)(e),isRestricted:null==o?void 0:o.isRestricted,lastSyncTime:e.lastSyncTime,serverTimeOffset:e.serverTimeOffset,activeDownloadIds:C,usersById:m,userStatusesById:h,chatsById:g,isChatProtected:null==o?void 0:o.isProtected,...I&&v&&{members:v},...w&&S&&{commonChatIds:null===(a=S.commonChats)||void 0===a?void 0:a.ids}}}))((({chatId:e,profileState:t,onProfileStateChange:s,theme:r,isChannel:i,resolvedUserId:c,currentUserId:l,chatMessages:g,foundIds:p,mediaSearchType:f,hasCommonChatsTab:I,hasMembersTab:v,areMembersHidden:y,canAddMembers:Z,canDeleteMembers:P,commonChatIds:C,members:w,usersById:b,userStatusesById:S,chatsById:E,isRightColumnShown:M,isRestricted:k,lastSyncTime:R,activeDownloadIds:T,serverTimeOffset:N,isChatProtected:B})=>{const{setLocalMediaSearchType:A,loadMoreMembers:x,loadCommonChats:L,openChat:O,searchMediaMessagesLocal:F,openMediaViewer:U,openAudioPlayer:$,openUserInfo:D,focusMessage:q,loadProfilePhotos:Q,setNewChatMembersDialogState:G}=(0,n.uC)(),j=(0,o.sO)(null),H=(0,o.sO)(null),_=(0,Ce.Z)(),[z,V]=(0,o.eJ)(0),[K,Y]=(0,o.eJ)(),W=(0,o.Ye)((()=>[...v?[{type:"members",title:i?"ChannelSubscribers":"GroupMembers"}]:[],...no,...I?[{type:"commonChats",title:"SharedGroupsTab2"}]:[]]),[I,v,i]),X=W[z].type,[J,ee,te,se]=function(e,t,s,n,a,r,i,c,l,u,m,h,g,p,f,I=0){const v="members"!==a&&r?r:a,y=(0,o.Ye)((()=>{if(i&&l&&u)return(0,d.Z0)(i.map((({userId:e})=>e)),l,u,void 0,I)}),[i,I,l,u]),Z=(0,o.Ye)((()=>{if(c&&m)return(0,d.ih)(c,m,!0)}),[m,c]),[P,C,w]=ja(0,t,f,y),[b,S,E]=Ha("media",v,n,f,h,g),[M,k,R]=Ha("documents",v,n,f,h,g),[T,N,B]=Ha("links",v,n,f,h,g),[A,x,L]=Ha("audio",v,n,f,h,g),[O,F,U]=Ha("voice",v,n,f,h,g),[$,D,q]=ja(0,s,f,Z);let Q,G,j=!1;switch(v){case"members":Q=P,G=C,j=w;break;case"commonChats":Q=$,G=D,j=q;break;case"media":Q=b,G=S,j=E;break;case"documents":Q=M,G=k,j=R;break;case"links":Q=T,G=N,j=B;break;case"audio":Q=A,G=x,j=L;break;case"voice":Q=O,G=F,j=U}return[v,Q,G,j]}(0,x,L,F,X,f,w,C,b,S,E,g,p,0,R,N),ne=W.findIndex((({type:e})=>e===J)),{handleScroll:ae}=function(e,t,s,n){(0,Yt.Z)((([s])=>{if(s&&s!==t){const s=e.current,a=s.querySelector(".TabList");s.scrollTop{za=!1}),350))}}),[t,n]),(0,Yt.Z)((([t])=>{if(s!==m.vi.Profile||s===t)return;const a=e.current;if(!a)return;const o=a.querySelector(".TabList");!o||o.offsetTop>a.scrollTop||(za=!0,(0,ss.Z)(a,a.firstElementChild,"start",void 0,2*a.offsetHeight),setTimeout((()=>{za=!1}),350),n(s))}),[s]);const a=(0,o.I4)((()=>{const s=e.current;if(!s)return;const a=s.querySelector(".TabList");if(!a)return;let o=m.vi.Profile;s.scrollTop>=a.offsetTop&&(o="members"===t?m.vi.MemberList:m.vi.SharedMedia),n(o)}),[e,n,t]);return(0,o.d4)((()=>{za||a()}),[a,t]),{handleScroll:(0,o.I4)((()=>{za||_a(a)}),[a])}}(j,X,t,s),{applyTransitionFix:oe,releaseTransitionFix:re}=function(e,t=".Transition.shared-media-transition"){return(0,o.d4)((()=>{function s(){const s=e.current,n=s.querySelector(t),a=s.querySelector(".TabList");n&&a&&(n.style.minHeight=s.offsetHeight-a.offsetHeight+"px")}return s(),window.addEventListener("resize",s,!1),()=>{window.removeEventListener("resize",s,!1)}}),[e,t]),{applyTransitionFix:(0,o.I4)((()=>{const t=e.current;if("hidden"!==t.style.overflowY){const e=t.offsetWidth-t.clientWidth;t.style.overflowY="hidden",t.style.marginRight=`${e}px`}}),[e]),releaseTransitionFix:(0,o.I4)((()=>{const t=e.current;t.style.overflowY="scroll",t.style.marginRight="0"}),[e])}}(j),[ie,ce]=(()=>{const[e,t]=(0,o.eJ)(!1);return[e,(0,o.I4)((()=>{t((e=>!e))}),[])]})(),de=(0,o.I4)((()=>{re(),ce()}),[re,ce]),le=(0,o.I4)((()=>{G(m.WB.InProgress)}),[G]);(0,o.d4)((()=>{A({mediaType:X})}),[A,X]);const ue=c||e;(0,o.d4)((()=>{R&&Q({profileId:ue})}),[Q,ue,R]);const me=(0,o.I4)((e=>{U({chatId:ue,threadId:u._f,messageId:e,origin:m.bZ.SharedMedia})}),[ue,U]),he=(0,o.I4)((e=>{$({chatId:ue,messageId:e})}),[ue,$]),ge=(0,o.I4)((e=>{D({id:e})}),[D]),pe=(0,o.I4)((e=>{q({chatId:ue,messageId:e})}),[ue,q]),fe=(0,o.I4)((()=>{Y(void 0)}),[]);let Ie;(0,o.d4)((()=>{if(H.current&&h.$b)return(0,Le.s)(H.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===Le.e.Left?(V(Math.min(z+1,W.length-1)),!0):t===Le.e.Right&&(V(Math.max(0,z-1)),!0)})}),[z,W.length]);const ve="members"===J||!v&&"media"===J;ve?Ie=M?0:1e3:ee||(Ie=a.Y);const ye=(0,Ia.Z)([e,J],Ie);function Pe(){if(!ee||!ye||!g){const e=ve&&ee&&!ye;return o.ZP.createElement("div",{className:"content empty-list"},!e&&o.ZP.createElement(Ae.Z,null))}if(!ee.length){let e;switch(J){case"members":e=y?"You have no access to group members list.":"No members found";break;case"commonChats":e=_("NoGroupsInCommon");break;case"documents":e=_("lng_media_file_empty");break;case"links":e=_("lng_media_link_empty");break;case"audio":e=_("lng_media_song_empty");break;case"voice":e=_("lng_media_audio_empty");break;default:e=_("SharedMedia.EmptyTitle")}return o.ZP.createElement("div",{className:"content empty-list"},o.ZP.createElement(eo.Z,{text:e}))}return o.ZP.createElement("div",{className:`content ${J}-list`,dir:_.isRtl&&"media"===J?"rtl":void 0,teactFastList:!0},"media"===J?ee.map((e=>g[e]&&o.ZP.createElement(Xa.Z,{key:e,message:g[e],isProtected:B||g[e].isProtected,onClick:me}))):"documents"===J?ee.map((e=>g[e]&&o.ZP.createElement(Cs.Z,{key:e,message:g[e],withDate:!0,smaller:!0,className:"scroll-item",onDateClick:pe,isDownloading:T.includes(e)}))):"links"===J?ee.map((e=>g[e]&&o.ZP.createElement(Ja.Z,{key:e,message:g[e],isProtected:B||g[e].isProtected,onMessageClick:pe}))):"audio"===J?ee.map((e=>g[e]&&o.ZP.createElement(ws.Z,{key:e,theme:r,message:g[e],origin:m.Cr.SharedMedia,date:g[e].date,lastSyncTime:R,className:"scroll-item",onPlay:he,onDateClick:pe,isDownloading:T.includes(e)}))):"voice"===J?ee.map((e=>g[e]&&o.ZP.createElement(ws.Z,{key:e,theme:r,message:g[e],senderTitle:(0,Qa.F)(_,g[e],E,b),origin:m.Cr.SharedMedia,date:g[e].date,lastSyncTime:R,className:"scroll-item",onPlay:he,onDateClick:pe,isDownloading:T.includes(e)}))):"members"===J?ee.map(((e,t)=>{return o.ZP.createElement(Ka.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>ge(e),contextActions:(s=e,s!==l&&P?[{title:_("lng_context_remove_from_group"),icon:"stop",handler:()=>{Y(s)}}]:void 0)},o.ZP.createElement(It.Z,{userId:e,forceShowSelf:!0}));var s})):"commonChats"===J?ee.map(((e,t)=>o.ZP.createElement(Ka.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>O({id:e})},o.ZP.createElement(vt.Z,{chatId:e})))):void 0)}return o.ZP.createElement(Va.Z,{ref:j,className:"Profile custom-scroll",itemSelector:ao(J),items:ye?ee:void 0,cacheBuster:ie,sensitiveArea:a.qU,preloadBackwards:ye?"members"===J?a.Vk:a.EN:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:te,onScroll:ae},!se&&function(e,t){return o.ZP.createElement("div",{className:"profile-info"},o.ZP.createElement(Ya.Z,{userId:t||e}),o.ZP.createElement(Wa.Z,{chatOrUserId:t||e}))}(e,c),!k&&o.ZP.createElement("div",{className:"shared-media"},o.ZP.createElement(Ze.Z,{ref:H,name:_.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:ne,renderCount:W.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:oe,onStop:de},Pe),o.ZP.createElement(Fe.Z,{big:!0,activeTab:z,tabs:W,onSwitchTab:V})),Z&&o.ZP.createElement(to.Z,{isShown:"members"===J,onClick:le,ariaLabel:_("lng_channel_add_users")},o.ZP.createElement("i",{className:"icon-add-user-filled"})),P&&o.ZP.createElement(so.Z,{isOpen:Boolean(K),userId:K,onClose:fe}))}))),ro=(0,o.X$)((e=>{const t=(0,qe.Z)(De.gl.Extra,"RightSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(Qe.Z,null)})),io=(0,o.X$)((e=>{const t=(0,qe.Z)(De.gl.Extra,"Management");return t?o.ZP.createElement(t,e):o.ZP.createElement(Qe.Z,null)})),co=(0,o.X$)((()=>{const e=(0,qe.Z)(De.gl.Extra,"StickerSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(Qe.Z,null)})),lo=(0,o.X$)((()=>{const e=(0,qe.Z)(De.gl.Extra,"GifSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(Qe.Z,null)})),uo=(0,o.X$)((()=>{const e=(0,qe.Z)(De.gl.Extra,"PollResults");return e?o.ZP.createElement(e,null):o.ZP.createElement(Qe.Z,null)}));var mo=s(1820);const ho=(0,o.X$)((0,n.c$)(((e,{chatId:t})=>{var s;const n=(0,i.Z1)(e,t),{userIds:a}=e.contactList||{},{byId:o}=e.chats,{currentUserId:r,newChatMembersProgress:c,connectionState:l}=e,u=n&&(0,d.eA)(n),{query:h,fetchingStatus:g,globalUserIds:p,localUserIds:f}=e.userSearch;return{isChannel:u,members:null==n||null===(s=n.fullInfo)||void 0===s?void 0:s.members,currentUserId:r,chatsById:o,localContactIds:a,searchQuery:h,isSearching:g,isLoading:c===m.WB.Loading,globalUserIds:p,localUserIds:f,connectionState:l}}))((({isChannel:e,connectionState:t,members:s,onNextStep:a,currentUserId:r,chatsById:i,localContactIds:c,isLoading:l,searchQuery:u,isSearching:m,localUserIds:h,globalUserIds:p,onClose:f,isActive:I})=>{const{setUserSearchQuery:v,loadContactList:y}=(0,n.uC)(),Z=(0,Ce.Z)(),[P,C]=(0,o.eJ)([]),w=(0,lt.Z)(P)===P;(0,o.d4)((()=>{I&&"connectionStateReady"===t&&y()}),[t,I,y]),(0,pe.ZP)(I,f);const b=(0,o.Ye)((()=>s?s.map((e=>e.userId)):[]),[s]),S=(0,o.I4)((e=>{v({query:e})}),[v]),E=(0,o.Ye)((()=>{const t=(0,n.Rd)().users.byId,s=c?(0,d.kK)(c,t,u):[];return(0,d.ih)((0,g.Tw)([...s,...h||[],...p||[]]).filter((s=>{const n=t[s];return!b.includes(s)&&s!==r&&(!n||!(0,d.cS)(n)||!e&&n.canBeInvitedToGroup)})),i)}),[c,i,u,h,p,r,b,e]),M=(0,o.I4)((()=>{P.length&&(v({query:""}),a(P))}),[P,v,a]);return o.ZP.createElement("div",{className:"AddChatMembers"},o.ZP.createElement("div",{className:"AddChatMembers-inner"},o.ZP.createElement(mo.Z,{itemIds:E,selectedIds:P,filterValue:u,filterPlaceholder:Z("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:m,onSelectedIdsChange:C,onFilterChange:S,noScrollRestore:w}),o.ZP.createElement(to.Z,{isShown:Boolean(P.length),disabled:l,ariaLabel:Z("lng_channel_add_users"),onClick:M},l?o.ZP.createElement(Ae.Z,{color:"white"}):o.ZP.createElement("i",{className:"icon-arrow-right"}))))}))),go=Object.keys(m.qt).length/2,po=Object.keys(m.u1).length/2;function fo(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const Io=(0,o.X$)((0,n.c$)((e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{},n=(0,i.g4)(e);return{contentKey:(0,i.Wq)(e),chatId:t,threadId:s,currentProfileUserId:e.users.selectedId,isChatSelected:Boolean(t&&n),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations}}))((({contentKey:e,chatId:t,threadId:s,currentProfileUserId:r,isChatSelected:i,shouldSkipHistoryAnimations:c})=>{var d;const{toggleChatInfo:l,toggleManagement:u,openUserInfo:h,closeLocalTextSearch:g,setStickerSearchQuery:p,setGifSearchQuery:f,closePollResults:I,addChatMembers:v,setNewChatMembersDialogState:y}=(0,n.uC)(),{width:Z}=ct(),[P,C]=(0,o.eJ)(m.vi.Profile),[w,b]=(0,o.eJ)(m.u1.Initial),[S,E]=(0,o.eJ)(),[M,k]=(0,o.eJ)(),R=P!==m.vi.Profile,T=void 0!==e,N=e===m.qt.ChatInfo||e===m.qt.UserInfo,B=e===m.qt.Search,A=e===m.qt.Management,x=e===m.qt.StickerSearch,L=e===m.qt.GifSearch,O=e===m.qt.PollResults,F=e===m.qt.AddingMembers,U=Z<=a._m,[$,D]=(0,o.eJ)(!T),q=null!==(d=(0,pt.Z)(e,!0,!i))&&void 0!==d?d:-1,Q=(0,o.I4)(((t=!0)=>{switch(e){case m.qt.AddingMembers:y(m.WB.Closed);break;case m.qt.ChatInfo:if(R&&t){C(m.vi.Profile);break}l(void 0,{forceSyncOnIOs:!0});break;case m.qt.UserInfo:if(R&&t){C(m.vi.Profile);break}h({id:void 0},{forceSyncOnIOs:!0});break;case m.qt.Management:switch(w){case m.u1.Initial:u();break;case m.u1.ChatPrivacyType:case m.u1.Discussion:case m.u1.GroupPermissions:case m.u1.GroupType:case m.u1.ChatAdministrators:case m.u1.ChannelSubscribers:case m.u1.GroupMembers:b(m.u1.Initial);break;case m.u1.GroupUserPermissionsCreate:case m.u1.GroupRemovedUsers:case m.u1.GroupUserPermissions:b(m.u1.GroupPermissions),E(void 0),k(void 0);break;case m.u1.ChatAdminRights:case m.u1.ChatNewAdminRights:case m.u1.GroupAddAdmins:case m.u1.GroupRecentActions:b(m.u1.ChatAdministrators)}break;case m.qt.Search:fo(),g();break;case m.qt.StickerSearch:fo(),p({query:void 0});break;case m.qt.GifSearch:fo(),f({query:void 0});break;case m.qt.PollResults:I()}}),[e,R,l,h,I,y,w,u,g,p,f]),G=(0,o.I4)(((e,t)=>{E(e),k(t)}),[]),j=(0,o.I4)((e=>{v({chatId:t,memberIds:e})}),[v,t]);function H(e){if(-1!==q)switch(q){case m.qt.AddingMembers:return o.ZP.createElement(ho,{chatId:t,onNextStep:j,isActive:T&&e,onClose:Q});case m.qt.ChatInfo:case m.qt.UserInfo:return o.ZP.createElement(oo,{key:r||t,chatId:t,userId:r,profileState:P,onProfileStateChange:C});case m.qt.Search:return o.ZP.createElement(ro,{chatId:t,threadId:s,onClose:Q,isActive:T&&e});case m.qt.Management:return o.ZP.createElement(io,{chatId:t,currentScreen:w,isPromotedByCurrentUser:M,selectedChatMemberId:S,onScreenSelect:b,onChatMemberSelect:G,isActive:T&&e,onClose:Q});case m.qt.StickerSearch:return o.ZP.createElement(co,{onClose:Q,isActive:T&&e});case m.qt.GifSearch:return o.ZP.createElement(lo,{onClose:Q,isActive:T&&e});case m.qt.PollResults:return o.ZP.createElement(uo,{onClose:Q,isActive:T&&e})}}return(0,o.d4)((()=>T?(0,fe.Z)(Q):void 0),[T,Q]),(0,o.d4)((()=>{setTimeout((()=>{D(!T)}),300)}),[T]),(0,o.d4)((()=>{T&&U&&Q()}),[U]),(0,Kt.Z)((([s,n])=>{(s===m.qt.ChatInfo&&e===m.qt.UserInfo||s===m.qt.UserInfo&&e===m.qt.ChatInfo||n!==t)&&(C(m.vi.Profile),b(m.u1.Initial))}),[e,t]),(0,pe.ZP)(i&&(e===m.qt.ChatInfo||e===m.qt.UserInfo||e===m.qt.Management||e===m.qt.AddingMembers),(()=>Q(!1)),l),o.ZP.createElement("div",{id:"RightColumn-wrapper",className:i?void 0:"is-hidden"},U&&o.ZP.createElement("div",{className:"overlay-backdrop",onClick:Q}),o.ZP.createElement("div",{id:"RightColumn"},o.ZP.createElement(qa,{chatId:t,isColumnOpen:T,isProfile:N,isSearch:B,isManagement:A,isStickerSearch:x,isGifSearch:L,isPollResults:O,isAddingChatMembers:F,profileState:P,managementScreen:w,onClose:Q,shouldSkipAnimation:$||c}),o.ZP.createElement(Ze.Z,{name:$||c?"none":"zoom-fade",renderCount:go+po,activeKey:A?go+w:q,shouldCleanup:!0,cleanupExceptionKey:m.qt.ChatInfo},H)))}))),vo=(0,o.X$)((({isOpen:e})=>{const t=(0,qe.Z)(De.gl.Extra,"MediaViewer",!e);return t?o.ZP.createElement(t,null):void 0}));function yo(e,t){const s=document.createElement("a");s.href=e,s.download=t;try{s.click()}catch(e){console.error(e)}}const Zo=new Set,Po=(0,o.X$)((0,n.c$)((e=>({activeDownloads:e.activeDownloads.byChatId,messages:e.messages.byChatId})))((({activeDownloads:e,messages:t})=>{const{cancelMessageMediaDownload:s}=(0,n.uC)();(0,o.d4)((()=>{Object.entries(e).forEach((([e,n])=>{n.map((s=>t[Number(e)].byId[s])).forEach((e=>{const t=(0,d.Ti)(e,"download");if(t){if(!Zo.has(t)){const n=Nt.UV(t);if(n)return Zo.delete(t),yo(n,(0,d.w6)(e)),void s({message:e});Nt.he(t,u.IU.BlobUrl,!0).then((n=>{Zo.delete(t),n&&yo(n,(0,d.w6)(e)),s({message:e})})),Zo.add(t)}}else s({message:e})}))}))}),[s,t,e])}))),Co=(0,o.X$)((({isOpen:e})=>{const t=(0,qe.Z)(De.gl.Extra,"Notifications",!e);return t?o.ZP.createElement(t,null):void 0})),wo=(0,o.X$)((({isOpen:e})=>{const t=(0,qe.Z)(De.gl.Extra,"Dialogs",!e);return t?o.ZP.createElement(t,null):void 0})),bo=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"ForwardPicker",!t);return s?o.ZP.createElement(s,e):void 0})),So=(0,o.X$)((e=>{const{url:t}=e,s=(0,qe.Z)(De.gl.Extra,"SafeLinkModal",!t);return s?o.ZP.createElement(s,e):void 0})),Eo=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,qe.Z)(De.gl.Extra,"HistoryCalendar",!t);return s?o.ZP.createElement(s,e):void 0})),Mo=(0,o.X$)((e=>{const{groupCallId:t}=e,s=(0,qe.Z)(De.gl.Calls,"GroupCall",!t);return s?o.ZP.createElement(s,e):void 0})),ko=(0,o.X$)((e=>{const{groupCallId:t}=e,s=(0,qe.Z)(De.gl.Calls,"ActiveCallHeader",!t);return s?o.ZP.createElement(s,null):void 0})),Ro=(0,o.X$)((({isOpen:e})=>{const t=(0,qe.Z)(De.gl.Calls,"CallFallbackConfirm",!e);return t?o.ZP.createElement(t,{isOpen:e}):void 0}));let To,No=!1;function Bo(e){document.querySelectorAll('link[rel="icon"], link[rel="alternate icon"]').forEach((t=>{e?t.href.includes("favicon-unread")||(t.href=t.href.replace("favicon","favicon-unread")):t.href=t.href.replace("favicon-unread","favicon")}))}function Ao(e){document.title!==e&&(document.title=e)}const xo=(0,o.X$)((0,n.c$)((e=>{const{settings:{byKey:{animationLevel:t,language:s,wasTimeFormatSetManually:n}}}=e,{chatId:a,messageId:o}=e.audioPlayer,r=a&&o?(0,i.hj)(e,a,o):void 0;return{lastSyncTime:e.lastSyncTime,isLeftColumnShown:e.isLeftColumnShown,isRightColumnShown:(0,i.Jf)(e),isMediaViewerOpen:(0,i.zQ)(e),isForwardModalOpen:(0,i.Ev)(e),hasNotifications:Boolean(e.notifications.length),hasDialogs:Boolean(e.dialogs.length),audioMessage:r,safeLinkModalUrl:e.safeLinkModalUrl,isHistoryCalendarOpen:Boolean(e.historyCalendarSelectedAt),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,openedStickerSetShortName:e.openedStickerSetShortName,isServiceChatReady:(0,i.UW)(e),activeGroupCallId:e.groupCalls.activeGroupCallId,animationLevel:t,language:s,wasTimeFormatSetManually:n,isCallFallbackConfirmOpen:Boolean(e.groupCalls.isFallbackConfirmOpen),addedSetIds:e.stickers.added.setIds}}))((({lastSyncTime:e,isLeftColumnShown:t,isRightColumnShown:s,isMediaViewerOpen:r,isForwardModalOpen:c,hasNotifications:d,hasDialogs:l,audioMessage:u,activeGroupCallId:m,safeLinkModalUrl:g,isHistoryCalendarOpen:p,shouldSkipHistoryAnimations:f,openedStickerSetShortName:I,isServiceChatReady:v,animationLevel:y,language:Z,wasTimeFormatSetManually:P,isCallFallbackConfirmOpen:w,addedSetIds:b})=>{const{loadAnimatedEmojis:S,loadNotificationSettings:E,loadNotificationExceptions:M,updateIsOnline:k,loadTopInlineBots:R,loadEmojiKeywords:T,loadCountryList:N,loadStickerSets:B,loadAddedStickers:A,loadFavoriteStickers:x,ensureTimeFormat:L,openStickerSetShortName:O,checkVersionNotification:F}=(0,n.uC)(),U=Boolean(e);a.eM&&!No&&(No=!0,console.log(">>> RENDER MAIN")),(0,o.d4)((()=>{e&&(k(!0),S(),E(),M(),R(),T({language:a.pR}))}),[e,S,T,M,E,R,k]),(0,o.d4)((()=>{e&&(Z!==a.pR&&T({language:Z}),N({langCode:Z}))}),[Z,e,N,T]),(0,o.d4)((()=>{U&&(b?A():(B(),x()))}),[U,b,B,x,A]),(0,o.d4)((()=>{e&&v&&F()}),[e,v,F]),(0,o.d4)((()=>{e&&!P&&L()}),[e,P,L]),(0,o.d4)((()=>{e&&pe.Oy.startsWith("#?tgaddr=")&&(0,oe.o)(decodeURIComponent(pe.Oy.substr("#?tgaddr=".length)))}),[e]),(0,o.d4)((()=>{if(m)return ie.Z.disableRefresh(),()=>{ie.Z.enableRefresh()}}),[m]);const{transitionClassNames:$}=(0,ce.Z)(!t,void 0,!0,void 0,f),{transitionClassNames:D}=(0,ce.Z)(s,void 0,!0,void 0,f),q=(0,ne.Z)($.replace(/([\w-]+)/g,"middle-column-$1"),D.replace(/([\w-]+)/g,"right-column-$1"),f&&"history-animation-disabled");(0,ue.Z)((([e])=>{if(void 0===e||0===y)return;const t=(0,se.YW)();(0,ae.L)(document.getElementById("MiddleColumn"),t)}),[t]),(0,ue.Z)((([e])=>{if(void 0===e||0===y)return;(0,C.T2)((()=>{document.body.classList.add("animating-right-column")}));const t=(0,se.YW)();(0,ae.L)(document.getElementById("RightColumn"),(()=>{t(),(0,C.T2)((()=>{document.body.classList.remove("animating-right-column")}))}))}),[s]);const Q=(0,o.I4)((()=>{k(!1);const e=(0,i.A1)((0,n.Rd)());let t=0;clearInterval(To),To=window.setInterval((()=>{if(document.title.includes(a.ou))Bo(!1);else{if(t%2==0){const t=(0,i.A1)((0,n.Rd)())-e;t>0&&(Ao(`${t} notification${t>1?"s":""}`),Bo(!0))}else Ao(a.Ti),Bo(!1);t++}}),1e3)}),[k]),G=(0,o.I4)((()=>{k(!0),clearInterval(To),To=void 0,document.title.includes(a.ou)||Ao(a.Ti),Bo(!1)}),[k]),j=(0,o.I4)((()=>{O({stickerSetShortName:void 0})}),[O]);return(0,de.Z)(Q,G),le(Q),function(e=!1){(0,o.d4)((()=>{if(h.$b){if(!e)return null==me||me.setAttribute("content",he),h.cj&&!h.fl&&document.addEventListener("gesturestart",ge),()=>{null==me||me.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),h.cj&&!h.fl&&document.removeEventListener("gesturestart",ge)};null==me||me.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover")}}),[e])}(r),o.ZP.createElement("div",{id:"Main",className:q,onDrop:re.Z,onDragOver:re.Z},o.ZP.createElement(nt,null),o.ZP.createElement(Ua,null),o.ZP.createElement(Io,null),o.ZP.createElement(vo,{isOpen:r}),o.ZP.createElement(bo,{isOpen:c}),o.ZP.createElement(Co,{isOpen:d}),o.ZP.createElement(wo,{isOpen:l}),u&&o.ZP.createElement(jt,{key:u.id,message:u,noUi:!0}),o.ZP.createElement(So,{url:g}),o.ZP.createElement(Eo,{isOpen:p}),o.ZP.createElement(ks.Z,{isOpen:Boolean(I),onClose:j,stickerSetShortName:I}),m&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Mo,{groupCallId:m}),o.ZP.createElement(ko,{groupCallId:m})),o.ZP.createElement(Po,null),o.ZP.createElement(Ro,{isOpen:w}))})));a.eM&&console.log(">>> FINISH LOAD MAIN BUNDLE"),(0,n.Rd)().connectionState||(0,n.uC)().initApi()},4524:(e,t,s)=>{e.exports=s.p+"telegram-logo-filled.67469f6dc5e301e8e0bd..svg"}}]); //# sourceMappingURL=87.74a4d72480e8214a0dde.js.map