@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
@@ -18,18 +18,6 @@
18
18
  * You should have received a copy of the GNU Lesser General Public License
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
22
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
23
- 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");
24
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
25
- };
26
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
27
- if (kind === "m") throw new TypeError("Private method is not writable");
28
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
29
- 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");
30
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
31
- };
32
- var _Client_instances, _Client_clients, _Client_downloadPools, _Client_uploadPools, _Client_guaranteeUpdateDelivery, _Client_accountManager, _Client_botInfoManager, _Client_businessConnectionManager, _Client_fileManager, _Client_networkStatisticsManager, _Client_paymentManager, _Client_reactionManager, _Client_translationsManager, _Client_updateManager, _Client_messageManager, _Client_videoChatManager, _Client_callbackQueryManager, _Client_chatListManager, _Client_chatManager, _Client_checklistManager, _Client_forumManager, _Client_giftManager, _Client_inlineQueryManager, _Client_linkPreviewManager, _Client_pollManager, _Client_storyManager, _Client_managers, _Client_storage_, _Client_messageStorage_, _Client_parseMode, _Client_apiId, _Client_apiHash, _Client_transportProvider, _Client_publicKeys, _Client_outgoingMessages, _Client_persistCache, _Client_disableUpdates, _Client_authString, _Client_initialDc, _Client_L, _Client_LsignIn, _Client_LupdateGapRecoveryLoop, _Client_LstorageWriteLoop, _Client_LhandleMigrationError, _Client_Lmin, _Client_setMainClient, _Client_newClient, _Client_disconnectAllClients, _Client_client_get, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_getIsPremium, _Client_lastUpdates, _Client_updateGapRecoveryLoop, _Client_clientDisconnectionLoop, _Client_storageWriteLoop, _Client_checkAuthorization, _Client_getClient, _Client_getMainClientMutex, _Client_getMainClient, _Client_getDownloadClient, _Client_getUploadPoolSize, _Client_getUploadClient, _Client_setupClient, _Client_importAuthorization, _Client_invoke, _Client_handleInvokeError, _Client_authStringImported, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerChatId, _Client_getInputPeerInner, _Client_getMinInputPeer, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe, _Client_getMeInner, _Client_previouslyConnected, _Client_lastConnectionState, _Client_onConnectionStateChange;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.Client = exports.handleMigrationError = exports.restartAuth = void 0;
35
23
  const _0_deps_js_1 = require("../0_deps.js");
@@ -82,258 +70,131 @@ const mustGetPeer = Symbol();
82
70
  * An MTKruto client.
83
71
  */
84
72
  class Client extends _5_composer_js_1.Composer {
73
+ #clients = new Array();
74
+ #downloadPools = {};
75
+ #uploadPools = {};
76
+ #guaranteeUpdateDelivery;
77
+ // 2_
78
+ #accountManager;
79
+ #botInfoManager;
80
+ #businessConnectionManager;
81
+ #fileManager;
82
+ #networkStatisticsManager;
83
+ #paymentManager;
84
+ #reactionManager;
85
+ #translationsManager;
86
+ #updateManager;
87
+ // 3_
88
+ #messageManager;
89
+ #videoChatManager;
90
+ // 4_
91
+ #callbackQueryManager;
92
+ #chatListManager;
93
+ #chatManager;
94
+ #checklistManager;
95
+ #forumManager;
96
+ #giftManager;
97
+ #inlineQueryManager;
98
+ #linkPreviewManager;
99
+ #pollManager;
100
+ #storyManager;
101
+ // deno-lint-ignore no-explicit-any
102
+ #managers;
85
103
  // deno-lint-ignore no-explicit-any
86
104
  get managers() {
87
- return __classPrivateFieldGet(this, _Client_managers, "f") ?? (__classPrivateFieldSet(this, _Client_managers, __classPrivateFieldGet(this, _Client_managers, "f") ?? {
105
+ return this.#managers ?? (this.#managers ??= {
88
106
  // 2_
89
- accountManager: __classPrivateFieldGet(this, _Client_accountManager, "f"),
90
- botInfoManager: __classPrivateFieldGet(this, _Client_botInfoManager, "f"),
91
- businessConnectionManager: __classPrivateFieldGet(this, _Client_businessConnectionManager, "f"),
92
- fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f"),
93
- networkStatisticsManager: __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f"),
94
- paymentManager: __classPrivateFieldGet(this, _Client_paymentManager, "f"),
95
- reactionManager: __classPrivateFieldGet(this, _Client_reactionManager, "f"),
96
- translationsManager: __classPrivateFieldGet(this, _Client_translationsManager, "f"),
97
- updateManager: __classPrivateFieldGet(this, _Client_updateManager, "f"),
107
+ accountManager: this.#accountManager,
108
+ botInfoManager: this.#botInfoManager,
109
+ businessConnectionManager: this.#businessConnectionManager,
110
+ fileManager: this.#fileManager,
111
+ networkStatisticsManager: this.#networkStatisticsManager,
112
+ paymentManager: this.#paymentManager,
113
+ reactionManager: this.#reactionManager,
114
+ translationsManager: this.#translationsManager,
115
+ updateManager: this.#updateManager,
98
116
  // 3_
99
- messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f"),
100
- videoChatManager: __classPrivateFieldGet(this, _Client_videoChatManager, "f"),
117
+ messageManager: this.#messageManager,
118
+ videoChatManager: this.#videoChatManager,
101
119
  // 4_
102
- callbackQueryManager: __classPrivateFieldGet(this, _Client_callbackQueryManager, "f"),
103
- chatListManager: __classPrivateFieldGet(this, _Client_chatListManager, "f"),
104
- chatManager: __classPrivateFieldGet(this, _Client_chatManager, "f"),
105
- checklistManager: __classPrivateFieldGet(this, _Client_checklistManager, "f"),
106
- forumManager: __classPrivateFieldGet(this, _Client_forumManager, "f"),
107
- giftManager: __classPrivateFieldGet(this, _Client_giftManager, "f"),
108
- inlineQueryManager: __classPrivateFieldGet(this, _Client_inlineQueryManager, "f"),
109
- linkPreviewManager: __classPrivateFieldGet(this, _Client_linkPreviewManager, "f"),
110
- pollManager: __classPrivateFieldGet(this, _Client_pollManager, "f"),
111
- storyManager: __classPrivateFieldGet(this, _Client_storyManager, "f"),
112
- }, "f"));
120
+ callbackQueryManager: this.#callbackQueryManager,
121
+ chatListManager: this.#chatListManager,
122
+ chatManager: this.#chatManager,
123
+ checklistManager: this.#checklistManager,
124
+ forumManager: this.#forumManager,
125
+ giftManager: this.#giftManager,
126
+ inlineQueryManager: this.#inlineQueryManager,
127
+ linkPreviewManager: this.#linkPreviewManager,
128
+ pollManager: this.#pollManager,
129
+ storyManager: this.#storyManager,
130
+ });
113
131
  }
132
+ #storage_;
133
+ #messageStorage_;
134
+ storage;
135
+ messageStorage;
136
+ #parseMode;
137
+ #apiId;
138
+ #apiHash;
139
+ #transportProvider;
140
+ appVersion;
141
+ deviceModel;
142
+ language;
143
+ platform;
144
+ systemLangCode;
145
+ systemVersion;
146
+ #publicKeys;
147
+ #outgoingMessages;
148
+ #persistCache;
149
+ #disableUpdates;
150
+ #authString;
151
+ #initialDc;
152
+ #L;
153
+ #LsignIn;
154
+ #LupdateGapRecoveryLoop;
155
+ #LstorageWriteLoop;
156
+ #LhandleMigrationError;
157
+ #Lmin;
114
158
  /**
115
159
  * Constructs the client.
116
160
  */
117
161
  constructor(params) {
118
162
  super();
119
- _Client_instances.add(this);
120
- _Client_clients.set(this, new Array());
121
- _Client_downloadPools.set(this, {});
122
- _Client_uploadPools.set(this, {});
123
- _Client_guaranteeUpdateDelivery.set(this, void 0);
124
- // 2_
125
- _Client_accountManager.set(this, void 0);
126
- _Client_botInfoManager.set(this, void 0);
127
- _Client_businessConnectionManager.set(this, void 0);
128
- _Client_fileManager.set(this, void 0);
129
- _Client_networkStatisticsManager.set(this, void 0);
130
- _Client_paymentManager.set(this, void 0);
131
- _Client_reactionManager.set(this, void 0);
132
- _Client_translationsManager.set(this, void 0);
133
- _Client_updateManager.set(this, void 0);
134
- // 3_
135
- _Client_messageManager.set(this, void 0);
136
- _Client_videoChatManager.set(this, void 0);
137
- // 4_
138
- _Client_callbackQueryManager.set(this, void 0);
139
- _Client_chatListManager.set(this, void 0);
140
- _Client_chatManager.set(this, void 0);
141
- _Client_checklistManager.set(this, void 0);
142
- _Client_forumManager.set(this, void 0);
143
- _Client_giftManager.set(this, void 0);
144
- _Client_inlineQueryManager.set(this, void 0);
145
- _Client_linkPreviewManager.set(this, void 0);
146
- _Client_pollManager.set(this, void 0);
147
- _Client_storyManager.set(this, void 0);
148
- // deno-lint-ignore no-explicit-any
149
- _Client_managers.set(this, void 0);
150
- _Client_storage_.set(this, void 0);
151
- _Client_messageStorage_.set(this, void 0);
152
- Object.defineProperty(this, "storage", {
153
- enumerable: true,
154
- configurable: true,
155
- writable: true,
156
- value: void 0
157
- });
158
- Object.defineProperty(this, "messageStorage", {
159
- enumerable: true,
160
- configurable: true,
161
- writable: true,
162
- value: void 0
163
- });
164
- _Client_parseMode.set(this, void 0);
165
- _Client_apiId.set(this, void 0);
166
- _Client_apiHash.set(this, void 0);
167
- _Client_transportProvider.set(this, void 0);
168
- Object.defineProperty(this, "appVersion", {
169
- enumerable: true,
170
- configurable: true,
171
- writable: true,
172
- value: void 0
173
- });
174
- Object.defineProperty(this, "deviceModel", {
175
- enumerable: true,
176
- configurable: true,
177
- writable: true,
178
- value: void 0
179
- });
180
- Object.defineProperty(this, "language", {
181
- enumerable: true,
182
- configurable: true,
183
- writable: true,
184
- value: void 0
185
- });
186
- Object.defineProperty(this, "platform", {
187
- enumerable: true,
188
- configurable: true,
189
- writable: true,
190
- value: void 0
191
- });
192
- Object.defineProperty(this, "systemLangCode", {
193
- enumerable: true,
194
- configurable: true,
195
- writable: true,
196
- value: void 0
197
- });
198
- Object.defineProperty(this, "systemVersion", {
199
- enumerable: true,
200
- configurable: true,
201
- writable: true,
202
- value: void 0
203
- });
204
- _Client_publicKeys.set(this, void 0);
205
- _Client_outgoingMessages.set(this, void 0);
206
- _Client_persistCache.set(this, void 0);
207
- _Client_disableUpdates.set(this, void 0);
208
- _Client_authString.set(this, void 0);
209
- _Client_initialDc.set(this, void 0);
210
- _Client_L.set(this, void 0);
211
- _Client_LsignIn.set(this, void 0);
212
- _Client_LupdateGapRecoveryLoop.set(this, void 0);
213
- _Client_LstorageWriteLoop.set(this, void 0);
214
- _Client_LhandleMigrationError.set(this, void 0);
215
- _Client_Lmin.set(this, void 0);
216
- _Client_lastPropagatedConnectionState.set(this, null);
217
- _Client_stateChangeHandler.set(this, ((isConnected) => {
218
- const connectionState = isConnected ? "ready" : "notConnected";
219
- if (__classPrivateFieldGet(this, _Client_lastPropagatedConnectionState, "f") !== connectionState) {
220
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateConnectionState).call(this, connectionState);
221
- }
222
- }).bind(this));
223
- _Client_storageInited.set(this, false);
224
- _Client_connectMutex.set(this, new _1_utilities_js_1.Mutex());
225
- _Client_lastPropagatedAuthorizationState.set(this, null);
226
- _Client_lastUpdates.set(this, new Date());
227
- _Client_updateGapRecoveryLoop.set(this, new _0_abortable_loop_js_1.AbortableLoop(async (loop, signal) => {
228
- await (0, _0_deps_js_1.delay)(60 * _0_deps_js_1.SECOND, { signal });
229
- if (!this.isConnected) {
230
- loop.abort();
231
- return;
232
- }
233
- if (Date.now() - __classPrivateFieldGet(this, _Client_lastUpdates, "f").getTime() >= 15 * _0_deps_js_1.MINUTE) {
234
- (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("lastUpdates").then(() => {
235
- __classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
236
- }));
237
- }
238
- }, (loop, err) => {
239
- if (!this.isConnected) {
240
- loop.abort();
241
- }
242
- else {
243
- __classPrivateFieldGet(this, _Client_LupdateGapRecoveryLoop, "f").error(err);
244
- }
245
- }));
246
- _Client_clientDisconnectionLoop.set(this, new _0_abortable_loop_js_1.AbortableLoop(async (loop, signal) => {
247
- await (0, _0_deps_js_1.delay)(60 * _0_deps_js_1.SECOND, { signal });
248
- if (!this.isConnected) {
249
- loop.abort();
250
- return;
251
- }
252
- const now = Date.now();
253
- const disconnectAfter = 5 * _0_deps_js_1.MINUTE;
254
- for (const [i, client] of __classPrivateFieldGet(this, _Client_clients, "f").entries()) {
255
- if (i > 0 && !client.isDisconnected && client.lastRequest && now - client.lastRequest.getTime() >= disconnectAfter) {
256
- client?.disconnect();
257
- }
258
- }
259
- }, (loop) => {
260
- if (!this.isConnected) {
261
- loop.abort();
262
- }
263
- }));
264
- _Client_storageWriteLoop.set(this, new _0_abortable_loop_js_1.AbortableLoop(async (_loop, signal) => {
265
- await (0, _0_deps_js_1.delay)(5 * _0_deps_js_1.SECOND, { signal });
266
- await this.messageStorage.commit();
267
- await this.storage.commit();
268
- }, (err) => {
269
- __classPrivateFieldGet(this, _Client_LstorageWriteLoop, "f").error(err);
270
- }));
271
- _Client_getMainClientMutex.set(this, new _1_utilities_js_1.Mutex());
272
- _Client_handleInvokeError.set(this, (0, _1_invoke_middleware_js_1.skipInvoke)());
273
- /**
274
- * Invokes a function waiting and returning its reply.
275
- * Requires the client to be connected.
276
- *
277
- * @param function_ The function to invoke.
278
- */
279
- Object.defineProperty(this, "invoke", {
280
- enumerable: true,
281
- configurable: true,
282
- writable: true,
283
- value: Object.assign(__classPrivateFieldGet(this, _Client_instances, "m", _Client_invoke), {
284
- use: (handler) => {
285
- const handle = __classPrivateFieldGet(this, _Client_handleInvokeError, "f");
286
- __classPrivateFieldSet(this, _Client_handleInvokeError, async (ctx, next) => {
287
- let result = null;
288
- return await handle(ctx, async () => {
289
- if (result !== null)
290
- return result;
291
- result = await handler(ctx, next);
292
- return result;
293
- });
294
- }, "f");
295
- },
296
- })
297
- });
298
- _Client_authStringImported.set(this, false);
299
- _Client_lastGetMe.set(this, null);
300
- _Client_previouslyConnected.set(this, false);
301
- _Client_lastConnectionState.set(this, false);
302
- __classPrivateFieldSet(this, _Client_apiId, params?.apiId ?? 0, "f");
303
- __classPrivateFieldSet(this, _Client_apiHash, params?.apiHash ?? "", "f");
304
- __classPrivateFieldSet(this, _Client_transportProvider, params?.transportProvider, "f");
305
- __classPrivateFieldSet(this, _Client_initialDc, params?.initialDc ?? _4_constants_js_1.INITIAL_DC, "f");
306
- __classPrivateFieldSet(this, _Client_storage_, params?.storage || new _2_storage_js_1.StorageMemory(), "f");
307
- __classPrivateFieldSet(this, _Client_persistCache, params?.persistCache ?? false, "f");
308
- if (!__classPrivateFieldGet(this, _Client_persistCache, "f")) {
309
- __classPrivateFieldSet(this, _Client_messageStorage_, new _2_storage_js_1.StorageMemory(), "f");
163
+ this.#apiId = params?.apiId ?? 0;
164
+ this.#apiHash = params?.apiHash ?? "";
165
+ this.#transportProvider = params?.transportProvider;
166
+ this.#initialDc = params?.initialDc ?? _4_constants_js_1.INITIAL_DC;
167
+ this.#storage_ = params?.storage || new _2_storage_js_1.StorageMemory();
168
+ this.#persistCache = params?.persistCache ?? false;
169
+ if (!this.#persistCache) {
170
+ this.#messageStorage_ = new _2_storage_js_1.StorageMemory();
310
171
  }
311
172
  else {
312
- __classPrivateFieldSet(this, _Client_messageStorage_, __classPrivateFieldGet(this, _Client_storage_, "f"), "f");
173
+ this.#messageStorage_ = this.#storage_;
313
174
  }
314
- this.storage = new _0_storage_operations_js_1.StorageOperations(__classPrivateFieldGet(this, _Client_storage_, "f"));
315
- this.messageStorage = new _0_storage_operations_js_1.StorageOperations(__classPrivateFieldGet(this, _Client_messageStorage_, "f"));
316
- __classPrivateFieldSet(this, _Client_parseMode, params?.parseMode ?? null, "f");
317
- __classPrivateFieldSet(this, _Client_disableUpdates, params?.disableUpdates ?? false, "f");
318
- __classPrivateFieldSet(this, _Client_authString, params?.authString, "f");
175
+ this.storage = new _0_storage_operations_js_1.StorageOperations(this.#storage_);
176
+ this.messageStorage = new _0_storage_operations_js_1.StorageOperations(this.#messageStorage_);
177
+ this.#parseMode = params?.parseMode ?? null;
178
+ this.#disableUpdates = params?.disableUpdates ?? false;
179
+ this.#authString = params?.authString;
319
180
  this.appVersion = params?.appVersion ?? _4_constants_js_1.APP_VERSION;
320
181
  this.deviceModel = params?.deviceModel ?? _4_constants_js_1.DEVICE_MODEL;
321
182
  this.language = params?.language ?? _4_constants_js_1.LANG_CODE;
322
183
  this.platform = params?.platform ?? _4_constants_js_1.LANG_PACK;
323
184
  this.systemLangCode = params?.systemLangCode ?? _4_constants_js_1.SYSTEM_LANG_CODE;
324
185
  this.systemVersion = params?.systemVersion ?? _4_constants_js_1.SYSTEM_VERSION;
325
- __classPrivateFieldSet(this, _Client_publicKeys, params?.publicKeys, "f");
326
- __classPrivateFieldSet(this, _Client_outgoingMessages, params?.outgoingMessages ?? false, "f");
327
- __classPrivateFieldSet(this, _Client_guaranteeUpdateDelivery, params?.guaranteeUpdateDelivery ?? false, "f");
328
- const L = __classPrivateFieldSet(this, _Client_L, (0, _1_utilities_js_1.getLogger)("Client").client(id++), "f");
329
- __classPrivateFieldSet(this, _Client_LsignIn, L.branch("signIn"), "f");
330
- __classPrivateFieldSet(this, _Client_LupdateGapRecoveryLoop, L.branch("updateGapRecoveryLoop"), "f");
331
- __classPrivateFieldSet(this, _Client_LstorageWriteLoop, L.branch("storageWriteLoop"), "f");
332
- __classPrivateFieldSet(this, _Client_LhandleMigrationError, L.branch("[handleMigrationError]"), "f");
333
- __classPrivateFieldSet(this, _Client_Lmin, L.branch("min"), "f");
186
+ this.#publicKeys = params?.publicKeys;
187
+ this.#outgoingMessages = params?.outgoingMessages ?? false;
188
+ this.#guaranteeUpdateDelivery = params?.guaranteeUpdateDelivery ?? false;
189
+ const L = this.#L = (0, _1_utilities_js_1.getLogger)("Client").client(id++);
190
+ this.#LsignIn = L.branch("signIn");
191
+ this.#LupdateGapRecoveryLoop = L.branch("updateGapRecoveryLoop");
192
+ this.#LstorageWriteLoop = L.branch("storageWriteLoop");
193
+ this.#LhandleMigrationError = L.branch("[handleMigrationError]");
194
+ this.#Lmin = L.branch("min");
334
195
  const c = {
335
196
  id,
336
- getUploadPoolSize: __classPrivateFieldGet(this, _Client_instances, "m", _Client_getUploadPoolSize).bind(this),
197
+ getUploadPoolSize: this.#getUploadPoolSize.bind(this),
337
198
  invoke: async (function_, params) => {
338
199
  if (params?.businessConnectionId) {
339
200
  if (_2_tl_js_1.Mtproto.is("ping", function_)) {
@@ -347,49 +208,49 @@ class Client extends _5_composer_js_1.Composer {
347
208
  },
348
209
  storage: this.storage,
349
210
  messageStorage: this.messageStorage,
350
- guaranteeUpdateDelivery: __classPrivateFieldGet(this, _Client_guaranteeUpdateDelivery, "f"),
351
- setConnectionState: __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateConnectionState).bind(this),
352
- resetConnectionState: () => __classPrivateFieldGet(this, _Client_stateChangeHandler, "f").call(this, this.isConnected),
353
- getSelfId: __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).bind(this),
354
- getIsPremium: __classPrivateFieldGet(this, _Client_instances, "m", _Client_getIsPremium).bind(this),
211
+ guaranteeUpdateDelivery: this.#guaranteeUpdateDelivery,
212
+ setConnectionState: this.#propagateConnectionState.bind(this),
213
+ resetConnectionState: () => this.#stateChangeHandler(this.isConnected),
214
+ getSelfId: this.#getSelfId.bind(this),
215
+ getIsPremium: this.#getIsPremium.bind(this),
355
216
  getInputPeer: this.getInputPeer.bind(this),
356
217
  getInputChannel: this.getInputChannel.bind(this),
357
218
  getInputUser: this.getInputUser.bind(this),
358
- getInputPeerChatId: __classPrivateFieldGet(this, _Client_instances, "m", _Client_getInputPeerChatId).bind(this),
219
+ getInputPeerChatId: this.#getInputPeerChatId.bind(this),
359
220
  getPeer: this[mustGetPeer].bind(this),
360
- handleUpdate: __classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).bind(this),
361
- parseMode: __classPrivateFieldGet(this, _Client_parseMode, "f"),
362
- outgoingMessages: __classPrivateFieldGet(this, _Client_outgoingMessages, "f"),
221
+ handleUpdate: this.#queueHandleCtxUpdate.bind(this),
222
+ parseMode: this.#parseMode,
223
+ outgoingMessages: this.#outgoingMessages,
363
224
  dropPendingUpdates: params?.dropPendingUpdates,
364
225
  isDisconnected: () => this.isDisconnected,
365
226
  langPack: this.platform,
366
227
  langCode: this.language,
367
228
  };
368
229
  // 2_
369
- __classPrivateFieldSet(this, _Client_accountManager, new _2_account_manager_js_1.AccountManager(c), "f");
370
- __classPrivateFieldSet(this, _Client_botInfoManager, new _2_bot_info_manager_js_1.BotInfoManager(c), "f");
371
- __classPrivateFieldSet(this, _Client_businessConnectionManager, new _2_business_connection_manager_js_1.BusinessConnectionManager(c), "f");
372
- const fileManager = __classPrivateFieldSet(this, _Client_fileManager, new _2_file_manager_js_1.FileManager(c), "f");
373
- __classPrivateFieldSet(this, _Client_networkStatisticsManager, new _2_network_statistics_manager_js_1.NetworkStatisticsManager(c), "f");
374
- __classPrivateFieldSet(this, _Client_paymentManager, new _2_payment_manager_js_1.PaymentManager(c), "f");
375
- __classPrivateFieldSet(this, _Client_reactionManager, new _2_reaction_manager_js_1.ReactionManager(c), "f");
376
- __classPrivateFieldSet(this, _Client_translationsManager, new _2_translations_manager_js_1.TranslationsManager(c), "f");
377
- __classPrivateFieldSet(this, _Client_updateManager, new _2_update_manager_js_1.UpdateManager(c), "f");
230
+ this.#accountManager = new _2_account_manager_js_1.AccountManager(c);
231
+ this.#botInfoManager = new _2_bot_info_manager_js_1.BotInfoManager(c);
232
+ this.#businessConnectionManager = new _2_business_connection_manager_js_1.BusinessConnectionManager(c);
233
+ const fileManager = this.#fileManager = new _2_file_manager_js_1.FileManager(c);
234
+ this.#networkStatisticsManager = new _2_network_statistics_manager_js_1.NetworkStatisticsManager(c);
235
+ this.#paymentManager = new _2_payment_manager_js_1.PaymentManager(c);
236
+ this.#reactionManager = new _2_reaction_manager_js_1.ReactionManager(c);
237
+ this.#translationsManager = new _2_translations_manager_js_1.TranslationsManager(c);
238
+ this.#updateManager = new _2_update_manager_js_1.UpdateManager(c);
378
239
  // 3_
379
- const messageManager = __classPrivateFieldSet(this, _Client_messageManager, new _3_message_manager_js_1.MessageManager({ ...c, fileManager }), "f");
380
- __classPrivateFieldSet(this, _Client_videoChatManager, new _3_video_chat_manager_js_1.VideoChatManager({ ...c, fileManager }), "f");
240
+ const messageManager = this.#messageManager = new _3_message_manager_js_1.MessageManager({ ...c, fileManager });
241
+ this.#videoChatManager = new _3_video_chat_manager_js_1.VideoChatManager({ ...c, fileManager });
381
242
  // 4_
382
- __classPrivateFieldSet(this, _Client_callbackQueryManager, new _4_callback_query_manager_js_1.CallbackQueryManager({ ...c, messageManager }), "f");
383
- __classPrivateFieldSet(this, _Client_chatListManager, new _4_chat_list_manager_js_1.ChatListManager({ ...c, fileManager, messageManager }), "f");
384
- __classPrivateFieldSet(this, _Client_chatManager, new _4_chat_manager_js_1.ChatManager({ ...c, fileManager, messageManager }), "f");
385
- __classPrivateFieldSet(this, _Client_checklistManager, new _4_checklist_manager_js_1.ChecklistManager({ ...c, messageManager }), "f");
386
- __classPrivateFieldSet(this, _Client_forumManager, new _4_forum_manager_js_1.ForumManager({ ...c, messageManager }), "f");
387
- __classPrivateFieldSet(this, _Client_giftManager, new _4_gift_manager_js_1.GiftManager({ ...c, messageManager }), "f");
388
- __classPrivateFieldSet(this, _Client_inlineQueryManager, new _4_inline_query_manager_js_1.InlineQueryManager({ ...c, messageManager }), "f");
389
- __classPrivateFieldSet(this, _Client_linkPreviewManager, new _4_link_preview_manager_js_1.LinkPreviewManager({ ...c, messageManager }), "f");
390
- __classPrivateFieldSet(this, _Client_pollManager, new _4_poll_manager_js_1.PollManager({ ...c, messageManager }), "f");
391
- __classPrivateFieldSet(this, _Client_storyManager, new _4_story_manager_js_1.StoryManager({ ...c, fileManager, messageManager }), "f");
392
- __classPrivateFieldGet(this, _Client_updateManager, "f").setUpdateHandler(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).bind(this));
243
+ this.#callbackQueryManager = new _4_callback_query_manager_js_1.CallbackQueryManager({ ...c, messageManager });
244
+ this.#chatListManager = new _4_chat_list_manager_js_1.ChatListManager({ ...c, fileManager, messageManager });
245
+ this.#chatManager = new _4_chat_manager_js_1.ChatManager({ ...c, fileManager, messageManager });
246
+ this.#checklistManager = new _4_checklist_manager_js_1.ChecklistManager({ ...c, messageManager });
247
+ this.#forumManager = new _4_forum_manager_js_1.ForumManager({ ...c, messageManager });
248
+ this.#giftManager = new _4_gift_manager_js_1.GiftManager({ ...c, messageManager });
249
+ this.#inlineQueryManager = new _4_inline_query_manager_js_1.InlineQueryManager({ ...c, messageManager });
250
+ this.#linkPreviewManager = new _4_link_preview_manager_js_1.LinkPreviewManager({ ...c, messageManager });
251
+ this.#pollManager = new _4_poll_manager_js_1.PollManager({ ...c, messageManager });
252
+ this.#storyManager = new _4_story_manager_js_1.StoryManager({ ...c, fileManager, messageManager });
253
+ this.#updateManager.setUpdateHandler(this.#handleUpdate.bind(this));
393
254
  if (params?.defaultHandlers ?? true) {
394
255
  this.invoke.use(async ({ error }, next) => {
395
256
  if (error instanceof _4_errors_js_1.FloodWait && error.seconds <= 10) {
@@ -403,59 +264,127 @@ class Client extends _5_composer_js_1.Composer {
403
264
  });
404
265
  }
405
266
  }
267
+ #setMainClient(client) {
268
+ this.#disconnectAllClients();
269
+ this.#clients = [client];
270
+ client.handlers.onUpdate = (updates) => {
271
+ this.#updateManager.processUpdates(updates, true, null);
272
+ this.#lastUpdates = new Date();
273
+ };
274
+ client.handlers.onDeserializationError = async () => {
275
+ await this.#updateManager.recoverUpdateGap("deserialization error");
276
+ };
277
+ client.handlers.onNewServerSalt = async (serverSalt) => {
278
+ await this.storage.setServerSalt(serverSalt);
279
+ };
280
+ client.onConnectionStateChange = this.#onConnectionStateChange.bind(this);
281
+ }
282
+ #newClient(dc, main, isCdn) {
283
+ const client = new _2_client_encrypted_js_1.ClientEncrypted(dc, this.#apiId, {
284
+ appVersion: this.appVersion,
285
+ deviceModel: this.deviceModel,
286
+ langCode: this.language,
287
+ langPack: this.platform,
288
+ systemLangCode: this.systemLangCode,
289
+ systemVersion: this.systemVersion,
290
+ transportProvider: this.#transportProvider,
291
+ isCdn: isCdn,
292
+ disableUpdates: !main || isCdn,
293
+ publicKeys: this.#publicKeys,
294
+ });
295
+ client.connectionCallback = this.#networkStatisticsManager.getTransportReadWriteCallback(isCdn);
296
+ return client;
297
+ }
298
+ #disconnectAllClients() {
299
+ for (const client of this.#clients) {
300
+ client.disconnect();
301
+ }
302
+ for (const pool of Object.values(this.#downloadPools)) {
303
+ pool.disconnect();
304
+ }
305
+ for (const pool of Object.values(this.#uploadPools)) {
306
+ pool.disconnect();
307
+ }
308
+ }
309
+ get #client() {
310
+ return this.#clients[0];
311
+ }
406
312
  // direct ClientEncrypted property proxies
