@mtkruto/browser 0.119.0 → 0.119.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/esm/0_errors.d.ts.map +1 -1
  2. package/esm/0_errors.js +9 -31
  3. package/esm/3_errors.js +2 -12
  4. package/esm/4_errors.js +2 -12
  5. package/esm/_dnt.polyfills.d.ts +0 -99
  6. package/esm/_dnt.polyfills.d.ts.map +1 -1
  7. package/esm/_dnt.polyfills.js +1 -127
  8. package/esm/client/0_abortable_loop.js +26 -39
  9. package/esm/client/0_storage_operations.js +179 -218
  10. package/esm/client/1_client_plain.js +4 -22
  11. package/esm/client/2_account_manager.js +140 -149
  12. package/esm/client/2_bot_info_manager.js +26 -38
  13. package/esm/client/2_business_connection_manager.js +10 -23
  14. package/esm/client/2_client_encrypted.js +198 -215
  15. package/esm/client/2_file_manager.js +255 -262
  16. package/esm/client/2_network_statistics_manager.js +31 -44
  17. package/esm/client/2_payment_manager.js +7 -20
  18. package/esm/client/2_reaction_manager.js +7 -20
  19. package/esm/client/2_translations_manager.js +101 -111
  20. package/esm/client/2_update_manager.js +750 -745
  21. package/esm/client/3_client_encrypted_pool.js +10 -26
  22. package/esm/client/3_message_manager.js +503 -508
  23. package/esm/client/3_video_chat_manager.js +57 -68
  24. package/esm/client/4_callback_query_manager.js +18 -30
  25. package/esm/client/4_chat_list_manager.js +140 -146
  26. package/esm/client/4_chat_manager.js +161 -169
  27. package/esm/client/4_checklist_manager.js +26 -39
  28. package/esm/client/4_context.js +244 -259
  29. package/esm/client/4_forum_manager.js +67 -73
  30. package/esm/client/4_gift_manager.js +22 -35
  31. package/esm/client/4_inline_query_manager.js +16 -28
  32. package/esm/client/4_link_preview_manager.js +6 -19
  33. package/esm/client/4_poll_manager.js +44 -57
  34. package/esm/client/4_story_manager.js +41 -53
  35. package/esm/client/5_composer.js +13 -26
  36. package/esm/client/6_client.js +866 -896
  37. package/esm/client/6_client_dispatcher.js +308 -325
  38. package/esm/client/7_client_worker.js +16 -29
  39. package/esm/connection/1_connection_tcp.js +55 -82
  40. package/esm/connection/1_connection_web_socket.js +75 -91
  41. package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  42. package/esm/deps/jsr.io/@std/async/1.2.0/mux_async_iterator.js +31 -47
  43. package/esm/deps/jsr.io/@std/async/1.2.0/tee.js +11 -34
  44. package/esm/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +30 -47
  45. package/esm/deps/jsr.io/@std/datetime/0.225.7/_date_time_formatter.js +4 -17
  46. package/esm/session/0_session_state.js +12 -38
  47. package/esm/session/1_session.js +49 -72
  48. package/esm/session/2_session_encrypted.js +422 -420
  49. package/esm/storage/2_storage_indexed_db.js +26 -44
  50. package/esm/storage/2_storage_local_storage.js +3 -16
  51. package/esm/storage/2_storage_memory.js +24 -41
  52. package/esm/storage/2_storage_session_storage.js +3 -16
  53. package/esm/tl/1_tl_reader.d.ts +1 -1
  54. package/esm/tl/1_tl_reader.d.ts.map +1 -1
  55. package/esm/tl/1_tl_reader.js +95 -103
  56. package/esm/tl/1_tl_writer.js +169 -178
  57. package/esm/transport/0_transport.js +1 -8
  58. package/esm/transport/1_transport_abridged.js +11 -24
  59. package/esm/transport/1_transport_intermediate.js +10 -23
  60. package/esm/utilities/0_mutex.js +4 -19
  61. package/esm/utilities/0_part_stream.js +11 -25
  62. package/esm/utilities/1_crypto.js +42 -53
  63. package/esm/utilities/2_queue.js +29 -47
  64. package/package.json +1 -1
  65. package/script/0_errors.d.ts.map +1 -1
  66. package/script/0_errors.js +9 -31
  67. package/script/3_errors.js +2 -12
  68. package/script/4_errors.js +2 -12
  69. package/script/_dnt.polyfills.d.ts +0 -99
  70. package/script/_dnt.polyfills.d.ts.map +1 -1
  71. package/script/_dnt.polyfills.js +0 -128
  72. package/script/client/0_abortable_loop.js +27 -40
  73. package/script/client/0_storage_operations.js +179 -218
  74. package/script/client/1_client_plain.js +4 -22
  75. package/script/client/2_account_manager.js +140 -149
  76. package/script/client/2_bot_info_manager.js +26 -38
  77. package/script/client/2_business_connection_manager.js +10 -23
  78. package/script/client/2_client_encrypted.js +199 -216
  79. package/script/client/2_file_manager.js +255 -262
  80. package/script/client/2_network_statistics_manager.js +32 -45
  81. package/script/client/2_payment_manager.js +7 -20
  82. package/script/client/2_reaction_manager.js +7 -20
  83. package/script/client/2_translations_manager.js +102 -112
  84. package/script/client/2_update_manager.js +750 -745
  85. package/script/client/3_client_encrypted_pool.js +10 -26
  86. package/script/client/3_message_manager.js +503 -508
  87. package/script/client/3_video_chat_manager.js +57 -68
  88. package/script/client/4_callback_query_manager.js +18 -30
  89. package/script/client/4_chat_list_manager.js +140 -146
  90. package/script/client/4_chat_manager.js +161 -169
  91. package/script/client/4_checklist_manager.js +26 -39
  92. package/script/client/4_context.js +244 -259
  93. package/script/client/4_forum_manager.js +67 -73
  94. package/script/client/4_gift_manager.js +22 -35
  95. package/script/client/4_inline_query_manager.js +16 -28
  96. package/script/client/4_link_preview_manager.js +6 -19
  97. package/script/client/4_poll_manager.js +44 -57
  98. package/script/client/4_story_manager.js +41 -53
  99. package/script/client/5_composer.js +13 -26
  100. package/script/client/6_client.js +866 -896
  101. package/script/client/6_client_dispatcher.js +308 -325
  102. package/script/client/7_client_worker.js +16 -29
  103. package/script/connection/1_connection_tcp.js +55 -82
  104. package/script/connection/1_connection_web_socket.js +75 -91
  105. package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  106. package/script/deps/jsr.io/@std/async/1.2.0/mux_async_iterator.js +31 -47
  107. package/script/deps/jsr.io/@std/async/1.2.0/tee.js +11 -34
  108. package/script/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +30 -47
  109. package/script/deps/jsr.io/@std/datetime/0.225.7/_date_time_formatter.js +4 -17
  110. package/script/session/0_session_state.js +12 -38
  111. package/script/session/1_session.js +49 -72
  112. package/script/session/2_session_encrypted.js +423 -421
  113. package/script/storage/2_storage_indexed_db.js +26 -44
  114. package/script/storage/2_storage_local_storage.js +3 -16
  115. package/script/storage/2_storage_memory.js +24 -41
  116. package/script/storage/2_storage_session_storage.js +3 -16
  117. package/script/tl/1_tl_reader.d.ts +1 -1
  118. package/script/tl/1_tl_reader.d.ts.map +1 -1
  119. package/script/tl/1_tl_reader.js +96 -104
  120. package/script/tl/1_tl_writer.js +170 -179
  121. package/script/transport/0_transport.js +1 -8
  122. package/script/transport/1_transport_abridged.js +11 -24
  123. package/script/transport/1_transport_intermediate.js +10 -23
  124. package/script/utilities/0_mutex.js +4 -19
  125. package/script/utilities/0_part_stream.js +11 -25
  126. package/script/utilities/1_crypto.js +43 -54
  127. package/script/utilities/2_queue.js +30 -48
