@mtkruto/node 0.67.2 → 0.69.0

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