@mtkruto/browser 0.119.0 → 0.119.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/esm/0_errors.d.ts.map +1 -1
  2. package/esm/0_errors.js +9 -31
  3. package/esm/3_errors.js +2 -12
  4. package/esm/4_errors.js +2 -12
  5. package/esm/_dnt.polyfills.d.ts +0 -99
  6. package/esm/_dnt.polyfills.d.ts.map +1 -1
  7. package/esm/_dnt.polyfills.js +1 -127
  8. package/esm/client/0_abortable_loop.js +26 -39
  9. package/esm/client/0_storage_operations.js +179 -218
  10. package/esm/client/1_client_plain.js +4 -22
  11. package/esm/client/2_account_manager.js +140 -149
  12. package/esm/client/2_bot_info_manager.js +26 -38
  13. package/esm/client/2_business_connection_manager.js +10 -23
  14. package/esm/client/2_client_encrypted.js +198 -215
  15. package/esm/client/2_file_manager.js +255 -262
  16. package/esm/client/2_network_statistics_manager.js +31 -44
  17. package/esm/client/2_payment_manager.js +7 -20
  18. package/esm/client/2_reaction_manager.js +7 -20
  19. package/esm/client/2_translations_manager.js +101 -111
  20. package/esm/client/2_update_manager.js +750 -745
  21. package/esm/client/3_client_encrypted_pool.js +10 -26
  22. package/esm/client/3_message_manager.js +503 -508
  23. package/esm/client/3_video_chat_manager.js +57 -68
  24. package/esm/client/4_callback_query_manager.js +18 -30
  25. package/esm/client/4_chat_list_manager.js +140 -146
  26. package/esm/client/4_chat_manager.js +161 -169
  27. package/esm/client/4_checklist_manager.js +26 -39
  28. package/esm/client/4_context.js +244 -259
  29. package/esm/client/4_forum_manager.js +67 -73
  30. package/esm/client/4_gift_manager.js +22 -35
  31. package/esm/client/4_inline_query_manager.js +16 -28
  32. package/esm/client/4_link_preview_manager.js +6 -19
  33. package/esm/client/4_poll_manager.js +44 -57
  34. package/esm/client/4_story_manager.js +41 -53
  35. package/esm/client/5_composer.js +13 -26
  36. package/esm/client/6_client.js +866 -896
  37. package/esm/client/6_client_dispatcher.js +308 -325
  38. package/esm/client/7_client_worker.js +16 -29
  39. package/esm/connection/1_connection_tcp.js +55 -82
  40. package/esm/connection/1_connection_web_socket.js +75 -91
  41. package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  42. package/esm/deps/jsr.io/@std/async/1.2.0/mux_async_iterator.js +31 -47
  43. package/esm/deps/jsr.io/@std/async/1.2.0/tee.js +11 -34
  44. package/esm/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +30 -47
  45. package/esm/deps/jsr.io/@std/datetime/0.225.7/_date_time_formatter.js +4 -17
  46. package/esm/session/0_session_state.js +12 -38
  47. package/esm/session/1_session.js +49 -72
  48. package/esm/session/2_session_encrypted.js +422 -420
  49. package/esm/storage/2_storage_indexed_db.js +26 -44
  50. package/esm/storage/2_storage_local_storage.js +3 -16
  51. package/esm/storage/2_storage_memory.js +24 -41
  52. package/esm/storage/2_storage_session_storage.js +3 -16
  53. package/esm/tl/1_tl_reader.d.ts +1 -1
  54. package/esm/tl/1_tl_reader.d.ts.map +1 -1
  55. package/esm/tl/1_tl_reader.js +95 -103
  56. package/esm/tl/1_tl_writer.js +169 -178
  57. package/esm/transport/0_transport.js +1 -8
  58. package/esm/transport/1_transport_abridged.js +11 -24
  59. package/esm/transport/1_transport_intermediate.js +10 -23
  60. package/esm/utilities/0_mutex.js +4 -19
  61. package/esm/utilities/0_part_stream.js +11 -25
  62. package/esm/utilities/1_crypto.js +42 -53
  63. package/esm/utilities/2_queue.js +29 -47
  64. package/package.json +1 -1
  65. package/script/0_errors.d.ts.map +1 -1
  66. package/script/0_errors.js +9 -31
  67. package/script/3_errors.js +2 -12
  68. package/script/4_errors.js +2 -12
  69. package/script/_dnt.polyfills.d.ts +0 -99
  70. package/script/_dnt.polyfills.d.ts.map +1 -1
  71. package/script/_dnt.polyfills.js +0 -128
  72. package/script/client/0_abortable_loop.js +27 -40
  73. package/script/client/0_storage_operations.js +179 -218
  74. package/script/client/1_client_plain.js +4 -22
  75. package/script/client/2_account_manager.js +140 -149
  76. package/script/client/2_bot_info_manager.js +26 -38
  77. package/script/client/2_business_connection_manager.js +10 -23
  78. package/script/client/2_client_encrypted.js +199 -216
  79. package/script/client/2_file_manager.js +255 -262
  80. package/script/client/2_network_statistics_manager.js +32 -45
  81. package/script/client/2_payment_manager.js +7 -20
  82. package/script/client/2_reaction_manager.js +7 -20
  83. package/script/client/2_translations_manager.js +102 -112
  84. package/script/client/2_update_manager.js +750 -745
  85. package/script/client/3_client_encrypted_pool.js +10 -26
  86. package/script/client/3_message_manager.js +503 -508
  87. package/script/client/3_video_chat_manager.js +57 -68
  88. package/script/client/4_callback_query_manager.js +18 -30
  89. package/script/client/4_chat_list_manager.js +140 -146
  90. package/script/client/4_chat_manager.js +161 -169
  91. package/script/client/4_checklist_manager.js +26 -39
  92. package/script/client/4_context.js +244 -259
  93. package/script/client/4_forum_manager.js +67 -73
  94. package/script/client/4_gift_manager.js +22 -35
  95. package/script/client/4_inline_query_manager.js +16 -28
  96. package/script/client/4_link_preview_manager.js +6 -19
  97. package/script/client/4_poll_manager.js +44 -57
  98. package/script/client/4_story_manager.js +41 -53
  99. package/script/client/5_composer.js +13 -26
  100. package/script/client/6_client.js +866 -896
  101. package/script/client/6_client_dispatcher.js +308 -325
  102. package/script/client/7_client_worker.js +16 -29
  103. package/script/connection/1_connection_tcp.js +55 -82
  104. package/script/connection/1_connection_web_socket.js +75 -91
  105. package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  106. package/script/deps/jsr.io/@std/async/1.2.0/mux_async_iterator.js +31 -47
  107. package/script/deps/jsr.io/@std/async/1.2.0/tee.js +11 -34
  108. package/script/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +30 -47
  109. package/script/deps/jsr.io/@std/datetime/0.225.7/_date_time_formatter.js +4 -17
  110. package/script/session/0_session_state.js +12 -38
  111. package/script/session/1_session.js +49 -72
  112. package/script/session/2_session_encrypted.js +423 -421
  113. package/script/storage/2_storage_indexed_db.js +26 -44
  114. package/script/storage/2_storage_local_storage.js +3 -16
  115. package/script/storage/2_storage_memory.js +24 -41
  116. package/script/storage/2_storage_session_storage.js +3 -16
  117. package/script/tl/1_tl_reader.d.ts +1 -1
  118. package/script/tl/1_tl_reader.d.ts.map +1 -1
  119. package/script/tl/1_tl_reader.js +96 -104
  120. package/script/tl/1_tl_writer.js +170 -179
  121. package/script/transport/0_transport.js +1 -8
  122. package/script/transport/1_transport_abridged.js +11 -24
  123. package/script/transport/1_transport_intermediate.js +10 -23
  124. package/script/utilities/0_mutex.js +4 -19
  125. package/script/utilities/0_part_stream.js +11 -25
  126. package/script/utilities/1_crypto.js +43 -54
  127. package/script/utilities/2_queue.js +30 -48
