mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-15 18:57:12 +01:00
2 lines
233 KiB
JavaScript
2 lines
233 KiB
JavaScript
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[87],{4087:(e,t,s)=>{s.r(t),s.d(t,{Main:()=>Ao});var n=s(5116),a=s(3716),o=s(4050),r=(s(7895),s(307)),i=s(1638),c=s(735),l=s(2858);function d(e){const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};return t&&s?(e=(0,r.qr)(e,t,s,!1),e=(0,r.Pb)(e,t,s,void 0)):e}(0,n.Q6)("openLocalTextSearch",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};if(t&&s)return(0,r.qr)(e,t,s,!0)})),(0,n.Q6)("closeLocalTextSearch",d),(0,n.Q6)("setLocalTextSearchQuery",((e,t,s)=>{const{chatId:n,threadId:a}=(0,i.Bt)(e)||{};if(!n||!a)return;const{query:o}=s,d=(0,l.uw)(n,a),{query:u}=e.localTextSearch.byChatThreadKey[d]||{};return o!==u&&(e=(0,r.Pb)(e,n,a,c.D)),(0,r.qr)(e,n,a,!0,o)})),(0,n.Q6)("setLocalMediaSearchType",((e,t,s)=>{const{chatId:n}=(0,i.Bt)(e)||{};if(!n)return;const{mediaType:a}=s;return(0,r.z5)(e,n,a)})),(0,n.Q6)("openChat",((e,t,s)=>{const{id:a,threadId:o=-1,type:c="thread",shouldReplaceHistory:l=!1}=s,u=(0,i.Bt)(e);return u&&u.chatId===a&&u.threadId===o&&u.type===c||(e=(0,r.pf)(e,a,o,"replyStack",[]),e=d(e=(0,r.i9)(e)),e={...e,messages:{...e.messages,contentToBeScheduled:void 0},...a!==e.forwardMessages.toChatId&&{forwardMessages:{}}},(0,n.R3)(e)),(0,r.Wy)(e,a,o,c,l)})),(0,n.Q6)("openPreviousChat",(e=>(0,r.Wy)(e,void 0))),(0,n.Q6)("openChatWithInfo",((e,t,s)=>{(0,n.R3)({...e,isChatInfoShown:!0}),t.openChat(s)})),(0,n.Q6)("resetChatCreation",(e=>({...e,chatCreation:void 0}))),(0,n.Q6)("setNewChatMembersDialogState",((e,t,s)=>({...e,newChatMembersProgress:s}))),(0,n.Q6)("openNextChat",((e,t,s)=>{const{targetIndexDelta:n,orderedIds:a}=s,{chatId:o}=(0,i.Bt)(e)||{};if(!o)return void t.openChat({id:a[0]});const r=a.indexOf(o);if(-1===r)return;const c=a[r+n];t.openChat({id:c,shouldReplaceHistory:!0})}));var u=s(6137),m=s(1713),h=s(7361),g=s(782),p=s(2267),f=s(3099);const I=a.ck+a.fK;let v;(0,n.Q6)("setScrollOffset",((e,t,s)=>{const{chatId:n,threadId:a,scrollOffset:o}=s;return(0,r.pf)(e,n,a,"scrollOffset",o)})),(0,n.Q6)("setReplyingToId",((e,t,s)=>{const{messageId:n}=s,a=(0,i.Bt)(e);if(!a)return;const{chatId:o,threadId:c}=a;return(0,r.pf)(e,o,c,"replyingToId",n)})),(0,n.Q6)("setEditingId",((e,t,s)=>{const{messageId:n}=s,a=(0,i.Bt)(e);if(!a)return;const{chatId:o,threadId:c,type:l}=a,d="scheduled"===l?"editingScheduledId":"editingId";return(0,r.pf)(e,o,c,d,n)})),(0,n.Q6)("editLastMessage",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{};if(!t||!s)return;const n=(0,i.Zw)(e,t),a=(0,i.Cb)(e,t,s);if(!n||!a)return;const o=(0,g.dF)(a,(t=>Boolean(n[t]&&(0,i._k)(e,n[t],s).canEdit)));return o?(0,r.pf)(e,t,s,"editingId",o):void 0})),(0,n.Q6)("replyToNextMessage",((e,t,s)=>{const{targetIndexDelta:n}=s,{chatId:a,threadId:o}=(0,i.Bt)(e)||{};if(!a||!o)return;const r=(0,i.Zw)(e,a),c=(0,i.Cb)(e,a,o);if(!r||!c)return;const l=(0,i.Yy)(e,a,o);let d;if((0,i.b9)(e,a,o)&&l){const e=Object.keys(r),t=e.indexOf(l.toString())+n;d=t<=e.length+1&&t>=0?Number(e[t]):void 0}else if(o===u._f){var m;const t=(0,i.Z1)(e,a);d=null==t||null===(m=t.lastMessage)||void 0===m?void 0:m.id}else{const t=(0,i.tZ)(e,a,o);d=null==t?void 0:t.lastMessageId}t.setReplyingToId({messageId:d}),t.focusMessage({chatId:a,threadId:o,messageId:d})})),(0,n.Q6)("openMediaViewer",((e,t,s)=>{const{chatId:n,threadId:a,messageId:o,avatarOwnerId:r,profilePhotoIndex:i,origin:c}=s;return{...e,mediaViewer:{chatId:n,threadId:a,messageId:o,avatarOwnerId:r,profilePhotoIndex:i,origin:c},forwardMessages:{}}})),(0,n.Q6)("closeMediaViewer",(e=>({...e,mediaViewer:{}}))),(0,n.Q6)("openAudioPlayer",((e,t,s)=>{const{chatId:n,threadId:a,messageId:o,origin:r,volume:i,playbackRate:c,isMuted:l}=s;return{...e,audioPlayer:{chatId:n,threadId:a,messageId:o,origin:null!=r?r:e.audioPlayer.origin,volume:null!=i?i:e.audioPlayer.volume,playbackRate:c||e.audioPlayer.playbackRate,isMuted:l||e.audioPlayer.isMuted}}})),(0,n.Q6)("setAudioPlayerVolume",((e,t,s)=>{const{volume:n}=s;return{...e,audioPlayer:{...e.audioPlayer,volume:n}}})),(0,n.Q6)("setAudioPlayerPlaybackRate",((e,t,s)=>{const{playbackRate:n}=s;return{...e,audioPlayer:{...e.audioPlayer,playbackRate:n}}})),(0,n.Q6)("setAudioPlayerMuted",((e,t,s)=>{const{isMuted:n}=s;return{...e,audioPlayer:{...e.audioPlayer,isMuted:n}}})),(0,n.Q6)("setAudioPlayerOrigin",((e,t,s)=>{const{origin:n}=s;return{...e,audioPlayer:{...e.audioPlayer,origin:n}}})),(0,n.Q6)("closeAudioPlayer",(e=>({...e,audioPlayer:{volume:e.audioPlayer.volume,playbackRate:e.audioPlayer.playbackRate,isMuted:e.audioPlayer.isMuted}}))),(0,n.Q6)("openPollResults",((e,t,s)=>{const{chatId:a,messageId:o}=s;(0,i.Jf)(e)?a===e.pollResults.chatId&&o===e.pollResults.messageId||(0,n.R3)({...e,pollResults:{chatId:a,messageId:o,voters:{}}}):window.setTimeout((()=>{const e=(0,n.Rd)();(0,n.R3)({...e,pollResults:{chatId:a,messageId:o,voters:{}}})}),450)})),(0,n.Q6)("closePollResults",(e=>{(0,n.R3)({...e,pollResults:{}})})),(0,n.Q6)("focusLastMessage",((e,t)=>{const s=(0,i.Bt)(e);if(!s)return;const{chatId:n,threadId:a}=s;let o;if(a===u._f){var r;const t=(0,i.Z1)(e,n);o=null==t||null===(r=t.lastMessage)||void 0===r?void 0:r.id}else{const t=(0,i.tZ)(e,n,a);o=null==t?void 0:t.lastMessageId}o&&t.focusMessage({chatId:n,threadId:a,messageId:o,noHighlight:!0})})),(0,n.Q6)("focusNextReply",((e,t)=>{const s=(0,i.Bt)(e);if(!s)return;const{chatId:a,threadId:o}=s,c=(0,i.p9)(e,a,o);if(c&&0!==c.length){const s=c.pop();e=(0,r.pf)(e,a,o,"replyStack",[...c]),(0,n.R3)(e),t.focusMessage({chatId:a,threadId:o,messageId:s})}else t.focusLastMessage()})),(0,n.Q6)("focusMessage",((e,t,s)=>{const{chatId:a,threadId:o=u._f,messageListType:c="thread",noHighlight:l,groupedId:d,groupedChatId:h,replyMessageId:g,isResizingContainer:p}=s;let{messageId:f}=s;if(void 0!==d){const t=(0,i.y8)(e,h,d);null!=t&&t.length&&([f]=t)}const y=(0,i.Bt)(e),Z=!y||a!==y.chatId||o!==y.threadId||c!==y.type;if(v&&(clearTimeout(v),v=void 0),v=window.setTimeout((()=>{let e=(0,n.Rd)();e=(0,r.cq)(e),e=(0,r.wV)(e),(0,n.R3)(e)}),l?I:1500),e=(0,r.cq)(e,a,f,l,p),e=(0,r.wV)(e,void 0),g){const t=(0,i.p9)(e,a,o)||[];e=(0,r.pf)(e,a,o,"replyStack",[...t,g])}Z&&(e=(0,r.wV)(e,m.fo.Static));const P=(0,i.Cb)(e,a,o);if(P&&P.includes(f))return(0,n.R3)(e),void t.openChat({id:a,threadId:o});if(Z&&(e=(0,r.pf)(e,a,o,"viewportIds",void 0)),e=(0,r.pf)(e,a,o,"outlyingIds",void 0),P&&!Z){const t=f>P[0]?m.fo.Down:m.fo.Up;e=(0,r.wV)(e,t)}(0,n.R3)(e),t.openChat({id:a,threadId:o}),t.loadViewportMessages()})),(0,n.Q6)("openForwardMenu",((e,t,s)=>{const{fromChatId:n,messageIds:a,groupedId:o}=s;let r;return o&&(r=(0,i.xH)(e,n,o)),{...e,forwardMessages:{fromChatId:n,messageIds:r||a,isModalShown:!0}}})),(0,n.Q6)("exitForwardMode",(e=>{(0,n.R3)({...e,forwardMessages:{}})})),(0,n.Q6)("setForwardChatId",((e,t,s)=>{const{id:a}=s;(0,n.R3)({...e,forwardMessages:{...e.forwardMessages,toChatId:a,isModalShown:!1}}),t.openChat({id:a}),t.closeMediaViewer(),t.exitMessageSelectMode()})),(0,n.Q6)("openForwardMenuForSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:s,messageIds:n}=e.selectedMessages;t.openForwardMenu({fromChatId:s,messageIds:n})})),(0,n.Q6)("cancelMessageMediaDownload",((e,t,s)=>{const{message:a}=s,o=e.activeDownloads.byChatId[a.chatId];o&&o.length&&(0,n.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[a.chatId]:o.filter((e=>e!==a.id))}}})})),(0,n.Q6)("downloadMessageMedia",((e,t,s)=>{const{message:a}=s;a&&(0,n.R3)({...e,activeDownloads:{byChatId:{...e.activeDownloads.byChatId,[a.chatId]:[...e.activeDownloads.byChatId[a.chatId]||[],a.id]}}})})),(0,n.Q6)("downloadSelectedMessages",((e,t)=>{if(!e.selectedMessages)return;const{chatId:s,messageIds:n}=e.selectedMessages,{threadId:a}=(0,i.Bt)(e)||{},o=(0,i.Zw)(e,s);o&&a&&n.map((e=>o[e])).filter((t=>(0,i._k)(e,t,a).canDownload)).forEach((e=>t.downloadMessageMedia({message:e})))})),(0,n.Q6)("enterMessageSelectMode",((e,t,s)=>{const{messageId:n}=s||{},a=(0,i.jr)(e);return a?(0,r.M6)(e,a.id,n):e})),(0,n.Q6)("toggleMessageSelection",((e,t,s)=>{const{messageId:a,groupedId:o,childMessageIds:c,withShift:l}=s,d=(0,i.Bt)(e);if(!d)return;const{chatId:u,threadId:m,type:g}=d;e=(0,r.Ob)(e,u,m,g,a,o,c,l),(0,n.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,n.Q6)("disableContextMenuHint",(e=>{if(e.shouldShowContextMenuHint)return{...e,shouldShowContextMenuHint:!1}})),(0,n.Q6)("exitMessageSelectMode",r.i9),(0,n.Q6)("openPollModal",(e=>({...e,isPollModalOpen:!0}))),(0,n.Q6)("closePollModal",(e=>({...e,isPollModalOpen:!1}))),(0,n.Q6)("checkVersionNotification",((e,t)=>{const s=a.Ji.split(".").slice(0,2).join("."),{serviceNotifications:n}=e;if(n.find((({version:e})=>e===s)))return;const o={chatId:a.aw,date:(0,p.b)(e.serverTimeOffset),content:{text:(0,f.Z)('**Telegram Web Z was updated to version 1.28**\n\n👏 **Harder**\n• Support for join requests in groups and channels.\n• Support for more service messages.\n\n🤩 **Better**\n• Easier to select and adjust left column width.\n• Redundant single quotes removed in Spanish and French translations.\n• Support for hotkeys on non-qwerty keyboards.\n• Use Ctrl+Shift+F or Ctrl+F (in PWA mode) to open global or local search.\n• Chat: "Add to folder..." only appears for users with folders.\n• Support for `start` parameter in `tg://resolve` links.\n\n💪 **Stronger**\n• Fixed focusing on messages in a chat that was previously open.\n• Fixed missing stickers in sticker suggestions.\n• Fixed opening chats from user mentions.\n• Fixed various glitches when appearing as a channel in public groups.\n• Removed redundant download and forward options in chats with protected content.\n')},isOutgoing:!1};t.createServiceNotification({message:o,version:s})})),(0,n.Q6)("createServiceNotification",((e,t,s)=>{var o;const{message:r,version:c}=s,{serviceNotifications:l}=e,d=(0,i.Z1)(e,a.aw),u=Math.max((null===(o=d.lastMessage)||void 0===o?void 0:o.id)||0,...l.map((({id:e})=>e))),m=(l.length+1)/1e3,h=Math.floor(u)+m;r.id=h;const g={id:h,message:r,version:c,isUnread:!0};(0,n.R3)({...e,serviceNotifications:[...l.slice(-1e3),g]}),t.apiUpdate({"@type":"newMessage",id:r.id,chatId:r.chatId,message:r})})),(0,n.Q6)("openSeenByModal",((e,t,s)=>{const{chatId:n,messageId:a}=s;return{...e,seenByModal:{chatId:n,messageId:a}}})),(0,n.Q6)("closeSeenByModal",(e=>({...e,seenByModal:void 0}))),(0,n.Q6)("setGlobalSearchQuery",((e,t,s)=>{const{query:n}=s,{chatId:a}=e.globalSearch;return(0,r.No)(e,{globalResults:{},localResults:{},resultsByType:void 0,...n?{fetchingStatus:{chats:!a,messages:!0}}:{fetchingStatus:void 0},query:n})})),(0,n.Q6)("addRecentlyFoundChatId",((e,t,s)=>{const{id:n}=s,{recentlyFoundChatIds:a}=e.globalSearch;if(!a)return(0,r.No)(e,{recentlyFoundChatIds:[n]});const o=a.filter((e=>e!==n));return o.unshift(n),o.length>10&&o.pop(),(0,r.No)(e,{recentlyFoundChatIds:o})})),(0,n.Q6)("clearRecentlyFoundChats",(e=>(0,r.No)(e,{recentlyFoundChatIds:void 0}))),(0,n.Q6)("setGlobalSearchContent",((e,t,s)=>{const{content:n}=s;return(0,r.Og)(e,n)})),(0,n.Q6)("setGlobalSearchChatId",((e,t,s)=>{const{id:n}=s;return(0,r.No)(e,{chatId:n,query:void 0,resultsByType:void 0})})),(0,n.Q6)("setStickerSearchQuery",((e,t,s)=>{const{query:n}=s;return{...e,stickers:{...e.stickers,search:{query:n,resultIds:void 0}}}})),(0,n.Q6)("setGifSearchQuery",((e,t,s)=>{const{query:n}=s;return{...e,gifs:{...e.gifs,search:{query:n,offsetId:void 0,results:void 0}}}})),(0,n.Q6)("openUserInfo",((e,t,s)=>{const{id:n}=s;t.openChat({id:n})})),(0,n.Q6)("openChat",(e=>(0,r.x1)(e,void 0))),(0,n.Q6)("setUserSearchQuery",((e,t,s)=>{const{query:n}=s;return(0,r.Lm)(e,{globalUserIds:void 0,localUserIds:void 0,fetchingStatus:Boolean(n),query:n})})),s(3781);var y=s(1947),Z=s(6926);(0,n.Q6)("toggleChatInfo",(e=>({...e,isChatInfoShown:!e.isChatInfoShown}))),(0,n.Q6)("setLeftColumnWidth",((e,t,s)=>({...e,leftColumnWidth:s}))),(0,n.Q6)("resetLeftColumnWidth",(e=>({...e,leftColumnWidth:void 0}))),(0,n.Q6)("toggleManagement",(e=>{const{chatId:t}=(0,i.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!(e.management.byChatId[t]||{}).isActive}}}}})),(0,n.Q6)("closeManagement",(e=>{const{chatId:t}=(0,i.Bt)(e)||{};if(t)return{...e,management:{byChatId:{...e.management.byChatId,[t]:{...e.management.byChatId[t],isActive:!1}}}}})),(0,n.Q6)("openChat",(e=>{if(h.wB||h.p7)return{...e,isLeftColumnShown:0===e.messages.messageLists.length}})),(0,n.Q6)("toggleLeftColumn",(e=>({...e,isLeftColumnShown:!e.isLeftColumnShown}))),(0,n.Q6)("addRecentEmoji",((e,t,s)=>{const{emoji:n}=s,{recentEmojis:a}=e;if(!a)return{...e,recentEmojis:[n]};const o=a.filter((e=>e!==n));return o.unshift(n),o.length>18&&o.pop(),{...e,recentEmojis:o}})),(0,n.Q6)("addRecentSticker",((e,t,s)=>{const{sticker:n}=s,{recent:a}=e.stickers;if(!a)return{...e,stickers:{...e.stickers,recent:{hash:"0",stickers:[n]}}};const o=a.stickers.filter((e=>e.id!==n.id));return o.unshift(n),{...e,stickers:{...e.stickers,recent:{...a,stickers:o}}}})),(0,n.Q6)("showNotification",((e,t,s)=>{const n=s;n.localId=(0,Z.Z)({});const a=[...e.notifications],o=a.findIndex((e=>e.message===n.message));return-1!==o&&a.splice(o,1),a.push(n),{...e,notifications:a}})),(0,n.Q6)("dismissNotification",((e,t,s)=>{const n=e.notifications.filter((({localId:e})=>e!==s.localId));return{...e,notifications:n}})),(0,n.Q6)("showDialog",((e,t,s)=>{const{data:n}=s;if("message"in n&&n.hasErrorKey&&!(0,y.ZP)(n))return e;const a=[...e.dialogs];if("message"in n){const e=a.findIndex((e=>e.message===n.message));-1!==e&&a.splice(e,1)}return a.push(n),{...e,dialogs:a}})),(0,n.Q6)("dismissDialog",(e=>{const t=[...e.dialogs];return t.pop(),{...e,dialogs:t}})),(0,n.Q6)("toggleSafeLinkModal",((e,t,s)=>{const{url:n}=s;return{...e,safeLinkModalUrl:n}})),(0,n.Q6)("openHistoryCalendar",((e,t,s)=>{const{selectedAt:n}=s;return{...e,historyCalendarSelectedAt:n}})),(0,n.Q6)("closeHistoryCalendar",(e=>({...e,historyCalendarSelectedAt:void 0}))),(0,n.Q6)("openPaymentModal",((e,t,s)=>{const{chatId:n,messageId:a}=s;return{...e,payment:{...e.payment,chatId:n,messageId:a,isPaymentModalOpen:!0}}})),(0,n.Q6)("closePaymentModal",(e=>{const t=(0,r.bp)(e);return(0,r.WY)(t)})),(0,n.Q6)("addPaymentError",((e,t,s)=>{const{error:n}=s;return{...e,payment:{...e.payment,error:n}}})),s(1689),s(1363),s(6204);var P=s(1226),C=s(9118);const w=new Map,b=(0,C.Ds)((e=>e()),500,!1);async function S(e,t,s,o,c=!1,l=!1){const d=e.id;let u;switch(o){case m.Uq.Backwards:u=void 0;break;case m.Uq.Around:u=-(Math.round(a.hT/2)+1);break;case m.Uq.Forwards:u=-(a.hT+1)}const h=await(0,P.t9)("fetchMessages",{chat:(0,i.Cm)((0,n.Rd)(),d,t),offsetId:s,addOffset:u,limit:a.hT,threadId:t});if(!h)return;const{messages:p,users:f,chats:I,threadInfos:v}=h;let y=(0,n.Rd)();const Z=d===a.aw?y.serviceNotifications.map((({message:e})=>e)):[],C=[].concat(p,Z),w=(0,g.ee)(C,"id"),b=Object.keys(w).map(Number);y=(0,r.c_)(y,d,w),y=c?(0,r.ff)(y,d,t,b):(0,r.xj)(y,d,t,b),y=(0,r.Sh)(y,(0,g.ee)(f,"id")),y=(0,r.fZ)(y,(0,g.ee)(I,"id")),y=(0,r.j6)(y,d,v);let S=(0,i.gb)(y,d,t);const M=(0,i.qC)(y,d,t);if(c&&S&&M&&(M.length&&!(0,g.YE)(S,M)||(y=(0,r.xj)(y,d,t,M),S=(0,i.gb)(y,d,t),y=(0,r.pf)(y,d,t,"outlyingIds",void 0),c=!1)),!l){const e=c?M:S,{newViewportIds:n}=E(e,s,o);y=(0,r.y9)(y,d,t,n)}(0,n.R3)(y)}function E(e,t,s){const{length:n}=e,o=t?function(e,t){return t<e[0]?0:t>e[e.length-1]?e.length-1:e.findIndex(((s,n)=>s===t||s<t&&e[n+1]>t))}(e,t):-1,r=s===m.Uq.Backwards?o:o+1||n,i=r-a.hT,c=r+a.hT-1,l=e.slice(Math.max(0,i),c+1);let d,u;switch(s){case m.Uq.Backwards:d=r>0,u=i>=0;break;case m.Uq.Forwards:d=r<n,u=c<=n-1;break;case m.Uq.Around:default:d=l.length>0,u=l.length===a.hT}return{newViewportIds:l,areSomeLocal:d,areAllLocal:u}}async function M(e){let t;const s=e.attachment?(e,a)=>{w.has(a)||(t=a,w.set(a,s));const o=(0,n.Rd)();(0,n.R3)({...o,fileUploads:{byMessageLocalId:{...o.fileUploads.byMessageLocalId,[a]:{progress:e}}}})}:void 0;(e.replyingTo||h.cj)&&await(0,C.Pn)();const a=(0,n.Rd)();e.serverTimeOffset=a.serverTimeOffset;const o=(0,i.Bt)(a);if(!o)return;const{threadId:r}=o;e.replyingTo||r===u._f||(e.replyingTo=(0,i.qS)(a,e.chat.id,r)),await(0,P.t9)("sendMessage",e,s),s&&t&&w.delete(t)}(0,n.Q6)("loadViewportMessages",((e,t,s)=>{const{direction:n=m.Uq.Around,isBudgetPreload:o=!1}=s||{};let{chatId:c,threadId:l}=s||{};if(!c){const t=(0,i.Bt)(e);if(!t)return;c=t.chatId,l=t.threadId}const d=(0,i.Z1)(e,c);if(!d||d.isRestricted)return;const u=(0,i.Cb)(e,c,l),h=(0,i.gb)(e,c,l),g=(0,i.qC)(e,c,l);if(u&&u.length&&n!==m.Uq.Around){const s=n===m.Uq.Backwards?u[0]:u[u.length-1],a=Boolean(g),i=a?g:h,{newViewportIds:p,areSomeLocal:f,areAllLocal:I}=E(i,s,n);if(f&&(e=(0,r.y9)(e,c,l,p)),async function(e,t,s,n,a,o,r,i){t||await S(a,o,i,r,s,n),n||(await Promise.resolve(),e.loadViewportMessages({chatId:a.id,threadId:o,direction:r,isBudgetPreload:!0}))}(t,I,a,o,d,l,n,s),o)return}else{const t=(0,i.G$)(e,c)||(0,i.rd)(e,c,l),s=Boolean(t&&h&&!h.includes(t)),n=(s?g:h)||[],{newViewportIds:u,areSomeLocal:p,areAllLocal:f}=E(n,t,m.Uq.Around);p&&u.length>=a.hT&&(e=(0,r.y9)(e,c,l,u)),f||S(d,l,t,m.Uq.Around,s,o)}return e})),(0,n.Q6)("loadMessage",((e,t,s)=>{const{chatId:a,messageId:o,replyOriginForId:c,threadUpdate:l}=s,d=(0,i.Z1)(e,a);d&&(async()=>{const e=await async function(e,t,s){const a=await(0,P.t9)("fetchMessage",{chat:e,messageId:t});if(!a)return;if(a===u._Q){if(s){let t=(0,n.Rd)();const a=(0,i.hj)(t,e.id,s);t=(0,r.cY)(t,e.id,s,{...a,replyToMessageId:void 0}),(0,n.R3)(t)}return}let o=(0,n.Rd)();return o=(0,r.cY)(o,e.id,t,a.message),o=(0,r.Sh)(o,(0,g.ee)(a.users,"id")),(0,n.R3)(o),a.message}(d,o,c);if(e&&l){const{lastMessageId:t,isDeleting:s}=l;(0,n.R3)((0,r.lG)((0,n.Rd)(),e,a,t,s))}})()})),(0,n.Q6)("sendMessage",((e,t,s)=>{const n=(0,i.Bt)(e);if(!n)return;const{chatId:o,threadId:r,type:c}=n;if("scheduled"===c&&!s.scheduledAt)return{...e,messages:{...e.messages,contentToBeScheduled:s}};const l=(0,i.Z1)(e,o);t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:o,threadId:r,value:!1});const d={...s,chat:l,replyingTo:(0,i.Yy)(e,o,r),noWebPage:(0,i.tV)(e,o,r),sendAs:(0,i._5)(e,o)},u=!s.attachments||s.attachments.length<=1,m=!u&&s.attachments&&s.attachments.length>1;if(u){const{attachments:e,...t}=d;M({...t,attachment:e?e[0]:void 0})}else if(m){const{text:e,entities:t,attachments:s,...n}=d,o=(0,g.Vl)(s,a.DU);for(let s=0;s<o.length;s++){const[a,...r]=o[s],i=`${Date.now()}${s}`;M({...n,text:0===s?e:void 0,entities:0===s?t:void 0,attachment:a,groupedId:r.length>0?i:void 0}),r.forEach((e=>{M({...n,attachment:e,groupedId:i})}))}}else{const{text:e,entities:t,attachments:s,replyingTo:n,...a}=d;e&&M({...a,text:e,entities:t,replyingTo:n}),s.forEach((e=>{M({...a,attachment:e})}))}})),(0,n.Q6)("editMessage",((e,t,s)=>{const{serverTimeOffset:n}=e,{text:a,entities:o}=s,r=(0,i.Bt)(e);if(!r)return;const{chatId:c,threadId:l,type:d}=r,u=(0,i.Z1)(e,c),m=(0,i.kK)(e,c,l,d);u&&m&&((0,P.t9)("editMessage",{chat:u,message:m,text:a,entities:o,noWebPage:(0,i.tV)(e,c,l),serverTimeOffset:n}),t.setEditingId({messageId:void 0}))})),(0,n.Q6)("cancelSendingMessage",((e,t,s)=>{const{chatId:n,messageId:a}=s,o=(0,i.hj)(e,n,a),r=o&&w.get(o.previousLocalId||o.id);r&&(0,P.u3)(r),t.apiUpdate({"@type":"deleteMessages",ids:[a],chatId:n})})),(0,n.Q6)("saveDraft",((e,t,s)=>{const{chatId:n,threadId:a,draft:o}=s;if(!o)return;const{text:c,entities:l}=o,d=(0,i.Z1)(e,n);return a===u._f&&(0,P.t9)("saveDraft",{chat:d,text:c,entities:l,replyToMsgId:(0,i.Yy)(e,n,a)}),e=(0,r.pf)(e,n,a,"draft",o),(0,r.a4)(e,n,{draftDate:Math.round(Date.now()/1e3)})})),(0,n.Q6)("clearDraft",((e,t,s)=>{const{chatId:n,threadId:a,localOnly:o}=s;if(!(0,i.Ms)(e,n,a))return;const c=(0,i.Z1)(e,n);return o||a!==u._f||(0,P.t9)("clearDraft",c),e=(0,r.pf)(e,n,a,"draft",void 0),(0,r.a4)(e,n,{draftDate:void 0})})),(0,n.Q6)("toggleMessageWebPage",((e,t,s)=>{const{chatId:n,threadId:a,noWebPage:o}=s;return(0,r.pf)(e,n,a,"noWebPage",o)})),(0,n.Q6)("pinMessage",((e,t,s)=>{const n=(0,i.jr)(e);if(!n)return;const{messageId:a,isUnpin:o,isOneSide:r,isSilent:c}=s;(0,P.t9)("pinMessage",{chat:n,messageId:a,isUnpin:o,isOneSide:r,isSilent:c})})),(0,n.Q6)("unpinAllMessages",((e,t,s)=>{const a=(0,i.Z1)(e,s.chatId);a&&async function(e){await(0,P.t9)("unpinAllMessages",{chat:e});let t=(0,n.Rd)();t=(0,r.pf)(t,e.id,u._f,"pinnedIds",[]),(0,n.R3)(t)}(a)})),(0,n.Q6)("deleteMessages",((e,t,s)=>{const{messageIds:n,shouldDeleteForAll:a}=s,o=(0,i.Bt)(e);if(!o)return;const{chatId:r,threadId:c}=o,l=(0,i.Z1)(e,r);(0,P.t9)("deleteMessages",{chat:l,messageIds:n,shouldDeleteForAll:a});const d=(0,i._$)(e,r,c);n.includes(d)&&t.setEditingId({messageId:void 0})})),(0,n.Q6)("deleteScheduledMessages",((e,t,s)=>{const{messageIds:n}=s,a=(0,i.Bt)(e);if(!a)return;const{chatId:o}=a,r=(0,i.Z1)(e,o);(0,P.t9)("deleteScheduledMessages",{chat:r,messageIds:n});const c=(0,i.wU)(e,o);n.includes(c)&&t.setEditingId({messageId:void 0})})),(0,n.Q6)("deleteHistory",((e,t,s)=>{(async()=>{var n;const{chatId:a,shouldDeleteForAll:o}=s,r=(0,i.Z1)(e,a);if(!r)return;const c=null===(n=r.lastMessage)||void 0===n?void 0:n.id;await(0,P.t9)("deleteHistory",{chat:r,shouldDeleteForAll:o,maxId:c});const l=(0,i.Bt)(e);l&&l.chatId===a&&t.openChat({id:void 0})})()})),(0,n.Q6)("reportMessages",((e,t,s)=>{(async()=>{const{messageIds:n,reason:a,description:o}=s,r=(0,i.Bt)(e);if(!r)return;const{chatId:c}=r,l=(0,i.Z1)(e,c),d=await(0,P.t9)("reportMessages",{peer:l,messageIds:n,reason:a,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,n.Q6)("sendMessageAction",((e,t,s)=>{(async()=>{const{action:t,chatId:n,threadId:a}=s;if(n===e.currentUserId)return;const o=(0,i.Z1)(e,n);o&&await(0,P.t9)("sendMessageAction",{peer:o,threadId:a,action:t})})()})),(0,n.Q6)("markMessageListRead",((e,t,s)=>{const{serverTimeOffset:n}=e,o=(0,i.Bt)(e);if(!o)return;const{chatId:c,threadId:l}=o,d=(0,i.Cm)(e,c,l);if(!d)return;const{maxId:m}=s;if(b((()=>{(0,P.t9)("markMessageListRead",{serverTimeOffset:n,chat:d,threadId:l,maxId:m})})),l!==u._f)return;c===a.aw&&(e={...e,serviceNotifications:e.serviceNotifications.map((e=>e.isUnread&&e.id<=m?{...e,isUnread:!1}:e))});const h=(0,i.Cb)(e,c,l),g=(0,i.It)(e,c,l);if(!h||!g||!d.unreadCount)return e;const p=function(e,t,s){let n=0;for(let a=0,o=e.length;a<o&&(e[a]>=t&&e[a]<=s&&n++,!(e[a]>=s));a++);return n}(h,g,m);return p?(0,r.a4)(e,c,{lastReadInboxMessageId:m,unreadCount:Math.max(0,d.unreadCount-p)}):e})),(0,n.Q6)("markMessagesRead",((e,t,s)=>{const n=(0,i.jr)(e);if(!n)return;const{messageIds:a}=s;(0,P.t9)("markMessagesRead",{chat:n,messageIds:a})})),(0,n.Q6)("loadWebPagePreview",((e,t,s)=>{const{text:a}=s;!async function(e){const t=await(0,P.t9)("fetchWebPagePreview",{message:e});(0,n.R3)({...(0,n.Rd)(),webPagePreview:t})}(a)})),(0,n.Q6)("clearWebPagePreview",(e=>{if(e.webPagePreview)return{...e,webPagePreview:void 0}})),(0,n.Q6)("sendPollVote",((e,t,s)=>{const{chatId:n,messageId:a,options:o}=s,r=(0,i.Z1)(e,n);r&&(0,P.t9)("sendPollVote",{chat:r,messageId:a,options:o})})),(0,n.Q6)("loadPollOptionResults",((e,t,s)=>{const{chat:a,messageId:o,option:i,offset:c,limit:l,shouldResetVoters:d}=s;!async function(e,t,s,a,o,i){const c=await(0,P.t9)("loadPollOptionResults",{chat:e,messageId:t,option:s,offset:a,limit:o});if(!c)return;let l=(0,n.Rd)();l=(0,r.Sh)(l,(0,g.ee)(c.users,"id"));const{voters:d}=l.pollResults;(0,n.R3)({...l,pollResults:{...l.pollResults,voters:{...d,[s]:(0,g.Tw)([...!i&&d&&d[s]?d[s]:[],...c&&c.users.map((e=>e.id))])},offsets:{...l.pollResults.offsets?l.pollResults.offsets:{},[s]:c.nextOffset||""}}})}(a,o,i,c,l,d)})),(0,n.Q6)("forwardMessages",((e,t,s)=>{const{fromChatId:a,messageIds:o,toChatId:r}=e.forwardMessages,c=a?(0,i.Z1)(e,a):void 0,d=r?(0,i.Z1)(e,r):void 0,u=a&&o?o.sort(((e,t)=>e-t)).map((t=>(0,i.hj)(e,a,t))).filter(Boolean):void 0;if(!c||!d||!u)return;const{isSilent:m,scheduledAt:h}=s,g=(0,i._5)(e,r),p=u.filter((e=>!(0,l.jM)(e)));p.length&&(0,P.t9)("forwardMessages",{fromChat:c,toChat:d,messages:p,serverTimeOffset:(0,n.Rd)().serverTimeOffset,isSilent:m,scheduledAt:h,sendAs:g}),u.filter((e=>(0,l.jM)(e))).forEach((e=>{const{text:t,entities:s}=e.content.text||{},{sticker:n,poll:a}=e.content;M({chat:d,text:t,entities:s,sticker:n,poll:a,isSilent:m,scheduledAt:h,sendAs:g})})),(0,n.R3)({...(0,n.Rd)(),forwardMessages:{}})})),(0,n.Q6)("loadScheduledHistory",((e,t,s)=>{const{chatId:a}=s,o=(0,i.Z1)(e,a);o&&async function(e){const t=await(0,P.t9)("fetchScheduledHistory",{chat:e});if(!t)return;const{messages:s}=t,a=(0,g.ee)(s,"id"),o=Object.keys(a).map(Number).sort(((e,t)=>t-e));let i=(0,n.Rd)();i=(0,r.w3)(i,e.id,a),i=(0,r.pf)(i,e.id,u._f,"scheduledIds",o),(0,n.R3)(i)}(o)})),(0,n.Q6)("sendScheduledMessages",((e,t,s)=>{const{chatId:n,id:a}=s,o=(0,i.Z1)(e,n);o&&(0,P.t9)("sendScheduledMessages",{chat:o,ids:[a]})})),(0,n.Q6)("rescheduleMessage",((e,t,s)=>{const{chatId:n,messageId:a,scheduledAt:o}=s,r=(0,i.Z1)(e,n),c=r&&(0,i.Tm)(e,r.id,a);r&&c&&(0,P.t9)("rescheduleMessage",{chat:r,message:c,scheduledAt:o})})),(0,n.Q6)("requestThreadInfoUpdate",((e,t,s)=>{const{chatId:n,threadId:a}=s,o=(0,i.Cm)(e,n,a);o&&(0,P.t9)("requestThreadInfoUpdate",{chat:o,threadId:a})})),(0,n.Q6)("loadPinnedMessages",((e,t,s)=>{const{chatId:a}=s,o=(0,i.Z1)(e,a);o&&async function(e){const t=await(0,P.t9)("fetchPinnedMessages",{chat:e});if(!t)return;const{messages:s,chats:a,users:o}=t,i=(0,g.ee)(s,"id"),c=Object.keys(i).map(Number).sort(((e,t)=>t-e));let l=(0,n.Rd)();l=(0,r.c_)(l,e.id,i),l=(0,r.pf)(l,e.id,u._f,"pinnedIds",c),l=(0,r.Sh)(l,(0,g.ee)(o,"id")),l=(0,r.fZ)(l,(0,g.ee)(a,"id")),(0,n.R3)(l)}(o)})),(0,n.Q6)("loadSeenBy",((e,t,s)=>{const{chatId:a,messageId:o}=s,c=(0,i.Z1)(e,a);c&&(async()=>{const e=await(0,P.t9)("fetchSeenBy",{chat:c,messageId:o});e&&(0,n.R3)((0,r.cY)((0,n.Rd)(),a,o,{seenByUserIds:e}))})()})),(0,n.Q6)("saveDefaultSendAs",((e,t,s)=>{const{chatId:n,sendAsId:a}=s,o=(0,i.Z1)(e,n),c=(0,i.Z1)(e,a)||(0,i.dy)(e,a);if(o&&c)return(0,P.t9)("saveDefaultSendAs",{sendAs:c,chat:o}),(0,r.a4)(e,n,{fullInfo:{...o.fullInfo,sendAsId:a}})})),(0,n.Q6)("loadSendAs",((e,t,s)=>{const{chatId:a}=s,o=(0,i.Z1)(e,a);o&&(async()=>{const t=await(0,P.t9)("fetchSendAs",{chat:o});if(!t)return e=(0,r.a4)(e,a,{sendAsIds:[]}),void(0,n.R3)(e);e=(0,n.Rd)(),e=(0,r.Sh)(e,(0,g.ee)(t.users,"id")),e=(0,r.fZ)(e,(0,g.ee)(t.chats,"id")),e=(0,r.a4)(e,a,{sendAsIds:t.ids}),(0,n.R3)(e)})()})),(0,n.Q6)("loadSponsoredMessages",((e,t,s)=>{const{chatId:a}=s,o=(0,i.Z1)(e,a);o&&(async()=>{const e=await(0,P.t9)("fetchSponsoredMessages",{chat:o});if(!e)return;let t=(0,r.Fn)((0,n.Rd)(),a,e.messages[0]);t=(0,r.Sh)(t,(0,g.ee)(e.users,"id")),t=(0,r.fZ)(t,(0,g.ee)(e.chats,"id")),(0,n.R3)(t)})()})),(0,n.Q6)("viewSponsoredMessage",((e,t,s)=>{const{chatId:n}=s,a=(0,i.Z1)(e,n),o=(0,i.fS)(e,n);a&&o&&(0,P.t9)("viewSponsoredMessage",{chat:a,random:o.randomId})}));var k=s(5765);const R=(0,C.P2)((e=>e()),500,!1);async function T(e,t){const s=await(0,P.t9)("searchGifs",{query:e,offset:t});s&&(0,n.R3)((0,r.rq)((0,n.Rd)(),!t,s.gifs,s.nextOffset))}(0,n.Q6)("loadStickerSets",(e=>{const{hash:t}=e.stickers.added||{};!async function(e){const t=await(0,P.t9)("fetchStickerSets",{hash:e});t&&(0,n.R3)((0,r.z3)((0,n.Rd)(),"added",t.hash,t.sets))}(t)})),(0,n.Q6)("loadAddedStickers",((e,t)=>{const{setIds:s}=e.stickers.added;s&&s.length&&(async()=>{for(let e=0;e<s.length;e++)t.loadStickers({stickerSetId:s[e]}),e%10==0&&e>0&&await(0,C.wO)(200)})()})),(0,n.Q6)("loadRecentStickers",(e=>{const{hash:t}=e.stickers.recent||{};!async function(e){const t=await(0,P.t9)("fetchRecentStickers",{hash:e});if(!t)return;const s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,recent:t}})}(t)})),(0,n.Q6)("loadFavoriteStickers",(e=>{const{hash:t}=e.stickers.favorite||{};!async function(e){const t=await(0,P.t9)("fetchFavoriteStickers",{hash:e});if(!t)return;const s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,favorite:t}})}(t)})),(0,n.Q6)("loadGreetingStickers",(e=>{const{hash:t}=e.stickers.greeting||{};(async()=>{const e=await(0,P.t9)("fetchStickersForEmoji",{emoji:"👋⭐️",hash:t});if(!e)return;const s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,greeting:{hash:e.hash,stickers:e.stickers.filter((e=>"👋"===e.emoji))}}})})()})),(0,n.Q6)("loadFeaturedStickers",(e=>{const{hash:t}=e.stickers.featured||{};!async function(e){const t=await(0,P.t9)("fetchFeaturedStickers",{hash:e});t&&(0,n.R3)((0,r.z3)((0,n.Rd)(),"featured",t.hash,t.sets))}(t)})),(0,n.Q6)("loadStickers",((e,t,s)=>{const{stickerSetId:a,stickerSetShortName:o}=s;let{stickerSetAccessHash:c}=s;if(!c&&!o){const t=(0,i.Ny)(e,a);if(!t)return;c=t.accessHash}!async function(e,t,s){const a=await(0,P.t9)("fetchStickers",{stickerSetShortName:s,stickerSetId:e,accessHash:t});if(!a)return;const{set:o,stickers:i,packs:c}=a;let l=(0,n.Rd)();l=(0,r.Rg)(l,o.id,{...o,stickers:i,packs:c});const d=l.stickers.forEmoji.emoji;d&&c[d]&&(l=(0,r.vy)(l)),(0,n.R3)(l)}(a,c,o)})),(0,n.Q6)("loadAnimatedEmojis",(()=>{!async function(){const e=await(0,P.t9)("fetchAnimatedEmojis");if(!e)return;const{set:t,stickers:s}=e;(0,n.R3)((0,r.g_)((0,n.Rd)(),{...t,stickers:s}))}()})),(0,n.Q6)("loadSavedGifs",(e=>{const{hash:t}=e.gifs.saved;!async function(e){const t=await(0,P.t9)("fetchSavedGifs",{hash:e});if(!t)return;const s=(0,n.Rd)();(0,n.R3)({...s,gifs:{...s.gifs,saved:t}})}(t)})),(0,n.Q6)("faveSticker",((e,t,s)=>{const{sticker:n}=s;n&&(0,P.t9)("faveSticker",{sticker:n})})),(0,n.Q6)("unfaveSticker",((e,t,s)=>{const{sticker:a}=s;a&&function(e){const t=(0,n.Rd)();(0,n.R3)({...t,stickers:{...t.stickers,favorite:{...t.stickers.favorite,stickers:t.stickers.favorite.stickers.filter((({id:t})=>t!==e.id))}}}),(0,P.t9)("faveSticker",{sticker:e,unfave:!0})}(a)})),(0,n.Q6)("toggleStickerSet",((e,t,s)=>{const{stickerSetId:n}=s,a=(0,i.Ny)(e,n);if(!a)return;const{accessHash:o,installedDate:r}=a;(0,P.t9)(r?"uninstallStickerSet":"installStickerSet",{stickerSetId:n,accessHash:o})})),(0,n.Q6)("loadEmojiKeywords",((e,t,s)=>{var a;const{language:o}=s;let r=e.emojiKeywords[o];null!==(a=r)&&void 0!==a&&a.isLoading||((0,n.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...r,isLoading:!0}}}),(async()=>{var t;const s=await(0,P.t9)("fetchEmojiKeywords",{language:o,fromVersion:r?r.version:0});e=(0,n.Rd)(),r=e.emojiKeywords[o],s?(0,n.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{isLoading:!1,version:s.version,keywords:{...null===(t=r)||void 0===t?void 0:t.keywords,...s.keywords}}}}):(0,n.R3)({...e,emojiKeywords:{...e.emojiKeywords,[o]:{...r,isLoading:!1}}})})())})),(0,n.Q6)("setStickerSearchQuery",((e,t,s)=>{const{query:a}=s;a&&R((()=>{!async function(e,t){const s=await(0,P.t9)("searchStickers",{query:e,hash:void 0});if(!s)return;const a=(0,n.Rd)(),{setsById:o,added:i}=a.stickers,c=s.sets.map((({id:e})=>e));i.setIds&&i.setIds.forEach((t=>{if(!c.includes(t)){const{title:s}=o[t]||{};s&&(0,k.Z)(s,e)&&c.unshift(t)}})),(0,n.R3)((0,r.z3)(a,"search",s.hash,s.sets,c))}(a)}))})),(0,n.Q6)("setGifSearchQuery",((e,t,s)=>{const{query:n}=s;"string"==typeof n&&R((()=>{T(n)}))})),(0,n.Q6)("searchMoreGifs",(e=>{const{query:t,offset:s}=e.gifs.search;"string"==typeof t&&R((()=>{T(t,s)}))})),(0,n.Q6)("loadStickersForEmoji",((e,t,s)=>{const{emoji:a}=s,{hash:o}=e.stickers.forEmoji;R((()=>{!async function(e,t){let s=(0,n.Rd)();(0,n.R3)({...s,stickers:{...s.stickers,forEmoji:{...s.stickers.forEmoji,emoji:e}}});const a=await(0,P.t9)("fetchStickersForEmoji",{emoji:e,hash:t});s=(0,n.Rd)(),a&&s.stickers.forEmoji.emoji===e&&(s=(0,r.IM)(s,e,a.stickers,a.hash),(0,n.R3)(s))}(a,o)}))})),(0,n.Q6)("clearStickersForEmoji",(e=>({...e,stickers:{...e.stickers,forEmoji:{}}}))),(0,n.Q6)("openStickerSetShortName",((e,t,s)=>{const{stickerSetShortName:n}=s;return{...e,openedStickerSetShortName:n}}));var N=s(790);const B=(0,C.P2)((e=>e()),500,!1);async function A(e="",t,s,o,c,l){let d;if(o){const n=await(0,P.t9)("searchMessagesLocal",{chatOrUser:o,query:e,type:t,limit:a.Hk,offsetId:s,minDate:l,maxDate:c});if(n){const{messages:e,users:t,totalCount:s,nextOffsetId:a}=n;d={messages:e,users:t,chats:[],totalCount:s,nextRate:a}}}else d=await(0,P.t9)("searchMessagesGlobal",{query:e,offsetRate:s,limit:a.Hk,type:t,maxDate:c,minDate:l});let u=(0,n.Rd)();const m=(0,i.JX)(u);if(!d||""!==e&&e!==m)return void(0,n.R3)((0,r.xv)(u,{messages:!1}));const{messages:h,users:p,chats:f,totalCount:I,nextRate:v}=d;f.length&&(u=(0,r.fZ)(u,(0,g.ee)(f,"id"))),p.length&&(u=(0,r.Sh)(u,(0,g.ee)(p,"id"))),h.length&&(u=(0,r.m6)(u,h)),u=(0,r.px)(u,h,I,t,v),(0,n.R3)(u)}(0,n.Q6)("setGlobalSearchQuery",((e,t,s)=>{const{chatId:a}=e.globalSearch,{query:o}=s;o&&!a&&B((()=>{!async function(e){const t=await(0,P.t9)("searchChats",{query:e});let s=(0,n.Rd)();const a=(0,i.JX)(s);if(!t||!a||e!==a)return void(0,n.R3)((0,r.xv)(s,{chats:!1}));const{localChats:o,localUsers:c,globalChats:l,globalUsers:d}=t;(o.length||l.length)&&(s=(0,r.fZ)(s,(0,g.ee)([...o,...l],"id"))),(c.length||d.length)&&(s=(0,r.Sh)(s,(0,g.ee)([...c,...d],"id"))),s=(0,r.xv)(s,{chats:!1}),s=(0,r.No)(s,{localResults:{chatIds:o.map((({id:e})=>e)),userIds:c.map((({id:e})=>e))},globalResults:{...s.globalSearch.globalResults,chatIds:l.map((({id:e})=>e)),userIds:d.map((({id:e})=>e))}}),(0,n.R3)(s)}(o)}))})),(0,n.Q6)("setGlobalSearchDate",((e,t,s)=>{const{date:a}=s,o=a?(0,N.IS)(a):a,c=(0,r.No)(e,{date:a,query:"",resultsByType:{...e.globalSearch.resultsByType,text:{totalCount:void 0,foundIds:[],nextOffsetId:0}}});(0,n.R3)(c);const{chatId:l}=e.globalSearch;A("","text",void 0,l?(0,i.Z1)(e,l):void 0,o,a)})),(0,n.Q6)("searchMessagesGlobal",((e,t,s)=>{var n;const{query:a,resultsByType:o,chatId:r,date:c}=e.globalSearch,l=c?(0,N.IS)(c):c,{type:d}=s;A(a,d,null==o||null===(n=o[d])||void 0===n?void 0:n.nextOffsetId,r?(0,i.Z1)(e,r):void 0,l,c)})),(0,n.Q6)("searchTextMessagesLocal",(e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{},o=t?(0,i.Z1)(e,t):void 0,c=(0,i.n5)(e);if(!o||!c||!s)return;const{query:l,results:d}=c,m=null==d?void 0:d.nextOffsetId;let h;if(s!==u._f){const n=(0,i.tZ)(e,t,s);h=null==n?void 0:n.topMessageId}!async function(e,t,s,o,c){const l=await(0,P.t9)("searchMessagesLocal",{chatOrUser:e,type:"text",query:o,topMessageId:s,limit:a.pn,offsetId:c});if(!l)return;const{messages:d,users:u,totalCount:m,nextOffsetId:h}=l,p=(0,g.ee)(d,"id"),f=Object.keys(p).map(Number);let I=(0,n.Rd)();const v=(0,i.n5)(I);!v||o&&o!==v.query||(I=(0,r.c_)(I,e.id,p),I=(0,r.Sh)(I,(0,g.ee)(u,"id")),I=(0,r.dx)(I,e.id,t,f,m,h),(0,n.R3)(I))}(o,s,h,l,m)})),(0,n.Q6)("searchMediaMessagesLocal",(e=>{const t=(0,i.og)(e),s=t?e.users.byId[t]||e.chats.byId[t]:void 0,o=(0,i.we)(e);if(!s||!o)return;const{currentType:c,resultsByType:l}=o,d=c&&l&&l[c],u=null==d?void 0:d.nextOffsetId;c&&async function(e,t,s){const o=await(0,P.t9)("searchMessagesLocal",{chatOrUser:e,type:t,limit:a.EN,offsetId:s});if(!o)return;const{messages:c,users:l,totalCount:d,nextOffsetId:u}=o,m=(0,g.ee)(c,"id"),h=Object.keys(m).map(Number);let p=(0,n.Rd)();(0,i.we)(p)&&(p=(0,r.c_)(p,e.id,m),p=(0,r.Sh)(p,(0,g.ee)(l,"id")),p=(0,r.c1)(p,e.id,t,h,d,u),(0,n.R3)(p))}(s,c,u)})),(0,n.Q6)("searchMessagesByDate",((e,t,s)=>{const{timestamp:a}=s,{chatId:o}=(0,i.Bt)(e)||{};if(!o)return;const r=(0,i.Z1)(e,o);r&&async function(e,t){const s=await(0,P.t9)("findFirstMessageIdAfterDate",{chat:e,timestamp:t});s&&(0,n.uC)().focusMessage({chatId:e.id,messageId:s})}(r,a)})),(0,n.Q6)("checkPublicLink",((e,t,s)=>{const{chatId:a}=(0,i.Bt)(e)||{};if(!a)return;if(e.management.progress===m.wv.InProgress)return;const{username:o}=s;(async()=>{e=(0,r.H9)(e,m.wv.InProgress),e=(0,r.fw)(e,a,{isUsernameAvailable:void 0}),(0,n.R3)(e);const t=await(0,P.t9)("checkChatUsername",{username:o});e=(0,n.Rd)(),e=(0,r.H9)(e,t?m.wv.Complete:m.wv.Error),e=(0,r.fw)(e,a,{isUsernameAvailable:t}),(0,n.R3)(e)})()})),(0,n.Q6)("updatePublicLink",((e,t,s)=>{const{chatId:a}=(0,i.Bt)(e)||{};let o=a&&(0,i.Z1)(e,a);if(!a||!o)return;const{username:c}=s;(async()=>{if(e=(0,r.H9)(e,m.wv.InProgress),(0,n.R3)(e),(0,l.G9)(o)){if(o=await(0,P.t9)("migrateChat",o),!o)return;t.openChat({id:o.id})}const s=await(0,P.t9)("setChatUsername",{chat:o,username:c});e=(0,n.Rd)(),e=(0,r.H9)(e,s?m.wv.Complete:m.wv.Error),e=(0,r.fw)(e,a,{isUsernameAvailable:void 0}),(0,n.R3)(e)})()})),(0,n.Q6)("updatePrivateLink",(e=>{const{chatId:t}=(0,i.Bt)(e)||{},s=t&&(0,i.Z1)(e,t);t&&s&&(0,P.t9)("updatePrivateLink",{chat:s})}));var x=s(7358);async function L(){const e=await(0,P.t9)("fetchChats",{limit:a.Ov,archived:!0,withPinned:!0,serverTimeOffset:(0,n.Rd)().serverTimeOffset});if(!e)return;let t=(0,n.Rd)();t=(0,r.eD)(t,(0,g.ee)(e.users,"id")),t=(0,r.zn)(t,e.userStatusesById),t=(0,r.GL)(t,(0,g.ee)(e.chats,"id")),t=(0,r.Mg)(t,"archived",e.chatIds),t=(0,r.vv)(t,"archived",e),(0,n.R3)(t)}async function O(){let e=(0,n.Rd)();const{recentlyFoundChatIds:t}=e.globalSearch,{userIds:s}=e.contactList||{};if(!(s&&s.length||t&&t.length))return;const a=[...t||[],...s||[]].map((t=>(0,i.dy)(e,t))).filter(Boolean),o=await(0,P.t9)("fetchUsers",{users:a});if(!o)return;const{users:c,userStatusesById:l}=o;e=(0,n.Rd)(),e=(0,r.eD)(e,(0,g.ee)(c,"id")),e=(0,r.zn)(e,l),(0,n.R3)(e)}function F(e){return(0,P.t9)("fetchMessages",{chat:e,threadId:u._f,offsetId:e.lastReadInboxMessageId,addOffset:-(Math.round(a.hT/2)+1),limit:a.hT})}(0,n.Q6)("sync",((e,t)=>{!async function(e){a.eM&&console.log(">>> START SYNC"),await(0,P.t9)("fetchCurrentUser");const t=await async function(){var e;let t=(0,n.Rd)();const s=await(0,P.t9)("fetchChats",{limit:a.Ov,withPinned:!0,serverTimeOffset:t.serverTimeOffset,lastLocalServiceMessage:null===(e=(0,i.VF)(t))||void 0===e?void 0:e.message});if(!s)return;t=(0,n.Rd)();const{recentlyFoundChatIds:o}=t.globalSearch,{userIds:c}=t.contactList||{},{currentUserId:d}=t,m=[...o||[],...c||[],...d?[d]:[]],h=m.map((e=>(0,i.dy)(t,e))).filter(Boolean),p=m.map((e=>(0,i.Z1)(t,e))).filter(Boolean),{chatId:f}=(0,i.Bt)(t)||{};if(f){const e=(0,i.Z1)(t,f);if(e&&!m.includes(f)&&p.push(e),(0,l.YC)(f)){const e=(0,i.dy)(t,f);e&&!m.includes(f)&&h.push(e)}}return h.push(...s.users),p.push(...s.chats),t=(0,r.ps)(t,s.userStatusesById),t=(0,r.SL)(t,(0,g.ee)(p,"id")),t=(0,r.Mg)(t,"active",s.chatIds),t=(0,r.vv)(t,"active",s),Object.keys(s.draftsById).forEach((e=>{t=(0,r.pf)(t,e,u._f,"draft",s.draftsById[e])})),Object.keys(s.replyingToById).forEach((e=>{t=(0,r.pf)(t,e,u._f,"replyingToId",s.replyingToById[e])})),(0,n.R3)(t),f&&!t.chats.byId[f]&&(0,n.uC)().openChat({id:void 0}),h}();await async function(e){let t=!1,s=e||[],o=(0,n.Rd)();const{chatId:c,threadId:l}=(0,i.Bt)(o)||{},d=Object.keys(o.messages.byChatId).reduce(((e,t)=>{const s=(0,i.Ms)(o,t,u._f);return s&&(e[t]=s),e}),{});if(c){const e=await F(o.chats.byId[c]);o=(0,n.Rd)();const{chatId:d}=(0,i.Bt)(o)||{},m=l&&(0,i.tZ)(o,c,l);if(e&&d===c){const n=o.messages.byChatId[c],i=c===a.aw?o.serviceNotifications.map((({message:e})=>e)):[],d=[].concat(e.messages,i),h=(0,g.ee)(d,"id"),p=Object.keys(h).map(Number);if(o={...o,messages:{...o.messages,byChatId:{}}},o=(0,r.c_)(o,c,h),o=(0,r.xj)(o,c,u._f,p),o=(0,r.y9)(o,c,u._f,p),l&&m&&m.originChannelId){const{originChannelId:e}=m,t=o.messages.byChatId[e],s=await F(o.chats.byId[e]);if(s){const e=(0,g.ee)(s.messages,"id"),a=Object.keys(e).map(Number);o={...o,messages:{...o.messages,byChatId:{...o.messages.byChatId,[m.originChannelId]:{byId:e,threadsById:{[u._f]:{...null==t?void 0:t.threadsById[u._f],listedIds:a,viewportIds:a,outlyingIds:void 0}}},[c]:{...o.messages.byChatId[c],threadsById:{...o.messages.byChatId[c].threadsById,[l]:{...null==n?void 0:n.threadsById[l],outlyingIds:void 0}}}}}}}}o=(0,r.GL)(o,(0,g.ee)(e.chats,"id")),o=(0,r.j6)(o,c,e.threadInfos),t=!0,s=Array.prototype.concat(s,e.users)}}t||(o={...o,messages:{...o.messages,byChatId:{}}}),Object.keys(d).forEach((e=>{o=(0,r.pf)(o,e,u._f,"draft",d[e])})),e?o=(0,r.s5)(o,(0,g.ee)(s,"id")):s&&(o=(0,r.eD)(o,(0,g.ee)(s,"id"))),(0,n.R3)(o);const{chatId:m,messageId:h}=o.audioPlayer;m&&h&&!(0,i.hj)(o,m,h)&&(0,n.uC)().closeAudioPlayer()}(t),(0,n.R3)({...(0,n.Rd)(),lastSyncTime:Date.now()}),a.eM&&console.log(">>> FINISH SYNC"),e()}(t.afterSync)})),(0,n.Q6)("afterSync",(()=>{!async function(){a.eM&&console.log(">>> START AFTER-SYNC"),await Promise.all([O(),L()]),await(0,P.t9)("fetchCurrentUser"),(0,x.w)((0,i.A1)((0,n.Rd)())),a.eM&&console.log(">>> FINISH AFTER-SYNC")}()}));const U=(0,C.Ds)((e=>e()),500,!1,!0),$=(0,C.P2)((e=>e()),500,!1);function D(e,t,s){return{...e,inlineBots:{...e.inlineBots,byUsername:{...e.inlineBots.byUsername,[t]:s}}}}function q(e,t){return{...e,inlineBots:{...e.inlineBots,isLoading:t}}}(0,n.Q6)("loadFullUser",((e,t,s)=>{const{userId:n}=s,a=(0,i.dy)(e,n);if(!a)return;const{id:o,accessHash:r}=a;U((()=>(0,P.t9)("fetchFullUser",{id:o,accessHash:r})))})),(0,n.Q6)("loadUser",((e,t,s)=>{const{userId:a}=s,o=(0,i.dy)(e,a);o&&(async()=>{const t=await(0,P.t9)("fetchUsers",{users:[o]});if(!t)return;const{users:s,userStatusesById:a}=t;e=(0,n.Rd)(),e=(0,r.eD)(e,(0,g.ee)(s,"id")),(0,n.R3)((0,r.ps)(e,{...e.users.statusesById,...a})),(0,n.R3)(e)})()})),(0,n.Q6)("loadTopUsers",(e=>{const{topPeers:{lastRequestedAt:t}}=e;(!t||(0,p.b)(e.serverTimeOffset)-t>60)&&async function(){const e=await(0,P.t9)("fetchTopUsers");if(!e)return;const{ids:t,users:s}=e;let a=(0,n.Rd)();a=(0,r.Sh)(a,(0,g.ee)(s,"id")),a={...a,topPeers:{...a.topPeers,userIds:t,lastRequestedAt:(0,p.b)(a.serverTimeOffset)}},(0,n.R3)(a)}()})),(0,n.Q6)("loadContactList",(()=>{!async function(){const e=await(0,P.t9)("fetchContactList");if(!e)return;let t=(0,r.Sh)((0,n.Rd)(),(0,g.ee)(e.users,"id"));t=(0,r.fZ)(t,(0,g.ee)(e.chats,"id"));const s=e=>e.lastName||e.firstName||"",a=new Intl.Collator("en-US"),o=e.users.sort(((e,t)=>a.compare(s(e),s(t)))).filter((e=>!e.isSelf));(0,n.R3)({...t,contactList:{userIds:o.map((e=>e.id))}})}()})),(0,n.Q6)("loadCurrentUser",(()=>{(0,P.t9)("fetchCurrentUser")})),(0,n.Q6)("loadCommonChats",(e=>{var t;const{chatId:s}=(0,i.Bt)(e)||{},a=s?(0,i.dy)(e,s):void 0;!a||(0,l.cS)(a)||null!==(t=a.commonChats)&&void 0!==t&&t.isFullyLoaded||(async()=>{var t,s;const o=null===(t=a.commonChats)||void 0===t?void 0:t.maxId,i=await(0,P.t9)("fetchCommonChats",a.id,a.accessHash,o);if(!i)return;const{chats:c,chatIds:l,isFullyLoaded:d}=i;e=(0,n.Rd)(),c.length&&(e=(0,r.fZ)(e,(0,g.ee)(c,"id"))),e=(0,r.Nq)(e,a.id,{commonChats:{maxId:l.length?l[l.length-1]:"0",ids:(0,g.Tw)(((null===(s=a.commonChats)||void 0===s?void 0:s.ids)||[]).concat(l)),isFullyLoaded:d}}),(0,n.R3)(e)})()})),(0,n.Q6)("updateContact",((e,t,s)=>{const{userId:a,isMuted:o,firstName:c,lastName:l}=s;!async function(e,t,s,a){const o=(0,n.Rd)(),c=(0,i.dy)(o,e);if(!c)return;let l;if((0,n.uC)().updateChatMutedState({chatId:e,isMuted:t}),(0,n.R3)((0,r.H9)((0,n.Rd)(),m.wv.InProgress)),c.phoneNumber)l=await(0,P.t9)("updateContact",{phone:c.phoneNumber,firstName:s,lastName:a});else{const{id:e,accessHash:t}=c;l=await(0,P.t9)("addContact",{id:e,accessHash:t,phoneNumber:"",firstName:s,lastName:a})}l&&(0,n.R3)((0,r.Nq)((0,n.Rd)(),c.id,{firstName:s,lastName:a})),(0,n.R3)((0,r.H9)((0,n.Rd)(),m.wv.Complete))}(a,o,c,l)})),(0,n.Q6)("deleteUser",((e,t,s)=>{const{userId:a}=s;!async function(e){const t=(0,n.Rd)(),s=(0,i.dy)(t,e);if(!s)return;const{id:a,accessHash:o}=s;await(0,P.t9)("deleteUser",{id:a,accessHash:o})}(a)})),(0,n.Q6)("loadProfilePhotos",((e,t,s)=>{const{profileId:a}=s,o=(0,l.YC)(a),c=o?(0,i.dy)(e,a):void 0,d=o?void 0:(0,i.Z1)(e,a);(c||d)&&(async()=>{const e=await(0,P.t9)("fetchProfilePhotos",c,d);if(!e||!e.photos)return;let t=(0,n.Rd)();o?t=(0,r.Nq)(t,a,{photos:e.photos}):(t=(0,r.Sh)(t,(0,g.ee)(e.users,"id")),t=(0,r.a4)(t,a,{photos:e.photos})),(0,n.R3)(t)})()})),(0,n.Q6)("setUserSearchQuery",((e,t,s)=>{const{query:a}=s;a&&$((()=>{!async function(e){const t=await(0,P.t9)("searchChats",{query:e});let s=(0,n.Rd)();const a=s.userSearch.query;if(!t||!a||e!==a)return void(0,n.R3)((0,r.Q3)(s,!1));const{localUsers:o,globalUsers:i}=t;let c,l;o.length&&(s=(0,r.Sh)(s,(0,g.ee)(o,"id")),c=o.map((({id:e})=>e))),i.length&&(s=(0,r.Sh)(s,(0,g.ee)(i,"id")),l=i.map((({id:e})=>e))),s=(0,r.Q3)(s,!1),s=(0,r.Lm)(s,{localUserIds:c,globalUserIds:l}),(0,n.R3)(s)}(a)}))})),(0,n.Q6)("addContact",((e,t,s)=>{const{userId:n}=s,a=(0,i.dy)(e,n);a&&(0,P.t9)("addContact",(0,g.ei)(a,["id","accessHash","firstName","lastName","phoneNumber"]))}));const Q=(0,C.Ds)((e=>e()),500,!1);async function G(e,t,s,n,a){await(0,P.t9)("sendMessage",{chat:e,text:s,replyingTo:n,sendAs:a})}(0,n.Q6)("clickInlineButton",((e,t,s)=>{const{button:o}=s;switch(o.type){case"command":t.sendBotCommand({command:o.value});break;case"url":o.value.match(a.FS)||o.value.match(a.g$)?t.openTelegramLink({url:o.value}):t.toggleSafeLinkModal({url:o.value});break;case"callback":{const t=(0,i.jr)(e);if(!t)return;!async function(e,t,s){const a=await(0,P.t9)("answerCallbackButton",{chatId:e.id,accessHash:e.accessHash,messageId:t,data:s});if(!a)return;const{showDialog:o,showNotification:r,toggleSafeLinkModal:i}=(0,n.uC)(),{message:c,alert:l,url:d}=a;l?o({data:{message:c||"Error"}}):c?r({message:c}):d&&i({url:d})}(t,o.messageId,o.value);break}case"requestPoll":t.openPollModal();break;case"buy":{const s=(0,i.jr)(e),{messageId:n,value:a}=o;if(!s)return;a?t.getReceipt({receiptMessageId:a,chatId:s.id,messageId:n}):(t.getPaymentForm({chat:s,messageId:n}),t.setInvoiceMessageInfo((0,i.hj)(e,s.id,n)),t.openPaymentModal({chatId:s.id,messageId:n}));break}}})),(0,n.Q6)("sendBotCommand",((e,t,s)=>{const{command:n,chatId:a}=s,{currentUserId:o}=e,r=a?(0,i.Z1)(e,a):(0,i.jr)(e),c=(0,i.Bt)(e);if(!o||!r||!c)return;const{threadId:l}=c;t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:r.id,threadId:l,value:!1}),G(r,0,n,(0,i.Yy)(e,r.id,l),(0,i._5)(e,a))})),(0,n.Q6)("restartBot",((e,t,s)=>{const{chatId:a}=s,{currentUserId:o}=e,c=(0,i.jr)(e),l=o&&(0,i.IK)(e,a);o&&c&&l&&(async()=>{await(0,P.t9)("unblockContact",l.id,l.accessHash)&&((0,n.R3)((0,r.rB)((0,n.Rd)(),l.id)),G(c,0,"/start",void 0,(0,i._5)(e,a)))})()})),(0,n.Q6)("loadTopInlineBots",(e=>{const{lastRequestedAt:t}=e.topInlineBots;t&&(0,p.b)(e.serverTimeOffset)-t<60||(async()=>{const t=await(0,P.t9)("fetchTopInlineBots");if(!t)return;const{ids:s,users:a}=t;let o=(0,n.Rd)();o=(0,r.Sh)(o,(0,g.ee)(a,"id")),o={...o,topInlineBots:{...o.topInlineBots,userIds:s,lastRequestedAt:(0,p.b)(e.serverTimeOffset)}},(0,n.R3)(o)})()})),(0,n.Q6)("queryInlineBot",((e,t,s)=>{const{chatId:a,username:o,query:c,offset:l}=s;(async()=>{let t=e.inlineBots.byUsername[o];if(!1!==t){if(void 0===t){const{user:s,chat:a}=await(0,P.t9)("fetchInlineBot",{username:o})||{};if(e=(0,n.Rd)(),!s||!a)return void(0,n.R3)(D(e,o,!1));e=(0,r.Sh)(e,{[s.id]:s}),e=(0,r.fZ)(e,{[a.id]:a}),t={id:s.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},e=D(e,o,t),(0,n.R3)(e)}(c!==t.query||t.canLoadMore)&&Q((()=>{!async function({username:e,inlineBotData:t,chatId:s,query:a,offset:o}){let r=(0,n.Rd)();const c=(0,i.dy)(r,t.id),l=(0,i.Z1)(r,s);if(!c||!l)return;const d=t.query!==a;r=q(r,!0),r=D(r,e,{...t,query:a,...d&&{offset:void 0,results:[]}}),(0,n.R3)(r);const u=await(0,P.t9)("fetchInlineBotResults",{bot:c,chat:l,query:a,offset:d?void 0:o}),m=r.inlineBots.byUsername[e];if(r=q((0,n.Rd)(),!1),!u||!m||a!==m.query)return void(0,n.R3)(r);const h=new Set((m.results||[]).map((e=>e.id))),g=u.results.filter((e=>!h.has(e.id)));r=D(r,e,{...m,help:u.help,...g.length&&{isGallery:u.isGallery},...u.switchPm&&{switchPm:u.switchPm},canLoadMore:u.results.length>0&&Boolean(u.nextOffset),results:""===m.offset||m.offset===u.nextOffset?u.results:(m.results||[]).concat(g),offset:g.length?u.nextOffset:""}),(0,n.R3)(r)}({username:o,inlineBotData:t,chatId:a,query:c,offset:l})}))}})()})),(0,n.Q6)("sendInlineBotResult",((e,t,s)=>{const{id:n,queryId:a}=s,o=(0,i.Bt)(e);if(!o||!n)return;const{chatId:r,threadId:c}=o,l=(0,i.Z1)(e,r);t.setReplyingToId({messageId:void 0}),t.clearWebPagePreview({chatId:r,threadId:c,value:!1}),(0,P.t9)("sendInlineBotResult",{chat:l,resultId:n,queryId:a,replyingTo:(0,i.Yy)(e,r,c),sendAs:(0,i._5)(e,r)})})),(0,n.Q6)("resetInlineBot",((e,t,s)=>{const{username:a}=s;let o=e.inlineBots.byUsername[a];o&&(o={id:o.id,query:"",offset:"",switchPm:void 0,canLoadMore:!0,results:[]},(0,n.R3)(D(e,a,o)))})),(0,n.Q6)("startBot",((e,t,s)=>{const{botId:n,param:a}=s,o=(0,i.dy)(e,n);o&&(async()=>{await(0,P.t9)("startBot",{bot:o,startParam:a})})()})),s(9667),(0,n.Q6)("loadPasswordInfo",(()=>{(async()=>{const e=await(0,P.t9)("getPasswordInfo");if(!e)return;let t=(0,n.Rd)();t=(0,r.BI)(t,{hasPassword:e.hasPassword}),t=(0,r.IE)(t,{hint:e.hint}),(0,n.R3)(t)})()})),(0,n.Q6)("checkPassword",((e,t,s)=>{const{currentPassword:a,onSuccess:o}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,P.t9)("checkPassword",a);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1})),e&&o()})()})),(0,n.Q6)("clearPassword",((e,t,s)=>{const{currentPassword:a,onSuccess:o}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,P.t9)("clearPassword",a);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1})),e&&o()})()})),(0,n.Q6)("updatePassword",((e,t,s)=>{const{currentPassword:a,password:o,hint:i,email:c,onSuccess:l}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,P.t9)("updatePassword",a,o,i,c);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1})),e&&l()})()})),(0,n.Q6)("updateRecoveryEmail",((e,t,s)=>{const{currentPassword:a,email:o,onSuccess:i}=s;(0,n.R3)((0,r.IE)(e,{isLoading:!0,error:void 0})),(async()=>{const e=await(0,P.t9)("updateRecoveryEmail",a,o);(0,n.R3)((0,r.IE)((0,n.Rd)(),{isLoading:!1,waitingEmailCodeLength:void 0})),e&&i()})()})),(0,n.Q6)("provideTwoFaEmailCode",((e,t,s)=>{const{code:n}=s;(0,P.t9)("provideRecoveryEmailCode",n)})),(0,n.Q6)("clearTwoFaError",(e=>(0,r.IE)(e,{error:void 0}))),(0,n.Q6)("validateRequestedInfo",((e,t,s)=>{const{requestInfo:a,saveInfo:o}=s,c=(0,i.gx)(e),l=c&&(0,i.Z1)(e,c),d=(0,i.Mz)(e);l&&d&&async function(e,t,s,a){const o=await(0,P.t9)("validateRequestedInfo",{chat:e,messageId:t,requestInfo:s,shouldSave:a});if(!o)return;const{id:i,shippingOptions:c}=o;if(!i)return;let l=(0,r.vT)((0,n.Rd)(),i);c?(l=(0,r.TM)(l,c),l=(0,r.Q$)(l,m.KB.Shipping)):l=(0,r.Q$)(l,m.KB.PaymentInfo),(0,n.R3)(l)}(l,d,a,o)})),(0,n.Q6)("getPaymentForm",((e,t,s)=>{const{chat:a,messageId:o}=s;a&&o&&async function(e,t){const s=await(0,P.t9)("getPaymentForm",{chat:e,messageId:t});if(!s)return;let a=(0,r._7)((0,n.Rd)(),s),o=m.KB.PaymentInfo;a.payment.invoice&&(a.payment.invoice.shippingAddressRequested||a.payment.invoice.nameRequested||a.payment.invoice.phoneRequested||a.payment.invoice.emailRequested)&&(o=m.KB.ShippingInfo),a=(0,r.Q$)(a,o),(0,n.R3)(a)}(a,o)})),(0,n.Q6)("getReceipt",((e,t,s)=>{const{receiptMessageId:a,chatId:o,messageId:c}=s,l=o&&(0,i.Z1)(e,o);c&&a&&l&&async function(e,t,s){const a=await(0,P.t9)("getReceipt",e,s);if(!a)return;let o=(0,n.Rd)();const c=(0,i.hj)(o,e.id,t);o=(0,r.Dq)(o,a,c),(0,n.R3)(o)}(l,c,a)})),(0,n.Q6)("clearPaymentError",(e=>{(0,n.R3)({...e,payment:{...e.payment,error:void 0}})})),(0,n.Q6)("clearReceipt",(e=>{(0,n.R3)({...e,payment:{...e.payment,receipt:void 0}})})),(0,n.Q6)("sendCredentialsInfo",((e,t,s)=>{const a=(0,i.$$)(e);if(!a)return;const{credentials:o}=s,{data:c}=o;!async function(e,t){const s=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}),a=await fetch(`https://api.stripe.com/v1/tokens${s}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${t}`}}),o=await a.json();if(o.error){const e=(0,l.Ow)(o.error),t=(0,n.Rd)();return void(0,n.R3)({...t,payment:{...t.payment,error:{...e}}})}let i=(0,r.QH)((0,n.Rd)(),{type:o.type,id:o.id});i=(0,r.Q$)(i,m.KB.Checkout),(0,n.R3)(i)}(c,a)})),(0,n.Q6)("sendPaymentForm",((e,t,s)=>{const{shippingOptionId:a,saveCredentials:o}=s,c=(0,i.gx)(e),l=c&&(0,i.Z1)(e,c),d=(0,i.Mz)(e),u=(0,i.eh)(e),m=(0,i.sp)(e),h=(0,i.$$)(e),g=(0,i.i3)(e);l&&d&&h&&u&&async function(e,t,s,a,o,i){if(await(0,P.t9)("sendPaymentForm",{chat:e,messageId:t,formId:s,credentials:a,requestedInfoId:o,shippingOptionId:i})){const e=(0,r.bp)((0,n.Rd)());(0,n.R3)((0,r.WY)(e))}}(l,d,u,{save:o,data:g},m,a)})),(0,n.Q6)("setPaymentStep",((e,t,s={})=>(0,r.Q$)(e,s.step||m.KB.ShippingInfo))),(0,n.Q6)("setInvoiceMessageInfo",((e,t,s)=>(0,r.nA)(e,s))),s(4907);var j=s(8406);const H=(0,C.P2)((e=>e()),500,!0);(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateChat":{s.noTopChatsRequest||(0,i.N)(e,s.id)||t.loadTopChats();const a=(0,r.a4)(e,s.id,s.chat,s.newProfilePhoto);(0,n.R3)(a),H((()=>(0,x.w)((0,i.A1)((0,n.Rd)())))),s.chat.id&&(0,j.Vr)({chatId:s.chat.id,lastReadInboxMessageId:s.chat.lastReadInboxMessageId});break}case"updateChatJoin":{const a=(0,i.Ek)(e,s.id);if(!a)break;e=(0,r.B1)(e,a,[s.id]),e=(0,r.a4)(e,s.id,{isNotJoined:!1}),(0,n.R3)(e);const o=(0,i.Z1)(e,s.id);o&&t.requestChatUpdate({chatId:o.id});break}case"updateChatLeave":(0,n.R3)((0,r.Dd)(e,s.id));break;case"updateChatInbox":(0,n.R3)((0,r.a4)(e,s.id,s.chat)),H((()=>(0,x.w)((0,i.A1)((0,n.Rd)()))));break;case"updateChatTypingStatus":{const{id:t,typingStatus:a}=s;(0,n.R3)((0,r.a4)(e,t,{typingStatus:a})),setTimeout((()=>{const e=(0,n.Rd)(),s=(0,i.Z1)(e,t);s&&a&&s.typingStatus&&s.typingStatus.timestamp===a.timestamp&&(0,n.R3)((0,r.a4)(e,t,{typingStatus:void 0}))}),6e3);break}case"newMessage":{const{message:a}=s,{chatId:o,threadId:c,type:l}=(0,i.Bt)(e)||{};if(a.senderId===e.currentUserId&&!a.isFromScheduled)return;const d=(0,i.Z1)(e,s.chatId);if(!d)return;"thread"===l&&c===u._f&&s.chatId===o?setTimeout((()=>{t.requestChatUpdate({chatId:s.chatId})}),1500):(0,n.R3)((0,r.a4)(e,s.chatId,{unreadCount:d.unreadCount?d.unreadCount+1:1,...s.message.hasUnreadMention&&{unreadMentionsCount:d.unreadMentionsCount?d.unreadMentionsCount+1:1}})),(0,x.w)((0,i.A1)((0,n.Rd)())),(0,j.zP)({chat:d,message:a});break}case"updateCommonBoxMessages":case"updateChannelMessages":{const{ids:t,messageUpdate:a}=s;if(!1!==a.hasUnreadMention)return;t.forEach((t=>{const n="channelId"in s?s.channelId:(0,i.X5)(e,t),a=(0,i.Z1)(e,n);null!=a&&a.unreadMentionsCount&&(e=(0,r.a4)(e,n,{unreadMentionsCount:a.unreadMentionsCount-1}))})),(0,n.R3)(e);break}case"updateChatFullInfo":{const{fullInfo:t}=s,a=e.chats.byId[s.id];if(!a)return;(0,n.R3)((0,r.a4)(e,s.id,{fullInfo:{...a.fullInfo,...t}}));break}case"updatePinnedChatIds":{const{ids:t,folderId:o}=s,r=o===a.WS?"archived":"active";e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[r]:t.length?t:void 0}}},(0,n.R3)(e);break}case"updateChatPinned":{const{id:t,isPinned:o}=s,r=(0,i.Ek)(e,t);if(r){const{[r]:s}=e.chats.orderedPinnedIds;let n=s||[];if(o){if(!n.includes(t)){if("active"===r&&n.length>=a.EG){const t=e.chats.listIds.active;n=n.filter((e=>t&&t.includes(e)))}n=[t,...n]}}else n=n.filter((e=>e!==t));e={...e,chats:{...e.chats,orderedPinnedIds:{...e.chats.orderedPinnedIds,[r]:n.length?n:void 0}}}}(0,n.R3)(e);break}case"updateChatListType":{const{id:t,folderId:a}=s;(0,n.R3)((0,r.Pi)(e,t,a));break}case"updateChatFolder":{const{id:t,folder:a}=s,{byId:o,orderedIds:r}=e.chatFolders,i=a?{...o,[t]:a}:(0,g.ei)(o,Object.keys(o).map(Number).filter((e=>e!==t))),c=a?r&&r.includes(t)?r:[...r||[],t]:r?r.filter((e=>e!==t)):void 0;(0,n.R3)({...e,chatFolders:{...e.chatFolders,byId:i,orderedIds:c}});break}case"updateChatFoldersOrder":{const{orderedIds:t}=s;(0,n.R3)({...e,chatFolders:{...e.chatFolders,orderedIds:t}});break}case"updateRecommendedChatFolders":{const{folders:t}=s;(0,n.R3)({...e,chatFolders:{...e.chatFolders,recommended:t}});break}case"updateChatMembers":{var o;const t=e.chats.byId[s.id],{replacedMembers:a,addedMember:i,deletedMemberId:c}=s;if(!t)return;let l=!1,d=null!==(o=t.fullInfo)&&void 0!==o&&o.members?[...t.fullInfo.members]:[];if(a)d=a,l=!0;else if(i)d.length&&d.some((e=>e.userId===i.userId))||(d.push(i),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 a=d.filter((({isOwner:e,isAdmin:t})=>e||t));(0,n.R3)((0,r.a4)(e,s.id,{membersCount:d.length,fullInfo:{...t.fullInfo,members:d,adminMembers:a}}))}break}case"deleteProfilePhotos":{const{chatId:t,ids:a}=s,o=e.chats.byId[t];null!=o&&o.photos&&(0,n.R3)((0,r.a4)(e,t,{photos:o.photos.filter((e=>!a.includes(e.id)))}));break}case"draftMessage":{const{chatId:t,formattedText:a,date:o,replyingToId:i}=s;e.chats.byId[t]&&(e=(0,r.pf)(e,t,u._f,"draft",a),e=(0,r.pf)(e,t,u._f,"replyingToId",i),e=(0,r.a4)(e,t,{draftDate:o}),(0,n.R3)(e));break}case"showInvite":{const{data:e}=s;t.showDialog({data:e});break}}}));const _=350;function z(e,t,s,n,a=!1){const o=a?(0,i.Tm)(e,t,s):(0,i.hj)(e,t,s);if(o&&n.content){const{photo:e,video:t,sticker:s,document:a}=(0,l.qp)(o);e&&n.content.photo?(n.content.photo.blobUrl=e.blobUrl,n.content.photo.thumbnail=e.thumbnail):t&&n.content.video?n.content.video.blobUrl=t.blobUrl:s&&n.content.sticker?n.content.sticker.isPreloadedGlobally=s.isPreloadedGlobally:a&&n.content.document&&(n.content.document.previewBlobUrl=a.previewBlobUrl)}return a?(0,r.P4)(e,t,s,n):(0,r.cY)(e,t,s,n)}function V(e,t,s,n){const{chatId:a}=s,{threadInfo:o}=(0,i.Db)(e,a,s)||{};if(!o&&s.replyToMessageId){const o=(0,i.hj)(e,a,s.replyToMessageId);o?e=(0,r.lG)(e,o,a,s.id,n):t.loadMessage({chatId:a,messageId:s.replyToMessageId,threadUpdate:{isDeleting:n,lastMessageId:s.id}})}return e}function Y(e,t,s){const{id:n,chatId:a}=s,{threadInfo:o,firstMessageId:c}=(0,i.Db)(e,a,s)||{},d=(0,i.Z1)(e,a),m=(null==d?void 0:d.unreadCount)&&!(0,i.gb)(e,a,u._f);if(e=V(e,t,s),o&&(!c&&(0,l.CI)(s)||(e=(0,r.xj)(e,a,o.threadId,[n]),(0,i.b9)(e,a,o.threadId)&&(e=(0,r.$S)(e,a,o.threadId,n),c||(e=(0,r.pf)(e,a,o.threadId,"firstMessageId",s.id)))),e=(0,r.pf)(e,a,o.threadId,"threadInfo",{...o,lastMessageId:s.id,messagesCount:o.messagesCount+1})),m)return e;if(e=(0,r.xj)(e,a,u._f,[n]),(0,i.b9)(e,a,u._f)){const t=(0,i.It)(e,a,u._f),s=(0,r.$S)(e,a,u._f,n),o=(0,i.Cb)(s,a,u._f);t&&!o.includes(t)||(e=s)}return e}function K(e,t,s,n=!1){var a;const{chats:o}=e,i=null===(a=o.byId[t])||void 0===a?void 0:a.lastMessage;return!i||n||i.id===s.id||i.id===s.previousLocalId||s.id>i.id?(0,r.a4)(e,t,{lastMessage:s}):e}function W(e,t){const s=(0,i.Zw)(e,t),n=(0,i.gb)(e,t,u._f);if(!s||!n)return;let a=n.length;for(;a--;){const e=s[n[a]];if(!e.isDeleting)return e}}function X(e,t,s,a){if(e){t.forEach((t=>{const s=W(a=(0,r.cY)(a,e,t,{isDeleting:!0}),e);s&&(a=K(a,e,s,!0))})),(0,n.R3)(a),s.requestChatUpdate({chatId:e});const o=[];return t.forEach((t=>{const n=(0,i.hj)(a,e,t);if(!n)return;a=V(a,s,n,!0);const{threadInfo:r}=(0,i.Db)(a,e,n)||{};r&&o.push(r.threadId)})),(0,n.R3)(a),void setTimeout((()=>{(0,n.R3)((0,r.K4)((0,n.Rd)(),e,t)),(0,g.Tw)(o).forEach((t=>{s.requestThreadInfoUpdate({chatId:e,threadId:t})}))}),_)}const o=[];t.forEach((e=>{const t=(0,i.X5)(a,e);if(t){o.push(t);const s=W(a=(0,r.cY)(a,t,e,{isDeleting:!0}),t);s&&(a=K(a,t,s,!0)),setTimeout((()=>{(0,n.R3)((0,r.K4)((0,n.Rd)(),t,[e]))}),_)}})),(0,n.R3)(a),(0,g.Tw)(o).forEach((e=>{s.requestChatUpdate({chatId:e})}))}(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"newMessage":{const{chatId:o,id:c,message:d,shouldForceReply:m}=s;e=Y(e=z(e,o,c,d),t,d),d.threadInfo&&(e=(0,r.Xg)(e,d.threadInfo.chatId,d.threadInfo.threadId,d.threadInfo)),(0,n.R3)(e);const h=(0,i.hj)(e,o,c);if((0,i.hg)(e,o,d)){var a;if(d.isOutgoing&&(null===(a=d.content)||void 0===a||!a.action)){const s=(0,i.Bt)(e);s&&t.focusMessage({chatId:o,threadId:s.threadId,messageId:d.id,noHighlight:!0,isResizingContainer:!0})}const{threadInfo:s}=(0,i.Db)(e,o,d)||{};s&&t.requestThreadInfoUpdate({chatId:o,threadId:s.threadId}),(0,l.CI)(d)||setTimeout((()=>{let e=(0,n.Rd)();m&&(e=(0,r.pf)(e,o,u._f,"replyingToId",c)),(0,n.R3)(K(e,o,h))}),_)}else(0,n.R3)(K((0,n.Rd)(),o,h));(0,i.N)(e,o)||t.loadTopChats();break}case"newScheduledMessage":{const{chatId:t,id:a,message:o}=s;e=z(e,t,a,o,!0);const c=(0,i.qy)(e,t)||[];e=(0,r.pf)(e,t,u._f,"scheduledIds",(0,g.Tw)([...c,a])),(0,n.R3)(e);break}case"updateMessage":{var o,c;const{chatId:a,id:l,message:d}=s;if(!(0,i.hj)(e,a,l))return;e=z(e,a,l,d);const m=(0,i.hj)(e,a,l);d.threadInfo&&(e=(0,r.Xg)(e,d.threadInfo.chatId,d.threadInfo.threadId,d.threadInfo)),e=K(e,a,m),(0,n.R3)(e);const h=(0,i.Z1)(e,a);h&&!d.isOutgoing&&(null===(o=h.lastMessage)||void 0===o?void 0:o.id)===d.id&&(0,i.xo)(e,h)&&(0,i.hg)(e,a,d)&&(0,i.b9)(e,a,(null===(c=d.threadInfo)||void 0===c?void 0:c.threadId)||u._f)&&t.focusLastMessage();break}case"updateScheduledMessage":{const{chatId:t,id:a,message:o}=s;if(!(0,i.Tm)(e,t,a))return;e=z(e,t,a,o,!0);const c=Object.keys((0,i.Fn)(e,t)||{}).map(Number).sort(((e,t)=>t-e));e=(0,r.pf)(e,t,u._f,"scheduledIds",c),(0,n.R3)(e);break}case"updateMessageSendSucceeded":{const{chatId:a,localId:o,message:c}=s;e=Y(e,t,c);const l=(0,i.hj)(e,a,o);e=(0,r.K4)(e,a,[o]),c.isScheduled&&(e=(0,r.bV)(e,a,[o])),e=(0,r.cY)(e,a,c.id,{...l,...c,previousLocalId:o});const d=(0,i.hj)(e,a,c.id);e=K(e,a,d);const u=(0,i.Db)(e,a,c);null!=u&&u.threadInfo&&(t.markMessageListRead({maxId:c.id}),e=(0,r.pf)(e,a,u.threadInfo.threadId,"threadInfo",{...u.threadInfo,lastMessageId:c.id,lastReadInboxMessageId:c.id})),(0,n.R3)(e);break}case"updateScheduledMessageSendSucceeded":{const{chatId:t,localId:a,message:o}=s,c=(0,i.qy)(e,t)||[];e=(0,r.pf)(e,t,u._f,"scheduledIds",[...c,o.id]);const l=(0,i.Tm)(e,t,a);e=(0,r.bV)(e,t,[a]),e=(0,r.P4)(e,t,o.id,{...l,...o,previousLocalId:a}),(0,n.R3)(e);break}case"updatePinnedIds":{const{chatId:t,isPinned:a,messageIds:o}=s,c=(0,i.KB)(e,t)||[],l=a?[...c,...o].sort(((e,t)=>t-e)):c.filter((e=>!o.includes(e)));(0,n.R3)((0,r.pf)(e,t,u._f,"pinnedIds",l));break}case"updateThreadInfo":{const{chatId:t,threadId:a,threadInfo:o,firstMessageId:c}=s,l={...(0,i.tZ)(e,t,a),...o};if(!l.threadId)return;e=(0,r.Xg)(e,t,a,l),c&&(e=(0,r.pf)(e,t,a,"firstMessageId",c)),(0,n.R3)(e);break}case"resetMessages":{const{id:a}=s,o=(0,i.Zw)(e,a);o&&!(0,l.YC)(a)&&(e=(0,r.K4)(e,a,Object.keys(o).map(Number)),(0,n.R3)(e),t.loadFullChat({chatId:a,force:!0}));break}case"deleteMessages":{const{ids:n,chatId:a}=s;X(a,n,t,e);break}case"deleteScheduledMessages":{const{ids:t,chatId:a}=s;!function(e,t,s,a){e&&(t.forEach((t=>{a=(0,r.P4)(a,e,t,{isDeleting:!0})})),(0,n.R3)(a),setTimeout((()=>{a=(0,r.bV)((0,n.Rd)(),e,t);const s=(0,i.Fn)(a,e);a=(0,r.pf)(a,e,u._f,"scheduledIds",Object.keys(s||{}).map(Number)),(0,n.R3)(a)}),_))}(a,t,0,e);break}case"deleteHistory":{const{chatId:n}=s,a=e.messages.byChatId[n];a?X(n,Object.keys(a.byId).map(Number),t,e):t.requestChatUpdate({chatId:n});break}case"updateCommonBoxMessages":{const{ids:t,messageUpdate:a}=s;t.forEach((t=>{const s=(0,i.X5)(e,t);s&&(e=(0,r.cY)(e,s,t,a))})),(0,n.R3)(e);break}case"updateChannelMessages":{const{channelId:t,ids:a,messageUpdate:o}=s;a.forEach((s=>{e=(0,r.cY)(e,t,s,o)})),(0,n.R3)(e);break}case"updateMessagePoll":{const{pollId:t,pollUpdate:a}=s,o=(0,i.ZB)(e,t);if(null!=o&&o.content.poll){const t={...o.content.poll,...a},{results:s}=t.results||{};if(s&&!s.some((e=>e.isChosen))){const{results:e}=o.content.poll.results,n=e&&e.filter((e=>e.isChosen));n&&n.forEach((e=>{const n=s.findIndex((t=>t.option===e.option));n>=0&&(t.results.results[n].isChosen=!0)}))}(0,n.R3)((0,r.cY)(e,o.chatId,o.id,{content:{...o.content,poll:t}}))}break}case"updateMessagePollVote":{const{pollId:t,userId:a,options:o}=s,c=(0,i.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(a),o.forEach((t=>{const s=p.find((e=>e.option===t)),n=p.findIndex((e=>e.option===t)),o=s?{...s}:{option:t,votersCount:0};o.votersCount+=1,a===e.currentUserId&&(o.isChosen=!0),n?p[n]=o:p.push(o)})),(0,n.R3)((0,r.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:n}=s;(0,i.UW)(e)&&t.createServiceNotification({message:n});break}}}));const J=(0,C.P2)((function(){const e=(0,n.Rd)();(0,n.R3)((0,r.ps)(e,{...e.users.statusesById,...ee})),ee={}}),3e3,!0);let ee={};(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"deleteUser":return(0,r.h8)(e,s.id);case"updateUser":return(0,r.Nq)(e,s.id,s.user);case"updateUserStatus":return n=s.userId,a=s.status,ee[n]=a,void J();case"updateUserFullInfo":{const{id:t,fullInfo:n}=s,a=e.users.byId[t];if(!a)return;return(0,r.Nq)(e,t,{fullInfo:{...a.fullInfo,...n}})}}var n,a})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateStickerSet":return(0,r.Rg)(e,s.id,s.stickerSet)}})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updatePeerBlocked":return s.isBlocked?(0,r.O4)((0,n.Rd)(),s.id):(0,r.rB)((0,n.Rd)(),s.id);case"updateResetContactList":(0,n.R3)({...(0,n.Rd)(),contactList:{userIds:[]}});break;case"updateFavoriteStickers":t.loadFavoriteStickers();break;case"updatePrivacy":e.settings.privacy[s.key]=s.rules}})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateNotifySettings":return(0,r.HN)(e,s.peerType,s.isSilent,s.shouldShowPreviews);case"updateNotifyExceptions":{const{chatId:t,isMuted:a,isSilent:o,shouldShowPreviews:i}=s;e.chats.byId[t]&&(e=(0,r.a4)(e,t,{isMuted:a})),(0,n.R3)((0,r.aK)(e,t,{isMuted:a,isSilent:o,shouldShowPreviews:i}));break}}})),(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateTwoFaStateWaitCode":return{...e,twoFaSettings:{...e.twoFaSettings,isLoading:!1,waitingEmailCodeLength:s.length}};case"updateTwoFaError":return{...e,twoFaSettings:{...e.twoFaSettings,error:s.message}}}}));var te=s(4446);(0,n.Q6)("apiUpdate",((e,t,s)=>{switch(s["@type"]){case"updateGroupCall":return"discarded"===s.call.connectionState?e.groupCalls.activeGroupCallId?void t.leaveGroupCall({shouldRemove:!0}):(0,te.dc)(e,s.call.id):(0,te.AH)(e,s.call.id,(0,g.CE)(s.call,["connectionState"]),void 0,s.call.participantsCount);case"updateGroupCallChatId":{const t=(0,i.Z1)(e,s.chatId);return t&&(e=(0,r.a4)(e,s.chatId,{fullInfo:{...t.fullInfo,groupCallId:s.call.id}})),e}case"updateGroupCallParticipants":{const{groupCallId:t,participants:a,nextOffset:o}=s,{currentUserId:r}=e;return e=(0,n.Rd)(),a.forEach((s=>{s.id&&(e=(0,te.B6)(e,t,s.id,s,!!o||r===s.id))})),o&&(e=(0,te.AH)(e,t,{nextOffset:o})),e}}}));var se=s(8674),ne=s(6752),ae=s(1279),oe=s(3551),re=s(3227),ie=s(3858),ce=s(1212),le=s(5332);function de(e){(0,o.d4)((()=>(0,C.Gq)(e)),[e])}var ue=s(9290);const me=document.querySelector('meta[name="viewport"]'),he=(null==me?void 0:me.getAttribute("content"))||"";function ge(e){e.preventDefault()}var pe=s(6590),fe=s(3989),Ie=s(7529),ve=s(3455),ye=s(706),Ze=s(2255);function Pe(){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}var Ce=s(9107),we=s(6917),be=s(3106),Se=s(8964),Ee=s(231),Me=s(9589),ke=s(9187),Re=s(3321);const Te=[0,1,2],Ne=(0,o.X$)((0,n.c$)((e=>{const{query:t,fetchingStatus:s,chatId:n,date:a}=e.globalSearch,{currentUserId:o}=e,{byId:r}=e.chats,{animationLevel:c}=e.settings.byKey;return{searchQuery:t,isLoading:!!s&&Boolean(s.chats||s.messages),currentUserId:o,chatsById:r,globalSearchChatId:n,searchDate:a,theme:(0,i.Pu)(e),animationLevel:c}}))((({content:e,contactsFilter:t,onSearchQuery:s,onSelectSettings:r,onSelectContacts:i,onSelectArchived:c,onReset:d,searchQuery:u,isLoading:g,shouldSkipTransition:p,currentUserId:f,globalSearchChatId:I,searchDate:v,theme:y,animationLevel:Z,chatsById:P})=>{const{openChat:C,openTipsChat:w,setGlobalSearchDate:b,setSettingOption:S,setGlobalSearchChatId:E}=(0,n.uC)(),M=(0,Ce.Z)(),k=e===m.du.ChatList,R=(0,o.Ye)((()=>v?(0,N.xH)(new Date(1e3*v)):void 0),[v]),T=(0,o.Ye)((()=>k&&P?Object.values(P).reduce(((e,t)=>(0,l.pE)(t)&&t.unreadCount?e+1:e),0):0),[k,P]),B="web.telegram.org"===window.location.hostname,A=(0,o.Ye)((()=>({onTrigger:e,isOpen:t})=>o.ZP.createElement(Ee.Z,{round:!0,ripple:k&&!h.wB,size:"smaller",color:"translucent",className:t?"active":"",onClick:k?e:()=>d(),ariaLabel:k?M("AccDescrOpenMenu2"):"Return to chat list"},o.ZP.createElement("div",{className:(0,ne.Z)("animated-menu-icon",!k&&"state-back",p&&"no-animation")}))),[k,M,d,p]),x=(0,o.I4)((()=>{u||s("")}),[u,s]),L=(0,o.I4)((()=>{C({id:f,shouldReplaceHistory:!0})}),[f,C]),O=(0,o.I4)((e=>{e.stopPropagation();const t="light"===y?"dark":"light";S({theme:t}),S({shouldUseSystemTheme:!1}),(0,we.Z)(t,Z===a.zy)}),[Z,S,y]),F=(0,o.I4)((e=>{e.stopPropagation();const t=0===Z?2:0;Te.forEach(((e,s)=>{document.body.classList.toggle(`animation-level-${s}`,t===s)})),S({animationLevel:t})}),[Z,S]),U=Boolean(I)||e===m.du.GlobalSearch||e===m.du.Contacts,$=e===m.du.Contacts?M("SearchFriends"):M("Search");return o.ZP.createElement("div",{className:"LeftMainHeader"},o.ZP.createElement("div",{id:"LeftMainHeader",className:"left-header"},o.ZP.createElement(be.Z,{trigger:A,footer:`${a.iC} ${a.Ji}`},o.ZP.createElement(Se.Z,{icon:"saved-messages",onClick:L},M("SavedMessages")),o.ZP.createElement(Se.Z,{icon:"archive",onClick:c},o.ZP.createElement("span",{className:"menu-item-name"},M("ArchivedChats")),T>0&&o.ZP.createElement("div",{className:"archived-badge"},T)),o.ZP.createElement(Se.Z,{icon:"user",onClick:i},M("Contacts")),o.ZP.createElement(Se.Z,{icon:"settings",onClick:r},M("Settings")),o.ZP.createElement(Se.Z,{icon:"darkmode",onClick:O},o.ZP.createElement("span",{className:"menu-item-name"},M("lng_menu_night_mode")),o.ZP.createElement(Re.Z,{id:"darkmode",label:M("dark"===y?"lng_settings_disable_night_theme":"lng_settings_enable_night_theme"),checked:"dark"===y,noAnimation:!0})),o.ZP.createElement(Se.Z,{icon:"animations",onClick:F},o.ZP.createElement("span",{className:"menu-item-name capitalize"},M("Appearance.Animations").toLowerCase()),o.ZP.createElement(Re.Z,{id:"animations",label:"Toggle Animations",checked:Z>0})),o.ZP.createElement(Se.Z,{icon:"help",onClick:()=>{w({langCode:M.code})}},M("TelegramFeatures")),o.ZP.createElement(Se.Z,{icon:"bug",href:a.mU},"Report Bug"),B&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Se.Z,{icon:"char-K",href:"https://web.telegram.org/k/",onClick:()=>{localStorage.setItem("kz_version",JSON.stringify("K")),(0,pe.Wv)()}},"Switch to K Version"),o.ZP.createElement(Se.Z,{icon:"char-W",href:"https://web.telegram.org/?legacy=1",onClick:pe.Wv},"Switch to Old Version"))),o.ZP.createElement(Me.Z,{inputId:"telegram-search-input",parentContainerClassName:"LeftSearch",className:I||v?"with-picker-item":"",value:t||u,focused:U,isLoading:g,placeholder:$,autoComplete:"off",canClose:Boolean(I||v),onChange:s,onReset:d,onFocus:x},R&&o.ZP.createElement(ke.Z,{icon:"calendar",title:R,canClose:!0,isMinimized:Boolean(I),className:"search-date",onClick:b,clickArg:{date:void 0}}),I&&o.ZP.createElement(ke.Z,{chatOrUserId:I,onClick:E,canClose:!0,clickArg:{id:void 0}}))))})));var Be=s(9204);const Ae=(0,o.X$)((()=>{const e=(0,Ce.Z)();return o.ZP.createElement("div",{id:"ConnectionState",dir:e.isRtl?"rtl":void 0},o.ZP.createElement(Be.Z,{color:"black"}),o.ZP.createElement("div",{className:"state-text"},e("WaitingForNetwork")))}));var xe=s(1174),Le=s(6071),Oe=s(3133),Fe=s(1080);const Ue=(0,o.X$)((0,n.c$)((e=>{const{chats:{listIds:t,byId:s},users:{byId:n},chatFolders:{byId:a,orderedIds:o,activeChatFolder:r},currentUserId:c,lastSyncTime:l,shouldSkipHistoryAnimations:d}=e;return{allListIds:t,chatsById:s,usersById:n,chatFoldersById:a,orderedFolderIds:o,lastSyncTime:l,notifySettings:(0,i.dZ)(e),notifyExceptions:(0,i.NJ)(e),activeChatFolder:r,currentUserId:c,shouldSkipHistoryAnimations:d}}))((({allListIds:e,chatsById:t,usersById:s,chatFoldersById:r,notifySettings:i,notifyExceptions:c,orderedFolderIds:d,activeChatFolder:u,currentUserId:m,lastSyncTime:p,shouldSkipHistoryAnimations:f,foldersDispatch:I,onScreenSelect:v})=>{const{loadChatFolders:y,setActiveChatFolder:Z,openChat:P}=(0,n.uC)(),C=(0,o.sO)(null),w=(0,Ce.Z)();(0,o.d4)((()=>{p&&y()}),[p,y]);const b=(0,o.Ye)((()=>d?d.map((e=>r[e]||{})).filter(Boolean):void 0),[r,d]),S=((n,a,r)=>{const d=(0,Le.Z)(3e3,!0),[u,m]=(0,o.eJ)(),[h,p,f]=(0,ye.Z)();return(0,se.ZP)(p,f),(0,ue.Z)((()=>{h||d((()=>{m((()=>{if(!b||!b.length)return;const n=b.map((n=>{const{unreadDialogsCount:a,hasActiveDialogs:o}=(0,l.Fu)(e,t,s,n,i,c)||{};return{id:n.id,badgeCount:a,isBadgeActive:o}}));return(0,g.ee)(n,"id")})())}))}),r.concat([h])),u})(0,0,[b,e,t,s,i,c]),E=(0,o.Ye)((()=>{if(b&&b.length)return[{title:"en"===w.code?"All":w("FilterAllChats"),id:a.Nf},...b.map((e=>({title:e.title,...null==S?void 0:S[e.id]})))]}),[b,S,w]),M=(0,o.I4)((e=>{Z(e,{forceOnHeavyAnimation:!0})}),[Z]);(0,o.d4)((()=>{E&&E.length&&u>=E.length&&Z(0)}),[u,E,Z]),(0,o.d4)((()=>{if(C.current&&h.$b&&E&&E.length)return(0,xe.s)(C.current,{selectorToPreventScroll:".chat-list",onSwipe:(e,t)=>t===xe.e.Left?(Z(Math.min(u+1,E.length-1),{forceOnHeavyAnimation:!0}),!0):t===xe.e.Right&&(Z(Math.max(0,u-1),{forceOnHeavyAnimation:!0}),!0)})}),[u,E,Z]);const k=(0,o.sO)();k.current=0!==u,(0,o.d4)((()=>k.current?(0,fe.Z)((()=>{k.current&&Z(0)})):void 0),[u,Z]),(0,pe.ZP)(0!==u,(()=>Z(0,{forceOnHeavyAnimation:!0}))),(0,o.d4)((()=>{const e=e=>{if(e.ctrlKey&&e.shiftKey&&e.code.startsWith("Digit")&&E){const[,t]=e.code.match(/Digit(\d)/)||[];if(!t)return;if("0"===t)return void P({id:m,shouldReplaceHistory:!0});const s=Number(t)-1;if(s>E.length-1)return;Z(s,{forceOnHeavyAnimation:!0}),e.preventDefault()}};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}}));const{shouldRender:R,transitionClassNames:T}=(0,ce.Z)(!d,void 0,!0);function N(e){const t=Object.values(r).find((({id:e})=>e===E[u].id));return t&&0!==u?o.ZP.createElement(Fe.Z,{folderType:"folder",folderId:t.id,isActive:e,onScreenSelect:v,foldersDispatch:I}):o.ZP.createElement(Fe.Z,{folderType:"all",isActive:e,foldersDispatch:I,onScreenSelect:v})}return o.ZP.createElement("div",{className:"ChatFolders"},null!=E&&E.length?o.ZP.createElement(Oe.Z,{tabs:E,activeTab:u,onSwitchTab:M}):R?o.ZP.createElement("div",{className:(0,ne.Z)("tabs-placeholder",T)}):void 0,o.ZP.createElement(Ze.Z,{ref:C,name:f?"none":w.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:u,renderCount:E?E.length:void 0},N))})));var $e=s(9203),De=s(8778),qe=s(4288);const Qe=(0,o.X$)((e=>{const t=(0,De.Z)($e.gl.Extra,"LeftSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),Ge=(0,o.X$)((e=>{const t=(0,De.Z)($e.gl.Extra,"ContactList");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)}));var je=s(2328);let He;const _e=(0,o.X$)((({isShown:e,onNewPrivateChat:t,onNewChannel:s,onNewGroup:n})=>{const[a,r]=(0,o.eJ)(!1);(0,o.d4)((()=>{e||r(!1)}),[e]);const i=(0,Ce.Z)(),c=(0,ne.Z)("NewChatButton",e&&"revealed",a&&"menu-is-open"),l=(0,o.I4)((()=>{He&&(clearTimeout(He),He=void 0)}),[]),d=(0,o.I4)((()=>{He&&(clearTimeout(He),He=void 0),He=window.setTimeout((()=>{r(!1)}),750)}),[]);return o.ZP.createElement("div",{className:c,onMouseEnter:l,onMouseLeave:d},o.ZP.createElement(Ee.Z,{round:!0,color:"primary",className:a?"active":"",onClick:()=>{r(!a)},ariaLabel:i(a?"Close":"NewMessageTitle"),tabIndex:-1},o.ZP.createElement("i",{className:"icon-new-chat-filled"}),o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(je.Z,{isOpen:a,positionX:"right",positionY:"bottom",autoClose:!0,onClose:()=>{r(!1)}},o.ZP.createElement(Se.Z,{icon:"channel",onClick:s},i("NewChannel")),o.ZP.createElement(Se.Z,{icon:"group",onClick:n},i("NewGroup")),o.ZP.createElement(Se.Z,{icon:"user",onClick:t},i("NewMessageTitle"))))}));var ze=s(126);const Ve=Object.keys(m.du).length/2;let Ye;const Ke=(0,n.c$)((e=>(0,g.ei)(e,["connectionState"])))((({content:e,searchQuery:t,searchDate:s,contactsFilter:n,shouldSkipTransition:a,foldersDispatch:r,onSearchQuery:i,onContentChange:c,onScreenSelect:l,onReset:d,connectionState:u})=>{const[g,p]=(0,o.eJ)(h.$b),f=!Pe()||"connectionStateConnecting"===u,I=(0,o.sO)(!1),v=(0,o.I4)((()=>{c(m.du.Settings)}),[c]),y=(0,o.I4)((()=>{c(m.du.Contacts)}),[c]),Z=(0,o.I4)((()=>{c(m.du.NewChannelStep1)}),[c]),P=(0,o.I4)((()=>{c(m.du.NewGroupStep1)}),[c]),C=(0,o.I4)((()=>{c(m.du.Archived)}),[c]),w=(0,o.I4)((()=>{e===m.du.ChatList&&(I.current=!0,p(!0))}),[e]),b=(0,o.I4)((()=>{I.current=!1,Ye&&(clearTimeout(Ye),Ye=void 0),Ye=window.setTimeout((()=>{I.current||p(!1)}),250)}),[]);(0,o.d4)((()=>{let t;return e!==m.du.ChatList?t=window.setTimeout((()=>{p(!1)}),250):(I.current||h.$b)&&p(!0),()=>{t&&(clearTimeout(t),t=void 0)}}),[e]);const[S,E,M]=function(){const[e,t]=(0,ye.Z)(!1);(0,o.d4)((()=>{const e=window.setTimeout(t,2592e5);return()=>{clearTimeout(e)}}),[t]);const{shouldRender:s,transitionClassNames:n}=(0,ce.Z)(e);return[s,n,()=>{window.location.reload()}]}(),k=(0,Ce.Z)();return o.ZP.createElement("div",{id:"LeftColumn-main",onMouseEnter:h.$b?void 0:w,onMouseLeave:h.$b?void 0:b},o.ZP.createElement(Ne,{content:e,contactsFilter:n,onSearchQuery:i,onSelectSettings:v,onSelectContacts:y,onSelectArchived:C,onReset:d,shouldSkipTransition:a}),o.ZP.createElement(ze.Z,{isOpen:f,isCustom:!0,className:"connection-state-wrapper opacity-transition slow"},(()=>o.ZP.createElement(Ae,null))),o.ZP.createElement(Ze.Z,{name:a?"none":"zoom-fade",renderCount:Ve,activeKey:e,shouldCleanup:!0,cleanupExceptionKey:m.du.ChatList,className:f?"pull-down":void 0},(a=>{switch(e){case m.du.ChatList:return o.ZP.createElement(Ue,{onScreenSelect:l,foldersDispatch:r});case m.du.GlobalSearch:return o.ZP.createElement(Qe,{searchQuery:t,searchDate:s,isActive:a,onReset:d});case m.du.Contacts:return o.ZP.createElement(Ge,{filter:n,isActive:a,onReset:d});default:return}})),S&&o.ZP.createElement(Ee.Z,{fluid:!0,pill:!0,className:(0,ne.Z)("btn-update",E),onClick:M},k("lng_update_telegram")),o.ZP.createElement(_e,{isShown:g,onNewPrivateChat:y,onNewChannel:Z,onNewGroup:P}))})),We=(0,o.X$)((e=>{const t=(0,De.Z)($e.gl.Extra,"Settings");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),Xe=(0,o.X$)((e=>{const t=(0,De.Z)($e.gl.Extra,"NewChat");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),Je=(0,o.X$)((e=>{const t=(0,De.Z)($e.gl.Extra,"ArchivedChats");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)}));var et;!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"}(et||(et={}));const tt=Object.keys(et).length/2,st=(0,o.X$)((0,n.c$)((e=>{const{globalSearch:{query:t,date:s},chatFolders:{activeChatFolder:n},shouldSkipHistoryAnimations:a,leftColumnWidth:o}=e;return{searchQuery:t,searchDate:s,activeChatFolder:n,shouldSkipHistoryAnimations:a,leftColumnWidth:o}}))((({searchQuery:e,searchDate:t,activeChatFolder:s,shouldSkipHistoryAnimations:a,leftColumnWidth:r})=>{const{setGlobalSearchQuery:i,setGlobalSearchChatId:c,resetChatCreation:l,setGlobalSearchDate:d,loadPasswordInfo:u,clearTwoFaError:g,setLeftColumnWidth:p,resetLeftColumnWidth:f}=(0,n.uC)(),I=(0,o.sO)(null),[v,y]=(0,o.eJ)(m.du.ChatList),[Z,P]=(0,o.eJ)(m.MT.Main),[C,w]=(0,o.eJ)(""),[b,S]=(0,ve.ZP)(),[E,M]=(0,o.eJ)(0);let k=et.Main;switch(v){case m.du.Archived:k=et.Archived;break;case m.du.Settings:k=et.Settings;break;case m.du.NewChannelStep1:case m.du.NewChannelStep2:k=et.NewChannel;break;case m.du.NewGroupStep1:case m.du.NewGroupStep2:k=et.NewGroup}const R=(0,o.I4)((e=>{if(v!==m.du.NewGroupStep2||e)if(v!==m.du.NewChannelStep2||e){if(v===m.du.NewGroupStep1){const e=document.getElementById("new-group-picker-search");e&&e.blur()}if(v===m.du.Settings)switch(Z){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 P(m.MT.Main);case m.MT.GeneralChatBackground:return void P(m.MT.General);case m.MT.GeneralChatBackgroundColor:return void P(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 P(m.MT.Privacy);case m.MT.PrivacyPhoneNumberAllowedContacts:case m.MT.PrivacyPhoneNumberDeniedContacts:return void P(m.MT.PrivacyPhoneNumber);case m.MT.PrivacyLastSeenAllowedContacts:case m.MT.PrivacyLastSeenDeniedContacts:return void P(m.MT.PrivacyLastSeen);case m.MT.PrivacyProfilePhotoAllowedContacts:case m.MT.PrivacyProfilePhotoDeniedContacts:return void P(m.MT.PrivacyProfilePhoto);case m.MT.PrivacyForwardingAllowedContacts:case m.MT.PrivacyForwardingDeniedContacts:return void P(m.MT.PrivacyForwarding);case m.MT.PrivacyGroupChatsAllowedContacts:case m.MT.PrivacyGroupChatsDeniedContacts:return void P(m.MT.PrivacyGroupChats);case m.MT.TwoFaNewPassword:return void P(m.MT.TwoFaDisabled);case m.MT.TwoFaNewPasswordConfirm:return void P(m.MT.TwoFaNewPassword);case m.MT.TwoFaNewPasswordHint:return void P(m.MT.TwoFaNewPasswordConfirm);case m.MT.TwoFaNewPasswordEmail:return void P(m.MT.TwoFaNewPasswordHint);case m.MT.TwoFaNewPasswordEmailCode:return void P(m.MT.TwoFaNewPasswordEmail);case m.MT.TwoFaChangePasswordCurrent:case m.MT.TwoFaTurnOff:case m.MT.TwoFaRecoveryEmailCurrentPassword:return void P(m.MT.TwoFaEnabled);case m.MT.TwoFaChangePasswordNew:return void P(m.MT.TwoFaChangePasswordCurrent);case m.MT.TwoFaChangePasswordConfirm:return void P(m.MT.TwoFaChangePasswordNew);case m.MT.TwoFaChangePasswordHint:return void P(m.MT.TwoFaChangePasswordConfirm);case m.MT.TwoFaRecoveryEmail:return void P(m.MT.TwoFaRecoveryEmailCurrentPassword);case m.MT.TwoFaRecoveryEmailCode:return void P(m.MT.TwoFaRecoveryEmail);case m.MT.FoldersCreateFolder:case m.MT.FoldersEditFolder:return void P(m.MT.Folders);case m.MT.FoldersIncludedChatsFromChatList:case m.MT.FoldersExcludedChatsFromChatList:return void P(m.MT.FoldersEditFolderFromChatList);case m.MT.FoldersEditFolderFromChatList:return y(m.du.ChatList),void P(m.MT.Main)}v!==m.du.ChatList||0!==s?(y(m.du.ChatList),w(""),i({query:""}),d({date:void 0}),c({id:void 0}),l(),setTimeout((()=>{M(Date.now())}),250)):y(m.du.GlobalSearch)}else y(m.du.NewChannelStep1);else y(m.du.NewGroupStep1)}),[v,s,Z,i,d,c,l]),T=(0,o.I4)((t=>{v!==m.du.Contacts?(y(m.du.GlobalSearch),t!==e&&i({query:t})):w(t)}),[v,e,i]);(0,o.d4)((()=>v!==m.du.ChatList||0===s?(0,fe.Z)((()=>R())):void 0),[s,v,R]),(0,o.d4)((()=>{if(v!==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,Ie.Z)(e)&&(e.preventDefault(),y(m.du.GlobalSearch))}}),[v]),(0,o.d4)((()=>{g(),Z===m.MT.Privacy&&u()}),[g,u,Z]);const{initResize:N,resetResize:B,handleMouseUp:A}=((e,t,s,n)=>{const[a,r,i]=(0,ye.Z)(),[c,l]=(0,o.eJ)(),[d,u]=(0,o.eJ)();(0,o.d4)((()=>{e.current&&n&&(e.current.style.width=`${n}px`)}),[e,n]);const m=()=>{document.body.classList.remove("no-selection","cursor-ew-resize")};return(0,o.d4)((()=>{if(!a)return;const s=t=>{const s=Math.ceil(d+t.clientX-c);e.current.style.width=`${s}px`},n=()=>{m(),document.removeEventListener("mousemove",s,!1),document.removeEventListener("mouseup",n,!1),document.removeEventListener("blur",n,!1),t(e.current.offsetWidth),i()};document.addEventListener("mousemove",s,!1),document.addEventListener("mouseup",n,!1),document.addEventListener("blur",n,!1)}),[d,c,e,t,a,i]),{initResize:t=>{document.body.classList.add("no-selection","cursor-ew-resize"),l(t.clientX),u(e.current.offsetWidth),r()},resetResize:t=>{t.preventDefault(),e.current.style.width="",s()},handleMouseUp:m}})(I,p,f,r),x=e=>{y(m.du.Settings),P(e)};return o.ZP.createElement("div",{id:"LeftColumn",ref:I},o.ZP.createElement(Ze.Z,{name:a?"none":h.s0,renderCount:tt,activeKey:k,shouldCleanup:!0,cleanupExceptionKey:et.Main},(s=>{switch(k){case et.Archived:return o.ZP.createElement(Je,{isActive:s,onReset:R,onContentChange:y});case et.Settings:return o.ZP.createElement(We,{isActive:s,currentScreen:Z,foldersState:b,foldersDispatch:S,onScreenSelect:x,onReset:R,shouldSkipTransition:a});case et.NewChannel:return o.ZP.createElement(Xe,{key:E,isActive:s,isChannel:!0,content:v,onContentChange:y,onReset:R});case et.NewGroup:return o.ZP.createElement(Xe,{key:E,isActive:s,content:v,onContentChange:y,onReset:R});default:return o.ZP.createElement(Ke,{content:v,searchQuery:e,searchDate:t,contactsFilter:C,foldersDispatch:S,onContentChange:y,onSearchQuery:T,onScreenSelect:x,onReset:R,shouldSkipTransition:a})}})),o.ZP.createElement("div",{className:"resize-handle",onMouseDown:N,onMouseUp:A,onDoubleClick:B}))})));var nt=s(2420),at=s(5780),ot=s(9524),rt=s(1394);const it=()=>{const[e,t]=(0,o.eJ)(ie.Z.get());return(0,o.d4)((()=>{const e=(0,C.P2)((()=>{t(ie.Z.get())}),250,!1);return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),e};var ct=s(2678),lt=s(7204),dt=s(5326);const ut=728;var mt=s(3570),ht=s(5790),gt=s(8360),pt=s(2155),ft=s(6058),It=s(8799);const vt=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"HeaderMenuContainer",!t);return s?o.ZP.createElement(s,e):void 0})),yt=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,messageListType:n})=>{var a;const o=(0,i.Z1)(e,t),r=Boolean(o&&(0,l.eA)(o));if(!o||o.isRestricted||(0,i.CA)(e))return{noMenu:!0};const c=(0,i.IK)(e,t),d=(0,i.FM)(e,t),m="thread"===n&&s===u._f,g="thread"===n&&s!==u._f,p=(0,i.Jf)(e),f=Boolean(c&&(0,i.s4)(e,c.id)),I=!f&&Boolean((0,i.pk)(e,t)),v=Boolean(m&&(r||(0,l.ZV)(o))&&o.isNotJoined);return{noMenu:!1,isChannel:r,isRightColumnShown:p,canStartBot:I,canRestartBot:f,canSubscribe:v,canSearch:m||g,canCall:h.Bi&&(0,l.YC)(o.id)&&!d&&!c,canMute:m&&!d&&!v,canLeave:m&&!v,canEnterVoiceChat:h.Bi&&o.isCallActive,canCreateVoiceChat:h.Bi&&!o.isCallActive&&((null===(a=o.adminRights)||void 0===a?void 0:a.manageCall)||o.isCreator&&(0,l.G9)(o))}}))((({chatId:e,threadId:t,noMenu:s,isChannel:a,canStartBot:r,canRestartBot:i,canSubscribe:c,canSearch:l,canCall:d,canMute:u,canLeave:m,canEnterVoiceChat:g,canCreateVoiceChat:p,isRightColumnShown:f,canExpandActions:I})=>{const{joinChannel:v,sendBotCommand:y,openLocalTextSearch:Z,restartBot:P,openCallFallbackConfirm:C}=(0,n.uC)(),w=(0,o.sO)(null),[b,S]=(0,o.eJ)(!1),[E,M]=(0,o.eJ)(void 0),k=(0,o.I4)((()=>{S(!0);const e=w.current.getBoundingClientRect();M({x:e.right,y:e.bottom})}),[]),R=(0,o.I4)((()=>{S(!1)}),[]),T=(0,o.I4)((()=>{M(void 0)}),[]),N=(0,o.I4)((()=>{v({chatId:e})}),[v,e]),B=(0,o.I4)((()=>{y({command:"/start"})}),[y]),A=(0,o.I4)((()=>{P({chatId:e})}),[e,P]),x=(0,o.I4)((()=>{Z(),h.wB?document.querySelector("#MobileSearch input").focus():setTimeout((()=>{const e=document.querySelector(".RightHeader .SearchInput input");e&&e.focus()}),400)}),[Z]);(0,o.d4)((()=>{if(l)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,Ie.Z)(e)&&(e.preventDefault(),x())}}),[l,x]);const L=(0,Ce.Z)();return o.ZP.createElement("div",{className:"HeaderActions"},!h.wB&&o.ZP.createElement(o.ZP.Fragment,null,I&&c&&o.ZP.createElement(Ee.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:N},L(a?"ProfileJoinChannel":"ProfileJoinGroup")),I&&r&&o.ZP.createElement(Ee.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:B},L("BotStart")),I&&i&&o.ZP.createElement(Ee.Z,{size:"tiny",ripple:!0,fluid:!0,onClick:A},L("BotRestart")),l&&o.ZP.createElement(Ee.Z,{round:!0,ripple:f,color:"translucent",size:"smaller",onClick:x,ariaLabel:"Search in this chat"},o.ZP.createElement("i",{className:"icon-search"})),d&&o.ZP.createElement(Ee.Z,{round:!0,color:"translucent",size:"smaller",onClick:C,ariaLabel:"Call"},o.ZP.createElement("i",{className:"icon-phone"}))),o.ZP.createElement(Ee.Z,{ref:w,className:b?"active":"",round:!0,ripple:!h.wB,size:"smaller",color:"translucent",disabled:s,ariaLabel:"More actions",onClick:k},o.ZP.createElement("i",{className:"icon-more"})),E&&o.ZP.createElement(vt,{chatId:e,threadId:t,isOpen:b,anchor:E,withExtraActions:h.wB||!I,isChannel:a,canStartBot:r,canRestartBot:i,canSubscribe:c,canSearch:l,canCall:d,canMute:u,canLeave:m,canEnterVoiceChat:g,canCreateVoiceChat:p,onSubscribeChannel:N,onSearchClick:x,onClose:R,onCloseAnimationEnd:T}))})));var Zt=s(4399),Pt=s(2340),Ct=s(6202),wt=s(862);function bt(e){var t;const s=e&&(0,l.DH)(e),n=null==e||null===(t=e.content)||void 0===t?void 0:t.sticker,r=s&&n&&!(0,h.on)()&&s.includes("image/webp"),[i,c]=(0,o.eJ)(wt.Hu),d=null==e?void 0:e.id;return(0,o.bt)((()=>{r&&(0,wt.p6)(`b64-${d}`,s).then(c).catch((e=>{a.eM&&console.error(e)}))}),[d,r,s]),r?i:s}var St=s(7551),Et=s(8512);function Mt(e,t,s,n,a){return`M${e},${t+a}a${a},${a},0,0,1,\n ${s},0v${n-2*a}a${a},${a},0,0,1,${-s},0Z`}const kt=(0,o.X$)((({count:e,index:t})=>{const s=(0,o.sO)(null),n=(0,o.Ye)((()=>function(e,t){const s=e-t-1,n=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),a=function(e,t){let s=36;return 1===e?s=36:2===e?s=17:3===e?s=1===t?12:11:(4===e||e>3)&&(s=7.5),s}(e,s),o=function(e,t){return e<=3?36:t*e+2*(e-1)}(e,n),r=`clipPath${e}`;return{markHeight:a,clipPath:function(e,t,s){let n="";if(3===s)n=Mt(0,0,2,t,1)+Mt(0,12,2,t+1,1)+Mt(0,25,2,t,1);else for(let e=0;e<s;e++)n+=Mt(0,(t+2)*e,2,t,1);return`<clipPath id="${e}">\n <path d="${n}" />\n </clipPath>`}(r,n,e),markTranslateY:function(e,t,s){return 1===s?0:2===s?0===e?0:t+2:3===s?0===e?0:1===e?12:25:(t+2)*e}(s,n,e),trackTranslateY:function(e,t,s,n){return t<=4||e<=1?0:e>=t-2?n-36:(s+4)/2+(e-2)*(s+2)}(s,e,n,o),trackHeight:o,clipPathId:r}}(e,t)),[e,t]);if((0,o.d4)((()=>{if(!s.current)return;const{trackHeight:e,trackTranslateY:t,markHeight:a,markTranslateY:o,clipPathId:r,clipPath:i}=n,c=s.current.firstElementChild;if(null!=s&&s.current){const n=s.current,{style:l}=n;l.height=`${e}px`,l.transform=`translateY(-${t}px)`,l.clipPath=`url("#${r}")`;const d=n.querySelector("svg"),u=n.querySelector("div"),m=n.querySelector("defs");d||c&&(c.innerHTML=`<svg height="0" width="0"><defs> ${i} </defs></svg>`),m&&(m.innerHTML=i),u&&(u.style.height=`${a}px`,u.style.transform=`translateY(${o}px)`)}}),[n]),1===e)return o.ZP.createElement("div",{className:"pinned-message-border"},o.ZP.createElement("div",{className:"pinned-message-border-wrapper-1",ref:s}));const{trackHeight:a,trackTranslateY:r,markHeight:i,markTranslateY:c,clipPathId:l}=n;return o.ZP.createElement("div",{className:(0,ne.Z)("pinned-message-border",e>4&&"pinned-message-border-mask")},o.ZP.createElement("div",{className:"pinned-message-border-wrapper",ref:s,style:`clip-path: url("#${l}"); width: 2px;\n height: ${a}px; transform: translateY(-${r}px);`},o.ZP.createElement("span",null),o.ZP.createElement("div",{className:"pinned-message-border-mark",style:`height: ${i}px; transform: translateY(${c}px);`})))})),Rt=(0,o.X$)((({message:e,count:t,index:s,customTitle:n,className:a,onUnpinMessage:r,onClick:i,onAllPinnedClick:c})=>{const d=(0,Ce.Z)(),u=bt(e),m=(0,Ct.Z)((0,l.Ti)(e,"pictogram")),h=(0,l.MK)(d,e,Boolean(u)),[g,p,f]=(0,ye.Z)(),I=(0,o.I4)((()=>{f(),r&&r(e.id)}),[f,r,e.id]);return o.ZP.createElement("div",{className:(0,ne.Z)("HeaderPinnedMessage-wrapper",a)},t>1&&o.ZP.createElement(Ee.Z,{round:!0,size:"smaller",color:"translucent",className:"pin-list-button",ariaLabel:d("EventLogFilterPinnedMessages"),onClick:c},o.ZP.createElement("i",{className:"icon-pin-list"})),r&&o.ZP.createElement(Ee.Z,{round:!0,size:"smaller",color:"translucent",ariaLabel:d("UnpinMessageAlertTitle"),className:"unpin-button",onClick:p},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(St.Z,{isOpen:g,onClose:f,text:"Would you like to unpin this message?",confirmLabel:"Unpin",confirmHandler:I}),o.ZP.createElement("div",{className:"HeaderPinnedMessage",onClick:i,dir:d.isRtl?"rtl":void 0},o.ZP.createElement(kt,{count:t,index:s}),u&&function(e,t){const{width:s,height:n}=(0,Zt.W7)();return o.ZP.createElement("img",{src:t||e,width:s,height:n,alt:""})}(u,m),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("div",{className:"title",dir:"auto"},n||`${d("PinnedMessage")} ${s>0?"#"+(t-s):""}`),o.ZP.createElement("p",{dir:"auto"},(0,Pt.Z)(h))),o.ZP.createElement(Et.Z,null)))}));var Tt=s(647),Nt=s(396),Bt=s(4532),At=s(3186),xt=s(663);function Lt(e,t,s="image/png"){const n=e instanceof Blob?URL.createObjectURL(e):e,a=new Image;return new Promise((o=>{a.onload=()=>{Ot(a,a.width*t,a.height*t,s).then((e=>URL.createObjectURL(e))).then(o).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(n)}))},a.src=n}))}async function Ot(e,t,s,n="image/png"){if(!("createImageBitmap"in window))return Ft(e,t,s,void 0,n);try{const a=await window.createImageBitmap(e,{resizeWidth:t,resizeHeight:s,resizeQuality:"high"});if(a.height!==s||a.width!==t)throw new Error("Image bitmap resize not supported!");return await new Promise((e=>{const t=document.createElement("canvas");t.width=a.width,t.height=a.height;const s=t.getContext("bitmaprenderer");s?s.transferFromImageBitmap(a):t.getContext("2d").drawImage(a,0,0),t.toBlob(e,n)}))}catch(a){return Ft(e,t,s,void 0,n)}}function Ft(e,t,s,n=.5,a="image/png"){const o=document.createElement("canvas"),r=o.getContext("2d"),i=document.createElement("canvas"),c=i.getContext("2d");if(o.width=t,o.height=s,e.width*n>t){const s=1/n;let a={width:Math.floor(e.width*n),height:Math.floor(e.height*n)};for(i.width=a.width,i.height=a.height,c.drawImage(e,0,0,a.width,a.height);a.width*n>t;)a={width:Math.floor(a.width*n),height:Math.floor(a.height*n)},c.drawImage(i,0,0,a.width*s,a.height*s,0,0,a.width,a.height);r.drawImage(i,0,0,a.width,a.height,0,0,o.width,o.height)}else r.drawImage(e,0,0,o.width,o.height);return new Promise((e=>{o.toBlob(e,a)}))}var Ut=s(4524);const $t={width:200,height:200},Dt=115,qt=(e,t,s)=>{const{audio:n,voice:a}=(0,l.qp)(e),r=n?n.title||n.fileName:a?"Voice message":"",i=n&&n.performer||t&&(0,l.OU)(xt.i0,t),c=s&&(0,l.U)(xt.i0,s)||"Telegram",d=n&&(0,l.MR)(n)&&(0,l.Ti)(e,"pictogram"),u=t&&(0,l.RT)(t,"big"),m=n&&d||a&&u,h=(0,Ct.Z)(m),g=(0,o.Ye)((()=>function(e,t,s){if(!s)return $t;if(e){if(!e.thumbnailSizes||0===e.thumbnailSizes.length)return;return e.thumbnailSizes.find((e=>"m"===e.type))||e.thumbnailSizes[0]}return t?Zt.vY:void 0}(n,a,h)),[n,h,a]),{result:p}=((e,t,s)=>{const[n,a]=(0,o.eJ)(!1),[r,i]=(0,o.eJ)(),[c,l]=(0,o.eJ)(s);return(0,o.d4)((()=>{a(!0);let e=!1;return function(e,t){if(!e)return Promise.resolve(Ut);if(!t)return function(e,t,s,n="image/png"){const a=e instanceof Blob?URL.createObjectURL(e):e,o=new Image;return new Promise((r=>{o.onload=()=>{Ot(o,t,s,n).then((e=>URL.createObjectURL(e))).then(r).finally((()=>{e instanceof Blob&&URL.revokeObjectURL(a)}))},o.src=a}))}(e,Dt,Dt);const s=Math.min(t.width,t.height);return s<Dt?Lt(e,Dt/s):Promise.resolve(e)}(h,g).then((t=>{e||(a(!1),l(t))}),(t=>{e||(a(!1),i(t))})),()=>{e=!0}}),t),{isLoading:n,error:r,result:c}})(0,[h,g],Ut);return(0,o.Ye)((()=>(0,Bt.Of)({title:r,artist:i,album:c,artwork:[{src:p}]})),[c,i,r,p])};var Qt=s(8051);const Gt=(0,n.c$)(((e,{message:t})=>{const s=(0,i.Ur)(e,t),n=(0,i.Z1)(e,t.chatId),{volume:a,playbackRate:o,isMuted:r}=e.audioPlayer;return{sender:s,chat:n,volume:a,playbackRate:o,isMuted:r}}))((({message:e,className:t,noUi:s,sender:a,chat:r,volume:i,playbackRate:c,isMuted:d})=>{const{setAudioPlayerVolume:u,setAudioPlayerPlaybackRate:m,setAudioPlayerMuted:g,focusMessage:p,closeAudioPlayer:f}=(0,n.uC)(),I=(0,Ce.Z)(),{audio:v,voice:y,video:Z}=(0,l.qp)(e),P=Boolean(y||Z),C=a?(0,l.OU)(I,a):void 0,w=Tt.UV((0,l.Ti)(e,"inline")),b=qt(e,a,r),{playPause:S,stop:E,isPlaying:M,requestNextTrack:k,requestPreviousTrack:R,isFirst:T,isLast:N,setVolume:B,toggleMuted:A,setPlaybackRate:x}=(0,At.Z)((0,Nt.An)(e),(0,l.XV)(e),P?"voice":"audio",w,void 0,b,void 0,!0,void 0,void 0,(0,l.CI)(e),!0),L=P&&M;(0,o.d4)((()=>{if(L)return ie.Z.disableRefresh(),()=>{ie.Z.enableRefresh()}}),[L]);const O=(0,o.I4)((()=>{p({chatId:e.chatId,messageId:e.id})}),[p,e.chatId,e.id]),F=(0,o.I4)((()=>{M&&S(),f(),(0,Bt.Ay)(),E()}),[f,M,S,E]),U=(0,o.I4)((e=>{u({volume:e/100}),g({isMuted:!1}),B(e/100)}),[g,u,B]),$=(0,o.I4)((()=>{h.$b&&!h.cj||(A(),g({isMuted:!d}))}),[d,g,A]),D=(0,o.I4)((()=>{1===c?(x(1.8),m({playbackRate:1.8})):(x(1),m({playbackRate:1}))}),[c,m,x]),q=(0,o.Ye)((()=>0===i||d?"icon-muted":i<.3?"icon-volume-1":i<.6?"icon-volume-2":"icon-volume-3"),[i,d]);if(!s)return o.ZP.createElement("div",{className:(0,ne.Z)("AudioPlayer",t),dir:I.isRtl?"rtl":void 0},o.ZP.createElement(Ee.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:T(),onClick:R,ariaLabel:"Previous track"},o.ZP.createElement("i",{className:"icon-skip-previous"})),o.ZP.createElement(Ee.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:(0,ne.Z)("toggle-play","player-button",M?"pause":"play"),onClick:S,ariaLabel:M?"Pause audio":"Play audio"},o.ZP.createElement("i",{className:"icon-play"}),o.ZP.createElement("i",{className:"icon-pause"})),o.ZP.createElement(Ee.Z,{round:!0,ripple:!h.wB,color:"translucent",size:"smaller",className:"player-button",disabled:N(),onClick:k,ariaLabel:"Next track"},o.ZP.createElement("i",{className:"icon-skip-next"})),o.ZP.createElement("div",{className:"AudioPlayer-content",onClick:O},v?function(e){const{title:t,performer:s,fileName:n}=e;return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},(0,Pt.Z)(t||n)),s&&o.ZP.createElement("div",{className:"subtitle",dir:"auto"},(0,Pt.Z)(s)))}(v):function(e,t){return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"title",dir:"auto"},t&&(0,Pt.Z)(t)),o.ZP.createElement("div",{className:"subtitle",dir:"auto"},e))}(I("AttachAudio"),C),o.ZP.createElement(Et.Z,null)),o.ZP.createElement(Ee.Z,{round:!0,className:"player-button volume-button",color:"translucent",size:"smaller",ariaLabel:"Volume",withClickPropagation:!0},o.ZP.createElement("i",{className:q,onClick:$}),!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(Qt.Z,{value:d?0:100*i,onChange:U})))),P&&o.ZP.createElement(Ee.Z,{round:!0,className:(0,ne.Z)("playback-button",1!==c&&"applied"),color:"translucent",size:"smaller",ariaLabel:"Playback Rate",ripple:!h.wB,onClick:D},o.ZP.createElement("span",{className:"playback-button-inner"},"2Х")),o.ZP.createElement(Ee.Z,{round:!0,className:"player-close",color:"translucent",size:"smaller",onClick:F,ariaLabel:"Close player"},o.ZP.createElement("i",{className:"icon-close"})))}));var jt=s(2607),Ht=s(172);const _t=(0,o.X$)((0,n.c$)(((e,{chatId:t})=>{const s=(0,i.Z1)(e,t),n=(0,jt.Bj)(e,t);return{groupCall:n,usersById:e.users.byId,chatsById:e.chats.byId,activeGroupCallId:e.groupCalls.activeGroupCallId,isActive:(n?n.participantsCount>0&&n.isLoaded:s&&s.isCallNotEmpty&&s.isCallActive)&&e.groupCalls.activeGroupCallId!==(null==n?void 0:n.id)}}))((({chatId:e,isActive:t,groupCall:s,hasPinnedOffset:a,usersById:r,chatsById:i})=>{const{joinGroupCall:c,subscribeToGroupCallUpdates:l}=(0,n.uC)(),d=(0,Ce.Z)(),u=(0,o.I4)((()=>{c({chatId:e})}),[c,e]),m=null==s?void 0:s.participants,h=(0,o.Ye)((()=>m?Object.values(m).filter(((e,t)=>t<3)).map((({id:e,isUser:t})=>{if(t){if(!r[e])return;return{user:r[e]}}if(i[e])return{chat:i[e]}})).filter(Boolean):[]),[i,m,r]);if((0,o.d4)((()=>{if(null!=s&&s.id&&(t||!s.isLoaded))return l({id:s.id,subscribed:!0}),()=>{l({id:s.id,subscribed:!1})}}),[null==s?void 0:s.id,null==s?void 0:s.isLoaded,t,l]),s)return o.ZP.createElement("div",{className:(0,ne.Z)("GroupCallTopPane",a&&"has-pinned-offset",!t&&"is-hidden"),onClick:u},o.ZP.createElement("div",{className:"info"},o.ZP.createElement("span",{className:"title"},d("VoipGroupVoiceChat")),o.ZP.createElement("span",{className:"participants"},d("Participants",s.participantsCount||0,"i"))),o.ZP.createElement("div",{className:"avatars"},h.map((e=>{if(e)return e.user?o.ZP.createElement(Ht.Z,{key:e.user.id,user:e.user}):o.ZP.createElement(Ht.Z,{key:e.chat.id,chat:e.chat})}))),o.ZP.createElement(Ee.Z,{round:!0,className:"join"},d("VoipChatJoin")))}))),zt=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,messageListType:n})=>{const{isLeftColumnShown:a,lastSyncTime:o,shouldSkipHistoryAnimations:r}=e,{byId:c}=e.chats,l=(0,i.Z1)(e,t),{typingStatus:d}=l||{},{chatId:m,messageId:h}=e.audioPlayer,g=m&&h?(0,i.hj)(e,m,h):void 0;let p;if("pinned"===n){const s=(0,i.KB)(e,t);p=null==s?void 0:s.length}else if("scheduled"===n){const s=(0,i.qy)(e,t);p=null==s?void 0:s.length}else if("thread"===n&&s!==u._f){const n=(0,i.tZ)(e,t,s);p=(null==n?void 0:n.messagesCount)||0}const f={typingStatus:d,isLeftColumnShown:a,isRightColumnShown:(0,i.Jf)(e),isSelectModeActive:(0,i.CA)(e),audioMessage:g,chat:l,chatsById:c,messagesCount:p,isChatWithSelf:(0,i.FM)(e,t),isChatWithBot:l&&(0,i.xo)(e,l),lastSyncTime:o,shouldSkipHistoryAnimations:r,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1),connectionState:e.connectionState},I=(0,i.Zw)(e,t);if("thread"!==n||!I)return f;if(Object.assign(f,{messagesById:I}),s!==u._f){const n=(0,i.qS)(e,t,s),a=n?(0,i.hj)(e,t,n):void 0,o=a?(0,i.cv)(e,a):void 0;return{...f,pinnedMessageIds:n,canUnpin:!1,topMessageSender:o}}const v=(0,i.KB)(e,t);if(null!=v&&v.length){const t=I[v[0]],{canUnpin:n}=t&&(0,i._k)(e,t,s)||{};return{...f,pinnedMessageIds:v,canUnpin:n}}return f}))((({chatId:e,threadId:t,messageListType:s,isReady:r,pinnedMessageIds:c,messagesById:d,canUnpin:m,topMessageSender:g,typingStatus:p,isSelectModeActive:f,isLeftColumnShown:I,isRightColumnShown:v,audioMessage:y,chat:Z,chatsById:P,messagesCount:C,isChatWithSelf:w,isChatWithBot:b,lastSyncTime:S,shouldSkipHistoryAnimations:E,currentTransitionKey:M,connectionState:k})=>{const{openChatWithInfo:R,pinMessage:T,focusMessage:N,openChat:B,openPreviousChat:A,loadPinnedMessages:x,toggleLeftColumn:L,exitMessageSelectMode:O}=(0,n.uC)(),F=(0,Ce.Z)(),U=(0,o.sO)(!0),[$,D]=(0,o.eJ)(0),q=Array.isArray(c)?c[$]:c,Q=d&&q?d[q]:void 0,G=Array.isArray(c)?c.length:c?1:void 0,j=Z&&(0,l.U)(F,Z).length,H=g?(0,l.OU)(F,g):void 0;(0,o.d4)((()=>{t===u._f&&S&&r&&x({chatId:e})}),[e,x,S,t,r]),(0,o.d4)((()=>{D(0)}),[c]),(0,ht.Z)(e,q,Q);const{width:_}=it(),z=_<=a.ks,V=h.p7&&I,Y=(0,o.sO)(null),K=(0,o.sO)(!0),W=(0,o.I4)((()=>{R({id:e})}),[R,e]),X=(0,o.I4)((t=>{T({chatId:e,messageId:t,isUnpin:!0})}),[T,e]),J=(0,o.I4)((()=>{if(Q){N({chatId:Q.chatId,threadId:t,messageId:Q.id});const e=(0,mt.Z)(G||1,$+1);D(e)}}),[Q,N,t,G,$]),ee=(0,o.I4)((()=>{B({id:e,threadId:u._f,type:"pinned"})}),[B,e]),te=(0,o.I4)((()=>{setTimeout((()=>{U.current=!0}),450)}),[]),se=(0,o.I4)((e=>{if(U.current){if(U.current=!1,h.wB){const e=document.getElementById(a.R2);e&&e.blur()}if(f)return O(),void te();if(t===u._f&&"thread"===s&&0===M)return h.wB||V?(e.stopPropagation(),B({id:void 0})):L(),void te();A(),te()}}),[t,s,M,f,A,V,B,L,O,te]),ae=(0,o.Ye)((()=>{if(z&&P)return(0,i.A1)((0,n.Rd)())||void 0}),[z,P]),oe=_>=a.ks&&_<a.jT||_>a.l3&&_<a.ks&&(!j||j>30),re=oe||_>a._m&&_<a.QU,{shouldRender:ie,transitionClassNames:le}=(0,ce.Z)(Boolean(y)),de=(0,gt.Z)(y),{shouldRender:ue,transitionClassNames:me}=(0,ce.Z)(Boolean(Q)),he=(0,gt.Z)(Q,!0),ge=(0,gt.Z)(G,!0),pe=(0,gt.Z)(m,!0),fe=(0,gt.Z)(H),Ie=ue&&he||ie&&de;(0,o.d4)((()=>{const e=Y.current;if(e)return re&&Ie?void(v||oe?(K.current&&(e.classList.add("tools-stacked","animated"),K.current=!1),setTimeout((()=>{e.classList.remove("animated")}),350)):(e.classList.remove("tools-stacked"),K.current=!0)):(e.classList.remove("tools-stacked","animated"),void(K.current=!0))}),[re,Ie,oe,v]);const ve=(!Pe()||"connectionStateConnecting"===k)&&(h.wB||h.p7&&!V);function ye(){return ve?o.ZP.createElement(o.ZP.Fragment,null,we(),o.ZP.createElement("h3",null,F("WaitingForNetwork"))):"thread"===s&&t===u._f?o.ZP.createElement(o.ZP.Fragment,null,(z||M>0)&&we(V,!0),o.ZP.createElement("div",{className:"chat-info-wrapper",onClick:W},(0,l.YC)(e)?o.ZP.createElement(ft.Z,{userId:e,typingStatus:p,withFullInfo:b,withMediaViewer:!0,withUpdatingStatus:!0,noRtl:!0}):o.ZP.createElement(It.Z,{chatId:e,typingStatus:p,noRtl:!0,withMediaViewer:!0,withFullInfo:!0,withUpdatingStatus:!0}))):"thread"===s?o.ZP.createElement(o.ZP.Fragment,null,we(),o.ZP.createElement("h3",null,F("CommentsCount",C,"i"))):"pinned"===s?o.ZP.createElement(o.ZP.Fragment,null,we(),o.ZP.createElement("h3",null,F("PinnedMessagesCount",C,"i"))):"scheduled"===s?o.ZP.createElement(o.ZP.Fragment,null,we(),o.ZP.createElement("h3",null,w?F("Reminders"):F("messages",C,"i"))):void 0}function we(e=!1,t=!1){return o.ZP.createElement("div",{className:"back-button"},o.ZP.createElement(Ee.Z,{round:!0,size:"smaller",color:"translucent",onClick:se,ariaLabel:F(e?"Close":"Back")},o.ZP.createElement("div",{className:(0,ne.Z)("animated-close-icon",!e&&"state-back")})),t&&ae&&o.ZP.createElement("div",{className:"unread-count active"},(0,pt.bi)(ae)))}const be=Boolean(ie&&de);return o.ZP.createElement("div",{className:"MiddleHeader",ref:Y},o.ZP.createElement(Ze.Z,{name:E?"none":"slide-fade",activeKey:ve?1/0:M},ye),o.ZP.createElement(_t,{hasPinnedOffset:ue&&!!he||ie&&!!de,chatId:e}),ue&&he&&o.ZP.createElement(Rt,{key:e,message:he,count:ge||0,index:$,customTitle:fe,className:(0,ne.Z)(me,be&&"full-width"),onUnpinMessage:pe?X:void 0,onClick:J,onAllPinnedClick:ee}),o.ZP.createElement("div",{className:"header-tools"},be&&o.ZP.createElement(Gt,{key:(0,l.Tp)(de),message:de,className:le}),o.ZP.createElement(yt,{chatId:e,threadId:t,messageListType:s,canExpandActions:!be})))})));var Vt=s(2645),Yt=s(274);function Kt(e){return"albumId"in e}function Wt(e,t){let s,n=[],a={originalDate:e[0].date,datetime:Number((0,N.$Y)(1e3*e[0].date)),senderGroups:[n]};const o=[a];return e.forEach(((r,i)=>{r.isInAlbum?s?(s.messages.push(r),r.content.text&&(s.mainMessage=r)):s={albumId:r.groupedId,messages:[r],mainMessage:r}:n.push(r);const c=e[i+1];if(!s||c&&c.groupedId&&c.groupedId===s.albumId||(n.push(s),s=void 0),c){const e=Number((0,N.$Y)(1e3*c.date));a.datetime!==e?(a={originalDate:c.date,datetime:e,senderGroups:[]},o.push(a),n=[],a.senderGroups.push(n)):(c.id===t||r.senderId!==c.senderId||r.isOutgoing!==c.isOutgoing||(0,l.Lo)(r)||(0,l.Lo)(c)||r.forwardInfo&&c.forwardInfo&&(r.forwardInfo.senderUserId!==c.forwardInfo.senderUserId||r.forwardInfo.fromChatId!==c.forwardInfo.fromChatId||r.forwardInfo.hiddenUserName!==c.forwardInfo.hiddenUserName)||r.inlineButtons||c.inlineButtons||c.date-r.date>600)&&(n=[],a.senderGroups.push(n))}})),o}var Xt=s(386),Jt=s(2202);var es=s(7675),ts=s(539),ss=s(3657);const ns=h.wZ?1e3:350,as=h.wB?300:500;var os=s(7240),rs=s(935);function is(e){return"number"==typeof e}function cs(e,t){return e?t?238:175:t?238:100}function ls(e,t){const s=(0,l.B4)(e),n=(0,l.MF)(e),a=(0,l.O$)(e)||(0,l.F$)(e),o=(0,l.b7)(e),r=Boolean((0,l.F$)(e)),{width:i,height:c}=a?(0,Zt.Eh)(a,s,n,r,t):(0,Zt.GC)(o,s,n,t),d=cs(Boolean((0,l.UD)(e)));let u=1;i<d&&d-i<12&&(u=d/i),c*u<90&&90-c*u<12&&(u=90/c);const m=Math.round(i*u),h=Math.round(c*u);return{width:m,height:h,isSmall:m<d||h<90}}function ds(e,t){return e.reduce(((e,t)=>e+t),t)}function us(e,t,s){return e<t?t:e>s?s:e}function ms(e){const t={width:0,height:0};return e.forEach((({dimensions:e,sides:s})=>{2&s&&(t.width=e.width+e.x),4&s&&(t.height=e.height+e.y)})),t}function hs(e,t,s,n){const a=n.messages.map((e=>{const t=ls(e);return t.width/t.height})),o=function(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}(a),r=function(e){return e.reduce(((e,t)=>t+e),1)/e.length}(a),i=a.length,c=a.some((e=>e>2)),l=(0,Zt.kc)(e,t,!1,s)-(t?2.5:0)*Zt.Gw;let d;const u={ratios:a,proportions:o,averageRatio:r,maxWidth:l,minWidth:100,maxHeight:l,spacing:2};return d=i>=5||c?function({ratios:e,averageRatio:t,maxWidth:s,minWidth:n,spacing:a,maxHeight:o=4*s/3}){const r=function(e,t){return e.map((e=>t>1.1?us(e,1,2.75):us(e,.6667,1)))}(e,t),i=e.length,c=new Array(i),l=[],d=e=>{const t=[];let n=0;e.forEach((e=>{t.push(((e,t)=>{const n=ds(r.slice(e,e+t),0);return(s-(t-1)*a)/n})(n,e)),n+=e})),l.push({lineCounts:e,heights:t})};for(let e=1;e!==i;++e){const t=i-e;e<=3&&t<=3&&d([e,t])}for(let e=1;e!==i-1;++e)for(let s=1;s!==i-e;++s){const n=i-e-s;e<=3&&s<=(t<.85?4:3)&&n<=3&&d([e,s,n])}for(let e=1;e!==i-1;++e)for(let t=1;t!==i-e;++t)for(let s=1;s!==i-e-t;++s){const n=i-e-t-s;e<=3&&t<=3&&s<=3&&n<=4&&d([e,t,s,n])}let u,m=0;for(let e=0;e<l.length;e++){const{heights:t,lineCounts:s}=l[e],r=s.length,i=ds(t,0)+a*(r-1),c=Math.min(...t)<n?1.5:1,d=(()=>{for(let e=1;e!==r;++e)if(s[e-1]>s[e])return 1.5;return 1})(),h=Math.abs(i-o)*c*d;(!u||h<m)&&(u=l[e],m=h)}const h=u.lineCounts,g=u.heights,p=h.length;let f=0,I=0;for(let e=0;e!==p;++e){const t=h[e],n=g[e],o=Math.round(n);let i=0;for(let l=0;l!==t;++l){const d=0|(0===e?1:0)|(e===p-1?4:0)|(0===l?8:0)|(l===t-1?2:0),u=r[f],m=l===t-1?s-i:Math.round(u*n);c[f]={dimensions:{x:i,y:I,width:m,height:o},sides:d},i+=m+a,++f}I+=o+a}return c}(u):2===i?function(e){const{ratios:t,proportions:s,averageRatio:n}=e;return"ww"===s&&n>1.4&&t[1]-t[0]<.2?function(e){const{ratios:t,maxWidth:s,spacing:n,maxHeight:a}=e,o=Math.round(Math.min(s/t[0],Math.min(s/t[1],(a-n)/2)));return[{dimensions:{x:0,y:0,width:s,height:o},sides:11},{dimensions:{x:0,y:o+n,width:s,height:o},sides:14}]}(e):"ww"===s||"qq"===s?function(e){const{ratios:t,maxWidth:s,spacing:n,maxHeight:a}=e,o=(s-n)/2,r=Math.round(Math.min(o/t[0],Math.min(o/t[1],a)));return[{dimensions:{x:0,y:0,width:o,height:r},sides:13},{dimensions:{x:o+n,y:0,width:o,height:r},sides:7}]}(e):function(e){const{ratios:t,minWidth:s,maxWidth:n,spacing:a,maxHeight:o}=e,r=Math.round(1.5*s),i=Math.min(Math.round(Math.max(.4*(n-a),(n-a)/t[0]/(1/t[0]+1/t[1]))),n-a-r),c=n-i-a,l=Math.min(o,Math.round(Math.min(c/t[0],i/t[1])));return[{dimensions:{x:0,y:0,width:c,height:l},sides:13},{dimensions:{x:c+a,y:0,width:i,height:l},sides:7}]}(e)}(u):3===i?function(e){const{proportions:t}=e;return"n"===t[0]?function(e){const{maxHeight:t,spacing:s,ratios:n,maxWidth:a,minWidth:o}=e,r=t,i=Math.round(Math.min((t-s)/2,n[1]*(a-s)/(n[2]+n[1]))),c=r-i-s,l=Math.max(o,Math.round(Math.min((a-s)/2,Math.min(i*n[2],c*n[1])))),d=Math.min(Math.round(r*n[0]),a-s-l);return[{dimensions:{x:0,y:0,width:d,height:r},sides:13},{dimensions:{x:d+s,y:0,width:l,height:c},sides:3},{dimensions:{x:d+s,y:c+s,width:l,height:i},sides:6}]}(e):function(e){const{maxWidth:t,ratios:s,maxHeight:n,spacing:a}=e,o=t,r=Math.round(Math.min(o/s[0],.66*(n-a))),i=(t-a)/2,c=Math.min(n-r-a,Math.round(Math.min(i/s[1],i/s[2])));return[{dimensions:{x:0,y:0,width:o,height:r},sides:11},{dimensions:{x:0,y:r+a,width:i,height:c},sides:12},{dimensions:{x:i+a,y:r+a,width:o-i-a,height:c},sides:6}]}(e)}(u):function(e){const{proportions:t}=e;return"w"===t[0]?function({maxWidth:e,ratios:t,spacing:s,maxHeight:n,minWidth:a}){const o=e,r=Math.round(Math.min(o/t[0],.66*(n-s))),i=Math.round((e-2*s)/(t[1]+t[2]+t[3])),c=Math.max(a,Math.round(Math.min(.4*(e-2*s),i*t[1]))),l=Math.round(Math.max(Math.max(a,.33*(e-2*s)),i*t[3])),d=o-c-l-2*s,u=Math.min(n-r-s,i);return[{dimensions:{x:0,y:0,width:o,height:r},sides:11},{dimensions:{x:0,y:r+s,width:c,height:u},sides:12},{dimensions:{x:c+s,y:r+s,width:d,height:u},sides:4},{dimensions:{x:c+s+d+s,y:r+s,width:l,height:u},sides:6}]}(e):function({maxHeight:e,ratios:t,maxWidth:s,spacing:n,minWidth:a}){const o=e,r=Math.round(Math.min(o*t[0],.6*(s-n))),i=Math.round((e-2*n)/(1/t[1]+1/t[2]+1/t[3])),c=Math.round(i/t[1]),l=Math.round(i/t[2]),d=o-c-l-2*n,u=Math.max(a,Math.min(s-r-n,i));return[{dimensions:{x:0,y:0,width:r,height:o},sides:13},{dimensions:{x:r+n,y:0,width:u,height:c},sides:3},{dimensions:{x:r+n,y:c+n,width:u,height:l},sides:2},{dimensions:{x:r+n,y:c+l+2*n,width:u,height:d},sides:6}]}(e)}(u),{layout:d,containerStyle:ms(d)}}let gs;function ps(e){return gs||(gs=document.createElement("span"),gs.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',gs.style.whiteSpace="nowrap",gs.style.position="absolute",gs.style.left="-999px",gs.style.opacity=".01",document.body.appendChild(gs)),gs.innerHTML=e,gs.offsetWidth}function fs(e,t,s,n,a,r){(0,o.bt)((()=>{if(s&&e.current){const t=e.current.closest(".MessageList");(0,ts.Z)(t,e.current,a?"end":"centerOrTop",20,void 0!==n?1e3:void 0,n,void 0,r)}}),[e,t,s,n,a,r])}var Is=s(8005);const vs=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"ContextMenuContainer",!t);return s?o.ZP.createElement(s,e):void 0})),ys=(0,o.X$)((0,n.c$)(((e,{message:t})=>{const{byId:s}=e.users,n=t.senderId,{targetUserIds:a,targetChatId:o}=t.content.action||{},r=t.replyToMessageId,c=r?(0,i.hj)(e,t.chatId,r):void 0,d=(0,i._X)(e,t),{direction:u,noHighlight:m}=d&&e.focusedMessage||{},h=(0,i.Z1)(e,t.chatId);return{usersById:s,sender:h&&((0,l.eA)(h)||n===t.chatId)?h:n?(0,i.dy)(e,n):void 0,targetChatId:o,targetUserIds:a,targetMessage:c,isFocused:d,...d&&{focusDirection:u,noFocusHighlight:m}}}))((({message:e,observeIntersection:t,isEmbedded:s,appearanceOrder:n=0,isLastInList:a,usersById:r,sender:i,targetUserIds:c,targetMessage:l,targetChatId:d,isFocused:u,focusDirection:m,noFocusHighlight:h})=>{const g=(0,o.sO)(null);(0,ss._N)(g,t),(0,ht.Z)(e.chatId,e.replyToMessageId,l),fs(g,e.chatId,u,m,h);const p=(0,Ce.Z)(),f=n<=0,[I,v]=(0,ye.Z)(f);(0,o.d4)((()=>{f||setTimeout(v,10*n)}),[n,v,f]);const{transitionClassNames:y}=(0,ce.Z)(I,void 0,f,!1),Z=(0,o.Ye)((()=>c?c.map((e=>null==r?void 0:r[e])).filter(Boolean):void 0),[c,r]),P=(0,Is.D)(p,e,i,Z,l,d,s?{isEmbedded:!0,asPlain:!0}:void 0),{isContextMenuOpen:C,contextMenuPosition:w,handleBeforeContextMenu:b,handleContextMenu:S,handleContextMenuClose:E,handleContextMenuHide:M}=(0,os.Z)(g),k=void 0!==w;if(s)return o.ZP.createElement("span",{className:"embedded-action-message"},(0,Pt.Z)(P));const R=(0,ne.Z)("ActionMessage message-list-item",u&&!h&&"focused",k&&"has-menu-open",a&&"last-in-list",y);return o.ZP.createElement("div",{ref:g,id:`message${e.id}`,className:R,"data-message-id":e.id,onMouseDown:e=>{(0,Xt.q)(e),b(e)},onContextMenu:S},o.ZP.createElement("span",null,P),w&&o.ZP.createElement(vs,{isOpen:C,anchor:w,message:e,messageListType:"thread",onClose:E,onCloseAnimationEnd:M}))}))),Zs=({className:e,message:t,sender:s,title:n,customText:a,isProtected:r,observeIntersection:i,onClick:c})=>{const d=(0,o.sO)(null),u=(0,ss.Op)(d,i),m=(0,Ct.Z)(t&&(0,l.Ti)(t,"pictogram"),!u),h=t&&`sticker-reply-thumb${t.id}`,g=bt(t),p=Boolean(t&&(0,l.Y5)(t)),f=(0,Ce.Z)(),I=s&&(0,l.OU)(f,s);return o.ZP.createElement("div",{ref:d,className:(0,ne.Z)("EmbeddedMessage",e),onClick:t?c:void 0},g&&function(e,t,s,n,a){const{width:r,height:i}=(0,Zt.W7)();return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("img",{id:e,src:s||t,width:r,height:i,alt:"",className:n?"round":"",draggable:!a}),a&&o.ZP.createElement("span",{className:"protector"}))}(h,g,m,p,r),o.ZP.createElement("div",{className:"message-text"},o.ZP.createElement("p",{dir:"auto"},t?(0,l.Lo)(t)?o.ZP.createElement(ys,{message:t,isEmbedded:!0}):(0,Pt.Z)((0,l.MK)(f,t,Boolean(g))):a||" "),o.ZP.createElement("div",{className:"message-title",dir:"auto"},(0,Pt.Z)(I||n||" "))))};var Ps=s(2535),Cs=s(4752),ws=s(8018);const bs=(0,o.X$)((({message:e,outgoingStatus:t,signature:s,onClick:n})=>{const a=(0,Ce.Z)(),[r,i]=(0,ye.Z)(),c=(0,o.Ye)((()=>{if(!r)return;const t=(0,N.SA)(1e3*e.date,a.code),s=e.isEdited&&(0,N.SA)(1e3*e.editDate,a.code),n=e.forwardInfo&&(0,N.SA)(1e3*e.forwardInfo.date,a.code);let o=t;return s&&(o+="\n",o+=a("lng_edited_date").replace("{date}",s)),n&&(o+="\n",o+=a("lng_forwarded_date").replace("{date}",n)),o}),[r,a,e]);return o.ZP.createElement("span",{className:"MessageMeta",dir:a.isRtl?"rtl":"ltr",onClick:n},Boolean(e.views)&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"message-views"},(0,pt.bi)(e.views)),o.ZP.createElement("i",{className:"icon-channelviews"})),s&&o.ZP.createElement("span",{className:"message-signature"},(0,Pt.Z)(s)),o.ZP.createElement("span",{className:"message-time",title:c,onMouseEnter:i},e.isEdited&&`${a("EditedMessage")} `,(0,N.mr)(1e3*e.date,a)),t&&o.ZP.createElement(ws.Z,{status:t}))}));var Ss=s(692),Es=s(7799),Ms=s(4851);const ks=({message:e,observeIntersection:t,observeIntersectionForPlaying:s,shouldLoop:n,lastSyncTime:r})=>{const i=(0,o.sO)(null),[c,d,u]=(0,ye.Z)(),m=e.content.sticker,{isAnimated:h,stickerSetId:g}=m,p=g===a.n,f=(0,ss.Op)(i,t),I=(0,ss.Op)(i,s),v=m.isPreloadedGlobally?`sticker${m.id}`:(0,l.Ti)(e,"inline"),y=bt(e),Z=(0,Ct.Z)(v,!f,(0,l.kG)(e,"inline",!0),r),P=Boolean(Z),[C,w]=(0,ye.Z)(P),b=h?C:P,S=(0,Ss.Z)(b),{width:E,height:M}=(0,Zt.Wr)(m),k=(0,ne.Z)("thumbnail",!y&&"empty"),R=(0,ne.Z)("Sticker media-inner",p&&"inactive");return o.ZP.createElement("div",{ref:i,className:R,onClick:p?void 0:d},!b&&o.ZP.createElement("img",{id:`sticker-thumb-${e.id}`,src:y,width:E,height:M,alt:"",className:k}),!h&&o.ZP.createElement("img",{id:`sticker-${e.id}`,src:Z,width:E,height:M,alt:"",className:(0,ne.Z)("full-media",S)}),h&&P&&o.ZP.createElement(Es.Z,{key:v,className:(0,ne.Z)("full-media",S),id:v,animationData:Z,size:E,play:I,noLoop:!n,onLoad:w}),o.ZP.createElement(Ms.Z,{isOpen:c,fromSticker:m,onClose:u}))};var Rs=s(7854),Ts=s(2566),Ns=s(5866);function Bs(e,t){return(0,Ns.Z)((0,l.DH)(e),Boolean(t),h.wB&&!h.vX)}const As={dark:{outgoing:"rgb(135,116,225)",incoming:"rgb(33,33,33)"},light:{outgoing:"rgb(238,255,222)",incoming:"rgb(255,255,255)"}};var xs=s(9196);const Ls=({id:e,message:t,observeIntersection:s,noAvatars:n,canAutoLoad:a,isInSelectMode:r,isSelected:i,uploadProgress:c,size:d="inline",dimensions:u,nonInteractive:m,shouldAffectAppendix:h,isDownloading:g,isProtected:p,theme:f,onClick:I,onCancelUpload:v})=>{const y=(0,o.sO)(null),Z=((0,l.O$)(t)||(0,l.F$)(t)).blobUrl,P=(0,ss.Op)(y,s),[C,w]=(0,o.eJ)(a),b=C&&P,{mediaData:S,loadProgress:E}=(0,Ts.Z)((0,l.Ti)(t,d),!b),M=Z||S,k=Bs(t,M),{loadProgress:R}=(0,Ts.Z)((0,l.Ti)(t,"download"),!g),{isUploading:T,isTransferring:N,transferProgress:B}=(0,l.Sc)(t,c||(g?R:E),b&&!M),A=!1===(0,lt.Z)(C),x=(0,Ss.Z)(M),{shouldRender:L,transitionClassNames:O}=(0,ce.Z)(N,void 0,A,"slow"),{shouldRender:F,transitionClassNames:U}=(0,ce.Z)(!M&&!C),$=(0,o.I4)((()=>{T?v&&v(t):M?I&&I(t.id):w((e=>!e))}),[M,T,t,v,I]),D=(0,l.B4)(t);(0,o.bt)((()=>{if(!h)return;const e=y.current.closest(".message-content");M?function(e,t,s,n,a){return n?Promise.resolve(As[a||"light"][t?"outgoing":"incoming"]):async function(e,t){const s=new Image;s.src=e,s.width||await new Promise((e=>{s.onload=e}));const n=document.createElement("canvas"),a=n.getContext("2d");n.width=s.width,n.height=s.height,a.drawImage(s,0,0,s.width,s.height);const o=t?s.width-1:0,r=s.height-1;return`rgba(${Array.from(a.getImageData(o,r,1,1).data).join(",")})`}(e,t)}(M,D,0,i,f).then((t=>{e.style.setProperty("--appendix-bg",t),e.setAttribute("data-has-custom-appendix","")})):e.classList.add("has-appendix-thumb")}),[M,D,h,r,i,f]);const{width:q,height:Q,isSmall:G}=u||ls(t,n),j=(0,ne.Z)("media-inner",!T&&!m&&"interactive",G&&"small-image",q===Q&&"square-image"),H=u?`width: ${q}px; height: ${Q}px; left: ${u.x}px; top: ${u.y}px;`:"";return o.ZP.createElement("div",{id:e,ref:y,className:j,style:H,onClick:T?void 0:$},o.ZP.createElement("canvas",{ref:k,className:"thumbnail",style:`width: ${q}px; height: ${Q}px`}),o.ZP.createElement("img",{src:M,className:`full-media ${x}`,width:q,height:Q,alt:"",draggable:!p}),p&&o.ZP.createElement("span",{className:"protector"}),L&&!F&&o.ZP.createElement("div",{className:`media-loading ${O}`},o.ZP.createElement(xs.Z,{progress:B,onClick:T?$:void 0})),F&&o.ZP.createElement("i",{className:(0,ne.Z)("icon-download",U)}),N&&o.ZP.createElement("span",{className:"message-transfer-progress"},Math.round(100*B),"%"))};var Os=s(2019),Fs=s(6898),Us=s(4753);function $s(e,t){var s;const n=(0,o.sO)(null===(s=e.current)||void 0===s?void 0:s.paused),a=(0,o.sO)();a.current=t;const r=(0,o.I4)((()=>{e.current&&(n.current=!e.current.paused,n.current&&e.current.pause())}),[e]),i=(0,o.I4)((()=>{e.current&&n.current&&a.current&&document.body.contains(e.current)&&(0,Us.Z)(e.current)}),[e]),c=(0,o.I4)((()=>{(0,C.T2)(i)}),[i]);(0,le.Z)(r,c),(0,se.ZP)(r,i)}function Ds(){return(Ds=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}const qs=({id:e,message:t,observeIntersection:s,noAvatars:a,canAutoLoad:r,canAutoPlay:i,uploadProgress:c,lastSyncTime:d,dimensions:m,onClick:h,onCancelUpload:g,isDownloading:p,isProtected:f})=>{var I;const v=(0,o.sO)(null),y=(0,o.sO)(null),Z=(0,l.b7)(t)||(0,l.Cg)(t),P=Z.blobUrl,C=(0,ss.Op)(v,s),[w,b]=(0,o.eJ)(r),S=Boolean(w&&C&&d),[E,M]=(0,o.eJ)(i),k=(0,Ct.Z)((0,l.Ti)(t,"pictogram"),!(C&&d),(0,l.kG)(t,"pictogram"),d),R=(0,Ss.Z)(k),{mediaData:T,loadProgress:B}=(0,Ts.Z)((0,l.Ti)(t,"inline"),!S,(0,l.kG)(t,"inline"),d),A=P||T,x=Boolean(C&&A),L=Bs(t,k),{loadProgress:O}=(0,Ts.Z)((0,l.Ti)(t,"download"),!p,u.IU.BlobUrl,d),{isBuffered:F,bufferingHandlers:U}=(0,Os.Z)(!r),{isUploading:$,isTransferring:D,transferProgress:q}=(0,l.Sc)(t,c||(p?O:B),S&&!F||p),Q=!1===(0,lt.Z)(w),{shouldRender:G,transitionClassNames:j}=(0,ce.Z)(D,void 0,Q),{shouldRender:H,transitionClassNames:_}=(0,ce.Z)(w&&!E&&!G),[z,V]=(0,o.eJ)(0),Y=(0,o.I4)((e=>{V(Math.max(0,e.currentTarget.currentTime-1))}),[]),K=(null===(I=y.current)||void 0===I?void 0:I.duration)||Z.duration||0,W=(0,l.B4)(t),X=(0,l.MF)(t),{width:J,height:ee}=m||(0,Zt.GC)(Z,W,X,a);$s(y,x),(0,Fs.Z)(y,[x]);const te=(0,o.I4)((()=>{$?g&&g(t):p?(0,n.uC)().cancelMessageMediaDownload({message:t}):A?A&&!E?(M(!0),y.current.play()):h&&h(t.id):b((e=>!e))}),[$,p,A,E,h,g,t]),se=(0,ne.Z)("media-inner dark",!$&&"interactive"),ae=m?`width: ${J}px; height: ${ee}px; left: ${m.x}px; top: ${m.y}px;`:"";return o.ZP.createElement("div",{ref:v,id:e,className:se,style:ae,onClick:$?void 0:te},o.ZP.createElement("canvas",{ref:L,className:"thumbnail",style:`width: ${J}px; height: ${ee}px;`}),o.ZP.createElement("img",{src:k,className:(0,ne.Z)("thumbnail",R),style:`width: ${J}px; height: ${ee}px;`,alt:"",draggable:!f}),x&&o.ZP.createElement("video",Ds({ref:y,className:"full-media",width:J,height:ee,autoPlay:E,muted:!0,loop:!0,playsInline:!0},U,{draggable:!f,onTimeUpdate:Y}),o.ZP.createElement("source",{src:A})),f&&o.ZP.createElement("span",{className:"protector"}),H&&o.ZP.createElement("i",{className:(0,ne.Z)("icon-large-play",_)}),G&&o.ZP.createElement("div",{className:(0,ne.Z)("media-loading",j)},o.ZP.createElement(xs.Z,{progress:q,onClick:te})),!w&&o.ZP.createElement("i",{className:"icon-download"}),D?o.ZP.createElement("span",{className:"message-transfer-progress"},$||p?`${Math.round(100*q)}%`:"..."):o.ZP.createElement("div",{className:"message-media-duration"},Z.isGif?"GIF":(0,N.k9)(Math.max(K-z,0))))};var Qs=s(6272);const Gs=(0,n.c$)(((e,{contact:t})=>{const{countryList:{phoneCodes:s}}=e;return{user:(0,i.dy)(e,t.userId),phoneCodeList:s}}))((({contact:e,user:t,phoneCodeList:s})=>{const{openUserInfo:a}=(0,n.uC)(),{firstName:r,lastName:i,phoneNumber:c,userId:l}=e,d=(0,o.I4)((()=>{a({id:l})}),[a,l]);return o.ZP.createElement("div",{className:(0,ne.Z)("Contact",Boolean(l)&&"interactive"),onClick:l?d:void 0},o.ZP.createElement(Ht.Z,{size:"large",user:t,text:r||i}),o.ZP.createElement("div",{className:"contact-info"},o.ZP.createElement("div",{className:"contact-name"},r," ",i),o.ZP.createElement("div",{className:"contact-phone"},(0,Qs.WZ)(s,c))))}));var js=s(1218),Hs=s(4434),_s=s(6937);function zs(e,t){return t>0?(e/t*100).toFixed():0}const Vs=({answer:e,voteResults:t,totalVoters:s,maxVotersCount:n,correctResults:a,shouldAnimate:r})=>{const i=t&&t.find((t=>t.option===e.option)),c=0===a.length||-1!==a.indexOf(e.option),l=a.length>0&&c||(null==i?void 0:i.isChosen),d=i?zs(i.votersCount,s||0):0,[u,m]=(0,o.eJ)(r?0:d),h=(0,o.sO)(null),g=i?zs(i.votersCount,n||0):0,p=u<d;if((0,o.d4)((()=>{r&&m(d)}),[r,d]),(0,o.d4)((()=>{const e=h.current;if(e&&r){const t=e.firstElementChild,s=p?"":"stroke-dasharray: 100% 200%; stroke-dashoffset: -44";t?t.setAttribute("style",s):e.innerHTML=`\n <svg class="poll-line" xmlns="http://www.w3.org/2000/svg" style="${s}">\n <path d="M4.47 5.33v13.6a9 9 0 009 9h13"/>\n </svg>`}}),[p,r]),!t||!i)return;const f=`width: ${g}%; transform:scaleX(${p?0:1})`;return o.ZP.createElement("div",{className:"PollOption",dir:"ltr"},o.ZP.createElement("div",{className:"poll-option-share "+("100"===d?"limit-width":"")},d,"%",l&&o.ZP.createElement("span",{className:(0,ne.Z)("poll-option-chosen",!c&&"wrong",r&&"animate")},o.ZP.createElement("i",{className:c?"icon-check":"icon-close"}))),o.ZP.createElement("div",{className:"poll-option-right"},o.ZP.createElement("div",{className:"poll-option-text",dir:"auto"},(0,Pt.Z)(e.text)),o.ZP.createElement("div",{className:(0,ne.Z)("poll-option-answer",l&&!c&&"wrong")},o.ZP.createElement("div",{className:"poll-option-corner",ref:h}),o.ZP.createElement("div",{className:"poll-option-line",style:f}))))},Ys=(0,o.X$)((0,n.c$)(((e,{poll:t})=>{const{recentVoterIds:s}=t.results,{serverTimeOffset:n,users:{byId:a}}=e;return s&&0!==s.length?{recentVoterIds:s,usersById:a,serverTimeOffset:n}:{}}))((({message:e,poll:t,recentVoterIds:s,usersById:a,onSendVote:r,serverTimeOffset:i})=>{const{loadMessage:c,openPollResults:l}=(0,n.uC)(),{id:d,chatId:u}=e,{summary:m,results:h}=t,[g,p]=(0,o.eJ)(!1),[f,I]=(0,o.eJ)([]),[v,y]=(0,o.eJ)(!1),[Z,P]=(0,o.eJ)(!1),[C,w]=(0,o.eJ)(!m.closed&&m.closeDate&&m.closeDate>0?Math.min(m.closeDate-Math.floor(Date.now()/1e3)+i,m.closePeriod):0),b=(0,o.sO)(null),{results:S,totalVoters:E}=h,M=S&&S.some((e=>e.isChosen)),k=!m.closed&&!M,R=!k&&m.isPublic&&Number(h.totalVoters)>0,T=k&&m.multipleChoice,B=S?Math.max(...S.map((e=>e.votersCount))):E,A=S?S.reduce(((e,t)=>(t.isCorrect&&e.push(t.option),e)),[]):[],x=m.answers.map((e=>({label:e.text,value:e.option,hidden:Boolean(m.quiz&&m.closePeriod&&C<=0)})));(0,o.d4)((()=>{g&&t.results.results&&t.results.results.some((e=>e.isChosen))&&p(!1)}),[g,t.results.results]),(0,o.d4)((()=>{C>0&&setTimeout((()=>w(C-1)),1e3);const e=b.current;if(e){const t=12*Math.PI,s=e.lastElementChild,n=e.firstElementChild;if(C<=5&&e.classList.add("hurry-up"),s&&n){const e=(m.closePeriod-C)/m.closePeriod*t;n.textContent=(0,N.k9)(C),s.firstElementChild.setAttribute("stroke-dashoffset",`-${e}`)}else e.innerHTML=`\n <span>${(0,N.k9)(C)}</span>\n <svg width="16px" height="16px">\n <circle cx="8" cy="8" r="6" class="poll-countdown-progress" transform="rotate(-90, 8, 8)"\n stroke-dasharray="${t} ${t}"\n stroke-dashoffset="0"\n />\n </svg>`}}),[C,m.closePeriod]),(0,o.d4)((()=>{m.quiz&&(C<=0||M&&!m.closed)&&c({chatId:u,messageId:d})}),[u,C,M,c,d,m.closed,m.quiz]),(0,o.d4)((()=>{let e;return m.quiz&&!m.closed&&m.closePeriod&&m.closePeriod>0&&(e=window.setTimeout((()=>{c({chatId:u,messageId:d})}),1e3*m.closePeriod)),()=>{e&&window.clearTimeout(e)}}),[k,u,c,d,m.closePeriod,m.closed,m.quiz]);const L=(0,o.Ye)((()=>s?s.reduce(((e,t)=>{const s=a[t];return s&&e.push(s),e}),[]):[]),[a,s]),O=(0,o.I4)((e=>{I([e]),p(!0),P(!0),r([e])}),[r]),F=(0,o.I4)((e=>{I(e)}),[]),U=(0,o.I4)((()=>{p(!0),P(!0),r(f)}),[r,f]),$=(0,o.I4)((()=>{l({chatId:u,messageId:d})}),[u,d,l]),D=(0,o.I4)((()=>{y(!0)}),[]),q=(0,o.I4)((()=>{y(!1),P(!1)}),[]);(0,o.d4)((()=>{Z&&M&&m.quiz&&h.results&&t.results.solution&&(h.results.find((e=>e.isChosen&&e.isCorrect))||y(!0))}),[M,Z,h.results,m.quiz,t.results.solution]);const Q=(0,Ce.Z)();return o.ZP.createElement("div",{className:"Poll",dir:Q.isRtl?"auto":"ltr"},v&&t.results.solution&&o.ZP.createElement(_s.Z,{message:(0,rs.H)(t.results.solution,t.results.solutionEntities),duration:5e3,onDismiss:q,containerId:"#middle-column-portals"}),o.ZP.createElement("div",{className:"poll-question"},(0,Pt.Z)(m.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"}(m)),L.length>0&&o.ZP.createElement("div",{className:"poll-recent-voters"},L.map((e=>o.ZP.createElement(Ht.Z,{size:"micro",user:e})))),C>0&&k&&o.ZP.createElement("div",{ref:b,className:"poll-countdown"}),m.quiz&&t.results.solution&&!k&&o.ZP.createElement(Ee.Z,{round:!0,size:"tiny",color:"translucent",className:"poll-quiz-help",disabled:v,onClick:D,ariaLabel:"Show Solution"},o.ZP.createElement("i",{className:"icon-lamp"}))),k&&o.ZP.createElement("div",{className:"poll-answers"},T?o.ZP.createElement(js.Z,{options:x,onChange:F,disabled:e.isScheduled||g,loadingOptions:g?f:void 0,round:!0}):o.ZP.createElement(Hs.Z,{name:`poll-${d}`,options:x,onChange:O,disabled:e.isScheduled||g,loadingOption:g?f[0]:void 0})),!k&&o.ZP.createElement("div",{className:"poll-results"},m.answers.map((function(e){return o.ZP.createElement(Vs,{key:e.option,shouldAnimate:Z,answer:e,voteResults:S,totalVoters:E,maxVotersCount:B,correctResults:A})}))),!R&&!T&&o.ZP.createElement("div",{className:"poll-voters-count"},function(e,t,s){return s?e(t?"Answer":"Vote",s,"i"):e(t?"Chat.Quiz.TotalVotesEmpty":"Chat.Poll.TotalVotesResultEmpty")}(Q,m.quiz,h.totalVoters)),T&&o.ZP.createElement(Ee.Z,{isText:!0,disabled:0===f.length,size:"tiny",onClick:U},Q("PollSubmitVotes")),R&&o.ZP.createElement(Ee.Z,{isText:!0,size:"tiny",onClick:$},Q("PollViewResults")))})));var Ks=s(8035),Ws=s(88);const Xs=(0,o.X$)((({message:e,observeIntersection:t,noAvatars:s,canAutoLoad:n,canAutoPlay:a,inPreview:r,lastSyncTime:i,isDownloading:c=!1,isProtected:d,theme:u,onMediaClick:m,onCancelMediaTransfer:h})=>{const g=(0,l.s1)(e);let p=!1;if(null!=g&&g.photo&&!g.video){const{width:t,height:s}=ls(e);p=t===s}const f=(0,o.I4)((()=>{m()}),[m]);if(!g)return;const{siteName:I,url:v,displayUrl:y,title:Z,description:P,photo:C,video:w}=g,b=(C||w)&&m&&!p,S=(0,Ks.Z)(P,170),E=(0,ne.Z)("WebPage",p&&"with-square-photo",!C&&!w&&!r&&"without-media",w&&"with-video");return o.ZP.createElement("div",{className:E,"data-initial":(I||y)[0],dir:"auto"},C&&!w&&o.ZP.createElement(Ls,{message:e,observeIntersection:t,noAvatars:s,canAutoLoad:n,size:p?"pictogram":"inline",nonInteractive:!b,onClick:b?f:void 0,onCancelUpload:h,isDownloading:c,isProtected:d,theme:u}),o.ZP.createElement("div",{className:"WebPage-text"},o.ZP.createElement(Ws.Z,{className:"site-name",url:v,text:I||y}),!r&&Z&&o.ZP.createElement("p",{className:"site-title"},(0,Pt.Z)(Z)),S&&o.ZP.createElement("p",{className:"site-description"},(0,Pt.Z)(S,["emoji","br"]))),!r&&w&&o.ZP.createElement(qs,{message:e,observeIntersection:t,noAvatars:s,canAutoLoad:n,canAutoPlay:a,lastSyncTime:i,onClick:b?f:void 0,onCancelUpload:h,isDownloading:c,isProtected:d}))}));var Js=s(9937);const en=(0,o.X$)((({message:e})=>{const t=(0,Ce.Z)(),s=(0,l.eO)(e),{title:n,text:a,amount:r,currency:i,isTest:c,photoUrl:d}=s;return o.ZP.createElement("div",{className:"Invoice"},n&&o.ZP.createElement("p",{className:"title"},(0,Pt.Z)(n)),a&&o.ZP.createElement("p",null,(0,Pt.Z)(a,["emoji","br"])),o.ZP.createElement("div",{className:"description "+(d?"has-image":"")},d&&o.ZP.createElement("img",{className:"invoice-image",src:d,alt:""}),o.ZP.createElement("p",{className:"description-text"},(0,Js.x)(r,i,t.code),c&&o.ZP.createElement("span",null,t("PaymentTestInvoice")))))}));function tn(e){return(0,o.X$)((0,n.c$)(((e,t)=>{const{message:s}=t;return{isInSelectMode:(0,i.CA)(e),isSelected:(0,i.vk)(e,s.id)}}))((t=>{const{isInSelectMode:s,isSelected:a,message:r,dimensions:i}=t,{toggleMessageSelection:c}=(0,n.uC)(),l=(0,o.I4)((e=>{e.stopPropagation(),c({messageId:r.id,withShift:null==e?void 0:e.shiftKey})}),[c,r]),d=(0,o.Ye)((()=>({...t,isInSelectMode:s,isSelected:a,dimensions:{...t.dimensions,x:0,y:0},onClick:s?void 0:t.onClick})),[t,s,a]);return o.ZP.createElement("div",{className:(0,ne.Z)("album-item-select-wrapper",a&&"is-selected"),style:i?`left: ${i.x}px; top: ${i.y}px;`:"",onClick:s?l:void 0},s&&o.ZP.createElement("div",{className:"message-select-control"},a&&o.ZP.createElement("i",{className:"icon-select"})),o.ZP.createElement(e,d))})))}const sn=tn(Ls),nn=tn(qs),an=(0,n.c$)(((e,{album:t})=>{const{chatId:s}=t.mainMessage,n=(0,i.Pu)(e),a=(0,i.xs)(e,s);return{theme:n,uploadsById:e.fileUploads.byMessageLocalId,activeDownloadIds:a}}))((({album:e,observeIntersection:t,hasCustomAppendix:s,lastSyncTime:a,isOwn:r,isProtected:c,albumLayout:d,onMediaClick:u,uploadsById:m,activeDownloadIds:h,theme:g})=>{const{cancelSendingMessage:p}=(0,n.uC)(),f=e.messages.length,I=(0,o.I4)((e=>{p({chatId:e.chatId,messageId:e.id})}),[p]),{width:v,height:y}=d.containerStyle;return o.ZP.createElement("div",{className:"Album",style:`width: ${v}px; height: ${y}px;`},e.messages.map((function(e,p){const{photo:v,video:y}=(0,l.qp)(e),Z=m[e.previousLocalId||e.id],P=null==Z?void 0:Z.progress,{dimensions:C,sides:w}=d.layout[p],b=(0,i.bH)((0,n.Rd)(),e),S=(0,i.__)((0,n.Rd)(),e);if(v){const n=s&&(r?p===f-1:Boolean(8&w&&4&w));return o.ZP.createElement(sn,{id:`album-media-${e.id}`,message:e,observeIntersection:t,canAutoLoad:b,shouldAffectAppendix:n,uploadProgress:P,dimensions:C,isProtected:c,onClick:u,onCancelUpload:I,isDownloading:h.includes(e.id),theme:g})}if(y)return o.ZP.createElement(nn,{id:`album-media-${e.id}`,message:e,observeIntersection:t,canAutoLoad:b,canAutoPlay:S,uploadProgress:P,lastSyncTime:a,dimensions:C,isProtected:c,onClick:u,onCancelUpload:I,isDownloading:h.includes(e.id),theme:g})})))}));function on(){return(on=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}let rn;const cn=({message:e,observeIntersection:t,canAutoLoad:s,lastSyncTime:a,isDownloading:r})=>{const i=(0,o.sO)(null),c=(0,o.sO)(null),d=(0,o.sO)(null),m=e.content.video,h=(0,ss.Op)(i,t),[g,p]=(0,o.eJ)(s),f=Boolean(g&&h&&a),{mediaData:I,loadProgress:v}=(0,Ts.Z)((0,l.Ti)(e,"inline"),!f,(0,l.kG)(e,"inline"),a),{loadProgress:y}=(0,Ts.Z)((0,l.Ti)(e,"download"),!r,u.IU.BlobUrl,a),Z=Bs(e,I),{isBuffered:P,bufferingHandlers:w}=(0,Os.Z)(),b=g&&!P||r,S=!1===(0,lt.Z)(g),E=(0,Ss.Z)(I),{shouldRender:M,transitionClassNames:k}=(0,ce.Z)(b||!P,void 0,S),[R,T]=(0,o.eJ)(!1),[B,A]=(0,o.eJ)(0);(0,o.d4)((()=>{if(!R)return;const e=Zt.Rj/2,t=2*(e-6)*Math.PI,s=t-B*t,n=d.current,a=c.current,o=a.firstElementChild;o?o.firstElementChild.setAttribute("stroke-dashoffset",s.toString()):a.innerHTML=`\n <svg width="${Zt.Rj}px" height="${Zt.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>`,A(n.currentTime/n.duration)}),[R,B]);const x=Boolean(I&&h),L=()=>{T(!1),A(0),(0,Us.Z)(d.current),(0,C.T2)((()=>{c.current.innerHTML=""}))},O=(F=L,()=>{rn&&rn(),rn=F});var F;(0,o.d4)((()=>{d.current&&(x?(0,Us.Z)(d.current):d.current.pause())}),[x]),$s(d,x),(0,Fs.Z)(d,[I]);const U=(0,o.I4)((()=>{if(!I)return void p((e=>!e));if(r)return void(0,n.uC)().cancelMessageMediaDownload({message:e});const t=d.current;R?t.paused?((0,Us.Z)(t),(0,Nt.Es)()):t.pause():(O(),t.pause(),t.currentTime=0,(0,Us.Z)(t),(0,Nt.Es)(),T(!0))}),[O,R,r,I,e]),$=(0,o.I4)((e=>{const t=e.currentTarget;A(t.currentTime/t.duration)}),[]),D=(0,ne.Z)("full-media",E);return o.ZP.createElement("div",{ref:i,className:"RoundVideo media-inner",onClick:U},o.ZP.createElement("div",{className:"thumbnail-wrapper"},o.ZP.createElement("canvas",{ref:Z,className:"thumbnail",style:`width: ${Zt.Rj}px; height: ${Zt.Rj}px`})),I&&o.ZP.createElement("div",{className:"video-wrapper"},o.ZP.createElement("video",on({ref:d,className:D,width:Zt.Rj,height:Zt.Rj,autoPlay:!0,muted:!R,loop:!R,playsInline:!0,onEnded:R?L:void 0},w,{onTimeUpdate:R?$:void 0}),o.ZP.createElement("source",{src:I}))),o.ZP.createElement("div",{className:"progress",ref:c}),M&&o.ZP.createElement("div",{className:`media-loading ${k}`},o.ZP.createElement(xs.Z,{progress:r?y:v})),!I&&!g&&o.ZP.createElement("i",{className:"icon-download"}),o.ZP.createElement("div",{className:"message-media-duration"},R?(0,N.k9)(d.current.currentTime):(0,N.k9)(m.duration),(!R||d.current.paused)&&o.ZP.createElement("i",{className:"icon-muted"})))},ln=({message:e,onClick:t})=>{const s=(0,Ce.Z)();return o.ZP.createElement("div",{className:"InlineButtons"},e.inlineButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(Ee.Z,{size:"tiny",ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>t({button:e})},(0,Pt.Z)(s(e.text)),"buy"===e.type&&o.ZP.createElement("i",{className:"icon-card"}),"url"===e.type&&!e.value.match(a.FS)&&o.ZP.createElement("i",{className:"icon-arrow-right"}))))))))},dn=(0,o.X$)((({threadInfo:e,disabled:t})=>{const{openChat:s}=(0,n.uC)(),a=(0,Ce.Z)(),{threadId:r,chatId:i,messagesCount:c,lastMessageId:d,lastReadInboxMessageId:u,recentReplierIds:m}=e,h=(0,o.I4)((()=>{s({id:i,threadId:r})}),[s,i,r]),g=(0,o.Ye)((()=>{if(null==m||!m.length)return;const{users:{byId:e},chats:{byId:t}}=(0,n.Rd)();return m.map((s=>(0,l.YC)(s)?e[s]:t[s])).filter(Boolean)}),[m]);if(void 0===c)return;const p=Boolean(u&&d&&u<d);return o.ZP.createElement("div",{"data-cnt":(0,pt.bi)(c),className:(0,ne.Z)("CommentButton",p&&"has-unread",t&&"disabled"),dir:a.isRtl?"rtl":"ltr",onClick:h},o.ZP.createElement("i",{className:"icon-comments-sticker"}),(!g||0===g.length)&&o.ZP.createElement("i",{className:"icon-comments"}),g&&g.length>0&&o.ZP.createElement("div",{className:"recent-repliers",dir:a.isRtl?"rtl":"ltr"},g.map((e=>o.ZP.createElement(Ht.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"},c?a("Comments",c,"i"):a("LeaveAComment")),o.ZP.createElement("i",{className:"icon-next"}))})),un="data-is-document-group-hover",mn={__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>'},hn={__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>'};function gn(e){const t=fn(e.currentTarget);t&&t.setAttribute(un,"")}function pn(e){const t=fn(e.currentTarget);t&&t.removeAttribute(un)}function fn(e){let t=e;do{t=t.nextElementSibling}while(t&&!t.classList.contains("last-in-document-group"));return t}const In=(0,o.X$)((0,n.c$)(((e,t)=>{const{focusedMessage:s,forwardMessages:n,lastSyncTime:a}=e,{message:o,album:r,withSenderName:c,withAvatar:d,threadId:u,messageListType:m}=t,{id:h,chatId:g,viaBotId:p,replyToChatId:f,replyToMessageId:I,isOutgoing:v,threadInfo:y}=o,Z=(0,i.Z1)(e,g),P=(0,i.FM)(e,g),C=(0,l.pK)(g),w=Z&&(0,l.eA)(Z),b=null==Z?void 0:Z.username,S=!P&&(0,l.Ul)(o),E=c||d||S,M=(0,i.Ur)(e,o),k=(0,i.cv)(e,o),R=p?(0,i.dy)(e,p):void 0,T=u?(0,i.qS)(e,g,u):void 0,N=o.id===T,B=I===T,A=I&&!B?(0,i.hj)(e,C&&f?f:g,I):void 0,x=A&&(0,i.Ur)(e,A),L=(0,i.uZ)(e,o),O="thread"===m&&(r?r.messages.some((t=>(0,i._X)(e,t))):(0,i._X)(e,o)),{direction:F,noHighlight:U,isResizingContainer:$}=O&&s||{},D=n.messageIds&&n.messageIds.includes(h),{query:q}=(0,i.n5)(e)||{},Q=(0,l._O)(o);let G;G=null!=r&&r.messages?r.messages.every((({id:t})=>(0,i.vk)(e,t))):(0,i.vk)(e,h);const{canReply:j}="thread"===m&&(0,i._k)(e,o,u)||{},H=(0,i.te)(e,o),_=y?(0,i.tZ)(e,y.chatId,y.threadId)||y:void 0;return{theme:(0,i.Pu)(e),chatUsername:b,forceSenderName:S,sender:E?M:void 0,originSender:k,botSender:R,shouldHideReply:B,isThreadTop:N,replyMessage:A,replyMessageSender:x,isProtected:(0,i.EV)(e,o),isFocused:O,isForwarding:D,isChatWithSelf:P,isRepliesChat:C,isChannel:w,canReply:j,lastSyncTime:a,highlight:q,isSingleEmoji:Boolean(Q),animatedEmoji:Q?(0,i.zB)(e,Q):void 0,isInSelectMode:(0,i.CA)(e),isSelected:G,isGroupSelected:!!o.groupedId&&!o.isInAlbum&&(0,i.a6)(e,g,o.groupedId),threadId:u,isDownloading:H,isPinnedList:"pinned"===m,canAutoLoadMedia:(0,i.bH)(e,o),canAutoPlayMedia:(0,i.__)(e,o),autoLoadFileMaxSizeMb:e.settings.byKey.autoLoadFileMaxSizeMb,shouldLoopStickers:(0,i.yB)(e),threadInfo:_,...v&&{outgoingStatus:(0,i.dT)(e,o,"scheduled"===m)},..."number"==typeof L&&{uploadProgress:L},...O&&{focusDirection:F,noFocusHighlight:U,isResizingContainer:$}}}))((({message:e,chatUsername:t,observeIntersectionForBottom:s,observeIntersectionForMedia:a,observeIntersectionForAnimatedStickers:r,album:i,noAvatars:c,withAvatar:d,withSenderName:g,noComments:p,appearanceOrder:f,isFirstInGroup:I,isLastInGroup:v,isFirstInDocumentGroup:y,isLastInDocumentGroup:Z,isLastInList:P,theme:C,forceSenderName:w,sender:b,originSender:S,botSender:E,isThreadTop:M,shouldHideReply:k,replyMessage:R,replyMessageSender:T,outgoingStatus:N,uploadProgress:B,isProtected:A,isFocused:x,focusDirection:L,noFocusHighlight:O,isResizingContainer:F,isForwarding:U,isChatWithSelf:$,isRepliesChat:D,isChannel:q,canReply:Q,lastSyncTime:G,highlight:j,animatedEmoji:H,isInSelectMode:_,isSelected:z,isGroupSelected:V,threadId:Y,messageListType:K,isPinnedList:W,isDownloading:X,canAutoLoadMedia:J,canAutoPlayMedia:ee,shouldLoopStickers:te,autoLoadFileMaxSizeMb:se,threadInfo:ae})=>{const{toggleMessageSelection:oe,clickInlineButton:le,disableContextMenuHint:de}=(0,n.uC)(),ue=(0,o.sO)(null),me=(0,o.sO)(null),he=(0,Ce.Z)();(0,ss._N)(me,s);const{isContextMenuOpen:ge,contextMenuPosition:pe,handleBeforeContextMenu:fe,handleContextMenu:Ie,handleContextMenuClose:ve,handleContextMenuHide:Ze}=(0,os.Z)(ue,h.$b&&_,!0,h.wZ);(0,o.d4)((()=>{ge&&de()}),[ge,de]);const Pe=f<=0,[we,be]=(0,ye.Z)(Pe);(0,o.d4)((()=>{Pe||setTimeout(be,10*f)}),[f,be,Pe]);const{transitionClassNames:Se}=(0,ce.Z)(we,void 0,Pe,!1),{id:Me,chatId:ke}=e,Re=(0,l.CI)(e),Te=(0,l.B4)(e),Ne="scheduled"===K||e.isScheduled,Be=(0,l.ss)(e)&&!k,Ae=Boolean(ae)&&"thread"===K,{forwardInfo:Le,viaBotId:Oe}=e,Fe=Le&&(!$||Ne)&&!D&&!Le.isLinkedChannelPost,Ue=Boolean(e.groupedId)&&!e.isInAlbum,$e=Boolean(i)&&i.messages.length>1,{text:De,photo:qe,video:Qe,audio:Ge,voice:je,document:He,sticker:_e,contact:ze,poll:Ve,webPage:Ye,invoice:Ke}=(0,l.qp)(e),We=(0,l.$D)(e),Xe=(0,rs.X)(e,j,is(We)),Je=void 0!==pe,et=q&&e.adminTitle||Le&&!Fe&&Le.adminTitle||void 0,tt=(0,o.Ye)((()=>et?ps(et):void 0),[et]),st=!(Je||_||U)&&(!Ue||Z),nt=q&&!Ne,at=Boolean(W||Le&&(Le.isChannelPost||$&&!Te||D)&&Le.fromMessageId),ot=Le&&($||D||!b)?S:b,rt=Le?S:b,it=(0,o.I4)(((e,t)=>{oe({messageId:Me,groupedId:t,...(null==e?void 0:e.shiftKey)&&{withShift:!0},...$e&&{childMessageIds:i.messages.map((({id:e})=>e))}})}),[oe,Me,$e,i]),{handleMouseDown:ct,handleClick:lt,handleContextMenu:dt,handleDoubleClick:ut,handleContentDoubleClick:mt,isSwiped:gt}=function(e,t,s,a,r,i,c,l,d){const{setReplyingToId:u}=(0,n.uC)(),[m,g,p]=(0,ye.Z)();return(0,o.d4)((()=>{if(!h.$b||r||!i)return;let e;return(0,xe.s)(t.current,{selectorToPreventScroll:".MessageList",onSwipe:(t,s)=>s===xe.e.Left&&(e||(e=Date.now()),g(),!0),onRelease:()=>{e&&(u({messageId:s}),setTimeout(p,Math.max(0,150-(Date.now()-e))),e=void 0)}})}),[t,r,s,u,g,p,i]),{handleMouseDown:r?void 0:function(e){(0,Xt.q)(e),d(e)},handleClick:function(t){if(r)e(t);else if(h.wZ){const e=t.target;if(!e.classList.contains("text-content")&&!e.classList.contains("Message"))return;ie.Z.getIsKeyboardVisible()?setTimeout((()=>{l(t)}),350):l(t)}},handleContextMenu:r?c?re.Z:void 0:function(t){if(h.wZ){if(t.target.matches("a[href]"))return;t.preventDefault(),e()}else l(t)},handleDoubleClick:r?void 0:function(){u({messageId:s})},handleContentDoubleClick:h.$b?void 0:function(e){e.stopPropagation()},isSwiped:m}}(it,ue,Me,0,Boolean(_),Boolean(Q),Boolean(A),Ie,fe),{handleAvatarClick:pt,handleSenderClick:ft,handleViaBotClick:It,handleReplyClick:vt,handleMediaClick:yt,handleAudioPlay:Ct,handleAlbumMediaClick:wt,handleMetaClick:bt,handleReadMedia:St,handleCancelUpload:Et,handleVoteSend:Mt,handleGroupForward:kt,handleForward:Rt,handleFocus:Tt,handleFocusForwarded:Nt,handleDocumentGroupSelectAll:Bt}=function(e,t,s,a,r,i,c,d,h,g,p,f){const{openUserInfo:I,openChat:v,showNotification:y,focusMessage:Z,openMediaViewer:P,openAudioPlayer:C,markMessagesRead:w,cancelSendingMessage:b,sendPollVote:S,openForwardMenu:E,focusMessageInComments:M}=(0,n.uC)(),{id:k,forwardInfo:R,replyToMessageId:T,replyToChatId:N,replyToTopMessageId:B,groupedId:A}=s,x=(0,o.I4)((()=>{g&&((0,l.YC)(g.id)?I({id:g.id}):v({id:g.id}))}),[g,I,v]),L=(0,o.I4)((()=>{p?null!=R&&R.channelPostId?Z({chatId:p.id,messageId:R.channelPostId}):(0,l.YC)(p.id)?I({id:p.id}):v({id:p.id}):y({message:e("HidAccount")})}),[Z,null==R?void 0:R.channelPostId,e,v,I,p,y]),O=(0,o.I4)((()=>{f&&I({id:f.id})}),[f,I]),F=(0,o.I4)((()=>{Z({chatId:d&&N?N:a,threadId:r,messageId:T,replyMessageId:d&&N?void 0:k})}),[Z,d,N,a,r,T,k]),U=(0,o.I4)((()=>{P({chatId:a,threadId:r,messageId:k,origin:c?m.bZ.ScheduledInline:m.bZ.Inline})}),[a,r,k,P,c]),$=(0,o.I4)((()=>{C({chatId:a,messageId:k})}),[a,k,C]),D=(0,o.I4)((e=>{P({chatId:a,threadId:r,messageId:e,origin:c?m.bZ.ScheduledAlbum:m.bZ.Album})}),[a,r,P,c]),q=(0,o.I4)((()=>{w({messageIds:[k]})}),[k,w]),Q=(0,o.I4)((()=>{b({chatId:a,messageId:k})}),[b,a,k]),G=(0,o.I4)((e=>{S({chatId:a,messageId:k,options:e})}),[a,k,S]),j=(0,o.I4)((()=>{E({fromChatId:a,groupedId:A})}),[E,a,A]),H=(0,o.I4)((()=>{if(h&&h.messages){const e=h.messages.map((({id:e})=>e));E({fromChatId:a,messageIds:e})}else E({fromChatId:a,messageIds:[k]})}),[h,E,a,k]),_=(0,o.I4)((()=>{Z({chatId:a,threadId:u._f,messageId:k})}),[Z,a,k]),z=(0,o.I4)((()=>{i?Z({chatId:R.fromChatId,groupedId:A,groupedChatId:a}):d&&N?M({chatId:N,threadId:B,messageId:R.fromMessageId}):Z({chatId:R.fromChatId,messageId:R.fromMessageId})}),[i,d,N,Z,R,A,a,M,B]),V=(0,o.I4)((e=>{e.stopPropagation(),t(e,A)}),[t,A]);return{handleAvatarClick:x,handleSenderClick:L,handleViaBotClick:O,handleReplyClick:F,handleMediaClick:U,handleAudioPlay:$,handleAlbumMediaClick:D,handleMetaClick:V,handleReadMedia:q,handleCancelUpload:Q,handleVoteSend:G,handleGroupForward:j,handleForward:H,handleFocus:_,handleFocusForwarded:z,handleDocumentGroupSelectAll:V}}(he,it,e,ke,Y,Ue,Boolean(Ne),D,i,ot,rt,E),At=(0,ne.Z)("Message message-list-item",I&&"first-in-group",A&&"is-protected",v&&"last-in-group",y&&"first-in-document-group",Z&&"last-in-document-group",P&&"last-in-list",Te&&"own",Boolean(e.views)&&"has-views",e.isEdited&&"was-edited",Be&&"has-reply",Je&&"has-menu-open",x&&!O&&"focused",U&&"is-forwarding",e.isDeleting&&"is-deleting",Ue&&"is-in-document-group",$e&&"is-album",e.hasUnreadMention&&"has-unread-mention",z&&"is-selected",_&&"is-in-selection-mode",M&&"is-thread-top",Boolean(e.inlineButtons)&&"has-inline-buttons",gt&&"is-swiped",Se),xt=function(e,{hasReply:t,customShape:s,isLastInGroup:n,asForwarded:a,hasThread:o,forceSenderName:r,hasComments:i,hasActionButton:c}={}){const{text:d,photo:u,video:m,audio:h,voice:g,document:p,poll:f,webPage:I,contact:v}=(0,l.qp)(e),y=["message-content"],Z=u||m,P=Z&&!d,C=Boolean(e.viaBotId);return is(s)?y.push(`emoji-only emoji-only-${s}`):d&&y.push("text"),c&&y.push("has-action-button"),s&&(y.push("custom-shape"),null!=m&&m.isRound&&y.push("round"),i&&y.push("has-comments")),u||m?y.push("media"):h?y.push("audio"):g?y.push("voice"):p?y.push("document"):v?y.push("contact"):f?y.push("poll"):I&&(y.push("web-page"),(I.photo||I.video)&&y.push("media")),a&&!s&&y.push("is-forwarded"),t&&y.push("is-reply"),o&&y.push("has-replies"),C&&y.push("is-via-bot"),r&&y.push("force-sender-name"),s||(y.push("has-shadow"),Z&&i&&y.push("has-background"),(t||a||!P||C||r)&&y.push("has-solid-background"),!n||!u&&P||y.push("has-appendix")),y.join(" ")}(e,{hasReply:Be,customShape:We,isLastInGroup:v,asForwarded:Fe,hasThread:Ae,forceSenderName:w,hasComments:ae&&(null==ae?void 0:ae.messagesCount)>0,hasActionButton:nt||at}),Lt=ae&&(!Ue||Z)&&"thread"===K&&!p,Ot=xt.includes("has-appendix");(0,ht.Z)(D&&e.replyToChatId?e.replyToChatId:ke,Be?e.replyToMessageId:void 0,R,e.id),fs(ue,ke,x,L,O,F);let Ft,Ut="",$t=!1;const Dt=(0,o.Ye)((()=>$e?hs(Te,Boolean(Fe),Boolean(c),i):void 0),[$e,Te,Fe,c,i]),qt=Fe?28:0;if($e||!qe&&!Qe)Dt&&(Ft=Math.max(cs(Boolean(De),Lt),Dt.containerStyle.width),Ft-Dt.containerStyle.width>18&&($t=!0));else{let t;qe?t=ls(e,c).width:Qe&&(t=Qe.isRound?Zt.Rj:ls(e,c).width),t&&(Ft=Math.max(cs(Boolean(De),Lt),t),Ft-t>18&&($t=!0))}return Ft&&(Ut=`width: ${Ft+qt}px`),o.ZP.createElement("div",{ref:ue,id:`message${Me}`,className:At,style:tt?`--meta-safe-author-width: ${tt}px`:void 0,"data-message-id":Me,onMouseDown:ct,onClick:lt,onContextMenu:dt,onDoubleClick:ut,onMouseEnter:Ue&&!Z?gn:void 0,onMouseLeave:Ue&&!Z?pn:void 0},o.ZP.createElement("div",{ref:me,className:"bottom-marker","data-message-id":Me,"data-last-message-id":i?i.messages[i.messages.length-1].id:void 0,"data-has-unread-mention":e.hasUnreadMention}),!Ue&&o.ZP.createElement("div",{className:"message-select-control"},z&&o.ZP.createElement("i",{className:"icon-select"})),Z&&o.ZP.createElement("div",{className:(0,ne.Z)("message-select-control group-select",V&&"is-selected"),onClick:Bt},V&&o.ZP.createElement("i",{className:"icon-select"})),d&&function(){const e=ot&&(0,l.YC)(ot.id),t=ot&&e?ot:void 0,s=ot&&!e?ot:void 0,n=!ot&&Le?Le.hiddenUserName:void 0;return o.ZP.createElement(Ht.Z,{size:"small",user:t,chat:s,text:n,lastSyncTime:G,onClick:t||s?pt:void 0})}(),o.ZP.createElement("div",{className:(0,ne.Z)("message-content-wrapper",xt.includes("text")&&"can-select-text")},o.ZP.createElement("div",{className:xt,style:Ut,dir:"auto"},Fe&&!We&&(!Ue||y)&&o.ZP.createElement("div",{className:"message-title"},he("ForwardedMessage")),function(){const t=(0,ne.Z)("content-inner",Fe&&!We&&"forwarded-message",Be&&"reply-message",$t&&"no-media-corners"),s=v&&!Xe&&!Fe&&!Ae,n=!Ye&&!H&&Xe,d=(0,ne.Z)("text-content",n&&"with-meta",N&&"with-outgoing-icon");return o.ZP.createElement("div",{className:t,onDoubleClick:mt,dir:"auto"},function(){if(We&&!Oe||!(g&&!qe&&!Qe||Fe||Oe||w)||Ue&&!y||Be&&We)return;let t,s;return!rt||We&&Oe?null!=Le&&Le.hiddenUserName&&(t=Le.hiddenUserName):(t=(0,l.OU)(he,rt),Fe||(s=`color-${(0,l.Rs)(rt)}`)),o.ZP.createElement("div",{className:"message-title",dir:"ltr"},t?o.ZP.createElement("span",{className:(0,ne.Z)("interactive",s),onClick:ft,dir:"auto"},(0,Pt.Z)(t)):E?void 0:" ",E&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("span",{className:"via"},he("ViaBot")),o.ZP.createElement("span",{className:"interactive",onClick:It},(0,Pt.Z)(`@${E.username}`))),null!=Le&&Le.isLinkedChannelPost?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},he("DiscussChannel")):e.adminTitle&&!q?o.ZP.createElement("span",{className:"admin-title",dir:"auto"},e.adminTitle):void 0)}(),Be&&o.ZP.createElement(Zs,{message:R,isProtected:A,sender:T,observeIntersection:a,onClick:vt}),_e&&o.ZP.createElement(ks,{message:e,observeIntersection:a,observeIntersectionForPlaying:r,shouldLoop:te,lastSyncTime:G}),H&&o.ZP.createElement(Rs.Z,{size:"small",sticker:H,observeIntersection:a,lastSyncTime:G,forceLoadPreview:Re}),$e&&o.ZP.createElement(an,{album:i,albumLayout:Dt,observeIntersection:a,isOwn:Te,isProtected:A,hasCustomAppendix:s,lastSyncTime:G,onMediaClick:wt}),!$e&&qe&&o.ZP.createElement(Ls,{message:e,observeIntersection:a,noAvatars:c,canAutoLoad:J,uploadProgress:B,shouldAffectAppendix:s,onClick:yt,onCancelUpload:Et,isDownloading:X,isProtected:A,theme:C}),!$e&&Qe&&Qe.isRound&&o.ZP.createElement(cn,{message:e,observeIntersection:a,canAutoLoad:J,lastSyncTime:G,isDownloading:X}),!$e&&Qe&&!Qe.isRound&&o.ZP.createElement(qs,{message:e,observeIntersection:a,noAvatars:c,canAutoLoad:J,canAutoPlay:ee,uploadProgress:B,lastSyncTime:G,onClick:yt,onCancelUpload:Et,isDownloading:X,isProtected:A}),(Ge||je)&&o.ZP.createElement(Cs.Z,{theme:C,message:e,origin:m.Cr.Inline,uploadProgress:B,lastSyncTime:G,isSelectable:Ue,isSelected:z,onPlay:Ct,onReadMedia:!je||Te&&!$?void 0:St,onCancelUpload:Et,isDownloading:X}),He&&o.ZP.createElement(Ps.Z,{message:e,observeIntersection:a,canAutoLoad:J,autoLoadFileMaxSizeMb:se,uploadProgress:B,isSelectable:Ue,isSelected:z,onMediaClick:yt,onCancelUpload:Et,isDownloading:X}),ze&&o.ZP.createElement(Gs,{contact:ze}),Ve&&o.ZP.createElement(Ys,{message:e,poll:Ve,onSendVote:Mt}),!H&&Xe&&o.ZP.createElement("p",{className:d,dir:"auto"},Xe,n&&o.ZP.createElement(bs,{message:e,outgoingStatus:N,signature:et,onClick:bt})),Ye&&o.ZP.createElement(Xs,{message:e,observeIntersection:a,noAvatars:c,canAutoLoad:J,canAutoPlay:ee,lastSyncTime:G,onMediaClick:yt,onCancelMediaTransfer:Et,isDownloading:X,isProtected:A,theme:C}),Ke&&o.ZP.createElement(en,{message:e}))}(),(!Ue||Z)&&!(!Ye&&!H&&Xe)&&o.ZP.createElement(bs,{message:e,outgoingStatus:N,signature:et,onClick:bt}),st&&nt?o.ZP.createElement(Ee.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:he("lng_context_forward_msg"),onClick:Z?kt:Rt},o.ZP.createElement("i",{className:"icon-share-filled"})):st&&at?o.ZP.createElement(Ee.Z,{className:"message-action-button",color:"translucent-white",round:!0,size:"tiny",ariaLabel:"Focus message",onClick:W?Tt:Nt},o.ZP.createElement("i",{className:"icon-arrow-right"})):void 0,Lt&&o.ZP.createElement(dn,{threadInfo:ae,disabled:p}),Ot&&o.ZP.createElement("div",{className:"svg-appendix",dangerouslySetInnerHTML:Te?mn:hn})),e.inlineButtons&&o.ZP.createElement(ln,{message:e,onClick:le})),pe&&o.ZP.createElement(vs,{isOpen:ge,anchor:pe,message:e,album:i,chatUsername:t,messageListType:K,onClose:ve,onCloseAnimationEnd:Ze}))}))),vn=(0,o.X$)((0,n.c$)(((e,{chatId:t})=>{const s=(0,i.fS)(e,t),{chatId:n,isBot:a}=s||{};return{message:s,bot:n&&a?(0,i.dy)(e,n):void 0,channel:!a&&n?(0,i.Z1)(e,n):void 0}}))((({chatId:e,message:t,containerRef:s,bot:a,channel:r})=>{const{viewSponsoredMessage:i,openChat:c,openChatByInvite:d,startBot:u,focusMessage:m}=(0,n.uC)(),h=(0,Ce.Z)(),g=(0,o.sO)(null),p=Boolean(t),{observe:f}=(0,ss.S1)({rootRef:s,debounceMs:200,threshold:1});if((0,o.d4)((()=>p?f(g.current,(t=>{t.isIntersecting&&i({chatId:e})})):void 0),[e,p,f,i]),t)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"},a&&(0,Pt.Z)((0,l.Js)(a)||""),r&&(0,Pt.Z)(t.chatInviteTitle||(0,l.U)(h,r,a)||"")),o.ZP.createElement("p",{className:"text-content with-meta",dir:"auto",ref:g},o.ZP.createElement("span",{className:"text-content-inner",dir:"auto"},(0,rs.H)(t.text.text,t.text.entities)),o.ZP.createElement("span",{className:"MessageMeta",dir:"ltr"},o.ZP.createElement("span",{className:"message-signature"},h("SponsoredMessage")))),o.ZP.createElement(Ee.Z,{color:"secondary",size:"tiny",ripple:!0,onClick:()=>{t.chatInviteHash?d({hash:t.chatInviteHash}):t.channelPostId?m({chatId:t.chatId,messageId:t.channelPostId}):(c({id:t.chatId}),t.startParam&&u({botId:t.chatId,param:t.startParam}))},className:"SponsoredMessage__button"},h(t.isBot?"Conversation.ViewBot":t.channelPostId?"Conversation.ViewPost":"Conversation.ViewChannel")))))}))),yn=(0,o.X$)((({chatId:e,messageIds:t,messageGroups:s,isViewportNewest:r,isUnread:i,withUsers:c,noAvatars:d,containerRef:u,anchorIdRef:p,memoUnreadDividerBeforeIdRef:f,memoFirstUnreadIdRef:I,threadId:v,type:y,isReady:Z,isScrollingRef:P,isScrollPatchNeededRef:w,threadTopMessageId:b,hasLinkedChat:S,isSchedule:E,noAppearanceAnimation:M,onFabToggle:k,onNotchToggle:R})=>{const{openHistoryCalendar:T}=(0,n.uC)(),{observeIntersectionForMedia:B,observeIntersectionForReading:A,observeIntersectionForAnimatedStickers:x}=function(e,t,s){const{markMessageListRead:a,markMessagesRead:o}=(0,n.uC)(),{observe:r}=(0,ss.S1)({rootRef:t,throttleMs:ns,margin:as}),{observe:i,freeze:c,unfreeze:l}=(0,ss.S1)({rootRef:t,throttleMs:150},(t=>{if("thread"!==e)return;let n=0;const r=[];t.forEach((e=>{const{isIntersecting:t,target:s}=e;if(!t)return;const{dataset:a}=s,o=Number(a.lastMessageId||a.messageId);o>n&&(n=o),a.hasUnreadMention&&r.push(o)})),s.current&&n>=s.current&&a({maxId:n}),r.length&&o({messageIds:r})}));(0,le.Z)(c,l);const{observe:d}=(0,ss.S1)({rootRef:t,throttleMs:ns});return{observeIntersectionForMedia:r,observeIntersectionForReading:i,observeIntersectionForAnimatedStickers:d}}(y,u,I),{backwardsTriggerRef:L,forwardsTriggerRef:O,fabTriggerRef:F}=function(e,t,s,r,i,c,l,d,u,g){const{loadViewportMessages:p}=(0,n.uC)(),[f,I]=(0,o.Ye)((()=>"thread"===e?[(0,C.Ds)((()=>p({direction:m.Uq.Backwards})),1e3,!0,!1),(0,C.Ds)((()=>p({direction:m.Uq.Forwards})),1e3,!0,!1)]:[]),[p,s]),v=(0,o.sO)(null),y=(0,o.sO)(null),Z=(0,o.sO)(null);function P(){if(!d)return;if(!s||!s.length)return c(!1),void l(!1);if(!r)return c(!0),void l(!0);const{offsetHeight:e,scrollHeight:n,scrollTop:a}=t.current,o=Math.round(n-a-e),u=o<=1;c(i?!u:!(o<=50)),l(!u)}const{observe:w}=(0,ss.S1)({rootRef:t,margin:h.gZ},(e=>{if(!I||!f)return;if(s[0]>=a.AE)return;const t=e.find((({isIntersecting:e})=>e));if(!t)return;const{target:n}=t;"backwards-trigger"===n.className?(h.i4&&u.current&&s.length<=a.hT&&(g.current=!0),f()):"forwards-trigger"===n.className&&I()}));(0,ss._N)(v,w),(0,ss._N)(y,w);const{observe:b,freeze:S,unfreeze:E}=(0,ss.S1)({rootRef:t,margin:100},P);(0,ss._N)(Z,b);const{observe:M,freeze:k,unfreeze:R}=(0,ss.S1)({rootRef:t,margin:1},P);return(0,ss._N)(Z,M),(0,ue.Z)((()=>{d&&P()}),[d]),(0,ue.Z)((()=>{S(),k(),setTimeout((()=>{R(),E()}),250)}),[s]),{backwardsTriggerRef:v,forwardsTriggerRef:y,fabTriggerRef:Z}}(y,u,t,r,i,k,R,Z,P,w),U=(0,Ce.Z)(),$=o.ZP.createElement("div",{className:(0,ne.Z)("unread-divider","local-action-message"),key:"unread-messages"},o.ZP.createElement("span",null,U("UnreadMessages"))),D=M?0:s.reduce(((e,t)=>e+(0,g.xH)(t.senderGroups).length),0);let q=0;const Q=s.map(((e,t,s)=>{const n=e.senderGroups.map(((e,n,a)=>{if(1===e.length&&!Kt(e[0])&&(0,l.Lo)(e[0])){const r=e[0],i=n===a.length-1&&t===s.length-1;return(0,g.oA)([r.id===f.current&&$,o.ZP.createElement(ys,{key:r.id,message:r,observeIntersection:A,appearanceOrder:D-++q,isLastInList:i})])}let r;return(0,g.xH)(e.map(((i,u)=>{const m=Kt(i)?i.mainMessage:i,h=Kt(i)?i:void 0,I=(0,l.B4)(m),Z=Kt(i),P=e[u+1];m.previousLocalId&&p.current===`message${m.previousLocalId}`&&(p.current=`message${m.id}`);const C=!Z&&m.groupedId?m.groupedId:void 0,w=P&&!Kt(P)?P.groupedId:void 0,E={isFirstInGroup:0===u,isLastInGroup:u===e.length-1,isFirstInDocumentGroup:Boolean(C&&C!==r),isLastInDocumentGroup:Boolean(C&&C!==w),isLastInList:u===e.length-1&&n===a.length-1&&t===s.length-1};r=C;const M=(0,l.KK)(m),k="scheduled"!==y?M:`${m.date}_${M}`;return(0,g.oA)([m.id===f.current&&$,o.ZP.createElement(In,{key:k,message:m,observeIntersectionForBottom:A,observeIntersectionForMedia:B,observeIntersectionForAnimatedStickers:x,album:h,noAvatars:d,withAvatar:E.isLastInGroup&&c&&!I&&!(m.id===b),withSenderName:E.isFirstInGroup&&c&&!I,threadId:v,messageListType:y,noComments:!1===S,appearanceOrder:D-++q,isFirstInGroup:E.isFirstInGroup,isLastInGroup:E.isLastInGroup,isFirstInDocumentGroup:E.isFirstInDocumentGroup,isLastInDocumentGroup:E.isLastInDocumentGroup,isLastInList:E.isLastInList}),m.id===b&&o.ZP.createElement("div",{className:"local-action-message",key:"discussion-started"},o.ZP.createElement("span",null,U("DiscussionStarted")))])})))}));return o.ZP.createElement("div",{className:"message-date-group",key:e.datetime,onMouseDown:Xt.q,teactFastList:!0},o.ZP.createElement("div",{className:(0,ne.Z)("sticky-date",!E&&"interactive"),key:"date-header",onMouseDown:Xt.q,onClick:E?void 0:()=>T({selectedAt:e.datetime})},o.ZP.createElement("span",{dir:"auto"},E&&e.originalDate===a.t4&&U("MessageScheduledUntilOnline"),E&&e.originalDate!==a.t4&&U("MessageScheduledOn",(0,N.j1)(U,e.datetime,void 0,!0)),!E&&(0,N.j1)(U,e.datetime))),(0,g.xH)(n))}));return o.ZP.createElement("div",{className:"messages-container",teactFastList:!0},o.ZP.createElement("div",{ref:L,key:"backwards-trigger",className:"backwards-trigger"}),(0,g.xH)(Q),r&&o.ZP.createElement(vn,{key:e,chatId:e,containerRef:u}),o.ZP.createElement("div",{ref:O,key:"forwards-trigger",className:"forwards-trigger"}),o.ZP.createElement("div",{ref:F,key:"fab-trigger",className:"fab-trigger"}))}));var Zn=s(3547);const Pn=(0,o.X$)((0,n.c$)(((e,{userId:t})=>{const{stickers:s}=e.stickers.greeting,n=(0,l.db)(t)+(0,l.db)(e.currentUserId),a=null!=s&&s.length?s[n%s.length]:void 0,o=(0,i.Z1)(e,t);return o?{sticker:a,lastUnreadMessageId:o.lastMessage&&o.lastMessage.id!==o.lastReadInboxMessageId?o.lastMessage.id:void 0,connectionState:e.connectionState}:{}}))((({sticker:e,connectionState:t,lastUnreadMessageId:s})=>{const{loadGreetingStickers:a,sendMessage:r,markMessageListRead:i}=(0,n.uC)(),c=(0,Ce.Z)(),l=(0,o.sO)(null),{observe:d}=(0,ss.S1)({rootRef:l,debounceMs:200});(0,o.d4)((()=>{e||"connectionStateReady"!==t||a()}),[t,a,e]),(0,o.d4)((()=>{"connectionStateReady"===t&&s&&i({maxId:s})}),[t,i,s]);const u=(0,o.I4)((e=>{e={...e,isPreloadedGlobally:!0},r({sticker:e})}),[r]);return o.ZP.createElement("div",{className:"ContactGreeting",ref:l},o.ZP.createElement("div",{className:"wrapper"},o.ZP.createElement("p",{className:"title",dir:"auto"},c("Conversation.EmptyPlaceholder")),o.ZP.createElement("p",{className:"description",dir:"auto"},c("Conversation.GreetingText")),o.ZP.createElement("div",{className:"sticker"},e&&o.ZP.createElement(Zn.Z,{sticker:e,onClick:u,clickArg:e,observeIntersection:d,size:160,className:"large"}))))}))),Cn=(0,o.X$)((({isChatWithSelf:e,type:t,isGroupChatJustCreated:s})=>{const n=(0,Ce.Z)();return"scheduled"===t?function(e){return o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,e("ScheduledMessages.EmptyPlaceholder")))}(n):e?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")))))}(n):s?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")))))}(n):o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,n("NoMessages")))})),wn=(0,C.Ds)((e=>e()),200,!1),bn=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,type:n})=>{const a=(0,i.Z1)(e,t);if(!a)return{};const o=(0,i.$W)(e,t,s,n),r="scheduled"===n?(0,i.Fn)(e,t):(0,i.Zw)(e,t),c=(0,i.qS)(e,t,s);if(s!==u._f&&!(r&&c&&r[c]))return{};const{isRestricted:d,restrictionReason:m,lastMessage:h}=a,g=(0,i.G$)(e,t),p=s===u._f&&!o&&!a.unreadCount&&!g&&h&&!h.groupedId,f=(0,i.IK)(e,t);let I;return(0,i.pk)(e,t)&&(I=f.fullInfo?f.fullInfo.botDescription||"NoMessages":"Updating bot info..."),{isChatLoaded:!0,isRestricted:d,restrictionReason:m,isChannelChat:(0,l.eA)(a),isGroupChat:(0,l.Bf)(a),isCreator:a.isCreator,isChatWithSelf:(0,i.FM)(e,t),isRepliesChat:(0,l.pK)(t),isBot:Boolean(f),messageIds:o,messagesById:r,firstUnreadId:(0,i.It)(e,t,s),isViewportNewest:"thread"!==n||(0,i.b9)(e,t,s),threadFirstMessageId:(0,i.yZ)(e,t,s),focusingId:g,isSelectModeActive:(0,i.CA)(e),botDescription:I,threadTopMessageId:c,hasLinkedChat:a.fullInfo&&"linkedChatId"in a.fullInfo?Boolean(a.fullInfo.linkedChatId):void 0,lastSyncTime:e.lastSyncTime,...p&&{lastMessage:h}}}))((({chatId:e,threadId:t,type:s,hasTools:r,onFabToggle:c,onNotchToggle:d,isChatLoaded:u,isChannelChat:h,isGroupChat:p,canPost:f,isReady:I,isChatWithSelf:v,isRepliesChat:y,isCreator:Z,isBot:P,messageIds:w,messagesById:b,firstUnreadId:S,isViewportNewest:E,threadFirstMessageId:M,isRestricted:k,restrictionReason:R,focusingId:T,isSelectModeActive:N,lastMessage:B,botDescription:A,threadTopMessageId:x,hasLinkedChat:L,lastSyncTime:O,withBottomShift:F})=>{var U,$,D,q,Q,G;const{loadViewportMessages:j,setScrollOffset:H,loadSponsoredMessages:_}=(0,n.uC)(),z=(0,o.sO)(null),V=(0,o.sO)("thread"===s&&(0,i.Vt)((0,n.Rd)(),e,t)||0),Y=(0,o.sO)(),K=(0,o.sO)(),W=(0,o.sO)(),X=(0,o.sO)(),J=(0,o.sO)(),ee=(0,o.sO)(),te=(0,o.sO)(!1),ae=(0,o.sO)(Boolean(B)),[oe,re]=(0,o.eJ)(),ie=Boolean(w);(0,ue.Z)((()=>{ie&&(0,C.R3)((()=>{ae.current=!1}))}),[ie]),(0,ue.Z)((()=>{X.current=S}),[S]),(0,ue.Z)((()=>{h&&I&&O&&_({chatId:e})}),[e,I,h,O]),(0,ue.Z)((()=>{ie&&(J.current=X.current)}),[ie]),(0,ue.Z)((()=>{ee.current=T}),[T]);const ce=(0,o.Ye)((()=>{if(!w||!b)return;const e=!x||w[0]&&M!==w[0]?w:[x,...w];if(!e.length)return;const t=e.map((e=>b[e])).filter(Boolean);return Wt((0,g.Xo)(t,["date","id"]),J.current)}),[w,b,M,x]),le=(0,o.Ye)((()=>{if("thread"===s)return(0,C.Ds)((()=>j({direction:m.Uq.Around})),1e3,!0,!1)}),[j,w]),{isScrolled:de,updateStickyDates:me}=function(){const[e,t]=(0,ye.Z)(!1),s=(0,Jt.Z)(1e3,!1);return{isScrolled:e,updateStickyDates:(0,o.I4)(((e,n)=>{t(),document.body.classList.contains("is-scrolling-messages")||(0,C.T2)((()=>{document.body.classList.add("is-scrolling-messages")})),s((()=>{(0,C.T2)((()=>{const t=document.querySelector(".stuck");t&&t.classList.remove("stuck");const s=function(e,t){const s=e.querySelectorAll(".sticky-date"),n=e.scrollTop;return Array.from(s).find((e=>{const{offsetTop:s,offsetHeight:a}=e,o=s-n;return-a<=o&&o<=(t?60:10)}))}(e,n);s&&s.classList.add("stuck"),document.body.classList.remove("is-scrolling-messages")}))}))}),[t,s])}}(),he=(0,o.sO)(),ge=(0,o.sO)(),pe=(0,o.I4)((()=>{if(te.current)return void(te.current=!1);he.current=!0;const n=z.current;ee.current||me(n,r),wn((()=>{he.current=!1,(0,C.T2)((()=>{n.parentElement&&(V.current=n.scrollHeight-n.scrollTop,"thread"===s&&H({chatId:e,threadId:t,scrollOffset:V.current}))}))}))}),[me,r,s,H,e,t]);(0,o.d4)((()=>{if(!("ResizeObserver"in window))return;const e=new ResizeObserver((([e])=>{e.target.offsetParent&&re(e.contentRect.height)}));return e.observe(z.current),()=>{e.disconnect()}}),[]);const{height:fe}=it();(0,o.d4)((()=>{I&&(z.current.dataset.normalHeight=String(z.current.offsetHeight))}),[fe,I,f]),(0,o.d4)((()=>{if(!le||!u||k||T)return;if(w&&w[w.length-1]>=a.AE)return;const e=z.current;(!w||w.length<a.hT/2&&e.firstElementChild.clientHeight<=e.offsetHeight)&&le()}),[u,w,le,T,k]),(0,ue.Z)((()=>{if(!w||!W.current)return;const e=W.current.filter((e=>w.includes(Number(e.dataset.messageId)))),t=e[1]||e[0];t&&(Y.current=t.id,K.current=t.getBoundingClientRect().top)}),[w,E,oe,r]),(0,Vt.Z)((([e,t,s])=>{const n=z.current;W.current=Array.from(n.querySelectorAll(".message-list-item"));const o=w&&e&&w[w.length-1]!==e[e.length-1],i=(null==w?void 0:w[0])!==(null==e?void 0:e[0])&&(null==w?void 0:w.length)===a.hT/2+1,c=o&&!i,l=w&&ee.current===w[w.length-1],d=E&&c&&w&&w.length<a.hT/2&&!n.parentElement.classList.contains("force-messages-scroll")&&n.firstElementChild.clientHeight<=2*n.offsetHeight;d&&(n.parentElement.classList.add("force-messages-scroll"),setTimeout((()=>{n.parentElement&&n.parentElement.classList.remove("force-messages-scroll")}),500));const{scrollTop:u,scrollHeight:m,offsetHeight:h}=n,g=V.current,p=W.current[W.current.length-1];let f=g-(s||h);c&&(f-=p?p.offsetHeight:0);const I=E&&t&&f<=20;let v;if(c&&I&&!l&&(p&&(0,C.T2)((()=>{(0,ts.Z)(n,p,"end",20)})),v=m-h,V.current=Math.max(Math.ceil(m-v),h),!d))return;const y=void 0!==s&&s!==oe,Z=Y.current&&n.querySelector(`#${Y.current}`),P=!Z&&J.current&&n.querySelector(".unread-divider");if(I&&y){if((0,ts.N)())return;v=m-h}else Z?(ge.current&&(ge.current=!1,(0,es.z)(n)),v=u+(Z.getBoundingClientRect().top-(K.current||0))):v=P?Math.min(P.offsetTop-(r?60:10),m-g):m-g;(0,es.Z)(n,Math.ceil(v)),ee.current||(te.current=!0,(0,C.T2)((()=>{te.current=!1}))),V.current=Math.max(Math.ceil(m-v),h)}),[w,E,oe,r]),(0,Yt.Z)((([e])=>{void 0!==e&&(0,se.YW)(200+a.fK)}),[N]);const Ie=(0,Ce.Z)(),ve=Boolean(e&&(0,l.YC)(e)),Ze=Boolean(!ve&&!h||v||y),Pe=Boolean(!Ze||h),we=(0,l.YC)(e)&&!v&&!P&&(!ce&&!B&&w&&(!W.current||0===W.current.length)||1===(null==w?void 0:w.length)&&"contactSignUp"===(null==b||null===(U=b[w[0]])||void 0===U||null===($=U.content.action)||void 0===$?void 0:$.type)||"contactSignUp"===(null==B||null===(D=B.content)||void 0===D||null===(q=D.action)||void 0===q?void 0:q.type)),be=p&&Z&&1===(null==w?void 0:w.length)&&"chatCreate"===(null==b||null===(Q=b[w[0]])||void 0===Q||null===(G=Q.content.action)||void 0===G?void 0:G.type),Se=(0,ne.Z)("MessageList custom-scroll",Pe&&"no-avatars",!f&&"no-composer","pinned"===s&&"type-pinned",F&&"with-bottom-shift",N&&"select-mode-active",de&&"scrolled",!I&&"is-animating");return o.ZP.createElement("div",{ref:z,className:Se,onScroll:pe,onMouseDown:Xt.q},k?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,R?R.text:"This is a private "+(h?"channel":"chat"))):A?o.ZP.createElement("div",{className:"empty"},o.ZP.createElement("span",null,(0,Pt.Z)(Ie(A),["br","emoji","links"]))):we?o.ZP.createElement(Pn,{userId:e}):!w||ce&&!be?w&&ce||B?o.ZP.createElement(yn,{chatId:e,messageIds:w||[B.id],messageGroups:ce||Wt([B]),isViewportNewest:Boolean(E),isUnread:Boolean(S),withUsers:Ze,noAvatars:Pe,containerRef:z,anchorIdRef:Y,memoUnreadDividerBeforeIdRef:J,memoFirstUnreadIdRef:X,threadId:t,type:s,isReady:I,isScrollingRef:he,isScrollPatchNeededRef:ge,threadTopMessageId:x,hasLinkedChat:L,isSchedule:!!ce&&"scheduled"===s,noAppearanceAnimation:!ce||!ae.current,onFabToggle:c,onNotchToggle:d}):o.ZP.createElement(qe.Z,{color:"white"}):o.ZP.createElement(Cn,{chatId:e,type:s,isChatWithSelf:v,isGroupChatJustCreated:be}))}))),Sn=(0,o.X$)((0,n.c$)((e=>{const t=(0,i.Bt)(e);if(!t)return{};const{chatId:s,threadId:n,type:a}=t,o=(0,i.Z1)(e,s);return{messageListType:a,unreadCount:o&&n===u._f&&"thread"===a?o.unreadCount:void 0}}))((({isShown:e,canPost:t,messageListType:s,unreadCount:a,withExtraShift:r})=>{const{focusNextReply:i}=(0,n.uC)(),c=(0,Ce.Z)(),l=(0,o.sO)(null),d=(0,o.I4)((()=>{if(e)if("thread"===s)i();else{const e=l.current.parentElement.querySelector(".MessageList"),t=e.querySelectorAll(".message-list-item"),s=t[t.length-1];if(!s)return;(0,ts.Z)(e,s,"end",20)}}),[e,s,i]),u=(0,ne.Z)("ScrollDownButton",e&&"revealed",!t&&"no-composer",r&&"with-extra-shift");return o.ZP.createElement("div",{ref:l,className:u},o.ZP.createElement("div",{className:"ScrollDownButton-inner"},o.ZP.createElement(Ee.Z,{color:"secondary",round:!0,onClick:d,ariaLabel:c("AccDescrPageDown")},o.ZP.createElement("i",{className:"icon-arrow-down"})),Boolean(a)&&o.ZP.createElement("div",{className:"unread-count"},(0,pt.bi)(a))))})));var En=s(5723);const Mn=1280,kn=/\.[^/.]+$/;async function Rn(e,t,s,n){const o=URL.createObjectURL(t),{type:r,size:i}=t;let c,l;if(a.oG.has(r))if(s){const t=await(0,rt.pt)(o),{width:s,height:a}=t;if(s>Mn||a>Mn||"image/jpeg"!==r){const t=await Lt(o,Mn/Math.max(s,a),"image/jpeg");return URL.revokeObjectURL(o),Rn(e,await(0,rt.gm)(t),!0,n)}"image/jpeg"===r&&(e=e.replace(kn,".jpg")),c={width:s,height:a}}else l=o;else if(a.wG.has(r)){const{videoWidth:e,videoHeight:t,duration:s}=await(0,rt.jj)(o);c={width:e,height:t,duration:s},l=await(0,rt.ud)(o)}return{blobUrl:o,filename:e,mimeType:r,size:i,quick:c,previewBlobUrl:l,...n}}var Tn=s(6391);let Nn;function Bn(e){Nn.focus(),e.focus()}h.cj&&(Nn=document.createElement("input"),Nn.classList.add("for-ios-autocapitalization-fix"),document.body.appendChild(Nn));var An=s(4784),xn=s(2400),Ln=s(6389);const On={encoderPath:s.p+"c0155344d336103c2b6a0b28cc510750.js",reuseWorker:!0},Fn={type:"audio/ogg"};let Un,$n,Dn;async function qn(){return Un||(Un=s.e(161).then(s.t.bind(s,1161,23)),$n=(await Un).default,Dn=new $n(On)),Un}async function Qn(e){await async function(){await qn(),await Dn.start()}();const t=Date.now();let s;const n=[],a=[];Dn.ondataavailable=e=>{n.push(e)};const o=function(t,s){const n=t.sourceNode,o=n.context.createAnalyser();o.fftSize=64,n.connect(o);const r=o.frequencyBinCount,i=new Uint8Array(r);let c=!1;return function t(){if(c)return;o.getByteFrequencyData(i);const s=i.reduce(((e,t)=>e+t),0)/r/255;(t=>{a.push(255*t),e(t)})(s<.1?0:s),requestAnimationFrame(t)}(),()=>{c=!0}}(Dn);return{stop:()=>new Promise(((e,r)=>{Dn.onstop=()=>{e({blob:new Blob(n,Fn),duration:Math.round(((s||Date.now())-t)/1e3),waveform:a})},Dn.onerror=r;const i=Math.max(0,t+1e3-Date.now());setTimeout((()=>{Dn.stop(),o()}),i)})),pause:()=>{const e=Math.max(0,t+1e3-Date.now());setTimeout((()=>{Dn.pause(),s=Date.now(),o()}),e)}}}const Gn=["image/png","image/jpeg","image/gif"];function jn(e){const{text:t,entities:s}=e||{};if(!t)return"";const n=(0,rs.H)(t,s,void 0,void 0,!0);return Array.isArray(n)?n.join(""):n}let Hn,_n;var zn=s(3575),Vn=s(9295);const Yn=document.createElement("div"),Kn=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+(.*)/i,Wn=/^@([a-z0-9_]{1,32})[\u00A0\u0020]+\n{2,}/i;const Xn=(0,C.P2)((e=>e()),500,!0),Jn=/^[\w@]{1,32}\s?/i,ea=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"DeleteMessageModal",!t);return s?o.ZP.createElement(s,e):void 0}));function ta(){return(ta=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}let sa,na=!0;const aa=(0,o.X$)((({onActivate:e,...t})=>{const s=(0,o.sO)(!1),n=(0,o.I4)((()=>{if(s.current=!0,na)return na=!1,void e();sa&&(clearTimeout(sa),sa=void 0),sa=window.setTimeout((()=>{s.current&&e()}),200)}),[e]),a=(0,o.I4)((()=>{s.current=!1}),[]);return o.ZP.createElement(Ee.Z,ta({},t,{onMouseEnter:h.$b?void 0:n,onMouseLeave:h.$b?void 0:a,onClick:h.$b?e:void 0}))})),oa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"AttachMenu",!t);return s?o.ZP.createElement(s,e):void 0})),ra=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"SymbolMenu",!t);return s?o.ZP.createElement(s,e):void 0})),ia=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"InlineBotTooltip",!t);return s?o.ZP.createElement(s,e):void 0})),ca=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"MentionTooltip",!t);return s?o.ZP.createElement(s,e):void 0})),la=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"CustomSendMenu",!t);return s?o.ZP.createElement(s,e):void 0})),da=e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"StickerTooltip",!t);return s?o.ZP.createElement(s,e):void 0};var ua=s(9830);const ma=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"BotCommandTooltip",!t);return s?o.ZP.createElement(s,e):void 0}));var ha=s(6503);const ga=(0,o.X$)((0,n.c$)(((e,{messageId:t})=>{const{chatId:s}=(0,i.Bt)(e)||{};return s?{message:(0,i.hj)(e,s,t)}:{}}))((({isOpen:e,message:t,onClose:s})=>{const{clickInlineButton:a}=(0,n.uC)(),[r,i]=(0,ha.Z)(e,s),{isKeyboardSingleUse:c}=t||{},[l,d,u]=(0,ye.Z)(!0),m=()=>{u(),s()};if((0,o.d4)((()=>{d()}),[d,t]),t&&t.keyboardButtons)return o.ZP.createElement(je.Z,{isOpen:e||l,autoClose:c,positionX:"right",positionY:"bottom",onClose:m,className:"BotKeyboardMenu",onCloseAnimationEnd:m,onMouseEnter:h.$b?void 0:r,onMouseLeave:h.$b?void 0:i},o.ZP.createElement("div",{className:"content"},t.keyboardButtons.map((e=>o.ZP.createElement("div",{className:"row"},e.map((e=>o.ZP.createElement(Ee.Z,{ripple:!0,disabled:"NOT_SUPPORTED"===e.type,onClick:()=>a({button:e})},e.text))))))))})));var pa=s(3616),fa=s(7891);const Ia=(0,o.X$)((0,n.c$)((e=>{const{chatId:t,threadId:s,type:n}=(0,i.Bt)(e)||{};if(!t||!s||!n)return{};const{currentUserId:a,forwardMessages:{fromChatId:o,toChatId:r,messageIds:c}}=e,d=(0,i.Yy)(e,t,s),u="scheduled"===n?(0,i.wU)(e,t):(0,i._$)(e,t,s),m=e.settings.byKey.animationLevel>=1,h=r===t;let g,p;if(d?g=(0,i.hj)(e,t,d):u?g=(0,i.kK)(e,t,s,n):h&&1===c.length&&(g=(0,i.hj)(e,o,c[0])),d&&g){const{forwardInfo:s}=g,n=t===a;s&&(s.isChannelPost||n)&&(p=(0,i.cv)(e,g)),p||(p=(0,i.Ur)(e,g))}else h&&(p=(0,l.YC)(o)?(0,i.dy)(e,o):(0,i.Z1)(e,o));return{replyingToId:d,editingId:u,message:g,sender:p,shouldAnimate:m,forwardedMessagesCount:h?c.length:void 0}}))((({replyingToId:e,editingId:t,message:s,sender:a,shouldAnimate:r,forwardedMessagesCount:i})=>{const{setReplyingToId:c,setEditingId:l,focusMessage:d,exitForwardMode:u}=(0,n.uC)(),m=Boolean((e||t)&&s||a&&i),h=(0,fa.Z)([i],i?300:void 0),{shouldRender:g,transitionClassNames:p}=(0,ce.Z)(h&&m,void 0,!r,void 0,!r),f=(0,o.I4)((()=>{e?c({messageId:void 0}):t?l({messageId:void 0}):i&&u()}),[e,t,i,c,l,u]);(0,o.d4)((()=>m?(0,fe.Z)(f):void 0),[m,f]);const I=(0,o.I4)((()=>{d({chatId:s.chatId,messageId:s.id})}),[d,s]),v=(0,ne.Z)("ComposerEmbeddedMessage",p),y=i&&i>1?`${i} forwarded messages`:void 0;if(g)return o.ZP.createElement("div",{className:v},o.ZP.createElement("div",null,o.ZP.createElement(Ee.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Cancel replying",onClick:f},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Zs,{className:"inside-input",message:s,sender:a,customText:y,title:t?"Edit Message":void 0,onClick:I})))}))),va=(0,o.X$)((e=>{const{attachments:t}=e,s=(0,De.Z)($e.gl.Extra,"AttachmentModal",!t.length);return s?o.ZP.createElement(s,e):void 0})),ya=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"BotCommandMenu",!t);return s?o.ZP.createElement(s,e):void 0})),Za=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"PollModal",!t);return s?o.ZP.createElement(s,e):void 0})),Pa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"DropArea",!t);return s?o.ZP.createElement(s,e):void 0})),Ca=new RegExp(a.FM,"i"),wa=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s})=>{const n=(0,i.tV)(e,t,s);return{theme:(0,i.Pu)(e),webPagePreview:e.webPagePreview,noWebPage:n}}))((({chatId:e,threadId:t,messageText:s,disabled:a,webPagePreview:r,noWebPage:i,theme:c})=>{const{loadWebPagePreview:l,clearWebPagePreview:d,toggleMessageWebPage:m}=(0,n.uC)(),h=(0,o.Ye)((()=>{const{text:e,entities:t}=(0,f.Z)(s),n=t&&t.find((({type:e})=>e===u.Vv.TextUrl));if(n)return n.url;const a=e.match(Ca);return a?a[0]:void 0}),[s]);(0,o.d4)((()=>{h?l({text:h}):(d(),m({chatId:e,threadId:t}))}),[e,m,d,h,l,t]),(0,ue.Z)((()=>{d(),m({chatId:e,threadId:t})}),[e]);const g=Boolean(r&&s.length&&!i&&!a),{shouldRender:p,transitionClassNames:I}=(0,ce.Z)(g),v=(0,gt.Z)(r,!0);if(!p||!v)return;const{photo:y,...Z}=v,P={content:{webPage:Z}};return o.ZP.createElement("div",{className:(0,ne.Z)("WebPagePreview",I)},o.ZP.createElement("div",null,o.ZP.createElement(Ee.Z,{round:!0,faded:!0,color:"translucent",ariaLabel:"Clear Webpage Preview",onClick:()=>{m({chatId:e,threadId:t,noWebPage:!0})}},o.ZP.createElement("i",{className:"icon-close"})),o.ZP.createElement(Xs,{message:P,inPreview:!0,theme:c})))})));var ba=s(2898);const Sa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"CalendarModal",!t);return s?o.ZP.createElement(s,e):void 0})),Ea=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"SendAsMenu",!t);return s?o.ZP.createElement(s,e):void 0}));var Ma;!function(e){e.Send="send",e.Record="record",e.Edit="edit"}(Ma||(Ma={}));const ka=(0,o.X$)((0,n.c$)(((e,{chatId:t,threadId:s,messageListType:n})=>{var o,r,c,d;const m=(0,i.Z1)(e,t),h=m&&(0,i.Dg)(e,m),g=t!==a.FV?(0,i.IK)(e,t):void 0,p=Boolean(g),f=(0,i.FM)(e,t),I=p&&(0,i.FT)(e,t),v=(0,i.qy)(e,t),{language:y,shouldSuggestStickers:Z}=e.settings.byKey,P=e.emojiKeywords[a.pR],C=y!==a.pR?e.emojiKeywords[y]:void 0,w=I?I.id:void 0,b=w?(0,i.hj)(e,t,w):void 0,S=e.users.byId,E=e.chats.byId,{currentUserId:M}=e,k=null!=m&&m.fullInfo?(null==m||null===(o=m.fullInfo)||void 0===o?void 0:o.sendAsId)||M:void 0,R=k?null==S?void 0:S[k]:void 0,T=!R&&k?null==E?void 0:E[k]:void 0;return{editingMessage:(0,i.kK)(e,t,s,n),connectionState:e.connectionState,draft:(0,i.Ms)(e,t,s),chat:m,isChatWithBot:p,isChatWithSelf:f,canScheduleUntilOnline:Boolean(!f&&!p&&m&&h&&(0,l.YC)(t)&&(null===(r=(0,i.ss)(e,t))||void 0===r?void 0:r.wasOnline)),isRightColumnShown:(0,i.Jf)(e),isSelectModeActive:(0,i.CA)(e),withScheduledButton:s===u._f&&"thread"===n&&Boolean(null==v?void 0:v.length),shouldSchedule:"scheduled"===n,botKeyboardMessageId:w,botKeyboardPlaceholder:null==b?void 0:b.keyboardPlaceholder,isForwarding:t===e.forwardMessages.toChatId,isPollModalOpen:e.isPollModalOpen,stickersForEmoji:e.stickers.forEmoji.stickers,groupChatMembers:null==m||null===(c=m.fullInfo)||void 0===c?void 0:c.members,topInlineBotIds:null===(d=e.topInlineBots)||void 0===d?void 0:d.userIds,currentUserId:M,usersById:S,lastSyncTime:e.lastSyncTime,contentToBeScheduled:e.messages.contentToBeScheduled,shouldSuggestStickers:Z,recentEmojis:e.recentEmojis,baseEmojiKeywords:null==P?void 0:P.keywords,emojiKeywords:null==C?void 0:C.keywords,serverTimeOffset:e.serverTimeOffset,inlineBots:e.inlineBots.byUsername,isInlineBotLoading:e.inlineBots.isLoading,chatBotCommands:m&&m.fullInfo&&m.fullInfo.botCommands,botCommands:g&&g.fullInfo?g.fullInfo.botCommands||!1:void 0,sendAsUser:R,sendAsChat:T,sendAsId:k}}))((({dropAreaState:e,shouldSchedule:t,canScheduleUntilOnline:s,isReady:r,onDropHide:i,editingMessage:c,chatId:d,threadId:m,messageListType:g,draft:I,chat:v,connectionState:y,isChatWithBot:Z,isChatWithSelf:P,isRightColumnShown:w,isSelectModeActive:b,isForwarding:S,isPollModalOpen:E,botKeyboardMessageId:M,botKeyboardPlaceholder:k,withScheduledButton:R,stickersForEmoji:T,groupChatMembers:B,topInlineBotIds:A,currentUserId:x,usersById:L,lastSyncTime:O,contentToBeScheduled:F,shouldSuggestStickers:U,baseEmojiKeywords:$,emojiKeywords:D,serverTimeOffset:q,recentEmojis:Q,inlineBots:G,isInlineBotLoading:j,botCommands:H,chatBotCommands:_,sendAsUser:z,sendAsChat:V,sendAsId:Y})=>{const{sendMessage:K,clearDraft:W,showDialog:X,setStickerSearchQuery:J,setGifSearchQuery:ee,forwardMessages:te,openPollModal:se,closePollModal:ae,loadScheduledHistory:oe,openChat:re,addRecentEmoji:ce,sendInlineBotResult:me,loadSendAs:he}=(0,n.uC)(),ge=(0,Ce.Z)(),pe=(0,o.sO)(null),[Ie,ve]=(0,o.eJ)(""),Ze=(0,o.sO)(),Pe=(0,lt.Z)(e),[we,be,Se]=(0,ye.Z)(),[Me,ke]=(0,o.eJ)(),{width:Re}=ie.Z.get(),Te=null==v?void 0:v.sendAsIds,Ne=(0,Ln.Z)(d,m),Ae=(0,o.sO)(Ie);(0,o.d4)((()=>{Ae.current=Ie}),[Ie]),(0,o.d4)((()=>{Ze.current=void 0}),[d]),(0,o.d4)((()=>{d&&O&&m===u._f&&r&&oe({chatId:d})}),[r,d,oe,O,m]),(0,o.d4)((()=>{d&&v&&O&&!Te&&r&&(0,l.ZV)(v)&&he({chatId:d})}),[v,d,r,O,he,Te]);const xe=(0,o.sO)(!1);(0,ue.Z)((([e,t])=>{xe.current=Boolean(d===e&&Te&&!t)}),[d,Te]),(0,o.bt)((()=>{pe.current&&(pe.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&&(ke(F),be())}),[F,be]);const[Le,Oe]=(0,o.eJ)([]),[Fe,Ue,$e]=(0,ye.Z)(),[De,qe,Qe]=(0,ye.Z)(),[Ge,je,He]=(0,ye.Z)(),[_e,ze,Ve]=(0,ye.Z)(),[Ye,Ke,We]=(0,ye.Z)(),[Xe,Je,et]=(0,ye.Z)(),[tt,st]=(0,ye.Z)(),[at,ot,rt]=(0,ye.Z)(),{startRecordingVoice:it,stopRecordingVoice:ct,pauseRecordingVoice:dt,activeVoiceRecording:ut,currentRecordTime:mt,recordButtonRef:ht,startRecordTimeRef:gt}=(()=>{const e=(0,o.sO)(null),[t,s]=(0,o.eJ)(),n=(0,o.sO)(),[a,r]=(0,o.eJ)();(0,o.d4)((()=>{h.s$&&h.mh&&qn()}),[]);const i=(0,o.I4)((async()=>{try{const{stop:t,pause:a}=await Qn((t=>{e.current&&(n.current&&Date.now()%4==0&&(e.current.style.boxShadow=`0 0 0 ${50*(t||0)}px rgba(0,0,0,.15)`),r(Date.now()))}));n.current=Date.now(),r(Date.now()),s({stop:t,pause:a})}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){s(void 0),n.current=void 0,r(void 0),e.current&&(e.current.style.boxShadow="none");try{return t.stop()}catch(e){return void console.error(e)}}}),[t]);return(0,o.d4)((()=>t?(0,fe.Z)(l):void 0),[t,l]),{startRecordingVoice:i,pauseRecordingVoice:c,stopRecordingVoice:l,activeVoiceRecording:t,currentRecordTime:a,recordButtonRef:e,startRecordTimeRef:n}})();(function(e,t,s=!1){const n=(0,o.sO)(e);(0,o.bt)((()=>{n.current=e}),[e]),(0,o.d4)((()=>{if(void 0===t)return;const e=setInterval((()=>n.current()),t);return s||n.current(),()=>clearInterval(e)}),[t,s])})((()=>{Ne({type:"recordAudio"})}),ut&&a.o_),(0,o.d4)((()=>{ut||Ne({type:"cancel"})}),[ut,Ne]);const pt=c?Ma.Edit:!h.mh||ut||Ie&&!Le.length||S?Ma.Send:Ma.Record,ft=!t,{isMentionTooltipOpen:It,closeMentionTooltip:vt,insertMention:yt,mentionFilteredUsers:Zt}=(0,Vn.Z)(!Le.length,Ie,ve,void 0,B,A,x),{isOpen:Ct,id:wt,isGallery:bt,switchPm:St,results:Et,closeTooltip:Mt,help:kt,loadMore:Rt}=function(e,t,s,a){const[r,i,c]=(0,ye.Z)(),l=function(e){return Yn.innerHTML=e.replace(/<br>/g,"\n"),Yn.innerText}(s),{queryInlineBot:d,resetInlineBot:u}=(0,n.uC)(),{username:m,query:h,canShowHelp:g}=function(e){const t=e.match(Kn);return t?{username:t[1],query:t[2],canShowHelp:""===t[2]&&!e.match(Wn)}:{username:"",query:"",canShowHelp:!1}}(l),p=m.toLowerCase(),f=(0,lt.Z)(h),I=(0,lt.Z)(m),v=null==a?void 0:a[p],{id:y,switchPm:Z,offset:P,results:C,isGallery:w,help:b}=v||{};(0,o.d4)((()=>{f!==h&&c()}),[f,h,c]),(0,o.d4)((()=>{e&&p&&t&&d({chatId:t,username:p,query:h})}),[h,e,d,t,p]);const S=(0,o.I4)((()=>{d({chatId:t,username:p,query:h,offset:P})}),[P,t,h,d,p]);return(0,o.d4)((()=>{e&&y&&(Z||null!=C&&C.length)?i():c()}),[y,e,i,C,Z,c]),I!==m&&u({username:I}),{isOpen:r,closeTooltip:c,loadMore:S,username:m,id:y,isGallery:w,switchPm:Z,results:C,help:g&&b?`@${m} ${b}`:void 0}}(Boolean(!Le.length&&O),d,Ie,G),{isOpen:Tt,close:Nt,filteredBotCommands:Bt}=function(e,t,s,n){const[a,r,i]=(0,ye.Z)(),[c,l]=(0,o.eJ)(),d=(0,o.I4)((e=>{s||n?Xn((()=>{const t=(s||n||[]).filter((({command:t})=>!e||t.includes(e)));l(t&&t.length?t:void 0)})):l(void 0)}),[s,n]);return(0,o.d4)((()=>{if(e&&t.length)if(t.startsWith("/")){const e=(0,xn._)(t.substr(1)).match(Jn);d(e?e[0]:"")}else i();else i()}),[d,t,e,i]),(0,o.d4)((()=>{c&&c.length?r():i()}),[c,r,i]),{isOpen:a,close:i,filteredBotCommands:c}}(Boolean(H&&H.length||_&&_.length),Ie,H,_),{isContextMenuOpen:At,handleContextMenu:xt,handleContextMenuClose:Lt,handleContextMenuHide:Ot}=(0,os.Z)(ht,!(pt===Ma.Send&&ft)),Ft=(0,o.Ye)((()=>(0,l.H5)(v,Z)),[v,Z]),Ut=v&&(0,l.Nl)(v),$t=(0,l.Hd)(v),{isStickerTooltipOpen:Dt,closeStickerTooltip:qt}=function(e,t,s,a=!1){const r=(0,o.Ye)((()=>(0,xn._)(t).trim()),[t]),{loadStickersForEmoji:i,clearStickersForEmoji:c}=(0,n.uC)(),l=h.op&&1===(0,An.Z)(r)||!h.op&&Boolean(t.match(/^<img.[^>]*?>$/g)),d=Boolean(s)&&l;return(0,o.d4)((()=>{var t;a||(e&&l?i({emoji:h.op?r:null===(t=r.match(/alt="(.+)"/))||void 0===t?void 0:t[1]}):!d&&l||c())}),[t,l,c,i,e,a]),{isStickerTooltipOpen:d,closeStickerTooltip:c}}(Boolean(U&&Ft.canSendStickers&&!Le.length),Ie,T,!r),{isEmojiTooltipOpen:Qt,closeEmojiTooltip:Gt,filteredEmojis:jt,insertEmoji:_t}=(0,zn.Z)(Boolean(U&&Ft.canSendStickers&&!Le.length),Ie,Q,void 0,ve,$,D,!r),zt=(0,o.I4)(((e,t=a.R2)=>{const s=window.getSelection(),n=document.getElementById(t),o=(0,Pt.Z)(e,["escape_html","emoji_html","br_html"]).join("").replace(/\u200b+/g,"");if(s.rangeCount){const e=s.getRangeAt(0);if((0,Tn.R)(e,t))return function(e){const t=window.getSelection();if(null!=t&&t.getRangeAt&&t.rangeCount){const s=t.getRangeAt(0);s.deleteContents();const n=s.createContextualFragment(e),a=n.lastChild;s.insertNode(n),a?(s.setStartAfter(a),s.setEndAfter(a)):s.collapse(!1),t.removeAllRanges(),t.addRange(s)}}(o),void n.dispatchEvent(new Event("input",{bubbles:!0}))}ve(`${Ae.current}${o}`),requestAnimationFrame((()=>{(0,En.Z)(n)}))}),[]),Vt=(0,o.I4)((()=>{const e=window.getSelection();if(e.rangeCount){const t=e.getRangeAt(0);if((0,Tn.R)(t,a.R2))return void document.execCommand("delete",!1)}ve(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 s=t.lastChild;if(s.lastChild)for(;s.lastChild;)s=s.lastChild;const n=s.textContent.length,a=document.createRange(),o=window.getSelection();a.setStart(s,n),a.setEnd(s,n),o.removeAllRanges(),o.addRange(a),document.execCommand("delete",!1);const r=t.innerHTML;return document.body.removeChild(t),r}(Ae.current))}),[]),Yt=(0,o.I4)(((e=!1)=>{e||ve(""),Oe([]),qt(),Se(),ke(void 0),vt(),Gt(),h.wB?setTimeout((()=>Ve()),350):Ve()}),[qt,Se,vt,Gt,Ve]),Kt=(0,o.sO)();Kt.current=ct,(0,o.d4)((()=>()=>{Kt.current(),Yt()}),[d,Yt,Kt]);const Wt=((e,t,s,r,i)=>{const{editMessage:c}=(0,n.uC)();return(0,o.d4)((()=>{s?(t(jn(s.content.text)),requestAnimationFrame((()=>{const e=document.getElementById(a.R2);(0,En.Z)(e,!0)}))):t("")}),[s,t]),(0,o.I4)((()=>{const{text:t,entities:n}=(0,f.Z)(e.current);s&&(t||(0,l.u8)(s)?(c({messageId:s.id,text:t,entities:n}),r()):i())}),[c,s,e,i,r])})(Ae,ve,c,Yt,Je);((e,t,s,r,i,c,l)=>{const{saveDraft:d,clearDraft:u}=(0,n.uC)(),m=(0,o.I4)(((e,t)=>{i.current.length&&!l?d({chatId:e,threadId:t,draft:(0,f.Z)(i.current)}):u({chatId:e,threadId:t})}),[u,l,i,d]),g=(0,o.Ye)((()=>(0,C.Ds)((e=>e()),a.r_,!1)),[t]),p=(0,lt.Z)(t),I=(0,lt.Z)(s);(0,o.d4)((()=>(Hn=t,_n=s,()=>{Hn=void 0,_n=void 0,m(t,s)})),[t,s,m]),(0,o.d4)((()=>{t===p&&s===I||e&&(c(jn(e)),h.$b||requestAnimationFrame((()=>{const e=document.getElementById(a.R2);(0,En.Z)(e,!0)})))}),[t,s,e,c,m,p,I]);const v=(0,lt.Z)(r);(0,o.d4)((()=>{t&&s&&p===t&&I===s&&v!==r&&(r.length?g((()=>{Hn===t&&_n===s&&m(t,s)})):m(t,s))}),[t,r,p,v,I,g,s,m]);const y=(0,o.I4)((()=>{t&&s&&m(t,s)}),[t,s,m]);(0,le.Z)(y),de(y)})(I,d,m,Ie,Ae,ve,c),((e,t,s)=>{(0,o.d4)((()=>{async function n(n){if(!n.clipboardData)return;const o=document.activeElement;if(o&&![a.R2,a.nY].includes(o.id))return;const{items:r}=n.clipboardData,i=Array.from(r).find((e=>Gn.includes(e.type)&&"file"===e.kind)),c=i&&i.getAsFile(),l=n.clipboardData.getData("text").substring(0,4096);if(n.preventDefault(),c||l){if(c&&!s){const e=await Rn(c.name,c,!0);t((t=>[...t,e]))}l&&e(l,null==o?void 0:o.id)}}return document.addEventListener("paste",n,!1),()=>{document.removeEventListener("paste",n,!1)}}),[e,s,t])})(zt,Oe,c);const Xt=(0,o.I4)((async(e,t)=>{Oe(await Promise.all(e.map((e=>Rn(e.name,e,t)))))}),[]),Jt=(0,o.I4)((async(e,t)=>{Oe([...Le,...await Promise.all(e.map((e=>Rn(e.name,e,t))))])}),[Le]),es=(0,o.I4)((()=>{Oe([])}),[]),ts=(0,o.I4)((async(e=!1,t)=>{if("connectionStateReady"!==y)return;let s=Le;if(ut){const e=await ct();if(e){const{blob:t,duration:n,waveform:a}=e;s=[await Rn("wonderful-voice-message.ogg",t,!1,{voice:{duration:n,waveform:a}})]}}const{text:n,entities:o}=(0,f.Z)(Ae.current);if(!s.length&&!n&&!S)return;const r=s.length?1024:4096;if((null==n?void 0:n.length)>r){const e=n.length-r;return void X({data:{message:"MESSAGE_TOO_LONG_PLEASE_REMOVE_CHARACTERS",textParams:{"{EXTRA_CHARS_COUNT}":e,"{PLURAL_S}":e>1?"s":""},hasErrorKey:!0}})}const i=document.getElementById(a.R2);if(s.length||n){if($t&&!Ut){const e=(0,p.b)(q),t=Ze.current&&Math.floor(e-Ze.current),s=$t.nextSendDate&&$t.nextSendDate>e;if(t&&t<$t.seconds||s){const n=s?$t.nextSendDate-e:$t.seconds-t;return X({data:{message:ge("SlowModeHint",(0,N.k9)(n)),isSlowMode:!0,hasErrorKey:!1}}),void i.blur()}}K({text:n,entities:o,attachments:s,scheduledAt:t,isSilent:e})}S&&te({scheduledAt:t,isSilent:e}),Ze.current=(0,p.b)(q),W({chatId:d,localOnly:!0}),h.cj&&i===document.activeElement&&Bn(i),requestAnimationFrame((()=>{Yt()}))}),[y,Le,ut,S,W,d,q,Yt,ct,X,$t,Ut,K,te,ge]),ss=(0,o.I4)((()=>{Ve(),qe()}),[Ve,qe]),ns=(0,o.I4)((()=>{Qe(),We(),ze()}),[Qe,We,ze]),as=(0,o.I4)(((e,s=!1)=>{e={...e,isPreloadedGlobally:!0},t?(ke({sticker:e}),be()):(K({sticker:e}),requestAnimationFrame((()=>{Yt(s)})))}),[t,be,K,Yt]),rs=(0,o.I4)((e=>{t?(ke({gif:e}),be()):(K({gif:e}),requestAnimationFrame((()=>{Yt(!0)})))}),[t,be,K,Yt]),is=(0,o.I4)((e=>{if("connectionStateReady"!==y)return;me({id:e.id,queryId:e.queryId});const t=document.getElementById(a.R2);h.cj&&t===document.activeElement&&Bn(t),W({chatId:d,localOnly:!0}),requestAnimationFrame((()=>{Yt()}))}),[d,W,y,Yt,me]),cs=(0,o.I4)((()=>{W({chatId:d,localOnly:!0}),requestAnimationFrame((()=>{Yt()}))}),[d,W,Yt]),ls=(0,o.I4)((e=>{t?(ke({poll:e}),ae(),be()):(K({poll:e}),ae())}),[ae,be,K,t]),ds=(0,o.I4)((()=>{t?(ke({isSilent:!0}),be()):ts(!0)}),[ts,be,t]),us=(0,o.I4)(((e,t=!1)=>{const{isSilent:s,...n}=Me||{},a=Math.round(Math.max(e.getTime(),Date.now()+6e4)/1e3)+(t?0:q);Me&&0!==Object.keys(n).length?(K({...Me,scheduledAt:a}),requestAnimationFrame((()=>{Yt()}))):ts(!!s,a),Se()}),[Se,ts,Yt,Me,K,q]),ms=(0,o.I4)((()=>{us(new Date(1e3*a.t4),!0)}),[us]),hs=(0,o.I4)((()=>{Se(),ke(void 0)}),[Se]),gs=(0,o.I4)((e=>{"stickers"===e?(J({query:""}),ee({query:void 0})):(ee({query:""}),J({query:void 0}))}),[J,ee]),ps=(0,o.I4)((()=>{const e=document.getElementById(a.R2);h.wB&&e===document.activeElement?(e.blur(),setTimeout((()=>{Qe(),ze()}),100)):ze()}),[ze,Qe]),fs=(0,o.I4)((()=>{const e=document.getElementById(a.R2);if(!h.wB||e!==document.activeElement)return Qe(),Ve(),void Ke();e.blur(),setTimeout((()=>{Qe(),Ve(),Ke()}),100)}),[Qe,Ve,Ke]),Is=(0,o.I4)((()=>{re({id:d,threadId:m,type:"scheduled"})}),[re,d,m]);(0,o.d4)((()=>{w&&h.wB&&Ve()}),[w,Ve]),(0,o.d4)((()=>{r&&(b?ot():setTimeout((()=>{rt()}),200))}),[b,rt,ot,r]);const vs=(0,o.I4)((()=>{switch(pt){case Ma.Send:t?(ut&&dt(),be()):ts();break;case Ma.Record:it();break;case Ma.Edit:Wt()}}),[pt,t,it,Wt,ut,be,dt,ts]),ys=pt===Ma.Record&&!Ft.canAttachMedia,Zs=(0,lt.Z)(c,!0),Ps=c||Zs,Cs=new Date;Cs.setSeconds(0),Cs.setMilliseconds(0);const ws=new Date;ws.setFullYear(ws.getFullYear()+1);let bs="SendMessage";switch(pt){case Ma.Edit:bs="Save edited message";break;case Ma.Record:bs=ys?"Conversation.DefaultRestrictedMedia":"AccDescrVoiceMessage"}const Ss=(0,ne.Z)("Composer",!b&&"shown",at&&"hover-disabled"),Es=(0,ne.Z)("mobile-symbol-menu-button",!r&&"not-ready",tt?_e&&"menu-opened":_e&&"is-loading"),Ms=pt===Ma.Edit?Wt:t?be:ts;return o.ZP.createElement("div",{className:Ss},Ft.canAttachMedia&&r&&o.ZP.createElement(ba.Z,{containerId:"#middle-column-portals"},o.ZP.createElement(Pa,{isOpen:e!==nt.t.None,withQuick:[e,Pe].includes(nt.t.QuickFile),onHide:i,onFileSelect:Xt})),o.ZP.createElement(va,{chatId:d,threadId:m,attachments:Le,caption:Le.length?Ie:"",groupChatMembers:B,currentUserId:x,usersById:L,recentEmojis:Q,isReady:r,onCaptionUpdate:ve,baseEmojiKeywords:$,emojiKeywords:D,addRecentEmoji:ce,onSend:t?be:ts,onFileAppend:Jt,onClear:es}),o.ZP.createElement(Za,{isOpen:Boolean(E),onClear:ae,onSend:ls}),Ps&&o.ZP.createElement(ea,{isOpen:Xe,isSchedule:"scheduled"===g,onClose:et,message:Ps}),o.ZP.createElement(Ea,{isOpen:Ye,onClose:We,chatId:d,selectedSendAsId:Y,sendAsIds:Te}),o.ZP.createElement(ca,{isOpen:It,onClose:vt,onInsertUserName:yt,filteredUsers:Zt,usersById:L}),o.ZP.createElement(ia,{isOpen:Ct,botId:wt,allowedAttachmentOptions:Ft,isGallery:bt,inlineBotResults:Et,switchPm:St,onSelectResult:is,loadMore:Rt,onClose:Mt}),o.ZP.createElement(ma,{isOpen:Tt,withUsername:Boolean(_),botCommands:Bt,onClick:cs,onClose:Nt}),o.ZP.createElement("div",{id:"message-compose"},o.ZP.createElement("div",{className:"svg-appendix",ref:pe}),o.ZP.createElement(Ia,null),o.ZP.createElement(wa,{chatId:d,threadId:m,messageText:Le.length?"":Ie,disabled:!Ft.canAttachEmbedLinks}),o.ZP.createElement("div",{className:"message-input-wrapper"},Z&&!1!==H&&!ut&&!c&&o.ZP.createElement(aa,{className:(0,ne.Z)("bot-commands",De&&"activated"),round:!0,disabled:void 0===H,color:"translucent",onActivate:ss,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-commands-filled"})),!(null==Te||!Te.length)&&(z||V)&&o.ZP.createElement(Ee.Z,{round:!0,color:"translucent",onClick:Ye?We:fs,ariaLabel:ge("SendMessageAsTitle"),className:(0,ne.Z)("send-as-button",xe.current&&"appear-animation")},o.ZP.createElement(Ht.Z,{user:z,chat:V,size:"tiny"})),h.wB?o.ZP.createElement(Ee.Z,{className:Es,round:!0,color:"translucent",onClick:_e?Ve:ps,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"}),o.ZP.createElement("i",{className:"icon-keyboard"}),_e&&!tt&&o.ZP.createElement(Be.Z,{color:"gray"})):o.ZP.createElement(aa,{className:_e?"activated":"",round:!0,color:"translucent",onActivate:ns,ariaLabel:"Choose emoji, sticker or GIF"},o.ZP.createElement("i",{className:"icon-smile"})),o.ZP.createElement(pa.Z,{id:"message-input-text",chatId:d,threadId:m,html:Le.length?"":Ie,placeholder:ut&&Re<=600?"":k||ge("Message"),forcedPlaceholder:kt,canAutoFocus:r&&!Le.length,shouldSuppressFocus:h.wB&&_e,shouldSuppressTextFormatter:Qt||It||Ct,onUpdate:ve,onSend:Ms,onSuppressedFocus:Ve}),j&&Boolean(wt)&&o.ZP.createElement(Be.Z,{color:"gray"}),R&&o.ZP.createElement(Ee.Z,{round:!0,faded:!0,className:"scheduled-button",color:"translucent",onClick:Is,ariaLabel:"Open scheduled messages"},o.ZP.createElement("i",{className:"icon-schedule"})),M&&!ut&&!c&&o.ZP.createElement(aa,{className:Fe?"activated":"",round:!0,color:"translucent",onActivate:Ue,ariaLabel:"Open bot command keyboard"},o.ZP.createElement("i",{className:"icon-bot-command"})),!ut&&!c&&o.ZP.createElement(aa,{className:Ge?"activated":"",round:!0,color:"translucent",onActivate:je,ariaLabel:"Add an attachment"},o.ZP.createElement("i",{className:"icon-attach"})),ut&&mt&&o.ZP.createElement("span",{className:"recording-state"},(0,N.rM)(mt-gt.current)),o.ZP.createElement(da,{chatId:d,threadId:m,isOpen:Dt,onStickerSelect:as}),o.ZP.createElement(ua.Z,{isOpen:Qt,emojis:jt,onClose:Gt,onEmojiSelect:_t,addRecentEmoji:ce}),o.ZP.createElement(oa,{isOpen:Ge,allowedAttachmentOptions:Ft,onFileSelect:Xt,onPollCreate:se,onClose:He}),M&&o.ZP.createElement(ga,{messageId:M,isOpen:Fe,onClose:$e}),H&&o.ZP.createElement(ya,{isOpen:De,botCommands:H,onClose:Qe}),o.ZP.createElement(ra,{chatId:d,threadId:m,isOpen:_e,allowedAttachmentOptions:Ft,onLoad:st,onClose:Ve,onEmojiSelect:zt,onStickerSelect:as,onGifSelect:rs,onRemoveSymbol:Vt,onSearchOpen:gs,addRecentEmoji:ce}))),ut&&o.ZP.createElement(Ee.Z,{round:!0,color:"danger",className:"cancel",onClick:ct,ariaLabel:"Cancel voice recording"},o.ZP.createElement("i",{className:"icon-delete"})),o.ZP.createElement(Ee.Z,{ref:ht,round:!0,color:"secondary",className:(0,ne.Z)(pt,!r&&"not-ready",ut&&"recording"),disabled:ys,ariaLabel:ge(bs),onClick:vs,onContextMenu:pt===Ma.Send&&ft?xt:void 0},o.ZP.createElement("i",{className:"icon-send"}),o.ZP.createElement("i",{className:"icon-microphone-alt"}),o.ZP.createElement("i",{className:"icon-check"})),ft&&o.ZP.createElement(la,{isOpen:At,onSilentSend:P?void 0:ds,onScheduleSend:t?void 0:be,onClose:Lt,onCloseAnimationEnd:Ot}),o.ZP.createElement(Sa,{isOpen:we,withTimePicker:!0,selectedAt:Cs.getTime(),maxAt:(0,N._F)(ws),isFutureMode:!0,secondButtonLabel:s?ge("Schedule.SendWhenOnline"):void 0,onClose:hs,onSubmit:us,onSecondButtonClick:s?ms:void 0}))}))),Ra=(0,o.X$)((e=>{const{isActive:t}=e,s=(0,De.Z)($e.gl.Extra,"MobileSearch",!t,!0);return s?o.ZP.createElement(s,e):void 0})),Ta=(0,o.X$)((e=>{const{isActive:t}=e,s=(0,De.Z)($e.gl.Extra,"MessageSelectToolbar",!t);return s?o.ZP.createElement(s,e):void 0})),Na=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"UnpinAllMessagesModal",!t);return s?o.ZP.createElement(s,e):void 0})),Ba=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"PaymentModal",!t);return s?o.ZP.createElement(s,e):void 0})),Aa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"ReceiptModal",!t);return s?o.ZP.createElement(s,e):void 0})),xa=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"SeenByModal",!t);return s?o.ZP.createElement(s,e):void 0})),La=h.wB?450+a.fK:void 0;function Oa(e){return"file"===e.kind&&e.type&&a.oG.has(e.type)}const Fa=(0,o.X$)((0,n.c$)((e=>{const t=(0,i.Pu)(e),{isBlurred:s,background:n,backgroundColor:a,patternColor:o}=e.settings.themes[t]||{},{messageLists:r}=e.messages,c=(0,i.Bt)(e),{isLeftColumnShown:d,chats:{listIds:m}}=e,g={theme:t,customBackground:n,backgroundColor:a,patternColor:o,isLeftColumnShown:d,isRightColumnShown:(0,i.Jf)(e),isBackgroundBlurred:s,isMobileSearchActive:Boolean(h.wB&&(0,i.n5)(e)),isSelectModeActive:(0,i.CA)(e),isPaymentModalOpen:e.payment.isPaymentModalOpen,isReceiptModalOpen:Boolean(e.payment.receipt),isSeenByModalOpen:Boolean(e.seenByModal),animationLevel:e.settings.byKey.animationLevel,currentTransitionKey:Math.max(0,e.messages.messageLists.length-1)};if(!c||!m.active)return g;const{chatId:p,threadId:f,type:I}=c,v=(0,i.Z1)(e,p),y=(0,i.IK)(e,p),Z=(0,i.KB)(e,p),{chatId:P,messageId:C}=e.audioPlayer,w=v&&(0,l.Qm)(v,f),b=(0,i.pk)(e,p),S="pinned"===I,E="scheduled"===I,M="thread"===I&&f===u._f,k=Boolean(v&&(0,l.eA)(v)),R=Boolean(v&&M&&(k||(0,l.ZV)(v))&&v.isNotJoined),T=Boolean(y&&(0,i.s4)(e,y.id)),N=!T&&b;return{...g,chatId:p,threadId:f,messageListType:I,isPrivate:(0,l.YC)(p),canPost:!S&&(!v||w)&&!b,isPinnedMessageList:S,isScheduledMessageList:E,currentUserBannedRights:null==v?void 0:v.currentUserBannedRights,defaultBannedRights:null==v?void 0:v.defaultBannedRights,hasPinnedOrAudioPlayer:f!==u._f||Boolean(!S&&(null==Z?void 0:Z.length))||Boolean(P&&C),pinnedMessagesCount:Z?Z.length:0,shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,messageLists:r,isChannel:k,canSubscribe:R,canStartBot:N,canRestartBot:T}}))((({chatId:e,threadId:t,messageListType:s,isPrivate:r,isPinnedMessageList:i,messageLists:c,canPost:d,currentUserBannedRights:u,defaultBannedRights:m,hasPinnedOrAudioPlayer:g,pinnedMessagesCount:p,customBackground:f,theme:I,backgroundColor:v,patternColor:y,isLeftColumnShown:Z,isRightColumnShown:P,isBackgroundBlurred:C,isMobileSearchActive:w,isSelectModeActive:b,isPaymentModalOpen:S,isReceiptModalOpen:E,isSeenByModalOpen:M,animationLevel:k,shouldSkipHistoryAnimations:R,currentTransitionKey:T,isChannel:N,canSubscribe:B,canStartBot:A,canRestartBot:x})=>{const{openChat:L,unpinAllMessages:O,loadUser:F,closeLocalTextSearch:U,exitMessageSelectMode:$,closePaymentModal:D,clearReceipt:q,joinChannel:Q,sendBotCommand:G,restartBot:j}=(0,n.uC)(),{width:H}=it(),_=(0,Ce.Z)(),[z,V]=(0,o.eJ)(nt.t.None),[Y,K]=(0,o.eJ)(),[W,X]=(0,o.eJ)(),[J,ee]=(0,o.eJ)(!1),te=g&&(H<a.l3||P&&H>a._m&&H<a.QU||H>=a.ks&&H<a.jT),se=(0,ct.Z)(e,La),ae=(0,ct.Z)(t,La),oe=(0,ct.Z)(s,La),re=(0,ct.Z)(B,La),ie=(0,ct.Z)(A,La),ce=(0,ct.Z)(x,La),le=(0,ct.Z)(d,La)&&!ce&&!ie&&!re,de=(0,ct.Z)(te,La),me=(0,ct.Z)(Y,La),he=(0,ct.Z)(N,La),ge=(0,lt.Z)(T),Ie=void 0!==ge&&ge<T?ge:void 0,{isReady:ve,handleOpenEnd:ye,handleSlideStop:Pe}=function(e,t,s,n){const[r,i]=(0,o.eJ)(!h.wB),c=(0,dt.Z)(),l=void 0!==s&&s!==t;return l&&(e!==a.oB?i(!1):c()),(0,ue.Z)((()=>{e===a.oB&&i(!0)}),[e]),{isReady:r&&!l,handleOpenEnd:e!==a.oB?function(e){"transform"===e.propertyName&&e.target===e.currentTarget&&i(Boolean(n))}:void 0,handleSlideStop:e!==a.oB?function(){i(!0)}:void 0}}(k,T,ge,e);(0,o.d4)((()=>e?(0,fe.Z)((()=>{L({id:void 0})})):void 0),[e,L]),(0,ue.Z)((()=>{V(nt.t.None),K(void 0),X(void 0)}),[e]),(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&&F({userId:e})}),[e,r,F]);const we=(0,o.I4)((e=>{if(h.$b)return;const{items:t}=e.dataTransfer||{},s=t&&Array.from(t).filter((e=>"text/uri-list"!==e.type)).every(Oa);V(s?nt.t.QuickFile:nt.t.Document)}),[]),be=(0,o.I4)((()=>{V(nt.t.None)}),[]),Se=(0,o.I4)((()=>{ee(!0)}),[]),Me=(0,o.I4)((()=>{ee(!1)}),[]),ke=(0,o.I4)((()=>{O({chatId:e}),Me(),L({id:e})}),[O,L,Me,e]),Re=(0,o.I4)((()=>{L({id:e})}),[L,e]),Te=(0,o.I4)((()=>{Q({chatId:e})}),[Q,e]),Ne=(0,o.I4)((()=>{G({command:"/start"})}),[G]),Be=(0,o.I4)((()=>{j({chatId:e})}),[e,j]),Ae=((e,t)=>{const[s,n]=(0,o.eJ)(t);return(0,o.d4)((()=>{t&&(t.startsWith("#")?n(t):ot.fetch(a.fo,e,ot.Type.Blob).then((e=>{const t=URL.createObjectURL(e);(0,rt.pt)(t).then((()=>{n(`url(${t})`)}))})))}),[t,e]),t?s:void 0})(I,f),xe=(0,ne.Z)(de&&"has-header-tools",f&&"custom-bg-image",v&&"custom-bg-color",f&&C&&"blurred",h.aZ?"mask-image-disabled":"mask-image-enabled"),Le=(0,ne.Z)("messaging-disabled",!b&&"shown"),Oe=(0,l.q8)(_,u,m),{composerHiddenScale:Fe,toolbarHiddenScale:Ue,composerTranslateX:$e,toolbarTranslateX:De,unpinHiddenScale:qe,toolbarForUnpinHiddenScale:Qe}=(0,o.Ye)((()=>function(e,t){const s=e<=a.l3?16:32,n=function(e){if(e>a._m){const t=Math.min(Math.max(.25*e,288),424),s=Math.min(.25*e,424);return Math.min(e-t-s,ut)}if(e>a.ks){const t=Math.min(Math.max(.4*e,288),424);return Math.min(e-t,ut)}return e>ut?ut:e}(e),o=e<=a.l3?54:64,r=t?n-s-o:n-s,i=e>a.l3?Math.min(n-s,512):n-s,c=i/r,l=r/i;return{composerHiddenScale:c,toolbarHiddenScale:l,composerTranslateX:t?o/2*l:0,toolbarTranslateX:t?o/2*-1*c:0,unpinHiddenScale:i/258,toolbarForUnpinHiddenScale:258/i}}(H,le)),[le,H]),Ge=(0,ne.Z)("middle-column-footer",!le&&"no-composer",le&&W&&!b&&"with-notch");(0,pe.ZP)(se&&ae,(()=>{L({id:void 0},{forceSyncOnIOs:!0})}),void 0,void 0,void 0,(null==c?void 0:c.map(at.q))||[]),(0,pe.ZP)(w,U),(0,pe.ZP)(b,$);const je=Boolean(!i&&!le&&Oe),He=Boolean(ce||re||ie||i),_e=Boolean(je||b||i);return o.ZP.createElement("div",{id:"MiddleColumn",className:xe,onTransitionEnd:ye,style:`\n --composer-hidden-scale: ${Fe};\n --toolbar-hidden-scale: ${Ue};\n --unpin-hidden-scale: ${qe};\n --toolbar-unpin-hidden-scale: ${Qe};\n --composer-translate-x: ${$e}px;\n --toolbar-translate-x: ${De}px;\n --pattern-color: ${y};\n --theme-background-color:\n ${v||("dark"===I?a.It:a.p3)};\n `,onClick:h.p7&&Z?Re:void 0},o.ZP.createElement("div",{id:"middle-column-bg",style:Ae?`--custom-background: ${Ae}`:void 0}),o.ZP.createElement("div",{id:"middle-column-portals"}),se&&ae&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("div",{className:"messages-layout",onDragEnter:le?we:void 0},o.ZP.createElement(zt,{chatId:se,threadId:ae,messageListType:oe,isReady:ve}),o.ZP.createElement(Ze.Z,{name:R?"none":k===a.zy?"slide":"fade",activeKey:T,shouldCleanup:!0,cleanupExceptionKey:Ie,onStop:Pe},(()=>o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(bn,{key:`${se}-${ae}-${oe}`,chatId:se,threadId:ae,type:oe,canPost:le,hasTools:de,onFabToggle:K,onNotchToggle:X,isReady:ve,withBottomShift:He}),o.ZP.createElement("div",{className:Ge},le&&o.ZP.createElement(ka,{chatId:se,threadId:ae,messageListType:oe,dropAreaState:z,onDropHide:be,isReady:ve}),i&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:_.isRtl?"rtl":void 0},o.ZP.createElement(Ee.Z,{size:"tiny",fluid:!0,color:"secondary",className:"unpin-all-button",onClick:Se},o.ZP.createElement("i",{className:"icon-unpin"}),o.ZP.createElement("span",null,_("Chat.Pinned.UnpinAll",p,"i")))),je&&o.ZP.createElement("div",{className:Le},o.ZP.createElement("div",{className:"messaging-disabled-inner"},o.ZP.createElement("span",null,Oe))),h.wB&&re&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:_.isRtl?"rtl":void 0},o.ZP.createElement(Ee.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Te},_(he?"ProfileJoinChannel":"ProfileJoinGroup"))),h.wB&&ie&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:_.isRtl?"rtl":void 0},o.ZP.createElement(Ee.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Ne},_("BotStart"))),h.wB&&ce&&o.ZP.createElement("div",{className:"middle-column-footer-button-container",dir:_.isRtl?"rtl":void 0},o.ZP.createElement(Ee.Z,{size:"tiny",fluid:!0,ripple:!0,className:"join-subscribe-button",onClick:Be},_("BotRestart"))),o.ZP.createElement(Ta,{messageListType:oe,isActive:b,canPost:le}),o.ZP.createElement(Ba,{isOpen:Boolean(S),onClose:D}),o.ZP.createElement(Aa,{isOpen:Boolean(E),onClose:q}),o.ZP.createElement(xa,{isOpen:M}))))),o.ZP.createElement(Sn,{isShown:me,canPost:le,withExtraShift:_e})),h.wB&&o.ZP.createElement(Ra,{isActive:Boolean(w)})),e&&o.ZP.createElement(Na,{isOpen:J,chatId:e,pinnedMessagesCount:p,onClose:Me,onUnpin:ke}))}))),Ua=(0,C.Ds)((e=>e()),200,!1);var $a;!function(e){e[e.Profile=0]="Profile",e[e.MemberList=1]="MemberList",e[e.SharedMedia=2]="SharedMedia",e[e.Search=3]="Search",e[e.Management=4]="Management",e[e.ManageInitial=5]="ManageInitial",e[e.ManageChannelSubscribers=6]="ManageChannelSubscribers",e[e.ManageChatAdministrators=7]="ManageChatAdministrators",e[e.ManageChatPrivacyType=8]="ManageChatPrivacyType",e[e.ManageDiscussion=9]="ManageDiscussion",e[e.ManageGroupPermissions=10]="ManageGroupPermissions",e[e.ManageGroupRemovedUsers=11]="ManageGroupRemovedUsers",e[e.ManageGroupUserPermissionsCreate=12]="ManageGroupUserPermissionsCreate",e[e.ManageGroupUserPermissions=13]="ManageGroupUserPermissions",e[e.ManageGroupRecentActions=14]="ManageGroupRecentActions",e[e.ManageGroupAdminRights=15]="ManageGroupAdminRights",e[e.ManageGroupMembers=16]="ManageGroupMembers",e[e.StickerSearch=17]="StickerSearch",e[e.GifSearch=18]="GifSearch",e[e.PollResults=19]="PollResults",e[e.AddingMembers=20]="AddingMembers"}($a||($a={}));const Da=(0,o.X$)((0,n.c$)(((e,{chatId:t,isProfile:s,isManagement:n})=>{const{query:a}=(0,i.n5)(e)||{},{query:o}=(0,i.y5)(e)||{},{query:r}=(0,i.yN)(e)||{},c=t?(0,i.Z1)(e,t):void 0,d=c&&(0,l.eA)(c),u=s&&t&&(0,l.YC)(t)?(0,i.dy)(e,t):void 0,m=u&&(0,l.kw)(u);return{canManage:Boolean(!n&&s&&!m&&c&&!(0,i.FM)(e,c.id)&&((0,l.YC)(c.id)||((0,l.Nl)(c)||c.isCreator)&&!c.isNotJoined)),canAddContact:m,isChannel:d,userId:null==u?void 0:u.id,messageSearchQuery:a,stickerSearchQuery:o,gifSearchQuery:r}}))((({isColumnOpen:e,isProfile:t,isSearch:s,isManagement:a,isStickerSearch:r,isGifSearch:i,isPollResults:c,isAddingChatMembers:l,profileState:d,managementScreen:u,canAddContact:g,userId:p,canManage:f,isChannel:I,onClose:v,messageSearchQuery:y,stickerSearchQuery:Z,gifSearchQuery:P,shouldSkipAnimation:C})=>{var w;const{setLocalTextSearchQuery:b,setStickerSearchQuery:S,setGifSearchQuery:E,searchTextMessagesLocal:M,toggleManagement:k,openHistoryCalendar:R,addContact:T}=(0,n.uC)(),B=(0,o.sO)(null),A=(0,o.I4)((e=>{b({query:e}),e.length&&Ua(M)}),[M,b]),x=(0,o.I4)((e=>{S({query:e})}),[S]),L=(0,o.I4)((e=>{E({query:e})}),[E]),O=(0,o.I4)((()=>{T({userId:p})}),[T,p]),[F,U]=(0,o.eJ)(!e);(0,o.d4)((()=>{setTimeout((()=>{U(!e)}),300)}),[e]);const $=(0,Ce.Z)(),D=t?d===m.vi.Profile?$a.Profile:d===m.vi.SharedMedia?$a.SharedMedia:d===m.vi.MemberList?$a.MemberList:-1:s?$a.Search:c?$a.PollResults:r?$a.StickerSearch:i?$a.GifSearch:l?$a.AddingMembers:a?u===m.u1.Initial?$a.ManageInitial:u===m.u1.ChatPrivacyType?$a.ManageChatPrivacyType:u===m.u1.Discussion?$a.ManageDiscussion:u===m.u1.ChannelSubscribers?$a.ManageChannelSubscribers:u===m.u1.GroupPermissions?$a.ManageGroupPermissions:u===m.u1.ChatAdministrators?$a.ManageChatAdministrators:u===m.u1.GroupRemovedUsers?$a.ManageGroupRemovedUsers:u===m.u1.GroupUserPermissionsCreate?$a.ManageGroupUserPermissionsCreate:u===m.u1.GroupUserPermissions?$a.ManageGroupUserPermissions:u===m.u1.GroupRecentActions?$a.ManageGroupRecentActions:u===m.u1.ChatAdminRights?$a.ManageGroupAdminRights:u===m.u1.GroupMembers?$a.ManageGroupMembers:void 0:void 0,q=null!==(w=(0,gt.Z)(D,!0))&&void 0!==w?w:-1;function Q(){if(-1!==q)switch(q){case $a.PollResults:return o.ZP.createElement("h3",null,$("PollResults"));case $a.Search:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Me.Z,{parentContainerClassName:"RightSearch",value:y,onChange:A}),o.ZP.createElement(Ee.Z,{round:!0,size:"smaller",color:"translucent",onClick:()=>R({selectedAt:(0,N._F)(Date.now())}),ariaLabel:"Search messages by date"},o.ZP.createElement("i",{className:"icon-calendar"})));case $a.AddingMembers:return o.ZP.createElement("h3",null,$("GroupAddMembers"));case $a.ManageInitial:return o.ZP.createElement("h3",null,$("Edit"));case $a.ManageChatPrivacyType:return o.ZP.createElement("h3",null,$(I?"ChannelTypeHeader":"GroupTypeHeader"));case $a.ManageDiscussion:return o.ZP.createElement("h3",null,$("Discussion"));case $a.ManageChatAdministrators:return o.ZP.createElement("h3",null,$("ChannelAdministrators"));case $a.ManageGroupRecentActions:return o.ZP.createElement("h3",null,$("Group.Info.AdminLog"));case $a.ManageGroupAdminRights:return o.ZP.createElement("h3",null,$("EditAdminRights"));case $a.ManageGroupPermissions:return o.ZP.createElement("h3",null,$("ChannelPermissions"));case $a.ManageGroupRemovedUsers:return o.ZP.createElement("h3",null,$("ChannelBlockedUsers"));case $a.ManageGroupUserPermissionsCreate:return o.ZP.createElement("h3",null,$("ChannelAddException"));case $a.ManageGroupUserPermissions:return o.ZP.createElement("h3",null,$("UserRestrictions"));case $a.StickerSearch:return o.ZP.createElement(Me.Z,{value:Z,placeholder:$("SearchStickersHint"),autoFocusSearch:!0,onChange:x});case $a.GifSearch:return o.ZP.createElement(Me.Z,{value:P,placeholder:$("SearchGifsTitle"),autoFocusSearch:!0,onChange:L});case $a.SharedMedia:return o.ZP.createElement("h3",null,$("SharedMedia"));case $a.ManageChannelSubscribers:return o.ZP.createElement("h3",null,$("ChannelSubscribers"));case $a.MemberList:case $a.ManageGroupMembers:return o.ZP.createElement("h3",null,$("GroupMembers"));default:return o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement("h3",null,"Profile"),o.ZP.createElement("section",{className:"tools"},g&&o.ZP.createElement(Ee.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:$("AddContact"),onClick:O},o.ZP.createElement("i",{className:"icon-add-user"})),f&&o.ZP.createElement(Ee.Z,{round:!0,color:"translucent",size:"smaller",ariaLabel:$("Edit"),onClick:k},o.ZP.createElement("i",{className:"icon-edit"}))))}}const G=h.wB||D===$a.SharedMedia||D===$a.MemberList||D===$a.AddingMembers||a,j=(0,ne.Z)("animated-close-icon",G&&"state-back",(F||C)&&"no-transition");return o.ZP.createElement("div",{className:"RightHeader"},o.ZP.createElement(Ee.Z,{className:"close-button",round:!0,color:"translucent",size:"smaller",onClick:v,ariaLabel:$(G?"Common.Back":"Common.Close")},o.ZP.createElement("div",{ref:B,className:j})),o.ZP.createElement(Ze.Z,{name:F||C?"none":"slide-fade",activeKey:q},Q))})));var qa=s(91),Qa=s(7407);function Ga(e,t,s,n){const[o,r]=(0,Qa.Z)(s?t:void 0,n,void 0,a.Vk);return[o,r,!(!o||!n||o[0]===n[0])]}function ja(e,t,s,n,r,i){const c=(0,o.sO)();(0,ue.Z)((()=>{t===e&&r&&i&&(c.current=(0,l.R5)(r,i,e).reverse())}),[r,i,t,e]);const[d,u]=(0,Qa.Z)(n?s:void 0,c.current,void 0,"media"===e?a.EN:a.pn);return[d,u,!(!d||!c.current||d[0]===c.current[0])]}const Ha=(0,C.P2)((e=>e()),250,!1);let _a=!1;var za=s(1273),Va=s(1876),Ya=s(787),Ka=s(180),Wa=s(3709),Xa=s(5418),Ja=s(7262),eo=s(1151),to=s(2275);const so=[{type:"media",title:"SharedMediaTab2"},{type:"documents",title:"SharedFilesTab2"},{type:"links",title:"SharedLinksTab2"},{type:"audio",title:"SharedMusicTab2"},{type:"voice",title:"SharedVoiceTab2"}];function no(e){return[`.shared-media-transition > div:only-child > .${e}-list > .scroll-item`,`.shared-media-transition > .Transition__slide--active > .${e}-list > .scroll-item`].join(", ")}const ao=(0,o.X$)((0,n.c$)(((e,{chatId:t,userId:s})=>{var n,a;const o=(0,i.Z1)(e,t),r=(0,i.Zw)(e,s||t),{currentType:c,resultsByType:d}=(0,i.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),I=p||f&&(0,l.Nl)(o),v=null==o||null===(n=o.fullInfo)||void 0===n?void 0:n.members,y=I&&o&&o.fullInfo&&!o.fullInfo.canViewMembers,Z=I&&o&&((0,l.VE)(o,"inviteUsers")||o.isCreator),P=I&&o&&((0,l.VE)(o,"banUsers")||o.isCreator),C=(0,i.xs)(e,t);let w,b,S;return s?b=s:(0,l.YC)(t)&&(b=t),b&&(S=(0,i.dy)(e,b),w=S&&!S.isSelf&&!(0,l.cS)(S)),{theme:(0,i.Pu)(e),isChannel:f,resolvedUserId:b,chatMessages:r,foundIds:u,mediaSearchType:c,hasCommonChatsTab:w,hasMembersTab:I,areMembersHidden:y,canAddMembers:Z,canDeleteMembers:P,currentUserId:e.currentUserId,isRightColumnShown:(0,i.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,...I&&v&&{members:v},...w&&S&&{commonChatIds:null===(a=S.commonChats)||void 0===a?void 0:a.ids}}}))((({chatId:e,profileState:t,onProfileStateChange:s,theme:r,isChannel:i,resolvedUserId:c,currentUserId:d,chatMessages:g,foundIds:p,mediaSearchType:f,hasCommonChatsTab:I,hasMembersTab:v,areMembersHidden:y,canAddMembers:Z,canDeleteMembers:P,commonChatIds:C,members:w,usersById:b,userStatusesById:S,chatsById:E,isRightColumnShown:M,isRestricted:k,lastSyncTime:R,activeDownloadIds:T,serverTimeOffset:N,isChatProtected:B})=>{const{setLocalMediaSearchType:A,loadMoreMembers:x,loadCommonChats:L,openChat:O,searchMediaMessagesLocal:F,openMediaViewer:U,openAudioPlayer:$,openUserInfo:D,focusMessage:q,loadProfilePhotos:Q,setNewChatMembersDialogState:G}=(0,n.uC)(),j=(0,o.sO)(null),H=(0,o.sO)(null),_=(0,Ce.Z)(),[z,V]=(0,o.eJ)(0),[Y,K]=(0,o.eJ)(),W=(0,o.Ye)((()=>[...v?[{type:"members",title:i?"ChannelSubscribers":"GroupMembers"}]:[],...so,...I?[{type:"commonChats",title:"SharedGroupsTab2"}]:[]]),[I,v,i]),X=W[z].type,[J,ee,te,se]=function(e,t,s,n,a,r,i,c,d,u,m,h,g,p,f,I=0){const v="members"!==a&&r?r:a,y=(0,o.Ye)((()=>{if(i&&d&&u)return(0,l.Z0)(i.map((({userId:e})=>e)),d,u,void 0,I)}),[i,I,d,u]),Z=(0,o.Ye)((()=>{if(c&&m)return(0,l.ih)(c,m,!0)}),[m,c]),[P,C,w]=Ga(0,t,f,y),[b,S,E]=ja("media",v,n,f,h,g),[M,k,R]=ja("documents",v,n,f,h,g),[T,N,B]=ja("links",v,n,f,h,g),[A,x,L]=ja("audio",v,n,f,h,g),[O,F,U]=ja("voice",v,n,f,h,g),[$,D,q]=Ga(0,s,f,Z);let Q,G,j=!1;switch(v){case"members":Q=P,G=C,j=w;break;case"commonChats":Q=$,G=D,j=q;break;case"media":Q=b,G=S,j=E;break;case"documents":Q=M,G=k,j=R;break;case"links":Q=T,G=N,j=B;break;case"audio":Q=A,G=x,j=L;break;case"voice":Q=O,G=F,j=U}return[v,Q,G,j]}(0,x,L,F,X,f,w,C,b,S,E,g,p,0,R,N),ne=W.findIndex((({type:e})=>e===J)),{handleScroll:ae}=function(e,t,s,n){(0,Yt.Z)((([s])=>{if(s&&s!==t){const s=e.current,a=s.querySelector(".TabList");s.scrollTop<a.offsetTop&&(n("members"===t?m.vi.MemberList:m.vi.SharedMedia),_a=!0,(0,ts.Z)(s,a,"start",void 0,void 0,void 0,300),setTimeout((()=>{_a=!1}),350))}}),[t,n]),(0,Yt.Z)((([t])=>{if(s!==m.vi.Profile||s===t)return;const a=e.current;if(!a)return;const o=a.querySelector(".TabList");!o||o.offsetTop>a.scrollTop||(_a=!0,(0,ts.Z)(a,a.firstElementChild,"start",void 0,2*a.offsetHeight),setTimeout((()=>{_a=!1}),350),n(s))}),[s]);const a=(0,o.I4)((()=>{const s=e.current;if(!s)return;const a=s.querySelector(".TabList");if(!a)return;let o=m.vi.Profile;s.scrollTop>=a.offsetTop&&(o="members"===t?m.vi.MemberList:m.vi.SharedMedia),n(o)}),[e,n,t]);return(0,o.d4)((()=>{_a||a()}),[a,t]),{handleScroll:(0,o.I4)((()=>{_a||Ha(a)}),[a])}}(j,X,t,s),{applyTransitionFix:oe,releaseTransitionFix:re}=function(e,t=".Transition.shared-media-transition"){return(0,o.d4)((()=>{function s(){const s=e.current,n=s.querySelector(t),a=s.querySelector(".TabList");n&&a&&(n.style.minHeight=s.offsetHeight-a.offsetHeight+"px")}return s(),window.addEventListener("resize",s,!1),()=>{window.removeEventListener("resize",s,!1)}}),[e,t]),{applyTransitionFix:(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]),releaseTransitionFix:(0,o.I4)((()=>{const t=e.current;t.style.overflowY="scroll",t.style.marginRight="0"}),[e])}}(j),[ie,ce]=(()=>{const[e,t]=(0,o.eJ)(!1);return[e,(0,o.I4)((()=>{t((e=>!e))}),[])]})(),le=(0,o.I4)((()=>{re(),ce()}),[re,ce]),de=(0,o.I4)((()=>{G(m.WB.InProgress)}),[G]);(0,o.d4)((()=>{A({mediaType:X})}),[A,X]);const ue=c||e;(0,o.d4)((()=>{R&&Q({profileId:ue})}),[Q,ue,R]);const me=(0,o.I4)((e=>{U({chatId:ue,threadId:u._f,messageId:e,origin:m.bZ.SharedMedia})}),[ue,U]),he=(0,o.I4)((e=>{$({chatId:ue,messageId:e})}),[ue,$]),ge=(0,o.I4)((e=>{D({id:e})}),[D]),pe=(0,o.I4)((e=>{q({chatId:ue,messageId:e})}),[ue,q]),fe=(0,o.I4)((()=>{K(void 0)}),[]);let Ie;(0,o.d4)((()=>{if(H.current&&h.$b)return(0,xe.s)(H.current,{selectorToPreventScroll:".Profile",onSwipe:(e,t)=>t===xe.e.Left?(V(Math.min(z+1,W.length-1)),!0):t===xe.e.Right&&(V(Math.max(0,z-1)),!0)})}),[z,W.length]);const ve="members"===J||!v&&"media"===J;ve?Ie=M?0:1e3:ee||(Ie=a.Y);const ye=(0,fa.Z)([e,J],Ie);function Pe(){if(!ee||!ye||!g){const e=ve&&ee&&!ye;return o.ZP.createElement("div",{className:"content empty-list"},!e&&o.ZP.createElement(Be.Z,null))}if(!ee.length){let e;switch(J){case"members":e=y?"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(Ja.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=>g[e]&&o.ZP.createElement(Wa.Z,{key:e,message:g[e],isProtected:B||g[e].isProtected,onClick:me}))):"documents"===J?ee.map((e=>g[e]&&o.ZP.createElement(Ps.Z,{key:e,message:g[e],withDate:!0,smaller:!0,className:"scroll-item",onDateClick:pe,isDownloading:T.includes(e)}))):"links"===J?ee.map((e=>g[e]&&o.ZP.createElement(Xa.Z,{key:e,message:g[e],isProtected:B||g[e].isProtected,onMessageClick:pe}))):"audio"===J?ee.map((e=>g[e]&&o.ZP.createElement(Cs.Z,{key:e,theme:r,message:g[e],origin:m.Cr.SharedMedia,date:g[e].date,lastSyncTime:R,className:"scroll-item",onPlay:he,onDateClick:pe,isDownloading:T.includes(e)}))):"voice"===J?ee.map((e=>g[e]&&o.ZP.createElement(Cs.Z,{key:e,theme:r,message:g[e],senderTitle:(0,qa.F)(_,g[e],E,b),origin:m.Cr.SharedMedia,date:g[e].date,lastSyncTime:R,className:"scroll-item",onPlay:he,onDateClick:pe,isDownloading:T.includes(e)}))):"members"===J?ee.map(((e,t)=>{return o.ZP.createElement(Va.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>ge(e),contextActions:(s=e,s!==d&&P?[{title:_("lng_context_remove_from_group"),icon:"stop",handler:()=>{K(s)}}]:void 0)},o.ZP.createElement(ft.Z,{userId:e,forceShowSelf:!0}));var s})):"commonChats"===J?ee.map(((e,t)=>o.ZP.createElement(Va.Z,{key:e,teactOrderKey:t,className:"chat-item-clickable scroll-item small-icon",onClick:()=>O({id:e})},o.ZP.createElement(It.Z,{chatId:e})))):void 0)}return o.ZP.createElement(za.Z,{ref:j,className:"Profile custom-scroll",itemSelector:no(J),items:ye?ee:void 0,cacheBuster:ie,sensitiveArea:a.qU,preloadBackwards:ye?"members"===J?a.Vk:a.EN:0,noScrollRestoreOnTop:!0,noFastList:!0,onLoadMore:te,onScroll:ae},!se&&function(e,t){return o.ZP.createElement("div",{className:"profile-info"},o.ZP.createElement(Ya.Z,{userId:t||e}),o.ZP.createElement(Ka.Z,{chatOrUserId:t||e}))}(e,c),!k&&o.ZP.createElement("div",{className:"shared-media"},o.ZP.createElement(Ze.Z,{ref:H,name:_.isRtl?"slide-optimized-rtl":"slide-optimized",activeKey:ne,renderCount:W.length,shouldRestoreHeight:!0,className:"shared-media-transition",onStart:oe,onStop:le},Pe),o.ZP.createElement(Oe.Z,{big:!0,activeTab:z,tabs:W,onSwitchTab:V})),Z&&o.ZP.createElement(eo.Z,{isShown:"members"===J,onClick:de,ariaLabel:_("lng_channel_add_users")},o.ZP.createElement("i",{className:"icon-add-user-filled"})),P&&o.ZP.createElement(to.Z,{isOpen:Boolean(Y),userId:Y,onClose:fe}))}))),oo=(0,o.X$)((e=>{const t=(0,De.Z)($e.gl.Extra,"RightSearch");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),ro=(0,o.X$)((e=>{const t=(0,De.Z)($e.gl.Extra,"Management");return t?o.ZP.createElement(t,e):o.ZP.createElement(qe.Z,null)})),io=(0,o.X$)((()=>{const e=(0,De.Z)($e.gl.Extra,"StickerSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(qe.Z,null)})),co=(0,o.X$)((()=>{const e=(0,De.Z)($e.gl.Extra,"GifSearch");return e?o.ZP.createElement(e,null):o.ZP.createElement(qe.Z,null)})),lo=(0,o.X$)((()=>{const e=(0,De.Z)($e.gl.Extra,"PollResults");return e?o.ZP.createElement(e,null):o.ZP.createElement(qe.Z,null)}));var uo=s(1820);const mo=(0,o.X$)((0,n.c$)(((e,{chatId:t})=>{var s;const n=(0,i.Z1)(e,t),{userIds:a}=e.contactList||{},{byId:o}=e.chats,{currentUserId:r,newChatMembersProgress:c,connectionState:d}=e,u=n&&(0,l.eA)(n),{query:h,fetchingStatus:g,globalUserIds:p,localUserIds:f}=e.userSearch;return{isChannel:u,members:null==n||null===(s=n.fullInfo)||void 0===s?void 0:s.members,currentUserId:r,chatsById:o,localContactIds:a,searchQuery:h,isSearching:g,isLoading:c===m.WB.Loading,globalUserIds:p,localUserIds:f,connectionState:d}}))((({isChannel:e,connectionState:t,members:s,onNextStep:a,currentUserId:r,chatsById:i,localContactIds:c,isLoading:d,searchQuery:u,isSearching:m,localUserIds:h,globalUserIds:p,onClose:f,isActive:I})=>{const{setUserSearchQuery:v,loadContactList:y}=(0,n.uC)(),Z=(0,Ce.Z)(),[P,C]=(0,o.eJ)([]),w=(0,lt.Z)(P)===P;(0,o.d4)((()=>{I&&"connectionStateReady"===t&&y()}),[t,I,y]),(0,pe.ZP)(I,f);const b=(0,o.Ye)((()=>s?s.map((e=>e.userId)):[]),[s]),S=(0,o.I4)((e=>{v({query:e})}),[v]),E=(0,o.Ye)((()=>{const t=(0,n.Rd)().users.byId,s=c?(0,l.kK)(c,t,u):[];return(0,l.ih)((0,g.Tw)([...s,...h||[],...p||[]]).filter((s=>{const n=t[s];return!b.includes(s)&&s!==r&&(!n||!(0,l.cS)(n)||!e&&n.canBeInvitedToGroup)})),i)}),[c,i,u,h,p,r,b,e]),M=(0,o.I4)((()=>{P.length&&(v({query:""}),a(P))}),[P,v,a]);return o.ZP.createElement("div",{className:"AddChatMembers"},o.ZP.createElement("div",{className:"AddChatMembers-inner"},o.ZP.createElement(uo.Z,{itemIds:E,selectedIds:P,filterValue:u,filterPlaceholder:Z("lng_channel_add_users"),searchInputId:"new-members-picker-search",isLoading:m,onSelectedIdsChange:C,onFilterChange:S,noScrollRestore:w}),o.ZP.createElement(eo.Z,{isShown:Boolean(P.length),disabled:d,ariaLabel:Z("lng_channel_add_users"),onClick:M},d?o.ZP.createElement(Be.Z,{color:"white"}):o.ZP.createElement("i",{className:"icon-arrow-right"}))))}))),ho=Object.keys(m.qt).length/2,go=Object.keys(m.u1).length/2;function po(){const e=document.querySelector(".RightHeader .SearchInput input");e&&e.blur()}const fo=(0,o.X$)((0,n.c$)((e=>{const{chatId:t,threadId:s}=(0,i.Bt)(e)||{},n=(0,i.g4)(e);return{contentKey:(0,i.Wq)(e),chatId:t,threadId:s,currentProfileUserId:e.users.selectedId,isChatSelected:Boolean(t&&n),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations}}))((({contentKey:e,chatId:t,threadId:s,currentProfileUserId:r,isChatSelected:i,shouldSkipHistoryAnimations:c})=>{var l;const{toggleChatInfo:d,toggleManagement:u,openUserInfo:h,closeLocalTextSearch:g,setStickerSearchQuery:p,setGifSearchQuery:f,closePollResults:I,addChatMembers:v,setNewChatMembersDialogState:y}=(0,n.uC)(),{width:Z}=it(),[P,C]=(0,o.eJ)(m.vi.Profile),[w,b]=(0,o.eJ)(m.u1.Initial),[S,E]=(0,o.eJ)(),[M,k]=(0,o.eJ)(),R=P!==m.vi.Profile,T=void 0!==e,N=e===m.qt.ChatInfo||e===m.qt.UserInfo,B=e===m.qt.Search,A=e===m.qt.Management,x=e===m.qt.StickerSearch,L=e===m.qt.GifSearch,O=e===m.qt.PollResults,F=e===m.qt.AddingMembers,U=Z<=a._m,[$,D]=(0,o.eJ)(!T),q=null!==(l=(0,gt.Z)(e,!0,!i))&&void 0!==l?l:-1,Q=(0,o.I4)(((t=!0)=>{switch(e){case m.qt.AddingMembers:y(m.WB.Closed);break;case m.qt.ChatInfo:if(R&&t){C(m.vi.Profile);break}d(void 0,{forceSyncOnIOs:!0});break;case m.qt.UserInfo:if(R&&t){C(m.vi.Profile);break}h({id:void 0},{forceSyncOnIOs:!0});break;case m.qt.Management:switch(w){case m.u1.Initial:u();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:b(m.u1.Initial);break;case m.u1.GroupUserPermissionsCreate:case m.u1.GroupRemovedUsers:case m.u1.GroupUserPermissions:b(m.u1.GroupPermissions),E(void 0),k(void 0);break;case m.u1.ChatAdminRights:case m.u1.GroupRecentActions:b(m.u1.ChatAdministrators)}break;case m.qt.Search:po(),g();break;case m.qt.StickerSearch:po(),p({query:void 0});break;case m.qt.GifSearch:po(),f({query:void 0});break;case m.qt.PollResults:I()}}),[e,R,d,h,I,y,w,u,g,p,f]),G=(0,o.I4)(((e,t)=>{E(e),k(t)}),[]),j=(0,o.I4)((e=>{v({chatId:t,memberIds:e})}),[v,t]);function H(e){if(-1!==q)switch(q){case m.qt.AddingMembers:return o.ZP.createElement(mo,{chatId:t,onNextStep:j,isActive:T&&e,onClose:Q});case m.qt.ChatInfo:case m.qt.UserInfo:return o.ZP.createElement(ao,{key:r||t,chatId:t,userId:r,profileState:P,onProfileStateChange:C});case m.qt.Search:return o.ZP.createElement(oo,{chatId:t,threadId:s,onClose:Q,isActive:T&&e});case m.qt.Management:return o.ZP.createElement(ro,{chatId:t,currentScreen:w,isPromotedByCurrentUser:M,selectedChatMemberId:S,onScreenSelect:b,onChatMemberSelect:G,isActive:T&&e,onClose:Q});case m.qt.StickerSearch:return o.ZP.createElement(io,{onClose:Q,isActive:T&&e});case m.qt.GifSearch:return o.ZP.createElement(co,{onClose:Q,isActive:T&&e});case m.qt.PollResults:return o.ZP.createElement(lo,{onClose:Q,isActive:T&&e})}}return(0,o.d4)((()=>T?(0,fe.Z)(Q):void 0),[T,Q]),(0,o.d4)((()=>{setTimeout((()=>{D(!T)}),300)}),[T]),(0,o.d4)((()=>{T&&U&&Q()}),[U]),(0,Vt.Z)((([s,n])=>{(s===m.qt.ChatInfo&&e===m.qt.UserInfo||s===m.qt.UserInfo&&e===m.qt.ChatInfo||n!==t)&&(C(m.vi.Profile),b(m.u1.Initial))}),[e,t]),(0,pe.ZP)(i&&(e===m.qt.ChatInfo||e===m.qt.UserInfo||e===m.qt.Management||e===m.qt.AddingMembers),(()=>Q(!1)),d),o.ZP.createElement("div",{id:"RightColumn-wrapper",className:i?void 0:"is-hidden"},U&&o.ZP.createElement("div",{className:"overlay-backdrop",onClick:Q}),o.ZP.createElement("div",{id:"RightColumn"},o.ZP.createElement(Da,{chatId:t,isColumnOpen:T,isProfile:N,isSearch:B,isManagement:A,isStickerSearch:x,isGifSearch:L,isPollResults:O,isAddingChatMembers:F,profileState:P,managementScreen:w,onClose:Q,shouldSkipAnimation:$||c}),o.ZP.createElement(Ze.Z,{name:$||c?"none":"zoom-fade",renderCount:ho+go,activeKey:A?ho+w:q,shouldCleanup:!0,cleanupExceptionKey:m.qt.ChatInfo},H)))}))),Io=(0,o.X$)((({isOpen:e})=>{const t=(0,De.Z)($e.gl.Extra,"MediaViewer",!e);return t?o.ZP.createElement(t,null):void 0}));function vo(e,t){const s=document.createElement("a");s.href=e,s.download=t;try{s.click()}catch(e){console.error(e)}}const yo=new Set,Zo=(0,o.X$)((0,n.c$)((e=>({activeDownloads:e.activeDownloads.byChatId,messages:e.messages.byChatId})))((({activeDownloads:e,messages:t})=>{const{cancelMessageMediaDownload:s}=(0,n.uC)();(0,o.d4)((()=>{Object.entries(e).forEach((([e,n])=>{n.map((s=>t[Number(e)].byId[s])).forEach((e=>{const t=(0,l.Ti)(e,"download");if(t){if(!yo.has(t)){const n=Tt.UV(t);if(n)return yo.delete(t),vo(n,(0,l.w6)(e)),void s({message:e});Tt.he(t,u.IU.BlobUrl,!0).then((n=>{yo.delete(t),n&&vo(n,(0,l.w6)(e)),s({message:e})})),yo.add(t)}}else s({message:e})}))}))}),[s,t,e])}))),Po=(0,o.X$)((({isOpen:e})=>{const t=(0,De.Z)($e.gl.Extra,"Notifications",!e);return t?o.ZP.createElement(t,null):void 0})),Co=(0,o.X$)((({isOpen:e})=>{const t=(0,De.Z)($e.gl.Extra,"Dialogs",!e);return t?o.ZP.createElement(t,null):void 0})),wo=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"ForwardPicker",!t);return s?o.ZP.createElement(s,e):void 0})),bo=(0,o.X$)((e=>{const{url:t}=e,s=(0,De.Z)($e.gl.Extra,"SafeLinkModal",!t);return s?o.ZP.createElement(s,e):void 0})),So=(0,o.X$)((e=>{const{isOpen:t}=e,s=(0,De.Z)($e.gl.Extra,"HistoryCalendar",!t);return s?o.ZP.createElement(s,e):void 0})),Eo=(0,o.X$)((e=>{const{groupCallId:t}=e,s=(0,De.Z)($e.gl.Calls,"GroupCall",!t);return s?o.ZP.createElement(s,e):void 0})),Mo=(0,o.X$)((e=>{const{groupCallId:t}=e,s=(0,De.Z)($e.gl.Calls,"ActiveCallHeader",!t);return s?o.ZP.createElement(s,null):void 0})),ko=(0,o.X$)((({isOpen:e})=>{const t=(0,De.Z)($e.gl.Calls,"CallFallbackConfirm",!e);return t?o.ZP.createElement(t,{isOpen:e}):void 0}));let Ro,To=!1;function No(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 Bo(e){document.title!==e&&(document.title=e)}const Ao=(0,o.X$)((0,n.c$)((e=>{const{settings:{byKey:{animationLevel:t,language:s,wasTimeFormatSetManually:n}}}=e,{chatId:a,messageId:o}=e.audioPlayer,r=a&&o?(0,i.hj)(e,a,o):void 0;return{lastSyncTime:e.lastSyncTime,isLeftColumnShown:e.isLeftColumnShown,isRightColumnShown:(0,i.Jf)(e),isMediaViewerOpen:(0,i.zQ)(e),isForwardModalOpen:(0,i.Ev)(e),hasNotifications:Boolean(e.notifications.length),hasDialogs:Boolean(e.dialogs.length),audioMessage:r,safeLinkModalUrl:e.safeLinkModalUrl,isHistoryCalendarOpen:Boolean(e.historyCalendarSelectedAt),shouldSkipHistoryAnimations:e.shouldSkipHistoryAnimations,openedStickerSetShortName:e.openedStickerSetShortName,isServiceChatReady:(0,i.UW)(e),activeGroupCallId:e.groupCalls.activeGroupCallId,animationLevel:t,language:s,wasTimeFormatSetManually:n,isCallFallbackConfirmOpen:Boolean(e.groupCalls.isFallbackConfirmOpen),addedSetIds:e.stickers.added.setIds}}))((({lastSyncTime:e,isLeftColumnShown:t,isRightColumnShown:s,isMediaViewerOpen:r,isForwardModalOpen:c,hasNotifications:l,hasDialogs:d,audioMessage:u,activeGroupCallId:m,safeLinkModalUrl:g,isHistoryCalendarOpen:p,shouldSkipHistoryAnimations:f,openedStickerSetShortName:I,isServiceChatReady:v,animationLevel:y,language:Z,wasTimeFormatSetManually:P,isCallFallbackConfirmOpen:w,addedSetIds:b})=>{const{loadAnimatedEmojis:S,loadNotificationSettings:E,loadNotificationExceptions:M,updateIsOnline:k,loadTopInlineBots:R,loadEmojiKeywords:T,loadCountryList:N,loadStickerSets:B,loadAddedStickers:A,loadFavoriteStickers:x,ensureTimeFormat:L,openStickerSetShortName:O,checkVersionNotification:F}=(0,n.uC)(),U=Boolean(e);a.eM&&!To&&(To=!0,console.log(">>> RENDER MAIN")),(0,o.d4)((()=>{e&&(k(!0),S(),E(),M(),R(),T({language:a.pR}))}),[e,S,T,M,E,R,k]),(0,o.d4)((()=>{e&&(Z!==a.pR&&T({language:Z}),N({langCode:Z}))}),[Z,e,N,T]),(0,o.d4)((()=>{U&&(b?A():(B(),x()))}),[U,b,B,x,A]),(0,o.d4)((()=>{e&&v&&F()}),[e,v,F]),(0,o.d4)((()=>{e&&!P&&L()}),[e,P,L]),(0,o.d4)((()=>{e&&pe.Oy.startsWith("#?tgaddr=")&&(0,oe.o)(decodeURIComponent(pe.Oy.substr("#?tgaddr=".length)))}),[e]),(0,o.d4)((()=>{if(m)return ie.Z.disableRefresh(),()=>{ie.Z.enableRefresh()}}),[m]);const{transitionClassNames:$}=(0,ce.Z)(!t,void 0,!0,void 0,f),{transitionClassNames:D}=(0,ce.Z)(s,void 0,!0,void 0,f),q=(0,ne.Z)($.replace(/([\w-]+)/g,"middle-column-$1"),D.replace(/([\w-]+)/g,"right-column-$1"),f&&"history-animation-disabled");(0,ue.Z)((([e])=>{if(void 0===e||0===y)return;const t=(0,se.YW)();(0,ae.L)(document.getElementById("MiddleColumn"),t)}),[t]),(0,ue.Z)((([e])=>{if(void 0===e||0===y)return;(0,C.T2)((()=>{document.body.classList.add("animating-right-column")}));const t=(0,se.YW)();(0,ae.L)(document.getElementById("RightColumn"),(()=>{t(),(0,C.T2)((()=>{document.body.classList.remove("animating-right-column")}))}))}),[s]);const Q=(0,o.I4)((()=>{k(!1);const e=(0,i.A1)((0,n.Rd)());let t=0;clearInterval(Ro),Ro=window.setInterval((()=>{if(document.title.includes(a.ou))No(!1);else{if(t%2==0){const t=(0,i.A1)((0,n.Rd)())-e;t>0&&(Bo(`${t} notification${t>1?"s":""}`),No(!0))}else Bo(a.Ti),No(!1);t++}}),1e3)}),[k]),G=(0,o.I4)((()=>{k(!0),clearInterval(Ro),Ro=void 0,document.title.includes(a.ou)||Bo(a.Ti),No(!1)}),[k]),j=(0,o.I4)((()=>{O({stickerSetShortName:void 0})}),[O]);return(0,le.Z)(Q,G),de(Q),function(e=!1){(0,o.d4)((()=>{if(h.$b){if(!e)return null==me||me.setAttribute("content",he),h.cj&&!h.fl&&document.addEventListener("gesturestart",ge),()=>{null==me||me.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no"),h.cj&&!h.fl&&document.removeEventListener("gesturestart",ge)};null==me||me.setAttribute("content","width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover")}}),[e])}(r),o.ZP.createElement("div",{id:"Main",className:q,onDrop:re.Z,onDragOver:re.Z},o.ZP.createElement(st,null),o.ZP.createElement(Fa,null),o.ZP.createElement(fo,null),o.ZP.createElement(Io,{isOpen:r}),o.ZP.createElement(wo,{isOpen:c}),o.ZP.createElement(Po,{isOpen:l}),o.ZP.createElement(Co,{isOpen:d}),u&&o.ZP.createElement(Gt,{key:u.id,message:u,noUi:!0}),o.ZP.createElement(bo,{url:g}),o.ZP.createElement(So,{isOpen:p}),o.ZP.createElement(Ms.Z,{isOpen:Boolean(I),onClose:j,stickerSetShortName:I}),m&&o.ZP.createElement(o.ZP.Fragment,null,o.ZP.createElement(Eo,{groupCallId:m}),o.ZP.createElement(Mo,{groupCallId:m})),o.ZP.createElement(Zo,null),o.ZP.createElement(ko,{isOpen:w}))})));a.eM&&console.log(">>> FINISH LOAD MAIN BUNDLE"),(0,n.Rd)().connectionState||(0,n.uC)().initApi()},4524:(e,t,s)=>{e.exports=s.p+"telegram-logo-filled.67469f6dc5e301e8e0bd..svg"}}]);
|
||
//# sourceMappingURL=87.eb81908a48287675776e.js.map
|