@tma.js/sdk-react 2.1.1 → 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,19 +1,19 @@
1
- import { jsx as vt } from "react/jsx-runtime";
2
- import { createContext as te, useContext as ee, useMemo as st, useRef as lt, useState as se, useCallback as _t, 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, c = (e, t, s) => (re(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 && Te();
13
+ t.unsubscribe(e), s && !t.count && Se();
14
14
  }
15
15
  function ie(e) {
16
- return G().subscribe(e), () => Et(e);
16
+ return G().subscribe(e), () => yt(e);
17
17
  }
18
18
  class oe {
19
19
  constructor(t, s = {}) {
@@ -60,18 +60,18 @@ const H = new oe("SDK", {
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
66
  function ae(e) {
67
- X !== e && (X = e, e ? ie(gt) : Et(gt));
67
+ X !== e && (X = e, e ? ie(_t) : yt(_t));
68
68
  }
69
- function ce(...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 he = "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", Pt = "ERR_PARSE", ge = "ERR_NAVIGATION_LIST_EMPTY", we = "ERR_NAVIGATION_CURSOR_INVALID", _n = "ERR_NAVIGATION_ITEM_INVALID", nt = "ERR_SSR_INIT", fe = "ERR_SSR_POST_EVENT", me = "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(_e, "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,17 +237,17 @@ 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
- function be(e) {
243
+ function me(e) {
244
244
  return /^#[\da-f]{3}$/i.test(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
- if (be(t)) {
250
+ if (me(t)) {
251
251
  let n = "#";
252
252
  for (let r = 0; r < 3; r += 1)
253
253
  n += t[1 + r].repeat(2);
@@ -261,30 +261,30 @@ 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");
269
- function ve(e) {
270
- return f({
271
- eventType: h(),
268
+ }, "string"), Ct = k((e) => xt(c().parse(e)), "rgb");
269
+ function be(e) {
270
+ return w({
271
+ eventType: c(),
272
272
  eventData: (t) => t
273
273
  }).parse(e);
274
274
  }
275
- function ye() {
275
+ function ve() {
276
276
  ["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
277
277
  delete window[e];
278
278
  });
279
279
  }
280
- function Ee(e, t) {
280
+ function ye(e, t) {
281
281
  window.dispatchEvent(new MessageEvent("message", {
282
282
  data: JSON.stringify({ eventType: e, eventData: t }),
283
283
  // We specify window.parent to imitate the case, the parent iframe sent us this event.
284
284
  source: window.parent
285
285
  }));
286
286
  }
287
- function Pe() {
287
+ function Ee() {
288
288
  [
289
289
  ["TelegramGameProxy_receiveEvent"],
290
290
  // Windows Phone.
@@ -296,60 +296,60 @@ function Pe() {
296
296
  let t = window;
297
297
  e.forEach((s, n, r) => {
298
298
  if (n === r.length - 1) {
299
- t[s] = Ee;
299
+ t[s] = ye;
300
300
  return;
301
301
  }
302
302
  s in t || (t[s] = {}), t = t[s];
303
303
  });
304
304
  });
305
305
  }
306
- const Re = f({
307
- button_id: (e) => e == null ? void 0 : h().parse(e)
308
- }), xe = {
309
- clipboard_text_received: f({
310
- req_id: h(),
311
- data: (e) => e === null ? e : h().optional().parse(e)
306
+ const Pe = w({
307
+ button_id: (e) => e == null ? void 0 : c().parse(e)
308
+ }), Re = {
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
- parse: (e) => Re.parse(e ?? {})
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
- function Se() {
347
+ function xe() {
348
348
  const e = new U();
349
- Pe();
349
+ Ee();
350
350
  let t = [
351
351
  // Don't forget to remove created handlers.
352
- ye,
352
+ ve,
353
353
  // Add "resize" event listener to make sure, we always have fresh viewport information.
354
354
  // Desktop version of Telegram is sometimes not sending the viewport_changed
355
355
  // event. For example, when the MainButton is shown. That's why we should
@@ -370,11 +370,11 @@ function Se() {
370
370
  return;
371
371
  let n;
372
372
  try {
373
- n = ve(s.data);
373
+ n = be(s.data);
374
374
  } catch {
375
375
  return;
376
376
  }
377
- const { eventType: r, eventData: i } = n, o = xe[r];
377
+ const { eventType: r, eventData: i } = n, o = Re[r];
378
378
  try {
379
379
  const a = o ? o.parse(i) : i;
380
380
  e.emit(...a ? [r, a] : [r]);
@@ -393,9 +393,9 @@ function Se() {
393
393
  t.forEach((s) => s()), t = [];
394
394
  }];
395
395
  }
396
- const [Ce, Te] = yt(
396
+ const [Ce, Se] = vt(
397
397
  (e) => {
398
- const [t, s] = Se(), n = t.off.bind(t);
398
+ const [t, s] = xe(), n = t.off.bind(t);
399
399
  return t.off = (r, i) => {
400
400
  const { count: o } = t;
401
401
  n(r, i), o && !t.count && e();
@@ -412,10 +412,10 @@ 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
- function Ae(e, t) {
418
+ function Te(e, t) {
419
419
  const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
420
420
  for (let i = 0; i < r; i += 1) {
421
421
  const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
@@ -425,7 +425,7 @@ function Ae(e, t) {
425
425
  return 0;
426
426
  }
427
427
  function y(e, t) {
428
- return Ae(e, t) <= 0;
428
+ return Te(e, t) <= 0;
429
429
  }
430
430
  function S(e, t, s) {
431
431
  if (typeof s == "string") {
@@ -479,10 +479,10 @@ function S(e, t, s) {
479
479
  }
480
480
  }
481
481
  function ke(e) {
482
- return "external" in e && D(e.external) && "notify" in e.external && typeof e.external.notify == "function";
482
+ return "external" in e && N(e.external) && "notify" in e.external && typeof e.external.notify == "function";
483
483
  }
484
- function Ct(e) {
485
- return "TelegramWebviewProxy" in e && D(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
484
+ function St(e) {
485
+ return "TelegramWebviewProxy" in e && N(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
486
486
  }
487
487
  function Tt() {
488
488
  try {
@@ -491,18 +491,18 @@ function Tt() {
491
491
  return !0;
492
492
  }
493
493
  }
494
- let At = "https://web.telegram.org";
495
- function gn(e) {
496
- At = e;
494
+ let kt = "https://web.telegram.org";
495
+ function _n(e) {
496
+ kt = e;
497
497
  }
498
- function Ie() {
499
- return At;
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 (ce("Posting event:", r ? { event: e, data: r } : { event: e }), Tt()) {
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
  }
@@ -510,37 +510,37 @@ function q(e, t, s) {
510
510
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
511
511
  return;
512
512
  }
513
- if (Ct(window)) {
513
+ if (St(window)) {
514
514
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
515
515
  return;
516
516
  }
517
- throw l(
517
+ throw m(
518
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(he, `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(
529
+ throw m(
530
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
- function kt(e) {
537
+ function At(e) {
538
538
  return ({ req_id: t }) => t === e;
539
539
  }
540
540
  function It(e) {
541
- return l(le, `Timeout reached: ${e}ms`);
541
+ return m(le, `Timeout reached: ${e}ms`);
542
542
  }
543
- function Ot(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) => {
@@ -550,7 +550,7 @@ function Ot(e, 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 ? Ot(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",
@@ -582,29 +582,29 @@ async function I(e, t, s, n = {}) {
582
582
  params: t,
583
583
  req_id: s
584
584
  },
585
- capture: kt(s)
585
+ capture: At(s)
586
586
  });
587
587
  if (i)
588
- throw l(de, 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), {});
606
606
  }
607
- function qt(e) {
607
+ function Ot(e) {
608
608
  const t = xt(e);
609
609
  return Math.sqrt(
610
610
  [0.299, 0.587, 0.114].reduce((s, n, r) => {
@@ -615,7 +615,7 @@ function qt(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 Nt(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 = Nt(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 Dt = 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 Vt() {
740
- return ct({
739
+ function Bt() {
740
+ return at({
741
741
  authDate: {
742
- type: Dt(),
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 Bt = 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
784
  function Mt(e) {
785
- return ct({
785
+ return at({
786
786
  botInline: {
787
787
  type: P().optional(),
788
788
  from: "tgWebAppBotInline"
789
789
  },
790
790
  initData: {
791
- type: Vt().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,15 +804,15 @@ function Mt(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: {
811
- type: Bt(),
811
+ type: Vt(),
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);
@@ -822,13 +822,13 @@ function $t(e) {
822
822
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
823
823
  );
824
824
  }
825
- function Me() {
825
+ function Ve() {
826
826
  return $t(window.location.href);
827
827
  }
828
828
  function Lt() {
829
829
  return performance.getEntriesByType("navigation")[0];
830
830
  }
831
- function $e() {
831
+ function Me() {
832
832
  const e = Lt();
833
833
  if (!e)
834
834
  throw new Error("Unable to get first navigation entry.");
@@ -847,17 +847,17 @@ function Wt(e) {
847
847
  } catch {
848
848
  }
849
849
  }
850
- function Le() {
850
+ function $e() {
851
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,24 +867,24 @@ 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
- Ut("launchParams", Ue(e));
872
+ function Ue(e) {
873
+ Ut("launchParams", He(e));
874
874
  }
875
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.");
@@ -893,34 +893,24 @@ function Gt() {
893
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 = jt();
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
- fe,
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,
@@ -931,14 +921,14 @@ function _(e, t) {
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
934
  function zt(e) {
@@ -959,14 +949,14 @@ function zt(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,7 +1020,7 @@ 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",
@@ -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) {
1062
+ async function ze(e) {
1073
1063
  return zt(
1074
- await m({
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 = Nt(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 Vt().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,32 +1539,32 @@ 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
  }),
1573
1563
  authDate: {
1574
- type: Dt(),
1564
+ type: Nt(),
1575
1565
  from: "auth_date"
1576
1566
  },
1577
- hash: h()
1567
+ hash: c()
1578
1568
  }, "RequestedContact");
1579
1569
  }
1580
1570
  function Kt(e, t) {
@@ -1583,12 +1573,12 @@ function Kt(e, t) {
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,7 +1586,7 @@ 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
1591
  this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Kt(n, {
1602
1592
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
@@ -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
  {},
@@ -1649,7 +1639,7 @@ class ds extends V {
1649
1639
  * True if current Mini App background color is recognized as dark.
1650
1640
  */
1651
1641
  get isDark() {
1652
- return qt(this.bgColor);
1642
+ return Ot(this.bgColor);
1653
1643
  }
1654
1644
  /**
1655
1645
  * Informs the Telegram app that the Mini App is ready to be displayed.
@@ -1678,13 +1668,13 @@ 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 Ot(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
1679
  throw It(t);
1690
1680
  }, t);
@@ -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));
1919
+ }) => new ms(s.isVisible, e, t));
1930
1920
  function Jt(e) {
1931
- return Bt().parse(e);
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
  */
@@ -1969,7 +1959,7 @@ class ys extends ht {
1969
1959
  * value is calculated according to theme bg color.
1970
1960
  */
1971
1961
  get isDark() {
1972
- return !this.bgColor || qt(this.bgColor);
1962
+ return !this.bgColor || Ot(this.bgColor);
1973
1963
  }
1974
1964
  get linkColor() {
1975
1965
  return this.get("linkColor");
@@ -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
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 = Kt(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,42 +2060,42 @@ 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,
2077
2067
  params: { req_id: t },
2078
- capture: kt(t)
2068
+ capture: At(t)
2079
2069
  });
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
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
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
@@ -2166,11 +2156,11 @@ class Ft 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,7 +2195,7 @@ class Ft 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,
@@ -2220,7 +2210,7 @@ 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
@@ -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,22 +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() {
2309
- if (Ct(window))
2298
+ async function yn() {
2299
+ if (St(window))
2310
2300
  return !0;
2311
2301
  try {
2312
- 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;
2313
2303
  } catch {
2314
2304
  return !1;
2315
2305
  }
2316
2306
  }
2317
- function As(e) {
2307
+ function Ts(e) {
2318
2308
  return e instanceof W;
2319
2309
  }
2320
- function Pn(e, t) {
2321
- return As(e) && e.type === t;
2310
+ function En(e, t) {
2311
+ return Ts(e) && e.type === t;
2322
2312
  }
2323
2313
  function J(e, t) {
2324
2314
  let s, n, r;
@@ -2329,11 +2319,11 @@ function J(e, t) {
2329
2319
  });
2330
2320
  }
2331
2321
  class ks {
2332
- constructor(t, s, n = q) {
2333
- 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)
2334
- throw l(ge, "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.");
2335
2325
  if (s < 0 || s >= t.length)
2336
- throw l(
2326
+ throw m(
2337
2327
  we,
2338
2328
  "Index should not be zero and higher or equal than history size."
2339
2329
  );
@@ -2455,12 +2445,12 @@ function Q({
2455
2445
  }) {
2456
2446
  return { ...e || { hash: "", search: "" }, ...t };
2457
2447
  }
2458
- function N(e, t) {
2448
+ function D(e, t) {
2459
2449
  return e.startsWith(t) ? e : `${t}${e}`;
2460
2450
  }
2461
2451
  function $(e) {
2462
2452
  return new URL(
2463
- 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 || "", "#")}`,
2464
2454
  "http://a"
2465
2455
  );
2466
2456
  }
@@ -2471,10 +2461,10 @@ function L(e) {
2471
2461
  function F(e, t, s) {
2472
2462
  let n, r;
2473
2463
  typeof e == "string" ? n = e : (n = L(e), s = e.state, r = e.id);
2474
- 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, "/")}`);
2475
2465
  return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
2476
2466
  }
2477
- async function O(e) {
2467
+ async function q(e) {
2478
2468
  return e === 0 ? !0 : Promise.race([
2479
2469
  new Promise((t) => {
2480
2470
  const s = tt("popstate", () => {
@@ -2488,24 +2478,24 @@ async function O(e) {
2488
2478
  })
2489
2479
  ]);
2490
2480
  }
2491
- async function Is() {
2492
- 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)))
2493
2483
  return;
2494
- let e = await O(-1);
2484
+ let e = await q(-1);
2495
2485
  for (; e; )
2496
- e = await O(-1);
2486
+ e = await q(-1);
2497
2487
  }
2498
2488
  function Yt(e) {
2499
2489
  return $(e).pathname;
2500
2490
  }
2501
- const bt = 0, Y = 1, Z = 2;
2491
+ const mt = 0, Y = 1, Z = 2;
2502
2492
  class Zt {
2503
2493
  constructor(t, s, { postEvent: n, hashMode: r, base: i } = {}) {
2504
- 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 }) => {
2505
2495
  if (o === null)
2506
2496
  return this.push(this.parsePath(window.location.href));
2507
- o === bt ? window.history.forward() : o === Y && this.back(), o === Z && this.forward();
2508
- }), c(this, "onNavigatorChange", async ({
2497
+ o === mt ? window.history.forward() : o === Y && this.back(), o === Z && this.forward();
2498
+ }), h(this, "onNavigatorChange", async ({
2509
2499
  to: o,
2510
2500
  from: a,
2511
2501
  delta: p
@@ -2516,7 +2506,7 @@ class Zt {
2516
2506
  to: Q(o),
2517
2507
  navigator: this
2518
2508
  });
2519
- }), 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(
2520
2510
  t.map((o) => F(o, "/")),
2521
2511
  s,
2522
2512
  n
@@ -2668,8 +2658,8 @@ class Zt {
2668
2658
  * @param value - path presented as string or URLLike.
2669
2659
  */
2670
2660
  renderPath(t) {
2671
- const s = (this.base.length === 1 ? "" : this.base) + N(L(t), "/");
2672
- 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;
2673
2663
  }
2674
2664
  /**
2675
2665
  * Synchronizes current navigator state with browser history.
@@ -2677,7 +2667,7 @@ class Zt {
2677
2667
  async syncHistory() {
2678
2668
  window.removeEventListener("popstate", this.onPopState);
2679
2669
  const { state: t } = this, s = this.renderPath(this);
2680
- 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);
2681
2671
  }
2682
2672
  /**
2683
2673
  * Current query parameters.
@@ -2695,7 +2685,7 @@ class Zt {
2695
2685
  return (this.navigator.current.params || {}).state;
2696
2686
  }
2697
2687
  }
2698
- function Os(e) {
2688
+ function Is(e) {
2699
2689
  e || (e = {});
2700
2690
  const { href: t, hash: s } = window.location;
2701
2691
  let n = L(
@@ -2704,15 +2694,15 @@ function Os(e) {
2704
2694
  const r = e.base ? Yt(e.base) : void 0;
2705
2695
  if (r) {
2706
2696
  if (!n.startsWith(r))
2707
- throw l(
2708
- me,
2697
+ throw m(
2698
+ fe,
2709
2699
  `Path "${n}" expected to be starting with "${r}"`
2710
2700
  );
2711
2701
  n = n.slice(r.length);
2712
2702
  }
2713
2703
  return new Zt([n], 0, e);
2714
2704
  }
2715
- function Rn(e) {
2705
+ function Pn(e) {
2716
2706
  const t = e.match(/#(.+)/);
2717
2707
  return t ? t[1] : null;
2718
2708
  }
@@ -2727,34 +2717,34 @@ function qs(e, t) {
2727
2717
  console.error("Unable to restore hash navigator state.", n);
2728
2718
  }
2729
2719
  }
2730
- return Os(t);
2720
+ return Is(t);
2731
2721
  }
2732
- function xn(e, t) {
2722
+ function Rn(e, t) {
2733
2723
  const s = qs(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2734
2724
  index: s.index,
2735
2725
  history: s.history
2736
2726
  }));
2737
2727
  return s.on("change", n), n(), s;
2738
2728
  }
2739
- function g(e, t) {
2729
+ function _(e, t) {
2740
2730
  function s(n) {
2741
2731
  return (r, i, o) => (a) => {
2742
2732
  const p = a[i] || [], u = { ...a, [r]: n(...p) };
2743
- return /* @__PURE__ */ vt(o, { ...u });
2733
+ return /* @__PURE__ */ bt(o, { ...u });
2744
2734
  };
2745
2735
  }
2746
2736
  return [s(e), s(t)];
2747
2737
  }
2748
2738
  const Xt = te(void 0);
2749
- function Ns() {
2739
+ function Os() {
2750
2740
  const e = ee(Xt);
2751
2741
  if (!e)
2752
2742
  throw new Error("useSDK was used outside the SDKProvider.");
2753
2743
  return e;
2754
2744
  }
2755
- function w(e) {
2745
+ function g(e) {
2756
2746
  const t = (...n) => {
2757
- const r = Ns();
2747
+ const r = Os();
2758
2748
  return st(() => r.use(e, ...n), [r]);
2759
2749
  };
2760
2750
  return [t, (...n) => {
@@ -2764,52 +2754,52 @@ function w(e) {
2764
2754
  return r.result;
2765
2755
  }];
2766
2756
  }
2767
- const [Ds, Vs] = w(ze), [Sn, Cn] = g(
2757
+ const [Ds, Ns] = g(Ge), [xn, Cn] = _(
2768
2758
  Ds,
2769
- Vs
2770
- ), [Bs, Ms] = w(Je), [Tn, An] = g(
2759
+ Ns
2760
+ ), [Bs, Vs] = g(Ke), [Sn, Tn] = _(
2771
2761
  Bs,
2772
- Ms
2773
- ), [$s, Ls] = w(Fe), [kn, In] = g(
2774
- $s,
2775
- Ls
2776
- ), [Hs, Us] = w(es), [On, qn] = g(
2777
- Hs,
2778
- Us
2779
- ), [Ws, js] = w(ns), [Nn, Dn] = g(
2780
- Ws,
2781
- js
2782
- ), [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(
2783
- nn,
2784
- rn
2785
- ), [on, an] = w(Es), [Fn, Yn] = g(on, an);
2786
- function Zn() {
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() {
2787
2777
  return st(jt, []);
2788
2778
  }
2789
- const [cn, hn] = w(Rs), [Xn, tr] = g(cn, hn), [pn, un] = w(Cs), [er, sr] = g(pn, un);
2790
- function nr({ children: e, acceptCustomStyles: t, debug: s }) {
2791
- const n = lt(!0), [r, i] = se(
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(
2792
2782
  () => /* @__PURE__ */ new Map()
2793
- ), o = _t((d) => {
2794
- n.current && i((B) => (d && d(B), new Map(B)));
2795
- }, []), a = _t(() => o(), [o]), p = lt([]), u = st(() => ({
2796
- use(d, ...B) {
2797
- const ut = r.get(d);
2798
- if (ut)
2799
- 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;
2800
2790
  let b;
2801
2791
  try {
2802
- b = { result: d(...B) };
2792
+ b = { result: d(...V) };
2803
2793
  } catch (v) {
2804
2794
  b = { error: v };
2805
2795
  }
2806
2796
  if ("error" in b || !b.result)
2807
2797
  return r.set(d, b), b;
2808
- 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 });
2809
2799
  return b.result instanceof Promise ? (b.result.then(
2810
- (v) => o((K) => K.set(d, dt(v))),
2800
+ (v) => o((K) => K.set(d, ut(v))),
2811
2801
  (v) => o((K) => K.set(d, { error: v }))
2812
- ), r.set(d, {}), {}) : (r.set(d, b = dt(b.result)), b);
2802
+ ), r.set(d, {}), {}) : (r.set(d, b = ut(b.result)), b);
2813
2803
  }
2814
2804
  }), [r]);
2815
2805
  return M(() => {
@@ -2818,174 +2808,173 @@ function nr({ children: e, acceptCustomStyles: t, debug: s }) {
2818
2808
  n.current = !1;
2819
2809
  }, []), M(() => {
2820
2810
  if (Tt())
2821
- return Ts(t);
2822
- }, [t]), M(() => () => p.current.forEach((d) => d.off("change", a)), [a]), /* @__PURE__ */ vt(Xt.Provider, { value: u, children: e });
2811
+ return Ss(t);
2812
+ }, [t]), M(() => () => p.current.forEach((d) => d.off("change", a)), [a]), /* @__PURE__ */ bt(Xt.Provider, { value: u, children: e });
2823
2813
  }
2824
2814
  export {
2825
- Ne as BackButton,
2815
+ Oe as BackButton,
2826
2816
  ks as BasicNavigator,
2827
- ft as BiometryManager,
2817
+ wt as BiometryManager,
2828
2818
  Zt as BrowserNavigator,
2829
- Qe as ClosingBehavior,
2830
- ts as CloudStorage,
2831
- me as ERR_INVALID_PATH_BASE,
2819
+ Je as ClosingBehavior,
2820
+ Xe as CloudStorage,
2821
+ fe as ERR_INVALID_PATH_BASE,
2832
2822
  de as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2833
2823
  pe as ERR_METHOD_PARAMETER_UNSUPPORTED,
2834
- he as ERR_METHOD_UNSUPPORTED,
2824
+ ce as ERR_METHOD_UNSUPPORTED,
2835
2825
  ge as ERR_NAVIGATION_HISTORY_EMPTY,
2836
2826
  we as ERR_NAVIGATION_INDEX_INVALID,
2837
- _n as ERR_NAVIGATION_ITEM_INVALID,
2838
- Pt as ERR_PARSE,
2839
- nt as ERR_SSR_INIT,
2840
- fe as ERR_SSR_POST_EVENT,
2827
+ ln as ERR_NAVIGATION_ITEM_INVALID,
2828
+ Et as ERR_PARSE,
2829
+ Pt as ERR_SSR_INIT,
2841
2830
  le as ERR_TIMED_OUT,
2842
2831
  _e as ERR_UNEXPECTED_TYPE,
2843
2832
  ue as ERR_UNKNOWN_ENV,
2844
2833
  U as EventEmitter,
2845
- ss as HapticFeedback,
2846
- rs as InitData,
2847
- os as Invoice,
2848
- cs as MainButton,
2849
- ds as MiniApp,
2850
- gs as Popup,
2851
- 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,
2852
2841
  W as SDKError,
2853
- nr as SDKProvider,
2854
- bs as SettingsButton,
2855
- ys as ThemeParams,
2856
- Ps as Utils,
2842
+ sr as SDKProvider,
2843
+ ms as SettingsButton,
2844
+ vs as ThemeParams,
2845
+ Es as Utils,
2857
2846
  Ft as Viewport,
2858
- Xe as array,
2859
- bn as bindMiniAppCSSVars,
2860
- vn as bindThemeParamsCSSVars,
2861
- yn as bindViewportCSSVars,
2847
+ Ze as array,
2848
+ mn as bindMiniAppCSSVars,
2849
+ bn as bindThemeParamsCSSVars,
2850
+ vn as bindViewportCSSVars,
2862
2851
  P as boolean,
2863
- kt as captureSameReq,
2852
+ At as captureSameReq,
2864
2853
  et as classNames,
2865
- Ae as compareVersions,
2866
- Os as createBrowserNavigatorFromLocation,
2867
- Oe as createPostEvent,
2854
+ Te as compareVersions,
2855
+ Is as createBrowserNavigatorFromLocation,
2856
+ Ie as createPostEvent,
2868
2857
  $ as createSafeURL,
2869
- Dt as date,
2870
- Rn as getHash,
2858
+ Nt as date,
2859
+ Pn as getHash,
2871
2860
  Yt as getPathname,
2872
- ze as initBackButton,
2873
- Je as initBiometryManager,
2874
- Fe as initClosingBehavior,
2875
- es as initCloudStorage,
2876
- ns as initHapticFeedback,
2877
- is as initInitData,
2878
- as as initInvoice,
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,
2879
2868
  hs as initMainButton,
2880
- ls as initMiniApp,
2881
- xn as initNavigator,
2882
- ws as initPopup,
2883
- ms as initQRScanner,
2884
- vs as initSettingsButton,
2885
- Es as initThemeParams,
2886
- 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,
2887
2876
  Cs as initViewport,
2888
- Ts as initWeb,
2877
+ Ss as initWeb,
2889
2878
  I as invokeCustomMethod,
2890
- qt as isColorDark,
2879
+ Ot as isColorDark,
2891
2880
  Tt as isIframe,
2892
2881
  Gt as isPageReload,
2893
- it as isRGB,
2894
- be as isRGBShort,
2895
- As as isSDKError,
2896
- Pn as isSDKErrorOfType,
2897
- C as isSSR,
2898
- En as isTMA,
2899
- f as json,
2900
- wn as mergeClassNames,
2901
- x as number,
2882
+ rt as isRGB,
2883
+ me as isRGBShort,
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,
2902
2891
  z as off,
2903
2892
  E as on,
2904
- fn as parseInitData,
2893
+ wn as parseInitData,
2905
2894
  Mt as parseLaunchParams,
2906
2895
  Jt as parseThemeParams,
2907
- q as postEvent,
2908
- m as request,
2909
- Ke as requestBiometryInfo,
2910
- mn as requestThemeParams,
2896
+ O as postEvent,
2897
+ f as request,
2898
+ ze as requestBiometryInfo,
2899
+ fn as requestThemeParams,
2911
2900
  Qt as requestViewport,
2912
2901
  jt as retrieveLaunchParams,
2913
- St as rgb,
2914
- ct as searchParams,
2915
- Ue as serializeLaunchParams,
2916
- He as serializeThemeParams,
2902
+ Ct as rgb,
2903
+ at as searchParams,
2904
+ He as serializeLaunchParams,
2905
+ Le as serializeThemeParams,
2917
2906
  R as setCSSVar,
2918
2907
  ae as setDebug,
2919
- gn as setTargetOrigin,
2920
- h as string,
2908
+ _n as setTargetOrigin,
2909
+ c as string,
2921
2910
  ie as subscribe,
2922
2911
  S as supports,
2923
- Ie as targetOrigin,
2912
+ Ae as targetOrigin,
2924
2913
  xt as toRGB,
2925
- Et as unsubscribe,
2914
+ yt as unsubscribe,
2926
2915
  L as urlToPath,
2927
- Vs as useBackButton,
2916
+ Ns as useBackButton,
2928
2917
  Ds as useBackButtonRaw,
2929
- Ms as useBiometryManager,
2918
+ Vs as useBiometryManager,
2930
2919
  Bs as useBiometryManagerRaw,
2931
- Ls as useClosingBehavior,
2932
- $s as useClosingBehaviorRaw,
2933
- Us as useCloudStorage,
2934
- Hs as useCloudStorageRaw,
2935
- js as useHapticFeedback,
2936
- Ws as useHapticFeedbackRaw,
2937
- zs as useInitData,
2938
- Gs as useInitDataRaw,
2939
- Js as useInvoice,
2940
- Ks as useInvoiceRaw,
2941
- Zn as useLaunchParams,
2942
- Fs as useMainButton,
2943
- Qs as useMainButtonRaw,
2944
- Zs as useMiniApp,
2945
- Ys as useMiniAppRaw,
2946
- tn as usePopup,
2947
- Xs as usePopupRaw,
2948
- sn as useQRScanner,
2949
- en as useQRScannerRaw,
2950
- Ns as useSDK,
2951
- rn as useSettingsButton,
2952
- nn as useSettingsButtonRaw,
2953
- an as useThemeParams,
2954
- 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,
2955
2944
  hn as useUtils,
2956
- cn as useUtilsRaw,
2957
- un as useViewport,
2958
- pn as useViewportRaw,
2945
+ an as useUtilsRaw,
2946
+ pn as useViewport,
2947
+ cn as useViewportRaw,
2959
2948
  Cn as withBackButton,
2960
- Sn as withBackButtonRaw,
2961
- An as withBiometryManager,
2962
- Tn as withBiometryManagerRaw,
2963
- In as withClosingBehavior,
2949
+ xn as withBackButtonRaw,
2950
+ Tn as withBiometryManager,
2951
+ Sn as withBiometryManagerRaw,
2952
+ An as withClosingBehavior,
2964
2953
  kn as withClosingBehaviorRaw,
2965
2954
  qn as withCloudStorage,
2966
- On as withCloudStorageRaw,
2955
+ In as withCloudStorageRaw,
2967
2956
  Dn as withHapticFeedback,
2968
- Nn as withHapticFeedbackRaw,
2957
+ On as withHapticFeedbackRaw,
2969
2958
  Bn as withInitData,
2970
- Vn as withInitDataRaw,
2971
- $n as withInvoice,
2972
- Mn as withInvoiceRaw,
2973
- Hn as withMainButton,
2974
- Ln as withMainButtonRaw,
2975
- Wn as withMiniApp,
2976
- Un as withMiniAppRaw,
2977
- Gn as withPopup,
2978
- jn as withPopupRaw,
2979
- Kn as withQRScanner,
2980
- zn as withQRScannerRaw,
2981
- Qn as withSettingsButton,
2982
- Jn as withSettingsButtonRaw,
2983
- Yn as withThemeParams,
2984
- Fn as withThemeParamsRaw,
2985
- Ot as withTimeout,
2986
- tr as withUtils,
2987
- Xn as withUtilsRaw,
2988
- sr as withViewport,
2989
- 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
2990
2979
  };
2991
2980
  //# sourceMappingURL=index.js.map