407
313
  get isConnected() {
408
- return __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.isConnected ?? false;
314
+ return this.#client?.isConnected ?? false;
409
315
  }
410
316
  get isDisconnected() {
411
- return __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.isDisconnected ?? true;
317
+ return this.#client?.isDisconnected ?? true;
318
+ }
319
+ #propagateConnectionState(connectionState) {
320
+ this.#queueHandleCtxUpdate({ connectionState });
321
+ this.#lastPropagatedConnectionState = connectionState;
322
+ }
323
+ #lastPropagatedConnectionState = null;
324
+ #stateChangeHandler = ((isConnected) => {
325
+ const connectionState = isConnected ? "ready" : "notConnected";
326
+ if (this.#lastPropagatedConnectionState !== connectionState) {
327
+ this.#propagateConnectionState(connectionState);
328
+ }
329
+ }).bind(this);
330
+ #storageInited = false;
331
+ async #initStorage() {
332
+ if (!this.#storageInited) {
333
+ await this.storage.initialize();
334
+ if (!this.#guaranteeUpdateDelivery) {
335
+ await this.storage.deleteUpdates();
336
+ await this.storage.commit(true);
337
+ }
338
+ this.#storageInited = true;
339
+ }
412
340
  }
341
+ #connectMutex = new _1_utilities_js_1.Mutex();
413
342
  /**
414
343
  * Loads the session if `setDc` was not called, initializes and connnects
415
344
  * a `ClientPlain` to generate auth key if there was none, and connects the client.
416
345
  * Before establishing the connection, the session is saved.
417
346
  */
418
347
  async connect() {
419
- const unlock = await __classPrivateFieldGet(this, _Client_connectMutex, "f").lock();
348
+ const unlock = await this.#connectMutex.lock();
420
349
  try {
421
350
  if (this.isConnected) {
422
351
  return;
423
352
  }
424
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initStorage).call(this);
425
- if (__classPrivateFieldGet(this, _Client_authString, "f") && !__classPrivateFieldGet(this, _Client_authStringImported, "f")) {
426
- await this.importAuthString(__classPrivateFieldGet(this, _Client_authString, "f"));
353
+ await this.#initStorage();
354
+ if (this.#authString && !this.#authStringImported) {
355
+ await this.importAuthString(this.#authString);
427
356
  }
428
357
  const auth = this.storage.auth.mustGet();
429
358
  if (auth.authKey !== null && auth.dc !== null) {
430
- if (!__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get) || __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc !== auth.dc) {
431
- __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.disconnect();
432
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMainClient).call(this, __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, auth.dc, true, false));
359
+ if (!this.#client || this.#client.dc !== auth.dc) {
360
+ this.#client?.disconnect();
361
+ this.#setMainClient(this.#newClient(auth.dc, true, false));
433
362
  }
434
- await __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).setAuthKey(auth.authKey);
435
- if (__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).serverSalt === 0n) {
436
- __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).serverSalt = await this.storage.getServerSalt() ?? 0n;
363
+ await this.#client.setAuthKey(auth.authKey);
364
+ if (this.#client.serverSalt === 0n) {
365
+ this.#client.serverSalt = await this.storage.getServerSalt() ?? 0n;
437
366
  }
438
367
  }
439
368
  else {
440
- const dc = auth.dc ?? __classPrivateFieldGet(this, _Client_initialDc, "f");
441
- if (!__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get) || __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc !== dc) {
442
- __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.disconnect();
443
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMainClient).call(this, __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, true, false));
369
+ const dc = auth.dc ?? this.#initialDc;
370
+ if (!this.#client || this.#client.dc !== dc) {
371
+ this.#client?.disconnect();
372
+ this.#setMainClient(this.#newClient(dc, true, false));
444
373
  }
445
374
  }
446
- await __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).connect();
375
+ await this.#client.connect();
447
376
  await this.storage.auth.update((v) => {
448
- v.authKey = __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).authKey;
449
- v.dc = __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc;
377
+ v.authKey = this.#client.authKey;
378
+ v.dc = this.#client.dc;
450
379
  });
451
- await this.storage.setServerSalt(__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).serverSalt);
452
- __classPrivateFieldGet(this, _Client_updateGapRecoveryLoop, "f").start();
453
- __classPrivateFieldGet(this, _Client_clientDisconnectionLoop, "f").start();
454
- if (!__classPrivateFieldGet(this, _Client_messageStorage_, "f").isMemory) {
455
- __classPrivateFieldGet(this, _Client_storageWriteLoop, "f").start();
380
+ await this.storage.setServerSalt(this.#client.serverSalt);
381
+ this.#updateGapRecoveryLoop.start();
382
+ this.#clientDisconnectionLoop.start();
383
+ if (!this.#messageStorage_.isMemory) {
384
+ this.#storageWriteLoop.start();
456
385
  }
457
386
  else {
458
- __classPrivateFieldGet(this, _Client_L, "f").debug("not starting storageWriteLoop");
387
+ this.#L.debug("not starting storageWriteLoop");
459
388
  }
460
389
  await this.storage.commit(true);
461
390
  }
@@ -463,62 +392,9 @@ class Client extends _5_composer_js_1.Composer {
463
392
  unlock();
464
393
  }
465
394
  }
466
- async [(_Client_clients = new WeakMap(), _Client_downloadPools = new WeakMap(), _Client_uploadPools = new WeakMap(), _Client_guaranteeUpdateDelivery = new WeakMap(), _Client_accountManager = new WeakMap(), _Client_botInfoManager = new WeakMap(), _Client_businessConnectionManager = new WeakMap(), _Client_fileManager = new WeakMap(), _Client_networkStatisticsManager = new WeakMap(), _Client_paymentManager = new WeakMap(), _Client_reactionManager = new WeakMap(), _Client_translationsManager = new WeakMap(), _Client_updateManager = new WeakMap(), _Client_messageManager = new WeakMap(), _Client_videoChatManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_chatManager = new WeakMap(), _Client_checklistManager = new WeakMap(), _Client_forumManager = new WeakMap(), _Client_giftManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_linkPreviewManager = new WeakMap(), _Client_pollManager = new WeakMap(), _Client_storyManager = new WeakMap(), _Client_managers = new WeakMap(), _Client_storage_ = new WeakMap(), _Client_messageStorage_ = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_apiId = new WeakMap(), _Client_apiHash = new WeakMap(), _Client_transportProvider = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_outgoingMessages = new WeakMap(), _Client_persistCache = new WeakMap(), _Client_disableUpdates = new WeakMap(), _Client_authString = new WeakMap(), _Client_initialDc = new WeakMap(), _Client_L = new WeakMap(), _Client_LsignIn = new WeakMap(), _Client_LupdateGapRecoveryLoop = new WeakMap(), _Client_LstorageWriteLoop = new WeakMap(), _Client_LhandleMigrationError = new WeakMap(), _Client_Lmin = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_stateChangeHandler = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_updateGapRecoveryLoop = new WeakMap(), _Client_clientDisconnectionLoop = new WeakMap(), _Client_storageWriteLoop = new WeakMap(), _Client_getMainClientMutex = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_authStringImported = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_previouslyConnected = new WeakMap(), _Client_lastConnectionState = new WeakMap(), _Client_instances = new WeakSet(), _Client_setMainClient = function _Client_setMainClient(client) {
467
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_disconnectAllClients).call(this);
468
- __classPrivateFieldSet(this, _Client_clients, [client], "f");
469
- client.handlers.onUpdate = (updates) => {
470
- __classPrivateFieldGet(this, _Client_updateManager, "f").processUpdates(updates, true, null);
471
- __classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
472
- };
473
- client.handlers.onDeserializationError = async () => {
474
- await __classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("deserialization error");
475
- };
476
- client.handlers.onNewServerSalt = async (serverSalt) => {
477
- await this.storage.setServerSalt(serverSalt);
478
- };
479
- client.onConnectionStateChange = __classPrivateFieldGet(this, _Client_instances, "m", _Client_onConnectionStateChange).bind(this);
480
- }, _Client_newClient = function _Client_newClient(dc, main, isCdn) {
481
- const client = new _2_client_encrypted_js_1.ClientEncrypted(dc, __classPrivateFieldGet(this, _Client_apiId, "f"), {
482
- appVersion: this.appVersion,
483
- deviceModel: this.deviceModel,
484
- langCode: this.language,
485
- langPack: this.platform,
486
- systemLangCode: this.systemLangCode,
487
- systemVersion: this.systemVersion,
488
- transportProvider: __classPrivateFieldGet(this, _Client_transportProvider, "f"),
489
- isCdn: isCdn,
490
- disableUpdates: !main || isCdn,
491
- publicKeys: __classPrivateFieldGet(this, _Client_publicKeys, "f"),
492
- });
493
- client.connectionCallback = __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f").getTransportReadWriteCallback(isCdn);
494
- return client;
495
- }, _Client_disconnectAllClients = function _Client_disconnectAllClients() {
496
- for (const client of __classPrivateFieldGet(this, _Client_clients, "f")) {
497
- client.disconnect();
498
- }
499
- for (const pool of Object.values(__classPrivateFieldGet(this, _Client_downloadPools, "f"))) {
500
- pool.disconnect();
501
- }
502
- for (const pool of Object.values(__classPrivateFieldGet(this, _Client_uploadPools, "f"))) {
503
- pool.disconnect();
504
- }
505
- }, _Client_client_get = function _Client_client_get() {
506
- return __classPrivateFieldGet(this, _Client_clients, "f")[0];
507
- }, _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
508
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
509
- __classPrivateFieldSet(this, _Client_lastPropagatedConnectionState, connectionState, "f");
510
- }, _Client_initStorage = async function _Client_initStorage() {
511
- if (!__classPrivateFieldGet(this, _Client_storageInited, "f")) {
512
- await this.storage.initialize();
513
- if (!__classPrivateFieldGet(this, _Client_guaranteeUpdateDelivery, "f")) {
514
- await this.storage.deleteUpdates();
515
- await this.storage.commit(true);
516
- }
517
- __classPrivateFieldSet(this, _Client_storageInited, true, "f");
518
- }
519
- }, exports.handleMigrationError)](err) {
395
+ async [exports.handleMigrationError](err) {
520
396
  let newDc = String(err.dc);
521
- if (Math.abs((0, _3_transport_js_1.getDcId)(__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc, __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).isCdn)) >= 10_000) {
397
+ if (Math.abs((0, _3_transport_js_1.getDcId)(this.#client.dc, this.#client.isCdn)) >= 10_000) {
522
398
  newDc += "-test";
523
399
  }
524
400
  this.disconnect();
@@ -527,17 +403,100 @@ class Client extends _5_composer_js_1.Composer {
527
403
  v.dc = newDc;
528
404
  });
529
405
  await this.connect();
530
- __classPrivateFieldGet(this, _Client_LhandleMigrationError, "f").debug(`migrated to DC${newDc}`);
406
+ this.#LhandleMigrationError.debug(`migrated to DC${newDc}`);
531
407
  }
532
408
  async disconnect() {
533
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_disconnectAllClients).call(this);
534
- __classPrivateFieldGet(this, _Client_clientDisconnectionLoop, "f").abort();
535
- __classPrivateFieldGet(this, _Client_updateGapRecoveryLoop, "f").abort();
536
- __classPrivateFieldGet(this, _Client_storageWriteLoop, "f").abort();
537
- __classPrivateFieldGet(this, _Client_updateManager, "f").closeAllChats();
409
+ this.#disconnectAllClients();
410
+ this.#clientDisconnectionLoop.abort();
411
+ this.#updateGapRecoveryLoop.abort();
412
+ this.#storageWriteLoop.abort();
413
+ this.#updateManager.closeAllChats();
538
414
  await this.storage.commit(true);
539
415
  await this.messageStorage.commit(true);
540
416
  }
417
+ #lastPropagatedAuthorizationState = null;
418
+ async #propagateAuthorizationState(authorized) {
419
+ if (this.#lastPropagatedAuthorizationState !== authorized) {
420
+ await this.#handleCtxUpdate({ authorizationState: { isAuthorized: authorized } });
421
+ this.#lastPropagatedAuthorizationState = authorized;
422
+ }
423
+ }
424
+ async #getSelfId() {
425
+ const id = await this.storage.getAccountId();
426
+ if (id === null) {
427
+ throw new Error("Unauthorized");
428
+ }
429
+ return id;
430
+ }
431
+ async #getIsPremium() {
432
+ const maybeIsPremium = await this.storage.getIsPremium();
433
+ if (maybeIsPremium !== null) {
434
+ return maybeIsPremium;
435
+ }
436
+ return this.#lastGetMe?.isPremium ?? false;
437
+ }
438
+ #lastUpdates = new Date();
439
+ #updateGapRecoveryLoop = new _0_abortable_loop_js_1.AbortableLoop(async (loop, signal) => {
440
+ await (0, _0_deps_js_1.delay)(60 * _0_deps_js_1.SECOND, { signal });
441
+ if (!this.isConnected) {
442
+ loop.abort();
443
+ return;
444
+ }
445
+ if (Date.now() - this.#lastUpdates.getTime() >= 15 * _0_deps_js_1.MINUTE) {
446
+ (0, _1_utilities_js_1.drop)(this.#updateManager.recoverUpdateGap("lastUpdates").then(() => {
447
+ this.#lastUpdates = new Date();
448
+ }));
449
+ }
450
+ }, (loop, err) => {
451
+ if (!this.isConnected) {
452
+ loop.abort();
453
+ }
454
+ else {
455
+ this.#LupdateGapRecoveryLoop.error(err);
456
+ }
457
+ });
458
+ #clientDisconnectionLoop = new _0_abortable_loop_js_1.AbortableLoop(async (loop, signal) => {
459
+ await (0, _0_deps_js_1.delay)(60 * _0_deps_js_1.SECOND, { signal });
460
+ if (!this.isConnected) {
461
+ loop.abort();
462
+ return;
463
+ }
464
+ const now = Date.now();
465
+ const disconnectAfter = 5 * _0_deps_js_1.MINUTE;
466
+ for (const [i, client] of this.#clients.entries()) {
467
+ if (i > 0 && !client.isDisconnected && client.lastRequest && now - client.lastRequest.getTime() >= disconnectAfter) {
468
+ client?.disconnect();
469
+ }
470
+ }
471
+ }, (loop) => {
472
+ if (!this.isConnected) {
473
+ loop.abort();
474
+ }
475
+ });
476
+ #storageWriteLoop = new _0_abortable_loop_js_1.AbortableLoop(async (_loop, signal) => {
477
+ await (0, _0_deps_js_1.delay)(5 * _0_deps_js_1.SECOND, { signal });
478
+ await this.messageStorage.commit();
479
+ await this.storage.commit();
480
+ }, (err) => {
481
+ this.#LstorageWriteLoop.error(err);
482
+ });
483
+ async #checkAuthorization() {
484
+ if (this.#lastGetMe) {
485
+ return this.#lastGetMe;
486
+ }
487
+ try {
488
+ await this.#updateManager.fetchState("#checkAuthorization");
489
+ const me = await this.#getMe();
490
+ await this.#propagateAuthorizationState(true);
491
+ (0, _1_utilities_js_1.drop)(this.#updateManager.recoverUpdateGap("#checkAuthorization"));
492
+ return me;
493
+ }
494
+ catch (err) {
495
+ if (!(err instanceof _4_errors_js_1.AuthKeyUnregistered) && !(err instanceof _4_errors_js_1.SessionRevoked)) {
496
+ throw err;
497
+ }
498
+ }
499
+ }
541
500
  /**
542
501
  * Send a user verification code.
543
502
  *
@@ -545,17 +504,17 @@ class Client extends _5_composer_js_1.Composer {
545
504
  * @method ac
546
505
  */
547
506
  async sendCode(phoneNumber) {
548
- const me = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkAuthorization).call(this);
507
+ const me = await this.#checkAuthorization();
549
508
  if (me) {
550
509
  return;
551
510
  }
552
511
  try {
553
- await __classPrivateFieldGet(this, _Client_accountManager, "f").sendCode(phoneNumber, __classPrivateFieldGet(this, _Client_apiId, "f"), __classPrivateFieldGet(this, _Client_apiHash, "f"));
512
+ await this.#accountManager.sendCode(phoneNumber, this.#apiId, this.#apiHash);
554
513
  }
