@tma.js/sdk-solid 2.1.3 → 2.1.4

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.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createComponent as gt, mergeProps as at, createContext as Qt, useContext as Ft, createEffect as ct, onCleanup as ht, createResource as Yt, createMemo as pt, from as Zt } from "solid-js";
2
- var Xt = Object.defineProperty, te = (e, t, s) => t in e ? Xt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (te(e, typeof t != "symbol" ? t + "" : t, s), s);
1
+ import { createComponent as gt, mergeProps as at, createContext as Qt, useContext as Yt, createEffect as ct, onCleanup as ht, createResource as Zt, createMemo as pt, from as Xt } from "solid-js";
2
+ var te = Object.defineProperty, ee = (e, t, s) => t in e ? te(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (ee(e, typeof t != "symbol" ? t + "" : t, s), s);
3
3
  function ft(e, t) {
4
4
  let s;
5
5
  const n = () => {
@@ -11,10 +11,10 @@ function mt(e) {
11
11
  const t = U(), { count: s } = t;
12
12
  t.unsubscribe(e), s && !t.count && Pe();
13
13
  }
14
- function ee(e) {
14
+ function se(e) {
15
15
  return U().subscribe(e), () => mt(e);
16
16
  }
17
- class se {
17
+ class ne {
18
18
  constructor(t, s = {}) {
19
19
  this.scope = t, this.options = s;
20
20
  }
@@ -54,21 +54,21 @@ class se {
54
54
  this.print("log", ...t);
55
55
  }
56
56
  }
57
- const Z = new se("SDK", {
57
+ const Z = new ne("SDK", {
58
58
  bgColor: "forestgreen",
59
59
  textColor: "white"
60
60
  });
61
- let Q = !1;
62
- const ut = ({ event: e, args: [t] }) => {
63
- Z.log("Event received:", t === void 0 ? { name: e } : { name: e, data: t });
61
+ let F = !1;
62
+ const ut = ({ name: e, payload: t }) => {
63
+ Z.log("Event received:", t ? { name: e, payload: t } : { name: e });
64
64
  };
65
- function ne(e) {
66
- Q !== e && (Q = e, e ? ee(ut) : mt(ut));
65
+ function re(e) {
66
+ F !== e && (F = e, e ? se(ut) : mt(ut));
67
67
  }
68
- function re(...e) {
69
- Q && Z.log(...e);
68
+ function ie(...e) {
69
+ F && Z.log(...e);
70
70
  }
71
- class B {
71
+ class O {
72
72
  constructor() {
73
73
  c(this, "listeners", /* @__PURE__ */ new Map()), c(this, "listenersCount", 0), c(this, "subscribeListeners", []);
74
74
  }
@@ -138,20 +138,31 @@ class B {
138
138
  }
139
139
  }
140
140
  }
141
- function F(e, t, s) {
141
+ function Q(e, t, s) {
142
142
  return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
143
143
  }
144
+ function bt(...e) {
145
+ let t = !1;
146
+ const s = [...e];
147
+ return [
148
+ (n) => !t && s.push(n),
149
+ () => {
150
+ t || (t = !0, s.forEach((n) => n()));
151
+ },
152
+ t
153
+ ];
154
+ }
144
155
  class $ extends Error {
145
156
  constructor(t, s, n) {
146
157
  super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, $.prototype);
147
158
  }
148
159
  }
149
- function w(e, t, s) {
160
+ function b(e, t, s) {
150
161
  return new $(e, t, s);
151
162
  }
152
- const ie = "ERR_METHOD_UNSUPPORTED", oe = "ERR_METHOD_PARAMETER_UNSUPPORTED", ae = "ERR_UNKNOWN_ENV", ce = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", he = "ERR_TIMED_OUT", pe = "ERR_UNEXPECTED_TYPE", wt = "ERR_PARSE", ue = "ERR_NAVIGATION_LIST_EMPTY", le = "ERR_NAVIGATION_CURSOR_INVALID", Js = "ERR_NAVIGATION_ITEM_INVALID", Qs = "ERR_SSR_INIT", de = "ERR_INVALID_PATH_BASE";
163
+ const oe = "ERR_METHOD_UNSUPPORTED", ae = "ERR_METHOD_PARAMETER_UNSUPPORTED", ce = "ERR_UNKNOWN_ENV", he = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", pe = "ERR_TIMED_OUT", ue = "ERR_UNEXPECTED_TYPE", wt = "ERR_PARSE", le = "ERR_NAVIGATION_LIST_EMPTY", de = "ERR_NAVIGATION_CURSOR_INVALID", zs = "ERR_NAVIGATION_ITEM_INVALID", Js = "ERR_SSR_INIT", _e = "ERR_INVALID_PATH_BASE";
153
164
  function S() {
154
- return w(pe, "Value has unexpected type");
165
+ return b(ue, "Value has unexpected type");
155
166
  }
156
167
  class L {
157
168
  constructor(t, s, n) {
@@ -168,7 +179,7 @@ class L {
168
179
  try {
169
180
  return this.parser(t);
170
181
  } catch (s) {
171
- throw w(
182
+ throw b(
172
183
  wt,
173
184
  `Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
174
185
  s
@@ -192,7 +203,7 @@ const y = R((e) => {
192
203
  return !1;
193
204
  throw S();
194
205
  }, "boolean");
195
- function bt(e, t) {
206
+ function vt(e, t) {
196
207
  const s = {};
197
208
  for (const n in e) {
198
209
  const r = e[n];
@@ -209,7 +220,7 @@ function bt(e, t) {
209
220
  const a = o(t(i));
210
221
  a !== void 0 && (s[n] = a);
211
222
  } catch (a) {
212
- throw w(wt, `Unable to parse field "${n}"`, a);
223
+ throw b(wt, `Unable to parse field "${n}"`, a);
213
224
  }
214
225
  }
215
226
  return s;
@@ -223,7 +234,7 @@ function X(e) {
223
234
  function f(e, t) {
224
235
  return new L((s) => {
225
236
  const n = X(s);
226
- return bt(e, (r) => n[r]);
237
+ return vt(e, (r) => n[r]);
227
238
  }, !1, t);
228
239
  }
229
240
  const P = R((e) => {
@@ -239,14 +250,14 @@ const P = R((e) => {
239
250
  function tt(e) {
240
251
  return /^#[\da-f]{6}$/i.test(e);
241
252
  }
242
- function _e(e) {
253
+ function ge(e) {
243
254
  return /^#[\da-f]{3}$/i.test(e);
244
255
  }
245
- function vt(e) {
256
+ function yt(e) {
246
257
  const t = e.replace(/\s/g, "").toLowerCase();
247
258
  if (tt(t))
248
259
  return t;
249
- if (_e(t)) {
260
+ if (ge(t)) {
250
261
  let n = "#";
251
262
  for (let r = 0; r < 3; r += 1)
252
263
  n += t[1 + r].repeat(2);
@@ -260,23 +271,23 @@ function vt(e) {
260
271
  return n + (i.length === 1 ? "0" : "") + i;
261
272
  }, "#");
262
273
  }
263
- const h = R((e) => {
274
+ const p = R((e) => {
264
275
  if (typeof e == "string" || typeof e == "number")
265
276
  return e.toString();
266
277
  throw S();
267
- }, "string"), yt = R((e) => vt(h().parse(e)), "rgb");
268
- function ge(e) {
278
+ }, "string"), Et = R((e) => yt(p().parse(e)), "rgb");
279
+ function fe(e) {
269
280
  return f({
270
- eventType: h(),
281
+ eventType: p(),
271
282
  eventData: (t) => t
272
283
  }).parse(e);
273
284
  }
274
- function fe() {
285
+ function me() {
275
286
  ["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
276
287
  delete window[e];
277
288
  });
278
289
  }
279
- function me(e, t) {
290
+ function be(e, t) {
280
291
  window.dispatchEvent(new MessageEvent("message", {
281
292
  data: JSON.stringify({ eventType: e, eventData: t }),
282
293
  // We specify window.parent to imitate the case, the parent iframe sent us this event.
@@ -295,41 +306,36 @@ function we() {
295
306
  let t = window;
296
307
  e.forEach((s, n, r) => {
297
308
  if (n === r.length - 1) {
298
- t[s] = me;
309
+ t[s] = be;
299
310
  return;
300
311
  }
301
312
  s in t || (t[s] = {}), t = t[s];
302
313
  });
303
314
  });
304
315
  }
305
- const be = f({
306
- button_id: (e) => e == null ? void 0 : h().parse(e)
307
- }), ve = {
316
+ const ve = {
308
317
  clipboard_text_received: f({
309
- req_id: h(),
310
- data: (e) => e === null ? e : h().optional().parse(e)
318
+ req_id: p(),
319
+ data: (e) => e === null ? e : p().optional().parse(e)
311
320
  }),
312
321
  custom_method_invoked: f({
313
- req_id: h(),
322
+ req_id: p(),
314
323
  result: (e) => e,
315
- error: h().optional()
316
- }),
317
- invoice_closed: f({
318
- slug: h(),
319
- status: h()
320
- }),
321
- phone_requested: f({
322
- status: h()
324
+ error: p().optional()
323
325
  }),
326
+ invoice_closed: f({ slug: p(), status: p() }),
327
+ phone_requested: f({ status: p() }),
324
328
  popup_closed: {
325
- parse: (e) => be.parse(e ?? {})
329
+ parse(e) {
330
+ return f({
331
+ button_id: (t) => t == null ? void 0 : p().parse(t)
332
+ }).parse(e ?? {});
333
+ }
326
334
  },
327
- qr_text_received: f({
328
- data: h().optional()
329
- }),
335
+ qr_text_received: f({ data: p().optional() }),
330
336
  theme_changed: f({
331
337
  theme_params: (e) => {
332
- const t = yt().optional();
338
+ const t = Et().optional();
333
339
  return Object.entries(X(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
334
340
  }
335
341
  }),
@@ -339,23 +345,23 @@ const be = f({
339
345
  is_state_stable: y(),
340
346
  is_expanded: y()
341
347
  }),
342
- write_access_requested: f({
343
- status: h()
344
- })
348
+ write_access_requested: f({ status: p() })
345
349
  };
346
350
  function ye() {
347
- const e = new B();
348
- we();
349
- let t = [
351
+ const e = new O(), t = new O();
352
+ t.subscribe((n) => {
353
+ e.emit("event", { name: n.event, payload: n.args[0] });
354
+ }), we();
355
+ const [, s] = bt(
350
356
  // Don't forget to remove created handlers.
351
- fe,
357
+ me,
352
358
  // Add "resize" event listener to make sure, we always have fresh viewport information.
353
359
  // Desktop version of Telegram is sometimes not sending the viewport_changed
354
360
  // event. For example, when the MainButton is shown. That's why we should
355
361
  // add our own listener to make sure, viewport information is always fresh.
356
362
  // Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/10
357
- F("resize", () => {
358
- e.emit("viewport_changed", {
363
+ Q("resize", () => {
364
+ t.emit("viewport_changed", {
359
365
  width: window.innerWidth,
360
366
  height: window.innerHeight,
361
367
  is_state_stable: !0,
@@ -364,33 +370,44 @@ function ye() {
364
370
  }),
365
371
  // Add listener, which handles events sent from the Telegram web application and also events
366
372
  // generated by the local emitEvent function.
367
- F("message", (s) => {
368
- if (s.source !== window.parent)
373
+ Q("message", (n) => {
374
+ if (n.source !== window.parent)
369
375
  return;
370
- let n;
376
+ let r;
371
377
  try {
372
- n = ge(s.data);
378
+ r = fe(n.data);
373
379
  } catch {
374
380
  return;
375
381
  }
376
- const { eventType: r, eventData: i } = n, o = ve[r];
382
+ const { eventType: i, eventData: o } = r, a = ve[i];
377
383
  try {
378
- const a = o ? o.parse(i) : i;
379
- e.emit(...a ? [r, a] : [r]);
380
- } catch (a) {
384
+ const h = a ? a.parse(o) : o;
385
+ t.emit(...h ? [i, h] : [i]);
386
+ } catch (h) {
381
387
  Z.error(
382
- `An error occurred processing the "${r}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
383
- n,
384
- a
388
+ `An error occurred processing the "${i}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
389
+ r,
390
+ h
385
391
  );
386
392
  }
387
393
  }),
388
- // Clear emitter bound events.
389
- () => e.clear()
390
- ];
391
- return [e, () => {
392
- t.forEach((s) => s()), t = [];
393
- }];
394
+ // Clear emitters.
395
+ () => e.clear(),
396
+ () => t.clear()
397
+ );
398
+ return [{
399
+ on: t.on.bind(t),
400
+ off: t.off.bind(t),
401
+ subscribe(n) {
402
+ return e.on("event", n);
403
+ },
404
+ unsubscribe(n) {
405
+ e.off("event", n);
406
+ },
407
+ get count() {
408
+ return t.count + e.count;
409
+ }
410
+ }, s];
394
411
  }
395
412
  const [Ee, Pe] = ft(
396
413
  (e) => {
@@ -411,7 +428,7 @@ function H(e, t) {
411
428
  function v(e, t, s) {
412
429
  return U().on(e, t, s);
413
430
  }
414
- function q(e) {
431
+ function D(e) {
415
432
  return typeof e == "object" && e !== null && !Array.isArray(e);
416
433
  }
417
434
  function xe(e, t) {
@@ -423,15 +440,15 @@ function xe(e, t) {
423
440
  }
424
441
  return 0;
425
442
  }
426
- function b(e, t) {
443
+ function w(e, t) {
427
444
  return xe(e, t) <= 0;
428
445
  }
429
- function C(e, t, s) {
446
+ function x(e, t, s) {
430
447
  if (typeof s == "string") {
431
448
  if (e === "web_app_open_link" && t === "try_instant_view")
432
- return b("6.4", s);
449
+ return w("6.4", s);
433
450
  if (e === "web_app_set_header_color" && t === "color")
434
- return b("6.9", s);
451
+ return w("6.9", s);
435
452
  }
436
453
  switch (e) {
437
454
  case "web_app_open_tg_link":
@@ -440,27 +457,27 @@ function C(e, t, s) {
440
457
  case "web_app_set_background_color":
441
458
  case "web_app_set_header_color":
442
459
  case "web_app_trigger_haptic_feedback":
443
- return b("6.1", t);
460
+ return w("6.1", t);
444
461
  case "web_app_open_popup":
445
- return b("6.2", t);
462
+ return w("6.2", t);
446
463
  case "web_app_close_scan_qr_popup":
447
464
  case "web_app_open_scan_qr_popup":
448
465
  case "web_app_read_text_from_clipboard":
449
- return b("6.4", t);
466
+ return w("6.4", t);
450
467
  case "web_app_switch_inline_query":
451
- return b("6.7", t);
468
+ return w("6.7", t);
452
469
  case "web_app_invoke_custom_method":
453
470
  case "web_app_request_write_access":
454
471
  case "web_app_request_phone":
455
- return b("6.9", t);
472
+ return w("6.9", t);
456
473
  case "web_app_setup_settings_button":
457
- return b("6.10", t);
474
+ return w("6.10", t);
458
475
  case "web_app_biometry_get_info":
459
476
  case "web_app_biometry_open_settings":
460
477
  case "web_app_biometry_request_access":
461
478
  case "web_app_biometry_request_auth":
462
479
  case "web_app_biometry_update_token":
463
- return b("7.2", t);
480
+ return w("7.2", t);
464
481
  default:
465
482
  return [
466
483
  "iframe_ready",
@@ -478,30 +495,30 @@ function C(e, t, s) {
478
495
  }
479
496
  }
480
497
  function Ce(e) {
481
- return "external" in e && q(e.external) && "notify" in e.external && typeof e.external.notify == "function";
498
+ return "external" in e && D(e.external) && "notify" in e.external && typeof e.external.notify == "function";
482
499
  }
483
- function Et(e) {
484
- return "TelegramWebviewProxy" in e && q(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
500
+ function Pt(e) {
501
+ return "TelegramWebviewProxy" in e && D(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
485
502
  }
486
- function Pt() {
503
+ function xt() {
487
504
  try {
488
505
  return window.self !== window.top;
489
506
  } catch {
490
507
  return !0;
491
508
  }
492
509
  }
493
- let xt = "https://web.telegram.org";
510
+ let Ct = "https://web.telegram.org";
494
511
  function Fs(e) {
495
- xt = e;
512
+ Ct = e;
496
513
  }
497
514
  function Se() {
498
- return xt;
515
+ return Ct;
499
516
  }
500
517
  function k(e, t, s) {
501
518
  let n = {}, r;
502
519
  t === void 0 && s === void 0 ? n = {} : t !== void 0 && s !== void 0 ? (n = s, r = t) : t !== void 0 && ("targetOrigin" in t ? n = t : r = t);
503
520
  const { targetOrigin: i = Se() } = n;
504
- if (re("Posting event:", r ? { event: e, data: r } : { event: e }), Pt()) {
521
+ if (ie("Posting event:", r ? { event: e, data: r } : { event: e }), xt()) {
505
522
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
506
523
  return;
507
524
  }
@@ -509,42 +526,42 @@ function k(e, t, s) {
509
526
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
510
527
  return;
511
528
  }
512
- if (Et(window)) {
529
+ if (Pt(window)) {
513
530
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
514
531
  return;
515
532
  }
516
- throw w(
517
- ae,
533
+ throw b(
534
+ ce,
518
535
  "Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside of Telegram application environment."
519
536
  );
520
537
  }
521
538
  function Re(e) {
522
539
  return (t, s) => {
523
- if (!C(t, e))
524
- throw w(ie, `Method "${t}" is unsupported in Mini Apps version ${e}`);
525
- if (q(s)) {
540
+ if (!x(t, e))
541
+ throw b(oe, `Method "${t}" is unsupported in Mini Apps version ${e}`);
542
+ if (D(s)) {
526
543
  let n;
527
- if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !C(t, n, e))
528
- throw w(
529
- oe,
544
+ if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !x(t, n, e))
545
+ throw b(
546
+ ae,
530
547
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
531
548
  );
532
549
  }
533
550
  return k(t, s);
534
551
  };
535
552
  }
536
- function Ct(e) {
553
+ function St(e) {
537
554
  return ({ req_id: t }) => t === e;
538
555
  }
539
- function St(e) {
540
- return w(he, `Timeout reached: ${e}ms`);
556
+ function Rt(e) {
557
+ return b(pe, `Timeout reached: ${e}ms`);
541
558
  }
542
- function Rt(e, t) {
559
+ function Tt(e, t) {
543
560
  return Promise.race([
544
561
  typeof e == "function" ? e() : e,
545
562
  new Promise((s, n) => {
546
563
  setTimeout(() => {
547
- n(St(t));
564
+ n(Rt(t));
548
565
  }, t);
549
566
  })
550
567
  ]);
@@ -559,13 +576,13 @@ async function m(e) {
559
576
  capture: i,
560
577
  postEvent: o = k,
561
578
  timeout: a
562
- } = e, p = (Array.isArray(r) ? r : [r]).map(
579
+ } = e, h = (Array.isArray(r) ? r : [r]).map(
563
580
  (u) => v(u, (l) => (!i || i(l)) && t(l))
564
581
  );
565
582
  try {
566
- return o(n, e.params), await (a ? Rt(s, a) : s);
583
+ return o(n, e.params), await (a ? Tt(s, a) : s);
567
584
  } finally {
568
- p.forEach((u) => u());
585
+ h.forEach((u) => u());
569
586
  }
570
587
  }
571
588
  async function A(e, t, s, n = {}) {
@@ -581,30 +598,30 @@ async function A(e, t, s, n = {}) {
581
598
  params: t,
582
599
  req_id: s
583
600
  },
584
- capture: Ct(s)
601
+ capture: St(s)
585
602
  });
586
603
  if (i)
587
- throw w(ce, i);
604
+ throw b(he, i);
588
605
  return r;
589
606
  }
590
607
  function Y(...e) {
591
608
  return e.map((t) => {
592
609
  if (typeof t == "string")
593
610
  return t;
594
- if (q(t))
611
+ if (D(t))
595
612
  return Y(Object.entries(t).map((s) => s[1] && s[0]));
596
613
  if (Array.isArray(t))
597
614
  return Y(...t);
598
615
  }).filter(Boolean).join(" ");
599
616
  }
600
- function Ys(...e) {
601
- return e.reduce((t, s) => (q(s) && Object.entries(s).forEach(([n, r]) => {
617
+ function Qs(...e) {
618
+ return e.reduce((t, s) => (D(s) && Object.entries(s).forEach(([n, r]) => {
602
619
  const i = Y(t[n], r);
603
620
  i.length && (t[n] = i);
604
621
  }), t), {});
605
622
  }
606
- function Tt(e) {
607
- const t = vt(e);
623
+ function At(e) {
624
+ const t = yt(e);
608
625
  return Math.sqrt(
609
626
  [0.299, 0.587, 0.114].reduce((s, n, r) => {
610
627
  const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
@@ -614,7 +631,7 @@ function Tt(e) {
614
631
  }
615
632
  class Te {
616
633
  constructor(t) {
617
- c(this, "ee", new B()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
634
+ c(this, "ee", new O()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
618
635
  }
619
636
  /**
620
637
  * Clones current state and returns its copy.
@@ -638,12 +655,12 @@ class et {
638
655
  c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new Te(t), this.set = this.state.set.bind(this.state), this.get = this.state.get.bind(this.state), this.clone = this.state.clone.bind(this.state);
639
656
  }
640
657
  }
641
- function At(e, t) {
642
- return (s) => C(t[s], e);
658
+ function It(e, t) {
659
+ return (s) => x(t[s], e);
643
660
  }
644
661
  class st extends et {
645
662
  constructor(t, s, n) {
646
- super(t), c(this, "supports"), this.supports = At(s, n);
663
+ super(t), c(this, "supports"), this.supports = It(s, n);
647
664
  }
648
665
  }
649
666
  class Ae extends st {
@@ -675,13 +692,13 @@ class Ae extends st {
675
692
  this.isVisible = !0;
676
693
  }
677
694
  }
678
- const It = R((e) => e instanceof Date ? e : new Date(P().parse(e) * 1e3), "Date");
695
+ const Ot = R((e) => e instanceof Date ? e : new Date(P().parse(e) * 1e3), "Date");
679
696
  function nt(e, t) {
680
697
  return new L((s) => {
681
698
  if (typeof s != "string" && !(s instanceof URLSearchParams))
682
699
  throw S();
683
700
  const n = typeof s == "string" ? new URLSearchParams(s) : s;
684
- return bt(e, (r) => {
701
+ return vt(e, (r) => {
685
702
  const i = n.get(r);
686
703
  return i === null ? void 0 : i;
687
704
  });
@@ -689,13 +706,13 @@ function nt(e, t) {
689
706
  }
690
707
  const Ie = f({
691
708
  id: P(),
692
- type: h(),
693
- title: h(),
709
+ type: p(),
710
+ title: p(),
694
711
  photoUrl: {
695
- type: h().optional(),
712
+ type: p().optional(),
696
713
  from: "photo_url"
697
714
  },
698
- username: h().optional()
715
+ username: p().optional()
699
716
  }, "Chat").optional(), lt = f({
700
717
  addedToAttachmentMenu: {
701
718
  type: y().optional(),
@@ -706,7 +723,7 @@ const Ie = f({
706
723
  from: "allows_write_to_pm"
707
724
  },
708
725
  firstName: {
709
- type: h(),
726
+ type: p(),
710
727
  from: "first_name"
711
728
  },
712
729
  id: P(),
@@ -719,23 +736,23 @@ const Ie = f({
719
736
  from: "is_premium"
720
737
  },
721
738
  languageCode: {
722
- type: h().optional(),
739
+ type: p().optional(),
723
740
  from: "language_code"
724
741
  },
725
742
  lastName: {
726
- type: h().optional(),
743
+ type: p().optional(),
727
744
  from: "last_name"
728
745
  },
729
746
  photoUrl: {
730
- type: h().optional(),
747
+ type: p().optional(),
731
748
  from: "photo_url"
732
749
  },
733
- username: h().optional()
750
+ username: p().optional()
734
751
  }, "User").optional();
735
752
  function kt() {
736
753
  return nt({
737
754
  authDate: {
738
- type: It(),
755
+ type: Ot(),
739
756
  from: "auth_date"
740
757
  },
741
758
  canSendAfter: {
@@ -744,40 +761,40 @@ function kt() {
744
761
  },
745
762
  chat: Ie,
746
763
  chatInstance: {
747
- type: h().optional(),
764
+ type: p().optional(),
748
765
  from: "chat_instance"
749
766
  },
750
767
  chatType: {
751
- type: h().optional(),
768
+ type: p().optional(),
752
769
  from: "chat_type"
753
770
  },
754
- hash: h(),
771
+ hash: p(),
755
772
  queryId: {
756
- type: h().optional(),
773
+ type: p().optional(),
757
774
  from: "query_id"
758
775
  },
759
776
  receiver: lt,
760
777
  startParam: {
761
- type: h().optional(),
778
+ type: p().optional(),
762
779
  from: "start_param"
763
780
  },
764
781
  user: lt
765
782
  }, "InitData");
766
783
  }
767
- function ke(e) {
784
+ function Oe(e) {
768
785
  return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
769
786
  }
770
- function Oe(e) {
787
+ function ke(e) {
771
788
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
772
789
  }
773
- const Ot = R(
790
+ const qt = R(
774
791
  (e) => {
775
- const t = yt().optional();
776
- return Object.entries(X(e)).reduce((s, [n, r]) => (s[ke(n)] = t.parse(r), s), {});
792
+ const t = Et().optional();
793
+ return Object.entries(X(e)).reduce((s, [n, r]) => (s[Oe(n)] = t.parse(r), s), {});
777
794
  },
778
795
  "ThemeParams"
779
796
  );
780
- function qt(e) {
797
+ function Dt(e) {
781
798
  return nt({
782
799
  botInline: {
783
800
  type: y().optional(),
@@ -788,11 +805,11 @@ function qt(e) {
788
805
  from: "tgWebAppData"
789
806
  },
790
807
  initDataRaw: {
791
- type: h().optional(),
808
+ type: p().optional(),
792
809
  from: "tgWebAppData"
793
810
  },
794
811
  platform: {
795
- type: h(),
812
+ type: p(),
796
813
  from: "tgWebAppPlatform"
797
814
  },
798
815
  showSettings: {
@@ -800,56 +817,56 @@ function qt(e) {
800
817
  from: "tgWebAppShowSettings"
801
818
  },
802
819
  startParam: {
803
- type: h().optional(),
820
+ type: p().optional(),
804
821
  from: "tgWebAppStartParam"
805
822
  },
806
823
  themeParams: {
807
- type: Ot(),
824
+ type: qt(),
808
825
  from: "tgWebAppThemeParams"
809
826
  },
810
827
  version: {
811
- type: h(),
828
+ type: p(),
812
829
  from: "tgWebAppVersion"
813
830
  }
814
831
  }).parse(e);
815
832
  }
816
- function Dt(e) {
817
- return qt(
833
+ function Nt(e) {
834
+ return Dt(
818
835
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
819
836
  );
820
837
  }
821
838
  function qe() {
822
- return Dt(window.location.href);
839
+ return Nt(window.location.href);
823
840
  }
824
- function Nt() {
841
+ function Vt() {
825
842
  return performance.getEntriesByType("navigation")[0];
826
843
  }
827
844
  function De() {
828
- const e = Nt();
845
+ const e = Vt();
829
846
  if (!e)
830
847
  throw new Error("Unable to get first navigation entry.");
831
- return Dt(e.name);
848
+ return Nt(e.name);
832
849
  }
833
- function Vt(e) {
850
+ function Mt(e) {
834
851
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
835
852
  }
836
- function Mt(e, t) {
837
- sessionStorage.setItem(Vt(e), JSON.stringify(t));
853
+ function Bt(e, t) {
854
+ sessionStorage.setItem(Mt(e), JSON.stringify(t));
838
855
  }
839
- function Bt(e) {
840
- const t = sessionStorage.getItem(Vt(e));
856
+ function $t(e) {
857
+ const t = sessionStorage.getItem(Mt(e));
841
858
  try {
842
859
  return t ? JSON.parse(t) : void 0;
843
860
  } catch {
844
861
  }
845
862
  }
846
863
  function Ne() {
847
- return qt(Bt("launchParams") || "");
864
+ return Dt($t("launchParams") || "");
848
865
  }
849
866
  function Ve(e) {
850
867
  return JSON.stringify(
851
868
  Object.fromEntries(
852
- Object.entries(e).map(([t, s]) => [Oe(t), s])
869
+ Object.entries(e).map(([t, s]) => [ke(t), s])
853
870
  )
854
871
  );
855
872
  }
@@ -862,11 +879,11 @@ function Me(e) {
862
879
  showSettings: i,
863
880
  startParam: o,
864
881
  botInline: a
865
- } = e, p = new URLSearchParams();
866
- return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", Ve(s)), p.set("tgWebAppVersion", r), t && p.set("tgWebAppData", t), o && p.set("tgWebAppStartParam", o), typeof i == "boolean" && p.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && p.set("tgWebAppBotInline", a ? "1" : "0"), p.toString();
882
+ } = e, h = new URLSearchParams();
883
+ return h.set("tgWebAppPlatform", n), h.set("tgWebAppThemeParams", Ve(s)), h.set("tgWebAppVersion", r), t && h.set("tgWebAppData", t), o && h.set("tgWebAppStartParam", o), typeof i == "boolean" && h.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && h.set("tgWebAppBotInline", a ? "1" : "0"), h.toString();
867
884
  }
868
885
  function Be(e) {
869
- Mt("launchParams", Me(e));
886
+ Bt("launchParams", Me(e));
870
887
  }
871
888
  function $e() {
872
889
  for (const e of [
@@ -885,64 +902,53 @@ function $e() {
885
902
  }
886
903
  throw new Error("Unable to retrieve launch parameters from any known source.");
887
904
  }
888
- function $t() {
889
- const e = Nt();
905
+ function Lt() {
906
+ const e = Vt();
890
907
  return !!(e && e.type === "reload");
891
908
  }
892
909
  function Le() {
893
910
  let e = 0;
894
911
  return () => (e += 1).toString();
895
912
  }
896
- function Ue() {
897
- let e = !1;
898
- const t = [];
899
- return [
900
- (s) => !e && t.push(s),
901
- () => {
902
- e || (e = !0, t.forEach((s) => s()));
903
- },
904
- e
905
- ];
906
- }
907
- const [He] = ft(Le);
913
+ const [Ue] = ft(Le);
908
914
  function d(e, t) {
909
915
  return () => {
910
916
  const s = $e(), n = {
911
917
  ...s,
912
918
  postEvent: Re(s.version),
913
- createRequestId: He()
919
+ createRequestId: Ue()
914
920
  };
915
921
  if (typeof e == "function")
916
922
  return e(n);
917
- const [r, i, o] = Ue(), a = t({
923
+ const [r, i, o] = bt(), a = t({
918
924
  ...n,
919
925
  // State should only be passed only in case, current page was reloaded. If we don't add
920
926
  // this check, state restoration will work improperly in the web version of Telegram,
921
927
  // when we are always working in the same "session" (tab).
922
- state: $t() ? Bt(e) : void 0,
928
+ state: Lt() ? $t(e) : void 0,
923
929
  addCleanup: r
924
- }), p = (u) => (o || r(
930
+ }), h = (u) => (o || r(
925
931
  u.on("change", (l) => {
926
- Mt(e, l);
932
+ Bt(e, l);
927
933
  })
928
934
  ), u);
929
935
  return [
930
- a instanceof Promise ? a.then(p) : p(a),
936
+ a instanceof Promise ? a.then(h) : h(a),
931
937
  i
932
938
  ];
933
939
  };
934
940
  }
935
- const We = d("backButton", ({
941
+ const He = d("backButton", ({
936
942
  postEvent: e,
937
943
  version: t,
938
944
  state: s = { isVisible: !1 }
939
945
  }) => new Ae(s.isVisible, t, e));
940
- class D extends st {
946
+ class N extends st {
941
947
  constructor() {
942
948
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
943
949
  }
944
950
  }
945
- function Lt(e) {
951
+ function Ut(e) {
946
952
  const t = e.available ? e : {
947
953
  available: !1,
948
954
  device_id: "",
@@ -960,7 +966,7 @@ function Lt(e) {
960
966
  accessGranted: t.access_granted
961
967
  };
962
968
  }
963
- class je extends D {
969
+ class We extends N {
964
970
  constructor({ postEvent: t, version: s, ...n }) {
965
971
  super(n, s, {
966
972
  auth: "web_app_biometry_request_auth",
@@ -1038,7 +1044,7 @@ class je extends D {
1038
1044
  event: "biometry_info_received",
1039
1045
  params: { reason: t || "" }
1040
1046
  }).then((n) => {
1041
- const r = Lt(n);
1047
+ const r = Ut(n);
1042
1048
  return this.set(r), r.accessGranted;
1043
1049
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1044
1050
  }
@@ -1070,8 +1076,8 @@ class je extends D {
1070
1076
  );
1071
1077
  }
1072
1078
  }
1073
- async function Ge(e) {
1074
- return Lt(
1079
+ async function je(e) {
1080
+ return Ut(
1075
1081
  await m({
1076
1082
  ...e || {},
1077
1083
  method: "web_app_biometry_get_info",
@@ -1079,10 +1085,16 @@ async function Ge(e) {
1079
1085
  })
1080
1086
  );
1081
1087
  }
1082
- const Ke = d(
1088
+ const Ge = d(
1083
1089
  "biometryManager",
1084
- async ({ postEvent: e, version: t, state: s }) => new je({
1085
- ...s || await Ge({ timeout: 1e3 }),
1090
+ async ({ postEvent: e, version: t, state: s }) => new We({
1091
+ ...s || x("web_app_biometry_get_info", t) ? s || await je({ timeout: 1e3 }) : {
1092
+ available: !1,
1093
+ accessGranted: !1,
1094
+ accessRequested: !1,
1095
+ tokenSaved: !1,
1096
+ deviceId: ""
1097
+ },
1086
1098
  version: t,
1087
1099
  postEvent: e
1088
1100
  })
@@ -1092,7 +1104,7 @@ class rt extends et {
1092
1104
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
1093
1105
  }
1094
1106
  }
1095
- class ze extends rt {
1107
+ class Ke extends rt {
1096
1108
  constructor(t, s) {
1097
1109
  super({ isConfirmationNeeded: t }), this.postEvent = s;
1098
1110
  }
@@ -1119,19 +1131,19 @@ class ze extends rt {
1119
1131
  this.isConfirmationNeeded = !0;
1120
1132
  }
1121
1133
  }
1122
- const Je = d(
1134
+ const ze = d(
1123
1135
  "closingBehavior",
1124
1136
  ({
1125
1137
  postEvent: e,
1126
1138
  state: t = { isConfirmationNeeded: !1 }
1127
- }) => new ze(t.isConfirmationNeeded, e)
1139
+ }) => new Ke(t.isConfirmationNeeded, e)
1128
1140
  );
1129
1141
  class it {
1130
1142
  constructor(t, s) {
1131
- c(this, "supports"), this.supports = At(t, s);
1143
+ c(this, "supports"), this.supports = It(t, s);
1132
1144
  }
1133
1145
  }
1134
- function Qe(e) {
1146
+ function Je(e) {
1135
1147
  if (Array.isArray(e))
1136
1148
  return e;
1137
1149
  if (typeof e == "string")
@@ -1145,7 +1157,7 @@ function Qe(e) {
1145
1157
  }
1146
1158
  class Fe extends L {
1147
1159
  constructor(t, s, n) {
1148
- super(Qe, s, n), c(this, "itemParser"), this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
1160
+ super(Je, s, n), c(this, "itemParser"), this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
1149
1161
  }
1150
1162
  /**
1151
1163
  * Attempts to parse passed value
@@ -1161,13 +1173,13 @@ class Fe extends L {
1161
1173
  return this.itemParser = typeof t == "function" ? t : t.parse.bind(t), this;
1162
1174
  }
1163
1175
  }
1164
- function Ye(e) {
1176
+ function Qe(e) {
1165
1177
  return new Fe((t) => t, !1, e);
1166
1178
  }
1167
1179
  function dt(e, t) {
1168
1180
  return Object.fromEntries(e.map((s) => [s, t]));
1169
1181
  }
1170
- class Ze extends it {
1182
+ class Ye extends it {
1171
1183
  constructor(t, s, n) {
1172
1184
  super(t, {
1173
1185
  delete: "web_app_invoke_custom_method",
@@ -1195,7 +1207,7 @@ class Ze extends it {
1195
1207
  * @param options - request execution options.
1196
1208
  */
1197
1209
  async getKeys(t = {}) {
1198
- return Ye().of(h()).parse(
1210
+ return Qe().of(p()).parse(
1199
1211
  await A(
1200
1212
  "getStorageKeys",
1201
1213
  {},
@@ -1213,7 +1225,7 @@ class Ze extends it {
1213
1225
  { keys: n },
1214
1226
  this.createRequestId(),
1215
1227
  { ...s, postEvent: this.postEvent }
1216
- ), i = f(dt(n, h()), "CloudStorageData").parse(r);
1228
+ ), i = f(dt(n, p()), "CloudStorageData").parse(r);
1217
1229
  return Array.isArray(t) ? i : i[t];
1218
1230
  }
1219
1231
  /**
@@ -1231,10 +1243,10 @@ class Ze extends it {
1231
1243
  );
1232
1244
  }
1233
1245
  }
1234
- const Xe = d(
1235
- ({ createRequestId: e, postEvent: t, version: s }) => new Ze(s, e, t)
1246
+ const Ze = d(
1247
+ ({ createRequestId: e, postEvent: t, version: s }) => new Ye(s, e, t)
1236
1248
  );
1237
- class ts extends it {
1249
+ class Xe extends it {
1238
1250
  constructor(t, s) {
1239
1251
  super(t, {
1240
1252
  impactOccurred: "web_app_trigger_haptic_feedback",
@@ -1276,10 +1288,10 @@ class ts extends it {
1276
1288
  this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
1277
1289
  }
1278
1290
  }
1279
- const es = d(
1280
- ({ version: e, postEvent: t }) => new ts(e, t)
1291
+ const ts = d(
1292
+ ({ version: e, postEvent: t }) => new Xe(e, t)
1281
1293
  );
1282
- class ss {
1294
+ class es {
1283
1295
  constructor(t) {
1284
1296
  this.initData = t;
1285
1297
  }
@@ -1352,13 +1364,13 @@ class ss {
1352
1364
  return this.initData.user;
1353
1365
  }
1354
1366
  }
1355
- const ns = d(
1356
- ({ initData: e }) => e ? new ss(e) : void 0
1367
+ const ss = d(
1368
+ ({ initData: e }) => e ? new es(e) : void 0
1357
1369
  );
1358
- function Zs(e) {
1370
+ function Ys(e) {
1359
1371
  return kt().parse(e);
1360
1372
  }
1361
- class rs extends D {
1373
+ class ns extends N {
1362
1374
  constructor(t, s, n) {
1363
1375
  super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
1364
1376
  }
@@ -1402,13 +1414,19 @@ class rs extends D {
1402
1414
  }
1403
1415
  }
1404
1416
  }
1405
- const is = d(
1406
- ({ version: e, postEvent: t }) => new rs(!1, e, t)
1417
+ const rs = d(
1418
+ ({ version: e, postEvent: t }) => new ns(!1, e, t)
1407
1419
  );
1408
- class os extends et {
1420
+ class is extends et {
1409
1421
  constructor({ postEvent: t, ...s }) {
1410
1422
  super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ? v("main_button_pressed", r) : this.state.on(n, r)), c(this, "off", (n, r) => n === "click" ? H("main_button_pressed", r) : this.state.off(n, r)), this.postEvent = t;
1411
1423
  }
1424
+ /**
1425
+ * The MainButton background color.
1426
+ */
1427
+ get bgColor() {
1428
+ return this.get("bgColor");
1429
+ }
1412
1430
  /**
1413
1431
  * Sends current local state to the Telegram application.
1414
1432
  */
@@ -1418,10 +1436,35 @@ class os extends et {
1418
1436
  is_active: this.isEnabled,
1419
1437
  is_progress_visible: this.isLoaderVisible,
1420
1438
  text: this.text,
1421
- color: this.backgroundColor,
1439
+ color: this.bgColor,
1422
1440
  text_color: this.textColor
1423
1441
  });
1424
1442
  }
1443
+ /**
1444
+ * Disables the MainButton.
1445
+ * @see Does not work on Android: https://github.com/Telegram-Mini-Apps/issues/issues/1
1446
+ */
1447
+ disable() {
1448
+ return this.isEnabled = !1, this;
1449
+ }
1450
+ /**
1451
+ * Enables the MainButton.
1452
+ */
1453
+ enable() {
1454
+ return this.isEnabled = !0, this;
1455
+ }
1456
+ /**
1457
+ * Hides the MainButton.
1458
+ */
1459
+ hide() {
1460
+ return this.isVisible = !1, this;
1461
+ }
1462
+ /**
1463
+ * Hides the MainButton loading indicator.
1464
+ */
1465
+ hideLoader() {
1466
+ return this.isLoaderVisible = !1, this;
1467
+ }
1425
1468
  set isEnabled(t) {
1426
1469
  this.setParams({ isEnabled: t });
1427
1470
  }
@@ -1449,49 +1492,6 @@ class os extends et {
1449
1492
  get isVisible() {
1450
1493
  return this.get("isVisible");
1451
1494
  }
1452
- /**
1453
- * The MainButton background color.
1454
- */
1455
- get backgroundColor() {
1456
- return this.get("backgroundColor");
1457
- }
1458
- /**
1459
- * The MainButton text.
1460
- */
1461
- get text() {
1462
- return this.get("text");
1463
- }
1464
- /**
1465
- * The MainButton text color.
1466
- */
1467
- get textColor() {
1468
- return this.get("textColor");
1469
- }
1470
- /**
1471
- * Disables the MainButton.
1472
- * @see Does not work on Android: https://github.com/Telegram-Mini-Apps/issues/issues/1
1473
- */
1474
- disable() {
1475
- return this.isEnabled = !1, this;
1476
- }
1477
- /**
1478
- * Enables the MainButton.
1479
- */
1480
- enable() {
1481
- return this.isEnabled = !0, this;
1482
- }
1483
- /**
1484
- * Hides the MainButton.
1485
- */
1486
- hide() {
1487
- return this.isVisible = !1, this;
1488
- }
1489
- /**
1490
- * Hides the MainButton loading indicator.
1491
- */
1492
- hideLoader() {
1493
- return this.isLoaderVisible = !1, this;
1494
- }
1495
1495
  /**
1496
1496
  * Shows the MainButton.
1497
1497
  *
@@ -1523,10 +1523,10 @@ class os extends et {
1523
1523
  }
1524
1524
  /**
1525
1525
  * Updates current Main Button color.
1526
- * @param backgroundColor - color to set.
1526
+ * @param bgColor - color to set.
1527
1527
  */
1528
- setBackgroundColor(t) {
1529
- return this.setParams({ backgroundColor: t });
1528
+ setBgColor(t) {
1529
+ return this.setParams({ bgColor: t });
1530
1530
  }
1531
1531
  /**
1532
1532
  * Allows setting multiple Main Button parameters.
@@ -1535,8 +1535,20 @@ class os extends et {
1535
1535
  setParams(t) {
1536
1536
  return this.set(t), this.commit(), this;
1537
1537
  }
1538
+ /**
1539
+ * The MainButton text.
1540
+ */
1541
+ get text() {
1542
+ return this.get("text");
1543
+ }
1544
+ /**
1545
+ * The MainButton text color.
1546
+ */
1547
+ get textColor() {
1548
+ return this.get("textColor");
1549
+ }
1538
1550
  }
1539
- const as = d(
1551
+ const os = d(
1540
1552
  "mainButton",
1541
1553
  ({
1542
1554
  postEvent: e,
@@ -1547,11 +1559,11 @@ const as = d(
1547
1559
  text: "",
1548
1560
  isLoaderVisible: !1,
1549
1561
  textColor: t.buttonTextColor || "#ffffff",
1550
- backgroundColor: t.buttonColor || "#000000"
1562
+ bgColor: t.buttonColor || "#000000"
1551
1563
  }
1552
- }) => new os({ ...s, postEvent: e })
1564
+ }) => new is({ ...s, postEvent: e })
1553
1565
  );
1554
- function cs() {
1566
+ function as() {
1555
1567
  return nt({
1556
1568
  contact: f({
1557
1569
  userId: {
@@ -1559,37 +1571,37 @@ function cs() {
1559
1571
  from: "user_id"
1560
1572
  },
1561
1573
  phoneNumber: {
1562
- type: h(),
1574
+ type: p(),
1563
1575
  from: "phone_number"
1564
1576
  },
1565
1577
  firstName: {
1566
- type: h(),
1578
+ type: p(),
1567
1579
  from: "first_name"
1568
1580
  },
1569
1581
  lastName: {
1570
- type: h().optional(),
1582
+ type: p().optional(),
1571
1583
  from: "last_name"
1572
1584
  }
1573
1585
  }),
1574
1586
  authDate: {
1575
- type: It(),
1587
+ type: Ot(),
1576
1588
  from: "auth_date"
1577
1589
  },
1578
- hash: h()
1590
+ hash: p()
1579
1591
  }, "RequestedContact");
1580
1592
  }
1581
- function Ut(e, t) {
1593
+ function Ht(e, t) {
1582
1594
  return (s) => {
1583
1595
  const [n, r] = t[s];
1584
- return C(n, r, e);
1596
+ return x(n, r, e);
1585
1597
  };
1586
1598
  }
1587
- function hs(e) {
1599
+ function cs(e) {
1588
1600
  return new Promise((t) => {
1589
1601
  setTimeout(t, e);
1590
1602
  });
1591
1603
  }
1592
- class ps extends D {
1604
+ class hs extends N {
1593
1605
  constructor({ postEvent: t, createRequestId: s, version: n, botInline: r, ...i }) {
1594
1606
  super(i, n, {
1595
1607
  requestPhoneAccess: "web_app_request_phone",
@@ -1599,7 +1611,7 @@ class ps extends D {
1599
1611
  setBackgroundColor: "web_app_set_background_color"
1600
1612
  }), c(this, "botInline"), c(this, "postEvent"), c(this, "createRequestId"), c(this, "requestPhoneAccessPromise"), c(this, "requestWriteAccessPromise"), c(this, "supportsParam"), this.createRequestId = s, this.postEvent = t, this.botInline = r;
1601
1613
  const o = this.supports.bind(this);
1602
- this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Ut(n, {
1614
+ this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Ht(n, {
1603
1615
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1604
1616
  });
1605
1617
  }
@@ -1610,7 +1622,7 @@ class ps extends D {
1610
1622
  async getRequestedContact({
1611
1623
  timeout: t = 1e4
1612
1624
  } = {}) {
1613
- return cs().parse(
1625
+ return as().parse(
1614
1626
  await A(
1615
1627
  "getRequestedContact",
1616
1628
  {},
@@ -1650,7 +1662,7 @@ class ps extends D {
1650
1662
  * True if current Mini App background color is recognized as dark.
1651
1663
  */
1652
1664
  get isDark() {
1653
- return Tt(this.bgColor);
1665
+ return At(this.bgColor);
1654
1666
  }
1655
1667
  /**
1656
1668
  * Informs the Telegram app that the Mini App is ready to be displayed.
@@ -1679,15 +1691,15 @@ class ps extends D {
1679
1691
  throw new Error("Access denied.");
1680
1692
  const s = Date.now() + t;
1681
1693
  let n = 50;
1682
- return Rt(async () => {
1694
+ return Tt(async () => {
1683
1695
  for (; Date.now() < s; ) {
1684
1696
  try {
1685
1697
  return await this.getRequestedContact();
1686
1698
  } catch {
1687
1699
  }
1688
- await hs(n), n += 50;
1700
+ await cs(n), n += 50;
1689
1701
  }
1690
- throw St(t);
1702
+ throw Rt(t);
1691
1703
  }, t);
1692
1704
  }
1693
1705
  /**
@@ -1770,7 +1782,7 @@ class ps extends D {
1770
1782
  this.postEvent("web_app_switch_inline_query", { query: t, chat_types: s });
1771
1783
  }
1772
1784
  }
1773
- const us = d(
1785
+ const ps = d(
1774
1786
  "miniApp",
1775
1787
  ({
1776
1788
  themeParams: e,
@@ -1780,9 +1792,9 @@ const us = d(
1780
1792
  headerColor: e.headerBgColor || "#000000"
1781
1793
  },
1782
1794
  ...n
1783
- }) => new ps({ ...n, ...s, botInline: t })
1795
+ }) => new hs({ ...n, ...s, botInline: t })
1784
1796
  );
1785
- function ls(e) {
1797
+ function us(e) {
1786
1798
  const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
1787
1799
  let r;
1788
1800
  if (s.length > 64)
@@ -1798,15 +1810,15 @@ function ls(e) {
1798
1810
  if (!i.type || i.type === "default" || i.type === "destructive") {
1799
1811
  const a = i.text.trim();
1800
1812
  if (!a.length || a.length > 64) {
1801
- const p = i.type || "default";
1802
- throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
1813
+ const h = i.type || "default";
1814
+ throw new Error(`Button text with type "${h}" has incorrect size: ${i.text.length}`);
1803
1815
  }
1804
1816
  return { ...i, text: a, id: o };
1805
1817
  }
1806
1818
  return { ...i, id: o };
1807
1819
  }) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
1808
1820
  }
1809
- class ds extends D {
1821
+ class ls extends N {
1810
1822
  constructor(t, s, n) {
1811
1823
  super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
1812
1824
  }
@@ -1839,7 +1851,7 @@ class ds extends D {
1839
1851
  event: "popup_closed",
1840
1852
  method: "web_app_open_popup",
1841
1853
  postEvent: this.postEvent,
1842
- params: ls(t)
1854
+ params: us(t)
1843
1855
  });
1844
1856
  return s;
1845
1857
  } finally {
@@ -1847,10 +1859,10 @@ class ds extends D {
1847
1859
  }
1848
1860
  }
1849
1861
  }
1850
- const _s = d(
1851
- ({ postEvent: e, version: t }) => new ds(!1, t, e)
1862
+ const ds = d(
1863
+ ({ postEvent: e, version: t }) => new ls(!1, t, e)
1852
1864
  );
1853
- class gs extends D {
1865
+ class _s extends N {
1854
1866
  constructor(t, s, n) {
1855
1867
  super({ isOpened: t }, s, {
1856
1868
  close: "web_app_close_scan_qr_popup",
@@ -1894,10 +1906,10 @@ class gs extends D {
1894
1906
  }
1895
1907
  }
1896
1908
  }
1897
- const fs = d(
1898
- ({ version: e, postEvent: t }) => new gs(!1, e, t)
1909
+ const gs = d(
1910
+ ({ version: e, postEvent: t }) => new _s(!1, e, t)
1899
1911
  );
1900
- class ms extends st {
1912
+ class fs extends st {
1901
1913
  constructor(t, s, n) {
1902
1914
  super({ isVisible: t }, s, {
1903
1915
  show: "web_app_setup_settings_button",
@@ -1926,16 +1938,16 @@ class ms extends st {
1926
1938
  this.isVisible = !0;
1927
1939
  }
1928
1940
  }
1929
- const ws = d(
1941
+ const ms = d(
1930
1942
  "settingsButton",
1931
1943
  ({
1932
1944
  version: e,
1933
1945
  postEvent: t,
1934
1946
  state: s = { isVisible: !1 }
1935
- }) => new ms(s.isVisible, e, t)
1947
+ }) => new fs(s.isVisible, e, t)
1936
1948
  );
1937
- function Ht(e) {
1938
- return Ot().parse(e);
1949
+ function Wt(e) {
1950
+ return qt().parse(e);
1939
1951
  }
1940
1952
  class bs extends rt {
1941
1953
  /**
@@ -1976,7 +1988,7 @@ class bs extends rt {
1976
1988
  * value is calculated according to theme bg color.
1977
1989
  */
1978
1990
  get isDark() {
1979
- return !this.bgColor || Tt(this.bgColor);
1991
+ return !this.bgColor || At(this.bgColor);
1980
1992
  }
1981
1993
  get linkColor() {
1982
1994
  return this.get("linkColor");
@@ -2002,7 +2014,7 @@ class bs extends rt {
2002
2014
  */
2003
2015
  listen() {
2004
2016
  return v("theme_changed", (t) => {
2005
- this.set(Ht(t.theme_params));
2017
+ this.set(Wt(t.theme_params));
2006
2018
  });
2007
2019
  }
2008
2020
  /**
@@ -2015,23 +2027,23 @@ class bs extends rt {
2015
2027
  return this.get("textColor");
2016
2028
  }
2017
2029
  }
2018
- const vs = d(
2030
+ const ws = d(
2019
2031
  "themeParams",
2020
2032
  ({ themeParams: e, state: t = e, addCleanup: s }) => {
2021
2033
  const n = new bs(t);
2022
2034
  return s(n.listen()), n;
2023
2035
  }
2024
2036
  );
2025
- function Xs(e = {}) {
2037
+ function Zs(e = {}) {
2026
2038
  return m({
2027
2039
  ...e,
2028
2040
  method: "web_app_request_theme",
2029
2041
  event: "theme_changed"
2030
- }).then(Ht);
2042
+ }).then(Wt);
2031
2043
  }
2032
- class ys extends it {
2044
+ class vs extends it {
2033
2045
  constructor(t, s, n) {
2034
- super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Ut(t, {
2046
+ super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Ht(t, {
2035
2047
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2036
2048
  });
2037
2049
  }
@@ -2046,7 +2058,7 @@ class ys extends it {
2046
2058
  */
2047
2059
  openLink(t, s) {
2048
2060
  const n = new URL(t, window.location.href).toString();
2049
- if (!C("web_app_open_link", this.version)) {
2061
+ if (!x("web_app_open_link", this.version)) {
2050
2062
  window.open(n, "_blank");
2051
2063
  return;
2052
2064
  }
@@ -2065,7 +2077,7 @@ class ys extends it {
2065
2077
  const { hostname: s, pathname: n, search: r } = new URL(t, window.location.href);
2066
2078
  if (s !== "t.me")
2067
2079
  throw new Error(`URL has not allowed hostname: ${s}. Only "t.me" is allowed`);
2068
- if (!C("web_app_open_tg_link", this.version)) {
2080
+ if (!x("web_app_open_tg_link", this.version)) {
2069
2081
  window.location.href = t;
2070
2082
  return;
2071
2083
  }
@@ -2085,15 +2097,15 @@ class ys extends it {
2085
2097
  event: "clipboard_text_received",
2086
2098
  postEvent: this.postEvent,
2087
2099
  params: { req_id: t },
2088
- capture: Ct(t)
2100
+ capture: St(t)
2089
2101
  });
2090
2102
  return s;
2091
2103
  }
2092
2104
  }
2093
- const Es = d(
2094
- ({ version: e, postEvent: t, createRequestId: s }) => new ys(e, s, t)
2105
+ const ys = d(
2106
+ ({ version: e, postEvent: t, createRequestId: s }) => new vs(e, s, t)
2095
2107
  );
2096
- async function Wt(e = {}) {
2108
+ async function jt(e = {}) {
2097
2109
  const {
2098
2110
  is_expanded: t,
2099
2111
  is_state_stable: s,
@@ -2108,7 +2120,7 @@ async function Wt(e = {}) {
2108
2120
  function T(e) {
2109
2121
  return e < 0 ? 0 : e;
2110
2122
  }
2111
- class Ps extends rt {
2123
+ class Es extends rt {
2112
2124
  constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
2113
2125
  super({
2114
2126
  height: T(n),
@@ -2123,7 +2135,7 @@ class Ps extends rt {
2123
2135
  * @param options - options to request fresh data.
2124
2136
  */
2125
2137
  async sync(t) {
2126
- const { isStateStable: s, ...n } = await Wt(t);
2138
+ const { isStateStable: s, ...n } = await jt(t);
2127
2139
  this.set({
2128
2140
  ...n,
2129
2141
  stableHeight: s ? n.height : this.get("stableHeight")
@@ -2215,7 +2227,7 @@ class Ps extends rt {
2215
2227
  return this.stableHeight === this.height;
2216
2228
  }
2217
2229
  }
2218
- const xs = d(
2230
+ const Ps = d(
2219
2231
  "viewport",
2220
2232
  async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
2221
2233
  let r = !1, i = 0, o = 0, a = 0;
@@ -2224,31 +2236,31 @@ const xs = d(
2224
2236
  else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2225
2237
  r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
2226
2238
  else {
2227
- const u = await Wt({ timeout: 1e3, postEvent: s });
2239
+ const u = await jt({ timeout: 1e3, postEvent: s });
2228
2240
  r = u.isExpanded, i = u.height, o = u.width, a = u.isStateStable ? i : 0;
2229
2241
  }
2230
- const p = new Ps({
2242
+ const h = new Es({
2231
2243
  postEvent: s,
2232
2244
  height: i,
2233
2245
  width: o,
2234
2246
  stableHeight: a,
2235
2247
  isExpanded: r
2236
2248
  });
2237
- return n(p.listen()), p;
2249
+ return n(h.listen()), h;
2238
2250
  }
2239
2251
  );
2240
2252
  function E(e, t) {
2241
2253
  document.documentElement.style.setProperty(e, t);
2242
2254
  }
2243
- function tn(e, t, s) {
2255
+ function Xs(e, t, s) {
2244
2256
  s || (s = (a) => `--tg-${a}-color`);
2245
2257
  const n = s("header"), r = s("bg"), i = () => {
2246
2258
  const { headerColor: a } = e;
2247
2259
  if (tt(a))
2248
2260
  E(n, a);
2249
2261
  else {
2250
- const { bgColor: p, secondaryBgColor: u } = t;
2251
- a === "bg_color" && p ? E(n, p) : a === "secondary_bg_color" && u && E(n, u);
2262
+ const { bgColor: h, secondaryBgColor: u } = t;
2263
+ a === "bg_color" && h ? E(n, h) : a === "secondary_bg_color" && u && E(n, u);
2252
2264
  }
2253
2265
  E(r, e.bgColor);
2254
2266
  }, o = [
@@ -2257,7 +2269,7 @@ function tn(e, t, s) {
2257
2269
  ];
2258
2270
  return i(), () => o.forEach((a) => a());
2259
2271
  }
2260
- function en(e, t) {
2272
+ function tn(e, t) {
2261
2273
  t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
2262
2274
  const s = () => {
2263
2275
  Object.entries(e.getState()).forEach(([n, r]) => {
@@ -2266,20 +2278,20 @@ function en(e, t) {
2266
2278
  };
2267
2279
  return s(), e.on("change", s);
2268
2280
  }
2269
- function sn(e, t) {
2281
+ function en(e, t) {
2270
2282
  t || (t = (u) => `--tg-viewport-${u}`);
2271
2283
  const [
2272
2284
  s,
2273
2285
  n,
2274
2286
  r
2275
- ] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => E(s, `${e.height}px`), o = () => E(n, `${e.width}px`), a = () => E(r, `${e.stableHeight}px`), p = [
2287
+ ] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => E(s, `${e.height}px`), o = () => E(n, `${e.width}px`), a = () => E(r, `${e.stableHeight}px`), h = [
2276
2288
  e.on("change:height", i),
2277
2289
  e.on("change:width", o),
2278
2290
  e.on("change:stableHeight", a)
2279
2291
  ];
2280
- return i(), o(), a(), () => p.forEach((u) => u());
2292
+ return i(), o(), a(), () => h.forEach((u) => u());
2281
2293
  }
2282
- function Cs(e = !0) {
2294
+ function xs(e = !0) {
2283
2295
  const t = [
2284
2296
  v("reload_iframe", () => {
2285
2297
  k("iframe_will_reload"), window.location.reload();
@@ -2296,11 +2308,11 @@ function Cs(e = !0) {
2296
2308
  }
2297
2309
  return k("iframe_ready", { reload_supported: !0 }), s;
2298
2310
  }
2299
- function nn() {
2311
+ function sn() {
2300
2312
  return typeof window > "u";
2301
2313
  }
2302
- async function rn() {
2303
- if (Et(window))
2314
+ async function nn() {
2315
+ if (Pt(window))
2304
2316
  return !0;
2305
2317
  try {
2306
2318
  return await m({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
@@ -2308,11 +2320,11 @@ async function rn() {
2308
2320
  return !1;
2309
2321
  }
2310
2322
  }
2311
- function Ss(e) {
2323
+ function Cs(e) {
2312
2324
  return e instanceof $;
2313
2325
  }
2314
- function on(e, t) {
2315
- return Ss(e) && e.type === t;
2326
+ function rn(e, t) {
2327
+ return Cs(e) && e.type === t;
2316
2328
  }
2317
2329
  function j(e, t) {
2318
2330
  let s, n, r;
@@ -2322,13 +2334,13 @@ function j(e, t) {
2322
2334
  params: n
2323
2335
  });
2324
2336
  }
2325
- class Rs {
2337
+ class Ss {
2326
2338
  constructor(t, s, n = k) {
2327
- if (c(this, "history"), c(this, "ee", new B()), c(this, "attached", !1), c(this, "back", () => this.go(-1)), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this._index = s, this.postEvent = n, t.length === 0)
2328
- throw w(ue, "History should not be empty.");
2339
+ if (c(this, "history"), c(this, "ee", new O()), c(this, "attached", !1), c(this, "back", () => this.go(-1)), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this._index = s, this.postEvent = n, t.length === 0)
2340
+ throw b(le, "History should not be empty.");
2329
2341
  if (s < 0 || s >= t.length)
2330
- throw w(
2331
- le,
2342
+ throw b(
2343
+ de,
2332
2344
  "Index should not be zero and higher or equal than history size."
2333
2345
  );
2334
2346
  this.history = t.map((r) => j(r, ""));
@@ -2449,29 +2461,29 @@ function G({
2449
2461
  }) {
2450
2462
  return { ...e || { hash: "", search: "" }, ...t };
2451
2463
  }
2452
- function O(e, t) {
2464
+ function q(e, t) {
2453
2465
  return e.startsWith(t) ? e : `${t}${e}`;
2454
2466
  }
2455
- function V(e) {
2467
+ function M(e) {
2456
2468
  return new URL(
2457
- typeof e == "string" ? e : `${e.pathname || ""}${O(e.search || "", "?")}${O(e.hash || "", "#")}`,
2469
+ typeof e == "string" ? e : `${e.pathname || ""}${q(e.search || "", "?")}${q(e.hash || "", "#")}`,
2458
2470
  "http://a"
2459
2471
  );
2460
2472
  }
2461
- function M(e) {
2462
- const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = V(e);
2473
+ function B(e) {
2474
+ const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = M(e);
2463
2475
  return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
2464
2476
  }
2465
2477
  function K(e, t, s) {
2466
2478
  let n, r;
2467
- typeof e == "string" ? n = e : (n = M(e), s = e.state, r = e.id);
2468
- const { pathname: i, search: o, hash: a } = new URL(n, `http://a${O(t, "/")}`);
2479
+ typeof e == "string" ? n = e : (n = B(e), s = e.state, r = e.id);
2480
+ const { pathname: i, search: o, hash: a } = new URL(n, `http://a${q(t, "/")}`);
2469
2481
  return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
2470
2482
  }
2471
2483
  async function I(e) {
2472
2484
  return e === 0 ? !0 : Promise.race([
2473
2485
  new Promise((t) => {
2474
- const s = F("popstate", () => {
2486
+ const s = Q("popstate", () => {
2475
2487
  s(), t(!0);
2476
2488
  });
2477
2489
  window.history.go(e);
@@ -2482,39 +2494,39 @@ async function I(e) {
2482
2494
  })
2483
2495
  ]);
2484
2496
  }
2485
- async function Ts() {
2497
+ async function Rs() {
2486
2498
  if (window.history.length <= 1 || (window.history.pushState(null, ""), await I(1 - window.history.length)))
2487
2499
  return;
2488
2500
  let e = await I(-1);
2489
2501
  for (; e; )
2490
2502
  e = await I(-1);
2491
2503
  }
2492
- function jt(e) {
2493
- return V(e).pathname;
2504
+ function Gt(e) {
2505
+ return M(e).pathname;
2494
2506
  }
2495
2507
  const _t = 0, z = 1, J = 2;
2496
- class Gt {
2508
+ class Kt {
2497
2509
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2498
- c(this, "navigator"), c(this, "ee", new B()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
2510
+ c(this, "navigator"), c(this, "ee", new O()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
2499
2511
  if (o === null)
2500
2512
  return this.push(this.parsePath(window.location.href));
2501
2513
  o === _t ? window.history.forward() : o === z && this.back(), o === J && this.forward();
2502
2514
  }), c(this, "onNavigatorChange", async ({
2503
2515
  to: o,
2504
2516
  from: a,
2505
- delta: p
2517
+ delta: h
2506
2518
  }) => {
2507
2519
  this.attached && await this.syncHistory(), this.ee.emit("change", {
2508
- delta: p,
2520
+ delta: h,
2509
2521
  from: G(a),
2510
2522
  to: G(o),
2511
2523
  navigator: this
2512
2524
  });
2513
- }), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new Rs(
2525
+ }), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new Ss(
2514
2526
  t.map((o) => K(o, "/")),
2515
2527
  s,
2516
2528
  n
2517
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = jt(i || "");
2529
+ ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Gt(i || "");
2518
2530
  }
2519
2531
  /**
2520
2532
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2612,7 +2624,7 @@ class Gt {
2612
2624
  * "/pathname?search#hash"
2613
2625
  */
2614
2626
  get path() {
2615
- return M(this);
2627
+ return B(this);
2616
2628
  }
2617
2629
  /**
2618
2630
  * Current pathname. Always starts with the slash.
@@ -2641,8 +2653,8 @@ class Gt {
2641
2653
  * // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
2642
2654
  */
2643
2655
  parsePath(t) {
2644
- let s = V(t);
2645
- return this.hashMode && (s = V(s.hash.slice(1))), {
2656
+ let s = M(t);
2657
+ return this.hashMode && (s = M(s.hash.slice(1))), {
2646
2658
  pathname: s.pathname,
2647
2659
  search: s.search,
2648
2660
  hash: s.hash
@@ -2662,8 +2674,8 @@ class Gt {
2662
2674
  * @param value - path presented as string or URLLike.
2663
2675
  */
2664
2676
  renderPath(t) {
2665
- const s = (this.base.length === 1 ? "" : this.base) + O(M(t), "/");
2666
- return this.hashMode ? O(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2677
+ const s = (this.base.length === 1 ? "" : this.base) + q(B(t), "/");
2678
+ return this.hashMode ? q(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2667
2679
  }
2668
2680
  /**
2669
2681
  * Synchronizes current navigator state with browser history.
@@ -2671,7 +2683,7 @@ class Gt {
2671
2683
  async syncHistory() {
2672
2684
  window.removeEventListener("popstate", this.onPopState);
2673
2685
  const { state: t } = this, s = this.renderPath(this);
2674
- await Ts(), this.hasPrev && this.hasNext ? (window.history.replaceState(z, ""), window.history.pushState(t, "", s), window.history.pushState(J, ""), await I(-1)) : this.hasPrev ? (window.history.replaceState(z, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(J, ""), await I(-1)) : (window.history.replaceState(_t, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2686
+ await Rs(), this.hasPrev && this.hasNext ? (window.history.replaceState(z, ""), window.history.pushState(t, "", s), window.history.pushState(J, ""), await I(-1)) : this.hasPrev ? (window.history.replaceState(z, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(J, ""), await I(-1)) : (window.history.replaceState(_t, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2675
2687
  }
2676
2688
  /**
2677
2689
  * Current query parameters.
@@ -2689,42 +2701,42 @@ class Gt {
2689
2701
  return (this.navigator.current.params || {}).state;
2690
2702
  }
2691
2703
  }
2692
- function As(e) {
2704
+ function Ts(e) {
2693
2705
  e || (e = {});
2694
2706
  const { href: t, hash: s } = window.location;
2695
- let n = M(
2707
+ let n = B(
2696
2708
  e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
2697
2709
  );
2698
- const r = e.base ? jt(e.base) : void 0;
2710
+ const r = e.base ? Gt(e.base) : void 0;
2699
2711
  if (r) {
2700
2712
  if (!n.startsWith(r))
2701
- throw w(
2702
- de,
2713
+ throw b(
2714
+ _e,
2703
2715
  `Path "${n}" expected to be starting with "${r}"`
2704
2716
  );
2705
2717
  n = n.slice(r.length);
2706
2718
  }
2707
- return new Gt([n], 0, e);
2719
+ return new Kt([n], 0, e);
2708
2720
  }
2709
- function an(e) {
2721
+ function on(e) {
2710
2722
  const t = e.match(/#(.+)/);
2711
2723
  return t ? t[1] : null;
2712
2724
  }
2713
- function Is(e, t) {
2714
- if ($t()) {
2725
+ function As(e, t) {
2726
+ if (Lt()) {
2715
2727
  const s = sessionStorage.getItem(e);
2716
2728
  if (s)
2717
2729
  try {
2718
2730
  const { index: n, history: r } = JSON.parse(s);
2719
- return new Gt(r, n, t);
2731
+ return new Kt(r, n, t);
2720
2732
  } catch (n) {
2721
2733
  console.error("Unable to restore hash navigator state.", n);
2722
2734
  }
2723
2735
  }
2724
- return As(t);
2736
+ return Ts(t);
2725
2737
  }
2726
- function cn(e, t) {
2727
- const s = Is(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2738
+ function an(e, t) {
2739
+ const s = As(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2728
2740
  index: s.index,
2729
2741
  history: s.history
2730
2742
  }));
@@ -2735,20 +2747,20 @@ function _(e) {
2735
2747
  [t]: e(...n)
2736
2748
  }, r)));
2737
2749
  }
2738
- const Kt = Qt();
2739
- function ks() {
2740
- const e = Ft(Kt);
2750
+ const zt = Qt();
2751
+ function Is() {
2752
+ const e = Yt(zt);
2741
2753
  if (!e)
2742
2754
  throw new Error("useSDK was used outside of SDKProvider.");
2743
2755
  return e;
2744
2756
  }
2745
2757
  function g(e) {
2746
2758
  return (...t) => {
2747
- const s = ks()(e, ...t), n = () => s.signal();
2759
+ const s = Is()(e, ...t), n = () => s.signal();
2748
2760
  return Object.defineProperty(n, "error", () => s.error), n;
2749
2761
  };
2750
2762
  }
2751
- const Os = g(We), hn = _(Os), qs = g(Ke), pn = _(qs), Ds = g(Je), un = _(Ds), Ns = g(Xe), ln = _(Ns), Vs = g(es), dn = _(Vs), Ms = g(ns), _n = _(Ms), Bs = g(is), gn = _(Bs), $s = g(as), fn = _($s), Ls = g(us), mn = _(Ls), Us = g(_s), wn = _(Us), Hs = g(fs), bn = _(Hs), Ws = g(ws), vn = _(Ws), js = g(vs), yn = _(js), Gs = g(Es), En = _(Gs), Ks = g(xs), Pn = _(Ks), xn = (e) => {
2763
+ const Os = g(He), cn = _(Os), ks = g(Ge), hn = _(ks), qs = g(ze), pn = _(qs), Ds = g(Ze), un = _(Ds), Ns = g(ts), ln = _(Ns), Vs = g(ss), dn = _(Vs), Ms = g(rs), _n = _(Ms), Bs = g(os), gn = _(Bs), $s = g(ps), fn = _($s), Ls = g(ds), mn = _(Ls), Us = g(gs), bn = _(Us), Hs = g(ms), wn = _(Hs), Ws = g(ws), vn = _(Ws), js = g(ys), yn = _(js), Gs = g(Ps), En = _(Gs), Pn = (e) => {
2752
2764
  const t = /* @__PURE__ */ new Map(), s = (n, ...r) => {
2753
2765
  if (t.has(n))
2754
2766
  return t.get(n);
@@ -2768,42 +2780,42 @@ const Os = g(We), hn = _(Os), qs = g(Ke), pn = _(qs), Ds = g(Je), un = _(Ds), Ns
2768
2780
  }
2769
2781
  let a;
2770
2782
  Array.isArray(o) && ([o, a] = o);
2771
- const [p] = Yt(() => o), u = pt(() => {
2772
- if (p.state !== "ready")
2783
+ const [h] = Zt(() => o), u = pt(() => {
2784
+ if (h.state !== "ready")
2773
2785
  return;
2774
- const l = p();
2786
+ const l = h();
2775
2787
  if (!l || !("on" in l))
2776
2788
  return l;
2777
- const zt = Zt((N) => (N(l), l.on("change", () => N(l)))), Jt = Object.getPrototypeOf(l), W = {};
2789
+ const Jt = Xt((V) => (V(l), l.on("change", () => V(l)))), Ft = Object.getPrototypeOf(l), W = {};
2778
2790
  return new Proxy(l, {
2779
- get(N, x) {
2780
- if (!(x in W)) {
2781
- const ot = Reflect.getOwnPropertyDescriptor(Jt, x);
2782
- W[x] = ot && "get" in ot ? pt(() => zt()[x]) : () => Reflect.get(N, x);
2791
+ get(V, C) {
2792
+ if (!(C in W)) {
2793
+ const ot = Reflect.getOwnPropertyDescriptor(Ft, C);
2794
+ W[C] = ot && "get" in ot ? pt(() => Jt()[C]) : () => Reflect.get(V, C);
2783
2795
  }
2784
- return W[x]();
2796
+ return W[C]();
2785
2797
  }
2786
2798
  });
2787
2799
  });
2788
2800
  return i({
2789
2801
  signal() {
2790
- if (p.error)
2791
- throw p.error;
2802
+ if (h.error)
2803
+ throw h.error;
2792
2804
  return u();
2793
2805
  },
2794
2806
  get error() {
2795
- return p.error;
2807
+ return h.error;
2796
2808
  },
2797
2809
  cleanup: a
2798
2810
  });
2799
2811
  };
2800
2812
  return ct(() => {
2801
- ne(e.debug || !1);
2813
+ re(e.debug || !1);
2802
2814
  }), ct(() => {
2803
- Pt() && ht(Cs(e.acceptCustomStyles));
2815
+ xt() && ht(xs(e.acceptCustomStyles));
2804
2816
  }), ht(() => {
2805
2817
  t.forEach((n) => n.cleanup && n.cleanup());
2806
- }), gt(Kt.Provider, {
2818
+ }), gt(zt.Provider, {
2807
2819
  value: s,
2808
2820
  get children() {
2809
2821
  return e.children;
@@ -2812,137 +2824,137 @@ const Os = g(We), hn = _(Os), qs = g(Ke), pn = _(qs), Ds = g(Je), un = _(Ds), Ns
2812
2824
  };
2813
2825
  export {
2814
2826
  Ae as BackButton,
2815
- Rs as BasicNavigator,
2816
- je as BiometryManager,
2817
- Gt as BrowserNavigator,
2818
- ze as ClosingBehavior,
2819
- Ze as CloudStorage,
2820
- de as ERR_INVALID_PATH_BASE,
2821
- ce as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2822
- oe as ERR_METHOD_PARAMETER_UNSUPPORTED,
2823
- ie as ERR_METHOD_UNSUPPORTED,
2824
- ue as ERR_NAVIGATION_HISTORY_EMPTY,
2825
- le as ERR_NAVIGATION_INDEX_INVALID,
2826
- Js as ERR_NAVIGATION_ITEM_INVALID,
2827
+ Ss as BasicNavigator,
2828
+ We as BiometryManager,
2829
+ Kt as BrowserNavigator,
2830
+ Ke as ClosingBehavior,
2831
+ Ye as CloudStorage,
2832
+ _e as ERR_INVALID_PATH_BASE,
2833
+ he as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2834
+ ae as ERR_METHOD_PARAMETER_UNSUPPORTED,
2835
+ oe as ERR_METHOD_UNSUPPORTED,
2836
+ le as ERR_NAVIGATION_HISTORY_EMPTY,
2837
+ de as ERR_NAVIGATION_INDEX_INVALID,
2838
+ zs as ERR_NAVIGATION_ITEM_INVALID,
2827
2839
  wt as ERR_PARSE,
2828
- Qs as ERR_SSR_INIT,
2829
- he as ERR_TIMED_OUT,
2830
- pe as ERR_UNEXPECTED_TYPE,
2831
- ae as ERR_UNKNOWN_ENV,
2832
- B as EventEmitter,
2833
- ts as HapticFeedback,
2834
- ss as InitData,
2835
- rs as Invoice,
2836
- os as MainButton,
2837
- ps as MiniApp,
2838
- ds as Popup,
2839
- gs as QRScanner,
2840
+ Js as ERR_SSR_INIT,
2841
+ pe as ERR_TIMED_OUT,
2842
+ ue as ERR_UNEXPECTED_TYPE,
2843
+ ce as ERR_UNKNOWN_ENV,
2844
+ O as EventEmitter,
2845
+ Xe as HapticFeedback,
2846
+ es as InitData,
2847
+ ns as Invoice,
2848
+ is as MainButton,
2849
+ hs as MiniApp,
2850
+ ls as Popup,
2851
+ _s as QRScanner,
2840
2852
  $ as SDKError,
2841
- xn as SDKProvider,
2842
- ms as SettingsButton,
2853
+ Pn as SDKProvider,
2854
+ fs as SettingsButton,
2843
2855
  bs as ThemeParams,
2844
- ys as Utils,
2845
- Ps as Viewport,
2846
- Ye as array,
2847
- tn as bindMiniAppCSSVars,
2848
- en as bindThemeParamsCSSVars,
2849
- sn as bindViewportCSSVars,
2856
+ vs as Utils,
2857
+ Es as Viewport,
2858
+ Qe as array,
2859
+ Xs as bindMiniAppCSSVars,
2860
+ tn as bindThemeParamsCSSVars,
2861
+ en as bindViewportCSSVars,
2850
2862
  y as boolean,
2851
- Ct as captureSameReq,
2863
+ St as captureSameReq,
2852
2864
  Y as classNames,
2853
2865
  xe as compareVersions,
2854
- As as createBrowserNavigatorFromLocation,
2866
+ Ts as createBrowserNavigatorFromLocation,
2855
2867
  Re as createPostEvent,
2856
- V as createSafeURL,
2857
- It as date,
2858
- an as getHash,
2859
- jt as getPathname,
2860
- We as initBackButton,
2861
- Ke as initBiometryManager,
2862
- Je as initClosingBehavior,
2863
- Xe as initCloudStorage,
2864
- es as initHapticFeedback,
2865
- ns as initInitData,
2866
- is as initInvoice,
2867
- as as initMainButton,
2868
- us as initMiniApp,
2869
- cn as initNavigator,
2870
- _s as initPopup,
2871
- fs as initQRScanner,
2872
- ws as initSettingsButton,
2873
- vs as initThemeParams,
2874
- Es as initUtils,
2875
- xs as initViewport,
2876
- Cs as initWeb,
2868
+ M as createSafeURL,
2869
+ Ot as date,
2870
+ on as getHash,
2871
+ Gt as getPathname,
2872
+ He as initBackButton,
2873
+ Ge as initBiometryManager,
2874
+ ze as initClosingBehavior,
2875
+ Ze as initCloudStorage,
2876
+ ts as initHapticFeedback,
2877
+ ss as initInitData,
2878
+ rs as initInvoice,
2879
+ os as initMainButton,
2880
+ ps as initMiniApp,
2881
+ an as initNavigator,
2882
+ ds as initPopup,
2883
+ gs as initQRScanner,
2884
+ ms as initSettingsButton,
2885
+ ws as initThemeParams,
2886
+ ys as initUtils,
2887
+ Ps as initViewport,
2888
+ xs as initWeb,
2877
2889
  A as invokeCustomMethod,
2878
- Tt as isColorDark,
2879
- Pt as isIframe,
2880
- $t as isPageReload,
2890
+ At as isColorDark,
2891
+ xt as isIframe,
2892
+ Lt as isPageReload,
2881
2893
  tt as isRGB,
2882
- _e as isRGBShort,
2883
- Ss as isSDKError,
2884
- on as isSDKErrorOfType,
2885
- nn as isSSR,
2886
- rn as isTMA,
2894
+ ge as isRGBShort,
2895
+ Cs as isSDKError,
2896
+ rn as isSDKErrorOfType,
2897
+ sn as isSSR,
2898
+ nn as isTMA,
2887
2899
  f as json,
2888
- Ys as mergeClassNames,
2900
+ Qs as mergeClassNames,
2889
2901
  P as number,
2890
2902
  H as off,
2891
2903
  v as on,
2892
- Zs as parseInitData,
2893
- qt as parseLaunchParams,
2894
- Ht as parseThemeParams,
2904
+ Ys as parseInitData,
2905
+ Dt as parseLaunchParams,
2906
+ Wt as parseThemeParams,
2895
2907
  k as postEvent,
2896
2908
  m as request,
2897
- Ge as requestBiometryInfo,
2898
- Xs as requestThemeParams,
2899
- Wt as requestViewport,
2909
+ je as requestBiometryInfo,
2910
+ Zs as requestThemeParams,
2911
+ jt as requestViewport,
2900
2912
  $e as retrieveLaunchParams,
2901
- yt as rgb,
2913
+ Et as rgb,
2902
2914
  nt as searchParams,
2903
2915
  Me as serializeLaunchParams,
2904
2916
  Ve as serializeThemeParams,
2905
2917
  E as setCSSVar,
2906
- ne as setDebug,
2918
+ re as setDebug,
2907
2919
  Fs as setTargetOrigin,
2908
- h as string,
2909
- ee as subscribe,
2910
- C as supports,
2920
+ p as string,
2921
+ se as subscribe,
2922
+ x as supports,
2911
2923
  Se as targetOrigin,
2912
- vt as toRGB,
2924
+ yt as toRGB,
2913
2925
  mt as unsubscribe,
2914
- M as urlToPath,
2926
+ B as urlToPath,
2915
2927
  Os as useBackButton,
2916
- qs as useBiometryManager,
2917
- Ds as useClosingBehavior,
2918
- Ns as useCloudStorage,
2919
- Vs as useHapticFeedback,
2920
- Ms as useInitData,
2921
- Bs as useInvoice,
2922
- $s as useMainButton,
2923
- Ls as useMiniApp,
2924
- Us as usePopup,
2925
- Hs as useQRScanner,
2926
- ks as useSDK,
2927
- Ws as useSettingsButton,
2928
- js as useThemeParams,
2929
- Gs as useUtils,
2930
- Ks as useViewport,
2931
- hn as withBackButton,
2932
- pn as withBiometryManager,
2933
- un as withClosingBehavior,
2934
- ln as withCloudStorage,
2935
- dn as withHapticFeedback,
2936
- _n as withInitData,
2937
- gn as withInvoice,
2938
- fn as withMainButton,
2939
- mn as withMiniApp,
2940
- wn as withPopup,
2928
+ ks as useBiometryManager,
2929
+ qs as useClosingBehavior,
2930
+ Ds as useCloudStorage,
2931
+ Ns as useHapticFeedback,
2932
+ Vs as useInitData,
2933
+ Ms as useInvoice,
2934
+ Bs as useMainButton,
2935
+ $s as useMiniApp,
2936
+ Ls as usePopup,
2937
+ Us as useQRScanner,
2938
+ Is as useSDK,
2939
+ Hs as useSettingsButton,
2940
+ Ws as useThemeParams,
2941
+ js as useUtils,
2942
+ Gs as useViewport,
2943
+ cn as withBackButton,
2944
+ hn as withBiometryManager,
2945
+ pn as withClosingBehavior,
2946
+ un as withCloudStorage,
2947
+ ln as withHapticFeedback,
2948
+ dn as withInitData,
2949
+ _n as withInvoice,
2950
+ gn as withMainButton,
2951
+ fn as withMiniApp,
2952
+ mn as withPopup,
2941
2953
  bn as withQRScanner,
2942
- vn as withSettingsButton,
2943
- yn as withThemeParams,
2944
- Rt as withTimeout,
2945
- En as withUtils,
2946
- Pn as withViewport
2954
+ wn as withSettingsButton,
2955
+ vn as withThemeParams,
2956
+ Tt as withTimeout,
2957
+ yn as withUtils,
2958
+ En as withViewport
2947
2959
  };
2948
2960
  //# sourceMappingURL=index.js.map