@@ -17,18 +17,6 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
21
- if (kind === "m") throw new TypeError("Private method is not writable");
22
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
23
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
24
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
25
- };
26
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
27
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
28
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
29
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
30
- };
31
- var _ChatManager_instances, _ChatManager_c, _ChatManager_toggleJoinRequests, _ChatManager_toggleSlowMode, _ChatManager_setIsMemberListVisible, _ChatManager_setIsTopicsEnabled, _ChatManager_setIsAntispamEnabled, _ChatManager_setIsSignaturesEnabled, _ChatManager_setIsSharingEnabled;
32
20
  import { unreachable } from "../0_deps.js";
33
21
  import { InputError } from "../0_errors.js";
34
22
  import { Api } from "../2_tl.js";
@@ -43,18 +31,17 @@ const chatManagerUpdates = [
43
31
  "updateBotChatInviteRequester",
44
32
  ];
45
33
  export class ChatManager {
34
+ #c;
46
35
  constructor(c) {
47
- _ChatManager_instances.add(this);
48
- _ChatManager_c.set(this, void 0);
49
- __classPrivateFieldSet(this, _ChatManager_c, c, "f");
36
+ this.#c = c;
50
37
  }
51
38
  canHandleUpdate(update) {
52
39
  return Api.isOneOf(chatManagerUpdates, update);
53
40
  }
54
41
  async handleUpdate(update) {
55
42
  if (Api.is("updateChannelParticipant", update) || Api.is("updateChatParticipant", update)) {
56
- const chatMember = constructChatMemberUpdated(update, __classPrivateFieldGet(this, _ChatManager_c, "f").getPeer);
57
- const selfId = await __classPrivateFieldGet(this, _ChatManager_c, "f").getSelfId();
43
+ const chatMember = constructChatMemberUpdated(update, this.#c.getPeer);
44
+ const selfId = await this.#c.getSelfId();
58
45
  if (chatMember.oldChatMember.member.id === selfId) {
59
46
  return { myChatMember: chatMember };
60
47
  }
@@ -63,51 +50,56 @@ export class ChatManager {
63
50
  }
64
51
  }
65
52
  if (Api.is("updateBotChatInviteRequester", update)) {
66
- const joinRequest = constructJoinRequest(update, __classPrivateFieldGet(this, _ChatManager_c, "f").getPeer);
53
+ const joinRequest = constructJoinRequest(update, this.#c.getPeer);
67
54
  return { joinRequest };
68
55
  }
69
56
  return null;
70
57
  }
58
+ // JOIN REQUESTS //
59
+ async #toggleJoinRequests(chatId, isEnabled) {
60
+ const channel = await this.#c.getInputChannel(chatId);
61
+ await this.#c.invoke({ _: "channels.toggleJoinRequest", channel, enabled: isEnabled });
62
+ }
71
63
  async approveJoinRequest(chatId, userId) {
72
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({
64
+ await this.#c.invoke({
73
65
  _: "messages.hideChatJoinRequest",
74
- peer: await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId),
75
- user_id: await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputUser(userId),
66
+ peer: await this.#c.getInputPeer(chatId),
67
+ user_id: await this.#c.getInputUser(userId),
76
68
  approved: true,
77
69
  });
78
70
  }
79
71
  async declineJoinRequest(chatId, userId) {
80
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({
72
+ await this.#c.invoke({
81
73
  _: "messages.hideChatJoinRequest",
82
- peer: await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId),
83
- user_id: await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputUser(userId),
74
+ peer: await this.#c.getInputPeer(chatId),
75
+ user_id: await this.#c.getInputUser(userId),
84
76
  });
85
77
  }