@@ -18,18 +18,6 @@
18
18
  * You should have received a copy of the GNU Lesser General Public License
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
- var __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 _StorageOperations_instances, _StorageOperations_storage, _StorageOperations_supportsFiles, _StorageOperations_mustSerialize, _StorageOperations_L, _StorageOperations_maps, _StorageOperations_values, _StorageOperations_addMap, _StorageOperations_addValue, _StorageOperations_lastCommit, _StorageOperations_accountId, _StorageOperations_getUpdateId, _StorageMap_storage, _StorageMap_path, _StorageMap_pendingUpdates, _StorageMap_cache, _StorageValue_storage, _StorageValue_key, _StorageValue_updatePending, _StorageValue_value, _StorageAuth_instances, _StorageAuth_authKeyId, _StorageAuth_resetAuthKeyId;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.StorageOperations = exports.K = void 0;
35
23
  const _0_deps_js_1 = require("../0_deps.js");
@@ -96,74 +84,54 @@ exports.K = {
96
84
  },
97
85
  };
98
86
  class StorageOperations {
87
+ #storage;
88
+ #supportsFiles;
89
+ #mustSerialize;
90
+ #L;
91
+ #maps = new Array();
92
+ #values = new Array();
93
+ auth;
94
+ channelPts;
95
+ peers;
96
+ usernames;
97
+ translations;
99
98
  constructor(storage) {
100
- _StorageOperations_instances.add(this);
101
- _StorageOperations_storage.set(this, void 0);
102
- _StorageOperations_supportsFiles.set(this, void 0);
103
- _StorageOperations_mustSerialize.set(this, void 0);
104
- _StorageOperations_L.set(this, void 0);
105
- _StorageOperations_maps.set(this, new Array());
106
- _StorageOperations_values.set(this, new Array());
107
- Object.defineProperty(this, "auth", {
108
- enumerable: true,
109
- configurable: true,
110
- writable: true,
111
- value: void 0
112
- });
113
- Object.defineProperty(this, "channelPts", {
114
- enumerable: true,
115
- configurable: true,
116
- writable: true,
117
- value: void 0
118
- });
119
- Object.defineProperty(this, "peers", {
120
- enumerable: true,
121
- configurable: true,
122
- writable: true,
123
- value: void 0
124
- });
125
- Object.defineProperty(this, "usernames", {
126
- enumerable: true,
127
- configurable: true,
128
- writable: true,
129
- value: void 0
130
- });
131
- Object.defineProperty(this, "translations", {
132
- enumerable: true,
133
- configurable: true,
134
- writable: true,
135
- value: void 0
136
- });
137
- _StorageOperations_lastCommit.set(this, null);
138
- _StorageOperations_accountId.set(this, null);
139
- __classPrivateFieldSet(this, _StorageOperations_storage, storage, "f");
140
- __classPrivateFieldSet(this, _StorageOperations_supportsFiles, storage.supportsFiles, "f");
141
- __classPrivateFieldSet(this, _StorageOperations_mustSerialize, storage.mustSerialize, "f");
142
- __classPrivateFieldSet(this, _StorageOperations_L, (0, _1_utilities_js_1.getLogger)("StorageOperations"), "f");
143
- this.auth = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addValue).call(this, new StorageAuth(storage));
144
- this.channelPts = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addMap).call(this, new StorageMap(storage, "channelPts"));
145
- this.peers = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addMap).call(this, new StorageMap(storage, "peers"));
146
- this.usernames = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addMap).call(this, new StorageMap(storage, "usernames"));
147
- this.translations = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addMap).call(this, new StorageMap(storage, "translations"));
99
+ this.#storage = storage;
100
+ this.#supportsFiles = storage.supportsFiles;
101
+ this.#mustSerialize = storage.mustSerialize;
102
+ this.#L = (0, _1_utilities_js_1.getLogger)("StorageOperations");
103
+ this.auth = this.#addValue(new StorageAuth(storage));
104
+ this.channelPts = this.#addMap(new StorageMap(storage, "channelPts"));
105
+ this.peers = this.#addMap(new StorageMap(storage, "peers"));
106
+ this.usernames = this.#addMap(new StorageMap(storage, "usernames"));
107
+ this.translations = this.#addMap(new StorageMap(storage, "translations"));
108
+ }
109
+ #addMap(map) {
110
+ this.#maps.push(map);
111
+ return map;
112
+ }
113
+ #addValue(value) {
114
+ this.#values.push(value);
115
+ return value;
148
116
  }
