@tma.js/sdk 2.3.0 → 2.5.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,5 +1,5 @@
1
- var Wt = Object.defineProperty;
2
- var Ut = (e, t, s) => t in e ? Wt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
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
3
  var c = (e, t, s) => (Ut(e, typeof t != "symbol" ? t + "" : t, s), s);
4
4
  function at(e, t) {
5
5
  let s;
@@ -9,11 +9,11 @@ function at(e, t) {
9
9
  return [() => s === void 0 ? s = e(n) : s, n];
10
10
  }
11
11
  function ct(e) {
12
- const t = $(), { count: s } = t;
12
+ const t = M(), { count: s } = t;
13
13
  t.unsubscribe(e), s && !t.count && ae();
14
14
  }
15
15
  function Ht(e) {
16
- return $().subscribe(e), () => ct(e);
16
+ return M().subscribe(e), () => ct(e);
17
17
  }
18
18
  class Gt {
19
19
  constructor(t, s = {}) {
@@ -31,12 +31,12 @@ class Gt {
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 Gt {
55
55
  this.print("log", ...t);
56
56
  }
57
57
  }
58
- const J = new Gt("SDK", {
58
+ const F = new Gt("SDK", {
59
59
  bgColor: "forestgreen",
60
60
  textColor: "white"
61
61
  });
62
- let G = !1;
62
+ let H = !1;
63
63
  const nt = ({ name: e, payload: t }) => {
64
- J.log("Event received:", t ? { name: e, payload: t } : { name: e });
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 ? Ht(nt) : ct(nt));
67
+ H !== e && (H = e, e ? Ht(nt) : ct(nt));
68
68
  }
69
69
  function jt(...e) {
70
- G && J.log(...e);
70
+ H && F.log(...e);
71
71
  }
72
- class T {
72
+ class R {
73
73
  constructor() {
74
74
  c(this, "listeners", /* @__PURE__ */ new Map());
75
75
  c(this, "listenersCount", 0);
@@ -141,10 +141,10 @@ class T {
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 ht(...e) {
147
+ function J(...e) {
148
148
  let t = !1;
149
149
  const s = [...e];
150
150
  return [
@@ -155,19 +155,19 @@ function ht(...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 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", pt = "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";
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
168
  return f(Zt, "Value has unexpected type");
169
169
  }
170
- class M {
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 M {
183
183
  return this.parser(t);
184
184
  } catch (s) {
185
185
  throw f(
186
- pt,
186
+ ht,
187
187
  `Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
188
188
  s
189
189
  );
@@ -194,7 +194,7 @@ class M {
194
194
  }
195
195
  }
196
196
  function P(e, t) {
197
- return () => new M(e, !1, t);
197
+ return () => new V(e, !1, t);
198
198
  }
199
199
  const b = P((e) => {
200
200
  if (typeof e == "boolean")
@@ -206,24 +206,24 @@ const b = P((e) => {
206
206
  return !1;
207
207
  throw E();
208
208
  }, "boolean");
209
- function ut(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(pt, `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;
@@ -235,9 +235,9 @@ function Q(e) {
235
235
  return t;
236
236
  }
237
237
  function d(e, t) {
238
- return new M((s) => {
238
+ return new V((s) => {
239
239
  const n = Q(s);
240
- return ut(e, (r) => n[r]);
240
+ return pt(e, (r) => n[r]);
241
241
  }, !1, t);
242
242
  }
243
243
  const y = P((e) => {
@@ -256,7 +256,7 @@ function Y(e) {
256
256
  function ee(e) {
257
257
  return /^#[\da-f]{3}$/i.test(e);
258
258
  }
259
- function lt(e) {
259
+ function ut(e) {
260
260
  const t = e.replace(/\s/g, "").toLowerCase();
261
261
  if (Y(t))
262
262
  return t;
@@ -278,8 +278,8 @@ const h = P((e) => {
278
278
  if (typeof e == "string" || typeof e == "number")
279
279
  return e.toString();
280
280
  throw E();
281
- }, "string"), dt = P((e) => lt(h().parse(e)), "rgb");
282
- function _t(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
@@ -290,7 +290,7 @@ function se() {
290
290
  delete window[e];
291
291
  });
292
292
  }
293
- function z(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.
@@ -309,7 +309,7 @@ function ne() {
309
309
  let t = window;
310
310
  e.forEach((s, n, r) => {
311
311
  if (n === r.length - 1) {
312
- t[s] = z;
312
+ t[s] = j;
313
313
  return;
314
314
  }
315
315
  s in t || (t[s] = {}), t = t[s];
@@ -338,7 +338,7 @@ const re = {
338
338
  qr_text_received: d({ data: h().optional() }),
339
339
  theme_changed: d({
340
340
  theme_params: (e) => {
341
- const t = dt().optional();
341
+ const t = lt().optional();
342
342
  return Object.entries(Q(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
343
343
  }
344
344
  }),
@@ -351,11 +351,11 @@ const re = {
351
351
  write_access_requested: d({ status: h() })
352
352
  };
353
353
  function ie() {
354
- const e = new T(), t = new T();
354
+ const e = new R(), t = new R();
355
355
  t.subscribe((n) => {
356
356
  e.emit("event", { name: n.event, payload: n.args[0] });
357
357
  }), ne();
358
- const [, s] = ht(
358
+ const [, s] = J(
359
359
  // Don't forget to remove created handlers.
360
360
  se,
361
361
  // Add "resize" event listener to make sure, we always have fresh viewport information.
@@ -363,7 +363,7 @@ function ie() {
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,21 +373,21 @@ function ie() {
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 = _t(n.data);
381
+ r = dt(n.data);
382
382
  } catch {
383
383
  return;
384
384
  }
385
- const { eventType: i, eventData: a } = r, o = re[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
- J.error(
390
+ F.error(
391
391
  `An error occurred processing the "${i}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
392
392
  r,
393
393
  p
@@ -416,20 +416,20 @@ const [oe, ae] = at(
416
416
  (e) => {
417
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
- function $() {
425
+ function M() {
426
426
  return oe()[0];
427
427
  }
428
428
  function L(e, t) {
429
- $().off(e, t);
429
+ M().off(e, t);
430
430
  }
431
431
  function w(e, t, s) {
432
- return $().on(e, t, s);
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);
@@ -437,9 +437,9 @@ function I(e) {
437
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
  }
@@ -497,39 +497,39 @@ function v(e, t, s) {
497
497
  ].includes(e);
498
498
  }
499
499
  }
500
- function ft(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 gt(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 wt() {
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 bt = "https://web.telegram.org";
513
+ let wt = "https://web.telegram.org";
514
514
  function Xe(e) {
515
- bt = e;
515
+ wt = e;
516
516
  }
517
517
  function he() {
518
- return bt;
518
+ return wt;
519
519
  }
520
- function R(e, t, s) {
520
+ function T(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
523
  const { targetOrigin: i = he() } = n;
524
- if (jt("Posting event:", r ? { event: e, data: r } : { event: e }), wt()) {
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 (ft(window)) {
528
+ if (_t(window)) {
529
529
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
530
530
  return;
531
531
  }
532
- if (gt(window)) {
532
+ if (ft(window)) {
533
533
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
534
534
  return;
535
535
  }
@@ -550,42 +550,38 @@ function pe(e) {
550
550
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
551
551
  );
552
552
  }
553
- return R(t, s);
553
+ return T(t, s);
554
554
  };
555
555
  }
556
- function mt(e) {
556
+ function bt(e) {
557
557
  return ({ req_id: t }) => t === e;
558
558
  }
559
- function yt(e) {
559
+ function mt(e) {
560
560
  return f(Yt, `Timeout reached: ${e}ms`);
561
561
  }
562
- function vt(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(yt(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 = R,
581
- timeout: o
582
- } = e, p = (Array.isArray(r) ? r : [r]).map(
583
- (u) => w(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 ? vt(s, o) : s);
582
+ return (e.postEvent || T)(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,30 +597,30 @@ async function S(e, t, s, n = {}) {
601
597
  params: t,
602
598
  req_id: s
603
599
  },
604
- capture: mt(s)
600
+ capture: bt(s)
605
601
  });
606
602
  if (i)
607
603
  throw f(Qt, i);
608
604
  return r;
609
605
  }
610
- function F(...e) {
606
+ function z(...e) {
611
607
  return e.map((t) => {
612
608
  if (typeof t == "string")
613
609
  return t;
614
610
  if (I(t))
615
- return F(Object.entries(t).map((s) => s[1] && s[0]));
611
+ return z(Object.entries(t).map((s) => s[1] && s[0]));
616
612
  if (Array.isArray(t))
617
- return F(...t);
613
+ return z(...t);
618
614
  }).filter(Boolean).join(" ");
619
615
  }
620
616
  function ts(...e) {
621
617
  return e.reduce((t, s) => (I(s) && Object.entries(s).forEach(([n, r]) => {
622
- const i = F(t[n], r);
618
+ const i = z(t[n], r);
623
619
  i.length && (t[n] = i);
624
620
  }), t), {});
625
621
  }
626
- function Et(e) {
627
- const t = lt(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);
@@ -634,7 +630,7 @@ function Et(e) {
634
630
  }
635
631
  class ue {
636
632
  constructor(t) {
637
- c(this, "ee", new T());
633
+ c(this, "ee", new R());
638
634
  /**
639
635
  * Adds new event listener.
640
636
  */
@@ -652,7 +648,7 @@ class ue {
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.
@@ -680,7 +676,7 @@ class Z {
680
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 Pt(e, t) {
679
+ function Et(e, t) {
684
680
  return (s) => v(t[s], e);
685
681
  }
686
682
  class K extends Z {
@@ -690,7 +686,7 @@ class K extends Z {
690
686
  * @returns True, if specified method is supported by the current component.
691
687
  */
692
688
  c(this, "supports");
693
- this.supports = Pt(n, r);
689
+ this.supports = Et(n, r);
694
690
  }
695
691
  }
696
692
  class le extends K {
@@ -735,13 +731,13 @@ class le extends K {
735
731
  this.isVisible = !0;
736
732
  }
737
733
  }
738
- const xt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
734
+ const Pt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
739
735
  function X(e, t) {
740
- return new M((s) => {
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 ut(e, (r) => {
740
+ return pt(e, (r) => {
745
741
  const i = n.get(r);
746
742
  return i === null ? void 0 : i;
747
743
  });
@@ -792,10 +788,10 @@ const de = d({
792
788
  },
793
789
  username: h().optional()
794
790
  }, "User").optional();
795
- function St() {
791
+ function xt() {
796
792
  return X({
797
793
  authDate: {
798
- type: xt(),
794
+ type: Pt(),
799
795
  from: "auth_date"
800
796
  },
801
797
  canSendAfter: {
@@ -830,9 +826,9 @@ function _e(e) {
830
826
  function fe(e) {
831
827
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
832
828
  }
833
- const Ct = P(
829
+ const St = P(
834
830
  (e) => {
835
- const t = dt().optional();
831
+ const t = lt().optional();
836
832
  return Object.entries(Q(e)).reduce((s, [n, r]) => (s[_e(n)] = t.parse(r), s), {});
837
833
  },
838
834
  "ThemeParams"
@@ -844,7 +840,7 @@ function tt(e) {
844
840
  from: "tgWebAppBotInline"
845
841
  },
846
842
  initData: {
847
- type: St().optional(),
843
+ type: xt().optional(),
848
844
  from: "tgWebAppData"
849
845
  },
850
846
  initDataRaw: {
@@ -864,7 +860,7 @@ function tt(e) {
864
860
  from: "tgWebAppStartParam"
865
861
  },
866
862
  themeParams: {
867
- type: Ct(),
863
+ type: St(),
868
864
  from: "tgWebAppThemeParams"
869
865
  },
870
866
  version: {
@@ -873,13 +869,13 @@ function tt(e) {
873
869
  }
874
870
  }).parse(e);
875
871
  }
876
- function Tt(e) {
872
+ function Ct(e) {
877
873
  return tt(
878
874
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
879
875
  );
880
876
  }
881
877
  function ge() {
882
- return Tt(window.location.href);
878
+ return Ct(window.location.href);
883
879
  }
884
880
  function Rt() {
885
881
  return performance.getEntriesByType("navigation")[0];
@@ -888,25 +884,25 @@ function we() {
888
884
  const e = Rt();
889
885
  if (!e)
890
886
  throw new Error("Unable to get first navigation entry.");
891
- return Tt(e.name);
887
+ return Ct(e.name);
892
888
  }
893
- function At(e) {
889
+ function Tt(e) {
894
890
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
895
891
  }
896
- function It(e, t) {
897
- sessionStorage.setItem(At(e), JSON.stringify(t));
892
+ function At(e, t) {
893
+ sessionStorage.setItem(Tt(e), JSON.stringify(t));
898
894
  }
899
- function qt(e) {
900
- const t = sessionStorage.getItem(At(e));
895
+ function It(e) {
896
+ const t = sessionStorage.getItem(Tt(e));
901
897
  try {
902
898
  return t ? JSON.parse(t) : void 0;
903
899
  } catch {
904
900
  }
905
901
  }
906
902
  function be() {
907
- return tt(qt("launchParams") || "");
903
+ return tt(It("launchParams") || "");
908
904
  }
909
- function kt(e) {
905
+ function qt(e) {
910
906
  return JSON.stringify(
911
907
  Object.fromEntries(
912
908
  Object.entries(e).map(([t, s]) => [fe(t), s])
@@ -920,13 +916,13 @@ function me(e) {
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", kt(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 Nt(e) {
929
- It("launchParams", me(e));
924
+ function kt(e) {
925
+ At("launchParams", me(e));
930
926
  }
931
927
  function ye() {
932
928
  for (const e of [
@@ -940,12 +936,12 @@ function ye() {
940
936
  ])
941
937
  try {
942
938
  const t = e();
943
- return Nt(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 Dt() {
944
+ function Nt() {
949
945
  const e = Rt();
950
946
  return !!(e && e.type === "reload");
951
947
  }
@@ -963,20 +959,20 @@ function l(e, t) {
963
959
  };
964
960
  if (typeof e == "function")
965
961
  return e(n);
966
- const [r, i, a] = ht(), 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: Dt() ? qt(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
- It(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
  };
@@ -999,7 +995,7 @@ class q extends K {
999
995
  c(this, "off", this.state.off.bind(this.state));
1000
996
  }
1001
997
  }
1002
- function Vt(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 = Vt(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 Vt(
1131
+ return Dt(
1136
1132
  await _({
1137
1133
  ...e || {},
1138
1134
  method: "web_app_biometry_get_info",
@@ -1207,7 +1203,7 @@ class st {
1207
1203
  * @returns True, if specified method is supported by the current component.
1208
1204
  */
1209
1205
  c(this, "supports");
1210
- this.supports = Pt(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 Te extends M {
1221
+ class Re extends V {
1226
1222
  constructor(s, n, r) {
1227
1223
  super(Ce, n, r);
1228
1224
  c(this, "itemParser");
@@ -1242,8 +1238,8 @@ class Te extends M {
1242
1238
  return this.itemParser = typeof s == "function" ? s : s.parse.bind(s), this;
1243
1239
  }
1244
1240
  }
1245
- function Re(e) {
1246
- return new Te((t) => t, !1, e);
1241
+ function Te(e) {
1242
+ return new Re((t) => t, !1, e);
1247
1243
  }
1248
1244
  function it(e, t) {
1249
1245
  return Object.fromEntries(e.map((s) => [s, t]));
@@ -1276,7 +1272,7 @@ class Ae extends st {
1276
1272
  * @param options - request execution options.
1277
1273
  */
1278
1274
  async getKeys(t = {}) {
1279
- return Re().of(h()).parse(
1275
+ return Te().of(h()).parse(
1280
1276
  await S(
1281
1277
  "getStorageKeys",
1282
1278
  {},
@@ -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 St().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 {
@@ -1667,13 +1663,13 @@ function De() {
1667
1663
  }
1668
1664
  }),
1669
1665
  authDate: {
1670
- type: xt(),
1666
+ type: Pt(),
1671
1667
  from: "auth_date"
1672
1668
  },
1673
1669
  hash: h()
1674
1670
  }, "RequestedContact");
1675
1671
  }
1676
- function Mt(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);
@@ -1685,8 +1681,8 @@ function Ve(e) {
1685
1681
  });
1686
1682
  }
1687
1683
  class Me extends q {
1688
- constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...a }) {
1689
- super(a, r, {
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 Me 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 = Mt(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 Me extends q {
1755
1751
  * True if current Mini App background color is recognized as dark.
1756
1752
  */
1757
1753
  get isDark() {
1758
- return Et(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 Me extends q {
1784
1780
  throw new Error("Access denied.");
1785
1781
  const r = Date.now() + s;
1786
1782
  let i = 50;
1787
- return vt(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 Me extends q {
1792
1788
  }
1793
1789
  await Ve(i), i += 50;
1794
1790
  }
1795
- throw yt(s);
1791
+ throw mt(s);
1796
1792
  }, s);
1797
1793
  }
1798
1794
  /**
@@ -1887,7 +1883,7 @@ const ps = l(
1887
1883
  ...n
1888
1884
  }) => new Me({ ...n, ...s, botInline: t })
1889
1885
  );
1890
- function $e(e) {
1886
+ function Le(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,21 +1893,21 @@ function $e(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
- class Le extends q {
1910
+ class $e extends q {
1915
1911
  constructor(t, s, n) {
1916
1912
  super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
1917
1913
  }
@@ -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: $e(t)
1943
+ params: Le(t)
1948
1944
  });
1949
1945
  return s;
1950
1946
  } finally {
@@ -1953,7 +1949,7 @@ class Le extends q {
1953
1949
  }
1954
1950
  }
1955
1951
  const us = l(
1956
- ({ postEvent: e, version: t }) => new Le(!1, t, e)
1952
+ ({ postEvent: e, version: t }) => new $e(!1, t, e)
1957
1953
  );
1958
1954
  class Be extends q {
1959
1955
  constructor(t, s, n) {
@@ -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 K {
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",
@@ -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 $t(e) {
2056
- return Ct().parse(e);
2050
+ function Mt(e) {
2051
+ return St().parse(e);
2057
2052
  }
2058
- class We extends et {
2053
+ class Oe extends et {
2059
2054
  /**
2060
2055
  * @since v6.10
2061
2056
  */
@@ -2094,7 +2089,7 @@ class We extends et {
2094
2089
  * value is calculated according to theme bg color.
2095
2090
  */
2096
2091
  get isDark() {
2097
- return !this.bgColor || Et(this.bgColor);
2092
+ return !this.bgColor || vt(this.bgColor);
2098
2093
  }
2099
2094
  get linkColor() {
2100
2095
  return this.get("linkColor");
@@ -2120,7 +2115,7 @@ class We extends et {
2120
2115
  */
2121
2116
  listen() {
2122
2117
  return w("theme_changed", (t) => {
2123
- this.set($t(t.theme_params));
2118
+ this.set(Mt(t.theme_params));
2124
2119
  });
2125
2120
  }
2126
2121
  /**
@@ -2136,7 +2131,7 @@ class We extends et {
2136
2131
  const _s = l(
2137
2132
  "themeParams",
2138
2133
  ({ themeParams: e, state: t = e, addCleanup: s }) => {
2139
- const n = new We(t);
2134
+ const n = new Oe(t);
2140
2135
  return s(n.listen()), n;
2141
2136
  }
2142
2137
  );
@@ -2145,7 +2140,7 @@ function fs(e = {}) {
2145
2140
  ...e,
2146
2141
  method: "web_app_request_theme",
2147
2142
  event: "theme_changed"
2148
- }).then($t);
2143
+ }).then(Mt);
2149
2144
  }
2150
2145
  class Ue extends st {
2151
2146
  constructor(s, n, r) {
@@ -2154,7 +2149,7 @@ class Ue extends st {
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 = Mt(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
  }
@@ -2185,7 +2180,7 @@ class Ue extends st {
2185
2180
  * @throws {Error} URL has not allowed hostname.
2186
2181
  */
2187
2182
  openTelegramLink(s) {
2188
- const { hostname: n, pathname: r, search: i } = new URL(s, window.location.href);
2183
+ const { hostname: n, pathname: r, search: i } = new URL(s, "https://t.me");
2189
2184
  if (n !== "t.me")
2190
2185
  throw new Error(`URL has not allowed hostname: ${n}. Only "t.me" is allowed`);
2191
2186
  if (!v("web_app_open_tg_link", this.version)) {
@@ -2208,10 +2203,24 @@ class Ue extends st {
2208
2203
  event: "clipboard_text_received",
2209
2204
  postEvent: this.postEvent,
2210
2205
  params: { req_id: s },
2211
- capture: mt(s)
2206
+ capture: bt(s)
2212
2207
  });
2213
2208
  return n;
2214
2209
  }
2210
+ /**
2211
+ * Shares specified URL with the passed to the chats, selected by user. After being called,
2212
+ * it closes the mini application.
2213
+ *
2214
+ * This method uses Telegram's Share Links.
2215
+ * @param url - URL to share.
2216
+ * @param text - text to append after the URL.
2217
+ * @see https://core.telegram.org/api/links#share-links
2218
+ */
2219
+ shareURL(s, n) {
2220
+ this.openTelegramLink(
2221
+ "https://t.me/share?" + new URLSearchParams({ url: s, text: n || "" }).toString()
2222
+ );
2223
+ }
2215
2224
  }
2216
2225
  const gs = l(
2217
2226
  ({ version: e, postEvent: t, createRequestId: s }) => new Ue(e, s, t)
@@ -2232,10 +2241,10 @@ function x(e) {
2232
2241
  return e < 0 ? 0 : e;
2233
2242
  }
2234
2243
  class He extends et {
2235
- constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: a }) {
2244
+ constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: o }) {
2236
2245
  super({
2237
2246
  height: x(r),
2238
- isExpanded: a,
2247
+ isExpanded: o,
2239
2248
  stableHeight: x(n),
2240
2249
  width: x(i)
2241
2250
  });
@@ -2300,13 +2309,13 @@ class He extends et {
2300
2309
  height: n,
2301
2310
  width: r,
2302
2311
  is_expanded: i,
2303
- is_state_stable: a
2304
- } = s, o = x(n);
2312
+ is_state_stable: o
2313
+ } = s, a = x(n);
2305
2314
  this.set({
2306
- height: o,
2315
+ height: a,
2307
2316
  isExpanded: i,
2308
2317
  width: x(r),
2309
- ...a ? { stableHeight: o } : {}
2318
+ ...o ? { stableHeight: a } : {}
2310
2319
  });
2311
2320
  });
2312
2321
  }
@@ -2343,20 +2352,20 @@ class He extends et {
2343
2352
  const ws = l(
2344
2353
  "viewport",
2345
2354
  async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
2346
- let r = !1, i = 0, a = 0, o = 0;
2355
+ let r = !1, i = 0, o = 0, a = 0;
2347
2356
  if (e)
2348
- r = e.isExpanded, i = e.height, a = e.width, o = e.stableHeight;
2357
+ r = e.isExpanded, i = e.height, o = e.width, a = e.stableHeight;
2349
2358
  else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2350
- r = !0, i = window.innerHeight, a = window.innerWidth, o = window.innerHeight;
2359
+ r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
2351
2360
  else {
2352
2361
  const u = await Lt({ timeout: 1e3, postEvent: s });
2353
- r = u.isExpanded, i = u.height, a = u.width, o = u.isStateStable ? i : 0;
2362
+ r = u.isExpanded, i = u.height, o = u.width, a = u.isStateStable ? i : 0;
2354
2363
  }
2355
2364
  const p = new He({
2356
2365
  postEvent: s,
2357
2366
  height: i,
2358
- width: a,
2359
- stableHeight: o,
2367
+ width: o,
2368
+ stableHeight: a,
2360
2369
  isExpanded: r
2361
2370
  });
2362
2371
  return n(p.listen()), p;
@@ -2366,21 +2375,21 @@ function m(e, t) {
2366
2375
  document.documentElement.style.setProperty(e, t);
2367
2376
  }
2368
2377
  function bs(e, t, s) {
2369
- s || (s = (o) => `--tg-${o}-color`);
2378
+ s || (s = (a) => `--tg-${a}-color`);
2370
2379
  const n = s("header"), r = s("bg"), i = () => {
2371
- const { headerColor: o } = e;
2372
- if (Y(o))
2373
- m(n, o);
2380
+ const { headerColor: a } = e;
2381
+ if (Y(a))
2382
+ m(n, a);
2374
2383
  else {
2375
2384
  const { bgColor: p, secondaryBgColor: u } = t;
2376
- o === "bg_color" && p ? m(n, p) : o === "secondary_bg_color" && u && m(n, u);
2385
+ a === "bg_color" && p ? m(n, p) : a === "secondary_bg_color" && u && m(n, u);
2377
2386
  }
2378
2387
  m(r, e.bgColor);
2379
- }, a = [
2388
+ }, o = [
2380
2389
  t.on("change", i),
2381
2390
  e.on("change", i)
2382
2391
  ];
2383
- return i(), () => a.forEach((o) => o());
2392
+ return i(), () => o.forEach((a) => a());
2384
2393
  }
2385
2394
  function ms(e, t) {
2386
2395
  t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
@@ -2397,17 +2406,17 @@ function ys(e, t) {
2397
2406
  s,
2398
2407
  n,
2399
2408
  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 = [
2409
+ ] = ["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
2410
  e.on("change:height", i),
2402
- e.on("change:width", a),
2403
- e.on("change:stableHeight", o)
2411
+ e.on("change:width", o),
2412
+ e.on("change:stableHeight", a)
2404
2413
  ];
2405
- return i(), a(), o(), () => p.forEach((u) => u());
2414
+ return i(), o(), a(), () => p.forEach((u) => u());
2406
2415
  }
2407
2416
  function vs(e = !0) {
2408
2417
  const t = [
2409
2418
  w("reload_iframe", () => {
2410
- R("iframe_will_reload"), window.location.reload();
2419
+ T("iframe_will_reload"), window.location.reload();
2411
2420
  })
2412
2421
  ], s = () => t.forEach((n) => n());
2413
2422
  if (e) {
@@ -2419,13 +2428,13 @@ function vs(e = !0) {
2419
2428
  () => document.head.removeChild(n)
2420
2429
  );
2421
2430
  }
2422
- return R("iframe_ready", { reload_supported: !0 }), s;
2431
+ return T("iframe_ready", { reload_supported: !0 }), s;
2423
2432
  }
2424
2433
  function Es() {
2425
2434
  return typeof window > "u";
2426
2435
  }
2427
2436
  async function Ps() {
2428
- if (gt(window))
2437
+ if (ft(window))
2429
2438
  return !0;
2430
2439
  try {
2431
2440
  return await _({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
@@ -2435,14 +2444,14 @@ async function Ps() {
2435
2444
  }
2436
2445
  function xs(e) {
2437
2446
  const t = typeof e == "string" ? tt(e) : e;
2438
- Nt(t);
2447
+ kt(t);
2439
2448
  function s(r) {
2440
2449
  if (typeof r == "string")
2441
2450
  try {
2442
- const { eventType: i } = _t(r);
2443
- i === "web_app_request_theme" && z("theme_changed", {
2444
- theme_params: JSON.parse(kt(t.themeParams))
2445
- }), i === "web_app_request_viewport" && z("viewport_changed", {
2451
+ const { eventType: i } = dt(r);
2452
+ i === "web_app_request_theme" && j("theme_changed", {
2453
+ theme_params: JSON.parse(qt(t.themeParams))
2454
+ }), i === "web_app_request_viewport" && j("viewport_changed", {
2446
2455
  width: window.innerWidth,
2447
2456
  height: window.innerHeight,
2448
2457
  is_state_stable: !0,
@@ -2451,14 +2460,14 @@ function xs(e) {
2451
2460
  } catch {
2452
2461
  }
2453
2462
  }
2454
- if (wt()) {
2463
+ if (gt()) {
2455
2464
  const r = window.parent.postMessage.bind(window.parent);
2456
2465
  window.parent.postMessage = (i) => {
2457
2466
  s(i), r(i);
2458
2467
  };
2459
2468
  return;
2460
2469
  }
2461
- if (ft(window)) {
2470
+ if (_t(window)) {
2462
2471
  const r = window.external.notify.bind(window.external);
2463
2472
  window.external.notify = (i) => {
2464
2473
  s(i), r(i);
@@ -2474,12 +2483,12 @@ function xs(e) {
2474
2483
  };
2475
2484
  }
2476
2485
  function Ge(e) {
2477
- return e instanceof V;
2486
+ return e instanceof D;
2478
2487
  }
2479
2488
  function Ss(e, t) {
2480
2489
  return Ge(e) && e.type === t;
2481
2490
  }
2482
- function B(e, t) {
2491
+ function $(e, t) {
2483
2492
  let s, n, r;
2484
2493
  return typeof e == "string" ? s = e : (s = e.pathname === void 0 ? t : e.pathname, n = e.params, r = e.id), Object.freeze({
2485
2494
  id: r || (Math.random() * 2 ** 14 | 0).toString(16),
@@ -2488,12 +2497,12 @@ function B(e, t) {
2488
2497
  });
2489
2498
  }
2490
2499
  class je {
2491
- constructor(t, s, n = R) {
2500
+ constructor(t, s, n = T) {
2492
2501
  /**
2493
2502
  * Navigation history.
2494
2503
  */
2495
2504
  c(this, "history");
2496
- c(this, "ee", new T());
2505
+ c(this, "ee", new R());
2497
2506
  /**
2498
2507
  * True, if current navigator is currently attached.
2499
2508
  */
@@ -2517,7 +2526,7 @@ class je {
2517
2526
  Xt,
2518
2527
  "Index should not be zero and higher or equal than history size."
2519
2528
  );
2520
- this.history = t.map((r) => B(r, ""));
2529
+ this.history = t.map((r) => $(r, ""));
2521
2530
  }
2522
2531
  /**
2523
2532
  * Allows this navigator to control the `BackButton` visibility state. It also tracks the
@@ -2592,14 +2601,14 @@ class je {
2592
2601
  * @param item - item to add.
2593
2602
  */
2594
2603
  push(t) {
2595
- this.hasNext && this.history.splice(this.index + 1), this.replaceAndMove(this.index + 1, B(t, this.current.pathname));
2604
+ this.hasNext && this.history.splice(this.index + 1), this.replaceAndMove(this.index + 1, $(t, this.current.pathname));
2596
2605
  }
2597
2606
  /**
2598
2607
  * Replaces the current history item.
2599
2608
  * @param item - item to replace the current item with.
2600
2609
  */
2601
2610
  replace(t) {
2602
- this.replaceAndMove(this.index, B(t, this.current.pathname));
2611
+ this.replaceAndMove(this.index, $(t, this.current.pathname));
2603
2612
  }
2604
2613
  /**
2605
2614
  * Sets history item by the specified index.
@@ -2629,7 +2638,7 @@ class je {
2629
2638
  this.postEvent("web_app_setup_back_button", { is_visible: !!this.index });
2630
2639
  }
2631
2640
  }
2632
- function O({
2641
+ function B({
2633
2642
  params: e,
2634
2643
  ...t
2635
2644
  }) {
@@ -2638,26 +2647,26 @@ function O({
2638
2647
  function A(e, t) {
2639
2648
  return e.startsWith(t) ? e : `${t}${e}`;
2640
2649
  }
2641
- function N(e) {
2650
+ function k(e) {
2642
2651
  return new URL(
2643
2652
  typeof e == "string" ? e : `${e.pathname || ""}${A(e.search || "", "?")}${A(e.hash || "", "#")}`,
2644
2653
  "http://a"
2645
2654
  );
2646
2655
  }
2647
- function D(e) {
2648
- const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = N(e);
2656
+ function N(e) {
2657
+ const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = k(e);
2649
2658
  return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
2650
2659
  }
2651
2660
  function W(e, t, s) {
2652
2661
  let n, r;
2653
- typeof e == "string" ? n = e : (n = D(e), s = e.state, r = e.id);
2654
- const { pathname: i, search: a, hash: o } = new URL(n, `http://a${A(t, "/")}`);
2655
- return { id: r, pathname: i, params: { hash: o, search: a, state: s } };
2662
+ typeof e == "string" ? n = e : (n = N(e), s = e.state, r = e.id);
2663
+ const { pathname: i, search: o, hash: a } = new URL(n, `http://a${A(t, "/")}`);
2664
+ return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
2656
2665
  }
2657
2666
  async function C(e) {
2658
2667
  return e === 0 ? !0 : Promise.race([
2659
2668
  new Promise((t) => {
2660
- const s = j("popstate", () => {
2669
+ const s = G("popstate", () => {
2661
2670
  s(), t(!0);
2662
2671
  });
2663
2672
  window.history.go(e);
@@ -2675,14 +2684,14 @@ async function ze() {
2675
2684
  for (; t; )
2676
2685
  t = await C(-1);
2677
2686
  }
2678
- function Bt(e) {
2679
- return N(e).pathname;
2687
+ function $t(e) {
2688
+ return k(e).pathname;
2680
2689
  }
2681
- const ot = 0, U = 1, H = 2;
2682
- class Ot {
2690
+ const ot = 0, O = 1, U = 2;
2691
+ class Bt {
2683
2692
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2684
2693
  c(this, "navigator");
2685
- c(this, "ee", new T());
2694
+ c(this, "ee", new R());
2686
2695
  c(this, "hashMode");
2687
2696
  c(this, "base");
2688
2697
  /**
@@ -2696,7 +2705,7 @@ class Ot {
2696
2705
  c(this, "onPopState", ({ state: t }) => {
2697
2706
  if (t === null)
2698
2707
  return this.push(this.parsePath(window.location.href));
2699
- t === ot ? window.history.forward() : t === U && this.back(), t === H && this.forward();
2708
+ t === ot ? window.history.forward() : t === O && this.back(), t === U && this.forward();
2700
2709
  });
2701
2710
  /**
2702
2711
  * Underlying navigator change event listener.
@@ -2708,8 +2717,8 @@ class Ot {
2708
2717
  }) => {
2709
2718
  this.attached && await this.syncHistory(), this.ee.emit("change", {
2710
2719
  delta: n,
2711
- from: O(s),
2712
- to: O(t),
2720
+ from: B(s),
2721
+ to: B(t),
2713
2722
  navigator: this
2714
2723
  });
2715
2724
  });
@@ -2722,10 +2731,12 @@ class Ot {
2722
2731
  */
2723
2732
  c(this, "off", this.ee.off.bind(this.ee));
2724
2733
  this.navigator = new je(
2725
- t.map((a) => W(a, "/")),
2734
+ t.map((o) => W(o, "/")),
2726
2735
  s,
2727
2736
  n
2728
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Bt(i || "");
2737
+ ), this.navigator.on("change", (o) => {
2738
+ this.onNavigatorChange(o);
2739
+ }), this.hashMode = r, this.base = $t(i || "");
2729
2740
  }
2730
2741
  /**
2731
2742
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2809,7 +2820,7 @@ class Ot {
2809
2820
  * Navigation history.
2810
2821
  */
2811
2822
  get history() {
2812
- return this.navigator.history.map(O);
2823
+ return this.navigator.history.map(B);
2813
2824
  }
2814
2825
  /**
2815
2826
  * Path, including pathname, search and hash.
@@ -2823,7 +2834,7 @@ class Ot {
2823
2834
  * "/pathname?search#hash"
2824
2835
  */
2825
2836
  get path() {
2826
- return D(this);
2837
+ return N(this);
2827
2838
  }
2828
2839
  /**
2829
2840
  * Current pathname. Always starts with the slash.
@@ -2852,8 +2863,8 @@ class Ot {
2852
2863
  * // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
2853
2864
  */
2854
2865
  parsePath(t) {
2855
- let s = N(t);
2856
- return this.hashMode && (s = N(s.hash.slice(1))), {
2866
+ let s = k(t);
2867
+ return this.hashMode && (s = k(s.hash.slice(1))), {
2857
2868
  pathname: s.pathname,
2858
2869
  search: s.search,
2859
2870
  hash: s.hash
@@ -2873,7 +2884,7 @@ class Ot {
2873
2884
  * @param value - path presented as string or URLLike.
2874
2885
  */
2875
2886
  renderPath(t) {
2876
- const s = (this.base.length === 1 ? "" : this.base) + A(D(t), "/");
2887
+ const s = (this.base.length === 1 ? "" : this.base) + A(N(t), "/");
2877
2888
  return this.hashMode ? A(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2878
2889
  }
2879
2890
  /**
@@ -2882,7 +2893,7 @@ class Ot {
2882
2893
  async syncHistory() {
2883
2894
  window.removeEventListener("popstate", this.onPopState);
2884
2895
  const { state: t } = this, s = this.renderPath(this);
2885
- await ze(), this.hasPrev && this.hasNext ? (window.history.replaceState(U, ""), window.history.pushState(t, "", s), window.history.pushState(H, ""), await C(-1)) : this.hasPrev ? (window.history.replaceState(U, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(H, ""), await C(-1)) : (window.history.replaceState(ot, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2896
+ 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);
2886
2897
  }
2887
2898
  /**
2888
2899
  * Current query parameters.
@@ -2903,10 +2914,10 @@ class Ot {
2903
2914
  function Fe(e) {
2904
2915
  e || (e = {});
2905
2916
  const { href: t, hash: s } = window.location;
2906
- let n = D(
2917
+ let n = N(
2907
2918
  e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
2908
2919
  );
2909
- const r = e.base ? Bt(e.base) : void 0;
2920
+ const r = e.base ? $t(e.base) : void 0;
2910
2921
  if (r) {
2911
2922
  if (!n.startsWith(r))
2912
2923
  throw f(
@@ -2915,26 +2926,30 @@ function Fe(e) {
2915
2926
  );
2916
2927
  n = n.slice(r.length);
2917
2928
  }
2918
- return new Ot([n], 0, e);
2929
+ return new Bt([n], 0, e);
2919
2930
  }
2920
2931
  function Cs(e) {
2921
2932
  const t = e.match(/#(.+)/);
2922
2933
  return t ? t[1] : null;
2923
2934
  }
2924
2935
  function Je(e, t) {
2925
- if (Dt()) {
2936
+ if (Nt()) {
2926
2937
  const s = sessionStorage.getItem(e);
2927
2938
  if (s)
2928
2939
  try {
2929
2940
  const { index: n, history: r } = JSON.parse(s);
2930
- return new Ot(r, n, t);
2941
+ return new Bt(
2942
+ r,
2943
+ n,
2944
+ t
2945
+ );
2931
2946
  } catch (n) {
2932
2947
  console.error("Unable to restore hash navigator state.", n);
2933
2948
  }
2934
2949
  }
2935
2950
  return Fe(t);
2936
2951
  }
2937
- function Ts(e, t) {
2952
+ function Rs(e, t) {
2938
2953
  const s = Je(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2939
2954
  index: s.index,
2940
2955
  history: s.history
@@ -2945,7 +2960,7 @@ export {
2945
2960
  le as BackButton,
2946
2961
  je as BasicNavigator,
2947
2962
  Pe as BiometryManager,
2948
- Ot as BrowserNavigator,
2963
+ Bt as BrowserNavigator,
2949
2964
  Se as ClosingBehavior,
2950
2965
  Ae as CloudStorage,
2951
2966
  te as ERR_INVALID_PATH_BASE,
@@ -2955,38 +2970,38 @@ export {
2955
2970
  Kt as ERR_NAVIGATION_HISTORY_EMPTY,
2956
2971
  Xt as ERR_NAVIGATION_INDEX_INVALID,
2957
2972
  Ze as ERR_NAVIGATION_ITEM_INVALID,
2958
- pt as ERR_PARSE,
2973
+ ht as ERR_PARSE,
2959
2974
  Ke as ERR_SSR_INIT,
2960
2975
  Yt as ERR_TIMED_OUT,
2961
2976
  Zt as ERR_UNEXPECTED_TYPE,
2962
2977
  Jt as ERR_UNKNOWN_ENV,
2963
- T as EventEmitter,
2978
+ R as EventEmitter,
2964
2979
  Ie as HapticFeedback,
2965
2980
  qe as InitData,
2966
2981
  ke as Invoice,
2967
2982
  Ne as MainButton,
2968
2983
  Me as MiniApp,
2969
- Le as Popup,
2984
+ $e as Popup,
2970
2985
  Be as QRScanner,
2971
- V as SDKError,
2972
- Oe as SettingsButton,
2973
- We as ThemeParams,
2986
+ D as SDKError,
2987
+ We as SettingsButton,
2988
+ Oe as ThemeParams,
2974
2989
  Ue as Utils,
2975
2990
  He as Viewport,
2976
- Re as array,
2991
+ Te as array,
2977
2992
  bs as bindMiniAppCSSVars,
2978
2993
  ms as bindThemeParamsCSSVars,
2979
2994
  ys as bindViewportCSSVars,
2980
2995
  b as boolean,
2981
- mt as captureSameReq,
2982
- F as classNames,
2996
+ bt as captureSameReq,
2997
+ z as classNames,
2983
2998
  ce as compareVersions,
2984
2999
  Fe as createBrowserNavigatorFromLocation,
2985
3000
  pe as createPostEvent,
2986
- N as createSafeURL,
2987
- xt as date,
3001
+ k as createSafeURL,
3002
+ Pt as date,
2988
3003
  Cs as getHash,
2989
- Bt as getPathname,
3004
+ $t as getPathname,
2990
3005
  es as initBackButton,
2991
3006
  ss as initBiometryManager,
2992
3007
  ns as initClosingBehavior,
@@ -2996,7 +3011,7 @@ export {
2996
3011
  cs as initInvoice,
2997
3012
  hs as initMainButton,
2998
3013
  ps as initMiniApp,
2999
- Ts as initNavigator,
3014
+ Rs as initNavigator,
3000
3015
  us as initPopup,
3001
3016
  ls as initQRScanner,
3002
3017
  ds as initSettingsButton,
@@ -3005,9 +3020,9 @@ export {
3005
3020
  ws as initViewport,
3006
3021
  vs as initWeb,
3007
3022
  S as invokeCustomMethod,
3008
- Et as isColorDark,
3009
- wt as isIframe,
3010
- Dt as isPageReload,
3023
+ vt as isColorDark,
3024
+ gt as isIframe,
3025
+ Nt as isPageReload,
3011
3026
  Y as isRGB,
3012
3027
  ee as isRGBShort,
3013
3028
  Ge as isSDKError,
@@ -3022,17 +3037,17 @@ export {
3022
3037
  w as on,
3023
3038
  as as parseInitData,
3024
3039
  tt as parseLaunchParams,
3025
- $t as parseThemeParams,
3026
- R as postEvent,
3040
+ Mt as parseThemeParams,
3041
+ T as postEvent,
3027
3042
  _ as request,
3028
3043
  xe as requestBiometryInfo,
3029
3044
  fs as requestThemeParams,
3030
3045
  Lt as requestViewport,
3031
3046
  ye as retrieveLaunchParams,
3032
- dt as rgb,
3047
+ lt as rgb,
3033
3048
  X as searchParams,
3034
3049
  me as serializeLaunchParams,
3035
- kt as serializeThemeParams,
3050
+ qt as serializeThemeParams,
3036
3051
  m as setCSSVar,
3037
3052
  Ye as setDebug,
3038
3053
  Xe as setTargetOrigin,
@@ -3040,9 +3055,9 @@ export {
3040
3055
  Ht as subscribe,
3041
3056
  v as supports,
3042
3057
  he as targetOrigin,
3043
- lt as toRGB,
3058
+ ut as toRGB,
3044
3059
  ct as unsubscribe,
3045
- D as urlToPath,
3046
- vt as withTimeout
3060
+ N as urlToPath,
3061
+ yt as withTimeout
3047
3062
  };
3048
3063
  //# sourceMappingURL=index.js.map