86
78
  async approveJoinRequests(chatId, params) {
87
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("approveJoinRequests");
88
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({
79
+ this.#c.storage.assertUser("approveJoinRequests");
80
+ await this.#c.invoke({
89
81
  _: "messages.hideAllChatJoinRequests",
90
- peer: await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId),
82
+ peer: await this.#c.getInputPeer(chatId),
91
83
  approved: true,
92
84
  link: params?.inviteLink,
93
85
  });
94
86
  }
95
87
  async declineJoinRequests(chatId, params) {
96
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("declineJoinRequests");
97
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({
88
+ this.#c.storage.assertUser("declineJoinRequests");
89
+ await this.#c.invoke({
98
90
  _: "messages.hideAllChatJoinRequests",
99
- peer: await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId),
91
+ peer: await this.#c.getInputPeer(chatId),
100
92
  link: params?.inviteLink,
101
93
  });
102
94
  }
103
95
  async getJoinRequests(chatId, params) {
104
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("getJoinRequests");
96
+ this.#c.storage.assertUser("getJoinRequests");
105
97
  if (typeof params?.inviteLink === "string" && typeof params?.search === "string") {
106
98
  throw new InputError("inviteLink and search cannot be specified together.");
107
99
  }
108
- const peer = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId);
109
- const offset_user = params?.fromUserId ? await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputUser(params.fromUserId) : { _: "inputUserEmpty" };
110
- const { importers } = await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({
100
+ const peer = await this.#c.getInputPeer(chatId);
101
+ const offset_user = params?.fromUserId ? await this.#c.getInputUser(params.fromUserId) : { _: "inputUserEmpty" };
102
+ const { importers } = await this.#c.invoke({
111
103
  _: "messages.getChatInviteImporters",
112
104
  requested: true,
113
105
  peer,
@@ -118,48 +110,48 @@ export class ChatManager {
118
110
  limit: getLimit(params?.limit),
119
111
  });
120
112
  const peer_ = inputPeerToPeer(peer);
121
- return await Promise.all(importers.map((v) => constructJoinRequest2(peer_, v, __classPrivateFieldGet(this, _ChatManager_c, "f").getPeer)));
113
+ return await Promise.all(importers.map((v) => constructJoinRequest2(peer_, v, this.#c.getPeer)));
122
114
  }
123
115
  // INVITE LINKS //
124
116
  async createInviteLink(chatId, params) {
125
117
  if (params?.isApprovalRequired && params?.limit) {
126
118
  throw new InputError("isApprovalRequired cannot be true while limit is specified.");
127
119
  }
128
- const result = await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.exportChatInvite", peer: await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId), title: params?.title, expire_date: params?.expireAt, request_needed: params?.isApprovalRequired ? true : undefined, usage_limit: params?.limit });
129
- return constructInviteLink(Api.as("chatInviteExported", result), __classPrivateFieldGet(this, _ChatManager_c, "f").getPeer);
120
+ const result = await this.#c.invoke({ _: "messages.exportChatInvite", peer: await this.#c.getInputPeer(chatId), title: params?.title, expire_date: params?.expireAt, request_needed: params?.isApprovalRequired ? true : undefined, usage_limit: params?.limit });
121
+ return constructInviteLink(Api.as("chatInviteExported", result), this.#c.getPeer);
130
122
  }
131
123
  async getCreatedInviteLinks(chatId, params) {
132
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("getCreatedInviteLinks");
133
- const { invites } = await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.getExportedChatInvites", peer: await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId), revoked: params?.isRevoked ? true : undefined, admin_id: params?.by ? await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputUser(params.by) : { _: "inputUserEmpty" }, limit: getLimit(params?.limit), offset_date: params?.afterDate, offset_link: params?.afterInviteLink });
134
- return await Promise.all(invites.map((v) => Api.as("chatInviteExported", v)).map((v) => constructInviteLink(v, __classPrivateFieldGet(this, _ChatManager_c, "f").getPeer)));
124
+ this.#c.storage.assertUser("getCreatedInviteLinks");
125
+ const { invites } = await this.#c.invoke({ _: "messages.getExportedChatInvites", peer: await this.#c.getInputPeer(chatId), revoked: params?.isRevoked ? true : undefined, admin_id: params?.by ? await this.#c.getInputUser(params.by) : { _: "inputUserEmpty" }, limit: getLimit(params?.limit), offset_date: params?.afterDate, offset_link: params?.afterInviteLink });
126
+ return await Promise.all(invites.map((v) => Api.as("chatInviteExported", v)).map((v) => constructInviteLink(v, this.#c.getPeer)));
135
127
  }
136
128
  // JOINING AND LEAVING CHATS //
137
129
  async joinChat(chatId) {
138
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("joinChat");
139
- const peer = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId);
130
+ this.#c.storage.assertUser("joinChat");
131
+ const peer = await this.#c.getInputPeer(chatId);
140
132
  if (canBeInputUser(peer)) {
141
133
  throw new InputError("Cannot join private chats.");
142
134
  }
143
135
  else if (canBeInputChannel(peer)) {
144
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.joinChannel", channel: toInputChannel(peer) });
136
+ await this.#c.invoke({ _: "channels.joinChannel", channel: toInputChannel(peer) });
145
137
  }
146
138
  else if (Api.is("inputPeerChat", peer)) {
147
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.addChatUser", chat_id: peer.chat_id, user_id: { _: "inputUserSelf" }, fwd_limit: 0 }); // TODO: use potential high-level method for adding participants to chats
139
+ await this.#c.invoke({ _: "messages.addChatUser", chat_id: peer.chat_id, user_id: { _: "inputUserSelf" }, fwd_limit: 0 }); // TODO: use potential high-level method for adding participants to chats
148
140
  }
149
141
  else {
150
142
  unreachable();
151
143
  }
152
144
  }
153
145
  async leaveChat(chatId) {
154
- const peer = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId);
146
+ const peer = await this.#c.getInputPeer(chatId);
155
147
  if (canBeInputUser(peer)) {
156
148
  throw new InputError("Cannot leave private chats.");
157
149
  }
158
150
  else if (canBeInputChannel(peer)) {
159
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.leaveChannel", channel: toInputChannel(peer) });
151
+ await this.#c.invoke({ _: "channels.leaveChannel", channel: toInputChannel(peer) });
160
152
  }
161
153
  else if (Api.is("inputPeerChat", peer)) {
162
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.deleteChatUser", chat_id: peer.chat_id, user_id: { _: "inputUserSelf" } }); // TODO: use potential high-level method for adding participants to chats
154
+ await this.#c.invoke({ _: "messages.deleteChatUser", chat_id: peer.chat_id, user_id: { _: "inputUserSelf" } }); // TODO: use potential high-level method for adding participants to chats
163
155
  }
164
156
  else {
165
157
  unreachable();
@@ -167,21 +159,21 @@ export class ChatManager {
167
159
  }
168
160
  // CHAT MEMBERS //
169
161
  async banChatMember(chatId, memberId, params) {
170
- const chat = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId);
162
+ const chat = await this.#c.getInputPeer(chatId);
171
163
  if (!(Api.is("inputPeerChannel", chat)) && !(Api.is("inputPeerChat", chat))) {
172
164
  throw new InputError("Expected a channel, supergroup, or group ID.");
173
165
  }
174
- const member = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(memberId);
166
+ const member = await this.#c.getInputPeer(memberId);
175
167
  if (Api.is("inputPeerChannel", chat)) {
176
168
  if (params?.deleteMessages) {
177
169
  try {
178
- await __classPrivateFieldGet(this, _ChatManager_c, "f").messageManager.deleteChatMemberMessages(chatId, memberId);
170
+ await this.#c.messageManager.deleteChatMemberMessages(chatId, memberId);
179
171
  }
180
172
  catch {
181
173
  //
182
174
  }
183
175
  }
184
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({
176
+ await this.#c.invoke({
185
177
  _: "channels.editBanned",
186
178
  channel: { ...chat, _: "inputChannel" },
187
179
  participant: member,
@@ -203,25 +195,25 @@ export class ChatManager {
203
195
  if (!canBeInputUser(member)) {
204
196
  throw new InputError(`Invalid user ID: ${memberId}`);
205
197
  }
206
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.deleteChatUser", chat_id: chat.chat_id, user_id: toInputUser(member), revoke_history: params?.deleteMessages ? true : undefined });
198
+ await this.#c.invoke({ _: "messages.deleteChatUser", chat_id: chat.chat_id, user_id: toInputUser(member), revoke_history: params?.deleteMessages ? true : undefined });
207
199
  }
208
200
  }
209
201
  async unbanChatMember(chatId, memberId) {
210
- const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
211
- const member = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(memberId);
212
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.editBanned", channel, participant: member, banned_rights: { _: "chatBannedRights", until_date: 0 } });
202
+ const channel = await this.#c.getInputChannel(chatId);
203
+ const member = await this.#c.getInputPeer(memberId);
204
+ await this.#c.invoke({ _: "channels.editBanned", channel, participant: member, banned_rights: { _: "chatBannedRights", until_date: 0 } });
213
205
  }
214
206
  async setChatMemberRights(chatId, memberId, params) {
215
- const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
216
- const member = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(memberId);
217
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.editBanned", channel, participant: member, banned_rights: chatMemberRightsToTlObject(params?.rights, params?.until) });
207
+ const channel = await this.#c.getInputChannel(chatId);
208
+ const member = await this.#c.getInputPeer(memberId);
209
+ await this.#c.invoke({ _: "channels.editBanned", channel, participant: member, banned_rights: chatMemberRightsToTlObject(params?.rights, params?.until) });
218
210
  }
219
211
  async promoteChatMember(chatId, userId, params) {
220
- const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
221
- const user_id = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputUser(userId);
212
+ const channel = await this.#c.getInputChannel(chatId);
213
+ const user_id = await this.#c.getInputUser(userId);
222
214
  const admin_rights = chatAdministratorRightsToTlObject(params ?? {});
223
215
  const rank = params?.title ?? "";
224
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({
216
+ await this.#c.invoke({
225
217
  _: "channels.editAdmin",
226
218
  channel,
227
219
  user_id,
@@ -230,117 +222,138 @@ export class ChatManager {
230
222
  });
231
223
  }
232
224
  async setChatMemberTag(chatId, userId, params) {
233
- const peer = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId);
234
- const participant = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(userId);
225
+ const peer = await this.#c.getInputPeer(chatId);
226
+ const participant = await this.#c.getInputPeer(userId);
235
227
  const rank = params?.tag ?? "";
236
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.editChatParticipantRank", peer, participant, rank });
228
+ await this.#c.invoke({ _: "messages.editChatParticipantRank", peer, participant, rank });
237
229
  }
238
230
  // CHAT SETTINGS //
239
231
  async setAvailableReactions(chatId, availableReactions) {
240
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.setChatAvailableReactions", peer: await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId), available_reactions: availableReactions === "none" ? { _: "chatReactionsNone" } : availableReactions === "all" ? { _: "chatReactionsAll" } : Array.isArray(availableReactions) ? ({ _: "chatReactionsSome", reactions: availableReactions.map((v) => reactionToTlObject(v)) }) : unreachable() });
232
+ await this.#c.invoke({ _: "messages.setChatAvailableReactions", peer: await this.#c.getInputPeer(chatId), available_reactions: availableReactions === "none" ? { _: "chatReactionsNone" } : availableReactions === "all" ? { _: "chatReactionsAll" } : Array.isArray(availableReactions) ? ({ _: "chatReactionsSome", reactions: availableReactions.map((v) => reactionToTlObject(v)) }) : unreachable() });
241
233
  }
242
234
  async setBoostsRequiredToCircumventRestrictions(chatId, boosts) {
243
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("setBoostsRequiredToCircumventRestrictions");
244
- const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
245
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.setBoostsToUnblockRestrictions", channel, boosts });
235
+ this.#c.storage.assertUser("setBoostsRequiredToCircumventRestrictions");
236
+ const channel = await this.#c.getInputChannel(chatId);
237
+ await this.#c.invoke({ _: "channels.setBoostsToUnblockRestrictions", channel, boosts });
246
238
  }
247
239
  async enableJoinRequests(chatId) {
248
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("enableJoinRequests");
249
- await __classPrivateFieldGet(this, _ChatManager_instances, "m", _ChatManager_toggleJoinRequests).call(this, chatId, true);
240
+ this.#c.storage.assertUser("enableJoinRequests");
241
+ await this.#toggleJoinRequests(chatId, true);
250
242
  }
251
243
  async disableJoinRequests(chatId) {
252
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("disableJoinRequests");
253
- await __classPrivateFieldGet(this, _ChatManager_instances, "m", _ChatManager_toggleJoinRequests).call(this, chatId, false);
244
+ this.#c.storage.assertUser("disableJoinRequests");
245
+ await this.#toggleJoinRequests(chatId, false);
254
246
  }
255
247
  async setChatStickerSet(chatId, setName) {
256
- const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
257
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetShortName", short_name: setName } });
248
+ const channel = await this.#c.getInputChannel(chatId);
249
+ await this.#c.invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetShortName", short_name: setName } });
258
250
  }
259
251
  async deleteChatStickerSet(chatId) {
260
- const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
261
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetEmpty" } });
252
+ const channel = await this.#c.getInputChannel(chatId);
253
+ await this.#c.invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetEmpty" } });
254
+ }
255
+ async #toggleSlowMode(chatId, seconds) {
256
+ const channel = await this.#c.getInputChannel(chatId);
257
+ await this.#c.invoke({ _: "channels.toggleSlowMode", channel, seconds });
262
258
  }
263
259
  async disableSlowMode(chatId) {
264
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("disableSlowMode");
265
- await __classPrivateFieldGet(this, _ChatManager_instances, "m", _ChatManager_toggleSlowMode).call(this, chatId, 0);
260
+ this.#c.storage.assertUser("disableSlowMode");
261
+ await this.#toggleSlowMode(chatId, 0);
266
262
  }
267
263
  async setSlowMode(chatId, duration) {
268
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("setSlowMode");
264
+ this.#c.storage.assertUser("setSlowMode");
269
265
  const seconds = slowModeDurationToSeconds(duration);
270
266
  if (seconds > 1) {
271
267
  throw new InputError("Invalid slow mode duration.");
272
268
  }
273
- await __classPrivateFieldGet(this, _ChatManager_instances, "m", _ChatManager_toggleSlowMode).call(this, chatId, seconds);
269
+ await this.#toggleSlowMode(chatId, seconds);
274
270
  }
275
271
  async setChatTitle(chatId, title) {
276
- const peer = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId);
272
+ const peer = await this.#c.getInputPeer(chatId);
277
273
  if (Api.is("inputPeerChat", peer)) {
278
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.editChatTitle", chat_id: peer.chat_id, title });
274
+ await this.#c.invoke({ _: "messages.editChatTitle", chat_id: peer.chat_id, title });
279
275
  }
280
276
  else if (canBeInputChannel(peer)) {
281
277
  const channel = toInputChannel(peer);
282
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.editTitle", channel, title });
278
+ await this.#c.invoke({ _: "channels.editTitle", channel, title });
283
279
  }
284
280
  else {
285
281
  throw new InputError("A chat or channel identifier was expected.");
286
282
  }
287
283
  }
288
284
  async setChatDescription(chatId, description) {
289
- const peer = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId);
285
+ const peer = await this.#c.getInputPeer(chatId);
290
286
  if (canBeInputUser(peer)) {
291
287
  throw new InputError("A chat or channel identifier was expected.");
292
288
  }
293
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.editChatAbout", peer, about: description });
289
+ await this.#c.invoke({ _: "messages.editChatAbout", peer, about: description });
290
+ }
291
+ async #setIsMemberListVisible(chatId, isVisible) {
292
+ const channel = await this.#c.getInputChannel(chatId);
293
+ const enabled = !isVisible;
294
+ await this.#c.invoke({ _: "channels.toggleParticipantsHidden", channel, enabled });
294
295
  }
295
296
  async hideMemberList(chatId) {
296
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("hideMemberList");
297
- await __classPrivateFieldGet(this, _ChatManager_instances, "m", _ChatManager_setIsMemberListVisible).call(this, chatId, false);
297
+ this.#c.storage.assertUser("hideMemberList");
298
+ await this.#setIsMemberListVisible(chatId, false);
298
299
  }
299
300
  async showMemberList(chatId) {
300
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("showMemberList");
301
- await __classPrivateFieldGet(this, _ChatManager_instances, "m", _ChatManager_setIsMemberListVisible).call(this, chatId, true);
301
+ this.#c.storage.assertUser("showMemberList");
302
+ await this.#setIsMemberListVisible(chatId, true);
303
+ }
304
+ async #setIsTopicsEnabled(chatId, isEnabled, isShownAsTabs) {
305
+ const channel = await this.#c.getInputChannel(chatId);
306
+ await this.#c.invoke({ _: "channels.toggleForum", channel, enabled: isEnabled, tabs: isShownAsTabs });
302
307
  }
303
308
  async disableTopics(chatId) {
304
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("disableTopics");
305
- await __classPrivateFieldGet(this, _ChatManager_instances, "m", _ChatManager_setIsTopicsEnabled).call(this, chatId, false, false);
309
+ this.#c.storage.assertUser("disableTopics");
310
+ await this.#setIsTopicsEnabled(chatId, false, false);
306
311
  }
307
312
  async enableTopics(chatId, isShownAsTabs) {
308
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("enableTopics");
309
- await __classPrivateFieldGet(this, _ChatManager_instances, "m", _ChatManager_setIsTopicsEnabled).call(this, chatId, true, isShownAsTabs);
313
+ this.#c.storage.assertUser("enableTopics");
314
+ await this.#setIsTopicsEnabled(chatId, true, isShownAsTabs);
315
+ }
316
+ async #setIsAntispamEnabled(chatId, isEnabled) {
317
+ const channel = await this.#c.getInputChannel(chatId);
318
+ await this.#c.invoke({ _: "channels.toggleAntiSpam", channel, enabled: isEnabled });
310
319
  }
311
320
  async enableAntispam(chatId) {
312
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("enableAntispam");
313
- await __classPrivateFieldGet(this, _ChatManager_instances, "m", _ChatManager_setIsAntispamEnabled).call(this, chatId, true);
321
+ this.#c.storage.assertUser("enableAntispam");
322
+ await this.#setIsAntispamEnabled(chatId, true);
314
323
  }
315
324
  async disableAntispam(chatId) {
316
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("disableAntispam");
317
- await __classPrivateFieldGet(this, _ChatManager_instances, "m", _ChatManager_setIsAntispamEnabled).call(this, chatId, false);
325
+ this.#c.storage.assertUser("disableAntispam");
326
+ await this.#setIsAntispamEnabled(chatId, false);
327
+ }
328
+ async #setIsSignaturesEnabled(chatId, isEnabled, params) {
329
+ const channel = await this.#c.getInputChannel(chatId);
330
+ await this.#c.invoke({ _: "channels.toggleSignatures", channel, signatures_enabled: isEnabled ? true : undefined, profiles_enabled: params?.showAuthorProfile ? true : undefined });
318
331
  }
319
332
  async enableSignatures(chatId, params) {
320
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("enableSignatures");
321
- await __classPrivateFieldGet(this, _ChatManager_instances, "m", _ChatManager_setIsSignaturesEnabled).call(this, chatId, true, params);
333
+ this.#c.storage.assertUser("enableSignatures");
334
+ await this.#setIsSignaturesEnabled(chatId, true, params);
322
335
  }
323
336
  async disableSignatures(chatId) {
324
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("disableSignatures");
325
- await __classPrivateFieldGet(this, _ChatManager_instances, "m", _ChatManager_setIsSignaturesEnabled).call(this, chatId, false);
337
+ this.#c.storage.assertUser("disableSignatures");
338
+ await this.#setIsSignaturesEnabled(chatId, false);
326
339
  }
327
340
  async deleteChat(chatId) {
328
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("deleteChat");
329
- const peer = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId);
341
+ this.#c.storage.assertUser("deleteChat");
342
+ const peer = await this.#c.getInputPeer(chatId);
330
343
  if (Api.is("inputPeerChat", peer)) {
331
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.deleteChat", chat_id: peer.chat_id });
344
+ await this.#c.invoke({ _: "messages.deleteChat", chat_id: peer.chat_id });
332
345
  }
333
346
  else if (canBeInputChannel(peer)) {
334
347
  const channel = toInputChannel(peer);
335
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.deleteChannel", channel });
348
+ await this.#c.invoke({ _: "channels.deleteChannel", channel });
336
349
  }
337
350
  else {
338
351
  throw new InputError("A chat or channel identifier was expected.");
339
352
  }
340
353
  }
341
354
  async getDiscussionChatSuggestions() {
342
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("getDiscussionChatSuggestions");
343
- const { chats } = await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.getGroupsForDiscussion" });
355
+ this.#c.storage.assertUser("getDiscussionChatSuggestions");
356
+ const { chats } = await this.#c.invoke({ _: "channels.getGroupsForDiscussion" });
344
357
  return chats
345
358
  .map((v) => {
346
359
  if (!Api.isOneOf(["chat", "channel"], v)) {
@@ -353,134 +366,113 @@ export class ChatManager {
353
366
  .filter((v) => v !== null);
354
367
  }
355
368
  async setDiscussionChat(chatId, discussionChatId) {
356
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("setDiscussionChat");
357
- const [broadcast, group] = await Promise.all([__classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId), __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(discussionChatId)]);
358
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.setDiscussionGroup", broadcast, group });
369
+ this.#c.storage.assertUser("setDiscussionChat");
370
+ const [broadcast, group] = await Promise.all([this.#c.getInputChannel(chatId), this.#c.getInputChannel(discussionChatId)]);
371
+ await this.#c.invoke({ _: "channels.setDiscussionGroup", broadcast, group });
359
372
  }
360
373
  async transferChatOwnership(chatId, userId, password) {
361
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("transferChat");
362
- const user_id = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputUser(userId);
374
+ this.#c.storage.assertUser("transferChat");
375
+ const user_id = await this.#c.getInputUser(userId);
363
376
  const isSelf = Api.is("inputUserSelf", user_id);
364
- if (isSelf || Api.peerToChatId(user_id) === await __classPrivateFieldGet(this, _ChatManager_c, "f").getSelfId()) {
377
+ if (isSelf || Api.peerToChatId(user_id) === await this.#c.getSelfId()) {
365
378
  throw new InputError("A user ID except that of the current one was expected.");
366
379
  }
367
- const peer = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId);
368
- const ap = await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "account.getPassword" });
380
+ const peer = await this.#c.getInputPeer(chatId);
381
+ const ap = await this.#c.invoke({ _: "account.getPassword" });
369
382
  const password_ = await checkPassword(password, ap);
370
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.editChatCreator", peer, user_id, password: password_ });
383
+ await this.#c.invoke({ _: "messages.editChatCreator", peer, user_id, password: password_ });
384
+ }
385
+ async #setIsSharingEnabled(chatId, isSharingEnabled) {
386
+ const peer = await this.#c.getInputPeer(chatId);
387
+ await this.#c.invoke({ _: "messages.toggleNoForwards", peer, enabled: !isSharingEnabled });
371
388
  }
372
389
  async enableSharing(chatId) {
373
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("enableSharing");
374
- await __classPrivateFieldGet(this, _ChatManager_instances, "m", _ChatManager_setIsSharingEnabled).call(this, chatId, true);
390
+ this.#c.storage.assertUser("enableSharing");
391
+ await this.#setIsSharingEnabled(chatId, true);
375
392
  }
376
393
  async disableSharing(chatId) {
377
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("disableSharing");
378
- await __classPrivateFieldGet(this, _ChatManager_instances, "m", _ChatManager_setIsSharingEnabled).call(this, chatId, false);
394
+ this.#c.storage.assertUser("disableSharing");
395
+ await this.#setIsSharingEnabled(chatId, false);
379
396
  }
380
397
  // CHAT PHOTOS //
381
398
  async deleteChatPhoto(chatId) {
382
- const peer = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId);
399
+ const peer = await this.#c.getInputPeer(chatId);
383
400
  if (!(canBeInputChannel(peer)) && !(Api.is("inputPeerChat", peer))) {
384
401
  unreachable();
385
402
  }
386
403
  if (canBeInputChannel(peer)) {
387
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.editPhoto", channel: toInputChannel(peer), photo: { _: "inputChatPhotoEmpty" } });
404
+ await this.#c.invoke({ _: "channels.editPhoto", channel: toInputChannel(peer), photo: { _: "inputChatPhotoEmpty" } });
388
405
  }
389
406
  else if (Api.is("inputPeerChat", peer)) {
390
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: { _: "inputChatPhotoEmpty" } });
407
+ await this.#c.invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: { _: "inputChatPhotoEmpty" } });
391
408
  }
392
409
  }