149
117
  get provider() {
150
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f");
118
+ return this.#storage;
151
119
  }
152
120
  get supportsFiles() {
153
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").supportsFiles;
121
+ return this.#storage.supportsFiles;
154
122
  }
155
123
  async initialize() {
156
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").initialize();
124
+ await this.#storage.initialize();
157
125
  await this.auth.get();
158
126
  }
159
127
  set(...args) {
160
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(...args);
128
+ return this.#storage.set(...args);
161
129
  }
162
130
  incr(...args) {
163
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").incr(...args);
131
+ return this.#storage.incr(...args);
164
132
  }
165
133
  get(...args) {
166
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(...args);
134
+ return this.#storage.get(...args);
167
135
  }
168
136
  async exportAuthString(apiId_) {
169
137
  if (typeof apiId_ === "number") {
@@ -198,56 +166,57 @@ class StorageOperations {
198
166
  userId,
199
167
  });
200
168
  }
169
+ #lastCommit = null;
201
170
  async commit(force = false) {
202
- if (__classPrivateFieldGet(this, _StorageOperations_storage, "f").isMemory) {
171
+ if (this.#storage.isMemory) {
203
172
  return;
204
173
  }
205
- const pending = __classPrivateFieldGet(this, _StorageOperations_values, "f").filter((v) => v.isUpdatePending).length + __classPrivateFieldGet(this, _StorageOperations_maps, "f").filter((v) => v.pendingUpdateCount > 0).length;
174
+ const pending = this.#values.filter((v) => v.isUpdatePending).length + this.#maps.filter((v) => v.pendingUpdateCount > 0).length;
206
175
  if (pending <= 0) {
207
- __classPrivateFieldGet(this, _StorageOperations_L, "f").debug("nothing to commit");
176
+ this.#L.debug("nothing to commit");
208
177
  return;
209
178
  }
210
179
  let commit = false;
211
180
  if (force) {
212
- __classPrivateFieldGet(this, _StorageOperations_L, "f").debug("committing because force = true");
181
+ this.#L.debug("committing because force = true");
213
182
  commit = true;
214
183
  }
215
184
  else {
216
185
  if (!commit && pending >= 1_000) {
217
- __classPrivateFieldGet(this, _StorageOperations_L, "f").debug("committing because pending writes >= threshold");
186
+ this.#L.debug("committing because pending writes >= threshold");
218
187
  commit = true;
219
188
  }
220
- else if (__classPrivateFieldGet(this, _StorageOperations_lastCommit, "f") === null) {
221
- __classPrivateFieldGet(this, _StorageOperations_L, "f").debug("committing because there is no last commit");
189
+ else if (this.#lastCommit === null) {
190
+ this.#L.debug("committing because there is no last commit");
222
191
  commit = true;
223
192
  }
224
- else if (Date.now() - __classPrivateFieldGet(this, _StorageOperations_lastCommit, "f").getTime() >= 5 * _0_deps_js_1.MINUTE) {
225
- __classPrivateFieldGet(this, _StorageOperations_L, "f").debug("committing because last commit is older than threshold");
193
+ else if (Date.now() - this.#lastCommit.getTime() >= 5 * _0_deps_js_1.MINUTE) {
194
+ this.#L.debug("committing because last commit is older than threshold");
226
195
  commit = true;
227
196
  }
228
197
  else {
229
- __classPrivateFieldGet(this, _StorageOperations_L, "f").debug("not committing");
198
+ this.#L.debug("not committing");
230
199
  }
231
200
  }
232
201
  if (commit) {
233
- const values = __classPrivateFieldGet(this, _StorageOperations_values, "f").filter((v) => v.isUpdatePending).map((v) => v.commit());
234
- const maps = __classPrivateFieldGet(this, _StorageOperations_maps, "f").filter((v) => v.pendingUpdateCount > 0).map((v) => v.commit());
202
+ const values = this.#values.filter((v) => v.isUpdatePending).map((v) => v.commit());
203
+ const maps = this.#maps.filter((v) => v.pendingUpdateCount > 0).map((v) => v.commit());
235
204
  await Promise.all(values.concat(maps));
236
- __classPrivateFieldGet(this, _StorageOperations_L, "f").debug("committed", values.length, "value(s) and", maps.length, "map(s)");
237
- __classPrivateFieldSet(this, _StorageOperations_lastCommit, new Date(), "f");
205
+ this.#L.debug("committed", values.length, "value(s) and", maps.length, "map(s)");
206
+ this.#lastCommit = new Date();
238
207
  }
239
208
  }
240
209
  async setTlObject(key, value) {
241
210
  if (value === null) {
242
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
211
+ await this.#storage.set(key, null);
243
212
  }
244
213
  else {
245
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, __classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? [value._, (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(value))] : value);
214
+ await this.#storage.set(key, this.#mustSerialize ? [value._, (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(value))] : value);
246
215
  }
247
216
  }
248
217
  async getTlObject(keyOrBuffer) {
249
218
  // @ts-ignore: TBD
250
- const buffer = (keyOrBuffer instanceof Uint8Array || _2_tl_js_1.Api.isValidObject(keyOrBuffer)) ? keyOrBuffer : await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(keyOrBuffer);
219
+ const buffer = (keyOrBuffer instanceof Uint8Array || _2_tl_js_1.Api.isValidObject(keyOrBuffer)) ? keyOrBuffer : await this.#storage.get(keyOrBuffer);
251
220
  if (buffer !== null) {
252
221
  if (buffer instanceof Uint8Array) {
253
222
  return await _2_tl_js_1.Api.deserializeType(_2_tl_js_1.X, (0, _1_utilities_js_1.rleDecode)(buffer));
@@ -271,19 +240,19 @@ class StorageOperations {
271
240
  }
272
241
  async setMessage(chatId, messageId, message) {
273
242
  if (chatId > _1_utilities_js_1.ZERO_CHANNEL_ID) {
274
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.messages.messageRef(messageId), message === null ? null : chatId);
243
+ await this.#storage.set(exports.K.messages.messageRef(messageId), message === null ? null : chatId);
275
244
  }
276
245
  await this.setTlObject(exports.K.messages.message(chatId, messageId), message);
277
246
  }
278
247
  async deleteMessages() {
279
248
  const maybePromises = new Array();
280
- for await (const [k, o] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.messages.allMessageRefs() })) {
281
- maybePromises.push(Promise.all([__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(k, null), o === null ? Promise.resolve() : __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.messages.message(o, k[1]), null)]));
249
+ for await (const [k, o] of await this.#storage.getMany({ prefix: exports.K.messages.allMessageRefs() })) {
250
+ maybePromises.push(Promise.all([this.#storage.set(k, null), o === null ? Promise.resolve() : this.#storage.set(exports.K.messages.message(o, k[1]), null)]));
282
251
  }
283
252
  await Promise.all(maybePromises.filter((v) => v instanceof Promise));
284
253
  }
285
254
  getMessageChat(messageId) {
286
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.messages.messageRef(messageId));
255
+ return this.#storage.get(exports.K.messages.messageRef(messageId));
287
256
  }
288
257
  async getMessage(chatId, messageId) {
289
258
  return await this.getTlObject(exports.K.messages.message(chatId, messageId));
@@ -295,31 +264,32 @@ class StorageOperations {
295
264
  setPeer2(chatP, accessHash) {
296
265
  this.peers.set([chatP.id], [chatP, accessHash]);
297
266
  }
267
+ #accountId = null;
298
268
  async getAccountId() {
299
- if (__classPrivateFieldGet(this, _StorageOperations_accountId, "f") !== null) {
300
- return __classPrivateFieldGet(this, _StorageOperations_accountId, "f");
269
+ if (this.#accountId !== null) {
270
+ return this.#accountId;
301
271
  }
302
272
  else {
303
- return __classPrivateFieldSet(this, _StorageOperations_accountId, (await this.auth.get())?.userId ?? null, "f");
273
+ return this.#accountId = (await this.auth.get())?.userId ?? null;
304
274
  }
305
275
  }
306
276
  async setIsPremium(isPremium) {
307
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.auth.isPremium(), isPremium);
277
+ await this.#storage.set(exports.K.auth.isPremium(), isPremium);
308
278
  }
309
279
  async getIsPremium() {
310
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.auth.isPremium());
280
+ return await this.#storage.get(exports.K.auth.isPremium());
311
281
  }
312
282
  async updateStickerSetName(id, accessHash, name) {
313
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.stickerSetName(id, accessHash), [name, new Date()]);
283
+ await this.#storage.set(exports.K.cache.stickerSetName(id, accessHash), [name, new Date()]);
314
284
  }
315
285
  getStickerSetName(id, accessHash) {
316
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.stickerSetName(id, accessHash));
286
+ return this.#storage.get(exports.K.cache.stickerSetName(id, accessHash));
317
287
  }
318
288
  async setServerSalt(serverSalt) {
319
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.session.serverSalt(), serverSalt);
289
+ await this.#storage.set(exports.K.session.serverSalt(), serverSalt);
320
290
  }
321
291
  getServerSalt() {
322
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.session.serverSalt());
292
+ return this.#storage.get(exports.K.session.serverSalt());
323
293
  }
324
294
  async getHistory(chatId, offsetId, limit) {
325
295
  if (offsetId === 0) {
@@ -327,7 +297,7 @@ class StorageOperations {
327
297
  }
328
298
  ++limit;
329
299
  const messages = new Array();
330
- for await (const [_, buffer] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ start: exports.K.messages.message(chatId, 0), end: exports.K.messages.message(chatId, offsetId) }, { limit, reverse: true })) {
300
+ for await (const [_, buffer] of await this.#storage.getMany({ start: exports.K.messages.message(chatId, 0), end: exports.K.messages.message(chatId, offsetId) }, { limit, reverse: true })) {
331
301
  const message = await this.getTlObject(buffer);
332
302
  if ("id" in message && message.id === offsetId) {
333
303
  continue;
@@ -337,18 +307,18 @@ class StorageOperations {
337
307
  return messages;
338
308
  }
339
309
  async getFile(id) {
340
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
310
+ if (!this.#supportsFiles) {
341
311
  return null;
342
312
  }
343
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.file(id));
313
+ return await this.#storage.get(exports.K.cache.file(id));
344
314
  }
345
315
  async *iterFileParts(id, partCount, offset, signal) {
346
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
316
+ if (!this.#supportsFiles) {
347
317
  return;
348
318
  }
349
319
  for (let i = offset; i < partCount; i++) {
350
320
  signal?.throwIfAborted();
351
- const part = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.filePart(id, i));
321
+ const part = await this.#storage.get(exports.K.cache.filePart(id, i));
352
322
  if (part === null) {
353
323
  continue;
354
324
  }
@@ -356,22 +326,22 @@ class StorageOperations {
356
326
  }
357
327
  }
358
328
  async saveFilePart(id, index, bytes) {
359
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
329
+ if (!this.#supportsFiles) {
360
330
  return;
361
331
  }
362
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.filePart(id, index), bytes);
332
+ await this.#storage.set(exports.K.cache.filePart(id, index), bytes);
363
333
  }
364
334
  async setFilePartCount(id, partCount, chunkSize) {
365
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
335
+ if (!this.#supportsFiles) {
366
336
  return;
367
337
  }
368
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.file(id), [partCount, chunkSize]);
338
+ await this.#storage.set(exports.K.cache.file(id), [partCount, chunkSize]);
369
339
  }
370
340
  async setCustomEmojiDocument(id, document) {
371
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.customEmojiDocument(id), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(document)) : document, new Date()]);
341
+ await this.#storage.set(exports.K.cache.customEmojiDocument(id), [this.#mustSerialize ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(document)) : document, new Date()]);
372
342
  }
