@mtkruto/node 0.67.1 → 0.68.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 (355) hide show
  1. package/esm/0_errors.js +2 -6
  2. package/esm/3_errors.js +2 -12
  3. package/esm/3_transport.d.ts +3 -3
  4. package/esm/3_transport.js +3 -3
  5. package/esm/3_types.d.ts +8 -7
  6. package/esm/3_types.d.ts.map +1 -1
  7. package/esm/3_types.js +8 -7
  8. package/esm/4_errors.js +2 -12
  9. package/esm/_dnt.polyfills.d.ts +99 -0
  10. package/esm/_dnt.polyfills.d.ts.map +1 -1
  11. package/esm/_dnt.polyfills.js +127 -1
  12. package/esm/_dnt.test_polyfills.d.ts.map +1 -0
  13. package/esm/client/0_filters_test.d.ts.map +1 -1
  14. package/esm/client/0_markdown_test.d.ts.map +1 -1
  15. package/esm/client/0_params.d.ts +2 -0
  16. package/esm/client/0_params.d.ts.map +1 -1
  17. package/esm/client/0_password.d.ts +5 -5
  18. package/esm/client/0_password.d.ts.map +1 -1
  19. package/esm/client/0_password_test.d.ts.map +1 -1
  20. package/esm/client/0_storage_operations.js +143 -155
  21. package/esm/client/0_storage_operations_test.d.ts.map +1 -1
  22. package/esm/client/0_utilities.d.ts +1 -1
  23. package/esm/client/0_utilities_test.d.ts.map +1 -1
  24. package/esm/client/1_client_plain.js +4 -22
  25. package/esm/client/1_composer.js +8 -21
  26. package/esm/client/2_account_manager.js +85 -97
  27. package/esm/client/2_bot_info_manager.js +26 -38
  28. package/esm/client/2_business_connection_manager.js +10 -23
  29. package/esm/client/2_client_encrypted.js +194 -211
  30. package/esm/client/2_file_manager.d.ts +4 -3
  31. package/esm/client/2_file_manager.d.ts.map +1 -1
  32. package/esm/client/2_file_manager.js +268 -224
  33. package/esm/client/2_file_manager_test.d.ts.map +1 -1
  34. package/esm/client/2_network_statistics_manager.js +8 -21
  35. package/esm/client/2_payment_manager.js +7 -20
  36. package/esm/client/2_reaction_manager.js +7 -20
  37. package/esm/client/2_translations_manager.js +97 -107
  38. package/esm/client/2_update_manager.js +764 -759
  39. package/esm/client/3_client_encrypted_pool.js +10 -26
  40. package/esm/client/3_client_encrypted_pool_test.d.ts.map +1 -1
  41. package/esm/client/3_message_manager.d.ts +1 -1
  42. package/esm/client/3_message_manager.js +441 -448
  43. package/esm/client/3_message_manager_test.d.ts.map +1 -1
  44. package/esm/client/3_video_chat_manager.d.ts +1 -1
  45. package/esm/client/3_video_chat_manager.js +57 -68
  46. package/esm/client/4_callback_query_manager.js +18 -30
  47. package/esm/client/4_chat_list_manager.js +322 -318
  48. package/esm/client/4_chat_manager.js +118 -131
  49. package/esm/client/4_forum_manager.js +67 -73
  50. package/esm/client/4_gift_manager.js +16 -29
  51. package/esm/client/4_inline_query_manager.js +16 -28
  52. package/esm/client/4_link_preview_manager.js +6 -19
  53. package/esm/client/4_poll_manager.js +44 -57
  54. package/esm/client/4_story_manager.js +41 -53
  55. package/esm/client/5_client.d.ts +7 -0
  56. package/esm/client/5_client.d.ts.map +1 -1
  57. package/esm/client/5_client.js +1271 -1290
  58. package/esm/connection/1_connection_tcp.node.js +48 -65
  59. package/esm/connection/1_connection_web_socket.js +75 -91
  60. package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  61. package/esm/deps/jsr.io/@std/assert/1.0.13/equals.js +4 -4
  62. package/esm/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
  63. package/esm/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
  64. package/esm/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
  65. package/esm/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
  66. package/esm/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
  67. package/esm/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
  68. package/esm/deps/jsr.io/@std/internal/1.0.10/format.d.ts +29 -0
  69. package/esm/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
  70. package/esm/deps/jsr.io/@std/internal/1.0.10/format.js +70 -0
  71. package/esm/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
  72. package/esm/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
  73. package/esm/mod.js +2 -12
  74. package/esm/session/0_session_state.js +12 -38
  75. package/esm/session/1_session.js +49 -72
  76. package/esm/session/2_session_encrypted.js +324 -320
  77. package/esm/storage/1_utilities_test.d.ts.map +1 -1
  78. package/esm/storage/2_storage_indexed_db.js +26 -44
  79. package/esm/storage/2_storage_local_storage.node.js +12 -25
  80. package/esm/storage/2_storage_memory.js +24 -41
  81. package/esm/storage/2_storage_session_storage.js +3 -16
  82. package/esm/tl/0_utilities_test.d.ts.map +1 -1
  83. package/esm/tl/1_tl_reader.js +80 -88
  84. package/esm/tl/1_tl_reader_test.d.ts.map +1 -1
  85. package/esm/tl/1_tl_writer.js +155 -164
  86. package/esm/tl/1_tl_writer_test.d.ts.map +1 -1
  87. package/esm/tl/2_telegram.d.ts +9 -10
  88. package/esm/tl/2_telegram.d.ts.map +1 -1
  89. package/esm/tl/2_telegram.js +10 -10
  90. package/esm/transport/0_transport.js +1 -8
  91. package/esm/transport/1_transport_abridged.js +11 -24
  92. package/esm/transport/1_transport_intermediate.js +10 -23
  93. package/{script/transport/2_transport_provider.d.ts → esm/transport/1_transport_provider.d.ts} +1 -1
  94. package/esm/transport/{2_transport_provider.d.ts.map → 1_transport_provider.d.ts.map} +1 -1
  95. package/{script/transport/3_transport_provider_tcp.d.ts → esm/transport/2_transport_provider_tcp.d.ts} +2 -2
  96. package/esm/transport/{3_transport_provider_tcp.d.ts.map → 2_transport_provider_tcp.d.ts.map} +1 -1
  97. package/esm/transport/{3_transport_provider_tcp.js → 2_transport_provider_tcp.js} +1 -1
  98. package/esm/transport/{3_transport_provider_web_socket.d.ts → 2_transport_provider_web_socket.d.ts} +2 -2
  99. package/esm/transport/2_transport_provider_web_socket.d.ts.map +1 -0
  100. package/esm/transport/{3_transport_provider_web_socket.js → 2_transport_provider_web_socket.js} +1 -1
  101. package/esm/types/0_upload_progress.d.ts +29 -0
  102. package/esm/types/0_upload_progress.d.ts.map +1 -0
  103. package/esm/types/0_upload_progress.js +20 -0
  104. package/esm/types/{2_inline_keyboard_button.d.ts → 1_inline_keyboard_button.d.ts} +1 -1
  105. package/esm/types/{2_inline_keyboard_button.d.ts.map → 1_inline_keyboard_button.d.ts.map} +1 -1
  106. package/esm/types/1_sticker.d.ts +1 -1
  107. package/esm/types/1_sticker.d.ts.map +1 -1
  108. package/esm/types/2_chat.d.ts.map +1 -1
  109. package/esm/types/2_poll_answer.d.ts +19 -0
  110. package/esm/types/2_poll_answer.d.ts.map +1 -1
  111. package/esm/types/2_poll_answer.js +19 -0
  112. package/esm/types/2_pre_checkout_query.d.ts.map +1 -1
  113. package/esm/types/{3_reply_markup.d.ts → 2_reply_markup.d.ts} +2 -2
  114. package/esm/types/{3_reply_markup.d.ts.map → 2_reply_markup.d.ts.map} +1 -1
  115. package/esm/types/{3_reply_markup.js → 2_reply_markup.js} +1 -1
  116. package/esm/types/2_story_interactive_area.d.ts.map +1 -1
  117. package/esm/types/3_chat_member_updated.d.ts.map +1 -1
  118. package/esm/types/3_story.d.ts.map +1 -1
  119. package/esm/types/5_message.d.ts +1 -1
  120. package/esm/types/5_message.d.ts.map +1 -1
  121. package/esm/types/5_message.js +1 -1
  122. package/esm/types/6_inline_query_result.d.ts +1 -1
  123. package/esm/types/6_inline_query_result.js +1 -1
  124. package/esm/types/7_update.d.ts +21 -2
  125. package/esm/types/7_update.d.ts.map +1 -1
  126. package/esm/utilities/0_bigint_test.d.ts.map +1 -1
  127. package/esm/utilities/0_buffer.d.ts +1 -1
  128. package/esm/utilities/0_buffer.d.ts.map +1 -1
  129. package/esm/utilities/0_buffer_test.d.ts.map +1 -1
  130. package/esm/utilities/0_hash.d.ts +2 -2
  131. package/esm/utilities/0_hash.d.ts.map +1 -1
  132. package/esm/utilities/0_mutex.js +4 -19
  133. package/esm/utilities/0_part_stream.js +11 -25
  134. package/esm/utilities/0_part_stream_test.d.ts.map +1 -1
  135. package/esm/utilities/0_rle.d.ts +2 -2
  136. package/esm/utilities/0_rle.d.ts.map +1 -1
  137. package/esm/utilities/0_rle_test.d.ts.map +1 -1
  138. package/esm/utilities/0_text.d.ts +20 -1
  139. package/esm/utilities/0_text.d.ts.map +1 -1
  140. package/esm/utilities/0_text.js +19 -0
  141. package/esm/utilities/1_auth.d.ts +1 -1
  142. package/esm/utilities/1_auth.d.ts.map +1 -1
  143. package/esm/utilities/1_base64.d.ts +1 -1
  144. package/esm/utilities/1_base64.d.ts.map +1 -1
  145. package/esm/utilities/1_base64_test.d.ts.map +1 -1
  146. package/esm/utilities/1_crypto.js +42 -53
  147. package/esm/utilities/1_crypto_test.d.ts.map +1 -1
  148. package/esm/utilities/1_logger.d.ts +2 -2
  149. package/esm/utilities/1_math_test.d.ts.map +1 -1
  150. package/esm/utilities/2_queue.js +29 -47
  151. package/package.json +1 -1
  152. package/script/0_errors.js +2 -6
  153. package/script/2_tl.js +17 -7
  154. package/script/3_errors.js +2 -12
  155. package/script/3_transport.d.ts +3 -3
  156. package/script/3_transport.js +3 -3
  157. package/script/3_types.d.ts +8 -7
  158. package/script/3_types.d.ts.map +1 -1
  159. package/script/3_types.js +8 -7
  160. package/script/4_constants.js +17 -7
  161. package/script/4_errors.js +2 -12
  162. package/script/_dnt.polyfills.d.ts +99 -0
  163. package/script/_dnt.polyfills.d.ts.map +1 -1
  164. package/script/_dnt.polyfills.js +128 -0
  165. package/script/_dnt.test_polyfills.d.ts.map +1 -0
  166. package/script/client/0_filters_test.d.ts.map +1 -1
  167. package/script/client/0_markdown_test.d.ts.map +1 -1
  168. package/script/client/0_params.d.ts +2 -0
  169. package/script/client/0_params.d.ts.map +1 -1
  170. package/script/client/0_password.d.ts +5 -5
  171. package/script/client/0_password.d.ts.map +1 -1
  172. package/script/client/0_password.js +17 -7
  173. package/script/client/0_password_test.d.ts.map +1 -1
  174. package/script/client/0_storage_operations.js +143 -155
  175. package/script/client/0_storage_operations_test.d.ts.map +1 -1
  176. package/script/client/0_utilities.d.ts +1 -1
  177. package/script/client/0_utilities_test.d.ts.map +1 -1
  178. package/script/client/1_client_plain.js +4 -22
  179. package/script/client/1_composer.js +8 -21
  180. package/script/client/2_account_manager.js +85 -97
  181. package/script/client/2_bot_info_manager.js +26 -38
  182. package/script/client/2_business_connection_manager.js +10 -23
  183. package/script/client/2_client_encrypted.js +195 -212
  184. package/script/client/2_file_manager.d.ts +4 -3
  185. package/script/client/2_file_manager.d.ts.map +1 -1
  186. package/script/client/2_file_manager.js +285 -231
  187. package/script/client/2_file_manager_test.d.ts.map +1 -1
  188. package/script/client/2_network_statistics_manager.js +8 -21
  189. package/script/client/2_payment_manager.js +7 -20
  190. package/script/client/2_reaction_manager.js +7 -20
  191. package/script/client/2_translations_manager.js +98 -108
  192. package/script/client/2_update_manager.js +764 -759
  193. package/script/client/3_client_encrypted_pool.js +10 -26
  194. package/script/client/3_client_encrypted_pool_test.d.ts.map +1 -1
  195. package/script/client/3_message_manager.d.ts +1 -1
  196. package/script/client/3_message_manager.js +441 -448
  197. package/script/client/3_message_manager_test.d.ts.map +1 -1
  198. package/script/client/3_video_chat_manager.d.ts +1 -1
  199. package/script/client/3_video_chat_manager.js +57 -68
  200. package/script/client/4_callback_query_manager.js +18 -30
  201. package/script/client/4_chat_list_manager.js +322 -318
  202. package/script/client/4_chat_manager.js +118 -131
  203. package/script/client/4_forum_manager.js +67 -73
  204. package/script/client/4_gift_manager.js +16 -29
  205. package/script/client/4_inline_query_manager.js +16 -28
  206. package/script/client/4_link_preview_manager.js +6 -19
  207. package/script/client/4_poll_manager.js +44 -57
  208. package/script/client/4_story_manager.js +41 -53
  209. package/script/client/5_client.d.ts +7 -0
  210. package/script/client/5_client.d.ts.map +1 -1
  211. package/script/client/5_client.js +1271 -1290
  212. package/script/connection/1_connection_tcp.node.js +48 -65
  213. package/script/connection/1_connection_web_socket.js +92 -98
  214. package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  215. package/script/deps/jsr.io/@std/assert/1.0.13/equal.js +17 -7
  216. package/script/deps/jsr.io/@std/assert/1.0.13/equals.js +4 -4
  217. package/script/deps/jsr.io/@std/async/1.0.13/delay.js +17 -7
  218. package/script/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
  219. package/script/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
  220. package/script/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
  221. package/script/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
  222. package/script/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
  223. package/script/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
  224. package/script/deps/jsr.io/@std/internal/1.0.10/format.d.ts +29 -0
  225. package/script/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
  226. package/script/deps/jsr.io/@std/internal/1.0.10/format.js +106 -0
  227. package/script/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
  228. package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.js +17 -7
  229. package/script/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
  230. package/script/deps/jsr.io/@std/path/1.1.0/_os.js +17 -7
  231. package/script/mod.js +19 -19
  232. package/script/session/0_session_state.js +12 -38
  233. package/script/session/1_session.js +66 -79
  234. package/script/session/2_session_encrypted.js +325 -321
  235. package/script/storage/1_utilities_test.d.ts.map +1 -1
  236. package/script/storage/2_storage_indexed_db.js +26 -44
  237. package/script/storage/2_storage_local_storage.node.js +12 -25
  238. package/script/storage/2_storage_memory.js +24 -41
  239. package/script/storage/2_storage_session_storage.js +3 -16
  240. package/script/tl/0_utilities_test.d.ts.map +1 -1
  241. package/script/tl/1_tl_reader.js +81 -89
  242. package/script/tl/1_tl_reader_test.d.ts.map +1 -1
  243. package/script/tl/1_tl_writer.js +156 -165
  244. package/script/tl/1_tl_writer_test.d.ts.map +1 -1
  245. package/script/tl/2_telegram.d.ts +9 -10
  246. package/script/tl/2_telegram.d.ts.map +1 -1
  247. package/script/tl/2_telegram.js +32 -10
  248. package/script/transport/0_obfuscation.js +17 -7
  249. package/script/transport/0_transport.js +1 -8
  250. package/script/transport/1_transport_abridged.js +11 -24
  251. package/script/transport/1_transport_intermediate.js +10 -23
  252. package/{esm/transport/2_transport_provider.d.ts → script/transport/1_transport_provider.d.ts} +1 -1
  253. package/script/transport/{2_transport_provider.d.ts.map → 1_transport_provider.d.ts.map} +1 -1
  254. package/{esm/transport/3_transport_provider_tcp.d.ts → script/transport/2_transport_provider_tcp.d.ts} +2 -2
  255. package/script/transport/{3_transport_provider_tcp.d.ts.map → 2_transport_provider_tcp.d.ts.map} +1 -1
  256. package/script/transport/{3_transport_provider_tcp.js → 2_transport_provider_tcp.js} +3 -3
  257. package/script/transport/{3_transport_provider_web_socket.d.ts → 2_transport_provider_web_socket.d.ts} +2 -2
  258. package/script/transport/2_transport_provider_web_socket.d.ts.map +1 -0
  259. package/script/transport/{3_transport_provider_web_socket.js → 2_transport_provider_web_socket.js} +2 -2
  260. package/script/types/0_upload_progress.d.ts +29 -0
  261. package/script/types/0_upload_progress.d.ts.map +1 -0
  262. package/script/types/0_upload_progress.js +21 -0
  263. package/script/types/{2_inline_keyboard_button.d.ts → 1_inline_keyboard_button.d.ts} +1 -1
  264. package/script/types/{2_inline_keyboard_button.d.ts.map → 1_inline_keyboard_button.d.ts.map} +1 -1
  265. package/script/types/1_sticker.d.ts +1 -1
  266. package/script/types/1_sticker.d.ts.map +1 -1
  267. package/script/types/2_chat.d.ts.map +1 -1
  268. package/script/types/2_poll_answer.d.ts +19 -0
  269. package/script/types/2_poll_answer.d.ts.map +1 -1
  270. package/script/types/2_poll_answer.js +19 -0
  271. package/script/types/2_pre_checkout_query.d.ts.map +1 -1
  272. package/script/types/{3_reply_markup.d.ts → 2_reply_markup.d.ts} +2 -2
  273. package/script/types/{3_reply_markup.d.ts.map → 2_reply_markup.d.ts.map} +1 -1
  274. package/script/types/{3_reply_markup.js → 2_reply_markup.js} +3 -3
  275. package/script/types/2_story_interactive_area.d.ts.map +1 -1
  276. package/script/types/3_chat_member_updated.d.ts.map +1 -1
  277. package/script/types/3_story.d.ts.map +1 -1
  278. package/script/types/5_message.d.ts +1 -1
  279. package/script/types/5_message.d.ts.map +1 -1
  280. package/script/types/5_message.js +2 -2
  281. package/script/types/6_inline_query_result.d.ts +1 -1
  282. package/script/types/6_inline_query_result.js +4 -4
  283. package/script/types/7_update.d.ts +21 -2
  284. package/script/types/7_update.d.ts.map +1 -1
  285. package/script/utilities/0_bigint.js +17 -7
  286. package/script/utilities/0_bigint_test.d.ts.map +1 -1
  287. package/script/utilities/0_buffer.d.ts +1 -1
  288. package/script/utilities/0_buffer.d.ts.map +1 -1
  289. package/script/utilities/0_buffer_test.d.ts.map +1 -1
  290. package/script/utilities/0_env.js +17 -7
  291. package/script/utilities/0_hash.d.ts +2 -2
  292. package/script/utilities/0_hash.d.ts.map +1 -1
  293. package/script/utilities/0_hash.js +17 -7
  294. package/script/utilities/0_misc.js +17 -7
  295. package/script/utilities/0_mutex.js +4 -19
  296. package/script/utilities/0_part_stream.js +11 -25
  297. package/script/utilities/0_part_stream_test.d.ts.map +1 -1
  298. package/script/utilities/0_rle.d.ts +2 -2
  299. package/script/utilities/0_rle.d.ts.map +1 -1
  300. package/script/utilities/0_rle_test.d.ts.map +1 -1
  301. package/script/utilities/0_text.d.ts +20 -1
  302. package/script/utilities/0_text.d.ts.map +1 -1
  303. package/script/utilities/0_text.js +19 -0
  304. package/script/utilities/1_auth.d.ts +1 -1
  305. package/script/utilities/1_auth.d.ts.map +1 -1
  306. package/script/utilities/1_auth.js +17 -7
  307. package/script/utilities/1_base64.d.ts +1 -1
  308. package/script/utilities/1_base64.d.ts.map +1 -1
  309. package/script/utilities/1_base64_test.d.ts.map +1 -1
  310. package/script/utilities/1_crypto.js +60 -61
  311. package/script/utilities/1_crypto_test.d.ts.map +1 -1
  312. package/script/utilities/1_logger.d.ts +2 -2
  313. package/script/utilities/1_math_test.d.ts.map +1 -1
  314. package/script/utilities/2_queue.js +30 -48
  315. package/esm/deps/jsr.io/@std/internal/1.0.9/build_message.d.ts.map +0 -1
  316. package/esm/deps/jsr.io/@std/internal/1.0.9/diff.d.ts.map +0 -1
  317. package/esm/deps/jsr.io/@std/internal/1.0.9/diff_str.d.ts.map +0 -1
  318. package/esm/deps/jsr.io/@std/internal/1.0.9/format.d.ts +0 -2
  319. package/esm/deps/jsr.io/@std/internal/1.0.9/format.d.ts.map +0 -1
  320. package/esm/deps/jsr.io/@std/internal/1.0.9/format.js +0 -37
  321. package/esm/deps/jsr.io/@std/internal/1.0.9/styles.d.ts.map +0 -1
  322. package/esm/deps/jsr.io/@std/internal/1.0.9/types.d.ts.map +0 -1
  323. package/esm/transport/3_transport_provider_web_socket.d.ts.map +0 -1
  324. package/script/deps/jsr.io/@std/internal/1.0.9/build_message.d.ts.map +0 -1
  325. package/script/deps/jsr.io/@std/internal/1.0.9/diff.d.ts.map +0 -1
  326. package/script/deps/jsr.io/@std/internal/1.0.9/diff_str.d.ts.map +0 -1
  327. package/script/deps/jsr.io/@std/internal/1.0.9/format.d.ts +0 -2
  328. package/script/deps/jsr.io/@std/internal/1.0.9/format.d.ts.map +0 -1
  329. package/script/deps/jsr.io/@std/internal/1.0.9/format.js +0 -63
  330. package/script/deps/jsr.io/@std/internal/1.0.9/styles.d.ts.map +0 -1
  331. package/script/deps/jsr.io/@std/internal/1.0.9/types.d.ts.map +0 -1
  332. package/script/transport/3_transport_provider_web_socket.d.ts.map +0 -1
  333. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.d.ts +0 -0
  334. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.js +0 -0
  335. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.d.ts +0 -0
  336. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.js +0 -0
  337. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.d.ts +0 -0
  338. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.js +0 -0
  339. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.d.ts +0 -0
  340. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.js +0 -0
  341. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.d.ts +0 -0
  342. /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.js +0 -0
  343. /package/esm/transport/{2_transport_provider.js → 1_transport_provider.js} +0 -0
  344. /package/esm/types/{2_inline_keyboard_button.js → 1_inline_keyboard_button.js} +0 -0
  345. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.d.ts +0 -0
  346. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.js +0 -0
  347. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.d.ts +0 -0
  348. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.js +0 -0
  349. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.d.ts +0 -0
  350. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.js +0 -0
  351. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.d.ts +0 -0
  352. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.d.ts +0 -0
  353. /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.js +0 -0
  354. /package/script/transport/{2_transport_provider.js → 1_transport_provider.js} +0 -0
  355. /package/script/types/{2_inline_keyboard_button.js → 1_inline_keyboard_button.js} +0 -0
