2 lines
368 KiB
JavaScript
2 lines
368 KiB
JavaScript
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[5769],{22894:(e,t,n)=>{n.r(t),n.d(t,{LockScreen:()=>Xc,Main:()=>$c});var a=n(33555),s=n(77361),o=n(83716),i=n(60748),r=(n(89005),n(6137)),c=n(5161),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=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 E=o.ckE+o.fK3;let S;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(S&&(clearTimeout(S),S=void 0),S=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?E: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.59**\n\n[👏](customEmoji:5471921242866981303) **Harder**\n• Chats can be opened in multiple browser tabs or windows.\n• A spoiler effect is available for photos and videos.\n• You can replace profile photos of contacts or suggest new ones.\n• Your account can have a public profile photo, in addition to the main one.\n• Media can be sent from your clipboard without compression.\n• Topics are able to be created or edited in groups.\n• Syntax highlighting is now supported for Type (.tl) language.\n\n[🤩](customEmoji:5373026167722876724) **Better**\n• Multiple media items can be sent as separate messages from the attachment menu.\n• The audio player now supports multiple playback speeds.\n• The topic panel can be quickly closed with a swipe.\n\n[🚀](customEmoji:5445284980978621387) **Faster**\n• Animations in the topic panel are faster and lighter.\n\n[💪](customEmoji:5471883477219549006) **Stronger**\n• Fixed some chats being hidden in the chat list.\n• Fixed the app reloading when resizing the window.\n• Fixed missing video in group video calls.\n• Fixed problems with deleting chat history.\n• Fixed missing text formats when composing a message.\n• Fixed jumping cursor when editing chat description.\n• Fixed app URL not updating after closing a chat.\n• Fixed yellow border when switching profile photos.\n• Fixed call indicator not hiding after a call ends.\n• Various layout 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)("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(65116),k=n(91947),T=n(26926),N=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")}))}function x(e){document.title!==e&&(document.title=e)}let B;(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,T.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)("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,k.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)("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:s}=n,o=(0,m._w)();s||t.updateIsOnline(!0);const i=(0,I.Tw)(s?[...e.blurredTabTokens,o]:e.blurredTabTokens.filter((e=>e!==o)));return i.length===(0,m.s1)().length&&t.updateIsOnline(!1),s&&1===i.length&&(B&&clearInterval(B),B=setInterval((()=>{e=(0,a.Rd)(),e={...e,notificationIndex:(e.notificationIndex||0)+1,allNotificationsCount:(0,N.xW)()},(0,a.R3)(e)}),1e3)),!i.length&&B&&(clearInterval(B),B=void 0,e={...e,notificationIndex:void 0}),{...e,blurredTabTokens:i,initialUnreadNotifications:s?(0,N.xW)():void 0}})),(0,a.iw)("updatePageTitle",((e,t,n)=>{const{isInactive:a,notificationCount:s,tabId:i=(0,m._w)()}=n||{};if(a)return void x(`${o.Tih} ${o.ouc}`);if(s)return void x(`${s} notification${s>1?"s":""}`);const r=(0,d.Bt)(e,i);if(r){const{chatId:t,threadId:n}=r,a=(0,d.Z1)(e,t);if(a)return a.isForum&&a.topics?.[n]?void x(`${a.title} › ${a.topics[n].title}`):void x(a.title)}x(o.Tih)})),(0,R.ll)((e=>{if(void 0===e.notificationIndex||void 0===e.allNotificationsCount)return;const{updatePageTitle:t}=(0,a.Sv)(),n=e.notificationIndex,s=e.allNotificationsCount;if(document.title.includes(o.ouc)||!e.initialUnreadNotifications)return A(!1),void t();if(n%2==0){const n=s-e.initialUnreadNotifications;if(n>0)return t({notificationCount:n}),void A(!0)}t(),A(!1)})),(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 L=n(50214),j=n(95281),O=n(5872),F=n(69118),_=n(35369);let D=!1;(0,F.Gq)((()=>{(0,a.Rd)().passcode.hasPasscode&&!D&&1===Object.keys((0,a.Rd)().byTabId).length&&(0,L.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,j.AU)(s);const o=JSON.stringify({...(0,L.K8)(),userId:e.currentUserId});e=(0,a.Rd)();const i=(0,O.Uf)((0,c.vu)(e,{hasPasscode:!0,error:void 0,isLoading:!1}));await(0,j.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,O.jA)(!0)})),(0,a.iw)("clearPasscode",(e=>((0,j.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,L.wX)(r,r.userId);const d=e;(e=JSON.parse(i)).byTabId=d.byTabId,(0,O.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,j.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,F.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.Cm)(e,v,n),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 E=v===o.awM?e.serviceNotifications.filter((e=>{let{isDeleted:t}=e;return!t})).map((e=>{let{message:t}=e;return t})):[],S=[].concat(y,E),M=(0,I.ee)(S,"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,F.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,F.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,F.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=l.isForum?(0,d.qS)(e,i,r):void 0,h={...n,chat:l,replyingTo:(0,d.Yy)(e,i,r),replyingToTopId:u,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 g=!n.attachments||n.attachments.length<=1,f=!g&&n.shouldGroupMessages;if(g){const{attachments:t,...n}=h;X(e,{...n,attachment:t?t[0]:void 0},a)}else if(f){const{text:t,entities:n,attachments:s,...i}=h,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}=h;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}=n;if(!i)return;const{text:r,entities:l}=i,m=(0,d.Z1)(e,s),h=(0,d.dy)(e,s);h&&(0,u.NB)(h)||(await(0,$.t9)("saveDraft",{chat:m,text:r,entities:l,replyToMsgId:(0,d.Yy)(e,s,o),threadId:(0,d.qS)(e,s,o)})||(i.isLocal=!0),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}=n;if(!(0,d.Ms)(e,a,s))return;const i=(0,d.Z1)(e,a);return o||(0,$.t9)("clearDraft",i,(0,d.qS)(e,a,s)),e=(0,c.pf)(e,a,s,"draft",void 0),(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.Cm)(e,l,u);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.Cm)(e,s,o);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})}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})})),(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})}));var J=n(85765),K=n(9211);const Q=(0,F.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,F.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,F.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 E=(0,d.we)(e,g);E&&(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),e=(0,c.xj)(e,t.id,n,C),(0,a.R3)(e),l||ie(e,t,n,s,P,!0,g))}let re,ce;(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,E=(0,I.ee)(P,"id"),S=Object.keys(E).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,E),e=(0,c.dx)(e,u.id,l,S,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)||{};let r=i&&(0,d.Z1)(e,i);if(!i||!r)return;if(e=(0,c.H9)(e,f.wv.InProgress,o),(0,a.R3)(e),(0,u.G9)(r)){if(r=await(0,q.bZ)(e,t,r,o),!r)return;t.openChat({id:r.id,tabId:o})}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})})),(0,a.iw)("sync",((e,t)=>{o.eMD&&console.log(">>> START SYNC"),re&&clearTimeout(re),e=(0,a.Rd)(),e={...e,isSyncing:!0},(0,a.R3)(e),re=window.setTimeout((()=>{e=(0,a.Rd)(),e={...e,isSyncing:!1},(0,a.R3)(e),re=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;for(const{id:m}of Object.values(e.byTabId)){e=(0,a.Rd)();const{chatId:h,threadId:g}=(0,d.Bt)(e,m)||{},f=g||r._f,v=g&&h?(0,d.tZ)(e,h,g):void 0,w=v?.originChannelId||h,b=Object.keys(e.messages.byChatId).reduce(((t,n)=>(t[n]={},t[n].draft=(0,d.Ms)(e,n,f),t[n].editingId=(0,d._$)(e,n,f),t[n].editingDraft=(0,d.s)(e,n,f),t)),{}),y=w?e.chats.byId[w]:void 0;if(w&&y){const t=await(i=y,l=f,u=v?.lastReadInboxMessageId,(0,$.t9)("fetchMessages",{chat:i,threadId:l,offsetId:u||i.lastReadInboxMessageId,addOffset:-(Math.round(o.hT6/2)+1),limit:o.hT6}));e=(0,a.Rd)();const{chatId:r}=(0,d.Bt)(e,m)||{};if(t&&r===h){const a=(0,d.Zw)(e,w),i=h===o.awM?e.serviceNotifications.filter((e=>{let{isDeleted:t}=e;return!t})).map((e=>{let{message:t}=e;return t})):[],r=y.isForum&&y.topics?Object.values(y.topics).map((e=>{let{lastMessageId:t}=e;return a[t]})).filter(Boolean):[],l=[].concat(t.messages,i,r),u=(0,I.ee)(l,"id"),m=Object.keys(u).map(Number);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,w,u),e=(0,c.xj)(e,w,f,m),Object.values(e.byTabId).forEach((t=>{let{id:n}=t;const{chatId:a,threadId:s}=(0,d.Bt)(e,n)||{};a===w&&s===f&&(e=(0,c.y9)(e,w,f,m,n))})),e=(0,c.GL)(e,(0,I.ee)(t.chats,"id")),e=(0,c.eD)(e,(0,I.ee)(t.users,"id")),e=(0,c.j6)(e,w,t.repliesThreadInfos),n=!0}}Object.keys(b).forEach((t=>{e=(0,c.sN)(e,t,f,b[t])})),(0,a.R3)(e),y?.isForum&&(t.loadTopics({chatId:w,force:!0}),g&&g!==r._f&&t.loadTopicById({chatId:w,topicId:g,shouldCloseChatOnError:!0}))}var i,l,u;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)})),(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,N.S1)(),n({listType:"archived",shouldReplace:!0}),(0,$.t9)("fetchCurrentUser"),s()}})})),(0,R.ll)((e=>{const{connectionState:t,authState:n}=e,{isMasterTab:s}=(0,d.jU)(e);!s||ce?.connectionState===t&&ce?.authState===n||("connectionStateReady"===t&&"authorizationStateReady"===n&&(0,a.Sv)().sync(),ce=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 de=(0,F.P2)((e=>e()),500,!1);function le(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 ue(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&&de((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 me=n(18629);const he=s.cj||s.wZ;class pe{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(){he&&(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(!he){const t=window.open(e,void 0,this.features);t?t.focus():this.onFail?.()}}cancelPreOpen(){this.preOpened?.close(),this.preOpened=void 0}}const ge="https://prizes.gamee.com/",fe=(0,F.Ds)((e=>e()),500,!1);async function Ie(e,t,n,s){await(0,$.t9)("toggleAttachBot",{bot:t,isWriteAllowed:s,isEnabled:n}),e=(0,a.Rd)(),await ve(e)}async function ve(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 we(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 be(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 ye;async function Pe(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&&(ye||(ye=new pe("popup,width=800,height=600",(()=>{u({message:"Allow browser to open popup window",tabId:d})}))),ye.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(ge)?ye.open(v):(ye.cancelPreOpen(),p({url:v,chatId:n.id,messageId:a,tabId:d})):h({url:v,tabId:d}))}function Ze(e){const t=Object.keys(e).map((t=>`${t}=${e[t]}`)).join("&");return t.length>0?`?${t}`:""}async function Ce(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;Pe(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;Pe(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,me.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,me.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}),be(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),be(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=le(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=le(e,o,u,l),(0,a.R3)(e)}(i!==u.query||u.canLoadMore)&&fe((()=>{!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=le(e=ue(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=ue(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=le(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=le(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:E}=Z;e=(0,a.Rd)(),e=(0,p.i)(e,{webApp:{url:C,botId:o,queryId:E,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 ve(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 Ie(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,me.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 Ie(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),we(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&&we(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),we(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&&we(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 Ce(e,{slug:n.slug},s);else{const t=(0,d.Z1)(e,n.chatId);if(!t)return;o=await Ce(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=Ze({"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 Se=n(40647),Me=n(74399);const Re=32*Me.Gw,ke=45.5*Me.Gw,Te=26.5*Me.Gw,Ne=16*Me.Gw,Ae=16.125*Me.Gw;var xe=n(43858),Be=n(53475),Ue=n(4907);function Le(e,t){return t-((0,d.jU)(e).isLeftColumnShown&&!(0,C.W7)()?e.leftColumnWidth||((n=xe.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):Te):0);var n}function je(e,t,n){return(0,Be.a4)(e,t,n,void 0,!0)}let Oe=0;(0,a.iw)("loadAvailableReactions",(async e=>{const t=await(0,$.t9)("getAvailableReactions");t&&(t.forEach((e=>{e.aroundAnimation&&Se.he(`sticker${e.aroundAnimation.id}`,r.IU.BlobUrl),e.centerIcon&&Se.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:Oe++,animatedEffect:a,x:Le(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)("openChat",((e,t,n)=>{const{id:a,tabId:s=(0,m._w)()}=n,o=(0,d.Bt)(e,s)?.chatId;return o===a?e:(0,p.i)(e,{activeReactions:{}},s)})),(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:Le(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=je(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=je(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=je(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}),je(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 Fe=n(28406);(0,a.iw)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateChat":{const{isForum:s}=(0,d.Z1)(e,n.id)||{};return 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,Fe.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)||{};i===n.id&&"isForum"in n.chat&&s!==n.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,Fe.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=je(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 _e=n(84112);const De=350;function qe(e,t,n,a,s,o,i){const r=i?.reactions;if(r&&(0,_e.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=je(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,F.R3)((()=>{(0,Fe.rh)({chat:s,message:a,isReaction:!0})}))}else l&&(e=je(e,t,{unreadReactionsCount:(s?.unreadReactionsCount||1)-1,unreadReactions:s?.unreadReactions?.filter((e=>e!==n))}));return e}function $e(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)}return s?(0,c.P4)(e,t,n,a):(0,c.cY)(e,t,n,a)}function Ge(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 He(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=Ge(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,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 Ve(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 ze(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 We(e,t,n,s){if(t){const o=(0,d.Z1)(e,t);if(!o)return;n.forEach((n=>{const a=ze(e=(0,c.cY)(e,t,n,{isDeleting:!0}),t);a&&(e=Ve(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=Ge(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})}))}),De)}const o=[];n.forEach((t=>{const n=(0,d.X5)(e,t);if(n){o.push(n);const s=ze(e=(0,c.cY)(e,n,t,{isDeleting:!0}),n);s&&(e=Ve(e,n,s,!0)),setTimeout((()=>{e=(0,a.Rd)(),e=(0,c.K4)(e,n,[t]),(0,a.R3)(e)}),De)}})),(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=He(e=$e(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&&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=Ve(e,s,m),(0,a.R3)(e)}),De)}else e=Ve(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=$e(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=$e(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=Ve(e,t,l)),o.reactions&&r&&(e=qe(e,t,s,o.reactions,r,l.isOutgoing,i)),(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=$e(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=He(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=Ve(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)),(0,d.Z1)(e,s)?.isForum&&i.lastReadInboxMessageId!==l?.lastReadInboxMessageId&&t.loadTopicById({chatId:s,topicId:o}),(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;We(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)}),De))}(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);We(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=qe(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}}}));const Xe=(0,F.P2)((function(){let e=(0,a.Rd)();e=(0,c.ps)(e,{...e.users.statusesById,...Ye}),(0,a.R3)(e),Ye={}}),3e3,!0);let Ye={};(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)&&t.openPremiumModal({isSuccess:!0,tabId:s})})),(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,Ye[a]=s,void Xe();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 Je=n(78958),Ke=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,Je.dc)(e,n.call.id);const a=(0,Ke.$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,Je.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,Je.B6)(e,t,n.id,n,Boolean(o)||i===n.id))})),o&&(e=(0,Je.AH)(e,t,{nextOffset:o}));const r=(0,Ke.$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,F.R3)((()=>{e=(0,a.Rd)(),(0,Fe.TO)({call:r,user:(0,Ke.fu)(e)})})),(0,U.o5)(),(0,U.CW)(e,t,r.isVideo,(0,m._w)()),e={...e,phoneCall:r},(0,p.i)(e,{isCallPanelVisible:!1},(0,m._w)())}}}));var Qe=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,Qe.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 et=n(46752),tt=n(1279),nt=n(53551),at=n(274),st=n(45332);function ot(e){(0,i.d4)((()=>(0,F.Gq)(e)),[e])}var it=n(34446);const rt=document.querySelector('meta[name="viewport"]'),ct=rt?.getAttribute("content")||"",dt="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover";function lt(e){e.preventDefault()}var ut=n(65326),mt=n(31212),ht=n(18674),pt=n(62357),gt=n(99203),ft=n(48778);const It=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"StickerSetModal",!t);return n?i.ZP.createElement(n,e):void 0}));var vt=n(2155),wt=n(95616),bt=n(17358);const yt=(0,i.X$)((e=>{let{isForAppBadge:t}=e;(0,wt.yi)();const n=(0,N.xW)();if((0,i.d4)((()=>{t&&(0,bt.w)(n)}),[t,n]),!t&&n)return i.ZP.createElement("div",{className:"unread-count active"},(0,vt.bi)(n))}));var Pt=n(23989),Zt=n(53455),Ct=n(60706),Et=n(73541),St=n(2255),Mt=n(59107),Rt=n(54416),kt=n(27370),Tt=n(706);let Nt;function At(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?Nt.syncing:Nt.online:Nt.waitingForNetwork,c=r===Nt.online||o?"none":a?"middleHeader":s?"minimized":"overlay",r===Nt.waitingForNetwork?d=e("WaitingForNetwork"):r===Nt.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"}(Nt||(Nt={}));var xt=n(36046),Bt=n(73217),Ut=n(53106),Lt=n(58964),jt=n(231),Ot=n(69589),Ft=n(49187),_t=n(83321),Dt=n(40126),qt=n(49204);const $t=(0,i.X$)((e=>{let{connectionStatus:t,connectionStatusText:n,onClick:a}=e;const s=(0,Mt.Z)();return i.ZP.createElement("div",{id:"ConnectionStatusOverlay",dir:s.isRtl?"rtl":void 0,onClick:a},i.ZP.createElement(qt.Z,{color:"black"}),i.ZP.createElement("div",{className:"state-text"},i.ZP.createElement(St.Z,{activeKey:t,name:"slide-fade"},n)),i.ZP.createElement(jt.Z,{round:!0,size:"tiny",color:"translucent-black"},i.ZP.createElement("span",{className:"icon-close"})))}));var Gt=n(28183),Ht=n(96459),Vt=n(4863),zt=n(6202);const Wt="HO3tML0GAC9vTH28baKB",Xt=(0,i.X$)((e=>{let{reaction:t,isLottie:n,className:a}=e;const o=(0,u.RK)(t.documentId),r=(0,zt.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,et.Z)("HAg4STRlxDV3frYuABYr",a)},c.map((e=>{const a=`--offset-path: path('${e}');`;return n?i.ZP.createElement(Ht.Z,{documentId:t.documentId,className:Wt,style:a,withSharedAnimation:!0}):i.ZP.createElement("img",{src:r,alt:"",className:Wt,style:a})})))})),Yt=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"StatusPickerMenu",!t);return n?i.ZP.createElement(n,e):void 0})),Jt=(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,Ct.Z)(!1),[u,m,h]=(0,Ct.Z)(!1),[p,g,f]=(0,Ct.Z)(!1),{isMobile:I}=(0,C.ZP)(),w=t?.until?1e3*t.until-Date.now()+1e3*(0,v.Qj)():void 0;(0,Gt.Z)(s,w),(0,at.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,Gt.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(Xt,{reaction:t,isLottie:!0,className:"emoji-status-effect"}),i.ZP.createElement(jt.Z,{round:!0,ref:r,ripple:!I,size:"smaller",color:"translucent",className:"emoji-status",onClick:y},t?i.ZP.createElement(Ht.Z,{key:t.documentId,documentId:t.documentId,size:24,loopLimit:o.y3O}):i.ZP.createElement(Vt.Z,null)),i.ZP.createElement(Yt,{statusButtonRef:r,isOpen:p,onEmojiStatusSelect:b,onClose:f}))}))),Kt=[0,1,2],Qt=(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}=e,{byId:l}=e.chats,{isConnectionStatusMinimized:u,animationLevel:m}=e.settings.byKey;return{searchQuery:n,isLoading:!!a&&Boolean(a.chats||a.messages),currentUserId:i,chatsById:l,globalSearchChatId:s,searchDate:o,theme:(0,d.Pu)(e),animationLevel:m,connectionState:r,isSyncing:c,isMessageListOpen:Boolean((0,d.Bt)(e)),isConnectionStatusMinimized:u,isCurrentUserPremium:(0,d.wV)(e),areChatsLoaded:Boolean(e.chats.listIds.active),hasPasscode:Boolean(e.passcode.hasPasscode),canInstall:Boolean(t.canInstall)}}))((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:E,chatsById:S,connectionState:M,isSyncing:R,isMessageListOpen:k,isConnectionStatusMinimized:T,areChatsLoaded:N,hasPasscode:A,canInstall:x}=e;const{openChat:B,setGlobalSearchDate:U,setSettingOption:L,setGlobalSearchChatId:j,openChatByUsername:O,lockScreen:F,requestNextSettingsScreen:_,skipLockOnUnload:D,openUrl:q}=(0,a.Sv)(),$=(0,Mt.Z)(),{isMobile:G}=(0,C.ZP)(),H=n===f.du.ChatList,V=(0,i.Ye)((()=>P?(0,ae.xH)(new Date(1e3*P)):void 0),[P]),z=(0,i.Ye)((()=>H&&S?Object.values(S).reduce(((e,t)=>(0,u.pE)(t)&&t.unreadCount?e+1:e),0):0),[H,S]),{connectionStatus:W,connectionStatusText:X,connectionStatusPosition:Y}=At($,M,R,k,T,!N),J=(0,i.I4)((e=>{e.preventDefault(),e.stopPropagation(),A?F():_({screen:f.MT.PasscodeDisabled})}),[A,F,_]);(0,Et.y)({"Ctrl+Shift+L":J,"Alt+Shift+L":J,"Meta+Shift+L":J,...s.fl&&{"Mod+L":J}});const K=window.location.hostname===o.xHY||o.Cgt,Q=(0,i.Ye)((()=>e=>{let{onTrigger:t,isOpen:n}=e;return i.ZP.createElement(jt.Z,{round:!0,ripple:H&&!G,size:"smaller",color:"translucent",className:n?"active":"",onClick:H?t:()=>p(),ariaLabel:H?$("AccDescrOpenMenu2"):"Return to chat list"},i.ZP.createElement("div",{className:(0,et.Z)("animated-menu-icon",!H&&"state-back",w&&"no-animation")}))}),[H,G,$,p,w]),ee=(0,i.I4)((()=>{g||c("")}),[g,c]),te=(0,i.I4)((()=>{L({isConnectionStatusMinimized:!T})}),[T,L]),ne=(0,i.I4)((()=>{B({id:b,shouldReplaceHistory:!0})}),[b,B]),se=(0,i.I4)((e=>{e.stopPropagation();const t="light"===Z?"dark":"light";L({theme:t}),L({shouldUseSystemTheme:!1}),(0,kt.Z)(t,E===o.zy8)}),[E,L,Z]),oe=(0,i.I4)((e=>{e.stopPropagation();const t=0===E?2:0;Kt.forEach(((e,n)=>{document.body.classList.toggle(`animation-level-${n}`,t===n)})),L({animationLevel:t})}),[E,L]),ie=(0,i.I4)((()=>{window.open(o.ulW,"_blank","noopener")}),[]),re=(0,i.I4)((()=>{localStorage.setItem("kz_version",JSON.stringify("K")),(0,Tt.W8)(),D()}),[D]),ce=(0,i.I4)((()=>{D()}),[D]),de=(0,i.I4)((()=>{O({username:$("Settings.TipsUsername")})}),[$,O]),le=(0,i.I4)((()=>{q({url:o.mUA})}),[q]),ue=(0,i.I4)((()=>{F()}),[F]),me=Boolean(y)||n===f.du.GlobalSearch||n===f.du.Contacts;(0,i.d4)((()=>me?(0,Pt.Z)((()=>p())):void 0),[me,p]);const he=n===f.du.Contacts?$("SearchFriends"):$("Search"),pe=o.Tjg?`${o.JiC} Beta (master)`:o.eMD?"master":o.JiC,{shouldDisableDropdownMenuTransitionRef:ge,handleDropdownMenuTransitionEnd:fe}=(0,Bt.Z)(t),Ie=(0,i.Ye)((()=>i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(Lt.Z,{icon:"saved-messages",onClick:ne},$("SavedMessages")),i.ZP.createElement(Lt.Z,{icon:"archive",onClick:h},i.ZP.createElement("span",{className:"menu-item-name"},$("ArchivedChats")),z>0&&i.ZP.createElement("div",{className:"right-badge"},z)),i.ZP.createElement(Lt.Z,{icon:"user",onClick:m},$("Contacts")),i.ZP.createElement(Lt.Z,{icon:"settings",onClick:l},$("Settings")),i.ZP.createElement(Lt.Z,{icon:"darkmode",onClick:se},i.ZP.createElement("span",{className:"menu-item-name"},$("lng_menu_night_mode")),i.ZP.createElement(_t.Z,{id:"darkmode",label:$("dark"===Z?"lng_settings_disable_night_theme":"lng_settings_enable_night_theme"),checked:"dark"===Z,noAnimation:!0})),i.ZP.createElement(Lt.Z,{icon:"animations",onClick:oe},i.ZP.createElement("span",{className:"menu-item-name capitalize"},$("Appearance.Animations").toLowerCase()),i.ZP.createElement(_t.Z,{id:"animations",label:"Toggle Animations",checked:E>0})),i.ZP.createElement(Lt.Z,{icon:"help",onClick:de},$("TelegramFeatures")),i.ZP.createElement(Lt.Z,{icon:"bug",onClick:le},"Report Bug"),o.Tjg&&i.ZP.createElement(Lt.Z,{icon:"permissions",onClick:ie},"Beta Changelog"),K&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(Lt.Z,{icon:"char-K",href:"https://web.telegram.org/k/",onClick:re},"Switch to K Version"),i.ZP.createElement(Lt.Z,{icon:"char-W",href:"https://web.telegram.org/?legacy=1",onClick:ce},"Switch to Old Version")),x&&i.ZP.createElement(Lt.Z,{icon:"install",onClick:(0,xt.G)()},"Install App"))),[E,z,x,oe,le,ie,se,de,ne,ce,re,$,h,m,l,Z,K]);return i.ZP.createElement("div",{className:"LeftMainHeader"},i.ZP.createElement("div",{id:"LeftMainHeader",className:"left-header"},$.isRtl&&i.ZP.createElement("div",{className:"DropdownMenuFiller"}),i.ZP.createElement(Ut.Z,{trigger:Q,footer:`${o.iCi} ${pe}`,className:(0,et.Z)($.isRtl&&"rtl",t&&$.isRtl&&"right-aligned",ge.current&&$.isRtl&&"disable-transition"),positionX:t&&$.isRtl?"right":"left",onTransitionEnd:$.isRtl?fe:void 0},Ie),i.ZP.createElement(Ot.Z,{inputId:"telegram-search-input",parentContainerClassName:"LeftSearch",className:(0,et.Z)(y||P?"with-picker-item":void 0,t&&"SearchInput--hidden"),value:d?void 0:r||g,focused:me,isLoading:I||"minimized"===Y,spinnerColor:"minimized"===Y?"yellow":void 0,spinnerBackgroundColor:"minimized"===Y&&"light"===Z?"light":void 0,placeholder:he,autoComplete:"off",canClose:Boolean(y||P),onChange:c,onReset:p,onFocus:ee,onSpinnerClick:"minimized"===Y?te:void 0},V&&i.ZP.createElement(Ft.Z,{icon:"calendar",title:V,canClose:!0,isMinimized:Boolean(y),className:"search-date",onClick:U,clickArg:{date:void 0}}),y&&i.ZP.createElement(Ft.Z,{chatOrUserId:y,onClick:j,canClose:!0,clickArg:{id:void 0}})),v&&i.ZP.createElement(Jt,null),A&&i.ZP.createElement(jt.Z,{round:!0,ripple:!G,size:"smaller",color:"translucent",ariaLabel:`${$("ShortcutsController.Others.LockByPasscode")} (Ctrl+Shift+L)`,onClick:ue,className:(0,et.Z)(!v&&"extra-spacing")},i.ZP.createElement("i",{className:"icon-lock"})),i.ZP.createElement(Dt.Z,{isOpen:"overlay"===Y,isCustom:!0,className:"connection-state-wrapper"},i.ZP.createElement($t,{connectionStatus:W,connectionStatusText:X,onClick:te}))))})));var en=n(64963),tn=n(46590),nn=n(93133),an=n(55993);const sn=(0,i.X$)((0,a.c$)((e=>{const{chatFolders:{byId:t,orderedIds:n},currentUserId:a,lastSyncTime:s}=e,{shouldSkipHistoryAnimations:o,activeChatFolder:i}=(0,d.jU)(e);return{chatFoldersById:t,orderedFolderIds:n,activeChatFolder:i,currentUserId:a,isForumPanelOpen:(0,d.nd)(e),lastSyncTime:s,shouldSkipHistoryAnimations:o,maxFolders:(0,K.M)(e,"dialogFilters")}}))((e=>{let{foldersDispatch:t,onScreenSelect:n,chatFoldersById:r,orderedFolderIds:c,activeChatFolder:d,currentUserId:l,isForumPanelOpen:u,lastSyncTime:m,shouldSkipHistoryAnimations:h,maxFolders:p,shouldHideFolderTabs:g}=e;const{loadChatFolders:f,setActiveChatFolder:I,openChat:v}=(0,a.Sv)(),w=(0,i.sO)(null),b=(0,Mt.Z)();(0,i.d4)((()=>{m&&!c&&f()}),[m,f,c]);const y=(0,i.Ye)((()=>({id:o.NfV,title:c?.[0]===o.NfV?b("FilterAllChatsShort"):b("FilterAllChats")})),[c,b]),P=(0,i.Ye)((()=>c?c.map((e=>e===o.NfV?y:r[e]||{})).filter(Boolean):void 0),[r,y,c]),Z=P?.findIndex((e=>e.id===o.NfV)),C=Z===d,E=0===d,S=(0,wt.yi)(),M=(0,i.Ye)((()=>{if(P&&P.length)return P.map(((e,t)=>{let{id:n,title:a}=e;const s=n!==o.NfV&&t>p-1;return{id:n,title:a,badgeCount:S[n]?.chatsCount,isBadgeActive:Boolean(S[n]?.notificationsCount),isBlocked:s}}))}),[P,S,p]),R=(0,i.I4)((e=>{I({activeChatFolder:e},{forceOnHeavyAnimation:!0})}),[I]);(0,i.d4)((()=>{M&&M.length&&d>=M.length&&I({activeChatFolder:0})}),[d,M,I]),(0,i.d4)((()=>{if(s.$b&&M?.length&&!u)return(0,en.sf)(w.current,{selectorToPreventScroll:".chat-list",onSwipe:(e,t)=>t===en.eM.Left?(I({activeChatFolder:Math.min(d+1,M.length-1)},{forceOnHeavyAnimation:!0}),!0):t===en.eM.Right&&(I({activeChatFolder:Math.max(0,d-1)},{forceOnHeavyAnimation:!0}),!0)})}),[d,M,u,I]);const k=(0,i.sO)();k.current=!E,(0,i.d4)((()=>k.current?(0,Pt.Z)((()=>{k.current&&I({activeChatFolder:0})})):void 0),[d,I]),(0,tn.Z)({isActive:!E,onBack:()=>I({activeChatFolder:0},{forceOnHeavyAnimation:!0})}),(0,i.d4)((()=>{const e=e=>{if(e.ctrlKey&&e.shiftKey&&e.code.startsWith("Digit")&&M){const[,t]=e.code.match(/Digit(\d)/)||[];if(!t)return;if("0"===t)return void v({id:l,shouldReplaceHistory:!0});const n=Number(t)-1;if(n>M.length-1)return;I({activeChatFolder:n},{forceOnHeavyAnimation:!0}),e.preventDefault()}};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}}),[l,M,v,I]);const{shouldRender:T,transitionClassNames:N}=(0,mt.Z)(!c,void 0,!0);function A(e){const a=Object.values(r).find((e=>{let{id:t}=e;return t===M[d].id})),s=a&&!C;return i.ZP.createElement(an.Z,{folderType:s?"folder":"all",folderId:s?a.id:void 0,isActive:e,isForumPanelOpen:u,lastSyncTime:m,foldersDispatch:t,onScreenSelect:n})}const x=M&&M.length>1;return i.ZP.createElement("div",{className:(0,et.Z)("ChatFolders",x&&g&&"ChatFolders--tabs-hidden")},x?i.ZP.createElement(nn.Z,{tabs:M,activeTab:d,onSwitchTab:R,areFolders:!0}):T?i.ZP.createElement("div",{className:(0,et.Z)("tabs-placeholder",N)}):void 0,i.ZP.createElement(St.Z,{ref:w,name:h?"none":b.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:d,renderCount:x?M.length:void 0},A))})));var on=n(34288);const rn=(0,i.X$)((e=>{const t=(0,ft.Z)(gt.gl.Extra,"LeftSearch");return t?i.ZP.createElement(t,e):i.ZP.createElement(on.Z,null)})),cn=(0,i.X$)((e=>{const t=(0,ft.Z)(gt.gl.Extra,"ContactList");return t?i.ZP.createElement(t,e):i.ZP.createElement(on.Z,null)}));var dn=n(52328);const ln=(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,Mt.Z)(),d=(0,et.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(Lt.Z,{icon:"channel",onClick:a},c("NewChannel")),i.ZP.createElement(Lt.Z,{icon:"group",onClick:s},c("NewGroup")),i.ZP.createElement(Lt.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(jt.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(dn.Z,{isOpen:o,positionX:c.isRtl?"left":"right",positionY:"bottom",autoClose:!0,onClose:u},m))}));var un=n(59690);const mn=Object.keys(f.du).length/2;let hn;const pn=(0,i.X$)((e=>{let{content:t,searchQuery:n,searchDate:a,isClosingSearch:o,contactsFilter:r,shouldSkipTransition:c,foldersDispatch:d,isUpdateAvailable:l,isForumPanelOpen:u,onSearchQuery:m,onContentChange:h,onScreenSelect:p,onReset:g,onTopicSearch:I}=e;const[v,w]=(0,i.eJ)(s.$b),{shouldRenderForumPanel:b,handleForumPanelAnimationEnd:y}=(0,Rt.Z)(u),P=u&&t===f.du.ChatList,{shouldRender:Z,transitionClassNames:C}=(0,mt.Z)(l),E=(0,i.sO)(!1),S=(0,i.I4)((()=>{t===f.du.ChatList&&(E.current=!0,w(!0))}),[t]),M=(0,i.I4)((()=>{E.current=!1,hn&&(clearTimeout(hn),hn=void 0),hn=window.setTimeout((()=>{E.current||w(!1)}),250)}),[]),R=(0,i.I4)((()=>{h(f.du.Settings)}),[h]),k=(0,i.I4)((()=>{h(f.du.Contacts)}),[h]),T=(0,i.I4)((()=>{h(f.du.Archived)}),[h]),N=(0,i.I4)((()=>{window.location.reload()}),[]),A=(0,i.I4)((()=>{h(f.du.NewChannelStep1)}),[h]),x=(0,i.I4)((()=>{h(f.du.NewGroupStep1)}),[h]);(0,i.d4)((()=>{let e;return t!==f.du.ChatList?e=window.setTimeout((()=>{w(!1)}),250):(E.current||s.$b)&&w(!0),()=>{e&&(clearTimeout(e),e=void 0)}}),[t]);const B=(0,Mt.Z)();return i.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:s.$b?void 0:S,onMouseLeave:s.$b?void 0:M},i.ZP.createElement(Qt,{shouldHideSearch:P,content:t,contactsFilter:r,onSearchQuery:m,onSelectSettings:R,onSelectContacts:k,onSelectArchived:T,onReset:g,shouldSkipTransition:c,isClosingSearch:o}),i.ZP.createElement(St.Z,{name:c?"none":"zoom-fade",renderCount:mn,activeKey:t,shouldCleanup:!0,cleanupExceptionKey:f.du.ChatList},(e=>{switch(t){case f.du.ChatList:return i.ZP.createElement(sn,{shouldHideFolderTabs:P,onScreenSelect:p,foldersDispatch:d});case f.du.GlobalSearch:return i.ZP.createElement(rn,{searchQuery:n,searchDate:a,isActive:e,onReset:g});case f.du.Contacts:return i.ZP.createElement(cn,{filter:r,isActive:e,onReset:g});default:return}})),Z&&i.ZP.createElement(jt.Z,{fluid:!0,pill:!0,className:(0,et.Z)("btn-update",C),onClick:N},B("lng_update_telegram")),b&&i.ZP.createElement(un.Z,{isOpen:u,isHidden:!P,onTopicSearch:I,onCloseAnimationEnd:y}),i.ZP.createElement(ln,{isShown:v,onNewPrivateChat:k,onNewChannel:A,onNewGroup:x}))})),gn=(0,i.X$)((e=>{const t=(0,ft.Z)(gt.gl.Extra,"Settings");return t?i.ZP.createElement(t,e):i.ZP.createElement(on.Z,null)})),fn=(0,i.X$)((e=>{const t=(0,ft.Z)(gt.gl.Extra,"NewChat");return t?i.ZP.createElement(t,e):i.ZP.createElement(on.Z,null)})),In=(0,i.X$)((e=>{const t=(0,ft.Z)(gt.gl.Extra,"ArchivedChats");return t?i.ZP.createElement(t,e):i.ZP.createElement(on.Z,null)}));var vn;!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"}(vn||(vn={}));const wn=Object.keys(vn).length/2,bn=(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}=e,m=(0,d.jr)(e);return{searchQuery:n,searchDate:a,isFirstChatFolderActive:0===o,shouldSkipHistoryAnimations:s,leftColumnWidth:r,currentUserId:c,hasPasscode:l,nextSettingsScreen:i,isChatOpen:Boolean(m?.id),isUpdateAvailable:u,isForumPanelOpen:(0,d.nd)(e),forumPanelChatId:t.forumPanelChatId,isClosingSearch:t.globalSearch.isClosing}}))((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}=e;const{setGlobalSearchQuery:v,setGlobalSearchClosing:w,setGlobalSearchChatId:b,resetChatCreation:y,setGlobalSearchDate:P,loadPasswordInfo:Z,clearTwoFaError:C,setLeftColumnWidth:E,resetLeftColumnWidth:S,openChat:M,requestNextSettingsScreen:R}=(0,a.Sv)(),k=(0,i.sO)(null),[T,N]=(0,i.eJ)(f.du.ChatList),[A,x]=(0,i.eJ)(f.MT.Main),[B,U]=(0,i.eJ)(""),[L,j]=(0,Zt.ZP)(),[O,F]=(0,i.eJ)(0);let _=vn.Main;switch(T){case f.du.Archived:_=vn.Archived;break;case f.du.Settings:_=vn.Settings;break;case f.du.NewChannelStep1:case f.du.NewChannelStep2:_=vn.NewChannel;break;case f.du.NewGroupStep1:case f.du.NewGroupStep2:_=vn.NewGroup}const D=(0,i.I4)((e=>{function t(){N(f.du.ChatList),U(""),w({isClosing:!0}),y(),setTimeout((()=>{v({query:""}),P({date:void 0}),b({id:void 0}),w({isClosing:!1}),F(Date.now())}),250)}if(!0!==e)if(T!==f.du.NewGroupStep2)if(T!==f.du.NewChannelStep2){if(T===f.du.NewGroupStep1){const e=document.getElementById("new-group-picker-search");e&&e.blur()}if(T===f.du.Settings)switch(A){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 x(f.MT.Main);case f.MT.GeneralChatBackground:return void x(f.MT.General);case f.MT.GeneralChatBackgroundColor:return void x(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 x(f.MT.Privacy);case f.MT.PasscodeNewPasscode:return void x(l?f.MT.PasscodeEnabled:f.MT.PasscodeDisabled);case f.MT.PasscodeChangePasscodeCurrent:case f.MT.PasscodeTurnOff:return void x(f.MT.PasscodeEnabled);case f.MT.PasscodeNewPasscodeConfirm:return void x(f.MT.PasscodeNewPasscode);case f.MT.PasscodeChangePasscodeNew:return void x(f.MT.PasscodeChangePasscodeCurrent);case f.MT.PasscodeChangePasscodeConfirm:return void x(f.MT.PasscodeChangePasscodeNew);case f.MT.PrivacyPhoneNumberAllowedContacts:case f.MT.PrivacyPhoneNumberDeniedContacts:return void x(f.MT.PrivacyPhoneNumber);case f.MT.PrivacyLastSeenAllowedContacts:case f.MT.PrivacyLastSeenDeniedContacts:return void x(f.MT.PrivacyLastSeen);case f.MT.PrivacyProfilePhotoAllowedContacts:case f.MT.PrivacyProfilePhotoDeniedContacts:return void x(f.MT.PrivacyProfilePhoto);case f.MT.PrivacyPhoneCallAllowedContacts:case f.MT.PrivacyPhoneCallDeniedContacts:return void x(f.MT.PrivacyPhoneCall);case f.MT.PrivacyPhoneP2PAllowedContacts:case f.MT.PrivacyPhoneP2PDeniedContacts:return void x(f.MT.PrivacyPhoneP2P);case f.MT.PrivacyForwardingAllowedContacts:case f.MT.PrivacyForwardingDeniedContacts:return void x(f.MT.PrivacyForwarding);case f.MT.PrivacyVoiceMessagesAllowedContacts:case f.MT.PrivacyVoiceMessagesDeniedContacts:return void x(f.MT.PrivacyVoiceMessages);case f.MT.PrivacyGroupChatsAllowedContacts:case f.MT.PrivacyGroupChatsDeniedContacts:return void x(f.MT.PrivacyGroupChats);case f.MT.TwoFaNewPassword:return void x(f.MT.TwoFaDisabled);case f.MT.TwoFaNewPasswordConfirm:return void x(f.MT.TwoFaNewPassword);case f.MT.TwoFaNewPasswordHint:return void x(f.MT.TwoFaNewPasswordConfirm);case f.MT.TwoFaNewPasswordEmail:return void x(f.MT.TwoFaNewPasswordHint);case f.MT.TwoFaNewPasswordEmailCode:return void x(f.MT.TwoFaNewPasswordEmail);case f.MT.TwoFaChangePasswordCurrent:case f.MT.TwoFaTurnOff:case f.MT.TwoFaRecoveryEmailCurrentPassword:return void x(f.MT.TwoFaEnabled);case f.MT.TwoFaChangePasswordNew:return void x(f.MT.TwoFaChangePasswordCurrent);case f.MT.TwoFaChangePasswordConfirm:return void x(f.MT.TwoFaChangePasswordNew);case f.MT.TwoFaChangePasswordHint:return void x(f.MT.TwoFaChangePasswordConfirm);case f.MT.TwoFaRecoveryEmail:return void x(f.MT.TwoFaRecoveryEmailCurrentPassword);case f.MT.TwoFaRecoveryEmailCode:return void x(f.MT.TwoFaRecoveryEmail);case f.MT.FoldersCreateFolder:case f.MT.FoldersEditFolder:return void x(f.MT.Folders);case f.MT.FoldersIncludedChatsFromChatList:case f.MT.FoldersExcludedChatsFromChatList:return void x(f.MT.FoldersEditFolderFromChatList);case f.MT.FoldersEditFolderFromChatList:return N(f.du.ChatList),void x(f.MT.Main);case f.MT.QuickReaction:case f.MT.CustomEmoji:return void x(f.MT.Stickers)}T===f.du.ChatList&&o?N(f.du.GlobalSearch):t()}else N(f.du.NewChannelStep1);else N(f.du.NewGroupStep1);else t()}),[T,o,w,y,v,P,b,A,l]),q=(0,i.I4)((e=>{T!==f.du.Contacts?(N(f.du.GlobalSearch),e!==t&&v({query:e})):U(e)}),[T,t,v]),$=(0,i.I4)((()=>{N(f.du.GlobalSearch),v({query:""}),b({id:g})}),[g,b,v]);(0,i.d4)((()=>T!==f.du.ChatList||o&&!m&&!p?(0,Pt.Z)((()=>D())):void 0),[o,T,D,m,p]);const G=(0,i.I4)((e=>{T!==f.du.GlobalSearch&&(e.preventDefault(),N(f.du.GlobalSearch))}),[T]),H=(0,i.I4)((e=>{e.preventDefault(),M({id:d,shouldReplaceHistory:!0})}),[d,M]),V=(0,i.I4)((e=>{e.preventDefault(),N(f.du.Settings)}),[]);(0,Et.y)({"Mod+Shift+F":G,"Mod+Shift+S":H,"Mod+0":H,...s.jm&&s.fl&&{"Mod+,":V}}),(0,i.d4)((()=>{C(),A===f.MT.Privacy&&Z()}),[C,Z,A]),(0,it.Z)((()=>{void 0!==u&&(N(f.du.Settings),x(u),R({screen:void 0}))}),[u,R]);const{initResize:z,resetResize:W,handleMouseUp:X}=function(e,t,n,a,s){const[o,r,c]=(0,Ct.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}}(k,(e=>E({leftColumnWidth:e})),S,c,"--left-column-width"),Y=(0,i.I4)((e=>{N(f.du.Settings),x(e)}),[]);return i.ZP.createElement("div",{id:"LeftColumn",ref:k},i.ZP.createElement(St.Z,{name:r?"none":s.s0,renderCount:wn,activeKey:_,shouldCleanup:!0,cleanupExceptionKey:vn.Main},(e=>{switch(_){case vn.Archived:return i.ZP.createElement(In,{isActive:e,onReset:D,onTopicSearch:$,isForumPanelOpen:p});case vn.Settings:return i.ZP.createElement(gn,{isActive:e,currentScreen:A,foldersState:L,foldersDispatch:j,onScreenSelect:Y,onReset:D,shouldSkipTransition:r});case vn.NewChannel:return i.ZP.createElement(fn,{key:O,isActive:e,isChannel:!0,content:T,onContentChange:N,onReset:D});case vn.NewGroup:return i.ZP.createElement(fn,{key:O,isActive:e,content:T,onContentChange:N,onReset:D});default:return i.ZP.createElement(pn,{content:T,isClosingSearch:I,searchQuery:t,searchDate:n,contactsFilter:B,foldersDispatch:j,onContentChange:N,onSearchQuery:q,onScreenSelect:Y,onReset:D,shouldSkipTransition:r,isUpdateAvailable:h,isForumPanelOpen:p,onTopicSearch:$})}})),i.ZP.createElement("div",{className:"resize-handle",onMouseDown:z,onMouseUp:X,onDoubleClick:W}))})));var yn=n(12420),Pn=n(49524),Zn=n(71394);var Cn=n(12255),En=n(52678),Sn=n(87204),Mn=n(3570),Rn=n(75790),kn=n(18360),Tn=n(6058),Nn=n(98799),An=n(59188),xn=n(32340),Bn=n(2903),Un=n(68512),Ln=n(17551);function jn(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 On=(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=jn(0,0,2,t,1)+jn(0,12,2,t+1,1)+jn(0,25,2,t,1);else for(let e=0;e<n;e++)a+=jn(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,et.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 Fn=n(45370),_n=n(62230);const Dn=(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,Mt.Z)(),g=(0,Bn.Z)(t),f=(0,zt.Z)((0,u.Ti)(t,"pictogram")),I=(0,u.NE)(t),[v,w,b]=(0,Ct.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,E,S]=(0,Ct.Z)();return i.ZP.createElement("div",{className:(0,et.Z)("HeaderPinnedMessage-wrapper",c)},n>1&&i.ZP.createElement(jt.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(jt.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(Ln.Z,{isOpen:v,onClose:b,text:"Would you like to unpin this message?",confirmLabel:"Unpin",confirmHandler:y}),i.ZP.createElement("div",{className:(0,et.Z)("HeaderPinnedMessage",C&&"no-hover"),onClick:l,dir:p.isRtl?"rtl":void 0},i.ZP.createElement(On,{count:n,index:o}),g&&function(e,t,n){const{width:a,height:s}=(0,Me.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(_n.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,xn.Z)(r):`${p("PinnedMessage")} ${o>0?"#"+(n-o):""}`),i.ZP.createElement("p",{dir:"auto"},i.ZP.createElement(Fn.Z,{lang:p,message:t,noEmoji:Boolean(g)})),i.ZP.createElement(Un.Z,null)),P&&i.ZP.createElement(jt.Z,{size:"tiny",className:"inline-button",onClick:Z,shouldStopPropagation:!0,onMouseEnter:s.$b?void 0:E,onMouseLeave:s.$b?void 0:S},P.text)))}));var qn=n(10396),$n=n(64532),Gn=n(23186),Hn=n(75851);const Vn=240;function zn(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=()=>{Wn(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 Wn(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";if(!("createImageBitmap"in window))return Xn(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,Hn.ix)(e.src),i=(0,Hn.rZ)(o)<Vn?"#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 Xn(e,t,n,void 0,a)}}async function Xn(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,Hn.ix)(e.src),l=(0,Hn.rZ)(d)<Vn?"#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 Yn=n(77510);const Jn=n.p+"telegram-logo-filled.67469f6dc5e301e8e0bd.svg",Kn={width:200,height:200},Qn=115;var ea=n(17240),ta=n(18051);const na={.5:.66,.75:.8,1:1,1.5:1.4,2:1.8},aa=Object.keys(na).sort().map(Number),sa=(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,Mt.Z)(),{isMobile:P}=(0,C.ZP)(),{audio:Z,voice:E,video:S}=(0,u.qp)(t),M=Boolean(E||S),R=M||(Z?.duration||0)>o.J0S,k=c?(0,u.OU)(y,c):void 0,T=Se.UV((0,u.Ti)(t,"inline")),N=((e,t,n)=>{const a=(0,Mt.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,zt.Z)(h),g=(0,i.Ye)((()=>function(e,t,n){if(!n)return Kn;if(e){if(!e.thumbnailSizes?.length)return;const t=e.thumbnailSizes.find((e=>"m"===e.type));return t||e.thumbnailSizes[0]}return t?Me.vY:void 0}(s,o,p)),[s,p,o]),{result:f}=(0,Yn.Z)((()=>function(e,t){if(!e)return Promise.resolve(Jn);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=()=>{Wn(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,Qn,Qn);const n=Math.min(t.width,t.height);return n<Qn?zn(e,Qn/n):Promise.resolve(e)}(p,g)),[p,g],Jn);return(0,i.Ye)((()=>(0,$n.Of)({title:r,artist:c,album:d,artwork:[{src:f}]})),[d,c,r,f])})(t,c,d),{playPause:A,stop:x,isPlaying:B,requestNextTrack:U,requestPreviousTrack:L,isFirst:j,isLast:O,setVolume:F,toggleMuted:_,setPlaybackRate:D}=(0,Gn.Z)((0,qn.An)(t),(0,u.XV)(t),M?"voice":"audio",T,void 0,N,void 0,!0,void 0,void 0,(0,u.CI)(t),!0),{isContextMenuOpen:q,handleBeforeContextMenu:$,handleContextMenu:G,handleContextMenuClose:H,handleContextMenuHide:V}=(0,ea.Z)(b),z=(0,i.I4)((()=>{v({chatId:t.chatId,messageId:t.id})}),[v,t.chatId,t.id]),W=(0,i.I4)((()=>{B&&A(),w(),(0,$n.Ay)(),x()}),[w,B,A,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=na[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(na).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(na).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(jt.Z,{round:!0,className:(0,et.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,et.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,et.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,xn.Z)(t||a)),n&&i.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,xn.Z)(n)))}(Z):function(e,t){return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,xn.Z)(t)),i.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(y("AttachAudio"),k),i.ZP.createElement(Un.Z,null)),i.ZP.createElement(jt.Z,{round:!0,ripple:!P,color:"translucent",size:"smaller",className:"player-button",disabled:j(),onClick:L,ariaLabel:"Previous track"},i.ZP.createElement("i",{className:"icon-skip-previous"})),i.ZP.createElement(jt.Z,{round:!0,ripple:!P,color:"translucent",size:"smaller",className:(0,et.Z)("toggle-play","player-button",B?"pause":"play"),onClick:A,ariaLabel:B?"Pause audio":"Play audio"},i.ZP.createElement("i",{className:"icon-play"}),i.ZP.createElement("i",{className:"icon-pause"})),i.ZP.createElement(jt.Z,{round:!0,ripple:!P,color:"translucent",size:"smaller",className:"player-button",disabled:O(),onClick:U,ariaLabel:"Next track"},i.ZP.createElement("i",{className:"icon-skip-next"})),i.ZP.createElement("div",{className:"volume-button-wrapper"},i.ZP.createElement(jt.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(ta.Z,{bold:!0,value:p?0:100*l,onChange:X})))),R&&i.ZP.createElement(Ut.Z,{forceOpen:q,positionX:"right",positionY:"top",className:"playback-rate-menu",trigger:Q,onClose:H,onHide:V,onMouseEnterBackdrop:H},aa.map((e=>function(e,t,n,a){const s=t===na[e]&&a||1===e&&!a;return i.ZP.createElement(Lt.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(jt.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:W,ariaLabel:"Close player"},i.ZP.createElement("i",{className:"icon-close"})))}));var oa=n(4794),ia=n(14605);const ra=(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,Mt.Z)(),[b,y,P]=(0,Ct.Z)(),[Z,C]=(0,i.eJ)(!0),[E,S]=(0,i.eJ)(!0),{accessHash:M}=s||{},{isAutoArchived:R,canReportSpam:k,canAddContact:T,canBlockContact:N}=r||{},A=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}),E&&h({chatId:t})}),[M,l,P,h,m,k,E,Z,t]),U=(0,i.I4)((()=>{v({chatId:t})}),[t,v]),L=(0,i.I4)((()=>{P(),m({chatId:t}),A?(g({chatId:t,userId:c}),f({chatId:t,shouldDeleteForAll:!1})):p({chatId:t})}),[t,P,c,g,f,A,p,m]);if(r)return i.ZP.createElement("div",{className:(0,et.Z)("ChatReportPanel",n),dir:w.isRtl?"rtl":void 0},T&&i.ZP.createElement(jt.Z,{isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:x},w("lng_new_contact_add")),N&&i.ZP.createElement(jt.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:y},w("lng_new_contact_block")),k&&!N&&i.ZP.createElement(jt.Z,{color:"danger",isText:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:y},w("lng_report_spam_and_leave")),i.ZP.createElement(jt.Z,{round:!0,ripple:!0,size:"tiny",color:"translucent",onClick:U,ariaLabel:w("Close")},i.ZP.createElement("i",{className:"icon-close"})),i.ZP.createElement(Ln.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:L},o&&i.ZP.createElement(ia.Z,{label:w("DeleteThisChat"),checked:E,onCheck:S}),o&&k&&i.ZP.createElement(ia.Z,{label:w("ReportChat"),checked:Z,onCheck:C})))}))),ca=(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),E=(0,d.WP)(e,n,a,"typingStatus"),S=(0,d.jU)(e).focusedMessage,M={typingStatus:E,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:!S||S.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;return{...M,pinnedMessageIds:t,canUnpin:!1,topMessageSender:o}}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,isChatWithSelf:P,lastSyncTime:Z,hasButtonInHeader:E,shouldSkipHistoryAnimations:S,currentTransitionKey:M,connectionState:R,hasReachedFocusedMessage:k,isSyncing:T}=e;const{openChatWithInfo:N,pinMessage:A,focusMessage:x,openChat:B,openPreviousChat:U,setReachedFocusedMessage:L,loadPinnedMessages:j,toggleLeftColumn:O,exitMessageSelectMode:F}=(0,a.Sv)(),_=(0,Mt.Z)(),D=(0,i.sO)(!0),[q,$]=(0,i.eJ)(!1),{isTablet:G}=(0,C.ZP)(),[H,V]=(0,i.eJ)(0),z=Array.isArray(l)?l[H]:l,W=m&&z?m[z]:void 0,X=Array.isArray(l)?l.length:l?1:void 0,Y=b&&(0,u.U)(_,b).length,J=p?(0,u.OU)(_,p):void 0,{settings:K}=b||{},Q=b?.isForum;(0,i.d4)((()=>{Z&&c&&(n===r._f||Q)&&j({chatId:t,threadId:n})}),[t,j,Z,n,c,Q]),(0,i.d4)((()=>{V(0),$(!1)}),[l]),(0,i.d4)((()=>{if(k&&q){L({hasReached:!1}),$(!1);const e=(0,Mn.Z)(X||1,H+1);V(e)}}),[k,q,H,X,L]),(0,Rn.Z)(t,z,W);const{width:ee}=(0,Cn.Z)(),te=ee<=o.ksF,ne=G&&I,ae=(0,i.sO)(null),se=(0,i.sO)(!0),oe=(0,i.I4)((()=>{N({id:t,threadId:n})}),[N,t,n]),ie=(0,i.I4)((e=>{A({messageId:e,isUnpin:!0})}),[A]),re=(0,i.I4)((()=>{W&&(x({chatId:W.chatId,threadId:n,messageId:W.id,noForumTopicPanel:!0}),$(!0))}),[W,x,n]),ce=(0,i.I4)((()=>{B({id:t,threadId:n,type:"pinned"})}),[B,t,n]),de=(0,i.I4)((()=>{setTimeout((()=>{D.current=!0}),450)}),[]),le=(0,i.I4)((e=>{if(D.current){if(D.current=!1,d&&document.querySelector(o.Edp)?.blur(),f)return F(),void de();if("thread"===s&&0===M)return d||ne?(e.stopPropagation(),B({id:void 0},{forceOnHeavyAnimation:!0})):O(),void de();U(),de()}}),[s,M,f,U,ne,B,O,F,de,d]),ue=ee>=o.ksF&&ee<o.jT7||ee>o.l35&&ee<o.ksF&&(!Y||Y>30),me=ue||ee>o._mX&&ee<o.QU1,he=Boolean(K?.canAddContact||K?.canBlockContact||K?.canReportSpam),{shouldRender:pe,transitionClassNames:ge}=(0,mt.Z)(he),fe=(0,kn.Z)(he?K:void 0,!0),{shouldRender:Ie,transitionClassNames:ve}=(0,mt.Z)(Boolean(w)),we=(0,kn.Z)(w,!0),{shouldRender:be,transitionClassNames:ye}=(0,mt.Z)(Boolean(W)),Pe=(0,kn.Z)(W,!0),Ze=(0,kn.Z)(X,!0),Ce=(0,kn.Z)(h,!0),Ee=(0,kn.Z)(J),Se=(0,Sn.Z)(M),Me=void 0!==Se&&Se<M?Se:void 0,Re=be&&Pe||Ie&&we;(0,i.d4)((()=>{const e=ae.current;if(e)return me&&Re?void(v||ue?(se.current&&(e.classList.add("tools-stacked","animated"),se.current=!1),setTimeout((()=>{e.classList.remove("animated")}),350)):(e.classList.remove("tools-stacked"),se.current=!0)):(e.classList.remove("tools-stacked","animated"),void(se.current=!0))}),[me,Re,ue,v]);const{connectionStatusText:ke}=At(_,R,T,!0);function Te(){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(jt.Z,{round:!0,size:"smaller",color:"translucent",onClick:le,ariaLabel:_(e?"Close":"Back")},i.ZP.createElement("div",{className:(0,et.Z)("animated-close-icon",!e&&"state-back")})),t&&i.ZP.createElement(yt,null))}const Ne=Boolean(Ie&&we),Ae=Ne||!d&&E&&ee<o.sgm;return i.ZP.createElement("div",{className:"MiddleHeader",ref:ae},i.ZP.createElement(St.Z,{name:S?"none":"slide-fade",activeKey:M,shouldCleanup:!0,cleanupExceptionKey:Me},"thread"!==s||n!==r._f&&!b?.isForum?i.ZP.createElement(i.ZP.Fragment,null,Te(),i.ZP.createElement("h3",null,void 0!==y?"thread"===s?_("CommentsCount",y,"i"):"pinned"===s?_("PinnedMessagesCount",y,"i"):"scheduled"===s?P?_("Reminders"):_("messages",y,"i"):void 0:_("Loading"))):i.ZP.createElement(i.ZP.Fragment,null,(te||M>0)&&Te(ne,!0),i.ZP.createElement("div",{className:"chat-info-wrapper",onClick:oe},(0,u.YC)(t)?i.ZP.createElement(Tn.Z,{key:t,userId:t,typingStatus:g,status:ke,withDots:Boolean(ke),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:ke,withDots:Boolean(ke),withMediaViewer:n===r._f,withFullInfo:n===r._f,withUpdatingStatus:!0,withVideoAvatar:c,noRtl:!0})))),i.ZP.createElement(oa.Z,{hasPinnedOffset:be&&Boolean(Pe)||Ie&&Boolean(we),chatId:t}),be&&Pe&&i.ZP.createElement(Dn,{key:t,message:Pe,count:Ze||0,index:H,customTitle:Ee,className:(0,et.Z)(ye,Ae&&"full-width"),onUnpinMessage:Ce?ie:void 0,onClick:re,onAllPinnedClick:ce}),pe&&i.ZP.createElement(ra,{key:t,chatId:t,settings:fe,className:ge}),i.ZP.createElement("div",{className:"header-tools"},Ne&&i.ZP.createElement(sa,{key:(0,u.Tp)(we),message:we,className:ve}),i.ZP.createElement(An.Z,{chatId:t,threadId:n,messageListType:s,isMobile:d,canExpandActions:!Ne})))})));function da(e){return"albumId"in e}function la(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 ua=n(30386),ma=n(87675),ha=n(60539),pa=n(88957);var ga=n(60998);const fa=(e,t,n)=>{const a=(0,Sn.Z)(t);return(0,i.bt)((()=>e(a||[])),t,n)};var Ia=n(78722),va=n(3657);const wa=s.wZ?1e3:350;function ba(e,t){return e?t?238:175:t?238:100}function ya(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,Me.Eh)(o,s,t,r,n,a):(0,Me.GC)(i,s,t,c,n,a),m=ba(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 Pa=n(28712);function Za(e,t){return e.reduce(((e,t)=>e+t),t)}function Ca(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=ya(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,Me.kc)(e,t,!1,n,s)-(t?2.5:0)*Me.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,Pa.uZ)(e,1,2.75):(0,Pa.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=Za(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=Za(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:Ca(u)}}let Sa,Ma;function Ra(e){return Ma||(Ma=getComputedStyle(document.documentElement).getPropertyValue("--font-family")),Sa||(Sa=document.createElement("span"),Sa.style.font=`400 12px ${Ma}`,Sa.style.whiteSpace="nowrap",Sa.style.position="absolute",Sa.style.left="-999px",Sa.style.opacity=".01",document.body.appendChild(Sa)),Sa.textContent=e,Sa.offsetWidth}var ka=n(55254),Ta=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,ha.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 Aa=n(3858);const xa=3*Me.Gw,Ba=Number(Me.Gw),Ua="data-is-document-group-hover";function La(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,Ct.Z)(),[P,Z,C]=(0,Ct.Z)(),E=(0,i.sO)();return(0,i.d4)((()=>{if(!s.$b||r||!c||h)return;let e;return(0,en.sf)(t.current,{selectorToPreventScroll:".MessageList",excludedClosestSelector:".no-word-wrap",onSwipe:(t,n)=>n===en.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,ua.q)(e),u(e)},handleClick:function(t){if(r)e(t);else if(s.$b)return E.current?(clearInterval(E.current),E.current=void 0,void v({chatId:m,messageId:n})):void(E.current=setTimeout((()=>{E.current=void 0,function(e){if(s.wZ){const t=e.target;if(!t.classList.contains("text-content")&&!t.classList.contains("Message"))return;xe.Z.getIsKeyboardVisible()?setTimeout((()=>{l(e)}),350):l(e)}}(t)}),200))},handleContextMenu:r?d?Aa.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)<xa,d=Math.abs(i+r-a)<Ba;c&&d?b():y()},handleSendQuickReaction:function(){v({chatId:m,messageId:n})},handleMouseLeave:function(e){y(),f&&function(e){const t=Oa(e.currentTarget);t&&t.removeAttribute(Ua)}(e)},isSwiped:P,isQuickReactionVisible:w,handleDocumentGroupMouseEnter:ja}}function ja(e){const t=Oa(e.currentTarget);t&&t.setAttribute(Ua,"")}function Oa(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}var Fa=n(3927),_a=n(70172),Da=n(18005);const qa=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"ContextMenuContainer",!t);return n?i.ZP.createElement(n,e):void 0}));var $a=n(45601),Ga=n(66735);const Ha=(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,Mt.Z)(),[m,h]=(0,i.eJ)(),[p,g,I]=(0,Ct.Z)(!1),v=(0,zt.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 Se.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(_a.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(Ga.Z,{file:m,onClose:P,onChange:y}),i.ZP.createElement(Ln.Z,{isOpen:p,title:l("SuggestedVideo"),confirmHandler:Z,onClose:I,textParts:n}))})),Va=(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:E}=(0,a.Sv)(),S=(0,Mt.Z)(),M=(0,i.sO)(null);(0,va._N)(M,y),(0,Rn.Z)(t.chatId,t.replyToMessageId,m),Na(M,t.chatId,p,g,f);const R=s<=0,[k,T]=(0,Ct.Z)(R),N=Boolean(t.content.action?.text.startsWith("ActionGift")),A="suggestProfilePhoto"===t.content.action?.type&&t.content.action.photo;(0,i.d4)((()=>{R||setTimeout(T,10*s)}),[s,T,R]);const x=(0,va.Op)(M,Z),B=(0,i.sO)((()=>{const e=b?.current&&t.id>=b.current;return N&&!t.isOutgoing&&e})());(0,i.d4)((()=>{x&&B.current&&(B.current=!1,E())}),[x,E]);const{transitionClassNames:U}=(0,mt.Z)(k,void 0,R,!1),L=(0,i.Ye)((()=>l?l.map((e=>r?.[e])).filter(Boolean):void 0),[l,r]),j=(0,Da.D)(S,t,c,d,L,m,h,w,{isEmbedded:n},P,Z),{isContextMenuOpen:O,contextMenuPosition:F,handleBeforeContextMenu:_,handleContextMenu:D,handleContextMenuClose:q,handleContextMenuHide:$}=(0,ea.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,et.Z)("ActionMessage message-list-item",p&&!f&&"focused",(N||A)&&"centered-action",G&&"has-menu-open",o&&"last-in-list",U);return i.ZP.createElement("div",{ref:M,id:(0,u.d0)(t.id),className:H,"data-message-id":t.id,onMouseDown:e=>{(0,ua.q)(e),_(e)},onContextMenu:D},!A&&i.ZP.createElement("span",{className:"action-message-content"},j),N&&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($a.Z,{key:t.id,sticker:I,play:!0,noLoop:!0,nonInteractive:!0}),i.ZP.createElement("strong",null,S("ActionGiftPremiumTitle")),i.ZP.createElement("span",null,S("ActionGiftPremiumSubtitle",S("Months",t.content.action?.months,"i"))),i.ZP.createElement("span",{className:"action-message-button"},S("ActionGiftPremiumView"))),A&&i.ZP.createElement(Ha,{message:t,content:j}),F&&i.ZP.createElement(qa,{isOpen:O,anchor:F,message:t,messageListType:"thread",onClose:q,onCloseAnimationEnd:$}))}))),za=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,va.Op)(p,l),f=(0,zt.Z)(n&&(0,u.Ti)(n,"pictogram"),!g),I=(0,Bn.Z)(n),v=Boolean(n&&(0,u.Y5)(n)),w=Boolean(n&&(0,u.NE)(n)),b=(0,Mt.Z)(),y=a?(0,u.OU)(b,a):n?.forwardInfo?.hiddenUserName;return i.ZP.createElement("div",{ref:p,className:(0,et.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,Me.W7)(),c=t||e;return i.ZP.createElement("div",{className:(0,et.Z)("embedded-thumb",n&&"round")},!s&&i.ZP.createElement("img",{src:c,width:o,height:r,alt:"",className:"pictogram",draggable:!1}),i.ZP.createElement(_n.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(Va,{message:n,isEmbedded:!0,observeIntersectionForLoading:l,observeIntersectionForPlaying:m}):i.ZP.createElement(Fn.Z,{lang:b,message:n,noEmoji:Boolean(I),observeIntersectionForLoading:l,observeIntersectionForPlaying:m}):o||" "),i.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,xn.Z)(y||s||" "))),d&&i.ZP.createElement("i",{className:"embedded-more icon-more"}))};var Wa=n(82535),Xa=n(54752),Ya=n(8018);const Ja=(0,i.X$)((e=>{let{message:t,outgoingStatus:n,signature:s,withReactionOffset:o,onClick:r}=e;const{showNotification:c}=(0,a.Sv)(),d=(0,Mt.Z)(),[l,u]=(0,Ct.Z)(),m=e=>{e.stopPropagation(),c({message:d("ImportedInfo")})},h=(0,i.Ye)((()=>{if(!l)return;const e=(0,ae.SA)(1e3*t.date,d.code),n=t.isEdited&&(0,ae.SA)(1e3*t.editDate,d.code),a=t.forwardInfo&&(0,ae.SA)(1e3*t.forwardInfo.date,d.code);let s=e;return n&&(s+="\n",s+=d("lng_edited_date").replace("{date}",n)),a&&(s+="\n",s+=d("lng_forwarded_date").replace("{date}",a)),s}),[l,d,t]),p=(0,et.Z)("MessageMeta",o&&"reactions-offset",t.forwardInfo?.isImported&&"is-imported");return i.ZP.createElement("span",{className:p,dir:d.isRtl?"rtl":"ltr",onClick:r,"data-ignore-on-paste":!0},Boolean(t.views)&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("span",{className:"message-views"},(0,vt.bi)(t.views)),i.ZP.createElement("i",{className:"icon-channelviews"})),s&&i.ZP.createElement("span",{className:"message-signature"},(0,xn.Z)(s)),i.ZP.createElement("span",{className:"message-time",title:h,onMouseEnter:u},t.forwardInfo?.isImported&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("span",{className:"message-imported",onClick:m},(0,ae.SA)(1e3*t.forwardInfo.date,d.code,!0)),i.ZP.createElement("span",{className:"message-imported",onClick:m},d("ImportedMessage"))),t.isEdited&&`${d("EditedMessage")} `,(0,ae.mr)(d,1e3*t.date)),n&&i.ZP.createElement(Ya.Z,{status:n}))}));var Ka=n(36765),Qa=n(97799);const es=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,Mt.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"),E=(0,va.Op)(v,n),S=(0,va.Op)(v,o),M=`sticker${w.id}?size=f`,R=(0,zt.Z)(M,!E||!P,r.IU.BlobUrl,d),[k,T,N]=(0,Ct.Z)(),A=(0,i.I4)((()=>{N(),h?.()}),[h,N]);(0,i.d4)((()=>{P&&S&&l&&(T(),m?.())}),[P,S,m,l,T]);const x=(0,i.I4)((()=>{g({stickerSetInfo:w.stickerSetInfo})}),[g,w]),B=(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?.());x()}),[P,k,f,m,x,p,T,w.stickerSetInfo]),U="isMissing"in b,{width:L,height:j}=(0,Me.Wr)(w,I),O=(0,et.Z)("Sticker media-inner",U&&"inactive",P&&!t.isOutgoing&&"reversed");return i.ZP.createElement("div",{ref:v,className:O,style:`width: ${L}px; height: ${j}px;`,onClick:U?void 0:B},i.ZP.createElement(Ka.Z,{containerRef:v,sticker:w,fullMediaHash:Z,fullMediaClassName:"full-media",size:L,shouldLoop:c,noLoad:!E,noPlay:!S,withSharedAnimation:!0,cacheBuster:d}),P&&E&&k&&i.ZP.createElement(Qa.Z,{key:M,className:"effect-sticker",tgsUrl:R,size:1.49*L,play:!0,isLowPriority:!0,noLoop:!0,onEnded:A}))};var ts=n(74753),ns=n(80036);const as=7*Me.Gw;function ss(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,zt.Z)(n?`document${n}`:void 0,!n),g=c||as,f=(0,ns.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,ts.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 os=(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}=ss(r,o,u,c,t,l?.emoji),f=(0,va.Op)(m,n);return i.ZP.createElement($a.Z,{sticker:d,size:h,quality:1,noLoad:!f,forcePreview:s,lastSyncTime:a,play:f,forceOnHeavyAnimation:!0,ref:m,className:(0,et.Z)("AnimatedEmoji media-inner",d?.id===Me.wB&&"like-sticker-thumb"),style:p,onClick:g})}))),is=(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}=ss(s,a,d,o,t,c?.emoji,(0,Ta.qo)(1));return i.ZP.createElement(Ht.Z,{ref:u,documentId:n,className:(0,et.Z)("AnimatedEmoji media-inner",r?.id===Me.wB&&"like-sticker-thumb"),style:h,size:m,isBig:!0,withSharedAnimation:!0,forceOnHeavyAnimation:!0,observeIntersectionForLoading:l,onClick:p})}))),rs={dark:{outgoing:"rgb(135,116,225)",incoming:"rgb(33,33,33)"},light:{outgoing:"rgb(238,255,222)",incoming:"rgb(255,255,255)"}};function cs(e,t,n,a,s){return a?Promise.resolve(rs[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 ds=n(92566),ls=n(15866);function us(e,t){const{isMobile:n}=(0,C.ZP)();return(0,ls.Z)((0,u.DH)(e),Boolean(t),n&&!s.vX)}var ms=n(70692),hs=n(39196);const ps=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),E=Z.blobUrl,S=(0,va.Op)(P,a),{isMobile:M}=(0,C.ZP)(),[R,k]=(0,i.eJ)(r),T=R&&S,{mediaData:N,loadProgress:A}=(0,ds.Z)((0,u.Ti)(n,m),!T),x=E||N,[B]=(0,i.eJ)(!x),U=Boolean(x),L=us(n,U),j=(0,ms.Z)(!U),O=(0,u.DH)(n),[F,,_]=(0,Ct.Z)(Z.isSpoiler),{loadProgress:D}=(0,ds.Z)((0,u.Ti)(n,"download"),!I,(0,u.kG)(n,"download")),{isUploading:q,isTransferring:$,transferProgress:G}=(0,u.Sc)(n,l||(I?D:A),T&&!x),H=!1===(0,Sn.Z)(R),{shouldRender:V,transitionClassNames:z}=(0,mt.Z)($,void 0,H,"slow"),{shouldRender:W,transitionClassNames:X}=(0,mt.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);fa((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?cs(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||ya(n,p,s,M),te=(0,et.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:L,className:(0,et.Z)("thumbnail",j)}),v&&i.ZP.createElement("span",{className:"protector"}),V&&!W&&i.ZP.createElement("div",{className:`media-loading ${z}`},i.ZP.createElement(hs.Z,{progress:G,onClick:q?Y:void 0})),W&&i.ZP.createElement("i",{className:(0,et.Z)("icon-download",X)}),i.ZP.createElement(_n.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 gs=n(35148);const fs=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,,E]=(0,Ct.Z)(y.isSpoiler),S=(0,va.Op)(w,s),M=(0,va.Op)(w,o)&&S,R=(0,i.sO)(S);M&&!R.current&&(R.current=!0);const{isMobile:k}=(0,C.ZP)(),[T,N]=(0,i.eJ)(c),A=Boolean(T&&S&&m),[x,B]=(0,i.eJ)(d&&!Z),U=(0,u.Ti)(n,"inline"),[L]=(0,i.eJ)(Boolean(U&&Se.UV(U))),{mediaData:j,loadProgress:O}=(0,ds.Z)(U,!A,(0,u.kG)(n,"inline"),m),F=P||j,[_,D]=(0,Ct.Z)(),q=(0,u.DH)(n),$=Boolean(q),G=(0,u.Ti)(n,"preview"),[H]=(0,i.eJ)(Boolean(G&&Se.UV(G))),V=S&&m,z=(0,zt.Z)(G,!V,void 0,m),W=(0,ms.Z)(($||z)&&!_),X=!$||z||_,Y=us(n,X),J=(0,ms.Z)(!X),K=F&&R.current,{loadProgress:Q}=(0,ds.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),A&&!_&&!L||g),se=!1===(0,Sn.Z)(T),{shouldRender:oe,transitionClassNames:ie}=(0,mt.Z)(te,void 0,se),{transitionClassNames:re}=(0,mt.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,Me.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?E():I?.(n.id)):N((e=>!e))}),[ee,g,F,x,Z,I,n,v,E]),Ie=(0,et.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(gs.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,et.Z)("thumbnail",W),alt:"",draggable:!f}),$&&!H&&i.ZP.createElement("canvas",{ref:Y,className:(0,et.Z)("thumbnail",J)}),f&&i.ZP.createElement("span",{className:"protector"}),i.ZP.createElement("i",{className:(0,et.Z)("icon-large-play",re)}),i.ZP.createElement(_n.Z,{isVisible:Z,withAnimation:!0,thumbDataUri:q,width:pe,height:ge,className:"media-spoiler"}),oe&&i.ZP.createElement("div",{className:(0,et.Z)("media-loading",ie)},i.ZP.createElement(hs.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 Is=n(6272);const vs=(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,et.Z)("Contact",m&&"interactive"),onClick:m?h:void 0},i.ZP.createElement(_a.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,Is.WZ)(s,l))))}));var ws=n(20230),bs=n(51218),ys=n(14434),Ps=n(96937);function Zs(e,t){return t>0?(e/t*100).toFixed():0}const Cs=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?Zs(c.votersCount,a||0):0,[m,h]=(0,i.eJ)(r?0:u),p=(0,i.sO)(null),g=c?Zs(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,et.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,xn.Z)(t.text)),i.ZP.createElement("div",{className:(0,et.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 Es(e){e.stopPropagation()}const Ss=(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,E]=(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),S=(0,i.sO)(null),{results:M,totalVoters:R}=p,k=M&&M.some((e=>e.isChosen)),T=!h.closed&&!k,N=!T&&h.isPublic&&Number(p.totalVoters)>0,A=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)),[]):[],U=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((()=>E(C-1)),1e3);const e=S.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 L=(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,Mt.Z)();return i.ZP.createElement("div",{className:"Poll",dir:$.isRtl?"auto":"ltr"},b&&n.results.solution&&i.ZP.createElement(Ps.Z,{message:(0,ws.H)(n.results.solution,n.results.solutionEntities),duration:5e3,onDismiss:q,containerId:"#middle-column-portals"}),i.ZP.createElement("div",{className:"poll-question"},(0,xn.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)),L.length>0&&i.ZP.createElement("div",{className:"poll-recent-voters"},L.map((e=>i.ZP.createElement(_a.Z,{size:"micro",user:e})))),C>0&&T&&i.ZP.createElement("div",{ref:S,className:"poll-countdown"}),h.quiz&&n.results.solution&&!T&&i.ZP.createElement(jt.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:Es},A?i.ZP.createElement(bs.Z,{options:U,onChange:O,disabled:t.isScheduled||g,loadingOptions:g?I:void 0,round:!0}):i.ZP.createElement(ys.Z,{name:`poll-${u}`,options:U,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(Cs,{key:e.option,shouldAnimate:P||!T,answer:e,voteResults:M,totalVoters:R,maxVotersCount:x,correctResults:B})}))),!N&&!A&&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)),A&&i.ZP.createElement(jt.Z,{isText:!0,disabled:0===I.length,size:"tiny",onClick:F},$("PollSubmitVotes")),N&&i.ZP.createElement(jt.Z,{isText:!0,size:"tiny",onClick:_},$("PollViewResults")))})));var Ms=n(48035),Rs=n(10088);const ks=(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:E,video:S}=f,M=(0,Ms.Z)(Z,170),R=Boolean(M||P||w);let k=!1;if(R&&f?.photo&&!f.video){const{width:e,height:n}=ya(t,void 0,void 0,I);k=e===n}const T=(E||S)&&p&&!k,N=(0,et.Z)("WebPage",r&&"in-preview",k&&"with-square-photo",!E&&!S&&!r&&"without-media",S&&"with-video",!R&&"no-article");return i.ZP.createElement("div",{className:N,"data-initial":(w||y)[0],dir:"auto"},E&&!S&&i.ZP.createElement(ps,{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(Rs.Z,{className:"site-name",url:b,text:w||y}),!r&&P&&i.ZP.createElement("p",{className:"site-title"},(0,xn.Z)(P)),M&&i.ZP.createElement("p",{className:"site-description"},(0,xn.Z)(M,["emoji","br"]))),!r&&S&&i.ZP.createElement(fs,{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 Ts=n(17921);const Ns=(0,i.X$)((e=>{let{message:t,shouldAffectAppendix:n,isInSelectMode:a,isSelected:s,theme:r}=e;const c=(0,i.sO)(null),d=(0,Mt.Z)(),l=(0,u.eO)(t),{title:m,text:h,amount:p,currency:g,isTest:f,photo:I}=l,v=(0,zt.Z)((0,u.O9)(I));return fa((e=>{let[t]=e;if(n){if(v){const e=c.current.closest(o.be_);cs(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,xn.Z)(m)),h&&i.ZP.createElement("div",null,(0,xn.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(Ts.Z,{width:I.dimensions?.width,height:I.dimensions?.height,forceAspectRatio:!0}),i.ZP.createElement("p",{className:"description-text"},(0,Qe.x)(p,g,d.code),f&&i.ZP.createElement("span",null,d("PaymentTestInvoice")))))})),As={root:"rwnm0xOh31c2MY4kK2No",duration:"lKSp02aI8WDGX3393nkh",buy:"gxQfWp0jp0_2Z4qWiXKN",spoiler:"z2tB5Vd_jKJ9IYX4Nijd"},xs=(0,i.X$)((e=>{let{message:t,lastSyncTime:n}=e;const{openInvoice:s,loadExtendedMedia:o}=(0,a.Sv)(),r=(0,Mt.Z)(),c=(0,u.eO)(t),{chatId:d,id:l}=t,m=(0,i.I4)((()=>{o({chatId:d,ids:[l]})}),[d,l,o]);(0,pt.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,et.Z)(As.root,"media-inner"),onClick:b},i.ZP.createElement(_n.Z,{thumbDataUri:v?.dataUri,width:f,height:I,isVisible:!0,className:As.spoiler}),Boolean(w)&&i.ZP.createElement("div",{className:As.duration},(0,ae.k9)(w)),i.ZP.createElement("div",{className:As.buy},i.ZP.createElement("i",{className:(0,et.Z)("icon-lock",As.lock)}),r("Checkout.PayPrice",(0,Qe.x)(h,p))))})),Bs=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"})),Us=["#e56cd5","#f89440","#9986ff","#44b3f5","#6dc139","#ff5d5a","#f87aad","#6e82b3","#f5ba21"],Ls=n.p+"map-pin.7b3c3e60ee24795e4bd2.svg",js=1e-4,Os={width:400,height:300,zoom:16,scale:2},Fs={__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>'},_s=(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,Mt.Z)(),g=(0,ut.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),E="venue"===I||"geoLive"===I&&!y,{width:S,height:M,zoom:R,scale:k}=Os,T=Boolean(s)&&(0,u.k6)(Z,S,M,R,k),N=(0,zt.Z)(T),A=(0,Sn.Z)(N),x=N||A,B=n&&(0,u.YC)(n.id),U=n&&B?n:void 0,L=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]),fa((e=>{let[t]=e;if(E)t||m.current.closest(o.be_).removeAttribute(o.s22);else if(x){const e=m.current.closest(o.be_);cs(x,j,0,c,d).then((t=>{e.style.setProperty("--appendix-bg",t),e.classList.add("has-appendix-thumb"),e.setAttribute(o.s22,"")}))}}),[E,j,r,c,d,x]),(0,i.d4)((()=>{Math.abs(w.lat-Z.lat)<js&&Math.abs(w.long-Z.long)<js?Z.accuracyRadius!==w.accuracyRadius&&C({...Z,accuracyRadius:w.accuracyRadius}):C(w)}),[w,Z]),(0,Gt.Z)((()=>{g()}),y?void 0:1e3*(P||0)),(0,pt.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: ${Os.width}px; height: ${Os.height}px;`}):i.ZP.createElement(Ts.Z,{width:S,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,et.Z)("pin",I,y&&"expired");if("geoLive"===I)return i.ZP.createElement("div",{className:e,dangerouslySetInnerHTML:Fs},i.ZP.createElement(_a.Z,{chat:L,user:U,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?Bs.get(e)||Bs.get(e.split("/")[0])||Us[(t=e,t.split("").reduce(((e,t)=>(e<<5)-e+t.charCodeAt(0)|0),0)%Us.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:Fs,style:`--pin-color: ${t}`},i.ZP.createElement("img",{src:n,className:"venue-icon",alt:""}))}return i.ZP.createElement("img",{className:e,src:Ls,alt:""})}())}()),function(){if(E)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}())})),Ds=(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,zt.Z)(l,!n),p=(0,zt.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(Ts.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 qs(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,et.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 $s=qs(ps),Gs=qs(fs),Hs=(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($s,{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(Gs,{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 Vs;const zs=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,va.Op)(d,n),[g,f]=(0,i.eJ)(s),I=Boolean(g&&p&&o),{mediaData:v,loadProgress:w}=(0,ds.Z)((0,u.Ti)(t,"inline"),!I,(0,u.kG)(t,"inline"),o),{loadProgress:b}=(0,ds.Z)((0,u.Ti)(t,"download"),!c,r.IU.BlobUrl,o),[y,P]=(0,Ct.Z)(),Z=!Boolean((0,u.DH)(t))||y,C=us(t,Z),E=(0,ms.Z)(!Z),S=g&&!y||c,M=!1===(0,Sn.Z)(g),{shouldRender:R,transitionClassNames:k}=(0,mt.Z)(S,void 0,M),[T,N]=(0,i.eJ)(!1),[A,x]=(0,i.eJ)(0);(0,i.d4)((()=>{if(!T)return;const e=Me.Rj/2,t=2*(e-6)*Math.PI,n=t-A*t,a=m.current,s=l.current,o=s.firstElementChild;o?o.firstElementChild.setAttribute("stroke-dashoffset",n.toString()):s.innerHTML=`\n <svg width="${Me.Rj}px" height="${Me.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>`,x(a.currentTime/a.duration)}),[T,A]);const B=Boolean(v&&p),U=(0,i.I4)((()=>{m.current&&(N(!1),x(0),(0,ts.Z)(m.current),(0,F.T2)((()=>{l.current.innerHTML=""})))}),[]),L=(0,i.I4)((()=>{Vs?.(),Vs=U}),[U]),j=(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,ts.Z)(e),(0,qn.Es)()):e.pause():(L(),e.pause(),e.currentTime=0,(0,ts.Z)(e),(0,qn.Es)(),N(!0))}),[L,T,c,v,t]),O=(0,i.I4)((e=>{const t=e.currentTarget;x(t.currentTime/t.duration)}),[]);return i.ZP.createElement("div",{ref:d,className:"RoundVideo media-inner",onClick:j},v&&i.ZP.createElement("div",{className:"video-wrapper"},i.ZP.createElement(gs.Z,{canPlay:B,ref:m,src:v,className:"full-media",width:Me.Rj,height:Me.Rj,autoPlay:!0,disablePictureInPicture:!0,muted:!T,loop:!T,playsInline:!0,onEnded:T?U:void 0,onTimeUpdate:T?O:void 0,onReady:P})),i.ZP.createElement("canvas",{ref:C,className:(0,et.Z)("thumbnail",E),style:`width: ${Me.Rj}px; height: ${Me.Rj}px`}),i.ZP.createElement("div",{className:"progress",ref:l}),R&&i.ZP.createElement("div",{className:`media-loading ${k}`},i.ZP.createElement(hs.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"})))},Ws=e=>{let{message:t,onClick:n}=e;const a=(0,Mt.Z)();return i.ZP.createElement("div",{className:"InlineButtons"},t.inlineButtons.map((e=>i.ZP.createElement("div",{className:"row"},e.map((e=>i.ZP.createElement(jt.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,xn.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))))))))};var Xs=n(34076);const Ys=(0,i.X$)((e=>{let{threadInfo:t,disabled:n}=e;const{openChat:s}=(0,a.Sv)(),o=(0,Mt.Z)(),{threadId:r,chatId:c,messagesCount:d,lastMessageId:l,lastReadInboxMessageId:m,recentReplierIds:h}=t,p=(0,i.I4)((()=>{s({id:c,threadId:r})}),[s,c,r]),g=(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 f=Boolean(m&&l&&m<l),I=d?o("Comments","%COMMENTS_COUNT%",void 0,d).split("%").map((e=>"COMMENTS_COUNT"===e?i.ZP.createElement(Xs.Z,{text:(0,vt.bi)(d)}):e)):void 0;return i.ZP.createElement("div",{"data-cnt":(0,vt.bi)(d),className:(0,et.Z)("CommentButton",f&&"has-unread",n&&"disabled"),dir:o.isRtl?"rtl":"ltr",onClick:p},i.ZP.createElement("i",{className:"icon-comments-sticker"}),(!g||0===g.length)&&i.ZP.createElement("i",{className:"icon-comments"}),g&&g.length>0&&i.ZP.createElement("div",{className:"recent-repliers",dir:o.isRtl?"rtl":"ltr"},g.map((e=>i.ZP.createElement(_a.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?I:o("LeaveAComment")),i.ZP.createElement("i",{className:"icon-next"}))}));var Js=n(78046),Ks=n(48198);const Qs={root:"JY0NZH9bysPBqR3sIbLu","is-custom-emoji":"T1R9OVCwcfQHR4vN8cx_",isCustomEmoji:"T1R9OVCwcfQHR4vN8cx_","animated-icon":"WTrBqa2uxq57nYJAIelk",animatedIcon:"WTrBqa2uxq57nYJAIelk",effect:"z9v8vlAIGxI3ITxuyEG1",animating:"sB0FGOzwkiDvNWHWcVEL"},eo=2.5*Me.Gw,to=6.5*Me.Gw,no=(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,Js.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,va.Op)(d,r),v=h&&`sticker${h}`,w=f&&`sticker${f}`,b=(0,zt.Z)(v,!h),y=(0,zt.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:E}=(0,mt.Z)(Z,void 0,!0,"slow"),S=(0,i.I4)((()=>{P?.messageId&&c({messageId:P.messageId,reaction:t})}),[P?.messageId,t,c]),[M,R,k]=(0,Ct.Z)(),T=!(l||Z&&M),N=(0,et.Z)(Qs.root,C&&Qs.animating,l&&Qs.isCustomEmoji);return i.ZP.createElement("div",{className:N,ref:d},T&&i.ZP.createElement(Ks.Z,{reaction:t,availableReactions:o}),l&&i.ZP.createElement(Ht.Z,{documentId:t.documentId,className:Qs.customEmoji,observeIntersectionForPlaying:r}),C&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(Qa.Z,{key:f,className:(0,et.Z)(Qs.effect,E),size:to,tgsUrl:y,play:I,noLoop:!0,forceOnHeavyAnimation:!0,onEnded:S}),l?!g&&I&&i.ZP.createElement(Xt,{reaction:t}):i.ZP.createElement(Qa.Z,{key:h,className:(0,et.Z)(Qs.animatedIcon,E),size:eo,tgsUrl:b,play:I,noLoop:!0,forceOnHeavyAnimation:!0,onLoad:R,onEnded:k})))})),ao=(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(jt.Z,{className:(0,et.Z)((0,u.Bt)(t)&&"chosen"),size:"tiny",onClick:p},i.ZP.createElement(no,{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(_a.Z,{user:e,size:"micro"})))):i.ZP.createElement(Xs.Z,{text:(0,vt.bi)(t.count)}))})),so=(0,i.X$)((e=>{let{message:t,isOutside:n,activeReactions:a,availableReactions:s,metaChildren:o,genericEffects:r,observeIntersection:c,noRecentReactors:d}=e;const l=(0,i.Ye)((()=>t.reactions.results.reduce(((e,t)=>e+t.count),0)),[t]);return i.ZP.createElement("div",{className:(0,et.Z)("Reactions",n&&"is-outside")},t.reactions.results.map((e=>i.ZP.createElement(ao,{key:(0,u.$d)(e.reaction),reaction:e,message:t,activeReactions:a,availableReactions:s,withRecentReactors:l<=3&&!d,genericEffects:r,observeIntersection:c}))),o)})),oo=(0,i.X$)((e=>{let{phoneCall:t,message:n,chatId:o}=e;const{requestMasterAndRequestCall:r}=(0,a.Sv)(),c=(0,Mt.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(jt.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,et.Z)("icon-arrow-right","wrUkWet7enyh9L1iPKvA",m&&"V5tKkKZpcY5yq_f5nO8l",!d&&"e0Vhbj8gfzQn1zJQoFLK")}),i.ZP.createElement("span",{className:"TJ2lYkLxYUie3A0JqtMR"},f?c("CallMessageWithDuration",[I,f]):I))))}));var io=n(78780),ro=n(50685),co=n(14612),lo=n(98138),uo=n(2995);var mo=n(69123);const ho=1.125*Me.Gw,po=(0,i.X$)((e=>{let{topic:t,className:n,onClick:a}=e;const s=(0,Mt.Z)();return i.ZP.createElement("div",{className:(0,et.Z)("wUl1jHjVuMxmGhsdl358",n),style:`--topic-button-accent-color: var(${(0,lo.gZ)(t?.iconColor)})`,onClick:a},t?i.ZP.createElement(uo.Z,{topic:t,size:ho}):i.ZP.createElement("img",{src:mo,alt:""}),t?.title?(0,xn.Z)(t.title):s("Loading"),t?.isClosed&&i.ZP.createElement("i",{className:"icon-lock"}),i.ZP.createElement("i",{className:"icon-next"}))})),go={__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>'},fo={__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>'},Io=1.75*Me.Gw,vo=(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:E,forwardInfo:S,transcriptionId:M}=l,R=(0,d.Z1)(e,b),k=(0,d.FM)(e,b),T=(0,u.pK)(b),N=R&&(0,u.eA)(R),A=R&&(0,u.Bf)(R),x=R?.usernames,B=a.messageIds&&a.messageIds.includes(w),U=!k&&(0,u.Ul)(l),L=h||p||U,j=(0,d.Ur)(e,l),O=(0,d.cv)(e,l),F=y?(0,d.dy)(e,y):void 0,_=j?.id&&A?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(S)),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=E?(0,d.tZ)(e,E.chatId,E.threadId)||E: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));return{theme:(0,d.Pu)(e),chatUsernames:x,forceSenderName:U,canShowSender:L,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:N,isGroup:A,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,...(L||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,appearanceOrder:w,isFirstInGroup:b,isPremium:y,isLastInGroup:P,isFirstInDocumentGroup:Z,isLastInDocumentGroup:E,isTranscribing:S,transcribedText:M,isLastInList:R,theme:k,forceSenderName:T,sender:N,canShowSender:A,originSender:x,botSender:B,isThreadTop:U,shouldHideReply:L,replyMessage:j,replyMessageSender:O,outgoingStatus:F,uploadProgress:_,isInDocumentGroup:D,isProtected:q,isChatProtected:$,isFocused:G,focusDirection:H,noFocusHighlight:V,isResizingContainer:z,isForwarding:W,isChatWithSelf:X,isRepliesChat:Y,isChannel:J,isGroup:K,canReply:Q,lastSyncTime:ee,highlight:te,animatedEmoji:ne,animatedCustomEmoji:ae,genericEffects:se,isInSelectMode:oe,isSelected:ie,isGroupSelected:re,threadId:ce,reactionMessage:de,availableReactions:le,defaultReaction:ue,activeReactions:me,activeEmojiInteractions:he,messageListType:pe,isPinnedList:ge,isDownloading:fe,canAutoLoadMedia:Ie,canAutoPlayMedia:ve,shouldLoopStickers:we,autoLoadFileMaxSizeMb:be,repliesThreadInfo:ye,hasUnreadReaction:Pe,memoFirstUnreadIdRef:Ze,animationLevel:Ce,senderAdminMember:Ee,messageTopic:Se,hasTopicChip:Re}=e;const{toggleMessageSelection:ke,clickBotInlineButton:Te,disableContextMenuHint:Ne,animateUnreadReaction:Ae,focusLastMessage:xe}=(0,a.Sv)(),Be=(0,i.sO)(null),Ue=(0,i.sO)(null),Le=(0,i.sO)(null),je=(0,i.sO)(0),Oe=(0,Mt.Z)(),[Fe,_e]=(0,i.eJ)(!1),[De,qe,$e]=(0,Ct.Z)(),{isMobile:Ge}=(0,C.ZP)();(0,va._N)(Ue,c);const{isContextMenuOpen:He,contextMenuPosition:Ve,handleBeforeContextMenu:ze,handleContextMenu:We,handleContextMenuClose:Xe,handleContextMenuHide:Ye}=(0,ea.Z)(Be,s.$b&&oe,!0,s.wZ);(0,i.d4)((()=>{He&&Ne()}),[He,Ne]);const Je=w<=0,[Ke,Qe]=(0,Ct.Z)(Je);(0,i.d4)((()=>{Je||setTimeout(Qe,10*w)}),[w,Qe,Je]);const{transitionClassNames:tt}=(0,mt.Z)(Ke,void 0,Je,!1),{id:nt,chatId:at,forwardInfo:st,viaBotId:ot,isTranscriptionError:it}=t,rt=(0,u.CI)(t),ct=(0,u.B4)(t),dt="scheduled"===pe||t.isScheduled,lt=(0,u.ss)(t)&&!L,ut=Boolean(ye)&&"thread"===pe,ht=(0,u.$D)(t),pt=ht&&(ne||ae),gt=de?.reactions&&!(0,u.JE)(de.reactions),ft=st&&(!X||dt)&&!Y&&!st.isLinkedChannelPost&&!ht,It=Boolean(m)&&m.messages.length>1&&!m?.messages.some((e=>0===Object.keys(e.content).length)),vt=D&&!Z,wt=D&&!E,bt=void 0!==Ve,yt=!(bt||oe||W||wt),Pt=J&&!dt&&t.isForwardingAllowed&&!$,Zt=Boolean(ge||st&&(st.isChannelPost||X&&!ct||Y)&&st.fromMessageId),Et=Re||lt,St=(0,i.I4)(((e,t)=>{ke({messageId:nt,groupedId:t,...e?.shiftKey&&{withShift:!0},...It&&{childMessageIds:m.messages.map((e=>{let{id:t}=e;return t}))}})}),[ke,nt,It,m]),Rt=A?N:void 0,kt=Boolean(!Fe&&(it||M)),Tt=st&&(X||Y||!Rt)?x:Rt,Nt=st?x:Rt,{handleMouseDown:At,handleClick:xt,handleContextMenu:Bt,handleDoubleClick:Ut,handleContentDoubleClick:Lt,handleMouseMove:Ot,handleSendQuickReaction:Ft,handleMouseLeave:_t,isSwiped:Dt,isQuickReactionVisible:qt,handleDocumentGroupMouseEnter:$t}=La(St,Be,nt,0,Boolean(oe),Boolean(Q),Boolean(q),We,ze,at,bt,Le,ct,wt),{handleAvatarClick:Gt,handleSenderClick:zt,handleViaBotClick:Wt,handleReplyClick:Xt,handleMediaClick:Yt,handleAudioPlay:Jt,handleAlbumMediaClick:Kt,handleMetaClick:Qt,handleReadMedia:en,handleCancelUpload:tn,handleVoteSend:nn,handleGroupForward:an,handleForward:sn,handleFocus:on,handleFocusForwarded:rn,handleDocumentGroupSelectAll:cn,handleTopicChipClick:dn}=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:E,openForwardMenu:S,focusMessageInComments:M}=(0,a.Sv)(),{id:R,forwardInfo:k,replyToMessageId:T,replyToChatId:N,replyToTopMessageId:A,groupedId:x}=n,B=(0,i.I4)((()=>{h&&v({id:h.id})}),[h,v]),U=(0,i.I4)((()=>{p?d&&k?.channelPostId?b({chatId:p.id,messageId:k.channelPostId}):v({id:p.id}):w({message:e("HidAccount")})}),[d,b,k,e,v,p,w]),L=(0,i.I4)((()=>{g&&v({id:g.id})}),[g,v]),j=(0,i.I4)((()=>{b({chatId:u&&N?N:s,threadId:o,messageId:T,replyMessageId:u&&N?void 0:R,noForumTopicPanel:!0})}),[b,u,N,s,o,T,R]),O=(0,i.I4)((()=>{y({chatId:s,threadId:o,mediaId:R,origin:l?f.bZ.ScheduledInline:f.bZ.Inline})}),[s,o,R,y,l]),F=(0,i.I4)((()=>{P({chatId:s,messageId:R})}),[s,R,P]),_=(0,i.I4)((e=>{y({chatId:s,threadId:o,mediaId:e,origin:l?f.bZ.ScheduledAlbum:f.bZ.Album})}),[s,o,y,l]),D=(0,i.I4)((()=>{Z({messageIds:[R]})}),[R,Z]),q=(0,i.I4)((()=>{C({chatId:s,messageId:R})}),[C,s,R]),$=(0,i.I4)((e=>{E({chatId:s,messageId:R,options:e})}),[s,R,E]),G=(0,i.I4)((()=>{S({fromChatId:s,groupedId:x})}),[S,s,x]),H=(0,i.I4)((()=>{if(m&&m.messages){const e=m.messages.map((e=>{let{id:t}=e;return t}));S({fromChatId:s,messageIds:e})}else S({fromChatId:s,messageIds:[R]})}),[m,S,s,R]),V=(0,i.I4)((()=>{b({chatId:s,threadId:r._f,messageId:R})}),[b,s,R]),z=(0,i.I4)((()=>{c?b({chatId:k.fromChatId,groupedId:x,groupedChatId:s,messageId:k.fromMessageId}):u&&N?M({chatId:N,threadId:A,messageId:k.fromMessageId}):b({chatId:k.fromChatId,messageId:k.fromMessageId})}),[c,u,N,b,k,x,s,M,A]),W=(0,i.I4)((e=>{e.stopPropagation(),t(e,x)}),[t,x]);return{handleAvatarClick:B,handleSenderClick:U,handleViaBotClick:L,handleReplyClick:j,handleMediaClick:O,handleAudioPlay:F,handleAlbumMediaClick:_,handleMetaClick:W,handleReadMedia:D,handleCancelUpload:q,handleVoteSend:$,handleGroupForward:G,handleForward:H,handleFocus:V,handleFocusForwarded:z,handleDocumentGroupSelectAll:W,handleTopicChipClick:(0,i.I4)((()=>{I&&b({chatId:u&&N?N:s,threadId:I.id,messageId:R})}),[s,b,u,I,R,N])}}(Oe,St,t,at,ce,D,ft,dt,Y,m,Tt,Nt,B,Se);(0,i.d4)((()=>{R&&kt&&M&&xe()}),[xe,R,M,kt]);const ln=(0,et.Z)("Message message-list-item",b&&"first-in-group",q&&"is-protected",P&&"last-in-group",Z&&"first-in-document-group",E&&"last-in-document-group",R&&"last-in-list",ct&&"own",Boolean(t.views)&&"has-views",t.isEdited&&"was-edited",lt&&"has-reply",bt&&"has-menu-open",G&&!V&&"focused",W&&"is-forwarding",t.isDeleting&&"is-deleting",D&&"is-in-document-group",It&&"is-album",t.hasUnreadMention&&"has-unread-mention",ie&&"is-selected",oe&&"is-in-selection-mode",U&&"is-thread-top",Boolean(t.inlineButtons)&&"has-inline-buttons",Dt&&"is-swiped",tt,(Boolean(me)||De)&&"has-active-reaction"),{text:un,photo:mn,video:hn,audio:pn,voice:gn,document:fn,sticker:In,contact:vn,poll:wn,webPage:bn,invoice:yn,location:Pn,action:Zn,game:Cn}=(0,u.qp)(t),{phoneCall:En}=Zn||{},Sn=ye&&!wt&&"thread"===pe&&!I,Mn=!s.$b&&!En&&!oe&&ue&&!wt,kn=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),E=[o.gnl],S=g||f||Z||C?.extendedMedia,M=p||"venue"===Z?.type||m,R=S&&!M,k=Boolean(e.viaBotId);return!S&&e.emojiOnlyCount?(E.push("emoji-only"),e.emojiOnlyCount<=o.L5X&&E.push(`emoji-only-${e.emojiOnlyCount}`)):M&&E.push("text"),d&&E.push("has-action-button"),n&&(E.push("custom-shape"),f?.isRound&&E.push("round"),c&&E.push("has-comments")),S?E.push("media"):I?E.push("audio"):v?(E.push("voice"),h&&E.push("with-voice-transcription")):w?E.push("document"):P?E.push("contact"):b?E.push("poll"):y&&(E.push("web-page"),(y.photo||y.video)&&E.push("media")),C&&!C.extendedMedia&&E.push("invoice"),s&&E.push("is-forwarded"),t&&E.push("has-subheader"),i&&E.push("has-replies"),l&&E.push("has-reactions"),k&&E.push("is-via-bot"),r&&E.push("force-sender-name"),n||(E.push("has-shadow"),S&&c&&E.push("has-background"),(t||s||k||!R||r)&&E.push("has-solid-background"),a&&(g||Z&&!M||!R)&&E.push("has-appendix")),E.join(" ")}(t,{hasSubheader:Et,isCustomShape:ht,isLastInGroup:P,asForwarded:ft,hasThread:ut,forceSenderName:T,hasComments:ye&&ye.messagesCount>0,hasActionButton:Pt||Zt,hasReactions:gt,isGeoLiveActive:"geoLive"===Pn?.type&&!(0,u.$R)(t,(0,v.bp)()),withVoiceTranscription:kt}),Tn=kn.includes("has-appendix"),Nn=(0,u.fY)(t),An=(0,Ta.qo)(t.emojiOnlyCount);let Bn,Un;Bn=En||wt?"none":!Nn||bn||pt?"standalone":"in-text",gt?ht||(mn||hn)&&!Nn?Un="outside":ft?(Bn="standalone",Un="inside"):Un="inside":Un="none",(0,Rn.Z)(Y&&t.replyToChatId?t.replyToChatId:at,lt?t.replyToMessageId:void 0,j,t.id),Na(Be,at,G,H,V,z);const Ln=P,jn=(0,i.I4)((e=>{const t=je.current,n=e.target.clientHeight;if(je.current=n,(0,ha.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&&xe()}),[xe]),On=(0,Fa.Z)(jn,[jn],300,!1);(0,Ia.Z)(Ln?Be:void 0,On),(0,i.d4)((()=>{const e=Ue.current;Pe&&e&&(0,ka.P)(e)&&Ae({messageIds:[nt]})}),[Pe,nt,Ae]);let Fn,_n="",Dn=!1;const qn=(0,i.Ye)((()=>It?Ea(ct,Boolean(ft),Boolean(h),m,Ge):void 0),[It,ct,ft,h,m,Ge]),$n=ft?28:0;if(!It&&(mn||hn||yn?.extendedMedia)){let e;if(mn)e=ya(t,ft,h,Ge).width;else if(hn)e=hn.isRound?Me.Rj:ya(t,ft,h,Ge).width;else if(yn?.extendedMedia&&yn.extendedMedia.width&&yn.extendedMedia.height){const{width:t,height:n}=yn.extendedMedia;e=(0,Me.Kf)({width:t,height:n,fromOwnMessage:ct,asForwarded:ft,noAvatars:h,isMobile:Ge}).width}e&&(Fn=Math.max(ba(Boolean(un),Sn),e),yn?.extendedMedia&&Fn-e>18&&(Dn=!0))}else qn&&(Fn=Math.max(ba(Boolean(un),Sn),qn.containerStyle.width),Fn-qn.containerStyle.width>18&&(Dn=!0));Fn&&(_n=`width: ${Fn+$n}px`);const Gn=J&&t.postAuthorTitle||!ft&&st?.postAuthorTitle||void 0,Hn=(0,i.Ye)((()=>Gn?Ra(Gn):void 0),[Gn]);function Vn(){const e=i.ZP.createElement(Ja,{message:t,outgoingStatus:F,signature:Gn,withReactionOffset:"inside"===Un,availableReactions:le,onClick:Qt});return"inside"!==Un?e:i.ZP.createElement(so,{activeReactions:me,message:de,metaChildren:e,availableReactions:le,genericEffects:se,observeIntersection:l,noRecentReactors:J})}const zn=K&&ft?t.postAuthorTitle:void 0,Wn=(0,i.Ye)((()=>n?.find((e=>e.isActive))),[n]);return i.ZP.createElement("div",{ref:Be,id:(0,u.d0)(t.id),className:ln,style:Hn?`--meta-safe-author-width: ${Hn}px`:void 0,"data-message-id":nt,onMouseDown:At,onClick:xt,onContextMenu:Bt,onDoubleClick:Ut,onMouseEnter:wt?$t:void 0,onMouseMove:Mn?Ot:void 0,onMouseLeave:Mn||wt?_t:void 0},i.ZP.createElement("div",{ref:Ue,className:"bottom-marker","data-message-id":nt,"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":Pe||void 0}),!D&&i.ZP.createElement("div",{className:"message-select-control"},ie&&i.ZP.createElement("i",{className:"icon-select"})),E&&i.ZP.createElement("div",{className:(0,et.Z)("message-select-control group-select",re&&"is-selected"),onClick:cn},re&&i.ZP.createElement("i",{className:"icon-select"})),p&&function(){const e=Tt&&(0,u.YC)(Tt.id),t=Tt&&e?Tt:void 0,n=Tt&&!e?Tt:void 0,a=!Tt&&st?st.hiddenUserName:void 0;return i.ZP.createElement(_a.Z,{size:"small",user:t,chat:n,text:a,lastSyncTime:ee,onClick:t||n?Gt:void 0,observeIntersection:d,animationLevel:Ce,withVideo:!0})}(),i.ZP.createElement("div",{className:(0,et.Z)("message-content-wrapper",kn.includes("text")&&"can-select-text")},i.ZP.createElement("div",{ref:Le,className:kn,style:_n,dir:"auto"},ft&&!vt&&i.ZP.createElement("div",{className:"message-title"},Oe("ForwardedMessage"),zn&&i.ZP.createElement("span",{className:"admin-title",dir:"auto"},zn)),function(){const e=(0,et.Z)("content-inner",ft&&"forwarded-message",Et&&"with-subheader",Dn&&"no-media-corners"),n=P&&!Nn&&!ft&&!ut,a=(0,et.Z)("text-content","in-text"===Bn&&"with-meta",F&&"with-outgoing-icon");return i.ZP.createElement("div",{className:e,onDoubleClick:Lt,dir:"auto"},function(){if(ht&&!ot||!(g&&(!(mn||hn||Pn)||Re)||ft||ot||T)||vt||lt&&ht)return;let e,n;!Nt||ht&&ot?st?.hiddenUserName&&(e=st.hiddenUserName):(e=(0,u.OU)(Oe,Nt),ft||(n=`color-${(0,u.Rs)(Nt)}`));const a=Nt&&"emojiStatus"in Nt&&Nt.emojiStatus,s=Nt&&"isPremium"in Nt&&Nt.isPremium;return i.ZP.createElement("div",{className:"message-title",dir:"ltr"},e?i.ZP.createElement("span",{className:(0,et.Z)("message-title-name interactive",n),onClick:zt,dir:"ltr"},(0,xn.Z)(e),!ft&&a&&i.ZP.createElement(Ht.Z,{documentId:a.documentId,loopLimit:o.y3O,observeIntersectionForLoading:d,observeIntersectionForPlaying:l}),!ft&&!a&&s&&i.ZP.createElement(Vt.Z,null),Nt?.fakeType&&i.ZP.createElement(ro.Z,{fakeType:Nt.fakeType})):B?void 0:" ",B&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("span",{className:"via"},Oe("ViaBot")),i.ZP.createElement("span",{className:"interactive",onClick:Wt},(0,xn.Z)(`@${B.usernames[0].username}`))),st?.isLinkedChannelPost?i.ZP.createElement("span",{className:"admin-title",dir:"auto"},Oe("DiscussChannel")):t.forwardInfo?.postAuthorTitle&&K&&ft?i.ZP.createElement("span",{className:"admin-title",dir:"auto"},t.forwardInfo?.postAuthorTitle):t.postAuthorTitle&&K&&!ft?i.ZP.createElement("span",{className:"admin-title",dir:"auto"},t.postAuthorTitle):Ee&&!ft?i.ZP.createElement("span",{className:"admin-title",dir:"auto"},Ee.customTitle||Oe(Ee.isOwner?"GroupInfo.LabelOwner":"GroupInfo.LabelAdmin")):void 0)}(),Et&&i.ZP.createElement("div",{className:"message-subheader"},Re&&i.ZP.createElement(po,{topic:Se,onClick:dn,className:"message-topic"}),lt&&i.ZP.createElement(za,{message:j,noUserColors:ct||J,isProtected:q,sender:O,observeIntersectionForLoading:d,observeIntersectionForPlaying:l,onClick:Xt})),In&&i.ZP.createElement(es,{message:t,observeIntersection:d,observeIntersectionForPlaying:l,shouldLoop:we,lastSyncTime:ee,shouldPlayEffect:In.hasEffect&&(Ze.current&&nt>=Ze.current||rt)||void 0,onPlayEffect:qe,onStopEffect:$e}),pt&&ae&&i.ZP.createElement(is,{customEmojiId:ae,withEffects:(0,u.YC)(at),isOwn:ct,observeIntersection:d,lastSyncTime:ee,forceLoadPreview:rt,messageId:nt,chatId:at,activeEmojiInteractions:he}),pt&&ne&&i.ZP.createElement(os,{emoji:ne,withEffects:(0,u.YC)(at),isOwn:ct,observeIntersection:d,lastSyncTime:ee,forceLoadPreview:rt,messageId:nt,chatId:at,activeEmojiInteractions:he}),It&&i.ZP.createElement(Hs,{album:m,albumLayout:qn,observeIntersection:d,isOwn:ct,isProtected:q,hasCustomAppendix:n,lastSyncTime:ee,onMediaClick:Kt}),En&&i.ZP.createElement(oo,{message:t,phoneCall:En,chatId:at}),!It&&mn&&i.ZP.createElement(ps,{message:t,observeIntersection:d,noAvatars:h,canAutoLoad:Ie,uploadProgress:_,shouldAffectAppendix:n,isDownloading:fe,isProtected:q,asForwarded:ft,theme:k,onClick:Yt,onCancelUpload:tn}),!It&&hn&&hn.isRound&&i.ZP.createElement(zs,{message:t,observeIntersection:d,canAutoLoad:Ie,lastSyncTime:ee,isDownloading:fe}),!It&&hn&&!hn.isRound&&i.ZP.createElement(fs,{message:t,observeIntersectionForLoading:d,observeIntersectionForPlaying:l,noAvatars:h,canAutoLoad:Ie,canAutoPlay:ve,uploadProgress:_,lastSyncTime:ee,isDownloading:fe,isProtected:q,asForwarded:ft,onClick:Yt,onCancelUpload:tn}),(pn||gn)&&i.ZP.createElement(Xa.ZP,{theme:k,message:t,origin:f.Cr.Inline,uploadProgress:_,lastSyncTime:ee,isSelectable:D,isSelected:ie,noAvatars:h,onPlay:Jt,onReadMedia:!gn||ct&&!X?void 0:en,onCancelUpload:tn,isDownloading:fe,isTranscribing:S,isTranscriptionHidden:Fe,isTranscribed:Boolean(M),isTranscriptionError:it,canDownload:!q,onHideTranscription:_e,canTranscribe:y}),fn&&i.ZP.createElement(Wa.Z,{message:t,observeIntersection:d,canAutoLoad:Ie,autoLoadFileMaxSizeMb:be,uploadProgress:_,isSelectable:D,isSelected:ie,onMediaClick:Yt,onCancelUpload:tn,isDownloading:fe}),vn&&i.ZP.createElement(vs,{contact:vn}),wn&&i.ZP.createElement(Ss,{message:t,poll:wn,onSendVote:nn}),Cn&&i.ZP.createElement(Ds,{message:t,canAutoLoadMedia:Ie,lastSyncTime:ee}),yn?.extendedMedia&&i.ZP.createElement(xs,{message:t,lastSyncTime:ee}),kt&&i.ZP.createElement("p",{className:(0,et.Z)("transcription",!Fe&&it&&"transcription-error"),dir:"auto"},it?Oe("NoWordsRecognized"):S&&M?i.ZP.createElement(io.Z,{content:M}):M),!pt&&Nn&&i.ZP.createElement("div",{className:a,dir:"auto"},i.ZP.createElement(co.Z,{message:t,emojiSize:An,highlight:te,isProtected:q,observeIntersectionForLoading:d,observeIntersectionForPlaying:l,withTranslucentThumbs:ht}),"in-text"===Bn&&Vn()),bn&&i.ZP.createElement(ks,{message:t,observeIntersection:d,noAvatars:h,canAutoLoad:Ie,canAutoPlay:ve,asForwarded:ft,lastSyncTime:ee,isDownloading:fe,isProtected:q,theme:k,onMediaClick:Yt,onCancelMediaTransfer:tn}),yn&&!yn.extendedMedia&&i.ZP.createElement(Ns,{message:t,shouldAffectAppendix:n,isInSelectMode:oe,isSelected:ie,theme:k}),Pn&&i.ZP.createElement(_s,{message:t,lastSyncTime:ee,isInSelectMode:oe,isSelected:ie,theme:k,peer:N}))}(),!wt&&"standalone"===Bn&&Vn(),yt&&Pt?i.ZP.createElement(jt.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:Oe("lng_context_forward_msg"),onClick:E?an:sn},i.ZP.createElement("i",{className:"icon-share-filled"})):yt&&Zt?i.ZP.createElement(jt.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:ge?on:rn},i.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,Sn&&i.ZP.createElement(Ys,{threadInfo:ye,disabled:I}),Tn&&i.ZP.createElement("div",{className:"svg-appendix",dangerouslySetInnerHTML:ct?go:fo}),Mn&&i.ZP.createElement("div",{className:(0,et.Z)("quick-reaction",qt&&!me&&"visible"),onClick:Ft},i.ZP.createElement(Ks.Z,{reaction:ue,size:Io,availableReactions:le,observeIntersection:l}))),t.inlineButtons&&i.ZP.createElement(Ws,{message:t,onClick:Te}),"outside"===Un&&i.ZP.createElement(so,{message:de,isOutside:!0,activeReactions:me,availableReactions:le,genericEffects:se,observeIntersection:l,noRecentReactors:J})),Ve&&i.ZP.createElement(qa,{isOpen:He,anchor:Ve,message:t,album:m,chatUsername:Wn?.username,messageListType:pe,onClose:Xe,onCloseAnimationEnd:Ye}))}))),wo=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"AboutAdsModal",!t);return n?i.ZP.createElement(n,e):void 0})),bo=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"SponsoredMessageContextMenuContainer",!t);return n?i.ZP.createElement(n,e):void 0})),yo=(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,Mt.Z)(),f=(0,i.sO)(null),I=(0,i.sO)(null),v=Boolean(n),{observe:w}=(0,va.S1)({rootRef:o,debounceMs:200,threshold:1}),{isContextMenuOpen:b,contextMenuPosition:y,handleBeforeContextMenu:P,handleContextMenu:Z,handleContextMenuClose:C,handleContextMenuHide:E}=(0,ea.Z)(f,s.$b,!0,s.wZ),[S,M,R]=(0,Ct.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,ua.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,xn.Z)((0,u.Js)(r)||""),c&&(0,xn.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,ws.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(jt.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(bo,{isOpen:b,anchor:y,message:n,onAboutAds:M,onClose:C,onCloseAnimationEnd:E}),i.ZP.createElement(wo,{isOpen:S,onClose:R}))}))),Po=(0,i.X$)((e=>{let{isCurrentUserPremium:t,chatId:n,threadId:c,messageIds:d,messageGroups:l,isViewportNewest:m,isUnread:h,withUsers:p,noAvatars:g,containerRef:v,anchorIdRef:w,memoUnreadDividerBeforeIdRef:b,memoFirstUnreadIdRef:y,type:P,isReady:Z,isScrollingRef:E,isScrollPatchNeededRef:S,threadTopMessageId:M,hasLinkedChat:R,isSchedule:k,noAppearanceAnimation:T,onFabToggle:N,onNotchToggle:A}=e;const{openHistoryCalendar:x}=(0,a.Sv)(),{observeIntersectionForReading:B,observeIntersectionForLoading:U,observeIntersectionForPlaying:L}=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,va.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,st.Z)(l,u);const{observe:m}=(0,va.S1)({rootRef:t,throttleMs:wa,margin:c}),{observe:h}=(0,va.S1)({rootRef:t,throttleMs:wa});return{observeIntersectionForReading:d,observeIntersectionForLoading:m,observeIntersectionForPlaying:h}}(P,v,y),{backwardsTriggerRef:j,forwardsTriggerRef:O,fabTriggerRef:_}=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,F.Ds)((()=>p({direction:f.Uq.Backwards})),1e3,!0,!1),(0,F.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,va.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,va._N)(v,P),(0,va._N)(w,P);const{observe:Z,freeze:C,unfreeze:E}=(0,va.S1)({rootRef:t,margin:100},y);(0,va._N)(b,Z);const{observe:S,freeze:M,unfreeze:R}=(0,va.S1)({rootRef:t,margin:1},y);(0,va._N)(b,S);const k=(0,i.sO)();return k.current=y,(0,it.Z)((()=>{u&&k.current()}),[u]),(0,it.Z)((()=>{C(),M(),setTimeout((()=>{R(),E()}),250)}),[C,M,n,E,R]),{backwardsTriggerRef:v,forwardsTriggerRef:w,fabTriggerRef:b}}(P,v,d,m,h,N,A,Z,E,S),D=(0,Mt.Z)(),q=i.ZP.createElement("div",{className:(0,et.Z)("unread-divider","local-action-message"),key:"unread-messages"},i.ZP.createElement("span",null,D("UnreadMessages"))),$=T?0:l.reduce(((e,t)=>e+t.senderGroups.flat().length),0);let G=0;const H=l.map(((e,t,n)=>{const a=e.senderGroups.map(((e,a,s)=>{if(1===e.length&&!da(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===b.current&&q,i.ZP.createElement(Va,{key:o.id,message:o,isInsideTopic:Boolean(c&&c!==r._f),observeIntersectionForReading:B,observeIntersectionForLoading:U,observeIntersectionForPlaying:L,memoFirstUnreadIdRef:y,appearanceOrder:$-++G,isLastInList:d})])}let o;return e.map(((r,d)=>{const l=da(r)?r.mainMessage:r,m=da(r)?r:void 0,h=(0,u.B4)(l),f=da(r),v=e[d+1];l.previousLocalId&&w.current===(0,u.d0)(l.previousLocalId)&&(w.current=(0,u.d0)(l.id));const Z=!f&&l.groupedId?l.groupedId:void 0,C=v&&!da(v)?v.groupedId:void 0,E={isFirstInGroup:0===d,isLastInGroup:d===e.length-1,isFirstInDocumentGroup:Boolean(Z&&Z!==o),isLastInDocumentGroup:Boolean(Z&&Z!==C),isLastInList:d===e.length-1&&a===s.length-1&&t===n.length-1};o=Z;const S=(0,u.KK)(l),k=(0,u.jM)(l)?`${l.date}_${S}`:S;return(0,I.oA)([l.id===b.current&&q,i.ZP.createElement(vo,{key:k,message:l,observeIntersectionForBottom:B,observeIntersectionForLoading:U,observeIntersectionForPlaying:L,album:m,noAvatars:g,withAvatar:E.isLastInGroup&&p&&!h&&!(l.id===M),withSenderName:E.isFirstInGroup&&p&&!h,threadId:c,messageListType:P,noComments:!1===R,appearanceOrder:$-++G,isFirstInGroup:E.isFirstInGroup,isLastInGroup:E.isLastInGroup,isFirstInDocumentGroup:E.isFirstInDocumentGroup,isLastInDocumentGroup:E.isLastInDocumentGroup,isLastInList:E.isLastInList,memoFirstUnreadIdRef:y}),l.id===M&&i.ZP.createElement("div",{className:"local-action-message",key:"discussion-started"},i.ZP.createElement("span",null,D("DiscussionStarted")))])})).flat()}));return i.ZP.createElement("div",{className:"message-date-group",key:e.datetime,onMouseDown:ua.q,teactFastList:!0},i.ZP.createElement("div",{className:(0,et.Z)("sticky-date",!k&&"interactive"),key:"date-header",onMouseDown:ua.q,onClick:k?void 0:()=>x({selectedAt:e.datetime})},i.ZP.createElement("span",{dir:"auto"},k&&e.originalDate===o.t4X&&D("MessageScheduledUntilOnline"),k&&e.originalDate!==o.t4X&&D("MessageScheduledOn",(0,ae.j1)(D,e.datetime,void 0,!0)),!k&&(0,ae.j1)(D,e.datetime))),a.flat())}));return i.ZP.createElement("div",{className:"messages-container",teactFastList:!0},i.ZP.createElement("div",{ref:j,key:"backwards-trigger",className:"backwards-trigger"}),H.flat(),!t&&m&&i.ZP.createElement(yo,{key:n,chatId:n,containerRef:v}),i.ZP.createElement("div",{ref:O,key:"forwards-trigger",className:"forwards-trigger"}),i.ZP.createElement("div",{ref:_,key:"fab-trigger",className:"fab-trigger"}))}));var Zo=n(73547);const Co=(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,Mt.Z)(),l=(0,i.sO)(null),{observe:u}=(0,va.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(Zo.Z,{sticker:t,onClick:m,clickArg:t,observeIntersection:u,size:160,className:"large",noContextMenu:!0,isCurrentUserPremium:!0}))))}))),Eo=3*Me.Gw,So=(0,i.X$)((e=>{let{isChatWithSelf:t,type:n,isGroupChatJustCreated:a,topic:s}=e;const o=(0,Mt.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(uo.Z,{topic:t,size:Eo,className:"icon topic-icon"}),i.ZP.createElement("h3",{className:"title"},e("Chat.EmptyTopicPlaceholder.Title")),i.ZP.createElement("p",{className:"description topic-description"},(0,xn.Z)(e("Chat.EmptyTopicPlaceholder.Text"),["br"]))))}(o,s):i.ZP.createElement("div",{className:"empty"},i.ZP.createElement("span",null,o("NoMessages")))})),Mo=(0,F.Ds)((e=>e()),200,!1),Ro=(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);if(!(a===r._f||o?.isForum||c&&l&&c[l]))return{};const{isRestricted:m,restrictionReason:h,lastMessage:p}=o,g=(0,d.G$)(e,n),f=a===r._f&&!i&&!o.unreadCount&&!g&&p&&!p.groupedId,I=(0,d.IK)(e,n);let v,w=!1;(0,d.pk)(e,n)&&(I.fullInfo?v=I.fullInfo.botInfo:w=!0);const b=o.topics?.[a];return{isCurrentUserPremium:(0,d.wV)(e),isChatLoaded:!0,isRestricted:m,restrictionReason:h,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(I),messageIds:i,messagesById:c,firstUnreadId:(0,d.It)(e,n,a),isViewportNewest:"thread"!==s||(0,d.b9)(e,n,a),threadFirstMessageId:(0,d.yZ)(e,n,a),focusingId:g,isSelectModeActive:(0,d.CA)(e),isLoadingBotInfo:w,botInfo:v,threadTopMessageId:l,hasLinkedChat:o.fullInfo&&"linkedChatId"in o.fullInfo?Boolean(o.fullInfo.linkedChatId):void 0,lastSyncTime:e.lastSyncTime,topic:b,...f&&{lastMessage:p}}}))((e=>{let{chatId:t,threadId:n,type:r,hasTools:c,onFabToggle:l,onNotchToggle:m,isCurrentUserPremium:h,isChatLoaded:p,isChannelChat:g,isGroupChat:v,canPost:w,isReady:b,isChatWithSelf:y,isRepliesChat:P,isCreator:Z,isBot:C,messageIds:E,messagesById:S,firstUnreadId:M,isViewportNewest:R,threadFirstMessageId:k,isRestricted:T,restrictionReason:N,focusingId:A,isSelectModeActive:x,lastMessage:B,isLoadingBotInfo:U,botInfo:L,threadTopMessageId:j,hasLinkedChat:O,lastSyncTime:_,withBottomShift:D,withDefaultBg:q,topic:$}=e;const{loadViewportMessages:G,setScrollOffset:H,loadSponsoredMessages:V,loadMessageReactions:z,copyMessagesByIds:W}=(0,a.Sv)(),X=(0,i.sO)(null),Y=(0,i.sO)("thread"===r&&(0,d.Vt)((0,a.Rd)(),t,n)||(0,d.T6)((0,a.Rd)(),t,n)||0),J=(0,i.sO)(),K=(0,i.sO)(),Q=(0,i.sO)(),ee=(0,i.sO)(),te=(0,i.sO)(),ne=(0,i.sO)(),ae=(0,i.sO)(!1),se=(0,i.sO)(Boolean(B)),[oe,ie]=(0,i.eJ)(),re=(0,zt.Z)(L?.photo?(0,u.NF)(L.photo):void 0),ce=(0,zt.Z)(L?.gif?(0,u.ym)(L.gif):void 0),de=L?.photo?(0,u.bV)(L.photo):L?.gif?(0,u.jC)(L.gif):void 0,le=de&&{width:de.width/s.cL,height:de.height/s.cL},ue=Boolean(E);(0,it.Z)((()=>{ue&&(0,F.R3)((()=>{se.current=!1}))}),[ue]),(0,it.Z)((()=>{ee.current=M}),[M]),(0,i.d4)((()=>{!h&&g&&b&&_&&V({chatId:t})}),[h,t,b,g,_,V]),(0,it.Z)((()=>{ue&&(te.current=ee.current)}),[ue]),(0,it.Z)((()=>{ne.current=A}),[A]),(e=>{(0,Et.y)({"Mod+C":function(t){const n=(0,ga.Z)();n&&n.length>1&&(t.preventDefault(),e({messageIds:n}))}})})(W);const me=(0,i.Ye)((()=>{if(!E||!S)return;const e=!j||k===j||E[0]&&k!==E[0]?E:[j,...E];if(!e.length)return;const t=e.map((e=>S[e])).filter(Boolean);return t.length?la((0,I.Xo)(t,["date","id"]),te.current):void 0}),[E,S,k,j]);(0,pt.Z)((()=>{if(!E||!S)return;const e=E.filter((e=>S[e]?.reactions));e.length&&z({chatId:t,ids:e})}),15e3);const he=(0,i.Ye)((()=>{if("thread"===r)return(0,F.Ds)((()=>G({direction:f.Uq.Around})),1e3,!0,!1)}),[G,E]),{isScrolled:pe,updateStickyDates:ge}=function(){const[e,t]=(0,Ct.Z)(!1),n=(0,pa.Z)(1e3,!0);return{isScrolled:e,updateStickyDates:(0,i.I4)(((e,a)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,F.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),n((()=>{(0,F.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])}}(),fe=(0,i.sO)(),Ie=(0,i.sO)(),ve=(0,i.I4)((()=>{if(ae.current)return void(ae.current=!1);const e=X.current;e&&(fe.current=!0,ne.current||ge(e,c),Mo((()=>{fe.current=!1,(0,F.T2)((()=>{e.parentElement&&(Y.current=e.scrollHeight-e.scrollTop,"thread"===r&&H({chatId:t,threadId:n,scrollOffset:Y.current}))}))})))}),[ge,c,r,H,t,n]),we=(0,i.I4)((e=>{ie(e.contentRect.height)}),[]);(0,Ia.Z)(X,we);const{height:be}=(0,Cn.Z)();(0,i.d4)((()=>{X.current.dataset.normalHeight=String(X.current.offsetHeight)}),[be,w]),(0,i.d4)((()=>{if(!he||!p||T||A)return;if(E&&E[E.length-1]>o.MPN)return;const e=X.current;(!E||E.length<o.hT6/2&&e.firstElementChild.clientHeight<=e.offsetHeight)&&he()}),[p,E,he,A,T]),(0,it.Z)((()=>{if(!E||!Q.current)return;const e=Q.current.filter((e=>E.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(J.current=t.id,K.current=t.getBoundingClientRect().top)}),[E,R,oe,c]),fa((e=>{let[t,n,a]=e;const s=X.current;Q.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,d=i&&!r,l=E&&ne.current===E[E.length-1],u=R&&d&&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=Y.current,f=Q.current[Q.current.length-1];let I=g-(a||p);d&&(I-=f?f.offsetHeight:0);const v=R&&n&&I<=50;let w;if(d&&v&&!l&&(f&&(0,F.T2)((()=>{(0,ha.Z)(s,f,"end",20)})),w=h-p,Y.current=Math.max(Math.ceil(h-w),p),!u))return;const b=void 0!==a&&a!==oe,y=J.current&&s.querySelector(`#${J.current}`),P=!y&&te.current&&s.querySelector(".unread-divider");if(v&&b){if((0,ha.N)())return;w=h-p}else y?(Ie.current&&(Ie.current=!1,(0,ma.z)(s)),w=m+(y.getBoundingClientRect().top-(K.current||0))):w=P?Math.min(P.offsetTop-(c?60:10),h-g):h-g;(0,ma.Z)(s,Math.ceil(w)),ne.current||(ae.current=!0,(0,F.T2)((()=>{ae.current=!1}))),Y.current=Math.max(Math.ceil(h-w),p)}),[E,R,oe,c]),(0,at.Z)((e=>{let[t]=e;void 0!==t&&(0,ht.YW)(200+o.fK3)}),[x]);const ye=(0,Mt.Z)(),Pe=Boolean(t&&(0,u.YC)(t)),Ze=Boolean(!Pe&&!g||y||P),Ce=Boolean(!Ze||g),Ee=(0,u.YC)(t)&&!y&&!C&&(!me&&!B&&E&&(!Q.current||0===Q.current.length)||1===E?.length&&"contactSignUp"===S?.[E[0]]?.content.action?.type||"contactSignUp"===B?.content?.action?.type),Se=v&&Z&&1===E?.length&&"chatCreate"===S?.[E[0]]?.content.action?.type,Me=1===E?.length&&"topicCreate"===S?.[E[0]]?.content.action?.type,Re=L&&!L.description&&!L.gif&&!L.photo,ke=(0,et.Z)("MessageList custom-scroll",Ce&&"no-avatars",!w&&"no-composer","pinned"===r&&"type-pinned",D&&"with-bottom-shift",q&&"with-default-bg",x&&"select-mode-active",pe&&"scrolled",!b&&"is-animating");return i.ZP.createElement("div",{ref:X,className:ke,onScroll:ve,onMouseDown:ua.q},T?i.ZP.createElement("div",{className:"empty"},i.ZP.createElement("span",null,N?N.text:"This is a private "+(g?"channel":"chat"))):L?i.ZP.createElement("div",{className:"empty"},U&&i.ZP.createElement("span",null,ye("Loading")),Re&&!U&&i.ZP.createElement("span",null,ye("NoMessages")),L&&i.ZP.createElement("div",{className:"bot-info",style:le&&`width: ${le.width}px`},re&&i.ZP.createElement("img",{src:re,width:le?.width,height:le?.height,alt:"Bot info"}),ce&&i.ZP.createElement(gs.Z,{canPlay:!0,src:ce,loop:!0,disablePictureInPicture:!0,muted:!0,playsInline:!0}),de&&!re&&!ce&&i.ZP.createElement(Ts.Z,{width:le?.width,height:le?.height}),L.description&&i.ZP.createElement("div",{className:"bot-info-description"},i.ZP.createElement("p",{className:"bot-info-title"},ye("BotInfoTitle")),(0,xn.Z)(L.description,["br","emoji","links"])))):Ee?i.ZP.createElement(Co,{userId:t}):E&&(!me||Se||Me)?i.ZP.createElement(So,{chatId:t,topic:$,type:r,isChatWithSelf:y,isGroupChatJustCreated:Se}):E&&me||B?i.ZP.createElement(Po,{isCurrentUserPremium:h,chatId:t,messageIds:E||[B.id],messageGroups:me||la([B]),isViewportNewest:Boolean(R),isUnread:Boolean(M),withUsers:Ze,noAvatars:Ce,containerRef:X,anchorIdRef:J,memoUnreadDividerBeforeIdRef:te,memoFirstUnreadIdRef:ee,threadId:n,type:r,isReady:b,isScrollingRef:fe,isScrollPatchNeededRef:Ie,threadTopMessageId:j,hasLinkedChat:O,isSchedule:!!me&&"scheduled"===r,noAppearanceAnimation:!me||!se.current,onFabToggle:l,onNotchToggle:m}):i.ZP.createElement(on.Z,{color:"white",backgroundColor:"dark"}))}))),ko=(0,i.X$)((e=>{let{icon:t,ariaLabelLang:n,unreadCount:a,onClick:s,onReadAll:o,className:r}=e;const c=(0,Mt.Z)(),d=(0,i.sO)(null),{isContextMenuOpen:l,handleContextMenu:u,handleContextMenuClose:m,handleContextMenuHide:h}=(0,ea.Z)(d,!o);return i.ZP.createElement("div",{className:(0,et.Z)("KboxtoWkfx23zfklH_Zg",r),ref:d},i.ZP.createElement(jt.Z,{color:"secondary",round:!0,className:"sgkkv3bmIMAZS9G9BHUz",onClick:s,onContextMenu:u,ariaLabel:c(n)},i.ZP.createElement("i",{className:(0,et.Z)("AafG9_xBi_2eJ_bFNnNg",`icon-${t}`)})),Boolean(a)&&i.ZP.createElement("div",{className:"yKN1kQ3YXf4SHHIBcotS"},(0,vt.bi)(a)),o&&i.ZP.createElement(dn.Z,{isOpen:l,onClose:m,onCloseAnimationEnd:h,autoClose:!0,positionX:"right",positionY:"bottom"},i.ZP.createElement(Lt.Z,{icon:"readchats",onClick:o},c("MarkAllAsRead"))))})),To="EcdaljLbQ7DJN9gbQpSC",No=(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,ha.Z)(e,n,"end",20)}}),[t,s,u]),P=(0,et.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(ko,{icon:"heart-outline",ariaLabelLang:"AccDescrReactionMentionDown",onClick:m,onReadAll:f,unreadCount:c,className:(0,et.Z)("wHTB_MNtk9J6I3F_4eVE",!w&&To,!b&&"uHEtFnXb6pb14Jf0EsDr")}),i.ZP.createElement(ko,{icon:"mention",ariaLabelLang:"AccDescrMentionDown",onClick:h,onReadAll:g,unreadCount:d,className:!b&&To}),i.ZP.createElement(ko,{icon:"arrow-down",ariaLabelLang:"AccDescrPageDown",onClick:y,unreadCount:r,className:"Hoi4yrJrfBHTmvB8TPce"}))})));var Ao=n(65723);const xo=/\.[^/.]+$/;async function Bo(e,t,a){const s=URL.createObjectURL(t),{type:i,size:r}=t;let c,d,l;if(o.oGt.has(i)){const n=await(0,Zn.pt)(s),{width:r,height:d}=n,u=Math.max(r,d)>1280,m=i===o.s11;if(!a?.compressedBlobUrl&&!m&&(u||"image/jpeg"!==i)){const n=await zn(s,u?1280/Math.max(r,d):1,"image/jpeg");return URL.revokeObjectURL(s),Bo(e,t,{compressedBlobUrl:n})}"image/jpeg"===i&&(e=e.replace(xo,".jpg")),c={width:r,height:d},l=s}else if(o.wGh.has(i)){const{videoWidth:e,videoHeight:t,duration:n}=await(0,Zn.jj)(s);c={width:e,height:t,duration:n},l=await(0,Zn.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,uniqueId:`${Date.now()}-${Math.random()}`,...a}}function Uo(e,t){return e.map((e=>t?e.compressedBlobUrl?{...e,blobUrl:e.compressedBlobUrl}:e:{...e,shouldSendAsFile:!e.voice||void 0,shouldSendAsSpoiler:void 0}))}var Lo=n(41098);function jo(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 Oo=n(96391);let Fo;function _o(e){Fo.focus(),e.focus()}s.cj&&(Fo=document.createElement("input"),Fo.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(Fo));var Do=n(74288),qo=n(33799),$o=n(94462),Go=n(33681),Ho=n(52400),Vo=n(86203),zo=n(71790);const Wo=new RegExp(`^${o.t8f.source}$`,"g");var Xo=n(56389);const Yo={encoderPath:new URL(n(68973),n.b).href,reuseWorker:!0},Jo={type:"audio/ogg"};let Ko,Qo,ei;async function ti(){return Ko||(Ko=n.e(1161).then(n.t.bind(n,1161,23)),Qo=(await Ko).default,ei=new Qo(Yo)),Ko}async function ni(e){await async function(){await ti(),await ei.start()}();const t=Date.now();let n;const a=[],s=[];ei.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}}(ei);return{stop:()=>new Promise(((e,i)=>{ei.onstop=()=>{e({blob:new Blob(a,Jo),duration:Math.round(((n||Date.now())-t)/1e3),waveform:s})},ei.onerror=i;const r=Math.max(0,t+1e3-Date.now());setTimeout((()=>{ei.stop(),o()}),r)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{ei.pause(),n=Date.now(),o()}),e)}}}var ai=n(21262);const si=/id="docs-internal-guid/i,oi=["H1","H2","H3","H4","H5","H6"];function ii(e){return(new DOMParser).parseFromString(e,"text/html").body}function ri(e,t){const n=document.createElement("a");return n.href=t,n.appendChild(e.cloneNode(!0)),n}function ci(e,t){const n=document.createElement(t);return n.appendChild(e.cloneNode(!0)),n}function di(e,t){let n=t.cloneNode(!0);return e?(e.style&&"700"===e.style.fontWeight&&(n=ci(n,"strong")),e.style&&"italic"===e.style.fontStyle&&(n=ci(n,"em")),e.style&&"underline"===e.style.textDecoration&&(n=ci(n,"u")),e.style&&"line-through"===e.style.textDecoration&&(n=ci(n,"del")),e.style&&"super"===e.style.verticalAlign&&(n=ci(n,"sup")),e.style&&"sub"===e.style.verticalAlign&&(n=ci(n,"sub")),n):n}function li(e){const t=e.cloneNode(!0);let n=document.createTextNode(t.textContent||""),a=t;return"A"===t.nodeName&&(n=ri(n,t.href),"style"in t.childNodes[0]&&Boolean(t.childNodes[0].style)&&(a=t.childNodes[0])),n=di(a,n),n}function ui(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(...ui(e.childNodes[t]));a.map((e=>n.appendChild(e)))}else-1!==oi.indexOf(e.nodeName)?(t=document.createElement(e.nodeName),n=li(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=ri(n.cloneNode(!0),t.childNodes[0].href),a=t.childNodes[0].childNodes[0]),n=di(a,n),n}(e)):"BR"===e.nodeName?n=e:(t=document.createElement("span"),n=li(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(...ui(e.childNodes[n]));return t}return[e]}function mi(e){return 8!==e.nodeType}var hi=n(56266);const pi=/<style>(.*?)<\/style>/gs,gi=(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(si)?function(e){const t=document.createElement("body"),n=e.childNodes,a=Array.from(n).filter(mi),s=[];for(const e of a)s.push(...ui(e));for(let e=0;e<s.length;e++)t.appendChild(s[e].cloneNode(!0));return t}(ii(n.replace(/(\r\n|\n|\r)/,""))).innerHTML:ii(n.replace(/(\r\n|\n|\r)/,"")).innerHTML}catch(e){o.eMD&&console.error(e)}var n;t.innerHTML=e.replace(/\u00a0/g," ").replace(pi,"");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,hi.Lo)(u)&&s&&(u=(0,hi.If)(u),c?.());const{items:m}=e.clipboardData;let h=[];if(e.preventDefault(),m.length>0&&(h=await(0,ai.Z)(m)),!h?.length&&!d)return;if(h?.length&&!a){const e=await Promise.all(h.map((e=>Bo(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 fi=n(28353),Ii=n(29295),vi=n(16580),wi=n(11309);const bi=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,yi=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i,Pi={username:"",query:"",canShowHelp:!1,usernameLowered:""},Zi=document.createElement("div");const Ci=(0,vi.Z)(((e,t,n)=>({username:e,query:t,canShowHelp:n,usernameLowered:e.toLowerCase()}))),Ei=/^\/([\w@]{1,32}\s?)?/i;var Si=n(33057),Mi=n(60130),Ri=n(69156),ki=n(70971);let Ti=!1;const Ni=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"DeleteMessageModal",!t);return n?i.ZP.createElement(n,e):void 0}));var Ai=n(43521),xi=n(85655),Bi=n(56503),Ui=n(62898);const Li="N3E1geoPu1vesCKf545F",ji=/#fff/gi,Oi=(0,i.X$)((e=>{let{icon:t,theme:n}=e;const a=(0,zt.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(ji,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,et.Z)("vL8HfVVnjTeFmp1ECFj8",s.FW&&Li)},i.ZP.createElement("img",{src:o,alt:"",className:(0,et.Z)("Fb4aIyDYEwOlaqY8oZkV",s.FW&&Li)}))})),Fi=(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,Mt.Z)(),m=(0,i.Ye)((()=>t.icons.find((e=>{let{name:t}=e;return"default_static"===t}))?.document),[t.icons]),[h,p,g]=(0,Ct.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(Lt.Z,{key:t.id,customIcon:m&&i.ZP.createElement(Oi,{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(Ui.Z,null,i.ZP.createElement(dn.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(Lt.Z,{icon:"stop",destructive:!0,onClick:y},u("WebApp.RemoveBot")))))})),_i=(0,i.X$)((e=>{let{chatId:t,threadId:n,isButtonVisible:a,canAttachMedia:r,canAttachPolls:c,attachBots:d,peerType:l,isScheduled:u,onFileSelect:m,onPollCreate:h,theme:p}=e;const[g,f,I]=(0,Ct.Z)(),[v,w,b]=(0,Bi.Z)(g,I),[y,P,Z]=(0,Ct.Z)();(0,i.d4)((()=>{g&&b()}),[g,b]);const C=(0,i.I4)((()=>{g?I():f()}),[g,f,I]),E=(0,i.I4)(((e,t)=>{const{files:n}=e.target,a=(0,Zn.ox)(n);a?.length&&m(a,t)}),[m]),S=(0,i.I4)((()=>{(0,xi.g)(Array.from(o.dII).join(","),(e=>E(e,!0)))}),[E]),M=(0,i.I4)((()=>{(0,xi.g)("*",(e=>E(e,!1)))}),[E]),R=(0,i.Ye)((()=>Object.values(d).filter((e=>!!l&&(!("bots"!==l||e.id!==t||!e.peerTypes.includes("self"))||e.peerTypes.includes(l))))),[d,t,l]),k=(0,Mt.Z)();if(a)return i.ZP.createElement("div",{className:"AttachMenu"},i.ZP.createElement(Ai.Z,{id:"attach-menu-button",className:g?"AttachMenu--button activated":"AttachMenu--button",round:!0,color:"translucent",onActivate:C,ariaLabel:"Add an attachment",ariaControls:"attach-menu-controls",hasPopup:!0},i.ZP.createElement("i",{className:"icon-attach"})),i.ZP.createElement(dn.Z,{id:"attach-menu-controls",isOpen:g||y,autoClose:!0,positionX:"right",positionY:"bottom",onClose:I,className:"AttachMenu--menu fluid",onCloseAnimationEnd:I,onMouseEnter:s.$b?void 0:v,onMouseLeave:s.$b?void 0:w,noCloseOnBackdrop:!s.$b,ariaLabelledBy:"attach-menu-button"},!r&&i.ZP.createElement(Lt.Z,{className:"media-disabled",disabled:!0},"Posting media content is not allowed in this group."),r&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(Lt.Z,{icon:"photo",onClick:S},k("AttachmentMenu.PhotoOrVideo")),i.ZP.createElement(Lt.Z,{icon:"document",onClick:M},k("AttachDocument"))),c&&i.ZP.createElement(Lt.Z,{icon:"poll",onClick:h},k("Poll")),r&&!u&&R.map((e=>i.ZP.createElement(Fi,{bot:e,chatId:t,threadId:n,theme:p,onMenuOpened:P,onMenuClosed:Z})))))})),Di=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"InlineBotTooltip",!t);return n?i.ZP.createElement(n,e):void 0})),qi=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"MentionTooltip",!t);return n?i.ZP.createElement(n,e):void 0}));var $i=n(67146);const Gi=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"StickerTooltip",!t);return n?i.ZP.createElement(n,e):void 0}));var Hi=n(93219),Vi=n(19830);const zi=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"BotCommandTooltip",!t);return n?i.ZP.createElement(n,e):void 0})),Wi=(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,Bi.Z)(t,o),{isKeyboardSingleUse:l}=n||{};if(n&&n.keyboardButtons)return i.ZP.createElement(dn.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(jt.Z,{ripple:!0,disabled:"unsupported"===e.type,onClick:()=>r({messageId:n.id,button:e})},e.text))))))))})));var Xi=n(49841),Yi=n(17891),Ji=n(63394),Ki=n(66902);const Qi=(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,Mt.Z)(),E=Boolean(c),S=Boolean((t||n)&&s||o&&c),M=(0,Yi.Z)([c],c?300:void 0),{shouldRender:R,transitionClassNames:k}=(0,mt.Z)(M&&S,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)((()=>S?(0,Pt.Z)(T):void 0),[S,T]);const N=(0,i.I4)((()=>{E||v({chatId:s.chatId,messageId:s.id,noForumTopicPanel:!0})}),[v,E,s]),A=(0,i.I4)((e=>{e.stopPropagation(),T()}),[T]),x=(0,i.I4)((()=>{w()}),[w]),{isContextMenuOpen:B,contextMenuPosition:U,handleContextMenu:L,handleContextMenuClose:j,handleContextMenuHide:O}=(0,ea.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,Ji.Z)(U,F,_,D),z=(0,et.Z)("ComposerEmbeddedMessage",k),W=(0,i.Ye)((()=>t&&!h?"icon-reply":n?"icon-edit":E?"icon-forward":void 0),[n,E,t,h]),X=c&&c>1?C("ForwardedMessageCount",c):void 0,Y=(0,i.Ye)((()=>{if(!s||!E||!s.content.text||!d||p)return s;const e=(0,u.If)(s.content.text);return{...s,content:{...s.content,text:e}}}),[p,E,s,d]);if(R)return i.ZP.createElement("div",{className:z,ref:Z,onContextMenu:L,onClick:L},i.ZP.createElement("div",null,i.ZP.createElement("div",{className:"embedded-left-icon"},i.ZP.createElement("i",{className:W})),i.ZP.createElement(za,{className:"inside-input",message:Y,sender:d?void 0:o,customText:X,title:n?C("EditMessage"):d?C("HiddenSendersNameDescription"):void 0,onClick:N,hasContextMenu:E}),i.ZP.createElement(jt.Z,{className:"embedded-cancel",round:!0,faded:!0,color:"translucent",ariaLabel:C("Cancel"),onClick:A},i.ZP.createElement("i",{className:"icon-close"})),E&&i.ZP.createElement(dn.Z,{isOpen:B,transformOriginX:G,transformOriginY:H,positionX:q,positionY:$,style:V,className:"forward-context-menu",onClose:j,onCloseAnimationEnd:O},i.ZP.createElement(Lt.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(Lt.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(Ki.Z,null),i.ZP.createElement(Lt.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(Lt.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(Ki.Z,null),i.ZP.createElement(Lt.Z,{icon:"replace",onClick:x},C("ChangeRecipient")))))}))),er=(0,i.X$)((e=>{const{attachments:t}=e,n=(0,ft.Z)(gt.gl.Extra,"AttachmentModal",!t.length);return n?i.ZP.createElement(n,e):void 0})),tr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"BotCommandMenu",!t);return n?i.ZP.createElement(n,e):void 0})),nr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"PollModal",!t);return n?i.ZP.createElement(n,e):void 0})),ar=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"DropArea",!t);return n?i.ZP.createElement(n,e):void 0})),sr=new RegExp(o.FM6,"i"),or=(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,wi.i)((()=>{const{text:e,entities:t}=(0,w.ZP)(s()),n=t?.find((e=>e.type===r.Vv.TextUrl));return n?.url||e.match(sr)?.[0]}),[s],300,!0),g=(0,zo.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,it.Z)((()=>{m(),h({chatId:t,threadId:n})}),[t,m,n,h]);const f=(0,Vo.Z)((()=>Boolean(c&&s()&&!d&&!o)),[o,s,d,c]),{shouldRender:I,transitionClassNames:v}=(0,mt.Z)(f),b=(0,kn.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,et.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(ks,{message:C,inPreview:!0,theme:l}),i.ZP.createElement(jt.Z,{className:"WebPagePreview-clear",round:!0,faded:!0,color:"translucent",ariaLabel:"Clear Webpage Preview",onClick:y},i.ZP.createElement("i",{className:"icon-close"}))))}))),ir=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"SendAsMenu",!t);return n?i.ZP.createElement(n,e):void 0})),rr=(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(jt.Z,{className:(0,et.Z)("bot-menu",t&&"open"),round:!0,color:"translucent",disabled:s,onClick:n,ariaLabel:"Open bot command keyboard"},i.ZP.createElement("i",{className:(0,et.Z)("bot-menu-icon","icon-webapp",t&&"open")}),i.ZP.createElement("span",{ref:o,className:"bot-menu-text"},a))}));var cr,dr=n(23522);!function(e){e.Send="send",e.Record="record",e.Edit="edit",e.Schedule="schedule"}(cr||(cr={}));const lr="wonderful-voice-message.ogg",ur=(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,E=c?.fullInfo?c?.fullInfo?.sendAsId||C:void 0,S=c?.sendAsPeerIds&&E&&(c.sendAsPeerIds.some((e=>e.id===E))?E:c?.adminRights?.anonymous?c?.id:void 0),M=S?(0,d.dy)(e,S):void 0,R=!M&&S?(0,d.Z1)(e,S):void 0,k=(0,d.uH)(e,a),T=(0,d.nA)(e,a),N=(0,d.Bt)(e),A=a===N?.chatId&&s===N?.threadId&&i===N?.type,x=(0,d.dy)(e,a),B=null===(n=x&&!x.fullInfo?.noVoiceMessages)||void 0===n||n,U="scheduled"===i?(0,d.hI)(e,a):(0,d.s)(e,a,s),L=(0,d.Yy)(e,a,s),j=(0,d.jU)(e);return{editingMessage:(0,d.kK)(e,a,s,i),connectionState:e.connectionState,replyingToId:L,draft:(0,d.Ms)(e,a,s),chat:c,isChatWithBot:m,isChatWithSelf:h,isForCurrentMessageList:A,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:S,editingDraft:U,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:E,isChatWithBot:S,isChatWithSelf:M,isChannel:R,fileSizeLimit:k,isRightColumnShown:T,isSelectModeActive:N,isForwarding:A,pollModal:x,botKeyboardMessageId:B,botKeyboardPlaceholder:U,withScheduledButton:L,stickersForEmoji:j,customEmojiForEmoji:O,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:Ee,callAttachBot:Se,addRecentCustomEmoji:Me,showNotification:Re}=(0,a.Sv)(),ke=(0,Mt.Z)(),Te=(0,i.sO)(null),Ne=(0,i.sO)(null),[Ae,Be]=(0,qo.Z)(""),Ue=(0,Ri.Z)(o.Edp),Le=(0,i.sO)(),je=(0,Sn.Z)(t),{width:Oe}=xe.Z.get(),Fe=y?.sendAsPeerIds,_e=Fe&&(Fe.length>1||!Fe.some((e=>e.id===q))),[De,qe,$e]=(0,Ct.Z)(),Ge=(0,Xo.Z)(g,f);(0,i.d4)(Do.AU,[Ae]);const He=(0,i.sO)(0),Ve=(0,i.I4)((()=>{$e()}),[$e]),[ze,We]=(0,Si.Z)(c,Ve);(0,i.d4)((()=>{Le.current=void 0}),[g]),(0,i.d4)((()=>{g&&G&&d&&be({chatId:g})}),[d,g,be,G,f]),(0,i.d4)((()=>{g&&y&&G&&!Fe&&d&&(0,u.ZV)(y)&&Ce({chatId:g})}),[y,g,d,G,Ce,Fe]);const Xe=(0,i.sO)(!1);(0,it.Z)((e=>{let[t,n]=e;Xe.current=Boolean(g===t&&Fe&&!n)}),[g,Fe]),(0,i.bt)((()=>{Te.current&&(Te.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[Ye,Je]=(0,i.eJ)([]),Ke=Boolean(Ye.length),{shouldSuggestCompression:Qe,handleAppendFiles:tt,handleFileSelect:nt,onCaptionUpdate:rt,handleClearAttachments:ct,handleSetAttachments:dt}=function(e){let{attachments:t,fileSizeLimit:n,setHtml:s,setAttachments:o}=e;const{openLimitReachedModal:r}=(0,a.Sv)(),[c,d]=(0,i.eJ)(void 0),u=(0,i.I4)((()=>{o(l.D)}),[o]),m=(0,i.I4)((e=>{const a="function"==typeof e?e(t):e;a.length?a.some((e=>{let{size:t}=e;return t>n}))?r({limit:"uploadMaxFileparts"}):o(a):o(l.D)}),[t,n,r,o]);return{shouldSuggestCompression:c,handleAppendFiles:(0,i.I4)((async(e,n)=>{m([...t,...await Promise.all(e.map((e=>Bo(e.name,e,{shouldSendAsSpoiler:n||void 0}))))])}),[t,m]),handleFileSelect:(0,i.I4)((async(e,t)=>{m(await Promise.all(e.map((e=>Bo(e.name,e))))),d(t)}),[m]),onCaptionUpdate:s,handleClearAttachments:u,handleSetAttachments:m}}({attachments:Ye,setHtml:Be,setAttachments:Je,fileSizeLimit:k}),[lt,ut,mt]=(0,Ct.Z)(),[ht,gt,ft]=(0,Ct.Z)(),[It,vt,wt]=(0,Ct.Z)(),[bt,yt,Zt]=(0,Ct.Z)(),[Et,St,Rt]=(0,Ct.Z)(),[kt,Tt,Nt]=(0,Ct.Z)(),{startRecordingVoice:At,stopRecordingVoice:xt,pauseRecordingVoice:Bt,activeVoiceRecording:Ut,currentRecordTime:Lt,recordButtonRef:Ot,startRecordTimeRef:Ft}=(()=>{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&&ti()}),[]);const c=(0,i.I4)((async()=>{try{const{stop:t,pause:s}=await ni((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,Pt.Z)(l):void 0),[t,l]),{startRecordingVoice:c,pauseRecordingVoice:d,stopRecordingVoice:l,activeVoiceRecording:t,currentRecordTime:o,recordButtonRef:e,startRecordTimeRef:a}})();(0,pt.Z)((()=>{Ge({type:"recordAudio"})}),Ut&&o.o_S),(0,i.d4)((()=>{Ut||Ge({type:"cancel"})}),[Ut,Ge]);const _t=(0,ki.Y)(Boolean(p));(0,i.d4)((()=>{Ae()&&!_t.current&&Ge({type:"typing"})}),[Ae,_t,Ge]);const{canSendStickers:Dt,canSendGifs:$t,canAttachMedia:Gt,canAttachPolls:Ht,canAttachEmbedLinks:Vt}=(0,i.Ye)((()=>(0,u.H5)(y,S)),[y,S]),zt=y&&(0,u.Nl)(y),Wt=(0,u.Hd)(y),{isEmojiTooltipOpen:Xt,closeEmojiTooltip:Yt,filteredEmojis:Jt,filteredCustomEmojis:Kt,insertEmoji:Qt}=(0,fi.Z)(Boolean(d&&P&&V&&!Ke),Ae,Be,void 0,Y,W,X),{isCustomEmojiTooltipOpen:en,closeCustomEmojiTooltip:tn,insertCustomEmoji:nn}=(0,Mi.Z)(Boolean(d&&P&&z&&!Ke),Ae,Be,Ue,Ne,O),{isStickerTooltipOpen:an,closeStickerTooltip:sn}=function(e,t,n){const{loadStickersForEmoji:r,clearStickersForEmoji:c}=(0,a.Sv)(),[d,l,u]=(0,Ct.Z)(!1),m=(0,zo.Z)((()=>{const n=t();if(!e||!n||s.op&&n.length>8)return;if(!n.match(s.op?Go.Z:o.t8f))return;const a=(0,Ho._)(n);return a&&(s.op&&1===(0,$o.Z)(a)||!s.op&&Boolean(n.match(Wo)))?s.op?a:a.match(/alt="(.+)"/)?.[1]:void 0}),[t,e]),h=(0,Vo.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&&Dt&&!Ke),Ae,j),{isMentionTooltipOpen:on,closeMentionTooltip:rn,insertMention:cn,mentionFilteredUsers:dn}=(0,Ii.Z)(Boolean(d&&P&&!Ke),Ae,Be,Ue,Ne,_,D,q),{isOpen:ln,botId:un,isGallery:mn,switchPm:hn,results:pn,closeTooltip:gn,help:fn,loadMore:In}=function(e,t,n,s){const{queryInlineBot:o,resetInlineBot:r,resetAllInlineBots:c}=(0,a.Sv)(),[d,l,u]=(0,Ct.Z)(!1),m=(0,wi.C)((()=>{const t=n();return e&&t.startsWith("@")?function(e){if(!e.startsWith("@"))return Pi;const t=function(e){return Zi.innerHTML=e.replace(/<br>/g,"\n"),Zi.querySelectorAll("[alt]").forEach((e=>{e.innerText||(e.innerText=e.getAttribute("alt"))})),Zi.innerText}(e),n=t.match(bi);return n?Ci(n[1],n[2],""===n[2]&&!t.match(yi)):Pi}(t):Pi}),[n,e],300),{username:h,query:p,canShowHelp:g,usernameLowered:f}=(0,Vo.Z)(m,[m,n],!0);(0,it.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&&!Ke&&G),g,Ae,J),{isOpen:vn,close:wn,filteredBotCommands:bn}=function(e,t,n,a){const[s,o]=(0,i.eJ)(),[r,c,d]=(0,Ct.Z)(!1),l=(0,wi.C)((()=>{const n=t();return e&&n.startsWith("/")?(0,Ho._)(n).match(Ei)?.[0].trim():void 0}),[t,e],300),u=(0,zo.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.includes(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)),Ae,Q,ee),Pn=(0,i.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.R2F;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,Oo.R)(s,t))return(0,Lo.t)(e),void a.dispatchEvent(new Event("input",{bubbles:!0}))}Be(`${Ae()}${e}`),requestAnimationFrame((()=>{(0,Ao.Z)(a)}))}),[Ae,Be]),Zn=(0,i.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.R2F;const n=(0,ws.z)(e);Pn(n,t)}),[Pn]),Cn=(0,i.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.R2F;Pn((0,Ta.yR)(e),t)}),[Pn]);((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]:{};if(g||!u)return;const a=c();var s,o,i,r;a?m({chatId:null!==(s=e.chatId)&&void 0!==s?s:t,threadId:null!==(o=e.threadId)&&void 0!==o?o:n,draft:(0,w.ZP)(a)}):h({chatId:null!==(i=e.chatId)&&void 0!==i?i:t,threadId:null!==(r=e.threadId)&&void 0!==r?r:n})}),[t,n,g,u,c,m,h]),I=(0,ki.Y)(f),v=(0,pa.Z)(o.r_R,!0,void 0,[t,n]);(0,at.Z)((a=>{let[i,c,u]=a;if(t===i&&n===c)return void(!e&&u&&d(""));if(l||!e)return;d((0,ws.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,Ao.Z)(e,!0)}))}),[t,n,e,d,l,p]),(0,i.d4)((()=>()=>{g||I.current({chatId:t,threadId:n}),Ti=!0,requestAnimationFrame((()=>{Ti=!1}))}),[t,n,g,I]);const b=(0,ki.Y)(t),y=(0,ki.Y)(n);(0,i.d4)((()=>{if(Ti)return;if(!c())return void I.current();const e=b.current,t=y.current;v((()=>{b.current===e&&y.current===t&&I.current()}))}),[b,c,v,y,I]),(0,st.Z)(f),ot(f)})(b,g,f,Ae,Be,p,G);const En=(0,i.I4)((function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e||Be(""),Je(l.D),Yt(),tn(),sn(),rn(),m?setTimeout((()=>wt()),350):wt()}),[Be,m,sn,tn,rn,Yt,wt]),[Mn,Rn,kn]=((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,at.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,ws.z)(i);t(r),v(!0),requestAnimationFrame((()=>{const e=document.querySelector(o.Edp);e&&(0,Ao.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,F.T2)((()=>{t((0,ws.z)(m));const e=document.querySelector(o.Edp);e&&requestAnimationFrame((()=>{(0,Ao.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,st.Z)(Z),ot(Z),[P,y,I]})(Ae,Be,p,En,St,g,f,I,b,oe,ie),Tn=(0,ki.Y)(En),Nn=(0,ki.Y)(xt);(0,i.d4)((()=>()=>{Nn.current(),Tn.current()}),[g,f,Tn,Nn]);const An=(0,i.I4)((()=>{const e=He.current;Re(e?{message:ke("UnlockPremiumEmojiHint2"),action:{action:"openChat",payload:{id:q,shouldReplaceHistory:!0}},actionText:ke("Open")}:{message:ke("UnlockPremiumEmojiHint"),action:{action:"openPremiumModal",payload:{initialSection:"animated_emoji"}},actionText:ke("PremiumMore")}),He.current=Number(!e)}),[q,ke,Re]),Bn=(0,Vo.Z)((()=>p&&kn?cr.Edit:!s.mh||Ut||A||Ae()&&!Ke?n?cr.Schedule:cr.Send:cr.Record),[Ut,p,Ae,Ke,A,kn,n]),Un=!n,{isContextMenuOpen:Ln,handleContextMenu:jn,handleContextMenuClose:On,handleContextMenuHide:Fn}=(0,ea.Z)(Ot,!(Bn===cr.Send&&Un));gi(P,Zn,dt,p,!Z&&!M,An);const _n=(0,i.I4)((()=>{p&&Rn()}),[p,Rn]),Dn=(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]),qn=(0,i.I4)((()=>{if(Wt&&!zt){const e=document.querySelector(o.Edp),t=(0,v.bp)(),n=Le.current&&Math.floor(t-Le.current),a=Wt.nextSendDate&&Wt.nextSendDate>t;if(n&&n<Wt.seconds||a){const s=a?Wt.nextSendDate-t:Wt.seconds-n;return fe({data:{message:ke("SlowModeHint",(0,ae.k9)(s)),isSlowMode:!0,hasErrorKey:!1}}),e?.blur(),!1}}return!0}),[zt,ke,fe,Wt]),$n=(0,i.I4)((e=>{let{attachments:t,sendCompressed:n=me.shouldCompress,sendGrouped:a=me.shouldSendGrouped,isSilent:s,scheduledAt:o}=e;if("connectionStateReady"!==E)return;const{text:i,entities:r}=(0,w.ZP)(Ae());(i||t.length)&&Dn(i,!0)&&qn()&&(pe({text:i,entities:r,scheduledAt:o,isSilent:s,shouldUpdateStickerSetsOrder:!0,attachments:Uo(t,n),shouldGroupMessages:a}),Le.current=(0,v.bp)(),ge({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{En()})))}),[me.shouldCompress,me.shouldSendGrouped,E,Ae,Dn,qn,pe,ge,g,En]),Gn=(0,i.I4)(((e,t,n,a)=>{$n({attachments:Ye,sendCompressed:e,sendGrouped:t,isSilent:n,scheduledAt:a})}),[Ye,$n]),Hn=(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"!==E)return;let n=Ye;if(Ut){const e=await xt();if(e){const{blob:t,duration:a,waveform:s}=e;n=[await Bo(lr,t,{voice:{duration:a,waveform:s}})]}}const{text:a,entities:i}=(0,w.ZP)(Ae());if(n.length)return void $n({attachments:n});if(!a&&!A)return;if(!Dn(a))return;const r=document.querySelector(o.Edp);if(a){if(!qn())return;pe({text:a,entities:i,scheduledAt:t,isSilent:e,shouldUpdateStickerSetsOrder:!0})}A&&Ie({scheduledAt:t,isSilent:e}),Le.current=(0,v.bp)(),ge({chatId:g,localOnly:!0}),s.cj&&r&&r===document.activeElement&&_o(r),requestAnimationFrame((()=>{En()}))}),[E,Ye,Ut,Ae,A,Dn,ge,g,xt,$n,qn,pe,Ie,En]),Vn=(0,i.I4)((()=>{"webApp"===de?.type&&Se({chatId:g,url:de.url,threadId:f})}),[de,Se,g,f]),zn=(0,i.I4)((()=>{wt(),gt()}),[wt,gt]),Wn=(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;Gn(a,s,n,t)}else pe({...e,scheduledAt:t});else Hn(Boolean(n),t)}),[Gn,Hn,Ze,pe]);(0,i.d4)((()=>{H&&ze((e=>{Wn(H,e)}))}),[H,Wn,ze]),(0,i.d4)((()=>{re&&(Be(re),Ee(),requestAnimationFrame((()=>{const e=document.getElementById(o.R2F);(0,Ao.Z)(e,!0)})))}),[re,Ee,Be]),(0,i.d4)((()=>{ce?.length&&(nt(ce),Ee())}),[nt,ce,Ee]);const Xn=(0,i.I4)(((e,t)=>{e.isFree||Z||M?Cn(e,t):An()}),[Cn,M,Z,An]),Yn=(0,i.I4)((e=>{Xn(e,o.nYf)}),[Xn]),Jn=(0,i.I4)(((e,t,a)=>{n||a?(qe(),ze((n=>{$e(),Wn({gif:e,isSilent:t},n),requestAnimationFrame((()=>{En(!0)}))}))):(pe({gif:e,isSilent:t}),requestAnimationFrame((()=>{En(!0)})))}),[n,qe,ze,$e,Wn,En,pe]),Kn=(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?(qe(),ze((n=>{$e(),Wn({sticker:e,isSilent:t},n),requestAnimationFrame((()=>{En(s)}))}))):(pe({sticker:e,isSilent:t,shouldUpdateStickerSetsOrder:o}),requestAnimationFrame((()=>{En(s)})))}),[n,qe,ze,$e,Wn,En,pe]),Qn=(0,i.I4)(((e,t,a)=>{if("connectionStateReady"!==E)return;n||a?ze((n=>{Wn({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&&_o(i),ge({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{En()}))}),[g,ge,E,Wn,ze,En,Ze,n]),ta=(0,i.I4)((()=>{ge({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{En()}))}),[g,ge,En]),na=(0,i.I4)((e=>{n?(ze((t=>{Wn({poll:e},t)})),we()):(pe({poll:e}),we())}),[we,Wn,ze,pe,n]),aa=(0,i.I4)((e=>{if(n)ze((t=>{Wn({...e,isSilent:!0},t)}));else if(e&&("sendCompressed"in e||"sendGrouped"in e)){const{sendCompressed:t=!1,sendGrouped:n=!1}=e;Gn(t,n,!0)}else Hn(!0)}),[Wn,Hn,Gn,ze,n]),sa=(0,i.I4)((()=>{const e=document.querySelector(o.Edp);if(!m||e!==document.activeElement)return ft(),wt(),void yt();e?.blur(),setTimeout((()=>{ft(),wt(),yt()}),100)}),[ft,wt,yt,m]),oa=(0,i.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.R2F;const n=(0,xn.Z)(e,["escape_html","emoji_html","br_html"]).join("").replace(/\u200b+/g,"");Pn(n,t)}),[Pn]),ia=(0,i.I4)((e=>{oa(e,o.nYf)}),[oa]),ra=(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,Oo.R)(n,e))return void document.execCommand("delete",!1)}Be(jo(Ae()))}),[Ae,Be]),ca=(0,i.I4)((()=>{ra(o.nYf)}),[ra]),da=(0,i.I4)((()=>{ye({id:g,threadId:f,type:"scheduled",noForumTopicPanel:!0})}),[ye,g,f]);(0,i.d4)((()=>{T&&m&&wt()}),[T,wt,m]),(0,i.d4)((()=>{d&&(N?Tt():setTimeout((()=>{Nt()}),200))}),[N,Nt,Tt,d]);const la=!(Bn!==cr.Record||Gt&&C),ua=(0,i.I4)((()=>{switch(Bn){case cr.Send:Hn();break;case cr.Record:la?C||Re({message:ke("VoiceMessagesRestrictedByPrivacy",y?.title)}):At();break;case cr.Edit:Mn();break;case cr.Schedule:Ut&&Bt(),ze((e=>{Wn({},e)}))}}),[Bn,Hn,Mn,Ut,ze,la,C,Re,ke,y?.title,At,Bt,Wn]),ma=(0,Sn.Z)(p,!0),ha=p||ma,ga=new Date;ga.setSeconds(0),ga.setMilliseconds(0);const fa=new Date;fa.setFullYear(fa.getFullYear()+1);let Ia="SendMessage";switch(Bn){case cr.Edit:Ia="Save edited message";break;case cr.Record:Ia=Gt?"AccDescrVoiceMessage":"Conversation.DefaultRestrictedMedia"}const va=(0,et.Z)("Composer",!N&&"shown",kt&&"hover-disabled"),wa=(0,i.I4)((()=>{ze((e=>{Wn({},e)}))}),[Wn,ze]),ba=(0,i.I4)((()=>{aa()}),[aa]),ya=(0,i.I4)(((e,t)=>{ze((n=>{Wn({sendCompressed:e,sendGrouped:t},n)}))}),[Wn,ze]),Pa=(0,i.I4)(((e,t)=>{aa({sendCompressed:e,sendGrouped:t})}),[aa]),Za=Bn===cr.Edit?Mn:Bn===cr.Schedule?wa:Hn,Ca=S&&"webApp"===de?.type&&!p,Ea=(0,Vo.Z)((()=>Ca&&!Ae()&&!Ut),[Ca,Ae,Ut]),Sa=S&&"commands"===de?.type&&!p&&!1!==Q&&!Ut;return i.ZP.createElement("div",{className:va},Gt&&d&&i.ZP.createElement(ar,{isOpen:t!==yn.t.None,withQuick:t===yn.t.QuickFile||je===yn.t.QuickFile,onHide:h,onFileSelect:nt}),i.ZP.createElement(er,{chatId:g,threadId:f,canShowCustomSendMenu:Un,attachments:Ye,getHtml:Ae,isReady:d,shouldSuggestCompression:Qe,isForCurrentMessageList:P,onCaptionUpdate:rt,onSendSilent:Pa,onSend:Gn,onSendScheduled:ya,onFileAppend:tt,onClear:ct,onAttachmentsUpdate:dt,onCustomEmojiSelect:Yn,onRemoveSymbol:ca,onEmojiSelect:ia}),i.ZP.createElement(nr,{isOpen:x.isOpen,isQuiz:x.isQuiz,shouldBeAnonymous:R,onClear:we,onSend:na}),ha&&i.ZP.createElement(Ni,{isOpen:Et,isSchedule:"scheduled"===I,onClose:Rt,message:ha}),i.ZP.createElement(ir,{isOpen:bt,onClose:Zt,chatId:g,selectedSendAsId:se,sendAsPeerIds:Fe,isCurrentUserPremium:Z}),i.ZP.createElement(qi,{isOpen:on,filteredUsers:dn,onInsertUserName:cn,onClose:rn}),i.ZP.createElement(zi,{isOpen:vn,withUsername:Boolean(ee),botCommands:bn,onClick:ta,onClose:wn}),i.ZP.createElement("div",{id:"message-compose"},i.ZP.createElement("div",{className:"svg-appendix",ref:Te}),i.ZP.createElement(Di,{isOpen:ln,botId:un,isGallery:mn,inlineBotResults:pn,switchPm:hn,loadMore:In,isSavedMessages:M,canSendGifs:$t,isCurrentUserPremium:Z,onSelectResult:Qn,onClose:gn}),i.ZP.createElement(Qi,{onClear:_n,shouldForceShowEditing:Boolean(kn&&p)}),i.ZP.createElement(or,{chatId:g,threadId:f,getHtml:Ae,isDisabled:!Vt||Ke}),i.ZP.createElement("div",{className:"message-input-wrapper"},Ca&&i.ZP.createElement(rr,{isOpen:Ea,text:de.text,isDisabled:Boolean(Ut),onClick:Vn}),Sa&&i.ZP.createElement(Ai.Z,{className:(0,et.Z)("bot-commands",ht&&"activated"),round:!0,disabled:void 0===Q,color:"translucent",onActivate:zn,ariaLabel:"Open bot command keyboard"},i.ZP.createElement("i",{className:"icon-bot-commands-filled"})),_e&&(te||ne)&&i.ZP.createElement(jt.Z,{round:!0,color:"translucent",onClick:bt?Zt:sa,ariaLabel:ke("SendMessageAsTitle"),className:(0,et.Z)("send-as-button",Xe.current&&"appear-animation")},i.ZP.createElement(_a.Z,{user:te,chat:ne,size:"tiny"})),i.ZP.createElement(dr.Z,{chatId:g,threadId:f,isMobile:m,isReady:d,isSymbolMenuOpen:It,openSymbolMenu:vt,closeSymbolMenu:wt,canSendStickers:Dt,canSendGifs:$t,onGifSelect:Jn,onStickerSelect:Kn,onCustomEmojiSelect:Xn,onRemoveSymbol:ra,onEmojiSelect:oa,closeBotCommandMenu:ft,closeSendAsMenu:Zt,isSymbolMenuForced:De}),i.ZP.createElement(Xi.Z,{ref:Ne,id:"message-input-text",editableInputId:o.R2F,chatId:g,threadId:f,isActive:!Ke,getHtml:Ae,placeholder:Ut&&Oe<=600?"":U||ke("Message"),forcedPlaceholder:fn,canAutoFocus:d&&P&&!Ke,noFocusInterception:Ke,shouldSuppressFocus:m&&It,shouldSuppressTextFormatter:Xt||on||ln,onUpdate:Be,onSend:Za,onSuppressedFocus:wt}),K&&Boolean(un)&&i.ZP.createElement(qt.Z,{color:"gray"}),L&&i.ZP.createElement(jt.Z,{round:!0,faded:!0,className:"scheduled-button",color:"translucent",onClick:da,ariaLabel:"Open scheduled messages"},i.ZP.createElement("i",{className:"icon-schedule"})),Boolean(B)&&!Ut&&!p&&i.ZP.createElement(Ai.Z,{className:lt?"activated":"",round:!0,color:"translucent",onActivate:ut,ariaLabel:"Open bot command keyboard"},i.ZP.createElement("i",{className:"icon-bot-command"})),Ut&&Boolean(Lt)&&i.ZP.createElement("span",{className:"recording-state"},(0,ae.rM)(Lt-Ft.current)),i.ZP.createElement(_i,{chatId:g,threadId:f,isButtonVisible:!Ut&&!p,canAttachMedia:Gt,canAttachPolls:Ht,onFileSelect:nt,onPollCreate:ve,isScheduled:n,attachBots:le,peerType:ue,theme:he}),Boolean(B)&&i.ZP.createElement(Wi,{messageId:B,isOpen:lt,onClose:mt}),Q&&i.ZP.createElement(tr,{isOpen:ht,botCommands:Q,onClose:ft}),i.ZP.createElement(Hi.Z,{chatId:g,isOpen:en,onCustomEmojiSelect:nn,addRecentCustomEmoji:Me,onClose:tn}),i.ZP.createElement(Gi,{chatId:g,threadId:f,isOpen:an,onStickerSelect:Kn,onClose:sn}),i.ZP.createElement(Vi.Z,{isOpen:Xt,emojis:Jt,customEmojis:Kt,addRecentEmoji:Pe,addRecentCustomEmoji:Me,onEmojiSelect:Qt,onCustomEmojiSelect:Qt,onClose:Yt}))),Ut&&i.ZP.createElement(jt.Z,{round:!0,color:"danger",className:"cancel",onClick:xt,ariaLabel:"Cancel voice recording"},i.ZP.createElement("i",{className:"icon-delete"})),i.ZP.createElement(jt.Z,{ref:Ot,round:!0,color:"secondary",className:(0,et.Z)(Bn,!d&&"not-ready",Ut&&"recording"),disabled:la,allowDisabledClick:!0,ariaLabel:ke(Ia),onClick:ua,onContextMenu:Bn===cr.Send&&Un?jn: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"})),Un&&i.ZP.createElement($i.Z,{isOpen:Ln,onSendSilent:M?void 0:ba,onSendSchedule:n?void 0:wa,onClose:On,onCloseAnimationEnd:Fn,isSavedMessages:M}),We)}))),mr=(0,i.X$)((e=>{const{isActive:t}=e,n=(0,ft.Z)(gt.gl.Extra,"MobileSearch",!t,!0);return n?i.ZP.createElement(n,e):void 0})),hr=(0,i.X$)((e=>{const{isActive:t}=e,n=(0,ft.Z)(gt.gl.Extra,"MessageSelectToolbar",!t);return n?i.ZP.createElement(n,e):void 0})),pr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"UnpinAllMessagesModal",!t);return n?i.ZP.createElement(n,e):void 0})),gr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"SeenByModal",!t);return n?i.ZP.createElement(n,e):void 0})),fr=(0,i.X$)((e=>{const{activeEmojiInteraction:t}=e,n=(0,ft.Z)(gt.gl.Extra,"EmojiInteractionAnimation",!t);return n?i.ZP.createElement(n,e):void 0})),Ir=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"ReactorListModal",!t);return n?i.ZP.createElement(n,e):void 0})),vr=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"GiftPremiumModal",!t);return n?i.ZP.createElement(n,e):void 0}));function wr(e){return"file"===e.kind&&e.type&&o.oGt.has(e.type)}const br=(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}=(0,d.jU)(e),b=(0,d.Bt)(e),{chats:{listIds:y},lastSyncTime:P}=e,Z={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,animationLevel:e.settings.byKey.animationLevel,currentTransitionKey:Math.max(0,m.length-1),activeEmojiInteractions:p,lastSyncTime:P};if(!b||!y.active)return Z;const{chatId:C,threadId:E,type:S}=b,M=(0,u.YC)(C),R=(0,d.Z1)(e,C),k=(0,d.IK)(e,C),T=(0,d.KB)(e,C,E),{chatId:N,messageId:A}=v,x=R&&(0,u.Qm)(R,E),B=(0,d.pk)(e,C),U="pinned"===S,L="scheduled"===S,j="thread"===S&&E===r._f,O=Boolean(R&&(0,u.eA)(R)),F=Boolean(R&&j&&(O||(0,u.ZV)(R))&&R.isNotJoined&&!R.joinRequests),_=Boolean(R?.isNotJoined&&R.isJoinToSend),D=Boolean(R?.isNotJoined&&R.isJoinRequest),q=Boolean(k&&(0,d.s4)(e,k.id)),$=!q&&B,G=Boolean(R&&(0,u.Bf)(R)&&!R.fullInfo&&P),H=(0,d.Yy)(e,C,E),V=!!R?.isForum&&E===r._f&&!H&&R.topics?.[o.OxA]?.isClosed;return{...Z,chatId:C,threadId:E,messageListType:S,chat:R,replyingToId:H,isPrivate:M,areChatSettingsLoaded:Boolean(R?.settings),canPost:!U&&(!R||x)&&!B&&!(_&&R?.isNotJoined)&&!V,isPinnedMessageList:U,isScheduledMessageList:L,currentUserBannedRights:R?.currentUserBannedRights,defaultBannedRights:R?.defaultBannedRights,hasPinnedOrAudioPlayer:E!==r._f&&!R?.isForum||Boolean(!U&&T?.length)||Boolean(N&&A),pinnedMessagesCount:T?T.length:0,shouldSkipHistoryAnimations:w,isChannel:O,canSubscribe:F,canStartBot:$,canRestartBot:q,shouldJoinToSend:_,shouldSendJoinRequest:D,shouldLoadFullChat:G}}))((e=>{let{chatId:t,threadId:n,messageListType:r,isMobile:c,chat:d,replyingToId:l,isPrivate:m,isPinnedMessageList:h,canPost:p,currentUserBannedRights:g,defaultBannedRights:f,hasPinnedOrAudioPlayer:I,pinnedMessagesCount:v,customBackground:w,theme:b,backgroundColor:y,patternColor:P,isLeftColumnShown:Z,isRightColumnShown:E,isBackgroundBlurred:S,hasCurrentTextSearch:M,isSelectModeActive:R,isSeenByModalOpen:k,isReactorListModalOpen:T,isGiftPremiumModalOpen:N,animationLevel:A,shouldSkipHistoryAnimations:x,currentTransitionKey:B,isChannel:U,areChatSettingsLoaded:L,canSubscribe:j,canStartBot:O,canRestartBot:F,activeEmojiInteractions:_,shouldJoinToSend:D,shouldSendJoinRequest:q,shouldLoadFullChat:$,lastSyncTime:G}=e;const{openChat:H,openPreviousChat:V,unpinAllMessages:z,loadUser:W,loadChatSettings:X,closeLocalTextSearch:Y,exitMessageSelectMode:J,joinChannel:K,sendBotCommand:Q,restartBot:ee,showNotification:te,loadFullChat:ne}=(0,a.Sv)(),{width:ae}=(0,Cn.Z)(),{isTablet:se}=(0,C.ZP)(),oe=(0,Mt.Z)(),[ie,re]=(0,i.eJ)(yn.t.None),[ce,de]=(0,i.eJ)(),[le,ue]=(0,i.eJ)(),[me,he]=(0,i.eJ)(!1),pe=c&&M,ge=c?450+o.fK3:void 0,fe=I&&(ae<o.l35||E&&ae>o._mX&&ae<o.QU1||ae>=o.ksF&&ae<o.jT7),Ie=(0,En.Z)(t,ge),ve=(0,En.Z)(n,ge),we=(0,En.Z)(r,ge),be=(0,En.Z)(j,ge),ye=(0,En.Z)(O,ge),Pe=(0,En.Z)(F,ge),Ze=(0,En.Z)(p,ge)&&!Pe&&!ye&&!be,Ce=(0,En.Z)(fe,ge),Ee=(0,En.Z)(ce,ge),Se=(0,En.Z)(U,ge),xe=(0,En.Z)(D,ge),Be=(0,En.Z)(q,ge),Ue=(0,Sn.Z)(B),Le=void 0!==Ue&&Ue<B?Ue:void 0,{isReady:je,handleOpenEnd:Oe,handleSlideStop:Fe}=function(e,t,n,a,s){const[o,r]=(0,i.eJ)(!s),c=(0,ut.Z)(),d=void 0!==n&&n!==t;return d&&(e?r(!1):c()),(0,it.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}}(!x&&A!==o.oBh,B,Ue,t,c);(0,i.d4)((()=>t?(0,Pt.Z)((()=>{H({id:void 0})})):void 0),[t,H]),(0,it.Z)((()=>{re(yn.t.None),ue(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&&W({userId:t})}),[t,m,W]),(0,i.d4)((()=>{!L&&G&&X({chatId:t})}),[t,m,L,G,X]),(0,i.d4)((()=>{t&&$&&je&&ne({chatId:t})}),[$,t,je,ne]);const _e=(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(wr);re(n?yn.t.QuickFile:yn.t.Document)}),[]),De=(0,i.I4)((()=>{re(yn.t.None)}),[]),qe=(0,i.I4)((()=>{he(!0)}),[]),$e=(0,i.I4)((()=>{he(!1)}),[]),Ge=(0,i.I4)((()=>{z({chatId:t,threadId:n}),$e(),V()}),[z,t,n,$e,V]),He=(0,i.I4)((()=>{H({id:t})}),[H,t]),Ve=(0,i.I4)((()=>{K({chatId:t}),Be&&te({message:oe(U?"RequestToJoinChannelSentDescription":"RequestToJoinGroupSentDescription")})}),[K,t,Be,te,U,oe]),ze=(0,i.I4)((()=>{Q({command:"/start"})}),[Q]),We=(0,i.I4)((()=>{ee({chatId:t})}),[t,ee]),Xe=((e,t)=>{const[n,a]=(0,i.eJ)(t);return(0,i.d4)((()=>{t&&(t.startsWith("#")?a(t):Pn.fetch(o.foQ,e,Pn.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,Zn.pt)(t).then((()=>{a(`url(${t})`)}))})))}),[t,e]),t?n:void 0})(b,w),Ye=(0,et.Z)(Ce&&"has-header-tools",s.aZ?"mask-image-disabled":"mask-image-enabled"),Je=(0,et.Z)("ON5E8MkEVA1mAlkuIxhG","OWFg9Wf1uioPWDz_IgS8",w&&"Ik9ZZlj3eKtKXRrUZKVk",y&&"avVozLQe3SaWcSkIt6pG",w&&S&&"Tipa66fYcSvl6w0587Xz",E&&"vhOr8s3T_LCKSt2BF7fs"),Ke=(0,et.Z)("messaging-disabled",!R&&"shown"),Qe=(0,u.q8)(oe,g,f),tt=(0,u.mt)(oe,d,n,Boolean(l)),nt=Qe||tt,{composerHiddenScale:at,toolbarHiddenScale:st,composerTranslateX:ot,toolbarTranslateX:rt,unpinHiddenScale:ct,toolbarForUnpinHiddenScale:dt}=(0,i.Ye)((()=>function(e,t){const n=e<=o.l35?Me.Gw:2*Me.Gw,a=function(e){if(e>o._mX){const t=Math.min(Math.max(.25*e,Ne),Te),n=Math.min(.25*e,Te);return Math.min(e-t-n,ke)}if(e>o.ksF){const t=Math.min(Math.max(.4*e,Ne),Te);return Math.min(e-t,ke)}return e>ke?ke:e}(e),s=e<=o.l35?3.375*Me.Gw:4*Me.Gw,i=t?a-n-s:a-n,r=e>o.l35?Math.min(a-n,Re):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/Ae,toolbarForUnpinHiddenScale:Ae/r}}(ae,Ze)),[Ze,ae]),lt=(0,et.Z)("middle-column-footer",!Ze&&"no-composer",Ze&&le&&!R&&"with-notch");(0,tn.Z)({isActive:R,onBack:J}),(0,tn.Z)({isActive:pe,onBack:Y});const mt=Boolean(!h&&!Ze&&!Pe&&!ye&&!be&&nt),ht=Boolean(Pe||be||Be||ye||h),pt=Boolean(mt||R||h);return i.ZP.createElement("div",{id:"MiddleColumn",className:Ye,onTransitionEnd:Oe,style:`\n --composer-hidden-scale: ${at};\n --toolbar-hidden-scale: ${st};\n --unpin-hidden-scale: ${ct};\n --toolbar-unpin-hidden-scale: ${dt};\n --composer-translate-x: ${ot}px;\n --toolbar-translate-x: ${rt}px;\n --pattern-color: ${P};\n --theme-background-color:\n ${y||("dark"===b?o.Itv:o.p3h)};\n `,onClick:se&&Z?He:void 0},i.ZP.createElement("div",{className:Je,style:Xe?`--custom-background: ${Xe}`:void 0}),i.ZP.createElement("div",{id:"middle-column-portals"}),Ie&&ve&&i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("div",{className:"messages-layout",onDragEnter:Ze?_e:void 0},i.ZP.createElement(ca,{chatId:Ie,threadId:ve,messageListType:we,isReady:je,isMobile:c}),i.ZP.createElement(St.Z,{name:x?"none":A===o.zy8?"slide":"fade",activeKey:B,shouldCleanup:!0,cleanupExceptionKey:Le,onStop:Fe},i.ZP.createElement(Ro,{key:`${Ie}-${ve}-${we}`,chatId:Ie,threadId:ve,type:we,canPost:Ze,hasTools:Ce,onFabToggle:de,onNotchToggle:ue,isReady:je,withBottomShift:ht,withDefaultBg:Boolean(!w&&!y)}),i.ZP.createElement("div",{className:lt},Ze&&i.ZP.createElement(ur,{chatId:Ie,threadId:ve,messageListType:we,dropAreaState:ie,onDropHide:De,isReady:je,isMobile:c}),h&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:oe.isRtl?"rtl":void 0},i.ZP.createElement(jt.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:qe},i.ZP.createElement("i",{className:"icon-unpin"}),i.ZP.createElement("span",null,oe("Chat.Pinned.UnpinAll",v,"i")))),mt&&i.ZP.createElement("div",{className:Ke},i.ZP.createElement("div",{className:"messaging-disabled-inner"},i.ZP.createElement("span",null,nt))),c&&(be||xe&&!Be)&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:oe.isRtl?"rtl":void 0},i.ZP.createElement(jt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Ve},oe(Se?"ProfileJoinChannel":"ProfileJoinGroup"))),c&&Be&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:oe.isRtl?"rtl":void 0},i.ZP.createElement(jt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Ve},oe("ChannelJoinRequest"))),c&&ye&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:oe.isRtl?"rtl":void 0},i.ZP.createElement(jt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:ze},oe("BotStart"))),c&&Pe&&i.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:oe.isRtl?"rtl":void 0},i.ZP.createElement(jt.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:We},oe("BotRestart"))),i.ZP.createElement(hr,{messageListType:we,isActive:R,canPost:Ze}),i.ZP.createElement(gr,{isOpen:k}),i.ZP.createElement(Ir,{isOpen:T}))),i.ZP.createElement(No,{isShown:Ee,canPost:Ze,withExtraShift:pt})),c&&i.ZP.createElement(mr,{isActive:Boolean(pe)})),t&&i.ZP.createElement(pr,{isOpen:me,chatId:t,pinnedMessagesCount:v,onClose:$e,onUnpin:Ge}),i.ZP.createElement("div",{teactFastList:!0},_?.map(((e,t)=>i.ZP.createElement(fr,{teactOrderKey:t,key:e.id,activeEmojiInteraction:e})))),i.ZP.createElement(vr,{isOpen:N}))}))),yr=450+o.fK3,Pr=(0,F.Ds)((e=>e()),200,!1);var Zr;!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"}(Zr||(Zr={}));const Cr=(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:E,onClose:S,onScreenSelect:M,messageSearchQuery:R,stickerSearchQuery:k,gifSearchQuery:T,isEditingInvite:N,canViewStatistics:A,currentInviteInfo:x,shouldSkipHistoryAnimations:B,isBot:U,isInsideTopic:L,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,Ct.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&&Pr(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)}),yr)}),[o]);const ue=(0,Mt.Z)(),me=r?w===f.vi.Profile?Zr.Profile:w===f.vi.SharedMedia?Zr.SharedMedia:w===f.vi.MemberList?Zr.MemberList:-1:c?Zr.Search:p?Zr.PollResults:m?Zr.StickerSearch:h?Zr.GifSearch:v?Zr.AddingMembers:d?b===f.u1.Initial?Zr.ManageInitial:b===f.u1.ChatPrivacyType?Zr.ManageChatPrivacyType:b===f.u1.Discussion?Zr.ManageDiscussion:b===f.u1.ChannelSubscribers?Zr.ManageChannelSubscribers:b===f.u1.GroupPermissions?Zr.ManageGroupPermissions:b===f.u1.ChatAdministrators?Zr.ManageChatAdministrators:b===f.u1.GroupRemovedUsers?Zr.ManageGroupRemovedUsers:b===f.u1.ChannelRemovedUsers?Zr.ManageChannelRemovedUsers:b===f.u1.GroupUserPermissionsCreate?Zr.ManageGroupUserPermissionsCreate:b===f.u1.GroupUserPermissions?Zr.ManageGroupUserPermissions:b===f.u1.GroupRecentActions?Zr.ManageGroupRecentActions:b===f.u1.ChatAdminRights?Zr.ManageGroupAdminRights:b===f.u1.ChatNewAdminRights?Zr.ManageGroupNewAdminRights:b===f.u1.GroupMembers?Zr.ManageGroupMembers:b===f.u1.Invites?Zr.ManageInvites:b===f.u1.EditInvite?Zr.ManageEditInvite:b===f.u1.GroupAddAdmins?Zr.ManageGroupAddAdmins:b===f.u1.Reactions?Zr.ManageReactions:b===f.u1.InviteInfo?Zr.ManageInviteInfo:b===f.u1.JoinRequests?Zr.ManageJoinRequests:void 0:l?Zr.Statistics:u?Zr.MessageStatistics:g?Zr.CreateTopic:I?Zr.EditTopic:void 0,he=null!==(t=(0,kn.Z)(me,!0))&&void 0!==t?t:-1,pe=K||me===Zr.SharedMedia||me===Zr.MemberList||me===Zr.AddingMembers||me===Zr.MessageStatistics||d,ge=(0,et.Z)("animated-close-icon",pe&&"state-back",(de||B)&&"no-transition");return i.ZP.createElement("div",{className:"RightHeader"},i.ZP.createElement(jt.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:S,ariaLabel:ue(pe?"Common.Back":"Common.Close")},i.ZP.createElement("div",{className:ge})),i.ZP.createElement(St.Z,{name:de||B?"none":"slide-fade",activeKey:he},function(){if(-1!==he)switch(he){case Zr.PollResults:return i.ZP.createElement("h3",null,ue("PollResults"));case Zr.Search:return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement(Ot.Z,{parentContainerClassName:"RightSearch",value:R,onChange:te}),i.ZP.createElement(jt.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 Zr.AddingMembers:return i.ZP.createElement("h3",null,ue(E?"ChannelAddSubscribers":"GroupAddMembers"));case Zr.ManageInitial:return i.ZP.createElement("h3",null,ue("Edit"));case Zr.ManageChatPrivacyType:return i.ZP.createElement("h3",null,ue(E?"ChannelTypeHeader":"GroupTypeHeader"));case Zr.ManageDiscussion:return i.ZP.createElement("h3",null,ue("Discussion"));case Zr.ManageChatAdministrators:return i.ZP.createElement("h3",null,ue("ChannelAdministrators"));case Zr.ManageGroupRecentActions:return i.ZP.createElement("h3",null,ue("Group.Info.AdminLog"));case Zr.ManageGroupAdminRights:return i.ZP.createElement("h3",null,ue("EditAdminRights"));case Zr.ManageGroupNewAdminRights:return i.ZP.createElement("h3",null,ue("SetAsAdmin"));case Zr.ManageGroupPermissions:return i.ZP.createElement("h3",null,ue("ChannelPermissions"));case Zr.ManageGroupRemovedUsers:return i.ZP.createElement("h3",null,ue("BlockedUsers"));case Zr.ManageChannelRemovedUsers:return i.ZP.createElement("h3",null,ue("ChannelBlockedUsers"));case Zr.ManageGroupUserPermissionsCreate:return i.ZP.createElement("h3",null,ue("ChannelAddException"));case Zr.ManageGroupUserPermissions:return i.ZP.createElement("h3",null,ue("UserRestrictions"));case Zr.ManageInvites:return i.ZP.createElement("h3",null,ue("lng_group_invite_title"));case Zr.ManageEditInvite:return i.ZP.createElement("h3",null,ue(N?"EditLink":"NewLink"));case Zr.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(jt.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(jt.Z,{round:!0,color:"danger",size:"smaller",ariaLabel:ue("Delete"),onClick:Y},i.ZP.createElement("i",{className:"icon-delete"})),i.ZP.createElement(Ln.Z,{isOpen:X,onClose:J,title:ue("DeleteLink"),text:ue("DeleteLinkHelp"),confirmIsDestructive:!0,confirmLabel:ue("Delete"),confirmHandler:ee}))));case Zr.ManageJoinRequests:return i.ZP.createElement("h3",null,ue(E?"SubscribeRequests":"MemberRequests"));case Zr.ManageGroupAddAdmins:return i.ZP.createElement("h3",null,ue("Channel.Management.AddModerator"));case Zr.StickerSearch:return i.ZP.createElement(Ot.Z,{value:k,placeholder:ue("SearchStickersHint"),autoFocusSearch:!0,onChange:ne});case Zr.GifSearch:return i.ZP.createElement(Ot.Z,{value:T,placeholder:ue("SearchGifsTitle"),autoFocusSearch:!0,onChange:se});case Zr.Statistics:return i.ZP.createElement("h3",null,ue(E?"ChannelStats.Title":"GroupStats.Title"));case Zr.MessageStatistics:return i.ZP.createElement("h3",null,ue("Stats.MessageTitle"));case Zr.SharedMedia:return i.ZP.createElement("h3",null,ue("SharedMedia"));case Zr.ManageChannelSubscribers:return i.ZP.createElement("h3",null,ue("ChannelSubscribers"));case Zr.MemberList:case Zr.ManageGroupMembers:return i.ZP.createElement("h3",null,ue("GroupMembers"));case Zr.ManageReactions:return i.ZP.createElement("h3",null,ue("Reactions"));case Zr.CreateTopic:return i.ZP.createElement("h3",null,ue("NewTopic"));case Zr.EditTopic:return i.ZP.createElement("h3",null,ue("EditTopic"));default:return i.ZP.createElement(i.ZP.Fragment,null,i.ZP.createElement("h3",null,ue(L?"AccDescrTopic":E?"Channel.TitleInfo":P?U?"lng_info_bot_title":"lng_info_user_title":"GroupInfo.Title")),i.ZP.createElement("section",{className:"tools"},y&&i.ZP.createElement(jt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ue("AddContact"),onClick:oe},i.ZP.createElement("i",{className:"icon-add-user"})),Z&&!L&&i.ZP.createElement(jt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ue("Edit"),onClick:re},i.ZP.createElement("i",{className:"icon-edit"})),j&&i.ZP.createElement(jt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ue("EditTopic"),onClick:ie},i.ZP.createElement("i",{className:"icon-edit"})),A&&i.ZP.createElement(jt.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:ue("Statistics"),onClick:ce},i.ZP.createElement("i",{className:"icon-stats"}))))}}()))})));var Er=n(91);var Sr=n(27407);function Mr(e,t,n,a){const[s,i]=(0,Sr.Z)(n?t:void 0,a,void 0,o.Vk);return[s,i,!(!s||!a||s[0]===a[0])]}function Rr(e,t,n,a,s,r,c){const d=(0,i.sO)();(0,it.Z)((()=>{d.current=void 0}),[c]),(0,it.Z)((()=>{t===e&&s&&r&&(d.current=(0,u.R5)(s,r,e))}),[s,r,t,e]);const[l,m]=(0,Sr.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 kr=(0,F.P2)((e=>e()),250,!1);let Tr=!1;var Nr=n(21273),Ar=n(31876),xr=n(16568),Br=n(70180),Ur=n(13709),Lr=n(45418),jr=n(47262),Or=n(41151),Fr=n(22275);const _r=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"}];function Dr(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > .Transition__slide--active > .${e}-list > .scroll-item`].join(", ")}const qr=(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:c,resultsByType:l}=(0,d.we)(e)||{},{foundIds:m}=l&&c&&l[c]||{},h=(0,d.gb)(e,n,a||r._f),{byId:p,statusesById:g}=e.users,{byId:f}=e.chats,I=o&&(0,u.Bf)(o),v=o&&(0,u.eA)(o),w=!a&&(I||v&&(0,u.Nl)(o)),b=o?.fullInfo?.members,y=o?.fullInfo?.adminMembersById,P=w&&o&&(o.isForbidden||o.fullInfo&&!o.fullInfo.canViewMembers),Z=w&&o&&((0,u.VE)(o,"inviteUsers")||!(0,u.Mg)(o,"inviteUsers")||o.isCreator),C=w&&o&&((0,u.VE)(o,"banUsers")||o.isCreator),E=(0,d.xs)(e,n);let S,M,R;return(0,u.YC)(n)&&(M=n,R=(0,d.dy)(e,M),S=R&&!R.isSelf&&!(0,u.cS)(R)),{theme:(0,d.Pu)(e),isChannel:v,resolvedUserId:M,messagesById:i,foundIds:m,messageIds:h,mediaSearchType:c,hasCommonChatsTab:S,hasMembersTab:w,areMembersHidden:P,canAddMembers:Z,canDeleteMembers:C,currentUserId:e.currentUserId,isRightColumnShown:(0,d.Jf)(e,s),isRestricted:o?.isRestricted,lastSyncTime:e.lastSyncTime,activeDownloadIds:E,usersById:p,userStatusesById:g,chatsById:f,isChatProtected:o?.isProtected,...w&&b&&{members:b,adminMembersById:y},...S&&R&&{commonChatIds:R.commonChats?.ids}}}))((e=>{let{chatId:t,topicId:n,profileState:c,onProfileStateChange:d,theme:l,isChannel:m,resolvedUserId:h,currentUserId:p,messagesById:g,foundIds:v,messageIds:w,mediaSearchType:b,hasCommonChatsTab:y,hasMembersTab:P,areMembersHidden:Z,canAddMembers:C,canDeleteMembers:E,commonChatIds:S,members:M,adminMembersById:R,usersById:k,userStatusesById:T,chatsById:N,isRightColumnShown:A,isRestricted:x,lastSyncTime:B,activeDownloadIds:U,isChatProtected:L}=e;const{setLocalMediaSearchType:j,loadMoreMembers:O,loadCommonChats:F,openChat:_,searchMediaMessagesLocal:D,openMediaViewer:q,openAudioPlayer:$,focusMessage:G,loadProfilePhotos:H,setNewChatMembersDialogState:V}=(0,a.Sv)(),z=(0,i.sO)(null),W=(0,i.sO)(null),X=(0,Mt.Z)(),[Y,J]=(0,i.eJ)(0),[K,Q]=(0,i.eJ)(),ee=(0,i.Ye)((()=>[...P?[{type:"members",title:m?"ChannelSubscribers":"GroupMembers"}]:[],..._r,...n?[]:[{type:"voice",title:"SharedVoiceTab2"}],...y?[{type:"commonChats",title:"SharedGroupsTab2"}]:[]]),[y,P,m,n]),te=Y>ee.length-1?ee.length-1:Y,ne=ee[te].type,ae=(0,i.Ye)((()=>w&&g?(0,I.q0)(g,w):{}),[g,w]),[se,oe,ie,re]=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]=Mr(0,e,p,I),[P,Z,C]=Rr("media",f,n,p,m,h,g),[E,S,M]=Rr("documents",f,n,p,m,h,g),[R,k,T]=Rr("links",f,n,p,m,h,g),[N,A,x]=Rr("audio",f,n,p,m,h,g),[B,U,L]=Rr("voice",f,n,p,m,h,g),[j,O,F]=Mr(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":_=E,D=S,q=M;break;case"links":_=R,D=k,q=T;break;case"audio":_=N,D=A,q=x;break;case"voice":_=B,D=U,q=L}return[f,_,D,q]}(O,F,D,ne,b,M,S,k,T,N,ae,v,B,n),ce="members"===se||!P&&"media"===se,de=ee.findIndex((e=>{let{type:t}=e;return t===se})),{handleScroll:le}=function(e,t,n,a){(0,at.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),Tr=!0,(0,ha.Z)(n,s,"start",void 0,void 0,void 0,300),setTimeout((()=>{Tr=!1}),350))}}),[t,a,e]),(0,at.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||(Tr=!0,(0,ha.Z)(o,o.firstElementChild,"start",void 0,2*o.offsetHeight),setTimeout((()=>{Tr=!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)((()=>{Tr||s()}),[s,t]),{handleScroll:(0,i.I4)((()=>{Tr||kr(s)}),[s])}}(z,se,c,d),{applyTransitionFix:ue,releaseTransitionFix:me}=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}}(z),[he,pe]=(()=>{const[e,t]=(0,i.eJ)(!1);return[e,(0,i.I4)((()=>{t((e=>!e))}),[])]})(),{observe:ge}=(0,va.S1)({rootRef:z,throttleMs:500}),fe=(0,i.I4)((()=>{me(),pe()}),[me,pe]),Ie=(0,i.I4)((()=>{V({newChatMembersProgress:f.WB.InProgress})}),[V]);(0,i.d4)((()=>{j({mediaType:ne})}),[j,ne,n]);const ve=h||t;(0,i.d4)((()=>{B&&H({profileId:ve})}),[H,ve,B]);const we=(0,i.I4)((e=>{q({chatId:ve,threadId:r._f,mediaId:e,origin:f.bZ.SharedMedia})}),[ve,q]),be=(0,i.I4)((e=>{$({chatId:ve,messageId:e})}),[ve,$]),ye=(0,i.I4)((e=>{_({id:e})}),[_]),Pe=(0,i.I4)((e=>{G({chatId:ve,messageId:e})}),[ve,G]),Ze=(0,i.I4)((()=>{Q(void 0)}),[]);let Ce;(0,at.Z)((e=>{let[t]=e;if(0===Y||t===P)return;const n=Y+(P?1:-1);J(Math.min(n,ee.length-1))}),[P,Y,ee]),(0,i.d4)((()=>{if(W.current&&s.$b)return(0,en.sf)(W.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===en.eM.Left?(J(Math.min(te+1,ee.length-1)),!0):t===en.eM.Right&&(J(Math.max(0,te-1)),!0)})}),[te,ee.length]),ce?Ce=A?0:1e3:oe||(Ce=o.Yan);const Ee=(0,Yi.Z)([t,n,se,te],Ce);return i.ZP.createElement(Nr.Z,{ref:z,className:"Profile custom-scroll",itemSelector:Dr(se),items:Ee?oe:void 0,cacheBuster:he,sensitiveArea:o.qUX,preloadBackwards:Ee?"members"===se?o.Vk:o.ENB:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:ie,onScroll:le},!re&&function(e,t,n){return i.ZP.createElement("div",{className:"profile-info"},i.ZP.createElement(xr.Z,{userId:t||e,canPlayVideo:n}),i.ZP.createElement(Br.Z,{chatOrUserId:t||e}))}(t,h,A&&Ee),!x&&i.ZP.createElement("div",{className:"shared-media"},i.ZP.createElement(St.Z,{ref:W,name:X.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:de,renderCount:ee.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:ue,onStop:fe},function(){if(!oe||!Ee||!ae){const e=ce&&!Ee,t=Boolean("members"===se&&Z);return i.ZP.createElement("div",{className:"content empty-list"},!e&&!t&&i.ZP.createElement(qt.Z,null),t&&i.ZP.createElement(jr.Z,{text:"You have no access to group members list."}))}if(!oe.length){let e;switch(se){case"members":e=Z?"You have no access to group members list.":"No members found";break;case"commonChats":e=X("NoGroupsInCommon");break;case"documents":e=X("lng_media_file_empty");break;case"links":e=X("lng_media_link_empty");break;case"audio":e=X("lng_media_song_empty");break;case"voice":e=X("lng_media_audio_empty");break;default:e=X("SharedMedia.EmptyTitle")}return i.ZP.createElement("div",{className:"content empty-list"},i.ZP.createElement(jr.Z,{text:e}))}return i.ZP.createElement("div",{className:`content ${se}-list`,dir:X.isRtl&&"media"===se?"rtl":void 0,teactFastList:!0},"media"===se?oe.map((e=>ae[e]&&i.ZP.createElement(Ur.Z,{key:e,message:ae[e],isProtected:L||ae[e].isProtected,observeIntersection:ge,onClick:we}))):"documents"===se?oe.map((e=>ae[e]&&i.ZP.createElement(Wa.Z,{key:e,message:ae[e],withDate:!0,smaller:!0,className:"scroll-item",isDownloading:U.includes(e),observeIntersection:ge,onDateClick:Pe}))):"links"===se?oe.map((e=>ae[e]&&i.ZP.createElement(Lr.Z,{key:e,message:ae[e],isProtected:L||ae[e].isProtected,observeIntersection:ge,onMessageClick:Pe}))):"audio"===se?oe.map((e=>ae[e]&&i.ZP.createElement(Xa.ZP,{key:e,theme:l,message:ae[e],origin:f.Cr.SharedMedia,date:ae[e].date,lastSyncTime:B,className:"scroll-item",onPlay:be,onDateClick:Pe,canDownload:!L&&!ae[e].isProtected,isDownloading:U.includes(e)}))):"voice"===se?oe.map((e=>ae[e]&&i.ZP.createElement(Xa.ZP,{key:e,theme:l,message:ae[e],senderTitle:(0,Er.F)(X,ae[e],N,k),origin:f.Cr.SharedMedia,date:ae[e].date,lastSyncTime:B,className:"scroll-item",onPlay:be,onDateClick:Pe,canDownload:!L&&!ae[e].isProtected,isDownloading:U.includes(e)}))):"members"===se?oe.map(((e,t)=>{return i.ZP.createElement(Ar.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>ye(e),contextActions:(n=e,n!==p&&E?[{title:X("lng_context_remove_from_group"),icon:"stop",handler:()=>{Q(n)}}]:void 0)},i.ZP.createElement(Tn.Z,{userId:e,adminMember:R?.[e],forceShowSelf:!0}));var n})):"commonChats"===se?oe.map(((e,t)=>i.ZP.createElement(Ar.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>_({id:e})},i.ZP.createElement(Nn.Z,{chatId:e})))):void 0)}()),i.ZP.createElement(nn.Z,{big:!0,activeTab:te,tabs:ee,onSwitchTab:J})),C&&i.ZP.createElement(Or.Z,{isShown:"members"===se,onClick:Ie,ariaLabel:X("lng_channel_add_users")},i.ZP.createElement("i",{className:"icon-add-user-filled"})),E&&i.ZP.createElement(Fr.Z,{isOpen:Boolean(K),userId:K,onClose:Ze}))}))),$r=(0,i.X$)((e=>{const t=(0,ft.Z)(gt.gl.Extra,"RightSearch");return t?i.ZP.createElement(t,e):i.ZP.createElement(on.Z,null)})),Gr=(0,i.X$)((e=>{const t=(0,ft.Z)(gt.gl.Extra,"Management");return t?i.ZP.createElement(t,e):i.ZP.createElement(on.Z,null)})),Hr=e=>{const t=(0,ft.Z)(gt.gl.Extra,"Statistics");return t?i.ZP.createElement(t,e):i.ZP.createElement(on.Z,null)},Vr=e=>{const t=(0,ft.Z)(gt.gl.Extra,"MessageStatistics");return t?i.ZP.createElement(t,e):i.ZP.createElement(on.Z,null)},zr=(0,i.X$)((()=>{const e=(0,ft.Z)(gt.gl.Extra,"StickerSearch");return e?i.ZP.createElement(e,null):i.ZP.createElement(on.Z,null)})),Wr=(0,i.X$)((()=>{const e=(0,ft.Z)(gt.gl.Extra,"GifSearch");return e?i.ZP.createElement(e,null):i.ZP.createElement(on.Z,null)})),Xr=(0,i.X$)((()=>{const e=(0,ft.Z)(gt.gl.Extra,"PollResults");return e?i.ZP.createElement(e,null):i.ZP.createElement(on.Z,null)}));var Yr=n(11820);const Jr=(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,Mt.Z)(),[b,y]=(0,i.eJ)([]),P=(0,Sn.Z)(b)===b;(0,tn.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]),E=(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]),S=(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(Yr.Z,{itemIds:E,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(Or.Z,{isShown:Boolean(b.length),disabled:d,ariaLabel:w("lng_channel_add_users"),onClick:S},d?i.ZP.createElement(qt.Z,{color:"white"}):i.ZP.createElement("i",{className:"icon-arrow-right"}))))}))),Kr=(0,i.X$)((e=>{const t=(0,ft.Z)(gt.gl.Extra,"CreateTopic");return t?i.ZP.createElement(t,e):i.ZP.createElement(on.Z,null)})),Qr=(0,i.X$)((e=>{const t=(0,ft.Z)(gt.gl.Extra,"EditTopic");return t?i.ZP.createElement(t,e):i.ZP.createElement(on.Z,null)})),ec=450+o.fK3,tc=Object.keys(f.qt).length/2,nc=Object.keys(f.u1).length/2;function ac(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const sc=(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:E,requestNextManagementScreen:S,closeCreateTopicPanel:M,closeEditTopicPanel:R}=(0,a.Sv)(),{width:k}=(0,Cn.Z)(),[T,N]=(0,i.eJ)(f.vi.Profile),[A,x]=(0,i.eJ)(f.u1.Initial),[B,U]=(0,i.eJ)(),[L,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,kn.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){N(f.vi.Profile);break}h({force:!1},{forceSyncOnIOs:!0});break;case f.qt.Management:switch(A){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),U(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),E({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:ac(),g();break;case f.qt.StickerSearch:ac(),I({query:void 0});break;case f.qt.GifSearch:ac(),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,A,p,g,I,v,P,s,E,Z,C,M,R]),ne=(0,i.I4)(((e,t)=>{U(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(Jr,{key:s,chatId:s,isActive:F&&e,onNextStep:ae,onClose:te});case f.qt.ChatInfo:return i.ZP.createElement(qr,{key:s,chatId:s,topicId:d?r:void 0,profileState:T,isMobile:c,onProfileStateChange:N});case f.qt.Search:return i.ZP.createElement($r,{chatId:s,threadId:r,onClose:te,isActive:F&&e});case f.qt.Management:return i.ZP.createElement(Gr,{key:s,chatId:s,currentScreen:A,isPromotedByCurrentUser:L,selectedChatMemberId:B,isActive:F&&e,onScreenSelect:x,onChatMemberSelect:ne,onClose:te});case f.qt.Statistics:return i.ZP.createElement(Hr,{chatId:s});case f.qt.MessageStatistics:return i.ZP.createElement(Vr,{chatId:s,isActive:F&&e});case f.qt.StickerSearch:return i.ZP.createElement(zr,{onClose:te,isActive:F&&e});case f.qt.GifSearch:return i.ZP.createElement(Wr,{onClose:te,isActive:F&&e});case f.qt.PollResults:return i.ZP.createElement(Xr,{onClose:te,isActive:F&&e});case f.qt.CreateTopic:return i.ZP.createElement(Kr,{onClose:te,isActive:F&&e});case f.qt.EditTopic:return i.ZP.createElement(Qr,{onClose:te,isActive:F&&e})}}return(0,i.d4)((()=>F?(0,Pt.Z)(te):void 0),[F,te]),(0,i.d4)((()=>{setTimeout((()=>{Q(!F)}),ec)}),[F]),(0,i.d4)((()=>{m&&(x(m),S(void 0))}),[m,S]),(0,i.d4)((()=>{F&&J&&te()}),[J]),fa((e=>{let[t]=e;t!==s&&(N(f.vi.Profile),x(f.u1.Initial))}),[s]),(0,tn.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(Cr,{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:A,onClose:te,onScreenSelect:x}),i.ZP.createElement(St.Z,{name:K||u?"none":"zoom-fade",renderCount:tc+nc,activeKey:q?tc+A:ee,shouldCleanup:!0,cleanupExceptionKey:ee===f.qt.MessageStatistics?f.qt.Statistics:void 0},se)))}))),oc=(0,i.X$)((e=>{let{isOpen:t}=e;const n=(0,ft.Z)(gt.gl.Extra,"MediaViewer",!t);return n?i.ZP.createElement(n,null):void 0}));let ic=[],rc=!1;function cc(e,t){ic.push({url:e,filename:t}),rc||(rc=!0,setTimeout((async()=>{await async function(){let e=0;for(const t of ic)dc(t),e++,10===e&&(await(0,F.wO)(1e3),e=0);ic=[]}(),rc=!1}),1e3))}function dc(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 lc=new Set,uc=new Set,mc=(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,pa.Z)(1e3,!0),l=(0,i.I4)((e=>{uc.add(e),d((()=>{uc.size&&(o({messages:Array.from(uc)}),uc.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(lc.has(e))return;lc.add(e);const t=(0,u.Ti)(e,"download");if(!t)return void l(e);const n=Se.UV(t);if(n)return cc(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");Se.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&&cc(t,(0,u.w6)(e));l(e)}))})):lc.clear()}),[n,t,o,l,c])})));var hc=n(13103);const pc=(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,R.Sv)(),r=(0,Mt.Z)(),{url:c,chatId:d,messageId:l}=t||{},u=Boolean(c),m=(0,Xo.Z)(d);(0,pt.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(hc.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"}))}))),gc=(0,i.X$)((e=>{let{isOpen:t}=e;const n=(0,ft.Z)(gt.gl.Extra,"Notifications",!t);return n?i.ZP.createElement(n,null):void 0})),fc=(0,i.X$)((e=>{let{isOpen:t}=e;const n=(0,ft.Z)(gt.gl.Extra,"Dialogs",!t);return n?i.ZP.createElement(n,null):void 0})),Ic=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"ForwardRecipientPicker",!t);return n?i.ZP.createElement(n,e):void 0})),vc=(0,i.X$)((e=>{const{url:t}=e,n=(0,ft.Z)(gt.gl.Extra,"SafeLinkModal",!t);return n?i.ZP.createElement(n,e):void 0})),wc=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"HistoryCalendar",!t);return n?i.ZP.createElement(n,e):void 0})),bc=(0,i.X$)((e=>{const{groupCallId:t}=e,n=(0,ft.Z)(gt.gl.Calls,"GroupCall",!t);return n?i.ZP.createElement(n,e):void 0})),yc=(0,i.X$)((e=>{const{isActive:t}=e,n=(0,ft.Z)(gt.gl.Calls,"ActiveCallHeader",!t);return n?i.ZP.createElement(n,null):void 0})),Pc=(0,i.X$)((e=>{const{isActive:t}=e,n=(0,ft.Z)(gt.gl.Calls,"PhoneCall",!t);return n?i.ZP.createElement(n,null):void 0}));function Zc(){return Zc=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},Zc.apply(this,arguments)}const Cc=(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,tn.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,Zc({key:`${e.chatId}_${e.threadId}_${e.type}_${t}`},e)))))}))),Ec=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"NewContactModal",!t);return n?i.ZP.createElement(n,e):void 0})),Sc=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Calls,"RatePhoneCallModal",!t);return n?i.ZP.createElement(n,e):void 0})),Mc=(0,i.X$)((e=>{const{webApp:t}=e,n=(0,ft.Z)(gt.gl.Extra,"WebAppModal",!t);return n?i.ZP.createElement(n,e):void 0})),Rc=(0,i.X$)((e=>{const{bot:t}=e,n=(0,ft.Z)(gt.gl.Extra,"BotTrustModal",!t);return n?i.ZP.createElement(n,e):void 0})),kc=(0,i.X$)((e=>{const{bot:t}=e,n=(0,ft.Z)(gt.gl.Extra,"AttachBotInstallModal",!t);return n?i.ZP.createElement(n,e):void 0})),Tc={root:"vfd0Bo1X6k19aaxQ577t"},Nc=["#E8BC2C","#D0049E","#02CBFE","#5723FD","#FE8C27","#6CB859"],Ac=(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,Cn.Z)(),r=(0,ut.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=Nc[Math.floor(Math.random()*Nc.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,it.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,ns.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:Tc.root,style:I},i.ZP.createElement("canvas",{ref:n,className:Tc.canvas,width:o.width,height:o.height}))}))),xc=(0,i.X$)((e=>{const{urlAuth:t}=e,n=(0,ft.Z)(gt.gl.Extra,"UrlAuthModal",!t);return n?i.ZP.createElement(n,e):void 0})),Bc=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"PremiumMainModal",!t);return n?i.ZP.createElement(n,e):void 0})),Uc=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"PaymentModal",!t);return n?i.ZP.createElement(n,e):void 0})),Lc=(0,i.X$)((e=>{const{isOpen:t}=e,n=(0,ft.Z)(gt.gl.Extra,"ReceiptModal",!t);return n?i.ZP.createElement(n,e):void 0})),jc=(0,i.X$)((e=>{const{limit:t}=e,n=(0,ft.Z)(gt.gl.Extra,"PremiumLimitReachedModal",!t);return n?i.ZP.createElement(n,e):void 0})),Oc=(0,i.X$)((e=>{const{deleteFolderDialogId:t}=e,n=(0,ft.Z)(gt.gl.Extra,"DeleteFolderDialog",!t);return n?i.ZP.createElement(n,e):void 0})),Fc=(0,i.X$)((e=>{const{customEmojiSetIds:t}=e,n=(0,ft.Z)(gt.gl.Extra,"CustomEmojiSetsModal",!t);return n?i.ZP.createElement(n,e):void 0})),_c=(0,i.X$)((e=>{const{requestedDraft:t}=e,n=(0,ft.Z)(gt.gl.Extra,"DraftRecipientPicker",!t);return n?i.ZP.createElement(n,e):void 0})),Dc=(0,i.X$)((e=>{const{requestedAttachBotInChat:t}=e,n=(0,ft.Z)(gt.gl.Extra,"AttachBotRecipientPicker",!t);return n?i.ZP.createElement(n,e):void 0}));let qc=!1;const $c=(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:E,premiumModal:S,isMasterTab:M,payment:R,limitReachedModal:k,deleteFolderDialogModal:T}=(0,d.jU)(e),{chatId:N,messageId:A}=w,x=N&&A?(0,d.hj)(e,N,A):void 0,B=(v&&(0,d.hj)(e,v.chatId,v.messageId))?.content.game?.title,U=e.currentUserId?(0,d.dy)(e,e.currentUserId):void 0,{chatId:L}=(0,d.Bt)(e)||{};return{lastSyncTime:i,isLeftColumnOpen:b,isMiddleColumnOpen:Boolean(L),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(E),botTrustRequest:r,botTrustRequestBot:r&&(0,d.dy)(e,r.botId),attachBotToInstall:c?.bot,requestedAttachBotInChat:l,webApp:h,currentUser:U,urlAuth:m,isCurrentUserPremium:(0,d.wV)(e),isPremiumModalOpen:S?.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:E,language:S,wasTimeFormatSetManually:M,addedSetIds:R,addedCustomEmojiIds:k,isPhoneCallActive:T,newContactUserId:N,newContactByPhoneNumber:x,openedGame:B,gameTitle:U,isRatePhoneCallModalOpen:L,botTrustRequest:j,botTrustRequestBot:O,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:Ee,openChat:Se,toggleLeftColumn:Me,loadRecentEmojiStatuses:Re,updatePageTitle:ke}=(0,a.Sv)();o.eMD&&!qc&&(qc=!0,console.log(">>> RENDER MAIN"));const{isDesktop:Te}=(0,C.ZP)();(0,i.d4)((()=>{r||c||Te?r&&c&&n&&Me():Me()}),[Te,r,c,n,Me]),(0,pt.Z)(Ee,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(),Ee(),X&&Re())}),[t,K,se,ee,Q,ae,te,ie,ve,we,be,ce,Ee,Ie,Pe,de,me,Re,X,J]),(0,i.d4)((()=>{t&&J&&(S!==o.pRL&&se({language:S}),oe({langCode:S}))}),[S,t,oe,se,J]),(0,at.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,nt.ou)(decodeURIComponent(e.tgaddr))}),[t]),(0,at.Z)((e=>{let[n]=e;const a=(0,g.VX)();a&&!n&&t&&Se({id:a.chatId,threadId:a.threadId,type:a.type})}),[t,Se]);const Ne=(0,mt.Z)(r,void 0,!0,void 0,w),Ae=(0,i.sO)(!1),xe=(0,ut.Z)();(0,it.Z)((e=>{let[t]=e;if(void 0===t||r===t||0===E)return;Ae.current=!0,s.wZ&&(0,F.T2)((()=>{document.body.classList.toggle("android-left-blackout-open",!r)}));const n=(0,ht.YW)();(0,tt.L)(document.getElementById("MiddleColumn"),(()=>{n(),Ae.current=!1,xe()}))}),[E,xe,r]);const Be=(0,mt.Z)(d,void 0,!0,void 0,w),Ue=(0,i.sO)(!1),[Le,je]=(0,i.eJ)(d);(0,it.Z)((e=>{let[t]=e;if(void 0===t||d===t)return;if(0===E)return void je(d);Ue.current=!0;const n=(0,ht.YW)();(0,tt.L)(document.getElementById("RightColumn"),(()=>{n(),Ue.current=!1,xe(),je(d)}))}),[E,xe,d]);const Oe=(0,et.Z)(Ne.hasShownClass&&"left-column-shown",Ne.hasOpenClass&&"left-column-open",Ae.current&&"left-column-animating",Be.hasShownClass&&"right-column-shown",Be.hasOpenClass&&"right-column-open",Ue.current&&"right-column-animating",Le&&"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,st.Z)(Fe,_e),ot(Fe),function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,i.d4)((()=>{if(s.$b){if(!e)return rt?.setAttribute("content",ct),s.cj&&!s.fl&&document.addEventListener("gesturestart",lt),()=>{rt?.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),s.cj&&!s.fl&&document.removeEventListener("gesturestart",lt)};rt?.setAttribute("content",dt)}}),[e])}(l),i.ZP.createElement("div",{id:"Main",className:Oe},i.ZP.createElement(bn,null),i.ZP.createElement(br,{isMobile:n}),i.ZP.createElement(sc,{isMobile:n}),i.ZP.createElement(oc,{isOpen:l}),i.ZP.createElement(Ic,{isOpen:u}),i.ZP.createElement(_c,{requestedDraft:q}),i.ZP.createElement(gc,{isOpen:m}),i.ZP.createElement(fc,{isOpen:h}),p&&i.ZP.createElement(sa,{key:p.id,message:p,noUi:!0}),i.ZP.createElement(vc,{url:I}),i.ZP.createElement(xc,{urlAuth:H,currentUser:G}),i.ZP.createElement(wc,{isOpen:v}),i.ZP.createElement(It,{isOpen:Boolean(y),onClose:De,stickerSetShortName:y}),i.ZP.createElement(Fc,{customEmojiSetIds:P,onClose:qe}),f&&i.ZP.createElement(bc,{groupCallId:f}),i.ZP.createElement(yc,{isActive:Boolean(f||T)}),i.ZP.createElement(Ec,{isOpen:Boolean(N||x),userId:N,isByPhoneNumber:x}),i.ZP.createElement(pc,{openedGame:B,gameTitle:U}),i.ZP.createElement(Mc,{webApp:$}),i.ZP.createElement(mc,null),i.ZP.createElement(Ac,null),i.ZP.createElement(Pc,{isActive:T}),i.ZP.createElement(yt,{isForAppBadge:!0}),i.ZP.createElement(Sc,{isOpen:L}),i.ZP.createElement(Rc,{bot:O,type:j?.type}),i.ZP.createElement(kc,{bot:_}),i.ZP.createElement(Dc,{requestedAttachBotInChat:D}),i.ZP.createElement(Cc,null),V&&i.ZP.createElement(Bc,{isOpen:V}),i.ZP.createElement(jc,{limit:b}),i.ZP.createElement(Uc,{isOpen:z,onClose:Ze}),i.ZP.createElement(Lc,{isOpen:W,onClose:Ce}),i.ZP.createElement(Oc,{deleteFolderDialogId:Y}))})));var Gc=n(62821),Hc=n(21179),Vc=n(99364),zc=n(8337);var Wc=n(2092);const Xc=(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,Mt.Z)(),[m,h]=(0,i.eJ)(""),[p,g]=(0,i.eJ)(!1),[f,I,v]=(0,Ct.Z)(!1),{shouldRender:w}=(0,mt.Z)(t);(0,Gt.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,j.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(Hc.Z,{tgsUrl:Gc.l.Lock,previewUrl:Wc,size:160,className:"ar9YdQbWJreREHmnZa9m"}),i.ZP.createElement(Vc.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(zc.Z,{onClick:I},"Log out")," ","if you don't remember your passcode."),i.ZP.createElement("p",null,i.ZP.createElement(jt.Z,{color:"translucent",size:"tiny",isText:!0,onClick:I},u("AccountSettings.Logout"))))),i.ZP.createElement(Ln.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:Yc},connectionState:Jc}=(0,a.Rd)();Jc||Yc||s.Eo||(0,a.Sv)().initApi()},68973:(e,t,n)=>{e.exports=n.p+"encoderWorker.min.8ea62f6317fbac7d4558.js"}}]);
|
||
//# sourceMappingURL=5769.194931be072ca5204e1b.js.map
|