@tma.js/sdk-react 2.2.2 → 2.2.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 { 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";
1
+ import { jsx as Rt } from "react/jsx-runtime";
2
+ import { createContext as re, useContext as ie, useState as rt, useEffect as R, useRef as bt, useCallback as oe, useMemo 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
4
  function xt(e, t) {
5
5
  let s;
@@ -31,12 +31,12 @@ class ue {
31
31
  second: "2-digit",
32
32
  fractionalSecondDigits: 3,
33
33
  timeZone: "UTC"
34
- }).format(n), { textColor: i, bgColor: a } = this.options, o = "font-weight: bold;padding: 0 5px;border-radius:5px";
34
+ }).format(n), { textColor: i, bgColor: o } = this.options, a = "font-weight: bold;padding: 0 5px;border-radius:5px";
35
35
  console[t](
36
36
  `%c${r}%c / %c${this.scope}`,
37
- `${o};background-color: lightblue;color:black`,
37
+ `${a};background-color: lightblue;color:black`,
38
38
  "",
39
- `${o};${i ? `color:${i};` : ""}${a ? `background-color:${a}` : ""}`,
39
+ `${a};${i ? `color:${i};` : ""}${o ? `background-color:${o}` : ""}`,
40
40
  ...s
41
41
  );
42
42
  }
@@ -55,19 +55,19 @@ class ue {
55
55
  this.print("log", ...t);
56
56
  }
57
57
  }