393
410
  async setChatPhoto(chatId, photo, params) {
394
- const peer = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId);
411
+ const peer = await this.#c.getInputPeer(chatId);
395
412
  if (!(canBeInputChannel(peer)) && !(Api.is("inputPeerChat", peer))) {
396
413
  unreachable();
397
414
  }
398
- const file = await __classPrivateFieldGet(this, _ChatManager_c, "f").fileManager.upload(photo, params);
415
+ const file = await this.#c.fileManager.upload(photo, params);
399
416
  const photo_ = { _: "inputChatUploadedPhoto", file };
400
417
  if (canBeInputChannel(peer)) {
401
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.editPhoto", channel: toInputChannel(peer), photo: photo_ });
418
+ await this.#c.invoke({ _: "channels.editPhoto", channel: toInputChannel(peer), photo: photo_ });
402
419
  }
403
420
  else if (Api.is("inputPeerChat", peer)) {
404
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: photo_ });
421
+ await this.#c.invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: photo_ });
405
422
  }
406
423
  }
407
424
  // INVITING MEMBERS //
408
425
  async addChatMember(chatId, userId, params) {
409
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("addChatMember");
410
- const chat = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId);
426
+ this.#c.storage.assertUser("addChatMember");
427
+ const chat = await this.#c.getInputPeer(chatId);
411
428
  if (Api.isOneOf(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
412
429
  throw new InputError("Cannot add members to private chats");
413
430
  }
414
- const user = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputUser(userId);
431
+ const user = await this.#c.getInputUser(userId);
415
432
  if (Api.is("inputPeerChat", chat)) {
416
- const result = await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.addChatUser", chat_id: chat.chat_id, user_id: user, fwd_limit: params?.historyLimit ?? 0 });
433
+ const result = await this.#c.invoke({ _: "messages.addChatUser", chat_id: chat.chat_id, user_id: user, fwd_limit: params?.historyLimit ?? 0 });
417
434
  return result.missing_invitees.map(constructFailedInvitation);
418
435
  }
419
436
  else if (Api.is("inputPeerChannel", chat)) {
420
- const result = await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.inviteToChannel", channel: { ...chat, _: "inputChannel" }, users: [user] });
437
+ const result = await this.#c.invoke({ _: "channels.inviteToChannel", channel: { ...chat, _: "inputChannel" }, users: [user] });
421
438
  return result.missing_invitees.map(constructFailedInvitation);
422
439
  }
423
440
  unreachable();
424
441
  }
