@tma.js/sdk-react 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx as vt } from "react/jsx-runtime";
2
- import { createContext as Xt, useContext as te, useMemo as st, useRef as lt, useState as ee, useCallback as _t, useEffect as M } from "react";
3
- var se = Object.defineProperty, ne = (e, t, s) => t in e ? se(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (ne(e, typeof t != "symbol" ? t + "" : t, s), s);
2
+ import { createContext as te, useContext as ee, useMemo as st, useRef as lt, useState as se, useCallback as _t, useEffect as M } from "react";
3
+ var ne = Object.defineProperty, re = (e, t, s) => t in e ? ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (re(e, typeof t != "symbol" ? t + "" : t, s), s);
4
4
  function yt(e, t) {
5
5
  let s;
6
6
  const n = () => {
@@ -10,12 +10,12 @@ function yt(e, t) {
10
10
  }
11
11
  function Et(e) {
12
12
  const t = G(), { count: s } = t;
13
- t.unsubscribe(e), s && !t.count && Ce();
13
+ t.unsubscribe(e), s && !t.count && Te();
14
14
  }
15
- function re(e) {
15
+ function ie(e) {
16
16
  return G().subscribe(e), () => Et(e);
17
17
  }
18
- class ie {
18
+ class oe {
19
19
  constructor(t, s = {}) {
20
20
  this.scope = t, this.options = s;
21
21
  }
@@ -55,7 +55,7 @@ class ie {
55
55
  this.print("log", ...t);
56
56
  }
57
57
  }
58
- const H = new ie("SDK", {
58
+ const H = new oe("SDK", {
59
59
  bgColor: "forestgreen",
60
60
  textColor: "white"
61
61
  });
@@ -63,10 +63,10 @@ let X = !1;
63
63
  const gt = ({ event: e, args: [t] }) => {
64
64
  H.log("Event received:", t === void 0 ? { name: e } : { name: e, data: t });
65
65
  };
66
- function oe(e) {
67
- X !== e && (X = e, e ? re(gt) : Et(gt));
66
+ function ae(e) {
67
+ X !== e && (X = e, e ? ie(gt) : Et(gt));
68
68
  }
69
- function ae(...e) {
69
+ function ce(...e) {
70
70
  X && H.log(...e);
71
71
  }
72
72
  class U {
@@ -150,9 +150,9 @@ class W extends Error {
150
150
  function l(e, t, s) {
151
151
  return new W(e, t, s);
152
152
  }
153
- const ce = "ERR_METHOD_UNSUPPORTED", he = "ERR_METHOD_PARAMETER_UNSUPPORTED", pe = "ERR_UNKNOWN_ENV", ue = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", de = "ERR_TIMED_OUT", le = "ERR_UNEXPECTED_TYPE", Pt = "ERR_PARSE", _e = "ERR_NAVIGATION_LIST_EMPTY", ge = "ERR_NAVIGATION_CURSOR_INVALID", _n = "ERR_NAVIGATION_ITEM_INVALID", nt = "ERR_SSR_INIT", we = "ERR_SSR_POST_EVENT", fe = "ERR_INVALID_PATH_BASE";
153
+ const he = "ERR_METHOD_UNSUPPORTED", pe = "ERR_METHOD_PARAMETER_UNSUPPORTED", ue = "ERR_UNKNOWN_ENV", de = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", le = "ERR_TIMED_OUT", _e = "ERR_UNEXPECTED_TYPE", Pt = "ERR_PARSE", ge = "ERR_NAVIGATION_LIST_EMPTY", we = "ERR_NAVIGATION_CURSOR_INVALID", _n = "ERR_NAVIGATION_ITEM_INVALID", nt = "ERR_SSR_INIT", fe = "ERR_SSR_POST_EVENT", me = "ERR_INVALID_PATH_BASE";
154
154
  function T() {
155
- return l(le, "Value has unexpected type");
155
+ return l(_e, "Value has unexpected type");
156
156
  }
157
157
  class j {
158
158
  constructor(t, s, n) {
@@ -240,14 +240,14 @@ const x = A((e) => {
240
240
  function it(e) {
241
241
  return /^#[\da-f]{6}$/i.test(e);
242
242
  }
243
- function me(e) {
243
+ function be(e) {
244
244
  return /^#[\da-f]{3}$/i.test(e);
245
245
  }
246
246
  function xt(e) {
247
247
  const t = e.replace(/\s/g, "").toLowerCase();
248
248
  if (it(t))
249
249
  return t;
250
- if (me(t)) {
250
+ if (be(t)) {
251
251
  let n = "#";
252
252
  for (let r = 0; r < 3; r += 1)
253
253
  n += t[1 + r].repeat(2);
@@ -266,25 +266,25 @@ const h = A((e) => {
266
266
  return e.toString();
267
267
  throw T();
268
268
  }, "string"), St = A((e) => xt(h().parse(e)), "rgb");
269
- function be(e) {
269
+ function ve(e) {
270
270
  return f({
271
271
  eventType: h(),
272
272
  eventData: (t) => t
273
273
  }).parse(e);
274
274
  }
275
- function ve() {
275
+ function ye() {
276
276
  ["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
277
277
  delete window[e];
278
278
  });
279
279
  }
280
- function ye(e, t) {
280
+ function Ee(e, t) {
281
281
  window.dispatchEvent(new MessageEvent("message", {
282
282
  data: JSON.stringify({ eventType: e, eventData: t }),
283
283
  // We specify window.parent to imitate the case, the parent iframe sent us this event.
284
284
  source: window.parent
285
285
  }));
286
286
  }
287
- function Ee() {
287
+ function Pe() {
288
288
  [
289
289
  ["TelegramGameProxy_receiveEvent"],
290
290
  // Windows Phone.
@@ -296,16 +296,16 @@ function Ee() {
296
296
  let t = window;
297
297
  e.forEach((s, n, r) => {
298
298
  if (n === r.length - 1) {
299
- t[s] = ye;
299
+ t[s] = Ee;
300
300
  return;
301
301
  }
302
302
  s in t || (t[s] = {}), t = t[s];
303
303
  });
304
304
  });
305
305
  }
306
- const Pe = f({
306
+ const Re = f({
307
307
  button_id: (e) => e == null ? void 0 : h().parse(e)
308
- }), Re = {
308
+ }), xe = {
309
309
  clipboard_text_received: f({
310
310
  req_id: h(),
311
311
  data: (e) => e === null ? e : h().optional().parse(e)
@@ -323,7 +323,7 @@ const Pe = f({
323
323
  status: h()
324
324
  }),
325
325
  popup_closed: {
326
- parse: (e) => Pe.parse(e ?? {})
326
+ parse: (e) => Re.parse(e ?? {})
327
327
  },
328
328
  qr_text_received: f({
329
329
  data: h().optional()
@@ -344,12 +344,12 @@ const Pe = f({
344
344
  status: h()
345
345
  })
346
346
  };
347
- function xe() {
347
+ function Se() {
348
348
  const e = new U();
349
- Ee();
349
+ Pe();
350
350
  let t = [
351
351
  // Don't forget to remove created handlers.
352
- ve,
352
+ ye,
353
353
  // Add "resize" event listener to make sure, we always have fresh viewport information.
354
354
  // Desktop version of Telegram is sometimes not sending the viewport_changed
355
355
  // event. For example, when the MainButton is shown. That's why we should
@@ -370,11 +370,11 @@ function xe() {
370
370
  return;
371
371
  let n;
372
372
  try {
373
- n = be(s.data);
373
+ n = ve(s.data);
374
374
  } catch {
375
375
  return;
376
376
  }
377
- const { eventType: r, eventData: i } = n, o = Re[r];
377
+ const { eventType: r, eventData: i } = n, o = xe[r];
378
378
  try {
379
379
  const a = o ? o.parse(i) : i;
380
380
  e.emit(...a ? [r, a] : [r]);
@@ -393,9 +393,9 @@ function xe() {
393
393
  t.forEach((s) => s()), t = [];
394
394
  }];
395
395
  }
396
- const [Se, Ce] = yt(
396
+ const [Ce, Te] = yt(
397
397
  (e) => {
398
- const [t, s] = xe(), n = t.off.bind(t);
398
+ const [t, s] = Se(), n = t.off.bind(t);
399
399
  return t.off = (r, i) => {
400
400
  const { count: o } = t;
401
401
  n(r, i), o && !t.count && e();
@@ -404,7 +404,7 @@ const [Se, Ce] = yt(
404
404
  ([, e]) => e()
405
405
  );
406
406
  function G() {
407
- return Se()[0];
407
+ return Ce()[0];
408
408
  }
409
409
  function z(e, t) {
410
410
  G().off(e, t);
@@ -415,7 +415,7 @@ function E(e, t, s) {
415
415
  function D(e) {
416
416
  return typeof e == "object" && e !== null && !Array.isArray(e);
417
417
  }
418
- function Te(e, t) {
418
+ function Ae(e, t) {
419
419
  const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
420
420
  for (let i = 0; i < r; i += 1) {
421
421
  const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
@@ -425,7 +425,7 @@ function Te(e, t) {
425
425
  return 0;
426
426
  }
427
427
  function y(e, t) {
428
- return Te(e, t) <= 0;
428
+ return Ae(e, t) <= 0;
429
429
  }
430
430
  function S(e, t, s) {
431
431
  if (typeof s == "string") {
@@ -478,74 +478,74 @@ function S(e, t, s) {
478
478
  ].includes(e);
479
479
  }
480
480
  }
481
- function Ae(e) {
481
+ function ke(e) {
482
482
  return "external" in e && D(e.external) && "notify" in e.external && typeof e.external.notify == "function";
483
483
  }
484
- function ke(e) {
484
+ function Ct(e) {
485
485
  return "TelegramWebviewProxy" in e && D(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
486
486
  }
487
- function Ct() {
487
+ function Tt() {
488
488
  try {
489
489
  return window.self !== window.top;
490
490
  } catch {
491
491
  return !0;
492
492
  }
493
493
  }
494
- let Tt = "https://web.telegram.org";
494
+ let At = "https://web.telegram.org";
495
495
  function gn(e) {
496
- Tt = e;
496
+ At = e;
497
497
  }
498
498
  function Ie() {
499
- return Tt;
499
+ return At;
500
500
  }
501
501
  function q(e, t, s) {
502
502
  let n = {}, r;
503
503
  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);
504
504
  const { targetOrigin: i = Ie() } = n;
505
- if (ae("Posting event:", r ? { event: e, data: r } : { event: e }), Ct()) {
505
+ if (ce("Posting event:", r ? { event: e, data: r } : { event: e }), Tt()) {
506
506
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
507
507
  return;
508
508
  }
509
- if (Ae(window)) {
509
+ if (ke(window)) {
510
510
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
511
511
  return;
512
512
  }
513
- if (ke(window)) {
513
+ if (Ct(window)) {
514
514
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
515
515
  return;
516
516
  }
517
517
  throw l(
518
- pe,
518
+ ue,
519
519
  "Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside of Telegram application environment."
520
520
  );
521
521
  }
522
522
  function Oe(e) {
523
523
  return (t, s) => {
524
524
  if (!S(t, e))
525
- throw l(ce, `Method "${t}" is unsupported in Mini Apps version ${e}`);
525
+ throw l(he, `Method "${t}" is unsupported in Mini Apps version ${e}`);
526
526
  if (D(s)) {
527
527
  let n;
528
528
  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 && !S(t, n, e))
529
529
  throw l(
530
- he,
530
+ pe,
531
531
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
532
532
  );
533
533
  }
534
534
  return q(t, s);
535
535
  };
536
536
  }
537
- function At(e) {
537
+ function kt(e) {
538
538
  return ({ req_id: t }) => t === e;
539
539
  }
540
- function kt(e) {
541
- return l(de, `Timeout reached: ${e}ms`);
540
+ function It(e) {
541
+ return l(le, `Timeout reached: ${e}ms`);
542
542
  }
543
- function It(e, t) {
543
+ function Ot(e, t) {
544
544
  return Promise.race([
545
545
  typeof e == "function" ? e() : e,
546
546
  new Promise((s, n) => {
547
547
  setTimeout(() => {
548
- n(kt(t));
548
+ n(It(t));
549
549
  }, t);
550
550
  })
551
551
  ]);
@@ -564,7 +564,7 @@ async function m(e) {
564
564
  (u) => E(u, (d) => (!i || i(d)) && t(d))
565
565
  );
566
566
  try {
567
- return o(n, e.params), await (a ? It(s, a) : s);
567
+ return o(n, e.params), await (a ? Ot(s, a) : s);
568
568
  } finally {
569
569
  p.forEach((u) => u());
570
570
  }
@@ -582,10 +582,10 @@ async function I(e, t, s, n = {}) {
582
582
  params: t,
583
583
  req_id: s
584
584
  },
585
- capture: At(s)
585
+ capture: kt(s)
586
586
  });
587
587
  if (i)
588
- throw l(ue, i);
588
+ throw l(de, i);
589
589
  return r;
590
590
  }
591
591
  function et(...e) {
@@ -604,7 +604,7 @@ function wn(...e) {
604
604
  i.length && (t[n] = i);
605
605
  }), t), {});
606
606
  }
607
- function Ot(e) {
607
+ function qt(e) {
608
608
  const t = xt(e);
609
609
  return Math.sqrt(
610
610
  [0.299, 0.587, 0.114].reduce((s, n, r) => {
@@ -639,12 +639,12 @@ class ot {
639
639
  c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new qe(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);
640
640
  }
641
641
  }
642
- function qt(e, t) {
642
+ function Nt(e, t) {
643
643
  return (s) => S(t[s], e);
644
644
  }
645
645
  class at extends ot {
646
646
  constructor(t, s, n) {
647
- super(t), c(this, "supports"), this.supports = qt(s, n);
647
+ super(t), c(this, "supports"), this.supports = Nt(s, n);
648
648
  }
649
649
  }
650
650
  class Ne extends at {
@@ -679,7 +679,7 @@ class Ne extends at {
679
679
  function C() {
680
680
  return typeof window > "u";
681
681
  }
682
- const Nt = A((e) => e instanceof Date ? e : new Date(x().parse(e) * 1e3), "Date");
682
+ const Dt = A((e) => e instanceof Date ? e : new Date(x().parse(e) * 1e3), "Date");
683
683
  function ct(e, t) {
684
684
  return new j((s) => {
685
685
  if (typeof s != "string" && !(s instanceof URLSearchParams))
@@ -736,10 +736,10 @@ const De = f({
736
736
  },
737
737
  username: h().optional()
738
738
  }, "User").optional();
739
- function Dt() {
739
+ function Vt() {
740
740
  return ct({
741
741
  authDate: {
742
- type: Nt(),
742
+ type: Dt(),
743
743
  from: "auth_date"
744
744
  },
745
745
  canSendAfter: {
@@ -774,21 +774,21 @@ function Ve(e) {
774
774
  function Be(e) {
775
775
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
776
776
  }
777
- const Vt = A(
777
+ const Bt = A(
778
778
  (e) => {
779
779
  const t = St().optional();
780
780
  return Object.entries(rt(e)).reduce((s, [n, r]) => (s[Ve(n)] = t.parse(r), s), {});
781
781
  },
782
782
  "ThemeParams"
783
783
  );
784
- function Bt(e) {
784
+ function Mt(e) {
785
785
  return ct({
786
786
  botInline: {
787
787
  type: P().optional(),
788
788
  from: "tgWebAppBotInline"
789
789
  },
790
790
  initData: {
791
- type: Dt().optional(),
791
+ type: Vt().optional(),
792
792
  from: "tgWebAppData"
793
793
  },
794
794
  initDataRaw: {
@@ -808,7 +808,7 @@ function Bt(e) {
808
808
  from: "tgWebAppStartParam"
809
809
  },
810
810
  themeParams: {
811
- type: Vt(),
811
+ type: Bt(),
812
812
  from: "tgWebAppThemeParams"
813
813
  },
814
814
  version: {
@@ -817,38 +817,38 @@ function Bt(e) {
817
817
  }
818
818
  }).parse(e);
819
819
  }
820
- function Mt(e) {
821
- return Bt(
820
+ function $t(e) {
821
+ return Mt(
822
822
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
823
823
  );
824
824
  }
825
825
  function Me() {
826
- return Mt(window.location.href);
826
+ return $t(window.location.href);
827
827
  }
828
- function $t() {
828
+ function Lt() {
829
829
  return performance.getEntriesByType("navigation")[0];
830
830
  }
831
831
  function $e() {
832
- const e = $t();
832
+ const e = Lt();
833
833
  if (!e)
834
834
  throw new Error("Unable to get first navigation entry.");
835
- return Mt(e.name);
835
+ return $t(e.name);
836
836
  }
837
- function Lt(e) {
837
+ function Ht(e) {
838
838
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
839
839
  }
840
- function Ht(e, t) {
841
- sessionStorage.setItem(Lt(e), JSON.stringify(t));
840
+ function Ut(e, t) {
841
+ sessionStorage.setItem(Ht(e), JSON.stringify(t));
842
842
  }
843
- function Ut(e) {
844
- const t = sessionStorage.getItem(Lt(e));
843
+ function Wt(e) {
844
+ const t = sessionStorage.getItem(Ht(e));
845
845
  try {
846
846
  return t ? JSON.parse(t) : void 0;
847
847
  } catch {
848
848
  }
849
849
  }
850
850
  function Le() {
851
- return Bt(Ut("launchParams") || "");
851
+ return Mt(Wt("launchParams") || "");
852
852
  }
853
853
  function He(e) {
854
854
  return JSON.stringify(
@@ -870,9 +870,9 @@ function Ue(e) {
870
870
  return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", He(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();
871
871
  }
872
872
  function We(e) {
873
- Ht("launchParams", Ue(e));
873
+ Ut("launchParams", Ue(e));
874
874
  }
875
- function Wt() {
875
+ function jt() {
876
876
  for (const e of [
877
877
  // Try to retrieve launch parameters from the current location. This method can return
878
878
  // nothing in case, location was changed and then page was reloaded.
@@ -889,8 +889,8 @@ function Wt() {
889
889
  }
890
890
  throw new Error("Unable to retrieve launch parameters from any known source.");
891
891
  }
892
- function jt() {
893
- const e = $t();
892
+ function Gt() {
893
+ const e = Lt();
894
894
  return !!(e && e.type === "reload");
895
895
  }
896
896
  function je() {
@@ -909,12 +909,12 @@ function _(e, t) {
909
909
  );
910
910
  n = s;
911
911
  } else
912
- n = Wt();
912
+ n = jt();
913
913
  const r = {
914
914
  ...n,
915
915
  postEvent: "version" in n ? Oe(n.version) : () => {
916
916
  throw l(
917
- we,
917
+ fe,
918
918
  "postEvent function is forbidden to be called on the server side."
919
919
  );
920
920
  },
@@ -924,9 +924,9 @@ function _(e, t) {
924
924
  return typeof e == "function" ? e(r) : t(r);
925
925
  const i = t({
926
926
  ...r,
927
- state: jt() ? Ut(e) : void 0
927
+ state: Gt() ? Wt(e) : void 0
928
928
  }), o = (a) => (a.on("change", (p) => {
929
- Ht(e, p);
929
+ Ut(e, p);
930
930
  }), a);
931
931
  return i instanceof Promise ? i.then(o) : o(i);
932
932
  };
@@ -941,7 +941,7 @@ class V extends at {
941
941
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
942
942
  }
943
943
  }
944
- function Gt(e) {
944
+ function zt(e) {
945
945
  const t = e.available ? e : {
946
946
  available: !1,
947
947
  device_id: "",
@@ -1037,7 +1037,7 @@ class ft extends V {
1037
1037
  event: "biometry_info_received",
1038
1038
  params: { reason: t || "" }
1039
1039
  }).then((n) => {
1040
- const r = Gt(n);
1040
+ const r = zt(n);
1041
1041
  return this.set(r), r.accessGranted;
1042
1042
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1043
1043
  }
@@ -1070,7 +1070,7 @@ class ft extends V {
1070
1070
  }
1071
1071
  }
1072
1072
  async function Ke(e) {
1073
- return Gt(
1073
+ return zt(
1074
1074
  await m({
1075
1075
  ...e || {},
1076
1076
  method: "web_app_biometry_get_info",
@@ -1130,7 +1130,7 @@ const Fe = _("closingBehavior", ({
1130
1130
  }) => new Qe(t.isConfirmationNeeded, e));
1131
1131
  class pt {
1132
1132
  constructor(t, s) {
1133
- c(this, "supports"), this.supports = qt(t, s);
1133
+ c(this, "supports"), this.supports = Nt(t, s);
1134
1134
  }
1135
1135
  }
1136
1136
  function Ye(e) {
@@ -1358,7 +1358,7 @@ const is = _(
1358
1358
  ({ initData: e }) => e ? new rs(e) : void 0
1359
1359
  );
1360
1360
  function fn(e) {
1361
- return Dt().parse(e);
1361
+ return Vt().parse(e);
1362
1362
  }
1363
1363
  class os extends V {
1364
1364
  constructor(t, s, n) {
@@ -1571,13 +1571,13 @@ function ps() {
1571
1571
  }
1572
1572
  }),
1573
1573
  authDate: {
1574
- type: Nt(),
1574
+ type: Dt(),
1575
1575
  from: "auth_date"
1576
1576
  },
1577
1577
  hash: h()
1578
1578
  }, "RequestedContact");
1579
1579
  }
1580
- function zt(e, t) {
1580
+ function Kt(e, t) {
1581
1581
  return (s) => {
1582
1582
  const [n, r] = t[s];
1583
1583
  return S(n, r, e);
@@ -1598,7 +1598,7 @@ class ds extends V {
1598
1598
  setBackgroundColor: "web_app_set_background_color"
1599
1599
  }), 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;
1600
1600
  const o = this.supports.bind(this);
1601
- this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = zt(n, {
1601
+ this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Kt(n, {
1602
1602
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1603
1603
  });
1604
1604
  }
@@ -1649,7 +1649,7 @@ class ds extends V {
1649
1649
  * True if current Mini App background color is recognized as dark.
1650
1650
  */
1651
1651
  get isDark() {
1652
- return Ot(this.bgColor);
1652
+ return qt(this.bgColor);
1653
1653
  }
1654
1654
  /**
1655
1655
  * Informs the Telegram app that the Mini App is ready to be displayed.
@@ -1678,7 +1678,7 @@ class ds extends V {
1678
1678
  throw new Error("Access denied.");
1679
1679
  const s = Date.now() + t;
1680
1680
  let n = 50;
1681
- return It(async () => {
1681
+ return Ot(async () => {
1682
1682
  for (; Date.now() < s; ) {
1683
1683
  try {
1684
1684
  return await this.getRequestedContact();
@@ -1686,7 +1686,7 @@ class ds extends V {
1686
1686
  }
1687
1687
  await us(n), n += 50;
1688
1688
  }
1689
- throw kt(t);
1689
+ throw It(t);
1690
1690
  }, t);
1691
1691
  }
1692
1692
  /**
@@ -1927,8 +1927,8 @@ const vs = _("settingsButton", ({
1927
1927
  postEvent: t,
1928
1928
  state: s = { isVisible: !1 }
1929
1929
  }) => new bs(s.isVisible, e, t));
1930
- function Kt(e) {
1931
- return Vt().parse(e);
1930
+ function Jt(e) {
1931
+ return Bt().parse(e);
1932
1932
  }
1933
1933
  class ys extends ht {
1934
1934
  /**
@@ -1969,7 +1969,7 @@ class ys extends ht {
1969
1969
  * value is calculated according to theme bg color.
1970
1970
  */
1971
1971
  get isDark() {
1972
- return !this.bgColor || Ot(this.bgColor);
1972
+ return !this.bgColor || qt(this.bgColor);
1973
1973
  }
1974
1974
  get linkColor() {
1975
1975
  return this.get("linkColor");
@@ -1995,7 +1995,7 @@ class ys extends ht {
1995
1995
  */
1996
1996
  listen() {
1997
1997
  return E("theme_changed", (t) => {
1998
- this.set(Kt(t.theme_params));
1998
+ this.set(Jt(t.theme_params));
1999
1999
  });
2000
2000
  }
2001
2001
  /**
@@ -2017,11 +2017,11 @@ function mn(e = {}) {
2017
2017
  ...e,
2018
2018
  method: "web_app_request_theme",
2019
2019
  event: "theme_changed"
2020
- }).then(Kt);
2020
+ }).then(Jt);
2021
2021
  }
2022
2022
  class Ps extends pt {
2023
2023
  constructor(t, s, n) {
2024
- 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, {
2024
+ super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Kt(t, {
2025
2025
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2026
2026
  });
2027
2027
  }
@@ -2075,7 +2075,7 @@ class Ps extends pt {
2075
2075
  event: "clipboard_text_received",
2076
2076
  postEvent: this.postEvent,
2077
2077
  params: { req_id: t },
2078
- capture: At(t)
2078
+ capture: kt(t)
2079
2079
  });
2080
2080
  return s;
2081
2081
  }
@@ -2083,7 +2083,7 @@ class Ps extends pt {
2083
2083
  const Rs = _(
2084
2084
  ({ version: e, postEvent: t, createRequestId: s }) => new Ps(e, s, t)
2085
2085
  );
2086
- async function Jt(e = {}) {
2086
+ async function Qt(e = {}) {
2087
2087
  const {
2088
2088
  is_expanded: t,
2089
2089
  is_state_stable: s,
@@ -2098,7 +2098,7 @@ async function Jt(e = {}) {
2098
2098
  function k(e) {
2099
2099
  return e < 0 ? 0 : e;
2100
2100
  }
2101
- class Qt extends ht {
2101
+ class Ft extends ht {
2102
2102
  constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
2103
2103
  super({
2104
2104
  height: k(n),
@@ -2113,7 +2113,7 @@ class Qt extends ht {
2113
2113
  * @param options - options to request fresh data.
2114
2114
  */
2115
2115
  async sync(t) {
2116
- const { isStateStable: s, ...n } = await Jt(t);
2116
+ const { isStateStable: s, ...n } = await Qt(t);
2117
2117
  this.set({
2118
2118
  ...n,
2119
2119
  stableHeight: s ? n.height : this.get("stableHeight")
@@ -2211,8 +2211,8 @@ async function xs(e, t = {}) {
2211
2211
  width: n,
2212
2212
  isExpanded: r,
2213
2213
  isStateStable: i
2214
- } = await Jt({ ...t, postEvent: e });
2215
- return new Qt({
2214
+ } = await Qt({ ...t, postEvent: e });
2215
+ return new Ft({
2216
2216
  postEvent: e,
2217
2217
  height: s,
2218
2218
  width: n,
@@ -2226,7 +2226,7 @@ function Ss({
2226
2226
  postEvent: s
2227
2227
  }) {
2228
2228
  let n = !1, r = 0, i = 0, o = 0;
2229
- return e ? (n = e.isExpanded, r = e.height, i = e.width, o = e.stableHeight) : ["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t) && (n = !0, r = window.innerHeight, i = window.innerWidth, o = window.innerHeight), new Qt({
2229
+ return e ? (n = e.isExpanded, r = e.height, i = e.width, o = e.stableHeight) : ["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t) && (n = !0, r = window.innerHeight, i = window.innerWidth, o = window.innerHeight), new Ft({
2230
2230
  postEvent: s,
2231
2231
  height: r,
2232
2232
  width: i,
@@ -2306,6 +2306,8 @@ function Ts(e = !0) {
2306
2306
  return q("iframe_ready", { reload_supported: !0 }), s;
2307
2307
  }
2308
2308
  async function En() {
2309
+ if (Ct(window))
2310
+ return !0;
2309
2311
  try {
2310
2312
  return await m({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
2311
2313
  } catch {
@@ -2329,10 +2331,10 @@ function J(e, t) {
2329
2331
  class ks {
2330
2332
  constructor(t, s, n = q) {
2331
2333
  if (c(this, "history"), c(this, "ee", new U()), 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)
2332
- throw l(_e, "History should not be empty.");
2334
+ throw l(ge, "History should not be empty.");
2333
2335
  if (s < 0 || s >= t.length)
2334
2336
  throw l(
2335
- ge,
2337
+ we,
2336
2338
  "Index should not be zero and higher or equal than history size."
2337
2339
  );
2338
2340
  this.history = t.map((r) => J(r, ""));
@@ -2493,11 +2495,11 @@ async function Is() {
2493
2495
  for (; e; )
2494
2496
  e = await O(-1);
2495
2497
  }
2496
- function Ft(e) {
2498
+ function Yt(e) {
2497
2499
  return $(e).pathname;
2498
2500
  }
2499
2501
  const bt = 0, Y = 1, Z = 2;
2500
- class Yt {
2502
+ class Zt {
2501
2503
  constructor(t, s, { postEvent: n, hashMode: r, base: i } = {}) {
2502
2504
  c(this, "navigator"), c(this, "ee", new U()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
2503
2505
  if (o === null)
@@ -2518,7 +2520,7 @@ class Yt {
2518
2520
  t.map((o) => F(o, "/")),
2519
2521
  s,
2520
2522
  n
2521
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Ft(i || "");
2523
+ ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Yt(i || "");
2522
2524
  }
2523
2525
  /**
2524
2526
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2699,28 +2701,28 @@ function Os(e) {
2699
2701
  let n = L(
2700
2702
  e.hashMode ? s.includes("?") ? s.slice(1) : `?${s.slice(1)}` : t
2701
2703
  );
2702
- const r = e.base ? Ft(e.base) : void 0;
2704
+ const r = e.base ? Yt(e.base) : void 0;
2703
2705
  if (r) {
2704
2706
  if (!n.startsWith(r))
2705
2707
  throw l(
2706
- fe,
2708
+ me,
2707
2709
  `Path "${n}" expected to be starting with "${r}"`
2708
2710
  );
2709
2711
  n = n.slice(r.length);
2710
2712
  }
2711
- return new Yt([n], 0, e);
2713
+ return new Zt([n], 0, e);
2712
2714
  }
2713
2715
  function Rn(e) {
2714
2716
  const t = e.match(/#(.+)/);
2715
2717
  return t ? t[1] : null;
2716
2718
  }
2717
2719
  function qs(e, t) {
2718
- if (jt()) {
2720
+ if (Gt()) {
2719
2721
  const s = sessionStorage.getItem(e);
2720
2722
  if (s)
2721
2723
  try {
2722
2724
  const { index: n, history: r } = JSON.parse(s);
2723
- return new Yt(r, n, t);
2725
+ return new Zt(r, n, t);
2724
2726
  } catch (n) {
2725
2727
  console.error("Unable to restore hash navigator state.", n);
2726
2728
  }
@@ -2743,9 +2745,9 @@ function g(e, t) {
2743
2745
  }
2744
2746
  return [s(e), s(t)];
2745
2747
  }
2746
- const Zt = Xt(void 0);
2748
+ const Xt = te(void 0);
2747
2749
  function Ns() {
2748
- const e = te(Zt);
2750
+ const e = ee(Xt);
2749
2751
  if (!e)
2750
2752
  throw new Error("useSDK was used outside the SDKProvider.");
2751
2753
  return e;
@@ -2782,11 +2784,11 @@ const [Ds, Vs] = w(ze), [Sn, Cn] = g(
2782
2784
  rn
2783
2785
  ), [on, an] = w(Es), [Fn, Yn] = g(on, an);
2784
2786
  function Zn() {
2785
- return st(Wt, []);
2787
+ return st(jt, []);
2786
2788
  }
2787
2789
  const [cn, hn] = w(Rs), [Xn, tr] = g(cn, hn), [pn, un] = w(Cs), [er, sr] = g(pn, un);
2788
2790
  function nr({ children: e, acceptCustomStyles: t, debug: s }) {
2789
- const n = lt(!0), [r, i] = ee(
2791
+ const n = lt(!0), [r, i] = se(
2790
2792
  () => /* @__PURE__ */ new Map()
2791
2793
  ), o = _t((d) => {
2792
2794
  n.current && i((B) => (d && d(B), new Map(B)));
@@ -2811,34 +2813,34 @@ function nr({ children: e, acceptCustomStyles: t, debug: s }) {
2811
2813
  }
2812
2814
  }), [r]);
2813
2815
  return M(() => {
2814
- oe(s || !1);
2816
+ ae(s || !1);
2815
2817
  }, [s]), M(() => () => {
2816
2818
  n.current = !1;
2817
2819
  }, []), M(() => {
2818
- if (Ct())
2820
+ if (Tt())
2819
2821
  return Ts(t);
2820
- }, [t]), M(() => () => p.current.forEach((d) => d.off("change", a)), [a]), /* @__PURE__ */ vt(Zt.Provider, { value: u, children: e });
2822
+ }, [t]), M(() => () => p.current.forEach((d) => d.off("change", a)), [a]), /* @__PURE__ */ vt(Xt.Provider, { value: u, children: e });
2821
2823
  }
2822
2824
  export {
2823
2825
  Ne as BackButton,
2824
2826
  ks as BasicNavigator,
2825
2827
  ft as BiometryManager,
2826
- Yt as BrowserNavigator,
2828
+ Zt as BrowserNavigator,
2827
2829
  Qe as ClosingBehavior,
2828
2830
  ts as CloudStorage,
2829
- fe as ERR_INVALID_PATH_BASE,
2830
- ue as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2831
- he as ERR_METHOD_PARAMETER_UNSUPPORTED,
2832
- ce as ERR_METHOD_UNSUPPORTED,
2833
- _e as ERR_NAVIGATION_HISTORY_EMPTY,
2834
- ge as ERR_NAVIGATION_INDEX_INVALID,
2831
+ me as ERR_INVALID_PATH_BASE,
2832
+ de as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2833
+ pe as ERR_METHOD_PARAMETER_UNSUPPORTED,
2834
+ he as ERR_METHOD_UNSUPPORTED,
2835
+ ge as ERR_NAVIGATION_HISTORY_EMPTY,
2836
+ we as ERR_NAVIGATION_INDEX_INVALID,
2835
2837
  _n as ERR_NAVIGATION_ITEM_INVALID,
2836
2838
  Pt as ERR_PARSE,
2837
2839
  nt as ERR_SSR_INIT,
2838
- we as ERR_SSR_POST_EVENT,
2839
- de as ERR_TIMED_OUT,
2840
- le as ERR_UNEXPECTED_TYPE,
2841
- pe as ERR_UNKNOWN_ENV,
2840
+ fe as ERR_SSR_POST_EVENT,
2841
+ le as ERR_TIMED_OUT,
2842
+ _e as ERR_UNEXPECTED_TYPE,
2843
+ ue as ERR_UNKNOWN_ENV,
2842
2844
  U as EventEmitter,
2843
2845
  ss as HapticFeedback,
2844
2846
  rs as InitData,
@@ -2852,21 +2854,21 @@ export {
2852
2854
  bs as SettingsButton,
2853
2855
  ys as ThemeParams,
2854
2856
  Ps as Utils,
2855
- Qt as Viewport,
2857
+ Ft as Viewport,
2856
2858
  Xe as array,
2857
2859
  bn as bindMiniAppCSSVars,
2858
2860
  vn as bindThemeParamsCSSVars,
2859
2861
  yn as bindViewportCSSVars,
2860
2862
  P as boolean,
2861
- At as captureSameReq,
2863
+ kt as captureSameReq,
2862
2864
  et as classNames,
2863
- Te as compareVersions,
2865
+ Ae as compareVersions,
2864
2866
  Os as createBrowserNavigatorFromLocation,
2865
2867
  Oe as createPostEvent,
2866
2868
  $ as createSafeURL,
2867
- Nt as date,
2869
+ Dt as date,
2868
2870
  Rn as getHash,
2869
- Ft as getPathname,
2871
+ Yt as getPathname,
2870
2872
  ze as initBackButton,
2871
2873
  Je as initBiometryManager,
2872
2874
  Fe as initClosingBehavior,
@@ -2885,13 +2887,14 @@ export {
2885
2887
  Cs as initViewport,
2886
2888
  Ts as initWeb,
2887
2889
  I as invokeCustomMethod,
2888
- Ot as isColorDark,
2889
- Ct as isIframe,
2890
- jt as isPageReload,
2890
+ qt as isColorDark,
2891
+ Tt as isIframe,
2892
+ Gt as isPageReload,
2891
2893
  it as isRGB,
2892
- me as isRGBShort,
2894
+ be as isRGBShort,
2893
2895
  As as isSDKError,
2894
2896
  Pn as isSDKErrorOfType,
2897
+ C as isSSR,
2895
2898
  En as isTMA,
2896
2899
  f as json,
2897
2900
  wn as mergeClassNames,
@@ -2899,23 +2902,23 @@ export {
2899
2902
  z as off,
2900
2903
  E as on,
2901
2904
  fn as parseInitData,
2902
- Bt as parseLaunchParams,
2903
- Kt as parseThemeParams,
2905
+ Mt as parseLaunchParams,
2906
+ Jt as parseThemeParams,
2904
2907
  q as postEvent,
2905
2908
  m as request,
2906
2909
  Ke as requestBiometryInfo,
2907
2910
  mn as requestThemeParams,
2908
- Jt as requestViewport,
2909
- Wt as retrieveLaunchParams,
2911
+ Qt as requestViewport,
2912
+ jt as retrieveLaunchParams,
2910
2913
  St as rgb,
2911
2914
  ct as searchParams,
2912
2915
  Ue as serializeLaunchParams,
2913
2916
  He as serializeThemeParams,
2914
2917
  R as setCSSVar,
2915
- oe as setDebug,
2918
+ ae as setDebug,
2916
2919
  gn as setTargetOrigin,
2917
2920
  h as string,
2918
- re as subscribe,
2921
+ ie as subscribe,
2919
2922
  S as supports,
2920
2923
  Ie as targetOrigin,
2921
2924
  xt as toRGB,
@@ -2979,7 +2982,7 @@ export {
2979
2982
  Jn as withSettingsButtonRaw,
2980
2983
  Yn as withThemeParams,
2981
2984
  Fn as withThemeParamsRaw,
2982
- It as withTimeout,
2985
+ Ot as withTimeout,
2983
2986
  tr as withUtils,
2984
2987
  Xn as withUtilsRaw,
2985
2988
  sr as withViewport,