@@ -18,18 +18,6 @@
18
18
  * You should have received a copy of the GNU Lesser General Public License
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
22
- if (kind === "m") throw new TypeError("Private method is not writable");
23
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
24
- 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");
25
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
26
- };
27
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
28
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
29
- 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");
30
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
31
- };
32
- var _MessageManager_instances, _a, _MessageManager_c, _MessageManager_LresolveFileId, _MessageManager_checkParams, _MessageManager_constructReplyMarkup, _MessageManager_resolveSendAs, _MessageManager_constructReplyTo, _MessageManager_sendDocumentInner, _MessageManager_sendMedia, _MessageManager_CAPTIONABLE_MESSAGE_TYPES, _MessageManager_editInlineMessageTextInner, _MessageManager_resolveInputMediaInner, _MessageManager_resolveInputMedia, _MessageManager_sendReaction, _MessageManager_getCachedVoiceTranscription, _MessageManager_cacheVoiceTranscription;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.MessageManager = void 0;
35
23
  const _0_deps_js_1 = require("../0_deps.js");
@@ -60,31 +48,21 @@ const messageManagerUpdates = [
60
48
  "updateTranscribedAudio",
61
49
  ];
62
50
  class MessageManager {
51
+ #c;
52
+ #LresolveFileId;
63
53
  constructor(c) {
64
- _MessageManager_instances.add(this);
65
- _MessageManager_c.set(this, void 0);
66
- _MessageManager_LresolveFileId.set(this, void 0);
67
- Object.defineProperty(this, "usernameResolver", {
68
- enumerable: true,
69
- configurable: true,
70
- writable: true,
71
- value: async (v) => {
72
- const inputPeer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(v).then((v) => _2_tl_js_1.Api.as("inputPeerUser", v));
73
- return { ...inputPeer, _: "inputUser" };
74
- }
75
- });
76
- __classPrivateFieldSet(this, _MessageManager_c, c, "f");
54
+ this.#c = c;
77
55
  const L = (0, _1_utilities_js_1.getLogger)("MessageManager").client(c.id);
78
- __classPrivateFieldSet(this, _MessageManager_LresolveFileId, L.branch("resolveFileId"), "f");
56
+ this.#LresolveFileId = L.branch("resolveFileId");
79
57
  }
80
58
  async getMessages(chatId, messageIds) {
81
59
  (0, _0_utilities_js_1.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
82
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
60
+ const peer = await this.#c.getInputPeer(chatId);
83
61
  let messages_ = new Array();
84
- const chatId_ = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeerChatId(peer);
62
+ const chatId_ = await this.#c.getInputPeerChatId(peer);
85
63
  let shouldFetch = false;
86
64
  for (const messageId of messageIds) {
87
- const message = await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getMessage(chatId_, messageId);
65
+ const message = await this.#c.messageStorage.getMessage(chatId_, messageId);
88
66
  if (message == null) {
89
67
  messages_ = [];
90
68
  shouldFetch = true;
@@ -96,10 +74,10 @@ class MessageManager {
96
74
  }
97
75
  if (shouldFetch) {
98
76
  if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
99
- messages_ = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.getMessages", channel: (0, _0_utilities_js_1.toInputChannel)(peer), id: messageIds.map((v) => ({ _: "inputMessageID", id: v })) }).then((v) => _2_tl_js_1.Api.as("messages.channelMessages", v).messages);
77
+ messages_ = await this.#c.invoke({ _: "channels.getMessages", channel: (0, _0_utilities_js_1.toInputChannel)(peer), id: messageIds.map((v) => ({ _: "inputMessageID", id: v })) }).then((v) => _2_tl_js_1.Api.as("messages.channelMessages", v).messages);
100
78
  }
101
79
  else {
102
- messages_ = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
80
+ messages_ = await this.#c.invoke({
103
81
  _: "messages.getMessages",
104
82
  id: messageIds.map((v) => ({ _: "inputMessageID", id: v })),
105
83
  }).then((v) => _2_tl_js_1.Api.as("messages.messages", v).messages);
@@ -162,9 +140,23 @@ class MessageManager {
162
140
  }
163
141
  return [text, entities];
164
142
  }
143
+ #checkParams(params) {
144
+ if (params && "replyMarkup" in params && params.replyMarkup !== undefined) {
145
+ this.#c.storage.assertBot("replyMarkup");
146
+ }
147
+ if (params && "businessConnectionId" in params && params.businessConnectionId !== undefined) {
148
+ this.#c.storage.assertBot("businessConnectionId");
149
+ }
150
+ if (params && "sendAs" in params && params.sendAs !== undefined) {
151
+ this.#c.storage.assertUser("sendAs");
152
+ }
153
+ if (params && "sendAt" in params && params.sendAt !== undefined) {
154
+ this.#c.storage.assertUser("businessConsendAtnectionId");
155
+ }
156
+ }
165
157
  async parseText(text_, params) {
166
- const [text, entities_] = _a.parseText(text_, params?.entities ?? [], params?.parseMode ?? __classPrivateFieldGet(this, _MessageManager_c, "f").parseMode);
167
- const entities = entities_?.length > 0 ? await Promise.all(entities_.map((v) => (0, _3_types_js_2.messageEntityToTlObject)(v, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity))) : undefined;
158
+ const [text, entities_] = MessageManager.parseText(text_, params?.entities ?? [], params?.parseMode ?? this.#c.parseMode);
159
+ const entities = entities_?.length > 0 ? await Promise.all(entities_.map((v) => (0, _3_types_js_2.messageEntityToTlObject)(v, this.#c.getEntity))) : undefined;
168
160
  return [text, entities];
169
161
  }
170
162
  async updatesToMessages(chatId, updates, businessConnectionId) {
@@ -206,35 +198,35 @@ class MessageManager {
206
198
  let poll = null;
207
199
  let pollResults = null;
208
200
  if (pollId) {
209
- [poll, pollResults] = await Promise.all([__classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getPoll(pollId), __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getPollResults(pollId)]);
201
+ [poll, pollResults] = await Promise.all([this.#c.messageStorage.getPoll(pollId), this.#c.messageStorage.getPollResults(pollId)]);
210
202
  }
211
- const message = await (0, _3_types_js_2.constructMessage)(message_, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity, this.getMessage.bind(this), __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.getStickerSetName.bind(__classPrivateFieldGet(this, _MessageManager_c, "f").fileManager), r, business, poll ?? undefined, pollResults ?? undefined);
203
+ const message = await (0, _3_types_js_2.constructMessage)(message_, this.#c.getEntity, this.getMessage.bind(this), this.#c.fileManager.getStickerSetName.bind(this.#c.fileManager), r, business, poll ?? undefined, pollResults ?? undefined);
212
204
  if (!poll && mediaPoll) {
213
- await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.setPoll(mediaPoll.poll.id, mediaPoll.poll);
205
+ await this.#c.storage.setPoll(mediaPoll.poll.id, mediaPoll.poll);
214
206
  }
215
207
  if (!pollResults && mediaPoll) {
216
- await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.setPollResults(mediaPoll.poll.id, mediaPoll.results);
208
+ await this.#c.storage.setPollResults(mediaPoll.poll.id, mediaPoll.results);
217
209
  }
218
210
  return message;
219
211
  }
220
212
  async forwardMessages(from, to, messageIds, params) {
221
213
  (0, _0_utilities_js_1.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
222
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.forwardMessages", from_peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(from), to_peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(to), id: messageIds, random_id: messageIds.map(() => (0, _1_utilities_js_1.getRandomId)()), silent: params?.disableNotification || undefined, top_msg_id: params?.messageThreadId, noforwards: params?.disableNotification || undefined, send_as: params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined, drop_author: params?.dropSenderName || undefined, drop_media_captions: params?.dropCaption || undefined });
214
+ const result = await this.#c.invoke({ _: "messages.forwardMessages", from_peer: await this.#c.getInputPeer(from), to_peer: await this.#c.getInputPeer(to), id: messageIds, random_id: messageIds.map(() => (0, _1_utilities_js_1.getRandomId)()), silent: params?.disableNotification || undefined, top_msg_id: params?.messageThreadId, noforwards: params?.disableNotification || undefined, send_as: params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined, drop_author: params?.dropSenderName || undefined, drop_media_captions: params?.dropCaption || undefined });
223
215
  return await this.updatesToMessages(to, result);
224
216
  }
225
217
  async getHistory(chatId, params) {
226
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("getHistory");
218
+ this.#c.storage.assertUser("getHistory");
227
219
  const limit = (0, _0_utilities_js_1.getLimit)(params?.limit);
228
220
  let offsetId = params?.fromMessageId ?? 0;
229
221
  if (offsetId < 0) {
230
222
  offsetId = 0;
231
223
  }
232
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
224
+ const peer = await this.#c.getInputPeer(chatId);
233
225
  const messages = new Array();
234
226
  if (messages.length > 0) {
235
227
  offsetId = messages[messages.length - 1].id; // TODO: track id of oldest message and don't send requests for it
236
228
  }
237
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.getHistory", peer: peer, offset_id: offsetId, offset_date: 0, add_offset: 0, limit, max_id: 0, min_id: 0, hash: 0n });
229
+ const result = await this.#c.invoke({ _: "messages.getHistory", peer: peer, offset_id: offsetId, offset_date: 0, add_offset: 0, limit, max_id: 0, min_id: 0, hash: 0n });
238
230
  if (!("messages" in result)) {
239
231
  (0, _0_deps_js_1.unreachable)();
240
232
  }
@@ -244,23 +236,40 @@ class MessageManager {
244
236
  }
245
237
  return messages;
246
238
  }
239
+ usernameResolver = async (v) => {
240
+ const inputPeer = await this.#c.getInputPeer(v).then((v) => _2_tl_js_1.Api.as("inputPeerUser", v));
241
+ return { ...inputPeer, _: "inputUser" };
242
+ };
243
+ async #constructReplyMarkup(params) {
244
+ if (params?.replyMarkup) {
245
+ this.#c.storage.assertBot("replyMarkup");
246
+ return await (0, _3_types_js_2.replyMarkupToTlObject)(params.replyMarkup, this.usernameResolver.bind(this));
247
+ }
248
+ }
249
+ async #resolveSendAs(params) {
250
+ const sendAs = params?.sendAs;
251
+ if (sendAs !== undefined) {
252
+ this.#c.storage.assertUser("sendAs");
253
+ return sendAs ? await this.#c.getInputPeer(sendAs) : undefined;
254
+ }
255
+ }
247
256
  async sendMessage(chatId, text, params) {
248
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
257
+ this.#checkParams(params);
249
258
  const [message, entities] = await this.parseText(text, params);
250
- const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
251
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
259
+ const replyMarkup = await this.#constructReplyMarkup(params);
260
+ const peer = await this.#c.getInputPeer(chatId);
252
261
  const randomId = (0, _1_utilities_js_1.getRandomId)();
253
262
  const noWebpage = params?.linkPreview?.disable ? true : undefined;
254
263
  const invertMedia = params?.linkPreview?.aboveText ? true : undefined;
255
264
  const silent = params?.disableNotification ? true : undefined;
256
265
  const noforwards = params?.protectContent ? true : undefined;
257
- const sendAs = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveSendAs).call(this, params);
266
+ const sendAs = await this.#resolveSendAs(params);
258
267
  const effect = params?.effectId ? BigInt(params.effectId) : undefined;
259
268
  const schedule_date = params?.sendAt;
260
269
  const allow_paid_floodskip = params?.paidBroadcast ? true : undefined;
261
270
  let result;
262
271
  if (!noWebpage && params?.linkPreview?.url) {
263
- result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
272
+ result = await this.#c.invoke({
264
273
  _: "messages.sendMedia",
265
274
  peer,
266
275
  random_id: randomId,
@@ -275,7 +284,7 @@ class MessageManager {
275
284
  invert_media: invertMedia,
276
285
  silent,
277
286
  noforwards,
278
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
287
+ reply_to: await this.#constructReplyTo(params),
279
288
  send_as: sendAs,
280
289
  entities,
281
290
  reply_markup: replyMarkup,
@@ -285,7 +294,7 @@ class MessageManager {
285
294
  }, { businessConnectionId: params?.businessConnectionId });
286
295
  }
287
296
  else {
288
- result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
297
+ result = await this.#c.invoke({
289
298
  _: "messages.sendMessage",
290
299
  peer,
291
300
  random_id: randomId,
@@ -294,7 +303,7 @@ class MessageManager {
294
303
  invert_media: invertMedia,
295
304
  silent,
296
305
  noforwards,
297
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
306
+ reply_to: await this.#constructReplyTo(params),
298
307
  send_as: sendAs,
299
308
  entities,
300
309
  reply_markup: replyMarkup,
@@ -306,21 +315,38 @@ class MessageManager {
306
315
  const message_ = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
307
316
  return (0, _3_types_js_2.assertMessageType)(message_, "text");
308
317
  }
318
+ async #constructReplyTo(params) {
319
+ const topMsgId = params?.messageThreadId;
320
+ if (!params?.replyTo) {
321
+ if (topMsgId) {
322
+ return { _: "inputReplyToMessage", reply_to_msg_id: topMsgId };
323
+ }
324
+ else {
325
+ return undefined;
326
+ }
327
+ }
328
+ if ("messageId" in params.replyTo) {
329
+ return { _: "inputReplyToMessage", reply_to_msg_id: params.replyTo.messageId, top_msg_id: topMsgId, quote_text: params.replyTo.quote?.text, quote_entities: await Promise.all(params.replyTo.quote?.entities.map((v) => (0, _3_types_js_2.messageEntityToTlObject)(v, this.#c.getEntity)) ?? []), quote_offset: params.replyTo.quote?.offset };
330
+ }
331
+ else {
332
+ return { _: "inputReplyToStory", peer: await this.#c.getInputPeer(params.replyTo.chatId), story_id: params.replyTo.storyId };
333
+ }
334
+ }
309
335
  async sendVenue(chatId, latitude, longitude, title, address, params) {
310
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
311
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
336
+ this.#checkParams(params);
337
+ const peer = await this.#c.getInputPeer(chatId);
312
338
  const randomId = (0, _1_utilities_js_1.getRandomId)();
313
339
  const silent = params?.disableNotification ? true : undefined;
314
340
  const noforwards = params?.protectContent ? true : undefined;
315
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
316
- const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
317
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
341
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
342
+ const replyMarkup = await this.#constructReplyMarkup(params);
343
+ const result = await this.#c.invoke({
318
344
  _: "messages.sendMedia",
319
345
  peer,
320
346
  random_id: randomId,
321
347
  silent,
322
348
  noforwards,
323
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
349
+ reply_to: await this.#constructReplyTo(params),
324
350
  send_as: sendAs,
325
351
  reply_markup: replyMarkup,
326
352
  media: ({
@@ -345,20 +371,20 @@ class MessageManager {
345
371
  return (0, _3_types_js_2.assertMessageType)(message, "venue");
346
372
  }
347
373
  async sendContact(chatId, firstName, number, params) {
348
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
349
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
374
+ this.#checkParams(params);
375
+ const peer = await this.#c.getInputPeer(chatId);
350
376
  const randomId = (0, _1_utilities_js_1.getRandomId)();
351
377
  const silent = params?.disableNotification ? true : undefined;
352
378
  const noforwards = params?.protectContent ? true : undefined;
353
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
354
- const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
355
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
379
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
380
+ const replyMarkup = await this.#constructReplyMarkup(params);
381
+ const result = await this.#c.invoke({
356
382
  _: "messages.sendMedia",
357
383
  peer,
358
384
  random_id: randomId,
359
385
  silent,
360
386
  noforwards,
361
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
387
+ reply_to: await this.#constructReplyTo(params),
362
388
  send_as: sendAs,
363
389
  reply_markup: replyMarkup,
364
390
  media: ({
@@ -377,20 +403,20 @@ class MessageManager {
377
403
  return (0, _3_types_js_2.assertMessageType)(message, "contact");
378
404
  }
379
405
  async sendDice(chatId, params) {
380
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
381
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
406
+ this.#checkParams(params);
407
+ const peer = await this.#c.getInputPeer(chatId);
382
408
  const randomId = (0, _1_utilities_js_1.getRandomId)();
383
409
  const silent = params?.disableNotification ? true : undefined;
384
410
  const noforwards = params?.protectContent ? true : undefined;
385
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
386
- const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
387
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
411
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
412
+ const replyMarkup = await this.#constructReplyMarkup(params);
413
+ const result = await this.#c.invoke({
388
414
  _: "messages.sendMedia",
389
415
  peer,
390
416
  random_id: randomId,
391
417
  silent,
392
418
  noforwards,
393
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
419
+ reply_to: await this.#constructReplyTo(params),
394
420
  send_as: sendAs,
395
421
  reply_markup: replyMarkup,
396
422
  media: ({
@@ -406,20 +432,20 @@ class MessageManager {
406
432
  return (0, _3_types_js_2.assertMessageType)(message, "dice");
407
433
  }
408
434
  async sendLocation(chatId, latitude, longitude, params) {
409
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
410
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
435
+ this.#checkParams(params);
436
+ const peer = await this.#c.getInputPeer(chatId);
411
437
  const randomId = (0, _1_utilities_js_1.getRandomId)();
412
438
  const silent = params?.disableNotification ? true : undefined;
413
439
  const noforwards = params?.protectContent ? true : undefined;
414
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
415
- const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
416
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
440
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
441
+ const replyMarkup = await this.#constructReplyMarkup(params);
442
+ const result = await this.#c.invoke({
417
443
  _: "messages.sendMedia",
418
444
  peer,
419
445
  random_id: randomId,
420
446
  silent,
421
447
  noforwards,
422
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
448
+ reply_to: await this.#constructReplyTo(params),
423
449
  send_as: sendAs,
424
450
  reply_markup: replyMarkup,
425
451
  media: params?.livePeriod !== undefined
@@ -453,53 +479,95 @@ class MessageManager {
453
479
  return (0, _3_types_js_2.assertMessageType)(message, "location");
454
480
  }
455
481
  async sendVideoNote(chatId, audio, params) {
456
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
457
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, audio, params, _3_types_js_2.FileType.VideoNote, [
482
+ this.#checkParams(params);
483
+ const message = await this.#sendDocumentInner(chatId, audio, params, _3_types_js_2.FileType.VideoNote, [
458
484
  { _: "documentAttributeVideo", round_message: true, w: params?.length ?? 0, h: params?.length ?? 0, duration: params?.duration ?? 0 },
459
485
  ], false);
460
486
  return (0, _3_types_js_2.assertMessageType)(message, "videoNote");
461
487
  }
462
488
  async sendAudio(chatId, audio, params) {
463
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
464
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, audio, params, _3_types_js_2.FileType.Audio, [
489
+ this.#checkParams(params);
490
+ const message = await this.#sendDocumentInner(chatId, audio, params, _3_types_js_2.FileType.Audio, [
465
491
  { _: "documentAttributeAudio", duration: params?.duration ?? 0, performer: params?.performer, title: params?.title },
466
492
  ]);
467
493
  return (0, _3_types_js_2.assertMessageType)(message, "audio");
468
494
  }
469
495
  async sendVoice(chatId, voice, params) {
470
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
471
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, voice, params, _3_types_js_2.FileType.VoiceNote, [
496
+ this.#checkParams(params);
497
+ const message = await this.#sendDocumentInner(chatId, voice, params, _3_types_js_2.FileType.VoiceNote, [
472
498
  { _: "documentAttributeAudio", voice: true, duration: params?.duration ?? 0 },
473
499
  ]);
474
500
  return (0, _3_types_js_2.assertMessageType)(message, "voice");
475
501
  }
476
502
  async sendAnimation(chatId, animation, params) {
477
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
478
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, animation, params, _3_types_js_2.FileType.Animation, [
503
+ this.#checkParams(params);
504
+ const message = await this.#sendDocumentInner(chatId, animation, params, _3_types_js_2.FileType.Animation, [
479
505
  { _: "documentAttributeAnimated" },
480
506
  { _: "documentAttributeVideo", supports_streaming: true, w: params?.width ?? 0, h: params?.height ?? 0, duration: params?.duration ?? 0 },
481
507
  ]);
482
508
  return (0, _3_types_js_2.assertMessageType)(message, "animation");
483
509
  }
484
510
  async sendVideo(chatId, video, params) {
485
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
486
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, video, params, _3_types_js_2.FileType.Video, [
511
+ this.#checkParams(params);
512
+ const message = await this.#sendDocumentInner(chatId, video, params, _3_types_js_2.FileType.Video, [
487
513
  { _: "documentAttributeVideo", supports_streaming: params?.supportsStreaming ? true : undefined, w: params?.width ?? 0, h: params?.height ?? 0, duration: params?.duration ?? 0 },
488
514
  ]);
489
515
  return (0, _3_types_js_2.assertMessageType)(message, "video");
490
516
  }
517
+ async #sendDocumentInner(chatId, document, params, fileType, otherAttribs, urlSupported = true, expectedMimeTypes) {
518
+ let media = null;
519
+ const spoiler = params?.hasSpoiler ? true : undefined;
520
+ const ttl_seconds = params && "selfDestruct" in params && typeof params.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(params.selfDestruct) : undefined;
521
+ if (typeof document === "string") {
522
+ const fileId = this.resolveFileId(document, fileType);
523
+ if (fileId != null) {
524
+ media = { _: "inputMediaDocument", id: { ...fileId, _: "inputDocument" }, spoiler, query: otherAttribs.find((v) => _2_tl_js_1.Api.is("documentAttributeSticker", v))?.alt || undefined, ttl_seconds };
525
+ }
526
+ }
527
+ if (media == null) {
528
+ if (typeof document === "string" && (0, _0_utilities_js_1.isHttpUrl)(document)) {
529
+ if (!urlSupported) {
530
+ throw new _0_errors_js_1.InputError("URL not supported.");
531
+ }
532
+ media = { _: "inputMediaDocumentExternal", url: document, spoiler, ttl_seconds };
533
+ }
534
+ else {
535
+ let mimeType;
536
+ const file = await this.#c.fileManager.upload(document, params, (name) => {
537
+ mimeType = params?.mimeType ?? (0, _0_deps_js_1.contentType)(name.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE;
538
+ if (expectedMimeTypes && !expectedMimeTypes.includes(mimeType)) {
539
+ (0, _0_deps_js_1.unreachable)();
540
+ }
541
+ if (name.endsWith(".tgs") && fileType == _3_types_js_2.FileType.Document) {
542
+ name += "-";
543
+ }
544
+ return name;
545
+ });
546
+ if (_2_tl_js_1.Api.is("inputFileStoryDocument", file)) {
547
+ (0, _0_deps_js_1.unreachable)();
548
+ }
549
+ let thumb = undefined;
550
+ if (params?.thumbnail) {
551
+ thumb = await this.#c.fileManager.upload(params.thumbnail, { chunkSize: params?.chunkSize, signal: params?.signal });
552
+ }
553
+ media = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType == _3_types_js_2.FileType.Document ? true : undefined, ttl_seconds };
554
+ }
555
+ }
556
+ const message = await this.#sendMedia(chatId, media, params);
557
+ return message;
558
+ }
491
559
  async sendDocument(chatId, document, params) {
492
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
493
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, document, params, _3_types_js_2.FileType.Document, []);
560
+ this.#checkParams(params);
561
+ const message = await this.#sendDocumentInner(chatId, document, params, _3_types_js_2.FileType.Document, []);
494
562
  return (0, _3_types_js_2.assertMessageType)(message, "document");
495
563
  }
496
564
  async sendSticker(chatId, sticker, params) {
497
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
498
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, sticker, params, _3_types_js_2.FileType.Sticker, [{ _: "documentAttributeSticker", alt: params?.emoji || "", stickerset: { _: "inputStickerSetEmpty" } }], undefined, STICKER_MIME_TYPES);
565
+ this.#checkParams(params);
566
+ const message = await this.#sendDocumentInner(chatId, sticker, params, _3_types_js_2.FileType.Sticker, [{ _: "documentAttributeSticker", alt: params?.emoji || "", stickerset: { _: "inputStickerSetEmpty" } }], undefined, STICKER_MIME_TYPES);
499
567
  return (0, _3_types_js_2.assertMessageType)(message, "sticker");
500
568
  }
501
569
  async sendPhoto(chatId, photo, params) {
502
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
570
+ this.#checkParams(params);
503
571
  let media = null;
504
572
  const spoiler = params?.hasSpoiler ? true : undefined;
505
573
  const ttl_seconds = params && "selfDestruct" in params && params.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(params.selfDestruct) : undefined;
@@ -514,13 +582,48 @@ class MessageManager {
514
582
  media = { _: "inputMediaPhotoExternal", url: photo, spoiler, ttl_seconds: (params && "selfDestruct" in params && params.selfDestruct !== undefined) ? (0, _3_types_js_1.selfDestructOptionToInt)(params.selfDestruct) : undefined };
515
583
  }
516
584
  else {
517
- const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(photo, params, null, false);
585
+ const file = await this.#c.fileManager.upload(photo, params, null, false);
518
586
  media = { _: "inputMediaUploadedPhoto", file, spoiler, ttl_seconds: (params && "selfDestruct" in params && params.selfDestruct !== undefined) ? (0, _3_types_js_1.selfDestructOptionToInt)(params.selfDestruct) : undefined };
519
587
  }
520
588
  }
521
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendMedia).call(this, chatId, media, params);
589
+ const message = await this.#sendMedia(chatId, media, params);
522
590
  return (0, _3_types_js_2.assertMessageType)(message, "photo");
523
591
  }
592
+ async #sendMedia(chatId, media, params) {
593
+ if (params?.starCount !== undefined) {
594
+ if (params.starCount <= 0) {
595
+ throw new _0_errors_js_1.InputError("starCount cannot be zero or negative");
596
+ }
597
+ media = { _: "inputMediaPaidMedia", stars_amount: BigInt(params.starCount), extended_media: [media] };
598
+ }
599
+ const peer = await this.#c.getInputPeer(chatId);
600
+ const randomId = (0, _1_utilities_js_1.getRandomId)();
601
+ const silent = params?.disableNotification ? true : undefined;
602
+ const noforwards = params?.protectContent ? true : undefined;
603
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
604
+ const replyMarkup = await this.#constructReplyMarkup(params);
605
+ const caption_ = params?.caption;
606
+ const parseResult = caption_ !== undefined ? await this.parseText(caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
607
+ const caption = parseResult === undefined ? undefined : parseResult[0];
608
+ const captionEntities = parseResult === undefined ? undefined : parseResult[1];
609
+ const result = await this.#c.invoke({
610
+ _: "messages.sendMedia",
611
+ peer,
612
+ random_id: randomId,
613
+ silent,
614
+ noforwards,
615
+ reply_markup: replyMarkup,
616
+ reply_to: await this.#constructReplyTo(params),
617
+ send_as: sendAs,
618
+ media,
619
+ message: caption ?? "",
620
+ entities: captionEntities,
621
+ effect: params?.effectId ? BigInt(params.effectId) : undefined,
622
+ schedule_date: params?.sendAt,
623
+ allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
624
+ }, { businessConnectionId: params?.businessConnectionId });
625
+ return (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
626
+ }
524
627
  resolveFileId(maybeFileId, expectedFileType) {
525
628
  expectedFileType = Array.isArray(expectedFileType) ? expectedFileType : [expectedFileType];
526
629
  let fileId = null;
@@ -528,7 +631,7 @@ class MessageManager {
528
631
  fileId = (0, _3_types_js_1.deserializeFileId)(maybeFileId);
529
632
  }
530
633
  catch (err) {
531
- __classPrivateFieldGet(this, _MessageManager_LresolveFileId, "f").warning(err);
634
+ this.#LresolveFileId.warning(err);
532
635
  }
533
636
  if (fileId != null) {
534
637
  if (!expectedFileType.includes(fileId.type)) {
@@ -543,7 +646,7 @@ class MessageManager {
543
646
  return null;
544
647
  }
545
648
  async sendPoll(chatId, question, options, params) {
546
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
649
+ this.#checkParams(params);
547
650
  question = question?.trim();
548
651
  if (!question) {
549
652
  throw new Error("Question must not be empty.");
@@ -551,12 +654,12 @@ class MessageManager {
551
654
  if (!Array.isArray(options) || options.length < 2) {
552
655
  throw new Error("There must be at least two options.");
553
656
  }
554
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
657
+ const peer = await this.#c.getInputPeer(chatId);
555
658
  const randomId = (0, _1_utilities_js_1.getRandomId)();
556
659
  const silent = params?.disableNotification ? true : undefined;
557
660
  const noforwards = params?.protectContent ? true : undefined;
558
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
559
- const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
661
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
662
+ const replyMarkup = await this.#constructReplyMarkup(params);
560
663
  const explanation = params?.explanation;
561
664
  const parseResult = explanation !== undefined ? await this.parseText(explanation, { parseMode: params?.explanationParseMode, entities: params?.explanationEntities }) : undefined;
562
665
  const solution = parseResult === undefined ? undefined : parseResult[0];
@@ -570,14 +673,14 @@ class MessageManager {
570
673
  const questionParseResult = await this.parseText(question, { parseMode: params?.questionParseMode, entities: params?.questionEntities });
571
674
  const poll = { _: "poll", id: (0, _1_utilities_js_1.getRandomId)(), answers, question: { _: "textWithEntities", text: questionParseResult[0], entities: questionParseResult[1] ?? [] }, closed: params?.isClosed ? true : undefined, close_date: params?.closeDate, close_period: params?.openPeriod ? params.openPeriod : undefined, multiple_choice: params?.allowMultipleAnswers ? true : undefined, public_voters: params?.isAnonymous === false ? true : undefined, quiz: params?.type == "quiz" ? true : undefined };
572
675
  const media = { _: "inputMediaPoll", poll, correct_answers: params?.correctOptionIndex !== undefined ? [(0, _1_utilities_js_1.encodeText)(String(params.correctOptionIndex))] : undefined, solution, solution_entities: solutionEntities };
573
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
676
+ const result = await this.#c.invoke({
574
677
  _: "messages.sendMedia",
575
678
  peer,
576
679
  random_id: randomId,
577
680
  silent,
578
681
  noforwards,
579
682
  reply_markup: replyMarkup,
580
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
683
+ reply_to: await this.#constructReplyTo(params),
581
684
  send_as: sendAs,
582
685
  media,
583
686
  message: "",
@@ -589,26 +692,26 @@ class MessageManager {
589
692
  return (0, _3_types_js_2.assertMessageType)(message, "poll");
590
693
  }
591
694
  async editMessageReplyMarkup(chatId, messageId, params) {
592
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
593
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
695
+ this.#checkParams(params);
696
+ const result = await this.#c.invoke({
594
697
  _: "messages.editMessage",
595
698
  id: (0, _0_utilities_js_1.checkMessageId)(messageId),
596
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
597
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
699
+ peer: await this.#c.getInputPeer(chatId),
700
+ reply_markup: await this.#constructReplyMarkup(params),
598
701
  }, { businessConnectionId: params?.businessConnectionId });
599
702
  const message_ = (await this.updatesToMessages(chatId, result))[0];
600
703
  return message_;
601
704
  }
602
705
  async editInlineMessageReplyMarkup(inlineMessageId, params) {
603
706
  const id = await (0, _3_types_js_2.deserializeInlineMessageId)(inlineMessageId);
604
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
707
+ await this.#c.invoke({
605
708
  _: "messages.editInlineBotMessage",
606
709
  id,
607
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
710
+ reply_markup: await this.#constructReplyMarkup(params),
608
711
  }, { dc: (0, _3_transport_js_1.getDc)(id.dc_id) });
609
712
  }
610
713
  async editMessageText(chatId, messageId, text, params) {
611
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
714
+ this.#checkParams(params);
612
715
  {
613
716
  const message = await this.getMessage(chatId, messageId);
614
717
  if (!message) {
@@ -631,27 +734,28 @@ class MessageManager {
631
734
  if (!noWebpage && params?.linkPreview?.url) {
632
735
  media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.largeMedia ? true : undefined, force_small_media: params.linkPreview.smallMedia ? true : undefined, optional: message.length ? undefined : true };
633
736
  }
634
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
737
+ const result = await this.#c.invoke({
635
738
  _: "messages.editMessage",
636
739
  id: (0, _0_utilities_js_1.checkMessageId)(messageId),
637
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
740
+ peer: await this.#c.getInputPeer(chatId),
638
741
  entities,
639
742
  message,
640
743
  media,
641
744
  no_webpage: noWebpage,
642
745
  invert_media: invertMedia,
643
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
746
+ reply_markup: await this.#constructReplyMarkup(params),
644
747
  }, { businessConnectionId: params?.businessConnectionId });
645
748
  const message_ = (await this.updatesToMessages(chatId, result))[0];
646
749
  return (0, _3_types_js_2.assertMessageType)(message_, "text");
647
750
  }
751
+ static #CAPTIONABLE_MESSAGE_TYPES = ["photo", "document", "video", "animation", "voice", "audio", "video"];
648
752
  async editMessageCaption(chatId, messageId, params) {
649
753
  let canHaveCaption = false;
650
754
  const message_ = await this.getMessage(chatId, messageId);
651
755
  if (!message_) {
652
756
  throw new _0_errors_js_1.InputError("Message not found.");
653
757
  }
654
- for (const type of __classPrivateFieldGet(_a, _a, "f", _MessageManager_CAPTIONABLE_MESSAGE_TYPES)) {
758
+ for (const type of MessageManager.#CAPTIONABLE_MESSAGE_TYPES) {
655
759
  if ((0, _3_types_js_1.isMessageType)(message_, type)) {
656
760
  canHaveCaption = true;
657
761
  }
@@ -660,24 +764,133 @@ class MessageManager {
660
764
  throw new _0_errors_js_1.InputError("The referenced message cannot have a caption.");
661
765
  }
662
766
  const [message, entities] = await this.parseText(params?.caption ?? "", params);
663
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
767
+ const result = await this.#c.invoke({
664
768
  _: "messages.editMessage",
665
769
  id: (0, _0_utilities_js_1.checkMessageId)(messageId),
666
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
770
+ peer: await this.#c.getInputPeer(chatId),
667
771
  entities: message ? entities : [],
668
772
  message,
669
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
773
+ reply_markup: await this.#constructReplyMarkup(params),
670
774
  }, { businessConnectionId: params?.businessConnectionId });
671
775
  return (await this.updatesToMessages(chatId, result))[0];
672
776
  }
777
+ async #editInlineMessageTextInner(inlineMessageId, text, params, allowEmpty = true) {
778
+ this.#checkParams(params);
779
+ const [message, entities] = await this.parseText(text, params);
780
+ if (!allowEmpty && !message) {
781
+ throw new _0_errors_js_1.InputError("Message text cannot be empty.");
782
+ }
783
+ const id = await (0, _3_types_js_2.deserializeInlineMessageId)(inlineMessageId);
784
+ if (params?.linkPreview && params.linkPreview.type != "input") {
785
+ throw new _0_errors_js_1.InputError("Expected link preview of type input.");
786
+ }
787
+ const noWebpage = params?.linkPreview && params.linkPreview.type == "input" && params.linkPreview.disable ? true : undefined;
788
+ const invertMedia = params?.linkPreview?.aboveText ? true : undefined;
789
+ let media = undefined;
790
+ if (!noWebpage && params?.linkPreview?.url) {
791
+ media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.largeMedia ? true : undefined, force_small_media: params.linkPreview.smallMedia ? true : undefined, optional: message.length ? undefined : true };
792
+ }
793
+ await this.#c.invoke({
794
+ _: "messages.editInlineBotMessage",
795
+ id,
796
+ entities,
797
+ message,
798
+ media,
799
+ no_webpage: noWebpage,
800
+ invert_media: invertMedia,
801
+ reply_markup: await this.#constructReplyMarkup(params),
802
+ }, { dc: (0, _3_transport_js_1.getDc)(id.dc_id) });
803
+ }
673
804
  async editInlineMessageText(inlineMessageId, text, params) {
674
- await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_editInlineMessageTextInner).call(this, inlineMessageId, text, params, false);
805
+ await this.#editInlineMessageTextInner(inlineMessageId, text, params, false);
675
806
  }
676
807
  async editInlineMessageCaption(inlineMessageId, params) {
677
- await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_editInlineMessageTextInner).call(this, inlineMessageId, params?.caption ?? "", params);
808
+ await this.#editInlineMessageTextInner(inlineMessageId, params?.caption ?? "", params);
809
+ }
810
+ async #resolveInputMediaInner(document, media, fileType, otherAttribs) {
811
+ let media_ = null;
812
+ const spoiler = "hasSpoiler" in media && media.hasSpoiler ? true : undefined;
813
+ if (typeof document === "string") {
814
+ const fileId = this.resolveFileId(document, fileType);
815
+ if (fileId != null) {
816
+ media_ = { _: "inputMediaDocument", id: { ...fileId, _: "inputDocument" }, spoiler, query: otherAttribs.find((v) => _2_tl_js_1.Api.is("documentAttributeSticker", v))?.alt || undefined };
817
+ }
818
+ }
819
+ if (media_ == null) {
820
+ if (typeof document === "string" && (0, _0_utilities_js_1.isHttpUrl)(document)) {
821
+ media_ = { _: "inputMediaDocumentExternal", url: document, spoiler };
822
+ }
823
+ else {
824
+ let mimeType;
825
+ const file = await this.#c.fileManager.upload(document, media, (name) => {
826
+ mimeType = media?.mimeType ?? (0, _0_deps_js_1.contentType)(name.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE;
827
+ if (name.endsWith(".tgs") && fileType == _3_types_js_2.FileType.Document) {
828
+ name += "-";
829
+ }
830
+ return name;
831
+ });
832
+ if (_2_tl_js_1.Api.is("inputFileStoryDocument", file)) {
833
+ (0, _0_deps_js_1.unreachable)();
834
+ }
835
+ let thumb = undefined;
836
+ if ("thumbnail" in media && media.thumbnail) {
837
+ thumb = await this.#c.fileManager.upload(media.thumbnail, { chunkSize: media?.chunkSize, signal: media?.signal });
838
+ }
839
+ media_ = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType == _3_types_js_2.FileType.Document ? true : undefined };
840
+ }
841
+ }
842
+ return media_;
843
+ }
844
+ async #resolveInputMedia(media) {
845
+ if ("animation" in media) {
846
+ return await this.#resolveInputMediaInner(media.animation, media, _3_types_js_2.FileType.Animation, [
847
+ { _: "documentAttributeAnimated" },
848
+ { _: "documentAttributeVideo", supports_streaming: true, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
849
+ ]);
850
+ }
851
+ else if ("audio" in media) {
852
+ return await this.#resolveInputMediaInner(media.audio, media, _3_types_js_2.FileType.Audio, [
853
+ { _: "documentAttributeAudio", duration: media?.duration ?? 0, performer: media?.performer, title: media?.title },
854
+ ]);
855
+ }
856
+ else if ("document" in media) {
857
+ return await this.#resolveInputMediaInner(media.document, media, _3_types_js_2.FileType.Document, []);
858
+ }
859
+ else if ("photo" in media) {
860
+ let media_ = null;
861
+ const spoiler = media.hasSpoiler ? true : undefined;
862
+ const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(media.selfDestruct) : undefined;
863
+ if (typeof media.photo === "string") {
864
+ const fileId = this.resolveFileId(media.photo, [_3_types_js_2.FileType.Photo, _3_types_js_2.FileType.ProfilePhoto]);
865
+ if (fileId != null) {
866
+ media_ = { _: "inputMediaPhoto", id: { ...fileId, _: "inputPhoto" }, spoiler, ttl_seconds };
867
+ }
868
+ }
869
+ if (media_ == null) {
870
+ if (typeof media.photo === "string" && (0, _0_utilities_js_1.isHttpUrl)(media.photo)) {
871
+ media_ = { _: "inputMediaPhotoExternal", url: media.photo, spoiler };
872
+ }
873
+ else {
874
+ const file = await this.#c.fileManager.upload(media.photo, media, null, false);
875
+ media_ = { _: "inputMediaUploadedPhoto", file, spoiler, ttl_seconds };
876
+ }
877
+ }
878
+ return media_;
879
+ }
880
+ else if ("video" in media) {
881
+ const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(media.selfDestruct) : undefined;
882
+ const media_ = await this.#resolveInputMediaInner(media.video, media, _3_types_js_2.FileType.Video, [
883
+ { _: "documentAttributeVideo", supports_streaming: media?.supportsStreaming ? true : undefined, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
884
+ ]);
885
+ media_.ttl_seconds = ttl_seconds;
886
+ return media_;
887
+ }
888
+ else {
889
+ (0, _0_deps_js_1.unreachable)();
890
+ }
678
891
  }
679
892
  async editMessageMedia(chatId, messageId, media, params) {
680
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
893
+ this.#checkParams(params);
681
894
  const message = await this.getMessage(chatId, messageId);
682
895
  if (!message) {
683
896
  throw new _0_errors_js_1.InputError("Message not found.");
@@ -686,12 +899,12 @@ class MessageManager {
686
899
  throw new _0_errors_js_1.InputError("Unexpected message type.");
687
900
  }
688
901
  const [text, entities] = media.caption !== undefined ? await this.parseText(media.caption, { entities: media.captionEntities, parseMode: media.parseMode }) : ["", []];
689
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
902
+ const result = await this.#c.invoke({
690
903
  _: "messages.editMessage",
691
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
904
+ peer: await this.#c.getInputPeer(chatId),
692
905
  id: messageId,
693
- media: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMedia).call(this, media),
694
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
906
+ media: await this.#resolveInputMedia(media),
907
+ reply_markup: await this.#constructReplyMarkup(params),
695
908
  message: text,
696
909
  entities,
697
910
  }, { businessConnectionId: params?.businessConnectionId });
