TelegramPWA/dist/176.2bd8fc859463a252c8a2.js
Alexander Zinchuk 86b636f941 [Build]
2022-02-25 22:56:09 +02:00

2 lines
258 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([[176],{3176:(e,t,n)=>{n.r(t),n.d(t,{Main:()=>ui});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),I=n(711),y=n(4319);const Z=s.ck+s.fK;let P;function C(e,t,n){const{threadId:a}=(0,r.Bt)(e)||{},s=I.i0,o=(0,r.Zw)(e,t);if(!o||!a)return;const i=n.map((e=>o[e])).filter((t=>(0,r._k)(e,t,a).canCopy)).sort(((e,t)=>e.id-t.id)).reduce(((t,n)=>{const a=(0,r.Ur)(e,n);return t.push(`> ${a?(0,l.OU)(s,a):""}:`),t.push((0,l.MK)(s,n,!1,0,void 0,!0)+"\n"),t}),[]);(0,y.TE)(i.join("\n"))}(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),I=!v||s!==v.chatId||o!==v.threadId||c!==v.type;if(P&&(clearTimeout(P),P=void 0),P=window.setTimeout((()=>{let e=(0,a.Rd)();e=(0,i.cq)(e),e=(0,i.wV)(e),(0,a.R3)(e)}),l?Z: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])}I&&(e=(0,i.wV)(e,m.fo.Static));const y=(0,r.Cb)(e,s,o);if(y&&y.includes(f))return(0,a.R3)(e),void t.openChat({id:s,threadId:o});if(I&&(e=(0,i.pf)(e,s,o,"viewportIds",void 0)),e=(0,i.pf)(e,s,o,"outlyingIds",void 0),y&&!I){const t=f>y[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)("copySelectedMessages",(e=>{if(!e.selectedMessages)return;const{chatId:t,messageIds:n}=e.selectedMessages;C(e,t,n)})),(0,a.Q6)("copyMessagesByIds",((e,t,n)=>{const{messageIds:a}=n,s=(0,r.jr)(e);a&&0!==a.length&&s&&C(e,s.id,a)})),(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 w=n(1947),b=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,b.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,w.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 E=n(1226),M=n(9118);const S=new Map,R=(0,M.Ds)((e=>e()),500,!1);async function k(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,E.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),C=(0,g.ee)(P,"id"),w=Object.keys(C).map(Number);y=(0,i.c_)(y,d,C),y=c?(0,i.ff)(y,d,t,w):(0,i.xj)(y,d,t,w),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 b=(0,r.gb)(y,d,t);const M=(0,r.qC)(y,d,t);if(c&&b&&M&&(M.length&&!(0,g.YE)(b,M)||(y=(0,i.xj)(y,d,t,M),b=(0,r.gb)(y,d,t),y=(0,i.pf)(y,d,t,"outlyingIds",void 0),c=!1)),!l){const e=c?M:b,{newViewportIds:a}=T(e,n,o);y=(0,i.y9)(y,d,t,a)}(0,a.R3)(y)}function T(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 N(e){let t;const n=e.attachment?(e,s)=>{S.has(s)||(t=s,S.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,M.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,E.t9)("sendMessage",e,n),n&&t&&S.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}=T(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 k(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}=T(a,t,m.Uq.Around);p&&u.length>=s.hT&&(e=(0,i.y9)(e,c,l,u)),f||k(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,E.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;N({...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}`;N({...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=>{N({...a,attachment:e,groupedId:r})}))}}else{const{text:e,entities:t,attachments:n,replyingTo:a,...s}=d;e&&N({...s,text:e,entities:t,replyingTo:a}),n.forEach((e=>{N({...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,E.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&&S.get(o.previousLocalId||o.id);i&&(0,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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(R((()=>{(0,E.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,E.t9)("markMessagesRead",{chat:a,messageIds:s})})),(0,a.Q6)("loadWebPagePreview",((e,t,n)=>{const{text:s}=n;!async function(e){const t=await(0,E.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,E.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,E.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,E.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;N({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,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.t9)("viewSponsoredMessage",{chat:s,random:o.randomId})}));var B=n(5765);const x=(0,M.P2)((e=>e()),500,!1);async function A(e,t){const n=await(0,E.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,E.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,M.wO)(200))}})()})),(0,a.Q6)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};!async function(e){const t=await(0,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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&&x((()=>{!async function(e,t){const n=await(0,E.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,B.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&&x((()=>{A(a)}))})),(0,a.Q6)("searchMoreGifs",(e=>{const{query:t,offset:n}=e.gifs.search;"string"==typeof t&&x((()=>{A(t,n)}))})),(0,a.Q6)("loadStickersForEmoji",((e,t,n)=>{const{emoji:s}=n,{hash:o}=e.stickers.forEmoji;x((()=>{!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,E.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 L=n(790);const O=(0,M.P2)((e=>e()),500,!1);async function U(){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,E.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,E.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 F(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const c=await(0,E.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||F(e,t,h,!0))}(0,a.Q6)("setGlobalSearchQuery",((e,t,n)=>{const{chatId:s}=e.globalSearch,{query:o}=n;o&&!s&&O((()=>{!async function(e){const t=await(0,E.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,L.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;U("","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,L.IS)(c):c,{type:d}=n;U(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,E.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&&F(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,E.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,E.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,E.t9)("migrateChat",o),!o)return;t.openChat({id:o.id})}const n=await(0,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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 $=n(6974);let D;function j(e){return(0,E.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"),D&&clearTimeout(D),(0,a.R3)({...(0,a.Rd)(),isSyncing:!0}),D=window.setTimeout((()=>{(0,a.R3)({...(0,a.Rd)(),isSyncing:!1}),D=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 j(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 j(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,$.S1)(),e({listType:"archived",shouldReplace:!0}),(0,E.t9)("fetchCurrentUser"),t()}})}));const Q=(0,M.Ds)((e=>e()),500,!1,!0),q=(0,M.P2)((e=>e()),500,!1);function G(e,t,n){return{...e,inlineBots:{...e.inlineBots,byUsername:{...e.inlineBots.byUsername,[t]:n}}}}function H(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;Q((()=>(0,E.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,E.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,E.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,E.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,E.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,E.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,E.t9)("updateContact",{phone:c.phoneNumber,firstName:n,lastName:s});else{const{id:e,accessHash:t}=c;l=await(0,E.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,E.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,E.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&&q((()=>{!async function(e){const t=await(0,E.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,E.t9)("addContact",(0,g.ei)(s,["id","accessHash","firstName","lastName","phoneNumber"]))}));const _=(0,M.Ds)((e=>e()),500,!1);async function z(e,t,n,a,s){await(0,E.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,E.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}),z(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,E.t9)("unblockContact",l.id,l.accessHash)&&((0,a.R3)((0,i.rB)((0,a.Rd)(),l.id)),z(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,E.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,E.t9)("fetchInlineBot",{username:o})||{};if(e=(0,a.Rd)(),!n||!s)return void(0,a.R3)(G(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=G(e,o,t),(0,a.R3)(e)}(c!==t.query||t.canLoadMore)&&_((()=>{!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=H(c,!0),c=G(c,t,{...n,query:o,...u&&{offset:void 0,results:[]}}),(0,a.R3)(c);const m=await(0,E.t9)("fetchInlineBotResults",{bot:l,chat:d,query:o,offset:u?void 0:i}),h=c.inlineBots.byUsername[t];if(c=H((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=G(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,E.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)(G(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,E.t9)("startBot",{bot:o,startParam:s})})()})),n(9667),(0,a.Q6)("loadPasswordInfo",(()=>{(async()=>{const e=await(0,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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,E.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{nativeProvider:o}=e.payment,{credentials:c}=n,{data:d}=c;if("stripe"===o){const t=(0,r.$$)(e);if(!t)return;!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)}(d,t)}else if("smartglocal"===o){const t=(0,r.EB)(e);if(!t)return;!async function(e,t){const n={card:{number:e.cardNumber.replace(/[^\d]+/g,""),expiration_month:e.expiryMonth,expiration_year:e.expiryYear,security_code:e.cvv.replace(/[^\d]+/g,"")}},o=s.eA?"https://tgb-playground.smart-glocal.com/cds/v1/tokenize/card":"https://tgb.smart-glocal.com/cds/v1/tokenize/card",r=await fetch(o,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","X-PUBLIC-TOKEN":t},body:JSON.stringify(n)}),c=await r.json();if("ok"!==c.status){const e={description:"payment error"},t=(0,a.Rd)();return void(0,a.R3)({...t,payment:{...t.payment,error:{...e}}})}let l=(0,i.QD)((0,a.Rd)(),{type:"card",token:c.data.token});l=(0,i.Q$)(l,m.KB.Checkout),(0,a.R3)(l)}(d,t)}})),(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),{nativeProvider:h}=e.payment,g="stripe"===h?(0,r.$$)(e):(0,r.EB)(e);l&&d&&g&&u&&h&&async function(e,t,n,s,o,r,c){if(!0===await(0,E.t9)("sendPaymentForm",{chat:e,messageId:t,formId:s,credentials:o,requestedInfoId:r,shippingOptionId:c})){const e=(0,i.bp)((0,a.Rd)());(0,a.R3)((0,i.WY)(e))}}(l,d,0,u,{save:o,data:"stripe"===h?(0,r.i3)(e):(0,r.Jg)(e)},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 V=n(647),X=n(3495);const K=728,W=424,Y=288;var J=n(3858);function ee(e,t){return t-(e.isLeftColumnShown&&!h.wB?e.leftColumnWidth||((n=J.Z.get().width)>s._m?Math.min(Math.max(.25*n,Y),.33*n):n>s.ks?Math.min(Math.max(.33*n,Y),.4*n):W):0);var n}let te=0;(0,a.Q6)("loadAvailableReactions",(()=>{(async()=>{const e=await(0,E.t9)("getAvailableReactions");e&&(e.forEach((e=>{e.aroundAnimation&&V.he(`sticker${e.aroundAnimation.id}`,u.IU.Lottie),e.centerIcon&&V.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:te++,animatedEffect:a||i,x:ee(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,E.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,E.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,X.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,E.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,E.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,E.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,E.t9)("sendWatchingEmojiInteraction",{chat:m,emoticon:o}),{...e,activeEmojiInteractions:e.activeEmojiInteractions.map((t=>t.id===u?{...t,x:ee(e,i),y:c,startSize:l,isReversed:d}:t))}})),n(4907);var ne=n(8406);function ae(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)=>ae(e,a[t])))}const s=e,o=t;return Object.keys(s).every((e=>ae(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,ne.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,ne.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,ne.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 se=n(3995);const oe=350;function ie(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 re(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 ce(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=re(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 le(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 de(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 ue(e,t,n,s){if(e){t.forEach((t=>{const n=de(s=(0,i.cY)(s,e,t,{isDeleting:!0}),e);n&&(s=le(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=re(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})}))}),oe)}const o=[];t.forEach((e=>{const t=(0,r.X5)(s,e);if(t){o.push(t);const n=de(s=(0,i.cY)(s,t,e,{isDeleting:!0}),t);n&&(s=le(s,t,n,!0)),setTimeout((()=>{(0,a.R3)((0,i.K4)((0,a.Rd)(),t,[e]))}),oe)}})),(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=ce(e=ie(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)(le(e,o,h))}),oe)}else(0,a.R3)(le((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=ie(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=ie(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=le(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=ie(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=ce(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=le(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;ue(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)}),oe))}(s,t,0,e);break}case"deleteHistory":{const{chatId:a}=n,s=e.messages.byChatId[a];s?ue(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&&ae(o,d))return;const u=(0,se.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,ne.rh)({chat:l,message:n})}(0,a.R3)(e);break}}}));const me=(0,M.P2)((function(){const e=(0,a.Rd)();(0,a.R3)((0,i.ps)(e,{...e.users.statusesById,...he})),he={}}),3e3,!0);let he={};(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,he[a]=s,void me();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;break;case"updatePaymentVerificationNeeded":e=(0,i.fS)((0,a.Rd)(),n.url),e=(0,i.Q$)(e,m.KB.ConfirmPayment),(0,a.R3)(e)}})),(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 ge=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,ge.dc)(e,n.call.id):(0,ge.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,ge.B6)(e,t,n.id,n,Boolean(o)||i===n.id))})),o&&(e=(0,ge.AH)(e,t,{nextOffset:o})),e}}})),(0,a.Q6)("apiUpdate",((e,t,n)=>{if("updatePaymentStateCompleted"===n["@type"])return(0,i.bp)(e)}));var pe=n(8674),fe=n(6752),ve=n(1279),Ie=n(3551),ye=n(3227),Ze=n(1212),Pe=n(5332);function Ce(e){(0,o.d4)((()=>(0,M.Gq)(e)),[e])}var we=n(9290);const be=document.querySelector('meta[name="viewport"]'),Ee=(null==be?void 0:be.getAttribute("content"))||"",Me="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover";function Se(e){e.preventDefault()}var Re=n(6590),ke=n(4851),Te=n(2155),Ne=n(5616),Be=n(7358);const xe=(0,o.X$)((e=>{let{isForAppBadge:t}=e;(0,Ne.yi)();const n=(0,$.xW)();if((0,o.d4)((()=>{t&&(0,Be.w)(n)}),[t,n]),!t&&n)return o.ZP.createElement("div",{className:"unread-count active"},(0,Te.bi)(n))}));var Ae=n(3989),Le=n(7529),Oe=n(3455),Ue=n(706),Fe=n(2255),$e=n(9107),De=n(7370),je=n(7926),Qe=n(1622);let qe;function Ge(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?qe.syncing:qe.online:qe.waitingForNetwork,c=r===qe.online||i?"none":a?"middleHeader":s?"minimized":"overlay",r===qe.waitingForNetwork?l=e("WaitingForNetwork"):r===qe.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"}(qe||(qe={}));var He=n(3106),_e=n(8964),ze=n(231),Ve=n(9589),Xe=n(9187),Ke=n(3321),We=n(126),Ye=n(9204);const Je=(0,o.X$)((e=>{let{connectionStatus:t,connectionStatusText:n,onClick:a}=e;const s=(0,$e.Z)();return o.ZP.createElement("div",{id:"ConnectionStatusOverlay",dir:s.isRtl?"rtl":void 0,onClick:a},o.ZP.createElement(Ye.Z,{color:"black"}),o.ZP.createElement("div",{className:"state-text"},o.ZP.createElement(Fe.Z,{activeKey:t,name:"slide-fade"},n)),o.ZP.createElement(ze.Z,{round:!0,size:"tiny",color:"translucent-black"},o.ZP.createElement("span",{className:"icon-close"})))})),et=[0,1,2],tt=(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:B}=(0,a.uC)(),x=(0,$e.Z)(),A=t===m.du.ChatList,O=(0,o.Ye)((()=>y?(0,L.xH)(new Date(1e3*y)):void 0),[y]),U=(0,o.Ye)((()=>A&&C?Object.values(C).reduce(((e,t)=>(0,l.pE)(t)&&t.unreadCount?e+1:e),0):0),[A,C]),{connectionStatus:F,connectionStatusText:$,connectionStatusPosition:D}=Ge(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(ze.Z,{round:!0,ripple:A&&!h.wB,size:"smaller",color:"translucent",className:n?"active":"",onClick:A?t:()=>u(),ariaLabel:A?x("AccDescrOpenMenu2"):"Return to chat list"},o.ZP.createElement("div",{className:(0,fe.Z)("animated-menu-icon",!A&&"state-back",f&&"no-animation")}))}),[A,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,De.Z)(t,P===s.zy)}),[P,N,Z]),z=(0,o.I4)((e=>{e.stopPropagation();const t=0===P?2:0;et.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(He.Z,{trigger:Q,footer:`${s.iC} ${s.eM?"master":s.Ji}`},o.ZP.createElement(_e.Z,{icon:"saved-messages",onClick:H},x("SavedMessages")),o.ZP.createElement(_e.Z,{icon:"archive",onClick:d},o.ZP.createElement("span",{className:"menu-item-name"},x("ArchivedChats")),U>0&&o.ZP.createElement("div",{className:"archived-badge"},U)),o.ZP.createElement(_e.Z,{icon:"user",onClick:c},x("Contacts")),o.ZP.createElement(_e.Z,{icon:"settings",onClick:r},x("Settings")),o.ZP.createElement(_e.Z,{icon:"darkmode",onClick:_},o.ZP.createElement("span",{className:"menu-item-name"},x("lng_menu_night_mode")),o.ZP.createElement(Ke.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(_e.Z,{icon:"animations",onClick:z},o.ZP.createElement("span",{className:"menu-item-name capitalize"},x("Appearance.Animations").toLowerCase()),o.ZP.createElement(Ke.Z,{id:"animations",label:"Toggle Animations",checked:P>0})),o.ZP.createElement(_e.Z,{icon:"help",onClick:()=>{k({langCode:x.code})}},x("TelegramFeatures")),o.ZP.createElement(_e.Z,{icon:"bug",href:s.mU},"Report Bug"),j&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(_e.Z,{icon:"char-K",href:"https://web.telegram.org/k/",onClick:()=>{(0,je.L)("K"),(0,Qe.W8)(),(0,Re.Wv)()}},"Switch to K Version"),o.ZP.createElement(_e.Z,{icon:"char-W",href:"https://web.telegram.org/?legacy=1",onClick:Re.Wv},"Switch to Old Version"))),o.ZP.createElement(Ve.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(Xe.Z,{icon:"calendar",title:O,canClose:!0,isMinimized:Boolean(I),className:"search-date",onClick:T,clickArg:{date:void 0}}),I&&o.ZP.createElement(Xe.Z,{chatOrUserId:I,onClick:B,canClose:!0,clickArg:{id:void 0}})),o.ZP.createElement(We.Z,{isOpen:"overlay"===D,isCustom:!0,className:"connection-state-wrapper"},o.ZP.createElement(Je,{connectionStatus:F,connectionStatusText:$,onClick:G}))))})));var nt=n(1174),at=n(3133),st=n(1080);const ot=(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,$e.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,Ne.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,nt.sf)(f.current,{selectorToPreventScroll:".chat-list",onSwipe:(e,t)=>t===nt.eM.Left?(g(Math.min(c+1,Z.length-1),{forceOnHeavyAnimation:!0}),!0):t===nt.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,Ae.Z)((()=>{C.current&&g(0)})):void 0),[c,g]),(0,Re.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,Ze.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(st.Z,{folderType:"folder",folderId:a.id,isActive:e,lastSyncTime:d,onScreenSelect:n,foldersDispatch:t}):o.ZP.createElement(st.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(at.Z,{tabs:Z,activeTab:c,onSwitchTab:P}):w?o.ZP.createElement("div",{className:(0,fe.Z)("tabs-placeholder",b)}):void 0,o.ZP.createElement(Fe.Z,{ref:f,name:u?"none":v.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:c,renderCount:Z?Z.length:void 0},E))})));var it=n(9203),rt=n(8778),ct=n(4288);const lt=(0,o.X$)((e=>{const t=(0,rt.Z)(it.gl.Extra,"LeftSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(ct.Z,null)})),dt=(0,o.X$)((e=>{const t=(0,rt.Z)(it.gl.Extra,"ContactList");return t?o.ZP.createElement(t,e):o.ZP.createElement(ct.Z,null)}));var ut=n(2328);const mt=(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,$e.Z)(),l=(0,fe.Z)("NewChatButton",t&&"revealed",i&&"menu-is-open");return o.ZP.createElement("div",{className:l},o.ZP.createElement(ze.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(ut.Z,{isOpen:i,positionX:"right",positionY:"bottom",autoClose:!0,onClose:()=>{r(!1)}},o.ZP.createElement(_e.Z,{icon:"channel",onClick:a},c("NewChannel")),o.ZP.createElement(_e.Z,{icon:"group",onClick:s},c("NewGroup")),o.ZP.createElement(_e.Z,{icon:"user",onClick:n},c("NewMessageTitle"))))})),ht=Object.keys(m.du).length/2;let gt;const pt=(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,gt&&(clearTimeout(gt),gt=void 0),gt=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,Ue.Z)(!1);(0,o.d4)((()=>{const e=window.setTimeout(t,2592e5);return()=>{clearTimeout(e)}}),[t]);const{shouldRender:n,transitionClassNames:a}=(0,Ze.Z)(e);return[n,a,()=>{window.location.reload()}]}(),S=(0,$e.Z)();return o.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:h.$b?void 0:C,onMouseLeave:h.$b?void 0:w},o.ZP.createElement(tt,{content:t,contactsFilter:s,onSearchQuery:c,onSelectSettings:v,onSelectContacts:I,onSelectArchived:P,onReset:u,shouldSkipTransition:i}),o.ZP.createElement(Fe.Z,{name:i?"none":"zoom-fade",renderCount:ht,activeKey:t,shouldCleanup:!0,cleanupExceptionKey:m.du.ChatList},(e=>{switch(t){case m.du.ChatList:return o.ZP.createElement(ot,{onScreenSelect:d,foldersDispatch:r});case m.du.GlobalSearch:return o.ZP.createElement(lt,{searchQuery:n,searchDate:a,isActive:e,onReset:u});case m.du.Contacts:return o.ZP.createElement(dt,{filter:s,isActive:e,onReset:u});default:return}})),b&&o.ZP.createElement(ze.Z,{fluid:!0,pill:!0,className:(0,fe.Z)("btn-update",E),onClick:M},S("lng_update_telegram")),o.ZP.createElement(mt,{isShown:g,onNewPrivateChat:I,onNewChannel:y,onNewGroup:Z}))})),ft=(0,o.X$)((e=>{const t=(0,rt.Z)(it.gl.Extra,"Settings");return t?o.ZP.createElement(t,e):o.ZP.createElement(ct.Z,null)})),vt=(0,o.X$)((e=>{const t=(0,rt.Z)(it.gl.Extra,"NewChat");return t?o.ZP.createElement(t,e):o.ZP.createElement(ct.Z,null)})),It=(0,o.X$)((e=>{const t=(0,rt.Z)(it.gl.Extra,"ArchivedChats");return t?o.ZP.createElement(t,e):o.ZP.createElement(ct.Z,null)}));var yt;!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"}(yt||(yt={}));const Zt=Object.keys(yt).length/2,Pt=(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,Oe.ZP)(),[S,R]=(0,o.eJ)(0);let k=yt.Main;switch(y){case m.du.Archived:k=yt.Archived;break;case m.du.Settings:k=yt.Settings;break;case m.du.NewChannelStep1:case m.du.NewChannelStep2:k=yt.NewChannel;break;case m.du.NewGroupStep1:case m.du.NewGroupStep2:k=yt.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,Ae.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,Le.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:x,handleMouseUp:A}=((e,t,n,a)=>{const[s,i,r]=(0,Ue.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(Fe.Z,{name:i?"none":h.s0,renderCount:Zt,activeKey:k,shouldCleanup:!0,cleanupExceptionKey:yt.Main},(e=>{switch(k){case yt.Archived:return o.ZP.createElement(It,{isActive:e,onReset:T,onContentChange:Z});case yt.Settings:return o.ZP.createElement(ft,{isActive:e,currentScreen:P,foldersState:E,foldersDispatch:M,onScreenSelect:L,onReset:T,shouldSkipTransition:i});case yt.NewChannel:return o.ZP.createElement(vt,{key:S,isActive:e,isChannel:!0,content:y,onContentChange:Z,onReset:T});case yt.NewGroup:return o.ZP.createElement(vt,{key:S,isActive:e,content:y,onContentChange:Z,onReset:T});default:return o.ZP.createElement(pt,{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:A,onDoubleClick:x}))})));var Ct=n(2420),wt=n(5780),bt=n(9524),Et=n(1394);const Mt=()=>{const[e,t]=(0,o.eJ)(J.Z.get());return(0,o.d4)((()=>{const e=(0,M.P2)((()=>{t(J.Z.get())}),250,!1);return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),e};var St=n(2678),Rt=n(7204),kt=n(5326),Tt=n(3570),Nt=n(5790),Bt=n(8360),xt=n(6058),At=n(8799);const Lt=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"HeaderMenuContainer",!t);return n?o.ZP.createElement(n,e):void 0})),Ot=(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})}),[]),x=(0,o.I4)((()=>{k(!1)}),[]),A=(0,o.I4)((()=>{N(void 0)}),[]),L=(0,o.I4)((()=>{P({chatId:t})}),[P,t]),O=(0,o.I4)((()=>{C({command:"/start"})}),[C]),U=(0,o.I4)((()=>{b({chatId:t})}),[t,b]),F=(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,Le.Z)(e)&&(e.preventDefault(),$())}}),[d,$]);const D=(0,$e.Z)();return o.ZP.createElement("div",{className:"HeaderActions"},!h.wB&&o.ZP.createElement(o.ZP.Fragment,null,Z&&l&&o.ZP.createElement(ze.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:L},D(i?"ProfileJoinChannel":"ProfileJoinGroup")),Z&&r&&o.ZP.createElement(ze.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:O},D("BotStart")),Z&&c&&o.ZP.createElement(ze.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:U},D("BotRestart")),d&&o.ZP.createElement(ze.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(ze.Z,{round:!0,color:"translucent",size:"smaller",onClick:E,ariaLabel:"Call"},o.ZP.createElement("i",{className:"icon-phone"}))),Boolean(I)&&o.ZP.createElement(ze.Z,{round:!0,className:"badge-button",ripple:y,color:"translucent",size:"smaller",onClick:F,ariaLabel:D(i?"SubscribeRequests":"MemberRequests")},o.ZP.createElement("i",{className:"icon-user"}),o.ZP.createElement("div",{className:"badge"},I)),o.ZP.createElement(ze.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(Lt,{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:x,onCloseAnimationEnd:A}))})));var Ut=n(4399),Ft=n(6202),$t=n(862);function Dt(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)($t.Hu),d=null==e?void 0:e.id;return(0,o.bt)((()=>{i&&(0,$t.p6)(`b64-${d}`,n).then(c).catch((e=>{s.eM&&console.error(e)}))}),[d,i,n]),i?r:n}var jt=n(7551),Qt=n(8512),qt=n(996);function Gt(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 Ht=(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=Gt(0,0,2,t,1)+Gt(0,12,2,t+1,1)+Gt(0,25,2,t,1);else for(let e=0;e<n;e++)a+=Gt(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,fe.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);`})))})),_t=(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,$e.Z)(),m=Dt(t),h=(0,Ft.Z)((0,l.Ti)(t,"pictogram")),g=(0,qt.e)(u,t,Boolean(m)),[p,f,v]=(0,Ue.Z)(),I=(0,o.I4)((()=>{v(),r&&r(t.id)}),[v,r,t.id]);return o.ZP.createElement("div",{className:(0,fe.Z)("HeaderPinnedMessage-wrapper",i)},n>1&&o.ZP.createElement(ze.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(ze.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(jt.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(Ht,{count:n,index:a}),m&&function(e,t){const{width:n,height:a}=(0,Ut.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(Qt.Z,null)))}));var zt=n(396),Vt=n(4532),Xt=n(3186);function Kt(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=()=>{Wt(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 Wt(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";if(!("createImageBitmap"in window))return Yt(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 Yt(e,t,n,void 0,a)}}function Yt(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 Jt=n(4524);const en={width:200,height:200},tn=115,nn=(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)(I.i0,t),c=n&&(0,l.U)(I.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,Ft.Z)(m),g=(0,o.Ye)((()=>function(e,t,n){if(!n)return en;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?Ut.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(Jt);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=()=>{Wt(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,tn,tn);const n=Math.min(t.width,t.height);return n<tn?Kt(e,tn/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],Jt);return(0,o.Ye)((()=>(0,Vt.Of)({title:i,artist:r,album:c,artwork:[{src:p}]})),[c,r,i,p])};var an=n(2340),sn=n(8051);const on=(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,$e.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=V.UV((0,l.Ti)(t,"inline")),E=nn(t,i,r),{playPause:M,stop:S,isPlaying:R,requestNextTrack:k,requestPreviousTrack:T,isFirst:N,isLast:B,setVolume:x,toggleMuted:A,setPlaybackRate:L}=(0,Xt.Z)((0,zt.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 J.Z.disableRefresh(),()=>{J.Z.enableRefresh()}}),[O]);const U=(0,o.I4)((()=>{f({chatId:t.chatId,messageId:t.id})}),[f,t.chatId,t.id]),F=(0,o.I4)((()=>{R&&M(),v(),(0,Vt.Ay)(),S()}),[v,R,M,S]),$=(0,o.I4)((e=>{m({volume:e/100}),p({isMuted:!1}),x(e/100)}),[p,m,x]),D=(0,o.I4)((()=>{h.$b&&!h.cj||(A(),p({isMuted:!u}))}),[u,p,A]),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,fe.Z)("AudioPlayer",n),dir:I.isRtl?"rtl":void 0},o.ZP.createElement(ze.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(ze.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:(0,fe.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(ze.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:U},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,an.Z)(t||a)),n&&o.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,an.Z)(n)))}(y):function(e,t){return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,an.Z)(t)),o.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(I("AttachAudio"),w),o.ZP.createElement(Qt.Z,null)),o.ZP.createElement(ze.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(sn.Z,{value:u?0:100*c,onChange:$})))),C&&o.ZP.createElement(ze.Z,{round:!0,className:(0,fe.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(ze.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:F,ariaLabel:"Close player"},o.ZP.createElement("i",{className:"icon-close"})))}));var rn=n(2607),cn=n(172);const ln=(0,o.X$)((0,a.c$)(((e,t)=>{let{chatId:n}=t;const a=(0,r.Z1)(e,n),s=(0,rn.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,$e.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,fe.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(cn.Z,{key:e.user.id,user:e.user}):o.ZP.createElement(cn.Z,{key:e.chat.id,chat:e.chat})}))),o.ZP.createElement(ze.Z,{round:!0,className:"join"},u("VoipChatJoin")))}))),dn=(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:x,loadPinnedMessages:A,toggleLeftColumn:L,exitMessageSelectMode:O}=(0,a.uC)(),U=(0,$e.Z)(),F=(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)(U,Z).length,H=g?(0,l.OU)(U,g):void 0;(0,o.d4)((()=>{n===u._f&&b&&r&&A({chatId:t})}),[t,A,b,n,r]),(0,o.d4)((()=>{D(0)}),[c]),(0,Nt.Z)(t,j,Q);const{width:_}=Mt(),z=_<=s.ks,V=h.p7&&v,X=(0,o.sO)(null),K=(0,o.sO)(!0),W=(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,Tt.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((()=>{F.current=!0}),450)}),[]),ne=(0,o.I4)((e=>{if(F.current){if(F.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();x(),te()}}),[n,i,M,f,x,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,Ze.Z)(Boolean(y)),re=(0,Bt.Z)(y,!0),{shouldRender:ce,transitionClassNames:le}=(0,Ze.Z)(Boolean(Q)),de=(0,Bt.Z)(Q,!0),ue=(0,Bt.Z)(q,!0),me=(0,Bt.Z)(m,!0),he=(0,Bt.Z)(H),ge=ce&&de||oe&&re;(0,o.d4)((()=>{const e=X.current;if(e)return se&&ge?void(I||ae?(K.current&&(e.classList.add("tools-stacked","animated"),K.current=!1),setTimeout((()=>{e.classList.remove("animated")}),350)):(e.classList.remove("tools-stacked"),K.current=!0)):(e.classList.remove("tools-stacked","animated"),void(K.current=!0))}),[se,ge,ae,I]);const{connectionStatusText:pe}=Ge(U,S,R,!0);function ve(){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(ze.Z,{round:!0,size:"smaller",color:"translucent",onClick:ne,ariaLabel:U(e?"Close":"Back")},o.ZP.createElement("div",{className:(0,fe.Z)("animated-close-icon",!e&&"state-back")})),t&&o.ZP.createElement(xe,null))}const Ie=Boolean(oe&&re);return o.ZP.createElement("div",{className:"MiddleHeader",ref:X},o.ZP.createElement(Fe.Z,{name:E?"none":"slide-fade",activeKey:M},"thread"===i&&n===u._f?o.ZP.createElement(o.ZP.Fragment,null,(z||M>0)&&ve(V,!0),o.ZP.createElement("div",{className:"chat-info-wrapper",onClick:W},(0,l.YC)(t)?o.ZP.createElement(xt.Z,{userId:t,typingStatus:p,status:pe,withDots:Boolean(pe),withFullInfo:w,withMediaViewer:!0,withUpdatingStatus:!0,noRtl:!0}):o.ZP.createElement(At.Z,{chatId:t,typingStatus:p,status:pe,withDots:Boolean(pe),withMediaViewer:!0,withFullInfo:!0,withUpdatingStatus:!0,noRtl:!0}))):"thread"===i?o.ZP.createElement(o.ZP.Fragment,null,ve(),o.ZP.createElement("h3",null,U("CommentsCount",P,"i"))):"pinned"===i?o.ZP.createElement(o.ZP.Fragment,null,ve(),o.ZP.createElement("h3",null,U("PinnedMessagesCount",P,"i"))):"scheduled"===i?o.ZP.createElement(o.ZP.Fragment,null,ve(),o.ZP.createElement("h3",null,C?U("Reminders"):U("messages",P,"i"))):void 0),o.ZP.createElement(ln,{hasPinnedOffset:ce&&Boolean(de)||oe&&Boolean(re),chatId:t}),ce&&de&&o.ZP.createElement(_t,{key:t,message:de,count:ue||0,index:$,customTitle:he,className:(0,fe.Z)(le,Ie&&"full-width"),onUnpinMessage:me?Y:void 0,onClick:J,onAllPinnedClick:ee}),o.ZP.createElement("div",{className:"header-tools"},Ie&&o.ZP.createElement(on,{key:(0,l.Tp)(re),message:re,className:ie}),o.ZP.createElement(Ot,{chatId:t,threadId:n,messageListType:i,canExpandActions:!Ie})))})));var un=n(2645),mn=n(274);function hn(e){return"albumId"in e}function gn(e,t){let n,a=[],s={originalDate:e[0].date,datetime:Number((0,L.$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,L.$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 pn=n(386),fn=n(2202);var vn=n(7675),In=n(539),yn=n(2357),Zn=n(998);var Pn=n(3657);const Cn=h.wZ?1e3:350,wn=h.wB?300:500;var bn=n(7240);function En(e){return"number"==typeof e}function Mn(e,t){return e?t?238:175:t?238:100}function Sn(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,Ut.Eh)(s,n,a,i,t):(0,Ut.GC)(o,n,a,t),d=Mn(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 Rn(e,t){return e.reduce(((e,t)=>e+t),t)}function kn(e,t,n){return e<t?t:e>n?n:e}function Tn(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 Nn(e,t,n,a){const s=function(e){return e.map((e=>{const t=Sn(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,Ut.kc)(e,t,!1,n)-(t?2.5:0)*Ut.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?kn(e,1,2.75):kn(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=Rn(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=Rn(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:Tn(d)}}let Bn;function xn(e){return Bn||(Bn=document.createElement("span"),Bn.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',Bn.style.whiteSpace="nowrap",Bn.style.position="absolute",Bn.style.left="-999px",Bn.style.opacity=".01",document.body.appendChild(Bn)),Bn.innerHTML=e,Bn.offsetWidth}function An(e,t,n,a,s,i){(0,o.bt)((()=>{if(n&&e.current){const t=e.current.closest(".MessageList");(0,In.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 Ln=3*Ut.Gw,On=Number(Ut.Gw),Un="data-is-document-group-hover";function Fn(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,Ue.Z)(),[C,w,b]=(0,Ue.Z)(),E=(0,o.sO)();return(0,o.d4)((()=>{if(!h.$b||i||!r||m)return;let e;return(0,nt.sf)(t.current,{selectorToPreventScroll:".MessageList",onSwipe:(t,n)=>n===nt.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,pn.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;J.Z.getIsKeyboardVisible()?setTimeout((()=>{l(e)}),350):l(e)}}(t)}),200))},handleContextMenu:i?c?ye.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)<Ln,l=Math.abs(i+r-a)<On;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=Dn(e.currentTarget);t&&t.removeAttribute(Un)}(e)},isSwiped:C,isQuickReactionVisible:y,handleDocumentGroupMouseEnter:$n}}function $n(e){const t=Dn(e.currentTarget);t&&t.setAttribute(Un,"")}function Dn(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}var jn=n(8005);const Qn=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"ContextMenuContainer",!t);return n?o.ZP.createElement(n,e):void 0})),qn=(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,Pn._N)(f,n),(0,Nt.Z)(t.chatId,t.replyToMessageId,u),An(f,t.chatId,h,g,p);const v=(0,$e.Z)(),I=s<=0,[y,Z]=(0,Ue.Z)(I);(0,o.d4)((()=>{I||setTimeout(Z,10*s)}),[s,Z,I]);const{transitionClassNames:P}=(0,Ze.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,jn.D)(v,t,c,l,C,u,m,{asTextWithSpoilers:a}),{isContextMenuOpen:b,contextMenuPosition:E,handleBeforeContextMenu:M,handleContextMenu:S,handleContextMenuClose:R,handleContextMenuHide:k}=(0,bn.Z)(f),T=void 0!==E;if(a)return o.ZP.createElement("span",{className:"embedded-action-message"},w);const N=(0,fe.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,pn.q)(e),M(e)},onContextMenu:S},o.ZP.createElement("span",null,w),E&&o.ZP.createElement(Qn,{isOpen:b,anchor:E,message:t,messageListType:"thread",onClose:R,onCloseAnimationEnd:k}))}))),Gn=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,Pn.Op)(u,c),h=(0,Ft.Z)(n&&(0,l.Ti)(n,"pictogram"),!m),g=n&&`sticker-reply-thumb${n.id}`,p=Dt(n),f=Boolean(n&&(0,l.Y5)(n)),v=(0,$e.Z)(),I=a&&(0,l.OU)(v,a);return o.ZP.createElement("div",{ref:u,className:(0,fe.Z)("EmbeddedMessage",t),onClick:n?d:void 0},p&&function(e,t,n,a,s){const{width:i,height:r}=(0,Ut.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(qn,{message:n,isEmbedded:!0}):(0,qt.e)(v,n,Boolean(p)):i||" "),o.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,an.Z)(I||s||" "))))};var Hn=n(2535),_n=n(4752),zn=n(8018),Vn=n(8198),Xn=n(7799);const Kn=(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,Ft.Z)(`sticker${m}`,!m,u.IU.Lottie),p=(0,Ft.Z)(`sticker${h}`,!h,u.IU.Lottie),f=Boolean((null==i?void 0:i.reaction)===s&&g&&p),{shouldRender:v,transitionClassNames:I}=(0,Ze.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,Ue.Z)(),w=!f||!Z,b=(0,fe.Z)("ReactionAnimatedEmoji",r&&"in-meta",v&&"is-animating");return o.ZP.createElement("div",{className:b},w&&o.ZP.createElement(Vn.Z,{reaction:s}),v&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Xn.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(Xn.Z,{key:h,id:`reaction_effect_${h}`,className:(0,fe.Z)("effect",I),size:100,animationData:p,play:!0,noLoop:!0,forceOnHeavyAnimation:!0,onEnded:y})))})),Wn=(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,$e.Z)(),[h,g]=(0,Ue.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,L.SA)(1e3*n.date,m.code),t=n.isEdited&&(0,L.SA)(1e3*n.editDate,m.code),a=n.forwardInfo&&(0,L.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,fe.Z)("MessageMeta",l&&"reactions-offset"),dir:m.isRtl?"rtl":"ltr",onClick:i},p&&p.map((e=>o.ZP.createElement(Kn,{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,Te.bi)(n.views)),o.ZP.createElement("i",{className:"icon-channelviews"})),s&&o.ZP.createElement("span",{className:"message-signature"},(0,an.Z)(s)),o.ZP.createElement("span",{className:"message-time",title:f,onMouseEnter:g},n.isEdited&&`${m("EditedMessage")} `,(0,L.mr)(m,1e3*n.date)),a&&o.ZP.createElement(zn.Z,{status:a}))}));var Yn=n(692),Jn=n(4753);const ea=e=>{let{message:t,observeIntersection:n,observeIntersectionForPlaying:a,shouldLoop:i,lastSyncTime:r}=e;const c=(0,o.sO)(null),[d,u,m]=(0,Ue.Z)(),g=t.content.sticker,{isLottie:p,stickerSetId:f,isGif:v}=g,I=h.Hh,y=f===s.$E,Z=(0,Pn.Op)(c,n),P=(0,Pn.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,Ft.Z)(w),E=Dt(t),M=b||E,S=(0,Ft.Z)(C,!Z,(0,l.kG)(t,"inline"),r),R=Boolean(S),[k,T]=(0,Ue.Z)(R),N=p?k:R,B=(0,Yn.Z)(N),{width:x,height:A}=(0,Ut.Wr)(g),L=(0,fe.Z)("thumbnail",!E&&"empty"),O=(0,fe.Z)("Sticker media-inner",y&&"inactive");return(0,o.d4)((()=>{if(!v||!c.current)return;const e=c.current.querySelector("video");e&&(P?(0,Jn.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:x,height:A,alt:"",className:L}),!p&&!v&&o.ZP.createElement("img",{id:`sticker-${t.id}`,src:S,width:x,height:A,alt:"",className:(0,fe.Z)("full-media",B)}),v&&I&&N&&o.ZP.createElement("video",{id:`sticker-${t.id}`,src:S,width:x,height:A,autoPlay:P,playsInline:!0,loop:i,muted:!0}),p&&R&&o.ZP.createElement(Xn.Z,{key:C,className:(0,fe.Z)("full-media",B),id:C,animationData:S,size:x,play:P,noLoop:!i,onLoad:T}),o.ZP.createElement(ke.Z,{isOpen:d,fromSticker:g,onClose:m}))};var ta=n(7854),na=n(2566),aa=n(5866);function sa(e,t){return(0,aa.Z)((0,l.DH)(e),Boolean(t),h.wB&&!h.vX)}const oa={dark:{outgoing:"rgb(135,116,225)",incoming:"rgb(33,33,33)"},light:{outgoing:"rgb(238,255,222)",incoming:"rgb(255,255,255)"}};var ia=n(9196);const ra=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,Pn.Op)(Z,a),[w,b]=(0,o.eJ)(i),E=w&&C,{mediaData:M,loadProgress:S}=(0,na.Z)((0,l.Ti)(n,u),!E),R=P||M,k=sa(n,R),{loadProgress:T}=(0,na.Z)((0,l.Ti)(n,"download"),!p),{isUploading:N,isTransferring:B,transferProgress:x}=(0,l.Sc)(n,d||(p?T:S),E&&!R),A=!1===(0,Rt.Z)(w),L=(0,Yn.Z)(R),{shouldRender:O,transitionClassNames:U}=(0,Ze.Z)(B,void 0,A,"slow"),{shouldRender:F,transitionClassNames:$}=(0,Ze.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(oa[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||Sn(n,s),H=(0,fe.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&&!F&&o.ZP.createElement("div",{className:`media-loading ${U}`},o.ZP.createElement(ia.Z,{progress:x,onClick:N?D:void 0})),F&&o.ZP.createElement("i",{className:(0,fe.Z)("icon-download",$)}),B&&o.ZP.createElement("span",{className:"message-transfer-progress"},Math.round(100*x),"%"))};var ca=n(2019),la=n(6898);function da(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,Jn.Z)(e.current)}),[e]),c=(0,o.I4)((()=>{(0,M.T2)(r)}),[r]);(0,Pe.Z)(i,c),(0,pe.ZP)(i,r)}function ua(){return ua=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},ua.apply(this,arguments)}const ma=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,Pn.Op)(y,i),[b,E]=(0,o.eJ)(c),M=Boolean(b&&w&&h),[S,R]=(0,o.eJ)(d),k=(0,Ft.Z)((0,l.Ti)(s,"pictogram"),!(w&&h),(0,l.kG)(s,"pictogram"),h),T=(0,Yn.Z)(k),{mediaData:N,loadProgress:B}=(0,na.Z)((0,l.Ti)(s,"inline"),!M,(0,l.kG)(s,"inline"),h),x=C||N,A=Boolean(w&&x),O=sa(s,k),{loadProgress:U}=(0,na.Z)((0,l.Ti)(s,"download"),!v,u.IU.BlobUrl,h),{isBuffered:F,bufferingHandlers:$}=(0,ca.Z)(!c),{isUploading:D,isTransferring:j,transferProgress:Q}=(0,l.Sc)(s,m||(v?U:B),M&&!F||v),q=!1===(0,Rt.Z)(b),{shouldRender:G,transitionClassNames:H}=(0,Ze.Z)(j,void 0,q),{shouldRender:_,transitionClassNames:z}=(0,Ze.Z)(b&&!S&&!G),[V,X]=(0,o.eJ)(0),K=(0,o.I4)((e=>{X(Math.max(0,e.currentTarget.currentTime-1))}),[]),W=(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,Ut.GC)(P,Y,J,r);da(Z,A),(0,la.Z)(Z,[A]);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,fe.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,fe.Z)("thumbnail",T),style:`width: ${ee}px; height: ${te}px;`,alt:"",draggable:!I}),A&&o.ZP.createElement("video",ua({ref:Z,className:"full-media",width:ee,height:te,autoPlay:S,muted:!0,loop:!0,playsInline:!0},$,{draggable:!I,onTimeUpdate:K}),o.ZP.createElement("source",{src:x})),I&&o.ZP.createElement("span",{className:"protector"}),_&&o.ZP.createElement("i",{className:(0,fe.Z)("icon-large-play",z)}),G&&o.ZP.createElement("div",{className:(0,fe.Z)("media-loading",H)},o.ZP.createElement(ia.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,L.k9)(Math.max(W-V,0))))};var ha=n(6272);const ga=(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,fe.Z)("Contact",Boolean(d)&&"interactive"),onClick:d?u:void 0},o.ZP.createElement(cn.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,ha.WZ)(s,l))))}));var pa=n(8974),fa=n(1218),va=n(4434),Ia=n(6937);function ya(e,t){return t>0?(e/t*100).toFixed():0}const Za=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?ya(c.votersCount,a||0):0,[m,h]=(0,o.eJ)(r?0:u),g=(0,o.sO)(null),p=c?ya(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,fe.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,an.Z)(t.text)),o.ZP.createElement("div",{className:(0,fe.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}))))},Pa=(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,B=M?Math.max(...M.map((e=>e.votersCount))):S,x=M?M.reduce(((e,t)=>(t.isCorrect&&e.push(t.option),e)),[]):[],A=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,L.k9)(w),n.firstElementChild.setAttribute("stroke-dashoffset",`-${e}`)}else e.innerHTML=`\n <span>${(0,L.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]),U=(0,o.I4)((e=>{I([e]),f(!0),C(!0),r([e])}),[r]),F=(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,$e.Z)();return o.ZP.createElement("div",{className:"Poll",dir:q.isRtl?"auto":"ltr"},y&&n.results.solution&&o.ZP.createElement(Ia.Z,{message:(0,pa.H)(n.results.solution,n.results.solutionEntities),duration:5e3,onDismiss:Q,containerId:"#middle-column-portals"}),o.ZP.createElement("div",{className:"poll-question"},(0,an.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(cn.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(ze.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(fa.Z,{options:A,onChange:F,disabled:t.isScheduled||p,loadingOptions:p?v:void 0,round:!0}):o.ZP.createElement(va.Z,{name:`poll-${u}`,options:A,onChange:U,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(Za,{key:e.option,shouldAnimate:P,answer:e,voteResults:M,totalVoters:S,maxVotersCount:B,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(ze.Z,{isText:!0,disabled:0===v.length,size:"tiny",onClick:$},q("PollSubmitVotes")),T&&o.ZP.createElement(ze.Z,{isText:!0,size:"tiny",onClick:D},q("PollViewResults")))})));var Ca=n(8035),wa=n(88);const ba=(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}=Sn(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,Ca.Z)(C,170),S=(0,fe.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(ra,{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(wa.Z,{className:"site-name",url:y,text:I||Z}),!r&&P&&o.ZP.createElement("p",{className:"site-title"},(0,an.Z)(P)),M&&o.ZP.createElement("p",{className:"site-description"},(0,an.Z)(M,["emoji","br"]))),!r&&b&&o.ZP.createElement(ma,{message:t,observeIntersection:n,noAvatars:a,canAutoLoad:s,canAutoPlay:i,lastSyncTime:c,onClick:E?v:void 0,onCancelUpload:g,isDownloading:d,isProtected:u}))}));var Ea=n(9937);const Ma=(0,o.X$)((e=>{let{message:t}=e;const n=(0,$e.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,an.Z)(s)),i&&o.ZP.createElement("p",null,(0,an.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,Ea.x)(r,c,n.code),d&&o.ZP.createElement("span",null,n("PaymentTestInvoice")))))}));function Sa(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,fe.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 Ra=Sa(ra),ka=Sa(ma),Ta=(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(Ra,{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(ka,{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 Na(){return Na=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},Na.apply(this,arguments)}let Ba;const xa=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,Pn.Op)(c,n),[p,f]=(0,o.eJ)(s),v=Boolean(p&&g&&i),{mediaData:I,loadProgress:y}=(0,na.Z)((0,l.Ti)(t,"inline"),!v,(0,l.kG)(t,"inline"),i),{loadProgress:Z}=(0,na.Z)((0,l.Ti)(t,"download"),!r,u.IU.BlobUrl,i),P=sa(t,I),{isBuffered:C,bufferingHandlers:w}=(0,ca.Z)(),b=p&&!C||r,E=!1===(0,Rt.Z)(p),S=(0,Yn.Z)(I),{shouldRender:R,transitionClassNames:k}=(0,Ze.Z)(b||!C,void 0,E),[T,N]=(0,o.eJ)(!1),[B,x]=(0,o.eJ)(0);(0,o.d4)((()=>{if(!T)return;const e=Ut.Rj/2,t=2*(e-6)*Math.PI,n=t-B*t,a=m.current,s=d.current,o=s.firstElementChild;o?o.firstElementChild.setAttribute("stroke-dashoffset",n.toString()):s.innerHTML=`\n <svg width="${Ut.Rj}px" height="${Ut.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,B]);const A=Boolean(I&&g),O=(0,o.I4)((()=>{m.current&&(N(!1),x(0),(0,Jn.Z)(m.current),(0,M.T2)((()=>{d.current.innerHTML=""})))}),[]),U=(0,o.I4)((()=>{var e;null===(e=Ba)||void 0===e||e(),Ba=O}),[O]);(0,o.d4)((()=>{m.current&&(A?(0,Jn.Z)(m.current):m.current.pause())}),[A]),da(m,A),(0,la.Z)(m,[I]);const F=(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,Jn.Z)(e),(0,zt.Es)()):e.pause():(U(),e.pause(),e.currentTime=0,(0,Jn.Z)(e),(0,zt.Es)(),N(!0))}),[U,T,r,I,t]),$=(0,o.I4)((e=>{const t=e.currentTarget;x(t.currentTime/t.duration)}),[]),D=(0,fe.Z)("full-media",S);return o.ZP.createElement("div",{ref:c,className:"RoundVideo media-inner",onClick:F},o.ZP.createElement("div",{className:"thumbnail-wrapper"},o.ZP.createElement("canvas",{ref:P,className:"thumbnail",style:`width: ${Ut.Rj}px; height: ${Ut.Rj}px`})),I&&o.ZP.createElement("div",{className:"video-wrapper"},o.ZP.createElement("video",Na({ref:m,className:D,width:Ut.Rj,height:Ut.Rj,autoPlay:!0,muted:!T,loop:!T,playsInline:!0,onEnded:T?O:void 0},w,{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(ia.Z,{progress:r?Z:y})),!I&&!p&&o.ZP.createElement("i",{className:"icon-download"}),o.ZP.createElement("div",{className:"message-media-duration"},T?(0,L.k9)(m.current.currentTime):(0,L.k9)(h.duration),(!T||m.current.paused)&&o.ZP.createElement("i",{className:"icon-muted"})))},Aa=e=>{let{message:t,onClick:n}=e;const a=(0,$e.Z)();return o.ZP.createElement("div",{className:"InlineButtons"},t.inlineButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(ze.Z,{size:"tiny",ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>n({button:e})},(0,an.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"}))))))))},La=(0,o.X$)((e=>{let{threadInfo:t,disabled:n}=e;const{openChat:s}=(0,a.uC)(),i=(0,$e.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,Te.bi)(d),className:(0,fe.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(cn.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"}))})),Oa=(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(ze.Z,{className:(0,fe.Z)(t.isChosen&&"chosen"),size:"tiny",onClick:d},o.ZP.createElement(Kn,{activeReaction:s,reaction:t.reaction,availableReactions:i}),null!=l&&l.length?o.ZP.createElement("div",{className:"avatars"},l.map((e=>o.ZP.createElement(cn.Z,{user:e,size:"micro"})))):(0,Te.bi)(t.count))})),Ua=(0,o.X$)((e=>{let{message:t,isOutside:n,activeReaction:a,availableReactions:s,metaChildren:i}=e;return o.ZP.createElement("div",{className:(0,fe.Z)("Reactions",n&&"is-outside")},t.reactions.results.map((e=>o.ZP.createElement(Oa,{key:e.reaction,reaction:e,message:t,activeReaction:a,availableReactions:s}))),i)}));var Fa=n(7324),$a=n(5296);const Da=(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,$a.Z)(i,l,c,s,d,a,n),v=`local_emoji_${t}`,I=(0,Pn.Op)(m,r),[y,Z]=(0,o.eJ)();return(0,o.d4)((()=>{t&&(0,Fa.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(Xn.Z,{key:v,id:v,animationData:y,size:g,quality:1,play:I&&u,forceOnHeavyAnimation:!0,noLoop:!0,onLoad:f}))})),ja={__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>'},Qa={__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>'},qa=(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,x=I===N,A=I&&!x?(0,r.hj)(e,w&&v?v:p,I):void 0,L=A&&(0,r.Ur)(e,A),O=(0,r.uZ)(e,o),U="thread"===m&&(i?i.messages.some((t=>(0,r._X)(e,t))):(0,r._X)(e,o)),{direction:F,noHighlight:$,isResizingContainer:D}=U&&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,K=V?h?(0,r.hj)(e,p,X):void 0:o,W=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:x,isThreadTop:B,replyMessage:A,replyMessageSender:L,isInDocumentGroup:V,isProtected:(0,r.EV)(e,o),isFocused:U,isForwarding:j,reactionMessage:K,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:W,localEffect:W&&(0,l.YC)(p)?(0,r.cu)(W):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:K&&e.activeReactions[K.id],activeEmojiInteractions:e.activeEmojiInteractions,...y&&{outgoingStatus:(0,r.dT)(e,o,"scheduled"===m)},..."number"==typeof O&&{uploadProgress:O},...U&&{focusDirection:F,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:x,uploadProgress:A,isInDocumentGroup:L,isProtected:O,isFocused:U,focusDirection:F,noFocusHighlight:$,isResizingContainer:D,isForwarding:j,isChatWithSelf:Q,isRepliesChat:q,isChannel:G,canReply:H,lastSyncTime:_,highlight:z,animatedEmoji:V,localSticker:X,localEffect:K,animatedEmojiEffect:W,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:he,autoLoadFileMaxSizeMb:ge,threadInfo:pe}=e;const{toggleMessageSelection:ve,clickInlineButton:Ie,disableContextMenuHint:ye}=(0,a.uC)(),Pe=(0,o.sO)(null),Ce=(0,o.sO)(null),we=(0,o.sO)(null),be=(0,$e.Z)();(0,Pn._N)(Ce,s);const{isContextMenuOpen:Ee,contextMenuPosition:Me,handleBeforeContextMenu:Se,handleContextMenu:Re,handleContextMenuClose:ke,handleContextMenuHide:Te}=(0,bn.Z)(Pe,h.$b&&J,!0,h.wZ);(0,o.d4)((()=>{Ee&&ye()}),[Ee,ye]);const Ne=I<=0,[Be,xe]=(0,Ue.Z)(Ne);(0,o.d4)((()=>{Ne||setTimeout(xe,10*I)}),[I,xe,Ne]);const{transitionClassNames:Ae}=(0,Ze.Z)(Be,void 0,Ne,!1),{id:Le,chatId:Oe,forwardInfo:Fe,viaBotId:De}=t,je=(0,l.CI)(t),Qe=(0,l.B4)(t),qe="scheduled"===ce||t.isScheduled,Ge=(0,l.ss)(t)&&!T,He=Boolean(pe)&&"thread"===ce,_e=(0,l.$D)(t),Ve=X||V,Xe=(null==ae?void 0:ae.reactions)&&!(0,l.JE)(ae.reactions),Ke=Fe&&(!Q||qe)&&!q&&!Fe.isLinkedChannelPost&&!_e,We=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||Fe&&(Fe.isChannelPost||Q&&!Qe||q)&&Fe.fromMessageId),st=pe&&!Je&&"thread"===ce&&!v,ot=!h.$b&&!J&&oe&&!Je,it=(0,o.I4)(((e,t)=>{ve({messageId:Le,groupedId:t,...(null==e?void 0:e.shiftKey)&&{withShift:!0},...We&&{childMessageIds:c.messages.map((e=>{let{id:t}=e;return t}))}})}),[ve,Le,We,c]),rt=Fe&&(Q||q||!M)?S:M,ct=Fe?S:M,{handleMouseDown:lt,handleClick:dt,handleContextMenu:ut,handleDoubleClick:mt,handleContentDoubleClick:ht,handleMouseMove:gt,handleSendQuickReaction:pt,handleMouseLeave:ft,isSwiped:vt,isQuickReactionVisible:It,handleDocumentGroupMouseEnter:yt}=Fn(it,Pe,Le,0,Boolean(J),Boolean(H),Boolean(O),Re,Se,Oe,et,we,Qe,Je),{handleAvatarClick:Zt,handleSenderClick:Pt,handleViaBotClick:Ct,handleReplyClick:wt,handleMediaClick:bt,handleAudioPlay:Et,handleAlbumMediaClick:Mt,handleMetaClick:St,handleReadMedia:Rt,handleCancelUpload:kt,handleVoteSend:Tt,handleGroupForward:Bt,handleForward:xt,handleFocus:At,handleFocusForwarded:Lt,handleDocumentGroupSelectAll:Ot}=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,x=(0,o.I4)((()=>{g&&v({id:g.id})}),[g,v]),A=(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]),U=(0,o.I4)((()=>{Z({chatId:s,threadId:i,messageId:S,origin:l?m.bZ.ScheduledInline:m.bZ.Inline})}),[s,i,S,Z,l]),F=(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:x,handleSenderClick:A,handleViaBotClick:L,handleReplyClick:O,handleMediaClick:U,handleAudioPlay:F,handleAlbumMediaClick:$,handleMetaClick:z,handleReadMedia:D,handleCancelUpload:j,handleVoteSend:Q,handleGroupForward:q,handleForward:G,handleFocus:H,handleFocusForwarded:_,handleDocumentGroupSelectAll:z}}(be,it,t,Oe,ne,L,Ke,qe,q,c,rt,ct,R),Ft=(0,fe.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",Ge&&"has-reply",et&&"has-menu-open",U&&!$&&"focused",j&&"is-forwarding",t.isDeleting&&"is-deleting",L&&"is-in-document-group",We&&"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",Ae,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 En(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:Ge,customShape:_e,isLastInGroup:Z,asForwarded:Ke,hasThread:He,forceSenderName:E,hasComments:pe&&(null==pe?void 0:pe.messagesCount)>0,hasActionButton:nt||at,hasReactions:Xe}),Dt=$t.includes("has-appendix"),jt=(0,qt.X)(t,z,En(_e)),{text:Qt,photo:Gt,video:Ht,audio:_t,voice:zt,document:Vt,sticker:Xt,contact:Kt,poll:Wt,webPage:Yt,invoice:Jt}=(0,l.qp)(t);let en,tn;en=Je?"none":!jt||Ve||Yt?"standalone":"in-text",f?tn="in-meta":Xe?_e||(Gt||Ht||Ve)&&!jt?tn="outside":Ke?(en="standalone",tn="inside"):tn="inside":tn="none",(0,Nt.Z)(q&&t.replyToChatId?t.replyToChatId:Oe,Ge?t.replyToMessageId:void 0,N,t.id),An(Pe,Oe,U,F,$,D);let nn,sn="",on=!1;const rn=(0,o.Ye)((()=>We?Nn(Qe,Boolean(Ke),Boolean(d),c):void 0),[We,Qe,Ke,d,c]),ln=Ke?28:0;if(We||!Gt&&!Ht)rn&&(nn=Math.max(Mn(Boolean(Qt),st),rn.containerStyle.width),nn-rn.containerStyle.width>18&&(on=!0));else{let e;Gt?e=Sn(t,d).width:Ht&&(e=Ht.isRound?Ut.Rj:Sn(t,d).width),e&&(nn=Math.max(Mn(Boolean(Qt),st),e),nn-e>18&&(on=!0))}nn&&(sn=`width: ${nn+ln}px`);const dn=G&&t.adminTitle||!Ke&&(null==Fe?void 0:Fe.adminTitle)||void 0,un=(0,o.Ye)((()=>dn?xn(dn):void 0),[dn]);function mn(){const e=o.ZP.createElement(Wn,{message:t,reactionMessage:ae,outgoingStatus:x,signature:dn,withReactions:"in-meta"===tn,withReactionOffset:"inside"===tn,availableReactions:se,activeReaction:ie,onClick:St});return"inside"!==tn?e:o.ZP.createElement(Ua,{activeReaction:ie,message:ae,metaChildren:e,availableReactions:se})}return o.ZP.createElement("div",{ref:Pe,id:`message${Le}`,className:Ft,style:un?`--meta-safe-author-width: ${un}px`:void 0,"data-message-id":Le,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":Le,"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,fe.Z)("message-select-control group-select",te&&"is-selected"),onClick:Ot},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&&Fe?Fe.hiddenUserName:void 0;return o.ZP.createElement(cn.Z,{size:"small",user:t,chat:n,text:a,lastSyncTime:_,onClick:t||n?Zt:void 0})}(),o.ZP.createElement("div",{className:(0,fe.Z)("message-content-wrapper",$t.includes("text")&&"can-select-text")},o.ZP.createElement("div",{ref:we,className:$t,style:sn,dir:"auto"},Ke&&!Ye&&o.ZP.createElement("div",{className:"message-title"},be("ForwardedMessage")),function(){const e=(0,fe.Z)("content-inner",Ke&&"forwarded-message",Ge&&"reply-message",on&&"no-media-corners"),n=Z&&!jt&&!Ke&&!He,a=(0,fe.Z)("text-content","in-text"===en&&"with-meta",x&&"with-outgoing-icon");return o.ZP.createElement("div",{className:e,onDoubleClick:ht,dir:"auto"},function(){if(_e&&!De||!(p&&!Gt&&!Ht||Ke||De||E)||Ye||Ge&&_e)return;let e,n;return!ct||_e&&De?null!=Fe&&Fe.hiddenUserName&&(e=Fe.hiddenUserName):(e=(0,l.OU)(be,ct),Ke||(n=`color-${(0,l.Rs)(ct)}`)),o.ZP.createElement("div",{className:"message-title",dir:"ltr"},e?o.ZP.createElement("span",{className:(0,fe.Z)("interactive",n),onClick:Pt,dir:"auto"},(0,an.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,an.Z)(`@${R.username}`))),null!=Fe&&Fe.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)}(),Ge&&o.ZP.createElement(Gn,{message:N,isProtected:O,sender:B,observeIntersection:i,onClick:wt}),Xt&&o.ZP.createElement(ea,{message:t,observeIntersection:i,observeIntersectionForPlaying:r,shouldLoop:he,lastSyncTime:_}),V&&o.ZP.createElement(ta.Z,{size:"small",isOwn:Qe,sticker:V,effect:W,soundId:Y,observeIntersection:i,lastSyncTime:_,forceLoadPreview:je,messageId:Le,chatId:Oe,activeEmojiInteractions:re}),X&&o.ZP.createElement(Da,{size:"small",isOwn:Qe,localSticker:X,localEffect:K,soundId:Y,observeIntersection:i,lastSyncTime:_,forceLoadPreview:je,messageId:Le,chatId:Oe,activeEmojiInteractions:re}),We&&o.ZP.createElement(Ta,{album:c,albumLayout:rn,observeIntersection:i,isOwn:Qe,isProtected:O,hasCustomAppendix:n,lastSyncTime:_,onMediaClick:Mt}),!We&&Gt&&o.ZP.createElement(ra,{message:t,observeIntersection:i,noAvatars:d,canAutoLoad:ue,uploadProgress:A,shouldAffectAppendix:n,onClick:bt,onCancelUpload:kt,isDownloading:de,isProtected:O,theme:b}),!We&&Ht&&Ht.isRound&&o.ZP.createElement(xa,{message:t,observeIntersection:i,canAutoLoad:ue,lastSyncTime:_,isDownloading:de}),!We&&Ht&&!Ht.isRound&&o.ZP.createElement(ma,{message:t,observeIntersection:i,noAvatars:d,canAutoLoad:ue,canAutoPlay:me,uploadProgress:A,lastSyncTime:_,onClick:bt,onCancelUpload:kt,isDownloading:de,isProtected:O}),(_t||zt)&&o.ZP.createElement(_n.Z,{theme:b,message:t,origin:m.Cr.Inline,uploadProgress:A,lastSyncTime:_,isSelectable:L,isSelected:ee,onPlay:Et,onReadMedia:!zt||Qe&&!Q?void 0:Rt,onCancelUpload:kt,isDownloading:de}),Vt&&o.ZP.createElement(Hn.Z,{message:t,observeIntersection:i,canAutoLoad:ue,autoLoadFileMaxSizeMb:ge,uploadProgress:A,isSelectable:L,isSelected:ee,onMediaClick:bt,onCancelUpload:kt,isDownloading:de}),Kt&&o.ZP.createElement(ga,{contact:Kt}),Wt&&o.ZP.createElement(Pa,{message:t,poll:Wt,onSendVote:Tt}),!Ve&&jt&&o.ZP.createElement("p",{className:a,dir:"auto"},jt,"in-text"===en&&mn()),Yt&&o.ZP.createElement(ba,{message:t,observeIntersection:i,noAvatars:d,canAutoLoad:ue,canAutoPlay:me,lastSyncTime:_,onMediaClick:bt,onCancelMediaTransfer:kt,isDownloading:de,isProtected:O,theme:b}),Jt&&o.ZP.createElement(Ma,{message:t}))}(),!Je&&"standalone"===en&&mn(),tt&&nt?o.ZP.createElement(ze.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:be("lng_context_forward_msg"),onClick:C?Bt:xt},o.ZP.createElement("i",{className:"icon-share-filled"})):tt&&at?o.ZP.createElement(ze.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:le?At:Lt},o.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,st&&o.ZP.createElement(La,{threadInfo:pe,disabled:v}),Dt&&o.ZP.createElement("div",{className:"svg-appendix",dangerouslySetInnerHTML:Qe?ja:Qa}),ot&&o.ZP.createElement("div",{className:(0,fe.Z)("quick-reaction",It&&!ie&&"visible"),onClick:pt},o.ZP.createElement(Vn.Z,{reaction:oe}))),t.inlineButtons&&o.ZP.createElement(Aa,{message:t,onClick:Ie}),"outside"===tn&&o.ZP.createElement(Ua,{message:ae,isOutside:!0,activeReaction:ie,availableReactions:se})),Me&&o.ZP.createElement(Qn,{isOpen:Ee,anchor:Me,message:t,album:c,chatUsername:n,messageListType:ce,onClose:ke,onCloseAnimationEnd:Te}))}))),Ga=(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,$e.Z)(),p=(0,o.sO)(null),f=Boolean(n),{observe:v}=(0,Pn.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,an.Z)((0,l.Js)(i)||""),r&&(0,an.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,pa.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(ze.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")))))}))),Ha=(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:w,isScrollPatchNeededRef:b,threadTopMessageId:E,hasLinkedChat:S,isSchedule:R,noAppearanceAnimation:k,onFabToggle:T,onNotchToggle:N}=e;const{openHistoryCalendar:B}=(0,a.uC)(),{observeIntersectionForMedia:x,observeIntersectionForReading:A,observeIntersectionForAnimatedStickers:O}=function(e,t,n){const{markMessageListRead:s,markMessagesRead:o}=(0,a.uC)(),{observe:i}=(0,Pn.S1)({rootRef:t,throttleMs:Cn,margin:wn}),{observe:r,freeze:c,unfreeze:l}=(0,Pn.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,Pe.Z)(c,l);const{observe:d}=(0,Pn.S1)({rootRef:t,throttleMs:Cn});return{observeIntersectionForMedia:i,observeIntersectionForReading:r,observeIntersectionForAnimatedStickers:d}}(P,f,y),{backwardsTriggerRef:U,forwardsTriggerRef:F,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,M.Ds)((()=>p({direction:m.Uq.Backwards})),1e3,!0,!1),(0,M.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,Pn.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,Pn._N)(I,C),(0,Pn._N)(y,C);const{observe:w,freeze:b,unfreeze:E}=(0,Pn.S1)({rootRef:t,margin:100},P);(0,Pn._N)(Z,w);const{observe:S,freeze:R,unfreeze:k}=(0,Pn.S1)({rootRef:t,margin:1},P);return(0,Pn._N)(Z,S),(0,we.Z)((()=>{d&&P()}),[d]),(0,we.Z)((()=>{b(),R(),setTimeout((()=>{k(),E()}),250)}),[n]),{backwardsTriggerRef:I,forwardsTriggerRef:y,fabTriggerRef:Z}}(P,f,n,r,c,T,N,C,w,b),D=(0,$e.Z)(),j=o.ZP.createElement("div",{className:(0,fe.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&&!hn(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(qn,{key:i.id,message:i,observeIntersection:A,appearanceOrder:Q-++q,isLastInList:r})])}let i;return(0,g.xH)(e.map(((r,c)=>{const m=hn(r)?r.mainMessage:r,h=hn(r)?r:void 0,f=(0,l.B4)(m),y=hn(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&&!hn(C)?C.groupedId:void 0,M={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(qa,{key:k,message:m,observeIntersectionForBottom:A,observeIntersectionForMedia:x,observeIntersectionForAnimatedStickers:O,album:h,noAvatars:p,withAvatar:M.isLastInGroup&&d&&!f&&!(m.id===E),withSenderName:M.isFirstInGroup&&d&&!f,areReactionsInMeta:u,threadId:Z,messageListType:P,noComments:!1===S,appearanceOrder:Q-++q,isFirstInGroup:M.isFirstInGroup,isLastInGroup:M.isLastInGroup,isFirstInDocumentGroup:M.isFirstInDocumentGroup,isLastInDocumentGroup:M.isLastInDocumentGroup,isLastInList:M.isLastInList}),m.id===E&&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:pn.q,teactFastList:!0},o.ZP.createElement("div",{className:(0,fe.Z)("sticky-date",!R&&"interactive"),key:"date-header",onMouseDown:pn.q,onClick:R?void 0:()=>B({selectedAt:e.datetime})},o.ZP.createElement("span",{dir:"auto"},R&&e.originalDate===s.t4&&D("MessageScheduledUntilOnline"),R&&e.originalDate!==s.t4&&D("MessageScheduledOn",(0,L.j1)(D,e.datetime,void 0,!0)),!R&&(0,L.j1)(D,e.datetime))),(0,g.xH)(a))}));return o.ZP.createElement("div",{className:"messages-container",teactFastList:!0},o.ZP.createElement("div",{ref:U,key:"backwards-trigger",className:"backwards-trigger"}),(0,g.xH)(G),r&&o.ZP.createElement(Ga,{key:t,chatId:t,containerRef:f}),o.ZP.createElement("div",{ref:F,key:"forwards-trigger",className:"forwards-trigger"}),o.ZP.createElement("div",{ref:$,key:"fab-trigger",className:"fab-trigger"}))}));var _a=n(3547);const za=(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,$e.Z)(),d=(0,o.sO)(null),{observe:u}=(0,Pn.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(_a.Z,{sticker:t,onClick:m,clickArg:t,observeIntersection:u,size:160,className:"large"}))))}))),Va=(0,o.X$)((e=>{let{isChatWithSelf:t,type:n,isGroupChatJustCreated:a}=e;const s=(0,$e.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")))})),Xa=(0,M.Ds)((e=>e()),200,!1),Ka=(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:p,threadId:f,type:v,hasTools:I,onFabToggle:y,onNotchToggle:Z,isChatLoaded:P,isChannelChat:C,isGroupChat:w,canPost:b,isReady:E,isChatWithSelf:S,isRepliesChat:R,isCreator:k,isBot:T,messageIds:N,messagesById:B,firstUnreadId:x,isViewportNewest:A,threadFirstMessageId:L,isRestricted:O,restrictionReason:U,focusingId:F,isSelectModeActive:$,lastMessage:D,botDescription:j,threadTopMessageId:Q,hasLinkedChat:q,lastSyncTime:G,withBottomShift:H}=e;const{loadViewportMessages:_,setScrollOffset:z,loadSponsoredMessages:V,loadMessageReactions:X,copyMessagesByIds:K}=(0,a.uC)(),W=(0,o.sO)(null),Y=(0,o.sO)("thread"===v&&(0,r.Vt)((0,a.Rd)(),p,f)||0),J=(0,o.sO)(),ee=(0,o.sO)(),te=(0,o.sO)(),ne=(0,o.sO)(),ae=(0,o.sO)(),se=(0,o.sO)(),oe=(0,o.sO)(!1),ie=(0,o.sO)(Boolean(D)),[re,ce]=(0,o.eJ)(),le=Boolean(N);(0,we.Z)((()=>{le&&(0,M.R3)((()=>{ie.current=!1}))}),[le]),(0,we.Z)((()=>{ne.current=x}),[x]),(0,we.Z)((()=>{C&&E&&G&&V({chatId:p})}),[p,E,C,G]),(0,we.Z)((()=>{le&&(ae.current=ne.current)}),[le]),(0,we.Z)((()=>{se.current=F}),[F]),(e=>{(0,o.d4)((()=>{function t(t){if((h.jm&&t.metaKey||!h.jm&&t.ctrlKey)&&"c"===(0,Le.Z)(t)){const n=(0,Zn.Z)();n&&n.length>0&&(t.preventDefault(),e({messageIds:n}))}}return document.addEventListener("keydown",t,!1),()=>{document.removeEventListener("keydown",t,!1)}}),[e])})(K);const de=(0,o.Ye)((()=>{if(!N||!B)return;const e=!Q||N[0]&&L!==N[0]?N:[Q,...N];if(!e.length)return;const t=e.map((e=>B[e])).filter(Boolean);return gn((0,g.Xo)(t,["date","id"]),ae.current)}),[N,B,L,Q]);(0,yn.Z)((()=>{if(!N||!B)return;const e=N.filter((e=>{var t;return null===(t=B[e])||void 0===t?void 0:t.reactions}));e.length&&X({chatId:p,ids:e})}),15e3);const ue=(0,o.Ye)((()=>{if("thread"===v)return(0,M.Ds)((()=>_({direction:m.Uq.Around})),1e3,!0,!1)}),[_,N]),{isScrolled:me,updateStickyDates:he}=function(){const[e,t]=(0,Ue.Z)(!1),n=(0,fn.Z)(1e3,!0);return{isScrolled:e,updateStickyDates:(0,o.I4)(((e,a)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,M.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),n((()=>{(0,M.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)(),ve=(0,o.sO)(),Ie=(0,o.I4)((()=>{if(oe.current)return void(oe.current=!1);ge.current=!0;const e=W.current;se.current||he(e,I),Xa((()=>{ge.current=!1,(0,M.T2)((()=>{e.parentElement&&(Y.current=e.scrollHeight-e.scrollTop,"thread"===v&&z({chatId:p,threadId:f,scrollOffset:Y.current}))}))}))}),[he,I,v,z,p,f]);(0,o.d4)((()=>{if(!("ResizeObserver"in window))return;const e=new ResizeObserver((e=>{let[t]=e;t.target.offsetParent&&ce(t.contentRect.height)}));return e.observe(W.current),()=>{e.disconnect()}}),[]);const{height:ye}=Mt();(0,o.d4)((()=>{W.current.dataset.normalHeight=String(W.current.offsetHeight)}),[ye,b]),(0,o.d4)((()=>{if(!ue||!P||O||F)return;if(N&&N[N.length-1]>=s.AE)return;const e=W.current;(!N||N.length<s.hT/2&&e.firstElementChild.clientHeight<=e.offsetHeight)&&ue()}),[P,N,ue,F,O]),(0,we.Z)((()=>{if(!N||!te.current)return;const e=te.current.filter((e=>N.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(J.current=t.id,ee.current=t.getBoundingClientRect().top)}),[N,A,re,I]),(0,un.Z)((e=>{let[t,n,a]=e;const o=W.current;te.current=Array.from(o.querySelectorAll(".message-list-item"));const i=N&&t&&N[N.length-1]!==t[t.length-1],r=(null==N?void 0:N[0])!==(null==t?void 0:t[0])&&(null==N?void 0:N.length)===s.hT/2+1,c=i&&!r,l=N&&se.current===N[N.length-1],d=A&&c&&N&&N.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=Y.current,p=te.current[te.current.length-1];let f=g-(a||h);c&&(f-=p?p.offsetHeight:0);const v=A&&n&&f<=20;let y;if(c&&v&&!l&&(p&&(0,M.T2)((()=>{(0,In.Z)(o,p,"end",20)})),y=m-h,Y.current=Math.max(Math.ceil(m-y),h),!d))return;const Z=void 0!==a&&a!==re,P=J.current&&o.querySelector(`#${J.current}`),C=!P&&ae.current&&o.querySelector(".unread-divider");if(v&&Z){if((0,In.N)())return;y=m-h}else P?(ve.current&&(ve.current=!1,(0,vn.z)(o)),y=u+(P.getBoundingClientRect().top-(ee.current||0))):y=C?Math.min(C.offsetTop-(I?60:10),m-g):m-g;(0,vn.Z)(o,Math.ceil(y)),se.current||(oe.current=!0,(0,M.T2)((()=>{oe.current=!1}))),Y.current=Math.max(Math.ceil(m-y),h)}),[N,A,re,I]),(0,mn.Z)((e=>{let[t]=e;void 0!==t&&(0,pe.YW)(200+s.fK)}),[$]);const Ze=(0,$e.Z)(),Pe=Boolean(p&&(0,l.YC)(p)),Ce=Boolean(!Pe&&!C||S||R),be=Boolean(!Ce||C),Ee=(0,l.YC)(p)&&!S&&!T&&(!de&&!D&&N&&(!te.current||0===te.current.length)||1===(null==N?void 0:N.length)&&"contactSignUp"===(null==B||null===(t=B[N[0]])||void 0===t||null===(n=t.content.action)||void 0===n?void 0:n.type)||"contactSignUp"===(null==D||null===(i=D.content)||void 0===i||null===(c=i.action)||void 0===c?void 0:c.type)),Me=w&&k&&1===(null==N?void 0:N.length)&&"chatCreate"===(null==B||null===(d=B[N[0]])||void 0===d||null===(u=d.content.action)||void 0===u?void 0:u.type),Se=(0,fe.Z)("MessageList custom-scroll",be&&"no-avatars",!b&&"no-composer","pinned"===v&&"type-pinned",H&&"with-bottom-shift",$&&"select-mode-active",me&&"scrolled",!E&&"is-animating");return o.ZP.createElement("div",{ref:W,className:Se,onScroll:Ie,onMouseDown:pn.q},O?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,U?U.text:"This is a private "+(C?"channel":"chat"))):j?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,(0,an.Z)(Ze(j),["br","emoji","links"]))):Ee?o.ZP.createElement(za,{userId:p}):!N||de&&!Me?N&&de||D?o.ZP.createElement(Ha,{chatId:p,messageIds:N||[D.id],messageGroups:de||gn([D]),isViewportNewest:Boolean(A),isUnread:Boolean(x),withUsers:Ce,areReactionsInMeta:Pe,noAvatars:be,containerRef:W,anchorIdRef:J,memoUnreadDividerBeforeIdRef:ae,memoFirstUnreadIdRef:ne,threadId:f,type:v,isReady:E,isScrollingRef:ge,isScrollPatchNeededRef:ve,threadTopMessageId:Q,hasLinkedChat:q,isSchedule:!!de&&"scheduled"===v,noAppearanceAnimation:!de||!ie.current,onFabToggle:y,onNotchToggle:Z}):o.ZP.createElement(ct.Z,{color:"white",backgroundColor:"dark"}):o.ZP.createElement(Va,{chatId:p,type:v,isChatWithSelf:S,isGroupChatJustCreated:Me}))}))),Wa=(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,$e.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,In.Z)(e,n,"end",20)}}),[t,s,c]),m=(0,fe.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(ze.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,Te.bi)(i))))})));var Ya=n(5723);const Ja=1280,es=/\.[^/.]+$/;async function ts(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,Et.pt)(o),{width:n,height:s}=t;if(n>Ja||s>Ja||"image/jpeg"!==i){const t=await Kt(o,Ja/Math.max(n,s),"image/jpeg");return URL.revokeObjectURL(o),ts(e,await(0,Et.gm)(t),!0,a)}"image/jpeg"===i&&(e=e.replace(es,".jpg")),c={width:n,height:s}}else l=o;else if(s.wG.has(i)){const{videoWidth:e,videoHeight:t,duration:n}=await(0,Et.jj)(o);c={width:e,height:t,duration:n},l=await(0,Et.ud)(o)}return{blobUrl:o,filename:e,mimeType:i,size:r,quick:c,previewBlobUrl:l,...a}}function ns(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 as=n(6391);let ss;function os(e){ss.focus(),e.focus()}h.cj&&(ss=document.createElement("input"),ss.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(ss));var is=n(4784),rs=n(2400),cs=n(6389),ls=n(971);const ds={encoderPath:new URL(n(8973),n.b).href,reuseWorker:!0},us={type:"audio/ogg"};let ms,hs,gs;async function ps(){return ms||(ms=n.e(161).then(n.t.bind(n,1161,23)),hs=(await ms).default,gs=new hs(ds)),ms}async function fs(e){await async function(){await ps(),await gs.start()}();const t=Date.now();let n;const a=[],s=[];gs.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}}(gs);return{stop:()=>new Promise(((e,i)=>{gs.onstop=()=>{e({blob:new Blob(a,us),duration:Math.round(((n||Date.now())-t)/1e3),waveform:s})},gs.onerror=i;const r=Math.max(0,t+1e3-Date.now());setTimeout((()=>{gs.stop(),o()}),r)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{gs.pause(),n=Date.now(),o()}),e)}}}var vs=n(1262);const Is=["image/png","image/jpeg","image/gif"];let ys,Zs;var Ps=n(3575),Cs=n(9295);function ws(e,t,n){const a=(0,fn.Z)(t,!0),[s,i]=(0,o.eJ)(),[r,c,l]=(0,Ue.Z)();return(0,pe.ZP)(c,l),(0,we.Z)((()=>{r||a((()=>{i(e())}))}),[...n,r]),s}const bs=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,Es=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i,Ms={username:"",query:"",canShowHelp:!1,usernameLowered:""},Ss=document.createElement("div");const Rs=(0,M.P2)((e=>e()),500,!0),ks=/^[\w@]{1,32}\s?/i,Ts=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"DeleteMessageModal",!t);return n?o.ZP.createElement(n,e):void 0}));function Ns(){return Ns=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},Ns.apply(this,arguments)}let Bs,xs=!0;const As=(0,o.X$)((e=>{let{onActivate:t,...n}=e;const a=(0,o.sO)(!1),s=(0,o.I4)((()=>{if(a.current=!0,xs)return xs=!1,void t();Bs&&(clearTimeout(Bs),Bs=void 0),Bs=window.setTimeout((()=>{a.current&&t()}),200)}),[t]),i=(0,o.I4)((()=>{a.current=!1}),[]);return o.ZP.createElement(ze.Z,Ns({},n,{onMouseEnter:h.$b?void 0:s,onMouseLeave:h.$b?void 0:i,onClick:h.$b?t:void 0}))})),Ls=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"CalendarModal",!t);return n?o.ZP.createElement(n,e):void 0})),Os=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"AttachMenu",!t);return n?o.ZP.createElement(n,e):void 0})),Us=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"SymbolMenu",!t);return n?o.ZP.createElement(n,e):void 0})),Fs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"InlineBotTooltip",!t);return n?o.ZP.createElement(n,e):void 0})),$s=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"MentionTooltip",!t);return n?o.ZP.createElement(n,e):void 0})),Ds=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"CustomSendMenu",!t);return n?o.ZP.createElement(n,e):void 0})),js=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"StickerTooltip",!t);return n?o.ZP.createElement(n,e):void 0}));var Qs=n(9830);const qs=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"BotCommandTooltip",!t);return n?o.ZP.createElement(n,e):void 0}));var Gs=n(6503);const Hs=(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,Gs.Z)(t,s),{isKeyboardSingleUse:l}=n||{},[d,u,m]=(0,Ue.Z)(!0),g=()=>{m(),s()};if((0,o.d4)((()=>{u()}),[u,null==n?void 0:n.keyboardButtons]),n&&n.keyboardButtons)return o.ZP.createElement(ut.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,noCompact:!0},o.ZP.createElement("div",{className:"content"},n.keyboardButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(ze.Z,{ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>i({button:e})},e.text))))))))})));var _s=n(3616),zs=n(7891);const Vs=(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,zs.Z)([c],c?300:void 0),{shouldRender:p,transitionClassNames:f}=(0,Ze.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,Ae.Z)(v):void 0),[h,v]);const I=(0,o.I4)((()=>{u({chatId:s.chatId,messageId:s.id})}),[u,s]),y=(0,fe.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(ze.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Cancel replying",onClick:v},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Gn,{className:"inside-input",message:s,sender:i,customText:Z,title:n?"Edit Message":void 0,onClick:I})))}))),Xs=(0,o.X$)((e=>{const{attachments:t}=e,n=(0,rt.Z)(it.gl.Extra,"AttachmentModal",!t.length);return n?o.ZP.createElement(n,e):void 0})),Ks=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"BotCommandMenu",!t);return n?o.ZP.createElement(n,e):void 0})),Ws=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"PollModal",!t);return n?o.ZP.createElement(n,e):void 0})),Ys=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"DropArea",!t);return n?o.ZP.createElement(n,e):void 0})),Js=new RegExp(s.FM,"i"),eo=(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=ws((()=>{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(Js);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,we.Z)((()=>{m(),h({chatId:t,threadId:n})}),[t]);const p=Boolean(r&&s.length&&!c&&!i),{shouldRender:f,transitionClassNames:I}=(0,Ze.Z)(p),y=(0,Bt.Z)(r,!0);if(!f||!y)return;const{photo:Z,...P}=y,C={content:{webPage:P}};return o.ZP.createElement("div",{className:(0,fe.Z)("WebPagePreview",I)},o.ZP.createElement("div",null,o.ZP.createElement(ze.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(ba,{message:C,inPreview:!0,theme:l})))}))),to=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"SendAsMenu",!t);return n?o.ZP.createElement(n,e):void 0}));var no;!function(e){e.Send="send",e.Record="record",e.Edit="edit",e.Schedule="schedule"}(no||(no={}));const ao="wonderful-voice-message.ogg",so=(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:w,isRightColumnShown:b,isSelectModeActive:E,isForwarding:S,isPollModalOpen:R,botKeyboardMessageId:k,botKeyboardPlaceholder:T,withScheduledButton:N,stickersForEmoji:B,groupChatMembers:x,topInlineBotIds:A,currentUserId:O,lastSyncTime:U,contentToBeScheduled:F,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:W,clearDraft:Y,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,$e.Z)(),he=(0,o.sO)(null),[ge,pe]=(0,o.eJ)(""),ve=(0,ls.Y)(ge),Ie=(0,o.sO)(),ye=(0,Rt.Z)(t),[Ze,be,Ee]=(0,Ue.Z)(),[Me,Se]=(0,o.eJ)(),{width:Re}=J.Z.get(),ke=null==Z?void 0:Z.sendAsIds,Te=ke&&(ke.length>1||!ke.includes(O)),Ne=(0,cs.Z)(g,f);(0,o.d4)((()=>{Ie.current=void 0}),[g]),(0,o.d4)((()=>{g&&U&&f===u._f&&r&&ie({chatId:g})}),[r,g,ie,U,f]),(0,o.d4)((()=>{g&&Z&&U&&!ke&&r&&(0,l.ZV)(Z)&&de({chatId:g})}),[Z,g,r,U,de,ke]),(0,o.d4)((()=>{g&&Z&&U&&!Z.fullInfo&&r&&(0,l.ZV)(Z)&&ue({chatId:g})}),[Z,g,r,U,ue]);const Be=(0,o.sO)(!1);(0,we.Z)((e=>{let[t,n]=e;Be.current=Boolean(g===t&&ke&&!n)}),[g,ke]),(0,o.bt)((()=>{he.current&&(he.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)((()=>{F&&(Se(F),be())}),[F,be]);const[xe,Le]=(0,o.eJ)([]),[Oe,Fe,De]=(0,Ue.Z)(),[je,Qe,qe]=(0,Ue.Z)(),[Ge,He,_e]=(0,Ue.Z)(),[Ve,Xe,Ke]=(0,Ue.Z)(),[We,Je,et]=(0,Ue.Z)(),[tt,nt,at]=(0,Ue.Z)(),[st,ot]=(0,Ue.Z)(),[it,rt,ct]=(0,Ue.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&&ps()}),[]);const r=(0,o.I4)((async()=>{try{const{stop:t,pause:s}=await fs((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,Ae.Z)(l):void 0),[t,l]),{startRecordingVoice:r,pauseRecordingVoice:c,stopRecordingVoice:l,activeVoiceRecording:t,currentRecordTime:s,recordButtonRef:e,startRecordTimeRef:a}})();(0,yn.Z)((()=>{Ne({type:"recordAudio"})}),mt&&s.o_),(0,o.d4)((()=>{mt||Ne({type:"cancel"})}),[mt,Ne]);const ft=m?no.Edit:!h.mh||mt||ge&&!xe.length||S?n?no.Schedule:no.Send:no.Record,vt=!n,{isMentionTooltipOpen:It,closeMentionTooltip:yt,insertMention:Zt,mentionFilteredUsers:Pt}=(0,Cs.Z)(!xe.length,ve,pe,void 0,x,A,O),{isOpen:wt,id:bt,isGallery:Et,switchPm:Mt,results:St,closeTooltip:kt,help:Tt,loadMore:Nt}=function(e,t,n,s){const{queryInlineBot:i,resetInlineBot:r}=(0,a.uC)(),[c,l,d]=(0,Ue.Z)(),{username:u,query:m,canShowHelp:h,usernameLowered:g}=ws((()=>function(e){const t=function(e){return Ss.innerHTML=e.replace(/<br>/g,"\n"),Ss.innerText}(e),n=t.match(bs);return n?{username:n[1],query:n[2],canShowHelp:""===n[2]&&!t.match(Es),usernameLowered:n[1].toLowerCase()}:Ms}(n)),300,[n])||{},p=(0,Rt.Z)(m),f=(0,Rt.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(!xe.length&&U),g,ge,G),{isOpen:Bt,close:xt,filteredBotCommands:At}=function(e,t,n,a){const[s,i,r]=(0,Ue.Z)(),[c,l]=(0,o.eJ)(),d=(0,o.I4)((e=>{n||a?Rs((()=>{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,rs._)(t.substr(1)).match(ks);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),ge,_,z),{isContextMenuOpen:Lt,handleContextMenu:Ot,handleContextMenuClose:Ut,handleContextMenuHide:Ft}=(0,bn.Z)(gt,!(ft===no.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,rs._)(t).trim()),[t]),{loadStickersForEmoji:r,clearStickersForEmoji:c}=(0,a.uC)(),l=h.op&&1===(0,is.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&&!xe.length),ge,B,!r),{isEmojiTooltipOpen:Vt,closeEmojiTooltip:Xt,filteredEmojis:Kt,insertEmoji:Wt}=(0,Ps.Z)(Boolean($&&$t&&!xe.length),ve,q,void 0,pe,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,an.Z)(e,["escape_html","emoji_html","br_html"]).join("").replace(/\u200b+/g,"");if(n.rangeCount){const e=n.getRangeAt(0);if((0,as.R)(e,t))return ns(o),void a.dispatchEvent(new Event("input",{bubbles:!0}))}pe(`${ve.current}${o}`),requestAnimationFrame((()=>{(0,Ya.Z)(a)}))}),[ve]),Jt=(0,o.I4)((()=>{const e=window.getSelection();if(e.rangeCount){const t=e.getRangeAt(0);if((0,as.R)(t,s.R2))return void document.execCommand("delete",!1)}pe(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||pe(""),Le(c.D),zt(),Ee(),Se(void 0),yt(),Xt(),h.wB?setTimeout((()=>Ke()),350):Ke()}),[zt,Ee,yt,Xt,Ke]),tn=(0,o.sO)();tn.current=dt,(0,o.d4)((()=>()=>{tn.current(),en()}),[g,en,tn]);const nn=((e,t,n,i,r)=>{const{editMessage:c}=(0,a.uC)();return(0,o.d4)((()=>{n?(t((0,pa.z)(n.content.text)),requestAnimationFrame((()=>{const e=document.getElementById(s.R2);(0,Ya.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,pe,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,M.Ds)((e=>e()),s.r_,!1)),[t]),g=(0,Rt.Z)(t),p=(0,Rt.Z)(n);(0,o.d4)((()=>(ys=t,Zs=n,()=>{ys=void 0,Zs=void 0,u(t,n)})),[t,n,u]),(0,o.d4)((()=>{t===g&&n===p||e&&(r((0,pa.z)(e)),h.$b||requestAnimationFrame((()=>{const e=document.getElementById(s.R2);(0,Ya.Z)(e,!0)})))}),[t,n,e,r,u,g,p]);const f=i.current,I=(0,Rt.Z)(f);(0,o.d4)((()=>{t&&n&&g===t&&p===n&&I!==f&&(f.length?m((()=>{ys===t&&Zs===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,Pe.Z)(y),Ce(y)})(y,g,f,ve,pe,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,vs.Z)(r)),0!==c.length||i){if(c.length>0&&!n){const e=await Promise.all(c.map((e=>ts(e.name,e,1===c.length&&Is.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,Le,m);const sn=(0,o.I4)((async(e,t)=>{Le(await Promise.all(e.map((e=>ts(e.name,e,t)))))}),[]),on=(0,o.I4)((async(e,t)=>{Le([...xe,...await Promise.all(e.map((e=>ts(e.name,e,t))))])}),[xe]),rn=(0,o.I4)((()=>{Le(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=xe;if(mt){const e=await dt();if(e){const{blob:t,duration:a,waveform:s}=e;n=[await ts(ao,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=Ie.current&&Math.floor(e-Ie.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,L.k9)(a)),isSlowMode:!0,hasErrorKey:!1}}),void r.blur()}}W({text:a,entities:o,attachments:n,scheduledAt:t,isSilent:e})}S&&ae({scheduledAt:t,isSilent:e}),Ie.current=(0,p.b)(Q),Y({chatId:g,localOnly:!0}),h.cj&&r===document.activeElement&&os(r),requestAnimationFrame((()=>{en()}))}),[P,xe,mt,S,Y,g,Q,en,dt,ee,Ht,Gt,W,ae,me,ve]),dn=(0,o.I4)((()=>{Ke(),Qe()}),[Ke,Qe]),un=(0,o.I4)((()=>{qe(),et(),Xe()}),[qe,et,Xe]),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()):(W({sticker:e}),requestAnimationFrame((()=>{en(t)})))}),[n,be,W,en]),hn=(0,o.I4)((e=>{n?(Se({gif:e}),be()):(W({gif:e}),requestAnimationFrame((()=>{en(!0)})))}),[n,be,W,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&&os(t),Y({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{en()}))}),[g,Y,P,en,le]),pn=(0,o.I4)((()=>{Y({chatId:g,localOnly:!0}),requestAnimationFrame((()=>{en()}))}),[g,Y,en]),fn=(0,o.I4)((e=>{n?(Se({poll:e}),oe(),be()):(W({poll:e}),oe())}),[oe,be,W,n]),vn=(0,o.I4)((()=>{n?(Se({isSilent:!0}),be()):ln(!0)}),[ln,be,n]),In=(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?(W({...Me,scheduledAt:s}),requestAnimationFrame((()=>{en()}))):ln(Boolean(n),s),Ee()}),[Ee,ln,en,Me,W,Q]),Zn=(0,o.I4)((()=>{In(new Date(1e3*s.t4),!0)}),[In]),Pn=(0,o.I4)((()=>{Ee(),Se(void 0)}),[Ee]),Cn=(0,o.I4)((e=>{"stickers"===e?(te({query:""}),ne({query:void 0})):(ne({query:""}),te({query:void 0}))}),[te,ne]),wn=(0,o.I4)((()=>{const e=document.getElementById(s.R2);h.wB&&e===document.activeElement?(e.blur(),setTimeout((()=>{qe(),Xe()}),100)):Xe()}),[Xe,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)((()=>{b&&h.wB&&Ke()}),[b,Ke]),(0,o.d4)((()=>{r&&(E?rt():setTimeout((()=>{ct()}),200))}),[E,ct,rt,r]);const Sn=(0,o.I4)((()=>{switch(ft){case no.Send:ln();break;case no.Record:lt();break;case no.Edit:nn();break;case no.Schedule:mt&&ut(),be()}}),[ft,ln,lt,nn,mt,be,ut]),Rn=ft===no.Record&&!jt,kn=(0,Rt.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 xn="SendMessage";switch(ft){case no.Edit:xn="Save edited message";break;case no.Record:xn=Rn?"Conversation.DefaultRestrictedMedia":"AccDescrVoiceMessage"}const An=(0,fe.Z)("Composer",!E&&"shown",it&&"hover-disabled"),Ln=(0,fe.Z)("mobile-symbol-menu-button",!r&&"not-ready",st?Ve&&"menu-opened":Ve&&"is-loading"),On=ft===no.Edit?nn:ft===no.Schedule?be:ln;return o.ZP.createElement("div",{className:An},jt&&r&&o.ZP.createElement(Ys,{isOpen:t!==Ct.t.None,withQuick:t===Ct.t.QuickFile||ye===Ct.t.QuickFile,onHide:d,onFileSelect:sn}),o.ZP.createElement(Xs,{chatId:g,threadId:f,attachments:xe,caption:xe.length?ge:"",groupChatMembers:x,currentUserId:O,recentEmojis:q,isReady:r,onCaptionUpdate:pe,baseEmojiKeywords:D,emojiKeywords:j,addRecentEmoji:ce,onSend:n?be:ln,onFileAppend:on,onClear:rn}),o.ZP.createElement(Ws,{isOpen:Boolean(R),onClear:oe,onSend:fn}),Tn&&o.ZP.createElement(Ts,{isOpen:tt,isSchedule:"scheduled"===I,onClose:at,message:Tn}),o.ZP.createElement(to,{isOpen:We,onClose:et,chatId:g,selectedSendAsId:K,sendAsIds:ke}),o.ZP.createElement($s,{isOpen:It,onClose:yt,onInsertUserName:Zt,filteredUsers:Pt}),o.ZP.createElement(Fs,{isOpen:wt,botId:bt,isGallery:Et,inlineBotResults:St,switchPm:Mt,onSelectResult:gn,loadMore:Nt,onClose:kt}),o.ZP.createElement(qs,{isOpen:Bt,withUsername:Boolean(z),botCommands:At,onClick:pn,onClose:xt}),o.ZP.createElement("div",{id:"message-compose"},o.ZP.createElement("div",{className:"svg-appendix",ref:he}),o.ZP.createElement(Vs,null),o.ZP.createElement(eo,{chatId:g,threadId:f,messageText:xe.length?"":ge,disabled:!qt}),o.ZP.createElement("div",{className:"message-input-wrapper"},C&&!1!==_&&!mt&&!m&&o.ZP.createElement(As,{className:(0,fe.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(ze.Z,{round:!0,color:"translucent",onClick:We?et:En,ariaLabel:me("SendMessageAsTitle"),className:(0,fe.Z)("send-as-button",Be.current&&"appear-animation")},o.ZP.createElement(cn.Z,{user:V,chat:X,size:"tiny"})),h.wB?o.ZP.createElement(ze.Z,{className:Ln,round:!0,color:"translucent",onClick:Ve?Ke:wn,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(Ye.Z,{color:"gray"})):o.ZP.createElement(As,{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(_s.Z,{id:"message-input-text",chatId:g,threadId:f,html:xe.length?"":ge,placeholder:mt&&Re<=600?"":T||me("Message"),forcedPlaceholder:Tt,canAutoFocus:r&&!xe.length,shouldSuppressFocus:h.wB&&Ve,shouldSuppressTextFormatter:Vt||It||wt,onUpdate:pe,onSend:On,onSuppressedFocus:Ke}),H&&Boolean(bt)&&o.ZP.createElement(Ye.Z,{color:"gray"}),N&&o.ZP.createElement(ze.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(As,{className:Oe?"activated":"",round:!0,color:"translucent",onActivate:Fe,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-command"})),!mt&&!m&&o.ZP.createElement(As,{className:Ge?"activated":"",round:!0,color:"translucent",onActivate:He,ariaLabel:"Add an attachment"},o.ZP.createElement("i",{className:"icon-attach"})),mt&&ht&&o.ZP.createElement("span",{className:"recording-state"},(0,L.rM)(ht-pt.current)),o.ZP.createElement(js,{chatId:g,threadId:f,isOpen:_t,onStickerSelect:mn}),o.ZP.createElement(Qs.Z,{isOpen:Vt,emojis:Kt,onClose:Xt,onEmojiSelect:Wt,addRecentEmoji:ce}),o.ZP.createElement(Os,{isOpen:Ge,canAttachMedia:jt,canAttachPolls:Qt,onFileSelect:sn,onPollCreate:se,onClose:_e}),k&&o.ZP.createElement(Hs,{messageId:k,isOpen:Oe,onClose:De}),_&&o.ZP.createElement(Ks,{isOpen:je,botCommands:_,onClose:qe}),o.ZP.createElement(Us,{chatId:g,threadId:f,isOpen:Ve,canSendGifs:Dt,canSendStickers:$t,onLoad:ot,onClose:Ke,onEmojiSelect:Yt,onStickerSelect:mn,onGifSelect:hn,onRemoveSymbol:Jt,onSearchOpen:Cn,addRecentEmoji:ce}))),mt&&o.ZP.createElement(ze.Z,{round:!0,color:"danger",className:"cancel",onClick:dt,ariaLabel:"Cancel voice recording"},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(ze.Z,{ref:gt,round:!0,color:"secondary",className:(0,fe.Z)(ft,!r&&"not-ready",mt&&"recording"),disabled:Rn,ariaLabel:me(xn),onClick:Sn,onContextMenu:ft===no.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(Ds,{isOpen:Lt,onSilentSend:w?void 0:vn,onScheduleSend:n?void 0:be,onClose:Ut,onCloseAnimationEnd:Ft}),o.ZP.createElement(Ls,{isOpen:Ze,withTimePicker:!0,selectedAt:Nn.getTime(),maxAt:(0,L._F)(Bn),isFutureMode:!0,secondButtonLabel:i?me("Schedule.SendWhenOnline"):void 0,onClose:Pn,onSubmit:In,onSecondButtonClick:i?Zn:void 0}))}))),oo=(0,o.X$)((e=>{const{isActive:t}=e,n=(0,rt.Z)(it.gl.Extra,"MobileSearch",!t,!0);return n?o.ZP.createElement(n,e):void 0})),io=(0,o.X$)((e=>{const{isActive:t}=e,n=(0,rt.Z)(it.gl.Extra,"MessageSelectToolbar",!t);return n?o.ZP.createElement(n,e):void 0})),ro=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"UnpinAllMessagesModal",!t);return n?o.ZP.createElement(n,e):void 0})),co=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"PaymentModal",!t);return n?o.ZP.createElement(n,e):void 0})),lo=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"ReceiptModal",!t);return n?o.ZP.createElement(n,e):void 0})),uo=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"SeenByModal",!t);return n?o.ZP.createElement(n,e):void 0})),mo=(0,o.X$)((e=>{const{activeEmojiInteraction:t}=e,n=(0,rt.Z)(it.gl.Extra,"EmojiInteractionAnimation",!t);return n?o.ZP.createElement(n,e):void 0})),ho=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"ReactorListModal",!t);return n?o.ZP.createElement(n,e):void 0})),go=h.wB?450+s.fK:void 0;function po(e){return"file"===e.kind&&e.type&&s.oG.has(e.type)}const fo=(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:x,canSubscribe:A,canStartBot:L,canRestartBot:O,activeEmojiInteractions:U}=e;const{openChat:F,unpinAllMessages:$,loadUser:D,closeLocalTextSearch:j,exitMessageSelectMode:Q,closePaymentModal:q,clearReceipt:G,joinChannel:H,sendBotCommand:_,restartBot:z}=(0,a.uC)(),{width:V}=Mt(),X=(0,$e.Z)(),[J,ee]=(0,o.eJ)(Ct.t.None),[te,ne]=(0,o.eJ)(),[ae,se]=(0,o.eJ)(),[oe,ie]=(0,o.eJ)(!1),re=p&&(V<s.l3||C&&V>s._m&&V<s.QU||V>=s.ks&&V<s.jT),ce=(0,St.Z)(t,go),le=(0,St.Z)(n,go),de=(0,St.Z)(i,go),ue=(0,St.Z)(A,go),me=(0,St.Z)(L,go),he=(0,St.Z)(O,go),ge=(0,St.Z)(u,go)&&!he&&!me&&!ue,pe=(0,St.Z)(re,go),ve=(0,St.Z)(te,go),Ie=(0,St.Z)(x,go),ye=(0,Rt.Z)(B),Ze=void 0!==ye&&ye<B?ye:void 0,{isReady:Pe,handleOpenEnd:Ce,handleSlideStop:be}=function(e,t,n,a){const[s,i]=(0,o.eJ)(!h.wB),r=(0,kt.Z)(),c=void 0!==n&&n!==t;return c&&(e?i(!1):r()),(0,we.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,Ae.Z)((()=>{F({id:void 0})})):void 0),[t,F]),(0,we.Z)((()=>{ee(Ct.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 Ee=(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(po);ee(n?Ct.t.QuickFile:Ct.t.Document)}),[]),Me=(0,o.I4)((()=>{ee(Ct.t.None)}),[]),Se=(0,o.I4)((()=>{ie(!0)}),[]),ke=(0,o.I4)((()=>{ie(!1)}),[]),Te=(0,o.I4)((()=>{$({chatId:t}),ke(),F({id:t})}),[$,F,ke,t]),Ne=(0,o.I4)((()=>{F({id:t})}),[F,t]),Be=(0,o.I4)((()=>{H({chatId:t})}),[H,t]),xe=(0,o.I4)((()=>{_({command:"/start"})}),[_]),Le=(0,o.I4)((()=>{z({chatId:t})}),[t,z]),Oe=((e,t)=>{const[n,a]=(0,o.eJ)(t);return(0,o.d4)((()=>{t&&(t.startsWith("#")?a(t):bt.fetch(s.fo,e,bt.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,Et.pt)(t).then((()=>{a(`url(${t})`)}))})))}),[t,e]),t?n:void 0})(I,v),Ue=(0,fe.Z)(pe&&"has-header-tools",v&&"custom-bg-image",y&&"custom-bg-color",v&&w&&"blurred",h.aZ?"mask-image-disabled":"mask-image-enabled"),De=(0,fe.Z)("messaging-disabled",!E&&"shown"),je=(0,l.q8)(X,m,g),{composerHiddenScale:Qe,toolbarHiddenScale:qe,composerTranslateX:Ge,toolbarTranslateX:He,unpinHiddenScale:_e,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,Y),W),n=Math.min(.25*e,W);return Math.min(e-t-n,K)}if(e>s.ks){const t=Math.min(Math.max(.4*e,Y),W);return Math.min(e-t,K)}return e>K?K: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}}(V,ge)),[ge,V]),Xe=(0,fe.Z)("middle-column-footer",!ge&&"no-composer",ge&&ae&&!E&&"with-notch");(0,Re.ZP)(ce&&le,(()=>{F({id:void 0},{forceSyncOnIOs:!0})}),void 0,void 0,void 0,(null==d?void 0:d.map(wt.q))||[]),(0,Re.ZP)(b,j),(0,Re.ZP)(E,Q);const Ke=Boolean(!c&&!ge&&!he&&!me&&!ue&&je),We=Boolean(he||ue||me||c),Ye=Boolean(Ke||E||c);return o.ZP.createElement("div",{id:"MiddleColumn",className:Ue,onTransitionEnd:Ce,style:`\n --composer-hidden-scale: ${Qe};\n --toolbar-hidden-scale: ${qe};\n --unpin-hidden-scale: ${_e};\n --toolbar-unpin-hidden-scale: ${Ve};\n --composer-translate-x: ${Ge}px;\n --toolbar-translate-x: ${He}px;\n --pattern-color: ${Z};\n --theme-background-color:\n ${y||("dark"===I?s.It:s.p3)};\n `,onClick:h.p7&&P?Ne:void 0},o.ZP.createElement("div",{id:"middle-column-bg",style:Oe?`--custom-background: ${Oe}`: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:ge?Ee:void 0},o.ZP.createElement(dn,{chatId:ce,threadId:le,messageListType:de,isReady:Pe}),o.ZP.createElement(Fe.Z,{name:N?"none":T===s.zy?"slide":"fade",activeKey:B,shouldCleanup:!0,cleanupExceptionKey:Ze,onStop:be},o.ZP.createElement(Ka,{key:`${ce}-${le}-${de}`,chatId:ce,threadId:le,type:de,canPost:ge,hasTools:pe,onFabToggle:ne,onNotchToggle:se,isReady:Pe,withBottomShift:We}),o.ZP.createElement("div",{className:Xe},ge&&o.ZP.createElement(so,{chatId:ce,threadId:le,messageListType:de,dropAreaState:J,onDropHide:Me,isReady:Pe}),c&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:X.isRtl?"rtl":void 0},o.ZP.createElement(ze.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:Se},o.ZP.createElement("i",{className:"icon-unpin"}),o.ZP.createElement("span",null,X("Chat.Pinned.UnpinAll",f,"i")))),Ke&&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:X.isRtl?"rtl":void 0},o.ZP.createElement(ze.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Be},X(Ie?"ProfileJoinChannel":"ProfileJoinGroup"))),h.wB&&me&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:X.isRtl?"rtl":void 0},o.ZP.createElement(ze.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:xe},X("BotStart"))),h.wB&&he&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:X.isRtl?"rtl":void 0},o.ZP.createElement(ze.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Le},X("BotRestart"))),o.ZP.createElement(io,{messageListType:de,isActive:E,canPost:ge}),o.ZP.createElement(co,{isOpen:Boolean(M),onClose:q}),o.ZP.createElement(lo,{isOpen:Boolean(S),onClose:G}),o.ZP.createElement(uo,{isOpen:R}),o.ZP.createElement(ho,{isOpen:k}))),o.ZP.createElement(Wa,{isShown:ve,canPost:ge,withExtraShift:Ye})),h.wB&&o.ZP.createElement(oo,{isActive:Boolean(b)})),t&&o.ZP.createElement(ro,{isOpen:oe,chatId:t,pinnedMessagesCount:f,onClose:ke,onUnpin:Te}),o.ZP.createElement("div",{teactFastList:!0},null==U?void 0:U.map(((e,t)=>o.ZP.createElement(mo,{teactOrderKey:t,key:e.id,activeEmojiInteraction:e})))))}))),vo=(0,M.Ds)((e=>e()),200,!1);var Io;!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.ManageChannelRemovedUsers=12]="ManageChannelRemovedUsers",e[e.ManageGroupUserPermissionsCreate=13]="ManageGroupUserPermissionsCreate",e[e.ManageGroupUserPermissions=14]="ManageGroupUserPermissions",e[e.ManageGroupRecentActions=15]="ManageGroupRecentActions",e[e.ManageGroupAdminRights=16]="ManageGroupAdminRights",e[e.ManageGroupNewAdminRights=17]="ManageGroupNewAdminRights",e[e.ManageGroupMembers=18]="ManageGroupMembers",e[e.ManageGroupAddAdmins=19]="ManageGroupAddAdmins",e[e.StickerSearch=20]="StickerSearch",e[e.GifSearch=21]="GifSearch",e[e.PollResults=22]="PollResults",e[e.AddingMembers=23]="AddingMembers",e[e.ManageInvites=24]="ManageInvites",e[e.ManageEditInvite=25]="ManageEditInvite",e[e.ManageReactions=26]="ManageReactions",e[e.ManageInviteInfo=27]="ManageInviteInfo",e[e.ManageJoinRequests=28]="ManageJoinRequests"}(Io||(Io={}));const yo=(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:B,toggleManagement:x,openHistoryCalendar:A,addContact:O,setEditingExportedInvite:U,deleteExportedChatInvite:F}=(0,a.uC)(),$=(0,o.sO)(null),[D,j,Q]=(0,Ue.Z)(),q=(0,o.I4)((()=>{U({chatId:n,invite:R}),C(m.u1.EditInvite)}),[n,R,C,U]),G=(0,o.I4)((()=>{F({chatId:n,link:R.link}),C(m.u1.Invites),Q()}),[n,Q,R,F,C]),H=(0,o.I4)((e=>{k({query:e}),e.length&&vo(B)}),[B,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,K]=(0,o.eJ)(!s);(0,o.d4)((()=>{setTimeout((()=>{K(!s)}),300)}),[s]);const W=(0,$e.Z)(),Y=i?p===m.vi.Profile?Io.Profile:p===m.vi.SharedMedia?Io.SharedMedia:p===m.vi.MemberList?Io.MemberList:-1:r?Io.Search:u?Io.PollResults:l?Io.StickerSearch:d?Io.GifSearch:g?Io.AddingMembers:c?f===m.u1.Initial?Io.ManageInitial:f===m.u1.ChatPrivacyType?Io.ManageChatPrivacyType:f===m.u1.Discussion?Io.ManageDiscussion:f===m.u1.ChannelSubscribers?Io.ManageChannelSubscribers:f===m.u1.GroupPermissions?Io.ManageGroupPermissions:f===m.u1.ChatAdministrators?Io.ManageChatAdministrators:f===m.u1.GroupRemovedUsers?Io.ManageGroupRemovedUsers:f===m.u1.ChannelRemovedUsers?Io.ManageChannelRemovedUsers:f===m.u1.GroupUserPermissionsCreate?Io.ManageGroupUserPermissionsCreate:f===m.u1.GroupUserPermissions?Io.ManageGroupUserPermissions:f===m.u1.GroupRecentActions?Io.ManageGroupRecentActions:f===m.u1.ChatAdminRights?Io.ManageGroupAdminRights:f===m.u1.ChatNewAdminRights?Io.ManageGroupNewAdminRights:f===m.u1.GroupMembers?Io.ManageGroupMembers:f===m.u1.Invites?Io.ManageInvites:f===m.u1.EditInvite?Io.ManageEditInvite:f===m.u1.GroupAddAdmins?Io.ManageGroupAddAdmins:f===m.u1.Reactions?Io.ManageReactions:f===m.u1.InviteInfo?Io.ManageInviteInfo:f===m.u1.JoinRequests?Io.ManageJoinRequests:void 0:void 0,J=null!==(t=(0,Bt.Z)(Y,!0))&&void 0!==t?t:-1,ee=h.wB||Y===Io.SharedMedia||Y===Io.MemberList||Y===Io.AddingMembers||c,te=(0,fe.Z)("animated-close-icon",ee&&"state-back",(X||M)&&"no-transition");return o.ZP.createElement("div",{className:"RightHeader"},o.ZP.createElement(ze.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:P,ariaLabel:W(ee?"Common.Back":"Common.Close")},o.ZP.createElement("div",{ref:$,className:te})),o.ZP.createElement(Fe.Z,{name:X||M?"none":"slide-fade",activeKey:J},function(){if(-1!==J)switch(J){case Io.PollResults:return o.ZP.createElement("h3",null,W("PollResults"));case Io.Search:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Ve.Z,{parentContainerClassName:"RightSearch",value:w,onChange:H}),o.ZP.createElement(ze.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>A({selectedAt:(0,L._F)(Date.now())}),ariaLabel:"Search messages by date"},o.ZP.createElement("i",{className:"icon-calendar"})));case Io.AddingMembers:return o.ZP.createElement("h3",null,W(Z?"ChannelAddSubscribers":"GroupAddMembers"));case Io.ManageInitial:return o.ZP.createElement("h3",null,W("Edit"));case Io.ManageChatPrivacyType:return o.ZP.createElement("h3",null,W(Z?"ChannelTypeHeader":"GroupTypeHeader"));case Io.ManageDiscussion:return o.ZP.createElement("h3",null,W("Discussion"));case Io.ManageChatAdministrators:return o.ZP.createElement("h3",null,W("ChannelAdministrators"));case Io.ManageGroupRecentActions:return o.ZP.createElement("h3",null,W("Group.Info.AdminLog"));case Io.ManageGroupAdminRights:return o.ZP.createElement("h3",null,W("EditAdminRights"));case Io.ManageGroupNewAdminRights:return o.ZP.createElement("h3",null,W("SetAsAdmin"));case Io.ManageGroupPermissions:return o.ZP.createElement("h3",null,W("ChannelPermissions"));case Io.ManageGroupRemovedUsers:return o.ZP.createElement("h3",null,W("BlockedUsers"));case Io.ManageChannelRemovedUsers:return o.ZP.createElement("h3",null,W("ChannelBlockedUsers"));case Io.ManageGroupUserPermissionsCreate:return o.ZP.createElement("h3",null,W("ChannelAddException"));case Io.ManageGroupUserPermissions:return o.ZP.createElement("h3",null,W("UserRestrictions"));case Io.ManageInvites:return o.ZP.createElement("h3",null,W("lng_group_invite_title"));case Io.ManageEditInvite:return o.ZP.createElement("h3",null,W(S?"EditLink":"NewLink"));case Io.ManageInviteInfo:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,W("InviteLink")),o.ZP.createElement("section",{className:"tools"},R&&!R.isRevoked&&o.ZP.createElement(ze.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:W("Edit"),onClick:q},o.ZP.createElement("i",{className:"icon-edit"})),R&&R.isRevoked&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(ze.Z,{round:!0,color:"danger",size:"smaller",ariaLabel:W("Delete"),onClick:j},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(jt.Z,{isOpen:D,onClose:Q,title:W("DeleteLink"),text:W("DeleteLinkHelp"),confirmIsDestructive:!0,confirmLabel:W("Delete"),confirmHandler:G}))));case Io.ManageJoinRequests:return o.ZP.createElement("h3",null,W(Z?"SubscribeRequests":"MemberRequests"));case Io.ManageGroupAddAdmins:return o.ZP.createElement("h3",null,W("Channel.Management.AddModerator"));case Io.StickerSearch:return o.ZP.createElement(Ve.Z,{value:b,placeholder:W("SearchStickersHint"),autoFocusSearch:!0,onChange:_});case Io.GifSearch:return o.ZP.createElement(Ve.Z,{value:E,placeholder:W("SearchGifsTitle"),autoFocusSearch:!0,onChange:z});case Io.SharedMedia:return o.ZP.createElement("h3",null,W("SharedMedia"));case Io.ManageChannelSubscribers:return o.ZP.createElement("h3",null,W("ChannelSubscribers"));case Io.MemberList:case Io.ManageGroupMembers:return o.ZP.createElement("h3",null,W("GroupMembers"));case Io.ManageReactions:return o.ZP.createElement("h3",null,W("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(ze.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:W("AddContact"),onClick:V},o.ZP.createElement("i",{className:"icon-add-user"})),y&&o.ZP.createElement(ze.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:W("Edit"),onClick:x},o.ZP.createElement("i",{className:"icon-edit"}))))}}()))})));var Zo=n(91);var Po=n(7407);function Co(e,t,n,a){const[o,i]=(0,Po.Z)(n?t:void 0,a,void 0,s.Vk);return[o,i,!(!o||!a||o[0]===a[0])]}function wo(e,t,n,a,i,r){const c=(0,o.sO)();(0,we.Z)((()=>{t===e&&i&&r&&(c.current=(0,l.R5)(i,r,e))}),[i,r,t,e]);const[d,u]=(0,Po.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 bo=(0,M.P2)((e=>e()),250,!1);let Eo=!1;var Mo=n(1273),So=n(1876),Ro=n(787),ko=n(180),To=n(3709),No=n(5418),Bo=n(7262),xo=n(1151),Ao=n(2275);const Lo=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"},{type:"voice",title:"SharedVoiceTab2"}];function Oo(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > .Transition__slide--active > .${e}-list > .scroll-item`].join(", ")}const Uo=(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:x}=e;const{setLocalMediaSearchType:A,loadMoreMembers:L,loadCommonChats:O,openChat:U,searchMediaMessagesLocal:F,openMediaViewer:$,openAudioPlayer:D,focusMessage:j,loadProfilePhotos:Q,setNewChatMembersDialogState:q}=(0,a.uC)(),G=(0,o.sO)(null),H=(0,o.sO)(null),_=(0,$e.Z)(),[z,V]=(0,o.eJ)(0),[X,K]=(0,o.eJ)(),W=(0,o.Ye)((()=>[...y?[{type:"members",title:c?"ChannelSubscribers":"GroupMembers"}]:[],...Lo,...I?[{type:"commonChats",title:"SharedGroupsTab2"}]:[]]),[I,y,c]),Y=W[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]=Co(0,t,f,y),[b,E,M]=wo("media",I,a,f,h,g),[S,R,k]=wo("documents",I,a,f,h,g),[T,N,B]=wo("links",I,a,f,h,g),[x,A,L]=wo("audio",I,a,f,h,g),[O,U,F]=wo("voice",I,a,f,h,g),[$,D,j]=Co(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=x,q=A,G=L;break;case"voice":Q=O,q=U,G=F}return[I,Q,q,G]}(R,L,O,F,Y,v,b,w,E,M,S,p,f,t,T,B),ae=W.findIndex((e=>{let{type:t}=e;return t===J})),{handleScroll:se}=function(e,t,n,a){(0,mn.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),Eo=!0,(0,In.Z)(n,s,"start",void 0,void 0,void 0,300),setTimeout((()=>{Eo=!1}),350))}}),[t,a]),(0,mn.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||(Eo=!0,(0,In.Z)(o,o.firstElementChild,"start",void 0,2*o.offsetHeight),setTimeout((()=>{Eo=!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)((()=>{Eo||s()}),[s,t]),{handleScroll:(0,o.I4)((()=>{Eo||bo(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,Pn.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)((()=>{A({mediaType:Y})}),[A,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=>{U({id:e})}),[U]),fe=(0,o.I4)((e=>{j({chatId:me,messageId:e})}),[me,j]),ve=(0,o.I4)((()=>{K(void 0)}),[]);let Ie;(0,o.d4)((()=>{if(H.current&&h.$b)return(0,nt.sf)(H.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===nt.eM.Left?(V(Math.min(z+1,W.length-1)),!0):t===nt.eM.Right&&(V(Math.max(0,z-1)),!0)})}),[z,W.length]);const ye="members"===J||!y&&"media"===J;ye?Ie=R?0:1e3:ee||(Ie=s.Y);const Ze=(0,zs.Z)([t,J],Ie);return o.ZP.createElement(Mo.Z,{ref:G,className:"Profile custom-scroll",itemSelector:Oo(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(Ro.Z,{userId:t||e}),o.ZP.createElement(ko.Z,{chatOrUserId:t||e}))}(t,d),!k&&o.ZP.createElement("div",{className:"shared-media"},o.ZP.createElement(Fe.Z,{ref:H,name:_.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:ae,renderCount:W.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:oe,onStop:de},function(){if(!ee||!Ze||!p){const e=ye&&!Ze;return o.ZP.createElement("div",{className:"content empty-list"},!e&&o.ZP.createElement(Ye.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(Bo.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(To.Z,{key:e,message:p[e],isProtected:x||p[e].isProtected,observeIntersection:le,onClick:he}))):"documents"===J?ee.map((e=>p[e]&&o.ZP.createElement(Hn.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(No.Z,{key:e,message:p[e],isProtected:x||p[e].isProtected,observeIntersection:le,onMessageClick:fe}))):"audio"===J?ee.map((e=>p[e]&&o.ZP.createElement(_n.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(_n.Z,{key:e,theme:r,message:p[e],senderTitle:(0,Zo.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(So.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:()=>{K(n)}}]:void 0)},o.ZP.createElement(xt.Z,{userId:e,forceShowSelf:!0}));var n})):"commonChats"===J?ee.map(((e,t)=>o.ZP.createElement(So.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>U({id:e})},o.ZP.createElement(At.Z,{chatId:e})))):void 0)}()),o.ZP.createElement(at.Z,{big:!0,activeTab:z,tabs:W,onSwitchTab:V})),P&&o.ZP.createElement(xo.Z,{isShown:"members"===J,onClick:ue,ariaLabel:_("lng_channel_add_users")},o.ZP.createElement("i",{className:"icon-add-user-filled"})),C&&o.ZP.createElement(Ao.Z,{isOpen:Boolean(X),userId:X,onClose:ve}))}))),Fo=(0,o.X$)((e=>{const t=(0,rt.Z)(it.gl.Extra,"RightSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(ct.Z,null)})),$o=(0,o.X$)((e=>{const t=(0,rt.Z)(it.gl.Extra,"Management");return t?o.ZP.createElement(t,e):o.ZP.createElement(ct.Z,null)})),Do=(0,o.X$)((()=>{const e=(0,rt.Z)(it.gl.Extra,"StickerSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(ct.Z,null)})),jo=(0,o.X$)((()=>{const e=(0,rt.Z)(it.gl.Extra,"GifSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(ct.Z,null)})),Qo=(0,o.X$)((()=>{const e=(0,rt.Z)(it.gl.Extra,"PollResults");return e?o.ZP.createElement(e,null):o.ZP.createElement(ct.Z,null)}));var qo=n(1820);const Go=(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,$e.Z)(),[C,w]=(0,o.eJ)([]),b=(0,Rt.Z)(C)===C;(0,o.d4)((()=>{I&&"connectionStateReady"===n&&Z()}),[n,I,Z]),(0,Re.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(qo.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(xo.Z,{isShown:Boolean(C.length),disabled:u,ariaLabel:P("lng_channel_add_users"),onClick:R},u?o.ZP.createElement(Ye.Z,{color:"white"}):o.ZP.createElement("i",{className:"icon-arrow-right"}))))}))),Ho=Object.keys(m.qt).length/2,_o=Object.keys(m.u1).length/2;function zo(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const Vo=(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}=Mt(),[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,x=void 0!==n,A=n===m.qt.ChatInfo,L=n===m.qt.Search,O=n===m.qt.Management,U=n===m.qt.StickerSearch,F=n===m.qt.GifSearch,$=n===m.qt.PollResults,D=n===m.qt.AddingMembers,j=w<=s._m,[Q,q]=(0,o.eJ)(!x),G=null!==(t=(0,Bt.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:case m.u1.ChannelRemovedUsers: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:zo(),g();break;case m.qt.StickerSearch:zo(),p({query:void 0});break;case m.qt.GifSearch:zo(),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(Go,{key:i,chatId:i,isActive:x&&e,onNextStep:z,onClose:H});case m.qt.ChatInfo:return o.ZP.createElement(Uo,{key:i,chatId:i,profileState:b,onProfileStateChange:E});case m.qt.Search:return o.ZP.createElement(Fo,{chatId:i,threadId:r,onClose:H,isActive:x&&e});case m.qt.Management:return o.ZP.createElement($o,{key:i,chatId:i,currentScreen:M,isPromotedByCurrentUser:T,selectedChatMemberId:R,isActive:x&&e,onScreenSelect:S,onChatMemberSelect:_,onClose:H});case m.qt.StickerSearch:return o.ZP.createElement(Do,{onClose:H,isActive:x&&e});case m.qt.GifSearch:return o.ZP.createElement(jo,{onClose:H,isActive:x&&e});case m.qt.PollResults:return o.ZP.createElement(Qo,{onClose:H,isActive:x&&e})}}return(0,o.d4)((()=>x?(0,Ae.Z)(H):void 0),[x,H]),(0,o.d4)((()=>{setTimeout((()=>{q(!x)}),300)}),[x]),(0,o.d4)((()=>{d&&(S(d),C(void 0))}),[d,C]),(0,o.d4)((()=>{x&&j&&H()}),[j]),(0,un.Z)((e=>{let[t]=e;t!==i&&(E(m.vi.Profile),S(m.u1.Initial))}),[i]),(0,Re.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(yo,{chatId:i,isColumnOpen:x,isProfile:A,isSearch:L,isManagement:O,isStickerSearch:U,isGifSearch:F,isPollResults:$,isAddingChatMembers:D,profileState:b,managementScreen:M,onClose:H,shouldSkipAnimation:Q||l,onScreenSelect:S}),o.ZP.createElement(Fe.Z,{name:Q||l?"none":"zoom-fade",renderCount:Ho+_o,activeKey:O?Ho+M:G,shouldCleanup:!0},V)))}))),Xo=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,rt.Z)(it.gl.Extra,"MediaViewer",!t);return n?o.ZP.createElement(n,null):void 0}));function Ko(e,t){const n=document.createElement("a");n.href=e,n.download=t;try{n.click()}catch(e){console.error(e)}}const Wo=new Set,Yo=(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(!Wo.has(t)){const n=V.UV(t);if(n)return Wo.delete(t),Ko(n,(0,l.w6)(e)),void s({message:e});V.he(t,u.IU.BlobUrl,!0).then((n=>{Wo.delete(t),n&&Ko(n,(0,l.w6)(e)),s({message:e})})),Wo.add(t)}}else s({message:e})}))}))}),[s,n,t])}))),Jo=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,rt.Z)(it.gl.Extra,"Notifications",!t);return n?o.ZP.createElement(n,null):void 0})),ei=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,rt.Z)(it.gl.Extra,"Dialogs",!t);return n?o.ZP.createElement(n,null):void 0})),ti=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"ForwardPicker",!t);return n?o.ZP.createElement(n,e):void 0})),ni=(0,o.X$)((e=>{const{url:t}=e,n=(0,rt.Z)(it.gl.Extra,"SafeLinkModal",!t);return n?o.ZP.createElement(n,e):void 0})),ai=(0,o.X$)((e=>{const{isOpen:t}=e,n=(0,rt.Z)(it.gl.Extra,"HistoryCalendar",!t);return n?o.ZP.createElement(n,e):void 0})),si=(0,o.X$)((e=>{const{groupCallId:t}=e,n=(0,rt.Z)(it.gl.Calls,"GroupCall",!t);return n?o.ZP.createElement(n,e):void 0})),oi=(0,o.X$)((e=>{const{groupCallId:t}=e,n=(0,rt.Z)(it.gl.Calls,"ActiveCallHeader",!t);return n?o.ZP.createElement(n,null):void 0})),ii=(0,o.X$)((e=>{let{isOpen:t}=e;const n=(0,rt.Z)(it.gl.Calls,"CallFallbackConfirm",!t);return n?o.ZP.createElement(n,{isOpen:t}):void 0}));let ri,ci=!1;function li(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 di(e){document.title!==e&&(document.title=e)}const ui=(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:w,isCallFallbackConfirmOpen:b,addedSetIds:E}=e;const{sync:S,loadAnimatedEmojis:R,loadNotificationSettings:k,loadNotificationExceptions:T,updateIsOnline:N,loadTopInlineBots:B,loadEmojiKeywords:x,loadCountryList:A,loadAvailableReactions:L,loadStickerSets:O,loadAddedStickers:U,loadFavoriteStickers:F,ensureTimeFormat:D,openStickerSetShortName:j,checkVersionNotification:Q,loadAppConfig:q}=(0,a.uC)();s.eM&&!ci&&(ci=!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(),x({language:s.pR}))}),[i,R,x,T,k,B,N,L,q]),(0,o.d4)((()=>{i&&(C!==s.pR&&x({language:C}),A({langCode:C}))}),[C,i,A,x]),(0,o.d4)((()=>{i&&(E?U():(O(),F()))}),[i,E,O,F,U]),(0,o.d4)((()=>{i&&Z&&Q()}),[i,Z,Q]),(0,o.d4)((()=>{i&&!w&&D()}),[i,w,D]),(0,o.d4)((()=>{i&&Re.Oy.startsWith("#?tgaddr=")&&(0,Ie.o)(decodeURIComponent(Re.Oy.substr("#?tgaddr=".length)))}),[i]),(0,o.d4)((()=>{if(p)return J.Z.disableRefresh(),()=>{J.Z.enableRefresh()}}),[p]);const{transitionClassNames:G}=(0,Ze.Z)(!r,void 0,!0,void 0,I),{transitionClassNames:H}=(0,Ze.Z)(c,void 0,!0,void 0,I),_=(0,fe.Z)(G.replace(/([\w-]+)/g,"middle-column-$1"),H.replace(/([\w-]+)/g,"right-column-$1"),I&&"history-animation-disabled");(0,we.Z)((e=>{let[t]=e;if(void 0===t||0===P)return;const n=(0,pe.YW)();(0,ve.L)(document.getElementById("MiddleColumn"),n)}),[r]),(0,we.Z)((e=>{let[t]=e;if(void 0===t||0===P)return;(0,M.T2)((()=>{document.body.classList.add("animating-right-column")}));const n=(0,pe.YW)();(0,ve.L)(document.getElementById("RightColumn"),(()=>{n(),(0,M.T2)((()=>{document.body.classList.remove("animating-right-column")}))}))}),[c]);const z=(0,o.I4)((()=>{N(!1);const e=(0,$.xW)();let t=0;clearInterval(ri),ri=window.setInterval((()=>{if(document.title.includes(s.ou))li(!1);else{if(t%2==0){const t=(0,$.xW)()-e;t>0&&(di(`${t} notification${t>1?"s":""}`),li(!0))}else di(s.Ti),li(!1);t++}}),1e3)}),[N]),V=(0,o.I4)((()=>{N(!0),clearInterval(ri),ri=void 0,document.title.includes(s.ou)||di(s.Ti),li(!1)}),[N]),X=(0,o.I4)((()=>{j({stickerSetShortName:void 0})}),[j]);return(0,Pe.Z)(z,V),Ce(z),function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,o.d4)((()=>{if(h.$b){if(!e)return null==be||be.setAttribute("content",Ee),h.cj&&!h.fl&&document.addEventListener("gesturestart",Se),()=>{null==be||be.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),h.cj&&!h.fl&&document.removeEventListener("gesturestart",Se)};null==be||be.setAttribute("content",Me)}}),[e])}(l),o.ZP.createElement("div",{id:"Main",className:_,onDrop:ye.Z,onDragOver:ye.Z},o.ZP.createElement(Pt,null),o.ZP.createElement(fo,null),o.ZP.createElement(Vo,null),o.ZP.createElement(Xo,{isOpen:l}),o.ZP.createElement(ti,{isOpen:d}),o.ZP.createElement(Jo,{isOpen:u}),o.ZP.createElement(ei,{isOpen:m}),g&&o.ZP.createElement(on,{key:g.id,message:g,noUi:!0}),o.ZP.createElement(ni,{url:f}),o.ZP.createElement(ai,{isOpen:v}),o.ZP.createElement(ke.Z,{isOpen:Boolean(y),onClose:X,stickerSetShortName:y}),p&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(si,{groupCallId:p}),o.ZP.createElement(oi,{groupCallId:p})),o.ZP.createElement(Yo,null),o.ZP.createElement(ii,{isOpen:b}),o.ZP.createElement(xe,{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.35**\n\n👏 **Harder**\n• Admins can now manage removed users list in channels.\n• Copy text feature of multiple messages preserves senders name.\n• Added support for subscription bots such as @donate.\n\n🤩 **Better**\n• Fully redesigned context menu on desktops featuring stunning blur effect.\n• Print or export as PDF chat history with Ctrl + P (⌘ + P on macOS).\n• Various layout improvements.\n\n🚀 **Faster**\n• More performance optimizations.\n"}}]);
//# sourceMappingURL=176.2bd8fc859463a252c8a2.js.map