TelegramPWA/dist/5769.c3dbfbe711671c6ba22d.js
Alexander Zinchuk 7bccdedf2a [Build]
2023-03-10 02:37:14 +01:00

2 lines
378 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[5769],{61006:(e,t,n)=>{n.r(t),n.d(t,{LockScreen:()=>sd,Main:()=>Kc});var a=n(33555),s=n(77361),o=n(83716),i=n(60748),r=(n(89005),n(6137)),c=n(25260),d=n(11192),l=n(70735),u=n(56112),m=n(65054);function h(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];let[s=(0,m._w)()]=n;const{chatId:o,threadId:i}=(0,d.Bt)(e,s)||{};return o&&i?(e=(0,c.qr)(e,o,i,!1,void 0,s),e=(0,c.Pb)(e,o,i,void 0,void 0,void 0,s)):e}(0,a.iw)("openLocalTextSearch",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},{chatId:s,threadId:o}=(0,d.Bt)(e,a)||{};if(s&&o)return(0,c.qr)(e,s,o,!0,void 0,a)})),(0,a.iw)("closeLocalTextSearch",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return h(e,a)})),(0,a.iw)("setLocalTextSearchQuery",((e,t,n)=>{const{query:a,tabId:s=(0,m._w)()}=n,{chatId:o,threadId:i}=(0,d.Bt)(e,s)||{};if(!o||!i)return;const r=(0,u.uw)(o,i),{query:h}=(0,d.jU)(e,s).localTextSearch.byChatThreadKey[r]||{};return a!==h&&(e=(0,c.Pb)(e,o,i,l.D,void 0,void 0,s)),(0,c.qr)(e,o,i,!0,a,s)})),(0,a.iw)("setLocalMediaSearchType",((e,t,n)=>{const{mediaType:a,tabId:s=(0,m._w)()}=n,{chatId:o,threadId:i}=(0,d.Bt)(e,s)||{};if(o&&i)return(0,c.z5)(e,o,i,a,s)}));var p=n(44271),g=n(15780);(0,a.iw)("openChat",((e,t,n)=>{const{id:a,threadId:s=r._f,type:o="thread",shouldReplaceHistory:i=!1,noForumTopicPanel:l,tabId:u=(0,m._w)()}=n,g=(0,d.Bt)(e,u),f=(0,d.jU)(e,u);return f.premiumModal?.promo&&f.premiumModal?.isOpen&&(e=(0,p.i)(e,{premiumModal:{...f.premiumModal,isOpen:!1}},u)),g&&g.chatId===a&&g.threadId===s&&g.type===o||(a&&(e=(0,c.O8)(e,a,s,"replyStack",[],u),e=(0,p.i)(e,{activeReactions:{}},u)),e=h(e=(0,c.i9)(e,u),u),e=(0,p.i)(e,{isStatisticsShown:!1,contentToBeScheduled:void 0,...a!==(0,d.jU)(e,u).forwardMessages.toChatId&&{forwardMessages:{}}},u)),a&&((0,d.Z1)(e,a)?.isForum&&!l?t.openForumPanel({chatId:a,tabId:u}):a!==(0,d.jU)(e,u).forumPanelChatId&&t.closeForumPanel({tabId:u})),t.updatePageTitle({tabId:u}),(0,c.Wy)(e,a,s,o,i,u)})),(0,a.iw)("openChatInNewTab",((e,t,n)=>{const{chatId:a,threadId:s=r._f}=n;window.open((0,g.Ex)(a,"thread",s),"_blank")})),(0,a.iw)("openPreviousChat",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,c.Wy)(e,void 0,void 0,void 0,void 0,a)})),(0,a.iw)("openChatWithInfo",((e,t,n)=>{const{tabId:s=(0,m._w)()}=n;e=(0,p.i)(e,{...(0,d.jU)(e,s),isChatInfoShown:!0},s),e={...e,lastIsChatInfoShown:!0},(0,a.R3)(e),t.openChat({...n,tabId:s})})),(0,a.iw)("openChatWithDraft",((e,t,n)=>{const{chatId:a,text:s,threadId:o,files:i,tabId:r=(0,m._w)()}=n;return a&&t.openChat({id:a,threadId:o,tabId:r}),(0,p.i)(e,{requestedDraft:{chatId:a,text:s,files:i}},r)})),(0,a.iw)("resetChatCreation",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{chatCreation:void 0},a)})),(0,a.iw)("setNewChatMembersDialogState",((e,t,n)=>{const{newChatMembersProgress:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{newChatMembersProgress:a},s)})),(0,a.iw)("openNextChat",((e,t,n)=>{const{targetIndexDelta:a,orderedIds:s,tabId:o=(0,m._w)()}=n,{chatId:i}=(0,d.Bt)(e,o)||{};if(!i)return void t.openChat({id:s[0],tabId:o});const r=s.indexOf(i);if(-1===r)return;const c=s[r+a];t.openChat({id:c,shouldReplaceHistory:!0,tabId:o})})),(0,a.iw)("openDeleteChatFolderModal",((e,t,n)=>{const{folderId:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{deleteFolderDialogModal:a},s)})),(0,a.iw)("closeDeleteChatFolderModal",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{deleteFolderDialogModal:void 0},a)}));var f=n(91713),I=n(60782),v=n(82267),w=n(83099),b=n(50711),y=n(64319),P=n(996),Z=n(42986),C=n(42797);const S=o.ckE+o.fK3;let E;function M(e,t,n){const{type:a,threadId:s}=(0,d.Bt)(e)||{},o=b.Iu,i="scheduled"===a?(0,d.yB)(e,t):(0,d.Zw)(e,t);if(!i||!s)return;const r=n.map((e=>i[e])).filter((t=>(0,d._k)(e,t,s).canCopy)).sort(((e,t)=>e.id-t.id)),c=r.reduce(((t,n)=>{const a=(0,d.Ur)(e,n);return t.push(`> ${a?(0,u.OU)(o,a):""}:`),t.push(`${function(e,t){const n=(0,Z.Eb)(t),a=n?`${n} `:"",s=(0,P.X)(t,void 0,void 0,void 0,void 0,void 0,!0)?.join("");return`${a}${(0,Z.Kk)(e,t,s,!0,!0)}`}(o,n)}\n`),t}),[]),l=r.reduce(((t,n)=>{const a=(0,d.Ur)(e,n);return t.push(`> ${a?(0,u.OU)(o,a):""}:`),t.push(`${(0,u.MK)(o,n,!1,0,void 0,!0)}\n`),t}),[]);(0,y.qN)(c.join("\n"),l.join("\n"))}(0,a.iw)("setScrollOffset",((e,t,n)=>{const{chatId:a,threadId:s,scrollOffset:o,tabId:i=(0,m._w)()}=n;return e=(0,c.pf)(e,a,s,"lastScrollOffset",o),(0,c.O8)(e,a,s,"scrollOffset",o,i)})),(0,a.iw)("setReplyingToId",((e,t,n)=>{const{messageId:a,tabId:s=(0,m._w)()}=n,o=(0,d.Bt)(e,s);if(!o)return;const{chatId:i,threadId:r}=o;return(0,c.pf)(e,i,r,"replyingToId",a)})),(0,a.iw)("setEditingId",((e,t,n)=>{const{messageId:a,tabId:s=(0,m._w)()}=n,o=(0,d.Bt)(e,s);if(!o)return;const{chatId:i,threadId:r,type:l}=o,u="scheduled"===l?"editingScheduledId":"editingId";return(0,c.pf)(e,i,r,u,a)})),(0,a.iw)("setEditingDraft",((e,t,n)=>{const{text:a,chatId:s,threadId:o,type:i}=n,r="scheduled"===i?"editingScheduledDraft":"editingDraft";return(0,c.pf)(e,s,o,r,a)})),(0,a.iw)("editLastMessage",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},{chatId:s,threadId:o}=(0,d.Bt)(e,a)||{};if(!s||!o)return;const i=(0,d.Zw)(e,s),r=(0,d.Cb)(e,s,o,a);if(!i||!r)return;const l=(0,I.dF)(r,(t=>Boolean(i[t]&&(0,d._k)(e,i[t],o).canEdit)));return l?(0,c.pf)(e,s,o,"editingId",l):void 0})),(0,a.iw)("replyToNextMessage",((e,t,n)=>{const{targetIndexDelta:a,tabId:s=(0,m._w)()}=n,{chatId:o,threadId:i}=(0,d.Bt)(e,s)||{};if(!o||!i)return;const c=(0,d.Zw)(e,o),l=(0,d.Cb)(e,o,i,s);if(!c||!l)return;const u=(0,d.Yy)(e,o,i);let h;if((0,d.b9)(e,o,i,s)&&u){const e=Object.keys(c),t=e.indexOf(u.toString())+a;h=t<=e.length+1&&t>=0?Number(e[t]):void 0}else h=i===r._f?(0,d.Z1)(e,o)?.lastMessage?.id:(0,d.tZ)(e,o,i)?.lastMessageId;t.setReplyingToId({messageId:h,tabId:s}),t.focusMessage({chatId:o,threadId:i,messageId:h,tabId:s})})),(0,a.iw)("openAudioPlayer",((e,t,n)=>{const{chatId:a,threadId:s,messageId:o,origin:i,volume:r,playbackRate:c,isMuted:l,tabId:u=(0,m._w)()}=n,h=(0,d.jU)(e,u);return(0,p.i)(e,{audioPlayer:{chatId:a,threadId:s,messageId:o,origin:null!=i?i:h.audioPlayer.origin,volume:null!=r?r:h.audioPlayer.volume,playbackRate:c||h.audioPlayer.playbackRate||e.audioPlayer.lastPlaybackRate,isPlaybackRateActive:void 0===h.audioPlayer.isPlaybackRateActive?e.audioPlayer.isLastPlaybackRateActive:h.audioPlayer.isPlaybackRateActive,isMuted:l||h.audioPlayer.isMuted}},u)})),(0,a.iw)("setAudioPlayerVolume",((e,t,n)=>{const{volume:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{audioPlayer:{...(0,d.jU)(e,s).audioPlayer,volume:a,isMuted:!1}},s)})),(0,a.iw)("setAudioPlayerPlaybackRate",((e,t,n)=>{const{playbackRate:a,isPlaybackRateActive:s,tabId:o=(0,m._w)()}=n;return e={...e,audioPlayer:{...e.audioPlayer,lastPlaybackRate:a,isLastPlaybackRateActive:s}},(0,p.i)(e,{audioPlayer:{...(0,d.jU)(e,o).audioPlayer,playbackRate:a,isPlaybackRateActive:s}},o)})),(0,a.iw)("setAudioPlayerMuted",((e,t,n)=>{const{isMuted:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{audioPlayer:{...(0,d.jU)(e,s).audioPlayer,isMuted:a}},s)})),(0,a.iw)("setAudioPlayerOrigin",((e,t,n)=>{const{origin:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{audioPlayer:{...(0,d.jU)(e,s).audioPlayer,origin:a}},s)})),(0,a.iw)("closeAudioPlayer",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},s=(0,d.jU)(e,a);return(0,p.i)(e,{audioPlayer:{volume:s.audioPlayer.volume,playbackRate:s.audioPlayer.playbackRate,isPlaybackRateActive:s.audioPlayer.isPlaybackRateActive,isMuted:s.audioPlayer.isMuted}},a)})),(0,a.iw)("openPollResults",((e,t,n)=>{const{chatId:s,messageId:o,tabId:i=(0,m._w)()}=n,r=(0,d.Jf)(e,(0,C.W7)(),i),c=(0,d.jU)(e,i);if(r){if(s!==c.pollResults.chatId||o!==c.pollResults.messageId)return(0,p.i)(e,{pollResults:{chatId:s,messageId:o,voters:{}}},i)}else window.setTimeout((()=>{e=(0,a.Rd)(),e=(0,p.i)(e,{pollResults:{chatId:s,messageId:o,voters:{}}},i),(0,a.R3)(e)}),450)})),(0,a.iw)("closePollResults",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{pollResults:{}},a)})),(0,a.iw)("focusLastMessage",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},s=(0,d.Bt)(e,a);if(!s)return;const{chatId:o,threadId:i}=s;let c;c=i===r._f?(0,d.Z1)(e,o)?.lastMessage?.id:(0,d.tZ)(e,o,i)?.lastMessageId,c&&t.focusMessage({chatId:o,threadId:i,messageId:c,noHighlight:!0,noForumTopicPanel:!0,tabId:a})})),(0,a.iw)("focusNextReply",((e,t,n)=>{const{tabId:s=(0,m._w)()}=n||{},o=(0,d.Bt)(e,s);if(!o)return;const{chatId:i,threadId:r}=o,l=(0,d.p9)(e,i,r,s);if(l&&0!==l.length){const n=l.pop();e=(0,c.O8)(e,i,r,"replyStack",[...l],s),(0,a.R3)(e),t.focusMessage({chatId:i,threadId:r,messageId:n,tabId:s,noForumTopicPanel:!0})}else t.focusLastMessage({tabId:s})})),(0,a.iw)("setReachedFocusedMessage",((e,t,n)=>{const{hasReached:a=!1,tabId:s=(0,m._w)()}=n;return(0,c.$G)(e,a,s)})),(0,a.iw)("focusMessage",((e,t,n)=>{const{chatId:s,threadId:o=r._f,messageListType:i="thread",noHighlight:l,groupedId:u,groupedChatId:h,replyMessageId:p,isResizingContainer:g,shouldReplaceHistory:v,noForumTopicPanel:w,tabId:b=(0,m._w)()}=n;let{messageId:y}=n;if(void 0!==u){const t=(0,d.y8)(e,h,u);t?.length&&([y]=(0,I.oA)(t))}const P=(0,d.Bt)(e,b),Z=!P||s!==P.chatId||o!==P.threadId||i!==P.type;if(E&&(clearTimeout(E),E=void 0),E=window.setTimeout((()=>{e=(0,a.Rd)(),e=(0,c.cq)(e,void 0,void 0,void 0,void 0,b),e=(0,c.wV)(e,void 0,b),(0,a.R3)(e)}),l?S:1500),e=(0,c.cq)(e,s,y,l,g,b),e=(0,c.wV)(e,void 0,b),p){const t=(0,d.p9)(e,s,o,b)||[];e=(0,c.O8)(e,s,o,"replyStack",[...t,p],b)}Z&&(e=(0,c.wV)(e,f.fo.Static,b));const C=(0,d.Cb)(e,s,o,b);if(C&&C.includes(y))return(0,a.R3)(e),void t.openChat({id:s,threadId:o,shouldReplaceHistory:v,noForumTopicPanel:w,tabId:b});if(Z&&(e=(0,c.O8)(e,s,o,"viewportIds",void 0,b)),e=(0,c.O8)(e,s,o,"outlyingIds",void 0,b),C&&!Z){const t=y>C[0]?f.fo.Down:f.fo.Up;e=(0,c.wV)(e,t,b)}(0,a.R3)(e),t.openChat({id:s,threadId:o,shouldReplaceHistory:v,noForumTopicPanel:w,tabId:b}),t.loadViewportMessages({tabId:b})})),(0,a.iw)("openForwardMenu",((e,t,n)=>{const{fromChatId:a,messageIds:s,groupedId:o,withMyScore:i,tabId:r=(0,m._w)()}=n;let c;return o&&(c=(0,d.xH)(e,a,o)),(0,p.i)(e,{forwardMessages:{fromChatId:a,messageIds:c||s,isModalShown:!0,withMyScore:i}},r)})),(0,a.iw)("changeForwardRecipient",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{forwardMessages:{...(0,d.jU)(e,a).forwardMessages,toChatId:void 0,isModalShown:!0,noAuthors:!1,noCaptions:!1}},a)})),(0,a.iw)("setForwardNoAuthors",((e,t,n)=>{const{noAuthors:a,tabId:s=(0,m._w)()}=n,o=(0,d.jU)(e,s);return(0,p.i)(e,{forwardMessages:{...o.forwardMessages,noAuthors:a,noCaptions:a&&o.forwardMessages.noCaptions}},s)})),(0,a.iw)("setForwardNoCaptions",((e,t,n)=>{const{noCaptions:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{forwardMessages:{...(0,d.jU)(e,s).forwardMessages,noCaptions:a,noAuthors:a}},s)})),(0,a.iw)("exitForwardMode",((e,t,n)=>{const{tabId:s=(0,m._w)()}=n||{};e=(0,p.i)(e,{forwardMessages:{}},s),(0,a.R3)(e)})),(0,a.iw)("openForwardMenuForSelectedMessages",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},s=(0,d.jU)(e,a);if(!s.selectedMessages)return;const{chatId:o,messageIds:i}=s.selectedMessages;t.openForwardMenu({fromChatId:o,messageIds:i,tabId:a})})),(0,a.iw)("cancelMessageMediaDownload",((e,t,n)=>{const{message:s,tabId:o=(0,m._w)()}=n,i=(0,d.jU)(e,o),r=i.activeDownloads.byChatId[s.chatId];r&&r.length&&(e=(0,p.i)(e,{activeDownloads:{byChatId:{...i.activeDownloads.byChatId,[s.chatId]:r.filter((e=>e!==s.id))}}},o),(0,a.R3)(e))})),(0,a.iw)("cancelMessagesMediaDownload",((e,t,n)=>{const{messages:a,tabId:s=(0,m._w)()}=n,o=(0,d.jU)(e,s).activeDownloads.byChatId,i={};return Object.keys(o).forEach((e=>{i[e]=o[e].filter((e=>!a.find((t=>t.id===e))))})),(0,p.i)(e,{activeDownloads:{byChatId:i}},s)})),(0,a.iw)("downloadMessageMedia",((e,t,n)=>{const{message:s,tabId:o=(0,m._w)()}=n,i=(0,d.jU)(e,o);e=(0,p.i)(e,{activeDownloads:{byChatId:{...i.activeDownloads.byChatId,[s.chatId]:[...i.activeDownloads.byChatId[s.chatId]||[],s.id]}}},o),(0,a.R3)(e)})),(0,a.iw)("downloadSelectedMessages",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},s=(0,d.jU)(e,a);if(!s.selectedMessages)return;const{chatId:o,messageIds:i}=s.selectedMessages,{threadId:r}=(0,d.Bt)(e,a)||{},c=(0,d.Zw)(e,o);c&&r&&i.map((e=>c[e])).filter((t=>(0,d._k)(e,t,r).canDownload)).forEach((e=>t.downloadMessageMedia({message:e,tabId:a})))})),(0,a.iw)("enterMessageSelectMode",((e,t,n)=>{const{messageId:a,tabId:s=(0,m._w)()}=n||{},o=(0,d.jr)(e,s);return o?(0,c.M6)(e,o.id,a,s):e})),(0,a.iw)("toggleMessageSelection",((e,t,n)=>{const{messageId:o,groupedId:i,childMessageIds:r,withShift:l,tabId:u=(0,m._w)()}=n,h=(0,d.Bt)(e,u);if(!h)return;const{chatId:p,threadId:g,type:f}=h;e=(0,c.Ob)(e,p,g,f,o,i,r,l,u),(0,a.R3)(e),(0,d.jU)(e,u).shouldShowContextMenuHint&&(t.disableContextMenuHint({tabId:u}),t.showNotification({message:`To **edit** or **reply**, close this menu. Then ${s.$b?"long tap":"right click"} on a message.`,tabId:u}))})),(0,a.iw)("disableContextMenuHint",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};if((0,d.jU)(e,a).shouldShowContextMenuHint)return(0,p.i)(e,{shouldShowContextMenuHint:!1},a)})),(0,a.iw)("exitMessageSelectMode",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,c.i9)(e,a)})),(0,a.iw)("openPollModal",((e,t,n)=>{const{isQuiz:a,tabId:s=(0,m._w)()}=n||{};return(0,p.i)(e,{pollModal:{isOpen:!0,isQuiz:a}},s)})),(0,a.iw)("closePollModal",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{pollModal:{isOpen:!1}},a)})),(0,a.iw)("checkVersionNotification",((e,t)=>{if(o.V61&&Date.now()>Number(o.V61)+2592e5)return;const n=o.JiC.split(".").slice(0,2).join("."),{serviceNotifications:a}=e;if(a.find((e=>{let{version:t}=e;return t===n})))return;const s={chatId:o.awM,date:(0,v.bp)(),content:{text:(0,w.ZP)("**Telegram Web Z was updated to version 1.60**\n\n[🤩](customEmoji:5373026167722876724) **Whats New**\n\n• Archived Chats Header - Archived Chats are now accessible from the chat list in a collapsable header.\n\n• Reply Threads - You can tap to view all replies to a message in a separate window.\n\n• Emoji In Captions - You can now open the emoji panel [🙂](customEmoji:5971928678198676594) when adding a caption to media.\n\n• Message Translation - You can translate any message into another language from the context menu. To show this option, enable Translation in _Settings > Language_.\n\n• Emoji Statuses - Premium users can update their animated emoji status from the [🌟](customEmoji:6046154264353442824) at the top of their chat list.\n\n• Granular Media Permissions - Admins can choose which media types are allowed in their groups, each with separate toggles.\n\n[😍](customEmoji:5372886001465170842) **Whats Better**\n\n• Multiple tabs can be opened by holding <Ctrl> (⌘ on macOS) and clicking on a chat.\n\n• Opening a chat changes the title of your browser tab to the chat name. This can be modified in _Settings > Privacy and Security_.\n\n• Bot reply keyboards are now supported in groups and channels.\n\n• The video and audio players always remember your last playback speed.\n\n• Opening topics has an improved animation.\n\n• Performance when typing messages has been drastically improved.\n\n• Fixed disappearing drafts.\n\n• Fixed missing results in Global Search.\n\n• Fixed rare issues with opening text format options.\n\n• Fixed pasting text from Google Docs.\n\n• Fixed auto-closing context menu on iOS PWA.\n\n• Fixed changing group and channel admin rights.\n\n• Various layout and performance improvements.\n",!0)},isOutgoing:!1};t.createServiceNotification({message:s,version:n})})),(0,a.iw)("createServiceNotification",((e,t,n)=>{const{message:s,version:i}=n,{serviceNotifications:r}=e,c=(0,d.Z1)(e,o.awM),l=Math.max(c.lastMessage?.id||0,...r.map((e=>{let{id:t}=e;return t}))),u=(r.length+1)/1e3,m=Math.floor(l)+u;s.previousLocalId=s.id,s.id=m;const h={id:m,message:s,version:i,isUnread:!0};e={...e,serviceNotifications:[...r.slice(-1e3),h]},(0,a.R3)(e),t.apiUpdate({"@type":"newMessage",id:s.id,chatId:s.chatId,message:s})})),(0,a.iw)("openReactorListModal",((e,t,n)=>{const{chatId:a,messageId:s,tabId:o=(0,m._w)()}=n;return(0,p.i)(e,{reactorModal:{chatId:a,messageId:s}},o)})),(0,a.iw)("closeReactorListModal",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{reactorModal:void 0},a)})),(0,a.iw)("openSeenByModal",((e,t,n)=>{const{chatId:a,messageId:s,tabId:o=(0,m._w)()}=n;return(0,p.i)(e,{seenByModal:{chatId:a,messageId:s}},o)})),(0,a.iw)("closeSeenByModal",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{seenByModal:void 0},a)})),(0,a.iw)("openMessageLanguageModal",((e,t,n)=>{const{chatId:a,id:s,tabId:o=(0,m._w)()}=n,i=(0,d.xx)(e,a,s,o);return(0,p.i)(e,{messageLanguageModal:{chatId:a,messageId:s,activeLanguage:i}},o)})),(0,a.iw)("closeMessageLanguageModal",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{messageLanguageModal:void 0},a)})),(0,a.iw)("copySelectedMessages",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n,s=(0,d.jU)(e,a);if(!s.selectedMessages)return;const{chatId:o,messageIds:i}=s.selectedMessages;M(e,o,i)})),(0,a.iw)("copyMessagesByIds",((e,t,n)=>{const{messageIds:a,tabId:s=(0,m._w)()}=n,o=(0,d.jr)(e,s);a&&0!==a.length&&o&&M(e,o.id,a)})),(0,a.iw)("setGlobalSearchQuery",((e,t,n)=>{const{query:a,tabId:s=(0,m._w)()}=n,{chatId:o}=(0,d.jU)(e,s).globalSearch;return(0,c.No)(e,{globalResults:{},localResults:{},resultsByType:void 0,...a?{fetchingStatus:{chats:!o,messages:!0}}:{fetchingStatus:void 0},query:a},s)})),(0,a.iw)("setGlobalSearchClosing",((e,t,n)=>{const{tabId:a=(0,m._w)(),isClosing:s}=n||{};return(0,c.No)(e,{isClosing:s},a)})),(0,a.iw)("addRecentlyFoundChatId",((e,t,n)=>{const{id:a}=n,{recentlyFoundChatIds:s}=e;if(!s)return{...e,recentlyFoundChatIds:[a]};const o=s.filter((e=>e!==a));return o.unshift(a),o.length>10&&o.pop(),{...e,recentlyFoundChatIds:o}})),(0,a.iw)("clearRecentlyFoundChats",(e=>({...e,recentlyFoundChatIds:void 0}))),(0,a.iw)("setGlobalSearchContent",((e,t,n)=>{const{content:a,tabId:s=(0,m._w)()}=n;return(0,c.Og)(e,a,s)})),(0,a.iw)("setGlobalSearchChatId",((e,t,n)=>{const{id:a,tabId:s=(0,m._w)()}=n;return(0,c.No)(e,{chatId:a,query:void 0,resultsByType:void 0},s)})),(0,a.iw)("setStickerSearchQuery",((e,t,n)=>{const{query:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{stickerSearch:{query:a,resultIds:void 0}},s)})),(0,a.iw)("setGifSearchQuery",((e,t,n)=>{const{query:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{gifSearch:{query:a,offset:void 0,results:void 0}},s)})),(0,a.iw)("setUserSearchQuery",((e,t,n)=>{const{query:a,tabId:s=(0,m._w)()}=n;return(0,c.Lm)(e,{globalUserIds:void 0,localUserIds:void 0,fetchingStatus:Boolean(a),query:a},s)})),(0,a.iw)("openAddContactDialog",((e,t,n)=>{const{userId:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{newContact:{userId:a}},s)})),(0,a.iw)("openNewContactDialog",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{newContact:{isByPhoneNumber:!0}},a)})),(0,a.iw)("closeNewContactDialog",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,c.ft)(e,a)})),n(73456);var R=n(91947),k=n(26926),T=n(16974);function A(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")}))}var N=n(69118);function x(e){document.title!==e&&(document.title=e)}const B=(0,N.Ds)(x,200,!1);let L;(0,a.iw)("toggleChatInfo",((e,t,n)=>{const{force:a,tabId:s=(0,m._w)()}=n||{},o=void 0!==a?a:!(0,d.jU)(e,s).isChatInfoShown;return e=(0,p.i)(e,{isChatInfoShown:o},s),{...e,lastIsChatInfoShown:o}})),(0,a.iw)("setLeftColumnWidth",((e,t,n)=>{const{leftColumnWidth:a}=n;return{...e,leftColumnWidth:a}})),(0,a.iw)("resetLeftColumnWidth",(e=>({...e,leftColumnWidth:void 0}))),(0,a.iw)("toggleManagement",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},{chatId:s}=(0,d.Bt)(e,a)||{};if(!s)return;const o=(0,d.jU)(e,a);return(0,p.i)(e,{management:{byChatId:{...o.management.byChatId,[s]:{...o.management.byChatId[s],isActive:!(o.management.byChatId[s]||{}).isActive}}}},a)})),(0,a.iw)("requestNextManagementScreen",((e,t,n)=>{const{screen:a,tabId:s=(0,m._w)()}=n||{},{chatId:o}=(0,d.Bt)(e,s)||{};if(!o)return;const i=(0,d.jU)(e,s);return(0,p.i)(e,{management:{byChatId:{...i.management.byChatId,[o]:{...i.management.byChatId[o],isActive:!0,nextScreen:a}}}},s)})),(0,a.iw)("closeManagement",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},{chatId:s}=(0,d.Bt)(e,a)||{};if(!s)return;const o=(0,d.jU)(e,a);return(0,p.i)(e,{management:{byChatId:{...o.management.byChatId,[s]:{...o.management.byChatId[s],isActive:!1}}}},a)})),(0,a.iw)("openChat",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n;if((0,C.W7)()||(0,C.c9)())return(0,p.i)(e,{isLeftColumnShown:0===(0,d.jU)(e,a).messageLists.length},a)})),(0,a.iw)("toggleStatistics",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},s=(0,d.jU)(e,a);return(0,p.i)(e,{isStatisticsShown:!s.isStatisticsShown,statistics:{...s.statistics,currentMessageId:void 0}},a)})),(0,a.iw)("toggleMessageStatistics",((e,t,n)=>{const{tabId:a=(0,m._w)(),messageId:s}=n||{};return(0,p.i)(e,{statistics:{...(0,d.jU)(e,a).statistics,currentMessageId:s}},a)})),(0,a.iw)("toggleLeftColumn",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{isLeftColumnShown:!(0,d.jU)(e,a).isLeftColumnShown},a)})),(0,a.iw)("addRecentEmoji",((e,t,n)=>{const{emoji:a}=n,{recentEmojis:s}=e;if(!s)return{...e,recentEmojis:[a]};const o=s.filter((e=>e!==a));return o.unshift(a),o.length>32&&o.pop(),{...e,recentEmojis:o}})),(0,a.iw)("addRecentSticker",((e,t,n)=>{const{sticker:a}=n,{recent:s}=e.stickers;if(!s)return{...e,stickers:{...e.stickers,recent:{hash:"0",stickers:[a]}}};const o=s.stickers.filter((e=>e.id!==a.id));return o.unshift(a),{...e,stickers:{...e.stickers,recent:{...s,stickers:o}}}})),(0,a.iw)("addRecentCustomEmoji",((e,t,n)=>{const{documentId:a}=n,{recentCustomEmojis:s}=e;if(!s)return{...e,recentCustomEmojis:[a]};const o=s.filter((e=>e!==a));return o.unshift(a),o.length>32&&o.pop(),{...e,recentCustomEmojis:o}})),(0,a.iw)("clearRecentCustomEmoji",(e=>({...e,recentCustomEmojis:[]}))),(0,a.iw)("reorderStickerSets",((e,t,n)=>{const{order:a,isCustomEmoji:s}=n;return{...e,stickers:{...e.stickers,added:{setIds:s?e.stickers.added.setIds:a}},customEmojis:{...e.customEmojis,added:{setIds:s?a:e.customEmojis.added.setIds}}}})),(0,a.iw)("showNotification",((e,t,n)=>{const{tabId:a=(0,m._w)(),...s}=n;s.localId=(0,k.Z)({});const o=[...(0,d.jU)(e,a).notifications],i=o.findIndex((e=>e.message===s.message));return-1!==i&&o.splice(i,1),o.push(s),(0,p.i)(e,{notifications:o},a)})),(0,a.iw)("showAllowedMessageTypesNotification",((e,t,n)=>{const{chatId:a,tabId:s=(0,m._w)()}=n,o=(0,d.Z1)(e,a);if(!o)return;const{canSendPlainText:i,canSendPhotos:r,canSendVideos:c,canSendDocuments:l,canSendAudios:h,canSendStickers:p,canSendRoundVideos:g,canSendVoices:f}=(0,u.H5)(o),v=(0,I.oA)([i?"Chat.SendAllowedContentTypeText":void 0,r?"Chat.SendAllowedContentTypePhoto":void 0,c?"Chat.SendAllowedContentTypeVideo":void 0,f?"Chat.SendAllowedContentTypeVoiceMessage":void 0,g?"Chat.SendAllowedContentTypeVideoMessage":void 0,l?"Chat.SendAllowedContentTypeFile":void 0,h?"Chat.SendAllowedContentTypeMusic":void 0,p?"Chat.SendAllowedContentTypeSticker":void 0]).map((e=>b.Iu(e)));if(!v.length)return void t.showNotification({message:b.Iu("Chat.SendNotAllowedText"),tabId:s});const w=b.Iu("AutoDownloadSettings.LastDelimeter"),y=v.join(", ").replace(/,([^,]*)$/,`${w}$1`);t.showNotification({message:b.Iu("Chat.SendAllowedContentText",y),tabId:s})})),(0,a.iw)("dismissNotification",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n,s=(0,d.jU)(e,a).notifications.filter((e=>{let{localId:t}=e;return t!==n.localId}));return(0,p.i)(e,{notifications:s},a)})),(0,a.iw)("showDialog",((e,t,n)=>{const{data:a,tabId:s=(0,m._w)()}=n;if("message"in a&&a.hasErrorKey&&!(0,R.ZP)(a))return e;const o=[...(0,d.jU)(e,s).dialogs];if("message"in a){const e=o.findIndex((e=>e.message===a.message));-1!==e&&o.splice(e,1)}return o.push(a),(0,p.i)(e,{dialogs:o},s)})),(0,a.iw)("dismissDialog",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},s=[...(0,d.jU)(e,a).dialogs];return s.pop(),(0,p.i)(e,{dialogs:s},a)})),(0,a.iw)("toggleSafeLinkModal",((e,t,n)=>{const{url:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{safeLinkModalUrl:a},s)})),(0,a.iw)("openHistoryCalendar",((e,t,n)=>{const{selectedAt:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{historyCalendarSelectedAt:a},s)})),(0,a.iw)("closeHistoryCalendar",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{historyCalendarSelectedAt:void 0},a)})),(0,a.iw)("openGame",((e,t,n)=>{const{url:s,chatId:o,messageId:i,tabId:r=(0,m._w)()}=n,c=(0,d.hj)(e,o,i);if(!c)return;const l=c.viaBotId||c.senderId;if(l){if(!(0,d.LM)(e,l))return e=(0,p.i)(e,{botTrustRequest:{botId:l,type:"game",onConfirm:{action:"openGame",payload:n}}},r),void(0,a.R3)(e);e=(0,p.i)(e,{openedGame:{url:s,chatId:o,messageId:i}},r),(0,a.R3)(e)}})),(0,a.iw)("closeGame",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{openedGame:void 0},a)})),(0,a.iw)("requestConfetti",((e,t,n)=>{const{top:a,left:s,width:o,height:i,tabId:r=(0,m._w)()}=n||{},{animationLevel:c}=e.settings.byKey;if(0!==c)return(0,p.i)(e,{confetti:{lastConfettiTime:Date.now(),top:a,left:s,width:o,height:i}},r)})),(0,a.iw)("updateAttachmentSettings",((e,t,n)=>{const{shouldCompress:a,shouldSendGrouped:s}=n;return{...e,attachmentSettings:{shouldCompress:null!=a?a:e.attachmentSettings.shouldCompress,shouldSendGrouped:null!=s?s:e.attachmentSettings.shouldSendGrouped}}})),(0,a.iw)("openLimitReachedModal",((e,t,n)=>{const{limit:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{limitReachedModal:{limit:a}},s)})),(0,a.iw)("closeLimitReachedModal",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{limitReachedModal:void 0},a)})),(0,a.iw)("closeStickerSetModal",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{openedStickerSetShortName:void 0},a)})),(0,a.iw)("openCustomEmojiSets",((e,t,n)=>{const{setIds:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{openedCustomEmojiSetIds:a},s)})),(0,a.iw)("closeCustomEmojiSets",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{openedCustomEmojiSetIds:void 0},a)})),(0,a.iw)("updateLastRenderedCustomEmojis",((e,t,n)=>{const{ids:a}=n,{lastRendered:s}=e.customEmojis;return{...e,customEmojis:{...e.customEmojis,lastRendered:(0,I.Tw)([...s,...a]).slice(0,o.j7i)}}})),(0,a.iw)("openCreateTopicPanel",((e,t,n)=>{const{chatId:a,tabId:s=(0,m._w)()}=n;return(0,d.jr)(e,s)||t.openChat({id:a,threadId:r._f,tabId:s}),(0,p.i)(e,{createTopicPanel:{chatId:a}},s)})),(0,a.iw)("closeCreateTopicPanel",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{createTopicPanel:void 0},a)})),(0,a.iw)("openEditTopicPanel",((e,t,n)=>{const{chatId:a,topicId:s,tabId:o=(0,m._w)()}=n;return(0,d.jr)(e,o)||t.openChat({id:a,tabId:o}),(0,p.i)(e,{editTopicPanel:{chatId:a,topicId:s}},o)})),(0,a.iw)("closeEditTopicPanel",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{editTopicPanel:void 0},a)})),(0,a.iw)("updateArchiveSettings",((e,t,n)=>{const{archiveSettings:a}=e,{isHidden:s=a.isHidden,isMinimized:o=a.isMinimized}=n;return{...e,archiveSettings:{isHidden:s,isMinimized:o}}})),(0,a.iw)("checkAppVersion",(e=>{const t=/^\d+\.\d+(\.\d+)?$/;fetch(`version.txt?${Date.now()}`).then((e=>e.text())).then((n=>{n=n.trim(),t.test(n)&&n!==o.JiC&&(e=(0,a.Rd)(),e={...e,isUpdateAvailable:!0},(0,a.R3)(e))})).catch((e=>{o.eMD&&console.error("[checkAppVersion failed] ",e)}))})),(0,a.iw)("afterHangUp",(e=>{(0,d.jU)(e,(0,m._w)()).multitabNextAction&&(0,m.g)()})),(0,a.iw)("onTabFocusChange",((e,t,n)=>{const{isBlurred:a,tabId:s=(0,m._w)()}=n;a||t.updateIsOnline(!0);const o=(0,I.Tw)(a?[...e.blurredTabTokens,s]:e.blurredTabTokens.filter((e=>e!==s)));return o.length===(0,m.s1)().length&&t.updateIsOnline(!1),a?(L&&clearInterval(L),L=window.setInterval((()=>{t.updatePageTitle({tabId:s})}),500)):(clearInterval(L),L=void 0),{...e,blurredTabTokens:o,initialUnreadNotifications:a?(0,T.xW)():void 0}})),(0,a.iw)("updatePageTitle",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},{canDisplayChatInTitle:s}=e.settings.byKey,i=e.currentUserId;if(document.title.includes(o.ouc))return A(!1),void x(`${o.Tih} ${o.ouc}`);if(e.initialUnreadNotifications&&Math.round(Date.now()/1e3)%2==0){const t=(0,T.xW)()-e.initialUnreadNotifications;if(t>0)return x(`${t} notification${t>1?"s":""}`),void A(!0)}A(!1);const r=(0,d.Bt)(e,a);if(r&&s){const{chatId:t,threadId:n}=r,a=(0,d.Z1)(e,t);if(a){const e=(0,u.U)(b.Iu,a,void 0,t===i);return a.isForum&&a.topics?.[n]?void B(`${e} ${a.topics[n].title}`):void B(e)}}x(o.Tih)})),(0,a.iw)("closePaymentModal",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},s=(0,d.jU)(e,a).payment.status;return e=(0,c.bp)(e,a),e=(0,c.WY)(e,a),(0,p.i)(e,{payment:{...(0,d.jU)(e,a).payment,status:s}},a)})),(0,a.iw)("addPaymentError",((e,t,n)=>{const{error:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{payment:{...(0,d.jU)(e,s).payment,status:"failed",error:a}},s)}));var U=n(88422);(0,a.iw)("openMediaViewer",((e,t,n)=>{const{chatId:a,threadId:s,mediaId:o,avatarOwnerId:i,profilePhotoIndex:r,origin:c,volume:l,playbackRate:u,isMuted:h,tabId:g=(0,m._w)()}=n,f=(0,d.jU)(e,g);return(0,p.i)(e,{mediaViewer:{...f.mediaViewer,chatId:a,threadId:s,mediaId:o,avatarOwnerId:i,profilePhotoIndex:r,origin:c,isHidden:!1,volume:null!=l?l:f.mediaViewer.volume,playbackRate:u||f.mediaViewer.playbackRate||e.mediaViewer.lastPlaybackRate,isMuted:h||f.mediaViewer.isMuted},forwardMessages:{}},g)})),(0,a.iw)("closeMediaViewer",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},{volume:s,isMuted:o,playbackRate:i,isHidden:r}=(0,d.jU)(e,a).mediaViewer;return(0,p.i)(e,{mediaViewer:{volume:s,isMuted:o,isHidden:r,playbackRate:i}},a)})),(0,a.iw)("setMediaViewerVolume",((e,t,n)=>{const{volume:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{mediaViewer:{...(0,d.jU)(e,s).mediaViewer,volume:a,isMuted:!1}},s)})),(0,a.iw)("setMediaViewerPlaybackRate",((e,t,n)=>{const{playbackRate:a,tabId:s=(0,m._w)()}=n;return e={...e,mediaViewer:{...e.mediaViewer,lastPlaybackRate:a}},(0,p.i)(e,{mediaViewer:{...(0,d.jU)(e,s).mediaViewer,playbackRate:a}},s)})),(0,a.iw)("setMediaViewerMuted",((e,t,n)=>{const{isMuted:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{mediaViewer:{...(0,d.jU)(e,s).mediaViewer,isMuted:a}},s)})),(0,a.iw)("setMediaViewerHidden",((e,t,n)=>{const{isHidden:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{mediaViewer:{...(0,d.jU)(e,s).mediaViewer,isHidden:a}},s)}));var j=n(50214),O=n(95281),F=n(5872),_=n(35369);let D=!1;(0,N.Gq)((()=>{(0,a.Rd)().passcode.hasPasscode&&!D&&1===Object.keys((0,a.Rd)().byTabId).length&&(0,j.jv)()})),(0,a.iw)("setPasscode",(async(e,t,n)=>{const{passcode:s}=n;e=(0,c.vu)(e,{isLoading:!0}),(0,a.R3)(e),await(0,O.AU)(s);const o=JSON.stringify({...(0,j.K8)(),userId:e.currentUserId});e=(0,a.Rd)();const i=(0,F.Uf)((0,c.vu)(e,{hasPasscode:!0,error:void 0,isLoading:!1}));await(0,O.H4)(o,i),(0,m.Z6)(),e=(0,a.Rd)(),e=(0,c.vu)(e,{hasPasscode:!0,error:void 0,isLoading:!1}),(0,a.R3)(e),(0,F.jA)(!0)})),(0,a.iw)("clearPasscode",(e=>((0,O.C8)(),(0,c.Kn)(e)))),(0,a.iw)("unlockScreen",((e,t,n)=>{const s=Object.values(e.byTabId),{sessionJson:o,globalJson:i}=n,r=JSON.parse(o);(0,j.wX)(r,r.userId);const d=e;(e=JSON.parse(i)).byTabId=d.byTabId,(0,F.nE)(e,(0,I.Xh)(_.g)),e=(0,c.vu)(e,{isScreenLocked:!1,error:void 0,invalidAttemptsCount:0}),(0,a.R3)(e),(0,m.Z6)(),s.forEach((e=>{let{id:n,isMasterTab:a}=e;return t.init({tabId:n,isMasterTab:a})})),t.initApi()})),(0,a.iw)("decryptSession",((e,t,n)=>{const{passcode:a}=n;(0,O.so)(a).then(t.unlockScreen,(()=>{t.logInvalidUnlockAttempt()}))})),(0,a.iw)("logInvalidUnlockAttempt",(e=>{var t;return(0,c.vu)(e,{invalidAttemptsCount:(null!==(t=e.passcode?.invalidAttemptsCount)&&void 0!==t?t:0)+1})})),(0,a.iw)("resetInvalidUnlockAttempts",(e=>(0,c.vu)(e,{invalidAttemptsCount:0}))),(0,a.iw)("setPasscodeError",((e,t,n)=>{const{error:a}=n;return(0,c.vu)(e,{error:a})})),(0,a.iw)("clearPasscodeError",(e=>(0,c.vu)(e,{error:void 0}))),(0,a.iw)("skipLockOnUnload",(()=>{D=!0})),n(65456);var q=n(27225),$=n(71226),G=n(81396);const H=new Map,V=(0,N.Ds)((e=>e()),500,!1);async function z(e,t,n,s,i){let r=arguments.length>5&&void 0!==arguments[5]&&arguments[5],l=arguments.length>6&&void 0!==arguments[6]&&arguments[6];for(var u=arguments.length,h=new Array(u>7?u-7:0),p=7;p<u;p++)h[p-7]=arguments[p];let[g=(0,m._w)()]=h;const v=t.id;let w;switch(i){case f.Uq.Backwards:w=void 0;break;case f.Uq.Around:w=-(Math.round(o.hT6/2)+1);break;case f.Uq.Forwards:w=-(o.hT6+1)}e=(0,a.Rd)();const b=await(0,$.t9)("fetchMessages",{chat:(0,d.Z1)(e,v),offsetId:s,addOffset:w,limit:o.hT6,threadId:n});if(!b)return;const{messages:y,users:P,chats:Z,repliesThreadInfos:C}=b;e=(0,a.Rd)();const S=v===o.awM?e.serviceNotifications.filter((e=>{let{isDeleted:t}=e;return!t})).map((e=>{let{message:t}=e;return t})):[],E=[].concat(y,S),M=(0,I.ee)(E,"id"),R=Object.keys(M).map(Number);e=(0,c.c_)(e,v,M),e=r?(0,c.ff)(e,v,n,R,g):(0,c.xj)(e,v,n,R),e=(0,c.Sh)(e,(0,I.ee)(P,"id")),e=(0,c.fZ)(e,(0,I.ee)(Z,"id")),e=(0,c.j6)(e,v,C);let k=(0,d.gb)(e,v,n);const T=(0,d.qC)(e,v,n,g);if(r&&k&&T&&(T.length&&!(0,I.YE)(k,T)||(e=(0,c.xj)(e,v,n,T),k=(0,d.gb)(e,v,n),e=(0,c.O8)(e,v,n,"outlyingIds",void 0,g),r=!1)),!l){const t=r?T:k,{newViewportIds:a}=W(t,s,i);e=(0,c.y9)(e,v,n,a,g)}(0,a.R3)(e)}function W(e,t,n){const{length:a}=e,s=t?function(e,t){return t<e[0]?0:t>e[e.length-1]?e.length-1:e.findIndex(((n,a)=>n===t||n<t&&e[a+1]>t))}(e,t):-1,i=n===f.Uq.Backwards?s:s+1||a,r=i-o.hT6,c=i+o.hT6-1,d=e.slice(Math.max(0,r),c+1);let l,u;switch(n){case f.Uq.Backwards:l=i>0,u=r>=0;break;case f.Uq.Forwards:l=i<a,u=c<=a-1;break;case f.Uq.Around:default:l=d.length>0,u=d.length===o.hT6}return{newViewportIds:d,areSomeLocal:l,areAllLocal:u}}async function X(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];let c,[l=(0,m._w)()]=o;const u=t.attachment?(t,n)=>{H.has(n)||(c=n,H.set(n,u)),e=(0,a.Rd)(),e={...e,fileUploads:{byMessageLocalId:{...e.fileUploads.byMessageLocalId,[n]:{progress:t}}}},(0,a.R3)(e)}:void 0;(t.replyingTo||s.cj)&&await(0,N.Pn)(),e=(0,a.Rd)();const h=(0,d.Bt)(e,l);if(!h)return;const{threadId:p}=h;t.replyingTo||p===r._f||(t.replyingTo=(0,d.qS)(e,t.chat.id,p)),t.replyingTo&&!t.replyingToTopId&&p!==r._f&&(t.replyingToTopId=(0,d.qS)(e,t.chat.id,p)),await(0,$.t9)("sendMessage",t,u),u&&c&&H.delete(c)}function Y(e){const{shouldSendAsFile:t,mimeType:n}=e;return t?"file":o.oGt.has(n)||o.wGh.has(n)?"media":o.e74.has(n)?"audio":e.voice?"voice":"file"}(0,a.iw)("loadViewportMessages",((e,t,n)=>{const{direction:a=f.Uq.Around,isBudgetPreload:s=!1,tabId:i=(0,m._w)()}=n||{};let{chatId:r,threadId:l}=n||{};if(!r||!l){const t=(0,d.Bt)(e,i);if(!t)return;r=t.chatId,l=t.threadId}const u=(0,d.Z1)(e,r);if(!u||u.isRestricted)return;const h=(0,d.Cb)(e,r,l,i),p=(0,d.gb)(e,r,l),g=(0,d.qC)(e,r,l,i);if(h&&h.length&&a!==f.Uq.Around){const n=a===f.Uq.Backwards?h[0]:h[h.length-1],o=Boolean(g),d=o?g:p,{newViewportIds:I,areSomeLocal:v,areAllLocal:w}=W(d,n,a);if(v&&(e=(0,c.y9)(e,r,l,I,i)),(0,N.R3)((()=>{!async function(e,t,n,a,s,o,i,r,c){for(var d=arguments.length,l=new Array(d>9?d-9:0),u=9;u<d;u++)l[u-9]=arguments[u];let[h=(0,m._w)()]=l;n||await z(e,o,i,c,r,a,s,h),s||t.loadViewportMessages({chatId:o.id,threadId:i,direction:r,isBudgetPreload:!0,tabId:h})}(e,t,w,o,s,u,l,a,n,i)})),s)return}else{const t=(0,d.G$)(e,r,i)||(0,d.rd)(e,r,l),n=Boolean(t&&p&&!p.includes(t)),a=(n?g:p)||[],{newViewportIds:m,areSomeLocal:h,areAllLocal:I}=W(a,t,f.Uq.Around);h&&m.length>=o.hT6&&(e=(0,c.y9)(e,r,l,m,i)),I||(0,N.R3)((()=>{z(e,u,l,t,f.Uq.Around,n,s,i)}))}return e})),(0,a.iw)("loadMessage",(async(e,t,n)=>{const{chatId:s,messageId:o,replyOriginForId:i,threadUpdate:l}=n,u=(0,d.Z1)(e,s);if(!u)return;const m=await async function(e,t,n,s){const o=await(0,$.t9)("fetchMessage",{chat:t,messageId:n});if(o){if(o!==r._Q)return e=(0,a.Rd)(),e=(0,c.cY)(e,t.id,n,o.message),e=(0,c.Sh)(e,(0,I.ee)(o.users,"id")),(0,a.R3)(e),o.message;if(s){e=(0,a.Rd)();const n=(0,d.hj)(e,t.id,s);e=(0,c.cY)(e,t.id,s,{...n,replyToMessageId:void 0}),(0,a.R3)(e)}}}(e,u,o,i);if(m&&l){const{lastMessageId:t,isDeleting:n}=l;e=(0,a.Rd)(),e=(0,c.lG)(e,m,s,t,n),(0,a.R3)(e)}})),(0,a.iw)("sendMessage",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n,s=(0,d.Bt)(e,a);if(!s)return;const{chatId:i,threadId:r,type:c}=s;if(n=(0,I.CE)(n,["tabId"]),"scheduled"===c&&!n.scheduledAt)return(0,p.i)(e,{contentToBeScheduled:n},a);const l=(0,d.Z1)(e,i),u=(0,d.Yy)(e,i,r),h=u?(0,d.hj)(e,i,u):void 0,g=l.isForum?(0,d.qS)(e,i,r):h?.replyToTopMessageId||h?.replyToMessageId,f={...n,chat:l,replyingTo:u,replyingToTopId:g,noWebPage:(0,d.tV)(e,i,r),sendAs:(0,d._5)(e,i)};t.setReplyingToId({messageId:void 0,tabId:a}),t.clearWebPagePreview({tabId:a});const v=!n.attachments||n.attachments.length<=1,w=!v&&n.shouldGroupMessages;if(v){const{attachments:t,...n}=f;X(e,{...n,attachment:t?t[0]:void 0},a)}else if(w){const{text:t,entities:n,attachments:s,...i}=f,r=function(e){return e.reduce(((e,t,n,a)=>0===n?(e.push([t]),e):(Y(t)===Y(a[n-1])?e[e.length-1].push(t):e.push([t]),e)),[])}(s);r.forEach(((s,r)=>{const c=(0,I.Vl)(s,o.DUi);for(let s=0;s<c.length;s++){const[o,...d]=c[s],l=`${Date.now()}${r}${s}`,u=0===s&&0===r;X(e,{...i,text:u?t:void 0,entities:u?n:void 0,attachment:o,groupedId:d.length>0?l:void 0},a),d.forEach((t=>{X(e,{...i,attachment:t,groupedId:l},a)}))}}))}else{const{text:t,entities:n,attachments:s,replyingTo:o,...i}=f;t&&X(e,{...i,text:t,entities:n,replyingTo:o},a),s?.forEach((t=>{X(e,{...i,attachment:t},a)}))}})),(0,a.iw)("editMessage",((e,t,n)=>{const{text:a,entities:s,tabId:o=(0,m._w)()}=n,i=(0,d.Bt)(e,o);if(!i)return;const{chatId:r,threadId:c,type:l}=i,u=(0,d.Z1)(e,r),h=(0,d.kK)(e,r,c,l);u&&h&&((0,$.t9)("editMessage",{chat:u,message:h,text:a,entities:s,noWebPage:(0,d.tV)(e,r,c)}),t.setEditingId({messageId:void 0,tabId:o}))})),(0,a.iw)("cancelSendingMessage",((e,t,n)=>{const{chatId:a,messageId:s}=n,o=(0,d.hj)(e,a,s),i=o&&H.get((0,u.KK)(o));i&&(0,$.u3)(i),t.apiUpdate({"@type":"deleteMessages",ids:[s],chatId:a})})),(0,a.iw)("saveDraft",(async(e,t,n)=>{const{chatId:s,threadId:o,draft:i,shouldForce:r}=n;if(!i)return;const{text:l,entities:m}=i,h=(0,d.Z1)(e,s),p=(0,d.dy)(e,s);p&&(0,u.NB)(p)||(i.isLocal=!0,i.shouldForce=r,e=(0,c.pf)(e,s,o,"draft",i),e=(0,c.a4)(e,s,{draftDate:Math.round(Date.now()/1e3)}),(0,a.R3)(e),await(0,$.t9)("saveDraft",{chat:h,text:l,entities:m,replyToMsgId:(0,d.Yy)(e,s,o),threadId:(0,d.qS)(e,s,o)})&&(i.isLocal=!1),e=(0,a.Rd)(),e=(0,c.pf)(e,s,o,"draft",i),e=(0,c.a4)(e,s,{draftDate:Math.round(Date.now()/1e3)}),(0,a.R3)(e))})),(0,a.iw)("clearDraft",((e,t,n)=>{const{chatId:a,threadId:s=r._f,localOnly:o,shouldForce:i}=n;if(!(0,d.Ms)(e,a,s))return;const l=(0,d.Z1)(e,a);o||(0,$.t9)("clearDraft",l,(0,d.qS)(e,a,s));const u=i?{shouldForce:i,text:""}:void 0;return e=(0,c.pf)(e,a,s,"draft",u),(0,c.a4)(e,a,{draftDate:void 0})})),(0,a.iw)("toggleMessageWebPage",((e,t,n)=>{const{chatId:a,threadId:s,noWebPage:o}=n;return(0,c.pf)(e,a,s,"noWebPage",o)})),(0,a.iw)("pinMessage",((e,t,n)=>{const{messageId:a,isUnpin:s,isOneSide:o,isSilent:i,tabId:r=(0,m._w)()}=n,c=(0,d.jr)(e,r);c&&(0,$.t9)("pinMessage",{chat:c,messageId:a,isUnpin:s,isOneSide:o,isSilent:i})})),(0,a.iw)("unpinAllMessages",(async(e,t,n)=>{const{chatId:s,threadId:o}=n,i=(0,d.Z1)(e,s);if(!i)return;const l=(0,d.qS)(e,s,o);await(0,$.t9)("unpinAllMessages",{chat:i,threadId:l}),e=(0,a.Rd)(),e=(0,c.pf)(e,i.id,r._f,"pinnedIds",[]),(0,a.R3)(e)})),(0,a.iw)("deleteMessages",((e,t,n)=>{const{messageIds:a,shouldDeleteForAll:s,tabId:o=(0,m._w)()}=n,i=(0,d.Bt)(e,o);if(!i)return;const{chatId:r,threadId:c}=i,l=(0,d.Z1)(e,r);(0,$.t9)("deleteMessages",{chat:l,messageIds:a,shouldDeleteForAll:s});const u=(0,d._$)(e,r,c);u&&a.includes(u)&&t.setEditingId({messageId:void 0,tabId:o})})),(0,a.iw)("deleteScheduledMessages",((e,t,n)=>{const{messageIds:a,tabId:s=(0,m._w)()}=n,o=(0,d.Bt)(e,s);if(!o)return;const{chatId:i}=o,r=(0,d.Z1)(e,i);(0,$.t9)("deleteScheduledMessages",{chat:r,messageIds:a});const c=(0,d.wU)(e,i);c&&a.includes(c)&&t.setEditingId({messageId:void 0,tabId:s})})),(0,a.iw)("deleteHistory",(async(e,t,n)=>{const{chatId:s,shouldDeleteForAll:o,tabId:i=(0,m._w)()}=n,r=(0,d.Z1)(e,s);if(!r)return;await(0,$.t9)("deleteHistory",{chat:r,shouldDeleteForAll:o}),e=(0,a.Rd)();const c=(0,d.Bt)(e,i);c&&c.chatId===s&&t.openChat({id:void 0,tabId:i})})),(0,a.iw)("reportMessages",(async(e,t,n)=>{const{messageIds:a,reason:s,description:o,tabId:i=(0,m._w)()}=n,r=(0,d.Bt)(e,i);if(!r)return;const{chatId:c}=r,l=(0,d.Z1)(e,c),u=await(0,$.t9)("reportMessages",{peer:l,messageIds:a,reason:s,description:o});t.showNotification({message:u?(0,b.Iu)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later.",tabId:i})})),(0,a.iw)("sendMessageAction",(async(e,t,n)=>{const{action:a,chatId:s,threadId:o}=n;if(s===e.currentUserId)return;const i=(0,d.Z1)(e,s);if(!i)return;const r=(0,d.dy)(e,s);r&&((0,u.cS)(r)||(0,u.NB)(r))||await(0,$.t9)("sendMessageAction",{peer:i,threadId:o,action:a})})),(0,a.iw)("markMessageListRead",((e,t,n)=>{const{maxId:a,tabId:s=(0,m._w)()}=n,i=(0,d.Bt)(e,s);if(!i)return;const{chatId:l,threadId:u}=i,h=(0,d.Z1)(e,l);if(!h)return;V((()=>{(0,$.t9)("markMessageListRead",{chat:h,threadId:u,maxId:a})})),l===o.awM&&(e={...e,serviceNotifications:e.serviceNotifications.map((e=>e.isUnread&&e.id<=a?{...e,isUnread:!1}:e))});const p=(0,d.Cb)(e,l,u,s),g=(0,d.It)(e,l,u,s);if(!p||!g||!h.unreadCount)return e;const f=function(e,t,n){let a=0;for(let s=0,o=e.length;s<o&&(e[s]>=t&&e[s]<=n&&a++,!(e[s]>=n));s++);return a}(p,g,a);if(!f)return e;if(h.isForum&&h.topics?.[u]){const t=h.topics[u];e=(0,c.Xg)(e,l,u,{lastReadInboxMessageId:a});const n=Math.max(0,t.unreadCount-f);return 0===n&&(e=(0,c.a4)(e,l,{unreadCount:Math.max(0,h.unreadCount-1)})),(0,c.Cn)(e,l,u,{unreadCount:n})}return u===r._f?(0,c.a4)(e,l,{lastReadInboxMessageId:a,unreadCount:Math.max(0,h.unreadCount-f)}):void 0})),(0,a.iw)("markMessagesRead",((e,t,n)=>{const{messageIds:a,tabId:s=(0,m._w)()}=n,o=(0,d.jr)(e,s);o&&(0,$.t9)("markMessagesRead",{chat:o,messageIds:a})})),(0,a.iw)("loadWebPagePreview",(async(e,t,n)=>{const{text:s,tabId:o=(0,m._w)()}=n,i=await(0,$.t9)("fetchWebPagePreview",{message:s});e=(0,a.Rd)(),e=(0,p.i)(e,{webPagePreview:i},o),(0,a.R3)(e)})),(0,a.iw)("clearWebPagePreview",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};if((0,d.jU)(e,a).webPagePreview)return(0,p.i)(e,{webPagePreview:void 0},a)})),(0,a.iw)("sendPollVote",((e,t,n)=>{const{chatId:a,messageId:s,options:o}=n,i=(0,d.Z1)(e,a);i&&(0,$.t9)("sendPollVote",{chat:i,messageId:s,options:o})})),(0,a.iw)("cancelPollVote",((e,t,n)=>{const{chatId:a,messageId:s}=n,o=(0,d.Z1)(e,a);o&&(0,$.t9)("sendPollVote",{chat:o,messageId:s,options:[]})})),(0,a.iw)("closePoll",((e,t,n)=>{const{chatId:a,messageId:s}=n,o=(0,d.Z1)(e,a),i=(0,d.hj)(e,a,s)?.content.poll;o&&i&&(0,$.t9)("closePoll",{chat:o,messageId:s,poll:i})})),(0,a.iw)("loadPollOptionResults",(async(e,t,n)=>{const{chat:s,messageId:o,option:i,offset:r,limit:l,shouldResetVoters:u,tabId:h=(0,m._w)()}=n,g=await(0,$.t9)("loadPollOptionResults",{chat:s,messageId:o,option:i,offset:r,limit:l});if(!g)return;e=(0,a.Rd)(),e=(0,c.Sh)(e,(0,I.ee)(g.users,"id"));const f=(0,d.jU)(e,h),{pollResults:v}=f,{voters:w}=f.pollResults;e=(0,p.i)(e,{pollResults:{...v,voters:{...w,[i]:(0,I.Tw)([...!u&&w&&w[i]?w[i]:[],...g&&g.users.map((e=>e.id))])},offsets:{...v.offsets?v.offsets:{},[i]:g.nextOffset||""}}},h),(0,a.R3)(e)})),(0,a.iw)("loadExtendedMedia",((e,t,n)=>{const{chatId:a,ids:s}=n,o=(0,d.Z1)(e,a);o&&(0,$.t9)("fetchExtendedMedia",{chat:o,ids:s})})),(0,a.iw)("forwardMessages",((e,t,n)=>{const{isSilent:s,scheduledAt:o,tabId:i=(0,m._w)()}=n,{fromChatId:r,messageIds:c,toChatId:l,withMyScore:h,noAuthors:g,noCaptions:f,toThreadId:I}=(0,d.jU)(e,i).forwardMessages,v=(0,d.wV)(e),w=r?(0,d.Z1)(e,r):void 0,b=l?(0,d.Z1)(e,l):void 0,y=r&&c?c.sort(((e,t)=>e-t)).map((t=>(0,d.hj)(e,r,t))).filter(Boolean):void 0;if(!w||!b||!y||I&&!b.isForum)return;const P=(0,d._5)(e,l),Z=y.filter((e=>!(0,u.jM)(e)));Z.length&&(0,$.t9)("forwardMessages",{fromChat:w,toChat:b,toThreadId:I,messages:Z,isSilent:s,scheduledAt:o,sendAs:P,withMyScore:h,noAuthors:g,noCaptions:f,isCurrentUserPremium:v}),y.filter((e=>(0,u.jM)(e))).forEach((t=>{const{text:n,entities:a}=t.content.text||{},{sticker:r,poll:c}=t.content;X(e,{chat:b,replyingToTopId:I,text:n,entities:a,sticker:r,poll:c,isSilent:s,scheduledAt:o,sendAs:P},i)})),e=(0,a.Rd)(),e=(0,p.i)(e,{forwardMessages:{}},i),(0,a.R3)(e)})),(0,a.iw)("loadScheduledHistory",(async(e,t,n)=>{const{chatId:s}=n,o=(0,d.Z1)(e,s);if(!o)return;const i=await(0,$.t9)("fetchScheduledHistory",{chat:o});if(!i)return;const{messages:l}=i,u=(0,I.ee)(l,"id"),m=Object.keys(u).map(Number).sort(((e,t)=>t-e));if(e=(0,a.Rd)(),e=(0,c.w3)(e,o.id,u),e=(0,c.pf)(e,o.id,r._f,"scheduledIds",m),o?.isForum){const t={};l.forEach((n=>{const a=(0,d.nr)(e,n),s=t[a]||[];s.push(n.id),t[a]=s})),Object.entries(t).forEach((t=>{let[n,a]=t;e=(0,c.pf)(e,o.id,Number(n),"scheduledIds",a)}))}(0,a.R3)(e)})),(0,a.iw)("sendScheduledMessages",((e,t,n)=>{const{chatId:a,id:s}=n,o=(0,d.Z1)(e,a);o&&(0,$.t9)("sendScheduledMessages",{chat:o,ids:[s]})})),(0,a.iw)("rescheduleMessage",((e,t,n)=>{const{chatId:a,messageId:s,scheduledAt:o}=n,i=(0,d.Z1)(e,a),r=i&&(0,d.Tm)(e,i.id,s);i&&r&&(0,$.t9)("rescheduleMessage",{chat:i,message:r,scheduledAt:o})})),(0,a.iw)("requestThreadInfoUpdate",(async(e,t,n)=>{const{chatId:s,threadId:o}=n,i=(0,d.Z1)(e,s);if(!i)return;const r=await(0,$.t9)("requestThreadInfoUpdate",{chat:i,threadId:o});r&&(e=(0,a.Rd)(),e=(0,c.Sh)(e,(0,I.ee)(r.users,"id")),(0,a.R3)(e))})),(0,a.iw)("transcribeAudio",(async(e,t,n)=>{const{messageId:s,chatId:o}=n,i=(0,d.Z1)(e,o);if(!i)return;e=(0,c.cY)(e,o,s,{transcriptionId:""}),(0,a.R3)(e);const r=await(0,$.t9)("transcribeAudio",{chat:i,messageId:s});e=(0,a.Rd)(),e=(0,c.cY)(e,o,s,{transcriptionId:r,isTranscriptionError:!r}),(0,a.R3)(e)})),(0,a.iw)("loadCustomEmojis",(async(e,t,n)=>{const{ids:s,ignoreCache:o}=n,i=o?s:(0,I.Tw)(s.filter((t=>!e.customEmojis.byId[t]))),r=await(0,$.t9)("fetchCustomEmoji",{documentId:i});r&&(e=(0,a.Rd)(),e={...e,customEmojis:{...e.customEmojis,byId:{...e.customEmojis.byId,...(0,I.ee)(r,"id")}}},(0,a.R3)(e))})),(0,a.iw)("loadPinnedMessages",(async(e,t,n)=>{const{chatId:s,threadId:o}=n,i=(0,d.Z1)(e,s);if(!i)return;const r=await(0,$.t9)("fetchPinnedMessages",{chat:i,threadId:o});if(!r)return;const{messages:l,chats:u,users:m}=r,h=(0,I.ee)(l,"id"),p=Object.keys(h).map(Number).sort(((e,t)=>t-e));e=(0,a.Rd)(),e=(0,c.c_)(e,i.id,h),e=(0,c.pf)(e,i.id,o,"pinnedIds",p),e=(0,c.Sh)(e,(0,I.ee)(m,"id")),e=(0,c.fZ)(e,(0,I.ee)(u,"id")),(0,a.R3)(e)})),(0,a.iw)("loadSeenBy",(async(e,t,n)=>{const{chatId:s,messageId:o}=n,i=(0,d.Z1)(e,s);if(!i)return;const r=await(0,$.t9)("fetchSeenBy",{chat:i,messageId:o});r&&(e=(0,a.Rd)(),e=(0,c.cY)(e,s,o,{seenByUserIds:r}),(0,a.R3)(e))})),(0,a.iw)("saveDefaultSendAs",((e,t,n)=>{const{chatId:a,sendAsId:s}=n,o=(0,d.Z1)(e,a),i=(0,d.Z1)(e,s)||(0,d.dy)(e,s);if(o&&i)return(0,$.t9)("saveDefaultSendAs",{sendAs:i,chat:o}),(0,c.a4)(e,a,{fullInfo:{...o.fullInfo,sendAsId:s}})})),(0,a.iw)("loadSendAs",(async(e,t,n)=>{const{chatId:s}=n,o=(0,d.Z1)(e,s);if(!o)return;const i=await(0,$.t9)("fetchSendAs",{chat:o});if(!i)return e=(0,a.Rd)(),e=(0,c.a4)(e,s,{sendAsPeerIds:[]}),void(0,a.R3)(e);e=(0,a.Rd)(),e=(0,c.Sh)(e,(0,I.ee)(i.users,"id")),e=(0,c.fZ)(e,(0,I.ee)(i.chats,"id")),e=(0,c.a4)(e,s,{sendAsPeerIds:i.sendAs}),(0,a.R3)(e)})),(0,a.iw)("loadSponsoredMessages",(async(e,t,n)=>{const{chatId:s}=n,o=(0,d.Z1)(e,s);if(!o)return;const i=await(0,$.t9)("fetchSponsoredMessages",{chat:o});i&&(e=(0,a.Rd)(),e=(0,c.Fn)(e,s,i.messages[0]),e=(0,c.Sh)(e,(0,I.ee)(i.users,"id")),e=(0,c.fZ)(e,(0,I.ee)(i.chats,"id")),(0,a.R3)(e))})),(0,a.iw)("viewSponsoredMessage",((e,t,n)=>{const{chatId:a}=n,s=(0,d.Z1)(e,a),o=(0,d.fS)(e,a);s&&o&&(0,$.t9)("viewSponsoredMessage",{chat:s,random:o.randomId})})),(0,a.iw)("fetchUnreadMentions",(async(e,t,n)=>{const{chatId:s,offsetId:o}=n,i=(0,d.Z1)(e,s);if(!i)return;const r=await(0,$.t9)("fetchUnreadMentions",{chat:i,offsetId:o});if(!r)return;const{messages:l,chats:u,users:m}=r,h=(0,I.ee)(l,"id"),p=Object.keys(h).map(Number);e=(0,a.Rd)(),e=(0,c.c_)(e,i.id,h),e=(0,c.Sh)(e,(0,I.ee)(m,"id")),e=(0,c.fZ)(e,(0,I.ee)(u,"id")),e=(0,c.a4)(e,s,{unreadMentions:[...i.unreadMentions||[],...p]}),(0,a.R3)(e)})),(0,a.iw)("markMentionsRead",((e,t,n)=>{const{messageIds:s,tabId:o=(0,m._w)()}=n,i=(0,d.jr)(e,o);if(!i)return;const r=(i.unreadMentions||[]).filter((e=>!s.includes(e)));e=(0,c.a4)(e,i.id,{unreadMentions:r}),(0,a.R3)(e),t.markMessagesRead({messageIds:s,tabId:o})})),(0,a.iw)("focusNextMention",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},s=(0,d.jr)(e,a);s?.unreadMentions&&t.focusMessage({chatId:s.id,messageId:s.unreadMentions[0],tabId:a})})),(0,a.iw)("readAllMentions",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},s=(0,d.jr)(e,a);if(s)return(0,$.t9)("readAllMentions",{chat:s}),(0,c.a4)(e,s.id,{unreadMentionsCount:void 0,unreadMentions:void 0})})),(0,a.iw)("openUrl",((e,t,n)=>{const{url:a,shouldSkipModal:s,tabId:i=(0,m._w)()}=n,r=(0,G.X)(a);if(r.match(o.FSu)||r.match(o.g$l))return void t.openTelegramLink({url:a,tabId:i});const{appConfig:c}=e;if(c){const e=new URL(r);if(c.autologinDomains.includes(e.hostname))return e.searchParams.set("autologin_token",c.autologinToken),void window.open(e.href,"_blank","noopener");if(c.urlAuthDomains.includes(e.hostname))return void t.requestLinkUrlAuth({url:a,tabId:i})}r.match(o.jL5)||s?window.open(r,"_blank","noopener"):t.toggleSafeLinkModal({url:r,tabId:i})})),(0,a.iw)("setForwardChatOrTopic",(async(e,t,n)=>{const{chatId:s,topicId:o,tabId:i=(0,m._w)()}=n;let r=(0,d.dy)(e,s);if(r&&(0,d.Nm)(e,i)){if(!r.fullInfo){const{accessHash:t}=r;r=await(0,$.t9)("fetchFullUser",{id:s,accessHash:t}),e=(0,a.Rd)()}if(r?.fullInfo.noVoiceMessages)return void t.showDialog({data:{message:(0,b.Iu)("VoiceMessagesRestrictedByPrivacy",(0,u.Js)(r))},tabId:i})}(0,d.GQ)(e,s,i)?(e=(0,p.i)(e,{forwardMessages:{...(0,d.jU)(e,i).forwardMessages,toChatId:s,toThreadId:o,isModalShown:!1}},i),(0,a.R3)(e),t.openChat({id:s,threadId:o,tabId:i}),t.closeMediaViewer({tabId:i}),t.exitMessageSelectMode({tabId:i})):t.showAllowedMessageTypesNotification({chatId:s,tabId:i})})),(0,a.iw)("forwardToSavedMessages",((e,t,n)=>{const{tabId:s=(0,m._w)()}=n||{};e=(0,p.i)(e,{forwardMessages:{...(0,d.jU)(e,s).forwardMessages,toChatId:e.currentUserId}},s),(0,a.R3)(e),t.exitMessageSelectMode({tabId:s}),t.forwardMessages({isSilent:!0,tabId:s})})),(0,a.iw)("requestMessageTranslation",((e,t,n)=>{const{chatId:a,id:s,toLanguageCode:o=(0,d.rB)(e),tabId:i=(0,m._w)()}=n;return(0,c.ql)(e,a,s,o,i)})),(0,a.iw)("showOriginalMessage",((e,t,n)=>{const{chatId:a,id:s,tabId:o=(0,m._w)()}=n;return(0,c.IR)(e,a,s,o)})),(0,a.iw)("translateMessages",((e,t,n)=>{const{chatId:a,messageIds:s,toLanguageCode:o=(0,d.rB)(e)}=n,i=(0,d.Z1)(e,a);if(i)return s.forEach((t=>{e=(0,c.qt)(e,a,t,o,{isPending:!0})})),(0,$.t9)("translateText",{chat:i,messageIds:s,toLanguageCode:o}),e})),(0,a.iw)("loadMessageViews",(async(e,t,n)=>{const{chatId:s,ids:o}=n,i=(0,d.Z1)(e,s);if(!i)return;const r=await(0,$.t9)("fetchMessageViews",{chat:i,ids:o});r&&(e=(0,a.Rd)(),r.forEach((t=>{e=(0,c.cY)(e,s,t.id,{views:t.views,forwards:t.forwards});const n=(0,d.hj)(e,s,t.id);if(!n)return;const a=n.repliesThreadInfo?.chatId,o=n.repliesThreadInfo?.threadId;a&&o&&(e=(0,c.Xg)(e,a,o,{messagesCount:t.messagesCount}))})),(0,a.R3)(e))}));var J=n(85765),K=n(9211);const Q=(0,N.P2)((e=>e()),500,!1);async function ee(e,t){const n=await(0,$.t9)("fetchRecentStickers",{hash:t});n&&(e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,recent:n}},(0,a.R3)(e))}async function te(e,t,n){for(var s=arguments.length,o=new Array(s>3?s-3:0),i=3;i<s;i++)o[i-3]=arguments[i];let r,[l=(0,m._w)()]=o;try{r=await(0,$.t9)("fetchStickers",{stickerSetInfo:n})}catch(s){if("STICKERSET_INVALID"===s.message)return t.showNotification({message:(0,b.Iu)("StickerPack.ErrorNotFound"),tabId:l}),void("shortName"in n&&(0,d.jU)(e,l).openedStickerSetShortName===n.shortName&&(e=(0,p.i)(e,{openedStickerSetShortName:void 0},l),(0,a.R3)(e)))}if(e=(0,a.Rd)(),!r)return;const{set:u,stickers:h,packs:g}=r,f=(e=(0,c.Rg)(e,u.id,{...u,stickers:h,packs:g})).stickers.forEmoji.emoji;f&&g[f]&&(e=(0,c.vy)(e)),(0,a.R3)(e)}async function ne(e,t,n,s){for(var o=arguments.length,i=new Array(o>4?o-4:0),r=4;r<o;r++)i[r-4]=arguments[r];let[d=(0,m._w)()]=i;const l=await(0,$.t9)("searchGifs",{query:t,offset:s,username:n});l&&(e=(0,a.Rd)(),e=(0,c.rq)(e,!s,l.gifs,l.nextOffset,d),(0,a.R3)(e))}(0,a.iw)("loadStickerSets",(async(e,t)=>{const[n,s]=await Promise.all([(0,$.t9)("fetchStickerSets",{hash:e.stickers.added.hash}),(0,$.t9)("fetchCustomEmojiSets",{hash:e.customEmojis.added.hash})]);s&&n&&(e=(0,a.Rd)(),e=(0,c.z3)(e,"added",n.hash,n.sets),e=(0,c.cU)(e,s.hash,s.sets),(0,a.R3)(e),t.loadCustomEmojis({ids:e.recentCustomEmojis}))})),(0,a.iw)("loadAddedStickers",(async(e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},{added:{setIds:s=[]},setsById:o}=e.stickers,{added:{setIds:i=[]}}=e.customEmojis,r=[...s,...i];if(r.length)for(let e=0;e<r.length;e++){const n=r[e];o[n]?.stickers||(t.loadStickers({stickerSetInfo:{id:n,accessHash:o[n].accessHash},tabId:a}),e%10==0&&e>0&&await(0,N.wO)(200))}})),(0,a.iw)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};ee(e,t)})),(0,a.iw)("loadFavoriteStickers",(async e=>{const{hash:t}=e.stickers.favorite||{},n=await(0,$.t9)("fetchFavoriteStickers",{hash:t});n&&(e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,favorite:n}},(0,a.R3)(e))})),(0,a.iw)("loadPremiumStickers",(async e=>{const{hash:t}=e.stickers.premium||{},n=await(0,$.t9)("fetchStickersForEmoji",{emoji:"⭐️⭐️",hash:t});n&&(e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,premium:{hash:n.hash,stickers:n.stickers}}},(0,a.R3)(e))})),(0,a.iw)("loadPremiumSetStickers",(async e=>{const{hash:t}=e.stickers.premium||{},n=await(0,$.t9)("fetchStickersForEmoji",{emoji:"📂⭐️",hash:t});n&&(e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,premiumSet:{hash:n.hash,stickers:n.stickers}}},(0,a.R3)(e))})),(0,a.iw)("loadGreetingStickers",(async e=>{const{hash:t}=e.stickers.greeting||{},n=await(0,$.t9)("fetchStickersForEmoji",{emoji:"👋⭐️",hash:t});n&&(e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,greeting:{hash:n.hash,stickers:n.stickers.filter((e=>"👋"===e.emoji))}}},(0,a.R3)(e))})),(0,a.iw)("loadFeaturedStickers",(async e=>{const{hash:t}=e.stickers.featured||{},n=await(0,$.t9)("fetchFeaturedStickers",{hash:t});n&&(e=(0,a.Rd)(),e=(0,c.z3)(e,"featured",n.hash,n.sets),(0,a.R3)(e))})),(0,a.iw)("loadPremiumGifts",(async e=>{const t=await(0,$.t9)("fetchPremiumGifts");if(!t)return;const{set:n,stickers:s}=t;e=(0,a.Rd)(),e={...e,premiumGifts:{...n,stickers:s}},(0,a.R3)(e)})),(0,a.iw)("loadDefaultTopicIcons",(async e=>{const t=await(0,$.t9)("fetchDefaultTopicIcons");if(!t)return;e=(0,a.Rd)();const{set:n,stickers:s}=t,o={...n,stickers:s};e=(0,c.Rg)(e,o.id,o),e={...e,defaultTopicIconsId:o.id},(0,a.R3)(e)})),(0,a.iw)("loadDefaultStatusIcons",(async e=>{const t=await(0,$.t9)("fetchDefaultStatusEmojis");if(!t)return;e=(0,a.Rd)();const{set:n,stickers:s}=t,o={...n,stickers:s};e=(0,c.Rg)(e,o.id,o),e={...e,defaultStatusIconsId:o.id},(0,a.R3)(e)})),(0,a.iw)("loadStickers",((e,t,n)=>{const{stickerSetInfo:a,tabId:s=(0,m._w)()}=n,o=(0,d.Ny)(e,a);o&&o.count===o?.stickers?.length||te(e,t,a,s)})),(0,a.iw)("loadAnimatedEmojis",(async e=>{const[t,n]=await Promise.all([(0,$.t9)("fetchAnimatedEmojis"),(0,$.t9)("fetchAnimatedEmojiEffects")]);t&&n&&(e=(0,a.Rd)(),e=(0,c.g_)(e,{...t.set,stickers:t.stickers}),e={...e,animatedEmojiEffects:{...n.set,stickers:n.stickers}},(0,a.R3)(e))})),(0,a.iw)("loadGenericEmojiEffects",(async e=>{const t=await(0,$.t9)("fetchGenericEmojiEffects");if(!t)return;e=(0,a.Rd)();const{set:n,stickers:s}=t;e={...e,genericEmojiEffects:{...n,stickers:s}},(0,a.R3)(e)})),(0,a.iw)("loadSavedGifs",(async e=>{const{hash:t}=e.gifs.saved,n=await(0,$.t9)("fetchSavedGifs",{hash:t});n&&(e=(0,a.Rd)(),e={...e,gifs:{...e.gifs,saved:n}},(0,a.R3)(e))})),(0,a.iw)("saveGif",(async(e,t,n)=>{const{gif:s,shouldUnsave:o,tabId:i=(0,m._w)()}=n,r=e.gifs.saved.gifs?.length,c=(0,K.M)(e,"savedGifs"),l=(0,K.P)(e,"savedGifs"),u=(0,d.wV)(e);if(!o&&r&&r>=c&&t.showNotification({title:b.Iu("LimitReachedFavoriteGifs",c.toString()),message:u?b.Iu("LimitReachedFavoriteGifsSubtitlePremium"):b.Iu("LimitReachedFavoriteGifsSubtitle",l.toString()),...!u&&{action:{action:"openPremiumModal",payload:{tabId:i}}},className:"bold-link",tabId:i}),!await(0,$.t9)("saveGif",{gif:s,shouldUnsave:o}))return;const h=(e=(0,a.Rd)()).gifs.saved.gifs?.filter((e=>{let{id:t}=e;return t!==s.id}))||[],p=o?h:[s,...h];e={...e,gifs:{...e.gifs,saved:{...e.gifs.saved,gifs:p}}},(0,a.R3)(e)})),(0,a.iw)("faveSticker",((e,t,n)=>{const{sticker:a,tabId:s=(0,m._w)()}=n,o=e.stickers.favorite.stickers.length,i=(0,K.M)(e,"stickersFaved"),r=(0,K.P)(e,"stickersFaved"),c=(0,d.wV)(e);o>=i&&t.showNotification({title:b.Iu("LimitReachedFavoriteStickers",i.toString()),message:c?b.Iu("LimitReachedFavoriteStickersSubtitlePremium"):b.Iu("LimitReachedFavoriteStickersSubtitle",r.toString()),...!c&&{action:{action:"openPremiumModal",payload:{tabId:s}}},className:"bold-link",tabId:s}),a&&(0,$.t9)("faveSticker",{sticker:a})})),(0,a.iw)("unfaveSticker",((e,t,n)=>{const{sticker:s}=n;s&&(e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,favorite:{...e.stickers.favorite,stickers:e.stickers.favorite.stickers.filter((e=>{let{id:t}=e;return t!==s.id}))}}},(0,a.R3)(e),(0,$.t9)("faveSticker",{sticker:s,unfave:!0}))})),(0,a.iw)("removeRecentSticker",(async(e,t,n)=>{const{sticker:s}=n;await(0,$.t9)("removeRecentSticker",{sticker:s})&&ee((0,a.Rd)())})),(0,a.iw)("clearRecentStickers",(async e=>{await(0,$.t9)("clearRecentStickers")&&(e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,recent:{stickers:[]}}},(0,a.R3)(e))})),(0,a.iw)("toggleStickerSet",((e,t,n)=>{const{stickerSetId:a}=n,s=(0,d.Ny)(e,a);if(!s)return;const{accessHash:o,installedDate:i,isArchived:r}=s,c=!r&&Boolean(i);(0,$.t9)(c?"uninstallStickerSet":"installStickerSet",{stickerSetId:a,accessHash:o})})),(0,a.iw)("loadEmojiKeywords",(async(e,t,n)=>{const{language:s}=n;let o=e.emojiKeywords[s];if(o?.isLoading)return;e={...e,emojiKeywords:{...e.emojiKeywords,[s]:{...o,isLoading:!0}}},(0,a.R3)(e);const i=await(0,$.t9)("fetchEmojiKeywords",{language:s,fromVersion:o?o.version:0});if(o=(e=(0,a.Rd)()).emojiKeywords[s],!i)return e={...e,emojiKeywords:{...e.emojiKeywords,[s]:{...o,isLoading:!1}}},void(0,a.R3)(e);e={...e,emojiKeywords:{...e.emojiKeywords,[s]:{isLoading:!1,version:i.version,keywords:{...o?.keywords,...i.keywords}}}},(0,a.R3)(e)})),(0,a.iw)("setStickerSearchQuery",((e,t,n)=>{const{query:s,tabId:o=(0,m._w)()}=n;s&&Q((async()=>{const t=await(0,$.t9)("searchStickers",{query:s});if(!t)return;e=(0,a.Rd)();const{setsById:n,added:i}=e.stickers,r=t.sets.map((e=>{let{id:t}=e;return t}));i.setIds&&i.setIds.forEach((e=>{if(!r.includes(e)){const{title:t}=n[e]||{};t&&(0,J.Z)(t,s)&&r.unshift(e)}})),e=(0,c.z3)(e,"search",t.hash,t.sets),e=(0,c.fH)(e,t.hash,r,o),(0,a.R3)(e)}))})),(0,a.iw)("setGifSearchQuery",((e,t,n)=>{const{query:a,tabId:s=(0,m._w)()}=n;"string"==typeof a&&Q((()=>{ne(e,a,e.config?.gifSearchUsername,void 0,s)}))})),(0,a.iw)("searchMoreGifs",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},{query:s,offset:o}=(0,d.jU)(e,a).gifSearch;"string"==typeof s&&Q((()=>{ne(e,s,e.config?.gifSearchUsername,o,a)}))})),(0,a.iw)("loadStickersForEmoji",((e,t,n)=>{const{emoji:s}=n,{hash:o}=e.stickers.forEmoji;Q((async()=>{e=(0,a.Rd)(),e={...e,stickers:{...e.stickers,forEmoji:{...e.stickers.forEmoji,emoji:s}}},(0,a.R3)(e);const t=await(0,$.t9)("fetchStickersForEmoji",{emoji:s,hash:o});e=(0,a.Rd)(),t&&e.stickers.forEmoji.emoji===s&&(e=(0,c.IM)(e,s,t.stickers,t.hash),(0,a.R3)(e))}))})),(0,a.iw)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,a.iw)("loadCustomEmojiForEmoji",((e,t,n)=>{const{emoji:a}=n;return(0,c.AA)(e,a)})),(0,a.iw)("clearCustomEmojiForEmoji",(e=>({...e,customEmojis:{...e.customEmojis,forEmoji:{}}}))),(0,a.iw)("loadFeaturedEmojiStickers",(async e=>{const t=await(0,$.t9)("fetchFeaturedEmojiStickers");t&&(e=(0,a.Rd)(),e={...e,customEmojis:{...e.customEmojis,featuredIds:t.sets.map((e=>{let{id:t}=e;return t})),byId:{...e.customEmojis.byId,...(0,I.ee)(t.sets.flatMap((e=>e.stickers||[])),"id")}},stickers:{...e.stickers,setsById:{...e.stickers.setsById,...(0,I.ee)(t.sets,"id")}}},(0,a.R3)(e))})),(0,a.iw)("openStickerSet",(async(e,t,n)=>{const{stickerSetInfo:s,tabId:o=(0,m._w)()}=n;(0,d.Ny)(e,s)||await te(e,t,s,o),e=(0,a.Rd)();const i=(0,d.Ny)(e,s);i?.shortName&&(e=(0,p.i)(e,{openedStickerSetShortName:i.shortName},o),(0,a.R3)(e))})),(0,a.iw)("loadRecentEmojiStatuses",(async e=>{const t=await(0,$.t9)("fetchRecentEmojiStatuses");t&&(e=(0,a.Rd)(),e=(0,c.et)(e,t.hash,t.emojiStatuses),(0,a.R3)(e))}));var ae=n(790);const se=(0,N.P2)((e=>e()),500,!1);async function oe(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,r=arguments.length>5?arguments[5]:void 0,l=arguments.length>6?arguments[6]:void 0;for(var u=arguments.length,h=new Array(u>7?u-7:0),p=7;p<u;p++)h[p-7]=arguments[p];let g,[f=(0,m._w)()]=h;if(i){const e=(0,$.t9)("searchMessagesLocal",{chat:i,query:t,type:n,limit:o.Hkl,offsetId:s,minDate:l,maxDate:r}),a=i.isForum?(0,$.t9)("fetchTopics",{chat:i,query:t,limit:o.XM3}):void 0,[c,d]=await Promise.all([e,a]);if(c){const{messages:e,users:t,totalCount:n,nextOffsetId:a}=c,{topics:s,count:o}=d||{};g={topics:s,totalTopicsCount:o,messages:e,users:t,chats:[],totalCount:n,nextRate:a}}}else g=await(0,$.t9)("searchMessagesGlobal",{query:t,offsetRate:s,limit:o.Hkl,type:n,maxDate:r,minDate:l});e=(0,a.Rd)();const v=(0,d.JX)(e,f);if(!g||""!==t&&t!==v)return e=(0,c.xv)(e,{messages:!1},f),void(0,a.R3)(e);const{messages:w,users:b,chats:y,totalCount:P,nextRate:Z}=g;y.length&&(e=(0,c.fZ)(e,(0,I.ee)(y,"id"))),b.length&&(e=(0,c.Sh)(e,(0,I.ee)(b,"id"))),w.length&&(e=(0,c.m6)(e,w)),e=(0,c.px)(e,w,P,n,Z,f),g.topics&&(e=(0,c.XG)(e,i.id,g.totalTopicsCount,g.topics));const C=g.topics?.map((e=>{let{id:t}=e;return t})).sort(((e,t)=>t-e));e=(0,c.No)(e,{foundTopicIds:C},f),(0,a.R3)(e)}async function ie(e,t,n,s,i){let l=arguments.length>5&&void 0!==arguments[5]&&arguments[5];for(var u=arguments.length,h=new Array(u>6?u-6:0),p=6;p<u;p++)h[p-6]=arguments[p];let[g=(0,m._w)()]=h;const f=await(0,$.t9)("searchMessagesLocal",{chat:t,type:s,limit:2*o.ENB,topMessageId:n===r._f?void 0:n,offsetId:i});if(!f)return;const{chats:v,users:w,messages:b,totalCount:y,nextOffsetId:P}=f,Z=(0,I.ee)(b,"id"),C=Object.keys(Z).map(Number);e=(0,a.Rd)();const S=(0,d.we)(e,g);S&&(e=(0,c.fZ)(e,(0,I.ee)(v,"id")),e=(0,c.Sh)(e,(0,I.ee)(w,"id")),e=(0,c.c_)(e,t.id,Z),e=(0,c.c1)(e,t.id,n,s,C,y,P,g),(0,a.R3)(e),l||ie(e,t,n,s,P,!0,g))}(0,a.iw)("setGlobalSearchQuery",((e,t,n)=>{const{query:s,tabId:o=(0,m._w)()}=n,{chatId:i}=(0,d.jU)(e,o).globalSearch;s&&!i&&se((async()=>{const t=await(0,$.t9)("searchChats",{query:s});e=(0,a.Rd)();const n=(0,d.JX)(e,o);if(!t||!n||s!==n)return e=(0,c.xv)(e,{chats:!1},o),void(0,a.R3)(e);const{localChats:i,localUsers:r,globalChats:l,globalUsers:u}=t;(i.length||l.length)&&(e=(0,c.fZ)(e,(0,I.ee)([...i,...l],"id"))),(r.length||u.length)&&(e=(0,c.Sh)(e,(0,I.ee)([...r,...u],"id"))),e=(0,c.xv)(e,{chats:!1},o),e=(0,c.No)(e,{localResults:{chatIds:i.map((e=>{let{id:t}=e;return t})),userIds:r.map((e=>{let{id:t}=e;return t}))},globalResults:{...(0,d.jU)(e,o).globalSearch.globalResults,chatIds:l.map((e=>{let{id:t}=e;return t})),userIds:u.map((e=>{let{id:t}=e;return t}))}},o),(0,a.R3)(e)}))})),(0,a.iw)("setGlobalSearchDate",((e,t,n)=>{const{date:s,tabId:o=(0,m._w)()}=n,i=s?(0,ae.IS)(s):s;e=(0,c.No)(e,{date:s,query:"",resultsByType:{...(0,d.jU)(e,o).globalSearch.resultsByType,text:{totalCount:void 0,foundIds:[],nextOffsetId:0}}},o),(0,a.R3)(e);const{chatId:r}=(0,d.jU)(e,o).globalSearch;oe(e,"","text",void 0,r?(0,d.Z1)(e,r):void 0,i,s,o)})),(0,a.iw)("searchMessagesGlobal",((e,t,n)=>{const{type:a,tabId:s=(0,m._w)()}=n,{query:o,resultsByType:i,chatId:r,date:c}=(0,d.jU)(e,s).globalSearch,l=c?(0,ae.IS)(c):c,u=i?.[a]?.nextOffsetId;oe(e,o,a,u,r?(0,d.Z1)(e,r):void 0,l,c,s)})),(0,a.iw)("searchTextMessagesLocal",(async(e,t,n)=>{const{tabId:s=(0,m._w)()}=n||{},{chatId:i,threadId:l}=(0,d.Bt)(e,s)||{},u=i?(0,d.Z1)(e,i):void 0;let h=(0,d.n5)(e,s);if(!u||!h||!l)return;const{query:p,results:g}=h,f=g?.nextOffsetId;let v;if(l!==r._f&&(v=(0,d.tZ)(e,i,l)?.topMessageId),!p)return;const w=await(0,$.t9)("searchMessagesLocal",{chat:u,type:"text",query:p,topMessageId:v,limit:o.pnA,offsetId:f});if(!w)return;const{chats:b,users:y,messages:P,totalCount:Z,nextOffsetId:C}=w,S=(0,I.ee)(P,"id"),E=Object.keys(S).map(Number);e=(0,a.Rd)(),h=(0,d.n5)(e,s),h&&p===h.query&&(e=(0,c.fZ)(e,(0,I.ee)(b,"id")),e=(0,c.Sh)(e,(0,I.ee)(y,"id")),e=(0,c.c_)(e,u.id,S),e=(0,c.dx)(e,u.id,l,E,Z,C,s),(0,a.R3)(e))})),(0,a.iw)("searchMediaMessagesLocal",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},{chatId:s,threadId:o}=(0,d.Bt)(e,a)||{};if(!s||!o)return;const i=(0,d.Z1)(e,s),r=(0,d.we)(e,a);if(!i||!r)return;const{currentType:c,resultsByType:l}=r,u=(c&&l&&l[c])?.nextOffsetId;c&&ie(e,i,o,c,u,void 0,a)})),(0,a.iw)("searchMessagesByDate",(async(e,t,n)=>{const{timestamp:a,tabId:s=(0,m._w)()}=n,{chatId:o}=(0,d.Bt)(e,s)||{};if(!o)return;const i=(0,d.Z1)(e,o);if(!i)return;const r=await(0,$.t9)("findFirstMessageIdAfterDate",{chat:i,timestamp:a});r&&t.focusMessage({chatId:i.id,messageId:r,tabId:s})})),(0,a.iw)("checkPublicLink",(async(e,t,n)=>{const{username:s,tabId:o=(0,m._w)()}=n,{chatId:i}=(0,d.Bt)(e,o)||{};if(!i)return;if((0,d.jU)(e,o).management.progress===f.wv.InProgress)return;e=(0,c.fw)(e,i,{isUsernameAvailable:void 0,checkedUsername:void 0},o),(0,a.R3)(e);const{result:r,error:l}=await(0,$.t9)("checkChatUsername",{username:s});e=(0,a.Rd)(),e=(0,c.H9)(e,!0===r?f.wv.Complete:f.wv.Error,o),e=(0,c.fw)(e,i,{isUsernameAvailable:!0===r,checkedUsername:s,error:l},o),(0,a.R3)(e),void 0===r&&t.openLimitReachedModal({limit:"channelsPublic",tabId:o})})),(0,a.iw)("updatePublicLink",(async(e,t,n)=>{const{username:s,tabId:o=(0,m._w)()}=n,{chatId:i}=(0,d.Bt)(e,o)||{};if(!i)return;const r=await(0,q.X9)(e,t,i,o);if(!r)return;e=(0,a.Rd)(),e=(0,c.H9)(e,f.wv.InProgress,o),(0,a.R3)(e);const l=await(0,$.t9)("setChatUsername",{chat:r,username:s});e=(0,a.Rd)(),e=(0,c.H9)(e,l?f.wv.Complete:f.wv.Error,o),e=(0,c.fw)(e,i,{isUsernameAvailable:void 0,checkedUsername:void 0,error:void 0},o),(0,a.R3)(e)})),(0,a.iw)("updatePrivateLink",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},{chatId:s}=(0,d.Bt)(e,a)||{},o=s&&(0,d.Z1)(e,s);s&&o&&(0,$.t9)("updatePrivateLink",{chat:o})})),(0,a.iw)("setEditingExportedInvite",((e,t,n)=>{const{chatId:s,invite:o,tabId:i=(0,m._w)()}=n;e=(0,c.fw)(e,s,{editingInvite:o},i),(0,a.R3)(e)})),(0,a.iw)("setOpenedInviteInfo",((e,t,n)=>{const{chatId:s,invite:o,tabId:i=(0,m._w)()}=n,r=o?{inviteInfo:{invite:o}}:{inviteInfo:void 0};e=(0,c.fw)(e,s,r,i),(0,a.R3)(e)})),(0,a.iw)("loadExportedChatInvites",(async(e,t,n)=>{const{chatId:s,adminId:o,isRevoked:i,limit:r,tabId:l=(0,m._w)()}=n,u=(0,d.Z1)(e,s),h=(0,d.dy)(e,o||e.currentUserId);if(!u||!h)return;const p=await(0,$.t9)("fetchExportedChatInvites",{peer:u,admin:h,isRevoked:i,limit:r});if(!p)return;e=(0,a.Rd)();const{invites:g,users:f}=p;e=(0,c.Sh)(e,(0,I.ee)(f,"id"));const v=i?{revokedInvites:g}:{invites:g};e=(0,c.fw)(e,s,v,l),(0,a.R3)(e)})),(0,a.iw)("editExportedChatInvite",(async(e,t,n)=>{const{chatId:s,link:o,isRevoked:i,expireDate:r,usageLimit:l,isRequestNeeded:u,title:h,tabId:p=(0,m._w)()}=n,g=(0,d.Z1)(e,s);if(!g)return;const f=await(0,$.t9)("editExportedChatInvite",{peer:g,link:o,isRevoked:i,expireDate:r,usageLimit:l,isRequestNeeded:u,title:h});if(!f)return;const{oldInvite:v,newInvite:w,users:b}=f;e=(0,a.Rd)();const{management:y}=(0,d.jU)(e,p),P=(y.byChatId[s].invites||[]).filter((e=>e.link!==v.link)),Z=[...y.byChatId[s].revokedInvites||[]];w.isRevoked?Z.unshift(w):P.push(w),e=(0,c.Sh)(e,(0,I.ee)(b,"id")),e=(0,c.fw)(e,s,{invites:P,revokedInvites:Z},p),(0,a.R3)(e)})),(0,a.iw)("exportChatInvite",(async(e,t,n)=>{const{chatId:s,expireDate:o,usageLimit:i,isRequestNeeded:r,title:l,tabId:u=(0,m._w)()}=n,h=(0,d.Z1)(e,s);if(!h)return;const p=await(0,$.t9)("exportChatInvite",{peer:h,expireDate:o,usageLimit:i,isRequestNeeded:r,title:l});if(!p)return;e=(0,a.Rd)();const g=(0,d.jU)(e,u).management.byChatId[s].invites||[];e=(0,c.fw)(e,s,{invites:[...g,p]},u),(0,a.R3)(e)})),(0,a.iw)("deleteExportedChatInvite",(async(e,t,n)=>{const{chatId:s,link:o,tabId:i=(0,m._w)()}=n,r=(0,d.Z1)(e,s);if(!r)return;if(!await(0,$.t9)("deleteExportedChatInvite",{peer:r,link:o}))return;e=(0,a.Rd)();const l=(0,d.jU)(e,i).management.byChatId[s];e=(0,c.fw)(e,s,{invites:l?.invites?.filter((e=>e.link!==o)),revokedInvites:l?.revokedInvites?.filter((e=>e.link!==o))},i),(0,a.R3)(e)})),(0,a.iw)("deleteRevokedExportedChatInvites",(async(e,t,n)=>{const{chatId:s,adminId:o,tabId:i=(0,m._w)()}=n,r=(0,d.Z1)(e,s),l=(0,d.dy)(e,o||e.currentUserId);r&&l&&await(0,$.t9)("deleteRevokedExportedChatInvites",{peer:r,admin:l})&&(e=(0,a.Rd)(),e=(0,c.fw)(e,s,{revokedInvites:[]},i),(0,a.R3)(e))})),(0,a.iw)("loadChatInviteImporters",(async(e,t,n)=>{const{chatId:s,link:o,offsetDate:i,offsetUserId:r,limit:l,tabId:u=(0,m._w)()}=n,h=(0,d.Z1)(e,s),p=r?(0,d.dy)(e,r):void 0;if(!h||r&&!p)return;const g=await(0,$.t9)("fetchChatInviteImporters",{peer:h,link:o,offsetDate:i,offsetUser:p,limit:l});if(!g)return;const{importers:f,users:I}=g;e=(0,a.Rd)();const v=(0,d.jU)(e,u).management.byChatId[s]?.inviteInfo;v?.invite&&v.invite.link===o&&(e=(0,c.fw)(e,s,{inviteInfo:{...v,importers:f}},u),e=(0,c.Sh)(e,I),(0,a.R3)(e))})),(0,a.iw)("loadChatInviteRequesters",(async(e,t,n)=>{const{chatId:s,link:o,offsetDate:i,offsetUserId:r,limit:l,tabId:u=(0,m._w)()}=n,h=(0,d.Z1)(e,s),p=r?(0,d.dy)(e,r):void 0;if(!h||r&&!p)return;const g=await(0,$.t9)("fetchChatInviteImporters",{peer:h,link:o,offsetDate:i,offsetUser:p,limit:l,isRequested:!0});if(!g)return;const{importers:f,users:I}=g;e=(0,a.Rd)();const v=(0,d.jU)(e,u).management.byChatId[s]?.inviteInfo;v?.invite&&v.invite.link===o&&(e=(0,c.fw)(e,s,{inviteInfo:{...v,requesters:f}},u),e=(0,c.Sh)(e,I),(0,a.R3)(e))})),(0,a.iw)("loadChatJoinRequests",(async(e,t,n)=>{const{chatId:s,offsetDate:o=0,offsetUserId:i,limit:r=0}=n,l=(0,d.Z1)(e,s),u=i?(0,d.dy)(e,i):void 0;if(!l||i&&!u)return;const m=await(0,$.t9)("fetchChatInviteImporters",{peer:l,offsetDate:o,offsetUser:u,limit:r,isRequested:!0});if(!m)return;const{importers:h,users:p}=m;e=(0,a.Rd)(),e=(0,c.a4)(e,s,{joinRequests:h}),e=(0,c.Sh)(e,p),(0,a.R3)(e)})),(0,a.iw)("hideChatJoinRequest",(async(e,t,n)=>{const{chatId:s,userId:o,isApproved:i}=n,r=(0,d.Z1)(e,s),l=(0,d.dy)(e,o);if(!r||!l)return;if(!await(0,$.t9)("hideChatJoinRequest",{peer:r,user:l,isApproved:i}))return;e=(0,a.Rd)();const u=(0,d.Z1)(e,s);u&&(e=(0,c.a4)(e,s,{joinRequests:u.joinRequests?.filter((e=>e.userId!==o))}),(0,a.R3)(e))})),(0,a.iw)("hideAllChatJoinRequests",(async(e,t,n)=>{const{chatId:s,isApproved:o,link:i}=n,r=(0,d.Z1)(e,s);if(!r)return;if(!await(0,$.t9)("hideAllChatJoinRequests",{peer:r,isApproved:o,link:i}))return;e=(0,a.Rd)();const l=(0,d.Z1)(e,s);l&&(e=(0,c.a4)(e,s,{joinRequests:[],fullInfo:{...l.fullInfo,recentRequesterIds:[],requestsPending:0}}),(0,a.R3)(e))})),(0,a.iw)("hideChatReportPanel",(async(e,t,n)=>{const{chatId:s}=n,o=(0,d.Z1)(e,s);o&&await(0,$.t9)("hideChatReportPanel",o)&&(e=(0,a.Rd)(),e=(0,c.a4)(e,s,{settings:void 0}),(0,a.R3)(e))})),(0,a.iw)("uploadContactProfilePhoto",(async(e,t,n)=>{const{userId:s,file:o,isSuggest:i,tabId:r=(0,m._w)()}=n,l=(0,d.dy)(e,s);if(!l)return;e=(0,c.H9)(e,f.wv.InProgress,r),(0,a.R3)(e);const h=await(0,$.t9)("uploadContactProfilePhoto",{user:l,file:o,isSuggest:i});if(!h)return e=(0,a.Rd)(),e=(0,c.H9)(e,f.wv.Error,r),void(0,a.R3)(e);e=(0,a.Rd)(),e=(0,c.Sh)(e,(0,I.ee)(h.users,"id")),(0,a.R3)(e);const{id:p,accessHash:g}=l;if(!await(0,$.t9)("fetchFullUser",{id:p,accessHash:g}))return e=(0,a.Rd)(),e=(0,c.H9)(e,f.wv.Error,r),void(0,a.R3)(e);t.loadProfilePhotos({profileId:s}),e=(0,a.Rd)(),e=(0,c.H9)(e,f.wv.Complete,r),(0,a.R3)(e),o&&!i&&t.showNotification({message:b.Iu("UserInfo.SetCustomPhoto.SuccessPhotoText",(0,u.Vl)(l)),tabId:r})}));var re=n(65116);let ce,de;(0,a.iw)("sync",((e,t)=>{o.eMD&&console.log(">>> START SYNC"),ce&&clearTimeout(ce),e=(0,a.Rd)(),e={...e,isSyncing:!0},(0,a.R3)(e),ce=window.setTimeout((()=>{e=(0,a.Rd)(),e={...e,isSyncing:!1},(0,a.R3)(e),ce=void 0}),15e3);const{loadAllChats:n,preloadTopChatMessages:s}=t;n({listType:"active",shouldReplace:!0,onReplace:async()=>{await async function(e,t){let n=!1;e=(0,a.Rd)();let s=!1;const i=Object.keys(e.messages.byChatId).reduce(((t,n)=>(t[n]=Object.keys(e.messages.byChatId[n].threadsById).reduce(((t,a)=>(t[Number(a)]={draft:(0,d.Ms)(e,n,Number(a)),editingId:(0,d._$)(e,n,Number(a)),editingDraft:(0,d.s)(e,n,Number(a))},t)),{}),t)),{});for(const{id:i}of Object.values(e.byTabId)){e=(0,a.Rd)();const{chatId:h,threadId:g}=(0,d.Bt)(e,i)||{},f=g||r._f,v=g&&h?(0,d.tZ)(e,h,g):void 0,w=h?e.chats.byId[h]:void 0;if(h&&w){const t=await(l=w,u=f,m=v?.lastReadInboxMessageId,(0,$.t9)("fetchMessages",{chat:l,threadId:u,offsetId:m||l.lastReadInboxMessageId,addOffset:-(Math.round(o.hT6/2)+1),limit:o.hT6}));e=(0,a.Rd)();const{chatId:r}=(0,d.Bt)(e,i)||{};if(t&&r===h){const a=(0,d.Zw)(e,h),i=h===o.awM?e.serviceNotifications.filter((e=>{let{isDeleted:t}=e;return!t})).map((e=>{let{message:t}=e;return t})):[],r=w.isForum&&w.topics?Object.values(w.topics).map((e=>{let{lastMessageId:t}=e;return a[t]})).filter(Boolean):[],l=[].concat(t.messages,i),u=l.concat(r),m=(0,I.ee)(u,"id"),g=l.map((e=>{let{id:t}=e;return t}));s||(e={...e,messages:{...e.messages,byChatId:{}}},Object.values(e.byTabId).forEach((t=>{let{id:n}=t;e=(0,p.i)(e,{tabThreads:{}},n)})),s=!0),e=(0,c.c_)(e,h,m),e=(0,c.xj)(e,h,f,g),v?.originChannelId&&(e=(0,c.Xg)(e,h,f,v)),Object.values(e.byTabId).forEach((t=>{let{id:n}=t;const{chatId:a,threadId:s}=(0,d.Bt)(e,n)||{};a===h&&s===f&&(e=(0,c.y9)(e,h,f,g,n))})),e=(0,c.GL)(e,(0,I.ee)(t.chats,"id")),e=(0,c.eD)(e,(0,I.ee)(t.users,"id")),t.repliesThreadInfos.length&&(e=(0,c.j6)(e,h,t.repliesThreadInfos)),n=!0}}(0,a.R3)(e),w?.isForum&&(t.loadTopics({chatId:h,force:!0}),g&&g!==r._f&&t.loadTopicById({chatId:h,topicId:g,shouldCloseChatOnError:!0}))}var l,u,m;e=(0,a.Rd)(),n||(e={...e,messages:{...e.messages,byChatId:{}}},Object.values(e.byTabId).forEach((t=>{let{id:n}=t;e=(0,p.i)(e,{tabThreads:{}},n)}))),Object.keys(i).forEach((t=>{const n=i[t];Object.keys(n).forEach((n=>{e=(0,c.sN)(e,t,Number(n),i[t][Number(n)])}))})),(0,a.R3)(e),Object.values(e.byTabId).forEach((n=>{let{id:a}=n;const{chatId:s,messageId:o}=(0,d.jU)(e,a).audioPlayer;s&&o&&!(0,d.hj)(e,s,o)&&t.closeAudioPlayer({tabId:a})}))}(e,t),e=(0,a.Rd)(),e={...e,lastSyncTime:Date.now(),isSyncing:!1},(0,a.R3)(e),o.eMD&&console.log(">>> FINISH SYNC"),(0,T.S1)(),n({listType:"archived",shouldReplace:!0}),(0,$.t9)("fetchCurrentUser"),s()}})})),(0,re.ll)((e=>{const{connectionState:t,authState:n}=e,{isMasterTab:s}=(0,d.jU)(e);!s||de?.connectionState===t&&de?.authState===n||"connectionStateReady"===t&&"authorizationStateReady"===n&&(0,a.Sv)().sync(),de=e})),(0,a.iw)("reportPeer",(async(e,t,n)=>{const{chatId:a,reason:s,description:o,tabId:i=(0,m._w)()}=n;if(!a)return;const r=(0,d.Z1)(e,a);if(!r)return;const c=await(0,$.t9)("reportPeer",{peer:r,reason:s,description:o});t.showNotification({message:c?(0,b.Iu)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later.",tabId:i})})),(0,a.iw)("reportProfilePhoto",(async(e,t,n)=>{const{chatId:a,reason:s,description:o,photo:i,tabId:r=(0,m._w)()}=n;if(!a)return;const c=(0,d.Z1)(e,a);if(!c||!i)return;const l=await(0,$.t9)("reportProfilePhoto",{peer:c,photo:i,reason:s,description:o});t.showNotification({message:l?(0,b.Iu)("ReportPeer.AlertSuccess"):"An error occurred while submitting your report. Please, try again later.",tabId:r})})),(0,a.iw)("loadAuthorizations",(async e=>{const t=await(0,$.t9)("fetchAuthorizations");t&&(e=(0,a.Rd)(),e={...e,activeSessions:{byHash:t.authorizations,orderedHashes:Object.keys(t.authorizations),ttlDays:t.ttlDays}},(0,a.R3)(e))})),(0,a.iw)("terminateAuthorization",(async(e,t,n)=>{const{hash:s}=n;if(!await(0,$.t9)("terminateAuthorization",s))return;e=(0,a.Rd)();const{[s]:o,...i}=e.activeSessions.byHash;e={...e,activeSessions:{byHash:i,orderedHashes:e.activeSessions.orderedHashes.filter((e=>e!==s))}},(0,a.R3)(e)})),(0,a.iw)("terminateAllAuthorizations",(async e=>{if(!await(0,$.t9)("terminateAllAuthorizations"))return;const t=(e=(0,a.Rd)()).activeSessions.orderedHashes.find((t=>e.activeSessions.byHash[t].isCurrent));if(!t)return;const n=e.activeSessions.byHash[t];e={...e,activeSessions:{byHash:{[t]:n},orderedHashes:[t]}},(0,a.R3)(e)})),(0,a.iw)("changeSessionSettings",(async(e,t,n)=>{const{hash:s,areCallsEnabled:o,areSecretChatsEnabled:i}=n;await(0,$.t9)("changeSessionSettings",{hash:s,areCallsEnabled:o,areSecretChatsEnabled:i})&&(e=(0,a.Rd)(),e={...e,activeSessions:{...e.activeSessions,byHash:{...e.activeSessions.byHash,[s]:{...e.activeSessions.byHash[s],...void 0!==o?{areCallsEnabled:o}:void 0,...void 0!==i?{areSecretChatsEnabled:i}:void 0}}}},(0,a.R3)(e))})),(0,a.iw)("changeSessionTtl",(async(e,t,n)=>{const{days:s}=n;await(0,$.t9)("changeSessionTtl",{days:s})&&(e=(0,a.Rd)(),e={...e,activeSessions:{...e.activeSessions,ttlDays:s}},(0,a.R3)(e))})),(0,a.iw)("loadWebAuthorizations",(async e=>{const t=await(0,$.t9)("fetchWebAuthorizations");if(!t)return;const{users:n,webAuthorizations:s}=t;e=(0,a.Rd)(),e=(0,c.Sh)(e,(0,I.ee)(n,"id")),e={...e,activeWebSessions:{byHash:s,orderedHashes:Object.keys(s)}},(0,a.R3)(e)})),(0,a.iw)("terminateWebAuthorization",(async(e,t,n)=>{const{hash:s}=n;if(!await(0,$.t9)("terminateWebAuthorization",s))return;e=(0,a.Rd)();const{[s]:o,...i}=e.activeWebSessions.byHash;e={...e,activeWebSessions:{byHash:i,orderedHashes:e.activeWebSessions.orderedHashes.filter((e=>e!==s))}},(0,a.R3)(e)})),(0,a.iw)("terminateAllWebAuthorizations",(async e=>{await(0,$.t9)("terminateAllWebAuthorizations")&&(e=(0,a.Rd)(),e={...e,activeWebSessions:{byHash:{},orderedHashes:[]}},(0,a.R3)(e))}));const le=(0,N.P2)((e=>e()),500,!1);function ue(e,t,n){for(var a=arguments.length,s=new Array(a>3?a-3:0),o=3;o<a;o++)s[o-3]=arguments[o];let[i=(0,m._w)()]=s;const r=(0,d.jU)(e,i);return(0,p.i)(e,{inlineBots:{...r.inlineBots,byUsername:{...r.inlineBots.byUsername,[t]:n}}},i)}function me(e,t){for(var n=arguments.length,a=new Array(n>2?n-2:0),s=2;s<n;s++)a[s-2]=arguments[s];let[o=(0,m._w)()]=a;return(0,p.i)(e,{inlineBots:{...(0,d.jU)(e,o).inlineBots,isLoading:t}},o)}(0,a.iw)("loadFullUser",(async(e,t,n)=>{const{userId:a}=n,s=(0,d.dy)(e,a);if(!s)return;const{id:o,accessHash:i}=s,r=await(0,$.t9)("fetchFullUser",{id:o,accessHash:i});if(!r)return;const c=s.avatarHash!==r.avatarHash,l=s.fullInfo?.profilePhoto?.id!==r.fullInfo?.profilePhoto?.id,u=s.fullInfo?.fallbackPhoto?.id!==r.fullInfo?.fallbackPhoto?.id,m=s.fullInfo?.personalPhoto?.id!==r.fullInfo?.personalPhoto?.id;(c||l||u||m)&&s.photos?.length&&t.loadProfilePhotos({profileId:a})})),(0,a.iw)("loadUser",(async(e,t,n)=>{const{userId:s}=n,o=(0,d.dy)(e,s);if(!o)return;const i=await(0,$.t9)("fetchUsers",{users:[o]});if(!i)return;const{users:r,userStatusesById:l}=i;e=(0,a.Rd)(),e=(0,c.eD)(e,(0,I.ee)(r,"id")),e=(0,c.ps)(e,{...e.users.statusesById,...l}),(0,a.R3)(e)})),(0,a.iw)("loadTopUsers",(async e=>{const{topPeers:{lastRequestedAt:t}}=e;if(t&&!((0,v.bp)()-t>60))return;const n=await(0,$.t9)("fetchTopUsers");if(!n)return;const{ids:s,users:o}=n;e=(0,a.Rd)(),e=(0,c.Sh)(e,(0,I.ee)(o,"id")),e={...e,topPeers:{...e.topPeers,userIds:s,lastRequestedAt:(0,v.bp)()}},(0,a.R3)(e)})),(0,a.iw)("loadContactList",(async e=>{const t=await(0,$.t9)("fetchContactList");if(!t)return;e=(0,a.Rd)(),e=(0,c.Sh)(e,(0,I.ee)(t.users,"id")),e=(0,c.fZ)(e,(0,I.ee)(t.chats,"id")),e=(0,c.zn)(e,t.userStatusesById);const n=e=>e.lastName||e.firstName||"",s=new Intl.Collator("en-US"),o=t.users.sort(((e,t)=>s.compare(n(e),n(t)))).filter((e=>!e.isSelf));e={...e,contactList:{userIds:o.map((e=>e.id))}},(0,a.R3)(e)})),(0,a.iw)("loadCurrentUser",(()=>{(0,$.t9)("fetchCurrentUser")})),(0,a.iw)("loadCommonChats",(async(e,t,n)=>{const{tabId:s=(0,m._w)()}=n||{},{chatId:o}=(0,d.Bt)(e,s)||{},i=o?(0,d.dy)(e,o):void 0;if(!i||(0,u.cS)(i)||i.commonChats?.isFullyLoaded)return;const r=i.commonChats?.maxId,l=await(0,$.t9)("fetchCommonChats",i.id,i.accessHash,r);if(!l)return;const{chats:h,chatIds:p,isFullyLoaded:g}=l;e=(0,a.Rd)(),h.length&&(e=(0,c.fZ)(e,(0,I.ee)(h,"id"))),e=(0,c.Nq)(e,i.id,{commonChats:{maxId:p.length?p[p.length-1]:"0",ids:(0,I.Tw)((i.commonChats?.ids||[]).concat(p)),isFullyLoaded:g}}),(0,a.R3)(e)})),(0,a.iw)("updateContact",(async(e,t,n)=>{const{userId:s,isMuted:o=!1,firstName:i,lastName:r,shouldSharePhoneNumber:l,tabId:u=(0,m._w)()}=n,h=(0,d.dy)(e,s);if(!h)return;let p;if(t.updateChatMutedState({chatId:s,isMuted:o}),e=(0,a.Rd)(),e=(0,c.H9)(e,f.wv.InProgress,u),(0,a.R3)(e),!h.isContact&&h.phoneNumber)p=await(0,$.t9)("importContact",{phone:h.phoneNumber,firstName:i,lastName:r});else{const{id:e,accessHash:t}=h;p=await(0,$.t9)("updateContact",{id:e,accessHash:t,phoneNumber:"",firstName:i,lastName:r,shouldSharePhoneNumber:l})}p&&(t.loadChatSettings({chatId:s}),e=(0,a.Rd)(),e=(0,c.Nq)(e,h.id,{firstName:i,lastName:r}),(0,a.R3)(e)),e=(0,a.Rd)(),e=(0,c.H9)(e,f.wv.Complete,u),e=(0,c.ft)(e,u),(0,a.R3)(e)})),(0,a.iw)("deleteContact",(async(e,t,n)=>{const{userId:a}=n,s=(0,d.dy)(e,a);if(!s)return;const{id:o,accessHash:i}=s;await(0,$.t9)("deleteContact",{id:o,accessHash:i})})),(0,a.iw)("loadProfilePhotos",(async(e,t,n)=>{const{profileId:s}=n,o=(0,u.YC)(s);let i=o?(0,d.dy)(e,s):void 0;const r=o?void 0:(0,d.Z1)(e,s);if(!i&&!r)return;if(i&&!i?.fullInfo){const{id:e,accessHash:t}=i;if(i=await(0,$.t9)("fetchFullUser",{id:e,accessHash:t}),!i)return}const l=await(0,$.t9)("fetchProfilePhotos",i,r);if(!l||!l.photos)return;e=(0,a.Rd)();const m=i||r,{photos:h,users:p}=l;h.sort((e=>e.id===m?.avatarHash?-1:1));const g=i?.fullInfo?.fallbackPhoto,f=i?.fullInfo?.personalPhoto;g&&h.push(g),f&&h.unshift(f),e=(0,c.Sh)(e,(0,I.ee)(p,"id")),e=o?(0,c.Nq)(e,s,{photos:h}):(0,c.a4)(e,s,{photos:h}),(0,a.R3)(e)})),(0,a.iw)("setUserSearchQuery",((e,t,n)=>{const{query:s,tabId:o=(0,m._w)()}=n;s&&le((async()=>{const t=await(0,$.t9)("searchChats",{query:s});e=(0,a.Rd)();const n=(0,d.jU)(e,o).userSearch.query;if(!t||!n||s!==n)return e=(0,c.Q3)(e,!1,o),void(0,a.R3)(e);const{localUsers:i,globalUsers:r}=t;let l,u;i.length&&(e=(0,c.Sh)(e,(0,I.ee)(i,"id")),l=i.map((e=>{let{id:t}=e;return t}))),r.length&&(e=(0,c.Sh)(e,(0,I.ee)(r,"id")),u=r.map((e=>{let{id:t}=e;return t}))),e=(0,c.Q3)(e,!1,o),e=(0,c.Lm)(e,{localUserIds:l,globalUserIds:u},o),(0,a.R3)(e)}))})),(0,a.iw)("importContact",(async(e,t,n)=>{const{phoneNumber:s,firstName:o,lastName:i,tabId:r=(0,m._w)()}=n,d=await(0,$.t9)("importContact",{phone:s,firstName:o,lastName:i});d?(t.openChat({id:d,tabId:r}),e=(0,a.Rd)(),e=(0,c.ft)(e,r),(0,a.R3)(e)):t.showNotification({message:b.Iu("Contacts.PhoneNumber.NotRegistred"),tabId:r})})),(0,a.iw)("reportSpam",((e,t,n)=>{const{chatId:a}=n,s=(0,u.YC)(a)?(0,d.dy)(e,a):(0,d.Z1)(e,a);s&&(0,$.t9)("reportSpam",s)})),(0,a.iw)("setEmojiStatus",((e,t,n)=>{const{emojiStatus:a,expires:s}=n;(0,$.t9)("updateEmojiStatus",a,s)}));var he=n(18629);const pe=s.cj||s.wZ;class ge{constructor(e,t){var n,a,s;this.features=e,this.onFail=t,n=this,s=void 0,(a=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,t);if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(a="preOpened"))in n?Object.defineProperty(n,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):n[a]=s}preOpenIfNeeded(){pe&&(this.preOpened=window.open("about:blank",void 0,this.features),this.preOpened?this.preOpened.blur():this.onFail?.())}open(e){if(this.preOpened)return this.preOpened.location.href=e,this.preOpened.focus(),void(this.preOpened=void 0);if(!pe){const t=window.open(e,void 0,this.features);t?t.focus():this.onFail?.()}}cancelPreOpen(){this.preOpened?.close(),this.preOpened=void 0}}const fe="https://prizes.gamee.com/",Ie=(0,N.Ds)((e=>e()),500,!1);async function ve(e,t,n,s){await(0,$.t9)("toggleAttachBot",{bot:t,isWriteAllowed:s,isEnabled:n}),e=(0,a.Rd)(),await we(e)}async function we(e,t){const n=await(0,$.t9)("loadAttachBots",{hash:t});n&&(e=(0,a.Rd)(),e=(0,c.Sh)(e,(0,I.ee)(n.users,"id")),e={...e,attachMenu:{hash:n.hash,bots:n.bots}},(0,a.R3)(e))}function be(e,t,n,s){for(var o=arguments.length,i=new Array(o>4?o-4:0),r=4;r<o;r++)i[r-4]=arguments[r];let[c=(0,m._w)()]=i;if("request"===s.type){e=(0,a.Rd)();const t=(0,d.jU)(e,c);if(!t.urlAuth)return;const{domain:n,bot:o,shouldRequestWriteAccess:i}=s;return e=(0,p.i)(e,{urlAuth:{...t.urlAuth,request:{domain:n,botId:o.id,shouldRequestWriteAccess:i}}},c),void(0,a.R3)(e)}const l="accepted"===s.type?s.url:n;window.open(l,"_blank","noopener"),t.closeUrlAuthModal({tabId:c})}async function ye(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r._f,n=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;await(0,$.t9)("sendMessage",{chat:e,replyingToTopId:t,text:n,replyingTo:a,sendAs:s})}let Pe;async function Ze(e,t,n,a,s){let o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];for(var i=arguments.length,r=new Array(i>6?i-6:0),c=6;c<i;c++)r[c-6]=arguments[c];let[d=(0,m._w)()]=r;const{showDialog:l,showNotification:u,openUrl:h,openGame:p}=t;o&&(Pe||(Pe=new ge("popup,width=800,height=600",(()=>{u({message:"Allow browser to open popup window",tabId:d})}))),Pe.preOpenIfNeeded());const g=await(0,$.t9)("answerCallbackButton",{chatId:n.id,accessHash:n.accessHash,messageId:a,data:s,isGame:o});if(!g)return;const{message:f,alert:I,url:v}=g;I?l({data:{message:f||"Error"},tabId:d}):f?u({message:f,tabId:d}):v&&(o?v.includes(fe)?Pe.open(v):(Pe.cancelPreOpen(),p({url:v,chatId:n.id,messageId:a,tabId:d})):h({url:v,tabId:d}))}function Ce(e){const t=Object.keys(e).map((t=>`${t}=${e[t]}`)).join("&");return t.length>0?`?${t}`:""}async function Se(e,t){for(var n=arguments.length,s=new Array(n>2?n-2:0),o=2;o<n;o++)s[o-2]=arguments[o];let[i=(0,m._w)()]=s;const r=await(0,$.t9)("getPaymentForm",t);if(!r)return;const{form:d,invoice:l,users:u}=r;return e=(0,a.Rd)(),e=(0,c._7)(e,d,i),e=(0,c.Q$)(e,f.KB.Checkout,i),e=(0,c.Sh)(e,(0,I.ee)(u,"id")),(0,a.R3)(e),l}async function Ee(e,t,n,s){for(var o=arguments.length,i=new Array(o>4?o-4:0),r=4;r<o;r++)i[r-4]=arguments[r];let[d=(0,m._w)()]=i;const l=await(0,$.t9)("validateRequestedInfo",{inputInvoice:t,requestInfo:n,shouldSave:s});if(!l)return;const{id:u,shippingOptions:h}=l;e=(0,a.Rd)(),e=(0,c.vT)(e,u,d),h?(e=(0,c.TM)(e,h,d),e=(0,c.Q$)(e,f.KB.Shipping,d)):e=(0,c.Q$)(e,f.KB.Checkout,d),(0,a.R3)(e)}(0,a.iw)("clickBotInlineButton",((e,t,n)=>{const{messageId:a,button:s,tabId:o=(0,m._w)()}=n;switch(s.type){case"command":t.sendBotCommand({command:s.text,tabId:o});break;case"url":{const{url:e}=s;t.openUrl({url:e,tabId:o});break}case"callback":{const n=(0,d.jr)(e,o);if(!n)return;Ze(e,t,n,a,s.data,void 0,o);break}case"requestPoll":t.openPollModal({isQuiz:s.isQuiz,tabId:o});break;case"requestPhone":{const n=e.currentUserId?(0,d.dy)(e,e.currentUserId):void 0;if(!n)return;t.showDialog({data:{phoneNumber:n.phoneNumber,firstName:n.firstName,lastName:n.lastName,userId:n.id},tabId:o});break}case"receipt":{const n=(0,d.jr)(e,o);if(!n)return;const{receiptMessageId:i}=s;t.getReceipt({receiptMessageId:i,chatId:n.id,messageId:a,tabId:o});break}case"buy":{const n=(0,d.jr)(e,o);if(!n)return;t.openInvoice({chatId:n.id,messageId:a,tabId:o});break}case"game":{const n=(0,d.jr)(e,o);if(!n)return;Ze(e,t,n,a,void 0,!0,o);break}case"switchBotInline":{const{query:e,isSamePeer:n}=s;t.switchBotInline({query:e,isSamePeer:n,messageId:a,tabId:o});break}case"userProfile":{const{userId:e}=s;t.openChatWithInfo({id:e,tabId:o});break}case"simpleWebView":{const{url:n}=s,{chatId:i}=(0,d.Bt)(e,o)||{};if(!i)return;const r=(0,d.hj)(e,i,a);if(!r?.senderId)return;const c=(0,he.BS)();t.requestSimpleWebView({url:n,botId:r?.senderId,theme:c,buttonText:s.text,tabId:o});break}case"webView":{const{url:n}=s,i=(0,d.jr)(e,o);if(!i)return;const r=(0,d.hj)(e,i.id,a);if(!r)return;const c=r.viaBotId||r.senderId;if(!c)return;const l=(0,he.BS)();t.requestWebView({url:n,botId:c,peerId:i.id,theme:l,buttonText:s.text,tabId:o});break}case"urlAuth":{const{url:n}=s,i=(0,d.jr)(e,o);if(!i)return;t.requestBotUrlAuth({chatId:i.id,messageId:a,buttonId:s.buttonId,url:n,tabId:o});break}}})),(0,a.iw)("sendBotCommand",((e,t,n)=>{const{command:a,chatId:s,tabId:o=(0,m._w)()}=n,i=s?(0,d.Z1)(e,s):(0,d.jr)(e,o),r=(0,d.Bt)(e,o);if(!i||!r)return;const{threadId:c}=r;t.setReplyingToId({messageId:void 0,tabId:o}),t.clearWebPagePreview({tabId:o}),ye(i,c,a,(0,d.Yy)(e,i.id,c),(0,d._5)(e,i.id))})),(0,a.iw)("restartBot",(async(e,t,n)=>{const{chatId:s,tabId:o=(0,m._w)()}=n,{currentUserId:i}=e,l=(0,d.jr)(e,o),u=i&&(0,d.IK)(e,s);i&&l&&u&&await(0,$.t9)("unblockContact",u.id,u.accessHash)&&(e=(0,a.Rd)(),e=(0,c.rB)(e,u.id),(0,a.R3)(e),ye(l,r._f,"/start",void 0,(0,d._5)(e,s)))})),(0,a.iw)("loadTopInlineBots",(async e=>{const{lastRequestedAt:t}=e.topInlineBots;if(t&&(0,v.bp)()-t<60)return;const n=await(0,$.t9)("fetchTopInlineBots");if(!n)return;const{ids:s,users:o}=n;e=(0,a.Rd)(),e=(0,c.Sh)(e,(0,I.ee)(o,"id")),e={...e,topInlineBots:{...e.topInlineBots,userIds:s,lastRequestedAt:(0,v.bp)()}},(0,a.R3)(e)})),(0,a.iw)("queryInlineBot",(async(e,t,n)=>{const{chatId:s,username:o,query:i,offset:r,tabId:l=(0,m._w)()}=n;let u=(0,d.jU)(e,l).inlineBots.byUsername[o];if(!1!==u){if(void 0===u){const{user:t,chat:n}=await(0,$.t9)("fetchInlineBot",{username:o})||{};if(e=(0,a.Rd)(),!t||!n)return e=ue(e,o,!1,l),void(0,a.R3)(e);e=(0,c.Sh)(e,{[t.id]:t}),e=(0,c.fZ)(e,{[n.id]:n}),u={id:t.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[],cacheTime:0},e=ue(e,o,u,l),(0,a.R3)(e)}(i!==u.query||u.canLoadMore)&&Ie((()=>{!async function(e,t){let{username:n,inlineBotData:s,chatId:o,query:i,offset:r}=t;for(var c=arguments.length,l=new Array(c>2?c-2:0),u=2;u<c;u++)l[u-2]=arguments[u];let[h=(0,m._w)()]=l;e=(0,a.Rd)();const p=(0,d.dy)(e,s.id),g=(0,d.Z1)(e,o);if(!p||!g)return;const f=s.query!==i;e=ue(e=me(e,!0,h),n,{...s,query:i,...f&&{offset:void 0,results:[]}},h),(0,a.R3)(e);const I=await(0,$.t9)("fetchInlineBotResults",{bot:p,chat:g,query:i,offset:f?void 0:r});e=(0,a.Rd)();const v=(0,d.jU)(e,h).inlineBots.byUsername[n];if(e=me(e,!1,h),!I||!v||i!==v.query)return void(0,a.R3)(e);const w=new Set((v.results||[]).map((e=>e.id))),b=I.results.filter((e=>!w.has(e.id)));e=ue(e,n,{...v,help:I.help,cacheTime:Date.now()+1e3*I.cacheTime,...b.length&&{isGallery:I.isGallery},...I.switchPm&&{switchPm:I.switchPm},canLoadMore:I.results.length>0&&Boolean(I.nextOffset),results:""===v.offset||v.offset===I.nextOffset?I.results:(v.results||[]).concat(b),offset:b.length?I.nextOffset:""},h),(0,a.R3)(e)}(e,{username:o,inlineBotData:u,chatId:s,query:i,offset:r},l)}))}})),(0,a.iw)("switchBotInline",((e,t,n)=>{const{query:a,isSamePeer:s,messageId:o,tabId:i=(0,m._w)()}=n,r=(0,d.jr)(e,i);if(!r)return;const c=(0,d.hj)(e,r.id,o);if(!c)return;const l=(0,d.dy)(e,c.viaBotId||c.senderId);l&&t.openChatWithDraft({text:`@${l.usernames[0].username} ${a}`,chatId:s?r.id:void 0,tabId:i})})),(0,a.iw)("sendInlineBotResult",((e,t,n)=>{const{id:a,queryId:s,isSilent:o,scheduledAt:i,tabId:c=(0,m._w)()}=n,l=(0,d.Bt)(e,c);if(!l||!a)return;const{chatId:u,threadId:h}=l,p=(0,d.Z1)(e,u),g=(0,d.Yy)(e,u,h);let f;g&&h!==r._f&&(f=(0,d.qS)(e,u,h)),t.setReplyingToId({messageId:void 0,tabId:c}),t.clearWebPagePreview({tabId:c}),(0,$.t9)("sendInlineBotResult",{chat:p,resultId:a,queryId:s,replyingTo:g,replyingToTopId:f,sendAs:(0,d._5)(e,u),isSilent:o,scheduleDate:i})})),(0,a.iw)("resetInlineBot",((e,t,n)=>{const{username:s,force:o,tabId:i=(0,m._w)()}=n;let r=(0,d.jU)(e,i).inlineBots.byUsername[s];r&&(!o&&Date.now()<r.cacheTime||(r={id:r.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[],cacheTime:0},e=ue(e,s,r,i),(0,a.R3)(e)))})),(0,a.iw)("resetAllInlineBots",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},s=(0,d.jU)(e,a).inlineBots.byUsername;Object.keys(s).forEach((e=>{t.resetInlineBot({username:e,tabId:a})}))})),(0,a.iw)("startBot",(async(e,t,n)=>{const{botId:s,param:o}=n;let i=(0,d.dy)(e,s);i&&(i.fullInfo||await(0,$.t9)("fetchFullUser",{id:i.id,accessHash:i.accessHash}),e=(0,a.Rd)(),i=(0,d.dy)(e,s),i.fullInfo?.isBlocked&&await(0,$.t9)("unblockContact",i.id,i.accessHash),await(0,$.t9)("startBot",{bot:i,startParam:o}))})),(0,a.iw)("requestSimpleWebView",(async(e,t,n)=>{const{url:s,botId:o,theme:i,buttonText:r,tabId:c=(0,m._w)()}=n,l=(0,d.dy)(e,o);if(!l)return;if(!(0,d.LM)(e,o))return e=(0,p.i)(e,{botTrustRequest:{botId:o,type:"webApp",onConfirm:{action:"requestSimpleWebView",payload:n}}},c),void(0,a.R3)(e);const u=await(0,$.t9)("requestSimpleWebView",{url:s,bot:l,theme:i});u&&(e=(0,a.Rd)(),e=(0,p.i)(e,{webApp:{url:u,botId:o,buttonText:r}},c),(0,a.R3)(e))})),(0,a.iw)("requestWebView",(async(e,t,n)=>{const{url:s,botId:o,peerId:i,theme:r,isSilent:c,buttonText:l,isFromBotMenu:u,startParam:h,tabId:g=(0,m._w)()}=n,f=(0,d.dy)(e,o);if(!f)return;const I=(0,d.Z1)(e,i);if(!I)return;if(!(0,d.LM)(e,o))return e=(0,p.i)(e,{botTrustRequest:{botId:o,type:"webApp",onConfirm:{action:"requestWebView",payload:n}}},g),void(0,a.R3)(e);const v=(0,d.Bt)(e,g);if(!v)return;const{chatId:w,threadId:b}=v,y=w&&(0,d.Yy)(e,w,b),P=(0,d._5)(e,w),Z=await(0,$.t9)("requestWebView",{url:s,bot:f,peer:I,theme:r,isSilent:c,replyToMessageId:y||void 0,threadId:b,isFromBotMenu:u,startParam:h,sendAs:P});if(!Z)return;const{url:C,queryId:S}=Z;e=(0,a.Rd)(),e=(0,p.i)(e,{webApp:{url:C,botId:o,queryId:S,replyToMessageId:y||void 0,threadId:b,buttonText:l}},g),(0,a.R3)(e)})),(0,a.iw)("prolongWebView",(async(e,t,n)=>{const{botId:a,peerId:s,isSilent:o,replyToMessageId:i,queryId:r,threadId:c,tabId:l=(0,m._w)()}=n,u=(0,d.dy)(e,a);if(!u)return;const h=(0,d.Z1)(e,s);if(!h)return;const p=(0,d._5)(e,s);await(0,$.t9)("prolongWebView",{bot:u,peer:h,isSilent:o,replyToMessageId:i,threadId:c,queryId:r,sendAs:p})||t.closeWebApp({tabId:l})})),(0,a.iw)("sendWebViewData",((e,t,n)=>{const{bot:a,data:s,buttonText:o}=n;(0,$.t9)("sendWebViewData",{bot:a,data:s,buttonText:o})})),(0,a.iw)("closeWebApp",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{webApp:void 0},a)})),(0,a.iw)("setWebAppPaymentSlug",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n,s=(0,d.jU)(e,a);if(s.webApp?.url)return(0,p.i)(e,{webApp:{...s.webApp,slug:n.slug}},a)})),(0,a.iw)("cancelBotTrustRequest",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{botTrustRequest:void 0},a)})),(0,a.iw)("markBotTrusted",((e,t,n)=>{const{botId:s,tabId:o=(0,m._w)()}=n,{trustedBotIds:i}=e,r=new Set(i);r.add(s),e={...e,trustedBotIds:Array.from(r)};const c=(0,d.jU)(e,o);if(c.botTrustRequest?.onConfirm){const{action:e,payload:n}=c.botTrustRequest.onConfirm;t[e](n)}e=(0,p.i)(e,{botTrustRequest:void 0},o),(0,a.R3)(e)})),(0,a.iw)("loadAttachBots",(async(e,t,n)=>{const{hash:a}=n||{};await we(e,a)})),(0,a.iw)("toggleAttachBot",(async(e,t,n)=>{const{botId:a,isWriteAllowed:s,isEnabled:o}=n,i=(0,d.dy)(e,a);i&&await ve(e,i,o,s)})),(0,a.iw)("callAttachBot",((e,t,n)=>{const{chatId:a,bot:s,url:o,startParam:i,threadId:r,tabId:c=(0,m._w)()}=n,d=!s;if(!d&&!e.attachMenu.bots[s.id])return(0,p.i)(e,{requestedAttachBotInstall:{bot:s,onConfirm:{action:"callAttachBot",payload:n}}},c);const l=(0,he.BS)();t.openChat({id:a,threadId:r,tabId:c}),t.requestWebView({url:o,peerId:a,botId:d?a:s.id,theme:l,buttonText:"",isFromBotMenu:d,startParam:i,tabId:c})})),(0,a.iw)("confirmAttachBotInstall",(async(e,t,n)=>{const{isWriteAllowed:s,tabId:o=(0,m._w)()}=n,{requestedAttachBotInstall:i}=(0,d.jU)(e,o),{bot:r,onConfirm:c}=i;e=(0,p.i)(e,{requestedAttachBotInstall:void 0},o),(0,a.R3)(e);const l=(0,d.dy)(e,r.id);if(l&&(await ve(e,l,!0,s),c)){const{action:e,payload:n}=c;t[e](n)}})),(0,a.iw)("cancelAttachBotInstall",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{requestedAttachBotInstall:void 0},a)})),(0,a.iw)("requestAttachBotInChat",((e,t,n)=>{const{bot:s,filter:o,startParam:i,tabId:r=(0,m._w)()}=n,c=(0,d.Bt)(e,r)?.chatId,l=s.peerTypes.filter((e=>"self"!==e&&o.includes(e)));l.length?(e=(0,p.i)(e,{requestedAttachBotInChat:{bot:s,filter:l,startParam:i}},r),(0,a.R3)(e)):t.callAttachBot({chatId:c||s.id,bot:s,startParam:i,tabId:r})})),(0,a.iw)("cancelAttachBotInChat",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{requestedAttachBotInChat:void 0},a)})),(0,a.iw)("requestBotUrlAuth",(async(e,t,n)=>{const{chatId:s,buttonId:o,messageId:i,url:r,tabId:c=(0,m._w)()}=n,l=(0,d.Z1)(e,s);if(!l)return;const u=await(0,$.t9)("requestBotUrlAuth",{chat:l,buttonId:o,messageId:i});u&&(e=(0,a.Rd)(),e=(0,p.i)(e,{urlAuth:{url:r,button:{buttonId:o,messageId:i,chatId:l.id}}},c),(0,a.R3)(e),be(e,t,r,u,c))})),(0,a.iw)("acceptBotUrlAuth",(async(e,t,n)=>{const{isWriteAllowed:s,tabId:o=(0,m._w)()}=n,i=(0,d.jU)(e,o);if(!i.urlAuth?.button)return;const{button:r,url:c}=i.urlAuth,{chatId:l,messageId:u,buttonId:h}=r,p=(0,d.Z1)(e,l);if(!p)return;const g=await(0,$.t9)("acceptBotUrlAuth",{chat:p,messageId:u,buttonId:h,isWriteAllowed:s});g&&be(e=(0,a.Rd)(),t,c,g,o)})),(0,a.iw)("requestLinkUrlAuth",(async(e,t,n)=>{const{url:s,tabId:o=(0,m._w)()}=n,i=await(0,$.t9)("requestLinkUrlAuth",{url:s});i&&(e=(0,a.Rd)(),e=(0,p.i)(e,{urlAuth:{url:s}},o),(0,a.R3)(e),be(e,t,s,i,o))})),(0,a.iw)("acceptLinkUrlAuth",(async(e,t,n)=>{const{isWriteAllowed:s,tabId:o=(0,m._w)()}=n,i=(0,d.jU)(e,o);if(!i.urlAuth?.url)return;const{url:r}=i.urlAuth,c=await(0,$.t9)("acceptLinkUrlAuth",{url:r,isWriteAllowed:s});c&&be(e=(0,a.Rd)(),t,r,c,o)})),(0,a.iw)("closeUrlAuthModal",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{urlAuth:void 0},a)})),n(55282),(0,a.iw)("loadPasswordInfo",(async e=>{const t=await(0,$.t9)("getPasswordInfo");t&&(e=(0,a.Rd)(),e=(0,c.BI)(e,{hasPassword:t.hasPassword}),e=(0,c.IE)(e,{hint:t.hint}),(0,a.R3)(e))})),(0,a.iw)("checkPassword",(async(e,t,n)=>{const{currentPassword:s,onSuccess:o}=n;e=(0,c.IE)(e,{isLoading:!0,error:void 0}),(0,a.R3)(e);const i=await(0,$.t9)("checkPassword",s);e=(0,a.Rd)(),e=(0,c.IE)(e,{isLoading:!1}),(0,a.R3)(e),i&&o()})),(0,a.iw)("clearPassword",(async(e,t,n)=>{const{currentPassword:s,onSuccess:o}=n;e=(0,c.IE)(e,{isLoading:!0,error:void 0}),(0,a.R3)(e);const i=await(0,$.t9)("clearPassword",s);e=(0,a.Rd)(),e=(0,c.IE)(e,{isLoading:!1}),(0,a.R3)(e),i&&o()})),(0,a.iw)("updatePassword",(async(e,t,n)=>{const{currentPassword:s,password:o,hint:i,email:r,onSuccess:d}=n;e=(0,c.IE)(e,{isLoading:!0,error:void 0}),(0,a.R3)(e);const l=await(0,$.t9)("updatePassword",s,o,i,r);e=(0,a.Rd)(),e=(0,c.IE)(e,{isLoading:!1}),(0,a.R3)(e),l&&d()})),(0,a.iw)("updateRecoveryEmail",(async(e,t,n)=>{const{currentPassword:s,email:o,onSuccess:i}=n;e=(0,c.IE)(e,{isLoading:!0,error:void 0}),(0,a.R3)(e);const r=await(0,$.t9)("updateRecoveryEmail",s,o);e=(0,a.Rd)(),e=(0,c.IE)(e,{isLoading:!1,waitingEmailCodeLength:void 0}),(0,a.R3)(e),r&&i()})),(0,a.iw)("provideTwoFaEmailCode",((e,t,n)=>{const{code:a}=n;(0,$.t9)("provideRecoveryEmailCode",a)})),(0,a.iw)("clearTwoFaError",(e=>(0,c.IE)(e,{error:void 0}))),(0,a.iw)("validateRequestedInfo",((e,t,n)=>{const{requestInfo:a,saveInfo:s,tabId:o=(0,m._w)()}=n,i=(0,d.kb)(e,o);if(i)if("slug"in i)Ee(e,i,a,s,o);else{const t=(0,d.Z1)(e,i.chatId);if(!t)return;Ee(e,{chat:t,messageId:i.messageId},a,s,o)}})),(0,a.iw)("openInvoice",(async(e,t,n)=>{const{tabId:s=(0,m._w)()}=n;let o;if("slug"in n)o=await Se(e,{slug:n.slug},s);else{const t=(0,d.Z1)(e,n.chatId);if(!t)return;o=await Se(e,{chat:t,messageId:n.messageId},s)}o&&(e=(0,a.Rd)(),e=(0,c.bs)(e,o,s),e=(0,p.i)(e,{payment:{...(0,d.jU)(e,s).payment,inputInvoice:n,isPaymentModalOpen:!0,status:"cancelled",isExtendedMedia:n.isExtendedMedia}},s),(0,a.R3)(e))})),(0,a.iw)("getReceipt",(async(e,t,n)=>{const{receiptMessageId:s,chatId:o,messageId:i,tabId:r=(0,m._w)()}=n,l=o&&(0,d.Z1)(e,o);if(!i||!s||!l)return;const u=await(0,$.t9)("getReceipt",l,s);if(!u)return;e=(0,a.Rd)();const h=(0,d.hj)(e,l.id,i);e=(0,c.Sh)(e,(0,I.ee)(u.users,"id")),e=(0,c.Dq)(e,u.receipt,h,r),(0,a.R3)(e)})),(0,a.iw)("clearPaymentError",((e,t,n)=>{const{tabId:s=(0,m._w)()}=n||{};e=(0,p.i)(e,{payment:{...(0,d.jU)(e,s).payment,error:void 0}},s),(0,a.R3)(e)})),(0,a.iw)("clearReceipt",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{};return(0,p.i)(e,{payment:{...(0,d.jU)(e,a).payment,receipt:void 0}},a)})),(0,a.iw)("sendCredentialsInfo",((e,t,n)=>{const{credentials:s,tabId:i=(0,m._w)()}=n,{nativeProvider:r}=(0,d.jU)(e,i).payment,{data:l}=s;if("stripe"===r){const t=(0,d.$$)(e,i);if(!t)return;!async function(e,t,n){for(var s=arguments.length,o=new Array(s>3?s-3:0),i=3;i<s;i++)o[i-3]=arguments[i];let[r=(0,m._w)()]=o;const l=Ce({"card[number]":t.cardNumber,"card[exp_month]":t.expiryMonth,"card[exp_year]":t.expiryYear,"card[cvc]":t.cvv,"card[address_zip]":t.zip,"card[address_country]":t.country}),h=await fetch(`https://api.stripe.com/v1/tokens${l}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${n}`}}),g=await h.json();if(g.error){const t=(0,u.Ow)(g.error);return e=(0,a.Rd)(),e=(0,p.i)(e,{payment:{...(0,d.jU)(e,r).payment,status:"failed",error:{...t}}},r),void(0,a.R3)(e)}e=(0,a.Rd)(),e=(0,c.QH)(e,{type:g.type,id:g.id},r),e=(0,c.Q$)(e,f.KB.Checkout,r),(0,a.R3)(e)}(e,l,t,i)}else if("smartglocal"===r){const t=(0,d.EB)(e,i);if(!t)return;!async function(e,t,n){for(var s=arguments.length,i=new Array(s>3?s-3:0),r=3;r<s;r++)i[r-3]=arguments[r];let[l=(0,m._w)()]=i;const u={card:{number:t.cardNumber.replace(/\D+/g,""),expiration_month:t.expiryMonth,expiration_year:t.expiryYear,security_code:t.cvv.replace(/\D+/g,"")}},h=o.eAU?"https://tgb-playground.smart-glocal.com/cds/v1/tokenize/card":"https://tgb.smart-glocal.com/cds/v1/tokenize/card",g=await fetch(h,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","X-PUBLIC-TOKEN":n},body:JSON.stringify(u)}),I=await g.json();if("ok"!==I.status){const t={description:"payment error"};return e=(0,a.Rd)(),e=(0,p.i)(e,{payment:{...(0,d.jU)(e,l).payment,status:"failed",error:{...t}}},l),void(0,a.R3)(e)}e=(0,a.Rd)(),e=(0,c.QD)(e,{type:"card",token:I.data.token},l),e=(0,c.Q$)(e,f.KB.Checkout,l),(0,a.R3)(e)}(e,l,t,i)}})),(0,a.iw)("sendPaymentForm",(async(e,t,n)=>{const{shippingOptionId:s,saveCredentials:o,savedCredentialId:i,tipAmount:r,tabId:l=(0,m._w)()}=n,u=(0,d.kb)(e,l),h=(0,d.eh)(e,l),p=(0,d.sp)(e,l),{nativeProvider:g,temporaryPassword:f}=(0,d.jU)(e,l).payment,I="stripe"===g?(0,d.$$)(e,l):(0,d.EB)(e,l);if(!(u&&I&&h&&g))return;let v;if("slug"in u)v={slug:u.slug};else{const t=(0,d.Z1)(e,u.chatId);if(!t)return;v={chat:t,messageId:u.messageId}}e=(0,c.cQ)(e,{status:"pending"},l),(0,a.R3)(e);const w={save:o,data:"stripe"===g?(0,d.i3)(e,l):(0,d.Jg)(e,l)};await(0,$.t9)("sendPaymentForm",{inputInvoice:v,formId:h,credentials:w,requestedInfoId:p,shippingOptionId:s,savedCredentialId:i,temporaryPassword:f?.value,tipAmount:r})&&(e=(0,a.Rd)(),e=(0,c.cQ)(e,{status:"paid"},l),e=(0,c.WY)(e,l),(0,a.R3)(e))})),(0,a.iw)("setPaymentStep",((e,t,n)=>{const{step:a,tabId:s=(0,m._w)()}=n;return(0,c.Q$)(e,null!=a?a:f.KB.Checkout,s)})),(0,a.iw)("closePremiumModal",((e,t,n)=>{const{isClosed:a,tabId:s=(0,m._w)()}=n||{},o=(0,d.jU)(e,s);if(o.premiumModal)return(0,p.i)(e,{premiumModal:{...o.premiumModal,...a&&{isOpen:!1},isClosing:!a}},s)})),(0,a.iw)("openPremiumModal",(async(e,t,n)=>{const{initialSection:s,fromUserId:o,isSuccess:i,isGift:r,monthsAmount:d,toUserId:l,tabId:u=(0,m._w)()}=n||{};t.loadPremiumStickers();const h=await(0,$.t9)("fetchPremiumPromo");h&&(e=(0,a.Rd)(),e=(0,c.Sh)(e,(0,I.ee)(h.users,"id")),e=(0,p.i)(e,{premiumModal:{promo:h.promo,initialSection:s,isOpen:!0,fromUserId:o,toUserId:l,isGift:r,monthsAmount:d,isSuccess:i}},u),(0,a.R3)(e))})),(0,a.iw)("openGiftPremiumModal",(async(e,t,n)=>{const{forUserId:s,tabId:o=(0,m._w)()}=n||{},i=await(0,$.t9)("fetchPremiumPromo");if(!i)return;e=(0,a.Rd)(),e=(0,c.Sh)(e,(0,I.ee)(i.users,"id"));const r=i.promo.options.find((e=>1===e.months));e=(0,p.i)(e,{giftPremiumModal:{isOpen:!0,forUserId:s,monthlyCurrency:r.currency,monthlyAmount:r.amount}},o),(0,a.R3)(e)})),(0,a.iw)("closeGiftPremiumModal",((e,t,n)=>{const{tabId:s=(0,m._w)()}=n||{};e=(0,p.i)(e,{giftPremiumModal:{isOpen:!1}},s),(0,a.R3)(e)})),(0,a.iw)("validatePaymentPassword",(async(e,t,n)=>{const{password:s,tabId:o=(0,m._w)()}=n,i=await(0,$.t9)("fetchTemporaryPaymentPassword",s);e=(0,a.Rd)(),e=i?"error"in i?(0,c.cQ)(e,{error:{message:i.error,field:"password"}},o):(0,c.cQ)(e,{temporaryPassword:i,step:f.KB.Checkout},o):(0,c.cQ)(e,{error:{message:"Unknown Error",field:"password"}},o),(0,a.R3)(e)}));var Me=n(40647),Re=n(74399);const ke=32*Re.Gw,Te=45.5*Re.Gw,Ae=26.5*Re.Gw,Ne=16*Re.Gw,xe=16.125*Re.Gw;var Be=n(43858),Le=n(53475),Ue=n(4907);function je(e,t){return t-((0,d.jU)(e).isLeftColumnShown&&!(0,C.W7)()?e.leftColumnWidth||((n=Be.Z.get().width)>o._mX?Math.min(Math.max(.25*n,Ne),.33*n):n>o.ksF?Math.min(Math.max(.33*n,Ne),.4*n):Ae):0);var n}function Oe(e,t,n){return(0,Le.a4)(e,t,n,void 0,!0)}let Fe=0;(0,a.iw)("loadAvailableReactions",(async e=>{const t=await(0,$.t9)("getAvailableReactions");t&&(t.forEach((e=>{e.aroundAnimation&&Me.he(`sticker${e.aroundAnimation.id}`,r.IU.BlobUrl),e.centerIcon&&Me.he(`sticker${e.centerIcon.id}`,r.IU.BlobUrl)})),e=(0,a.Rd)(),e={...e,availableReactions:t},(0,a.R3)(e))})),(0,a.iw)("interactWithAnimatedEmoji",((e,t,n)=>{const{emoji:a,x:s,y:o,startSize:i,isReversed:r,tabId:c=(0,m._w)()}=n,l={id:Fe++,animatedEffect:a,x:je(e,s)+40*Math.random()-20,y:o+40*Math.random()-20,startSize:i,isReversed:r};return(0,p.i)(e,{activeEmojiInteractions:[...(0,d.jU)(e,c).activeEmojiInteractions||[],l]},c)})),(0,a.iw)("sendEmojiInteraction",((e,t,n)=>{const{messageId:a,chatId:s,emoji:o,interactions:i}=n,r=(0,d.Z1)(e,s);r&&o&&s!==e.currentUserId&&(0,$.t9)("sendEmojiInteraction",{chat:r,messageId:a,emoticon:o,timestamps:i})})),(0,a.iw)("sendDefaultReaction",((e,t,n)=>{const{chatId:a,messageId:s,tabId:o=(0,m._w)()}=n,i=(0,d.q6)(e,a),r=(0,d.hj)(e,a,s);i&&r&&!(0,u.CI)(r)&&t.toggleReaction({chatId:a,messageId:s,reaction:i,tabId:o})})),(0,a.iw)("toggleReaction",((e,t,n)=>{const{chatId:a,reaction:s,tabId:i=(0,m._w)()}=n;let{messageId:r}=n;const c=(0,d.Z1)(e,a);let l=(0,d.hj)(e,a,r);if(!c||!l)return;const h=Boolean(l.groupedId)&&!l.isInAlbum,g=h?(0,d.xH)(e,a,l.groupedId)[0]:void 0;l=h&&(0,d.hj)(e,a,g)||l,r=l?.id||r;const f=(0,u.UZ)(l),v=f.some((e=>(0,u.Hl)(e,s))),w=v?f.filter((e=>!(0,u.Hl)(e,s))):[...f,s],b=(0,d.oC)(e),y=w.slice(-b);(0,$.t9)("sendReaction",{chat:c,messageId:r,reactions:y});const{animationLevel:P}=e.settings.byKey,Z=(0,d.jU)(e,i);if(P===o.zy8){const t=v?(0,I.CE)(Z.activeReactions,[r]):{...Z.activeReactions,[r]:[...Z.activeReactions[r]||[],{messageId:r,reaction:s}]};e=(0,p.i)(e,{activeReactions:t},i)}return function(e,t,n){const a=t.reactions||{results:[]},s=a.results.map((e=>(0,u.Bt)(e)?{...e,chosenOrder:void 0,count:e.count-1}:e)).filter((e=>{let{count:t}=e;return t>0}));n.forEach(((e,t)=>{const n=s.findIndex((t=>(0,u.Hl)(t.reaction,e)));n>-1?s[n]={...s[n],chosenOrder:t,count:s[n].count+1}:s.push({reaction:e,chosenOrder:t,count:1})}));let{recentReactions:o=[]}=a;return o.length&&(o=o.filter((t=>{let{userId:n}=t;return n!==e.currentUserId}))),n.forEach((t=>{const{currentUserId:n}=e;o.unshift({userId:n,reaction:t})})),(0,Ue.cY)(e,t.chatId,t.id,{reactions:{...a,results:s,recentReactions:o}})}(e,l,y)})),(0,a.iw)("stopActiveReaction",((e,t,n)=>{const{messageId:a,reaction:s,tabId:o=(0,m._w)()}=n,i=(0,d.jU)(e,o);if(!i.activeReactions[a]?.some((e=>(0,u.Hl)(e.reaction,s))))return e;const r=i.activeReactions[a].filter((e=>!(0,u.Hl)(e.reaction,s))),c=r.length?{...i.activeReactions,[a]:r}:(0,I.CE)(i.activeReactions,[a]);return(0,p.i)(e,{activeReactions:c},o)})),(0,a.iw)("setDefaultReaction",(async(e,t,n)=>{const{reaction:s}=n;await(0,$.t9)("setDefaultReaction",{reaction:s})&&((e=(0,a.Rd)()).config?(e={...e,config:{...e.config,defaultReaction:s}},(0,a.R3)(e)):t.loadConfig())})),(0,a.iw)("stopActiveEmojiInteraction",((e,t,n)=>{const{id:a,tabId:s=(0,m._w)()}=n;return(0,p.i)(e,{activeEmojiInteractions:(0,d.jU)(e,s).activeEmojiInteractions?.filter((e=>e.id!==a))},s)})),(0,a.iw)("loadReactors",(async(e,t,n)=>{const{chatId:s,messageId:o,reaction:i}=n,r=(0,d.Z1)(e,s),l=(0,d.hj)(e,s,o);if(!r||!l)return;const u=l.reactors?.nextOffset,m=await(0,$.t9)("fetchMessageReactionsList",{reaction:i,chat:r,messageId:o,offset:u});m&&(e=(0,a.Rd)(),m.users?.length&&(e=(0,c.Sh)(e,(0,I.ee)(m.users,"id"))),e=(0,c.cY)(e,s,o,{reactors:m}),(0,a.R3)(e))})),(0,a.iw)("loadMessageReactions",((e,t,n)=>{const{ids:a,chatId:s}=n,o=(0,d.Z1)(e,s);o&&(0,$.t9)("fetchMessageReactions",{ids:a,chat:o})})),(0,a.iw)("sendWatchingEmojiInteraction",((e,t,n)=>{const{chatId:a,emoticon:s,x:o,y:i,startSize:r,isReversed:c,id:l,tabId:u=(0,m._w)()}=n,h=(0,d.Z1)(e,a),g=(0,d.jU)(e,u);if(h&&g.activeEmojiInteractions?.some((e=>e.id===l))&&a!==e.currentUserId)return(0,$.t9)("sendWatchingEmojiInteraction",{chat:h,emoticon:s}),(0,p.i)(e,{activeEmojiInteractions:g.activeEmojiInteractions.map((t=>t.id===l?{...t,x:je(e,o),y:i,startSize:r,isReversed:c}:t))},u)})),(0,a.iw)("fetchUnreadReactions",(async(e,t,n)=>{const{chatId:s,offsetId:o}=n,i=(0,d.Z1)(e,s);if(!i)return;const r=await(0,$.t9)("fetchUnreadReactions",{chat:i,offsetId:o,addOffset:o?-1:void 0});if(!r||!r.messages.length)return e=Oe(e=(0,a.Rd)(),s,{unreadReactionsCount:0}),void(0,a.R3)(e);const{messages:l,chats:u,users:m}=r,h=(0,I.ee)(l,"id"),p=Object.keys(h).map(Number);e=(0,a.Rd)(),e=(0,c.c_)(e,i.id,h),e=(0,c.Sh)(e,(0,I.ee)(m,"id")),e=Oe(e=(0,c.fZ)(e,(0,I.ee)(u,"id")),s,{unreadReactions:[...i.unreadReactions||[],...p]}),(0,a.R3)(e)})),(0,a.iw)("animateUnreadReaction",((e,t,n)=>{const{messageIds:s,tabId:i=(0,m._w)()}=n,{animationLevel:r}=e.settings.byKey,c=(0,d.jr)(e,i);if(c){if(c.unreadReactionsCount){const n=c.unreadReactionsCount-s.length,o=(c.unreadReactions||[]).filter((e=>!s.includes(e)));e=Oe(e,c.id,{unreadReactions:o}),(0,a.R3)(e),!o.length&&n&&t.fetchUnreadReactions({chatId:c.id,offsetId:Math.min(...s)})}if(t.markMessagesRead({messageIds:s,tabId:i}),r===o.zy8)return e=(0,a.Rd)(),(0,p.i)(e,{activeReactions:{...(0,d.jU)(e,i).activeReactions,...Object.fromEntries(s.map((t=>{const n=(0,d.hj)(e,c.id,t);if(!n)return;const a=n.reactions?.recentReactions?.filter((e=>{let{isUnread:t}=e;return t}));if(!a)return;const s=a.map((e=>e.reaction));return[t,s.map((e=>({messageId:t,reaction:e})))]})).filter(Boolean))}},i)}})),(0,a.iw)("focusNextReaction",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},s=(0,d.jr)(e,a);s?.unreadReactions&&t.focusMessage({chatId:s.id,messageId:s.unreadReactions[0],tabId:a})})),(0,a.iw)("readAllReactions",((e,t,n)=>{const{tabId:a=(0,m._w)()}=n||{},s=(0,d.jr)(e,a);if(s)return(0,$.t9)("readAllReactions",{chat:s}),Oe(e,s.id,{unreadReactionsCount:void 0,unreadReactions:void 0})})),(0,a.iw)("loadStatistics",(async(e,t,n)=>{const{chatId:s,isGroup:o,tabId:i=(0,m._w)()}=n,r=(0,d.Z1)(e,s);if(!r?.fullInfo)return;const l=await(0,$.t9)(o?"fetchGroupStatistics":"fetchChannelStatistics",{chat:r});if(!l)return;e=(0,a.Rd)();const{stats:u,users:h}=l;if(e=(0,c.Sh)(e,(0,I.ee)(h,"id")),"recentTopMessages"in u&&u.recentTopMessages.length){const t=(0,d.Zw)(e,s);u.recentTopMessages=u.recentTopMessages.map((e=>({...e,...t[e.msgId]})))}e=(0,c.ze)(e,s,u,i),(0,a.R3)(e)})),(0,a.iw)("loadMessageStatistics",(async(e,t,n)=>{const{chatId:s,messageId:o,tabId:i=(0,m._w)()}=n,r=(0,d.Z1)(e,s);if(!r?.fullInfo)return;let l=await(0,$.t9)("fetchMessageStatistics",{chat:r,messageId:o});l||(l={}),e=(0,a.Rd)();const{views:u,forwards:h}=(0,d.Zw)(e,s)[o];l.views=u,l.forwards=h;const p=r.fullInfo.statisticsDcId,g=await(0,$.t9)("fetchMessagePublicForwards",{chat:r,messageId:o,dcId:p});l.publicForwards=g?.length,l.publicForwardsData=g,e=(0,a.Rd)(),e=(0,c.kM)(e,l,i),(0,a.R3)(e)})),(0,a.iw)("loadStatisticsAsyncGraph",(async(e,t,n)=>{const{chatId:s,token:o,name:i,isPercentage:r,tabId:l=(0,m._w)()}=n,u=(0,d.Z1)(e,s);if(!u?.fullInfo)return;const h=u.fullInfo.statisticsDcId,p=await(0,$.t9)("fetchStatisticsAsyncGraph",{token:o,dcId:h,isPercentage:r});p&&(e=(0,a.Rd)(),e=(0,c.yC)(e,s,i,p,l),(0,a.R3)(e))})),n(28304);var _e=n(28406);(0,a.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateChat":{const{isForum:s,lastReadOutboxMessageId:o}=(0,d.Z1)(e,n.id)||{};return n.chat.lastReadOutboxMessageId&&o&&n.chat.lastReadOutboxMessageId<o&&(n={...n,chat:(0,I.CE)(n.chat,["lastReadInboxMessageId"])}),e=(0,c.a4)(e,n.id,n.chat,n.newProfilePhoto),(0,a.R3)(e),n.noTopChatsRequest||(0,d.N)(e,n.id)||t.loadTopChats(),n.chat.id&&(0,_e.Vr)({chatId:n.chat.id,lastReadInboxMessageId:n.chat.lastReadInboxMessageId}),void Object.values(e.byTabId).forEach((a=>{let{id:o}=a;const{chatId:i}=(0,d.Bt)(e,o)||{},r=n;i===r.id&&"isForum"in r.chat&&s!==r.chat.isForum&&(s&&t.closeForumPanel({tabId:o}),t.openChat({id:i,tabId:o}))}))}case"updateChatJoin":{const s=(0,d.Ek)(e,n.id);if(!s)return;e=(0,c.B1)(e,s,[n.id]),e=(0,c.a4)(e,n.id,{isNotJoined:!1}),(0,a.R3)(e);const o=(0,d.Z1)(e,n.id);return void(o&&t.requestChatUpdate({chatId:o.id}))}case"updateChatLeave":return(0,c.Dd)(e,n.id);case"updateChatInbox":return(0,c.a4)(e,n.id,n.chat);case"updateChatTypingStatus":{const{id:t,threadId:s=r._f,typingStatus:o}=n;return e=(0,c.pf)(e,t,s,"typingStatus",o),(0,a.R3)(e),void setTimeout((()=>{e=(0,a.Rd)();const n=(0,d.WP)(e,t,s,"typingStatus");o&&n&&o.timestamp===n.timestamp&&(e=(0,c.pf)(e,t,s,"typingStatus",void 0),(0,a.R3)(e))}),6e3)}case"newMessage":{const{message:t}=n;if(t.senderId===e.currentUserId&&!t.isFromScheduled)return;const s=(0,d.Z1)(e,n.chatId);if(!s)return;const o=Boolean(n.message.id&&n.message.hasUnreadMention);return e=(0,c.a4)(e,n.chatId,{unreadCount:s.unreadCount?s.unreadCount+1:1,...o&&{unreadMentionsCount:(s.unreadMentionsCount||0)+1}}),o&&(e=(0,c.a4)(e,n.chatId,{unreadMentions:[...s.unreadMentions||[],n.message.id]})),(0,a.R3)(e),void(0,_e.rh)({chat:s,message:t})}case"updateCommonBoxMessages":case"updateChannelMessages":{const{ids:t,messageUpdate:a}=n;if(!1!==a.hasUnreadMention)return;return t.forEach((t=>{const a="channelId"in n?n.channelId:(0,d.X5)(e,t),s=(0,d.Z1)(e,a);s?.unreadReactionsCount&&(e=Oe(e,a,{unreadReactionsCount:s.unreadReactionsCount-1||void 0,unreadReactions:s.unreadReactions?.filter((e=>e!==t))})),s?.unreadMentionsCount&&(e=(0,c.a4)(e,a,{unreadMentionsCount:s.unreadMentionsCount-1||void 0,unreadMentions:s.unreadMentions?.filter((e=>e!==t))}))})),e}case"updateChatFullInfo":{const{fullInfo:t}=n,a=e.chats.byId[n.id];if(!a)return;return(0,c.a4)(e,n.id,{fullInfo:{...a.fullInfo,...t}})}case"updatePinnedChatIds":{const{ids:t,folderId:a}=n,s=a===o.WSp?"archived":"active";return{...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[s]:t.length?t:void 0}}}}case"updateChatPinned":{const{id:t,isPinned:a}=n,s=(0,d.Ek)(e,t);if(!s)return;const{[s]:i}=e.chats.orderedPinnedIds;let r=i||[];if(a){if(!r.includes(t)){if("active"===s&&r.length>=o.EGK){const t=e.chats.listIds.active;r=r.filter((e=>t&&t.includes(e)))}r=[t,...r]}}else r=r.filter((e=>e!==t));return{...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[s]:r.length?r:void 0}}}}case"updateChatListType":{const{id:t,folderId:a}=n;return(0,c.Pi)(e,t,a)}case"updateChatFolder":{const{id:t,folder:a}=n,{byId:s,orderedIds:o}=e.chatFolders,i=a?{...s,[t]:a}:(0,I.ei)(s,Object.keys(s).map(Number).filter((e=>e!==t))),r=a?o&&o.includes(t)?o:[...o||[],t]:o?o.filter((e=>e!==t)):void 0;return{...e,chatFolders:{...e.chatFolders,byId:i,orderedIds:r}}}case"updateChatFoldersOrder":{const{orderedIds:t}=n;return{...e,chatFolders:{...e.chatFolders,orderedIds:t}}}case"updateRecommendedChatFolders":{const{folders:t}=n;return{...e,chatFolders:{...e.chatFolders,recommended:t}}}case"updateChatMembers":{const t=e.chats.byId[n.id],{replacedMembers:a,addedMember:s,deletedMemberId:o}=n;if(!t)return;let i=!1,r=t.fullInfo?.members?[...t.fullInfo.members]:[];if(a)r=a,i=!0;else if(s)r.length&&r.some((e=>e.userId===s.userId))||(r.push(s),i=!0);else if(r.length&&o){const e=r.findIndex((e=>e.userId===o));e>-1&&(r.slice(e,1),i=!0)}if(i){const a=r.filter((e=>{let{isOwner:t,isAdmin:n}=e;return t||n}));return(0,c.a4)(e,n.id,{membersCount:r.length,fullInfo:{...t.fullInfo,members:r,adminMembersById:(0,I.ee)(a,"userId")}})}return}case"deleteProfilePhotos":{const{chatId:t,ids:a}=n,s=e.chats.byId[t];return s?.photos?(0,c.a4)(e,t,{photos:s.photos.filter((e=>!a.includes(e.id)))}):void 0}case"draftMessage":{const{chatId:t,formattedText:a,date:s,replyingToId:o,threadId:i}=n;if(!e.chats.byId[t])return;return e=(0,c.pf)(e,t,i||r._f,"draft",a),e=(0,c.pf)(e,t,i||r._f,"replyingToId",o),e=(0,c.a4)(e,t,{draftDate:s})}case"showInvite":{const{data:a}=n;return void Object.values(e.byTabId).forEach((e=>{let{id:n}=e;t.showDialog({data:a,tabId:n})}))}case"updatePendingJoinRequests":{const{chatId:s,requestsPending:o,recentRequesterIds:i}=n,r=e.chats.byId[s];if(!r)return;return e=(0,c.a4)(e,s,{fullInfo:{...r.fullInfo,requestsPending:o,recentRequesterIds:i}}),(0,a.R3)(e),void t.loadChatJoinRequests({chatId:s})}case"updatePinnedTopic":{const{chatId:t,topicId:s,isPinned:o}=n;if(!e.chats.byId[t])return;return e=(0,c.Cn)(e,t,s,{isPinned:o}),void(0,a.R3)(e)}case"updatePinnedTopicsOrder":{const{chatId:t,order:s}=n;if(!e.chats.byId[t])return;return e=(0,c.a4)(e,t,{orderedPinnedTopicIds:s}),void(0,a.R3)(e)}case"updateTopic":{const{chatId:a,topicId:s}=n;if(!(0,d.Z1)(e,a)?.isForum)return;return void t.loadTopicById({chatId:a,topicId:s})}case"updateTopics":{const{chatId:a}=n;if(!(0,d.Z1)(e,a)?.isForum)return;return void t.loadTopics({chatId:a,force:!0})}}}));var De=n(84112);const qe=350;function $e(e,t,n,a,s,o,i){const r=i?.reactions;if(r&&(0,De.A)(a,r))return e;if(e=(0,c.cY)(e,t,n,{reactions:a}),!o)return e;const l=s.unreadReactions?.includes(n);if((0,u.yL)(e,a)&&!l){e=Oe(e,t,{unreadReactionsCount:(s?.unreadReactionsCount||0)+1,unreadReactions:[...s?.unreadReactions||[],n]});const a=(0,d.hj)(e,t,n);if(!s||!a)return e;(0,N.R3)((()=>{(0,_e.rh)({chat:s,message:a,isReaction:!0})}))}else l&&(e=Oe(e,t,{unreadReactionsCount:(s?.unreadReactionsCount||1)-1,unreadReactions:s?.unreadReactions?.filter((e=>e!==n))}));return e}function Ge(e,t,n,a){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const o=s?(0,d.Tm)(e,t,n):(0,d.hj)(e,t,n);if(o&&a.content){const{photo:e,video:t,sticker:n,document:s}=(0,u.qp)(o);e&&a.content.photo?(a.content.photo.blobUrl=e.blobUrl,a.content.photo.thumbnail=e.thumbnail):t&&a.content.video?a.content.video.blobUrl=t.blobUrl:n&&a.content.sticker?a.content.sticker.isPreloadedGlobally=n.isPreloadedGlobally:s&&a.content.document&&(a.content.document.previewBlobUrl=s.previewBlobUrl)}const i=o?{...o,...a}:a;return s?(0,c.P4)(e,t,n,i):(0,c.cY)(e,t,n,i)}function He(e,t,n,a){const{chatId:s}=n,{threadInfo:o}=(0,d.Db)(e,n)||{};if(!o&&n.replyToMessageId){const o=(0,d.hj)(e,s,n.replyToMessageId);o?e=(0,c.lG)(e,o,s,n.id,a):t.loadMessage({chatId:s,messageId:n.replyToMessageId,threadUpdate:{isDeleting:a,lastMessageId:n.id}})}return e}function Ve(e,t,n){const{id:a,chatId:s}=n,{threadInfo:o,firstMessageId:i}=(0,d.Db)(e,n)||{},l=(0,d.Z1)(e,s)?.unreadCount&&!(0,d.gb)(e,s,r._f);return e=He(e,t,n),o&&(!i&&(0,u.CI)(n)||(e=(0,c.xj)(e,s,o.threadId,[a]),Object.values(e.byTabId).forEach((t=>{let{id:r}=t;(0,d.b9)(e,s,o.threadId,r)&&(e=(0,c.$S)(e,s,o.threadId,a,r),i||(e=(0,c.pf)(e,s,o.threadId,"firstMessageId",n.id)))}))),e=(0,c.pf)(e,s,o.threadId,"threadInfo",{...o,lastMessageId:n.id}),(0,u.CI)(n)||(e=(0,c.Xg)(e,s,o.threadId,{messagesCount:(o.messagesCount||0)+1}))),l||(e=(0,c.xj)(e,s,r._f,[a]),Object.values(e.byTabId).forEach((t=>{let{id:n}=t;if((0,d.b9)(e,s,r._f,n)){const t=(0,d.It)(e,s,r._f,n),o=(0,c.$S)(e,s,r._f,a,n),i=(0,d.Cb)(o,s,r._f,n);t&&!i.includes(t)||(e=o)}}))),e}function ze(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const{chats:s}=e,o=s.byId[t],i=o?.lastMessage,r=o?.isForum?(0,d.p$)(e,n):void 0;return r&&(e=(0,c.Cn)(e,t,r.id,{lastMessageId:n.id})),!i||a||i.id===n.id||i.id===n.previousLocalId||n.id>i.id?(0,c.a4)(e,t,{lastMessage:n}):e}function We(e,t){const n=(0,d.Zw)(e,t),a=(0,d.gb)(e,t,r._f);if(!n||!a)return;let s=a.length;for(;s--;){const e=n[a[s]];if(!e.isDeleting)return e}}function Xe(e,t,n,s){if(t){const o=(0,d.Z1)(e,t);if(!o)return;n.forEach((n=>{e=(0,c.cY)(e,t,n,{isDeleting:!0});const a=We(e=(0,c.CE)(e,t,n),t);a&&(e=ze(e,t,a,!0)),o.topics?.[n]&&(e=(0,c.BK)(e,t,n))})),s.requestChatUpdate({chatId:t});const i=[];return n.forEach((n=>{const a=(0,d.hj)(e,t,n);if(!a)return;e=He(e,s,a,!0);const o=(0,d.nr)(e,a);o&&i.push(o)})),(0,a.R3)(e),void setTimeout((()=>{e=(0,a.Rd)(),e=(0,c.K4)(e,t,n),(0,a.R3)(e),(0,I.Tw)(i).forEach((e=>{s.requestThreadInfoUpdate({chatId:t,threadId:e})}))}),qe)}const o=[];n.forEach((t=>{const n=(0,d.X5)(e,t);if(n){o.push(n);const s=We(e=(0,c.cY)(e,n,t,{isDeleting:!0}),n);s&&(e=ze(e,n,s,!0)),setTimeout((()=>{e=(0,a.Rd)(),e=(0,c.K4)(e,n,[t]),(0,a.R3)(e)}),qe)}})),(0,a.R3)(e),(0,I.Tw)(o).forEach((e=>{s.requestChatUpdate({chatId:e})}))}(0,a.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"newMessage":{const{chatId:s,id:o,message:i,shouldForceReply:l}=n;e=Ve(e=Ge(e,s,o,i),t,i),i.repliesThreadInfo&&(e=(0,c.Xg)(e,i.repliesThreadInfo.chatId,i.repliesThreadInfo.threadId,i.repliesThreadInfo));const m=(0,d.hj)(e,s,o);(0,d.Z1)(e,s)?.isForum&&m.isTopicReply&&!(0,d.p$)(e,m)&&m.replyToMessageId&&t.loadTopicById({chatId:s,topicId:m.replyToMessageId}),Object.values(e.byTabId).forEach((n=>{let{id:h}=n;const p=(0,u.CI)(i);if((0,d.KA)(e,s,i,h)){if(p&&i.isOutgoing&&!i.content?.action){const n=(0,d.Bt)(e,h);n&&t.focusMessage({chatId:s,threadId:n.threadId,messageId:i.id,noHighlight:!0,isResizingContainer:!0,tabId:h})}const{threadInfo:n}=(0,d.Db)(e,i)||{};n&&!p&&t.requestThreadInfoUpdate({chatId:s,threadId:n.threadId}),p||setTimeout((()=>{e=(0,a.Rd)(),l&&(e=(0,c.pf)(e,s,r._f,"replyingToId",o)),e=ze(e,s,m),(0,a.R3)(e)}),qe)}else e=ze(e,s,m)})),(0,a.R3)(e),(0,d.N)(e,s)||t.loadTopChats();break}case"updateStartEmojiInteraction":Object.values(e.byTabId).forEach((t=>{let{id:a}=t;const{chatId:s}=(0,d.Bt)(e,a)||{};if(s!==n.id)return;const o=(0,d.hj)(e,s,n.messageId);if(!o)return;if((0,u.UD)(o)!==n.emoji)return;const i=(0,d.jU)(e,a);e=(0,p.i)(e,{activeEmojiInteractions:[...i.activeEmojiInteractions||[],{id:i.activeEmojiInteractions?.length||0,animatedEffect:n.emoji,messageId:n.messageId}]},a)})),(0,a.R3)(e);break;case"newScheduledMessage":{const{chatId:t,id:s,message:o}=n;e=Ge(e,t,s,o,!0);const i=(0,d.qy)(e,t,r._f)||[];e=(0,c.pf)(e,t,r._f,"scheduledIds",(0,I.Tw)([...i,s]));const l=(0,d.nr)(e,o);if(l!==r._f){const n=(0,d.qy)(e,t,l)||[];e=(0,c.pf)(e,t,l,"scheduledIds",(0,I.Tw)([...n,s]))}(0,a.R3)(e);break}case"updateMessage":{const{chatId:t,id:s,message:o}=n,i=(0,d.hj)(e,t,s),r=(0,d.Z1)(e,t);e=Ge(e,t,s,o);const l=(0,d.hj)(e,t,s);o.repliesThreadInfo&&(e=(0,c.Xg)(e,o.repliesThreadInfo.chatId,o.repliesThreadInfo.threadId,o.repliesThreadInfo)),i&&(e=ze(e,t,l)),o.reactions&&r&&(e=$e(e,t,s,o.reactions,r,l.isOutgoing,i)),o.content?.text?.text!==i?.content?.text?.text&&(e=(0,c.CE)(e,t,s)),(0,a.R3)(e);break}case"updateScheduledMessage":{const{chatId:t,id:s,message:o}=n,i=(0,d.Tm)(e,t,s);if(!i)return;e=Ge(e,t,s,o,!0);const l=Object.keys((0,d.yB)(e,t)||{}).map(Number).sort(((e,t)=>t-e));e=(0,c.pf)(e,t,r._f,"scheduledIds",l);const u=(0,d.nr)(e,i);if(u!==r._f){const n=(0,d.qy)(e,t,u)||[];e=(0,c.pf)(e,t,u,"scheduledIds",n.sort(((e,t)=>t-e)))}(0,a.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:s,localId:o,message:i}=n;e=Ve(e,t,i);const l=(0,d.hj)(e,s,o);e=(0,c.K4)(e,s,[o]),i.isScheduled&&(e=(0,c.bV)(e,s,[o])),e=(0,c.cY)(e,s,i.id,{...l,...i,previousLocalId:o});const u=(0,d.hj)(e,s,i.id);e=ze(e,s,u);const m=(0,d.Db)(e,i);Object.values(e.byTabId).forEach((n=>{let{id:a}=n;const{chatId:o,threadId:c}=(0,d.Bt)(e,a)||{};o===s&&(m?.threadInfo?.threadId||r._f)===c&&t.markMessageListRead({maxId:i.id,tabId:a})})),m?.threadInfo&&(e=(0,c.pf)(e,s,m.threadInfo.threadId,"threadInfo",{...m.threadInfo,lastMessageId:i.id,lastReadInboxMessageId:i.id})),(0,a.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:s,message:o}=n,i=(0,d.qy)(e,t,r._f)||[];e=(0,c.pf)(e,t,r._f,"scheduledIds",[...i,o.id]);const l=(0,d.nr)(e,o);if(l!==r._f){const n=(0,d.qy)(e,t,l)||[];e=(0,c.pf)(e,t,l,"scheduledIds",[...n,o.id])}const u=(0,d.Tm)(e,t,s);e=(0,c.bV)(e,t,[s]),e=(0,c.P4)(e,t,o.id,{...u,...o,previousLocalId:s}),(0,a.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:s,messageIds:o}=n,i=(0,I.q0)((0,d.Zw)(e,t),o),l={[r._f]:o};Object.values(i).forEach((t=>{const n=(0,d.nr)(e,t);if(n===r._f)return;const a=l[n]||[];a.push(t.id),l[n]=a})),Object.entries(l).forEach((n=>{let[a,o]=n;const i=(0,d.KB)(e,t,r._f)||[],l=s?(0,I.Tw)(i.concat(o)).sort(((e,t)=>t-e)):i.filter((e=>!o.includes(e)));e=(0,c.pf)(e,t,Number(a),"pinnedIds",l)})),(0,a.R3)(e);break}case"updateThreadInfo":{const{chatId:s,threadId:o,threadInfo:i,firstMessageId:r}=n,l=(0,d.tZ)(e,s,o),u={...l,...i};if(!u.threadId)return;e=(0,c.Xg)(e,s,o,u),r&&(e=(0,c.pf)(e,s,o,"firstMessageId",r));const m=(0,d.Z1)(e,s);if(m?.isForum&&i.lastReadInboxMessageId!==l?.lastReadInboxMessageId&&t.loadTopicById({chatId:s,topicId:o}),i.topMessageId===o&&!m?.isForum){const t=m?.lastReadInboxMessageId,n=u.lastReadInboxMessageId||t;t&&n&&(e=(0,c.Xg)(e,s,o,{lastReadInboxMessageId:Math.max(n,t)}))}(0,a.R3)(e);break}case"resetMessages":{const{id:s}=n,o=(0,d.Zw)(e,s);o&&!(0,u.YC)(s)&&(e=(0,c.K4)(e,s,Object.keys(o).map(Number)),(0,a.R3)(e),t.loadFullChat({chatId:s,force:!0,tabId:(0,m._w)()}));break}case"deleteMessages":{const{ids:a,chatId:s}=n;Xe(e,s,a,t);break}case"deleteScheduledMessages":{const{ids:t,chatId:s}=n;!function(e,t,n,s){e&&(t.forEach((t=>{s=(0,c.P4)(s,e,t,{isDeleting:!0})})),(0,a.R3)(s),setTimeout((()=>{s=(0,a.Rd)(),s=(0,c.bV)(s,e,t);const n=(0,d.yB)(s,e);s=(0,c.pf)(s,e,r._f,"scheduledIds",Object.keys(n||{}).map(Number)),(0,a.R3)(s)}),qe))}(s,t,0,e);break}case"deleteHistory":{const{chatId:s}=n,i=e.messages.byChatId[s];if(s===o.awM&&(e={...e,serviceNotifications:e.serviceNotifications.map((e=>({...e,isDeleted:!0})))},(0,a.R3)(e)),i){const n=Object.keys(i.byId).map(Number);Xe(e=(0,a.Rd)(),s,n,t)}else t.requestChatUpdate({chatId:s});break}case"updateCommonBoxMessages":{const{ids:t,messageUpdate:s}=n;t.forEach((t=>{const n=(0,d.X5)(e,t);n&&(e=(0,c.cY)(e,n,t,s))})),(0,a.R3)(e);break}case"updateChannelMessages":{const{channelId:t,ids:s,messageUpdate:o}=n;s.forEach((n=>{e=(0,c.cY)(e,t,n,o)})),(0,a.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:s}=n,o=(0,d.ZB)(e,t);if(o?.content.poll){const t=o.content.poll.results;let n=t;s.results?.results&&(t.results&&s.results.isMin?t.results&&(n={...s.results,results:s.results.results.map((e=>({...e,isChosen:t.results.find((t=>t.option===e.option))?.isChosen}))),isMin:void 0}):n=s.results);const i={...o.content.poll,...s,results:n};e=(0,c.cY)(e,o.chatId,o.id,{content:{...o.content,poll:i}}),(0,a.R3)(e)}break}case"updateMessagePollVote":{const{pollId:t,userId:s,options:o}=n,i=(0,d.ZB)(e,t);if(!i||!i.content.poll||!i.content.poll.results)break;const{poll:r}=i.content,{recentVoterIds:l,totalVoters:u,results:m}=r.results,h=l?[...l]:[],p=u?u+1:1,g=m?[...m]:[];h.push(s),o.forEach((t=>{const n=g.findIndex((e=>e.option===t)),a=g[n],o=a?{...a}:{option:t,votersCount:0};o.votersCount+=1,s===e.currentUserId&&(o.isChosen=!0),n?g[n]=o:g.push(o)})),e=(0,c.cY)(e,i.chatId,i.id,{content:{...i.content,poll:{...r,results:{...r.results,recentVoterIds:h,totalVoters:p,results:g}}}}),(0,a.R3)(e);break}case"updateServiceNotification":{const{message:a}=n;(0,d.UW)(e)&&t.createServiceNotification({message:a});break}case"updateMessageReactions":{const{chatId:t,id:s,reactions:o}=n,i=(0,d.hj)(e,t,s),r=(0,d.Z1)(e,n.chatId);if(!r||!i)return;e=$e(e,t,s,o,r,i.isOutgoing,i),(0,a.R3)(e);break}case"updateMessageExtendedMedia":{const{chatId:t,id:s,media:o,preview:i}=n,r=(0,d.hj)(e,t,s);if(!(0,d.Z1)(e,n.chatId)||!r)return;if(i){if(!r.content.invoice)return;e=(0,c.cY)(e,t,s,{content:{...r.content,invoice:{...r.content.invoice,extendedMedia:i}}}),(0,a.R3)(e)}else o&&(e=(0,c.cY)(e,t,s,{content:{...o}}),(0,a.R3)(e));break}case"updateTranscribedAudio":{const{transcriptionId:t,text:s,isPending:o}=n;e={...e,transcriptions:{...e.transcriptions,[t]:{...e.transcriptions[t]||{},transcriptionId:t,text:s,isPending:o}}},(0,a.R3)(e);break}case"updateMessageSendFailed":{const{chatId:s,localId:o,error:i}=n;i.match(/CHAT_SEND_.+?FORBIDDEN/)&&Object.values(e.byTabId).forEach((e=>{let{id:n}=e;t.showAllowedMessageTypesNotification({chatId:s,tabId:n})})),e=(0,c.cY)(e,s,o,{sendingState:"messageSendingStateFailed"}),(0,a.R3)(e);break}case"updateMessageTranslations":{const{chatId:t,messageIds:s,toLanguageCode:o,translations:i}=n;e=(0,c.TD)(e,t,s,o,i),(0,a.R3)(e);break}}}));const Ye=(0,N.P2)((function(){let e=(0,a.Rd)();e=(0,c.ps)(e,{...e.users.statusesById,...Je}),(0,a.R3)(e),Je={}}),3e3,!0);let Je={};(0,a.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"deleteContact":return(0,c.GK)(e,n.id);case"updateUser":return Object.values(e.byTabId).forEach((a=>{let{id:s}=a;n.id===e.currentUserId&&n.user.isPremium!==(0,d.wV)(e)&&(n.user.isPremium&&t.openPremiumModal({isSuccess:!0,tabId:s}),e={...e,translations:{byChatId:{}}})})),(0,c.Nq)(e,n.id,n.user);case"updateRequestUserUpdate":t.loadFullUser({userId:n.id});break;case"updateUserEmojiStatus":return(0,c.Nq)(e,n.userId,{emojiStatus:n.emojiStatus});case"updateUserStatus":return a=n.userId,s=n.status,Je[a]=s,void Ye();case"updateUserFullInfo":{const{id:t,fullInfo:a}=n,s=e.users.byId[t];if(!s)return;return(0,c.Nq)(e,t,{fullInfo:{...s.fullInfo,...a}})}case"updateBotMenuButton":{const{botId:t,button:a}=n,s=(0,d.dy)(e,t);if(!s?.fullInfo?.botInfo)return;return(0,c.Nq)(e,t,{fullInfo:{...s.fullInfo,botInfo:{...s.fullInfo.botInfo,menuButton:a}}})}}var a,s})),(0,a.iw)("apiUpdate",((e,t,n)=>{if("updateStickerSet"===n["@type"])return(0,c.Rg)(e,n.id,n.stickerSet)})),(0,a.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updatePeerBlocked":return n.isBlocked?(0,c.O4)(e,n.id):(0,c.rB)(e,n.id);case"updateResetContactList":e={...e,contactList:{userIds:[]}},(0,a.R3)(e);break;case"updateConfig":t.loadConfig();break;case"updateFavoriteStickers":t.loadFavoriteStickers();break;case"updateRecentStickers":t.loadRecentStickers();break;case"updateRecentEmojiStatuses":t.loadRecentEmojiStatuses();break;case"updateMoveStickerSetToTop":{const a=n.isCustomEmoji?e.customEmojis.added.setIds:e.stickers.added.setIds;if(!a)return e;const s=[n.id,...a.filter((e=>e!==n.id))];t.reorderStickerSets({order:s,isCustomEmoji:n.isCustomEmoji});break}case"updateStickerSets":t.loadStickerSets();break;case"updateStickerSetsOrder":t.reorderStickerSets({order:n.order,isCustomEmoji:n.isCustomEmoji});break;case"updateSavedGifs":t.loadSavedGifs();break;case"updatePrivacy":e={...e,settings:{...e.settings,privacy:{...e.settings.privacy,[n.key]:n.rules}}},(0,a.R3)(e);break;case"updatePaymentVerificationNeeded":Object.values(e.byTabId).forEach((t=>{let{id:a}=t;e=(0,c.fS)(e,n.url,a),e=(0,c.Q$)(e,f.KB.ConfirmPayment,a)})),(0,a.R3)(e);break;case"updateWebViewResultSent":Object.values(e.byTabId).forEach((e=>{e.webApp?.queryId===n.queryId&&(t.setReplyingToId({messageId:void 0,tabId:e.id}),t.closeWebApp({tabId:e.id}))}))}})),(0,a.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateNotifySettings":return(0,c.HN)(e,n.peerType,n.isSilent,n.shouldShowPreviews);case"updateNotifyExceptions":{const{chatId:t,isMuted:s,isSilent:o,shouldShowPreviews:i}=n;e.chats.byId[t]&&(e=(0,c.a4)(e,t,{isMuted:s})),e=(0,c.aK)(e,t,{isMuted:s,isSilent:o,shouldShowPreviews:i}),(0,a.R3)(e);break}case"updateTopicNotifyExceptions":{const{chatId:t,topicId:s,isMuted:o}=n;e=(0,c.Cn)(e,t,s,{isMuted:o}),(0,a.R3)(e);break}}})),(0,a.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateTwoFaStateWaitCode":return{...e,twoFaSettings:{...e.twoFaSettings,isLoading:!1,waitingEmailCodeLength:n.length}};case"updateTwoFaError":return{...e,twoFaSettings:{...e.twoFaSettings,error:n.message}}}}));var Ke=n(78958),Qe=n(42431);(0,a.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateGroupCall":{if("discarded"===n.call.connectionState)return e.groupCalls.activeGroupCallId?void("leaveGroupCall"in t&&t.leaveGroupCall({shouldRemove:!0,tabId:(0,m._w)()})):(0,Ke.dc)(e,n.call.id);const a=(0,Qe.$5)(e,n.call.id),s=a?.chatId;return s&&(e=(0,c.a4)(e,s,{isCallNotEmpty:a.participantsCount>0||Boolean(a.participants?.length)})),(0,Ke.AH)(e,n.call.id,(0,I.CE)(n.call,["connectionState"]),void 0,n.call.participantsCount)}case"updateGroupCallChatId":{const t=(0,d.Z1)(e,n.chatId);return t&&(e=(0,c.a4)(e,n.chatId,{fullInfo:{...t.fullInfo,groupCallId:n.call.id}})),e}case"updateGroupCallParticipants":{const{groupCallId:t,participants:s,nextOffset:o}=n,{currentUserId:i}=e;e=(0,a.Rd)(),s.forEach((n=>{n.id&&(e=(0,Ke.B6)(e,t,n.id,n,Boolean(o)||i===n.id))})),o&&(e=(0,Ke.AH)(e,t,{nextOffset:o}));const r=(0,Qe.$5)(e,t),d=r?.chatId;return d&&(e=(0,c.a4)(e,d,{isCallNotEmpty:r.participantsCount>0||Boolean(r.participants?.length)})),e}case"updatePhoneCall":{if(!s.Bi)return;const{phoneCall:o,currentUserId:i}=e,{call:r}=n;if(o)return"discarded"===r.state?(t.playGroupCallSound({sound:"end"}),"hangUp"in t&&t.hangUp({tabId:(0,m._w)()}),{...e,...r.needRating&&{ratingPhoneCall:r}}):void 0;if(r?.adminId!==i&&"requested"===r.state)return(0,N.R3)((()=>{e=(0,a.Rd)(),(0,_e.TO)({call:r,user:(0,Qe.fu)(e)})})),(0,U.EP)(),(0,U.CW)(e,t,r.isVideo,(0,m._w)()),e={...e,phoneCall:r},(0,p.i)(e,{isCallPanelVisible:!1},(0,m._w)())}}}));var et=n(9937);(0,a.iw)("apiUpdate",((e,t,n)=>{"updatePaymentStateCompleted"===n["@type"]&&Object.values(e.byTabId).forEach((a=>{let{id:o}=a;const{inputInvoice:i}=(0,d.jU)(e,o).payment;if(i&&"chatId"in i&&"messageId"in i){const n=(0,d.hj)(e,i.chatId,i.messageId);if(n&&n.content.invoice){const{amount:e,currency:a,title:s}=n.content.invoice;t.showNotification({tabId:o,message:b.Iu("PaymentInfoHint",[(0,et.x)(e,a,b.QO().code),s])})}}s.Xp||(e=(0,c.WY)(e,o)),n.slug&&i&&"slug"in i&&i.slug!==n.slug||(e=(0,p.i)(e,{payment:{...(0,d.jU)(e,o).payment,status:"paid"}},o))}))}));var tt=n(46752),nt=n(1279),at=n(53551),st=n(99203),ot=n(274),it=n(45332);function rt(e){(0,i.d4)((()=>(0,N.Gq)(e)),[e])}var ct=n(34446);const dt=document.querySelector('meta[name="viewport"]'),lt=dt?.getAttribute("content")||"",ut="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover";function mt(e){e.preventDefault()}var ht=n(65326),pt=n(31212),gt=n(18674),ft=n(62357),It=n(28183),vt=n(48778);const wt=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"StickerSetModal",!t);return n?i.ZP.createElement(n,e):void 0}));var bt=n(2155),yt=n(95616),Pt=n(17358);const Zt=(0,i.X$)((e=>{let{isForAppBadge:t}=e;(0,yt.yi)();const n=(0,T.xW)();if((0,i.d4)((()=>{t&&(0,Pt.w)(n)}),[t,n]),!t&&n)return i.ZP.createElement("div",{className:"unread-count active"},(0,bt.bi)(n))}));var Ct=n(23989),St=n(53455),Et=n(60706),Mt=n(73541),Rt=n(2255),kt=n(59107),Tt=n(54416),At=n(27370),Nt=n(706);let xt;function Bt(e,t,n,a,s,o){let r,c,d;return r=function(){const[e,t]=(0,i.eJ)(window.navigator.onLine);return(0,i.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}()&&"connectionStateConnecting"!==t?n?xt.syncing:xt.online:xt.waitingForNetwork,c=r===xt.online||o?"none":a?"middleHeader":s?"minimized":"overlay",r===xt.waitingForNetwork?d=e("WaitingForNetwork"):r===xt.syncing&&(d=e("Updating")),"middleHeader"===c&&(d=d.toLowerCase().replace(/\.+$/,"")),{connectionStatus:r,connectionStatusPosition:c,connectionStatusText:d}}!function(e){e[e.waitingForNetwork=0]="waitingForNetwork",e[e.syncing=1]="syncing",e[e.online=2]="online"}(xt||(xt={}));var Lt=n(36046),Ut=n(73217),jt=n(53106),Ot=n(58964),Ft=n(231),_t=n(69589),Dt=n(49187),qt=n(83321),$t=n(40126),Gt=n(49204);const Ht=(0,i.X$)((e=>{let{connectionStatus:t,connectionStatusText:n,onClick:a}=e;const s=(0,kt.Z)();return i.ZP.createElement("div",{id:"ConnectionStatusOverlay",dir:s.isRtl?"rtl":void 0,onClick:a},i.ZP.createElement(Gt.Z,{color:"black"}),i.ZP.createElement("div",{className:"state-text"},i.ZP.createElement(Rt.Z,{activeKey:t,name:"slide-fade"},n)),i.ZP.createElement(Ft.Z,{round:!0,size:"tiny",color:"translucent-black"},i.ZP.createElement("span",{className:"icon-close"})))}));var Vt=n(96459),zt=n(4863),Wt=n(6202);const Xt="HO3tML0GAC9vTH28baKB",Yt=(0,i.X$)((e=>{let{reaction:t,isLottie:n,className:a}=e;const o=(0,u.RK)(t.documentId),r=(0,Wt.Z)(n?void 0:o),c=(0,i.Ye)((()=>s._G?Array.from({length:7}).map((()=>function(){const e=(10+60*Math.random())*(Math.random()>.5?1:-1),t=20+80*Math.random();return`M 0 0 C 0 0 ${e} ${-t-20} ${e} ${t}`}())):[]),[]);if(r||n)return i.ZP.createElement("div",{className:(0,tt.Z)("HAg4STRlxDV3frYuABYr",a)},c.map((e=>{const a=`--offset-path: path('${e}');`;return n?i.ZP.createElement(Vt.Z,{documentId:t.documentId,className:Xt,style:a,withSharedAnimation:!0}):i.ZP.createElement("img",{src:r,alt:"",className:Xt,style:a})})))})),Jt=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"StatusPickerMenu",!t);return n?i.ZP.createElement(n,e):void 0})),Kt=(0,i.X$)((0,a.c$)((e=>{const{currentUserId:t}=e;return{emojiStatus:(t?(0,d.dy)(e,t):void 0)?.emojiStatus}}))((e=>{let{emojiStatus:t}=e;const{setEmojiStatus:n,loadCurrentUser:s}=(0,a.Sv)(),r=(0,i.sO)(null),[c,d,l]=(0,Et.Z)(!1),[u,m,h]=(0,Et.Z)(!1),[p,g,f]=(0,Et.Z)(!1),{isMobile:I}=(0,C.ZP)(),w=t?.until?1e3*t.until-Date.now()+1e3*(0,v.Qj)():void 0;(0,It.Z)(s,w),(0,ot.Z)((e=>{let[n]=e;c&&t&&n&&t.documentId!==n.documentId&&(m(),l())}),[t,c,m,l]);const b=(0,i.I4)((e=>{d(),n({emojiStatus:e})}),[d,n]);(0,It.Z)(h,u?1500:void 0);const y=(0,i.I4)((()=>{g()}),[g]);return i.ZP.createElement("div",{className:"extra-spacing"},Boolean(u&&t)&&i.ZP.createElement(Yt,{reaction:t,isLottie:!0,className:"emoji-status-effect"}),i.ZP.createElement(Ft.Z,{round:!0,ref:r,ripple:!I,size:"smaller",color:"translucent",className:"emoji-status",onClick:y},t?i.ZP.createElement(Vt.Z,{key:t.documentId,documentId:t.documentId,size:24,loopLimit:o.y3O}):i.ZP.createElement(zt.Z,null)),i.ZP.createElement(Jt,{statusButtonRef:r,isOpen:p,onEmojiStatusSelect:b,onClose:f}))}))),Qt=[0,1,2],en=(0,i.X$)((0,a.c$)((e=>{const t=(0,d.jU)(e),{query:n,fetchingStatus:a,chatId:s,date:o}=t.globalSearch,{currentUserId:i,connectionState:r,isSyncing:c,archiveSettings:l}=e,{byId:u}=e.chats,{isConnectionStatusMinimized:m,animationLevel:h}=e.settings.byKey;return{searchQuery:n,isLoading:!!a&&Boolean(a.chats||a.messages),currentUserId:i,chatsById:u,globalSearchChatId:s,searchDate:o,theme:(0,d.Pu)(e),animationLevel:h,connectionState:r,isSyncing:c,isMessageListOpen:Boolean((0,d.Bt)(e)),isConnectionStatusMinimized:m,isCurrentUserPremium:(0,d.wV)(e),areChatsLoaded:Boolean(e.chats.listIds.active),hasPasscode:Boolean(e.passcode.hasPasscode),canInstall:Boolean(t.canInstall),archiveSettings:l}}))((e=>{let{shouldHideSearch:t,content:n,contactsFilter:r,onSearchQuery:c,isClosingSearch:d,onSelectSettings:l,onSelectContacts:m,onSelectArchived:h,onReset:p,searchQuery:g,isLoading:I,isCurrentUserPremium:v,shouldSkipTransition:w,currentUserId:b,globalSearchChatId:y,searchDate:P,theme:Z,animationLevel:S,chatsById:E,connectionState:M,isSyncing:R,isMessageListOpen:k,isConnectionStatusMinimized:T,areChatsLoaded:A,hasPasscode:N,canInstall:x,archiveSettings:B}=e;const{openChat:L,setGlobalSearchDate:U,setSettingOption:j,setGlobalSearchChatId:O,openChatByUsername:F,lockScreen:_,requestNextSettingsScreen:D,skipLockOnUnload:q,openUrl:$}=(0,a.Sv)(),G=(0,kt.Z)(),{isMobile:H}=(0,C.ZP)(),V=n===f.du.ChatList,z=(0,i.Ye)((()=>P?(0,ae.xH)(new Date(1e3*P)):void 0),[P]),W=(0,i.Ye)((()=>V&&E?Object.values(E).reduce(((e,t)=>(0,u.pE)(t)&&t.unreadCount?e+1:e),0):0),[V,E]),{connectionStatus:X,connectionStatusText:Y,connectionStatusPosition:J}=Bt(G,M,R,k,T,!A),K=(0,i.I4)((e=>{e.preventDefault(),e.stopPropagation(),N?_():D({screen:f.MT.PasscodeDisabled})}),[N,_,D]);(0,Mt.y)({"Ctrl+Shift+L":K,"Alt+Shift+L":K,"Meta+Shift+L":K,...s.fl&&{"Mod+L":K}});const Q=window.location.hostname===o.xHY||o.Cgt,ee=(0,i.Ye)((()=>e=>{let{onTrigger:t,isOpen:n}=e;return i.ZP.createElement(Ft.Z,{round:!0,ripple:V&&!H,size:"smaller",color:"translucent",className:n?"active":"",onClick:V?t:()=>p(),ariaLabel:V?G("AccDescrOpenMenu2"):"Return to chat list"},i.ZP.createElement("div",{className:(0,tt.Z)("animated-menu-icon",!V&&"state-back",w&&"no-animation")}))}),[V,H,G,p,w]),te=(0,i.I4)((()=>{g||c("")}),[g,c]),ne=(0,i.I4)((()=>{j({isConnectionStatusMinimized:!T})}),[T,j]),se=(0,i.I4)((()=>{L({id:b,shouldReplaceHistory:!0})}),[b,L]),oe=(0,i.I4)((e=>{e.stopPropagation();const t="light"===Z?"dark":"light";j({theme:t}),j({shouldUseSystemTheme:!1}),(0,At.Z)(t,S===o.zy8)}),[S,j,Z]),ie=(0,i.I4)((e=>{e.stopPropagation();const t=0===S?2:0;Qt.forEach(((e,n)=>{document.body.classList.toggle(`animation-level-${n}`,t===n)})),j({animationLevel:t})}),[S,j]),re=(0,i.I4)((()=>{window.open(o.ulW,"_blank","noopener")}),[]),ce=(0,i.I4)((()=>{localStorage.setItem("kz_version",JSON.stringify("K")),(0,Nt.W8)(),q()}),[q]),de=(0,i.I4)((()=>{F({username:G("Settings.TipsUsername")})}),[G,F]),le=(0,i.I4)((()=>{$({url:o.mUA})}),[$]),ue=(0,i.I4)((()=>{_()}),[_]),me=Boolean(y)||n===f.du.GlobalSearch||n===f.du.Contacts;(0,i.d4)((()=>me?(0,Ct.Z)((()=>p())):void 0),[me,p]);const he=n===f.du.Contacts?G("SearchFriends"):G("Search"),pe=o.Tjg?`${o.JiC} Beta (master)`:o.eMD?"master":o.JiC,{shouldDisableDropdownMenuTransitionRef:ge,handleDropdownMenuTransitionEnd:fe}=(0,Ut.Z)(t),Ie=(0,i.Ye)((()=>i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(Ot.Z,{icon:"saved-messages",onClick:se},G("SavedMessages")),B.isHidden&&i.ZP.createElement(Ot.Z,{icon:"archive",onClick:h},i.ZP.createElement("span",{className:"menu-item-name"},G("ArchivedChats")),W>0&&i.ZP.createElement("div",{className:"right-badge"},W)),i.ZP.createElement(Ot.Z,{icon:"user",onClick:m},G("Contacts")),i.ZP.createElement(Ot.Z,{icon:"settings",onClick:l},G("Settings")),i.ZP.createElement(Ot.Z,{icon:"darkmode",onClick:oe},i.ZP.createElement("span",{className:"menu-item-name"},G("lng_menu_night_mode")),i.ZP.createElement(qt.Z,{id:"darkmode",label:G("dark"===Z?"lng_settings_disable_night_theme":"lng_settings_enable_night_theme"),checked:"dark"===Z,noAnimation:!0})),i.ZP.createElement(Ot.Z,{icon:"animations",onClick:ie},i.ZP.createElement("span",{className:"menu-item-name capitalize"},G("Appearance.Animations").toLowerCase()),i.ZP.createElement(qt.Z,{id:"animations",label:"Toggle Animations",checked:S>0})),i.ZP.createElement(Ot.Z,{icon:"help",onClick:de},G("TelegramFeatures")),i.ZP.createElement(Ot.Z,{icon:"bug",onClick:le},"Report Bug"),o.Tjg&&i.ZP.createElement(Ot.Z,{icon:"permissions",onClick:re},"Beta Changelog"),Q&&i.ZP.createElement(Ot.Z,{icon:"char-K",href:"https://web.telegram.org/k/",onClick:ce},"Switch to K Version"),x&&i.ZP.createElement(Ot.Z,{icon:"install",onClick:(0,Lt.G)()},"Install App"))),[S,W,x,ie,le,G,re,oe,de,se,ce,h,m,l,Z,Q,B]);return i.ZP.createElement("div",{className:"LeftMainHeader"},i.ZP.createElement("div",{id:"LeftMainHeader",className:"left-header"},G.isRtl&&i.ZP.createElement("div",{className:"DropdownMenuFiller"}),i.ZP.createElement(jt.Z,{trigger:ee,footer:`${o.iCi} ${pe}`,className:(0,tt.Z)(G.isRtl&&"rtl",t&&G.isRtl&&"right-aligned",ge.current&&G.isRtl&&"disable-transition"),positionX:t&&G.isRtl?"right":"left",onTransitionEnd:G.isRtl?fe:void 0},Ie),i.ZP.createElement(_t.Z,{inputId:"telegram-search-input",parentContainerClassName:"LeftSearch",className:(0,tt.Z)(y||P?"with-picker-item":void 0,t&&"SearchInput--hidden"),value:d?void 0:r||g,focused:me,isLoading:I||"minimized"===J,spinnerColor:"minimized"===J?"yellow":void 0,spinnerBackgroundColor:"minimized"===J&&"light"===Z?"light":void 0,placeholder:he,autoComplete:"off",canClose:Boolean(y||P),onChange:c,onReset:p,onFocus:te,onSpinnerClick:"minimized"===J?ne:void 0},z&&i.ZP.createElement(Dt.Z,{icon:"calendar",title:z,canClose:!0,isMinimized:Boolean(y),className:"search-date",onClick:U,clickArg:{date:void 0}}),y&&i.ZP.createElement(Dt.Z,{chatOrUserId:y,onClick:O,canClose:!0,clickArg:{id:void 0}})),v&&i.ZP.createElement(Kt,null),N&&i.ZP.createElement(Ft.Z,{round:!0,ripple:!H,size:"smaller",color:"translucent",ariaLabel:`${G("ShortcutsController.Others.LockByPasscode")} (Ctrl+Shift+L)`,onClick:ue,className:(0,tt.Z)(!v&&"extra-spacing")},i.ZP.createElement("i",{className:"icon-lock"})),i.ZP.createElement($t.Z,{isOpen:"overlay"===J,isCustom:!0,className:"connection-state-wrapper"},i.ZP.createElement(Ht,{connectionStatus:X,connectionStatusText:Y,onClick:ne}))))})));var tn=n(64963),nn=n(46590),an=n(93133),sn=n(46915);const on=(0,i.X$)((0,a.c$)((e=>{const{chatFolders:{byId:t,orderedIds:n},chats:{listIds:{archived:a}},currentUserId:s,lastSyncTime:o,archiveSettings:i}=e,{shouldSkipHistoryAnimations:r,activeChatFolder:c}=(0,d.jU)(e);return{chatFoldersById:t,orderedFolderIds:n,activeChatFolder:c,currentUserId:s,isForumPanelOpen:(0,d.nd)(e),lastSyncTime:o,shouldSkipHistoryAnimations:r,hasArchivedChats:Boolean(a?.length),maxFolders:(0,K.M)(e,"dialogFilters"),archiveSettings:i}}))((e=>{let{foldersDispatch:t,onSettingsScreenSelect:n,onLeftColumnContentChange:r,chatFoldersById:c,orderedFolderIds:d,activeChatFolder:l,currentUserId:u,isForumPanelOpen:m,lastSyncTime:h,shouldSkipHistoryAnimations:p,maxFolders:g,shouldHideFolderTabs:f,hasArchivedChats:I,archiveSettings:v}=e;const{loadChatFolders:w,setActiveChatFolder:b,openChat:y}=(0,a.Sv)(),P=(0,i.sO)(null),Z=(0,kt.Z)();(0,i.d4)((()=>{h&&w()}),[h,w]);const C=(0,i.Ye)((()=>({id:o.NfV,title:d?.[0]===o.NfV?Z("FilterAllChatsShort"):Z("FilterAllChats")})),[d,Z]),S=(0,i.Ye)((()=>d?d.map((e=>e===o.NfV?C:c[e]||{})).filter(Boolean):void 0),[c,C,d]),E=S?.findIndex((e=>e.id===o.NfV)),M=E===l,R=0===l,k=(0,yt.yi)(),T=(0,i.Ye)((()=>{if(S&&S.length)return S.map(((e,t)=>{let{id:n,title:a}=e;const s=n!==o.NfV&&t>g-1;return{id:n,title:a,badgeCount:k[n]?.chatsCount,isBadgeActive:Boolean(k[n]?.notificationsCount),isBlocked:s}}))}),[S,k,g]),A=(0,i.I4)((e=>{b({activeChatFolder:e},{forceOnHeavyAnimation:!0})}),[b]);(0,i.d4)((()=>{T?.length&&l>=T.length&&b({activeChatFolder:0})}),[l,T,b]),(0,i.d4)((()=>{if(s.$b&&T?.length&&!m)return(0,tn.sf)(P.current,{selectorToPreventScroll:".chat-list",onSwipe:(e,t)=>t===tn.eM.Left?(b({activeChatFolder:Math.min(l+1,T.length-1)},{forceOnHeavyAnimation:!0}),!0):t===tn.eM.Right&&(b({activeChatFolder:Math.max(0,l-1)},{forceOnHeavyAnimation:!0}),!0)})}),[l,T,m,b]);const N=(0,i.sO)();N.current=!R,(0,i.d4)((()=>N.current?(0,Ct.Z)((()=>{N.current&&b({activeChatFolder:0})})):void 0),[l,b]),(0,nn.Z)({isActive:!R,onBack:()=>b({activeChatFolder:0},{forceOnHeavyAnimation:!0})}),(0,i.d4)((()=>{const e=e=>{if(e.ctrlKey&&e.shiftKey&&e.code.startsWith("Digit")&&T){const[,t]=e.code.match(/Digit(\d)/)||[];if(!t)return;if("0"===t)return void y({id:u,shouldReplaceHistory:!0});const n=Number(t)-1;if(n>T.length-1)return;b({activeChatFolder:n},{forceOnHeavyAnimation:!0}),e.preventDefault()}};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}}),[u,T,y,b]);const{shouldRender:x,transitionClassNames:B}=(0,pt.Z)(!d,void 0,!0);function L(e){const a=Object.values(c).find((e=>{let{id:t}=e;return t===T[l].id})),s=a&&!M;return i.ZP.createElement(sn.Z,{folderType:s?"folder":"all",folderId:s?a.id:void 0,isActive:e,isForumPanelOpen:m,lastSyncTime:h,foldersDispatch:t,onSettingsScreenSelect:n,onLeftColumnContentChange:r,canDisplayArchive:I&&!v.isHidden,archiveSettings:v})}const U=T&&T.length>1;return i.ZP.createElement("div",{className:(0,tt.Z)("ChatFolders",U&&f&&"ChatFolders--tabs-hidden")},U?i.ZP.createElement(an.Z,{tabs:T,activeTab:l,onSwitchTab:A,areFolders:!0}):x?i.ZP.createElement("div",{className:(0,tt.Z)("tabs-placeholder",B)}):void 0,i.ZP.createElement(Rt.Z,{ref:P,name:p?"none":Z.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:l,renderCount:U?T.length:void 0},L))})));var rn=n(34288);const cn=(0,i.X$)((e=>{const t=(0,vt.Z)(st.gl.Extra,"LeftSearch");return t?i.ZP.createElement(t,e):i.ZP.createElement(rn.Z,null)})),dn=(0,i.X$)((e=>{const t=(0,vt.Z)(st.gl.Extra,"ContactList");return t?i.ZP.createElement(t,e):i.ZP.createElement(rn.Z,null)}));var ln=n(52328);const un=(0,i.X$)((e=>{let{isShown:t,onNewPrivateChat:n,onNewChannel:a,onNewGroup:s}=e;const[o,r]=(0,i.eJ)(!1);(0,i.d4)((()=>{t||r(!1)}),[t]);const c=(0,kt.Z)(),d=(0,tt.Z)("NewChatButton",t&&"revealed",o&&"menu-is-open"),l=(0,i.I4)((()=>{r(!o)}),[o]),u=(0,i.I4)((()=>{r(!1)}),[]),m=(0,i.Ye)((()=>i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(Ot.Z,{icon:"channel",onClick:a},c("NewChannel")),i.ZP.createElement(Ot.Z,{icon:"group",onClick:s},c("NewGroup")),i.ZP.createElement(Ot.Z,{icon:"user",onClick:n},c("NewMessageTitle")))),[c,a,s,n]);return i.ZP.createElement("div",{className:d,dir:c.isRtl?"rtl":void 0},i.ZP.createElement(Ft.Z,{round:!0,color:"primary",className:o?"active":"",onClick:l,ariaLabel:c(o?"Close":"NewMessageTitle"),tabIndex:-1},i.ZP.createElement("i",{className:"icon-new-chat-filled"}),i.ZP.createElement("i",{className:"icon-close"})),i.ZP.createElement(ln.Z,{isOpen:o,positionX:c.isRtl?"left":"right",positionY:"bottom",autoClose:!0,onClose:u},m))}));var mn=n(59690);const hn=Object.keys(f.du).length/2;let pn;const gn=(0,i.X$)((e=>{let{content:t,searchQuery:n,searchDate:o,isClosingSearch:r,contactsFilter:c,shouldSkipTransition:d,foldersDispatch:l,isUpdateAvailable:u,isForumPanelOpen:m,onSearchQuery:h,onContentChange:p,onSettingsScreenSelect:g,onReset:I,onTopicSearch:v}=e;const{closeForumPanel:w}=(0,a.Sv)(),[b,y]=(0,i.eJ)(s.$b),{shouldRenderForumPanel:P,handleForumPanelAnimationEnd:Z}=(0,Tt.Z)(m),C=m&&t===f.du.ChatList,{shouldRender:S,transitionClassNames:E}=(0,pt.Z)(u),M=(0,i.sO)(!1),R=(0,i.I4)((()=>{t===f.du.ChatList&&(M.current=!0,y(!0))}),[t]),k=(0,i.I4)((()=>{M.current=!1,pn&&(clearTimeout(pn),pn=void 0),pn=window.setTimeout((()=>{M.current||y(!1)}),250)}),[]),T=(0,i.I4)((()=>{p(f.du.Settings)}),[p]),A=(0,i.I4)((()=>{p(f.du.Contacts)}),[p]),N=(0,i.I4)((()=>{p(f.du.Archived),w()}),[w,p]),x=(0,i.I4)((()=>{window.location.reload()}),[]),B=(0,i.I4)((()=>{p(f.du.NewChannelStep1)}),[p]),L=(0,i.I4)((()=>{p(f.du.NewGroupStep1)}),[p]);(0,i.d4)((()=>{let e;return t!==f.du.ChatList?e=window.setTimeout((()=>{y(!1)}),250):(M.current||s.$b)&&y(!0),()=>{e&&(clearTimeout(e),e=void 0)}}),[t]);const U=(0,kt.Z)();return i.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:s.$b?void 0:R,onMouseLeave:s.$b?void 0:k},i.ZP.createElement(en,{shouldHideSearch:C,content:t,contactsFilter:c,onSearchQuery:h,onSelectSettings:T,onSelectContacts:A,onSelectArchived:N,onReset:I,shouldSkipTransition:d,isClosingSearch:r}),i.ZP.createElement(Rt.Z,{name:d?"none":"zoom-fade",renderCount:hn,activeKey:t,shouldCleanup:!0,cleanupExceptionKey:f.du.ChatList},(e=>{switch(t){case f.du.ChatList:return i.ZP.createElement(on,{shouldHideFolderTabs:C,onSettingsScreenSelect:g,onLeftColumnContentChange:p,foldersDispatch:l});case f.du.GlobalSearch:return i.ZP.createElement(cn,{searchQuery:n,searchDate:o,isActive:e,onReset:I});case f.du.Contacts:return i.ZP.createElement(dn,{filter:c,isActive:e,onReset:I});default:return}})),S&&i.ZP.createElement(Ft.Z,{fluid:!0,pill:!0,className:(0,tt.Z)("btn-update",E),onClick:x},U("lng_update_telegram")),P&&i.ZP.createElement(mn.Z,{isOpen:m,isHidden:!C,onTopicSearch:v,onCloseAnimationEnd:Z}),i.ZP.createElement(un,{isShown:b,onNewPrivateChat:A,onNewChannel:B,onNewGroup:L}))})),fn=(0,i.X$)((e=>{const t=(0,vt.Z)(st.gl.Extra,"Settings");return t?i.ZP.createElement(t,e):i.ZP.createElement(rn.Z,null)})),In=(0,i.X$)((e=>{const t=(0,vt.Z)(st.gl.Extra,"NewChat");return t?i.ZP.createElement(t,e):i.ZP.createElement(rn.Z,null)})),vn=(0,i.X$)((e=>{const t=(0,vt.Z)(st.gl.Extra,"ArchivedChats");return t?i.ZP.createElement(t,e):i.ZP.createElement(rn.Z,null)}));var wn;!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"}(wn||(wn={}));const bn=Object.keys(wn).length/2,yn=(0,i.X$)((0,a.c$)((e=>{const t=(0,d.jU)(e),{globalSearch:{query:n,date:a},shouldSkipHistoryAnimations:s,activeChatFolder:o,nextSettingsScreen:i}=t,{leftColumnWidth:r,currentUserId:c,passcode:{hasPasscode:l},isUpdateAvailable:u,archiveSettings:m}=e,h=(0,d.jr)(e);return{searchQuery:n,searchDate:a,isFirstChatFolderActive:0===o,shouldSkipHistoryAnimations:s,leftColumnWidth:r,currentUserId:c,hasPasscode:l,nextSettingsScreen:i,isChatOpen:Boolean(h?.id),isUpdateAvailable:u,isForumPanelOpen:(0,d.nd)(e),forumPanelChatId:t.forumPanelChatId,isClosingSearch:t.globalSearch.isClosing,archiveSettings:m}}))((e=>{let{searchQuery:t,searchDate:n,isFirstChatFolderActive:o,shouldSkipHistoryAnimations:r,leftColumnWidth:c,currentUserId:d,hasPasscode:l,nextSettingsScreen:u,isChatOpen:m,isUpdateAvailable:h,isForumPanelOpen:p,forumPanelChatId:g,isClosingSearch:I,archiveSettings:v}=e;const{setGlobalSearchQuery:w,setGlobalSearchClosing:b,setGlobalSearchChatId:y,resetChatCreation:P,setGlobalSearchDate:Z,loadPasswordInfo:C,clearTwoFaError:S,setLeftColumnWidth:E,resetLeftColumnWidth:M,openChat:R,requestNextSettingsScreen:k}=(0,a.Sv)(),T=(0,i.sO)(null),[A,N]=(0,i.eJ)(f.du.ChatList),[x,B]=(0,i.eJ)(f.MT.Main),[L,U]=(0,i.eJ)(""),[j,O]=(0,St.ZP)(),[F,_]=(0,i.eJ)(0);let D=wn.Main;switch(A){case f.du.Archived:D=wn.Archived;break;case f.du.Settings:D=wn.Settings;break;case f.du.NewChannelStep1:case f.du.NewChannelStep2:D=wn.NewChannel;break;case f.du.NewGroupStep1:case f.du.NewGroupStep2:D=wn.NewGroup}const q=(0,i.I4)((e=>{function t(){N(f.du.ChatList),U(""),b({isClosing:!0}),P(),setTimeout((()=>{w({query:""}),Z({date:void 0}),y({id:void 0}),b({isClosing:!1}),_(Date.now())}),250)}if(!0!==e)if(A!==f.du.NewGroupStep2)if(A!==f.du.NewChannelStep2){if(A===f.du.NewGroupStep1){const e=document.getElementById("new-group-picker-search");e&&e.blur()}if(A===f.du.Settings)switch(x){case f.MT.EditProfile:case f.MT.Folders:case f.MT.General:case f.MT.Notifications:case f.MT.DataStorage:case f.MT.Privacy:case f.MT.ActiveSessions:case f.MT.Language:case f.MT.Stickers:case f.MT.Experimental:return void B(f.MT.Main);case f.MT.GeneralChatBackground:return void B(f.MT.General);case f.MT.GeneralChatBackgroundColor:return void B(f.MT.GeneralChatBackground);case f.MT.PrivacyPhoneNumber:case f.MT.PrivacyLastSeen:case f.MT.PrivacyProfilePhoto:case f.MT.PrivacyPhoneCall:case f.MT.PrivacyPhoneP2P:case f.MT.PrivacyForwarding:case f.MT.PrivacyGroupChats:case f.MT.PrivacyVoiceMessages:case f.MT.PrivacyBlockedUsers:case f.MT.ActiveWebsites:case f.MT.TwoFaDisabled:case f.MT.TwoFaEnabled:case f.MT.TwoFaCongratulations:case f.MT.PasscodeDisabled:case f.MT.PasscodeEnabled:case f.MT.PasscodeCongratulations:return void B(f.MT.Privacy);case f.MT.PasscodeNewPasscode:return void B(l?f.MT.PasscodeEnabled:f.MT.PasscodeDisabled);case f.MT.PasscodeChangePasscodeCurrent:case f.MT.PasscodeTurnOff:return void B(f.MT.PasscodeEnabled);case f.MT.PasscodeNewPasscodeConfirm:return void B(f.MT.PasscodeNewPasscode);case f.MT.PasscodeChangePasscodeNew:return void B(f.MT.PasscodeChangePasscodeCurrent);case f.MT.PasscodeChangePasscodeConfirm:return void B(f.MT.PasscodeChangePasscodeNew);case f.MT.PrivacyPhoneNumberAllowedContacts:case f.MT.PrivacyPhoneNumberDeniedContacts:return void B(f.MT.PrivacyPhoneNumber);case f.MT.PrivacyLastSeenAllowedContacts:case f.MT.PrivacyLastSeenDeniedContacts:return void B(f.MT.PrivacyLastSeen);case f.MT.PrivacyProfilePhotoAllowedContacts:case f.MT.PrivacyProfilePhotoDeniedContacts:return void B(f.MT.PrivacyProfilePhoto);case f.MT.PrivacyPhoneCallAllowedContacts:case f.MT.PrivacyPhoneCallDeniedContacts:return void B(f.MT.PrivacyPhoneCall);case f.MT.PrivacyPhoneP2PAllowedContacts:case f.MT.PrivacyPhoneP2PDeniedContacts:return void B(f.MT.PrivacyPhoneP2P);case f.MT.PrivacyForwardingAllowedContacts:case f.MT.PrivacyForwardingDeniedContacts:return void B(f.MT.PrivacyForwarding);case f.MT.PrivacyVoiceMessagesAllowedContacts:case f.MT.PrivacyVoiceMessagesDeniedContacts:return void B(f.MT.PrivacyVoiceMessages);case f.MT.PrivacyGroupChatsAllowedContacts:case f.MT.PrivacyGroupChatsDeniedContacts:return void B(f.MT.PrivacyGroupChats);case f.MT.TwoFaNewPassword:return void B(f.MT.TwoFaDisabled);case f.MT.TwoFaNewPasswordConfirm:return void B(f.MT.TwoFaNewPassword);case f.MT.TwoFaNewPasswordHint:return void B(f.MT.TwoFaNewPasswordConfirm);case f.MT.TwoFaNewPasswordEmail:return void B(f.MT.TwoFaNewPasswordHint);case f.MT.TwoFaNewPasswordEmailCode:return void B(f.MT.TwoFaNewPasswordEmail);case f.MT.TwoFaChangePasswordCurrent:case f.MT.TwoFaTurnOff:case f.MT.TwoFaRecoveryEmailCurrentPassword:return void B(f.MT.TwoFaEnabled);case f.MT.TwoFaChangePasswordNew:return void B(f.MT.TwoFaChangePasswordCurrent);case f.MT.TwoFaChangePasswordConfirm:return void B(f.MT.TwoFaChangePasswordNew);case f.MT.TwoFaChangePasswordHint:return void B(f.MT.TwoFaChangePasswordConfirm);case f.MT.TwoFaRecoveryEmail:return void B(f.MT.TwoFaRecoveryEmailCurrentPassword);case f.MT.TwoFaRecoveryEmailCode:return void B(f.MT.TwoFaRecoveryEmail);case f.MT.FoldersCreateFolder:case f.MT.FoldersEditFolder:return void B(f.MT.Folders);case f.MT.FoldersIncludedChatsFromChatList:case f.MT.FoldersExcludedChatsFromChatList:return void B(f.MT.FoldersEditFolderFromChatList);case f.MT.FoldersEditFolderFromChatList:return N(f.du.ChatList),void B(f.MT.Main);case f.MT.QuickReaction:case f.MT.CustomEmoji:return void B(f.MT.Stickers);case f.MT.DoNotTranslate:return void B(f.MT.Language)}A===f.du.ChatList&&o?N(f.du.GlobalSearch):t()}else N(f.du.NewChannelStep1);else N(f.du.NewGroupStep1);else t()}),[A,o,b,P,w,Z,y,x,l]),$=(0,i.I4)((e=>{A!==f.du.Contacts?(N(f.du.GlobalSearch),e!==t&&w({query:e})):U(e)}),[A,t,w]),G=(0,i.I4)((()=>{N(f.du.GlobalSearch),w({query:""}),y({id:g})}),[g,y,w]);(0,i.d4)((()=>A!==f.du.ChatList||o&&!m&&!p?(0,Ct.Z)((()=>q())):void 0),[o,A,q,m,p]);const H=(0,i.I4)((e=>{A!==f.du.GlobalSearch&&(e.preventDefault(),N(f.du.GlobalSearch))}),[A]),V=(0,i.I4)((e=>{e.preventDefault(),R({id:d,shouldReplaceHistory:!0})}),[d,R]),z=(0,i.I4)((e=>{e.preventDefault(),N(f.du.Archived)}),[]),W=(0,i.I4)((e=>{e.preventDefault(),N(f.du.Settings)}),[]);(0,Mt.y)({"Mod+Shift+F":H,"Mod+Shift+S":V,...s.fl&&{"Mod+0":V,"Mod+9":z},...s.jm&&s.fl&&{"Mod+,":W}}),(0,i.d4)((()=>{S(),x===f.MT.Privacy&&C()}),[S,C,x]),(0,ct.Z)((()=>{void 0!==u&&(N(f.du.Settings),B(u),k({screen:void 0}))}),[u,k]);const{initResize:X,resetResize:Y,handleMouseUp:J}=function(e,t,n,a,s){const[o,r,c]=(0,Et.Z)(),[d,l]=(0,i.eJ)(),[u,m]=(0,i.eJ)(),h=(0,i.I4)((t=>{if(!e.current)return;const n=t?`${t}px`:"";e.current.style.width=n,e.current.style.setProperty(s,n)}),[s,e]);function p(){document.body.classList.remove("cursor-ew-resize")}return(0,i.bt)((()=>{e.current&&a&&h(a)}),[s,e,a,h]),(0,i.d4)((()=>{if(!o)return;const n=e=>{const t=Math.ceil(u+e.clientX-d);h(t)};function a(){s(),t(e.current.offsetWidth)}function s(){p(),document.removeEventListener("mousemove",n,!1),document.removeEventListener("mouseup",a,!1),document.removeEventListener("blur",a,!1),c()}return document.addEventListener("mousemove",n,!1),document.addEventListener("mouseup",a,!1),document.addEventListener("blur",a,!1),s}),[u,d,e,t,o,c,h]),{initResize:function(t){t.preventDefault(),document.body.classList.add("cursor-ew-resize"),l(t.clientX),m(e.current.offsetWidth),r()},resetResize:function(e){e.preventDefault(),h(void 0),n()},handleMouseUp:p}}(T,(e=>E({leftColumnWidth:e})),M,c,"--left-column-width"),K=(0,i.I4)((e=>{N(f.du.Settings),B(e)}),[]);return i.ZP.createElement("div",{id:"LeftColumn",ref:T},i.ZP.createElement(Rt.Z,{name:r?"none":s.s0,renderCount:bn,activeKey:D,shouldCleanup:!0,cleanupExceptionKey:wn.Main},(e=>{switch(D){case wn.Archived:return i.ZP.createElement(vn,{isActive:e,onReset:q,onTopicSearch:G,foldersDispatch:O,onSettingsScreenSelect:K,onLeftColumnContentChange:N,isForumPanelOpen:p,archiveSettings:v});case wn.Settings:return i.ZP.createElement(fn,{isActive:e,currentScreen:x,foldersState:j,foldersDispatch:O,onScreenSelect:K,onReset:q,shouldSkipTransition:r});case wn.NewChannel:return i.ZP.createElement(In,{key:F,isActive:e,isChannel:!0,content:A,onContentChange:N,onReset:q});case wn.NewGroup:return i.ZP.createElement(In,{key:F,isActive:e,content:A,onContentChange:N,onReset:q});default:return i.ZP.createElement(gn,{content:A,isClosingSearch:I,searchQuery:t,searchDate:n,contactsFilter:L,foldersDispatch:O,onContentChange:N,onSearchQuery:$,onSettingsScreenSelect:K,onReset:q,shouldSkipTransition:r,isUpdateAvailable:h,isForumPanelOpen:p,onTopicSearch:G})}})),i.ZP.createElement("div",{className:"resize-handle",onMouseDown:X,onMouseUp:J,onDoubleClick:Y}))})));var Pn=n(12420),Zn=n(49524),Cn=n(71394);var Sn=n(12255),En=n(52678),Mn=n(87204),Rn=n(3570),kn=n(75790),Tn=n(18360),An=n(6058),Nn=n(98799),xn=n(59188),Bn=n(32340),Ln=n(2903),Un=n(68512),jn=n(17551);function On(e,t,n,a,s){return`M${e},${t+s}a${s},${s},0,0,1,\n ${n},0v${a-2*s}a${s},${s},0,0,1,${-n},0Z`}const Fn=(0,i.X$)((e=>{let{count:t,index:n}=e;const a=(0,i.sO)(null),s=(0,i.Ye)((()=>function(e,t){const n=e-t-1,a=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),s=function(e,t){let n=36;return 1===e?n=36:2===e?n=17:3===e?n=1===t?12:11:(4===e||e>3)&&(n=7.5),n}(e,n),o=function(e,t){return e<=3?36:t*e+2*(e-1)}(e,a),i=`clipPath${e}`,r=function(e,t,n){let a="";if(3===n)a=On(0,0,2,t,1)+On(0,12,2,t+1,1)+On(0,25,2,t,1);else for(let e=0;e<n;e++)a+=On(0,(t+2)*e,2,t,1);return`<clipPath id="${e}">\n <path d="${a}" />\n </clipPath>`}(i,a,e),c=function(e,t,n){return 1===n?0:2===n?0===e?0:t+2:3===n?0===e?0:1===e?12:25:(t+2)*e}(n,a,e),d=function(e,t,n,a){return t<=4||e<=1?0:e>=t-2?a-36:(n+4)/2+(e-2)*(n+2)}(n,e,a,o);return{markHeight:s,clipPath:r,markTranslateY:c,trackTranslateY:d,trackHeight:o,clipPathId:i}}(t,n)),[t,n]);if((0,i.d4)((()=>{if(!a.current)return;const{trackHeight:e,trackTranslateY:t,markHeight:n,markTranslateY:o,clipPathId:i,clipPath:r}=s,c=a.current.firstElementChild;if(a?.current){const s=a.current,{style:d}=s;d.height=`${e}px`,d.transform=`translateY(-${t}px)`,d.clipPath=`url("#${i}")`;const l=s.querySelector("svg"),u=s.querySelector("div"),m=s.querySelector("defs");l||c&&(c.innerHTML=`<svg height="0" width="0"><defs> ${r} </defs></svg>`),m&&(m.innerHTML=r),u&&(u.style.height=`${n}px`,u.style.transform=`translateY(${o}px)`)}}),[s]),1===t)return i.ZP.createElement("div",{className:"pinned-message-border"},i.ZP.createElement("div",{className:"pinned-message-border-wrapper-1",ref:a}));const{trackHeight:o,trackTranslateY:r,markHeight:c,markTranslateY:d,clipPathId:l}=s;return i.ZP.createElement("div",{className:(0,tt.Z)("pinned-message-border",t>4&&"pinned-message-border-mask")},i.ZP.createElement("div",{className:"pinned-message-border-wrapper",ref:a,style:`clip-path: url("#${l}"); width: 2px;\n height: ${o}px; transform: translateY(-${r}px);`},i.ZP.createElement("span",null),i.ZP.createElement("div",{className:"pinned-message-border-mark",style:`height: ${c}px; transform: translateY(${d}px);`})))}));var _n=n(45370),Dn=n(62230);const qn=(0,i.X$)((e=>{let{message:t,count:n,index:o,customTitle:r,className:c,onUnpinMessage:d,onClick:l,onAllPinnedClick:m}=e;const{clickBotInlineButton:h}=(0,a.Sv)(),p=(0,kt.Z)(),g=(0,Ln.Z)(t),f=(0,Wt.Z)((0,u.Ti)(t,"pictogram")),I=(0,u.NE)(t),[v,w,b]=(0,Et.Z)(),y=(0,i.I4)((()=>{b(),d&&d(t.id)}),[b,d,t.id]),P=(0,u.eH)(t),Z=(0,i.I4)((()=>{P&&h({messageId:t.id,button:P})}),[h,P,t.id]),[C,S,E]=(0,Et.Z)();return i.ZP.createElement("div",{className:(0,tt.Z)("HeaderPinnedMessage-wrapper",c)},n>1&&i.ZP.createElement(Ft.Z,{round:!0,size:"smaller",color:"translucent",className:"pin-list-button",ariaLabel:p("EventLogFilterPinnedMessages"),onClick:m},i.ZP.createElement("i",{className:"icon-pin-list"})),d&&i.ZP.createElement(Ft.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:p("UnpinMessageAlertTitle"),className:"unpin-button",onClick:w},i.ZP.createElement("i",{className:"icon-close"})),i.ZP.createElement(jn.Z,{isOpen:v,onClose:b,text:"Would you like to unpin this message?",confirmLabel:"Unpin",confirmHandler:y}),i.ZP.createElement("div",{className:(0,tt.Z)("HeaderPinnedMessage",C&&"no-hover"),onClick:l,dir:p.isRtl?"rtl":void 0},i.ZP.createElement(Fn,{count:n,index:o}),g&&function(e,t,n){const{width:a,height:s}=(0,Re.W7)(),o=t||e;return i.ZP.createElement("div",{className:"pinned-thumb"},!n&&i.ZP.createElement("img",{className:"pinned-thumb-image",src:o,width:a,height:s,alt:""}),i.ZP.createElement(Dn.Z,{thumbDataUri:o,isVisible:Boolean(n),width:a,height:s}))}(g,f,I),i.ZP.createElement("div",{className:"message-text"},i.ZP.createElement("div",{className:"title",dir:"auto"},r?(0,Bn.Z)(r):`${p("PinnedMessage")} ${o>0?"#"+(n-o):""}`),i.ZP.createElement("p",{dir:"auto"},i.ZP.createElement(_n.Z,{lang:p,message:t,noEmoji:Boolean(g)})),i.ZP.createElement(Un.Z,null)),P&&i.ZP.createElement(Ft.Z,{size:"tiny",className:"inline-button",onClick:Z,shouldStopPropagation:!0,onMouseEnter:s.$b?void 0:S,onMouseLeave:s.$b?void 0:E},P.text)))}));var $n=n(10396),Gn=n(64532),Hn=n(23186),Vn=n(75851);const zn=240;function Wn(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"image/png";const a=e instanceof Blob?URL.createObjectURL(e):e,s=new Image;return new Promise((o=>{s.onload=()=>{Xn(s,s.width*t,s.height*t,n).then((e=>{if(!e)throw new Error("Image resize failed!");return URL.createObjectURL(e)})).then(o).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(a)}))},s.src=a}))}async function Xn(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";if(!("createImageBitmap"in window))return Yn(e,t,n,void 0,a);try{const s=await window.createImageBitmap(e,{resizeWidth:t,resizeHeight:n,resizeQuality:"high"});if(s.height!==n||s.width!==t)throw new Error("Image bitmap resize not supported!");const o=await(0,Vn.ix)(e.src),i=(0,Vn.rZ)(o)<zn?"#fff":"#000";return await new Promise((e=>{const t=document.createElement("canvas");t.width=s.width,t.height=s.height;const n=t.getContext("2d");n.fillStyle=i,n.fillRect(0,0,t.width,t.height);const o=t.getContext("bitmaprenderer");o?o.transferFromImageBitmap(s):n.drawImage(s,0,0),t.toBlob(e,a)}))}catch(s){return Yn(e,t,n,void 0,a)}}async function Yn(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"image/png";const o=document.createElement("canvas"),i=o.getContext("2d"),r=document.createElement("canvas"),c=r.getContext("2d");if(o.width=t,o.height=n,e.width*a>t){const n=1/a;let s={width:Math.floor(e.width*a),height:Math.floor(e.height*a)};for(r.width=s.width,r.height=s.height,c.drawImage(e,0,0,s.width,s.height);s.width*a>t;)s={width:Math.floor(s.width*a),height:Math.floor(s.height*a)},c.drawImage(r,0,0,s.width*n,s.height*n,0,0,s.width,s.height);i.drawImage(r,0,0,s.width,s.height,0,0,o.width,o.height)}else i.drawImage(e,0,0,o.width,o.height);const d=await(0,Vn.ix)(e.src),l=(0,Vn.rZ)(d)<zn?"#fff":"#000";return i.fillStyle=l,i.globalCompositeOperation="destination-over",i.fillRect(0,0,o.width,o.height),new Promise((e=>{o.toBlob(e,s)}))}var Jn=n(77510);const Kn=n.p+"telegram-logo-filled.67469f6dc5e301e8e0bd.svg",Qn={width:200,height:200},ea=115;var ta=n(17240),na=n(18051);const aa={.5:.66,.75:.8,1:1,1.5:1.4,2:1.8},sa=Object.keys(aa).sort().map(Number),oa=(0,a.c$)(((e,t)=>{let{message:n}=t;const a=(0,d.Ur)(e,n),s=(0,d.Z1)(e,n.chatId),{volume:o,playbackRate:i,isMuted:r,isPlaybackRateActive:c}=(0,d.jU)(e).audioPlayer;return{sender:a,chat:s,volume:o,playbackRate:i,isPlaybackRateActive:c,isMuted:r}}))((e=>{let{message:t,className:n,noUi:r,sender:c,chat:d,volume:l,playbackRate:m,isPlaybackRateActive:h,isMuted:p}=e;const{setAudioPlayerVolume:g,setAudioPlayerPlaybackRate:f,setAudioPlayerMuted:I,focusMessage:v,closeAudioPlayer:w}=(0,a.Sv)(),b=(0,i.sO)(null),y=(0,kt.Z)(),{isMobile:P}=(0,C.ZP)(),{audio:Z,voice:S,video:E}=(0,u.qp)(t),M=Boolean(S||E),R=M||(Z?.duration||0)>o.J0S,k=c?(0,u.OU)(y,c):void 0,T=Me.UV((0,u.Ti)(t,"inline")),A=((e,t,n)=>{const a=(0,kt.Z)(),{audio:s,voice:o}=(0,u.qp)(e),r=s?s.title||s.fileName:o?"Voice message":"",c=s?.performer||t&&(0,u.OU)(a,t),d=n&&(0,u.U)(a,n)||"Telegram",l=s&&(0,u.MR)(s)&&(0,u.Ti)(e,"pictogram"),m=t&&(0,u.RT)(t,"big"),h=s&&l||o&&m,p=(0,Wt.Z)(h),g=(0,i.Ye)((()=>function(e,t,n){if(!n)return Qn;if(e){if(!e.thumbnailSizes?.length)return;const t=e.thumbnailSizes.find((e=>"m"===e.type));return t||e.thumbnailSizes[0]}return t?Re.vY:void 0}(s,o,p)),[s,p,o]),{result:f}=(0,Jn.Z)((()=>function(e,t){if(!e)return Promise.resolve(Kn);if(!t)return function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";const s=e instanceof Blob?URL.createObjectURL(e):e,o=new Image;return new Promise((i=>{o.onload=()=>{Xn(o,t,n,a).then((e=>{if(!e)throw new Error("Image resize failed!");return URL.createObjectURL(e)})).then(i).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(s)}))},o.src=s}))}(e,ea,ea);const n=Math.min(t.width,t.height);return n<ea?Wn(e,ea/n):Promise.resolve(e)}(p,g)),[p,g],Kn);return(0,i.Ye)((()=>(0,Gn.Of)({title:r,artist:c,album:d,artwork:[{src:f}]})),[d,c,r,f])})(t,c,d),{playPause:N,stop:x,isPlaying:B,requestNextTrack:L,requestPreviousTrack:U,isFirst:j,isLast:O,setVolume:F,toggleMuted:_,setPlaybackRate:D}=(0,Hn.Z)((0,$n.An)(t),(0,u.XV)(t),M?"voice":"audio",T,void 0,A,void 0,!0,void 0,void 0,(0,u.CI)(t),!0),{isContextMenuOpen:q,handleBeforeContextMenu:$,handleContextMenu:G,handleContextMenuClose:H,handleContextMenuHide:V}=(0,ta.Z)(b),z=(0,i.I4)((()=>{v({chatId:t.chatId,messageId:t.id})}),[v,t.chatId,t.id]),W=(0,i.I4)((()=>{B&&N(),w(),(0,Gn.Ay)(),x()}),[w,B,N,x]),X=(0,i.I4)((e=>{g({volume:e/100}),F(e/100)}),[g,F]),Y=(0,i.I4)((()=>{s.$b&&!s.cj||(_(),I({isMuted:!p}))}),[p,I,_]),J=(0,i.I4)((function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const n=aa[e],a=1!==e&&t;f({playbackRate:n,isPlaybackRateActive:a}),D(a?n:1)}),[f,D]),K=(0,i.I4)((()=>{H();const e=Number(Object.entries(aa).find((e=>{let[,t]=e;return t===m}))?.[0])||1,t=!h;J(t&&1===e?2:e,t)}),[H,h,m,J]),Q=(0,i.I4)((()=>{const e=Object.entries(aa).find((e=>{let[,t]=e;return t===m}))?.[0]||1,t=`${1===m?2:e}Х`;return i.ZP.createElement("div",{className:"playback-wrapper"},q&&i.ZP.createElement("div",{className:"playback-backdrop",onClick:H}),i.ZP.createElement(Ft.Z,{round:!0,className:(0,tt.Z)("playback-button",h&&"applied",q&&"on-top"),color:"translucent",size:"smaller",ariaLabel:"Playback Rate",ripple:!P,onMouseEnter:G,onClick:K,onMouseDown:$,onContextMenu:G},i.ZP.createElement("span",{className:(0,tt.Z)("playback-button-inner",4===t.length&&"small",5===t.length&&"tiny")},t)))}),[$,G,H,K,q,P,h,m]),ee=(0,i.Ye)((()=>0===l||p?"icon-muted":l<.3?"icon-volume-1":l<.6?"icon-volume-2":"icon-volume-3"),[l,p]);if(!r)return i.ZP.createElement("div",{className:(0,tt.Z)("AudioPlayer",n),dir:y.isRtl?"rtl":void 0,ref:b},i.ZP.createElement("div",{className:"AudioPlayer-content",onClick:z},Z?function(e){const{title:t,performer:n,fileName:a}=e;return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("div",{className:"title",dir:"auto"},(0,Bn.Z)(t||a)),n&&i.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,Bn.Z)(n)))}(Z):function(e,t){return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,Bn.Z)(t)),i.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(y("AttachAudio"),k),i.ZP.createElement(Un.Z,null)),i.ZP.createElement(Ft.Z,{round:!0,ripple:!P,color:"translucent",size:"smaller",className:"player-button",disabled:j(),onClick:U,ariaLabel:"Previous track"},i.ZP.createElement("i",{className:"icon-skip-previous"})),i.ZP.createElement(Ft.Z,{round:!0,ripple:!P,color:"translucent",size:"smaller",className:(0,tt.Z)("toggle-play","player-button",B?"pause":"play"),onClick:N,ariaLabel:B?"Pause audio":"Play audio"},i.ZP.createElement("i",{className:"icon-play"}),i.ZP.createElement("i",{className:"icon-pause"})),i.ZP.createElement(Ft.Z,{round:!0,ripple:!P,color:"translucent",size:"smaller",className:"player-button",disabled:O(),onClick:L,ariaLabel:"Next track"},i.ZP.createElement("i",{className:"icon-skip-next"})),i.ZP.createElement("div",{className:"volume-button-wrapper"},i.ZP.createElement(Ft.Z,{round:!0,className:"player-button volume-button",color:"translucent",size:"smaller",ariaLabel:"Volume",onClick:Y,ripple:!P},i.ZP.createElement("i",{className:ee})),!s.cj&&i.ZP.createElement("div",{className:"volume-slider-wrapper"},i.ZP.createElement("div",{className:"volume-slider-spacer"}),i.ZP.createElement("div",{className:"volume-slider"},i.ZP.createElement(na.Z,{bold:!0,value:p?0:100*l,onChange:X})))),R&&i.ZP.createElement(jt.Z,{forceOpen:q,positionX:"right",positionY:"top",className:"playback-rate-menu",trigger:Q,onClose:H,onHide:V,onMouseEnterBackdrop:H},sa.map((e=>function(e,t,n,a){const s=t===aa[e]&&a||1===e&&!a;return i.ZP.createElement(Ot.Z,{key:e,onClick:()=>n(e),icon:s?"check":void 0,customIcon:s?void 0:i.ZP.createElement("i",{className:"icon-placeholder"})},e,"X")}(e,m,J,h)))),i.ZP.createElement(Ft.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:W,ariaLabel:"Close player"},i.ZP.createElement("i",{className:"icon-close"})))}));var ia=n(4794),ra=n(14605);const ca=(0,i.X$)((0,a.c$)(((e,t)=>{let{chatId:n}=t;return{currentUserId:e.currentUserId,chat:(0,d.Z1)(e,n),user:(0,u.YC)(n)?(0,d.dy)(e,n):void 0}}))((e=>{let{chatId:t,className:n,chat:s,user:o,settings:r,currentUserId:c}=e;const{openAddContactDialog:d,blockContact:l,reportSpam:m,deleteChat:h,leaveChannel:p,deleteChatUser:g,deleteHistory:f,toggleChatArchived:I,hideChatReportPanel:v}=(0,a.Sv)(),w=(0,kt.Z)(),[b,y,P]=(0,Et.Z)(),[Z,C]=(0,i.eJ)(!0),[S,E]=(0,i.eJ)(!0),{accessHash:M}=s||{},{isAutoArchived:R,canReportSpam:k,canAddContact:T,canBlockContact:A}=r||{},N=s&&(0,u.G9)(s),x=(0,i.I4)((()=>{d({userId:t}),R&&I({id:t})}),[d,R,I,t]),B=(0,i.I4)((()=>{P(),l({contactId:t,accessHash:M}),k&&Z&&m({chatId:t}),S&&h({chatId:t})}),[M,l,P,h,m,k,S,Z,t]),L=(0,i.I4)((()=>{v({chatId:t})}),[t,v]),U=(0,i.I4)((()=>{P(),m({chatId:t}),N?(g({chatId:t,userId:c}),f({chatId:t,shouldDeleteForAll:!1})):p({chatId:t})}),[t,P,c,g,f,N,p,m]);if(r)return i.ZP.createElement("div",{className:(0,tt.Z)("ChatReportPanel",n),dir:w.isRtl?"rtl":void 0},T&&i.ZP.createElement(Ft.Z,{isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:x},w("lng_new_contact_add")),A&&i.ZP.createElement(Ft.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:y},w("lng_new_contact_block")),k&&!A&&i.ZP.createElement(Ft.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:y},w("lng_report_spam_and_leave")),i.ZP.createElement(Ft.Z,{round:!0,ripple:!0,size:"tiny",color:"translucent",onClick:L,ariaLabel:w("Close")},i.ZP.createElement("i",{className:"icon-close"})),i.ZP.createElement(jn.Z,{isOpen:b,onClose:P,title:w("BlockUserTitle",o?(0,u.Vl)(o):(0,u.U)(w,s)),text:o?w("UserInfo.BlockConfirmationTitle",(0,u.Js)(o)):w("Chat.Confirm.ReportSpam.Channel"),confirmIsDestructive:!0,confirmLabel:w("Block"),confirmHandler:o?B:U},o&&i.ZP.createElement(ra.Z,{label:w("DeleteThisChat"),checked:S,onCheck:E}),o&&k&&i.ZP.createElement(ra.Z,{label:w("ReportChat"),checked:Z,onCheck:C})))}))),da=(0,i.X$)((0,a.c$)(((e,t)=>{let{chatId:n,threadId:a,messageListType:s,isMobile:o}=t;const{isLeftColumnShown:i,shouldSkipHistoryAnimations:c,audioPlayer:l,messageLists:m}=(0,d.jU)(e),{lastSyncTime:h}=e,p=(0,d.Z1)(e,n),{chatId:g,messageId:f}=l,I=g&&f?(0,d.hj)(e,g,f):void 0;let v;"pinned"===s?v=(0,d.KB)(e,n,a)?.length:"scheduled"===s?v=(0,d.qy)(e,n,a)?.length:"thread"===s&&a!==r._f&&(v=(0,d.tZ)(e,n,a)?.messagesCount||0);const w="thread"===s&&a===r._f,b=p&&(0,d.xo)(e,p),y=Boolean(b&&(0,d.s4)(e,n)),P=b&&!y&&Boolean((0,d.pk)(e,n)),Z=Boolean(p&&(w||p.isForum)&&((0,u.eA)(p)||(0,u.ZV)(p))&&p.isNotJoined),C=Boolean(p?.isNotJoined&&p.isJoinRequest),S=(0,d.WP)(e,n,a,"typingStatus"),E=(0,d.jU)(e).focusedMessage,M={typingStatus:S,isLeftColumnShown:i,isRightColumnShown:(0,d.Jf)(e,o),isSelectModeActive:(0,d.CA)(e),audioMessage:I,chat:p,messagesCount:v,isChatWithSelf:(0,d.FM)(e,n),lastSyncTime:h,shouldSkipHistoryAnimations:c,currentTransitionKey:Math.max(0,m.length-1),connectionState:e.connectionState,isSyncing:e.isSyncing,hasButtonInHeader:P||y||Z||C,hasReachedFocusedMessage:!E||E.hasReachedMessage},R=(0,d.Zw)(e,n);if("thread"!==s||!R)return M;if(Object.assign(M,{messagesById:R}),a!==r._f&&!p?.isForum){const t=(0,d.qS)(e,n,a),s=t?(0,d.hj)(e,n,t):void 0,o=s?(0,d.cv)(e,s):void 0,i=(0,d.tZ)(e,n,a);return{...M,pinnedMessageIds:t,canUnpin:!1,topMessageSender:o,isComments:Boolean(i?.originChannelId)}}const k=(0,d.KB)(e,n,a);if(k?.length){const t=R[k[0]],{canUnpin:n}=t&&(0,d._k)(e,t,a)||{};return{...M,pinnedMessageIds:k,canUnpin:n}}return M}))((e=>{let{chatId:t,threadId:n,messageListType:s,isReady:c,isMobile:d,pinnedMessageIds:l,messagesById:m,canUnpin:h,topMessageSender:p,typingStatus:g,isSelectModeActive:f,isLeftColumnShown:I,isRightColumnShown:v,audioMessage:w,chat:b,messagesCount:y,isComments:P,isChatWithSelf:Z,lastSyncTime:S,hasButtonInHeader:E,shouldSkipHistoryAnimations:M,currentTransitionKey:R,connectionState:k,hasReachedFocusedMessage:T,isSyncing:A}=e;const{openChatWithInfo:N,pinMessage:x,focusMessage:B,openChat:L,openPreviousChat:U,setReachedFocusedMessage:j,loadPinnedMessages:O,toggleLeftColumn:F,exitMessageSelectMode:_}=(0,a.Sv)(),D=(0,kt.Z)(),q=(0,i.sO)(!0),[$,G]=(0,i.eJ)(!1),{isTablet:H}=(0,C.ZP)(),[V,z]=(0,i.eJ)(0),W=Array.isArray(l)?l[V]:l,X=m&&W?m[W]:void 0,Y=Array.isArray(l)?l.length:l?1:void 0,J=b&&(0,u.U)(D,b).length,K=p?(0,u.OU)(D,p):void 0,{settings:Q}=b||{},ee=b?.isForum;(0,i.d4)((()=>{S&&c&&(n===r._f||ee)&&O({chatId:t,threadId:n})}),[t,O,S,n,c,ee]),(0,i.d4)((()=>{z(0),G(!1)}),[l]),(0,i.d4)((()=>{if(T&&$){j({hasReached:!1}),G(!1);const e=(0,Rn.Z)(Y||1,V+1);z(e)}}),[T,$,V,Y,j]),(0,kn.Z)(t,W,X);const{width:te}=(0,Sn.Z)(),ne=te<=o.ksF,ae=H&&I,se=(0,i.sO)(null),oe=(0,i.sO)(!0),ie=(0,i.I4)((()=>{N({id:t,threadId:n})}),[N,t,n]),re=(0,i.I4)((e=>{x({messageId:e,isUnpin:!0})}),[x]),ce=(0,i.I4)((()=>{X&&(B({chatId:X.chatId,threadId:n,messageId:X.id,noForumTopicPanel:!0}),G(!0))}),[X,B,n]),de=(0,i.I4)((()=>{L({id:t,threadId:n,type:"pinned"})}),[L,t,n]),le=(0,i.I4)((()=>{setTimeout((()=>{q.current=!0}),450)}),[]),ue=(0,i.I4)((e=>{if(q.current){if(q.current=!1,d&&document.querySelector(o.Edp)?.blur(),f)return _(),void le();if("thread"===s&&0===R)return!H||ae?(e.stopPropagation(),L({id:void 0},{forceOnHeavyAnimation:!0})):F(),void le();U(),le()}}),[d,f,s,R,le,H,ae]),me=te>=o.ksF&&te<o.jT7||te>o.l35&&te<o.ksF&&(!J||J>30),he=me||te>o._mX&&te<o.QU1,pe=Boolean(Q?.canAddContact||Q?.canBlockContact||Q?.canReportSpam),{shouldRender:ge,transitionClassNames:fe}=(0,pt.Z)(pe),Ie=(0,Tn.Z)(pe?Q:void 0,!0),{shouldRender:ve,transitionClassNames:we}=(0,pt.Z)(Boolean(w)),be=(0,Tn.Z)(w,!0),{shouldRender:ye,transitionClassNames:Pe}=(0,pt.Z)(Boolean(X)),Ze=(0,Tn.Z)(X,!0),Ce=(0,Tn.Z)(Y,!0),Se=(0,Tn.Z)(h,!0),Ee=(0,Tn.Z)(K),Me=(0,Mn.Z)(R),Re=void 0!==Me&&Me<R?Me:void 0,ke=ye&&Ze||ve&&be;(0,i.d4)((()=>{const e=se.current;if(e)return he&&ke?void(v||me?(oe.current&&(e.classList.add("tools-stacked","animated"),oe.current=!1),setTimeout((()=>{e.classList.remove("animated")}),350)):(e.classList.remove("tools-stacked"),oe.current=!0)):(e.classList.remove("tools-stacked","animated"),void(oe.current=!0))}),[he,ke,me,v]);const{connectionStatusText:Te}=Bt(D,k,A,!0);function Ae(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return i.ZP.createElement("div",{className:"back-button"},i.ZP.createElement(Ft.Z,{round:!0,size:"smaller",color:"translucent",onClick:ue,ariaLabel:D(e?"Close":"Back")},i.ZP.createElement("div",{className:(0,tt.Z)("animated-close-icon",!e&&"state-back")})),t&&i.ZP.createElement(Zt,null))}const Ne=Boolean(ve&&be),xe=Ne||!d&&E&&te<o.sgm;return i.ZP.createElement("div",{className:"MiddleHeader",ref:se},i.ZP.createElement(Rt.Z,{name:M?"none":"slide-fade",activeKey:R,shouldCleanup:!0,cleanupExceptionKey:Re},"thread"!==s||n!==r._f&&!b?.isForum?i.ZP.createElement(i.ZP.Fragment,null,Ae(),i.ZP.createElement("h3",null,void 0!==y?"thread"===s?D(P?"CommentsCount":"Replies",y,"i"):"pinned"===s?D("PinnedMessagesCount",y,"i"):"scheduled"===s?Z?D("Reminders"):D("messages",y,"i"):void 0:D("Loading"))):i.ZP.createElement(i.ZP.Fragment,null,(ne||R>0)&&Ae(ae,!0),i.ZP.createElement("div",{className:"chat-info-wrapper",onClick:ie},(0,u.YC)(t)?i.ZP.createElement(An.Z,{key:t,userId:t,typingStatus:g,status:Te,withDots:Boolean(Te),withFullInfo:!0,withMediaViewer:!0,withUpdatingStatus:!0,withVideoAvatar:c,emojiStatusSize:22,noRtl:!0}):i.ZP.createElement(Nn.Z,{key:t,chatId:t,threadId:n,typingStatus:g,status:Te,withDots:Boolean(Te),withMediaViewer:n===r._f,withFullInfo:n===r._f,withUpdatingStatus:!0,withVideoAvatar:c,noRtl:!0})))),n===r._f&&!b?.isForum&&i.ZP.createElement(ia.Z,{hasPinnedOffset:ye&&Boolean(Ze)||ve&&Boolean(be),chatId:t}),ye&&Ze&&i.ZP.createElement(qn,{key:t,message:Ze,count:Ce||0,index:V,customTitle:Ee,className:(0,tt.Z)(Pe,xe&&"full-width"),onUnpinMessage:Se?re:void 0,onClick:ce,onAllPinnedClick:de}),ge&&i.ZP.createElement(ca,{key:t,chatId:t,settings:Ie,className:fe}),i.ZP.createElement("div",{className:"header-tools"},Ne&&i.ZP.createElement(oa,{key:(0,u.Tp)(be),message:be,className:we}),i.ZP.createElement(xn.Z,{chatId:t,threadId:n,messageListType:s,isMobile:d,canExpandActions:!Ne})))})));function la(e){return"albumId"in e}function ua(e,t){let n,a=[],s={originalDate:e[0].date,datetime:(0,ae._F)(1e3*e[0].date),senderGroups:[a]};const o=[s];return e.forEach(((i,r)=>{i.isInAlbum?n?(n.messages.push(i),i.content.text&&(n.mainMessage=i)):n={albumId:i.groupedId,messages:[i],mainMessage:i}:a.push(i);const c=e[r+1];if(!n||c&&c.groupedId&&c.groupedId===n.albumId||(a.push(n),n=void 0),c){const e=(0,ae._F)(1e3*c.date);s.datetime!==e?(s={originalDate:c.date,datetime:e,senderGroups:[]},o.push(s),a=[],s.senderGroups.push(a)):(c.id===t||i.senderId!==c.senderId||i.isOutgoing!==c.isOutgoing||(0,u.FT)(i)||(0,u.FT)(c)||i.forwardInfo&&c.forwardInfo&&(i.forwardInfo.senderUserId!==c.forwardInfo.senderUserId||i.forwardInfo.fromChatId!==c.forwardInfo.fromChatId||i.forwardInfo.hiddenUserName!==c.forwardInfo.hiddenUserName)||i.inlineButtons||c.inlineButtons||c.date-i.date>600)&&(a=[],s.senderGroups.push(a))}})),o}var ma=n(30386),ha=n(87675),pa=n(60539),ga=n(88957);var fa=n(60998);const Ia=(e,t,n)=>{const a=(0,Mn.Z)(t);return(0,i.bt)((()=>e(a||[])),t,n)};var va=n(78722),wa=n(3657);const ba=s.wZ?1e3:350;function ya(e,t){return e?t?238:175:t?238:100}function Pa(e,t,n,a){const s=(0,u.B4)(e),o=(0,u.O$)(e)||(0,u.F$)(e),i=(0,u.b7)(e),r=Boolean((0,u.F$)(e)),c=Boolean((0,u.Cg)(e)),{width:d,height:l}=o?(0,Re.Eh)(o,s,t,r,n,a):(0,Re.GC)(i,s,t,c,n,a),m=ya(Boolean((0,u.UD)(e)));let h=1;d<m&&m-d<12&&(h=m/d),l*h<90&&90-l*h<12&&(h=90/l);const p=Math.round(d*h),g=Math.round(l*h);return{width:p,height:g,isSmall:p<m||g<90}}var Za=n(28712);function Ca(e,t){return e.reduce(((e,t)=>e+t),t)}function Sa(e){const t={width:0,height:0};return e.forEach((e=>{let{dimensions:n,sides:a}=e;2&a&&(t.width=n.width+n.x),4&a&&(t.height=n.height+n.y)})),t}function Ea(e,t,n,a,s){const o=function(e,t){return e.map((e=>{const n=Pa(e,void 0,void 0,t);return n.width/n.height}))}(a.messages,s),i=function(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}(o),r=function(e){return e.reduce(((e,t)=>t+e),1)/e.length}(o),c=o.length,d=o.some((e=>e>2)),l=(0,Re.kc)(e,t,!1,n,s)-(t?2.5:0)*Re.Gw;let u;const m={ratios:o,proportions:i,averageRatio:r,maxWidth:l,minWidth:100,maxHeight:l,spacing:2};return u=c>=5||d?function(e){let{ratios:t,averageRatio:n,maxWidth:a,minWidth:s,spacing:o,maxHeight:i=4*a/3}=e;const r=function(e,t){return e.map((e=>t>1.1?(0,Za.uZ)(e,1,2.75):(0,Za.uZ)(e,.6667,1)))}(t,n),c=t.length,d=new Array(c),l=[],u=e=>{const t=[];let n=0;e.forEach((e=>{t.push(((e,t)=>{const n=Ca(r.slice(e,e+t),0);return(a-(t-1)*o)/n})(n,e)),n+=e})),l.push({lineCounts:e,heights:t})};for(let e=1;e!==c;++e){const t=c-e;e<=3&&t<=3&&u([e,t])}for(let e=1;e!==c-1;++e)for(let t=1;t!==c-e;++t){const a=c-e-t;e<=3&&t<=(n<.85?4:3)&&a<=3&&u([e,t,a])}for(let e=1;e!==c-1;++e)for(let t=1;t!==c-e;++t)for(let n=1;n!==c-e-t;++n){const a=c-e-t-n;e<=3&&t<=3&&n<=3&&a<=4&&u([e,t,n,a])}let m,h=0;for(let e=0;e<l.length;e++){const{heights:t,lineCounts:n}=l[e],a=n.length,r=Ca(t,0)+o*(a-1),c=Math.min(...t)<s?1.5:1,d=(()=>{for(let e=1;e!==a;++e)if(n[e-1]>n[e])return 1.5;return 1})(),u=Math.abs(r-i)*c*d;(!m||u<h)&&(m=l[e],h=u)}const p=m.lineCounts,g=m.heights,f=p.length;let I=0,v=0;for(let e=0;e!==f;++e){const t=p[e],n=g[e],s=Math.round(n);let i=0;for(let c=0;c!==t;++c){const l=0|(0===e?1:0)|(e===f-1?4:0)|(0===c?8:0)|(c===t-1?2:0),u=r[I],m=c===t-1?a-i:Math.round(u*n);d[I]={dimensions:{x:i,y:v,width:m,height:s},sides:l},i+=m+o,++I}v+=s+o}return d}(m):2===c?function(e){const{ratios:t,proportions:n,averageRatio:a}=e;return"ww"===n&&a>1.4&&t[1]-t[0]<.2?function(e){const{ratios:t,maxWidth:n,spacing:a,maxHeight:s}=e,o=Math.round(Math.min(n/t[0],Math.min(n/t[1],(s-a)/2)));return[{dimensions:{x:0,y:0,width:n,height:o},sides:11},{dimensions:{x:0,y:o+a,width:n,height:o},sides:14}]}(e):"ww"===n||"qq"===n?function(e){const{ratios:t,maxWidth:n,spacing:a,maxHeight:s}=e,o=(n-a)/2,i=Math.round(Math.min(o/t[0],Math.min(o/t[1],s)));return[{dimensions:{x:0,y:0,width:o,height:i},sides:13},{dimensions:{x:o+a,y:0,width:o,height:i},sides:7}]}(e):function(e){const{ratios:t,minWidth:n,maxWidth:a,spacing:s,maxHeight:o}=e,i=Math.round(1.5*n),r=Math.min(Math.round(Math.max(.4*(a-s),(a-s)/t[0]/(1/t[0]+1/t[1]))),a-s-i),c=a-r-s,d=Math.min(o,Math.round(Math.min(c/t[0],r/t[1])));return[{dimensions:{x:0,y:0,width:c,height:d},sides:13},{dimensions:{x:c+s,y:0,width:r,height:d},sides:7}]}(e)}(m):3===c?function(e){const{proportions:t}=e;return"n"===t[0]?function(e){const{maxHeight:t,spacing:n,ratios:a,maxWidth:s,minWidth:o}=e,i=t,r=Math.round(Math.min((t-n)/2,a[1]*(s-n)/(a[2]+a[1]))),c=i-r-n,d=Math.max(o,Math.round(Math.min((s-n)/2,Math.min(r*a[2],c*a[1])))),l=Math.min(Math.round(i*a[0]),s-n-d);return[{dimensions:{x:0,y:0,width:l,height:i},sides:13},{dimensions:{x:l+n,y:0,width:d,height:c},sides:3},{dimensions:{x:l+n,y:c+n,width:d,height:r},sides:6}]}(e):function(e){const{maxWidth:t,ratios:n,maxHeight:a,spacing:s}=e,o=t,i=Math.round(Math.min(o/n[0],.66*(a-s))),r=(t-s)/2,c=Math.min(a-i-s,Math.round(Math.min(r/n[1],r/n[2])));return[{dimensions:{x:0,y:0,width:o,height:i},sides:11},{dimensions:{x:0,y:i+s,width:r,height:c},sides:12},{dimensions:{x:r+s,y:i+s,width:o-r-s,height:c},sides:6}]}(e)}(m):function(e){const{proportions:t}=e;return"w"===t[0]?function(e){let{maxWidth:t,ratios:n,spacing:a,maxHeight:s,minWidth:o}=e;const i=t,r=Math.round(Math.min(i/n[0],.66*(s-a))),c=Math.round((t-2*a)/(n[1]+n[2]+n[3])),d=Math.max(o,Math.round(Math.min(.4*(t-2*a),c*n[1]))),l=Math.round(Math.max(Math.max(o,.33*(t-2*a)),c*n[3])),u=i-d-l-2*a,m=Math.min(s-r-a,c);return[{dimensions:{x:0,y:0,width:i,height:r},sides:11},{dimensions:{x:0,y:r+a,width:d,height:m},sides:12},{dimensions:{x:d+a,y:r+a,width:u,height:m},sides:4},{dimensions:{x:d+a+u+a,y:r+a,width:l,height:m},sides:6}]}(e):function(e){let{maxHeight:t,ratios:n,maxWidth:a,spacing:s,minWidth:o}=e;const i=t,r=Math.round(Math.min(i*n[0],.6*(a-s))),c=Math.round((t-2*s)/(1/n[1]+1/n[2]+1/n[3])),d=Math.round(c/n[1]),l=Math.round(c/n[2]),u=i-d-l-2*s,m=Math.max(o,Math.min(a-r-s,c));return[{dimensions:{x:0,y:0,width:r,height:i},sides:13},{dimensions:{x:r+s,y:0,width:m,height:d},sides:3},{dimensions:{x:r+s,y:d+s,width:m,height:l},sides:2},{dimensions:{x:r+s,y:d+l+2*s,width:m,height:u},sides:6}]}(e)}(m),{layout:u,containerStyle:Sa(u)}}let Ma,Ra;function ka(e){return Ra||(Ra=getComputedStyle(document.documentElement).getPropertyValue("--font-family")),Ma||(Ma=document.createElement("span"),Ma.style.font=`400 12px ${Ra}`,Ma.style.whiteSpace="nowrap",Ma.style.position="absolute",Ma.style.left="-999px",Ma.style.opacity=".01",document.body.appendChild(Ma)),Ma.textContent=e,Ma.offsetWidth}var Ta=n(55254),Aa=n(44139);function Na(e,t,n,s,o,r){const{setReachedFocusedMessage:c}=(0,a.Sv)();(0,i.bt)((()=>{if(n&&e.current){const t=e.current.closest(".MessageList");c({hasReached:!0}),(0,pa.Z)(t,e.current,o?"end":"centerOrTop",20,void 0!==s?1e3:void 0,s,void 0,r)}}),[e,t,n,s,o,r,c])}var xa=n(3858);const Ba=3*Re.Gw,La=Number(Re.Gw),Ua="data-is-document-group-hover";function ja(e,t,n,o,r,c,d,l,u,m,h,p,g,f){const{setReplyingToId:I,sendDefaultReaction:v}=(0,a.Sv)(),[w,b,y]=(0,Et.Z)(),[P,Z,C]=(0,Et.Z)(),S=(0,i.sO)();return(0,i.d4)((()=>{if(!s.$b||r||!c||h)return;let e;return(0,tn.sf)(t.current,{selectorToPreventScroll:".MessageList",excludedClosestSelector:".no-word-wrap",onSwipe:(t,n)=>n===tn.eM.Left&&(e||(e=Date.now()),Z(),!0),onRelease:()=>{e&&c&&(I({messageId:n}),setTimeout(C,Math.max(0,150-(Date.now()-e))),e=void 0)}})}),[t,r,n,I,Z,C,c,h]),{handleMouseDown:r?void 0:function(e){(0,ma.q)(e),u(e)},handleClick:function(t){if(r)e(t);else if(s.$b)return S.current?(clearInterval(S.current),S.current=void 0,void v({chatId:m,messageId:n})):void(S.current=setTimeout((()=>{S.current=void 0,function(e){if(s.wZ){const t=e.target;if(!t.classList.contains("text-content")&&!t.classList.contains("Message"))return;Be.Z.getIsKeyboardVisible()?setTimeout((()=>{l(e)}),350):l(e)}}(t)}),200))},handleContextMenu:r?d?xa.Z:void 0:function(t){if(s.wZ){if(t.target.matches("a[href]")||h)return;t.preventDefault(),e()}else l(t)},handleDoubleClick:r?void 0:function(){!s.$b&&c&&I({messageId:n})},handleContentDoubleClick:s.$b?void 0:function(e){e.stopPropagation()},handleMouseMove:function(e){const t=p.current;if(!t)return;const{clientX:n,clientY:a}=e,{x:s,width:o,y:i,height:r}=t.getBoundingClientRect(),c=Math.abs(g?n-s:s+o-n)<Ba,d=Math.abs(i+r-a)<La;c&&d?b():y()},handleSendQuickReaction:function(){v({chatId:m,messageId:n})},handleMouseLeave:function(e){y(),f&&function(e){const t=Fa(e.currentTarget);t&&t.removeAttribute(Ua)}(e)},isSwiped:P,isQuickReactionVisible:w,handleDocumentGroupMouseEnter:Oa}}function Oa(e){const t=Fa(e.currentTarget);t&&t.setAttribute(Ua,"")}function Fa(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}var _a=n(3927),Da=n(74095);function qa(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,t);if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let $a;const Ga=new class{constructor(){qa(this,"promise",void 0),qa(this,"reject",void 0),qa(this,"resolve",void 0),this.promise=new Promise(((e,t)=>{this.reject=t,this.resolve=e}))}};setTimeout((function(){$a||($a=(0,Da.K)(new Worker(new URL(n.p+n.u(1275),n.b))),Ga.resolve())}),4e3);var Ha=n(70172),Va=n(18005);const za=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"ContextMenuContainer",!t);return n?i.ZP.createElement(n,e):void 0}));var Wa=n(45601),Xa=n(66735);const Ya=(0,i.X$)((e=>{let{message:t,content:n}=e;const{openMediaViewer:s,uploadProfilePhoto:o,showNotification:c}=(0,a.Sv)(),{isOutgoing:d}=t,l=(0,kt.Z)(),[m,h]=(0,i.eJ)(),[p,g,I]=(0,Et.Z)(!1),v=(0,Wt.Z)((0,u.Ti)(t,"full")),w=t.content.action.photo?.isVideo,b=(0,i.I4)((()=>{c({title:l("ApplyAvatarHintTitle"),message:l("ApplyAvatarHint"),action:{action:"requestNextSettingsScreen",payload:{screen:f.MT.Main}},actionText:l("Open")})}),[l,c]),y=(0,i.I4)((e=>{h(void 0),o({file:e}),b()}),[b,o]),P=(0,i.I4)((()=>{h(void 0)}),[]),Z=(0,i.I4)((async()=>{I(),b();const e=t.content.action.photo,n=await Me.he(`videoAvatar${e.id}?size=u`,r.IU.BlobUrl),a=await fetch(n).then((e=>e.blob()));o({file:new File([a],"avatar.mp4"),isVideo:!0,videoTs:e.videoSizes?.find((e=>void 0!==e.videoStartTs))?.videoStartTs})}),[I,t.content.action,b,o]);return i.ZP.createElement("span",{className:"action-message-suggested-avatar",tabIndex:0,role:"button",onClick:async()=>{!d&&v?w?g():h(await fetch(v).then((e=>e.blob()))):s({chatId:t.chatId,mediaId:t.id,threadId:r._f,origin:f.bZ.SuggestedAvatar})}},i.ZP.createElement(Ha.Z,{photo:t.content.action.photo,showVideoOverwrite:!0,loopIndefinitely:!0,withVideo:w,size:"jumbo"}),i.ZP.createElement("span",null,n),i.ZP.createElement("span",{className:"action-message-button"},l(w?"ViewVideoAction":"ViewPhotoAction")),i.ZP.createElement(Xa.Z,{file:m,onClose:P,onChange:y}),i.ZP.createElement(jn.Z,{isOpen:p,title:l("SuggestedVideo"),confirmHandler:Z,onClose:I,textParts:n}))})),Ja=(0,i.X$)((0,a.c$)(((e,t)=>{let{message:n}=t;const{byId:a}=e.users,s=n.senderId,{targetUserIds:o,targetChatId:i}=n.content.action||{},r=n.replyToMessageId,c=r?(0,d.hj)(e,n.chatId,r):void 0,l=(0,d._X)(e,n),{direction:m,noHighlight:h}=l&&(0,d.jU)(e).focusedMessage||{},p=(0,d.Z1)(e,n.chatId),g=p&&((0,u.eA)(p)||s===n.chatId),f=!g&&s?(0,d.dy)(e,s):void 0,I=g?p:void 0,v=e.premiumGifts?.stickers?.[0];return{usersById:a,senderUser:f,senderChat:I,targetChatId:i,targetUserIds:o,targetMessage:c,isFocused:l,premiumGiftSticker:v,topic:(0,d.p$)(e,n),...l&&{focusDirection:m,noFocusHighlight:h}}}))((e=>{let{message:t,isEmbedded:n,appearanceOrder:s=0,isLastInList:o,usersById:r,senderUser:c,senderChat:d,targetUserIds:l,targetMessage:m,targetChatId:h,isFocused:p,focusDirection:g,noFocusHighlight:f,premiumGiftSticker:I,isInsideTopic:v,topic:w,memoFirstUnreadIdRef:b,observeIntersectionForReading:y,observeIntersectionForLoading:P,observeIntersectionForPlaying:Z}=e;const{openPremiumModal:C,requestConfetti:S}=(0,a.Sv)(),E=(0,kt.Z)(),M=(0,i.sO)(null);(0,wa._N)(M,y),(0,kn.Z)(t.chatId,t.replyToMessageId,m),Na(M,t.chatId,p,g,f);const R=s<=0,[k,T]=(0,Et.Z)(R),A=Boolean(t.content.action?.text.startsWith("ActionGift")),N="suggestProfilePhoto"===t.content.action?.type&&t.content.action.photo;(0,i.d4)((()=>{R||setTimeout(T,10*s)}),[s,T,R]);const x=(0,wa.Op)(M,Z),B=(0,i.sO)((()=>{const e=b?.current&&t.id>=b.current;return A&&!t.isOutgoing&&e})());(0,i.d4)((()=>{x&&B.current&&(B.current=!1,S())}),[x,S]);const{transitionClassNames:L}=(0,pt.Z)(k,void 0,R,!1),U=(0,i.Ye)((()=>l?l.map((e=>r?.[e])).filter(Boolean):void 0),[l,r]),j=(0,Va.D)(E,t,c,d,U,m,h,w,{isEmbedded:n},P,Z),{isContextMenuOpen:O,contextMenuPosition:F,handleBeforeContextMenu:_,handleContextMenu:D,handleContextMenuClose:q,handleContextMenuHide:$}=(0,ta.Z)(M),G=void 0!==F;if(v&&"TopicWasCreatedAction"===t.content.action?.text)return i.ZP.createElement("span",{ref:M});if(n)return i.ZP.createElement("span",{ref:M,className:"embedded-action-message"},j);const H=(0,tt.Z)("ActionMessage message-list-item",p&&!f&&"focused",(A||N)&&"centered-action",G&&"has-menu-open",o&&"last-in-list",!A&&!N&&"in-one-row",L);return i.ZP.createElement("div",{ref:M,id:(0,u.d0)(t.id),className:H,"data-message-id":t.id,onMouseDown:e=>{(0,ma.q)(e),_(e)},onContextMenu:D},!N&&i.ZP.createElement("span",{className:"action-message-content"},j),A&&i.ZP.createElement("span",{className:"action-message-gift",tabIndex:0,role:"button",onClick:()=>{C({isGift:!0,fromUserId:c?.id,toUserId:l?.[0],monthsAmount:t.content.action?.months||0})}},i.ZP.createElement(Wa.Z,{key:t.id,sticker:I,play:!0,noLoop:!0,nonInteractive:!0}),i.ZP.createElement("strong",null,E("ActionGiftPremiumTitle")),i.ZP.createElement("span",null,E("ActionGiftPremiumSubtitle",E("Months",t.content.action?.months,"i"))),i.ZP.createElement("span",{className:"action-message-button"},E("ActionGiftPremiumView"))),N&&i.ZP.createElement(Ya,{message:t,content:j}),F&&i.ZP.createElement(za,{isOpen:O,anchor:F,message:t,messageListType:"thread",onClose:q,onCloseAnimationEnd:$}))}))),Ka=e=>{let{className:t,message:n,sender:a,title:s,customText:o,isProtected:r,noUserColors:c,hasContextMenu:d,observeIntersectionForLoading:l,observeIntersectionForPlaying:m,onClick:h}=e;const p=(0,i.sO)(null),g=(0,wa.Op)(p,l),f=(0,Wt.Z)(n&&(0,u.Ti)(n,"pictogram"),!g),I=(0,Ln.Z)(n),v=Boolean(n&&(0,u.Y5)(n)),w=Boolean(n&&(0,u.NE)(n)),b=(0,kt.Z)(),y=a?(0,u.OU)(b,a):n?.forwardInfo?.hiddenUserName;return i.ZP.createElement("div",{ref:p,className:(0,tt.Z)("EmbeddedMessage",t,a&&!c&&`color-${(0,u.Rs)(a)}`),onClick:n?h:void 0},I&&function(e,t,n,a,s){const{width:o,height:r}=(0,Re.W7)(),c=t||e;return i.ZP.createElement("div",{className:(0,tt.Z)("embedded-thumb",n&&"round")},!s&&i.ZP.createElement("img",{src:c,width:o,height:r,alt:"",className:"pictogram",draggable:!1}),i.ZP.createElement(Dn.Z,{thumbDataUri:c,isVisible:Boolean(s),width:o,height:r}),a&&i.ZP.createElement("span",{className:"protector"}))}(I,f,v,r,w),i.ZP.createElement("div",{className:"message-text"},i.ZP.createElement("p",{dir:"auto"},n?(0,u.FT)(n)?i.ZP.createElement(Ja,{message:n,isEmbedded:!0,observeIntersectionForLoading:l,observeIntersectionForPlaying:m}):i.ZP.createElement(_n.Z,{lang:b,message:n,noEmoji:Boolean(I),observeIntersectionForLoading:l,observeIntersectionForPlaying:m}):o||" "),i.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,Bn.Z)(y||s||" "))),d&&i.ZP.createElement("i",{className:"embedded-more icon-more"}))};var Qa=n(82535),es=n(54752),ts=n(8018),ns=n(34076);const as=(0,i.X$)((e=>{let{message:t,outgoingStatus:n,signature:s,withReactionOffset:o,repliesThreadInfo:r,noReplies:c,isTranslated:d,onClick:l,onTranslationClick:u,onOpenThread:m}=e;const{showNotification:h}=(0,a.Sv)(),p=(0,kt.Z)(),[g,f]=(0,Et.Z)(),I=e=>{e.stopPropagation(),h({message:p("ImportedInfo")})},v=(0,i.Ye)((()=>{if(!g)return;const e=(0,ae.SA)(1e3*t.date,p.code),n=t.isEdited&&(0,ae.SA)(1e3*t.editDate,p.code),a=t.forwardInfo&&(0,ae.SA)(1e3*t.forwardInfo.date,p.code);let s=e;return n&&(s+="\n",s+=p("lng_edited_date").replace("{date}",n)),a&&(s+="\n",s+=p("lng_forwarded_date").replace("{date}",a)),s}),[g,p,t]),w=(0,tt.Z)("MessageMeta",o&&"reactions-offset",t.forwardInfo?.isImported&&"is-imported");return i.ZP.createElement("span",{className:w,dir:p.isRtl?"rtl":"ltr",onClick:l,"data-ignore-on-paste":!0},d&&i.ZP.createElement("i",{className:"icon-language message-translated",onClick:u}),Boolean(t.views)&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("span",{className:"message-views"},(0,bt.bi)(t.views)),i.ZP.createElement("i",{className:"icon-channelviews"})),!c&&Boolean(r?.messagesCount)&&i.ZP.createElement("span",{onClick:function(e){e.stopPropagation(),m()}},i.ZP.createElement("span",{className:"message-replies"},i.ZP.createElement(ns.Z,{text:(0,bt.bi)(r.messagesCount)})),i.ZP.createElement("i",{className:"icon-reply-filled"})),s&&i.ZP.createElement("span",{className:"message-signature"},(0,Bn.Z)(s)),i.ZP.createElement("span",{className:"message-time",title:v,onMouseEnter:f},t.forwardInfo?.isImported&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("span",{className:"message-imported",onClick:I},(0,ae.SA)(1e3*t.forwardInfo.date,p.code,!0)),i.ZP.createElement("span",{className:"message-imported",onClick:I},p("ImportedMessage"))),t.isEdited&&`${p("EditedMessage")} `,(0,ae.mr)(p,1e3*t.date)),n&&i.ZP.createElement(ts.Z,{status:n}))}));var ss=n(36765),os=n(97799);const is=e=>{let{message:t,observeIntersection:n,observeIntersectionForPlaying:o,shouldLoop:c,lastSyncTime:d,shouldPlayEffect:l,onPlayEffect:m,onStopEffect:h}=e;const{showNotification:p,openStickerSet:g}=(0,a.Sv)(),f=(0,kt.Z)(),{isMobile:I}=(0,C.ZP)(),v=(0,i.sO)(null),w=t.content.sticker,{stickerSetInfo:b,isVideo:y,hasEffect:P}=w,Z=w.isPreloadedGlobally?void 0:(0,u.Ti)(t,y&&!s.Hh?"pictogram":"inline"),S=(0,wa.Op)(v,n),E=(0,wa.Op)(v,o),M=`sticker${w.id}?size=f`,R=(0,Wt.Z)(M,!S||!P,r.IU.BlobUrl,d),[k,T,A]=(0,Et.Z)(),N=(0,i.I4)((()=>{A(),h?.()}),[h,A]),x=(0,Mn.Z)(l);(0,i.d4)((()=>{P&&E&&(l||x)&&(T(),m?.())}),[P,E,m,l,x,T]);const B=(0,i.I4)((()=>{g({stickerSetInfo:w.stickerSetInfo})}),[g,w]),L=(0,i.I4)((()=>{if(P)return k?void p({message:f("PremiumStickerTooltip"),action:{action:"openStickerSet",payload:{stickerSetInfo:w.stickerSetInfo}},actionText:f("ViewAction")}):(T(),void m?.());B()}),[P,k,f,m,B,p,T,w.stickerSetInfo]),U="isMissing"in b,{width:j,height:O}=(0,Re.Wr)(w,I),F=(0,tt.Z)("Sticker media-inner",U&&"inactive",P&&!t.isOutgoing&&"reversed");return i.ZP.createElement("div",{ref:v,className:F,style:`width: ${j}px; height: ${O}px;`,onClick:U?void 0:L},i.ZP.createElement(ss.Z,{containerRef:v,sticker:w,fullMediaHash:Z,fullMediaClassName:"full-media",size:j,shouldLoop:c,noLoad:!S,noPlay:!E,withSharedAnimation:!0,cacheBuster:d}),P&&S&&k&&i.ZP.createElement(os.Z,{key:M,className:"effect-sticker",tgsUrl:R,size:1.49*j,play:!0,isLowPriority:!0,noLoop:!0,onEnded:N}))};var rs=n(74753),cs=n(80036);const ds=7*Re.Gw;function ls(e,t,n,s,o,r,c){const{interactWithAnimatedEmoji:d,sendEmojiInteraction:l,sendWatchingEmojiInteraction:u}=(0,a.Sv)(),m=(0,i.sO)(null),h=(0,i.sO)(null),p=(0,Wt.Z)(n?`document${n}`:void 0,!n),g=c||ds,f=(0,cs.Z)(`width: ${g}px`,`height: ${g}px`,r&&"cursor: pointer"),I=(0,i.sO)(void 0),v=(0,i.sO)(void 0),w=(0,i.I4)((()=>{m.current&&(l({chatId:e,messageId:t,emoji:r,interactions:I.current}),v.current=void 0,I.current=void 0)}),[l,e,t,r]),b=(0,i.I4)((()=>{const e=h.current;p&&(e&&(e.pause(),e.remove()),h.current=new Audio,h.current.src=p,(0,rs.Z)(h.current),h.current.addEventListener("ended",(()=>{h.current=void 0}),{once:!0}))}),[p]),y=(0,i.I4)((()=>{b();const n=m.current;if(!(r&&n&&t&&e))return;const{x:a,y:s}=n.getBoundingClientRect();d({emoji:r,x:a,y:s,startSize:g,isReversed:!o}),I.current||(I.current=[],v.current=performance.now(),setTimeout(w,1e3)),I.current.push(v.current?(performance.now()-v.current)/1e3:0)}),[e,r,d,o,t,b,w,g]);return(0,i.d4)((()=>{const n=m.current;n&&s&&s.forEach((a=>{let{id:s,startSize:i,messageId:c}=a;if(i||t!==c)return;const{x:d,y:l}=n.getBoundingClientRect();u({id:s,chatId:e,emoticon:r,startSize:g,x:d,y:l,isReversed:!o}),b()}))}),[s,e,r,o,t,b,u,g]),{ref:m,size:g,style:f,handleClick:y}}const us=(0,i.X$)((0,a.c$)(((e,t)=>{let{emoji:n,withEffects:a}=t;return{sticker:(0,d.zB)(e,n),effect:a?(0,d.tH)(e,n):void 0,soundId:(0,d.Oh)(e,n)}}))((e=>{let{isOwn:t,observeIntersection:n,lastSyncTime:a,forceLoadPreview:s,messageId:o,chatId:r,activeEmojiInteractions:c,sticker:d,effect:l,soundId:u}=e;const{ref:m,size:h,style:p,handleClick:g}=ls(r,o,u,c,t,l?.emoji),f=(0,wa.Op)(m,n);return i.ZP.createElement(Wa.Z,{sticker:d,size:h,quality:1,noLoad:!f,forcePreview:s,lastSyncTime:a,play:f,forceOnHeavyAnimation:!0,ref:m,className:(0,tt.Z)("AnimatedEmoji media-inner",d?.id===Re.wB&&"like-sticker-thumb"),style:p,onClick:g})}))),ms=(0,i.X$)((0,a.c$)(((e,t)=>{let{customEmojiId:n,withEffects:a}=t;const s=e.customEmojis.byId[n];return{sticker:s,effect:s?.emoji&&a?(0,d.tH)(e,s.emoji):void 0,soundId:s?.emoji&&(0,d.Oh)(e,s.emoji)}}))((e=>{let{isOwn:t,customEmojiId:n,messageId:a,chatId:s,activeEmojiInteractions:o,sticker:r,effect:c,soundId:d,observeIntersection:l}=e;const{ref:u,size:m,style:h,handleClick:p}=ls(s,a,d,o,t,c?.emoji,(0,Aa.qo)(1));return i.ZP.createElement(Vt.Z,{ref:u,documentId:n,className:(0,tt.Z)("AnimatedEmoji media-inner",r?.id===Re.wB&&"like-sticker-thumb"),style:h,size:m,isBig:!0,withSharedAnimation:!0,forceOnHeavyAnimation:!0,observeIntersectionForLoading:l,onClick:p})}))),hs={dark:{outgoing:"rgb(135,116,225)",incoming:"rgb(33,33,33)"},light:{outgoing:"rgb(238,255,222)",incoming:"rgb(255,255,255)"}};function ps(e,t,n,a,s){return a?Promise.resolve(hs[s||"light"][t?"outgoing":"incoming"]):async function(e,t){const n=new Image;n.src=e,n.crossOrigin="anonymous",n.width||await new Promise((e=>{n.onload=e}));const a=document.createElement("canvas"),s=a.getContext("2d");a.width=n.width,a.height=n.height,s.drawImage(n,0,0,n.width,n.height);const o=t?n.width-1:0,i=n.height-1;return`rgba(${Array.from(s.getImageData(o,i,1,1).data).join(",")})`}(e,t)}var gs=n(92566),fs=n(15866);function Is(e,t){const{isMobile:n}=(0,C.ZP)();return(0,fs.Z)((0,u.DH)(e),Boolean(t),n&&!s.vX)}var vs=n(70692),ws=n(39196);const bs=e=>{let{id:t,message:n,observeIntersection:a,noAvatars:s,canAutoLoad:r,isInSelectMode:c,isSelected:d,uploadProgress:l,size:m="inline",dimensions:h,asForwarded:p,nonInteractive:g,shouldAffectAppendix:f,isDownloading:I,isProtected:v,theme:w,onClick:b,onCancelUpload:y}=e;const P=(0,i.sO)(null),Z=(0,u.O$)(n)||(0,u.F$)(n),S=Z.blobUrl,E=(0,wa.Op)(P,a),{isMobile:M}=(0,C.ZP)(),[R,k]=(0,i.eJ)(r),T=R&&E,{mediaData:A,loadProgress:N}=(0,gs.Z)((0,u.Ti)(n,m),!T),x=S||A,[B]=(0,i.eJ)(!x),L=Boolean(x),U=Is(n,L),j=(0,vs.Z)(!L),O=(0,u.DH)(n),[F,,_]=(0,Et.Z)(Z.isSpoiler),{loadProgress:D}=(0,gs.Z)((0,u.Ti)(n,"download"),!I,(0,u.kG)(n,"download")),{isUploading:q,isTransferring:$,transferProgress:G}=(0,u.Sc)(n,l||(I?D:N),T&&!x),H=!1===(0,Mn.Z)(R),{shouldRender:V,transitionClassNames:z}=(0,pt.Z)($,void 0,H,"slow"),{shouldRender:W,transitionClassNames:X}=(0,pt.Z)(!x&&!R),Y=(0,i.I4)((()=>{q?y?.(n):x?F?_():b?.(n.id):k((e=>!e))}),[x,_,F,q,n,y,b]),J=(0,u.B4)(n);Ia((e=>{let[t]=e;if(!f)return void(t&&P.current.closest(o.be_).removeAttribute(o.s22));const n=P.current.closest(o.be_);x?ps(x,J,0,d,w).then((e=>{n.style.setProperty("--appendix-bg",e),n.setAttribute(o.s22,"")})):n.classList.add("has-appendix-thumb")}),[f,x,J,c,d,w]);const{width:K,height:Q,isSmall:ee}=h||Pa(n,p,s,M),te=(0,tt.Z)("media-inner",!q&&!g&&"interactive",ee&&"small-image",K===Q&&"square-image"),ne=h?` width: ${K}px; left: ${h.x}px; top: ${h.y}px;`:"",ae="inline"===m?`height: ${Q}px;${ne}`:void 0;return i.ZP.createElement("div",{id:t,ref:P,className:te,style:ae,onClick:q?void 0:Y},i.ZP.createElement("img",{src:x,className:"full-media",alt:"",draggable:!v}),B&&i.ZP.createElement("canvas",{ref:U,className:(0,tt.Z)("thumbnail",j)}),v&&i.ZP.createElement("span",{className:"protector"}),V&&!W&&i.ZP.createElement("div",{className:`media-loading ${z}`},i.ZP.createElement(ws.Z,{progress:G,onClick:q?Y:void 0})),W&&i.ZP.createElement("i",{className:(0,tt.Z)("icon-download",X)}),i.ZP.createElement(Dn.Z,{isVisible:F,withAnimation:!0,thumbDataUri:O,width:K,height:Q,className:"media-spoiler"}),$&&i.ZP.createElement("span",{className:"message-transfer-progress"},Math.round(100*G),"%"))};var ys=n(35148);const Ps=e=>{let{id:t,message:n,observeIntersectionForLoading:s,observeIntersectionForPlaying:o,noAvatars:r,canAutoLoad:c,canAutoPlay:d,uploadProgress:l,lastSyncTime:m,dimensions:h,asForwarded:p,isDownloading:g,isProtected:f,onClick:I,onCancelUpload:v}=e;const w=(0,i.sO)(null),b=(0,i.sO)(null),y=(0,u.b7)(n)||(0,u.Cg)(n),P=y.blobUrl,[Z,,S]=(0,Et.Z)(y.isSpoiler),E=(0,wa.Op)(w,s),M=(0,wa.Op)(w,o)&&E,R=(0,i.sO)(E);M&&!R.current&&(R.current=!0);const{isMobile:k}=(0,C.ZP)(),[T,A]=(0,i.eJ)(c),N=Boolean(T&&E&&m),[x,B]=(0,i.eJ)(d&&!Z),L=(0,u.Ti)(n,"inline"),[U]=(0,i.eJ)(Boolean(L&&Me.UV(L))),{mediaData:j,loadProgress:O}=(0,gs.Z)(L,!N,(0,u.kG)(n,"inline"),m),F=P||j,[_,D]=(0,Et.Z)(),q=(0,u.DH)(n),$=Boolean(q),G=(0,u.Ti)(n,"preview"),[H]=(0,i.eJ)(Boolean(G&&Me.UV(G))),V=E&&m,z=(0,Wt.Z)(G,!V,void 0,m),W=(0,vs.Z)(($||z)&&!_),X=!$||z||_,Y=Is(n,X),J=(0,vs.Z)(!X),K=F&&R.current,{loadProgress:Q}=(0,gs.Z)((0,u.Ti)(n,"download"),!g,(0,u.kG)(n,"download"),m),{isUploading:ee,isTransferring:te,transferProgress:ne}=(0,u.Sc)(n,l||(g?Q:O),N&&!_&&!U||g),se=!1===(0,Mn.Z)(T),{shouldRender:oe,transitionClassNames:ie}=(0,pt.Z)(te,void 0,se),{transitionClassNames:re}=(0,pt.Z)(Boolean((T||F)&&!x&&!oe)),[ce,de]=(0,i.eJ)(0),le=(0,i.I4)((e=>{de(Math.max(0,e.currentTarget.currentTime-1))}),[]),ue=b.current?.duration||y.duration||0,me=(0,u.B4)(n),he=Boolean((0,u.Cg)(n)),{width:pe,height:ge}=h||(0,Re.GC)(y,me,p,he,r,k),fe=(0,i.I4)((()=>{ee?v?.(n):g?(0,a.Sv)().cancelMessageMediaDownload({message:n}):F?(F&&!x&&B(!0),Z?S():I?.(n.id)):A((e=>!e))}),[ee,g,F,x,Z,I,n,v,S]),Ie=(0,tt.Z)("media-inner dark",!ee&&"interactive"),ve=`height: ${ge}px;${h?` width: ${pe}px; left: ${h.x}px; top: ${h.y}px;`:""}`;return i.ZP.createElement("div",{ref:w,id:t,className:Ie,style:ve,onClick:ee?void 0:fe},K&&i.ZP.createElement(ys.Z,{ref:b,src:F,className:"full-media",canPlay:x&&M,muted:!0,loop:!0,playsInline:!0,draggable:!f,onTimeUpdate:le,onReady:D}),i.ZP.createElement("img",{src:z,className:(0,tt.Z)("thumbnail",W),alt:"",draggable:!f}),$&&!H&&i.ZP.createElement("canvas",{ref:Y,className:(0,tt.Z)("thumbnail",J)}),f&&i.ZP.createElement("span",{className:"protector"}),i.ZP.createElement("i",{className:(0,tt.Z)("icon-large-play",re)}),i.ZP.createElement(Dn.Z,{isVisible:Z,withAnimation:!0,thumbDataUri:q,width:pe,height:ge,className:"media-spoiler"}),oe&&i.ZP.createElement("div",{className:(0,tt.Z)("media-loading",ie)},i.ZP.createElement(ws.Z,{progress:ne,onClick:fe})),!T&&!F&&i.ZP.createElement("i",{className:"icon-download"}),te?i.ZP.createElement("span",{className:"message-transfer-progress"},ee||g?`${Math.round(100*ne)}%`:"..."):i.ZP.createElement("div",{className:"message-media-duration"},y.isGif?"GIF":(0,ae.k9)(Math.max(ue-ce,0))))};var Zs=n(6272);const Cs=(0,a.c$)(((e,t)=>{let{contact:n}=t;const{countryList:{phoneCodes:a}}=e;return{user:(0,d.dy)(e,n.userId),phoneCodeList:a,animationLevel:e.settings.byKey.animationLevel}}))((e=>{let{contact:t,user:n,phoneCodeList:s,animationLevel:o}=e;const{openChat:r}=(0,a.Sv)(),{firstName:c,lastName:d,phoneNumber:l,userId:u}=t,m="0"!==u,h=(0,i.I4)((()=>{r({id:u})}),[r,u]);return i.ZP.createElement("div",{className:(0,tt.Z)("Contact",m&&"interactive"),onClick:m?h:void 0},i.ZP.createElement(Ha.Z,{size:"large",user:n,text:c||d,animationLevel:o,withVideo:!0}),i.ZP.createElement("div",{className:"contact-info"},i.ZP.createElement("div",{className:"contact-name"},c," ",d),i.ZP.createElement("div",{className:"contact-phone"},(0,Zs.WZ)(s,l))))}));var Ss=n(20230),Es=n(51218),Ms=n(14434),Rs=n(96937);function ks(e,t){return t>0?(e/t*100).toFixed():0}const Ts=e=>{let{answer:t,voteResults:n,totalVoters:a,maxVotersCount:s,correctResults:o,shouldAnimate:r}=e;const c=n&&n.find((e=>e.option===t.option)),d=0===o.length||-1!==o.indexOf(t.option),l=o.length>0&&d||c?.isChosen,u=c?ks(c.votersCount,a||0):0,[m,h]=(0,i.eJ)(r?0:u),p=(0,i.sO)(null),g=c?ks(c.votersCount,s||0):0,f=m!==u;if((0,i.d4)((()=>{r&&h(u)}),[r,u]),(0,i.d4)((()=>{const e=p.current;if(e&&r){const t=e.firstElementChild,n=f?"":"stroke-dasharray: 100% 200%; stroke-dashoffset: -44";t?t.setAttribute("style",n):e.innerHTML=`\n <svg class="poll-line" xmlns="http://www.w3.org/2000/svg" style="${n}">\n <path d="M4.47 5.33v13.6a9 9 0 009 9h13"/>\n </svg>`}}),[f,r]),!n||!c)return;const I=`width: ${g}%; transform:scaleX(${f?0:1})`;return i.ZP.createElement("div",{className:"PollOption",dir:"ltr"},i.ZP.createElement("div",{className:"poll-option-share "+("100"===u?"limit-width":"")},u,"%",l&&i.ZP.createElement("span",{className:(0,tt.Z)("poll-option-chosen",!d&&"wrong",r&&"animate")},i.ZP.createElement("i",{className:d?"icon-check":"icon-close"}))),i.ZP.createElement("div",{className:"poll-option-right"},i.ZP.createElement("div",{className:"poll-option-text",dir:"auto"},(0,Bn.Z)(t.text)),i.ZP.createElement("div",{className:(0,tt.Z)("poll-option-answer",l&&!d&&"wrong")},i.ZP.createElement("div",{className:"poll-option-corner",ref:p}),i.ZP.createElement("div",{className:"poll-option-line",style:I}))))};function As(e){e.stopPropagation()}const Ns=(0,i.X$)((0,a.c$)(((e,t)=>{let{poll:n}=t;const{recentVoterIds:a}=n.results,{users:{byId:s}}=e;return a&&0!==a.length?{recentVoterIds:a,usersById:s}:{}}))((e=>{let{message:t,poll:n,recentVoterIds:s,usersById:o,onSendVote:r}=e;const{loadMessage:c,openPollResults:d,requestConfetti:l}=(0,a.Sv)(),{id:u,chatId:m}=t,{summary:h,results:p}=n,[g,f]=(0,i.eJ)(!1),[I,w]=(0,i.eJ)([]),[b,y]=(0,i.eJ)(!1),[P,Z]=(0,i.eJ)(!1),[C,S]=(0,i.eJ)(!h.closed&&h.closeDate&&h.closeDate>0?Math.min(h.closeDate-Math.floor(Date.now()/1e3)+(0,v.Qj)(),h.closePeriod):0),E=(0,i.sO)(null),{results:M,totalVoters:R}=p,k=M&&M.some((e=>e.isChosen)),T=!h.closed&&!k,A=!T&&h.isPublic&&Number(p.totalVoters)>0,N=T&&h.multipleChoice,x=M?Math.max(...M.map((e=>e.votersCount))):R,B=M?M.reduce(((e,t)=>(t.isCorrect&&e.push(t.option),e)),[]):[],L=h.answers.map((e=>({label:e.text,value:e.option,hidden:Boolean(h.quiz&&h.closePeriod&&C<=0)})));(0,i.d4)((()=>{const e=n.results.results?.find((e=>e.isChosen));g&&e&&(e.isCorrect&&l(),f(!1))}),[g,n.results.results,l]),(0,i.d4)((()=>{C>0&&setTimeout((()=>S(C-1)),1e3);const e=E.current;if(e){const t=12*Math.PI,n=e.lastElementChild,a=e.firstElementChild;if(C<=5&&e.classList.add("hurry-up"),n&&a){const e=(h.closePeriod-C)/h.closePeriod*t;a.textContent=(0,ae.k9)(C),n.firstElementChild.setAttribute("stroke-dashoffset",`-${e}`)}else e.innerHTML=`\n <span>${(0,ae.k9)(C)}</span>\n <svg width="16px" height="16px">\n <circle cx="8" cy="8" r="6" class="poll-countdown-progress" transform="rotate(-90, 8, 8)"\n stroke-dasharray="${t} ${t}"\n stroke-dashoffset="0"\n />\n </svg>`}}),[C,h.closePeriod]),(0,i.d4)((()=>{h.quiz&&(C<=0||k&&!h.closed)&&c({chatId:m,messageId:u})}),[m,C,k,c,u,h.closed,h.quiz]),(0,i.d4)((()=>{let e;return h.quiz&&!h.closed&&h.closePeriod&&h.closePeriod>0&&(e=window.setTimeout((()=>{c({chatId:m,messageId:u})}),1e3*h.closePeriod)),()=>{e&&window.clearTimeout(e)}}),[T,m,c,u,h.closePeriod,h.closed,h.quiz]);const U=(0,i.Ye)((()=>s?s.reduce(((e,t)=>{const n=o[t];return n&&e.push(n),e}),[]):[]),[o,s]),j=(0,i.I4)((e=>{w([e]),f(!0),Z(!0),r([e])}),[r]),O=(0,i.I4)((e=>{w(e)}),[]),F=(0,i.I4)((()=>{f(!0),Z(!0),r(I)}),[r,I]),_=(0,i.I4)((()=>{d({chatId:m,messageId:u})}),[m,u,d]),D=(0,i.I4)((()=>{y(!0)}),[]),q=(0,i.I4)((()=>{y(!1),Z(!1)}),[]);(0,i.d4)((()=>{P&&k&&h.quiz&&p.results&&n.results.solution&&(p.results.find((e=>e.isChosen&&e.isCorrect))||y(!0))}),[k,P,p.results,h.quiz,n.results.solution]);const $=(0,kt.Z)();return i.ZP.createElement("div",{className:"Poll",dir:$.isRtl?"auto":"ltr"},b&&n.results.solution&&i.ZP.createElement(Rs.Z,{message:(0,Ss.H)(n.results.solution,n.results.solutionEntities),duration:5e3,onDismiss:q,containerId:"#middle-column-portals"}),i.ZP.createElement("div",{className:"poll-question"},(0,Bn.Z)(h.question,["emoji","br"])),i.ZP.createElement("div",{className:"poll-type"},$(function(e){return void 0===e.isPublic?" ":e.closed?"FinalResults":e.quiz?e.isPublic?"QuizPoll":"AnonymousQuizPoll":e.isPublic?"PublicPoll":"AnonymousPoll"}(h)),U.length>0&&i.ZP.createElement("div",{className:"poll-recent-voters"},U.map((e=>i.ZP.createElement(Ha.Z,{size:"micro",user:e})))),C>0&&T&&i.ZP.createElement("div",{ref:E,className:"poll-countdown"}),h.quiz&&n.results.solution&&!T&&i.ZP.createElement(Ft.Z,{round:!0,size:"tiny",color:"translucent",className:"poll-quiz-help",disabled:b,onClick:D,ariaLabel:"Show Solution"},i.ZP.createElement("i",{className:"icon-lamp"}))),T&&i.ZP.createElement("div",{className:"poll-answers",onClick:As},N?i.ZP.createElement(Es.Z,{options:L,onChange:O,disabled:t.isScheduled||g,loadingOptions:g?I:void 0,round:!0}):i.ZP.createElement(Ms.Z,{name:`poll-${u}`,options:L,onChange:j,disabled:t.isScheduled||g,loadingOption:g?I[0]:void 0})),!T&&i.ZP.createElement("div",{className:"poll-results"},h.answers.map((function(e){return i.ZP.createElement(Ts,{key:e.option,shouldAnimate:P||!T,answer:e,voteResults:M,totalVoters:R,maxVotersCount:x,correctResults:B})}))),!A&&!N&&i.ZP.createElement("div",{className:"poll-voters-count"},function(e,t,n){return n?e(t?"Answer":"Vote",n,"i"):e(t?"Chat.Quiz.TotalVotesEmpty":"Chat.Poll.TotalVotesResultEmpty")}($,h.quiz,p.totalVoters)),N&&i.ZP.createElement(Ft.Z,{isText:!0,disabled:0===I.length,size:"tiny",onClick:F},$("PollSubmitVotes")),A&&i.ZP.createElement(Ft.Z,{isText:!0,size:"tiny",onClick:_},$("PollViewResults")))})));var xs=n(48035),Bs=n(10088);const Ls=(0,i.X$)((e=>{let{message:t,observeIntersection:n,noAvatars:a,canAutoLoad:s,canAutoPlay:o,inPreview:r,asForwarded:c,lastSyncTime:d,isDownloading:l=!1,isProtected:m,theme:h,onMediaClick:p,onCancelMediaTransfer:g}=e;const f=(0,u.s1)(t),{isMobile:I}=(0,C.ZP)(),v=(0,i.I4)((()=>{p()}),[p]);if(!f)return;const{siteName:w,url:b,displayUrl:y,title:P,description:Z,photo:S,video:E}=f,M=(0,xs.Z)(Z,170),R=Boolean(M||P||w);let k=!1;if(R&&f?.photo&&!f.video){const{width:e,height:n}=Pa(t,void 0,void 0,I);k=e===n}const T=(S||E)&&p&&!k,A=(0,tt.Z)("WebPage",r&&"in-preview",k&&"with-square-photo",!S&&!E&&!r&&"without-media",E&&"with-video",!R&&"no-article");return i.ZP.createElement("div",{className:A,"data-initial":(w||y)[0],dir:"auto"},S&&!E&&i.ZP.createElement(bs,{message:t,observeIntersection:n,noAvatars:a,canAutoLoad:s,size:k?"pictogram":"inline",asForwarded:c,nonInteractive:!T,isDownloading:l,isProtected:m,theme:h,onClick:T?v:void 0,onCancelUpload:g}),R&&i.ZP.createElement("div",{className:"WebPage-text"},i.ZP.createElement(Bs.Z,{className:"site-name",url:b,text:w||y}),!r&&P&&i.ZP.createElement("p",{className:"site-title"},(0,Bn.Z)(P)),M&&i.ZP.createElement("p",{className:"site-description"},(0,Bn.Z)(M,["emoji","br"]))),!r&&E&&i.ZP.createElement(Ps,{message:t,observeIntersectionForLoading:n,noAvatars:a,canAutoLoad:s,canAutoPlay:o,lastSyncTime:d,asForwarded:c,isDownloading:l,isProtected:m,onClick:T?v:void 0,onCancelUpload:g}))}));var Us=n(17921);const js=(0,i.X$)((e=>{let{message:t,shouldAffectAppendix:n,isInSelectMode:a,isSelected:s,theme:r}=e;const c=(0,i.sO)(null),d=(0,kt.Z)(),l=(0,u.eO)(t),{title:m,text:h,amount:p,currency:g,isTest:f,photo:I}=l,v=(0,Wt.Z)((0,u.O9)(I));return Ia((e=>{let[t]=e;if(n){if(v){const e=c.current.closest(o.be_);ps(v,!1,0,s,r).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute(o.s22,"")}))}}else t&&c.current.closest(o.be_).removeAttribute(o.s22)}),[n,v,a,s,r]),i.ZP.createElement("div",{ref:c,className:"Invoice"},m&&i.ZP.createElement("p",{className:"title"},(0,Bn.Z)(m)),h&&i.ZP.createElement("div",null,(0,Bn.Z)(h,["emoji","br"])),i.ZP.createElement("div",{className:"description "+(I?"has-image":"")},v&&i.ZP.createElement("img",{className:"invoice-image",src:v,alt:"",crossOrigin:"anonymous"}),!v&&I&&i.ZP.createElement(Us.Z,{width:I.dimensions?.width,height:I.dimensions?.height,forceAspectRatio:!0}),i.ZP.createElement("p",{className:"description-text"},(0,et.x)(p,g,d.code),f&&i.ZP.createElement("span",null,d("PaymentTestInvoice")))))})),Os={root:"rwnm0xOh31c2MY4kK2No",duration:"lKSp02aI8WDGX3393nkh",buy:"gxQfWp0jp0_2Z4qWiXKN",spoiler:"z2tB5Vd_jKJ9IYX4Nijd"},Fs=(0,i.X$)((e=>{let{message:t,lastSyncTime:n}=e;const{openInvoice:s,loadExtendedMedia:o}=(0,a.Sv)(),r=(0,kt.Z)(),c=(0,u.eO)(t),{chatId:d,id:l}=t,m=(0,i.I4)((()=>{o({chatId:d,ids:[l]})}),[d,l,o]);(0,ft.Z)(m,n?3e4:void 0);const{amount:h,currency:p,extendedMedia:g}=c,{width:f,height:I,thumbnail:v,duration:w}=g,b=(0,i.I4)((()=>{s({chatId:d,messageId:l,isExtendedMedia:!0})}),[d,l,s]);return i.ZP.createElement("div",{className:(0,tt.Z)(Os.root,"media-inner"),onClick:b},i.ZP.createElement(Dn.Z,{thumbDataUri:v?.dataUri,width:f,height:I,isVisible:!0,className:Os.spoiler}),Boolean(w)&&i.ZP.createElement("div",{className:Os.duration},(0,ae.k9)(w)),i.ZP.createElement("div",{className:Os.buy},i.ZP.createElement("i",{className:(0,tt.Z)("icon-lock",Os.lock)}),r("Checkout.PayPrice",(0,et.x)(h,p))))})),_s=new Map(Object.entries({"building/medical":"#43b3f4","building/gym":"#43b3f4","education/cafeteria":"#f7943f","travel/bedandbreakfast":"#9987ff","travel/hotel":"#9987ff","travel/hostel":"#9987ff","travel/resort":"#9987ff","travel/hotel_bar":"#e56dd6",arts_entertainment:"#e56dd6",building:"#6e81b2",education:"#a57348",event:"#959595",food:"#f7943f",home:"#00aeef",nightlife:"#e56dd6",parks_outdoors:"#6cc039",shops:"#ffb300",travel:"#1c9fff",work:"#ad7854"})),Ds=["#e56cd5","#f89440","#9986ff","#44b3f5","#6dc139","#ff5d5a","#f87aad","#6e82b3","#f5ba21"],qs=n.p+"map-pin.7b3c3e60ee24795e4bd2.svg",$s=1e-4,Gs={width:400,height:300,zoom:16,scale:2},Hs={__html:'<svg version="1.1" class="round-pin" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 64 64" style="enable-background:new 0 0 64 64;" xml:space="preserve"><g><circle cx="32" cy="32" r="24.5"/><path d="M32,8c13.23,0,24,10.77,24,24S45.23,56,32,56S8,45.23,8,32S18.77,8,32,8 M32,7C18.19,7,7,18.19,7,32s11.19,25,25,25 s25-11.19,25-25S45.81,7,32,7L32,7z"/></g><g><polygon points="29.38,57.67 27.4,56.08 30.42,54.42 32,51.54 33.58,54.42 36.6,56.08 34.69,57.61 32,60.73"/><path d="M32,52.58l1.07,1.95l0.14,0.26l0.26,0.14l2.24,1.22l-1.33,1.06l-0.07,0.06l-0.06,0.07L32,59.96l-2.24-2.61l-0.06-0.07 l-0.07-0.06l-1.33-1.06l2.24-1.22l0.26-0.14l0.14-0.26L32,52.58 M32,50.5l-1.94,3.56L26.5,56l2.5,2l3,3.5l3-3.5l2.5-2l-3.56-1.94 L32,50.5L32,50.5z"/></g></svg>'},Vs=(0,i.X$)((e=>{let{message:t,peer:n,lastSyncTime:s,isInSelectMode:r,isSelected:c,theme:d}=e;const{openUrl:l}=(0,a.Sv)(),m=(0,i.sO)(null),h=(0,i.sO)(null),p=(0,kt.Z)(),g=(0,ht.Z)(),f=(0,u.nf)(t),{type:I,geo:w}=f,b=(0,v.bp)(),y=(0,u.$R)(t,b),P="geoLive"!==I||y?void 0:t.date+f.period-b,[Z,C]=(0,i.eJ)(w),S="venue"===I||"geoLive"===I&&!y,{width:E,height:M,zoom:R,scale:k}=Gs,T=Boolean(s)&&(0,u.k6)(Z,E,M,R,k),A=(0,Wt.Z)(T),N=(0,Mn.Z)(A),x=A||N,B=n&&(0,u.YC)(n.id),L=n&&B?n:void 0,U=n&&!B?n:void 0,j=(0,u.B4)(t),O=(0,i.Ye)((()=>{if("geoLive"!==I||!Z.accuracyRadius)return 0;const{lat:e,accuracyRadius:t}=Z;return t/function(e,t){return 156543.03392*Math.cos(e*(Math.PI/180))/2**t}(e,R)}),[I,Z,R]),F=(0,i.I4)((e=>{if("geoLive"!==I)return;const n=24*Math.PI,a=e.lastElementChild,s=e.firstElementChild,o=t.date+f.period-(0,v.bp)(),i=(1-o/f.period)*n,r=(0,ae.mB)(p,1e3*o);a&&s?(s.textContent=r,a.firstElementChild.setAttribute("stroke-dashoffset",`-${i}`)):e.innerHTML=`\n <span class="geo-countdown-text">${r}</span>\n <svg width="32px" height="32px">\n <circle cx="16" cy="16" r="12" class="geo-countdown-progress" transform="rotate(-90, 16, 16)"\n stroke-dasharray="${n} ${n}"\n stroke-dashoffset="-${i}"\n />\n </svg>`}),[I,t.date,f,p]);return(0,i.bt)((()=>{h.current&&F(h.current)}),[F]),Ia((e=>{let[t]=e;if(S)t||m.current.closest(o.be_).removeAttribute(o.s22);else if(x){const e=m.current.closest(o.be_);ps(x,j,0,c,d).then((t=>{e.style.setProperty("--appendix-bg",t),e.classList.add("has-appendix-thumb"),e.setAttribute(o.s22,"")}))}}),[S,j,r,c,d,x]),(0,i.d4)((()=>{Math.abs(w.lat-Z.lat)<$s&&Math.abs(w.long-Z.long)<$s?Z.accuracyRadius!==w.accuracyRadius&&C({...Z,accuracyRadius:w.accuracyRadius}):C(w)}),[w,Z]),(0,It.Z)((()=>{g()}),y?void 0:1e3*(P||0)),(0,ft.Z)((()=>{const e=h.current;e&&F(e)}),P?1e3:void 0),i.ZP.createElement("div",{ref:m,className:"Location media-inner interactive",onClick:()=>{const e=function(e,t,n){return`https://maps.google.com/maps/place/${e}+${t}/@${e},${t},${n}z`}(Z.lat,Z.long,R);l({url:e})}},i.ZP.createElement("div",{className:"map-wrapper"},x?i.ZP.createElement("img",{className:"full-media map",src:x,alt:"Location on a map",style:`width: ${Gs.width}px; height: ${Gs.height}px;`}):i.ZP.createElement(Us.Z,{width:E,height:M}),function(){if(x)return i.ZP.createElement(i.ZP.Fragment,null,Boolean(O)&&!y&&i.ZP.createElement("div",{className:"location-accuracy",style:`width: ${2*O}px; height: ${2*O}px`}),function(){const e=(0,tt.Z)("pin",I,y&&"expired");if("geoLive"===I)return i.ZP.createElement("div",{className:e,dangerouslySetInnerHTML:Hs},i.ZP.createElement(Ha.Z,{chat:U,user:L,className:"location-avatar"}),void 0!==f.heading&&i.ZP.createElement("div",{className:"direction",style:`--direction: ${f.heading}deg`}));if("venue"===I){const t=function(e){return e?_s.get(e)||_s.get(e.split("/")[0])||Ds[(t=e,t.split("").reduce(((e,t)=>(e<<5)-e+t.charCodeAt(0)|0),0)%Ds.length)]:"#008df2";var t}(f.venueType),n=function(e){return e?`https://ss3.4sqi.net/img/categories_v2/${e}_88.png`:""}(f.venueType);return i.ZP.createElement("div",{className:e,dangerouslySetInnerHTML:Hs,style:`--pin-color: ${t}`},i.ZP.createElement("img",{src:n,className:"venue-icon",alt:""}))}return i.ZP.createElement("img",{className:e,src:qs,alt:""})}())}()),function(){if(S)return"venue"===I?i.ZP.createElement("div",{className:"location-info"},i.ZP.createElement("div",{className:"location-info-title"},f.title),i.ZP.createElement("div",{className:"location-info-subtitle"},f.address)):"geoLive"===I?i.ZP.createElement("div",{className:"location-info"},i.ZP.createElement("div",{className:"location-info-title"},p("AttachLiveLocation")),i.ZP.createElement("div",{className:"location-info-subtitle"},(0,ae.dJ)(p,b,t.editDate)),!y&&i.ZP.createElement("div",{className:"geo-countdown",ref:h})):void 0}())})),zs=(0,i.X$)((e=>{let{message:t,canAutoLoadMedia:n,lastSyncTime:s}=e;const{clickBotInlineButton:o}=(0,a.Sv)(),r=t.content.game,{title:c,description:d}=r,l=Boolean(s)&&(0,u.N)(r),m=Boolean(s)&&(0,u.Wc)(r),h=(0,Wt.Z)(l,!n),p=(0,Wt.Z)(m,!n);return i.ZP.createElement("div",{className:"Game"},i.ZP.createElement("div",{className:"preview",style:"width: 480px; height: 270px",onClick:()=>{o({messageId:t.id,button:t.inlineButtons[0][0]})}},!h&&!p&&i.ZP.createElement(Us.Z,{className:"skeleton preview-content"}),h&&i.ZP.createElement("img",{className:"preview-content",src:h,alt:c}),p&&i.ZP.createElement("video",{className:"preview-content",playsInline:!0,muted:!0,disablePictureInPicture:!0,autoPlay:!0,loop:!0,src:p})),i.ZP.createElement("div",{className:"title"},c),!(0,u.UD)(t)&&i.ZP.createElement("div",{className:"description"},d))}));function Ws(e){return(0,i.X$)((0,a.c$)(((e,t)=>{const{message:n}=t;return{isInSelectMode:(0,d.CA)(e),isSelected:(0,d.vk)(e,n.id)}}))((t=>{const{isInSelectMode:n,isSelected:s,message:o,dimensions:r}=t,{toggleMessageSelection:c}=(0,a.Sv)(),d=(0,i.I4)((e=>{e.stopPropagation(),c({messageId:o.id,withShift:e?.shiftKey})}),[c,o]),l=(0,i.Ye)((()=>{const{dimensions:e,onClick:a}=t;return{...t,isInSelectMode:n,isSelected:s,dimensions:{...e,x:0,y:0},onClick:n?void 0:a}}),[t,n,s]);return i.ZP.createElement("div",{className:(0,tt.Z)("album-item-select-wrapper",s&&"is-selected"),style:r?`left: ${r.x}px; top: ${r.y}px;`:"",onClick:n?d:void 0},n&&i.ZP.createElement("div",{className:"message-select-control"},s&&i.ZP.createElement("i",{className:"icon-select"})),i.ZP.createElement(e,l))})))}const Xs=Ws(bs),Ys=Ws(Ps),Js=(0,a.c$)(((e,t)=>{let{album:n}=t;const{chatId:a}=n.mainMessage,s=(0,d.Pu)(e),o=(0,d.xs)(e,a);return{theme:s,uploadsById:e.fileUploads.byMessageLocalId,activeDownloadIds:o}}))((e=>{let{album:t,observeIntersection:n,hasCustomAppendix:s,lastSyncTime:o,isOwn:r,isProtected:c,albumLayout:l,onMediaClick:m,uploadsById:h,activeDownloadIds:p,theme:g}=e;const{cancelSendingMessage:f}=(0,a.Sv)(),I=t.messages.length,v=(0,i.I4)((e=>{f({chatId:e.chatId,messageId:e.id})}),[f]),{width:w,height:b}=l.containerStyle;return i.ZP.createElement("div",{className:"Album",style:`width: ${w}px; height: ${b}px;`},t.messages.map((function(e,t){const{photo:f,video:w}=(0,u.qp)(e),b=h[(0,u.KK)(e)]?.progress,{dimensions:y,sides:P}=l.layout[t],Z=(0,d.bH)((0,a.Rd)(),e),C=(0,d.__)((0,a.Rd)(),e);if(f){const a=s&&(r?t===I-1:Boolean(8&P&&4&P));return i.ZP.createElement(Xs,{id:`album-media-${(0,u.d0)(e.id)}`,message:e,observeIntersectionForLoading:n,canAutoLoad:Z,shouldAffectAppendix:a,uploadProgress:b,dimensions:y,isProtected:c,onClick:m,onCancelUpload:v,isDownloading:p.includes(e.id),theme:g})}if(w)return i.ZP.createElement(Ys,{id:`album-media-${(0,u.d0)(e.id)}`,message:e,observeIntersectionForLoading:n,canAutoLoad:Z,canAutoPlay:C,uploadProgress:b,lastSyncTime:o,dimensions:y,isProtected:c,onClick:m,onCancelUpload:v,isDownloading:p.includes(e.id),theme:g})})))}));let Ks;const Qs=e=>{let{message:t,observeIntersection:n,canAutoLoad:s,lastSyncTime:o,isDownloading:c}=e;const d=(0,i.sO)(null),l=(0,i.sO)(null),m=(0,i.sO)(null),h=t.content.video,p=(0,wa.Op)(d,n),[g,f]=(0,i.eJ)(s),I=Boolean(g&&p&&o),{mediaData:v,loadProgress:w}=(0,gs.Z)((0,u.Ti)(t,"inline"),!I,(0,u.kG)(t,"inline"),o),{loadProgress:b}=(0,gs.Z)((0,u.Ti)(t,"download"),!c,r.IU.BlobUrl,o),[y,P]=(0,Et.Z)(),Z=!Boolean((0,u.DH)(t))||y,C=Is(t,Z),S=(0,vs.Z)(!Z),E=g&&!y||c,M=!1===(0,Mn.Z)(g),{shouldRender:R,transitionClassNames:k}=(0,pt.Z)(E,void 0,M),[T,A]=(0,i.eJ)(!1),[x,B]=(0,i.eJ)(0);(0,i.d4)((()=>{if(!T)return;const e=Re.Rj/2,t=2*(e-6)*Math.PI,n=t-x*t,a=m.current,s=l.current,o=s.firstElementChild;o?o.firstElementChild.setAttribute("stroke-dashoffset",n.toString()):s.innerHTML=`\n <svg width="${Re.Rj}px" height="${Re.Rj}px">\n <circle cx="${e}" cy="${e}" r="${e-6}" class="progress-circle"\n transform="rotate(-90, ${e}, ${e})"\n stroke-dasharray="${t} ${t}"\n stroke-dashoffset="${t}"\n />\n </svg>`,B(a.currentTime/a.duration)}),[T,x]);const L=Boolean(v&&p),U=(0,i.I4)((()=>{m.current&&(A(!1),B(0),(0,rs.Z)(m.current),(0,N.T2)((()=>{l.current.innerHTML=""})))}),[]),j=(0,i.I4)((()=>{Ks?.(),Ks=U}),[U]),O=(0,i.I4)((()=>{if(!v)return void f((e=>!e));if(c)return void(0,a.Sv)().cancelMessageMediaDownload({message:t});const e=m.current;T?e.paused?((0,rs.Z)(e),(0,$n.Es)()):e.pause():(j(),e.pause(),e.currentTime=0,(0,rs.Z)(e),(0,$n.Es)(),A(!0))}),[j,T,c,v,t]),F=(0,i.I4)((e=>{const t=e.currentTarget;B(t.currentTime/t.duration)}),[]);return i.ZP.createElement("div",{ref:d,className:"RoundVideo media-inner",onClick:O},v&&i.ZP.createElement("div",{className:"video-wrapper"},i.ZP.createElement(ys.Z,{canPlay:L,ref:m,src:v,className:"full-media",width:Re.Rj,height:Re.Rj,autoPlay:!0,disablePictureInPicture:!0,muted:!T,loop:!T,playsInline:!0,onEnded:T?U:void 0,onTimeUpdate:T?F:void 0,onReady:P})),i.ZP.createElement("canvas",{ref:C,className:(0,tt.Z)("thumbnail",S),style:`width: ${Re.Rj}px; height: ${Re.Rj}px`}),i.ZP.createElement("div",{className:"progress",ref:l}),R&&i.ZP.createElement("div",{className:`media-loading ${k}`},i.ZP.createElement(ws.Z,{progress:c?b:w})),!v&&!g&&i.ZP.createElement("i",{className:"icon-download"}),i.ZP.createElement("div",{className:"message-media-duration"},T?(0,ae.k9)(m.current.currentTime):(0,ae.k9)(h.duration),(!T||m.current.paused)&&i.ZP.createElement("i",{className:"icon-muted"})))},eo=e=>{let{message:t,onClick:n}=e;const a=(0,kt.Z)();return i.ZP.createElement("div",{className:"InlineButtons"},t.inlineButtons.map((e=>i.ZP.createElement("div",{className:"row"},e.map((e=>i.ZP.createElement(Ft.Z,{size:"tiny",ripple:!0,disabled:"unsupported"===e.type,onClick:()=>n({messageId:t.id,button:e})},i.ZP.createElement("span",{className:"inline-button-text"},(0,Bn.Z)(a(e.text))),(e=>{const{type:t}=e;switch(t){case"url":if(!o.FSu.test(e.url))return i.ZP.createElement("i",{className:"icon-arrow-right"});break;case"urlAuth":return i.ZP.createElement("i",{className:"icon-arrow-right"});case"buy":case"receipt":return i.ZP.createElement("i",{className:"icon-cart"});case"switchBotInline":return i.ZP.createElement("i",{className:"icon-share-filled"});case"webView":case"simpleWebView":return i.ZP.createElement("i",{className:"icon-webapp"})}})(e))))))))},to=(0,i.X$)((e=>{let{threadInfo:t,disabled:n}=e;const{openComments:s}=(0,a.Sv)(),o=(0,kt.Z)(),{threadId:r,chatId:c,messagesCount:d,lastMessageId:l,lastReadInboxMessageId:m,recentReplierIds:h,originChannelId:p}=t,g=(0,i.I4)((()=>{s({id:c,threadId:r,originChannelId:p})}),[s,c,r,p]),f=(0,i.Ye)((()=>{if(!h?.length)return;const{users:{byId:e},chats:{byId:t}}=(0,a.Rd)();return h.map((n=>(0,u.YC)(n)?e[n]:t[n])).filter(Boolean)}),[h]);if(void 0===d)return;const I=Boolean(m&&l&&m<l),v=d?o("Comments","%COMMENTS_COUNT%",void 0,d).split("%").map((e=>"COMMENTS_COUNT"===e?i.ZP.createElement(ns.Z,{text:(0,bt.bi)(d)}):e)):void 0;return i.ZP.createElement("div",{"data-cnt":(0,bt.bi)(d),className:(0,tt.Z)("CommentButton",I&&"has-unread",n&&"disabled"),dir:o.isRtl?"rtl":"ltr",onClick:g},i.ZP.createElement("i",{className:"icon-comments-sticker"}),(!f||0===f.length)&&i.ZP.createElement("i",{className:"icon-comments"}),f&&f.length>0&&i.ZP.createElement("div",{className:"recent-repliers",dir:o.isRtl?"rtl":"ltr"},f.map((e=>i.ZP.createElement(Ha.Z,{key:e.id,size:"small",user:(0,u.YC)(e.id)?e:void 0,chat:(0,u.YC)(e.id)?void 0:e})))),i.ZP.createElement("div",{className:"label",dir:"auto"},d?v:o("LeaveAComment")),i.ZP.createElement("i",{className:"icon-next"}))}));var no=n(78046),ao=n(48198);const so={root:"JY0NZH9bysPBqR3sIbLu","is-custom-emoji":"T1R9OVCwcfQHR4vN8cx_",isCustomEmoji:"T1R9OVCwcfQHR4vN8cx_","animated-icon":"WTrBqa2uxq57nYJAIelk",animatedIcon:"WTrBqa2uxq57nYJAIelk",effect:"z9v8vlAIGxI3ITxuyEG1",animating:"sB0FGOzwkiDvNWHWcVEL"},oo=2.5*Re.Gw,io=6.5*Re.Gw,ro=(0,i.X$)((e=>{let{reaction:t,genericEffects:n,activeReactions:s,availableReactions:o,observeIntersection:r}=e;const{stopActiveReaction:c}=(0,a.Sv)(),d=(0,i.sO)(null),l="documentId"in t,m=(0,i.Ye)((()=>o?.find((e=>(0,u.Hl)(e.reaction,t)))),[o,t]),h=m?.centerIcon?.id,p=(0,no.Z)(l?t.documentId:void 0),g=(0,i.Ye)((()=>{if(!l)return m?.aroundAnimation?.id;if(!p)return;const e=o?.find((e=>e.reaction.emoticon===p.emoji))?.aroundAnimation?.id;return e}),[m,o,p,l]),f=(0,i.Ye)((()=>{if(g)return g;if(!n?.stickers)return;const{stickers:e}=n;return e[Math.floor(Math.random()*e.length)].id}),[g,n]),I=(0,wa.Op)(d,r),v=h&&`sticker${h}`,w=f&&`sticker${f}`,b=(0,Wt.Z)(v,!h),y=(0,Wt.Z)(w,!f),P=(0,i.Ye)((()=>s?.find((e=>(0,u.Hl)(e.reaction,t)))),[s,t]),Z=Boolean(P&&(l||b)&&y),{shouldRender:C,transitionClassNames:S}=(0,pt.Z)(Z,void 0,!0,"slow"),E=(0,i.I4)((()=>{P?.messageId&&c({messageId:P.messageId,reaction:t})}),[P?.messageId,t,c]),[M,R,k]=(0,Et.Z)(),T=!(l||Z&&M),A=(0,tt.Z)(so.root,C&&so.animating,l&&so.isCustomEmoji);return i.ZP.createElement("div",{className:A,ref:d},T&&i.ZP.createElement(ao.Z,{reaction:t,availableReactions:o}),l&&i.ZP.createElement(Vt.Z,{documentId:t.documentId,className:so.customEmoji,observeIntersectionForPlaying:r}),C&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(os.Z,{key:f,className:(0,tt.Z)(so.effect,S),size:io,tgsUrl:y,play:I,noLoop:!0,forceOnHeavyAnimation:!0,onEnded:E}),l?!g&&I&&i.ZP.createElement(Yt,{reaction:t}):i.ZP.createElement(os.Z,{key:h,className:(0,tt.Z)(so.animatedIcon,S),size:oo,tgsUrl:b,play:I,noLoop:!0,forceOnHeavyAnimation:!0,onLoad:R,onEnded:k})))})),co=(0,i.X$)((e=>{let{reaction:t,message:n,activeReactions:s,availableReactions:o,withRecentReactors:r,genericEffects:c,observeIntersection:d}=e;const{toggleReaction:l}=(0,a.Sv)(),{recentReactions:m}=n.reactions,h=(0,i.Ye)((()=>{if(!r||!m)return;const e=(0,a.Rd)().users.byId;return m.filter((e=>(0,u.Hl)(e.reaction,t.reaction))).map((t=>e[t.userId])).filter(Boolean)}),[t.reaction,m,r]),p=(0,i.I4)((()=>{l({reaction:t.reaction,chatId:n.chatId,messageId:n.id})}),[n,t,l]);return i.ZP.createElement(Ft.Z,{className:(0,tt.Z)((0,u.Bt)(t)&&"chosen"),size:"tiny",onClick:p},i.ZP.createElement(ro,{activeReactions:s,reaction:t.reaction,availableReactions:o,genericEffects:c,observeIntersection:d}),h?.length?i.ZP.createElement("div",{className:"avatars"},h.map((e=>i.ZP.createElement(Ha.Z,{user:e,size:"micro"})))):i.ZP.createElement(ns.Z,{text:(0,bt.bi)(t.count)}))})),lo=(0,i.X$)((e=>{let{message:t,isOutside:n,maxWidth:a,activeReactions:s,availableReactions:o,metaChildren:r,genericEffects:c,observeIntersection:d,noRecentReactors:l}=e;const m=(0,i.Ye)((()=>t.reactions.results.reduce(((e,t)=>e+t.count),0)),[t]);return i.ZP.createElement("div",{className:(0,tt.Z)("Reactions",n&&"is-outside"),style:a?`max-width: ${a}px`:void 0},t.reactions.results.map((e=>i.ZP.createElement(co,{key:(0,u.$d)(e.reaction),reaction:e,message:t,activeReactions:s,availableReactions:o,withRecentReactors:m<=3&&!l,genericEffects:c,observeIntersection:d}))),r)})),uo=(0,i.X$)((e=>{let{phoneCall:t,message:n,chatId:o}=e;const{requestMasterAndRequestCall:r}=(0,a.Sv)(),c=(0,kt.Z)(),{isOutgoing:d,isVideo:l,reason:u}=t,m="missed"===u,h="busy"===u&&!d,p=(0,i.I4)((()=>{r({isVideo:l,userId:o})}),[o,l,r]),g=(0,i.Ye)((()=>l?h?"CallMessageVideoIncomingDeclined":m?d?"CallMessageVideoOutgoingMissed":"CallMessageVideoIncomingMissed":d?"CallMessageVideoOutgoing":"CallMessageVideoIncoming":h?"CallMessageIncomingDeclined":m?d?"CallMessageOutgoingMissed":"CallMessageIncomingMissed":d?"CallMessageOutgoing":"CallMessageIncoming"),[h,m,d,l]),f=(0,i.Ye)((()=>t.duration?(0,ae.J_)(c,t.duration):void 0),[c,t.duration]),I=(0,ae.mr)(c,1e3*n.date);return i.ZP.createElement("div",{className:"vDeypQzM845_JE14qGId"},i.ZP.createElement(Ft.Z,{size:"smaller",color:"translucent",round:!0,ripple:!0,onClick:p,className:"OtJi45yywgt1n_y6VPkE",disabled:!s.Bi,ariaLabel:c(d?"CallAgain":"CallBack")},i.ZP.createElement("i",{className:l?"icon-video-outlined":"icon-phone"})),i.ZP.createElement("div",{className:"_0BG8sziTJQ_NYrsspMg"},i.ZP.createElement("div",{className:"LWVSvxVjeEyHPBrCb2sD"},c(g)),i.ZP.createElement("div",{className:"nuIsoCP15iD4ETadJ44R"},i.ZP.createElement("i",{className:(0,tt.Z)("icon-arrow-right","wrUkWet7enyh9L1iPKvA",m&&"V5tKkKZpcY5yq_f5nO8l",!d&&"e0Vhbj8gfzQn1zJQoFLK")}),i.ZP.createElement("span",{className:"TJ2lYkLxYUie3A0JqtMR"},f?c("CallMessageWithDuration",[I,f]):I))))}));var mo=n(78780),ho=n(50685),po=n(14612),go=n(98138),fo=n(2995);var Io=n(69123);const vo=1.125*Re.Gw,wo=(0,i.X$)((e=>{let{topic:t,className:n,onClick:a}=e;const s=(0,kt.Z)();return i.ZP.createElement("div",{className:(0,tt.Z)("wUl1jHjVuMxmGhsdl358",n),style:`--topic-button-accent-color: var(${(0,go.gZ)(t?.iconColor)})`,onClick:a},t?i.ZP.createElement(fo.Z,{topic:t,size:vo}):i.ZP.createElement("img",{src:Io,alt:""}),t?.title?(0,Bn.Z)(t.title):s("Loading"),t?.isClosed&&i.ZP.createElement("i",{className:"icon-lock"}),i.ZP.createElement("i",{className:"icon-next"}))})),bo={__html:'<svg width="9" height="20" xmlns="http://www.w3.org/2000/svg"><defs><filter x="-50%" y="-14.7%" width="200%" height="141.2%" filterUnits="objectBoundingBox" id="a"><feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur stdDeviation="1" in="shadowOffsetOuter1" result="shadowBlurOuter1"/><feColorMatrix values="0 0 0 0 0.0621962482 0 0 0 0 0.138574144 0 0 0 0 0.185037364 0 0 0 0.15 0" in="shadowBlurOuter1"/></filter></defs><g fill="none" fill-rule="evenodd"><path d="M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z" fill="#000" filter="url(#a)"/><path d="M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z" fill="#EEFFDE" class="corner"/></g></svg>'},yo={__html:'<svg width="9" height="20" xmlns="http://www.w3.org/2000/svg"><defs><filter x="-50%" y="-14.7%" width="200%" height="141.2%" filterUnits="objectBoundingBox" id="a"><feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur stdDeviation="1" in="shadowOffsetOuter1" result="shadowBlurOuter1"/><feColorMatrix values="0 0 0 0 0.0621962482 0 0 0 0 0.138574144 0 0 0 0 0.185037364 0 0 0 0.15 0" in="shadowBlurOuter1"/></filter></defs><g fill="none" fill-rule="evenodd"><path d="M3 17h6V0c-.193 2.84-.876 5.767-2.05 8.782-.904 2.325-2.446 4.485-4.625 6.48A1 1 0 003 17z" fill="#000" filter="url(#a)"/><path d="M3 17h6V0c-.193 2.84-.876 5.767-2.05 8.782-.904 2.325-2.446 4.485-4.625 6.48A1 1 0 003 17z" fill="#FFF" class="corner"/></g></svg>'},Po=1.75*Re.Gw,Zo=2.25*Re.Gw,Co=(0,i.X$)((0,a.c$)(((e,t)=>{const{focusedMessage:n,forwardMessages:a,activeReactions:s,activeEmojiInteractions:i}=(0,d.jU)(e),{lastSyncTime:c}=e,{message:l,album:m,withSenderName:h,withAvatar:p,threadId:g,messageListType:f,isLastInDocumentGroup:I,isFirstInGroup:v}=t,{id:w,chatId:b,viaBotId:y,replyToChatId:P,replyToMessageId:Z,isOutgoing:C,repliesThreadInfo:S,forwardInfo:E,transcriptionId:M}=l,R=(0,d.Z1)(e,b),k=(0,d.FM)(e,b),T=(0,u.pK)(b),A=R&&(0,u.eA)(R),N=R&&(0,u.Bf)(R),x=R?.usernames,B=a.messageIds&&a.messageIds.includes(w),L=!k&&(0,u.Ul)(l),U=h||p||L,j=(0,d.Ur)(e,l),O=(0,d.cv)(e,l),F=y?(0,d.dy)(e,y):void 0,_=j?.id&&N?R.fullInfo?.adminMembersById?.[j?.id]:void 0,D=g?(0,d.qS)(e,b,g):void 0,q=l.id===D,$=Z===D,G=Z&&!$?(0,d.hj)(e,T&&P?P:b,Z):void 0,H=G&&(0,d.Bz)(e,G,Boolean(E)),V="topicCreate"===G?.content.action?.type,z=(0,d.uZ)(e,l),W="thread"===f&&(m?m.messages.some((t=>(0,d._X)(e,t))):(0,d._X)(e,l)),{direction:X,noHighlight:Y,isResizingContainer:J}=W&&n||{},{query:K}=(0,d.n5)(e)||{},Q=(0,u.h_)(l),ee=Q&&(0,d.zB)(e,Q)?Q:void 0,te=(0,u.HW)(l);let ne;ne=m?.messages?m.messages.every((t=>{let{id:n}=t;return(0,d.vk)(e,n)})):(0,d.vk)(e,w);const{canReply:ae}="thread"===f&&(0,d._k)(e,l,g)||{},se=(0,d.te)(e,l),oe=S?(0,d.tZ)(e,S.chatId,S.threadId)||S:void 0,ie=Boolean(l.groupedId)&&!l.isInAlbum,re=ie?(0,d.xH)(e,b,l.groupedId)[0]:void 0,ce=ie?I?(0,d.hj)(e,b,re):void 0:l,de=R?.unreadReactions?.includes(l.id),le=g===r._f&&R?.isForum&&v,ue=le?(0,d.p$)(e,l)||R?.topics?.[o.OxA]:void 0,me=Boolean((0,u.nf)(l)),he=(0,d.xf)(e,b),pe=(0,d.xx)(e,b,l.id);return{theme:(0,d.Pu)(e),chatUsernames:x,forceSenderName:L,canShowSender:U,originSender:O,botSender:F,shouldHideReply:$||V,isThreadTop:q,replyMessage:G,replyMessageSender:H,isInDocumentGroup:ie,isProtected:(0,d.EV)(e,l),isChatProtected:(0,d.Am)(e,b),isFocused:W,isForwarding:B,reactionMessage:ce,isChatWithSelf:k,isRepliesChat:T,isChannel:A,isGroup:N,canReply:ae,lastSyncTime:c,highlight:K,animatedEmoji:ee,animatedCustomEmoji:te,isInSelectMode:(0,d.CA)(e),isSelected:ne,isGroupSelected:Boolean(l.groupedId)&&!l.isInAlbum&&(0,d.a6)(e,b,l.groupedId),threadId:g,isDownloading:se,isPinnedList:"pinned"===f,canAutoLoadMedia:(0,d.bH)(e,l),canAutoPlayMedia:(0,d.__)(e,l),autoLoadFileMaxSizeMb:e.settings.byKey.autoLoadFileMaxSizeMb,shouldLoopStickers:(0,d.Cy)(e),repliesThreadInfo:oe,availableReactions:e.availableReactions,defaultReaction:(0,u.CI)(l)?void 0:(0,d.q6)(e,b),activeReactions:ce&&s[ce.id],activeEmojiInteractions:i,hasUnreadReaction:de,isTranscribing:void 0!==M&&e.transcriptions[M]?.isPending,transcribedText:void 0!==M?e.transcriptions[M]?.text:void 0,isPremium:(0,d.wV)(e),animationLevel:e.settings.byKey.animationLevel,senderAdminMember:_,messageTopic:ue,genericEffects:e.genericEmojiEffects,hasTopicChip:le,chatTranslations:he,areTranslationsEnabled:e.settings.byKey.canTranslate,requestedTranslationLanguage:pe,...(U||me)&&{sender:j},...C&&{outgoingStatus:(0,d.dT)(e,l,"scheduled"===f)},..."number"==typeof z&&{uploadProgress:z},...W&&{focusDirection:X,noFocusHighlight:Y,isResizingContainer:J}}}))((e=>{let{message:t,chatUsernames:n,observeIntersectionForBottom:c,observeIntersectionForLoading:d,observeIntersectionForPlaying:l,album:m,noAvatars:h,withAvatar:p,withSenderName:g,noComments:I,noReplies:w,appearanceOrder:b,isFirstInGroup:y,isPremium:P,isLastInGroup:Z,isFirstInDocumentGroup:S,isLastInDocumentGroup:E,isTranscribing:M,transcribedText:R,isLastInList:k,theme:T,forceSenderName:A,sender:N,canShowSender:x,originSender:B,botSender:L,isThreadTop:U,shouldHideReply:j,replyMessage:O,replyMessageSender:F,outgoingStatus:_,uploadProgress:D,isInDocumentGroup:q,isProtected:$,isChatProtected:G,isFocused:H,focusDirection:V,noFocusHighlight:z,isResizingContainer:W,isForwarding:X,isChatWithSelf:Y,isRepliesChat:J,isChannel:K,isGroup:Q,canReply:ee,lastSyncTime:te,highlight:ne,animatedEmoji:ae,animatedCustomEmoji:se,genericEffects:oe,isInSelectMode:ie,isSelected:re,isGroupSelected:ce,threadId:de,reactionMessage:le,availableReactions:ue,defaultReaction:me,activeReactions:he,activeEmojiInteractions:pe,messageListType:ge,isPinnedList:fe,isDownloading:Ie,canAutoLoadMedia:ve,canAutoPlayMedia:we,shouldLoopStickers:be,autoLoadFileMaxSizeMb:ye,repliesThreadInfo:Pe,hasUnreadReaction:Ze,memoFirstUnreadIdRef:Ce,animationLevel:Se,senderAdminMember:Ee,messageTopic:Me,hasTopicChip:ke,chatTranslations:Te,areTranslationsEnabled:Ae,requestedTranslationLanguage:Ne}=e;const{toggleMessageSelection:xe,clickBotInlineButton:Be,disableContextMenuHint:Le,animateUnreadReaction:Ue,focusLastMessage:je}=(0,a.Sv)(),Oe=(0,i.sO)(null),Fe=(0,i.sO)(null),_e=(0,i.sO)(null),De=(0,i.sO)(0),qe=(0,kt.Z)(),[$e,Ge]=(0,i.eJ)(!1),[He,Ve,ze]=(0,Et.Z)(),{isMobile:We}=(0,C.ZP)();(0,wa._N)(Fe,c);const{isContextMenuOpen:Xe,contextMenuPosition:Ye,handleBeforeContextMenu:Je,handleContextMenu:Ke,handleContextMenuClose:Qe,handleContextMenuHide:et}=(0,ta.Z)(Oe,s.$b&&ie,!0,s.wZ);(0,i.d4)((()=>{Xe&&Le()}),[Xe,Le]);const nt=b<=0,[at,st]=(0,Et.Z)(nt);(0,i.d4)((()=>{nt||setTimeout(st,10*b)}),[b,st,nt]);const{transitionClassNames:ot}=(0,pt.Z)(at,void 0,nt,!1),{id:it,chatId:rt,forwardInfo:ct,viaBotId:dt,isTranscriptionError:lt}=t,ut=(0,u.CI)(t),mt=(0,u.B4)(t),ht="scheduled"===ge||t.isScheduled,gt=(0,u.ss)(t)&&!j,ft=Boolean(Pe)&&"thread"===ge,It=(0,u.$D)(t),vt=It&&(ae||se),wt=le?.reactions&&!(0,u.JE)(le.reactions),bt=ct&&(!Y||ht)&&!J&&!ct.isLinkedChannelPost&&!It,yt=Boolean(m)&&m.messages.length>1&&!m?.messages.some((e=>0===Object.keys(e.content).length)),Pt=q&&!S,Zt=q&&!E,Ct=void 0!==Ye,St=!(Ct||ie||X||Zt),Mt=K&&!ht&&t.isForwardingAllowed&&!G,Rt=Boolean(fe||ct&&(ct.isChannelPost||Y&&!mt||J)&&ct.fromMessageId),Tt=ke||gt,At=(0,i.I4)(((e,t)=>{xe({messageId:it,groupedId:t,...e?.shiftKey&&{withShift:!0},...yt&&{childMessageIds:m.messages.map((e=>{let{id:t}=e;return t}))}})}),[xe,it,yt,m]),Nt=x?N:void 0,xt=Boolean(!$e&&(lt||R)),Bt=ct&&(Y||J||!Nt)?B:Nt,Lt=ct?B:Nt,{handleMouseDown:Ut,handleClick:jt,handleContextMenu:Ot,handleDoubleClick:_t,handleContentDoubleClick:Dt,handleMouseMove:qt,handleSendQuickReaction:$t,handleMouseLeave:Gt,isSwiped:Ht,isQuickReactionVisible:Wt,handleDocumentGroupMouseEnter:Xt}=ja(At,Oe,it,0,Boolean(ie),Boolean(ee),Boolean($),Ke,Je,rt,Ct,_e,mt,Zt),{handleAvatarClick:Yt,handleSenderClick:Jt,handleViaBotClick:Kt,handleReplyClick:Qt,handleMediaClick:en,handleAudioPlay:tn,handleAlbumMediaClick:nn,handleMetaClick:an,handleTranslationClick:sn,handleOpenThread:on,handleReadMedia:rn,handleCancelUpload:cn,handleVoteSend:dn,handleGroupForward:ln,handleForward:un,handleFocus:mn,handleFocusForwarded:hn,handleDocumentGroupSelectAll:pn,handleTopicChipClick:gn}=function(e,t,n,s,o,c,d,l,u,m,h,p,g,I){const{openChat:v,showNotification:w,focusMessage:b,openMediaViewer:y,openAudioPlayer:P,markMessagesRead:Z,cancelSendingMessage:C,sendPollVote:S,openForwardMenu:E,focusMessageInComments:M,openMessageLanguageModal:R}=(0,a.Sv)(),{id:k,forwardInfo:T,replyToMessageId:A,replyToChatId:N,replyToTopMessageId:x,groupedId:B}=n,L=(0,i.I4)((()=>{h&&v({id:h.id})}),[h,v]),U=(0,i.I4)((()=>{p?d&&T?.channelPostId?b({chatId:p.id,messageId:T.channelPostId}):v({id:p.id}):w({message:e("HidAccount")})}),[d,b,T,e,v,p,w]),j=(0,i.I4)((()=>{g&&v({id:g.id})}),[g,v]),O=(0,i.I4)((()=>{b({chatId:u&&N?N:s,threadId:o,messageId:A,replyMessageId:u&&N?void 0:k,noForumTopicPanel:!0})}),[b,u,N,s,o,A,k]),F=(0,i.I4)((()=>{y({chatId:s,threadId:o,mediaId:k,origin:l?f.bZ.ScheduledInline:f.bZ.Inline})}),[s,o,k,y,l]),_=(0,i.I4)((()=>{P({chatId:s,messageId:k})}),[s,k,P]),D=(0,i.I4)((e=>{y({chatId:s,threadId:o,mediaId:e,origin:l?f.bZ.ScheduledAlbum:f.bZ.Album})}),[s,o,y,l]),q=(0,i.I4)((()=>{Z({messageIds:[k]})}),[k,Z]),$=(0,i.I4)((()=>{C({chatId:s,messageId:k})}),[C,s,k]),G=(0,i.I4)((e=>{S({chatId:s,messageId:k,options:e})}),[s,k,S]),H=(0,i.I4)((()=>{E({fromChatId:s,groupedId:B})}),[E,s,B]),V=(0,i.I4)((()=>{if(m&&m.messages){const e=m.messages.map((e=>{let{id:t}=e;return t}));E({fromChatId:s,messageIds:e})}else E({fromChatId:s,messageIds:[k]})}),[m,E,s,k]),z=(0,i.I4)((()=>{b({chatId:s,threadId:r._f,messageId:k})}),[b,s,k]),W=(0,i.I4)((()=>{c?b({chatId:T.fromChatId,groupedId:B,groupedChatId:s,messageId:T.fromMessageId}):u&&N?M({chatId:N,threadId:x,messageId:T.fromMessageId}):b({chatId:T.fromChatId,messageId:T.fromMessageId})}),[c,u,N,b,T,B,s,M,x]),X=(0,i.I4)((e=>{e.stopPropagation(),t(e,B)}),[t,B]);return{handleAvatarClick:L,handleSenderClick:U,handleViaBotClick:j,handleReplyClick:O,handleMediaClick:F,handleAudioPlay:_,handleAlbumMediaClick:D,handleMetaClick:X,handleTranslationClick:(0,i.I4)((e=>{e.stopPropagation(),R({chatId:s,id:k})}),[s,k,R]),handleOpenThread:(0,i.I4)((()=>{v({id:n.chatId,threadId:n.id})}),[n.chatId,n.id,v]),handleReadMedia:q,handleCancelUpload:$,handleVoteSend:G,handleGroupForward:H,handleForward:V,handleFocus:z,handleFocusForwarded:W,handleDocumentGroupSelectAll:X,handleTopicChipClick:(0,i.I4)((()=>{I&&b({chatId:u&&N?N:s,threadId:I.id,messageId:k})}),[s,b,u,I,k,N])}}(qe,At,t,rt,de,q,bt,ht,J,m,Bt,Lt,L,Me);(0,i.d4)((()=>{k&&xt&&R&&je()}),[je,k,R,xt]);const fn=(0,tt.Z)("Message message-list-item",y&&"first-in-group",$&&"is-protected",Z&&"last-in-group",S&&"first-in-document-group",E&&"last-in-document-group",k&&"last-in-list",mt&&"own",Boolean(t.views)&&"has-views",t.isEdited&&"was-edited",gt&&"has-reply",Ct&&"has-menu-open",H&&!z&&"focused",X&&"is-forwarding",t.isDeleting&&"is-deleting",q&&"is-in-document-group",yt&&"is-album",t.hasUnreadMention&&"has-unread-mention",re&&"is-selected",ie&&"is-in-selection-mode",U&&!p&&"is-thread-top",Boolean(t.inlineButtons)&&"has-inline-buttons",Ht&&"is-swiped",ot,(Boolean(he)||He)&&"has-active-reaction"),{text:In,photo:vn,video:wn,audio:bn,voice:yn,document:Pn,sticker:Zn,contact:Cn,poll:Sn,webPage:En,invoice:Rn,location:Tn,action:An,game:Nn}=(0,u.qp)(t),{result:xn}=function(e){const t=(0,Jn.Z)((()=>e?async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.2;return $a||await Ga.promise,await $a.request({name:"detectLanguage",args:[e,t]})}(e):Promise.resolve(void 0)),[e],void 0);return t}(Ae?In?.text:void 0),{isPending:Ln,translatedText:Un}=function(e,t,n,s){const{translateMessages:o}=(0,a.Sv)(),r=s?e?.byLangCode[s]?.[n]:void 0,{isPending:c,text:d}=r||{};return(0,i.d4)((()=>{d||c||!s||o({chatId:t,messageIds:[n],toLanguageCode:s})}),[t,d,c,n,s,o]),{isPending:c,translatedText:d}}(Te,rt,it,Ne),jn=(0,Mn.Z)(Un,!0),On=Ln?jn||In:Un,Fn=Un||jn,{phoneCall:_n}=An||{},Dn=Pe&&!Zt&&"thread"===ge&&!I,qn=!s.$b&&!_n&&!ie&&me&&!Zt,$n=function(e){let{hasSubheader:t,isCustomShape:n,isLastInGroup:a,asForwarded:s,hasThread:i,forceSenderName:r,hasComments:c,hasActionButton:d,hasReactions:l,isGeoLiveActive:m,withVoiceTranscription:h}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{text:p,photo:g,video:f,audio:I,voice:v,document:w,poll:b,webPage:y,contact:P,location:Z,invoice:C}=(0,u.qp)(e),S=[o.gnl],E=g||f||Z||C?.extendedMedia,M=p||"venue"===Z?.type||m,R=E&&!M,k=Boolean(e.viaBotId);return!E&&e.emojiOnlyCount?(S.push("emoji-only"),e.emojiOnlyCount<=o.L5X&&S.push(`emoji-only-${e.emojiOnlyCount}`)):M&&S.push("text"),d&&S.push("has-action-button"),n&&(S.push("custom-shape"),f?.isRound&&S.push("round"),c&&S.push("has-comments")),E?S.push("media"):I?S.push("audio"):v?(S.push("voice"),h&&S.push("with-voice-transcription")):w?S.push("document"):P?S.push("contact"):b?S.push("poll"):y&&(S.push("web-page"),(y.photo||y.video)&&S.push("media")),C&&!C.extendedMedia&&S.push("invoice"),s&&S.push("is-forwarded"),t&&S.push("has-subheader"),i&&S.push("has-replies"),l&&S.push("has-reactions"),k&&S.push("is-via-bot"),r&&S.push("force-sender-name"),n||(S.push("has-shadow"),E&&c&&S.push("has-background"),(t||s||k||!R||r)&&S.push("has-solid-background"),a&&(g||Z&&!M||!R)&&S.push("has-appendix")),S.join(" ")}(t,{hasSubheader:Tt,isCustomShape:It,isLastInGroup:Z,asForwarded:bt,hasThread:ft&&!I,forceSenderName:A,hasComments:Pe&&Pe.messagesCount>0,hasActionButton:Mt||Rt,hasReactions:wt,isGeoLiveActive:"geoLive"===Tn?.type&&!(0,u.$R)(t,(0,v.bp)()),withVoiceTranscription:xt}),Gn=$n.includes("has-appendix"),Hn=(0,u.fY)(t),Vn=(0,Aa.qo)(t.emojiOnlyCount);let zn,Wn;zn=_n||Zt?"none":!Hn||En||vt?"standalone":"in-text",wt?It||(vn||wn)&&!Hn?Wn="outside":bt?(zn="standalone",Wn="inside"):Wn="inside":Wn="none",(0,kn.Z)(J&&t.replyToChatId?t.replyToChatId:rt,gt?t.replyToMessageId:void 0,O,t.id),Na(Oe,rt,H,V,z,W);const Xn=Z,Yn=(0,i.I4)((e=>{const t=De.current,n=e.target.clientHeight;if(De.current=n,(0,pa.N)()||!t||n<=t)return;const a=e.target.closest(".MessageList");if(!a)return;const s=n-t,{offsetHeight:o,scrollHeight:i,scrollTop:r}=a;Math.round(i-r-o)-s<=5&&je()}),[je]),Kn=(0,_a.Z)(Yn,[Yn],300,!1);(0,va.Z)(Xn?Oe:void 0,Kn),(0,i.d4)((()=>{const e=Fe.current;Ze&&e&&(0,Ta.P)(e)&&Ue({messageIds:[it]})}),[Ze,it,Ue]);let Qn,ea,na="",aa=!1;const sa=(0,i.Ye)((()=>yt?Ea(mt,Boolean(bt),Boolean(h),m,We):void 0),[yt,mt,bt,h,m,We]),oa=bt?28:0;if(!yt&&(vn||wn||Rn?.extendedMedia)){let e;if(vn)e=Pa(t,bt,h,We).width;else if(wn)e=wn.isRound?Re.Rj:Pa(t,bt,h,We).width;else if(Rn?.extendedMedia&&Rn.extendedMedia.width&&Rn.extendedMedia.height){const{width:t,height:n}=Rn.extendedMedia;e=(0,Re.Kf)({width:t,height:n,fromOwnMessage:mt,asForwarded:bt,noAvatars:h,isMobile:We}).width}e&&(Qn=Math.max(ya(Boolean(On),Dn),e),Rn?.extendedMedia&&Qn-e>18&&(aa=!0))}else sa&&(Qn=Math.max(ya(Boolean(On),Dn),sa.containerStyle.width),Qn-sa.containerStyle.width>18&&(aa=!0));Qn&&(na=`width: ${Qn+oa}px`,ea=Qn+Zo);const ia=K&&t.postAuthorTitle||!bt&&ct?.postAuthorTitle||void 0,ra=(0,i.Ye)((()=>ia?ka(ia):void 0),[ia]);function ca(e){return i.ZP.createElement(po.Z,{message:t,translatedText:Ne?Fn:void 0,isForAnimation:e,emojiSize:Vn,highlight:ne,isProtected:$,observeIntersectionForLoading:d,observeIntersectionForPlaying:l,withTranslucentThumbs:It})}function da(){const e=i.ZP.createElement(as,{message:t,noReplies:w,repliesThreadInfo:Pe,outgoingStatus:_,signature:ia,withReactionOffset:"inside"===Wn,availableReactions:ue,isTranslated:Boolean(Ne?Fn:void 0),onClick:an,onTranslationClick:sn,onOpenThread:on});return"inside"!==Wn?e:i.ZP.createElement(lo,{activeReactions:he,message:le,metaChildren:e,availableReactions:ue,genericEffects:oe,observeIntersection:l,noRecentReactors:K})}const la=Q&&bt?t.postAuthorTitle:void 0,ua=(0,i.Ye)((()=>n?.find((e=>e.isActive))),[n]);return i.ZP.createElement("div",{ref:Oe,id:(0,u.d0)(t.id),className:fn,style:ra?`--meta-safe-author-width: ${ra}px`:void 0,"data-message-id":it,onMouseDown:Ut,onClick:jt,onContextMenu:Ot,onDoubleClick:_t,onMouseEnter:Zt?Xt:void 0,onMouseMove:qn?qt:void 0,onMouseLeave:qn||Zt?Gt:void 0},i.ZP.createElement("div",{ref:Fe,className:"bottom-marker","data-message-id":it,"data-last-message-id":m?m.messages[m.messages.length-1].id:void 0,"data-has-unread-mention":t.hasUnreadMention||void 0,"data-has-unread-reaction":Ze||void 0}),!q&&i.ZP.createElement("div",{className:"message-select-control"},re&&i.ZP.createElement("i",{className:"icon-select"})),E&&i.ZP.createElement("div",{className:(0,tt.Z)("message-select-control group-select",ce&&"is-selected"),onClick:pn},ce&&i.ZP.createElement("i",{className:"icon-select"})),p&&function(){const e=Bt&&(0,u.YC)(Bt.id),t=Bt&&e?Bt:void 0,n=Bt&&!e?Bt:void 0,a=!Bt&&ct?ct.hiddenUserName:void 0;return i.ZP.createElement(Ha.Z,{size:We?"small-mobile":"small",user:t,chat:n,text:a,lastSyncTime:te,onClick:t||n?Yt:void 0,observeIntersection:d,animationLevel:Se,withVideo:!0})}(),i.ZP.createElement("div",{className:(0,tt.Z)("message-content-wrapper",$n.includes("text")&&"can-select-text")},i.ZP.createElement("div",{ref:_e,className:$n,style:na,dir:"auto"},bt&&!Pt&&i.ZP.createElement("div",{className:"message-title"},qe("ForwardedMessage"),la&&i.ZP.createElement("span",{className:"admin-title",dir:"auto"},la)),function(){const e=(0,tt.Z)("content-inner",bt&&"forwarded-message",Tt&&"with-subheader",aa&&"no-media-corners"),n=Z&&!Hn&&!bt&&!Dn,a=(0,tt.Z)("text-content","clearfix","in-text"===zn&&"with-meta",_&&"with-outgoing-icon");return i.ZP.createElement("div",{className:e,onDoubleClick:Dt,dir:"auto"},function(){if(It&&!dt||!(g&&(!(vn||wn||Tn)||ke)||bt||dt||A)||Pt||gt&&It)return;let e,n;!Lt||It&&dt?ct?.hiddenUserName&&(e=ct.hiddenUserName):(e=(0,u.OU)(qe,Lt),bt||mt||(n=`color-${(0,u.Rs)(Lt)}`));const a=Lt&&"emojiStatus"in Lt&&Lt.emojiStatus,s=Lt&&"isPremium"in Lt&&Lt.isPremium;return i.ZP.createElement("div",{className:"message-title",dir:"ltr"},e?i.ZP.createElement("span",{className:(0,tt.Z)("message-title-name interactive",n),onClick:Jt,dir:"ltr"},(0,Bn.Z)(e),!bt&&a&&i.ZP.createElement(Vt.Z,{documentId:a.documentId,loopLimit:o.y3O,observeIntersectionForLoading:d,observeIntersectionForPlaying:l}),!bt&&!a&&s&&i.ZP.createElement(zt.Z,null),Lt?.fakeType&&i.ZP.createElement(ho.Z,{fakeType:Lt.fakeType})):L?void 0:" ",L&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("span",{className:"via"},qe("ViaBot")),i.ZP.createElement("span",{className:"interactive",onClick:Kt},(0,Bn.Z)(`@${L.usernames[0].username}`))),ct?.isLinkedChannelPost?i.ZP.createElement("span",{className:"admin-title",dir:"auto"},qe("DiscussChannel")):t.forwardInfo?.postAuthorTitle&&Q&&bt?i.ZP.createElement("span",{className:"admin-title",dir:"auto"},t.forwardInfo?.postAuthorTitle):t.postAuthorTitle&&Q&&!bt?i.ZP.createElement("span",{className:"admin-title",dir:"auto"},t.postAuthorTitle):Ee&&!bt?i.ZP.createElement("span",{className:"admin-title",dir:"auto"},Ee.customTitle||qe(Ee.isOwner?"GroupInfo.LabelOwner":"GroupInfo.LabelAdmin")):void 0)}(),Tt&&i.ZP.createElement("div",{className:"message-subheader"},ke&&i.ZP.createElement(wo,{topic:Me,onClick:gn,className:"message-topic"}),gt&&i.ZP.createElement(Ka,{message:O,noUserColors:mt||K,isProtected:$,sender:F,observeIntersectionForLoading:d,observeIntersectionForPlaying:l,onClick:Qt})),Zn&&i.ZP.createElement(is,{message:t,observeIntersection:d,observeIntersectionForPlaying:l,shouldLoop:be,lastSyncTime:te,shouldPlayEffect:Zn.hasEffect&&(Ce.current&&it>=Ce.current||ut)||void 0,onPlayEffect:Ve,onStopEffect:ze}),vt&&se&&i.ZP.createElement(ms,{customEmojiId:se,withEffects:(0,u.YC)(rt),isOwn:mt,observeIntersection:d,lastSyncTime:te,forceLoadPreview:ut,messageId:it,chatId:rt,activeEmojiInteractions:pe}),vt&&ae&&i.ZP.createElement(us,{emoji:ae,withEffects:(0,u.YC)(rt),isOwn:mt,observeIntersection:d,lastSyncTime:te,forceLoadPreview:ut,messageId:it,chatId:rt,activeEmojiInteractions:pe}),yt&&i.ZP.createElement(Js,{album:m,albumLayout:sa,observeIntersection:d,isOwn:mt,isProtected:$,hasCustomAppendix:n,lastSyncTime:te,onMediaClick:nn}),_n&&i.ZP.createElement(uo,{message:t,phoneCall:_n,chatId:rt}),!yt&&vn&&i.ZP.createElement(bs,{message:t,observeIntersection:d,noAvatars:h,canAutoLoad:ve,uploadProgress:D,shouldAffectAppendix:n,isDownloading:Ie,isProtected:$,asForwarded:bt,theme:T,onClick:en,onCancelUpload:cn}),!yt&&wn&&wn.isRound&&i.ZP.createElement(Qs,{message:t,observeIntersection:d,canAutoLoad:ve,lastSyncTime:te,isDownloading:Ie}),!yt&&wn&&!wn.isRound&&i.ZP.createElement(Ps,{message:t,observeIntersectionForLoading:d,observeIntersectionForPlaying:l,noAvatars:h,canAutoLoad:ve,canAutoPlay:we,uploadProgress:D,lastSyncTime:te,isDownloading:Ie,isProtected:$,asForwarded:bt,onClick:en,onCancelUpload:cn}),(bn||yn)&&i.ZP.createElement(es.ZP,{theme:T,message:t,origin:f.Cr.Inline,uploadProgress:D,lastSyncTime:te,isSelectable:q,isSelected:re,noAvatars:h,onPlay:tn,onReadMedia:!yn||mt&&!Y?void 0:rn,onCancelUpload:cn,isDownloading:Ie,isTranscribing:M,isTranscriptionHidden:$e,isTranscribed:Boolean(R),isTranscriptionError:lt,canDownload:!$,onHideTranscription:Ge,canTranscribe:P}),Pn&&i.ZP.createElement(Qa.Z,{message:t,observeIntersection:d,canAutoLoad:ve,autoLoadFileMaxSizeMb:ye,uploadProgress:D,isSelectable:q,isSelected:re,onMediaClick:en,onCancelUpload:cn,isDownloading:Ie}),Cn&&i.ZP.createElement(Cs,{contact:Cn}),Sn&&i.ZP.createElement(Ns,{message:t,poll:Sn,onSendVote:dn}),Nn&&i.ZP.createElement(zs,{message:t,canAutoLoadMedia:ve,lastSyncTime:te}),Rn?.extendedMedia&&i.ZP.createElement(Fs,{message:t,lastSyncTime:te}),xt&&i.ZP.createElement("p",{className:(0,tt.Z)("transcription",!$e&&lt&&"transcription-error"),dir:"auto"},lt?qe("NoWordsRecognized"):M&&R?i.ZP.createElement(mo.Z,{content:R}):R),!vt&&Hn&&i.ZP.createElement("div",{className:a,dir:"auto"},ca(),Ln&&i.ZP.createElement("div",{className:"translation-animation"},i.ZP.createElement("div",{className:"text-loading"},ca(!0))),"in-text"===zn&&da()),En&&i.ZP.createElement(Ls,{message:t,observeIntersection:d,noAvatars:h,canAutoLoad:ve,canAutoPlay:we,asForwarded:bt,lastSyncTime:te,isDownloading:Ie,isProtected:$,theme:T,onMediaClick:en,onCancelMediaTransfer:cn}),Rn&&!Rn.extendedMedia&&i.ZP.createElement(js,{message:t,shouldAffectAppendix:n,isInSelectMode:ie,isSelected:re,theme:T}),Tn&&i.ZP.createElement(Vs,{message:t,lastSyncTime:te,isInSelectMode:ie,isSelected:re,theme:T,peer:N}))}(),!Zt&&"standalone"===zn&&da(),St&&Mt?i.ZP.createElement(Ft.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:qe("lng_context_forward_msg"),onClick:E?ln:un},i.ZP.createElement("i",{className:"icon-share-filled"})):St&&Rt?i.ZP.createElement(Ft.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:fe?mn:hn},i.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,Dn&&i.ZP.createElement(to,{threadInfo:Pe,disabled:I}),Gn&&i.ZP.createElement("div",{className:"svg-appendix",dangerouslySetInnerHTML:mt?bo:yo}),qn&&i.ZP.createElement("div",{className:(0,tt.Z)("quick-reaction",Wt&&!he&&"visible"),onClick:$t},i.ZP.createElement(ao.Z,{reaction:me,size:Po,availableReactions:ue,observeIntersection:l}))),t.inlineButtons&&i.ZP.createElement(eo,{message:t,onClick:Be}),"outside"===Wn&&i.ZP.createElement(lo,{message:le,isOutside:!0,maxWidth:ea,activeReactions:he,availableReactions:ue,genericEffects:oe,observeIntersection:l,noRecentReactors:K})),Ye&&i.ZP.createElement(za,{isOpen:Xe,anchor:Ye,message:t,album:m,chatUsername:ua?.username,messageListType:ge,onClose:Qe,onCloseAnimationEnd:et,repliesThreadInfo:Pe,noReplies:w,detectedLanguage:xn}))}))),So=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"AboutAdsModal",!t);return n?i.ZP.createElement(n,e):void 0})),Eo=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"SponsoredMessageContextMenuContainer",!t);return n?i.ZP.createElement(n,e):void 0})),Mo=(0,i.X$)((0,a.c$)(((e,t)=>{let{chatId:n}=t;const a=(0,d.fS)(e,n),{chatId:s,isBot:o}=a||{};return{message:a,bot:s&&o?(0,d.dy)(e,s):void 0,channel:!o&&s?(0,d.Z1)(e,s):void 0}}))((e=>{let{chatId:t,message:n,containerRef:o,bot:r,channel:c}=e;const{viewSponsoredMessage:d,openChat:l,openChatByInvite:m,startBot:h,focusMessage:p}=(0,a.Sv)(),g=(0,kt.Z)(),f=(0,i.sO)(null),I=(0,i.sO)(null),v=Boolean(n),{observe:w}=(0,wa.S1)({rootRef:o,debounceMs:200,threshold:1}),{isContextMenuOpen:b,contextMenuPosition:y,handleBeforeContextMenu:P,handleContextMenu:Z,handleContextMenuClose:C,handleContextMenuHide:S}=(0,ta.Z)(f,s.$b,!0,s.wZ),[E,M,R]=(0,Et.Z)(!1);(0,i.d4)((()=>v?w(I.current,(e=>{e.isIntersecting&&d({chatId:t})})):void 0),[t,v,w,d]);const k=(0,i.I4)((()=>{n&&(n.chatInviteHash?m({hash:n.chatInviteHash}):n.channelPostId?p({chatId:n.chatId,messageId:n.channelPostId}):(l({id:n.chatId}),n.startParam&&h({botId:n.chatId,param:n.startParam})))}),[p,n,l,m,h]);if(n)return i.ZP.createElement("div",{ref:f,key:"sponsored-message",className:"SponsoredMessage Message open",onMouseDown:e=>{(0,ma.q)(e),P(e)},onContextMenu:Z},i.ZP.createElement("div",{className:"message-content has-shadow has-solid-background",dir:"auto"},i.ZP.createElement("div",{className:"content-inner",dir:"auto"},i.ZP.createElement("div",{className:"message-title",dir:"ltr"},r&&(0,Bn.Z)((0,u.Js)(r)||""),c&&(0,Bn.Z)(n.chatInviteTitle||(0,u.U)(g,c,r)||"")),i.ZP.createElement("div",{className:"text-content with-meta",dir:"auto",ref:I},i.ZP.createElement("span",{className:"text-content-inner",dir:"auto"},(0,Ss.H)(n.text.text,n.text.entities)),i.ZP.createElement("span",{className:"MessageMeta",dir:"ltr"},i.ZP.createElement("span",{className:"message-signature"},n.isRecommended?g("Message.RecommendedLabel"):g("SponsoredMessage")))),i.ZP.createElement(Ft.Z,{color:"secondary",size:"tiny",ripple:!0,onClick:k,className:"SponsoredMessage__button"},g(n.isBot?"Conversation.ViewBot":n.channelPostId?"Conversation.ViewPost":"Conversation.ViewChannel")))),y&&i.ZP.createElement(Eo,{isOpen:b,anchor:y,message:n,onAboutAds:M,onClose:C,onCloseAnimationEnd:S}),i.ZP.createElement(So,{isOpen:E,onClose:R}))}))),Ro=(0,i.X$)((e=>{let{isCurrentUserPremium:t,chatId:n,threadId:c,messageIds:d,messageGroups:l,isViewportNewest:m,isUnread:h,isComments:p,withUsers:g,isChannelChat:v,noAvatars:w,containerRef:b,anchorIdRef:y,memoUnreadDividerBeforeIdRef:P,memoFirstUnreadIdRef:Z,type:S,isReady:E,isScrollingRef:M,isScrollPatchNeededRef:R,threadTopMessageId:k,hasLinkedChat:T,isSchedule:A,noAppearanceAnimation:x,onFabToggle:B,onNotchToggle:L}=e;const{openHistoryCalendar:U}=(0,a.Sv)(),{observeIntersectionForReading:j,observeIntersectionForLoading:O,observeIntersectionForPlaying:F}=function(e,t,n){const{markMessageListRead:s,markMentionsRead:o,animateUnreadReaction:i}=(0,a.Sv)(),{isMobile:r}=(0,C.ZP)(),c=r?300:500,{observe:d,freeze:l,unfreeze:u}=(0,wa.S1)({rootRef:t,throttleMs:150},(t=>{if("thread"!==e)return;let a=0;const r=[],c=[];t.forEach((e=>{const{isIntersecting:t,target:n}=e;if(!t)return;const{dataset:s}=n,o=Number(s.lastMessageId||s.messageId);o>a&&(a=o),s.hasUnreadMention&&r.push(o),s.hasUnreadReaction&&c.push(o)})),n.current&&a>=n.current&&s({maxId:a}),r.length&&o({messageIds:r}),c.length&&i({messageIds:c})}));(0,it.Z)(l,u);const{observe:m}=(0,wa.S1)({rootRef:t,throttleMs:ba,margin:c}),{observe:h}=(0,wa.S1)({rootRef:t,throttleMs:ba});return{observeIntersectionForReading:d,observeIntersectionForLoading:m,observeIntersectionForPlaying:h}}(S,b,Z),{backwardsTriggerRef:_,forwardsTriggerRef:D,fabTriggerRef:q}=function(e,t,n,r,c,d,l,u,m,h){const{loadViewportMessages:p}=(0,a.Sv)(),[g,I]=(0,i.Ye)((()=>"thread"===e?[(0,N.Ds)((()=>p({direction:f.Uq.Backwards})),1e3,!0,!1),(0,N.Ds)((()=>p({direction:f.Uq.Forwards})),1e3,!0,!1)]:[]),[p,n]),v=(0,i.sO)(null),w=(0,i.sO)(null),b=(0,i.sO)(null);function y(){if(!u)return;if(!n||!n.length)return d(!1),void l(!1);if(!r)return d(!0),void l(!0);if(!t.current)return;const{offsetHeight:e,scrollHeight:a,scrollTop:s}=t.current,o=Math.round(a-s-e),i=o<=1;0!==a&&(d(c?!i:!(o<=50)),l(!i))}const{observe:P}=(0,wa.S1)({rootRef:t,margin:s.gZ},(e=>{if(!I||!g)return;if(n[0]>o.MPN)return;const t=e.find((e=>{let{isIntersecting:t}=e;return t}));if(!t)return;const{target:a}=t;"backwards-trigger"===a.className?(s.i4&&m.current&&n.length<=o.hT6&&(h.current=!0),g()):"forwards-trigger"===a.className&&I()}));(0,wa._N)(v,P),(0,wa._N)(w,P);const{observe:Z,freeze:C,unfreeze:S}=(0,wa.S1)({rootRef:t,margin:100},y);(0,wa._N)(b,Z);const{observe:E,freeze:M,unfreeze:R}=(0,wa.S1)({rootRef:t,margin:1},y);(0,wa._N)(b,E);const k=(0,i.sO)();return k.current=y,(0,ct.Z)((()=>{u&&k.current()}),[u]),(0,ct.Z)((()=>{C(),M(),setTimeout((()=>{R(),S()}),250)}),[C,M,n,S,R]),{backwardsTriggerRef:v,forwardsTriggerRef:w,fabTriggerRef:b}}(S,b,d,m,h,B,L,E,M,R),$=(0,kt.Z)(),G=i.ZP.createElement("div",{className:(0,tt.Z)("unread-divider","local-action-message"),key:"unread-messages"},i.ZP.createElement("span",null,$("UnreadMessages"))),H=x?0:l.reduce(((e,t)=>e+t.senderGroups.flat().length),0);let V=0;const z=l.map(((e,t,n)=>{const a=e.senderGroups.map(((e,a,s)=>{if(1===e.length&&!la(e[0])&&(0,u.FT)(e[0])&&!e[0].content.action?.phoneCall){const o=e[0],d=a===s.length-1&&t===n.length-1;return(0,I.oA)([o.id===P.current&&G,i.ZP.createElement(Ja,{key:o.id,message:o,isInsideTopic:Boolean(c&&c!==r._f),observeIntersectionForReading:j,observeIntersectionForLoading:O,observeIntersectionForPlaying:F,memoFirstUnreadIdRef:Z,appearanceOrder:H-++V,isLastInList:d})])}let o;return e.map(((d,l)=>{const m=la(d)?d.mainMessage:d,h=la(d)?d:void 0,f=(0,u.B4)(m),b=la(d),C=e[l+1];m.previousLocalId&&y.current===(0,u.d0)(m.previousLocalId)&&(y.current=(0,u.d0)(m.id));const E=!b&&m.groupedId?m.groupedId:void 0,M=C&&!la(C)?C.groupedId:void 0,R={isFirstInGroup:0===l,isLastInGroup:l===e.length-1,isFirstInDocumentGroup:Boolean(E&&E!==o),isLastInDocumentGroup:Boolean(E&&E!==M),isLastInList:l===e.length-1&&a===s.length-1&&t===n.length-1};o=E;const A=(0,u.KK)(m),N=(0,u.jM)(m)?`${m.date}_${A}`:A,x=!1===T||!v,B=m.id===k;return(0,I.oA)([m.id===P.current&&G,i.ZP.createElement(Co,{key:N,message:m,observeIntersectionForBottom:j,observeIntersectionForLoading:O,observeIntersectionForPlaying:F,album:h,noAvatars:w,withAvatar:R.isLastInGroup&&g&&!f&&(!B||!p),withSenderName:R.isFirstInGroup&&g&&!f,threadId:c,messageListType:S,noComments:x,noReplies:!x||c!==r._f,appearanceOrder:H-++V,isFirstInGroup:R.isFirstInGroup,isLastInGroup:R.isLastInGroup,isFirstInDocumentGroup:R.isFirstInDocumentGroup,isLastInDocumentGroup:R.isLastInDocumentGroup,isLastInList:R.isLastInList,memoFirstUnreadIdRef:Z}),m.id===k&&i.ZP.createElement("div",{className:"local-action-message",key:"discussion-started"},i.ZP.createElement("span",null,$("DiscussionStarted")))])})).flat()}));return i.ZP.createElement("div",{className:"message-date-group",key:e.datetime,onMouseDown:ma.q,teactFastList:!0},i.ZP.createElement("div",{className:(0,tt.Z)("sticky-date",!A&&"interactive"),key:"date-header",onMouseDown:ma.q,onClick:A?void 0:()=>U({selectedAt:e.datetime})},i.ZP.createElement("span",{dir:"auto"},A&&e.originalDate===o.t4X&&$("MessageScheduledUntilOnline"),A&&e.originalDate!==o.t4X&&$("MessageScheduledOn",(0,ae.j1)($,e.datetime,void 0,!0)),!A&&(0,ae.j1)($,e.datetime))),a.flat())}));return i.ZP.createElement("div",{className:"messages-container",teactFastList:!0},i.ZP.createElement("div",{ref:_,key:"backwards-trigger",className:"backwards-trigger"}),z.flat(),!t&&m&&i.ZP.createElement(Mo,{key:n,chatId:n,containerRef:b}),i.ZP.createElement("div",{ref:D,key:"forwards-trigger",className:"forwards-trigger"}),i.ZP.createElement("div",{ref:q,key:"fab-trigger",className:"fab-trigger"}))}));var ko=n(73547);const To=(0,i.X$)((0,a.c$)(((e,t)=>{let{userId:n}=t;const{stickers:a}=e.stickers.greeting,s=(0,u.db)(n)+(0,u.db)(e.currentUserId),o=a?.length?a[s%a.length]:void 0,i=(0,d.Z1)(e,n);return i?{sticker:o,lastUnreadMessageId:i.lastMessage&&i.lastMessage.id!==i.lastReadInboxMessageId?i.lastMessage.id:void 0,connectionState:e.connectionState}:{}}))((e=>{let{sticker:t,connectionState:n,lastUnreadMessageId:s}=e;const{loadGreetingStickers:o,sendMessage:r,markMessageListRead:c}=(0,a.Sv)(),d=(0,kt.Z)(),l=(0,i.sO)(null),{observe:u}=(0,wa.S1)({rootRef:l,debounceMs:200});(0,i.d4)((()=>{t||"connectionStateReady"!==n||o()}),[n,o,t]),(0,i.d4)((()=>{"connectionStateReady"===n&&s&&c({maxId:s})}),[n,c,s]);const m=(0,i.I4)((e=>{e={...e,isPreloadedGlobally:!0},r({sticker:e})}),[r]);return i.ZP.createElement("div",{className:"ContactGreeting",ref:l},i.ZP.createElement("div",{className:"wrapper"},i.ZP.createElement("p",{className:"title",dir:"auto"},d("Conversation.EmptyPlaceholder")),i.ZP.createElement("p",{className:"description",dir:"auto"},d("Conversation.GreetingText")),i.ZP.createElement("div",{className:"sticker"},t&&i.ZP.createElement(ko.Z,{sticker:t,onClick:m,clickArg:t,observeIntersection:u,size:160,className:"large",noContextMenu:!0,isCurrentUserPremium:!0}))))}))),Ao=3*Re.Gw,No=(0,i.X$)((e=>{let{isChatWithSelf:t,type:n,isGroupChatJustCreated:a,topic:s}=e;const o=(0,kt.Z)();return"scheduled"===n?function(e){return i.ZP.createElement("div",{className:"empty"},i.ZP.createElement("span",null,e("ScheduledMessages.EmptyPlaceholder")))}(o):t?function(e){return i.ZP.createElement("div",{className:"NoMessages"},i.ZP.createElement("div",{className:"wrapper"},i.ZP.createElement("i",{className:"icon icon-cloud-download"}),i.ZP.createElement("h3",{className:"title"},e("Conversation.CloudStorageInfo.Title")),i.ZP.createElement("ul",{className:"description"},i.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description1")),i.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description2")),i.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description3")),i.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description4")))))}(o):a?function(e){return i.ZP.createElement("div",{className:"NoMessages"},i.ZP.createElement("div",{className:"wrapper",dir:e.isRtl?"rtl":void 0},i.ZP.createElement("h3",{className:"title"},e("EmptyGroupInfo.Title")),i.ZP.createElement("p",{className:"description"},e("EmptyGroupInfo.Subtitle")),i.ZP.createElement("ul",{className:"list-checkmarks"},i.ZP.createElement("li",null,e("EmptyGroupInfo.Line1")),i.ZP.createElement("li",null,e("EmptyGroupInfo.Line2")),i.ZP.createElement("li",null,e("EmptyGroupInfo.Line3")),i.ZP.createElement("li",null,e("EmptyGroupInfo.Line4")))))}(o):s?function(e,t){return i.ZP.createElement("div",{className:"NoMessages"},i.ZP.createElement("div",{className:"wrapper"},i.ZP.createElement(fo.Z,{topic:t,size:Ao,className:"icon topic-icon"}),i.ZP.createElement("h3",{className:"title"},e("Chat.EmptyTopicPlaceholder.Title")),i.ZP.createElement("p",{className:"description topic-description"},(0,Bn.Z)(e("Chat.EmptyTopicPlaceholder.Text"),["br"]))))}(o,s):i.ZP.createElement("div",{className:"empty"},i.ZP.createElement("span",null,o("NoMessages")))})),xo=(0,N.Ds)((e=>e()),200,!1),Bo=(0,i.X$)((0,a.c$)(((e,t)=>{let{chatId:n,threadId:a,type:s}=t;const o=(0,d.Z1)(e,n);if(!o)return{};const i=(0,d.$W)(e,n,a,s),c="scheduled"===s?(0,d.yB)(e,n):(0,d.Zw)(e,n),l=(0,d.qS)(e,n,a),m=(0,d.tZ)(e,n,a);if(!(a===r._f||o?.isForum||c&&l&&c[l]))return{};const{isRestricted:h,restrictionReason:p,lastMessage:g}=o,f=(0,d.G$)(e,n),I=a===r._f&&!i&&!o.unreadCount&&!f&&g&&!g.groupedId,v=(0,d.IK)(e,n);let w,b=!1;(0,d.pk)(e,n)&&(v.fullInfo?w=v.fullInfo.botInfo:b=!0);const y=o.topics?.[a];return{isCurrentUserPremium:(0,d.wV)(e),isChatLoaded:!0,isRestricted:h,restrictionReason:p,isChannelChat:(0,u.eA)(o),isGroupChat:(0,u.Bf)(o),isCreator:o.isCreator,isChatWithSelf:(0,d.FM)(e,n),isRepliesChat:(0,u.pK)(n),isBot:Boolean(v),messageIds:i,messagesById:c,isComments:Boolean(m?.originChannelId),firstUnreadId:(0,d.It)(e,n,a),isViewportNewest:"thread"!==s||(0,d.b9)(e,n,a),threadFirstMessageId:(0,d.yZ)(e,n,a),focusingId:f,isSelectModeActive:(0,d.CA)(e),isLoadingBotInfo:b,botInfo:w,threadTopMessageId:l,hasLinkedChat:o.fullInfo&&"linkedChatId"in o.fullInfo?Boolean(o.fullInfo.linkedChatId):void 0,lastSyncTime:e.lastSyncTime,topic:y,...I&&{lastMessage:g}}}))((e=>{let{chatId:t,threadId:n,type:c,hasTools:l,onFabToggle:m,onNotchToggle:h,isCurrentUserPremium:p,isChatLoaded:g,isChannelChat:v,isGroupChat:w,canPost:b,isReady:y,isChatWithSelf:P,isRepliesChat:Z,isCreator:C,isBot:S,messageIds:E,messagesById:M,firstUnreadId:R,isComments:k,isViewportNewest:T,threadFirstMessageId:A,isRestricted:x,restrictionReason:B,focusingId:L,isSelectModeActive:U,lastMessage:j,isLoadingBotInfo:O,botInfo:F,threadTopMessageId:_,hasLinkedChat:D,lastSyncTime:q,withBottomShift:$,withDefaultBg:G,topic:H}=e;const{loadViewportMessages:V,setScrollOffset:z,loadSponsoredMessages:W,loadMessageReactions:X,copyMessagesByIds:Y,loadMessageViews:J}=(0,a.Sv)(),K=(0,i.sO)(null),Q=(0,i.sO)("thread"===c&&(0,d.Vt)((0,a.Rd)(),t,n)||(0,d.T6)((0,a.Rd)(),t,n)||0),ee=(0,i.sO)(),te=(0,i.sO)(),ne=(0,i.sO)(),ae=(0,i.sO)(),se=(0,i.sO)(),oe=(0,i.sO)(),ie=(0,i.sO)(!1),re=(0,i.sO)(Boolean(j)),[ce,de]=(0,i.eJ)(),le=(0,Wt.Z)(F?.photo?(0,u.NF)(F.photo):void 0),ue=(0,Wt.Z)(F?.gif?(0,u.ym)(F.gif):void 0),me=F?.photo?(0,u.bV)(F.photo):F?.gif?(0,u.jC)(F.gif):void 0,he=me&&{width:me.width/s.cL,height:me.height/s.cL},pe=Boolean(E);(0,ct.Z)((()=>{pe&&(0,N.R3)((()=>{re.current=!1}))}),[pe]),(0,ct.Z)((()=>{ae.current=R}),[R]),(0,i.d4)((()=>{!p&&v&&y&&q&&W({chatId:t})}),[p,t,y,v,q,W]),(0,ct.Z)((()=>{pe&&(se.current=ae.current)}),[pe]),(0,ct.Z)((()=>{oe.current=L}),[L]),(e=>{(0,Mt.y)({"Mod+C":function(t){const n=(0,fa.Z)();n&&n.length>1&&(t.preventDefault(),e({messageIds:n}))}})})(Y);const ge=(0,i.Ye)((()=>{if(!E||!M)return;const e=!_||A===_||E[0]&&A!==E[0]?E:[_,...E];if(!e.length)return;const t=e.map((e=>M[e])).filter(Boolean);return t.length?ua((0,I.Xo)(t,"id"),se.current):void 0}),[E,M,A,_]);(0,ft.Z)((()=>{if(!E||!M)return;const e=E.filter((e=>M[e]?.reactions));e.length&&X({chatId:t,ids:e})}),15e3),(0,ft.Z)((()=>{if(!E||!M||n!==r._f)return;const e=E.filter((e=>M[e]?.repliesThreadInfo?.isComments));e.length&&J({chatId:t,ids:e})}),15e3);const fe=(0,i.Ye)((()=>{if("thread"===c)return(0,N.Ds)((()=>V({direction:f.Uq.Around})),1e3,!0,!1)}),[V,E]),{isScrolled:Ie,updateStickyDates:ve}=function(){const[e,t]=(0,Et.Z)(!1),n=(0,ga.Z)(1e3,!0);return{isScrolled:e,updateStickyDates:(0,i.I4)(((e,a)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,N.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),n((()=>{(0,N.T2)((()=>{const t=document.querySelector(".stuck");t&&t.classList.remove("stuck");const n=function(e,t){const n=e.querySelectorAll(".sticky-date"),a=e.scrollTop;return Array.from(n).find((e=>{const{offsetTop:n,offsetHeight:s}=e,o=n-a;return-s<=o&&o<=(t?60:10)}))}(e,a);n&&n.classList.add("stuck"),document.body.classList.remove("is-scrolling-messages")}))}))}),[t,n])}}(),we=(0,i.sO)(),be=(0,i.sO)(),ye=(0,i.I4)((()=>{if(ie.current)return void(ie.current=!1);const e=K.current;e&&(we.current=!0,oe.current||ve(e,l),xo((()=>{we.current=!1,(0,N.T2)((()=>{e.parentElement&&(Q.current=e.scrollHeight-e.scrollTop,"thread"===c&&z({chatId:t,threadId:n,scrollOffset:Q.current}))}))})))}),[ve,l,c,z,t,n]),Pe=(0,i.I4)((e=>{de(e.contentRect.height)}),[]);(0,va.Z)(K,Pe);const{height:Ze}=(0,Sn.Z)();(0,i.d4)((()=>{K.current.dataset.normalHeight=String(K.current.offsetHeight)}),[Ze,b]),(0,i.d4)((()=>{if(!fe||!g||x||L)return;if(E&&E[E.length-1]>o.MPN)return;const e=K.current;(!E||E.length<o.hT6/2&&e.firstElementChild.clientHeight<=e.offsetHeight)&&fe()}),[g,E,fe,L,x]),(0,ct.Z)((()=>{if(!E||!ne.current)return;const e=ne.current.filter((e=>E.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(ee.current=t.id,te.current=t.getBoundingClientRect().top)}),[E,T,ce,l]),Ia((e=>{let[t,n,a]=e;const s=K.current;ne.current=Array.from(s.querySelectorAll(".message-list-item"));const i=E&&t&&E[E.length-1]!==t[t.length-1],r=E?.[0]!==t?.[0]&&E?.length===o.hT6/2+1,c=i&&!r,d=E&&oe.current===E[E.length-1],u=T&&c&&E&&E.length<o.hT6/2&&!s.parentElement.classList.contains("force-messages-scroll")&&s.firstElementChild.clientHeight<=2*s.offsetHeight;u&&(s.parentElement.classList.add("force-messages-scroll"),setTimeout((()=>{s.parentElement&&s.parentElement.classList.remove("force-messages-scroll")}),500));const{scrollTop:m,scrollHeight:h,offsetHeight:p}=s,g=Q.current,f=ne.current[ne.current.length-1];let I=g-(a||p);c&&(I-=f?f.offsetHeight:0);const v=T&&n&&I<=50;let w;if(c&&v&&!d&&(f&&(0,N.T2)((()=>{(0,pa.Z)(s,f,"end",20)})),w=h-p,Q.current=Math.max(Math.ceil(h-w),p),!u))return;const b=void 0!==a&&a!==ce,y=ee.current&&s.querySelector(`#${ee.current}`),P=!y&&se.current&&s.querySelector(".unread-divider");if(v&&b){if((0,pa.N)())return;w=h-p}else y?(be.current&&(be.current=!1,(0,ha.z)(s)),w=m+(y.getBoundingClientRect().top-(te.current||0))):w=P?Math.min(P.offsetTop-(l?60:10),h-g):h-g;(0,ha.Z)(s,Math.ceil(w)),oe.current||(ie.current=!0,(0,N.T2)((()=>{ie.current=!1}))),Q.current=Math.max(Math.ceil(h-w),p)}),[E,T,ce,l]),(0,ot.Z)((e=>{let[t]=e;void 0!==t&&(0,gt.YW)(200+o.fK3)}),[U]);const Ce=(0,kt.Z)(),Se=Boolean(t&&(0,u.YC)(t)),Ee=Boolean(!Se&&!v||P||Z),Me=Boolean(!Ee||v),Re=(0,u.YC)(t)&&!P&&!S&&(!ge&&!j&&E&&(!ne.current||0===ne.current.length)||1===E?.length&&"contactSignUp"===M?.[E[0]]?.content.action?.type||"contactSignUp"===j?.content?.action?.type),ke=w&&C&&1===E?.length&&"chatCreate"===M?.[E[0]]?.content.action?.type,Te=1===E?.length&&"topicCreate"===M?.[E[0]]?.content.action?.type,Ae=F&&!F.description&&!F.gif&&!F.photo,Ne=(0,tt.Z)("MessageList custom-scroll",Me&&"no-avatars",!b&&"no-composer","pinned"===c&&"type-pinned",$&&"with-bottom-shift",G&&"with-default-bg",U&&"select-mode-active",Ie&&"scrolled",!y&&"is-animating");return i.ZP.createElement("div",{ref:K,className:Ne,onScroll:ye,onMouseDown:ma.q},x?i.ZP.createElement("div",{className:"empty"},i.ZP.createElement("span",null,B?B.text:"This is a private "+(v?"channel":"chat"))):F?i.ZP.createElement("div",{className:"empty"},O&&i.ZP.createElement("span",null,Ce("Loading")),Ae&&!O&&i.ZP.createElement("span",null,Ce("NoMessages")),F&&i.ZP.createElement("div",{className:"bot-info",style:he&&`width: ${he.width}px`},le&&i.ZP.createElement("img",{src:le,width:he?.width,height:he?.height,alt:"Bot info"}),ue&&i.ZP.createElement(ys.Z,{canPlay:!0,src:ue,loop:!0,disablePictureInPicture:!0,muted:!0,playsInline:!0}),me&&!le&&!ue&&i.ZP.createElement(Us.Z,{width:he?.width,height:he?.height}),F.description&&i.ZP.createElement("div",{className:"bot-info-description"},i.ZP.createElement("p",{className:"bot-info-title"},Ce("BotInfoTitle")),(0,Bn.Z)(F.description,["br","emoji","links"])))):Re?i.ZP.createElement(To,{userId:t}):E&&(!ge||ke||Te)?i.ZP.createElement(No,{chatId:t,topic:H,type:c,isChatWithSelf:P,isGroupChatJustCreated:ke}):E&&ge||j?i.ZP.createElement(Ro,{isCurrentUserPremium:p,chatId:t,isComments:k,isChannelChat:v,messageIds:E||[j.id],messageGroups:ge||ua([j]),isViewportNewest:Boolean(T),isUnread:Boolean(R),withUsers:Ee,noAvatars:Me,containerRef:K,anchorIdRef:ee,memoUnreadDividerBeforeIdRef:se,memoFirstUnreadIdRef:ae,threadId:n,type:c,isReady:y,isScrollingRef:we,isScrollPatchNeededRef:be,threadTopMessageId:_,hasLinkedChat:D,isSchedule:!!ge&&"scheduled"===c,noAppearanceAnimation:!ge||!re.current,onFabToggle:m,onNotchToggle:h}):i.ZP.createElement(rn.Z,{color:"white",backgroundColor:"dark"}))}))),Lo=(0,i.X$)((e=>{let{icon:t,ariaLabelLang:n,unreadCount:a,onClick:s,onReadAll:o,className:r}=e;const c=(0,kt.Z)(),d=(0,i.sO)(null),{isContextMenuOpen:l,handleContextMenu:u,handleContextMenuClose:m,handleContextMenuHide:h}=(0,ta.Z)(d,!o);return i.ZP.createElement("div",{className:(0,tt.Z)("KboxtoWkfx23zfklH_Zg",r),ref:d},i.ZP.createElement(Ft.Z,{color:"secondary",round:!0,className:"sgkkv3bmIMAZS9G9BHUz",onClick:s,onContextMenu:u,ariaLabel:c(n)},i.ZP.createElement("i",{className:(0,tt.Z)("AafG9_xBi_2eJ_bFNnNg",`icon-${t}`)})),Boolean(a)&&i.ZP.createElement("div",{className:"yKN1kQ3YXf4SHHIBcotS"},(0,bt.bi)(a)),o&&i.ZP.createElement(ln.Z,{isOpen:l,onClose:m,onCloseAnimationEnd:h,autoClose:!0,positionX:"right",positionY:"bottom"},i.ZP.createElement(Ot.Z,{icon:"readchats",onClick:o},c("MarkAllAsRead"))))})),Uo="EcdaljLbQ7DJN9gbQpSC",jo=(0,i.X$)((0,a.c$)((e=>{const t=(0,d.Bt)(e);if(!t)return{};const{chatId:n,threadId:a,type:s}=t,o=(0,d.Z1)(e,n),i=o&&a===r._f&&"thread"===s;return{messageListType:s,chatId:n,reactionsCount:i?o.unreadReactionsCount:void 0,mentionsCount:i?o.unreadMentionsCount:void 0,unreadCount:i?o.unreadCount:void 0}}))((e=>{let{isShown:t,canPost:n,messageListType:s,chatId:o,unreadCount:r,reactionsCount:c,mentionsCount:d,withExtraShift:l}=e;const{focusNextReply:u,focusNextReaction:m,focusNextMention:h,fetchUnreadReactions:p,readAllMentions:g,readAllReactions:f,fetchUnreadMentions:I}=(0,a.Sv)(),v=(0,i.sO)(null),w=Boolean(c),b=Boolean(d);(0,i.d4)((()=>{w&&o&&p({chatId:o})}),[o,p,w]),(0,i.d4)((()=>{b&&o&&I({chatId:o})}),[o,I,b]);const y=(0,i.I4)((()=>{if(t)if("thread"===s)u();else{const e=v.current.parentElement.querySelector(".MessageList"),t=e.querySelectorAll(".message-list-item"),n=t[t.length-1];if(!n)return;(0,pa.Z)(e,n,"end",20)}}),[t,s,u]),P=(0,tt.Z)("quM3aP53TOfurCEOYgOE",(t||Boolean(c)||Boolean(d))&&"Gutr8PrNAFFTnrIdgK_l",(Boolean(c)||Boolean(d))&&!t&&"bHOz3QboabL0RvHuj3ku",!n&&"r7RXnwv5TF4Cf2V0d5Mf",!l&&"S98OqutuQVCNVHgTrKv4");return i.ZP.createElement("div",{ref:v,className:P},i.ZP.createElement(Lo,{icon:"heart-outline",ariaLabelLang:"AccDescrReactionMentionDown",onClick:m,onReadAll:f,unreadCount:c,className:(0,tt.Z)("wHTB_MNtk9J6I3F_4eVE",!w&&Uo,!b&&"uHEtFnXb6pb14Jf0EsDr")}),i.ZP.createElement(Lo,{icon:"mention",ariaLabelLang:"AccDescrMentionDown",onClick:h,onReadAll:g,unreadCount:d,className:!b&&Uo}),i.ZP.createElement(Lo,{icon:"arrow-down",ariaLabelLang:"AccDescrPageDown",onClick:y,unreadCount:r,className:"Hoi4yrJrfBHTmvB8TPce"}))})));var Oo=n(65723);const Fo=/\.[^/.]+$/;async function _o(e,t,a){const s=URL.createObjectURL(t),{type:i,size:r}=t;let c,d,l,u;if(o.oGt.has(i)){const n=await(0,Cn.pt)(s),{width:r,height:d}=n;u=!qo(r,d);const m=Math.max(r,d)>1280,h=i===o.s11;if(!u){if(!a?.compressedBlobUrl&&!h&&(m||"image/jpeg"!==i)){const n=await Wn(s,m?1280/Math.max(r,d):1,"image/jpeg");return URL.revokeObjectURL(s),_o(e,t,{compressedBlobUrl:n})}"image/jpeg"===i&&(e=e.replace(Fo,".jpg")),c={width:r,height:d}}l=s}else if(o.wGh.has(i)){const{videoWidth:e,videoHeight:t,duration:n}=await(0,Cn.jj)(s);u=!qo(e,t),u||(c={width:e,height:t,duration:n}),l=await(0,Cn.ud)(s)}else if(o.e74.has(i)){const{duration:e,title:t,performer:a,coverUrl:o}=await async function(e){const{fetchFromUrl:t,selectCover:a}=await n.e(8505).then(n.t.bind(n,38505,23)),s=await t(e),{common:{title:o,artist:i,picture:r},format:{duration:c}}=s,d=a(r);return{title:o,performer:i,duration:c,coverUrl:d?`data:${d.format};base64,${d.data.toString("base64")}`:void 0}}(s);d={duration:e||0,title:t,performer:a},l=o}return{blobUrl:s,filename:e,mimeType:i,size:r,quick:c,audio:d,previewBlobUrl:l,shouldSendAsFile:u||void 0,uniqueId:`${Date.now()}-${Math.random()}`,...a}}function Do(e,t){return e.map((e=>t?e.compressedBlobUrl?{...e,blobUrl:e.compressedBlobUrl}:e:{...e,shouldSendAsFile:!e.voice||void 0,shouldSendAsSpoiler:void 0}))}function qo(e,t){return Math.max(e,t)/Math.min(e,t)<=20}var $o=n(41098);function Go(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 n=t.lastChild;if(n.lastChild)for(;n.lastChild;)n=n.lastChild;const a=n.textContent.length,s=document.createRange(),o=window.getSelection();s.setStart(n,a),s.setEnd(n,a),o.removeAllRanges(),o.addRange(s),document.execCommand("delete",!1);const i=t.innerHTML;return document.body.removeChild(t),i}var Ho=n(96391);let Vo;function zo(e){Vo.focus(),e.focus()}s.cj&&(Vo=document.createElement("input"),Vo.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(Vo));var Wo=n(74288),Xo=n(33799),Yo=n(94462),Jo=n(33681),Ko=n(52400),Qo=n(86203),ei=n(71790);const ti=new RegExp(`^${o.t8f.source}$`,"g");var ni=n(56389);const ai={encoderPath:new URL(n(68973),n.b).href,reuseWorker:!0},si={type:"audio/ogg"};let oi,ii,ri;async function ci(){return oi||(oi=n.e(1161).then(n.t.bind(n,1161,23)),ii=(await oi).default,ri=new ii(ai)),oi}async function di(e){await async function(){await ci(),await ri.start()}();const t=Date.now();let n;const a=[],s=[];ri.ondataavailable=e=>{a.push(e)};const o=function(t,n){const a=t.sourceNode,o=a.context.createAnalyser();o.fftSize=64,a.connect(o);const i=o.frequencyBinCount,r=new Uint8Array(i);let c=!1;return function t(){if(c)return;o.getByteFrequencyData(r);const n=r.reduce(((e,t)=>e+t),0)/i/255;(t=>{s.push(255*t),e(t)})(n<.1?0:n),requestAnimationFrame(t)}(),()=>{c=!0}}(ri);return{stop:()=>new Promise(((e,i)=>{ri.onstop=()=>{e({blob:new Blob(a,si),duration:Math.round(((n||Date.now())-t)/1e3),waveform:s})},ri.onerror=i;const r=Math.max(0,t+1e3-Date.now());setTimeout((()=>{ri.stop(),o()}),r)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{ri.pause(),n=Date.now(),o()}),e)}}}var li=n(21262);const ui=/id="docs-internal-guid/i,mi=["H1","H2","H3","H4","H5","H6"];function hi(e){return(new DOMParser).parseFromString(e,"text/html").body}function pi(e,t){const n=document.createElement("a");return n.href=t,n.appendChild(e.cloneNode(!0)),n}function gi(e,t){const n=document.createElement(t);return n.appendChild(e.cloneNode(!0)),n}function fi(e,t){let n=t.cloneNode(!0);return e?(e.style&&"700"===e.style.fontWeight&&(n=gi(n,"strong")),e.style&&"italic"===e.style.fontStyle&&(n=gi(n,"em")),e.style&&"underline"===e.style.textDecoration&&(n=gi(n,"u")),e.style&&"line-through"===e.style.textDecoration&&(n=gi(n,"del")),e.style&&"super"===e.style.verticalAlign&&(n=gi(n,"sup")),e.style&&"sub"===e.style.verticalAlign&&(n=gi(n,"sub")),n):n}function Ii(e){const t=e.cloneNode(!0);let n=document.createTextNode(t.textContent||""),a=t;return"A"===t.nodeName&&(n=pi(n,t.href),"style"in t.childNodes[0]&&Boolean(t.childNodes[0].style)&&(a=t.childNodes[0])),n=fi(a,n),n}function vi(e){if(e.childNodes&&(e.childNodes.length<=1||"OL"===e.nodeName||"UL"===e.nodeName)){let t,n=document.createTextNode(e.textContent||"");if("UL"===e.nodeName||"OL"===e.nodeName||"LI"===e.nodeName){t=document.createElement(e.nodeName),n=document.createDocumentFragment();const a=[];for(let t=0;t<e.childNodes.length;t++)a.push(...vi(e.childNodes[t]));a.map((e=>n.appendChild(e)))}else-1!==mi.indexOf(e.nodeName)?(t=document.createElement(e.nodeName),n=Ii(e.childNodes[0])):"P"===e.nodeName?(t=document.createElement("p"),n=function(e){const t=e.cloneNode(!0);let n=document.createTextNode(t.textContent||""),a=document.createTextNode("");return"style"in t.childNodes[0]&&Boolean(t.childNodes[0].style)&&(a=t.childNodes[0]),t.childNodes[0]&&"A"===t.childNodes[0].nodeName&&(n=pi(n.cloneNode(!0),t.childNodes[0].href),a=t.childNodes[0].childNodes[0]),n=fi(a,n),n}(e)):"BR"===e.nodeName?n=e:(t=document.createElement("span"),n=Ii(e));return t?(t.appendChild(n),[t]):[e.cloneNode(!0)]}if(e.childNodes){const t=[];for(let n=0;n<e.childNodes.length;n++)t.push(...vi(e.childNodes[n]));return t}return[e]}function wi(e){return 8!==e.nodeType}var bi=n(56266);const yi=/<style>(.*?)<\/style>/gs,Pi=(e,t,n,a,s,c)=>{(0,i.d4)((()=>{if(e)return document.addEventListener("paste",i,!1),()=>{document.removeEventListener("paste",i,!1)};async function i(e){if(!e.clipboardData)return;const i=document.activeElement;if(i&&![o.R2F,o.nYf].includes(i.id))return;const d=e.clipboardData.getData("text").substring(0,4096),l=e.clipboardData.getData("text/html");let u=l?(0,w.ZP)(function(e){let t=document.createElement("div");try{e=(n=e).match(ui)?function(e){const t=document.createElement("body"),n=e.childNodes,a=Array.from(n).filter(wi),s=[];for(const e of a)s.push(...vi(e));for(let e=0;e<s.length;e++)t.appendChild(s[e].cloneNode(!0));return t}(hi(n.replace(/(\r\n|\n|\r)/,""))).innerHTML:hi(n.replace(/(\r\n|\n|\r)/,"")).innerHTML}catch(e){o.eMD&&console.error(e)}var n;t.innerHTML=e.replace(/\u00a0/g," ").replace(yi,"");const a=t.querySelectorAll(".text-content");return a.length&&(t=a[a.length-1]),Array.from(t.getElementsByTagName("*")).forEach((e=>{if(e instanceof HTMLElement)switch(e.removeAttribute("style"),"BR"===e.tagName&&e.replaceWith("\n"),"P"===e.tagName&&e.appendChild(document.createTextNode("\n")),"IMG"!==e.tagName||e.dataset.entityType||e.replaceWith(e.getAttribute("alt")||""),e.dataset.ignoreOnPaste&&e.remove(),w.xe[e.tagName]&&e.setAttribute("data-entity-type",w.xe[e.tagName]),e.dataset.entityType||e.textContent!==e.innerText||e.replaceWith(e.textContent),e.dataset.alt&&e.setAttribute("alt",e.dataset.alt),e.dataset.entityType){case r.Vv.MentionName:e.replaceWith(e.textContent||"");break;case r.Vv.CustomEmoji:e.textContent=e.dataset.alt||""}})),t.innerHTML.trimEnd()}(l),void 0,!0):void 0;u&&(0,bi.Lo)(u)&&s&&(u=(0,bi.If)(u),c?.());const{items:m}=e.clipboardData;let h=[];if(e.preventDefault(),m.length>0&&(h=await(0,li.Z)(m)),!h?.length&&!d)return;if(h?.length&&!a){const e=await Promise.all(h.map((e=>_o(e.name,e))));n((t=>t.concat(e)))}const p=u?.entities?.length?u:{text:d};p&&t(p,i?.id)}}),[t,a,n,e,s,c])};var Zi=n(28353),Ci=n(29295),Si=n(16580),Ei=n(11309);const Mi=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,Ri=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i,ki={username:"",query:"",canShowHelp:!1,usernameLowered:""},Ti=document.createElement("div");const Ai=(0,Si.Z)(((e,t,n)=>({username:e,query:t,canShowHelp:n,usernameLowered:e.toLowerCase()}))),Ni=/^\/([\w@]{1,32})?$/i;var xi=n(33057),Bi=n(60130);function Li(e){return e.shouldSendAsFile?"file":o.oGt.has(e.mimeType)?"image":o.wGh.has(e.mimeType)?"video":o.e74.has(e.mimeType)?"audio":"file"}var Ui=n(69156),ji=n(70971);let Oi=!1;const Fi=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"DeleteMessageModal",!t);return n?i.ZP.createElement(n,e):void 0}));var _i=n(43521),Di=n(85655),qi=n(56503),$i=n(62898);const Gi="N3E1geoPu1vesCKf545F",Hi=/#fff/gi,Vi=(0,i.X$)((e=>{let{icon:t,theme:n}=e;const a=(0,Wt.Z)((0,u.ym)(t),!1,r.IU.Text),o=(0,i.Ye)((()=>{if(!a)return"";const e="dark"===n?"rgb(170, 170, 170)":"rgb(112, 117, 121)",t=a.replace(Hi,e),s=(new DOMParser).parseFromString(t,"image/svg+xml");return s.querySelectorAll("path").forEach((t=>{t.style.stroke=e,t.style.strokeWidth="0.5px"})),`data:image/svg+xml;utf8,${s.documentElement.outerHTML}`}),[a,n]);return i.ZP.createElement("i",{className:(0,tt.Z)("vL8HfVVnjTeFmp1ECFj8",s.FW&&Gi)},i.ZP.createElement("img",{src:o,alt:"",className:(0,tt.Z)("Fb4aIyDYEwOlaqY8oZkV",s.FW&&Gi)}))})),zi=(0,i.X$)((e=>{let{bot:t,theme:n,chatId:s,threadId:o,onMenuOpened:r,onMenuClosed:c}=e;const{callAttachBot:d,toggleAttachBot:l}=(0,a.Sv)(),u=(0,kt.Z)(),m=(0,i.Ye)((()=>t.icons.find((e=>{let{name:t}=e;return"default_static"===t}))?.document),[t.icons]),[h,p,g]=(0,Et.Z)(),[f,I]=(0,i.eJ)(void 0),v=(0,i.I4)((e=>{e.preventDefault();const t=e.currentTarget.getBoundingClientRect();I({x:t.right,y:t.bottom}),r(),p()}),[r,p]),w=(0,i.I4)((()=>{g(),c()}),[g,c]),b=(0,i.I4)((()=>{I(void 0)}),[]),y=(0,i.I4)((()=>{l({botId:t.id,isEnabled:!1})}),[t.id,l]);return i.ZP.createElement(Ot.Z,{key:t.id,customIcon:m&&i.ZP.createElement(Vi,{icon:m,theme:n}),icon:m?void 0:"bots",onClick:()=>d({bot:t,chatId:s,threadId:o}),onContextMenu:v},t.shortName,f&&i.ZP.createElement($i.Z,null,i.ZP.createElement(ln.Z,{isOpen:h,positionX:"right",style:`left: ${f.x}px;top: ${f.y}px;`,className:"bot-attach-context-menu",autoClose:!0,onClose:w,onCloseAnimationEnd:b},i.ZP.createElement(Ot.Z,{icon:"stop",destructive:!0,onClick:y},u("WebApp.RemoveBot")))))})),Wi=(0,i.X$)((e=>{let{chatId:t,threadId:n,isButtonVisible:a,canAttachMedia:r,canAttachPolls:c,canSendPhotos:d,canSendVideos:l,canSendDocuments:u,canSendAudios:m,attachBots:h,peerType:p,isScheduled:g,onFileSelect:f,onPollCreate:I,theme:v}=e;const[w,b,y]=(0,Et.Z)(),[P,Z,C]=(0,qi.Z)(w,y),S=d&&l,E=d||l,[M,R,k]=(0,Et.Z)();(0,i.d4)((()=>{w&&C()}),[w,C]);const T=(0,i.I4)((()=>{w?y():b()}),[w,b,y]),A=(0,i.I4)(((e,t)=>{const{files:n}=e.target,a=(0,Cn.ox)(n);a?.length&&f(a,t)}),[f]),N=(0,i.I4)((()=>{(0,Di.g)(Array.from(S?o.dII:d?o.oGt:o.wGh).join(","),(e=>A(e,!0)))}),[d,S,A]),x=(0,i.I4)((()=>{(0,Di.g)(!u&&m?Array.from(o.e74).join(","):"*",(e=>A(e,!1)))}),[m,u,A]),B=(0,i.Ye)((()=>Object.values(h).filter((e=>!!p&&(!("bots"!==p||e.id!==t||!e.peerTypes.includes("self"))||e.peerTypes.includes(p))))),[h,t,p]),L=(0,kt.Z)();if(a)return i.ZP.createElement("div",{className:"AttachMenu"},i.ZP.createElement(_i.Z,{id:"attach-menu-button",className:w?"AttachMenu--button activated":"AttachMenu--button",round:!0,color:"translucent",onActivate:T,ariaLabel:"Add an attachment",ariaControls:"attach-menu-controls",hasPopup:!0},i.ZP.createElement("i",{className:"icon-attach"})),i.ZP.createElement(ln.Z,{id:"attach-menu-controls",isOpen:w||M,autoClose:!0,positionX:"right",positionY:"bottom",onClose:y,className:"AttachMenu--menu fluid",onCloseAnimationEnd:y,onMouseEnter:s.$b?void 0:P,onMouseLeave:s.$b?void 0:Z,noCloseOnBackdrop:!s.$b,ariaLabelledBy:"attach-menu-button"},!r&&i.ZP.createElement(Ot.Z,{className:"media-disabled",disabled:!0},"Posting media content is not allowed in this group."),r&&i.ZP.createElement(i.ZP.Fragment,null,E&&i.ZP.createElement(Ot.Z,{icon:"photo",onClick:N},L(S?"AttachmentMenu.PhotoOrVideo":d?"InputAttach.Popover.Photo":"InputAttach.Popover.Video")),(u||m)&&i.ZP.createElement(Ot.Z,{icon:"document",onClick:x},L(!u&&m?"InputAttach.Popover.Music":"AttachDocument"))),c&&i.ZP.createElement(Ot.Z,{icon:"poll",onClick:I},L("Poll")),r&&!g&&B.map((e=>i.ZP.createElement(zi,{bot:e,chatId:t,threadId:n,theme:v,onMenuOpened:R,onMenuClosed:k})))))})),Xi=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"InlineBotTooltip",!t);return n?i.ZP.createElement(n,e):void 0})),Yi=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"MentionTooltip",!t);return n?i.ZP.createElement(n,e):void 0}));var Ji=n(67146);const Ki=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"StickerTooltip",!t);return n?i.ZP.createElement(n,e):void 0}));var Qi=n(93219),er=n(19830);const tr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"BotCommandTooltip",!t);return n?i.ZP.createElement(n,e):void 0})),nr=(0,i.X$)((0,a.c$)(((e,t)=>{let{messageId:n}=t;const{chatId:a}=(0,d.Bt)(e)||{};return a?{message:(0,d.hj)(e,a,n)}:{}}))((e=>{let{isOpen:t,message:n,onClose:o}=e;const{clickBotInlineButton:r}=(0,a.Sv)(),[c,d]=(0,qi.Z)(t,o),{isKeyboardSingleUse:l}=n||{};if(n&&n.keyboardButtons)return i.ZP.createElement(ln.Z,{isOpen:t,autoClose:l,positionX:"right",positionY:"bottom",onClose:o,className:"BotKeyboardMenu",onCloseAnimationEnd:o,onMouseEnter:s.$b?void 0:c,onMouseLeave:s.$b?void 0:d,noCompact:!0},i.ZP.createElement("div",{className:"content"},n.keyboardButtons.map((e=>i.ZP.createElement("div",{className:"row"},e.map((e=>i.ZP.createElement(Ft.Z,{ripple:!0,disabled:"unsupported"===e.type,onClick:()=>r({messageId:n.id,button:e})},e.text))))))))})));var ar=n(49841),sr=n(17891),or=n(63394),ir=n(66902);const rr=(0,i.X$)((0,a.c$)(((e,t)=>{let{shouldForceShowEditing:n}=t;const{chatId:a,threadId:s,type:o}=(0,d.Bt)(e)||{};if(!a||!s||!o)return{};const{forwardMessages:{fromChatId:i,toChatId:r,messageIds:c,noAuthors:l,noCaptions:m}}=(0,d.jU)(e),h=(0,d.Yy)(e,a,s),p="scheduled"===o?(0,d.wU)(e,a):(0,d._$)(e,a,s),g=e.settings.byKey.animationLevel>=1,f=r===a,I=c?.map((t=>(0,d.hj)(e,i,t)));let v,w;if(h&&!n?v=(0,d.hj)(e,a,h):p?v=(0,d.kK)(e,a,s,o):f&&1===c.length&&(v=I?.[0]),h&&v&&!n){const{forwardInfo:t}=v,n=(0,d.FM)(e,a);t&&(t.isChannelPost||n)&&(w=(0,d.cv)(e,v)),w||t?.hiddenUserName||(w=(0,d.Ur)(e,v))}else f&&(v&&(w=(0,d.cv)(e,v),w||(w=(0,d.Ur)(e,v))),w||(w=(0,u.YC)(i)?(0,d.dy)(e,i):(0,d.Z1)(e,i)));const b=I?.some((e=>e?.content.text&&Object.keys(e.content).length>1));return{replyingToId:h,editingId:p,message:v,sender:w,shouldAnimate:g,forwardedMessagesCount:f?c.length:void 0,noAuthors:l,noCaptions:m,forwardsHaveCaptions:b,isCurrentUserPremium:(0,d.wV)(e)}}))((e=>{let{replyingToId:t,editingId:n,message:s,sender:o,shouldAnimate:r,forwardedMessagesCount:c,noAuthors:d,noCaptions:l,forwardsHaveCaptions:m,shouldForceShowEditing:h,isCurrentUserPremium:p,onClear:g}=e;const{setReplyingToId:f,setEditingId:I,focusMessage:v,changeForwardRecipient:w,setForwardNoAuthors:b,setForwardNoCaptions:y,exitForwardMode:P}=(0,a.Sv)(),Z=(0,i.sO)(null),C=(0,kt.Z)(),S=Boolean(c),E=Boolean((t||n)&&s||o&&c),M=(0,sr.Z)([c],c?300:void 0),{shouldRender:R,transitionClassNames:k}=(0,pt.Z)(M&&E,void 0,!r,void 0,!r),T=(0,i.I4)((()=>{t&&!h?f({messageId:void 0}):n?I({messageId:void 0}):c&&P(),g?.()}),[t,h,n,c,g,f,I,P]);(0,i.d4)((()=>E?(0,Ct.Z)(T):void 0),[E,T]);const A=(0,i.I4)((()=>{S||v({chatId:s.chatId,messageId:s.id,noForumTopicPanel:!0})}),[v,S,s]),N=(0,i.I4)((e=>{e.stopPropagation(),T()}),[T]),x=(0,i.I4)((()=>{w()}),[w]),{isContextMenuOpen:B,contextMenuPosition:L,handleContextMenu:U,handleContextMenuClose:j,handleContextMenuHide:O}=(0,ta.Z)(Z),F=(0,i.I4)((()=>Z.current),[]),_=(0,i.I4)((()=>Z.current),[]),D=(0,i.I4)((()=>Z.current.querySelector(".forward-context-menu .bubble")),[]),{positionX:q,positionY:$,transformOriginX:G,transformOriginY:H,style:V}=(0,or.Z)(L,F,_,D),z=(0,tt.Z)("ComposerEmbeddedMessage",k),W=(0,i.Ye)((()=>t&&!h?"icon-reply":n?"icon-edit":S?"icon-forward":void 0),[n,S,t,h]),X=c&&c>1?C("ForwardedMessageCount",c):void 0,Y=(0,i.Ye)((()=>{if(!s||!S||!s.content.text||!d||p)return s;const e=(0,u.If)(s.content.text);return{...s,content:{...s.content,text:e}}}),[p,S,s,d]);if(R)return i.ZP.createElement("div",{className:z,ref:Z,onContextMenu:U,onClick:U},i.ZP.createElement("div",null,i.ZP.createElement("div",{className:"embedded-left-icon"},i.ZP.createElement("i",{className:W})),i.ZP.createElement(Ka,{className:"inside-input",message:Y,sender:d?void 0:o,customText:X,title:n?C("EditMessage"):d?C("HiddenSendersNameDescription"):void 0,onClick:A,hasContextMenu:S}),i.ZP.createElement(Ft.Z,{className:"embedded-cancel",round:!0,faded:!0,color:"translucent",ariaLabel:C("Cancel"),onClick:N},i.ZP.createElement("i",{className:"icon-close"})),S&&i.ZP.createElement(ln.Z,{isOpen:B,transformOriginX:G,transformOriginY:H,positionX:q,positionY:$,style:V,className:"forward-context-menu",onClose:j,onCloseAnimationEnd:O},i.ZP.createElement(Ot.Z,{icon:d?void 0:"message-succeeded",customIcon:d?i.ZP.createElement("i",{className:"icon-placeholder"}):void 0,onClick:()=>b({noAuthors:!1})},C(c>1?"ShowSenderNames":"ShowSendersName")),i.ZP.createElement(Ot.Z,{icon:d?"message-succeeded":void 0,customIcon:d?void 0:i.ZP.createElement("i",{className:"icon-placeholder"}),onClick:()=>b({noAuthors:!0})},C(c>1?"HideSenderNames":"HideSendersName")),m&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(ir.Z,null),i.ZP.createElement(Ot.Z,{icon:l?void 0:"message-succeeded",customIcon:l?i.ZP.createElement("i",{className:"icon-placeholder"}):void 0,onClick:()=>y({noCaptions:!1})},C(c>1?"Conversation.ForwardOptions.ShowCaption":"ShowCaption")),i.ZP.createElement(Ot.Z,{icon:l?"message-succeeded":void 0,customIcon:l?void 0:i.ZP.createElement("i",{className:"icon-placeholder"}),onClick:()=>y({noCaptions:!0})},C(c>1?"Conversation.ForwardOptions.HideCaption":"HideCaption"))),i.ZP.createElement(ir.Z,null),i.ZP.createElement(Ot.Z,{icon:"replace",onClick:x},C("ChangeRecipient")))))}))),cr=(0,i.X$)((e=>{const{attachments:t}=e,n=(0,vt.Z)(st.gl.Extra,"AttachmentModal",!t.length);return n?i.ZP.createElement(n,e):void 0})),dr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"BotCommandMenu",!t);return n?i.ZP.createElement(n,e):void 0})),lr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"PollModal",!t);return n?i.ZP.createElement(n,e):void 0})),ur=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"DropArea",!t);return n?i.ZP.createElement(n,e):void 0})),mr=new RegExp(o.FM6,"i"),hr=(0,i.X$)((0,a.c$)(((e,t)=>{let{chatId:n,threadId:a}=t;const s=(0,d.tV)(e,n,a);return{theme:(0,d.Pu)(e),webPagePreview:(0,d.jU)(e).webPagePreview,noWebPage:s}}))((e=>{let{chatId:t,threadId:n,getHtml:s,isDisabled:o,webPagePreview:c,noWebPage:d,theme:l}=e;const{loadWebPagePreview:u,clearWebPagePreview:m,toggleMessageWebPage:h}=(0,a.Sv)(),p=(0,Ei.i)((()=>{const{text:e,entities:t}=(0,w.ZP)(s()),n=t?.find((e=>e.type===r.Vv.TextUrl));return n?.url||e.match(mr)?.[0]}),[s],300,!0),g=(0,ei.Z)(p,[p,s],!0);(0,i.d4)((()=>{const e=g();e?u({text:e}):(m(),h({chatId:t,threadId:n}))}),[g,t,n,m,u,h]),(0,ct.Z)((()=>{m(),h({chatId:t,threadId:n})}),[t,m,n,h]);const f=(0,Qo.Z)((()=>Boolean(c&&s()&&!d&&!o)),[o,s,d,c]),{shouldRender:I,transitionClassNames:v}=(0,pt.Z)(f),b=(0,Tn.Z)(c,!0),y=(0,i.I4)((()=>{h({chatId:t,threadId:n,noWebPage:!0})}),[t,n,h]);if(!I||!b)return;const{photo:P,...Z}=b,C={content:{webPage:Z}};return i.ZP.createElement("div",{className:(0,tt.Z)("WebPagePreview",v)},i.ZP.createElement("div",null,i.ZP.createElement("div",{className:"WebPagePreview-left-icon"},i.ZP.createElement("i",{className:"icon-link"})),i.ZP.createElement(Ls,{message:C,inPreview:!0,theme:l}),i.ZP.createElement(Ft.Z,{className:"WebPagePreview-clear",round:!0,faded:!0,color:"translucent",ariaLabel:"Clear Webpage Preview",onClick:y},i.ZP.createElement("i",{className:"icon-close"}))))}))),pr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"SendAsMenu",!t);return n?i.ZP.createElement(n,e):void 0})),gr=(0,i.X$)((e=>{let{isOpen:t,onClick:n,text:a,isDisabled:s}=e;const o=(0,i.sO)(null);return(0,i.d4)((()=>{const e=o.current;if(!e)return;const t=e.scrollWidth+1;e.closest(".Composer").style.setProperty("--bot-menu-text-width",`${t}px`)}),[t,a]),(0,i.d4)((()=>{const e=o.current;if(!e)return;const t=e.closest(".Composer");return()=>{t.style.removeProperty("--bot-menu-text-width")}}),[]),i.ZP.createElement(Ft.Z,{className:(0,tt.Z)("bot-menu",t&&"open"),round:!0,color:"translucent",disabled:s,onClick:n,ariaLabel:"Open bot command keyboard"},i.ZP.createElement("i",{className:(0,tt.Z)("bot-menu-icon","icon-webapp",t&&"open")}),i.ZP.createElement("span",{ref:o,className:"bot-menu-text"},a))}));var fr,Ir=n(23522);!function(e){e.Send="send",e.Record="record",e.Edit="edit",e.Schedule="schedule"}(fr||(fr={}));const vr="wonderful-voice-message.ogg",wr=(0,i.X$)((0,a.c$)(((e,t)=>{var n;let{chatId:a,threadId:s,messageListType:i,isMobile:r}=t;const c=(0,d.Z1)(e,a),l=a!==o.FVh?(0,d.IK)(e,a):void 0,m=Boolean(l),h=(0,d.FM)(e,a),p=(0,u.YC)(a),g=(m||!p)&&(0,d.FT)(e,a,s),f=(0,d.qy)(e,a,s),{language:I,shouldSuggestStickers:v,shouldSuggestCustomEmoji:w}=e.settings.byKey,b=e.emojiKeywords[o.pRL],y=I!==o.pRL?e.emojiKeywords[I]:void 0,P=g?g.id:void 0,Z=P?(0,d.hj)(e,a,P):void 0,{currentUserId:C}=e,S=c?.fullInfo?c?.fullInfo?.sendAsId||C:void 0,E=c?.sendAsPeerIds&&S&&(c.sendAsPeerIds.some((e=>e.id===S))?S:c?.adminRights?.anonymous?c?.id:void 0),M=E?(0,d.dy)(e,E):void 0,R=!M&&E?(0,d.Z1)(e,E):void 0,k=(0,d.uH)(e,a),T=(0,d.nA)(e,a),A=(0,d.Bt)(e),N=a===A?.chatId&&s===A?.threadId&&i===A?.type,x=(0,d.dy)(e,a),B=null===(n=x&&!x.fullInfo?.noVoiceMessages)||void 0===n||n,L="scheduled"===i?(0,d.hI)(e,a):(0,d.s)(e,a,s),U=(0,d.Yy)(e,a,s),j=(0,d.jU)(e);return{editingMessage:(0,d.kK)(e,a,s,i),connectionState:e.connectionState,replyingToId:U,draft:(0,d.Ms)(e,a,s),chat:c,isChatWithBot:m,isChatWithSelf:h,isForCurrentMessageList:N,canScheduleUntilOnline:(0,d.Eh)(e,a),isChannel:c?(0,u.eA)(c):void 0,isRightColumnShown:(0,d.Jf)(e,r),isSelectModeActive:(0,d.CA)(e),withScheduledButton:"thread"===i&&Boolean(f?.length),shouldSchedule:"scheduled"===i,botKeyboardMessageId:P,botKeyboardPlaceholder:Z?.keyboardPlaceholder,isForwarding:a===j.forwardMessages.toChatId,pollModal:j.pollModal,stickersForEmoji:e.stickers.forEmoji.stickers,customEmojiForEmoji:e.customEmojis.forEmoji.stickers,groupChatMembers:c?.fullInfo?.members,topInlineBotIds:e.topInlineBots?.userIds,currentUserId:C,lastSyncTime:e.lastSyncTime,contentToBeScheduled:j.contentToBeScheduled,shouldSuggestStickers:v,shouldSuggestCustomEmoji:w,recentEmojis:e.recentEmojis,baseEmojiKeywords:b?.keywords,emojiKeywords:y?.keywords,inlineBots:j.inlineBots.byUsername,isInlineBotLoading:j.inlineBots.isLoading,chatBotCommands:c?.fullInfo&&c.fullInfo.botCommands,botCommands:l?.fullInfo?l.fullInfo.botInfo?.commands||!1:void 0,botMenuButton:l?.fullInfo?.botInfo?.menuButton,sendAsUser:M,sendAsChat:R,sendAsId:E,editingDraft:L,requestedDraftText:k,requestedDraftFiles:T,attachBots:e.attachMenu.bots,attachMenuPeerType:(0,d.t)(e,a),theme:(0,d.Pu)(e),fileSizeLimit:(0,K.M)(e,"uploadMaxFileparts")*o.pJM,captionLimit:(0,K.M)(e,"captionLength"),isCurrentUserPremium:(0,d.wV)(e),canSendVoiceByPrivacy:B,attachmentSettings:e.attachmentSettings}}))((e=>{let{dropAreaState:t,shouldSchedule:n,canScheduleUntilOnline:c,isReady:d,isMobile:m,onDropHide:h,editingMessage:p,chatId:g,threadId:f,messageListType:I,draft:b,chat:y,isForCurrentMessageList:P,isCurrentUserPremium:Z,canSendVoiceByPrivacy:C,connectionState:S,isChatWithBot:E,isChatWithSelf:M,isChannel:R,fileSizeLimit:k,isRightColumnShown:T,isSelectModeActive:A,isForwarding:x,pollModal:B,botKeyboardMessageId:L,botKeyboardPlaceholder:U,withScheduledButton:j,stickersForEmoji:O,customEmojiForEmoji:F,groupChatMembers:_,topInlineBotIds:D,currentUserId:q,captionLimit:$,lastSyncTime:G,contentToBeScheduled:H,shouldSuggestStickers:V,shouldSuggestCustomEmoji:z,baseEmojiKeywords:W,emojiKeywords:X,recentEmojis:Y,inlineBots:J,isInlineBotLoading:K,botCommands:Q,chatBotCommands:ee,sendAsUser:te,sendAsChat:ne,sendAsId:se,editingDraft:oe,replyingToId:ie,requestedDraftText:re,requestedDraftFiles:ce,botMenuButton:de,attachBots:le,attachMenuPeerType:ue,attachmentSettings:me,theme:he}=e;const{sendMessage:pe,clearDraft:ge,showDialog:fe,forwardMessages:Ie,openPollModal:ve,closePollModal:we,loadScheduledHistory:be,openChat:ye,addRecentEmoji:Pe,sendInlineBotResult:Ze,loadSendAs:Ce,resetOpenChatWithDraft:Se,callAttachBot:Ee,addRecentCustomEmoji:Me,showNotification:Re,showAllowedMessageTypesNotification:ke}=(0,a.Sv)(),Te=(0,kt.Z)(),Ae=(0,i.sO)(null),Ne=(0,i.sO)(null),[xe,Le]=(0,Xo.Z)(""),Ue=(0,Ui.Z)(o.Edp),je=(0,i.sO)(),Oe=(0,Mn.Z)(t),{width:Fe}=Be.Z.get(),_e=y?.sendAsPeerIds,De=_e&&(_e.length>1||!_e.some((e=>e.id===q))),[qe,$e,Ge]=(0,Et.Z)(),He=(0,ni.Z)(g,f);(0,i.d4)(Wo.AU,[xe]);const Ve=(0,i.sO)(0),ze=(0,i.I4)((()=>{Ge()}),[Ge]),[We,Xe]=(0,xi.Z)(c,ze);(0,i.d4)((()=>{je.current=void 0}),[g]),(0,i.d4)((()=>{g&&G&&d&&be({chatId:g})}),[d,g,be,G,f]),(0,i.d4)((()=>{g&&y&&G&&!_e&&d&&(0,u.ZV)(y)&&Ce({chatId:g})}),[y,g,d,G,Ce,_e]);const Ye=(0,i.sO)(!1);(0,ct.Z)((e=>{let[t,n]=e;Ye.current=Boolean(g===t&&_e&&!n)}),[g,_e]),(0,i.bt)((()=>{Ae.current&&(Ae.current.innerHTML='<svg width="9" height="20" xmlns="http://www.w3.org/2000/svg"><defs><filter x="-50%" y="-14.7%" width="200%" height="141.2%" filterUnits="objectBoundingBox" id="a"><feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur stdDeviation="1" in="shadowOffsetOuter1" result="shadowBlurOuter1"/><feColorMatrix values="0 0 0 0 0.0621962482 0 0 0 0 0.138574144 0 0 0 0 0.185037364 0 0 0 0.15 0" in="shadowBlurOuter1"/></filter></defs><g fill="none" fill-rule="evenodd"><path d="M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z" fill="#000" filter="url(#a)"/><path d="M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z" fill="#FFF" class="corner"/></g></svg>')}),[]);const[Je,Ke]=(0,i.eJ)([]),Qe=Boolean(Je.length),{canSendStickers:et,canSendGifs:nt,canAttachMedia:at,canAttachPolls:st,canAttachEmbedLinks:dt,canSendVoices:lt,canSendPlainText:ut,canSendAudios:mt,canSendVideos:ht,canSendPhotos:pt,canSendDocuments:gt}=(0,i.Ye)((()=>(0,u.H5)(y,E)),[y,E]),It=!ut&&!p,{shouldSuggestCompression:vt,shouldForceCompression:wt,shouldForceAsFile:bt,handleAppendFiles:yt,handleFileSelect:Pt,onCaptionUpdate:Zt,handleClearAttachments:St,handleSetAttachments:Mt}=function(e){let{attachments:t,fileSizeLimit:n,setHtml:s,setAttachments:o,chatId:r,canSendAudios:c,canSendVideos:d,canSendPhotos:u,canSendDocuments:m}=e;const{openLimitReachedModal:h,showAllowedMessageTypesNotification:p}=(0,a.Sv)(),[g,f]=(0,i.eJ)(!1),[I,v]=(0,i.eJ)(!1),[w,b]=(0,i.eJ)(void 0),y=(0,i.I4)((()=>{o(l.D)}),[o]),P=(0,i.I4)((e=>{const a="function"==typeof e?e(t):e;if(a.length)if(a.some((e=>{const t=Li(e);return"audio"===t&&!c&&!m||"video"===t&&!d&&!m||"image"===t&&!u&&!m||"file"===t&&!m})))p({chatId:r});else if(a.some((e=>{let{size:t}=e;return t>n})))h({limit:"uploadMaxFileparts"});else{o(a);const e=a.some((e=>{const t=Li(e);return"audio"===t&&!c||"video"===t&&!d||"image"===t&&!u}));f(Boolean(e&&m)),v(!m)}else y()}),[t,c,m,u,d,r,n,y,h,o,p]);return{shouldSuggestCompression:w,handleAppendFiles:(0,i.I4)((async(e,n)=>{P([...t,...await Promise.all(e.map((e=>_o(e.name,e,{shouldSendAsSpoiler:n||void 0}))))])}),[t,P]),handleFileSelect:(0,i.I4)((async(e,t)=>{P(await Promise.all(e.map((e=>_o(e.name,e))))),b(t)}),[P]),onCaptionUpdate:s,handleClearAttachments:y,handleSetAttachments:P,shouldForceCompression:I,shouldForceAsFile:g}}({attachments:Je,setHtml:Le,setAttachments:Ke,fileSizeLimit:k,chatId:g,canSendAudios:mt,canSendVideos:ht,canSendPhotos:pt,canSendDocuments:gt}),[Rt,Tt,At]=(0,Et.Z)(),[Nt,xt,Bt]=(0,Et.Z)(),[Lt,Ut,jt]=(0,Et.Z)(),[Ot,_t,Dt]=(0,Et.Z)(),[qt,$t,Ht]=(0,Et.Z)(),[Vt,zt,Wt]=(0,Et.Z)(),{startRecordingVoice:Xt,stopRecordingVoice:Yt,pauseRecordingVoice:Jt,activeVoiceRecording:Kt,currentRecordTime:Qt,recordButtonRef:en,startRecordTimeRef:tn}=(()=>{const e=(0,i.sO)(null),[t,n]=(0,i.eJ)(),a=(0,i.sO)(),[o,r]=(0,i.eJ)();(0,i.d4)((()=>{s.s$&&s.mh&&ci()}),[]);const c=(0,i.I4)((async()=>{try{const{stop:t,pause:s}=await di((t=>{e.current&&(a.current&&Date.now()%4==0&&(e.current.style.boxShadow=`0 0 0 ${50*(t||0)}px rgba(0,0,0,.15)`),r(Date.now()))}));a.current=Date.now(),r(Date.now()),n({stop:t,pause:s})}catch(e){console.error(e)}}),[]),d=(0,i.I4)((()=>{if(t){e.current&&(e.current.style.boxShadow="none");try{return t.pause()}catch(e){return void console.error(e)}}}),[t]),l=(0,i.I4)((()=>{if(t){n(void 0),a.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,i.d4)((()=>t?(0,Ct.Z)(l):void 0),[t,l]),{startRecordingVoice:c,pauseRecordingVoice:d,stopRecordingVoice:l,activeVoiceRecording:t,currentRecordTime:o,recordButtonRef:e,startRecordTimeRef:a}})();(0,ft.Z)((()=>{He({type:"recordAudio"})}),Kt&&o.o_S),(0,i.d4)((()=>{Kt||He({type:"cancel"})}),[Kt,He]);const nn=(0,ji.Y)(Boolean(p));(0,i.d4)((()=>{xe()&&!nn.current&&He({type:"typing"})}),[xe,nn,He]);const an=y&&(0,u.Nl)(y),sn=(0,u.Hd)(y),{isEmojiTooltipOpen:on,closeEmojiTooltip:rn,filteredEmojis:cn,filteredCustomEmojis:dn,insertEmoji:ln}=(0,Zi.Z)(Boolean(d&&P&&V&&!Qe),xe,Le,void 0,Y,W,X),{isCustomEmojiTooltipOpen:un,closeCustomEmojiTooltip:mn,insertCustomEmoji:hn}=(0,Bi.Z)(Boolean(d&&P&&z&&!Qe),xe,Le,Ue,Ne,F),{isStickerTooltipOpen:pn,closeStickerTooltip:gn}=function(e,t,n){const{loadStickersForEmoji:r,clearStickersForEmoji:c}=(0,a.Sv)(),[d,l,u]=(0,Et.Z)(!1),m=(0,ei.Z)((()=>{const n=t();if(!e||!n||s.op&&n.length>8)return;if(!n.match(s.op?Jo.Z:o.t8f))return;const a=(0,Ko._)(n);return a&&(s.op&&1===(0,Yo.Z)(a)||!s.op&&Boolean(n.match(ti)))?s.op?a:a.match(/alt="(.+)"/)?.[1]:void 0}),[t,e]),h=(0,Qo.Z)((()=>Boolean(m())),[m]),p=Boolean(n?.length);return(0,i.d4)((()=>{if(!e)return;const t=m();t?p||r({emoji:t}):c()}),[e,m,p,r,c]),(0,i.d4)(u,[u,t]),{isStickerTooltipOpen:Boolean(h&&p&&!d),closeStickerTooltip:l}}(Boolean(d&&P&&V&&et&&!Qe),xe,O),{isMentionTooltipOpen:fn,closeMentionTooltip:In,insertMention:vn,mentionFilteredUsers:wn}=(0,Ci.Z)(Boolean(d&&P&&!Qe),xe,Le,Ue,Ne,_,D,q),{isOpen:bn,botId:yn,isGallery:Zn,switchPm:Cn,results:Sn,closeTooltip:En,help:Rn,loadMore:kn}=function(e,t,n,s){const{queryInlineBot:o,resetInlineBot:r,resetAllInlineBots:c}=(0,a.Sv)(),[d,l,u]=(0,Et.Z)(!1),m=(0,Ei.C)((()=>{const t=n();return e&&t.startsWith("@")?function(e){if(!e.startsWith("@"))return ki;const t=function(e){return Ti.innerHTML=e.replace(/<br>/g,"\n"),Ti.querySelectorAll("[alt]").forEach((e=>{e.innerText||(e.innerText=e.getAttribute("alt"))})),Ti.innerText}(e),n=t.match(Mi);return n?Ai(n[1],n[2],""===n[2]&&!t.match(Ri)):ki}(t):ki}),[n,e],300),{username:h,query:p,canShowHelp:g,usernameLowered:f}=(0,Qo.Z)(m,[m,n],!0);(0,ct.Z)((e=>{let[t]=e;t&&r({username:t})}),[h,r]),(0,i.d4)((()=>{f&&o({chatId:t,username:f,query:p})}),[t,p,o,f]),(0,i.d4)(u,[u,n]);const{id:I,switchPm:v,offset:w,results:b,isGallery:y,help:P}=f&&s?.[f]||{},Z=Boolean((b?.length||v)&&!d);(0,i.d4)((()=>{Z||h||c()}),[Z,c,h]);const C=(0,i.I4)((()=>{f&&o({chatId:t,username:f,query:p,offset:w})}),[t,w,p,o,f]);return{isOpen:Z,botId:I,isGallery:y,switchPm:v,results:b,closeTooltip:l,help:g&&P?`@${h} ${P}`:void 0,loadMore:C}}(Boolean(d&&P&&!Qe&&G),g,xe,J),{isOpen:Tn,close:An,filteredBotCommands:Nn}=function(e,t,n,a){const[s,o]=(0,i.eJ)(),[r,c,d]=(0,Et.Z)(!1),l=(0,Ei.C)((()=>{const n=t();return e&&n.startsWith("/")?(0,Ko._)(n).match(Ni)?.[0].trim():void 0}),[t,e],300),u=(0,ei.Z)(l,[l,t],!0);return(0,i.d4)((()=>{const e=u(),t=n||a;if(!e||!t)return void o(void 0);const s=e.substring(1),i=t.filter((e=>!s||e.command.startsWith(s)));o(i?.length?i:void 0)}),[u,n,a]),(0,i.d4)(d,[d,t]),{isOpen:Boolean(s?.length&&!r),close:c,filteredBotCommands:s}}(Boolean(d&&P&&(Q&&Q?.length||ee?.length)),xe,Q,ee),xn=(0,i.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.R2F;if(t===o.R2F&&It)return;const n=window.getSelection();let a;if(a=t===o.R2F?document.querySelector(o.Edp):document.getElementById(t),n.rangeCount){const s=n.getRangeAt(0);if((0,Ho.R)(s,t))return(0,$o.t)(e),void a.dispatchEvent(new Event("input",{bubbles:!0}))}Le(`${xe()}${e}`),requestAnimationFrame((()=>{(0,Oo.Z)(a)}))}),[It,xe,Le]),Ln=(0,i.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.R2F;const n=(0,Ss.z)(e);xn(n,t)}),[xn]),Un=(0,i.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.R2F;xn((0,Aa.yR)(e),t)}),[xn]);((e,t,n,c,d,l,u)=>{const{saveDraft:m,clearDraft:h,loadCustomEmojis:p}=(0,a.Sv)(),g=Boolean(l),f=(0,i.I4)((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(g||!u)return;const s=c();var o,i,r,d;s?m({chatId:null!==(o=e.chatId)&&void 0!==o?o:t,threadId:null!==(i=e.threadId)&&void 0!==i?i:n,draft:(0,w.ZP)(s),shouldForce:a}):h({chatId:null!==(r=e.chatId)&&void 0!==r?r:t,threadId:null!==(d=e.threadId)&&void 0!==d?d:n,shouldForce:a})}),[t,n,g,u,c,m,h]),I=(0,i.I4)((()=>{f(void 0,!0)}),[f]),v=(0,ji.Y)(f),b=(0,ga.Z)(o.r_R,!0,void 0,[t,n]);(0,ot.Z)((a=>{let[i,c,u]=a;if(t===i&&n===c&&(!e&&u&&d(""),!e?.shouldForce))return;if(l||!e)return;d((0,Ss.z)(e));const m=e.entities?.map((e=>e.type===r.Vv.CustomEmoji&&e.documentId)).filter(Boolean)||[];m.length&&p({ids:m}),s.$b||requestAnimationFrame((()=>{const e=document.querySelector(o.Edp);e&&(0,Oo.Z)(e,!0)}))}),[t,n,e,d,l,p]),(0,i.d4)((()=>()=>{g||v.current({chatId:t,threadId:n}),Oi=!0,requestAnimationFrame((()=>{Oi=!1}))}),[t,n,g,v]);const y=(0,ji.Y)(t),P=(0,ji.Y)(n);(0,i.d4)((()=>{if(Oi)return;if(!c())return void v.current();const e=y.current,t=P.current;b((()=>{y.current===e&&P.current===t&&v.current()}))}),[y,c,b,P,v]),(0,it.Z)(I),rt(I)})(b,g,f,xe,Le,p,G);const jn=(0,i.I4)((function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e||Le(""),Ke(l.D),rn(),mn(),gn(),In(),m?setTimeout((()=>jt()),350):jt()}),[Le,m,gn,mn,In,rn,jt]),[On,Fn,_n]=((e,t,n,s,r,c,d,l,m,h,p)=>{const{editMessage:g,setEditingDraft:f}=(0,a.Sv)(),[I,v]=(0,i.eJ)();(0,ot.Z)((e=>{let[a,s]=e;if(!n)return;if(p&&s!==p)return t(""),void v(!1);if(a?.id===n.id&&p===s)return;const i=!a&&h?.text.length?h:n.content.text,r=(0,Ss.z)(i);t(r),v(!0),requestAnimationFrame((()=>{const e=document.querySelector(o.Edp);e&&(0,Oo.Z)(e,!0)}))}),[n,p,t]),(0,i.d4)((()=>{if(n)return()=>{const t=(0,w.ZP)(e()),n=t.text.length?t:void 0;f({chatId:c,threadId:d,type:l,text:n})}}),[c,n,e,f,d,l]);const b=(0,i.I4)((()=>{m&&(0,N.T2)((()=>{t((0,Ss.z)(m));const e=document.querySelector(o.Edp);e&&requestAnimationFrame((()=>{(0,Oo.Z)(e,!0)}))}))}),[m,t]),y=(0,i.I4)((()=>{s(),b()}),[s,b]),P=(0,i.I4)((()=>{const{text:t,entities:a}=(0,w.ZP)(e());n&&(t||(0,u.u8)(n)?(g({text:t,entities:a}),s(),b()):r())}),[g,n,e,r,s,b]),Z=(0,i.I4)((()=>{if(!n)return;const t=(0,w.ZP)(e()),a=t.text.length?t:void 0;f({chatId:c,threadId:d,type:l,text:a})}),[c,n,e,f,d,l]);return(0,it.Z)(Z),rt(Z),[P,y,I]})(xe,Le,p,jn,$t,g,f,I,b,oe,ie),Dn=(0,ji.Y)(jn),qn=(0,ji.Y)(Yt);(0,i.d4)((()=>()=>{qn.current(),Dn.current()}),[g,f,Dn,qn]);const $n=(0,i.I4)((()=>{const e=Ve.current;Re(e?{message:Te("UnlockPremiumEmojiHint2"),action:{action:"openChat",payload:{id:q,shouldReplaceHistory:!0}},actionText:Te("Open")}:{message:Te("UnlockPremiumEmojiHint"),action:{action:"openPremiumModal",payload:{initialSection:"animated_emoji"}},actionText:Te("PremiumMore")}),Ve.current=Number(!e)}),[q,Te,Re]),Gn=(0,Qo.Z)((()=>p&&_n?fr.Edit:!s.mh||Kt||x||xe()&&!Qe?n?fr.Schedule:fr.Send:fr.Record),[Kt,p,xe,Qe,x,_n,n]),Hn=!n,{isContextMenuOpen:Vn,handleContextMenu:zn,handleContextMenuClose:Wn,handleContextMenuHide:Xn}=(0,ta.Z)(en,!(Gn===fr.Send&&Hn));Pi(P,Ln,Mt,p,!Z&&!M,$n);const Yn=(0,i.I4)((()=>{p&&Fn()}),[p,Fn]),Jn=(0,i.I4)(((e,t)=>{const n=t?$:4096;if(e?.length>n){const t=e.length-n;return fe({data:{message:"MESSAGE_TOO_LONG_PLEASE_REMOVE_CHARACTERS",textParams:{"{EXTRA_CHARS_COUNT}":t.toString(),"{PLURAL_S}":t>1?"s":""},hasErrorKey:!0}}),!1}return!0}),[$,fe]),Kn=(0,i.I4)((()=>{if(sn&&!an){const e=document.querySelector(o.Edp),t=(0,v.bp)(),n=je.current&&Math.floor(t-je.current),a=sn.nextSendDate&&sn.nextSendDate>t;if(n&&n<sn.seconds||a){const s=a?sn.nextSendDate-t:sn.seconds-n;return fe({data:{message:Te("SlowModeHint",(0,ae.k9)(s)),isSlowMode:!0,hasErrorKey:!1}}),e?.blur(),!1}}return!0}),[an,Te,fe,sn]),Qn=(0,i.I4)((e=>{let{attachments:t,sendCompressed:n=me.shouldCompress,sendGrouped:a=me.shouldSendGrouped,isSilent:s,scheduledAt:o}=e;if("connectionStateReady"!==S)return;const{text:i,entities:r}=(0,w.ZP)(xe());(i||t.length)&&Jn(i,!0)&&Kn()&&(pe({text:i,entities:r,scheduledAt:o,isSilent:s,shouldUpdateStickerSetsOrder:!0,attachments:Do(t,n),shouldGroupMessages:a}),je.current=(0,v.bp)(),ge({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{jn()})))}),[me.shouldCompress,me.shouldSendGrouped,S,xe,Jn,Kn,pe,ge,g,jn]),ea=(0,i.I4)(((e,t,n,a)=>{Qn({attachments:Je,sendCompressed:e,sendGrouped:t,isSilent:n,scheduledAt:a})}),[Je,Qn]),na=(0,i.I4)((async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1?arguments[1]:void 0;if("connectionStateReady"!==S)return;let n=Je;if(Kt){const e=await Yt();if(e){const{blob:t,duration:a,waveform:s}=e;n=[await _o(vr,t,{voice:{duration:a,waveform:s}})]}}const{text:a,entities:i}=(0,w.ZP)(xe());if(n.length)return void Qn({attachments:n});if(!a&&!x)return;if(!Jn(a))return;const r=document.querySelector(o.Edp);if(a){if(!Kn())return;pe({text:a,entities:i,scheduledAt:t,isSilent:e,shouldUpdateStickerSetsOrder:!0})}x&&Ie({scheduledAt:t,isSilent:e}),je.current=(0,v.bp)(),ge({chatId:g,localOnly:!0}),s.cj&&r&&r===document.activeElement&&zo(r),requestAnimationFrame((()=>{jn()}))}),[S,Je,Kt,xe,x,Jn,ge,g,Yt,Qn,Kn,pe,Ie,jn]),aa=(0,i.I4)((()=>{"webApp"===de?.type&&Ee({chatId:g,url:de.url,threadId:f})}),[de,Ee,g,f]),sa=(0,i.I4)((()=>{jt(),xt()}),[jt,xt]),oa=(0,i.I4)(((e,t)=>{if(e&&"queryId"in e){const{id:n,queryId:a,isSilent:s}=e;return void Ze({id:n,queryId:a,scheduledAt:t,isSilent:s})}const{isSilent:n,...a}=e||{};if(e&&0!==Object.keys(a).length)if(void 0!==e.sendCompressed||void 0!==e.sendGrouped){const{sendCompressed:a=!1,sendGrouped:s=!1}=e;ea(a,s,n,t)}else pe({...e,scheduledAt:t});else na(Boolean(n),t)}),[ea,na,Ze,pe]);(0,i.d4)((()=>{H&&We((e=>{oa(H,e)}))}),[H,oa,We]),(0,i.d4)((()=>{re&&(Le(re),Se(),requestAnimationFrame((()=>{const e=document.getElementById(o.R2F);(0,Oo.Z)(e,!0)})))}),[re,Se,Le]),(0,i.d4)((()=>{ce?.length&&(Pt(ce),Se())}),[Pt,ce,Se]);const ia=(0,i.I4)(((e,t)=>{e.isFree||Z||M?Un(e,t):$n()}),[Un,M,Z,$n]),ra=(0,i.I4)((e=>{ia(e,o.nYf)}),[ia]),ca=(0,i.I4)(((e,t,a)=>{n||a?($e(),We((n=>{Ge(),oa({gif:e,isSilent:t},n),requestAnimationFrame((()=>{jn(!0)}))}))):(pe({gif:e,isSilent:t}),requestAnimationFrame((()=>{jn(!0)})))}),[n,$e,We,Ge,oa,jn,pe]),da=(0,i.I4)((function(e,t,a){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4?arguments[4]:void 0;e={...e,isPreloadedGlobally:!0},n||a?($e(),We((n=>{Ge(),oa({sticker:e,isSilent:t},n),requestAnimationFrame((()=>{jn(s)}))}))):(pe({sticker:e,isSilent:t,shouldUpdateStickerSetsOrder:o}),requestAnimationFrame((()=>{jn(s)})))}),[n,$e,We,Ge,oa,jn,pe]),la=(0,i.I4)(((e,t,a)=>{if("connectionStateReady"!==S)return;n||a?We((n=>{oa({id:e.id,queryId:e.queryId,isSilent:t},n)})):Ze({id:e.id,queryId:e.queryId,isSilent:t});const i=document.querySelector(o.Edp);s.cj&&i&&i===document.activeElement&&zo(i),ge({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{jn()}))}),[g,ge,S,oa,We,jn,Ze,n]),ua=(0,i.I4)((()=>{ge({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{jn()}))}),[g,ge,jn]),ma=(0,i.I4)((e=>{n?(We((t=>{oa({poll:e},t)})),we()):(pe({poll:e}),we())}),[we,oa,We,pe,n]),ha=(0,i.I4)((e=>{if(n)We((t=>{oa({...e,isSilent:!0},t)}));else if(e&&("sendCompressed"in e||"sendGrouped"in e)){const{sendCompressed:t=!1,sendGrouped:n=!1}=e;ea(t,n,!0)}else na(!0)}),[oa,na,ea,We,n]),pa=(0,i.I4)((()=>{const e=document.querySelector(o.Edp);if(!m||e!==document.activeElement)return Bt(),jt(),void _t();e?.blur(),setTimeout((()=>{Bt(),jt(),_t()}),100)}),[Bt,jt,_t,m]),fa=(0,i.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.R2F;const n=(0,Bn.Z)(e,["escape_html","emoji_html","br_html"]).join("").replace(/\u200b+/g,"");xn(n,t)}),[xn]);(0,i.d4)((()=>{It&&Le("")}),[It,Le,Je]);const Ia=(0,i.I4)((e=>{fa(e,o.nYf)}),[fa]),va=(0,i.I4)((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o.R2F;const t=window.getSelection();if(t.rangeCount){const n=t.getRangeAt(0);if((0,Ho.R)(n,e))return void document.execCommand("delete",!1)}Le(Go(xe()))}),[xe,Le]),wa=(0,i.I4)((()=>{va(o.nYf)}),[va]),ba=(0,i.I4)((()=>{ye({id:g,threadId:f,type:"scheduled",noForumTopicPanel:!0})}),[ye,g,f]);(0,i.d4)((()=>{T&&m&&jt()}),[T,jt,m]),(0,i.d4)((()=>{d&&(A?zt():setTimeout((()=>{Wt()}),200))}),[A,Wt,zt,d]);const ya=!(Gn!==fr.Record||at&&C&&lt),Pa=(0,i.I4)((()=>{switch(Gn){case fr.Send:na();break;case fr.Record:ya?C?lt||ke({chatId:g}):Re({message:Te("VoiceMessagesRestrictedByPrivacy",y?.title)}):Xt();break;case fr.Edit:On();break;case fr.Schedule:Kt&&Jt(),We((e=>{oa({},e)}))}}),[Gn,na,On,Kt,We,ya,C,Re,Te,y?.title,Xt,Jt,oa,g,ke,lt]),Za=(0,Mn.Z)(p,!0),Ca=p||Za,Sa=new Date;Sa.setSeconds(0),Sa.setMilliseconds(0);const Ea=new Date;Ea.setFullYear(Ea.getFullYear()+1);let Ma="SendMessage";switch(Gn){case fr.Edit:Ma="Save edited message";break;case fr.Record:Ma=at?"AccDescrVoiceMessage":"Conversation.DefaultRestrictedMedia"}const Ra=(0,tt.Z)("Composer",!A&&"shown",Vt&&"hover-disabled"),ka=(0,i.I4)((()=>{We((e=>{oa({},e)}))}),[oa,We]),Ta=(0,i.I4)((()=>{ha()}),[ha]),Na=(0,i.I4)(((e,t)=>{We((n=>{oa({sendCompressed:e,sendGrouped:t},n)}))}),[oa,We]),xa=(0,i.I4)(((e,t)=>{ha({sendCompressed:e,sendGrouped:t})}),[ha]),Ba=Gn===fr.Edit?On:Gn===fr.Schedule?ka:na,La=E&&"webApp"===de?.type&&!p,Ua=(0,Qo.Z)((()=>La&&!xe()&&!Kt),[La,xe,Kt]),ja=E&&"commands"===de?.type&&!p&&!1!==Q&&!Kt;return i.ZP.createElement("div",{className:Ra},at&&d&&i.ZP.createElement(ur,{isOpen:t!==Pn.t.None,withQuick:t===Pn.t.QuickFile||Oe===Pn.t.QuickFile,onHide:h,onFileSelect:Pt}),i.ZP.createElement(cr,{chatId:g,threadId:f,canShowCustomSendMenu:Hn,attachments:Je,getHtml:xe,isReady:d,shouldSuggestCompression:vt,shouldForceCompression:wt,shouldForceAsFile:bt,isForCurrentMessageList:P,onCaptionUpdate:Zt,onSendSilent:xa,onSend:ea,onSendScheduled:Na,onFileAppend:yt,onClear:St,onAttachmentsUpdate:Mt,onCustomEmojiSelect:ra,onRemoveSymbol:wa,onEmojiSelect:Ia}),i.ZP.createElement(lr,{isOpen:B.isOpen,isQuiz:B.isQuiz,shouldBeAnonymous:R,onClear:we,onSend:ma}),Ca&&i.ZP.createElement(Fi,{isOpen:qt,isSchedule:"scheduled"===I,onClose:Ht,message:Ca}),i.ZP.createElement(pr,{isOpen:Ot,onClose:Dt,chatId:g,selectedSendAsId:se,sendAsPeerIds:_e,isCurrentUserPremium:Z}),i.ZP.createElement(Yi,{isOpen:fn,filteredUsers:wn,onInsertUserName:vn,onClose:In}),i.ZP.createElement(tr,{isOpen:Tn,withUsername:Boolean(ee),botCommands:Nn,getHtml:xe,onClick:ua,onClose:An}),i.ZP.createElement("div",{id:"message-compose"},i.ZP.createElement("div",{className:"svg-appendix",ref:Ae}),i.ZP.createElement(Xi,{isOpen:bn,botId:yn,isGallery:Zn,inlineBotResults:Sn,switchPm:Cn,loadMore:kn,isSavedMessages:M,canSendGifs:nt,isCurrentUserPremium:Z,onSelectResult:la,onClose:En}),i.ZP.createElement(rr,{onClear:Yn,shouldForceShowEditing:Boolean(_n&&p)}),i.ZP.createElement(hr,{chatId:g,threadId:f,getHtml:xe,isDisabled:!dt||Qe}),i.ZP.createElement("div",{className:"message-input-wrapper"},La&&i.ZP.createElement(gr,{isOpen:Ua,text:de.text,isDisabled:Boolean(Kt),onClick:aa}),ja&&i.ZP.createElement(_i.Z,{className:(0,tt.Z)("bot-commands",Nt&&"activated"),round:!0,disabled:void 0===Q,color:"translucent",onActivate:sa,ariaLabel:"Open bot command keyboard"},i.ZP.createElement("i",{className:"icon-bot-commands-filled"})),De&&(te||ne)&&i.ZP.createElement(Ft.Z,{round:!0,color:"translucent",onClick:Ot?Dt:pa,ariaLabel:Te("SendMessageAsTitle"),className:(0,tt.Z)("send-as-button",Ye.current&&"appear-animation")},i.ZP.createElement(Ha.Z,{user:te,chat:ne,size:"tiny"})),(!It||nt||et)&&i.ZP.createElement(Ir.Z,{chatId:g,threadId:f,isMobile:m,isReady:d,isSymbolMenuOpen:Lt,openSymbolMenu:Ut,closeSymbolMenu:jt,canSendStickers:et,canSendGifs:nt,onGifSelect:ca,onStickerSelect:da,onCustomEmojiSelect:ia,onRemoveSymbol:va,onEmojiSelect:fa,closeBotCommandMenu:Bt,closeSendAsMenu:Dt,isSymbolMenuForced:qe,canSendPlainText:!It}),i.ZP.createElement(ar.Z,{ref:Ne,id:"message-input-text",editableInputId:o.R2F,chatId:g,canSendPlainText:!It,threadId:f,isActive:!Qe,getHtml:xe,placeholder:Kt&&Fe<=600?"":It?Te("Chat.PlaceholderTextNotAllowed"):U||Te("Message"),forcedPlaceholder:Rn,canAutoFocus:d&&P&&!Qe,noFocusInterception:Qe,shouldSuppressFocus:m&&Lt,shouldSuppressTextFormatter:on||fn||bn,onUpdate:Le,onSend:Ba,onSuppressedFocus:jt}),K&&Boolean(yn)&&i.ZP.createElement(Gt.Z,{color:"gray"}),j&&i.ZP.createElement(Ft.Z,{round:!0,faded:!0,className:"scheduled-button",color:"translucent",onClick:ba,ariaLabel:"Open scheduled messages"},i.ZP.createElement("i",{className:"icon-schedule"})),Boolean(L)&&!Kt&&!p&&i.ZP.createElement(_i.Z,{className:Rt?"activated":"",round:!0,color:"translucent",onActivate:Tt,ariaLabel:"Open bot command keyboard"},i.ZP.createElement("i",{className:"icon-bot-command"})),Kt&&Boolean(Qt)&&i.ZP.createElement("span",{className:"recording-state"},(0,ae.rM)(Qt-tn.current)),i.ZP.createElement(Wi,{chatId:g,threadId:f,isButtonVisible:!Kt&&!p,canAttachMedia:at,canAttachPolls:st,canSendPhotos:pt,canSendVideos:ht,canSendDocuments:gt,canSendAudios:mt,onFileSelect:Pt,onPollCreate:ve,isScheduled:n,attachBots:le,peerType:ue,theme:he}),Boolean(L)&&i.ZP.createElement(nr,{messageId:L,isOpen:Rt,onClose:At}),Q&&i.ZP.createElement(dr,{isOpen:Nt,botCommands:Q,onClose:Bt}),i.ZP.createElement(Qi.Z,{chatId:g,isOpen:un,onCustomEmojiSelect:hn,addRecentCustomEmoji:Me,onClose:mn}),i.ZP.createElement(Ki,{chatId:g,threadId:f,isOpen:pn,onStickerSelect:da,onClose:gn}),i.ZP.createElement(er.Z,{isOpen:on,emojis:cn,customEmojis:dn,addRecentEmoji:Pe,addRecentCustomEmoji:Me,onEmojiSelect:ln,onCustomEmojiSelect:ln,onClose:rn}))),Kt&&i.ZP.createElement(Ft.Z,{round:!0,color:"danger",className:"cancel",onClick:Yt,ariaLabel:"Cancel voice recording"},i.ZP.createElement("i",{className:"icon-delete"})),i.ZP.createElement(Ft.Z,{ref:en,round:!0,color:"secondary",className:(0,tt.Z)(Gn,!d&&"not-ready",Kt&&"recording"),disabled:ya,allowDisabledClick:!0,ariaLabel:Te(Ma),onClick:Pa,onContextMenu:Gn===fr.Send&&Hn?zn:void 0},i.ZP.createElement("i",{className:"icon-send"}),i.ZP.createElement("i",{className:"icon-schedule"}),i.ZP.createElement("i",{className:"icon-microphone-alt"}),i.ZP.createElement("i",{className:"icon-check"})),Hn&&i.ZP.createElement(Ji.Z,{isOpen:Vn,onSendSilent:M?void 0:Ta,onSendSchedule:n?void 0:ka,onClose:Wn,onCloseAnimationEnd:Xn,isSavedMessages:M}),Xe)}))),br=(0,i.X$)((e=>{const{isActive:t}=e,n=(0,vt.Z)(st.gl.Extra,"MobileSearch",!t,!0);return n?i.ZP.createElement(n,e):void 0})),yr=(0,i.X$)((e=>{const{isActive:t}=e,n=(0,vt.Z)(st.gl.Extra,"MessageSelectToolbar",!t);return n?i.ZP.createElement(n,e):void 0})),Pr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"UnpinAllMessagesModal",!t);return n?i.ZP.createElement(n,e):void 0})),Zr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"SeenByModal",!t);return n?i.ZP.createElement(n,e):void 0})),Cr=(0,i.X$)((e=>{const{activeEmojiInteraction:t}=e,n=(0,vt.Z)(st.gl.Extra,"EmojiInteractionAnimation",!t);return n?i.ZP.createElement(n,e):void 0})),Sr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"ReactorListModal",!t);return n?i.ZP.createElement(n,e):void 0})),Er=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"GiftPremiumModal",!t);return n?i.ZP.createElement(n,e):void 0})),Mr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"MessageLanguageModal",!t);return n?i.ZP.createElement(n,e):void 0}));function Rr(e){return"file"===e.kind&&e.type&&o.oGt.has(e.type)}const kr=(0,i.X$)((0,a.c$)(((e,t)=>{let{isMobile:n}=t;const a=(0,d.Pu)(e),{isBlurred:s,background:i,backgroundColor:c,patternColor:l}=e.settings.themes[a]||{},{messageLists:m,isLeftColumnShown:h,activeEmojiInteractions:p,seenByModal:g,giftPremiumModal:f,reactorModal:I,audioPlayer:v,shouldSkipHistoryAnimations:w,messageLanguageModal:b}=(0,d.jU)(e),y=(0,d.Bt)(e),{chats:{listIds:P},lastSyncTime:Z}=e,C={theme:a,customBackground:i,backgroundColor:c,patternColor:l,isLeftColumnShown:h,isRightColumnShown:(0,d.Jf)(e,n),isBackgroundBlurred:s,hasCurrentTextSearch:Boolean((0,d.n5)(e)),isSelectModeActive:(0,d.CA)(e),isSeenByModalOpen:Boolean(g),isReactorListModalOpen:Boolean(I),isGiftPremiumModalOpen:f?.isOpen,isMessageLanguageModalOpen:Boolean(b),animationLevel:e.settings.byKey.animationLevel,currentTransitionKey:Math.max(0,m.length-1),activeEmojiInteractions:p,lastSyncTime:Z};if(!y||!P.active)return C;const{chatId:S,threadId:E,type:M}=y,R=(0,u.YC)(S),k=(0,d.Z1)(e,S),T=(0,d.IK)(e,S),A=(0,d.KB)(e,S,E),{chatId:N,messageId:x}=v,B=(0,d.tZ)(e,S,E),L=Boolean(B?.originChannelId),U=k&&(0,u.Qm)(k,E,L),j=(0,d.pk)(e,S),O="pinned"===M,F="scheduled"===M,_="thread"===M&&E===r._f,D=Boolean(k&&(0,u.eA)(k)),q=Boolean(k&&_&&(D||(0,u.ZV)(k))&&k.isNotJoined&&!k.joinRequests),$=Boolean(k?.isNotJoined&&k.isJoinToSend),G=Boolean(k?.isNotJoined&&k.isJoinRequest),H=Boolean(T&&(0,d.s4)(e,T.id)),V=!H&&j,z=Boolean(k&&(0,u.Bf)(k)&&!k.fullInfo&&Z),W=(0,d.Yy)(e,S,E),X=!!k?.isForum&&E===r._f&&!W&&k.topics?.[o.OxA]?.isClosed,Y=N&&x?(0,d.hj)(e,N,x):void 0;return{...C,chatId:S,threadId:E,messageListType:M,chat:k,replyingToId:W,isPrivate:R,areChatSettingsLoaded:Boolean(k?.settings),canPost:!O&&(!k||U)&&!j&&!($&&k?.isNotJoined)&&!X,isPinnedMessageList:O,isScheduledMessageList:F,currentUserBannedRights:k?.currentUserBannedRights,defaultBannedRights:k?.defaultBannedRights,hasPinned:E!==r._f&&!k?.isForum||Boolean(!O&&A?.length),hasAudioPlayer:Boolean(Y),pinnedMessagesCount:A?A.length:0,shouldSkipHistoryAnimations:w,isChannel:D,canSubscribe:q,canStartBot:V,canRestartBot:H,shouldJoinToSend:$,shouldSendJoinRequest:G,shouldLoadFullChat:z}}))((e=>{let{chatId:t,threadId:n,messageListType:r,isMobile:c,chat:d,replyingToId:l,isPrivate:m,isPinnedMessageList:h,canPost:p,currentUserBannedRights:g,defaultBannedRights:f,hasPinned:I,hasAudioPlayer:v,pinnedMessagesCount:w,customBackground:b,theme:y,backgroundColor:P,patternColor:Z,isLeftColumnShown:S,isRightColumnShown:E,isBackgroundBlurred:M,hasCurrentTextSearch:R,isSelectModeActive:k,isSeenByModalOpen:T,isReactorListModalOpen:A,isGiftPremiumModalOpen:N,isMessageLanguageModalOpen:x,animationLevel:B,shouldSkipHistoryAnimations:L,currentTransitionKey:U,isChannel:j,areChatSettingsLoaded:O,canSubscribe:F,canStartBot:_,canRestartBot:D,activeEmojiInteractions:q,shouldJoinToSend:$,shouldSendJoinRequest:G,shouldLoadFullChat:H,lastSyncTime:V}=e;const{openChat:z,openPreviousChat:W,unpinAllMessages:X,loadUser:Y,loadChatSettings:J,closeLocalTextSearch:K,exitMessageSelectMode:Q,joinChannel:ee,sendBotCommand:te,restartBot:ne,showNotification:ae,loadFullChat:se}=(0,a.Sv)(),{width:oe}=(0,Sn.Z)(),{isTablet:ie}=(0,C.ZP)(),re=(0,kt.Z)(),[ce,de]=(0,i.eJ)(Pn.t.None),[le,ue]=(0,i.eJ)(),[me,he]=(0,i.eJ)(),[pe,ge]=(0,i.eJ)(!1),fe=c&&R,Ie=c?450+o.fK3:void 0,ve=I&&(oe<o.l35||E&&oe>o._mX&&oe<o.QU1||oe>=o.ksF&&oe<o.jT7&&v),we=(0,En.Z)(t,Ie),be=(0,En.Z)(n,Ie),ye=(0,En.Z)(r,Ie),Pe=(0,En.Z)(F,Ie),Ze=(0,En.Z)(_,Ie),Ce=(0,En.Z)(D,Ie),Se=(0,En.Z)(p,Ie)&&!Ce&&!Ze&&!Pe&&t!==o.mzl,Ee=(0,En.Z)(ve,Ie),Me=(0,En.Z)(le,Ie)&&t!==o.mzl,Be=(0,En.Z)(j,Ie),Le=(0,En.Z)($,Ie),Ue=(0,En.Z)(G,Ie),je=(0,Mn.Z)(U),Oe=void 0!==je&&je<U?je:void 0,{isReady:Fe,handleOpenEnd:_e,handleSlideStop:De}=function(e,t,n,a,s){const[o,r]=(0,i.eJ)(!s),c=(0,ht.Z)(),d=void 0!==n&&n!==t;return d&&(e?r(!1):c()),(0,ct.Z)((()=>{e||r(!0)}),[e]),{isReady:o&&!d,handleOpenEnd:e?function(e){"transform"===e.propertyName&&e.target===e.currentTarget&&r(Boolean(a))}:void 0,handleSlideStop:e?function(){r(!0)}:void 0}}(!L&&B!==o.oBh,U,je,t,c);(0,i.d4)((()=>t?(0,Ct.Z)((()=>{z({id:void 0})})):void 0),[t,z]),(0,ct.Z)((()=>{de(Pn.t.None),he(void 0)}),[t]),(0,i.d4)((()=>{const{visualViewport:e}=window;if(!e)return;const t=()=>{e.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,i.d4)((()=>{m&&Y({userId:t})}),[t,m,Y]),(0,i.d4)((()=>{!O&&V&&J({chatId:t})}),[t,m,O,V,J]),(0,i.d4)((()=>{t&&H&&Fe&&se({chatId:t})}),[H,t,Fe,se]);const qe=(0,i.I4)((e=>{const{items:t}=e.dataTransfer||{},n=t&&t.length>0&&Array.from(t).filter((e=>"text/uri-list"!==e.type)).every(Rr);de(n?Pn.t.QuickFile:Pn.t.Document)}),[]),$e=(0,i.I4)((()=>{de(Pn.t.None)}),[]),Ge=(0,i.I4)((()=>{ge(!0)}),[]),He=(0,i.I4)((()=>{ge(!1)}),[]),Ve=(0,i.I4)((()=>{X({chatId:t,threadId:n}),He(),W()}),[X,t,n,He,W]),ze=(0,i.I4)((()=>{z({id:t})}),[z,t]),We=(0,i.I4)((()=>{ee({chatId:t}),Ue&&ae({message:re(j?"RequestToJoinChannelSentDescription":"RequestToJoinGroupSentDescription")})}),[ee,t,Ue,ae,j,re]),Xe=(0,i.I4)((()=>{te({command:"/start"})}),[te]),Ye=(0,i.I4)((()=>{ne({chatId:t})}),[t,ne]),Je=((e,t)=>{const[n,a]=(0,i.eJ)(t);return(0,i.d4)((()=>{t&&(t.startsWith("#")?a(t):Zn.fetch(o.foQ,e,Zn.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,Cn.pt)(t).then((()=>{a(`url(${t})`)}))})))}),[t,e]),t?n:void 0})(y,b),Ke=(0,tt.Z)(Ee&&"has-header-tools",s.aZ?"mask-image-disabled":"mask-image-enabled"),Qe=(0,tt.Z)("ON5E8MkEVA1mAlkuIxhG","OWFg9Wf1uioPWDz_IgS8",b&&"Ik9ZZlj3eKtKXRrUZKVk",P&&"avVozLQe3SaWcSkIt6pG",b&&M&&"Tipa66fYcSvl6w0587Xz",E&&"vhOr8s3T_LCKSt2BF7fs"),et=(0,tt.Z)("messaging-disabled",!k&&"shown"),nt=(0,u.q8)(re,g,f),at=(0,u.mt)(re,d,n,Boolean(l)),st=nt||at,{composerHiddenScale:ot,toolbarHiddenScale:it,composerTranslateX:rt,toolbarTranslateX:dt,unpinHiddenScale:lt,toolbarForUnpinHiddenScale:ut}=(0,i.Ye)((()=>function(e,t){const n=e<=o.l35?Re.Gw:2*Re.Gw,a=function(e){if(e>o._mX){const t=Math.min(Math.max(.25*e,Ne),Ae),n=Math.min(.25*e,Ae);return Math.min(e-t-n,Te)}if(e>o.ksF){const t=Math.min(Math.max(.4*e,Ne),Ae);return Math.min(e-t,Te)}return e>Te?Te:e}(e),s=e<=o.l35?3.375*Re.Gw:4*Re.Gw,i=t?a-n-s:a-n,r=e>o.l35?Math.min(a-n,ke):a-n,c=r/i,d=i/r;return{composerHiddenScale:c,toolbarHiddenScale:d,composerTranslateX:t?s/2*d:0,toolbarTranslateX:t?s/2*-1*c:0,unpinHiddenScale:r/xe,toolbarForUnpinHiddenScale:xe/r}}(oe,Se)),[Se,oe]),mt=(0,tt.Z)("middle-column-footer",!Se&&"no-composer",Se&&me&&!k&&"with-notch");(0,nn.Z)({isActive:k,onBack:Q}),(0,nn.Z)({isActive:fe,onBack:K});const pt=Boolean(!h&&!Se&&!Ce&&!Ze&&!Pe&&st),gt=Boolean(Ce||Pe||Ue||Ze||h),ft=Boolean(pt||k||h);return i.ZP.createElement("div",{id:"MiddleColumn",className:Ke,onTransitionEnd:_e,style:`\n --composer-hidden-scale: ${ot};\n --toolbar-hidden-scale: ${it};\n --unpin-hidden-scale: ${lt};\n --toolbar-unpin-hidden-scale: ${ut};\n --composer-translate-x: ${rt}px;\n --toolbar-translate-x: ${dt}px;\n --pattern-color: ${Z};\n --theme-background-color:\n ${P||("dark"===y?o.Itv:o.p3h)};\n `,onClick:ie&&S?ze:void 0},i.ZP.createElement("div",{className:Qe,style:Je?`--custom-background: ${Je}`:void 0}),i.ZP.createElement("div",{id:"middle-column-portals"}),we&&be&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("div",{className:"messages-layout",onDragEnter:Se?qe:void 0},i.ZP.createElement(da,{chatId:we,threadId:be,messageListType:ye,isReady:Fe,isMobile:c}),i.ZP.createElement(Rt.Z,{name:L?"none":B===o.zy8?"slide":"fade",activeKey:U,shouldCleanup:!0,cleanupExceptionKey:Oe,onStop:De},i.ZP.createElement(Bo,{key:`${we}-${be}-${ye}`,chatId:we,threadId:be,type:ye,canPost:Se,hasTools:Ee,onFabToggle:ue,onNotchToggle:he,isReady:Fe,withBottomShift:gt,withDefaultBg:Boolean(!b&&!P)}),i.ZP.createElement("div",{className:mt},Se&&i.ZP.createElement(wr,{chatId:we,threadId:be,messageListType:ye,dropAreaState:ce,onDropHide:$e,isReady:Fe,isMobile:c}),h&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:re.isRtl?"rtl":void 0},i.ZP.createElement(Ft.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:Ge},i.ZP.createElement("i",{className:"icon-unpin"}),i.ZP.createElement("span",null,re("Chat.Pinned.UnpinAll",w,"i")))),pt&&i.ZP.createElement("div",{className:et},i.ZP.createElement("div",{className:"messaging-disabled-inner"},i.ZP.createElement("span",null,st))),c&&(Pe||Le&&!Ue)&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:re.isRtl?"rtl":void 0},i.ZP.createElement(Ft.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:We},re(Be?"ProfileJoinChannel":"ProfileJoinGroup"))),c&&Ue&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:re.isRtl?"rtl":void 0},i.ZP.createElement(Ft.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:We},re("ChannelJoinRequest"))),c&&Ze&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:re.isRtl?"rtl":void 0},i.ZP.createElement(Ft.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Xe},re("BotStart"))),c&&Ce&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:re.isRtl?"rtl":void 0},i.ZP.createElement(Ft.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Ye},re("BotRestart"))),i.ZP.createElement(yr,{messageListType:ye,isActive:k,canPost:Se}),i.ZP.createElement(Zr,{isOpen:T}),i.ZP.createElement(Sr,{isOpen:A}),i.ZP.createElement(Mr,{isOpen:x}))),i.ZP.createElement(jo,{isShown:Me,canPost:Se,withExtraShift:ft})),c&&i.ZP.createElement(br,{isActive:Boolean(fe)})),t&&i.ZP.createElement(Pr,{isOpen:pe,chatId:t,pinnedMessagesCount:w,onClose:He,onUnpin:Ve}),i.ZP.createElement("div",{teactFastList:!0},q?.map(((e,t)=>i.ZP.createElement(Cr,{teactOrderKey:t,key:e.id,activeEmojiInteraction:e})))),i.ZP.createElement(Er,{isOpen:N}))}))),Tr=450+o.fK3,Ar=(0,N.Ds)((e=>e()),200,!1);var Nr;!function(e){e[e.Profile=0]="Profile",e[e.MemberList=1]="MemberList",e[e.SharedMedia=2]="SharedMedia",e[e.Search=3]="Search",e[e.Statistics=4]="Statistics",e[e.MessageStatistics=5]="MessageStatistics",e[e.Management=6]="Management",e[e.ManageInitial=7]="ManageInitial",e[e.ManageChannelSubscribers=8]="ManageChannelSubscribers",e[e.ManageChatAdministrators=9]="ManageChatAdministrators",e[e.ManageChatPrivacyType=10]="ManageChatPrivacyType",e[e.ManageDiscussion=11]="ManageDiscussion",e[e.ManageGroupPermissions=12]="ManageGroupPermissions",e[e.ManageGroupRemovedUsers=13]="ManageGroupRemovedUsers",e[e.ManageChannelRemovedUsers=14]="ManageChannelRemovedUsers",e[e.ManageGroupUserPermissionsCreate=15]="ManageGroupUserPermissionsCreate",e[e.ManageGroupUserPermissions=16]="ManageGroupUserPermissions",e[e.ManageGroupRecentActions=17]="ManageGroupRecentActions",e[e.ManageGroupAdminRights=18]="ManageGroupAdminRights",e[e.ManageGroupNewAdminRights=19]="ManageGroupNewAdminRights",e[e.ManageGroupMembers=20]="ManageGroupMembers",e[e.ManageGroupAddAdmins=21]="ManageGroupAddAdmins",e[e.StickerSearch=22]="StickerSearch",e[e.GifSearch=23]="GifSearch",e[e.PollResults=24]="PollResults",e[e.AddingMembers=25]="AddingMembers",e[e.ManageInvites=26]="ManageInvites",e[e.ManageEditInvite=27]="ManageEditInvite",e[e.ManageReactions=28]="ManageReactions",e[e.ManageInviteInfo=29]="ManageInviteInfo",e[e.ManageJoinRequests=30]="ManageJoinRequests",e[e.CreateTopic=31]="CreateTopic",e[e.EditTopic=32]="EditTopic"}(Nr||(Nr={}));const xr=(0,i.X$)((0,a.c$)(((e,t)=>{let{chatId:n,isProfile:a,isManagement:s,threadId:o}=t;const i=(0,d.jU)(e),{query:c}=(0,d.n5)(e)||{},{query:l}=(0,d.y5)(e)||{},{query:m}=(0,d.yN)(e)||{},h=n?(0,d.Z1)(e,n):void 0,p=a&&n&&(0,u.YC)(n)?(0,d.dy)(e,n):void 0,g=h&&(0,u.eA)(h),f=h?.isForum&&Boolean(o&&o!==r._f),I=f?h.topics?.[o]:void 0,v=f&&I&&(0,u.GU)(h,I),w=p&&(0,u.cS)(p),b=p&&(0,u.kw)(p),y=Boolean(!s&&a&&!b&&h&&!(0,d.FM)(e,h.id)&&((0,u.YC)(h.id)||((0,u.Nl)(h)||h.isCreator)&&!h.isNotJoined)),P=Boolean(n&&i.management.byChatId[n]?.editingInvite),Z=!f&&h?.fullInfo?.canViewStatistics,C=n?i.management.byChatId[n]?.inviteInfo?.invite:void 0;return{canManage:y,canAddContact:b,canViewStatistics:Z,isChannel:g,isBot:w,isInsideTopic:f,canEditTopic:v,userId:p?.id,messageSearchQuery:c,stickerSearchQuery:l,gifSearchQuery:m,isEditingInvite:P,currentInviteInfo:C,shouldSkipHistoryAnimations:i.shouldSkipHistoryAnimations}}))((e=>{var t;let{chatId:n,threadId:s,isColumnOpen:o,isProfile:r,isSearch:c,isManagement:d,isStatistics:l,isMessageStatistics:u,isStickerSearch:m,isGifSearch:h,isPollResults:p,isCreatingTopic:g,isEditingTopic:I,isAddingChatMembers:v,profileState:w,managementScreen:b,canAddContact:y,userId:P,canManage:Z,isChannel:S,onClose:E,onScreenSelect:M,messageSearchQuery:R,stickerSearchQuery:k,gifSearchQuery:T,isEditingInvite:A,canViewStatistics:N,currentInviteInfo:x,shouldSkipHistoryAnimations:B,isBot:L,isInsideTopic:U,canEditTopic:j}=e;const{setLocalTextSearchQuery:O,setStickerSearchQuery:F,setGifSearchQuery:_,searchTextMessagesLocal:D,toggleManagement:q,openHistoryCalendar:$,openAddContactDialog:G,toggleStatistics:H,setEditingExportedInvite:V,deleteExportedChatInvite:z,openEditTopicPanel:W}=(0,a.Sv)(),[X,Y,J]=(0,Et.Z)(),{isMobile:K}=(0,C.ZP)(),Q=(0,i.I4)((()=>{V({chatId:n,invite:x}),M(f.u1.EditInvite)}),[n,x,M,V]),ee=(0,i.I4)((()=>{z({chatId:n,link:x.link}),M(f.u1.Invites),J()}),[n,J,x,z,M]),te=(0,i.I4)((e=>{O({query:e}),e.length&&Ar(D)}),[D,O]),ne=(0,i.I4)((e=>{F({query:e})}),[F]),se=(0,i.I4)((e=>{_({query:e})}),[_]),oe=(0,i.I4)((()=>{G({userId:P})}),[G,P]),ie=(0,i.I4)((()=>{n&&s&&W({chatId:n,topicId:s})}),[n,W,s]),re=(0,i.I4)((()=>{q()}),[q]),ce=(0,i.I4)((()=>{H()}),[H]),[de,le]=(0,i.eJ)(!o);(0,i.d4)((()=>{setTimeout((()=>{le(!o)}),Tr)}),[o]);const ue=(0,kt.Z)(),me=r?w===f.vi.Profile?Nr.Profile:w===f.vi.SharedMedia?Nr.SharedMedia:w===f.vi.MemberList?Nr.MemberList:-1:c?Nr.Search:p?Nr.PollResults:m?Nr.StickerSearch:h?Nr.GifSearch:v?Nr.AddingMembers:d?b===f.u1.Initial?Nr.ManageInitial:b===f.u1.ChatPrivacyType?Nr.ManageChatPrivacyType:b===f.u1.Discussion?Nr.ManageDiscussion:b===f.u1.ChannelSubscribers?Nr.ManageChannelSubscribers:b===f.u1.GroupPermissions?Nr.ManageGroupPermissions:b===f.u1.ChatAdministrators?Nr.ManageChatAdministrators:b===f.u1.GroupRemovedUsers?Nr.ManageGroupRemovedUsers:b===f.u1.ChannelRemovedUsers?Nr.ManageChannelRemovedUsers:b===f.u1.GroupUserPermissionsCreate?Nr.ManageGroupUserPermissionsCreate:b===f.u1.GroupUserPermissions?Nr.ManageGroupUserPermissions:b===f.u1.GroupRecentActions?Nr.ManageGroupRecentActions:b===f.u1.ChatAdminRights?Nr.ManageGroupAdminRights:b===f.u1.ChatNewAdminRights?Nr.ManageGroupNewAdminRights:b===f.u1.GroupMembers?Nr.ManageGroupMembers:b===f.u1.Invites?Nr.ManageInvites:b===f.u1.EditInvite?Nr.ManageEditInvite:b===f.u1.GroupAddAdmins?Nr.ManageGroupAddAdmins:b===f.u1.Reactions?Nr.ManageReactions:b===f.u1.InviteInfo?Nr.ManageInviteInfo:b===f.u1.JoinRequests?Nr.ManageJoinRequests:void 0:l?Nr.Statistics:u?Nr.MessageStatistics:g?Nr.CreateTopic:I?Nr.EditTopic:void 0,he=null!==(t=(0,Tn.Z)(me,!0))&&void 0!==t?t:-1,pe=K||me===Nr.SharedMedia||me===Nr.MemberList||me===Nr.AddingMembers||me===Nr.MessageStatistics||d,ge=(0,tt.Z)("animated-close-icon",pe&&"state-back",(de||B)&&"no-transition");return i.ZP.createElement("div",{className:"RightHeader"},i.ZP.createElement(Ft.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:E,ariaLabel:ue(pe?"Common.Back":"Common.Close")},i.ZP.createElement("div",{className:ge})),i.ZP.createElement(Rt.Z,{name:de||B?"none":"slide-fade",activeKey:he},function(){if(-1!==he)switch(he){case Nr.PollResults:return i.ZP.createElement("h3",null,ue("PollResults"));case Nr.Search:return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(_t.Z,{parentContainerClassName:"RightSearch",value:R,onChange:te}),i.ZP.createElement(Ft.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>$({selectedAt:(0,ae._F)(Date.now())}),ariaLabel:"Search messages by date"},i.ZP.createElement("i",{className:"icon-calendar"})));case Nr.AddingMembers:return i.ZP.createElement("h3",null,ue(S?"ChannelAddSubscribers":"GroupAddMembers"));case Nr.ManageInitial:return i.ZP.createElement("h3",null,ue("Edit"));case Nr.ManageChatPrivacyType:return i.ZP.createElement("h3",null,ue(S?"ChannelTypeHeader":"GroupTypeHeader"));case Nr.ManageDiscussion:return i.ZP.createElement("h3",null,ue("Discussion"));case Nr.ManageChatAdministrators:return i.ZP.createElement("h3",null,ue("ChannelAdministrators"));case Nr.ManageGroupRecentActions:return i.ZP.createElement("h3",null,ue("Group.Info.AdminLog"));case Nr.ManageGroupAdminRights:return i.ZP.createElement("h3",null,ue("EditAdminRights"));case Nr.ManageGroupNewAdminRights:return i.ZP.createElement("h3",null,ue("SetAsAdmin"));case Nr.ManageGroupPermissions:return i.ZP.createElement("h3",null,ue("ChannelPermissions"));case Nr.ManageGroupRemovedUsers:return i.ZP.createElement("h3",null,ue("BlockedUsers"));case Nr.ManageChannelRemovedUsers:return i.ZP.createElement("h3",null,ue("ChannelBlockedUsers"));case Nr.ManageGroupUserPermissionsCreate:return i.ZP.createElement("h3",null,ue("ChannelAddException"));case Nr.ManageGroupUserPermissions:return i.ZP.createElement("h3",null,ue("UserRestrictions"));case Nr.ManageInvites:return i.ZP.createElement("h3",null,ue("lng_group_invite_title"));case Nr.ManageEditInvite:return i.ZP.createElement("h3",null,ue(A?"EditLink":"NewLink"));case Nr.ManageInviteInfo:return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("h3",null,ue("InviteLink")),i.ZP.createElement("section",{className:"tools"},x&&!x.isRevoked&&i.ZP.createElement(Ft.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ue("Edit"),onClick:Q},i.ZP.createElement("i",{className:"icon-edit"})),x&&x.isRevoked&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(Ft.Z,{round:!0,color:"danger",size:"smaller",ariaLabel:ue("Delete"),onClick:Y},i.ZP.createElement("i",{className:"icon-delete"})),i.ZP.createElement(jn.Z,{isOpen:X,onClose:J,title:ue("DeleteLink"),text:ue("DeleteLinkHelp"),confirmIsDestructive:!0,confirmLabel:ue("Delete"),confirmHandler:ee}))));case Nr.ManageJoinRequests:return i.ZP.createElement("h3",null,ue(S?"SubscribeRequests":"MemberRequests"));case Nr.ManageGroupAddAdmins:return i.ZP.createElement("h3",null,ue("Channel.Management.AddModerator"));case Nr.StickerSearch:return i.ZP.createElement(_t.Z,{value:k,placeholder:ue("SearchStickersHint"),autoFocusSearch:!0,onChange:ne});case Nr.GifSearch:return i.ZP.createElement(_t.Z,{value:T,placeholder:ue("SearchGifsTitle"),autoFocusSearch:!0,onChange:se});case Nr.Statistics:return i.ZP.createElement("h3",null,ue(S?"ChannelStats.Title":"GroupStats.Title"));case Nr.MessageStatistics:return i.ZP.createElement("h3",null,ue("Stats.MessageTitle"));case Nr.SharedMedia:return i.ZP.createElement("h3",null,ue("SharedMedia"));case Nr.ManageChannelSubscribers:return i.ZP.createElement("h3",null,ue("ChannelSubscribers"));case Nr.MemberList:case Nr.ManageGroupMembers:return i.ZP.createElement("h3",null,ue("GroupMembers"));case Nr.ManageReactions:return i.ZP.createElement("h3",null,ue("Reactions"));case Nr.CreateTopic:return i.ZP.createElement("h3",null,ue("NewTopic"));case Nr.EditTopic:return i.ZP.createElement("h3",null,ue("EditTopic"));default:return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("h3",null,ue(U?"AccDescrTopic":S?"Channel.TitleInfo":P?L?"lng_info_bot_title":"lng_info_user_title":"GroupInfo.Title")),i.ZP.createElement("section",{className:"tools"},y&&i.ZP.createElement(Ft.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ue("AddContact"),onClick:oe},i.ZP.createElement("i",{className:"icon-add-user"})),Z&&!U&&i.ZP.createElement(Ft.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ue("Edit"),onClick:re},i.ZP.createElement("i",{className:"icon-edit"})),j&&i.ZP.createElement(Ft.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ue("EditTopic"),onClick:ie},i.ZP.createElement("i",{className:"icon-edit"})),N&&i.ZP.createElement(Ft.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ue("Statistics"),onClick:ce},i.ZP.createElement("i",{className:"icon-stats"}))))}}()))})));var Br=n(91);var Lr=n(27407);function Ur(e,t,n,a){const[s,i]=(0,Lr.Z)(n?t:void 0,a,void 0,o.Vk);return[s,i,!(!s||!a||s[0]===a[0])]}function jr(e,t,n,a,s,r,c){const d=(0,i.sO)();(0,ct.Z)((()=>{d.current=void 0}),[c]),(0,ct.Z)((()=>{t===e&&s&&r&&(d.current=(0,u.R5)(s,r,e))}),[s,r,t,e]);const[l,m]=(0,Lr.Z)(a?n:void 0,d.current,void 0,"media"===e?o.ENB:o.pnA);return[l,m,!(!l||!d.current||l[0]===d.current[0])]}const Or=(0,N.P2)((e=>e()),250,!1);let Fr=!1;var _r=n(21273),Dr=n(31876),qr=n(16568),$r=n(70180),Gr=n(13709),Hr=n(45418),Vr=n(47262),zr=n(41151),Wr=n(22275);const Xr=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"}];function Yr(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > .Transition__slide--active > .${e}-list > .scroll-item`].join(", ")}const Jr=(0,i.X$)((0,a.c$)(((e,t)=>{let{chatId:n,topicId:a,isMobile:s}=t;const o=(0,d.Z1)(e,n),i=(0,d.Zw)(e,n),{currentType:r,resultsByType:c}=(0,d.we)(e)||{},{foundIds:l}=c&&r&&c[r]||{},{byId:m,statusesById:h}=e.users,{byId:p}=e.chats,g=o&&(0,u.Bf)(o),f=o&&(0,u.eA)(o),I=!a&&(g||f&&(0,u.Nl)(o)),v=o?.fullInfo?.members,w=o?.fullInfo?.adminMembersById,b=I&&o&&(o.isForbidden||o.fullInfo&&!o.fullInfo.canViewMembers),y=I&&o&&((0,u.VE)(o,"inviteUsers")||!(0,u.Mg)(o,"inviteUsers")||o.isCreator),P=I&&o&&((0,u.VE)(o,"banUsers")||o.isCreator),Z=(0,d.xs)(e,n);let C,S,E;return(0,u.YC)(n)&&(S=n,E=(0,d.dy)(e,S),C=E&&!E.isSelf&&!(0,u.cS)(E)),{theme:(0,d.Pu)(e),isChannel:f,resolvedUserId:S,messagesById:i,foundIds:l,mediaSearchType:r,hasCommonChatsTab:C,hasMembersTab:I,areMembersHidden:b,canAddMembers:y,canDeleteMembers:P,currentUserId:e.currentUserId,isRightColumnShown:(0,d.Jf)(e,s),isRestricted:o?.isRestricted,lastSyncTime:e.lastSyncTime,activeDownloadIds:Z,usersById:m,userStatusesById:h,chatsById:p,isChatProtected:o?.isProtected,...I&&v&&{members:v,adminMembersById:w},...C&&E&&{commonChatIds:E.commonChats?.ids}}}))((e=>{let{chatId:t,topicId:n,profileState:c,onProfileStateChange:d,theme:l,isChannel:m,resolvedUserId:h,currentUserId:p,messagesById:g,foundIds:I,mediaSearchType:v,hasCommonChatsTab:w,hasMembersTab:b,areMembersHidden:y,canAddMembers:P,canDeleteMembers:Z,commonChatIds:C,members:S,adminMembersById:E,usersById:M,userStatusesById:R,chatsById:k,isRightColumnShown:T,isRestricted:A,lastSyncTime:N,activeDownloadIds:x,isChatProtected:B}=e;const{setLocalMediaSearchType:L,loadMoreMembers:U,loadCommonChats:j,openChat:O,searchMediaMessagesLocal:F,openMediaViewer:_,openAudioPlayer:D,focusMessage:q,loadProfilePhotos:$,setNewChatMembersDialogState:G}=(0,a.Sv)(),H=(0,i.sO)(null),V=(0,i.sO)(null),z=(0,kt.Z)(),[W,X]=(0,i.eJ)(0),[Y,J]=(0,i.eJ)(),K=(0,i.Ye)((()=>[...b?[{type:"members",title:m?"ChannelSubscribers":"GroupMembers"}]:[],...Xr,...n?[]:[{type:"voice",title:"SharedVoiceTab2"}],...w?[{type:"commonChats",title:"SharedGroupsTab2"}]:[]]),[w,b,m,n]),Q=W>K.length-1?K.length-1:W,ee=K[Q].type,[te,ne,ae,se]=function(e,t,n,a,s,o,r,c,d,l,m,h,p,g){const f="members"!==a&&s?s:a,I=(0,i.Ye)((()=>{if(o&&c&&d)return(0,u.Z0)(o.map((e=>{let{userId:t}=e;return t})),c,d)}),[o,c,d]),v=(0,i.Ye)((()=>{if(r&&l)return(0,u.ih)(r,l,!0)}),[l,r]),[w,b,y]=Ur(0,e,p,I),[P,Z,C]=jr("media",f,n,p,m,h,g),[S,E,M]=jr("documents",f,n,p,m,h,g),[R,k,T]=jr("links",f,n,p,m,h,g),[A,N,x]=jr("audio",f,n,p,m,h,g),[B,L,U]=jr("voice",f,n,p,m,h,g),[j,O,F]=Ur(0,t,p,v);let _,D,q=!1;switch(f){case"members":_=w,D=b,q=y;break;case"commonChats":_=j,D=O,q=F;break;case"media":_=P,D=Z,q=C;break;case"documents":_=S,D=E,q=M;break;case"links":_=R,D=k,q=T;break;case"audio":_=A,D=N,q=x;break;case"voice":_=B,D=L,q=U}return[f,_,D,q]}(U,j,F,ee,v,S,C,M,R,k,g,I,N,n),oe="members"===te||!b&&"media"===te,ie=K.findIndex((e=>{let{type:t}=e;return t===te})),{handleScroll:re}=function(e,t,n,a){(0,ot.Z)((n=>{let[s]=n;if(s&&s!==t){const n=e.current,s=n.querySelector(".TabList");n.scrollTop<s.offsetTop&&(a("members"===t?f.vi.MemberList:f.vi.SharedMedia),Fr=!0,(0,pa.Z)(n,s,"start",void 0,void 0,void 0,300),setTimeout((()=>{Fr=!1}),350))}}),[t,a,e]),(0,ot.Z)((t=>{let[s]=t;if(n!==f.vi.Profile||n===s)return;const o=e.current;if(!o)return;const i=o.querySelector(".TabList");!i||i.offsetTop>o.scrollTop||(Fr=!0,(0,pa.Z)(o,o.firstElementChild,"start",void 0,2*o.offsetHeight),setTimeout((()=>{Fr=!1}),350),a(n))}),[n,e,a]);const s=(0,i.I4)((()=>{const n=e.current;if(!n)return;const s=n.querySelector(".TabList");if(!s)return;let o=f.vi.Profile;n.scrollTop>=s.offsetTop&&(o="members"===t?f.vi.MemberList:f.vi.SharedMedia),a(o)}),[e,a,t]);return(0,i.d4)((()=>{Fr||s()}),[s,t]),{handleScroll:(0,i.I4)((()=>{Fr||Or(s)}),[s])}}(H,te,c,d),{applyTransitionFix:ce,releaseTransitionFix:de}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".Transition.shared-media-transition";(0,i.d4)((()=>{function n(){const n=e.current,a=n.querySelector(t),s=n.querySelector(".TabList");a&&s&&(a.style.minHeight=n.offsetHeight-s.offsetHeight+"px")}return n(),window.addEventListener("resize",n,!1),()=>{window.removeEventListener("resize",n,!1)}}),[e,t]);const n=(0,i.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]),a=(0,i.I4)((()=>{const t=e.current;t.style.overflowY="scroll",t.style.marginRight="0"}),[e]);return{applyTransitionFix:n,releaseTransitionFix:a}}(H),[le,ue]=(()=>{const[e,t]=(0,i.eJ)(0);return[e,(0,i.I4)((()=>{t((e=>e+1))}),[])]})(),{observe:me}=(0,wa.S1)({rootRef:H,throttleMs:500}),he=(0,i.I4)((()=>{de(),ue()}),[de,ue]),pe=(0,i.I4)((()=>{G({newChatMembersProgress:f.WB.InProgress})}),[G]);(0,i.d4)((()=>{L({mediaType:ee})}),[L,ee,n]);const ge=h||t;(0,i.d4)((()=>{N&&$({profileId:ge})}),[$,ge,N]);const fe=(0,i.I4)((e=>{_({chatId:ge,threadId:r._f,mediaId:e,origin:f.bZ.SharedMedia})}),[ge,_]),Ie=(0,i.I4)((e=>{D({chatId:ge,messageId:e})}),[ge,D]),ve=(0,i.I4)((e=>{O({id:e})}),[O]),we=(0,i.I4)((e=>{q({chatId:ge,messageId:e})}),[ge,q]),be=(0,i.I4)((()=>{J(void 0)}),[]);let ye;(0,ot.Z)((e=>{let[t]=e;if(0===W||t===b)return;const n=W+(b?1:-1);X(Math.min(n,K.length-1))}),[b,W,K]),(0,i.d4)((()=>{if(V.current&&s.$b)return(0,tn.sf)(V.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===tn.eM.Left?(X(Math.min(Q+1,K.length-1)),!0):t===tn.eM.Right&&(X(Math.max(0,Q-1)),!0)})}),[Q,K.length]),oe?ye=T?0:1e3:ne||(ye=o.Yan);const Pe=(0,sr.Z)([t,n,te,Q],ye);return i.ZP.createElement(_r.Z,{ref:H,className:"Profile custom-scroll",itemSelector:Yr(te),items:Pe?ne:void 0,cacheBuster:le,sensitiveArea:o.qUX,preloadBackwards:Pe?"members"===te?o.Vk:o.ENB:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:ae,onScroll:re},!se&&function(e,t,n){return i.ZP.createElement("div",{className:"profile-info"},i.ZP.createElement(qr.Z,{userId:t||e,canPlayVideo:n}),i.ZP.createElement($r.Z,{chatOrUserId:t||e}))}(t,h,T&&Pe),!A&&i.ZP.createElement("div",{className:"shared-media"},i.ZP.createElement(Rt.Z,{ref:V,name:z.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:ie,renderCount:K.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:ce,onStop:he},function(){if(!ne||!Pe||!g){const e=oe&&!Pe,t=Boolean("members"===te&&y);return i.ZP.createElement("div",{className:"content empty-list"},!e&&!t&&i.ZP.createElement(Gt.Z,null),t&&i.ZP.createElement(Vr.Z,{text:"You have no access to group members list."}))}if(!ne.length){let e;switch(te){case"members":e=y?"You have no access to group members list.":"No members found";break;case"commonChats":e=z("NoGroupsInCommon");break;case"documents":e=z("lng_media_file_empty");break;case"links":e=z("lng_media_link_empty");break;case"audio":e=z("lng_media_song_empty");break;case"voice":e=z("lng_media_audio_empty");break;default:e=z("SharedMedia.EmptyTitle")}return i.ZP.createElement("div",{className:"content empty-list"},i.ZP.createElement(Vr.Z,{text:e}))}return i.ZP.createElement("div",{className:`content ${te}-list`,dir:z.isRtl&&"media"===te?"rtl":void 0,teactFastList:!0},"media"===te?ne.map((e=>g[e]&&i.ZP.createElement(Gr.Z,{key:e,message:g[e],isProtected:B||g[e].isProtected,observeIntersection:me,onClick:fe}))):"documents"===te?ne.map((e=>g[e]&&i.ZP.createElement(Qa.Z,{key:e,message:g[e],withDate:!0,smaller:!0,className:"scroll-item",isDownloading:x.includes(e),observeIntersection:me,onDateClick:we}))):"links"===te?ne.map((e=>g[e]&&i.ZP.createElement(Hr.Z,{key:e,message:g[e],isProtected:B||g[e].isProtected,observeIntersection:me,onMessageClick:we}))):"audio"===te?ne.map((e=>g[e]&&i.ZP.createElement(es.ZP,{key:e,theme:l,message:g[e],origin:f.Cr.SharedMedia,date:g[e].date,lastSyncTime:N,className:"scroll-item",onPlay:Ie,onDateClick:we,canDownload:!B&&!g[e].isProtected,isDownloading:x.includes(e)}))):"voice"===te?ne.map((e=>g[e]&&i.ZP.createElement(es.ZP,{key:e,theme:l,message:g[e],senderTitle:(0,Br.F)(z,g[e],k,M),origin:f.Cr.SharedMedia,date:g[e].date,lastSyncTime:N,className:"scroll-item",onPlay:Ie,onDateClick:we,canDownload:!B&&!g[e].isProtected,isDownloading:x.includes(e)}))):"members"===te?ne.map(((e,t)=>{return i.ZP.createElement(Dr.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>ve(e),contextActions:(n=e,n!==p&&Z?[{title:z("lng_context_remove_from_group"),icon:"stop",handler:()=>{J(n)}}]:void 0)},i.ZP.createElement(An.Z,{userId:e,adminMember:E?.[e],forceShowSelf:!0}));var n})):"commonChats"===te?ne.map(((e,t)=>i.ZP.createElement(Dr.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>O({id:e})},i.ZP.createElement(Nn.Z,{chatId:e})))):void 0)}()),i.ZP.createElement(an.Z,{big:!0,activeTab:Q,tabs:K,onSwitchTab:X})),P&&i.ZP.createElement(zr.Z,{isShown:"members"===te,onClick:pe,ariaLabel:z("lng_channel_add_users")},i.ZP.createElement("i",{className:"icon-add-user-filled"})),Z&&i.ZP.createElement(Wr.Z,{isOpen:Boolean(Y),userId:Y,onClose:be}))}))),Kr=(0,i.X$)((e=>{const t=(0,vt.Z)(st.gl.Extra,"RightSearch");return t?i.ZP.createElement(t,e):i.ZP.createElement(rn.Z,null)})),Qr=(0,i.X$)((e=>{const t=(0,vt.Z)(st.gl.Extra,"Management");return t?i.ZP.createElement(t,e):i.ZP.createElement(rn.Z,null)})),ec=e=>{const t=(0,vt.Z)(st.gl.Extra,"Statistics");return t?i.ZP.createElement(t,e):i.ZP.createElement(rn.Z,null)},tc=e=>{const t=(0,vt.Z)(st.gl.Extra,"MessageStatistics");return t?i.ZP.createElement(t,e):i.ZP.createElement(rn.Z,null)},nc=(0,i.X$)((()=>{const e=(0,vt.Z)(st.gl.Extra,"StickerSearch");return e?i.ZP.createElement(e,null):i.ZP.createElement(rn.Z,null)})),ac=(0,i.X$)((()=>{const e=(0,vt.Z)(st.gl.Extra,"GifSearch");return e?i.ZP.createElement(e,null):i.ZP.createElement(rn.Z,null)})),sc=(0,i.X$)((()=>{const e=(0,vt.Z)(st.gl.Extra,"PollResults");return e?i.ZP.createElement(e,null):i.ZP.createElement(rn.Z,null)}));var oc=n(11820);const ic=(0,i.X$)((0,a.c$)(((e,t)=>{let{chatId:n}=t;const a=(0,d.Z1)(e,n),{userIds:s}=e.contactList||{},{byId:o}=e.chats,{newChatMembersProgress:i}=(0,d.jU)(e),{currentUserId:r}=e,c=a&&(0,u.eA)(a),{query:l,fetchingStatus:m,globalUserIds:h,localUserIds:p}=(0,d.jU)(e).userSearch;return{isChannel:c,members:a?.fullInfo?.members,currentUserId:r,chatsById:o,localContactIds:s,searchQuery:l,isSearching:m,isLoading:i===f.WB.Loading,globalUserIds:h,localUserIds:p}}))((e=>{let{isChannel:t,members:n,onNextStep:s,currentUserId:o,chatsById:r,localContactIds:c,isLoading:d,searchQuery:l,isSearching:m,localUserIds:h,globalUserIds:p,onClose:g,isActive:f}=e;const{setUserSearchQuery:v}=(0,a.Sv)(),w=(0,kt.Z)(),[b,y]=(0,i.eJ)([]),P=(0,Mn.Z)(b)===b;(0,nn.Z)({isActive:f,onBack:g});const Z=(0,i.Ye)((()=>n?n.map((e=>e.userId)):[]),[n]),C=(0,i.I4)((e=>{v({query:e})}),[v]),S=(0,i.Ye)((()=>{const e=(0,a.Rd)().users.byId,n=c?(0,u.kK)(c,e,l):[];return(0,u.ih)((0,I.Tw)([...n,...h||[],...p||[]]).filter((n=>{const a=e[n];return!Z.includes(n)&&n!==o&&(!a||!(0,u.cS)(a)||!t&&a.canBeInvitedToGroup)})),r)}),[c,r,l,h,p,o,Z,t]),E=(0,i.I4)((()=>{b.length&&(v({query:""}),s(b))}),[b,v,s]);return i.ZP.createElement("div",{className:"AddChatMembers"},i.ZP.createElement("div",{className:"AddChatMembers-inner"},i.ZP.createElement(oc.Z,{itemIds:S,selectedIds:b,filterValue:l,filterPlaceholder:w("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:m,onSelectedIdsChange:y,onFilterChange:C,noScrollRestore:P}),i.ZP.createElement(zr.Z,{isShown:Boolean(b.length),disabled:d,ariaLabel:w("lng_channel_add_users"),onClick:E},d?i.ZP.createElement(Gt.Z,{color:"white"}):i.ZP.createElement("i",{className:"icon-arrow-right"}))))}))),rc=(0,i.X$)((e=>{const t=(0,vt.Z)(st.gl.Extra,"CreateTopic");return t?i.ZP.createElement(t,e):i.ZP.createElement(rn.Z,null)})),cc=(0,i.X$)((e=>{const t=(0,vt.Z)(st.gl.Extra,"EditTopic");return t?i.ZP.createElement(t,e):i.ZP.createElement(rn.Z,null)})),dc=450+o.fK3,lc=Object.keys(f.qt).length/2,uc=Object.keys(f.u1).length/2;function mc(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const hc=(0,i.X$)((0,a.c$)(((e,t)=>{let{isMobile:n}=t;const{chatId:a,threadId:s}=(0,d.Bt)(e)||{},o=(0,d.g4)(e),{management:i,shouldSkipHistoryAnimations:c}=(0,d.jU)(e),l=a?i.byChatId[a]?.nextScreen:void 0,u=(a?(0,d.Z1)(e,a)?.isForum:void 0)&&Boolean(s&&s!==r._f);return{contentKey:(0,d.Wq)(e,n),chatId:a,threadId:s,isInsideTopic:u,isChatSelected:Boolean(a&&o),shouldSkipHistoryAnimations:c,nextManagementScreen:l}}))((e=>{var t;let{contentKey:n,chatId:s,threadId:r,isMobile:c,isInsideTopic:d,isChatSelected:l,shouldSkipHistoryAnimations:u,nextManagementScreen:m}=e;const{toggleChatInfo:h,toggleManagement:p,closeLocalTextSearch:g,setStickerSearchQuery:I,setGifSearchQuery:v,closePollResults:w,addChatMembers:b,setNewChatMembersDialogState:y,setEditingExportedInvite:P,toggleStatistics:Z,toggleMessageStatistics:C,setOpenedInviteInfo:S,requestNextManagementScreen:E,closeCreateTopicPanel:M,closeEditTopicPanel:R}=(0,a.Sv)(),{width:k}=(0,Sn.Z)(),[T,A]=(0,i.eJ)(f.vi.Profile),[N,x]=(0,i.eJ)(f.u1.Initial),[B,L]=(0,i.eJ)(),[U,j]=(0,i.eJ)(),O=T!==f.vi.Profile,F=void 0!==n,_=n===f.qt.ChatInfo,D=n===f.qt.Search,q=n===f.qt.Management,$=n===f.qt.Statistics,G=n===f.qt.MessageStatistics,H=n===f.qt.StickerSearch,V=n===f.qt.GifSearch,z=n===f.qt.PollResults,W=n===f.qt.AddingMembers,X=n===f.qt.CreateTopic,Y=n===f.qt.EditTopic,J=k<=o._mX,[K,Q]=(0,i.eJ)(!F),ee=null!==(t=(0,Tn.Z)(n,!0,!l))&&void 0!==t?t:-1,te=(0,i.I4)((function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];switch(n){case f.qt.AddingMembers:y({newChatMembersProgress:f.WB.Closed});break;case f.qt.ChatInfo:if(O&&e){A(f.vi.Profile);break}h({force:!1},{forceSyncOnIOs:!0});break;case f.qt.Management:switch(N){case f.u1.Initial:p();break;case f.u1.ChatPrivacyType:case f.u1.Discussion:case f.u1.GroupPermissions:case f.u1.GroupType:case f.u1.ChatAdministrators:case f.u1.ChannelSubscribers:case f.u1.GroupMembers:case f.u1.Invites:case f.u1.Reactions:case f.u1.JoinRequests:case f.u1.ChannelRemovedUsers:x(f.u1.Initial);break;case f.u1.GroupUserPermissionsCreate:case f.u1.GroupRemovedUsers:case f.u1.GroupUserPermissions:x(f.u1.GroupPermissions),L(void 0),j(void 0);break;case f.u1.ChatAdminRights:case f.u1.ChatNewAdminRights:case f.u1.GroupAddAdmins:case f.u1.GroupRecentActions:x(f.u1.ChatAdministrators);break;case f.u1.EditInvite:case f.u1.InviteInfo:x(f.u1.Invites),S({chatId:s,invite:void 0}),P({chatId:s,invite:void 0})}break;case f.qt.MessageStatistics:C();break;case f.qt.Statistics:Z();break;case f.qt.Search:mc(),g();break;case f.qt.StickerSearch:mc(),I({query:void 0});break;case f.qt.GifSearch:mc(),v({query:void 0});break;case f.qt.PollResults:w();break;case f.qt.CreateTopic:M();break;case f.qt.EditTopic:R()}}),[n,O,h,w,y,N,p,g,I,v,P,s,S,Z,C,M,R]),ne=(0,i.I4)(((e,t)=>{L(e),j(t)}),[]),ae=(0,i.I4)((e=>{b({chatId:s,memberIds:e})}),[b,s]);function se(e){if(-1!==ee)switch(ee){case f.qt.AddingMembers:return i.ZP.createElement(ic,{key:s,chatId:s,isActive:F&&e,onNextStep:ae,onClose:te});case f.qt.ChatInfo:return i.ZP.createElement(Jr,{key:s,chatId:s,topicId:d?r:void 0,profileState:T,isMobile:c,onProfileStateChange:A});case f.qt.Search:return i.ZP.createElement(Kr,{chatId:s,threadId:r,onClose:te,isActive:F&&e});case f.qt.Management:return i.ZP.createElement(Qr,{key:s,chatId:s,currentScreen:N,isPromotedByCurrentUser:U,selectedChatMemberId:B,isActive:F&&e,onScreenSelect:x,onChatMemberSelect:ne,onClose:te});case f.qt.Statistics:return i.ZP.createElement(ec,{chatId:s});case f.qt.MessageStatistics:return i.ZP.createElement(tc,{chatId:s,isActive:F&&e});case f.qt.StickerSearch:return i.ZP.createElement(nc,{onClose:te,isActive:F&&e});case f.qt.GifSearch:return i.ZP.createElement(ac,{onClose:te,isActive:F&&e});case f.qt.PollResults:return i.ZP.createElement(sc,{onClose:te,isActive:F&&e});case f.qt.CreateTopic:return i.ZP.createElement(rc,{onClose:te,isActive:F&&e});case f.qt.EditTopic:return i.ZP.createElement(cc,{onClose:te,isActive:F&&e})}}return(0,i.d4)((()=>F?(0,Ct.Z)(te):void 0),[F,te]),(0,i.d4)((()=>{setTimeout((()=>{Q(!F)}),dc)}),[F]),(0,i.d4)((()=>{m&&(x(m),E(void 0))}),[m,E]),(0,i.d4)((()=>{F&&J&&te()}),[J]),Ia((e=>{let[t]=e;t!==s&&(A(f.vi.Profile),x(f.u1.Initial))}),[s]),(0,nn.Z)({isActive:l&&(n===f.qt.ChatInfo||n===f.qt.Management||n===f.qt.AddingMembers||n===f.qt.CreateTopic||n===f.qt.EditTopic),onBack:()=>te(!1)}),i.ZP.createElement("div",{id:"RightColumn-wrapper",className:l?void 0:"is-hidden"},J&&i.ZP.createElement("div",{className:"overlay-backdrop",onClick:te}),i.ZP.createElement("div",{id:"RightColumn"},i.ZP.createElement(xr,{chatId:s,threadId:r,isColumnOpen:F,isProfile:_,isSearch:D,isManagement:q,isStatistics:$,isMessageStatistics:G,isStickerSearch:H,isGifSearch:V,isPollResults:z,isCreatingTopic:X,isEditingTopic:Y,isAddingChatMembers:W,profileState:T,managementScreen:N,onClose:te,onScreenSelect:x}),i.ZP.createElement(Rt.Z,{name:K||u?"none":"zoom-fade",renderCount:lc+uc,activeKey:q?lc+N:ee,shouldCleanup:!0,cleanupExceptionKey:ee===f.qt.MessageStatistics?f.qt.Statistics:void 0},se)))}))),pc=(0,i.X$)((e=>{let{isOpen:t}=e;const n=(0,vt.Z)(st.gl.Extra,"MediaViewer",!t);return n?i.ZP.createElement(n,null):void 0}));let gc=[],fc=!1;function Ic(e,t){gc.push({url:e,filename:t}),fc||(fc=!0,setTimeout((async()=>{await async function(){let e=0;for(const t of gc)vc(t),e++,10===e&&(await(0,N.wO)(1e3),e=0);gc=[]}(),fc=!1}),1e3))}function vc(e){let{url:t,filename:n}=e;const a=document.createElement("a");a.href=t,a.download=n;try{a.click()}catch(e){console.error(e)}}const wc=new Set,bc=new Set,yc=(0,i.X$)((0,a.c$)((e=>({activeDownloads:(0,d.jU)(e).activeDownloads.byChatId,messages:e.messages.byChatId})))((e=>{let{activeDownloads:t,messages:n}=e;const{cancelMessagesMediaDownload:o,showNotification:c}=(0,a.Sv)(),d=(0,ga.Z)(1e3,!0),l=(0,i.I4)((e=>{bc.add(e),d((()=>{bc.size&&(o({messages:Array.from(bc)}),bc.clear())}))}),[o,d]);(0,i.d4)((()=>{const e=Object.entries(t).map((e=>{let[t,a]=e;return a.map((e=>n[t].byId[e]))})).flat();e.length?e.forEach((e=>{if(wc.has(e))return;wc.add(e);const t=(0,u.Ti)(e,"download");if(!t)return void l(e);const n=Me.UV(t);if(n)return Ic(n,(0,u.w6)(e)),void l(e);const{document:a,video:o,audio:i}=e.content;if(((a||o||i)?.size||0)>s.l0&&!s.rT&&!s.Mc)return c({message:"Downloading files bigger than 2GB is not supported in your browser."}),void l(e);const d=(0,u.kG)(e,"download");Me.he(t,d,!0).then((t=>{if(d===r.IU.DownloadUrl){const n=new URL(t,window.document.baseURI),a=(0,u.w6)(e);n.searchParams.set("filename",encodeURIComponent(a)),window.open(n.toString())?.addEventListener("beforeunload",(()=>{c({message:"Download started. Please, do not close the app before it is finished."})}))}else t&&Ic(t,(0,u.w6)(e));l(e)}))})):wc.clear()}),[n,t,o,l,c])})));var Pc=n(13103);const Zc=(0,i.X$)((0,a.c$)(((e,t)=>{let{openedGame:n}=t;const{chatId:a}=n||{},s=a&&(0,d.Z1)(e,a);return{canPost:Boolean(s)&&(0,u.Qm)(s,r._f)}}))((e=>{let{openedGame:t,gameTitle:n,canPost:a}=e;const{closeGame:s,openForwardMenu:o}=(0,re.Sv)(),r=(0,kt.Z)(),{url:c,chatId:d,messageId:l}=t||{},u=Boolean(c),m=(0,ni.Z)(d);(0,ft.Z)((()=>{m({type:"playingGame"})}),u&&a?5e3:void 0);const h=(0,i.I4)((e=>{try{const t=JSON.parse(e.data);"share_score"===t.eventType&&(o({fromChatId:d,messageIds:[l],withMyScore:!0}),s()),"share_game"===t.eventType&&(o({fromChatId:d,messageIds:[l]}),s())}catch(e){}}),[d,s,l,o]),p=(0,i.I4)((e=>{e.currentTarget.focus()}),[]);return(0,i.d4)((()=>(window.addEventListener("message",h),()=>window.removeEventListener("message",h))),[h]),i.ZP.createElement(Pc.Z,{className:"GameModal",isOpen:u,onClose:s,title:n,hasCloseButton:!0},u&&i.ZP.createElement("iframe",{className:"game-frame",onLoad:p,src:c,title:r("AttachGame"),sandbox:"allow-scripts allow-same-origin allow-orientation-lock",allow:"fullscreen"}))}))),Cc=(0,i.X$)((e=>{let{isOpen:t}=e;const n=(0,vt.Z)(st.gl.Extra,"Notifications",!t);return n?i.ZP.createElement(n,null):void 0})),Sc=(0,i.X$)((e=>{let{isOpen:t}=e;const n=(0,vt.Z)(st.gl.Extra,"Dialogs",!t);return n?i.ZP.createElement(n,null):void 0})),Ec=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"ForwardRecipientPicker",!t);return n?i.ZP.createElement(n,e):void 0})),Mc=(0,i.X$)((e=>{const{url:t}=e,n=(0,vt.Z)(st.gl.Extra,"SafeLinkModal",!t);return n?i.ZP.createElement(n,e):void 0})),Rc=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"HistoryCalendar",!t);return n?i.ZP.createElement(n,e):void 0})),kc=(0,i.X$)((e=>{const{groupCallId:t}=e,n=(0,vt.Z)(st.gl.Calls,"GroupCall",!t);return n?i.ZP.createElement(n,e):void 0})),Tc=(0,i.X$)((e=>{const{isActive:t}=e,n=(0,vt.Z)(st.gl.Calls,"ActiveCallHeader",!t);return n?i.ZP.createElement(n,null):void 0})),Ac=(0,i.X$)((e=>{const{isActive:t}=e,n=(0,vt.Z)(st.gl.Calls,"PhoneCall",!t);return n?i.ZP.createElement(n,null):void 0}));function Nc(){return Nc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Nc.apply(this,arguments)}const xc=(0,i.X$)((0,a.c$)((e=>({messageLists:(0,d.jU)(e).messageLists})))((e=>{let{messageLists:t}=e;const{openChat:n}=(0,a.Sv)(),s=()=>{n({id:void 0},{forceSyncOnIOs:!0})},o=e=>{let{chatId:t,type:n,threadId:a}=e;(0,nn.Z)({isActive:!0,hash:(0,g.tB)(t,n,a),onBack:s})};return i.ZP.createElement("div",null,t?.map(((e,t)=>i.ZP.createElement(o,Nc({key:`${e.chatId}_${e.threadId}_${e.type}_${t}`},e)))))}))),Bc=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"NewContactModal",!t);return n?i.ZP.createElement(n,e):void 0})),Lc=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Calls,"RatePhoneCallModal",!t);return n?i.ZP.createElement(n,e):void 0})),Uc=(0,i.X$)((e=>{const{webApp:t}=e,n=(0,vt.Z)(st.gl.Extra,"WebAppModal",!t);return n?i.ZP.createElement(n,e):void 0})),jc=(0,i.X$)((e=>{const{bot:t}=e,n=(0,vt.Z)(st.gl.Extra,"BotTrustModal",!t);return n?i.ZP.createElement(n,e):void 0})),Oc=(0,i.X$)((e=>{const{bot:t}=e,n=(0,vt.Z)(st.gl.Extra,"AttachBotInstallModal",!t);return n?i.ZP.createElement(n,e):void 0})),Fc={root:"vfd0Bo1X6k19aaxQ577t"},_c=["#E8BC2C","#D0049E","#02CBFE","#5723FD","#FE8C27","#6CB859"],Dc=(0,i.X$)((0,a.c$)((e=>(0,I.ei)((0,d.jU)(e),["confetti"])))((e=>{let{confetti:t}=e;const n=(0,i.sO)(null),a=(0,i.sO)([]),s=(0,i.sO)(!1),o=(0,Sn.Z)(),r=(0,ht.Z)(),{isMobile:c}=(0,C.ZP)(),d=c?50:100,{lastConfettiTime:l,top:u,width:m,left:h,height:p}=t||{},g=(0,i.I4)((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:d;for(let s=0;s<n;s++){const n=s%2,o={x:e*(n?-.1:1.1),y:.75*t},i=Math.random()*e*1.5,r={x:n?i:-1*i,y:-t/2-Math.random()*t},c=_c[Math.floor(Math.random()*_c.length)],d=10;a.current.push({pos:o,size:d,color:c,velocity:r,flicker:d,flickerFrequency:.2*Math.random(),rotation:0,lastDrawnAt:Date.now(),frameCount:0})}}),[d]),f=(0,i.I4)((()=>{if(!n.current||!s.current)return;const e=n.current,t=e.getContext("2d");if(!t)return;const{width:o,height:i}=e;t.clearRect(0,0,o,i);const r=[];a.current.forEach(((e,n)=>{const{pos:s,velocity:o,size:c,color:d,flicker:l,flickerFrequency:u,rotation:m,lastDrawnAt:h,frameCount:p}=e,g=(Date.now()-h)/1e3,f={x:s.x+o.x*g,y:s.y+o.y*g},I={x:.98*o.x,y:o.y+=1e3*g},v=c*Math.abs(Math.sin(p*u)),w=5*p*u*(Math.PI/180),b=p+1,y=Date.now();if(f.y>i+e.size)return void r.push(e);const P={...e,pos:f,velocity:I,flicker:v,rotation:w,lastDrawnAt:y,frameCount:b};a.current[n]=P,t.fillStyle=d,t.beginPath(),t.ellipse(s.x,s.y,c,l,m,0,2*Math.PI),t.fill()})),a.current=a.current.filter((e=>!r.includes(e))),a.current.length?requestAnimationFrame(f):s.current=!1}),[]);if((0,ct.Z)((e=>{let t,[n]=e;return n!==l&&(g(m||o.width,p||o.height),t=setTimeout(r,1e4),s.current||(s.current=!0,requestAnimationFrame(f))),()=>{clearTimeout(t)}}),[l,r,f]),!l||Date.now()-l>1e4)return;const I=(0,cs.Z)(Boolean(u)&&`top: ${u}px`,Boolean(h)&&`left: ${h}px`,Boolean(m)&&`width: ${m}px`,Boolean(p)&&`height: ${p}px`);return i.ZP.createElement("div",{id:"Confetti",className:Fc.root,style:I},i.ZP.createElement("canvas",{ref:n,className:Fc.canvas,width:o.width,height:o.height}))}))),qc=(0,i.X$)((e=>{const{urlAuth:t}=e,n=(0,vt.Z)(st.gl.Extra,"UrlAuthModal",!t);return n?i.ZP.createElement(n,e):void 0})),$c=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"PremiumMainModal",!t);return n?i.ZP.createElement(n,e):void 0})),Gc=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"PaymentModal",!t);return n?i.ZP.createElement(n,e):void 0})),Hc=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,vt.Z)(st.gl.Extra,"ReceiptModal",!t);return n?i.ZP.createElement(n,e):void 0})),Vc=(0,i.X$)((e=>{const{limit:t}=e,n=(0,vt.Z)(st.gl.Extra,"PremiumLimitReachedModal",!t);return n?i.ZP.createElement(n,e):void 0})),zc=(0,i.X$)((e=>{const{deleteFolderDialogId:t}=e,n=(0,vt.Z)(st.gl.Extra,"DeleteFolderDialog",!t);return n?i.ZP.createElement(n,e):void 0})),Wc=(0,i.X$)((e=>{const{customEmojiSetIds:t}=e,n=(0,vt.Z)(st.gl.Extra,"CustomEmojiSetsModal",!t);return n?i.ZP.createElement(n,e):void 0})),Xc=(0,i.X$)((e=>{const{requestedDraft:t}=e,n=(0,vt.Z)(st.gl.Extra,"DraftRecipientPicker",!t);return n?i.ZP.createElement(n,e):void 0})),Yc=(0,i.X$)((e=>{const{requestedAttachBotInChat:t}=e,n=(0,vt.Z)(st.gl.Extra,"AttachBotRecipientPicker",!t);return n?i.ZP.createElement(n,e):void 0}));let Jc=!1;const Kc=(0,i.X$)((0,a.c$)(((e,t)=>{let{isMobile:n}=t;const{settings:{byKey:{animationLevel:a,language:s,wasTimeFormatSetManually:o}},lastSyncTime:i}=e,{botTrustRequest:r,requestedAttachBotInstall:c,requestedAttachBotInChat:l,requestedDraft:u,urlAuth:m,webApp:h,safeLinkModalUrl:p,openedStickerSetShortName:g,openedCustomEmojiSetIds:f,shouldSkipHistoryAnimations:I,openedGame:v,audioPlayer:w,isLeftColumnShown:b,historyCalendarSelectedAt:y,notifications:P,dialogs:Z,newContact:C,ratingPhoneCall:S,premiumModal:E,isMasterTab:M,payment:R,limitReachedModal:k,deleteFolderDialogModal:T}=(0,d.jU)(e),{chatId:A,messageId:N}=w,x=A&&N?(0,d.hj)(e,A,N):void 0,B=(v&&(0,d.hj)(e,v.chatId,v.messageId))?.content.game?.title,L=e.currentUserId?(0,d.dy)(e,e.currentUserId):void 0,{chatId:U}=(0,d.Bt)(e)||{};return{lastSyncTime:i,isLeftColumnOpen:b,isMiddleColumnOpen:Boolean(U),isRightColumnOpen:(0,d.Jf)(e,n),isMediaViewerOpen:(0,d.zQ)(e),isForwardModalOpen:(0,d.Ev)(e),hasNotifications:Boolean(P.length),hasDialogs:Boolean(Z.length),audioMessage:x,safeLinkModalUrl:p,isHistoryCalendarOpen:Boolean(y),shouldSkipHistoryAnimations:I,openedStickerSetShortName:g,openedCustomEmojiSetIds:f,isServiceChatReady:(0,d.UW)(e),activeGroupCallId:M?e.groupCalls.activeGroupCallId:void 0,animationLevel:a,language:s,wasTimeFormatSetManually:o,isPhoneCallActive:M?Boolean(e.phoneCall):void 0,addedSetIds:e.stickers.added.setIds,addedCustomEmojiIds:e.customEmojis.added.setIds,newContactUserId:C?.userId,newContactByPhoneNumber:C?.isByPhoneNumber,openedGame:v,gameTitle:B,isRatePhoneCallModalOpen:Boolean(S),botTrustRequest:r,botTrustRequestBot:r&&(0,d.dy)(e,r.botId),attachBotToInstall:c?.bot,requestedAttachBotInChat:l,webApp:h,currentUser:L,urlAuth:m,isCurrentUserPremium:(0,d.wV)(e),isPremiumModalOpen:E?.isOpen,limitReached:k?.limit,isPaymentModalOpen:R.isPaymentModalOpen,isReceiptModalOpen:Boolean(R.receipt),deleteFolderDialogId:T,isMasterTab:M,requestedDraft:u}}))((e=>{let{lastSyncTime:t,isMobile:n,isLeftColumnOpen:r,isMiddleColumnOpen:c,isRightColumnOpen:d,isMediaViewerOpen:l,isForwardModalOpen:u,hasNotifications:m,hasDialogs:h,audioMessage:p,activeGroupCallId:f,safeLinkModalUrl:I,isHistoryCalendarOpen:v,shouldSkipHistoryAnimations:w,limitReached:b,openedStickerSetShortName:y,openedCustomEmojiSetIds:P,isServiceChatReady:Z,animationLevel:S,language:E,wasTimeFormatSetManually:M,addedSetIds:R,addedCustomEmojiIds:k,isPhoneCallActive:T,newContactUserId:x,newContactByPhoneNumber:B,openedGame:L,gameTitle:U,isRatePhoneCallModalOpen:j,botTrustRequest:O,botTrustRequestBot:F,attachBotToInstall:_,requestedAttachBotInChat:D,requestedDraft:q,webApp:$,currentUser:G,urlAuth:H,isPremiumModalOpen:V,isPaymentModalOpen:z,isReceiptModalOpen:W,isCurrentUserPremium:X,deleteFolderDialogId:Y,isMasterTab:J}=e;const{loadAnimatedEmojis:K,loadNotificationSettings:Q,loadNotificationExceptions:ee,updateIsOnline:te,onTabFocusChange:ne,loadTopInlineBots:ae,loadEmojiKeywords:se,loadCountryList:oe,loadAvailableReactions:ie,loadStickerSets:re,loadPremiumGifts:ce,loadDefaultTopicIcons:de,loadAddedStickers:le,loadFavoriteStickers:ue,loadDefaultStatusIcons:me,ensureTimeFormat:he,closeStickerSetModal:pe,closeCustomEmojiSets:ge,checkVersionNotification:fe,loadConfig:Ie,loadAppConfig:ve,loadAttachBots:we,loadContactList:be,loadCustomEmojis:ye,loadGenericEmojiEffects:Pe,closePaymentModal:Ze,clearReceipt:Ce,checkAppVersion:Se,openChat:Ee,toggleLeftColumn:Me,loadRecentEmojiStatuses:Re,updatePageTitle:ke}=(0,a.Sv)();o.eMD&&!Jc&&(Jc=!0,console.log(">>> RENDER MAIN")),(0,It.Z)((()=>{(0,st.Pb)(st.gl.Calls)}),5e3);const{isDesktop:Te}=(0,C.ZP)();(0,i.d4)((()=>{r||c||Te?r&&c&&n&&Me():Me()}),[Te,r,c,n,Me]),(0,ft.Z)(Se,J?3e5:void 0,!0),(0,i.d4)((()=>{t&&J&&(te(!0),Ie(),ve(),ie(),K(),Pe(),Q(),ee(),ae(),se({language:o.pRL}),we(),be(),ce(),de(),me(),Se(),X&&Re())}),[t,K,se,ee,Q,ae,te,ie,ve,we,be,ce,Se,Ie,Pe,de,me,Re,X,J]),(0,i.d4)((()=>{t&&J&&(E!==o.pRL&&se({language:E}),oe({langCode:E}))}),[E,t,oe,se,J]),(0,ot.Z)((e=>{let[n]=e;!n&&t&&J&&ye({ids:Object.keys((0,a.Rd)().customEmojis.byId),ignoreCache:!0})}),[t,J,ye]),(0,i.d4)((()=>{t&&J&&(R&&k||(re(),ue()),R&&k&&le())}),[t,R,re,ue,le,k,J]),(0,i.d4)((()=>{t&&Z&&J&&fe()}),[t,Z,fe,J]),(0,i.d4)((()=>{t&&!M&&he()}),[t,M,he]),(0,i.d4)((()=>{const e=(0,g.dx)();t&&e?.tgaddr&&(0,at.ou)(decodeURIComponent(e.tgaddr))}),[t]),(0,ot.Z)((e=>{let[n]=e;const a=(0,g.VX)();a&&!n&&t&&Ee({id:a.chatId,threadId:a.threadId,type:a.type})}),[t,Ee]);const Ae=(0,pt.Z)(r,void 0,!0,void 0,w),Ne=(0,i.sO)(!1),xe=(0,ht.Z)();(0,ct.Z)((e=>{let[t]=e;if(void 0===t||r===t||0===S)return;Ne.current=!0,s.wZ&&(0,N.T2)((()=>{document.body.classList.toggle("android-left-blackout-open",!r)}));const n=(0,gt.YW)();(0,nt.L)(document.getElementById("MiddleColumn"),(()=>{n(),Ne.current=!1,xe()}))}),[S,xe,r]);const Be=(0,pt.Z)(d,void 0,!0,void 0,w),Le=(0,i.sO)(!1),[Ue,je]=(0,i.eJ)(d);(0,ct.Z)((e=>{let[t]=e;if(void 0===t||d===t)return;if(0===S)return void je(d);Le.current=!0;const n=(0,gt.YW)();(0,nt.L)(document.getElementById("RightColumn"),(()=>{n(),Le.current=!1,xe(),je(d)}))}),[S,xe,d]);const Oe=(0,tt.Z)(Ae.hasShownClass&&"left-column-shown",Ae.hasOpenClass&&"left-column-open",Ne.current&&"left-column-animating",Be.hasShownClass&&"right-column-shown",Be.hasOpenClass&&"right-column-open",Le.current&&"right-column-animating",Ue&&"narrow-message-list",w&&"history-animation-disabled"),Fe=(0,i.I4)((()=>{ne({isBlurred:!0})}),[ne]),_e=(0,i.I4)((()=>{ne({isBlurred:!1}),document.title.includes(o.ouc)||ke(),A(!1)}),[ne,ke]),De=(0,i.I4)((()=>{pe()}),[pe]),qe=(0,i.I4)((()=>{ge()}),[ge]);return(0,it.Z)(Fe,_e),rt(Fe),function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,i.d4)((()=>{if(s.$b){if(!e)return dt?.setAttribute("content",lt),s.cj&&!s.fl&&document.addEventListener("gesturestart",mt),()=>{dt?.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),s.cj&&!s.fl&&document.removeEventListener("gesturestart",mt)};dt?.setAttribute("content",ut)}}),[e])}(l),i.ZP.createElement("div",{id:"Main",className:Oe},i.ZP.createElement(yn,null),i.ZP.createElement(kr,{isMobile:n}),i.ZP.createElement(hc,{isMobile:n}),i.ZP.createElement(pc,{isOpen:l}),i.ZP.createElement(Ec,{isOpen:u}),i.ZP.createElement(Xc,{requestedDraft:q}),i.ZP.createElement(Cc,{isOpen:m}),i.ZP.createElement(Sc,{isOpen:h}),p&&i.ZP.createElement(oa,{key:p.id,message:p,noUi:!0}),i.ZP.createElement(Mc,{url:I}),i.ZP.createElement(qc,{urlAuth:H,currentUser:G}),i.ZP.createElement(Rc,{isOpen:v}),i.ZP.createElement(wt,{isOpen:Boolean(y),onClose:De,stickerSetShortName:y}),i.ZP.createElement(Wc,{customEmojiSetIds:P,onClose:qe}),f&&i.ZP.createElement(kc,{groupCallId:f}),i.ZP.createElement(Tc,{isActive:Boolean(f||T)}),i.ZP.createElement(Bc,{isOpen:Boolean(x||B),userId:x,isByPhoneNumber:B}),i.ZP.createElement(Zc,{openedGame:L,gameTitle:U}),i.ZP.createElement(Uc,{webApp:$}),i.ZP.createElement(yc,null),i.ZP.createElement(Dc,null),i.ZP.createElement(Ac,{isActive:T}),i.ZP.createElement(Zt,{isForAppBadge:!0}),i.ZP.createElement(Lc,{isOpen:j}),i.ZP.createElement(jc,{bot:F,type:O?.type}),i.ZP.createElement(Oc,{bot:_}),i.ZP.createElement(Yc,{requestedAttachBotInChat:D}),i.ZP.createElement(xc,null),V&&i.ZP.createElement($c,{isOpen:V}),i.ZP.createElement(Vc,{limit:b}),i.ZP.createElement(Gc,{isOpen:z,onClose:Ze}),i.ZP.createElement(Hc,{isOpen:W,onClose:Ce}),i.ZP.createElement(zc,{deleteFolderDialogId:Y}))})));var Qc=n(62821),ed=n(21179),td=n(99364),nd=n(8337);var ad=n(2092);const sd=(0,i.X$)((0,a.c$)((e=>({passcodeSettings:e.passcode})))((e=>{let{isLocked:t,passcodeSettings:n}=e;const{unlockScreen:s,signOut:o,logInvalidUnlockAttempt:r,resetInvalidUnlockAttempts:c}=(0,a.Sv)(),{invalidAttemptsCount:d,isLoading:l}=n,u=(0,kt.Z)(),[m,h]=(0,i.eJ)(""),[p,g]=(0,i.eJ)(!1),[f,I,v]=(0,Et.Z)(!1),{shouldRender:w}=(0,pt.Z)(t);(0,It.Z)(c,d&&d>=5?18e4:void 0);const b=(0,i.I4)((()=>{h("")}),[]),y=(0,i.I4)((e=>{d&&d>=5?h(u("FloodWait")):(h(""),(0,O.so)(e).then(s,(()=>{r(),h(u("lng_passcode_wrong"))})))}),[d,u,r,s]);(0,i.d4)((()=>{d&&d>=5?h(u("FloodWait")):0===d&&h("")}),[d,u]);const P=(0,i.I4)((()=>{v(),o({forceInitApi:!0})}),[v,o]);if(w)return i.ZP.createElement("div",{className:"sY59IPNwkaRsrfYPhEJc"},i.ZP.createElement("div",{className:"DlErQEIDwmZ0duQgO_2b",dir:u.isRtl?"rtl":void 0},i.ZP.createElement(ed.Z,{tgsUrl:Qc.l.Lock,previewUrl:ad,size:160,className:"ar9YdQbWJreREHmnZa9m"}),i.ZP.createElement(td.Z,{key:"password-form",shouldShowSubmit:!0,shouldDisablePasswordManager:!0,isLoading:l,error:m,placeholder:u("Passcode.EnterPasscodePlaceholder"),submitLabel:u("Next"),clearError:b,isPasswordVisible:p,noRipple:!0,onChangePasswordVisibility:g,onSubmit:y}),i.ZP.createElement("div",{className:"uOmdTQr_cJEvuTkQipx7"},i.ZP.createElement("p",null,i.ZP.createElement(nd.Z,{onClick:I},"Log out")," ","if you don't remember your passcode."),i.ZP.createElement("p",null,i.ZP.createElement(Ft.Z,{color:"translucent",size:"tiny",isText:!0,onClick:I},u("AccountSettings.Logout"))))),i.ZP.createElement(jn.Z,{isOpen:f,onClose:v,text:u("lng_sure_logout"),confirmLabel:u("AccountSettings.Logout"),confirmHandler:P,confirmIsDestructive:!0}))})));o.eMD&&console.log(">>> FINISH LOAD MAIN BUNDLE");const{passcode:{isScreenLocked:od},connectionState:id}=(0,a.Rd)();id||od||s.Eo||(0,a.Sv)().initApi()},68973:(e,t,n)=>{e.exports=n.p+"encoderWorker.min.8ea62f6317fbac7d4558.js"}}]);
//# sourceMappingURL=5769.c3dbfbe711671c6ba22d.js.map