@@ -699,66 +912,69 @@ class MessageManager {
699
912
  return message_;
700
913
  }
701
914
  async editInlineMessageMedia(inlineMessageId, media, params) {
702
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
703
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("editInlineMessageMedia");
915
+ this.#checkParams(params);
916
+ this.#c.storage.assertBot("editInlineMessageMedia");
704
917
  const id = await (0, _3_types_js_2.deserializeInlineMessageId)(inlineMessageId);
705
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
918
+ await this.#c.invoke({
706
919
  _: "messages.editInlineBotMessage",
707
920
  id,
708
- media: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMedia).call(this, media),
709
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
921
+ media: await this.#resolveInputMedia(media),
922
+ reply_markup: await this.#constructReplyMarkup(params),
710
923
  }, { dc: (0, _3_transport_js_1.getDc)(id.dc_id) });
711
924
  }
712
925
  async deleteMessages(chatId, messageIds, params) {
713
926
  (0, _0_utilities_js_1.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
714
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
927
+ const peer = await this.#c.getInputPeer(chatId);
715
928
  if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
716
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.deleteMessages", channel: (0, _0_utilities_js_1.toInputChannel)(peer), id: messageIds });
929
+ await this.#c.invoke({ _: "channels.deleteMessages", channel: (0, _0_utilities_js_1.toInputChannel)(peer), id: messageIds });
717
930
  }
718
931
  else {
719
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.deleteMessages", id: messageIds, revoke: params?.onlyForMe ? undefined : true });
932
+ await this.#c.invoke({ _: "messages.deleteMessages", id: messageIds, revoke: params?.onlyForMe ? undefined : true });
720
933
  }
721
934
  }
