mirror of
https://github.com/danog/telegram-tt.git
synced 2024-11-27 12:55:11 +01:00
2 lines
266 KiB
JavaScript
2 lines
266 KiB
JavaScript
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[610],{2610:(e,t,n)=>{n.r(t),n.d(t,{Main:()=>wi});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),S=n(9118);const M=new Map,R=(0,S.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 S=(0,r.qC)(y,d,t);if(c&&b&&S&&(S.length&&!(0,g.YE)(b,S)||(y=(0,i.xj)(y,d,t,S),b=(0,r.gb)(y,d,t),y=(0,i.pf)(y,d,t,"outlyingIds",void 0),c=!1)),!l){const e=c?S: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)=>{M.has(s)||(t=s,M.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,S.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&&M.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&&M.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 x=n(5765);const B=(0,S.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,S.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&&B((()=>{!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,x.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&&B((()=>{A(a)}))})),(0,a.Q6)("searchMoreGifs",(e=>{const{query:t,offset:n}=e.gifs.search;"string"==typeof t&&B((()=>{A(t,n)}))})),(0,a.Q6)("loadStickersForEmoji",((e,t,n)=>{const{emoji:s}=n,{hash:o}=e.stickers.forEmoji;B((()=>{!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,S.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,S.Ds)((e=>e()),500,!1,!0),q=(0,S.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"]))})),(0,a.Q6)("reportSpam",((e,t,n)=>{const{userId:a}=n,s=(0,r.dy)(e,a);s&&(0,E.t9)("reportSpam",s)}));const _=(0,S.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,e.currentUserId);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,S.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,S.Gq)(e)),[e])}var we=n(9290);const be=document.querySelector('meta[name="viewport"]'),Ee=(null==be?void 0:be.getAttribute("content"))||"",Se="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover";function Me(e){e.preventDefault()}var Re=n(6590),ke=n(4851),Te=n(2155),Ne=n(5616),xe=n(7358);const Be=(0,o.X$)((e=>{let{isForAppBadge:t}=e;(0,Ne.yi)();const n=(0,$.xW)();if((0,o.d4)((()=>{t&&(0,xe.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:S,areChatsLoaded:M}=e;const{openChat:R,openTipsChat:k,setGlobalSearchDate:T,setSettingOption:N,setGlobalSearchChatId:x}=(0,a.uC)(),B=(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(B,w,b,E,S,!M),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?B("AccDescrOpenMenu2"):"Return to chat list"},o.ZP.createElement("div",{className:(0,fe.Z)("animated-menu-icon",!A&&"state-back",f&&"no-animation")}))}),[A,B,u,f]),q=(0,o.I4)((()=>{g||i("")}),[g,i]),G=(0,o.I4)((()=>{N({isConnectionStatusMinimized:!S})}),[S,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?B("SearchFriends"):B("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},B("SavedMessages")),o.ZP.createElement(_e.Z,{icon:"archive",onClick:d},o.ZP.createElement("span",{className:"menu-item-name"},B("ArchivedChats")),U>0&&o.ZP.createElement("div",{className:"archived-badge"},U)),o.ZP.createElement(_e.Z,{icon:"user",onClick:c},B("Contacts")),o.ZP.createElement(_e.Z,{icon:"settings",onClick:r},B("Settings")),o.ZP.createElement(_e.Z,{icon:"darkmode",onClick:_},o.ZP.createElement("span",{className:"menu-item-name"},B("lng_menu_night_mode")),o.ZP.createElement(Ke.Z,{id:"darkmode",label:B("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"},B("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:B.code})}},B("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:x,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,S]=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()}]}(),M=(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:S},M("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,S]=(0,Oe.ZP)(),[M,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:x,resetResize:B,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:S,onScreenSelect:L,onReset:T,shouldSkipTransition:i});case yt.NewChannel:return o.ZP.createElement(vt,{key:M,isActive:e,isChannel:!0,content:y,onContentChange:Z,onReset:T});case yt.NewGroup:return o.ZP.createElement(vt,{key:M,isActive:e,content:y,onContentChange:Z,onReset:T});default:return o.ZP.createElement(pt,{content:y,searchQuery:t,searchDate:n,contactsFilter:w,foldersDispatch:S,onContentChange:Z,onSearchQuery:N,onScreenSelect:L,onReset:T,shouldSkipTransition:i})}})),o.ZP.createElement("div",{className:"resize-handle",onMouseDown:x,onMouseUp:A,onDoubleClick:B}))})));var Ct=n(2420),wt=n(5780),bt=n(9524),Et=n(1394);const St=()=>{const[e,t]=(0,o.eJ)(J.Z.get());return(0,o.d4)((()=>{const e=(0,S.P2)((()=>{t(J.Z.get())}),250,!1);return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),e};var Mt=n(2678),Rt=n(7204),kt=n(5326),Tt=n(3570),Nt=n(5790),xt=n(8360),Bt=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:S}=(0,a.uC)(),M=(0,o.sO)(null),[R,k]=(0,o.eJ)(!1),[T,N]=(0,o.eJ)(void 0),x=(0,o.I4)((()=>{k(!0);const e=M.current.getBoundingClientRect();N({x:e.right,y:e.bottom})}),[]),B=(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)((()=>{S({screen:m.u1.JoinRequests})}),[S]),$=(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:M,className:R?"active":"",round:!0,ripple:!h.wB,size:"smaller",color:"translucent",disabled:s,ariaLabel:"More actions",onClick:x},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:B,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:S,stop:M,isPlaying:R,requestNextTrack:k,requestPreviousTrack:T,isFirst:N,isLast:x,setVolume:B,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&&S(),v(),(0,Vt.Ay)(),M()}),[v,R,S,M]),$=(0,o.I4)((e=>{m({volume:e/100}),p({isMuted:!1}),B(e/100)}),[p,m,B]),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:S,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:x(),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")))})));var dn=n(4605);const un=(0,o.X$)((0,a.c$)(((e,t)=>{let{userId:n}=t;return{user:(0,r.dy)(e,n)}}))((e=>{let{userId:t,user:n}=e;const{addContact:s,blockContact:i,reportSpam:r,deleteChat:c,toggleChatArchived:d}=(0,a.uC)(),u=(0,$e.Z)(),[m,h,g]=(0,Ue.Z)(),[p,f]=(0,o.eJ)(!0),[v,I]=(0,o.eJ)(!0),{settings:y,accessHash:Z}=n||{},{isAutoArchived:P,canReportSpam:C,canAddContact:w,canBlockContact:b}=y||{},E=(0,o.I4)((()=>{s({userId:t}),P&&d({chatId:t})}),[s,P,d,t]),S=(0,o.I4)((()=>{g(),i({contactId:t,accessHash:Z}),C&&p&&r({userId:t}),v&&c({chatId:t})}),[Z,i,g,c,r,C,v,p,t]);if(y)return o.ZP.createElement("div",{className:"UserReportPanel"},w&&o.ZP.createElement(ze.Z,{isText:!0,ripple:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:E},u("lng_new_contact_add")),b&&o.ZP.createElement(ze.Z,{color:"danger",isText:!0,ripple:!0,fluid:!0,size:"tiny",className:"UserReportPanel--Button",onClick:h},u("lng_new_contact_block")),o.ZP.createElement(jt.Z,{isOpen:m,onClose:g,title:u("BlockUserTitle",(0,l.Vl)(n)),text:u("UserInfo.BlockConfirmationTitle",(0,l.Js)(n)),isButtonsInOneRow:!0,confirmIsDestructive:!0,confirmLabel:u("Block"),confirmHandler:S},C&&o.ZP.createElement(dn.Z,{label:u("DeleteReportSpam"),checked:p,onCheck:f}),o.ZP.createElement(dn.Z,{label:u("DeleteThisChat"),checked:v,onCheck:I})))}))),mn=(0,o.X$)((0,a.c$)(((e,t)=>{var n,a;let{chatId:s,threadId:o,messageListType:i}=t;const{isLeftColumnShown:c,lastSyncTime:d,shouldSkipHistoryAnimations:m}=e,h=(0,r.Z1)(e,s),g=h&&(0,l.zX)(h),p=g?(0,r.dy)(e,g):void 0,{typingStatus:f}=h||{},{chatId:v,messageId:I}=e.audioPlayer,y=v&&I?(0,r.hj)(e,v,I):void 0;let Z;if("pinned"===i){const t=(0,r.KB)(e,s);Z=null==t?void 0:t.length}else if("scheduled"===i){const t=(0,r.qy)(e,s);Z=null==t?void 0:t.length}else if("thread"===i&&o!==u._f){const t=(0,r.tZ)(e,s,o);Z=(null==t?void 0:t.messagesCount)||0}const P={typingStatus:f,isLeftColumnShown:c,isRightColumnShown:(0,r.Jf)(e),isSelectModeActive:(0,r.CA)(e),audioMessage:y,chat:h,messagesCount:Z,shouldShowUserReportPanel:Boolean((null==p||null===(n=p.settings)||void 0===n?void 0:n.canAddContact)||(null==p||null===(a=p.settings)||void 0===a?void 0:a.canBlockContact)),isChatWithSelf:(0,r.FM)(e,s),isChatWithBot:h&&(0,r.xo)(e,h),lastSyncTime:d,shouldSkipHistoryAnimations:m,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1),connectionState:e.connectionState,isSyncing:e.isSyncing},C=(0,r.Zw)(e,s);if("thread"!==i||!C)return P;if(Object.assign(P,{messagesById:C}),o!==u._f){const t=(0,r.qS)(e,s,o),n=t?(0,r.hj)(e,s,t):void 0,a=n?(0,r.cv)(e,n):void 0;return{...P,pinnedMessageIds:t,canUnpin:!1,topMessageSender:a}}const w=(0,r.KB)(e,s);if(null!=w&&w.length){const t=C[w[0]],{canUnpin:n}=t&&(0,r._k)(e,t,o)||{};return{...P,pinnedMessageIds:w,canUnpin:n}}return P}))((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,shouldShowUserReportPanel:E,shouldSkipHistoryAnimations:S,currentTransitionKey:M,connectionState:R,isSyncing:k}=e;const{openChatWithInfo:T,pinMessage:N,focusMessage:x,openChat:B,openPreviousChat:A,loadPinnedMessages:L,toggleLeftColumn:O,exitMessageSelectMode:U}=(0,a.uC)(),F=(0,$e.Z)(),$=(0,o.sO)(!0),[D,j]=(0,o.eJ)(0),Q=Array.isArray(c)?c[D]:c,q=d&&Q?d[Q]:void 0,G=Array.isArray(c)?c.length:c?1:void 0,H=Z&&(0,l.U)(F,Z).length,_=g?(0,l.OU)(F,g):void 0;(0,o.d4)((()=>{n===u._f&&b&&r&&L({chatId:t})}),[t,L,b,n,r]),(0,o.d4)((()=>{j(0)}),[c]),(0,Nt.Z)(t,Q,q);const{width:z}=St(),V=z<=s.ks,X=h.p7&&v,K=(0,o.sO)(null),W=(0,o.sO)(!0),Y=(0,o.I4)((()=>{T({id:t})}),[T,t]),J=(0,o.I4)((e=>{N({chatId:t,messageId:e,isUnpin:!0})}),[N,t]),ee=(0,o.I4)((()=>{if(q){x({chatId:q.chatId,threadId:n,messageId:q.id});const e=(0,Tt.Z)(G||1,D+1);j(e)}}),[q,x,n,G,D]),te=(0,o.I4)((()=>{B({id:t,threadId:u._f,type:"pinned"})}),[B,t]),ne=(0,o.I4)((()=>{setTimeout((()=>{$.current=!0}),450)}),[]),ae=(0,o.I4)((e=>{if($.current){if($.current=!1,h.wB){const e=document.getElementById(s.R2);e&&e.blur()}if(f)return U(),void ne();if(n===u._f&&"thread"===i&&0===M)return h.wB||X?(e.stopPropagation(),B({id:void 0})):O(),void ne();A(),ne()}}),[n,i,M,f,A,X,B,O,U,ne]),se=z>=s.ks&&z<s.jT||z>s.l3&&z<s.ks&&(!H||H>30),oe=se||z>s._m&&z<s.QU,{shouldRender:ie,transitionClassNames:re}=(0,Ze.Z)(Boolean(y)),ce=(0,xt.Z)(y,!0),{shouldRender:le,transitionClassNames:de}=(0,Ze.Z)(Boolean(q)),ue=(0,xt.Z)(q,!0),me=(0,xt.Z)(G,!0),he=(0,xt.Z)(m,!0),ge=(0,xt.Z)(_),pe=le&&ue||ie&&ce;(0,o.d4)((()=>{const e=K.current;if(e)return oe&&pe?void(I||se?(W.current&&(e.classList.add("tools-stacked","animated"),W.current=!1),setTimeout((()=>{e.classList.remove("animated")}),350)):(e.classList.remove("tools-stacked"),W.current=!0)):(e.classList.remove("tools-stacked","animated"),void(W.current=!0))}),[oe,pe,se,I]);const{connectionStatusText:ve}=Ge(F,R,k,!0);function Ie(){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:ae,ariaLabel:F(e?"Close":"Back")},o.ZP.createElement("div",{className:(0,fe.Z)("animated-close-icon",!e&&"state-back")})),t&&o.ZP.createElement(Be,null))}const ye=Boolean(ie&&ce);return o.ZP.createElement("div",{className:"MiddleHeader",ref:K},o.ZP.createElement(Fe.Z,{name:S?"none":"slide-fade",activeKey:M},"thread"===i&&n===u._f?o.ZP.createElement(o.ZP.Fragment,null,(V||M>0)&&Ie(X,!0),o.ZP.createElement("div",{className:"chat-info-wrapper",onClick:Y},(0,l.YC)(t)?o.ZP.createElement(Bt.Z,{userId:t,typingStatus:p,status:ve,withDots:Boolean(ve),withFullInfo:w,withMediaViewer:!0,withUpdatingStatus:!0,noRtl:!0}):o.ZP.createElement(At.Z,{chatId:t,typingStatus:p,status:ve,withDots:Boolean(ve),withMediaViewer:!0,withFullInfo:!0,withUpdatingStatus:!0,noRtl:!0}))):"thread"===i?o.ZP.createElement(o.ZP.Fragment,null,Ie(),o.ZP.createElement("h3",null,F("CommentsCount",P,"i"))):"pinned"===i?o.ZP.createElement(o.ZP.Fragment,null,Ie(),o.ZP.createElement("h3",null,F("PinnedMessagesCount",P,"i"))):"scheduled"===i?o.ZP.createElement(o.ZP.Fragment,null,Ie(),o.ZP.createElement("h3",null,C?F("Reminders"):F("messages",P,"i"))):void 0),o.ZP.createElement(ln,{hasPinnedOffset:le&&Boolean(ue)||ie&&Boolean(ce),chatId:t}),le&&ue&&o.ZP.createElement(_t,{key:t,message:ue,count:me||0,index:D,customTitle:ge,className:(0,fe.Z)(de,ye&&"full-width"),onUnpinMessage:he?J:void 0,onClick:ee,onAllPinnedClick:te}),E&&o.ZP.createElement(un,{key:t,userId:t}),o.ZP.createElement("div",{className:"header-tools"},ye&&o.ZP.createElement(on,{key:(0,l.Tp)(ce),message:ce,className:re}),o.ZP.createElement(Ot,{chatId:t,threadId:n,messageListType:i,canExpandActions:!ye})))})));var hn=n(2645),gn=n(274);function pn(e){return"albumId"in e}function fn(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 vn=n(386),In=n(2202);var yn=n(7675),Zn=n(539),Pn=n(2357),Cn=n(998);var wn=n(3657);const bn=h.wZ?1e3:350,En=h.wB?300:500;var Sn=n(7240);function Mn(e){return"number"==typeof e}function Rn(e,t){return e?t?238:175:t?238:100}function kn(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=Rn(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 Tn(e,t){return e.reduce(((e,t)=>e+t),t)}function Nn(e,t,n){return e<t?t:e>n?n:e}function xn(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 Bn(e,t,n,a){const s=function(e){return e.map((e=>{const t=kn(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?Nn(e,1,2.75):Nn(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=Tn(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=Tn(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:xn(d)}}let An;function Ln(e){return An||(An=document.createElement("span"),An.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',An.style.whiteSpace="nowrap",An.style.position="absolute",An.style.left="-999px",An.style.opacity=".01",document.body.appendChild(An)),An.innerHTML=e,An.offsetWidth}function On(e,t,n,a,s,i){(0,o.bt)((()=>{if(n&&e.current){const t=e.current.closest(".MessageList");(0,Zn.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 Un=3*Ut.Gw,Fn=Number(Ut.Gw),$n="data-is-document-group-hover";function Dn(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,vn.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)<Un,l=Math.abs(i+r-a)<Fn;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=Qn(e.currentTarget);t&&t.removeAttribute($n)}(e)},isSwiped:C,isQuickReactionVisible:y,handleDocumentGroupMouseEnter:jn}}function jn(e){const t=Qn(e.currentTarget);t&&t.setAttribute($n,"")}function Qn(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}var qn=n(8005);const Gn=(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})),Hn=(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:d,targetUserIds:u,targetMessage:m,targetChatId:h,isFocused:g,focusDirection:p,noFocusHighlight:f}=e;const v=(0,o.sO)(null);(0,wn._N)(v,n),(0,Nt.Z)(t.chatId,t.replyToMessageId,m),On(v,t.chatId,g,p,f);const I=(0,$e.Z)(),y=s<=0,[Z,P]=(0,Ue.Z)(y);(0,o.d4)((()=>{y||setTimeout(P,10*s)}),[s,P,y]);const{transitionClassNames:C}=(0,Ze.Z)(Z,void 0,y,!1),w=(0,o.Ye)((()=>u?u.map((e=>null==r?void 0:r[e])).filter(Boolean):void 0),[u,r]),b=(0,qn.D)(I,t,c,d,w,m,h,{asTextWithSpoilers:a}),{isContextMenuOpen:E,contextMenuPosition:S,handleBeforeContextMenu:M,handleContextMenu:R,handleContextMenuClose:k,handleContextMenuHide:T}=(0,Sn.Z)(v),N=void 0!==S;if(a)return o.ZP.createElement("span",{className:"embedded-action-message"},b);const x=(0,fe.Z)("ActionMessage message-list-item",g&&!f&&"focused",N&&"has-menu-open",i&&"last-in-list",C);return o.ZP.createElement("div",{ref:v,id:(0,l.d0)(t.id),className:x,"data-message-id":t.id,onMouseDown:e=>{(0,vn.q)(e),M(e)},onContextMenu:R},o.ZP.createElement("span",null,b),S&&o.ZP.createElement(Gn,{isOpen:E,anchor:S,message:t,messageListType:"thread",onClose:k,onCloseAnimationEnd:T}))}))),_n=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,wn.Op)(u,c),h=(0,Ft.Z)(n&&(0,l.Ti)(n,"pictogram"),!m),g=Dt(n),p=Boolean(n&&(0,l.Y5)(n)),f=(0,$e.Z)(),v=a&&(0,l.OU)(f,a);return o.ZP.createElement("div",{ref:u,className:(0,fe.Z)("EmbeddedMessage",t),onClick:n?d:void 0},g&&function(e,t,n,a){const{width:s,height:i}=(0,Ut.W7)();return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("img",{src:t||e,width:s,height:i,alt:"",className:n?"round":"",draggable:!a}),a&&o.ZP.createElement("span",{className:"protector"}))}(g,h,p,r),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("p",{dir:"auto"},n?(0,l.Lo)(n)?o.ZP.createElement(Hn,{message:n,isEmbedded:!0}):(0,qt.e)(f,n,Boolean(g)):i||" "),o.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,an.Z)(v||s||" "))))};var zn=n(2535),Vn=n(4752),Xn=n(8018),Kn=n(8198),Wn=n(7799);const Yn=(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(Kn.Z,{reaction:s}),v&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Wn.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(Wn.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})))})),Jn=(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(Yn,{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(Xn.Z,{status:a}))}));var ea=n(692),ta=n(4753);const na=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,isVideo:v}=g,I=h.Hh,y=f===s.$E,Z=(0,wn.Op)(c,n),P=(0,wn.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),S=b||E,M=(0,Ft.Z)(C,!Z,(0,l.kG)(t,"inline"),r),R=Boolean(M),[k,T]=(0,Ue.Z)(R),N=p?k:R,x=(0,ea.Z)(N),{width:B,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,ta.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-${(0,l.d0)(t.id)}`,src:S,width:B,height:A,alt:"",className:L}),!p&&!v&&o.ZP.createElement("img",{id:`sticker-${(0,l.d0)(t.id)}`,src:M,width:B,height:A,alt:"",className:(0,fe.Z)("full-media",x)}),v&&I&&N&&o.ZP.createElement("video",{id:`sticker-${(0,l.d0)(t.id)}`,src:M,width:B,height:A,autoPlay:P,playsInline:!0,loop:i,muted:!0}),p&&R&&o.ZP.createElement(Wn.Z,{key:C,className:(0,fe.Z)("full-media",x),id:C,animationData:M,size:B,play:P,noLoop:!i,onLoad:T}),o.ZP.createElement(ke.Z,{isOpen:d,fromSticker:g,onClose:m}))};var aa=n(7854),sa=n(2566),oa=n(5866);function ia(e,t){return(0,oa.Z)((0,l.DH)(e),Boolean(t),h.wB&&!h.vX)}const ra={dark:{outgoing:"rgb(135,116,225)",incoming:"rgb(33,33,33)"},light:{outgoing:"rgb(238,255,222)",incoming:"rgb(255,255,255)"}};function ca(e,t,n,a,s){return a?Promise.resolve(ra[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)}var la=n(9196);const da=e=>{let{id:t,message:n,observeIntersection:a,noAvatars:i,canAutoLoad:r,isInSelectMode:c,isSelected:d,uploadProgress:u,size:m="inline",dimensions:h,nonInteractive:g,shouldAffectAppendix:p,isDownloading:f,isProtected:v,theme:I,onClick:y,onCancelUpload:Z}=e;const P=(0,o.sO)(null),C=((0,l.O$)(n)||(0,l.F$)(n)).blobUrl,w=(0,wn.Op)(P,a),[b,E]=(0,o.eJ)(r),S=b&&w,{mediaData:M,loadProgress:R}=(0,sa.Z)((0,l.Ti)(n,m),!S),k=C||M,T=ia(n,k),{loadProgress:N}=(0,sa.Z)((0,l.Ti)(n,"download"),!f),{isUploading:x,isTransferring:B,transferProgress:A}=(0,l.Sc)(n,u||(f?N:R),S&&!k),L=!1===(0,Rt.Z)(b),O=(0,ea.Z)(k),{shouldRender:U,transitionClassNames:F}=(0,Ze.Z)(B,void 0,L,"slow"),{shouldRender:$,transitionClassNames:D}=(0,Ze.Z)(!k&&!b),j=(0,o.I4)((()=>{x?Z&&Z(n):k?y&&y(n.id):E((e=>!e))}),[k,x,n,Z,y]),Q=(0,l.B4)(n);(0,o.bt)((()=>{if(!p)return;const e=P.current.closest(".message-content");k?ca(k,Q,0,d,I).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute(s.s2,"")})):e.classList.add("has-appendix-thumb")}),[k,Q,p,c,d,I]);const{width:q,height:G,isSmall:H}=h||kn(n,i),_=(0,fe.Z)("media-inner",!x&&!g&&"interactive",H&&"small-image",q===G&&"square-image"),z=h?`width: ${q}px; height: ${G}px; left: ${h.x}px; top: ${h.y}px;`:"";return o.ZP.createElement("div",{id:t,ref:P,className:_,style:z,onClick:x?void 0:j},o.ZP.createElement("canvas",{ref:T,className:"thumbnail",style:`width: ${q}px; height: ${G}px`}),o.ZP.createElement("img",{src:k,className:`full-media ${O}`,width:q,height:G,alt:"",draggable:!v}),v&&o.ZP.createElement("span",{className:"protector"}),U&&!$&&o.ZP.createElement("div",{className:`media-loading ${F}`},o.ZP.createElement(la.Z,{progress:A,onClick:x?j:void 0})),$&&o.ZP.createElement("i",{className:(0,fe.Z)("icon-download",D)}),B&&o.ZP.createElement("span",{className:"message-transfer-progress"},Math.round(100*A),"%"))};var ua=n(2019),ma=n(6898);function ha(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,ta.Z)(e.current)}),[e]),c=(0,o.I4)((()=>{(0,S.T2)(r)}),[r]);(0,Pe.Z)(i,c),(0,pe.ZP)(i,r)}function ga(){return ga=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},ga.apply(this,arguments)}const pa=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,wn.Op)(y,i),[b,E]=(0,o.eJ)(c),S=Boolean(b&&w&&h),[M,R]=(0,o.eJ)(d),k=(0,Ft.Z)((0,l.Ti)(s,"pictogram"),!(w&&h),(0,l.kG)(s,"pictogram"),h),T=(0,ea.Z)(k),{mediaData:N,loadProgress:x}=(0,sa.Z)((0,l.Ti)(s,"inline"),!S,(0,l.kG)(s,"inline"),h),B=C||N,A=Boolean(w&&B),O=ia(s,k),{loadProgress:U}=(0,sa.Z)((0,l.Ti)(s,"download"),!v,u.IU.BlobUrl,h),{isBuffered:F,bufferingHandlers:$}=(0,ua.Z)(!c),{isUploading:D,isTransferring:j,transferProgress:Q}=(0,l.Sc)(s,m||(v?U:x),S&&!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&&!M&&!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);ha(Z,A),(0,ma.Z)(Z,[A]);const ne=(0,o.I4)((()=>{D?f&&f(s):v?(0,a.uC)().cancelMessageMediaDownload({message:s}):B?B&&!M?(R(!0),Z.current.play()):p&&p(s.id):E((e=>!e))}),[D,v,B,M,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",ga({ref:Z,className:"full-media",width:ee,height:te,autoPlay:M,muted:!0,loop:!0,playsInline:!0},$,{draggable:!I,onTimeUpdate:K}),o.ZP.createElement("source",{src:B})),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(la.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 fa=n(6272);const va=(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,fa.WZ)(s,l))))}));var Ia=n(8974),ya=n(1218),Za=n(4434),Pa=n(6937);function Ca(e,t){return t>0?(e/t*100).toFixed():0}const wa=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?Ca(c.votersCount,a||0):0,[m,h]=(0,o.eJ)(r?0:u),g=(0,o.sO)(null),p=c?Ca(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}))))},ba=(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:S,totalVoters:M}=g,R=S&&S.some((e=>e.isChosen)),k=!h.closed&&!R,T=!k&&h.isPublic&&Number(g.totalVoters)>0,N=k&&h.multipleChoice,x=S?Math.max(...S.map((e=>e.votersCount))):M,B=S?S.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(Pa.Z,{message:(0,Ia.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(ya.Z,{options:A,onChange:F,disabled:t.isScheduled||p,loadingOptions:p?v:void 0,round:!0}):o.ZP.createElement(Za.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(wa,{key:e.option,shouldAnimate:P,answer:e,voteResults:S,totalVoters:M,maxVotersCount:x,correctResults:B})}))),!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 Ea=n(8035),Sa=n(88);const Ma=(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}=kn(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,S=(0,Ea.Z)(C,170),M=(0,fe.Z)("WebPage",f&&"with-square-photo",!w&&!b&&!r&&"without-media",b&&"with-video");return o.ZP.createElement("div",{className:M,"data-initial":(I||Z)[0],dir:"auto"},w&&!b&&o.ZP.createElement(da,{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(Sa.Z,{className:"site-name",url:y,text:I||Z}),!r&&P&&o.ZP.createElement("p",{className:"site-title"},(0,an.Z)(P)),S&&o.ZP.createElement("p",{className:"site-description"},(0,an.Z)(S,["emoji","br"]))),!r&&b&&o.ZP.createElement(pa,{message:t,observeIntersection:n,noAvatars:a,canAutoLoad:s,canAutoPlay:i,lastSyncTime:c,onClick:E?v:void 0,onCancelUpload:g,isDownloading:d,isProtected:u}))}));var Ra=n(9937);const ka=(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,Ra.x)(r,c,n.code),d&&o.ZP.createElement("span",null,n("PaymentTestInvoice")))))}));var Ta=n(8183);const Na=new Map(Object.entries({"building/medical":"#43b3f4","building/gym":"#43b3f4",arts_entertainment:"#e56dd6","travel/bedandbreakfast":"#9987ff","travel/hotel":"#9987ff","travel/hostel":"#9987ff","travel/resort":"#9987ff",building:"#6e81b2",education:"#a57348",event:"#959595",food:"#f7943f","education/cafeteria":"#f7943f",nightlife:"#e56dd6","travel/hotel_bar":"#e56dd6",parks_outdoors:"#6cc039",shops:"#ffb300",travel:"#1c9fff",work:"#ad7854",home:"#00aeef"})),xa=["#e56cd5","#f89440","#9986ff","#44b3f5","#6dc139","#ff5d5a","#f87aad","#6e82b3","#f5ba21"],Ba=e=>{let{variant:t="rectangular",animation:n="wave",width:a,height:s,className:i}=e;const r=(0,fe.Z)("Skeleton",t,n,i),c=(a?`width: ${a}px;`:"")+(s?`height: ${s}px;`:"");return o.ZP.createElement("div",{className:r,style:c})};var Aa=n(8226);const La=1e-4,Oa={width:400,height:300,zoom:16,scale:2},Ua={__html:'<svg version="1.1" class="round-pin" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 64 64" style="enable-background:new 0 0 64 64;" xml:space="preserve"><g><circle cx="32" cy="32" r="24.5"/><path d="M32,8c13.23,0,24,10.77,24,24S45.23,56,32,56S8,45.23,8,32S18.77,8,32,8 M32,7C18.19,7,7,18.19,7,32s11.19,25,25,25 s25-11.19,25-25S45.81,7,32,7L32,7z"/></g><g><polygon points="29.38,57.67 27.4,56.08 30.42,54.42 32,51.54 33.58,54.42 36.6,56.08 34.69,57.61 32,60.73"/><path d="M32,52.58l1.07,1.95l0.14,0.26l0.26,0.14l2.24,1.22l-1.33,1.06l-0.07,0.06l-0.06,0.07L32,59.96l-2.24-2.61l-0.06-0.07 l-0.07-0.06l-1.33-1.06l2.24-1.22l0.26-0.14l0.14-0.26L32,52.58 M32,50.5l-1.94,3.56L26.5,56l2.5,2l3,3.5l3-3.5l2.5-2l-3.56-1.94 L32,50.5L32,50.5z"/></g></svg>'},Fa=(0,o.X$)((e=>{let{message:t,peer:n,lastSyncTime:a,isInSelectMode:i,isSelected:r,theme:c,serverTimeOffset:d}=e;const u=(0,o.sO)(null),m=(0,o.sO)(null),h=(0,$e.Z)(),g=(0,kt.Z)(),f=(0,l.nf)(t),{type:v,geo:I}=f,y=(0,p.b)(d),Z=(0,l.$R)(t,y),P="geoLive"!==v||Z?void 0:t.date+f.period-y,[C,w]=(0,o.eJ)(I),b="venue"===v||"geoLive"===v&&!Z,{width:E,height:S,zoom:M,scale:R}=Oa,k=Boolean(a)&&(0,l.k6)(C,E,S,M,R),T=(0,Ft.Z)(k),N=(0,Rt.Z)(T),x=T||N,B=n&&(0,l.YC)(n.id),A=n&&B?n:void 0,O=n&&!B?n:void 0,U=(0,l.B4)(t),F=(0,o.Ye)((()=>{if("geoLive"!==v||!C.accuracyRadius)return 0;const{lat:e,accuracyRadius:t}=C;return t/function(e,t){return 156543.03392*Math.cos(e*Math.PI/180)/Math.pow(2,t)}(e,M)}),[v,C,M]),$=(0,o.I4)((e=>{if("geoLive"!==v)return;const n=24*Math.PI,a=e.lastElementChild,s=e.firstElementChild,o=t.date+f.period-(0,p.b)(d),i=(1-o/f.period)*n,r=(0,L.mB)(h,1e3*o);a&&s?(s.textContent=r,a.firstElementChild.setAttribute("stroke-dashoffset",`-${i}`)):e.innerHTML=`\n <span class="geo-countdown-text">${r}</span>\n <svg width="32px" height="32px">\n <circle cx="16" cy="16" r="12" class="geo-countdown-progress" transform="rotate(-90, 16, 16)"\n stroke-dasharray="${n} ${n}"\n stroke-dashoffset="-${i}"\n />\n </svg>`}),[v,t.date,f,d,h]);return(0,o.bt)((()=>{m.current&&$(m.current)}),[$]),(0,o.bt)((()=>{if(b)return;const e=u.current.closest(".message-content");x&&ca(x,U,0,r,c).then((t=>{e.style.setProperty("--appendix-bg",t),e.classList.add("has-appendix-thumb"),e.setAttribute(s.s2,"")}))}),[U,i,r,c,x,b]),(0,o.d4)((()=>{Math.abs(I.lat-C.lat)<La&&Math.abs(I.long-C.long)<La?C.accuracyRadius!==I.accuracyRadius&&w({...C,accuracyRadius:I.accuracyRadius}):w(I)}),[I,C]),(0,Ta.Z)((()=>{g()}),Z?void 0:1e3*(P||0)),(0,Pn.Z)((()=>{const e=m.current;e&&$(e)}),P?1e3:void 0),o.ZP.createElement("div",{ref:u,className:"Location media-inner interactive",onClick:()=>{var e;const t=function(e,t,n){return`http://maps.google.com/maps/place/${e}+${t}/@${e},${t},${n}z`}(C.lat,C.long,M);null===(e=window.open(t,"_blank"))||void 0===e||e.focus()}},o.ZP.createElement("div",{className:"map-wrapper"},x?o.ZP.createElement("img",{className:"full-media map",src:x,alt:"Location on a map",width:Oa.width,height:Oa.height}):o.ZP.createElement(Ba,{width:E,height:S}),function(){if(x)return o.ZP.createElement(o.ZP.Fragment,null,Boolean(F)&&!Z&&o.ZP.createElement("div",{className:"location-accuracy",style:`width: ${2*F}px; height: ${2*F}px`}),function(){const e=(0,fe.Z)("pin",v,Z&&"expired");if("geoLive"===v)return o.ZP.createElement("div",{className:e,dangerouslySetInnerHTML:Ua},o.ZP.createElement(cn.Z,{chat:O,user:A,className:"location-avatar"}),void 0!==f.heading&&o.ZP.createElement("div",{className:"direction",style:`--direction: ${f.heading}deg`}));if("venue"===v){const t=function(e){return e?Na.get(e)||Na.get(e.split("/")[0])||xa[(t=e,t.split("").reduce(((e,t)=>(e<<5)-e+t.charCodeAt(0)|0),0)%xa.length)]:"#008df2";var t}(f.venueType),n=function(e){return e?`https://ss3.4sqi.net/img/categories_v2/${e}_88.png`:""}(f.venueType);return o.ZP.createElement("div",{className:e,dangerouslySetInnerHTML:Ua,style:`--pin-color: ${t}`},o.ZP.createElement("img",{src:n,className:"venue-icon",alt:""}))}return o.ZP.createElement("img",{className:e,src:Aa,alt:""})}())}()),function(){if(b)return"venue"===v?o.ZP.createElement("div",{className:"location-info"},o.ZP.createElement("div",{className:"location-info-title"},f.title),o.ZP.createElement("div",{className:"location-info-subtitle"},f.address)):"geoLive"===v?o.ZP.createElement("div",{className:"location-info"},o.ZP.createElement("div",{className:"location-info-title"},h("AttachLiveLocation")),o.ZP.createElement("div",{className:"location-info-subtitle"},(0,L.dJ)(h,y,t.editDate)),!Z&&o.ZP.createElement("div",{className:"geo-countdown",ref:m})):void 0}())}));function $a(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 Da=$a(da),ja=$a(pa),Qa=(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(Da,{id:`album-media-${(0,l.d0)(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(ja,{id:`album-media-${(0,l.d0)(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 qa(){return qa=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},qa.apply(this,arguments)}let Ga;const Ha=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,wn.Op)(c,n),[p,f]=(0,o.eJ)(s),v=Boolean(p&&g&&i),{mediaData:I,loadProgress:y}=(0,sa.Z)((0,l.Ti)(t,"inline"),!v,(0,l.kG)(t,"inline"),i),{loadProgress:Z}=(0,sa.Z)((0,l.Ti)(t,"download"),!r,u.IU.BlobUrl,i),P=ia(t,I),{isBuffered:C,bufferingHandlers:w}=(0,ua.Z)(),b=p&&!C||r,E=!1===(0,Rt.Z)(p),M=(0,ea.Z)(I),{shouldRender:R,transitionClassNames:k}=(0,Ze.Z)(b||!C,void 0,E),[T,N]=(0,o.eJ)(!1),[x,B]=(0,o.eJ)(0);(0,o.d4)((()=>{if(!T)return;const e=Ut.Rj/2,t=2*(e-6)*Math.PI,n=t-x*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>`,B(a.currentTime/a.duration)}),[T,x]);const A=Boolean(I&&g),O=(0,o.I4)((()=>{m.current&&(N(!1),B(0),(0,ta.Z)(m.current),(0,S.T2)((()=>{d.current.innerHTML=""})))}),[]),U=(0,o.I4)((()=>{var e;null===(e=Ga)||void 0===e||e(),Ga=O}),[O]);(0,o.d4)((()=>{m.current&&(A?(0,ta.Z)(m.current):m.current.pause())}),[A]),ha(m,A),(0,ma.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,ta.Z)(e),(0,zt.Es)()):e.pause():(U(),e.pause(),e.currentTime=0,(0,ta.Z)(e),(0,zt.Es)(),N(!0))}),[U,T,r,I,t]),$=(0,o.I4)((e=>{const t=e.currentTarget;B(t.currentTime/t.duration)}),[]),D=(0,fe.Z)("full-media",M);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",qa({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(la.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"})))},_a=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"}))))))))},za=(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"}))})),Va=(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(Yn,{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))})),Xa=(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(Va,{key:e.reaction,reaction:e,message:t,activeReaction:a,availableReactions:s}))),i)}));var Ka=n(7324),Wa=n(5296);const Ya=(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,Wa.Z)(i,l,c,s,d,a,n),v=`local_emoji_${t}`,I=(0,wn.Op)(m,r),[y,Z]=(0,o.eJ)();return(0,o.d4)((()=>{t&&(0,Ka.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(Wn.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>'},es={__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>'},ts=(0,o.X$)((0,a.c$)(((e,t)=>{const{focusedMessage:n,forwardMessages:a,lastSyncTime:s,serverTimeOffset:o}=e,{message:i,album:c,withSenderName:d,withAvatar:u,threadId:m,messageListType:h,isLastInDocumentGroup:g}=t,{id:p,chatId:f,viaBotId:v,replyToChatId:I,replyToMessageId:y,isOutgoing:Z,threadInfo:P}=i,C=(0,r.Z1)(e,f),w=(0,r.FM)(e,f),b=(0,l.pK)(f),E=C&&(0,l.eA)(C),S=null==C?void 0:C.username,M=!w&&(0,l.Ul)(i),R=d||u||M,k=(0,r.Ur)(e,i),T=(0,r.cv)(e,i),N=v?(0,r.dy)(e,v):void 0,x=m?(0,r.qS)(e,f,m):void 0,B=i.id===x,A=y===x,L=y&&!A?(0,r.hj)(e,b&&I?I:f,y):void 0,O=L&&(0,r.Ur)(e,L),U=(0,r.uZ)(e,i),F="thread"===h&&(c?c.messages.some((t=>(0,r._X)(e,t))):(0,r._X)(e,i)),{direction:$,noHighlight:D,isResizingContainer:j}=F&&n||{},Q=a.messageIds&&a.messageIds.includes(p),{query:q}=(0,r.n5)(e)||{},G=(0,l._O)(i);let H;H=null!=c&&c.messages?c.messages.every((t=>{let{id:n}=t;return(0,r.vk)(e,n)})):(0,r.vk)(e,p);const{canReply:_}="thread"===h&&(0,r._k)(e,i,m)||{},z=(0,r.te)(e,i),V=P?(0,r.tZ)(e,P.chatId,P.threadId)||P:void 0,X=Boolean(i.groupedId)&&!i.isInAlbum,K=X?(0,r.xH)(e,f,i.groupedId)[0]:void 0,W=X?g?(0,r.hj)(e,f,K):void 0:i,Y=G?(0,r.CP)(e,G):void 0;return{theme:(0,r.Pu)(e),chatUsername:S,forceSenderName:M,sender:k,canShowSender:R,originSender:T,botSender:N,shouldHideReply:A,isThreadTop:B,replyMessage:L,replyMessageSender:O,isInDocumentGroup:X,isProtected:(0,r.EV)(e,i),isFocused:F,isForwarding:Q,reactionMessage:W,isChatWithSelf:w,isRepliesChat:b,isChannel:E,canReply:_,lastSyncTime:s,serverTimeOffset:o,highlight:q,isSingleEmoji:Boolean(G),animatedEmoji:G?(0,r.zB)(e,G):void 0,animatedEmojiEffect:G&&(0,l.YC)(f)?(0,r.tH)(e,G):void 0,animatedEmojiSoundId:G?(0,r.Oh)(e,G):void 0,localSticker:Y,localEffect:Y&&(0,l.YC)(f)?(0,r.cu)(Y):void 0,isInSelectMode:(0,r.CA)(e),isSelected:H,isGroupSelected:Boolean(i.groupedId)&&!i.isInAlbum&&(0,r.a6)(e,f,i.groupedId),threadId:m,isDownloading:z,isPinnedList:"pinned"===h,canAutoLoadMedia:(0,r.bH)(e,i),canAutoPlayMedia:(0,r.__)(e,i),autoLoadFileMaxSizeMb:e.settings.byKey.autoLoadFileMaxSizeMb,shouldLoopStickers:(0,r.yB)(e),threadInfo:V,availableReactions:e.availableReactions,defaultReaction:(0,l.CI)(i)?void 0:(0,r.q6)(e,f),activeReaction:W&&e.activeReactions[W.id],activeEmojiInteractions:e.activeEmojiInteractions,...Z&&{outgoingStatus:(0,r.dT)(e,i,"scheduled"===h)},..."number"==typeof U&&{uploadProgress:U},...F&&{focusDirection:$,noFocusHighlight:D,isResizingContainer:j}}}))((e=>{let{message:t,chatUsername:n,observeIntersectionForBottom:s,observeIntersectionForMedia:i,observeIntersectionForAnimatedStickers:r,album:c,noAvatars:d,withAvatar:g,withSenderName:f,areReactionsInMeta:v,noComments:I,appearanceOrder:y,isFirstInGroup:Z,isLastInGroup:P,isFirstInDocumentGroup:C,isLastInDocumentGroup:w,isLastInList:b,theme:E,forceSenderName:S,sender:M,canShowSender:R,originSender:k,botSender:T,isThreadTop:N,shouldHideReply:x,replyMessage:B,replyMessageSender:A,outgoingStatus:L,uploadProgress:O,isInDocumentGroup:U,isProtected:F,isFocused:$,focusDirection:D,noFocusHighlight:j,isResizingContainer:Q,isForwarding:q,isChatWithSelf:G,isRepliesChat:H,isChannel:_,canReply:z,lastSyncTime:V,serverTimeOffset:X,highlight:K,animatedEmoji:W,localSticker:Y,localEffect:J,animatedEmojiEffect:ee,animatedEmojiSoundId:te,isInSelectMode:ne,isSelected:ae,isGroupSelected:se,threadId:oe,reactionMessage:ie,availableReactions:re,defaultReaction:ce,activeReaction:le,activeEmojiInteractions:de,messageListType:ue,isPinnedList:me,isDownloading:he,canAutoLoadMedia:ge,canAutoPlayMedia:pe,shouldLoopStickers:ve,autoLoadFileMaxSizeMb:Ie,threadInfo:ye}=e;const{toggleMessageSelection:Pe,clickInlineButton:Ce,disableContextMenuHint:we}=(0,a.uC)(),be=(0,o.sO)(null),Ee=(0,o.sO)(null),Se=(0,o.sO)(null),Me=(0,$e.Z)();(0,wn._N)(Ee,s);const{isContextMenuOpen:Re,contextMenuPosition:ke,handleBeforeContextMenu:Te,handleContextMenu:Ne,handleContextMenuClose:xe,handleContextMenuHide:Be}=(0,Sn.Z)(be,h.$b&&ne,!0,h.wZ);(0,o.d4)((()=>{Re&&we()}),[Re,we]);const Ae=y<=0,[Le,Oe]=(0,Ue.Z)(Ae);(0,o.d4)((()=>{Ae||setTimeout(Oe,10*y)}),[y,Oe,Ae]);const{transitionClassNames:Fe}=(0,Ze.Z)(Le,void 0,Ae,!1),{id:De,chatId:je,forwardInfo:Qe,viaBotId:qe}=t,Ge=(0,l.CI)(t),He=(0,l.B4)(t),_e="scheduled"===ue||t.isScheduled,Ve=(0,l.ss)(t)&&!x,Xe=Boolean(ye)&&"thread"===ue,Ke=(0,l.$D)(t),We=Y||W,Ye=(null==ie?void 0:ie.reactions)&&!(0,l.JE)(ie.reactions),Je=Qe&&(!G||_e)&&!H&&!Qe.isLinkedChannelPost&&!Ke,et=Boolean(c)&&c.messages.length>1,tt=U&&!C,nt=U&&!w,at=void 0!==ke,st=!(at||ne||q||nt),ot=_&&!_e,it=Boolean(me||Qe&&(Qe.isChannelPost||G&&!He||H)&&Qe.fromMessageId),rt=ye&&!nt&&"thread"===ue&&!I,ct=!h.$b&&!ne&&ce&&!nt,lt=(0,o.I4)(((e,t)=>{Pe({messageId:De,groupedId:t,...(null==e?void 0:e.shiftKey)&&{withShift:!0},...et&&{childMessageIds:c.messages.map((e=>{let{id:t}=e;return t}))}})}),[Pe,De,et,c]),dt=R?M:void 0,ut=Qe&&(G||H||!dt)?k:dt,mt=Qe?k:dt,{handleMouseDown:ht,handleClick:gt,handleContextMenu:pt,handleDoubleClick:ft,handleContentDoubleClick:vt,handleMouseMove:It,handleSendQuickReaction:yt,handleMouseLeave:Zt,isSwiped:Pt,isQuickReactionVisible:Ct,handleDocumentGroupMouseEnter:wt}=Dn(lt,be,De,0,Boolean(ne),Boolean(z),Boolean(F),Ne,Te,je,at,Se,He,nt),{handleAvatarClick:bt,handleSenderClick:Et,handleViaBotClick:St,handleReplyClick:Mt,handleMediaClick:Rt,handleAudioPlay:kt,handleAlbumMediaClick:Tt,handleMetaClick:xt,handleReadMedia:Bt,handleCancelUpload:At,handleVoteSend:Lt,handleGroupForward:Ot,handleForward:Ft,handleFocus:$t,handleFocusForwarded:Dt,handleDocumentGroupSelectAll:jt}=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:S}=(0,a.uC)(),{id:M,forwardInfo:R,replyToMessageId:k,replyToChatId:T,replyToTopMessageId:N,groupedId:x}=n,B=(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:M})}),[y,d,T,s,i,k,M]),U=(0,o.I4)((()=>{Z({chatId:s,threadId:i,messageId:M,origin:l?m.bZ.ScheduledInline:m.bZ.Inline})}),[s,i,M,Z,l]),F=(0,o.I4)((()=>{P({chatId:s,messageId:M})}),[s,M,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:[M]})}),[M,C]),j=(0,o.I4)((()=>{w({chatId:s,messageId:M})}),[w,s,M]),Q=(0,o.I4)((e=>{b({chatId:s,messageId:M,options:e})}),[s,M,b]),q=(0,o.I4)((()=>{E({fromChatId:s,groupedId:x})}),[E,s,x]),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:[M]})}),[h,E,s,M]),H=(0,o.I4)((()=>{y({chatId:s,threadId:u._f,messageId:M})}),[y,s,M]),_=(0,o.I4)((()=>{r?y({chatId:R.fromChatId,groupedId:x,groupedChatId:s}):d&&T?S({chatId:T,threadId:N,messageId:R.fromMessageId}):y({chatId:R.fromChatId,messageId:R.fromMessageId})}),[r,d,T,y,R,x,s,S,N]),z=(0,o.I4)((e=>{e.stopPropagation(),t(e,x)}),[t,x]);return{handleAvatarClick:B,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}}(Me,lt,t,je,oe,U,Je,_e,H,c,ut,mt,T),Qt=(0,fe.Z)("Message message-list-item",Z&&"first-in-group",F&&"is-protected",P&&"last-in-group",C&&"first-in-document-group",w&&"last-in-document-group",b&&"last-in-list",He&&"own",Boolean(t.views)&&"has-views",t.isEdited&&"was-edited",Ve&&"has-reply",at&&"has-menu-open",$&&!j&&"focused",q&&"is-forwarding",t.isDeleting&&"is-deleting",U&&"is-in-document-group",et&&"is-album",t.hasUnreadMention&&"has-unread-mention",ae&&"is-selected",ne&&"is-in-selection-mode",N&&"is-thread-top",Boolean(t.inlineButtons)&&"has-inline-buttons",Pt&&"is-swiped",Fe,Boolean(le)&&"has-active-reaction"),{text:Gt,photo:Ht,video:_t,audio:zt,voice:Vt,document:Xt,sticker:Kt,contact:Wt,poll:Yt,webPage:Jt,invoice:en,location:tn}=(0,l.qp)(t),nn=function(e){let{hasReply:t,customShape:n,isLastInGroup:a,asForwarded:s,hasThread:o,forceSenderName:i,hasComments:r,hasActionButton:c,hasReactions:d,isGeoLiveActive:u}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{text:m,photo:h,video:g,audio:p,voice:f,document:v,poll:I,webPage:y,contact:Z,location:P}=(0,l.qp)(e),C=["message-content"],w=h||g||P,b=m||"venue"===(null==P?void 0:P.type)||u,E=w&&!b,S=Boolean(e.viaBotId);return Mn(n)?C.push(`emoji-only emoji-only-${n}`):b&&C.push("text"),c&&C.push("has-action-button"),n&&(C.push("custom-shape"),null!=g&&g.isRound&&C.push("round"),r&&C.push("has-comments")),w?C.push("media"):p?C.push("audio"):f?C.push("voice"):v?C.push("document"):Z?C.push("contact"):I?C.push("poll"):y&&(C.push("web-page"),(y.photo||y.video)&&C.push("media")),s&&C.push("is-forwarded"),t&&C.push("is-reply"),o&&C.push("has-replies"),d&&C.push("has-reactions"),S&&C.push("is-via-bot"),i&&C.push("force-sender-name"),n||(C.push("has-shadow"),w&&r&&C.push("has-background"),(t||s||!E||S||i)&&C.push("has-solid-background"),a&&(h||P&&!b||!E)&&C.push("has-appendix")),C.join(" ")}(t,{hasReply:Ve,customShape:Ke,isLastInGroup:P,asForwarded:Je,hasThread:Xe,forceSenderName:S,hasComments:ye&&(null==ye?void 0:ye.messagesCount)>0,hasActionButton:ot||it,hasReactions:Ye,isGeoLiveActive:"geoLive"===(null==tn?void 0:tn.type)&&!(0,l.$R)(t,(0,p.b)(X))}),sn=nn.includes("has-appendix"),on=(0,qt.X)(t,K,Mn(Ke));let rn,ln;rn=nt?"none":!on||We||Jt?"standalone":"in-text",v?ln="in-meta":Ye?Ke||(Ht||_t||We)&&!on?ln="outside":Je?(rn="standalone",ln="inside"):ln="inside":ln="none",(0,Nt.Z)(H&&t.replyToChatId?t.replyToChatId:je,Ve?t.replyToMessageId:void 0,B,t.id),On(be,je,$,D,j,Q);let dn,un="",mn=!1;const hn=(0,o.Ye)((()=>et?Bn(He,Boolean(Je),Boolean(d),c):void 0),[et,He,Je,d,c]),gn=Je?28:0;if(et||!Ht&&!_t)hn&&(dn=Math.max(Rn(Boolean(Gt),rt),hn.containerStyle.width),dn-hn.containerStyle.width>18&&(mn=!0));else{let e;Ht?e=kn(t,d).width:_t&&(e=_t.isRound?Ut.Rj:kn(t,d).width),e&&(dn=Math.max(Rn(Boolean(Gt),rt),e),dn-e>18&&(mn=!0))}dn&&(un=`width: ${dn+gn}px`);const pn=_&&t.adminTitle||!Je&&(null==Qe?void 0:Qe.adminTitle)||void 0,fn=(0,o.Ye)((()=>pn?Ln(pn):void 0),[pn]);function vn(){const e=o.ZP.createElement(Jn,{message:t,reactionMessage:ie,outgoingStatus:L,signature:pn,withReactions:"in-meta"===ln,withReactionOffset:"inside"===ln,availableReactions:re,activeReaction:le,onClick:xt});return"inside"!==ln?e:o.ZP.createElement(Xa,{activeReaction:le,message:ie,metaChildren:e,availableReactions:re})}return o.ZP.createElement("div",{ref:be,id:(0,l.d0)(t.id),className:Qt,style:fn?`--meta-safe-author-width: ${fn}px`:void 0,"data-message-id":De,onMouseDown:ht,onClick:gt,onContextMenu:pt,onDoubleClick:ft,onMouseEnter:nt?wt:void 0,onMouseMove:ct?It:void 0,onMouseLeave:ct||nt?Zt:void 0},o.ZP.createElement("div",{ref:Ee,className:"bottom-marker","data-message-id":De,"data-last-message-id":c?c.messages[c.messages.length-1].id:void 0,"data-has-unread-mention":t.hasUnreadMention}),!U&&o.ZP.createElement("div",{className:"message-select-control"},ae&&o.ZP.createElement("i",{className:"icon-select"})),w&&o.ZP.createElement("div",{className:(0,fe.Z)("message-select-control group-select",se&&"is-selected"),onClick:jt},se&&o.ZP.createElement("i",{className:"icon-select"})),g&&function(){const e=ut&&(0,l.YC)(ut.id),t=ut&&e?ut:void 0,n=ut&&!e?ut:void 0,a=!ut&&Qe?Qe.hiddenUserName:void 0;return o.ZP.createElement(cn.Z,{size:"small",user:t,chat:n,text:a,lastSyncTime:V,onClick:t||n?bt:void 0})}(),o.ZP.createElement("div",{className:(0,fe.Z)("message-content-wrapper",nn.includes("text")&&"can-select-text")},o.ZP.createElement("div",{ref:Se,className:nn,style:un,dir:"auto"},Je&&!tt&&o.ZP.createElement("div",{className:"message-title"},Me("ForwardedMessage")),function(){const e=(0,fe.Z)("content-inner",Je&&"forwarded-message",Ve&&"reply-message",mn&&"no-media-corners"),n=P&&!on&&!Je&&!Xe,a=(0,fe.Z)("text-content","in-text"===rn&&"with-meta",L&&"with-outgoing-icon");return o.ZP.createElement("div",{className:e,onDoubleClick:vt,dir:"auto"},function(){if(Ke&&!qe||!(f&&!(Ht||_t||tn)||Je||qe||S)||tt||Ve&&Ke)return;let e,n;return!mt||Ke&&qe?null!=Qe&&Qe.hiddenUserName&&(e=Qe.hiddenUserName):(e=(0,l.OU)(Me,mt),Je||(n=`color-${(0,l.Rs)(mt)}`)),o.ZP.createElement("div",{className:"message-title",dir:"ltr"},e?o.ZP.createElement("span",{className:(0,fe.Z)("interactive",n),onClick:Et,dir:"auto"},(0,an.Z)(e)):T?void 0:" ",T&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"via"},Me("ViaBot")),o.ZP.createElement("span",{className:"interactive",onClick:St},(0,an.Z)(`@${T.username}`))),null!=Qe&&Qe.isLinkedChannelPost?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},Me("DiscussChannel")):t.adminTitle&&!_?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},t.adminTitle):void 0)}(),Ve&&o.ZP.createElement(_n,{message:B,isProtected:F,sender:A,observeIntersection:i,onClick:Mt}),Kt&&o.ZP.createElement(na,{message:t,observeIntersection:i,observeIntersectionForPlaying:r,shouldLoop:ve,lastSyncTime:V}),W&&o.ZP.createElement(aa.Z,{size:"small",isOwn:He,sticker:W,effect:ee,soundId:te,observeIntersection:i,lastSyncTime:V,forceLoadPreview:Ge,messageId:De,chatId:je,activeEmojiInteractions:de}),Y&&o.ZP.createElement(Ya,{size:"small",isOwn:He,localSticker:Y,localEffect:J,soundId:te,observeIntersection:i,lastSyncTime:V,forceLoadPreview:Ge,messageId:De,chatId:je,activeEmojiInteractions:de}),et&&o.ZP.createElement(Qa,{album:c,albumLayout:hn,observeIntersection:i,isOwn:He,isProtected:F,hasCustomAppendix:n,lastSyncTime:V,onMediaClick:Tt}),!et&&Ht&&o.ZP.createElement(da,{message:t,observeIntersection:i,noAvatars:d,canAutoLoad:ge,uploadProgress:O,shouldAffectAppendix:n,onClick:Rt,onCancelUpload:At,isDownloading:he,isProtected:F,theme:E}),!et&&_t&&_t.isRound&&o.ZP.createElement(Ha,{message:t,observeIntersection:i,canAutoLoad:ge,lastSyncTime:V,isDownloading:he}),!et&&_t&&!_t.isRound&&o.ZP.createElement(pa,{message:t,observeIntersection:i,noAvatars:d,canAutoLoad:ge,canAutoPlay:pe,uploadProgress:O,lastSyncTime:V,onClick:Rt,onCancelUpload:At,isDownloading:he,isProtected:F}),(zt||Vt)&&o.ZP.createElement(Vn.Z,{theme:E,message:t,origin:m.Cr.Inline,uploadProgress:O,lastSyncTime:V,isSelectable:U,isSelected:ae,onPlay:kt,onReadMedia:!Vt||He&&!G?void 0:Bt,onCancelUpload:At,isDownloading:he}),Xt&&o.ZP.createElement(zn.Z,{message:t,observeIntersection:i,canAutoLoad:ge,autoLoadFileMaxSizeMb:Ie,uploadProgress:O,isSelectable:U,isSelected:ae,onMediaClick:Rt,onCancelUpload:At,isDownloading:he}),Wt&&o.ZP.createElement(va,{contact:Wt}),Yt&&o.ZP.createElement(ba,{message:t,poll:Yt,onSendVote:Lt}),!We&&on&&o.ZP.createElement("p",{className:a,dir:"auto"},on,"in-text"===rn&&vn()),Jt&&o.ZP.createElement(Ma,{message:t,observeIntersection:i,noAvatars:d,canAutoLoad:ge,canAutoPlay:pe,lastSyncTime:V,onMediaClick:Rt,onCancelMediaTransfer:At,isDownloading:he,isProtected:F,theme:E}),en&&o.ZP.createElement(ka,{message:t}),tn&&o.ZP.createElement(Fa,{message:t,lastSyncTime:V,isInSelectMode:ne,isSelected:ae,theme:E,peer:M,serverTimeOffset:X}))}(),!nt&&"standalone"===rn&&vn(),st&&ot?o.ZP.createElement(ze.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:Me("lng_context_forward_msg"),onClick:w?Ot:Ft},o.ZP.createElement("i",{className:"icon-share-filled"})):st&&it?o.ZP.createElement(ze.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:me?$t:Dt},o.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,rt&&o.ZP.createElement(za,{threadInfo:ye,disabled:I}),sn&&o.ZP.createElement("div",{className:"svg-appendix",dangerouslySetInnerHTML:He?Ja:es}),ct&&o.ZP.createElement("div",{className:(0,fe.Z)("quick-reaction",Ct&&!le&&"visible"),onClick:yt},o.ZP.createElement(Kn.Z,{reaction:ce}))),t.inlineButtons&&o.ZP.createElement(_a,{message:t,onClick:Ce}),"outside"===ln&&o.ZP.createElement(Xa,{message:ie,isOutside:!0,activeReaction:le,availableReactions:re})),ke&&o.ZP.createElement(Gn,{isOpen:Re,anchor:ke,message:t,album:c,chatUsername:n,messageListType:ue,onClose:xe,onCloseAnimationEnd:Be}))}))),ns=(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,wn.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,Ia.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")))))}))),as=(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:M,isSchedule:R,noAppearanceAnimation:k,onFabToggle:T,onNotchToggle:N}=e;const{openHistoryCalendar:x}=(0,a.uC)(),{observeIntersectionForMedia:B,observeIntersectionForReading:A,observeIntersectionForAnimatedStickers:O}=function(e,t,n){const{markMessageListRead:s,markMessagesRead:o}=(0,a.uC)(),{observe:i}=(0,wn.S1)({rootRef:t,throttleMs:bn,margin:En}),{observe:r,freeze:c,unfreeze:l}=(0,wn.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,wn.S1)({rootRef:t,throttleMs:bn});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,S.Ds)((()=>p({direction:m.Uq.Backwards})),1e3,!0,!1),(0,S.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,wn.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,wn._N)(I,C),(0,wn._N)(y,C);const{observe:w,freeze:b,unfreeze:E}=(0,wn.S1)({rootRef:t,margin:100},P);(0,wn._N)(Z,w);const{observe:M,freeze:R,unfreeze:k}=(0,wn.S1)({rootRef:t,margin:1},P);return(0,wn._N)(Z,M),(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&&!pn(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(Hn,{key:i.id,message:i,observeIntersection:A,appearanceOrder:Q-++q,isLastInList:r})])}let i;return(0,g.xH)(e.map(((r,c)=>{const m=pn(r)?r.mainMessage:r,h=pn(r)?r:void 0,f=(0,l.B4)(m),y=pn(r),C=e[c+1];m.previousLocalId&&v.current===(0,l.d0)(m.previousLocalId)&&(v.current=(0,l.d0)(m.id));const w=!y&&m.groupedId?m.groupedId:void 0,b=C&&!pn(C)?C.groupedId:void 0,S={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(ts,{key:k,message:m,observeIntersectionForBottom:A,observeIntersectionForMedia:B,observeIntersectionForAnimatedStickers:O,album:h,noAvatars:p,withAvatar:S.isLastInGroup&&d&&!f&&!(m.id===E),withSenderName:S.isFirstInGroup&&d&&!f,areReactionsInMeta:u,threadId:Z,messageListType:P,noComments:!1===M,appearanceOrder:Q-++q,isFirstInGroup:S.isFirstInGroup,isLastInGroup:S.isLastInGroup,isFirstInDocumentGroup:S.isFirstInDocumentGroup,isLastInDocumentGroup:S.isLastInDocumentGroup,isLastInList:S.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:vn.q,teactFastList:!0},o.ZP.createElement("div",{className:(0,fe.Z)("sticky-date",!R&&"interactive"),key:"date-header",onMouseDown:vn.q,onClick:R?void 0:()=>x({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(ns,{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 ss=n(3547);const os=(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,wn.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(ss.Z,{sticker:t,onClick:m,clickArg:t,observeIntersection:u,size:160,className:"large"}))))}))),is=(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")))})),rs=(0,S.Ds)((e=>e()),200,!1),cs=(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:M,isRepliesChat:R,isCreator:k,isBot:T,messageIds:N,messagesById:x,firstUnreadId:B,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,S.R3)((()=>{ie.current=!1}))}),[le]),(0,we.Z)((()=>{ne.current=B}),[B]),(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,Cn.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||!x)return;const e=!Q||N[0]&&L!==N[0]?N:[Q,...N];if(!e.length)return;const t=e.map((e=>x[e])).filter(Boolean);return fn((0,g.Xo)(t,["date","id"]),ae.current)}),[N,x,L,Q]);(0,Pn.Z)((()=>{if(!N||!x)return;const e=N.filter((e=>{var t;return null===(t=x[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,S.Ds)((()=>_({direction:m.Uq.Around})),1e3,!0,!1)}),[_,N]),{isScrolled:me,updateStickyDates:he}=function(){const[e,t]=(0,Ue.Z)(!1),n=(0,In.Z)(1e3,!0);return{isScrolled:e,updateStickyDates:(0,o.I4)(((e,a)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,S.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),n((()=>{(0,S.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),rs((()=>{ge.current=!1,(0,S.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}=St();(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,hn.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,S.T2)((()=>{(0,Zn.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,Zn.N)())return;y=m-h}else P?(ve.current&&(ve.current=!1,(0,yn.z)(o)),y=u+(P.getBoundingClientRect().top-(ee.current||0))):y=C?Math.min(C.offsetTop-(I?60:10),m-g):m-g;(0,yn.Z)(o,Math.ceil(y)),se.current||(oe.current=!0,(0,S.T2)((()=>{oe.current=!1}))),Y.current=Math.max(Math.ceil(m-y),h)}),[N,A,re,I]),(0,gn.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||M||R),be=Boolean(!Ce||C),Ee=(0,l.YC)(p)&&!M&&!T&&(!de&&!D&&N&&(!te.current||0===te.current.length)||1===(null==N?void 0:N.length)&&"contactSignUp"===(null==x||null===(t=x[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)),Se=w&&k&&1===(null==N?void 0:N.length)&&"chatCreate"===(null==x||null===(d=x[N[0]])||void 0===d||null===(u=d.content.action)||void 0===u?void 0:u.type),Me=(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:Me,onScroll:Ie,onMouseDown:vn.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(os,{userId:p}):!N||de&&!Se?N&&de||D?o.ZP.createElement(as,{chatId:p,messageIds:N||[D.id],messageGroups:de||fn([D]),isViewportNewest:Boolean(A),isUnread:Boolean(B),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(is,{chatId:p,type:v,isChatWithSelf:M,isGroupChatJustCreated:Se}))}))),ls=(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,Zn.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 ds=n(5723);const us=1280,ms=/\.[^/.]+$/;async function hs(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>us||s>us||"image/jpeg"!==i){const t=await Kt(o,us/Math.max(n,s),"image/jpeg");return URL.revokeObjectURL(o),hs(e,await(0,Et.gm)(t),!0,a)}"image/jpeg"===i&&(e=e.replace(ms,".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 gs(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 ps=n(6391);let fs;function vs(e){fs.focus(),e.focus()}h.cj&&(fs=document.createElement("input"),fs.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(fs));var Is=n(4784),ys=n(2400),Zs=n(6389),Ps=n(971);const Cs={encoderPath:new URL(n(8973),n.b).href,reuseWorker:!0},ws={type:"audio/ogg"};let bs,Es,Ss;async function Ms(){return bs||(bs=n.e(161).then(n.t.bind(n,1161,23)),Es=(await bs).default,Ss=new Es(Cs)),bs}async function Rs(e){await async function(){await Ms(),await Ss.start()}();const t=Date.now();let n;const a=[],s=[];Ss.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}}(Ss);return{stop:()=>new Promise(((e,i)=>{Ss.onstop=()=>{e({blob:new Blob(a,ws),duration:Math.round(((n||Date.now())-t)/1e3),waveform:s})},Ss.onerror=i;const r=Math.max(0,t+1e3-Date.now());setTimeout((()=>{Ss.stop(),o()}),r)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{Ss.pause(),n=Date.now(),o()}),e)}}}var ks=n(1262);const Ts=["image/png","image/jpeg","image/gif"];let Ns,xs;var Bs=n(3575),As=n(9295);function Ls(e,t,n){const a=(0,In.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 Os=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,Us=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i,Fs={username:"",query:"",canShowHelp:!1,usernameLowered:""},$s=document.createElement("div");const Ds=(0,S.P2)((e=>e()),500,!0),js=/^[\w@]{1,32}\s?/i,Qs=(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 qs(){return qs=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},qs.apply(this,arguments)}let Gs,Hs=!0;const _s=(0,o.X$)((e=>{let{onActivate:t,...n}=e;const a=(0,o.sO)(!1),s=(0,o.I4)((()=>{if(a.current=!0,Hs)return Hs=!1,void t();Gs&&(clearTimeout(Gs),Gs=void 0),Gs=window.setTimeout((()=>{a.current&&t()}),200)}),[t]),i=(0,o.I4)((()=>{a.current=!1}),[]);return o.ZP.createElement(ze.Z,qs({},n,{onMouseEnter:h.$b?void 0:s,onMouseLeave:h.$b?void 0:i,onClick:h.$b?t:void 0}))})),zs=(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})),Vs=(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})),Xs=(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})),Ks=(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})),Ws=(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}));var Ys=n(7146);const 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 eo=n(9830);const to=(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 no=n(6503);const ao=(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,no.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 so=n(3616),oo=n(7891);const io=(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,oo.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(_n,{className:"inside-input",message:s,sender:i,customText:Z,title:n?"Edit Message":void 0,onClick:I})))}))),ro=(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})),co=(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})),lo=(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})),uo=(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})),mo=new RegExp(s.FM,"i"),ho=(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=Ls((()=>{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(mo);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,xt.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(Ma,{message:C,inPreview:!0,theme:l})))}))),go=(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 po;!function(e){e.Send="send",e.Record="record",e.Edit="edit",e.Schedule="schedule"}(po||(po={}));const fo="wonderful-voice-message.ogg",vo=(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,S=E?(0,r.hj)(e,d,E):void 0,{currentUserId:M}=e,R=null!=g&&g.fullInfo?(null==g||null===(n=g.fullInfo)||void 0===n?void 0:n.sendAsId)||M: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==S?void 0:S.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:M,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:M,isPollModalOpen:R,botKeyboardMessageId:k,botKeyboardPlaceholder:T,withScheduledButton:N,stickersForEmoji:x,groupChatMembers:B,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,Ps.Y)(ge),Ie=(0,o.sO)(),ye=(0,Rt.Z)(t),[Ze,be,Ee]=(0,Ue.Z)(),[Se,Me]=(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,Zs.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 xe=(0,o.sO)(!1);(0,we.Z)((e=>{let[t,n]=e;xe.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&&(Me(F),be())}),[F,be]);const[Be,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&&Ms()}),[]);const r=(0,o.I4)((async()=>{try{const{stop:t,pause:s}=await Rs((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,Pn.Z)((()=>{Ne({type:"recordAudio"})}),mt&&s.o_),(0,o.d4)((()=>{mt||Ne({type:"cancel"})}),[mt,Ne]);const ft=m?po.Edit:!h.mh||mt||ge&&!Be.length||M?n?po.Schedule:po.Send:po.Record,vt=!n,{isMentionTooltipOpen:It,closeMentionTooltip:yt,insertMention:Zt,mentionFilteredUsers:Pt}=(0,As.Z)(!Be.length,ve,pe,void 0,B,A,O),{isOpen:wt,id:bt,isGallery:Et,switchPm:St,results:Mt,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}=Ls((()=>function(e){const t=function(e){return $s.innerHTML=e.replace(/<br>/g,"\n"),$s.innerText}(e),n=t.match(Os);return n?{username:n[1],query:n[2],canShowHelp:""===n[2]&&!t.match(Us),usernameLowered:n[1].toLowerCase()}:Fs}(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(!Be.length&&U),g,ge,G),{isOpen:xt,close:Bt,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?Ds((()=>{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,ys._)(t.substr(1)).match(js);d(e?e[0]:"")}else l(void 0);else l(void 0)}),[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,Sn.Z)(gt,!(ft===po.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,ys._)(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&&!Be.length),ge,x,!r),{isEmojiTooltipOpen:Vt,closeEmojiTooltip:Xt,filteredEmojis:Kt,insertEmoji:Wt}=(0,Bs.Z)(Boolean($&&$t&&!Be.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,ps.R)(e,t))return gs(o),void a.dispatchEvent(new Event("input",{bubbles:!0}))}pe(`${ve.current}${o}`),requestAnimationFrame((()=>{(0,ds.Z)(a)}))}),[ve]),Jt=(0,o.I4)((()=>{const e=window.getSelection();if(e.rangeCount){const t=e.getRangeAt(0);if((0,ps.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(),Me(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,we.Z)((e=>{let[a]=e;n?(null==a?void 0:a.id)!==n.id&&(t((0,Ia.z)(n.content.text)),requestAnimationFrame((()=>{const e=document.getElementById(s.R2);(0,ds.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,S.Ds)((e=>e()),s.r_,!1)),[t]),g=(0,Rt.Z)(t),p=(0,Rt.Z)(n);(0,o.d4)((()=>(Ns=t,xs=n,()=>{Ns=void 0,xs=void 0,u(t,n)})),[t,n,u]),(0,o.d4)((()=>{t===g&&n===p||e&&(r((0,Ia.z)(e)),h.$b||requestAnimationFrame((()=>{const e=document.getElementById(s.R2);(0,ds.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((()=>{Ns===t&&xs===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,ks.Z)(r)),0!==c.length||i){if(c.length>0&&!n){const e=await Promise.all(c.map((e=>hs(e.name,e,1===c.length&&Ts.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=>hs(e.name,e,t)))))}),[]),on=(0,o.I4)((async(e,t)=>{Le([...Be,...await Promise.all(e.map((e=>hs(e.name,e,t))))])}),[Be]),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=Be;if(mt){const e=await dt();if(e){const{blob:t,duration:a,waveform:s}=e;n=[await hs(fo,t,!1,{voice:{duration:a,waveform:s}})]}}const{text:a,entities:o}=(0,v.Z)(ve.current);if(!n.length&&!a&&!M)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})}M&&ae({scheduledAt:t,isSilent:e}),Ie.current=(0,p.b)(Q),Y({chatId:g,localOnly:!0}),h.cj&&r===document.activeElement&&vs(r),requestAnimationFrame((()=>{en()}))}),[P,Be,mt,M,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?(Me({sticker:e}),be()):(W({sticker:e}),requestAnimationFrame((()=>{en(t)})))}),[n,be,W,en]),hn=(0,o.I4)((e=>{n?(Me({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&&vs(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?(Me({poll:e}),oe(),be()):(W({poll:e}),oe())}),[oe,be,W,n]),vn=(0,o.I4)((()=>{n?(Me({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}=Se||{},s=Math.round(Math.max(e.getTime(),Date.now()+6e4)/1e3)+(t?0:Q);Se&&0!==Object.keys(a).length?(W({...Se,scheduledAt:s}),requestAnimationFrame((()=>{en()}))):ln(Boolean(n),s),Ee()}),[Ee,ln,en,Se,W,Q]),yn=(0,o.I4)((()=>{In(new Date(1e3*s.t4),!0)}),[In]),Zn=(0,o.I4)((()=>{Ee(),Me(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]),bn=(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]),En=(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 Mn=(0,o.I4)((()=>{switch(ft){case po.Send:ln();break;case po.Record:lt();break;case po.Edit:nn();break;case po.Schedule:mt&&ut(),be()}}),[ft,ln,lt,nn,mt,be,ut]),Rn=ft===po.Record&&!jt,kn=(0,Rt.Z)(m,!0),Tn=m||kn,Nn=new Date;Nn.setSeconds(0),Nn.setMilliseconds(0);const xn=new Date;xn.setFullYear(xn.getFullYear()+1);let Bn="SendMessage";switch(ft){case po.Edit:Bn="Save edited message";break;case po.Record:Bn=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===po.Edit?nn:ft===po.Schedule?be:ln;return o.ZP.createElement("div",{className:An},jt&&r&&o.ZP.createElement(uo,{isOpen:t!==Ct.t.None,withQuick:t===Ct.t.QuickFile||ye===Ct.t.QuickFile,onHide:d,onFileSelect:sn}),o.ZP.createElement(ro,{chatId:g,threadId:f,canShowCustomSendMenu:vt,attachments:Be,caption:Be.length?ge:"",groupChatMembers:B,currentUserId:O,recentEmojis:q,isReady:r,isChatWithSelf:w,onCaptionUpdate:pe,baseEmojiKeywords:D,emojiKeywords:j,addRecentEmoji:ce,onSilentSend:vn,openCalendar:be,onSend:n?be:ln,onFileAppend:on,onClear:rn}),o.ZP.createElement(lo,{isOpen:Boolean(R),onClear:oe,onSend:fn}),Tn&&o.ZP.createElement(Qs,{isOpen:tt,isSchedule:"scheduled"===I,onClose:at,message:Tn}),o.ZP.createElement(go,{isOpen:We,onClose:et,chatId:g,selectedSendAsId:K,sendAsIds:ke}),o.ZP.createElement(Ws,{isOpen:It,onClose:yt,onInsertUserName:Zt,filteredUsers:Pt}),o.ZP.createElement(Ks,{isOpen:wt,botId:bt,isGallery:Et,inlineBotResults:Mt,switchPm:St,onSelectResult:gn,loadMore:Nt,onClose:kt}),o.ZP.createElement(to,{isOpen:xt,withUsername:Boolean(z),botCommands:At,onClick:pn,onClose:Bt}),o.ZP.createElement("div",{id:"message-compose"},o.ZP.createElement("div",{className:"svg-appendix",ref:he}),o.ZP.createElement(io,null),o.ZP.createElement(ho,{chatId:g,threadId:f,messageText:Be.length?"":ge,disabled:!qt}),o.ZP.createElement("div",{className:"message-input-wrapper"},C&&!1!==_&&!mt&&!m&&o.ZP.createElement(_s,{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:bn,ariaLabel:me("SendMessageAsTitle"),className:(0,fe.Z)("send-as-button",xe.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(_s,{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(so.Z,{id:"message-input-text",chatId:g,threadId:f,html:Be.length?"":ge,placeholder:mt&&Re<=600?"":T||me("Message"),forcedPlaceholder:Tt,canAutoFocus:r&&!Be.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:En,ariaLabel:"Open scheduled messages"},o.ZP.createElement("i",{className:"icon-schedule"})),k&&!mt&&!m&&o.ZP.createElement(_s,{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(_s,{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(eo.Z,{isOpen:Vt,emojis:Kt,onClose:Xt,onEmojiSelect:Wt,addRecentEmoji:ce}),o.ZP.createElement(Vs,{isOpen:Ge,canAttachMedia:jt,canAttachPolls:Qt,onFileSelect:sn,onPollCreate:se,onClose:_e}),k&&o.ZP.createElement(ao,{messageId:k,isOpen:Oe,onClose:De}),_&&o.ZP.createElement(co,{isOpen:je,botCommands:_,onClose:qe}),o.ZP.createElement(Xs,{chatId:g,threadId:f,isOpen:Ve,canSendGifs:Dt,canSendStickers:$t,onLoad:ot,onClose:Ke,onEmojiSelect:Yt,onStickerSelect:mn,onGifSelect:hn,onRemoveSymbol:Jt,onSearchOpen: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(Bn),onClick:Mn,onContextMenu:ft===po.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(Ys.Z,{isOpen:Lt,onSilentSend:w?void 0:vn,onScheduleSend:n?void 0:be,onClose:Ut,onCloseAnimationEnd:Ft}),o.ZP.createElement(zs,{isOpen:Ze,withTimePicker:!0,selectedAt:Nn.getTime(),maxAt:(0,L._F)(xn),isFutureMode:!0,secondButtonLabel:i?me("Schedule.SendWhenOnline"):void 0,onClose:Zn,onSubmit:In,onSecondButtonClick:i?yn:void 0}))}))),Io=(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})),yo=(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})),Zo=(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})),Po=(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})),Co=(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})),wo=(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})),bo=(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})),Eo=(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})),So=h.wB?450+s.fK:void 0;function Mo(e){return"file"===e.kind&&e.type&&s.oG.has(e.type)}const Ro=(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,lastSyncTime:p}=e,f={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,lastSyncTime:p};if(!c||!m.active)return f;const{chatId:v,threadId:I,type:y}=c,Z=(0,l.YC)(v),P=(0,r.Z1)(e,v),C=(0,r.IK)(e,v),w=Z?(0,r.dy)(e,v):void 0,b=(0,r.KB)(e,v),{chatId:E,messageId:S}=e.audioPlayer,M=P&&(0,l.Qm)(P,I),R=(0,r.pk)(e,v),k="pinned"===y,T="scheduled"===y,N="thread"===y&&I===u._f,x=Boolean(P&&(0,l.eA)(P)),B=Boolean(P&&N&&(x||(0,l.ZV)(P))&&P.isNotJoined),A=Boolean(C&&(0,r.s4)(e,C.id)),L=!A&&R;return{...f,chatId:v,threadId:I,messageListType:y,isPrivate:Z,isUserFull:Boolean(null==w?void 0:w.settings),canPost:!k&&(!P||M)&&!R,isPinnedMessageList:k,isScheduledMessageList:T,currentUserBannedRights:null==P?void 0:P.currentUserBannedRights,defaultBannedRights:null==P?void 0:P.defaultBannedRights,hasPinnedOrAudioPlayer:I!==u._f||Boolean(!k&&(null==b?void 0:b.length))||Boolean(E&&S),pinnedMessagesCount:b?b.length:0,shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,messageLists:i,isChannel:x,canSubscribe:B,canStartBot:L,canRestartBot:A}}))((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:S,isReceiptModalOpen:M,isSeenByModalOpen:R,isReactorListModalOpen:k,animationLevel:T,shouldSkipHistoryAnimations:N,currentTransitionKey:x,isChannel:B,isUserFull:A,canSubscribe:L,canStartBot:O,canRestartBot:U,activeEmojiInteractions:F,lastSyncTime:$}=e;const{openChat:D,unpinAllMessages:j,loadUser:Q,loadFullUser:q,closeLocalTextSearch:G,exitMessageSelectMode:H,closePaymentModal:_,clearReceipt:z,joinChannel:V,sendBotCommand:X,restartBot:J}=(0,a.uC)(),{width:ee}=St(),te=(0,$e.Z)(),[ne,ae]=(0,o.eJ)(Ct.t.None),[se,oe]=(0,o.eJ)(),[ie,re]=(0,o.eJ)(),[ce,le]=(0,o.eJ)(!1),de=p&&(ee<s.l3||C&&ee>s._m&&ee<s.QU||ee>=s.ks&&ee<s.jT),ue=(0,Mt.Z)(t,So),me=(0,Mt.Z)(n,So),he=(0,Mt.Z)(i,So),ge=(0,Mt.Z)(L,So),pe=(0,Mt.Z)(O,So),ve=(0,Mt.Z)(U,So),Ie=(0,Mt.Z)(u,So)&&!ve&&!pe&&!ge,ye=(0,Mt.Z)(de,So),Ze=(0,Mt.Z)(se,So),Pe=(0,Mt.Z)(B,So),Ce=(0,Rt.Z)(x),be=void 0!==Ce&&Ce<x?Ce:void 0,{isReady:Ee,handleOpenEnd:Se,handleSlideStop:Me}=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,x,Ce,t);(0,o.d4)((()=>t?(0,Ae.Z)((()=>{D({id:void 0})})):void 0),[t,D]),(0,we.Z)((()=>{ae(Ct.t.None),oe(void 0),re(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&&Q({userId:t})}),[t,r,Q]),(0,o.d4)((()=>{r&&!A&&$&&q({userId:t})}),[t,r,A,$,q]);const ke=(0,o.I4)((e=>{if(h.$b)return;const{items:t}=e.dataTransfer||{},n=t&&t.length>0&&Array.from(t).filter((e=>"text/uri-list"!==e.type)).every(Mo);ae(n?Ct.t.QuickFile:Ct.t.Document)}),[]),Te=(0,o.I4)((()=>{ae(Ct.t.None)}),[]),Ne=(0,o.I4)((()=>{le(!0)}),[]),xe=(0,o.I4)((()=>{le(!1)}),[]),Be=(0,o.I4)((()=>{j({chatId:t}),xe(),D({id:t})}),[j,D,xe,t]),Le=(0,o.I4)((()=>{D({id:t})}),[D,t]),Oe=(0,o.I4)((()=>{V({chatId:t})}),[V,t]),Ue=(0,o.I4)((()=>{X({command:"/start"})}),[X]),De=(0,o.I4)((()=>{J({chatId:t})}),[t,J]),je=((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),Qe=(0,fe.Z)(ye&&"has-header-tools",v&&"custom-bg-image",y&&"custom-bg-color",v&&w&&"blurred",h.aZ?"mask-image-disabled":"mask-image-enabled"),qe=(0,fe.Z)("messaging-disabled",!E&&"shown"),Ge=(0,l.q8)(te,m,g),{composerHiddenScale:He,toolbarHiddenScale:_e,composerTranslateX:Ve,toolbarTranslateX:Xe,unpinHiddenScale:Ke,toolbarForUnpinHiddenScale:We}=(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}}(ee,Ie)),[Ie,ee]),Ye=(0,fe.Z)("middle-column-footer",!Ie&&"no-composer",Ie&&ie&&!E&&"with-notch");(0,Re.ZP)(ue&&me,(()=>{D({id:void 0},{forceSyncOnIOs:!0})}),void 0,void 0,void 0,(null==d?void 0:d.map(wt.q))||[]),(0,Re.ZP)(b,G),(0,Re.ZP)(E,H);const Je=Boolean(!c&&!Ie&&!ve&&!pe&&!ge&&Ge),et=Boolean(ve||ge||pe||c),tt=Boolean(Je||E||c);return o.ZP.createElement("div",{id:"MiddleColumn",className:Qe,onTransitionEnd:Se,style:`\n --composer-hidden-scale: ${He};\n --toolbar-hidden-scale: ${_e};\n --unpin-hidden-scale: ${Ke};\n --toolbar-unpin-hidden-scale: ${We};\n --composer-translate-x: ${Ve}px;\n --toolbar-translate-x: ${Xe}px;\n --pattern-color: ${Z};\n --theme-background-color:\n ${y||("dark"===I?s.It:s.p3)};\n `,onClick:h.p7&&P?Le:void 0},o.ZP.createElement("div",{id:"middle-column-bg",style:je?`--custom-background: ${je}`:void 0}),o.ZP.createElement("div",{id:"middle-column-portals"}),ue&&me&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"messages-layout",onDragEnter:Ie?ke:void 0},o.ZP.createElement(mn,{chatId:ue,threadId:me,messageListType:he,isReady:Ee}),o.ZP.createElement(Fe.Z,{name:N?"none":T===s.zy?"slide":"fade",activeKey:x,shouldCleanup:!0,cleanupExceptionKey:be,onStop:Me},o.ZP.createElement(cs,{key:`${ue}-${me}-${he}`,chatId:ue,threadId:me,type:he,canPost:Ie,hasTools:ye,onFabToggle:oe,onNotchToggle:re,isReady:Ee,withBottomShift:et}),o.ZP.createElement("div",{className:Ye},Ie&&o.ZP.createElement(vo,{chatId:ue,threadId:me,messageListType:he,dropAreaState:ne,onDropHide:Te,isReady:Ee}),c&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:te.isRtl?"rtl":void 0},o.ZP.createElement(ze.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:Ne},o.ZP.createElement("i",{className:"icon-unpin"}),o.ZP.createElement("span",null,te("Chat.Pinned.UnpinAll",f,"i")))),Je&&o.ZP.createElement("div",{className:qe},o.ZP.createElement("div",{className:"messaging-disabled-inner"},o.ZP.createElement("span",null,Ge))),h.wB&&ge&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:te.isRtl?"rtl":void 0},o.ZP.createElement(ze.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Oe},te(Pe?"ProfileJoinChannel":"ProfileJoinGroup"))),h.wB&&pe&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:te.isRtl?"rtl":void 0},o.ZP.createElement(ze.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Ue},te("BotStart"))),h.wB&&ve&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:te.isRtl?"rtl":void 0},o.ZP.createElement(ze.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:De},te("BotRestart"))),o.ZP.createElement(yo,{messageListType:he,isActive:E,canPost:Ie}),o.ZP.createElement(Po,{isOpen:Boolean(S),onClose:_}),o.ZP.createElement(Co,{isOpen:Boolean(M),onClose:z}),o.ZP.createElement(wo,{isOpen:R}),o.ZP.createElement(Eo,{isOpen:k}))),o.ZP.createElement(ls,{isShown:Ze,canPost:Ie,withExtraShift:tt})),h.wB&&o.ZP.createElement(Io,{isActive:Boolean(b)})),t&&o.ZP.createElement(Zo,{isOpen:ce,chatId:t,pinnedMessagesCount:f,onClose:xe,onUnpin:Be}),o.ZP.createElement("div",{teactFastList:!0},null==F?void 0:F.map(((e,t)=>o.ZP.createElement(bo,{teactOrderKey:t,key:e.id,activeEmojiInteraction:e})))))}))),ko=(0,S.Ds)((e=>e()),200,!1);var To;!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"}(To||(To={}));const No=(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:S,isEditingInvite:M,currentInviteInfo:R}=e;const{setLocalTextSearchQuery:k,setStickerSearchQuery:T,setGifSearchQuery:N,searchTextMessagesLocal:x,toggleManagement:B,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&&ko(x)}),[x,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?To.Profile:p===m.vi.SharedMedia?To.SharedMedia:p===m.vi.MemberList?To.MemberList:-1:r?To.Search:u?To.PollResults:l?To.StickerSearch:d?To.GifSearch:g?To.AddingMembers:c?f===m.u1.Initial?To.ManageInitial:f===m.u1.ChatPrivacyType?To.ManageChatPrivacyType:f===m.u1.Discussion?To.ManageDiscussion:f===m.u1.ChannelSubscribers?To.ManageChannelSubscribers:f===m.u1.GroupPermissions?To.ManageGroupPermissions:f===m.u1.ChatAdministrators?To.ManageChatAdministrators:f===m.u1.GroupRemovedUsers?To.ManageGroupRemovedUsers:f===m.u1.ChannelRemovedUsers?To.ManageChannelRemovedUsers:f===m.u1.GroupUserPermissionsCreate?To.ManageGroupUserPermissionsCreate:f===m.u1.GroupUserPermissions?To.ManageGroupUserPermissions:f===m.u1.GroupRecentActions?To.ManageGroupRecentActions:f===m.u1.ChatAdminRights?To.ManageGroupAdminRights:f===m.u1.ChatNewAdminRights?To.ManageGroupNewAdminRights:f===m.u1.GroupMembers?To.ManageGroupMembers:f===m.u1.Invites?To.ManageInvites:f===m.u1.EditInvite?To.ManageEditInvite:f===m.u1.GroupAddAdmins?To.ManageGroupAddAdmins:f===m.u1.Reactions?To.ManageReactions:f===m.u1.InviteInfo?To.ManageInviteInfo:f===m.u1.JoinRequests?To.ManageJoinRequests:void 0:void 0,J=null!==(t=(0,xt.Z)(Y,!0))&&void 0!==t?t:-1,ee=h.wB||Y===To.SharedMedia||Y===To.MemberList||Y===To.AddingMembers||c,te=(0,fe.Z)("animated-close-icon",ee&&"state-back",(X||S)&&"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||S?"none":"slide-fade",activeKey:J},function(){if(-1!==J)switch(J){case To.PollResults:return o.ZP.createElement("h3",null,W("PollResults"));case To.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 To.AddingMembers:return o.ZP.createElement("h3",null,W(Z?"ChannelAddSubscribers":"GroupAddMembers"));case To.ManageInitial:return o.ZP.createElement("h3",null,W("Edit"));case To.ManageChatPrivacyType:return o.ZP.createElement("h3",null,W(Z?"ChannelTypeHeader":"GroupTypeHeader"));case To.ManageDiscussion:return o.ZP.createElement("h3",null,W("Discussion"));case To.ManageChatAdministrators:return o.ZP.createElement("h3",null,W("ChannelAdministrators"));case To.ManageGroupRecentActions:return o.ZP.createElement("h3",null,W("Group.Info.AdminLog"));case To.ManageGroupAdminRights:return o.ZP.createElement("h3",null,W("EditAdminRights"));case To.ManageGroupNewAdminRights:return o.ZP.createElement("h3",null,W("SetAsAdmin"));case To.ManageGroupPermissions:return o.ZP.createElement("h3",null,W("ChannelPermissions"));case To.ManageGroupRemovedUsers:return o.ZP.createElement("h3",null,W("BlockedUsers"));case To.ManageChannelRemovedUsers:return o.ZP.createElement("h3",null,W("ChannelBlockedUsers"));case To.ManageGroupUserPermissionsCreate:return o.ZP.createElement("h3",null,W("ChannelAddException"));case To.ManageGroupUserPermissions:return o.ZP.createElement("h3",null,W("UserRestrictions"));case To.ManageInvites:return o.ZP.createElement("h3",null,W("lng_group_invite_title"));case To.ManageEditInvite:return o.ZP.createElement("h3",null,W(M?"EditLink":"NewLink"));case To.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 To.ManageJoinRequests:return o.ZP.createElement("h3",null,W(Z?"SubscribeRequests":"MemberRequests"));case To.ManageGroupAddAdmins:return o.ZP.createElement("h3",null,W("Channel.Management.AddModerator"));case To.StickerSearch:return o.ZP.createElement(Ve.Z,{value:b,placeholder:W("SearchStickersHint"),autoFocusSearch:!0,onChange:_});case To.GifSearch:return o.ZP.createElement(Ve.Z,{value:E,placeholder:W("SearchGifsTitle"),autoFocusSearch:!0,onChange:z});case To.SharedMedia:return o.ZP.createElement("h3",null,W("SharedMedia"));case To.ManageChannelSubscribers:return o.ZP.createElement("h3",null,W("ChannelSubscribers"));case To.MemberList:case To.ManageGroupMembers:return o.ZP.createElement("h3",null,W("GroupMembers"));case To.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:B},o.ZP.createElement("i",{className:"icon-edit"}))))}}()))})));var xo=n(91);var Bo=n(7407);function Ao(e,t,n,a){const[o,i]=(0,Bo.Z)(n?t:void 0,a,void 0,s.Vk);return[o,i,!(!o||!a||o[0]===a[0])]}function Lo(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,Bo.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 Oo=(0,S.P2)((e=>e()),250,!1);let Uo=!1;var Fo=n(1273),$o=n(1876),Do=n(787),jo=n(180),Qo=n(3709),qo=n(5418),Go=n(7262),Ho=n(1151),_o=n(2275);const zo=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"},{type:"voice",title:"SharedVoiceTab2"}];function Vo(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > .Transition__slide--active > .${e}-list > .scroll-item`].join(", ")}const Xo=(0,o.X$)((0,a.c$)(((e,t)=>{var n,a;let{chatId:s}=t;const o=(0,r.Z1)(e,s),i=(0,r.Zw)(e,s),{currentType:c,resultsByType:d}=(0,r.we)(e)||{},{foundIds:u}=d&&c&&d[c]||{},{byId:m,statusesById:h}=e.users,{byId:g}=e.chats,p=o&&(0,l.Bf)(o),f=o&&(0,l.eA)(o),v=p||f&&(0,l.Nl)(o),I=null==o||null===(n=o.fullInfo)||void 0===n?void 0:n.members,y=v&&o&&o.fullInfo&&!o.fullInfo.canViewMembers,Z=v&&o&&((0,l.VE)(o,"inviteUsers")||o.isCreator),P=v&&o&&((0,l.VE)(o,"banUsers")||o.isCreator),C=(0,r.xs)(e,s);let w,b,E;return(0,l.YC)(s)&&(b=s,E=(0,r.dy)(e,b),w=E&&!E.isSelf&&!(0,l.cS)(E)),{theme:(0,r.Pu)(e),isChannel:f,resolvedUserId:b,chatMessages:i,foundIds:u,mediaSearchType:c,hasCommonChatsTab:w,hasMembersTab:v,areMembersHidden:y,canAddMembers:Z,canDeleteMembers:P,currentUserId:e.currentUserId,isRightColumnShown:(0,r.Jf)(e),isRestricted:null==o?void 0:o.isRestricted,lastSyncTime:e.lastSyncTime,serverTimeOffset:e.serverTimeOffset,activeDownloadIds:C,usersById:m,userStatusesById:h,chatsById:g,isChatProtected:null==o?void 0:o.isProtected,...v&&I&&{members:I},...w&&E&&{commonChatIds:null===(a=E.commonChats)||void 0===a?void 0:a.ids}}}))((e=>{let{chatId:t,profileState:n,onProfileStateChange:i,theme:r,isChannel:c,resolvedUserId:d,currentUserId:g,chatMessages:p,foundIds:f,mediaSearchType:v,hasCommonChatsTab:I,hasMembersTab:y,areMembersHidden:Z,canAddMembers:P,canDeleteMembers:C,commonChatIds:w,members:b,usersById:E,userStatusesById:S,chatsById:M,isRightColumnShown:R,isRestricted:k,lastSyncTime:T,activeDownloadIds:N,serverTimeOffset:x,isChatProtected:B}=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"}]:[],...zo,...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]=Ao(0,t,f,y),[b,E,S]=Lo("media",I,a,f,h,g),[M,R,k]=Lo("documents",I,a,f,h,g),[T,N,x]=Lo("links",I,a,f,h,g),[B,A,L]=Lo("audio",I,a,f,h,g),[O,U,F]=Lo("voice",I,a,f,h,g),[$,D,j]=Ao(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=S;break;case"documents":Q=M,q=R,G=k;break;case"links":Q=T,q=N,G=x;break;case"audio":Q=B,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,S,M,p,f,t,T,x),ae=W.findIndex((e=>{let{type:t}=e;return t===J})),{handleScroll:se}=function(e,t,n,a){(0,gn.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),Uo=!0,(0,Zn.Z)(n,s,"start",void 0,void 0,void 0,300),setTimeout((()=>{Uo=!1}),350))}}),[t,a]),(0,gn.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||(Uo=!0,(0,Zn.Z)(o,o.firstElementChild,"start",void 0,2*o.offsetHeight),setTimeout((()=>{Uo=!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)((()=>{Uo||s()}),[s,t]),{handleScroll:(0,o.I4)((()=>{Uo||Oo(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,wn.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,oo.Z)([t,J],Ie);return o.ZP.createElement(Fo.Z,{ref:G,className:"Profile custom-scroll",itemSelector:Vo(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(Do.Z,{userId:t||e}),o.ZP.createElement(jo.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(Go.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(Qo.Z,{key:e,message:p[e],isProtected:B||p[e].isProtected,observeIntersection:le,onClick:he}))):"documents"===J?ee.map((e=>p[e]&&o.ZP.createElement(zn.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(qo.Z,{key:e,message:p[e],isProtected:B||p[e].isProtected,observeIntersection:le,onMessageClick:fe}))):"audio"===J?ee.map((e=>p[e]&&o.ZP.createElement(Vn.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(Vn.Z,{key:e,theme:r,message:p[e],senderTitle:(0,xo.F)(_,p[e],M,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($o.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(Bt.Z,{userId:e,forceShowSelf:!0}));var n})):"commonChats"===J?ee.map(((e,t)=>o.ZP.createElement($o.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(Ho.Z,{isShown:"members"===J,onClick:ue,ariaLabel:_("lng_channel_add_users")},o.ZP.createElement("i",{className:"icon-add-user-filled"})),C&&o.ZP.createElement(_o.Z,{isOpen:Boolean(X),userId:X,onClose:ve}))}))),Ko=(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)})),Wo=(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)})),Yo=(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)})),ei=(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 ti=n(1820);const ni=(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]),S=(0,o.I4)((e=>{y({query:e})}),[y]),M=(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(ti.Z,{itemIds:M,selectedIds:C,filterValue:m,filterPlaceholder:P("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:h,onSelectedIdsChange:w,onFilterChange:S,noScrollRestore:b}),o.ZP.createElement(Ho.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"}))))}))),ai=Object.keys(m.qt).length/2,si=Object.keys(m.u1).length/2;function oi(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const ii=(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}=St(),[b,E]=(0,o.eJ)(m.vi.Profile),[S,M]=(0,o.eJ)(m.u1.Initial),[R,k]=(0,o.eJ)(),[T,N]=(0,o.eJ)(),x=b!==m.vi.Profile,B=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)(!B),G=null!==(t=(0,xt.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(x&&e){E(m.vi.Profile);break}u(void 0,{forceSyncOnIOs:!0});break;case m.qt.Management:switch(S){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:M(m.u1.Initial);break;case m.u1.GroupUserPermissionsCreate:case m.u1.GroupRemovedUsers:case m.u1.GroupUserPermissions:M(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:M(m.u1.ChatAdministrators);break;case m.u1.EditInvite:case m.u1.InviteInfo:M(m.u1.Invites),P({invite:void 0}),Z({chatId:i,invite:void 0})}break;case m.qt.Search:oi(),g();break;case m.qt.StickerSearch:oi(),p({query:void 0});break;case m.qt.GifSearch:oi(),f({query:void 0});break;case m.qt.PollResults:v()}}),[n,x,u,v,y,S,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(ni,{key:i,chatId:i,isActive:B&&e,onNextStep:z,onClose:H});case m.qt.ChatInfo:return o.ZP.createElement(Xo,{key:i,chatId:i,profileState:b,onProfileStateChange:E});case m.qt.Search:return o.ZP.createElement(Ko,{chatId:i,threadId:r,onClose:H,isActive:B&&e});case m.qt.Management:return o.ZP.createElement(Wo,{key:i,chatId:i,currentScreen:S,isPromotedByCurrentUser:T,selectedChatMemberId:R,isActive:B&&e,onScreenSelect:M,onChatMemberSelect:_,onClose:H});case m.qt.StickerSearch:return o.ZP.createElement(Yo,{onClose:H,isActive:B&&e});case m.qt.GifSearch:return o.ZP.createElement(Jo,{onClose:H,isActive:B&&e});case m.qt.PollResults:return o.ZP.createElement(ei,{onClose:H,isActive:B&&e})}}return(0,o.d4)((()=>B?(0,Ae.Z)(H):void 0),[B,H]),(0,o.d4)((()=>{setTimeout((()=>{q(!B)}),300)}),[B]),(0,o.d4)((()=>{d&&(M(d),C(void 0))}),[d,C]),(0,o.d4)((()=>{B&&j&&H()}),[j]),(0,hn.Z)((e=>{let[t]=e;t!==i&&(E(m.vi.Profile),M(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(No,{chatId:i,isColumnOpen:B,isProfile:A,isSearch:L,isManagement:O,isStickerSearch:U,isGifSearch:F,isPollResults:$,isAddingChatMembers:D,profileState:b,managementScreen:S,onClose:H,shouldSkipAnimation:Q||l,onScreenSelect:M}),o.ZP.createElement(Fe.Z,{name:Q||l?"none":"zoom-fade",renderCount:ai+si,activeKey:O?ai+S:G,shouldCleanup:!0},V)))}))),ri=(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 ci(e,t){const n=document.createElement("a");n.href=e,n.download=t;try{n.click()}catch(e){console.error(e)}}const li=new Set,di=(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(!li.has(t)){const n=V.UV(t);if(n)return li.delete(t),ci(n,(0,l.w6)(e)),void s({message:e});V.he(t,u.IU.BlobUrl,!0).then((n=>{li.delete(t),n&&ci(n,(0,l.w6)(e)),s({message:e})})),li.add(t)}}else s({message:e})}))}))}),[s,n,t])}))),ui=(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})),mi=(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})),hi=(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})),gi=(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})),pi=(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})),fi=(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})),vi=(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 yi,Zi=!1;function Pi(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 Ci(e){document.title!==e&&(document.title=e)}const wi=(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:M,loadAnimatedEmojis:R,loadNotificationSettings:k,loadNotificationExceptions:T,updateIsOnline:N,loadTopInlineBots:x,loadEmojiKeywords:B,loadCountryList:A,loadAvailableReactions:L,loadStickerSets:O,loadAddedStickers:U,loadFavoriteStickers:F,ensureTimeFormat:D,openStickerSetShortName:j,checkVersionNotification:Q,loadAppConfig:q}=(0,a.uC)();s.eM&&!Zi&&(Zi=!0,console.log(">>> RENDER MAIN")),(0,o.d4)((()=>{"connectionStateReady"===t&&"authorizationStateReady"===n&&M()}),[t,n,M]),(0,o.d4)((()=>{i&&(N(!0),q(),L(),R(),k(),T(),x(),B({language:s.pR}))}),[i,R,B,T,k,x,N,L,q]),(0,o.d4)((()=>{i&&(C!==s.pR&&B({language:C}),A({langCode:C}))}),[C,i,A,B]),(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,S.T2)((()=>{document.body.classList.add("animating-right-column")}));const n=(0,pe.YW)();(0,ve.L)(document.getElementById("RightColumn"),(()=>{n(),(0,S.T2)((()=>{document.body.classList.remove("animating-right-column")}))}))}),[c]);const z=(0,o.I4)((()=>{N(!1);const e=(0,$.xW)();let t=0;clearInterval(yi),yi=window.setInterval((()=>{if(document.title.includes(s.ou))Pi(!1);else{if(t%2==0){const t=(0,$.xW)()-e;t>0&&(Ci(`${t} notification${t>1?"s":""}`),Pi(!0))}else Ci(s.Ti),Pi(!1);t++}}),1e3)}),[N]),V=(0,o.I4)((()=>{N(!0),clearInterval(yi),yi=void 0,document.title.includes(s.ou)||Ci(s.Ti),Pi(!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",Me),()=>{null==be||be.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),h.cj&&!h.fl&&document.removeEventListener("gesturestart",Me)};null==be||be.setAttribute("content",Se)}}),[e])}(l),o.ZP.createElement("div",{id:"Main",className:_,onDrop:ye.Z,onDragOver:ye.Z},o.ZP.createElement(Pt,null),o.ZP.createElement(Ro,null),o.ZP.createElement(ii,null),o.ZP.createElement(ri,{isOpen:l}),o.ZP.createElement(hi,{isOpen:d}),o.ZP.createElement(ui,{isOpen:u}),o.ZP.createElement(mi,{isOpen:m}),g&&o.ZP.createElement(on,{key:g.id,message:g,noUi:!0}),o.ZP.createElement(gi,{url:f}),o.ZP.createElement(pi,{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(fi,{groupCallId:p}),o.ZP.createElement(vi,{groupCallId:p})),o.ZP.createElement(di,null),o.ZP.createElement(Ii,{isOpen:b}),o.ZP.createElement(Be,{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"},8226:(e,t,n)=>{e.exports=n.p+"map-pin.7b3c3e60ee24795e4bd2..svg"},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.36**\n\n👏 **Harder**\n• ‘Add Contact’ and ‘Block User’ buttons appear in the chat header of new chats.\n• Send media without sound or schedule it for later. Right-click the Send button on desktop, or press and hold on mobile.\n• Added support for viewing shared geo, live locations and venues.\n• Chat owners can leave their own groups without deleting them.\n• Choose from more categories when reporting specific messages.\n\n🤩 **Better**\n• Even more UX improvements.\n\n💪 **Stronger**\n• Fixed flickering menu for bot commands.\n• Copying message text on mobile devices now works as expected.\n• Fixed frozen UI when moving between chats and comments.\n"}}]);
|
||
//# sourceMappingURL=610.9b9d6fccd04efe3c170d.js.map
|