@tma.js/sdk 1.2.1 → 1.4.0

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.
Files changed (97) hide show
  1. package/dist/dts/index.d.ts +1 -1
  2. package/dist/dts/init/creators/createViewport.d.ts +2 -9
  3. package/dist/dts/init/init.d.ts +2 -0
  4. package/dist/dts/init/types.d.ts +7 -4
  5. package/dist/dts/launch-params/index.d.ts +1 -0
  6. package/dist/dts/launch-params/retrieveFromUrl.d.ts +6 -0
  7. package/dist/dts/launch-params/types.d.ts +12 -8
  8. package/dist/dts/types/platform.d.ts +1 -1
  9. package/dist/dts/viewport/index.d.ts +1 -0
  10. package/dist/dts/viewport/isStableViewportPlatform.d.ts +7 -0
  11. package/dist/index.cjs +1 -1
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.iife.js +1 -1
  14. package/dist/index.iife.js.map +1 -1
  15. package/dist/index.mjs +469 -467
  16. package/dist/index.mjs.map +1 -1
  17. package/package.json +2 -2
  18. package/src/__tests__/globals.ts +39 -0
  19. package/src/back-button/__tests__/BackButton.ts +129 -0
  20. package/src/bridge/__tests__/request.ts +236 -0
  21. package/src/bridge/env/__tests__/hasExternalNotify.ts +15 -0
  22. package/src/bridge/env/__tests__/hasWebviewProxy.ts +15 -0
  23. package/src/bridge/env/__tests__/isIframe.ts +30 -0
  24. package/src/bridge/events/__tests__/createEmitter.ts +143 -0
  25. package/src/bridge/events/__tests__/off.ts +34 -0
  26. package/src/bridge/events/__tests__/on.ts +49 -0
  27. package/src/bridge/events/__tests__/onTelegramEvent.ts +51 -0
  28. package/src/bridge/events/__tests__/once.ts +64 -0
  29. package/src/bridge/events/__tests__/singletonEmitter.ts +22 -0
  30. package/src/bridge/events/__tests__/subscribe.ts +49 -0
  31. package/src/bridge/events/__tests__/unsubscribe.ts +34 -0
  32. package/src/bridge/events/parsers/__tests__/clipboardTextReceived.ts +21 -0
  33. package/src/bridge/events/parsers/__tests__/invoiceClosed.ts +12 -0
  34. package/src/bridge/events/parsers/__tests__/popupClosed.ts +10 -0
  35. package/src/bridge/events/parsers/__tests__/qrTextReceived.ts +9 -0
  36. package/src/bridge/events/parsers/__tests__/theme-changed.ts +42 -0
  37. package/src/bridge/events/parsers/__tests__/viewportChanged.ts +49 -0
  38. package/src/bridge/methods/__tests__/createPostEvent.ts +37 -0
  39. package/src/bridge/methods/__tests__/postEvent.ts +137 -0
  40. package/src/classnames/__tests__/classNames.ts +20 -0
  41. package/src/classnames/__tests__/mergeClassNames.ts +21 -0
  42. package/src/closing-behavior/__tests__/ClosingBehavior.ts +86 -0
  43. package/src/colors/__tests__/isColorDark.ts +12 -0
  44. package/src/colors/__tests__/isRGB.ts +13 -0
  45. package/src/colors/__tests__/isRGBShort.ts +13 -0
  46. package/src/colors/__tests__/toRGB.ts +23 -0
  47. package/src/event-emitter/__tests__/EventEmitter.ts +145 -0
  48. package/src/haptic-feedback/__tests__/HapticFeedback.ts +68 -0
  49. package/src/index.ts +1 -0
  50. package/src/init/creators/__tests__/createViewport.ts +96 -0
  51. package/src/init/creators/createViewport.ts +60 -81
  52. package/src/init/init.ts +13 -15
  53. package/src/init/types.ts +8 -4
  54. package/src/init-data/__tests__/InitData.ts +98 -0
  55. package/src/init-data/__tests__/chatParser.ts +102 -0
  56. package/src/init-data/__tests__/initDataParser.ts +136 -0
  57. package/src/init-data/__tests__/parseInitData.ts +136 -0
  58. package/src/init-data/__tests__/userParser.ts +96 -0
  59. package/src/launch-params/__tests__/retrieveFromUrl.ts +19 -0
  60. package/src/launch-params/index.ts +1 -0
  61. package/src/launch-params/launchParamsParser.ts +4 -0
  62. package/src/launch-params/retrieveFromLocation.ts +2 -2
  63. package/src/launch-params/retrieveFromPerformance.ts +2 -7
  64. package/src/launch-params/retrieveFromUrl.ts +19 -0
  65. package/src/launch-params/types.ts +13 -8
  66. package/src/logger/__tests__/Logger.ts +107 -0
  67. package/src/main-button/__tests__/MainButton.ts +346 -0
  68. package/src/mini-app/__tests__/MiniApp.ts +140 -0
  69. package/src/misc/__tests__/isRecord.ts +21 -0
  70. package/src/navigation/HashNavigator/__tests__/HashNavigator.ts +144 -0
  71. package/src/navigation/HashNavigator/__tests__/drop.ts +42 -0
  72. package/src/navigation/HashNavigator/__tests__/go.ts +9 -0
  73. package/src/parsing/__tests__/ArrayValueParser.ts +18 -0
  74. package/src/parsing/__tests__/toRecord.ts +10 -0
  75. package/src/parsing/parsers/__tests__/array.ts +39 -0
  76. package/src/parsing/parsers/__tests__/boolean.ts +31 -0
  77. package/src/parsing/parsers/__tests__/date.ts +25 -0
  78. package/src/parsing/parsers/__tests__/json.ts +80 -0
  79. package/src/parsing/parsers/__tests__/number.ts +23 -0
  80. package/src/parsing/parsers/__tests__/rgb.ts +22 -0
  81. package/src/parsing/parsers/__tests__/searchParams.ts +105 -0
  82. package/src/parsing/parsers/__tests__/string.ts +25 -0
  83. package/src/popup/__tests__/Popup.ts +130 -0
  84. package/src/popup/__tests__/preparePopupParams.ts +85 -0
  85. package/src/supports/__tests__/supports.ts +123 -0
  86. package/src/theme-params/__tests__/keys.ts +19 -0
  87. package/src/theme-params/__tests__/parseThemeParams.ts +29 -0
  88. package/src/theme-params/__tests__/serializeThemeParams.ts +29 -0
  89. package/src/theme-params/__tests__/themeParamsParser.ts +29 -0
  90. package/src/timeout/__tests__/isTimeoutError.ts +9 -0
  91. package/src/timeout/__tests__/withTimeout.ts +28 -0
  92. package/src/types/platform.ts +2 -2
  93. package/src/version/__tests__/compareVersions.ts +19 -0
  94. package/src/viewport/__tests__/isStableViewportPlatform.ts +15 -0
  95. package/src/viewport/__tests__/utils.ts +12 -0
  96. package/src/viewport/index.ts +1 -0
  97. package/src/viewport/isStableViewportPlatform.ts +10 -0