722
935
  async deleteScheduledMessages(chatId, messageIds) {
723
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendScheduledMessage");
936
+ this.#c.storage.assertUser("sendScheduledMessage");
724
937
  (0, _0_utilities_js_1.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
725
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
726
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.deleteScheduledMessages", peer, id: messageIds });
938
+ const peer = await this.#c.getInputPeer(chatId);
939
+ await this.#c.invoke({ _: "messages.deleteScheduledMessages", peer, id: messageIds });
727
940
  }
728
941
  async deleteScheduledMessage(chatId, messageId) {
729
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("deleteScheduledMessage");
942
+ this.#c.storage.assertUser("deleteScheduledMessage");
730
943
  return await this.deleteScheduledMessages(chatId, [messageId]);
731
944
  }
732
945
  async sendScheduledMessages(chatId, messageIds) {
733
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendScheduledMessages");
946
+ this.#c.storage.assertUser("sendScheduledMessages");
734
947
  (0, _0_utilities_js_1.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
735
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
736
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.sendScheduledMessages", peer, id: messageIds });
948
+ const peer = await this.#c.getInputPeer(chatId);
949
+ const result = await this.#c.invoke({ _: "messages.sendScheduledMessages", peer, id: messageIds });
737
950
  return await this.updatesToMessages(chatId, result);
738
951
  }
739
952
  async sendScheduledMessage(chatId, messageId) {
740
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendScheduledMessage");
953
+ this.#c.storage.assertUser("sendScheduledMessage");
741
954
  return (await this.sendScheduledMessages(chatId, [messageId]))[0];
742
955
  }
743
956
  async deleteChatMemberMessages(chatId, memberId) {
744
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("deleteChatMemberMessages");
745
- const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
746
- const participant = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(memberId);
747
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.deleteParticipantHistory", channel, participant });
957
+ this.#c.storage.assertUser("deleteChatMemberMessages");
958
+ const channel = await this.#c.getInputChannel(chatId);
959
+ const participant = await this.#c.getInputPeer(memberId);
960
+ await this.#c.invoke({ _: "channels.deleteParticipantHistory", channel, participant });
748
961
  }
749
962
  async pinMessage(chatId, messageId, params) {
750
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
751
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.updatePinnedMessage", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), id: (0, _0_utilities_js_1.checkMessageId)(messageId), silent: params?.disableNotification ? true : undefined, pm_oneside: params?.bothSides ? undefined : true });
963
+ this.#checkParams(params);
964
+ await this.#c.invoke({ _: "messages.updatePinnedMessage", peer: await this.#c.getInputPeer(chatId), id: (0, _0_utilities_js_1.checkMessageId)(messageId), silent: params?.disableNotification ? true : undefined, pm_oneside: params?.bothSides ? undefined : true });
752
965
  }
753
966
  async unpinMessage(chatId, messageId, params) {
754
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
755
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.updatePinnedMessage", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), id: (0, _0_utilities_js_1.checkMessageId)(messageId), unpin: true }, { businessConnectionId: params?.businessConnectionId });
967
+ this.#checkParams(params);
968
+ await this.#c.invoke({ _: "messages.updatePinnedMessage", peer: await this.#c.getInputPeer(chatId), id: (0, _0_utilities_js_1.checkMessageId)(messageId), unpin: true }, { businessConnectionId: params?.businessConnectionId });
756
969
  }
757
970
  async unpinMessages(chatId) {
758
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.unpinAllMessages", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId) });
971
+ await this.#c.invoke({ _: "messages.unpinAllMessages", peer: await this.#c.getInputPeer(chatId) });
972
+ }
973
+ async #sendReaction(chatId, messageId, reactions, params) {
974
+ await this.#c.invoke({ _: "messages.sendReaction", peer: await this.#c.getInputPeer(chatId), msg_id: (0, _0_utilities_js_1.checkMessageId)(messageId), reaction: reactions.map((v) => (0, _3_types_js_2.reactionToTlObject)(v)), big: params?.big ? true : undefined, add_to_recent: params?.addToRecents ? true : undefined });
759
975
  }
760
976
  async setReactions(chatId, messageId, reactions, params) {
761
- await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendReaction).call(this, chatId, messageId, reactions, params);
977
+ await this.#sendReaction(chatId, messageId, reactions, params);
762
978
  }