373
343
  async getCustomEmojiDocument(id) {
374
- const v = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.customEmojiDocument(id));
344
+ const v = await this.#storage.get(exports.K.cache.customEmojiDocument(id));
375
345
  if (v !== null) {
376
346
  return [await this.getTlObject(v[0]), v[1]];
377
347
  }
@@ -380,10 +350,10 @@ class StorageOperations {
380
350
  }
381
351
  }
382
352
  async setBusinessConnection(id, connection) {
383
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.businessConnection(id), connection === null ? null : __classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(connection)) : connection);
353
+ await this.#storage.set(exports.K.cache.businessConnection(id), connection === null ? null : this.#mustSerialize ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(connection)) : connection);
384
354
  }
385
355
  async getBusinessConnection(id) {
386
- const v = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.businessConnection(id));
356
+ const v = await this.#storage.get(exports.K.cache.businessConnection(id));
387
357
  if (v !== null) {
388
358
  return await this.getTlObject(v);
389
359
  }
@@ -392,10 +362,10 @@ class StorageOperations {
392
362
  }
393
363
  }
394
364
  async setInlineQueryAnswer(userId, chatId, query, offset, results, date) {
395
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.inlineQueryAnswer(userId, chatId, query, offset), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(results)) : results, date]);
365
+ await this.#storage.set(exports.K.cache.inlineQueryAnswer(userId, chatId, query, offset), [this.#mustSerialize ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(results)) : results, date]);
396
366
  }
