@mtkruto/node 0.1.201 → 0.1.301

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 (137) hide show
  1. package/esm/0_deps.d.ts +1 -1
  2. package/esm/0_deps.js +2 -1
  3. package/esm/1_utilities.d.ts +1 -1
  4. package/esm/1_utilities.js +1 -1
  5. package/esm/4_errors.js +3 -3
  6. package/esm/client/0_markdown.js +5 -5
  7. package/esm/client/0_utilities.d.ts +7 -0
  8. package/esm/client/0_utilities.js +47 -4
  9. package/esm/client/1_account_manager.js +4 -4
  10. package/esm/client/1_client_encrypted.js +4 -4
  11. package/esm/client/1_client_plain.js +3 -3
  12. package/esm/client/1_file_manager.js +6 -5
  13. package/esm/client/1_reaction_manager.js +2 -2
  14. package/esm/client/1_update_manager.js +9 -8
  15. package/esm/client/2_message_manager.js +47 -24
  16. package/esm/client/3_callback_query_manager.js +2 -0
  17. package/esm/client/3_chat_list_manager.js +13 -12
  18. package/esm/client/3_inline_query_manager.js +4 -2
  19. package/esm/client/3_story_manager.js +7 -5
  20. package/esm/client/4_client.js +16 -15
  21. package/esm/connection/1_connection_web_socket.js +3 -2
  22. package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.d.ts +0 -1
  23. package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.js +0 -11
  24. package/esm/deps/deno.land/x/tgcrypto@0.4.0/tgcrypto.js +308 -0
  25. package/esm/mod.d.ts +1 -1
  26. package/esm/mod.js +1 -1
  27. package/esm/storage/0_storage.js +6 -5
  28. package/esm/storage/1_utilities.d.ts +0 -1
  29. package/esm/storage/1_utilities.js +2 -3
  30. package/esm/storage/2_storage_local_storage.js +1 -4
  31. package/esm/storage/2_storage_session_storage.js +1 -4
  32. package/esm/tl/3_utilities.js +5 -4
  33. package/esm/transport/2_transport_provider.js +4 -4
  34. package/esm/types/0_message_entity.js +3 -3
  35. package/esm/types/0_message_search_filter.js +2 -2
  36. package/esm/types/0_reaction.js +2 -2
  37. package/esm/types/1_bot_command_scope.js +3 -3
  38. package/esm/types/1_chat_p.js +3 -2
  39. package/esm/types/1_keyboard_button.js +3 -3
  40. package/esm/types/1_message_reaction.js +2 -2
  41. package/esm/types/1_story_privacy.js +3 -3
  42. package/esm/types/2_chat_member.js +6 -5
  43. package/esm/types/2_chosen_inline_result.js +3 -2
  44. package/esm/types/2_inactive_chat.js +3 -2
  45. package/esm/types/2_inline_keyboard_button.js +3 -3
  46. package/esm/types/2_inline_query.js +3 -3
  47. package/esm/types/2_invite_link.js +3 -2
  48. package/esm/types/2_story_content.js +5 -5
  49. package/esm/types/2_story_interactive_area.js +5 -5
  50. package/esm/types/3_chat_member_updated.js +4 -3
  51. package/esm/types/3_reply_markup.js +4 -3
  52. package/esm/types/3_story.js +3 -2
  53. package/esm/types/4_inline_query_result.js +5 -5
  54. package/esm/types/4_message.js +17 -16
  55. package/esm/types/5_callback_query.js +4 -3
  56. package/esm/types/5_chat.js +8 -7
  57. package/esm/types/_file_id.js +9 -8
  58. package/esm/utilities/0_bigint.d.ts +1 -0
  59. package/esm/utilities/0_bigint.js +25 -0
  60. package/esm/utilities/0_logger.d.ts +8 -0
  61. package/esm/utilities/0_logger.js +9 -5
  62. package/esm/utilities/1_math.d.ts +1 -0
  63. package/esm/utilities/1_math.js +51 -0
  64. package/esm/utilities/1_misc.js +2 -2
  65. package/package.json +1 -1
  66. package/script/0_deps.d.ts +1 -1
  67. package/script/0_deps.js +3 -3
  68. package/script/1_utilities.d.ts +1 -1
  69. package/script/1_utilities.js +1 -1
  70. package/script/4_errors.js +3 -3
  71. package/script/client/0_markdown.js +5 -5
  72. package/script/client/0_utilities.d.ts +7 -0
  73. package/script/client/0_utilities.js +54 -4
  74. package/script/client/1_account_manager.js +4 -4
  75. package/script/client/1_client_encrypted.js +2 -2
  76. package/script/client/1_client_plain.js +2 -2
  77. package/script/client/1_file_manager.js +5 -4
  78. package/script/client/1_reaction_manager.js +2 -2
  79. package/script/client/1_update_manager.js +8 -7
  80. package/script/client/2_message_manager.js +51 -28
  81. package/script/client/3_callback_query_manager.js +2 -0
  82. package/script/client/3_chat_list_manager.js +12 -11
  83. package/script/client/3_inline_query_manager.js +4 -2
  84. package/script/client/3_story_manager.js +4 -2
  85. package/script/client/4_client.js +14 -13
  86. package/script/connection/1_connection_web_socket.js +2 -1
  87. package/script/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.d.ts +0 -1
  88. package/script/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.js +1 -13
  89. package/script/deps/deno.land/x/tgcrypto@0.4.0/tgcrypto.js +310 -0
  90. package/script/mod.d.ts +1 -1
  91. package/script/mod.js +2 -1
  92. package/script/storage/0_storage.js +5 -4
  93. package/script/storage/1_utilities.d.ts +0 -1
  94. package/script/storage/1_utilities.js +3 -4
  95. package/script/storage/2_storage_local_storage.js +0 -3
  96. package/script/storage/2_storage_session_storage.js +0 -3
  97. package/script/tl/3_utilities.js +4 -3
  98. package/script/transport/2_transport_provider.js +4 -4
  99. package/script/types/0_message_entity.js +3 -3
  100. package/script/types/0_message_search_filter.js +2 -2
  101. package/script/types/0_reaction.js +2 -2
  102. package/script/types/1_bot_command_scope.js +3 -3
  103. package/script/types/1_chat_p.js +2 -1
  104. package/script/types/1_keyboard_button.js +3 -3
  105. package/script/types/1_message_reaction.js +2 -2
  106. package/script/types/1_story_privacy.js +3 -3
  107. package/script/types/2_chat_member.js +5 -4
  108. package/script/types/2_chosen_inline_result.js +2 -1
  109. package/script/types/2_inactive_chat.js +2 -1
  110. package/script/types/2_inline_keyboard_button.js +3 -3
  111. package/script/types/2_inline_query.js +3 -3
  112. package/script/types/2_invite_link.js +2 -1
  113. package/script/types/2_story_content.js +5 -5
  114. package/script/types/2_story_interactive_area.js +5 -5
  115. package/script/types/3_chat_member_updated.js +3 -2
  116. package/script/types/3_reply_markup.js +3 -2
  117. package/script/types/3_story.js +2 -1
  118. package/script/types/4_inline_query_result.js +5 -5
  119. package/script/types/4_message.js +16 -15
  120. package/script/types/5_callback_query.js +3 -2
  121. package/script/types/5_chat.js +7 -6
  122. package/script/types/_file_id.js +8 -7
  123. package/script/utilities/0_bigint.d.ts +1 -0
  124. package/script/utilities/0_bigint.js +27 -1
  125. package/script/utilities/0_logger.d.ts +8 -0
  126. package/script/utilities/0_logger.js +11 -6
  127. package/script/utilities/1_math.d.ts +1 -0
  128. package/script/utilities/1_math.js +55 -0
  129. package/script/utilities/1_misc.js +2 -2
  130. package/esm/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +0 -324
  131. package/esm/utilities/0_control.d.ts +0 -1
  132. package/esm/utilities/0_control.js +0 -3
  133. package/script/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +0 -326
  134. package/script/utilities/0_control.d.ts +0 -1
  135. package/script/utilities/0_control.js +0 -7
  136. /package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/tgcrypto.d.ts +0 -0
  137. /package/script/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/tgcrypto.d.ts +0 -0
