@mtcute/core 0.25.7 → 0.26.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 (118) hide show
  1. package/client.cjs +20 -11
  2. package/client.js +23 -14
  3. package/highlevel/client.d.cts +80 -64
  4. package/highlevel/client.d.ts +80 -64
  5. package/highlevel/methods/files/normalize-input-media.cjs +13 -4
  6. package/highlevel/methods/files/normalize-input-media.js +13 -4
  7. package/highlevel/methods/forums/toggle-forum.cjs +0 -10
  8. package/highlevel/methods/forums/toggle-forum.d.cts +0 -10
  9. package/highlevel/methods/forums/toggle-forum.d.ts +0 -10
  10. package/highlevel/methods/forums/toggle-forum.js +0 -10
  11. package/highlevel/methods/premium/buy-resale-gift.cjs +3 -2
  12. package/highlevel/methods/premium/buy-resale-gift.d.cts +2 -0
  13. package/highlevel/methods/premium/buy-resale-gift.d.ts +2 -0
  14. package/highlevel/methods/premium/buy-resale-gift.js +3 -2
  15. package/highlevel/methods/premium/get-resale-star-gifts.cjs +2 -2
  16. package/highlevel/methods/premium/get-resale-star-gifts.d.cts +1 -1
  17. package/highlevel/methods/premium/get-resale-star-gifts.d.ts +1 -1
  18. package/highlevel/methods/premium/get-resale-star-gifts.js +2 -2
  19. package/highlevel/methods/premium/get-saved-star-gifts.cjs +2 -1
  20. package/highlevel/methods/premium/get-saved-star-gifts.d.cts +4 -2
  21. package/highlevel/methods/premium/get-saved-star-gifts.d.ts +4 -2
  22. package/highlevel/methods/premium/get-saved-star-gifts.js +2 -1
  23. package/highlevel/methods/{auth/run.cjs → premium/get-star-gift-value.cjs} +8 -5
  24. package/highlevel/methods/premium/get-star-gift-value.d.cts +9 -0
  25. package/highlevel/methods/premium/get-star-gift-value.d.ts +9 -0
  26. package/highlevel/methods/premium/get-star-gift-value.js +11 -0
  27. package/highlevel/methods/premium/get-stars-transactions.cjs +3 -2
  28. package/highlevel/methods/premium/get-stars-transactions.d.cts +2 -0
  29. package/highlevel/methods/premium/get-stars-transactions.d.ts +2 -0
  30. package/highlevel/methods/premium/get-stars-transactions.js +3 -2
  31. package/highlevel/methods/premium/iter-saved-star-gifts.cjs +15 -10
  32. package/highlevel/methods/premium/iter-saved-star-gifts.d.cts +13 -19
  33. package/highlevel/methods/premium/iter-saved-star-gifts.d.ts +13 -19
  34. package/highlevel/methods/premium/iter-saved-star-gifts.js +15 -10
  35. package/highlevel/methods/premium/prepay-star-gift-upgrade.cjs +30 -0
  36. package/highlevel/methods/premium/prepay-star-gift-upgrade.d.cts +23 -0
  37. package/highlevel/methods/premium/prepay-star-gift-upgrade.d.ts +23 -0
  38. package/highlevel/methods/premium/prepay-star-gift-upgrade.js +25 -0
  39. package/highlevel/methods/stickers/delete-sticker-from-set.d.cts +2 -4
  40. package/highlevel/methods/stickers/delete-sticker-from-set.d.ts +2 -4
  41. package/highlevel/methods/stickers/move-sticker-in-set.d.cts +2 -4
  42. package/highlevel/methods/stickers/move-sticker-in-set.d.ts +2 -4
  43. package/highlevel/methods/stickers/replace-sticker-in-set.d.cts +2 -4
  44. package/highlevel/methods/stickers/replace-sticker-in-set.d.ts +2 -4
  45. package/highlevel/methods/users/get-saved-music.cjs +38 -0
  46. package/highlevel/methods/users/get-saved-music.d.cts +13 -0
  47. package/highlevel/methods/users/get-saved-music.d.ts +13 -0
  48. package/highlevel/methods/users/get-saved-music.js +33 -0
  49. package/highlevel/methods/users/save-music-to-profile.cjs +57 -0
  50. package/highlevel/methods/users/save-music-to-profile.d.cts +19 -0
  51. package/highlevel/methods/users/save-music-to-profile.d.ts +19 -0
  52. package/highlevel/methods/users/save-music-to-profile.js +52 -0
  53. package/highlevel/methods/users/set-emoji-status.cjs +0 -8
  54. package/highlevel/methods/users/set-emoji-status.d.cts +0 -11
  55. package/highlevel/methods/users/set-emoji-status.d.ts +0 -11
  56. package/highlevel/methods/users/set-emoji-status.js +1 -9
  57. package/highlevel/methods.d.cts +6 -4
  58. package/highlevel/methods.d.ts +6 -4
  59. package/highlevel/types/files/utils.d.cts +7 -0
  60. package/highlevel/types/files/utils.d.ts +7 -0
  61. package/highlevel/types/media/document.d.cts +1 -1
  62. package/highlevel/types/media/document.d.ts +1 -1
  63. package/highlevel/types/messages/message-action.cjs +43 -21
  64. package/highlevel/types/messages/message-action.d.cts +58 -17
  65. package/highlevel/types/messages/message-action.d.ts +58 -17
  66. package/highlevel/types/messages/message-action.js +43 -21
  67. package/highlevel/types/peers/chat.cjs +5 -1
  68. package/highlevel/types/peers/chat.d.cts +5 -1
  69. package/highlevel/types/peers/chat.d.ts +5 -1
  70. package/highlevel/types/peers/chat.js +5 -1
  71. package/highlevel/types/peers/full-chat.cjs +4 -0
  72. package/highlevel/types/peers/full-chat.d.cts +2 -0
  73. package/highlevel/types/peers/full-chat.d.ts +2 -0
  74. package/highlevel/types/peers/full-chat.js +4 -0
  75. package/highlevel/types/peers/full-user.cjs +10 -1
  76. package/highlevel/types/peers/full-user.d.cts +3 -0
  77. package/highlevel/types/peers/full-user.d.ts +3 -0
  78. package/highlevel/types/peers/full-user.js +10 -1
  79. package/highlevel/types/premium/index.d.cts +1 -0
  80. package/highlevel/types/premium/index.d.ts +1 -0
  81. package/highlevel/types/premium/saved-star-gift.cjs +6 -0
  82. package/highlevel/types/premium/saved-star-gift.d.cts +4 -0
  83. package/highlevel/types/premium/saved-star-gift.d.ts +4 -0
  84. package/highlevel/types/premium/saved-star-gift.js +6 -0
  85. package/highlevel/types/premium/star-gift-value.cjs +65 -0
  86. package/highlevel/types/premium/star-gift-value.d.cts +41 -0
  87. package/highlevel/types/premium/star-gift-value.d.ts +41 -0
  88. package/highlevel/types/premium/star-gift-value.js +60 -0
  89. package/highlevel/types/premium/stars-gift-unique.cjs +10 -3
  90. package/highlevel/types/premium/stars-gift-unique.d.cts +1 -1
  91. package/highlevel/types/premium/stars-gift-unique.d.ts +1 -1
  92. package/highlevel/types/premium/stars-gift-unique.js +10 -3
  93. package/highlevel/types/premium/stars-transaction.cjs +9 -0
  94. package/highlevel/types/premium/stars-transaction.d.cts +10 -0
  95. package/highlevel/types/premium/stars-transaction.d.ts +10 -0
  96. package/highlevel/types/premium/stars-transaction.js +9 -0
  97. package/index.cjs +2 -0
  98. package/index.js +2 -0
  99. package/methods.cjs +10 -5
  100. package/methods.js +13 -8
  101. package/network/mtproto-session.cjs +1 -0
  102. package/network/mtproto-session.d.cts +1 -0
  103. package/network/mtproto-session.d.ts +1 -0
  104. package/network/mtproto-session.js +1 -0
  105. package/network/network-manager.cjs +1 -1
  106. package/network/network-manager.js +1 -1
  107. package/network/session-connection.cjs +27 -10
  108. package/network/session-connection.d.cts +1 -0
  109. package/network/session-connection.d.ts +1 -0
  110. package/network/session-connection.js +27 -10
  111. package/package.json +2 -2
  112. package/utils/binary/compat.cjs +35 -4
  113. package/utils/binary/compat.js +35 -4
  114. package/utils/binary/serialization.d.cts +3 -3
  115. package/utils/binary/serialization.d.ts +3 -3
  116. package/highlevel/methods/auth/run.d.cts +0 -16
  117. package/highlevel/methods/auth/run.d.ts +0 -16
  118. package/highlevel/methods/auth/run.js +0 -8