763
979
  async addReaction(chatId, messageId, reaction, params) {
764
980
  const message = await this.getMessage(chatId, messageId);
@@ -795,7 +1011,7 @@ class MessageManager {
795
1011
  if (_2_tl_js_1.Api.is("updateNewMessage", update) || _2_tl_js_1.Api.is("updateNewChannelMessage", update) || _2_tl_js_1.Api.is("updateEditMessage", update) || _2_tl_js_1.Api.is("updateEditChannelMessage", update)) {
796
1012
  if (_2_tl_js_1.Api.is("message", update.message) || _2_tl_js_1.Api.is("messageService", update.message)) {
797
1013
  const chatId = _2_tl_js_1.Api.peerToChatId(update.message.peer_id);
798
- await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.setMessage(chatId, update.message.id, update.message);
1014
+ await this.#c.messageStorage.setMessage(chatId, update.message.id, update.message);
799
1015
  }
800
1016
  }
801
1017
  if (_2_tl_js_1.Api.isOneOf([
@@ -811,13 +1027,13 @@ class MessageManager {
811
1027
  const isOutgoing = update.message.out;
812
1028
  let shouldIgnore = false;
813
1029
  if (isOutgoing) {
814
- if (__classPrivateFieldGet(this, _MessageManager_c, "f").outgoingMessages == null) {
815
- __classPrivateFieldGet(this, _MessageManager_c, "f").outgoingMessages = __classPrivateFieldGet(this, _MessageManager_c, "f").storage.accountType == "user" ? "all" : "business";
1030
+ if (this.#c.outgoingMessages == null) {
1031
+ this.#c.outgoingMessages = this.#c.storage.accountType == "user" ? "all" : "business";
816
1032
  }
817
- if (__classPrivateFieldGet(this, _MessageManager_c, "f").outgoingMessages == "none") {
1033
+ if (this.#c.outgoingMessages == "none") {
818
1034
  shouldIgnore = true;
819
1035
  }
820
- else if (__classPrivateFieldGet(this, _MessageManager_c, "f").outgoingMessages == "business") {
1036
+ else if (this.#c.outgoingMessages == "business") {
821
1037
  if (!_2_tl_js_1.Api.is("updateBotNewBusinessMessage", update) && !_2_tl_js_1.Api.is("updateBotEditBusinessMessage", update)) {
822
1038
  shouldIgnore = true;
823
1039
  }
@@ -842,7 +1058,7 @@ class MessageManager {
842
1058
  if (_2_tl_js_1.Api.is("updateDeleteMessages", update)) {
843
1059
  const deletedMessages = new Array();
844
1060
  for (const messageId of update.messages) {
845
- const chatId = await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getMessageChat(messageId);
1061
+ const chatId = await this.#c.messageStorage.getMessageChat(messageId);
846
1062
  if (chatId) {
847
1063
  deletedMessages.push({ chatId, messageId });
848
1064
  }
@@ -855,7 +1071,7 @@ class MessageManager {
855
1071
  const chatId = _2_tl_js_1.Api.getChannelChatId(update.channel_id);
856
1072
  const deletedMessages = new Array();
857
1073
  for (const messageId of update.messages) {
858
- const message = await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getMessage(chatId, messageId);
1074
+ const message = await this.#c.messageStorage.getMessage(chatId, messageId);
859
1075
  if (message != null) {
860
1076
  deletedMessages.push({ chatId, messageId });
861
1077
  }
@@ -874,13 +1090,13 @@ class MessageManager {
874
1090
  }
875
1091
  if (_2_tl_js_1.Api.is("updateTranscribedAudio", update)) {
876
1092
  const voiceTranscription = (0, _3_types_js_1.constructVoiceTranscription)(update);
877
- await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.setVoiceTranscription(voiceTranscription);
1093
+ await this.#c.messageStorage.setVoiceTranscription(voiceTranscription);
878
1094
  return { voiceTranscription };
879
1095
  }
880
1096
  return null;
881
1097
  }
882
1098
  async sendChatAction(chatId, action, params) {
883
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
1099
+ this.#checkParams(params);
884
1100
  let action_;
885
1101
  switch (action) {
886
1102
  case "type":
@@ -919,11 +1135,11 @@ class MessageManager {
919
1135
  default:
920
1136
  throw new _0_errors_js_1.InputError(`Invalid chat action: ${action}`);
921
1137
  }
922
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.setTyping", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId }, { businessConnectionId: params?.businessConnectionId });
1138
+ await this.#c.invoke({ _: "messages.setTyping", peer: await this.#c.getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId }, { businessConnectionId: params?.businessConnectionId });
923
1139
  }
924
1140
  async searchMessages(chatId, query, params) {
925
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("searchMessages");
926
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.search", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), q: query, add_offset: 0, filter: (0, _0_message_search_filter_js_1.messageSearchFilterToTlObject)(params?.filter ?? "empty"), hash: 0n, limit: (0, _0_utilities_js_1.getLimit)(params?.limit), max_date: 0, max_id: 0, min_date: 0, min_id: 0, offset_id: params?.after ? params.after : 0, from_id: params?.from ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.from) : undefined });
1141
+ this.#c.storage.assertUser("searchMessages");
1142
+ const result = await this.#c.invoke({ _: "messages.search", peer: await this.#c.getInputPeer(chatId), q: query, add_offset: 0, filter: (0, _0_message_search_filter_js_1.messageSearchFilterToTlObject)(params?.filter ?? "empty"), hash: 0n, limit: (0, _0_utilities_js_1.getLimit)(params?.limit), max_date: 0, max_id: 0, min_date: 0, min_id: 0, offset_id: params?.after ? params.after : 0, from_id: params?.from ? await this.#c.getInputPeer(params.from) : undefined });
927
1143
  if (!("messages" in result)) {
928
1144
  (0, _0_deps_js_1.unreachable)();
929
1145
  }
@@ -935,25 +1151,25 @@ class MessageManager {
935
1151
  return messages;
936
1152
  }
937
1153
  async blockUser(userId) {
938
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("blockUser");
939
- const id = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId);
940
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "contacts.block", id });
1154
+ this.#c.storage.assertUser("blockUser");
1155
+ const id = await this.#c.getInputPeer(userId);
1156
+ await this.#c.invoke({ _: "contacts.block", id });
941
1157
  }
942
1158
  async unblockUser(userId) {
943
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("unblockUser");
944
- const id = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId);
945
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "contacts.unblock", id });
1159
+ this.#c.storage.assertUser("unblockUser");
1160
+ const id = await this.#c.getInputPeer(userId);
1161
+ await this.#c.invoke({ _: "contacts.unblock", id });
946
1162
  }
947
1163
  async setChatStickerSet(chatId, setName) {
948
- const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
949
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetShortName", short_name: setName } });
1164
+ const channel = await this.#c.getInputChannel(chatId);
1165
+ await this.#c.invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetShortName", short_name: setName } });
950
1166
  }
951
1167
  async deleteChatStickerSet(chatId) {
952
- const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
953
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetEmpty" } });
1168
+ const channel = await this.#c.getInputChannel(chatId);
1169
+ await this.#c.invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetEmpty" } });
954
1170
  }
955
1171
  async stopPoll(chatId, messageId, params) {
956
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
1172
+ this.#checkParams(params);
957
1173
  const message = await this.getMessage(chatId, messageId);
958
1174
  if (!message) {
959
1175
  throw new _0_errors_js_1.InputError("Message not found.");
@@ -964,26 +1180,26 @@ class MessageManager {
964
1180
  if (message.poll.isClosed) {
965
1181
  throw new _0_errors_js_1.InputError("Poll is already stopped.");
966
1182
  }
967
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1183
+ const result = await this.#c.invoke({
968
1184
  _: "messages.editMessage",
969
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
1185
+ peer: await this.#c.getInputPeer(chatId),
970
1186
  id: messageId,
971
1187
  media: ({ _: "inputMediaPoll", poll: ({ _: "poll", id: BigInt(message.poll.id), closed: true, question: { _: "textWithEntities", text: "", entities: [] }, answers: [] }) }),
972
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
1188
+ reply_markup: await this.#constructReplyMarkup(params),
973
1189
  }, { businessConnectionId: params?.businessConnectionId });
974
1190
  const message_ = (await this.updatesToMessages(chatId, result))[0];
975
1191
  return (0, _3_types_js_2.assertMessageType)(message_, "poll").poll;
976
1192
  }
977
1193
  async editMessageLiveLocation(chatId, messageId, latitude, longitude, params) {
978
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
1194
+ this.#checkParams(params);
979
1195
  const message = await this.getMessage(chatId, messageId);
980
1196
  if (message && "location" in message && message.location.livePeriod) {
981
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1197
+ const result = await this.#c.invoke({
982
1198
  _: "messages.editMessage",
983
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
1199
+ peer: await this.#c.getInputPeer(chatId),
984
1200
  id: messageId,
985
1201
  media: ({ _: "inputMediaGeoLive", geo_point: ({ _: "inputGeoPoint", lat: latitude, long: longitude, accuracy_radius: params?.horizontalAccuracy }), heading: params?.heading, proximity_notification_radius: params?.proximityAlertRadius }),
986
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
1202
+ reply_markup: await this.#constructReplyMarkup(params),
987
1203
  }, { businessConnectionId: params?.businessConnectionId });
988
1204
  const message = (await this.updatesToMessages(chatId, result))[0];
989
1205
  return (0, _3_types_js_2.assertMessageType)(message, "location");
@@ -991,19 +1207,19 @@ class MessageManager {
991
1207
  (0, _0_deps_js_1.unreachable)();
992
1208
  }
993
1209
  async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
994
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
995
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("editInlineMessageLiveLocation");
1210
+ this.#checkParams(params);
1211
+ this.#c.storage.assertBot("editInlineMessageLiveLocation");
996
1212
  const id = await (0, _3_types_js_2.deserializeInlineMessageId)(inlineMessageId);
997
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1213
+ await this.#c.invoke({
998
1214
  _: "messages.editInlineBotMessage",
999
1215
  id,
1000
1216
  media: ({ _: "inputMediaGeoLive", geo_point: ({ _: "inputGeoPoint", lat: latitude, long: longitude, accuracy_radius: params?.horizontalAccuracy }), heading: params?.heading, proximity_notification_radius: params?.proximityAlertRadius }),
1001
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
1217
+ reply_markup: await this.#constructReplyMarkup(params),
1002
1218
  }, { dc: (0, _3_transport_js_1.getDc)(id.dc_id) });
1003
1219
  }
1004
1220
  async sendInvoice(chatId, title, description, payload, currency, prices, params) {
1005
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("sendInvoice");
1006
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
1221
+ this.#c.storage.assertBot("sendInvoice");
1222
+ this.#checkParams(params);
1007
1223
  if (title.length < 1) {
1008
1224
  throw new _0_errors_js_1.InputError("Invoice title cannot be empty.");
1009
1225
  }
@@ -1030,7 +1246,7 @@ class MessageManager {
1030
1246
  phone_to_provider: params?.sendPhoneNumberToProvider || undefined,
1031
1247
  flexible: params?.flexible || undefined,
1032
1248
  };
1033
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendMedia).call(this, chatId, {
1249
+ const message = await this.#sendMedia(chatId, {
1034
1250
  _: "inputMediaInvoice",
1035
1251
  title,
1036
1252
  description,
@@ -1056,7 +1272,7 @@ class MessageManager {
1056
1272
  return (0, _3_types_js_2.assertMessageType)(message, "invoice");
1057
1273
  }
1058
1274
  async sendMediaGroup(chatId, media, params) {
1059
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
1275
+ this.#checkParams(params);
1060
1276
  {
1061
1277
  if (!Array.isArray(media) || !media.length) {
1062
1278
  throw new _0_errors_js_1.InputError("Media group must not be empty.");
@@ -1082,25 +1298,25 @@ class MessageManager {
1082
1298
  for (const v of media) {
1083
1299
  const randomId = (0, _1_utilities_js_1.getRandomId)();
1084
1300
  const [message, entities] = v.caption !== undefined ? await this.parseText(v.caption, { entities: v.captionEntities, parseMode: v.parseMode }) : ["", []];
1085
- multiMedia.push({ _: "inputSingleMedia", message, entities, random_id: randomId, media: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMedia).call(this, v) });
1301
+ multiMedia.push({ _: "inputSingleMedia", message, entities, random_id: randomId, media: await this.#resolveInputMedia(v) });
1086
1302
  }
1087
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
1303
+ const peer = await this.#c.getInputPeer(chatId);
1088
1304
  for (const [i, media_] of multiMedia.entries()) {
1089
1305
  if (_2_tl_js_1.Api.is("inputMediaUploadedPhoto", media_.media)) {
1090
- const result = _2_tl_js_1.Api.as("messageMediaPhoto", await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.uploadMedia", media: media_.media, peer }));
1306
+ const result = _2_tl_js_1.Api.as("messageMediaPhoto", await this.#c.invoke({ _: "messages.uploadMedia", media: media_.media, peer }));
1091
1307
  const photo = _2_tl_js_1.Api.as("photo", result.photo);
1092
1308
  multiMedia[i] = { ...media_, media: { _: "inputMediaPhoto", id: { ...photo, _: "inputPhoto" } } };
1093
1309
  }
1094
1310
  else if (_2_tl_js_1.Api.is("inputMediaUploadedDocument", media_.media)) {
1095
- const result = _2_tl_js_1.Api.as("messageMediaDocument", await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.uploadMedia", media: media_.media, peer }));
1311
+ const result = _2_tl_js_1.Api.as("messageMediaDocument", await this.#c.invoke({ _: "messages.uploadMedia", media: media_.media, peer }));
1096
1312
  const document = _2_tl_js_1.Api.as("document", result.document);
1097
1313
  multiMedia[i] = { ...media_, media: { _: "inputMediaDocument", id: { ...document, _: "inputDocument" } } };
1098
1314
  }
1099
1315
  }
1100
1316
  const silent = params?.disableNotification ? true : undefined;
1101
1317
  const noforwards = params?.protectContent ? true : undefined;
1102
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
1103
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1318
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
1319
+ const result = await this.#c.invoke({
1104
1320
  _: "messages.sendMultiMedia",
1105
1321
  peer,
1106
1322
  multi_media: multiMedia,
@@ -1108,19 +1324,19 @@ class MessageManager {
1108
1324
  noforwards,
1109
1325
  silent,
1110
1326
  send_as: sendAs,
1111
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
1327
+ reply_to: await this.#constructReplyTo(params),
1112
1328
  allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
1113
1329
  });
1114
1330
  return await this.updatesToMessages(chatId, result);
1115
1331
  }
1116
1332
  async readMessages(chatId, untilMessageId) {
1117
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("readMessages");
1118
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
1333
+ this.#c.storage.assertUser("readMessages");
1334
+ const peer = await this.#c.getInputPeer(chatId);
1119
1335
  const max_id = untilMessageId;
1120
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.readHistory", peer, max_id });
1336
+ await this.#c.invoke({ _: "messages.readHistory", peer, max_id });
1121
1337
  }
1122
1338
  async startBot(botId, params) {
1123
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("startBot");
1339
+ this.#c.storage.assertUser("startBot");
1124
1340
  const start_param = params?.deeplink?.trim() || "";
1125
1341
  if (params?.chatId !== undefined && !start_param) {
1126
1342
  throw new _0_errors_js_1.InputError("deeplink cannot be unspecified while chatId is specified.");
@@ -1128,13 +1344,13 @@ class MessageManager {
1128
1344
  if (!params?.deeplink) {
1129
1345
  return await this.sendMessage(botId, "/start");
1130
1346
  }
1131
- const bot = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputUser(botId);
1132
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params?.chatId || botId);
1133
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.startBot", bot, peer, random_id: (0, _1_utilities_js_1.getRandomId)(), start_param });
1347
+ const bot = await this.#c.getInputUser(botId);
1348
+ const peer = await this.#c.getInputPeer(params?.chatId || botId);
1349
+ const result = await this.#c.invoke({ _: "messages.startBot", bot, peer, random_id: (0, _1_utilities_js_1.getRandomId)(), start_param });
1134
1350
  return (await this.updatesToMessages(botId, result))[0];
1135
1351
  }
1136
1352
  async transcribeVoice(chatId, messageId) {
1137
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("transcribeVoice");
1353
+ this.#c.storage.assertUser("transcribeVoice");
1138
1354
  const message = await this.getMessage(chatId, messageId);
1139
1355
  if (message == null) {
1140
1356
  throw new _0_errors_js_1.InputError("Message not found.");
@@ -1142,16 +1358,32 @@ class MessageManager {
1142
1358
  if (!(0, _3_types_js_1.isMessageType)(message, "voice")) {
1143
1359
  throw new _0_errors_js_1.InputError("Message not voice.");
1144
1360
  }
1145
- const cachedTranscription = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_getCachedVoiceTranscription).call(this, message);
1361
+ const cachedTranscription = await this.#getCachedVoiceTranscription(message);
1146
1362
  if (cachedTranscription) {
1147
1363
  return cachedTranscription;
1148
1364
  }
1149
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
1150
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.transcribeAudio", peer, msg_id: messageId });
1151
- return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_cacheVoiceTranscription).call(this, message, (0, _3_types_js_1.constructVoiceTranscription)(result));
1365
+ const peer = await this.#c.getInputPeer(chatId);
1366
+ const result = await this.#c.invoke({ _: "messages.transcribeAudio", peer, msg_id: messageId });
1367
+ return await this.#cacheVoiceTranscription(message, (0, _3_types_js_1.constructVoiceTranscription)(result));
1368
+ }
1369
+ async #getCachedVoiceTranscription(message) {
1370
+ const reference = await this.#c.messageStorage.getVoiceTranscriptionReference(message.chat.id, message.id, (0, _1_utilities_js_1.fromUnixTimestamp)(message.editDate ?? message.date));
1371
+ if (!reference) {
1372
+ return null;
1373
+ }
1374
+ const voiceTranscription = await this.#c.messageStorage.getVoiceTranscription(reference);
1375
+ if (!voiceTranscription || !voiceTranscription.done) {
1376
+ return null;
1377
+ }
1378
+ return voiceTranscription;
1379
+ }
1380
+ async #cacheVoiceTranscription(message, voiceTranscription) {
1381
+ await this.#c.messageStorage.setVoiceTranscriptionReference(message.chat.id, message.id, (0, _1_utilities_js_1.fromUnixTimestamp)(message.editDate ?? message.date), BigInt(voiceTranscription.id));
1382
+ await this.#c.messageStorage.setVoiceTranscription(voiceTranscription);
1383
+ return voiceTranscription;
1152
1384
  }
1153
1385
  async resolveMessageLink(link) {
1154
- const parseResult = _a.parseMessageLink(link);
1386
+ const parseResult = MessageManager.parseMessageLink(link);
1155
1387
  if (parseResult == null) {
1156
1388
  throw new _0_errors_js_1.InputError("Invalid messsage link.");
1157
1389
  }
@@ -1238,20 +1470,20 @@ class MessageManager {
1238
1470
  return [peer, id];
1239
1471
  }
1240
1472
  async openMiniApp(botId, chatId, params) {
1241
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("openMiniApp");
1473
+ this.#c.storage.assertUser("openMiniApp");
1242
1474
  const from_bot_menu = params?.fromMenu ? true : undefined;
1243
1475
  const silent = params?.disableNotification ? true : undefined;
1244
1476
  const compact = params?.mode === "compact" ? true : undefined;
1245
1477
  const fullscreen = params?.mode === "fullscreen" ? true : undefined;
1246
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
1247
- const bot = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputUser(botId);
1478
+ const peer = await this.#c.getInputPeer(chatId);
1479
+ const bot = await this.#c.getInputUser(botId);
1248
1480
  const url = params?.url;
1249
1481
  const start_param = params?.startParameter;
1250
1482
  const theme_params = params?.themeParameters ? { _: "dataJSON", data: params.themeParameters } : undefined;
1251
- const platform = __classPrivateFieldGet(this, _MessageManager_c, "f").langPack ?? "";
1252
- const reply_to = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params);
1253
- const send_as = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
1254
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1483
+ const platform = this.#c.langPack ?? "";
1484
+ const reply_to = await this.#constructReplyTo(params);
1485
+ const send_as = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
1486
+ const result = await this.#c.invoke({
1255
1487
  _: "messages.requestWebView",
1256
1488
  from_bot_menu,
1257
1489
  silent,
@@ -1270,242 +1502,3 @@ class MessageManager {
1270
1502
  }
1271
1503
  }
1272
1504
  exports.MessageManager = MessageManager;
1273
- _a = MessageManager, _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(), _MessageManager_instances = new WeakSet(), _MessageManager_checkParams = function _MessageManager_checkParams(params) {
1274
- if (params && "replyMarkup" in params && params.replyMarkup !== undefined) {
1275
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("replyMarkup");
1276
- }
1277
- if (params && "businessConnectionId" in params && params.businessConnectionId !== undefined) {
1278
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("businessConnectionId");
1279
- }
1280
- if (params && "sendAs" in params && params.sendAs !== undefined) {
1281
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendAs");
1282
- }
1283
- if (params && "sendAt" in params && params.sendAt !== undefined) {
1284
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("businessConsendAtnectionId");
1285
- }
1286
- }, _MessageManager_constructReplyMarkup = async function _MessageManager_constructReplyMarkup(params) {
1287
- if (params?.replyMarkup) {
1288
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("replyMarkup");
1289
- return await (0, _3_types_js_2.replyMarkupToTlObject)(params.replyMarkup, this.usernameResolver.bind(this));
1290
- }
1291
- }, _MessageManager_resolveSendAs = async function _MessageManager_resolveSendAs(params) {
1292
- const sendAs = params?.sendAs;
1293
- if (sendAs !== undefined) {
1294
- __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendAs");
1295
- return sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(sendAs) : undefined;
1296
- }
1297
- }, _MessageManager_constructReplyTo = async function _MessageManager_constructReplyTo(params) {
1298
- const topMsgId = params?.messageThreadId;
1299
- if (!params?.replyTo) {
1300
- if (topMsgId) {
1301
- return { _: "inputReplyToMessage", reply_to_msg_id: topMsgId };
1302
- }
1303
- else {
1304
- return undefined;
1305
- }
1306
- }
1307
- if ("messageId" in params.replyTo) {
1308
- return { _: "inputReplyToMessage", reply_to_msg_id: params.replyTo.messageId, top_msg_id: topMsgId, quote_text: params.replyTo.quote?.text, quote_entities: await Promise.all(params.replyTo.quote?.entities.map((v) => (0, _3_types_js_2.messageEntityToTlObject)(v, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity)) ?? []), quote_offset: params.replyTo.quote?.offset };
1309
- }
1310
- else {
1311
- return { _: "inputReplyToStory", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.replyTo.chatId), story_id: params.replyTo.storyId };
1312
- }
1313
- }, _MessageManager_sendDocumentInner = async function _MessageManager_sendDocumentInner(chatId, document, params, fileType, otherAttribs, urlSupported = true, expectedMimeTypes) {
1314
- let media = null;
1315
- const spoiler = params?.hasSpoiler ? true : undefined;
1316
- const ttl_seconds = params && "selfDestruct" in params && typeof params.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(params.selfDestruct) : undefined;
1317
- if (typeof document === "string") {
1318
- const fileId = this.resolveFileId(document, fileType);
1319
- if (fileId != null) {
1320
- media = { _: "inputMediaDocument", id: { ...fileId, _: "inputDocument" }, spoiler, query: otherAttribs.find((v) => _2_tl_js_1.Api.is("documentAttributeSticker", v))?.alt || undefined, ttl_seconds };
1321
- }
1322
- }
1323
- if (media == null) {
1324
- if (typeof document === "string" && (0, _0_utilities_js_1.isHttpUrl)(document)) {
1325
- if (!urlSupported) {
1326
- throw new _0_errors_js_1.InputError("URL not supported.");
1327
- }
1328
- media = { _: "inputMediaDocumentExternal", url: document, spoiler, ttl_seconds };
1329
- }
1330
- else {
1331
- let mimeType;
1332
- const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(document, params, (name) => {
1333
- mimeType = params?.mimeType ?? (0, _0_deps_js_1.contentType)(name.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE;
1334
- if (expectedMimeTypes && !expectedMimeTypes.includes(mimeType)) {
1335
- (0, _0_deps_js_1.unreachable)();
1336
- }
1337
- if (name.endsWith(".tgs") && fileType == _3_types_js_2.FileType.Document) {
1338
- name += "-";
1339
- }
1340
- return name;
1341
- });
1342
- if (_2_tl_js_1.Api.is("inputFileStoryDocument", file)) {
1343
- (0, _0_deps_js_1.unreachable)();
1344
- }
1345
- let thumb = undefined;
1346
- if (params?.thumbnail) {
1347
- thumb = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(params.thumbnail, { chunkSize: params?.chunkSize, signal: params?.signal });
1348
- }
1349
- media = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType == _3_types_js_2.FileType.Document ? true : undefined, ttl_seconds };
1350
- }
1351
- }
1352
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendMedia).call(this, chatId, media, params);
1353
- return message;
1354
- }, _MessageManager_sendMedia = async function _MessageManager_sendMedia(chatId, media, params) {
1355
- if (params?.starCount !== undefined) {
1356
- if (params.starCount <= 0) {
1357
- throw new _0_errors_js_1.InputError("starCount cannot be zero or negative");
1358
- }
1359
- media = { _: "inputMediaPaidMedia", stars_amount: BigInt(params.starCount), extended_media: [media] };
1360
- }
1361
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
1362
- const randomId = (0, _1_utilities_js_1.getRandomId)();
1363
- const silent = params?.disableNotification ? true : undefined;
1364
- const noforwards = params?.protectContent ? true : undefined;
1365
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
1366
- const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
1367
- const caption_ = params?.caption;
1368
- const parseResult = caption_ !== undefined ? await this.parseText(caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
1369
- const caption = parseResult === undefined ? undefined : parseResult[0];
1370
- const captionEntities = parseResult === undefined ? undefined : parseResult[1];
1371
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1372
- _: "messages.sendMedia",
1373
- peer,
1374
- random_id: randomId,
1375
- silent,
1376
- noforwards,
1377
- reply_markup: replyMarkup,
1378
- reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
1379
- send_as: sendAs,
1380
- media,
1381
- message: caption ?? "",
1382
- entities: captionEntities,
1383
- effect: params?.effectId ? BigInt(params.effectId) : undefined,
1384
- schedule_date: params?.sendAt,
1385
- allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
1386
- }, { businessConnectionId: params?.businessConnectionId });
1387
- return (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
1388
- }, _MessageManager_editInlineMessageTextInner = async function _MessageManager_editInlineMessageTextInner(inlineMessageId, text, params, allowEmpty = true) {
1389
- __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
1390
- const [message, entities] = await this.parseText(text, params);
1391
- if (!allowEmpty && !message) {
1392
- throw new _0_errors_js_1.InputError("Message text cannot be empty.");
1393
- }
1394
- const id = await (0, _3_types_js_2.deserializeInlineMessageId)(inlineMessageId);
1395
- if (params?.linkPreview && params.linkPreview.type != "input") {
1396
- throw new _0_errors_js_1.InputError("Expected link preview of type input.");
1397
- }
1398
- const noWebpage = params?.linkPreview && params.linkPreview.type == "input" && params.linkPreview.disable ? true : undefined;
1399
- const invertMedia = params?.linkPreview?.aboveText ? true : undefined;
1400
- let media = undefined;
1401
- if (!noWebpage && params?.linkPreview?.url) {
1402
- media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.largeMedia ? true : undefined, force_small_media: params.linkPreview.smallMedia ? true : undefined, optional: message.length ? undefined : true };
1403
- }
1404
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1405
- _: "messages.editInlineBotMessage",
1406
- id,
1407
- entities,
1408
- message,
1409
- media,
1410
- no_webpage: noWebpage,
1411
- invert_media: invertMedia,
1412
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
1413
- }, { dc: (0, _3_transport_js_1.getDc)(id.dc_id) });
1414
- }, _MessageManager_resolveInputMediaInner = async function _MessageManager_resolveInputMediaInner(document, media, fileType, otherAttribs) {
1415
- let media_ = null;
1416
- const spoiler = "hasSpoiler" in media && media.hasSpoiler ? true : undefined;
1417
- if (typeof document === "string") {
1418
- const fileId = this.resolveFileId(document, fileType);
1419
- if (fileId != null) {
1420
- media_ = { _: "inputMediaDocument", id: { ...fileId, _: "inputDocument" }, spoiler, query: otherAttribs.find((v) => _2_tl_js_1.Api.is("documentAttributeSticker", v))?.alt || undefined };
1421
- }
1422
- }
1423
- if (media_ == null) {
1424
- if (typeof document === "string" && (0, _0_utilities_js_1.isHttpUrl)(document)) {
1425
- media_ = { _: "inputMediaDocumentExternal", url: document, spoiler };
1426
- }
1427
- else {
1428
- let mimeType;
1429
- const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(document, media, (name) => {
1430
- mimeType = media?.mimeType ?? (0, _0_deps_js_1.contentType)(name.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE;
1431
- if (name.endsWith(".tgs") && fileType == _3_types_js_2.FileType.Document) {
1432
- name += "-";
1433
- }
1434
- return name;
1435
- });
1436
- if (_2_tl_js_1.Api.is("inputFileStoryDocument", file)) {
1437
- (0, _0_deps_js_1.unreachable)();
1438
- }
1439
- let thumb = undefined;
1440
- if ("thumbnail" in media && media.thumbnail) {
1441
- thumb = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(media.thumbnail, { chunkSize: media?.chunkSize, signal: media?.signal });
1442
- }
1443
- media_ = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType == _3_types_js_2.FileType.Document ? true : undefined };
1444
- }
1445
- }
1446
- return media_;
1447
- }, _MessageManager_resolveInputMedia = async function _MessageManager_resolveInputMedia(media) {
1448
- if ("animation" in media) {
1449
- return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.animation, media, _3_types_js_2.FileType.Animation, [
1450
- { _: "documentAttributeAnimated" },
1451
- { _: "documentAttributeVideo", supports_streaming: true, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
1452
- ]);
1453
- }
1454
- else if ("audio" in media) {
1455
- return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.audio, media, _3_types_js_2.FileType.Audio, [
1456
- { _: "documentAttributeAudio", duration: media?.duration ?? 0, performer: media?.performer, title: media?.title },
1457
- ]);
1458
- }
1459
- else if ("document" in media) {
1460
- return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.document, media, _3_types_js_2.FileType.Document, []);
1461
- }
1462
- else if ("photo" in media) {
1463
- let media_ = null;
1464
- const spoiler = media.hasSpoiler ? true : undefined;
1465
- const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(media.selfDestruct) : undefined;
1466
- if (typeof media.photo === "string") {
1467
- const fileId = this.resolveFileId(media.photo, [_3_types_js_2.FileType.Photo, _3_types_js_2.FileType.ProfilePhoto]);
1468
- if (fileId != null) {
1469
- media_ = { _: "inputMediaPhoto", id: { ...fileId, _: "inputPhoto" }, spoiler, ttl_seconds };
1470
- }
1471
- }
1472
- if (media_ == null) {
1473
- if (typeof media.photo === "string" && (0, _0_utilities_js_1.isHttpUrl)(media.photo)) {
1474
- media_ = { _: "inputMediaPhotoExternal", url: media.photo, spoiler };
1475
- }
1476
- else {
1477
- const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(media.photo, media, null, false);
1478
- media_ = { _: "inputMediaUploadedPhoto", file, spoiler, ttl_seconds };
1479
- }
1480
- }
1481
- return media_;
1482
- }
1483
- else if ("video" in media) {
1484
- const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(media.selfDestruct) : undefined;
1485
- const media_ = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.video, media, _3_types_js_2.FileType.Video, [
1486
- { _: "documentAttributeVideo", supports_streaming: media?.supportsStreaming ? true : undefined, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
1487
- ]);
1488
- media_.ttl_seconds = ttl_seconds;
1489
- return media_;
1490
- }
1491
- else {
1492
- (0, _0_deps_js_1.unreachable)();
1493
- }
1494
- }, _MessageManager_sendReaction = async function _MessageManager_sendReaction(chatId, messageId, reactions, params) {
1495
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.sendReaction", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), msg_id: (0, _0_utilities_js_1.checkMessageId)(messageId), reaction: reactions.map((v) => (0, _3_types_js_2.reactionToTlObject)(v)), big: params?.big ? true : undefined, add_to_recent: params?.addToRecents ? true : undefined });
1496
- }, _MessageManager_getCachedVoiceTranscription = async function _MessageManager_getCachedVoiceTranscription(message) {
1497
- const reference = await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getVoiceTranscriptionReference(message.chat.id, message.id, (0, _1_utilities_js_1.fromUnixTimestamp)(message.editDate ?? message.date));
1498
- if (!reference) {
1499
- return null;
1500
- }
1501
- const voiceTranscription = await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getVoiceTranscription(reference);
1502
- if (!voiceTranscription || !voiceTranscription.done) {
1503
- return null;
1504
- }
1505
- return voiceTranscription;
1506
- }, _MessageManager_cacheVoiceTranscription = async function _MessageManager_cacheVoiceTranscription(message, voiceTranscription) {
1507
- await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.setVoiceTranscriptionReference(message.chat.id, message.id, (0, _1_utilities_js_1.fromUnixTimestamp)(message.editDate ?? message.date), BigInt(voiceTranscription.id));
1508
- await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.setVoiceTranscription(voiceTranscription);
1509
- return voiceTranscription;
1510
- };
1511
- _MessageManager_CAPTIONABLE_MESSAGE_TYPES = { value: ["photo", "document", "video", "animation", "voice", "audio", "video"] };