58
- const nt = new ue("SDK", {
58
+ const it = new ue("SDK", {
59
59
  bgColor: "forestgreen",
60
60
  textColor: "white"
61
61
  });
62
62
  let X = !1;
63
- const mt = ({ name: e, payload: t }) => {
64
- nt.log("Event received:", t ? { name: e, payload: t } : { name: e });
63
+ const vt = ({ name: e, payload: t }) => {
64
+ it.log("Event received:", t ? { name: e, payload: t } : { name: e });
65
65
  };
66
66
  function le(e) {
67
- X !== e && (X = e, e ? pe(mt) : Ct(mt));
67
+ X !== e && (X = e, e ? pe(vt) : Ct(vt));
68
68
  }
69
69
  function de(...e) {
70
- X && nt.log(...e);
70
+ X && it.log(...e);
71
71
  }
72
72
  class D {
73
73
  constructor() {
@@ -142,7 +142,7 @@ class D {
142
142
  function tt(e, t, s) {
143
143
  return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
144
144
  }
145
- function rt(...e) {
145
+ function ot(...e) {
146
146
  let t = !1;
147
147
  const s = [...e];
148
148
  return [
@@ -210,23 +210,23 @@ function Tt(e, t) {
210
210
  const r = e[n];
211
211
  if (!r)
212
212
  continue;
213
- let i, a;
213
+ let i, o;
214
214
  if (typeof r == "function" || "parse" in r)
215
- i = n, a = typeof r == "function" ? r : r.parse.bind(r);
215
+ i = n, o = typeof r == "function" ? r : r.parse.bind(r);
216
216
  else {
217
- const { type: o } = r;
218
- i = r.from || n, a = typeof o == "function" ? o : o.parse.bind(o);
217
+ const { type: a } = r;
218
+ i = r.from || n, o = typeof a == "function" ? a : a.parse.bind(a);
219
219
  }
220
220
  try {
221
- const o = a(t(i));
222
- o !== void 0 && (s[n] = o);
223
- } catch (o) {
224
- throw m(St, `Unable to parse field "${n}"`, o);
221
+ const a = o(t(i));
222
+ a !== void 0 && (s[n] = a);
223
+ } catch (a) {
224
+ throw m(St, `Unable to parse field "${n}"`, a);
225
225
  }
226
226
  }
227
227
  return s;
228
228
  }
229
- function it(e) {
229
+ function at(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 it(e) {
234
234
  }
235
235
  function w(e, t) {
236
236
  return new G((s) => {
237
- const n = it(s);
237
+ const n = at(s);
238
238
  return Tt(e, (r) => n[r]);
239
239
  }, !1, t);
240
240
  }
241
- const R = A((e) => {
241
+ const x = A((e) => {
242
242
  if (typeof e == "number")
243
243
  return e;
244
244
  if (typeof e == "string") {
@@ -248,7 +248,7 @@ const R = A((e) => {
248
248
  }
249
249
  throw T();
250
250
  }, "number");
251
- function ot(e) {
251
+ function ct(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 (ot(t))
259
+ if (ct(t))
260
260
  return t;
261
261
  if (Pe(t)) {
262
262
  let n = "#";
@@ -337,12 +337,12 @@ const Ce = {
337
337
  theme_changed: w({
338
338
  theme_params: (e) => {
339
339
  const t = It().optional();
340
- return Object.entries(it(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
340
+ return Object.entries(at(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
341
341
  }
342
342
  }),
343
343
  viewport_changed: w({
344
- height: R(),
345
- width: (e) => e == null ? window.innerWidth : R().parse(e),
344
+ height: x(),
345
+ width: (e) => e == null ? window.innerWidth : x().parse(e),
346
346
  is_state_stable: E(),
347
347
  is_expanded: E()
348
348
  }),
@@ -353,7 +353,7 @@ function Se() {
353
353
  t.subscribe((n) => {
354
354
  e.emit("event", { name: n.event, payload: n.args[0] });
355
355
  }), xe();
356
- const [, s] = rt(
356
+ const [, s] = ot(
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.
@@ -380,12 +380,12 @@ function Se() {
380
380
  } catch {
381
381
  return;
382
382
  }
383
- const { eventType: i, eventData: a } = r, o = Ce[i];
383
+ const { eventType: i, eventData: o } = r, a = Ce[i];
384
384
  try {
385
- const p = o ? o.parse(a) : a;
385
+ const p = a ? a.parse(o) : o;
386
386
  t.emit(...p ? [i, p] : [i]);
387
387
  } catch (p) {
388
- nt.error(
388
+ it.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
391
  p
@@ -414,8 +414,8 @@ 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) => {
417
- const { count: a } = t;
418
- n(r, i), a && !t.count && e();
417
+ const { count: o } = t;
418
+ n(r, i), o && !t.count && e();
419
419
  }, [t, s];
420
420
  },
421
421
  ([, e]) => e()
@@ -435,16 +435,16 @@ function V(e) {
435
435
  function Ie(e, t) {
436
436
  const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
437
437
  for (let i = 0; i < r; i += 1) {
438
- const a = parseInt(s[i] || "0", 10), o = parseInt(n[i] || "0", 10);
439
- if (a !== o)
440
- return a > o ? 1 : -1;
438
+ const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
439
+ if (o !== a)
440
+ return o > a ? 1 : -1;
441
441
  }
442
442
  return 0;
443
443
  }
444
444
  function v(e, t) {
445
445
  return Ie(e, t) <= 0;
446
446
  }
447
- function x(e, t, s) {
447
+ function C(e, t, s) {
448
448
  if (typeof s == "string") {
449
449
  if (e === "web_app_open_link" && t === "try_instant_view")
450
450
  return v("6.4", s);
@@ -501,7 +501,7 @@ 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 at() {
504
+ function ht() {
505
505
  try {
506
506
  return window.self !== window.top;
507
507
  } catch {
@@ -519,7 +519,7 @@ 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 }), at()) {
522
+ if (de("Posting event:", r ? { event: e, data: r } : { event: e }), ht()) {
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 (!x(t, e))
541
+ if (!C(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 && !x(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 && !C(t, n, e))
546
546
  throw m(
547
547
  we,
548
548
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
@@ -569,17 +569,17 @@ function Mt(e, t) {
569
569
  }
570
570
  async function g(e) {
571
571
  let t;
572
- const s = new Promise((o) => {
573
- t = o;
574
- }), { event: n, capture: r, timeout: i } = e, [, a] = rt(
572
+ const s = new Promise((a) => {
573
+ t = a;
574
+ }), { event: n, capture: r, timeout: i } = e, [, o] = ot(
575
575
  ...(Array.isArray(n) ? n : [n]).map(
576
- (o) => y(o, (p) => (!r || r(p)) && t(p))
576
+ (a) => y(a, (p) => (!r || r(p)) && t(p))
577
577
  )
578
578
  );
579
579
  try {
580
580
  return (e.postEvent || B)(e.method, e.params), await (i ? Mt(s, i) : s);
581
581
  } finally {
582
- a();
582
+ o();
583
583
  }
584
584
  }
585
585
  async function O(e, t, s, n = {}) {
@@ -647,20 +647,20 @@ class Oe {
647
647
  return this.state[t];
648
648
  }
649
649
  }
650
- class ct {
650
+ class pt {
651
651
  constructor(t) {
652
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);
653
653
  }
654
654
  }
655
- function $t(e, t) {
656
- return (s) => x(t[s], e);
655
+ function Lt(e, t) {
656
+ return (s) => C(t[s], e);
657
657
  }
658
- class ht extends ct {
658
+ class ut extends pt {
659
659
  constructor(t, s, n) {
660
- super(t), c(this, "supports"), this.supports = $t(s, n);
660
+ super(t), c(this, "supports"), this.supports = Lt(s, n);
661
661
  }
662
662
  }
663
- class Ne extends ht {
663
+ class Ne extends ut {
664
664
  constructor(t, s, n) {
665
665
  super({ isVisible: t }, s, {
666
666
  show: "web_app_setup_back_button",
@@ -689,8 +689,8 @@ class Ne extends ht {
689
689
  this.isVisible = !0;
690
690
  }
691
691
  }
692
- const Lt = A((e) => e instanceof Date ? e : new Date(R().parse(e) * 1e3), "Date");
693
- function pt(e, t) {
692
+ const $t = A((e) => e instanceof Date ? e : new Date(x().parse(e) * 1e3), "Date");
693
+ function lt(e, t) {
694
694
  return new G((s) => {
695
695
  if (typeof s != "string" && !(s instanceof URLSearchParams))
696
696
  throw T();
@@ -702,7 +702,7 @@ function pt(e, t) {
702
702
  }, !1, t);
703
703
  }
704
704
  const De = w({
705
- id: R(),
705
+ id: x(),
706
706
  type: h(),
707
707
  title: h(),
708
708
  photoUrl: {
@@ -710,7 +710,7 @@ const De = w({
710
710
  from: "photo_url"
711
711
  },
712
712
  username: h().optional()
713
- }, "Chat").optional(), bt = w({
713
+ }, "Chat").optional(), yt = w({
714
714
  addedToAttachmentMenu: {
715
715
  type: E().optional(),
716
716
  from: "added_to_attachment_menu"
@@ -723,7 +723,7 @@ const De = w({
723
723
  type: h(),
724
724
  from: "first_name"
725
725
  },
726
- id: R(),
726
+ id: x(),
727
727
  isBot: {
728
728
  type: E().optional(),
729
729
  from: "is_bot"
@@ -746,14 +746,14 @@ const De = w({
746
746
  },
747
747
  username: h().optional()
748
748
  }, "User").optional();
749
- function Ht() {
750
- return pt({
749
+ function Ut() {
750
+ return lt({
751
751
  authDate: {
752
- type: Lt(),
752
+ type: $t(),
753
753
  from: "auth_date"
754
754
  },
755
755
  canSendAfter: {
756
- type: R().optional(),
756
+ type: x().optional(),
757
757
  from: "can_send_after"
758
758
  },
759
759
  chat: De,
@@ -770,12 +770,12 @@ function Ht() {
770
770
  type: h().optional(),
771
771
  from: "query_id"
772
772
  },
773
- receiver: bt,
773
+ receiver: yt,
774
774
  startParam: {
775
775
  type: h().optional(),
776
776
  from: "start_param"
777
777
  },
778
- user: bt
778
+ user: yt
779
779
  }, "InitData");
780
780
  }
781
781
  function Be(e) {
@@ -784,21 +784,21 @@ function Be(e) {
784
784
  function Me(e) {
785
785
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
786
786
  }
787
- const Ut = A(
787
+ const Ht = A(
788
788
  (e) => {
789
789
  const t = It().optional();
790
- return Object.entries(it(e)).reduce((s, [n, r]) => (s[Be(n)] = t.parse(r), s), {});
790
+ return Object.entries(at(e)).reduce((s, [n, r]) => (s[Be(n)] = t.parse(r), s), {});
791
791
  },
792
792
  "ThemeParams"
793
793
  );
794
- function ut(e) {
795
- return pt({
794
+ function dt(e) {
795
+ return lt({
796
796
  botInline: {
797
797
  type: E().optional(),
798
798
  from: "tgWebAppBotInline"
799
799
  },
800
800
  initData: {
801
- type: Ht().optional(),
801
+ type: Ut().optional(),
802
802
  from: "tgWebAppData"
803
803
  },
804
804
  initDataRaw: {
@@ -818,7 +818,7 @@ function ut(e) {
818
818
  from: "tgWebAppStartParam"
819
819
  },
820
820
  themeParams: {
821
- type: Ut(),
821
+ type: Ht(),
822
822
  from: "tgWebAppThemeParams"
823
823
  },
824
824
  version: {
@@ -828,7 +828,7 @@ function ut(e) {
828
828
  }).parse(e);
829
829
  }
830
830
  function Wt(e) {
831
- return ut(
831
+ return dt(
832
832
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
833
833
  );
834
834
  }
@@ -838,7 +838,7 @@ function Ve() {
838
838
  function Gt() {
839
839
  return performance.getEntriesByType("navigation")[0];
840
840
  }
841
- function $e() {
841
+ function Le() {
842
842
  const e = Gt();
843
843
  if (!e)
844
844
  throw new Error("Unable to get first navigation entry.");
@@ -857,8 +857,8 @@ function Kt(e) {
857
857
  } catch {
858
858
  }
859
859
  }
860
- function Le() {
861
- return ut(Kt("launchParams") || "");
860
+ function $e() {
861
+ return dt(Kt("launchParams") || "");
862
862
  }
863
863
  function Jt(e) {
864
864
  return JSON.stringify(
@@ -867,30 +867,30 @@ function Jt(e) {
867
867
  )
868
868
  );
869
869
  }
870
- function He(e) {
870
+ function Ue(e) {
871
871
  const {
872
872
  initDataRaw: t,
873
873
  themeParams: s,
874
874
  platform: n,
875
875
  version: r,
876
876
  showSettings: i,
877
- startParam: a,
878
- botInline: o
877
+ startParam: o,
878
+ botInline: a
879
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), a && p.set("tgWebAppStartParam", a), typeof i == "boolean" && p.set("tgWebAppShowSettings", i ? "1" : "0"), typeof o == "boolean" && p.set("tgWebAppBotInline", o ? "1" : "0"), p.toString();
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();
881
881
  }
882
882
  function Ft(e) {
883
- zt("launchParams", He(e));
883
+ zt("launchParams", Ue(e));
884
884
  }
885
- function Qt() {
885
+ function nt() {
886
886
  for (const e of [
887
887
  // Try to retrieve launch parameters from the current location. This method can return
888
888
  // nothing in case, location was changed and then page was reloaded.
889
889
  Ve,
890
890
  // Then, try using the lower level API - window.performance.
891
- $e,
891
+ Le,
892
892
  // Finally, try to extract launch parameters from the session storage.
893
- Le
893
+ $e
894
894
  ])
895
895
  try {
896
896
  const t = e();
@@ -899,38 +899,38 @@ function Qt() {
899
899
  }
900
900
  throw new Error("Unable to retrieve launch parameters from any known source.");
901
901
  }
902
- function Yt() {
902
+ function Qt() {
903
903
  const e = Gt();
904
904
  return !!(e && e.type === "reload");
905
905
  }
906
- function Ue() {
906
+ function He() {
907
907
  let e = 0;
908
908
  return () => (e += 1).toString();
909
909
  }
910
- const [We] = xt(Ue);
910
+ const [We] = xt(He);
911
911
  function l(e, t) {
912
912
  return () => {
913
- const s = Qt(), n = {
913
+ const s = nt(), n = {
914
914
  ...s,
915
915
  postEvent: qe(s.version),
916
916
  createRequestId: We()
917
917
  };
918
918
  if (typeof e == "function")
919
919
  return e(n);
920
- const [r, i, a] = rt(), o = t({
920
+ const [r, i, o] = ot(), a = t({
921
921
  ...n,
922
922
  // State should only be passed only in case, current page was reloaded. If we don't add
923
923
  // this check, state restoration will work improperly in the web version of Telegram,
924
924
  // when we are always working in the same "session" (tab).
925
- state: Yt() ? Kt(e) : void 0,
925
+ state: Qt() ? Kt(e) : void 0,
926
926
  addCleanup: r
927
- }), p = (u) => (a || r(
928
- u.on("change", (C) => {
929
- zt(e, C);
927
+ }), p = (u) => (o || r(
928
+ u.on("change", (S) => {
929
+ zt(e, S);
930
930
  })
931
931
  ), u);
932
932
  return [
933
- o instanceof Promise ? o.then(p) : p(o),
933
+ a instanceof Promise ? a.then(p) : p(a),
934
934
  i
935
935
  ];
936
936
  };
@@ -940,12 +940,12 @@ const Ge = l("backButton", ({
940
940
  version: t,
941
941
  state: s = { isVisible: !1 }
942
942
  }) => new Ne(s.isVisible, t, e));
943
- class $ extends ht {
943
+ class L extends ut {
944
944
  constructor() {
945
945
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
946
946
  }
947
947
  }
948
- function Zt(e) {
948
+ function Yt(e) {
949
949
  const t = e.available ? e : {
950
950
  available: !1,
951
951
  device_id: "",
@@ -963,7 +963,7 @@ function Zt(e) {
963
963
  accessGranted: t.access_granted
964
964
  };
965
965
  }
966
- class je extends $ {
966
+ class je extends L {
967
967
  constructor({ postEvent: t, version: s, ...n }) {
968
968
  super(n, s, {
969
969
  auth: "web_app_biometry_request_auth",
@@ -1041,7 +1041,7 @@ class je extends $ {
1041
1041
  event: "biometry_info_received",
1042
1042
  params: { reason: t || "" }
1043
1043
  }).then((n) => {
1044
- const r = Zt(n);
1044
+ const r = Yt(n);
1045
1045
  return this.set(r), r.accessGranted;
1046
1046
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1047
1047
  }
@@ -1074,7 +1074,7 @@ class je extends $ {
1074
1074
  }
1075
1075
  }
1076
1076
  async function ze(e) {
1077
- return Zt(
1077
+ return Yt(
1078
1078
  await g({
1079
1079
  ...e || {},
1080
1080
  method: "web_app_biometry_get_info",
@@ -1085,7 +1085,7 @@ async function ze(e) {
1085
1085
  const Ke = l(
1086
1086
  "biometryManager",
1087
1087
  async ({ postEvent: e, version: t, state: s }) => new je({
1088
- ...s || x("web_app_biometry_get_info", t) ? s || await ze({ timeout: 1e3 }) : {
1088
+ ...s || C("web_app_biometry_get_info", t) ? s || await ze({ timeout: 1e3 }) : {
1089
1089
  available: !1,
1090
1090
  accessGranted: !1,
1091
1091
  accessRequested: !1,
@@ -1096,12 +1096,12 @@ const Ke = l(
1096
1096
  postEvent: e
1097
1097
  })
1098
1098
  );
1099
- class lt extends ct {
1099
+ class _t extends pt {
1100
1100
  constructor() {
1101
1101
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
1102
1102
  }
1103
1103
  }
1104
- class Je extends lt {
1104
+ class Je extends _t {
1105
1105
  constructor(t, s) {
1106
1106
  super({ isConfirmationNeeded: t }), this.postEvent = s;
1107
1107
  }
@@ -1135,9 +1135,9 @@ const Fe = l(
1135
1135
  state: t = { isConfirmationNeeded: !1 }
1136
1136
  }) => new Je(t.isConfirmationNeeded, e)
1137
1137
  );
1138
- class dt {
1138
+ class wt {
1139
1139
  constructor(t, s) {
1140
- c(this, "supports"), this.supports = $t(t, s);
1140
+ c(this, "supports"), this.supports = Lt(t, s);
1141
1141
  }
1142
1142
  }
1143
1143
  function Qe(e) {
@@ -1173,10 +1173,10 @@ class Ye extends G {
1173
1173
  function Ze(e) {
1174
1174
  return new Ye((t) => t, !1, e);
1175
1175
  }
1176
- function vt(e, t) {
1176
+ function Et(e, t) {
1177
1177
  return Object.fromEntries(e.map((s) => [s, t]));
1178
1178
  }
1179
- class Xe extends dt {
1179
+ class Xe extends wt {
1180
1180
  constructor(t, s, n) {
1181
1181
  super(t, {
1182
1182
  delete: "web_app_invoke_custom_method",
@@ -1216,13 +1216,13 @@ class Xe extends dt {
1216
1216
  async get(t, s = {}) {
1217
1217
  const n = Array.isArray(t) ? t : [t];
1218
1218
  if (!n.length)
1219
- return vt(n, "");
1219
+ return Et(n, "");
1220
1220
  const r = await O(
1221
1221
  "getStorageValues",
1222
1222
  { keys: n },
1223
1223
  this.createRequestId(),
1224
1224
  { ...s, postEvent: this.postEvent }
1225
- ), i = w(vt(n, h()), "CloudStorageData").parse(r);
1225
+ ), i = w(Et(n, h()), "CloudStorageData").parse(r);
1226
1226
  return Array.isArray(t) ? i : i[t];
1227
1227
  }
1228
1228
  /**
@@ -1243,7 +1243,7 @@ class Xe extends dt {
1243
1243
  const ts = l(
1244
1244
  ({ createRequestId: e, postEvent: t, version: s }) => new Xe(s, e, t)
1245
1245
  );
1246
- class es extends dt {
1246
+ class es extends wt {
1247
1247
  constructor(t, s) {
1248
1248
  super(t, {
1249
1249
  impactOccurred: "web_app_trigger_haptic_feedback",
@@ -1365,9 +1365,9 @@ const rs = l(
1365
1365
  ({ initData: e }) => e ? new ns(e) : void 0
1366
1366
  );
1367
1367
  function fn(e) {
1368
- return Ht().parse(e);
1368
+ return Ut().parse(e);
1369
1369
  }
1370
- class is extends $ {
1370
+ class is extends L {
1371
1371
  constructor(t, s, n) {
1372
1372
  super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
1373
1373
  }
@@ -1390,10 +1390,10 @@ class is extends $ {
1390
1390
  const { hostname: r, pathname: i } = new URL(t, window.location.href);
1391
1391
  if (r !== "t.me")
1392
1392
  throw new Error(`Incorrect hostname: ${r}`);
1393
- const a = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1394
- if (!a)
1393
+ const o = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1394
+ if (!o)
1395
1395
  throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
1396
- [, , n] = a;
1396
+ [, , n] = o;
1397
1397
  }
1398
1398
  this.isOpened = !0;
1399
1399
  try {
@@ -1414,7 +1414,7 @@ class is extends $ {
1414
1414
  const os = l(
1415
1415
  ({ version: e, postEvent: t }) => new is(!1, e, t)
1416
1416
  );
1417
- class as extends ct {
1417
+ class as extends pt {
1418
1418
  constructor({ postEvent: t, ...s }) {
1419
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;
1420
1420
  }
@@ -1561,10 +1561,10 @@ const cs = l(
1561
1561
  }) => new as({ ...s, postEvent: e })
1562
1562
  );
1563
1563
  function hs() {
1564
- return pt({
1564
+ return lt({
1565
1565
  contact: w({
1566
1566
  userId: {
1567
- type: R(),
1567
+ type: x(),
1568
1568
  from: "user_id"
1569
1569
  },
1570
1570
  phoneNumber: {
@@ -1581,16 +1581,16 @@ function hs() {
1581
1581
  }
1582
1582
  }),
1583
1583
  authDate: {
1584
- type: Lt(),
1584
+ type: $t(),
1585
1585
  from: "auth_date"
1586
1586
  },
1587
1587
  hash: h()
1588
1588
  }, "RequestedContact");
1589
1589
  }
1590
- function Xt(e, t) {
1590
+ function Zt(e, t) {
1591
1591
  return (s) => {
1592
1592
  const [n, r] = t[s];
1593
- return x(n, r, e);
1593
+ return C(n, r, e);
1594
1594
  };
1595
1595
  }
1596
1596
  function ps(e) {
@@ -1598,7 +1598,7 @@ function ps(e) {
1598
1598
  setTimeout(t, e);
1599
1599
  });
1600
1600
  }
1601
- class us extends $ {
1601
+ class us extends L {
1602
1602
  constructor({ postEvent: t, createRequestId: s, version: n, botInline: r, ...i }) {
1603
1603
  super(i, n, {
1604
1604
  requestPhoneAccess: "web_app_request_phone",
@@ -1607,8 +1607,8 @@ class us extends $ {
1607
1607
  setHeaderColor: "web_app_set_header_color",
1608
1608
  setBackgroundColor: "web_app_set_background_color"
1609
1609
  }), 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;
1610
- const a = this.supports.bind(this);
1611
- this.supports = (o) => a(o) ? o !== "switchInlineQuery" || r : !1, this.supportsParam = Xt(n, {
1610
+ const o = this.supports.bind(this);
1611
+ this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Zt(n, {
1612
1612
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1613
1613
  });
1614
1614
  }
@@ -1751,7 +1751,7 @@ class us extends $ {
1751
1751
  * @param color - color key or RGB color.
1752
1752
  */
1753
1753
  setHeaderColor(t) {
1754
- this.postEvent("web_app_set_header_color", ot(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
1754
+ this.postEvent("web_app_set_header_color", ct(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
1755
1755
  }
1756
1756
  /**
1757
1757
  * Updates current Mini App background color.
@@ -1801,21 +1801,21 @@ function ds(e) {
1801
1801
  if (n.length > 3)
1802
1802
  throw new Error(`Buttons have incorrect size: ${n.length}`);
1803
1803
  return n.length ? r = n.map((i) => {
1804
- const { id: a = "" } = i;
1805
- if (a.length > 64)
1806
- throw new Error(`Button ID has incorrect size: ${a}`);
1804
+ const { id: o = "" } = i;
1805
+ if (o.length > 64)
1806
+ throw new Error(`Button ID has incorrect size: ${o}`);
1807
1807
  if (!i.type || i.type === "default" || i.type === "destructive") {
1808
- const o = i.text.trim();
1809
- if (!o.length || o.length > 64) {
1808
+ const a = i.text.trim();
1809
+ if (!a.length || a.length > 64) {
1810
1810
  const p = i.type || "default";
1811
1811
  throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
1812
1812
  }
1813
- return { ...i, text: o, id: a };
1813
+ return { ...i, text: a, id: o };
1814
1814
  }
1815
- return { ...i, id: a };
1815
+ return { ...i, id: o };
1816
1816
  }) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
1817
1817
  }
1818
- class _s extends $ {
1818
+ class _s extends L {
1819
1819
  constructor(t, s, n) {
1820
1820
  super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
1821
1821
  }
@@ -1859,7 +1859,7 @@ class _s extends $ {
1859
1859
  const ws = l(
1860
1860
  ({ postEvent: e, version: t }) => new _s(!1, t, e)
1861
1861
  );
1862
- class gs extends $ {
1862
+ class gs extends L {
1863
1863
  constructor(t, s, n) {
1864
1864
  super({ isOpened: t }, s, {
1865
1865
  close: "web_app_close_scan_qr_popup",
@@ -1905,7 +1905,7 @@ class gs extends $ {
1905
1905
  const fs = l(
1906
1906
  ({ version: e, postEvent: t }) => new gs(!1, e, t)
1907
1907
  );
1908
- class ms extends ht {
1908
+ class ms extends ut {
1909
1909
  constructor(t, s, n) {
1910
1910
  super({ isVisible: t }, s, {
1911
1911
  show: "web_app_setup_settings_button",
@@ -1942,10 +1942,10 @@ const bs = l(
1942
1942
  state: s = { isVisible: !1 }
1943
1943
  }) => new ms(s.isVisible, e, t)
1944
1944
  );
1945
- function te(e) {
1946
- return Ut().parse(e);
1945
+ function Xt(e) {
1946
+ return Ht().parse(e);
1947
1947
  }
1948
- class vs extends lt {
1948
+ class vs extends _t {
1949
1949
  /**
1950
1950
  * @since v6.10
1951
1951
  */
@@ -2010,7 +2010,7 @@ class vs extends lt {
2010
2010
  */
2011
2011
  listen() {
2012
2012
  return y("theme_changed", (t) => {
2013
- this.set(te(t.theme_params));
2013
+ this.set(Xt(t.theme_params));
2014
2014
  });
2015
2015
  }
2016
2016
  /**
@@ -2035,11 +2035,11 @@ function mn(e = {}) {
2035
2035
  ...e,
2036
2036
  method: "web_app_request_theme",
2037
2037
  event: "theme_changed"
2038
- }).then(te);
2038
+ }).then(Xt);
2039
2039
  }
2040
- class Es extends dt {
2040
+ class Es extends wt {
2041
2041
  constructor(t, s, n) {
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, {
2042
+ super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Zt(t, {
2043
2043
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2044
2044
  });
2045
2045
  }
@@ -2054,7 +2054,7 @@ class Es extends dt {
2054
2054
  */
2055
2055
  openLink(t, s) {
2056
2056
  const n = new URL(t, window.location.href).toString();
2057
- if (!x("web_app_open_link", this.version)) {
2057
+ if (!C("web_app_open_link", this.version)) {
2058
2058
  window.open(n, "_blank");
2059
2059
  return;
2060
2060
  }
@@ -2070,10 +2070,10 @@ class Es extends dt {
2070
2070
  * @throws {Error} URL has not allowed hostname.
2071
2071
  */
2072
2072
  openTelegramLink(t) {
2073
- 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");
2074
2074
  if (s !== "t.me")
2075
2075
  throw new Error(`URL has not allowed hostname: ${s}. Only "t.me" is allowed`);
2076
- if (!x("web_app_open_tg_link", this.version)) {
2076
+ if (!C("web_app_open_tg_link", this.version)) {
2077
2077
  window.location.href = t;
2078
2078
  return;
2079
2079
  }
@@ -2097,11 +2097,25 @@ class Es extends dt {
2097
2097
  });
2098
2098
  return s;
2099
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
+ }
2100
2114
  }
2101
2115
  const Ps = l(
2102
2116
  ({ version: e, postEvent: t, createRequestId: s }) => new Es(e, s, t)
2103
2117
  );
2104
- async function ee(e = {}) {
2118
+ async function te(e = {}) {
2105
2119
  const {
2106
2120
  is_expanded: t,
2107
2121
  is_state_stable: s,
@@ -2116,7 +2130,7 @@ async function ee(e = {}) {
2116
2130
  function q(e) {
2117
2131
  return e < 0 ? 0 : e;
2118
2132
  }
2119
- class Rs extends lt {
2133
+ class Rs extends _t {
2120
2134
  constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
2121
2135
  super({
2122
2136
  height: q(n),
@@ -2131,7 +2145,7 @@ class Rs extends lt {
2131
2145
  * @param options - options to request fresh data.
2132
2146
  */
2133
2147
  async sync(t) {
2134
- const { isStateStable: s, ...n } = await ee(t);
2148
+ const { isStateStable: s, ...n } = await te(t);
2135
2149
  this.set({
2136
2150
  ...n,
2137
2151
  stableHeight: s ? n.height : this.get("stableHeight")
@@ -2184,12 +2198,12 @@ class Rs extends lt {
2184
2198
  width: n,
2185
2199
  is_expanded: r,
2186
2200
  is_state_stable: i
2187
- } = t, a = q(s);
2201
+ } = t, o = q(s);
2188
2202
  this.set({
2189
- height: a,
2203
+ height: o,
2190
2204
  isExpanded: r,
2191
2205
  width: q(n),
2192
- ...i ? { stableHeight: a } : {}
2206
+ ...i ? { stableHeight: o } : {}
2193
2207
  });
2194
2208
  });
2195
2209
  }
@@ -2226,20 +2240,20 @@ class Rs extends lt {
2226
2240
  const xs = l(
2227
2241
  "viewport",
2228
2242
  async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
2229
- let r = !1, i = 0, a = 0, o = 0;
2243
+ let r = !1, i = 0, o = 0, a = 0;
2230
2244
  if (e)
2231
- r = e.isExpanded, i = e.height, a = e.width, o = e.stableHeight;
2245
+ r = e.isExpanded, i = e.height, o = e.width, a = e.stableHeight;
2232
2246
  else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2233
- r = !0, i = window.innerHeight, a = window.innerWidth, o = window.innerHeight;
2247
+ r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
2234
2248
  else {
2235
- const u = await ee({ timeout: 1e3, postEvent: s });
2236
- r = u.isExpanded, i = u.height, a = u.width, o = u.isStateStable ? i : 0;
2249
+ const u = await te({ timeout: 1e3, postEvent: s });
2250
+ r = u.isExpanded, i = u.height, o = u.width, a = u.isStateStable ? i : 0;
2237
2251
  }
2238
2252
  const p = new Rs({
2239
2253
  postEvent: s,
2240
2254
  height: i,
2241
- width: a,
2242
- stableHeight: o,
2255
+ width: o,
2256
+ stableHeight: a,
2243
2257
  isExpanded: r
2244
2258
  });
2245
2259
  return n(p.listen()), p;
@@ -2249,21 +2263,21 @@ function P(e, t) {
2249
2263
  document.documentElement.style.setProperty(e, t);
2250
2264
  }
2251
2265
  function bn(e, t, s) {
2252
- s || (s = (o) => `--tg-${o}-color`);
2266
+ s || (s = (a) => `--tg-${a}-color`);
2253
2267
  const n = s("header"), r = s("bg"), i = () => {
2254
- const { headerColor: o } = e;
2255
- if (ot(o))
2256
- P(n, o);
2268
+ const { headerColor: a } = e;
2269
+ if (ct(a))
2270
+ P(n, a);
2257
2271
  else {
2258
2272
  const { bgColor: p, secondaryBgColor: u } = t;
2259
- o === "bg_color" && p ? P(n, p) : o === "secondary_bg_color" && u && P(n, u);
2273
+ a === "bg_color" && p ? P(n, p) : a === "secondary_bg_color" && u && P(n, u);
2260
2274
  }
2261
2275
  P(r, e.bgColor);
2262
- }, a = [
2276
+ }, o = [
2263
2277
  t.on("change", i),
2264
2278
  e.on("change", i)
2265
2279
  ];
2266
- return i(), () => a.forEach((o) => o());
2280
+ return i(), () => o.forEach((a) => a());
2267
2281
  }
2268
2282
  function vn(e, t) {
2269
2283
  t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
@@ -2280,12 +2294,12 @@ function yn(e, t) {
2280
2294
  s,
2281
2295
  n,
2282
2296
  r
2283
- ] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => P(s, `${e.height}px`), a = () => P(n, `${e.width}px`), o = () => P(r, `${e.stableHeight}px`), p = [
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 = [
2284
2298
  e.on("change:height", i),
2285
- e.on("change:width", a),
2286
- e.on("change:stableHeight", o)
2299
+ e.on("change:width", o),
2300
+ e.on("change:stableHeight", a)
2287
2301
  ];
2288
- return i(), a(), o(), () => p.forEach((u) => u());
2302
+ return i(), o(), a(), () => p.forEach((u) => u());
2289
2303
  }
2290
2304
  function Cs(e = !0) {
2291
2305
  const t = [
@@ -2317,7 +2331,7 @@ async function En() {
2317
2331
  }
2318
2332
  }
2319
2333
  function Pn(e) {
2320
- const t = typeof e == "string" ? ut(e) : e;
2334
+ const t = typeof e == "string" ? dt(e) : e;
2321
2335
  Ft(t);
2322
2336
  function s(r) {
2323
2337
  if (typeof r == "string")
@@ -2334,7 +2348,7 @@ function Pn(e) {
2334
2348
  } catch {
2335
2349
  }
2336
2350
  }
2337
- if (at()) {
2351
+ if (ht()) {
2338
2352
  const r = window.parent.postMessage.bind(window.parent);
2339
2353
  window.parent.postMessage = (i) => {
2340
2354
  s(i), r(i);
@@ -2500,21 +2514,21 @@ function F({
2500
2514
  function M(e, t) {
2501
2515
  return e.startsWith(t) ? e : `${t}${e}`;
2502
2516
  }
2503
- function H(e) {
2517
+ function U(e) {
2504
2518
  return new URL(
2505
2519
  typeof e == "string" ? e : `${e.pathname || ""}${M(e.search || "", "?")}${M(e.hash || "", "#")}`,
2506
2520
  "http://a"
2507
2521
  );
2508
2522
  }
2509
- function U(e) {
2510
- 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);
2511
2525
  return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
2512
2526
  }
2513
2527
  function Q(e, t, s) {
2514
2528
  let n, r;
2515
- typeof e == "string" ? n = e : (n = U(e), s = e.state, r = e.id);
2516
- const { pathname: i, search: a, hash: o } = new URL(n, `http://a${M(t, "/")}`);
2517
- return { id: r, pathname: i, params: { hash: o, search: a, state: s } };
2529
+ typeof e == "string" ? n = e : (n = H(e), s = e.state, r = e.id);
2530
+ const { pathname: i, search: o, hash: a } = new URL(n, `http://a${M(t, "/")}`);
2531
+ return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
2518
2532
  }
2519
2533
  async function N(e) {
2520
2534
  return e === 0 ? !0 : Promise.race([
@@ -2537,32 +2551,34 @@ async function Is() {
2537
2551
  for (; e; )
2538
2552
  e = await N(-1);
2539
2553
  }
2540
- function se(e) {
2541
- return H(e).pathname;
2554
+ function ee(e) {
2555
+ return U(e).pathname;
2542
2556
  }
2543
- const yt = 0, Y = 1, Z = 2;
2544
- class ne {
2557
+ const Pt = 0, Y = 1, Z = 2;
2558
+ class se {
2545
2559
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2546
- c(this, "navigator"), c(this, "ee", new D()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: a }) => {
2547
- if (a === null)
2560
+ c(this, "navigator"), c(this, "ee", new D()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
2561
+ if (o === null)
2548
2562
  return this.push(this.parsePath(window.location.href));
2549
- a === yt ? window.history.forward() : a === Y && this.back(), a === Z && this.forward();
2563
+ o === Pt ? window.history.forward() : o === Y && this.back(), o === Z && this.forward();
2550
2564
  }), c(this, "onNavigatorChange", async ({
2551
- to: a,
2552
- from: o,
2565
+ to: o,
2566
+ from: a,
2553
2567
  delta: p
2554
2568
  }) => {
2555
2569
  this.attached && await this.syncHistory(), this.ee.emit("change", {
2556
2570
  delta: p,
2557
- from: F(o),
2558
- to: F(a),
2571
+ from: F(a),
2572
+ to: F(o),
2559
2573
  navigator: this
2560
2574
  });
2561
2575
  }), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new As(
2562
- t.map((a) => Q(a, "/")),
2576
+ t.map((o) => Q(o, "/")),
2563
2577
  s,
2564
2578
  n
2565
- ), 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 = ee(i || "");
2566
2582
  }
2567
2583
  /**
2568
2584
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2660,7 +2676,7 @@ class ne {
2660
2676
  * "/pathname?search#hash"
2661
2677
  */
2662
2678
  get path() {
2663
- return U(this);
2679
+ return H(this);
2664
2680
  }
2665
2681
  /**
2666
2682
  * Current pathname. Always starts with the slash.
@@ -2689,8 +2705,8 @@ class ne {
2689
2705
  * // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
2690
2706
  */
2691
2707
  parsePath(t) {
2692
- let s = H(t);
2693
- return this.hashMode && (s = H(s.hash.slice(1))), {
2708
+ let s = U(t);
2709
+ return this.hashMode && (s = U(s.hash.slice(1))), {
2694
2710
  pathname: s.pathname,
2695
2711
  search: s.search,
2696
2712
  hash: s.hash
@@ -2710,7 +2726,7 @@ class ne {
2710
2726
  * @param value - path presented as string or URLLike.
2711
2727
  */
2712
2728
  renderPath(t) {
2713
- const s = (this.base.length === 1 ? "" : this.base) + M(U(t), "/");
2729
+ const s = (this.base.length === 1 ? "" : this.base) + M(H(t), "/");
2714
2730
  return this.hashMode ? M(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2715
2731
  }
2716
2732
  /**
@@ -2719,7 +2735,7 @@ class ne {
2719
2735
  async syncHistory() {
2720
2736
  window.removeEventListener("popstate", this.onPopState);
2721
2737
  const { state: t } = this, s = this.renderPath(this);
2722
- 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);
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(Pt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2723
2739
  }
2724
2740
  /**
2725
2741
  * Current query parameters.
@@ -2740,10 +2756,10 @@ class ne {
2740
2756
  function ks(e) {
2741
2757
  e || (e = {});
2742
2758
  const { href: t, hash: s } = window.location;
2743
- let n = U(
2759
+ let n = H(
2744
2760
  e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
2745
2761
  );
2746
- const r = e.base ? se(e.base) : void 0;
2762
+ const r = e.base ? ee(e.base) : void 0;
2747
2763
  if (r) {
2748
2764
  if (!n.startsWith(r))
2749
2765
  throw m(
@@ -2752,19 +2768,23 @@ function ks(e) {
2752
2768
  );
2753
2769
  n = n.slice(r.length);
2754
2770
  }
2755
- return new ne([n], 0, e);
2771
+ return new se([n], 0, e);
2756
2772
  }
2757
2773
  function xn(e) {
2758
2774
  const t = e.match(/#(.+)/);
2759
2775
  return t ? t[1] : null;
2760
2776
  }
2761
2777
  function qs(e, t) {
2762
- if (Yt()) {
2778
+ if (Qt()) {
2763
2779
  const s = sessionStorage.getItem(e);
2764
2780
  if (s)
2765
2781
  try {
2766
2782
  const { index: n, history: r } = JSON.parse(s);
2767
- return new ne(r, n, t);
2783
+ return new se(
2784
+ r,
2785
+ n,
2786
+ t
2787
+ );
2768
2788
  } catch (n) {
2769
2789
  console.error("Unable to restore hash navigator state.", n);
2770
2790
  }
@@ -2780,36 +2800,36 @@ function Cn(e, t) {
2780
2800
  }
2781
2801
  function d(e, t) {
2782
2802
  function s(n) {
2783
- return function(i, a, o) {
2803
+ return function(i, o, a) {
2784
2804
  return (p) => {
2785
2805
  const u = {
2786
2806
  ...p,
2787
- [i]: n(a)
2807
+ [i]: n(o)
2788
2808
  };
2789
- return /* @__PURE__ */ Et(o, { ...u });
2809
+ return /* @__PURE__ */ Rt(a, { ...u });
2790
2810
  };
2791
2811
  };
2792
2812
  }
2793
2813
  return [s(e), s(t)];
2794
2814
  }
2795
- const re = ie(void 0);
2815
+ const ne = re(void 0);
2796
2816
  function Os() {
2797
- const e = oe(re);
2817
+ const e = ie(ne);
2798
2818
  if (!e)
2799
2819
  throw new Error("useSDK was used outside the SDKProvider.");
2800
2820
  return e;
2801
2821
  }
2802
2822
  function _(e) {
2803
2823
  function t(n) {
2804
- const r = Os(), [i, a] = Pt(
2824
+ const r = Os(), [i, o] = rt(
2805
2825
  n ? void 0 : () => {
2806
2826
  if (Ss())
2807
2827
  throw new Error("Using hooks on the server side, you must explicitly specify ssr = true option");
2808
2828
  return r.use(e);
2809
2829
  }
2810
2830
  );
2811
- return S(() => {
2812
- a(r.use(e));
2831
+ return R(() => {
2832
+ o(r.use(e));
2813
2833
  }, [r]), i;
2814
2834
  }
2815
2835
  function s(n) {
@@ -2828,83 +2848,86 @@ const [Ns, Ds] = _(Ge), [Sn, Tn] = d(
2828
2848
  ), [Bs, Ms] = _(Ke), [An, In] = d(
2829
2849
  Bs,
2830
2850
  Ms
2831
- ), [Vs, $s] = _(Fe), [kn, qn] = d(
2851
+ ), [Vs, Ls] = _(Fe), [kn, qn] = d(
2832
2852
  Vs,
2833
- $s
2834
- ), [Ls, Hs] = _(ts), [On, Nn] = d(
2835
- Ls,
2836
- Hs
2837
- ), [Us, Ws] = _(ss), [Dn, Bn] = d(
2838
- Us,
2853
+ Ls
2854
+ ), [$s, Us] = _(ts), [On, Nn] = d(
2855
+ $s,
2856
+ Us
2857
+ ), [Hs, Ws] = _(ss), [Dn, Bn] = d(
2858
+ Hs,
2839
2859
  Ws
2840
- ), [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(
2841
2861
  sn,
2842
2862
  nn
2843
2863
  ), [rn, on] = _(ys), [Yn, Zn] = d(rn, on);
2844
- function Xn() {
2845
- return Rt(Qt, []);
2864
+ function Xn(e) {
2865
+ const [t, s] = rt(() => e ? void 0 : nt());
2866
+ return R(() => {
2867
+ e && s(nt());
2868
+ }, []), t;
2846
2869
  }
2847
2870
  const [an, cn] = _(Ps), [tr, er] = d(an, cn), [hn, pn] = _(xs), [sr, nr] = d(hn, pn);
2848
2871
  function rr({ children: e, acceptCustomStyles: t, debug: s }) {
2849
- const n = ft(!0), [r, i] = Pt(/* @__PURE__ */ new Map()), a = ft(r), o = ae(
2872
+ const n = bt(!0), [r, i] = rt(/* @__PURE__ */ new Map()), o = bt(r), a = oe(
2850
2873
  (u) => {
2851
- n.current && i((C) => (u && u(C), new Map(C)));
2874
+ n.current && i((S) => (u && u(S), new Map(S)));
2852
2875
  },
2853
2876
  []
2854
- ), p = Rt(() => ({
2855
- use(u, ...C) {
2856
- const _t = r.get(u);
2857
- if (_t)
2858
- return _t;
2877
+ ), p = ae(() => ({
2878
+ use(u, ...S) {
2879
+ const gt = r.get(u);
2880
+ if (gt)
2881
+ return gt;
2859
2882
  let b, K;
2860
2883
  try {
2861
- b = u(...C);
2884
+ b = u(...S);
2862
2885
  } catch (f) {
2863
2886
  K = f;
2864
2887
  }
2865
- function L(f) {
2888
+ function $(f) {
2866
2889
  return r.set(u, f), f;
2867
2890
  }
2868
2891
  if (K)
2869
- return L({ error: K });
2892
+ return $({ error: K });
2870
2893
  let I;
2871
2894
  if (Array.isArray(b) && (I = b[1], b = b[0]), !b)
2872
- return L({ result: b, cleanup: I });
2873
- function wt(f) {
2895
+ return $({ result: b, cleanup: I });
2896
+ function ft(f) {
2874
2897
  if ("on" in f) {
2875
- const k = f.on("change", () => o()), gt = I;
2898
+ const k = f.on("change", () => a()), mt = I;
2876
2899
  I = () => {
2877
- gt && gt(), k();
2900
+ mt && mt(), k();
2878
2901
  };
2879
2902
  }
2880
2903
  return { result: f, cleanup: I };
2881
2904
  }
2882
2905
  return b instanceof Promise ? (b.then(
2883
- (f) => o((k) => k.set(u, wt(f))),
2884
- (f) => o((k) => k.set(u, { error: f }))
2885
- ), L({})) : L(wt(b));
2906
+ (f) => a((k) => k.set(u, ft(f))),
2907
+ (f) => a((k) => k.set(u, { error: f }))
2908
+ ), $({})) : $(ft(b));
2886
2909
  }
2887
2910
  }), [r]);
2888
- return S(() => (n.current = !0, () => {
2911
+ return R(() => (n.current = !0, () => {
2889
2912
  n.current = !1;
2890
- }), []), S(() => {
2891
- if (at())
2913
+ }), []), R(() => {
2914
+ if (ht())
2892
2915
  return Cs(t);
2893
- }, [t]), S(() => {
2916
+ }, [t]), R(() => {
2894
2917
  le(s || !1);
2895
- }, [s]), S(() => {
2896
- a.current = r;
2897
- }, [r]), S(() => () => {
2898
- a.current.forEach((u) => {
2918
+ }, [s]), R(() => {
2919
+ o.current = r;
2920
+ }, [r]), R(() => () => {
2921
+ o.current.forEach((u) => {
2899
2922
  "cleanup" in u && u.cleanup && u.cleanup();
2900
2923
  });
2901
- }, []), /* @__PURE__ */ Et(re.Provider, { value: p, children: e });
2924
+ }, []), /* @__PURE__ */ Rt(ne.Provider, { value: p, children: e });
2902
2925
  }
2903
2926
  export {
2904
2927
  Ne as BackButton,
2905
2928
  As as BasicNavigator,
2906
2929
  je as BiometryManager,
2907
- ne as BrowserNavigator,
2930
+ se as BrowserNavigator,
2908
2931
  Je as ClosingBehavior,
2909
2932
  Xe as CloudStorage,
2910
2933
  Ee as ERR_INVALID_PATH_BASE,
@@ -2943,10 +2966,10 @@ export {
2943
2966
  Ie as compareVersions,
2944
2967
  ks as createBrowserNavigatorFromLocation,
2945
2968
  qe as createPostEvent,
2946
- H as createSafeURL,
2947
- Lt as date,
2969
+ U as createSafeURL,
2970
+ $t as date,
2948
2971
  xn as getHash,
2949
- se as getPathname,
2972
+ ee as getPathname,
2950
2973
  Ge as initBackButton,
2951
2974
  Ke as initBiometryManager,
2952
2975
  Fe as initClosingBehavior,
@@ -2966,9 +2989,9 @@ export {
2966
2989
  Cs as initWeb,
2967
2990
  O as invokeCustomMethod,
2968
2991
  Vt as isColorDark,
2969
- at as isIframe,
2970
- Yt as isPageReload,
2971
- ot as isRGB,
2992
+ ht as isIframe,
2993
+ Qt as isPageReload,
2994
+ ct as isRGB,
2972
2995
  Pe as isRGBShort,
2973
2996
  Ts as isSDKError,
2974
2997
  Rn as isSDKErrorOfType,
@@ -2977,42 +3000,42 @@ export {
2977
3000
  w as json,
2978
3001
  gn as mergeClassNames,
2979
3002
  Pn as mockTelegramEnv,
2980
- R as number,
3003
+ x as number,
2981
3004
  z as off,
2982
3005
  y as on,
2983
3006
  fn as parseInitData,
2984
- ut as parseLaunchParams,
2985
- te as parseThemeParams,
3007
+ dt as parseLaunchParams,
3008
+ Xt as parseThemeParams,
2986
3009
  B as postEvent,
2987
3010
  g as request,
2988
3011
  ze as requestBiometryInfo,
2989
3012
  mn as requestThemeParams,
2990
- ee as requestViewport,
2991
- Qt as retrieveLaunchParams,
3013
+ te as requestViewport,
3014
+ nt as retrieveLaunchParams,
2992
3015
  It as rgb,
2993
- pt as searchParams,
2994
- He as serializeLaunchParams,
3016
+ lt as searchParams,
3017
+ Ue as serializeLaunchParams,
2995
3018
  Jt as serializeThemeParams,
2996
3019
  P as setCSSVar,
2997
3020
  le as setDebug,
2998
3021
  wn as setTargetOrigin,
2999
3022
  h as string,
3000
3023
  pe as subscribe,
3001
- x as supports,
3024
+ C as supports,
3002
3025
  ke as targetOrigin,
3003
3026
  At as toRGB,
3004
3027
  Ct as unsubscribe,
3005
- U as urlToPath,
3028
+ H as urlToPath,
3006
3029
  Ds as useBackButton,
3007
3030
  Ns as useBackButtonRaw,
3008
3031
  Ms as useBiometryManager,
3009
3032
  Bs as useBiometryManagerRaw,
3010
- $s as useClosingBehavior,
3033
+ Ls as useClosingBehavior,
3011
3034
  Vs as useClosingBehaviorRaw,
3012
- Hs as useCloudStorage,
3013
- Ls as useCloudStorageRaw,
3035
+ Us as useCloudStorage,
3036
+ $s as useCloudStorageRaw,
3014
3037
  Ws as useHapticFeedback,
3015
- Us as useHapticFeedbackRaw,
3038
+ Hs as useHapticFeedbackRaw,
3016
3039
  js as useInitData,
3017
3040
  Gs as useInitDataRaw,
3018
3041
  Ks as useInvoice,
@@ -3047,10 +3070,10 @@ export {
3047
3070
  Dn as withHapticFeedbackRaw,
3048
3071
  Vn as withInitData,
3049
3072
  Mn as withInitDataRaw,
3050
- Ln as withInvoice,
3051
- $n as withInvoiceRaw,
3052
- Un as withMainButton,
3053
- Hn as withMainButtonRaw,
3073
+ $n as withInvoice,
3074
+ Ln as withInvoiceRaw,
3075
+ Hn as withMainButton,
3076
+ Un as withMainButtonRaw,
3054
3077
  Gn as withMiniApp,
3055
3078
  Wn as withMiniAppRaw,
3056
3079
  zn as withPopup,