@tma.js/sdk 1.4.2 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  var Rt = Object.defineProperty;
2
2
  var It = (r, t, e) => t in r ? Rt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
3
  var o = (r, t, e) => (It(r, typeof t != "symbol" ? t + "" : t, e), e);
4
- function H(r) {
4
+ function R(r) {
5
5
  return typeof r == "object" && r !== null && !Array.isArray(r);
6
6
  }
7
7
  function ut() {
@@ -11,7 +11,7 @@ function Lt() {
11
11
  const r = ut();
12
12
  return r ? r.type === "reload" : null;
13
13
  }
14
- function I() {
14
+ function L() {
15
15
  return new TypeError("Value has unexpected type");
16
16
  }
17
17
  class F extends Error {
@@ -50,7 +50,7 @@ function $t(r) {
50
50
  return t;
51
51
  } catch {
52
52
  }
53
- throw I();
53
+ throw L();
54
54
  }
55
55
  class Tt extends z {
56
56
  constructor(e, s, n) {
@@ -66,12 +66,12 @@ class Tt extends z {
66
66
  return this.itemParser = typeof e == "function" ? e : e.parse.bind(e), this;
67
67
  }
68
68
  }
69
- function L(r, t) {
69
+ function $(r, t) {
70
70
  return () => new z(r, !1, t);
71
71
  }
72
- class G extends Error {
72
+ class j extends Error {
73
73
  constructor(t, { cause: e, type: s } = {}) {
74
- super(`Unable to parse field "${t}"${s ? ` as ${s}` : ""}`, { cause: e }), Object.setPrototypeOf(this, G.prototype);
74
+ super(`Unable to parse field "${t}"${s ? ` as ${s}` : ""}`, { cause: e }), Object.setPrototypeOf(this, j.prototype);
75
75
  }
76
76
  }
77
77
  function ht(r, t) {
@@ -92,10 +92,10 @@ function ht(r, t) {
92
92
  try {
93
93
  c = a(p);
94
94
  } catch (h) {
95
- throw h instanceof F ? new G(i, {
95
+ throw h instanceof F ? new j(i, {
96
96
  type: h.type,
97
97
  cause: h
98
- }) : new G(i, { cause: h });
98
+ }) : new j(i, { cause: h });
99
99
  }
100
100
  c !== void 0 && (e[s] = c);
101
101
  }
@@ -104,7 +104,7 @@ function ht(r, t) {
104
104
  function Bt(r) {
105
105
  return new Tt((t) => t, !1, r);
106
106
  }
107
- const k = L((r) => {
107
+ const k = $((r) => {
108
108
  if (typeof r == "boolean")
109
109
  return r;
110
110
  const t = String(r);
@@ -112,8 +112,8 @@ const k = L((r) => {
112
112
  return !0;
113
113
  if (t === "0" || t === "false")
114
114
  return !1;
115
- throw I();
116
- }, "boolean"), q = L((r) => {
115
+ throw L();
116
+ }, "boolean"), q = $((r) => {
117
117
  if (typeof r == "number")
118
118
  return r;
119
119
  if (typeof r == "string") {
@@ -121,12 +121,12 @@ const k = L((r) => {
121
121
  if (!Number.isNaN(t))
122
122
  return t;
123
123
  }
124
- throw I();
125
- }, "number"), pt = L((r) => r instanceof Date ? r : new Date(q().parse(r) * 1e3), "Date");
124
+ throw L();
125
+ }, "number"), pt = $((r) => r instanceof Date ? r : new Date(q().parse(r) * 1e3), "Date");
126
126
  function Y(r) {
127
127
  let t = r;
128
128
  if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
129
- throw I();
129
+ throw L();
130
130
  return t;
131
131
  }
132
132
  function f(r, t) {
@@ -168,15 +168,15 @@ function ft(r) {
168
168
  }, 0)
169
169
  ) < 120;
170
170
  }
171
- const u = L((r) => {
171
+ const u = $((r) => {
172
172
  if (typeof r == "string" || typeof r == "number")
173
173
  return r.toString();
174
- throw I();
175
- }, "string"), gt = L((r) => dt(u().parse(r)), "rgb");
174
+ throw L();
175
+ }, "string"), gt = $((r) => dt(u().parse(r)), "rgb");
176
176
  function X(r, t) {
177
177
  return new z((e) => {
178
178
  if (typeof e != "string" && !(e instanceof URLSearchParams))
179
- throw I();
179
+ throw L();
180
180
  const s = typeof e == "string" ? new URLSearchParams(e) : e;
181
181
  return ht(r, (n) => {
182
182
  const i = s.get(n);
@@ -196,7 +196,7 @@ function Wt() {
196
196
  username: u().optional()
197
197
  }, "Chat");
198
198
  }
199
- class Ot {
199
+ class Nt {
200
200
  constructor(t) {
201
201
  this.initData = t;
202
202
  }
@@ -339,26 +339,26 @@ function wt() {
339
339
  user: rt().optional()
340
340
  }, "InitData");
341
341
  }
342
- function er(r) {
342
+ function tr(r) {
343
343
  return wt().parse(r);
344
344
  }
345
- function Nt(r) {
345
+ function Ot(r) {
346
346
  return r.replace(/(^|_)bg/, (t, e) => `${e}background`).replace(/_([a-z])/g, (t, e) => e.toUpperCase());
347
347
  }
348
348
  function Ht(r) {
349
349
  return r.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`).replace(/(^|_)background/, (t, e) => `${e}bg`);
350
350
  }
351
- const _t = L(
351
+ const _t = $(
352
352
  (r) => {
353
353
  const t = gt().optional();
354
- return Object.entries(Y(r)).reduce((e, [s, n]) => (e[Nt(s)] = t.parse(n), e), {});
354
+ return Object.entries(Y(r)).reduce((e, [s, n]) => (e[Ot(s)] = t.parse(n), e), {});
355
355
  },
356
356
  "ThemeParams"
357
357
  );
358
358
  function bt(r) {
359
359
  return _t().parse(r);
360
360
  }
361
- function rr(r = {}) {
361
+ function er(r = {}) {
362
362
  return m("web_app_request_theme", "theme_changed", r).then(bt);
363
363
  }
364
364
  function Ut(r) {
@@ -612,14 +612,14 @@ function mt() {
612
612
  }
613
613
  }, "LaunchParams");
614
614
  }
615
- function jt(r) {
615
+ function Gt(r) {
616
616
  return mt().parse(r);
617
617
  }
618
618
  function yt(r) {
619
619
  const t = r.includes("?") ? r.replace("#", "&").slice(r.indexOf("?") + 1) : r.slice(r.indexOf("#") + 1);
620
- return jt(t);
620
+ return Gt(t);
621
621
  }
622
- function Gt() {
622
+ function jt() {
623
623
  return yt(window.location.href);
624
624
  }
625
625
  function Ft() {
@@ -634,7 +634,7 @@ function zt() {
634
634
  } catch {
635
635
  }
636
636
  try {
637
- return Gt();
637
+ return jt();
638
638
  } catch {
639
639
  }
640
640
  return null;
@@ -695,7 +695,7 @@ function Ct() {
695
695
  const t = Yt();
696
696
  return window[st] = t, Zt(t.launchParams), t;
697
697
  }
698
- function sr() {
698
+ function rr() {
699
699
  try {
700
700
  return Ct(), !0;
701
701
  } catch {
@@ -703,10 +703,10 @@ function sr() {
703
703
  }
704
704
  }
705
705
  function Xt(r) {
706
- return "external" in r && H(r.external) && "notify" in r.external && typeof r.external.notify == "function";
706
+ return "external" in r && R(r.external) && "notify" in r.external && typeof r.external.notify == "function";
707
707
  }
708
708
  function te(r) {
709
- return "TelegramWebviewProxy" in r && H(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
709
+ return "TelegramWebviewProxy" in r && R(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
710
710
  }
711
711
  function vt() {
712
712
  try {
@@ -782,14 +782,14 @@ class Pt {
782
782
  }
783
783
  let kt = "https://web.telegram.org";
784
784
  const V = new Pt("[SDK]", !1);
785
- function nr(r) {
785
+ function sr(r) {
786
786
  if (r) {
787
787
  V.enable();
788
788
  return;
789
789
  }
790
790
  V.disable();
791
791
  }
792
- function ir(r) {
792
+ function nr(r) {
793
793
  kt = r;
794
794
  }
795
795
  function ee() {
@@ -804,7 +804,9 @@ function se(r) {
804
804
  }
805
805
  function ne(r, t) {
806
806
  window.dispatchEvent(new MessageEvent("message", {
807
- data: JSON.stringify({ eventType: r, eventData: t })
807
+ data: JSON.stringify({ eventType: r, eventData: t }),
808
+ // We specify window.parent to imitate the case, it sent us this event.
809
+ source: window.parent
808
810
  }));
809
811
  }
810
812
  function ie() {
@@ -829,11 +831,12 @@ function ie() {
829
831
  }
830
832
  function oe(r) {
831
833
  ie(), window.addEventListener("message", (t) => {
832
- try {
833
- const { eventType: e, eventData: s } = se(t.data);
834
- r(e, s);
835
- } catch {
836
- }
834
+ if (t.source === window.parent)
835
+ try {
836
+ const { eventType: e, eventData: s } = se(t.data);
837
+ r(e, s);
838
+ } catch {
839
+ }
837
840
  });
838
841
  }
839
842
  function ae() {
@@ -944,19 +947,19 @@ function U() {
944
947
  const r = window;
945
948
  return r[Q] === void 0 && (r[Q] = we()), r[Q];
946
949
  }
947
- function $(r, t) {
950
+ function T(r, t) {
948
951
  U().off(r, t);
949
952
  }
950
953
  function y(r, t) {
951
- return U().on(r, t), () => $(r, t);
954
+ return U().on(r, t), () => T(r, t);
952
955
  }
953
- function or(r, t) {
954
- return U().once(r, t), () => $(r, t);
956
+ function ir(r, t) {
957
+ return U().once(r, t), () => T(r, t);
955
958
  }
956
959
  function _e(r) {
957
960
  U().unsubscribe(r);
958
961
  }
959
- function ar(r) {
962
+ function or(r) {
960
963
  return U().subscribe(r), () => _e(r);
961
964
  }
962
965
  function be(r, t) {
@@ -971,7 +974,7 @@ function be(r, t) {
971
974
  function P(r, t) {
972
975
  return be(r, t) <= 0;
973
976
  }
974
- function R(r, t, e) {
977
+ function I(r, t, e) {
975
978
  if (typeof e == "string") {
976
979
  if (r === "web_app_open_link" && t === "try_instant_view")
977
980
  return P("6.4", e);
@@ -1005,12 +1008,12 @@ function R(r, t, e) {
1005
1008
  }
1006
1009
  }
1007
1010
  function E(r, t) {
1008
- return (e) => R(t[e], r);
1011
+ return (e) => I(t[e], r);
1009
1012
  }
1010
1013
  function St(r, t) {
1011
1014
  return (e) => {
1012
1015
  const [s, n] = t[e];
1013
- return R(s, n, r);
1016
+ return I(s, n, r);
1014
1017
  };
1015
1018
  }
1016
1019
  function d(r, t, e) {
@@ -1038,11 +1041,11 @@ function d(r, t, e) {
1038
1041
  }
1039
1042
  function me(r) {
1040
1043
  return (t, e) => {
1041
- if (!R(t, r))
1044
+ if (!I(t, r))
1042
1045
  throw new tt(t, r);
1043
- if (H(e)) {
1046
+ if (R(e)) {
1044
1047
  let s;
1045
- if (t === "web_app_open_link" && "try_instant_view" in e ? s = "try_instant_view" : t === "web_app_set_header_color" && "color" in e && (s = "color"), s && !R(t, s, r))
1048
+ if (t === "web_app_open_link" && "try_instant_view" in e ? s = "try_instant_view" : t === "web_app_set_header_color" && "color" in e && (s = "color"), s && !I(t, s, r))
1046
1049
  throw new et(t, s, r);
1047
1050
  }
1048
1051
  return d(t, e);
@@ -1053,7 +1056,7 @@ class J extends Error {
1053
1056
  super(`Async call timeout exceeded. Timeout: ${t}`), Object.setPrototypeOf(this, J.prototype);
1054
1057
  }
1055
1058
  }
1056
- function cr(r) {
1059
+ function ar(r) {
1057
1060
  return r instanceof J;
1058
1061
  }
1059
1062
  function ye(r) {
@@ -1074,10 +1077,10 @@ function xt(r, t) {
1074
1077
  }
1075
1078
  function m(r, t, e, s) {
1076
1079
  let n, i, a, c;
1077
- typeof t == "string" || Array.isArray(t) ? (a = Array.isArray(t) ? t : [t], n = e) : (i = t, a = Array.isArray(e) ? e : [e], n = s), H(i) && typeof i.req_id == "string" && (c = i.req_id);
1080
+ typeof t == "string" || Array.isArray(t) ? (a = Array.isArray(t) ? t : [t], n = e) : (i = t, a = Array.isArray(e) ? e : [e], n = s), R(i) && typeof i.req_id == "string" && (c = i.req_id);
1078
1081
  const { postEvent: p = d, timeout: h } = n || {}, g = n && "capture" in n ? n.capture : null, _ = () => new Promise((A, l) => {
1079
1082
  const C = a.map((v) => y(v, (M) => {
1080
- c && (!H(M) || M.req_id !== c) || typeof g == "function" && !g(M) || (x(), A(M));
1083
+ c && (!R(M) || M.req_id !== c) || typeof g == "function" && !g(M) || (x(), A(M));
1081
1084
  })), x = () => C.forEach((v) => v());
1082
1085
  try {
1083
1086
  p(r, i);
@@ -1117,7 +1120,7 @@ class Ce {
1117
1120
  * @param event - event name.
1118
1121
  * @param listener - event listener.
1119
1122
  */
1120
- o(this, "off", (t, e) => t === "click" ? $("back_button_pressed", e) : this.ee.off(t, e));
1123
+ o(this, "off", (t, e) => t === "click" ? T("back_button_pressed", e) : this.ee.off(t, e));
1121
1124
  /**
1122
1125
  * Checks if specified method is supported by current component.
1123
1126
  */
@@ -1158,16 +1161,13 @@ function ve(...r) {
1158
1161
  return typeof e == "string" ? s = e : typeof e == "object" && e !== null && (s = Object.entries(e).reduce((n, [i, a]) => a ? nt(n, i) : n, "")), nt(t, s);
1159
1162
  }, "");
1160
1163
  }
1161
- function Pe(r) {
1162
- return typeof r == "object" && r !== null && !Array.isArray(null);
1163
- }
1164
- function ur(...r) {
1165
- return r.reduce((t, e) => (Pe(e) && Object.entries(e).forEach(([s, n]) => {
1164
+ function cr(...r) {
1165
+ return r.reduce((t, e) => (R(e) && Object.entries(e).forEach(([s, n]) => {
1166
1166
  const i = ve(t[s], n);
1167
1167
  i.length > 0 && (t[s] = i);
1168
1168
  }), t), {});
1169
1169
  }
1170
- class ke {
1170
+ class Pe {
1171
1171
  constructor(t, e = d) {
1172
1172
  o(this, "ee", new w());
1173
1173
  o(this, "state");
@@ -1209,7 +1209,7 @@ class ke {
1209
1209
  function it(r, t) {
1210
1210
  return r.reduce((e, s) => (e[s] = t, e), {});
1211
1211
  }
1212
- class Se {
1212
+ class ke {
1213
1213
  constructor(t, e, s = d) {
1214
1214
  /**
1215
1215
  * Checks if specified method is supported by current component.
@@ -1278,7 +1278,7 @@ class Se {
1278
1278
  );
1279
1279
  }
1280
1280
  }
1281
- class xe {
1281
+ class Se {
1282
1282
  constructor(t, e = d) {
1283
1283
  /**
1284
1284
  * Checks if specified method is supported by current component.
@@ -1324,7 +1324,7 @@ class xe {
1324
1324
  this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
1325
1325
  }
1326
1326
  }
1327
- function qe() {
1327
+ function xe() {
1328
1328
  const r = document.createElement("style");
1329
1329
  r.id = "telegram-custom-styles", document.head.appendChild(r), y("set_custom_style", (t) => {
1330
1330
  r.innerHTML = t;
@@ -1333,26 +1333,26 @@ function qe() {
1333
1333
  function qt(r) {
1334
1334
  return `telegram-mini-apps-${r}`;
1335
1335
  }
1336
- function T(r, t) {
1336
+ function B(r, t) {
1337
1337
  sessionStorage.setItem(qt(r), JSON.stringify(t));
1338
1338
  }
1339
- function B(r) {
1339
+ function D(r) {
1340
1340
  const t = sessionStorage.getItem(qt(r));
1341
1341
  return t ? JSON.parse(t) : null;
1342
1342
  }
1343
- function Ae(r, t, e) {
1344
- const { isVisible: s = !1 } = r ? B("back-button") || {} : {}, n = new Ce(s, t, e);
1343
+ function qe(r, t, e) {
1344
+ const { isVisible: s = !1 } = r ? D("back-button") || {} : {}, n = new Ce(s, t, e);
1345
1345
  return n.on("change", () => {
1346
- T("back-button", { isVisible: n.isVisible });
1346
+ B("back-button", { isVisible: n.isVisible });
1347
1347
  }), n;
1348
1348
  }
1349
- function Ve(r, t) {
1350
- const { isConfirmationNeeded: e = !1 } = r ? B("closing-behavior") || {} : {}, s = new ke(e, t);
1351
- return s.on("change", () => T("closing-behavior", {
1349
+ function Ae(r, t) {
1350
+ const { isConfirmationNeeded: e = !1 } = r ? D("closing-behavior") || {} : {}, s = new Pe(e, t);
1351
+ return s.on("change", () => B("closing-behavior", {
1352
1352
  isConfirmationNeeded: s.isConfirmationNeeded
1353
1353
  })), s;
1354
1354
  }
1355
- class Re {
1355
+ class Ve {
1356
1356
  constructor(t) {
1357
1357
  o(this, "ee", new w());
1358
1358
  o(this, "state");
@@ -1373,7 +1373,7 @@ class Re {
1373
1373
  * @param event - event name.
1374
1374
  * @param listener - event listener.
1375
1375
  */
1376
- o(this, "off", (t, e) => t === "click" ? $("main_button_pressed", e) : this.ee.off(t, e));
1376
+ o(this, "off", (t, e) => t === "click" ? T("main_button_pressed", e) : this.ee.off(t, e));
1377
1377
  const {
1378
1378
  postEvent: e = d,
1379
1379
  text: s,
@@ -1517,7 +1517,7 @@ class Re {
1517
1517
  return this.state.set(t), this.commit(), this;
1518
1518
  }
1519
1519
  }
1520
- function Ie(r, t, e, s) {
1520
+ function Re(r, t, e, s) {
1521
1521
  const {
1522
1522
  backgroundColor: n = t,
1523
1523
  isEnabled: i = !1,
@@ -1525,7 +1525,7 @@ function Ie(r, t, e, s) {
1525
1525
  isLoaderVisible: c = !1,
1526
1526
  textColor: p = e,
1527
1527
  text: h = ""
1528
- } = r ? B("main-button") || {} : {}, g = new Re({
1528
+ } = r ? D("main-button") || {} : {}, g = new Ve({
1529
1529
  backgroundColor: n,
1530
1530
  isEnabled: i,
1531
1531
  isLoaderVisible: c,
@@ -1533,7 +1533,7 @@ function Ie(r, t, e, s) {
1533
1533
  postEvent: s,
1534
1534
  text: h,
1535
1535
  textColor: p
1536
- }), _ = () => T("main-button", {
1536
+ }), _ = () => B("main-button", {
1537
1537
  backgroundColor: g.backgroundColor,
1538
1538
  isEnabled: g.isEnabled,
1539
1539
  isLoaderVisible: g.isLoaderVisible,
@@ -1543,7 +1543,7 @@ function Ie(r, t, e, s) {
1543
1543
  });
1544
1544
  return g.on("change", _), g;
1545
1545
  }
1546
- const Le = X({
1546
+ const Ie = X({
1547
1547
  contact: f({
1548
1548
  userId: {
1549
1549
  type: q(),
@@ -1568,7 +1568,7 @@ const Le = X({
1568
1568
  },
1569
1569
  hash: u()
1570
1570
  });
1571
- class $e {
1571
+ class Le {
1572
1572
  constructor(t) {
1573
1573
  o(this, "ee", new w());
1574
1574
  o(this, "state");
@@ -1623,7 +1623,7 @@ class $e {
1623
1623
  postEvent: this.postEvent,
1624
1624
  timeout: 1e4
1625
1625
  }
1626
- ).then((t) => Le.parse(t));
1626
+ ).then((t) => Ie.parse(t));
1627
1627
  }
1628
1628
  /**
1629
1629
  * The Mini App background color.
@@ -1786,28 +1786,28 @@ class $e {
1786
1786
  });
1787
1787
  }
1788
1788
  }
1789
- function Te(r, t, e, s, n, i) {
1789
+ function $e(r, t, e, s, n, i) {
1790
1790
  const {
1791
1791
  backgroundColor: a = t,
1792
1792
  headerColor: c = "bg_color"
1793
- } = r ? B("mini-app") || {} : {}, p = new $e({
1793
+ } = r ? D("mini-app") || {} : {}, p = new Le({
1794
1794
  headerColor: c,
1795
1795
  backgroundColor: a,
1796
1796
  version: e,
1797
1797
  botInline: s,
1798
1798
  createRequestId: n,
1799
1799
  postEvent: i
1800
- }), h = () => T("mini-app", {
1800
+ }), h = () => B("mini-app", {
1801
1801
  backgroundColor: p.backgroundColor,
1802
1802
  headerColor: p.headerColor
1803
1803
  });
1804
1804
  return p.on("change", h), p;
1805
1805
  }
1806
- function Be() {
1806
+ function Te() {
1807
1807
  let r = 0;
1808
1808
  return () => (r += 1, r.toString());
1809
1809
  }
1810
- class De {
1810
+ class Be {
1811
1811
  constructor(t, e, s = d) {
1812
1812
  o(this, "ee", new w());
1813
1813
  o(this, "state");
@@ -1822,7 +1822,7 @@ class De {
1822
1822
  * @param event - event name.
1823
1823
  * @param listener - event listener.
1824
1824
  */
1825
- o(this, "off", (t, e) => t === "click" ? $("settings_button_pressed", e) : this.ee.off(t, e));
1825
+ o(this, "off", (t, e) => t === "click" ? T("settings_button_pressed", e) : this.ee.off(t, e));
1826
1826
  /**
1827
1827
  * Checks if specified method is supported by current component.
1828
1828
  */
@@ -1854,13 +1854,13 @@ class De {
1854
1854
  this.isVisible = !0;
1855
1855
  }
1856
1856
  }
1857
- function We(r, t, e) {
1858
- const { isVisible: s = !1 } = r ? B("settings-button") || {} : {}, n = new De(s, t, e);
1857
+ function De(r, t, e) {
1858
+ const { isVisible: s = !1 } = r ? D("settings-button") || {} : {}, n = new Be(s, t, e);
1859
1859
  return n.on("change", () => {
1860
- T("settings-button", { isVisible: n.isVisible });
1860
+ B("settings-button", { isVisible: n.isVisible });
1861
1861
  }), n;
1862
1862
  }
1863
- function Oe(r) {
1863
+ function We(r) {
1864
1864
  const t = new Mt(r);
1865
1865
  return t.listen(), t;
1866
1866
  }
@@ -1876,10 +1876,10 @@ async function At(r) {
1876
1876
  isStateStable: t.is_state_stable
1877
1877
  };
1878
1878
  }
1879
- function D(r) {
1879
+ function W(r) {
1880
1880
  return r < 0 ? 0 : r;
1881
1881
  }
1882
- class He {
1882
+ class Oe {
1883
1883
  constructor(t) {
1884
1884
  o(this, "ee", new w());
1885
1885
  o(this, "state");
@@ -1900,10 +1900,10 @@ class He {
1900
1900
  postEvent: a = d
1901
1901
  } = t;
1902
1902
  this.postEvent = a, this.state = new b({
1903
- height: D(e),
1903
+ height: W(e),
1904
1904
  isExpanded: s,
1905
- stableHeight: D(i),
1906
- width: D(n)
1905
+ stableHeight: W(i),
1906
+ width: W(n)
1907
1907
  }, this.ee);
1908
1908
  }
1909
1909
  /**
@@ -1969,9 +1969,9 @@ class He {
1969
1969
  is_expanded: n,
1970
1970
  is_state_stable: i
1971
1971
  } = t, a = {
1972
- height: D(e),
1972
+ height: W(e),
1973
1973
  isExpanded: n,
1974
- width: D(s)
1974
+ width: W(s)
1975
1975
  };
1976
1976
  i && (a.stableHeight = a.height), this.state.set(a);
1977
1977
  });
@@ -2008,21 +2008,21 @@ class He {
2008
2008
  return this.stableHeight === this.height;
2009
2009
  }
2010
2010
  }
2011
- function j(r) {
2012
- const t = new He(r);
2013
- return t.on("change", () => T("viewport", {
2011
+ function G(r) {
2012
+ const t = new Oe(r);
2013
+ return t.on("change", () => B("viewport", {
2014
2014
  height: t.height,
2015
2015
  isExpanded: t.isExpanded,
2016
2016
  stableHeight: t.stableHeight,
2017
2017
  width: t.width
2018
2018
  })), t.listen(), t;
2019
2019
  }
2020
- function Ue(r, t, e, s) {
2021
- const n = r ? B("viewport") : null;
2020
+ function He(r, t, e, s) {
2021
+ const n = r ? D("viewport") : null;
2022
2022
  if (n)
2023
- return j({ ...n, postEvent: e });
2023
+ return G({ ...n, postEvent: e });
2024
2024
  if (Ne(t))
2025
- return j({
2025
+ return G({
2026
2026
  height: window.innerHeight,
2027
2027
  isExpanded: !0,
2028
2028
  postEvent: e,
@@ -2033,12 +2033,12 @@ function Ue(r, t, e, s) {
2033
2033
  return At({
2034
2034
  postEvent: e,
2035
2035
  timeout: 5e3
2036
- }).then(({ height: a, isStateStable: c, ...p }) => j({
2036
+ }).then(({ height: a, isStateStable: c, ...p }) => G({
2037
2037
  ...p,
2038
2038
  height: a,
2039
2039
  stableHeight: c ? a : 0
2040
2040
  }));
2041
- const i = j({
2041
+ const i = G({
2042
2042
  width: 0,
2043
2043
  height: 0,
2044
2044
  isExpanded: !1,
@@ -2052,7 +2052,7 @@ function Ue(r, t, e, s) {
2052
2052
  function S(r, t) {
2053
2053
  document.documentElement.style.setProperty(r, t);
2054
2054
  }
2055
- function Me(r, t) {
2055
+ function Ue(r, t) {
2056
2056
  const e = () => {
2057
2057
  S("--tg-background-color", r.backgroundColor);
2058
2058
  }, s = () => {
@@ -2064,7 +2064,7 @@ function Me(r, t) {
2064
2064
  };
2065
2065
  t.on("change", s), r.on("change:backgroundColor", e), r.on("change:headerColor", s), e(), s();
2066
2066
  }
2067
- function je(r) {
2067
+ function Me(r) {
2068
2068
  const t = () => {
2069
2069
  const e = r.getState();
2070
2070
  Object.entries(e).forEach(([s, n]) => {
@@ -2089,9 +2089,9 @@ function Ge(r) {
2089
2089
  }
2090
2090
  function at(r, t, e, s) {
2091
2091
  const n = Ge(r);
2092
- n.miniApp && Me(t, e), n.themeParams && je(e), n.viewport && (s instanceof Promise ? s.then(ot) : ot(s));
2092
+ n.miniApp && Ue(t, e), n.themeParams && Me(e), n.viewport && (s instanceof Promise ? s.then(ot) : ot(s));
2093
2093
  }
2094
- function Fe(r) {
2094
+ function je(r) {
2095
2095
  const { hostname: t, pathname: e } = new URL(r, window.location.href);
2096
2096
  if (t !== "t.me")
2097
2097
  throw new Error(`Incorrect hostname: ${t}`);
@@ -2100,7 +2100,7 @@ function Fe(r) {
2100
2100
  throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
2101
2101
  return s[2];
2102
2102
  }
2103
- class ze {
2103
+ class Fe {
2104
2104
  constructor(t, e = d) {
2105
2105
  o(this, "ee", new w());
2106
2106
  o(this, "state");
@@ -2130,7 +2130,7 @@ class ze {
2130
2130
  async open(t, e) {
2131
2131
  if (this.isOpened)
2132
2132
  throw new Error("Invoice is already opened");
2133
- const s = e ? Fe(t) : t;
2133
+ const s = e ? je(t) : t;
2134
2134
  this.isOpened = !0;
2135
2135
  try {
2136
2136
  return (await m(
@@ -2149,7 +2149,7 @@ class ze {
2149
2149
  }
2150
2150
  }
2151
2151
  }
2152
- function Je(r) {
2152
+ function ze(r) {
2153
2153
  const t = r.message.trim(), e = (r.title || "").trim(), s = r.buttons || [];
2154
2154
  let n;
2155
2155
  if (e.length > 64)
@@ -2173,7 +2173,7 @@ function Je(r) {
2173
2173
  return { ...i, id: a };
2174
2174
  }), { title: e, message: t, buttons: n };
2175
2175
  }
2176
- class Qe {
2176
+ class Je {
2177
2177
  constructor(t, e = d) {
2178
2178
  o(this, "ee", new w());
2179
2179
  o(this, "state");
@@ -2218,7 +2218,7 @@ class Qe {
2218
2218
  throw new Error("Popup is already opened.");
2219
2219
  return this.isOpened = !0, m(
2220
2220
  "web_app_open_popup",
2221
- Je(t),
2221
+ ze(t),
2222
2222
  "popup_closed",
2223
2223
  { postEvent: this.postEvent }
2224
2224
  ).then(({ button_id: e = null }) => e).finally(() => {
@@ -2226,7 +2226,7 @@ class Qe {
2226
2226
  });
2227
2227
  }
2228
2228
  }
2229
- class Ze {
2229
+ class Qe {
2230
2230
  constructor(t, e = d) {
2231
2231
  o(this, "ee", new w());
2232
2232
  o(this, "state");
@@ -2285,7 +2285,7 @@ class Ze {
2285
2285
  }
2286
2286
  }
2287
2287
  }
2288
- class Ke {
2288
+ class Ze {
2289
2289
  constructor(t, e, s = d) {
2290
2290
  /**
2291
2291
  * Checks if specified method is supported by current component.
@@ -2312,7 +2312,7 @@ class Ke {
2312
2312
  */
2313
2313
  openLink(t, e) {
2314
2314
  const s = new URL(t, window.location.href).toString();
2315
- if (!R("web_app_open_link", this.version)) {
2315
+ if (!I("web_app_open_link", this.version)) {
2316
2316
  window.open(s, "_blank");
2317
2317
  return;
2318
2318
  }
@@ -2335,7 +2335,7 @@ class Ke {
2335
2335
  } = new URL(t, window.location.href);
2336
2336
  if (e !== "t.me")
2337
2337
  throw new Error(`URL has not allowed hostname: ${e}. Only "t.me" is allowed`);
2338
- if (!R("web_app_open_tg_link", this.version)) {
2338
+ if (!I("web_app_open_tg_link", this.version)) {
2339
2339
  window.location.href = t;
2340
2340
  return;
2341
2341
  }
@@ -2356,7 +2356,7 @@ class Ke {
2356
2356
  ).then(({ data: t = null }) => t);
2357
2357
  }
2358
2358
  }
2359
- function hr(r = {}) {
2359
+ function ur(r = {}) {
2360
2360
  const {
2361
2361
  async: t = !1,
2362
2362
  complete: e = t,
@@ -2374,22 +2374,22 @@ function hr(r = {}) {
2374
2374
  botInline: g = !1
2375
2375
  },
2376
2376
  isPageReload: _
2377
- } = Ct(), A = Be(), l = me(c);
2378
- vt() && (n && qe(), l("iframe_ready", { reload_supported: !0 }), y("reload_iframe", () => window.location.reload()));
2377
+ } = Ct(), A = Te(), l = me(c);
2378
+ vt() && (n && xe(), l("iframe_ready", { reload_supported: !0 }), y("reload_iframe", () => window.location.reload()));
2379
2379
  const C = {
2380
- backButton: Ae(_, c, l),
2381
- closingBehavior: Ve(_, l),
2382
- cloudStorage: new Se(c, A, l),
2380
+ backButton: qe(_, c, l),
2381
+ closingBehavior: Ae(_, l),
2382
+ cloudStorage: new ke(c, A, l),
2383
2383
  createRequestId: A,
2384
- hapticFeedback: new xe(c, l),
2385
- invoice: new ze(c, l),
2386
- mainButton: Ie(
2384
+ hapticFeedback: new Se(c, l),
2385
+ invoice: new Fe(c, l),
2386
+ mainButton: Re(
2387
2387
  _,
2388
2388
  h.buttonColor || "#000000",
2389
2389
  h.buttonTextColor || "#ffffff",
2390
2390
  l
2391
2391
  ),
2392
- miniApp: Te(
2392
+ miniApp: $e(
2393
2393
  _,
2394
2394
  h.backgroundColor || "#ffffff",
2395
2395
  c,
@@ -2397,17 +2397,17 @@ function hr(r = {}) {
2397
2397
  A,
2398
2398
  l
2399
2399
  ),
2400
- popup: new Qe(c, l),
2400
+ popup: new Je(c, l),
2401
2401
  postEvent: l,
2402
- qrScanner: new Ze(c, l),
2403
- settingsButton: We(_, c, l),
2404
- themeParams: Oe(h),
2405
- utils: new Ke(c, A, l),
2402
+ qrScanner: new Qe(c, l),
2403
+ settingsButton: De(_, c, l),
2404
+ themeParams: We(h),
2405
+ utils: new Ze(c, A, l),
2406
2406
  ...i ? {
2407
- initData: new Ot(i),
2407
+ initData: new Nt(i),
2408
2408
  initDataRaw: a
2409
2409
  } : {}
2410
- }, x = Ue(_, p, l, e);
2410
+ }, x = He(_, p, l, e);
2411
2411
  return x instanceof Promise || e ? Promise.resolve(x).then((v) => (at(
2412
2412
  s,
2413
2413
  C.miniApp,
@@ -2425,14 +2425,14 @@ function hr(r = {}) {
2425
2425
  throw i;
2426
2426
  }
2427
2427
  }
2428
- function W(r, t) {
2428
+ function N(r, t) {
2429
2429
  return r.startsWith(t) ? r : `${t}${r}`;
2430
2430
  }
2431
- function pr(r) {
2431
+ function hr(r) {
2432
2432
  const t = r.match(/#(.+)/);
2433
2433
  return t ? t[1] : null;
2434
2434
  }
2435
- async function N(r) {
2435
+ async function H(r) {
2436
2436
  return r === 0 ? !0 : Promise.race([
2437
2437
  new Promise((t) => {
2438
2438
  window.addEventListener("popstate", function e() {
@@ -2445,14 +2445,14 @@ async function N(r) {
2445
2445
  })
2446
2446
  ]);
2447
2447
  }
2448
- async function Ye() {
2449
- if (window.history.length <= 1 || (window.history.pushState(null, ""), await N(1 - window.history.length)))
2448
+ async function Ke() {
2449
+ if (window.history.length <= 1 || (window.history.pushState(null, ""), await H(1 - window.history.length)))
2450
2450
  return;
2451
- let t = await N(-1);
2451
+ let t = await H(-1);
2452
2452
  for (; t; )
2453
- t = await N(-1);
2453
+ t = await H(-1);
2454
2454
  }
2455
- class Xe {
2455
+ class Ye {
2456
2456
  constructor(t, e, {
2457
2457
  debug: s = !1,
2458
2458
  loggerPrefix: n = "Navigator"
@@ -2467,9 +2467,9 @@ class Xe {
2467
2467
  if (!i.startsWith("/") && i.length > 0)
2468
2468
  throw new Error('Pathname should start with "/"');
2469
2469
  return {
2470
- pathname: W(i, "/"),
2471
- search: a ? W(a, "?") : "",
2472
- hash: c ? W(c, "#") : ""
2470
+ pathname: N(i, "/"),
2471
+ search: a ? N(a, "?") : "",
2472
+ hash: c ? N(c, "#") : ""
2473
2473
  };
2474
2474
  }), this.logger = new Pt(`[${n}]`, s);
2475
2475
  }
@@ -2487,7 +2487,7 @@ class Xe {
2487
2487
  search: c,
2488
2488
  hash: p
2489
2489
  } = t;
2490
- e = a + (c ? W(c, "?") : "") + (p ? W(p, "#") : "");
2490
+ e = a + (c ? N(c, "?") : "") + (p ? N(p, "#") : "");
2491
2491
  }
2492
2492
  const {
2493
2493
  pathname: s,
@@ -2652,7 +2652,7 @@ class Xe {
2652
2652
  }
2653
2653
  }
2654
2654
  const ct = 0, Z = 1, K = 2;
2655
- class Vt extends Xe {
2655
+ class Vt extends Ye {
2656
2656
  constructor(e, s, n = {}) {
2657
2657
  super(e, s, {
2658
2658
  ...n,
@@ -2716,7 +2716,7 @@ class Vt extends Xe {
2716
2716
  async syncHistory() {
2717
2717
  window.removeEventListener("popstate", this.onPopState);
2718
2718
  const e = `#${this.path}`;
2719
- await Ye(), d("web_app_setup_back_button", { is_visible: this.canGoBack }), this.canGoBack && this.canGoForward ? (this.logger.log("Setting up history: [<-, *, ->]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", e), window.history.pushState(K, ""), await N(-1)) : this.canGoBack ? (this.logger.log("Setting up history: [<-, *]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", e)) : this.canGoForward ? (this.logger.log("Setting up history: [*, ->]"), window.history.replaceState(null, e), window.history.pushState(K, ""), await N(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ct, ""), window.history.pushState(null, "", e)), window.addEventListener("popstate", this.onPopState);
2719
+ await Ke(), d("web_app_setup_back_button", { is_visible: this.canGoBack }), this.canGoBack && this.canGoForward ? (this.logger.log("Setting up history: [<-, *, ->]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", e), window.history.pushState(K, ""), await H(-1)) : this.canGoBack ? (this.logger.log("Setting up history: [<-, *]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", e)) : this.canGoForward ? (this.logger.log("Setting up history: [*, ->]"), window.history.replaceState(null, e), window.history.pushState(K, ""), await H(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ct, ""), window.history.pushState(null, "", e)), window.addEventListener("popstate", this.onPopState);
2720
2720
  }
2721
2721
  emitChanged(e, s) {
2722
2722
  this.ee.emit("change", {
@@ -2736,31 +2736,31 @@ class Vt extends Xe {
2736
2736
  * Detaches current navigator from the browser history.
2737
2737
  */
2738
2738
  detach() {
2739
- this.attached && (this.logger.log("Detaching", this), this.attached = !1, window.removeEventListener("popstate", this.onPopState), $("back_button_pressed", this.back));
2739
+ this.attached && (this.logger.log("Detaching", this), this.attached = !1, window.removeEventListener("popstate", this.onPopState), T("back_button_pressed", this.back));
2740
2740
  }
2741
2741
  }
2742
2742
  export {
2743
2743
  Ce as BackButton,
2744
- ke as ClosingBehavior,
2745
- Se as CloudStorage,
2746
- xe as HapticFeedback,
2744
+ Pe as ClosingBehavior,
2745
+ ke as CloudStorage,
2746
+ Se as HapticFeedback,
2747
2747
  Vt as HashNavigator,
2748
- Ot as InitData,
2749
- ze as Invoice,
2750
- Re as MainButton,
2748
+ Nt as InitData,
2749
+ Fe as Invoice,
2750
+ Ve as MainButton,
2751
2751
  tt as MethodUnsupportedError,
2752
- $e as MiniApp,
2753
- Xe as Navigator,
2752
+ Le as MiniApp,
2753
+ Ye as Navigator,
2754
2754
  et as ParameterUnsupportedError,
2755
2755
  F as ParseError,
2756
- G as ParseSchemaFieldError,
2757
- Qe as Popup,
2758
- Ze as QRScanner,
2759
- De as SettingsButton,
2756
+ j as ParseSchemaFieldError,
2757
+ Je as Popup,
2758
+ Qe as QRScanner,
2759
+ Be as SettingsButton,
2760
2760
  Mt as ThemeParams,
2761
2761
  J as TimeoutError,
2762
- Ke as Utils,
2763
- He as Viewport,
2762
+ Ze as Utils,
2763
+ Oe as Viewport,
2764
2764
  Bt as array,
2765
2765
  k as boolean,
2766
2766
  Wt as chatParser,
@@ -2768,43 +2768,43 @@ export {
2768
2768
  be as compareVersions,
2769
2769
  me as createPostEvent,
2770
2770
  pt as date,
2771
- pr as getHash,
2772
- hr as init,
2771
+ hr as getHash,
2772
+ ur as init,
2773
2773
  wt as initDataParser,
2774
2774
  O as invokeCustomMethod,
2775
2775
  ft as isColorDark,
2776
2776
  vt as isIframe,
2777
2777
  lt as isRGB,
2778
2778
  Dt as isRGBShort,
2779
- H as isRecord,
2779
+ R as isRecord,
2780
2780
  Ne as isStableViewportPlatform,
2781
- sr as isTMA,
2782
- cr as isTimeoutError,
2781
+ rr as isTMA,
2782
+ ar as isTimeoutError,
2783
2783
  f as json,
2784
2784
  mt as launchParamsParser,
2785
- ur as mergeClassNames,
2785
+ cr as mergeClassNames,
2786
2786
  q as number,
2787
- $ as off,
2787
+ T as off,
2788
2788
  y as on,
2789
- or as once,
2790
- er as parseInitData,
2791
- jt as parseLaunchParams,
2789
+ ir as once,
2790
+ tr as parseInitData,
2791
+ Gt as parseLaunchParams,
2792
2792
  se as parseMessage,
2793
2793
  bt as parseThemeParams,
2794
2794
  d as postEvent,
2795
2795
  m as request,
2796
- rr as requestThemeParams,
2796
+ er as requestThemeParams,
2797
2797
  At as requestViewport,
2798
2798
  Ct as retrieveLaunchData,
2799
2799
  gt as rgb,
2800
2800
  X as searchParams,
2801
2801
  Jt as serializeLaunchParams,
2802
2802
  Ut as serializeThemeParams,
2803
- nr as setDebug,
2804
- ir as setTargetOrigin,
2803
+ sr as setDebug,
2804
+ nr as setTargetOrigin,
2805
2805
  u as string,
2806
- ar as subscribe,
2807
- R as supports,
2806
+ or as subscribe,
2807
+ I as supports,
2808
2808
  _t as themeParamsParser,
2809
2809
  dt as toRGB,
2810
2810
  _e as unsubscribe,