@@ -23,6 +23,8 @@ const _0_message_search_filter_js_1 = require("../types/0_message_search_filter.
23
23
  const _0_html_js_1 = require("./0_html.js");
24
24
  const _0_markdown_js_1 = require("./0_markdown.js");
25
25
  const _0_utilities_js_1 = require("./0_utilities.js");
26
+ const _0_utilities_js_2 = require("./0_utilities.js");
27
+ const _0_utilities_js_3 = require("./0_utilities.js");
26
28
  const FALLBACK_MIME_TYPE = "application/octet-stream";
27
29
  const STICKER_MIME_TYPES = ["image/webp", "video/webm", "application/x-tgsticker"];
28
30
  class MessageManager {
@@ -44,6 +46,7 @@ class MessageManager {
44
46
  __classPrivateFieldSet(this, _MessageManager_LresolveFileId, L.branch("resolveFileId"), "f");
45
47
  }
46
48
  async getMessages(chatId, messageIds) {
49
+ (0, _0_utilities_js_2.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
47
50
  const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
48
51
  let messages_ = new Array();
49
52
  const chatId_ = (0, _2_tl_js_1.peerToChatId)(peer);
@@ -114,7 +117,7 @@ class MessageManager {
114
117
  break;
115
118
  }
116
119
  default:
117
- (0, _1_utilities_js_1.UNREACHABLE)();
120
+ (0, _0_deps_js_1.unreachable)();
118
121
  }
119
122
  text = text.trimEnd();
120
123
  for (const entity of entities) {
@@ -122,6 +125,9 @@ class MessageManager {
122
125
  --entity.length;
123
126
  }
124
127
  }
128
+ if (!text.length) {
129
+ throw new _0_errors_js_1.InputError("Text must not be empty.");
130
+ }
125
131
  return [text, entities];
126
132
  }
127
133
  async parseText(text_, params) {
@@ -133,6 +139,7 @@ class MessageManager {
133
139
  return 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);
134
140
  }
135
141
  async forwardMessages(from, to, messageIds, params) {
142
+ (0, _0_utilities_js_2.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
136
143
  const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.forwardMessages({
137
144
  from_peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(from),
138
145
  to_peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(to),
@@ -176,7 +183,7 @@ class MessageManager {
176
183
  hash: 0n,
177
184
  });
178
185
  if (!("messages" in result)) {
179
- (0, _1_utilities_js_1.UNREACHABLE)();
186
+ (0, _0_deps_js_1.unreachable)();
180
187
  }
181
188
  for (const message_ of result.messages) {
182
189
  const message = await this.constructMessage(message_, false);
@@ -425,11 +432,11 @@ class MessageManager {
425
432
  }
426
433
  }
427
434
  if (media == null) {
428
- if (typeof photo === "string" && (0, _0_utilities_js_1.isHttpUrl)(photo)) {
435
+ if (typeof photo === "string" && (0, _0_utilities_js_3.isHttpUrl)(photo)) {
429
436
  media = new _2_tl_js_1.types.InputMediaPhotoExternal({ url: photo, spoiler });
430
437
  }
431
438
  else {
432
- const [contents, fileName] = await (0, _0_utilities_js_1.getFileContents)(photo);
439
+ const [contents, fileName] = await (0, _0_utilities_js_3.getFileContents)(photo);
433
440
  const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(contents, { fileName, chunkSize: params?.chunkSize, signal: params?.signal });
434
441
  media = new _2_tl_js_1.types.InputMediaUploadedPhoto({ file, spoiler });
435
442
  }
@@ -448,10 +455,10 @@ class MessageManager {
448
455
  }
449
456
  if (fileId != null) {
450
457
  if (!expectedFileType.includes(fileId.type)) {
451
- (0, _1_utilities_js_1.UNREACHABLE)();
458
+ (0, _0_deps_js_1.unreachable)();
452
459
  }
453
460
  return {
454
- id: "id" in fileId.location ? fileId.location.id : (0, _1_utilities_js_1.UNREACHABLE)(),
461
+ id: "id" in fileId.location ? fileId.location.id : (0, _0_deps_js_1.unreachable)(),
455
462
  access_hash: fileId.location.accessHash,
456
463
  file_reference: fileId.fileReference ?? new Uint8Array(),
457
464
  };
@@ -459,6 +466,13 @@ class MessageManager {
459
466
  return null;
460
467
  }
461
468
  async sendPoll(chatId, question, options, params) {
469
+ question = question?.trim();
470
+ if (!question) {
471
+ throw new Error("Question must not be empty.");
472
+ }
473
+ if (!Array.isArray(options) || options.length < 2) {
474
+ throw new Error("There must be at least two options.");
475
+ }
462
476
  const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
463
477
  const randomId = (0, _1_utilities_js_1.getRandomId)();
464
478
  const silent = params?.disableNotification ? true : undefined;
@@ -503,7 +517,7 @@ class MessageManager {
503
517
  }
504
518
  async editMessageReplyMarkup(chatId, messageId, params) {
505
519
  const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editMessage({
506
- id: messageId,
520
+ id: (0, _0_utilities_js_1.checkMessageId)(messageId),
507
521
  peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
508
522
  reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
509
523
  });
@@ -531,7 +545,7 @@ class MessageManager {
531
545
  });
532
546
  }
533
547
  const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editMessage({
534
- id: messageId,
548
+ id: (0, _0_utilities_js_1.checkMessageId)(messageId),
535
549
  peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
536
550
  entities,
537
551
  message,
@@ -568,6 +582,7 @@ class MessageManager {
568
582
  });
569
583
  }
570
584
  async deleteMessages(chatId, messageIds, params) {
585
+ (0, _0_utilities_js_2.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
571
586
  const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
572
587
  if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
573
588
  await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.deleteMessages({ channel: new _2_tl_js_1.types.InputChannel(peer), id: messageIds });
@@ -584,7 +599,7 @@ class MessageManager {
584
599
  async pinMessage(chatId, messageId, params) {
585
600
  await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.updatePinnedMessage({
586
601
  peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
587
- id: messageId,
602
+ id: (0, _0_utilities_js_1.checkMessageId)(messageId),
588
603
  silent: params?.disableNotification ? true : undefined,
589
604
  pm_oneside: params?.bothSides ? undefined : true,
590
605
  });
@@ -592,7 +607,7 @@ class MessageManager {
592
607
  async unpinMessage(chatId, messageId) {
593
608
  await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.updatePinnedMessage({
594
609
  peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
595
- id: messageId,
610
+ id: (0, _0_utilities_js_1.checkMessageId)(messageId),
596
611
  unpin: true,
597
612
  });
598
613
  }
@@ -603,14 +618,18 @@ class MessageManager {
603
618
  // TODO: sync with storage
604
619
  await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.setChatAvailableReactions({
605
620
  peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
606
- available_reactions: availableReactions == "none" ? new _2_tl_js_1.types.ChatReactionsNone() : availableReactions == "all" ? new _2_tl_js_1.types.ChatReactionsAll() : Array.isArray(availableReactions) ? new _2_tl_js_1.types.ChatReactionsSome({ reactions: availableReactions.map((v) => v.type == "emoji" ? new _2_tl_js_1.types.ReactionEmoji({ emoticon: v.emoji }) : new _2_tl_js_1.types.ReactionCustomEmoji({ document_id: BigInt(v.id) })) }) : (0, _1_utilities_js_1.UNREACHABLE)(),
621
+ available_reactions: availableReactions == "none" ? new _2_tl_js_1.types.ChatReactionsNone() : availableReactions == "all" ? new _2_tl_js_1.types.ChatReactionsAll() : Array.isArray(availableReactions) ? new _2_tl_js_1.types.ChatReactionsSome({ reactions: availableReactions.map((v) => v.type == "emoji" ? new _2_tl_js_1.types.ReactionEmoji({ emoticon: v.emoji }) : new _2_tl_js_1.types.ReactionCustomEmoji({ document_id: BigInt(v.id) })) }) : (0, _0_deps_js_1.unreachable)(),
607
622
  });
608
623
  }
609
624
  async setReactions(chatId, messageId, reactions, params) {
610
625
  await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendReaction).call(this, chatId, messageId, reactions, params);
611
626
  }
612
627
  async addReaction(chatId, messageId, reaction, params) {
613
- const chosenReactions = await this.getMessage(chatId, messageId).then((v) => v?.reactions ?? []).then((v) => v.filter((v) => v.chosen));
628
+ const message = await this.getMessage(chatId, messageId);
629
+ if (!message) {
630
+ throw new _0_errors_js_1.InputError("Message not found.");
631
+ }
632
+ const chosenReactions = (message.reactions ?? []).filter((v) => v.chosen);
614
633
  for (const r of chosenReactions) {
615
634
  if ((0, _3_types_js_2.reactionEqual)(r.reaction, reaction)) {
616
635
  return;
@@ -620,7 +639,11 @@ class MessageManager {
620
639
  await this.setReactions(chatId, messageId, reactions, params);
621
640
  }
622
641
  async removeReaction(chatId, messageId, reaction) {
623
- const chosenReactions = await this.getMessage(chatId, messageId).then((v) => v?.reactions ?? []).then((v) => v.filter((v) => v.chosen));
642
+ const message = await this.getMessage(chatId, messageId);
643
+ if (!message) {
644
+ throw new _0_errors_js_1.InputError("Message not found.");
645
+ }
646
+ const chosenReactions = (message.reactions ?? []).filter((v) => v.chosen);
624
647
  for (const r of chosenReactions) {
625
648
  if ((0, _3_types_js_2.reactionEqual)(r.reaction, reaction)) {
626
649
  const reactions = chosenReactions.filter((v) => v != r).map((v) => v.reaction);
@@ -757,7 +780,7 @@ class MessageManager {
757
780
  async deleteChatPhoto(chatId) {
758
781
  const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
759
782
  if (!(peer instanceof _2_tl_js_1.types.InputPeerChannel) && !(peer instanceof _2_tl_js_1.types.InputPeerChat)) {
760
- (0, _1_utilities_js_1.UNREACHABLE)();
783
+ (0, _0_deps_js_1.unreachable)();
761
784
  }
762
785
  if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
763
786
  await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.editPhoto({ channel: new _2_tl_js_1.types.InputChannel(peer), photo: new _2_tl_js_1.types.InputChatPhotoEmpty() });
@@ -769,9 +792,9 @@ class MessageManager {
769
792
  async setChatPhoto(chatId, photo, params) {
770
793
  const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
771
794
  if (!(peer instanceof _2_tl_js_1.types.InputPeerChannel) && !(peer instanceof _2_tl_js_1.types.InputPeerChat)) {
772
- (0, _1_utilities_js_1.UNREACHABLE)();
795
+ (0, _0_deps_js_1.unreachable)();
773
796
  }
774
- const [contents, fileName] = await (0, _0_utilities_js_1.getFileContents)(photo);
797
+ const [contents, fileName] = await (0, _0_utilities_js_3.getFileContents)(photo);
775
798
  const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(contents, { fileName: params?.fileName ?? fileName, chunkSize: params?.chunkSize, signal: params?.signal });
776
799
  const photo_ = new _2_tl_js_1.types.InputChatUploadedPhoto({ file });
777
800
  if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
@@ -853,7 +876,7 @@ class MessageManager {
853
876
  hash: 0n,
854
877
  });
855
878
  if (participants instanceof _2_tl_js_1.types.channels.ChannelParticipantsNotModified) {
856
- (0, _1_utilities_js_1.UNREACHABLE)();
879
+ (0, _0_deps_js_1.unreachable)();
857
880
  }
858
881
  const chatMembers = new Array();
859
882
  for (const p of participants.participants) {
@@ -864,7 +887,7 @@ class MessageManager {
864
887
  else if (peer instanceof _2_tl_js_1.types.InputPeerChat) {
865
888
  const fullChat = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.getFullChat(peer); // TODO: full chat cache
866
889
  if (!(fullChat.full_chat instanceof _2_tl_js_1.types.ChatFull) || !(fullChat.full_chat.participants instanceof _2_tl_js_1.types.ChatParticipants)) {
867
- (0, _1_utilities_js_1.UNREACHABLE)();
890
+ (0, _0_deps_js_1.unreachable)();
868
891
  }
869
892
  const chatMembers = new Array();
870
893
  for (const p of fullChat.full_chat.participants.participants) {
@@ -873,7 +896,7 @@ class MessageManager {
873
896
  return chatMembers;
874
897
  }
875
898
  else {
876
- (0, _1_utilities_js_1.UNREACHABLE)();
899
+ (0, _0_deps_js_1.unreachable)();
877
900
  }
878
901
  }
879
902
  async enableJoinRequests(chatId) {
@@ -900,7 +923,7 @@ class MessageManager {
900
923
  from_id: params?.from ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.from) : undefined,
901
924
  });
902
925
  if (!("messages" in result)) {
903
- (0, _1_utilities_js_1.UNREACHABLE)();
926
+ (0, _0_deps_js_1.unreachable)();
904
927
  }
905
928
  const messages = new Array();
906
929
  for (const message_ of result.messages) {
@@ -951,7 +974,7 @@ class MessageManager {
951
974
  await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.addChatUser({ chat_id: peer.chat_id, user_id: new _2_tl_js_1.types.InputUserSelf(), fwd_limit: 0 }); // TODO: use potential high-level method for adding participants to chats
952
975
  }
953
976
  else {
954
- (0, _1_utilities_js_1.UNREACHABLE)();
977
+ (0, _0_deps_js_1.unreachable)();
955
978
  }
956
979
  }
957
980
  async leaveChat(chatId) {
@@ -966,7 +989,7 @@ class MessageManager {
966
989
  await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.deleteChatUser({ chat_id: peer.chat_id, user_id: new _2_tl_js_1.types.InputUserSelf() }); // TODO: use potential high-level method for adding participants to chats
967
990
  }
968
991
  else {
969
- (0, _1_utilities_js_1.UNREACHABLE)();
992
+ (0, _0_deps_js_1.unreachable)();
970
993
  }
971
994
  }
972
995
  async blockUser(userId) {
@@ -1059,7 +1082,7 @@ class MessageManager {
1059
1082
  const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1060
1083
  return (0, _3_types_js_2.assertMessageType)(message, "location");
1061
1084
  }
1062
- (0, _1_utilities_js_1.UNREACHABLE)();
1085
+ (0, _0_deps_js_1.unreachable)();
1063
1086
  }
1064
1087
  async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
1065
1088
  await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("editInlineMessageLiveLocation");
@@ -1137,18 +1160,18 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
1137
1160
  }
1138
1161
  }
1139
1162
  if (media == null) {
1140
- if (typeof document === "string" && (0, _0_utilities_js_1.isHttpUrl)(document)) {
1163
+ if (typeof document === "string" && (0, _0_utilities_js_3.isHttpUrl)(document)) {
1141
1164
  if (!urlSupported) {
1142
1165
  throw new _0_errors_js_1.InputError("URL not supported.");
1143
1166
  }
1144
1167
  media = new _2_tl_js_1.types.InputMediaDocumentExternal({ url: document, spoiler });
1145
1168
  }
1146
1169
  else {
1147
- const [contents, fileName_] = await (0, _0_utilities_js_1.getFileContents)(document);
1170
+ const [contents, fileName_] = await (0, _0_utilities_js_3.getFileContents)(document);
1148
1171
  let fileName = params?.fileName ?? fileName_;
1149
1172
  const mimeType = params?.mimeType ?? (0, _0_deps_js_1.contentType)(fileName.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE;
1150
1173
  if (expectedMimeTypes && !expectedMimeTypes.includes(mimeType)) {
1151
- (0, _1_utilities_js_1.UNREACHABLE)();
1174
+ (0, _0_deps_js_1.unreachable)();
1152
1175
  }
1153
1176
  if (fileName.endsWith(".tgs") && fileType == _3_types_js_2.FileType.Document) {
1154
1177
  fileName += "-";
@@ -1156,7 +1179,7 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
1156
1179
  const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(contents, { fileName, chunkSize: params?.chunkSize, signal: params?.signal });
1157
1180
  let thumb = undefined;
1158
1181
  if (params?.thumbnail) {
1159
- const [thumbContents, fileName__] = await (0, _0_utilities_js_1.getFileContents)(params.thumbnail);
1182
+ const [thumbContents, fileName__] = await (0, _0_utilities_js_3.getFileContents)(params.thumbnail);
1160
1183
  thumb = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(thumbContents, { fileName: fileName__, chunkSize: params?.chunkSize, signal: params?.signal });
1161
1184
  }
1162
1185
  media = new _2_tl_js_1.types.InputMediaUploadedDocument({
@@ -1198,7 +1221,7 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
1198
1221
  }, _MessageManager_sendReaction = async function _MessageManager_sendReaction(chatId, messageId, reactions, params) {
1199
1222
  await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.sendReaction({
1200
1223
  peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
1201
- msg_id: messageId,
1224
+ msg_id: (0, _0_utilities_js_1.checkMessageId)(messageId),
1202
1225
  reaction: reactions.map((v) => (0, _3_types_js_2.reactionToTlObject)(v)),
1203
1226
  big: params?.big ? true : undefined,
1204
1227
  add_to_recent: params?.addToRecents ? true : undefined,
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.CallbackQueryManager = void 0;
16
16
  const _2_tl_js_1 = require("../2_tl.js");
17
17
  const _3_types_js_1 = require("../3_types.js");
18
+ const _0_utilities_js_1 = require("./0_utilities.js");
18
19
  class CallbackQueryManager {
19
20
  constructor(c) {
20
21
  _CallbackQueryManager_c.set(this, void 0);
@@ -22,6 +23,7 @@ class CallbackQueryManager {
22
23
  }
23
24
  async answerCallbackQuery(id, params) {
24
25
  await __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").storage.assertBot("answerCallbackQuery");
26
+ (0, _0_utilities_js_1.checkCallbackQueryId)(id);
25
27
  await __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").api.messages.setBotCallbackAnswer({
26
28
  query_id: BigInt(id),
27
29
  cache_time: params?.cacheTime ?? 0,
@@ -13,6 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var _ChatListManager_instances, _ChatListManager_c, _ChatListManager_LgetChats, _ChatListManager_sendChatUpdate, _ChatListManager_chats, _ChatListManager_archivedChats, _ChatListManager_chatsLoadedFromStorage, _ChatListManager_tryGetChatId, _ChatListManager_getChatAnywhere, _ChatListManager_getChatList, _ChatListManager_loadChatsFromStorage, _ChatListManager_getLoadedChats, _ChatListManager_pinnedChats, _ChatListManager_pinnedArchiveChats, _ChatListManager_storageHadPinnedChats, _ChatListManager_pinnedChatsLoaded, _ChatListManager_loadPinnedChats, _ChatListManager_fetchPinnedChats, _ChatListManager_getPinnedChats, _ChatListManager_updateOrAddChat, _ChatListManager_removeChat, _ChatListManager_handleUpdateFolderPeers, _ChatListManager_handleUpdatePinnedDialogs, _ChatListManager_handleUpdateChannel, _ChatListManager_handleUpdateChat, _ChatListManager_handleUpdateUser, _ChatListManager_fetchChats;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.ChatListManager = void 0;
16
+ const _0_deps_js_1 = require("../0_deps.js");
16
17
  const _0_errors_js_1 = require("../0_errors.js");
17
18
  const _1_utilities_js_1 = require("../1_utilities.js");
18
19
  const _2_tl_js_1 = require("../2_tl.js");
@@ -57,7 +58,7 @@ class ChatListManager {
57
58
  const pinnedChats = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId);
58
59
  const chat = await (0, _3_types_js_1.constructChat3)(chatId, pinnedChats.indexOf(chatId), message, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
59
60
  if (chat == null) {
60
- (0, _1_utilities_js_1.UNREACHABLE)();
61
+ (0, _0_deps_js_1.unreachable)();
61
62
  }
62
63
  __classPrivateFieldGet(this, _ChatListManager_chats, "f").set(chatId, chat);
63
64
  await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setChat(listId, chatId, chat.pinned, chat.lastMessage?.id ?? 0, chat.lastMessage?.date ?? new Date(0));
@@ -78,7 +79,7 @@ class ChatListManager {
78
79
  const pinnedChats = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId);
79
80
  const chat = await (0, _3_types_js_1.constructChat3)(chatId, pinnedChats.indexOf(chatId), message, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
80
81
  if (chat == null) {
81
- (0, _1_utilities_js_1.UNREACHABLE)();
82
+ (0, _0_deps_js_1.unreachable)();
82
83
  }
83
84
  __classPrivateFieldGet(this, _ChatListManager_chats, "f").set(chatId, chat);
84
85
  }
@@ -149,7 +150,7 @@ class ChatListManager {
149
150
  await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_handleUpdateUser).call(this, update);
150
151
  }
151
152
  else {
152
- (0, _1_utilities_js_1.UNREACHABLE)();
153
+ (0, _0_deps_js_1.unreachable)();
153
154
  }
154
155
  }
155
156
  async getChat(chatId) {
@@ -162,7 +163,7 @@ class ChatListManager {
162
163
  maybeChatId = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_tryGetChatId).call(this, (0, _0_utilities_js_1.getUsername)(chatId));
163
164
  }
164
165
  else {
165
- (0, _1_utilities_js_1.UNREACHABLE)();
166
+ (0, _0_deps_js_1.unreachable)();
166
167
  }
167
168
  if (maybeChatId != null) {
168
169
  const [chat] = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatAnywhere).call(this, maybeChatId);
@@ -193,7 +194,7 @@ class ChatListManager {
193
194
  const chats = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.messages.getChats({ id: [inputPeer.chat_id] }).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.messages.Chats));
194
195
  const chat = chats.chats[0];
195
196
  if (chat instanceof _2_tl_js_1.types.ChatEmpty) {
196
- (0, _1_utilities_js_1.UNREACHABLE)();
197
+ (0, _0_deps_js_1.unreachable)();
197
198
  }
198
199
  return (0, _3_types_js_1.constructChat2)(chat, -1, undefined);
199
200
  }
@@ -201,7 +202,7 @@ class ChatListManager {
201
202
  const channels = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.channels.getChannels({ id: [new _2_tl_js_1.types.InputChannel(inputPeer)] });
202
203
  const channel = channels.chats[0];
203
204
  if (channel instanceof _2_tl_js_1.types.ChatEmpty) {
204
- (0, _1_utilities_js_1.UNREACHABLE)();
205
+ (0, _0_deps_js_1.unreachable)();
205
206
  }
206
207
  return (0, _3_types_js_1.constructChat2)(channel, -1, undefined);
207
208
  }
@@ -209,12 +210,12 @@ class ChatListManager {
209
210
  const users = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.users.getUsers({ id: [new _2_tl_js_1.types.InputUser(inputPeer)] });
210
211
  const user = users[0];
211
212
  if (user instanceof _2_tl_js_1.types.UserEmpty) {
212
- (0, _1_utilities_js_1.UNREACHABLE)();
213
+ (0, _0_deps_js_1.unreachable)();
213
214
  }
214
215
  return (0, _3_types_js_1.constructChat2)(user, -1, undefined);
215
216
  }
216
217
  else {
217
- (0, _1_utilities_js_1.UNREACHABLE)();
218
+ (0, _0_deps_js_1.unreachable)();
218
219
  }
219
220
  }
220
221
  }
@@ -320,7 +321,7 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
320
321
  await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setPinnedChats(1, __classPrivateFieldGet(this, _ChatListManager_pinnedArchiveChats, "f"));
321
322
  }
322
323
  if (listId != null && listId != 0 && listId != 1) {
323
- (0, _1_utilities_js_1.UNREACHABLE)();
324
+ (0, _0_deps_js_1.unreachable)();
324
325
  }
325
326
  }, _ChatListManager_getPinnedChats = async function _ChatListManager_getPinnedChats(listId) {
326
327
  if (!__classPrivateFieldGet(this, _ChatListManager_pinnedChatsLoaded, "f")) {
@@ -335,7 +336,7 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
335
336
  case 1:
336
337
  return __classPrivateFieldGet(this, _ChatListManager_pinnedArchiveChats, "f");
337
338
  default:
338
- (0, _1_utilities_js_1.UNREACHABLE)();
339
+ (0, _0_deps_js_1.unreachable)();
339
340
  }
340
341
  }, _ChatListManager_updateOrAddChat = async function _ChatListManager_updateOrAddChat(chatId) {
341
342
  const [chat, listId] = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatAnywhere).call(this, chatId);
@@ -432,7 +433,7 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
432
433
  });
433
434
  const pinnedChats = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId);
434
435
  if (!(dialogs instanceof _2_tl_js_1.types.messages.Dialogs) && !(dialogs instanceof _2_tl_js_1.types.messages.DialogsSlice)) {
435
- (0, _1_utilities_js_1.UNREACHABLE)();
436
+ (0, _0_deps_js_1.unreachable)();
436
437
  }
437
438
  if (dialogs.dialogs.length < limit) {
438
439
  await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setHasAllChats(listId, true);
@@ -13,9 +13,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var _InlineQueryManager_c;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.InlineQueryManager = void 0;
16
- const _1_utilities_js_1 = require("../1_utilities.js");
16
+ const _0_deps_js_1 = require("../0_deps.js");
17
17
  const _2_tl_js_1 = require("../2_tl.js");
18
18
  const _3_types_js_1 = require("../3_types.js");
19
+ const _0_utilities_js_1 = require("./0_utilities.js");
19
20
  class InlineQueryManager {
20
21
  constructor(c) {
21
22
  _InlineQueryManager_c.set(this, void 0);
@@ -23,6 +24,7 @@ class InlineQueryManager {
23
24
  }
24
25
  async answerInlineQuery(id, results, params) {
25
26
  await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").storage.assertBot("answerInlineQuery");
27
+ (0, _0_utilities_js_1.checkInlineQueryId)(id);
26
28
  await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").api.messages.setInlineBotResults({
27
29
  query_id: BigInt(id),
28
30
  results: await Promise.all(results.map((v) => (0, _3_types_js_1.inlineQueryResultToTlObject)(v, __classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageManager.parseText.bind(__classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageManager), __classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageManager.usernameResolver.bind(__classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageManager)))),
@@ -45,7 +47,7 @@ class InlineQueryManager {
45
47
  return { chosenInlineResult: await (0, _3_types_js_1.constructChosenInlineResult)(update, __classPrivateFieldGet(this, _InlineQueryManager_c, "f").getEntity) };
46
48
  }
47
49
  else {
48
- (0, _1_utilities_js_1.UNREACHABLE)();
50
+ (0, _0_deps_js_1.unreachable)();
49
51
  }
50
52
  }
51
53
  }
@@ -28,7 +28,7 @@ class StoryManager {
28
28
  async createStory(chatId, content, params) {
29
29
  await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("createStory");
30
30
  let media = null;
31
- const source = "video" in content ? content.video : "photo" in content ? content.photo : (0, _1_utilities_js_1.UNREACHABLE)();
31
+ const source = "video" in content ? content.video : "photo" in content ? content.photo : (0, _0_deps_js_1.unreachable)();
32
32
  if (typeof source === "string") {
33
33
  const fileId = __classPrivateFieldGet(this, _StoryManager_c, "f").messageManager.resolveFileId(source, _3_types_js_1.FileType.Photo);
34
34
  if (fileId != null) {
@@ -87,6 +87,7 @@ class StoryManager {
87
87
  }
88
88
  async getStories(chatId, storyIds) {
89
89
  await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("getStories");
90
+ (0, _0_utilities_js_1.checkArray)(storyIds, _0_utilities_js_1.checkStoryId);
90
91
  const peer = await __classPrivateFieldGet(this, _StoryManager_c, "f").getInputPeer(chatId);
91
92
  const stories_ = await __classPrivateFieldGet(this, _StoryManager_c, "f").api.stories.getStoriesByID({ peer, id: storyIds });
92
93
  const stories = new Array();
@@ -150,8 +151,9 @@ _StoryManager_c = new WeakMap(), _StoryManager_instances = new WeakSet(), _Story
150
151
  return await (0, _3_types_js_1.constructStory)(updateStory.story, updateStory.peer, __classPrivateFieldGet(this, _StoryManager_c, "f").getEntity);
151
152
  }
152
153
  }
153
- (0, _1_utilities_js_1.UNREACHABLE)();
154
+ (0, _0_deps_js_1.unreachable)();
154
155
  }, _StoryManager_togglePinned = async function _StoryManager_togglePinned(chatId, storyIds, pinned) {
156
+ (0, _0_utilities_js_1.checkArray)(storyIds, _0_utilities_js_1.checkStoryId);
155
157
  const peer = await __classPrivateFieldGet(this, _StoryManager_c, "f").getInputPeer(chatId);
156
158
  await __classPrivateFieldGet(this, _StoryManager_c, "f").api.stories.togglePinned({ peer, id: storyIds, pinned });
157
159
  };
@@ -13,6 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var _Client_instances, _Client_client, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_businessConnectionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_accountManager, _Client_parseMode, _Client_publicKeys, _Client_ignoreOutgoing, _Client_storeMessages, _Client_Lauthorize, _Client_LpingLoop, _Client_LhandleMigrationError, _Client_L$initConncetion, _Client_namespaceProxies, _Client_getApiId, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectionInited, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_pingLoopStarted, _Client_pingLoopAbortController, _Client_pingInterval, _Client_lastUpdates, _Client_startPingLoop, _Client_pingLoop, _Client_invoke, _Client_handleInvokeError, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Client = exports.handleMigrationError = exports.restartAuth = exports.Composer = void 0;
16
+ const _0_deps_js_1 = require("../0_deps.js");
16
17
  const _0_errors_js_1 = require("../0_errors.js");
17
18
  const _1_utilities_js_1 = require("../1_utilities.js");
18
19
  const _2_tl_js_1 = require("../2_tl.js");
@@ -164,7 +165,7 @@ class Client extends Composer {
164
165
  };
165
166
  }
166
167
  else {
167
- (0, _1_utilities_js_1.UNREACHABLE)();
168
+ (0, _0_deps_js_1.unreachable)();
168
169
  }
169
170
  }
170
171
  },
@@ -212,7 +213,7 @@ class Client extends Composer {
212
213
  return { chatId: reactions.chatId, messageId: reactions.messageId };
213
214
  }
214
215
  else {
215
- (0, _1_utilities_js_1.UNREACHABLE)();
216
+ (0, _0_deps_js_1.unreachable)();
216
217
  }
217
218
  };
218
219
  const mustGetUserId = () => {
@@ -226,7 +227,7 @@ class Client extends Composer {
226
227
  return update.chosenInlineResult.from.id;
227
228
  }
228
229
  else {
229
- (0, _1_utilities_js_1.UNREACHABLE)();
230
+ (0, _0_deps_js_1.unreachable)();
230
231
  }
231
232
  };
232
233
  const mustGetInlineMsgId = () => {
@@ -240,7 +241,7 @@ class Client extends Composer {
240
241
  return update.callbackQuery.inlineMessageId;
241
242
  }
242
243
  }
243
- (0, _1_utilities_js_1.UNREACHABLE)();
244
+ (0, _0_deps_js_1.unreachable)();
244
245
  };
245
246
  const chat_ = "messageReactions" in update ? update.messageReactions.chat : "messageReactionCount" in update ? update.messageReactionCount.chat : undefined;
246
247
  const chat = chat_ ?? msg?.chat;
@@ -353,21 +354,21 @@ class Client extends Composer {
353
354
  banSender: (params) => {
354
355
  const { chatId, senderId } = mustGetMsg();
355
356
  if (!senderId) {
356
- (0, _1_utilities_js_1.UNREACHABLE)();
357
+ (0, _0_deps_js_1.unreachable)();
357
358
  }
358
359
  return this.banChatMember(chatId, senderId, params);
359
360
  },
360
361
  kickSender: () => {
361
362
  const { chatId, senderId } = mustGetMsg();
362
363
  if (!senderId) {
363
- (0, _1_utilities_js_1.UNREACHABLE)();
364
+ (0, _0_deps_js_1.unreachable)();
364
365
  }
365
366
  return this.kickChatMember(chatId, senderId);
366
367
  },
367
368
  setSenderRights: (params) => {
368
369
  const { chatId, senderId } = mustGetMsg();
369
370
  if (!senderId) {
370
- (0, _1_utilities_js_1.UNREACHABLE)();
371
+ (0, _0_deps_js_1.unreachable)();
371
372
  }
372
373
  return this.setChatMemberRights(chatId, senderId, params);
373
374
  },
@@ -381,13 +382,13 @@ class Client extends Composer {
381
382
  },
382
383
  answerCallbackQuery: (params) => {
383
384
  if (!("callbackQuery" in update)) {
384
- (0, _1_utilities_js_1.UNREACHABLE)();
385
+ (0, _0_deps_js_1.unreachable)();
385
386
  }
386
387
  return this.answerCallbackQuery(update.callbackQuery.id, params);
387
388
  },
388
389
  answerInlineQuery: (results, params) => {
389
390
  if (!("inlineQuery" in update)) {
390
- (0, _1_utilities_js_1.UNREACHABLE)();
391
+ (0, _0_deps_js_1.unreachable)();
391
392
  }
392
393
  return this.answerInlineQuery(update.inlineQuery.id, results, params);
393
394
  },
@@ -540,7 +541,7 @@ class Client extends Composer {
540
541
  getBusinessConnection: () => {
541
542
  const { businessConnectionId } = mustGetMsg();
542
543
  if (!businessConnectionId) {
543
- (0, _1_utilities_js_1.UNREACHABLE)();
544
+ (0, _0_deps_js_1.unreachable)();
544
545
  }
545
546
  return this.getBusinessConnection(businessConnectionId);
546
547
  },
@@ -1142,7 +1143,7 @@ class Client extends Composer {
1142
1143
  let n = 1;
1143
1144
  while (true) {
1144
1145
  try {
1145
- if (function_ instanceof _2_tl_js_1.functions.Function && !__classPrivateFieldGet(this, _Client_connectionInited, "f")) {
1146
+ if (function_ instanceof _2_tl_js_1.functions.Function && !__classPrivateFieldGet(this, _Client_connectionInited, "f") && !(0, _0_utilities_js_1.isMtprotoFunction)(function_)) {
1146
1147
  const result = await __classPrivateFieldGet(this, _Client_client, "f").invoke(new _2_tl_js_1.functions.initConnection({
1147
1148
  api_id: await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getApiId).call(this),
1148
1149
  app_version: this.appVersion,
@@ -1221,7 +1222,7 @@ class Client extends Composer {
1221
1222
  resolvedId = (0, _2_tl_js_1.peerToChatId)(resolved.peer);
1222
1223
  }
1223
1224
  else {
1224
- (0, _1_utilities_js_1.UNREACHABLE)();
1225
+ (0, _0_deps_js_1.unreachable)();
1225
1226
  }
1226
1227
  }
1227
1228
  const resolvedIdType = (0, _2_tl_js_1.getChatIdPeerType)(resolvedId);
@@ -1234,7 +1235,7 @@ class Client extends Composer {
1234
1235
  return new _2_tl_js_1.types.InputPeerChannel({ channel_id: (0, _2_tl_js_1.chatIdToPeerId)(resolvedId), access_hash: accessHash ?? 0n });
1235
1236
  }
1236
1237
  else {
1237
- (0, _1_utilities_js_1.UNREACHABLE)();
1238
+ (0, _0_deps_js_1.unreachable)();
1238
1239
  }
1239
1240
  }
1240
1241
  else if (id > 0) {
@@ -37,6 +37,7 @@ var _ConnectionWebSocket_instances, _ConnectionWebSocket_webSocket, _ConnectionW
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.ConnectionWebSocket = void 0;
39
39
  const dntShim = __importStar(require("../_dnt.shims.js"));
40
+ const _0_deps_js_1 = require("../0_deps.js");
40
41
  const _1_utilities_js_1 = require("../1_utilities.js");
41
42
  const _0_connection_js_1 = require("./0_connection.js");
42
43
  const L = (0, _1_utilities_js_1.getLogger)("ConnectionWebSocket");
@@ -142,7 +143,7 @@ _ConnectionWebSocket_webSocket = new WeakMap(), _ConnectionWebSocket_rMutex = ne
142
143
  return;
143
144
  }
144
145
  const unlock = await mutex.lock();
145
- const data = new Uint8Array(await new Blob([e.data].map((v) => v instanceof Blob || v instanceof Uint8Array ? v : v instanceof ArrayBuffer ? v : (0, _1_utilities_js_1.UNREACHABLE)())).arrayBuffer());
146
+ const data = new Uint8Array(await new Blob([e.data].map((v) => v instanceof Blob || v instanceof Uint8Array ? v : v instanceof ArrayBuffer ? v : (0, _0_deps_js_1.unreachable)())).arrayBuffer());
146
147
  __classPrivateFieldSet(this, _ConnectionWebSocket_buffer, (0, _1_utilities_js_1.concat)(__classPrivateFieldGet(this, _ConnectionWebSocket_buffer, "f"), data), "f");
147
148
  if (__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f") != null && __classPrivateFieldGet(this, _ConnectionWebSocket_buffer, "f").length >= __classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f")[0]) {
148
149
  __classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f")[1].resolve();
@@ -40,4 +40,3 @@ export declare function cbc256Encrypt(data: Uint8Array, key: Uint8Array, iv: Uin
40
40
  * @param iv 16-byte initialization vector
41
41
  */
42
42
  export declare function cbc256Decrypt(data: Uint8Array, key: Uint8Array, iv: Uint8Array): Uint8Array;
43
- export declare function factorize(pq: bigint): [bigint, bigint];
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.factorize = exports.cbc256Decrypt = exports.cbc256Encrypt = exports.ctr256 = exports.ige256Decrypt = exports.ige256Encrypt = exports.init = void 0;
6
+ exports.cbc256Decrypt = exports.cbc256Encrypt = exports.ctr256 = exports.ige256Decrypt = exports.ige256Encrypt = exports.init = void 0;
7
7
  const tgcrypto_js_1 = __importDefault(require("./tgcrypto.js"));
8
8
  // deno-lint-ignore no-explicit-any
9
9
  let module_;
@@ -163,15 +163,3 @@ function cbc256Decrypt(data, key, iv) {
163
163
  }
164
164
  }
165
165
  exports.cbc256Decrypt = cbc256Decrypt;
166
- function factorize(pq) {
167
- const pqp = module_._malloc(16);
168
- module_.ccall("factorize", "void", ["number", "pointer"], [pq, pqp]);
169
- try {
170
- const pqp_ = module_.HEAP64.slice(pqp / 8, pqp / 8 + 2);
171
- return [pqp_[0], pqp_[1]];
172
- }
173
- finally {
174
- module_._free(pqp);
175
- }
176
- }
177
- exports.factorize = factorize;