@tma.js/sdk-solid 2.1.4 → 2.1.6

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,20 +1,20 @@
1
- import { createComponent as gt, mergeProps as at, createContext as Qt, useContext as Yt, createEffect as ct, onCleanup as ht, createResource as Zt, createMemo as pt, from as Xt } from "solid-js";
2
- var te = Object.defineProperty, ee = (e, t, s) => t in e ? te(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (ee(e, typeof t != "symbol" ? t + "" : t, s), s);
3
- function ft(e, t) {
1
+ import { createComponent as bt, mergeProps as ut, createContext as ee, useContext as se, createEffect as dt, onCleanup as lt, createResource as ne, createMemo as _t, from as re } from "solid-js";
2
+ var ie = Object.defineProperty, oe = (e, t, s) => t in e ? ie(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (oe(e, typeof t != "symbol" ? t + "" : t, s), s);
3
+ function vt(e, t) {
4
4
  let s;
5
5
  const n = () => {
6
6
  s !== void 0 && t && t(s), s = void 0;
7
7
  };
8
8
  return [() => s === void 0 ? s = e(n) : s, n];
9
9
  }
10
- function mt(e) {
11
- const t = U(), { count: s } = t;
12
- t.unsubscribe(e), s && !t.count && Pe();
10
+ function yt(e) {
11
+ const t = H(), { count: s } = t;
12
+ t.unsubscribe(e), s && !t.count && Se();
13
13
  }
14
- function se(e) {
15
- return U().subscribe(e), () => mt(e);
14
+ function ae(e) {
15
+ return H().subscribe(e), () => yt(e);
16
16
  }
17
- class ne {
17
+ class ce {
18
18
  constructor(t, s = {}) {
19
19
  this.scope = t, this.options = s;
20
20
  }
@@ -54,21 +54,21 @@ class ne {
54
54
  this.print("log", ...t);
55
55
  }
56
56
  }
57
- const Z = new ne("SDK", {
57
+ const X = new ce("SDK", {
58
58
  bgColor: "forestgreen",
59
59
  textColor: "white"
60
60
  });
61
61
  let F = !1;
62
- const ut = ({ name: e, payload: t }) => {
63
- Z.log("Event received:", t ? { name: e, payload: t } : { name: e });
62
+ const gt = ({ name: e, payload: t }) => {
63
+ X.log("Event received:", t ? { name: e, payload: t } : { name: e });
64
64
  };
65
- function re(e) {
66
- F !== e && (F = e, e ? se(ut) : mt(ut));
65
+ function he(e) {
66
+ F !== e && (F = e, e ? ae(gt) : yt(gt));
67
67
  }
68
- function ie(...e) {
69
- F && Z.log(...e);
68
+ function pe(...e) {
69
+ F && X.log(...e);
70
70
  }
71
- class O {
71
+ class k {
72
72
  constructor() {
73
73
  c(this, "listeners", /* @__PURE__ */ new Map()), c(this, "listenersCount", 0), c(this, "subscribeListeners", []);
74
74
  }
@@ -141,7 +141,7 @@ class O {
141
141
  function Q(e, t, s) {
142
142
  return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
143
143
  }
144
- function bt(...e) {
144
+ function tt(...e) {
145
145
  let t = !1;
146
146
  const s = [...e];
147
147
  return [
@@ -157,12 +157,12 @@ class $ extends Error {
157
157
  super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, $.prototype);
158
158
  }
159
159
  }
160
- function b(e, t, s) {
160
+ function m(e, t, s) {
161
161
  return new $(e, t, s);
162
162
  }
163
- const oe = "ERR_METHOD_UNSUPPORTED", ae = "ERR_METHOD_PARAMETER_UNSUPPORTED", ce = "ERR_UNKNOWN_ENV", he = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", pe = "ERR_TIMED_OUT", ue = "ERR_UNEXPECTED_TYPE", wt = "ERR_PARSE", le = "ERR_NAVIGATION_LIST_EMPTY", de = "ERR_NAVIGATION_CURSOR_INVALID", zs = "ERR_NAVIGATION_ITEM_INVALID", Js = "ERR_SSR_INIT", _e = "ERR_INVALID_PATH_BASE";
163
+ const ue = "ERR_METHOD_UNSUPPORTED", de = "ERR_METHOD_PARAMETER_UNSUPPORTED", le = "ERR_UNKNOWN_ENV", _e = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", ge = "ERR_TIMED_OUT", fe = "ERR_UNEXPECTED_TYPE", Et = "ERR_PARSE", we = "ERR_NAVIGATION_LIST_EMPTY", me = "ERR_NAVIGATION_CURSOR_INVALID", zs = "ERR_NAVIGATION_ITEM_INVALID", Js = "ERR_SSR_INIT", be = "ERR_INVALID_PATH_BASE";
164
164
  function S() {
165
- return b(ue, "Value has unexpected type");
165
+ return m(fe, "Value has unexpected type");
166
166
  }
167
167
  class L {
168
168
  constructor(t, s, n) {
@@ -179,8 +179,8 @@ class L {
179
179
  try {
180
180
  return this.parser(t);
181
181
  } catch (s) {
182
- throw b(
183
- wt,
182
+ throw m(
183
+ Et,
184
184
  `Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
185
185
  s
186
186
  );
@@ -190,10 +190,10 @@ class L {
190
190
  return this.isOptional = !0, this;
191
191
  }
192
192
  }
193
- function R(e, t) {
193
+ function T(e, t) {
194
194
  return () => new L(e, !1, t);
195
195
  }
196
- const y = R((e) => {
196
+ const y = T((e) => {
197
197
  if (typeof e == "boolean")
198
198
  return e;
199
199
  const t = String(e);
@@ -203,7 +203,7 @@ const y = R((e) => {
203
203
  return !1;
204
204
  throw S();
205
205
  }, "boolean");
206
- function vt(e, t) {
206
+ function Pt(e, t) {
207
207
  const s = {};
208
208
  for (const n in e) {
209
209
  const r = e[n];
@@ -220,12 +220,12 @@ function vt(e, t) {
220
220
  const a = o(t(i));
221
221
  a !== void 0 && (s[n] = a);
222
222
  } catch (a) {
223
- throw b(wt, `Unable to parse field "${n}"`, a);
223
+ throw m(Et, `Unable to parse field "${n}"`, a);
224
224
  }
225
225
  }
226
226
  return s;
227
227
  }
228
- function X(e) {
228
+ function et(e) {
229
229
  let t = e;
230
230
  if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
231
231
  throw S();
@@ -233,11 +233,11 @@ function X(e) {
233
233
  }
234
234
  function f(e, t) {
235
235
  return new L((s) => {
236
- const n = X(s);
237
- return vt(e, (r) => n[r]);
236
+ const n = et(s);
237
+ return Pt(e, (r) => n[r]);
238
238
  }, !1, t);
239
239
  }
240
- const P = R((e) => {
240
+ const P = T((e) => {
241
241
  if (typeof e == "number")
242
242
  return e;
243
243
  if (typeof e == "string") {
@@ -247,17 +247,17 @@ const P = R((e) => {
247
247
  }
248
248
  throw S();
249
249
  }, "number");
250
- function tt(e) {
250
+ function st(e) {
251
251
  return /^#[\da-f]{6}$/i.test(e);
252
252
  }
253
- function ge(e) {
253
+ function ve(e) {
254
254
  return /^#[\da-f]{3}$/i.test(e);
255
255
  }
256
- function yt(e) {
256
+ function xt(e) {
257
257
  const t = e.replace(/\s/g, "").toLowerCase();
258
- if (tt(t))
258
+ if (st(t))
259
259
  return t;
260
- if (ge(t)) {
260
+ if (ve(t)) {
261
261
  let n = "#";
262
262
  for (let r = 0; r < 3; r += 1)
263
263
  n += t[1 + r].repeat(2);
@@ -271,30 +271,30 @@ function yt(e) {
271
271
  return n + (i.length === 1 ? "0" : "") + i;
272
272
  }, "#");
273
273
  }
274
- const p = R((e) => {
274
+ const p = T((e) => {
275
275
  if (typeof e == "string" || typeof e == "number")
276
276
  return e.toString();
277
277
  throw S();
278
- }, "string"), Et = R((e) => yt(p().parse(e)), "rgb");
279
- function fe(e) {
278
+ }, "string"), Ct = T((e) => xt(p().parse(e)), "rgb");
279
+ function St(e) {
280
280
  return f({
281
281
  eventType: p(),
282
282
  eventData: (t) => t
283
283
  }).parse(e);
284
284
  }
285
- function me() {
285
+ function ye() {
286
286
  ["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
287
287
  delete window[e];
288
288
  });
289
289
  }
290
- function be(e, t) {
290
+ function Y(e, t) {
291
291
  window.dispatchEvent(new MessageEvent("message", {
292
292
  data: JSON.stringify({ eventType: e, eventData: t }),
293
293
  // We specify window.parent to imitate the case, the parent iframe sent us this event.
294
294
  source: window.parent
295
295
  }));
296
296
  }
297
- function we() {
297
+ function Ee() {
298
298
  [
299
299
  ["TelegramGameProxy_receiveEvent"],
300
300
  // Windows Phone.
@@ -306,14 +306,14 @@ function we() {
306
306
  let t = window;
307
307
  e.forEach((s, n, r) => {
308
308
  if (n === r.length - 1) {
309
- t[s] = be;
309
+ t[s] = Y;
310
310
  return;
311
311
  }
312
312
  s in t || (t[s] = {}), t = t[s];
313
313
  });
314
314
  });
315
315
  }
316
- const ve = {
316
+ const Pe = {
317
317
  clipboard_text_received: f({
318
318
  req_id: p(),
319
319
  data: (e) => e === null ? e : p().optional().parse(e)
@@ -335,8 +335,8 @@ const ve = {
335
335
  qr_text_received: f({ data: p().optional() }),
336
336
  theme_changed: f({
337
337
  theme_params: (e) => {
338
- const t = Et().optional();
339
- return Object.entries(X(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
338
+ const t = Ct().optional();
339
+ return Object.entries(et(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
340
340
  }
341
341
  }),
342
342
  viewport_changed: f({
@@ -347,14 +347,14 @@ const ve = {
347
347
  }),
348
348
  write_access_requested: f({ status: p() })
349
349
  };
350
- function ye() {
351
- const e = new O(), t = new O();
350
+ function xe() {
351
+ const e = new k(), t = new k();
352
352
  t.subscribe((n) => {
353
353
  e.emit("event", { name: n.event, payload: n.args[0] });
354
- }), we();
355
- const [, s] = bt(
354
+ }), Ee();
355
+ const [, s] = tt(
356
356
  // Don't forget to remove created handlers.
357
- me,
357
+ ye,
358
358
  // Add "resize" event listener to make sure, we always have fresh viewport information.
359
359
  // Desktop version of Telegram is sometimes not sending the viewport_changed
360
360
  // event. For example, when the MainButton is shown. That's why we should
@@ -375,16 +375,16 @@ function ye() {
375
375
  return;
376
376
  let r;
377
377
  try {
378
- r = fe(n.data);
378
+ r = St(n.data);
379
379
  } catch {
380
380
  return;
381
381
  }
382
- const { eventType: i, eventData: o } = r, a = ve[i];
382
+ const { eventType: i, eventData: o } = r, a = Pe[i];
383
383
  try {
384
384
  const h = a ? a.parse(o) : o;
385
385
  t.emit(...h ? [i, h] : [i]);
386
386
  } catch (h) {
387
- Z.error(
387
+ X.error(
388
388
  `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`,
389
389
  r,
390
390
  h
@@ -409,9 +409,9 @@ function ye() {
409
409
  }
410
410
  }, s];
411
411
  }
412
- const [Ee, Pe] = ft(
412
+ const [Ce, Se] = vt(
413
413
  (e) => {
414
- const [t, s] = ye(), n = t.off.bind(t);
414
+ const [t, s] = xe(), n = t.off.bind(t);
415
415
  return t.off = (r, i) => {
416
416
  const { count: o } = t;
417
417
  n(r, i), o && !t.count && e();
@@ -419,19 +419,19 @@ const [Ee, Pe] = ft(
419
419
  },
420
420
  ([, e]) => e()
421
421
  );
422
- function U() {
423
- return Ee()[0];
422
+ function H() {
423
+ return Ce()[0];
424
424
  }
425
- function H(e, t) {
426
- U().off(e, t);
425
+ function U(e, t) {
426
+ H().off(e, t);
427
427
  }
428
428
  function v(e, t, s) {
429
- return U().on(e, t, s);
429
+ return H().on(e, t, s);
430
430
  }
431
- function D(e) {
431
+ function N(e) {
432
432
  return typeof e == "object" && e !== null && !Array.isArray(e);
433
433
  }
434
- function xe(e, t) {
434
+ function Te(e, t) {
435
435
  const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
436
436
  for (let i = 0; i < r; i += 1) {
437
437
  const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
@@ -440,15 +440,15 @@ function xe(e, t) {
440
440
  }
441
441
  return 0;
442
442
  }
443
- function w(e, t) {
444
- return xe(e, t) <= 0;
443
+ function b(e, t) {
444
+ return Te(e, t) <= 0;
445
445
  }
446
446
  function x(e, t, s) {
447
447
  if (typeof s == "string") {
448
448
  if (e === "web_app_open_link" && t === "try_instant_view")
449
- return w("6.4", s);
449
+ return b("6.4", s);
450
450
  if (e === "web_app_set_header_color" && t === "color")
451
- return w("6.9", s);
451
+ return b("6.9", s);
452
452
  }
453
453
  switch (e) {
454
454
  case "web_app_open_tg_link":
@@ -457,27 +457,27 @@ function x(e, t, s) {
457
457
  case "web_app_set_background_color":
458
458
  case "web_app_set_header_color":
459
459
  case "web_app_trigger_haptic_feedback":
460
- return w("6.1", t);
460
+ return b("6.1", t);
461
461
  case "web_app_open_popup":
462
- return w("6.2", t);
462
+ return b("6.2", t);
463
463
  case "web_app_close_scan_qr_popup":
464
464
  case "web_app_open_scan_qr_popup":
465
465
  case "web_app_read_text_from_clipboard":
466
- return w("6.4", t);
466
+ return b("6.4", t);
467
467
  case "web_app_switch_inline_query":
468
- return w("6.7", t);
468
+ return b("6.7", t);
469
469
  case "web_app_invoke_custom_method":
470
470
  case "web_app_request_write_access":
471
471
  case "web_app_request_phone":
472
- return w("6.9", t);
472
+ return b("6.9", t);
473
473
  case "web_app_setup_settings_button":
474
- return w("6.10", t);
474
+ return b("6.10", t);
475
475
  case "web_app_biometry_get_info":
476
476
  case "web_app_biometry_open_settings":
477
477
  case "web_app_biometry_request_access":
478
478
  case "web_app_biometry_request_auth":
479
479
  case "web_app_biometry_update_token":
480
- return w("7.2", t);
480
+ return b("7.2", t);
481
481
  default:
482
482
  return [
483
483
  "iframe_ready",
@@ -494,102 +494,98 @@ function x(e, t, s) {
494
494
  ].includes(e);
495
495
  }
496
496
  }
497
- function Ce(e) {
498
- return "external" in e && D(e.external) && "notify" in e.external && typeof e.external.notify == "function";
497
+ function Tt(e) {
498
+ return "external" in e && N(e.external) && "notify" in e.external && typeof e.external.notify == "function";
499
499
  }
500
- function Pt(e) {
501
- return "TelegramWebviewProxy" in e && D(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
500
+ function Rt(e) {
501
+ return "TelegramWebviewProxy" in e && N(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
502
502
  }
503
- function xt() {
503
+ function nt() {
504
504
  try {
505
505
  return window.self !== window.top;
506
506
  } catch {
507
507
  return !0;
508
508
  }
509
509
  }
510
- let Ct = "https://web.telegram.org";
510
+ let At = "https://web.telegram.org";
511
511
  function Fs(e) {
512
- Ct = e;
512
+ At = e;
513
513
  }
514
- function Se() {
515
- return Ct;
514
+ function Re() {
515
+ return At;
516
516
  }
517
- function k(e, t, s) {
517
+ function q(e, t, s) {
518
518
  let n = {}, r;
519
519
  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);
520
- const { targetOrigin: i = Se() } = n;
521
- if (ie("Posting event:", r ? { event: e, data: r } : { event: e }), xt()) {
520
+ const { targetOrigin: i = Re() } = n;
521
+ if (pe("Posting event:", r ? { event: e, data: r } : { event: e }), nt()) {
522
522
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
523
523
  return;
524
524
  }
525
- if (Ce(window)) {
525
+ if (Tt(window)) {
526
526
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
527
527
  return;
528
528
  }
529
- if (Pt(window)) {
529
+ if (Rt(window)) {
530
530
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
531
531
  return;
532
532
  }
533
- throw b(
534
- ce,
533
+ throw m(
534
+ le,
535
535
  "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."
536
536
  );
537
537
  }
538
- function Re(e) {
538
+ function Ae(e) {
539
539
  return (t, s) => {
540
540
  if (!x(t, e))
541
- throw b(oe, `Method "${t}" is unsupported in Mini Apps version ${e}`);
542
- if (D(s)) {
541
+ throw m(ue, `Method "${t}" is unsupported in Mini Apps version ${e}`);
542
+ if (N(s)) {
543
543
  let n;
544
544
  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 && !x(t, n, e))
545
- throw b(
546
- ae,
545
+ throw m(
546
+ de,
547
547
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
548
548
  );
549
549
  }
550
- return k(t, s);
550
+ return q(t, s);
551
551
  };
552
552
  }
553
- function St(e) {
553
+ function It(e) {
554
554
  return ({ req_id: t }) => t === e;
555
555
  }
556
- function Rt(e) {
557
- return b(pe, `Timeout reached: ${e}ms`);
556
+ function kt(e) {
557
+ return m(ge, `Timeout reached: ${e}ms`);
558
558
  }
559
- function Tt(e, t) {
559
+ function qt(e, t) {
560
560
  return Promise.race([
561
561
  typeof e == "function" ? e() : e,
562
562
  new Promise((s, n) => {
563
563
  setTimeout(() => {
564
- n(Rt(t));
564
+ n(kt(t));
565
565
  }, t);
566
566
  })
567
567
  ]);
568
568
  }
569
- async function m(e) {
569
+ async function w(e) {
570
570
  let t;
571
- const s = new Promise((u) => {
572
- t = u;
573
- }), {
574
- method: n,
575
- event: r,
576
- capture: i,
577
- postEvent: o = k,
578
- timeout: a
579
- } = e, h = (Array.isArray(r) ? r : [r]).map(
580
- (u) => v(u, (l) => (!i || i(l)) && t(l))
571
+ const s = new Promise((a) => {
572
+ t = a;
573
+ }), { event: n, capture: r, timeout: i } = e, [, o] = tt(
574
+ ...(Array.isArray(n) ? n : [n]).map(
575
+ (a) => v(a, (h) => (!r || r(h)) && t(h))
576
+ )
581
577
  );
582
578
  try {
583
- return o(n, e.params), await (a ? Tt(s, a) : s);
579
+ return (e.postEvent || q)(e.method, e.params), await (i ? qt(s, i) : s);
584
580
  } finally {
585
- h.forEach((u) => u());
581
+ o();
586
582
  }
587
583
  }
588
584
  async function A(e, t, s, n = {}) {
589
585
  const {
590
586
  result: r,
591
587
  error: i
592
- } = await m({
588
+ } = await w({
593
589
  ...n,
594
590
  method: "web_app_invoke_custom_method",
595
591
  event: "custom_method_invoked",
@@ -598,30 +594,30 @@ async function A(e, t, s, n = {}) {
598
594
  params: t,
599
595
  req_id: s
600
596
  },
601
- capture: St(s)
597
+ capture: It(s)
602
598
  });
603
599
  if (i)
604
- throw b(he, i);
600
+ throw m(_e, i);
605
601
  return r;
606
602
  }
607
- function Y(...e) {
603
+ function Z(...e) {
608
604
  return e.map((t) => {
609
605
  if (typeof t == "string")
610
606
  return t;
611
- if (D(t))
612
- return Y(Object.entries(t).map((s) => s[1] && s[0]));
607
+ if (N(t))
608
+ return Z(Object.entries(t).map((s) => s[1] && s[0]));
613
609
  if (Array.isArray(t))
614
- return Y(...t);
610
+ return Z(...t);
615
611
  }).filter(Boolean).join(" ");
616
612
  }
617
613
  function Qs(...e) {
618
- return e.reduce((t, s) => (D(s) && Object.entries(s).forEach(([n, r]) => {
619
- const i = Y(t[n], r);
614
+ return e.reduce((t, s) => (N(s) && Object.entries(s).forEach(([n, r]) => {
615
+ const i = Z(t[n], r);
620
616
  i.length && (t[n] = i);
621
617
  }), t), {});
622
618
  }
623
- function At(e) {
624
- const t = yt(e);
619
+ function Ot(e) {
620
+ const t = xt(e);
625
621
  return Math.sqrt(
626
622
  [0.299, 0.587, 0.114].reduce((s, n, r) => {
627
623
  const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
@@ -629,9 +625,9 @@ function At(e) {
629
625
  }, 0)
630
626
  ) < 120;
631
627
  }
632
- class Te {
628
+ class Ie {
633
629
  constructor(t) {
634
- c(this, "ee", new O()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
630
+ c(this, "ee", new k()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
635
631
  }
636
632
  /**
637
633
  * Clones current state and returns its copy.
@@ -650,25 +646,25 @@ class Te {
650
646
  return this.state[t];
651
647
  }
652
648
  }
653
- class et {
649
+ class rt {
654
650
  constructor(t) {
655
- c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new Te(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);
651
+ c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new Ie(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);
656
652
  }
657
653
  }
658
- function It(e, t) {
654
+ function Nt(e, t) {
659
655
  return (s) => x(t[s], e);
660
656
  }
661
- class st extends et {
657
+ class it extends rt {
662
658
  constructor(t, s, n) {
663
- super(t), c(this, "supports"), this.supports = It(s, n);
659
+ super(t), c(this, "supports"), this.supports = Nt(s, n);
664
660
  }
665
661
  }
666
- class Ae extends st {
662
+ class ke extends it {
667
663
  constructor(t, s, n) {
668
664
  super({ isVisible: t }, s, {
669
665
  show: "web_app_setup_back_button",
670
666
  hide: "web_app_setup_back_button"
671
- }), c(this, "on", (r, i) => r === "click" ? v("back_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? H("back_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
667
+ }), c(this, "on", (r, i) => r === "click" ? v("back_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? U("back_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
672
668
  }
673
669
  set isVisible(t) {
674
670
  this.set("isVisible", t), this.postEvent("web_app_setup_back_button", { is_visible: t });
@@ -692,19 +688,19 @@ class Ae extends st {
692
688
  this.isVisible = !0;
693
689
  }
694
690
  }
695
- const Ot = R((e) => e instanceof Date ? e : new Date(P().parse(e) * 1e3), "Date");
696
- function nt(e, t) {
691
+ const Dt = T((e) => e instanceof Date ? e : new Date(P().parse(e) * 1e3), "Date");
692
+ function ot(e, t) {
697
693
  return new L((s) => {
698
694
  if (typeof s != "string" && !(s instanceof URLSearchParams))
699
695
  throw S();
700
696
  const n = typeof s == "string" ? new URLSearchParams(s) : s;
701
- return vt(e, (r) => {
697
+ return Pt(e, (r) => {
702
698
  const i = n.get(r);
703
699
  return i === null ? void 0 : i;
704
700
  });
705
701
  }, !1, t);
706
702
  }
707
- const Ie = f({
703
+ const qe = f({
708
704
  id: P(),
709
705
  type: p(),
710
706
  title: p(),
@@ -713,7 +709,7 @@ const Ie = f({
713
709
  from: "photo_url"
714
710
  },
715
711
  username: p().optional()
716
- }, "Chat").optional(), lt = f({
712
+ }, "Chat").optional(), ft = f({
717
713
  addedToAttachmentMenu: {
718
714
  type: y().optional(),
719
715
  from: "added_to_attachment_menu"
@@ -749,17 +745,17 @@ const Ie = f({
749
745
  },
750
746
  username: p().optional()
751
747
  }, "User").optional();
752
- function kt() {
753
- return nt({
748
+ function Vt() {
749
+ return ot({
754
750
  authDate: {
755
- type: Ot(),
751
+ type: Dt(),
756
752
  from: "auth_date"
757
753
  },
758
754
  canSendAfter: {
759
755
  type: P().optional(),
760
756
  from: "can_send_after"
761
757
  },
762
- chat: Ie,
758
+ chat: qe,
763
759
  chatInstance: {
764
760
  type: p().optional(),
765
761
  from: "chat_instance"
@@ -773,35 +769,35 @@ function kt() {
773
769
  type: p().optional(),
774
770
  from: "query_id"
775
771
  },
776
- receiver: lt,
772
+ receiver: ft,
777
773
  startParam: {
778
774
  type: p().optional(),
779
775
  from: "start_param"
780
776
  },
781
- user: lt
777
+ user: ft
782
778
  }, "InitData");
783
779
  }
784
780
  function Oe(e) {
785
781
  return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
786
782
  }
787
- function ke(e) {
783
+ function Ne(e) {
788
784
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
789
785
  }
790
- const qt = R(
786
+ const Mt = T(
791
787
  (e) => {
792
- const t = Et().optional();
793
- return Object.entries(X(e)).reduce((s, [n, r]) => (s[Oe(n)] = t.parse(r), s), {});
788
+ const t = Ct().optional();
789
+ return Object.entries(et(e)).reduce((s, [n, r]) => (s[Oe(n)] = t.parse(r), s), {});
794
790
  },
795
791
  "ThemeParams"
796
792
  );
797
- function Dt(e) {
798
- return nt({
793
+ function at(e) {
794
+ return ot({
799
795
  botInline: {
800
796
  type: y().optional(),
801
797
  from: "tgWebAppBotInline"
802
798
  },
803
799
  initData: {
804
- type: kt().optional(),
800
+ type: Vt().optional(),
805
801
  from: "tgWebAppData"
806
802
  },
807
803
  initDataRaw: {
@@ -821,7 +817,7 @@ function Dt(e) {
821
817
  from: "tgWebAppStartParam"
822
818
  },
823
819
  themeParams: {
824
- type: qt(),
820
+ type: Mt(),
825
821
  from: "tgWebAppThemeParams"
826
822
  },
827
823
  version: {
@@ -830,47 +826,47 @@ function Dt(e) {
830
826
  }
831
827
  }).parse(e);
832
828
  }
833
- function Nt(e) {
834
- return Dt(
829
+ function Bt(e) {
830
+ return at(
835
831
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
836
832
  );
837
833
  }
838
- function qe() {
839
- return Nt(window.location.href);
834
+ function De() {
835
+ return Bt(window.location.href);
840
836
  }
841
- function Vt() {
837
+ function $t() {
842
838
  return performance.getEntriesByType("navigation")[0];
843
839
  }
844
- function De() {
845
- const e = Vt();
840
+ function Ve() {
841
+ const e = $t();
846
842
  if (!e)
847
843
  throw new Error("Unable to get first navigation entry.");
848
- return Nt(e.name);
844
+ return Bt(e.name);
849
845
  }
850
- function Mt(e) {
846
+ function Lt(e) {
851
847
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
852
848
  }
853
- function Bt(e, t) {
854
- sessionStorage.setItem(Mt(e), JSON.stringify(t));
849
+ function Ht(e, t) {
850
+ sessionStorage.setItem(Lt(e), JSON.stringify(t));
855
851
  }
856
- function $t(e) {
857
- const t = sessionStorage.getItem(Mt(e));
852
+ function Ut(e) {
853
+ const t = sessionStorage.getItem(Lt(e));
858
854
  try {
859
855
  return t ? JSON.parse(t) : void 0;
860
856
  } catch {
861
857
  }
862
858
  }
863
- function Ne() {
864
- return Dt($t("launchParams") || "");
859
+ function Me() {
860
+ return at(Ut("launchParams") || "");
865
861
  }
866
- function Ve(e) {
862
+ function Wt(e) {
867
863
  return JSON.stringify(
868
864
  Object.fromEntries(
869
- Object.entries(e).map(([t, s]) => [ke(t), s])
865
+ Object.entries(e).map(([t, s]) => [Ne(t), s])
870
866
  )
871
867
  );
872
868
  }
873
- function Me(e) {
869
+ function Be(e) {
874
870
  const {
875
871
  initDataRaw: t,
876
872
  themeParams: s,
@@ -880,56 +876,56 @@ function Me(e) {
880
876
  startParam: o,
881
877
  botInline: a
882
878
  } = e, h = new URLSearchParams();
883
- return h.set("tgWebAppPlatform", n), h.set("tgWebAppThemeParams", Ve(s)), h.set("tgWebAppVersion", r), t && h.set("tgWebAppData", t), o && h.set("tgWebAppStartParam", o), typeof i == "boolean" && h.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && h.set("tgWebAppBotInline", a ? "1" : "0"), h.toString();
879
+ return h.set("tgWebAppPlatform", n), h.set("tgWebAppThemeParams", Wt(s)), h.set("tgWebAppVersion", r), t && h.set("tgWebAppData", t), o && h.set("tgWebAppStartParam", o), typeof i == "boolean" && h.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && h.set("tgWebAppBotInline", a ? "1" : "0"), h.toString();
884
880
  }
885
- function Be(e) {
886
- Bt("launchParams", Me(e));
881
+ function jt(e) {
882
+ Ht("launchParams", Be(e));
887
883
  }
888
884
  function $e() {
889
885
  for (const e of [
890
886
  // Try to retrieve launch parameters from the current location. This method can return
891
887
  // nothing in case, location was changed and then page was reloaded.
892
- qe,
893
- // Then, try using the lower level API - window.performance.
894
888
  De,
889
+ // Then, try using the lower level API - window.performance.
890
+ Ve,
895
891
  // Finally, try to extract launch parameters from the session storage.
896
- Ne
892
+ Me
897
893
  ])
898
894
  try {
899
895
  const t = e();
900
- return Be(t), t;
896
+ return jt(t), t;
901
897
  } catch {
902
898
  }
903
899
  throw new Error("Unable to retrieve launch parameters from any known source.");
904
900
  }
905
- function Lt() {
906
- const e = Vt();
901
+ function Gt() {
902
+ const e = $t();
907
903
  return !!(e && e.type === "reload");
908
904
  }
909
905
  function Le() {
910
906
  let e = 0;
911
907
  return () => (e += 1).toString();
912
908
  }
913
- const [Ue] = ft(Le);
914
- function d(e, t) {
909
+ const [He] = vt(Le);
910
+ function l(e, t) {
915
911
  return () => {
916
912
  const s = $e(), n = {
917
913
  ...s,
918
- postEvent: Re(s.version),
919
- createRequestId: Ue()
914
+ postEvent: Ae(s.version),
915
+ createRequestId: He()
920
916
  };
921
917
  if (typeof e == "function")
922
918
  return e(n);
923
- const [r, i, o] = bt(), a = t({
919
+ const [r, i, o] = tt(), a = t({
924
920
  ...n,
925
921
  // State should only be passed only in case, current page was reloaded. If we don't add
926
922
  // this check, state restoration will work improperly in the web version of Telegram,
927
923
  // when we are always working in the same "session" (tab).
928
- state: Lt() ? $t(e) : void 0,
924
+ state: Gt() ? Ut(e) : void 0,
929
925
  addCleanup: r
930
926
  }), h = (u) => (o || r(
931
- u.on("change", (l) => {
932
- Bt(e, l);
927
+ u.on("change", (d) => {
928
+ Ht(e, d);
933
929
  })
934
930
  ), u);
935
931
  return [
@@ -938,17 +934,17 @@ function d(e, t) {
938
934
  ];
939
935
  };
940
936
  }
941
- const He = d("backButton", ({
937
+ const Ue = l("backButton", ({
942
938
  postEvent: e,
943
939
  version: t,
944
940
  state: s = { isVisible: !1 }
945
- }) => new Ae(s.isVisible, t, e));
946
- class N extends st {
941
+ }) => new ke(s.isVisible, t, e));
942
+ class D extends it {
947
943
  constructor() {
948
944
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
949
945
  }
950
946
  }
951
- function Ut(e) {
947
+ function Kt(e) {
952
948
  const t = e.available ? e : {
953
949
  available: !1,
954
950
  device_id: "",
@@ -966,7 +962,7 @@ function Ut(e) {
966
962
  accessGranted: t.access_granted
967
963
  };
968
964
  }
969
- class We extends N {
965
+ class We extends D {
970
966
  constructor({ postEvent: t, version: s, ...n }) {
971
967
  super(n, s, {
972
968
  auth: "web_app_biometry_request_auth",
@@ -1003,7 +999,7 @@ class We extends N {
1003
999
  reason: t,
1004
1000
  ...s
1005
1001
  }) {
1006
- return this.authPromise || (this.authPromise = m({
1002
+ return this.authPromise || (this.authPromise = w({
1007
1003
  ...s,
1008
1004
  method: "web_app_biometry_request_auth",
1009
1005
  event: "biometry_auth_requested",
@@ -1037,14 +1033,14 @@ class We extends N {
1037
1033
  * @returns Promise with true, if access was granted.
1038
1034
  */
1039
1035
  requestAccess({ reason: t, ...s } = {}) {
1040
- return this.accessPromise || (this.accessPromise = m({
1036
+ return this.accessPromise || (this.accessPromise = w({
1041
1037
  ...s,
1042
1038
  postEvent: this.postEvent,
1043
1039
  method: "web_app_biometry_request_access",
1044
1040
  event: "biometry_info_received",
1045
1041
  params: { reason: t || "" }
1046
1042
  }).then((n) => {
1047
- const r = Ut(n);
1043
+ const r = Kt(n);
1048
1044
  return this.set(r), r.accessGranted;
1049
1045
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1050
1046
  }
@@ -1066,7 +1062,7 @@ class We extends N {
1066
1062
  */
1067
1063
  async updateToken({ token: t, ...s } = {}) {
1068
1064
  return ["removed", "updated"].includes(
1069
- (await m({
1065
+ (await w({
1070
1066
  ...s,
1071
1067
  postEvent: this.postEvent,
1072
1068
  method: "web_app_biometry_update_token",
@@ -1077,15 +1073,15 @@ class We extends N {
1077
1073
  }
1078
1074
  }
1079
1075
  async function je(e) {
1080
- return Ut(
1081
- await m({
1076
+ return Kt(
1077
+ await w({
1082
1078
  ...e || {},
1083
1079
  method: "web_app_biometry_get_info",
1084
1080
  event: "biometry_info_received"
1085
1081
  })
1086
1082
  );
1087
1083
  }
1088
- const Ge = d(
1084
+ const Ge = l(
1089
1085
  "biometryManager",
1090
1086
  async ({ postEvent: e, version: t, state: s }) => new We({
1091
1087
  ...s || x("web_app_biometry_get_info", t) ? s || await je({ timeout: 1e3 }) : {
@@ -1099,12 +1095,12 @@ const Ge = d(
1099
1095
  postEvent: e
1100
1096
  })
1101
1097
  );
1102
- class rt extends et {
1098
+ class ct extends rt {
1103
1099
  constructor() {
1104
1100
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
1105
1101
  }
1106
1102
  }
1107
- class Ke extends rt {
1103
+ class Ke extends ct {
1108
1104
  constructor(t, s) {
1109
1105
  super({ isConfirmationNeeded: t }), this.postEvent = s;
1110
1106
  }
@@ -1131,16 +1127,16 @@ class Ke extends rt {
1131
1127
  this.isConfirmationNeeded = !0;
1132
1128
  }
1133
1129
  }
1134
- const ze = d(
1130
+ const ze = l(
1135
1131
  "closingBehavior",
1136
1132
  ({
1137
1133
  postEvent: e,
1138
1134
  state: t = { isConfirmationNeeded: !1 }
1139
1135
  }) => new Ke(t.isConfirmationNeeded, e)
1140
1136
  );
1141
- class it {
1137
+ class ht {
1142
1138
  constructor(t, s) {
1143
- c(this, "supports"), this.supports = It(t, s);
1139
+ c(this, "supports"), this.supports = Nt(t, s);
1144
1140
  }
1145
1141
  }
1146
1142
  function Je(e) {
@@ -1176,10 +1172,10 @@ class Fe extends L {
1176
1172
  function Qe(e) {
1177
1173
  return new Fe((t) => t, !1, e);
1178
1174
  }
1179
- function dt(e, t) {
1175
+ function wt(e, t) {
1180
1176
  return Object.fromEntries(e.map((s) => [s, t]));
1181
1177
  }
1182
- class Ye extends it {
1178
+ class Ye extends ht {
1183
1179
  constructor(t, s, n) {
1184
1180
  super(t, {
1185
1181
  delete: "web_app_invoke_custom_method",
@@ -1219,13 +1215,13 @@ class Ye extends it {
1219
1215
  async get(t, s = {}) {
1220
1216
  const n = Array.isArray(t) ? t : [t];
1221
1217
  if (!n.length)
1222
- return dt(n, "");
1218
+ return wt(n, "");
1223
1219
  const r = await A(
1224
1220
  "getStorageValues",
1225
1221
  { keys: n },
1226
1222
  this.createRequestId(),
1227
1223
  { ...s, postEvent: this.postEvent }
1228
- ), i = f(dt(n, p()), "CloudStorageData").parse(r);
1224
+ ), i = f(wt(n, p()), "CloudStorageData").parse(r);
1229
1225
  return Array.isArray(t) ? i : i[t];
1230
1226
  }
1231
1227
  /**
@@ -1243,10 +1239,10 @@ class Ye extends it {
1243
1239
  );
1244
1240
  }
1245
1241
  }
1246
- const Ze = d(
1242
+ const Ze = l(
1247
1243
  ({ createRequestId: e, postEvent: t, version: s }) => new Ye(s, e, t)
1248
1244
  );
1249
- class Xe extends it {
1245
+ class Xe extends ht {
1250
1246
  constructor(t, s) {
1251
1247
  super(t, {
1252
1248
  impactOccurred: "web_app_trigger_haptic_feedback",
@@ -1288,7 +1284,7 @@ class Xe extends it {
1288
1284
  this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
1289
1285
  }
1290
1286
  }
1291
- const ts = d(
1287
+ const ts = l(
1292
1288
  ({ version: e, postEvent: t }) => new Xe(e, t)
1293
1289
  );
1294
1290
  class es {
@@ -1364,13 +1360,13 @@ class es {
1364
1360
  return this.initData.user;
1365
1361
  }
1366
1362
  }
1367
- const ss = d(
1363
+ const ss = l(
1368
1364
  ({ initData: e }) => e ? new es(e) : void 0
1369
1365
  );
1370
1366
  function Ys(e) {
1371
- return kt().parse(e);
1367
+ return Vt().parse(e);
1372
1368
  }
1373
- class ns extends N {
1369
+ class ns extends D {
1374
1370
  constructor(t, s, n) {
1375
1371
  super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
1376
1372
  }
@@ -1400,7 +1396,7 @@ class ns extends N {
1400
1396
  }
1401
1397
  this.isOpened = !0;
1402
1398
  try {
1403
- return (await m({
1399
+ return (await w({
1404
1400
  method: "web_app_open_invoice",
1405
1401
  event: "invoice_closed",
1406
1402
  params: { slug: n },
@@ -1414,12 +1410,12 @@ class ns extends N {
1414
1410
  }
1415
1411
  }
1416
1412
  }
1417
- const rs = d(
1413
+ const rs = l(
1418
1414
  ({ version: e, postEvent: t }) => new ns(!1, e, t)
1419
1415
  );
1420
- class is extends et {
1416
+ class is extends rt {
1421
1417
  constructor({ postEvent: t, ...s }) {
1422
- super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ? v("main_button_pressed", r) : this.state.on(n, r)), c(this, "off", (n, r) => n === "click" ? H("main_button_pressed", r) : this.state.off(n, r)), this.postEvent = t;
1418
+ super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ? v("main_button_pressed", r) : this.state.on(n, r)), c(this, "off", (n, r) => n === "click" ? U("main_button_pressed", r) : this.state.off(n, r)), this.postEvent = t;
1423
1419
  }
1424
1420
  /**
1425
1421
  * The MainButton background color.
@@ -1548,7 +1544,7 @@ class is extends et {
1548
1544
  return this.get("textColor");
1549
1545
  }
1550
1546
  }
1551
- const os = d(
1547
+ const os = l(
1552
1548
  "mainButton",
1553
1549
  ({
1554
1550
  postEvent: e,
@@ -1564,7 +1560,7 @@ const os = d(
1564
1560
  }) => new is({ ...s, postEvent: e })
1565
1561
  );
1566
1562
  function as() {
1567
- return nt({
1563
+ return ot({
1568
1564
  contact: f({
1569
1565
  userId: {
1570
1566
  type: P(),
@@ -1584,13 +1580,13 @@ function as() {
1584
1580
  }
1585
1581
  }),
1586
1582
  authDate: {
1587
- type: Ot(),
1583
+ type: Dt(),
1588
1584
  from: "auth_date"
1589
1585
  },
1590
1586
  hash: p()
1591
1587
  }, "RequestedContact");
1592
1588
  }
1593
- function Ht(e, t) {
1589
+ function zt(e, t) {
1594
1590
  return (s) => {
1595
1591
  const [n, r] = t[s];
1596
1592
  return x(n, r, e);
@@ -1601,7 +1597,7 @@ function cs(e) {
1601
1597
  setTimeout(t, e);
1602
1598
  });
1603
1599
  }
1604
- class hs extends N {
1600
+ class hs extends D {
1605
1601
  constructor({ postEvent: t, createRequestId: s, version: n, botInline: r, ...i }) {
1606
1602
  super(i, n, {
1607
1603
  requestPhoneAccess: "web_app_request_phone",
@@ -1611,7 +1607,7 @@ class hs extends N {
1611
1607
  setBackgroundColor: "web_app_set_background_color"
1612
1608
  }), c(this, "botInline"), c(this, "postEvent"), c(this, "createRequestId"), c(this, "requestPhoneAccessPromise"), c(this, "requestWriteAccessPromise"), c(this, "supportsParam"), this.createRequestId = s, this.postEvent = t, this.botInline = r;
1613
1609
  const o = this.supports.bind(this);
1614
- this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Ht(n, {
1610
+ this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = zt(n, {
1615
1611
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1616
1612
  });
1617
1613
  }
@@ -1662,7 +1658,7 @@ class hs extends N {
1662
1658
  * True if current Mini App background color is recognized as dark.
1663
1659
  */
1664
1660
  get isDark() {
1665
- return At(this.bgColor);
1661
+ return Ot(this.bgColor);
1666
1662
  }
1667
1663
  /**
1668
1664
  * Informs the Telegram app that the Mini App is ready to be displayed.
@@ -1691,7 +1687,7 @@ class hs extends N {
1691
1687
  throw new Error("Access denied.");
1692
1688
  const s = Date.now() + t;
1693
1689
  let n = 50;
1694
- return Tt(async () => {
1690
+ return qt(async () => {
1695
1691
  for (; Date.now() < s; ) {
1696
1692
  try {
1697
1693
  return await this.getRequestedContact();
@@ -1699,7 +1695,7 @@ class hs extends N {
1699
1695
  }
1700
1696
  await cs(n), n += 50;
1701
1697
  }
1702
- throw Rt(t);
1698
+ throw kt(t);
1703
1699
  }, t);
1704
1700
  }
1705
1701
  /**
@@ -1712,7 +1708,7 @@ class hs extends N {
1712
1708
  * @see requestContact
1713
1709
  */
1714
1710
  async requestPhoneAccess(t = {}) {
1715
- return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = m({
1711
+ return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = w({
1716
1712
  ...t,
1717
1713
  method: "web_app_request_phone",
1718
1714
  event: "phone_requested",
@@ -1724,7 +1720,7 @@ class hs extends N {
1724
1720
  * @param options - additional options.
1725
1721
  */
1726
1722
  async requestWriteAccess(t = {}) {
1727
- return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = m({
1723
+ return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = w({
1728
1724
  ...t,
1729
1725
  method: "web_app_request_write_access",
1730
1726
  event: "write_access_requested",
@@ -1754,7 +1750,7 @@ class hs extends N {
1754
1750
  * @param color - color key or RGB color.
1755
1751
  */
1756
1752
  setHeaderColor(t) {
1757
- this.postEvent("web_app_set_header_color", tt(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
1753
+ this.postEvent("web_app_set_header_color", st(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
1758
1754
  }
1759
1755
  /**
1760
1756
  * Updates current Mini App background color.
@@ -1782,7 +1778,7 @@ class hs extends N {
1782
1778
  this.postEvent("web_app_switch_inline_query", { query: t, chat_types: s });
1783
1779
  }
1784
1780
  }
1785
- const ps = d(
1781
+ const ps = l(
1786
1782
  "miniApp",
1787
1783
  ({
1788
1784
  themeParams: e,
@@ -1818,7 +1814,7 @@ function us(e) {
1818
1814
  return { ...i, id: o };
1819
1815
  }) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
1820
1816
  }
1821
- class ls extends N {
1817
+ class ds extends D {
1822
1818
  constructor(t, s, n) {
1823
1819
  super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
1824
1820
  }
@@ -1847,7 +1843,7 @@ class ls extends N {
1847
1843
  throw new Error("Popup is already opened.");
1848
1844
  this.isOpened = !0;
1849
1845
  try {
1850
- const { button_id: s = null } = await m({
1846
+ const { button_id: s = null } = await w({
1851
1847
  event: "popup_closed",
1852
1848
  method: "web_app_open_popup",
1853
1849
  postEvent: this.postEvent,
@@ -1859,10 +1855,10 @@ class ls extends N {
1859
1855
  }
1860
1856
  }
1861
1857
  }
1862
- const ds = d(
1863
- ({ postEvent: e, version: t }) => new ls(!1, t, e)
1858
+ const ls = l(
1859
+ ({ postEvent: e, version: t }) => new ds(!1, t, e)
1864
1860
  );
1865
- class _s extends N {
1861
+ class _s extends D {
1866
1862
  constructor(t, s, n) {
1867
1863
  super({ isOpened: t }, s, {
1868
1864
  close: "web_app_close_scan_qr_popup",
@@ -1884,37 +1880,36 @@ class _s extends N {
1884
1880
  get isOpened() {
1885
1881
  return this.get("isOpened");
1886
1882
  }
1887
- /**
1888
- * Opens scanner with specified title shown to user. Method returns promise
1889
- * with scanned QR content in case, it was scanned. It will contain null in
1890
- * case, scanner was closed.
1891
- * @param text - title to display.
1892
- */
1893
1883
  async open(t) {
1894
1884
  if (this.isOpened)
1895
1885
  throw new Error("QR scanner is already opened.");
1886
+ const { text: s, capture: n } = (typeof t == "string" ? { text: t } : t) || {};
1896
1887
  this.isOpened = !0;
1897
1888
  try {
1898
- return (await m({
1889
+ const r = (await w({
1899
1890
  method: "web_app_open_scan_qr_popup",
1900
1891
  event: ["qr_text_received", "scan_qr_popup_closed"],
1901
1892
  postEvent: this.postEvent,
1902
- params: { text: t }
1893
+ params: { text: s },
1894
+ capture(i) {
1895
+ return i.event === "scan_qr_popup_closed" || !n || n(i.payload);
1896
+ }
1903
1897
  }) || {}).data || null;
1904
- } finally {
1905
- this.isOpened = !1;
1898
+ return r && this.close(), r;
1899
+ } catch (r) {
1900
+ throw this.isOpened = !1, r;
1906
1901
  }
1907
1902
  }
1908
1903
  }
1909
- const gs = d(
1904
+ const gs = l(
1910
1905
  ({ version: e, postEvent: t }) => new _s(!1, e, t)
1911
1906
  );
1912
- class fs extends st {
1907
+ class fs extends it {
1913
1908
  constructor(t, s, n) {
1914
1909
  super({ isVisible: t }, s, {
1915
1910
  show: "web_app_setup_settings_button",
1916
1911
  hide: "web_app_setup_settings_button"
1917
- }), c(this, "on", (r, i) => r === "click" ? v("settings_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? H("settings_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
1912
+ }), c(this, "on", (r, i) => r === "click" ? v("settings_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? U("settings_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
1918
1913
  }
1919
1914
  set isVisible(t) {
1920
1915
  this.set("isVisible", t), this.postEvent("web_app_setup_settings_button", { is_visible: t });
@@ -1938,7 +1933,7 @@ class fs extends st {
1938
1933
  this.isVisible = !0;
1939
1934
  }
1940
1935
  }
1941
- const ms = d(
1936
+ const ws = l(
1942
1937
  "settingsButton",
1943
1938
  ({
1944
1939
  version: e,
@@ -1946,10 +1941,10 @@ const ms = d(
1946
1941
  state: s = { isVisible: !1 }
1947
1942
  }) => new fs(s.isVisible, e, t)
1948
1943
  );
1949
- function Wt(e) {
1950
- return qt().parse(e);
1944
+ function Jt(e) {
1945
+ return Mt().parse(e);
1951
1946
  }
1952
- class bs extends rt {
1947
+ class ms extends ct {
1953
1948
  /**
1954
1949
  * @since v6.10
1955
1950
  */
@@ -1988,7 +1983,7 @@ class bs extends rt {
1988
1983
  * value is calculated according to theme bg color.
1989
1984
  */
1990
1985
  get isDark() {
1991
- return !this.bgColor || At(this.bgColor);
1986
+ return !this.bgColor || Ot(this.bgColor);
1992
1987
  }
1993
1988
  get linkColor() {
1994
1989
  return this.get("linkColor");
@@ -2014,7 +2009,7 @@ class bs extends rt {
2014
2009
  */
2015
2010
  listen() {
2016
2011
  return v("theme_changed", (t) => {
2017
- this.set(Wt(t.theme_params));
2012
+ this.set(Jt(t.theme_params));
2018
2013
  });
2019
2014
  }
2020
2015
  /**
@@ -2027,23 +2022,23 @@ class bs extends rt {
2027
2022
  return this.get("textColor");
2028
2023
  }
2029
2024
  }
2030
- const ws = d(
2025
+ const bs = l(
2031
2026
  "themeParams",
2032
2027
  ({ themeParams: e, state: t = e, addCleanup: s }) => {
2033
- const n = new bs(t);
2028
+ const n = new ms(t);
2034
2029
  return s(n.listen()), n;
2035
2030
  }
2036
2031
  );
2037
2032
  function Zs(e = {}) {
2038
- return m({
2033
+ return w({
2039
2034
  ...e,
2040
2035
  method: "web_app_request_theme",
2041
2036
  event: "theme_changed"
2042
- }).then(Wt);
2037
+ }).then(Jt);
2043
2038
  }
2044
- class vs extends it {
2039
+ class vs extends ht {
2045
2040
  constructor(t, s, n) {
2046
- super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Ht(t, {
2041
+ super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = zt(t, {
2047
2042
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2048
2043
  });
2049
2044
  }
@@ -2092,41 +2087,41 @@ class vs extends it {
2092
2087
  async readTextFromClipboard() {
2093
2088
  const t = this.createRequestId(), {
2094
2089
  data: s = null
2095
- } = await m({
2090
+ } = await w({
2096
2091
  method: "web_app_read_text_from_clipboard",
2097
2092
  event: "clipboard_text_received",
2098
2093
  postEvent: this.postEvent,
2099
2094
  params: { req_id: t },
2100
- capture: St(t)
2095
+ capture: It(t)
2101
2096
  });
2102
2097
  return s;
2103
2098
  }
2104
2099
  }
2105
- const ys = d(
2100
+ const ys = l(
2106
2101
  ({ version: e, postEvent: t, createRequestId: s }) => new vs(e, s, t)
2107
2102
  );
2108
- async function jt(e = {}) {
2103
+ async function Ft(e = {}) {
2109
2104
  const {
2110
2105
  is_expanded: t,
2111
2106
  is_state_stable: s,
2112
2107
  ...n
2113
- } = await m({
2108
+ } = await w({
2114
2109
  ...e,
2115
2110
  method: "web_app_request_viewport",
2116
2111
  event: "viewport_changed"
2117
2112
  });
2118
2113
  return { ...n, isExpanded: t, isStateStable: s };
2119
2114
  }
2120
- function T(e) {
2115
+ function R(e) {
2121
2116
  return e < 0 ? 0 : e;
2122
2117
  }
2123
- class Es extends rt {
2118
+ class Es extends ct {
2124
2119
  constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
2125
2120
  super({
2126
- height: T(n),
2121
+ height: R(n),
2127
2122
  isExpanded: i,
2128
- stableHeight: T(s),
2129
- width: T(r)
2123
+ stableHeight: R(s),
2124
+ width: R(r)
2130
2125
  }), c(this, "postEvent"), this.postEvent = t;
2131
2126
  }
2132
2127
  /**
@@ -2135,7 +2130,7 @@ class Es extends rt {
2135
2130
  * @param options - options to request fresh data.
2136
2131
  */
2137
2132
  async sync(t) {
2138
- const { isStateStable: s, ...n } = await jt(t);
2133
+ const { isStateStable: s, ...n } = await Ft(t);
2139
2134
  this.set({
2140
2135
  ...n,
2141
2136
  stableHeight: s ? n.height : this.get("stableHeight")
@@ -2188,11 +2183,11 @@ class Es extends rt {
2188
2183
  width: n,
2189
2184
  is_expanded: r,
2190
2185
  is_state_stable: i
2191
- } = t, o = T(s);
2186
+ } = t, o = R(s);
2192
2187
  this.set({
2193
2188
  height: o,
2194
2189
  isExpanded: r,
2195
- width: T(n),
2190
+ width: R(n),
2196
2191
  ...i ? { stableHeight: o } : {}
2197
2192
  });
2198
2193
  });
@@ -2227,7 +2222,7 @@ class Es extends rt {
2227
2222
  return this.stableHeight === this.height;
2228
2223
  }
2229
2224
  }
2230
- const Ps = d(
2225
+ const Ps = l(
2231
2226
  "viewport",
2232
2227
  async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
2233
2228
  let r = !1, i = 0, o = 0, a = 0;
@@ -2236,7 +2231,7 @@ const Ps = d(
2236
2231
  else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2237
2232
  r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
2238
2233
  else {
2239
- const u = await jt({ timeout: 1e3, postEvent: s });
2234
+ const u = await Ft({ timeout: 1e3, postEvent: s });
2240
2235
  r = u.isExpanded, i = u.height, o = u.width, a = u.isStateStable ? i : 0;
2241
2236
  }
2242
2237
  const h = new Es({
@@ -2256,7 +2251,7 @@ function Xs(e, t, s) {
2256
2251
  s || (s = (a) => `--tg-${a}-color`);
2257
2252
  const n = s("header"), r = s("bg"), i = () => {
2258
2253
  const { headerColor: a } = e;
2259
- if (tt(a))
2254
+ if (st(a))
2260
2255
  E(n, a);
2261
2256
  else {
2262
2257
  const { bgColor: h, secondaryBgColor: u } = t;
@@ -2294,7 +2289,7 @@ function en(e, t) {
2294
2289
  function xs(e = !0) {
2295
2290
  const t = [
2296
2291
  v("reload_iframe", () => {
2297
- k("iframe_will_reload"), window.location.reload();
2292
+ q("iframe_will_reload"), window.location.reload();
2298
2293
  })
2299
2294
  ], s = () => t.forEach((n) => n());
2300
2295
  if (e) {
@@ -2306,24 +2301,64 @@ function xs(e = !0) {
2306
2301
  () => document.head.removeChild(n)
2307
2302
  );
2308
2303
  }
2309
- return k("iframe_ready", { reload_supported: !0 }), s;
2304
+ return q("iframe_ready", { reload_supported: !0 }), s;
2310
2305
  }
2311
2306
  function sn() {
2312
2307
  return typeof window > "u";
2313
2308
  }
2314
2309
  async function nn() {
2315
- if (Pt(window))
2310
+ if (Rt(window))
2316
2311
  return !0;
2317
2312
  try {
2318
- return await m({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
2313
+ return await w({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
2319
2314
  } catch {
2320
2315
  return !1;
2321
2316
  }
2322
2317
  }
2318
+ function rn(e) {
2319
+ const t = typeof e == "string" ? at(e) : e;
2320
+ jt(t);
2321
+ function s(r) {
2322
+ if (typeof r == "string")
2323
+ try {
2324
+ const { eventType: i } = St(r);
2325
+ i === "web_app_request_theme" && Y("theme_changed", {
2326
+ theme_params: JSON.parse(Wt(t.themeParams))
2327
+ }), i === "web_app_request_viewport" && Y("viewport_changed", {
2328
+ width: window.innerWidth,
2329
+ height: window.innerHeight,
2330
+ is_state_stable: !0,
2331
+ is_expanded: !0
2332
+ });
2333
+ } catch {
2334
+ }
2335
+ }
2336
+ if (nt()) {
2337
+ const r = window.parent.postMessage.bind(window.parent);
2338
+ window.parent.postMessage = (i) => {
2339
+ s(i), r(i);
2340
+ };
2341
+ return;
2342
+ }
2343
+ if (Tt(window)) {
2344
+ const r = window.external.notify.bind(window.external);
2345
+ window.external.notify = (i) => {
2346
+ s(i), r(i);
2347
+ };
2348
+ return;
2349
+ }
2350
+ const n = window.TelegramWebviewProxy;
2351
+ window.TelegramWebviewProxy = {
2352
+ ...n || {},
2353
+ postEvent(...r) {
2354
+ s(JSON.stringify({ eventType: r[0], eventData: r[1] })), n && n.postEvent(...r);
2355
+ }
2356
+ };
2357
+ }
2323
2358
  function Cs(e) {
2324
2359
  return e instanceof $;
2325
2360
  }
2326
- function rn(e, t) {
2361
+ function on(e, t) {
2327
2362
  return Cs(e) && e.type === t;
2328
2363
  }
2329
2364
  function j(e, t) {
@@ -2335,12 +2370,12 @@ function j(e, t) {
2335
2370
  });
2336
2371
  }
2337
2372
  class Ss {
2338
- constructor(t, s, n = k) {
2339
- if (c(this, "history"), c(this, "ee", new O()), c(this, "attached", !1), c(this, "back", () => this.go(-1)), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this._index = s, this.postEvent = n, t.length === 0)
2340
- throw b(le, "History should not be empty.");
2373
+ constructor(t, s, n = q) {
2374
+ if (c(this, "history"), c(this, "ee", new k()), c(this, "attached", !1), c(this, "back", () => this.go(-1)), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this._index = s, this.postEvent = n, t.length === 0)
2375
+ throw m(we, "History should not be empty.");
2341
2376
  if (s < 0 || s >= t.length)
2342
- throw b(
2343
- de,
2377
+ throw m(
2378
+ me,
2344
2379
  "Index should not be zero and higher or equal than history size."
2345
2380
  );
2346
2381
  this.history = t.map((r) => j(r, ""));
@@ -2362,7 +2397,7 @@ class Ss {
2362
2397
  * Prevents current navigator from controlling the BackButton visibility state.
2363
2398
  */
2364
2399
  detach() {
2365
- this.attached = !1, H("back_button_pressed", this.back);
2400
+ this.attached = !1, U("back_button_pressed", this.back);
2366
2401
  }
2367
2402
  /**
2368
2403
  * Goes to the next history item.
@@ -2461,12 +2496,12 @@ function G({
2461
2496
  }) {
2462
2497
  return { ...e || { hash: "", search: "" }, ...t };
2463
2498
  }
2464
- function q(e, t) {
2499
+ function O(e, t) {
2465
2500
  return e.startsWith(t) ? e : `${t}${e}`;
2466
2501
  }
2467
2502
  function M(e) {
2468
2503
  return new URL(
2469
- typeof e == "string" ? e : `${e.pathname || ""}${q(e.search || "", "?")}${q(e.hash || "", "#")}`,
2504
+ typeof e == "string" ? e : `${e.pathname || ""}${O(e.search || "", "?")}${O(e.hash || "", "#")}`,
2470
2505
  "http://a"
2471
2506
  );
2472
2507
  }
@@ -2477,7 +2512,7 @@ function B(e) {
2477
2512
  function K(e, t, s) {
2478
2513
  let n, r;
2479
2514
  typeof e == "string" ? n = e : (n = B(e), s = e.state, r = e.id);
2480
- const { pathname: i, search: o, hash: a } = new URL(n, `http://a${q(t, "/")}`);
2515
+ const { pathname: i, search: o, hash: a } = new URL(n, `http://a${O(t, "/")}`);
2481
2516
  return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
2482
2517
  }
2483
2518
  async function I(e) {
@@ -2494,23 +2529,23 @@ async function I(e) {
2494
2529
  })
2495
2530
  ]);
2496
2531
  }
2497
- async function Rs() {
2532
+ async function Ts() {
2498
2533
  if (window.history.length <= 1 || (window.history.pushState(null, ""), await I(1 - window.history.length)))
2499
2534
  return;
2500
2535
  let e = await I(-1);
2501
2536
  for (; e; )
2502
2537
  e = await I(-1);
2503
2538
  }
2504
- function Gt(e) {
2539
+ function Qt(e) {
2505
2540
  return M(e).pathname;
2506
2541
  }
2507
- const _t = 0, z = 1, J = 2;
2508
- class Kt {
2542
+ const mt = 0, z = 1, J = 2;
2543
+ class Yt {
2509
2544
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2510
- c(this, "navigator"), c(this, "ee", new O()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
2545
+ c(this, "navigator"), c(this, "ee", new k()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
2511
2546
  if (o === null)
2512
2547
  return this.push(this.parsePath(window.location.href));
2513
- o === _t ? window.history.forward() : o === z && this.back(), o === J && this.forward();
2548
+ o === mt ? window.history.forward() : o === z && this.back(), o === J && this.forward();
2514
2549
  }), c(this, "onNavigatorChange", async ({
2515
2550
  to: o,
2516
2551
  from: a,
@@ -2526,7 +2561,7 @@ class Kt {
2526
2561
  t.map((o) => K(o, "/")),
2527
2562
  s,
2528
2563
  n
2529
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Gt(i || "");
2564
+ ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Qt(i || "");
2530
2565
  }
2531
2566
  /**
2532
2567
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2674,8 +2709,8 @@ class Kt {
2674
2709
  * @param value - path presented as string or URLLike.
2675
2710
  */
2676
2711
  renderPath(t) {
2677
- const s = (this.base.length === 1 ? "" : this.base) + q(B(t), "/");
2678
- return this.hashMode ? q(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2712
+ const s = (this.base.length === 1 ? "" : this.base) + O(B(t), "/");
2713
+ return this.hashMode ? O(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2679
2714
  }
2680
2715
  /**
2681
2716
  * Synchronizes current navigator state with browser history.
@@ -2683,7 +2718,7 @@ class Kt {
2683
2718
  async syncHistory() {
2684
2719
  window.removeEventListener("popstate", this.onPopState);
2685
2720
  const { state: t } = this, s = this.renderPath(this);
2686
- await Rs(), this.hasPrev && this.hasNext ? (window.history.replaceState(z, ""), window.history.pushState(t, "", s), window.history.pushState(J, ""), await I(-1)) : this.hasPrev ? (window.history.replaceState(z, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(J, ""), await I(-1)) : (window.history.replaceState(_t, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2721
+ await Ts(), this.hasPrev && this.hasNext ? (window.history.replaceState(z, ""), window.history.pushState(t, "", s), window.history.pushState(J, ""), await I(-1)) : this.hasPrev ? (window.history.replaceState(z, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(J, ""), await I(-1)) : (window.history.replaceState(mt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2687
2722
  }
2688
2723
  /**
2689
2724
  * Current query parameters.
@@ -2701,41 +2736,41 @@ class Kt {
2701
2736
  return (this.navigator.current.params || {}).state;
2702
2737
  }
2703
2738
  }
2704
- function Ts(e) {
2739
+ function Rs(e) {
2705
2740
  e || (e = {});
2706
2741
  const { href: t, hash: s } = window.location;
2707
2742
  let n = B(
2708
2743
  e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
2709
2744
  );
2710
- const r = e.base ? Gt(e.base) : void 0;
2745
+ const r = e.base ? Qt(e.base) : void 0;
2711
2746
  if (r) {
2712
2747
  if (!n.startsWith(r))
2713
- throw b(
2714
- _e,
2748
+ throw m(
2749
+ be,
2715
2750
  `Path "${n}" expected to be starting with "${r}"`
2716
2751
  );
2717
2752
  n = n.slice(r.length);
2718
2753
  }
2719
- return new Kt([n], 0, e);
2754
+ return new Yt([n], 0, e);
2720
2755
  }
2721
- function on(e) {
2756
+ function an(e) {
2722
2757
  const t = e.match(/#(.+)/);
2723
2758
  return t ? t[1] : null;
2724
2759
  }
2725
2760
  function As(e, t) {
2726
- if (Lt()) {
2761
+ if (Gt()) {
2727
2762
  const s = sessionStorage.getItem(e);
2728
2763
  if (s)
2729
2764
  try {
2730
2765
  const { index: n, history: r } = JSON.parse(s);
2731
- return new Kt(r, n, t);
2766
+ return new Yt(r, n, t);
2732
2767
  } catch (n) {
2733
2768
  console.error("Unable to restore hash navigator state.", n);
2734
2769
  }
2735
2770
  }
2736
- return Ts(t);
2771
+ return Rs(t);
2737
2772
  }
2738
- function an(e, t) {
2773
+ function cn(e, t) {
2739
2774
  const s = As(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2740
2775
  index: s.index,
2741
2776
  history: s.history
@@ -2743,13 +2778,13 @@ function an(e, t) {
2743
2778
  return s.on("change", n), n(), s;
2744
2779
  }
2745
2780
  function _(e) {
2746
- return (t, s, ...n) => (r) => gt(s, at(() => at({
2781
+ return (t, s, ...n) => (r) => bt(s, ut(() => ut({
2747
2782
  [t]: e(...n)
2748
2783
  }, r)));
2749
2784
  }
2750
- const zt = Qt();
2785
+ const Zt = ee();
2751
2786
  function Is() {
2752
- const e = Yt(zt);
2787
+ const e = se(Zt);
2753
2788
  if (!e)
2754
2789
  throw new Error("useSDK was used outside of SDKProvider.");
2755
2790
  return e;
@@ -2760,38 +2795,38 @@ function g(e) {
2760
2795
  return Object.defineProperty(n, "error", () => s.error), n;
2761
2796
  };
2762
2797
  }
2763
- const Os = g(He), cn = _(Os), ks = g(Ge), hn = _(ks), qs = g(ze), pn = _(qs), Ds = g(Ze), un = _(Ds), Ns = g(ts), ln = _(Ns), Vs = g(ss), dn = _(Vs), Ms = g(rs), _n = _(Ms), Bs = g(os), gn = _(Bs), $s = g(ps), fn = _($s), Ls = g(ds), mn = _(Ls), Us = g(gs), bn = _(Us), Hs = g(ms), wn = _(Hs), Ws = g(ws), vn = _(Ws), js = g(ys), yn = _(js), Gs = g(Ps), En = _(Gs), Pn = (e) => {
2798
+ const ks = g(Ue), hn = _(ks), qs = g(Ge), pn = _(qs), Os = g(ze), un = _(Os), Ns = g(Ze), dn = _(Ns), Ds = g(ts), ln = _(Ds), Vs = g(ss), _n = _(Vs), Ms = g(rs), gn = _(Ms), Bs = g(os), fn = _(Bs), $s = g(ps), wn = _($s), Ls = g(ls), mn = _(Ls), Hs = g(gs), bn = _(Hs), Us = g(ws), vn = _(Us), Ws = g(bs), yn = _(Ws), js = g(ys), En = _(js), Gs = g(Ps), Pn = _(Gs), xn = (e) => {
2764
2799
  const t = /* @__PURE__ */ new Map(), s = (n, ...r) => {
2765
2800
  if (t.has(n))
2766
2801
  return t.get(n);
2767
- function i(l) {
2768
- return t.set(n, l), l;
2802
+ function i(d) {
2803
+ return t.set(n, d), d;
2769
2804
  }
2770
2805
  let o;
2771
2806
  try {
2772
2807
  o = n(...r);
2773
- } catch (l) {
2808
+ } catch (d) {
2774
2809
  return i({
2775
- error: l,
2810
+ error: d,
2776
2811
  signal: () => {
2777
- throw l;
2812
+ throw d;
2778
2813
  }
2779
2814
  });
2780
2815
  }
2781
2816
  let a;
2782
2817
  Array.isArray(o) && ([o, a] = o);
2783
- const [h] = Zt(() => o), u = pt(() => {
2818
+ const [h] = ne(() => o), u = _t(() => {
2784
2819
  if (h.state !== "ready")
2785
2820
  return;
2786
- const l = h();
2787
- if (!l || !("on" in l))
2788
- return l;
2789
- const Jt = Xt((V) => (V(l), l.on("change", () => V(l)))), Ft = Object.getPrototypeOf(l), W = {};
2790
- return new Proxy(l, {
2821
+ const d = h();
2822
+ if (!d || !("on" in d))
2823
+ return d;
2824
+ const Xt = re((V) => (V(d), d.on("change", () => V(d)))), te = Object.getPrototypeOf(d), W = {};
2825
+ return new Proxy(d, {
2791
2826
  get(V, C) {
2792
2827
  if (!(C in W)) {
2793
- const ot = Reflect.getOwnPropertyDescriptor(Ft, C);
2794
- W[C] = ot && "get" in ot ? pt(() => Jt()[C]) : () => Reflect.get(V, C);
2828
+ const pt = Reflect.getOwnPropertyDescriptor(te, C);
2829
+ W[C] = pt && "get" in pt ? _t(() => Xt()[C]) : () => Reflect.get(V, C);
2795
2830
  }
2796
2831
  return W[C]();
2797
2832
  }
@@ -2809,13 +2844,13 @@ const Os = g(He), cn = _(Os), ks = g(Ge), hn = _(ks), qs = g(ze), pn = _(qs), Ds
2809
2844
  cleanup: a
2810
2845
  });
2811
2846
  };
2812
- return ct(() => {
2813
- re(e.debug || !1);
2814
- }), ct(() => {
2815
- xt() && ht(xs(e.acceptCustomStyles));
2816
- }), ht(() => {
2847
+ return dt(() => {
2848
+ he(e.debug || !1);
2849
+ }), dt(() => {
2850
+ nt() && lt(xs(e.acceptCustomStyles));
2851
+ }), lt(() => {
2817
2852
  t.forEach((n) => n.cleanup && n.cleanup());
2818
- }), gt(zt.Provider, {
2853
+ }), bt(Zt.Provider, {
2819
2854
  value: s,
2820
2855
  get children() {
2821
2856
  return e.children;
@@ -2823,36 +2858,36 @@ const Os = g(He), cn = _(Os), ks = g(Ge), hn = _(ks), qs = g(ze), pn = _(qs), Ds
2823
2858
  });
2824
2859
  };
2825
2860
  export {
2826
- Ae as BackButton,
2861
+ ke as BackButton,
2827
2862
  Ss as BasicNavigator,
2828
2863
  We as BiometryManager,
2829
- Kt as BrowserNavigator,
2864
+ Yt as BrowserNavigator,
2830
2865
  Ke as ClosingBehavior,
2831
2866
  Ye as CloudStorage,
2832
- _e as ERR_INVALID_PATH_BASE,
2833
- he as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2834
- ae as ERR_METHOD_PARAMETER_UNSUPPORTED,
2835
- oe as ERR_METHOD_UNSUPPORTED,
2836
- le as ERR_NAVIGATION_HISTORY_EMPTY,
2837
- de as ERR_NAVIGATION_INDEX_INVALID,
2867
+ be as ERR_INVALID_PATH_BASE,
2868
+ _e as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2869
+ de as ERR_METHOD_PARAMETER_UNSUPPORTED,
2870
+ ue as ERR_METHOD_UNSUPPORTED,
2871
+ we as ERR_NAVIGATION_HISTORY_EMPTY,
2872
+ me as ERR_NAVIGATION_INDEX_INVALID,
2838
2873
  zs as ERR_NAVIGATION_ITEM_INVALID,
2839
- wt as ERR_PARSE,
2874
+ Et as ERR_PARSE,
2840
2875
  Js as ERR_SSR_INIT,
2841
- pe as ERR_TIMED_OUT,
2842
- ue as ERR_UNEXPECTED_TYPE,
2843
- ce as ERR_UNKNOWN_ENV,
2844
- O as EventEmitter,
2876
+ ge as ERR_TIMED_OUT,
2877
+ fe as ERR_UNEXPECTED_TYPE,
2878
+ le as ERR_UNKNOWN_ENV,
2879
+ k as EventEmitter,
2845
2880
  Xe as HapticFeedback,
2846
2881
  es as InitData,
2847
2882
  ns as Invoice,
2848
2883
  is as MainButton,
2849
2884
  hs as MiniApp,
2850
- ls as Popup,
2885
+ ds as Popup,
2851
2886
  _s as QRScanner,
2852
2887
  $ as SDKError,
2853
- Pn as SDKProvider,
2888
+ xn as SDKProvider,
2854
2889
  fs as SettingsButton,
2855
- bs as ThemeParams,
2890
+ ms as ThemeParams,
2856
2891
  vs as Utils,
2857
2892
  Es as Viewport,
2858
2893
  Qe as array,
@@ -2860,16 +2895,16 @@ export {
2860
2895
  tn as bindThemeParamsCSSVars,
2861
2896
  en as bindViewportCSSVars,
2862
2897
  y as boolean,
2863
- St as captureSameReq,
2864
- Y as classNames,
2865
- xe as compareVersions,
2866
- Ts as createBrowserNavigatorFromLocation,
2867
- Re as createPostEvent,
2898
+ It as captureSameReq,
2899
+ Z as classNames,
2900
+ Te as compareVersions,
2901
+ Rs as createBrowserNavigatorFromLocation,
2902
+ Ae as createPostEvent,
2868
2903
  M as createSafeURL,
2869
- Ot as date,
2870
- on as getHash,
2871
- Gt as getPathname,
2872
- He as initBackButton,
2904
+ Dt as date,
2905
+ an as getHash,
2906
+ Qt as getPathname,
2907
+ Ue as initBackButton,
2873
2908
  Ge as initBiometryManager,
2874
2909
  ze as initClosingBehavior,
2875
2910
  Ze as initCloudStorage,
@@ -2878,83 +2913,84 @@ export {
2878
2913
  rs as initInvoice,
2879
2914
  os as initMainButton,
2880
2915
  ps as initMiniApp,
2881
- an as initNavigator,
2882
- ds as initPopup,
2916
+ cn as initNavigator,
2917
+ ls as initPopup,
2883
2918
  gs as initQRScanner,
2884
- ms as initSettingsButton,
2885
- ws as initThemeParams,
2919
+ ws as initSettingsButton,
2920
+ bs as initThemeParams,
2886
2921
  ys as initUtils,
2887
2922
  Ps as initViewport,
2888
2923
  xs as initWeb,
2889
2924
  A as invokeCustomMethod,
2890
- At as isColorDark,
2891
- xt as isIframe,
2892
- Lt as isPageReload,
2893
- tt as isRGB,
2894
- ge as isRGBShort,
2925
+ Ot as isColorDark,
2926
+ nt as isIframe,
2927
+ Gt as isPageReload,
2928
+ st as isRGB,
2929
+ ve as isRGBShort,
2895
2930
  Cs as isSDKError,
2896
- rn as isSDKErrorOfType,
2931
+ on as isSDKErrorOfType,
2897
2932
  sn as isSSR,
2898
2933
  nn as isTMA,
2899
2934
  f as json,
2900
2935
  Qs as mergeClassNames,
2936
+ rn as mockTelegramEnv,
2901
2937
  P as number,
2902
- H as off,
2938
+ U as off,
2903
2939
  v as on,
2904
2940
  Ys as parseInitData,
2905
- Dt as parseLaunchParams,
2906
- Wt as parseThemeParams,
2907
- k as postEvent,
2908
- m as request,
2941
+ at as parseLaunchParams,
2942
+ Jt as parseThemeParams,
2943
+ q as postEvent,
2944
+ w as request,
2909
2945
  je as requestBiometryInfo,
2910
2946
  Zs as requestThemeParams,
2911
- jt as requestViewport,
2947
+ Ft as requestViewport,
2912
2948
  $e as retrieveLaunchParams,
2913
- Et as rgb,
2914
- nt as searchParams,
2915
- Me as serializeLaunchParams,
2916
- Ve as serializeThemeParams,
2949
+ Ct as rgb,
2950
+ ot as searchParams,
2951
+ Be as serializeLaunchParams,
2952
+ Wt as serializeThemeParams,
2917
2953
  E as setCSSVar,
2918
- re as setDebug,
2954
+ he as setDebug,
2919
2955
  Fs as setTargetOrigin,
2920
2956
  p as string,
2921
- se as subscribe,
2957
+ ae as subscribe,
2922
2958
  x as supports,
2923
- Se as targetOrigin,
2924
- yt as toRGB,
2925
- mt as unsubscribe,
2959
+ Re as targetOrigin,
2960
+ xt as toRGB,
2961
+ yt as unsubscribe,
2926
2962
  B as urlToPath,
2927
- Os as useBackButton,
2928
- ks as useBiometryManager,
2929
- qs as useClosingBehavior,
2930
- Ds as useCloudStorage,
2931
- Ns as useHapticFeedback,
2963
+ ks as useBackButton,
2964
+ qs as useBiometryManager,
2965
+ Os as useClosingBehavior,
2966
+ Ns as useCloudStorage,
2967
+ Ds as useHapticFeedback,
2932
2968
  Vs as useInitData,
2933
2969
  Ms as useInvoice,
2934
2970
  Bs as useMainButton,
2935
2971
  $s as useMiniApp,
2936
2972
  Ls as usePopup,
2937
- Us as useQRScanner,
2973
+ Hs as useQRScanner,
2938
2974
  Is as useSDK,
2939
- Hs as useSettingsButton,
2975
+ Us as useSettingsButton,
2940
2976
  Ws as useThemeParams,
2941
2977
  js as useUtils,
2942
2978
  Gs as useViewport,
2943
- cn as withBackButton,
2944
- hn as withBiometryManager,
2945
- pn as withClosingBehavior,
2946
- un as withCloudStorage,
2979
+ hn as withBackButton,
2980
+ pn as withBiometryManager,
2981
+ un as withClosingBehavior,
2982
+ dn as withCloudStorage,
2947
2983
  ln as withHapticFeedback,
2948
- dn as withInitData,
2949
- _n as withInvoice,
2950
- gn as withMainButton,
2951
- fn as withMiniApp,
2984
+ _n as withInitData,
2985
+ gn as withInvoice,
2986
+ fn as withMainButton,
2987
+ wn as withMiniApp,
2952
2988
  mn as withPopup,
2953
2989
  bn as withQRScanner,
2954
- wn as withSettingsButton,
2955
- vn as withThemeParams,
2956
- Tt as withTimeout,
2957
- yn as withUtils,
2958
- En as withViewport
2990
+ vn as withSettingsButton,
2991
+ yn as withThemeParams,
2992
+ qt as withTimeout,
2993
+ En as withUtils,
2994
+ Pn as withViewport
2959
2995
  };
2960
2996
  //# sourceMappingURL=index.js.map