397
367
  async getInlineQueryAnswer(userId, chatId, query, offset) {
398
- const peer_ = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.inlineQueryAnswer(userId, chatId, query, offset));
368
+ const peer_ = await this.#storage.get(exports.K.cache.inlineQueryAnswer(userId, chatId, query, offset));
399
369
  if (peer_ !== null) {
400
370
  const [obj_, date] = peer_;
401
371
  return [_2_tl_js_1.Api.as("messages.botResults", await this.getTlObject(obj_)), date];
@@ -405,10 +375,10 @@ class StorageOperations {
405
375
  }
406
376
  }
407
377
  async setCallbackQueryAnswer(chatId, messageId, question, answer) {
408
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.callbackQueryAnswer(chatId, messageId, question), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(answer)) : answer, new Date()]);
378
+ await this.#storage.set(exports.K.cache.callbackQueryAnswer(chatId, messageId, question), [this.#mustSerialize ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(answer)) : answer, new Date()]);
409
379
  }
410
380
  async getCallbackQueryAnswer(chatId, messageId, question) {
411
- const peer_ = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.callbackQueryAnswer(chatId, messageId, question));
381
+ const peer_ = await this.#storage.get(exports.K.cache.callbackQueryAnswer(chatId, messageId, question));
412
382
  if (peer_ !== null) {
413
383
  const [obj_, date] = peer_;
414
384
  return [_2_tl_js_1.Api.as("messages.botCallbackAnswer", await this.getTlObject(obj_)), date];
@@ -430,23 +400,33 @@ class StorageOperations {
430
400
  return await this.getTlObject(exports.K.cache.groupCall(id));
431
401
  }
432
402
  async setGroupCallAccessHash(id, accessHash) {
433
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.groupCallAccessHash(id), accessHash);
403
+ await this.#storage.set(exports.K.cache.groupCallAccessHash(id), accessHash);
434
404
  }
435
405
  async getGroupCallAccessHash(id) {
436
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.groupCallAccessHash(id));
406
+ return await this.#storage.get(exports.K.cache.groupCallAccessHash(id));
407
+ }
408
+ #getUpdateId(update) {
409
+ let id = BigInt(Date.now()) << 32n;
410
+ if ("pts" in update && update.pts) {
411
+ id |= BigInt(update.pts);
412
+ }
413
+ else {
414
+ id |= BigInt(0xffffffffn);
415
+ }
416
+ return id;
437
417
  }
438
418
  async setUpdate(boxId, update) {
439
- await this.setTlObject(exports.K.updates.update(boxId, __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_getUpdateId).call(this, update)), update);
419
+ await this.setTlObject(exports.K.updates.update(boxId, this.#getUpdateId(update)), update);
440
420
  }
441
421
  async deleteUpdates() {
442
422
  const maybePromises = new Array();
443
- for await (const [k] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.updates.all() })) {
444
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(k, null));
423
+ for await (const [k] of await this.#storage.getMany({ prefix: exports.K.updates.all() })) {
424
+ maybePromises.push(this.#storage.set(k, null));
445
425
  }
446
426
  await Promise.all(maybePromises.filter((v) => v instanceof Promise));
447
427
  }
