@tma.js/sdk-react 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
- import { jsx as vt } from "react/jsx-runtime";
2
- import { createContext as Xt, useContext as te, useMemo as st, useRef as lt, useState as ee, useCallback as _t, useEffect as M } from "react";
3
- var se = Object.defineProperty, ne = (e, t, s) => t in e ? se(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (ne(e, typeof t != "symbol" ? t + "" : t, s), s);
4
- function yt(e, t) {
1
+ import { jsx as bt } from "react/jsx-runtime";
2
+ import { createContext as te, useContext as ee, useMemo as st, useRef as dt, useState as se, useCallback as lt, useEffect as M } from "react";
3
+ var ne = Object.defineProperty, re = (e, t, s) => t in e ? ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, h = (e, t, s) => (re(e, typeof t != "symbol" ? t + "" : t, s), s);
4
+ function vt(e, t) {
5
5
  let s;
6
6
  const n = () => {
7
7
  s !== void 0 && t && t(s), s = void 0;
8
8
  };
9
9
  return [() => s === void 0 ? s = e(n) : s, n];
10
10
  }
11
- function Et(e) {
11
+ function yt(e) {
12
12
  const t = G(), { count: s } = t;
13
- t.unsubscribe(e), s && !t.count && Ce();
13
+ t.unsubscribe(e), s && !t.count && Se();
14
14
  }
15
- function re(e) {
16
- return G().subscribe(e), () => Et(e);
15
+ function ie(e) {
16
+ return G().subscribe(e), () => yt(e);
17
17
  }
18
- class ie {
18
+ class oe {
19
19
  constructor(t, s = {}) {
20
20
  this.scope = t, this.options = s;
21
21
  }
@@ -55,23 +55,23 @@ class ie {
55
55
  this.print("log", ...t);
56
56
  }
57
57
  }
58
- const H = new ie("SDK", {
58
+ const H = new oe("SDK", {
59
59
  bgColor: "forestgreen",
60
60
  textColor: "white"
61
61
  });
62
62
  let X = !1;
63
- const gt = ({ event: e, args: [t] }) => {
63
+ const _t = ({ event: e, args: [t] }) => {
64
64
  H.log("Event received:", t === void 0 ? { name: e } : { name: e, data: t });
65
65
  };
66
- function oe(e) {
67
- X !== e && (X = e, e ? re(gt) : Et(gt));
66
+ function ae(e) {
67
+ X !== e && (X = e, e ? ie(_t) : yt(_t));
68
68
  }
69
- function ae(...e) {
69
+ function he(...e) {
70
70
  X && H.log(...e);
71
71
  }
72
72
  class U {
73
73
  constructor() {
74
- c(this, "listeners", /* @__PURE__ */ new Map()), c(this, "listenersCount", 0), c(this, "subscribeListeners", []);
74
+ h(this, "listeners", /* @__PURE__ */ new Map()), h(this, "listenersCount", 0), h(this, "subscribeListeners", []);
75
75
  }
76
76
  /**
77
77
  * Removes all event listeners.
@@ -147,12 +147,12 @@ class W extends Error {
147
147
  super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, W.prototype);
148
148
  }
149
149
  }
150
- function l(e, t, s) {
150
+ function m(e, t, s) {
151
151
  return new W(e, t, s);
152
152
  }
153
- const ce = "ERR_METHOD_UNSUPPORTED", he = "ERR_METHOD_PARAMETER_UNSUPPORTED", pe = "ERR_UNKNOWN_ENV", ue = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", de = "ERR_TIMED_OUT", le = "ERR_UNEXPECTED_TYPE", Pt = "ERR_PARSE", _e = "ERR_NAVIGATION_LIST_EMPTY", ge = "ERR_NAVIGATION_CURSOR_INVALID", _n = "ERR_NAVIGATION_ITEM_INVALID", nt = "ERR_SSR_INIT", we = "ERR_SSR_POST_EVENT", fe = "ERR_INVALID_PATH_BASE";
153
+ const ce = "ERR_METHOD_UNSUPPORTED", pe = "ERR_METHOD_PARAMETER_UNSUPPORTED", ue = "ERR_UNKNOWN_ENV", de = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", le = "ERR_TIMED_OUT", _e = "ERR_UNEXPECTED_TYPE", Et = "ERR_PARSE", ge = "ERR_NAVIGATION_LIST_EMPTY", we = "ERR_NAVIGATION_CURSOR_INVALID", ln = "ERR_NAVIGATION_ITEM_INVALID", Pt = "ERR_SSR_INIT", fe = "ERR_INVALID_PATH_BASE";
154
154
  function T() {
155
- return l(le, "Value has unexpected type");
155
+ return m(_e, "Value has unexpected type");
156
156
  }
157
157
  class j {
158
158
  constructor(t, s, n) {
@@ -169,8 +169,8 @@ class j {
169
169
  try {
170
170
  return this.parser(t);
171
171
  } catch (s) {
172
- throw l(
173
- Pt,
172
+ throw m(
173
+ Et,
174
174
  `Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
175
175
  s
176
176
  );
@@ -180,10 +180,10 @@ class j {
180
180
  return this.isOptional = !0, this;
181
181
  }
182
182
  }
183
- function A(e, t) {
183
+ function k(e, t) {
184
184
  return () => new j(e, !1, t);
185
185
  }
186
- const P = A((e) => {
186
+ const P = k((e) => {
187
187
  if (typeof e == "boolean")
188
188
  return e;
189
189
  const t = String(e);
@@ -210,24 +210,24 @@ function Rt(e, t) {
210
210
  const a = o(t(i));
211
211
  a !== void 0 && (s[n] = a);
212
212
  } catch (a) {
213
- throw l(Pt, `Unable to parse field "${n}"`, a);
213
+ throw m(Et, `Unable to parse field "${n}"`, a);
214
214
  }
215
215
  }
216
216
  return s;
217
217
  }
218
- function rt(e) {
218
+ function nt(e) {
219
219
  let t = e;
220
220
  if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
221
221
  throw T();
222
222
  return t;
223
223
  }
224
- function f(e, t) {
224
+ function w(e, t) {
225
225
  return new j((s) => {
226
- const n = rt(s);
226
+ const n = nt(s);
227
227
  return Rt(e, (r) => n[r]);
228
228
  }, !1, t);
229
229
  }
230
- const x = A((e) => {
230
+ const C = k((e) => {
231
231
  if (typeof e == "number")
232
232
  return e;
233
233
  if (typeof e == "string") {
@@ -237,7 +237,7 @@ const x = A((e) => {
237
237
  }
238
238
  throw T();
239
239
  }, "number");
240
- function it(e) {
240
+ function rt(e) {
241
241
  return /^#[\da-f]{6}$/i.test(e);
242
242
  }
243
243
  function me(e) {
@@ -245,7 +245,7 @@ function me(e) {
245
245
  }
246
246
  function xt(e) {
247
247
  const t = e.replace(/\s/g, "").toLowerCase();
248
- if (it(t))
248
+ if (rt(t))
249
249
  return t;
250
250
  if (me(t)) {
251
251
  let n = "#";
@@ -261,14 +261,14 @@ function xt(e) {
261
261
  return n + (i.length === 1 ? "0" : "") + i;
262
262
  }, "#");
263
263
  }
264
- const h = A((e) => {
264
+ const c = k((e) => {
265
265
  if (typeof e == "string" || typeof e == "number")
266
266
  return e.toString();
267
267
  throw T();
268
- }, "string"), St = A((e) => xt(h().parse(e)), "rgb");
268
+ }, "string"), Ct = k((e) => xt(c().parse(e)), "rgb");
269
269
  function be(e) {
270
- return f({
271
- eventType: h(),
270
+ return w({
271
+ eventType: c(),
272
272
  eventData: (t) => t
273
273
  }).parse(e);
274
274
  }
@@ -303,45 +303,45 @@ function Ee() {
303
303
  });
304
304
  });
305
305
  }
306
- const Pe = f({
307
- button_id: (e) => e == null ? void 0 : h().parse(e)
306
+ const Pe = w({
307
+ button_id: (e) => e == null ? void 0 : c().parse(e)
308
308
  }), Re = {
309
- clipboard_text_received: f({
310
- req_id: h(),
311
- data: (e) => e === null ? e : h().optional().parse(e)
309
+ clipboard_text_received: w({
310
+ req_id: c(),
311
+ data: (e) => e === null ? e : c().optional().parse(e)
312
312
  }),
313
- custom_method_invoked: f({
314
- req_id: h(),
313
+ custom_method_invoked: w({
314
+ req_id: c(),
315
315
  result: (e) => e,
316
- error: h().optional()
316
+ error: c().optional()
317
317
  }),
318
- invoice_closed: f({
319
- slug: h(),
320
- status: h()
318
+ invoice_closed: w({
319
+ slug: c(),
320
+ status: c()
321
321
  }),
322
- phone_requested: f({
323
- status: h()
322
+ phone_requested: w({
323
+ status: c()
324
324
  }),
325
325
  popup_closed: {
326
326
  parse: (e) => Pe.parse(e ?? {})
327
327
  },
328
- qr_text_received: f({
329
- data: h().optional()
328
+ qr_text_received: w({
329
+ data: c().optional()
330
330
  }),
331
- theme_changed: f({
331
+ theme_changed: w({
332
332
  theme_params: (e) => {
333
- const t = St().optional();
334
- return Object.entries(rt(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
333
+ const t = Ct().optional();
334
+ return Object.entries(nt(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
335
335
  }
336
336
  }),
337
- viewport_changed: f({
338
- height: x(),
339
- width: (e) => e == null ? window.innerWidth : x().parse(e),
337
+ viewport_changed: w({
338
+ height: C(),
339
+ width: (e) => e == null ? window.innerWidth : C().parse(e),
340
340
  is_state_stable: P(),
341
341
  is_expanded: P()
342
342
  }),
343
- write_access_requested: f({
344
- status: h()
343
+ write_access_requested: w({
344
+ status: c()
345
345
  })
346
346
  };
347
347
  function xe() {
@@ -393,7 +393,7 @@ function xe() {
393
393
  t.forEach((s) => s()), t = [];
394
394
  }];
395
395
  }
396
- const [Se, Ce] = yt(
396
+ const [Ce, Se] = vt(
397
397
  (e) => {
398
398
  const [t, s] = xe(), n = t.off.bind(t);
399
399
  return t.off = (r, i) => {
@@ -404,7 +404,7 @@ const [Se, Ce] = yt(
404
404
  ([, e]) => e()
405
405
  );
406
406
  function G() {
407
- return Se()[0];
407
+ return Ce()[0];
408
408
  }
409
409
  function z(e, t) {
410
410
  G().off(e, t);
@@ -412,7 +412,7 @@ function z(e, t) {
412
412
  function E(e, t, s) {
413
413
  return G().on(e, t, s);
414
414
  }
415
- function D(e) {
415
+ function N(e) {
416
416
  return typeof e == "object" && e !== null && !Array.isArray(e);
417
417
  }
418
418
  function Te(e, t) {
@@ -478,79 +478,79 @@ function S(e, t, s) {
478
478
  ].includes(e);
479
479
  }
480
480
  }
481
- function Ae(e) {
482
- return "external" in e && D(e.external) && "notify" in e.external && typeof e.external.notify == "function";
483
- }
484
481
  function ke(e) {
485
- return "TelegramWebviewProxy" in e && D(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
482
+ return "external" in e && N(e.external) && "notify" in e.external && typeof e.external.notify == "function";
483
+ }
484
+ function St(e) {
485
+ return "TelegramWebviewProxy" in e && N(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
486
486
  }
487
- function Ct() {
487
+ function Tt() {
488
488
  try {
489
489
  return window.self !== window.top;
490
490
  } catch {
491
491
  return !0;
492
492
  }
493
493
  }
494
- let Tt = "https://web.telegram.org";
495
- function gn(e) {
496
- Tt = e;
494
+ let kt = "https://web.telegram.org";
495
+ function _n(e) {
496
+ kt = e;
497
497
  }
498
- function Ie() {
499
- return Tt;
498
+ function Ae() {
499
+ return kt;
500
500
  }
501
- function q(e, t, s) {
501
+ function O(e, t, s) {
502
502
  let n = {}, r;
503
503
  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);
504
- const { targetOrigin: i = Ie() } = n;
505
- if (ae("Posting event:", r ? { event: e, data: r } : { event: e }), Ct()) {
504
+ const { targetOrigin: i = Ae() } = n;
505
+ if (he("Posting event:", r ? { event: e, data: r } : { event: e }), Tt()) {
506
506
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
507
507
  return;
508
508
  }
509
- if (Ae(window)) {
509
+ if (ke(window)) {
510
510
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
511
511
  return;
512
512
  }
513
- if (ke(window)) {
513
+ if (St(window)) {
514
514
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
515
515
  return;
516
516
  }
517
- throw l(
518
- pe,
517
+ throw m(
518
+ ue,
519
519
  "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."
520
520
  );
521
521
  }
522
- function Oe(e) {
522
+ function Ie(e) {
523
523
  return (t, s) => {
524
524
  if (!S(t, e))
525
- throw l(ce, `Method "${t}" is unsupported in Mini Apps version ${e}`);
526
- if (D(s)) {
525
+ throw m(ce, `Method "${t}" is unsupported in Mini Apps version ${e}`);
526
+ if (N(s)) {
527
527
  let n;
528
528
  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 && !S(t, n, e))
529
- throw l(
530
- he,
529
+ throw m(
530
+ pe,
531
531
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
532
532
  );
533
533
  }
534
- return q(t, s);
534
+ return O(t, s);
535
535
  };
536
536
  }
537
537
  function At(e) {
538
538
  return ({ req_id: t }) => t === e;
539
539
  }
540
- function kt(e) {
541
- return l(de, `Timeout reached: ${e}ms`);
540
+ function It(e) {
541
+ return m(le, `Timeout reached: ${e}ms`);
542
542
  }
543
- function It(e, t) {
543
+ function qt(e, t) {
544
544
  return Promise.race([
545
545
  typeof e == "function" ? e() : e,
546
546
  new Promise((s, n) => {
547
547
  setTimeout(() => {
548
- n(kt(t));
548
+ n(It(t));
549
549
  }, t);
550
550
  })
551
551
  ]);
552
552
  }
553
- async function m(e) {
553
+ async function f(e) {
554
554
  let t;
555
555
  const s = new Promise((u) => {
556
556
  t = u;
@@ -558,13 +558,13 @@ async function m(e) {
558
558
  method: n,
559
559
  event: r,
560
560
  capture: i,
561
- postEvent: o = q,
561
+ postEvent: o = O,
562
562
  timeout: a
563
563
  } = e, p = (Array.isArray(r) ? r : [r]).map(
564
564
  (u) => E(u, (d) => (!i || i(d)) && t(d))
565
565
  );
566
566
  try {
567
- return o(n, e.params), await (a ? It(s, a) : s);
567
+ return o(n, e.params), await (a ? qt(s, a) : s);
568
568
  } finally {
569
569
  p.forEach((u) => u());
570
570
  }
@@ -573,7 +573,7 @@ async function I(e, t, s, n = {}) {
573
573
  const {
574
574
  result: r,
575
575
  error: i
576
- } = await m({
576
+ } = await f({
577
577
  ...n,
578
578
  method: "web_app_invoke_custom_method",
579
579
  event: "custom_method_invoked",
@@ -585,21 +585,21 @@ async function I(e, t, s, n = {}) {
585
585
  capture: At(s)
586
586
  });
587
587
  if (i)
588
- throw l(ue, i);
588
+ throw m(de, i);
589
589
  return r;
590
590
  }
591
591
  function et(...e) {
592
592
  return e.map((t) => {
593
593
  if (typeof t == "string")
594
594
  return t;
595
- if (D(t))
595
+ if (N(t))
596
596
  return et(Object.entries(t).map((s) => s[1] && s[0]));
597
597
  if (Array.isArray(t))
598
598
  return et(...t);
599
599
  }).filter(Boolean).join(" ");
600
600
  }
601
- function wn(...e) {
602
- return e.reduce((t, s) => (D(s) && Object.entries(s).forEach(([n, r]) => {
601
+ function gn(...e) {
602
+ return e.reduce((t, s) => (N(s) && Object.entries(s).forEach(([n, r]) => {
603
603
  const i = et(t[n], r);
604
604
  i.length && (t[n] = i);
605
605
  }), t), {});
@@ -615,7 +615,7 @@ function Ot(e) {
615
615
  }
616
616
  class qe {
617
617
  constructor(t) {
618
- c(this, "ee", new U()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
618
+ h(this, "ee", new U()), h(this, "on", this.ee.on.bind(this.ee)), h(this, "off", this.ee.off.bind(this.ee)), this.state = t;
619
619
  }
620
620
  /**
621
621
  * Clones current state and returns its copy.
@@ -634,25 +634,25 @@ class qe {
634
634
  return this.state[t];
635
635
  }
636
636
  }
637
- class ot {
637
+ class it {
638
638
  constructor(t) {
639
- c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new qe(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);
639
+ h(this, "state"), h(this, "get"), h(this, "set"), h(this, "clone"), this.state = new qe(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);
640
640
  }
641
641
  }
642
- function qt(e, t) {
642
+ function Dt(e, t) {
643
643
  return (s) => S(t[s], e);
644
644
  }
645
- class at extends ot {
645
+ class ot extends it {
646
646
  constructor(t, s, n) {
647
- super(t), c(this, "supports"), this.supports = qt(s, n);
647
+ super(t), h(this, "supports"), this.supports = Dt(s, n);
648
648
  }
649
649
  }
650
- class Ne extends at {
650
+ class Oe extends ot {
651
651
  constructor(t, s, n) {
652
652
  super({ isVisible: t }, s, {
653
653
  show: "web_app_setup_back_button",
654
654
  hide: "web_app_setup_back_button"
655
- }), c(this, "on", (r, i) => r === "click" ? E("back_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? z("back_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
655
+ }), h(this, "on", (r, i) => r === "click" ? E("back_button_pressed", i) : this.state.on(r, i)), h(this, "off", (r, i) => r === "click" ? z("back_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
656
656
  }
657
657
  set isVisible(t) {
658
658
  this.set("isVisible", t), this.postEvent("web_app_setup_back_button", { is_visible: t });
@@ -676,11 +676,11 @@ class Ne extends at {
676
676
  this.isVisible = !0;
677
677
  }
678
678
  }
679
- function C() {
679
+ function x() {
680
680
  return typeof window > "u";
681
681
  }
682
- const Nt = A((e) => e instanceof Date ? e : new Date(x().parse(e) * 1e3), "Date");
683
- function ct(e, t) {
682
+ const Nt = k((e) => e instanceof Date ? e : new Date(C().parse(e) * 1e3), "Date");
683
+ function at(e, t) {
684
684
  return new j((s) => {
685
685
  if (typeof s != "string" && !(s instanceof URLSearchParams))
686
686
  throw T();
@@ -691,16 +691,16 @@ function ct(e, t) {
691
691
  });
692
692
  }, !1, t);
693
693
  }
694
- const De = f({
695
- id: x(),
696
- type: h(),
697
- title: h(),
694
+ const De = w({
695
+ id: C(),
696
+ type: c(),
697
+ title: c(),
698
698
  photoUrl: {
699
- type: h().optional(),
699
+ type: c().optional(),
700
700
  from: "photo_url"
701
701
  },
702
- username: h().optional()
703
- }, "Chat").optional(), wt = f({
702
+ username: c().optional()
703
+ }, "Chat").optional(), gt = w({
704
704
  addedToAttachmentMenu: {
705
705
  type: P().optional(),
706
706
  from: "added_to_attachment_menu"
@@ -710,10 +710,10 @@ const De = f({
710
710
  from: "allows_write_to_pm"
711
711
  },
712
712
  firstName: {
713
- type: h(),
713
+ type: c(),
714
714
  from: "first_name"
715
715
  },
716
- id: x(),
716
+ id: C(),
717
717
  isBot: {
718
718
  type: P().optional(),
719
719
  from: "is_bot"
@@ -723,80 +723,80 @@ const De = f({
723
723
  from: "is_premium"
724
724
  },
725
725
  languageCode: {
726
- type: h().optional(),
726
+ type: c().optional(),
727
727
  from: "language_code"
728
728
  },
729
729
  lastName: {
730
- type: h().optional(),
730
+ type: c().optional(),
731
731
  from: "last_name"
732
732
  },
733
733
  photoUrl: {
734
- type: h().optional(),
734
+ type: c().optional(),
735
735
  from: "photo_url"
736
736
  },
737
- username: h().optional()
737
+ username: c().optional()
738
738
  }, "User").optional();
739
- function Dt() {
740
- return ct({
739
+ function Bt() {
740
+ return at({
741
741
  authDate: {
742
742
  type: Nt(),
743
743
  from: "auth_date"
744
744
  },
745
745
  canSendAfter: {
746
- type: x().optional(),
746
+ type: C().optional(),
747
747
  from: "can_send_after"
748
748
  },
749
749
  chat: De,
750
750
  chatInstance: {
751
- type: h().optional(),
751
+ type: c().optional(),
752
752
  from: "chat_instance"
753
753
  },
754
754
  chatType: {
755
- type: h().optional(),
755
+ type: c().optional(),
756
756
  from: "chat_type"
757
757
  },
758
- hash: h(),
758
+ hash: c(),
759
759
  queryId: {
760
- type: h().optional(),
760
+ type: c().optional(),
761
761
  from: "query_id"
762
762
  },
763
- receiver: wt,
763
+ receiver: gt,
764
764
  startParam: {
765
- type: h().optional(),
765
+ type: c().optional(),
766
766
  from: "start_param"
767
767
  },
768
- user: wt
768
+ user: gt
769
769
  }, "InitData");
770
770
  }
771
- function Ve(e) {
771
+ function Ne(e) {
772
772
  return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
773
773
  }
774
774
  function Be(e) {
775
775
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
776
776
  }
777
- const Vt = A(
777
+ const Vt = k(
778
778
  (e) => {
779
- const t = St().optional();
780
- return Object.entries(rt(e)).reduce((s, [n, r]) => (s[Ve(n)] = t.parse(r), s), {});
779
+ const t = Ct().optional();
780
+ return Object.entries(nt(e)).reduce((s, [n, r]) => (s[Ne(n)] = t.parse(r), s), {});
781
781
  },
782
782
  "ThemeParams"
783
783
  );
784
- function Bt(e) {
785
- return ct({
784
+ function Mt(e) {
785
+ return at({
786
786
  botInline: {
787
787
  type: P().optional(),
788
788
  from: "tgWebAppBotInline"
789
789
  },
790
790
  initData: {
791
- type: Dt().optional(),
791
+ type: Bt().optional(),
792
792
  from: "tgWebAppData"
793
793
  },
794
794
  initDataRaw: {
795
- type: h().optional(),
795
+ type: c().optional(),
796
796
  from: "tgWebAppData"
797
797
  },
798
798
  platform: {
799
- type: h(),
799
+ type: c(),
800
800
  from: "tgWebAppPlatform"
801
801
  },
802
802
  showSettings: {
@@ -804,7 +804,7 @@ function Bt(e) {
804
804
  from: "tgWebAppShowSettings"
805
805
  },
806
806
  startParam: {
807
- type: h().optional(),
807
+ type: c().optional(),
808
808
  from: "tgWebAppStartParam"
809
809
  },
810
810
  themeParams: {
@@ -812,52 +812,52 @@ function Bt(e) {
812
812
  from: "tgWebAppThemeParams"
813
813
  },
814
814
  version: {
815
- type: h(),
815
+ type: c(),
816
816
  from: "tgWebAppVersion"
817
817
  }
818
818
  }).parse(e);
819
819
  }
820
- function Mt(e) {
821
- return Bt(
820
+ function $t(e) {
821
+ return Mt(
822
822
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
823
823
  );
824
824
  }
825
- function Me() {
826
- return Mt(window.location.href);
825
+ function Ve() {
826
+ return $t(window.location.href);
827
827
  }
828
- function $t() {
828
+ function Lt() {
829
829
  return performance.getEntriesByType("navigation")[0];
830
830
  }
831
- function $e() {
832
- const e = $t();
831
+ function Me() {
832
+ const e = Lt();
833
833
  if (!e)
834
834
  throw new Error("Unable to get first navigation entry.");
835
- return Mt(e.name);
835
+ return $t(e.name);
836
836
  }
837
- function Lt(e) {
837
+ function Ht(e) {
838
838
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
839
839
  }
840
- function Ht(e, t) {
841
- sessionStorage.setItem(Lt(e), JSON.stringify(t));
840
+ function Ut(e, t) {
841
+ sessionStorage.setItem(Ht(e), JSON.stringify(t));
842
842
  }
843
- function Ut(e) {
844
- const t = sessionStorage.getItem(Lt(e));
843
+ function Wt(e) {
844
+ const t = sessionStorage.getItem(Ht(e));
845
845
  try {
846
846
  return t ? JSON.parse(t) : void 0;
847
847
  } catch {
848
848
  }
849
849
  }
850
- function Le() {
851
- return Bt(Ut("launchParams") || "");
850
+ function $e() {
851
+ return Mt(Wt("launchParams") || "");
852
852
  }
853
- function He(e) {
853
+ function Le(e) {
854
854
  return JSON.stringify(
855
855
  Object.fromEntries(
856
856
  Object.entries(e).map(([t, s]) => [Be(t), s])
857
857
  )
858
858
  );
859
859
  }
860
- function Ue(e) {
860
+ function He(e) {
861
861
  const {
862
862
  initDataRaw: t,
863
863
  themeParams: s,
@@ -867,81 +867,71 @@ function Ue(e) {
867
867
  startParam: o,
868
868
  botInline: a
869
869
  } = e, p = new URLSearchParams();
870
- return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", He(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();
870
+ return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", Le(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();
871
871
  }
872
- function We(e) {
873
- Ht("launchParams", Ue(e));
872
+ function Ue(e) {
873
+ Ut("launchParams", He(e));
874
874
  }
875
- function Wt() {
875
+ function jt() {
876
876
  for (const e of [
877
877
  // Try to retrieve launch parameters from the current location. This method can return
878
878
  // nothing in case, location was changed and then page was reloaded.
879
- Me,
879
+ Ve,
880
880
  // Then, try using the lower level API - window.performance.
881
- $e,
881
+ Me,
882
882
  // Finally, try to extract launch parameters from the session storage.
883
- Le
883
+ $e
884
884
  ])
885
885
  try {
886
886
  const t = e();
887
- return We(t), t;
887
+ return Ue(t), t;
888
888
  } catch {
889
889
  }
890
890
  throw new Error("Unable to retrieve launch parameters from any known source.");
891
891
  }
892
- function jt() {
893
- const e = $t();
892
+ function Gt() {
893
+ const e = Lt();
894
894
  return !!(e && e.type === "reload");
895
895
  }
896
- function je() {
896
+ function We() {
897
897
  let e = 0;
898
898
  return () => (e += 1).toString();
899
899
  }
900
- const [Ge] = yt(je);
901
- function _(e, t) {
900
+ const [je] = vt(We);
901
+ function l(e, t) {
902
902
  return ({ ssr: s } = {}) => {
903
- let n;
904
- if (C()) {
905
- if (!s)
906
- throw l(
907
- nt,
908
- "ssr.options must be specified to initialize component on the server side"
909
- );
910
- n = s;
911
- } else
912
- n = Wt();
913
- const r = {
903
+ const n = x() ? {
904
+ version: "6.0",
905
+ themeParams: {},
906
+ platform: "unknown",
907
+ ...s || {}
908
+ } : jt(), r = {
914
909
  ...n,
915
- postEvent: "version" in n ? Oe(n.version) : () => {
916
- throw l(
917
- we,
918
- "postEvent function is forbidden to be called on the server side."
919
- );
920
- },
921
- createRequestId: Ge()
910
+ postEvent: x() ? () => null : Ie(n.version),
911
+ createRequestId: je()
922
912
  };
923
- if (C() || typeof e == "function")
913
+ if (x() || typeof e == "function")
924
914
  return typeof e == "function" ? e(r) : t(r);
925
915
  const i = t({
926
916
  ...r,
927
- state: jt() ? Ut(e) : void 0
917
+ state: Gt() ? Wt(e) : void 0
928
918
  }), o = (a) => (a.on("change", (p) => {
929
- Ht(e, p);
919
+ Ut(e, p);
930
920
  }), a);
931
921
  return i instanceof Promise ? i.then(o) : o(i);
932
922
  };
933
923
  }
934
- const ze = _("backButton", ({
924
+ const Ge = l("backButton", ({
935
925
  postEvent: e,
936
926
  version: t,
937
927
  state: s = { isVisible: !1 }
938
- }) => new Ne(s.isVisible, t, e));
939
- class V extends at {
928
+ }) => new Oe(s.isVisible, t, e));
929
+ class B extends ot {
940
930
  constructor() {
941
- super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
931
+ super(...arguments), h(this, "on", this.state.on.bind(this.state)), h(this, "off", this.state.off.bind(this.state));
942
932
  }
943
933
  }
944
- function Gt(e) {
934
+ function zt(e) {
945
935
  const t = e.available ? e : {
946
936
  available: !1,
947
937
  device_id: "",
@@ -959,14 +949,14 @@ function Gt(e) {
959
949
  accessGranted: t.access_granted
960
950
  };
961
951
  }
962
- class ft extends V {
952
+ class wt extends B {
963
953
  constructor({ postEvent: t, version: s, ...n }) {
964
954
  super(n, s, {
965
955
  auth: "web_app_biometry_request_auth",
966
956
  openSettings: "web_app_biometry_open_settings",
967
957
  requestAccess: "web_app_biometry_request_access",
968
958
  updateToken: "web_app_biometry_update_token"
969
- }), c(this, "postEvent"), c(this, "authPromise"), c(this, "accessPromise"), this.postEvent = t;
959
+ }), h(this, "postEvent"), h(this, "authPromise"), h(this, "accessPromise"), this.postEvent = t;
970
960
  }
971
961
  /**
972
962
  * Shows whether biometry is available.
@@ -996,7 +986,7 @@ class ft extends V {
996
986
  reason: t,
997
987
  ...s
998
988
  }) {
999
- return this.authPromise || (this.authPromise = m({
989
+ return this.authPromise || (this.authPromise = f({
1000
990
  ...s,
1001
991
  method: "web_app_biometry_request_auth",
1002
992
  event: "biometry_auth_requested",
@@ -1030,14 +1020,14 @@ class ft extends V {
1030
1020
  * @returns Promise with true, if access was granted.
1031
1021
  */
1032
1022
  requestAccess({ reason: t, ...s } = {}) {
1033
- return this.accessPromise || (this.accessPromise = m({
1023
+ return this.accessPromise || (this.accessPromise = f({
1034
1024
  ...s,
1035
1025
  postEvent: this.postEvent,
1036
1026
  method: "web_app_biometry_request_access",
1037
1027
  event: "biometry_info_received",
1038
1028
  params: { reason: t || "" }
1039
1029
  }).then((n) => {
1040
- const r = Gt(n);
1030
+ const r = zt(n);
1041
1031
  return this.set(r), r.accessGranted;
1042
1032
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1043
1033
  }
@@ -1059,7 +1049,7 @@ class ft extends V {
1059
1049
  */
1060
1050
  async updateToken({ token: t, ...s } = {}) {
1061
1051
  return ["removed", "updated"].includes(
1062
- (await m({
1052
+ (await f({
1063
1053
  ...s,
1064
1054
  postEvent: this.postEvent,
1065
1055
  method: "web_app_biometry_update_token",
@@ -1069,35 +1059,35 @@ class ft extends V {
1069
1059
  );
1070
1060
  }
1071
1061
  }
1072
- async function Ke(e) {
1073
- return Gt(
1074
- await m({
1062
+ async function ze(e) {
1063
+ return zt(
1064
+ await f({
1075
1065
  ...e || {},
1076
1066
  method: "web_app_biometry_get_info",
1077
1067
  event: "biometry_info_received"
1078
1068
  })
1079
1069
  );
1080
1070
  }
1081
- const Je = _("biometryManager", async ({ postEvent: e, version: t, state: s }) => {
1071
+ const Ke = l("biometryManager", async ({ postEvent: e, version: t, state: s }) => {
1082
1072
  if (s)
1083
- return new ft({ ...s, version: t, postEvent: e });
1084
- if (C())
1085
- throw l(
1086
- nt,
1073
+ return new wt({ ...s, version: t, postEvent: e });
1074
+ if (x())
1075
+ throw m(
1076
+ Pt,
1087
1077
  "BiometryManager cannot be instantiated on the server side without passing the ssr.state object."
1088
1078
  );
1089
- return new ft({
1090
- ...await Ke({ timeout: 1e3 }),
1079
+ return new wt({
1080
+ ...await ze({ timeout: 1e3 }),
1091
1081
  version: t,
1092
1082
  postEvent: e
1093
1083
  });
1094
1084
  });
1095
- class ht extends ot {
1085
+ class ht extends it {
1096
1086
  constructor() {
1097
- super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
1087
+ super(...arguments), h(this, "on", this.state.on.bind(this.state)), h(this, "off", this.state.off.bind(this.state));
1098
1088
  }
1099
1089
  }
1100
- class Qe extends ht {
1090
+ class Je extends ht {
1101
1091
  constructor(t, s) {
1102
1092
  super({ isConfirmationNeeded: t }), this.postEvent = s;
1103
1093
  }
@@ -1124,16 +1114,16 @@ class Qe extends ht {
1124
1114
  this.isConfirmationNeeded = !0;
1125
1115
  }
1126
1116
  }
1127
- const Fe = _("closingBehavior", ({
1117
+ const Qe = l("closingBehavior", ({
1128
1118
  postEvent: e,
1129
1119
  state: t = { isConfirmationNeeded: !1 }
1130
- }) => new Qe(t.isConfirmationNeeded, e));
1131
- class pt {
1120
+ }) => new Je(t.isConfirmationNeeded, e));
1121
+ class ct {
1132
1122
  constructor(t, s) {
1133
- c(this, "supports"), this.supports = qt(t, s);
1123
+ h(this, "supports"), this.supports = Dt(t, s);
1134
1124
  }
1135
1125
  }
1136
- function Ye(e) {
1126
+ function Fe(e) {
1137
1127
  if (Array.isArray(e))
1138
1128
  return e;
1139
1129
  if (typeof e == "string")
@@ -1145,9 +1135,9 @@ function Ye(e) {
1145
1135
  }
1146
1136
  throw T();
1147
1137
  }
1148
- class Ze extends j {
1138
+ class Ye extends j {
1149
1139
  constructor(t, s, n) {
1150
- super(Ye, s, n), c(this, "itemParser"), this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
1140
+ super(Fe, s, n), h(this, "itemParser"), this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
1151
1141
  }
1152
1142
  /**
1153
1143
  * Attempts to parse passed value
@@ -1163,13 +1153,13 @@ class Ze extends j {
1163
1153
  return this.itemParser = typeof t == "function" ? t : t.parse.bind(t), this;
1164
1154
  }
1165
1155
  }
1166
- function Xe(e) {
1167
- return new Ze((t) => t, !1, e);
1156
+ function Ze(e) {
1157
+ return new Ye((t) => t, !1, e);
1168
1158
  }
1169
- function mt(e, t) {
1159
+ function ft(e, t) {
1170
1160
  return Object.fromEntries(e.map((s) => [s, t]));
1171
1161
  }
1172
- class ts extends pt {
1162
+ class Xe extends ct {
1173
1163
  constructor(t, s, n) {
1174
1164
  super(t, {
1175
1165
  delete: "web_app_invoke_custom_method",
@@ -1197,7 +1187,7 @@ class ts extends pt {
1197
1187
  * @param options - request execution options.
1198
1188
  */
1199
1189
  async getKeys(t = {}) {
1200
- return Xe().of(h()).parse(
1190
+ return Ze().of(c()).parse(
1201
1191
  await I(
1202
1192
  "getStorageKeys",
1203
1193
  {},
@@ -1209,13 +1199,13 @@ class ts extends pt {
1209
1199
  async get(t, s = {}) {
1210
1200
  const n = Array.isArray(t) ? t : [t];
1211
1201
  if (!n.length)
1212
- return mt(n, "");
1202
+ return ft(n, "");
1213
1203
  const r = await I(
1214
1204
  "getStorageValues",
1215
1205
  { keys: n },
1216
1206
  this.createRequestId(),
1217
1207
  { ...s, postEvent: this.postEvent }
1218
- ), i = f(mt(n, h()), "CloudStorageData").parse(r);
1208
+ ), i = w(ft(n, c()), "CloudStorageData").parse(r);
1219
1209
  return Array.isArray(t) ? i : i[t];
1220
1210
  }
1221
1211
  /**
@@ -1233,10 +1223,10 @@ class ts extends pt {
1233
1223
  );
1234
1224
  }
1235
1225
  }
1236
- const es = _(
1237
- ({ createRequestId: e, postEvent: t, version: s }) => new ts(s, e, t)
1226
+ const ts = l(
1227
+ ({ createRequestId: e, postEvent: t, version: s }) => new Xe(s, e, t)
1238
1228
  );
1239
- class ss extends pt {
1229
+ class es extends ct {
1240
1230
  constructor(t, s) {
1241
1231
  super(t, {
1242
1232
  impactOccurred: "web_app_trigger_haptic_feedback",
@@ -1278,10 +1268,10 @@ class ss extends pt {
1278
1268
  this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
1279
1269
  }
1280
1270
  }
1281
- const ns = _(
1282
- ({ version: e, postEvent: t }) => new ss(e, t)
1271
+ const ss = l(
1272
+ ({ version: e, postEvent: t }) => new es(e, t)
1283
1273
  );
1284
- class rs {
1274
+ class ns {
1285
1275
  constructor(t) {
1286
1276
  this.initData = t;
1287
1277
  }
@@ -1354,13 +1344,13 @@ class rs {
1354
1344
  return this.initData.user;
1355
1345
  }
1356
1346
  }
1357
- const is = _(
1358
- ({ initData: e }) => e ? new rs(e) : void 0
1347
+ const rs = l(
1348
+ ({ initData: e }) => e ? new ns(e) : void 0
1359
1349
  );
1360
- function fn(e) {
1361
- return Dt().parse(e);
1350
+ function wn(e) {
1351
+ return Bt().parse(e);
1362
1352
  }
1363
- class os extends V {
1353
+ class is extends B {
1364
1354
  constructor(t, s, n) {
1365
1355
  super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
1366
1356
  }
@@ -1390,7 +1380,7 @@ class os extends V {
1390
1380
  }
1391
1381
  this.isOpened = !0;
1392
1382
  try {
1393
- return (await m({
1383
+ return (await f({
1394
1384
  method: "web_app_open_invoice",
1395
1385
  event: "invoice_closed",
1396
1386
  params: { slug: n },
@@ -1404,12 +1394,12 @@ class os extends V {
1404
1394
  }
1405
1395
  }
1406
1396
  }
1407
- const as = _(
1408
- ({ version: e, postEvent: t }) => new os(!1, e, t)
1397
+ const os = l(
1398
+ ({ version: e, postEvent: t }) => new is(!1, e, t)
1409
1399
  );
1410
- class cs extends ot {
1400
+ class as extends it {
1411
1401
  constructor({ postEvent: t, ...s }) {
1412
- super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ? E("main_button_pressed", r) : this.state.on(n, r)), c(this, "off", (n, r) => n === "click" ? z("main_button_pressed", r) : this.state.off(n, r)), this.postEvent = t;
1402
+ super(s), h(this, "postEvent"), h(this, "on", (n, r) => n === "click" ? E("main_button_pressed", r) : this.state.on(n, r)), h(this, "off", (n, r) => n === "click" ? z("main_button_pressed", r) : this.state.off(n, r)), this.postEvent = t;
1413
1403
  }
1414
1404
  /**
1415
1405
  * Sends current local state to the Telegram application.
@@ -1538,7 +1528,7 @@ class cs extends ot {
1538
1528
  return this.set(t), this.commit(), this;
1539
1529
  }
1540
1530
  }
1541
- const hs = _("mainButton", ({
1531
+ const hs = l("mainButton", ({
1542
1532
  postEvent: e,
1543
1533
  themeParams: t,
1544
1534
  state: s = {
@@ -1549,24 +1539,24 @@ const hs = _("mainButton", ({
1549
1539
  textColor: t.buttonTextColor || "#ffffff",
1550
1540
  backgroundColor: t.buttonColor || "#000000"
1551
1541
  }
1552
- }) => new cs({ ...s, postEvent: e }));
1553
- function ps() {
1554
- return ct({
1555
- contact: f({
1542
+ }) => new as({ ...s, postEvent: e }));
1543
+ function cs() {
1544
+ return at({
1545
+ contact: w({
1556
1546
  userId: {
1557
- type: x(),
1547
+ type: C(),
1558
1548
  from: "user_id"
1559
1549
  },
1560
1550
  phoneNumber: {
1561
- type: h(),
1551
+ type: c(),
1562
1552
  from: "phone_number"
1563
1553
  },
1564
1554
  firstName: {
1565
- type: h(),
1555
+ type: c(),
1566
1556
  from: "first_name"
1567
1557
  },
1568
1558
  lastName: {
1569
- type: h().optional(),
1559
+ type: c().optional(),
1570
1560
  from: "last_name"
1571
1561
  }
1572
1562
  }),
@@ -1574,21 +1564,21 @@ function ps() {
1574
1564
  type: Nt(),
1575
1565
  from: "auth_date"
1576
1566
  },
1577
- hash: h()
1567
+ hash: c()
1578
1568
  }, "RequestedContact");
1579
1569
  }
1580
- function zt(e, t) {
1570
+ function Kt(e, t) {
1581
1571
  return (s) => {
1582
1572
  const [n, r] = t[s];
1583
1573
  return S(n, r, e);
1584
1574
  };
1585
1575
  }
1586
- function us(e) {
1576
+ function ps(e) {
1587
1577
  return new Promise((t) => {
1588
1578
  setTimeout(t, e);
1589
1579
  });
1590
1580
  }
1591
- class ds extends V {
1581
+ class us extends B {
1592
1582
  constructor({ postEvent: t, createRequestId: s, version: n, botInline: r, ...i }) {
1593
1583
  super(i, n, {
1594
1584
  requestPhoneAccess: "web_app_request_phone",
@@ -1596,9 +1586,9 @@ class ds extends V {
1596
1586
  switchInlineQuery: "web_app_switch_inline_query",
1597
1587
  setHeaderColor: "web_app_set_header_color",
1598
1588
  setBackgroundColor: "web_app_set_background_color"
1599
- }), 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;
1589
+ }), h(this, "botInline"), h(this, "postEvent"), h(this, "createRequestId"), h(this, "requestPhoneAccessPromise"), h(this, "requestWriteAccessPromise"), h(this, "supportsParam"), this.createRequestId = s, this.postEvent = t, this.botInline = r;
1600
1590
  const o = this.supports.bind(this);
1601
- this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = zt(n, {
1591
+ this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Kt(n, {
1602
1592
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1603
1593
  });
1604
1594
  }
@@ -1609,7 +1599,7 @@ class ds extends V {
1609
1599
  async getRequestedContact({
1610
1600
  timeout: t = 1e4
1611
1601
  } = {}) {
1612
- return ps().parse(
1602
+ return cs().parse(
1613
1603
  await I(
1614
1604
  "getRequestedContact",
1615
1605
  {},
@@ -1678,15 +1668,15 @@ class ds extends V {
1678
1668
  throw new Error("Access denied.");
1679
1669
  const s = Date.now() + t;
1680
1670
  let n = 50;
1681
- return It(async () => {
1671
+ return qt(async () => {
1682
1672
  for (; Date.now() < s; ) {
1683
1673
  try {
1684
1674
  return await this.getRequestedContact();
1685
1675
  } catch {
1686
1676
  }
1687
- await us(n), n += 50;
1677
+ await ps(n), n += 50;
1688
1678
  }
1689
- throw kt(t);
1679
+ throw It(t);
1690
1680
  }, t);
1691
1681
  }
1692
1682
  /**
@@ -1699,7 +1689,7 @@ class ds extends V {
1699
1689
  * @see requestContact
1700
1690
  */
1701
1691
  async requestPhoneAccess(t = {}) {
1702
- return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = m({
1692
+ return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = f({
1703
1693
  ...t,
1704
1694
  method: "web_app_request_phone",
1705
1695
  event: "phone_requested",
@@ -1711,7 +1701,7 @@ class ds extends V {
1711
1701
  * @param options - additional options.
1712
1702
  */
1713
1703
  async requestWriteAccess(t = {}) {
1714
- return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = m({
1704
+ return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = f({
1715
1705
  ...t,
1716
1706
  method: "web_app_request_write_access",
1717
1707
  event: "write_access_requested",
@@ -1741,7 +1731,7 @@ class ds extends V {
1741
1731
  * @param color - color key or RGB color.
1742
1732
  */
1743
1733
  setHeaderColor(t) {
1744
- this.postEvent("web_app_set_header_color", it(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
1734
+ this.postEvent("web_app_set_header_color", rt(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
1745
1735
  }
1746
1736
  /**
1747
1737
  * Updates current Mini App background color.
@@ -1769,7 +1759,7 @@ class ds extends V {
1769
1759
  this.postEvent("web_app_switch_inline_query", { query: t, chat_types: s });
1770
1760
  }
1771
1761
  }
1772
- const ls = _("miniApp", ({
1762
+ const ds = l("miniApp", ({
1773
1763
  themeParams: e,
1774
1764
  botInline: t = !1,
1775
1765
  state: s = {
@@ -1777,8 +1767,8 @@ const ls = _("miniApp", ({
1777
1767
  headerColor: e.headerBgColor || "#000000"
1778
1768
  },
1779
1769
  ...n
1780
- }) => new ds({ ...n, ...s, botInline: t }));
1781
- function _s(e) {
1770
+ }) => new us({ ...n, ...s, botInline: t }));
1771
+ function ls(e) {
1782
1772
  const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
1783
1773
  let r;
1784
1774
  if (s.length > 64)
@@ -1802,7 +1792,7 @@ function _s(e) {
1802
1792
  return { ...i, id: o };
1803
1793
  }) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
1804
1794
  }
1805
- class gs extends V {
1795
+ class _s extends B {
1806
1796
  constructor(t, s, n) {
1807
1797
  super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
1808
1798
  }
@@ -1831,11 +1821,11 @@ class gs extends V {
1831
1821
  throw new Error("Popup is already opened.");
1832
1822
  this.isOpened = !0;
1833
1823
  try {
1834
- const { button_id: s = null } = await m({
1824
+ const { button_id: s = null } = await f({
1835
1825
  event: "popup_closed",
1836
1826
  method: "web_app_open_popup",
1837
1827
  postEvent: this.postEvent,
1838
- params: _s(t)
1828
+ params: ls(t)
1839
1829
  });
1840
1830
  return s;
1841
1831
  } finally {
@@ -1843,10 +1833,10 @@ class gs extends V {
1843
1833
  }
1844
1834
  }
1845
1835
  }
1846
- const ws = _(
1847
- ({ postEvent: e, version: t }) => new gs(!1, t, e)
1836
+ const gs = l(
1837
+ ({ postEvent: e, version: t }) => new _s(!1, t, e)
1848
1838
  );
1849
- class fs extends V {
1839
+ class ws extends B {
1850
1840
  constructor(t, s, n) {
1851
1841
  super({ isOpened: t }, s, {
1852
1842
  close: "web_app_close_scan_qr_popup",
@@ -1879,7 +1869,7 @@ class fs extends V {
1879
1869
  throw new Error("QR scanner is already opened.");
1880
1870
  this.isOpened = !0;
1881
1871
  try {
1882
- return (await m({
1872
+ return (await f({
1883
1873
  method: "web_app_open_scan_qr_popup",
1884
1874
  event: ["qr_text_received", "scan_qr_popup_closed"],
1885
1875
  postEvent: this.postEvent,
@@ -1890,15 +1880,15 @@ class fs extends V {
1890
1880
  }
1891
1881
  }
1892
1882
  }
1893
- const ms = _(
1894
- ({ version: e, postEvent: t }) => new fs(!1, e, t)
1883
+ const fs = l(
1884
+ ({ version: e, postEvent: t }) => new ws(!1, e, t)
1895
1885
  );
1896
- class bs extends at {
1886
+ class ms extends ot {
1897
1887
  constructor(t, s, n) {
1898
1888
  super({ isVisible: t }, s, {
1899
1889
  show: "web_app_setup_settings_button",
1900
1890
  hide: "web_app_setup_settings_button"
1901
- }), c(this, "on", (r, i) => r === "click" ? E("settings_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? z("settings_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
1891
+ }), h(this, "on", (r, i) => r === "click" ? E("settings_button_pressed", i) : this.state.on(r, i)), h(this, "off", (r, i) => r === "click" ? z("settings_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
1902
1892
  }
1903
1893
  set isVisible(t) {
1904
1894
  this.set("isVisible", t), this.postEvent("web_app_setup_settings_button", { is_visible: t });
@@ -1922,15 +1912,15 @@ class bs extends at {
1922
1912
  this.isVisible = !0;
1923
1913
  }
1924
1914
  }
1925
- const vs = _("settingsButton", ({
1915
+ const bs = l("settingsButton", ({
1926
1916
  version: e,
1927
1917
  postEvent: t,
1928
1918
  state: s = { isVisible: !1 }
1929
- }) => new bs(s.isVisible, e, t));
1930
- function Kt(e) {
1919
+ }) => new ms(s.isVisible, e, t));
1920
+ function Jt(e) {
1931
1921
  return Vt().parse(e);
1932
1922
  }
1933
- class ys extends ht {
1923
+ class vs extends ht {
1934
1924
  /**
1935
1925
  * @since v6.10
1936
1926
  */
@@ -1995,7 +1985,7 @@ class ys extends ht {
1995
1985
  */
1996
1986
  listen() {
1997
1987
  return E("theme_changed", (t) => {
1998
- this.set(Kt(t.theme_params));
1988
+ this.set(Jt(t.theme_params));
1999
1989
  });
2000
1990
  }
2001
1991
  /**
@@ -2008,20 +1998,20 @@ class ys extends ht {
2008
1998
  return this.get("textColor");
2009
1999
  }
2010
2000
  }
2011
- const Es = _("themeParams", ({ themeParams: e, state: t = e }) => {
2012
- const s = new ys(t);
2013
- return C() || s.listen(), s;
2001
+ const ys = l("themeParams", ({ themeParams: e, state: t = e }) => {
2002
+ const s = new vs(t);
2003
+ return x() || s.listen(), s;
2014
2004
  });
2015
- function mn(e = {}) {
2016
- return m({
2005
+ function fn(e = {}) {
2006
+ return f({
2017
2007
  ...e,
2018
2008
  method: "web_app_request_theme",
2019
2009
  event: "theme_changed"
2020
- }).then(Kt);
2010
+ }).then(Jt);
2021
2011
  }
2022
- class Ps extends pt {
2012
+ class Es extends ct {
2023
2013
  constructor(t, s, n) {
2024
- 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, {
2014
+ super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), h(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Kt(t, {
2025
2015
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2026
2016
  });
2027
2017
  }
@@ -2070,7 +2060,7 @@ class Ps extends pt {
2070
2060
  async readTextFromClipboard() {
2071
2061
  const t = this.createRequestId(), {
2072
2062
  data: s = null
2073
- } = await m({
2063
+ } = await f({
2074
2064
  method: "web_app_read_text_from_clipboard",
2075
2065
  event: "clipboard_text_received",
2076
2066
  postEvent: this.postEvent,
@@ -2080,32 +2070,32 @@ class Ps extends pt {
2080
2070
  return s;
2081
2071
  }
2082
2072
  }
2083
- const Rs = _(
2084
- ({ version: e, postEvent: t, createRequestId: s }) => new Ps(e, s, t)
2073
+ const Ps = l(
2074
+ ({ version: e, postEvent: t, createRequestId: s }) => new Es(e, s, t)
2085
2075
  );
2086
- async function Jt(e = {}) {
2076
+ async function Qt(e = {}) {
2087
2077
  const {
2088
2078
  is_expanded: t,
2089
2079
  is_state_stable: s,
2090
2080
  ...n
2091
- } = await m({
2081
+ } = await f({
2092
2082
  ...e,
2093
2083
  method: "web_app_request_viewport",
2094
2084
  event: "viewport_changed"
2095
2085
  });
2096
2086
  return { ...n, isExpanded: t, isStateStable: s };
2097
2087
  }
2098
- function k(e) {
2088
+ function A(e) {
2099
2089
  return e < 0 ? 0 : e;
2100
2090
  }
2101
- class Qt extends ht {
2091
+ class Ft extends ht {
2102
2092
  constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
2103
2093
  super({
2104
- height: k(n),
2094
+ height: A(n),
2105
2095
  isExpanded: i,
2106
- stableHeight: k(s),
2107
- width: k(r)
2108
- }), c(this, "postEvent"), this.postEvent = t;
2096
+ stableHeight: A(s),
2097
+ width: A(r)
2098
+ }), h(this, "postEvent"), this.postEvent = t;
2109
2099
  }
2110
2100
  /**
2111
2101
  * Requests viewport information from the Telegram application and updates current Viewport
@@ -2113,7 +2103,7 @@ class Qt extends ht {
2113
2103
  * @param options - options to request fresh data.
2114
2104
  */
2115
2105
  async sync(t) {
2116
- const { isStateStable: s, ...n } = await Jt(t);
2106
+ const { isStateStable: s, ...n } = await Qt(t);
2117
2107
  this.set({
2118
2108
  ...n,
2119
2109
  stableHeight: s ? n.height : this.get("stableHeight")
@@ -2166,11 +2156,11 @@ class Qt extends ht {
2166
2156
  width: n,
2167
2157
  is_expanded: r,
2168
2158
  is_state_stable: i
2169
- } = t, o = k(s);
2159
+ } = t, o = A(s);
2170
2160
  this.set({
2171
2161
  height: o,
2172
2162
  isExpanded: r,
2173
- width: k(n),
2163
+ width: A(n),
2174
2164
  ...i ? { stableHeight: o } : {}
2175
2165
  });
2176
2166
  });
@@ -2205,14 +2195,14 @@ class Qt extends ht {
2205
2195
  return this.stableHeight === this.height;
2206
2196
  }
2207
2197
  }
2208
- async function xs(e, t = {}) {
2198
+ async function Rs(e, t = {}) {
2209
2199
  const {
2210
2200
  height: s,
2211
2201
  width: n,
2212
2202
  isExpanded: r,
2213
2203
  isStateStable: i
2214
- } = await Jt({ ...t, postEvent: e });
2215
- return new Qt({
2204
+ } = await Qt({ ...t, postEvent: e });
2205
+ return new Ft({
2216
2206
  postEvent: e,
2217
2207
  height: s,
2218
2208
  width: n,
@@ -2220,13 +2210,13 @@ async function xs(e, t = {}) {
2220
2210
  stableHeight: i ? s : 0
2221
2211
  });
2222
2212
  }
2223
- function Ss({
2213
+ function xs({
2224
2214
  state: e,
2225
2215
  platform: t,
2226
2216
  postEvent: s
2227
2217
  }) {
2228
2218
  let n = !1, r = 0, i = 0, o = 0;
2229
- return e ? (n = e.isExpanded, r = e.height, i = e.width, o = e.stableHeight) : ["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t) && (n = !0, r = window.innerHeight, i = window.innerWidth, o = window.innerHeight), new Qt({
2219
+ return e ? (n = e.isExpanded, r = e.height, i = e.width, o = e.stableHeight) : ["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t) && (n = !0, r = window.innerHeight, i = window.innerWidth, o = window.innerHeight), new Ft({
2230
2220
  postEvent: s,
2231
2221
  height: r,
2232
2222
  width: i,
@@ -2234,26 +2224,26 @@ function Ss({
2234
2224
  isExpanded: n
2235
2225
  });
2236
2226
  }
2237
- const Cs = _(
2227
+ const Cs = l(
2238
2228
  "viewport",
2239
2229
  async (e) => {
2240
- if (C() && !e.state)
2241
- throw l(
2242
- nt,
2230
+ if (x() && !e.state)
2231
+ throw m(
2232
+ Pt,
2243
2233
  "Viewport cannot be instantiated on the server side without passing the ssr.state object."
2244
2234
  );
2245
- let t = Ss(e);
2246
- return C() || (t.width === 0 && await xs(e.postEvent, { timeout: 1e3 }).then((s) => t = s).catch((s) => H.error("Unable to sync viewport state", s)), t.listen()), t;
2235
+ let t = xs(e);
2236
+ return x() || (t.width === 0 && await Rs(e.postEvent, { timeout: 1e3 }).then((s) => t = s).catch((s) => H.error("Unable to sync viewport state", s)), t.listen()), t;
2247
2237
  }
2248
2238
  );
2249
2239
  function R(e, t) {
2250
2240
  document.documentElement.style.setProperty(e, t);
2251
2241
  }
2252
- function bn(e, t, s) {
2242
+ function mn(e, t, s) {
2253
2243
  s || (s = (a) => `--tg-${a}-color`);
2254
2244
  const n = s("header"), r = s("bg"), i = () => {
2255
2245
  const { headerColor: a } = e;
2256
- if (it(a))
2246
+ if (rt(a))
2257
2247
  R(n, a);
2258
2248
  else {
2259
2249
  const { bgColor: p, secondaryBgColor: u } = t;
@@ -2266,7 +2256,7 @@ function bn(e, t, s) {
2266
2256
  ];
2267
2257
  return i(), () => o.forEach((a) => a());
2268
2258
  }
2269
- function vn(e, t) {
2259
+ function bn(e, t) {
2270
2260
  t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
2271
2261
  const s = () => {
2272
2262
  Object.entries(e.getState()).forEach(([n, r]) => {
@@ -2275,7 +2265,7 @@ function vn(e, t) {
2275
2265
  };
2276
2266
  return s(), e.on("change", s);
2277
2267
  }
2278
- function yn(e, t) {
2268
+ function vn(e, t) {
2279
2269
  t || (t = (u) => `--tg-viewport-${u}`);
2280
2270
  const [
2281
2271
  s,
@@ -2288,10 +2278,10 @@ function yn(e, t) {
2288
2278
  ];
2289
2279
  return i(), o(), a(), () => p.forEach((u) => u());
2290
2280
  }
2291
- function Ts(e = !0) {
2281
+ function Ss(e = !0) {
2292
2282
  const t = [
2293
2283
  E("reload_iframe", () => {
2294
- q("iframe_will_reload"), window.location.reload();
2284
+ O("iframe_will_reload"), window.location.reload();
2295
2285
  })
2296
2286
  ], s = () => t.forEach((n) => n());
2297
2287
  if (e) {
@@ -2303,20 +2293,22 @@ function Ts(e = !0) {
2303
2293
  () => document.head.removeChild(n)
2304
2294
  );
2305
2295
  }
2306
- return q("iframe_ready", { reload_supported: !0 }), s;
2296
+ return O("iframe_ready", { reload_supported: !0 }), s;
2307
2297
  }
2308
- async function En() {
2298
+ async function yn() {
2299
+ if (St(window))
2300
+ return !0;
2309
2301
  try {
2310
- return await m({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
2302
+ return await f({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
2311
2303
  } catch {
2312
2304
  return !1;
2313
2305
  }
2314
2306
  }
2315
- function As(e) {
2307
+ function Ts(e) {
2316
2308
  return e instanceof W;
2317
2309
  }
2318
- function Pn(e, t) {
2319
- return As(e) && e.type === t;
2310
+ function En(e, t) {
2311
+ return Ts(e) && e.type === t;
2320
2312
  }
2321
2313
  function J(e, t) {
2322
2314
  let s, n, r;
@@ -2327,12 +2319,12 @@ function J(e, t) {
2327
2319
  });
2328
2320
  }
2329
2321
  class ks {
2330
- constructor(t, s, n = q) {
2331
- if (c(this, "history"), c(this, "ee", new U()), 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)
2332
- throw l(_e, "History should not be empty.");
2322
+ constructor(t, s, n = O) {
2323
+ if (h(this, "history"), h(this, "ee", new U()), h(this, "attached", !1), h(this, "back", () => this.go(-1)), h(this, "on", this.ee.on.bind(this.ee)), h(this, "off", this.ee.off.bind(this.ee)), this._index = s, this.postEvent = n, t.length === 0)
2324
+ throw m(ge, "History should not be empty.");
2333
2325
  if (s < 0 || s >= t.length)
2334
- throw l(
2335
- ge,
2326
+ throw m(
2327
+ we,
2336
2328
  "Index should not be zero and higher or equal than history size."
2337
2329
  );
2338
2330
  this.history = t.map((r) => J(r, ""));
@@ -2453,12 +2445,12 @@ function Q({
2453
2445
  }) {
2454
2446
  return { ...e || { hash: "", search: "" }, ...t };
2455
2447
  }
2456
- function N(e, t) {
2448
+ function D(e, t) {
2457
2449
  return e.startsWith(t) ? e : `${t}${e}`;
2458
2450
  }
2459
2451
  function $(e) {
2460
2452
  return new URL(
2461
- typeof e == "string" ? e : `${e.pathname || ""}${N(e.search || "", "?")}${N(e.hash || "", "#")}`,
2453
+ typeof e == "string" ? e : `${e.pathname || ""}${D(e.search || "", "?")}${D(e.hash || "", "#")}`,
2462
2454
  "http://a"
2463
2455
  );
2464
2456
  }
@@ -2469,10 +2461,10 @@ function L(e) {
2469
2461
  function F(e, t, s) {
2470
2462
  let n, r;
2471
2463
  typeof e == "string" ? n = e : (n = L(e), s = e.state, r = e.id);
2472
- const { pathname: i, search: o, hash: a } = new URL(n, `http://a${N(t, "/")}`);
2464
+ const { pathname: i, search: o, hash: a } = new URL(n, `http://a${D(t, "/")}`);
2473
2465
  return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
2474
2466
  }
2475
- async function O(e) {
2467
+ async function q(e) {
2476
2468
  return e === 0 ? !0 : Promise.race([
2477
2469
  new Promise((t) => {
2478
2470
  const s = tt("popstate", () => {
@@ -2486,24 +2478,24 @@ async function O(e) {
2486
2478
  })
2487
2479
  ]);
2488
2480
  }
2489
- async function Is() {
2490
- if (window.history.length <= 1 || (window.history.pushState(null, ""), await O(1 - window.history.length)))
2481
+ async function As() {
2482
+ if (window.history.length <= 1 || (window.history.pushState(null, ""), await q(1 - window.history.length)))
2491
2483
  return;
2492
- let e = await O(-1);
2484
+ let e = await q(-1);
2493
2485
  for (; e; )
2494
- e = await O(-1);
2486
+ e = await q(-1);
2495
2487
  }
2496
- function Ft(e) {
2488
+ function Yt(e) {
2497
2489
  return $(e).pathname;
2498
2490
  }
2499
- const bt = 0, Y = 1, Z = 2;
2500
- class Yt {
2491
+ const mt = 0, Y = 1, Z = 2;
2492
+ class Zt {
2501
2493
  constructor(t, s, { postEvent: n, hashMode: r, base: i } = {}) {
2502
- c(this, "navigator"), c(this, "ee", new U()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
2494
+ h(this, "navigator"), h(this, "ee", new U()), h(this, "hashMode"), h(this, "base"), h(this, "attached", !1), h(this, "onPopState", ({ state: o }) => {
2503
2495
  if (o === null)
2504
2496
  return this.push(this.parsePath(window.location.href));
2505
- o === bt ? window.history.forward() : o === Y && this.back(), o === Z && this.forward();
2506
- }), c(this, "onNavigatorChange", async ({
2497
+ o === mt ? window.history.forward() : o === Y && this.back(), o === Z && this.forward();
2498
+ }), h(this, "onNavigatorChange", async ({
2507
2499
  to: o,
2508
2500
  from: a,
2509
2501
  delta: p
@@ -2514,11 +2506,11 @@ class Yt {
2514
2506
  to: Q(o),
2515
2507
  navigator: this
2516
2508
  });
2517
- }), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new ks(
2509
+ }), h(this, "on", this.ee.on.bind(this.ee)), h(this, "off", this.ee.off.bind(this.ee)), this.navigator = new ks(
2518
2510
  t.map((o) => F(o, "/")),
2519
2511
  s,
2520
2512
  n
2521
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Ft(i || "");
2513
+ ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Yt(i || "");
2522
2514
  }
2523
2515
  /**
2524
2516
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2666,8 +2658,8 @@ class Yt {
2666
2658
  * @param value - path presented as string or URLLike.
2667
2659
  */
2668
2660
  renderPath(t) {
2669
- const s = (this.base.length === 1 ? "" : this.base) + N(L(t), "/");
2670
- return this.hashMode ? N(s.slice(1), this.hashMode === "default" ? "#" : "#/") : s;
2661
+ const s = (this.base.length === 1 ? "" : this.base) + D(L(t), "/");
2662
+ return this.hashMode ? D(s.slice(1), this.hashMode === "default" ? "#" : "#/") : s;
2671
2663
  }
2672
2664
  /**
2673
2665
  * Synchronizes current navigator state with browser history.
@@ -2675,7 +2667,7 @@ class Yt {
2675
2667
  async syncHistory() {
2676
2668
  window.removeEventListener("popstate", this.onPopState);
2677
2669
  const { state: t } = this, s = this.renderPath(this);
2678
- await Is(), this.hasPrev && this.hasNext ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s), window.history.pushState(Z, ""), await O(-1)) : this.hasPrev ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(Z, ""), await O(-1)) : (window.history.replaceState(bt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2670
+ await As(), this.hasPrev && this.hasNext ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s), window.history.pushState(Z, ""), await q(-1)) : this.hasPrev ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(Z, ""), await q(-1)) : (window.history.replaceState(mt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2679
2671
  }
2680
2672
  /**
2681
2673
  * Current query parameters.
@@ -2693,66 +2685,66 @@ class Yt {
2693
2685
  return (this.navigator.current.params || {}).state;
2694
2686
  }
2695
2687
  }
2696
- function Os(e) {
2688
+ function Is(e) {
2697
2689
  e || (e = {});
2698
2690
  const { href: t, hash: s } = window.location;
2699
2691
  let n = L(
2700
2692
  e.hashMode ? s.includes("?") ? s.slice(1) : `?${s.slice(1)}` : t
2701
2693
  );
2702
- const r = e.base ? Ft(e.base) : void 0;
2694
+ const r = e.base ? Yt(e.base) : void 0;
2703
2695
  if (r) {
2704
2696
  if (!n.startsWith(r))
2705
- throw l(
2697
+ throw m(
2706
2698
  fe,
2707
2699
  `Path "${n}" expected to be starting with "${r}"`
2708
2700
  );
2709
2701
  n = n.slice(r.length);
2710
2702
  }
2711
- return new Yt([n], 0, e);
2703
+ return new Zt([n], 0, e);
2712
2704
  }
2713
- function Rn(e) {
2705
+ function Pn(e) {
2714
2706
  const t = e.match(/#(.+)/);
2715
2707
  return t ? t[1] : null;
2716
2708
  }
2717
2709
  function qs(e, t) {
2718
- if (jt()) {
2710
+ if (Gt()) {
2719
2711
  const s = sessionStorage.getItem(e);
2720
2712
  if (s)
2721
2713
  try {
2722
2714
  const { index: n, history: r } = JSON.parse(s);
2723
- return new Yt(r, n, t);
2715
+ return new Zt(r, n, t);
2724
2716
  } catch (n) {
2725
2717
  console.error("Unable to restore hash navigator state.", n);
2726
2718
  }
2727
2719
  }
2728
- return Os(t);
2720
+ return Is(t);
2729
2721
  }
2730
- function xn(e, t) {
2722
+ function Rn(e, t) {
2731
2723
  const s = qs(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2732
2724
  index: s.index,
2733
2725
  history: s.history
2734
2726
  }));
2735
2727
  return s.on("change", n), n(), s;
2736
2728
  }
2737
- function g(e, t) {
2729
+ function _(e, t) {
2738
2730
  function s(n) {
2739
2731
  return (r, i, o) => (a) => {
2740
2732
  const p = a[i] || [], u = { ...a, [r]: n(...p) };
2741
- return /* @__PURE__ */ vt(o, { ...u });
2733
+ return /* @__PURE__ */ bt(o, { ...u });
2742
2734
  };
2743
2735
  }
2744
2736
  return [s(e), s(t)];
2745
2737
  }
2746
- const Zt = Xt(void 0);
2747
- function Ns() {
2748
- const e = te(Zt);
2738
+ const Xt = te(void 0);
2739
+ function Os() {
2740
+ const e = ee(Xt);
2749
2741
  if (!e)
2750
2742
  throw new Error("useSDK was used outside the SDKProvider.");
2751
2743
  return e;
2752
2744
  }
2753
- function w(e) {
2745
+ function g(e) {
2754
2746
  const t = (...n) => {
2755
- const r = Ns();
2747
+ const r = Os();
2756
2748
  return st(() => r.use(e, ...n), [r]);
2757
2749
  };
2758
2750
  return [t, (...n) => {
@@ -2762,227 +2754,227 @@ function w(e) {
2762
2754
  return r.result;
2763
2755
  }];
2764
2756
  }
2765
- const [Ds, Vs] = w(ze), [Sn, Cn] = g(
2757
+ const [Ds, Ns] = g(Ge), [xn, Cn] = _(
2766
2758
  Ds,
2767
- Vs
2768
- ), [Bs, Ms] = w(Je), [Tn, An] = g(
2759
+ Ns
2760
+ ), [Bs, Vs] = g(Ke), [Sn, Tn] = _(
2769
2761
  Bs,
2770
- Ms
2771
- ), [$s, Ls] = w(Fe), [kn, In] = g(
2772
- $s,
2773
- Ls
2774
- ), [Hs, Us] = w(es), [On, qn] = g(
2775
- Hs,
2776
- Us
2777
- ), [Ws, js] = w(ns), [Nn, Dn] = g(
2778
- Ws,
2779
- js
2780
- ), [Gs, zs] = w(is), [Vn, Bn] = g(Gs, zs), [Ks, Js] = w(as), [Mn, $n] = g(Ks, Js), [Qs, Fs] = w(hs), [Ln, Hn] = g(Qs, Fs), [Ys, Zs] = w(ls), [Un, Wn] = g(Ys, Zs), [Xs, tn] = w(ws), [jn, Gn] = g(Xs, tn), [en, sn] = w(ms), [zn, Kn] = g(en, sn), [nn, rn] = w(vs), [Jn, Qn] = g(
2781
- nn,
2782
- rn
2783
- ), [on, an] = w(Es), [Fn, Yn] = g(on, an);
2784
- function Zn() {
2785
- return st(Wt, []);
2786
- }
2787
- const [cn, hn] = w(Rs), [Xn, tr] = g(cn, hn), [pn, un] = w(Cs), [er, sr] = g(pn, un);
2788
- function nr({ children: e, acceptCustomStyles: t, debug: s }) {
2789
- const n = lt(!0), [r, i] = ee(
2762
+ Vs
2763
+ ), [Ms, $s] = g(Qe), [kn, An] = _(
2764
+ Ms,
2765
+ $s
2766
+ ), [Ls, Hs] = g(ts), [In, qn] = _(
2767
+ Ls,
2768
+ Hs
2769
+ ), [Us, Ws] = g(ss), [On, Dn] = _(
2770
+ Us,
2771
+ Ws
2772
+ ), [js, Gs] = g(rs), [Nn, Bn] = _(js, Gs), [zs, Ks] = g(os), [Vn, Mn] = _(zs, Ks), [Js, Qs] = g(hs), [$n, Ln] = _(Js, Qs), [Fs, Ys] = g(ds), [Hn, Un] = _(Fs, Ys), [Zs, Xs] = g(gs), [Wn, jn] = _(Zs, Xs), [tn, en] = g(fs), [Gn, zn] = _(tn, en), [sn, nn] = g(bs), [Kn, Jn] = _(
2773
+ sn,
2774
+ nn
2775
+ ), [rn, on] = g(ys), [Qn, Fn] = _(rn, on);
2776
+ function Yn() {
2777
+ return st(jt, []);
2778
+ }
2779
+ const [an, hn] = g(Ps), [Zn, Xn] = _(an, hn), [cn, pn] = g(Cs), [tr, er] = _(cn, pn);
2780
+ function sr({ children: e, acceptCustomStyles: t, debug: s }) {
2781
+ const n = dt(!0), [r, i] = se(
2790
2782
  () => /* @__PURE__ */ new Map()
2791
- ), o = _t((d) => {
2792
- n.current && i((B) => (d && d(B), new Map(B)));
2793
- }, []), a = _t(() => o(), [o]), p = lt([]), u = st(() => ({
2794
- use(d, ...B) {
2795
- const ut = r.get(d);
2796
- if (ut)
2797
- return ut;
2783
+ ), o = lt((d) => {
2784
+ n.current && i((V) => (d && d(V), new Map(V)));
2785
+ }, []), a = lt(() => o(), [o]), p = dt([]), u = st(() => ({
2786
+ use(d, ...V) {
2787
+ const pt = r.get(d);
2788
+ if (pt)
2789
+ return pt;
2798
2790
  let b;
2799
2791
  try {
2800
- b = { result: d(...B) };
2792
+ b = { result: d(...V) };
2801
2793
  } catch (v) {
2802
2794
  b = { error: v };
2803
2795
  }
2804
2796
  if ("error" in b || !b.result)
2805
2797
  return r.set(d, b), b;
2806
- const dt = (v) => ("on" in v && (v.on("change", a), p.current.push(v)), { result: v });
2798
+ const ut = (v) => ("on" in v && (v.on("change", a), p.current.push(v)), { result: v });
2807
2799
  return b.result instanceof Promise ? (b.result.then(
2808
- (v) => o((K) => K.set(d, dt(v))),
2800
+ (v) => o((K) => K.set(d, ut(v))),
2809
2801
  (v) => o((K) => K.set(d, { error: v }))
2810
- ), r.set(d, {}), {}) : (r.set(d, b = dt(b.result)), b);
2802
+ ), r.set(d, {}), {}) : (r.set(d, b = ut(b.result)), b);
2811
2803
  }
2812
2804
  }), [r]);
2813
2805
  return M(() => {
2814
- oe(s || !1);
2806
+ ae(s || !1);
2815
2807
  }, [s]), M(() => () => {
2816
2808
  n.current = !1;
2817
2809
  }, []), M(() => {
2818
- if (Ct())
2819
- return Ts(t);
2820
- }, [t]), M(() => () => p.current.forEach((d) => d.off("change", a)), [a]), /* @__PURE__ */ vt(Zt.Provider, { value: u, children: e });
2810
+ if (Tt())
2811
+ return Ss(t);
2812
+ }, [t]), M(() => () => p.current.forEach((d) => d.off("change", a)), [a]), /* @__PURE__ */ bt(Xt.Provider, { value: u, children: e });
2821
2813
  }
2822
2814
  export {
2823
- Ne as BackButton,
2815
+ Oe as BackButton,
2824
2816
  ks as BasicNavigator,
2825
- ft as BiometryManager,
2826
- Yt as BrowserNavigator,
2827
- Qe as ClosingBehavior,
2828
- ts as CloudStorage,
2817
+ wt as BiometryManager,
2818
+ Zt as BrowserNavigator,
2819
+ Je as ClosingBehavior,
2820
+ Xe as CloudStorage,
2829
2821
  fe as ERR_INVALID_PATH_BASE,
2830
- ue as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2831
- he as ERR_METHOD_PARAMETER_UNSUPPORTED,
2822
+ de as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2823
+ pe as ERR_METHOD_PARAMETER_UNSUPPORTED,
2832
2824
  ce as ERR_METHOD_UNSUPPORTED,
2833
- _e as ERR_NAVIGATION_HISTORY_EMPTY,
2834
- ge as ERR_NAVIGATION_INDEX_INVALID,
2835
- _n as ERR_NAVIGATION_ITEM_INVALID,
2836
- Pt as ERR_PARSE,
2837
- nt as ERR_SSR_INIT,
2838
- we as ERR_SSR_POST_EVENT,
2839
- de as ERR_TIMED_OUT,
2840
- le as ERR_UNEXPECTED_TYPE,
2841
- pe as ERR_UNKNOWN_ENV,
2825
+ ge as ERR_NAVIGATION_HISTORY_EMPTY,
2826
+ we as ERR_NAVIGATION_INDEX_INVALID,
2827
+ ln as ERR_NAVIGATION_ITEM_INVALID,
2828
+ Et as ERR_PARSE,
2829
+ Pt as ERR_SSR_INIT,
2830
+ le as ERR_TIMED_OUT,
2831
+ _e as ERR_UNEXPECTED_TYPE,
2832
+ ue as ERR_UNKNOWN_ENV,
2842
2833
  U as EventEmitter,
2843
- ss as HapticFeedback,
2844
- rs as InitData,
2845
- os as Invoice,
2846
- cs as MainButton,
2847
- ds as MiniApp,
2848
- gs as Popup,
2849
- fs as QRScanner,
2834
+ es as HapticFeedback,
2835
+ ns as InitData,
2836
+ is as Invoice,
2837
+ as as MainButton,
2838
+ us as MiniApp,
2839
+ _s as Popup,
2840
+ ws as QRScanner,
2850
2841
  W as SDKError,
2851
- nr as SDKProvider,
2852
- bs as SettingsButton,
2853
- ys as ThemeParams,
2854
- Ps as Utils,
2855
- Qt as Viewport,
2856
- Xe as array,
2857
- bn as bindMiniAppCSSVars,
2858
- vn as bindThemeParamsCSSVars,
2859
- yn as bindViewportCSSVars,
2842
+ sr as SDKProvider,
2843
+ ms as SettingsButton,
2844
+ vs as ThemeParams,
2845
+ Es as Utils,
2846
+ Ft as Viewport,
2847
+ Ze as array,
2848
+ mn as bindMiniAppCSSVars,
2849
+ bn as bindThemeParamsCSSVars,
2850
+ vn as bindViewportCSSVars,
2860
2851
  P as boolean,
2861
2852
  At as captureSameReq,
2862
2853
  et as classNames,
2863
2854
  Te as compareVersions,
2864
- Os as createBrowserNavigatorFromLocation,
2865
- Oe as createPostEvent,
2855
+ Is as createBrowserNavigatorFromLocation,
2856
+ Ie as createPostEvent,
2866
2857
  $ as createSafeURL,
2867
2858
  Nt as date,
2868
- Rn as getHash,
2869
- Ft as getPathname,
2870
- ze as initBackButton,
2871
- Je as initBiometryManager,
2872
- Fe as initClosingBehavior,
2873
- es as initCloudStorage,
2874
- ns as initHapticFeedback,
2875
- is as initInitData,
2876
- as as initInvoice,
2859
+ Pn as getHash,
2860
+ Yt as getPathname,
2861
+ Ge as initBackButton,
2862
+ Ke as initBiometryManager,
2863
+ Qe as initClosingBehavior,
2864
+ ts as initCloudStorage,
2865
+ ss as initHapticFeedback,
2866
+ rs as initInitData,
2867
+ os as initInvoice,
2877
2868
  hs as initMainButton,
2878
- ls as initMiniApp,
2879
- xn as initNavigator,
2880
- ws as initPopup,
2881
- ms as initQRScanner,
2882
- vs as initSettingsButton,
2883
- Es as initThemeParams,
2884
- Rs as initUtils,
2869
+ ds as initMiniApp,
2870
+ Rn as initNavigator,
2871
+ gs as initPopup,
2872
+ fs as initQRScanner,
2873
+ bs as initSettingsButton,
2874
+ ys as initThemeParams,
2875
+ Ps as initUtils,
2885
2876
  Cs as initViewport,
2886
- Ts as initWeb,
2877
+ Ss as initWeb,
2887
2878
  I as invokeCustomMethod,
2888
2879
  Ot as isColorDark,
2889
- Ct as isIframe,
2890
- jt as isPageReload,
2891
- it as isRGB,
2880
+ Tt as isIframe,
2881
+ Gt as isPageReload,
2882
+ rt as isRGB,
2892
2883
  me as isRGBShort,
2893
- As as isSDKError,
2894
- Pn as isSDKErrorOfType,
2895
- En as isTMA,
2896
- f as json,
2897
- wn as mergeClassNames,
2898
- x as number,
2884
+ Ts as isSDKError,
2885
+ En as isSDKErrorOfType,
2886
+ x as isSSR,
2887
+ yn as isTMA,
2888
+ w as json,
2889
+ gn as mergeClassNames,
2890
+ C as number,
2899
2891
  z as off,
2900
2892
  E as on,
2901
- fn as parseInitData,
2902
- Bt as parseLaunchParams,
2903
- Kt as parseThemeParams,
2904
- q as postEvent,
2905
- m as request,
2906
- Ke as requestBiometryInfo,
2907
- mn as requestThemeParams,
2908
- Jt as requestViewport,
2909
- Wt as retrieveLaunchParams,
2910
- St as rgb,
2911
- ct as searchParams,
2912
- Ue as serializeLaunchParams,
2913
- He as serializeThemeParams,
2893
+ wn as parseInitData,
2894
+ Mt as parseLaunchParams,
2895
+ Jt as parseThemeParams,
2896
+ O as postEvent,
2897
+ f as request,
2898
+ ze as requestBiometryInfo,
2899
+ fn as requestThemeParams,
2900
+ Qt as requestViewport,
2901
+ jt as retrieveLaunchParams,
2902
+ Ct as rgb,
2903
+ at as searchParams,
2904
+ He as serializeLaunchParams,
2905
+ Le as serializeThemeParams,
2914
2906
  R as setCSSVar,
2915
- oe as setDebug,
2916
- gn as setTargetOrigin,
2917
- h as string,
2918
- re as subscribe,
2907
+ ae as setDebug,
2908
+ _n as setTargetOrigin,
2909
+ c as string,
2910
+ ie as subscribe,
2919
2911
  S as supports,
2920
- Ie as targetOrigin,
2912
+ Ae as targetOrigin,
2921
2913
  xt as toRGB,
2922
- Et as unsubscribe,
2914
+ yt as unsubscribe,
2923
2915
  L as urlToPath,
2924
- Vs as useBackButton,
2916
+ Ns as useBackButton,
2925
2917
  Ds as useBackButtonRaw,
2926
- Ms as useBiometryManager,
2918
+ Vs as useBiometryManager,
2927
2919
  Bs as useBiometryManagerRaw,
2928
- Ls as useClosingBehavior,
2929
- $s as useClosingBehaviorRaw,
2930
- Us as useCloudStorage,
2931
- Hs as useCloudStorageRaw,
2932
- js as useHapticFeedback,
2933
- Ws as useHapticFeedbackRaw,
2934
- zs as useInitData,
2935
- Gs as useInitDataRaw,
2936
- Js as useInvoice,
2937
- Ks as useInvoiceRaw,
2938
- Zn as useLaunchParams,
2939
- Fs as useMainButton,
2940
- Qs as useMainButtonRaw,
2941
- Zs as useMiniApp,
2942
- Ys as useMiniAppRaw,
2943
- tn as usePopup,
2944
- Xs as usePopupRaw,
2945
- sn as useQRScanner,
2946
- en as useQRScannerRaw,
2947
- Ns as useSDK,
2948
- rn as useSettingsButton,
2949
- nn as useSettingsButtonRaw,
2950
- an as useThemeParams,
2951
- on as useThemeParamsRaw,
2920
+ $s as useClosingBehavior,
2921
+ Ms as useClosingBehaviorRaw,
2922
+ Hs as useCloudStorage,
2923
+ Ls as useCloudStorageRaw,
2924
+ Ws as useHapticFeedback,
2925
+ Us as useHapticFeedbackRaw,
2926
+ Gs as useInitData,
2927
+ js as useInitDataRaw,
2928
+ Ks as useInvoice,
2929
+ zs as useInvoiceRaw,
2930
+ Yn as useLaunchParams,
2931
+ Qs as useMainButton,
2932
+ Js as useMainButtonRaw,
2933
+ Ys as useMiniApp,
2934
+ Fs as useMiniAppRaw,
2935
+ Xs as usePopup,
2936
+ Zs as usePopupRaw,
2937
+ en as useQRScanner,
2938
+ tn as useQRScannerRaw,
2939
+ Os as useSDK,
2940
+ nn as useSettingsButton,
2941
+ sn as useSettingsButtonRaw,
2942
+ on as useThemeParams,
2943
+ rn as useThemeParamsRaw,
2952
2944
  hn as useUtils,
2953
- cn as useUtilsRaw,
2954
- un as useViewport,
2955
- pn as useViewportRaw,
2945
+ an as useUtilsRaw,
2946
+ pn as useViewport,
2947
+ cn as useViewportRaw,
2956
2948
  Cn as withBackButton,
2957
- Sn as withBackButtonRaw,
2958
- An as withBiometryManager,
2959
- Tn as withBiometryManagerRaw,
2960
- In as withClosingBehavior,
2949
+ xn as withBackButtonRaw,
2950
+ Tn as withBiometryManager,
2951
+ Sn as withBiometryManagerRaw,
2952
+ An as withClosingBehavior,
2961
2953
  kn as withClosingBehaviorRaw,
2962
2954
  qn as withCloudStorage,
2963
- On as withCloudStorageRaw,
2955
+ In as withCloudStorageRaw,
2964
2956
  Dn as withHapticFeedback,
2965
- Nn as withHapticFeedbackRaw,
2957
+ On as withHapticFeedbackRaw,
2966
2958
  Bn as withInitData,
2967
- Vn as withInitDataRaw,
2968
- $n as withInvoice,
2969
- Mn as withInvoiceRaw,
2970
- Hn as withMainButton,
2971
- Ln as withMainButtonRaw,
2972
- Wn as withMiniApp,
2973
- Un as withMiniAppRaw,
2974
- Gn as withPopup,
2975
- jn as withPopupRaw,
2976
- Kn as withQRScanner,
2977
- zn as withQRScannerRaw,
2978
- Qn as withSettingsButton,
2979
- Jn as withSettingsButtonRaw,
2980
- Yn as withThemeParams,
2981
- Fn as withThemeParamsRaw,
2982
- It as withTimeout,
2983
- tr as withUtils,
2984
- Xn as withUtilsRaw,
2985
- sr as withViewport,
2986
- er as withViewportRaw
2959
+ Nn as withInitDataRaw,
2960
+ Mn as withInvoice,
2961
+ Vn as withInvoiceRaw,
2962
+ Ln as withMainButton,
2963
+ $n as withMainButtonRaw,
2964
+ Un as withMiniApp,
2965
+ Hn as withMiniAppRaw,
2966
+ jn as withPopup,
2967
+ Wn as withPopupRaw,
2968
+ zn as withQRScanner,
2969
+ Gn as withQRScannerRaw,
2970
+ Jn as withSettingsButton,
2971
+ Kn as withSettingsButtonRaw,
2972
+ Fn as withThemeParams,
2973
+ Qn as withThemeParamsRaw,
2974
+ qt as withTimeout,
2975
+ Xn as withUtils,
2976
+ Zn as withUtilsRaw,
2977
+ er as withViewport,
2978
+ tr as withViewportRaw
2987
2979
  };
2988
2980
  //# sourceMappingURL=index.js.map