@tma.js/sdk 2.2.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
- var Vt = Object.defineProperty;
2
- var $t = (e, t, s) => t in e ? Vt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var c = (e, t, s) => ($t(e, typeof t != "symbol" ? t + "" : t, s), s);
4
- function it(e, t) {
1
+ var Ot = Object.defineProperty;
2
+ var Ut = (e, t, s) => t in e ? Ot(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var c = (e, t, s) => (Ut(e, typeof t != "symbol" ? t + "" : t, s), s);
4
+ function at(e, t) {
5
5
  let s;
6
6
  const n = () => {
7
7
  s !== void 0 && t && t(s), s = void 0;
8
8
  };
9
9
  return [() => s === void 0 ? s = e(n) : s, n];
10
10
  }
11
- function ot(e) {
11
+ function ct(e) {
12
12
  const t = M(), { count: s } = t;
13
- t.unsubscribe(e), s && !t.count && ne();
13
+ t.unsubscribe(e), s && !t.count && ae();
14
14
  }
15
- function Mt(e) {
16
- return M().subscribe(e), () => ot(e);
15
+ function Ht(e) {
16
+ return M().subscribe(e), () => ct(e);
17
17
  }
18
- class Lt {
18
+ class Gt {
19
19
  constructor(t, s = {}) {
20
20
  this.scope = t, this.options = s;
21
21
  }
@@ -31,12 +31,12 @@ class Lt {
31
31
  second: "2-digit",
32
32
  fractionalSecondDigits: 3,
33
33
  timeZone: "UTC"
34
- }).format(n), { textColor: i, bgColor: a } = this.options, o = "font-weight: bold;padding: 0 5px;border-radius:5px";
34
+ }).format(n), { textColor: i, bgColor: o } = this.options, a = "font-weight: bold;padding: 0 5px;border-radius:5px";
35
35
  console[t](
36
36
  `%c${r}%c / %c${this.scope}`,
37
- `${o};background-color: lightblue;color:black`,
37
+ `${a};background-color: lightblue;color:black`,
38
38
  "",
39
- `${o};${i ? `color:${i};` : ""}${a ? `background-color:${a}` : ""}`,
39
+ `${a};${i ? `color:${i};` : ""}${o ? `background-color:${o}` : ""}`,
40
40
  ...s
41
41
  );
42
42
  }
@@ -55,21 +55,21 @@ class Lt {
55
55
  this.print("log", ...t);
56
56
  }
57
57
  }
58
- const F = new Lt("SDK", {
58
+ const F = new Gt("SDK", {
59
59
  bgColor: "forestgreen",
60
60
  textColor: "white"
61
61
  });
62
- let G = !1;
63
- const et = ({ name: e, payload: t }) => {
62
+ let H = !1;
63
+ const nt = ({ name: e, payload: t }) => {
64
64
  F.log("Event received:", t ? { name: e, payload: t } : { name: e });
65
65
  };
66
66
  function Ye(e) {
67
- G !== e && (G = e, e ? Mt(et) : ot(et));
67
+ H !== e && (H = e, e ? Ht(nt) : ct(nt));
68
68
  }
69
- function Bt(...e) {
70
- G && F.log(...e);
69
+ function jt(...e) {
70
+ H && F.log(...e);
71
71
  }
72
- class R {
72
+ class T {
73
73
  constructor() {
74
74
  c(this, "listeners", /* @__PURE__ */ new Map());
75
75
  c(this, "listenersCount", 0);
@@ -141,10 +141,10 @@ class R {
141
141
  }
142
142
  }
143
143
  }
144
- function j(e, t, s) {
144
+ function G(e, t, s) {
145
145
  return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
146
146
  }
147
- function at(...e) {
147
+ function J(...e) {
148
148
  let t = !1;
149
149
  const s = [...e];
150
150
  return [
@@ -155,19 +155,19 @@ function at(...e) {
155
155
  t
156
156
  ];
157
157
  }
158
- class V extends Error {
158
+ class D extends Error {
159
159
  constructor(t, s, n) {
160
- super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, V.prototype);
160
+ super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, D.prototype);
161
161
  }
162
162
  }
163
163
  function f(e, t, s) {
164
- return new V(e, t, s);
164
+ return new D(e, t, s);
165
165
  }
166
- const Ot = "ERR_METHOD_UNSUPPORTED", Ut = "ERR_METHOD_PARAMETER_UNSUPPORTED", Wt = "ERR_UNKNOWN_ENV", Ht = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", Gt = "ERR_TIMED_OUT", jt = "ERR_UNEXPECTED_TYPE", ct = "ERR_PARSE", zt = "ERR_NAVIGATION_LIST_EMPTY", Ft = "ERR_NAVIGATION_CURSOR_INVALID", Ze = "ERR_NAVIGATION_ITEM_INVALID", Ke = "ERR_SSR_INIT", Jt = "ERR_INVALID_PATH_BASE";
166
+ const zt = "ERR_METHOD_UNSUPPORTED", Ft = "ERR_METHOD_PARAMETER_UNSUPPORTED", Jt = "ERR_UNKNOWN_ENV", Qt = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", Yt = "ERR_TIMED_OUT", Zt = "ERR_UNEXPECTED_TYPE", ht = "ERR_PARSE", Kt = "ERR_NAVIGATION_LIST_EMPTY", Xt = "ERR_NAVIGATION_CURSOR_INVALID", Ze = "ERR_NAVIGATION_ITEM_INVALID", Ke = "ERR_SSR_INIT", te = "ERR_INVALID_PATH_BASE";
167
167
  function E() {
168
- return f(jt, "Value has unexpected type");
168
+ return f(Zt, "Value has unexpected type");
169
169
  }
170
- class $ {
170
+ class V {
171
171
  constructor(t, s, n) {
172
172
  this.parser = t, this.isOptional = s, this.type = n;
173
173
  }
@@ -183,7 +183,7 @@ class $ {
183
183
  return this.parser(t);
184
184
  } catch (s) {
185
185
  throw f(
186
- ct,
186
+ ht,
187
187
  `Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
188
188
  s
189
189
  );
@@ -194,9 +194,9 @@ class $ {
194
194
  }
195
195
  }
196
196
  function P(e, t) {
197
- return () => new $(e, !1, t);
197
+ return () => new V(e, !1, t);
198
198
  }
199
- const w = P((e) => {
199
+ const b = P((e) => {
200
200
  if (typeof e == "boolean")
201
201
  return e;
202
202
  const t = String(e);
@@ -206,38 +206,38 @@ const w = P((e) => {
206
206
  return !1;
207
207
  throw E();
208
208
  }, "boolean");
209
- function ht(e, t) {
209
+ function pt(e, t) {
210
210
  const s = {};
211
211
  for (const n in e) {
212
212
  const r = e[n];
213
213
  if (!r)
214
214
  continue;
215
- let i, a;
215
+ let i, o;
216
216
  if (typeof r == "function" || "parse" in r)
217
- i = n, a = typeof r == "function" ? r : r.parse.bind(r);
217
+ i = n, o = typeof r == "function" ? r : r.parse.bind(r);
218
218
  else {
219
- const { type: o } = r;
220
- i = r.from || n, a = typeof o == "function" ? o : o.parse.bind(o);
219
+ const { type: a } = r;
220
+ i = r.from || n, o = typeof a == "function" ? a : a.parse.bind(a);
221
221
  }
222
222
  try {
223
- const o = a(t(i));
224
- o !== void 0 && (s[n] = o);
225
- } catch (o) {
226
- throw f(ct, `Unable to parse field "${n}"`, o);
223
+ const a = o(t(i));
224
+ a !== void 0 && (s[n] = a);
225
+ } catch (a) {
226
+ throw f(ht, `Unable to parse field "${n}"`, a);
227
227
  }
228
228
  }
229
229
  return s;
230
230
  }
231
- function J(e) {
231
+ function Q(e) {
232
232
  let t = e;
233
233
  if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
234
234
  throw E();
235
235
  return t;
236
236
  }
237
237
  function d(e, t) {
238
- return new $((s) => {
239
- const n = J(s);
240
- return ht(e, (r) => n[r]);
238
+ return new V((s) => {
239
+ const n = Q(s);
240
+ return pt(e, (r) => n[r]);
241
241
  }, !1, t);
242
242
  }
243
243
  const y = P((e) => {
@@ -250,17 +250,17 @@ const y = P((e) => {
250
250
  }
251
251
  throw E();
252
252
  }, "number");
253
- function Q(e) {
253
+ function Y(e) {
254
254
  return /^#[\da-f]{6}$/i.test(e);
255
255
  }
256
- function Qt(e) {
256
+ function ee(e) {
257
257
  return /^#[\da-f]{3}$/i.test(e);
258
258
  }
259
- function pt(e) {
259
+ function ut(e) {
260
260
  const t = e.replace(/\s/g, "").toLowerCase();
261
- if (Q(t))
261
+ if (Y(t))
262
262
  return t;
263
- if (Qt(t)) {
263
+ if (ee(t)) {
264
264
  let n = "#";
265
265
  for (let r = 0; r < 3; r += 1)
266
266
  n += t[1 + r].repeat(2);
@@ -278,26 +278,26 @@ const h = P((e) => {
278
278
  if (typeof e == "string" || typeof e == "number")
279
279
  return e.toString();
280
280
  throw E();
281
- }, "string"), ut = P((e) => pt(h().parse(e)), "rgb");
282
- function Yt(e) {
281
+ }, "string"), lt = P((e) => ut(h().parse(e)), "rgb");
282
+ function dt(e) {
283
283
  return d({
284
284
  eventType: h(),
285
285
  eventData: (t) => t
286
286
  }).parse(e);
287
287
  }
288
- function Zt() {
288
+ function se() {
289
289
  ["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
290
290
  delete window[e];
291
291
  });
292
292
  }
293
- function Kt(e, t) {
293
+ function j(e, t) {
294
294
  window.dispatchEvent(new MessageEvent("message", {
295
295
  data: JSON.stringify({ eventType: e, eventData: t }),
296
296
  // We specify window.parent to imitate the case, the parent iframe sent us this event.
297
297
  source: window.parent
298
298
  }));
299
299
  }
300
- function Xt() {
300
+ function ne() {
301
301
  [
302
302
  ["TelegramGameProxy_receiveEvent"],
303
303
  // Windows Phone.
@@ -309,14 +309,14 @@ function Xt() {
309
309
  let t = window;
310
310
  e.forEach((s, n, r) => {
311
311
  if (n === r.length - 1) {
312
- t[s] = Kt;
312
+ t[s] = j;
313
313
  return;
314
314
  }
315
315
  s in t || (t[s] = {}), t = t[s];
316
316
  });
317
317
  });
318
318
  }
319
- const te = {
319
+ const re = {
320
320
  clipboard_text_received: d({
321
321
  req_id: h(),
322
322
  data: (e) => e === null ? e : h().optional().parse(e)
@@ -338,32 +338,32 @@ const te = {
338
338
  qr_text_received: d({ data: h().optional() }),
339
339
  theme_changed: d({
340
340
  theme_params: (e) => {
341
- const t = ut().optional();
342
- return Object.entries(J(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
341
+ const t = lt().optional();
342
+ return Object.entries(Q(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
343
343
  }
344
344
  }),
345
345
  viewport_changed: d({
346
346
  height: y(),
347
347
  width: (e) => e == null ? window.innerWidth : y().parse(e),
348
- is_state_stable: w(),
349
- is_expanded: w()
348
+ is_state_stable: b(),
349
+ is_expanded: b()
350
350
  }),
351
351
  write_access_requested: d({ status: h() })
352
352
  };
353
- function ee() {
354
- const e = new R(), t = new R();
353
+ function ie() {
354
+ const e = new T(), t = new T();
355
355
  t.subscribe((n) => {
356
356
  e.emit("event", { name: n.event, payload: n.args[0] });
357
- }), Xt();
358
- const [, s] = at(
357
+ }), ne();
358
+ const [, s] = J(
359
359
  // Don't forget to remove created handlers.
360
- Zt,
360
+ se,
361
361
  // Add "resize" event listener to make sure, we always have fresh viewport information.
362
362
  // Desktop version of Telegram is sometimes not sending the viewport_changed
363
363
  // event. For example, when the MainButton is shown. That's why we should
364
364
  // add our own listener to make sure, viewport information is always fresh.
365
365
  // Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/10
366
- j("resize", () => {
366
+ G("resize", () => {
367
367
  t.emit("viewport_changed", {
368
368
  width: window.innerWidth,
369
369
  height: window.innerHeight,
@@ -373,18 +373,18 @@ function ee() {
373
373
  }),
374
374
  // Add listener, which handles events sent from the Telegram web application and also events
375
375
  // generated by the local emitEvent function.
376
- j("message", (n) => {
376
+ G("message", (n) => {
377
377
  if (n.source !== window.parent)
378
378
  return;
379
379
  let r;
380
380
  try {
381
- r = Yt(n.data);
381
+ r = dt(n.data);
382
382
  } catch {
383
383
  return;
384
384
  }
385
- const { eventType: i, eventData: a } = r, o = te[i];
385
+ const { eventType: i, eventData: o } = r, a = re[i];
386
386
  try {
387
- const p = o ? o.parse(a) : a;
387
+ const p = a ? a.parse(o) : o;
388
388
  t.emit(...p ? [i, p] : [i]);
389
389
  } catch (p) {
390
390
  F.error(
@@ -412,39 +412,39 @@ function ee() {
412
412
  }
413
413
  }, s];
414
414
  }
415
- const [se, ne] = it(
415
+ const [oe, ae] = at(
416
416
  (e) => {
417
- const [t, s] = ee(), n = t.off.bind(t);
417
+ const [t, s] = ie(), n = t.off.bind(t);
418
418
  return t.off = (r, i) => {
419
- const { count: a } = t;
420
- n(r, i), a && !t.count && e();
419
+ const { count: o } = t;
420
+ n(r, i), o && !t.count && e();
421
421
  }, [t, s];
422
422
  },
423
423
  ([, e]) => e()
424
424
  );
425
425
  function M() {
426
- return se()[0];
426
+ return oe()[0];
427
427
  }
428
- function L(e, t) {
428
+ function $(e, t) {
429
429
  M().off(e, t);
430
430
  }
431
- function b(e, t, s) {
431
+ function w(e, t, s) {
432
432
  return M().on(e, t, s);
433
433
  }
434
434
  function I(e) {
435
435
  return typeof e == "object" && e !== null && !Array.isArray(e);
436
436
  }
437
- function re(e, t) {
437
+ function ce(e, t) {
438
438
  const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
439
439
  for (let i = 0; i < r; i += 1) {
440
- const a = parseInt(s[i] || "0", 10), o = parseInt(n[i] || "0", 10);
441
- if (a !== o)
442
- return a > o ? 1 : -1;
440
+ const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
441
+ if (o !== a)
442
+ return o > a ? 1 : -1;
443
443
  }
444
444
  return 0;
445
445
  }
446
446
  function g(e, t) {
447
- return re(e, t) <= 0;
447
+ return ce(e, t) <= 0;
448
448
  }
449
449
  function v(e, t, s) {
450
450
  if (typeof s == "string") {
@@ -497,95 +497,91 @@ function v(e, t, s) {
497
497
  ].includes(e);
498
498
  }
499
499
  }
500
- function ie(e) {
500
+ function _t(e) {
501
501
  return "external" in e && I(e.external) && "notify" in e.external && typeof e.external.notify == "function";
502
502
  }
503
- function lt(e) {
503
+ function ft(e) {
504
504
  return "TelegramWebviewProxy" in e && I(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
505
505
  }
506
- function oe() {
506
+ function gt() {
507
507
  try {
508
508
  return window.self !== window.top;
509
509
  } catch {
510
510
  return !0;
511
511
  }
512
512
  }
513
- let dt = "https://web.telegram.org";
513
+ let wt = "https://web.telegram.org";
514
514
  function Xe(e) {
515
- dt = e;
515
+ wt = e;
516
516
  }
517
- function ae() {
518
- return dt;
517
+ function he() {
518
+ return wt;
519
519
  }
520
- function A(e, t, s) {
520
+ function R(e, t, s) {
521
521
  let n = {}, r;
522
522
  t === void 0 && s === void 0 ? n = {} : t !== void 0 && s !== void 0 ? (n = s, r = t) : t !== void 0 && ("targetOrigin" in t ? n = t : r = t);
523
- const { targetOrigin: i = ae() } = n;
524
- if (Bt("Posting event:", r ? { event: e, data: r } : { event: e }), oe()) {
523
+ const { targetOrigin: i = he() } = n;
524
+ if (jt("Posting event:", r ? { event: e, data: r } : { event: e }), gt()) {
525
525
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
526
526
  return;
527
527
  }
528
- if (ie(window)) {
528
+ if (_t(window)) {
529
529
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
530
530
  return;
531
531
  }
532
- if (lt(window)) {
532
+ if (ft(window)) {
533
533
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
534
534
  return;
535
535
  }
536
536
  throw f(
537
- Wt,
537
+ Jt,
538
538
  "Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside of Telegram application environment."
539
539
  );
540
540
  }
541
- function ce(e) {
541
+ function pe(e) {
542
542
  return (t, s) => {
543
543
  if (!v(t, e))
544
- throw f(Ot, `Method "${t}" is unsupported in Mini Apps version ${e}`);
544
+ throw f(zt, `Method "${t}" is unsupported in Mini Apps version ${e}`);
545
545
  if (I(s)) {
546
546
  let n;
547
547
  if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !v(t, n, e))
548
548
  throw f(
549
- Ut,
549
+ Ft,
550
550
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
551
551
  );
552
552
  }
553
- return A(t, s);
553
+ return R(t, s);
554
554
  };
555
555
  }
556
- function _t(e) {
556
+ function bt(e) {
557
557
  return ({ req_id: t }) => t === e;
558
558
  }
559
- function ft(e) {
560
- return f(Gt, `Timeout reached: ${e}ms`);
559
+ function mt(e) {
560
+ return f(Yt, `Timeout reached: ${e}ms`);
561
561
  }
562
- function gt(e, t) {
562
+ function yt(e, t) {
563
563
  return Promise.race([
564
564
  typeof e == "function" ? e() : e,
565
565
  new Promise((s, n) => {
566
566
  setTimeout(() => {
567
- n(ft(t));
567
+ n(mt(t));
568
568
  }, t);
569
569
  })
570
570
  ]);
571
571
  }
572
572
  async function _(e) {
573
573
  let t;
574
- const s = new Promise((u) => {
575
- t = u;
576
- }), {
577
- method: n,
578
- event: r,
579
- capture: i,
580
- postEvent: a = A,
581
- timeout: o
582
- } = e, p = (Array.isArray(r) ? r : [r]).map(
583
- (u) => b(u, (k) => (!i || i(k)) && t(k))
574
+ const s = new Promise((a) => {
575
+ t = a;
576
+ }), { event: n, capture: r, timeout: i } = e, [, o] = J(
577
+ ...(Array.isArray(n) ? n : [n]).map(
578
+ (a) => w(a, (p) => (!r || r(p)) && t(p))
579
+ )
584
580
  );
585
581
  try {
586
- return a(n, e.params), await (o ? gt(s, o) : s);
582
+ return (e.postEvent || R)(e.method, e.params), await (i ? yt(s, i) : s);
587
583
  } finally {
588
- p.forEach((u) => u());
584
+ o();
589
585
  }
590
586
  }
591
587
  async function S(e, t, s, n = {}) {
@@ -601,10 +597,10 @@ async function S(e, t, s, n = {}) {
601
597
  params: t,
602
598
  req_id: s
603
599
  },
604
- capture: _t(s)
600
+ capture: bt(s)
605
601
  });
606
602
  if (i)
607
- throw f(Ht, i);
603
+ throw f(Qt, i);
608
604
  return r;
609
605
  }
610
606
  function z(...e) {
@@ -623,8 +619,8 @@ function ts(...e) {
623
619
  i.length && (t[n] = i);
624
620
  }), t), {});
625
621
  }
626
- function bt(e) {
627
- const t = pt(e);
622
+ function vt(e) {
623
+ const t = ut(e);
628
624
  return Math.sqrt(
629
625
  [0.299, 0.587, 0.114].reduce((s, n, r) => {
630
626
  const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
@@ -632,9 +628,9 @@ function bt(e) {
632
628
  }, 0)
633
629
  ) < 120;
634
630
  }
635
- class he {
631
+ class ue {
636
632
  constructor(t) {
637
- c(this, "ee", new R());
633
+ c(this, "ee", new T());
638
634
  /**
639
635
  * Adds new event listener.
640
636
  */
@@ -652,7 +648,7 @@ class he {
652
648
  return { ...this.state };
653
649
  }
654
650
  set(t, s) {
655
- Object.entries(typeof t == "string" ? { [t]: s } : t).reduce((r, [i, a]) => this.state[i] === a || a === void 0 ? r : (this.state[i] = a, this.ee.emit(`change:${i}`, a), !0), !1) && this.ee.emit("change", this.state);
651
+ Object.entries(typeof t == "string" ? { [t]: s } : t).reduce((r, [i, o]) => this.state[i] === o || o === void 0 ? r : (this.state[i] = o, this.ee.emit(`change:${i}`, o), !0), !1) && this.ee.emit("change", this.state);
656
652
  }
657
653
  /**
658
654
  * Returns value by specified key.
@@ -662,7 +658,7 @@ class he {
662
658
  return this.state[t];
663
659
  }
664
660
  }
665
- class Y {
661
+ class Z {
666
662
  constructor(t) {
667
663
  c(this, "state");
668
664
  /**
@@ -677,23 +673,23 @@ class Y {
677
673
  * Clones the current state.
678
674
  */
679
675
  c(this, "clone");
680
- this.state = new he(t), this.set = this.state.set.bind(this.state), this.get = this.state.get.bind(this.state), this.clone = this.state.clone.bind(this.state);
676
+ this.state = new ue(t), this.set = this.state.set.bind(this.state), this.get = this.state.get.bind(this.state), this.clone = this.state.clone.bind(this.state);
681
677
  }
682
678
  }
683
- function wt(e, t) {
679
+ function Et(e, t) {
684
680
  return (s) => v(t[s], e);
685
681
  }
686
- class Z extends Y {
682
+ class K extends Z {
687
683
  constructor(s, n, r) {
688
684
  super(s);
689
685
  /**
690
686
  * @returns True, if specified method is supported by the current component.
691
687
  */
692
688
  c(this, "supports");
693
- this.supports = wt(n, r);
689
+ this.supports = Et(n, r);
694
690
  }
695
691
  }
696
- class pe extends Z {
692
+ class le extends K {
697
693
  constructor(s, n, r) {
698
694
  super({ isVisible: s }, n, {
699
695
  show: "web_app_setup_back_button",
@@ -704,13 +700,13 @@ class pe extends Z {
704
700
  * @param event - event to listen.
705
701
  * @param listener - listener to add.
706
702
  */
707
- c(this, "on", (s, n) => s === "click" ? b("back_button_pressed", n) : this.state.on(s, n));
703
+ c(this, "on", (s, n) => s === "click" ? w("back_button_pressed", n) : this.state.on(s, n));
708
704
  /**
709
705
  * Removes the event listener.
710
706
  * @param event - event to listen.
711
707
  * @param listener - listener to remove.
712
708
  */
713
- c(this, "off", (s, n) => s === "click" ? L("back_button_pressed", n) : this.state.off(s, n));
709
+ c(this, "off", (s, n) => s === "click" ? $("back_button_pressed", n) : this.state.off(s, n));
714
710
  this.postEvent = r;
715
711
  }
716
712
  set isVisible(s) {
@@ -735,19 +731,19 @@ class pe extends Z {
735
731
  this.isVisible = !0;
736
732
  }
737
733
  }
738
- const mt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
739
- function K(e, t) {
740
- return new $((s) => {
734
+ const Pt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
735
+ function X(e, t) {
736
+ return new V((s) => {
741
737
  if (typeof s != "string" && !(s instanceof URLSearchParams))
742
738
  throw E();
743
739
  const n = typeof s == "string" ? new URLSearchParams(s) : s;
744
- return ht(e, (r) => {
740
+ return pt(e, (r) => {
745
741
  const i = n.get(r);
746
742
  return i === null ? void 0 : i;
747
743
  });
748
744
  }, !1, t);
749
745
  }
750
- const ue = d({
746
+ const de = d({
751
747
  id: y(),
752
748
  type: h(),
753
749
  title: h(),
@@ -756,13 +752,13 @@ const ue = d({
756
752
  from: "photo_url"
757
753
  },
758
754
  username: h().optional()
759
- }, "Chat").optional(), st = d({
755
+ }, "Chat").optional(), rt = d({
760
756
  addedToAttachmentMenu: {
761
- type: w().optional(),
757
+ type: b().optional(),
762
758
  from: "added_to_attachment_menu"
763
759
  },
764
760
  allowsWriteToPm: {
765
- type: w().optional(),
761
+ type: b().optional(),
766
762
  from: "allows_write_to_pm"
767
763
  },
768
764
  firstName: {
@@ -771,11 +767,11 @@ const ue = d({
771
767
  },
772
768
  id: y(),
773
769
  isBot: {
774
- type: w().optional(),
770
+ type: b().optional(),
775
771
  from: "is_bot"
776
772
  },
777
773
  isPremium: {
778
- type: w().optional(),
774
+ type: b().optional(),
779
775
  from: "is_premium"
780
776
  },
781
777
  languageCode: {
@@ -792,17 +788,17 @@ const ue = d({
792
788
  },
793
789
  username: h().optional()
794
790
  }, "User").optional();
795
- function yt() {
796
- return K({
791
+ function xt() {
792
+ return X({
797
793
  authDate: {
798
- type: mt(),
794
+ type: Pt(),
799
795
  from: "auth_date"
800
796
  },
801
797
  canSendAfter: {
802
798
  type: y().optional(),
803
799
  from: "can_send_after"
804
800
  },
805
- chat: ue,
801
+ chat: de,
806
802
  chatInstance: {
807
803
  type: h().optional(),
808
804
  from: "chat_instance"
@@ -816,35 +812,35 @@ function yt() {
816
812
  type: h().optional(),
817
813
  from: "query_id"
818
814
  },
819
- receiver: st,
815
+ receiver: rt,
820
816
  startParam: {
821
817
  type: h().optional(),
822
818
  from: "start_param"
823
819
  },
824
- user: st
820
+ user: rt
825
821
  }, "InitData");
826
822
  }
827
- function le(e) {
823
+ function _e(e) {
828
824
  return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
829
825
  }
830
- function de(e) {
826
+ function fe(e) {
831
827
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
832
828
  }
833
- const vt = P(
829
+ const St = P(
834
830
  (e) => {
835
- const t = ut().optional();
836
- return Object.entries(J(e)).reduce((s, [n, r]) => (s[le(n)] = t.parse(r), s), {});
831
+ const t = lt().optional();
832
+ return Object.entries(Q(e)).reduce((s, [n, r]) => (s[_e(n)] = t.parse(r), s), {});
837
833
  },
838
834
  "ThemeParams"
839
835
  );
840
- function Et(e) {
841
- return K({
836
+ function tt(e) {
837
+ return X({
842
838
  botInline: {
843
- type: w().optional(),
839
+ type: b().optional(),
844
840
  from: "tgWebAppBotInline"
845
841
  },
846
842
  initData: {
847
- type: yt().optional(),
843
+ type: xt().optional(),
848
844
  from: "tgWebAppData"
849
845
  },
850
846
  initDataRaw: {
@@ -856,7 +852,7 @@ function Et(e) {
856
852
  from: "tgWebAppPlatform"
857
853
  },
858
854
  showSettings: {
859
- type: w().optional(),
855
+ type: b().optional(),
860
856
  from: "tgWebAppShowSettings"
861
857
  },
862
858
  startParam: {
@@ -864,7 +860,7 @@ function Et(e) {
864
860
  from: "tgWebAppStartParam"
865
861
  },
866
862
  themeParams: {
867
- type: vt(),
863
+ type: St(),
868
864
  from: "tgWebAppThemeParams"
869
865
  },
870
866
  version: {
@@ -873,110 +869,110 @@ function Et(e) {
873
869
  }
874
870
  }).parse(e);
875
871
  }
876
- function Pt(e) {
877
- return Et(
872
+ function Ct(e) {
873
+ return tt(
878
874
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
879
875
  );
880
876
  }
881
- function _e() {
882
- return Pt(window.location.href);
877
+ function ge() {
878
+ return Ct(window.location.href);
883
879
  }
884
- function xt() {
880
+ function Tt() {
885
881
  return performance.getEntriesByType("navigation")[0];
886
882
  }
887
- function fe() {
888
- const e = xt();
883
+ function we() {
884
+ const e = Tt();
889
885
  if (!e)
890
886
  throw new Error("Unable to get first navigation entry.");
891
- return Pt(e.name);
887
+ return Ct(e.name);
892
888
  }
893
- function St(e) {
889
+ function Rt(e) {
894
890
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
895
891
  }
896
- function Ct(e, t) {
897
- sessionStorage.setItem(St(e), JSON.stringify(t));
892
+ function At(e, t) {
893
+ sessionStorage.setItem(Rt(e), JSON.stringify(t));
898
894
  }
899
- function Rt(e) {
900
- const t = sessionStorage.getItem(St(e));
895
+ function It(e) {
896
+ const t = sessionStorage.getItem(Rt(e));
901
897
  try {
902
898
  return t ? JSON.parse(t) : void 0;
903
899
  } catch {
904
900
  }
905
901
  }
906
- function ge() {
907
- return Et(Rt("launchParams") || "");
902
+ function be() {
903
+ return tt(It("launchParams") || "");
908
904
  }
909
- function be(e) {
905
+ function qt(e) {
910
906
  return JSON.stringify(
911
907
  Object.fromEntries(
912
- Object.entries(e).map(([t, s]) => [de(t), s])
908
+ Object.entries(e).map(([t, s]) => [fe(t), s])
913
909
  )
914
910
  );
915
911
  }
916
- function we(e) {
912
+ function me(e) {
917
913
  const {
918
914
  initDataRaw: t,
919
915
  themeParams: s,
920
916
  platform: n,
921
917
  version: r,
922
918
  showSettings: i,
923
- startParam: a,
924
- botInline: o
919
+ startParam: o,
920
+ botInline: a
925
921
  } = e, p = new URLSearchParams();
926
- return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", be(s)), p.set("tgWebAppVersion", r), t && p.set("tgWebAppData", t), a && p.set("tgWebAppStartParam", a), typeof i == "boolean" && p.set("tgWebAppShowSettings", i ? "1" : "0"), typeof o == "boolean" && p.set("tgWebAppBotInline", o ? "1" : "0"), p.toString();
922
+ return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", qt(s)), p.set("tgWebAppVersion", r), t && p.set("tgWebAppData", t), o && p.set("tgWebAppStartParam", o), typeof i == "boolean" && p.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && p.set("tgWebAppBotInline", a ? "1" : "0"), p.toString();
927
923
  }
928
- function me(e) {
929
- Ct("launchParams", we(e));
924
+ function kt(e) {
925
+ At("launchParams", me(e));
930
926
  }
931
927
  function ye() {
932
928
  for (const e of [
933
929
  // Try to retrieve launch parameters from the current location. This method can return
934
930
  // nothing in case, location was changed and then page was reloaded.
935
- _e,
931
+ ge,
936
932
  // Then, try using the lower level API - window.performance.
937
- fe,
933
+ we,
938
934
  // Finally, try to extract launch parameters from the session storage.
939
- ge
935
+ be
940
936
  ])
941
937
  try {
942
938
  const t = e();
943
- return me(t), t;
939
+ return kt(t), t;
944
940
  } catch {
945
941
  }
946
942
  throw new Error("Unable to retrieve launch parameters from any known source.");
947
943
  }
948
- function At() {
949
- const e = xt();
944
+ function Nt() {
945
+ const e = Tt();
950
946
  return !!(e && e.type === "reload");
951
947
  }
952
948
  function ve() {
953
949
  let e = 0;
954
950
  return () => (e += 1).toString();
955
951
  }
956
- const [Ee] = it(ve);
952
+ const [Ee] = at(ve);
957
953
  function l(e, t) {
958
954
  return () => {
959
955
  const s = ye(), n = {
960
956
  ...s,
961
- postEvent: ce(s.version),
957
+ postEvent: pe(s.version),
962
958
  createRequestId: Ee()
963
959
  };
964
960
  if (typeof e == "function")
965
961
  return e(n);
966
- const [r, i, a] = at(), o = t({
962
+ const [r, i, o] = J(), a = t({
967
963
  ...n,
968
964
  // State should only be passed only in case, current page was reloaded. If we don't add
969
965
  // this check, state restoration will work improperly in the web version of Telegram,
970
966
  // when we are always working in the same "session" (tab).
971
- state: At() ? Rt(e) : void 0,
967
+ state: Nt() ? It(e) : void 0,
972
968
  addCleanup: r
973
- }), p = (u) => (a || r(
974
- u.on("change", (k) => {
975
- Ct(e, k);
969
+ }), p = (u) => (o || r(
970
+ u.on("change", (Wt) => {
971
+ At(e, Wt);
976
972
  })
977
973
  ), u);
978
974
  return [
979
- o instanceof Promise ? o.then(p) : p(o),
975
+ a instanceof Promise ? a.then(p) : p(a),
980
976
  i
981
977
  ];
982
978
  };
@@ -985,8 +981,8 @@ const es = l("backButton", ({
985
981
  postEvent: e,
986
982
  version: t,
987
983
  state: s = { isVisible: !1 }
988
- }) => new pe(s.isVisible, t, e));
989
- class q extends Z {
984
+ }) => new le(s.isVisible, t, e));
985
+ class q extends K {
990
986
  constructor() {
991
987
  super(...arguments);
992
988
  /**
@@ -999,7 +995,7 @@ class q extends Z {
999
995
  c(this, "off", this.state.off.bind(this.state));
1000
996
  }
1001
997
  }
1002
- function Tt(e) {
998
+ function Dt(e) {
1003
999
  const t = e.available ? e : {
1004
1000
  available: !1,
1005
1001
  device_id: "",
@@ -1099,7 +1095,7 @@ class Pe extends q {
1099
1095
  event: "biometry_info_received",
1100
1096
  params: { reason: s || "" }
1101
1097
  }).then((r) => {
1102
- const i = Tt(r);
1098
+ const i = Dt(r);
1103
1099
  return this.set(i), i.accessGranted;
1104
1100
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1105
1101
  }
@@ -1132,7 +1128,7 @@ class Pe extends q {
1132
1128
  }
1133
1129
  }
1134
1130
  async function xe(e) {
1135
- return Tt(
1131
+ return Dt(
1136
1132
  await _({
1137
1133
  ...e || {},
1138
1134
  method: "web_app_biometry_get_info",
@@ -1154,7 +1150,7 @@ const ss = l(
1154
1150
  postEvent: e
1155
1151
  })
1156
1152
  );
1157
- class X extends Y {
1153
+ class et extends Z {
1158
1154
  constructor() {
1159
1155
  super(...arguments);
1160
1156
  /**
@@ -1167,7 +1163,7 @@ class X extends Y {
1167
1163
  c(this, "off", this.state.off.bind(this.state));
1168
1164
  }
1169
1165
  }
1170
- class Se extends X {
1166
+ class Se extends et {
1171
1167
  constructor(t, s) {
1172
1168
  super({ isConfirmationNeeded: t }), this.postEvent = s;
1173
1169
  }
@@ -1201,13 +1197,13 @@ const ns = l(
1201
1197
  state: t = { isConfirmationNeeded: !1 }
1202
1198
  }) => new Se(t.isConfirmationNeeded, e)
1203
1199
  );
1204
- class tt {
1200
+ class st {
1205
1201
  constructor(t, s) {
1206
1202
  /**
1207
1203
  * @returns True, if specified method is supported by the current component.
1208
1204
  */
1209
1205
  c(this, "supports");
1210
- this.supports = wt(t, s);
1206
+ this.supports = Et(t, s);
1211
1207
  }
1212
1208
  }
1213
1209
  function Ce(e) {
@@ -1222,7 +1218,7 @@ function Ce(e) {
1222
1218
  }
1223
1219
  throw E();
1224
1220
  }
1225
- class Re extends $ {
1221
+ class Te extends V {
1226
1222
  constructor(s, n, r) {
1227
1223
  super(Ce, n, r);
1228
1224
  c(this, "itemParser");
@@ -1242,13 +1238,13 @@ class Re extends $ {
1242
1238
  return this.itemParser = typeof s == "function" ? s : s.parse.bind(s), this;
1243
1239
  }
1244
1240
  }
1245
- function Ae(e) {
1246
- return new Re((t) => t, !1, e);
1241
+ function Re(e) {
1242
+ return new Te((t) => t, !1, e);
1247
1243
  }
1248
- function nt(e, t) {
1244
+ function it(e, t) {
1249
1245
  return Object.fromEntries(e.map((s) => [s, t]));
1250
1246
  }
1251
- class Te extends tt {
1247
+ class Ae extends st {
1252
1248
  constructor(t, s, n) {
1253
1249
  super(t, {
1254
1250
  delete: "web_app_invoke_custom_method",
@@ -1276,7 +1272,7 @@ class Te extends tt {
1276
1272
  * @param options - request execution options.
1277
1273
  */
1278
1274
  async getKeys(t = {}) {
1279
- return Ae().of(h()).parse(
1275
+ return Re().of(h()).parse(
1280
1276
  await S(
1281
1277
  "getStorageKeys",
1282
1278
  {},
@@ -1288,13 +1284,13 @@ class Te extends tt {
1288
1284
  async get(t, s = {}) {
1289
1285
  const n = Array.isArray(t) ? t : [t];
1290
1286
  if (!n.length)
1291
- return nt(n, "");
1287
+ return it(n, "");
1292
1288
  const r = await S(
1293
1289
  "getStorageValues",
1294
1290
  { keys: n },
1295
1291
  this.createRequestId(),
1296
1292
  { ...s, postEvent: this.postEvent }
1297
- ), i = d(nt(n, h()), "CloudStorageData").parse(r);
1293
+ ), i = d(it(n, h()), "CloudStorageData").parse(r);
1298
1294
  return Array.isArray(t) ? i : i[t];
1299
1295
  }
1300
1296
  /**
@@ -1313,9 +1309,9 @@ class Te extends tt {
1313
1309
  }
1314
1310
  }
1315
1311
  const rs = l(
1316
- ({ createRequestId: e, postEvent: t, version: s }) => new Te(s, e, t)
1312
+ ({ createRequestId: e, postEvent: t, version: s }) => new Ae(s, e, t)
1317
1313
  );
1318
- class Ie extends tt {
1314
+ class Ie extends st {
1319
1315
  constructor(t, s) {
1320
1316
  super(t, {
1321
1317
  impactOccurred: "web_app_trigger_haptic_feedback",
@@ -1437,7 +1433,7 @@ const os = l(
1437
1433
  ({ initData: e }) => e ? new qe(e) : void 0
1438
1434
  );
1439
1435
  function as(e) {
1440
- return yt().parse(e);
1436
+ return xt().parse(e);
1441
1437
  }
1442
1438
  class ke extends q {
1443
1439
  constructor(t, s, n) {
@@ -1462,10 +1458,10 @@ class ke extends q {
1462
1458
  const { hostname: r, pathname: i } = new URL(t, window.location.href);
1463
1459
  if (r !== "t.me")
1464
1460
  throw new Error(`Incorrect hostname: ${r}`);
1465
- const a = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1466
- if (!a)
1461
+ const o = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1462
+ if (!o)
1467
1463
  throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
1468
- [, , n] = a;
1464
+ [, , n] = o;
1469
1465
  }
1470
1466
  this.isOpened = !0;
1471
1467
  try {
@@ -1486,7 +1482,7 @@ class ke extends q {
1486
1482
  const cs = l(
1487
1483
  ({ version: e, postEvent: t }) => new ke(!1, e, t)
1488
1484
  );
1489
- class Ne extends Y {
1485
+ class Ne extends Z {
1490
1486
  constructor({ postEvent: s, ...n }) {
1491
1487
  super(n);
1492
1488
  c(this, "postEvent");
@@ -1495,13 +1491,13 @@ class Ne extends Y {
1495
1491
  * @param event - event to listen.
1496
1492
  * @param listener - listener to add.
1497
1493
  */
1498
- c(this, "on", (s, n) => s === "click" ? b("main_button_pressed", n) : this.state.on(s, n));
1494
+ c(this, "on", (s, n) => s === "click" ? w("main_button_pressed", n) : this.state.on(s, n));
1499
1495
  /**
1500
1496
  * Removes the event listener.
1501
1497
  * @param event - event to listen.
1502
1498
  * @param listener - listener to remove.
1503
1499
  */
1504
- c(this, "off", (s, n) => s === "click" ? L("main_button_pressed", n) : this.state.off(s, n));
1500
+ c(this, "off", (s, n) => s === "click" ? $("main_button_pressed", n) : this.state.off(s, n));
1505
1501
  this.postEvent = s;
1506
1502
  }
1507
1503
  /**
@@ -1647,7 +1643,7 @@ const hs = l(
1647
1643
  }) => new Ne({ ...s, postEvent: e })
1648
1644
  );
1649
1645
  function De() {
1650
- return K({
1646
+ return X({
1651
1647
  contact: d({
1652
1648
  userId: {
1653
1649
  type: y(),
@@ -1667,13 +1663,13 @@ function De() {
1667
1663
  }
1668
1664
  }),
1669
1665
  authDate: {
1670
- type: mt(),
1666
+ type: Pt(),
1671
1667
  from: "auth_date"
1672
1668
  },
1673
1669
  hash: h()
1674
1670
  }, "RequestedContact");
1675
1671
  }
1676
- function It(e, t) {
1672
+ function Vt(e, t) {
1677
1673
  return (s) => {
1678
1674
  const [n, r] = t[s];
1679
1675
  return v(n, r, e);
@@ -1684,9 +1680,9 @@ function Ve(e) {
1684
1680
  setTimeout(t, e);
1685
1681
  });
1686
1682
  }
1687
- class $e extends q {
1688
- constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...a }) {
1689
- super(a, r, {
1683
+ class Me extends q {
1684
+ constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...o }) {
1685
+ super(o, r, {
1690
1686
  requestPhoneAccess: "web_app_request_phone",
1691
1687
  requestWriteAccess: "web_app_request_write_access",
1692
1688
  switchInlineQuery: "web_app_switch_inline_query",
@@ -1703,8 +1699,8 @@ class $e extends q {
1703
1699
  */
1704
1700
  c(this, "supportsParam");
1705
1701
  this.createRequestId = n, this.postEvent = s, this.botInline = i;
1706
- const o = this.supports.bind(this);
1707
- this.supports = (p) => o(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = It(r, {
1702
+ const a = this.supports.bind(this);
1703
+ this.supports = (p) => a(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = Vt(r, {
1708
1704
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1709
1705
  });
1710
1706
  }
@@ -1755,7 +1751,7 @@ class $e extends q {
1755
1751
  * True if current Mini App background color is recognized as dark.
1756
1752
  */
1757
1753
  get isDark() {
1758
- return bt(this.bgColor);
1754
+ return vt(this.bgColor);
1759
1755
  }
1760
1756
  /**
1761
1757
  * Informs the Telegram app that the Mini App is ready to be displayed.
@@ -1784,7 +1780,7 @@ class $e extends q {
1784
1780
  throw new Error("Access denied.");
1785
1781
  const r = Date.now() + s;
1786
1782
  let i = 50;
1787
- return gt(async () => {
1783
+ return yt(async () => {
1788
1784
  for (; Date.now() < r; ) {
1789
1785
  try {
1790
1786
  return await this.getRequestedContact();
@@ -1792,7 +1788,7 @@ class $e extends q {
1792
1788
  }
1793
1789
  await Ve(i), i += 50;
1794
1790
  }
1795
- throw ft(s);
1791
+ throw mt(s);
1796
1792
  }, s);
1797
1793
  }
1798
1794
  /**
@@ -1847,7 +1843,7 @@ class $e extends q {
1847
1843
  * @param color - color key or RGB color.
1848
1844
  */
1849
1845
  setHeaderColor(s) {
1850
- this.postEvent("web_app_set_header_color", Q(s) ? { color: s } : { color_key: s }), this.set("headerColor", s);
1846
+ this.postEvent("web_app_set_header_color", Y(s) ? { color: s } : { color_key: s }), this.set("headerColor", s);
1851
1847
  }
1852
1848
  /**
1853
1849
  * Updates current Mini App background color.
@@ -1885,9 +1881,9 @@ const ps = l(
1885
1881
  headerColor: e.headerBgColor || "#000000"
1886
1882
  },
1887
1883
  ...n
1888
- }) => new $e({ ...n, ...s, botInline: t })
1884
+ }) => new Me({ ...n, ...s, botInline: t })
1889
1885
  );
1890
- function Me(e) {
1886
+ function $e(e) {
1891
1887
  const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
1892
1888
  let r;
1893
1889
  if (s.length > 64)
@@ -1897,18 +1893,18 @@ function Me(e) {
1897
1893
  if (n.length > 3)
1898
1894
  throw new Error(`Buttons have incorrect size: ${n.length}`);
1899
1895
  return n.length ? r = n.map((i) => {
1900
- const { id: a = "" } = i;
1901
- if (a.length > 64)
1902
- throw new Error(`Button ID has incorrect size: ${a}`);
1896
+ const { id: o = "" } = i;
1897
+ if (o.length > 64)
1898
+ throw new Error(`Button ID has incorrect size: ${o}`);
1903
1899
  if (!i.type || i.type === "default" || i.type === "destructive") {
1904
- const o = i.text.trim();
1905
- if (!o.length || o.length > 64) {
1900
+ const a = i.text.trim();
1901
+ if (!a.length || a.length > 64) {
1906
1902
  const p = i.type || "default";
1907
1903
  throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
1908
1904
  }
1909
- return { ...i, text: o, id: a };
1905
+ return { ...i, text: a, id: o };
1910
1906
  }
1911
- return { ...i, id: a };
1907
+ return { ...i, id: o };
1912
1908
  }) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
1913
1909
  }
1914
1910
  class Le extends q {
@@ -1944,7 +1940,7 @@ class Le extends q {
1944
1940
  event: "popup_closed",
1945
1941
  method: "web_app_open_popup",
1946
1942
  postEvent: this.postEvent,
1947
- params: Me(t)
1943
+ params: $e(t)
1948
1944
  });
1949
1945
  return s;
1950
1946
  } finally {
@@ -1977,32 +1973,31 @@ class Be extends q {
1977
1973
  get isOpened() {
1978
1974
  return this.get("isOpened");
1979
1975
  }
1980
- /**
1981
- * Opens scanner with specified title shown to user. Method returns promise
1982
- * with scanned QR content in case, it was scanned. It will contain null in
1983
- * case, scanner was closed.
1984
- * @param text - title to display.
1985
- */
1986
1976
  async open(t) {
1987
1977
  if (this.isOpened)
1988
1978
  throw new Error("QR scanner is already opened.");
1979
+ const { text: s, capture: n } = (typeof t == "string" ? { text: t } : t) || {};
1989
1980
  this.isOpened = !0;
1990
1981
  try {
1991
- return (await _({
1982
+ const i = (await _({
1992
1983
  method: "web_app_open_scan_qr_popup",
1993
1984
  event: ["qr_text_received", "scan_qr_popup_closed"],
1994
1985
  postEvent: this.postEvent,
1995
- params: { text: t }
1986
+ params: { text: s },
1987
+ capture(o) {
1988
+ return o.event === "scan_qr_popup_closed" || !n || n(o.payload);
1989
+ }
1996
1990
  }) || {}).data || null;
1997
- } finally {
1998
- this.isOpened = !1;
1991
+ return i && this.close(), i;
1992
+ } catch (r) {
1993
+ throw this.isOpened = !1, r;
1999
1994
  }
2000
1995
  }
2001
1996
  }
2002
1997
  const ls = l(
2003
1998
  ({ version: e, postEvent: t }) => new Be(!1, e, t)
2004
1999
  );
2005
- class Oe extends Z {
2000
+ class We extends K {
2006
2001
  constructor(s, n, r) {
2007
2002
  super({ isVisible: s }, n, {
2008
2003
  show: "web_app_setup_settings_button",
@@ -2013,13 +2008,13 @@ class Oe extends Z {
2013
2008
  * @param event - event to listen.
2014
2009
  * @param listener - listener to add.
2015
2010
  */
2016
- c(this, "on", (s, n) => s === "click" ? b("settings_button_pressed", n) : this.state.on(s, n));
2011
+ c(this, "on", (s, n) => s === "click" ? w("settings_button_pressed", n) : this.state.on(s, n));
2017
2012
  /**
2018
2013
  * Removes the event listener.
2019
2014
  * @param event - event to listen.
2020
2015
  * @param listener - listener to remove.
2021
2016
  */
2022
- c(this, "off", (s, n) => s === "click" ? L("settings_button_pressed", n) : this.state.off(s, n));
2017
+ c(this, "off", (s, n) => s === "click" ? $("settings_button_pressed", n) : this.state.off(s, n));
2023
2018
  this.postEvent = r;
2024
2019
  }
2025
2020
  set isVisible(s) {
@@ -2050,12 +2045,12 @@ const ds = l(
2050
2045
  version: e,
2051
2046
  postEvent: t,
2052
2047
  state: s = { isVisible: !1 }
2053
- }) => new Oe(s.isVisible, e, t)
2048
+ }) => new We(s.isVisible, e, t)
2054
2049
  );
2055
- function qt(e) {
2056
- return vt().parse(e);
2050
+ function Mt(e) {
2051
+ return St().parse(e);
2057
2052
  }
2058
- class Ue extends X {
2053
+ class Oe extends et {
2059
2054
  /**
2060
2055
  * @since v6.10
2061
2056
  */
@@ -2094,7 +2089,7 @@ class Ue extends X {
2094
2089
  * value is calculated according to theme bg color.
2095
2090
  */
2096
2091
  get isDark() {
2097
- return !this.bgColor || bt(this.bgColor);
2092
+ return !this.bgColor || vt(this.bgColor);
2098
2093
  }
2099
2094
  get linkColor() {
2100
2095
  return this.get("linkColor");
@@ -2119,8 +2114,8 @@ class Ue extends X {
2119
2114
  * @returns Function to stop listening.
2120
2115
  */
2121
2116
  listen() {
2122
- return b("theme_changed", (t) => {
2123
- this.set(qt(t.theme_params));
2117
+ return w("theme_changed", (t) => {
2118
+ this.set(Mt(t.theme_params));
2124
2119
  });
2125
2120
  }
2126
2121
  /**
@@ -2136,7 +2131,7 @@ class Ue extends X {
2136
2131
  const _s = l(
2137
2132
  "themeParams",
2138
2133
  ({ themeParams: e, state: t = e, addCleanup: s }) => {
2139
- const n = new Ue(t);
2134
+ const n = new Oe(t);
2140
2135
  return s(n.listen()), n;
2141
2136
  }
2142
2137
  );
@@ -2145,16 +2140,16 @@ function fs(e = {}) {
2145
2140
  ...e,
2146
2141
  method: "web_app_request_theme",
2147
2142
  event: "theme_changed"
2148
- }).then(qt);
2143
+ }).then(Mt);
2149
2144
  }
2150
- class We extends tt {
2145
+ class Ue extends st {
2151
2146
  constructor(s, n, r) {
2152
2147
  super(s, { readTextFromClipboard: "web_app_read_text_from_clipboard" });
2153
2148
  /**
2154
2149
  * Checks if specified method parameter is supported by current component.
2155
2150
  */
2156
2151
  c(this, "supportsParam");
2157
- this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = It(s, {
2152
+ this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = Vt(s, {
2158
2153
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2159
2154
  });
2160
2155
  }
@@ -2208,15 +2203,15 @@ class We extends tt {
2208
2203
  event: "clipboard_text_received",
2209
2204
  postEvent: this.postEvent,
2210
2205
  params: { req_id: s },
2211
- capture: _t(s)
2206
+ capture: bt(s)
2212
2207
  });
2213
2208
  return n;
2214
2209
  }
2215
2210
  }
2216
2211
  const gs = l(
2217
- ({ version: e, postEvent: t, createRequestId: s }) => new We(e, s, t)
2212
+ ({ version: e, postEvent: t, createRequestId: s }) => new Ue(e, s, t)
2218
2213
  );
2219
- async function kt(e = {}) {
2214
+ async function $t(e = {}) {
2220
2215
  const {
2221
2216
  is_expanded: t,
2222
2217
  is_state_stable: s,
@@ -2231,11 +2226,11 @@ async function kt(e = {}) {
2231
2226
  function x(e) {
2232
2227
  return e < 0 ? 0 : e;
2233
2228
  }
2234
- class He extends X {
2235
- constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: a }) {
2229
+ class He extends et {
2230
+ constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: o }) {
2236
2231
  super({
2237
2232
  height: x(r),
2238
- isExpanded: a,
2233
+ isExpanded: o,
2239
2234
  stableHeight: x(n),
2240
2235
  width: x(i)
2241
2236
  });
@@ -2248,7 +2243,7 @@ class He extends X {
2248
2243
  * @param options - options to request fresh data.
2249
2244
  */
2250
2245
  async sync(s) {
2251
- const { isStateStable: n, ...r } = await kt(s);
2246
+ const { isStateStable: n, ...r } = await $t(s);
2252
2247
  this.set({
2253
2248
  ...r,
2254
2249
  stableHeight: n ? r.height : this.get("stableHeight")
@@ -2295,18 +2290,18 @@ class He extends X {
2295
2290
  * @returns Function to stop listening.
2296
2291
  */
2297
2292
  listen() {
2298
- return b("viewport_changed", (s) => {
2293
+ return w("viewport_changed", (s) => {
2299
2294
  const {
2300
2295
  height: n,
2301
2296
  width: r,
2302
2297
  is_expanded: i,
2303
- is_state_stable: a
2304
- } = s, o = x(n);
2298
+ is_state_stable: o
2299
+ } = s, a = x(n);
2305
2300
  this.set({
2306
- height: o,
2301
+ height: a,
2307
2302
  isExpanded: i,
2308
2303
  width: x(r),
2309
- ...a ? { stableHeight: o } : {}
2304
+ ...o ? { stableHeight: a } : {}
2310
2305
  });
2311
2306
  });
2312
2307
  }
@@ -2340,23 +2335,23 @@ class He extends X {
2340
2335
  return this.stableHeight === this.height;
2341
2336
  }
2342
2337
  }
2343
- const bs = l(
2338
+ const ws = l(
2344
2339
  "viewport",
2345
2340
  async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
2346
- let r = !1, i = 0, a = 0, o = 0;
2341
+ let r = !1, i = 0, o = 0, a = 0;
2347
2342
  if (e)
2348
- r = e.isExpanded, i = e.height, a = e.width, o = e.stableHeight;
2343
+ r = e.isExpanded, i = e.height, o = e.width, a = e.stableHeight;
2349
2344
  else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2350
- r = !0, i = window.innerHeight, a = window.innerWidth, o = window.innerHeight;
2345
+ r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
2351
2346
  else {
2352
- const u = await kt({ timeout: 1e3, postEvent: s });
2353
- r = u.isExpanded, i = u.height, a = u.width, o = u.isStateStable ? i : 0;
2347
+ const u = await $t({ timeout: 1e3, postEvent: s });
2348
+ r = u.isExpanded, i = u.height, o = u.width, a = u.isStateStable ? i : 0;
2354
2349
  }
2355
2350
  const p = new He({
2356
2351
  postEvent: s,
2357
2352
  height: i,
2358
- width: a,
2359
- stableHeight: o,
2353
+ width: o,
2354
+ stableHeight: a,
2360
2355
  isExpanded: r
2361
2356
  });
2362
2357
  return n(p.listen()), p;
@@ -2365,22 +2360,22 @@ const bs = l(
2365
2360
  function m(e, t) {
2366
2361
  document.documentElement.style.setProperty(e, t);
2367
2362
  }
2368
- function ws(e, t, s) {
2369
- s || (s = (o) => `--tg-${o}-color`);
2363
+ function bs(e, t, s) {
2364
+ s || (s = (a) => `--tg-${a}-color`);
2370
2365
  const n = s("header"), r = s("bg"), i = () => {
2371
- const { headerColor: o } = e;
2372
- if (Q(o))
2373
- m(n, o);
2366
+ const { headerColor: a } = e;
2367
+ if (Y(a))
2368
+ m(n, a);
2374
2369
  else {
2375
2370
  const { bgColor: p, secondaryBgColor: u } = t;
2376
- o === "bg_color" && p ? m(n, p) : o === "secondary_bg_color" && u && m(n, u);
2371
+ a === "bg_color" && p ? m(n, p) : a === "secondary_bg_color" && u && m(n, u);
2377
2372
  }
2378
2373
  m(r, e.bgColor);
2379
- }, a = [
2374
+ }, o = [
2380
2375
  t.on("change", i),
2381
2376
  e.on("change", i)
2382
2377
  ];
2383
- return i(), () => a.forEach((o) => o());
2378
+ return i(), () => o.forEach((a) => a());
2384
2379
  }
2385
2380
  function ms(e, t) {
2386
2381
  t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
@@ -2397,35 +2392,35 @@ function ys(e, t) {
2397
2392
  s,
2398
2393
  n,
2399
2394
  r
2400
- ] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => m(s, `${e.height}px`), a = () => m(n, `${e.width}px`), o = () => m(r, `${e.stableHeight}px`), p = [
2395
+ ] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => m(s, `${e.height}px`), o = () => m(n, `${e.width}px`), a = () => m(r, `${e.stableHeight}px`), p = [
2401
2396
  e.on("change:height", i),
2402
- e.on("change:width", a),
2403
- e.on("change:stableHeight", o)
2397
+ e.on("change:width", o),
2398
+ e.on("change:stableHeight", a)
2404
2399
  ];
2405
- return i(), a(), o(), () => p.forEach((u) => u());
2400
+ return i(), o(), a(), () => p.forEach((u) => u());
2406
2401
  }
2407
2402
  function vs(e = !0) {
2408
2403
  const t = [
2409
- b("reload_iframe", () => {
2410
- A("iframe_will_reload"), window.location.reload();
2404
+ w("reload_iframe", () => {
2405
+ R("iframe_will_reload"), window.location.reload();
2411
2406
  })
2412
2407
  ], s = () => t.forEach((n) => n());
2413
2408
  if (e) {
2414
2409
  const n = document.createElement("style");
2415
2410
  n.id = "telegram-custom-styles", document.head.appendChild(n), t.push(
2416
- b("set_custom_style", (r) => {
2411
+ w("set_custom_style", (r) => {
2417
2412
  n.innerHTML = r;
2418
2413
  }),
2419
2414
  () => document.head.removeChild(n)
2420
2415
  );
2421
2416
  }
2422
- return A("iframe_ready", { reload_supported: !0 }), s;
2417
+ return R("iframe_ready", { reload_supported: !0 }), s;
2423
2418
  }
2424
2419
  function Es() {
2425
2420
  return typeof window > "u";
2426
2421
  }
2427
2422
  async function Ps() {
2428
- if (lt(window))
2423
+ if (ft(window))
2429
2424
  return !0;
2430
2425
  try {
2431
2426
  return await _({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
@@ -2433,13 +2428,53 @@ async function Ps() {
2433
2428
  return !1;
2434
2429
  }
2435
2430
  }
2431
+ function xs(e) {
2432
+ const t = typeof e == "string" ? tt(e) : e;
2433
+ kt(t);
2434
+ function s(r) {
2435
+ if (typeof r == "string")
2436
+ try {
2437
+ const { eventType: i } = dt(r);
2438
+ i === "web_app_request_theme" && j("theme_changed", {
2439
+ theme_params: JSON.parse(qt(t.themeParams))
2440
+ }), i === "web_app_request_viewport" && j("viewport_changed", {
2441
+ width: window.innerWidth,
2442
+ height: window.innerHeight,
2443
+ is_state_stable: !0,
2444
+ is_expanded: !0
2445
+ });
2446
+ } catch {
2447
+ }
2448
+ }
2449
+ if (gt()) {
2450
+ const r = window.parent.postMessage.bind(window.parent);
2451
+ window.parent.postMessage = (i) => {
2452
+ s(i), r(i);
2453
+ };
2454
+ return;
2455
+ }
2456
+ if (_t(window)) {
2457
+ const r = window.external.notify.bind(window.external);
2458
+ window.external.notify = (i) => {
2459
+ s(i), r(i);
2460
+ };
2461
+ return;
2462
+ }
2463
+ const n = window.TelegramWebviewProxy;
2464
+ window.TelegramWebviewProxy = {
2465
+ ...n || {},
2466
+ postEvent(...r) {
2467
+ s(JSON.stringify({ eventType: r[0], eventData: r[1] })), n && n.postEvent(...r);
2468
+ }
2469
+ };
2470
+ }
2436
2471
  function Ge(e) {
2437
- return e instanceof V;
2472
+ return e instanceof D;
2438
2473
  }
2439
- function xs(e, t) {
2474
+ function Ss(e, t) {
2440
2475
  return Ge(e) && e.type === t;
2441
2476
  }
2442
- function B(e, t) {
2477
+ function L(e, t) {
2443
2478
  let s, n, r;
2444
2479
  return typeof e == "string" ? s = e : (s = e.pathname === void 0 ? t : e.pathname, n = e.params, r = e.id), Object.freeze({
2445
2480
  id: r || (Math.random() * 2 ** 14 | 0).toString(16),
@@ -2448,12 +2483,12 @@ function B(e, t) {
2448
2483
  });
2449
2484
  }
2450
2485
  class je {
2451
- constructor(t, s, n = A) {
2486
+ constructor(t, s, n = R) {
2452
2487
  /**
2453
2488
  * Navigation history.
2454
2489
  */
2455
2490
  c(this, "history");
2456
- c(this, "ee", new R());
2491
+ c(this, "ee", new T());
2457
2492
  /**
2458
2493
  * True, if current navigator is currently attached.
2459
2494
  */
@@ -2471,20 +2506,20 @@ class je {
2471
2506
  */
2472
2507
  c(this, "off", this.ee.off.bind(this.ee));
2473
2508
  if (this._index = s, this.postEvent = n, t.length === 0)
2474
- throw f(zt, "History should not be empty.");
2509
+ throw f(Kt, "History should not be empty.");
2475
2510
  if (s < 0 || s >= t.length)
2476
2511
  throw f(
2477
- Ft,
2512
+ Xt,
2478
2513
  "Index should not be zero and higher or equal than history size."
2479
2514
  );
2480
- this.history = t.map((r) => B(r, ""));
2515
+ this.history = t.map((r) => L(r, ""));
2481
2516
  }
2482
2517
  /**
2483
2518
  * Allows this navigator to control the `BackButton` visibility state. It also tracks the
2484
2519
  * `BackButton` clicks and calls the `back` method.
2485
2520
  */
2486
2521
  attach() {
2487
- this.attached || (this.attached = !0, this.sync(), b("back_button_pressed", this.back));
2522
+ this.attached || (this.attached = !0, this.sync(), w("back_button_pressed", this.back));
2488
2523
  }
2489
2524
  /**
2490
2525
  * Currently active history item.
@@ -2496,7 +2531,7 @@ class je {
2496
2531
  * Prevents current navigator from controlling the BackButton visibility state.
2497
2532
  */
2498
2533
  detach() {
2499
- this.attached = !1, L("back_button_pressed", this.back);
2534
+ this.attached = !1, $("back_button_pressed", this.back);
2500
2535
  }
2501
2536
  /**
2502
2537
  * Goes to the next history item.
@@ -2552,14 +2587,14 @@ class je {
2552
2587
  * @param item - item to add.
2553
2588
  */
2554
2589
  push(t) {
2555
- this.hasNext && this.history.splice(this.index + 1), this.replaceAndMove(this.index + 1, B(t, this.current.pathname));
2590
+ this.hasNext && this.history.splice(this.index + 1), this.replaceAndMove(this.index + 1, L(t, this.current.pathname));
2556
2591
  }
2557
2592
  /**
2558
2593
  * Replaces the current history item.
2559
2594
  * @param item - item to replace the current item with.
2560
2595
  */
2561
2596
  replace(t) {
2562
- this.replaceAndMove(this.index, B(t, this.current.pathname));
2597
+ this.replaceAndMove(this.index, L(t, this.current.pathname));
2563
2598
  }
2564
2599
  /**
2565
2600
  * Sets history item by the specified index.
@@ -2589,35 +2624,35 @@ class je {
2589
2624
  this.postEvent("web_app_setup_back_button", { is_visible: !!this.index });
2590
2625
  }
2591
2626
  }
2592
- function O({
2627
+ function B({
2593
2628
  params: e,
2594
2629
  ...t
2595
2630
  }) {
2596
2631
  return { ...e || { hash: "", search: "" }, ...t };
2597
2632
  }
2598
- function T(e, t) {
2633
+ function A(e, t) {
2599
2634
  return e.startsWith(t) ? e : `${t}${e}`;
2600
2635
  }
2601
- function N(e) {
2636
+ function k(e) {
2602
2637
  return new URL(
2603
- typeof e == "string" ? e : `${e.pathname || ""}${T(e.search || "", "?")}${T(e.hash || "", "#")}`,
2638
+ typeof e == "string" ? e : `${e.pathname || ""}${A(e.search || "", "?")}${A(e.hash || "", "#")}`,
2604
2639
  "http://a"
2605
2640
  );
2606
2641
  }
2607
- function D(e) {
2608
- const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = N(e);
2642
+ function N(e) {
2643
+ const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = k(e);
2609
2644
  return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
2610
2645
  }
2611
- function U(e, t, s) {
2646
+ function W(e, t, s) {
2612
2647
  let n, r;
2613
- typeof e == "string" ? n = e : (n = D(e), s = e.state, r = e.id);
2614
- const { pathname: i, search: a, hash: o } = new URL(n, `http://a${T(t, "/")}`);
2615
- return { id: r, pathname: i, params: { hash: o, search: a, state: s } };
2648
+ typeof e == "string" ? n = e : (n = N(e), s = e.state, r = e.id);
2649
+ const { pathname: i, search: o, hash: a } = new URL(n, `http://a${A(t, "/")}`);
2650
+ return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
2616
2651
  }
2617
2652
  async function C(e) {
2618
2653
  return e === 0 ? !0 : Promise.race([
2619
2654
  new Promise((t) => {
2620
- const s = j("popstate", () => {
2655
+ const s = G("popstate", () => {
2621
2656
  s(), t(!0);
2622
2657
  });
2623
2658
  window.history.go(e);
@@ -2635,14 +2670,14 @@ async function ze() {
2635
2670
  for (; t; )
2636
2671
  t = await C(-1);
2637
2672
  }
2638
- function Nt(e) {
2639
- return N(e).pathname;
2673
+ function Lt(e) {
2674
+ return k(e).pathname;
2640
2675
  }
2641
- const rt = 0, W = 1, H = 2;
2642
- class Dt {
2676
+ const ot = 0, O = 1, U = 2;
2677
+ class Bt {
2643
2678
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2644
2679
  c(this, "navigator");
2645
- c(this, "ee", new R());
2680
+ c(this, "ee", new T());
2646
2681
  c(this, "hashMode");
2647
2682
  c(this, "base");
2648
2683
  /**
@@ -2656,7 +2691,7 @@ class Dt {
2656
2691
  c(this, "onPopState", ({ state: t }) => {
2657
2692
  if (t === null)
2658
2693
  return this.push(this.parsePath(window.location.href));
2659
- t === rt ? window.history.forward() : t === W && this.back(), t === H && this.forward();
2694
+ t === ot ? window.history.forward() : t === O && this.back(), t === U && this.forward();
2660
2695
  });
2661
2696
  /**
2662
2697
  * Underlying navigator change event listener.
@@ -2668,8 +2703,8 @@ class Dt {
2668
2703
  }) => {
2669
2704
  this.attached && await this.syncHistory(), this.ee.emit("change", {
2670
2705
  delta: n,
2671
- from: O(s),
2672
- to: O(t),
2706
+ from: B(s),
2707
+ to: B(t),
2673
2708
  navigator: this
2674
2709
  });
2675
2710
  });
@@ -2682,10 +2717,10 @@ class Dt {
2682
2717
  */
2683
2718
  c(this, "off", this.ee.off.bind(this.ee));
2684
2719
  this.navigator = new je(
2685
- t.map((a) => U(a, "/")),
2720
+ t.map((o) => W(o, "/")),
2686
2721
  s,
2687
2722
  n
2688
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Nt(i || "");
2723
+ ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Lt(i || "");
2689
2724
  }
2690
2725
  /**
2691
2726
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2769,7 +2804,7 @@ class Dt {
2769
2804
  * Navigation history.
2770
2805
  */
2771
2806
  get history() {
2772
- return this.navigator.history.map(O);
2807
+ return this.navigator.history.map(B);
2773
2808
  }
2774
2809
  /**
2775
2810
  * Path, including pathname, search and hash.
@@ -2783,7 +2818,7 @@ class Dt {
2783
2818
  * "/pathname?search#hash"
2784
2819
  */
2785
2820
  get path() {
2786
- return D(this);
2821
+ return N(this);
2787
2822
  }
2788
2823
  /**
2789
2824
  * Current pathname. Always starts with the slash.
@@ -2812,19 +2847,19 @@ class Dt {
2812
2847
  * // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
2813
2848
  */
2814
2849
  parsePath(t) {
2815
- let s = N(t);
2816
- return this.hashMode && (s = N(s.hash.slice(1))), {
2850
+ let s = k(t);
2851
+ return this.hashMode && (s = k(s.hash.slice(1))), {
2817
2852
  pathname: s.pathname,
2818
2853
  search: s.search,
2819
2854
  hash: s.hash
2820
2855
  };
2821
2856
  }
2822
2857
  push(t, s) {
2823
- const n = U(t, this.path), { state: r = s } = n.params;
2858
+ const n = W(t, this.path), { state: r = s } = n.params;
2824
2859
  this.navigator.push({ ...n, params: { ...n.params, state: r } });
2825
2860
  }
2826
2861
  replace(t, s) {
2827
- const n = U(t, this.path), { state: r = s } = n.params;
2862
+ const n = W(t, this.path), { state: r = s } = n.params;
2828
2863
  this.navigator.replace({ ...n, params: { ...n.params, state: r } });
2829
2864
  }
2830
2865
  /**
@@ -2833,8 +2868,8 @@ class Dt {
2833
2868
  * @param value - path presented as string or URLLike.
2834
2869
  */
2835
2870
  renderPath(t) {
2836
- const s = (this.base.length === 1 ? "" : this.base) + T(D(t), "/");
2837
- return this.hashMode ? T(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2871
+ const s = (this.base.length === 1 ? "" : this.base) + A(N(t), "/");
2872
+ return this.hashMode ? A(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2838
2873
  }
2839
2874
  /**
2840
2875
  * Synchronizes current navigator state with browser history.
@@ -2842,7 +2877,7 @@ class Dt {
2842
2877
  async syncHistory() {
2843
2878
  window.removeEventListener("popstate", this.onPopState);
2844
2879
  const { state: t } = this, s = this.renderPath(this);
2845
- await ze(), this.hasPrev && this.hasNext ? (window.history.replaceState(W, ""), window.history.pushState(t, "", s), window.history.pushState(H, ""), await C(-1)) : this.hasPrev ? (window.history.replaceState(W, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(H, ""), await C(-1)) : (window.history.replaceState(rt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2880
+ await ze(), this.hasPrev && this.hasNext ? (window.history.replaceState(O, ""), window.history.pushState(t, "", s), window.history.pushState(U, ""), await C(-1)) : this.hasPrev ? (window.history.replaceState(O, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(U, ""), await C(-1)) : (window.history.replaceState(ot, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2846
2881
  }
2847
2882
  /**
2848
2883
  * Current query parameters.
@@ -2863,38 +2898,38 @@ class Dt {
2863
2898
  function Fe(e) {
2864
2899
  e || (e = {});
2865
2900
  const { href: t, hash: s } = window.location;
2866
- let n = D(
2901
+ let n = N(
2867
2902
  e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
2868
2903
  );
2869
- const r = e.base ? Nt(e.base) : void 0;
2904
+ const r = e.base ? Lt(e.base) : void 0;
2870
2905
  if (r) {
2871
2906
  if (!n.startsWith(r))
2872
2907
  throw f(
2873
- Jt,
2908
+ te,
2874
2909
  `Path "${n}" expected to be starting with "${r}"`
2875
2910
  );
2876
2911
  n = n.slice(r.length);
2877
2912
  }
2878
- return new Dt([n], 0, e);
2913
+ return new Bt([n], 0, e);
2879
2914
  }
2880
- function Ss(e) {
2915
+ function Cs(e) {
2881
2916
  const t = e.match(/#(.+)/);
2882
2917
  return t ? t[1] : null;
2883
2918
  }
2884
2919
  function Je(e, t) {
2885
- if (At()) {
2920
+ if (Nt()) {
2886
2921
  const s = sessionStorage.getItem(e);
2887
2922
  if (s)
2888
2923
  try {
2889
2924
  const { index: n, history: r } = JSON.parse(s);
2890
- return new Dt(r, n, t);
2925
+ return new Bt(r, n, t);
2891
2926
  } catch (n) {
2892
2927
  console.error("Unable to restore hash navigator state.", n);
2893
2928
  }
2894
2929
  }
2895
2930
  return Fe(t);
2896
2931
  }
2897
- function Cs(e, t) {
2932
+ function Ts(e, t) {
2898
2933
  const s = Je(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2899
2934
  index: s.index,
2900
2935
  history: s.history
@@ -2902,51 +2937,51 @@ function Cs(e, t) {
2902
2937
  return s.on("change", n), n(), s;
2903
2938
  }
2904
2939
  export {
2905
- pe as BackButton,
2940
+ le as BackButton,
2906
2941
  je as BasicNavigator,
2907
2942
  Pe as BiometryManager,
2908
- Dt as BrowserNavigator,
2943
+ Bt as BrowserNavigator,
2909
2944
  Se as ClosingBehavior,
2910
- Te as CloudStorage,
2911
- Jt as ERR_INVALID_PATH_BASE,
2912
- Ht as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2913
- Ut as ERR_METHOD_PARAMETER_UNSUPPORTED,
2914
- Ot as ERR_METHOD_UNSUPPORTED,
2915
- zt as ERR_NAVIGATION_HISTORY_EMPTY,
2916
- Ft as ERR_NAVIGATION_INDEX_INVALID,
2945
+ Ae as CloudStorage,
2946
+ te as ERR_INVALID_PATH_BASE,
2947
+ Qt as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2948
+ Ft as ERR_METHOD_PARAMETER_UNSUPPORTED,
2949
+ zt as ERR_METHOD_UNSUPPORTED,
2950
+ Kt as ERR_NAVIGATION_HISTORY_EMPTY,
2951
+ Xt as ERR_NAVIGATION_INDEX_INVALID,
2917
2952
  Ze as ERR_NAVIGATION_ITEM_INVALID,
2918
- ct as ERR_PARSE,
2953
+ ht as ERR_PARSE,
2919
2954
  Ke as ERR_SSR_INIT,
2920
- Gt as ERR_TIMED_OUT,
2921
- jt as ERR_UNEXPECTED_TYPE,
2922
- Wt as ERR_UNKNOWN_ENV,
2923
- R as EventEmitter,
2955
+ Yt as ERR_TIMED_OUT,
2956
+ Zt as ERR_UNEXPECTED_TYPE,
2957
+ Jt as ERR_UNKNOWN_ENV,
2958
+ T as EventEmitter,
2924
2959
  Ie as HapticFeedback,
2925
2960
  qe as InitData,
2926
2961
  ke as Invoice,
2927
2962
  Ne as MainButton,
2928
- $e as MiniApp,
2963
+ Me as MiniApp,
2929
2964
  Le as Popup,
2930
2965
  Be as QRScanner,
2931
- V as SDKError,
2932
- Oe as SettingsButton,
2933
- Ue as ThemeParams,
2934
- We as Utils,
2966
+ D as SDKError,
2967
+ We as SettingsButton,
2968
+ Oe as ThemeParams,
2969
+ Ue as Utils,
2935
2970
  He as Viewport,
2936
- Ae as array,
2937
- ws as bindMiniAppCSSVars,
2971
+ Re as array,
2972
+ bs as bindMiniAppCSSVars,
2938
2973
  ms as bindThemeParamsCSSVars,
2939
2974
  ys as bindViewportCSSVars,
2940
- w as boolean,
2941
- _t as captureSameReq,
2975
+ b as boolean,
2976
+ bt as captureSameReq,
2942
2977
  z as classNames,
2943
- re as compareVersions,
2978
+ ce as compareVersions,
2944
2979
  Fe as createBrowserNavigatorFromLocation,
2945
- ce as createPostEvent,
2946
- N as createSafeURL,
2947
- mt as date,
2948
- Ss as getHash,
2949
- Nt as getPathname,
2980
+ pe as createPostEvent,
2981
+ k as createSafeURL,
2982
+ Pt as date,
2983
+ Cs as getHash,
2984
+ Lt as getPathname,
2950
2985
  es as initBackButton,
2951
2986
  ss as initBiometryManager,
2952
2987
  ns as initClosingBehavior,
@@ -2956,52 +2991,53 @@ export {
2956
2991
  cs as initInvoice,
2957
2992
  hs as initMainButton,
2958
2993
  ps as initMiniApp,
2959
- Cs as initNavigator,
2994
+ Ts as initNavigator,
2960
2995
  us as initPopup,
2961
2996
  ls as initQRScanner,
2962
2997
  ds as initSettingsButton,
2963
2998
  _s as initThemeParams,
2964
2999
  gs as initUtils,
2965
- bs as initViewport,
3000
+ ws as initViewport,
2966
3001
  vs as initWeb,
2967
3002
  S as invokeCustomMethod,
2968
- bt as isColorDark,
2969
- oe as isIframe,
2970
- At as isPageReload,
2971
- Q as isRGB,
2972
- Qt as isRGBShort,
3003
+ vt as isColorDark,
3004
+ gt as isIframe,
3005
+ Nt as isPageReload,
3006
+ Y as isRGB,
3007
+ ee as isRGBShort,
2973
3008
  Ge as isSDKError,
2974
- xs as isSDKErrorOfType,
3009
+ Ss as isSDKErrorOfType,
2975
3010
  Es as isSSR,
2976
3011
  Ps as isTMA,
2977
3012
  d as json,
2978
3013
  ts as mergeClassNames,
3014
+ xs as mockTelegramEnv,
2979
3015
  y as number,
2980
- L as off,
2981
- b as on,
3016
+ $ as off,
3017
+ w as on,
2982
3018
  as as parseInitData,
2983
- Et as parseLaunchParams,
2984
- qt as parseThemeParams,
2985
- A as postEvent,
3019
+ tt as parseLaunchParams,
3020
+ Mt as parseThemeParams,
3021
+ R as postEvent,
2986
3022
  _ as request,
2987
3023
  xe as requestBiometryInfo,
2988
3024
  fs as requestThemeParams,
2989
- kt as requestViewport,
3025
+ $t as requestViewport,
2990
3026
  ye as retrieveLaunchParams,
2991
- ut as rgb,
2992
- K as searchParams,
2993
- we as serializeLaunchParams,
2994
- be as serializeThemeParams,
3027
+ lt as rgb,
3028
+ X as searchParams,
3029
+ me as serializeLaunchParams,
3030
+ qt as serializeThemeParams,
2995
3031
  m as setCSSVar,
2996
3032
  Ye as setDebug,
2997
3033
  Xe as setTargetOrigin,
2998
3034
  h as string,
2999
- Mt as subscribe,
3035
+ Ht as subscribe,
3000
3036
  v as supports,
3001
- ae as targetOrigin,
3002
- pt as toRGB,
3003
- ot as unsubscribe,
3004
- D as urlToPath,
3005
- gt as withTimeout
3037
+ he as targetOrigin,
3038
+ ut as toRGB,
3039
+ ct as unsubscribe,
3040
+ N as urlToPath,
3041
+ yt as withTimeout
3006
3042
  };
3007
3043
  //# sourceMappingURL=index.js.map