448
428
  async getFirstUpdate(boxId) {
449
- for await (const [key, update] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.updates.updates(boxId) }, { limit: 1 })) {
429
+ for await (const [key, update] of await this.#storage.getMany({ prefix: exports.K.updates.updates(boxId) }, { limit: 1 })) {
450
430
  return [key, (await this.getTlObject(update))];
451
431
  }
452
432
  return null;
@@ -485,49 +465,49 @@ class StorageOperations {
485
465
  }
486
466
  }
487
467
  async deleteFiles() {
488
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
468
+ if (!this.#supportsFiles) {
489
469
  return;
490
470
  }
491
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.fileParts() })) {
492
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
471
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.fileParts() })) {
472
+ await this.#storage.set(key, null);
493
473
  }
494
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.files() })) {
495
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
474
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.files() })) {
475
+ await this.#storage.set(key, null);
496
476
  }
497
477
  }
498
478
  async deleteCustomEmojiDocuments() {
499
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.customEmojiDocuments() })) {
500
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
479
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.customEmojiDocuments() })) {
480
+ await this.#storage.set(key, null);
501
481
  }
502
482
  }
503
483
  async deleteBusinessConnections() {
504
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.businessConnections() })) {
505
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
484
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.businessConnections() })) {
485
+ await this.#storage.set(key, null);
506
486
  }
507
487
  }
508
488
  async deleteInlineQueryAnswers() {
509
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.inlineQueryAnswers() })) {
510
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
489
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.inlineQueryAnswers() })) {
490
+ await this.#storage.set(key, null);
511
491
  }
512
492
  }
513
493
  async deleteCallbackQueryAnswers() {
514
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.callbackQueryAnswers() })) {
515
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
494
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.callbackQueryAnswers() })) {
495
+ await this.#storage.set(key, null);
516
496
  }
517
497
  }
518
498
  async deleteFullChats() {
519
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.fullChats() })) {
520
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
499
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.fullChats() })) {
500
+ await this.#storage.set(key, null);
521
501
  }
522
502
  }
523
503
  async deleteGroupCalls() {
524
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.groupCalls() })) {
525
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
504
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.groupCalls() })) {
505
+ await this.#storage.set(key, null);
526
506
  }
527
507
  }
528
508
  async deleteStickerSetNames() {
529
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.stickerSetNames() })) {
530
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
509
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.stickerSetNames() })) {
510
+ await this.#storage.set(key, null);
531
511
  }
532
512
  }
533
513
  async clear() {
@@ -552,8 +532,8 @@ class StorageOperations {
552
532
  ]);
553
533
  }
554
534
  async reset() {
555
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: [] })) {
556
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
535
+ for await (const [key] of await this.#storage.getMany({ prefix: [] })) {
536
+ await this.#storage.set(key, null);
557
537
  }
558
538
  }
559
539
  async setPollResults(pollId, pollResults) {
@@ -564,8 +544,8 @@ class StorageOperations {
564
544
  }
565
545
  async deletePollResults() {
566
546
  const maybePromises = new Array();
567
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.pollResults() })) {
568
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null));
547
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.pollResults() })) {
548
+ maybePromises.push(this.#storage.set(key, null));
569
549
  }
570
550
  await Promise.all(maybePromises);
571
551
  }
@@ -577,76 +557,60 @@ class StorageOperations {
577
557
  }
578
558
  async deletePolls() {
579
559
  const maybePromises = new Array();
580
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.polls() })) {
581
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null));
560
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.polls() })) {
561
+ maybePromises.push(this.#storage.set(key, null));
582
562
  }
583
563
  await Promise.all(maybePromises);
584
564
  }
585
565
  async setVoiceTranscription(voiceTranscription) {
586
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.voiceTranscription(BigInt(voiceTranscription.id)), voiceTranscription);
566
+ await this.#storage.set(exports.K.cache.voiceTranscription(BigInt(voiceTranscription.id)), voiceTranscription);
587
567
  }
588
568
  async getVoiceTranscription(transcriptionId) {
589
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.voiceTranscription(transcriptionId));
569
+ return await this.#storage.get(exports.K.cache.voiceTranscription(transcriptionId));
590
570
  }
591
571
  async deleteVoiceTranscriptions() {
592
572
  const maybePromises = new Array();
593
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.voiceTranscriptions() })) {
594
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null));
573
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.voiceTranscriptions() })) {
574
+ maybePromises.push(this.#storage.set(key, null));
595
575
  }
596
576
  await Promise.all(maybePromises);
597
577
  }
598
578
  async setVoiceTranscriptionReference(chatId, messageId, messageEditDate, transcriptionId) {
599
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.voiceTranscriptionReference(chatId, messageId, messageEditDate.getTime()), transcriptionId);
579
+ await this.#storage.set(exports.K.cache.voiceTranscriptionReference(chatId, messageId, messageEditDate.getTime()), transcriptionId);
600
580
  }
601
581
  async getVoiceTranscriptionReference(chatId, messageId, messageEditDate) {
602
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.voiceTranscriptionReference(chatId, messageId, messageEditDate.getTime()));
582
+ return await this.#storage.get(exports.K.cache.voiceTranscriptionReference(chatId, messageId, messageEditDate.getTime()));
603
583
  }
604
584
  async deleteVoiceTranscriptionReferences() {
605
585
  const maybePromises = new Array();
606
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.voiceTranscriptions() })) {
607
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null));
586
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.voiceTranscriptions() })) {
587
+ maybePromises.push(this.#storage.set(key, null));
608
588
  }
609
589
  await Promise.all(maybePromises);
610
590
  }
