telegram-tt/dist/640.b191f48c5df91e546441.js
Alexander Zinchuk f9c9ae08ea [Build]
2022-02-20 13:49:20 +02:00

2 lines
255 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

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

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

"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[640],{5640:(e,t,n)=>{n.r(t),n.d(t,{Main:()=>ci});var a=n(5116),s=n(3716),o=n(4050),i=(n(7895),n(9959)),r=n(9066),c=n(735),l=n(8415);function d(e){const{chatId:t,threadId:n}=(0,r.Bt)(e)||{};return t&&n?(e=(0,i.qr)(e,t,n,!1),e=(0,i.Pb)(e,t,n,void 0)):e}(0,a.Q6)("openLocalTextSearch",(e=>{const{chatId:t,threadId:n}=(0,r.Bt)(e)||{};if(t&&n)return(0,i.qr)(e,t,n,!0)})),(0,a.Q6)("closeLocalTextSearch",d),(0,a.Q6)("setLocalTextSearchQuery",((e,t,n)=>{const{chatId:a,threadId:s}=(0,r.Bt)(e)||{};if(!a||!s)return;const{query:o}=n,d=(0,l.uw)(a,s),{query:u}=e.localTextSearch.byChatThreadKey[d]||{};return o!==u&&(e=(0,i.Pb)(e,a,s,c.D)),(0,i.qr)(e,a,s,!0,o)})),(0,a.Q6)("setLocalMediaSearchType",((e,t,n)=>{const{chatId:a}=(0,r.Bt)(e)||{};if(!a)return;const{mediaType:s}=n;return(0,i.z5)(e,a,s)})),(0,a.Q6)("openChat",((e,t,n)=>{const{id:s,threadId:o=-1,type:c="thread",shouldReplaceHistory:l=!1}=n,u=(0,r.Bt)(e);return u&&u.chatId===s&&u.threadId===o&&u.type===c||(e=(0,i.pf)(e,s,o,"replyStack",[]),e=d(e=(0,i.i9)(e)),e={...e,messages:{...e.messages,contentToBeScheduled:void 0},...s!==e.forwardMessages.toChatId&&{forwardMessages:{}}},(0,a.R3)(e)),(0,i.Wy)(e,s,o,c,l)})),(0,a.Q6)("openPreviousChat",(e=>(0,i.Wy)(e,void 0))),(0,a.Q6)("openChatWithInfo",((e,t,n)=>{(0,a.R3)({...e,isChatInfoShown:!0}),t.openChat(n)})),(0,a.Q6)("resetChatCreation",(e=>({...e,chatCreation:void 0}))),(0,a.Q6)("setNewChatMembersDialogState",((e,t,n)=>({...e,newChatMembersProgress:n}))),(0,a.Q6)("openNextChat",((e,t,n)=>{const{targetIndexDelta:a,orderedIds:s}=n,{chatId:o}=(0,r.Bt)(e)||{};if(!o)return void t.openChat({id:s[0]});const i=s.indexOf(o);if(-1===i)return;const c=s[i+a];t.openChat({id:c,shouldReplaceHistory:!0})}));var u=n(6137),m=n(1713),h=n(7361),g=n(782),p=n(2267),f=n(257),v=n(3099);const I=s.ck+s.fK;let y;(0,a.Q6)("setScrollOffset",((e,t,n)=>{const{chatId:a,threadId:s,scrollOffset:o}=n;return(0,i.pf)(e,a,s,"scrollOffset",o)})),(0,a.Q6)("setReplyingToId",((e,t,n)=>{const{messageId:a}=n,s=(0,r.Bt)(e);if(!s)return;const{chatId:o,threadId:c}=s;return(0,i.pf)(e,o,c,"replyingToId",a)})),(0,a.Q6)("setEditingId",((e,t,n)=>{const{messageId:a}=n,s=(0,r.Bt)(e);if(!s)return;const{chatId:o,threadId:c,type:l}=s,d="scheduled"===l?"editingScheduledId":"editingId";return(0,i.pf)(e,o,c,d,a)})),(0,a.Q6)("editLastMessage",(e=>{const{chatId:t,threadId:n}=(0,r.Bt)(e)||{};if(!t||!n)return;const a=(0,r.Zw)(e,t),s=(0,r.Cb)(e,t,n);if(!a||!s)return;const o=(0,g.dF)(s,(t=>Boolean(a[t]&&(0,r._k)(e,a[t],n).canEdit)));return o?(0,i.pf)(e,t,n,"editingId",o):void 0})),(0,a.Q6)("replyToNextMessage",((e,t,n)=>{const{targetIndexDelta:a}=n,{chatId:s,threadId:o}=(0,r.Bt)(e)||{};if(!s||!o)return;const i=(0,r.Zw)(e,s),c=(0,r.Cb)(e,s,o);if(!i||!c)return;const l=(0,r.Yy)(e,s,o);let d;if((0,r.b9)(e,s,o)&&l){const e=Object.keys(i),t=e.indexOf(l.toString())+a;d=t<=e.length+1&&t>=0?Number(e[t]):void 0}else if(o===u._f){var m;const t=(0,r.Z1)(e,s);d=null==t||null===(m=t.lastMessage)||void 0===m?void 0:m.id}else{const t=(0,r.tZ)(e,s,o);d=null==t?void 0:t.lastMessageId}t.setReplyingToId({messageId:d}),t.focusMessage({chatId:s,threadId:o,messageId:d})})),(0,a.Q6)("openMediaViewer",((e,t,n)=>{const{chatId:a,threadId:s,messageId:o,avatarOwnerId:i,profilePhotoIndex:r,origin:c}=n;return{...e,mediaViewer:{chatId:a,threadId:s,messageId:o,avatarOwnerId:i,profilePhotoIndex:r,origin:c},forwardMessages:{}}})),(0,a.Q6)("closeMediaViewer",(e=>({...e,mediaViewer:{}}))),(0,a.Q6)("openAudioPlayer",((e,t,n)=>{const{chatId:a,threadId:s,messageId:o,origin:i,volume:r,playbackRate:c,isMuted:l}=n;return{...e,audioPlayer:{chatId:a,threadId:s,messageId:o,origin:null!=i?i:e.audioPlayer.origin,volume:null!=r?r:e.audioPlayer.volume,playbackRate:c||e.audioPlayer.playbackRate,isMuted:l||e.audioPlayer.isMuted}}})),(0,a.Q6)("setAudioPlayerVolume",((e,t,n)=>{const{volume:a}=n;return{...e,audioPlayer:{...e.audioPlayer,volume:a}}})),(0,a.Q6)("setAudioPlayerPlaybackRate",((e,t,n)=>{const{playbackRate:a}=n;return{...e,audioPlayer:{...e.audioPlayer,playbackRate:a}}})),(0,a.Q6)("setAudioPlayerMuted",((e,t,n)=>{const{isMuted:a}=n;return{...e,audioPlayer:{...e.audioPlayer,isMuted:a}}})),(0,a.Q6)("setAudioPlayerOrigin",((e,t,n)=>{const{origin:a}=n;return{...e,audioPlayer:{...e.audioPlayer,origin:a}}})),(0,a.Q6)("closeAudioPlayer",(e=>({...e,audioPlayer:{volume:e.audioPlayer.volume,playbackRate:e.audioPlayer.playbackRate,isMuted:e.audioPlayer.isMuted}}))),(0,a.Q6)("openPollResults",((e,t,n)=>{const{chatId:s,messageId:o}=n;(0,r.Jf)(e)?s===e.pollResults.chatId&&o===e.pollResults.messageId||(0,a.R3)({...e,pollResults:{chatId:s,messageId:o,voters:{}}}):window.setTimeout((()=>{const e=(0,a.Rd)();(0,a.R3)({...e,pollResults:{chatId:s,messageId:o,voters:{}}})}),450)})),(0,a.Q6)("closePollResults",(e=>{(0,a.R3)({...e,pollResults:{}})})),(0,a.Q6)("focusLastMessage",((e,t)=>{const n=(0,r.Bt)(e);if(!n)return;const{chatId:a,threadId:s}=n;let o;if(s===u._f){var i;const t=(0,r.Z1)(e,a);o=null==t||null===(i=t.lastMessage)||void 0===i?void 0:i.id}else{const t=(0,r.tZ)(e,a,s);o=null==t?void 0:t.lastMessageId}o&&t.focusMessage({chatId:a,threadId:s,messageId:o,noHighlight:!0})})),(0,a.Q6)("focusNextReply",((e,t)=>{const n=(0,r.Bt)(e);if(!n)return;const{chatId:s,threadId:o}=n,c=(0,r.p9)(e,s,o);if(c&&0!==c.length){const n=c.pop();e=(0,i.pf)(e,s,o,"replyStack",[...c]),(0,a.R3)(e),t.focusMessage({chatId:s,threadId:o,messageId:n})}else t.focusLastMessage()})),(0,a.Q6)("focusMessage",((e,t,n)=>{const{chatId:s,threadId:o=u._f,messageListType:c="thread",noHighlight:l,groupedId:d,groupedChatId:h,replyMessageId:g,isResizingContainer:p}=n;let{messageId:f}=n;if(void 0!==d){const t=(0,r.y8)(e,h,d);null!=t&&t.length&&([f]=t)}const v=(0,r.Bt)(e),Z=!v||s!==v.chatId||o!==v.threadId||c!==v.type;if(y&&(clearTimeout(y),y=void 0),y=window.setTimeout((()=>{let e=(0,a.Rd)();e=(0,i.cq)(e),e=(0,i.wV)(e),(0,a.R3)(e)}),l?I:1500),e=(0,i.cq)(e,s,f,l,p),e=(0,i.wV)(e,void 0),g){const t=(0,r.p9)(e,s,o)||[];e=(0,i.pf)(e,s,o,"replyStack",[...t,g])}Z&&(e=(0,i.wV)(e,m.fo.Static));const P=(0,r.Cb)(e,s,o);if(P&&P.includes(f))return(0,a.R3)(e),void t.openChat({id:s,threadId:o});if(Z&&(e=(0,i.pf)(e,s,o,"viewportIds",void 0)),e=(0,i.pf)(e,s,o,"outlyingIds",void 0),P&&!Z){const t=f>P[0]?m.fo.Down:m.fo.Up;e=(0,i.wV)(e,t)}(0,a.R3)(e),t.openChat({id:s,threadId:o}),t.loadViewportMessages()})),(0,a.Q6)("openForwardMenu",((e,t,n)=>{const{fromChatId:a,messageIds:s,groupedId:o}=n;let i;return o&&(i=(0,r.xH)(e,a,o)),{...e,forwardMessages:{fromChatId:a,messageIds:i||s,isModalShown:!0}}})),(0,a.Q6)("exitForwardMode",(e=>{(0,a.R3)({...e,forwardMessages:{}})})),(0,a.Q6)("setForwardChatId",((e,t,n)=>{const{id:s}=n;(0,a.R3)({...e,forwardMessages:{...e.forwardMessages,toChatId:s,isModalShown:!1}}),t.openChat({id:s}),t.closeMediaViewer(),t.exitMessageSelectMode()})),(0,a.Q6)("openForwardMenuForSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:n,messageIds:a}=e.selectedMessages;t.openForwardMenu({fromChatId:n,messageIds:a})})),(0,a.Q6)("cancelMessageMediaDownload",((e,t,n)=>{const{message:s}=n,o=e.activeDownloads.byChatId[s.chatId];o&&o.length&&(0,a.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[s.chatId]:o.filter((e=>e!==s.id))}}})})),(0,a.Q6)("downloadMessageMedia",((e,t,n)=>{const{message:s}=n;s&&(0,a.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[s.chatId]:[...e.activeDownloads.byChatId[s.chatId]||[],s.id]}}})})),(0,a.Q6)("downloadSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:n,messageIds:a}=e.selectedMessages,{threadId:s}=(0,r.Bt)(e)||{},o=(0,r.Zw)(e,n);o&&s&&a.map((e=>o[e])).filter((t=>(0,r._k)(e,t,s).canDownload)).forEach((e=>t.downloadMessageMedia({message:e})))})),(0,a.Q6)("enterMessageSelectMode",((e,t,n)=>{const{messageId:a}=n||{},s=(0,r.jr)(e);return s?(0,i.M6)(e,s.id,a):e})),(0,a.Q6)("toggleMessageSelection",((e,t,n)=>{const{messageId:s,groupedId:o,childMessageIds:c,withShift:l}=n,d=(0,r.Bt)(e);if(!d)return;const{chatId:u,threadId:m,type:g}=d;e=(0,i.Ob)(e,u,m,g,s,o,c,l),(0,a.R3)(e),e.shouldShowContextMenuHint&&(t.disableContextMenuHint(),t.showNotification({message:`To **edit** or **reply**, close this menu. Then ${h.$b?"long tap":"right click"} on a message.`}))})),(0,a.Q6)("disableContextMenuHint",(e=>{if(e.shouldShowContextMenuHint)return{...e,shouldShowContextMenuHint:!1}})),(0,a.Q6)("exitMessageSelectMode",i.i9),(0,a.Q6)("openPollModal",(e=>({...e,isPollModalOpen:!0}))),(0,a.Q6)("closePollModal",(e=>({...e,isPollModalOpen:!1}))),(0,a.Q6)("checkVersionNotification",((e,t)=>{const n=s.Ji.split(".").slice(0,2).join("."),{serviceNotifications:a}=e;if(a.find((e=>{let{version:t}=e;return t===n})))return;const o={chatId:s.aw,date:(0,p.b)(e.serverTimeOffset),content:{text:(0,v.Z)(f)},isOutgoing:!1};t.createServiceNotification({message:o,version:n})})),(0,a.Q6)("createServiceNotification",((e,t,n)=>{var o;const{message:i,version:c}=n,{serviceNotifications:l}=e,d=(0,r.Z1)(e,s.aw),u=Math.max((null===(o=d.lastMessage)||void 0===o?void 0:o.id)||0,...l.map((e=>{let{id:t}=e;return t}))),m=(l.length+1)/1e3,h=Math.floor(u)+m;i.id=h;const g={id:h,message:i,version:c,isUnread:!0};(0,a.R3)({...e,serviceNotifications:[...l.slice(-1e3),g]}),t.apiUpdate({"@type":"newMessage",id:i.id,chatId:i.chatId,message:i})})),(0,a.Q6)("openReactorListModal",((e,t,n)=>{const{chatId:a,messageId:s}=n;return{...e,reactorModal:{chatId:a,messageId:s}}})),(0,a.Q6)("closeReactorListModal",(e=>({...e,reactorModal:void 0}))),(0,a.Q6)("openSeenByModal",((e,t,n)=>{const{chatId:a,messageId:s}=n;return{...e,seenByModal:{chatId:a,messageId:s}}})),(0,a.Q6)("closeSeenByModal",(e=>({...e,seenByModal:void 0}))),(0,a.Q6)("setGlobalSearchQuery",((e,t,n)=>{const{query:a}=n,{chatId:s}=e.globalSearch;return(0,i.No)(e,{globalResults:{},localResults:{},resultsByType:void 0,...a?{fetchingStatus:{chats:!s,messages:!0}}:{fetchingStatus:void 0},query:a})})),(0,a.Q6)("addRecentlyFoundChatId",((e,t,n)=>{const{id:a}=n,{recentlyFoundChatIds:s}=e.globalSearch;if(!s)return(0,i.No)(e,{recentlyFoundChatIds:[a]});const o=s.filter((e=>e!==a));return o.unshift(a),o.length>10&&o.pop(),(0,i.No)(e,{recentlyFoundChatIds:o})})),(0,a.Q6)("clearRecentlyFoundChats",(e=>(0,i.No)(e,{recentlyFoundChatIds:void 0}))),(0,a.Q6)("setGlobalSearchContent",((e,t,n)=>{const{content:a}=n;return(0,i.Og)(e,a)})),(0,a.Q6)("setGlobalSearchChatId",((e,t,n)=>{const{id:a}=n;return(0,i.No)(e,{chatId:a,query:void 0,resultsByType:void 0})})),(0,a.Q6)("setStickerSearchQuery",((e,t,n)=>{const{query:a}=n;return{...e,stickers:{...e.stickers,search:{query:a,resultIds:void 0}}}})),(0,a.Q6)("setGifSearchQuery",((e,t,n)=>{const{query:a}=n;return{...e,gifs:{...e.gifs,search:{query:a,offsetId:void 0,results:void 0}}}})),(0,a.Q6)("setUserSearchQuery",((e,t,n)=>{const{query:a}=n;return(0,i.Lm)(e,{globalUserIds:void 0,localUserIds:void 0,fetchingStatus:Boolean(a),query:a})})),n(3781);var Z=n(1947),P=n(6926);(0,a.Q6)("toggleChatInfo",((e,t,n)=>({...e,isChatInfoShown:void 0!==n?n:!e.isChatInfoShown}))),(0,a.Q6)("setLeftColumnWidth",((e,t,n)=>({...e,leftColumnWidth:n}))),(0,a.Q6)("resetLeftColumnWidth",(e=>({...e,leftColumnWidth:void 0}))),(0,a.Q6)("toggleManagement",(e=>{const{chatId:t}=(0,r.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!(e.management.byChatId[t]||{}).isActive}}}}})),(0,a.Q6)("requestNextManagementScreen",((e,t,n)=>{const{screen:a}=n||{},{chatId:s}=(0,r.Bt)(e)||{};if(s)return{...e,management:{byChatId:{...e.management.byChatId,[s]:{...e.management.byChatId[s],isActive:!0,nextScreen:a}}}}})),(0,a.Q6)("closeManagement",(e=>{const{chatId:t}=(0,r.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!1}}}}})),(0,a.Q6)("openChat",(e=>{if(h.wB||h.p7)return{...e,isLeftColumnShown:0===e.messages.messageLists.length}})),(0,a.Q6)("toggleLeftColumn",(e=>({...e,isLeftColumnShown:!e.isLeftColumnShown}))),(0,a.Q6)("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>18&&o.pop(),{...e,recentEmojis:o}})),(0,a.Q6)("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.Q6)("showNotification",((e,t,n)=>{const a=n;a.localId=(0,P.Z)({});const s=[...e.notifications],o=s.findIndex((e=>e.message===a.message));return-1!==o&&s.splice(o,1),s.push(a),{...e,notifications:s}})),(0,a.Q6)("dismissNotification",((e,t,n)=>{const a=e.notifications.filter((e=>{let{localId:t}=e;return t!==n.localId}));return{...e,notifications:a}})),(0,a.Q6)("showDialog",((e,t,n)=>{const{data:a}=n;if("message"in a&&a.hasErrorKey&&!(0,Z.ZP)(a))return e;const s=[...e.dialogs];if("message"in a){const e=s.findIndex((e=>e.message===a.message));-1!==e&&s.splice(e,1)}return s.push(a),{...e,dialogs:s}})),(0,a.Q6)("dismissDialog",(e=>{const t=[...e.dialogs];return t.pop(),{...e,dialogs:t}})),(0,a.Q6)("toggleSafeLinkModal",((e,t,n)=>{const{url:a}=n;return{...e,safeLinkModalUrl:a}})),(0,a.Q6)("openHistoryCalendar",((e,t,n)=>{const{selectedAt:a}=n;return{...e,historyCalendarSelectedAt:a}})),(0,a.Q6)("closeHistoryCalendar",(e=>({...e,historyCalendarSelectedAt:void 0}))),(0,a.Q6)("openPaymentModal",((e,t,n)=>{const{chatId:a,messageId:s}=n;return{...e,payment:{...e.payment,chatId:a,messageId:s,isPaymentModalOpen:!0}}})),(0,a.Q6)("closePaymentModal",(e=>{const t=(0,i.bp)(e);return(0,i.WY)(t)})),(0,a.Q6)("addPaymentError",((e,t,n)=>{const{error:a}=n;return{...e,payment:{...e.payment,error:a}}})),n(1689),n(1363),n(6204);var C=n(1226),w=n(9118);const b=new Map,E=(0,w.Ds)((e=>e()),500,!1);async function M(e,t,n,o){let c=arguments.length>4&&void 0!==arguments[4]&&arguments[4],l=arguments.length>5&&void 0!==arguments[5]&&arguments[5];const d=e.id;let u;switch(o){case m.Uq.Backwards:u=void 0;break;case m.Uq.Around:u=-(Math.round(s.hT/2)+1);break;case m.Uq.Forwards:u=-(s.hT+1)}const h=await(0,C.t9)("fetchMessages",{chat:(0,r.Cm)((0,a.Rd)(),d,t),offsetId:n,addOffset:u,limit:s.hT,threadId:t});if(!h)return;const{messages:p,users:f,chats:v,threadInfos:I}=h;let y=(0,a.Rd)();const Z=d===s.aw?y.serviceNotifications.map((e=>{let{message:t}=e;return t})):[],P=[].concat(p,Z),w=(0,g.ee)(P,"id"),b=Object.keys(w).map(Number);y=(0,i.c_)(y,d,w),y=c?(0,i.ff)(y,d,t,b):(0,i.xj)(y,d,t,b),y=(0,i.Sh)(y,(0,g.ee)(f,"id")),y=(0,i.fZ)(y,(0,g.ee)(v,"id")),y=(0,i.j6)(y,d,I);let E=(0,r.gb)(y,d,t);const M=(0,r.qC)(y,d,t);if(c&&E&&M&&(M.length&&!(0,g.YE)(E,M)||(y=(0,i.xj)(y,d,t,M),E=(0,r.gb)(y,d,t),y=(0,i.pf)(y,d,t,"outlyingIds",void 0),c=!1)),!l){const e=c?M:E,{newViewportIds:a}=S(e,n,o);y=(0,i.y9)(y,d,t,a)}(0,a.R3)(y)}function S(e,t,n){const{length:a}=e,o=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===m.Uq.Backwards?o:o+1||a,r=i-s.hT,c=i+s.hT-1,l=e.slice(Math.max(0,r),c+1);let d,u;switch(n){case m.Uq.Backwards:d=i>0,u=r>=0;break;case m.Uq.Forwards:d=i<a,u=c<=a-1;break;case m.Uq.Around:default:d=l.length>0,u=l.length===s.hT}return{newViewportIds:l,areSomeLocal:d,areAllLocal:u}}async function R(e){let t;const n=e.attachment?(e,s)=>{b.has(s)||(t=s,b.set(s,n));const o=(0,a.Rd)();(0,a.R3)({...o,fileUploads:{byMessageLocalId:{...o.fileUploads.byMessageLocalId,[s]:{progress:e}}}})}:void 0;(e.replyingTo||h.cj)&&await(0,w.Pn)();const s=(0,a.Rd)();e.serverTimeOffset=s.serverTimeOffset;const o=(0,r.Bt)(s);if(!o)return;const{threadId:i}=o;e.replyingTo||i===u._f||(e.replyingTo=(0,r.qS)(s,e.chat.id,i)),await(0,C.t9)("sendMessage",e,n),n&&t&&b.delete(t)}(0,a.Q6)("loadViewportMessages",((e,t,n)=>{const{direction:a=m.Uq.Around,isBudgetPreload:o=!1}=n||{};let{chatId:c,threadId:l}=n||{};if(!c){const t=(0,r.Bt)(e);if(!t)return;c=t.chatId,l=t.threadId}const d=(0,r.Z1)(e,c);if(!d||d.isRestricted)return;const u=(0,r.Cb)(e,c,l),h=(0,r.gb)(e,c,l),g=(0,r.qC)(e,c,l);if(u&&u.length&&a!==m.Uq.Around){const n=a===m.Uq.Backwards?u[0]:u[u.length-1],s=Boolean(g),r=s?g:h,{newViewportIds:p,areSomeLocal:f,areAllLocal:v}=S(r,n,a);if(f&&(e=(0,i.y9)(e,c,l,p)),async function(e,t,n,a,s,o,i,r){t||await M(s,o,r,i,n,a),a||(await Promise.resolve(),e.loadViewportMessages({chatId:s.id,threadId:o,direction:i,isBudgetPreload:!0}))}(t,v,s,o,d,l,a,n),o)return}else{const t=(0,r.G$)(e,c)||(0,r.rd)(e,c,l),n=Boolean(t&&h&&!h.includes(t)),a=(n?g:h)||[],{newViewportIds:u,areSomeLocal:p,areAllLocal:f}=S(a,t,m.Uq.Around);p&&u.length>=s.hT&&(e=(0,i.y9)(e,c,l,u)),f||M(d,l,t,m.Uq.Around,n,o)}return e})),(0,a.Q6)("loadMessage",((e,t,n)=>{const{chatId:s,messageId:o,replyOriginForId:c,threadUpdate:l}=n,d=(0,r.Z1)(e,s);d&&(async()=>{const e=await async function(e,t,n){const s=await(0,C.t9)("fetchMessage",{chat:e,messageId:t});if(!s)return;if(s===u._Q){if(n){let t=(0,a.Rd)();const s=(0,r.hj)(t,e.id,n);t=(0,i.cY)(t,e.id,n,{...s,replyToMessageId:void 0}),(0,a.R3)(t)}return}let o=(0,a.Rd)();return o=(0,i.cY)(o,e.id,t,s.message),o=(0,i.Sh)(o,(0,g.ee)(s.users,"id")),(0,a.R3)(o),s.message}(d,o,c);if(e&&l){const{lastMessageId:t,isDeleting:n}=l;(0,a.R3)((0,i.lG)((0,a.Rd)(),e,s,t,n))}})()})),(0,a.Q6)("sendMessage",((e,t,n)=>{const a=(0,r.Bt)(e);if(!a)return;const{chatId:o,threadId:i,type:c}=a;if("scheduled"===c&&!n.scheduledAt)return{...e,messages:{...e.messages,contentToBeScheduled:n}};const l=(0,r.Z1)(e,o),d={...n,chat:l,replyingTo:(0,r.Yy)(e,o,i),noWebPage:(0,r.tV)(e,o,i),sendAs:(0,r._5)(e,o)};t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:o,threadId:i,value:!1});const u=!n.attachments||n.attachments.length<=1,m=!u&&n.attachments&&n.attachments.length>1;if(u){const{attachments:e,...t}=d;R({...t,attachment:e?e[0]:void 0})}else if(m){const{text:e,entities:t,attachments:n,...a}=d,o=(0,g.Vl)(n,s.DU);for(let n=0;n<o.length;n++){const[s,...i]=o[n],r=`${Date.now()}${n}`;R({...a,text:0===n?e:void 0,entities:0===n?t:void 0,attachment:s,groupedId:i.length>0?r:void 0}),i.forEach((e=>{R({...a,attachment:e,groupedId:r})}))}}else{const{text:e,entities:t,attachments:n,replyingTo:a,...s}=d;e&&R({...s,text:e,entities:t,replyingTo:a}),n.forEach((e=>{R({...s,attachment:e})}))}})),(0,a.Q6)("editMessage",((e,t,n)=>{const{serverTimeOffset:a}=e,{text:s,entities:o}=n,i=(0,r.Bt)(e);if(!i)return;const{chatId:c,threadId:l,type:d}=i,u=(0,r.Z1)(e,c),m=(0,r.kK)(e,c,l,d);u&&m&&((0,C.t9)("editMessage",{chat:u,message:m,text:s,entities:o,noWebPage:(0,r.tV)(e,c,l),serverTimeOffset:a}),t.setEditingId({messageId:void 0}))})),(0,a.Q6)("cancelSendingMessage",((e,t,n)=>{const{chatId:a,messageId:s}=n,o=(0,r.hj)(e,a,s),i=o&&b.get(o.previousLocalId||o.id);i&&(0,C.u3)(i),t.apiUpdate({"@type":"deleteMessages",ids:[s],chatId:a})})),(0,a.Q6)("saveDraft",((e,t,n)=>{const{chatId:a,threadId:s,draft:o}=n;if(!o)return;const{text:c,entities:l}=o,d=(0,r.Z1)(e,a);return s===u._f&&(0,C.t9)("saveDraft",{chat:d,text:c,entities:l,replyToMsgId:(0,r.Yy)(e,a,s)}),e=(0,i.pf)(e,a,s,"draft",o),(0,i.a4)(e,a,{draftDate:Math.round(Date.now()/1e3)})})),(0,a.Q6)("clearDraft",((e,t,n)=>{const{chatId:a,threadId:s,localOnly:o}=n;if(!(0,r.Ms)(e,a,s))return;const c=(0,r.Z1)(e,a);return o||s!==u._f||(0,C.t9)("clearDraft",c),e=(0,i.pf)(e,a,s,"draft",void 0),(0,i.a4)(e,a,{draftDate:void 0})})),(0,a.Q6)("toggleMessageWebPage",((e,t,n)=>{const{chatId:a,threadId:s,noWebPage:o}=n;return(0,i.pf)(e,a,s,"noWebPage",o)})),(0,a.Q6)("pinMessage",((e,t,n)=>{const a=(0,r.jr)(e);if(!a)return;const{messageId:s,isUnpin:o,isOneSide:i,isSilent:c}=n;(0,C.t9)("pinMessage",{chat:a,messageId:s,isUnpin:o,isOneSide:i,isSilent:c})})),(0,a.Q6)("unpinAllMessages",((e,t,n)=>{const s=(0,r.Z1)(e,n.chatId);s&&async function(e){await(0,C.t9)("unpinAllMessages",{chat:e});let t=(0,a.Rd)();t=(0,i.pf)(t,e.id,u._f,"pinnedIds",[]),(0,a.R3)(t)}(s)})),(0,a.Q6)("deleteMessages",((e,t,n)=>{const{messageIds:a,shouldDeleteForAll:s}=n,o=(0,r.Bt)(e);if(!o)return;const{chatId:i,threadId:c}=o,l=(0,r.Z1)(e,i);(0,C.t9)("deleteMessages",{chat:l,messageIds:a,shouldDeleteForAll:s});const d=(0,r._$)(e,i,c);a.includes(d)&&t.setEditingId({messageId:void 0})})),(0,a.Q6)("deleteScheduledMessages",((e,t,n)=>{const{messageIds:a}=n,s=(0,r.Bt)(e);if(!s)return;const{chatId:o}=s,i=(0,r.Z1)(e,o);(0,C.t9)("deleteScheduledMessages",{chat:i,messageIds:a});const c=(0,r.wU)(e,o);a.includes(c)&&t.setEditingId({messageId:void 0})})),(0,a.Q6)("deleteHistory",((e,t,n)=>{(async()=>{var a;const{chatId:s,shouldDeleteForAll:o}=n,i=(0,r.Z1)(e,s);if(!i)return;const c=null===(a=i.lastMessage)||void 0===a?void 0:a.id;await(0,C.t9)("deleteHistory",{chat:i,shouldDeleteForAll:o,maxId:c});const l=(0,r.Bt)(e);l&&l.chatId===s&&t.openChat({id:void 0})})()})),(0,a.Q6)("reportMessages",((e,t,n)=>{(async()=>{const{messageIds:a,reason:s,description:o}=n,i=(0,r.Bt)(e);if(!i)return;const{chatId:c}=i,l=(0,r.Z1)(e,c),d=await(0,C.t9)("reportMessages",{peer:l,messageIds:a,reason:s,description:o});t.showNotification({message:d?"Thank you! Your report will be reviewed by our team.":"Error occured while submiting report. Please, try again later."})})()})),(0,a.Q6)("sendMessageAction",((e,t,n)=>{(async()=>{const{action:t,chatId:a,threadId:s}=n;if(a===e.currentUserId)return;const o=(0,r.Z1)(e,a);o&&await(0,C.t9)("sendMessageAction",{peer:o,threadId:s,action:t})})()})),(0,a.Q6)("markMessageListRead",((e,t,n)=>{const{serverTimeOffset:a}=e,o=(0,r.Bt)(e);if(!o)return;const{chatId:c,threadId:l}=o,d=(0,r.Cm)(e,c,l);if(!d)return;const{maxId:m}=n;if(E((()=>{(0,C.t9)("markMessageListRead",{serverTimeOffset:a,chat:d,threadId:l,maxId:m})})),l!==u._f)return;c===s.aw&&(e={...e,serviceNotifications:e.serviceNotifications.map((e=>e.isUnread&&e.id<=m?{...e,isUnread:!1}:e))});const h=(0,r.Cb)(e,c,l),g=(0,r.It)(e,c,l);if(!h||!g||!d.unreadCount)return e;const p=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}(h,g,m);return p?(0,i.a4)(e,c,{lastReadInboxMessageId:m,unreadCount:Math.max(0,d.unreadCount-p)}):e})),(0,a.Q6)("markMessagesRead",((e,t,n)=>{const a=(0,r.jr)(e);if(!a)return;const{messageIds:s}=n;(0,C.t9)("markMessagesRead",{chat:a,messageIds:s})})),(0,a.Q6)("loadWebPagePreview",((e,t,n)=>{const{text:s}=n;!async function(e){const t=await(0,C.t9)("fetchWebPagePreview",{message:e});(0,a.R3)({...(0,a.Rd)(),webPagePreview:t})}(s)})),(0,a.Q6)("clearWebPagePreview",(e=>{if(e.webPagePreview)return{...e,webPagePreview:void 0}})),(0,a.Q6)("sendPollVote",((e,t,n)=>{const{chatId:a,messageId:s,options:o}=n,i=(0,r.Z1)(e,a);i&&(0,C.t9)("sendPollVote",{chat:i,messageId:s,options:o})})),(0,a.Q6)("loadPollOptionResults",((e,t,n)=>{const{chat:s,messageId:o,option:r,offset:c,limit:l,shouldResetVoters:d}=n;!async function(e,t,n,s,o,r){const c=await(0,C.t9)("loadPollOptionResults",{chat:e,messageId:t,option:n,offset:s,limit:o});if(!c)return;let l=(0,a.Rd)();l=(0,i.Sh)(l,(0,g.ee)(c.users,"id"));const{voters:d}=l.pollResults;(0,a.R3)({...l,pollResults:{...l.pollResults,voters:{...d,[n]:(0,g.Tw)([...!r&&d&&d[n]?d[n]:[],...c&&c.users.map((e=>e.id))])},offsets:{...l.pollResults.offsets?l.pollResults.offsets:{},[n]:c.nextOffset||""}}})}(s,o,r,c,l,d)})),(0,a.Q6)("forwardMessages",((e,t,n)=>{const{fromChatId:s,messageIds:o,toChatId:i}=e.forwardMessages,c=s?(0,r.Z1)(e,s):void 0,d=i?(0,r.Z1)(e,i):void 0,u=s&&o?o.sort(((e,t)=>e-t)).map((t=>(0,r.hj)(e,s,t))).filter(Boolean):void 0;if(!c||!d||!u)return;const{isSilent:m,scheduledAt:h}=n,g=(0,r._5)(e,i),p=u.filter((e=>!(0,l.jM)(e)));p.length&&(0,C.t9)("forwardMessages",{fromChat:c,toChat:d,messages:p,serverTimeOffset:(0,a.Rd)().serverTimeOffset,isSilent:m,scheduledAt:h,sendAs:g}),u.filter((e=>(0,l.jM)(e))).forEach((e=>{const{text:t,entities:n}=e.content.text||{},{sticker:a,poll:s}=e.content;R({chat:d,text:t,entities:n,sticker:a,poll:s,isSilent:m,scheduledAt:h,sendAs:g})})),(0,a.R3)({...(0,a.Rd)(),forwardMessages:{}})})),(0,a.Q6)("loadScheduledHistory",((e,t,n)=>{const{chatId:s}=n,o=(0,r.Z1)(e,s);o&&async function(e){const t=await(0,C.t9)("fetchScheduledHistory",{chat:e});if(!t)return;const{messages:n}=t,s=(0,g.ee)(n,"id"),o=Object.keys(s).map(Number).sort(((e,t)=>t-e));let r=(0,a.Rd)();r=(0,i.w3)(r,e.id,s),r=(0,i.pf)(r,e.id,u._f,"scheduledIds",o),(0,a.R3)(r)}(o)})),(0,a.Q6)("sendScheduledMessages",((e,t,n)=>{const{chatId:a,id:s}=n,o=(0,r.Z1)(e,a);o&&(0,C.t9)("sendScheduledMessages",{chat:o,ids:[s]})})),(0,a.Q6)("rescheduleMessage",((e,t,n)=>{const{chatId:a,messageId:s,scheduledAt:o}=n,i=(0,r.Z1)(e,a),c=i&&(0,r.Tm)(e,i.id,s);i&&c&&(0,C.t9)("rescheduleMessage",{chat:i,message:c,scheduledAt:o})})),(0,a.Q6)("requestThreadInfoUpdate",((e,t,n)=>{const{chatId:a,threadId:s}=n,o=(0,r.Cm)(e,a,s);o&&(0,C.t9)("requestThreadInfoUpdate",{chat:o,threadId:s})})),(0,a.Q6)("loadPinnedMessages",((e,t,n)=>{const{chatId:s}=n,o=(0,r.Z1)(e,s);o&&async function(e){const t=await(0,C.t9)("fetchPinnedMessages",{chat:e});if(!t)return;const{messages:n,chats:s,users:o}=t,r=(0,g.ee)(n,"id"),c=Object.keys(r).map(Number).sort(((e,t)=>t-e));let l=(0,a.Rd)();l=(0,i.c_)(l,e.id,r),l=(0,i.pf)(l,e.id,u._f,"pinnedIds",c),l=(0,i.Sh)(l,(0,g.ee)(o,"id")),l=(0,i.fZ)(l,(0,g.ee)(s,"id")),(0,a.R3)(l)}(o)})),(0,a.Q6)("loadSeenBy",((e,t,n)=>{const{chatId:s,messageId:o}=n,c=(0,r.Z1)(e,s);c&&(async()=>{const e=await(0,C.t9)("fetchSeenBy",{chat:c,messageId:o});e&&(0,a.R3)((0,i.cY)((0,a.Rd)(),s,o,{seenByUserIds:e}))})()})),(0,a.Q6)("saveDefaultSendAs",((e,t,n)=>{const{chatId:a,sendAsId:s}=n,o=(0,r.Z1)(e,a),c=(0,r.Z1)(e,s)||(0,r.dy)(e,s);if(o&&c)return(0,C.t9)("saveDefaultSendAs",{sendAs:c,chat:o}),(0,i.a4)(e,a,{fullInfo:{...o.fullInfo,sendAsId:s}})})),(0,a.Q6)("loadSendAs",((e,t,n)=>{const{chatId:s}=n,o=(0,r.Z1)(e,s);o&&(async()=>{const t=await(0,C.t9)("fetchSendAs",{chat:o});if(!t)return e=(0,i.a4)(e,s,{sendAsIds:[]}),void(0,a.R3)(e);e=(0,a.Rd)(),e=(0,i.Sh)(e,(0,g.ee)(t.users,"id")),e=(0,i.fZ)(e,(0,g.ee)(t.chats,"id")),e=(0,i.a4)(e,s,{sendAsIds:t.ids}),(0,a.R3)(e)})()})),(0,a.Q6)("loadSponsoredMessages",((e,t,n)=>{const{chatId:s}=n,o=(0,r.Z1)(e,s);o&&(async()=>{const e=await(0,C.t9)("fetchSponsoredMessages",{chat:o});if(!e)return;let t=(0,i.Fn)((0,a.Rd)(),s,e.messages[0]);t=(0,i.Sh)(t,(0,g.ee)(e.users,"id")),t=(0,i.fZ)(t,(0,g.ee)(e.chats,"id")),(0,a.R3)(t)})()})),(0,a.Q6)("viewSponsoredMessage",((e,t,n)=>{const{chatId:a}=n,s=(0,r.Z1)(e,a),o=(0,r.fS)(e,a);s&&o&&(0,C.t9)("viewSponsoredMessage",{chat:s,random:o.randomId})}));var k=n(5765);const T=(0,w.P2)((e=>e()),500,!1);async function N(e,t){const n=await(0,C.t9)("searchGifs",{query:e,offset:t});n&&(0,a.R3)((0,i.rq)((0,a.Rd)(),!t,n.gifs,n.nextOffset))}(0,a.Q6)("loadStickerSets",(e=>{const{hash:t}=e.stickers.added||{};!async function(e){const t=await(0,C.t9)("fetchStickerSets",{hash:e});t&&(0,a.R3)((0,i.z3)((0,a.Rd)(),"added",t.hash,t.sets))}(t)})),(0,a.Q6)("loadAddedStickers",((e,t)=>{const{setIds:n}=e.stickers.added,a=e.stickers.setsById;n&&n.length&&(async()=>{for(let e=0;e<n.length;e++){const s=n[e];a[s].stickers||(t.loadStickers({stickerSetId:s}),e%10==0&&e>0&&await(0,w.wO)(200))}})()})),(0,a.Q6)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};!async function(e){const t=await(0,C.t9)("fetchRecentStickers",{hash:e});if(!t)return;const n=(0,a.Rd)();(0,a.R3)({...n,stickers:{...n.stickers,recent:t}})}(t)})),(0,a.Q6)("loadFavoriteStickers",(e=>{const{hash:t}=e.stickers.favorite||{};!async function(e){const t=await(0,C.t9)("fetchFavoriteStickers",{hash:e});if(!t)return;const n=(0,a.Rd)();(0,a.R3)({...n,stickers:{...n.stickers,favorite:t}})}(t)})),(0,a.Q6)("loadGreetingStickers",(e=>{const{hash:t}=e.stickers.greeting||{};(async()=>{const e=await(0,C.t9)("fetchStickersForEmoji",{emoji:"👋⭐️",hash:t});if(!e)return;const n=(0,a.Rd)();(0,a.R3)({...n,stickers:{...n.stickers,greeting:{hash:e.hash,stickers:e.stickers.filter((e=>"👋"===e.emoji))}}})})()})),(0,a.Q6)("loadFeaturedStickers",(e=>{const{hash:t}=e.stickers.featured||{};!async function(e){const t=await(0,C.t9)("fetchFeaturedStickers",{hash:e});t&&(0,a.R3)((0,i.z3)((0,a.Rd)(),"featured",t.hash,t.sets))}(t)})),(0,a.Q6)("loadStickers",((e,t,n)=>{const{stickerSetId:s,stickerSetShortName:o}=n;let{stickerSetAccessHash:c}=n;if(!c&&!o){const t=(0,r.Ny)(e,s);if(!t)return;c=t.accessHash}!async function(e,t,n){const s=await(0,C.t9)("fetchStickers",{stickerSetShortName:n,stickerSetId:e,accessHash:t});if(!s)return;const{set:o,stickers:r,packs:c}=s;let l=(0,a.Rd)();l=(0,i.Rg)(l,o.id,{...o,stickers:r,packs:c});const d=l.stickers.forEmoji.emoji;d&&c[d]&&(l=(0,i.vy)(l)),(0,a.R3)(l)}(s,c,o)})),(0,a.Q6)("loadAnimatedEmojis",(()=>{!async function(){const e=await(0,C.t9)("fetchAnimatedEmojis");if(!e)return;const{set:t,stickers:n}=e;(0,a.R3)((0,i.g_)((0,a.Rd)(),{...t,stickers:n}))}(),async function(){const e=await(0,C.t9)("fetchAnimatedEmojiEffects");if(!e)return;const{set:t,stickers:n}=e;(0,a.R3)({...(0,a.Rd)(),animatedEmojiEffects:{...t,stickers:n}})}()})),(0,a.Q6)("loadSavedGifs",(e=>{const{hash:t}=e.gifs.saved;!async function(e){const t=await(0,C.t9)("fetchSavedGifs",{hash:e});if(!t)return;const n=(0,a.Rd)();(0,a.R3)({...n,gifs:{...n.gifs,saved:t}})}(t)})),(0,a.Q6)("faveSticker",((e,t,n)=>{const{sticker:a}=n;a&&(0,C.t9)("faveSticker",{sticker:a})})),(0,a.Q6)("unfaveSticker",((e,t,n)=>{const{sticker:s}=n;s&&function(e){const t=(0,a.Rd)();(0,a.R3)({...t,stickers:{...t.stickers,favorite:{...t.stickers.favorite,stickers:t.stickers.favorite.stickers.filter((t=>{let{id:n}=t;return n!==e.id}))}}}),(0,C.t9)("faveSticker",{sticker:e,unfave:!0})}(s)})),(0,a.Q6)("toggleStickerSet",((e,t,n)=>{const{stickerSetId:a}=n,s=(0,r.Ny)(e,a);if(!s)return;const{accessHash:o,installedDate:i}=s;(0,C.t9)(i?"uninstallStickerSet":"installStickerSet",{stickerSetId:a,accessHash:o})})),(0,a.Q6)("loadEmojiKeywords",((e,t,n)=>{var s;const{language:o}=n;let i=e.emojiKeywords[o];null!==(s=i)&&void 0!==s&&s.isLoading||((0,a.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...i,isLoading:!0}}}),(async()=>{var t;const n=await(0,C.t9)("fetchEmojiKeywords",{language:o,fromVersion:i?i.version:0});e=(0,a.Rd)(),i=e.emojiKeywords[o],n?(0,a.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{isLoading:!1,version:n.version,keywords:{...null===(t=i)||void 0===t?void 0:t.keywords,...n.keywords}}}}):(0,a.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...i,isLoading:!1}}})})())})),(0,a.Q6)("setStickerSearchQuery",((e,t,n)=>{const{query:s}=n;s&&T((()=>{!async function(e,t){const n=await(0,C.t9)("searchStickers",{query:e,hash:void 0});if(!n)return;const s=(0,a.Rd)(),{setsById:o,added:r}=s.stickers,c=n.sets.map((e=>{let{id:t}=e;return t}));r.setIds&&r.setIds.forEach((t=>{if(!c.includes(t)){const{title:n}=o[t]||{};n&&(0,k.Z)(n,e)&&c.unshift(t)}})),(0,a.R3)((0,i.z3)(s,"search",n.hash,n.sets,c))}(s)}))})),(0,a.Q6)("setGifSearchQuery",((e,t,n)=>{const{query:a}=n;"string"==typeof a&&T((()=>{N(a)}))})),(0,a.Q6)("searchMoreGifs",(e=>{const{query:t,offset:n}=e.gifs.search;"string"==typeof t&&T((()=>{N(t,n)}))})),(0,a.Q6)("loadStickersForEmoji",((e,t,n)=>{const{emoji:s}=n,{hash:o}=e.stickers.forEmoji;T((()=>{!async function(e,t){let n=(0,a.Rd)();(0,a.R3)({...n,stickers:{...n.stickers,forEmoji:{...n.stickers.forEmoji,emoji:e}}});const s=await(0,C.t9)("fetchStickersForEmoji",{emoji:e,hash:t});n=(0,a.Rd)(),s&&n.stickers.forEmoji.emoji===e&&(n=(0,i.IM)(n,e,s.stickers,s.hash),(0,a.R3)(n))}(s,o)}))})),(0,a.Q6)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,a.Q6)("openStickerSetShortName",((e,t,n)=>{const{stickerSetShortName:a}=n;return{...e,openedStickerSetShortName:a}}));var B=n(790);const A=(0,w.P2)((e=>e()),500,!1);async function x(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1?arguments[1]:void 0,o=arguments.length>2?arguments[2]:void 0,c=arguments.length>3?arguments[3]:void 0,l=arguments.length>4?arguments[4]:void 0,d=arguments.length>5?arguments[5]:void 0;if(c){const a=await(0,C.t9)("searchMessagesLocal",{chat:c,query:t,type:n,limit:s.Hk,offsetId:o,minDate:d,maxDate:l});if(a){const{messages:t,users:n,totalCount:s,nextOffsetId:o}=a;e={messages:t,users:n,chats:[],totalCount:s,nextRate:o}}}else e=await(0,C.t9)("searchMessagesGlobal",{query:t,offsetRate:o,limit:s.Hk,type:n,maxDate:l,minDate:d});let u=(0,a.Rd)();const m=(0,r.JX)(u);if(!e||""!==t&&t!==m)return void(0,a.R3)((0,i.xv)(u,{messages:!1}));const{messages:h,users:p,chats:f,totalCount:v,nextRate:I}=e;f.length&&(u=(0,i.fZ)(u,(0,g.ee)(f,"id"))),p.length&&(u=(0,i.Sh)(u,(0,g.ee)(p,"id"))),h.length&&(u=(0,i.m6)(u,h)),u=(0,i.px)(u,h,v,n,I),(0,a.R3)(u)}async function L(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const c=await(0,C.t9)("searchMessagesLocal",{chat:e,type:t,limit:2*s.EN,offsetId:n});if(!c)return;const{chats:l,users:d,messages:u,totalCount:m,nextOffsetId:h}=c,p=(0,g.ee)(u,"id"),f=Object.keys(p).map(Number);let v=(0,a.Rd)();const I=(0,r.we)(v);I&&(v=(0,i.fZ)(v,(0,g.ee)(l,"id")),v=(0,i.Sh)(v,(0,g.ee)(d,"id")),v=(0,i.c_)(v,e.id,p),v=(0,i.c1)(v,e.id,t,f,m,h),(0,a.R3)(v),o||L(e,t,h,!0))}(0,a.Q6)("setGlobalSearchQuery",((e,t,n)=>{const{chatId:s}=e.globalSearch,{query:o}=n;o&&!s&&A((()=>{!async function(e){const t=await(0,C.t9)("searchChats",{query:e});let n=(0,a.Rd)();const s=(0,r.JX)(n);if(!t||!s||e!==s)return void(0,a.R3)((0,i.xv)(n,{chats:!1}));const{localChats:o,localUsers:c,globalChats:l,globalUsers:d}=t;(o.length||l.length)&&(n=(0,i.fZ)(n,(0,g.ee)([...o,...l],"id"))),(c.length||d.length)&&(n=(0,i.Sh)(n,(0,g.ee)([...c,...d],"id"))),n=(0,i.xv)(n,{chats:!1}),n=(0,i.No)(n,{localResults:{chatIds:o.map((e=>{let{id:t}=e;return t})),userIds:c.map((e=>{let{id:t}=e;return t}))},globalResults:{...n.globalSearch.globalResults,chatIds:l.map((e=>{let{id:t}=e;return t})),userIds:d.map((e=>{let{id:t}=e;return t}))}}),(0,a.R3)(n)}(o)}))})),(0,a.Q6)("setGlobalSearchDate",((e,t,n)=>{const{date:s}=n,o=s?(0,B.IS)(s):s,c=(0,i.No)(e,{date:s,query:"",resultsByType:{...e.globalSearch.resultsByType,text:{totalCount:void 0,foundIds:[],nextOffsetId:0}}});(0,a.R3)(c);const{chatId:l}=e.globalSearch;x("","text",void 0,l?(0,r.Z1)(e,l):void 0,o,s)})),(0,a.Q6)("searchMessagesGlobal",((e,t,n)=>{var a;const{query:s,resultsByType:o,chatId:i,date:c}=e.globalSearch,l=c?(0,B.IS)(c):c,{type:d}=n;x(s,d,null==o||null===(a=o[d])||void 0===a?void 0:a.nextOffsetId,i?(0,r.Z1)(e,i):void 0,l,c)})),(0,a.Q6)("searchTextMessagesLocal",(e=>{const{chatId:t,threadId:n}=(0,r.Bt)(e)||{},o=t?(0,r.Z1)(e,t):void 0,c=(0,r.n5)(e);if(!o||!c||!n)return;const{query:l,results:d}=c,m=null==d?void 0:d.nextOffsetId;let h;if(n!==u._f){const a=(0,r.tZ)(e,t,n);h=null==a?void 0:a.topMessageId}!async function(e,t,n,o,c){if(!o)return;const l=await(0,C.t9)("searchMessagesLocal",{chat:e,type:"text",query:o,topMessageId:n,limit:s.pn,offsetId:c});if(!l)return;const{chats:d,users:u,messages:m,totalCount:h,nextOffsetId:p}=l,f=(0,g.ee)(m,"id"),v=Object.keys(f).map(Number);let I=(0,a.Rd)();const y=(0,r.n5)(I);y&&o===y.query&&(I=(0,i.fZ)(I,(0,g.ee)(d,"id")),I=(0,i.Sh)(I,(0,g.ee)(u,"id")),I=(0,i.c_)(I,e.id,f),I=(0,i.dx)(I,e.id,t,v,h,p),(0,a.R3)(I))}(o,n,h,l,m)})),(0,a.Q6)("searchMediaMessagesLocal",(e=>{const{chatId:t}=(0,r.Bt)(e)||{};if(!t)return;const n=(0,r.Z1)(e,t),a=(0,r.we)(e);if(!n||!a)return;const{currentType:s,resultsByType:o}=a,i=s&&o&&o[s],c=null==i?void 0:i.nextOffsetId;s&&L(n,s,c)})),(0,a.Q6)("searchMessagesByDate",((e,t,n)=>{const{timestamp:s}=n,{chatId:o}=(0,r.Bt)(e)||{};if(!o)return;const i=(0,r.Z1)(e,o);i&&async function(e,t){const n=await(0,C.t9)("findFirstMessageIdAfterDate",{chat:e,timestamp:t});n&&(0,a.uC)().focusMessage({chatId:e.id,messageId:n})}(i,s)})),(0,a.Q6)("checkPublicLink",((e,t,n)=>{const{chatId:s}=(0,r.Bt)(e)||{};if(!s)return;if(e.management.progress===m.wv.InProgress)return;const{username:o}=n;(async()=>{e=(0,i.H9)(e,m.wv.InProgress),e=(0,i.fw)(e,s,{isUsernameAvailable:void 0}),(0,a.R3)(e);const t=await(0,C.t9)("checkChatUsername",{username:o});e=(0,a.Rd)(),e=(0,i.H9)(e,t?m.wv.Complete:m.wv.Error),e=(0,i.fw)(e,s,{isUsernameAvailable:t}),(0,a.R3)(e)})()})),(0,a.Q6)("updatePublicLink",((e,t,n)=>{const{chatId:s}=(0,r.Bt)(e)||{};let o=s&&(0,r.Z1)(e,s);if(!s||!o)return;const{username:c}=n;(async()=>{if(e=(0,i.H9)(e,m.wv.InProgress),(0,a.R3)(e),(0,l.G9)(o)){if(o=await(0,C.t9)("migrateChat",o),!o)return;t.openChat({id:o.id})}const n=await(0,C.t9)("setChatUsername",{chat:o,username:c});e=(0,a.Rd)(),e=(0,i.H9)(e,n?m.wv.Complete:m.wv.Error),e=(0,i.fw)(e,s,{isUsernameAvailable:void 0}),(0,a.R3)(e)})()})),(0,a.Q6)("updatePrivateLink",(e=>{const{chatId:t}=(0,r.Bt)(e)||{},n=t&&(0,r.Z1)(e,t);t&&n&&(0,C.t9)("updatePrivateLink",{chat:n})})),(0,a.Q6)("setEditingExportedInvite",((e,t,n)=>{const{chatId:s,invite:o}=n;(0,a.R3)((0,i.fw)(e,s,{editingInvite:o}))})),(0,a.Q6)("setOpenedInviteInfo",((e,t,n)=>{const{chatId:s,invite:o}=n,r=o?{inviteInfo:{invite:o}}:{inviteInfo:void 0};(0,a.R3)((0,i.fw)(e,s,r))})),(0,a.Q6)("loadExportedChatInvites",((e,t,n)=>{const{chatId:s,adminId:o,isRevoked:c,limit:l}=n,d=(0,r.Z1)(e,s),u=(0,r.dy)(e,o||e.currentUserId);d&&u&&(async()=>{const e=await(0,C.t9)("fetchExportedChatInvites",{peer:d,admin:u,isRevoked:c,limit:l});if(!e)return;const t=c?{revokedInvites:e}:{invites:e};(0,a.R3)((0,i.fw)((0,a.Rd)(),s,t))})()})),(0,a.Q6)("editExportedChatInvite",((e,t,n)=>{const{chatId:s,link:o,isRevoked:c,expireDate:l,usageLimit:d,isRequestNeeded:u,title:m}=n,h=(0,r.Z1)(e,s);h&&(async()=>{const t=await(0,C.t9)("editExportedChatInvite",{peer:h,link:o,isRevoked:c,expireDate:l,usageLimit:d,isRequestNeeded:u,title:m});if(!t)return;let n=(e=(0,a.Rd)()).management.byChatId[s].invites||[];const r=e.management.byChatId[s].revokedInvites||[],{oldInvite:g,newInvite:p}=t;n=n.filter((e=>e.link!==g.link)),p.isRevoked?r.unshift(p):n.push(p),(0,a.R3)((0,i.fw)(e,s,{invites:n,revokedInvites:r}))})()})),(0,a.Q6)("exportChatInvite",((e,t,n)=>{const{chatId:s,expireDate:o,usageLimit:c,isRequestNeeded:l,title:d}=n,u=(0,r.Z1)(e,s);u&&(async()=>{const t=await(0,C.t9)("exportChatInvite",{peer:u,expireDate:o,usageLimit:c,isRequestNeeded:l,title:d});if(!t)return;const n=(e=(0,a.Rd)()).management.byChatId[s].invites||[];(0,a.R3)((0,i.fw)(e,s,{invites:[...n,t]}))})()})),(0,a.Q6)("deleteExportedChatInvite",((e,t,n)=>{const{chatId:s,link:o}=n,c=(0,r.Z1)(e,s);c&&(async()=>{var t,n;if(!await(0,C.t9)("deleteExportedChatInvite",{peer:c,link:o}))return;const r=(e=(0,a.Rd)()).management.byChatId[s];(0,a.R3)((0,i.fw)(e,s,{invites:null==r||null===(t=r.invites)||void 0===t?void 0:t.filter((e=>e.link!==o)),revokedInvites:null==r||null===(n=r.revokedInvites)||void 0===n?void 0:n.filter((e=>e.link!==o))}))})()})),(0,a.Q6)("deleteRevokedExportedChatInvites",((e,t,n)=>{const{chatId:s,adminId:o}=n,c=(0,r.Z1)(e,s),l=(0,r.dy)(e,o||e.currentUserId);c&&l&&(async()=>{await(0,C.t9)("deleteRevokedExportedChatInvites",{peer:c,admin:l})&&(e=(0,a.Rd)(),(0,a.R3)((0,i.fw)(e,s,{revokedInvites:[]})))})()})),(0,a.Q6)("loadChatInviteImporters",((e,t,n)=>{const{chatId:s,link:o,offsetDate:c,offsetUserId:l,limit:d}=n,u=(0,r.Z1)(e,s),m=(0,r.dy)(e,l);!u||l&&!m||(async()=>{var t;const n=await(0,C.t9)("fetchChatInviteImporters",{peer:u,link:o,offsetDate:c,offsetUser:m,limit:d});if(!n)return;const r=null===(t=(e=(0,a.Rd)()).management.byChatId[s])||void 0===t?void 0:t.inviteInfo;null!=r&&r.invite&&r.invite.link===o&&(0,a.R3)((0,i.fw)(e,s,{inviteInfo:{...r,importers:n}}))})()})),(0,a.Q6)("loadChatInviteRequesters",((e,t,n)=>{const{chatId:s,link:o,offsetDate:c,offsetUserId:l,limit:d}=n,u=(0,r.Z1)(e,s),m=(0,r.dy)(e,l);!u||l&&!m||(async()=>{var t;const n=await(0,C.t9)("fetchChatInviteImporters",{peer:u,link:o,offsetDate:c,offsetUser:m,limit:d,isRequested:!0});if(!n)return;const r=null===(t=(e=(0,a.Rd)()).management.byChatId[s])||void 0===t?void 0:t.inviteInfo;null!=r&&r.invite&&r.invite.link===o&&(0,a.R3)((0,i.fw)(e,s,{inviteInfo:{...r,requesters:n}}))})()})),(0,a.Q6)("loadChatJoinRequests",((e,t,n)=>{const{chatId:s,offsetDate:o,offsetUserId:c,limit:l}=n,d=(0,r.Z1)(e,s),u=(0,r.dy)(e,c);!d||c&&!u||(async()=>{const t=await(0,C.t9)("fetchChatInviteImporters",{peer:d,offsetDate:o,offsetUser:u,limit:l,isRequested:!0});t&&(e=(0,a.Rd)(),(0,a.R3)((0,i.a4)(e,s,{joinRequests:t})))})()})),(0,a.Q6)("hideChatJoinRequest",((e,t,n)=>{const{chatId:s,userId:o,isApproved:c}=n,l=(0,r.Z1)(e,s),d=(0,r.dy)(e,o);l&&d&&(async()=>{var t;if(!await(0,C.t9)("hideChatJoinRequest",{peer:l,user:d,isApproved:c}))return;e=(0,a.Rd)();const n=(0,r.Z1)(e,s);n&&(0,a.R3)((0,i.a4)(e,s,{joinRequests:null===(t=n.joinRequests)||void 0===t?void 0:t.filter((e=>e.userId!==o))}))})()})),(0,a.Q6)("hideAllChatJoinRequests",((e,t,n)=>{const{chatId:s,isApproved:o,link:c}=n,l=(0,r.Z1)(e,s);l&&(async()=>{if(!await(0,C.t9)("hideAllChatJoinRequests",{peer:l,isApproved:o,link:c}))return;e=(0,a.Rd)();const t=(0,r.Z1)(e,s);t&&(0,a.R3)((0,i.a4)(e,s,{joinRequests:[],fullInfo:{...t.fullInfo,recentRequesterIds:[],requestsPending:0}}))})()}));var O=n(6974);let F;function U(e){return(0,C.t9)("fetchMessages",{chat:e,threadId:u._f,offsetId:e.lastReadInboxMessageId,addOffset:-(Math.round(s.hT/2)+1),limit:s.hT})}(0,a.Q6)("sync",(()=>{s.eM&&console.log(">>> START SYNC"),F&&clearTimeout(F),(0,a.R3)({...(0,a.Rd)(),isSyncing:!0}),F=window.setTimeout((()=>{(0,a.R3)({...(0,a.Rd)(),isSyncing:!1}),F=void 0}),15e3);const{loadAllChats:e,preloadTopChatMessages:t}=(0,a.uC)();e({listType:"active",shouldReplace:!0,onReplace:async()=>{await async function(){let e=!1,t=(0,a.Rd)();const n=Object.keys(t.messages.byChatId).reduce(((e,n)=>{const a=(0,r.Ms)(t,n,u._f);return a&&(e[n]=a),e}),{}),{chatId:o,threadId:c}=(0,r.Bt)(t)||{},l=o?t.chats.byId[o]:void 0;if(o&&l){const n=await U(l);t=(0,a.Rd)();const{chatId:d}=(0,r.Bt)(t)||{},m=c&&(0,r.tZ)(t,o,c);if(n&&d===o){const a=t.messages.byChatId[o],r=o===s.aw?t.serviceNotifications.map((e=>{let{message:t}=e;return t})):[],l=[].concat(n.messages,r),d=(0,g.ee)(l,"id"),h=Object.keys(d).map(Number);if(t={...t,messages:{...t.messages,byChatId:{}}},t=(0,i.c_)(t,o,d),t=(0,i.xj)(t,o,u._f,h),t=(0,i.y9)(t,o,u._f,h),c&&m&&m.originChannelId){const{originChannelId:e}=m,n=t.messages.byChatId[e],s=await U(t.chats.byId[e]);if(s){const e=(0,g.ee)(s.messages,"id"),i=Object.keys(e).map(Number);t={...t,messages:{...t.messages,byChatId:{...t.messages.byChatId,[m.originChannelId]:{byId:e,threadsById:{[u._f]:{...null==n?void 0:n.threadsById[u._f],listedIds:i,viewportIds:i,outlyingIds:void 0}}},[o]:{...t.messages.byChatId[o],threadsById:{...t.messages.byChatId[o].threadsById,[c]:{...null==a?void 0:a.threadsById[c],outlyingIds:void 0}}}}}}}}t=(0,i.GL)(t,(0,g.ee)(n.chats,"id")),t=(0,i.eD)(t,(0,g.ee)(n.users,"id")),t=(0,i.j6)(t,o,n.threadInfos),e=!0}}e||(t={...t,messages:{...t.messages,byChatId:{}}}),Object.keys(n).forEach((e=>{t=(0,i.pf)(t,e,u._f,"draft",n[e])})),(0,a.R3)(t);const{chatId:d,messageId:m}=t.audioPlayer;d&&m&&!(0,r.hj)(t,d,m)&&(0,a.uC)().closeAudioPlayer()}(),(0,a.R3)({...(0,a.Rd)(),lastSyncTime:Date.now(),isSyncing:!1}),s.eM&&console.log(">>> FINISH SYNC"),(0,O.S1)(),e({listType:"archived",shouldReplace:!0}),(0,C.t9)("fetchCurrentUser"),t()}})}));const $=(0,w.Ds)((e=>e()),500,!1,!0),D=(0,w.P2)((e=>e()),500,!1);function j(e,t,n){return{...e,inlineBots:{...e.inlineBots,byUsername:{...e.inlineBots.byUsername,[t]:n}}}}function q(e,t){return{...e,inlineBots:{...e.inlineBots,isLoading:t}}}(0,a.Q6)("loadFullUser",((e,t,n)=>{const{userId:a}=n,s=(0,r.dy)(e,a);if(!s)return;const{id:o,accessHash:i}=s;$((()=>(0,C.t9)("fetchFullUser",{id:o,accessHash:i})))})),(0,a.Q6)("loadUser",((e,t,n)=>{const{userId:s}=n,o=(0,r.dy)(e,s);o&&(async()=>{const t=await(0,C.t9)("fetchUsers",{users:[o]});if(!t)return;const{users:n,userStatusesById:s}=t;e=(0,a.Rd)(),e=(0,i.eD)(e,(0,g.ee)(n,"id")),(0,a.R3)((0,i.ps)(e,{...e.users.statusesById,...s})),(0,a.R3)(e)})()})),(0,a.Q6)("loadTopUsers",(e=>{const{topPeers:{lastRequestedAt:t}}=e;(!t||(0,p.b)(e.serverTimeOffset)-t>60)&&async function(){const e=await(0,C.t9)("fetchTopUsers");if(!e)return;const{ids:t,users:n}=e;let s=(0,a.Rd)();s=(0,i.Sh)(s,(0,g.ee)(n,"id")),s={...s,topPeers:{...s.topPeers,userIds:t,lastRequestedAt:(0,p.b)(s.serverTimeOffset)}},(0,a.R3)(s)}()})),(0,a.Q6)("loadContactList",(()=>{!async function(){const e=await(0,C.t9)("fetchContactList");if(!e)return;let t=(0,i.Sh)((0,a.Rd)(),(0,g.ee)(e.users,"id"));t=(0,i.fZ)(t,(0,g.ee)(e.chats,"id"));const n=e=>e.lastName||e.firstName||"",s=new Intl.Collator("en-US"),o=e.users.sort(((e,t)=>s.compare(n(e),n(t)))).filter((e=>!e.isSelf));(0,a.R3)({...t,contactList:{userIds:o.map((e=>e.id))}})}()})),(0,a.Q6)("loadCurrentUser",(()=>{(0,C.t9)("fetchCurrentUser")})),(0,a.Q6)("loadCommonChats",(e=>{var t;const{chatId:n}=(0,r.Bt)(e)||{},s=n?(0,r.dy)(e,n):void 0;!s||(0,l.cS)(s)||null!==(t=s.commonChats)&&void 0!==t&&t.isFullyLoaded||(async()=>{var t,n;const o=null===(t=s.commonChats)||void 0===t?void 0:t.maxId,r=await(0,C.t9)("fetchCommonChats",s.id,s.accessHash,o);if(!r)return;const{chats:c,chatIds:l,isFullyLoaded:d}=r;e=(0,a.Rd)(),c.length&&(e=(0,i.fZ)(e,(0,g.ee)(c,"id"))),e=(0,i.Nq)(e,s.id,{commonChats:{maxId:l.length?l[l.length-1]:"0",ids:(0,g.Tw)(((null===(n=s.commonChats)||void 0===n?void 0:n.ids)||[]).concat(l)),isFullyLoaded:d}}),(0,a.R3)(e)})()})),(0,a.Q6)("updateContact",((e,t,n)=>{const{userId:s,isMuted:o,firstName:c,lastName:l}=n;!async function(e,t,n,s){const o=(0,a.Rd)(),c=(0,r.dy)(o,e);if(!c)return;let l;if((0,a.uC)().updateChatMutedState({chatId:e,isMuted:t}),(0,a.R3)((0,i.H9)((0,a.Rd)(),m.wv.InProgress)),c.phoneNumber)l=await(0,C.t9)("updateContact",{phone:c.phoneNumber,firstName:n,lastName:s});else{const{id:e,accessHash:t}=c;l=await(0,C.t9)("addContact",{id:e,accessHash:t,phoneNumber:"",firstName:n,lastName:s})}l&&(0,a.R3)((0,i.Nq)((0,a.Rd)(),c.id,{firstName:n,lastName:s})),(0,a.R3)((0,i.H9)((0,a.Rd)(),m.wv.Complete))}(s,o,c,l)})),(0,a.Q6)("deleteContact",((e,t,n)=>{const{userId:s}=n;!async function(e){const t=(0,a.Rd)(),n=(0,r.dy)(t,e);if(!n)return;const{id:s,accessHash:o}=n;await(0,C.t9)("deleteContact",{id:s,accessHash:o})}(s)})),(0,a.Q6)("loadProfilePhotos",((e,t,n)=>{const{profileId:s}=n,o=(0,l.YC)(s),c=o?(0,r.dy)(e,s):void 0,d=o?void 0:(0,r.Z1)(e,s);(c||d)&&(async()=>{const e=await(0,C.t9)("fetchProfilePhotos",c,d);if(!e||!e.photos)return;let t=(0,a.Rd)();o?t=(0,i.Nq)(t,s,{photos:e.photos}):(t=(0,i.Sh)(t,(0,g.ee)(e.users,"id")),t=(0,i.a4)(t,s,{photos:e.photos})),(0,a.R3)(t)})()})),(0,a.Q6)("setUserSearchQuery",((e,t,n)=>{const{query:s}=n;s&&D((()=>{!async function(e){const t=await(0,C.t9)("searchChats",{query:e});let n=(0,a.Rd)();const s=n.userSearch.query;if(!t||!s||e!==s)return void(0,a.R3)((0,i.Q3)(n,!1));const{localUsers:o,globalUsers:r}=t;let c,l;o.length&&(n=(0,i.Sh)(n,(0,g.ee)(o,"id")),c=o.map((e=>{let{id:t}=e;return t}))),r.length&&(n=(0,i.Sh)(n,(0,g.ee)(r,"id")),l=r.map((e=>{let{id:t}=e;return t}))),n=(0,i.Q3)(n,!1),n=(0,i.Lm)(n,{localUserIds:c,globalUserIds:l}),(0,a.R3)(n)}(s)}))})),(0,a.Q6)("addContact",((e,t,n)=>{const{userId:a}=n,s=(0,r.dy)(e,a);s&&(0,C.t9)("addContact",(0,g.ei)(s,["id","accessHash","firstName","lastName","phoneNumber"]))}));const Q=(0,w.Ds)((e=>e()),500,!1);async function G(e,t,n,a,s){await(0,C.t9)("sendMessage",{chat:e,text:n,replyingTo:a,sendAs:s})}(0,a.Q6)("clickInlineButton",((e,t,n)=>{const{button:o}=n;switch(o.type){case"command":t.sendBotCommand({command:o.value});break;case"url":o.value.match(s.FS)||o.value.match(s.g$)?t.openTelegramLink({url:o.value}):t.toggleSafeLinkModal({url:o.value});break;case"callback":{const t=(0,r.jr)(e);if(!t)return;!async function(e,t,n){const s=await(0,C.t9)("answerCallbackButton",{chatId:e.id,accessHash:e.accessHash,messageId:t,data:n});if(!s)return;const{showDialog:o,showNotification:i,toggleSafeLinkModal:r}=(0,a.uC)(),{message:c,alert:l,url:d}=s;l?o({data:{message:c||"Error"}}):c?i({message:c}):d&&r({url:d})}(t,o.messageId,o.value);break}case"requestPoll":t.openPollModal();break;case"requestSelfContact":{const n=e.currentUserId?(0,r.dy)(e,e.currentUserId):void 0;if(!n)return;t.showDialog({data:{phoneNumber:n.phoneNumber,firstName:n.firstName,lastName:n.lastName,userId:n.id}});break}case"buy":{const n=(0,r.jr)(e),{messageId:a,value:s}=o;if(!n)return;s?t.getReceipt({receiptMessageId:s,chatId:n.id,messageId:a}):(t.getPaymentForm({chat:n,messageId:a}),t.setInvoiceMessageInfo((0,r.hj)(e,n.id,a)),t.openPaymentModal({chatId:n.id,messageId:a}));break}}})),(0,a.Q6)("sendBotCommand",((e,t,n)=>{const{command:a,chatId:s}=n,{currentUserId:o}=e,i=s?(0,r.Z1)(e,s):(0,r.jr)(e),c=(0,r.Bt)(e);if(!o||!i||!c)return;const{threadId:l}=c;t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:i.id,threadId:l,value:!1}),G(i,0,a,(0,r.Yy)(e,i.id,l),(0,r._5)(e,s))})),(0,a.Q6)("restartBot",((e,t,n)=>{const{chatId:s}=n,{currentUserId:o}=e,c=(0,r.jr)(e),l=o&&(0,r.IK)(e,s);o&&c&&l&&(async()=>{await(0,C.t9)("unblockContact",l.id,l.accessHash)&&((0,a.R3)((0,i.rB)((0,a.Rd)(),l.id)),G(c,0,"/start",void 0,(0,r._5)(e,s)))})()})),(0,a.Q6)("loadTopInlineBots",(e=>{const{lastRequestedAt:t}=e.topInlineBots;t&&(0,p.b)(e.serverTimeOffset)-t<60||(async()=>{const t=await(0,C.t9)("fetchTopInlineBots");if(!t)return;const{ids:n,users:s}=t;let o=(0,a.Rd)();o=(0,i.Sh)(o,(0,g.ee)(s,"id")),o={...o,topInlineBots:{...o.topInlineBots,userIds:n,lastRequestedAt:(0,p.b)(e.serverTimeOffset)}},(0,a.R3)(o)})()})),(0,a.Q6)("queryInlineBot",((e,t,n)=>{const{chatId:s,username:o,query:c,offset:l}=n;(async()=>{let t=e.inlineBots.byUsername[o];if(!1!==t){if(void 0===t){const{user:n,chat:s}=await(0,C.t9)("fetchInlineBot",{username:o})||{};if(e=(0,a.Rd)(),!n||!s)return void(0,a.R3)(j(e,o,!1));e=(0,i.Sh)(e,{[n.id]:n}),e=(0,i.fZ)(e,{[s.id]:s}),t={id:n.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},e=j(e,o,t),(0,a.R3)(e)}(c!==t.query||t.canLoadMore)&&Q((()=>{!async function(e){let{username:t,inlineBotData:n,chatId:s,query:o,offset:i}=e,c=(0,a.Rd)();const l=(0,r.dy)(c,n.id),d=(0,r.Z1)(c,s);if(!l||!d)return;const u=n.query!==o;c=q(c,!0),c=j(c,t,{...n,query:o,...u&&{offset:void 0,results:[]}}),(0,a.R3)(c);const m=await(0,C.t9)("fetchInlineBotResults",{bot:l,chat:d,query:o,offset:u?void 0:i}),h=c.inlineBots.byUsername[t];if(c=q((0,a.Rd)(),!1),!m||!h||o!==h.query)return void(0,a.R3)(c);const g=new Set((h.results||[]).map((e=>e.id))),p=m.results.filter((e=>!g.has(e.id)));c=j(c,t,{...h,help:m.help,...p.length&&{isGallery:m.isGallery},...m.switchPm&&{switchPm:m.switchPm},canLoadMore:m.results.length>0&&Boolean(m.nextOffset),results:""===h.offset||h.offset===m.nextOffset?m.results:(h.results||[]).concat(p),offset:p.length?m.nextOffset:""}),(0,a.R3)(c)}({username:o,inlineBotData:t,chatId:s,query:c,offset:l})}))}})()})),(0,a.Q6)("sendInlineBotResult",((e,t,n)=>{const{id:a,queryId:s}=n,o=(0,r.Bt)(e);if(!o||!a)return;const{chatId:i,threadId:c}=o,l=(0,r.Z1)(e,i);t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:i,threadId:c,value:!1}),(0,C.t9)("sendInlineBotResult",{chat:l,resultId:a,queryId:s,replyingTo:(0,r.Yy)(e,i,c),sendAs:(0,r._5)(e,i)})})),(0,a.Q6)("resetInlineBot",((e,t,n)=>{const{username:s}=n;let o=e.inlineBots.byUsername[s];o&&(o={id:o.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},(0,a.R3)(j(e,s,o)))})),(0,a.Q6)("startBot",((e,t,n)=>{const{botId:a,param:s}=n,o=(0,r.dy)(e,a);o&&(async()=>{await(0,C.t9)("startBot",{bot:o,startParam:s})})()})),n(9667),(0,a.Q6)("loadPasswordInfo",(()=>{(async()=>{const e=await(0,C.t9)("getPasswordInfo");if(!e)return;let t=(0,a.Rd)();t=(0,i.BI)(t,{hasPassword:e.hasPassword}),t=(0,i.IE)(t,{hint:e.hint}),(0,a.R3)(t)})()})),(0,a.Q6)("checkPassword",((e,t,n)=>{const{currentPassword:s,onSuccess:o}=n;(0,a.R3)((0,i.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,C.t9)("checkPassword",s);(0,a.R3)((0,i.IE)((0,a.Rd)(),{isLoading:!1})),e&&o()})()})),(0,a.Q6)("clearPassword",((e,t,n)=>{const{currentPassword:s,onSuccess:o}=n;(0,a.R3)((0,i.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,C.t9)("clearPassword",s);(0,a.R3)((0,i.IE)((0,a.Rd)(),{isLoading:!1})),e&&o()})()})),(0,a.Q6)("updatePassword",((e,t,n)=>{const{currentPassword:s,password:o,hint:r,email:c,onSuccess:l}=n;(0,a.R3)((0,i.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,C.t9)("updatePassword",s,o,r,c);(0,a.R3)((0,i.IE)((0,a.Rd)(),{isLoading:!1})),e&&l()})()})),(0,a.Q6)("updateRecoveryEmail",((e,t,n)=>{const{currentPassword:s,email:o,onSuccess:r}=n;(0,a.R3)((0,i.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,C.t9)("updateRecoveryEmail",s,o);(0,a.R3)((0,i.IE)((0,a.Rd)(),{isLoading:!1,waitingEmailCodeLength:void 0})),e&&r()})()})),(0,a.Q6)("provideTwoFaEmailCode",((e,t,n)=>{const{code:a}=n;(0,C.t9)("provideRecoveryEmailCode",a)})),(0,a.Q6)("clearTwoFaError",(e=>(0,i.IE)(e,{error:void 0}))),(0,a.Q6)("validateRequestedInfo",((e,t,n)=>{const{requestInfo:s,saveInfo:o}=n,c=(0,r.gx)(e),l=c&&(0,r.Z1)(e,c),d=(0,r.Mz)(e);l&&d&&async function(e,t,n,s){const o=await(0,C.t9)("validateRequestedInfo",{chat:e,messageId:t,requestInfo:n,shouldSave:s});if(!o)return;const{id:r,shippingOptions:c}=o;if(!r)return;let l=(0,i.vT)((0,a.Rd)(),r);c?(l=(0,i.TM)(l,c),l=(0,i.Q$)(l,m.KB.Shipping)):l=(0,i.Q$)(l,m.KB.PaymentInfo),(0,a.R3)(l)}(l,d,s,o)})),(0,a.Q6)("getPaymentForm",((e,t,n)=>{const{chat:s,messageId:o}=n;s&&o&&async function(e,t){const n=await(0,C.t9)("getPaymentForm",{chat:e,messageId:t});if(!n)return;let s=(0,i._7)((0,a.Rd)(),n),o=m.KB.PaymentInfo;s.payment.invoice&&(s.payment.invoice.shippingAddressRequested||s.payment.invoice.nameRequested||s.payment.invoice.phoneRequested||s.payment.invoice.emailRequested)&&(o=m.KB.ShippingInfo),s=(0,i.Q$)(s,o),(0,a.R3)(s)}(s,o)})),(0,a.Q6)("getReceipt",((e,t,n)=>{const{receiptMessageId:s,chatId:o,messageId:c}=n,l=o&&(0,r.Z1)(e,o);c&&s&&l&&async function(e,t,n){const s=await(0,C.t9)("getReceipt",e,n);if(!s)return;let o=(0,a.Rd)();const c=(0,r.hj)(o,e.id,t);o=(0,i.Dq)(o,s,c),(0,a.R3)(o)}(l,c,s)})),(0,a.Q6)("clearPaymentError",(e=>{(0,a.R3)({...e,payment:{...e.payment,error:void 0}})})),(0,a.Q6)("clearReceipt",(e=>{(0,a.R3)({...e,payment:{...e.payment,receipt:void 0}})})),(0,a.Q6)("sendCredentialsInfo",((e,t,n)=>{const s=(0,r.$$)(e);if(!s)return;const{credentials:o}=n,{data:c}=o;!async function(e,t){const n=function(e){const t=Object.keys(e).map((t=>`${t}=${e[t]}`)).join("&");return t.length>0?`?${t}`:""}({"card[number]":e.cardNumber,"card[exp_month]":e.expiryMonth,"card[exp_year]":e.expiryYear,"card[cvc]":e.cvv,"card[address_zip]":e.zip,"card[address_country]":e.country}),s=await fetch(`https://api.stripe.com/v1/tokens${n}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${t}`}}),o=await s.json();if(o.error){const e=(0,l.Ow)(o.error),t=(0,a.Rd)();return void(0,a.R3)({...t,payment:{...t.payment,error:{...e}}})}let r=(0,i.QH)((0,a.Rd)(),{type:o.type,id:o.id});r=(0,i.Q$)(r,m.KB.Checkout),(0,a.R3)(r)}(c,s)})),(0,a.Q6)("sendPaymentForm",((e,t,n)=>{const{shippingOptionId:s,saveCredentials:o}=n,c=(0,r.gx)(e),l=c&&(0,r.Z1)(e,c),d=(0,r.Mz)(e),u=(0,r.eh)(e),m=(0,r.sp)(e),h=(0,r.$$)(e),g=(0,r.i3)(e);l&&d&&h&&u&&async function(e,t,n,s,o,r){if(await(0,C.t9)("sendPaymentForm",{chat:e,messageId:t,formId:n,credentials:s,requestedInfoId:o,shippingOptionId:r})){const e=(0,i.bp)((0,a.Rd)());(0,a.R3)((0,i.WY)(e))}}(l,d,u,{save:o,data:g},m,s)})),(0,a.Q6)("setPaymentStep",(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(0,i.Q$)(e,n.step||m.KB.ShippingInfo)})),(0,a.Q6)("setInvoiceMessageInfo",((e,t,n)=>(0,i.nA)(e,n)));var H=n(647),_=n(3495);const z=728,V=424,X=288;var W=n(3858);function K(e,t){return t-(e.isLeftColumnShown&&!h.wB?e.leftColumnWidth||((n=W.Z.get().width)>s._m?Math.min(Math.max(.25*n,X),.33*n):n>s.ks?Math.min(Math.max(.33*n,X),.4*n):V):0);var n}let Y=0;(0,a.Q6)("loadAvailableReactions",(()=>{(async()=>{const e=await(0,C.t9)("getAvailableReactions");e&&(e.forEach((e=>{e.aroundAnimation&&H.he(`sticker${e.aroundAnimation.id}`,u.IU.Lottie),e.centerIcon&&H.he(`sticker${e.centerIcon.id}`,u.IU.Lottie)})),(0,a.R3)({...(0,a.Rd)(),availableReactions:e}))})()})),(0,a.Q6)("interactWithAnimatedEmoji",((e,t,n)=>{const{emoji:a,x:s,y:o,localEffect:i,startSize:r,isReversed:c}=n,l={id:Y++,animatedEffect:a||i,x:K(e,s)+40*Math.random()-20,y:o+40*Math.random()-20,startSize:r,isReversed:c};return{...e,activeEmojiInteractions:[...e.activeEmojiInteractions||[],l]}})),(0,a.Q6)("sendEmojiInteraction",((e,t,n)=>{const{messageId:a,chatId:s,emoji:o,interactions:i,localEffect:c}=n,l=(0,r.Z1)(e,s);l&&(o||c)&&s!==e.currentUserId&&(0,C.t9)("sendEmojiInteraction",{chat:l,messageId:a,emoticon:o||(0,r.ji)(c),timestamps:i})})),(0,a.Q6)("sendDefaultReaction",((e,t,n)=>{const{chatId:a,messageId:s,x:o,y:i}=n,c=(0,r.q6)(e,a),d=(0,r.hj)(e,a,s);c&&d&&!(0,l.CI)(d)&&t.sendReaction({chatId:a,messageId:s,reaction:c,x:o,y:i})})),(0,a.Q6)("sendReaction",((e,t,n)=>{var a,o,i;const{chatId:c}=n;let{messageId:l}=n,{reaction:d}=n;const u=(0,r.Z1)(e,c);let m=(0,r.hj)(e,c,l);if(!u||!m)return;const h=Boolean(m.groupedId)&&!m.isInAlbum,p=h?(0,r.xH)(e,c,m.groupedId)[0]:void 0;m=h&&(0,r.hj)(e,c,p)||m,l=(null===(a=m)||void 0===a?void 0:a.id)||l,null!==(o=m.reactions)&&void 0!==o&&null!==(i=o.results)&&void 0!==i&&i.some((e=>e.reaction===d&&e.isChosen))&&(d=void 0),(0,C.t9)("sendReaction",{chat:u,messageId:l,reaction:d});const{animationLevel:f}=e.settings.byKey;return f===s.zy&&(e={...e,activeReactions:{...d?e.activeReactions:(0,g.CE)(e.activeReactions,[l]),...d&&{[l]:{reaction:d,messageId:l}}}}),function(e,t,n,a){const{reactions:s}=(0,r.hj)(e,t,n)||{};if(!s)return e;let o=s.results.map((e=>e.reaction===a?{...e,count:e.isChosen?e.count:e.count+1,isChosen:!0}:e.isChosen?{...e,isChosen:!1,count:e.count-1}:e)).filter((e=>e.count>0)),{recentReactions:i}=s;if(a&&!o.some((e=>e.reaction===a))){const{currentUserId:t}=e;o=[...o,{reaction:a,isChosen:!0,count:1}],s.canSeeList&&(i=[...i||[],{userId:t,reaction:a}])}return(0,_.cY)(e,t,n,{reactions:{...s,results:o,recentReactions:i}})}(e,c,l,d)})),(0,a.Q6)("openChat",(e=>({...e,activeReactions:{}}))),(0,a.Q6)("startActiveReaction",((e,t,n)=>{var a;const{messageId:o,reaction:i}=n,{animationLevel:r}=e.settings.byKey;return r!==s.zy||(null===(a=e.activeReactions[o])||void 0===a?void 0:a.reaction)===i?e:{...e,activeReactions:{...i?e.activeReactions:(0,g.CE)(e.activeReactions,[o]),...i&&{[o]:{reaction:i,messageId:o}}}}})),(0,a.Q6)("stopActiveReaction",((e,t,n)=>{var a;const{messageId:s,reaction:o}=n;return(null===(a=e.activeReactions[s])||void 0===a?void 0:a.reaction)!==o?e:{...e,activeReactions:(0,g.CE)(e.activeReactions,[s])}})),(0,a.Q6)("setDefaultReaction",((e,t,n)=>{const{reaction:s}=n;(async()=>{await(0,C.t9)("setDefaultReaction",{reaction:s})&&(e=(0,a.Rd)(),(0,a.R3)({...e,appConfig:{...e.appConfig,defaultReaction:s}}))})()})),(0,a.Q6)("stopActiveEmojiInteraction",((e,t,n)=>{var a;const{id:s}=n;return{...e,activeEmojiInteractions:null===(a=e.activeEmojiInteractions)||void 0===a?void 0:a.filter((e=>e.id!==s))}})),(0,a.Q6)("loadReactors",((e,t,n)=>{var s;const{chatId:o,messageId:c,reaction:l}=n,d=(0,r.Z1)(e,o),u=(0,r.hj)(e,o,c);if(!d||!u)return;const m=null===(s=u.reactors)||void 0===s?void 0:s.nextOffset;(async()=>{var t,n;const s=await(0,C.t9)("fetchMessageReactionsList",{reaction:l,chat:d,messageId:c,offset:m});if(!s)return;e=(0,a.Rd)(),null!==(t=s.users)&&void 0!==t&&t.length&&(e=(0,i.Sh)(e,(0,g.ee)(s.users,"id")));const{nextOffset:r,count:h,reactions:p}=s;(0,a.R3)((0,i.cY)(e,o,c,{reactors:{nextOffset:r,count:h,reactions:[...(null===(n=u.reactors)||void 0===n?void 0:n.reactions)||[],...p]}}))})()})),(0,a.Q6)("loadMessageReactions",((e,t,n)=>{const{ids:a,chatId:s}=n,o=(0,r.Z1)(e,s);o&&(0,C.t9)("fetchMessageReactions",{ids:a,chat:o})})),(0,a.Q6)("sendWatchingEmojiInteraction",((e,t,n)=>{var a;const{chatId:s,emoticon:o,x:i,y:c,startSize:l,isReversed:d,id:u}=n,m=(0,r.Z1)(e,s);if(m&&null!==(a=e.activeEmojiInteractions)&&void 0!==a&&a.some((e=>e.id===u))&&s!==e.currentUserId)return(0,C.t9)("sendWatchingEmojiInteraction",{chat:m,emoticon:o}),{...e,activeEmojiInteractions:e.activeEmojiInteractions.map((t=>t.id===u?{...t,x:K(e,i),y:c,startSize:l,isReversed:d}:t))}})),n(4907);var J=n(8406);function ee(e,t){const n=typeof e;if(n!==typeof t)return!1;if("object"!==n)return e===t;const a=Array.isArray(e);if(a!==Array.isArray(t))return!1;if(a){const n=e,a=t;return n.length===a.length&&n.every(((e,t)=>ee(e,a[t])))}const s=e,o=t;return Object.keys(s).every((e=>ee(s[e],o[e])))}(0,a.Q6)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateChat":{n.noTopChatsRequest||(0,r.N)(e,n.id)||t.loadTopChats();const s=(0,i.a4)(e,n.id,n.chat,n.newProfilePhoto);(0,a.R3)(s),n.chat.id&&(0,J.Vr)({chatId:n.chat.id,lastReadInboxMessageId:n.chat.lastReadInboxMessageId});break}case"updateChatJoin":{const s=(0,r.Ek)(e,n.id);if(!s)break;e=(0,i.B1)(e,s,[n.id]),e=(0,i.a4)(e,n.id,{isNotJoined:!1}),(0,a.R3)(e);const o=(0,r.Z1)(e,n.id);o&&t.requestChatUpdate({chatId:o.id});break}case"updateChatLeave":(0,a.R3)((0,i.Dd)(e,n.id));break;case"updateChatInbox":(0,a.R3)((0,i.a4)(e,n.id,n.chat));break;case"updateChatTypingStatus":{const{id:t,typingStatus:s}=n;(0,a.R3)((0,i.a4)(e,t,{typingStatus:s})),setTimeout((()=>{const e=(0,a.Rd)(),n=(0,r.Z1)(e,t);n&&s&&n.typingStatus&&n.typingStatus.timestamp===s.timestamp&&(0,a.R3)((0,i.a4)(e,t,{typingStatus:void 0}))}),6e3);break}case"newMessage":{const{message:s}=n,{chatId:o,threadId:c,type:l}=(0,r.Bt)(e)||{};if(s.senderId===e.currentUserId&&!s.isFromScheduled)return;const d=(0,r.Z1)(e,n.chatId);if(!d)return;"thread"===l&&c===u._f&&n.chatId===o?setTimeout((()=>{t.requestChatUpdate({chatId:n.chatId})}),1500):(0,a.R3)((0,i.a4)(e,n.chatId,{unreadCount:d.unreadCount?d.unreadCount+1:1,...n.message.hasUnreadMention&&{unreadMentionsCount:d.unreadMentionsCount?d.unreadMentionsCount+1:1}})),(0,J.rh)({chat:d,message:s});break}case"updateMessage":{const{message:t}=n,a=(0,r.Z1)(e,n.chatId);if(!a)return;(0,l.dT)(t)&&(0,J.rh)({chat:a,message:t});break}case"updateCommonBoxMessages":case"updateChannelMessages":{const{ids:t,messageUpdate:s}=n;if(!1!==s.hasUnreadMention)return;t.forEach((t=>{const a="channelId"in n?n.channelId:(0,r.X5)(e,t),s=(0,r.Z1)(e,a);null!=s&&s.unreadMentionsCount&&(e=(0,i.a4)(e,a,{unreadMentionsCount:s.unreadMentionsCount-1}))})),(0,a.R3)(e);break}case"updateChatFullInfo":{const{fullInfo:t}=n,s=e.chats.byId[n.id];if(!s)return;(0,a.R3)((0,i.a4)(e,n.id,{fullInfo:{...s.fullInfo,...t}}));break}case"updatePinnedChatIds":{const{ids:t,folderId:o}=n,i=o===s.WS?"archived":"active";e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[i]:t.length?t:void 0}}},(0,a.R3)(e);break}case"updateChatPinned":{const{id:t,isPinned:o}=n,i=(0,r.Ek)(e,t);if(i){const{[i]:n}=e.chats.orderedPinnedIds;let a=n||[];if(o){if(!a.includes(t)){if("active"===i&&a.length>=s.EG){const t=e.chats.listIds.active;a=a.filter((e=>t&&t.includes(e)))}a=[t,...a]}}else a=a.filter((e=>e!==t));e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[i]:a.length?a:void 0}}}}(0,a.R3)(e);break}case"updateChatListType":{const{id:t,folderId:s}=n;(0,a.R3)((0,i.Pi)(e,t,s));break}case"updateChatFolder":{const{id:t,folder:s}=n,{byId:o,orderedIds:i}=e.chatFolders,r=s?{...o,[t]:s}:(0,g.ei)(o,Object.keys(o).map(Number).filter((e=>e!==t))),c=s?i&&i.includes(t)?i:[...i||[],t]:i?i.filter((e=>e!==t)):void 0;(0,a.R3)({...e,chatFolders:{...e.chatFolders,byId:r,orderedIds:c}});break}case"updateChatFoldersOrder":{const{orderedIds:t}=n;(0,a.R3)({...e,chatFolders:{...e.chatFolders,orderedIds:t}});break}case"updateRecommendedChatFolders":{const{folders:t}=n;(0,a.R3)({...e,chatFolders:{...e.chatFolders,recommended:t}});break}case"updateChatMembers":{var o;const t=e.chats.byId[n.id],{replacedMembers:s,addedMember:r,deletedMemberId:c}=n;if(!t)return;let l=!1,d=null!==(o=t.fullInfo)&&void 0!==o&&o.members?[...t.fullInfo.members]:[];if(s)d=s,l=!0;else if(r)d.length&&d.some((e=>e.userId===r.userId))||(d.push(r),l=!0);else if(d.length&&c){const e=d.findIndex((e=>e.userId===c));e>-1&&(d.slice(e,1),l=!0)}if(l){const s=d.filter((e=>{let{isOwner:t,isAdmin:n}=e;return t||n}));(0,a.R3)((0,i.a4)(e,n.id,{membersCount:d.length,fullInfo:{...t.fullInfo,members:d,adminMembers:s}}))}break}case"deleteProfilePhotos":{const{chatId:t,ids:s}=n,o=e.chats.byId[t];null!=o&&o.photos&&(0,a.R3)((0,i.a4)(e,t,{photos:o.photos.filter((e=>!s.includes(e.id)))}));break}case"draftMessage":{const{chatId:t,formattedText:s,date:o,replyingToId:r}=n;e.chats.byId[t]&&(e=(0,i.pf)(e,t,u._f,"draft",s),e=(0,i.pf)(e,t,u._f,"replyingToId",r),e=(0,i.a4)(e,t,{draftDate:o}),(0,a.R3)(e));break}case"showInvite":{const{data:e}=n;t.showDialog({data:e});break}case"updatePendingJoinRequests":{const{chatId:s,requestsPending:o,recentRequesterIds:r}=n,c=e.chats.byId[s];c&&(e=(0,i.a4)(e,s,{fullInfo:{...c.fullInfo,requestsPending:o,recentRequesterIds:r}}),(0,a.R3)(e),t.loadChatJoinRequests({chatId:s}))}}}));var te=n(3995);const ne=350;function ae(e,t,n,a){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const o=s?(0,r.Tm)(e,t,n):(0,r.hj)(e,t,n);if(o&&a.content){const{photo:e,video:t,sticker:n,document:s}=(0,l.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,i.P4)(e,t,n,a):(0,i.cY)(e,t,n,a)}function se(e,t,n,a){const{chatId:s}=n,{threadInfo:o}=(0,r.Db)(e,s,n)||{};if(!o&&n.replyToMessageId){const o=(0,r.hj)(e,s,n.replyToMessageId);o?e=(0,i.lG)(e,o,s,n.id,a):t.loadMessage({chatId:s,messageId:n.replyToMessageId,threadUpdate:{isDeleting:a,lastMessageId:n.id}})}return e}function oe(e,t,n){const{id:a,chatId:s}=n,{threadInfo:o,firstMessageId:c}=(0,r.Db)(e,s,n)||{},d=(0,r.Z1)(e,s),m=(null==d?void 0:d.unreadCount)&&!(0,r.gb)(e,s,u._f);if(e=se(e,t,n),o&&(!c&&(0,l.CI)(n)||(e=(0,i.xj)(e,s,o.threadId,[a]),(0,r.b9)(e,s,o.threadId)&&(e=(0,i.$S)(e,s,o.threadId,a),c||(e=(0,i.pf)(e,s,o.threadId,"firstMessageId",n.id)))),e=(0,i.pf)(e,s,o.threadId,"threadInfo",{...o,lastMessageId:n.id,messagesCount:o.messagesCount+1})),m)return e;if(e=(0,i.xj)(e,s,u._f,[a]),(0,r.b9)(e,s,u._f)){const t=(0,r.It)(e,s,u._f),n=(0,i.$S)(e,s,u._f,a),o=(0,r.Cb)(n,s,u._f);t&&!o.includes(t)||(e=n)}return e}function ie(e,t,n){var a;let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const{chats:o}=e,r=null===(a=o.byId[t])||void 0===a?void 0:a.lastMessage;return!r||s||r.id===n.id||r.id===n.previousLocalId||n.id>r.id?(0,i.a4)(e,t,{lastMessage:n}):e}function re(e,t){const n=(0,r.Zw)(e,t),a=(0,r.gb)(e,t,u._f);if(!n||!a)return;let s=a.length;for(;s--;){const e=n[a[s]];if(!e.isDeleting)return e}}function ce(e,t,n,s){if(e){t.forEach((t=>{const n=re(s=(0,i.cY)(s,e,t,{isDeleting:!0}),e);n&&(s=ie(s,e,n,!0))})),(0,a.R3)(s),n.requestChatUpdate({chatId:e});const o=[];return t.forEach((t=>{const a=(0,r.hj)(s,e,t);if(!a)return;s=se(s,n,a,!0);const{threadInfo:i}=(0,r.Db)(s,e,a)||{};i&&o.push(i.threadId)})),(0,a.R3)(s),void setTimeout((()=>{(0,a.R3)((0,i.K4)((0,a.Rd)(),e,t)),(0,g.Tw)(o).forEach((t=>{n.requestThreadInfoUpdate({chatId:e,threadId:t})}))}),ne)}const o=[];t.forEach((e=>{const t=(0,r.X5)(s,e);if(t){o.push(t);const n=re(s=(0,i.cY)(s,t,e,{isDeleting:!0}),t);n&&(s=ie(s,t,n,!0)),setTimeout((()=>{(0,a.R3)((0,i.K4)((0,a.Rd)(),t,[e]))}),ne)}})),(0,a.R3)(s),(0,g.Tw)(o).forEach((e=>{n.requestChatUpdate({chatId:e})}))}(0,a.Q6)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"newMessage":{const{chatId:o,id:c,message:d,shouldForceReply:m}=n;e=oe(e=ae(e,o,c,d),t,d),d.threadInfo&&(e=(0,i.Xg)(e,d.threadInfo.chatId,d.threadInfo.threadId,d.threadInfo)),(0,a.R3)(e);const h=(0,r.hj)(e,o,c);if((0,r.hg)(e,o,d)){var s;if(d.isOutgoing&&(null===(s=d.content)||void 0===s||!s.action)){const n=(0,r.Bt)(e);n&&t.focusMessage({chatId:o,threadId:n.threadId,messageId:d.id,noHighlight:!0,isResizingContainer:!0})}const{threadInfo:n}=(0,r.Db)(e,o,d)||{};n&&t.requestThreadInfoUpdate({chatId:o,threadId:n.threadId}),(0,l.CI)(d)||setTimeout((()=>{let e=(0,a.Rd)();m&&(e=(0,i.pf)(e,o,u._f,"replyingToId",c)),(0,a.R3)(ie(e,o,h))}),ne)}else(0,a.R3)(ie((0,a.Rd)(),o,h));(0,r.N)(e,o)||t.loadTopChats();break}case"updateStartEmojiInteraction":{var o;const{chatId:t}=(0,r.Bt)(e)||{};if(t!==n.id)return;const s=(0,r.hj)(e,t,n.messageId);if(!s)return;if((0,l.UD)(s)!==n.emoji)return;const i=(0,r.CP)(e,n.emoji);e={...e,activeEmojiInteractions:[...e.activeEmojiInteractions||[],{id:(null===(o=e.activeEmojiInteractions)||void 0===o?void 0:o.length)||0,animatedEffect:i?(0,r.cu)(i):n.emoji,messageId:n.messageId}]},(0,a.R3)(e);break}case"newScheduledMessage":{const{chatId:t,id:s,message:o}=n;e=ae(e,t,s,o,!0);const c=(0,r.qy)(e,t)||[];e=(0,i.pf)(e,t,u._f,"scheduledIds",(0,g.Tw)([...c,s])),(0,a.R3)(e);break}case"updateMessage":{var c,d;const{chatId:s,id:o,message:l}=n;if(!(0,r.hj)(e,s,o))return;e=ae(e,s,o,l);const m=(0,r.hj)(e,s,o);l.threadInfo&&(e=(0,i.Xg)(e,l.threadInfo.chatId,l.threadInfo.threadId,l.threadInfo)),e=ie(e,s,m),(0,a.R3)(e);const h=(0,r.Z1)(e,s);h&&!l.isOutgoing&&(null===(c=h.lastMessage)||void 0===c?void 0:c.id)===l.id&&(0,r.xo)(e,h)&&(0,r.hg)(e,s,l)&&(0,r.b9)(e,s,(null===(d=l.threadInfo)||void 0===d?void 0:d.threadId)||u._f)&&t.focusLastMessage();break}case"updateScheduledMessage":{const{chatId:t,id:s,message:o}=n;if(!(0,r.Tm)(e,t,s))return;e=ae(e,t,s,o,!0);const c=Object.keys((0,r.Fn)(e,t)||{}).map(Number).sort(((e,t)=>t-e));e=(0,i.pf)(e,t,u._f,"scheduledIds",c),(0,a.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:s,localId:o,message:c}=n;e=oe(e,t,c);const l=(0,r.hj)(e,s,o);e=(0,i.K4)(e,s,[o]),c.isScheduled&&(e=(0,i.bV)(e,s,[o])),e=(0,i.cY)(e,s,c.id,{...l,...c,previousLocalId:o});const d=(0,r.hj)(e,s,c.id);e=ie(e,s,d);const u=(0,r.Db)(e,s,c);null!=u&&u.threadInfo&&(t.markMessageListRead({maxId:c.id}),e=(0,i.pf)(e,s,u.threadInfo.threadId,"threadInfo",{...u.threadInfo,lastMessageId:c.id,lastReadInboxMessageId:c.id})),(0,a.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:s,message:o}=n,c=(0,r.qy)(e,t)||[];e=(0,i.pf)(e,t,u._f,"scheduledIds",[...c,o.id]);const l=(0,r.Tm)(e,t,s);e=(0,i.bV)(e,t,[s]),e=(0,i.P4)(e,t,o.id,{...l,...o,previousLocalId:s}),(0,a.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:s,messageIds:o}=n,c=(0,r.KB)(e,t)||[],l=s?[...c,...o].sort(((e,t)=>t-e)):c.filter((e=>!o.includes(e)));(0,a.R3)((0,i.pf)(e,t,u._f,"pinnedIds",l));break}case"updateThreadInfo":{const{chatId:t,threadId:s,threadInfo:o,firstMessageId:c}=n,l={...(0,r.tZ)(e,t,s),...o};if(!l.threadId)return;e=(0,i.Xg)(e,t,s,l),c&&(e=(0,i.pf)(e,t,s,"firstMessageId",c)),(0,a.R3)(e);break}case"resetMessages":{const{id:s}=n,o=(0,r.Zw)(e,s);o&&!(0,l.YC)(s)&&(e=(0,i.K4)(e,s,Object.keys(o).map(Number)),(0,a.R3)(e),t.loadFullChat({chatId:s,force:!0}));break}case"deleteMessages":{const{ids:a,chatId:s}=n;ce(s,a,t,e);break}case"deleteScheduledMessages":{const{ids:t,chatId:s}=n;!function(e,t,n,s){e&&(t.forEach((t=>{s=(0,i.P4)(s,e,t,{isDeleting:!0})})),(0,a.R3)(s),setTimeout((()=>{s=(0,i.bV)((0,a.Rd)(),e,t);const n=(0,r.Fn)(s,e);s=(0,i.pf)(s,e,u._f,"scheduledIds",Object.keys(n||{}).map(Number)),(0,a.R3)(s)}),ne))}(s,t,0,e);break}case"deleteHistory":{const{chatId:a}=n,s=e.messages.byChatId[a];s?ce(a,Object.keys(s.byId).map(Number),t,e):t.requestChatUpdate({chatId:a});break}case"updateCommonBoxMessages":{const{ids:t,messageUpdate:s}=n;t.forEach((t=>{const n=(0,r.X5)(e,t);n&&(e=(0,i.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,i.cY)(e,t,n,o)})),(0,a.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:s}=n,o=(0,r.ZB)(e,t);if(null!=o&&o.content.poll){const t={...o.content.poll,...s},{results:n}=t.results||{};if(n&&!n.some((e=>e.isChosen))){const{results:e}=o.content.poll.results,a=e&&e.filter((e=>e.isChosen));a&&a.forEach((e=>{const a=n.findIndex((t=>t.option===e.option));a>=0&&(t.results.results[a].isChosen=!0)}))}(0,a.R3)((0,i.cY)(e,o.chatId,o.id,{content:{...o.content,poll:t}}))}break}case"updateMessagePollVote":{const{pollId:t,userId:s,options:o}=n,c=(0,r.ZB)(e,t);if(!c||!c.content.poll||!c.content.poll.results)break;const{poll:l}=c.content,{recentVoterIds:d,totalVoters:u,results:m}=l.results,h=d?[...d]:[],g=u?u+1:1,p=m?[...m]:[];h.push(s),o.forEach((t=>{const n=p.find((e=>e.option===t)),a=p.findIndex((e=>e.option===t)),o=n?{...n}:{option:t,votersCount:0};o.votersCount+=1,s===e.currentUserId&&(o.isChosen=!0),a?p[a]=o:p.push(o)})),(0,a.R3)((0,i.cY)(e,c.chatId,c.id,{content:{...c.content,poll:{...l,results:{...l.results,recentVoterIds:h,totalVoters:g,results:p}}}}));break}case"updateServiceNotification":{const{message:a}=n;(0,r.UW)(e)&&t.createServiceNotification({message:a});break}case"updateMessageReactions":{const{chatId:t,id:s,reactions:o}=n,c=(0,r.hj)(e,t,s),l=(0,r.Z1)(e,n.chatId),d=null==c?void 0:c.reactions;if(d&&ee(o,d))return;const u=(0,te.l)(d,o);if(e=(0,i.cY)(e,t,s,{reactions:n.reactions}),u){const n=(0,r.hj)(e,t,s);if(!l||!n)return;(0,J.rh)({chat:l,message:n})}(0,a.R3)(e);break}}}));const le=(0,w.P2)((function(){const e=(0,a.Rd)();(0,a.R3)((0,i.ps)(e,{...e.users.statusesById,...de})),de={}}),3e3,!0);let de={};(0,a.Q6)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"deleteContact":return(0,i.GK)(e,n.id);case"updateUser":return(0,i.Nq)(e,n.id,n.user);case"updateUserStatus":return a=n.userId,s=n.status,de[a]=s,void le();case"updateUserFullInfo":{const{id:t,fullInfo:a}=n,s=e.users.byId[t];if(!s)return;return(0,i.Nq)(e,t,{fullInfo:{...s.fullInfo,...a}})}}var a,s})),(0,a.Q6)("apiUpdate",((e,t,n)=>{if("updateStickerSet"===n["@type"])return(0,i.Rg)(e,n.id,n.stickerSet)})),(0,a.Q6)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updatePeerBlocked":return n.isBlocked?(0,i.O4)((0,a.Rd)(),n.id):(0,i.rB)((0,a.Rd)(),n.id);case"updateResetContactList":(0,a.R3)({...(0,a.Rd)(),contactList:{userIds:[]}});break;case"updateFavoriteStickers":t.loadFavoriteStickers();break;case"updatePrivacy":e.settings.privacy[n.key]=n.rules}})),(0,a.Q6)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateNotifySettings":return(0,i.HN)(e,n.peerType,n.isSilent,n.shouldShowPreviews);case"updateNotifyExceptions":{const{chatId:t,isMuted:s,isSilent:o,shouldShowPreviews:r}=n;e.chats.byId[t]&&(e=(0,i.a4)(e,t,{isMuted:s})),(0,a.R3)((0,i.aK)(e,t,{isMuted:s,isSilent:o,shouldShowPreviews:r}));break}}})),(0,a.Q6)("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 ue=n(4446);(0,a.Q6)("apiUpdate",((e,t,n)=>{switch(n["@type"]){case"updateGroupCall":return"discarded"===n.call.connectionState?e.groupCalls.activeGroupCallId?void t.leaveGroupCall({shouldRemove:!0}):(0,ue.dc)(e,n.call.id):(0,ue.AH)(e,n.call.id,(0,g.CE)(n.call,["connectionState"]),void 0,n.call.participantsCount);case"updateGroupCallChatId":{const t=(0,r.Z1)(e,n.chatId);return t&&(e=(0,i.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;return e=(0,a.Rd)(),s.forEach((n=>{n.id&&(e=(0,ue.B6)(e,t,n.id,n,Boolean(o)||i===n.id))})),o&&(e=(0,ue.AH)(e,t,{nextOffset:o})),e}}}));var me=n(8674),he=n(6752),ge=n(1279),pe=n(3551),fe=n(3227),ve=n(1212),Ie=n(5332);function ye(e){(0,o.d4)((()=>(0,w.Gq)(e)),[e])}var Ze=n(9290);const Pe=document.querySelector('meta[name="viewport"]'),Ce=(null==Pe?void 0:Pe.getAttribute("content"))||"",we="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover";function be(e){e.preventDefault()}var Ee=n(6590),Me=n(4851),Se=n(2155),Re=n(5616),ke=n(7358);const Te=(0,o.X$)((e=>{let{isForAppBadge:t}=e;(0,Re.yi)();const n=(0,O.xW)();if((0,o.d4)((()=>{t&&(0,ke.w)(n)}),[t,n]),!t&&n)return o.ZP.createElement("div",{className:"unread-count active"},(0,Se.bi)(n))}));var Ne=n(3989),Be=n(7529),Ae=n(3455),xe=n(706),Le=n(2255),Oe=n(9107),Fe=n(7370),Ue=n(7926),$e=n(1622);let De;function je(e,t,n,a,s,i){let r,c,l;return r=function(){const[e,t]=(0,o.eJ)(window.navigator.onLine);return(0,o.d4)((()=>{function e(){t(window.navigator.onLine)}return window.addEventListener("online",e),window.addEventListener("offline",e),()=>{window.removeEventListener("offline",e),window.removeEventListener("online",e)}}),[]),e}()&&"connectionStateConnecting"!==t?n?De.syncing:De.online:De.waitingForNetwork,c=r===De.online||i?"none":a?"middleHeader":s?"minimized":"overlay",r===De.waitingForNetwork?l=e("WaitingForNetwork"):r===De.syncing&&(l=e("Updating")),"middleHeader"===c&&(l=l.toLowerCase().replace(/\.+$/,"")),{connectionStatus:r,connectionStatusPosition:c,connectionStatusText:l}}!function(e){e[e.waitingForNetwork=0]="waitingForNetwork",e[e.syncing=1]="syncing",e[e.online=2]="online"}(De||(De={}));var qe=n(3106),Qe=n(8964),Ge=n(231),He=n(9589),_e=n(9187),ze=n(3321),Ve=n(126),Xe=n(9204);const We=(0,o.X$)((e=>{let{connectionStatus:t,connectionStatusText:n,onClick:a}=e;const s=(0,Oe.Z)();return o.ZP.createElement("div",{id:"ConnectionStatusOverlay",dir:s.isRtl?"rtl":void 0,onClick:a},o.ZP.createElement(Xe.Z,{color:"black"}),o.ZP.createElement("div",{className:"state-text"},o.ZP.createElement(Le.Z,{activeKey:t,name:"slide-fade"},(()=>n))),o.ZP.createElement(Ge.Z,{round:!0,size:"tiny",color:"translucent-black"},o.ZP.createElement("span",{className:"icon-close"})))})),Ke=[0,1,2],Ye=(0,o.X$)((0,a.c$)((e=>{const{query:t,fetchingStatus:n,chatId:a,date:s}=e.globalSearch,{currentUserId:o,connectionState:i,isSyncing:c}=e,{byId:l}=e.chats,{isConnectionStatusMinimized:d,animationLevel:u}=e.settings.byKey;return{searchQuery:t,isLoading:!!n&&Boolean(n.chats||n.messages),currentUserId:o,chatsById:l,globalSearchChatId:a,searchDate:s,theme:(0,r.Pu)(e),animationLevel:u,connectionState:i,isSyncing:c,isMessageListOpen:Boolean((0,r.Bt)(e)),isConnectionStatusMinimized:d,areChatsLoaded:Boolean(e.chats.listIds.active)}}))((e=>{let{content:t,contactsFilter:n,onSearchQuery:i,onSelectSettings:r,onSelectContacts:c,onSelectArchived:d,onReset:u,searchQuery:g,isLoading:p,shouldSkipTransition:f,currentUserId:v,globalSearchChatId:I,searchDate:y,theme:Z,animationLevel:P,chatsById:C,connectionState:w,isSyncing:b,isMessageListOpen:E,isConnectionStatusMinimized:M,areChatsLoaded:S}=e;const{openChat:R,openTipsChat:k,setGlobalSearchDate:T,setSettingOption:N,setGlobalSearchChatId:A}=(0,a.uC)(),x=(0,Oe.Z)(),L=t===m.du.ChatList,O=(0,o.Ye)((()=>y?(0,B.xH)(new Date(1e3*y)):void 0),[y]),F=(0,o.Ye)((()=>L&&C?Object.values(C).reduce(((e,t)=>(0,l.pE)(t)&&t.unreadCount?e+1:e),0):0),[L,C]),{connectionStatus:U,connectionStatusText:$,connectionStatusPosition:D}=je(x,w,b,E,M,!S),j="web.telegram.org"===window.location.hostname,q=(0,o.Ye)((()=>e=>{let{onTrigger:t,isOpen:n}=e;return o.ZP.createElement(Ge.Z,{round:!0,ripple:L&&!h.wB,size:"smaller",color:"translucent",className:n?"active":"",onClick:L?t:()=>u(),ariaLabel:L?x("AccDescrOpenMenu2"):"Return to chat list"},o.ZP.createElement("div",{className:(0,he.Z)("animated-menu-icon",!L&&"state-back",f&&"no-animation")}))}),[L,x,u,f]),Q=(0,o.I4)((()=>{g||i("")}),[g,i]),G=(0,o.I4)((()=>{N({isConnectionStatusMinimized:!M})}),[M,N]),H=(0,o.I4)((()=>{R({id:v,shouldReplaceHistory:!0})}),[v,R]),_=(0,o.I4)((e=>{e.stopPropagation();const t="light"===Z?"dark":"light";N({theme:t}),N({shouldUseSystemTheme:!1}),(0,Fe.Z)(t,P===s.zy)}),[P,N,Z]),z=(0,o.I4)((e=>{e.stopPropagation();const t=0===P?2:0;Ke.forEach(((e,n)=>{document.body.classList.toggle(`animation-level-${n}`,t===n)})),N({animationLevel:t})}),[P,N]),V=Boolean(I)||t===m.du.GlobalSearch||t===m.du.Contacts,X=t===m.du.Contacts?x("SearchFriends"):x("Search");return o.ZP.createElement("div",{className:"LeftMainHeader"},o.ZP.createElement("div",{id:"LeftMainHeader",className:"left-header"},o.ZP.createElement(qe.Z,{trigger:q,footer:`${s.iC} ${s.eM?s.BI:s.Ji}`},o.ZP.createElement(Qe.Z,{icon:"saved-messages",onClick:H},x("SavedMessages")),o.ZP.createElement(Qe.Z,{icon:"archive",onClick:d},o.ZP.createElement("span",{className:"menu-item-name"},x("ArchivedChats")),F>0&&o.ZP.createElement("div",{className:"archived-badge"},F)),o.ZP.createElement(Qe.Z,{icon:"user",onClick:c},x("Contacts")),o.ZP.createElement(Qe.Z,{icon:"settings",onClick:r},x("Settings")),o.ZP.createElement(Qe.Z,{icon:"darkmode",onClick:_},o.ZP.createElement("span",{className:"menu-item-name"},x("lng_menu_night_mode")),o.ZP.createElement(ze.Z,{id:"darkmode",label:x("dark"===Z?"lng_settings_disable_night_theme":"lng_settings_enable_night_theme"),checked:"dark"===Z,noAnimation:!0})),o.ZP.createElement(Qe.Z,{icon:"animations",onClick:z},o.ZP.createElement("span",{className:"menu-item-name capitalize"},x("Appearance.Animations").toLowerCase()),o.ZP.createElement(ze.Z,{id:"animations",label:"Toggle Animations",checked:P>0})),o.ZP.createElement(Qe.Z,{icon:"help",onClick:()=>{k({langCode:x.code})}},x("TelegramFeatures")),o.ZP.createElement(Qe.Z,{icon:"bug",href:s.mU},"Report Bug"),j&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Qe.Z,{icon:"char-K",href:"https://web.telegram.org/k/",onClick:()=>{(0,Ue.L)("K"),(0,$e.W8)(),(0,Ee.Wv)()}},"Switch to K Version"),o.ZP.createElement(Qe.Z,{icon:"char-W",href:"https://web.telegram.org/?legacy=1",onClick:Ee.Wv},"Switch to Old Version"))),o.ZP.createElement(He.Z,{inputId:"telegram-search-input",parentContainerClassName:"LeftSearch",className:I||y?"with-picker-item":"",value:n||g,focused:V,isLoading:p||"minimized"===D,spinnerColor:"minimized"===D?"yellow":void 0,spinnerBackgroundColor:"minimized"===D&&"light"===Z?"light":void 0,placeholder:X,autoComplete:"off",canClose:Boolean(I||y),onChange:i,onReset:u,onFocus:Q,onSpinnerClick:"minimized"===D?G:void 0},O&&o.ZP.createElement(_e.Z,{icon:"calendar",title:O,canClose:!0,isMinimized:Boolean(I),className:"search-date",onClick:T,clickArg:{date:void 0}}),I&&o.ZP.createElement(_e.Z,{chatOrUserId:I,onClick:A,canClose:!0,clickArg:{id:void 0}})),o.ZP.createElement(Ve.Z,{isOpen:"overlay"===D,isCustom:!0,className:"connection-state-wrapper"},(()=>o.ZP.createElement(We,{connectionStatus:U,connectionStatusText:$,onClick:G})))))})));var Je=n(1174),et=n(3133),tt=n(1080);const nt=(0,o.X$)((0,a.c$)((e=>{const{chatFolders:{byId:t,orderedIds:n,activeChatFolder:a},currentUserId:s,lastSyncTime:o,shouldSkipHistoryAnimations:i}=e;return{chatFoldersById:t,orderedFolderIds:n,activeChatFolder:a,currentUserId:s,lastSyncTime:o,shouldSkipHistoryAnimations:i}}))((e=>{let{foldersDispatch:t,onScreenSelect:n,chatFoldersById:i,orderedFolderIds:r,activeChatFolder:c,currentUserId:l,lastSyncTime:d,shouldSkipHistoryAnimations:u}=e;const{loadChatFolders:m,setActiveChatFolder:g,openChat:p}=(0,a.uC)(),f=(0,o.sO)(null),v=(0,Oe.Z)();(0,o.d4)((()=>{d&&m()}),[d,m]);const I=(0,o.Ye)((()=>r?r.map((e=>i[e]||{})).filter(Boolean):void 0),[i,r]),y=(0,Re.yi)(),Z=(0,o.Ye)((()=>{if(I&&I.length)return[{id:s.Nf,title:"en"===v.code?"All":v("FilterAllChats")},...I.map((e=>{var t,n;let{id:a,title:s}=e;return{id:a,title:s,badgeCount:null===(t=y[a])||void 0===t?void 0:t.chatsCount,isBadgeActive:Boolean(null===(n=y[a])||void 0===n?void 0:n.notificationsCount)}}))]}),[I,y,v]),P=(0,o.I4)((e=>{g(e,{forceOnHeavyAnimation:!0})}),[g]);(0,o.d4)((()=>{Z&&Z.length&&c>=Z.length&&g(0)}),[c,Z,g]),(0,o.d4)((()=>{if(f.current&&h.$b&&Z&&Z.length)return(0,Je.sf)(f.current,{selectorToPreventScroll:".chat-list",onSwipe:(e,t)=>t===Je.eM.Left?(g(Math.min(c+1,Z.length-1),{forceOnHeavyAnimation:!0}),!0):t===Je.eM.Right&&(g(Math.max(0,c-1),{forceOnHeavyAnimation:!0}),!0)})}),[c,Z,g]);const C=(0,o.sO)();C.current=0!==c,(0,o.d4)((()=>C.current?(0,Ne.Z)((()=>{C.current&&g(0)})):void 0),[c,g]),(0,Ee.ZP)(0!==c,(()=>g(0,{forceOnHeavyAnimation:!0}))),(0,o.d4)((()=>{const e=e=>{if(e.ctrlKey&&e.shiftKey&&e.code.startsWith("Digit")&&Z){const[,t]=e.code.match(/Digit(\d)/)||[];if(!t)return;if("0"===t)return void p({id:l,shouldReplaceHistory:!0});const n=Number(t)-1;if(n>Z.length-1)return;g(n,{forceOnHeavyAnimation:!0}),e.preventDefault()}};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}}));const{shouldRender:w,transitionClassNames:b}=(0,ve.Z)(!r,void 0,!0);function E(e){const a=Object.values(i).find((e=>{let{id:t}=e;return t===Z[c].id}));return a&&0!==c?o.ZP.createElement(tt.Z,{folderType:"folder",folderId:a.id,isActive:e,lastSyncTime:d,onScreenSelect:n,foldersDispatch:t}):o.ZP.createElement(tt.Z,{folderType:"all",isActive:e,lastSyncTime:d,foldersDispatch:t,onScreenSelect:n})}return o.ZP.createElement("div",{className:"ChatFolders"},null!=Z&&Z.length?o.ZP.createElement(et.Z,{tabs:Z,activeTab:c,onSwitchTab:P}):w?o.ZP.createElement("div",{className:(0,he.Z)("tabs-placeholder",b)}):void 0,o.ZP.createElement(Le.Z,{ref:f,name:u?"none":v.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:c,renderCount:Z?Z.length:void 0},E))})));var at=n(9203),st=n(8778),ot=n(4288);const it=(0,o.X$)((e=>{const t=(0,st.Z)(at.gl.Extra,"LeftSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(ot.Z,null)})),rt=(0,o.X$)((e=>{const t=(0,st.Z)(at.gl.Extra,"ContactList");return t?o.ZP.createElement(t,e):o.ZP.createElement(ot.Z,null)}));var ct=n(2328);const lt=(0,o.X$)((e=>{let{isShown:t,onNewPrivateChat:n,onNewChannel:a,onNewGroup:s}=e;const[i,r]=(0,o.eJ)(!1);(0,o.d4)((()=>{t||r(!1)}),[t]);const c=(0,Oe.Z)(),l=(0,he.Z)("NewChatButton",t&&"revealed",i&&"menu-is-open");return o.ZP.createElement("div",{className:l},o.ZP.createElement(Ge.Z,{round:!0,color:"primary",className:i?"active":"",onClick:()=>{r(!i)},ariaLabel:c(i?"Close":"NewMessageTitle"),tabIndex:-1},o.ZP.createElement("i",{className:"icon-new-chat-filled"}),o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(ct.Z,{isOpen:i,positionX:"right",positionY:"bottom",autoClose:!0,onClose:()=>{r(!1)}},o.ZP.createElement(Qe.Z,{icon:"channel",onClick:a},c("NewChannel")),o.ZP.createElement(Qe.Z,{icon:"group",onClick:s},c("NewGroup")),o.ZP.createElement(Qe.Z,{icon:"user",onClick:n},c("NewMessageTitle"))))})),dt=Object.keys(m.du).length/2;let ut;const mt=(0,o.X$)((e=>{let{content:t,searchQuery:n,searchDate:a,contactsFilter:s,shouldSkipTransition:i,foldersDispatch:r,onSearchQuery:c,onContentChange:l,onScreenSelect:d,onReset:u}=e;const[g,p]=(0,o.eJ)(h.$b),f=(0,o.sO)(!1),v=(0,o.I4)((()=>{l(m.du.Settings)}),[l]),I=(0,o.I4)((()=>{l(m.du.Contacts)}),[l]),y=(0,o.I4)((()=>{l(m.du.NewChannelStep1)}),[l]),Z=(0,o.I4)((()=>{l(m.du.NewGroupStep1)}),[l]),P=(0,o.I4)((()=>{l(m.du.Archived)}),[l]),C=(0,o.I4)((()=>{t===m.du.ChatList&&(f.current=!0,p(!0))}),[t]),w=(0,o.I4)((()=>{f.current=!1,ut&&(clearTimeout(ut),ut=void 0),ut=window.setTimeout((()=>{f.current||p(!1)}),250)}),[]);(0,o.d4)((()=>{let e;return t!==m.du.ChatList?e=window.setTimeout((()=>{p(!1)}),250):(f.current||h.$b)&&p(!0),()=>{e&&(clearTimeout(e),e=void 0)}}),[t]);const[b,E,M]=function(){const[e,t]=(0,xe.Z)(!1);(0,o.d4)((()=>{const e=window.setTimeout(t,2592e5);return()=>{clearTimeout(e)}}),[t]);const{shouldRender:n,transitionClassNames:a}=(0,ve.Z)(e);return[n,a,()=>{window.location.reload()}]}(),S=(0,Oe.Z)();return o.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:h.$b?void 0:C,onMouseLeave:h.$b?void 0:w},o.ZP.createElement(Ye,{content:t,contactsFilter:s,onSearchQuery:c,onSelectSettings:v,onSelectContacts:I,onSelectArchived:P,onReset:u,shouldSkipTransition:i}),o.ZP.createElement(Le.Z,{name:i?"none":"zoom-fade",renderCount:dt,activeKey:t,shouldCleanup:!0,cleanupExceptionKey:m.du.ChatList},(e=>{switch(t){case m.du.ChatList:return o.ZP.createElement(nt,{onScreenSelect:d,foldersDispatch:r});case m.du.GlobalSearch:return o.ZP.createElement(it,{searchQuery:n,searchDate:a,isActive:e,onReset:u});case m.du.Contacts:return o.ZP.createElement(rt,{filter:s,isActive:e,onReset:u});default:return}})),b&&o.ZP.createElement(Ge.Z,{fluid:!0,pill:!0,className:(0,he.Z)("btn-update",E),onClick:M},S("lng_update_telegram")),o.ZP.createElement(lt,{isShown:g,onNewPrivateChat:I,onNewChannel:y,onNewGroup:Z}))})),ht=(0,o.X$)((e=>{const t=(0,st.Z)(at.gl.Extra,"Settings");return t?o.ZP.createElement(t,e):o.ZP.createElement(ot.Z,null)})),gt=(0,o.X$)((e=>{const t=(0,st.Z)(at.gl.Extra,"NewChat");return t?o.ZP.createElement(t,e):o.ZP.createElement(ot.Z,null)})),pt=(0,o.X$)((e=>{const t=(0,st.Z)(at.gl.Extra,"ArchivedChats");return t?o.ZP.createElement(t,e):o.ZP.createElement(ot.Z,null)}));var ft;!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"}(ft||(ft={}));const vt=Object.keys(ft).length/2,It=(0,o.X$)((0,a.c$)((e=>{const{globalSearch:{query:t,date:n},chatFolders:{activeChatFolder:a},shouldSkipHistoryAnimations:s,leftColumnWidth:o}=e;return{searchQuery:t,searchDate:n,activeChatFolder:a,shouldSkipHistoryAnimations:s,leftColumnWidth:o}}))((e=>{let{searchQuery:t,searchDate:n,activeChatFolder:s,shouldSkipHistoryAnimations:i,leftColumnWidth:r}=e;const{setGlobalSearchQuery:c,setGlobalSearchChatId:l,resetChatCreation:d,setGlobalSearchDate:u,loadPasswordInfo:g,clearTwoFaError:p,setLeftColumnWidth:f,resetLeftColumnWidth:v}=(0,a.uC)(),I=(0,o.sO)(null),[y,Z]=(0,o.eJ)(m.du.ChatList),[P,C]=(0,o.eJ)(m.MT.Main),[w,b]=(0,o.eJ)(""),[E,M]=(0,Ae.ZP)(),[S,R]=(0,o.eJ)(0);let k=ft.Main;switch(y){case m.du.Archived:k=ft.Archived;break;case m.du.Settings:k=ft.Settings;break;case m.du.NewChannelStep1:case m.du.NewChannelStep2:k=ft.NewChannel;break;case m.du.NewGroupStep1:case m.du.NewGroupStep2:k=ft.NewGroup}const T=(0,o.I4)((e=>{if(y!==m.du.NewGroupStep2||e)if(y!==m.du.NewChannelStep2||e){if(y===m.du.NewGroupStep1){const e=document.getElementById("new-group-picker-search");e&&e.blur()}if(y===m.du.Settings)switch(P){case m.MT.EditProfile:case m.MT.Folders:case m.MT.General:case m.MT.Notifications:case m.MT.DataStorage:case m.MT.Privacy:case m.MT.Language:return void C(m.MT.Main);case m.MT.GeneralChatBackground:case m.MT.QuickReaction:return void C(m.MT.General);case m.MT.GeneralChatBackgroundColor:return void C(m.MT.GeneralChatBackground);case m.MT.PrivacyPhoneNumber:case m.MT.PrivacyLastSeen:case m.MT.PrivacyProfilePhoto:case m.MT.PrivacyForwarding:case m.MT.PrivacyGroupChats:case m.MT.PrivacyActiveSessions:case m.MT.PrivacyBlockedUsers:case m.MT.TwoFaDisabled:case m.MT.TwoFaEnabled:case m.MT.TwoFaCongratulations:return void C(m.MT.Privacy);case m.MT.PrivacyPhoneNumberAllowedContacts:case m.MT.PrivacyPhoneNumberDeniedContacts:return void C(m.MT.PrivacyPhoneNumber);case m.MT.PrivacyLastSeenAllowedContacts:case m.MT.PrivacyLastSeenDeniedContacts:return void C(m.MT.PrivacyLastSeen);case m.MT.PrivacyProfilePhotoAllowedContacts:case m.MT.PrivacyProfilePhotoDeniedContacts:return void C(m.MT.PrivacyProfilePhoto);case m.MT.PrivacyForwardingAllowedContacts:case m.MT.PrivacyForwardingDeniedContacts:return void C(m.MT.PrivacyForwarding);case m.MT.PrivacyGroupChatsAllowedContacts:case m.MT.PrivacyGroupChatsDeniedContacts:return void C(m.MT.PrivacyGroupChats);case m.MT.TwoFaNewPassword:return void C(m.MT.TwoFaDisabled);case m.MT.TwoFaNewPasswordConfirm:return void C(m.MT.TwoFaNewPassword);case m.MT.TwoFaNewPasswordHint:return void C(m.MT.TwoFaNewPasswordConfirm);case m.MT.TwoFaNewPasswordEmail:return void C(m.MT.TwoFaNewPasswordHint);case m.MT.TwoFaNewPasswordEmailCode:return void C(m.MT.TwoFaNewPasswordEmail);case m.MT.TwoFaChangePasswordCurrent:case m.MT.TwoFaTurnOff:case m.MT.TwoFaRecoveryEmailCurrentPassword:return void C(m.MT.TwoFaEnabled);case m.MT.TwoFaChangePasswordNew:return void C(m.MT.TwoFaChangePasswordCurrent);case m.MT.TwoFaChangePasswordConfirm:return void C(m.MT.TwoFaChangePasswordNew);case m.MT.TwoFaChangePasswordHint:return void C(m.MT.TwoFaChangePasswordConfirm);case m.MT.TwoFaRecoveryEmail:return void C(m.MT.TwoFaRecoveryEmailCurrentPassword);case m.MT.TwoFaRecoveryEmailCode:return void C(m.MT.TwoFaRecoveryEmail);case m.MT.FoldersCreateFolder:case m.MT.FoldersEditFolder:return void C(m.MT.Folders);case m.MT.FoldersIncludedChatsFromChatList:case m.MT.FoldersExcludedChatsFromChatList:return void C(m.MT.FoldersEditFolderFromChatList);case m.MT.FoldersEditFolderFromChatList:return Z(m.du.ChatList),void C(m.MT.Main)}y!==m.du.ChatList||0!==s?(Z(m.du.ChatList),b(""),c({query:""}),u({date:void 0}),l({id:void 0}),d(),setTimeout((()=>{R(Date.now())}),250)):Z(m.du.GlobalSearch)}else Z(m.du.NewChannelStep1);else Z(m.du.NewGroupStep1)}),[y,s,P,c,u,l,d]),N=(0,o.I4)((e=>{y!==m.du.Contacts?(Z(m.du.GlobalSearch),e!==t&&c({query:e})):b(e)}),[y,t,c]);(0,o.d4)((()=>y!==m.du.ChatList||0===s?(0,Ne.Z)((()=>T())):void 0),[s,y,T]),(0,o.d4)((()=>{if(y!==m.du.GlobalSearch)return document.addEventListener("keydown",e,!1),()=>{document.removeEventListener("keydown",e,!1)};function e(e){(h.jm&&e.metaKey||!h.jm&&e.ctrlKey)&&e.shiftKey&&"f"===(0,Be.Z)(e)&&(e.preventDefault(),Z(m.du.GlobalSearch))}}),[y]),(0,o.d4)((()=>{p(),P===m.MT.Privacy&&g()}),[p,g,P]);const{initResize:B,resetResize:A,handleMouseUp:x}=((e,t,n,a)=>{const[s,i,r]=(0,xe.Z)(),[c,l]=(0,o.eJ)(),[d,u]=(0,o.eJ)();function m(){document.body.classList.remove("no-selection","cursor-ew-resize")}return(0,o.d4)((()=>{e.current&&a&&(e.current.style.width=`${a}px`)}),[e,a]),(0,o.d4)((()=>{if(!s)return;const n=t=>{const n=Math.ceil(d+t.clientX-c);e.current.style.width=`${n}px`};function a(){o(),t(e.current.offsetWidth)}function o(){m(),document.removeEventListener("mousemove",n,!1),document.removeEventListener("mouseup",a,!1),document.removeEventListener("blur",a,!1),r()}return document.addEventListener("mousemove",n,!1),document.addEventListener("mouseup",a,!1),document.addEventListener("blur",a,!1),o}),[d,c,e,t,s,r]),{initResize:function(t){document.body.classList.add("no-selection","cursor-ew-resize"),l(t.clientX),u(e.current.offsetWidth),i()},resetResize:function(t){t.preventDefault(),e.current.style.width="",n()},handleMouseUp:m}})(I,f,v,r),L=e=>{Z(m.du.Settings),C(e)};return o.ZP.createElement("div",{id:"LeftColumn",ref:I},o.ZP.createElement(Le.Z,{name:i?"none":h.s0,renderCount:vt,activeKey:k,shouldCleanup:!0,cleanupExceptionKey:ft.Main},(e=>{switch(k){case ft.Archived:return o.ZP.createElement(pt,{isActive:e,onReset:T,onContentChange:Z});case ft.Settings:return o.ZP.createElement(ht,{isActive:e,currentScreen:P,foldersState:E,foldersDispatch:M,onScreenSelect:L,onReset:T,shouldSkipTransition:i});case ft.NewChannel:return o.ZP.createElement(gt,{key:S,isActive:e,isChannel:!0,content:y,onContentChange:Z,onReset:T});case ft.NewGroup:return o.ZP.createElement(gt,{key:S,isActive:e,content:y,onContentChange:Z,onReset:T});default:return o.ZP.createElement(mt,{content:y,searchQuery:t,searchDate:n,contactsFilter:w,foldersDispatch:M,onContentChange:Z,onSearchQuery:N,onScreenSelect:L,onReset:T,shouldSkipTransition:i})}})),o.ZP.createElement("div",{className:"resize-handle",onMouseDown:B,onMouseUp:x,onDoubleClick:A}))})));var yt=n(2420),Zt=n(5780),Pt=n(9524),Ct=n(1394);const wt=()=>{const[e,t]=(0,o.eJ)(W.Z.get());return(0,o.d4)((()=>{const e=(0,w.P2)((()=>{t(W.Z.get())}),250,!1);return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),e};var bt=n(2678),Et=n(7204),Mt=n(5326),St=n(3570),Rt=n(5790),kt=n(8360),Tt=n(6058),Nt=n(8799);const Bt=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"HeaderMenuContainer",!t);return n?o.ZP.createElement(n,e):void 0})),At=(0,o.X$)((0,a.c$)(((e,t)=>{var n,a;let{chatId:s,threadId:o,messageListType:i}=t;const c=(0,r.Z1)(e,s),d=Boolean(c&&(0,l.eA)(c));if(!c||c.isRestricted||(0,r.CA)(e))return{noMenu:!0};const m=(0,r.IK)(e,s),g=(0,r.FM)(e,s),p="thread"===i&&o===u._f,f="thread"===i&&o!==u._f,v=(0,r.Jf)(e),I=Boolean(m&&(0,r.s4)(e,m.id)),y=!I&&Boolean((0,r.pk)(e,s)),Z=Boolean(p&&(d||(0,l.ZV)(c))&&c.isNotJoined);return{noMenu:!1,isChannel:d,isRightColumnShown:v,canStartBot:y,canRestartBot:I,canSubscribe:Z,canSearch:p||f,canCall:h.Bi&&(0,l.YC)(c.id)&&!g&&!m,canMute:p&&!g&&!Z,canLeave:p&&!Z,canEnterVoiceChat:h.Bi&&c.isCallActive,canCreateVoiceChat:h.Bi&&!c.isCallActive&&((null===(n=c.adminRights)||void 0===n?void 0:n.manageCall)||c.isCreator&&(0,l.G9)(c)),pendingJoinRequests:null===(a=c.fullInfo)||void 0===a?void 0:a.requestsPending}}))((e=>{let{chatId:t,threadId:n,noMenu:s,isChannel:i,canStartBot:r,canRestartBot:c,canSubscribe:l,canSearch:d,canCall:u,canMute:g,canLeave:p,canEnterVoiceChat:f,canCreateVoiceChat:v,pendingJoinRequests:I,isRightColumnShown:y,canExpandActions:Z}=e;const{joinChannel:P,sendBotCommand:C,openLocalTextSearch:w,restartBot:b,openCallFallbackConfirm:E,requestNextManagementScreen:M}=(0,a.uC)(),S=(0,o.sO)(null),[R,k]=(0,o.eJ)(!1),[T,N]=(0,o.eJ)(void 0),B=(0,o.I4)((()=>{k(!0);const e=S.current.getBoundingClientRect();N({x:e.right,y:e.bottom})}),[]),A=(0,o.I4)((()=>{k(!1)}),[]),x=(0,o.I4)((()=>{N(void 0)}),[]),L=(0,o.I4)((()=>{P({chatId:t})}),[P,t]),O=(0,o.I4)((()=>{C({command:"/start"})}),[C]),F=(0,o.I4)((()=>{b({chatId:t})}),[t,b]),U=(0,o.I4)((()=>{M({screen:m.u1.JoinRequests})}),[M]),$=(0,o.I4)((()=>{w(),h.wB?document.querySelector("#MobileSearch input").focus():setTimeout((()=>{const e=document.querySelector(".RightHeader .SearchInput input");e&&e.focus()}),400)}),[w]);(0,o.d4)((()=>{if(d)return document.addEventListener("keydown",e,!1),()=>{document.removeEventListener("keydown",e,!1)};function e(e){h.fl&&(h.jm&&e.metaKey||!h.jm&&e.ctrlKey)&&!e.shiftKey&&"f"===(0,Be.Z)(e)&&(e.preventDefault(),$())}}),[d,$]);const D=(0,Oe.Z)();return o.ZP.createElement("div",{className:"HeaderActions"},!h.wB&&o.ZP.createElement(o.ZP.Fragment,null,Z&&l&&o.ZP.createElement(Ge.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:L},D(i?"ProfileJoinChannel":"ProfileJoinGroup")),Z&&r&&o.ZP.createElement(Ge.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:O},D("BotStart")),Z&&c&&o.ZP.createElement(Ge.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:F},D("BotRestart")),d&&o.ZP.createElement(Ge.Z,{round:!0,ripple:y,color:"translucent",size:"smaller",onClick:$,ariaLabel:"Search in this chat"},o.ZP.createElement("i",{className:"icon-search"})),u&&o.ZP.createElement(Ge.Z,{round:!0,color:"translucent",size:"smaller",onClick:E,ariaLabel:"Call"},o.ZP.createElement("i",{className:"icon-phone"}))),Boolean(I)&&o.ZP.createElement(Ge.Z,{round:!0,className:"badge-button",ripple:y,color:"translucent",size:"smaller",onClick:U,ariaLabel:D(i?"SubscribeRequests":"MemberRequests")},o.ZP.createElement("i",{className:"icon-user"}),o.ZP.createElement("div",{className:"badge"},I)),o.ZP.createElement(Ge.Z,{ref:S,className:R?"active":"",round:!0,ripple:!h.wB,size:"smaller",color:"translucent",disabled:s,ariaLabel:"More actions",onClick:B},o.ZP.createElement("i",{className:"icon-more"})),T&&o.ZP.createElement(Bt,{chatId:t,threadId:n,isOpen:R,anchor:T,withExtraActions:h.wB||!Z,isChannel:i,canStartBot:r,canRestartBot:c,canSubscribe:l,canSearch:d,canCall:u,canMute:g,canLeave:p,canEnterVoiceChat:f,canCreateVoiceChat:v,onSubscribeChannel:L,onSearchClick:$,onClose:A,onCloseAnimationEnd:x}))})));var xt=n(4399),Lt=n(6202),Ot=n(862);function Ft(e){var t;const n=e&&(0,l.DH)(e),a=null==e||null===(t=e.content)||void 0===t?void 0:t.sticker,i=n&&a&&!(0,h.on)()&&n.includes("image/webp"),[r,c]=(0,o.eJ)(Ot.Hu),d=null==e?void 0:e.id;return(0,o.bt)((()=>{i&&(0,Ot.p6)(`b64-${d}`,n).then(c).catch((e=>{s.eM&&console.error(e)}))}),[d,i,n]),i?r:n}var Ut=n(7551),$t=n(8512),Dt=n(996);function jt(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 qt=(0,o.X$)((e=>{let{count:t,index:n}=e;const a=(0,o.sO)(null),s=(0,o.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=jt(0,0,2,t,1)+jt(0,12,2,t+1,1)+jt(0,25,2,t,1);else for(let e=0;e<n;e++)a+=jt(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),l=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:l,trackHeight:o,clipPathId:i}}(t,n)),[t,n]);if((0,o.d4)((()=>{if(!a.current)return;const{trackHeight:e,trackTranslateY:t,markHeight:n,markTranslateY:o,clipPathId:i,clipPath:r}=s,c=a.current.firstElementChild;if(null!=a&&a.current){const s=a.current,{style:l}=s;l.height=`${e}px`,l.transform=`translateY(-${t}px)`,l.clipPath=`url("#${i}")`;const d=s.querySelector("svg"),u=s.querySelector("div"),m=s.querySelector("defs");d||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 o.ZP.createElement("div",{className:"pinned-message-border"},o.ZP.createElement("div",{className:"pinned-message-border-wrapper-1",ref:a}));const{trackHeight:i,trackTranslateY:r,markHeight:c,markTranslateY:l,clipPathId:d}=s;return o.ZP.createElement("div",{className:(0,he.Z)("pinned-message-border",t>4&&"pinned-message-border-mask")},o.ZP.createElement("div",{className:"pinned-message-border-wrapper",ref:a,style:`clip-path: url("#${d}"); width: 2px;\n height: ${i}px; transform: translateY(-${r}px);`},o.ZP.createElement("span",null),o.ZP.createElement("div",{className:"pinned-message-border-mark",style:`height: ${c}px; transform: translateY(${l}px);`})))})),Qt=(0,o.X$)((e=>{let{message:t,count:n,index:a,customTitle:s,className:i,onUnpinMessage:r,onClick:c,onAllPinnedClick:d}=e;const u=(0,Oe.Z)(),m=Ft(t),h=(0,Lt.Z)((0,l.Ti)(t,"pictogram")),g=(0,Dt.e)(u,t,Boolean(m)),[p,f,v]=(0,xe.Z)(),I=(0,o.I4)((()=>{v(),r&&r(t.id)}),[v,r,t.id]);return o.ZP.createElement("div",{className:(0,he.Z)("HeaderPinnedMessage-wrapper",i)},n>1&&o.ZP.createElement(Ge.Z,{round:!0,size:"smaller",color:"translucent",className:"pin-list-button",ariaLabel:u("EventLogFilterPinnedMessages"),onClick:d},o.ZP.createElement("i",{className:"icon-pin-list"})),r&&o.ZP.createElement(Ge.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:u("UnpinMessageAlertTitle"),className:"unpin-button",onClick:f},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Ut.Z,{isOpen:p,onClose:v,text:"Would you like to unpin this message?",confirmLabel:"Unpin",confirmHandler:I}),o.ZP.createElement("div",{className:"HeaderPinnedMessage",onClick:c,dir:u.isRtl?"rtl":void 0},o.ZP.createElement(qt,{count:n,index:a}),m&&function(e,t){const{width:n,height:a}=(0,xt.W7)();return o.ZP.createElement("img",{src:t||e,width:n,height:a,alt:""})}(m,h),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("div",{className:"title",dir:"auto"},s||`${u("PinnedMessage")} ${a>0?"#"+(n-a):""}`),o.ZP.createElement("p",{dir:"auto"},g)),o.ZP.createElement($t.Z,null)))}));var Gt=n(396),Ht=n(4532),_t=n(3186),zt=n(711);function Vt(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=()=>{Xt(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 Xt(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";if(!("createImageBitmap"in window))return Wt(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!");return await new Promise((e=>{const t=document.createElement("canvas");t.width=s.width,t.height=s.height;const n=t.getContext("bitmaprenderer");n?n.transferFromImageBitmap(s):t.getContext("2d").drawImage(s,0,0),t.toBlob(e,a)}))}catch(s){return Wt(e,t,n,void 0,a)}}function Wt(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);return new Promise((e=>{o.toBlob(e,s)}))}var Kt=n(4524);const Yt={width:200,height:200},Jt=115,en=(e,t,n)=>{const{audio:a,voice:s}=(0,l.qp)(e),i=a?a.title||a.fileName:s?"Voice message":"",r=a&&a.performer||t&&(0,l.OU)(zt.i0,t),c=n&&(0,l.U)(zt.i0,n)||"Telegram",d=a&&(0,l.MR)(a)&&(0,l.Ti)(e,"pictogram"),u=t&&(0,l.RT)(t,"big"),m=a&&d||s&&u,h=(0,Lt.Z)(m),g=(0,o.Ye)((()=>function(e,t,n){if(!n)return Yt;if(e){if(!e.thumbnailSizes||0===e.thumbnailSizes.length)return;const t=e.thumbnailSizes.find((e=>"m"===e.type));return t||e.thumbnailSizes[0]}return t?xt.vY:void 0}(a,s,h)),[a,h,s]),{result:p}=((e,t,n)=>{const[a,s]=(0,o.eJ)(!1),[i,r]=(0,o.eJ)(),[c,l]=(0,o.eJ)(n);return(0,o.d4)((()=>{s(!0);let e=!1;return function(e,t){if(!e)return Promise.resolve(Kt);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=()=>{Xt(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,Jt,Jt);const n=Math.min(t.width,t.height);return n<Jt?Vt(e,Jt/n):Promise.resolve(e)}(h,g).then((t=>{e||(s(!1),l(t))}),(t=>{e||(s(!1),r(t))})),()=>{e=!0}}),t),{isLoading:a,error:i,result:c}})(0,[h,g],Kt);return(0,o.Ye)((()=>(0,Ht.Of)({title:i,artist:r,album:c,artwork:[{src:p}]})),[c,r,i,p])};var tn=n(2340),nn=n(8051);const an=(0,a.c$)(((e,t)=>{let{message:n}=t;const a=(0,r.Ur)(e,n),s=(0,r.Z1)(e,n.chatId),{volume:o,playbackRate:i,isMuted:c}=e.audioPlayer;return{sender:a,chat:s,volume:o,playbackRate:i,isMuted:c}}))((e=>{let{message:t,className:n,noUi:s,sender:i,chat:r,volume:c,playbackRate:d,isMuted:u}=e;const{setAudioPlayerVolume:m,setAudioPlayerPlaybackRate:g,setAudioPlayerMuted:p,focusMessage:f,closeAudioPlayer:v}=(0,a.uC)(),I=(0,Oe.Z)(),{audio:y,voice:Z,video:P}=(0,l.qp)(t),C=Boolean(Z||P),w=i?(0,l.OU)(I,i):void 0,b=H.UV((0,l.Ti)(t,"inline")),E=en(t,i,r),{playPause:M,stop:S,isPlaying:R,requestNextTrack:k,requestPreviousTrack:T,isFirst:N,isLast:B,setVolume:A,toggleMuted:x,setPlaybackRate:L}=(0,_t.Z)((0,Gt.An)(t),(0,l.XV)(t),C?"voice":"audio",b,void 0,E,void 0,!0,void 0,void 0,(0,l.CI)(t),!0),O=C&&R;(0,o.d4)((()=>{if(O)return W.Z.disableRefresh(),()=>{W.Z.enableRefresh()}}),[O]);const F=(0,o.I4)((()=>{f({chatId:t.chatId,messageId:t.id})}),[f,t.chatId,t.id]),U=(0,o.I4)((()=>{R&&M(),v(),(0,Ht.Ay)(),S()}),[v,R,M,S]),$=(0,o.I4)((e=>{m({volume:e/100}),p({isMuted:!1}),A(e/100)}),[p,m,A]),D=(0,o.I4)((()=>{h.$b&&!h.cj||(x(),p({isMuted:!u}))}),[u,p,x]),j=(0,o.I4)((()=>{1===d?(L(1.8),g({playbackRate:1.8})):(L(1),g({playbackRate:1}))}),[d,g,L]),q=(0,o.Ye)((()=>0===c||u?"icon-muted":c<.3?"icon-volume-1":c<.6?"icon-volume-2":"icon-volume-3"),[c,u]);if(!s)return o.ZP.createElement("div",{className:(0,he.Z)("AudioPlayer",n),dir:I.isRtl?"rtl":void 0},o.ZP.createElement(Ge.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:N(),onClick:T,ariaLabel:"Previous track"},o.ZP.createElement("i",{className:"icon-skip-previous"})),o.ZP.createElement(Ge.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:(0,he.Z)("toggle-play","player-button",R?"pause":"play"),onClick:M,ariaLabel:R?"Pause audio":"Play audio"},o.ZP.createElement("i",{className:"icon-play"}),o.ZP.createElement("i",{className:"icon-pause"})),o.ZP.createElement(Ge.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:B(),onClick:k,ariaLabel:"Next track"},o.ZP.createElement("i",{className:"icon-skip-next"})),o.ZP.createElement("div",{className:"AudioPlayer-content",onClick:F},y?function(e){const{title:t,performer:n,fileName:a}=e;return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},(0,tn.Z)(t||a)),n&&o.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,tn.Z)(n)))}(y):function(e,t){return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,tn.Z)(t)),o.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(I("AttachAudio"),w),o.ZP.createElement($t.Z,null)),o.ZP.createElement(Ge.Z,{round:!0,className:"player-button volume-button",color:"translucent",size:"smaller",ariaLabel:"Volume",withClickPropagation:!0},o.ZP.createElement("i",{className:q,onClick:D}),!h.cj&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"volume-slider-spacer"}),o.ZP.createElement("div",{className:"volume-slider"},o.ZP.createElement(nn.Z,{value:u?0:100*c,onChange:$})))),C&&o.ZP.createElement(Ge.Z,{round:!0,className:(0,he.Z)("playback-button",1!==d&&"applied"),color:"translucent",size:"smaller",ariaLabel:"Playback Rate",ripple:!h.wB,onClick:j},o.ZP.createElement("span",{className:"playback-button-inner"},"2Х")),o.ZP.createElement(Ge.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:U,ariaLabel:"Close player"},o.ZP.createElement("i",{className:"icon-close"})))}));var sn=n(2607),on=n(172);const rn=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n}=t;const a=(0,r.Z1)(e,n),s=(0,sn.Bj)(e,n);return{groupCall:s,usersById:e.users.byId,chatsById:e.chats.byId,activeGroupCallId:e.groupCalls.activeGroupCallId,isActive:(s?s.participantsCount>0&&s.isLoaded:a&&a.isCallNotEmpty&&a.isCallActive)&&e.groupCalls.activeGroupCallId!==(null==s?void 0:s.id)}}))((e=>{let{chatId:t,isActive:n,groupCall:s,hasPinnedOffset:i,usersById:r,chatsById:c}=e;const{joinGroupCall:l,subscribeToGroupCallUpdates:d}=(0,a.uC)(),u=(0,Oe.Z)(),m=(0,o.I4)((()=>{l({chatId:t})}),[l,t]),h=null==s?void 0:s.participants,g=(0,o.Ye)((()=>h?Object.values(h).filter(((e,t)=>t<3)).map((e=>{let{id:t,isUser:n}=e;if(n){if(!r[t])return;return{user:r[t]}}if(c[t])return{chat:c[t]}})).filter(Boolean):[]),[c,h,r]);if((0,o.d4)((()=>{if(null!=s&&s.id&&(n||!s.isLoaded))return d({id:s.id,subscribed:!0}),()=>{d({id:s.id,subscribed:!1})}}),[null==s?void 0:s.id,null==s?void 0:s.isLoaded,n,d]),s)return o.ZP.createElement("div",{className:(0,he.Z)("GroupCallTopPane",i&&"has-pinned-offset",!n&&"is-hidden"),onClick:m},o.ZP.createElement("div",{className:"info"},o.ZP.createElement("span",{className:"title"},u("VoipGroupVoiceChat")),o.ZP.createElement("span",{className:"participants"},u("Participants",s.participantsCount||0,"i"))),o.ZP.createElement("div",{className:"avatars"},g.map((e=>{if(e)return e.user?o.ZP.createElement(on.Z,{key:e.user.id,user:e.user}):o.ZP.createElement(on.Z,{key:e.chat.id,chat:e.chat})}))),o.ZP.createElement(Ge.Z,{round:!0,className:"join"},u("VoipChatJoin")))}))),cn=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n,threadId:a,messageListType:s}=t;const{isLeftColumnShown:o,lastSyncTime:i,shouldSkipHistoryAnimations:c}=e,l=(0,r.Z1)(e,n),{typingStatus:d}=l||{},{chatId:m,messageId:h}=e.audioPlayer,g=m&&h?(0,r.hj)(e,m,h):void 0;let p;if("pinned"===s){const t=(0,r.KB)(e,n);p=null==t?void 0:t.length}else if("scheduled"===s){const t=(0,r.qy)(e,n);p=null==t?void 0:t.length}else if("thread"===s&&a!==u._f){const t=(0,r.tZ)(e,n,a);p=(null==t?void 0:t.messagesCount)||0}const f={typingStatus:d,isLeftColumnShown:o,isRightColumnShown:(0,r.Jf)(e),isSelectModeActive:(0,r.CA)(e),audioMessage:g,chat:l,messagesCount:p,isChatWithSelf:(0,r.FM)(e,n),isChatWithBot:l&&(0,r.xo)(e,l),lastSyncTime:i,shouldSkipHistoryAnimations:c,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1),connectionState:e.connectionState,isSyncing:e.isSyncing},v=(0,r.Zw)(e,n);if("thread"!==s||!v)return f;if(Object.assign(f,{messagesById:v}),a!==u._f){const t=(0,r.qS)(e,n,a),s=t?(0,r.hj)(e,n,t):void 0,o=s?(0,r.cv)(e,s):void 0;return{...f,pinnedMessageIds:t,canUnpin:!1,topMessageSender:o}}const I=(0,r.KB)(e,n);if(null!=I&&I.length){const t=v[I[0]],{canUnpin:n}=t&&(0,r._k)(e,t,a)||{};return{...f,pinnedMessageIds:I,canUnpin:n}}return f}))((e=>{let{chatId:t,threadId:n,messageListType:i,isReady:r,pinnedMessageIds:c,messagesById:d,canUnpin:m,topMessageSender:g,typingStatus:p,isSelectModeActive:f,isLeftColumnShown:v,isRightColumnShown:I,audioMessage:y,chat:Z,messagesCount:P,isChatWithSelf:C,isChatWithBot:w,lastSyncTime:b,shouldSkipHistoryAnimations:E,currentTransitionKey:M,connectionState:S,isSyncing:R}=e;const{openChatWithInfo:k,pinMessage:T,focusMessage:N,openChat:B,openPreviousChat:A,loadPinnedMessages:x,toggleLeftColumn:L,exitMessageSelectMode:O}=(0,a.uC)(),F=(0,Oe.Z)(),U=(0,o.sO)(!0),[$,D]=(0,o.eJ)(0),j=Array.isArray(c)?c[$]:c,q=d&&j?d[j]:void 0,Q=Array.isArray(c)?c.length:c?1:void 0,G=Z&&(0,l.U)(F,Z).length,H=g?(0,l.OU)(F,g):void 0;(0,o.d4)((()=>{n===u._f&&b&&r&&x({chatId:t})}),[t,x,b,n,r]),(0,o.d4)((()=>{D(0)}),[c]),(0,Rt.Z)(t,j,q);const{width:_}=wt(),z=_<=s.ks,V=h.p7&&v,X=(0,o.sO)(null),W=(0,o.sO)(!0),K=(0,o.I4)((()=>{k({id:t})}),[k,t]),Y=(0,o.I4)((e=>{T({chatId:t,messageId:e,isUnpin:!0})}),[T,t]),J=(0,o.I4)((()=>{if(q){N({chatId:q.chatId,threadId:n,messageId:q.id});const e=(0,St.Z)(Q||1,$+1);D(e)}}),[q,N,n,Q,$]),ee=(0,o.I4)((()=>{B({id:t,threadId:u._f,type:"pinned"})}),[B,t]),te=(0,o.I4)((()=>{setTimeout((()=>{U.current=!0}),450)}),[]),ne=(0,o.I4)((e=>{if(U.current){if(U.current=!1,h.wB){const e=document.getElementById(s.R2);e&&e.blur()}if(f)return O(),void te();if(n===u._f&&"thread"===i&&0===M)return h.wB||V?(e.stopPropagation(),B({id:void 0})):L(),void te();A(),te()}}),[n,i,M,f,A,V,B,L,O,te]),ae=_>=s.ks&&_<s.jT||_>s.l3&&_<s.ks&&(!G||G>30),se=ae||_>s._m&&_<s.QU,{shouldRender:oe,transitionClassNames:ie}=(0,ve.Z)(Boolean(y)),re=(0,kt.Z)(y,!0),{shouldRender:ce,transitionClassNames:le}=(0,ve.Z)(Boolean(q)),de=(0,kt.Z)(q,!0),ue=(0,kt.Z)(Q,!0),me=(0,kt.Z)(m,!0),ge=(0,kt.Z)(H),pe=ce&&de||oe&&re;(0,o.d4)((()=>{const e=X.current;if(e)return se&&pe?void(I||ae?(W.current&&(e.classList.add("tools-stacked","animated"),W.current=!1),setTimeout((()=>{e.classList.remove("animated")}),350)):(e.classList.remove("tools-stacked"),W.current=!0)):(e.classList.remove("tools-stacked","animated"),void(W.current=!0))}),[se,pe,ae,I]);const{connectionStatusText:fe}=je(F,S,R,!0);function Ie(){return"thread"===i&&n===u._f?o.ZP.createElement(o.ZP.Fragment,null,(z||M>0)&&ye(V,!0),o.ZP.createElement("div",{className:"chat-info-wrapper",onClick:K},(0,l.YC)(t)?o.ZP.createElement(Tt.Z,{userId:t,typingStatus:p,status:fe,withDots:Boolean(fe),withFullInfo:w,withMediaViewer:!0,withUpdatingStatus:!0,noRtl:!0}):o.ZP.createElement(Nt.Z,{chatId:t,typingStatus:p,status:fe,withDots:Boolean(fe),withMediaViewer:!0,withFullInfo:!0,withUpdatingStatus:!0,noRtl:!0}))):"thread"===i?o.ZP.createElement(o.ZP.Fragment,null,ye(),o.ZP.createElement("h3",null,F("CommentsCount",P,"i"))):"pinned"===i?o.ZP.createElement(o.ZP.Fragment,null,ye(),o.ZP.createElement("h3",null,F("PinnedMessagesCount",P,"i"))):"scheduled"===i?o.ZP.createElement(o.ZP.Fragment,null,ye(),o.ZP.createElement("h3",null,C?F("Reminders"):F("messages",P,"i"))):void 0}function ye(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return o.ZP.createElement("div",{className:"back-button"},o.ZP.createElement(Ge.Z,{round:!0,size:"smaller",color:"translucent",onClick:ne,ariaLabel:F(e?"Close":"Back")},o.ZP.createElement("div",{className:(0,he.Z)("animated-close-icon",!e&&"state-back")})),t&&o.ZP.createElement(Te,null))}const Ze=Boolean(oe&&re);return o.ZP.createElement("div",{className:"MiddleHeader",ref:X},o.ZP.createElement(Le.Z,{name:E?"none":"slide-fade",activeKey:M},Ie),o.ZP.createElement(rn,{hasPinnedOffset:ce&&Boolean(de)||oe&&Boolean(re),chatId:t}),ce&&de&&o.ZP.createElement(Qt,{key:t,message:de,count:ue||0,index:$,customTitle:ge,className:(0,he.Z)(le,Ze&&"full-width"),onUnpinMessage:me?Y:void 0,onClick:J,onAllPinnedClick:ee}),o.ZP.createElement("div",{className:"header-tools"},Ze&&o.ZP.createElement(an,{key:(0,l.Tp)(re),message:re,className:ie}),o.ZP.createElement(At,{chatId:t,threadId:n,messageListType:i,canExpandActions:!Ze})))})));var ln=n(2645),dn=n(274);function un(e){return"albumId"in e}function mn(e,t){let n,a=[],s={originalDate:e[0].date,datetime:Number((0,B.$Y)(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=Number((0,B.$Y)(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,l.Lo)(i)||(0,l.Lo)(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 hn=n(386),gn=n(2202);var pn=n(7675),fn=n(539),vn=n(2357),In=n(3657);const yn=h.wZ?1e3:350,Zn=h.wB?300:500;var Pn=n(7240);function Cn(e){return"number"==typeof e}function wn(e,t){return e?t?238:175:t?238:100}function bn(e,t){const n=(0,l.B4)(e),a=(0,l.MF)(e),s=(0,l.O$)(e)||(0,l.F$)(e),o=(0,l.b7)(e),i=Boolean((0,l.F$)(e)),{width:r,height:c}=s?(0,xt.Eh)(s,n,a,i,t):(0,xt.GC)(o,n,a,t),d=wn(Boolean((0,l.UD)(e)));let u=1;r<d&&d-r<12&&(u=d/r),c*u<90&&90-c*u<12&&(u=90/c);const m=Math.round(r*u),h=Math.round(c*u);return{width:m,height:h,isSmall:m<d||h<90}}function En(e,t){return e.reduce(((e,t)=>e+t),t)}function Mn(e,t,n){return e<t?t:e>n?n:e}function Sn(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 Rn(e,t,n,a){const s=function(e){return e.map((e=>{const t=bn(e);return t.width/t.height}))}(a.messages),o=function(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}(s),i=function(e){return e.reduce(((e,t)=>t+e),1)/e.length}(s),r=s.length,c=s.some((e=>e>2)),l=(0,xt.kc)(e,t,!1,n)-(t?2.5:0)*xt.Gw;let d;const u={ratios:s,proportions:o,averageRatio:i,maxWidth:l,minWidth:100,maxHeight:l,spacing:2};return d=r>=5||c?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?Mn(e,1,2.75):Mn(e,.6667,1)))}(t,n),c=t.length,l=new Array(c),d=[],u=e=>{const t=[];let n=0;e.forEach((e=>{t.push(((e,t)=>{const n=En(r.slice(e,e+t),0);return(a-(t-1)*o)/n})(n,e)),n+=e})),d.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<d.length;e++){const{heights:t,lineCounts:n}=d[e],a=n.length,r=En(t,0)+o*(a-1),c=Math.min(...t)<s?1.5:1,l=(()=>{for(let e=1;e!==a;++e)if(n[e-1]>n[e])return 1.5;return 1})(),u=Math.abs(r-i)*c*l;(!m||u<h)&&(m=d[e],h=u)}const g=m.lineCounts,p=m.heights,f=g.length;let v=0,I=0;for(let e=0;e!==f;++e){const t=g[e],n=p[e],s=Math.round(n);let i=0;for(let c=0;c!==t;++c){const d=0|(0===e?1:0)|(e===f-1?4:0)|(0===c?8:0)|(c===t-1?2:0),u=r[v],m=c===t-1?a-i:Math.round(u*n);l[v]={dimensions:{x:i,y:I,width:m,height:s},sides:d},i+=m+o,++v}I+=s+o}return l}(u):2===r?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,l=Math.min(o,Math.round(Math.min(c/t[0],r/t[1])));return[{dimensions:{x:0,y:0,width:c,height:l},sides:13},{dimensions:{x:c+s,y:0,width:r,height:l},sides:7}]}(e)}(u):3===r?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,l=Math.max(o,Math.round(Math.min((s-n)/2,Math.min(r*a[2],c*a[1])))),d=Math.min(Math.round(i*a[0]),s-n-l);return[{dimensions:{x:0,y:0,width:d,height:i},sides:13},{dimensions:{x:d+n,y:0,width:l,height:c},sides:3},{dimensions:{x:d+n,y:c+n,width:l,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)}(u):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])),l=Math.max(o,Math.round(Math.min(.4*(t-2*a),c*n[1]))),d=Math.round(Math.max(Math.max(o,.33*(t-2*a)),c*n[3])),u=i-l-d-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:l,height:m},sides:12},{dimensions:{x:l+a,y:r+a,width:u,height:m},sides:4},{dimensions:{x:l+a+u+a,y:r+a,width:d,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])),l=Math.round(c/n[1]),d=Math.round(c/n[2]),u=i-l-d-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:l},sides:3},{dimensions:{x:r+s,y:l+s,width:m,height:d},sides:2},{dimensions:{x:r+s,y:l+d+2*s,width:m,height:u},sides:6}]}(e)}(u),{layout:d,containerStyle:Sn(d)}}let kn;function Tn(e){return kn||(kn=document.createElement("span"),kn.style.font=h.cj?'400 12px system-ui, -apple-system, BlinkMacSystemFont, "Roboto", "Apple Color Emoji", "Helvetica Neue", sans-serif':'400 12px "Roboto", -apple-system, "Apple Color Emoji", BlinkMacSystemFont, "Helvetica Neue", sans-serif',kn.style.whiteSpace="nowrap",kn.style.position="absolute",kn.style.left="-999px",kn.style.opacity=".01",document.body.appendChild(kn)),kn.innerHTML=e,kn.offsetWidth}function Nn(e,t,n,a,s,i){(0,o.bt)((()=>{if(n&&e.current){const t=e.current.closest(".MessageList");(0,fn.Z)(t,e.current,s?"end":"centerOrTop",20,void 0!==a?1e3:void 0,a,void 0,i)}}),[e,t,n,a,s,i])}const Bn=3*xt.Gw,An=Number(xt.Gw),xn="data-is-document-group-hover";function Ln(e,t,n,s,i,r,c,l,d,u,m,g,p,f){const{setReplyingToId:v,sendDefaultReaction:I}=(0,a.uC)(),[y,Z,P]=(0,xe.Z)(),[C,w,b]=(0,xe.Z)(),E=(0,o.sO)();return(0,o.d4)((()=>{if(!h.$b||i||!r||m)return;let e;return(0,Je.sf)(t.current,{selectorToPreventScroll:".MessageList",onSwipe:(t,n)=>n===Je.eM.Left&&(e||(e=Date.now()),w(),!0),onRelease:()=>{e&&(v({messageId:n}),setTimeout(b,Math.max(0,150-(Date.now()-e))),e=void 0)}})}),[t,i,n,v,w,b,r,m]),{handleMouseDown:i?void 0:function(e){(0,hn.q)(e),d(e)},handleClick:function(t){if(i)e(t);else if(h.$b)return E.current?(clearInterval(E.current),E.current=void 0,void function(e){const{pageX:t,pageY:a}=e;I({chatId:u,messageId:n,x:t,y:a})}(t)):void(E.current=setTimeout((()=>{E.current=void 0,function(e){if(h.wZ){const t=e.target;if(!t.classList.contains("text-content")&&!t.classList.contains("Message"))return;W.Z.getIsKeyboardVisible()?setTimeout((()=>{l(e)}),350):l(e)}}(t)}),200))},handleContextMenu:i?c?fe.Z:void 0:function(t){if(h.wZ){if(t.target.matches("a[href]")||m)return;t.preventDefault(),e()}else l(t)},handleDoubleClick:i?void 0:function(){h.$b||v({messageId:n})},handleContentDoubleClick:h.$b?void 0:function(e){e.stopPropagation()},handleMouseMove:function(e){const t=g.current;if(!t)return;const{clientX:n,clientY:a}=e,{x:s,width:o,y:i,height:r}=t.getBoundingClientRect(),c=Math.abs(p?n-s:s+o-n)<Bn,l=Math.abs(i+r-a)<An;c&&l?Z():P()},handleSendQuickReaction:function(e){const{x:t,y:a}=e.currentTarget.getBoundingClientRect();I({chatId:u,messageId:n,x:t,y:a})},handleMouseLeave:function(e){P(),f&&function(e){const t=Fn(e.currentTarget);t&&t.removeAttribute(xn)}(e)},isSwiped:C,isQuickReactionVisible:y,handleDocumentGroupMouseEnter:On}}function On(e){const t=Fn(e.currentTarget);t&&t.setAttribute(xn,"")}function Fn(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}var Un=n(8005);const $n=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"ContextMenuContainer",!t);return n?o.ZP.createElement(n,e):void 0})),Dn=(0,o.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||{},c=n.replyToMessageId,d=c?(0,r.hj)(e,n.chatId,c):void 0,u=(0,r._X)(e,n),{direction:m,noHighlight:h}=u&&e.focusedMessage||{},g=(0,r.Z1)(e,n.chatId),p=g&&((0,l.eA)(g)||s===n.chatId);return{usersById:a,senderUser:!p&&s?(0,r.dy)(e,s):void 0,senderChat:p?g:void 0,targetChatId:i,targetUserIds:o,targetMessage:d,isFocused:u,...u&&{focusDirection:m,noFocusHighlight:h}}}))((e=>{let{message:t,observeIntersection:n,isEmbedded:a,appearanceOrder:s=0,isLastInList:i,usersById:r,senderUser:c,senderChat:l,targetUserIds:d,targetMessage:u,targetChatId:m,isFocused:h,focusDirection:g,noFocusHighlight:p}=e;const f=(0,o.sO)(null);(0,In._N)(f,n),(0,Rt.Z)(t.chatId,t.replyToMessageId,u),Nn(f,t.chatId,h,g,p);const v=(0,Oe.Z)(),I=s<=0,[y,Z]=(0,xe.Z)(I);(0,o.d4)((()=>{I||setTimeout(Z,10*s)}),[s,Z,I]);const{transitionClassNames:P}=(0,ve.Z)(y,void 0,I,!1),C=(0,o.Ye)((()=>d?d.map((e=>null==r?void 0:r[e])).filter(Boolean):void 0),[d,r]),w=(0,Un.D)(v,t,c,l,C,u,m,{asTextWithSpoilers:a}),{isContextMenuOpen:b,contextMenuPosition:E,handleBeforeContextMenu:M,handleContextMenu:S,handleContextMenuClose:R,handleContextMenuHide:k}=(0,Pn.Z)(f),T=void 0!==E;if(a)return o.ZP.createElement("span",{className:"embedded-action-message"},w);const N=(0,he.Z)("ActionMessage message-list-item",h&&!p&&"focused",T&&"has-menu-open",i&&"last-in-list",P);return o.ZP.createElement("div",{ref:f,id:`message${t.id}`,className:N,"data-message-id":t.id,onMouseDown:e=>{(0,hn.q)(e),M(e)},onContextMenu:S},o.ZP.createElement("span",null,w),E&&o.ZP.createElement($n,{isOpen:b,anchor:E,message:t,messageListType:"thread",onClose:R,onCloseAnimationEnd:k}))}))),jn=e=>{let{className:t,message:n,sender:a,title:s,customText:i,isProtected:r,observeIntersection:c,onClick:d}=e;const u=(0,o.sO)(null),m=(0,In.Op)(u,c),h=(0,Lt.Z)(n&&(0,l.Ti)(n,"pictogram"),!m),g=n&&`sticker-reply-thumb${n.id}`,p=Ft(n),f=Boolean(n&&(0,l.Y5)(n)),v=(0,Oe.Z)(),I=a&&(0,l.OU)(v,a);return o.ZP.createElement("div",{ref:u,className:(0,he.Z)("EmbeddedMessage",t),onClick:n?d:void 0},p&&function(e,t,n,a,s){const{width:i,height:r}=(0,xt.W7)();return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("img",{id:e,src:n||t,width:i,height:r,alt:"",className:a?"round":"",draggable:!s}),s&&o.ZP.createElement("span",{className:"protector"}))}(g,p,h,f,r),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("p",{dir:"auto"},n?(0,l.Lo)(n)?o.ZP.createElement(Dn,{message:n,isEmbedded:!0}):(0,Dt.e)(v,n,Boolean(p)):i||" "),o.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,tn.Z)(I||s||" "))))};var qn=n(2535),Qn=n(4752),Gn=n(8018),Hn=n(8198),_n=n(7799);const zn=(0,o.X$)((e=>{var t,n;let{reaction:s,activeReaction:i,isInMeta:r,availableReactions:c}=e;const{stopActiveReaction:l}=(0,a.uC)(),d=null==c?void 0:c.find((e=>e.reaction===s)),m=null==d||null===(t=d.centerIcon)||void 0===t?void 0:t.id,h=null==d||null===(n=d.aroundAnimation)||void 0===n?void 0:n.id,g=(0,Lt.Z)(`sticker${m}`,!m,u.IU.Lottie),p=(0,Lt.Z)(`sticker${h}`,!h,u.IU.Lottie),f=Boolean((null==i?void 0:i.reaction)===s&&g&&p),{shouldRender:v,transitionClassNames:I}=(0,ve.Z)(f,void 0,!0,"slow"),y=(0,o.I4)((()=>{l({messageId:null==i?void 0:i.messageId,reaction:s})}),[null==i?void 0:i.messageId,s,l]),[Z,P,C]=(0,xe.Z)(),w=!f||!Z,b=(0,he.Z)("ReactionAnimatedEmoji",r&&"in-meta",v&&"is-animating");return o.ZP.createElement("div",{className:b},w&&o.ZP.createElement(Hn.Z,{reaction:s}),v&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(_n.Z,{key:m,id:`reaction_emoji_${m}`,className:I,size:30,animationData:g,play:!0,noLoop:!0,forceOnHeavyAnimation:!0,onLoad:P,onEnded:C}),o.ZP.createElement(_n.Z,{key:h,id:`reaction_effect_${h}`,className:(0,he.Z)("effect",I),size:100,animationData:p,play:!0,noLoop:!0,forceOnHeavyAnimation:!0,onEnded:y})))})),Vn=(0,o.X$)((e=>{var t;let{message:n,outgoingStatus:a,signature:s,onClick:i,withReactions:r,activeReaction:c,withReactionOffset:l,availableReactions:d,reactionMessage:u}=e;const m=(0,Oe.Z)(),[h,g]=(0,xe.Z)(),p=r&&(null==u||null===(t=u.reactions)||void 0===t?void 0:t.results.filter((e=>e.count>0))),f=(0,o.Ye)((()=>{if(!h)return;const e=(0,B.SA)(1e3*n.date,m.code),t=n.isEdited&&(0,B.SA)(1e3*n.editDate,m.code),a=n.forwardInfo&&(0,B.SA)(1e3*n.forwardInfo.date,m.code);let s=e;return t&&(s+="\n",s+=m("lng_edited_date").replace("{date}",t)),a&&(s+="\n",s+=m("lng_forwarded_date").replace("{date}",a)),s}),[h,m,n]);return o.ZP.createElement("span",{className:(0,he.Z)("MessageMeta",l&&"reactions-offset"),dir:m.isRtl?"rtl":"ltr",onClick:i},p&&p.map((e=>o.ZP.createElement(zn,{activeReaction:c,reaction:e.reaction,isInMeta:!0,availableReactions:d}))),Boolean(n.views)&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"message-views"},(0,Se.bi)(n.views)),o.ZP.createElement("i",{className:"icon-channelviews"})),s&&o.ZP.createElement("span",{className:"message-signature"},(0,tn.Z)(s)),o.ZP.createElement("span",{className:"message-time",title:f,onMouseEnter:g},n.isEdited&&`${m("EditedMessage")} `,(0,B.mr)(m,1e3*n.date)),a&&o.ZP.createElement(Gn.Z,{status:a}))}));var Xn=n(692),Wn=n(4753);const Kn=e=>{let{message:t,observeIntersection:n,observeIntersectionForPlaying:a,shouldLoop:i,lastSyncTime:r}=e;const c=(0,o.sO)(null),[d,u,m]=(0,xe.Z)(),g=t.content.sticker,{isLottie:p,stickerSetId:f,isGif:v}=g,I=h.Hh,y=f===s.$E,Z=(0,In.Op)(c,n),P=(0,In.Op)(c,a),C=g.isPreloadedGlobally?`sticker${g.id}`:(0,l.Ti)(t,"inline"),w=v&&!I&&(g.isPreloadedGlobally?`sticker${g.id}?size=m`:(0,l.Ti)(t,"pictogram")),b=(0,Lt.Z)(w),E=Ft(t),M=b||E,S=(0,Lt.Z)(C,!Z,(0,l.kG)(t,"inline"),r),R=Boolean(S),[k,T]=(0,xe.Z)(R),N=p?k:R,B=(0,Xn.Z)(N),{width:A,height:x}=(0,xt.Wr)(g),L=(0,he.Z)("thumbnail",!E&&"empty"),O=(0,he.Z)("Sticker media-inner",y&&"inactive");return(0,o.d4)((()=>{if(!v||!c.current)return;const e=c.current.querySelector("video");e&&(P?(0,Wn.Z)(e):e.pause())}),[v,P]),o.ZP.createElement("div",{ref:c,className:O,onClick:y?void 0:u},(!N||v&&!I)&&o.ZP.createElement("img",{id:`sticker-thumb-${t.id}`,src:M,width:A,height:x,alt:"",className:L}),!p&&!v&&o.ZP.createElement("img",{id:`sticker-${t.id}`,src:S,width:A,height:x,alt:"",className:(0,he.Z)("full-media",B)}),v&&I&&N&&o.ZP.createElement("video",{id:`sticker-${t.id}`,src:S,width:A,height:x,autoPlay:P,playsInline:!0,loop:i,muted:!0}),p&&R&&o.ZP.createElement(_n.Z,{key:C,className:(0,he.Z)("full-media",B),id:C,animationData:S,size:A,play:P,noLoop:!i,onLoad:T}),o.ZP.createElement(Me.Z,{isOpen:d,fromSticker:g,onClose:m}))};var Yn=n(7854),Jn=n(2566),ea=n(5866);function ta(e,t){return(0,ea.Z)((0,l.DH)(e),Boolean(t),h.wB&&!h.vX)}const na={dark:{outgoing:"rgb(135,116,225)",incoming:"rgb(33,33,33)"},light:{outgoing:"rgb(238,255,222)",incoming:"rgb(255,255,255)"}};var aa=n(9196);const sa=e=>{let{id:t,message:n,observeIntersection:a,noAvatars:s,canAutoLoad:i,isInSelectMode:r,isSelected:c,uploadProgress:d,size:u="inline",dimensions:m,nonInteractive:h,shouldAffectAppendix:g,isDownloading:p,isProtected:f,theme:v,onClick:I,onCancelUpload:y}=e;const Z=(0,o.sO)(null),P=((0,l.O$)(n)||(0,l.F$)(n)).blobUrl,C=(0,In.Op)(Z,a),[w,b]=(0,o.eJ)(i),E=w&&C,{mediaData:M,loadProgress:S}=(0,Jn.Z)((0,l.Ti)(n,u),!E),R=P||M,k=ta(n,R),{loadProgress:T}=(0,Jn.Z)((0,l.Ti)(n,"download"),!p),{isUploading:N,isTransferring:B,transferProgress:A}=(0,l.Sc)(n,d||(p?T:S),E&&!R),x=!1===(0,Et.Z)(w),L=(0,Xn.Z)(R),{shouldRender:O,transitionClassNames:F}=(0,ve.Z)(B,void 0,x,"slow"),{shouldRender:U,transitionClassNames:$}=(0,ve.Z)(!R&&!w),D=(0,o.I4)((()=>{N?y&&y(n):R?I&&I(n.id):b((e=>!e))}),[R,N,n,y,I]),j=(0,l.B4)(n);(0,o.bt)((()=>{if(!g)return;const e=Z.current.closest(".message-content");R?function(e,t,n,a,s){return a?Promise.resolve(na[s||"light"][t?"outgoing":"incoming"]):async function(e,t){const n=new Image;n.src=e,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)}(R,j,0,c,v).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute("data-has-custom-appendix","")})):e.classList.add("has-appendix-thumb")}),[R,j,g,r,c,v]);const{width:q,height:Q,isSmall:G}=m||bn(n,s),H=(0,he.Z)("media-inner",!N&&!h&&"interactive",G&&"small-image",q===Q&&"square-image"),_=m?`width: ${q}px; height: ${Q}px; left: ${m.x}px; top: ${m.y}px;`:"";return o.ZP.createElement("div",{id:t,ref:Z,className:H,style:_,onClick:N?void 0:D},o.ZP.createElement("canvas",{ref:k,className:"thumbnail",style:`width: ${q}px; height: ${Q}px`}),o.ZP.createElement("img",{src:R,className:`full-media ${L}`,width:q,height:Q,alt:"",draggable:!f}),f&&o.ZP.createElement("span",{className:"protector"}),O&&!U&&o.ZP.createElement("div",{className:`media-loading ${F}`},o.ZP.createElement(aa.Z,{progress:A,onClick:N?D:void 0})),U&&o.ZP.createElement("i",{className:(0,he.Z)("icon-download",$)}),B&&o.ZP.createElement("span",{className:"message-transfer-progress"},Math.round(100*A),"%"))};var oa=n(2019),ia=n(6898);function ra(e,t){var n;const a=(0,o.sO)(null===(n=e.current)||void 0===n?void 0:n.paused),s=(0,o.sO)();s.current=t;const i=(0,o.I4)((()=>{e.current&&(a.current=!e.current.paused,a.current&&e.current.pause())}),[e]),r=(0,o.I4)((()=>{e.current&&a.current&&s.current&&document.body.contains(e.current)&&(0,Wn.Z)(e.current)}),[e]),c=(0,o.I4)((()=>{(0,w.T2)(r)}),[r]);(0,Ie.Z)(i,c),(0,me.ZP)(i,r)}function ca(){return ca=Object.assign||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},ca.apply(this,arguments)}const la=e=>{var t;let{id:n,message:s,observeIntersection:i,noAvatars:r,canAutoLoad:c,canAutoPlay:d,uploadProgress:m,lastSyncTime:h,dimensions:g,onClick:p,onCancelUpload:f,isDownloading:v,isProtected:I}=e;const y=(0,o.sO)(null),Z=(0,o.sO)(null),P=(0,l.b7)(s)||(0,l.Cg)(s),C=P.blobUrl,w=(0,In.Op)(y,i),[b,E]=(0,o.eJ)(c),M=Boolean(b&&w&&h),[S,R]=(0,o.eJ)(d),k=(0,Lt.Z)((0,l.Ti)(s,"pictogram"),!(w&&h),(0,l.kG)(s,"pictogram"),h),T=(0,Xn.Z)(k),{mediaData:N,loadProgress:A}=(0,Jn.Z)((0,l.Ti)(s,"inline"),!M,(0,l.kG)(s,"inline"),h),x=C||N,L=Boolean(w&&x),O=ta(s,k),{loadProgress:F}=(0,Jn.Z)((0,l.Ti)(s,"download"),!v,u.IU.BlobUrl,h),{isBuffered:U,bufferingHandlers:$}=(0,oa.Z)(!c),{isUploading:D,isTransferring:j,transferProgress:q}=(0,l.Sc)(s,m||(v?F:A),M&&!U||v),Q=!1===(0,Et.Z)(b),{shouldRender:G,transitionClassNames:H}=(0,ve.Z)(j,void 0,Q),{shouldRender:_,transitionClassNames:z}=(0,ve.Z)(b&&!S&&!G),[V,X]=(0,o.eJ)(0),W=(0,o.I4)((e=>{X(Math.max(0,e.currentTarget.currentTime-1))}),[]),K=(null===(t=Z.current)||void 0===t?void 0:t.duration)||P.duration||0,Y=(0,l.B4)(s),J=(0,l.MF)(s),{width:ee,height:te}=g||(0,xt.GC)(P,Y,J,r);ra(Z,L),(0,ia.Z)(Z,[L]);const ne=(0,o.I4)((()=>{D?f&&f(s):v?(0,a.uC)().cancelMessageMediaDownload({message:s}):x?x&&!S?(R(!0),Z.current.play()):p&&p(s.id):E((e=>!e))}),[D,v,x,S,p,f,s]),ae=(0,he.Z)("media-inner dark",!D&&"interactive"),se=g?`width: ${ee}px; height: ${te}px; left: ${g.x}px; top: ${g.y}px;`:"";return o.ZP.createElement("div",{ref:y,id:n,className:ae,style:se,onClick:D?void 0:ne},o.ZP.createElement("canvas",{ref:O,className:"thumbnail",style:`width: ${ee}px; height: ${te}px;`}),o.ZP.createElement("img",{src:k,className:(0,he.Z)("thumbnail",T),style:`width: ${ee}px; height: ${te}px;`,alt:"",draggable:!I}),L&&o.ZP.createElement("video",ca({ref:Z,className:"full-media",width:ee,height:te,autoPlay:S,muted:!0,loop:!0,playsInline:!0},$,{draggable:!I,onTimeUpdate:W}),o.ZP.createElement("source",{src:x})),I&&o.ZP.createElement("span",{className:"protector"}),_&&o.ZP.createElement("i",{className:(0,he.Z)("icon-large-play",z)}),G&&o.ZP.createElement("div",{className:(0,he.Z)("media-loading",H)},o.ZP.createElement(aa.Z,{progress:q,onClick:ne})),!b&&o.ZP.createElement("i",{className:"icon-download"}),j?o.ZP.createElement("span",{className:"message-transfer-progress"},D||v?`${Math.round(100*q)}%`:"..."):o.ZP.createElement("div",{className:"message-media-duration"},P.isGif?"GIF":(0,B.k9)(Math.max(K-V,0))))};var da=n(6272);const ua=(0,a.c$)(((e,t)=>{let{contact:n}=t;const{countryList:{phoneCodes:a}}=e;return{user:(0,r.dy)(e,n.userId),phoneCodeList:a}}))((e=>{let{contact:t,user:n,phoneCodeList:s}=e;const{openChat:i}=(0,a.uC)(),{firstName:r,lastName:c,phoneNumber:l,userId:d}=t,u=(0,o.I4)((()=>{i({id:d})}),[i,d]);return o.ZP.createElement("div",{className:(0,he.Z)("Contact",Boolean(d)&&"interactive"),onClick:d?u:void 0},o.ZP.createElement(on.Z,{size:"large",user:n,text:r||c}),o.ZP.createElement("div",{className:"contact-info"},o.ZP.createElement("div",{className:"contact-name"},r," ",c),o.ZP.createElement("div",{className:"contact-phone"},(0,da.WZ)(s,l))))}));var ma=n(8974),ha=n(1218),ga=n(4434),pa=n(6937);function fa(e,t){return t>0?(e/t*100).toFixed():0}const va=e=>{let{answer:t,voteResults:n,totalVoters:a,maxVotersCount:s,correctResults:i,shouldAnimate:r}=e;const c=n&&n.find((e=>e.option===t.option)),l=0===i.length||-1!==i.indexOf(t.option),d=i.length>0&&l||(null==c?void 0:c.isChosen),u=c?fa(c.votersCount,a||0):0,[m,h]=(0,o.eJ)(r?0:u),g=(0,o.sO)(null),p=c?fa(c.votersCount,s||0):0,f=m<u;if((0,o.d4)((()=>{r&&h(u)}),[r,u]),(0,o.d4)((()=>{const e=g.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 v=`width: ${p}%; transform:scaleX(${f?0:1})`;return o.ZP.createElement("div",{className:"PollOption",dir:"ltr"},o.ZP.createElement("div",{className:"poll-option-share "+("100"===u?"limit-width":"")},u,"%",d&&o.ZP.createElement("span",{className:(0,he.Z)("poll-option-chosen",!l&&"wrong",r&&"animate")},o.ZP.createElement("i",{className:l?"icon-check":"icon-close"}))),o.ZP.createElement("div",{className:"poll-option-right"},o.ZP.createElement("div",{className:"poll-option-text",dir:"auto"},(0,tn.Z)(t.text)),o.ZP.createElement("div",{className:(0,he.Z)("poll-option-answer",d&&!l&&"wrong")},o.ZP.createElement("div",{className:"poll-option-corner",ref:g}),o.ZP.createElement("div",{className:"poll-option-line",style:v}))))},Ia=(0,o.X$)((0,a.c$)(((e,t)=>{let{poll:n}=t;const{recentVoterIds:a}=n.results,{serverTimeOffset:s,users:{byId:o}}=e;return a&&0!==a.length?{recentVoterIds:a,usersById:o,serverTimeOffset:s}:{}}))((e=>{let{message:t,poll:n,recentVoterIds:s,usersById:i,onSendVote:r,serverTimeOffset:c}=e;const{loadMessage:l,openPollResults:d}=(0,a.uC)(),{id:u,chatId:m}=t,{summary:h,results:g}=n,[p,f]=(0,o.eJ)(!1),[v,I]=(0,o.eJ)([]),[y,Z]=(0,o.eJ)(!1),[P,C]=(0,o.eJ)(!1),[w,b]=(0,o.eJ)(!h.closed&&h.closeDate&&h.closeDate>0?Math.min(h.closeDate-Math.floor(Date.now()/1e3)+c,h.closePeriod):0),E=(0,o.sO)(null),{results:M,totalVoters:S}=g,R=M&&M.some((e=>e.isChosen)),k=!h.closed&&!R,T=!k&&h.isPublic&&Number(g.totalVoters)>0,N=k&&h.multipleChoice,A=M?Math.max(...M.map((e=>e.votersCount))):S,x=M?M.reduce(((e,t)=>(t.isCorrect&&e.push(t.option),e)),[]):[],L=h.answers.map((e=>({label:e.text,value:e.option,hidden:Boolean(h.quiz&&h.closePeriod&&w<=0)})));(0,o.d4)((()=>{p&&n.results.results&&n.results.results.some((e=>e.isChosen))&&f(!1)}),[p,n.results.results]),(0,o.d4)((()=>{w>0&&setTimeout((()=>b(w-1)),1e3);const e=E.current;if(e){const t=12*Math.PI,n=e.lastElementChild,a=e.firstElementChild;if(w<=5&&e.classList.add("hurry-up"),n&&a){const e=(h.closePeriod-w)/h.closePeriod*t;a.textContent=(0,B.k9)(w),n.firstElementChild.setAttribute("stroke-dashoffset",`-${e}`)}else e.innerHTML=`\n <span>${(0,B.k9)(w)}</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>`}}),[w,h.closePeriod]),(0,o.d4)((()=>{h.quiz&&(w<=0||R&&!h.closed)&&l({chatId:m,messageId:u})}),[m,w,R,l,u,h.closed,h.quiz]),(0,o.d4)((()=>{let e;return h.quiz&&!h.closed&&h.closePeriod&&h.closePeriod>0&&(e=window.setTimeout((()=>{l({chatId:m,messageId:u})}),1e3*h.closePeriod)),()=>{e&&window.clearTimeout(e)}}),[k,m,l,u,h.closePeriod,h.closed,h.quiz]);const O=(0,o.Ye)((()=>s?s.reduce(((e,t)=>{const n=i[t];return n&&e.push(n),e}),[]):[]),[i,s]),F=(0,o.I4)((e=>{I([e]),f(!0),C(!0),r([e])}),[r]),U=(0,o.I4)((e=>{I(e)}),[]),$=(0,o.I4)((()=>{f(!0),C(!0),r(v)}),[r,v]),D=(0,o.I4)((()=>{d({chatId:m,messageId:u})}),[m,u,d]),j=(0,o.I4)((()=>{Z(!0)}),[]),q=(0,o.I4)((()=>{Z(!1),C(!1)}),[]);(0,o.d4)((()=>{P&&R&&h.quiz&&g.results&&n.results.solution&&(g.results.find((e=>e.isChosen&&e.isCorrect))||Z(!0))}),[R,P,g.results,h.quiz,n.results.solution]);const Q=(0,Oe.Z)();return o.ZP.createElement("div",{className:"Poll",dir:Q.isRtl?"auto":"ltr"},y&&n.results.solution&&o.ZP.createElement(pa.Z,{message:(0,ma.H)(n.results.solution,n.results.solutionEntities),duration:5e3,onDismiss:q,containerId:"#middle-column-portals"}),o.ZP.createElement("div",{className:"poll-question"},(0,tn.Z)(h.question,["emoji","br"])),o.ZP.createElement("div",{className:"poll-type"},Q(function(e){return void 0===e.isPublic?" ":e.quiz?e.isPublic?"QuizPoll":"AnonymousQuizPoll":e.closed?"FinalResults":e.isPublic?"PublicPoll":"AnonymousPoll"}(h)),O.length>0&&o.ZP.createElement("div",{className:"poll-recent-voters"},O.map((e=>o.ZP.createElement(on.Z,{size:"micro",user:e})))),w>0&&k&&o.ZP.createElement("div",{ref:E,className:"poll-countdown"}),h.quiz&&n.results.solution&&!k&&o.ZP.createElement(Ge.Z,{round:!0,size:"tiny",color:"translucent",className:"poll-quiz-help",disabled:y,onClick:j,ariaLabel:"Show Solution"},o.ZP.createElement("i",{className:"icon-lamp"}))),k&&o.ZP.createElement("div",{className:"poll-answers"},N?o.ZP.createElement(ha.Z,{options:L,onChange:U,disabled:t.isScheduled||p,loadingOptions:p?v:void 0,round:!0}):o.ZP.createElement(ga.Z,{name:`poll-${u}`,options:L,onChange:F,disabled:t.isScheduled||p,loadingOption:p?v[0]:void 0})),!k&&o.ZP.createElement("div",{className:"poll-results"},h.answers.map((function(e){return o.ZP.createElement(va,{key:e.option,shouldAnimate:P,answer:e,voteResults:M,totalVoters:S,maxVotersCount:A,correctResults:x})}))),!T&&!N&&o.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")}(Q,h.quiz,g.totalVoters)),N&&o.ZP.createElement(Ge.Z,{isText:!0,disabled:0===v.length,size:"tiny",onClick:$},Q("PollSubmitVotes")),T&&o.ZP.createElement(Ge.Z,{isText:!0,size:"tiny",onClick:D},Q("PollViewResults")))})));var ya=n(8035),Za=n(88);const Pa=(0,o.X$)((e=>{let{message:t,observeIntersection:n,noAvatars:a,canAutoLoad:s,canAutoPlay:i,inPreview:r,lastSyncTime:c,isDownloading:d=!1,isProtected:u,theme:m,onMediaClick:h,onCancelMediaTransfer:g}=e;const p=(0,l.s1)(t);let f=!1;if(null!=p&&p.photo&&!p.video){const{width:e,height:n}=bn(t);f=e===n}const v=(0,o.I4)((()=>{h()}),[h]);if(!p)return;const{siteName:I,url:y,displayUrl:Z,title:P,description:C,photo:w,video:b}=p,E=(w||b)&&h&&!f,M=(0,ya.Z)(C,170),S=(0,he.Z)("WebPage",f&&"with-square-photo",!w&&!b&&!r&&"without-media",b&&"with-video");return o.ZP.createElement("div",{className:S,"data-initial":(I||Z)[0],dir:"auto"},w&&!b&&o.ZP.createElement(sa,{message:t,observeIntersection:n,noAvatars:a,canAutoLoad:s,size:f?"pictogram":"inline",nonInteractive:!E,onClick:E?v:void 0,onCancelUpload:g,isDownloading:d,isProtected:u,theme:m}),o.ZP.createElement("div",{className:"WebPage-text"},o.ZP.createElement(Za.Z,{className:"site-name",url:y,text:I||Z}),!r&&P&&o.ZP.createElement("p",{className:"site-title"},(0,tn.Z)(P)),M&&o.ZP.createElement("p",{className:"site-description"},(0,tn.Z)(M,["emoji","br"]))),!r&&b&&o.ZP.createElement(la,{message:t,observeIntersection:n,noAvatars:a,canAutoLoad:s,canAutoPlay:i,lastSyncTime:c,onClick:E?v:void 0,onCancelUpload:g,isDownloading:d,isProtected:u}))}));var Ca=n(9937);const wa=(0,o.X$)((e=>{let{message:t}=e;const n=(0,Oe.Z)(),a=(0,l.eO)(t),{title:s,text:i,amount:r,currency:c,isTest:d,photoUrl:u}=a;return o.ZP.createElement("div",{className:"Invoice"},s&&o.ZP.createElement("p",{className:"title"},(0,tn.Z)(s)),i&&o.ZP.createElement("p",null,(0,tn.Z)(i,["emoji","br"])),o.ZP.createElement("div",{className:"description "+(u?"has-image":"")},u&&o.ZP.createElement("img",{className:"invoice-image",src:u,alt:""}),o.ZP.createElement("p",{className:"description-text"},(0,Ca.x)(r,c,n.code),d&&o.ZP.createElement("span",null,n("PaymentTestInvoice")))))}));function ba(e){return(0,o.X$)((0,a.c$)(((e,t)=>{const{message:n}=t;return{isInSelectMode:(0,r.CA)(e),isSelected:(0,r.vk)(e,n.id)}}))((t=>{const{isInSelectMode:n,isSelected:s,message:i,dimensions:r}=t,{toggleMessageSelection:c}=(0,a.uC)(),l=(0,o.I4)((e=>{e.stopPropagation(),c({messageId:i.id,withShift:null==e?void 0:e.shiftKey})}),[c,i]),d=(0,o.Ye)((()=>({...t,isInSelectMode:n,isSelected:s,dimensions:{...t.dimensions,x:0,y:0},onClick:n?void 0:t.onClick})),[t,n,s]);return o.ZP.createElement("div",{className:(0,he.Z)("album-item-select-wrapper",s&&"is-selected"),style:r?`left: ${r.x}px; top: ${r.y}px;`:"",onClick:n?l:void 0},n&&o.ZP.createElement("div",{className:"message-select-control"},s&&o.ZP.createElement("i",{className:"icon-select"})),o.ZP.createElement(e,d))})))}const Ea=ba(sa),Ma=ba(la),Sa=(0,a.c$)(((e,t)=>{let{album:n}=t;const{chatId:a}=n.mainMessage,s=(0,r.Pu)(e),o=(0,r.xs)(e,a);return{theme:s,uploadsById:e.fileUploads.byMessageLocalId,activeDownloadIds:o}}))((e=>{let{album:t,observeIntersection:n,hasCustomAppendix:s,lastSyncTime:i,isOwn:c,isProtected:d,albumLayout:u,onMediaClick:m,uploadsById:h,activeDownloadIds:g,theme:p}=e;const{cancelSendingMessage:f}=(0,a.uC)(),v=t.messages.length,I=(0,o.I4)((e=>{f({chatId:e.chatId,messageId:e.id})}),[f]),{width:y,height:Z}=u.containerStyle;return o.ZP.createElement("div",{className:"Album",style:`width: ${y}px; height: ${Z}px;`},t.messages.map((function(e,t){const{photo:f,video:y}=(0,l.qp)(e),Z=h[e.previousLocalId||e.id],P=null==Z?void 0:Z.progress,{dimensions:C,sides:w}=u.layout[t],b=(0,r.bH)((0,a.Rd)(),e),E=(0,r.__)((0,a.Rd)(),e);if(f){const a=s&&(c?t===v-1:Boolean(8&w&&4&w));return o.ZP.createElement(Ea,{id:`album-media-${e.id}`,message:e,observeIntersection:n,canAutoLoad:b,shouldAffectAppendix:a,uploadProgress:P,dimensions:C,isProtected:d,onClick:m,onCancelUpload:I,isDownloading:g.includes(e.id),theme:p})}if(y)return o.ZP.createElement(Ma,{id:`album-media-${e.id}`,message:e,observeIntersection:n,canAutoLoad:b,canAutoPlay:E,uploadProgress:P,lastSyncTime:i,dimensions:C,isProtected:d,onClick:m,onCancelUpload:I,isDownloading:g.includes(e.id),theme:p})})))}));function Ra(){return Ra=Object.assign||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},Ra.apply(this,arguments)}let ka;const Ta=e=>{let{message:t,observeIntersection:n,canAutoLoad:s,lastSyncTime:i,isDownloading:r}=e;const c=(0,o.sO)(null),d=(0,o.sO)(null),m=(0,o.sO)(null),h=t.content.video,g=(0,In.Op)(c,n),[p,f]=(0,o.eJ)(s),v=Boolean(p&&g&&i),{mediaData:I,loadProgress:y}=(0,Jn.Z)((0,l.Ti)(t,"inline"),!v,(0,l.kG)(t,"inline"),i),{loadProgress:Z}=(0,Jn.Z)((0,l.Ti)(t,"download"),!r,u.IU.BlobUrl,i),P=ta(t,I),{isBuffered:C,bufferingHandlers:b}=(0,oa.Z)(),E=p&&!C||r,M=!1===(0,Et.Z)(p),S=(0,Xn.Z)(I),{shouldRender:R,transitionClassNames:k}=(0,ve.Z)(E||!C,void 0,M),[T,N]=(0,o.eJ)(!1),[A,x]=(0,o.eJ)(0);(0,o.d4)((()=>{if(!T)return;const e=xt.Rj/2,t=2*(e-6)*Math.PI,n=t-A*t,a=m.current,s=d.current,o=s.firstElementChild;o?o.firstElementChild.setAttribute("stroke-dashoffset",n.toString()):s.innerHTML=`\n <svg width="${xt.Rj}px" height="${xt.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 L=Boolean(I&&g),O=(0,o.I4)((()=>{m.current&&(N(!1),x(0),(0,Wn.Z)(m.current),(0,w.T2)((()=>{d.current.innerHTML=""})))}),[]),F=(0,o.I4)((()=>{var e;null===(e=ka)||void 0===e||e(),ka=O}),[O]);(0,o.d4)((()=>{m.current&&(L?(0,Wn.Z)(m.current):m.current.pause())}),[L]),ra(m,L),(0,ia.Z)(m,[I]);const U=(0,o.I4)((()=>{if(!I)return void f((e=>!e));if(r)return void(0,a.uC)().cancelMessageMediaDownload({message:t});const e=m.current;T?e.paused?((0,Wn.Z)(e),(0,Gt.Es)()):e.pause():(F(),e.pause(),e.currentTime=0,(0,Wn.Z)(e),(0,Gt.Es)(),N(!0))}),[F,T,r,I,t]),$=(0,o.I4)((e=>{const t=e.currentTarget;x(t.currentTime/t.duration)}),[]),D=(0,he.Z)("full-media",S);return o.ZP.createElement("div",{ref:c,className:"RoundVideo media-inner",onClick:U},o.ZP.createElement("div",{className:"thumbnail-wrapper"},o.ZP.createElement("canvas",{ref:P,className:"thumbnail",style:`width: ${xt.Rj}px; height: ${xt.Rj}px`})),I&&o.ZP.createElement("div",{className:"video-wrapper"},o.ZP.createElement("video",Ra({ref:m,className:D,width:xt.Rj,height:xt.Rj,autoPlay:!0,muted:!T,loop:!T,playsInline:!0,onEnded:T?O:void 0},b,{onTimeUpdate:T?$:void 0}),o.ZP.createElement("source",{src:I}))),o.ZP.createElement("div",{className:"progress",ref:d}),R&&o.ZP.createElement("div",{className:`media-loading ${k}`},o.ZP.createElement(aa.Z,{progress:r?Z:y})),!I&&!p&&o.ZP.createElement("i",{className:"icon-download"}),o.ZP.createElement("div",{className:"message-media-duration"},T?(0,B.k9)(m.current.currentTime):(0,B.k9)(h.duration),(!T||m.current.paused)&&o.ZP.createElement("i",{className:"icon-muted"})))},Na=e=>{let{message:t,onClick:n}=e;const a=(0,Oe.Z)();return o.ZP.createElement("div",{className:"InlineButtons"},t.inlineButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(Ge.Z,{size:"tiny",ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>n({button:e})},(0,tn.Z)(a(e.text)),"buy"===e.type&&o.ZP.createElement("i",{className:"icon-card"}),"url"===e.type&&!e.value.match(s.FS)&&o.ZP.createElement("i",{className:"icon-arrow-right"}))))))))},Ba=(0,o.X$)((e=>{let{threadInfo:t,disabled:n}=e;const{openChat:s}=(0,a.uC)(),i=(0,Oe.Z)(),{threadId:r,chatId:c,messagesCount:d,lastMessageId:u,lastReadInboxMessageId:m,recentReplierIds:h}=t,g=(0,o.I4)((()=>{s({id:c,threadId:r})}),[s,c,r]),p=(0,o.Ye)((()=>{if(null==h||!h.length)return;const{users:{byId:e},chats:{byId:t}}=(0,a.Rd)();return h.map((n=>(0,l.YC)(n)?e[n]:t[n])).filter(Boolean)}),[h]);if(void 0===d)return;const f=Boolean(m&&u&&m<u);return o.ZP.createElement("div",{"data-cnt":(0,Se.bi)(d),className:(0,he.Z)("CommentButton",f&&"has-unread",n&&"disabled"),dir:i.isRtl?"rtl":"ltr",onClick:g},o.ZP.createElement("i",{className:"icon-comments-sticker"}),(!p||0===p.length)&&o.ZP.createElement("i",{className:"icon-comments"}),p&&p.length>0&&o.ZP.createElement("div",{className:"recent-repliers",dir:i.isRtl?"rtl":"ltr"},p.map((e=>o.ZP.createElement(on.Z,{key:e.id,size:"small",user:(0,l.YC)(e.id)?e:void 0,chat:(0,l.YC)(e.id)?void 0:e})))),o.ZP.createElement("div",{className:"label",dir:"auto"},d?i("Comments",d,"i"):i("LeaveAComment")),o.ZP.createElement("i",{className:"icon-next"}))})),Aa=(0,o.X$)((e=>{let{reaction:t,message:n,activeReaction:s,availableReactions:i}=e;const{sendReaction:r}=(0,a.uC)(),{recentReactions:c}=n.reactions,l=(0,o.Ye)((()=>{if(!c||t.count>3)return;const e=(0,a.Rd)().users.byId;return c.filter((e=>e.reaction===t.reaction)).map((t=>e[t.userId])).filter(Boolean)}),[t,c]),d=(0,o.I4)((()=>{r({reaction:t.isChosen?void 0:t.reaction,chatId:n.chatId,messageId:n.id})}),[n,t,r]);return o.ZP.createElement(Ge.Z,{className:(0,he.Z)(t.isChosen&&"chosen"),size:"tiny",onClick:d},o.ZP.createElement(zn,{activeReaction:s,reaction:t.reaction,availableReactions:i}),null!=l&&l.length?o.ZP.createElement("div",{className:"avatars"},l.map((e=>o.ZP.createElement(on.Z,{user:e,size:"micro"})))):(0,Se.bi)(t.count))})),xa=(0,o.X$)((e=>{let{message:t,isOutside:n,activeReaction:a,availableReactions:s,metaChildren:i}=e;return o.ZP.createElement("div",{className:(0,he.Z)("Reactions",n&&"is-outside")},t.reactions.results.map((e=>o.ZP.createElement(Aa,{key:e.reaction,reaction:e,message:t,activeReaction:a,availableReactions:s}))),i)}));var La=n(7324),Oa=n(5296);const Fa=(0,o.X$)((e=>{let{localSticker:t,localEffect:n,isOwn:a,soundId:s,size:i="medium",observeIntersection:r,messageId:c,chatId:l,activeEmojiInteractions:d}=e;const{playKey:u,ref:m,style:h,width:g,handleClick:p,markAnimationLoaded:f}=(0,Oa.Z)(i,l,c,s,d,a,n),v=`local_emoji_${t}`,I=(0,In.Op)(m,r),[y,Z]=(0,o.eJ)();return(0,o.d4)((()=>{t&&(0,La.Z)(t).then((e=>{Z(e)}))}),[t]),o.ZP.createElement("div",{ref:m,className:"AnimatedEmoji media-inner",style:h,onClick:p},y&&o.ZP.createElement(_n.Z,{key:v,id:v,animationData:y,size:g,quality:1,play:I&&u,forceOnHeavyAnimation:!0,noLoop:!0,onLoad:f}))})),Ua={__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>'},$a={__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>'},Da=(0,o.X$)((0,a.c$)(((e,t)=>{const{focusedMessage:n,forwardMessages:a,lastSyncTime:s}=e,{message:o,album:i,withSenderName:c,withAvatar:d,threadId:u,messageListType:m,isLastInDocumentGroup:h}=t,{id:g,chatId:p,viaBotId:f,replyToChatId:v,replyToMessageId:I,isOutgoing:y,threadInfo:Z}=o,P=(0,r.Z1)(e,p),C=(0,r.FM)(e,p),w=(0,l.pK)(p),b=P&&(0,l.eA)(P),E=null==P?void 0:P.username,M=!C&&(0,l.Ul)(o),S=c||d||M,R=(0,r.Ur)(e,o),k=(0,r.cv)(e,o),T=f?(0,r.dy)(e,f):void 0,N=u?(0,r.qS)(e,p,u):void 0,B=o.id===N,A=I===N,x=I&&!A?(0,r.hj)(e,w&&v?v:p,I):void 0,L=x&&(0,r.Ur)(e,x),O=(0,r.uZ)(e,o),F="thread"===m&&(i?i.messages.some((t=>(0,r._X)(e,t))):(0,r._X)(e,o)),{direction:U,noHighlight:$,isResizingContainer:D}=F&&n||{},j=a.messageIds&&a.messageIds.includes(g),{query:q}=(0,r.n5)(e)||{},Q=(0,l._O)(o);let G;G=null!=i&&i.messages?i.messages.every((t=>{let{id:n}=t;return(0,r.vk)(e,n)})):(0,r.vk)(e,g);const{canReply:H}="thread"===m&&(0,r._k)(e,o,u)||{},_=(0,r.te)(e,o),z=Z?(0,r.tZ)(e,Z.chatId,Z.threadId)||Z:void 0,V=Boolean(o.groupedId)&&!o.isInAlbum,X=V?(0,r.xH)(e,p,o.groupedId)[0]:void 0,W=V?h?(0,r.hj)(e,p,X):void 0:o,K=Q?(0,r.CP)(e,Q):void 0;return{theme:(0,r.Pu)(e),chatUsername:E,forceSenderName:M,sender:S?R:void 0,originSender:k,botSender:T,shouldHideReply:A,isThreadTop:B,replyMessage:x,replyMessageSender:L,isInDocumentGroup:V,isProtected:(0,r.EV)(e,o),isFocused:F,isForwarding:j,reactionMessage:W,isChatWithSelf:C,isRepliesChat:w,isChannel:b,canReply:H,lastSyncTime:s,highlight:q,isSingleEmoji:Boolean(Q),animatedEmoji:Q?(0,r.zB)(e,Q):void 0,animatedEmojiEffect:Q&&(0,l.YC)(p)?(0,r.tH)(e,Q):void 0,animatedEmojiSoundId:Q?(0,r.Oh)(e,Q):void 0,localSticker:K,localEffect:K&&(0,l.YC)(p)?(0,r.cu)(K):void 0,isInSelectMode:(0,r.CA)(e),isSelected:G,isGroupSelected:Boolean(o.groupedId)&&!o.isInAlbum&&(0,r.a6)(e,p,o.groupedId),threadId:u,isDownloading:_,isPinnedList:"pinned"===m,canAutoLoadMedia:(0,r.bH)(e,o),canAutoPlayMedia:(0,r.__)(e,o),autoLoadFileMaxSizeMb:e.settings.byKey.autoLoadFileMaxSizeMb,shouldLoopStickers:(0,r.yB)(e),threadInfo:z,availableReactions:e.availableReactions,defaultReaction:(0,l.CI)(o)?void 0:(0,r.q6)(e,p),activeReaction:W&&e.activeReactions[W.id],activeEmojiInteractions:e.activeEmojiInteractions,...y&&{outgoingStatus:(0,r.dT)(e,o,"scheduled"===m)},..."number"==typeof O&&{uploadProgress:O},...F&&{focusDirection:U,noFocusHighlight:$,isResizingContainer:D}}}))((e=>{let{message:t,chatUsername:n,observeIntersectionForBottom:s,observeIntersectionForMedia:i,observeIntersectionForAnimatedStickers:r,album:c,noAvatars:d,withAvatar:g,withSenderName:p,areReactionsInMeta:f,noComments:v,appearanceOrder:I,isFirstInGroup:y,isLastInGroup:Z,isFirstInDocumentGroup:P,isLastInDocumentGroup:C,isLastInList:w,theme:b,forceSenderName:E,sender:M,originSender:S,botSender:R,isThreadTop:k,shouldHideReply:T,replyMessage:N,replyMessageSender:B,outgoingStatus:A,uploadProgress:x,isInDocumentGroup:L,isProtected:O,isFocused:F,focusDirection:U,noFocusHighlight:$,isResizingContainer:D,isForwarding:j,isChatWithSelf:q,isRepliesChat:Q,isChannel:G,canReply:H,lastSyncTime:_,highlight:z,animatedEmoji:V,localSticker:X,localEffect:W,animatedEmojiEffect:K,animatedEmojiSoundId:Y,isInSelectMode:J,isSelected:ee,isGroupSelected:te,threadId:ne,reactionMessage:ae,availableReactions:se,defaultReaction:oe,activeReaction:ie,activeEmojiInteractions:re,messageListType:ce,isPinnedList:le,isDownloading:de,canAutoLoadMedia:ue,canAutoPlayMedia:me,shouldLoopStickers:ge,autoLoadFileMaxSizeMb:pe,threadInfo:fe}=e;const{toggleMessageSelection:Ie,clickInlineButton:ye,disableContextMenuHint:Ze}=(0,a.uC)(),Pe=(0,o.sO)(null),Ce=(0,o.sO)(null),we=(0,o.sO)(null),be=(0,Oe.Z)();(0,In._N)(Ce,s);const{isContextMenuOpen:Ee,contextMenuPosition:Me,handleBeforeContextMenu:Se,handleContextMenu:Re,handleContextMenuClose:ke,handleContextMenuHide:Te}=(0,Pn.Z)(Pe,h.$b&&J,!0,h.wZ);(0,o.d4)((()=>{Ee&&Ze()}),[Ee,Ze]);const Ne=I<=0,[Be,Ae]=(0,xe.Z)(Ne);(0,o.d4)((()=>{Ne||setTimeout(Ae,10*I)}),[I,Ae,Ne]);const{transitionClassNames:Le}=(0,ve.Z)(Be,void 0,Ne,!1),{id:Fe,chatId:Ue,forwardInfo:$e,viaBotId:De}=t,je=(0,l.CI)(t),qe=(0,l.B4)(t),Qe="scheduled"===ce||t.isScheduled,He=(0,l.ss)(t)&&!T,_e=Boolean(fe)&&"thread"===ce,ze=(0,l.$D)(t),Ve=X||V,Xe=(null==ae?void 0:ae.reactions)&&!(0,l.JE)(ae.reactions),We=$e&&(!q||Qe)&&!Q&&!$e.isLinkedChannelPost&&!ze,Ke=Boolean(c)&&c.messages.length>1,Ye=L&&!P,Je=L&&!C,et=void 0!==Me,tt=!(et||J||j||Je),nt=G&&!Qe,at=Boolean(le||$e&&($e.isChannelPost||q&&!qe||Q)&&$e.fromMessageId),st=fe&&!Je&&"thread"===ce&&!v,ot=!h.$b&&!J&&oe&&!Je,it=(0,o.I4)(((e,t)=>{Ie({messageId:Fe,groupedId:t,...(null==e?void 0:e.shiftKey)&&{withShift:!0},...Ke&&{childMessageIds:c.messages.map((e=>{let{id:t}=e;return t}))}})}),[Ie,Fe,Ke,c]),rt=$e&&(q||Q||!M)?S:M,ct=$e?S:M,{handleMouseDown:lt,handleClick:dt,handleContextMenu:ut,handleDoubleClick:mt,handleContentDoubleClick:ht,handleMouseMove:gt,handleSendQuickReaction:pt,handleMouseLeave:ft,isSwiped:vt,isQuickReactionVisible:It,handleDocumentGroupMouseEnter:yt}=Ln(it,Pe,Fe,0,Boolean(J),Boolean(H),Boolean(O),Re,Se,Ue,et,we,qe,Je),{handleAvatarClick:Zt,handleSenderClick:Pt,handleViaBotClick:Ct,handleReplyClick:wt,handleMediaClick:bt,handleAudioPlay:Et,handleAlbumMediaClick:Mt,handleMetaClick:St,handleReadMedia:kt,handleCancelUpload:Tt,handleVoteSend:Nt,handleGroupForward:Bt,handleForward:At,handleFocus:Lt,handleFocusForwarded:Ot,handleDocumentGroupSelectAll:Ft}=function(e,t,n,s,i,r,c,l,d,h,g,p,f){const{openChat:v,showNotification:I,focusMessage:y,openMediaViewer:Z,openAudioPlayer:P,markMessagesRead:C,cancelSendingMessage:w,sendPollVote:b,openForwardMenu:E,focusMessageInComments:M}=(0,a.uC)(),{id:S,forwardInfo:R,replyToMessageId:k,replyToChatId:T,replyToTopMessageId:N,groupedId:B}=n,A=(0,o.I4)((()=>{g&&v({id:g.id})}),[g,v]),x=(0,o.I4)((()=>{p?c&&null!=R&&R.channelPostId?y({chatId:p.id,messageId:R.channelPostId}):v({id:p.id}):I({message:e("HidAccount")})}),[c,y,R,e,v,p,I]),L=(0,o.I4)((()=>{f&&v({id:f.id})}),[f,v]),O=(0,o.I4)((()=>{y({chatId:d&&T?T:s,threadId:i,messageId:k,replyMessageId:d&&T?void 0:S})}),[y,d,T,s,i,k,S]),F=(0,o.I4)((()=>{Z({chatId:s,threadId:i,messageId:S,origin:l?m.bZ.ScheduledInline:m.bZ.Inline})}),[s,i,S,Z,l]),U=(0,o.I4)((()=>{P({chatId:s,messageId:S})}),[s,S,P]),$=(0,o.I4)((e=>{Z({chatId:s,threadId:i,messageId:e,origin:l?m.bZ.ScheduledAlbum:m.bZ.Album})}),[s,i,Z,l]),D=(0,o.I4)((()=>{C({messageIds:[S]})}),[S,C]),j=(0,o.I4)((()=>{w({chatId:s,messageId:S})}),[w,s,S]),q=(0,o.I4)((e=>{b({chatId:s,messageId:S,options:e})}),[s,S,b]),Q=(0,o.I4)((()=>{E({fromChatId:s,groupedId:B})}),[E,s,B]),G=(0,o.I4)((()=>{if(h&&h.messages){const e=h.messages.map((e=>{let{id:t}=e;return t}));E({fromChatId:s,messageIds:e})}else E({fromChatId:s,messageIds:[S]})}),[h,E,s,S]),H=(0,o.I4)((()=>{y({chatId:s,threadId:u._f,messageId:S})}),[y,s,S]),_=(0,o.I4)((()=>{r?y({chatId:R.fromChatId,groupedId:B,groupedChatId:s}):d&&T?M({chatId:T,threadId:N,messageId:R.fromMessageId}):y({chatId:R.fromChatId,messageId:R.fromMessageId})}),[r,d,T,y,R,B,s,M,N]),z=(0,o.I4)((e=>{e.stopPropagation(),t(e,B)}),[t,B]);return{handleAvatarClick:A,handleSenderClick:x,handleViaBotClick:L,handleReplyClick:O,handleMediaClick:F,handleAudioPlay:U,handleAlbumMediaClick:$,handleMetaClick:z,handleReadMedia:D,handleCancelUpload:j,handleVoteSend:q,handleGroupForward:Q,handleForward:G,handleFocus:H,handleFocusForwarded:_,handleDocumentGroupSelectAll:z}}(be,it,t,Ue,ne,L,We,Qe,Q,c,rt,ct,R),Ut=(0,he.Z)("Message message-list-item",y&&"first-in-group",O&&"is-protected",Z&&"last-in-group",P&&"first-in-document-group",C&&"last-in-document-group",w&&"last-in-list",qe&&"own",Boolean(t.views)&&"has-views",t.isEdited&&"was-edited",He&&"has-reply",et&&"has-menu-open",F&&!$&&"focused",j&&"is-forwarding",t.isDeleting&&"is-deleting",L&&"is-in-document-group",Ke&&"is-album",t.hasUnreadMention&&"has-unread-mention",ee&&"is-selected",J&&"is-in-selection-mode",k&&"is-thread-top",Boolean(t.inlineButtons)&&"has-inline-buttons",vt&&"is-swiped",Le,Boolean(ie)&&"has-active-reaction"),$t=function(e){let{hasReply:t,customShape:n,isLastInGroup:a,asForwarded:s,hasThread:o,forceSenderName:i,hasComments:r,hasActionButton:c,hasReactions:d}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{text:u,photo:m,video:h,audio:g,voice:p,document:f,poll:v,webPage:I,contact:y}=(0,l.qp)(e),Z=["message-content"],P=m||h,C=P&&!u,w=Boolean(e.viaBotId);return Cn(n)?Z.push(`emoji-only emoji-only-${n}`):u&&Z.push("text"),c&&Z.push("has-action-button"),n&&(Z.push("custom-shape"),null!=h&&h.isRound&&Z.push("round"),r&&Z.push("has-comments")),m||h?Z.push("media"):g?Z.push("audio"):p?Z.push("voice"):f?Z.push("document"):y?Z.push("contact"):v?Z.push("poll"):I&&(Z.push("web-page"),(I.photo||I.video)&&Z.push("media")),s&&Z.push("is-forwarded"),t&&Z.push("is-reply"),o&&Z.push("has-replies"),d&&Z.push("has-reactions"),w&&Z.push("is-via-bot"),i&&Z.push("force-sender-name"),n||(Z.push("has-shadow"),P&&r&&Z.push("has-background"),(t||s||!C||w||i)&&Z.push("has-solid-background"),!a||!m&&C||Z.push("has-appendix")),Z.join(" ")}(t,{hasReply:He,customShape:ze,isLastInGroup:Z,asForwarded:We,hasThread:_e,forceSenderName:E,hasComments:fe&&(null==fe?void 0:fe.messagesCount)>0,hasActionButton:nt||at,hasReactions:Xe}),jt=$t.includes("has-appendix"),qt=(0,Dt.X)(t,z,Cn(ze)),{text:Qt,photo:Gt,video:Ht,audio:_t,voice:zt,document:Vt,sticker:Xt,contact:Wt,poll:Kt,webPage:Yt,invoice:Jt}=(0,l.qp)(t);let en,nn;en=Je?"none":!qt||Ve||Yt?"standalone":"in-text",f?nn="in-meta":Xe?ze||(Gt||Ht||Ve)&&!qt?nn="outside":We?(en="standalone",nn="inside"):nn="inside":nn="none",(0,Rt.Z)(Q&&t.replyToChatId?t.replyToChatId:Ue,He?t.replyToMessageId:void 0,N,t.id),Nn(Pe,Ue,F,U,$,D);let an,sn="",rn=!1;const cn=(0,o.Ye)((()=>Ke?Rn(qe,Boolean(We),Boolean(d),c):void 0),[Ke,qe,We,d,c]),ln=We?28:0;if(Ke||!Gt&&!Ht)cn&&(an=Math.max(wn(Boolean(Qt),st),cn.containerStyle.width),an-cn.containerStyle.width>18&&(rn=!0));else{let e;Gt?e=bn(t,d).width:Ht&&(e=Ht.isRound?xt.Rj:bn(t,d).width),e&&(an=Math.max(wn(Boolean(Qt),st),e),an-e>18&&(rn=!0))}an&&(sn=`width: ${an+ln}px`);const dn=G&&t.adminTitle||!We&&(null==$e?void 0:$e.adminTitle)||void 0,un=(0,o.Ye)((()=>dn?Tn(dn):void 0),[dn]);function mn(){const e=o.ZP.createElement(Vn,{message:t,reactionMessage:ae,outgoingStatus:A,signature:dn,withReactions:"in-meta"===nn,withReactionOffset:"inside"===nn,availableReactions:se,activeReaction:ie,onClick:St});return"inside"!==nn?e:o.ZP.createElement(xa,{activeReaction:ie,message:ae,metaChildren:e,availableReactions:se})}return o.ZP.createElement("div",{ref:Pe,id:`message${Fe}`,className:Ut,style:un?`--meta-safe-author-width: ${un}px`:void 0,"data-message-id":Fe,onMouseDown:lt,onClick:dt,onContextMenu:ut,onDoubleClick:mt,onMouseEnter:Je?yt:void 0,onMouseMove:ot?gt:void 0,onMouseLeave:ot||Je?ft:void 0},o.ZP.createElement("div",{ref:Ce,className:"bottom-marker","data-message-id":Fe,"data-last-message-id":c?c.messages[c.messages.length-1].id:void 0,"data-has-unread-mention":t.hasUnreadMention}),!L&&o.ZP.createElement("div",{className:"message-select-control"},ee&&o.ZP.createElement("i",{className:"icon-select"})),C&&o.ZP.createElement("div",{className:(0,he.Z)("message-select-control group-select",te&&"is-selected"),onClick:Ft},te&&o.ZP.createElement("i",{className:"icon-select"})),g&&function(){const e=rt&&(0,l.YC)(rt.id),t=rt&&e?rt:void 0,n=rt&&!e?rt:void 0,a=!rt&&$e?$e.hiddenUserName:void 0;return o.ZP.createElement(on.Z,{size:"small",user:t,chat:n,text:a,lastSyncTime:_,onClick:t||n?Zt:void 0})}(),o.ZP.createElement("div",{className:(0,he.Z)("message-content-wrapper",$t.includes("text")&&"can-select-text")},o.ZP.createElement("div",{ref:we,className:$t,style:sn,dir:"auto"},We&&!Ye&&o.ZP.createElement("div",{className:"message-title"},be("ForwardedMessage")),function(){const e=(0,he.Z)("content-inner",We&&"forwarded-message",He&&"reply-message",rn&&"no-media-corners"),n=Z&&!qt&&!We&&!_e,a=(0,he.Z)("text-content","in-text"===en&&"with-meta",A&&"with-outgoing-icon");return o.ZP.createElement("div",{className:e,onDoubleClick:ht,dir:"auto"},function(){if(ze&&!De||!(p&&!Gt&&!Ht||We||De||E)||Ye||He&&ze)return;let e,n;return!ct||ze&&De?null!=$e&&$e.hiddenUserName&&(e=$e.hiddenUserName):(e=(0,l.OU)(be,ct),We||(n=`color-${(0,l.Rs)(ct)}`)),o.ZP.createElement("div",{className:"message-title",dir:"ltr"},e?o.ZP.createElement("span",{className:(0,he.Z)("interactive",n),onClick:Pt,dir:"auto"},(0,tn.Z)(e)):R?void 0:" ",R&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"via"},be("ViaBot")),o.ZP.createElement("span",{className:"interactive",onClick:Ct},(0,tn.Z)(`@${R.username}`))),null!=$e&&$e.isLinkedChannelPost?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},be("DiscussChannel")):t.adminTitle&&!G?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},t.adminTitle):void 0)}(),He&&o.ZP.createElement(jn,{message:N,isProtected:O,sender:B,observeIntersection:i,onClick:wt}),Xt&&o.ZP.createElement(Kn,{message:t,observeIntersection:i,observeIntersectionForPlaying:r,shouldLoop:ge,lastSyncTime:_}),V&&o.ZP.createElement(Yn.Z,{size:"small",isOwn:qe,sticker:V,effect:K,soundId:Y,observeIntersection:i,lastSyncTime:_,forceLoadPreview:je,messageId:Fe,chatId:Ue,activeEmojiInteractions:re}),X&&o.ZP.createElement(Fa,{size:"small",isOwn:qe,localSticker:X,localEffect:W,soundId:Y,observeIntersection:i,lastSyncTime:_,forceLoadPreview:je,messageId:Fe,chatId:Ue,activeEmojiInteractions:re}),Ke&&o.ZP.createElement(Sa,{album:c,albumLayout:cn,observeIntersection:i,isOwn:qe,isProtected:O,hasCustomAppendix:n,lastSyncTime:_,onMediaClick:Mt}),!Ke&&Gt&&o.ZP.createElement(sa,{message:t,observeIntersection:i,noAvatars:d,canAutoLoad:ue,uploadProgress:x,shouldAffectAppendix:n,onClick:bt,onCancelUpload:Tt,isDownloading:de,isProtected:O,theme:b}),!Ke&&Ht&&Ht.isRound&&o.ZP.createElement(Ta,{message:t,observeIntersection:i,canAutoLoad:ue,lastSyncTime:_,isDownloading:de}),!Ke&&Ht&&!Ht.isRound&&o.ZP.createElement(la,{message:t,observeIntersection:i,noAvatars:d,canAutoLoad:ue,canAutoPlay:me,uploadProgress:x,lastSyncTime:_,onClick:bt,onCancelUpload:Tt,isDownloading:de,isProtected:O}),(_t||zt)&&o.ZP.createElement(Qn.Z,{theme:b,message:t,origin:m.Cr.Inline,uploadProgress:x,lastSyncTime:_,isSelectable:L,isSelected:ee,onPlay:Et,onReadMedia:!zt||qe&&!q?void 0:kt,onCancelUpload:Tt,isDownloading:de}),Vt&&o.ZP.createElement(qn.Z,{message:t,observeIntersection:i,canAutoLoad:ue,autoLoadFileMaxSizeMb:pe,uploadProgress:x,isSelectable:L,isSelected:ee,onMediaClick:bt,onCancelUpload:Tt,isDownloading:de}),Wt&&o.ZP.createElement(ua,{contact:Wt}),Kt&&o.ZP.createElement(Ia,{message:t,poll:Kt,onSendVote:Nt}),!Ve&&qt&&o.ZP.createElement("p",{className:a,dir:"auto"},qt,"in-text"===en&&mn()),Yt&&o.ZP.createElement(Pa,{message:t,observeIntersection:i,noAvatars:d,canAutoLoad:ue,canAutoPlay:me,lastSyncTime:_,onMediaClick:bt,onCancelMediaTransfer:Tt,isDownloading:de,isProtected:O,theme:b}),Jt&&o.ZP.createElement(wa,{message:t}))}(),!Je&&"standalone"===en&&mn(),tt&&nt?o.ZP.createElement(Ge.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:be("lng_context_forward_msg"),onClick:C?Bt:At},o.ZP.createElement("i",{className:"icon-share-filled"})):tt&&at?o.ZP.createElement(Ge.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:le?Lt:Ot},o.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,st&&o.ZP.createElement(Ba,{threadInfo:fe,disabled:v}),jt&&o.ZP.createElement("div",{className:"svg-appendix",dangerouslySetInnerHTML:qe?Ua:$a}),ot&&o.ZP.createElement("div",{className:(0,he.Z)("quick-reaction",It&&!ie&&"visible"),onClick:pt},o.ZP.createElement(Hn.Z,{reaction:oe}))),t.inlineButtons&&o.ZP.createElement(Na,{message:t,onClick:ye}),"outside"===nn&&o.ZP.createElement(xa,{message:ae,isOutside:!0,activeReaction:ie,availableReactions:se})),Me&&o.ZP.createElement($n,{isOpen:Ee,anchor:Me,message:t,album:c,chatUsername:n,messageListType:ce,onClose:ke,onCloseAnimationEnd:Te}))}))),ja=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n}=t;const a=(0,r.fS)(e,n),{chatId:s,isBot:o}=a||{};return{message:a,bot:s&&o?(0,r.dy)(e,s):void 0,channel:!o&&s?(0,r.Z1)(e,s):void 0}}))((e=>{let{chatId:t,message:n,containerRef:s,bot:i,channel:r}=e;const{viewSponsoredMessage:c,openChat:d,openChatByInvite:u,startBot:m,focusMessage:h}=(0,a.uC)(),g=(0,Oe.Z)(),p=(0,o.sO)(null),f=Boolean(n),{observe:v}=(0,In.S1)({rootRef:s,debounceMs:200,threshold:1});if((0,o.d4)((()=>f?v(p.current,(e=>{e.isIntersecting&&c({chatId:t})})):void 0),[t,f,v,c]),n)return o.ZP.createElement("div",{className:"SponsoredMessage Message open",key:"sponsored-message"},o.ZP.createElement("div",{className:"message-content has-shadow has-solid-background",dir:"auto"},o.ZP.createElement("div",{className:"content-inner",dir:"auto"},o.ZP.createElement("div",{className:"message-title",dir:"ltr"},i&&(0,tn.Z)((0,l.Js)(i)||""),r&&(0,tn.Z)(n.chatInviteTitle||(0,l.U)(g,r,i)||"")),o.ZP.createElement("p",{className:"text-content with-meta",dir:"auto",ref:p},o.ZP.createElement("span",{className:"text-content-inner",dir:"auto"},(0,ma.H)(n.text.text,n.text.entities)),o.ZP.createElement("span",{className:"MessageMeta",dir:"ltr"},o.ZP.createElement("span",{className:"message-signature"},g("SponsoredMessage")))),o.ZP.createElement(Ge.Z,{color:"secondary",size:"tiny",ripple:!0,onClick:()=>{n.chatInviteHash?u({hash:n.chatInviteHash}):n.channelPostId?h({chatId:n.chatId,messageId:n.channelPostId}):(d({id:n.chatId}),n.startParam&&m({botId:n.chatId,param:n.startParam}))},className:"SponsoredMessage__button"},g(n.isBot?"Conversation.ViewBot":n.channelPostId?"Conversation.ViewPost":"Conversation.ViewChannel")))))}))),qa=(0,o.X$)((e=>{let{chatId:t,messageIds:n,messageGroups:i,isViewportNewest:r,isUnread:c,withUsers:d,areReactionsInMeta:u,noAvatars:p,containerRef:f,anchorIdRef:v,memoUnreadDividerBeforeIdRef:I,memoFirstUnreadIdRef:y,threadId:Z,type:P,isReady:C,isScrollingRef:b,isScrollPatchNeededRef:E,threadTopMessageId:M,hasLinkedChat:S,isSchedule:R,noAppearanceAnimation:k,onFabToggle:T,onNotchToggle:N}=e;const{openHistoryCalendar:A}=(0,a.uC)(),{observeIntersectionForMedia:x,observeIntersectionForReading:L,observeIntersectionForAnimatedStickers:O}=function(e,t,n){const{markMessageListRead:s,markMessagesRead:o}=(0,a.uC)(),{observe:i}=(0,In.S1)({rootRef:t,throttleMs:yn,margin:Zn}),{observe:r,freeze:c,unfreeze:l}=(0,In.S1)({rootRef:t,throttleMs:150},(t=>{if("thread"!==e)return;let a=0;const i=[];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&&i.push(o)})),n.current&&a>=n.current&&s({maxId:a}),i.length&&o({messageIds:i})}));(0,Ie.Z)(c,l);const{observe:d}=(0,In.S1)({rootRef:t,throttleMs:yn});return{observeIntersectionForMedia:i,observeIntersectionForReading:r,observeIntersectionForAnimatedStickers:d}}(P,f,y),{backwardsTriggerRef:F,forwardsTriggerRef:U,fabTriggerRef:$}=function(e,t,n,i,r,c,l,d,u,g){const{loadViewportMessages:p}=(0,a.uC)(),[f,v]=(0,o.Ye)((()=>"thread"===e?[(0,w.Ds)((()=>p({direction:m.Uq.Backwards})),1e3,!0,!1),(0,w.Ds)((()=>p({direction:m.Uq.Forwards})),1e3,!0,!1)]:[]),[p,n]),I=(0,o.sO)(null),y=(0,o.sO)(null),Z=(0,o.sO)(null);function P(){if(!d)return;if(!n||!n.length)return c(!1),void l(!1);if(!i)return c(!0),void l(!0);if(!t.current)return;const{offsetHeight:e,scrollHeight:a,scrollTop:s}=t.current,o=Math.round(a-s-e),u=o<=1;c(r?!u:!(o<=50)),l(!u)}const{observe:C}=(0,In.S1)({rootRef:t,margin:h.gZ},(e=>{if(!v||!f)return;if(n[0]>=s.AE)return;const t=e.find((e=>{let{isIntersecting:t}=e;return t}));if(!t)return;const{target:a}=t;"backwards-trigger"===a.className?(h.i4&&u.current&&n.length<=s.hT&&(g.current=!0),f()):"forwards-trigger"===a.className&&v()}));(0,In._N)(I,C),(0,In._N)(y,C);const{observe:b,freeze:E,unfreeze:M}=(0,In.S1)({rootRef:t,margin:100},P);(0,In._N)(Z,b);const{observe:S,freeze:R,unfreeze:k}=(0,In.S1)({rootRef:t,margin:1},P);return(0,In._N)(Z,S),(0,Ze.Z)((()=>{d&&P()}),[d]),(0,Ze.Z)((()=>{E(),R(),setTimeout((()=>{k(),M()}),250)}),[n]),{backwardsTriggerRef:I,forwardsTriggerRef:y,fabTriggerRef:Z}}(P,f,n,r,c,T,N,C,b,E),D=(0,Oe.Z)(),j=o.ZP.createElement("div",{className:(0,he.Z)("unread-divider","local-action-message"),key:"unread-messages"},o.ZP.createElement("span",null,D("UnreadMessages"))),q=k?0:i.reduce(((e,t)=>e+(0,g.xH)(t.senderGroups).length),0);let Q=0;const G=i.map(((e,t,n)=>{const a=e.senderGroups.map(((e,a,s)=>{if(1===e.length&&!un(e[0])&&(0,l.Lo)(e[0])){const i=e[0],r=a===s.length-1&&t===n.length-1;return(0,g.oA)([i.id===I.current&&j,o.ZP.createElement(Dn,{key:i.id,message:i,observeIntersection:L,appearanceOrder:q-++Q,isLastInList:r})])}let i;return(0,g.xH)(e.map(((r,c)=>{const m=un(r)?r.mainMessage:r,h=un(r)?r:void 0,f=(0,l.B4)(m),y=un(r),C=e[c+1];m.previousLocalId&&v.current===`message${m.previousLocalId}`&&(v.current=`message${m.id}`);const w=!y&&m.groupedId?m.groupedId:void 0,b=C&&!un(C)?C.groupedId:void 0,E={isFirstInGroup:0===c,isLastInGroup:c===e.length-1,isFirstInDocumentGroup:Boolean(w&&w!==i),isLastInDocumentGroup:Boolean(w&&w!==b),isLastInList:c===e.length-1&&a===s.length-1&&t===n.length-1};i=w;const R=(0,l.KK)(m),k="scheduled"!==P?R:`${m.date}_${R}`;return(0,g.oA)([m.id===I.current&&j,o.ZP.createElement(Da,{key:k,message:m,observeIntersectionForBottom:L,observeIntersectionForMedia:x,observeIntersectionForAnimatedStickers:O,album:h,noAvatars:p,withAvatar:E.isLastInGroup&&d&&!f&&!(m.id===M),withSenderName:E.isFirstInGroup&&d&&!f,areReactionsInMeta:u,threadId:Z,messageListType:P,noComments:!1===S,appearanceOrder:q-++Q,isFirstInGroup:E.isFirstInGroup,isLastInGroup:E.isLastInGroup,isFirstInDocumentGroup:E.isFirstInDocumentGroup,isLastInDocumentGroup:E.isLastInDocumentGroup,isLastInList:E.isLastInList}),m.id===M&&o.ZP.createElement("div",{className:"local-action-message",key:"discussion-started"},o.ZP.createElement("span",null,D("DiscussionStarted")))])})))}));return o.ZP.createElement("div",{className:"message-date-group",key:e.datetime,onMouseDown:hn.q,teactFastList:!0},o.ZP.createElement("div",{className:(0,he.Z)("sticky-date",!R&&"interactive"),key:"date-header",onMouseDown:hn.q,onClick:R?void 0:()=>A({selectedAt:e.datetime})},o.ZP.createElement("span",{dir:"auto"},R&&e.originalDate===s.t4&&D("MessageScheduledUntilOnline"),R&&e.originalDate!==s.t4&&D("MessageScheduledOn",(0,B.j1)(D,e.datetime,void 0,!0)),!R&&(0,B.j1)(D,e.datetime))),(0,g.xH)(a))}));return o.ZP.createElement("div",{className:"messages-container",teactFastList:!0},o.ZP.createElement("div",{ref:F,key:"backwards-trigger",className:"backwards-trigger"}),(0,g.xH)(G),r&&o.ZP.createElement(ja,{key:t,chatId:t,containerRef:f}),o.ZP.createElement("div",{ref:U,key:"forwards-trigger",className:"forwards-trigger"}),o.ZP.createElement("div",{ref:$,key:"fab-trigger",className:"fab-trigger"}))}));var Qa=n(3547);const Ga=(0,o.X$)((0,a.c$)(((e,t)=>{let{userId:n}=t;const{stickers:a}=e.stickers.greeting,s=(0,l.db)(n)+(0,l.db)(e.currentUserId),o=null!=a&&a.length?a[s%a.length]:void 0,i=(0,r.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:i,sendMessage:r,markMessageListRead:c}=(0,a.uC)(),l=(0,Oe.Z)(),d=(0,o.sO)(null),{observe:u}=(0,In.S1)({rootRef:d,debounceMs:200});(0,o.d4)((()=>{t||"connectionStateReady"!==n||i()}),[n,i,t]),(0,o.d4)((()=>{"connectionStateReady"===n&&s&&c({maxId:s})}),[n,c,s]);const m=(0,o.I4)((e=>{e={...e,isPreloadedGlobally:!0},r({sticker:e})}),[r]);return o.ZP.createElement("div",{className:"ContactGreeting",ref:d},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("p",{className:"title",dir:"auto"},l("Conversation.EmptyPlaceholder")),o.ZP.createElement("p",{className:"description",dir:"auto"},l("Conversation.GreetingText")),o.ZP.createElement("div",{className:"sticker"},t&&o.ZP.createElement(Qa.Z,{sticker:t,onClick:m,clickArg:t,observeIntersection:u,size:160,className:"large"}))))}))),Ha=(0,o.X$)((e=>{let{isChatWithSelf:t,type:n,isGroupChatJustCreated:a}=e;const s=(0,Oe.Z)();return"scheduled"===n?function(e){return o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,e("ScheduledMessages.EmptyPlaceholder")))}(s):t?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("i",{className:"icon icon-cloud-download"}),o.ZP.createElement("h3",{className:"title"},e("Conversation.CloudStorageInfo.Title")),o.ZP.createElement("ul",{className:"description"},o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description1")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description2")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description3")),o.ZP.createElement("li",null,e("Conversation.ClousStorageInfo.Description4")))))}(s):a?function(e){return o.ZP.createElement("div",{className:"NoMessages"},o.ZP.createElement("div",{className:"wrapper",dir:e.isRtl?"rtl":void 0},o.ZP.createElement("h3",{className:"title"},e("EmptyGroupInfo.Title")),o.ZP.createElement("p",{className:"description"},e("EmptyGroupInfo.Subtitle")),o.ZP.createElement("ul",{className:"list-checkmarks"},o.ZP.createElement("li",null,e("EmptyGroupInfo.Line1")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line2")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line3")),o.ZP.createElement("li",null,e("EmptyGroupInfo.Line4")))))}(s):o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,s("NoMessages")))})),_a=(0,w.Ds)((e=>e()),200,!1),za=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n,threadId:a,type:s}=t;const o=(0,r.Z1)(e,n);if(!o)return{};const i=(0,r.$W)(e,n,a,s),c="scheduled"===s?(0,r.Fn)(e,n):(0,r.Zw)(e,n),d=(0,r.qS)(e,n,a);if(a!==u._f&&!(c&&d&&c[d]))return{};const{isRestricted:m,restrictionReason:h,lastMessage:g}=o,p=(0,r.G$)(e,n),f=a===u._f&&!i&&!o.unreadCount&&!p&&g&&!g.groupedId,v=(0,r.IK)(e,n);let I;return(0,r.pk)(e,n)&&(I=v.fullInfo?v.fullInfo.botDescription||"NoMessages":"Updating bot info..."),{isChatLoaded:!0,isRestricted:m,restrictionReason:h,isChannelChat:(0,l.eA)(o),isGroupChat:(0,l.Bf)(o),isCreator:o.isCreator,isChatWithSelf:(0,r.FM)(e,n),isRepliesChat:(0,l.pK)(n),isBot:Boolean(v),messageIds:i,messagesById:c,firstUnreadId:(0,r.It)(e,n,a),isViewportNewest:"thread"!==s||(0,r.b9)(e,n,a),threadFirstMessageId:(0,r.yZ)(e,n,a),focusingId:p,isSelectModeActive:(0,r.CA)(e),botDescription:I,threadTopMessageId:d,hasLinkedChat:o.fullInfo&&"linkedChatId"in o.fullInfo?Boolean(o.fullInfo.linkedChatId):void 0,lastSyncTime:e.lastSyncTime,...f&&{lastMessage:g}}}))((e=>{var t,n,i,c,d,u;let{chatId:h,threadId:p,type:f,hasTools:v,onFabToggle:I,onNotchToggle:y,isChatLoaded:Z,isChannelChat:P,isGroupChat:C,canPost:b,isReady:E,isChatWithSelf:M,isRepliesChat:S,isCreator:R,isBot:k,messageIds:T,messagesById:N,firstUnreadId:B,isViewportNewest:A,threadFirstMessageId:x,isRestricted:L,restrictionReason:O,focusingId:F,isSelectModeActive:U,lastMessage:$,botDescription:D,threadTopMessageId:j,hasLinkedChat:q,lastSyncTime:Q,withBottomShift:G}=e;const{loadViewportMessages:H,setScrollOffset:_,loadSponsoredMessages:z,loadMessageReactions:V}=(0,a.uC)(),X=(0,o.sO)(null),W=(0,o.sO)("thread"===f&&(0,r.Vt)((0,a.Rd)(),h,p)||0),K=(0,o.sO)(),Y=(0,o.sO)(),J=(0,o.sO)(),ee=(0,o.sO)(),te=(0,o.sO)(),ne=(0,o.sO)(),ae=(0,o.sO)(!1),se=(0,o.sO)(Boolean($)),[oe,ie]=(0,o.eJ)(),re=Boolean(T);(0,Ze.Z)((()=>{re&&(0,w.R3)((()=>{se.current=!1}))}),[re]),(0,Ze.Z)((()=>{ee.current=B}),[B]),(0,Ze.Z)((()=>{P&&E&&Q&&z({chatId:h})}),[h,E,P,Q]),(0,Ze.Z)((()=>{re&&(te.current=ee.current)}),[re]),(0,Ze.Z)((()=>{ne.current=F}),[F]);const ce=(0,o.Ye)((()=>{if(!T||!N)return;const e=!j||T[0]&&x!==T[0]?T:[j,...T];if(!e.length)return;const t=e.map((e=>N[e])).filter(Boolean);return mn((0,g.Xo)(t,["date","id"]),te.current)}),[T,N,x,j]);(0,vn.Z)((()=>{if(!T||!N)return;const e=T.filter((e=>{var t;return null===(t=N[e])||void 0===t?void 0:t.reactions}));e.length&&V({chatId:h,ids:e})}),15e3);const le=(0,o.Ye)((()=>{if("thread"===f)return(0,w.Ds)((()=>H({direction:m.Uq.Around})),1e3,!0,!1)}),[H,T]),{isScrolled:de,updateStickyDates:ue}=function(){const[e,t]=(0,xe.Z)(!1),n=(0,gn.Z)(1e3,!0);return{isScrolled:e,updateStickyDates:(0,o.I4)(((e,a)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,w.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),n((()=>{(0,w.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])}}(),ge=(0,o.sO)(),pe=(0,o.sO)(),fe=(0,o.I4)((()=>{if(ae.current)return void(ae.current=!1);ge.current=!0;const e=X.current;ne.current||ue(e,v),_a((()=>{ge.current=!1,(0,w.T2)((()=>{e.parentElement&&(W.current=e.scrollHeight-e.scrollTop,"thread"===f&&_({chatId:h,threadId:p,scrollOffset:W.current}))}))}))}),[ue,v,f,_,h,p]);(0,o.d4)((()=>{if(!("ResizeObserver"in window))return;const e=new ResizeObserver((e=>{let[t]=e;t.target.offsetParent&&ie(t.contentRect.height)}));return e.observe(X.current),()=>{e.disconnect()}}),[]);const{height:ve}=wt();(0,o.d4)((()=>{X.current.dataset.normalHeight=String(X.current.offsetHeight)}),[ve,b]),(0,o.d4)((()=>{if(!le||!Z||L||F)return;if(T&&T[T.length-1]>=s.AE)return;const e=X.current;(!T||T.length<s.hT/2&&e.firstElementChild.clientHeight<=e.offsetHeight)&&le()}),[Z,T,le,F,L]),(0,Ze.Z)((()=>{if(!T||!J.current)return;const e=J.current.filter((e=>T.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(K.current=t.id,Y.current=t.getBoundingClientRect().top)}),[T,A,oe,v]),(0,ln.Z)((e=>{let[t,n,a]=e;const o=X.current;J.current=Array.from(o.querySelectorAll(".message-list-item"));const i=T&&t&&T[T.length-1]!==t[t.length-1],r=(null==T?void 0:T[0])!==(null==t?void 0:t[0])&&(null==T?void 0:T.length)===s.hT/2+1,c=i&&!r,l=T&&ne.current===T[T.length-1],d=A&&c&&T&&T.length<s.hT/2&&!o.parentElement.classList.contains("force-messages-scroll")&&o.firstElementChild.clientHeight<=2*o.offsetHeight;d&&(o.parentElement.classList.add("force-messages-scroll"),setTimeout((()=>{o.parentElement&&o.parentElement.classList.remove("force-messages-scroll")}),500));const{scrollTop:u,scrollHeight:m,offsetHeight:h}=o,g=W.current,p=J.current[J.current.length-1];let f=g-(a||h);c&&(f-=p?p.offsetHeight:0);const I=A&&n&&f<=20;let y;if(c&&I&&!l&&(p&&(0,w.T2)((()=>{(0,fn.Z)(o,p,"end",20)})),y=m-h,W.current=Math.max(Math.ceil(m-y),h),!d))return;const Z=void 0!==a&&a!==oe,P=K.current&&o.querySelector(`#${K.current}`),C=!P&&te.current&&o.querySelector(".unread-divider");if(I&&Z){if((0,fn.N)())return;y=m-h}else P?(pe.current&&(pe.current=!1,(0,pn.z)(o)),y=u+(P.getBoundingClientRect().top-(Y.current||0))):y=C?Math.min(C.offsetTop-(v?60:10),m-g):m-g;(0,pn.Z)(o,Math.ceil(y)),ne.current||(ae.current=!0,(0,w.T2)((()=>{ae.current=!1}))),W.current=Math.max(Math.ceil(m-y),h)}),[T,A,oe,v]),(0,dn.Z)((e=>{let[t]=e;void 0!==t&&(0,me.YW)(200+s.fK)}),[U]);const Ie=(0,Oe.Z)(),ye=Boolean(h&&(0,l.YC)(h)),Pe=Boolean(!ye&&!P||M||S),Ce=Boolean(!Pe||P),we=(0,l.YC)(h)&&!M&&!k&&(!ce&&!$&&T&&(!J.current||0===J.current.length)||1===(null==T?void 0:T.length)&&"contactSignUp"===(null==N||null===(t=N[T[0]])||void 0===t||null===(n=t.content.action)||void 0===n?void 0:n.type)||"contactSignUp"===(null==$||null===(i=$.content)||void 0===i||null===(c=i.action)||void 0===c?void 0:c.type)),be=C&&R&&1===(null==T?void 0:T.length)&&"chatCreate"===(null==N||null===(d=N[T[0]])||void 0===d||null===(u=d.content.action)||void 0===u?void 0:u.type),Ee=(0,he.Z)("MessageList custom-scroll",Ce&&"no-avatars",!b&&"no-composer","pinned"===f&&"type-pinned",G&&"with-bottom-shift",U&&"select-mode-active",de&&"scrolled",!E&&"is-animating");return o.ZP.createElement("div",{ref:X,className:Ee,onScroll:fe,onMouseDown:hn.q},L?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,O?O.text:"This is a private "+(P?"channel":"chat"))):D?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,(0,tn.Z)(Ie(D),["br","emoji","links"]))):we?o.ZP.createElement(Ga,{userId:h}):!T||ce&&!be?T&&ce||$?o.ZP.createElement(qa,{chatId:h,messageIds:T||[$.id],messageGroups:ce||mn([$]),isViewportNewest:Boolean(A),isUnread:Boolean(B),withUsers:Pe,areReactionsInMeta:ye,noAvatars:Ce,containerRef:X,anchorIdRef:K,memoUnreadDividerBeforeIdRef:te,memoFirstUnreadIdRef:ee,threadId:p,type:f,isReady:E,isScrollingRef:ge,isScrollPatchNeededRef:pe,threadTopMessageId:j,hasLinkedChat:q,isSchedule:!!ce&&"scheduled"===f,noAppearanceAnimation:!ce||!se.current,onFabToggle:I,onNotchToggle:y}):o.ZP.createElement(ot.Z,{color:"white",backgroundColor:"dark"}):o.ZP.createElement(Ha,{chatId:h,type:f,isChatWithSelf:M,isGroupChatJustCreated:be}))}))),Va=(0,o.X$)((0,a.c$)((e=>{const t=(0,r.Bt)(e);if(!t)return{};const{chatId:n,threadId:a,type:s}=t,o=(0,r.Z1)(e,n);return{messageListType:s,unreadCount:o&&a===u._f&&"thread"===s?o.unreadCount:void 0}}))((e=>{let{isShown:t,canPost:n,messageListType:s,unreadCount:i,withExtraShift:r}=e;const{focusNextReply:c}=(0,a.uC)(),l=(0,Oe.Z)(),d=(0,o.sO)(null),u=(0,o.I4)((()=>{if(t)if("thread"===s)c();else{const e=d.current.parentElement.querySelector(".MessageList"),t=e.querySelectorAll(".message-list-item"),n=t[t.length-1];if(!n)return;(0,fn.Z)(e,n,"end",20)}}),[t,s,c]),m=(0,he.Z)("ScrollDownButton",t&&"revealed",!n&&"no-composer",r&&"with-extra-shift");return o.ZP.createElement("div",{ref:d,className:m},o.ZP.createElement("div",{className:"ScrollDownButton-inner"},o.ZP.createElement(Ge.Z,{color:"secondary",round:!0,onClick:u,ariaLabel:l("AccDescrPageDown")},o.ZP.createElement("i",{className:"icon-arrow-down"})),Boolean(i)&&o.ZP.createElement("div",{className:"unread-count"},(0,Se.bi)(i))))})));var Xa=n(5723);const Wa=1280,Ka=/\.[^/.]+$/;async function Ya(e,t,n,a){const o=URL.createObjectURL(t),{type:i,size:r}=t;let c,l;if(s.oG.has(i))if(n){const t=await(0,Ct.pt)(o),{width:n,height:s}=t;if(n>Wa||s>Wa||"image/jpeg"!==i){const t=await Vt(o,Wa/Math.max(n,s),"image/jpeg");return URL.revokeObjectURL(o),Ya(e,await(0,Ct.gm)(t),!0,a)}"image/jpeg"===i&&(e=e.replace(Ka,".jpg")),c={width:n,height:s}}else l=o;else if(s.wG.has(i)){const{videoWidth:e,videoHeight:t,duration:n}=await(0,Ct.jj)(o);c={width:e,height:t,duration:n},l=await(0,Ct.ud)(o)}return{blobUrl:o,filename:e,mimeType:i,size:r,quick:c,previewBlobUrl:l,...a}}function Ja(e){const t=window.getSelection();if(null!=t&&t.getRangeAt&&t.rangeCount){const n=t.getRangeAt(0);n.deleteContents();const a=n.createContextualFragment(e),s=a.lastChild;n.insertNode(a),s?(n.setStartAfter(s),n.setEndAfter(s)):n.collapse(!1),t.removeAllRanges(),t.addRange(n)}}var es=n(6391);let ts;function ns(e){ts.focus(),e.focus()}h.cj&&(ts=document.createElement("input"),ts.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(ts));var as=n(4784),ss=n(2400),os=n(6389),is=n(971);const rs={encoderPath:new URL(n(8973),n.b).href,reuseWorker:!0},cs={type:"audio/ogg"};let ls,ds,us;async function ms(){return ls||(ls=n.e(161).then(n.t.bind(n,1161,23)),ds=(await ls).default,us=new ds(rs)),ls}async function hs(e){await async function(){await ms(),await us.start()}();const t=Date.now();let n;const a=[],s=[];us.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}}(us);return{stop:()=>new Promise(((e,i)=>{us.onstop=()=>{e({blob:new Blob(a,cs),duration:Math.round(((n||Date.now())-t)/1e3),waveform:s})},us.onerror=i;const r=Math.max(0,t+1e3-Date.now());setTimeout((()=>{us.stop(),o()}),r)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{us.pause(),n=Date.now(),o()}),e)}}}var gs=n(1262);const ps=["image/png","image/jpeg","image/gif"];let fs,vs;var Is=n(3575),ys=n(9295);function Zs(e,t,n){const a=(0,gn.Z)(t,!0),[s,i]=(0,o.eJ)(),[r,c,l]=(0,xe.Z)();return(0,me.ZP)(c,l),(0,Ze.Z)((()=>{r||a((()=>{i(e())}))}),[...n,r]),s}const Ps=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,Cs=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i,ws={username:"",query:"",canShowHelp:!1,usernameLowered:""},bs=document.createElement("div");const Es=(0,w.P2)((e=>e()),500,!0),Ms=/^[\w@]{1,32}\s?/i,Ss=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"DeleteMessageModal",!t);return n?o.ZP.createElement(n,e):void 0}));function Rs(){return Rs=Object.assign||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},Rs.apply(this,arguments)}let ks,Ts=!0;const Ns=(0,o.X$)((e=>{let{onActivate:t,...n}=e;const a=(0,o.sO)(!1),s=(0,o.I4)((()=>{if(a.current=!0,Ts)return Ts=!1,void t();ks&&(clearTimeout(ks),ks=void 0),ks=window.setTimeout((()=>{a.current&&t()}),200)}),[t]),i=(0,o.I4)((()=>{a.current=!1}),[]);return o.ZP.createElement(Ge.Z,Rs({},n,{onMouseEnter:h.$b?void 0:s,onMouseLeave:h.$b?void 0:i,onClick:h.$b?t:void 0}))})),Bs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"CalendarModal",!t);return n?o.ZP.createElement(n,e):void 0})),As=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"AttachMenu",!t);return n?o.ZP.createElement(n,e):void 0})),xs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"SymbolMenu",!t);return n?o.ZP.createElement(n,e):void 0})),Ls=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"InlineBotTooltip",!t);return n?o.ZP.createElement(n,e):void 0})),Os=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"MentionTooltip",!t);return n?o.ZP.createElement(n,e):void 0})),Fs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"CustomSendMenu",!t);return n?o.ZP.createElement(n,e):void 0})),Us=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"StickerTooltip",!t);return n?o.ZP.createElement(n,e):void 0}));var $s=n(9830);const Ds=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"BotCommandTooltip",!t);return n?o.ZP.createElement(n,e):void 0}));var js=n(6503);const qs=(0,o.X$)((0,a.c$)(((e,t)=>{let{messageId:n}=t;const{chatId:a}=(0,r.Bt)(e)||{};return a?{message:(0,r.hj)(e,a,n)}:{}}))((e=>{let{isOpen:t,message:n,onClose:s}=e;const{clickInlineButton:i}=(0,a.uC)(),[r,c]=(0,js.Z)(t,s),{isKeyboardSingleUse:l}=n||{},[d,u,m]=(0,xe.Z)(!0),g=()=>{m(),s()};if((0,o.d4)((()=>{u()}),[u,null==n?void 0:n.keyboardButtons]),n&&n.keyboardButtons)return o.ZP.createElement(ct.Z,{isOpen:t||d,autoClose:l,positionX:"right",positionY:"bottom",onClose:g,className:"BotKeyboardMenu",onCloseAnimationEnd:g,onMouseEnter:h.$b?void 0:r,onMouseLeave:h.$b?void 0:c},o.ZP.createElement("div",{className:"content"},n.keyboardButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(Ge.Z,{ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>i({button:e})},e.text))))))))})));var Qs=n(3616),Gs=n(7891);const Hs=(0,o.X$)((0,a.c$)((e=>{const{chatId:t,threadId:n,type:a}=(0,r.Bt)(e)||{};if(!t||!n||!a)return{};const{currentUserId:s,forwardMessages:{fromChatId:o,toChatId:i,messageIds:c}}=e,d=(0,r.Yy)(e,t,n),u="scheduled"===a?(0,r.wU)(e,t):(0,r._$)(e,t,n),m=e.settings.byKey.animationLevel>=1,h=i===t;let g,p;if(d?g=(0,r.hj)(e,t,d):u?g=(0,r.kK)(e,t,n,a):h&&1===c.length&&(g=(0,r.hj)(e,o,c[0])),d&&g){const{forwardInfo:n}=g,a=t===s;n&&(n.isChannelPost||a)&&(p=(0,r.cv)(e,g)),p||(p=(0,r.Ur)(e,g))}else h&&(p=(0,l.YC)(o)?(0,r.dy)(e,o):(0,r.Z1)(e,o));return{replyingToId:d,editingId:u,message:g,sender:p,shouldAnimate:m,forwardedMessagesCount:h?c.length:void 0}}))((e=>{let{replyingToId:t,editingId:n,message:s,sender:i,shouldAnimate:r,forwardedMessagesCount:c}=e;const{setReplyingToId:l,setEditingId:d,focusMessage:u,exitForwardMode:m}=(0,a.uC)(),h=Boolean((t||n)&&s||i&&c),g=(0,Gs.Z)([c],c?300:void 0),{shouldRender:p,transitionClassNames:f}=(0,ve.Z)(g&&h,void 0,!r,void 0,!r),v=(0,o.I4)((()=>{t?l({messageId:void 0}):n?d({messageId:void 0}):c&&m()}),[t,n,c,l,d,m]);(0,o.d4)((()=>h?(0,Ne.Z)(v):void 0),[h,v]);const I=(0,o.I4)((()=>{u({chatId:s.chatId,messageId:s.id})}),[u,s]),y=(0,he.Z)("ComposerEmbeddedMessage",f),Z=c&&c>1?`${c} forwarded messages`:void 0;if(p)return o.ZP.createElement("div",{className:y},o.ZP.createElement("div",null,o.ZP.createElement(Ge.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Cancel replying",onClick:v},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(jn,{className:"inside-input",message:s,sender:i,customText:Z,title:n?"Edit Message":void 0,onClick:I})))}))),_s=(0,o.X$)((e=>{const{attachments:t}=e,n=(0,st.Z)(at.gl.Extra,"AttachmentModal",!t.length);return n?o.ZP.createElement(n,e):void 0})),zs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"BotCommandMenu",!t);return n?o.ZP.createElement(n,e):void 0})),Vs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"PollModal",!t);return n?o.ZP.createElement(n,e):void 0})),Xs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"DropArea",!t);return n?o.ZP.createElement(n,e):void 0})),Ws=new RegExp(s.FM,"i"),Ks=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n,threadId:a}=t;const s=(0,r.tV)(e,n,a);return{theme:(0,r.Pu)(e),webPagePreview:e.webPagePreview,noWebPage:s}}))((e=>{let{chatId:t,threadId:n,messageText:s,disabled:i,webPagePreview:r,noWebPage:c,theme:l}=e;const{loadWebPagePreview:d,clearWebPagePreview:m,toggleMessageWebPage:h}=(0,a.uC)(),g=Zs((()=>{const{text:e,entities:t}=(0,v.Z)(s),n=t&&t.find((e=>{let{type:t}=e;return t===u.Vv.TextUrl}));if(n)return n.url;const a=e.match(Ws);return a?a[0]:void 0}),300,[s]);(0,o.d4)((()=>{g?d({text:g}):(m(),h({chatId:t,threadId:n}))}),[t,h,m,g,d,n]),(0,Ze.Z)((()=>{m(),h({chatId:t,threadId:n})}),[t]);const p=Boolean(r&&s.length&&!c&&!i),{shouldRender:f,transitionClassNames:I}=(0,ve.Z)(p),y=(0,kt.Z)(r,!0);if(!f||!y)return;const{photo:Z,...P}=y,C={content:{webPage:P}};return o.ZP.createElement("div",{className:(0,he.Z)("WebPagePreview",I)},o.ZP.createElement("div",null,o.ZP.createElement(Ge.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Clear Webpage Preview",onClick:()=>{h({chatId:t,threadId:n,noWebPage:!0})}},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Pa,{message:C,inPreview:!0,theme:l})))}))),Ys=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"SendAsMenu",!t);return n?o.ZP.createElement(n,e):void 0}));var Js;!function(e){e.Send="send",e.Record="record",e.Edit="edit",e.Schedule="schedule"}(Js||(Js={}));const eo="wonderful-voice-message.ogg",to=(0,o.X$)((0,a.c$)(((e,t)=>{var n,a,o,i,c;let{chatId:d,threadId:m,messageListType:h}=t;const g=(0,r.Z1)(e,d),p=g&&(0,r.Dg)(e,g),f=d!==s.FV?(0,r.IK)(e,d):void 0,v=Boolean(f),I=(0,r.FM)(e,d),y=v&&(0,r.FT)(e,d),Z=(0,r.qy)(e,d),{language:P,shouldSuggestStickers:C}=e.settings.byKey,w=e.emojiKeywords[s.pR],b=P!==s.pR?e.emojiKeywords[P]:void 0,E=y?y.id:void 0,M=E?(0,r.hj)(e,d,E):void 0,{currentUserId:S}=e,R=null!=g&&g.fullInfo?(null==g||null===(n=g.fullInfo)||void 0===n?void 0:n.sendAsId)||S:void 0,k=null!=g&&g.sendAsIds&&R&&g.sendAsIds.includes(R)?R:null!=g&&null!==(a=g.adminRights)&&void 0!==a&&a.anonymous?null==g?void 0:g.id:void 0,T=k?(0,r.dy)(e,k):void 0,N=!T&&k?(0,r.Z1)(e,k):void 0;return{editingMessage:(0,r.kK)(e,d,m,h),connectionState:e.connectionState,draft:(0,r.Ms)(e,d,m),chat:g,isChatWithBot:v,isChatWithSelf:I,canScheduleUntilOnline:Boolean(!I&&!v&&g&&p&&(0,l.YC)(d)&&(null===(o=(0,r.ss)(e,d))||void 0===o?void 0:o.wasOnline)),isRightColumnShown:(0,r.Jf)(e),isSelectModeActive:(0,r.CA)(e),withScheduledButton:m===u._f&&"thread"===h&&Boolean(null==Z?void 0:Z.length),shouldSchedule:"scheduled"===h,botKeyboardMessageId:E,botKeyboardPlaceholder:null==M?void 0:M.keyboardPlaceholder,isForwarding:d===e.forwardMessages.toChatId,isPollModalOpen:e.isPollModalOpen,stickersForEmoji:e.stickers.forEmoji.stickers,groupChatMembers:null==g||null===(i=g.fullInfo)||void 0===i?void 0:i.members,topInlineBotIds:null===(c=e.topInlineBots)||void 0===c?void 0:c.userIds,currentUserId:S,lastSyncTime:e.lastSyncTime,contentToBeScheduled:e.messages.contentToBeScheduled,shouldSuggestStickers:C,recentEmojis:e.recentEmojis,baseEmojiKeywords:null==w?void 0:w.keywords,emojiKeywords:null==b?void 0:b.keywords,serverTimeOffset:e.serverTimeOffset,inlineBots:e.inlineBots.byUsername,isInlineBotLoading:e.inlineBots.isLoading,chatBotCommands:g&&g.fullInfo&&g.fullInfo.botCommands,botCommands:f&&f.fullInfo?f.fullInfo.botCommands||!1:void 0,sendAsUser:T,sendAsChat:N,sendAsId:k}}))((e=>{let{dropAreaState:t,shouldSchedule:n,canScheduleUntilOnline:i,isReady:r,onDropHide:d,editingMessage:m,chatId:g,threadId:f,messageListType:I,draft:y,chat:Z,connectionState:P,isChatWithBot:C,isChatWithSelf:b,isRightColumnShown:E,isSelectModeActive:M,isForwarding:S,isPollModalOpen:R,botKeyboardMessageId:k,botKeyboardPlaceholder:T,withScheduledButton:N,stickersForEmoji:A,groupChatMembers:x,topInlineBotIds:L,currentUserId:O,lastSyncTime:F,contentToBeScheduled:U,shouldSuggestStickers:$,baseEmojiKeywords:D,emojiKeywords:j,serverTimeOffset:q,recentEmojis:Q,inlineBots:G,isInlineBotLoading:H,botCommands:_,chatBotCommands:z,sendAsUser:V,sendAsChat:X,sendAsId:K}=e;const{sendMessage:Y,clearDraft:J,showDialog:ee,setStickerSearchQuery:te,setGifSearchQuery:ne,forwardMessages:ae,openPollModal:se,closePollModal:oe,loadScheduledHistory:ie,openChat:re,addRecentEmoji:ce,sendInlineBotResult:le,loadSendAs:de,loadFullChat:ue}=(0,a.uC)(),me=(0,Oe.Z)(),ge=(0,o.sO)(null),[pe,fe]=(0,o.eJ)(""),ve=(0,is.Y)(pe),Pe=(0,o.sO)(),Ce=(0,Et.Z)(t),[we,be,Ee]=(0,xe.Z)(),[Me,Se]=(0,o.eJ)(),{width:Re}=W.Z.get(),ke=null==Z?void 0:Z.sendAsIds,Te=ke&&(ke.length>1||!ke.includes(O)),Be=(0,os.Z)(g,f);(0,o.d4)((()=>{Pe.current=void 0}),[g]),(0,o.d4)((()=>{g&&F&&f===u._f&&r&&ie({chatId:g})}),[r,g,ie,F,f]),(0,o.d4)((()=>{g&&Z&&F&&!ke&&r&&(0,l.ZV)(Z)&&de({chatId:g})}),[Z,g,r,F,de,ke]),(0,o.d4)((()=>{g&&Z&&F&&!Z.fullInfo&&r&&(0,l.ZV)(Z)&&ue({chatId:g})}),[Z,g,r,F,ue]);const Ae=(0,o.sO)(!1);(0,Ze.Z)((e=>{let[t,n]=e;Ae.current=Boolean(g===t&&ke&&!n)}),[g,ke]),(0,o.bt)((()=>{ge.current&&(ge.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>')}),[]),(0,o.d4)((()=>{U&&(Se(U),be())}),[U,be]);const[Le,Fe]=(0,o.eJ)([]),[Ue,$e,De]=(0,xe.Z)(),[je,qe,Qe]=(0,xe.Z)(),[He,_e,ze]=(0,xe.Z)(),[Ve,We,Ke]=(0,xe.Z)(),[Ye,Je,et]=(0,xe.Z)(),[tt,nt,at]=(0,xe.Z)(),[st,ot]=(0,xe.Z)(),[it,rt,ct]=(0,xe.Z)(),{startRecordingVoice:lt,stopRecordingVoice:dt,pauseRecordingVoice:ut,activeVoiceRecording:mt,currentRecordTime:ht,recordButtonRef:gt,startRecordTimeRef:pt}=(()=>{const e=(0,o.sO)(null),[t,n]=(0,o.eJ)(),a=(0,o.sO)(),[s,i]=(0,o.eJ)();(0,o.d4)((()=>{h.s$&&h.mh&&ms()}),[]);const r=(0,o.I4)((async()=>{try{const{stop:t,pause:s}=await hs((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)`),i(Date.now()))}));a.current=Date.now(),i(Date.now()),n({stop:t,pause:s})}catch(e){console.error(e)}}),[]),c=(0,o.I4)((()=>{if(t){e.current&&(e.current.style.boxShadow="none");try{return t.pause()}catch(e){return void console.error(e)}}}),[t]),l=(0,o.I4)((()=>{if(t){n(void 0),a.current=void 0,i(void 0),e.current&&(e.current.style.boxShadow="none");try{return t.stop()}catch(e){return void console.error(e)}}}),[t]);return(0,o.d4)((()=>t?(0,Ne.Z)(l):void 0),[t,l]),{startRecordingVoice:r,pauseRecordingVoice:c,stopRecordingVoice:l,activeVoiceRecording:t,currentRecordTime:s,recordButtonRef:e,startRecordTimeRef:a}})();(0,vn.Z)((()=>{Be({type:"recordAudio"})}),mt&&s.o_),(0,o.d4)((()=>{mt||Be({type:"cancel"})}),[mt,Be]);const ft=m?Js.Edit:!h.mh||mt||pe&&!Le.length||S?n?Js.Schedule:Js.Send:Js.Record,vt=!n,{isMentionTooltipOpen:It,closeMentionTooltip:Zt,insertMention:Pt,mentionFilteredUsers:Ct}=(0,ys.Z)(!Le.length,ve,fe,void 0,x,L,O),{isOpen:wt,id:bt,isGallery:Mt,switchPm:St,results:Rt,closeTooltip:kt,help:Tt,loadMore:Nt}=function(e,t,n,s){const{queryInlineBot:i,resetInlineBot:r}=(0,a.uC)(),[c,l,d]=(0,xe.Z)(),{username:u,query:m,canShowHelp:h,usernameLowered:g}=Zs((()=>function(e){const t=function(e){return bs.innerHTML=e.replace(/<br>/g,"\n"),bs.innerText}(e),n=t.match(Ps);return n?{username:n[1],query:n[2],canShowHelp:""===n[2]&&!t.match(Cs),usernameLowered:n[1].toLowerCase()}:ws}(n)),300,[n])||{},p=(0,Et.Z)(m),f=(0,Et.Z)(u),v=g?null==s?void 0:s[g]:void 0,{id:I,switchPm:y,offset:Z,results:P,isGallery:C,help:w}=v||{};(0,o.d4)((()=>{p!==m&&d()}),[p,m,d]),(0,o.d4)((()=>{e&&g&&t&&i({chatId:t,username:g,query:m})}),[m,e,i,t,g]);const b=(0,o.I4)((()=>{i({chatId:t,username:g,query:m,offset:Z})}),[Z,t,m,i,g]);return(0,o.d4)((()=>{e&&I&&(y||null!=P&&P.length)?l():d()}),[I,e,l,P,y,d]),f!==u&&r({username:f}),{isOpen:c,id:I,isGallery:C,switchPm:y,results:P,closeTooltip:d,help:h&&w?`@${u} ${w}`:void 0,loadMore:b}}(Boolean(!Le.length&&F),g,pe,G),{isOpen:Bt,close:At,filteredBotCommands:xt}=function(e,t,n,a){const[s,i,r]=(0,xe.Z)(),[c,l]=(0,o.eJ)(),d=(0,o.I4)((e=>{n||a?Es((()=>{const t=(n||a||[]).filter((t=>{let{command:n}=t;return!e||n.includes(e)}));l(t&&t.length?t:void 0)})):l(void 0)}),[n,a]);return(0,o.d4)((()=>{if(e&&t.length)if(t.startsWith("/")){const e=(0,ss._)(t.substr(1)).match(Ms);d(e?e[0]:"")}else r();else r()}),[d,t,e,r]),(0,o.d4)((()=>{c&&c.length?i():r()}),[c,i,r]),{isOpen:s,close:r,filteredBotCommands:c}}(Boolean(_&&_.length||z&&z.length),pe,_,z),{isContextMenuOpen:Lt,handleContextMenu:Ot,handleContextMenuClose:Ft,handleContextMenuHide:Ut}=(0,Pn.Z)(gt,!(ft===Js.Send&&vt)),{canSendStickers:$t,canSendGifs:Dt,canAttachMedia:jt,canAttachPolls:qt,canAttachEmbedLinks:Qt}=(0,o.Ye)((()=>(0,l.H5)(Z,C)),[Z,C]),Gt=Z&&(0,l.Nl)(Z),Ht=(0,l.Hd)(Z),{isStickerTooltipOpen:_t,closeStickerTooltip:zt}=function(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const i=(0,o.Ye)((()=>(0,ss._)(t).trim()),[t]),{loadStickersForEmoji:r,clearStickersForEmoji:c}=(0,a.uC)(),l=h.op&&1===(0,as.Z)(i)||!h.op&&Boolean(t.match(/^<img.[^>]*?>$/g)),d=Boolean(n)&&l;return(0,o.d4)((()=>{var t;s||(e&&l?r({emoji:h.op?i:null===(t=i.match(/alt="(.+)"/))||void 0===t?void 0:t[1]}):!d&&l||c())}),[t,l,c,r,e,s]),{isStickerTooltipOpen:d,closeStickerTooltip:c}}(Boolean($&&$t&&!Le.length),pe,A,!r),{isEmojiTooltipOpen:Vt,closeEmojiTooltip:Xt,filteredEmojis:Wt,insertEmoji:Kt}=(0,Is.Z)(Boolean($&&$t&&!Le.length),ve,Q,void 0,fe,D,j,!r),Yt=(0,o.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s.R2;const n=window.getSelection(),a=document.getElementById(t),o=(0,tn.Z)(e,["escape_html","emoji_html","br_html"]).join("").replace(/\u200b+/g,"");if(n.rangeCount){const e=n.getRangeAt(0);if((0,es.R)(e,t))return Ja(o),void a.dispatchEvent(new Event("input",{bubbles:!0}))}fe(`${ve.current}${o}`),requestAnimationFrame((()=>{(0,Xa.Z)(a)}))}),[ve]),Jt=(0,o.I4)((()=>{const e=window.getSelection();if(e.rangeCount){const t=e.getRangeAt(0);if((0,es.R)(t,s.R2))return void document.execCommand("delete",!1)}fe(function(e){const t=document.createElement("div");t.contentEditable="true",t.style.position="absolute",t.style.left="-10000px",t.style.top="-10000px",t.innerHTML=e,document.body.appendChild(t);let 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}(ve.current))}),[ve]),en=(0,o.I4)((function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e||fe(""),Fe(c.D),zt(),Ee(),Se(void 0),Zt(),Xt(),h.wB?setTimeout((()=>Ke()),350):Ke()}),[zt,Ee,Zt,Xt,Ke]),nn=(0,o.sO)();nn.current=dt,(0,o.d4)((()=>()=>{nn.current(),en()}),[g,en,nn]);const an=((e,t,n,i,r)=>{const{editMessage:c}=(0,a.uC)();return(0,o.d4)((()=>{n?(t((0,ma.z)(n.content.text)),requestAnimationFrame((()=>{const e=document.getElementById(s.R2);(0,Xa.Z)(e,!0)}))):t("")}),[n,t]),(0,o.I4)((()=>{const{text:t,entities:a}=(0,v.Z)(e.current);n&&(t||(0,l.u8)(n)?(c({messageId:n.id,text:t,entities:a}),i()):r())}),[c,n,e,r,i])})(ve,fe,m,en,nt);((e,t,n,i,r,c)=>{const{saveDraft:l,clearDraft:d}=(0,a.uC)(),u=(0,o.I4)(((e,t)=>{const n=i.current;n.length&&!c?l({chatId:e,threadId:t,draft:(0,v.Z)(n)}):d({chatId:e,threadId:t})}),[d,c,i,l]),m=(0,o.Ye)((()=>(0,w.Ds)((e=>e()),s.r_,!1)),[t]),g=(0,Et.Z)(t),p=(0,Et.Z)(n);(0,o.d4)((()=>(fs=t,vs=n,()=>{fs=void 0,vs=void 0,u(t,n)})),[t,n,u]),(0,o.d4)((()=>{t===g&&n===p||e&&(r((0,ma.z)(e)),h.$b||requestAnimationFrame((()=>{const e=document.getElementById(s.R2);(0,Xa.Z)(e,!0)})))}),[t,n,e,r,u,g,p]);const f=i.current,I=(0,Et.Z)(f);(0,o.d4)((()=>{t&&n&&g===t&&p===n&&I!==f&&(f.length?m((()=>{fs===t&&vs===n&&u(t,n)})):u(t,n))}),[t,f,g,I,p,m,n,u]);const y=(0,o.I4)((()=>{t&&n&&u(t,n)}),[t,n,u]);(0,Ie.Z)(y),ye(y)})(y,g,f,ve,fe,m),((e,t,n)=>{(0,o.d4)((()=>{async function a(a){if(!a.clipboardData)return;const o=document.activeElement;if(o&&![s.R2,s.nY].includes(o.id))return;const i=a.clipboardData.getData("text").substring(0,4096),{items:r}=a.clipboardData;let c=[];if(a.preventDefault(),r.length>0&&(c=await(0,gs.Z)(r)),0!==c.length||i){if(c.length>0&&!n){const e=await Promise.all(c.map((e=>Ya(e.name,e,1===c.length&&ps.includes(e.type)))));t((t=>t.concat(e)))}i&&e(i,null==o?void 0:o.id)}}return document.addEventListener("paste",a,!1),()=>{document.removeEventListener("paste",a,!1)}}),[e,n,t])})(Yt,Fe,m);const sn=(0,o.I4)((async(e,t)=>{Fe(await Promise.all(e.map((e=>Ya(e.name,e,t)))))}),[]),rn=(0,o.I4)((async(e,t)=>{Fe([...Le,...await Promise.all(e.map((e=>Ya(e.name,e,t))))])}),[Le]),cn=(0,o.I4)((()=>{Fe(c.D)}),[]),ln=(0,o.I4)((async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1?arguments[1]:void 0;if("connectionStateReady"!==P)return;let n=Le;if(mt){const e=await dt();if(e){const{blob:t,duration:a,waveform:s}=e;n=[await Ya(eo,t,!1,{voice:{duration:a,waveform:s}})]}}const{text:a,entities:o}=(0,v.Z)(ve.current);if(!n.length&&!a&&!S)return;const i=n.length?1024:4096;if((null==a?void 0:a.length)>i){const e=a.length-i;return void ee({data:{message:"MESSAGE_TOO_LONG_PLEASE_REMOVE_CHARACTERS",textParams:{"{EXTRA_CHARS_COUNT}":e,"{PLURAL_S}":e>1?"s":""},hasErrorKey:!0}})}const r=document.getElementById(s.R2);if(n.length||a){if(Ht&&!Gt){const e=(0,p.b)(q),t=Pe.current&&Math.floor(e-Pe.current),n=Ht.nextSendDate&&Ht.nextSendDate>e;if(t&&t<Ht.seconds||n){const a=n?Ht.nextSendDate-e:Ht.seconds-t;return ee({data:{message:me("SlowModeHint",(0,B.k9)(a)),isSlowMode:!0,hasErrorKey:!1}}),void r.blur()}}Y({text:a,entities:o,attachments:n,scheduledAt:t,isSilent:e})}S&&ae({scheduledAt:t,isSilent:e}),Pe.current=(0,p.b)(q),J({chatId:g,localOnly:!0}),h.cj&&r===document.activeElement&&ns(r),requestAnimationFrame((()=>{en()}))}),[P,Le,mt,S,J,g,q,en,dt,ee,Ht,Gt,Y,ae,me,ve]),dn=(0,o.I4)((()=>{Ke(),qe()}),[Ke,qe]),un=(0,o.I4)((()=>{Qe(),et(),We()}),[Qe,et,We]),mn=(0,o.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e={...e,isPreloadedGlobally:!0},n?(Se({sticker:e}),be()):(Y({sticker:e}),requestAnimationFrame((()=>{en(t)})))}),[n,be,Y,en]),hn=(0,o.I4)((e=>{n?(Se({gif:e}),be()):(Y({gif:e}),requestAnimationFrame((()=>{en(!0)})))}),[n,be,Y,en]),gn=(0,o.I4)((e=>{if("connectionStateReady"!==P)return;le({id:e.id,queryId:e.queryId});const t=document.getElementById(s.R2);h.cj&&t===document.activeElement&&ns(t),J({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{en()}))}),[g,J,P,en,le]),pn=(0,o.I4)((()=>{J({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{en()}))}),[g,J,en]),fn=(0,o.I4)((e=>{n?(Se({poll:e}),oe(),be()):(Y({poll:e}),oe())}),[oe,be,Y,n]),In=(0,o.I4)((()=>{n?(Se({isSilent:!0}),be()):ln(!0)}),[ln,be,n]),yn=(0,o.I4)((function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const{isSilent:n,...a}=Me||{},s=Math.round(Math.max(e.getTime(),Date.now()+6e4)/1e3)+(t?0:q);Me&&0!==Object.keys(a).length?(Y({...Me,scheduledAt:s}),requestAnimationFrame((()=>{en()}))):ln(Boolean(n),s),Ee()}),[Ee,ln,en,Me,Y,q]),Zn=(0,o.I4)((()=>{yn(new Date(1e3*s.t4),!0)}),[yn]),Cn=(0,o.I4)((()=>{Ee(),Se(void 0)}),[Ee]),wn=(0,o.I4)((e=>{"stickers"===e?(te({query:""}),ne({query:void 0})):(ne({query:""}),te({query:void 0}))}),[te,ne]),bn=(0,o.I4)((()=>{const e=document.getElementById(s.R2);h.wB&&e===document.activeElement?(e.blur(),setTimeout((()=>{Qe(),We()}),100)):We()}),[We,Qe]),En=(0,o.I4)((()=>{const e=document.getElementById(s.R2);if(!h.wB||e!==document.activeElement)return Qe(),Ke(),void Je();e.blur(),setTimeout((()=>{Qe(),Ke(),Je()}),100)}),[Qe,Ke,Je]),Mn=(0,o.I4)((()=>{re({id:g,threadId:f,type:"scheduled"})}),[re,g,f]);(0,o.d4)((()=>{E&&h.wB&&Ke()}),[E,Ke]),(0,o.d4)((()=>{r&&(M?rt():setTimeout((()=>{ct()}),200))}),[M,ct,rt,r]);const Sn=(0,o.I4)((()=>{switch(ft){case Js.Send:ln();break;case Js.Record:lt();break;case Js.Edit:an();break;case Js.Schedule:mt&&ut(),be()}}),[ft,ln,lt,an,mt,be,ut]),Rn=ft===Js.Record&&!jt,kn=(0,Et.Z)(m,!0),Tn=m||kn,Nn=new Date;Nn.setSeconds(0),Nn.setMilliseconds(0);const Bn=new Date;Bn.setFullYear(Bn.getFullYear()+1);let An="SendMessage";switch(ft){case Js.Edit:An="Save edited message";break;case Js.Record:An=Rn?"Conversation.DefaultRestrictedMedia":"AccDescrVoiceMessage"}const xn=(0,he.Z)("Composer",!M&&"shown",it&&"hover-disabled"),Ln=(0,he.Z)("mobile-symbol-menu-button",!r&&"not-ready",st?Ve&&"menu-opened":Ve&&"is-loading"),On=ft===Js.Edit?an:ft===Js.Schedule?be:ln;return o.ZP.createElement("div",{className:xn},jt&&r&&o.ZP.createElement(Xs,{isOpen:t!==yt.t.None,withQuick:t===yt.t.QuickFile||Ce===yt.t.QuickFile,onHide:d,onFileSelect:sn}),o.ZP.createElement(_s,{chatId:g,threadId:f,attachments:Le,caption:Le.length?pe:"",groupChatMembers:x,currentUserId:O,recentEmojis:Q,isReady:r,onCaptionUpdate:fe,baseEmojiKeywords:D,emojiKeywords:j,addRecentEmoji:ce,onSend:n?be:ln,onFileAppend:rn,onClear:cn}),o.ZP.createElement(Vs,{isOpen:Boolean(R),onClear:oe,onSend:fn}),Tn&&o.ZP.createElement(Ss,{isOpen:tt,isSchedule:"scheduled"===I,onClose:at,message:Tn}),o.ZP.createElement(Ys,{isOpen:Ye,onClose:et,chatId:g,selectedSendAsId:K,sendAsIds:ke}),o.ZP.createElement(Os,{isOpen:It,onClose:Zt,onInsertUserName:Pt,filteredUsers:Ct}),o.ZP.createElement(Ls,{isOpen:wt,botId:bt,isGallery:Mt,inlineBotResults:Rt,switchPm:St,onSelectResult:gn,loadMore:Nt,onClose:kt}),o.ZP.createElement(Ds,{isOpen:Bt,withUsername:Boolean(z),botCommands:xt,onClick:pn,onClose:At}),o.ZP.createElement("div",{id:"message-compose"},o.ZP.createElement("div",{className:"svg-appendix",ref:ge}),o.ZP.createElement(Hs,null),o.ZP.createElement(Ks,{chatId:g,threadId:f,messageText:Le.length?"":pe,disabled:!Qt}),o.ZP.createElement("div",{className:"message-input-wrapper"},C&&!1!==_&&!mt&&!m&&o.ZP.createElement(Ns,{className:(0,he.Z)("bot-commands",je&&"activated"),round:!0,disabled:void 0===_,color:"translucent",onActivate:dn,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-commands-filled"})),Te&&(V||X)&&o.ZP.createElement(Ge.Z,{round:!0,color:"translucent",onClick:Ye?et:En,ariaLabel:me("SendMessageAsTitle"),className:(0,he.Z)("send-as-button",Ae.current&&"appear-animation")},o.ZP.createElement(on.Z,{user:V,chat:X,size:"tiny"})),h.wB?o.ZP.createElement(Ge.Z,{className:Ln,round:!0,color:"translucent",onClick:Ve?Ke:bn,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"}),o.ZP.createElement("i",{className:"icon-keyboard"}),Ve&&!st&&o.ZP.createElement(Xe.Z,{color:"gray"})):o.ZP.createElement(Ns,{className:Ve?"activated":"",round:!0,color:"translucent",onActivate:un,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"})),o.ZP.createElement(Qs.Z,{id:"message-input-text",chatId:g,threadId:f,html:Le.length?"":pe,placeholder:mt&&Re<=600?"":T||me("Message"),forcedPlaceholder:Tt,canAutoFocus:r&&!Le.length,shouldSuppressFocus:h.wB&&Ve,shouldSuppressTextFormatter:Vt||It||wt,onUpdate:fe,onSend:On,onSuppressedFocus:Ke}),H&&Boolean(bt)&&o.ZP.createElement(Xe.Z,{color:"gray"}),N&&o.ZP.createElement(Ge.Z,{round:!0,faded:!0,className:"scheduled-button",color:"translucent",onClick:Mn,ariaLabel:"Open scheduled messages"},o.ZP.createElement("i",{className:"icon-schedule"})),k&&!mt&&!m&&o.ZP.createElement(Ns,{className:Ue?"activated":"",round:!0,color:"translucent",onActivate:$e,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-command"})),!mt&&!m&&o.ZP.createElement(Ns,{className:He?"activated":"",round:!0,color:"translucent",onActivate:_e,ariaLabel:"Add an attachment"},o.ZP.createElement("i",{className:"icon-attach"})),mt&&ht&&o.ZP.createElement("span",{className:"recording-state"},(0,B.rM)(ht-pt.current)),o.ZP.createElement(Us,{chatId:g,threadId:f,isOpen:_t,onStickerSelect:mn}),o.ZP.createElement($s.Z,{isOpen:Vt,emojis:Wt,onClose:Xt,onEmojiSelect:Kt,addRecentEmoji:ce}),o.ZP.createElement(As,{isOpen:He,canAttachMedia:jt,canAttachPolls:qt,onFileSelect:sn,onPollCreate:se,onClose:ze}),k&&o.ZP.createElement(qs,{messageId:k,isOpen:Ue,onClose:De}),_&&o.ZP.createElement(zs,{isOpen:je,botCommands:_,onClose:Qe}),o.ZP.createElement(xs,{chatId:g,threadId:f,isOpen:Ve,canSendGifs:Dt,canSendStickers:$t,onLoad:ot,onClose:Ke,onEmojiSelect:Yt,onStickerSelect:mn,onGifSelect:hn,onRemoveSymbol:Jt,onSearchOpen:wn,addRecentEmoji:ce}))),mt&&o.ZP.createElement(Ge.Z,{round:!0,color:"danger",className:"cancel",onClick:dt,ariaLabel:"Cancel voice recording"},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(Ge.Z,{ref:gt,round:!0,color:"secondary",className:(0,he.Z)(ft,!r&&"not-ready",mt&&"recording"),disabled:Rn,ariaLabel:me(An),onClick:Sn,onContextMenu:ft===Js.Send&&vt?Ot:void 0},o.ZP.createElement("i",{className:"icon-send"}),o.ZP.createElement("i",{className:"icon-schedule"}),o.ZP.createElement("i",{className:"icon-microphone-alt"}),o.ZP.createElement("i",{className:"icon-check"})),vt&&o.ZP.createElement(Fs,{isOpen:Lt,onSilentSend:b?void 0:In,onScheduleSend:n?void 0:be,onClose:Ft,onCloseAnimationEnd:Ut}),o.ZP.createElement(Bs,{isOpen:we,withTimePicker:!0,selectedAt:Nn.getTime(),maxAt:(0,B._F)(Bn),isFutureMode:!0,secondButtonLabel:i?me("Schedule.SendWhenOnline"):void 0,onClose:Cn,onSubmit:yn,onSecondButtonClick:i?Zn:void 0}))}))),no=(0,o.X$)((e=>{const{isActive:t}=e,n=(0,st.Z)(at.gl.Extra,"MobileSearch",!t,!0);return n?o.ZP.createElement(n,e):void 0})),ao=(0,o.X$)((e=>{const{isActive:t}=e,n=(0,st.Z)(at.gl.Extra,"MessageSelectToolbar",!t);return n?o.ZP.createElement(n,e):void 0})),so=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"UnpinAllMessagesModal",!t);return n?o.ZP.createElement(n,e):void 0})),oo=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"PaymentModal",!t);return n?o.ZP.createElement(n,e):void 0})),io=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"ReceiptModal",!t);return n?o.ZP.createElement(n,e):void 0})),ro=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"SeenByModal",!t);return n?o.ZP.createElement(n,e):void 0})),co=(0,o.X$)((e=>{const{activeEmojiInteraction:t}=e,n=(0,st.Z)(at.gl.Extra,"EmojiInteractionAnimation",!t);return n?o.ZP.createElement(n,e):void 0})),lo=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"ReactorListModal",!t);return n?o.ZP.createElement(n,e):void 0})),uo=h.wB?450+s.fK:void 0;function mo(e){return"file"===e.kind&&e.type&&s.oG.has(e.type)}const ho=(0,o.X$)((0,a.c$)((e=>{const t=(0,r.Pu)(e),{isBlurred:n,background:a,backgroundColor:s,patternColor:o}=e.settings.themes[t]||{},{messageLists:i}=e.messages,c=(0,r.Bt)(e),{isLeftColumnShown:d,chats:{listIds:m},activeEmojiInteractions:g}=e,p={theme:t,customBackground:a,backgroundColor:s,patternColor:o,isLeftColumnShown:d,isRightColumnShown:(0,r.Jf)(e),isBackgroundBlurred:n,isMobileSearchActive:Boolean(h.wB&&(0,r.n5)(e)),isSelectModeActive:(0,r.CA)(e),isPaymentModalOpen:e.payment.isPaymentModalOpen,isReceiptModalOpen:Boolean(e.payment.receipt),isSeenByModalOpen:Boolean(e.seenByModal),isReactorListModalOpen:Boolean(e.reactorModal),animationLevel:e.settings.byKey.animationLevel,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1),activeEmojiInteractions:g};if(!c||!m.active)return p;const{chatId:f,threadId:v,type:I}=c,y=(0,r.Z1)(e,f),Z=(0,r.IK)(e,f),P=(0,r.KB)(e,f),{chatId:C,messageId:w}=e.audioPlayer,b=y&&(0,l.Qm)(y,v),E=(0,r.pk)(e,f),M="pinned"===I,S="scheduled"===I,R="thread"===I&&v===u._f,k=Boolean(y&&(0,l.eA)(y)),T=Boolean(y&&R&&(k||(0,l.ZV)(y))&&y.isNotJoined),N=Boolean(Z&&(0,r.s4)(e,Z.id)),B=!N&&E;return{...p,chatId:f,threadId:v,messageListType:I,isPrivate:(0,l.YC)(f),canPost:!M&&(!y||b)&&!E,isPinnedMessageList:M,isScheduledMessageList:S,currentUserBannedRights:null==y?void 0:y.currentUserBannedRights,defaultBannedRights:null==y?void 0:y.defaultBannedRights,hasPinnedOrAudioPlayer:v!==u._f||Boolean(!M&&(null==P?void 0:P.length))||Boolean(C&&w),pinnedMessagesCount:P?P.length:0,shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,messageLists:i,isChannel:k,canSubscribe:T,canStartBot:B,canRestartBot:N}}))((e=>{let{chatId:t,threadId:n,messageListType:i,isPrivate:r,isPinnedMessageList:c,messageLists:d,canPost:u,currentUserBannedRights:m,defaultBannedRights:g,hasPinnedOrAudioPlayer:p,pinnedMessagesCount:f,customBackground:v,theme:I,backgroundColor:y,patternColor:Z,isLeftColumnShown:P,isRightColumnShown:C,isBackgroundBlurred:w,isMobileSearchActive:b,isSelectModeActive:E,isPaymentModalOpen:M,isReceiptModalOpen:S,isSeenByModalOpen:R,isReactorListModalOpen:k,animationLevel:T,shouldSkipHistoryAnimations:N,currentTransitionKey:B,isChannel:A,canSubscribe:x,canStartBot:L,canRestartBot:O,activeEmojiInteractions:F}=e;const{openChat:U,unpinAllMessages:$,loadUser:D,closeLocalTextSearch:j,exitMessageSelectMode:q,closePaymentModal:Q,clearReceipt:G,joinChannel:H,sendBotCommand:_,restartBot:W}=(0,a.uC)(),{width:K}=wt(),Y=(0,Oe.Z)(),[J,ee]=(0,o.eJ)(yt.t.None),[te,ne]=(0,o.eJ)(),[ae,se]=(0,o.eJ)(),[oe,ie]=(0,o.eJ)(!1),re=p&&(K<s.l3||C&&K>s._m&&K<s.QU||K>=s.ks&&K<s.jT),ce=(0,bt.Z)(t,uo),le=(0,bt.Z)(n,uo),de=(0,bt.Z)(i,uo),ue=(0,bt.Z)(x,uo),me=(0,bt.Z)(L,uo),ge=(0,bt.Z)(O,uo),pe=(0,bt.Z)(u,uo)&&!ge&&!me&&!ue,fe=(0,bt.Z)(re,uo),ve=(0,bt.Z)(te,uo),Ie=(0,bt.Z)(A,uo),ye=(0,Et.Z)(B),Pe=void 0!==ye&&ye<B?ye:void 0,{isReady:Ce,handleOpenEnd:we,handleSlideStop:be}=function(e,t,n,a){const[s,i]=(0,o.eJ)(!h.wB),r=(0,Mt.Z)(),c=void 0!==n&&n!==t;return c&&(e?i(!1):r()),(0,Ze.Z)((()=>{e||i(!0)}),[e]),{isReady:s&&!c,handleOpenEnd:e?function(e){"transform"===e.propertyName&&e.target===e.currentTarget&&i(Boolean(a))}:void 0,handleSlideStop:e?function(){i(!0)}:void 0}}(!N&&T!==s.oB,B,ye,t);(0,o.d4)((()=>t?(0,Ne.Z)((()=>{U({id:void 0})})):void 0),[t,U]),(0,Ze.Z)((()=>{ee(yt.t.None),ne(void 0),se(void 0)}),[t]),(0,o.d4)((()=>{const{visualViewport:e}=window;if(!e)return;const t=()=>{window.visualViewport.height!==document.documentElement.clientHeight?document.body.classList.add("keyboard-visible"):document.body.classList.remove("keyboard-visible")};return e.addEventListener("resize",t),()=>{e.removeEventListener("resize",t)}}),[]),(0,o.d4)((()=>{r&&D({userId:t})}),[t,r,D]);const Me=(0,o.I4)((e=>{if(h.$b)return;const{items:t}=e.dataTransfer||{},n=t&&t.length>0&&Array.from(t).filter((e=>"text/uri-list"!==e.type)).every(mo);ee(n?yt.t.QuickFile:yt.t.Document)}),[]),Se=(0,o.I4)((()=>{ee(yt.t.None)}),[]),Re=(0,o.I4)((()=>{ie(!0)}),[]),ke=(0,o.I4)((()=>{ie(!1)}),[]),Te=(0,o.I4)((()=>{$({chatId:t}),ke(),U({id:t})}),[$,U,ke,t]),Be=(0,o.I4)((()=>{U({id:t})}),[U,t]),Ae=(0,o.I4)((()=>{H({chatId:t})}),[H,t]),xe=(0,o.I4)((()=>{_({command:"/start"})}),[_]),Fe=(0,o.I4)((()=>{W({chatId:t})}),[t,W]),Ue=((e,t)=>{const[n,a]=(0,o.eJ)(t);return(0,o.d4)((()=>{t&&(t.startsWith("#")?a(t):Pt.fetch(s.fo,e,Pt.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,Ct.pt)(t).then((()=>{a(`url(${t})`)}))})))}),[t,e]),t?n:void 0})(I,v),$e=(0,he.Z)(fe&&"has-header-tools",v&&"custom-bg-image",y&&"custom-bg-color",v&&w&&"blurred",h.aZ?"mask-image-disabled":"mask-image-enabled"),De=(0,he.Z)("messaging-disabled",!E&&"shown"),je=(0,l.q8)(Y,m,g),{composerHiddenScale:qe,toolbarHiddenScale:Qe,composerTranslateX:He,toolbarTranslateX:_e,unpinHiddenScale:ze,toolbarForUnpinHiddenScale:Ve}=(0,o.Ye)((()=>function(e,t){const n=e<=s.l3?16:32,a=function(e){if(e>s._m){const t=Math.min(Math.max(.25*e,X),V),n=Math.min(.25*e,V);return Math.min(e-t-n,z)}if(e>s.ks){const t=Math.min(Math.max(.4*e,X),V);return Math.min(e-t,z)}return e>z?z:e}(e),o=e<=s.l3?54:64,i=t?a-n-o:a-n,r=e>s.l3?Math.min(a-n,512):a-n,c=r/i,l=i/r;return{composerHiddenScale:c,toolbarHiddenScale:l,composerTranslateX:t?o/2*l:0,toolbarTranslateX:t?o/2*-1*c:0,unpinHiddenScale:r/258,toolbarForUnpinHiddenScale:258/r}}(K,pe)),[pe,K]),Xe=(0,he.Z)("middle-column-footer",!pe&&"no-composer",pe&&ae&&!E&&"with-notch");(0,Ee.ZP)(ce&&le,(()=>{U({id:void 0},{forceSyncOnIOs:!0})}),void 0,void 0,void 0,(null==d?void 0:d.map(Zt.q))||[]),(0,Ee.ZP)(b,j),(0,Ee.ZP)(E,q);const We=Boolean(!c&&!pe&&!ge&&!me&&!ue&&je),Ke=Boolean(ge||ue||me||c),Ye=Boolean(We||E||c);return o.ZP.createElement("div",{id:"MiddleColumn",className:$e,onTransitionEnd:we,style:`\n --composer-hidden-scale: ${qe};\n --toolbar-hidden-scale: ${Qe};\n --unpin-hidden-scale: ${ze};\n --toolbar-unpin-hidden-scale: ${Ve};\n --composer-translate-x: ${He}px;\n --toolbar-translate-x: ${_e}px;\n --pattern-color: ${Z};\n --theme-background-color:\n ${y||("dark"===I?s.It:s.p3)};\n `,onClick:h.p7&&P?Be:void 0},o.ZP.createElement("div",{id:"middle-column-bg",style:Ue?`--custom-background: ${Ue}`:void 0}),o.ZP.createElement("div",{id:"middle-column-portals"}),ce&&le&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"messages-layout",onDragEnter:pe?Me:void 0},o.ZP.createElement(cn,{chatId:ce,threadId:le,messageListType:de,isReady:Ce}),o.ZP.createElement(Le.Z,{name:N?"none":T===s.zy?"slide":"fade",activeKey:B,shouldCleanup:!0,cleanupExceptionKey:Pe,onStop:be},(()=>o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(za,{key:`${ce}-${le}-${de}`,chatId:ce,threadId:le,type:de,canPost:pe,hasTools:fe,onFabToggle:ne,onNotchToggle:se,isReady:Ce,withBottomShift:Ke}),o.ZP.createElement("div",{className:Xe},pe&&o.ZP.createElement(to,{chatId:ce,threadId:le,messageListType:de,dropAreaState:J,onDropHide:Se,isReady:Ce}),c&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Y.isRtl?"rtl":void 0},o.ZP.createElement(Ge.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:Re},o.ZP.createElement("i",{className:"icon-unpin"}),o.ZP.createElement("span",null,Y("Chat.Pinned.UnpinAll",f,"i")))),We&&o.ZP.createElement("div",{className:De},o.ZP.createElement("div",{className:"messaging-disabled-inner"},o.ZP.createElement("span",null,je))),h.wB&&ue&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Y.isRtl?"rtl":void 0},o.ZP.createElement(Ge.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Ae},Y(Ie?"ProfileJoinChannel":"ProfileJoinGroup"))),h.wB&&me&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Y.isRtl?"rtl":void 0},o.ZP.createElement(Ge.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:xe},Y("BotStart"))),h.wB&&ge&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:Y.isRtl?"rtl":void 0},o.ZP.createElement(Ge.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Fe},Y("BotRestart"))),o.ZP.createElement(ao,{messageListType:de,isActive:E,canPost:pe}),o.ZP.createElement(oo,{isOpen:Boolean(M),onClose:Q}),o.ZP.createElement(io,{isOpen:Boolean(S),onClose:G}),o.ZP.createElement(ro,{isOpen:R}),o.ZP.createElement(lo,{isOpen:k}))))),o.ZP.createElement(Va,{isShown:ve,canPost:pe,withExtraShift:Ye})),h.wB&&o.ZP.createElement(no,{isActive:Boolean(b)})),t&&o.ZP.createElement(so,{isOpen:oe,chatId:t,pinnedMessagesCount:f,onClose:ke,onUnpin:Te}),o.ZP.createElement("div",{teactFastList:!0},null==F?void 0:F.map(((e,t)=>o.ZP.createElement(co,{teactOrderKey:t,key:e.id,activeEmojiInteraction:e})))))}))),go=(0,w.Ds)((e=>e()),200,!1);var po;!function(e){e[e.Profile=0]="Profile",e[e.MemberList=1]="MemberList",e[e.SharedMedia=2]="SharedMedia",e[e.Search=3]="Search",e[e.Management=4]="Management",e[e.ManageInitial=5]="ManageInitial",e[e.ManageChannelSubscribers=6]="ManageChannelSubscribers",e[e.ManageChatAdministrators=7]="ManageChatAdministrators",e[e.ManageChatPrivacyType=8]="ManageChatPrivacyType",e[e.ManageDiscussion=9]="ManageDiscussion",e[e.ManageGroupPermissions=10]="ManageGroupPermissions",e[e.ManageGroupRemovedUsers=11]="ManageGroupRemovedUsers",e[e.ManageGroupUserPermissionsCreate=12]="ManageGroupUserPermissionsCreate",e[e.ManageGroupUserPermissions=13]="ManageGroupUserPermissions",e[e.ManageGroupRecentActions=14]="ManageGroupRecentActions",e[e.ManageGroupAdminRights=15]="ManageGroupAdminRights",e[e.ManageGroupNewAdminRights=16]="ManageGroupNewAdminRights",e[e.ManageGroupMembers=17]="ManageGroupMembers",e[e.ManageGroupAddAdmins=18]="ManageGroupAddAdmins",e[e.StickerSearch=19]="StickerSearch",e[e.GifSearch=20]="GifSearch",e[e.PollResults=21]="PollResults",e[e.AddingMembers=22]="AddingMembers",e[e.ManageInvites=23]="ManageInvites",e[e.ManageEditInvite=24]="ManageEditInvite",e[e.ManageReactions=25]="ManageReactions",e[e.ManageInviteInfo=26]="ManageInviteInfo",e[e.ManageJoinRequests=27]="ManageJoinRequests"}(po||(po={}));const fo=(0,o.X$)((0,a.c$)(((e,t)=>{var n,a,s;let{chatId:o,isProfile:i,isManagement:c}=t;const{query:d}=(0,r.n5)(e)||{},{query:u}=(0,r.y5)(e)||{},{query:m}=(0,r.yN)(e)||{},h=o?(0,r.Z1)(e,o):void 0,g=h&&(0,l.eA)(h),p=i&&o&&(0,l.YC)(o)?(0,r.dy)(e,o):void 0,f=p&&(0,l.kw)(p),v=Boolean(!c&&i&&!f&&h&&!(0,r.FM)(e,h.id)&&((0,l.YC)(h.id)||((0,l.Nl)(h)||h.isCreator)&&!h.isNotJoined)),I=Boolean(o&&(null===(n=e.management.byChatId[o])||void 0===n?void 0:n.editingInvite)),y=o?null===(a=e.management.byChatId[o])||void 0===a||null===(s=a.inviteInfo)||void 0===s?void 0:s.invite:void 0;return{canManage:v,canAddContact:f,isChannel:g,userId:null==p?void 0:p.id,messageSearchQuery:d,stickerSearchQuery:u,gifSearchQuery:m,isEditingInvite:I,currentInviteInfo:y}}))((e=>{var t;let{chatId:n,isColumnOpen:s,isProfile:i,isSearch:r,isManagement:c,isStickerSearch:l,isGifSearch:d,isPollResults:u,isAddingChatMembers:g,profileState:p,managementScreen:f,canAddContact:v,userId:I,canManage:y,isChannel:Z,onClose:P,onScreenSelect:C,messageSearchQuery:w,stickerSearchQuery:b,gifSearchQuery:E,shouldSkipAnimation:M,isEditingInvite:S,currentInviteInfo:R}=e;const{setLocalTextSearchQuery:k,setStickerSearchQuery:T,setGifSearchQuery:N,searchTextMessagesLocal:A,toggleManagement:x,openHistoryCalendar:L,addContact:O,setEditingExportedInvite:F,deleteExportedChatInvite:U}=(0,a.uC)(),$=(0,o.sO)(null),[D,j,q]=(0,xe.Z)(),Q=(0,o.I4)((()=>{F({chatId:n,invite:R}),C(m.u1.EditInvite)}),[n,R,C,F]),G=(0,o.I4)((()=>{U({chatId:n,link:R.link}),C(m.u1.Invites),q()}),[n,q,R,U,C]),H=(0,o.I4)((e=>{k({query:e}),e.length&&go(A)}),[A,k]),_=(0,o.I4)((e=>{T({query:e})}),[T]),z=(0,o.I4)((e=>{N({query:e})}),[N]),V=(0,o.I4)((()=>{O({userId:I})}),[O,I]),[X,W]=(0,o.eJ)(!s);(0,o.d4)((()=>{setTimeout((()=>{W(!s)}),300)}),[s]);const K=(0,Oe.Z)(),Y=i?p===m.vi.Profile?po.Profile:p===m.vi.SharedMedia?po.SharedMedia:p===m.vi.MemberList?po.MemberList:-1:r?po.Search:u?po.PollResults:l?po.StickerSearch:d?po.GifSearch:g?po.AddingMembers:c?f===m.u1.Initial?po.ManageInitial:f===m.u1.ChatPrivacyType?po.ManageChatPrivacyType:f===m.u1.Discussion?po.ManageDiscussion:f===m.u1.ChannelSubscribers?po.ManageChannelSubscribers:f===m.u1.GroupPermissions?po.ManageGroupPermissions:f===m.u1.ChatAdministrators?po.ManageChatAdministrators:f===m.u1.GroupRemovedUsers?po.ManageGroupRemovedUsers:f===m.u1.GroupUserPermissionsCreate?po.ManageGroupUserPermissionsCreate:f===m.u1.GroupUserPermissions?po.ManageGroupUserPermissions:f===m.u1.GroupRecentActions?po.ManageGroupRecentActions:f===m.u1.ChatAdminRights?po.ManageGroupAdminRights:f===m.u1.ChatNewAdminRights?po.ManageGroupNewAdminRights:f===m.u1.GroupMembers?po.ManageGroupMembers:f===m.u1.Invites?po.ManageInvites:f===m.u1.EditInvite?po.ManageEditInvite:f===m.u1.GroupAddAdmins?po.ManageGroupAddAdmins:f===m.u1.Reactions?po.ManageReactions:f===m.u1.InviteInfo?po.ManageInviteInfo:f===m.u1.JoinRequests?po.ManageJoinRequests:void 0:void 0,J=null!==(t=(0,kt.Z)(Y,!0))&&void 0!==t?t:-1;function ee(){if(-1!==J)switch(J){case po.PollResults:return o.ZP.createElement("h3",null,K("PollResults"));case po.Search:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(He.Z,{parentContainerClassName:"RightSearch",value:w,onChange:H}),o.ZP.createElement(Ge.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>L({selectedAt:(0,B._F)(Date.now())}),ariaLabel:"Search messages by date"},o.ZP.createElement("i",{className:"icon-calendar"})));case po.AddingMembers:return o.ZP.createElement("h3",null,K(Z?"ChannelAddSubscribers":"GroupAddMembers"));case po.ManageInitial:return o.ZP.createElement("h3",null,K("Edit"));case po.ManageChatPrivacyType:return o.ZP.createElement("h3",null,K(Z?"ChannelTypeHeader":"GroupTypeHeader"));case po.ManageDiscussion:return o.ZP.createElement("h3",null,K("Discussion"));case po.ManageChatAdministrators:return o.ZP.createElement("h3",null,K("ChannelAdministrators"));case po.ManageGroupRecentActions:return o.ZP.createElement("h3",null,K("Group.Info.AdminLog"));case po.ManageGroupAdminRights:return o.ZP.createElement("h3",null,K("EditAdminRights"));case po.ManageGroupNewAdminRights:return o.ZP.createElement("h3",null,K("SetAsAdmin"));case po.ManageGroupPermissions:return o.ZP.createElement("h3",null,K("ChannelPermissions"));case po.ManageGroupRemovedUsers:return o.ZP.createElement("h3",null,K("ChannelBlockedUsers"));case po.ManageGroupUserPermissionsCreate:return o.ZP.createElement("h3",null,K("ChannelAddException"));case po.ManageGroupUserPermissions:return o.ZP.createElement("h3",null,K("UserRestrictions"));case po.ManageInvites:return o.ZP.createElement("h3",null,K("lng_group_invite_title"));case po.ManageEditInvite:return o.ZP.createElement("h3",null,K(S?"EditLink":"NewLink"));case po.ManageInviteInfo:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,K("InviteLink")),o.ZP.createElement("section",{className:"tools"},R&&!R.isRevoked&&o.ZP.createElement(Ge.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:K("Edit"),onClick:Q},o.ZP.createElement("i",{className:"icon-edit"})),R&&R.isRevoked&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Ge.Z,{round:!0,color:"danger",size:"smaller",ariaLabel:K("Delete"),onClick:j},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(Ut.Z,{isOpen:D,onClose:q,title:K("DeleteLink"),text:K("DeleteLinkHelp"),confirmIsDestructive:!0,confirmLabel:K("Delete"),confirmHandler:G}))));case po.ManageJoinRequests:return o.ZP.createElement("h3",null,K(Z?"SubscribeRequests":"MemberRequests"));case po.ManageGroupAddAdmins:return o.ZP.createElement("h3",null,K("Channel.Management.AddModerator"));case po.StickerSearch:return o.ZP.createElement(He.Z,{value:b,placeholder:K("SearchStickersHint"),autoFocusSearch:!0,onChange:_});case po.GifSearch:return o.ZP.createElement(He.Z,{value:E,placeholder:K("SearchGifsTitle"),autoFocusSearch:!0,onChange:z});case po.SharedMedia:return o.ZP.createElement("h3",null,K("SharedMedia"));case po.ManageChannelSubscribers:return o.ZP.createElement("h3",null,K("ChannelSubscribers"));case po.MemberList:case po.ManageGroupMembers:return o.ZP.createElement("h3",null,K("GroupMembers"));case po.ManageReactions:return o.ZP.createElement("h3",null,K("Reactions"));default:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,"Profile"),o.ZP.createElement("section",{className:"tools"},v&&o.ZP.createElement(Ge.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:K("AddContact"),onClick:V},o.ZP.createElement("i",{className:"icon-add-user"})),y&&o.ZP.createElement(Ge.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:K("Edit"),onClick:x},o.ZP.createElement("i",{className:"icon-edit"}))))}}const te=h.wB||Y===po.SharedMedia||Y===po.MemberList||Y===po.AddingMembers||c,ne=(0,he.Z)("animated-close-icon",te&&"state-back",(X||M)&&"no-transition");return o.ZP.createElement("div",{className:"RightHeader"},o.ZP.createElement(Ge.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:P,ariaLabel:K(te?"Common.Back":"Common.Close")},o.ZP.createElement("div",{ref:$,className:ne})),o.ZP.createElement(Le.Z,{name:X||M?"none":"slide-fade",activeKey:J},ee))})));var vo=n(91);var Io=n(7407);function yo(e,t,n,a){const[o,i]=(0,Io.Z)(n?t:void 0,a,void 0,s.Vk);return[o,i,!(!o||!a||o[0]===a[0])]}function Zo(e,t,n,a,i,r){const c=(0,o.sO)();(0,Ze.Z)((()=>{t===e&&i&&r&&(c.current=(0,l.R5)(i,r,e))}),[i,r,t,e]);const[d,u]=(0,Io.Z)(a?n:void 0,c.current,void 0,"media"===e?s.EN:s.pn);return[d,u,!(!d||!c.current||d[0]===c.current[0])]}const Po=(0,w.P2)((e=>e()),250,!1);let Co=!1;var wo=n(1273),bo=n(1876),Eo=n(787),Mo=n(180),So=n(3709),Ro=n(5418),ko=n(7262),To=n(1151),No=n(2275);const Bo=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"},{type:"voice",title:"SharedVoiceTab2"}];function Ao(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > .Transition__slide--active > .${e}-list > .scroll-item`].join(", ")}const xo=(0,o.X$)((0,a.c$)(((e,t)=>{var n,a;let{chatId:s}=t;const o=(0,r.Z1)(e,s),i=(0,r.Zw)(e,s),{currentType:c,resultsByType:d}=(0,r.we)(e)||{},{foundIds:u}=d&&c&&d[c]||{},{byId:m,statusesById:h}=e.users,{byId:g}=e.chats,p=o&&(0,l.Bf)(o),f=o&&(0,l.eA)(o),v=p||f&&(0,l.Nl)(o),I=null==o||null===(n=o.fullInfo)||void 0===n?void 0:n.members,y=v&&o&&o.fullInfo&&!o.fullInfo.canViewMembers,Z=v&&o&&((0,l.VE)(o,"inviteUsers")||o.isCreator),P=v&&o&&((0,l.VE)(o,"banUsers")||o.isCreator),C=(0,r.xs)(e,s);let w,b,E;return(0,l.YC)(s)&&(b=s,E=(0,r.dy)(e,b),w=E&&!E.isSelf&&!(0,l.cS)(E)),{theme:(0,r.Pu)(e),isChannel:f,resolvedUserId:b,chatMessages:i,foundIds:u,mediaSearchType:c,hasCommonChatsTab:w,hasMembersTab:v,areMembersHidden:y,canAddMembers:Z,canDeleteMembers:P,currentUserId:e.currentUserId,isRightColumnShown:(0,r.Jf)(e),isRestricted:null==o?void 0:o.isRestricted,lastSyncTime:e.lastSyncTime,serverTimeOffset:e.serverTimeOffset,activeDownloadIds:C,usersById:m,userStatusesById:h,chatsById:g,isChatProtected:null==o?void 0:o.isProtected,...v&&I&&{members:I},...w&&E&&{commonChatIds:null===(a=E.commonChats)||void 0===a?void 0:a.ids}}}))((e=>{let{chatId:t,profileState:n,onProfileStateChange:i,theme:r,isChannel:c,resolvedUserId:d,currentUserId:g,chatMessages:p,foundIds:f,mediaSearchType:v,hasCommonChatsTab:I,hasMembersTab:y,areMembersHidden:Z,canAddMembers:P,canDeleteMembers:C,commonChatIds:w,members:b,usersById:E,userStatusesById:M,chatsById:S,isRightColumnShown:R,isRestricted:k,lastSyncTime:T,activeDownloadIds:N,serverTimeOffset:B,isChatProtected:A}=e;const{setLocalMediaSearchType:x,loadMoreMembers:L,loadCommonChats:O,openChat:F,searchMediaMessagesLocal:U,openMediaViewer:$,openAudioPlayer:D,focusMessage:j,loadProfilePhotos:q,setNewChatMembersDialogState:Q}=(0,a.uC)(),G=(0,o.sO)(null),H=(0,o.sO)(null),_=(0,Oe.Z)(),[z,V]=(0,o.eJ)(0),[X,W]=(0,o.eJ)(),K=(0,o.Ye)((()=>[...y?[{type:"members",title:c?"ChannelSubscribers":"GroupMembers"}]:[],...Bo,...I?[{type:"commonChats",title:"SharedGroupsTab2"}]:[]]),[I,y,c]),Y=K[z].type,[J,ee,te,ne]=function(e,t,n,a,s,i,r,c,d,u,m,h,g,p,f){let v=arguments.length>15&&void 0!==arguments[15]?arguments[15]:0;const I="members"!==s&&i?i:s,y=(0,o.Ye)((()=>{if(r&&d&&u)return(0,l.Z0)(r.map((e=>{let{userId:t}=e;return t})),d,u,void 0,v)}),[r,v,d,u]),Z=(0,o.Ye)((()=>{if(c&&m)return(0,l.ih)(c,m,!0)}),[m,c]),[P,C,w]=yo(0,t,f,y),[b,E,M]=Zo("media",I,a,f,h,g),[S,R,k]=Zo("documents",I,a,f,h,g),[T,N,B]=Zo("links",I,a,f,h,g),[A,x,L]=Zo("audio",I,a,f,h,g),[O,F,U]=Zo("voice",I,a,f,h,g),[$,D,j]=yo(0,n,f,Z);let q,Q,G=!1;switch(I){case"members":q=P,Q=C,G=w;break;case"commonChats":q=$,Q=D,G=j;break;case"media":q=b,Q=E,G=M;break;case"documents":q=S,Q=R,G=k;break;case"links":q=T,Q=N,G=B;break;case"audio":q=A,Q=x,G=L;break;case"voice":q=O,Q=F,G=U}return[I,q,Q,G]}(R,L,O,U,Y,v,b,w,E,M,S,p,f,t,T,B),ae=K.findIndex((e=>{let{type:t}=e;return t===J})),{handleScroll:se}=function(e,t,n,a){(0,dn.Z)((n=>{let[s]=n;if(s&&s!==t){const n=e.current,s=n.querySelector(".TabList");n.scrollTop<s.offsetTop&&(a("members"===t?m.vi.MemberList:m.vi.SharedMedia),Co=!0,(0,fn.Z)(n,s,"start",void 0,void 0,void 0,300),setTimeout((()=>{Co=!1}),350))}}),[t,a]),(0,dn.Z)((t=>{let[s]=t;if(n!==m.vi.Profile||n===s)return;const o=e.current;if(!o)return;const i=o.querySelector(".TabList");!i||i.offsetTop>o.scrollTop||(Co=!0,(0,fn.Z)(o,o.firstElementChild,"start",void 0,2*o.offsetHeight),setTimeout((()=>{Co=!1}),350),a(n))}),[n]);const s=(0,o.I4)((()=>{const n=e.current;if(!n)return;const s=n.querySelector(".TabList");if(!s)return;let o=m.vi.Profile;n.scrollTop>=s.offsetTop&&(o="members"===t?m.vi.MemberList:m.vi.SharedMedia),a(o)}),[e,a,t]);return(0,o.d4)((()=>{Co||s()}),[s,t]),{handleScroll:(0,o.I4)((()=>{Co||Po(s)}),[s])}}(G,Y,n,i),{applyTransitionFix:oe,releaseTransitionFix:ie}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".Transition.shared-media-transition";(0,o.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,o.I4)((()=>{const t=e.current;if("hidden"!==t.style.overflowY){const e=t.offsetWidth-t.clientWidth;t.style.overflowY="hidden",t.style.marginRight=`${e}px`}}),[e]),a=(0,o.I4)((()=>{const t=e.current;t.style.overflowY="scroll",t.style.marginRight="0"}),[e]);return{applyTransitionFix:n,releaseTransitionFix:a}}(G),[re,ce]=(()=>{const[e,t]=(0,o.eJ)(!1);return[e,(0,o.I4)((()=>{t((e=>!e))}),[])]})(),{observe:le}=(0,In.S1)({rootRef:G,throttleMs:500}),de=(0,o.I4)((()=>{ie(),ce()}),[ie,ce]),ue=(0,o.I4)((()=>{Q(m.WB.InProgress)}),[Q]);(0,o.d4)((()=>{x({mediaType:Y})}),[x,Y]);const me=d||t;(0,o.d4)((()=>{T&&q({profileId:me})}),[q,me,T]);const he=(0,o.I4)((e=>{$({chatId:me,threadId:u._f,messageId:e,origin:m.bZ.SharedMedia})}),[me,$]),ge=(0,o.I4)((e=>{D({chatId:me,messageId:e})}),[me,D]),pe=(0,o.I4)((e=>{F({id:e})}),[F]),fe=(0,o.I4)((e=>{j({chatId:me,messageId:e})}),[me,j]),ve=(0,o.I4)((()=>{W(void 0)}),[]);let Ie;(0,o.d4)((()=>{if(H.current&&h.$b)return(0,Je.sf)(H.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===Je.eM.Left?(V(Math.min(z+1,K.length-1)),!0):t===Je.eM.Right&&(V(Math.max(0,z-1)),!0)})}),[z,K.length]);const ye="members"===J||!y&&"media"===J;ye?Ie=R?0:1e3:ee||(Ie=s.Y);const Ze=(0,Gs.Z)([t,J],Ie);function Pe(){if(!ee||!Ze||!p){const e=ye&&!Ze;return o.ZP.createElement("div",{className:"content empty-list"},!e&&o.ZP.createElement(Xe.Z,null))}if(!ee.length){let e;switch(J){case"members":e=Z?"You have no access to group members list.":"No members found";break;case"commonChats":e=_("NoGroupsInCommon");break;case"documents":e=_("lng_media_file_empty");break;case"links":e=_("lng_media_link_empty");break;case"audio":e=_("lng_media_song_empty");break;case"voice":e=_("lng_media_audio_empty");break;default:e=_("SharedMedia.EmptyTitle")}return o.ZP.createElement("div",{className:"content empty-list"},o.ZP.createElement(ko.Z,{text:e}))}return o.ZP.createElement("div",{className:`content ${J}-list`,dir:_.isRtl&&"media"===J?"rtl":void 0,teactFastList:!0},"media"===J?ee.map((e=>p[e]&&o.ZP.createElement(So.Z,{key:e,message:p[e],isProtected:A||p[e].isProtected,observeIntersection:le,onClick:he}))):"documents"===J?ee.map((e=>p[e]&&o.ZP.createElement(qn.Z,{key:e,message:p[e],withDate:!0,smaller:!0,className:"scroll-item",isDownloading:N.includes(e),observeIntersection:le,onDateClick:fe}))):"links"===J?ee.map((e=>p[e]&&o.ZP.createElement(Ro.Z,{key:e,message:p[e],isProtected:A||p[e].isProtected,observeIntersection:le,onMessageClick:fe}))):"audio"===J?ee.map((e=>p[e]&&o.ZP.createElement(Qn.Z,{key:e,theme:r,message:p[e],origin:m.Cr.SharedMedia,date:p[e].date,lastSyncTime:T,className:"scroll-item",onPlay:ge,onDateClick:fe,isDownloading:N.includes(e)}))):"voice"===J?ee.map((e=>p[e]&&o.ZP.createElement(Qn.Z,{key:e,theme:r,message:p[e],senderTitle:(0,vo.F)(_,p[e],S,E),origin:m.Cr.SharedMedia,date:p[e].date,lastSyncTime:T,className:"scroll-item",onPlay:ge,onDateClick:fe,isDownloading:N.includes(e)}))):"members"===J?ee.map(((e,t)=>{return o.ZP.createElement(bo.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>pe(e),contextActions:(n=e,n!==g&&C?[{title:_("lng_context_remove_from_group"),icon:"stop",handler:()=>{W(n)}}]:void 0)},o.ZP.createElement(Tt.Z,{userId:e,forceShowSelf:!0}));var n})):"commonChats"===J?ee.map(((e,t)=>o.ZP.createElement(bo.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>F({id:e})},o.ZP.createElement(Nt.Z,{chatId:e})))):void 0)}return o.ZP.createElement(wo.Z,{ref:G,className:"Profile custom-scroll",itemSelector:Ao(J),items:Ze?ee:void 0,cacheBuster:re,sensitiveArea:s.qU,preloadBackwards:Ze?"members"===J?s.Vk:s.EN:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:te,onScroll:se},!ne&&function(e,t){return o.ZP.createElement("div",{className:"profile-info"},o.ZP.createElement(Eo.Z,{userId:t||e}),o.ZP.createElement(Mo.Z,{chatOrUserId:t||e}))}(t,d),!k&&o.ZP.createElement("div",{className:"shared-media"},o.ZP.createElement(Le.Z,{ref:H,name:_.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:ae,renderCount:K.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:oe,onStop:de},Pe),o.ZP.createElement(et.Z,{big:!0,activeTab:z,tabs:K,onSwitchTab:V})),P&&o.ZP.createElement(To.Z,{isShown:"members"===J,onClick:ue,ariaLabel:_("lng_channel_add_users")},o.ZP.createElement("i",{className:"icon-add-user-filled"})),C&&o.ZP.createElement(No.Z,{isOpen:Boolean(X),userId:X,onClose:ve}))}))),Lo=(0,o.X$)((e=>{const t=(0,st.Z)(at.gl.Extra,"RightSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(ot.Z,null)})),Oo=(0,o.X$)((e=>{const t=(0,st.Z)(at.gl.Extra,"Management");return t?o.ZP.createElement(t,e):o.ZP.createElement(ot.Z,null)})),Fo=(0,o.X$)((()=>{const e=(0,st.Z)(at.gl.Extra,"StickerSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(ot.Z,null)})),Uo=(0,o.X$)((()=>{const e=(0,st.Z)(at.gl.Extra,"GifSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(ot.Z,null)})),$o=(0,o.X$)((()=>{const e=(0,st.Z)(at.gl.Extra,"PollResults");return e?o.ZP.createElement(e,null):o.ZP.createElement(ot.Z,null)}));var Do=n(1820);const jo=(0,o.X$)((0,a.c$)(((e,t)=>{var n;let{chatId:a}=t;const s=(0,r.Z1)(e,a),{userIds:o}=e.contactList||{},{byId:i}=e.chats,{currentUserId:c,newChatMembersProgress:d,connectionState:u}=e,h=s&&(0,l.eA)(s),{query:g,fetchingStatus:p,globalUserIds:f,localUserIds:v}=e.userSearch;return{isChannel:h,members:null==s||null===(n=s.fullInfo)||void 0===n?void 0:n.members,currentUserId:c,chatsById:i,localContactIds:o,searchQuery:g,isSearching:p,isLoading:d===m.WB.Loading,globalUserIds:f,localUserIds:v,connectionState:u}}))((e=>{let{isChannel:t,connectionState:n,members:s,onNextStep:i,currentUserId:r,chatsById:c,localContactIds:d,isLoading:u,searchQuery:m,isSearching:h,localUserIds:p,globalUserIds:f,onClose:v,isActive:I}=e;const{setUserSearchQuery:y,loadContactList:Z}=(0,a.uC)(),P=(0,Oe.Z)(),[C,w]=(0,o.eJ)([]),b=(0,Et.Z)(C)===C;(0,o.d4)((()=>{I&&"connectionStateReady"===n&&Z()}),[n,I,Z]),(0,Ee.ZP)(I,v);const E=(0,o.Ye)((()=>s?s.map((e=>e.userId)):[]),[s]),M=(0,o.I4)((e=>{y({query:e})}),[y]),S=(0,o.Ye)((()=>{const e=(0,a.Rd)().users.byId,n=d?(0,l.kK)(d,e,m):[];return(0,l.ih)((0,g.Tw)([...n,...p||[],...f||[]]).filter((n=>{const a=e[n];return!E.includes(n)&&n!==r&&(!a||!(0,l.cS)(a)||!t&&a.canBeInvitedToGroup)})),c)}),[d,c,m,p,f,r,E,t]),R=(0,o.I4)((()=>{C.length&&(y({query:""}),i(C))}),[C,y,i]);return o.ZP.createElement("div",{className:"AddChatMembers"},o.ZP.createElement("div",{className:"AddChatMembers-inner"},o.ZP.createElement(Do.Z,{itemIds:S,selectedIds:C,filterValue:m,filterPlaceholder:P("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:h,onSelectedIdsChange:w,onFilterChange:M,noScrollRestore:b}),o.ZP.createElement(To.Z,{isShown:Boolean(C.length),disabled:u,ariaLabel:P("lng_channel_add_users"),onClick:R},u?o.ZP.createElement(Xe.Z,{color:"white"}):o.ZP.createElement("i",{className:"icon-arrow-right"}))))}))),qo=Object.keys(m.qt).length/2,Qo=Object.keys(m.u1).length/2;function Go(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const Ho=(0,o.X$)((0,a.c$)((e=>{var t;const{chatId:n,threadId:a}=(0,r.Bt)(e)||{},s=(0,r.g4)(e),o=n?null===(t=e.management.byChatId[n])||void 0===t?void 0:t.nextScreen:void 0;return{contentKey:(0,r.Wq)(e),chatId:n,threadId:a,isChatSelected:Boolean(n&&s),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,nextManagementScreen:o}}))((e=>{var t;let{contentKey:n,chatId:i,threadId:r,isChatSelected:c,shouldSkipHistoryAnimations:l,nextManagementScreen:d}=e;const{toggleChatInfo:u,toggleManagement:h,closeLocalTextSearch:g,setStickerSearchQuery:p,setGifSearchQuery:f,closePollResults:v,addChatMembers:I,setNewChatMembersDialogState:y,setEditingExportedInvite:Z,setOpenedInviteInfo:P,requestNextManagementScreen:C}=(0,a.uC)(),{width:w}=wt(),[b,E]=(0,o.eJ)(m.vi.Profile),[M,S]=(0,o.eJ)(m.u1.Initial),[R,k]=(0,o.eJ)(),[T,N]=(0,o.eJ)(),B=b!==m.vi.Profile,A=void 0!==n,x=n===m.qt.ChatInfo,L=n===m.qt.Search,O=n===m.qt.Management,F=n===m.qt.StickerSearch,U=n===m.qt.GifSearch,$=n===m.qt.PollResults,D=n===m.qt.AddingMembers,j=w<=s._m,[q,Q]=(0,o.eJ)(!A),G=null!==(t=(0,kt.Z)(n,!0,!c))&&void 0!==t?t:-1,H=(0,o.I4)((function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];switch(n){case m.qt.AddingMembers:y(m.WB.Closed);break;case m.qt.ChatInfo:if(B&&e){E(m.vi.Profile);break}u(void 0,{forceSyncOnIOs:!0});break;case m.qt.Management:switch(M){case m.u1.Initial:h();break;case m.u1.ChatPrivacyType:case m.u1.Discussion:case m.u1.GroupPermissions:case m.u1.GroupType:case m.u1.ChatAdministrators:case m.u1.ChannelSubscribers:case m.u1.GroupMembers:case m.u1.Invites:case m.u1.Reactions:case m.u1.JoinRequests:S(m.u1.Initial);break;case m.u1.GroupUserPermissionsCreate:case m.u1.GroupRemovedUsers:case m.u1.GroupUserPermissions:S(m.u1.GroupPermissions),k(void 0),N(void 0);break;case m.u1.ChatAdminRights:case m.u1.ChatNewAdminRights:case m.u1.GroupAddAdmins:case m.u1.GroupRecentActions:S(m.u1.ChatAdministrators);break;case m.u1.EditInvite:case m.u1.InviteInfo:S(m.u1.Invites),P({invite:void 0}),Z({chatId:i,invite:void 0})}break;case m.qt.Search:Go(),g();break;case m.qt.StickerSearch:Go(),p({query:void 0});break;case m.qt.GifSearch:Go(),f({query:void 0});break;case m.qt.PollResults:v()}}),[n,B,u,v,y,M,h,g,p,f,Z,i,P]),_=(0,o.I4)(((e,t)=>{k(e),N(t)}),[]),z=(0,o.I4)((e=>{I({chatId:i,memberIds:e})}),[I,i]);function V(e){if(-1!==G)switch(G){case m.qt.AddingMembers:return o.ZP.createElement(jo,{key:i,chatId:i,isActive:A&&e,onNextStep:z,onClose:H});case m.qt.ChatInfo:return o.ZP.createElement(xo,{key:i,chatId:i,profileState:b,onProfileStateChange:E});case m.qt.Search:return o.ZP.createElement(Lo,{chatId:i,threadId:r,onClose:H,isActive:A&&e});case m.qt.Management:return o.ZP.createElement(Oo,{key:i,chatId:i,currentScreen:M,isPromotedByCurrentUser:T,selectedChatMemberId:R,isActive:A&&e,onScreenSelect:S,onChatMemberSelect:_,onClose:H});case m.qt.StickerSearch:return o.ZP.createElement(Fo,{onClose:H,isActive:A&&e});case m.qt.GifSearch:return o.ZP.createElement(Uo,{onClose:H,isActive:A&&e});case m.qt.PollResults:return o.ZP.createElement($o,{onClose:H,isActive:A&&e})}}return(0,o.d4)((()=>A?(0,Ne.Z)(H):void 0),[A,H]),(0,o.d4)((()=>{setTimeout((()=>{Q(!A)}),300)}),[A]),(0,o.d4)((()=>{d&&(S(d),C(void 0))}),[d,C]),(0,o.d4)((()=>{A&&j&&H()}),[j]),(0,ln.Z)((e=>{let[t]=e;t!==i&&(E(m.vi.Profile),S(m.u1.Initial))}),[i]),(0,Ee.ZP)(c&&(n===m.qt.ChatInfo||n===m.qt.Management||n===m.qt.AddingMembers),(()=>H(!1)),u),o.ZP.createElement("div",{id:"RightColumn-wrapper",className:c?void 0:"is-hidden"},j&&o.ZP.createElement("div",{className:"overlay-backdrop",onClick:H}),o.ZP.createElement("div",{id:"RightColumn"},o.ZP.createElement(fo,{chatId:i,isColumnOpen:A,isProfile:x,isSearch:L,isManagement:O,isStickerSearch:F,isGifSearch:U,isPollResults:$,isAddingChatMembers:D,profileState:b,managementScreen:M,onClose:H,shouldSkipAnimation:q||l,onScreenSelect:S}),o.ZP.createElement(Le.Z,{name:q||l?"none":"zoom-fade",renderCount:qo+Qo,activeKey:O?qo+M:G,shouldCleanup:!0},V)))}))),_o=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,st.Z)(at.gl.Extra,"MediaViewer",!t);return n?o.ZP.createElement(n,null):void 0}));function zo(e,t){const n=document.createElement("a");n.href=e,n.download=t;try{n.click()}catch(e){console.error(e)}}const Vo=new Set,Xo=(0,o.X$)((0,a.c$)((e=>({activeDownloads:e.activeDownloads.byChatId,messages:e.messages.byChatId})))((e=>{let{activeDownloads:t,messages:n}=e;const{cancelMessageMediaDownload:s}=(0,a.uC)();(0,o.d4)((()=>{Object.entries(t).forEach((e=>{let[t,a]=e;a.map((e=>n[Number(t)].byId[e])).forEach((e=>{const t=(0,l.Ti)(e,"download");if(t){if(!Vo.has(t)){const n=H.UV(t);if(n)return Vo.delete(t),zo(n,(0,l.w6)(e)),void s({message:e});H.he(t,u.IU.BlobUrl,!0).then((n=>{Vo.delete(t),n&&zo(n,(0,l.w6)(e)),s({message:e})})),Vo.add(t)}}else s({message:e})}))}))}),[s,n,t])}))),Wo=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,st.Z)(at.gl.Extra,"Notifications",!t);return n?o.ZP.createElement(n,null):void 0})),Ko=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,st.Z)(at.gl.Extra,"Dialogs",!t);return n?o.ZP.createElement(n,null):void 0})),Yo=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"ForwardPicker",!t);return n?o.ZP.createElement(n,e):void 0})),Jo=(0,o.X$)((e=>{const{url:t}=e,n=(0,st.Z)(at.gl.Extra,"SafeLinkModal",!t);return n?o.ZP.createElement(n,e):void 0})),ei=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,st.Z)(at.gl.Extra,"HistoryCalendar",!t);return n?o.ZP.createElement(n,e):void 0})),ti=(0,o.X$)((e=>{const{groupCallId:t}=e,n=(0,st.Z)(at.gl.Calls,"GroupCall",!t);return n?o.ZP.createElement(n,e):void 0})),ni=(0,o.X$)((e=>{const{groupCallId:t}=e,n=(0,st.Z)(at.gl.Calls,"ActiveCallHeader",!t);return n?o.ZP.createElement(n,null):void 0})),ai=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,st.Z)(at.gl.Calls,"CallFallbackConfirm",!t);return n?o.ZP.createElement(n,{isOpen:t}):void 0}));let si,oi=!1;function ii(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 ri(e){document.title!==e&&(document.title=e)}const ci=(0,o.X$)((0,a.c$)((e=>{const{settings:{byKey:{animationLevel:t,language:n,wasTimeFormatSetManually:a}}}=e,{chatId:s,messageId:o}=e.audioPlayer,i=s&&o?(0,r.hj)(e,s,o):void 0;return{connectionState:e.connectionState,authState:e.authState,lastSyncTime:e.lastSyncTime,isLeftColumnShown:e.isLeftColumnShown,isRightColumnShown:(0,r.Jf)(e),isMediaViewerOpen:(0,r.zQ)(e),isForwardModalOpen:(0,r.Ev)(e),hasNotifications:Boolean(e.notifications.length),hasDialogs:Boolean(e.dialogs.length),audioMessage:i,safeLinkModalUrl:e.safeLinkModalUrl,isHistoryCalendarOpen:Boolean(e.historyCalendarSelectedAt),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,openedStickerSetShortName:e.openedStickerSetShortName,isServiceChatReady:(0,r.UW)(e),activeGroupCallId:e.groupCalls.activeGroupCallId,animationLevel:t,language:n,wasTimeFormatSetManually:a,isCallFallbackConfirmOpen:Boolean(e.groupCalls.isFallbackConfirmOpen),addedSetIds:e.stickers.added.setIds}}))((e=>{let{connectionState:t,authState:n,lastSyncTime:i,isLeftColumnShown:r,isRightColumnShown:c,isMediaViewerOpen:l,isForwardModalOpen:d,hasNotifications:u,hasDialogs:m,audioMessage:g,activeGroupCallId:p,safeLinkModalUrl:f,isHistoryCalendarOpen:v,shouldSkipHistoryAnimations:I,openedStickerSetShortName:y,isServiceChatReady:Z,animationLevel:P,language:C,wasTimeFormatSetManually:b,isCallFallbackConfirmOpen:E,addedSetIds:M}=e;const{sync:S,loadAnimatedEmojis:R,loadNotificationSettings:k,loadNotificationExceptions:T,updateIsOnline:N,loadTopInlineBots:B,loadEmojiKeywords:A,loadCountryList:x,loadAvailableReactions:L,loadStickerSets:F,loadAddedStickers:U,loadFavoriteStickers:$,ensureTimeFormat:D,openStickerSetShortName:j,checkVersionNotification:q,loadAppConfig:Q}=(0,a.uC)();s.eM&&!oi&&(oi=!0,console.log(">>> RENDER MAIN")),(0,o.d4)((()=>{"connectionStateReady"===t&&"authorizationStateReady"===n&&S()}),[t,n,S]),(0,o.d4)((()=>{i&&(N(!0),Q(),L(),R(),k(),T(),B(),A({language:s.pR}))}),[i,R,A,T,k,B,N,L,Q]),(0,o.d4)((()=>{i&&(C!==s.pR&&A({language:C}),x({langCode:C}))}),[C,i,x,A]),(0,o.d4)((()=>{i&&(M?U():(F(),$()))}),[i,M,F,$,U]),(0,o.d4)((()=>{i&&Z&&q()}),[i,Z,q]),(0,o.d4)((()=>{i&&!b&&D()}),[i,b,D]),(0,o.d4)((()=>{i&&Ee.Oy.startsWith("#?tgaddr=")&&(0,pe.o)(decodeURIComponent(Ee.Oy.substr("#?tgaddr=".length)))}),[i]),(0,o.d4)((()=>{if(p)return W.Z.disableRefresh(),()=>{W.Z.enableRefresh()}}),[p]);const{transitionClassNames:G}=(0,ve.Z)(!r,void 0,!0,void 0,I),{transitionClassNames:H}=(0,ve.Z)(c,void 0,!0,void 0,I),_=(0,he.Z)(G.replace(/([\w-]+)/g,"middle-column-$1"),H.replace(/([\w-]+)/g,"right-column-$1"),I&&"history-animation-disabled");(0,Ze.Z)((e=>{let[t]=e;if(void 0===t||0===P)return;const n=(0,me.YW)();(0,ge.L)(document.getElementById("MiddleColumn"),n)}),[r]),(0,Ze.Z)((e=>{let[t]=e;if(void 0===t||0===P)return;(0,w.T2)((()=>{document.body.classList.add("animating-right-column")}));const n=(0,me.YW)();(0,ge.L)(document.getElementById("RightColumn"),(()=>{n(),(0,w.T2)((()=>{document.body.classList.remove("animating-right-column")}))}))}),[c]);const z=(0,o.I4)((()=>{N(!1);const e=(0,O.xW)();let t=0;clearInterval(si),si=window.setInterval((()=>{if(document.title.includes(s.ou))ii(!1);else{if(t%2==0){const t=(0,O.xW)()-e;t>0&&(ri(`${t} notification${t>1?"s":""}`),ii(!0))}else ri(s.Ti),ii(!1);t++}}),1e3)}),[N]),V=(0,o.I4)((()=>{N(!0),clearInterval(si),si=void 0,document.title.includes(s.ou)||ri(s.Ti),ii(!1)}),[N]),X=(0,o.I4)((()=>{j({stickerSetShortName:void 0})}),[j]);return(0,Ie.Z)(z,V),ye(z),function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,o.d4)((()=>{if(h.$b){if(!e)return null==Pe||Pe.setAttribute("content",Ce),h.cj&&!h.fl&&document.addEventListener("gesturestart",be),()=>{null==Pe||Pe.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),h.cj&&!h.fl&&document.removeEventListener("gesturestart",be)};null==Pe||Pe.setAttribute("content",we)}}),[e])}(l),o.ZP.createElement("div",{id:"Main",className:_,onDrop:fe.Z,onDragOver:fe.Z},o.ZP.createElement(It,null),o.ZP.createElement(ho,null),o.ZP.createElement(Ho,null),o.ZP.createElement(_o,{isOpen:l}),o.ZP.createElement(Yo,{isOpen:d}),o.ZP.createElement(Wo,{isOpen:u}),o.ZP.createElement(Ko,{isOpen:m}),g&&o.ZP.createElement(an,{key:g.id,message:g,noUi:!0}),o.ZP.createElement(Jo,{url:f}),o.ZP.createElement(ei,{isOpen:v}),o.ZP.createElement(Me.Z,{isOpen:Boolean(y),onClose:X,stickerSetShortName:y}),p&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(ti,{groupCallId:p}),o.ZP.createElement(ni,{groupCallId:p})),o.ZP.createElement(Xo,null),o.ZP.createElement(ai,{isOpen:E}),o.ZP.createElement(Te,{isForAppBadge:!0}))})));s.eM&&console.log(">>> FINISH LOAD MAIN BUNDLE"),(0,a.Rd)().connectionState||(0,a.uC)().initApi()},8973:(e,t,n)=>{e.exports=n.p+"encoderWorker.min.8ea62f6317fbac7d4558..js"},4524:(e,t,n)=>{e.exports=n.p+"telegram-logo-filled.67469f6dc5e301e8e0bd..svg"},257:e=>{e.exports="**Telegram Web Z was updated to version 1.34**\n\n🤩 **Better**\n• Reactions to your messages are now shown in notifications.\n• Multiple improvements for Media Viewer.\n• Better keyboard support in modal dialogs.\n• Various layout improvements.\n\n💪 **Stronger**\n• Video messages always play now.\n• Fixed playing multiple emoji interactions.\n"}}]);
//# sourceMappingURL=640.b191f48c5df91e546441.js.map