555
514
  catch (err) {
556
515
  if (err instanceof _4_errors_js_1.Migrate) {
557
516
  await this[exports.handleMigrationError](err);
558
- await __classPrivateFieldGet(this, _Client_accountManager, "f").sendCode(phoneNumber, __classPrivateFieldGet(this, _Client_apiId, "f"), __classPrivateFieldGet(this, _Client_apiHash, "f"));
517
+ await this.#accountManager.sendCode(phoneNumber, this.#apiId, this.#apiHash);
559
518
  }
560
519
  else {
561
520
  throw err;
@@ -569,15 +528,15 @@ class Client extends _5_composer_js_1.Composer {
569
528
  * @method ac
570
529
  */
571
530
  async checkCode(code) {
572
- const result = await __classPrivateFieldGet(this, _Client_accountManager, "f").checkCode(code);
531
+ const result = await this.#accountManager.checkCode(code);
573
532
  if (result.type === "signedIn") {
574
533
  await this.storage.auth.update((v) => {
575
534
  v.userId = result.userId;
576
535
  v.isBot = false;
577
536
  });
578
- __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("signed in as user");
579
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
580
- await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("checkCode");
537
+ this.#LsignIn.debug("signed in as user");
538
+ await this.#propagateAuthorizationState(true);
539
+ await this.#updateManager.fetchState("checkCode");
581
540
  }
582
541
  return result;
583
542
  }
@@ -587,7 +546,7 @@ class Client extends _5_composer_js_1.Composer {
587
546
  * @method ac
588
547
  */
589
548
  async getPasswordHint() {
590
- return await __classPrivateFieldGet(this, _Client_accountManager, "f").getPasswordHint();
549
+ return await this.#accountManager.getPasswordHint();
591
550
  }
592
551
  /**
593
552
  * Check whether a password entered by the user is the same as the account's one.
@@ -597,16 +556,16 @@ class Client extends _5_composer_js_1.Composer {
597
556
  * @method ac
598
557
  */
599
558
  async checkPassword(password) {
600
- const result = await __classPrivateFieldGet(this, _Client_accountManager, "f").checkPassword(password);
559
+ const result = await this.#accountManager.checkPassword(password);
601
560
  if (result.type === "signedIn") {
602
561
  await this.storage.auth.update((v) => {
603
562
  v.userId = result.userId;
604
563
  v.isBot = false;
605
564
  });
606
565
  await this.storage.commit(true);
607
- __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("signed in as user");
608
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
609
- await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("checkPassword");
566
+ this.#LsignIn.debug("signed in as user");
567
+ await this.#propagateAuthorizationState(true);
568
+ await this.#updateManager.fetchState("checkPassword");
610
569
  }
611
570
  return result;
612
571
  }
@@ -618,7 +577,7 @@ class Client extends _5_composer_js_1.Composer {
618
577
  * @method ac
619
578
  */
620
579
  async checkBotToken(botToken) {
621
- const me = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkAuthorization).call(this);
580
+ const me = await this.#checkAuthorization();
622
581
  if (me) {
623
582
  return {
624
583
  type: "signedIn",
@@ -627,16 +586,16 @@ class Client extends _5_composer_js_1.Composer {
627
586
  }
628
587
  while (true) {
629
588
  try {
630
- const result = await __classPrivateFieldGet(this, _Client_accountManager, "f").checkBotToken(botToken, __classPrivateFieldGet(this, _Client_apiId, "f"), __classPrivateFieldGet(this, _Client_apiHash, "f"));
589
+ const result = await this.#accountManager.checkBotToken(botToken, this.#apiId, this.#apiHash);
631
590
  if (result.type === "signedIn") {
632
591
  await this.storage.auth.update((v) => {
633
592
  v.userId = result.userId;
634
593
  v.isBot = true;
635
594
  });
636
595
  await this.storage.commit(true);
637
- __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("signed in as bot");
638
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
639
- await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("checkBotToken");
596
+ this.#LsignIn.debug("signed in as bot");
597
+ await this.#propagateAuthorizationState(true);
598
+ await this.#updateManager.fetchState("checkBotToken");
640
599
  }
641
600
  return result;
642
601
  }
@@ -660,19 +619,19 @@ class Client extends _5_composer_js_1.Composer {
660
619
  * 3. Reconnects the client to the appropriate DC in case of MIGRATE_X errors.
661
620
  */
662
621
  async signIn(params) {
663
- await (0, _2_sign_in_js_1.signIn)(this, __classPrivateFieldGet(this, _Client_LsignIn, "f"), params);
622
+ await (0, _2_sign_in_js_1.signIn)(this, this.#LsignIn, params);
664
623
  }
665
624
  async signOut() {
666
625
  try {
667
626
  await Promise.all([
668
627
  this.storage.reset(),
669
628
  this.invoke({ _: "auth.logOut" }).then(() => {
670
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, false);
629
+ this.#propagateAuthorizationState(false);
671
630
  }),
672
631
  ]);
673
632
  }
674
633
  finally {
675
- __classPrivateFieldSet(this, _Client_lastGetMe, null, "f");
634
+ this.#lastGetMe = null;
676
635
  this.disconnect();
677
636
  await this.connect();
678
637
  }
@@ -684,146 +643,55 @@ class Client extends _5_composer_js_1.Composer {
684
643
  await this.connect();
685
644
  await this.signIn(params);
686
645
  }
687
- exportAuthString() {
688
- return this.storage.exportAuthString(__classPrivateFieldGet(this, _Client_apiId, "f"));
689
- }
690
- async importAuthString(authString) {
691
- if (this.isConnected) {
692
- throw new Error("Cannot import auth string while the client is connected");
693
- }
694
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initStorage).call(this);
695
- await this.storage.importAuthString(authString);
696
- __classPrivateFieldSet(this, _Client_authStringImported, true, "f");
697
- if (!__classPrivateFieldGet(this, _Client_apiId, "f")) {
698
- __classPrivateFieldSet(this, _Client_apiId, this.storage.auth.mustGet().apiId, "f");
699
- }
700
- }
701
- /**
702
- * Get a chat's inputPeer. Useful when calling API functions directly.
703
- *
704
- * @param id The identifier of a chat.
705
- */
706
- async getInputPeer(id) {
707
- if (id === "me" || id === await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this)) {
708
- return { _: "inputPeerSelf" };
709
- }
710
- const inputPeer = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getInputPeerInner).call(this, id);
711
- if (((_2_tl_js_1.Api.is("inputPeerUser", inputPeer) || _2_tl_js_1.Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash === 0n) && this.storage.isBot) {
712
- if ("channel_id" in inputPeer) {
713
- inputPeer.access_hash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChannelAccessHash).call(this, inputPeer.channel_id);
714
- }
715
- else {
716
- inputPeer.access_hash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getUserAccessHash).call(this, inputPeer.user_id);
717
- }
718
- }
719
- if ((_2_tl_js_1.Api.is("inputPeerUser", inputPeer) || _2_tl_js_1.Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash === 0n) {
720
- throw new _0_errors_js_1.AccessError(`The chat ${id} cannot be accessed.`);
721
- }
722
- return inputPeer;
723
- }
724
- /**
725
- * Get a channel or a supergroup's inputChannel. Useful when calling API functions directly.
726
- *
727
- * @param id The identifier of the channel or the supergroup.
728
- */
729
- async getInputChannel(id) {
730
- const inputPeer = await this.getInputPeer(id);
731
- if (!(0, _0_utilities_js_1.canBeInputChannel)(inputPeer)) {
732
- throw new TypeError(`The chat ${id} is not a channel neither a supergroup.`);
733
- }
734
- return (0, _0_utilities_js_1.toInputChannel)(inputPeer);
735
- }
736
- /**
737
- * Get a user's inputUser. Useful when calling API functions directly.
738
- *
739
- * @param id The identifier of the user.
740
- */
741
- async getInputUser(id) {
742
- const inputPeer = await this.getInputPeer(id);
743
- if (!(0, _0_utilities_js_1.canBeInputUser)(inputPeer)) {
744
- throw new TypeError(`The chat ${id} is not a private chat.`);
745
- }
746
- return (0, _0_utilities_js_1.toInputUser)(inputPeer);
747
- }
748
- async [(_Client_propagateAuthorizationState = async function _Client_propagateAuthorizationState(authorized) {
749
- if (__classPrivateFieldGet(this, _Client_lastPropagatedAuthorizationState, "f") !== authorized) {
750
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, { authorizationState: { isAuthorized: authorized } });
751
- __classPrivateFieldSet(this, _Client_lastPropagatedAuthorizationState, authorized, "f");
752
- }
753
- }, _Client_getSelfId = async function _Client_getSelfId() {
754
- const id = await this.storage.getAccountId();
755
- if (id === null) {
756
- throw new Error("Unauthorized");
757
- }
758
- return id;
759
- }, _Client_getIsPremium = async function _Client_getIsPremium() {
760
- const maybeIsPremium = await this.storage.getIsPremium();
761
- if (maybeIsPremium !== null) {
762
- return maybeIsPremium;
763
- }
764
- return __classPrivateFieldGet(this, _Client_lastGetMe, "f")?.isPremium ?? false;
765
- }, _Client_checkAuthorization = async function _Client_checkAuthorization() {
766
- if (__classPrivateFieldGet(this, _Client_lastGetMe, "f")) {
767
- return __classPrivateFieldGet(this, _Client_lastGetMe, "f");
768
- }
769
- try {
770
- await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("#checkAuthorization");
771
- const me = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMe).call(this);
772
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
773
- (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("#checkAuthorization"));
774
- return me;
775
- }
776
- catch (err) {
777
- if (!(err instanceof _4_errors_js_1.AuthKeyUnregistered) && !(err instanceof _4_errors_js_1.SessionRevoked)) {
778
- throw err;
779
- }
780
- }
781
- }, _Client_getClient = async function _Client_getClient(params) {
646
+ async #getClient(params) {
782
647
  let client;
783
648
  switch (params.type) {
784
649
  case undefined:
785
- client = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMainClient).call(this, params.dc);
650
+ client = await this.#getMainClient(params.dc);
786
651
  break;
787
652
  case "download":
788
- client = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getDownloadClient).call(this, params.dc);
653
+ client = await this.#getDownloadClient(params.dc);
789
654
  break;
790
655
  case "upload":
791
- client = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getUploadClient).call(this);
656
+ client = await this.#getUploadClient();
792
657
  break;
793
658
  }
794
- if (client !== __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get) && !this.isDisconnected && client.isDisconnected) {
659
+ if (client !== this.#client && !this.isDisconnected && client.isDisconnected) {
795
660
  await client.connect();
796
661
  }
797
662
  return client;
798
- }, _Client_getMainClient = async function _Client_getMainClient(dc) {
799
- if (dc === undefined || dc === __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.dc) {
800
- return __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get);
663
+ }
664
+ #getMainClientMutex = new _1_utilities_js_1.Mutex();
665
+ async #getMainClient(dc) {
666
+ if (dc === undefined || dc === this.#client?.dc) {
667
+ return this.#client;
801
668
  }
802
- let client = __classPrivateFieldGet(this, _Client_clients, "f").find((v) => v.dc === dc);
669
+ let client = this.#clients.find((v) => v.dc === dc);
803
670
  if (client) {
804
671
  return client;
805
672
  }
806
- const unlock = await __classPrivateFieldGet(this, _Client_getMainClientMutex, "f").lock();
807
- client = __classPrivateFieldGet(this, _Client_clients, "f").find((v) => v.dc === dc);
673
+ const unlock = await this.#getMainClientMutex.lock();
674
+ client = this.#clients.find((v) => v.dc === dc);
808
675
  if (client) {
809
676
  return client;
810
677
  }
811
678
  try {
812
- client = __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, false, false);
813
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setupClient).call(this, client);
814
- __classPrivateFieldGet(this, _Client_clients, "f").push(client);
679
+ client = this.#newClient(dc, false, false);
680
+ await this.#setupClient(client);
681
+ this.#clients.push(client);
815
682
  return client;
816
683
  }
817
684
  finally {
818
685
  unlock();
819
686
  }
820
- }, _Client_getDownloadClient = async function _Client_getDownloadClient(dc) {
821
- dc ??= __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc;
822
- const pool = __classPrivateFieldGet(this, _Client_downloadPools, "f")[dc] ??= new _3_client_encrypted_pool_js_1.ClientEncryptedPool();
687
+ }
688
+ async #getDownloadClient(dc) {
689
+ dc ??= this.#client.dc;
690
+ const pool = this.#downloadPools[dc] ??= new _3_client_encrypted_pool_js_1.ClientEncryptedPool();
823
691
  if (!pool.size) {
824
692
  if (!pool.size) {
825
693
  for (let i = 0; i < _0_utilities_js_1.DOWNLOAD_POOL_SIZE; ++i) {
826
- pool.add(__classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, false, true));
694
+ pool.add(this.#newClient(dc, false, true));
827
695
  }
828
696
  }
829
697
  }
@@ -831,28 +699,31 @@ class Client extends _5_composer_js_1.Composer {
831
699
  if (client.authKey.length) {
832
700
  return client;
833
701
  }
834
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setupClient).call(this, client);
702
+ await this.#setupClient(client);
835
703
  return client;
836
- }, _Client_getUploadPoolSize = async function _Client_getUploadPoolSize() {
837
- const dc = __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc;
838
- return (dc !== "2" && dc !== "4") || await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getIsPremium).call(this) ? 8 : 4;
839
- }, _Client_getUploadClient = async function _Client_getUploadClient() {
840
- const dc = __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc;
841
- const poolSize = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getUploadPoolSize).call(this);
842
- const pool = __classPrivateFieldGet(this, _Client_uploadPools, "f")[dc] ??= new _3_client_encrypted_pool_js_1.ClientEncryptedPool();
704
+ }
705
+ async #getUploadPoolSize() {
706
+ const dc = this.#client.dc;
707
+ return (dc !== "2" && dc !== "4") || await this.#getIsPremium() ? 8 : 4;
708
+ }
709
+ async #getUploadClient() {
710
+ const dc = this.#client.dc;
711
+ const poolSize = await this.#getUploadPoolSize();
712
+ const pool = this.#uploadPools[dc] ??= new _3_client_encrypted_pool_js_1.ClientEncryptedPool();
843
713
  if (!pool.size) {
844
714
  for (let i = 0; i < poolSize; ++i) {
845
- pool.add(await __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, false, true));
715
+ pool.add(await this.#newClient(dc, false, true));
846
716
  }
847
717
  }
848
718
  const client = pool.nextClient();
849
719
  if (client.authKey.length) {
850
720
  return client;
851
721
  }
852
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setupClient).call(this, client);
722
+ await this.#setupClient(client);
853
723
  return client;
854
- }, _Client_setupClient = async function _Client_setupClient(client) {
855
- const storage = client.dc === __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc ? this.storage : new _0_storage_operations_js_1.StorageOperations(this.storage.provider.branch(client.dc + (client.isCdn ? "_cdn" : "")));
724
+ }
725
+ async #setupClient(client) {
726
+ const storage = client.dc === this.#client.dc ? this.storage : new _0_storage_operations_js_1.StorageOperations(this.storage.provider.branch(client.dc + (client.isCdn ? "_cdn" : "")));
856
727
  await storage.initialize();
857
728
  const auth = storage.auth.mustGet();
858
729
  const serverSalt = await storage.getServerSalt();
@@ -864,17 +735,18 @@ class Client extends _5_composer_js_1.Composer {
864
735
  }
865
736
  await client.connect();
866
737
  if (auth.authKey === null) {
867
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_importAuthorization).call(this, client);
738
+ await this.#importAuthorization(client);
868
739
  }
869
740
  await storage.auth.update((v) => v.authKey = client.authKey);
870
- if (client.dc !== __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc) {
741
+ if (client.dc !== this.#client.dc) {
871
742
  await storage.setServerSalt(client.serverSalt);
872
743
  client.handlers.onNewServerSalt = async (serverSalt) => {
873
744
  await storage.setServerSalt(serverSalt);
874
745
  };
875
746
  }
876
- }, _Client_importAuthorization = async function _Client_importAuthorization(client) {
877
- if (__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc === client.dc && __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).isCdn === client.isCdn) {
747
+ }
748
+ async #importAuthorization(client) {
749
+ if (this.#client.dc === client.dc && this.#client.isCdn === client.isCdn) {
878
750
  const auth = this.storage.auth.mustGet();
879
751
  const serverSalt = await this.storage.getServerSalt();
880
752
  if (auth.authKey !== null) {
@@ -885,29 +757,30 @@ class Client extends _5_composer_js_1.Composer {
885
757
  }
886
758
  return;
887
759
  }
888
- const exportedAuthorization = await __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).invoke({ _: "auth.exportAuthorization", dc_id: (0, _3_transport_js_1.getDcId)(client.dc, client.isCdn) });
760
+ const exportedAuthorization = await this.#client.invoke({ _: "auth.exportAuthorization", dc_id: (0, _3_transport_js_1.getDcId)(client.dc, client.isCdn) });
889
761
  await client.invoke({ ...exportedAuthorization, _: "auth.importAuthorization" });
890
- }, _Client_invoke = async function _Client_invoke(function_, params) {
891
- if (!__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)) {
762
+ }
763
+ async #invoke(function_, params) {
764
+ if (!this.#client) {
892
765
  throw new _0_errors_js_1.ConnectionError("The connection is not open.");
893
766
  }
894
767
  let n = 1;
895
768
  let client;
896
769
  while (true) {
897
- client = params ? await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getClient).call(this, params) : __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get);
898
- const main = client === __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get);
770
+ client = params ? await this.#getClient(params) : this.#client;
771
+ const main = client === this.#client;
899
772
  try {
900
773
  const result = await client.invoke(function_);
901
774
  if (main) {
902
775
  try {
903
- await __classPrivateFieldGet(this, _Client_updateManager, "f").processResult(result);
776
+ await this.#updateManager.processResult(result);
904
777
  }
905
778
  catch (err) {
906
- __classPrivateFieldGet(this, _Client_L, "f").error("failed to process result:", err);
779
+ this.#L.error("failed to process result:", err);
907
780
  }
908
781
  if (_2_tl_js_1.Api.isOfEnum("Update", result) || _2_tl_js_1.Api.isOfEnum("Updates", result)) {
909
782
  return new Promise((resolve) => {
910
- __classPrivateFieldGet(this, _Client_updateManager, "f").processUpdates(result, true, _2_tl_js_1.Mtproto.is("ping", function_) ? null : function_, () => resolve(result));
783
+ this.#updateManager.processUpdates(result, true, _2_tl_js_1.Mtproto.is("ping", function_) ? null : function_, () => resolve(result));
911
784
  });
912
785
  }
913
786
  }
@@ -915,13 +788,13 @@ class Client extends _5_composer_js_1.Composer {
915
788
  }
916
789
  catch (err) {
917
790
  if (err instanceof _4_errors_js_1.AuthKeyUnregistered && !main) {
918
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_importAuthorization).call(this, client);
791
+ await this.#importAuthorization(client);
919
792
  continue;
920
793
  }
921
794
  else if (err instanceof _0_errors_js_1.ConnectionError && !main && !this.isDisconnected) {
922
795
  continue;
923
796
  }
924
- else if (await __classPrivateFieldGet(this, _Client_handleInvokeError, "f").call(this, Object.freeze({ client: this, error: err, function: function_, n: n++ }), () => Promise.resolve(false))) {
797
+ else if (await this.#handleInvokeError(Object.freeze({ client: this, error: err, function: function_, n: n++ }), () => Promise.resolve(false))) {
925
798
  continue;
926
799
  }
927
800
  else {
@@ -929,17 +802,79 @@ class Client extends _5_composer_js_1.Composer {
929
802
  }
930
803
  }
931
804
  }
932
- }, _Client_getUserAccessHash = async function _Client_getUserAccessHash(userId) {
805
+ }
806
+ #handleInvokeError = (0, _1_invoke_middleware_js_1.skipInvoke)();
807
+ /**
808
+ * Invokes a function waiting and returning its reply.
809
+ * Requires the client to be connected.
810
+ *
811
+ * @param function_ The function to invoke.
812
+ */
813
+ invoke = Object.assign(this.#invoke, {
814
+ use: (handler) => {
815
+ const handle = this.#handleInvokeError;
816
+ this.#handleInvokeError = async (ctx, next) => {
817
+ let result = null;
818
+ return await handle(ctx, async () => {
819
+ if (result !== null)
820
+ return result;
821
+ result = await handler(ctx, next);
822
+ return result;
823
+ });
824
+ };
825
+ },
826
+ });
827
+ exportAuthString() {
828
+ return this.storage.exportAuthString(this.#apiId);
829
+ }
830
+ #authStringImported = false;
831
+ async importAuthString(authString) {
832
+ if (this.isConnected) {
833
+ throw new Error("Cannot import auth string while the client is connected");
834
+ }
835
+ await this.#initStorage();
836
+ await this.storage.importAuthString(authString);
837
+ this.#authStringImported = true;
838
+ if (!this.#apiId) {
839
+ this.#apiId = this.storage.auth.mustGet().apiId;
840
+ }
841
+ }
842
+ async #getUserAccessHash(userId) {
933
843
  const users = await this.invoke({ _: "users.getUsers", id: [{ _: "inputUser", user_id: userId, access_hash: 0n }] });
934
844
  const user = _2_tl_js_1.Api.is("user", users[0]) ? users[0] : undefined;
935
845
  return user?.access_hash ?? 0n;
936
- }, _Client_getChannelAccessHash = async function _Client_getChannelAccessHash(channelId) {
846
+ }
847
+ async #getChannelAccessHash(channelId) {
937
848
  const channels = await this.invoke({ _: "channels.getChannels", id: [{ _: "inputChannel", channel_id: channelId, access_hash: 0n }] });
938
849
  const channel = _2_tl_js_1.Api.is("channel", channels.chats[0]) ? channels.chats[0] : undefined;
939
850
  return channel?.access_hash ?? 0n;
