@tma.js/sdk 1.5.1 → 1.5.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,16 +1,16 @@
1
- var Ie = Object.defineProperty;
2
- var Te = (r, e, t) => e in r ? Ie(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var o = (r, e, t) => (Te(r, typeof e != "symbol" ? e + "" : e, t), t);
4
- class he {
5
- constructor(e, t) {
6
- this.prefix = e, this.enabled = t;
1
+ var It = Object.defineProperty;
2
+ var Tt = (r, t, e) => t in r ? It(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);
4
+ class ht {
5
+ constructor(t, e) {
6
+ this.prefix = t, this.enabled = e;
7
7
  }
8
8
  /**
9
9
  * Prints message into a console in case, logger is currently enabled.
10
10
  * @param level - log level.
11
11
  * @param args - arguments.
12
12
  */
13
- print(e, ...t) {
13
+ print(t, ...e) {
14
14
  if (!this.enabled)
15
15
  return;
16
16
  const s = /* @__PURE__ */ new Date(), n = Intl.DateTimeFormat("en-GB", {
@@ -20,7 +20,7 @@ class he {
20
20
  fractionalSecondDigits: 3,
21
21
  timeZone: "UTC"
22
22
  }).format(s);
23
- console[e](`[${n}]`, this.prefix, ...t);
23
+ console[t](`[${n}]`, this.prefix, ...e);
24
24
  }
25
25
  /**
26
26
  * Disables the logger.
@@ -32,8 +32,8 @@ class he {
32
32
  * Prints error message into a console.
33
33
  * @param args
34
34
  */
35
- error(...e) {
36
- this.print("error", ...e);
35
+ error(...t) {
36
+ this.print("error", ...t);
37
37
  }
38
38
  /**
39
39
  * Enables the logger.
@@ -45,33 +45,33 @@ class he {
45
45
  * Prints log message into a console.
46
46
  * @param args
47
47
  */
48
- log(...e) {
49
- this.print("log", ...e);
48
+ log(...t) {
49
+ this.print("log", ...t);
50
50
  }
51
51
  /**
52
52
  * Prints warning message into a console.
53
53
  * @param args
54
54
  */
55
- warn(...e) {
56
- this.print("warn", ...e);
55
+ warn(...t) {
56
+ this.print("warn", ...t);
57
57
  }
58
58
  }
59
- let ue = "https://web.telegram.org";
60
- const k = new he("[SDK]", !1);
61
- function Qt(r) {
59
+ let ut = "https://web.telegram.org";
60
+ const k = new ht("[SDK]", !1);
61
+ function Qe(r) {
62
62
  if (r) {
63
63
  k.enable();
64
64
  return;
65
65
  }
66
66
  k.disable();
67
67
  }
68
- function Zt(r) {
69
- ue = r;
68
+ function Ze(r) {
69
+ ut = r;
70
70
  }
71
- function $e() {
72
- return ue;
71
+ function $t() {
72
+ return ut;
73
73
  }
74
- function pe() {
74
+ function pt() {
75
75
  try {
76
76
  return window.self !== window.top;
77
77
  } catch {
@@ -81,28 +81,28 @@ function pe() {
81
81
  function W(r) {
82
82
  return typeof r == "object" && r !== null && !Array.isArray(r);
83
83
  }
84
- function Le(r) {
84
+ function Lt(r) {
85
85
  return "external" in r && W(r.external) && "notify" in r.external && typeof r.external.notify == "function";
86
86
  }
87
- function Be(r) {
87
+ function Bt(r) {
88
88
  return "TelegramWebviewProxy" in r && W(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
89
89
  }
90
- function d(r, e, t) {
90
+ function d(r, t, e) {
91
91
  let s = {}, n;
92
- e === void 0 && t === void 0 ? s = {} : e !== void 0 && t !== void 0 ? (s = t, n = e) : e !== void 0 && ("targetOrigin" in e ? s = e : n = e);
93
- const { targetOrigin: i = $e() } = s;
94
- if (k.log(`Calling method "${r}"`, n), pe()) {
92
+ 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);
93
+ const { targetOrigin: i = $t() } = s;
94
+ if (k.log(`Calling method "${r}"`, n), pt()) {
95
95
  window.parent.postMessage(JSON.stringify({
96
96
  eventType: r,
97
97
  eventData: n
98
98
  }), i);
99
99
  return;
100
100
  }
101
- if (Le(window)) {
101
+ if (Lt(window)) {
102
102
  window.external.notify(JSON.stringify({ eventType: r, eventData: n }));
103
103
  return;
104
104
  }
105
- if (Be(window)) {
105
+ if (Bt(window)) {
106
106
  window.TelegramWebviewProxy.postEvent(r, JSON.stringify(n));
107
107
  return;
108
108
  }
@@ -110,24 +110,24 @@ function d(r, e, t) {
110
110
  "Unable to determine current environment and possible way to send event."
111
111
  );
112
112
  }
113
- function Oe(r, e) {
114
- const t = r.split("."), s = e.split("."), n = Math.max(t.length, s.length);
113
+ function Dt(r, t) {
114
+ const e = r.split("."), s = t.split("."), n = Math.max(e.length, s.length);
115
115
  for (let i = 0; i < n; i += 1) {
116
- const a = parseInt(t[i] || "0", 10), c = parseInt(s[i] || "0", 10);
116
+ const a = parseInt(e[i] || "0", 10), c = parseInt(s[i] || "0", 10);
117
117
  if (a !== c)
118
118
  return a > c ? 1 : -1;
119
119
  }
120
120
  return 0;
121
121
  }
122
- function v(r, e) {
123
- return Oe(r, e) <= 0;
122
+ function v(r, t) {
123
+ return Dt(r, t) <= 0;
124
124
  }
125
- function A(r, e, t) {
126
- if (typeof t == "string") {
127
- if (r === "web_app_open_link" && e === "try_instant_view")
128
- return v("6.4", t);
129
- if (r === "web_app_set_header_color" && e === "color")
130
- return v("6.9", t);
125
+ function A(r, t, e) {
126
+ if (typeof e == "string") {
127
+ if (r === "web_app_open_link" && t === "try_instant_view")
128
+ return v("6.4", e);
129
+ if (r === "web_app_set_header_color" && t === "color")
130
+ return v("6.9", e);
131
131
  }
132
132
  switch (r) {
133
133
  case "web_app_open_tg_link":
@@ -136,67 +136,67 @@ function A(r, e, t) {
136
136
  case "web_app_set_background_color":
137
137
  case "web_app_set_header_color":
138
138
  case "web_app_trigger_haptic_feedback":
139
- return v("6.1", e);
139
+ return v("6.1", t);
140
140
  case "web_app_open_popup":
141
- return v("6.2", e);
141
+ return v("6.2", t);
142
142
  case "web_app_close_scan_qr_popup":
143
143
  case "web_app_open_scan_qr_popup":
144
144
  case "web_app_read_text_from_clipboard":
145
- return v("6.4", e);
145
+ return v("6.4", t);
146
146
  case "web_app_switch_inline_query":
147
- return v("6.7", e);
147
+ return v("6.7", t);
148
148
  case "web_app_invoke_custom_method":
149
149
  case "web_app_request_write_access":
150
150
  case "web_app_request_phone":
151
- return v("6.9", e);
151
+ return v("6.9", t);
152
152
  case "web_app_setup_settings_button":
153
- return v("6.10", e);
153
+ return v("6.10", t);
154
154
  default:
155
155
  return !0;
156
156
  }
157
157
  }
158
158
  class K extends Error {
159
- constructor(e, t) {
160
- super(`Method "${e}" is unsupported in the Mini Apps version ${t}.`), Object.setPrototypeOf(this, K.prototype);
159
+ constructor(t, e) {
160
+ super(`Method "${t}" is unsupported in the Mini Apps version ${e}.`), Object.setPrototypeOf(this, K.prototype);
161
161
  }
162
162
  }
163
163
  class Y extends Error {
164
- constructor(e, t, s) {
165
- super(`Parameter "${t}" in method "${e}" is unsupported in the Mini Apps version ${s}.`), Object.setPrototypeOf(this, Y.prototype);
164
+ constructor(t, e, s) {
165
+ super(`Parameter "${e}" in method "${t}" is unsupported in the Mini Apps version ${s}.`), Object.setPrototypeOf(this, Y.prototype);
166
166
  }
167
167
  }
168
- function De(r) {
169
- return (e, t) => {
170
- if (!A(e, r))
171
- throw new K(e, r);
172
- if (W(t)) {
168
+ function Ot(r) {
169
+ return (t, e) => {
170
+ if (!A(t, r))
171
+ throw new K(t, r);
172
+ if (W(e)) {
173
173
  let s;
174
- if (e === "web_app_open_link" && "try_instant_view" in t ? s = "try_instant_view" : e === "web_app_set_header_color" && "color" in t && (s = "color"), s && !A(e, s, r))
175
- throw new Y(e, s, r);
174
+ 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))
175
+ throw new Y(t, s, r);
176
176
  }
177
- return d(e, t);
177
+ return d(t, e);
178
178
  };
179
179
  }
180
- function le(r) {
181
- return ({ req_id: e }) => e === r;
180
+ function lt(r) {
181
+ return ({ req_id: t }) => t === r;
182
182
  }
183
183
  class j extends Error {
184
- constructor(t, { cause: s, type: n } = {}) {
184
+ constructor(e, { cause: s, type: n } = {}) {
185
185
  super(`Unable to parse value${n ? ` as ${n}` : ""}`, { cause: s });
186
186
  /**
187
187
  * Parser name.
188
188
  */
189
189
  o(this, "type");
190
- this.value = t, Object.setPrototypeOf(this, j.prototype), this.type = n;
190
+ this.value = e, Object.setPrototypeOf(this, j.prototype), this.type = n;
191
191
  }
192
192
  }
193
193
  class G extends Error {
194
- constructor(e, { cause: t, type: s } = {}) {
195
- super(`Unable to parse field "${e}"${s ? ` as ${s}` : ""}`, { cause: t }), Object.setPrototypeOf(this, G.prototype);
194
+ constructor(t, { cause: e, type: s } = {}) {
195
+ super(`Unable to parse field "${t}"${s ? ` as ${s}` : ""}`, { cause: e }), Object.setPrototypeOf(this, G.prototype);
196
196
  }
197
197
  }
198
- function de(r, e) {
199
- const t = {};
198
+ function dt(r, t) {
199
+ const e = {};
200
200
  for (const s in r) {
201
201
  const n = r[s];
202
202
  if (!n)
@@ -209,7 +209,7 @@ function de(r, e) {
209
209
  i = n.from || s, a = typeof p == "function" ? p : p.parse.bind(p);
210
210
  }
211
211
  let c;
212
- const u = e(i);
212
+ const u = t(i);
213
213
  try {
214
214
  c = a(u);
215
215
  } catch (p) {
@@ -218,63 +218,63 @@ function de(r, e) {
218
218
  cause: p
219
219
  }) : new G(i, { cause: p });
220
220
  }
221
- c !== void 0 && (t[s] = c);
221
+ c !== void 0 && (e[s] = c);
222
222
  }
223
- return t;
223
+ return e;
224
224
  }
225
225
  function V() {
226
226
  return new TypeError("Value has unexpected type");
227
227
  }
228
228
  function X(r) {
229
- let e = r;
230
- if (typeof e == "string" && (e = JSON.parse(e)), typeof e != "object" || e === null || Array.isArray(e))
229
+ let t = r;
230
+ if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
231
231
  throw V();
232
- return e;
232
+ return t;
233
233
  }
234
234
  class F {
235
- constructor(e, t, s) {
236
- this.parser = e, this.isOptional = t, this.type = s;
235
+ constructor(t, e, s) {
236
+ this.parser = t, this.isOptional = e, this.type = s;
237
237
  }
238
- parse(e) {
239
- if (!(this.isOptional && e === void 0))
238
+ parse(t) {
239
+ if (!(this.isOptional && t === void 0))
240
240
  try {
241
- return this.parser(e);
242
- } catch (t) {
243
- throw new j(e, { type: this.type, cause: t });
241
+ return this.parser(t);
242
+ } catch (e) {
243
+ throw new j(t, { type: this.type, cause: e });
244
244
  }
245
245
  }
246
246
  optional() {
247
247
  return this.isOptional = !0, this;
248
248
  }
249
249
  }
250
- function f(r, e) {
251
- return new F((t) => {
252
- const s = X(t);
253
- return de(r, (n) => s[n]);
254
- }, !1, e);
250
+ function f(r, t) {
251
+ return new F((e) => {
252
+ const s = X(e);
253
+ return dt(r, (n) => s[n]);
254
+ }, !1, t);
255
255
  }
256
- function R(r, e) {
257
- return () => new F(r, !1, e);
256
+ function R(r, t) {
257
+ return () => new F(r, !1, t);
258
258
  }
259
259
  const h = R((r) => {
260
260
  if (typeof r == "string" || typeof r == "number")
261
261
  return r.toString();
262
262
  throw V();
263
263
  }, "string");
264
- function We(r) {
264
+ function Wt(r) {
265
265
  return f({
266
266
  eventType: h(),
267
- eventData: (e) => e
267
+ eventData: (t) => t
268
268
  }).parse(r);
269
269
  }
270
- function He(r, e) {
270
+ function Ht(r, t) {
271
271
  window.dispatchEvent(new MessageEvent("message", {
272
- data: JSON.stringify({ eventType: r, eventData: e }),
272
+ data: JSON.stringify({ eventType: r, eventData: t }),
273
273
  // We specify window.parent to imitate the case, it sent us this event.
274
274
  source: window.parent
275
275
  }));
276
276
  }
277
- function Ne() {
277
+ function Nt() {
278
278
  const r = window;
279
279
  "TelegramGameProxy_receiveEvent" in r || [
280
280
  ["TelegramGameProxy_receiveEvent"],
@@ -283,112 +283,112 @@ function Ne() {
283
283
  // Desktop.
284
284
  ["Telegram", "WebView", "receiveEvent"]
285
285
  // Android and iOS.
286
- ].forEach((e) => {
287
- let t = r;
288
- e.forEach((s, n, i) => {
286
+ ].forEach((t) => {
287
+ let e = r;
288
+ t.forEach((s, n, i) => {
289
289
  if (n === i.length - 1) {
290
- t[s] = He;
290
+ e[s] = Ht;
291
291
  return;
292
292
  }
293
- s in t || (t[s] = {}), t = t[s];
293
+ s in e || (e[s] = {}), e = e[s];
294
294
  });
295
295
  });
296
296
  }
297
- function Ue(r) {
298
- Ne(), window.addEventListener("message", (e) => {
299
- if (e.source === window.parent)
297
+ function Ut(r) {
298
+ Nt(), window.addEventListener("message", (t) => {
299
+ if (t.source === window.parent)
300
300
  try {
301
- const { eventType: t, eventData: s } = We(e.data);
302
- r(t, s);
301
+ const { eventType: e, eventData: s } = Wt(t.data);
302
+ r(e, s);
303
303
  } catch {
304
304
  }
305
305
  });
306
306
  }
307
- function Me() {
307
+ function Mt() {
308
308
  return f({
309
309
  req_id: h(),
310
310
  data: (r) => r === null ? r : h().optional().parse(r)
311
311
  });
312
312
  }
313
- function Ge() {
313
+ function Gt() {
314
314
  return f({
315
315
  req_id: h(),
316
316
  result: (r) => r,
317
317
  error: h().optional()
318
318
  });
319
319
  }
320
- function je() {
320
+ function jt() {
321
321
  return f({
322
322
  slug: h(),
323
323
  status: h()
324
324
  });
325
325
  }
326
- function Fe() {
326
+ function Ft() {
327
327
  return f({ status: h() });
328
328
  }
329
- function ze() {
329
+ function zt() {
330
330
  return f({
331
331
  button_id: (r) => r == null ? void 0 : h().parse(r)
332
332
  });
333
333
  }
334
- function Je() {
334
+ function Jt() {
335
335
  return f({
336
336
  data: h().optional()
337
337
  });
338
338
  }
339
- function ee(r) {
339
+ function tt(r) {
340
340
  return /^#[\da-f]{6}$/i.test(r);
341
341
  }
342
- function Qe(r) {
342
+ function Qt(r) {
343
343
  return /^#[\da-f]{3}$/i.test(r);
344
344
  }
345
- function fe(r) {
346
- const e = r.replace(/\s/g, "").toLowerCase();
347
- if (ee(e))
348
- return e;
349
- if (Qe(e)) {
345
+ function ft(r) {
346
+ const t = r.replace(/\s/g, "").toLowerCase();
347
+ if (tt(t))
348
+ return t;
349
+ if (Qt(t)) {
350
350
  let s = "#";
351
351
  for (let n = 0; n < 3; n += 1)
352
- s += e[1 + n].repeat(2);
352
+ s += t[1 + n].repeat(2);
353
353
  return s;
354
354
  }
355
- const t = e.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/) || e.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);
356
- if (t === null)
355
+ const e = t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/) || t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);
356
+ if (e === null)
357
357
  throw new Error(`Value "${r}" does not satisfy any of known RGB formats.`);
358
- return t.slice(1).reduce((s, n) => {
358
+ return e.slice(1).reduce((s, n) => {
359
359
  const i = parseInt(n, 10).toString(16);
360
360
  return s + (i.length === 1 ? "0" : "") + i;
361
361
  }, "#");
362
362
  }
363
- const ge = R((r) => fe(h().parse(r)), "rgb");
364
- function Ze() {
363
+ const gt = R((r) => ft(h().parse(r)), "rgb");
364
+ function Zt() {
365
365
  return f({
366
366
  theme_params: (r) => {
367
- const e = ge().optional();
368
- return Object.entries(X(r)).reduce((t, [s, n]) => (t[s] = e.parse(n), t), {});
367
+ const t = gt().optional();
368
+ return Object.entries(X(r)).reduce((e, [s, n]) => (e[s] = t.parse(n), e), {});
369
369
  }
370
370
  });
371
371
  }
372
372
  const P = R((r) => {
373
373
  if (typeof r == "boolean")
374
374
  return r;
375
- const e = String(r);
376
- if (e === "1" || e === "true")
375
+ const t = String(r);
376
+ if (t === "1" || t === "true")
377
377
  return !0;
378
- if (e === "0" || e === "false")
378
+ if (t === "0" || t === "false")
379
379
  return !1;
380
380
  throw V();
381
381
  }, "boolean"), x = R((r) => {
382
382
  if (typeof r == "number")
383
383
  return r;
384
384
  if (typeof r == "string") {
385
- const e = Number(r);
386
- if (!Number.isNaN(e))
387
- return e;
385
+ const t = Number(r);
386
+ if (!Number.isNaN(t))
387
+ return t;
388
388
  }
389
389
  throw V();
390
390
  }, "number");
391
- function Ke() {
391
+ function Kt() {
392
392
  return f({
393
393
  height: x(),
394
394
  width: (r) => r == null ? window.innerWidth : x().parse(r),
@@ -396,7 +396,7 @@ function Ke() {
396
396
  is_expanded: P()
397
397
  });
398
398
  }
399
- function Ye() {
399
+ function Yt() {
400
400
  return f({ status: h() });
401
401
  }
402
402
  class w {
@@ -410,15 +410,15 @@ class w {
410
410
  * @param listener - event listener.
411
411
  * @param once - should listener called only once.
412
412
  */
413
- addListener(e, t, s) {
414
- let n = this.listeners.get(e);
415
- return n || (n = [], this.listeners.set(e, n)), n.push([t, s]), () => this.off(e, t);
413
+ addListener(t, e, s) {
414
+ let n = this.listeners.get(t);
415
+ return n || (n = [], this.listeners.set(t, n)), n.push([e, s]), () => this.off(t, e);
416
416
  }
417
- emit(e, ...t) {
418
- this.subscribeListeners.forEach((n) => n(e, ...t));
419
- const s = this.listeners.get(e);
417
+ emit(t, ...e) {
418
+ this.subscribeListeners.forEach((n) => n(t, ...e));
419
+ const s = this.listeners.get(t);
420
420
  s && s.forEach(([n, i], a) => {
421
- n(...t), i && s.splice(a, 1);
421
+ n(...e), i && s.splice(a, 1);
422
422
  });
423
423
  }
424
424
  /**
@@ -427,8 +427,8 @@ class w {
427
427
  * @param listener - event listener.
428
428
  * @returns Function to remove event listener.
429
429
  */
430
- on(e, t) {
431
- return this.addListener(e, t, !1);
430
+ on(t, e) {
431
+ return this.addListener(t, e, !1);
432
432
  }
433
433
  /**
434
434
  * Adds event listener following the logic, described in `on` method, but calls specified
@@ -438,8 +438,8 @@ class w {
438
438
  * @returns Function to remove event listener.
439
439
  * @see on
440
440
  */
441
- once(e, t) {
442
- return this.addListener(e, t, !0);
441
+ once(t, e) {
442
+ return this.addListener(t, e, !0);
443
443
  }
444
444
  /**
445
445
  * Removes event listener. In case, specified listener was bound several times, it removes
@@ -447,11 +447,11 @@ class w {
447
447
  * @param event - event name.
448
448
  * @param listener - event listener.
449
449
  */
450
- off(e, t) {
451
- const s = this.listeners.get(e);
450
+ off(t, e) {
451
+ const s = this.listeners.get(t);
452
452
  if (s) {
453
453
  for (let n = 0; n < s.length; n += 1)
454
- if (t === s[n][0]) {
454
+ if (e === s[n][0]) {
455
455
  s.splice(n, 1);
456
456
  return;
457
457
  }
@@ -464,8 +464,8 @@ class w {
464
464
  * @see on
465
465
  * @see once
466
466
  */
467
- subscribe(e) {
468
- return this.subscribeListeners.push(e), () => this.unsubscribe(e);
467
+ subscribe(t) {
468
+ return this.subscribeListeners.push(t), () => this.unsubscribe(t);
469
469
  }
470
470
  /**
471
471
  * Removes global event listener. In case, specified listener was bound several times, it removes
@@ -473,60 +473,60 @@ class w {
473
473
  * @param listener - events listener.
474
474
  * @returns Function to remove event listener.
475
475
  */
476
- unsubscribe(e) {
477
- for (let t = 0; t < this.subscribeListeners.length; t += 1)
478
- if (this.subscribeListeners[t] === e) {
479
- this.subscribeListeners.splice(t, 1);
476
+ unsubscribe(t) {
477
+ for (let e = 0; e < this.subscribeListeners.length; e += 1)
478
+ if (this.subscribeListeners[e] === t) {
479
+ this.subscribeListeners.splice(e, 1);
480
480
  return;
481
481
  }
482
482
  }
483
483
  }
484
- function Xe() {
485
- const r = new w(), e = (t, ...s) => {
486
- k.log("Emitting processed event:", t, ...s), r.emit(t, ...s);
484
+ function Xt() {
485
+ const r = new w(), t = (e, ...s) => {
486
+ k.log("Emitting processed event:", e, ...s), r.emit(e, ...s);
487
487
  };
488
488
  return window.addEventListener("resize", () => {
489
- e("viewport_changed", {
489
+ t("viewport_changed", {
490
490
  width: window.innerWidth,
491
491
  height: window.innerHeight,
492
492
  is_state_stable: !0,
493
493
  is_expanded: !0
494
494
  });
495
- }), Ue((t, s) => {
496
- k.log("Received raw event:", t, s);
495
+ }), Ut((e, s) => {
496
+ k.log("Received raw event:", e, s);
497
497
  try {
498
- switch (t) {
498
+ switch (e) {
499
499
  case "viewport_changed":
500
- return e(t, Ke().parse(s));
500
+ return t(e, Kt().parse(s));
501
501
  case "theme_changed":
502
- return e(t, Ze().parse(s));
502
+ return t(e, Zt().parse(s));
503
503
  case "popup_closed":
504
504
  return (
505
505
  // Sent on desktop.
506
- s == null ? e(t, {}) : e(t, ze().parse(s))
506
+ s == null ? t(e, {}) : t(e, zt().parse(s))
507
507
  );
508
508
  case "set_custom_style":
509
- return e(t, h().parse(s));
509
+ return t(e, h().parse(s));
510
510
  case "qr_text_received":
511
- return e(t, Je().parse(s));
511
+ return t(e, Jt().parse(s));
512
512
  case "clipboard_text_received":
513
- return e(t, Me().parse(s));
513
+ return t(e, Mt().parse(s));
514
514
  case "invoice_closed":
515
- return e(t, je().parse(s));
515
+ return t(e, jt().parse(s));
516
516
  case "phone_requested":
517
- return e("phone_requested", Fe().parse(s));
517
+ return t("phone_requested", Ft().parse(s));
518
518
  case "custom_method_invoked":
519
- return e("custom_method_invoked", Ge().parse(s));
519
+ return t("custom_method_invoked", Gt().parse(s));
520
520
  case "write_access_requested":
521
- return e("write_access_requested", Ye().parse(s));
521
+ return t("write_access_requested", Yt().parse(s));
522
522
  case "main_button_pressed":
523
523
  case "back_button_pressed":
524
524
  case "settings_button_pressed":
525
525
  case "scan_qr_popup_closed":
526
526
  case "reload_iframe":
527
- return e(t);
527
+ return t(e);
528
528
  default:
529
- return e(t, s);
529
+ return t(e, s);
530
530
  }
531
531
  } catch (n) {
532
532
  k.error("Error processing event:", n);
@@ -536,37 +536,37 @@ function Xe() {
536
536
  const J = "telegram-mini-apps-cached-emitter";
537
537
  function H() {
538
538
  const r = window;
539
- return r[J] === void 0 && (r[J] = Xe()), r[J];
539
+ return r[J] === void 0 && (r[J] = Xt()), r[J];
540
540
  }
541
- function I(r, e) {
542
- H().off(r, e);
541
+ function I(r, t) {
542
+ H().off(r, t);
543
543
  }
544
- function E(r, e) {
545
- return H().on(r, e), () => I(r, e);
544
+ function E(r, t) {
545
+ return H().on(r, t), () => I(r, t);
546
546
  }
547
547
  class z extends Error {
548
- constructor(e) {
549
- super(`Async call timeout exceeded. Timeout: ${e}`), Object.setPrototypeOf(this, z.prototype);
548
+ constructor(t) {
549
+ super(`Async call timeout exceeded. Timeout: ${t}`), Object.setPrototypeOf(this, z.prototype);
550
550
  }
551
551
  }
552
- function et(r) {
553
- return new Promise((e, t) => {
554
- setTimeout(t, r, new z(r));
552
+ function te(r) {
553
+ return new Promise((t, e) => {
554
+ setTimeout(e, r, new z(r));
555
555
  });
556
556
  }
557
- function we(r, e) {
557
+ function wt(r, t) {
558
558
  return Promise.race([
559
559
  typeof r == "function" ? r() : r,
560
- et(e)
560
+ te(t)
561
561
  ]);
562
562
  }
563
- async function y(r, e, t) {
563
+ async function y(r, t, e) {
564
564
  let s;
565
565
  const n = new Promise((b) => {
566
566
  s = b;
567
- }), i = e ? {
568
- ...t,
569
- event: e,
567
+ }), i = t ? {
568
+ ...e,
569
+ event: t,
570
570
  method: r
571
571
  } : r, {
572
572
  method: a,
@@ -578,12 +578,12 @@ async function y(r, e, t) {
578
578
  (b) => E(b, (l) => (!u || u(l)) && s(l))
579
579
  );
580
580
  try {
581
- return p(a, i.params), await (g ? we(n, g) : n);
581
+ return p(a, i.params), await (g ? wt(n, g) : n);
582
582
  } finally {
583
583
  _.forEach((b) => b());
584
584
  }
585
585
  }
586
- async function O(r, e, t, s = {}) {
586
+ async function D(r, t, e, s = {}) {
587
587
  const {
588
588
  result: n,
589
589
  error: i
@@ -591,51 +591,51 @@ async function O(r, e, t, s = {}) {
591
591
  ...s,
592
592
  params: {
593
593
  method: r,
594
- params: e,
595
- req_id: t
594
+ params: t,
595
+ req_id: e
596
596
  },
597
- capture: le(t)
597
+ capture: lt(e)
598
598
  });
599
599
  if (i)
600
600
  throw new Error(i);
601
601
  return n;
602
602
  }
603
- function Kt(r, e) {
604
- return H().once(r, e), () => I(r, e);
603
+ function Ke(r, t) {
604
+ return H().once(r, t), () => I(r, t);
605
605
  }
606
- function tt(r) {
606
+ function ee(r) {
607
607
  H().unsubscribe(r);
608
608
  }
609
- function Yt(r) {
610
- return H().subscribe(r), () => tt(r);
609
+ function Ye(r) {
610
+ return H().subscribe(r), () => ee(r);
611
611
  }
612
- function U(r, e) {
613
- return r + (r.length && e.length ? ` ${e}` : e);
612
+ function U(r, t) {
613
+ return r + (r.length && t.length ? ` ${t}` : t);
614
614
  }
615
- function _e(...r) {
616
- return r.reduce((e, t) => typeof t == "string" ? U(e, t) : W(t) ? U(e, Object.entries(t).reduce((s, n) => n[1] ? U(s, n[0]) : s, "")) : Array.isArray(t) ? U(e, _e(...t)) : e, "");
615
+ function _t(...r) {
616
+ return r.reduce((t, e) => typeof e == "string" ? U(t, e) : W(e) ? U(t, Object.entries(e).reduce((s, n) => n[1] ? U(s, n[0]) : s, "")) : Array.isArray(e) ? U(t, _t(...e)) : t, "");
617
617
  }
618
- function Xt(...r) {
619
- return r.reduce((e, t) => (W(t) && Object.entries(t).forEach(([s, n]) => {
620
- const i = _e(e[s], n);
621
- i.length > 0 && (e[s] = i);
622
- }), e), {});
618
+ function Xe(...r) {
619
+ return r.reduce((t, e) => (W(e) && Object.entries(e).forEach(([s, n]) => {
620
+ const i = _t(t[s], n);
621
+ i.length > 0 && (t[s] = i);
622
+ }), t), {});
623
623
  }
624
- function be(r) {
625
- const e = fe(r);
624
+ function bt(r) {
625
+ const t = ft(r);
626
626
  return Math.sqrt(
627
627
  [0.299, 0.587, 0.114].reduce((s, n, i) => {
628
- const a = parseInt(e.slice(1 + i * 2, 1 + (i + 1) * 2), 16);
628
+ const a = parseInt(t.slice(1 + i * 2, 1 + (i + 1) * 2), 16);
629
629
  return s + a * a * n;
630
630
  }, 0)
631
631
  ) < 120;
632
632
  }
633
633
  class m {
634
- constructor(e, t) {
635
- this.state = e, this.ee = t;
634
+ constructor(t, e) {
635
+ this.state = t, this.ee = e;
636
636
  }
637
- internalSet(e, t) {
638
- return this.state[e] === t || t === void 0 ? !1 : (this.state[e] = t, this.ee.emit(`change:${e}`, t), !0);
637
+ internalSet(t, e) {
638
+ return this.state[t] === e || e === void 0 ? !1 : (this.state[t] = e, this.ee.emit(`change:${t}`, e), !0);
639
639
  }
640
640
  /**
641
641
  * Returns copy of current state.
@@ -643,28 +643,28 @@ class m {
643
643
  clone() {
644
644
  return { ...this.state };
645
645
  }
646
- set(e, t) {
646
+ set(t, e) {
647
647
  let s = !1;
648
- if (typeof e == "string")
649
- s = this.internalSet(e, t);
648
+ if (typeof t == "string")
649
+ s = this.internalSet(t, e);
650
650
  else
651
- for (const n in e)
652
- this.internalSet(n, e[n]) && (s = !0);
651
+ for (const n in t)
652
+ this.internalSet(n, t[n]) && (s = !0);
653
653
  s && this.ee.emit("change");
654
654
  }
655
655
  /**
656
656
  * Returns value by specified key.
657
657
  * @param key - state key.
658
658
  */
659
- get(e) {
660
- return this.state[e];
659
+ get(t) {
660
+ return this.state[t];
661
661
  }
662
662
  }
663
- function C(r, e) {
664
- return (t) => A(e[t], r);
663
+ function C(r, t) {
664
+ return (e) => A(t[e], r);
665
665
  }
666
- class rt {
667
- constructor(e, t, s = d) {
666
+ class re {
667
+ constructor(t, e, s = d) {
668
668
  o(this, "ee", new w());
669
669
  o(this, "state");
670
670
  /**
@@ -672,24 +672,24 @@ class rt {
672
672
  * @param event - event name.
673
673
  * @param listener - event listener.
674
674
  */
675
- o(this, "on", (e, t) => e === "click" ? E("back_button_pressed", t) : this.ee.on(e, t));
675
+ o(this, "on", (t, e) => t === "click" ? E("back_button_pressed", e) : this.ee.on(t, e));
676
676
  /**
677
677
  * Removes event listener.
678
678
  * @param event - event name.
679
679
  * @param listener - event listener.
680
680
  */
681
- o(this, "off", (e, t) => e === "click" ? I("back_button_pressed", t) : this.ee.off(e, t));
681
+ o(this, "off", (t, e) => t === "click" ? I("back_button_pressed", e) : this.ee.off(t, e));
682
682
  /**
683
683
  * Checks if specified method is supported by current component.
684
684
  */
685
685
  o(this, "supports");
686
- this.postEvent = s, this.state = new m({ isVisible: e }, this.ee), this.supports = C(t, {
686
+ this.postEvent = s, this.state = new m({ isVisible: t }, this.ee), this.supports = C(e, {
687
687
  show: "web_app_setup_back_button",
688
688
  hide: "web_app_setup_back_button"
689
689
  });
690
690
  }
691
- set isVisible(e) {
692
- this.state.set("isVisible", e), this.postEvent("web_app_setup_back_button", { is_visible: e });
691
+ set isVisible(t) {
692
+ this.state.set("isVisible", t), this.postEvent("web_app_setup_back_button", { is_visible: t });
693
693
  }
694
694
  /**
695
695
  * True if BackButton is currently visible.
@@ -710,8 +710,8 @@ class rt {
710
710
  this.isVisible = !0;
711
711
  }
712
712
  }
713
- class st {
714
- constructor(e, t = d) {
713
+ class se {
714
+ constructor(t, e = d) {
715
715
  o(this, "ee", new w());
716
716
  o(this, "state");
717
717
  /**
@@ -722,10 +722,10 @@ class st {
722
722
  * Removes event listener.
723
723
  */
724
724
  o(this, "off", this.ee.off.bind(this.ee));
725
- this.postEvent = t, this.state = new m({ isConfirmationNeeded: e }, this.ee);
725
+ this.postEvent = e, this.state = new m({ isConfirmationNeeded: t }, this.ee);
726
726
  }
727
- set isConfirmationNeeded(e) {
728
- this.state.set("isConfirmationNeeded", e), this.postEvent("web_app_setup_closing_behavior", { need_confirmation: e });
727
+ set isConfirmationNeeded(t) {
728
+ this.state.set("isConfirmationNeeded", t), this.postEvent("web_app_setup_closing_behavior", { need_confirmation: t });
729
729
  }
730
730
  /**
731
731
  * Returns true, if the confirmation dialog enabled while the user is trying
@@ -749,45 +749,45 @@ class st {
749
749
  this.isConfirmationNeeded = !0;
750
750
  }
751
751
  }
752
- function nt(r) {
752
+ function ne(r) {
753
753
  if (Array.isArray(r))
754
754
  return r;
755
755
  if (typeof r == "string")
756
756
  try {
757
- const e = JSON.parse(r);
758
- if (Array.isArray(e))
759
- return e;
757
+ const t = JSON.parse(r);
758
+ if (Array.isArray(t))
759
+ return t;
760
760
  } catch {
761
761
  }
762
762
  throw V();
763
763
  }
764
- class it extends F {
765
- constructor(t, s, n) {
766
- super(nt, s, n);
764
+ class ie extends F {
765
+ constructor(e, s, n) {
766
+ super(ne, s, n);
767
767
  o(this, "itemParser");
768
- this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
768
+ this.itemParser = typeof e == "function" ? e : e.parse.bind(e);
769
769
  }
770
- parse(t) {
771
- const s = super.parse(t);
770
+ parse(e) {
771
+ const s = super.parse(e);
772
772
  return s === void 0 ? s : s.map(this.itemParser);
773
773
  }
774
- of(t) {
775
- return this.itemParser = typeof t == "function" ? t : t.parse.bind(t), this;
774
+ of(e) {
775
+ return this.itemParser = typeof e == "function" ? e : e.parse.bind(e), this;
776
776
  }
777
777
  }
778
- function ot(r) {
779
- return new it((e) => e, !1, r);
778
+ function oe(r) {
779
+ return new ie((t) => t, !1, r);
780
780
  }
781
- function ne(r, e) {
782
- return r.reduce((t, s) => (t[s] = e, t), {});
781
+ function nt(r, t) {
782
+ return r.reduce((e, s) => (e[s] = t, e), {});
783
783
  }
784
- class at {
785
- constructor(e, t, s = d) {
784
+ class ae {
785
+ constructor(t, e, s = d) {
786
786
  /**
787
787
  * Checks if specified method is supported by current component.
788
788
  */
789
789
  o(this, "supports");
790
- this.createRequestId = t, this.postEvent = s, this.supports = C(e, {
790
+ this.createRequestId = e, this.postEvent = s, this.supports = C(t, {
791
791
  delete: "web_app_invoke_custom_method",
792
792
  get: "web_app_invoke_custom_method",
793
793
  getKeys: "web_app_invoke_custom_method",
@@ -799,41 +799,41 @@ class at {
799
799
  * @param keyOrKeys - key or keys to delete.
800
800
  * @param options - request execution options.
801
801
  */
802
- async delete(e, t = {}) {
803
- const s = Array.isArray(e) ? e : [e];
804
- s.length !== 0 && await O(
802
+ async delete(t, e = {}) {
803
+ const s = Array.isArray(t) ? t : [t];
804
+ s.length !== 0 && await D(
805
805
  "deleteStorageValues",
806
806
  { keys: s },
807
807
  this.createRequestId(),
808
- { ...t, postEvent: this.postEvent }
808
+ { ...e, postEvent: this.postEvent }
809
809
  );
810
810
  }
811
811
  /**
812
812
  * Returns list of all keys presented in the cloud storage.
813
813
  * @param options - request execution options.
814
814
  */
815
- async getKeys(e = {}) {
816
- const t = await O(
815
+ async getKeys(t = {}) {
816
+ const e = await D(
817
817
  "getStorageKeys",
818
818
  {},
819
819
  this.createRequestId(),
820
- { ...e, postEvent: this.postEvent }
820
+ { ...t, postEvent: this.postEvent }
821
821
  );
822
- return ot().of(h()).parse(t);
822
+ return oe().of(h()).parse(e);
823
823
  }
824
- async get(e, t = {}) {
825
- const s = Array.isArray(e) ? e : [e];
824
+ async get(t, e = {}) {
825
+ const s = Array.isArray(t) ? t : [t];
826
826
  if (s.length === 0)
827
- return ne(s, "");
827
+ return nt(s, "");
828
828
  const n = f(
829
- ne(s, h())
830
- ), i = await O(
829
+ nt(s, h())
830
+ ), i = await D(
831
831
  "getStorageValues",
832
832
  { keys: s },
833
833
  this.createRequestId(),
834
- { ...t, postEvent: this.postEvent }
834
+ { ...e, postEvent: this.postEvent }
835
835
  ).then((a) => n.parse(a));
836
- return Array.isArray(e) ? i : i[e];
836
+ return Array.isArray(t) ? i : i[t];
837
837
  }
838
838
  /**
839
839
  * Saves specified value by key.
@@ -841,22 +841,22 @@ class at {
841
841
  * @param value - storage value.
842
842
  * @param options - request execution options.
843
843
  */
844
- async set(e, t, s = {}) {
845
- await O(
844
+ async set(t, e, s = {}) {
845
+ await D(
846
846
  "saveStorageValue",
847
- { key: e, value: t },
847
+ { key: t, value: e },
848
848
  this.createRequestId(),
849
849
  { ...s, postEvent: this.postEvent }
850
850
  );
851
851
  }
852
852
  }
853
- class ct {
854
- constructor(e, t = d) {
853
+ class ce {
854
+ constructor(t, e = d) {
855
855
  /**
856
856
  * Checks if specified method is supported by current component.
857
857
  */
858
858
  o(this, "supports");
859
- this.postEvent = t, this.supports = C(e, {
859
+ this.postEvent = e, this.supports = C(t, {
860
860
  impactOccurred: "web_app_trigger_haptic_feedback",
861
861
  notificationOccurred: "web_app_trigger_haptic_feedback",
862
862
  selectionChanged: "web_app_trigger_haptic_feedback"
@@ -867,10 +867,10 @@ class ct {
867
867
  * appropriate haptics based on style value passed.
868
868
  * @param style - impact style.
869
869
  */
870
- impactOccurred(e) {
870
+ impactOccurred(t) {
871
871
  this.postEvent("web_app_trigger_haptic_feedback", {
872
872
  type: "impact",
873
- impact_style: e
873
+ impact_style: t
874
874
  });
875
875
  }
876
876
  /**
@@ -879,10 +879,10 @@ class ct {
879
879
  * type value passed.
880
880
  * @param type - notification type.
881
881
  */
882
- notificationOccurred(e) {
882
+ notificationOccurred(t) {
883
883
  this.postEvent("web_app_trigger_haptic_feedback", {
884
884
  type: "notification",
885
- notification_type: e
885
+ notification_type: t
886
886
  });
887
887
  }
888
888
  /**
@@ -896,7 +896,7 @@ class ct {
896
896
  this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
897
897
  }
898
898
  }
899
- function ht() {
899
+ function he() {
900
900
  return f({
901
901
  id: x(),
902
902
  type: h(),
@@ -908,9 +908,9 @@ function ht() {
908
908
  username: h().optional()
909
909
  }, "Chat");
910
910
  }
911
- class ut {
912
- constructor(e) {
913
- this.initData = e;
911
+ class ue {
912
+ constructor(t) {
913
+ this.initData = t;
914
914
  }
915
915
  /**
916
916
  * @see InitDataParsed.authDate
@@ -929,8 +929,8 @@ class ut {
929
929
  * the [answerWebAppQuery](https://core.telegram.org/bots/api#answerwebappquery) method.
930
930
  */
931
931
  get canSendAfterDate() {
932
- const { canSendAfter: e } = this;
933
- return e === void 0 ? void 0 : new Date(this.authDate.getTime() + e * 1e3);
932
+ const { canSendAfter: t } = this;
933
+ return t === void 0 ? void 0 : new Date(this.authDate.getTime() + t * 1e3);
934
934
  }
935
935
  /**
936
936
  * @see InitDataParsed.chat
@@ -981,7 +981,7 @@ class ut {
981
981
  return this.initData.user;
982
982
  }
983
983
  }
984
- function ie() {
984
+ function it() {
985
985
  return f({
986
986
  addedToAttachmentMenu: {
987
987
  type: P().optional(),
@@ -1019,29 +1019,29 @@ function ie() {
1019
1019
  username: h().optional()
1020
1020
  }, "User");
1021
1021
  }
1022
- const me = R((r) => r instanceof Date ? r : new Date(x().parse(r) * 1e3), "Date");
1023
- function te(r, e) {
1024
- return new F((t) => {
1025
- if (typeof t != "string" && !(t instanceof URLSearchParams))
1022
+ const mt = R((r) => r instanceof Date ? r : new Date(x().parse(r) * 1e3), "Date");
1023
+ function et(r, t) {
1024
+ return new F((e) => {
1025
+ if (typeof e != "string" && !(e instanceof URLSearchParams))
1026
1026
  throw V();
1027
- const s = typeof t == "string" ? new URLSearchParams(t) : t;
1028
- return de(r, (n) => {
1027
+ const s = typeof e == "string" ? new URLSearchParams(e) : e;
1028
+ return dt(r, (n) => {
1029
1029
  const i = s.get(n);
1030
1030
  return i === null ? void 0 : i;
1031
1031
  });
1032
- }, !1, e);
1032
+ }, !1, t);
1033
1033
  }
1034
- function ye() {
1035
- return te({
1034
+ function yt() {
1035
+ return et({
1036
1036
  authDate: {
1037
- type: me(),
1037
+ type: mt(),
1038
1038
  from: "auth_date"
1039
1039
  },
1040
1040
  canSendAfter: {
1041
1041
  type: x().optional(),
1042
1042
  from: "can_send_after"
1043
1043
  },
1044
- chat: ht().optional(),
1044
+ chat: he().optional(),
1045
1045
  chatInstance: {
1046
1046
  type: h().optional(),
1047
1047
  from: "chat_instance"
@@ -1055,28 +1055,28 @@ function ye() {
1055
1055
  type: h().optional(),
1056
1056
  from: "query_id"
1057
1057
  },
1058
- receiver: ie().optional(),
1058
+ receiver: it().optional(),
1059
1059
  startParam: {
1060
1060
  type: h().optional(),
1061
1061
  from: "start_param"
1062
1062
  },
1063
- user: ie().optional()
1063
+ user: it().optional()
1064
1064
  }, "InitData");
1065
1065
  }
1066
- function er(r) {
1067
- return ye().parse(r);
1066
+ function tr(r) {
1067
+ return yt().parse(r);
1068
1068
  }
1069
- function pt(r) {
1070
- const { hostname: e, pathname: t } = new URL(r, window.location.href);
1071
- if (e !== "t.me")
1072
- throw new Error(`Incorrect hostname: ${e}`);
1073
- const s = t.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1069
+ function pe(r) {
1070
+ const { hostname: t, pathname: e } = new URL(r, window.location.href);
1071
+ if (t !== "t.me")
1072
+ throw new Error(`Incorrect hostname: ${t}`);
1073
+ const s = e.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1074
1074
  if (s === null)
1075
1075
  throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
1076
1076
  return s[2];
1077
1077
  }
1078
- class lt {
1079
- constructor(e, t = d) {
1078
+ class le {
1079
+ constructor(t, e = d) {
1080
1080
  o(this, "ee", new w());
1081
1081
  o(this, "state");
1082
1082
  /**
@@ -1091,10 +1091,10 @@ class lt {
1091
1091
  * Checks if specified method is supported by current component.
1092
1092
  */
1093
1093
  o(this, "supports");
1094
- this.postEvent = t, this.state = new m({ isOpened: !1 }, this.ee), this.supports = C(e, { open: "web_app_open_invoice" });
1094
+ this.postEvent = e, this.state = new m({ isOpened: !1 }, this.ee), this.supports = C(t, { open: "web_app_open_invoice" });
1095
1095
  }
1096
- set isOpened(e) {
1097
- this.state.set("isOpened", e);
1096
+ set isOpened(t) {
1097
+ this.state.set("isOpened", t);
1098
1098
  }
1099
1099
  /**
1100
1100
  * True if invoice is currently opened.
@@ -1102,10 +1102,10 @@ class lt {
1102
1102
  get isOpened() {
1103
1103
  return this.state.get("isOpened");
1104
1104
  }
1105
- async open(e, t) {
1105
+ async open(t, e) {
1106
1106
  if (this.isOpened)
1107
1107
  throw new Error("Invoice is already opened");
1108
- const s = t ? pt(e) : e;
1108
+ const s = e ? pe(t) : t;
1109
1109
  this.isOpened = !0;
1110
1110
  try {
1111
1111
  return (await y("web_app_open_invoice", "invoice_closed", {
@@ -1120,8 +1120,8 @@ class lt {
1120
1120
  }
1121
1121
  }
1122
1122
  }
1123
- class dt {
1124
- constructor(e) {
1123
+ class de {
1124
+ constructor(t) {
1125
1125
  o(this, "ee", new w());
1126
1126
  o(this, "state");
1127
1127
  o(this, "postEvent");
@@ -1130,28 +1130,28 @@ class dt {
1130
1130
  * @param event - event name.
1131
1131
  * @param listener - event listener.
1132
1132
  */
1133
- o(this, "on", (e, t) => (
1133
+ o(this, "on", (t, e) => (
1134
1134
  // FIXME: Event 'main_button_pressed' is still being received on Android
1135
1135
  // even if the main button is disabled.
1136
1136
  // Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/3
1137
- e === "click" ? E("main_button_pressed", t) : this.ee.on(e, t)
1137
+ t === "click" ? E("main_button_pressed", e) : this.ee.on(t, e)
1138
1138
  ));
1139
1139
  /**
1140
1140
  * Removes event listener.
1141
1141
  * @param event - event name.
1142
1142
  * @param listener - event listener.
1143
1143
  */
1144
- o(this, "off", (e, t) => e === "click" ? I("main_button_pressed", t) : this.ee.off(e, t));
1144
+ o(this, "off", (t, e) => t === "click" ? I("main_button_pressed", e) : this.ee.off(t, e));
1145
1145
  const {
1146
- postEvent: t = d,
1146
+ postEvent: e = d,
1147
1147
  text: s,
1148
1148
  textColor: n,
1149
1149
  backgroundColor: i,
1150
1150
  isEnabled: a,
1151
1151
  isVisible: c,
1152
1152
  isLoaderVisible: u
1153
- } = e;
1154
- this.postEvent = t, this.state = new m({
1153
+ } = t;
1154
+ this.postEvent = e, this.state = new m({
1155
1155
  backgroundColor: i,
1156
1156
  isEnabled: a,
1157
1157
  isVisible: c,
@@ -1173,8 +1173,8 @@ class dt {
1173
1173
  text_color: this.textColor
1174
1174
  });
1175
1175
  }
1176
- set isEnabled(e) {
1177
- this.setParams({ isEnabled: e });
1176
+ set isEnabled(t) {
1177
+ this.setParams({ isEnabled: t });
1178
1178
  }
1179
1179
  /**
1180
1180
  * True if the Main Button is currently enabled.
@@ -1182,8 +1182,8 @@ class dt {
1182
1182
  get isEnabled() {
1183
1183
  return this.state.get("isEnabled");
1184
1184
  }
1185
- set isLoaderVisible(e) {
1186
- this.setParams({ isLoaderVisible: e });
1185
+ set isLoaderVisible(t) {
1186
+ this.setParams({ isLoaderVisible: t });
1187
1187
  }
1188
1188
  /**
1189
1189
  * True if the Main Button loader is currently visible.
@@ -1191,8 +1191,8 @@ class dt {
1191
1191
  get isLoaderVisible() {
1192
1192
  return this.state.get("isLoaderVisible");
1193
1193
  }
1194
- set isVisible(e) {
1195
- this.setParams({ isVisible: e });
1194
+ set isVisible(t) {
1195
+ this.setParams({ isVisible: t });
1196
1196
  }
1197
1197
  /**
1198
1198
  * True if the Main Button is currently visible.
@@ -1260,32 +1260,32 @@ class dt {
1260
1260
  * Sets new Main Button text. Minimal length for text is 1 symbol, and maximum is 64 symbols.
1261
1261
  * @param text - new text.
1262
1262
  */
1263
- setText(e) {
1264
- return this.setParams({ text: e });
1263
+ setText(t) {
1264
+ return this.setParams({ text: t });
1265
1265
  }
1266
1266
  /**
1267
1267
  * Sets new Main Button text color.
1268
1268
  * @param textColor - new text color.
1269
1269
  */
1270
- setTextColor(e) {
1271
- return this.setParams({ textColor: e });
1270
+ setTextColor(t) {
1271
+ return this.setParams({ textColor: t });
1272
1272
  }
1273
1273
  /**
1274
1274
  * Updates current Main Button color.
1275
1275
  * @param backgroundColor - color to set.
1276
1276
  */
1277
- setBackgroundColor(e) {
1278
- return this.setParams({ backgroundColor: e });
1277
+ setBackgroundColor(t) {
1278
+ return this.setParams({ backgroundColor: t });
1279
1279
  }
1280
1280
  /**
1281
1281
  * Allows setting multiple Main Button parameters.
1282
1282
  * @param params - Main Button parameters.
1283
1283
  */
1284
- setParams(e) {
1285
- return this.state.set(e), this.commit(), this;
1284
+ setParams(t) {
1285
+ return this.state.set(t), this.commit(), this;
1286
1286
  }
1287
1287
  }
1288
- const ft = te({
1288
+ const fe = et({
1289
1289
  contact: f({
1290
1290
  userId: {
1291
1291
  type: x(),
@@ -1305,24 +1305,24 @@ const ft = te({
1305
1305
  }
1306
1306
  }),
1307
1307
  authDate: {
1308
- type: me(),
1308
+ type: mt(),
1309
1309
  from: "auth_date"
1310
1310
  },
1311
1311
  hash: h()
1312
1312
  });
1313
- function Ee(r, e) {
1314
- return (t) => {
1315
- const [s, n] = e[t];
1313
+ function Et(r, t) {
1314
+ return (e) => {
1315
+ const [s, n] = t[e];
1316
1316
  return A(s, n, r);
1317
1317
  };
1318
1318
  }
1319
- function gt(r) {
1320
- return new Promise((e) => {
1321
- setTimeout(e, r);
1319
+ function ge(r) {
1320
+ return new Promise((t) => {
1321
+ setTimeout(t, r);
1322
1322
  });
1323
1323
  }
1324
- class wt {
1325
- constructor(e) {
1324
+ class we {
1325
+ constructor(t) {
1326
1326
  o(this, "ee", new w());
1327
1327
  o(this, "state");
1328
1328
  o(this, "botInline");
@@ -1347,20 +1347,20 @@ class wt {
1347
1347
  */
1348
1348
  o(this, "supportsParam");
1349
1349
  const {
1350
- postEvent: t = d,
1350
+ postEvent: e = d,
1351
1351
  headerColor: s,
1352
1352
  backgroundColor: n,
1353
1353
  version: i,
1354
1354
  botInline: a,
1355
1355
  createRequestId: c
1356
- } = e, u = C(i, {
1356
+ } = t, u = C(i, {
1357
1357
  requestPhoneAccess: "web_app_request_phone",
1358
1358
  requestWriteAccess: "web_app_request_write_access",
1359
1359
  switchInlineQuery: "web_app_switch_inline_query",
1360
1360
  setHeaderColor: "web_app_set_header_color",
1361
1361
  setBackgroundColor: "web_app_set_background_color"
1362
1362
  });
1363
- this.postEvent = t, this.botInline = a, this.createRequestId = c, this.supports = (p) => !(!u(p) || p === "switchInlineQuery" && !a), this.state = new m({ backgroundColor: n, headerColor: s }, this.ee), this.supportsParam = Ee(i, {
1363
+ this.postEvent = e, this.botInline = a, this.createRequestId = c, this.supports = (p) => !(!u(p) || p === "switchInlineQuery" && !a), this.state = new m({ backgroundColor: n, headerColor: s }, this.ee), this.supportsParam = Et(i, {
1364
1364
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1365
1365
  });
1366
1366
  }
@@ -1368,7 +1368,7 @@ class wt {
1368
1368
  * Attempts to get requested contact.
1369
1369
  */
1370
1370
  async getRequestedContact() {
1371
- return O(
1371
+ return D(
1372
1372
  "getRequestedContact",
1373
1373
  {},
1374
1374
  this.createRequestId(),
@@ -1376,7 +1376,7 @@ class wt {
1376
1376
  postEvent: this.postEvent,
1377
1377
  timeout: 1e4
1378
1378
  }
1379
- ).then((e) => ft.parse(e));
1379
+ ).then((t) => fe.parse(t));
1380
1380
  }
1381
1381
  /**
1382
1382
  * The Mini App background color.
@@ -1406,7 +1406,7 @@ class wt {
1406
1406
  * True if current Mini App background color recognized as dark.
1407
1407
  */
1408
1408
  get isDark() {
1409
- return be(this.backgroundColor);
1409
+ return bt(this.backgroundColor);
1410
1410
  }
1411
1411
  /**
1412
1412
  * True if phone access is currently being requested.
@@ -1438,25 +1438,25 @@ class wt {
1438
1438
  * failed.
1439
1439
  * @param options - additional options.
1440
1440
  */
1441
- async requestContact({ timeout: e = 5e3 } = {}) {
1441
+ async requestContact({ timeout: t = 5e3 } = {}) {
1442
1442
  try {
1443
1443
  return await this.getRequestedContact();
1444
1444
  } catch {
1445
1445
  }
1446
1446
  if (await this.requestPhoneAccess() !== "sent")
1447
1447
  throw new Error("Access denied.");
1448
- const s = Date.now() + e;
1448
+ const s = Date.now() + t;
1449
1449
  let n = 50;
1450
- return we(async () => {
1450
+ return wt(async () => {
1451
1451
  for (; Date.now() < s; ) {
1452
1452
  try {
1453
1453
  return await this.getRequestedContact();
1454
1454
  } catch {
1455
1455
  }
1456
- await gt(n), n += 50;
1456
+ await ge(n), n += 50;
1457
1457
  }
1458
1458
  throw new Error("Unable to retrieve requested contact.");
1459
- }, e);
1459
+ }, t);
1460
1460
  }
1461
1461
  /**
1462
1462
  * Requests current user phone access. Method returns promise, which resolves
@@ -1467,13 +1467,13 @@ class wt {
1467
1467
  * @param options - additional options.
1468
1468
  * @see requestContact
1469
1469
  */
1470
- requestPhoneAccess(e = {}) {
1470
+ requestPhoneAccess(t = {}) {
1471
1471
  if (this.requestingPhoneAccess)
1472
1472
  throw new Error("Phone access is already being requested.");
1473
1473
  return this.requestingPhoneAccess = !0, y("web_app_request_phone", "phone_requested", {
1474
- ...e,
1474
+ ...t,
1475
1475
  postEvent: this.postEvent
1476
- }).then((t) => t.status).finally(() => {
1476
+ }).then((e) => e.status).finally(() => {
1477
1477
  this.requestingPhoneAccess = !1;
1478
1478
  });
1479
1479
  }
@@ -1481,13 +1481,13 @@ class wt {
1481
1481
  * Requests write message access to current user.
1482
1482
  * @param options - additional options.
1483
1483
  */
1484
- requestWriteAccess(e = {}) {
1484
+ requestWriteAccess(t = {}) {
1485
1485
  if (this.requestingWriteAccess)
1486
1486
  throw new Error("Write access is already being requested.");
1487
1487
  return this.requestingWriteAccess = !0, y("web_app_request_write_access", "write_access_requested", {
1488
- ...e,
1488
+ ...t,
1489
1489
  postEvent: this.postEvent
1490
- }).then((t) => t.status).finally(() => {
1490
+ }).then((e) => e.status).finally(() => {
1491
1491
  this.requestingWriteAccess = !1;
1492
1492
  });
1493
1493
  }
@@ -1500,25 +1500,25 @@ class wt {
1500
1500
  * @param data - data to send to bot.
1501
1501
  * @throws {Error} data has incorrect size.
1502
1502
  */
1503
- sendData(e) {
1504
- const { size: t } = new Blob([e]);
1505
- if (t === 0 || t > 4096)
1506
- throw new Error(`Passed data has incorrect size: ${t}`);
1507
- this.postEvent("web_app_data_send", { data: e });
1503
+ sendData(t) {
1504
+ const { size: e } = new Blob([t]);
1505
+ if (e === 0 || e > 4096)
1506
+ throw new Error(`Passed data has incorrect size: ${e}`);
1507
+ this.postEvent("web_app_data_send", { data: t });
1508
1508
  }
1509
1509
  /**
1510
1510
  * Updates current Mini App header color.
1511
1511
  * @param color - color key or RGB color.
1512
1512
  */
1513
- setHeaderColor(e) {
1514
- this.postEvent("web_app_set_header_color", ee(e) ? { color: e } : { color_key: e }), this.state.set("headerColor", e);
1513
+ setHeaderColor(t) {
1514
+ this.postEvent("web_app_set_header_color", tt(t) ? { color: t } : { color_key: t }), this.state.set("headerColor", t);
1515
1515
  }
1516
1516
  /**
1517
1517
  * Updates current Mini App background color.
1518
1518
  * @param color - RGB color.
1519
1519
  */
1520
- setBackgroundColor(e) {
1521
- this.postEvent("web_app_set_background_color", { color: e }), this.state.set("backgroundColor", e);
1520
+ setBackgroundColor(t) {
1521
+ this.postEvent("web_app_set_background_color", { color: t }), this.state.set("backgroundColor", t);
1522
1522
  }
1523
1523
  /**
1524
1524
  * Inserts the bot's username and the specified inline query in the current chat's input field.
@@ -1530,22 +1530,22 @@ class wt {
1530
1530
  * @param chatTypes - List of chat types which could be chosen to send the message. Could be
1531
1531
  * empty list.
1532
1532
  */
1533
- switchInlineQuery(e, t = []) {
1533
+ switchInlineQuery(t, e = []) {
1534
1534
  if (!this.supports("switchInlineQuery") && !this.isBotInline)
1535
1535
  throw new Error("Method is unsupported because Mini App should be launched in inline mode.");
1536
1536
  this.postEvent("web_app_switch_inline_query", {
1537
- query: e,
1538
- chat_types: t
1537
+ query: t,
1538
+ chat_types: e
1539
1539
  });
1540
1540
  }
1541
1541
  }
1542
- function _t(r) {
1543
- const e = r.message.trim(), t = (r.title || "").trim(), s = r.buttons || [];
1542
+ function _e(r) {
1543
+ const t = r.message.trim(), e = (r.title || "").trim(), s = r.buttons || [];
1544
1544
  let n;
1545
- if (t.length > 64)
1546
- throw new Error(`Title has incorrect size: ${t.length}`);
1547
- if (e.length === 0 || e.length > 256)
1548
- throw new Error(`Message has incorrect size: ${e.length}`);
1545
+ if (e.length > 64)
1546
+ throw new Error(`Title has incorrect size: ${e.length}`);
1547
+ if (t.length === 0 || t.length > 256)
1548
+ throw new Error(`Message has incorrect size: ${t.length}`);
1549
1549
  if (s.length > 3)
1550
1550
  throw new Error(`Buttons have incorrect size: ${s.length}`);
1551
1551
  return s.length === 0 ? n = [{ type: "close", id: "" }] : n = s.map((i) => {
@@ -1561,10 +1561,10 @@ function _t(r) {
1561
1561
  return { ...i, text: c, id: a };
1562
1562
  }
1563
1563
  return { ...i, id: a };
1564
- }), { title: t, message: e, buttons: n };
1564
+ }), { title: e, message: t, buttons: n };
1565
1565
  }
1566
- class bt {
1567
- constructor(e, t = d) {
1566
+ class be {
1567
+ constructor(t, e = d) {
1568
1568
  o(this, "ee", new w());
1569
1569
  o(this, "state");
1570
1570
  /**
@@ -1579,10 +1579,10 @@ class bt {
1579
1579
  * Checks if specified method is supported by current component.
1580
1580
  */
1581
1581
  o(this, "supports");
1582
- this.postEvent = t, this.state = new m({ isOpened: !1 }, this.ee), this.supports = C(e, { open: "web_app_open_popup" });
1582
+ this.postEvent = e, this.state = new m({ isOpened: !1 }, this.ee), this.supports = C(t, { open: "web_app_open_popup" });
1583
1583
  }
1584
- set isOpened(e) {
1585
- this.state.set("isOpened", e);
1584
+ set isOpened(t) {
1585
+ this.state.set("isOpened", t);
1586
1586
  }
1587
1587
  /**
1588
1588
  * True if popup is currently opened.
@@ -1603,19 +1603,19 @@ class bt {
1603
1603
  * @param options - popup parameters.
1604
1604
  * @throws {Error} Popup is already opened.
1605
1605
  */
1606
- open(e) {
1606
+ open(t) {
1607
1607
  if (this.isOpened)
1608
1608
  throw new Error("Popup is already opened.");
1609
1609
  return this.isOpened = !0, y("web_app_open_popup", "popup_closed", {
1610
1610
  postEvent: this.postEvent,
1611
- params: _t(e)
1612
- }).then(({ button_id: t = null }) => t).finally(() => {
1611
+ params: _e(t)
1612
+ }).then(({ button_id: e = null }) => e).finally(() => {
1613
1613
  this.isOpened = !1;
1614
1614
  });
1615
1615
  }
1616
1616
  }
1617
- class mt {
1618
- constructor(e, t = d) {
1617
+ class me {
1618
+ constructor(t, e = d) {
1619
1619
  o(this, "ee", new w());
1620
1620
  o(this, "state");
1621
1621
  /**
@@ -1630,7 +1630,7 @@ class mt {
1630
1630
  * Checks if specified method is supported by current component.
1631
1631
  */
1632
1632
  o(this, "supports");
1633
- this.postEvent = t, this.state = new m({ isOpened: !1 }, this.ee), this.supports = C(e, {
1633
+ this.postEvent = e, this.state = new m({ isOpened: !1 }, this.ee), this.supports = C(t, {
1634
1634
  close: "web_app_close_scan_qr_popup",
1635
1635
  open: "web_app_open_scan_qr_popup"
1636
1636
  });
@@ -1641,8 +1641,8 @@ class mt {
1641
1641
  close() {
1642
1642
  this.postEvent("web_app_close_scan_qr_popup"), this.isOpened = !1;
1643
1643
  }
1644
- set isOpened(e) {
1645
- this.state.set("isOpened", e);
1644
+ set isOpened(t) {
1645
+ this.state.set("isOpened", t);
1646
1646
  }
1647
1647
  /**
1648
1648
  * Returns true in case, QR scanner is currently opened.
@@ -1656,27 +1656,27 @@ class mt {
1656
1656
  * case, scanner was closed.
1657
1657
  * @param text - title to display.
1658
1658
  */
1659
- async open(e) {
1659
+ async open(t) {
1660
1660
  if (this.isOpened)
1661
1661
  throw new Error("QR scanner is already opened.");
1662
1662
  this.isOpened = !0;
1663
1663
  try {
1664
- const t = await y(
1664
+ const e = await y(
1665
1665
  "web_app_open_scan_qr_popup",
1666
1666
  ["qr_text_received", "scan_qr_popup_closed"],
1667
1667
  {
1668
1668
  postEvent: this.postEvent,
1669
- params: { text: e }
1669
+ params: { text: t }
1670
1670
  }
1671
1671
  );
1672
- return typeof t == "object" && typeof t.data == "string" ? t.data : null;
1672
+ return typeof e == "object" && typeof e.data == "string" ? e.data : null;
1673
1673
  } finally {
1674
1674
  this.isOpened = !1;
1675
1675
  }
1676
1676
  }
1677
1677
  }
1678
- class yt {
1679
- constructor(e, t, s = d) {
1678
+ class ye {
1679
+ constructor(t, e, s = d) {
1680
1680
  o(this, "ee", new w());
1681
1681
  o(this, "state");
1682
1682
  /**
@@ -1684,24 +1684,24 @@ class yt {
1684
1684
  * @param event - event name.
1685
1685
  * @param listener - event listener.
1686
1686
  */
1687
- o(this, "on", (e, t) => e === "click" ? E("settings_button_pressed", t) : this.ee.on(e, t));
1687
+ o(this, "on", (t, e) => t === "click" ? E("settings_button_pressed", e) : this.ee.on(t, e));
1688
1688
  /**
1689
1689
  * Removes event listener.
1690
1690
  * @param event - event name.
1691
1691
  * @param listener - event listener.
1692
1692
  */
1693
- o(this, "off", (e, t) => e === "click" ? I("settings_button_pressed", t) : this.ee.off(e, t));
1693
+ o(this, "off", (t, e) => t === "click" ? I("settings_button_pressed", e) : this.ee.off(t, e));
1694
1694
  /**
1695
1695
  * Checks if specified method is supported by current component.
1696
1696
  */
1697
1697
  o(this, "supports");
1698
- this.postEvent = s, this.state = new m({ isVisible: e }, this.ee), this.supports = C(t, {
1698
+ this.postEvent = s, this.state = new m({ isVisible: t }, this.ee), this.supports = C(e, {
1699
1699
  show: "web_app_setup_settings_button",
1700
1700
  hide: "web_app_setup_settings_button"
1701
1701
  });
1702
1702
  }
1703
- set isVisible(e) {
1704
- this.state.set("isVisible", e), this.postEvent("web_app_setup_settings_button", { is_visible: e });
1703
+ set isVisible(t) {
1704
+ this.state.set("isVisible", t), this.postEvent("web_app_setup_settings_button", { is_visible: t });
1705
1705
  }
1706
1706
  /**
1707
1707
  * True if SettingsButton is currently visible.
@@ -1722,32 +1722,32 @@ class yt {
1722
1722
  this.isVisible = !0;
1723
1723
  }
1724
1724
  }
1725
- function Et(r) {
1726
- return r.replace(/(^|_)bg/, (e, t) => `${t}background`).replace(/_([a-z])/g, (e, t) => t.toUpperCase());
1725
+ function Ee(r) {
1726
+ return r.replace(/(^|_)bg/, (t, e) => `${e}background`).replace(/_([a-z])/g, (t, e) => e.toUpperCase());
1727
1727
  }
1728
- function Ct(r) {
1729
- return r.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`).replace(/(^|_)background/, (e, t) => `${t}bg`);
1728
+ function Ce(r) {
1729
+ return r.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`).replace(/(^|_)background/, (t, e) => `${e}bg`);
1730
1730
  }
1731
- const Ce = R(
1731
+ const Ct = R(
1732
1732
  (r) => {
1733
- const e = ge().optional();
1734
- return Object.entries(X(r)).reduce((t, [s, n]) => (t[Et(s)] = e.parse(n), t), {});
1733
+ const t = gt().optional();
1734
+ return Object.entries(X(r)).reduce((e, [s, n]) => (e[Ee(s)] = t.parse(n), e), {});
1735
1735
  },
1736
1736
  "ThemeParams"
1737
1737
  );
1738
- function ve(r) {
1739
- return Ce().parse(r);
1738
+ function vt(r) {
1739
+ return Ct().parse(r);
1740
1740
  }
1741
- function tr(r) {
1742
- return y("web_app_request_theme", "theme_changed", r).then(ve);
1741
+ function er(r) {
1742
+ return y("web_app_request_theme", "theme_changed", r).then(vt);
1743
1743
  }
1744
- function vt(r) {
1744
+ function ve(r) {
1745
1745
  return JSON.stringify(
1746
- Object.entries(r).reduce((e, [t, s]) => (s && (e[Ct(t)] = s), e), {})
1746
+ Object.entries(r).reduce((t, [e, s]) => (s && (t[Ce(e)] = s), t), {})
1747
1747
  );
1748
1748
  }
1749
- class Pt {
1750
- constructor(e) {
1749
+ class Pe {
1750
+ constructor(t) {
1751
1751
  o(this, "ee", new w());
1752
1752
  o(this, "state");
1753
1753
  /**
@@ -1758,7 +1758,7 @@ class Pt {
1758
1758
  * Removes event listener.
1759
1759
  */
1760
1760
  o(this, "off", this.ee.off.bind(this.ee));
1761
- this.state = new m(e, this.ee);
1761
+ this.state = new m(t, this.ee);
1762
1762
  }
1763
1763
  /**
1764
1764
  * @since v6.10
@@ -1782,8 +1782,8 @@ class Pt {
1782
1782
  * Retrieves palette color value by its name.
1783
1783
  * @param key - palette key name.
1784
1784
  */
1785
- get(e) {
1786
- return this.state.get(e);
1785
+ get(t) {
1786
+ return this.state.get(t);
1787
1787
  }
1788
1788
  /**
1789
1789
  * Returns the copy of the internal state of the current component instance.
@@ -1805,7 +1805,7 @@ class Pt {
1805
1805
  * value is calculated according to theme background color.
1806
1806
  */
1807
1807
  get isDark() {
1808
- return !this.backgroundColor || be(this.backgroundColor);
1808
+ return !this.backgroundColor || bt(this.backgroundColor);
1809
1809
  }
1810
1810
  get linkColor() {
1811
1811
  return this.get("linkColor");
@@ -1830,8 +1830,8 @@ class Pt {
1830
1830
  * @returns Function to stop listening.
1831
1831
  */
1832
1832
  listen() {
1833
- return E("theme_changed", (e) => {
1834
- this.state.set(ve(e.theme_params));
1833
+ return E("theme_changed", (t) => {
1834
+ this.state.set(vt(t.theme_params));
1835
1835
  });
1836
1836
  }
1837
1837
  /**
@@ -1844,8 +1844,8 @@ class Pt {
1844
1844
  return this.get("textColor");
1845
1845
  }
1846
1846
  }
1847
- class St {
1848
- constructor(e, t, s = d) {
1847
+ class Se {
1848
+ constructor(t, e, s = d) {
1849
1849
  /**
1850
1850
  * Checks if specified method is supported by current component.
1851
1851
  */
@@ -1854,9 +1854,9 @@ class St {
1854
1854
  * Checks if specified method parameter is supported by current component.
1855
1855
  */
1856
1856
  o(this, "supportsParam");
1857
- this.version = e, this.createRequestId = t, this.postEvent = s, this.supports = C(e, {
1857
+ this.version = t, this.createRequestId = e, this.postEvent = s, this.supports = C(t, {
1858
1858
  readTextFromClipboard: "web_app_read_text_from_clipboard"
1859
- }), this.supportsParam = Ee(e, {
1859
+ }), this.supportsParam = Et(t, {
1860
1860
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
1861
1861
  });
1862
1862
  }
@@ -1869,15 +1869,15 @@ class St {
1869
1869
  * @param url - URL to be opened.
1870
1870
  * @param tryInstantView
1871
1871
  */
1872
- openLink(e, t) {
1873
- const s = new URL(e, window.location.href).toString();
1872
+ openLink(t, e) {
1873
+ const s = new URL(t, window.location.href).toString();
1874
1874
  if (!A("web_app_open_link", this.version)) {
1875
1875
  window.open(s, "_blank");
1876
1876
  return;
1877
1877
  }
1878
1878
  this.postEvent("web_app_open_link", {
1879
1879
  url: s,
1880
- ...typeof t == "boolean" ? { try_instant_view: t } : {}
1880
+ ...typeof e == "boolean" ? { try_instant_view: e } : {}
1881
1881
  });
1882
1882
  }
1883
1883
  /**
@@ -1886,16 +1886,16 @@ class St {
1886
1886
  * @param url - URL to be opened.
1887
1887
  * @throws {Error} URL has not allowed hostname.
1888
1888
  */
1889
- openTelegramLink(e) {
1889
+ openTelegramLink(t) {
1890
1890
  const {
1891
- hostname: t,
1891
+ hostname: e,
1892
1892
  pathname: s,
1893
1893
  search: n
1894
- } = new URL(e, window.location.href);
1895
- if (t !== "t.me")
1896
- throw new Error(`URL has not allowed hostname: ${t}. Only "t.me" is allowed`);
1894
+ } = new URL(t, window.location.href);
1895
+ if (e !== "t.me")
1896
+ throw new Error(`URL has not allowed hostname: ${e}. Only "t.me" is allowed`);
1897
1897
  if (!A("web_app_open_tg_link", this.version)) {
1898
- window.location.href = e;
1898
+ window.location.href = t;
1899
1899
  return;
1900
1900
  }
1901
1901
  this.postEvent("web_app_open_tg_link", { path_full: s + n });
@@ -1907,33 +1907,33 @@ class St {
1907
1907
  * - Access to clipboard is not allowed
1908
1908
  */
1909
1909
  async readTextFromClipboard() {
1910
- const e = this.createRequestId(), {
1911
- data: t = null
1910
+ const t = this.createRequestId(), {
1911
+ data: e = null
1912
1912
  } = await y("web_app_read_text_from_clipboard", "clipboard_text_received", {
1913
1913
  postEvent: this.postEvent,
1914
- params: { req_id: e },
1915
- capture: le(e)
1914
+ params: { req_id: t },
1915
+ capture: lt(t)
1916
1916
  });
1917
- return t;
1917
+ return e;
1918
1918
  }
1919
1919
  }
1920
- function kt(r) {
1920
+ function ke(r) {
1921
1921
  return ["macos", "tdesktop", "unigram", "web", "weba"].includes(r);
1922
1922
  }
1923
- async function Pe(r) {
1924
- const e = await y("web_app_request_viewport", "viewport_changed", r);
1923
+ async function Pt(r) {
1924
+ const t = await y("web_app_request_viewport", "viewport_changed", r);
1925
1925
  return {
1926
- height: e.height,
1927
- width: e.width,
1928
- isExpanded: e.is_expanded,
1929
- isStateStable: e.is_state_stable
1926
+ height: t.height,
1927
+ width: t.width,
1928
+ isExpanded: t.is_expanded,
1929
+ isStateStable: t.is_state_stable
1930
1930
  };
1931
1931
  }
1932
1932
  function L(r) {
1933
1933
  return r < 0 ? 0 : r;
1934
1934
  }
1935
- class xt {
1936
- constructor(e) {
1935
+ class xe {
1936
+ constructor(t) {
1937
1937
  o(this, "ee", new w());
1938
1938
  o(this, "state");
1939
1939
  o(this, "postEvent");
@@ -1946,14 +1946,14 @@ class xt {
1946
1946
  */
1947
1947
  o(this, "off", this.ee.off.bind(this.ee));
1948
1948
  const {
1949
- height: t,
1949
+ height: e,
1950
1950
  isExpanded: s,
1951
1951
  width: n,
1952
1952
  stableHeight: i,
1953
1953
  postEvent: a = d
1954
- } = e;
1954
+ } = t;
1955
1955
  this.postEvent = a, this.state = new m({
1956
- height: L(t),
1956
+ height: L(e),
1957
1957
  isExpanded: s,
1958
1958
  stableHeight: L(i),
1959
1959
  width: L(n)
@@ -1964,13 +1964,13 @@ class xt {
1964
1964
  * instance.
1965
1965
  * @param options - options to request fresh data.
1966
1966
  */
1967
- sync(e) {
1968
- return Pe(e).then(({ height: t, isExpanded: s, width: n, isStateStable: i }) => {
1967
+ sync(t) {
1968
+ return Pt(t).then(({ height: e, isExpanded: s, width: n, isStateStable: i }) => {
1969
1969
  this.state.set({
1970
- height: t,
1970
+ height: e,
1971
1971
  width: n,
1972
1972
  isExpanded: s,
1973
- stableHeight: i ? t : this.state.get("stableHeight")
1973
+ stableHeight: i ? e : this.state.get("stableHeight")
1974
1974
  });
1975
1975
  });
1976
1976
  }
@@ -2015,14 +2015,14 @@ class xt {
2015
2015
  * @returns Function to stop listening.
2016
2016
  */
2017
2017
  listen() {
2018
- return E("viewport_changed", (e) => {
2018
+ return E("viewport_changed", (t) => {
2019
2019
  const {
2020
- height: t,
2020
+ height: e,
2021
2021
  width: s,
2022
2022
  is_expanded: n,
2023
2023
  is_state_stable: i
2024
- } = e, a = {
2025
- height: L(t),
2024
+ } = t, a = {
2025
+ height: L(e),
2026
2026
  isExpanded: n,
2027
2027
  width: L(s)
2028
2028
  };
@@ -2061,18 +2061,18 @@ class xt {
2061
2061
  return this.stableHeight === this.height;
2062
2062
  }
2063
2063
  }
2064
- function S(r, e) {
2065
- document.documentElement.style.setProperty(r, e);
2064
+ function S(r, t) {
2065
+ document.documentElement.style.setProperty(r, t);
2066
2066
  }
2067
- function qt(r, e) {
2068
- const t = () => {
2067
+ function qe(r, t) {
2068
+ const e = () => {
2069
2069
  S("--tg-background-color", r.backgroundColor);
2070
2070
  }, s = () => {
2071
2071
  const {
2072
2072
  backgroundColor: n,
2073
2073
  secondaryBackgroundColor: i
2074
- } = e;
2075
- if (ee(r.headerColor)) {
2074
+ } = t;
2075
+ if (tt(r.headerColor)) {
2076
2076
  S("--tg-header-color", r.headerColor);
2077
2077
  return;
2078
2078
  }
@@ -2082,61 +2082,61 @@ function qt(r, e) {
2082
2082
  }
2083
2083
  r.headerColor === "secondary_bg_color" && i && S("--tg-header-color", i);
2084
2084
  };
2085
- e.on("change", s), r.on("change:backgroundColor", t), r.on("change:headerColor", s), t(), s();
2085
+ t.on("change", s), r.on("change:backgroundColor", e), r.on("change:headerColor", s), e(), s();
2086
2086
  }
2087
- function At(r) {
2088
- const e = () => {
2089
- const t = r.getState();
2090
- Object.entries(t).forEach(([s, n]) => {
2087
+ function Ae(r) {
2088
+ const t = () => {
2089
+ const e = r.getState();
2090
+ Object.entries(e).forEach(([s, n]) => {
2091
2091
  if (n) {
2092
2092
  const i = s.replace(/[A-Z]/g, (a) => `-${a.toLowerCase()}`);
2093
2093
  S(`--tg-theme-${i}`, n);
2094
2094
  }
2095
2095
  });
2096
2096
  };
2097
- r.on("change", e), e();
2097
+ r.on("change", t), t();
2098
2098
  }
2099
- function oe(r) {
2100
- const e = () => S("--tg-viewport-height", `${r.height}px`), t = () => S("--tg-viewport-width", `${r.width}px`), s = () => S("--tg-viewport-stable-height", `${r.stableHeight}px`);
2101
- r.on("change:height", e), r.on("change:width", t), r.on("change:stableHeight", s), e(), t(), s();
2099
+ function ot(r) {
2100
+ const t = () => S("--tg-viewport-height", `${r.height}px`), e = () => S("--tg-viewport-width", `${r.width}px`), s = () => S("--tg-viewport-stable-height", `${r.stableHeight}px`);
2101
+ r.on("change:height", t), r.on("change:width", e), r.on("change:stableHeight", s), t(), e(), s();
2102
2102
  }
2103
- function Vt() {
2103
+ function Ve() {
2104
2104
  const r = document.createElement("style");
2105
- r.id = "telegram-custom-styles", document.head.appendChild(r), E("set_custom_style", (e) => {
2106
- r.innerHTML = e;
2105
+ r.id = "telegram-custom-styles", document.head.appendChild(r), E("set_custom_style", (t) => {
2106
+ r.innerHTML = t;
2107
2107
  });
2108
2108
  }
2109
- function Se(r) {
2109
+ function St(r) {
2110
2110
  return `telegram-mini-apps-${r}`;
2111
2111
  }
2112
- function T(r, e) {
2113
- sessionStorage.setItem(Se(r), JSON.stringify(e));
2112
+ function T(r, t) {
2113
+ sessionStorage.setItem(St(r), JSON.stringify(t));
2114
2114
  }
2115
2115
  function $(r) {
2116
- const e = sessionStorage.getItem(Se(r));
2117
- return e ? JSON.parse(e) : null;
2116
+ const t = sessionStorage.getItem(St(r));
2117
+ return t ? JSON.parse(t) : null;
2118
2118
  }
2119
- function Rt(r, e, t) {
2120
- const { isVisible: s = !1 } = r ? $("back-button") || {} : {}, n = new rt(s, e, t);
2119
+ function Re(r, t, e) {
2120
+ const { isVisible: s = !1 } = r ? $("back-button") || {} : {}, n = new re(s, t, e);
2121
2121
  return n.on("change", () => {
2122
2122
  T("back-button", { isVisible: n.isVisible });
2123
2123
  }), n;
2124
2124
  }
2125
- function It(r, e) {
2126
- const { isConfirmationNeeded: t = !1 } = r ? $("closing-behavior") || {} : {}, s = new st(t, e);
2125
+ function Ie(r, t) {
2126
+ const { isConfirmationNeeded: e = !1 } = r ? $("closing-behavior") || {} : {}, s = new se(e, t);
2127
2127
  return s.on("change", () => T("closing-behavior", {
2128
2128
  isConfirmationNeeded: s.isConfirmationNeeded
2129
2129
  })), s;
2130
2130
  }
2131
- function Tt(r, e, t, s) {
2131
+ function Te(r, t, e, s) {
2132
2132
  const {
2133
- backgroundColor: n = e,
2133
+ backgroundColor: n = t,
2134
2134
  isEnabled: i = !1,
2135
2135
  isVisible: a = !1,
2136
2136
  isLoaderVisible: c = !1,
2137
- textColor: u = t,
2137
+ textColor: u = e,
2138
2138
  text: p = ""
2139
- } = r ? $("main-button") || {} : {}, g = new dt({
2139
+ } = r ? $("main-button") || {} : {}, g = new de({
2140
2140
  backgroundColor: n,
2141
2141
  isEnabled: i,
2142
2142
  isLoaderVisible: c,
@@ -2154,14 +2154,14 @@ function Tt(r, e, t, s) {
2154
2154
  });
2155
2155
  return g.on("change", _), g;
2156
2156
  }
2157
- function $t(r, e, t, s, n, i) {
2157
+ function $e(r, t, e, s, n, i) {
2158
2158
  const {
2159
- backgroundColor: a = e,
2159
+ backgroundColor: a = t,
2160
2160
  headerColor: c = "bg_color"
2161
- } = r ? $("mini-app") || {} : {}, u = new wt({
2161
+ } = r ? $("mini-app") || {} : {}, u = new we({
2162
2162
  headerColor: c,
2163
2163
  backgroundColor: a,
2164
- version: t,
2164
+ version: e,
2165
2165
  botInline: s,
2166
2166
  createRequestId: n,
2167
2167
  postEvent: i
@@ -2171,44 +2171,44 @@ function $t(r, e, t, s, n, i) {
2171
2171
  });
2172
2172
  return u.on("change", p), u;
2173
2173
  }
2174
- function Lt() {
2174
+ function Le() {
2175
2175
  let r = 0;
2176
2176
  return () => (r += 1, r.toString());
2177
2177
  }
2178
- function Bt(r, e, t) {
2179
- const { isVisible: s = !1 } = r ? $("settings-button") || {} : {}, n = new yt(s, e, t);
2178
+ function Be(r, t, e) {
2179
+ const { isVisible: s = !1 } = r ? $("settings-button") || {} : {}, n = new ye(s, t, e);
2180
2180
  return n.on("change", () => {
2181
2181
  T("settings-button", { isVisible: n.isVisible });
2182
2182
  }), n;
2183
2183
  }
2184
- function Ot(r) {
2185
- const e = new Pt(r);
2186
- return e.listen(), e;
2184
+ function De(r) {
2185
+ const t = new Pe(r);
2186
+ return t.listen(), t;
2187
2187
  }
2188
2188
  function M(r) {
2189
- const e = new xt(r);
2190
- return e.on("change", () => T("viewport", {
2191
- height: e.height,
2192
- isExpanded: e.isExpanded,
2193
- stableHeight: e.stableHeight,
2194
- width: e.width
2195
- })), e.listen(), e;
2196
- }
2197
- function Dt(r, e, t, s) {
2189
+ const t = new xe(r);
2190
+ return t.on("change", () => T("viewport", {
2191
+ height: t.height,
2192
+ isExpanded: t.isExpanded,
2193
+ stableHeight: t.stableHeight,
2194
+ width: t.width
2195
+ })), t.listen(), t;
2196
+ }
2197
+ function Oe(r, t, e, s) {
2198
2198
  const n = r ? $("viewport") : null;
2199
2199
  if (n)
2200
- return M({ ...n, postEvent: t });
2201
- if (kt(e))
2200
+ return M({ ...n, postEvent: e });
2201
+ if (ke(t))
2202
2202
  return M({
2203
2203
  height: window.innerHeight,
2204
2204
  isExpanded: !0,
2205
- postEvent: t,
2205
+ postEvent: e,
2206
2206
  stableHeight: window.innerHeight,
2207
2207
  width: window.innerWidth
2208
2208
  });
2209
2209
  if (s)
2210
- return Pe({
2211
- postEvent: t,
2210
+ return Pt({
2211
+ postEvent: e,
2212
2212
  timeout: 5e3
2213
2213
  }).then(({ height: a, isStateStable: c, ...u }) => M({
2214
2214
  ...u,
@@ -2219,32 +2219,32 @@ function Dt(r, e, t, s) {
2219
2219
  width: 0,
2220
2220
  height: 0,
2221
2221
  isExpanded: !1,
2222
- postEvent: t,
2222
+ postEvent: e,
2223
2223
  stableHeight: 0
2224
2224
  });
2225
- return i.sync({ postEvent: t, timeout: 5e3 }).catch((a) => {
2225
+ return i.sync({ postEvent: e, timeout: 5e3 }).catch((a) => {
2226
2226
  console.error("Unable to actualize viewport state", a);
2227
2227
  }), i;
2228
2228
  }
2229
- function Wt(r) {
2229
+ function We(r) {
2230
2230
  return typeof r == "object" ? r : r ? {
2231
2231
  themeParams: !0,
2232
2232
  viewport: !0,
2233
2233
  miniApp: !0
2234
2234
  } : {};
2235
2235
  }
2236
- function ae(r, e, t, s) {
2237
- const n = Wt(r);
2238
- n.miniApp && qt(e, t), n.themeParams && At(t), n.viewport && (s instanceof Promise ? s.then(oe) : oe(s));
2236
+ function at(r, t, e, s) {
2237
+ const n = We(r);
2238
+ n.miniApp && qe(t, e), n.themeParams && Ae(e), n.viewport && (s instanceof Promise ? s.then(ot) : ot(s));
2239
2239
  }
2240
- function Ht() {
2241
- return te({
2240
+ function He() {
2241
+ return et({
2242
2242
  botInline: {
2243
2243
  type: P().optional(),
2244
2244
  from: "tgWebAppBotInline"
2245
2245
  },
2246
2246
  initData: {
2247
- type: ye().optional(),
2247
+ type: yt().optional(),
2248
2248
  from: "tgWebAppData"
2249
2249
  },
2250
2250
  initDataRaw: {
@@ -2264,7 +2264,7 @@ function Ht() {
2264
2264
  from: "tgWebAppStartParam"
2265
2265
  },
2266
2266
  themeParams: {
2267
- type: Ce(),
2267
+ type: Ct(),
2268
2268
  from: "tgWebAppThemeParams"
2269
2269
  },
2270
2270
  version: {
@@ -2273,71 +2273,72 @@ function Ht() {
2273
2273
  }
2274
2274
  }, "LaunchParams");
2275
2275
  }
2276
- function ke(r) {
2277
- return Ht().parse(r);
2276
+ function kt(r) {
2277
+ return He().parse(r);
2278
2278
  }
2279
- function xe(r) {
2280
- const e = r.includes("?") ? r.replace("#", "&").slice(r.indexOf("?") + 1) : r.slice(r.indexOf("#") + 1);
2281
- return ke(e);
2279
+ function xt(r) {
2280
+ return kt(
2281
+ r.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
2282
+ );
2282
2283
  }
2283
- function Nt() {
2284
- return xe(window.location.href);
2284
+ function Ne() {
2285
+ return xt(window.location.href);
2285
2286
  }
2286
- function qe() {
2287
+ function qt() {
2287
2288
  return performance.getEntriesByType("navigation")[0];
2288
2289
  }
2289
- function Ut() {
2290
- const r = qe();
2290
+ function Ue() {
2291
+ const r = qt();
2291
2292
  if (!r)
2292
2293
  throw new Error("Unable to get first navigation entry.");
2293
- return xe(r.name);
2294
+ return xt(r.name);
2294
2295
  }
2295
- function Mt(r) {
2296
+ function Me(r) {
2296
2297
  const {
2297
- initDataRaw: e,
2298
- themeParams: t,
2298
+ initDataRaw: t,
2299
+ themeParams: e,
2299
2300
  platform: s,
2300
2301
  version: n,
2301
2302
  showSettings: i,
2302
2303
  startParam: a,
2303
2304
  botInline: c
2304
2305
  } = r, u = new URLSearchParams();
2305
- return e && u.set("tgWebAppData", e), u.set("tgWebAppPlatform", s), u.set("tgWebAppThemeParams", vt(t)), u.set("tgWebAppVersion", n), a && u.set("tgWebAppStartParam", n), typeof i == "boolean" && u.set("tgWebAppShowSettings", i ? "1" : "0"), typeof c == "boolean" && u.set("tgWebAppBotInline", c ? "1" : "0"), u.toString();
2306
+ return t && u.set("tgWebAppData", t), u.set("tgWebAppPlatform", s), u.set("tgWebAppThemeParams", ve(e)), u.set("tgWebAppVersion", n), a && u.set("tgWebAppStartParam", a), typeof i == "boolean" && u.set("tgWebAppShowSettings", i ? "1" : "0"), typeof c == "boolean" && u.set("tgWebAppBotInline", c ? "1" : "0"), u.toString();
2306
2307
  }
2307
- const Ae = "telegram-mini-apps-launch-params";
2308
- function Gt() {
2309
- return ke(sessionStorage.getItem(Ae) || "");
2308
+ const At = "telegram-mini-apps-launch-params";
2309
+ function Ge() {
2310
+ return kt(sessionStorage.getItem(At) || "");
2310
2311
  }
2311
- function jt(r) {
2312
- sessionStorage.setItem(Ae, Mt(r));
2312
+ function je(r) {
2313
+ sessionStorage.setItem(At, Me(r));
2313
2314
  }
2314
- function re() {
2315
+ function rt() {
2315
2316
  const r = [];
2316
- for (const e of [
2317
+ for (const t of [
2317
2318
  // Try to retrieve launch parameters from the current location. This method can return
2318
2319
  // nothing in case, location was changed and then page was reloaded.
2319
- Nt,
2320
+ Ne,
2320
2321
  // Then, try using the lower level API - window.performance.
2321
- Ut,
2322
+ Ue,
2322
2323
  // Finally, try to extract launch parameters from the session storage.
2323
- Gt
2324
+ Ge
2324
2325
  ])
2325
2326
  try {
2326
- const t = e();
2327
- return jt(t), t;
2328
- } catch (t) {
2329
- r.push(t);
2327
+ const e = t();
2328
+ return je(e), e;
2329
+ } catch (e) {
2330
+ r.push(e);
2330
2331
  }
2331
2332
  throw k.error("Unable to extract launch parameters. Received errors:", r), new Error("Unable to retrieve launch parameters from any known source.");
2332
2333
  }
2333
- function Ve() {
2334
+ function Vt() {
2334
2335
  var r;
2335
- return ((r = qe()) == null ? void 0 : r.type) === "reload";
2336
+ return ((r = qt()) == null ? void 0 : r.type) === "reload";
2336
2337
  }
2337
2338
  function rr(r = {}) {
2338
2339
  const {
2339
- async: e = !1,
2340
- complete: t = e,
2340
+ async: t = !1,
2341
+ complete: e = t,
2341
2342
  cssVars: s = !1,
2342
2343
  acceptCustomStyles: n = !1
2343
2344
  } = r;
@@ -2349,24 +2350,24 @@ function rr(r = {}) {
2349
2350
  platform: u,
2350
2351
  themeParams: p,
2351
2352
  botInline: g = !1
2352
- } = re(), _ = Ve(), b = Lt(), l = De(c);
2353
- pe() && (n && Vt(), l("iframe_ready", { reload_supported: !0 }), E("reload_iframe", () => {
2353
+ } = rt(), _ = Vt(), b = Le(), l = Ot(c);
2354
+ pt() && (n && Ve(), l("iframe_ready", { reload_supported: !0 }), E("reload_iframe", () => {
2354
2355
  l("iframe_will_reload"), window.location.reload();
2355
2356
  }));
2356
2357
  const q = {
2357
- backButton: Rt(_, c, l),
2358
- closingBehavior: It(_, l),
2359
- cloudStorage: new at(c, b, l),
2358
+ backButton: Re(_, c, l),
2359
+ closingBehavior: Ie(_, l),
2360
+ cloudStorage: new ae(c, b, l),
2360
2361
  createRequestId: b,
2361
- hapticFeedback: new ct(c, l),
2362
- invoice: new lt(c, l),
2363
- mainButton: Tt(
2362
+ hapticFeedback: new ce(c, l),
2363
+ invoice: new le(c, l),
2364
+ mainButton: Te(
2364
2365
  _,
2365
2366
  p.buttonColor || "#000000",
2366
2367
  p.buttonTextColor || "#ffffff",
2367
2368
  l
2368
2369
  ),
2369
- miniApp: $t(
2370
+ miniApp: $e(
2370
2371
  _,
2371
2372
  p.backgroundColor || "#ffffff",
2372
2373
  c,
@@ -2374,86 +2375,86 @@ function rr(r = {}) {
2374
2375
  b,
2375
2376
  l
2376
2377
  ),
2377
- popup: new bt(c, l),
2378
+ popup: new be(c, l),
2378
2379
  postEvent: l,
2379
- qrScanner: new mt(c, l),
2380
- settingsButton: Bt(_, c, l),
2381
- themeParams: Ot(p),
2382
- utils: new St(c, b, l),
2380
+ qrScanner: new me(c, l),
2381
+ settingsButton: Be(_, c, l),
2382
+ themeParams: De(p),
2383
+ utils: new Se(c, b, l),
2383
2384
  ...i ? {
2384
- initData: new ut(i),
2385
+ initData: new ue(i),
2385
2386
  initDataRaw: a
2386
2387
  } : {}
2387
- }, N = Dt(_, u, l, t);
2388
- return N instanceof Promise || t ? Promise.resolve(N).then((se) => (ae(
2388
+ }, N = Oe(_, u, l, e);
2389
+ return N instanceof Promise || e ? Promise.resolve(N).then((st) => (at(
2389
2390
  s,
2390
2391
  q.miniApp,
2391
2392
  q.themeParams,
2392
- se
2393
- ), { ...q, viewport: se })) : (ae(
2393
+ st
2394
+ ), { ...q, viewport: st })) : (at(
2394
2395
  s,
2395
2396
  q.miniApp,
2396
2397
  q.themeParams,
2397
2398
  N
2398
2399
  ), { ...q, viewport: N });
2399
2400
  } catch (i) {
2400
- if (t)
2401
+ if (e)
2401
2402
  return Promise.reject(i);
2402
2403
  throw i;
2403
2404
  }
2404
2405
  }
2405
2406
  function sr() {
2406
2407
  return {
2407
- launchParams: re(),
2408
- isPageReload: Ve()
2408
+ launchParams: rt(),
2409
+ isPageReload: Vt()
2409
2410
  };
2410
2411
  }
2411
2412
  function nr() {
2412
2413
  try {
2413
- return re(), !0;
2414
+ return rt(), !0;
2414
2415
  } catch {
2415
2416
  return !1;
2416
2417
  }
2417
2418
  }
2418
2419
  function ir(r) {
2419
- const e = r.match(/#(.+)/);
2420
- return e ? e[1] : null;
2420
+ const t = r.match(/#(.+)/);
2421
+ return t ? t[1] : null;
2421
2422
  }
2422
- async function D(r) {
2423
+ async function O(r) {
2423
2424
  return r === 0 ? !0 : Promise.race([
2424
- new Promise((e) => {
2425
- window.addEventListener("popstate", function t() {
2426
- window.removeEventListener("popstate", t), e(!0);
2425
+ new Promise((t) => {
2426
+ window.addEventListener("popstate", function e() {
2427
+ window.removeEventListener("popstate", e), t(!0);
2427
2428
  }), window.history.go(r);
2428
2429
  }),
2429
2430
  // Usually, it takes about 1ms to emit this event, but we use some buffer.
2430
- new Promise((e) => {
2431
- setTimeout(e, 50, !1);
2431
+ new Promise((t) => {
2432
+ setTimeout(t, 50, !1);
2432
2433
  })
2433
2434
  ]);
2434
2435
  }
2435
- async function Ft() {
2436
- if (window.history.length <= 1 || (window.history.pushState(null, ""), await D(1 - window.history.length)))
2436
+ async function Fe() {
2437
+ if (window.history.length <= 1 || (window.history.pushState(null, ""), await O(1 - window.history.length)))
2437
2438
  return;
2438
- let e = await D(-1);
2439
- for (; e; )
2440
- e = await D(-1);
2439
+ let t = await O(-1);
2440
+ for (; t; )
2441
+ t = await O(-1);
2441
2442
  }
2442
- function B(r, e) {
2443
- return r.startsWith(e) ? r : `${e}${r}`;
2443
+ function B(r, t) {
2444
+ return r.startsWith(t) ? r : `${t}${r}`;
2444
2445
  }
2445
- class zt {
2446
- constructor(e, t, {
2446
+ class ze {
2447
+ constructor(t, e, {
2447
2448
  debug: s = !1,
2448
2449
  loggerPrefix: n = "Navigator"
2449
2450
  }) {
2450
2451
  o(this, "logger");
2451
2452
  o(this, "entries");
2452
- if (this.entriesCursor = t, e.length === 0)
2453
+ if (this.entriesCursor = e, t.length === 0)
2453
2454
  throw new Error("Entries list should not be empty.");
2454
- if (t >= e.length)
2455
+ if (e >= t.length)
2455
2456
  throw new Error("Cursor should be less than entries count.");
2456
- this.entries = e.map(({ pathname: i = "", search: a, hash: c }) => {
2457
+ this.entries = t.map(({ pathname: i = "", search: a, hash: c }) => {
2457
2458
  if (!i.startsWith("/") && i.length > 0)
2458
2459
  throw new Error('Pathname should start with "/"');
2459
2460
  return {
@@ -2461,29 +2462,29 @@ class zt {
2461
2462
  search: a ? B(a, "?") : "",
2462
2463
  hash: c ? B(c, "#") : ""
2463
2464
  };
2464
- }), this.logger = new he(`[${n}]`, s);
2465
+ }), this.logger = new ht(`[${n}]`, s);
2465
2466
  }
2466
2467
  /**
2467
2468
  * Converts entry to the navigation entry.
2468
2469
  * @param entry - entry data
2469
2470
  */
2470
- formatEntry(e) {
2471
- let t;
2472
- if (typeof e == "string")
2473
- t = e;
2471
+ formatEntry(t) {
2472
+ let e;
2473
+ if (typeof t == "string")
2474
+ e = t;
2474
2475
  else {
2475
2476
  const {
2476
2477
  pathname: a = "",
2477
2478
  search: c,
2478
2479
  hash: u
2479
- } = e;
2480
- t = a + (c ? B(c, "?") : "") + (u ? B(u, "#") : "");
2480
+ } = t;
2481
+ e = a + (c ? B(c, "?") : "") + (u ? B(u, "#") : "");
2481
2482
  }
2482
2483
  const {
2483
2484
  pathname: s,
2484
2485
  search: n,
2485
2486
  hash: i
2486
- } = new URL(t, `https://localhost${this.path}`);
2487
+ } = new URL(e, `https://localhost${this.path}`);
2487
2488
  return {
2488
2489
  pathname: s,
2489
2490
  search: n,
@@ -2530,23 +2531,23 @@ class zt {
2530
2531
  * Moves entries cursor by specified delta.
2531
2532
  * @param delta - cursor delta.
2532
2533
  */
2533
- go(e) {
2534
- this.logger.log(`called go(${e})`);
2535
- const t = Math.min(
2534
+ go(t) {
2535
+ this.logger.log(`called go(${t})`);
2536
+ const e = Math.min(
2536
2537
  this.entries.length - 1,
2537
- Math.max(this.entriesCursor + e, 0)
2538
+ Math.max(this.entriesCursor + t, 0)
2538
2539
  );
2539
- if (this.entriesCursor === t)
2540
+ if (this.entriesCursor === e)
2540
2541
  return this.performGo({
2541
2542
  updated: !1,
2542
- delta: e
2543
+ delta: t
2543
2544
  });
2544
2545
  const s = this.entry;
2545
- this.entriesCursor = t;
2546
+ this.entriesCursor = e;
2546
2547
  const n = this.entry;
2547
2548
  return this.logger.log("State changed", { before: s, after: n }), this.performGo({
2548
2549
  updated: !0,
2549
- delta: e,
2550
+ delta: t,
2550
2551
  before: s,
2551
2552
  after: n
2552
2553
  });
@@ -2555,7 +2556,7 @@ class zt {
2555
2556
  * Returns copy of navigator entries.
2556
2557
  */
2557
2558
  getEntries() {
2558
- return this.entries.map((e) => ({ ...e }));
2559
+ return this.entries.map((t) => ({ ...t }));
2559
2560
  }
2560
2561
  /**
2561
2562
  * Current hash.
@@ -2586,10 +2587,10 @@ class zt {
2586
2587
  * push("#my-hash"); // "/home" -> "/home#my-hash"
2587
2588
  * push("johny#my-hash"); // "/home/root" -> "/home/johny#my-hash"
2588
2589
  */
2589
- push(e) {
2590
+ push(t) {
2590
2591
  this.entriesCursor !== this.entries.length - 1 && this.entries.splice(this.entriesCursor + 1);
2591
- const t = this.formatEntry(e), s = this.entry;
2592
- this.entriesCursor += 1, this.entries[this.entriesCursor] = t;
2592
+ const e = this.formatEntry(t), s = this.entry;
2593
+ this.entriesCursor += 1, this.entries[this.entriesCursor] = e;
2593
2594
  const n = this.entry;
2594
2595
  return this.logger.log("State changed", { before: s, after: n }), this.performPush({
2595
2596
  before: s,
@@ -2616,15 +2617,15 @@ class zt {
2616
2617
  * @see push
2617
2618
  * @returns True if changes were done.
2618
2619
  */
2619
- replace(e) {
2620
- const t = this.formatEntry(e);
2621
- if (this.search === t.search && this.pathname === t.pathname && this.hash === t.hash)
2620
+ replace(t) {
2621
+ const e = this.formatEntry(t);
2622
+ if (this.search === e.search && this.pathname === e.pathname && this.hash === e.hash)
2622
2623
  return this.performReplace({
2623
2624
  updated: !1,
2624
- entry: t
2625
+ entry: e
2625
2626
  });
2626
2627
  const s = this.entry;
2627
- this.entries[this.entriesCursor] = t;
2628
+ this.entries[this.entriesCursor] = e;
2628
2629
  const n = this.entry;
2629
2630
  return this.logger.log("State changed", { before: s, after: n }), this.performReplace({
2630
2631
  updated: !0,
@@ -2641,10 +2642,10 @@ class zt {
2641
2642
  return this.entry.search;
2642
2643
  }
2643
2644
  }
2644
- const ce = 0, Q = 1, Z = 2;
2645
- class Re extends zt {
2646
- constructor(t, s, n = {}) {
2647
- super(t, s, {
2645
+ const ct = 0, Q = 1, Z = 2;
2646
+ class Rt extends ze {
2647
+ constructor(e, s, n = {}) {
2648
+ super(e, s, {
2648
2649
  ...n,
2649
2650
  loggerPrefix: "HashNavigator"
2650
2651
  });
@@ -2654,16 +2655,16 @@ class Re extends zt {
2654
2655
  * Handles window "popstate" event.
2655
2656
  * @param state - event state.
2656
2657
  */
2657
- o(this, "onPopState", async ({ state: t }) => {
2658
- if (this.logger.log('"popstate" event received. State:', t), t === null)
2658
+ o(this, "onPopState", async ({ state: e }) => {
2659
+ if (this.logger.log('"popstate" event received. State:', e), e === null)
2659
2660
  return this.push(window.location.hash.slice(1));
2660
- if (t === ce) {
2661
+ if (e === ct) {
2661
2662
  this.logger.log("Void reached. Moving history forward"), window.history.forward();
2662
2663
  return;
2663
2664
  }
2664
- if (t === Q)
2665
+ if (e === Q)
2665
2666
  return this.back();
2666
- if (t === Z)
2667
+ if (e === Z)
2667
2668
  return this.forward();
2668
2669
  });
2669
2670
  o(this, "back", () => super.back());
@@ -2680,7 +2681,7 @@ class Re extends zt {
2680
2681
  * Creates navigator from current window location hash.
2681
2682
  * @param options - options passed to constructor.
2682
2683
  */
2683
- static fromLocation(t) {
2684
+ static fromLocation(e) {
2684
2685
  const {
2685
2686
  search: s,
2686
2687
  pathname: n,
@@ -2689,29 +2690,29 @@ class Re extends zt {
2689
2690
  window.location.hash.slice(1),
2690
2691
  window.location.href
2691
2692
  );
2692
- return new Re([{ search: s, pathname: n, hash: i }], 0, t);
2693
+ return new Rt([{ search: s, pathname: n, hash: i }], 0, e);
2693
2694
  }
2694
- async performGo(t) {
2695
- t.updated && (this.attached && await this.syncHistory(), this.emitChanged(t.before, t.after));
2695
+ async performGo(e) {
2696
+ e.updated && (this.attached && await this.syncHistory(), this.emitChanged(e.before, e.after));
2696
2697
  }
2697
- async performPush({ before: t, after: s }) {
2698
- this.attached && await this.syncHistory(), this.emitChanged(t, s);
2698
+ async performPush({ before: e, after: s }) {
2699
+ this.attached && await this.syncHistory(), this.emitChanged(e, s);
2699
2700
  }
2700
- async performReplace(t) {
2701
- t.updated && (this.attached && window.history.replaceState(null, "", `#${this.path}`), this.emitChanged(t.before, t.after));
2701
+ async performReplace(e) {
2702
+ e.updated && (this.attached && window.history.replaceState(null, "", `#${this.path}`), this.emitChanged(e.before, e.after));
2702
2703
  }
2703
2704
  /**
2704
2705
  * Synchronizes current navigator state with browser history.
2705
2706
  */
2706
2707
  async syncHistory() {
2707
2708
  window.removeEventListener("popstate", this.onPopState);
2708
- const t = `#${this.path}`;
2709
- await Ft(), d("web_app_setup_back_button", { is_visible: this.canGoBack }), this.canGoBack && this.canGoForward ? (this.logger.log("Setting up history: [<-, *, ->]"), window.history.replaceState(Q, ""), window.history.pushState(null, "", t), window.history.pushState(Z, ""), await D(-1)) : this.canGoBack ? (this.logger.log("Setting up history: [<-, *]"), window.history.replaceState(Q, ""), window.history.pushState(null, "", t)) : this.canGoForward ? (this.logger.log("Setting up history: [*, ->]"), window.history.replaceState(null, t), window.history.pushState(Z, ""), await D(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ce, ""), window.history.pushState(null, "", t)), window.addEventListener("popstate", this.onPopState);
2709
+ const e = `#${this.path}`;
2710
+ await Fe(), d("web_app_setup_back_button", { is_visible: this.canGoBack }), this.canGoBack && this.canGoForward ? (this.logger.log("Setting up history: [<-, *, ->]"), window.history.replaceState(Q, ""), window.history.pushState(null, "", e), window.history.pushState(Z, ""), await O(-1)) : this.canGoBack ? (this.logger.log("Setting up history: [<-, *]"), window.history.replaceState(Q, ""), window.history.pushState(null, "", e)) : this.canGoForward ? (this.logger.log("Setting up history: [*, ->]"), window.history.replaceState(null, e), window.history.pushState(Z, ""), await O(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ct, ""), window.history.pushState(null, "", e)), window.addEventListener("popstate", this.onPopState);
2710
2711
  }
2711
- emitChanged(t, s) {
2712
+ emitChanged(e, s) {
2712
2713
  this.ee.emit("change", {
2713
2714
  navigator: this,
2714
- from: t,
2715
+ from: e,
2715
2716
  to: s
2716
2717
  });
2717
2718
  }
@@ -2733,80 +2734,80 @@ function or(r) {
2733
2734
  return r instanceof z;
2734
2735
  }
2735
2736
  export {
2736
- rt as BackButton,
2737
- st as ClosingBehavior,
2738
- at as CloudStorage,
2739
- ct as HapticFeedback,
2740
- Re as HashNavigator,
2741
- ut as InitData,
2742
- lt as Invoice,
2743
- dt as MainButton,
2737
+ re as BackButton,
2738
+ se as ClosingBehavior,
2739
+ ae as CloudStorage,
2740
+ ce as HapticFeedback,
2741
+ Rt as HashNavigator,
2742
+ ue as InitData,
2743
+ le as Invoice,
2744
+ de as MainButton,
2744
2745
  K as MethodUnsupportedError,
2745
- wt as MiniApp,
2746
- zt as Navigator,
2746
+ we as MiniApp,
2747
+ ze as Navigator,
2747
2748
  Y as ParameterUnsupportedError,
2748
2749
  j as ParseError,
2749
2750
  G as ParseSchemaFieldError,
2750
- bt as Popup,
2751
- mt as QRScanner,
2752
- yt as SettingsButton,
2753
- Pt as ThemeParams,
2751
+ be as Popup,
2752
+ me as QRScanner,
2753
+ ye as SettingsButton,
2754
+ Pe as ThemeParams,
2754
2755
  z as TimeoutError,
2755
- St as Utils,
2756
- xt as Viewport,
2757
- ot as array,
2758
- qt as bindMiniAppCSSVars,
2759
- At as bindThemeCSSVars,
2760
- oe as bindViewportCSSVars,
2756
+ Se as Utils,
2757
+ xe as Viewport,
2758
+ oe as array,
2759
+ qe as bindMiniAppCSSVars,
2760
+ Ae as bindThemeCSSVars,
2761
+ ot as bindViewportCSSVars,
2761
2762
  P as boolean,
2762
- ht as chatParser,
2763
- _e as classNames,
2764
- Oe as compareVersions,
2765
- De as createPostEvent,
2766
- me as date,
2763
+ he as chatParser,
2764
+ _t as classNames,
2765
+ Dt as compareVersions,
2766
+ Ot as createPostEvent,
2767
+ mt as date,
2767
2768
  ir as getHash,
2768
2769
  rr as init,
2769
- ye as initDataParser,
2770
- O as invokeCustomMethod,
2771
- be as isColorDark,
2772
- pe as isIframe,
2773
- Ve as isPageReload,
2774
- ee as isRGB,
2775
- Qe as isRGBShort,
2770
+ yt as initDataParser,
2771
+ D as invokeCustomMethod,
2772
+ bt as isColorDark,
2773
+ pt as isIframe,
2774
+ Vt as isPageReload,
2775
+ tt as isRGB,
2776
+ Qt as isRGBShort,
2776
2777
  W as isRecord,
2777
- kt as isStableViewportPlatform,
2778
+ ke as isStableViewportPlatform,
2778
2779
  nr as isTMA,
2779
2780
  or as isTimeoutError,
2780
2781
  f as json,
2781
- Ht as launchParamsParser,
2782
- Xt as mergeClassNames,
2782
+ He as launchParamsParser,
2783
+ Xe as mergeClassNames,
2783
2784
  x as number,
2784
2785
  I as off,
2785
2786
  E as on,
2786
- Kt as once,
2787
- er as parseInitData,
2788
- ke as parseLaunchParams,
2789
- We as parseMessage,
2790
- ve as parseThemeParams,
2787
+ Ke as once,
2788
+ tr as parseInitData,
2789
+ kt as parseLaunchParams,
2790
+ Wt as parseMessage,
2791
+ vt as parseThemeParams,
2791
2792
  d as postEvent,
2792
2793
  y as request,
2793
- tr as requestThemeParams,
2794
- Pe as requestViewport,
2794
+ er as requestThemeParams,
2795
+ Pt as requestViewport,
2795
2796
  sr as retrieveLaunchData,
2796
- re as retrieveLaunchParams,
2797
- ge as rgb,
2798
- te as searchParams,
2799
- Mt as serializeLaunchParams,
2800
- vt as serializeThemeParams,
2797
+ rt as retrieveLaunchParams,
2798
+ gt as rgb,
2799
+ et as searchParams,
2800
+ Me as serializeLaunchParams,
2801
+ ve as serializeThemeParams,
2801
2802
  S as setCSSVar,
2802
- Qt as setDebug,
2803
- Zt as setTargetOrigin,
2803
+ Qe as setDebug,
2804
+ Ze as setTargetOrigin,
2804
2805
  h as string,
2805
- Yt as subscribe,
2806
+ Ye as subscribe,
2806
2807
  A as supports,
2807
- Ce as themeParamsParser,
2808
- fe as toRGB,
2809
- tt as unsubscribe,
2810
- ie as userParser,
2811
- we as withTimeout
2808
+ Ct as themeParamsParser,
2809
+ ft as toRGB,
2810
+ ee as unsubscribe,
2811
+ it as userParser,
2812
+ wt as withTimeout
2812
2813
  };