425
442
  async addChatMembers(chatId, userIds) {
426
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("addChatMembers");
427
- const chat = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId);
443
+ this.#c.storage.assertUser("addChatMembers");
444
+ const chat = await this.#c.getInputPeer(chatId);
428
445
  if (Api.isOneOf(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
429
446
  throw new InputError("Cannot add members to private chats");
430
447
  }
431
448
  const users = new Array();
432
449
  for (const userId of userIds) {
433
- users.push(await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputUser(userId));
450
+ users.push(await this.#c.getInputUser(userId));
434
451
  }
435
452
  if (Api.is("inputPeerChat", chat)) {
436
453
  throw new InputError("addChatMembers cannot be used with basic groups");
437
454
  }
438
455
  else if (canBeInputChannel(chat)) {
439
- const result = await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.inviteToChannel", channel: toInputChannel(chat), users });
456
+ const result = await this.#c.invoke({ _: "channels.inviteToChannel", channel: toInputChannel(chat), users });
440
457
  return result.missing_invitees.map(constructFailedInvitation);
441
458
  }
442
459
  unreachable();
443
460
  }
444
461
  async getRecommendedChannels() {
445
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("getRecommendedChannels");
446
- const result = await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.getChannelRecommendations" });
462
+ this.#c.storage.assertUser("getRecommendedChannels");
463
+ const result = await this.#c.invoke({ _: "channels.getChannelRecommendations" });
447
464
  return result.chats.map((v) => constructChatP(v)).filter((v) => v.type === "channel");
448
465
  }
449
466
  async getSimilarChannels(chatId) {
450
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("getSimilarChannels");
451
- const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
452
- const result = await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.getChannelRecommendations", channel });
467
+ this.#c.storage.assertUser("getSimilarChannels");
468
+ const channel = await this.#c.getInputChannel(chatId);
469
+ const result = await this.#c.invoke({ _: "channels.getChannelRecommendations", channel });
453
470
  return result.chats.map((v) => constructChatP(v)).filter((v) => v.type === "channel");
454
471
  }
455
472
  async getSimilarBots(chatId) {
456
- __classPrivateFieldGet(this, _ChatManager_c, "f").storage.assertUser("getSimilarBots");
457
- const bot = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputUser(chatId);
458
- const result = await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "bots.getBotRecommendations", bot });
473
+ this.#c.storage.assertUser("getSimilarBots");
474
+ const bot = await this.#c.getInputUser(chatId);
475
+ const result = await this.#c.invoke({ _: "bots.getBotRecommendations", bot });
459
476
  return result.users.map((v) => constructChatP(v)).filter((v) => v.type === "private");
