@tma.js/sdk 2.0.0 → 2.0.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
- var Mt = Object.defineProperty;
2
- var Lt = (e, t, s) => t in e ? Mt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var c = (e, t, s) => (Lt(e, typeof t != "symbol" ? t + "" : t, s), s);
1
+ var Lt = Object.defineProperty;
2
+ var Bt = (e, t, s) => t in e ? Lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var c = (e, t, s) => (Bt(e, typeof t != "symbol" ? t + "" : t, s), s);
4
4
  function ct(e, t) {
5
5
  let s;
6
6
  const n = () => {
@@ -10,12 +10,12 @@ function ct(e, t) {
10
10
  }
11
11
  function ht(e) {
12
12
  const t = L(), { count: s } = t;
13
- t.unsubscribe(e), s && !t.count && ae();
13
+ t.unsubscribe(e), s && !t.count && ce();
14
14
  }
15
- function Bt(e) {
15
+ function Ot(e) {
16
16
  return L().subscribe(e), () => ht(e);
17
17
  }
18
- class Ot {
18
+ class Ut {
19
19
  constructor(t, s = {}) {
20
20
  this.scope = t, this.options = s;
21
21
  }
@@ -55,7 +55,7 @@ class Ot {
55
55
  this.print("log", ...t);
56
56
  }
57
57
  }
58
- const D = new Ot("SDK", {
58
+ const D = new Ut("SDK", {
59
59
  bgColor: "forestgreen",
60
60
  textColor: "white"
61
61
  });
@@ -64,9 +64,9 @@ const nt = ({ event: e, args: [t] }) => {
64
64
  D.log("Event received:", t === void 0 ? { name: e } : { name: e, data: t });
65
65
  };
66
66
  function es(e) {
67
- j !== e && (j = e, e ? Bt(nt) : ht(nt));
67
+ j !== e && (j = e, e ? Ot(nt) : ht(nt));
68
68
  }
69
- function Ut(...e) {
69
+ function Wt(...e) {
70
70
  j && D.log(...e);
71
71
  }
72
72
  class V {
@@ -152,9 +152,9 @@ class $ extends Error {
152
152
  function u(e, t, s) {
153
153
  return new $(e, t, s);
154
154
  }
155
- const Wt = "ERR_METHOD_UNSUPPORTED", Ht = "ERR_METHOD_PARAMETER_UNSUPPORTED", Gt = "ERR_UNKNOWN_ENV", jt = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", zt = "ERR_TIMED_OUT", Ft = "ERR_UNEXPECTED_TYPE", pt = "ERR_PARSE", Jt = "ERR_NAVIGATION_LIST_EMPTY", Qt = "ERR_NAVIGATION_CURSOR_INVALID", ss = "ERR_NAVIGATION_ITEM_INVALID", J = "ERR_SSR_INIT", Yt = "ERR_SSR_POST_EVENT", Zt = "ERR_INVALID_PATH_BASE";
155
+ const Ht = "ERR_METHOD_UNSUPPORTED", Gt = "ERR_METHOD_PARAMETER_UNSUPPORTED", jt = "ERR_UNKNOWN_ENV", zt = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", Ft = "ERR_TIMED_OUT", Jt = "ERR_UNEXPECTED_TYPE", pt = "ERR_PARSE", Qt = "ERR_NAVIGATION_LIST_EMPTY", Yt = "ERR_NAVIGATION_CURSOR_INVALID", ss = "ERR_NAVIGATION_ITEM_INVALID", J = "ERR_SSR_INIT", Zt = "ERR_SSR_POST_EVENT", Xt = "ERR_INVALID_PATH_BASE";
156
156
  function P() {
157
- return u(Ft, "Value has unexpected type");
157
+ return u(Jt, "Value has unexpected type");
158
158
  }
159
159
  class M {
160
160
  constructor(t, s, n) {
@@ -242,14 +242,14 @@ const y = S((e) => {
242
242
  function Y(e) {
243
243
  return /^#[\da-f]{6}$/i.test(e);
244
244
  }
245
- function Xt(e) {
245
+ function Kt(e) {
246
246
  return /^#[\da-f]{3}$/i.test(e);
247
247
  }
248
248
  function lt(e) {
249
249
  const t = e.replace(/\s/g, "").toLowerCase();
250
250
  if (Y(t))
251
251
  return t;
252
- if (Xt(t)) {
252
+ if (Kt(t)) {
253
253
  let n = "#";
254
254
  for (let r = 0; r < 3; r += 1)
255
255
  n += t[1 + r].repeat(2);
@@ -268,25 +268,25 @@ const h = S((e) => {
268
268
  return e.toString();
269
269
  throw P();
270
270
  }, "string"), dt = S((e) => lt(h().parse(e)), "rgb");
271
- function Kt(e) {
271
+ function te(e) {
272
272
  return _({
273
273
  eventType: h(),
274
274
  eventData: (t) => t
275
275
  }).parse(e);
276
276
  }
277
- function te() {
277
+ function ee() {
278
278
  ["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
279
279
  delete window[e];
280
280
  });
281
281
  }
282
- function ee(e, t) {
282
+ function se(e, t) {
283
283
  window.dispatchEvent(new MessageEvent("message", {
284
284
  data: JSON.stringify({ eventType: e, eventData: t }),
285
285
  // We specify window.parent to imitate the case, the parent iframe sent us this event.
286
286
  source: window.parent
287
287
  }));
288
288
  }
289
- function se() {
289
+ function ne() {
290
290
  [
291
291
  ["TelegramGameProxy_receiveEvent"],
292
292
  // Windows Phone.
@@ -298,16 +298,16 @@ function se() {
298
298
  let t = window;
299
299
  e.forEach((s, n, r) => {
300
300
  if (n === r.length - 1) {
301
- t[s] = ee;
301
+ t[s] = se;
302
302
  return;
303
303
  }
304
304
  s in t || (t[s] = {}), t = t[s];
305
305
  });
306
306
  });
307
307
  }
308
- const ne = _({
308
+ const re = _({
309
309
  button_id: (e) => e == null ? void 0 : h().parse(e)
310
- }), re = {
310
+ }), ie = {
311
311
  clipboard_text_received: _({
312
312
  req_id: h(),
313
313
  data: (e) => e === null ? e : h().optional().parse(e)
@@ -325,7 +325,7 @@ const ne = _({
325
325
  status: h()
326
326
  }),
327
327
  popup_closed: {
328
- parse: (e) => ne.parse(e ?? {})
328
+ parse: (e) => re.parse(e ?? {})
329
329
  },
330
330
  qr_text_received: _({
331
331
  data: h().optional()
@@ -346,12 +346,12 @@ const ne = _({
346
346
  status: h()
347
347
  })
348
348
  };
349
- function ie() {
349
+ function oe() {
350
350
  const e = new V();
351
- se();
351
+ ne();
352
352
  let t = [
353
353
  // Don't forget to remove created handlers.
354
- te,
354
+ ee,
355
355
  // Add "resize" event listener to make sure, we always have fresh viewport information.
356
356
  // Desktop version of Telegram is sometimes not sending the viewport_changed
357
357
  // event. For example, when the MainButton is shown. That's why we should
@@ -372,11 +372,11 @@ function ie() {
372
372
  return;
373
373
  let n;
374
374
  try {
375
- n = Kt(s.data);
375
+ n = te(s.data);
376
376
  } catch {
377
377
  return;
378
378
  }
379
- const { eventType: r, eventData: i } = n, o = re[r];
379
+ const { eventType: r, eventData: i } = n, o = ie[r];
380
380
  try {
381
381
  const a = o ? o.parse(i) : i;
382
382
  e.emit(...a ? [r, a] : [r]);
@@ -395,9 +395,9 @@ function ie() {
395
395
  t.forEach((s) => s()), t = [];
396
396
  }];
397
397
  }
398
- const [oe, ae] = ct(
398
+ const [ae, ce] = ct(
399
399
  (e) => {
400
- const [t, s] = ie(), n = t.off.bind(t);
400
+ const [t, s] = oe(), n = t.off.bind(t);
401
401
  return t.off = (r, i) => {
402
402
  const { count: o } = t;
403
403
  n(r, i), o && !t.count && e();
@@ -406,7 +406,7 @@ const [oe, ae] = ct(
406
406
  ([, e]) => e()
407
407
  );
408
408
  function L() {
409
- return oe()[0];
409
+ return ae()[0];
410
410
  }
411
411
  function B(e, t) {
412
412
  L().off(e, t);
@@ -417,7 +417,7 @@ function b(e, t, s) {
417
417
  function I(e) {
418
418
  return typeof e == "object" && e !== null && !Array.isArray(e);
419
419
  }
420
- function ce(e, t) {
420
+ function he(e, t) {
421
421
  const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
422
422
  for (let i = 0; i < r; i += 1) {
423
423
  const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
@@ -427,7 +427,7 @@ function ce(e, t) {
427
427
  return 0;
428
428
  }
429
429
  function g(e, t) {
430
- return ce(e, t) <= 0;
430
+ return he(e, t) <= 0;
431
431
  }
432
432
  function v(e, t, s) {
433
433
  if (typeof s == "string") {
@@ -480,10 +480,10 @@ function v(e, t, s) {
480
480
  ].includes(e);
481
481
  }
482
482
  }
483
- function he(e) {
483
+ function pe(e) {
484
484
  return "external" in e && I(e.external) && "notify" in e.external && typeof e.external.notify == "function";
485
485
  }
486
- function pe(e) {
486
+ function _t(e) {
487
487
  return "TelegramWebviewProxy" in e && I(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
488
488
  }
489
489
  function ue() {
@@ -493,61 +493,61 @@ function ue() {
493
493
  return !0;
494
494
  }
495
495
  }
496
- let _t = "https://web.telegram.org";
496
+ let ft = "https://web.telegram.org";
497
497
  function ns(e) {
498
- _t = e;
498
+ ft = e;
499
499
  }
500
500
  function le() {
501
- return _t;
501
+ return ft;
502
502
  }
503
503
  function T(e, t, s) {
504
504
  let n = {}, r;
505
505
  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);
506
506
  const { targetOrigin: i = le() } = n;
507
- if (Ut("Posting event:", r ? { event: e, data: r } : { event: e }), ue()) {
507
+ if (Wt("Posting event:", r ? { event: e, data: r } : { event: e }), ue()) {
508
508
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
509
509
  return;
510
510
  }
511
- if (he(window)) {
511
+ if (pe(window)) {
512
512
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
513
513
  return;
514
514
  }
515
- if (pe(window)) {
515
+ if (_t(window)) {
516
516
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
517
517
  return;
518
518
  }
519
519
  throw u(
520
- Gt,
520
+ jt,
521
521
  "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."
522
522
  );
523
523
  }
524
524
  function de(e) {
525
525
  return (t, s) => {
526
526
  if (!v(t, e))
527
- throw u(Wt, `Method "${t}" is unsupported in Mini Apps version ${e}`);
527
+ throw u(Ht, `Method "${t}" is unsupported in Mini Apps version ${e}`);
528
528
  if (I(s)) {
529
529
  let n;
530
530
  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 && !v(t, n, e))
531
531
  throw u(
532
- Ht,
532
+ Gt,
533
533
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
534
534
  );
535
535
  }
536
536
  return T(t, s);
537
537
  };
538
538
  }
539
- function ft(e) {
539
+ function gt(e) {
540
540
  return ({ req_id: t }) => t === e;
541
541
  }
542
- function gt(e) {
543
- return u(zt, `Timeout reached: ${e}ms`);
542
+ function bt(e) {
543
+ return u(Ft, `Timeout reached: ${e}ms`);
544
544
  }
545
- function bt(e, t) {
545
+ function wt(e, t) {
546
546
  return Promise.race([
547
547
  typeof e == "function" ? e() : e,
548
548
  new Promise((s, n) => {
549
549
  setTimeout(() => {
550
- n(gt(t));
550
+ n(bt(t));
551
551
  }, t);
552
552
  })
553
553
  ]);
@@ -566,7 +566,7 @@ async function f(e) {
566
566
  (d) => b(d, (st) => (!i || i(st)) && t(st))
567
567
  );
568
568
  try {
569
- return o(n, e.params), await (a ? bt(s, a) : s);
569
+ return o(n, e.params), await (a ? wt(s, a) : s);
570
570
  } finally {
571
571
  p.forEach((d) => d());
572
572
  }
@@ -584,10 +584,10 @@ async function R(e, t, s, n = {}) {
584
584
  params: t,
585
585
  req_id: s
586
586
  },
587
- capture: ft(s)
587
+ capture: gt(s)
588
588
  });
589
589
  if (i)
590
- throw u(jt, i);
590
+ throw u(zt, i);
591
591
  return r;
592
592
  }
593
593
  function F(...e) {
@@ -606,7 +606,7 @@ function rs(...e) {
606
606
  i.length && (t[n] = i);
607
607
  }), t), {});
608
608
  }
609
- function wt(e) {
609
+ function mt(e) {
610
610
  const t = lt(e);
611
611
  return Math.sqrt(
612
612
  [0.299, 0.587, 0.114].reduce((s, n, r) => {
@@ -663,7 +663,7 @@ class Z {
663
663
  this.state = new _e(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);
664
664
  }
665
665
  }
666
- function mt(e, t) {
666
+ function yt(e, t) {
667
667
  return (s) => v(t[s], e);
668
668
  }
669
669
  class X extends Z {
@@ -673,7 +673,7 @@ class X extends Z {
673
673
  * @returns True, if specified method is supported by the current component.
674
674
  */
675
675
  c(this, "supports");
676
- this.supports = mt(n, r);
676
+ this.supports = yt(n, r);
677
677
  }
678
678
  }
679
679
  class fe extends X {
@@ -721,7 +721,7 @@ class fe extends X {
721
721
  function E() {
722
722
  return typeof window > "u";
723
723
  }
724
- const yt = S((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
724
+ const vt = S((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
725
725
  function K(e, t) {
726
726
  return new M((s) => {
727
727
  if (typeof s != "string" && !(s instanceof URLSearchParams))
@@ -778,10 +778,10 @@ const ge = _({
778
778
  },
779
779
  username: h().optional()
780
780
  }, "User").optional();
781
- function vt() {
781
+ function Et() {
782
782
  return K({
783
783
  authDate: {
784
- type: yt(),
784
+ type: vt(),
785
785
  from: "auth_date"
786
786
  },
787
787
  canSendAfter: {
@@ -816,21 +816,21 @@ function be(e) {
816
816
  function we(e) {
817
817
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
818
818
  }
819
- const Et = S(
819
+ const Pt = S(
820
820
  (e) => {
821
821
  const t = dt().optional();
822
822
  return Object.entries(Q(e)).reduce((s, [n, r]) => (s[be(n)] = t.parse(r), s), {});
823
823
  },
824
824
  "ThemeParams"
825
825
  );
826
- function Pt(e) {
826
+ function St(e) {
827
827
  return K({
828
828
  botInline: {
829
829
  type: w().optional(),
830
830
  from: "tgWebAppBotInline"
831
831
  },
832
832
  initData: {
833
- type: vt().optional(),
833
+ type: Et().optional(),
834
834
  from: "tgWebAppData"
835
835
  },
836
836
  initDataRaw: {
@@ -850,7 +850,7 @@ function Pt(e) {
850
850
  from: "tgWebAppStartParam"
851
851
  },
852
852
  themeParams: {
853
- type: Et(),
853
+ type: Pt(),
854
854
  from: "tgWebAppThemeParams"
855
855
  },
856
856
  version: {
@@ -859,38 +859,38 @@ function Pt(e) {
859
859
  }
860
860
  }).parse(e);
861
861
  }
862
- function St(e) {
863
- return Pt(
862
+ function xt(e) {
863
+ return St(
864
864
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
865
865
  );
866
866
  }
867
867
  function me() {
868
- return St(window.location.href);
868
+ return xt(window.location.href);
869
869
  }
870
- function xt() {
870
+ function Rt() {
871
871
  return performance.getEntriesByType("navigation")[0];
872
872
  }
873
873
  function ye() {
874
- const e = xt();
874
+ const e = Rt();
875
875
  if (!e)
876
876
  throw new Error("Unable to get first navigation entry.");
877
- return St(e.name);
877
+ return xt(e.name);
878
878
  }
879
- function Rt(e) {
879
+ function Ct(e) {
880
880
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
881
881
  }
882
- function Ct(e, t) {
883
- sessionStorage.setItem(Rt(e), JSON.stringify(t));
882
+ function Tt(e, t) {
883
+ sessionStorage.setItem(Ct(e), JSON.stringify(t));
884
884
  }
885
- function Tt(e) {
886
- const t = sessionStorage.getItem(Rt(e));
885
+ function At(e) {
886
+ const t = sessionStorage.getItem(Ct(e));
887
887
  try {
888
888
  return t ? JSON.parse(t) : void 0;
889
889
  } catch {
890
890
  }
891
891
  }
892
892
  function ve() {
893
- return Pt(Tt("launchParams") || "");
893
+ return St(At("launchParams") || "");
894
894
  }
895
895
  function Ee(e) {
896
896
  return JSON.stringify(
@@ -912,7 +912,7 @@ function Pe(e) {
912
912
  return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", Ee(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();
913
913
  }
914
914
  function Se(e) {
915
- Ct("launchParams", Pe(e));
915
+ Tt("launchParams", Pe(e));
916
916
  }
917
917
  function xe() {
918
918
  for (const e of [
@@ -931,8 +931,8 @@ function xe() {
931
931
  }
932
932
  throw new Error("Unable to retrieve launch parameters from any known source.");
933
933
  }
934
- function At() {
935
- const e = xt();
934
+ function It() {
935
+ const e = Rt();
936
936
  return !!(e && e.type === "reload");
937
937
  }
938
938
  function Re() {
@@ -956,7 +956,7 @@ function l(e, t) {
956
956
  ...n,
957
957
  postEvent: "version" in n ? de(n.version) : () => {
958
958
  throw u(
959
- Yt,
959
+ Zt,
960
960
  "postEvent function is forbidden to be called on the server side."
961
961
  );
962
962
  },
@@ -966,9 +966,9 @@ function l(e, t) {
966
966
  return typeof e == "function" ? e(r) : t(r);
967
967
  const i = t({
968
968
  ...r,
969
- state: At() ? Tt(e) : void 0
969
+ state: It() ? At(e) : void 0
970
970
  }), o = (a) => (a.on("change", (p) => {
971
- Ct(e, p);
971
+ Tt(e, p);
972
972
  }), a);
973
973
  return i instanceof Promise ? i.then(o) : o(i);
974
974
  };
@@ -991,7 +991,7 @@ class q extends X {
991
991
  c(this, "off", this.state.off.bind(this.state));
992
992
  }
993
993
  }
994
- function It(e) {
994
+ function qt(e) {
995
995
  const t = e.available ? e : {
996
996
  available: !1,
997
997
  device_id: "",
@@ -1091,7 +1091,7 @@ class it extends q {
1091
1091
  event: "biometry_info_received",
1092
1092
  params: { reason: s || "" }
1093
1093
  }).then((r) => {
1094
- const i = It(r);
1094
+ const i = qt(r);
1095
1095
  return this.set(i), i.accessGranted;
1096
1096
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1097
1097
  }
@@ -1124,7 +1124,7 @@ class it extends q {
1124
1124
  }
1125
1125
  }
1126
1126
  async function Te(e) {
1127
- return It(
1127
+ return qt(
1128
1128
  await f({
1129
1129
  ...e || {},
1130
1130
  method: "web_app_biometry_get_info",
@@ -1196,7 +1196,7 @@ class et {
1196
1196
  * @returns True, if specified method is supported by the current component.
1197
1197
  */
1198
1198
  c(this, "supports");
1199
- this.supports = mt(t, s);
1199
+ this.supports = yt(t, s);
1200
1200
  }
1201
1201
  }
1202
1202
  function Ie(e) {
@@ -1426,7 +1426,7 @@ const ps = l(
1426
1426
  ({ initData: e }) => e ? new Ve(e) : void 0
1427
1427
  );
1428
1428
  function us(e) {
1429
- return vt().parse(e);
1429
+ return Et().parse(e);
1430
1430
  }
1431
1431
  class $e extends q {
1432
1432
  constructor(t, s, n) {
@@ -1653,13 +1653,13 @@ function Le() {
1653
1653
  }
1654
1654
  }),
1655
1655
  authDate: {
1656
- type: yt(),
1656
+ type: vt(),
1657
1657
  from: "auth_date"
1658
1658
  },
1659
1659
  hash: h()
1660
1660
  }, "RequestedContact");
1661
1661
  }
1662
- function qt(e, t) {
1662
+ function kt(e, t) {
1663
1663
  return (s) => {
1664
1664
  const [n, r] = t[s];
1665
1665
  return v(n, r, e);
@@ -1690,7 +1690,7 @@ class Oe extends q {
1690
1690
  c(this, "supportsParam");
1691
1691
  this.createRequestId = n, this.postEvent = s, this.botInline = i;
1692
1692
  const a = this.supports.bind(this);
1693
- this.supports = (p) => a(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = qt(r, {
1693
+ this.supports = (p) => a(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = kt(r, {
1694
1694
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1695
1695
  });
1696
1696
  }
@@ -1741,7 +1741,7 @@ class Oe extends q {
1741
1741
  * True if current Mini App background color is recognized as dark.
1742
1742
  */
1743
1743
  get isDark() {
1744
- return wt(this.bgColor);
1744
+ return mt(this.bgColor);
1745
1745
  }
1746
1746
  /**
1747
1747
  * Informs the Telegram app that the Mini App is ready to be displayed.
@@ -1770,7 +1770,7 @@ class Oe extends q {
1770
1770
  throw new Error("Access denied.");
1771
1771
  const r = Date.now() + s;
1772
1772
  let i = 50;
1773
- return bt(async () => {
1773
+ return wt(async () => {
1774
1774
  for (; Date.now() < r; ) {
1775
1775
  try {
1776
1776
  return await this.getRequestedContact();
@@ -1778,7 +1778,7 @@ class Oe extends q {
1778
1778
  }
1779
1779
  await Be(i), i += 50;
1780
1780
  }
1781
- throw gt(s);
1781
+ throw bt(s);
1782
1782
  }, s);
1783
1783
  }
1784
1784
  /**
@@ -2032,8 +2032,8 @@ const bs = l("settingsButton", ({
2032
2032
  postEvent: t,
2033
2033
  state: s = { isVisible: !1 }
2034
2034
  }) => new Ge(s.isVisible, e, t));
2035
- function kt(e) {
2036
- return Et().parse(e);
2035
+ function Nt(e) {
2036
+ return Pt().parse(e);
2037
2037
  }
2038
2038
  class je extends tt {
2039
2039
  /**
@@ -2074,7 +2074,7 @@ class je extends tt {
2074
2074
  * value is calculated according to theme bg color.
2075
2075
  */
2076
2076
  get isDark() {
2077
- return !this.bgColor || wt(this.bgColor);
2077
+ return !this.bgColor || mt(this.bgColor);
2078
2078
  }
2079
2079
  get linkColor() {
2080
2080
  return this.get("linkColor");
@@ -2100,7 +2100,7 @@ class je extends tt {
2100
2100
  */
2101
2101
  listen() {
2102
2102
  return b("theme_changed", (t) => {
2103
- this.set(kt(t.theme_params));
2103
+ this.set(Nt(t.theme_params));
2104
2104
  });
2105
2105
  }
2106
2106
  /**
@@ -2122,7 +2122,7 @@ function ms(e = {}) {
2122
2122
  ...e,
2123
2123
  method: "web_app_request_theme",
2124
2124
  event: "theme_changed"
2125
- }).then(kt);
2125
+ }).then(Nt);
2126
2126
  }
2127
2127
  class ze extends et {
2128
2128
  constructor(s, n, r) {
@@ -2131,7 +2131,7 @@ class ze extends et {
2131
2131
  * Checks if specified method parameter is supported by current component.
2132
2132
  */
2133
2133
  c(this, "supportsParam");
2134
- this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = qt(s, {
2134
+ this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = kt(s, {
2135
2135
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2136
2136
  });
2137
2137
  }
@@ -2185,7 +2185,7 @@ class ze extends et {
2185
2185
  event: "clipboard_text_received",
2186
2186
  postEvent: this.postEvent,
2187
2187
  params: { req_id: s },
2188
- capture: ft(s)
2188
+ capture: gt(s)
2189
2189
  });
2190
2190
  return n;
2191
2191
  }
@@ -2193,7 +2193,7 @@ class ze extends et {
2193
2193
  const ys = l(
2194
2194
  ({ version: e, postEvent: t, createRequestId: s }) => new ze(e, s, t)
2195
2195
  );
2196
- async function Nt(e = {}) {
2196
+ async function Dt(e = {}) {
2197
2197
  const {
2198
2198
  is_expanded: t,
2199
2199
  is_state_stable: s,
@@ -2208,7 +2208,7 @@ async function Nt(e = {}) {
2208
2208
  function x(e) {
2209
2209
  return e < 0 ? 0 : e;
2210
2210
  }
2211
- class Dt extends tt {
2211
+ class Vt extends tt {
2212
2212
  constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: o }) {
2213
2213
  super({
2214
2214
  height: x(r),
@@ -2225,7 +2225,7 @@ class Dt extends tt {
2225
2225
  * @param options - options to request fresh data.
2226
2226
  */
2227
2227
  async sync(s) {
2228
- const { isStateStable: n, ...r } = await Nt(s);
2228
+ const { isStateStable: n, ...r } = await Dt(s);
2229
2229
  this.set({
2230
2230
  ...r,
2231
2231
  stableHeight: n ? r.height : this.get("stableHeight")
@@ -2323,8 +2323,8 @@ async function Fe(e, t = {}) {
2323
2323
  width: n,
2324
2324
  isExpanded: r,
2325
2325
  isStateStable: i
2326
- } = await Nt({ ...t, postEvent: e });
2327
- return new Dt({
2326
+ } = await Dt({ ...t, postEvent: e });
2327
+ return new Vt({
2328
2328
  postEvent: e,
2329
2329
  height: s,
2330
2330
  width: n,
@@ -2338,7 +2338,7 @@ function Je({
2338
2338
  postEvent: s
2339
2339
  }) {
2340
2340
  let n = !1, r = 0, i = 0, o = 0;
2341
- 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 Dt({
2341
+ 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 Vt({
2342
2342
  postEvent: s,
2343
2343
  height: r,
2344
2344
  width: i,
@@ -2418,6 +2418,8 @@ function xs(e = !0) {
2418
2418
  return T("iframe_ready", { reload_supported: !0 }), s;
2419
2419
  }
2420
2420
  async function Rs() {
2421
+ if (_t(window))
2422
+ return !0;
2421
2423
  try {
2422
2424
  return await f({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
2423
2425
  } catch {
@@ -2462,10 +2464,10 @@ class Ye {
2462
2464
  */
2463
2465
  c(this, "off", this.ee.off.bind(this.ee));
2464
2466
  if (this._index = s, this.postEvent = n, t.length === 0)
2465
- throw u(Jt, "History should not be empty.");
2467
+ throw u(Qt, "History should not be empty.");
2466
2468
  if (s < 0 || s >= t.length)
2467
2469
  throw u(
2468
- Qt,
2470
+ Yt,
2469
2471
  "Index should not be zero and higher or equal than history size."
2470
2472
  );
2471
2473
  this.history = t.map((r) => O(r, ""));
@@ -2626,11 +2628,11 @@ async function Ze() {
2626
2628
  for (; t; )
2627
2629
  t = await C(-1);
2628
2630
  }
2629
- function Vt(e) {
2631
+ function $t(e) {
2630
2632
  return k(e).pathname;
2631
2633
  }
2632
2634
  const at = 0, H = 1, G = 2;
2633
- class $t {
2635
+ class Mt {
2634
2636
  constructor(t, s, { postEvent: n, hashMode: r, base: i } = {}) {
2635
2637
  c(this, "navigator");
2636
2638
  c(this, "ee", new V());
@@ -2676,7 +2678,7 @@ class $t {
2676
2678
  t.map((o) => W(o, "/")),
2677
2679
  s,
2678
2680
  n
2679
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Vt(i || "");
2681
+ ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = $t(i || "");
2680
2682
  }
2681
2683
  /**
2682
2684
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2857,28 +2859,28 @@ function Xe(e) {
2857
2859
  let n = N(
2858
2860
  e.hashMode ? s.includes("?") ? s.slice(1) : `?${s.slice(1)}` : t
2859
2861
  );
2860
- const r = e.base ? Vt(e.base) : void 0;
2862
+ const r = e.base ? $t(e.base) : void 0;
2861
2863
  if (r) {
2862
2864
  if (!n.startsWith(r))
2863
2865
  throw u(
2864
- Zt,
2866
+ Xt,
2865
2867
  `Path "${n}" expected to be starting with "${r}"`
2866
2868
  );
2867
2869
  n = n.slice(r.length);
2868
2870
  }
2869
- return new $t([n], 0, e);
2871
+ return new Mt([n], 0, e);
2870
2872
  }
2871
2873
  function Ts(e) {
2872
2874
  const t = e.match(/#(.+)/);
2873
2875
  return t ? t[1] : null;
2874
2876
  }
2875
2877
  function Ke(e, t) {
2876
- if (At()) {
2878
+ if (It()) {
2877
2879
  const s = sessionStorage.getItem(e);
2878
2880
  if (s)
2879
2881
  try {
2880
2882
  const { index: n, history: r } = JSON.parse(s);
2881
- return new $t(r, n, t);
2883
+ return new Mt(r, n, t);
2882
2884
  } catch (n) {
2883
2885
  console.error("Unable to restore hash navigator state.", n);
2884
2886
  }
@@ -2896,22 +2898,22 @@ export {
2896
2898
  fe as BackButton,
2897
2899
  Ye as BasicNavigator,
2898
2900
  it as BiometryManager,
2899
- $t as BrowserNavigator,
2901
+ Mt as BrowserNavigator,
2900
2902
  Ae as ClosingBehavior,
2901
2903
  Ne as CloudStorage,
2902
- Zt as ERR_INVALID_PATH_BASE,
2903
- jt as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2904
- Ht as ERR_METHOD_PARAMETER_UNSUPPORTED,
2905
- Wt as ERR_METHOD_UNSUPPORTED,
2906
- Jt as ERR_NAVIGATION_HISTORY_EMPTY,
2907
- Qt as ERR_NAVIGATION_INDEX_INVALID,
2904
+ Xt as ERR_INVALID_PATH_BASE,
2905
+ zt as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2906
+ Gt as ERR_METHOD_PARAMETER_UNSUPPORTED,
2907
+ Ht as ERR_METHOD_UNSUPPORTED,
2908
+ Qt as ERR_NAVIGATION_HISTORY_EMPTY,
2909
+ Yt as ERR_NAVIGATION_INDEX_INVALID,
2908
2910
  ss as ERR_NAVIGATION_ITEM_INVALID,
2909
2911
  pt as ERR_PARSE,
2910
2912
  J as ERR_SSR_INIT,
2911
- Yt as ERR_SSR_POST_EVENT,
2912
- zt as ERR_TIMED_OUT,
2913
- Ft as ERR_UNEXPECTED_TYPE,
2914
- Gt as ERR_UNKNOWN_ENV,
2913
+ Zt as ERR_SSR_POST_EVENT,
2914
+ Ft as ERR_TIMED_OUT,
2915
+ Jt as ERR_UNEXPECTED_TYPE,
2916
+ jt as ERR_UNKNOWN_ENV,
2915
2917
  V as EventEmitter,
2916
2918
  De as HapticFeedback,
2917
2919
  Ve as InitData,
@@ -2924,21 +2926,21 @@ export {
2924
2926
  Ge as SettingsButton,
2925
2927
  je as ThemeParams,
2926
2928
  ze as Utils,
2927
- Dt as Viewport,
2929
+ Vt as Viewport,
2928
2930
  ke as array,
2929
2931
  Es as bindMiniAppCSSVars,
2930
2932
  Ps as bindThemeParamsCSSVars,
2931
2933
  Ss as bindViewportCSSVars,
2932
2934
  w as boolean,
2933
- ft as captureSameReq,
2935
+ gt as captureSameReq,
2934
2936
  F as classNames,
2935
- ce as compareVersions,
2937
+ he as compareVersions,
2936
2938
  Xe as createBrowserNavigatorFromLocation,
2937
2939
  de as createPostEvent,
2938
2940
  k as createSafeURL,
2939
- yt as date,
2941
+ vt as date,
2940
2942
  Ts as getHash,
2941
- Vt as getPathname,
2943
+ $t as getPathname,
2942
2944
  is as initBackButton,
2943
2945
  os as initBiometryManager,
2944
2946
  as as initClosingBehavior,
@@ -2957,13 +2959,14 @@ export {
2957
2959
  vs as initViewport,
2958
2960
  xs as initWeb,
2959
2961
  R as invokeCustomMethod,
2960
- wt as isColorDark,
2962
+ mt as isColorDark,
2961
2963
  ue as isIframe,
2962
- At as isPageReload,
2964
+ It as isPageReload,
2963
2965
  Y as isRGB,
2964
- Xt as isRGBShort,
2966
+ Kt as isRGBShort,
2965
2967
  Qe as isSDKError,
2966
2968
  Cs as isSDKErrorOfType,
2969
+ E as isSSR,
2967
2970
  Rs as isTMA,
2968
2971
  _ as json,
2969
2972
  rs as mergeClassNames,
@@ -2971,13 +2974,13 @@ export {
2971
2974
  B as off,
2972
2975
  b as on,
2973
2976
  us as parseInitData,
2974
- Pt as parseLaunchParams,
2975
- kt as parseThemeParams,
2977
+ St as parseLaunchParams,
2978
+ Nt as parseThemeParams,
2976
2979
  T as postEvent,
2977
2980
  f as request,
2978
2981
  Te as requestBiometryInfo,
2979
2982
  ms as requestThemeParams,
2980
- Nt as requestViewport,
2983
+ Dt as requestViewport,
2981
2984
  xe as retrieveLaunchParams,
2982
2985
  dt as rgb,
2983
2986
  K as searchParams,
@@ -2987,12 +2990,12 @@ export {
2987
2990
  es as setDebug,
2988
2991
  ns as setTargetOrigin,
2989
2992
  h as string,
2990
- Bt as subscribe,
2993
+ Ot as subscribe,
2991
2994
  v as supports,
2992
2995
  le as targetOrigin,
2993
2996
  lt as toRGB,
2994
2997
  ht as unsubscribe,
2995
2998
  N as urlToPath,
2996
- bt as withTimeout
2999
+ wt as withTimeout
2997
3000
  };
2998
3001
  //# sourceMappingURL=index.js.map