@@ -176,9 +176,17 @@ function _messageActionFromTl(act) {
176
176
  action: act.message
177
177
  };
178
178
  case "messageActionSetChatTheme":
179
+ if (act.theme._ === "chatThemeUniqueGift") {
180
+ assert(act.theme.gift._ === "starGiftUnique");
181
+ return {
182
+ type: "theme_changed_unique",
183
+ gift: new StarGiftUnique$2(act.theme.gift, this._peers),
184
+ themeSettings: act.theme.themeSettings
185
+ };
186
+ }
179
187
  return {
180
188
  type: "theme_changed",
181
- emoji: act.emoticon
189
+ emoji: act.theme.emoticon
182
190
  };
183
191
  case "messageActionChatJoinedByRequest":
184
192
  return {
@@ -279,10 +287,19 @@ function _messageActionFromTl(act) {
279
287
  boostPeer: parsePeer(act.boostPeer, this._peers),
280
288
  giveawayMessageId: act.giveawayMsgId
281
289
  };
290
+ // todo: cleanup in the next breaking update
282
291
  case "messageActionStarGift":
283
292
  assert(act.gift._ === "starGift");
293
+ if (act.prepaidUpgrade) {
294
+ return {
295
+ type: "star_gift_upgrade_paid",
296
+ gift: new StarGift$2(act.gift, this._peers),
297
+ giftMsgId: act.giftMsgId ?? void 0,
298
+ upgradeMsgId: act.upgradeMsgId ?? null
299
+ };
300
+ }
284
301
  return {
285
- type: "stars_gift",
302
+ type: "star_gift_sent",
286
303
  nameHidden: act.nameHidden,
287
304
  saved: act.saved,
288
305
  converted: act.converted,
@@ -294,33 +311,38 @@ function _messageActionFromTl(act) {
294
311
  upgraded: act.upgraded,
295
312
  upgradeStars: act.upgradeStars ?? Long.ZERO,
296
313
  upgradeMsgId: act.upgradeMsgId ?? null,
297
- fromId: act.fromId ? getMarkedPeerId(act.fromId) : void 0,
298
- toId: act.peer ? getMarkedPeerId(act.peer) : void 0,
299
- savedId: act.savedId
314
+ savedId: act.savedId,
315
+ prepaidUpgradeHash: act.prepaidUpgradeHash ?? void 0
300
316
  };
301
- case "messageActionStarGiftUnique":
317
+ case "messageActionStarGiftUnique": {
302
318
  assert(act.gift._ === "starGiftUnique");
303
- return {
304
- type: "stars_gift",
305
- nameHidden: false,
319
+ const common = {
306
320
  saved: act.saved,
307
- converted: false,
308
- convertStars: Long.ZERO,
309
321
  refunded: act.refunded,
310
322
  gift: new StarGiftUnique$2(act.gift, this._peers),
311
- message: null,
312
- canUpgrade: false,
313
- upgraded: true,
314
- upgradeStars: Long.ZERO,
315
- upgradeMsgId: null,
316
- canTransferSince: act.canTransferAt ? new Date(act.canTransferAt * 1e3) : void 0,
317
- resaleStars: act.resaleAmount?._ === "starsAmount" ? act.resaleAmount.amount : void 0,
318
- resaleTon: act.resaleAmount?._ === "starsTonAmount" ? act.resaleAmount.amount : void 0,
323
+ canTransferAt: act.canTransferAt ? new Date(act.canTransferAt * 1e3) : void 0,
319
324
  canResellAt: act.canResellAt ? new Date(act.canResellAt * 1e3) : void 0,
320
- fromId: act.fromId ? getMarkedPeerId(act.fromId) : void 0,
321
- toId: act.peer ? getMarkedPeerId(act.peer) : void 0,
325
+ canExportAt: act.canExportAt ? new Date(act.canExportAt * 1e3) : void 0,
322
326
  savedId: act.savedId
323
327
  };
328
+ if (act.resaleAmount) {
329
+ return {
330
+ type: "star_gift_bought_resale",
331
+ ...common,
332
+ amount: act.resaleAmount
333
+ };
334
+ }
335
+ if (act.upgrade) {
336
+ return {
337
+ type: "star_gift_upgraded",
338
+ ...common
339
+ };
340
+ }
341
+ return {
342
+ type: "star_gift_transferred",
343
+ ...common
344
+ };
345
+ }
324
346
  case "messageActionPaidMessagesPrice":
325
347
  return {
326
348
  type: "messages_paid",
@@ -398,7 +398,11 @@ class Chat {
398
398
  if (this.raw._ !== "channelForbidden" || !this.raw.untilDate) return null;
399
399
  return new Date(this.raw.untilDate * 1e3);
400
400
  }
401
- /** Number of members in this chat (if available) */
401
+ /**
402
+ * Number of members in this chat (if available)
403
+ *
404
+ * If not available, try fetching a full chat info with {@link TelegramClient.getFullChat}
405
+ */
402
406
  get membersCount() {
403
407
  return "participantsCount" in this.raw ? this.raw.participantsCount ?? null : null;
404
408
  }
@@ -227,7 +227,11 @@ export declare class Chat {
227
227
  * Returns `null` if the user is not banned, or if the ban is permanent
228
228
  */
229
229
  get bannedUntilDate(): Date | null;
230
- /** Number of members in this chat (if available) */
230
+ /**
231
+ * Number of members in this chat (if available)
232
+ *
233
+ * If not available, try fetching a full chat info with {@link TelegramClient.getFullChat}
234
+ */
231
235
  get membersCount(): number | null;
232
236
  /**
233
237
  * If this chat is a basic group that has been migrated to a supergroup,
@@ -227,7 +227,11 @@ export declare class Chat {
227
227
  * Returns `null` if the user is not banned, or if the ban is permanent
228
228
  */
229
229
  get bannedUntilDate(): Date | null;
230
- /** Number of members in this chat (if available) */
230
+ /**
231
+ * Number of members in this chat (if available)
232
+ *
233
+ * If not available, try fetching a full chat info with {@link TelegramClient.getFullChat}
234
+ */
231
235
  get membersCount(): number | null;
232
236
  /**
233
237
  * If this chat is a basic group that has been migrated to a supergroup,
@@ -391,7 +391,11 @@ class Chat {
391
391
  if (this.raw._ !== "channelForbidden" || !this.raw.untilDate) return null;
392
392
  return new Date(this.raw.untilDate * 1e3);
393
393
  }
394
- /** Number of members in this chat (if available) */
394
+ /**
395
+ * Number of members in this chat (if available)
396
+ *
397
+ * If not available, try fetching a full chat info with {@link TelegramClient.getFullChat}
398
+ */
395
399
  get membersCount() {
396
400
  return "participantsCount" in this.raw ? this.raw.participantsCount ?? null : null;
397
401
  }
@@ -178,6 +178,10 @@ class FullChat extends chat.Chat {
178
178
  get canViewAdRevenue() {
179
179
  return this.full._ === "channelFull" && this.full.canViewRevenue;
180
180
  }
181
+ /** Number of members in the chat (0 if not available) */
182
+ get membersCount() {
183
+ return this.full._ === "channelFull" ? this.full.participantsCount ?? 0 : 0;
184
+ }
181
185
  /** Number of admins in the chat (0 if not available) */
182
186
  get adminsCount() {
183
187
  return this.full._ === "channelFull" ? this.full.adminsCount ?? 0 : 0;
@@ -98,6 +98,8 @@ export declare class FullChat extends Chat {
98
98
  get canViewStarsRevenue(): boolean;
99
99
  /** Whether the current user can view ad revenue for this chat */
100
100
  get canViewAdRevenue(): boolean;
101
+ /** Number of members in the chat (0 if not available) */
102
+ get membersCount(): number;
101
103
  /** Number of admins in the chat (0 if not available) */
102
104
  get adminsCount(): number;
103
105
  /** Number of users kicked from the chat (if available) */
@@ -98,6 +98,8 @@ export declare class FullChat extends Chat {
98
98
  get canViewStarsRevenue(): boolean;
99
99
  /** Whether the current user can view ad revenue for this chat */
100
100
  get canViewAdRevenue(): boolean;
101
+ /** Number of members in the chat (0 if not available) */
102
+ get membersCount(): number;
101
103
  /** Number of admins in the chat (0 if not available) */
102
104
  get adminsCount(): number;
103
105
  /** Number of users kicked from the chat (if available) */
@@ -171,6 +171,10 @@ class FullChat extends Chat$2 {
171
171
  get canViewAdRevenue() {
172
172
  return this.full._ === "channelFull" && this.full.canViewRevenue;
173
173
  }
174
+ /** Number of members in the chat (0 if not available) */
175
+ get membersCount() {
176
+ return this.full._ === "channelFull" ? this.full.participantsCount ?? 0 : 0;
177
+ }
174
178
  /** Number of admins in the chat (0 if not available) */
175
179
  get adminsCount() {
176
180
  return this.full._ === "channelFull" ? this.full.adminsCount ?? 0 : 0;
@@ -7,6 +7,7 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const inspectable = require("../../utils/inspectable.cjs");
9
9
  const memoize = require("../../utils/memoize.cjs");
10
+ const documentUtils = require("../media/document-utils.cjs");
10
11
  const photo = require("../media/photo.cjs");
11
12
  const businessAccount = require("../premium/business-account.cjs");
12
13
  const botVerification = require("./bot-verification.cjs");
@@ -234,6 +235,13 @@ class FullUser extends user.User {
234
235
  date: new Date(this.full.starsMyPendingRatingDate * 1e3)
235
236
  };
236
237
  }
238
+ /** User's last saved audio file, to be displayed in the profile under their name */
239
+ get lastSavedMusic() {
240
+ if (this.full.savedMusic?._ !== "document") return null;
241
+ const doc = documentUtils.parseDocument(this.full.savedMusic);
242
+ if (doc.type !== "audio") return null;
243
+ return doc;
244
+ }
237
245
  }
238
246
  const FullUser$1 = /* @__PURE__ */ memoize.memoizeGetters(FullUser, [
239
247
  "fullPhoto",
@@ -243,7 +251,8 @@ const FullUser$1 = /* @__PURE__ */ memoize.memoizeGetters(FullUser, [
243
251
  "personalChannel",
244
252
  "business",
245
253
  "botVerification",
246
- "starsRatingPending"
254
+ "starsRatingPending",
255
+ "lastSavedMusic"
247
256
  ]);
248
257
  const FullUser$2 = /* @__PURE__ */ inspectable.makeInspectable(FullUser$1);
249
258
  exports.FullUser = FullUser$2;
@@ -1,4 +1,5 @@
1
1
  import { tl } from '@mtcute/tl';
2
+ import { Audio } from '../media/audio.js';
2
3
  import { Photo } from '../media/photo.js';
3
4
  import { BusinessAccount } from '../premium/business-account.js';
4
5
  import { BotVerification } from './bot-verification.js';
@@ -132,4 +133,6 @@ export declare class FullUser extends User {
132
133
  rating: tl.RawStarsRating;
133
134
  date: Date;
134
135
  } | null;
136
+ /** User's last saved audio file, to be displayed in the profile under their name */
137
+ get lastSavedMusic(): Audio | null;
135
138
  }
@@ -1,4 +1,5 @@
1
1
  import { tl } from '@mtcute/tl';
2
+ import { Audio } from '../media/audio.js';
2
3
  import { Photo } from '../media/photo.js';
3
4
  import { BusinessAccount } from '../premium/business-account.js';
4
5
  import { BotVerification } from './bot-verification.js';
@@ -132,4 +133,6 @@ export declare class FullUser extends User {
132
133
  rating: tl.RawStarsRating;
133
134
  date: Date;
134
135
  } | null;
136
+ /** User's last saved audio file, to be displayed in the profile under their name */
137
+ get lastSavedMusic(): Audio | null;
135
138
  }
@@ -1,5 +1,6 @@
1
1
  import { makeInspectable } from "../../utils/inspectable.js";
2
2
  import { memoizeGetters } from "../../utils/memoize.js";
3
+ import { parseDocument } from "../media/document-utils.js";
3
4
  import { Photo as Photo$2 } from "../media/photo.js";
4
5
  import { BusinessAccount as BusinessAccount$2 } from "../premium/business-account.js";
5
6
  import { BotVerification as BotVerification$1 } from "./bot-verification.js";
@@ -227,6 +228,13 @@ class FullUser extends User$2 {
227
228
  date: new Date(this.full.starsMyPendingRatingDate * 1e3)
228
229
  };
229
230
  }
231
+ /** User's last saved audio file, to be displayed in the profile under their name */
232
+ get lastSavedMusic() {
233
+ if (this.full.savedMusic?._ !== "document") return null;
234
+ const doc = parseDocument(this.full.savedMusic);
235
+ if (doc.type !== "audio") return null;
236
+ return doc;
237
+ }
230
238
  }
231
239
  const FullUser$1 = /* @__PURE__ */ memoizeGetters(FullUser, [
232
240
  "fullPhoto",
@@ -236,7 +244,8 @@ const FullUser$1 = /* @__PURE__ */ memoizeGetters(FullUser, [
236
244
  "personalChannel",
237
245
  "business",
238
246
  "botVerification",
239
- "starsRatingPending"
247
+ "starsRatingPending",
248
+ "lastSavedMusic"
240
249
  ]);
241
250
  const FullUser$2 = /* @__PURE__ */ makeInspectable(FullUser$1);
242
251
  export {
@@ -8,6 +8,7 @@ export * from './business-intro.js';
8
8
  export * from './business-location.js';
9
9
  export * from './business-work-hours.js';
10
10
  export * from './saved-star-gift.js';
11
+ export * from './star-gift-value.js';
11
12
  export * from './stars-gift-unique.js';
12
13
  export * from './stars-gift.js';
13
14
  export * from './stars-status.js';
@@ -8,6 +8,7 @@ export * from './business-intro.js';
8
8
  export * from './business-location.js';
9
9
  export * from './business-work-hours.js';
10
10
  export * from './saved-star-gift.js';
11
+ export * from './star-gift-value.js';
11
12
  export * from './stars-gift-unique.js';
12
13
  export * from './stars-gift.js';
13
14
  export * from './stars-status.js';
@@ -90,6 +90,12 @@ class SavedStarGift {
90
90
  get collectionIds() {
91
91
  return this.raw.collectionId ?? [];
92
92
  }
93
+ /**
94
+ * If available, you can pay for this gift's upgrade by passing this hash to `prepayStarGiftUpgrade`
95
+ */
96
+ get prepaidUpgradeHash() {
97
+ return this.raw.prepaidUpgradeHash ?? null;
98
+ }
93
99
  }
94
100
  const SavedStarGift$1 = /* @__PURE__ */ inspectable.makeInspectable(SavedStarGift);
95
101
  const SavedStarGift$2 = /* @__PURE__ */ memoize.memoizeGetters(SavedStarGift$1, ["sender", "gift"]);
@@ -44,4 +44,8 @@ export declare class SavedStarGift {
44
44
  get canResellAt(): Date | null;
45
45
  /** IDs of the collections this gift belongs to */
46
46
  get collectionIds(): number[];
47
+ /**
48
+ * If available, you can pay for this gift's upgrade by passing this hash to `prepayStarGiftUpgrade`
49
+ */
50
+ get prepaidUpgradeHash(): string | null;
47
51
  }
@@ -44,4 +44,8 @@ export declare class SavedStarGift {
44
44
  get canResellAt(): Date | null;
45
45
  /** IDs of the collections this gift belongs to */
46
46
  get collectionIds(): number[];
47
+ /**
48
+ * If available, you can pay for this gift's upgrade by passing this hash to `prepayStarGiftUpgrade`
49
+ */
50
+ get prepaidUpgradeHash(): string | null;
47
51
  }
@@ -83,6 +83,12 @@ class SavedStarGift {
83
83
  get collectionIds() {
84
84
  return this.raw.collectionId ?? [];
85
85
  }
86
+ /**
87
+ * If available, you can pay for this gift's upgrade by passing this hash to `prepayStarGiftUpgrade`
88
+ */
89
+ get prepaidUpgradeHash() {
90
+ return this.raw.prepaidUpgradeHash ?? null;
91
+ }
86
92
  }
87
93
  const SavedStarGift$1 = /* @__PURE__ */ makeInspectable(SavedStarGift);
88
94
  const SavedStarGift$2 = /* @__PURE__ */ memoizeGetters(SavedStarGift$1, ["sender", "gift"]);
@@ -0,0 +1,65 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS bundles are deprecated. They will be removed completely in one of the upcoming releases. No support is provided for CommonJS users. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const inspectable = require("../../utils/inspectable.cjs");
9
+ const memoize = require("../../utils/memoize.cjs");
10
+ class StarGiftValue {
11
+ constructor(raw) {
12
+ this.raw = raw;
13
+ }
14
+ /** Currency of values in this object */
15
+ get currency() {
16
+ return this.raw.currency;
17
+ }
18
+ /** Information about the initial sale of the gift */
19
+ get initialSale() {
20
+ return {
21
+ date: new Date(this.raw.initialSaleDate * 1e3),
22
+ stars: this.raw.initialSaleStars,
23
+ price: this.raw.initialSalePrice
24
+ };
25
+ }
26
+ /** Information about the last sale of the gift on the secondary market (Telegram and Fragment) */
27
+ get lastSale() {
28
+ if (!this.raw.lastSaleDate || !this.raw.lastSalePrice) return null;
29
+ return {
30
+ date: new Date(this.raw.lastSaleDate * 1e3),
31
+ price: this.raw.lastSalePrice,
32
+ fragment: this.raw.lastSaleOnFragment
33
+ };
34
+ }
35
+ /** Whether {@link value} is calculated as an after-market average over the past month */
36
+ get isValueAverage() {
37
+ return this.raw.valueIsAverage;
38
+ }
39
+ /** Estimated value of the gift (in {@link currency}) */
40
+ get value() {
41
+ return this.raw.value;
42
+ }
43
+ /** Floor price for the gift on the secondary market (Telegram and Fragment), if available */
44
+ get floorPrice() {
45
+ return this.raw.floorPrice ?? null;
46
+ }
47
+ /** Average price for the gift on the secondary market (Telegram and Fragment), if available */
48
+ get averagePrice() {
49
+ return this.raw.averagePrice ?? null;
50
+ }
51
+ /** Number of such gifts listed on the secondary market (Telegram and Fragment) */
52
+ get listedCount() {
53
+ return {
54
+ telegram: this.raw.listedCount ?? 0,
55
+ fragment: this.raw.fragmentListedCount ?? 0
56
+ };
57
+ }
58
+ /** URL to the collectible on Fragment */
59
+ get fragmentUrl() {
60
+ return this.raw.fragmentListedUrl ?? null;
61
+ }
62
+ }
63
+ const StarGiftValue$1 = /* @__PURE__ */ memoize.memoizeGetters(StarGiftValue, ["initialSale", "lastSale"]);
64
+ const StarGiftValue$2 = /* @__PURE__ */ inspectable.makeInspectable(StarGiftValue$1);
65
+ exports.StarGiftValue = StarGiftValue$2;
@@ -0,0 +1,41 @@
1
+ import { tl } from '@mtcute/tl';
2
+ /** Information about the value of a star gift */
3
+ export declare class StarGiftValue {
4
+ private readonly raw;
5
+ constructor(raw: tl.payments.TypeUniqueStarGiftValueInfo);
6
+ /** Currency of values in this object */
7
+ get currency(): string;
8
+ /** Information about the initial sale of the gift */
9
+ get initialSale(): {
10
+ /** Date when the first such gift was sold */
11
+ date: Date;
12
+ /** Number of stars the gift was sold for */
13
+ stars: tl.Long;
14
+ /** Price of the gift in {@link currency} at the time of the sale */
15
+ price: tl.Long;
16
+ };
17
+ /** Information about the last sale of the gift on the secondary market (Telegram and Fragment) */
18
+ get lastSale(): {
19
+ /** Date when the last such gift was sold */
20
+ date: Date;
21
+ /** Price of the gift in {@link currency} at the time of the sale */
22
+ price: tl.Long;
23
+ /** Whether the sale was made on Fragment */
24
+ fragment: boolean;
25
+ } | null;
26
+ /** Whether {@link value} is calculated as an after-market average over the past month */
27
+ get isValueAverage(): boolean;
28
+ /** Estimated value of the gift (in {@link currency}) */
29
+ get value(): tl.Long;
30
+ /** Floor price for the gift on the secondary market (Telegram and Fragment), if available */
31
+ get floorPrice(): tl.Long | null;
32
+ /** Average price for the gift on the secondary market (Telegram and Fragment), if available */
33
+ get averagePrice(): tl.Long | null;
34
+ /** Number of such gifts listed on the secondary market (Telegram and Fragment) */
35
+ get listedCount(): {
36
+ telegram: number;
37
+ fragment: number;
38
+ };
39
+ /** URL to the collectible on Fragment */
40
+ get fragmentUrl(): string | null;
41
+ }
@@ -0,0 +1,41 @@
1
+ import { tl } from '@mtcute/tl';
2
+ /** Information about the value of a star gift */
3
+ export declare class StarGiftValue {
4
+ private readonly raw;
5
+ constructor(raw: tl.payments.TypeUniqueStarGiftValueInfo);
6
+ /** Currency of values in this object */
7
+ get currency(): string;
8
+ /** Information about the initial sale of the gift */
9
+ get initialSale(): {
10
+ /** Date when the first such gift was sold */
11
+ date: Date;
12
+ /** Number of stars the gift was sold for */
13
+ stars: tl.Long;
14
+ /** Price of the gift in {@link currency} at the time of the sale */
15
+ price: tl.Long;
16
+ };
17
+ /** Information about the last sale of the gift on the secondary market (Telegram and Fragment) */
18
+ get lastSale(): {
19
+ /** Date when the last such gift was sold */
20
+ date: Date;
21
+ /** Price of the gift in {@link currency} at the time of the sale */
22
+ price: tl.Long;
23
+ /** Whether the sale was made on Fragment */
24
+ fragment: boolean;
25
+ } | null;
26
+ /** Whether {@link value} is calculated as an after-market average over the past month */
27
+ get isValueAverage(): boolean;
28
+ /** Estimated value of the gift (in {@link currency}) */
29
+ get value(): tl.Long;
30
+ /** Floor price for the gift on the secondary market (Telegram and Fragment), if available */
31
+ get floorPrice(): tl.Long | null;
32
+ /** Average price for the gift on the secondary market (Telegram and Fragment), if available */
33
+ get averagePrice(): tl.Long | null;
34
+ /** Number of such gifts listed on the secondary market (Telegram and Fragment) */
35
+ get listedCount(): {
36
+ telegram: number;
37
+ fragment: number;
38
+ };
39
+ /** URL to the collectible on Fragment */
40
+ get fragmentUrl(): string | null;
41
+ }
@@ -0,0 +1,60 @@
1
+ import { makeInspectable } from "../../utils/inspectable.js";
2
+ import { memoizeGetters } from "../../utils/memoize.js";
3
+ class StarGiftValue {
4
+ constructor(raw) {
5
+ this.raw = raw;
6
+ }
7
+ /** Currency of values in this object */
8
+ get currency() {
9
+ return this.raw.currency;
10
+ }
11
+ /** Information about the initial sale of the gift */
12
+ get initialSale() {
13
+ return {
14
+ date: new Date(this.raw.initialSaleDate * 1e3),
15
+ stars: this.raw.initialSaleStars,
16
+ price: this.raw.initialSalePrice
17
+ };
18
+ }
19
+ /** Information about the last sale of the gift on the secondary market (Telegram and Fragment) */
20
+ get lastSale() {
21
+ if (!this.raw.lastSaleDate || !this.raw.lastSalePrice) return null;
22
+ return {
23
+ date: new Date(this.raw.lastSaleDate * 1e3),
24
+ price: this.raw.lastSalePrice,
25
+ fragment: this.raw.lastSaleOnFragment
26
+ };
27
+ }
28
+ /** Whether {@link value} is calculated as an after-market average over the past month */
29
+ get isValueAverage() {
30
+ return this.raw.valueIsAverage;
31
+ }
32
+ /** Estimated value of the gift (in {@link currency}) */
33
+ get value() {
34
+ return this.raw.value;
35
+ }
36
+ /** Floor price for the gift on the secondary market (Telegram and Fragment), if available */
37
+ get floorPrice() {
38
+ return this.raw.floorPrice ?? null;
39
+ }
40
+ /** Average price for the gift on the secondary market (Telegram and Fragment), if available */
41
+ get averagePrice() {
42
+ return this.raw.averagePrice ?? null;
43
+ }
44
+ /** Number of such gifts listed on the secondary market (Telegram and Fragment) */
45
+ get listedCount() {
46
+ return {
47
+ telegram: this.raw.listedCount ?? 0,
48
+ fragment: this.raw.fragmentListedCount ?? 0
49
+ };
50
+ }
51
+ /** URL to the collectible on Fragment */
52
+ get fragmentUrl() {
53
+ return this.raw.fragmentListedUrl ?? null;
54
+ }
55
+ }
56
+ const StarGiftValue$1 = /* @__PURE__ */ memoizeGetters(StarGiftValue, ["initialSale", "lastSale"]);
57
+ const StarGiftValue$2 = /* @__PURE__ */ makeInspectable(StarGiftValue$1);
58
+ export {
59
+ StarGiftValue$2 as StarGiftValue
60
+ };
@@ -172,9 +172,8 @@ class StarGiftUnique {
172
172
  get availabilityTotal() {
173
173
  return this.raw.availabilityTotal;
174
174
  }
175
- // todo for breaking: rename to resellPriceStars
176
175
  /** Number of stars this gift is up for resell for */
177
- get resellPrice() {
176
+ get resellPriceStars() {
178
177
  const resellPriceStars = this.raw.resellAmount?.find((it) => it._ === "starsAmount");
179
178
  return resellPriceStars?.amount ?? null;
180
179
  }
@@ -217,7 +216,15 @@ class StarGiftUnique {
217
216
  }
218
217
  }
219
218
  const StarGiftUnique$1 = /* @__PURE__ */ inspectable.makeInspectable(StarGiftUnique);
220
- const StarGiftUnique$2 = /* @__PURE__ */ memoize.memoizeGetters(StarGiftUnique$1, ["model", "pattern", "backdrop", "originalDetails"]);
219
+ const StarGiftUnique$2 = /* @__PURE__ */ memoize.memoizeGetters(StarGiftUnique$1, [
220
+ "model",
221
+ "pattern",
222
+ "backdrop",
223
+ "originalDetails",
224
+ "resellPriceStars",
225
+ "resellPriceTon",
226
+ "releasedBy"
227
+ ]);
221
228
  exports.StarGiftUnique = StarGiftUnique$2;
222
229
  exports.StarGiftUniqueAttribute = StarGiftUniqueAttribute$2;
223
230
  exports.StarGiftUniqueBackdrop = StarGiftUniqueBackdrop$1;
@@ -88,7 +88,7 @@ export declare class StarGiftUnique {
88
88
  get availabilityIssued(): number;
89
89
  get availabilityTotal(): number;
90
90
  /** Number of stars this gift is up for resell for */
91
- get resellPrice(): tl.Long | null;
91
+ get resellPriceStars(): tl.Long | null;
92
92
  /** Number of nanoton this gift is up for resell for */
93
93
  get resellPriceTon(): tl.Long | null;
94
94
  /** Model (i.e. the gift itself) of the unique star gift */
@@ -88,7 +88,7 @@ export declare class StarGiftUnique {
88
88
  get availabilityIssued(): number;
89
89
  get availabilityTotal(): number;
90
90
  /** Number of stars this gift is up for resell for */
91
- get resellPrice(): tl.Long | null;
91
+ get resellPriceStars(): tl.Long | null;
92
92
  /** Number of nanoton this gift is up for resell for */
93
93
  get resellPriceTon(): tl.Long | null;
94
94
  /** Model (i.e. the gift itself) of the unique star gift */
@@ -165,9 +165,8 @@ class StarGiftUnique {
165
165
  get availabilityTotal() {
166
166
  return this.raw.availabilityTotal;
167
167
  }
168
- // todo for breaking: rename to resellPriceStars
169
168
  /** Number of stars this gift is up for resell for */
170
- get resellPrice() {
169
+ get resellPriceStars() {
171
170
  const resellPriceStars = this.raw.resellAmount?.find((it) => it._ === "starsAmount");
172
171
  return resellPriceStars?.amount ?? null;
173
172
  }
@@ -210,7 +209,15 @@ class StarGiftUnique {
210
209
  }
211
210
  }
212
211
  const StarGiftUnique$1 = /* @__PURE__ */ makeInspectable(StarGiftUnique);
213
- const StarGiftUnique$2 = /* @__PURE__ */ memoizeGetters(StarGiftUnique$1, ["model", "pattern", "backdrop", "originalDetails"]);
212
+ const StarGiftUnique$2 = /* @__PURE__ */ memoizeGetters(StarGiftUnique$1, [
213
+ "model",
214
+ "pattern",
215
+ "backdrop",
216
+ "originalDetails",
217
+ "resellPriceStars",
218
+ "resellPriceTon",
219
+ "releasedBy"
220
+ ]);
214
221
  export {
215
222
  StarGiftUnique$2 as StarGiftUnique,
216
223
  StarGiftUniqueAttribute$2 as StarGiftUniqueAttribute,