2 lines
48 KiB
JavaScript
2 lines
48 KiB
JavaScript
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[2859],{42347:(t,e,a)=>{a.d(e,{A$:()=>J,Jm:()=>E,ad:()=>M});var s=a(23174),i=a(89925),o=a(31481),d=a(85982),n=a(55148),r=a(46275),c=a(14487),l=a(49763),h=a(87894),u=a(60343),I=a(6e4),p=a(37836),m=a(59852),g=a(4875),f=a(90709),b=a(13439),C=a(46042),V=a(80840),w=a(32989),y=a(29807),v=a(71331),F=a(64520);const S=new Set(["FILTERS_TOO_MUCH","CHATLISTS_TOO_MUCH","INVITES_TOO_MUCH"]),A=(0,p.nF)((t=>t()),3e3,!0),x=(0,p.sg)((t=>t()),500,!1,!0);function U(t,e){(0,g.px)("abortChatRequests",{chatId:t,threadId:e})}function P(t,e,a,...[s=(0,c.g0)()]){const i=(0,y.Xf0)(t,s),o=i?.chatId,d=i?.threadId;if(o&&(o!==e||d!==a)){const[a,i]=Object.values(t.byTabId).reduce((([e,a],{id:i})=>{if(i===s||e&&a)return[e,a];const n=(0,y.Xf0)(t,i),r=n?.chatId===o;return[e||r,a||r&&n?.threadId===d]}),[o===e,!1]);(!a||!i)&&U(o,a?d:void 0)}}async function T(t,e,a){let i=(0,b.mS)(),d=(0,y.xzS)(i)?.id;const n=a?{}:(0,y.$TA)(i,t),r=n.nextOffsetPeerId?(0,y.PVB)(i,n.nextOffsetPeerId):void 0,c=n.nextOffsetDate,l=n.nextOffsetId,u=!(a||r||c||l),I="saved"===t?await(0,g.px)("fetchSavedChats",{limit:o.uCr,offsetDate:c,offsetId:l,offsetPeer:r,withPinned:u}):await(0,g.px)("fetchChats",{limit:o.uCr,offsetDate:c,offsetId:l,offsetPeer:r,archived:"archived"===t,withPinned:u,lastLocalServiceMessageId:d});if(!I)return;const{chatIds:p}=I;i=(0,b.mS)(),d=(0,y.xzS)(i)?.id;const m=(0,h.dU)(I.chats,"id");i=(0,C.CKT)(i,(0,h.dU)(I.users,"id")),i=(0,C.h7P)(i,m),u?(i=(0,C.hOQ)(i,t,p),i=(0,C.wWy)(i,I.userStatusesById)):(i=(0,C.ec2)(i,t,p),i=(0,C.d2X)(i,I.userStatusesById)),i=(0,C.qwk)(i,t,I),i=(0,C.tTf)(i,I.messages),i=(0,C.XUr)(i,I.lastMessageByChatId,t),a||(i=(0,C.tPq)(i,t,I.nextOffsetId,I.nextOffsetPeerId,I.nextOffsetDate)),(e?I.chatIds:Object.keys(I.draftsById)).forEach((t=>{const e=I.draftsById[t],a=(0,y.$jd)(i,t,s.l3);(e||a)&&((0,y.GA4)(i,t,s.l3)?.isLocal||(i=(0,C.eww)(i,t,s.l3,"draft",e)))})),0!==p.length&&p.length!==I.totalChatCount||i.chats.isFullyLoaded[t]||(i={...i,chats:{...i.chats,isFullyLoaded:{...i.chats.isFullyLoaded,[t]:!0}}}),(0,b.UF)(i)}async function M(t,e,a){const s=await(0,g.px)("fetchFullChat",a);if(!s)return;const{chats:i,userStatusesById:o,fullInfo:d,groupCall:n,membersCount:r,isForumAsMessages:c}=s;if(t=(0,b.mS)(),t=(0,C.h7P)(t,(0,h.dU)(i,"id")),o&&(t=(0,C.d2X)(t,o)),n){const e=(0,v.Ip)(t,n.id);t=(0,V.h9)(t,n.id,(0,h.cJ)(n,["connectionState","isLoaded"]),void 0,e?void 0:n.participantsCount)}void 0!==r&&(t=(0,C.wix)(t,a.id,{membersCount:r})),a.isForum&&(t=(0,C.wix)(t,a.id,{isForumAsMessages:c})),t=(0,C.iW2)(t,a.id,d),(0,b.UF)(t);const l=d.stickerSet,u=l&&(0,y.ycM)(t,l);l&&!u&&e.loadStickers({stickerSetInfo:{id:l.id,accessHash:l.accessHash}});const I=d.emojiSet,p=I&&(0,y.ycM)(t,I);return I&&!p&&e.loadStickers({stickerSetInfo:{id:I.id,accessHash:I.accessHash}}),s}async function J(t,e,a){t=(0,b.mS)();const s=a?void 0:(0,y.qn$)(t,e);if(s&&!s.isMin)return s;const{chat:i,user:o}=await(0,g.px)("getChatByUsername",e,a)||{};return i?(t=(0,b.mS)(),t=(0,C.wix)(t,i.id,i),o&&(t=(0,C.TKu)(t,o.id,o)),(0,b.UF)(t),i):void 0}async function B(t,e,a,...[s=(0,c.g0)()]){const i=await J(t,a);if(!i)return;t=(0,b.mS)();const o=(0,y.mBe)(t,i.id);if(!o)return;if(!(0,f.tvf)(o))return;const d=await(0,g.px)("loadAttachBot",{bot:o});if(t=(0,b.mS)(),d)return(0,b.UF)(t),d.bot;e.showNotification({message:I.yE("WebApp.AddToAttachmentUnavailableError"),tabId:s})}async function k(t,e,a,i,...[o=(0,c.g0)()]){const{isCurrentChat:d,threadId:n,messageId:r,startParam:l,referrer:h,startAttach:u,attach:I,text:p}=i;if(r){let s=!1;if(a.isForum&&!n){let i=(0,y.pSx)(t,a.id)?.[r];if(!i){const t=await(0,g.px)("fetchTopicById",{chat:a,topicId:r});i=t?.topic}i&&(e.openThread({chatId:a.id,threadId:i.id,tabId:o}),s=!0)}s||e.focusMessage({chatId:a.id,threadId:n,messageId:r,tabId:o})}else d||e.openThread({chatId:a.id,threadId:n??s.l3,tabId:o});l&&!h&&e.startBot({botId:a.id,param:l}),I&&R(t=(0,b.mS)(),e,a.id,I,u,o),p&&e.openChatWithDraft({chatId:a.id,text:{text:p},tabId:o})}async function R(t,e,a,s,i,...[o=(0,c.g0)()]){t=(0,b.mS)();const d=await B(t,e,s,o);d&&e.callAttachBot({bot:d,chatId:a,..."string"==typeof i&&{startParam:i},tabId:o})}async function E(t,e,a,...[s=(0,c.g0)()]){const i=(0,y.hds)(t,a);if(!i||!(0,f.yn$)(i))return i;const o=await async function(t,e,a,...[s=(0,c.g0)()]){try{return await(0,g.px)("migrateChat",a)}catch(t){return void("CHANNELS_TOO_MUCH"===t.message?e.openLimitReachedModal({limit:"channels",tabId:s}):e.showDialog({data:{...t,hasErrorKey:!0},tabId:s}))}}(0,e,i,s);return o?(e.loadFullChat({chatId:o.id}),e.openChat({id:o.id,tabId:s}),o):void 0}(0,b.aJ)("preloadTopChatMessages",(async(t,e)=>{const a=new Set;for(let i=0;i<o.irO;i++){await(0,p.v7)(100),t=(0,b.mS)();const i=Object.values(t.byTabId).map((({id:e})=>(0,y.Xf0)(t,e)?.chatId)).filter(Boolean),d=(0,l.YA)(o.DSF),n=d?.find((t=>!i.includes(t)&&!a.has(t)));if(!n)return;a.add(n),e.loadViewportMessages({chatId:n,threadId:s.l3,tabId:(0,c.g0)()})}})),(0,b.aJ)("openChat",((t,e,a)=>{const{id:i,type:d,noForumTopicPanel:n,shouldReplaceHistory:r,shouldReplaceLast:l,tabId:h=(0,c.g0)()}=a;if(e.processOpenChatOrThread({chatId:i,type:d,threadId:s.l3,noForumTopicPanel:n,shouldReplaceHistory:r,shouldReplaceLast:l,tabId:h}),P(t,i,s.l3,h),!i||i===o.Xab)return;const u=(0,y.hds)(t,i);u?.hasUnreadMark&&e.toggleChatUnread({id:i});const I=!(0,y.ZZX)(t,i);if(u)I&&!u.isMin&&e.requestChatUpdate({chatId:i});else if((0,y.nZ4)(t,i))(0,g.px)("fetchChat",{type:"self"});else{const e=(0,y.mBe)(t,i);e&&(0,g.px)("fetchChat",{type:"user",user:e})}})),(0,b.aJ)("openSavedDialog",((t,e,a)=>{const{chatId:s,tabId:i=(0,c.g0)(),...o}=a;e.openThread({chatId:t.currentUserId,threadId:s,tabId:i,...o})})),(0,b.aJ)("openThread",(async(t,e,a)=>{const{type:i,isComments:o,noForumTopicPanel:d,shouldReplaceHistory:n,shouldReplaceLast:r,focusMessageId:l,tabId:u=(0,c.g0)()}=a;let p,m,V,{chatId:v}=a;if(o){const{originChannelId:t,originMessageId:e}=a;m=t,V=e}else{m=a.chatId,p=a.threadId,V=p;const c=(0,y.hds)(t,m);if(p===s.l3)return void e.openChat({id:v,type:i,noForumTopicPanel:d,shouldReplaceHistory:n,shouldReplaceLast:r,tabId:u});if(c?.isForum||v&&(0,f.cG0)(v,p,t.currentUserId))return void e.processOpenChatOrThread({chatId:v,type:i,threadId:p,isComments:o,noForumTopicPanel:d,shouldReplaceHistory:n,shouldReplaceLast:r,tabId:u})}const F=(0,y.hds)(t,m),S=(0,y.Vw0)(t,m,V),A=(0,y.$jd)(t,m,V);if(!F)return;if(P(t,m,V,u),v&&S?.threadId&&(o||A?.listedIds?.length&&A.listedIds.includes(Number(S.threadId))))return t=(0,w.w)(t,{loadingThread:void 0},u),(0,b.UF)(t),void e.processOpenChatOrThread({chatId:v,type:i,threadId:S.threadId,isComments:o,noForumTopicPanel:d,shouldReplaceHistory:n,shouldReplaceLast:r,tabId:u});let{loadingThread:x}=(0,y.nTw)(t,u);x&&U(x.loadingChatId,x.loadingMessageId),t=(0,w.w)(t,{loadingThread:{loadingChatId:m,loadingMessageId:Number(V)}},u),(0,b.UF)(t);const T=()=>{const t=(0,b.mS)();o||(0,y.Xf0)(t,u)?.chatId!==m||(0,y.Xf0)(t,u)?.threadId!==V||e.openPreviousChat({tabId:u})};o||e.processOpenChatOrThread({chatId:v,type:i,threadId:p,tabId:u,isComments:o,noForumTopicPanel:d,shouldReplaceHistory:n,shouldReplaceLast:r});const M=await(0,g.px)("fetchDiscussionMessage",{chat:(0,y.hds)(t,m),messageId:Number(V)});if(t=(0,b.mS)(),x=(0,y.nTw)(t,u).loadingThread,x?.loadingChatId===m&&x?.loadingMessageId===V){if(!M)return t=(0,w.w)(t,{loadingThread:void 0},u),(0,b.UF)(t),e.showNotification({message:I.yE(o?"ChannelPostDeleted":"lng_message_not_found"),tabId:u}),void T();p??(p=M.threadId),v??(v=M.chatId),v?(t=(0,b.mS)(),t=(0,C.KcS)(t,M.messages),o&&(t=(0,C.eAk)(t,m,V,{threadId:p}),t=(0,C.eAk)(t,v,p,{isCommentsInfo:!1,threadId:p,chatId:v,fromChannelId:m,fromMessageId:V,...S&&(0,h.Up)(S,["messagesCount","lastMessageId","lastReadInboxMessageId","recentReplierIds"])})),t=(0,C.e49)(t,v,p,{firstMessageId:M.firstMessageId}),(0,b.UF)(t),l&&e.focusMessage({chatId:v,threadId:p,messageId:l,tabId:u}),e.loadViewportMessages({chatId:v,threadId:p,tabId:u,onError:()=>{t=(0,b.mS)(),t=(0,w.w)(t,{loadingThread:void 0},u),(0,b.UF)(t),e.showNotification({message:I.yE("Group.ErrorAccessDenied"),tabId:u})},onLoaded:()=>{t=(0,b.mS)(),x=(0,y.nTw)(t,u).loadingThread,x?.loadingChatId===m&&x?.loadingMessageId===V&&(t=(0,w.w)(t,{loadingThread:void 0},u),(0,b.UF)(t),e.processOpenChatOrThread({chatId:v,type:i,threadId:p,tabId:u,isComments:o,noForumTopicPanel:d,shouldReplaceHistory:n,shouldReplaceLast:r}))}})):T()}else T()})),(0,b.aJ)("openLinkedChat",(async(t,e,a)=>{const{id:s,tabId:i=(0,c.g0)()}=a,o=(0,y.hds)(t,s);if(!o)return;const d=await(0,g.px)("fetchFullChat",o);d?.fullInfo?.linkedChatId&&e.openChat({id:d.fullInfo.linkedChatId,tabId:i})})),(0,b.aJ)("openSupportChat",(async(t,e,a)=>{const{tabId:s=(0,c.g0)()}=a||{},i=(0,y.ke9)(t);if(i)return void e.openChat({id:i.id,shouldReplaceHistory:!0,tabId:s});e.openChat({id:o.Xab,shouldReplaceHistory:!0,tabId:s});const d=await(0,g.px)("fetchChat",{type:"support"});d&&e.openChat({id:d.chatId,shouldReplaceHistory:!0,tabId:s})})),(0,b.aJ)("loadAllChats",(async(t,e,a)=>{const{whenFirstBatchDone:s}=a,i=a.listType;let d=!1,n=0;for(;!t.chats.isFullyLoaded[i];){if(n++>=100)return void(o.Oig&&console.error("`actions/loadAllChats`: Infinite loop detected"));if("connectionStateReady"!==(t=(0,b.mS)()).connectionState||"authorizationStateReady"!==t.authState)return;await T(i,!0),d||(await(s?.()),d=!0),t=(0,b.mS)()}})),(0,b.aJ)("loadFullChat",((t,e,a)=>{const{chatId:s,force:i,withPhotos:o}=a,d=(0,y.hds)(t,s);if(!d)return;const n=async()=>{await M(t,e,d),o&&e.loadMoreProfilePhotos({peerId:s,shouldInvalidateCache:!0})};i?n():x(n)})),(0,b.aJ)("loadTopChats",(()=>{A((()=>{T("active",void 0,!0),T("archived",void 0,!0)}))})),(0,b.aJ)("requestChatUpdate",((t,e,a)=>{const{chatId:s}=a,i=(0,y.hds)(t,s);i&&(0,g.px)("requestChatUpdate",{chat:i,...s===o.zv8&&{lastLocalMessage:(0,y.xzS)(t)?.message}})})),(0,b.aJ)("requestSavedDialogUpdate",(async(t,e,a)=>{const{chatId:s}=a,i=(0,y.hds)(t,s);if(!i)return;const o=await(0,g.px)("fetchMessages",{chat:i,isSavedDialog:!0,limit:1});o&&(t=(0,b.mS)(),t=(0,C.KcS)(t,o.messages),o.messages.length?(t=(0,C.yKC)(t,s,o.messages[0].id,"saved"),t=(0,C.ec2)(t,"saved",[s]),(0,b.UF)(t)):(t=(0,C.SJu)(t,s,"saved"),(0,b.UF)(t),Object.values(t.byTabId).forEach((({id:a})=>{const i=(0,y.Xf0)(t,a);if(!i)return;const{chatId:o,threadId:d}=i;(0,y.nZ4)(t,o)&&d===s&&e.openChat({id:void 0,tabId:a})}))))})),(0,b.aJ)("updateChatMutedState",((t,e,a)=>{const{chatId:s,muteUntil:i=0}=a,o=(0,y.hds)(t,s);if(!o)return;const d=a.isMuted??i>0;t=(0,C.wix)(t,s,{isMuted:d}),(0,b.UF)(t),(0,g.px)("updateChatMutedState",{chat:o,isMuted:d,muteUntil:i})})),(0,b.aJ)("updateTopicMutedState",((t,e,a)=>{const{chatId:s,topicId:i,muteUntil:o=0}=a,d=(0,y.hds)(t,s);if(!d)return;const n=a.isMuted??o>0;t=(0,C.TwA)(t,s,i,{isMuted:n}),(0,b.UF)(t),(0,g.px)("updateTopicMutedState",{chat:d,topicId:i,isMuted:n,muteUntil:o})})),(0,b.aJ)("createChannel",(async(t,e,a)=>{const{title:s,about:o,photo:d,memberIds:n,tabId:r=(0,c.g0)()}=a,l=n.map((e=>(0,y.mBe)(t,e))).filter(Boolean);let h,u;t=(0,w.w)(t,{chatCreation:{progress:i.n7.InProgress}},r),(0,b.UF)(t);try{const t=await(0,g.px)("createChannel",{title:s,about:o,users:l});h=t?.channel,u=t?.missingUsers}catch(a){t=(0,b.mS)(),t=(0,w.w)(t,{chatCreation:{progress:i.n7.Error}},r),(0,b.UF)(t),"CHANNELS_TOO_MUCH"===a.message?e.openLimitReachedModal({limit:"channels",tabId:r}):e.showDialog({data:{...a,hasErrorKey:!0},tabId:r})}if(!h)return;const{id:I,accessHash:p}=h;t=(0,b.mS)(),t=(0,C.wix)(t,I,h),t=(0,w.w)(t,{chatCreation:{...(0,y.nTw)(t,r).chatCreation,progress:h?i.n7.Complete:i.n7.Error}},r),(0,b.UF)(t),e.openChat({id:I,shouldReplaceHistory:!0,tabId:r}),u&&(t=(0,b.mS)(),t=(0,C.hQe)(t,I,u,r),(0,b.UF)(t)),I&&p&&d&&await(0,g.px)("editChatPhoto",{chatId:I,accessHash:p,photo:d})})),(0,b.aJ)("joinChannel",(async(t,e,a)=>{const{chatId:s,tabId:i=(0,c.g0)()}=a,o=(0,y.hds)(t,s);if(!o)return;const{id:d,accessHash:n}=o;if(d&&n)try{await(0,g.px)("joinChannel",{channelId:d,accessHash:n})}catch(t){"CHANNELS_TOO_MUCH"===t.message?e.openLimitReachedModal({limit:"channels",tabId:i}):e.showDialog({data:{...t,hasErrorKey:!0},tabId:i})}})),(0,b.aJ)("deleteChatUser",((t,e,a)=>{const{chatId:s,userId:i,shouldRevokeHistory:o,tabId:d=(0,c.g0)()}=a,n=(0,y.hds)(t,s),r=(0,y.mBe)(t,i);n&&r&&(t=(0,C.CX_)(t,s),(0,b.UF)(t),(0,y.Xf0)(t,d)?.chatId===s&&e.openChat({id:void 0,tabId:d}),(0,g.px)("deleteChatUser",{chat:n,user:r,shouldRevokeHistory:o}))})),(0,b.aJ)("deleteChat",((t,e,a)=>{const{chatId:s,tabId:i=(0,c.g0)()}=a,o=(0,y.hds)(t,s);o&&(t=(0,C.CX_)(t,s),(0,b.UF)(t),(0,y.Xf0)(t,i)?.chatId===s&&e.openChat({id:void 0,tabId:i}),(0,g.px)("deleteChat",{chatId:o.id}))})),(0,b.aJ)("leaveChannel",(async(t,e,a)=>{const{chatId:s,tabId:i=(0,c.g0)()}=a,o=(0,y.hds)(t,s);if(!o)return;t=(0,C.CX_)(t,s),(0,b.UF)(t),(0,y.Xf0)(t,i)?.chatId===s&&e.openChat({id:void 0,tabId:i});const{id:d,accessHash:n}=o;if(d&&n){await(0,g.px)("leaveChannel",{channelId:d,accessHash:n}),t=(0,b.mS)();const e=(0,y.zeq)(t,s),a=Object.keys(e).map(Number).filter(u.iL);t=(0,C.AH0)(t,s,a),(0,b.UF)(t)}})),(0,b.aJ)("deleteChannel",((t,e,a)=>{const{chatId:s,tabId:i=(0,c.g0)()}=a,o=(0,y.hds)(t,s);if(!o)return;t=(0,C.CX_)(t,s),(0,b.UF)(t),(0,y.Xf0)(t,i)?.chatId===s&&e.openChat({id:void 0,tabId:i});const{id:d,accessHash:n}=o;d&&n&&(0,g.px)("deleteChannel",{channelId:d,accessHash:n})})),(0,b.aJ)("createGroupChat",(async(t,e,a)=>{const{title:s,memberIds:o,photo:d,tabId:n=(0,c.g0)()}=a,r=o.map((e=>(0,y.mBe)(t,e))).filter(Boolean);t=(0,w.w)(t,{chatCreation:{progress:i.n7.InProgress}},n),(0,b.UF)(t);try{const{chat:a,missingUsers:o}=await(0,g.px)("createGroupChat",{title:s,users:r})??{};if(!a)return;const{id:c}=a;t=(0,b.mS)(),t=(0,C.wix)(t,c,a),t=(0,w.w)(t,{chatCreation:{...(0,y.nTw)(t,n).chatCreation,progress:a?i.n7.Complete:i.n7.Error}},n),(0,b.UF)(t),e.openChat({id:c,shouldReplaceHistory:!0,tabId:n}),o&&(t=(0,b.mS)(),t=(0,C.hQe)(t,c,o,n),(0,b.UF)(t)),c&&d&&await(0,g.px)("editChatPhoto",{chatId:c,photo:d})}catch(e){"USERS_TOO_FEW"===e.message&&(t=(0,b.mS)(),t=(0,w.w)(t,{chatCreation:{...(0,y.nTw)(t,n).chatCreation,progress:i.n7.Error,error:"CreateGroupError"}},n),(0,b.UF)(t))}})),(0,b.aJ)("toggleChatPinned",((t,e,a)=>{const{id:s,folderId:i,tabId:d=(0,c.g0)()}=a,n=(0,y.hds)(t,s);if(!n)return;const r=(0,F.d)(t,"dialogFolderPinned");if(i){const e=(0,y.$aQ)(t,i);if(e){const a=!(0,y.D3D)(t,s,i),{pinnedChatIds:o,includedChatIds:d}=e,n=a?[s,...o||[]]:(o||[]).filter((t=>t!==s)),r=[s,...d];(0,g.px)("editChatFolder",{id:i,folderUpdate:{...e,pinnedChatIds:n,includedChatIds:r}})}}else{const a=(0,y.P4G)(t,s),i=(0,y.D3D)(t,s,"archived"===a?o._E9:void 0),c=t.chats.orderedPinnedIds["archived"===a?"archived":"active"];if((c?.length||0)>=r&&!i)return void e.openLimitReachedModal({limit:"dialogFolderPinned",tabId:d});(0,g.px)("toggleChatPinned",{chat:n,shouldBePinned:!i})}})),(0,b.aJ)("toggleChatArchived",((t,e,a)=>{const{id:s}=a,i=(0,y.hds)(t,s);i&&(0,g.px)("toggleChatArchived",{chat:i,folderId:(0,f.TJc)(i)?0:o._E9})})),(0,b.aJ)("toggleSavedDialogPinned",((t,e,a)=>{const{id:s,tabId:i=(0,c.g0)()}=a,d=(0,y.hds)(t,s);if(!d)return;const n=(0,F.d)(t,"savedDialogsPinned"),r=(0,y.D3D)(t,s,o.pX9),l=t.chats.orderedPinnedIds.saved;(l?.length||0)>=n&&!r?e.openLimitReachedModal({limit:"savedDialogsPinned",tabId:i}):(0,g.px)("toggleSavedDialogPinned",{chat:d,shouldBePinned:!r})})),(0,b.aJ)("loadChatFolders",(async t=>{const e=await(0,g.px)("fetchChatFolders");e&&(t=(0,b.mS)(),t={...t,chatFolders:{...t.chatFolders,...e}},(0,b.UF)(t))})),(0,b.aJ)("loadRecommendedChatFolders",(async t=>{const e=await(0,g.px)("fetchRecommendedChatFolders");e&&(t=(0,b.mS)(),t={...t,chatFolders:{...t.chatFolders,recommended:e}},(0,b.UF)(t))})),(0,b.aJ)("editChatFolders",((t,e,a)=>{const{chatId:s,idsToRemove:i,idsToAdd:o,tabId:d=(0,c.g0)()}=a,n=(0,F.d)(t,"dialogFiltersChats");o.some((e=>(0,y.$aQ)(t,e).includedChatIds.length>=n))?e.openLimitReachedModal({limit:"dialogFiltersChats",tabId:d}):(i.forEach((async e=>{const a=(0,y.$aQ)(t,e);a&&await(0,g.px)("editChatFolder",{id:e,folderUpdate:{...a,pinnedChatIds:a.pinnedChatIds?.filter((t=>t!==s)),includedChatIds:a.includedChatIds.filter((t=>t!==s))}})})),o.forEach((async e=>{const a=(0,y.$aQ)(t,e);a&&await(0,g.px)("editChatFolder",{id:e,folderUpdate:{...a,includedChatIds:a.includedChatIds.concat(s)}})})))})),(0,b.aJ)("editChatFolder",((t,e,a)=>{const{id:s,folderUpdate:i}=a,o=(0,y.$aQ)(t,s);o&&(0,g.px)("editChatFolder",{id:s,folderUpdate:{id:s,emoticon:o.emoticon,pinnedChatIds:o.pinnedChatIds,...i}})})),(0,b.aJ)("addChatFolder",(async(t,e,a)=>{const{folder:s,tabId:i=(0,c.g0)()}=a,{orderedIds:d,byId:n}=t.chatFolders,r=(0,F.d)(t,"dialogFilters");if(Object.keys(n).length>=r)return void e.openLimitReachedModal({limit:"dialogFilters",tabId:i});const l=Math.max(...d||[],o._E9),{id:h,description:u,...I}=s,p=l+1,m={id:p,...I};if(await(0,g.px)("editChatFolder",{id:p,folderUpdate:m}),e.apiUpdate({"@type":"updateChatFolder",id:p,folder:m}),e.requestNextSettingsScreen({foldersAction:{type:"setFolderId",payload:l+1},tabId:i}),!u)return;t=(0,b.mS)();const{recommended:f}=t.chatFolders;f&&(t={...t,chatFolders:{...t.chatFolders,recommended:f.filter((({id:t})=>t!==h))}},(0,b.UF)(t))})),(0,b.aJ)("sortChatFolders",(async(t,e,a)=>{const{folderIds:s}=a;await(0,g.px)("sortChatFolders",s)&&(t=(0,b.mS)(),t={...t,chatFolders:{...t.chatFolders,orderedIds:s}},(0,b.UF)(t))})),(0,b.aJ)("deleteChatFolder",(async(t,e,a)=>{const{id:s}=a;(0,y.$aQ)(t,s)&&await(0,g.px)("deleteChatFolder",s)})),(0,b.aJ)("toggleChatUnread",((t,e,a)=>{const{id:i}=a,o=(0,y.hds)(t,i);o&&(o.unreadCount?(0,g.px)("markMessageListRead",{chat:o,threadId:s.l3}):(0,g.px)("toggleDialogUnread",{chat:o,hasUnreadMark:!o.hasUnreadMark}))})),(0,b.aJ)("markTopicRead",((t,e,a)=>{const{chatId:s,topicId:i}=a,o=(0,y.hds)(t,s);if(!o)return;const d=(0,y.S0q)(t,s,i),n=d?.lastMessageId;n&&((0,g.px)("markMessageListRead",{chat:o,threadId:i,maxId:n}),t=(0,b.mS)(),t=(0,C.TwA)(t,s,i,{unreadCount:0}),t=(0,C.eAk)(t,s,i,{lastReadInboxMessageId:n}),(0,b.UF)(t))})),(0,b.aJ)("checkChatInvite",(async(t,e,a)=>{const{hash:s,tabId:i=(0,c.g0)()}=a,o=await(0,g.px)("checkChatInvite",s);if(o){if(t=(0,b.mS)(),o.users&&(t=(0,C.g18)(t,(0,h.dU)(o.users,"id"))),o.chat)return t=(0,C.Nl5)(t,(0,h.dU)([o.chat],"id")),(0,b.UF)(t),void e.openChat({id:o.chat.id,tabId:i});if(o.invite.subscriptionFormId)return t=(0,w.w)(t,{starsPayment:{inputInvoice:{type:"chatInviteSubscription",hash:s},subscriptionInfo:o.invite,status:"pending"}},i),void(0,b.UF)(t);t=(0,w.w)(t,{chatInviteModal:{hash:s,inviteInfo:o.invite}},i),(0,b.UF)(t)}})),(0,b.aJ)("openChatByPhoneNumber",(async(t,e,a)=>{const{phoneNumber:s,startAttach:i,attach:d,text:n,tabId:r=(0,c.g0)()}=a;e.openChat({id:o.Xab,tabId:r});const l=await async function(t,e){t=(0,b.mS)();const a=(0,y.gTO)(t,e);if(a&&!a.isMin)return(0,y.hds)(t,a.id);const{chat:s,user:i}=await(0,g.px)("getChatByPhoneNumber",e)||{};return s?(t=(0,b.mS)(),t=(0,C.wix)(t,s.id,s),i&&(t=(0,C.TKu)(t,i.id,i)),(0,b.UF)(t),s):void 0}(t,s);if(!l)return e.openPreviousChat({tabId:r}),void e.showNotification({message:I.yE("lng_username_by_phone_not_found").replace("{phone}",s),tabId:r});n?e.openChatWithDraft({chatId:l.id,text:{text:n},tabId:r}):e.openChat({id:l.id,tabId:r}),d&&R(t=(0,b.mS)(),e,l.id,d,i,r)})),(0,b.aJ)("openTelegramLink",(async(t,e,a)=>{const{url:s,shouldIgnoreCache:i,tabId:d=(0,c.g0)()}=a,{openChatByPhoneNumber:l,checkChatInvite:h,openStickerSet:u,openChatWithDraft:I,joinVoiceChatByLink:p,openInvoice:m,checkChatlistInvite:f,openChatByUsername:C,openStoryViewerByUsername:V,checkGiftCode:w}=e;if((0,r.zq)(s)&&((0,n._)(s)||s.match(o.bnE)))return;const v=new URL(s.toLowerCase().startsWith("http")?s:`https://${s}`);if(o.G38.has(v.hostname)&&"/"===v.pathname)return void window.open(v.toString(),"_blank","noopener");const F=(o.G38.has(v.hostname)?"t.me":v.hostname).split(".");if(F.length>3)return;const S=v.pathname.replace(/^\/?s\//,""),A=3===F.length?`${F[0]}/${S}`:S,[x,U,P]=A.split("/").filter(Boolean).map((t=>decodeURI(t))),T=Object.fromEntries(v.searchParams);let M;"joinchat"===x&&(M=U);const B="s"===U&&(Number(P)||void 0);if(x.match(/^\+([0-9]+)(\?|$)/))return void l({phoneNumber:x.substr(1,x.length-1),startAttach:T.startattach,attach:T.attach,text:T.text,tabId:d});if(B)return void V({username:x,storyId:B,tabId:d});if((x.startsWith(" ")||x.startsWith("+"))&&(M=x.substr(1,x.length-1)),M)return void h({hash:M,tabId:d});if("addstickers"===x||"addemoji"===x)return void u({stickerSetInfo:{shortName:U},shouldIgnoreCache:i,tabId:d});if("share"===x)return void I({text:(0,n.E)(T.url,T.text),tabId:d});if("addlist"===x)return void f({slug:U,tabId:d});if("giftcode"===x)return void w({slug:U,tabId:d});const k=U||void 0,R=P?Number(P):void 0,E=T.comment?Number(T.comment):void 0,H=await async function(t,e,a){if(!e||!a)return!1;t=(0,b.mS)();const s=await J(t,e);t=(0,b.mS)();const i=s&&(0,y.mBe)(t,s.id),o=i&&await(0,g.px)("fetchBotApp",{bot:i,appName:a});return Boolean(o)}(t,x,U),L=x&&!U||Number.isInteger(Number(U))||H;T.hasOwnProperty("voicechat")||T.hasOwnProperty("livestream")?p({username:x,inviteHash:T.voicechat||T.livestream,tabId:d}):x.startsWith("$")?m({type:"slug",slug:x.substring(1),tabId:d}):"invoice"===x?m({type:"slug",slug:U,tabId:d}):L?C({username:x,messageId:R||Number(k),threadId:R?Number(k):void 0,commentId:E,startParam:T.start,startAttach:T.startattach,attach:T.attach,startApp:T.startapp,mode:T.mode,originalParts:[x,U,P],tabId:d}):e.openUrl({url:s,shouldSkipModal:!0,tabId:d,ignoreDeepLinks:!0})})),(0,b.aJ)("processBoostParameters",(async(t,e,a)=>{const{usernameOrId:s,isPrivate:i,tabId:o=(0,c.g0)()}=a;let d;if(i){if(d=(0,y.hds)(t,s),!d)return void e.showNotification({message:{key:"PrivateChannelInaccessible"},tabId:o})}else if(d=await J(t,s),!d)return void e.showNotification({message:{key:"NoUsernameFound"},tabId:o});(0,f.WXB)(d)||(0,f.VsK)(d)?e.openBoostModal({chatId:d.id,tabId:o}):e.openChat({id:d.id,tabId:o})})),(0,b.aJ)("acceptChatInvite",(async(t,e,a)=>{const{hash:s,tabId:i=(0,c.g0)()}=a,o=await(0,g.px)("importChatInvite",{hash:s});o&&e.openChat({id:o.id,tabId:i})})),(0,b.aJ)("openChatByUsername",(async(t,e,a)=>{const{username:s,messageId:i,commentId:d,startParam:n,startAttach:r,attach:l,threadId:h,originalParts:u,startApp:I,mode:p,text:g,onChatChanged:f,choose:C,ref:V,tabId:w=(0,c.g0)()}=a,v=(0,y.meB)(t,w),F=u?.[1],S=F&&!Number(F)&&!u?.[2];if(!d){if(void 0===r&&i&&!n&&!V&&v?.usernames?.some((t=>t.username===s)))return void e.focusMessage({chatId:v.id,threadId:h,messageId:i,tabId:w});if(void 0!==r&&C)return void e.processAttachBotParameters({username:s,filter:C,startParam:r||I,tabId:w});if(void 0!==I&&!F){const a=(0,m.A)(),i=await J(t,s);t=(0,b.mS)();const o=i&&(0,y.mBe)(t,i.id);if(!i||!v||!o?.hasMainMiniApp)return;return void e.requestMainWebView({botId:i.id,peerId:v.id,theme:a,tabId:w,mode:p})}if(!S)return await async function(t,e,a,...[s=(0,c.g0)()]){const{username:i,threadId:d,channelPostId:n,startParam:r,ref:l,startAttach:h,attach:u,text:I}=a,p=(0,y.meB)(t,s);if(void 0!==h&&!u){const a=await B(t,e,i,s);if(!a)return;return void e.callAttachBot({bot:a,chatId:p?.id||a.id,startParam:h,tabId:s})}const m=p?.usernames?.some((t=>t.username===i));m||e.openChat({id:o.Xab,tabId:s});const g=t.appConfig?.starRefStartPrefixes;let f=l;if(r&&g?.length){const t=g.find((t=>r.startsWith(t)));t&&(f=r.slice(t.length))}const b=await J(t,i,f);b?k(t,e,b,{isCurrentChat:m,threadId:d,messageId:n,startParam:r,referrer:f,startAttach:h,attach:u,text:I},s):m||(e.openPreviousChat({tabId:s}),e.showNotification({message:"User does not exist",tabId:s}))}(t,e,{username:s,threadId:h,channelPostId:i,startParam:n,ref:V,startAttach:r,attach:l,text:g},w),void(f&&e[f.action](f.payload))}const A=(0,y.qn$)(t,s);if(d&&i&&A)return void e.openThread({isComments:!0,originChannelId:A.id,originMessageId:i,tabId:w,focusMessageId:d});S||e.openChat({id:o.Xab,tabId:w});const x=await J(t,s);if(x)if(S&&x){const t=(0,m.A)();e.requestAppWebView({appName:F,botId:x.id,tabId:w,startApp:I,mode:p,theme:t})}else i&&(e.openThread({isComments:!0,originChannelId:x.id,originMessageId:i,tabId:w,focusMessageId:d}),f&&e[f.action](f.payload))})),(0,b.aJ)("openPrivateChannel",((t,e,a)=>{const{id:s,commentId:i,messageId:o,threadId:d,tabId:n=(0,c.g0)()}=a,r=(0,y.hds)(t,s);r?i||o||d?i&&o?e.openThread({isComments:!0,originChannelId:r.id,originMessageId:o,tabId:n,focusMessageId:i}):k(t,e,r,{messageId:o,threadId:d},n):e.openChat({id:s,tabId:n}):e.showNotification({message:{key:"PrivateChannelInaccessible"},tabId:n})})),(0,b.aJ)("togglePreHistoryHidden",(async(t,e,a)=>{const{chatId:s,isEnabled:i,tabId:o=(0,c.g0)()}=a,d=await E(t,e,s,o);d&&(t=(0,b.mS)(),t=(0,C.ltr)(t,d.id,{isPreHistoryHidden:i}),(0,b.UF)(t),(0,g.px)("togglePreHistoryHidden",{chat:d,isEnabled:i}))})),(0,b.aJ)("updateChatDefaultBannedRights",((t,e,a)=>{const{chatId:s,bannedRights:i}=a,o=(0,y.hds)(t,s);o&&(0,g.px)("updateChatDefaultBannedRights",{chat:o,bannedRights:i})})),(0,b.aJ)("updateChatMemberBannedRights",(async(t,e,a)=>{const{chatId:s,userId:i,bannedRights:o,tabId:d=(0,c.g0)()}=a,n=(0,y.mBe)(t,i);if(!n)return;const r=await E(t,e,s,d);if(!r)return;await(0,g.px)("updateChatMemberBannedRights",{chat:r,user:n,bannedRights:o}),t=(0,b.mS)();const l=(0,y.AWZ)(t,r.id);if(!l)return;const{members:h,kickedMembers:u}=l,I=Boolean(o.viewMessages),p=!Object.keys(o).length;t=(0,C.ltr)(t,r.id,{...h&&I&&{members:h.filter((t=>t.userId!==i))},...h&&!I&&{members:h.map((t=>t.userId===i?{...t,bannedRights:o}:t))},...p&&u&&{kickedMembers:u.filter((t=>t.userId!==i))}}),(0,b.UF)(t)})),(0,b.aJ)("updateChatAdmin",(async(t,e,a)=>{const{chatId:s,userId:i,adminRights:o,customTitle:d,tabId:n=(0,c.g0)()}=a,r=(0,y.mBe)(t,i);if(!r)return;const l=await E(t,e,s,n);if(!l)return;await(0,g.px)("updateChatAdmin",{chat:l,user:r,adminRights:o,customTitle:d});const h=await(0,g.px)("fetchFullChat",l);if(!h?.fullInfo)return;const{adminMembersById:u}=h.fullInfo,I=!Object.keys(o).length;let p;if(u)if(I){const{[i]:t,...e}=u;p=e}else p={...u,[i]:{...u[i],adminRights:o,customTitle:d}};p&&(t=(0,b.mS)(),t=(0,C.ltr)(t,l.id,{adminMembersById:p}),(0,b.UF)(t))})),(0,b.aJ)("updateChat",(async(t,e,a)=>{const{chatId:s,title:o,about:d,photo:n,tabId:r=(0,c.g0)()}=a,l=(0,y.hds)(t,s),h=(0,y.AWZ)(t,s);l&&(t=(0,b.mS)(),t=(0,C.G42)(t,i.TD.InProgress,r),(0,b.UF)(t),await Promise.all([l.title!==o?(0,g.px)("updateChatTitle",l,o):void 0,h?.about!==d?(0,g.px)("updateChatAbout",l,d):void 0,n?(0,g.px)("editChatPhoto",{chatId:s,accessHash:l.accessHash,photo:n}):void 0]),t=(0,b.mS)(),t=(0,C.G42)(t,i.TD.Complete,r),(0,b.UF)(t),n&&e.loadFullChat({chatId:s,withPhotos:!0}))})),(0,b.aJ)("updateChatPhoto",(async(t,e,a)=>{const{photo:s,chatId:i}=a,o=(0,y.hds)(t,i);o&&(await(0,g.px)("editChatPhoto",{chatId:i,accessHash:o.accessHash,photo:s}),e.loadFullChat({chatId:i,withPhotos:!0}))})),(0,b.aJ)("deleteChatPhoto",(async(t,e,a)=>{const{photo:s,chatId:i}=a,o=(0,y.hds)(t,i);if(!o)return;let d;d=s.id===o.avatarPhotoId?await(0,g.px)("editChatPhoto",{chatId:i,accessHash:o.accessHash}):await(0,g.px)("deleteProfilePhotos",[s]),d&&(t=(0,b.mS)(),t=(0,C.sol)(t,i,s.id),(0,b.UF)(t),e.loadFullChat({chatId:i,withPhotos:!0}))})),(0,b.aJ)("toggleSignatures",((t,e,a)=>{const{chatId:s,areProfilesEnabled:i,areSignaturesEnabled:o}=a,d=(0,y.hds)(t,s);d&&(0,g.px)("toggleSignatures",{chat:d,areProfilesEnabled:i,areSignaturesEnabled:o})})),(0,b.aJ)("loadGroupsForDiscussion",(async t=>{const e=await(0,g.px)("fetchGroupsForDiscussion");if(!e)return;const a=e.reduce(((t,e)=>(e&&!e.isForum&&(t[e.id]=e),t)),{});t=(0,b.mS)(),t={...t,chats:{...t.chats,forDiscussionIds:Object.keys(a)}},(0,b.UF)(t)})),(0,b.aJ)("linkDiscussionGroup",(async(t,e,a)=>{const{channelId:s,chatId:i,tabId:o=(0,c.g0)()}=a||{},d=(0,y.hds)(t,s);if(!d)return;const n=await E(t,e,i,o);if(!n)return;let r=(0,y.AWZ)(t,n.id);if(!r){const t=await(0,g.px)("fetchFullChat",n);if(!t)return;r=t.fullInfo}r.isPreHistoryHidden&&(t=(0,b.mS)(),t=(0,C.ltr)(t,n.id,{isPreHistoryHidden:!1}),(0,b.UF)(t),await(0,g.px)("togglePreHistoryHidden",{chat:n,isEnabled:!1})),(0,g.px)("setDiscussionGroup",{channel:d,chat:n})})),(0,b.aJ)("unlinkDiscussionGroup",(async(t,e,a)=>{const{channelId:s}=a,i=(0,y.hds)(t,s);if(!i)return;const o=(0,y.AWZ)(t,s);let d;o?.linkedChatId&&(d=(0,y.hds)(t,o.linkedChatId)),await(0,g.px)("setDiscussionGroup",{channel:i}),d&&M(t=(0,b.mS)(),e,d)})),(0,b.aJ)("setActiveChatFolder",((t,e,a)=>{const{activeChatFolder:s,tabId:i=(0,c.g0)()}=a;if(!(s+1>(0,F.d)(t,"dialogFilters")))return(0,w.w)(t,{activeChatFolder:s},i);e.openLimitReachedModal({limit:"dialogFilters",tabId:i})})),(0,b.aJ)("resetOpenChatWithDraft",((t,e,a)=>{const{tabId:s=(0,c.g0)()}=a||{};return(0,w.w)(t,{requestedDraft:void 0},s)})),(0,b.aJ)("loadMoreMembers",(async(t,e,a)=>{const{tabId:s=(0,c.g0)()}=a||{},{chatId:i}=(0,y.Xf0)(t,s)||{},o=i?(0,y.hds)(t,i):void 0;if(!o||(0,f.yn$)(o))return;const d=(0,y.AWZ)(t,o.id)?.members?.length;if(void 0!==d&&void 0!==o.membersCount&&d>=o.membersCount)return;const n=await(0,g.px)("fetchMembers",{chat:o,offset:d});if(!n)return;const{members:r,userStatusesById:l}=n;r&&r.length&&(t=(0,b.mS)(),t=(0,C.d2X)(t,l),t=(0,C.t_k)(t,o,r),(0,b.UF)(t))})),(0,b.aJ)("addChatMembers",(async(t,e,a)=>{const{chatId:s,memberIds:o,tabId:d=(0,c.g0)()}=a,n=(0,y.hds)(t,s),r=o.map((e=>(0,y.mBe)(t,e))).filter(Boolean);if(!n||!r.length)return;e.setNewChatMembersDialogState({newChatMembersProgress:i.D7.Loading,tabId:d});const l=await(0,g.px)("addChatMembers",n,r);l&&(t=(0,b.mS)(),t=(0,C.hQe)(t,s,l,d),(0,b.UF)(t)),e.setNewChatMembersDialogState({newChatMembersProgress:i.D7.Closed,tabId:d}),M(t=(0,b.mS)(),e,n)})),(0,b.aJ)("deleteChatMember",(async(t,e,a)=>{const{chatId:s,userId:i}=a,o=(0,y.hds)(t,s),d=(0,y.mBe)(t,i);o&&d&&(await(0,g.px)("deleteChatMember",o,d),M(t=(0,b.mS)(),e,o))})),(0,b.aJ)("toggleIsProtected",((t,e,a)=>{const{chatId:s,isProtected:i}=a,o=(0,y.hds)(t,s);o&&(0,g.px)("toggleIsProtected",{chat:o,isProtected:i})})),(0,b.aJ)("setChatEnabledReactions",(async(t,e,a)=>{const{chatId:s,enabledReactions:i,reactionsLimit:o}=a,d=(0,y.hds)(t,s);d&&(await(0,g.px)("setChatEnabledReactions",{chat:d,enabledReactions:i,reactionsLimit:o}),M(t=(0,b.mS)(),e,d))})),(0,b.aJ)("fetchChat",((t,e,a)=>{const{chatId:s}=a;if(!(0,y.hds)(t,s))if((0,y.nZ4)(t,s))(0,g.px)("fetchChat",{type:"self"});else{const e=(0,y.mBe)(t,s);e&&(0,g.px)("fetchChat",{type:"user",user:e})}})),(0,b.aJ)("loadChatSettings",(async(t,e,a)=>{const{chatId:s}=a,i=(0,y.hds)(t,s);if(!i)return;const o=await(0,g.px)("fetchChatSettings",i);if(!o)return;const{settings:d}=o;t=(0,b.mS)(),t=(0,C.wix)(t,i.id,{settings:d}),(0,b.UF)(t)})),(0,b.aJ)("toggleJoinToSend",(async(t,e,a)=>{const{chatId:s,isEnabled:i}=a,o=(0,y.hds)(t,s);o&&((0,f.VsK)(o)||(0,f.WXB)(o))&&await(0,g.px)("toggleJoinToSend",o,i)})),(0,b.aJ)("toggleJoinRequest",(async(t,e,a)=>{const{chatId:s,isEnabled:i}=a,o=(0,y.hds)(t,s);o&&((0,f.VsK)(o)||(0,f.WXB)(o))&&await(0,g.px)("toggleJoinRequest",o,i)})),(0,b.aJ)("openForumPanel",((t,e,a)=>{const{chatId:s,tabId:i=(0,c.g0)()}=a;return e.toggleStoryRibbon({isShown:!1,tabId:i}),e.toggleStoryRibbon({isShown:!1,isArchived:!0,tabId:i}),(0,w.w)(t,{forumPanelChatId:s},i)})),(0,b.aJ)("closeForumPanel",((t,e,a)=>{const{tabId:s=(0,c.g0)()}=a||{};return(0,w.w)(t,{forumPanelChatId:void 0},s)})),(0,b.aJ)("processAttachBotParameters",(async(t,e,a)=>{const{username:s,filter:i,startParam:o,tabId:d=(0,c.g0)()}=a,n=await B(t,e,s,d);if(!n)return;if(!Boolean(i))return void e.callAttachBot({isFromSideMenu:!0,bot:n,startParam:o,tabId:d});t=(0,b.mS)();const{attachMenu:{bots:r}}=t;if(!r[n.id])return t=(0,w.w)(t,{requestedAttachBotInstall:{bot:n,onConfirm:{action:"requestAttachBotInChat",payload:{bot:n,filter:i,startParam:o}}}},d),void(0,b.UF)(t);e.requestAttachBotInChat({bot:n,filter:i,startParam:o,tabId:d})})),(0,b.aJ)("loadTopics",(async(t,e,a)=>{const{chatId:s,force:i}=a,d=(0,y.hds)(t,s);if(!d)return;const n=(0,y.xyP)(t,s);if(!i&&n?.listedTopicIds&&n.listedTopicIds.length===n.totalCount)return;const r=i?void 0:n?.listedTopicIds?.reduce(((e,a)=>{const i=(0,y.S0q)(t,s,a),o=(0,y.S0q)(t,s,e);return i&&(!o||i.lastMessageId<o.lastMessageId)?a:e})),{id:c,date:l,lastMessageId:h}=r&&(0,y.S0q)(t,s,r)||{},u=await(0,g.px)("fetchTopics",{chat:d,offsetTopicId:c,offsetId:h,offsetDate:l,limit:c?o.iIc:o.qj6});u&&(t=(0,b.mS)(),t=(0,C.KcS)(t,u.messages),t=(0,C.mIA)(t,s,u.count,u.topics),t=(0,C.Y4o)(t,s,u.topics.map((t=>t.id))),Object.entries(u.draftsById||{}).forEach((([e,a])=>{t=(0,C.eww)(t,s,Number(e),"draft",a)})),Object.entries(u.readInboxMessageIdByTopicId||{}).forEach((([e,a])=>{t=(0,C.eAk)(t,s,Number(e),{lastReadInboxMessageId:a})})),(0,b.UF)(t))})),(0,b.aJ)("loadTopicById",(async(t,e,a)=>{const{chatId:s,topicId:i}=a,o=(0,y.hds)(t,s);if(!o)return;const d=await(0,g.px)("fetchTopicById",{chat:o,topicId:i});if(d)t=(0,b.mS)(),t=(0,C.KcS)(t,d.messages),t=(0,C.TwA)(t,s,i,d.topic),(0,b.UF)(t);else if("tabId"in a&&a.shouldCloseChatOnError){const{tabId:t=(0,c.g0)()}=a;e.openChat({id:void 0,tabId:t})}})),(0,b.aJ)("toggleForum",(async(t,e,a)=>{const{chatId:s,isEnabled:i,tabId:o=(0,c.g0)()}=a,d=await E(t,e,s,o);if(!d)return;let n;try{n=await(0,g.px)("toggleForum",{chat:d,isEnabled:i})}catch(t){"FLOOD"===t.message?e.showNotification({message:I.yE("FloodWait"),tabId:o}):e.showDialog({data:{...t,hasErrorKey:!0},tabId:o})}n&&(t=(0,b.mS)(),t=(0,C.wix)(t,d.id,{isForum:i}),(0,b.UF)(t),i?e.openForumPanel({chatId:d.id,tabId:o}):e.closeForumPanel({tabId:o}))})),(0,b.aJ)("toggleParticipantsHidden",(async(t,e,a)=>{const{chatId:s,isEnabled:i}=a,o=(0,y.hds)(t,s);if(!o)return;const d=(0,y.AWZ)(t,o.id)?.areParticipantsHidden;t=(0,C.ltr)(t,s,{areParticipantsHidden:i}),(0,b.UF)(t),await(0,g.px)("toggleParticipantsHidden",{chat:o,isEnabled:i})||void 0===d||(t=(0,b.mS)(),t=(0,C.ltr)(t,s,{areParticipantsHidden:d}),(0,b.UF)(t))})),(0,b.aJ)("createTopic",(async(t,e,a)=>{const{chatId:s,title:i,iconColor:o,iconEmojiId:d,tabId:n=(0,c.g0)()}=a,r=(0,y.hds)(t,s);if(!r)return;(0,y.nTw)(t,n).createTopicPanel&&(t=(0,w.w)(t,{createTopicPanel:{chatId:s,isLoading:!0}},n),(0,b.UF)(t));const l=await(0,g.px)("createTopic",{chat:r,title:i,iconColor:o,iconEmojiId:d});l&&e.openThread({chatId:s,threadId:l,shouldReplaceHistory:!0,tabId:n}),e.closeCreateTopicPanel({tabId:n})})),(0,b.aJ)("deleteTopic",(async(t,e,a)=>{const{chatId:s,topicId:i}=a,o=(0,y.hds)(t,s);o&&(await(0,g.px)("deleteTopic",{chat:o,topicId:i}),t=(0,b.mS)(),t=(0,C.do9)(t,s,i),(0,b.UF)(t))})),(0,b.aJ)("editTopic",(async(t,e,a)=>{const{chatId:s,topicId:i,tabId:o=(0,c.g0)(),...d}=a,n=(0,y.hds)(t,s),r=(0,y.S0q)(t,s,i);n&&r&&((0,y.nTw)(t,o).editTopicPanel&&(t=(0,w.w)(t,{editTopicPanel:{chatId:s,topicId:i,isLoading:!0}},o),(0,b.UF)(t)),await(0,g.px)("editTopic",{chat:n,topicId:i,...d})&&(t=(0,b.mS)(),t=(0,C.TwA)(t,s,i,d),(0,b.UF)(t),e.closeEditTopicPanel({tabId:o})))})),(0,b.aJ)("toggleTopicPinned",((t,e,a)=>{const{chatId:s,topicId:i,isPinned:o,tabId:d=(0,c.g0)()}=a,{topicsPinnedLimit:n}=t.appConfig||{},r=(0,y.hds)(t,s),l=(0,y.pSx)(t,s);r&&l&&n&&(o&&Object.values(l).filter((t=>t.isPinned)).length>=n?e.showNotification({message:I.yE("LimitReachedPinnedTopics",n,"i"),tabId:d}):(0,g.px)("togglePinnedTopic",{chat:r,topicId:i,isPinned:o}))})),(0,b.aJ)("checkChatlistInvite",(async(t,e,a)=>{const{slug:s,tabId:i=(0,c.g0)()}=a,o=await(0,g.px)("checkChatlistInvite",{slug:s});o?(t=(0,b.mS)(),t=(0,w.w)(t,{chatlistModal:{invite:o.invite}},i),(0,b.UF)(t)):e.showNotification({message:I.yE("lng_group_invite_bad_link"),tabId:i})})),(0,b.aJ)("joinChatlistInvite",(async(t,e,a)=>{const{invite:s,peerIds:i,tabId:o=(0,c.g0)()}=a,d=i.map((e=>(0,y.hds)(t,e))).filter(Boolean),n=d.filter((t=>t.isNotJoined)).length,r="folderId"in s?(0,y.$aQ)(t,s.folderId):void 0,l="title"in s?s.title:r?.title;try{if(!await(0,g.px)("joinChatlistInvite",{slug:s.slug,peers:d}))return;if(r)return void e.showNotification({title:{key:"FolderLinkNotificationUpdatedTitle",variables:{title:l.text}},message:{key:"FolderLinkNotificationUpdatedSubtitle",variables:{count:n},options:{pluralValue:n}},tabId:o});e.showNotification({title:{key:"FolderLinkNotificationAddedTitle",variables:{title:l.text}},message:{key:"FolderLinkNotificationAddedSubtitle",variables:{count:n},options:{pluralValue:n}},tabId:o})}catch(t){"CHATLISTS_TOO_MUCH"===t.message?e.openLimitReachedModal({limit:"chatlistJoined",tabId:o}):e.showDialog({data:{...t,hasErrorKey:!0},tabId:o})}})),(0,b.aJ)("leaveChatlist",(async(t,e,a)=>{const{folderId:s,peerIds:i,tabId:o=(0,c.g0)()}=a,d=(0,y.$aQ)(t,s),n=i?.map((e=>(0,y.hds)(t,e))).filter(Boolean)||[];await(0,g.px)("leaveChatlist",{folderId:s,peers:n})&&d&&e.showNotification({title:{key:"FolderLinkNotificationDeletedTitle",variables:{title:d.title.text}},message:{key:"FolderLinkNotificationDeletedSubtitle",variables:{count:n.length},options:{pluralValue:n.length}},tabId:o})})),(0,b.aJ)("loadChatlistInvites",(async(t,e,a)=>{const{folderId:s}=a,i=await(0,g.px)("fetchChatlistInvites",{folderId:s});i&&(t=(0,b.mS)(),t={...t,chatFolders:{...t.chatFolders,invites:{...t.chatFolders.invites,[s]:i.invites}}},(0,b.UF)(t))})),(0,b.aJ)("createChatlistInvite",(async(t,e,a)=>{const{folderId:s,tabId:o=(0,c.g0)()}=a,d=(0,y.$aQ)(t,s);if(!d)return;let n;t=(0,w.w)(t,{shareFolderScreen:{...(0,y.nTw)(t,o).shareFolderScreen,isLoading:!0}},o),(0,b.UF)(t);try{n=await(0,g.px)("createChalistInvite",{folderId:s,peers:d.includedChatIds.concat(d.pinnedChatIds||[]).map((e=>(0,y.hds)(t,e)||(0,y.mBe)(t,e))).filter(Boolean)})}catch(t){S.has(t.message)?(e.openLimitReachedModal({limit:"chatlistInvites",tabId:o}),e.requestNextSettingsScreen({screen:i.VS.Folders,tabId:o})):e.showDialog({data:{...t,hasErrorKey:!0},tabId:o})}if(!n||!n.invite)return;const{shareFolderScreen:r}=(0,y.nTw)(t,o);r&&(t=(0,b.mS)(),t={...t,chatFolders:{...t.chatFolders,byId:{...t.chatFolders.byId,[s]:{...t.chatFolders.byId[s],...n.filter}},invites:{...t.chatFolders.invites,[s]:[...t.chatFolders.invites[s]||[],n.invite]}}},t=(0,w.w)(t,{shareFolderScreen:{...r,url:n.invite.url,isLoading:!1}},o),(0,b.UF)(t))})),(0,b.aJ)("editChatlistInvite",(async(t,e,a)=>{const{folderId:s,peerIds:i,url:o,tabId:d=(0,c.g0)()}=a,n=o.split("/").pop();if(!n)return;const r=i.map((e=>(0,y.hds)(t,e)||(0,y.mBe)(t,e))).filter(Boolean);t=(0,w.w)(t,{shareFolderScreen:{...(0,y.nTw)(t,d).shareFolderScreen,isLoading:!0}},d),(0,b.UF)(t);try{const e=await(0,g.px)("editChatlistInvite",{folderId:s,slug:n,peers:r});if(!e)return;t=(0,b.mS)(),t={...t,chatFolders:{...t.chatFolders,invites:{...t.chatFolders.invites,[s]:t.chatFolders.invites[s]?.map((t=>t.url===o?e:t))}}},(0,b.UF)(t)}catch(t){e.showDialog({data:{...t,hasErrorKey:!0},tabId:d})}finally{t=(0,b.mS)(),t=(0,w.w)(t,{shareFolderScreen:{...(0,y.nTw)(t,d).shareFolderScreen,isLoading:!1}},d),(0,b.UF)(t)}})),(0,b.aJ)("deleteChatlistInvite",(async(t,e,a)=>{const{folderId:s,url:i}=a,o=i.split("/").pop();o&&await(0,g.px)("deleteChatlistInvite",{folderId:s,slug:o})&&(t=(0,b.mS)(),t={...t,chatFolders:{...t.chatFolders,invites:{...t.chatFolders.invites,[s]:t.chatFolders.invites[s]?.filter((t=>t.url!==i))}}},(0,b.UF)(t))})),(0,b.aJ)("openDeleteChatFolderModal",(async(t,e,a)=>{const{folderId:s,isConfirmedForChatlist:i,tabId:o=(0,c.g0)()}=a,d=(0,y.$aQ)(t,s);if(d){if(d.isChatList&&(!d.hasMyInvites||i)){const e=(0,l.YA)(s),a=await(0,g.px)("fetchLeaveChatlistSuggestions",{folderId:s});return t=(0,b.mS)(),t=(0,w.w)(t,{chatlistModal:{removal:{folderId:s,suggestedPeerIds:(0,h.Am)([...a||[],...e||[]])}}},o),void(0,b.UF)(t)}t=(0,w.w)(t,{deleteFolderDialogModal:s},o),(0,b.UF)(t)}})),(0,b.aJ)("updateChatDetectedLanguage",((t,e,a)=>{const{chatId:s,detectedLanguage:i}=a;return t=(0,b.mS)(),(0,C.wix)(t,s,{detectedLanguage:i},void 0,!0)})),(0,b.aJ)("togglePeerTranslations",(async(t,e,a)=>{const{chatId:s,isEnabled:i}=a,o=(0,y.hds)(t,s);o&&void 0!==await(0,g.px)("togglePeerTranslations",{chat:o,isEnabled:i})&&(t=(0,b.mS)(),t=(0,C.zTz)(t,s,{isTranslationDisabled:!i||void 0}),(0,b.UF)(t))})),(0,b.aJ)("setViewForumAsMessages",((t,e,a)=>{const{chatId:s,isEnabled:i}=a,o=(0,y.hds)(t,s);o?.isForum&&o.isForumAsMessages!==i&&(t=(0,C.wix)(t,s,{isForumAsMessages:i||void 0}),(0,b.UF)(t),(0,g.px)("setViewForumAsMessages",{chat:o,isEnabled:i}))})),(0,b.aJ)("loadChannelRecommendations",(async(t,e,a)=>{const{chatId:s}=a,i=s?(0,y.hds)(t,s):void 0;if(s&&!i)return;if(!s&&(0,y.dg4)(t,o.rBM))return;const d=await(0,g.px)("fetchChannelRecommendations",{chat:i});if(!d)return;const{similarChannels:n,count:r}=d,c=(0,h.dU)(n,"id");t=(0,b.mS)(),t=(0,C.czZ)(t,s||o.rBM,Object.keys(c),r),(0,b.UF)(t)})),(0,b.aJ)("loadBotRecommendations",(async(t,e,a)=>{const{userId:s}=a,i=(0,y.hds)(t,s);if(!i)return;const o=await(0,g.px)("fetchBotsRecommendations",{user:i});if(!o)return;const{similarBots:d,count:n}=o,r=(0,h.dU)(d,"id");t=(0,b.mS)(),t=(0,C.g18)(t,r),t=(0,C.tNY)(t,s,Object.keys(r),n),(0,b.UF)(t)})),(0,b.aJ)("toggleChannelRecommendations",((t,e,a)=>{const{chatId:s}=a;(0,y.hds)(t,s)&&(t=(0,C.Cbr)(t,s),(0,b.UF)(t))})),(0,b.aJ)("resolveBusinessChatLink",(async(t,e,a)=>{const{slug:s,tabId:i=(0,c.g0)()}=a,o=await(0,g.px)("resolveBusinessChatLink",{slug:s});if(!o)return void e.showNotification({message:I.yE("BusinessLink.ErrorExpired"),tabId:i});const{chatLink:d}=o;e.openChatWithDraft({chatId:d.chatId,text:d.text,tabId:i})})),(0,b.aJ)("requestCollectibleInfo",(async(t,e,a)=>{const{type:s,collectible:i,peerId:o,tabId:n=(0,c.g0)()}=a;let r;if("phone"===s&&(r={phone:i}),"username"===s&&(r={username:i}),!r)return;const l=await(0,g.px)("fetchCollectionInfo",r);l?(t=(0,b.mS)(),t=(0,w.w)(t,{collectibleInfoModal:{...l,type:s,collectible:i,peerId:o}},n),(0,b.UF)(t)):(0,d.eM)(i)}))},12859:(t,e,a)=>{a.d(e,{Hc:()=>U,JD:()=>v,cw:()=>y,ow:()=>P,re:()=>T,sN:()=>x});var s=a(66644),i=a(85982),o=a(14487),d=a(87894),n=a(6e4),r=a(41733),c=a(82393),l=a(4875),h=a(90709),u=a(13439),I=a(80840),p=a(32989),m=a(29807),g=a(71331),f=a(42347);const b="data:audio/mpeg;base64,SUQzBAAAAAABEVRYWFgAAAAtAAADY29tbWVudABCaWdTb3VuZEJhbmsuY29tIC8gTGFTb25vdGhlcXVlLm9yZwBURU5DAAAAHQAAA1N3aXRjaCBQbHVzIMKpIE5DSCBTb2Z0d2FyZQBUSVQyAAAABgAAAzIyMzUAVFNTRQAAAA8AAANMYXZmNTcuODMuMTAwAAAAAAAAAAAAAAD/80DEAAAAA0gAAAAATEFNRTMuMTAwVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/zQsRbAAADSAAAAABVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/zQMSkAAADSAAAAABVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";let C,V,w;function y(){return v(),Promise.all(Object.values(w).map((t=>{const e=t.src;return t.src=b,t.muted=!0,t.volume=1e-4,t.play().then((()=>{t.pause(),t.volume=1,t.currentTime=0,t.muted=!1,(0,s.Uz)((()=>{t.src=e}))}))})))}function v(){if(w)return;const t=new Audio("./voicechat_join.mp3"),e=new Audio("./voicechat_connecting.mp3");e.loop=!0;const a=new Audio("./voicechat_leave.mp3"),s=new Audio("./voicechat_onallowtalk.mp3"),i=new Audio("./call_busy.mp3"),o=new Audio("./call_connect.mp3"),d=new Audio("./call_end.mp3"),n=new Audio("./call_incoming.mp3");n.loop=!0;const r=new Audio("./call_ringing.mp3");r.loop=!0,w={join:t,allowTalk:s,leave:a,connecting:e,incoming:n,end:d,connect:o,busy:i,ringing:r}}async function F(t,e){const a=await(0,l.px)("getGroupCall",{call:e});if(!a)return;t=(0,u.mS)();const s=(0,g.Ip)(t,e.id);return t=(0,I.h9)(t,e.id,(0,d.cJ)(a.groupCall,["connectionState"]),void 0,s?.isLoaded?void 0:a.groupCall.participantsCount),(0,u.UF)(t),a.groupCall}function S(t,e){return(0,l.px)("fetchGroupCallParticipants",{call:t,offset:e})}(0,u.aJ)("toggleGroupCallPanel",((t,e,a)=>{const{force:s,tabId:i=(0,o.g0)()}=a||{};return(0,p.w)(t,{isCallPanelVisible:"force"in(a||{})?s:!(0,m.nTw)(t,i).isCallPanelVisible},i)})),(0,u.aJ)("subscribeToGroupCallUpdates",(async(t,e,a)=>{const{subscribed:s,id:i}=a,o=(0,g.Ip)(t,i);o&&(s&&(await F(t,o),t=(0,u.mS)(),await S(o)),await(0,l.px)("toggleGroupCallStartSubscription",{subscribed:s,call:o}))})),(0,u.aJ)("createGroupCall",(async(t,e,a)=>{const{chatId:s,tabId:i=(0,o.g0)()}=a,d=(0,m.hds)(t,s);if(!d)return;const n=await(0,l.px)("createGroupCall",{peer:d});n&&(t=(0,u.mS)(),t=(0,I.h9)(t,n.id,{...n,chatId:s}),(0,u.UF)(t),e.requestMasterAndJoinGroupCall({id:n.id,accessHash:n.accessHash,tabId:i}))})),(0,u.aJ)("createGroupCallInviteLink",(async(t,e,a)=>{const{tabId:s=(0,o.g0)()}=a||{},d=(0,g.iT)(t);if(!d||!d.chatId)return;const n=(0,m.hds)(t,d.chatId);if(!n)return;const r=Boolean((0,h.KlG)(n));let c=(0,m.AWZ)(t,n.id)?.inviteLink;r&&(c=await(0,l.px)("exportGroupCallInvite",{call:d,canSelfUnmute:!1})),c&&((0,i.eM)(c),e.showNotification({message:{key:"LinkCopied"},tabId:s}))})),(0,u.aJ)("joinVoiceChatByLink",(async(t,e,a)=>{const{username:s,inviteHash:i,tabId:d=(0,o.g0)()}=a,r=await(0,f.A$)(t,s);if(!r)return void e.showNotification({message:n.yE("NoUsernameFound"),tabId:d});t=(0,u.mS)();const c=await(0,f.ad)(t,e,r);c?.groupCall&&e.requestMasterAndJoinGroupCall({id:c.groupCall.id,accessHash:c.groupCall.accessHash,inviteHash:i,tabId:d})})),(0,u.aJ)("requestMasterAndJoinGroupCall",((t,e,a)=>{e.requestMasterAndCallAction({action:"joinGroupCall",payload:a,tabId:a.tabId||(0,o.g0)()})})),(0,u.aJ)("requestMasterAndAcceptCall",((t,e,a)=>{e.requestMasterAndCallAction({action:"acceptCall",payload:void 0,tabId:a?.tabId||(0,o.g0)()})})),(0,u.aJ)("joinGroupCall",(async(t,e,a)=>{const{chatId:s,id:i,accessHash:d,inviteHash:n,tabId:l=(0,o.g0)()}=a;if(!c.OL)return void e.showNotification({message:"Sorry, your browser doesn't support group calls",tabId:l});if(t.phoneCall)return void e.toggleGroupCallPanel({tabId:l});!function(){const t=new(window.AudioContext||window.webkitAudioContext);C=new Audio,V=t,C.srcObject=A(t),(0,r.A)(C)}(),v(),T(t=(0,u.mS)(),e,!0,l);const{groupCalls:{activeGroupCallId:h}}=t;let p=i?(0,g.Ip)(t,i):(0,g.mD)(t,s);if(p&&p.id===h)e.toggleGroupCallPanel({tabId:l});else if(h)"leaveGroupCall"in e&&e.leaveGroupCall({rejoin:a,tabId:l});else if(p&&h===p.id)e.toggleGroupCallPanel({tabId:l});else{if(p||i&&d||!s)!p&&i&&d&&(p=await F(t,{id:i,accessHash:d}));else{const a=(0,m.hds)(t,s);if(!a)return;await(0,f.ad)(t,e,a),t=(0,u.mS)(),p=(0,g.mD)(t,s)}p&&(t=(0,u.mS)(),t=(0,I.h9)(t,p.id,{...p,inviteHash:n},void 0,p.participantsCount+1),t={...t,groupCalls:{...t.groupCalls,activeGroupCallId:p.id}},(0,u.UF)(t),e.toggleGroupCallPanel({force:!1,tabId:l}))}})),(0,u.aJ)("playGroupCallSound",((t,e,a)=>{const{sound:s}=a;w[s]&&("connecting"!==s&&w.connecting.pause(),"incoming"!==s&&w.incoming.pause(),"ringing"!==s&&w.ringing.pause(),(0,r.A)(w[s]))})),(0,u.aJ)("loadMoreGroupCallParticipants",(t=>{const e=(0,g.iT)(t);e&&S(e,e.nextOffset)})),(0,u.aJ)("requestMasterAndRequestCall",((t,e,a)=>{e.requestMasterAndCallAction({action:"requestCall",payload:a,tabId:a.tabId||(0,o.g0)()})})),(0,u.aJ)("requestCall",((t,e,a)=>{const{userId:s,isVideo:i,tabId:d=(0,o.g0)()}=a;t.phoneCall?e.toggleGroupCallPanel({tabId:d}):(0,m.mBe)(t,s)&&(v(),T(t=(0,u.mS)(),e,i,d),t=(0,u.mS)(),t={...t,phoneCall:{id:"",state:"requesting",participantId:s,isVideo:i,adminId:t.currentUserId}},(0,u.UF)(t),e.toggleGroupCallPanel({force:!1,tabId:d}))}));const A=t=>{const e=t.createOscillator(),a=e.connect(t.createMediaStreamDestination());return e.start(),new MediaStream([Object.assign(a.stream.getAudioTracks()[0],{enabled:!1})])};function x(){return C}function U(){return V}function P(){C?.pause(),V=void 0,C=void 0}function T(t,e,a,...[s=(0,o.g0)()]){a?navigator.mediaDevices.getUserMedia({video:!0}).then((t=>{0===t.getVideoTracks().length?e.showNotification({message:n.yE("Call.Camera.Error"),tabId:s}):(t.getTracks().forEach((t=>t.stop())),M(0,e,s))})).catch((()=>{e.showNotification({message:n.yE("Call.Camera.Error"),tabId:s})})):M(0,e,s)}function M(t,e,...[a=(0,o.g0)()]){navigator.mediaDevices.getUserMedia({audio:!0}).then((t=>{0===t.getAudioTracks().length?e.showNotification({message:n.yE("RequestAcces.Error.HaveNotAccess.Call"),tabId:a}):t.getTracks().forEach((t=>t.stop()))})).catch((()=>{e.showNotification({message:n.yE("RequestAcces.Error.HaveNotAccess.Call"),tabId:a})}))}},80840:(t,e,a)=>{a.d(e,{R6:()=>c,c5:()=>l,h9:()=>n,um:()=>r});var s=a(87894),i=a(29807),o=a(71331),d=a(16350);function n(t,e,a,i,o){const d=Object.values({...t.groupCalls.byId[e]?.participants,...a.participants}).filter((({isLeft:t})=>!t)).reduce(((t,e)=>(t[e.id]=e,t)),{});return{...t,groupCalls:{...t.groupCalls,byId:{...t.groupCalls.byId,[e]:{...t.groupCalls.byId[e],...(0,s.cJ)(a,["participantsCount"]),...i&&{participantsCount:t.groupCalls.byId[e].participantsCount+i},...void 0!==o&&{participantsCount:o},participants:d}}}}}function r(t,e){const a=(0,o.Ip)(t,e);return a&&a.chatId&&(0,i.hds)(t,a.chatId)&&(t=(0,d.lt)(t,a.chatId,{groupCallId:void 0})),{...t,groupCalls:{...t.groupCalls,byId:{...(0,s.cJ)(t.groupCalls.byId,[e.toString()])}}}}function c(t,e,a){return t.groupCalls.activeGroupCallId?n(t,t.groupCalls.activeGroupCallId,e,void 0,a):t}function l(t,e,a,s,i=!1){const d=(0,o.Ip)(t,e);return d?n(t,e,{participants:{...d.participants,[a]:{...d.participants[a],...s}}},s.isLeft?i?0:-1:d.participants[a]||i?0:1):t}}}]);
|
|
//# sourceMappingURL=2859.7710f39d0f624b3513d4.js.map
|