package/dist/index.mjs CHANGED
@@ -1,17 +1,17 @@
1
- var $t = Object.defineProperty;
2
- var Tt = (r, t, e) => t in r ? $t(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var o = (r, t, e) => (Tt(r, typeof t != "symbol" ? t + "" : t, e), e);
1
+ var Rt = Object.defineProperty;
2
+ var It = (r, t, e) => t in r ? Rt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var o = (r, t, e) => (It(r, typeof t != "symbol" ? t + "" : t, e), e);
4
4
  function H(r) {
5
5
  return typeof r == "object" && r !== null && !Array.isArray(r);
6
6
  }
7
- function ht() {
7
+ function ut() {
8
8
  return performance.getEntriesByType("navigation")[0] || null;
9
9
  }
10
- function Bt() {
11
- const r = ht();
10
+ function Lt() {
11
+ const r = ut();
12
12
  return r ? r.type === "reload" : null;
13
13
  }
14
- function R() {
14
+ function I() {
15
15
  return new TypeError("Value has unexpected type");
16
16
  }
17
17
  class F extends Error {
@@ -40,7 +40,7 @@ class z {
40
40
  return this.isOptional = !0, this;
41
41
  }
42
42
  }
43
- function Dt(r) {
43
+ function $t(r) {
44
44
  if (Array.isArray(r))
45
45
  return r;
46
46
  if (typeof r == "string")
@@ -50,11 +50,11 @@ function Dt(r) {
50
50
  return t;
51
51
  } catch {
52
52
  }
53
- throw R();
53
+ throw I();
54
54
  }
55
- class Wt extends z {
55
+ class Tt extends z {
56
56
  constructor(e, s, n) {
57
- super(Dt, s, n);
57
+ super($t, s, n);
58
58
  o(this, "itemParser");
59
59
  this.itemParser = typeof e == "function" ? e : e.parse.bind(e);
60
60
  }
@@ -66,15 +66,15 @@ class Wt extends z {
66
66
  return this.itemParser = typeof e == "function" ? e : e.parse.bind(e), this;
67
67
  }
68
68
  }
69
- function V(r, t) {
69
+ function L(r, t) {
70
70
  return () => new z(r, !1, t);
71
71
  }
72
- class j extends Error {
72
+ class G 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, j.prototype);
74
+ super(`Unable to parse field "${t}"${s ? ` as ${s}` : ""}`, { cause: e }), Object.setPrototypeOf(this, G.prototype);
75
75
  }
76
76
  }
77
- function ut(r, t) {
77
+ function ht(r, t) {
78
78
  const e = {};
79
79
  for (const s in r) {
80
80
  const n = r[s];
@@ -84,27 +84,27 @@ function ut(r, t) {
84
84
  if (typeof n == "function" || "parse" in n)
85
85
  i = s, a = typeof n == "function" ? n : n.parse.bind(n);
86
86
  else {
87
- const { type: p } = n;
88
- i = n.from || s, a = typeof p == "function" ? p : p.parse.bind(p);
87
+ const { type: h } = n;
88
+ i = n.from || s, a = typeof h == "function" ? h : h.parse.bind(h);
89
89
  }
90
90
  let c;
91
- const u = t(i);
91
+ const p = t(i);
92
92
  try {
93
- c = a(u);
94
- } catch (p) {
95
- throw p instanceof F ? new j(i, {
96
- type: p.type,
97
- cause: p
98
- }) : new j(i, { cause: p });
93
+ c = a(p);
94
+ } catch (h) {
95
+ throw h instanceof F ? new G(i, {
96
+ type: h.type,
97
+ cause: h
98
+ }) : new G(i, { cause: h });
99
99
  }
100
100
  c !== void 0 && (e[s] = c);
101
101
  }
102
102
  return e;
103
103
  }
104
- function Nt(r) {
105
- return new Wt((t) => t, !1, r);
104
+ function Bt(r) {
105
+ return new Tt((t) => t, !1, r);
106
106
  }
107
- const P = V((r) => {
107
+ const k = L((r) => {
108
108
  if (typeof r == "boolean")
109
109
  return r;
110
110
  const t = String(r);
@@ -112,8 +112,8 @@ const P = V((r) => {
112
112
  return !0;
113
113
  if (t === "0" || t === "false")
114
114
  return !1;
115
- throw R();
116
- }, "boolean"), k = V((r) => {
115
+ throw I();
116
+ }, "boolean"), q = L((r) => {
117
117
  if (typeof r == "number")
118
118
  return r;
119
119
  if (typeof r == "string") {
@@ -121,31 +121,31 @@ const P = V((r) => {
121
121
  if (!Number.isNaN(t))
122
122
  return t;
123
123
  }
124
- throw R();
125
- }, "number"), pt = V((r) => r instanceof Date ? r : new Date(k().parse(r) * 1e3), "Date");
124
+ throw I();
125
+ }, "number"), pt = L((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 R();
129
+ throw I();
130
130
  return t;
131
131
  }
132
- function g(r, t) {
132
+ function f(r, t) {
133
133
  return new z((e) => {
134
134
  const s = Y(e);
135
- return ut(r, (n) => s[n]);
135
+ return ht(r, (n) => s[n]);
136
136
  }, !1, t);
137
137
  }
138
138
  function lt(r) {
139
139
  return /^#[\da-f]{6}$/i.test(r);
140
140
  }
141
- function Ot(r) {
141
+ function Dt(r) {
142
142
  return /^#[\da-f]{3}$/i.test(r);
143
143
  }
144
144
  function dt(r) {
145
145
  const t = r.replace(/\s/g, "").toLowerCase();
146
146
  if (lt(t))
147
147
  return t;
148
- if (Ot(t)) {
148
+ if (Dt(t)) {
149
149
  let s = "#";
150
150
  for (let n = 0; n < 3; n += 1)
151
151
  s += t[1 + n].repeat(2);
@@ -168,35 +168,35 @@ function ft(r) {
168
168
  }, 0)
169
169
  ) < 120;
170
170
  }
171
- const h = V((r) => {
171
+ const u = L((r) => {
172
172
  if (typeof r == "string" || typeof r == "number")
173
173
  return r.toString();
174
- throw R();
175
- }, "string"), gt = V((r) => dt(h().parse(r)), "rgb");
174
+ throw I();
175
+ }, "string"), gt = L((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 R();
179
+ throw I();
180
180
  const s = typeof e == "string" ? new URLSearchParams(e) : e;
181
- return ut(r, (n) => {
181
+ return ht(r, (n) => {
182
182
  const i = s.get(n);
183
183
  return i === null ? void 0 : i;
184
184
  });
185
185
  }, !1, t);
186
186
  }
187
- function Ht() {
188
- return g({
189
- id: k(),
190
- type: h(),
191
- title: h(),
187
+ function Wt() {
188
+ return f({
189
+ id: q(),
190
+ type: u(),
191
+ title: u(),
192
192
  photoUrl: {
193
- type: h().optional(),
193
+ type: u().optional(),
194
194
  from: "photo_url"
195
195
  },
196
- username: h().optional()
196
+ username: u().optional()
197
197
  }, "Chat");
198
198
  }
199
- class Ut {
199
+ class Ot {
200
200
  constructor(t) {
201
201
  this.initData = t;
202
202
  }
@@ -270,41 +270,41 @@ class Ut {
270
270
  }
271
271
  }
272
272
  function rt() {
273
- return g({
273
+ return f({
274
274
  addedToAttachmentMenu: {
275
- type: P().optional(),
275
+ type: k().optional(),
276
276
  from: "added_to_attachment_menu"
277
277
  },
278
278
  allowsWriteToPm: {
279
- type: P().optional(),
279
+ type: k().optional(),
280
280
  from: "allows_write_to_pm"
281
281
  },
282
282
  firstName: {
283
- type: h(),
283
+ type: u(),
284
284
  from: "first_name"
285
285
  },
286
- id: k(),
286
+ id: q(),
287
287
  isBot: {
288
- type: P().optional(),
288
+ type: k().optional(),
289
289
  from: "is_bot"
290
290
  },
291
291
  isPremium: {
292
- type: P().optional(),
292
+ type: k().optional(),
293
293
  from: "is_premium"
294
294
  },
295
295
  languageCode: {
296
- type: h().optional(),
296
+ type: u().optional(),
297
297
  from: "language_code"
298
298
  },
299
299
  lastName: {
300
- type: h().optional(),
300
+ type: u().optional(),
301
301
  from: "last_name"
302
302
  },
303
303
  photoUrl: {
304
- type: h().optional(),
304
+ type: u().optional(),
305
305
  from: "photo_url"
306
306
  },
307
- username: h().optional()
307
+ username: u().optional()
308
308
  }, "User");
309
309
  }
310
310
  function wt() {
@@ -314,56 +314,56 @@ function wt() {
314
314
  from: "auth_date"
315
315
  },
316
316
  canSendAfter: {
317
- type: k().optional(),
317
+ type: q().optional(),
318
318
  from: "can_send_after"
319
319
  },
320
- chat: Ht().optional(),
320
+ chat: Wt().optional(),
321
321
  chatInstance: {
322
- type: h().optional(),
322
+ type: u().optional(),
323
323
  from: "chat_instance"
324
324
  },
325
325
  chatType: {
326
- type: h().optional(),
326
+ type: u().optional(),
327
327
  from: "chat_type"
328
328
  },
329
- hash: h(),
329
+ hash: u(),
330
330
  queryId: {
331
- type: h().optional(),
331
+ type: u().optional(),
332
332
  from: "query_id"
333
333
  },
334
334
  receiver: rt().optional(),
335
335
  startParam: {
336
- type: h().optional(),
336
+ type: u().optional(),
337
337
  from: "start_param"
338
338
  },
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 Mt(r) {
345
+ function Nt(r) {
346
346
  return r.replace(/(^|_)bg/, (t, e) => `${e}background`).replace(/_([a-z])/g, (t, e) => e.toUpperCase());
347
347
  }
348
- function jt(r) {
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 = V(
351
+ const _t = L(
352
352
  (r) => {
353
353
  const t = gt().optional();
354
- return Object.entries(Y(r)).reduce((e, [s, n]) => (e[Mt(s)] = t.parse(n), e), {});
354
+ return Object.entries(Y(r)).reduce((e, [s, n]) => (e[Nt(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
- function Gt(r) {
364
+ function Ut(r) {
365
365
  return JSON.stringify(
366
- Object.entries(r).reduce((t, [e, s]) => (s && (t[jt(e)] = s), t), {})
366
+ Object.entries(r).reduce((t, [e, s]) => (s && (t[Ht(e)] = s), t), {})
367
367
  );
368
368
  }
369
369
  class w {
@@ -448,7 +448,7 @@ class w {
448
448
  }
449
449
  }
450
450
  }
451
- class _ {
451
+ class b {
452
452
  constructor(t, e) {
453
453
  this.state = t, this.ee = e;
454
454
  }
@@ -478,7 +478,7 @@ class _ {
478
478
  return this.state[t];
479
479
  }
480
480
  }
481
- class Ft {
481
+ class Mt {
482
482
  constructor(t) {
483
483
  o(this, "ee", new w());
484
484
  o(this, "state");
@@ -490,7 +490,7 @@ class Ft {
490
490
  * Removes event listener.
491
491
  */
492
492
  o(this, "off", this.ee.off.bind(this.ee));
493
- this.state = new _(t, this.ee);
493
+ this.state = new b(t, this.ee);
494
494
  }
495
495
  /**
496
496
  * @since v6.10
@@ -579,7 +579,7 @@ class Ft {
579
579
  function mt() {
580
580
  return X({
581
581
  botInline: {
582
- type: P().optional(),
582
+ type: k().optional(),
583
583
  from: "tgWebAppBotInline"
584
584
  },
585
585
  initData: {
@@ -587,54 +587,59 @@ function mt() {
587
587
  from: "tgWebAppData"
588
588
  },
589
589
  initDataRaw: {
590
- type: h().optional(),
590
+ type: u().optional(),
591
591
  from: "tgWebAppData"
592
592
  },
593
593
  platform: {
594
- type: h(),
594
+ type: u(),
595
595
  from: "tgWebAppPlatform"
596
596
  },
597
597
  showSettings: {
598
- type: P().optional(),
598
+ type: k().optional(),
599
599
  from: "tgWebAppShowSettings"
600
600
  },
601
+ startParam: {
602
+ type: u().optional(),
603
+ from: "tgWebAppStartParam"
604
+ },
601
605
  themeParams: {
602
606
  type: _t(),
603
607
  from: "tgWebAppThemeParams"
604
608
  },
605
609
  version: {
606
- type: h(),
610
+ type: u(),
607
611
  from: "tgWebAppVersion"
608
612
  }
609
613
  }, "LaunchParams");
610
614
  }
611
- function yt(r) {
615
+ function jt(r) {
612
616
  return mt().parse(r);
613
617
  }
614
- function zt() {
615
- return yt(window.location.hash.slice(1));
618
+ function yt(r) {
619
+ const t = r.includes("?") ? r.replace("#", "&").slice(r.indexOf("?") + 1) : r.slice(r.indexOf("#") + 1);
620
+ return jt(t);
621
+ }
622
+ function Gt() {
623
+ return yt(window.location.href);
616
624
  }
617
- function Jt() {
618
- const r = ht();
625
+ function Ft() {
626
+ const r = ut();
619
627
  if (!r)
620
628
  throw new Error("Unable to get first navigation entry.");
621
- const t = r.name.match(/#(.*)/);
622
- if (!t)
623
- throw new Error("First navigation entry does not contain hash part.");
624
- return yt(t[1]);
629
+ return yt(r.name);
625
630
  }
626
- function Qt() {
631
+ function zt() {
627
632
  try {
628
- return Jt();
633
+ return Ft();
629
634
  } catch {
630
635
  }
631
636
  try {
632
- return zt();
637
+ return Gt();
633
638
  } catch {
634
639
  }
635
640
  return null;
636
641
  }
637
- function Zt(r) {
642
+ function Jt(r) {
638
643
  const {
639
644
  initDataRaw: t,
640
645
  themeParams: e,
@@ -643,30 +648,30 @@ function Zt(r) {
643
648
  showSettings: i,
644
649
  botInline: a
645
650
  } = r, c = new URLSearchParams();
646
- return t && c.set("tgWebAppData", t), c.set("tgWebAppPlatform", s), c.set("tgWebAppThemeParams", Gt(e)), c.set("tgWebAppVersion", n), typeof i == "boolean" && c.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && c.set("tgWebAppBotInline", a ? "1" : "0"), c.toString();
651
+ return t && c.set("tgWebAppData", t), c.set("tgWebAppPlatform", s), c.set("tgWebAppThemeParams", Ut(e)), c.set("tgWebAppVersion", n), typeof i == "boolean" && c.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && c.set("tgWebAppBotInline", a ? "1" : "0"), c.toString();
647
652
  }
648
653
  const Et = "telegram-mini-apps-launch-params";
649
- function Kt() {
654
+ function Qt() {
650
655
  const r = sessionStorage.getItem(Et);
651
656
  return r ? mt().parse(r) : null;
652
657
  }
653
- function Yt(r) {
654
- sessionStorage.setItem(Et, Zt(r));
658
+ function Zt(r) {
659
+ sessionStorage.setItem(Et, Jt(r));
655
660
  }
656
- function Xt() {
661
+ function Kt() {
657
662
  try {
658
663
  return window.self !== window.top;
659
664
  } catch {
660
665
  return !0;
661
666
  }
662
667
  }
663
- function te() {
664
- const r = Kt(), t = Qt(), e = Bt();
668
+ function Yt() {
669
+ const r = Qt(), t = zt(), e = Lt();
665
670
  if (r) {
666
671
  if (t)
667
672
  return {
668
673
  launchParams: t,
669
- isPageReload: Xt() ? e || r.initDataRaw === t.initDataRaw : !0
674
+ isPageReload: Kt() ? e || r.initDataRaw === t.initDataRaw : !0
670
675
  };
671
676
  if (e)
672
677
  return {
@@ -687,20 +692,20 @@ function Ct() {
687
692
  const r = window[st];
688
693
  if (r)
689
694
  return r;
690
- const t = te();
691
- return window[st] = t, Yt(t.launchParams), t;
695
+ const t = Yt();
696
+ return window[st] = t, Zt(t.launchParams), t;
692
697
  }
693
- function sr() {
698
+ function rr() {
694
699
  try {
695
700
  return Ct(), !0;
696
701
  } catch {
697
702
  return !1;
698
703
  }
699
704
  }
700
- function ee(r) {
705
+ function Xt(r) {
701
706
  return "external" in r && H(r.external) && "notify" in r.external && typeof r.external.notify == "function";
702
707
  }
703
- function re(r) {
708
+ function te(r) {
704
709
  return "TelegramWebviewProxy" in r && H(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
705
710
  }
706
711
  function vt() {
@@ -775,31 +780,31 @@ class Pt {
775
780
  this.print("warn", ...t);
776
781
  }
777
782
  }
778
- let St = "https://web.telegram.org";
779
- const q = new Pt("[SDK]", !1);
780
- function nr(r) {
783
+ let kt = "https://web.telegram.org";
784
+ const V = new Pt("[SDK]", !1);
785
+ function sr(r) {
781
786
  if (r) {
782
- q.enable();
787
+ V.enable();
783
788
  return;
784
789
  }
785
- q.disable();
790
+ V.disable();
786
791
  }
787
- function ir(r) {
788
- St = r;
792
+ function nr(r) {
793
+ kt = r;
789
794
  }
790
- function se() {
791
- return St;
795
+ function ee() {
796
+ return kt;
792
797
  }
793
- const ne = g({
794
- eventType: h(),
798
+ const re = f({
799
+ eventType: u(),
795
800
  eventData: (r) => r
796
801
  });
797
- function ie(r, t) {
802
+ function se(r, t) {
798
803
  window.dispatchEvent(new MessageEvent("message", {
799
804
  data: JSON.stringify({ eventType: r, eventData: t })
800
805
  }));
801
806
  }
802
- function oe() {
807
+ function ne() {
803
808
  const r = window;
804
809
  "TelegramGameProxy_receiveEvent" in r || [
805
810
  ["TelegramGameProxy_receiveEvent"],
@@ -812,76 +817,76 @@ function oe() {
812
817
  let e = r;
813
818
  t.forEach((s, n, i) => {
814
819
  if (n === i.length - 1) {
815
- e[s] = ie;
820
+ e[s] = se;
816
821
  return;
817
822
  }
818
823
  s in e || (e[s] = {}), e = e[s];
819
824
  });
820
825
  });
821
826
  }
822
- function ae(r) {
823
- oe(), window.addEventListener("message", (t) => {
827
+ function ie(r) {
828
+ ne(), window.addEventListener("message", (t) => {
824
829
  try {
825
- const { eventType: e, eventData: s } = ne.parse(t.data);
830
+ const { eventType: e, eventData: s } = re.parse(t.data);
826
831
  r(e, s);
827
832
  } catch {
828
833
  }
829
834
  });
830
835
  }
831
- function ce() {
832
- return g({
833
- req_id: h(),
834
- data: (r) => r === null ? r : h().optional().parse(r)
836
+ function oe() {
837
+ return f({
838
+ req_id: u(),
839
+ data: (r) => r === null ? r : u().optional().parse(r)
835
840
  });
836
841
  }
837
- function he() {
838
- return g({
839
- req_id: h(),
842
+ function ae() {
843
+ return f({
844
+ req_id: u(),
840
845
  result: (r) => r,
841
- error: h().optional()
846
+ error: u().optional()
842
847
  });
843
848
  }
844
- function ue() {
845
- return g({
846
- slug: h(),
847
- status: h()
849
+ function ce() {
850
+ return f({
851
+ slug: u(),
852
+ status: u()
848
853
  });
849
854
  }
850
- function pe() {
851
- return g({ status: h() });
855
+ function ue() {
856
+ return f({ status: u() });
852
857
  }
853
- function le() {
854
- return g({
855
- button_id: (r) => r == null ? void 0 : h().parse(r)
858
+ function he() {
859
+ return f({
860
+ button_id: (r) => r == null ? void 0 : u().parse(r)
856
861
  });
857
862
  }
858
- function de() {
859
- return g({
860
- data: h().optional()
863
+ function pe() {
864
+ return f({
865
+ data: u().optional()
861
866
  });
862
867
  }
863
- function fe() {
864
- return g({
868
+ function le() {
869
+ return f({
865
870
  theme_params: (r) => {
866
871
  const t = gt().optional();
867
872
  return Object.entries(Y(r)).reduce((e, [s, n]) => (e[s] = t.parse(n), e), {});
868
873
  }
869
874
  });
870
875
  }
871
- function ge() {
872
- return g({
873
- height: k(),
874
- width: (r) => r == null ? window.innerWidth : k().parse(r),
875
- is_state_stable: P(),
876
- is_expanded: P()
876
+ function de() {
877
+ return f({
878
+ height: q(),
879
+ width: (r) => r == null ? window.innerWidth : q().parse(r),
880
+ is_state_stable: k(),
881
+ is_expanded: k()
877
882
  });
878
883
  }
879
- function we() {
880
- return g({ status: h() });
884
+ function fe() {
885
+ return f({ status: u() });
881
886
  }
882
- function _e() {
887
+ function ge() {
883
888
  const r = new w(), t = (e, ...s) => {
884
- q.log("Emitting processed event:", e, ...s), r.emit(e, ...s);
889
+ V.log("Emitting processed event:", e, ...s), r.emit(e, ...s);
885
890
  };
886
891
  return window.addEventListener("resize", () => {
887
892
  t("viewport_changed", {
@@ -890,33 +895,33 @@ function _e() {
890
895
  is_state_stable: !0,
891
896
  is_expanded: !0
892
897
  });
893
- }), ae((e, s) => {
894
- q.log("Received raw event:", e, s);
898
+ }), ie((e, s) => {
899
+ V.log("Received raw event:", e, s);
895
900
  try {
896
901
  switch (e) {
897
902
  case "viewport_changed":
898
- return t(e, ge().parse(s));
903
+ return t(e, de().parse(s));
899
904
  case "theme_changed":
900
- return t(e, fe().parse(s));
905
+ return t(e, le().parse(s));
901
906
  case "popup_closed":
902
907
  return (
903
908
  // Sent on desktop.
904
- s == null ? t(e, {}) : t(e, le().parse(s))
909
+ s == null ? t(e, {}) : t(e, he().parse(s))
905
910
  );
906
911
  case "set_custom_style":
907
- return t(e, h().parse(s));
912
+ return t(e, u().parse(s));
908
913
  case "qr_text_received":
909
- return t(e, de().parse(s));
914
+ return t(e, pe().parse(s));
910
915
  case "clipboard_text_received":
911
- return t(e, ce().parse(s));
916
+ return t(e, oe().parse(s));
912
917
  case "invoice_closed":
913
- return t(e, ue().parse(s));
918
+ return t(e, ce().parse(s));
914
919
  case "phone_requested":
915
- return t("phone_requested", pe().parse(s));
920
+ return t("phone_requested", ue().parse(s));
916
921
  case "custom_method_invoked":
917
- return t("custom_method_invoked", he().parse(s));
922
+ return t("custom_method_invoked", ae().parse(s));
918
923
  case "write_access_requested":
919
- return t("write_access_requested", we().parse(s));
924
+ return t("write_access_requested", fe().parse(s));
920
925
  case "main_button_pressed":
921
926
  case "back_button_pressed":
922
927
  case "settings_button_pressed":
@@ -927,31 +932,31 @@ function _e() {
927
932
  return t(e, s);
928
933
  }
929
934
  } catch (n) {
930
- q.error("Error processing event:", n);
935
+ V.error("Error processing event:", n);
931
936
  }
932
937
  }), r;
933
938
  }
934
939
  const Q = "telegram-mini-apps-cached-emitter";
935
940
  function U() {
936
941
  const r = window;
937
- return r[Q] === void 0 && (r[Q] = _e()), r[Q];
942
+ return r[Q] === void 0 && (r[Q] = ge()), r[Q];
938
943
  }
939
- function I(r, t) {
944
+ function $(r, t) {
940
945
  U().off(r, t);
941
946
  }
942
947
  function y(r, t) {
943
- return U().on(r, t), () => I(r, t);
948
+ return U().on(r, t), () => $(r, t);
944
949
  }
945
- function or(r, t) {
946
- return U().once(r, t), () => I(r, t);
950
+ function ir(r, t) {
951
+ return U().once(r, t), () => $(r, t);
947
952
  }
948
- function be(r) {
953
+ function we(r) {
949
954
  U().unsubscribe(r);
950
955
  }
951
- function ar(r) {
952
- return U().subscribe(r), () => be(r);
956
+ function or(r) {
957
+ return U().subscribe(r), () => we(r);
953
958
  }
954
- function me(r, t) {
959
+ function _e(r, t) {
955
960
  const e = r.split("."), s = t.split("."), n = Math.max(e.length, s.length);
956
961
  for (let i = 0; i < n; i += 1) {
957
962
  const a = parseInt(e[i] || "0", 10), c = parseInt(s[i] || "0", 10);
@@ -960,15 +965,15 @@ function me(r, t) {
960
965
  }
961
966
  return 0;
962
967
  }
963
- function v(r, t) {
964
- return me(r, t) <= 0;
968
+ function P(r, t) {
969
+ return _e(r, t) <= 0;
965
970
  }
966
- function A(r, t, e) {
971
+ function R(r, t, e) {
967
972
  if (typeof e == "string") {
968
973
  if (r === "web_app_open_link" && t === "try_instant_view")
969
- return v("6.4", e);
974
+ return P("6.4", e);
970
975
  if (r === "web_app_set_header_color" && t === "color")
971
- return v("6.9", e);
976
+ return P("6.9", e);
972
977
  }
973
978
  switch (r) {
974
979
  case "web_app_open_tg_link":
@@ -977,50 +982,50 @@ function A(r, t, e) {
977
982
  case "web_app_set_background_color":
978
983
  case "web_app_set_header_color":
979
984
  case "web_app_trigger_haptic_feedback":
980
- return v("6.1", t);
985
+ return P("6.1", t);
981
986
  case "web_app_open_popup":
982
- return v("6.2", t);
987
+ return P("6.2", t);
983
988
  case "web_app_close_scan_qr_popup":
984
989
  case "web_app_open_scan_qr_popup":
985
990
  case "web_app_read_text_from_clipboard":
986
- return v("6.4", t);
991
+ return P("6.4", t);
987
992
  case "web_app_switch_inline_query":
988
- return v("6.7", t);
993
+ return P("6.7", t);
989
994
  case "web_app_invoke_custom_method":
990
995
  case "web_app_request_write_access":
991
996
  case "web_app_request_phone":
992
- return v("6.9", t);
997
+ return P("6.9", t);
993
998
  case "web_app_setup_settings_button":
994
- return v("6.10", t);
999
+ return P("6.10", t);
995
1000
  default:
996
1001
  return !0;
997
1002
  }
998
1003
  }
999
1004
  function E(r, t) {
1000
- return (e) => A(t[e], r);
1005
+ return (e) => R(t[e], r);
1001
1006
  }
1002
- function kt(r, t) {
1007
+ function St(r, t) {
1003
1008
  return (e) => {
1004
1009
  const [s, n] = t[e];
1005
- return A(s, n, r);
1010
+ return R(s, n, r);
1006
1011
  };
1007
1012
  }
1008
- function f(r, t, e) {
1013
+ function d(r, t, e) {
1009
1014
  let s = {}, n;
1010
1015
  t === void 0 && e === void 0 ? s = {} : t !== void 0 && e !== void 0 ? (s = e, n = t) : t !== void 0 && ("targetOrigin" in t ? s = t : n = t);
1011
- const { targetOrigin: i = se() } = s;
1012
- if (q.log(`Calling method "${r}"`, n), vt()) {
1016
+ const { targetOrigin: i = ee() } = s;
1017
+ if (V.log(`Calling method "${r}"`, n), vt()) {
1013
1018
  window.parent.postMessage(JSON.stringify({
1014
1019
  eventType: r,
1015
1020
  eventData: n
1016
1021
  }), i);
1017
1022
  return;
1018
1023
  }
1019
- if (ee(window)) {
1024
+ if (Xt(window)) {
1020
1025
  window.external.notify(JSON.stringify({ eventType: r, eventData: n }));
1021
1026
  return;
1022
1027
  }
1023
- if (re(window)) {
1028
+ if (te(window)) {
1024
1029
  window.TelegramWebviewProxy.postEvent(r, JSON.stringify(n));
1025
1030
  return;
1026
1031
  }
@@ -1028,16 +1033,16 @@ function f(r, t, e) {
1028
1033
  "Unable to determine current environment and possible way to send event."
1029
1034
  );
1030
1035
  }
1031
- function ye(r) {
1036
+ function be(r) {
1032
1037
  return (t, e) => {
1033
- if (!A(t, r))
1038
+ if (!R(t, r))
1034
1039
  throw new tt(t, r);
1035
1040
  if (H(e)) {
1036
1041
  let s;
1037
- 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 && !A(t, s, r))
1042
+ 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))
1038
1043
  throw new et(t, s, r);
1039
1044
  }
1040
- return f(t, e);
1045
+ return d(t, e);
1041
1046
  };
1042
1047
  }
1043
1048
  class J extends Error {
@@ -1045,15 +1050,15 @@ class J extends Error {
1045
1050
  super(`Async call timeout exceeded. Timeout: ${t}`), Object.setPrototypeOf(this, J.prototype);
1046
1051
  }
1047
1052
  }
1048
- function cr(r) {
1053
+ function ar(r) {
1049
1054
  return r instanceof J;
1050
1055
  }
1051
- function Ee(r) {
1056
+ function me(r) {
1052
1057
  return new Promise((t) => {
1053
1058
  setTimeout(t, r);
1054
1059
  });
1055
1060
  }
1056
- function Ce(r) {
1061
+ function ye(r) {
1057
1062
  return new Promise((t, e) => {
1058
1063
  setTimeout(e, r, new J(r));
1059
1064
  });
@@ -1061,25 +1066,25 @@ function Ce(r) {
1061
1066
  function xt(r, t) {
1062
1067
  return Promise.race([
1063
1068
  r(),
1064
- Ce(t)
1069
+ ye(t)
1065
1070
  ]);
1066
1071
  }
1067
1072
  function m(r, t, e, s) {
1068
1073
  let n, i, a, c;
1069
1074
  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);
1070
- const { postEvent: u = f, timeout: p } = n || {}, l = n && "capture" in n ? n.capture : null, b = () => new Promise((d, C) => {
1071
- const x = a.map((B) => y(B, (M) => {
1072
- c && (!H(M) || M.req_id !== c) || typeof l == "function" && !l(M) || (T(), d(M));
1073
- })), T = () => x.forEach((B) => B());
1075
+ const { postEvent: p = d, timeout: h } = n || {}, g = n && "capture" in n ? n.capture : null, _ = () => new Promise((A, l) => {
1076
+ const C = a.map((v) => y(v, (M) => {
1077
+ c && (!H(M) || M.req_id !== c) || typeof g == "function" && !g(M) || (x(), A(M));
1078
+ })), x = () => C.forEach((v) => v());
1074
1079
  try {
1075
- u(r, i);
1076
- } catch (B) {
1077
- T(), C(B);
1080
+ p(r, i);
1081
+ } catch (v) {
1082
+ x(), l(v);
1078
1083
  }
1079
1084
  });
1080
- return typeof p == "number" ? xt(b, p) : b();
1085
+ return typeof h == "number" ? xt(_, h) : _();
1081
1086
  }
1082
- async function N(r, t, e, s = {}) {
1087
+ async function O(r, t, e, s = {}) {
1083
1088
  const { result: n, error: i } = await m(
1084
1089
  "web_app_invoke_custom_method",
1085
1090
  {
@@ -1094,8 +1099,8 @@ async function N(r, t, e, s = {}) {
1094
1099
  throw new Error(i);
1095
1100
  return n;
1096
1101
  }
1097
- class ve {
1098
- constructor(t, e, s = f) {
1102
+ class Ee {
1103
+ constructor(t, e, s = d) {
1099
1104
  o(this, "ee", new w());
1100
1105
  o(this, "state");
1101
1106
  /**
@@ -1109,12 +1114,12 @@ class ve {
1109
1114
  * @param event - event name.
1110
1115
  * @param listener - event listener.
1111
1116
  */
1112
- o(this, "off", (t, e) => t === "click" ? I("back_button_pressed", e) : this.ee.off(t, e));
1117
+ o(this, "off", (t, e) => t === "click" ? $("back_button_pressed", e) : this.ee.off(t, e));
1113
1118
  /**
1114
1119
  * Checks if specified method is supported by current component.
1115
1120
  */
1116
1121
  o(this, "supports");
1117
- this.postEvent = s, this.state = new _({ isVisible: t }, this.ee), this.supports = E(e, {
1122
+ this.postEvent = s, this.state = new b({ isVisible: t }, this.ee), this.supports = E(e, {
1118
1123
  show: "web_app_setup_back_button",
1119
1124
  hide: "web_app_setup_back_button"
1120
1125
  });
@@ -1144,23 +1149,23 @@ class ve {
1144
1149
  function nt(r, t) {
1145
1150
  return r + (r.length > 0 && t.length > 0 ? ` ${t}` : t);
1146
1151
  }
1147
- function Pe(...r) {
1152
+ function Ce(...r) {
1148
1153
  return r.reduce((t, e) => {
1149
1154
  let s = "";
1150
1155
  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);
1151
1156
  }, "");
1152
1157
  }
1153
- function Se(r) {
1158
+ function ve(r) {
1154
1159
  return typeof r == "object" && r !== null && !Array.isArray(null);
1155
1160
  }
1156
- function hr(...r) {
1157
- return r.reduce((t, e) => (Se(e) && Object.entries(e).forEach(([s, n]) => {
1158
- const i = Pe(t[s], n);
1161
+ function cr(...r) {
1162
+ return r.reduce((t, e) => (ve(e) && Object.entries(e).forEach(([s, n]) => {
1163
+ const i = Ce(t[s], n);
1159
1164
  i.length > 0 && (t[s] = i);
1160
1165
  }), t), {});
1161
1166
  }
1162
- class ke {
1163
- constructor(t, e = f) {
1167
+ class Pe {
1168
+ constructor(t, e = d) {
1164
1169
  o(this, "ee", new w());
1165
1170
  o(this, "state");
1166
1171
  /**
@@ -1171,7 +1176,7 @@ class ke {
1171
1176
  * Removes event listener.
1172
1177
  */
1173
1178
  o(this, "off", this.ee.off.bind(this.ee));
1174
- this.postEvent = e, this.state = new _({ isConfirmationNeeded: t }, this.ee);
1179
+ this.postEvent = e, this.state = new b({ isConfirmationNeeded: t }, this.ee);
1175
1180
  }
1176
1181
  set isConfirmationNeeded(t) {
1177
1182
  this.state.set("isConfirmationNeeded", t), this.postEvent("web_app_setup_closing_behavior", { need_confirmation: t });
@@ -1201,8 +1206,8 @@ class ke {
1201
1206
  function it(r, t) {
1202
1207
  return r.reduce((e, s) => (e[s] = t, e), {});
1203
1208
  }
1204
- class xe {
1205
- constructor(t, e, s = f) {
1209
+ class ke {
1210
+ constructor(t, e, s = d) {
1206
1211
  /**
1207
1212
  * Checks if specified method is supported by current component.
1208
1213
  */
@@ -1221,7 +1226,7 @@ class xe {
1221
1226
  */
1222
1227
  async delete(t, e = {}) {
1223
1228
  const s = Array.isArray(t) ? t : [t];
1224
- s.length !== 0 && await N(
1229
+ s.length !== 0 && await O(
1225
1230
  "deleteStorageValues",
1226
1231
  { keys: s },
1227
1232
  this.createRequestId(),
@@ -1233,21 +1238,21 @@ class xe {
1233
1238
  * @param options - request execution options.
1234
1239
  */
1235
1240
  async getKeys(t = {}) {
1236
- const e = await N(
1241
+ const e = await O(
1237
1242
  "getStorageKeys",
1238
1243
  {},
1239
1244
  this.createRequestId(),
1240
1245
  { ...t, postEvent: this.postEvent }
1241
1246
  );
1242
- return Nt().of(h()).parse(e);
1247
+ return Bt().of(u()).parse(e);
1243
1248
  }
1244
1249
  async get(t, e = {}) {
1245
1250
  const s = Array.isArray(t) ? t : [t];
1246
1251
  if (s.length === 0)
1247
1252
  return it(s, "");
1248
- const n = g(
1249
- it(s, h())
1250
- ), i = await N(
1253
+ const n = f(
1254
+ it(s, u())
1255
+ ), i = await O(
1251
1256
  "getStorageValues",
1252
1257
  { keys: s },
1253
1258
  this.createRequestId(),
@@ -1262,7 +1267,7 @@ class xe {
1262
1267
  * @param options - request execution options.
1263
1268
  */
1264
1269
  async set(t, e, s = {}) {
1265
- await N(
1270
+ await O(
1266
1271
  "saveStorageValue",
1267
1272
  { key: t, value: e },
1268
1273
  this.createRequestId(),
@@ -1270,8 +1275,8 @@ class xe {
1270
1275
  );
1271
1276
  }
1272
1277
  }
1273
- class qe {
1274
- constructor(t, e = f) {
1278
+ class Se {
1279
+ constructor(t, e = d) {
1275
1280
  /**
1276
1281
  * Checks if specified method is supported by current component.
1277
1282
  */
@@ -1316,7 +1321,7 @@ class qe {
1316
1321
  this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
1317
1322
  }
1318
1323
  }
1319
- function Ae() {
1324
+ function xe() {
1320
1325
  const r = document.createElement("style");
1321
1326
  r.id = "telegram-custom-styles", document.head.appendChild(r), y("set_custom_style", (t) => {
1322
1327
  r.innerHTML = t;
@@ -1325,26 +1330,26 @@ function Ae() {
1325
1330
  function qt(r) {
1326
1331
  return `telegram-mini-apps-${r}`;
1327
1332
  }
1328
- function L(r, t) {
1333
+ function T(r, t) {
1329
1334
  sessionStorage.setItem(qt(r), JSON.stringify(t));
1330
1335
  }
1331
- function $(r) {
1336
+ function B(r) {
1332
1337
  const t = sessionStorage.getItem(qt(r));
1333
1338
  return t ? JSON.parse(t) : null;
1334
1339
  }
1335
- function Re(r, t, e) {
1336
- const { isVisible: s = !1 } = r ? $("back-button") || {} : {}, n = new ve(s, t, e);
1340
+ function qe(r, t, e) {
1341
+ const { isVisible: s = !1 } = r ? B("back-button") || {} : {}, n = new Ee(s, t, e);
1337
1342
  return n.on("change", () => {
1338
- L("back-button", { isVisible: n.isVisible });
1343
+ T("back-button", { isVisible: n.isVisible });
1339
1344
  }), n;
1340
1345
  }
1341
- function Ve(r, t) {
1342
- const { isConfirmationNeeded: e = !1 } = r ? $("closing-behavior") || {} : {}, s = new ke(e, t);
1343
- return s.on("change", () => L("closing-behavior", {
1346
+ function Ae(r, t) {
1347
+ const { isConfirmationNeeded: e = !1 } = r ? B("closing-behavior") || {} : {}, s = new Pe(e, t);
1348
+ return s.on("change", () => T("closing-behavior", {
1344
1349
  isConfirmationNeeded: s.isConfirmationNeeded
1345
1350
  })), s;
1346
1351
  }
1347
- class Ie {
1352
+ class Ve {
1348
1353
  constructor(t) {
1349
1354
  o(this, "ee", new w());
1350
1355
  o(this, "state");
@@ -1365,21 +1370,21 @@ class Ie {
1365
1370
  * @param event - event name.
1366
1371
  * @param listener - event listener.
1367
1372
  */
1368
- o(this, "off", (t, e) => t === "click" ? I("main_button_pressed", e) : this.ee.off(t, e));
1373
+ o(this, "off", (t, e) => t === "click" ? $("main_button_pressed", e) : this.ee.off(t, e));
1369
1374
  const {
1370
- postEvent: e = f,
1375
+ postEvent: e = d,
1371
1376
  text: s,
1372
1377
  textColor: n,
1373
1378
  backgroundColor: i,
1374
1379
  isEnabled: a,
1375
1380
  isVisible: c,
1376
- isLoaderVisible: u
1381
+ isLoaderVisible: p
1377
1382
  } = t;
1378
- this.postEvent = e, this.state = new _({
1383
+ this.postEvent = e, this.state = new b({
1379
1384
  backgroundColor: i,
1380
1385
  isEnabled: a,
1381
1386
  isVisible: c,
1382
- isLoaderVisible: u,
1387
+ isLoaderVisible: p,
1383
1388
  text: s,
1384
1389
  textColor: n
1385
1390
  }, this.ee);
@@ -1509,48 +1514,48 @@ class Ie {
1509
1514
  return this.state.set(t), this.commit(), this;
1510
1515
  }
1511
1516
  }
1512
- function Le(r, t, e, s) {
1517
+ function Re(r, t, e, s) {
1513
1518
  const {
1514
1519
  backgroundColor: n = t,
1515
1520
  isEnabled: i = !1,
1516
1521
  isVisible: a = !1,
1517
1522
  isLoaderVisible: c = !1,
1518
- textColor: u = e,
1519
- text: p = ""
1520
- } = r ? $("main-button") || {} : {}, l = new Ie({
1523
+ textColor: p = e,
1524
+ text: h = ""
1525
+ } = r ? B("main-button") || {} : {}, g = new Ve({
1521
1526
  backgroundColor: n,
1522
1527
  isEnabled: i,
1523
1528
  isLoaderVisible: c,
1524
1529
  isVisible: a,
1525
1530
  postEvent: s,
1526
- text: p,
1527
- textColor: u
1528
- }), b = () => L("main-button", {
1529
- backgroundColor: l.backgroundColor,
1530
- isEnabled: l.isEnabled,
1531
- isLoaderVisible: l.isLoaderVisible,
1532
- isVisible: l.isVisible,
1533
- text: l.text,
1534
- textColor: l.textColor
1531
+ text: h,
1532
+ textColor: p
1533
+ }), _ = () => T("main-button", {
1534
+ backgroundColor: g.backgroundColor,
1535
+ isEnabled: g.isEnabled,
1536
+ isLoaderVisible: g.isLoaderVisible,
1537
+ isVisible: g.isVisible,
1538
+ text: g.text,
1539
+ textColor: g.textColor
1535
1540
  });
1536
- return l.on("change", b), l;
1541
+ return g.on("change", _), g;
1537
1542
  }
1538
- const $e = X({
1539
- contact: g({
1543
+ const Ie = X({
1544
+ contact: f({
1540
1545
  userId: {
1541
- type: k(),
1546
+ type: q(),
1542
1547
  from: "user_id"
1543
1548
  },
1544
1549
  phoneNumber: {
1545
- type: h(),
1550
+ type: u(),
1546
1551
  from: "phone_number"
1547
1552
  },
1548
1553
  firstName: {
1549
- type: h(),
1554
+ type: u(),
1550
1555
  from: "first_name"
1551
1556
  },
1552
1557
  lastName: {
1553
- type: h().optional(),
1558
+ type: u().optional(),
1554
1559
  from: "last_name"
1555
1560
  }
1556
1561
  }),
@@ -1558,9 +1563,9 @@ const $e = X({
1558
1563
  type: pt(),
1559
1564
  from: "auth_date"
1560
1565
  },
1561
- hash: h()
1566
+ hash: u()
1562
1567
  });
1563
- class Te {
1568
+ class Le {
1564
1569
  constructor(t) {
1565
1570
  o(this, "ee", new w());
1566
1571
  o(this, "state");
@@ -1586,20 +1591,20 @@ class Te {
1586
1591
  */
1587
1592
  o(this, "supportsParam");
1588
1593
  const {
1589
- postEvent: e = f,
1594
+ postEvent: e = d,
1590
1595
  headerColor: s,
1591
1596
  backgroundColor: n,
1592
1597
  version: i,
1593
1598
  botInline: a,
1594
1599
  createRequestId: c
1595
- } = t, u = E(i, {
1600
+ } = t, p = E(i, {
1596
1601
  requestPhoneAccess: "web_app_request_phone",
1597
1602
  requestWriteAccess: "web_app_request_write_access",
1598
1603
  switchInlineQuery: "web_app_switch_inline_query",
1599
1604
  setHeaderColor: "web_app_set_header_color",
1600
1605
  setBackgroundColor: "web_app_set_background_color"
1601
1606
  });
1602
- this.postEvent = e, this.botInline = a, this.createRequestId = c, this.supports = (p) => !(!u(p) || p === "switchInlineQuery" && !a), this.state = new _({ backgroundColor: n, headerColor: s }, this.ee), this.supportsParam = kt(i, {
1607
+ this.postEvent = e, this.botInline = a, this.createRequestId = c, this.supports = (h) => !(!p(h) || h === "switchInlineQuery" && !a), this.state = new b({ backgroundColor: n, headerColor: s }, this.ee), this.supportsParam = St(i, {
1603
1608
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1604
1609
  });
1605
1610
  }
@@ -1607,7 +1612,7 @@ class Te {
1607
1612
  * Attempts to get requested contact.
1608
1613
  */
1609
1614
  async getRequestedContact() {
1610
- return N(
1615
+ return O(
1611
1616
  "getRequestedContact",
1612
1617
  {},
1613
1618
  this.createRequestId(),
@@ -1615,7 +1620,7 @@ class Te {
1615
1620
  postEvent: this.postEvent,
1616
1621
  timeout: 1e4
1617
1622
  }
1618
- ).then((t) => $e.parse(t));
1623
+ ).then((t) => Ie.parse(t));
1619
1624
  }
1620
1625
  /**
1621
1626
  * The Mini App background color.
@@ -1692,7 +1697,7 @@ class Te {
1692
1697
  return await this.getRequestedContact();
1693
1698
  } catch {
1694
1699
  }
1695
- await Ee(n), n += 50;
1700
+ await me(n), n += 50;
1696
1701
  }
1697
1702
  throw new Error("Unable to retrieve requested contact.");
1698
1703
  }, t);
@@ -1778,29 +1783,29 @@ class Te {
1778
1783
  });
1779
1784
  }
1780
1785
  }
1781
- function Be(r, t, e, s, n, i) {
1786
+ function $e(r, t, e, s, n, i) {
1782
1787
  const {
1783
1788
  backgroundColor: a = t,
1784
1789
  headerColor: c = "bg_color"
1785
- } = r ? $("mini-app") || {} : {}, u = new Te({
1790
+ } = r ? B("mini-app") || {} : {}, p = new Le({
1786
1791
  headerColor: c,
1787
1792
  backgroundColor: a,
1788
1793
  version: e,
1789
1794
  botInline: s,
1790
1795
  createRequestId: n,
1791
1796
  postEvent: i
1792
- }), p = () => L("mini-app", {
1793
- backgroundColor: u.backgroundColor,
1794
- headerColor: u.headerColor
1797
+ }), h = () => T("mini-app", {
1798
+ backgroundColor: p.backgroundColor,
1799
+ headerColor: p.headerColor
1795
1800
  });
1796
- return u.on("change", p), u;
1801
+ return p.on("change", h), p;
1797
1802
  }
1798
- function De() {
1803
+ function Te() {
1799
1804
  let r = 0;
1800
1805
  return () => (r += 1, r.toString());
1801
1806
  }
1802
- class We {
1803
- constructor(t, e, s = f) {
1807
+ class Be {
1808
+ constructor(t, e, s = d) {
1804
1809
  o(this, "ee", new w());
1805
1810
  o(this, "state");
1806
1811
  /**
@@ -1814,12 +1819,12 @@ class We {
1814
1819
  * @param event - event name.
1815
1820
  * @param listener - event listener.
1816
1821
  */
1817
- o(this, "off", (t, e) => t === "click" ? I("settings_button_pressed", e) : this.ee.off(t, e));
1822
+ o(this, "off", (t, e) => t === "click" ? $("settings_button_pressed", e) : this.ee.off(t, e));
1818
1823
  /**
1819
1824
  * Checks if specified method is supported by current component.
1820
1825
  */
1821
1826
  o(this, "supports");
1822
- this.postEvent = s, this.state = new _({ isVisible: t }, this.ee), this.supports = E(e, {
1827
+ this.postEvent = s, this.state = new b({ isVisible: t }, this.ee), this.supports = E(e, {
1823
1828
  show: "web_app_setup_settings_button",
1824
1829
  hide: "web_app_setup_settings_button"
1825
1830
  });
@@ -1846,16 +1851,19 @@ class We {
1846
1851
  this.isVisible = !0;
1847
1852
  }
1848
1853
  }
1849
- function Ne(r, t, e) {
1850
- const { isVisible: s = !1 } = r ? $("settings-button") || {} : {}, n = new We(s, t, e);
1854
+ function De(r, t, e) {
1855
+ const { isVisible: s = !1 } = r ? B("settings-button") || {} : {}, n = new Be(s, t, e);
1851
1856
  return n.on("change", () => {
1852
- L("settings-button", { isVisible: n.isVisible });
1857
+ T("settings-button", { isVisible: n.isVisible });
1853
1858
  }), n;
1854
1859
  }
1855
- function Oe(r) {
1856
- const t = new Ft(r);
1860
+ function We(r) {
1861
+ const t = new Mt(r);
1857
1862
  return t.listen(), t;
1858
1863
  }
1864
+ function Oe(r) {
1865
+ return ["macos", "tdesktop", "unigram", "web", "weba"].includes(r);
1866
+ }
1859
1867
  async function At(r) {
1860
1868
  const t = await m("web_app_request_viewport", "viewport_changed", r);
1861
1869
  return {
@@ -1868,7 +1876,7 @@ async function At(r) {
1868
1876
  function D(r) {
1869
1877
  return r < 0 ? 0 : r;
1870
1878
  }
1871
- class G {
1879
+ class Ne {
1872
1880
  constructor(t) {
1873
1881
  o(this, "ee", new w());
1874
1882
  o(this, "state");
@@ -1886,9 +1894,9 @@ class G {
1886
1894
  isExpanded: s,
1887
1895
  width: n,
1888
1896
  stableHeight: i,
1889
- postEvent: a = f
1897
+ postEvent: a = d
1890
1898
  } = t;
1891
- this.postEvent = a, this.state = new _({
1899
+ this.postEvent = a, this.state = new b({
1892
1900
  height: D(e),
1893
1901
  isExpanded: s,
1894
1902
  stableHeight: D(i),
@@ -1997,56 +2005,51 @@ class G {
1997
2005
  return this.stableHeight === this.height;
1998
2006
  }
1999
2007
  }
2000
- function Rt(r) {
2001
- return !["macos", "web", "weba"].includes(r);
2002
- }
2003
- function Vt(r, t, e) {
2004
- if (r || !Rt(t))
2005
- return new G({
2008
+ function j(r) {
2009
+ const t = new Ne(r);
2010
+ return t.on("change", () => T("viewport", {
2011
+ height: t.height,
2012
+ isExpanded: t.isExpanded,
2013
+ stableHeight: t.stableHeight,
2014
+ width: t.width
2015
+ })), t.listen(), t;
2016
+ }
2017
+ function He(r, t, e, s) {
2018
+ const n = r ? B("viewport") : null;
2019
+ if (n)
2020
+ return j({ ...n, postEvent: e });
2021
+ if (Oe(t))
2022
+ return j({
2006
2023
  height: window.innerHeight,
2007
2024
  isExpanded: !0,
2008
2025
  postEvent: e,
2009
2026
  stableHeight: window.innerHeight,
2010
2027
  width: window.innerWidth
2011
2028
  });
2012
- const s = $("viewport");
2013
- return s ? new G({ ...s, postEvent: e }) : null;
2014
- }
2015
- function It(r) {
2016
- return r.listen(), r.on("change", () => L("viewport", {
2017
- height: r.height,
2018
- isExpanded: r.isExpanded,
2019
- stableHeight: r.stableHeight,
2020
- width: r.width
2021
- })), r;
2022
- }
2023
- function He(r, t, e) {
2024
- const s = It(
2025
- Vt(r, t, e) || new G({
2026
- width: 0,
2027
- height: 0,
2028
- isExpanded: !1,
2029
+ if (s)
2030
+ return At({
2029
2031
  postEvent: e,
2030
- stableHeight: 0
2031
- })
2032
- );
2033
- return Rt(t) && s.sync({ postEvent: e, timeout: 100 }).catch((n) => {
2034
- console.error("Unable to actualize viewport state", n);
2035
- }), s;
2036
- }
2037
- async function Ue(r, t, e) {
2038
- return It(
2039
- Vt(r, t, e) || await At({ postEvent: e, timeout: 100 }).then(({ height: s, isStateStable: n, ...i }) => new G({
2040
- ...i,
2041
- height: s,
2042
- stableHeight: n ? s : 0
2043
- }))
2044
- );
2032
+ timeout: 5e3
2033
+ }).then(({ height: a, isStateStable: c, ...p }) => j({
2034
+ ...p,
2035
+ height: a,
2036
+ stableHeight: c ? a : 0
2037
+ }));
2038
+ const i = j({
2039
+ width: 0,
2040
+ height: 0,
2041
+ isExpanded: !1,
2042
+ postEvent: e,
2043
+ stableHeight: 0
2044
+ });
2045
+ return i.sync({ postEvent: e, timeout: 5e3 }).catch((a) => {
2046
+ console.error("Unable to actualize viewport state", a);
2047
+ }), i;
2045
2048
  }
2046
2049
  function S(r, t) {
2047
2050
  document.documentElement.style.setProperty(r, t);
2048
2051
  }
2049
- function Me(r, t) {
2052
+ function Ue(r, t) {
2050
2053
  const e = () => {
2051
2054
  S("--tg-background-color", r.backgroundColor);
2052
2055
  }, s = () => {
@@ -2058,7 +2061,7 @@ function Me(r, t) {
2058
2061
  };
2059
2062
  t.on("change", s), r.on("change:backgroundColor", e), r.on("change:headerColor", s), e(), s();
2060
2063
  }
2061
- function je(r) {
2064
+ function Me(r) {
2062
2065
  const t = () => {
2063
2066
  const e = r.getState();
2064
2067
  Object.entries(e).forEach(([s, n]) => {
@@ -2074,7 +2077,7 @@ function ot(r) {
2074
2077
  const t = () => S("--tg-viewport-height", `${r.height}px`), e = () => S("--tg-viewport-width", `${r.width}px`), s = () => S("--tg-viewport-height", `${r.stableHeight}px`);
2075
2078
  r.on("change:height", t), r.on("change:width", e), r.on("change:stableHeight", s), t(), e(), s();
2076
2079
  }
2077
- function Ge(r) {
2080
+ function je(r) {
2078
2081
  return typeof r == "object" ? r : r ? {
2079
2082
  themeParams: !0,
2080
2083
  viewport: !0,
@@ -2082,10 +2085,10 @@ function Ge(r) {
2082
2085
  } : {};
2083
2086
  }
2084
2087
  function at(r, t, e, s) {
2085
- const n = Ge(r);
2086
- n.miniApp && Me(t, e), n.themeParams && je(e), n.viewport && (s instanceof Promise ? s.then(ot) : ot(s));
2088
+ const n = je(r);
2089
+ n.miniApp && Ue(t, e), n.themeParams && Me(e), n.viewport && (s instanceof Promise ? s.then(ot) : ot(s));
2087
2090
  }
2088
- function Fe(r) {
2091
+ function Ge(r) {
2089
2092
  const { hostname: t, pathname: e } = new URL(r, window.location.href);
2090
2093
  if (t !== "t.me")
2091
2094
  throw new Error(`Incorrect hostname: ${t}`);
@@ -2094,8 +2097,8 @@ function Fe(r) {
2094
2097
  throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
2095
2098
  return s[2];
2096
2099
  }
2097
- class ze {
2098
- constructor(t, e = f) {
2100
+ class Fe {
2101
+ constructor(t, e = d) {
2099
2102
  o(this, "ee", new w());
2100
2103
  o(this, "state");
2101
2104
  /**
@@ -2110,7 +2113,7 @@ class ze {
2110
2113
  * Checks if specified method is supported by current component.
2111
2114
  */
2112
2115
  o(this, "supports");
2113
- this.postEvent = e, this.state = new _({ isOpened: !1 }, this.ee), this.supports = E(t, { open: "web_app_open_invoice" });
2116
+ this.postEvent = e, this.state = new b({ isOpened: !1 }, this.ee), this.supports = E(t, { open: "web_app_open_invoice" });
2114
2117
  }
2115
2118
  set isOpened(t) {
2116
2119
  this.state.set("isOpened", t);
@@ -2124,7 +2127,7 @@ class ze {
2124
2127
  async open(t, e) {
2125
2128
  if (this.isOpened)
2126
2129
  throw new Error("Invoice is already opened");
2127
- const s = e ? Fe(t) : t;
2130
+ const s = e ? Ge(t) : t;
2128
2131
  this.isOpened = !0;
2129
2132
  try {
2130
2133
  return (await m(
@@ -2143,7 +2146,7 @@ class ze {
2143
2146
  }
2144
2147
  }
2145
2148
  }
2146
- function Je(r) {
2149
+ function ze(r) {
2147
2150
  const t = r.message.trim(), e = (r.title || "").trim(), s = r.buttons || [];
2148
2151
  let n;
2149
2152
  if (e.length > 64)
@@ -2159,16 +2162,16 @@ function Je(r) {
2159
2162
  if (i.type === void 0 || i.type === "default" || i.type === "destructive") {
2160
2163
  const c = i.text.trim();
2161
2164
  if (c.length === 0 || c.length > 64) {
2162
- const u = i.type || "default";
2163
- throw new Error(`Button text with type "${u}" has incorrect size: ${i.text.length}`);
2165
+ const p = i.type || "default";
2166
+ throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
2164
2167
  }
2165
2168
  return { ...i, text: c, id: a };
2166
2169
  }
2167
2170
  return { ...i, id: a };
2168
2171
  }), { title: e, message: t, buttons: n };
2169
2172
  }
2170
- class Qe {
2171
- constructor(t, e = f) {
2173
+ class Je {
2174
+ constructor(t, e = d) {
2172
2175
  o(this, "ee", new w());
2173
2176
  o(this, "state");
2174
2177
  /**
@@ -2183,7 +2186,7 @@ class Qe {
2183
2186
  * Checks if specified method is supported by current component.
2184
2187
  */
2185
2188
  o(this, "supports");
2186
- this.postEvent = e, this.state = new _({ isOpened: !1 }, this.ee), this.supports = E(t, { open: "web_app_open_popup" });
2189
+ this.postEvent = e, this.state = new b({ isOpened: !1 }, this.ee), this.supports = E(t, { open: "web_app_open_popup" });
2187
2190
  }
2188
2191
  set isOpened(t) {
2189
2192
  this.state.set("isOpened", t);
@@ -2212,7 +2215,7 @@ class Qe {
2212
2215
  throw new Error("Popup is already opened.");
2213
2216
  return this.isOpened = !0, m(
2214
2217
  "web_app_open_popup",
2215
- Je(t),
2218
+ ze(t),
2216
2219
  "popup_closed",
2217
2220
  { postEvent: this.postEvent }
2218
2221
  ).then(({ button_id: e = null }) => e).finally(() => {
@@ -2220,8 +2223,8 @@ class Qe {
2220
2223
  });
2221
2224
  }
2222
2225
  }
2223
- class Ze {
2224
- constructor(t, e = f) {
2226
+ class Qe {
2227
+ constructor(t, e = d) {
2225
2228
  o(this, "ee", new w());
2226
2229
  o(this, "state");
2227
2230
  /**
@@ -2236,7 +2239,7 @@ class Ze {
2236
2239
  * Checks if specified method is supported by current component.
2237
2240
  */
2238
2241
  o(this, "supports");
2239
- this.postEvent = e, this.state = new _({ isOpened: !1 }, this.ee), this.supports = E(t, {
2242
+ this.postEvent = e, this.state = new b({ isOpened: !1 }, this.ee), this.supports = E(t, {
2240
2243
  close: "web_app_close_scan_qr_popup",
2241
2244
  open: "web_app_open_scan_qr_popup"
2242
2245
  });
@@ -2279,8 +2282,8 @@ class Ze {
2279
2282
  }
2280
2283
  }
2281
2284
  }
2282
- class Ke {
2283
- constructor(t, e, s = f) {
2285
+ class Ze {
2286
+ constructor(t, e, s = d) {
2284
2287
  /**
2285
2288
  * Checks if specified method is supported by current component.
2286
2289
  */
@@ -2291,7 +2294,7 @@ class Ke {
2291
2294
  o(this, "supportsParam");
2292
2295
  this.version = t, this.createRequestId = e, this.postEvent = s, this.supports = E(t, {
2293
2296
  readTextFromClipboard: "web_app_read_text_from_clipboard"
2294
- }), this.supportsParam = kt(t, {
2297
+ }), this.supportsParam = St(t, {
2295
2298
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2296
2299
  });
2297
2300
  }
@@ -2306,7 +2309,7 @@ class Ke {
2306
2309
  */
2307
2310
  openLink(t, e) {
2308
2311
  const s = new URL(t, window.location.href).toString();
2309
- if (!A("web_app_open_link", this.version)) {
2312
+ if (!R("web_app_open_link", this.version)) {
2310
2313
  window.open(s, "_blank");
2311
2314
  return;
2312
2315
  }
@@ -2329,7 +2332,7 @@ class Ke {
2329
2332
  } = new URL(t, window.location.href);
2330
2333
  if (e !== "t.me")
2331
2334
  throw new Error(`URL has not allowed hostname: ${e}. Only "t.me" is allowed`);
2332
- if (!A("web_app_open_tg_link", this.version)) {
2335
+ if (!R("web_app_open_tg_link", this.version)) {
2333
2336
  window.location.href = t;
2334
2337
  return;
2335
2338
  }
@@ -2353,82 +2356,80 @@ class Ke {
2353
2356
  function ur(r = {}) {
2354
2357
  const {
2355
2358
  async: t = !1,
2356
- cssVars: e = !1,
2357
- acceptCustomStyles: s = !1
2359
+ complete: e = t,
2360
+ cssVars: s = !1,
2361
+ acceptCustomStyles: n = !1
2358
2362
  } = r;
2359
2363
  try {
2360
2364
  const {
2361
2365
  launchParams: {
2362
- initData: n,
2363
- initDataRaw: i,
2364
- version: a,
2365
- platform: c,
2366
- themeParams: u,
2367
- botInline: p = !1
2366
+ initData: i,
2367
+ initDataRaw: a,
2368
+ version: c,
2369
+ platform: p,
2370
+ themeParams: h,
2371
+ botInline: g = !1
2368
2372
  },
2369
- isPageReload: l
2370
- } = Ct(), b = De(), d = ye(a);
2371
- vt() && (s && Ae(), d("iframe_ready", { reload_supported: !0 }), y("reload_iframe", () => window.location.reload()));
2373
+ isPageReload: _
2374
+ } = Ct(), A = Te(), l = be(c);
2375
+ vt() && (n && xe(), l("iframe_ready", { reload_supported: !0 }), y("reload_iframe", () => window.location.reload()));
2372
2376
  const C = {
2373
- backButton: Re(l, a, d),
2374
- closingBehavior: Ve(l, d),
2375
- cloudStorage: new xe(a, b, d),
2376
- createRequestId: b,
2377
- hapticFeedback: new qe(a, d),
2378
- invoice: new ze(a, d),
2379
- mainButton: Le(
2380
- l,
2381
- u.buttonColor || "#000000",
2382
- u.buttonTextColor || "#ffffff",
2383
- d
2377
+ backButton: qe(_, c, l),
2378
+ closingBehavior: Ae(_, l),
2379
+ cloudStorage: new ke(c, A, l),
2380
+ createRequestId: A,
2381
+ hapticFeedback: new Se(c, l),
2382
+ invoice: new Fe(c, l),
2383
+ mainButton: Re(
2384
+ _,
2385
+ h.buttonColor || "#000000",
2386
+ h.buttonTextColor || "#ffffff",
2387
+ l
2384
2388
  ),
2385
- miniApp: Be(
2386
- l,
2387
- u.backgroundColor || "#ffffff",
2388
- a,
2389
- p,
2390
- b,
2391
- d
2389
+ miniApp: $e(
2390
+ _,
2391
+ h.backgroundColor || "#ffffff",
2392
+ c,
2393
+ g,
2394
+ A,
2395
+ l
2392
2396
  ),
2393
- popup: new Qe(a, d),
2394
- postEvent: d,
2395
- qrScanner: new Ze(a, d),
2396
- settingsButton: Ne(l, a, d),
2397
- themeParams: Oe(u),
2398
- utils: new Ke(a, b, d),
2399
- ...n ? {
2400
- initData: new Ut(n),
2401
- initDataRaw: i
2397
+ popup: new Je(c, l),
2398
+ postEvent: l,
2399
+ qrScanner: new Qe(c, l),
2400
+ settingsButton: De(_, c, l),
2401
+ themeParams: We(h),
2402
+ utils: new Ze(c, A, l),
2403
+ ...i ? {
2404
+ initData: new Ot(i),
2405
+ initDataRaw: a
2402
2406
  } : {}
2403
- }, x = t ? Ue(l, c, d) : He(l, c, d);
2404
- return x instanceof Promise ? x.then((T) => (at(
2405
- e,
2407
+ }, x = He(_, p, l, e);
2408
+ return x instanceof Promise || e ? Promise.resolve(x).then((v) => (at(
2409
+ s,
2406
2410
  C.miniApp,
2407
2411
  C.themeParams,
2408
- T
2409
- ), {
2410
- ...C,
2411
- viewport: T
2412
- })) : (at(
2413
- e,
2412
+ v
2413
+ ), { ...C, viewport: v })) : (at(
2414
+ s,
2414
2415
  C.miniApp,
2415
2416
  C.themeParams,
2416
2417
  x
2417
2418
  ), { ...C, viewport: x });
2418
- } catch (n) {
2419
- if (t)
2420
- return Promise.reject(n);
2421
- throw n;
2419
+ } catch (i) {
2420
+ if (e)
2421
+ return Promise.reject(i);
2422
+ throw i;
2422
2423
  }
2423
2424
  }
2424
2425
  function W(r, t) {
2425
2426
  return r.startsWith(t) ? r : `${t}${r}`;
2426
2427
  }
2427
- function pr(r) {
2428
+ function hr(r) {
2428
2429
  const t = r.match(/#(.+)/);
2429
2430
  return t ? t[1] : null;
2430
2431
  }
2431
- async function O(r) {
2432
+ async function N(r) {
2432
2433
  return r === 0 ? !0 : Promise.race([
2433
2434
  new Promise((t) => {
2434
2435
  window.addEventListener("popstate", function e() {
@@ -2441,14 +2442,14 @@ async function O(r) {
2441
2442
  })
2442
2443
  ]);
2443
2444
  }
2444
- async function Ye() {
2445
- if (window.history.length <= 1 || (window.history.pushState(null, ""), await O(1 - window.history.length)))
2445
+ async function Ke() {
2446
+ if (window.history.length <= 1 || (window.history.pushState(null, ""), await N(1 - window.history.length)))
2446
2447
  return;
2447
- let t = await O(-1);
2448
+ let t = await N(-1);
2448
2449
  for (; t; )
2449
- t = await O(-1);
2450
+ t = await N(-1);
2450
2451
  }
2451
- class Xe {
2452
+ class Ye {
2452
2453
  constructor(t, e, {
2453
2454
  debug: s = !1,
2454
2455
  loggerPrefix: n = "Navigator"
@@ -2481,9 +2482,9 @@ class Xe {
2481
2482
  const {
2482
2483
  pathname: a = "",
2483
2484
  search: c,
2484
- hash: u
2485
+ hash: p
2485
2486
  } = t;
2486
- e = a + (c ? W(c, "?") : "") + (u ? W(u, "#") : "");
2487
+ e = a + (c ? W(c, "?") : "") + (p ? W(p, "#") : "");
2487
2488
  }
2488
2489
  const {
2489
2490
  pathname: s,
@@ -2648,7 +2649,7 @@ class Xe {
2648
2649
  }
2649
2650
  }
2650
2651
  const ct = 0, Z = 1, K = 2;
2651
- class Lt extends Xe {
2652
+ class Vt extends Ye {
2652
2653
  constructor(e, s, n = {}) {
2653
2654
  super(e, s, {
2654
2655
  ...n,
@@ -2695,7 +2696,7 @@ class Lt extends Xe {
2695
2696
  window.location.hash.slice(1),
2696
2697
  window.location.href
2697
2698
  );
2698
- return new Lt([{ search: s, pathname: n, hash: i }], 0, e);
2699
+ return new Vt([{ search: s, pathname: n, hash: i }], 0, e);
2699
2700
  }
2700
2701
  async performGo(e) {
2701
2702
  e.updated && (this.attached && await this.syncHistory(), this.emitChanged(e.before, e.after));
@@ -2712,7 +2713,7 @@ class Lt extends Xe {
2712
2713
  async syncHistory() {
2713
2714
  window.removeEventListener("popstate", this.onPopState);
2714
2715
  const e = `#${this.path}`;
2715
- await Ye(), f("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 O(-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 O(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ct, ""), window.history.pushState(null, "", e)), window.addEventListener("popstate", this.onPopState);
2716
+ 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 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);
2716
2717
  }
2717
2718
  emitChanged(e, s) {
2718
2719
  this.ee.emit("change", {
@@ -2732,66 +2733,67 @@ class Lt extends Xe {
2732
2733
  * Detaches current navigator from the browser history.
2733
2734
  */
2734
2735
  detach() {
2735
- this.attached && (this.logger.log("Detaching", this), this.attached = !1, window.removeEventListener("popstate", this.onPopState), I("back_button_pressed", this.back));
2736
+ this.attached && (this.logger.log("Detaching", this), this.attached = !1, window.removeEventListener("popstate", this.onPopState), $("back_button_pressed", this.back));
2736
2737
  }
2737
2738
  }
2738
2739
  export {
2739
- ve as BackButton,
2740
- ke as ClosingBehavior,
2741
- xe as CloudStorage,
2742
- qe as HapticFeedback,
2743
- Lt as HashNavigator,
2744
- Ut as InitData,
2745
- ze as Invoice,
2746
- Ie as MainButton,
2740
+ Ee as BackButton,
2741
+ Pe as ClosingBehavior,
2742
+ ke as CloudStorage,
2743
+ Se as HapticFeedback,
2744
+ Vt as HashNavigator,
2745
+ Ot as InitData,
2746
+ Fe as Invoice,
2747
+ Ve as MainButton,
2747
2748
  tt as MethodUnsupportedError,
2748
- Te as MiniApp,
2749
- Xe as Navigator,
2749
+ Le as MiniApp,
2750
+ Ye as Navigator,
2750
2751
  et as ParameterUnsupportedError,
2751
- Qe as Popup,
2752
- Ze as QRScanner,
2753
- We as SettingsButton,
2754
- Ft as ThemeParams,
2752
+ Je as Popup,
2753
+ Qe as QRScanner,
2754
+ Be as SettingsButton,
2755
+ Mt as ThemeParams,
2755
2756
  J as TimeoutError,
2756
- Ke as Utils,
2757
- G as Viewport,
2758
- Ht as chatParser,
2759
- Pe as classNames,
2760
- me as compareVersions,
2761
- ye as createPostEvent,
2762
- pr as getHash,
2757
+ Ze as Utils,
2758
+ Ne as Viewport,
2759
+ Wt as chatParser,
2760
+ Ce as classNames,
2761
+ _e as compareVersions,
2762
+ be as createPostEvent,
2763
+ hr as getHash,
2763
2764
  ur as init,
2764
2765
  wt as initDataParser,
2765
- N as invokeCustomMethod,
2766
+ O as invokeCustomMethod,
2766
2767
  ft as isColorDark,
2767
2768
  vt as isIframe,
2768
2769
  lt as isRGB,
2769
- Ot as isRGBShort,
2770
+ Dt as isRGBShort,
2770
2771
  H as isRecord,
2771
- sr as isTMA,
2772
- cr as isTimeoutError,
2772
+ Oe as isStableViewportPlatform,
2773
+ rr as isTMA,
2774
+ ar as isTimeoutError,
2773
2775
  mt as launchParamsParser,
2774
- hr as mergeClassNames,
2775
- I as off,
2776
+ cr as mergeClassNames,
2777
+ $ as off,
2776
2778
  y as on,
2777
- or as once,
2778
- er as parseInitData,
2779
- yt as parseLaunchParams,
2779
+ ir as once,
2780
+ tr as parseInitData,
2781
+ jt as parseLaunchParams,
2780
2782
  bt as parseThemeParams,
2781
- f as postEvent,
2783
+ d as postEvent,
2782
2784
  m as request,
2783
- rr as requestThemeParams,
2785
+ er as requestThemeParams,
2784
2786
  At as requestViewport,
2785
2787
  Ct as retrieveLaunchData,
2786
- Zt as serializeLaunchParams,
2787
- Gt as serializeThemeParams,
2788
- nr as setDebug,
2789
- ir as setTargetOrigin,
2790
- ar as subscribe,
2791
- A as supports,
2788
+ Jt as serializeLaunchParams,
2789
+ Ut as serializeThemeParams,
2790
+ sr as setDebug,
2791
+ nr as setTargetOrigin,
2792
+ or as subscribe,
2793
+ R as supports,
2792
2794
  _t as themeParamsParser,
2793
2795
  dt as toRGB,
2794
- be as unsubscribe,
2796
+ we as unsubscribe,
2795
2797
  rt as userParser,
2796
2798
  xt as withTimeout
2797
2799
  };