460
477
  }
461
478
  }
462
- _ChatManager_c = new WeakMap(), _ChatManager_instances = new WeakSet(), _ChatManager_toggleJoinRequests =
463
- // JOIN REQUESTS //
464
- async function _ChatManager_toggleJoinRequests(chatId, isEnabled) {
465
- const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
466
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.toggleJoinRequest", channel, enabled: isEnabled });
467
- }, _ChatManager_toggleSlowMode = async function _ChatManager_toggleSlowMode(chatId, seconds) {
468
- const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
469
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.toggleSlowMode", channel, seconds });
470
- }, _ChatManager_setIsMemberListVisible = async function _ChatManager_setIsMemberListVisible(chatId, isVisible) {
471
- const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
472
- const enabled = !isVisible;
473
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.toggleParticipantsHidden", channel, enabled });
474
- }, _ChatManager_setIsTopicsEnabled = async function _ChatManager_setIsTopicsEnabled(chatId, isEnabled, isShownAsTabs) {
475
- const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
476
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.toggleForum", channel, enabled: isEnabled, tabs: isShownAsTabs });
477
- }, _ChatManager_setIsAntispamEnabled = async function _ChatManager_setIsAntispamEnabled(chatId, isEnabled) {
478
- const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
479
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.toggleAntiSpam", channel, enabled: isEnabled });
480
- }, _ChatManager_setIsSignaturesEnabled = async function _ChatManager_setIsSignaturesEnabled(chatId, isEnabled, params) {
481
- const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
482
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.toggleSignatures", channel, signatures_enabled: isEnabled ? true : undefined, profiles_enabled: params?.showAuthorProfile ? true : undefined });
483
- }, _ChatManager_setIsSharingEnabled = async function _ChatManager_setIsSharingEnabled(chatId, isSharingEnabled) {
484
- const peer = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputPeer(chatId);
485
- await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "messages.toggleNoForwards", peer, enabled: !isSharingEnabled });
486
- };