mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-15 02:37:17 +01:00
2 lines
24 KiB
JavaScript
2 lines
24 KiB
JavaScript
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[884],{2275:(t,e,a)=>{a.d(e,{Z:()=>h});var s=a(4050),o=a(5116),n=a(1638),i=a(2858),d=a(2340),r=a(9107),c=a(3103),l=a(231);const h=(0,s.X$)((0,o.c$)(((t,{userId:e})=>{const a=(0,n.jr)(t),s=e&&(0,n.dy)(t,e);return{chat:a,contactName:s?(0,i.Vl)(s):void 0}}))((({isOpen:t,chat:e,userId:a,contactName:n,onClose:i})=>{const{deleteChatMember:h}=(0,o.uC)(),u=(0,r.Z)(),p=(0,s.I4)((()=>{h({chatId:e.id,userId:a}),i()}),[e,h,i,a]);if(e&&a)return s.ZP.createElement(c.Z,{isOpen:t,onClose:i,onEnter:p,className:"delete",title:u("GroupRemoved.Remove")},s.ZP.createElement("p",null,(0,d.Z)(u("PeerInfo.Confirm.RemovePeer",n))),s.ZP.createElement(l.Z,{color:"danger",className:"confirm-dialog-button",isText:!0,onClick:p},u("lng_box_remove")),s.ZP.createElement(l.Z,{className:"confirm-dialog-button",isText:!0,onClick:i},u("Cancel")))})))},6071:(t,e,a)=>{a.d(e,{Z:()=>n});var s=a(4050),o=a(9118);const n=(t,e=!1)=>(0,s.Ye)((()=>(0,o.P2)((t=>t()),t,!e)),[t,e])},6204:(t,e,a)=>{a.d(e,{f:()=>y,C:()=>b});var s=a(5116),o=a(6137),n=a(1713),i=a(3716),d=a(1226),r=a(307),c=a(1638),l=a(782),h=a(9118),u=a(2858),p=a(3551),f=a(4446),C=a(2607);const I=(0,h.P2)((t=>t()),300,!0),m=(0,h.P2)((t=>t()),3e3,!0),g=(0,h.Ds)((t=>t()),500,!1,!0);async function v(t,e,a){var n;let h=(0,s.Rd)();const u=await(0,d.t9)("fetchChats",{limit:i.Ov,offsetDate:a,archived:"archived"===t,withPinned:void 0===h.chats.orderedPinnedIds[t],serverTimeOffset:h.serverTimeOffset,lastLocalServiceMessage:null===(n=(0,c.VF)(h))||void 0===n?void 0:n.message});if(!u)return;const{chatIds:p}=u;p.length>0&&p[0]===e&&p.shift(),h=(0,s.Rd)(),h=(0,r.Sh)(h,(0,l.ee)(u.users,"id")),h=(0,r.zn)(h,u.userStatusesById),h=(0,r.GL)(h,(0,l.ee)(u.chats,"id")),h=(0,r.B1)(h,t,p),h=(0,r.vv)(h,t,u),Object.keys(u.draftsById).forEach((t=>{h=(0,r.pf)(h,t,o._f,"draft",u.draftsById[t])})),Object.keys(u.replyingToById).forEach((t=>{h=(0,r.pf)(h,t,o._f,"replyingToId",u.replyingToById[t])})),0!==p.length||h.chats.isFullyLoaded[t]||(h={...h,chats:{...h.chats,isFullyLoaded:{...h.chats.isFullyLoaded,[t]:!0}}}),(0,s.R3)(h)}async function y(t){const e=await(0,d.t9)("fetchFullChat",t);if(!e)return;const{users:a,fullInfo:o,groupCall:n}=e;let i=(0,s.Rd)();if(a&&(i=(0,r.Sh)(i,(0,l.ee)(a,"id"))),n){const t=(0,C.$5)(i,n.id);i=(0,f.AH)(i,n.id,(0,l.CE)(n,["connectionState"]),void 0,t?void 0:n.participantsCount)}return i=(0,r.a4)(i,t.id,{fullInfo:o}),(0,s.R3)(i),e}async function b(t){const e=(0,s.Rd)(),a=(0,c.DI)(e,t);if(a&&!a.isMin)return a;const o=await(0,d.t9)("getChatByUsername",t);return o?((0,s.R3)((0,r.a4)((0,s.Rd)(),o.id,o)),o):void 0}(0,s.Q6)("preloadTopChatMessages",((t,e)=>{(async()=>{const a=[];for(let n=0;n<i.ul;n++){await(0,h.wO)(100);const{byId:n,listIds:{active:i},orderedPinnedIds:{active:d}}=(0,s.Rd)().chats;if(!i)return;const{chatId:r}=(0,c.Bt)(t)||{},{pinnedChats:l,otherChats:p}=(0,u.O)(n,i,d,"all",!0),f=[...l,...p].find((({id:t})=>t!==r&&!a.includes(t)));if(!f)return;a.push(f.id),e.loadViewportMessages({chatId:f.id,threadId:o._f})}})()})),(0,s.Q6)("openChat",((t,e,a)=>{const{id:s,threadId:n}=a,{currentUserId:i}=t,r=(0,c.Z1)(t,s);if(null!=r&&r.hasUnreadMark&&e.toggleChatUnread({id:s}),r&&r.lastMessage&&r.lastMessage.threadInfo&&e.requestThreadInfoUpdate({chatId:r.lastMessage.threadInfo.chatId,threadId:r.lastMessage.threadInfo.threadId}),r)(0,u.Hp)(r)&&!r.isMin&&e.requestChatUpdate({chatId:s});else if(s===i)(0,d.t9)("fetchChat",{type:"self"});else{const e=(0,c.dy)(t,s);e&&(0,d.t9)("fetchChat",{type:"user",user:e})}n!==o._f&&((0,c.qS)(t,s,n)||e.requestThreadInfoUpdate({chatId:s,threadId:n}))})),(0,s.Q6)("openLinkedChat",((t,e,a)=>{const{id:s}=a,o=(0,c.Z1)(t,s);o&&(async()=>{var t;const a=await(0,d.t9)("fetchFullChat",o);null!=a&&null!==(t=a.fullInfo)&&void 0!==t&&t.linkedChatId&&e.openChat({id:a.fullInfo.linkedChatId})})()})),(0,s.Q6)("focusMessageInComments",((t,e,a)=>{const{chatId:s,threadId:o,messageId:n}=a,i=(0,c.Z1)(t,s);i&&(async()=>{await(0,d.t9)("requestThreadInfoUpdate",{chat:i,threadId:o})&&e.focusMessage({chatId:s,threadId:o,messageId:n})})()})),(0,s.Q6)("openSupportChat",((t,e)=>{const a=(0,c.P_)(t);a?e.openChat({id:a.id,shouldReplaceHistory:!0}):(e.openChat({id:i.AJ,shouldReplaceHistory:!0}),(async()=>{const t=await(0,d.t9)("fetchChat",{type:"support"});t&&e.openChat({id:t.chatId,shouldReplaceHistory:!0})})())})),(0,s.Q6)("openTipsChat",((t,e,a)=>{const{langCode:s}=a,o="pt-br"===s?"BR":i.Db.includes(s)?s.toUpperCase():"";e.openChatByUsername({username:`${i.vi}${o}`})})),(0,s.Q6)("loadMoreChats",((t,e,a)=>{const{listType:s="active"}=a,o=t.chats.listIds[s];if(t.chats.isFullyLoaded[s])return;const n=o?o.map((e=>t.chats.byId[e])).filter((e=>Boolean(null==e?void 0:e.lastMessage)&&!(0,c.ep)(t,e.id))).sort(((t,e)=>t.lastMessage.date-e.lastMessage.date))[0]:void 0;I(n?()=>v(s,n.id,n.lastMessage.date):()=>v(s))})),(0,s.Q6)("preloadArchivedChats",(()=>{(async()=>{for(;!(0,s.Rd)().chats.isFullyLoaded.archived;){const t=(0,s.Rd)(),e=t.chats.listIds.archived,a=e?e.map((e=>t.chats.byId[e])).filter((e=>Boolean(null==e?void 0:e.lastMessage)&&!(0,c.ep)(t,e.id))).sort(((t,e)=>t.lastMessage.date-e.lastMessage.date))[0]:void 0;await v("archived",null==a?void 0:a.id,null==a?void 0:a.lastMessage.date),await(0,h.wO)(300)}})()})),(0,s.Q6)("loadFullChat",((t,e,a)=>{const{chatId:s,force:o}=a,n=(0,c.Z1)(t,s);n&&(o?y(n):g((()=>y(n))))})),(0,s.Q6)("loadTopChats",(()=>{m((()=>v("active")))})),(0,s.Q6)("requestChatUpdate",((t,e,a)=>{var s;const{serverTimeOffset:o}=t,{chatId:n}=a,r=(0,c.Z1)(t,n);r&&(0,d.t9)("requestChatUpdate",{chat:r,serverTimeOffset:o,...n===i.aw&&{lastLocalMessage:null===(s=(0,c.VF)(t))||void 0===s?void 0:s.message}})})),(0,s.Q6)("updateChatMutedState",((t,e,a)=>{const{serverTimeOffset:o}=t,{chatId:n,isMuted:i}=a,l=(0,c.Z1)(t,n);l&&((0,s.R3)((0,r.a4)(t,n,{isMuted:i})),(0,d.t9)("updateChatMutedState",{chat:l,isMuted:i,serverTimeOffset:o}))})),(0,s.Q6)("createChannel",((t,e,a)=>{const{title:o,about:i,photo:l,memberIds:h}=a;!async function(t,e,a,o){(0,s.R3)({...(0,s.Rd)(),chatCreation:{progress:n.Nh.InProgress}});const i=await(0,d.t9)("createChannel",{title:t,about:a,users:e});if(!i)return;const{id:c,accessHash:l}=i;let h=(0,s.Rd)();h=(0,r.a4)(h,c,i),h={...h,chatCreation:{...h.chatCreation,progress:i?n.Nh.Complete:n.Nh.Error}},(0,s.R3)(h),(0,s.uC)().openChat({id:c,shouldReplaceHistory:!0}),c&&l&&o&&await(0,d.t9)("editChatPhoto",{chatId:c,accessHash:l,photo:o})}(o,h.map((e=>(0,c.dy)(t,e))).filter(Boolean),i,l)})),(0,s.Q6)("joinChannel",((t,e,a)=>{const{chatId:s}=a,o=(0,c.Z1)(t,s);if(!o)return;const{id:n,accessHash:i}=o;n&&i&&(0,d.t9)("joinChannel",{channelId:n,accessHash:i})})),(0,s.Q6)("deleteChatUser",((t,e,a)=>{var o;const{chatId:n,userId:i}=a,l=(0,c.Z1)(t,n),h=(0,c.dy)(t,i);l&&h&&(t=(0,r.Dd)(t,n),(0,s.R3)(t),(null===(o=(0,c.Bt)(t))||void 0===o?void 0:o.chatId)===n&&e.openChat({id:void 0}),(0,d.t9)("deleteChatUser",{chat:l,user:h}))})),(0,s.Q6)("deleteChat",((t,e,a)=>{var o;const{chatId:n}=a,i=(0,c.Z1)(t,n);i&&(t=(0,r.Dd)(t,n),(0,s.R3)(t),(null===(o=(0,c.Bt)(t))||void 0===o?void 0:o.chatId)===n&&e.openChat({id:void 0}),(0,d.t9)("deleteChat",{chatId:i.id}))})),(0,s.Q6)("leaveChannel",((t,e,a)=>{var o;const{chatId:n}=a,i=(0,c.Z1)(t,n);if(!i)return;t=(0,r.Dd)(t,n),(0,s.R3)(t),(null===(o=(0,c.Bt)(t))||void 0===o?void 0:o.chatId)===n&&e.openChat({id:void 0});const{id:l,accessHash:h}=i;l&&h&&(0,d.t9)("leaveChannel",{channelId:l,accessHash:h})})),(0,s.Q6)("deleteChannel",((t,e,a)=>{var o;const{chatId:n}=a,i=(0,c.Z1)(t,n);if(!i)return;t=(0,r.Dd)(t,n),(0,s.R3)(t),(null===(o=(0,c.Bt)(t))||void 0===o?void 0:o.chatId)===n&&e.openChat({id:void 0});const{id:l,accessHash:h}=i;l&&h&&(0,d.t9)("deleteChannel",{channelId:l,accessHash:h})})),(0,s.Q6)("createGroupChat",((t,e,a)=>{const{title:o,memberIds:i,photo:l}=a;!async function(t,e,a){(0,s.R3)({...(0,s.Rd)(),chatCreation:{progress:n.Nh.InProgress}});try{const o=await(0,d.t9)("createGroupChat",{title:t,users:e});if(!o)return;const{id:i}=o;let c=(0,s.Rd)();c=(0,r.a4)(c,i,o),c={...c,chatCreation:{...c.chatCreation,progress:o?n.Nh.Complete:n.Nh.Error}},(0,s.R3)(c),(0,s.uC)().openChat({id:i,shouldReplaceHistory:!0}),i&&a&&await(0,d.t9)("editChatPhoto",{chatId:i,photo:a})}catch(t){if("USERS_TOO_FEW"===t.message){const t=(0,s.Rd)();(0,s.R3)({...t,chatCreation:{...t.chatCreation,progress:n.Nh.Error,error:"CreateGroupError"}})}}}(o,i.map((e=>(0,c.dy)(t,e))).filter(Boolean),l)})),(0,s.Q6)("toggleChatPinned",((t,e,a)=>{const{id:s,folderId:o}=a,n=(0,c.Z1)(t,s);if(n)if(o){const e=(0,c.Mw)(t,o);if(e){const a=!(0,c.ep)(t,s,o),{pinnedChatIds:n,includedChatIds:i}=e,r=a?[s,...n||[]]:(n||[]).filter((t=>t!==s)),l=[s,...i];(0,d.t9)("editChatFolder",{id:o,folderUpdate:{...e,pinnedChatIds:r,includedChatIds:l}})}}else{const e=(0,c.Ek)(t,s),a=(0,c.ep)(t,s,"archived"===e?i.WS:void 0);(0,d.t9)("toggleChatPinned",{chat:n,shouldBePinned:!a})}})),(0,s.Q6)("toggleChatArchived",((t,e,a)=>{const{id:s}=a,o=(0,c.Z1)(t,s);o&&(0,d.t9)("toggleChatArchived",{chat:o,folderId:(0,u.pE)(o)?0:i.WS})})),(0,s.Q6)("loadChatFolders",(()=>{!async function(){const t=await(0,d.t9)("fetchChatFolders");if(t){const e=(0,s.Rd)();(0,s.R3)({...e,chatFolders:{...e.chatFolders,...t}})}}()})),(0,s.Q6)("loadRecommendedChatFolders",(()=>{!async function(){const t=await(0,d.t9)("fetchRecommendedChatFolders");if(t){const e=(0,s.Rd)();(0,s.R3)({...e,chatFolders:{...e.chatFolders,recommended:t}})}}()})),(0,s.Q6)("editChatFolders",((t,e,a)=>{const{chatId:s,idsToRemove:o,idsToAdd:n}=a;o.forEach((async e=>{const a=(0,c.Mw)(t,e);var o;a&&await(0,d.t9)("editChatFolder",{id:e,folderUpdate:{...a,pinnedChatIds:null===(o=a.pinnedChatIds)||void 0===o?void 0:o.filter((t=>t!==s)),includedChatIds:a.includedChatIds.filter((t=>t!==s))}})})),n.forEach((async e=>{const a=(0,c.Mw)(t,e);a&&await(0,d.t9)("editChatFolder",{id:e,folderUpdate:{...a,includedChatIds:a.includedChatIds.concat(s)}})}))})),(0,s.Q6)("editChatFolder",((t,e,a)=>{const{id:s,folderUpdate:o}=a,n=(0,c.Mw)(t,s);n&&(0,d.t9)("editChatFolder",{id:s,folderUpdate:{id:s,emoticon:n.emoticon,pinnedChatIds:n.pinnedChatIds,...o}})})),(0,s.Q6)("addChatFolder",((t,e,a)=>{const{folder:o}=a,{orderedIds:n}=t.chatFolders;!async function(t,e){const{id:a,description:o,...n}=t;if(await(0,d.t9)("editChatFolder",{id:e+1,folderUpdate:{id:e+1,...n}}),!o)return;const i=(0,s.Rd)(),{recommended:r}=i.chatFolders;r&&(0,s.R3)({...i,chatFolders:{...i.chatFolders,recommended:r.filter((({id:t})=>t!==a))}})}(o,null!=n&&n.length?Math.max.apply(Math.max,n):i.WS)})),(0,s.Q6)("deleteChatFolder",((t,e,a)=>{const{id:s}=a;(0,c.Mw)(t,s)&&async function(t){await(0,d.t9)("deleteChatFolder",t)}(s)})),(0,s.Q6)("toggleChatUnread",((t,e,a)=>{const{id:s}=a,{serverTimeOffset:n}=t,i=(0,c.Z1)(t,s);i&&(i.unreadCount?(0,d.t9)("markMessageListRead",{serverTimeOffset:n,chat:i,threadId:o._f}):(0,d.t9)("toggleDialogUnread",{chat:i,hasUnreadMark:!i.hasUnreadMark}))})),(0,s.Q6)("openChatByInvite",((t,e,a)=>{const{hash:s}=a;(async()=>{const t=await(0,d.t9)("openChatByInvite",s);t&&e.openChat({id:t.chatId})})()})),(0,s.Q6)("openTelegramLink",((t,e,a)=>{const{url:s}=a;if(s.match(i.g$))return void(0,p.o)(s.match(i.g$)[0]);const o=new URL(s.startsWith("http")?s:`https://${s}`),[n,d,r]=o.pathname.split("/").filter(Boolean).map((t=>decodeURI(t))),l=Object.fromEntries(o.searchParams);let h;if("joinchat"===n&&(h=d),(n.startsWith(" ")||n.startsWith("+"))&&(h=n.substr(1,n.length-1)),h)return void e.openChatByInvite({hash:h});if("addstickers"===n)return void e.openStickerSetShortName({stickerSetShortName:d});const u=d||void 0,f=r?Number(r):void 0,C=l.comment?Number(l.comment):void 0;if(l.hasOwnProperty("voicechat")||l.hasOwnProperty("livestream"))e.joinVoiceChatByLink({username:n,inviteHash:l.voicechat||l.livestream});else if("c"===n&&u&&f){const a=`-${u}`;if(!(0,c.Z1)(t,a))return void e.showNotification({message:"Chat does not exist"});e.focusMessage({chatId:a,messageId:f})}else e.openChatByUsername({username:n,messageId:f||Number(u),commentId:C,startParam:l.start})})),(0,s.Q6)("acceptInviteConfirmation",((t,e,a)=>{const{hash:s}=a;(async()=>{const t=await(0,d.t9)("importChatInvite",{hash:s});t&&e.openChat({id:t.id})})()})),(0,s.Q6)("openChatByUsername",((t,e,a)=>{const{username:o,messageId:n,commentId:r,startParam:l}=a;(async()=>{const a=(0,c.jr)(t);if(!r)return a&&a.username===o?void e.focusMessage({chatId:a.id,messageId:n}):void await async function(t,e,a,s){t.openChat({id:i.AJ});const o=await b(e);if(!o)return t.openPreviousChat(),void t.showNotification({message:"User does not exist"});a?t.focusMessage({chatId:o.id,messageId:a}):t.openChat({id:o.id}),s&&t.startBot({botId:o.id,param:s})}(e,o,n,l);const{chatId:h,type:u}=(0,c.Bt)(t)||{},p=(0,c.DI)(t,o);if(h&&p&&"thread"===u){const a=(0,c.tZ)(t,h,n);if(a&&a.chatId===h)return void e.focusMessage({chatId:a.chatId,threadId:a.threadId,messageId:r})}n&&await async function(t,e,a,o){t.openChat({id:i.AJ});const n=await b(e);if(!n)return;const r=(0,s.Rd)(),l=(0,c.tZ)(r,n.id,a);let h;if(l)h=l.chatId;else{const t=await(0,d.t9)("requestThreadInfoUpdate",{chat:n,threadId:a});if(!t)return;h=t.discussionChatId}h&&t.focusMessage({chatId:h,threadId:a,messageId:Number(o)})}(e,o,n,r)})()})),(0,s.Q6)("togglePreHistoryHidden",((t,e,a)=>{const{chatId:s,isEnabled:o}=a;let n=(0,c.Z1)(t,s);n&&(async()=>{if((0,u.G9)(n)){if(n=await(0,d.t9)("migrateChat",n),!n)return;e.openChat({id:n.id})}(0,d.t9)("togglePreHistoryHidden",{chat:n,isEnabled:o})})()})),(0,s.Q6)("updateChatDefaultBannedRights",((t,e,a)=>{const{chatId:s,bannedRights:o}=a,n=(0,c.Z1)(t,s);n&&(0,d.t9)("updateChatDefaultBannedRights",{chat:n,bannedRights:o})})),(0,s.Q6)("updateChatMemberBannedRights",((t,e,a)=>{const{chatId:o,userId:n,bannedRights:i}=a;let l=(0,c.Z1)(t,o);const h=(0,c.dy)(t,n);l&&h&&(async()=>{if((0,u.G9)(l)){if(l=await(0,d.t9)("migrateChat",l),!l)return;e.openChat({id:l.id})}await(0,d.t9)("updateChatMemberBannedRights",{chat:l,user:h,bannedRights:i});const t=(0,s.Rd)(),a=(0,c.Z1)(t,o);if(!a||!a.fullInfo)return;const{members:p,kickedMembers:f}=a.fullInfo,C=!!i.viewMessages,I=!Object.keys(i).length;(0,s.R3)((0,r.a4)(t,o,{fullInfo:{...a.fullInfo,...p&&C&&{members:p.filter((t=>t.userId!==n))},...p&&!C&&{members:p.map((t=>t.userId===n?{...t,bannedRights:i}:t))},...I&&f&&{kickedMembers:f.filter((t=>t.userId!==n))}}}))})()})),(0,s.Q6)("updateChatAdmin",((t,e,a)=>{const{chatId:o,userId:n,adminRights:i,customTitle:l}=a;let h=(0,c.Z1)(t,o);const p=(0,c.dy)(t,n);h&&p&&(async()=>{if((0,u.G9)(h)){if(h=await(0,d.t9)("migrateChat",h),!h)return;e.openChat({id:h.id})}await(0,d.t9)("updateChatAdmin",{chat:h,user:p,adminRights:i,customTitle:l});const t=await(0,d.t9)("fetchFullChat",h),a=(0,s.Rd)();if(!t||!t.fullInfo)return;const{adminMembers:c}=t.fullInfo,f=!Object.keys(i).length;(0,s.R3)((0,r.a4)(a,o,{fullInfo:{...t.fullInfo,...c&&f&&{adminMembers:c.filter((t=>t.userId!==n))},...c&&!f&&{adminMembers:c.map((t=>t.userId===n?{...t,adminRights:i,customTitle:l}:t))}}}))})()})),(0,s.Q6)("updateChat",((t,e,a)=>{const{chatId:o,title:i,about:l,photo:h}=a,u=(0,c.Z1)(t,o);u&&(async()=>{(0,s.R3)((0,r.H9)((0,s.Rd)(),n.wv.InProgress)),await Promise.all([u.title!==i?(0,d.t9)("updateChatTitle",u,i):void 0,u.fullInfo&&u.fullInfo.about!==l?(0,d.t9)("updateChatAbout",u,l):void 0,h?(0,d.t9)("editChatPhoto",{chatId:o,accessHash:u.accessHash,photo:h}):void 0]),(0,s.R3)((0,r.H9)((0,s.Rd)(),n.wv.Complete))})()})),(0,s.Q6)("toggleSignatures",((t,e,a)=>{const{chatId:s,isEnabled:o}=a,n=(0,c.Z1)(t,s);n&&(0,d.t9)("toggleSignatures",{chat:n,isEnabled:o})})),(0,s.Q6)("loadGroupsForDiscussion",(()=>{(async()=>{const t=await(0,d.t9)("fetchGroupsForDiscussion");if(!t)return;const e=t.reduce(((t,e)=>(e&&(t[e.id]=e),t)),{}),a=(0,r.fZ)((0,s.Rd)(),e);(0,s.R3)({...a,chats:{...a.chats,forDiscussionIds:Object.keys(e)}})})()})),(0,s.Q6)("linkDiscussionGroup",((t,e,a)=>{const{channelId:s,chatId:o}=a,n=(0,c.Z1)(t,s);let i=(0,c.Z1)(t,o);n&&i&&(async()=>{if((0,u.G9)(i)){if(i=await(0,d.t9)("migrateChat",i),!i)return;e.openChat({id:i.id})}let{fullInfo:t}=i;if(!t){const e=await(0,d.t9)("fetchFullChat",i);if(!e)return;t=e.fullInfo}t.isPreHistoryHidden&&await(0,d.t9)("togglePreHistoryHidden",{chat:i,isEnabled:!1}),(0,d.t9)("setDiscussionGroup",{channel:n,chat:i})})()})),(0,s.Q6)("unlinkDiscussionGroup",((t,e,a)=>{var s;const{channelId:o}=a,n=(0,c.Z1)(t,o);if(!n)return;let i;null!==(s=n.fullInfo)&&void 0!==s&&s.linkedChatId&&(i=(0,c.Z1)(t,n.fullInfo.linkedChatId)),(async()=>{await(0,d.t9)("setDiscussionGroup",{channel:n}),i&&y(i)})()})),(0,s.Q6)("setActiveChatFolder",((t,e,a)=>({...t,chatFolders:{...t.chatFolders,activeChatFolder:a}}))),(0,s.Q6)("loadMoreMembers",(t=>{(async()=>{var e,a;const{chatId:o}=(0,c.Bt)(t)||{},n=o?(0,c.Z1)(t,o):void 0;if(!n||(0,u.G9)(n))return;const i=(null===(e=n.fullInfo)||void 0===e||null===(a=e.members)||void 0===a?void 0:a.length)||void 0,h=await(0,d.t9)("fetchMembers",n.id,n.accessHash,"recent",i);if(!h)return;const{members:p,users:f}=h;p&&p.length&&(t=(0,s.Rd)(),t=(0,r.Sh)(t,(0,l.ee)(f,"id")),t=(0,r.a4)(t,n.id,{fullInfo:{...n.fullInfo,members:[...(n.fullInfo||{}).members||[],...p||[]]}}),(0,s.R3)(t))})()})),(0,s.Q6)("addChatMembers",((t,e,a)=>{const{chatId:s,memberIds:o}=a,i=(0,c.Z1)(t,s),r=o.map((e=>(0,c.dy)(t,e))).filter(Boolean);i&&r.length&&(e.setNewChatMembersDialogState(n.WB.Loading),(async()=>{await(0,d.t9)("addChatMembers",i,r),e.setNewChatMembersDialogState(n.WB.Closed),y(i)})())})),(0,s.Q6)("deleteChatMember",((t,e,a)=>{const{chatId:s,userId:o}=a,n=(0,c.Z1)(t,s),i=(0,c.dy)(t,o);n&&i&&(async()=>{await(0,d.t9)("deleteChatMember",n,i),y(n)})()})),(0,s.Q6)("toggleIsProtected",((t,e,a)=>{const{chatId:s,isProtected:o}=a,n=(0,c.Z1)(t,s);n&&(0,d.t9)("toggleIsProtected",{chat:n,isProtected:o})}))},1689:(t,e,a)=>{a.d(e,{FF:()=>M,NH:()=>Q,Mt:()=>Z});var s=a(5116),o=a(2607),n=a(1226),i=a(1638),d=a(4319),r=a(4446),c=a(782),l=a(307),h=a(6204),u=a(4753),p=a(7361),f=a(663);let C,I;const m=new Audio("./voicechat_join.mp3"),g=new Audio("./voicechat_connecting.mp3");g.loop=!0;const v=new Audio("./voicechat_leave.mp3"),y={join:m,allowTalk:new Audio("./voicechat_onallowtalk.mp3"),leave:v,connecting:g};let b=Promise.resolve();async function w(t){const e=await(0,n.t9)("getGroupCall",{call:t});if(!e)return;let a=(0,s.Rd)();const i=(0,o.$5)(a,t.id);return a=(0,r.AH)(a,t.id,(0,c.CE)(e.groupCall,["connectionState"]),void 0,null!=i&&i.isLoaded?void 0:e.groupCall.participantsCount),a=(0,l.Sh)(a,(0,c.ee)(e.users,"id")),a=(0,l.fZ)(a,(0,c.ee)(e.chats,"id")),(0,s.R3)(a),e.groupCall}async function R(t,e){const a=await(0,n.t9)("fetchGroupCallParticipants",{call:t,offset:e});if(!a)return;let o=(0,s.Rd)();o=(0,l.Sh)(o,(0,c.ee)(a.users,"id")),o=(0,l.fZ)(o,(0,c.ee)(a.chats,"id")),(0,s.R3)(o)}function M(){return C}function Q(){return I}function Z(){var t;null===(t=C)||void 0===t||t.pause(),I=void 0,C=void 0}(0,s.Q6)("toggleGroupCallPanel",(t=>({...t,groupCalls:{...t.groupCalls,isGroupCallPanelHidden:!t.groupCalls.isGroupCallPanelHidden}}))),(0,s.Q6)("subscribeToGroupCallUpdates",((t,e,a)=>{const{subscribed:s,id:i}=a,d=(0,o.$5)(t,i);d&&(async()=>{s&&(await w(d),await R(d)),await(0,n.t9)("toggleGroupCallStartSubscription",{subscribed:s,call:d})})()})),(0,s.Q6)("createGroupCall",((t,e,a)=>{const{chatId:o}=a,d=(0,i.Z1)(t,o);d&&(async()=>{const a=await(0,n.t9)("createGroupCall",{peer:d});a&&(t=(0,s.Rd)(),(0,s.R3)((0,r.AH)(t,a.id,{...a,chatId:o})),e.joinGroupCall({id:a.id,accessHash:a.accessHash}))})()})),(0,s.Q6)("createGroupCallInviteLink",((t,e)=>{const a=(0,o.mU)(t);if(!a||!a.chatId)return;const s=(0,i.Z1)(t,a.chatId);if(!s)return;const r=!!s&&!!s.username;(async()=>{let{inviteLink:t}=s.fullInfo;r&&(t=await(0,n.t9)("exportGroupCallInvite",{call:a,canSelfUnmute:!1})),t&&((0,d.TE)(t),e.showNotification({message:"Link copied to clipboard"}))})()})),(0,s.Q6)("joinVoiceChatByLink",((t,e,a)=>{const{username:s,inviteHash:o}=a;(async()=>{const t=await(0,h.C)(s);if(!t)return void e.showNotification({message:f.i0("NoUsernameFound")});const a=await(0,h.f)(t);null!=a&&a.groupCall&&e.joinGroupCall({id:a.groupCall.id,accessHash:a.groupCall.accessHash,inviteHash:o})})()})),(0,s.Q6)("joinGroupCall",((t,e,a)=>{if(!p.Bi)return;const{chatId:n,id:i,accessHash:d,inviteHash:c}=a;!function(){const t=new(window.AudioContext||window.webkitAudioContext);C=new Audio,I=t,C.srcObject=(t=>{const e=t.createOscillator(),a=e.connect(t.createMediaStreamDestination());return e.start(),new MediaStream([Object.assign(a.stream.getAudioTracks()[0],{enabled:!1})])})(t),(0,u.Z)(C)}(),(async()=>{var l;await(b?(b=Promise.all(Object.values(y).map((t=>(t.muted=!0,t.volume=1e-4,t.play().then((()=>{t.pause(),t.volume=1,t.currentTime=0,t.muted=!1})))))).then((()=>{b=void 0})),b):Promise.resolve());const{groupCalls:{activeGroupCallId:h}}=t;let u=i?(0,o.$5)(t,i):(0,o.Bj)(t,n);(null===(l=u)||void 0===l?void 0:l.id)!==h?h?e.leaveGroupCall({rejoin:a}):u&&h===u.id?e.toggleGroupCallPanel():(u||i&&d||(u=await w({id:i,accessHash:d})),u&&(t=(0,s.Rd)(),t=(0,r.AH)(t,u.id,{...u,inviteHash:c},void 0,u.participantsCount+1),(0,s.R3)({...t,groupCalls:{...t.groupCalls,activeGroupCallId:u.id,isGroupCallPanelHidden:!1}}))):e.toggleGroupCallPanel()})()})),(0,s.Q6)("playGroupCallSound",((t,e,a)=>{const{sound:s}=a;y[s]&&(b?b.then((()=>{(0,u.Z)(y[s])})):("connecting"!==s&&y.connecting.pause(),(0,u.Z)(y[s])))})),(0,s.Q6)("loadMoreGroupCallParticipants",(t=>{const e=(0,o.mU)(t);e&&R(e,e.nextOffset)})),(0,s.Q6)("openCallFallbackConfirm",(t=>({...t,groupCalls:{...t.groupCalls,isFallbackConfirmOpen:!0}}))),(0,s.Q6)("closeCallFallbackConfirm",(t=>({...t,groupCalls:{...t.groupCalls,isFallbackConfirmOpen:!1}})))},4446:(t,e,a)=>{a.d(e,{AH:()=>d,dc:()=>r,Ic:()=>c,B6:()=>l});var s=a(2607),o=a(782),n=a(6788),i=a(1638);function d(t,e,a,s,n){var i;const d=Object.values({...null===(i=t.groupCalls.byId[e])||void 0===i?void 0:i.participants,...a.participants}).filter((t=>!t.isLeft)).reduce(((t,e)=>(t[e.id]=e,t)),{});return{...t,groupCalls:{...t.groupCalls,byId:{...t.groupCalls.byId,[e]:{...t.groupCalls.byId[e],...(0,o.CE)(a,["participantsCount"]),...s&&{participantsCount:t.groupCalls.byId[e].participantsCount+s},...void 0!==n&&{participantsCount:n},participants:d}}}}}function r(t,e){const a=(0,s.$5)(t,e);if(a&&a.chatId){const e=(0,i.Z1)(t,a.chatId);e&&(t=(0,n.a4)(t,a.chatId,{fullInfo:{...e.fullInfo,groupCallId:void 0}}))}return{...t,groupCalls:{...t.groupCalls,byId:{...(0,o.CE)(t.groupCalls.byId,[e.toString()])}}}}function c(t,e,a){return t.groupCalls.activeGroupCallId?d(t,t.groupCalls.activeGroupCallId,e,void 0,a):t}function l(t,e,a,o,n=!1){const i=(0,s.$5)(t,e);return i?d(t,e,{participants:{...i.participants,[a]:{...i.participants[a],...o}}},o.isLeft?n?0:-1:i.participants[a]||n?0:1):t}},2607:(t,e,a)=>{a.d(e,{Bj:()=>i,$5:()=>d,GU:()=>r,Ht:()=>c,mU:()=>l,oq:()=>h});var s=a(8857),o=a(2858),n=a(6376);function i(t,e){const a=(0,s.Z1)(t,e);if(a&&a.fullInfo&&a.fullInfo.groupCallId)return d(t,a.fullInfo.groupCallId)}function d(t,e){return t.groupCalls.byId[e]}function r(t,e,a){var s;return null===(s=d(t,e))||void 0===s?void 0:s.participants[a]}function c(t){var e,a;const n=null===(e=l(t))||void 0===e?void 0:e.chatId;if(!n)return!1;const i=(0,s.Z1)(t,n);return!!i&&((0,o.G9)(i)&&i.isCreator||!(null===(a=i.adminRights)||void 0===a||!a.manageCall))}function l(t){const{groupCalls:{activeGroupCallId:e}}=t;if(e)return d(t,e)}function h(t){const e=(0,n.dy)(t,t.currentUserId);return`Calls: ${(0,o.Js)(e)}`}},3551:(t,e,a)=>{a.d(e,{o:()=>n});var s=a(5116),o=a(7361);const n=t=>{const{protocol:e,searchParams:a,pathname:n,hostname:i}=new URL(t);if("tg:"!==e)return;const{openChatByInvite:d,openChatByUsername:r,openStickerSetShortName:c,focusMessage:l,joinVoiceChatByLink:h}=(0,s.uC)(),u=(o.s$?i:n).replace(/^\/\//,""),p={};switch(a.forEach(((t,e)=>{p[e]=t})),u){case"resolve":{const{domain:t,post:e,comment:a,voicechat:s,livestream:o,start:n}=p;"telegrampassport"!==t&&(p.hasOwnProperty("voicechat")||p.hasOwnProperty("livestream")?h({username:t,inviteHash:s||o}):r({username:t,messageId:Number(e),commentId:Number(a),startParam:n}));break}case"privatepost":{const{post:t,channel:e}=p;l({chatId:`-${e}`,id:t});break}case"bg":break;case"join":{const{invite:t}=p;d({hash:t});break}case"addstickers":{const{set:t}=p;c({stickerSetShortName:t});break}}}}}]);
|
|
//# sourceMappingURL=884.525be6735d9f795229c2.js.map
|