940
- }, _Client_getInputPeerChatId = async function _Client_getInputPeerChatId(inputPeer) {
851
+ }
852
+ /**
853
+ * Get a chat's inputPeer. Useful when calling API functions directly.
854
+ *
855
+ * @param id The identifier of a chat.
856
+ */
857
+ async getInputPeer(id) {
858
+ if (id === "me" || id === await this.#getSelfId()) {
859
+ return { _: "inputPeerSelf" };
860
+ }
861
+ const inputPeer = await this.#getInputPeerInner(id);
862
+ if (((_2_tl_js_1.Api.is("inputPeerUser", inputPeer) || _2_tl_js_1.Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash === 0n) && this.storage.isBot) {
863
+ if ("channel_id" in inputPeer) {
864
+ inputPeer.access_hash = await this.#getChannelAccessHash(inputPeer.channel_id);
865
+ }
866
+ else {
867
+ inputPeer.access_hash = await this.#getUserAccessHash(inputPeer.user_id);
868
+ }
869
+ }
870
+ if ((_2_tl_js_1.Api.is("inputPeerUser", inputPeer) || _2_tl_js_1.Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash === 0n) {
871
+ throw new _0_errors_js_1.AccessError(`The chat ${id} cannot be accessed.`);
872
+ }
873
+ return inputPeer;
874
+ }
875
+ async #getInputPeerChatId(inputPeer) {
941
876
  if (_2_tl_js_1.Api.isOneOf(["inputPeerSelf", "inputUserSelf"], inputPeer)) {
942
- return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this);
877
+ return await this.#getSelfId();
943
878
  }
944
879
  else if (_2_tl_js_1.Api.isOneOf(["inputPeerEmpty", "inputUserEmpty", "inputChannelEmpty"], inputPeer)) {
945
880
  (0, _0_deps_js_1.unreachable)();
@@ -947,7 +882,32 @@ class Client extends _5_composer_js_1.Composer {
947
882
  else {
948
883
  return _2_tl_js_1.Api.peerToChatId(inputPeer);
949
884
  }
950
- }, _Client_getInputPeerInner = async function _Client_getInputPeerInner(id) {
885
+ }
886
+ /**
887
+ * Get a channel or a supergroup's inputChannel. Useful when calling API functions directly.
888
+ *
889
+ * @param id The identifier of the channel or the supergroup.
890
+ */
891
+ async getInputChannel(id) {
892
+ const inputPeer = await this.getInputPeer(id);
893
+ if (!(0, _0_utilities_js_1.canBeInputChannel)(inputPeer)) {
894
+ throw new TypeError(`The chat ${id} is not a channel neither a supergroup.`);
895
+ }
896
+ return (0, _0_utilities_js_1.toInputChannel)(inputPeer);
897
+ }
898
+ /**
899
+ * Get a user's inputUser. Useful when calling API functions directly.
900
+ *
901
+ * @param id The identifier of the user.
902
+ */
903
+ async getInputUser(id) {
904
+ const inputPeer = await this.getInputPeer(id);
905
+ if (!(0, _0_utilities_js_1.canBeInputUser)(inputPeer)) {
906
+ throw new TypeError(`The chat ${id} is not a private chat.`);
907
+ }
908
+ return (0, _0_utilities_js_1.toInputUser)(inputPeer);
909
+ }
910
+ async #getInputPeerInner(id) {
951
911
  const idn = Number(id);
952
912
  if (!isNaN(idn)) {
953
913
  id = idn;
@@ -963,8 +923,8 @@ class Client extends _5_composer_js_1.Composer {
963
923
  }
964
924
  else {
965
925
  const resolved = await this.invoke({ _: "contacts.resolveUsername", username: id });
966
- __classPrivateFieldGet(this, _Client_updateManager, "f").processChats(resolved.chats, resolved);
967
- __classPrivateFieldGet(this, _Client_updateManager, "f").processUsers(resolved.users, resolved);
926
+ this.#updateManager.processChats(resolved.chats, resolved);
927
+ this.#updateManager.processUsers(resolved.users, resolved);
968
928
  if (_2_tl_js_1.Api.is("peerUser", resolved.peer)) {
969
929
  resolvedId = _2_tl_js_1.Api.peerToChatId(resolved.peer);
970
930
  }
@@ -1015,7 +975,8 @@ class Client extends _5_composer_js_1.Composer {
1015
975
  // }
1016
976
  }
1017
977
  return peer;
1018
- }, _Client_getMinInputPeer = async function _Client_getMinInputPeer(type, reference) {
978
+ }
979
+ async #getMinInputPeer(type, reference) {
1019
980
  const peer_ = await this.messageStorage.peers.get([reference.chatId]);
1020
981
  if (peer_ !== null && (peer_[0].type === "channel" || peer_[0].type === "supergroup")) {
1021
982
  const peer = { _: "inputPeerChannel", channel_id: BigInt(peer_[0].id), access_hash: peer_[1] };
@@ -1029,7 +990,8 @@ class Client extends _5_composer_js_1.Composer {
1029
990
  else {
1030
991
  return null;
1031
992
  }
1032
- }, getPeer)](peer) {
993
+ }
994
+ async [getPeer](peer) {
1033
995
  const id = _2_tl_js_1.Api.peerToChatId(peer);
1034
996
  const entity = await this.messageStorage.peers.get([id]);
1035
997
  if (entity === null) {
@@ -1045,6 +1007,163 @@ class Client extends _5_composer_js_1.Composer {
1045
1007
  [mustGetPeer](peer) {
1046
1008
  return this.messageStorage.peers.mustGet([(0, _2_telegram_js_1.peerToChatId)(peer)]);
1047
1009
  }
1010
+ async #handleCtxUpdate(update) {
1011
+ if (this.#disableUpdates && !("authorizationState" in update) && !("connectionState" in update)) {
1012
+ return;
1013
+ }
1014
+ try {
1015
+ await this.handleUpdate(this, update);
1016
+ }
1017
+ catch (err) {
1018
+ this.#L.error("Failed to handle update:", err);
1019
+ throw err;
1020
+ }
1021
+ }
1022
+ #queueHandleCtxUpdate(update) {
1023
+ this.#updateManager.getHandleUpdateQueue(_2_update_manager_js_1.UpdateManager.MAIN_BOX_ID).add(async () => {
1024
+ await this.#handleCtxUpdate(update);
1025
+ });
1026
+ }
1027
+ async #handleUpdate(update) {
1028
+ const maybePromises = new Array();
1029
+ if (_2_tl_js_1.Api.is("updateUserName", update)) {
1030
+ const value = [Number(update.user_id), new Date()];
1031
+ for (const username_ of update.usernames) {
1032
+ const username = username_.username.toLowerCase();
1033
+ this.messageStorage.usernames.set([username], value);
1034
+ }
1035
+ const peer = { ...update, _: "peerUser" };
1036
+ const peer_ = await this[getPeer](peer);
1037
+ if (peer_ !== null) {
1038
+ const username = update.usernames[0];
1039
+ if (username !== undefined) {
1040
+ peer_[0].username = username.username;
1041
+ const also = update.usernames.filter((v) => v !== username);
1042
+ if (also.length) {
1043
+ peer_[0].also = also.map((v) => v.username);
1044
+ }
1045
+ else {
1046
+ delete peer_[0].also;
1047
+ }
1048
+ }
1049
+ else {
1050
+ delete peer_[0].username;
1051
+ }
1052
+ this.messageStorage.setPeer2(peer_[0], peer_[1]);
1053
+ }
1054
+ }
1055
+ if (this.#messageManager.canHandleUpdate(update)) {
1056
+ maybePromises.push(() => this.#messageManager.handleUpdate(update));
1057
+ }
1058
+ if (this.#chatManager.canHandleUpdate(update)) {
1059
+ maybePromises.push(() => this.#chatManager.handleUpdate(update));
1060
+ }
1061
+ if (this.#pollManager.canHandleUpdate(update)) {
1062
+ maybePromises.push(() => this.#pollManager.handleUpdate(update));
1063
+ }
1064
+ if (this.#videoChatManager.canHandleUpdate(update)) {
1065
+ maybePromises.push(() => this.#videoChatManager.handleUpdate(update));
1066
+ }
1067
+ if (this.#callbackQueryManager.canHandleUpdate(update)) {
1068
+ maybePromises.push(() => this.#callbackQueryManager.handleUpdate(update));
1069
+ }
1070
+ if (this.#inlineQueryManager.canHandleUpdate(update)) {
1071
+ maybePromises.push(() => this.#inlineQueryManager.handleUpdate(update));
1072
+ }
1073
+ if (this.#linkPreviewManager.canHandleUpdate(update)) {
1074
+ maybePromises.push(() => this.#linkPreviewManager.handleUpdate(update));
1075
+ }
1076
+ if (this.#reactionManager.canHandleUpdate(update)) {
1077
+ maybePromises.push(() => this.#reactionManager.handleUpdate(update));
1078
+ }
1079
+ if (this.#chatListManager.canHandleUpdate(update)) {
1080
+ maybePromises.push(() => this.#chatListManager.handleUpdate(update));
1081
+ }
1082
+ if (this.#storyManager.canHandleUpdate(update)) {
1083
+ maybePromises.push(() => this.#storyManager.handleUpdate(update));
1084
+ }
1085
+ if (this.#businessConnectionManager.canHandleUpdate(update)) {
1086
+ maybePromises.push(() => this.#businessConnectionManager.handleUpdate(update));
1087
+ }
1088
+ if (this.#storyManager.canHandleUpdate(update)) {
1089
+ maybePromises.push(() => this.#storyManager.handleUpdate(update));
1090
+ }
1091
+ if (this.#paymentManager.canHandleUpdate(update)) {
1092
+ maybePromises.push(() => this.#paymentManager.handleUpdate(update));
1093
+ }
1094
+ if (this.#translationsManager.canHandleUpdate(update)) {
1095
+ maybePromises.push(() => this.#translationsManager.handleUpdate(update));
1096
+ }
1097
+ if (this.#botInfoManager.canHandleUpdate(update)) {
1098
+ maybePromises.push(() => this.#botInfoManager.handleUpdate(update));
1099
+ }
1100
+ if (this.#accountManager.canHandleUpdate(update)) {
1101
+ maybePromises.push(() => this.#accountManager.handleUpdate(update));
1102
+ }
1103
+ return () => Promise.resolve().then(async () => {
1104
+ const updates = [{ update }];
1105
+ for (const maybePromise of maybePromises) {
1106
+ try {
1107
+ const value = maybePromise();
1108
+ const update = value instanceof Promise ? await value : value;
1109
+ if (update) {
1110
+ updates.push(update);
1111
+ }
1112
+ }
1113
+ catch (err) {
1114
+ this.#L.error("failed to construct update:", err);
1115
+ }
1116
+ }
1117
+ for (const update of updates) {
1118
+ try {
1119
+ await this.#handleCtxUpdate(update);
1120
+ }
1121
+ finally {
1122
+ if ("deletedMessages" in update) {
1123
+ for (const { chatId, messageId } of update.deletedMessages) {
1124
+ await this.messageStorage.setMessage(chatId, messageId, null);
1125
+ }
1126
+ }
1127
+ }
1128
+ }
1129
+ });
1130
+ }
1131
+ #lastGetMe = null;
1132
+ async #getMe() {
1133
+ if (this.#lastGetMe !== null) {
1134
+ return this.#lastGetMe;
1135
+ }
1136
+ else {
1137
+ const user = await this.#getMeInner();
1138
+ this.#lastGetMe = user;
1139
+ return user;
1140
+ }
1141
+ }
1142
+ async #getMeInner() {
1143
+ let chatP = (await this[getPeer]({ _: "peerUser", user_id: BigInt(await this.#getSelfId()) }))?.[0] ?? null;
1144
+ if (chatP === null) {
1145
+ const users = await this.invoke({ _: "users.getUsers", id: [{ _: "inputUserSelf" }] });
1146
+ chatP = (0, _3_types_js_1.constructChatP)(_2_tl_js_1.Api.as("user", users[0]));
1147
+ await this.storage.setIsPremium(chatP.isPremium);
1148
+ }
1149
+ const user = (0, _3_types_js_1.constructUser2)(chatP);
1150
+ this.#lastGetMe = user;
1151
+ return user;
1152
+ }
1153
+ #previouslyConnected = false;
1154
+ #lastConnectionState = false;
1155
+ #onConnectionStateChange(isConnected) {
1156
+ if (this.#lastConnectionState !== isConnected) {
1157
+ if (isConnected) {
1158
+ if (this.#previouslyConnected) {
1159
+ (0, _1_utilities_js_1.drop)(this.#updateManager.recoverUpdateGap("reconnect"));
1160
+ }
1161
+ this.#previouslyConnected = true;
1162
+ }
1163
+ const connectionState = isConnected ? "ready" : "notConnected";
1164
+ this.#queueHandleCtxUpdate({ connectionState });
1165
+ }
1166
+ }
1048
1167
  //
1049
1168
  // ========================= ACCOUNT ========================= //
1050
1169
  //
@@ -1055,8 +1174,8 @@ class Client extends _5_composer_js_1.Composer {
1055
1174
  * @returns Information on the currently authorized user.
1056
1175
  */
1057
1176
  async getMe() {
1058
- if (__classPrivateFieldGet(this, _Client_lastGetMe, "f") === null) {
1059
- const me = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkAuthorization).call(this);
1177
+ if (this.#lastGetMe === null) {
1178
+ const me = await this.#checkAuthorization();
1060
1179
  if (!me) {
1061
1180
  throw new _0_errors_js_1.InputError("Not signed in.");
1062
1181
  }
@@ -1064,7 +1183,7 @@ class Client extends _5_composer_js_1.Composer {
1064
1183
  return me;
1065
1184
  }
1066
1185
  }
1067
- return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMeInner).call(this);
1186
+ return await this.#getMeInner();
1068
1187
  }
1069
1188
  /**
1070
1189
  * Show a username in the current account, a bot account, a supergroup, or a channel's profile. User-only.
@@ -1074,7 +1193,7 @@ class Client extends _5_composer_js_1.Composer {
1074
1193
  * @param username The username to show.
1075
1194
  */
1076
1195
  async showUsername(id, username) {
1077
- await __classPrivateFieldGet(this, _Client_accountManager, "f").showUsername(id, username);
1196
+ await this.#accountManager.showUsername(id, username);
1078
1197
  }
1079
1198
  /**
1080
1199
  * Hide a username from the current account, a bot account, a supergroup, or a channel's profile. User-only.
@@ -1084,7 +1203,7 @@ class Client extends _5_composer_js_1.Composer {
1084
1203
  * @param username The username to hide.
1085
1204
  */
1086
1205
  async hideUsername(id, username) {
1087
- await __classPrivateFieldGet(this, _Client_accountManager, "f").hideUsername(id, username);
1206
+ await this.#accountManager.hideUsername(id, username);
1088
1207
  }
1089
1208
  /**
1090
1209
  * Check the availability of a username. User-only.
@@ -1094,7 +1213,7 @@ class Client extends _5_composer_js_1.Composer {
1094
1213
  * @returns Whether the username is available.
1095
1214
  */
1096
1215
  async checkUsername(username, params) {
1097
- return await __classPrivateFieldGet(this, _Client_accountManager, "f").checkUsername(username, params);
1216
+ return await this.#accountManager.checkUsername(username, params);
1098
1217
  }
1099
1218
  /**
1100
1219
  * Set the username of the current account. User-only.
@@ -1103,7 +1222,7 @@ class Client extends _5_composer_js_1.Composer {
1103
1222
  * @param username The username to set.
1104
1223
  */
1105
1224
  async setUsername(username) {
1106
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setUsername(username);
1225
+ await this.#accountManager.setUsername(username);
1107
1226
  }
1108
1227
  /**
1109
1228
  * Remove the current account's username. User-only.
@@ -1111,7 +1230,7 @@ class Client extends _5_composer_js_1.Composer {
1111
1230
  * @method ac
1112
1231
  */
1113
1232
  async removeUsername() {
1114
- await __classPrivateFieldGet(this, _Client_accountManager, "f").removeUsername();
1233
+ await this.#accountManager.removeUsername();
1115
1234
  }
1116
1235
  /**
1117
1236
  * Reorder the usernames of the current account, a bot account, a supergroup, or a channel's profile. User-only.
@@ -1122,7 +1241,7 @@ class Client extends _5_composer_js_1.Composer {
1122
1241
  * @returns Whether the order was changed.
1123
1242
  */
1124
1243
  async reorderUsernames(id, order) {
1125
- return await __classPrivateFieldGet(this, _Client_accountManager, "f").reorderUsernames(id, order);
1244
+ return await this.#accountManager.reorderUsernames(id, order);
1126
1245
  }
1127
1246
  /**
1128
1247
  * Hide all usernames from a supergroup or a channel's profile. User-only.
@@ -1132,7 +1251,7 @@ class Client extends _5_composer_js_1.Composer {
1132
1251
  * @returns Whether any username was hidden.
1133
1252
  */
1134
1253
  async hideUsernames(id) {
1135
- return await __classPrivateFieldGet(this, _Client_accountManager, "f").hideUsernames(id);
1254
+ return await this.#accountManager.hideUsernames(id);
1136
1255
  }
1137
1256
  /**
1138
1257
  * Get a business connection. Bot-only.
@@ -1142,7 +1261,7 @@ class Client extends _5_composer_js_1.Composer {
1142
1261
  * @cache
1143
1262
  */
1144
1263
  async getBusinessConnection(id) {
1145
- return await __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").getBusinessConnection(id);
1264
+ return await this.#businessConnectionManager.getBusinessConnection(id);
1146
1265
  }
1147
1266
  /**
1148
1267
  * Set the current account's online status. User-only.
@@ -1151,7 +1270,7 @@ class Client extends _5_composer_js_1.Composer {
1151
1270
  * @param isOnline The new online status.
1152
1271
  */
1153
1272
  async setIsOnline(isOnline) {
1154
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setIsOnline(isOnline);
1273
+ await this.#accountManager.setIsOnline(isOnline);
1155
1274
  }
1156
1275
  /**
1157
1276
  * Set the current account's emoji status. User-only.
@@ -1160,7 +1279,7 @@ class Client extends _5_composer_js_1.Composer {
1160
1279
  * @param emojiStatus The emoji or gift to set as the new emoji status.
1161
1280
  */
1162
1281
  async setEmojiStatus(emojiStatus, params) {
1163
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setEmojiStatus(emojiStatus, params);
1282
+ await this.#accountManager.setEmojiStatus(emojiStatus, params);
1164
1283
  }
1165
1284
  /**
1166
1285
  * Remove the current account's emoji status. User-only.
@@ -1168,7 +1287,7 @@ class Client extends _5_composer_js_1.Composer {
1168
1287
  * @method ac
1169
1288
  */
1170
1289
  async removeEmojiStatus() {
1171
- await __classPrivateFieldGet(this, _Client_accountManager, "f").removeEmojiStatus();
1290
+ await this.#accountManager.removeEmojiStatus();
1172
1291
  }
1173
1292
  /**
1174
1293
  * Set the emoji status of a channel. User-only.
@@ -1178,7 +1297,7 @@ class Client extends _5_composer_js_1.Composer {
1178
1297
  * @param emojiStatus The emoji or gift to set as the new emoji status.
1179
1298
  */
1180
1299
  async setChannelEmojiStatus(chatId, emojiStatus, params) {
1181
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setChannelEmojiStatus(chatId, emojiStatus, params);
1300
+ await this.#accountManager.setChannelEmojiStatus(chatId, emojiStatus, params);
1182
1301
  }
1183
1302
  /**
1184
1303
  * Remove the emoji status of a channel. User-only.
@@ -1187,7 +1306,7 @@ class Client extends _5_composer_js_1.Composer {
1187
1306
  * @param chatId The identifier of a channel.
1188
1307
  */
1189
1308
  async removeChannelEmojiStatus(chatId) {
1190
- await __classPrivateFieldGet(this, _Client_accountManager, "f").removeChannelEmojiStatus(chatId);
1309
+ await this.#accountManager.removeChannelEmojiStatus(chatId);
1191
1310
  }
1192
1311
  /**
1193
1312
  * Set the emoji status of a bot's user. Bot-only.
@@ -1197,7 +1316,7 @@ class Client extends _5_composer_js_1.Composer {
1197
1316
  * @param emojiStatus The emoji or gift to set as the new emoji status.
1198
1317
  */
1199
1318
  async setUserEmojiStatus(userId, emojiStatus, params) {
1200
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setUserEmojiStatus(userId, emojiStatus, params);
1319
+ await this.#accountManager.setUserEmojiStatus(userId, emojiStatus, params);
1201
1320
  }
1202
1321
  /**
1203
1322
  * Remove the emoji status of a bot's user. Bot-only.
@@ -1206,7 +1325,7 @@ class Client extends _5_composer_js_1.Composer {
1206
1325
  * @param userId The identifier of a user of the bot.
1207
1326
  */
1208
1327
  async removeUserEmojiStatus(userId) {
1209
- await __classPrivateFieldGet(this, _Client_accountManager, "f").removeUserEmojiStatus(userId);
1328
+ await this.#accountManager.removeUserEmojiStatus(userId);
1210
1329
  }
1211
1330
  /**
1212
1331
  * Update the profile of the current user. At least one parameter must be specified. User-only.
@@ -1214,7 +1333,7 @@ class Client extends _5_composer_js_1.Composer {
1214
1333
  * @method ac
1215
1334
  */
1216
1335
  async updateProfile(params) {
1217
- await __classPrivateFieldGet(this, _Client_accountManager, "f").updateProfile(params);
1336
+ await this.#accountManager.updateProfile(params);
1218
1337
  }
1219
1338
  /**
1220
1339
  * Set the birthday of the current user. User-only.
@@ -1222,7 +1341,7 @@ class Client extends _5_composer_js_1.Composer {
1222
1341
  * @method ac
1223
1342
  */
1224
1343
  async setBirthday(params) {
1225
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setBirthday(params);
1344
+ await this.#accountManager.setBirthday(params);
1226
1345
  }
1227
1346
  /**
1228
1347
  * Set the personal channel of the current user. User-only.
@@ -1230,7 +1349,7 @@ class Client extends _5_composer_js_1.Composer {
1230
1349
  * @method ac
1231
1350
  */
1232
1351
  async setPersonalChannel(params) {
1233
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setPersonalChannel(params);
1352
+ await this.#accountManager.setPersonalChannel(params);
1234
1353
  }
1235
1354
  /**
1236
1355
  * Set the name color of the current user. User-only.
@@ -1239,7 +1358,7 @@ class Client extends _5_composer_js_1.Composer {
1239
1358
  * @param color The identifier of the color to set.
1240
1359
  */
1241
1360
  async setNameColor(color, params) {
1242
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setNameColor(color, params);
1361
+ await this.#accountManager.setNameColor(color, params);
1243
1362
  }
1244
1363
  /**
1245
1364
  * Set the profile color of the current user. User-only.
@@ -1248,7 +1367,7 @@ class Client extends _5_composer_js_1.Composer {
1248
1367
  * @param color The identifier of the color to set.
1249
1368
  */
1250
1369
  async setProfileColor(color, params) {
1251
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setProfileColor(color, params);
1370
+ await this.#accountManager.setProfileColor(color, params);
1252
1371
  }
1253
1372
  /**
1254
1373
  * Set the location of the current user. User-only.
@@ -1256,7 +1375,7 @@ class Client extends _5_composer_js_1.Composer {
1256
1375
  * @method ac
1257
1376
  */
1258
1377
  async setLocation(params) {
1259
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setLocation(params);
1378
+ await this.#accountManager.setLocation(params);
1260
1379
  }
1261
1380
  /**
1262
1381
  * Set the working hours of the current user. User-only.
@@ -1264,7 +1383,7 @@ class Client extends _5_composer_js_1.Composer {
1264
1383
  * @method ac
1265
1384
  */
1266
1385
  async setWorkingHours(params) {
1267
- await __classPrivateFieldGet(this, _Client_accountManager, "f").setWorkingHours(params);
1386
+ await this.#accountManager.setWorkingHours(params);
1268
1387
  }
1269
1388
  /**
1270
1389
  * Enable sponsored messages on the current user. User-only.
@@ -1272,7 +1391,7 @@ class Client extends _5_composer_js_1.Composer {
1272
1391
  * @method ac
1273
1392
  */
1274
1393
  async enableSponsoredMessages() {
1275
- await __classPrivateFieldGet(this, _Client_accountManager, "f").enableSponsoredMessages();
1394
+ await this.#accountManager.enableSponsoredMessages();
1276
1395
  }
1277
1396
  /**
1278
1397
  * Disable sponsored messages on the current user. User-only.
@@ -1280,7 +1399,7 @@ class Client extends _5_composer_js_1.Composer {
1280
1399
  * @method ac
1281
1400
  */
1282
1401
  async disableSponsoredMessages() {
1283
- await __classPrivateFieldGet(this, _Client_accountManager, "f").disableSponsoredMessages();
1402
+ await this.#accountManager.disableSponsoredMessages();
1284
1403
  }
1285
1404
  /**
1286
1405
  * Pause the business bot in a chat. User-only.
@@ -1288,7 +1407,7 @@ class Client extends _5_composer_js_1.Composer {
1288
1407
  * @method ac
1289
1408
  */
1290
1409
  async pauseBusinessBotConnection(chatId) {
1291
- await __classPrivateFieldGet(this, _Client_accountManager, "f").pauseBusinessBotConnection(chatId);
1410
+ await this.#accountManager.pauseBusinessBotConnection(chatId);
1292
1411
  }
1293
1412
  /**
1294
1413
  * Resume the business bot in a chat. User-only.
@@ -1296,7 +1415,7 @@ class Client extends _5_composer_js_1.Composer {
1296
1415
  * @method ac
1297
1416
  */
1298
1417
  async resumeBusinessBotConnection(chatId) {
1299
- await __classPrivateFieldGet(this, _Client_accountManager, "f").resumeBusinessBotConnection(chatId);
1418
+ await this.#accountManager.resumeBusinessBotConnection(chatId);
1300
1419
  }
1301
1420
  //
1302
1421
  // ========================= MESSAGES ========================= //
@@ -1310,7 +1429,7 @@ class Client extends _5_composer_js_1.Composer {
1310
1429
  * @returns The sent text message.
1311
1430
  */
1312
1431
  async sendMessage(chatId, text, params) {
1313
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendMessage(chatId, text, params);
1432
+ return await this.#messageManager.sendMessage(chatId, text, params);
1314
1433
  }
1315
1434
  /**
1316
1435
  * Stream a drafted text message. Bot-only.
@@ -1321,7 +1440,7 @@ class Client extends _5_composer_js_1.Composer {
1321
1440
  * @param text The message's text.
1322
1441
  */
1323
1442
  async sendMessageDraft(chatId, draftId, text, params) {
1324
- await __classPrivateFieldGet(this, _Client_messageManager, "f").sendMessageDraft(chatId, draftId, text, params);
1443
+ await this.#messageManager.sendMessageDraft(chatId, draftId, text, params);
1325
1444
  }
1326
1445
  /**
1327
1446
  * Send a photo.
@@ -1332,7 +1451,7 @@ class Client extends _5_composer_js_1.Composer {
1332
1451
  * @returns The sent photo.
1333
1452
  */
1334
1453
  async sendPhoto(chatId, photo, params) {
1335
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendPhoto(chatId, photo, params);
1454
+ return await this.#messageManager.sendPhoto(chatId, photo, params);
1336
1455
  }
1337
1456
  /**
1338
1457
  * Send a document.
@@ -1343,7 +1462,7 @@ class Client extends _5_composer_js_1.Composer {
1343
1462
  * @returns The sent document.
1344
1463
  */
1345
1464
  async sendDocument(chatId, document, params) {
1346
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendDocument(chatId, document, params);
1465
+ return await this.#messageManager.sendDocument(chatId, document, params);
1347
1466
  }
1348
1467
  /**
1349
1468
  * Send a sticker.
@@ -1354,7 +1473,7 @@ class Client extends _5_composer_js_1.Composer {
1354
1473
  * @returns The sent sticker.
1355
1474
  */
1356
1475
  async sendSticker(chatId, sticker, params) {
1357
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendSticker(chatId, sticker, params);
1476
+ return await this.#messageManager.sendSticker(chatId, sticker, params);
1358
1477
  }
1359
1478
  /**
1360
1479
  * Send a video.
@@ -1365,7 +1484,7 @@ class Client extends _5_composer_js_1.Composer {
1365
1484
  * @returns The sent video.
1366
1485
  */
1367
1486
  async sendVideo(chatId, video, params) {
1368
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVideo(chatId, video, params);
1487
+ return await this.#messageManager.sendVideo(chatId, video, params);
1369
1488
  }
1370
1489
  /**
1371
1490
  * Send an animation.
@@ -1376,7 +1495,7 @@ class Client extends _5_composer_js_1.Composer {
1376
1495
  * @returns The sent animation.
1377
1496
  */
1378
1497
  async sendAnimation(chatId, animation, params) {
1379
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendAnimation(chatId, animation, params);
1498
+ return await this.#messageManager.sendAnimation(chatId, animation, params);
1380
1499
  }
1381
1500
  /**
1382
1501
  * Send a voice message.
@@ -1387,7 +1506,7 @@ class Client extends _5_composer_js_1.Composer {
1387
1506
  * @returns The sent voice message.
1388
1507
  */
1389
1508
  async sendVoice(chatId, voice, params) {
1390
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVoice(chatId, voice, params);
1509
+ return await this.#messageManager.sendVoice(chatId, voice, params);
1391
1510
  }
1392
1511
  /**
1393
1512
  * Send an audio file.
@@ -1398,7 +1517,7 @@ class Client extends _5_composer_js_1.Composer {
1398
1517
  * @returns The sent audio filr.
1399
1518
  */
1400
1519
  async sendAudio(chatId, audio, params) {
1401
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendAudio(chatId, audio, params);
1520
+ return await this.#messageManager.sendAudio(chatId, audio, params);
1402
1521
  }
1403
1522
  /**
1404
1523
  * Send a media group.
@@ -1409,7 +1528,7 @@ class Client extends _5_composer_js_1.Composer {
1409
1528
  * @returns The sent messages.
1410
1529
  */
1411
1530
  async sendMediaGroup(chatId, media, params) {
1412
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendMediaGroup(chatId, media, params);
1531
+ return await this.#messageManager.sendMediaGroup(chatId, media, params);
1413
1532
  }
1414
1533
  /**
1415
1534
  * Send a video note.
@@ -1420,7 +1539,7 @@ class Client extends _5_composer_js_1.Composer {
1420
1539
  * @returns The sent video note.
1421
1540
  */
1422
1541
  async sendVideoNote(chatId, videoNote, params) {
1423
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVideoNote(chatId, videoNote, params);
1542
+ return await this.#messageManager.sendVideoNote(chatId, videoNote, params);
1424
1543
  }
1425
1544
  /**
1426
1545
  * Send a location.
@@ -1432,7 +1551,7 @@ class Client extends _5_composer_js_1.Composer {
1432
1551
  * @returns The sent location.
1433
1552
  */
1434
1553
  async sendLocation(chatId, latitude, longitude, params) {
1435
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendLocation(chatId, latitude, longitude, params);
1554
+ return await this.#messageManager.sendLocation(chatId, latitude, longitude, params);
1436
1555
  }
1437
1556
  /**
1438
1557
  * Send a contact.
@@ -1444,7 +1563,7 @@ class Client extends _5_composer_js_1.Composer {
1444
1563
  * @returns The sent contact.
1445
1564
  */
1446
1565
  async sendContact(chatId, firstName, number, params) {
1447
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendContact(chatId, firstName, number, params);
1566
+ return await this.#messageManager.sendContact(chatId, firstName, number, params);
1448
1567
  }
1449
1568
  /**
1450
1569
  * Send a dice.
@@ -1454,7 +1573,7 @@ class Client extends _5_composer_js_1.Composer {
1454
1573
  * @returns The sent dice.
1455
1574
  */
1456
1575
  async sendDice(chatId, params) {
1457
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendDice(chatId, params);
1576
+ return await this.#messageManager.sendDice(chatId, params);
1458
1577
  }
1459
1578
  /**
1460
1579
  * Send a venue.
@@ -1468,7 +1587,7 @@ class Client extends _5_composer_js_1.Composer {
1468
1587
  * @returns The sent venue.
1469
1588
  */
1470
1589
  async sendVenue(chatId, latitude, longitude, title, address, params) {
1471
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendVenue(chatId, latitude, longitude, title, address, params);
1590
+ return await this.#messageManager.sendVenue(chatId, latitude, longitude, title, address, params);
1472
1591
  }
1473
1592
  /**
1474
1593
  * Send a poll.
@@ -1480,7 +1599,7 @@ class Client extends _5_composer_js_1.Composer {
1480
1599
  * @returns The sent poll.
1481
1600
  */
1482
1601
  async sendPoll(chatId, question, options, params) {
1483
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendPoll(chatId, question, options, params);
1602
+ return await this.#messageManager.sendPoll(chatId, question, options, params);
1484
1603
  }
1485
1604
  /**
1486
1605
  * Send a checklist. User-only.
@@ -1492,7 +1611,7 @@ class Client extends _5_composer_js_1.Composer {
1492
1611
  * @returns The sent checklist.
1493
1612
  */
1494
1613
  async sendChecklist(chatId, title, items, params) {
1495
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendChecklist(chatId, title, items, params);
1614
+ return await this.#messageManager.sendChecklist(chatId, title, items, params);
1496
1615
  }
1497
1616
  /**
1498
1617
  * Send an invoice. Bot-only.
@@ -1507,7 +1626,7 @@ class Client extends _5_composer_js_1.Composer {
1507
1626
  * @returns The sent invoice.
1508
1627
  */
1509
1628
  async sendInvoice(chatId, title, description, payload, currency, prices, params) {
1510
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendInvoice(chatId, title, description, payload, currency, prices, params);
1629
+ return await this.#messageManager.sendInvoice(chatId, title, description, payload, currency, prices, params);
1511
1630
  }
1512
1631
  /**
1513
1632
  * Edit a message's text.
@@ -1519,7 +1638,7 @@ class Client extends _5_composer_js_1.Composer {
1519
1638
  * @returns The edited text message.
1520
1639
  */
1521
1640
  async editMessageText(chatId, messageId, text, params) {
1522
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").editMessageText(chatId, messageId, text, params);
1641
+ return await this.#messageManager.editMessageText(chatId, messageId, text, params);
1523
1642
  }
1524
1643
  /**
1525
1644
  * Edit a message's caption.
@@ -1531,7 +1650,7 @@ class Client extends _5_composer_js_1.Composer {
1531
1650
  * @returns The edited message.
1532
1651
  */
1533
1652
  async editMessageCaption(chatId, messageId, params) {
1534
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").editMessageCaption(chatId, messageId, params);
1653
+ return await this.#messageManager.editMessageCaption(chatId, messageId, params);
1535
1654
  }
1536
1655
  /**
1537
1656
  * Edit a message's media.
@@ -1543,7 +1662,7 @@ class Client extends _5_composer_js_1.Composer {
1543
1662
  * @returns The edited message.
1544
1663
  */
1545
1664
  async editMessageMedia(chatId, messageId, media, params) {
1546
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").editMessageMedia(chatId, messageId, media, params);
1665
+ return await this.#messageManager.editMessageMedia(chatId, messageId, media, params);
1547
1666
  }
1548
1667
  /**
1549
1668
  * Edit an inline message's media.
@@ -1553,7 +1672,7 @@ class Client extends _5_composer_js_1.Composer {
1553
1672
  * @param media The new media of the message.
1554
1673
  */
1555
1674
  async editInlineMessageMedia(inlineMessageId, media, params) {
1556
- await __classPrivateFieldGet(this, _Client_messageManager, "f").editInlineMessageMedia(inlineMessageId, media, params);
1675
+ await this.#messageManager.editInlineMessageMedia(inlineMessageId, media, params);
1557
1676
  }
1558
1677
  /**
1559
1678
  * Edit an inline message's text. Bot-only.
@@ -1563,7 +1682,7 @@ class Client extends _5_composer_js_1.Composer {
1563
1682
  * @param text The new text of the message.
1564
1683
  */
1565
1684
  async editInlineMessageText(inlineMessageId, text, params) {
1566
- await __classPrivateFieldGet(this, _Client_messageManager, "f").editInlineMessageText(inlineMessageId, text, params);
1685
+ await this.#messageManager.editInlineMessageText(inlineMessageId, text, params);
1567
1686
  }
1568
1687
  /**
1569
1688
  * Edit an inline message's caption. Bot-only.
@@ -1572,7 +1691,7 @@ class Client extends _5_composer_js_1.Composer {
1572
1691
  * @param inlineMessageId The identifier of the inline message.
1573
1692
  */
1574
1693
  async editInlineMessageCaption(inlineMessageId, params) {
1575
- await __classPrivateFieldGet(this, _Client_messageManager, "f").editInlineMessageCaption(inlineMessageId, params);
1694
+ await this.#messageManager.editInlineMessageCaption(inlineMessageId, params);
1576
1695
  }
1577
1696
  /**
1578
1697
  * Edit a message's reply markup.
@@ -1583,7 +1702,7 @@ class Client extends _5_composer_js_1.Composer {
1583
1702
  * @returns The edited message.
1584
1703
  */
1585
1704
  async editMessageReplyMarkup(chatId, messageId, params) {
1586
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").editMessageReplyMarkup(chatId, messageId, params);
1705
+ return await this.#messageManager.editMessageReplyMarkup(chatId, messageId, params);
1587
1706
  }
1588
1707
  /**
1589
1708
  * Edit an inline message's reply markup. Bot-only.
@@ -1592,7 +1711,7 @@ class Client extends _5_composer_js_1.Composer {
1592
1711
  * @param inlineMessageId The identifier of the inline message.
1593
1712
  */
1594
1713
  async editInlineMessageReplyMarkup(inlineMessageId, params) {
1595
- await __classPrivateFieldGet(this, _Client_messageManager, "f").editInlineMessageReplyMarkup(inlineMessageId, params);
1714
+ await this.#messageManager.editInlineMessageReplyMarkup(inlineMessageId, params);
1596
1715
  }
1597
1716
  /**
1598
1717
  * Edit a message's live location.
@@ -1605,7 +1724,7 @@ class Client extends _5_composer_js_1.Composer {
1605
1724
  * @returns The edited location message.
1606
1725
  */
1607
1726
  async editMessageLiveLocation(chatId, messageId, latitude, longitude, params) {
1608
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").editMessageLiveLocation(chatId, messageId, latitude, longitude, params);
1727
+ return await this.#messageManager.editMessageLiveLocation(chatId, messageId, latitude, longitude, params);
1609
1728
  }
1610
1729
  /**
1611
1730
  * Edit an inline message's live location. Bot-only.
@@ -1617,7 +1736,7 @@ class Client extends _5_composer_js_1.Composer {
1617
1736
  * @returns The edited location message.
1618
1737
  */
1619
1738
  async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
1620
- await __classPrivateFieldGet(this, _Client_messageManager, "f").editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params);
1739
+ await this.#messageManager.editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params);
1621
1740
  }
1622
1741
  /**
1623
1742
  * Retrieve multiple messages.
@@ -1632,7 +1751,7 @@ class Client extends _5_composer_js_1.Composer {
1632
1751
  * @cache
1633
1752
  */
1634
1753
  async getMessages(chatId, messageIds) {
1635
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").getMessages(chatId, messageIds);
1754
+ return await this.#messageManager.getMessages(chatId, messageIds);
1636
1755
  }
1637
1756
  /**
1638
1757
  * Retrieve a single message.
@@ -1647,7 +1766,7 @@ class Client extends _5_composer_js_1.Composer {
1647
1766
  * @cache
1648
1767
  */
1649
1768
  async getMessage(chatId, messageId) {
1650
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").getMessage(chatId, messageId);
1769
+ return await this.#messageManager.getMessage(chatId, messageId);
1651
1770
  }
1652
1771
  /**
1653
1772
  * Retrieve a message using its link.
@@ -1660,7 +1779,7 @@ class Client extends _5_composer_js_1.Composer {
1660
1779
  * @returns The message that was linked to.
1661
1780
  */
1662
1781
  async resolveMessageLink(link) {
1663
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").resolveMessageLink(link);
1782
+ return await this.#messageManager.resolveMessageLink(link);
1664
1783
  }
1665
1784
  /**
1666
1785
  * Delete multiple messages.
@@ -1670,7 +1789,7 @@ class Client extends _5_composer_js_1.Composer {
1670
1789
  * @param messageIds The identifiers of the messages to delete.
1671
1790
  */
1672
1791
  async deleteMessages(chatId, messageIds, params) {
1673
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteMessages(chatId, messageIds, params);
1792
+ await this.#messageManager.deleteMessages(chatId, messageIds, params);
1674
1793
  }
1675
1794
  /**
1676
1795
  * Delete a single message.
@@ -1680,7 +1799,7 @@ class Client extends _5_composer_js_1.Composer {
1680
1799
  * @param messageId The identifier of the message to delete.
1681
1800
  */
1682
1801
  async deleteMessage(chatId, messageId, params) {
1683
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteMessages(chatId, [messageId], params);
1802
+ await this.#messageManager.deleteMessages(chatId, [messageId], params);
1684
1803
  }
1685
1804
  /**
1686
1805
  * Delete all messages sent by a specific member of a chat. User-only.
@@ -1690,7 +1809,7 @@ class Client extends _5_composer_js_1.Composer {
1690
1809
  * @param memberId The identifier of the member.
1691
1810
  */
1692
1811
  async deleteChatMemberMessages(chatId, memberId) {
1693
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteChatMemberMessages(chatId, memberId);
1812
+ await this.#messageManager.deleteChatMemberMessages(chatId, memberId);
1694
1813
  }
1695
1814
  /**
1696
1815
  * Delete multiple scheduled messages.
@@ -1700,7 +1819,7 @@ class Client extends _5_composer_js_1.Composer {
1700
1819
  * @param messageIds The identifiers of the scheduled messages to delete.
1701
1820
  */
1702
1821
  async deleteScheduledMessages(chatId, messageIds) {
1703
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteScheduledMessages(chatId, messageIds);
1822
+ await this.#messageManager.deleteScheduledMessages(chatId, messageIds);
1704
1823
  }
1705
1824
  /**
1706
1825
  * Delete a scheduled message.
@@ -1710,7 +1829,7 @@ class Client extends _5_composer_js_1.Composer {
1710
1829
  * @param messageId The identifier of the scheduled message to delete.
1711
1830
  */
1712
1831
  async deleteScheduledMessage(chatId, messageId) {
1713
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteScheduledMessage(chatId, messageId);
1832
+ await this.#messageManager.deleteScheduledMessage(chatId, messageId);
1714
1833
  }
1715
1834
  /**
1716
1835
  * Send multiple scheduled messages before their schedule.
@@ -1720,7 +1839,7 @@ class Client extends _5_composer_js_1.Composer {
1720
1839
  * @param messageIds The identifiers of the scheduled messages to send.
1721
1840
  */
1722
1841
  async sendScheduledMessages(chatId, messageIds) {
1723
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendScheduledMessages(chatId, messageIds);
1842
+ return await this.#messageManager.sendScheduledMessages(chatId, messageIds);
1724
1843
  }
1725
1844
  /**
1726
1845
  * Send a scheduled message before its schedule.
@@ -1730,7 +1849,7 @@ class Client extends _5_composer_js_1.Composer {
1730
1849
  * @param messageId The identifier of the scheduled message to send.
1731
1850
  */
1732
1851
  async sendScheduledMessage(chatId, messageId) {
1733
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendScheduledMessage(chatId, messageId);
1852
+ return await this.#messageManager.sendScheduledMessage(chatId, messageId);
1734
1853
  }
1735
1854
  /**
1736
1855
  * Pin a message in a chat.
@@ -1740,7 +1859,7 @@ class Client extends _5_composer_js_1.Composer {
1740
1859
  * @param messageId The identifier of the message.
1741
1860
  */
1742
1861
  async pinMessage(chatId, messageId, params) {
1743
- await __classPrivateFieldGet(this, _Client_messageManager, "f").pinMessage(chatId, messageId, params);
1862
+ await this.#messageManager.pinMessage(chatId, messageId, params);
1744
1863
  }
1745
1864
  /**
1746
1865
  * Unpin a pinned message.
@@ -1750,7 +1869,7 @@ class Client extends _5_composer_js_1.Composer {
1750
1869
  * @param messageId The identifier of the message.
1751
1870
  */
1752
1871
  async unpinMessage(chatId, messageId, params) {
1753
- await __classPrivateFieldGet(this, _Client_messageManager, "f").unpinMessage(chatId, messageId, params);
1872
+ await this.#messageManager.unpinMessage(chatId, messageId, params);
1754
1873
  }
1755
1874
  /**
1756
1875
  * Unpin all pinned messages.
@@ -1759,7 +1878,7 @@ class Client extends _5_composer_js_1.Composer {
1759
1878
  * @param chatId The identifier of a chat.
1760
1879
  */
1761
1880
  async unpinMessages(chatId, params) {
1762
- await __classPrivateFieldGet(this, _Client_messageManager, "f").unpinMessages(chatId, params);
1881
+ await this.#messageManager.unpinMessages(chatId, params);
1763
1882
  }
1764
1883
  /**
1765
1884
  * Forward multiple messages.
@@ -1771,7 +1890,7 @@ class Client extends _5_composer_js_1.Composer {
1771
1890
  * @returns The forwarded messages.
1772
1891
  */
1773
1892
  async forwardMessages(from, to, messageIds, params) {
1774
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").forwardMessages(from, to, messageIds, params);
1893
+ return await this.#messageManager.forwardMessages(from, to, messageIds, params);
1775
1894
  }
1776
1895
  /**
1777
1896
  * Forward a single message.
@@ -1794,7 +1913,7 @@ class Client extends _5_composer_js_1.Composer {
1794
1913
  * @returns The new state of the poll.
1795
1914
  */
1796
1915
  async stopPoll(chatId, messageId, params) {
1797
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").stopPoll(chatId, messageId, params);
1916
+ return await this.#messageManager.stopPoll(chatId, messageId, params);
1798
1917
  }
1799
1918
  /**
1800
1919
  * Send a chat action.
@@ -1805,7 +1924,7 @@ class Client extends _5_composer_js_1.Composer {
1805
1924
  * @param messageThreadId The thread to send the chat action to.
1806
1925
  */
1807
1926
  async sendChatAction(chatId, action, params) {
1808
- await __classPrivateFieldGet(this, _Client_messageManager, "f").sendChatAction(chatId, action, params);
1927
+ await this.#messageManager.sendChatAction(chatId, action, params);
1809
1928
  }
1810
1929
  /**
1811
1930
  * Search for messages. User-only.
@@ -1813,7 +1932,7 @@ class Client extends _5_composer_js_1.Composer {
1813
1932
  * @method ms
1814
1933
  */
1815
1934
  async searchMessages(params) {
1816
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").searchMessages(params);
1935
+ return await this.#messageManager.searchMessages(params);
1817
1936
  }
1818
1937
  /**
1819
1938
  * Mark messages as read. User-only.
@@ -1823,7 +1942,7 @@ class Client extends _5_composer_js_1.Composer {
1823
1942
  * @param untilMessageId The identifier of the message that will be marked as read, along with any other unread messages before it.
1824
1943
  */
1825
1944
  async readMessages(chatId, untilMessageId) {
1826
- await __classPrivateFieldGet(this, _Client_messageManager, "f").readMessages(chatId, untilMessageId);
1945
+ await this.#messageManager.readMessages(chatId, untilMessageId);
1827
1946
  }
1828
1947
  /**
1829
1948
  * Start a bot. User-only.
@@ -1833,7 +1952,7 @@ class Client extends _5_composer_js_1.Composer {
1833
1952
  * @returns The start message.
1834
1953
  */
1835
1954
  async startBot(botId, params) {
1836
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").startBot(botId, params);
1955
+ return await this.#messageManager.startBot(botId, params);
1837
1956
  }
1838
1957
  /**
1839
1958
  * Transcribe a voice message. User-only.
@@ -1844,7 +1963,7 @@ class Client extends _5_composer_js_1.Composer {
1844
1963
  * @cache
1845
1964
  */
1846
1965
  async transcribeVoice(chatId, messageId) {
1847
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").transcribeVoice(chatId, messageId);
1966
+ return await this.#messageManager.transcribeVoice(chatId, messageId);
1848
1967
  }
1849
1968
  /**
1850
1969
  * Get a sticker set.
@@ -1853,7 +1972,7 @@ class Client extends _5_composer_js_1.Composer {
1853
1972
  * @param name The name of the sticker set or its link.
1854
1973
  */
1855
1974
  async getStickerSet(name) {
1856
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").getStickerSet(name);
1975
+ return await this.#messageManager.getStickerSet(name);
1857
1976
  }
1858
1977
  /*
1859
1978
  * Get the link preview for a message that is about to be sent. User-only.
@@ -1862,7 +1981,7 @@ class Client extends _5_composer_js_1.Composer {
1862
1981
  * @param text The message's text.
1863
1982
  */
1864
1983
  async getLinkPreview(text, params) {
1865
- return await __classPrivateFieldGet(this, _Client_linkPreviewManager, "f").getLinkPreview(text, params);
1984
+ return await this.#linkPreviewManager.getLinkPreview(text, params);
1866
1985
  }
1867
1986
  /**
1868
1987
  * Open a mini app. User-only.
@@ -1873,7 +1992,7 @@ class Client extends _5_composer_js_1.Composer {
1873
1992
  * @cache
1874
1993
  */
1875
1994
  async openMiniApp(botId, chatId, params) {
1876
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").openMiniApp(botId, chatId, params);
1995
+ return await this.#messageManager.openMiniApp(botId, chatId, params);
1877
1996
  }
1878
1997
  /**
1879
1998
  * Get a progress ID that can be passed to relevant send* methods to receive upload progress updates for them.
@@ -1882,7 +2001,7 @@ class Client extends _5_composer_js_1.Composer {
1882
2001
  * @cache
1883
2002
  */
1884
2003
  async getProgressId() {
1885
- return await __classPrivateFieldGet(this, _Client_fileManager, "f").getProgressId();
2004
+ return await this.#fileManager.getProgressId();
1886
2005
  }
1887
2006
  /**
1888
2007
  * Get messages saved from a specific chat.
@@ -1891,7 +2010,7 @@ class Client extends _5_composer_js_1.Composer {
1891
2010
  * @param chatId The identifier of a chat.
1892
2011
  */
1893
2012
  async getSavedMessages(chatId, params) {
1894
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").getSavedMessages(chatId, params);
2013
+ return await this.#messageManager.getSavedMessages(chatId, params);
1895
2014
  }
1896
2015
  /**
1897
2016
  * Get a list of saved chats.
@@ -1899,7 +2018,7 @@ class Client extends _5_composer_js_1.Composer {
1899
2018
  * @method ms
1900
2019
  */
1901
2020
  async getSavedChats(params) {
1902
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").getSavedChats(params);
2021
+ return await this.#messageManager.getSavedChats(params);
1903
2022
  }
1904
2023
  /**
1905
2024
  * Get a list of reactions made to a message. User-only.
@@ -1909,7 +2028,7 @@ class Client extends _5_composer_js_1.Composer {
1909
2028
  * @method ms
1910
2029
  */
1911
2030
  async getMessageReactions(chatId, messageId, params) {
1912
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").getMessageReactions(chatId, messageId, params);
2031
+ return await this.#messageManager.getMessageReactions(chatId, messageId, params);
1913
2032
  }
1914
2033
  //
1915
2034
  // ========================= POLLS ========================= //
@@ -1923,7 +2042,7 @@ class Client extends _5_composer_js_1.Composer {
1923
2042
  * @param optionIndexes The indexes of the options to cast for.
1924
2043
  */
1925
2044
  async vote(chatId, messageId, optionIndexes) {
1926
- await __classPrivateFieldGet(this, _Client_pollManager, "f").vote(chatId, messageId, optionIndexes);
2045
+ await this.#pollManager.vote(chatId, messageId, optionIndexes);
1927
2046
  }
1928
2047
  /**
1929
2048
  * Retract a vote. User-only.
@@ -1933,7 +2052,7 @@ class Client extends _5_composer_js_1.Composer {
1933
2052
  * @param messageId The identifier of the message that includes the poll.
1934
2053
  */
1935
2054
  async retractVote(chatId, messageId) {
1936
- await __classPrivateFieldGet(this, _Client_pollManager, "f").retractVote(chatId, messageId);
2055
+ await this.#pollManager.retractVote(chatId, messageId);
1937
2056
  }
1938
2057
  //
1939
2058
  // ========================= CHECKLISTS ========================= //
@@ -1947,7 +2066,7 @@ class Client extends _5_composer_js_1.Composer {
1947
2066
  * @method cl
1948
2067
  */
1949
2068
  async addToChecklist(chatId, messageId, items) {
1950
- await __classPrivateFieldGet(this, _Client_checklistManager, "f").addToChecklist(chatId, messageId, items);
2069
+ await this.#checklistManager.addToChecklist(chatId, messageId, items);
1951
2070
  }
1952
2071
  /**
1953
2072
  * Update a checklist. User-only.
@@ -1957,7 +2076,7 @@ class Client extends _5_composer_js_1.Composer {
1957
2076
  * @method cl
1958
2077
  */
1959
2078
  async updateChecklist(chatId, messageId, params) {
1960
- await __classPrivateFieldGet(this, _Client_checklistManager, "f").updateChecklist(chatId, messageId, params);
2079
+ await this.#checklistManager.updateChecklist(chatId, messageId, params);
1961
2080
  }
1962
2081
  /**
1963
2082
  * Check multiple items of a checklist. User-only.
@@ -1968,7 +2087,7 @@ class Client extends _5_composer_js_1.Composer {
1968
2087
  * @method cl
1969
2088
  */
1970
2089
  async checkChecklistItems(chatId, messageId, items) {
1971
- await __classPrivateFieldGet(this, _Client_checklistManager, "f").checkChecklistItems(chatId, messageId, items);
2090
+ await this.#checklistManager.checkChecklistItems(chatId, messageId, items);
1972
2091
  }
1973
2092
  /**
1974
2093
  * Uncheck multiple items of a checklist. User-only.
@@ -1979,7 +2098,7 @@ class Client extends _5_composer_js_1.Composer {
1979
2098
  * @method cl
1980
2099
  */
1981
2100
  async uncheckChecklistItems(chatId, messageId, items) {
1982
- await __classPrivateFieldGet(this, _Client_checklistManager, "f").uncheckChecklistItems(chatId, messageId, items);
2101
+ await this.#checklistManager.uncheckChecklistItems(chatId, messageId, items);
1983
2102
  }
1984
2103
  /**
1985
2104
  * Check a single item of a checklist. User-only.
@@ -1990,7 +2109,7 @@ class Client extends _5_composer_js_1.Composer {
1990
2109
  * @method cl
1991
2110
  */
1992
2111
  async checkChecklistItem(chatId, messageId, item) {
1993
- await __classPrivateFieldGet(this, _Client_checklistManager, "f").checkChecklistItem(chatId, messageId, item);
2112
+ await this.#checklistManager.checkChecklistItem(chatId, messageId, item);
1994
2113
  }
1995
2114
  /**
1996
2115
  * Uncheck a single item of a checklist. User-only.
@@ -2001,7 +2120,7 @@ class Client extends _5_composer_js_1.Composer {
2001
2120
  * @method cl
2002
2121
  */
2003
2122
  async uncheckChecklistItem(chatId, messageId, item) {
2004
- await __classPrivateFieldGet(this, _Client_checklistManager, "f").uncheckChecklistItem(chatId, messageId, item);
2123
+ await this.#checklistManager.uncheckChecklistItem(chatId, messageId, item);
2005
2124
  }
2006
2125
  //
2007
2126
  // ========================= FILES ========================= //
@@ -2019,7 +2138,7 @@ class Client extends _5_composer_js_1.Composer {
2019
2138
  */
2020
2139
  async downloadChunk(fileId, params) {
2021
2140
  const controller = new AbortController();
2022
- for await (const chunk of __classPrivateFieldGet(this, _Client_fileManager, "f").download(fileId, { ...params, signal: controller.signal })) {
2141
+ for await (const chunk of this.#fileManager.download(fileId, { ...params, signal: controller.signal })) {
2023
2142
  controller.abort();
2024
2143
  return chunk;
2025
2144
  }
@@ -2039,7 +2158,7 @@ class Client extends _5_composer_js_1.Composer {
2039
2158
  * @cache file
2040
2159
  */
2041
2160
  async *download(fileId, params) {
2042
- for await (const chunk of __classPrivateFieldGet(this, _Client_fileManager, "f").download(fileId, params)) {
2161
+ for await (const chunk of this.#fileManager.download(fileId, params)) {
2043
2162
  yield chunk;
2044
2163
  }
2045
2164
  }
@@ -2052,7 +2171,7 @@ class Client extends _5_composer_js_1.Composer {
2052
2171
  * @cache
2053
2172
  */
2054
2173
  async getCustomEmojiStickers(id) {
2055
- return await __classPrivateFieldGet(this, _Client_fileManager, "f").getCustomEmojiStickers(id);
2174
+ return await this.#fileManager.getCustomEmojiStickers(id);
2056
2175
  }
2057
2176
  //
2058
2177
  // ========================= CHATS ========================= //
@@ -2063,7 +2182,7 @@ class Client extends _5_composer_js_1.Composer {
2063
2182
  * @method ch
2064
2183
  */
2065
2184
  async getChats(params) {
2066
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChats(params?.from, params?.after, params?.limit);
2185
+ return await this.#chatListManager.getChats(params?.from, params?.after, params?.limit);
2067
2186
  }
2068
2187
  /**
2069
2188
  * Get pinned chats from a chat list. User-only.
@@ -2072,7 +2191,7 @@ class Client extends _5_composer_js_1.Composer {
2072
2191
  * @param from The chat list to get the pinned chats from. Defaults to main.
2073
2192
  */
2074
2193
  async getPinnedChats(from) {
2075
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getPinnedChats(from);
2194
+ return await this.#chatListManager.getPinnedChats(from);
2076
2195
  }
2077
2196
  /**
2078
2197
  * Get a chat.
@@ -2081,7 +2200,7 @@ class Client extends _5_composer_js_1.Composer {
2081
2200
  * @cache
2082
2201
  */
2083
2202
  async getChat(chatId) {
2084
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChat(chatId);
2203
+ return await this.#chatListManager.getChat(chatId);
2085
2204
  }
2086
2205
  /**
2087
2206
  * Get chat history. User-only.
@@ -2090,7 +2209,7 @@ class Client extends _5_composer_js_1.Composer {
2090
2209
  * @param chatId The identifier of a chat.
2091
2210
  */
2092
2211
  async getHistory(chatId, params) {
2093
- return await __classPrivateFieldGet(this, _Client_messageManager, "f").getHistory(chatId, params);
2212
+ return await this.#messageManager.getHistory(chatId, params);
2094
2213
  }
2095
2214
  /**
2096
2215
  * Set a chat's available reactions. User-only.
@@ -2100,7 +2219,7 @@ class Client extends _5_composer_js_1.Composer {
2100
2219
  * @param availableReactions The new available reactions.
2101
2220
  */
2102
2221
  async setAvailableReactions(chatId, availableReactions) {
2103
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setAvailableReactions(chatId, availableReactions);
2222
+ await this.#chatManager.setAvailableReactions(chatId, availableReactions);
2104
2223
  }
2105
2224
  /**
2106
2225
  * Set a chat's photo.
@@ -2110,7 +2229,7 @@ class Client extends _5_composer_js_1.Composer {
2110
2229
  * @param photo A photo to set as the chat's photo.
2111
2230
  */
2112
2231
  async setChatPhoto(chatId, photo, params) {
2113
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setChatPhoto(chatId, photo, params);
2232
+ await this.#chatManager.setChatPhoto(chatId, photo, params);
2114
2233
  }
2115
2234
  /**
2116
2235
  * Delete a chat's photo.
@@ -2119,7 +2238,7 @@ class Client extends _5_composer_js_1.Composer {
2119
2238
  * @param chatId The identifier of a chat.
2120
2239
  */
2121
2240
  async deleteChatPhoto(chatId) {
2122
- await __classPrivateFieldGet(this, _Client_chatManager, "f").deleteChatPhoto(chatId);
2241
+ await this.#chatManager.deleteChatPhoto(chatId);
2123
2242
  }
2124
2243
  /**
2125
2244
  * Ban a member from a chat.
@@ -2129,7 +2248,7 @@ class Client extends _5_composer_js_1.Composer {
2129
2248
  * @param memberId The identifier of the member.
2130
2249
  */
2131
2250
  async banChatMember(chatId, memberId, params) {
2132
- await __classPrivateFieldGet(this, _Client_chatManager, "f").banChatMember(chatId, memberId, params);
2251
+ await this.#chatManager.banChatMember(chatId, memberId, params);
2133
2252
  }
2134
2253
  /**
2135
2254
  * Unban a member from a chat.
@@ -2139,7 +2258,7 @@ class Client extends _5_composer_js_1.Composer {
2139
2258
  * @param memberId The identifier of the member.
2140
2259
  */
2141
2260
  async unbanChatMember(chatId, memberId) {
2142
- await __classPrivateFieldGet(this, _Client_chatManager, "f").unbanChatMember(chatId, memberId);
2261
+ await this.#chatManager.unbanChatMember(chatId, memberId);
2143
2262
  }
2144
2263
  /**
2145
2264
  * Kick a member from a chat. Same as a banChatMember call followed by unbanChatMember.
@@ -2149,8 +2268,8 @@ class Client extends _5_composer_js_1.Composer {
2149
2268
  * @param memberId The identifier of the member.
2150
2269
  */
2151
2270
  async kickChatMember(chatId, memberId) {
2152
- await __classPrivateFieldGet(this, _Client_chatManager, "f").banChatMember(chatId, memberId);
2153
- await __classPrivateFieldGet(this, _Client_chatManager, "f").unbanChatMember(chatId, memberId);
2271
+ await this.#chatManager.banChatMember(chatId, memberId);
2272
+ await this.#chatManager.unbanChatMember(chatId, memberId);
2154
2273
  }
2155
2274
  /**
2156
2275
  * Set the rights of a chat member.
@@ -2160,7 +2279,7 @@ class Client extends _5_composer_js_1.Composer {
2160
2279
  * @param memberId The identifier of the member.
2161
2280
  */
2162
2281
  async setChatMemberRights(chatId, memberId, params) {
2163
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setChatMemberRights(chatId, memberId, params);
2282
+ await this.#chatManager.setChatMemberRights(chatId, memberId, params);
2164
2283
  }
2165
2284
  /**
2166
2285
  * Get the administrators of a chat.
@@ -2170,7 +2289,7 @@ class Client extends _5_composer_js_1.Composer {
2170
2289
  * @returns The chat's administrators.
2171
2290
  */
2172
2291
  async getChatAdministrators(chatId) {
2173
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChatAdministrators(chatId);
2292
+ return await this.#chatListManager.getChatAdministrators(chatId);
2174
2293
  }
2175
2294
  /**
2176
2295
  * Enable join requests in a chat. User-only.
@@ -2179,7 +2298,7 @@ class Client extends _5_composer_js_1.Composer {
2179
2298
  * @param chatId The identifier of a chat. Must be a channel or a supergroup.
2180
2299
  */
2181
2300
  async enableJoinRequests(chatId) {
2182
- await __classPrivateFieldGet(this, _Client_chatManager, "f").enableJoinRequests(chatId);
2301
+ await this.#chatManager.enableJoinRequests(chatId);
2183
2302
  }
2184
2303
  /**
2185
2304
  * Disable join requests in a chat. User-only.
@@ -2188,7 +2307,7 @@ class Client extends _5_composer_js_1.Composer {
2188
2307
  * @param chatId The identifier of a chat. Must be a channel or a supergroup.
2189
2308
  */
2190
2309
  async disableJoinRequests(chatId) {
2191
- await __classPrivateFieldGet(this, _Client_chatManager, "f").disableJoinRequests(chatId);
2310
+ await this.#chatManager.disableJoinRequests(chatId);
2192
2311
  }
2193
2312
  /**
2194
2313
  * Get inactive chats. User-only.
@@ -2197,7 +2316,7 @@ class Client extends _5_composer_js_1.Composer {
2197
2316
  * @retuns A list of inactive chats the current user is member of.
2198
2317
  */
2199
2318
  async getInactiveChats() {
2200
- return await __classPrivateFieldGet(this, _Client_accountManager, "f").getInactiveChats();
2319
+ return await this.#accountManager.getInactiveChats();
2201
2320
  }
2202
2321
  /**
2203
2322
  * Get the invite links created for a chat. User-only.
@@ -2207,7 +2326,7 @@ class Client extends _5_composer_js_1.Composer {
2207
2326
  * @returns The invite links created for the chat. This might be a subset of the results if they were less than `limit`. The parameters `afterDate` and `afterInviteLink` can be used for pagination.
2208
2327
  */
2209
2328
  async getCreatedInviteLinks(chatId, params) {
2210
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").getCreatedInviteLinks(chatId, params);
2329
+ return await this.#chatManager.getCreatedInviteLinks(chatId, params);
2211
2330
  }
2212
2331
  /**
2213
2332
  * Join a chat. User-only.
@@ -2216,7 +2335,7 @@ class Client extends _5_composer_js_1.Composer {
2216
2335
  * @param chatId The identifier of a chat.
2217
2336
  */
2218
2337
  async joinChat(chatId) {
2219
- await __classPrivateFieldGet(this, _Client_chatManager, "f").joinChat(chatId);
2338
+ await this.#chatManager.joinChat(chatId);
2220
2339
  }
2221
2340
  /**
2222
2341
  * Leave a chat.
@@ -2225,7 +2344,7 @@ class Client extends _5_composer_js_1.Composer {
2225
2344
  * @param chatId The identifier of a chat.
2226
2345
  */
2227
2346
  async leaveChat(chatId) {
2228
- await __classPrivateFieldGet(this, _Client_chatManager, "f").leaveChat(chatId);
2347
+ await this.#chatManager.leaveChat(chatId);
2229
2348
  }
2230
2349
  /**
2231
2350
  * Get information on a user's chat membership.
@@ -2235,7 +2354,7 @@ class Client extends _5_composer_js_1.Composer {
2235
2354
  * @param userId The identifier of the user.
2236
2355
  */
2237
2356
  async getChatMember(chatId, userId) {
2238
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChatMember(chatId, userId);
2357
+ return await this.#chatListManager.getChatMember(chatId, userId);
2239
2358
  }
2240
2359
  /**
2241
2360
  * Get the members of a chat.
@@ -2244,7 +2363,7 @@ class Client extends _5_composer_js_1.Composer {
2244
2363
  * @param chatId The identifier of a chat.
2245
2364
  */
2246
2365
  async getChatMembers(chatId, params) {
2247
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChatMembers(chatId, params);
2366
+ return await this.#chatListManager.getChatMembers(chatId, params);
2248
2367
  }
2249
2368
  /**
2250
2369
  * Set a chat's sticker set.
@@ -2254,7 +2373,7 @@ class Client extends _5_composer_js_1.Composer {
2254
2373
  * @param setName The name of the set.
2255
2374
  */
2256
2375
  async setChatStickerSet(chatId, setName) {
2257
- await __classPrivateFieldGet(this, _Client_messageManager, "f").setChatStickerSet(chatId, setName);
2376
+ await this.#messageManager.setChatStickerSet(chatId, setName);
2258
2377
  }
2259
2378
  /**
2260
2379
  * Delete a chat's sticker set.
@@ -2263,7 +2382,7 @@ class Client extends _5_composer_js_1.Composer {
2263
2382
  * @param chatId The identifier of a chat. Must be a supergroup.
2264
2383
  */
2265
2384
  async deleteChatStickerSet(chatId) {
2266
- await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteChatStickerSet(chatId);
2385
+ await this.#messageManager.deleteChatStickerSet(chatId);
2267
2386
  }
2268
2387
  /**
2269
2388
  * Set the number of boosts required to circument a chat's default restrictions. User-only.
@@ -2273,7 +2392,7 @@ class Client extends _5_composer_js_1.Composer {
2273
2392
  * @param boosts The number of boosts required to circumvent its restrictions.
2274
2393
  */
2275
2394
  async setBoostsRequiredToCircumventRestrictions(chatId, boosts) {
2276
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setBoostsRequiredToCircumventRestrictions(chatId, boosts);
2395
+ await this.#chatManager.setBoostsRequiredToCircumventRestrictions(chatId, boosts);
2277
2396
  }
2278
2397
  /**
2279
2398
  * Create an invite link.
@@ -2283,7 +2402,7 @@ class Client extends _5_composer_js_1.Composer {
2283
2402
  * @returns The newly created invite link.
2284
2403
  */
2285
2404
  async createInviteLink(chatId, params) {
2286
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").createInviteLink(chatId, params);
2405
+ return await this.#chatManager.createInviteLink(chatId, params);
2287
2406
  }
2288
2407
  /**
2289
2408
  * Approve a join request.
@@ -2293,7 +2412,7 @@ class Client extends _5_composer_js_1.Composer {
2293
2412
  * @param userId The user who made the join request.
2294
2413
  */
2295
2414
  async approveJoinRequest(chatId, userId) {
2296
- await __classPrivateFieldGet(this, _Client_chatManager, "f").approveJoinRequest(chatId, userId);
2415
+ await this.#chatManager.approveJoinRequest(chatId, userId);
2297
2416
  }
2298
2417
  /**
2299
2418
  * Decline a join request.
@@ -2303,7 +2422,7 @@ class Client extends _5_composer_js_1.Composer {
2303
2422
  * @param userId The user who made the join request.
2304
2423
  */
2305
2424
  async declineJoinRequest(chatId, userId) {
2306
- await __classPrivateFieldGet(this, _Client_chatManager, "f").declineJoinRequest(chatId, userId);
2425
+ await this.#chatManager.declineJoinRequest(chatId, userId);
2307
2426
  }
2308
2427
  /**
2309
2428
  * Approve all join requests. User-only.
@@ -2312,7 +2431,7 @@ class Client extends _5_composer_js_1.Composer {
2312
2431
  * @param chatId The identifier of a chat with the join requests.
2313
2432
  */
2314
2433
  async approveJoinRequests(chatId, params) {
2315
- await __classPrivateFieldGet(this, _Client_chatManager, "f").approveJoinRequests(chatId, params);
2434
+ await this.#chatManager.approveJoinRequests(chatId, params);
2316
2435
  }
2317
2436
  /**
2318
2437
  * Decline all join requests. User-only.
@@ -2321,7 +2440,7 @@ class Client extends _5_composer_js_1.Composer {
2321
2440
  * @param chatId The identifier of a chat with the join requests.
2322
2441
  */
2323
2442
  async declineJoinRequests(chatId, params) {
2324
- await __classPrivateFieldGet(this, _Client_chatManager, "f").declineJoinRequests(chatId, params);
2443
+ await this.#chatManager.declineJoinRequests(chatId, params);
2325
2444
  }
2326
2445
  /**
2327
2446
  * Get pending join requests in a chat. User-only.
@@ -2330,7 +2449,7 @@ class Client extends _5_composer_js_1.Composer {
2330
2449
  * @param chatId The identifier of a chat with the join requests.
2331
2450
  */
2332
2451
  async getJoinRequests(chatId, params) {
2333
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").getJoinRequests(chatId, params);
2452
+ return await this.#chatManager.getJoinRequests(chatId, params);
2334
2453
  }
2335
2454
  /**
2336
2455
  * Add a single user to a chat.
@@ -2341,7 +2460,7 @@ class Client extends _5_composer_js_1.Composer {
2341
2460
  * @returns An array of FailedInvitation that has at most a length of 1. If empty, it means that the user was added.
2342
2461
  */
2343
2462
  async addChatMember(chatId, userId, params) {
2344
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").addChatMember(chatId, userId, params);
2463
+ return await this.#chatManager.addChatMember(chatId, userId, params);
2345
2464
  }
2346
2465
  /**
2347
2466
  * Add multiple users at once to a channel or a supergroup.
@@ -2352,7 +2471,7 @@ class Client extends _5_composer_js_1.Composer {
2352
2471
  * @returns An array of FailedInvitation that has at most a length that is the same as that of the parameter userIds. If empty, it means that all the provided users were added.
2353
2472
  */
2354
2473
  async addChatMembers(chatId, userIds) {
2355
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").addChatMembers(chatId, userIds);
2474
+ return await this.#chatManager.addChatMembers(chatId, userIds);
2356
2475
  }
2357
2476
  /**
2358
2477
  * Open a chat.
@@ -2361,7 +2480,7 @@ class Client extends _5_composer_js_1.Composer {
2361
2480
  * @param chatId The identifier of a chat to open.
2362
2481
  */
2363
2482
  async openChat(chatId, params) {
2364
- await __classPrivateFieldGet(this, _Client_updateManager, "f").openChat(chatId, params);
2483
+ await this.#updateManager.openChat(chatId, params);
2365
2484
  }
2366
2485
  /**
2367
2486
  * Close a chat previously opened by openChat.
@@ -2370,7 +2489,7 @@ class Client extends _5_composer_js_1.Composer {
2370
2489
  * @param chatId The identifier of a chat to close.
2371
2490
  */
2372
2491
  async closeChat(chatId) {
2373
- await __classPrivateFieldGet(this, _Client_updateManager, "f").closeChat(chatId);
2492
+ await this.#updateManager.closeChat(chatId);
2374
2493
  }
2375
2494
  /**
2376
2495
  * Create a group. User-only.
@@ -2380,7 +2499,7 @@ class Client extends _5_composer_js_1.Composer {
2380
2499
  * @returns The created group.
2381
2500
  */
2382
2501
  async createGroup(title, params) {
2383
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").createGroup(title, params);
2502
+ return await this.#chatListManager.createGroup(title, params);
2384
2503
  }
2385
2504
  /**
2386
2505
  * Create a supergroup. User-only.
@@ -2390,7 +2509,7 @@ class Client extends _5_composer_js_1.Composer {
2390
2509
  * @returns The created supergroup.
2391
2510
  */
2392
2511
  async createSupergroup(title, params) {
2393
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").createSupergroup(title, params);
2512
+ return await this.#chatListManager.createSupergroup(title, params);
2394
2513
  }
2395
2514
  /**
2396
2515
  * Create a channel. User-only.
@@ -2400,7 +2519,7 @@ class Client extends _5_composer_js_1.Composer {
2400
2519
  * @returns The created channel.
2401
2520
  */
2402
2521
  async createChannel(title, params) {
2403
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").createChannel(title, params);
2522
+ return await this.#chatListManager.createChannel(title, params);
2404
2523
  }
2405
2524
  /**
2406
2525
  * Set the time to live of the messages of a chat. User-only.
@@ -2410,7 +2529,7 @@ class Client extends _5_composer_js_1.Composer {
2410
2529
  * @param messageTtl The time to live of the messages in seconds.
2411
2530
  */
2412
2531
  async setMessageTtl(chatId, messageTtl) {
2413
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").setMessageTtl(chatId, messageTtl);
2532
+ await this.#chatListManager.setMessageTtl(chatId, messageTtl);
2414
2533
  }
2415
2534
  /**
2416
2535
  * Archive multiple chats. User-only.
@@ -2419,7 +2538,7 @@ class Client extends _5_composer_js_1.Composer {
2419
2538
  * @param chatIds The identifiers of the chats to archive.
2420
2539
  */
2421
2540
  async archiveChats(chatIds) {
2422
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").archiveChats(chatIds);
2541
+ await this.#chatListManager.archiveChats(chatIds);
2423
2542
  }
2424
2543
  /**
2425
2544
  * Archive a single chat. User-only.
@@ -2428,7 +2547,7 @@ class Client extends _5_composer_js_1.Composer {
2428
2547
  * @param chatId The identifier of a chat.
2429
2548
  */
2430
2549
  async archiveChat(chatId) {
2431
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").archiveChat(chatId);
2550
+ await this.#chatListManager.archiveChat(chatId);
2432
2551
  }
2433
2552
  /**
2434
2553
  * Unarchive multiple chats. User-only.
@@ -2437,7 +2556,7 @@ class Client extends _5_composer_js_1.Composer {
2437
2556
  * @param chatIds The identifiers of the chats to unarchive.
2438
2557
  */
2439
2558
  async unarchiveChats(chatIds) {
2440
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").unarchiveChats(chatIds);
2559
+ await this.#chatListManager.unarchiveChats(chatIds);
2441
2560
  }
2442
2561
  /**
2443
2562
  * Unarchive a single chat. User-only.
@@ -2446,7 +2565,7 @@ class Client extends _5_composer_js_1.Composer {
2446
2565
  * @param chatId The identifier of a chat.
2447
2566
  */
2448
2567
  async unarchiveChat(chatId) {
2449
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").unarchiveChat(chatId);
2568
+ await this.#chatListManager.unarchiveChat(chatId);
2450
2569
  }
2451
2570
  /**
2452
2571
  * Get common chats between a user and the current one. User-only.
@@ -2455,7 +2574,7 @@ class Client extends _5_composer_js_1.Composer {
2455
2574
  * @param userId The identifier of the user to get the common chats with them.
2456
2575
  */
2457
2576
  async getCommonChats(userId, params) {
2458
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getCommonChats(userId, params);
2577
+ return await this.#chatListManager.getCommonChats(userId, params);
2459
2578
  }
2460
2579
  /**
2461
2580
  * Get the settings of a chat. User-only.
@@ -2464,7 +2583,7 @@ class Client extends _5_composer_js_1.Composer {
2464
2583
  * @param chatId The identifier of a chat.
2465
2584
  */
2466
2585
  async getChatSettings(chatId) {
2467
- return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChatSettings(chatId);
2586
+ return await this.#chatListManager.getChatSettings(chatId);
2468
2587
  }
2469
2588
  /**
2470
2589
  * Disable business bots in a private chat. User-only.
@@ -2473,7 +2592,7 @@ class Client extends _5_composer_js_1.Composer {
2473
2592
  * @param chatId The identifier of the private chat to disable business bots in.
2474
2593
  */
2475
2594
  async disableBusinessBots(chatId) {
2476
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").disableBusinessBots(chatId);
2595
+ await this.#chatListManager.disableBusinessBots(chatId);
2477
2596
  }
2478
2597
  /**
2479
2598
  * Enable business bots in a private chat. User-only.
@@ -2482,7 +2601,7 @@ class Client extends _5_composer_js_1.Composer {
2482
2601
  * @param chatId The identifier of the private chat to enable business bots in.
2483
2602
  */
2484
2603
  async enableBusinessBots(chatId) {
2485
- await __classPrivateFieldGet(this, _Client_chatListManager, "f").enableBusinessBots(chatId);
2604
+ await this.#chatListManager.enableBusinessBots(chatId);
2486
2605
  }
2487
2606
  /**
2488
2607
  * Disable slow mode in a group. User-only.
@@ -2491,7 +2610,7 @@ class Client extends _5_composer_js_1.Composer {
2491
2610
  * @param chatId The identifier of the group to disable slow mode in.
2492
2611
  */
2493
2612
  async disableSlowMode(chatId) {
2494
- await __classPrivateFieldGet(this, _Client_chatManager, "f").disableSlowMode(chatId);
2613
+ await this.#chatManager.disableSlowMode(chatId);
2495
2614
  }
2496
2615
  /**
2497
2616
  * Change slow mode in a group. User-only.
@@ -2501,7 +2620,7 @@ class Client extends _5_composer_js_1.Composer {
2501
2620
  * @param duration New slow mode duration.
2502
2621
  */
2503
2622
  async setSlowMode(chatId, duration) {
2504
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setSlowMode(chatId, duration);
2623
+ await this.#chatManager.setSlowMode(chatId, duration);
2505
2624
  }
2506
2625
  /**
2507
2626
  * Change the title of a chat.
@@ -2511,7 +2630,7 @@ class Client extends _5_composer_js_1.Composer {
2511
2630
  * @param title The new title.
2512
2631
  */
2513
2632
  async setChatTitle(chatId, title) {
2514
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setChatTitle(chatId, title);
2633
+ await this.#chatManager.setChatTitle(chatId, title);
2515
2634
  }
2516
2635
  /**
2517
2636
  * Change the description of a chat.
@@ -2521,7 +2640,7 @@ class Client extends _5_composer_js_1.Composer {
2521
2640
  * @param description The new description.
2522
2641
  */
2523
2642
  async setChatDescription(chatId, description) {
2524
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setChatDescription(chatId, description);
2643
+ await this.#chatManager.setChatDescription(chatId, description);
2525
2644
  }
2526
2645
  /**
2527
2646
  * Hide the member list of a group to non-admins. User-only.
@@ -2530,7 +2649,7 @@ class Client extends _5_composer_js_1.Composer {
2530
2649
  * @param chatId The identifier of the group.
2531
2650
  */
2532
2651
  async hideMemberList(chatId) {
2533
- await __classPrivateFieldGet(this, _Client_chatManager, "f").hideMemberList(chatId);
2652
+ await this.#chatManager.hideMemberList(chatId);
2534
2653
  }
2535
2654
  /**
2536
2655
  * Show the member list of a group to non-admins. User-only.
@@ -2539,7 +2658,7 @@ class Client extends _5_composer_js_1.Composer {
2539
2658
  * @param chatId The identifier of the group.
2540
2659
  */
2541
2660
  async showMemberList(chatId) {
2542
- await __classPrivateFieldGet(this, _Client_chatManager, "f").showMemberList(chatId);
2661
+ await this.#chatManager.showMemberList(chatId);
2543
2662
  }
2544
2663
  /**
2545
2664
  * Enable topics in a group. User-only.
@@ -2549,7 +2668,7 @@ class Client extends _5_composer_js_1.Composer {
2549
2668
  * @param isShownAsTabs Whether topics should be displayed as tabs.
2550
2669
  */
2551
2670
  async enableTopics(chatId, isShownAsTabs) {
2552
- await __classPrivateFieldGet(this, _Client_chatManager, "f").enableTopics(chatId, isShownAsTabs);
2671
+ await this.#chatManager.enableTopics(chatId, isShownAsTabs);
2553
2672
  }
2554
2673
  /**
2555
2674
  * Disable topics in a group. User-only.
@@ -2558,7 +2677,7 @@ class Client extends _5_composer_js_1.Composer {
2558
2677
  * @param chatId The identifier of the group.
2559
2678
  */
2560
2679
  async disableTopics(chatId) {
2561
- await __classPrivateFieldGet(this, _Client_chatManager, "f").disableTopics(chatId);
2680
+ await this.#chatManager.disableTopics(chatId);
2562
2681
  }
2563
2682
  /**
2564
2683
  * Enable automatic anti-spam in a group. User-only.
@@ -2567,7 +2686,7 @@ class Client extends _5_composer_js_1.Composer {
2567
2686
  * @param chatId The identifier of the group.
2568
2687
  */
2569
2688
  async enableAntispam(chatId) {
2570
- await __classPrivateFieldGet(this, _Client_chatManager, "f").enableAntispam(chatId);
2689
+ await this.#chatManager.enableAntispam(chatId);
2571
2690
  }
2572
2691
  /**
2573
2692
  * Disable automatic anti-spam in a group. User-only.
@@ -2576,7 +2695,7 @@ class Client extends _5_composer_js_1.Composer {
2576
2695
  * @param chatId The identifier of the group.
2577
2696
  */
2578
2697
  async disableAntispam(chatId) {
2579
- await __classPrivateFieldGet(this, _Client_chatManager, "f").disableAntispam(chatId);
2698
+ await this.#chatManager.disableAntispam(chatId);
2580
2699
  }
2581
2700
  /**
2582
2701
  * Enable post signatures in a channel. User-only.
@@ -2585,7 +2704,7 @@ class Client extends _5_composer_js_1.Composer {
2585
2704
  * @param chatId The identifier of the channel.
2586
2705
  */
2587
2706
  async enableSignatures(chatId, params) {
2588
- await __classPrivateFieldGet(this, _Client_chatManager, "f").enableSignatures(chatId, params);
2707
+ await this.#chatManager.enableSignatures(chatId, params);
2589
2708
  }
2590
2709
  /**
2591
2710
  * Disable post signatures in a channel. User-only.
@@ -2594,7 +2713,7 @@ class Client extends _5_composer_js_1.Composer {
2594
2713
  * @param chatId The identifier of the channel.
2595
2714
  */
2596
2715
  async disableSignatures(chatId) {
2597
- await __classPrivateFieldGet(this, _Client_chatManager, "f").disableSignatures(chatId);
2716
+ await this.#chatManager.disableSignatures(chatId);
2598
2717
  }
2599
2718
  /**
2600
2719
  * Delete a chat. User-only.
@@ -2603,7 +2722,7 @@ class Client extends _5_composer_js_1.Composer {
2603
2722
  * @param chatId The identifier of a chat.
2604
2723
  */
2605
2724
  async deleteChat(chatId) {
2606
- await __classPrivateFieldGet(this, _Client_chatManager, "f").deleteChat(chatId);
2725
+ await this.#chatManager.deleteChat(chatId);
2607
2726
  }
2608
2727
  /**
2609
2728
  * Get discussion chat suggestions. User-only.
@@ -2611,7 +2730,7 @@ class Client extends _5_composer_js_1.Composer {
2611
2730
  * @method ch
2612
2731
  */
2613
2732
  async getDiscussionChatSuggestions() {
2614
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").getDiscussionChatSuggestions();
2733
+ return await this.#chatManager.getDiscussionChatSuggestions();
2615
2734
  }
2616
2735
  /**
2617
2736
  * Set a channel's discussion chat. User-only.
@@ -2621,7 +2740,7 @@ class Client extends _5_composer_js_1.Composer {
2621
2740
  * @param discussionChatId The identifier of a chat to use as discussion for the channel.
2622
2741
  */
2623
2742
  async setDiscussionChat(chatId, discussionChatId) {
2624
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setDiscussionChat(chatId, discussionChatId);
2743
+ await this.#chatManager.setDiscussionChat(chatId, discussionChatId);
2625
2744
  }
2626
2745
  /**
2627
2746
  * Transfer the ownership of a chat. User-only.
@@ -2632,7 +2751,7 @@ class Client extends _5_composer_js_1.Composer {
2632
2751
  * @param password The password of the current account.
2633
2752
  */
2634
2753
  async transferChatOwnership(chatId, userId, password) {
2635
- await __classPrivateFieldGet(this, _Client_chatManager, "f").transferChatOwnership(chatId, userId, password);
2754
+ await this.#chatManager.transferChatOwnership(chatId, userId, password);
2636
2755
  }
2637
2756
  /**
2638
2757
  * Create a forum topic.
@@ -2643,7 +2762,7 @@ class Client extends _5_composer_js_1.Composer {
2643
2762
  * @returns The created topic.
2644
2763
  */
2645
2764
  async createTopic(chatId, title, params) {
2646
- return await __classPrivateFieldGet(this, _Client_forumManager, "f").createTopic(chatId, title, params);
2765
+ return await this.#forumManager.createTopic(chatId, title, params);
2647
2766
  }
2648
2767
  /**
2649
2768
  * Edit a forum topic.
@@ -2655,7 +2774,7 @@ class Client extends _5_composer_js_1.Composer {
2655
2774
  * @returns The new topic.
2656
2775
  */
2657
2776
  async editTopic(chatId, topicId, title, params) {
2658
- return await __classPrivateFieldGet(this, _Client_forumManager, "f").editTopic(chatId, topicId, title, params);
2777
+ return await this.#forumManager.editTopic(chatId, topicId, title, params);
2659
2778
  }
2660
2779
  /**
2661
2780
  * Hide the general forum topic.
@@ -2664,7 +2783,7 @@ class Client extends _5_composer_js_1.Composer {
2664
2783
  * @param chatId The identifier of a chat.
2665
2784
  */
2666
2785
  async hideGeneralTopic(chatId) {
2667
- await __classPrivateFieldGet(this, _Client_forumManager, "f").hideGeneralTopic(chatId);
2786
+ await this.#forumManager.hideGeneralTopic(chatId);
2668
2787
  }
2669
2788
  /**
2670
2789
  * Show the general forum topic.
@@ -2673,7 +2792,7 @@ class Client extends _5_composer_js_1.Composer {
2673
2792
  * @param chatId The identifier of a chat.
2674
2793
  */
2675
2794
  async showGeneralTopic(chatId) {
2676
- await __classPrivateFieldGet(this, _Client_forumManager, "f").showGeneralTopic(chatId);
2795
+ await this.#forumManager.showGeneralTopic(chatId);
2677
2796
  }
2678
2797
  /**
2679
2798
  * Close a forum topic.
@@ -2683,7 +2802,7 @@ class Client extends _5_composer_js_1.Composer {
2683
2802
  * @param topicId The identifier of the topic.
2684
2803
  */
2685
2804
  async closeTopic(chatId, topicId) {
2686
- await __classPrivateFieldGet(this, _Client_forumManager, "f").closeTopic(chatId, topicId);
2805
+ await this.#forumManager.closeTopic(chatId, topicId);
2687
2806
  }
2688
2807
  /**
2689
2808
  * Reopen a forum topic.
@@ -2693,7 +2812,7 @@ class Client extends _5_composer_js_1.Composer {
2693
2812
  * @param topicId The identifier of the topic.
2694
2813
  */
2695
2814
  async reopenTopic(chatId, topicId) {
2696
- await __classPrivateFieldGet(this, _Client_forumManager, "f").reopenTopic(chatId, topicId);
2815
+ await this.#forumManager.reopenTopic(chatId, topicId);
2697
2816
  }
2698
2817
  /**
2699
2818
  * Pin a forum topic.
@@ -2703,7 +2822,7 @@ class Client extends _5_composer_js_1.Composer {
2703
2822
  * @param topicId The identifier of the topic.
2704
2823
  */
2705
2824
  async pinTopic(chatId, topicId) {
2706
- await __classPrivateFieldGet(this, _Client_forumManager, "f").pinTopic(chatId, topicId);
2825
+ await this.#forumManager.pinTopic(chatId, topicId);
2707
2826
  }
2708
2827
  /**
2709
2828
  * Unpin a forum topic.
@@ -2713,7 +2832,7 @@ class Client extends _5_composer_js_1.Composer {
2713
2832
  * @param topicId The identifier of the topic.
2714
2833
  */
2715
2834
  async unpinTopic(chatId, topicId) {
2716
- await __classPrivateFieldGet(this, _Client_forumManager, "f").unpinTopic(chatId, topicId);
2835
+ await this.#forumManager.unpinTopic(chatId, topicId);
2717
2836
  }
2718
2837
  /**
2719
2838
  * Promote a chat member.
@@ -2723,7 +2842,7 @@ class Client extends _5_composer_js_1.Composer {
2723
2842
  * @param userId The identifier of the user to promote.
2724
2843
  */
2725
2844
  async promoteChatMember(chatId, userId, params) {
2726
- await __classPrivateFieldGet(this, _Client_chatManager, "f").promoteChatMember(chatId, userId, params);
2845
+ await this.#chatManager.promoteChatMember(chatId, userId, params);
2727
2846
  }
2728
2847
  /**
2729
2848
  * Change the tag of a chat member.
@@ -2733,7 +2852,7 @@ class Client extends _5_composer_js_1.Composer {
2733
2852
  * @param userId The identifier of the user that is a member of the chat.
2734
2853
  */
2735
2854
  async setChatMemberTag(chatId, userId, params) {
2736
- await __classPrivateFieldGet(this, _Client_chatManager, "f").setChatMemberTag(chatId, userId, params);
2855
+ await this.#chatManager.setChatMemberTag(chatId, userId, params);
2737
2856
  }
2738
2857
  /**
2739
2858
  * Enable sharing in a chat. User-only.
@@ -2742,7 +2861,7 @@ class Client extends _5_composer_js_1.Composer {
2742
2861
  * @param chatId The identifier of a chat.
2743
2862
  */
2744
2863
  async enableSharing(chatId) {
2745
- await __classPrivateFieldGet(this, _Client_chatManager, "f").enableSharing(chatId);
2864
+ await this.#chatManager.enableSharing(chatId);
2746
2865
  }
2747
2866
  /**
2748
2867
  * Disable sharing in a chat. User-only.
@@ -2751,7 +2870,7 @@ class Client extends _5_composer_js_1.Composer {
2751
2870
  * @param chatId The identifier of a chat.
2752
2871
  */
2753
2872
  async disableSharing(chatId) {
2754
- await __classPrivateFieldGet(this, _Client_chatManager, "f").disableSharing(chatId);
2873
+ await this.#chatManager.disableSharing(chatId);
2755
2874
  }
2756
2875
  /**
2757
2876
  * Get recommended channels. User-only.
@@ -2760,7 +2879,7 @@ class Client extends _5_composer_js_1.Composer {
2760
2879
  * @returns A list of recommended channels.
2761
2880
  */
2762
2881
  async getRecommendedChannels() {
2763
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").getRecommendedChannels();
2882
+ return await this.#chatManager.getRecommendedChannels();
2764
2883
  }
2765
2884
  /**
2766
2885
  * Get similar channels. User-only.
@@ -2770,7 +2889,7 @@ class Client extends _5_composer_js_1.Composer {
2770
2889
  * @returns A list of similar channels.
2771
2890
  */
2772
2891
  async getSimilarChannels(chatId) {
2773
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").getSimilarChannels(chatId);
2892
+ return await this.#chatManager.getSimilarChannels(chatId);
2774
2893
  }
2775
2894
  /**
2776
2895
  * Get similar bots. User-only.
@@ -2780,7 +2899,7 @@ class Client extends _5_composer_js_1.Composer {
2780
2899
  * @returns A list of similar bots.
2781
2900
  */
2782
2901
  async getSimilarBots(chatId) {
2783
- return await __classPrivateFieldGet(this, _Client_chatManager, "f").getSimilarBots(chatId);
2902
+ return await this.#chatManager.getSimilarBots(chatId);
2784
2903
  }
2785
2904
  //
2786
2905
  // ========================= CALLBACK QUERIES ========================= //
@@ -2796,7 +2915,7 @@ class Client extends _5_composer_js_1.Composer {
2796
2915
  * @cache
2797
2916
  */
2798
2917
  async sendCallbackQuery(botId, messageId, question) {
2799
- return await __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").sendCallbackQuery(botId, messageId, question);
2918
+ return await this.#callbackQueryManager.sendCallbackQuery(botId, messageId, question);
2800
2919
  }
2801
2920
  /**
2802
2921
  * Answer a callback query. Bot-only.
@@ -2805,7 +2924,7 @@ class Client extends _5_composer_js_1.Composer {
2805
2924
  * @param id ID of the callback query to answer.
2806
2925
  */
2807
2926
  async answerCallbackQuery(id, params) {
2808
- await __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").answerCallbackQuery(id, params);
2927
+ await this.#callbackQueryManager.answerCallbackQuery(id, params);
2809
2928
  }
2810
2929
  //
2811
2930
  // ========================= INLINE QUERIES ========================= //
@@ -2820,7 +2939,7 @@ class Client extends _5_composer_js_1.Composer {
2820
2939
  * @cache
2821
2940
  */
2822
2941
  async sendInlineQuery(botId, chatId, params) {
2823
- return await __classPrivateFieldGet(this, _Client_inlineQueryManager, "f").sendInlineQuery(botId, chatId, params);
2942
+ return await this.#inlineQueryManager.sendInlineQuery(botId, chatId, params);
2824
2943
  }
2825
2944
  /**
2826
2945
  * Answer an inline query. Bot-only.
@@ -2830,7 +2949,7 @@ class Client extends _5_composer_js_1.Composer {
2830
2949
  * @param results The results to answer with.
2831
2950
  */
2832
2951
  async answerInlineQuery(id, results, params) {
2833
- await __classPrivateFieldGet(this, _Client_inlineQueryManager, "f").answerInlineQuery(id, results, params);
2952
+ await this.#inlineQueryManager.answerInlineQuery(id, results, params);
2834
2953
  }
2835
2954
  //
2836
2955
  // ========================= BOTS ========================= //
@@ -2841,7 +2960,7 @@ class Client extends _5_composer_js_1.Composer {
2841
2960
  * @method bs
2842
2961
  */
2843
2962
  async setMyDescription(params) {
2844
- await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyDescription(params);
2963
+ await this.#botInfoManager.setMyDescription(params);
2845
2964
  }
2846
2965
  /**
2847
2966
  * Set the bot's name in the given language. Bot-only.
@@ -2849,7 +2968,7 @@ class Client extends _5_composer_js_1.Composer {
2849
2968
  * @method bs
2850
2969
  */
2851
2970
  async setMyName(params) {
2852
- await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyName(params);
2971
+ await this.#botInfoManager.setMyName(params);
2853
2972
  }
2854
2973
  /**
2855
2974
  * Set the bot's short description in the given language. Bot-only.
@@ -2857,7 +2976,7 @@ class Client extends _5_composer_js_1.Composer {
2857
2976
  * @method bs
2858
2977
  */
2859
2978
  async setMyShortDescription(params) {
2860
- await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyShortDescription(params);
2979
+ await this.#botInfoManager.setMyShortDescription(params);
2861
2980
  }
2862
2981
  /**
2863
2982
  * Get the bot's description in the given language. Bot-only.
@@ -2866,7 +2985,7 @@ class Client extends _5_composer_js_1.Composer {
2866
2985
  * @returns The current bot's description in the specified language.
2867
2986
  */
2868
2987
  async getMyDescription(params) {
2869
- return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyDescription(params);
2988
+ return await this.#botInfoManager.getMyDescription(params);
2870
2989
  }
2871
2990
  /**
2872
2991
  * Get the bot's name in the given language. Bot-only.
@@ -2875,7 +2994,7 @@ class Client extends _5_composer_js_1.Composer {
2875
2994
  * @returns The current bot's name in the specified language.
2876
2995
  */
2877
2996
  async getMyName(params) {
2878
- return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyName(params);
2997
+ return await this.#botInfoManager.getMyName(params);
2879
2998
  }
2880
2999
  /**
2881
3000
  * Get the bot's short description in the given language. Bot-only.
@@ -2884,7 +3003,7 @@ class Client extends _5_composer_js_1.Composer {
2884
3003
  * @returns The current bot's short description in the specified language.
2885
3004
  */
2886
3005
  async getMyShortDescription(params) {
2887
- return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyShortDescription(params);
3006
+ return await this.#botInfoManager.getMyShortDescription(params);
2888
3007
  }
2889
3008
  /**
2890
3009
  * Set the bot's commands in the given scope and/or language. Bot-only.
@@ -2893,7 +3012,7 @@ class Client extends _5_composer_js_1.Composer {
2893
3012
  * @param commands The commands to set.
2894
3013
  */
2895
3014
  async setMyCommands(commands, params) {
2896
- await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyCommands(commands, params);
3015
+ await this.#botInfoManager.setMyCommands(commands, params);
2897
3016
  }
2898
3017
  /**
2899
3018
  * Get the bot's commands in the given scope and/or language. Bot-only.
@@ -2902,7 +3021,7 @@ class Client extends _5_composer_js_1.Composer {
2902
3021
  * @returns The current bot's commands in the specified language.
2903
3022
  */
2904
3023
  async getMyCommands(params) {
2905
- return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyCommands(params);
3024
+ return await this.#botInfoManager.getMyCommands(params);
2906
3025
  }
2907
3026
  //
2908
3027
  // ========================= REACTIONS ========================= //
@@ -2916,7 +3035,7 @@ class Client extends _5_composer_js_1.Composer {
2916
3035
  * @param reactions The new reactions.
2917
3036
  */
2918
3037
  async setReactions(chatId, messageId, reactions, params) {
2919
- await __classPrivateFieldGet(this, _Client_messageManager, "f").setReactions(chatId, messageId, reactions, params);
3038
+ await this.#messageManager.setReactions(chatId, messageId, reactions, params);
2920
3039
  }
2921
3040
  /**
2922
3041
  * Make a reaction to a message.
@@ -2927,7 +3046,7 @@ class Client extends _5_composer_js_1.Composer {
2927
3046
  * @param reaction The reaction to add.
2928
3047
  */
2929
3048
  async addReaction(chatId, messageId, reaction, params) {
2930
- await __classPrivateFieldGet(this, _Client_messageManager, "f").addReaction(chatId, messageId, reaction, params);
3049
+ await this.#messageManager.addReaction(chatId, messageId, reaction, params);
2931
3050
  }
2932
3051
  /**
2933
3052
  * Undo a reaction made to a message.
@@ -2938,7 +3057,7 @@ class Client extends _5_composer_js_1.Composer {
2938
3057
  * @param reaction The reaction to remove.
2939
3058
  */
2940
3059
  async removeReaction(chatId, messageId, reaction) {
2941
- await __classPrivateFieldGet(this, _Client_messageManager, "f").removeReaction(chatId, messageId, reaction);
3060
+ await this.#messageManager.removeReaction(chatId, messageId, reaction);
2942
3061
  }
2943
3062
  //
2944
3063
  // ========================= STORIES ========================= //
@@ -2951,7 +3070,7 @@ class Client extends _5_composer_js_1.Composer {
2951
3070
  * @returns The created story.
2952
3071
  */
2953
3072
  async createStory(chatId, content, params) {
2954
- return await __classPrivateFieldGet(this, _Client_storyManager, "f").createStory(chatId, content, params);
3073
+ return await this.#storyManager.createStory(chatId, content, params);
2955
3074
  }
2956
3075
  /**
2957
3076
  * Retrieve multiple stories. User-only.
@@ -2965,7 +3084,7 @@ class Client extends _5_composer_js_1.Composer {
2965
3084
  if (!storyIds.length) {
2966
3085
  return [];
2967
3086
  }
2968
- return await __classPrivateFieldGet(this, _Client_storyManager, "f").getStories(chatId, storyIds);
3087
+ return await this.#storyManager.getStories(chatId, storyIds);
2969
3088
  }
2970
3089
  /**
2971
3090
  * Retrieve a single story. User-only.
@@ -2976,7 +3095,7 @@ class Client extends _5_composer_js_1.Composer {
2976
3095
  * @returns The retrieved story.
2977
3096
  */
2978
3097
  async getStory(chatId, storyId) {
2979
- return await __classPrivateFieldGet(this, _Client_storyManager, "f").getStory(chatId, storyId);
3098
+ return await this.#storyManager.getStory(chatId, storyId);
2980
3099
  }
2981
3100
  /**
2982
3101
  * Delete multiple stories. User-only.
@@ -2986,7 +3105,7 @@ class Client extends _5_composer_js_1.Composer {
2986
3105
  * @param storyIds The identifiers of the stories to delete.
2987
3106
  */
2988
3107
  async deleteStories(chatId, storyIds) {
2989
- await __classPrivateFieldGet(this, _Client_storyManager, "f").deleteStories(chatId, storyIds);
3108
+ await this.#storyManager.deleteStories(chatId, storyIds);
2990
3109
  }
2991
3110
  /**
2992
3111
  * Delete a single story. User-only.
@@ -2996,7 +3115,7 @@ class Client extends _5_composer_js_1.Composer {
2996
3115
  * @param storyId The identifier of the story to delete.
2997
3116
  */
2998
3117
  async deleteStory(chatId, storyId) {
2999
- await __classPrivateFieldGet(this, _Client_storyManager, "f").deleteStory(chatId, storyId);
3118
+ await this.#storyManager.deleteStory(chatId, storyId);
3000
3119
  }
3001
3120
  /**
3002
3121
  * Add multiple stories to highlights. User-only.
@@ -3006,7 +3125,7 @@ class Client extends _5_composer_js_1.Composer {
3006
3125
  * @param storyIds The identifiers of the stories to add to highlights.
3007
3126
  */
3008
3127
  async addStoriesToHighlights(chatId, storyIds) {
3009
- await __classPrivateFieldGet(this, _Client_storyManager, "f").addStoriesToHighlights(chatId, storyIds);
3128
+ await this.#storyManager.addStoriesToHighlights(chatId, storyIds);
3010
3129
  }
3011
3130
  /**
3012
3131
  * Add a single story to highlights. User-only.
@@ -3016,7 +3135,7 @@ class Client extends _5_composer_js_1.Composer {
3016
3135
  * @param storyId The identifier of the story to add to highlights.
3017
3136
  */
3018
3137
  async addStoryToHighlights(chatId, storyId) {
3019
- await __classPrivateFieldGet(this, _Client_storyManager, "f").addStoryToHighlights(chatId, storyId);
3138
+ await this.#storyManager.addStoryToHighlights(chatId, storyId);
3020
3139
  }
3021
3140
  /**
3022
3141
  * Remove multiple stories from highlights. User-only.
@@ -3026,7 +3145,7 @@ class Client extends _5_composer_js_1.Composer {
3026
3145
  * @param storyIds The identifiers of the stories to remove from highlights.
3027
3146
  */
3028
3147
  async removeStoriesFromHighlights(chatId, storyIds) {
3029
- await __classPrivateFieldGet(this, _Client_storyManager, "f").removeStoriesFromHighlights(chatId, storyIds);
3148
+ await this.#storyManager.removeStoriesFromHighlights(chatId, storyIds);
3030
3149
  }
3031
3150
  /**
3032
3151
  * Remove a single story from highlights. User-only.
@@ -3036,7 +3155,7 @@ class Client extends _5_composer_js_1.Composer {
3036
3155
  * @param storyId The identifier of the story to remove from highlights.
3037
3156
  */
3038
3157
  async removeStoryFromHighlights(chatId, storyId) {
3039
- await __classPrivateFieldGet(this, _Client_storyManager, "f").removeStoryFromHighlights(chatId, storyId);
3158
+ await this.#storyManager.removeStoryFromHighlights(chatId, storyId);
3040
3159
  }
3041
3160
  //
3042
3161
  // ========================= MISC ========================= //
@@ -3047,7 +3166,7 @@ class Client extends _5_composer_js_1.Composer {
3047
3166
  * @method mc
3048
3167
  */
3049
3168
  async getNetworkStatistics() {
3050
- return await __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f").getNetworkStatistics();
3169
+ return await this.#networkStatisticsManager.getNetworkStatistics();
3051
3170
  }
3052
3171
  /**
3053
3172
  * Block a user. User-only.
@@ -3056,7 +3175,7 @@ class Client extends _5_composer_js_1.Composer {
3056
3175
  * @param userId The identifier of the user to block.
3057
3176
  */
3058
3177
  async blockUser(userId) {
3059
- await __classPrivateFieldGet(this, _Client_messageManager, "f").blockUser(userId);
3178
+ await this.#messageManager.blockUser(userId);
3060
3179
  }
3061
3180
  /**
3062
3181
  * Unblock a user. User-only.
@@ -3065,7 +3184,7 @@ class Client extends _5_composer_js_1.Composer {
3065
3184
  * @param userId The identifier of the user to unblock.
3066
3185
  */
3067
3186
  async unblockUser(userId) {
3068
- await __classPrivateFieldGet(this, _Client_messageManager, "f").unblockUser(userId);
3187
+ await this.#messageManager.unblockUser(userId);
3069
3188
  }
3070
3189
  //
3071
3190
  // ========================= VIDEO CHATS ========================= //
@@ -3078,7 +3197,7 @@ class Client extends _5_composer_js_1.Composer {
3078
3197
  * @returns The started video chat.
3079
3198
  */
3080
3199
  async startVideoChat(chatId, params) {
3081
- return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").startVideoChat(chatId, params);
3200
+ return await this.#videoChatManager.startVideoChat(chatId, params);
3082
3201
  }
3083
3202
  /**
3084
3203
  * Schedule a video chat. User-only.
@@ -3089,7 +3208,7 @@ class Client extends _5_composer_js_1.Composer {
3089
3208
  * @returns The scheduled video chat.
3090
3209
  */
3091
3210
  async scheduleVideoChat(chatId, startAt, params) {
3092
- return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").scheduleVideoChat(chatId, startAt, params);
3211
+ return await this.#videoChatManager.scheduleVideoChat(chatId, startAt, params);
3093
3212
  }
3094
3213
  /**
3095
3214
  * Join a video chat. User-only.
@@ -3100,7 +3219,7 @@ class Client extends _5_composer_js_1.Composer {
3100
3219
  * @returns Parameters to be passed to the used WebRTC library.
3101
3220
  */
3102
3221
  async joinVideoChat(id, params_, params) {
3103
- return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").joinVideoChat(id, params_, params);
3222
+ return await this.#videoChatManager.joinVideoChat(id, params_, params);
3104
3223
  }
3105
3224
  /**
3106
3225
  * Leave a video chat. User-only.
@@ -3109,7 +3228,7 @@ class Client extends _5_composer_js_1.Composer {
3109
3228
  * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
3110
3229
  */
3111
3230
  async leaveVideoChat(id) {
3112
- await __classPrivateFieldGet(this, _Client_videoChatManager, "f").leaveVideoChat(id);
3231
+ await this.#videoChatManager.leaveVideoChat(id);
3113
3232
  }
3114
3233
  /**
3115
3234
  * Join a live stream. User-only.
@@ -3118,7 +3237,7 @@ class Client extends _5_composer_js_1.Composer {
3118
3237
  * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
3119
3238
  */
3120
3239
  async joinLiveStream(id) {
3121
- await __classPrivateFieldGet(this, _Client_videoChatManager, "f").joinLiveStream(id);
3240
+ await this.#videoChatManager.joinLiveStream(id);
3122
3241
  }
3123
3242
  /**
3124
3243
  * Get a video chat. User-only.
@@ -3128,7 +3247,7 @@ class Client extends _5_composer_js_1.Composer {
3128
3247
  * @cache
3129
3248
  */
3130
3249
  async getVideoChat(id) {
3131
- return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").getVideoChat(id);
3250
+ return await this.#videoChatManager.getVideoChat(id);
3132
3251
  }
3133
3252
  /**
3134
3253
  * Get live stream channels. User-only.
@@ -3137,7 +3256,7 @@ class Client extends _5_composer_js_1.Composer {
3137
3256
  * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
3138
3257
  */
3139
3258
  async getLiveStreamChannels(id) {
3140
- return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").getLiveStreamChannels(id);
3259
+ return await this.#videoChatManager.getLiveStreamChannels(id);
3141
3260
  }
3142
3261
  /**
3143
3262
  * Download a live stream segment. User-only.
@@ -3149,7 +3268,7 @@ class Client extends _5_composer_js_1.Composer {
3149
3268
  * @param timestamp Millisecond timestamp of the chunk to download.
3150
3269
  */
3151
3270
  async downloadLiveStreamSegment(id, channelId, scale, timestamp, params) {
3152
- return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").downloadLiveStreamSegment(id, channelId, scale, timestamp, params);
3271
+ return await this.#videoChatManager.downloadLiveStreamSegment(id, channelId, scale, timestamp, params);
3153
3272
  }
3154
3273
  //
3155
3274
  // ========================= PAYMENTS ========================= //
@@ -3162,7 +3281,7 @@ class Client extends _5_composer_js_1.Composer {
3162
3281
  * @param ok Whether the checkout is going to be processed.
3163
3282
  */
3164
3283
  async answerPreCheckoutQuery(preCheckoutQueryId, ok, params) {
3165
- await __classPrivateFieldGet(this, _Client_paymentManager, "f").answerPreCheckoutQuery(preCheckoutQueryId, ok, params);
3284
+ await this.#paymentManager.answerPreCheckoutQuery(preCheckoutQueryId, ok, params);
3166
3285
  }
3167
3286
  /**
3168
3287
  * Refund a star payment. Bot-only.
@@ -3172,7 +3291,7 @@ class Client extends _5_composer_js_1.Composer {
3172
3291
  * @param telegramPaymentChargeId The identifier of the charge.
3173
3292
  */
3174
3293
  async refundStarPayment(userId, telegramPaymentChargeId) {
3175
- await __classPrivateFieldGet(this, _Client_paymentManager, "f").refundStarPayment(userId, telegramPaymentChargeId);
3294
+ await this.#paymentManager.refundStarPayment(userId, telegramPaymentChargeId);
3176
3295
  }
3177
3296
  //
3178
3297
  // ========================= CONTACTS ========================= //
@@ -3183,7 +3302,7 @@ class Client extends _5_composer_js_1.Composer {
3183
3302
  * @method co
3184
3303
  */
3185
3304
  async getContacts() {
3186
- return await __classPrivateFieldGet(this, _Client_accountManager, "f").getContacts();
3305
+ return await this.#accountManager.getContacts();
3187
3306
  }
3188
3307
  /**
3189
3308
  * Delete multiple contacts. User-only.
@@ -3192,7 +3311,7 @@ class Client extends _5_composer_js_1.Composer {
3192
3311
  * @param userIds The identifiers of contacts to delete.
3193
3312
  */
3194
3313
  async deleteContacts(userIds) {
3195
- await __classPrivateFieldGet(this, _Client_accountManager, "f").deleteContacts(userIds);
3314
+ await this.#accountManager.deleteContacts(userIds);
3196
3315
  }
3197
3316
  /**
3198
3317
  * Delete a single contact. User-only.
@@ -3201,7 +3320,7 @@ class Client extends _5_composer_js_1.Composer {
3201
3320
  * @param userId The identifier of the contact to delete.
3202
3321
  */
3203
3322
  async deleteContact(userId) {
3204
- await __classPrivateFieldGet(this, _Client_accountManager, "f").deleteContact(userId);
3323
+ await this.#accountManager.deleteContact(userId);
3205
3324
  }
3206
3325
  /**
3207
3326
  * Add a contact. User-only.
@@ -3210,7 +3329,7 @@ class Client extends _5_composer_js_1.Composer {
3210
3329
  * @param userId The identifier of the user to add as contact.
3211
3330
  */
3212
3331
  async addContact(userId, params) {
3213
- await __classPrivateFieldGet(this, _Client_accountManager, "f").addContact(userId, params);
3332
+ await this.#accountManager.addContact(userId, params);
3214
3333
  }
3215
3334
  //
3216
3335
  // ========================= TRANSLATIONS ========================= //
@@ -3222,7 +3341,7 @@ class Client extends _5_composer_js_1.Composer {
3222
3341
  * @cache
3223
3342
  */
3224
3343
  async getTranslations(params) {
3225
- return await __classPrivateFieldGet(this, _Client_translationsManager, "f").getTranslations(params);
3344
+ return await this.#translationsManager.getTranslations(params);
3226
3345
  }
3227
3346
  //
3228
3347
  // ========================= GIFTS ========================= //
@@ -3233,7 +3352,7 @@ class Client extends _5_composer_js_1.Composer {
3233
3352
  * @method gf
3234
3353
  */
3235
3354
  async getGifts() {
3236
- return await __classPrivateFieldGet(this, _Client_giftManager, "f").getGifts();
3355
+ return await this.#giftManager.getGifts();
3237
3356
  }
3238
3357
  /**
3239
3358
  * Get gifts claimed by a user or a channel. User-only.
@@ -3242,7 +3361,7 @@ class Client extends _5_composer_js_1.Composer {
3242
3361
  * @param chatId The identifier of a user or a channel to get gifts for.
3243
3362
  */
3244
3363
  async getClaimedGifts(chatId, params) {
3245
- return await __classPrivateFieldGet(this, _Client_giftManager, "f").getClaimedGifts(chatId, params);
3364
+ return await this.#giftManager.getClaimedGifts(chatId, params);
3246
3365
  }
3247
3366
  /**
3248
3367
  * Send a gift.
@@ -3252,7 +3371,7 @@ class Client extends _5_composer_js_1.Composer {
3252
3371
  * @param giftId The identifier of the gift to send.
3253
3372
  */
3254
3373
  async sendGift(chatId, giftId, params) {
3255
- await __classPrivateFieldGet(this, _Client_giftManager, "f").sendGift(chatId, giftId, params);
3374
+ await this.#giftManager.sendGift(chatId, giftId, params);
3256
3375
  }
3257
3376
  /**
3258
3377
  * Sell a gift.
@@ -3261,7 +3380,7 @@ class Client extends _5_composer_js_1.Composer {
3261
3380
  * @param gift The gift to sell.
3262
3381
  */
3263
3382
  async sellGift(gift) {
3264
- await __classPrivateFieldGet(this, _Client_giftManager, "f").sellGift(gift);
3383
+ await this.#giftManager.sellGift(gift);
3265
3384
  }
3266
3385
  /**
3267
3386
  * Craft gifts.
@@ -3270,7 +3389,7 @@ class Client extends _5_composer_js_1.Composer {
3270
3389
  * @param gift The gifts to craft.
3271
3390
  */
3272
3391
  async craftGifts(gifts) {
3273
- await __classPrivateFieldGet(this, _Client_giftManager, "f").craftGifts(gifts);
3392
+ await this.#giftManager.craftGifts(gifts);
3274
3393
  }
3275
3394
  /**
3276
3395
  * Get a gift using its slug.
@@ -3279,7 +3398,7 @@ class Client extends _5_composer_js_1.Composer {
3279
3398
  * @param slug The slug of a gift.
3280
3399
  */
3281
3400
  async getGift(slug) {
3282
- return await __classPrivateFieldGet(this, _Client_giftManager, "f").getGift(slug);
3401
+ return await this.#giftManager.getGift(slug);
3283
3402
  }
3284
3403
  /**
3285
3404
  * Transfer a gift. User-only.
@@ -3289,156 +3408,7 @@ class Client extends _5_composer_js_1.Composer {
3289
3408
  * @param gift The gift to transfer.
3290
3409
  */
3291
3410
  async transferGift(chatId, gift) {
3292
- return await __classPrivateFieldGet(this, _Client_giftManager, "f").transferGift(chatId, gift);
3411
+ return await this.#giftManager.transferGift(chatId, gift);
3293
3412
  }
3294
3413
  }
3295
3414
  exports.Client = Client;
3296
- _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
3297
- if (__classPrivateFieldGet(this, _Client_disableUpdates, "f") && !("authorizationState" in update) && !("connectionState" in update)) {
3298
- return;
3299
- }
3300
- try {
3301
- await this.handleUpdate(this, update);
3302
- }
3303
- catch (err) {
3304
- __classPrivateFieldGet(this, _Client_L, "f").error("Failed to handle update:", err);
3305
- throw err;
3306
- }
3307
- }, _Client_queueHandleCtxUpdate = function _Client_queueHandleCtxUpdate(update) {
3308
- __classPrivateFieldGet(this, _Client_updateManager, "f").getHandleUpdateQueue(_2_update_manager_js_1.UpdateManager.MAIN_BOX_ID).add(async () => {
3309
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, update);
3310
- });
3311
- }, _Client_handleUpdate = async function _Client_handleUpdate(update) {
3312
- const maybePromises = new Array();
3313
- if (_2_tl_js_1.Api.is("updateUserName", update)) {
3314
- const value = [Number(update.user_id), new Date()];
3315
- for (const username_ of update.usernames) {
3316
- const username = username_.username.toLowerCase();
3317
- this.messageStorage.usernames.set([username], value);
3318
- }
3319
- const peer = { ...update, _: "peerUser" };
3320
- const peer_ = await this[getPeer](peer);
3321
- if (peer_ !== null) {
3322
- const username = update.usernames[0];
3323
- if (username !== undefined) {
3324
- peer_[0].username = username.username;
3325
- const also = update.usernames.filter((v) => v !== username);
3326
- if (also.length) {
3327
- peer_[0].also = also.map((v) => v.username);
3328
- }
3329
- else {
3330
- delete peer_[0].also;
3331
- }
3332
- }
3333
- else {
3334
- delete peer_[0].username;
3335
- }
3336
- this.messageStorage.setPeer2(peer_[0], peer_[1]);
3337
- }
3338
- }
3339
- if (__classPrivateFieldGet(this, _Client_messageManager, "f").canHandleUpdate(update)) {
3340
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_messageManager, "f").handleUpdate(update));
3341
- }
3342
- if (__classPrivateFieldGet(this, _Client_chatManager, "f").canHandleUpdate(update)) {
3343
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_chatManager, "f").handleUpdate(update));
3344
- }
3345
- if (__classPrivateFieldGet(this, _Client_pollManager, "f").canHandleUpdate(update)) {
3346
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_pollManager, "f").handleUpdate(update));
3347
- }
3348
- if (__classPrivateFieldGet(this, _Client_videoChatManager, "f").canHandleUpdate(update)) {
3349
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_videoChatManager, "f").handleUpdate(update));
3350
- }
3351
- if (__classPrivateFieldGet(this, _Client_callbackQueryManager, "f").canHandleUpdate(update)) {
3352
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").handleUpdate(update));
3353
- }
3354
- if (__classPrivateFieldGet(this, _Client_inlineQueryManager, "f").canHandleUpdate(update)) {
3355
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_inlineQueryManager, "f").handleUpdate(update));
3356
- }
3357
- if (__classPrivateFieldGet(this, _Client_linkPreviewManager, "f").canHandleUpdate(update)) {
3358
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_linkPreviewManager, "f").handleUpdate(update));
3359
- }
3360
- if (__classPrivateFieldGet(this, _Client_reactionManager, "f").canHandleUpdate(update)) {
3361
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_reactionManager, "f").handleUpdate(update));
3362
- }
3363
- if (__classPrivateFieldGet(this, _Client_chatListManager, "f").canHandleUpdate(update)) {
3364
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_chatListManager, "f").handleUpdate(update));
3365
- }
3366
- if (__classPrivateFieldGet(this, _Client_storyManager, "f").canHandleUpdate(update)) {
3367
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_storyManager, "f").handleUpdate(update));
3368
- }
3369
- if (__classPrivateFieldGet(this, _Client_businessConnectionManager, "f").canHandleUpdate(update)) {
3370
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").handleUpdate(update));
3371
- }
3372
- if (__classPrivateFieldGet(this, _Client_storyManager, "f").canHandleUpdate(update)) {
3373
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_storyManager, "f").handleUpdate(update));
3374
- }
3375
- if (__classPrivateFieldGet(this, _Client_paymentManager, "f").canHandleUpdate(update)) {
3376
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_paymentManager, "f").handleUpdate(update));
3377
- }
3378
- if (__classPrivateFieldGet(this, _Client_translationsManager, "f").canHandleUpdate(update)) {
3379
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_translationsManager, "f").handleUpdate(update));
3380
- }
3381
- if (__classPrivateFieldGet(this, _Client_botInfoManager, "f").canHandleUpdate(update)) {
3382
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_botInfoManager, "f").handleUpdate(update));
3383
- }
3384
- if (__classPrivateFieldGet(this, _Client_accountManager, "f").canHandleUpdate(update)) {
3385
- maybePromises.push(() => __classPrivateFieldGet(this, _Client_accountManager, "f").handleUpdate(update));
3386
- }
3387
- return () => Promise.resolve().then(async () => {
3388
- const updates = [{ update }];
3389
- for (const maybePromise of maybePromises) {
3390
- try {
3391
- const value = maybePromise();
3392
- const update = value instanceof Promise ? await value : value;
3393
- if (update) {
3394
- updates.push(update);
3395
- }
3396
- }
3397
- catch (err) {
3398
- __classPrivateFieldGet(this, _Client_L, "f").error("failed to construct update:", err);
3399
- }
3400
- }
3401
- for (const update of updates) {
3402
- try {
3403
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, update);
3404
- }
3405
- finally {
3406
- if ("deletedMessages" in update) {
3407
- for (const { chatId, messageId } of update.deletedMessages) {
3408
- await this.messageStorage.setMessage(chatId, messageId, null);
3409
- }
3410
- }
3411
- }
3412
- }
3413
- });
3414
- }, _Client_getMe = async function _Client_getMe() {
3415
- if (__classPrivateFieldGet(this, _Client_lastGetMe, "f") !== null) {
3416
- return __classPrivateFieldGet(this, _Client_lastGetMe, "f");
3417
- }
3418
- else {
3419
- const user = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMeInner).call(this);
3420
- __classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
3421
- return user;
3422
- }
3423
- }, _Client_getMeInner = async function _Client_getMeInner() {
3424
- let chatP = (await this[getPeer]({ _: "peerUser", user_id: BigInt(await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this)) }))?.[0] ?? null;
3425
- if (chatP === null) {
3426
- const users = await this.invoke({ _: "users.getUsers", id: [{ _: "inputUserSelf" }] });
3427
- chatP = (0, _3_types_js_1.constructChatP)(_2_tl_js_1.Api.as("user", users[0]));
3428
- await this.storage.setIsPremium(chatP.isPremium);
3429
- }
3430
- const user = (0, _3_types_js_1.constructUser2)(chatP);
3431
- __classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
3432
- return user;
3433
- }, _Client_onConnectionStateChange = function _Client_onConnectionStateChange(isConnected) {
3434
- if (__classPrivateFieldGet(this, _Client_lastConnectionState, "f") !== isConnected) {
3435
- if (isConnected) {
3436
- if (__classPrivateFieldGet(this, _Client_previouslyConnected, "f")) {
3437
- (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("reconnect"));
3438
- }
3439
- __classPrivateFieldSet(this, _Client_previouslyConnected, true, "f");
3440
- }
3441
- const connectionState = isConnected ? "ready" : "notConnected";
3442
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
3443
- }
3444
- };