611
591
  }
612
592
  exports.StorageOperations = StorageOperations;
613
- _StorageOperations_storage = new WeakMap(), _StorageOperations_supportsFiles = new WeakMap(), _StorageOperations_mustSerialize = new WeakMap(), _StorageOperations_L = new WeakMap(), _StorageOperations_maps = new WeakMap(), _StorageOperations_values = new WeakMap(), _StorageOperations_lastCommit = new WeakMap(), _StorageOperations_accountId = new WeakMap(), _StorageOperations_instances = new WeakSet(), _StorageOperations_addMap = function _StorageOperations_addMap(map) {
614
- __classPrivateFieldGet(this, _StorageOperations_maps, "f").push(map);
615
- return map;
616
- }, _StorageOperations_addValue = function _StorageOperations_addValue(value) {
617
- __classPrivateFieldGet(this, _StorageOperations_values, "f").push(value);
618
- return value;
619
- }, _StorageOperations_getUpdateId = function _StorageOperations_getUpdateId(update) {
620
- let id = BigInt(Date.now()) << 32n;
621
- if ("pts" in update && update.pts) {
622
- id |= BigInt(update.pts);
623
- }
624
- else {
625
- id |= BigInt(0xffffffffn);
626
- }
627
- return id;
628
- };
629
593
  class StorageMap {
594
+ #storage;
595
+ #path;
630
596
  constructor(storage, path) {
631
- _StorageMap_storage.set(this, void 0);
632
- _StorageMap_path.set(this, void 0);
633
- _StorageMap_pendingUpdates.set(this, new Map());
634
- _StorageMap_cache.set(this, new _0_deps_js_2.LruCache(20_000));
635
- __classPrivateFieldSet(this, _StorageMap_storage, storage, "f");
636
- __classPrivateFieldSet(this, _StorageMap_path, path, "f");
597
+ this.#storage = storage;
598
+ this.#path = path;
637
599
  }
600
+ #pendingUpdates = new Map();
601
+ #cache = new _0_deps_js_2.LruCache(20_000);
638
602
  set(key, value) {
639
603
  const key_ = (0, _2_storage_js_1.toString)(key);
640
- __classPrivateFieldGet(this, _StorageMap_cache, "f").set(key_, value);
641
- if (!__classPrivateFieldGet(this, _StorageMap_storage, "f").isMemory) {
642
- __classPrivateFieldGet(this, _StorageMap_pendingUpdates, "f").set(key_, value);
604
+ this.#cache.set(key_, value);
605
+ if (!this.#storage.isMemory) {
606
+ this.#pendingUpdates.set(key_, value);
643
607
  }
644
608
  }
645
609
  get pendingUpdateCount() {
646
- return __classPrivateFieldGet(this, _StorageMap_pendingUpdates, "f").size;
610
+ return this.#pendingUpdates.size;
647
611
  }
648
612
  mustGet(key) {
649
- const value = __classPrivateFieldGet(this, _StorageMap_cache, "f").get((0, _2_storage_js_1.toString)(key));
613
+ const value = this.#cache.get((0, _2_storage_js_1.toString)(key));
650
614
  if (value === undefined) {
651
615
  (0, _0_deps_js_2.unreachable)();
652
616
  }
@@ -655,71 +619,67 @@ class StorageMap {
655
619
  }
656
620
  }
657
621
  async clear() {
658
- await (0, _1_utilities_js_2.awaitablePooledMap)(10, await __classPrivateFieldGet(this, _StorageMap_storage, "f").getMany({ prefix: [__classPrivateFieldGet(this, _StorageMap_path, "f")] }), async ([key]) => await __classPrivateFieldGet(this, _StorageMap_storage, "f").set(key, null));
622
+ await (0, _1_utilities_js_2.awaitablePooledMap)(10, await this.#storage.getMany({ prefix: [this.#path] }), async ([key]) => await this.#storage.set(key, null));
659
623
  }
660
624
  async get(key) {
661
625
  const key_ = (0, _2_storage_js_1.toString)(key);
662
- let value = __classPrivateFieldGet(this, _StorageMap_cache, "f").get(key_);
626
+ let value = this.#cache.get(key_);
663
627
  if (value === undefined) {
664
- value = await __classPrivateFieldGet(this, _StorageMap_storage, "f").get([__classPrivateFieldGet(this, _StorageMap_path, "f"), ...key]);
665
- __classPrivateFieldGet(this, _StorageMap_cache, "f").set(key_, value);
628
+ value = await this.#storage.get([this.#path, ...key]);
629
+ this.#cache.set(key_, value);
666
630
  }
667
631
  return value;
668
632
  }
669
633
  async commit() {
670
- if (__classPrivateFieldGet(this, _StorageMap_storage, "f").isMemory) {
634
+ if (this.#storage.isMemory) {
671
635
  return;
672
636
  }
673
- await (0, _1_utilities_js_2.awaitablePooledMap)(2, __classPrivateFieldGet(this, _StorageMap_pendingUpdates, "f"), async ([key, value]) => await __classPrivateFieldGet(this, _StorageMap_storage, "f").set([__classPrivateFieldGet(this, _StorageMap_path, "f"), ...(0, _2_storage_js_1.fromString)(key)], value));
674
- __classPrivateFieldGet(this, _StorageMap_pendingUpdates, "f").clear();
637
+ await (0, _1_utilities_js_2.awaitablePooledMap)(2, this.#pendingUpdates, async ([key, value]) => await this.#storage.set([this.#path, ...(0, _2_storage_js_1.fromString)(key)], value));
638
+ this.#pendingUpdates.clear();
675
639
  }
676
640
  }
677
- _StorageMap_storage = new WeakMap(), _StorageMap_path = new WeakMap(), _StorageMap_pendingUpdates = new WeakMap(), _StorageMap_cache = new WeakMap();
678
641
  class StorageValue {
642
+ #storage;
643
+ #key;
679
644
  constructor(storage, path) {
680
- _StorageValue_storage.set(this, void 0);
681
- _StorageValue_key.set(this, void 0);
682
- _StorageValue_updatePending.set(this, false);
683
- _StorageValue_value.set(this, void 0);
684
- __classPrivateFieldSet(this, _StorageValue_storage, storage, "f");
685
- __classPrivateFieldSet(this, _StorageValue_key, [path], "f");
645
+ this.#storage = storage;
646
+ this.#key = [path];
686
647
  }
648
+ #updatePending = false;
649
+ #value;
687
650
  set(value) {
688
- __classPrivateFieldSet(this, _StorageValue_value, value, "f");
689
- if (!__classPrivateFieldGet(this, _StorageValue_storage, "f").isMemory) {
690
- __classPrivateFieldSet(this, _StorageValue_updatePending, true, "f");
651
+ this.#value = value;
652
+ if (!this.#storage.isMemory) {
653
+ this.#updatePending = true;
691
654
  }
692
655
  }
693
656
  get isUpdatePending() {
694
- return __classPrivateFieldGet(this, _StorageValue_updatePending, "f");
657
+ return this.#updatePending;
695
658
  }
696
659
  mustGet() {
697
- return __classPrivateFieldGet(this, _StorageValue_value, "f") === undefined ? (0, _0_deps_js_2.unreachable)() : __classPrivateFieldGet(this, _StorageValue_value, "f");
660
+ return this.#value === undefined ? (0, _0_deps_js_2.unreachable)() : this.#value;
698
661
  }
699
662
  async get() {
700
- if (__classPrivateFieldGet(this, _StorageValue_value, "f") === undefined) {
701
- __classPrivateFieldSet(this, _StorageValue_value, await __classPrivateFieldGet(this, _StorageValue_storage, "f").get(__classPrivateFieldGet(this, _StorageValue_key, "f")), "f");
663
+ if (this.#value === undefined) {
664
+ this.#value = await this.#storage.get(this.#key);
702
665
  }
703
- return __classPrivateFieldGet(this, _StorageValue_value, "f");
666
+ return this.#value;
704
667
  }
705
668
  async commit() {
706
- if (__classPrivateFieldGet(this, _StorageValue_storage, "f").isMemory || __classPrivateFieldGet(this, _StorageValue_value, "f") === undefined) {
669
+ if (this.#storage.isMemory || this.#value === undefined) {
707
670
  return;
708
671
  }
709
- await __classPrivateFieldGet(this, _StorageValue_storage, "f").set(__classPrivateFieldGet(this, _StorageValue_key, "f"), __classPrivateFieldGet(this, _StorageValue_value, "f"));
710
- __classPrivateFieldSet(this, _StorageValue_updatePending, false, "f");
672
+ await this.#storage.set(this.#key, this.#value);
673
+ this.#updatePending = false;
711
674
  }
712
675
  }
713
- _StorageValue_storage = new WeakMap(), _StorageValue_key = new WeakMap(), _StorageValue_updatePending = new WeakMap(), _StorageValue_value = new WeakMap();
714
676
  class StorageAuth extends StorageValue {
715
677
  constructor(storage) {
716
678
  super(storage, "auth");
717
- _StorageAuth_instances.add(this);
718
- _StorageAuth_authKeyId.set(this, null);
719
679
  }
720
680
  async get() {
721
681
  const value = await super.get();
722
- await __classPrivateFieldGet(this, _StorageAuth_instances, "m", _StorageAuth_resetAuthKeyId).call(this, value);
682
+ await this.#resetAuthKeyId(value);
723
683
  return value;
724
684
  }
725
685
  mustGet() {
@@ -733,22 +693,23 @@ class StorageAuth extends StorageValue {
733
693
  }
734
694
  async set(auth) {
735
695
  super.set(auth);
736
- await __classPrivateFieldGet(this, _StorageAuth_instances, "m", _StorageAuth_resetAuthKeyId).call(this, auth);
696
+ await this.#resetAuthKeyId(auth);
737
697
  }
738
698
  async update(fn) {
739
699
  const auth = this.mustGet();
740
700
  fn(auth);
741
701
  await this.set(auth);
742
702
  }
703
+ #authKeyId = null;
704
+ async #resetAuthKeyId(auth) {
705
+ if (auth?.authKey) {
706
+ this.#authKeyId = (0, _1_utilities_js_1.intFromBytes)((await (0, _1_utilities_js_1.sha1)(auth.authKey)).subarray(-8));
707
+ }
708
+ else {
709
+ this.#authKeyId = null;
710
+ }
711
+ }
743
712
  get authKeyId() {
744
- return __classPrivateFieldGet(this, _StorageAuth_authKeyId, "f");
713
+ return this.#authKeyId;
745
714
  }
746
715
  }
747
- _StorageAuth_authKeyId = new WeakMap(), _StorageAuth_instances = new WeakSet(), _StorageAuth_resetAuthKeyId = async function _StorageAuth_resetAuthKeyId(auth) {
748
- if (auth?.authKey) {
749
- __classPrivateFieldSet(this, _StorageAuth_authKeyId, (0, _1_utilities_js_1.intFromBytes)((await (0, _1_utilities_js_1.sha1)(auth.authKey)).subarray(-8)), "f");
750
- }
751
- else {
752
- __classPrivateFieldSet(this, _StorageAuth_authKeyId, null, "f");
753
- }
754
- };