@tma.js/sdk-react 2.2.1 → 2.2.3

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,19 +1,19 @@
1
- import { jsx as yt } from "react/jsx-runtime";
2
- import { createContext as ie, useContext as oe, useState as Et, useEffect as S, useMemo as Pt, useRef as gt, useCallback as ae } from "react";
1
+ import { jsx as Et } from "react/jsx-runtime";
2
+ import { createContext as ie, useContext as oe, useState as Pt, useEffect as S, useMemo as Rt, useRef as ft, useCallback as ae } from "react";
3
3
  var ce = Object.defineProperty, he = (e, t, s) => t in e ? ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (he(e, typeof t != "symbol" ? t + "" : t, s), s);
4
- function Rt(e, t) {
4
+ function xt(e, t) {
5
5
  let s;
6
6
  const n = () => {
7
7
  s !== void 0 && t && t(s), s = void 0;
8
8
  };
9
9
  return [() => s === void 0 ? s = e(n) : s, n];
10
10
  }
11
- function xt(e) {
11
+ function Ct(e) {
12
12
  const t = j(), { count: s } = t;
13
13
  t.unsubscribe(e), s && !t.count && Ae();
14
14
  }
15
15
  function pe(e) {
16
- return j().subscribe(e), () => xt(e);
16
+ return j().subscribe(e), () => Ct(e);
17
17
  }
18
18
  class ue {
19
19
  constructor(t, s = {}) {
@@ -60,16 +60,16 @@ const nt = new ue("SDK", {
60
60
  textColor: "white"
61
61
  });
62
62
  let X = !1;
63
- const ft = ({ name: e, payload: t }) => {
63
+ const mt = ({ name: e, payload: t }) => {
64
64
  nt.log("Event received:", t ? { name: e, payload: t } : { name: e });
65
65
  };
66
66
  function le(e) {
67
- X !== e && (X = e, e ? pe(ft) : xt(ft));
67
+ X !== e && (X = e, e ? pe(mt) : Ct(mt));
68
68
  }
69
69
  function de(...e) {
70
70
  X && nt.log(...e);
71
71
  }
72
- class N {
72
+ class D {
73
73
  constructor() {
74
74
  c(this, "listeners", /* @__PURE__ */ new Map()), c(this, "listenersCount", 0), c(this, "subscribeListeners", []);
75
75
  }
@@ -142,7 +142,7 @@ class N {
142
142
  function tt(e, t, s) {
143
143
  return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
144
144
  }
145
- function Ct(...e) {
145
+ function rt(...e) {
146
146
  let t = !1;
147
147
  const s = [...e];
148
148
  return [
@@ -194,7 +194,7 @@ class G {
194
194
  function A(e, t) {
195
195
  return () => new G(e, !1, t);
196
196
  }
197
- const P = A((e) => {
197
+ const E = A((e) => {
198
198
  if (typeof e == "boolean")
199
199
  return e;
200
200
  const t = String(e);
@@ -226,7 +226,7 @@ function Tt(e, t) {
226
226
  }
227
227
  return s;
228
228
  }
229
- function rt(e) {
229
+ function it(e) {
230
230
  let t = e;
231
231
  if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
232
232
  throw T();
@@ -234,11 +234,11 @@ function rt(e) {
234
234
  }
235
235
  function w(e, t) {
236
236
  return new G((s) => {
237
- const n = rt(s);
237
+ const n = it(s);
238
238
  return Tt(e, (r) => n[r]);
239
239
  }, !1, t);
240
240
  }
241
- const x = A((e) => {
241
+ const R = A((e) => {
242
242
  if (typeof e == "number")
243
243
  return e;
244
244
  if (typeof e == "string") {
@@ -248,7 +248,7 @@ const x = A((e) => {
248
248
  }
249
249
  throw T();
250
250
  }, "number");
251
- function it(e) {
251
+ function ot(e) {
252
252
  return /^#[\da-f]{6}$/i.test(e);
253
253
  }
254
254
  function Pe(e) {
@@ -256,7 +256,7 @@ function Pe(e) {
256
256
  }
257
257
  function At(e) {
258
258
  const t = e.replace(/\s/g, "").toLowerCase();
259
- if (it(t))
259
+ if (ot(t))
260
260
  return t;
261
261
  if (Pe(t)) {
262
262
  let n = "#";
@@ -272,14 +272,14 @@ function At(e) {
272
272
  return n + (i.length === 1 ? "0" : "") + i;
273
273
  }, "#");
274
274
  }
275
- const p = A((e) => {
275
+ const h = A((e) => {
276
276
  if (typeof e == "string" || typeof e == "number")
277
277
  return e.toString();
278
278
  throw T();
279
- }, "string"), It = A((e) => At(p().parse(e)), "rgb");
279
+ }, "string"), It = A((e) => At(h().parse(e)), "rgb");
280
280
  function kt(e) {
281
281
  return w({
282
- eventType: p(),
282
+ eventType: h(),
283
283
  eventData: (t) => t
284
284
  }).parse(e);
285
285
  }
@@ -316,44 +316,44 @@ function xe() {
316
316
  }
317
317
  const Ce = {
318
318
  clipboard_text_received: w({
319
- req_id: p(),
320
- data: (e) => e === null ? e : p().optional().parse(e)
319
+ req_id: h(),
320
+ data: (e) => e === null ? e : h().optional().parse(e)
321
321
  }),
322
322
  custom_method_invoked: w({
323
- req_id: p(),
323
+ req_id: h(),
324
324
  result: (e) => e,
325
- error: p().optional()
325
+ error: h().optional()
326
326
  }),
327
- invoice_closed: w({ slug: p(), status: p() }),
328
- phone_requested: w({ status: p() }),
327
+ invoice_closed: w({ slug: h(), status: h() }),
328
+ phone_requested: w({ status: h() }),
329
329
  popup_closed: {
330
330
  parse(e) {
331
331
  return w({
332
- button_id: (t) => t == null ? void 0 : p().parse(t)
332
+ button_id: (t) => t == null ? void 0 : h().parse(t)
333
333
  }).parse(e ?? {});
334
334
  }
335
335
  },
336
- qr_text_received: w({ data: p().optional() }),
336
+ qr_text_received: w({ data: h().optional() }),
337
337
  theme_changed: w({
338
338
  theme_params: (e) => {
339
339
  const t = It().optional();
340
- return Object.entries(rt(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
340
+ return Object.entries(it(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
341
341
  }
342
342
  }),
343
343
  viewport_changed: w({
344
- height: x(),
345
- width: (e) => e == null ? window.innerWidth : x().parse(e),
346
- is_state_stable: P(),
347
- is_expanded: P()
344
+ height: R(),
345
+ width: (e) => e == null ? window.innerWidth : R().parse(e),
346
+ is_state_stable: E(),
347
+ is_expanded: E()
348
348
  }),
349
- write_access_requested: w({ status: p() })
349
+ write_access_requested: w({ status: h() })
350
350
  };
351
351
  function Se() {
352
- const e = new N(), t = new N();
352
+ const e = new D(), t = new D();
353
353
  t.subscribe((n) => {
354
354
  e.emit("event", { name: n.event, payload: n.args[0] });
355
355
  }), xe();
356
- const [, s] = Ct(
356
+ const [, s] = rt(
357
357
  // Don't forget to remove created handlers.
358
358
  Re,
359
359
  // Add "resize" event listener to make sure, we always have fresh viewport information.
@@ -382,13 +382,13 @@ function Se() {
382
382
  }
383
383
  const { eventType: i, eventData: o } = r, a = Ce[i];
384
384
  try {
385
- const u = a ? a.parse(o) : o;
386
- t.emit(...u ? [i, u] : [i]);
387
- } catch (u) {
385
+ const p = a ? a.parse(o) : o;
386
+ t.emit(...p ? [i, p] : [i]);
387
+ } catch (p) {
388
388
  nt.error(
389
389
  `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`,
390
390
  r,
391
- u
391
+ p
392
392
  );
393
393
  }
394
394
  }),
@@ -410,7 +410,7 @@ function Se() {
410
410
  }
411
411
  }, s];
412
412
  }
413
- const [Te, Ae] = Rt(
413
+ const [Te, Ae] = xt(
414
414
  (e) => {
415
415
  const [t, s] = Se(), n = t.off.bind(t);
416
416
  return t.off = (r, i) => {
@@ -426,7 +426,7 @@ function j() {
426
426
  function z(e, t) {
427
427
  j().off(e, t);
428
428
  }
429
- function E(e, t, s) {
429
+ function y(e, t, s) {
430
430
  return j().on(e, t, s);
431
431
  }
432
432
  function V(e) {
@@ -441,15 +441,15 @@ function Ie(e, t) {
441
441
  }
442
442
  return 0;
443
443
  }
444
- function y(e, t) {
444
+ function v(e, t) {
445
445
  return Ie(e, t) <= 0;
446
446
  }
447
- function C(e, t, s) {
447
+ function x(e, t, s) {
448
448
  if (typeof s == "string") {
449
449
  if (e === "web_app_open_link" && t === "try_instant_view")
450
- return y("6.4", s);
450
+ return v("6.4", s);
451
451
  if (e === "web_app_set_header_color" && t === "color")
452
- return y("6.9", s);
452
+ return v("6.9", s);
453
453
  }
454
454
  switch (e) {
455
455
  case "web_app_open_tg_link":
@@ -458,27 +458,27 @@ function C(e, t, s) {
458
458
  case "web_app_set_background_color":
459
459
  case "web_app_set_header_color":
460
460
  case "web_app_trigger_haptic_feedback":
461
- return y("6.1", t);
461
+ return v("6.1", t);
462
462
  case "web_app_open_popup":
463
- return y("6.2", t);
463
+ return v("6.2", t);
464
464
  case "web_app_close_scan_qr_popup":
465
465
  case "web_app_open_scan_qr_popup":
466
466
  case "web_app_read_text_from_clipboard":
467
- return y("6.4", t);
467
+ return v("6.4", t);
468
468
  case "web_app_switch_inline_query":
469
- return y("6.7", t);
469
+ return v("6.7", t);
470
470
  case "web_app_invoke_custom_method":
471
471
  case "web_app_request_write_access":
472
472
  case "web_app_request_phone":
473
- return y("6.9", t);
473
+ return v("6.9", t);
474
474
  case "web_app_setup_settings_button":
475
- return y("6.10", t);
475
+ return v("6.10", t);
476
476
  case "web_app_biometry_get_info":
477
477
  case "web_app_biometry_open_settings":
478
478
  case "web_app_biometry_request_access":
479
479
  case "web_app_biometry_request_auth":
480
480
  case "web_app_biometry_update_token":
481
- return y("7.2", t);
481
+ return v("7.2", t);
482
482
  default:
483
483
  return [
484
484
  "iframe_ready",
@@ -501,25 +501,25 @@ function qt(e) {
501
501
  function Ot(e) {
502
502
  return "TelegramWebviewProxy" in e && V(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
503
503
  }
504
- function ot() {
504
+ function at() {
505
505
  try {
506
506
  return window.self !== window.top;
507
507
  } catch {
508
508
  return !0;
509
509
  }
510
510
  }
511
- let Dt = "https://web.telegram.org";
511
+ let Nt = "https://web.telegram.org";
512
512
  function wn(e) {
513
- Dt = e;
513
+ Nt = e;
514
514
  }
515
515
  function ke() {
516
- return Dt;
516
+ return Nt;
517
517
  }
518
518
  function B(e, t, s) {
519
519
  let n = {}, r;
520
520
  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);
521
521
  const { targetOrigin: i = ke() } = n;
522
- if (de("Posting event:", r ? { event: e, data: r } : { event: e }), ot()) {
522
+ if (de("Posting event:", r ? { event: e, data: r } : { event: e }), at()) {
523
523
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
524
524
  return;
525
525
  }
@@ -538,11 +538,11 @@ function B(e, t, s) {
538
538
  }
539
539
  function qe(e) {
540
540
  return (t, s) => {
541
- if (!C(t, e))
541
+ if (!x(t, e))
542
542
  throw m(_e, `Method "${t}" is unsupported in Mini Apps version ${e}`);
543
543
  if (V(s)) {
544
544
  let n;
545
- 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))
545
+ 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))
546
546
  throw m(
547
547
  we,
548
548
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
@@ -551,7 +551,7 @@ function qe(e) {
551
551
  return B(t, s);
552
552
  };
553
553
  }
554
- function Nt(e) {
554
+ function Dt(e) {
555
555
  return ({ req_id: t }) => t === e;
556
556
  }
557
557
  function Bt(e) {
@@ -569,21 +569,17 @@ function Mt(e, t) {
569
569
  }
570
570
  async function g(e) {
571
571
  let t;
572
- const s = new Promise((h) => {
573
- t = h;
574
- }), {
575
- method: n,
576
- event: r,
577
- capture: i,
578
- postEvent: o = B,
579
- timeout: a
580
- } = e, u = (Array.isArray(r) ? r : [r]).map(
581
- (h) => E(h, (v) => (!i || i(v)) && t(v))
572
+ const s = new Promise((a) => {
573
+ t = a;
574
+ }), { event: n, capture: r, timeout: i } = e, [, o] = rt(
575
+ ...(Array.isArray(n) ? n : [n]).map(
576
+ (a) => y(a, (p) => (!r || r(p)) && t(p))
577
+ )
582
578
  );
583
579
  try {
584
- return o(n, e.params), await (a ? Mt(s, a) : s);
580
+ return (e.postEvent || B)(e.method, e.params), await (i ? Mt(s, i) : s);
585
581
  } finally {
586
- u.forEach((h) => h());
582
+ o();
587
583
  }
588
584
  }
589
585
  async function O(e, t, s, n = {}) {
@@ -599,7 +595,7 @@ async function O(e, t, s, n = {}) {
599
595
  params: t,
600
596
  req_id: s
601
597
  },
602
- capture: Nt(s)
598
+ capture: Dt(s)
603
599
  });
604
600
  if (i)
605
601
  throw m(fe, i);
@@ -632,7 +628,7 @@ function Vt(e) {
632
628
  }
633
629
  class Oe {
634
630
  constructor(t) {
635
- c(this, "ee", new N()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
631
+ c(this, "ee", new D()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
636
632
  }
637
633
  /**
638
634
  * Clones current state and returns its copy.
@@ -651,25 +647,25 @@ class Oe {
651
647
  return this.state[t];
652
648
  }
653
649
  }
654
- class at {
650
+ class ct {
655
651
  constructor(t) {
656
652
  c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new Oe(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);
657
653
  }
658
654
  }
659
- function $t(e, t) {
660
- return (s) => C(t[s], e);
655
+ function Lt(e, t) {
656
+ return (s) => x(t[s], e);
661
657
  }
662
- class ct extends at {
658
+ class ht extends ct {
663
659
  constructor(t, s, n) {
664
- super(t), c(this, "supports"), this.supports = $t(s, n);
660
+ super(t), c(this, "supports"), this.supports = Lt(s, n);
665
661
  }
666
662
  }
667
- class De extends ct {
663
+ class Ne extends ht {
668
664
  constructor(t, s, n) {
669
665
  super({ isVisible: t }, s, {
670
666
  show: "web_app_setup_back_button",
671
667
  hide: "web_app_setup_back_button"
672
- }), c(this, "on", (r, i) => r === "click" ? E("back_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? z("back_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
668
+ }), c(this, "on", (r, i) => r === "click" ? y("back_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? z("back_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
673
669
  }
674
670
  set isVisible(t) {
675
671
  this.set("isVisible", t), this.postEvent("web_app_setup_back_button", { is_visible: t });
@@ -693,8 +689,8 @@ class De extends ct {
693
689
  this.isVisible = !0;
694
690
  }
695
691
  }
696
- const Lt = A((e) => e instanceof Date ? e : new Date(x().parse(e) * 1e3), "Date");
697
- function ht(e, t) {
692
+ const $t = A((e) => e instanceof Date ? e : new Date(R().parse(e) * 1e3), "Date");
693
+ function pt(e, t) {
698
694
  return new G((s) => {
699
695
  if (typeof s != "string" && !(s instanceof URLSearchParams))
700
696
  throw T();
@@ -705,81 +701,81 @@ function ht(e, t) {
705
701
  });
706
702
  }, !1, t);
707
703
  }
708
- const Ne = w({
709
- id: x(),
710
- type: p(),
711
- title: p(),
704
+ const De = w({
705
+ id: R(),
706
+ type: h(),
707
+ title: h(),
712
708
  photoUrl: {
713
- type: p().optional(),
709
+ type: h().optional(),
714
710
  from: "photo_url"
715
711
  },
716
- username: p().optional()
717
- }, "Chat").optional(), mt = w({
712
+ username: h().optional()
713
+ }, "Chat").optional(), bt = w({
718
714
  addedToAttachmentMenu: {
719
- type: P().optional(),
715
+ type: E().optional(),
720
716
  from: "added_to_attachment_menu"
721
717
  },
722
718
  allowsWriteToPm: {
723
- type: P().optional(),
719
+ type: E().optional(),
724
720
  from: "allows_write_to_pm"
725
721
  },
726
722
  firstName: {
727
- type: p(),
723
+ type: h(),
728
724
  from: "first_name"
729
725
  },
730
- id: x(),
726
+ id: R(),
731
727
  isBot: {
732
- type: P().optional(),
728
+ type: E().optional(),
733
729
  from: "is_bot"
734
730
  },
735
731
  isPremium: {
736
- type: P().optional(),
732
+ type: E().optional(),
737
733
  from: "is_premium"
738
734
  },
739
735
  languageCode: {
740
- type: p().optional(),
736
+ type: h().optional(),
741
737
  from: "language_code"
742
738
  },
743
739
  lastName: {
744
- type: p().optional(),
740
+ type: h().optional(),
745
741
  from: "last_name"
746
742
  },
747
743
  photoUrl: {
748
- type: p().optional(),
744
+ type: h().optional(),
749
745
  from: "photo_url"
750
746
  },
751
- username: p().optional()
747
+ username: h().optional()
752
748
  }, "User").optional();
753
- function Ht() {
754
- return ht({
749
+ function Ut() {
750
+ return pt({
755
751
  authDate: {
756
- type: Lt(),
752
+ type: $t(),
757
753
  from: "auth_date"
758
754
  },
759
755
  canSendAfter: {
760
- type: x().optional(),
756
+ type: R().optional(),
761
757
  from: "can_send_after"
762
758
  },
763
- chat: Ne,
759
+ chat: De,
764
760
  chatInstance: {
765
- type: p().optional(),
761
+ type: h().optional(),
766
762
  from: "chat_instance"
767
763
  },
768
764
  chatType: {
769
- type: p().optional(),
765
+ type: h().optional(),
770
766
  from: "chat_type"
771
767
  },
772
- hash: p(),
768
+ hash: h(),
773
769
  queryId: {
774
- type: p().optional(),
770
+ type: h().optional(),
775
771
  from: "query_id"
776
772
  },
777
- receiver: mt,
773
+ receiver: bt,
778
774
  startParam: {
779
- type: p().optional(),
775
+ type: h().optional(),
780
776
  from: "start_param"
781
777
  },
782
- user: mt
778
+ user: bt
783
779
  }, "InitData");
784
780
  }
785
781
  function Be(e) {
@@ -788,51 +784,51 @@ function Be(e) {
788
784
  function Me(e) {
789
785
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
790
786
  }
791
- const Ut = A(
787
+ const Ht = A(
792
788
  (e) => {
793
789
  const t = It().optional();
794
- return Object.entries(rt(e)).reduce((s, [n, r]) => (s[Be(n)] = t.parse(r), s), {});
790
+ return Object.entries(it(e)).reduce((s, [n, r]) => (s[Be(n)] = t.parse(r), s), {});
795
791
  },
796
792
  "ThemeParams"
797
793
  );
798
- function pt(e) {
799
- return ht({
794
+ function ut(e) {
795
+ return pt({
800
796
  botInline: {
801
- type: P().optional(),
797
+ type: E().optional(),
802
798
  from: "tgWebAppBotInline"
803
799
  },
804
800
  initData: {
805
- type: Ht().optional(),
801
+ type: Ut().optional(),
806
802
  from: "tgWebAppData"
807
803
  },
808
804
  initDataRaw: {
809
- type: p().optional(),
805
+ type: h().optional(),
810
806
  from: "tgWebAppData"
811
807
  },
812
808
  platform: {
813
- type: p(),
809
+ type: h(),
814
810
  from: "tgWebAppPlatform"
815
811
  },
816
812
  showSettings: {
817
- type: P().optional(),
813
+ type: E().optional(),
818
814
  from: "tgWebAppShowSettings"
819
815
  },
820
816
  startParam: {
821
- type: p().optional(),
817
+ type: h().optional(),
822
818
  from: "tgWebAppStartParam"
823
819
  },
824
820
  themeParams: {
825
- type: Ut(),
821
+ type: Ht(),
826
822
  from: "tgWebAppThemeParams"
827
823
  },
828
824
  version: {
829
- type: p(),
825
+ type: h(),
830
826
  from: "tgWebAppVersion"
831
827
  }
832
828
  }).parse(e);
833
829
  }
834
830
  function Wt(e) {
835
- return pt(
831
+ return ut(
836
832
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
837
833
  );
838
834
  }
@@ -842,7 +838,7 @@ function Ve() {
842
838
  function Gt() {
843
839
  return performance.getEntriesByType("navigation")[0];
844
840
  }
845
- function $e() {
841
+ function Le() {
846
842
  const e = Gt();
847
843
  if (!e)
848
844
  throw new Error("Unable to get first navigation entry.");
@@ -861,8 +857,8 @@ function Kt(e) {
861
857
  } catch {
862
858
  }
863
859
  }
864
- function Le() {
865
- return pt(Kt("launchParams") || "");
860
+ function $e() {
861
+ return ut(Kt("launchParams") || "");
866
862
  }
867
863
  function Jt(e) {
868
864
  return JSON.stringify(
@@ -871,7 +867,7 @@ function Jt(e) {
871
867
  )
872
868
  );
873
869
  }
874
- function He(e) {
870
+ function Ue(e) {
875
871
  const {
876
872
  initDataRaw: t,
877
873
  themeParams: s,
@@ -880,11 +876,11 @@ function He(e) {
880
876
  showSettings: i,
881
877
  startParam: o,
882
878
  botInline: a
883
- } = e, u = new URLSearchParams();
884
- return u.set("tgWebAppPlatform", n), u.set("tgWebAppThemeParams", Jt(s)), u.set("tgWebAppVersion", r), t && u.set("tgWebAppData", t), o && u.set("tgWebAppStartParam", o), typeof i == "boolean" && u.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && u.set("tgWebAppBotInline", a ? "1" : "0"), u.toString();
879
+ } = e, p = new URLSearchParams();
880
+ return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", Jt(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();
885
881
  }
886
882
  function Ft(e) {
887
- zt("launchParams", He(e));
883
+ zt("launchParams", Ue(e));
888
884
  }
889
885
  function Qt() {
890
886
  for (const e of [
@@ -892,9 +888,9 @@ function Qt() {
892
888
  // nothing in case, location was changed and then page was reloaded.
893
889
  Ve,
894
890
  // Then, try using the lower level API - window.performance.
895
- $e,
891
+ Le,
896
892
  // Finally, try to extract launch parameters from the session storage.
897
- Le
893
+ $e
898
894
  ])
899
895
  try {
900
896
  const t = e();
@@ -907,11 +903,11 @@ function Yt() {
907
903
  const e = Gt();
908
904
  return !!(e && e.type === "reload");
909
905
  }
910
- function Ue() {
906
+ function He() {
911
907
  let e = 0;
912
908
  return () => (e += 1).toString();
913
909
  }
914
- const [We] = Rt(Ue);
910
+ const [We] = xt(He);
915
911
  function l(e, t) {
916
912
  return () => {
917
913
  const s = Qt(), n = {
@@ -921,20 +917,20 @@ function l(e, t) {
921
917
  };
922
918
  if (typeof e == "function")
923
919
  return e(n);
924
- const [r, i, o] = Ct(), a = t({
920
+ const [r, i, o] = rt(), a = t({
925
921
  ...n,
926
922
  // State should only be passed only in case, current page was reloaded. If we don't add
927
923
  // this check, state restoration will work improperly in the web version of Telegram,
928
924
  // when we are always working in the same "session" (tab).
929
925
  state: Yt() ? Kt(e) : void 0,
930
926
  addCleanup: r
931
- }), u = (h) => (o || r(
932
- h.on("change", (v) => {
933
- zt(e, v);
927
+ }), p = (u) => (o || r(
928
+ u.on("change", (C) => {
929
+ zt(e, C);
934
930
  })
935
- ), h);
931
+ ), u);
936
932
  return [
937
- a instanceof Promise ? a.then(u) : u(a),
933
+ a instanceof Promise ? a.then(p) : p(a),
938
934
  i
939
935
  ];
940
936
  };
@@ -943,8 +939,8 @@ const Ge = l("backButton", ({
943
939
  postEvent: e,
944
940
  version: t,
945
941
  state: s = { isVisible: !1 }
946
- }) => new De(s.isVisible, t, e));
947
- class $ extends ct {
942
+ }) => new Ne(s.isVisible, t, e));
943
+ class L extends ht {
948
944
  constructor() {
949
945
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
950
946
  }
@@ -967,7 +963,7 @@ function Zt(e) {
967
963
  accessGranted: t.access_granted
968
964
  };
969
965
  }
970
- class je extends $ {
966
+ class je extends L {
971
967
  constructor({ postEvent: t, version: s, ...n }) {
972
968
  super(n, s, {
973
969
  auth: "web_app_biometry_request_auth",
@@ -1089,7 +1085,7 @@ async function ze(e) {
1089
1085
  const Ke = l(
1090
1086
  "biometryManager",
1091
1087
  async ({ postEvent: e, version: t, state: s }) => new je({
1092
- ...s || C("web_app_biometry_get_info", t) ? s || await ze({ timeout: 1e3 }) : {
1088
+ ...s || x("web_app_biometry_get_info", t) ? s || await ze({ timeout: 1e3 }) : {
1093
1089
  available: !1,
1094
1090
  accessGranted: !1,
1095
1091
  accessRequested: !1,
@@ -1100,12 +1096,12 @@ const Ke = l(
1100
1096
  postEvent: e
1101
1097
  })
1102
1098
  );
1103
- class ut extends at {
1099
+ class lt extends ct {
1104
1100
  constructor() {
1105
1101
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
1106
1102
  }
1107
1103
  }
1108
- class Je extends ut {
1104
+ class Je extends lt {
1109
1105
  constructor(t, s) {
1110
1106
  super({ isConfirmationNeeded: t }), this.postEvent = s;
1111
1107
  }
@@ -1139,9 +1135,9 @@ const Fe = l(
1139
1135
  state: t = { isConfirmationNeeded: !1 }
1140
1136
  }) => new Je(t.isConfirmationNeeded, e)
1141
1137
  );
1142
- class lt {
1138
+ class dt {
1143
1139
  constructor(t, s) {
1144
- c(this, "supports"), this.supports = $t(t, s);
1140
+ c(this, "supports"), this.supports = Lt(t, s);
1145
1141
  }
1146
1142
  }
1147
1143
  function Qe(e) {
@@ -1177,10 +1173,10 @@ class Ye extends G {
1177
1173
  function Ze(e) {
1178
1174
  return new Ye((t) => t, !1, e);
1179
1175
  }
1180
- function bt(e, t) {
1176
+ function vt(e, t) {
1181
1177
  return Object.fromEntries(e.map((s) => [s, t]));
1182
1178
  }
1183
- class Xe extends lt {
1179
+ class Xe extends dt {
1184
1180
  constructor(t, s, n) {
1185
1181
  super(t, {
1186
1182
  delete: "web_app_invoke_custom_method",
@@ -1208,7 +1204,7 @@ class Xe extends lt {
1208
1204
  * @param options - request execution options.
1209
1205
  */
1210
1206
  async getKeys(t = {}) {
1211
- return Ze().of(p()).parse(
1207
+ return Ze().of(h()).parse(
1212
1208
  await O(
1213
1209
  "getStorageKeys",
1214
1210
  {},
@@ -1220,13 +1216,13 @@ class Xe extends lt {
1220
1216
  async get(t, s = {}) {
1221
1217
  const n = Array.isArray(t) ? t : [t];
1222
1218
  if (!n.length)
1223
- return bt(n, "");
1219
+ return vt(n, "");
1224
1220
  const r = await O(
1225
1221
  "getStorageValues",
1226
1222
  { keys: n },
1227
1223
  this.createRequestId(),
1228
1224
  { ...s, postEvent: this.postEvent }
1229
- ), i = w(bt(n, p()), "CloudStorageData").parse(r);
1225
+ ), i = w(vt(n, h()), "CloudStorageData").parse(r);
1230
1226
  return Array.isArray(t) ? i : i[t];
1231
1227
  }
1232
1228
  /**
@@ -1247,7 +1243,7 @@ class Xe extends lt {
1247
1243
  const ts = l(
1248
1244
  ({ createRequestId: e, postEvent: t, version: s }) => new Xe(s, e, t)
1249
1245
  );
1250
- class es extends lt {
1246
+ class es extends dt {
1251
1247
  constructor(t, s) {
1252
1248
  super(t, {
1253
1249
  impactOccurred: "web_app_trigger_haptic_feedback",
@@ -1369,9 +1365,9 @@ const rs = l(
1369
1365
  ({ initData: e }) => e ? new ns(e) : void 0
1370
1366
  );
1371
1367
  function fn(e) {
1372
- return Ht().parse(e);
1368
+ return Ut().parse(e);
1373
1369
  }
1374
- class is extends $ {
1370
+ class is extends L {
1375
1371
  constructor(t, s, n) {
1376
1372
  super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
1377
1373
  }
@@ -1418,9 +1414,9 @@ class is extends $ {
1418
1414
  const os = l(
1419
1415
  ({ version: e, postEvent: t }) => new is(!1, e, t)
1420
1416
  );
1421
- class as extends at {
1417
+ class as extends ct {
1422
1418
  constructor({ postEvent: t, ...s }) {
1423
- super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ? E("main_button_pressed", r) : this.state.on(n, r)), c(this, "off", (n, r) => n === "click" ? z("main_button_pressed", r) : this.state.off(n, r)), this.postEvent = t;
1419
+ super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ? y("main_button_pressed", r) : this.state.on(n, r)), c(this, "off", (n, r) => n === "click" ? z("main_button_pressed", r) : this.state.off(n, r)), this.postEvent = t;
1424
1420
  }
1425
1421
  /**
1426
1422
  * The MainButton background color.
@@ -1565,36 +1561,36 @@ const cs = l(
1565
1561
  }) => new as({ ...s, postEvent: e })
1566
1562
  );
1567
1563
  function hs() {
1568
- return ht({
1564
+ return pt({
1569
1565
  contact: w({
1570
1566
  userId: {
1571
- type: x(),
1567
+ type: R(),
1572
1568
  from: "user_id"
1573
1569
  },
1574
1570
  phoneNumber: {
1575
- type: p(),
1571
+ type: h(),
1576
1572
  from: "phone_number"
1577
1573
  },
1578
1574
  firstName: {
1579
- type: p(),
1575
+ type: h(),
1580
1576
  from: "first_name"
1581
1577
  },
1582
1578
  lastName: {
1583
- type: p().optional(),
1579
+ type: h().optional(),
1584
1580
  from: "last_name"
1585
1581
  }
1586
1582
  }),
1587
1583
  authDate: {
1588
- type: Lt(),
1584
+ type: $t(),
1589
1585
  from: "auth_date"
1590
1586
  },
1591
- hash: p()
1587
+ hash: h()
1592
1588
  }, "RequestedContact");
1593
1589
  }
1594
1590
  function Xt(e, t) {
1595
1591
  return (s) => {
1596
1592
  const [n, r] = t[s];
1597
- return C(n, r, e);
1593
+ return x(n, r, e);
1598
1594
  };
1599
1595
  }
1600
1596
  function ps(e) {
@@ -1602,7 +1598,7 @@ function ps(e) {
1602
1598
  setTimeout(t, e);
1603
1599
  });
1604
1600
  }
1605
- class us extends $ {
1601
+ class us extends L {
1606
1602
  constructor({ postEvent: t, createRequestId: s, version: n, botInline: r, ...i }) {
1607
1603
  super(i, n, {
1608
1604
  requestPhoneAccess: "web_app_request_phone",
@@ -1755,7 +1751,7 @@ class us extends $ {
1755
1751
  * @param color - color key or RGB color.
1756
1752
  */
1757
1753
  setHeaderColor(t) {
1758
- this.postEvent("web_app_set_header_color", it(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
1754
+ this.postEvent("web_app_set_header_color", ot(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
1759
1755
  }
1760
1756
  /**
1761
1757
  * Updates current Mini App background color.
@@ -1811,15 +1807,15 @@ function ds(e) {
1811
1807
  if (!i.type || i.type === "default" || i.type === "destructive") {
1812
1808
  const a = i.text.trim();
1813
1809
  if (!a.length || a.length > 64) {
1814
- const u = i.type || "default";
1815
- throw new Error(`Button text with type "${u}" has incorrect size: ${i.text.length}`);
1810
+ const p = i.type || "default";
1811
+ throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
1816
1812
  }
1817
1813
  return { ...i, text: a, id: o };
1818
1814
  }
1819
1815
  return { ...i, id: o };
1820
1816
  }) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
1821
1817
  }
1822
- class _s extends $ {
1818
+ class _s extends L {
1823
1819
  constructor(t, s, n) {
1824
1820
  super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
1825
1821
  }
@@ -1863,7 +1859,7 @@ class _s extends $ {
1863
1859
  const ws = l(
1864
1860
  ({ postEvent: e, version: t }) => new _s(!1, t, e)
1865
1861
  );
1866
- class gs extends $ {
1862
+ class gs extends L {
1867
1863
  constructor(t, s, n) {
1868
1864
  super({ isOpened: t }, s, {
1869
1865
  close: "web_app_close_scan_qr_popup",
@@ -1885,37 +1881,36 @@ class gs extends $ {
1885
1881
  get isOpened() {
1886
1882
  return this.get("isOpened");
1887
1883
  }
1888
- /**
1889
- * Opens scanner with specified title shown to user. Method returns promise
1890
- * with scanned QR content in case, it was scanned. It will contain null in
1891
- * case, scanner was closed.
1892
- * @param text - title to display.
1893
- */
1894
1884
  async open(t) {
1895
1885
  if (this.isOpened)
1896
1886
  throw new Error("QR scanner is already opened.");
1887
+ const { text: s, capture: n } = (typeof t == "string" ? { text: t } : t) || {};
1897
1888
  this.isOpened = !0;
1898
1889
  try {
1899
- return (await g({
1890
+ const r = (await g({
1900
1891
  method: "web_app_open_scan_qr_popup",
1901
1892
  event: ["qr_text_received", "scan_qr_popup_closed"],
1902
1893
  postEvent: this.postEvent,
1903
- params: { text: t }
1894
+ params: { text: s },
1895
+ capture(i) {
1896
+ return i.event === "scan_qr_popup_closed" || !n || n(i.payload);
1897
+ }
1904
1898
  }) || {}).data || null;
1905
- } finally {
1906
- this.isOpened = !1;
1899
+ return r && this.close(), r;
1900
+ } catch (r) {
1901
+ throw this.isOpened = !1, r;
1907
1902
  }
1908
1903
  }
1909
1904
  }
1910
1905
  const fs = l(
1911
1906
  ({ version: e, postEvent: t }) => new gs(!1, e, t)
1912
1907
  );
1913
- class ms extends ct {
1908
+ class ms extends ht {
1914
1909
  constructor(t, s, n) {
1915
1910
  super({ isVisible: t }, s, {
1916
1911
  show: "web_app_setup_settings_button",
1917
1912
  hide: "web_app_setup_settings_button"
1918
- }), c(this, "on", (r, i) => r === "click" ? E("settings_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? z("settings_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
1913
+ }), c(this, "on", (r, i) => r === "click" ? y("settings_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? z("settings_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
1919
1914
  }
1920
1915
  set isVisible(t) {
1921
1916
  this.set("isVisible", t), this.postEvent("web_app_setup_settings_button", { is_visible: t });
@@ -1948,9 +1943,9 @@ const bs = l(
1948
1943
  }) => new ms(s.isVisible, e, t)
1949
1944
  );
1950
1945
  function te(e) {
1951
- return Ut().parse(e);
1946
+ return Ht().parse(e);
1952
1947
  }
1953
- class vs extends ut {
1948
+ class vs extends lt {
1954
1949
  /**
1955
1950
  * @since v6.10
1956
1951
  */
@@ -2014,7 +2009,7 @@ class vs extends ut {
2014
2009
  * @returns Function to stop listening.
2015
2010
  */
2016
2011
  listen() {
2017
- return E("theme_changed", (t) => {
2012
+ return y("theme_changed", (t) => {
2018
2013
  this.set(te(t.theme_params));
2019
2014
  });
2020
2015
  }
@@ -2042,7 +2037,7 @@ function mn(e = {}) {
2042
2037
  event: "theme_changed"
2043
2038
  }).then(te);
2044
2039
  }
2045
- class Es extends lt {
2040
+ class Es extends dt {
2046
2041
  constructor(t, s, n) {
2047
2042
  super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Xt(t, {
2048
2043
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
@@ -2059,7 +2054,7 @@ class Es extends lt {
2059
2054
  */
2060
2055
  openLink(t, s) {
2061
2056
  const n = new URL(t, window.location.href).toString();
2062
- if (!C("web_app_open_link", this.version)) {
2057
+ if (!x("web_app_open_link", this.version)) {
2063
2058
  window.open(n, "_blank");
2064
2059
  return;
2065
2060
  }
@@ -2075,10 +2070,10 @@ class Es extends lt {
2075
2070
  * @throws {Error} URL has not allowed hostname.
2076
2071
  */
2077
2072
  openTelegramLink(t) {
2078
- const { hostname: s, pathname: n, search: r } = new URL(t, window.location.href);
2073
+ const { hostname: s, pathname: n, search: r } = new URL(t, "https://t.me");
2079
2074
  if (s !== "t.me")
2080
2075
  throw new Error(`URL has not allowed hostname: ${s}. Only "t.me" is allowed`);
2081
- if (!C("web_app_open_tg_link", this.version)) {
2076
+ if (!x("web_app_open_tg_link", this.version)) {
2082
2077
  window.location.href = t;
2083
2078
  return;
2084
2079
  }
@@ -2098,10 +2093,24 @@ class Es extends lt {
2098
2093
  event: "clipboard_text_received",
2099
2094
  postEvent: this.postEvent,
2100
2095
  params: { req_id: t },
2101
- capture: Nt(t)
2096
+ capture: Dt(t)
2102
2097
  });
2103
2098
  return s;
2104
2099
  }
2100
+ /**
2101
+ * Shares specified URL with the passed to the chats, selected by user. After being called,
2102
+ * it closes the mini application.
2103
+ *
2104
+ * This method uses Telegram's Share Links.
2105
+ * @param url - URL to share.
2106
+ * @param text - text to append after the URL.
2107
+ * @see https://core.telegram.org/api/links#share-links
2108
+ */
2109
+ shareURL(t, s) {
2110
+ this.openTelegramLink(
2111
+ "https://t.me/share?" + new URLSearchParams({ url: t, text: s || "" }).toString()
2112
+ );
2113
+ }
2105
2114
  }
2106
2115
  const Ps = l(
2107
2116
  ({ version: e, postEvent: t, createRequestId: s }) => new Es(e, s, t)
@@ -2121,7 +2130,7 @@ async function ee(e = {}) {
2121
2130
  function q(e) {
2122
2131
  return e < 0 ? 0 : e;
2123
2132
  }
2124
- class Rs extends ut {
2133
+ class Rs extends lt {
2125
2134
  constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
2126
2135
  super({
2127
2136
  height: q(n),
@@ -2183,7 +2192,7 @@ class Rs extends ut {
2183
2192
  * @returns Function to stop listening.
2184
2193
  */
2185
2194
  listen() {
2186
- return E("viewport_changed", (t) => {
2195
+ return y("viewport_changed", (t) => {
2187
2196
  const {
2188
2197
  height: s,
2189
2198
  width: n,
@@ -2237,33 +2246,33 @@ const xs = l(
2237
2246
  else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2238
2247
  r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
2239
2248
  else {
2240
- const h = await ee({ timeout: 1e3, postEvent: s });
2241
- r = h.isExpanded, i = h.height, o = h.width, a = h.isStateStable ? i : 0;
2249
+ const u = await ee({ timeout: 1e3, postEvent: s });
2250
+ r = u.isExpanded, i = u.height, o = u.width, a = u.isStateStable ? i : 0;
2242
2251
  }
2243
- const u = new Rs({
2252
+ const p = new Rs({
2244
2253
  postEvent: s,
2245
2254
  height: i,
2246
2255
  width: o,
2247
2256
  stableHeight: a,
2248
2257
  isExpanded: r
2249
2258
  });
2250
- return n(u.listen()), u;
2259
+ return n(p.listen()), p;
2251
2260
  }
2252
2261
  );
2253
- function R(e, t) {
2262
+ function P(e, t) {
2254
2263
  document.documentElement.style.setProperty(e, t);
2255
2264
  }
2256
2265
  function bn(e, t, s) {
2257
2266
  s || (s = (a) => `--tg-${a}-color`);
2258
2267
  const n = s("header"), r = s("bg"), i = () => {
2259
2268
  const { headerColor: a } = e;
2260
- if (it(a))
2261
- R(n, a);
2269
+ if (ot(a))
2270
+ P(n, a);
2262
2271
  else {
2263
- const { bgColor: u, secondaryBgColor: h } = t;
2264
- a === "bg_color" && u ? R(n, u) : a === "secondary_bg_color" && h && R(n, h);
2272
+ const { bgColor: p, secondaryBgColor: u } = t;
2273
+ a === "bg_color" && p ? P(n, p) : a === "secondary_bg_color" && u && P(n, u);
2265
2274
  }
2266
- R(r, e.bgColor);
2275
+ P(r, e.bgColor);
2267
2276
  }, o = [
2268
2277
  t.on("change", i),
2269
2278
  e.on("change", i)
@@ -2274,34 +2283,34 @@ function vn(e, t) {
2274
2283
  t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
2275
2284
  const s = () => {
2276
2285
  Object.entries(e.getState()).forEach(([n, r]) => {
2277
- r && R(t(n), r);
2286
+ r && P(t(n), r);
2278
2287
  });
2279
2288
  };
2280
2289
  return s(), e.on("change", s);
2281
2290
  }
2282
2291
  function yn(e, t) {
2283
- t || (t = (h) => `--tg-viewport-${h}`);
2292
+ t || (t = (u) => `--tg-viewport-${u}`);
2284
2293
  const [
2285
2294
  s,
2286
2295
  n,
2287
2296
  r
2288
- ] = ["height", "width", "stable-height"].map((h) => t(h)), i = () => R(s, `${e.height}px`), o = () => R(n, `${e.width}px`), a = () => R(r, `${e.stableHeight}px`), u = [
2297
+ ] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => P(s, `${e.height}px`), o = () => P(n, `${e.width}px`), a = () => P(r, `${e.stableHeight}px`), p = [
2289
2298
  e.on("change:height", i),
2290
2299
  e.on("change:width", o),
2291
2300
  e.on("change:stableHeight", a)
2292
2301
  ];
2293
- return i(), o(), a(), () => u.forEach((h) => h());
2302
+ return i(), o(), a(), () => p.forEach((u) => u());
2294
2303
  }
2295
2304
  function Cs(e = !0) {
2296
2305
  const t = [
2297
- E("reload_iframe", () => {
2306
+ y("reload_iframe", () => {
2298
2307
  B("iframe_will_reload"), window.location.reload();
2299
2308
  })
2300
2309
  ], s = () => t.forEach((n) => n());
2301
2310
  if (e) {
2302
2311
  const n = document.createElement("style");
2303
2312
  n.id = "telegram-custom-styles", document.head.appendChild(n), t.push(
2304
- E("set_custom_style", (r) => {
2313
+ y("set_custom_style", (r) => {
2305
2314
  n.innerHTML = r;
2306
2315
  }),
2307
2316
  () => document.head.removeChild(n)
@@ -2322,7 +2331,7 @@ async function En() {
2322
2331
  }
2323
2332
  }
2324
2333
  function Pn(e) {
2325
- const t = typeof e == "string" ? pt(e) : e;
2334
+ const t = typeof e == "string" ? ut(e) : e;
2326
2335
  Ft(t);
2327
2336
  function s(r) {
2328
2337
  if (typeof r == "string")
@@ -2339,7 +2348,7 @@ function Pn(e) {
2339
2348
  } catch {
2340
2349
  }
2341
2350
  }
2342
- if (ot()) {
2351
+ if (at()) {
2343
2352
  const r = window.parent.postMessage.bind(window.parent);
2344
2353
  window.parent.postMessage = (i) => {
2345
2354
  s(i), r(i);
@@ -2377,7 +2386,7 @@ function J(e, t) {
2377
2386
  }
2378
2387
  class As {
2379
2388
  constructor(t, s, n = B) {
2380
- if (c(this, "history"), c(this, "ee", new N()), 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)
2389
+ if (c(this, "history"), c(this, "ee", new D()), 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)
2381
2390
  throw m(ve, "History should not be empty.");
2382
2391
  if (s < 0 || s >= t.length)
2383
2392
  throw m(
@@ -2391,7 +2400,7 @@ class As {
2391
2400
  * `BackButton` clicks and calls the `back` method.
2392
2401
  */
2393
2402
  attach() {
2394
- this.attached || (this.attached = !0, this.sync(), E("back_button_pressed", this.back));
2403
+ this.attached || (this.attached = !0, this.sync(), y("back_button_pressed", this.back));
2395
2404
  }
2396
2405
  /**
2397
2406
  * Currently active history item.
@@ -2505,23 +2514,23 @@ function F({
2505
2514
  function M(e, t) {
2506
2515
  return e.startsWith(t) ? e : `${t}${e}`;
2507
2516
  }
2508
- function H(e) {
2517
+ function U(e) {
2509
2518
  return new URL(
2510
2519
  typeof e == "string" ? e : `${e.pathname || ""}${M(e.search || "", "?")}${M(e.hash || "", "#")}`,
2511
2520
  "http://a"
2512
2521
  );
2513
2522
  }
2514
- function U(e) {
2515
- const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = H(e);
2523
+ function H(e) {
2524
+ const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = U(e);
2516
2525
  return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
2517
2526
  }
2518
2527
  function Q(e, t, s) {
2519
2528
  let n, r;
2520
- typeof e == "string" ? n = e : (n = U(e), s = e.state, r = e.id);
2529
+ typeof e == "string" ? n = e : (n = H(e), s = e.state, r = e.id);
2521
2530
  const { pathname: i, search: o, hash: a } = new URL(n, `http://a${M(t, "/")}`);
2522
2531
  return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
2523
2532
  }
2524
- async function D(e) {
2533
+ async function N(e) {
2525
2534
  return e === 0 ? !0 : Promise.race([
2526
2535
  new Promise((t) => {
2527
2536
  const s = tt("popstate", () => {
@@ -2536,29 +2545,29 @@ async function D(e) {
2536
2545
  ]);
2537
2546
  }
2538
2547
  async function Is() {
2539
- if (window.history.length <= 1 || (window.history.pushState(null, ""), await D(1 - window.history.length)))
2548
+ if (window.history.length <= 1 || (window.history.pushState(null, ""), await N(1 - window.history.length)))
2540
2549
  return;
2541
- let e = await D(-1);
2550
+ let e = await N(-1);
2542
2551
  for (; e; )
2543
- e = await D(-1);
2552
+ e = await N(-1);
2544
2553
  }
2545
2554
  function se(e) {
2546
- return H(e).pathname;
2555
+ return U(e).pathname;
2547
2556
  }
2548
- const vt = 0, Y = 1, Z = 2;
2557
+ const yt = 0, Y = 1, Z = 2;
2549
2558
  class ne {
2550
2559
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2551
- c(this, "navigator"), c(this, "ee", new N()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
2560
+ c(this, "navigator"), c(this, "ee", new D()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
2552
2561
  if (o === null)
2553
2562
  return this.push(this.parsePath(window.location.href));
2554
- o === vt ? window.history.forward() : o === Y && this.back(), o === Z && this.forward();
2563
+ o === yt ? window.history.forward() : o === Y && this.back(), o === Z && this.forward();
2555
2564
  }), c(this, "onNavigatorChange", async ({
2556
2565
  to: o,
2557
2566
  from: a,
2558
- delta: u
2567
+ delta: p
2559
2568
  }) => {
2560
2569
  this.attached && await this.syncHistory(), this.ee.emit("change", {
2561
- delta: u,
2570
+ delta: p,
2562
2571
  from: F(a),
2563
2572
  to: F(o),
2564
2573
  navigator: this
@@ -2567,7 +2576,9 @@ class ne {
2567
2576
  t.map((o) => Q(o, "/")),
2568
2577
  s,
2569
2578
  n
2570
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = se(i || "");
2579
+ ), this.navigator.on("change", (o) => {
2580
+ this.onNavigatorChange(o);
2581
+ }), this.hashMode = r, this.base = se(i || "");
2571
2582
  }
2572
2583
  /**
2573
2584
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2665,7 +2676,7 @@ class ne {
2665
2676
  * "/pathname?search#hash"
2666
2677
  */
2667
2678
  get path() {
2668
- return U(this);
2679
+ return H(this);
2669
2680
  }
2670
2681
  /**
2671
2682
  * Current pathname. Always starts with the slash.
@@ -2694,8 +2705,8 @@ class ne {
2694
2705
  * // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
2695
2706
  */
2696
2707
  parsePath(t) {
2697
- let s = H(t);
2698
- return this.hashMode && (s = H(s.hash.slice(1))), {
2708
+ let s = U(t);
2709
+ return this.hashMode && (s = U(s.hash.slice(1))), {
2699
2710
  pathname: s.pathname,
2700
2711
  search: s.search,
2701
2712
  hash: s.hash
@@ -2715,7 +2726,7 @@ class ne {
2715
2726
  * @param value - path presented as string or URLLike.
2716
2727
  */
2717
2728
  renderPath(t) {
2718
- const s = (this.base.length === 1 ? "" : this.base) + M(U(t), "/");
2729
+ const s = (this.base.length === 1 ? "" : this.base) + M(H(t), "/");
2719
2730
  return this.hashMode ? M(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2720
2731
  }
2721
2732
  /**
@@ -2724,7 +2735,7 @@ class ne {
2724
2735
  async syncHistory() {
2725
2736
  window.removeEventListener("popstate", this.onPopState);
2726
2737
  const { state: t } = this, s = this.renderPath(this);
2727
- await Is(), this.hasPrev && this.hasNext ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s), window.history.pushState(Z, ""), await D(-1)) : this.hasPrev ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(Z, ""), await D(-1)) : (window.history.replaceState(vt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2738
+ await Is(), this.hasPrev && this.hasNext ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s), window.history.pushState(Z, ""), await N(-1)) : this.hasPrev ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(Z, ""), await N(-1)) : (window.history.replaceState(yt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2728
2739
  }
2729
2740
  /**
2730
2741
  * Current query parameters.
@@ -2745,7 +2756,7 @@ class ne {
2745
2756
  function ks(e) {
2746
2757
  e || (e = {});
2747
2758
  const { href: t, hash: s } = window.location;
2748
- let n = U(
2759
+ let n = H(
2749
2760
  e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
2750
2761
  );
2751
2762
  const r = e.base ? se(e.base) : void 0;
@@ -2769,7 +2780,11 @@ function qs(e, t) {
2769
2780
  if (s)
2770
2781
  try {
2771
2782
  const { index: n, history: r } = JSON.parse(s);
2772
- return new ne(r, n, t);
2783
+ return new ne(
2784
+ r,
2785
+ n,
2786
+ t
2787
+ );
2773
2788
  } catch (n) {
2774
2789
  console.error("Unable to restore hash navigator state.", n);
2775
2790
  }
@@ -2786,12 +2801,12 @@ function Cn(e, t) {
2786
2801
  function d(e, t) {
2787
2802
  function s(n) {
2788
2803
  return function(i, o, a) {
2789
- return (u) => {
2790
- const h = {
2791
- ...u,
2804
+ return (p) => {
2805
+ const u = {
2806
+ ...p,
2792
2807
  [i]: n(o)
2793
2808
  };
2794
- return /* @__PURE__ */ yt(a, { ...h });
2809
+ return /* @__PURE__ */ Et(a, { ...u });
2795
2810
  };
2796
2811
  };
2797
2812
  }
@@ -2806,7 +2821,7 @@ function Os() {
2806
2821
  }
2807
2822
  function _(e) {
2808
2823
  function t(n) {
2809
- const r = Os(), [i, o] = Et(
2824
+ const r = Os(), [i, o] = Pt(
2810
2825
  n ? void 0 : () => {
2811
2826
  if (Ss())
2812
2827
  throw new Error("Using hooks on the server side, you must explicitly specify ssr = true option");
@@ -2827,86 +2842,86 @@ function _(e) {
2827
2842
  }
2828
2843
  return [t, s];
2829
2844
  }
2830
- const [Ds, Ns] = _(Ge), [Sn, Tn] = d(
2831
- Ds,
2832
- Ns
2845
+ const [Ns, Ds] = _(Ge), [Sn, Tn] = d(
2846
+ Ns,
2847
+ Ds
2833
2848
  ), [Bs, Ms] = _(Ke), [An, In] = d(
2834
2849
  Bs,
2835
2850
  Ms
2836
- ), [Vs, $s] = _(Fe), [kn, qn] = d(
2851
+ ), [Vs, Ls] = _(Fe), [kn, qn] = d(
2837
2852
  Vs,
2838
- $s
2839
- ), [Ls, Hs] = _(ts), [On, Dn] = d(
2840
- Ls,
2841
- Hs
2842
- ), [Us, Ws] = _(ss), [Nn, Bn] = d(
2843
- Us,
2853
+ Ls
2854
+ ), [$s, Us] = _(ts), [On, Nn] = d(
2855
+ $s,
2856
+ Us
2857
+ ), [Hs, Ws] = _(ss), [Dn, Bn] = d(
2858
+ Hs,
2844
2859
  Ws
2845
- ), [Gs, js] = _(rs), [Mn, Vn] = d(Gs, js), [zs, Ks] = _(os), [$n, Ln] = d(zs, Ks), [Js, Fs] = _(cs), [Hn, Un] = d(Js, Fs), [Qs, Ys] = _(ls), [Wn, Gn] = d(Qs, Ys), [Zs, Xs] = _(ws), [jn, zn] = d(Zs, Xs), [tn, en] = _(fs), [Kn, Jn] = d(tn, en), [sn, nn] = _(bs), [Fn, Qn] = d(
2860
+ ), [Gs, js] = _(rs), [Mn, Vn] = d(Gs, js), [zs, Ks] = _(os), [Ln, $n] = d(zs, Ks), [Js, Fs] = _(cs), [Un, Hn] = d(Js, Fs), [Qs, Ys] = _(ls), [Wn, Gn] = d(Qs, Ys), [Zs, Xs] = _(ws), [jn, zn] = d(Zs, Xs), [tn, en] = _(fs), [Kn, Jn] = d(tn, en), [sn, nn] = _(bs), [Fn, Qn] = d(
2846
2861
  sn,
2847
2862
  nn
2848
2863
  ), [rn, on] = _(ys), [Yn, Zn] = d(rn, on);
2849
2864
  function Xn() {
2850
- return Pt(Qt, []);
2865
+ return Rt(Qt, []);
2851
2866
  }
2852
2867
  const [an, cn] = _(Ps), [tr, er] = d(an, cn), [hn, pn] = _(xs), [sr, nr] = d(hn, pn);
2853
2868
  function rr({ children: e, acceptCustomStyles: t, debug: s }) {
2854
- const n = gt(!0), [r, i] = Et(/* @__PURE__ */ new Map()), o = gt(r), a = ae(
2855
- (h) => {
2856
- n.current && i((v) => (h && h(v), new Map(v)));
2869
+ const n = ft(!0), [r, i] = Pt(/* @__PURE__ */ new Map()), o = ft(r), a = ae(
2870
+ (u) => {
2871
+ n.current && i((C) => (u && u(C), new Map(C)));
2857
2872
  },
2858
2873
  []
2859
- ), u = Pt(() => ({
2860
- use(h, ...v) {
2861
- const dt = r.get(h);
2862
- if (dt)
2863
- return dt;
2874
+ ), p = Rt(() => ({
2875
+ use(u, ...C) {
2876
+ const _t = r.get(u);
2877
+ if (_t)
2878
+ return _t;
2864
2879
  let b, K;
2865
2880
  try {
2866
- b = h(...v);
2881
+ b = u(...C);
2867
2882
  } catch (f) {
2868
2883
  K = f;
2869
2884
  }
2870
- function L(f) {
2871
- return r.set(h, f), f;
2885
+ function $(f) {
2886
+ return r.set(u, f), f;
2872
2887
  }
2873
2888
  if (K)
2874
- return L({ error: K });
2889
+ return $({ error: K });
2875
2890
  let I;
2876
2891
  if (Array.isArray(b) && (I = b[1], b = b[0]), !b)
2877
- return L({ result: b, cleanup: I });
2878
- function _t(f) {
2892
+ return $({ result: b, cleanup: I });
2893
+ function wt(f) {
2879
2894
  if ("on" in f) {
2880
- const k = f.on("change", () => a()), wt = I;
2895
+ const k = f.on("change", () => a()), gt = I;
2881
2896
  I = () => {
2882
- wt && wt(), k();
2897
+ gt && gt(), k();
2883
2898
  };
2884
2899
  }
2885
2900
  return { result: f, cleanup: I };
2886
2901
  }
2887
2902
  return b instanceof Promise ? (b.then(
2888
- (f) => a((k) => k.set(h, _t(f))),
2889
- (f) => a((k) => k.set(h, { error: f }))
2890
- ), L({})) : L(_t(b));
2903
+ (f) => a((k) => k.set(u, wt(f))),
2904
+ (f) => a((k) => k.set(u, { error: f }))
2905
+ ), $({})) : $(wt(b));
2891
2906
  }
2892
2907
  }), [r]);
2893
2908
  return S(() => (n.current = !0, () => {
2894
2909
  n.current = !1;
2895
2910
  }), []), S(() => {
2896
- if (ot())
2911
+ if (at())
2897
2912
  return Cs(t);
2898
2913
  }, [t]), S(() => {
2899
2914
  le(s || !1);
2900
2915
  }, [s]), S(() => {
2901
2916
  o.current = r;
2902
2917
  }, [r]), S(() => () => {
2903
- o.current.forEach((h) => {
2904
- "cleanup" in h && h.cleanup && h.cleanup();
2918
+ o.current.forEach((u) => {
2919
+ "cleanup" in u && u.cleanup && u.cleanup();
2905
2920
  });
2906
- }, []), /* @__PURE__ */ yt(re.Provider, { value: u, children: e });
2921
+ }, []), /* @__PURE__ */ Et(re.Provider, { value: p, children: e });
2907
2922
  }
2908
2923
  export {
2909
- De as BackButton,
2924
+ Ne as BackButton,
2910
2925
  As as BasicNavigator,
2911
2926
  je as BiometryManager,
2912
2927
  ne as BrowserNavigator,
@@ -2924,7 +2939,7 @@ export {
2924
2939
  me as ERR_TIMED_OUT,
2925
2940
  be as ERR_UNEXPECTED_TYPE,
2926
2941
  ge as ERR_UNKNOWN_ENV,
2927
- N as EventEmitter,
2942
+ D as EventEmitter,
2928
2943
  es as HapticFeedback,
2929
2944
  ns as InitData,
2930
2945
  is as Invoice,
@@ -2942,14 +2957,14 @@ export {
2942
2957
  bn as bindMiniAppCSSVars,
2943
2958
  vn as bindThemeParamsCSSVars,
2944
2959
  yn as bindViewportCSSVars,
2945
- P as boolean,
2946
- Nt as captureSameReq,
2960
+ E as boolean,
2961
+ Dt as captureSameReq,
2947
2962
  st as classNames,
2948
2963
  Ie as compareVersions,
2949
2964
  ks as createBrowserNavigatorFromLocation,
2950
2965
  qe as createPostEvent,
2951
- H as createSafeURL,
2952
- Lt as date,
2966
+ U as createSafeURL,
2967
+ $t as date,
2953
2968
  xn as getHash,
2954
2969
  se as getPathname,
2955
2970
  Ge as initBackButton,
@@ -2971,9 +2986,9 @@ export {
2971
2986
  Cs as initWeb,
2972
2987
  O as invokeCustomMethod,
2973
2988
  Vt as isColorDark,
2974
- ot as isIframe,
2989
+ at as isIframe,
2975
2990
  Yt as isPageReload,
2976
- it as isRGB,
2991
+ ot as isRGB,
2977
2992
  Pe as isRGBShort,
2978
2993
  Ts as isSDKError,
2979
2994
  Rn as isSDKErrorOfType,
@@ -2982,11 +2997,11 @@ export {
2982
2997
  w as json,
2983
2998
  gn as mergeClassNames,
2984
2999
  Pn as mockTelegramEnv,
2985
- x as number,
3000
+ R as number,
2986
3001
  z as off,
2987
- E as on,
3002
+ y as on,
2988
3003
  fn as parseInitData,
2989
- pt as parseLaunchParams,
3004
+ ut as parseLaunchParams,
2990
3005
  te as parseThemeParams,
2991
3006
  B as postEvent,
2992
3007
  g as request,
@@ -2995,29 +3010,29 @@ export {
2995
3010
  ee as requestViewport,
2996
3011
  Qt as retrieveLaunchParams,
2997
3012
  It as rgb,
2998
- ht as searchParams,
2999
- He as serializeLaunchParams,
3013
+ pt as searchParams,
3014
+ Ue as serializeLaunchParams,
3000
3015
  Jt as serializeThemeParams,
3001
- R as setCSSVar,
3016
+ P as setCSSVar,
3002
3017
  le as setDebug,
3003
3018
  wn as setTargetOrigin,
3004
- p as string,
3019
+ h as string,
3005
3020
  pe as subscribe,
3006
- C as supports,
3021
+ x as supports,
3007
3022
  ke as targetOrigin,
3008
3023
  At as toRGB,
3009
- xt as unsubscribe,
3010
- U as urlToPath,
3011
- Ns as useBackButton,
3012
- Ds as useBackButtonRaw,
3024
+ Ct as unsubscribe,
3025
+ H as urlToPath,
3026
+ Ds as useBackButton,
3027
+ Ns as useBackButtonRaw,
3013
3028
  Ms as useBiometryManager,
3014
3029
  Bs as useBiometryManagerRaw,
3015
- $s as useClosingBehavior,
3030
+ Ls as useClosingBehavior,
3016
3031
  Vs as useClosingBehaviorRaw,
3017
- Hs as useCloudStorage,
3018
- Ls as useCloudStorageRaw,
3032
+ Us as useCloudStorage,
3033
+ $s as useCloudStorageRaw,
3019
3034
  Ws as useHapticFeedback,
3020
- Us as useHapticFeedbackRaw,
3035
+ Hs as useHapticFeedbackRaw,
3021
3036
  js as useInitData,
3022
3037
  Gs as useInitDataRaw,
3023
3038
  Ks as useInvoice,
@@ -3046,16 +3061,16 @@ export {
3046
3061
  An as withBiometryManagerRaw,
3047
3062
  qn as withClosingBehavior,
3048
3063
  kn as withClosingBehaviorRaw,
3049
- Dn as withCloudStorage,
3064
+ Nn as withCloudStorage,
3050
3065
  On as withCloudStorageRaw,
3051
3066
  Bn as withHapticFeedback,
3052
- Nn as withHapticFeedbackRaw,
3067
+ Dn as withHapticFeedbackRaw,
3053
3068
  Vn as withInitData,
3054
3069
  Mn as withInitDataRaw,
3055
- Ln as withInvoice,
3056
- $n as withInvoiceRaw,
3057
- Un as withMainButton,
3058
- Hn as withMainButtonRaw,
3070
+ $n as withInvoice,
3071
+ Ln as withInvoiceRaw,
3072
+ Hn as withMainButton,
3073
+ Un as withMainButtonRaw,
3059
3074
  Gn as withMiniApp,
3060
3075
  Wn as withMiniAppRaw,
3061
3076
  zn as withPopup,