@tma.js/sdk-react 2.1.4 → 2.2.1

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 mt } from "react/jsx-runtime";
2
- import { createContext as Xt, useContext as te, useState as bt, useEffect as C, useMemo as vt, useRef as dt, useCallback as ee } 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 yt } from "react/jsx-runtime";
2
+ import { createContext as ie, useContext as oe, useState as Et, useEffect as S, useMemo as Pt, useRef as gt, useCallback as ae } from "react";
3
+ var ce = Object.defineProperty, he = (e, t, s) => t in e ? ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (he(e, typeof t != "symbol" ? t + "" : t, s), s);
4
+ function Rt(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) {
12
- const t = G(), { count: s } = t;
13
- t.unsubscribe(e), s && !t.count && Ce();
11
+ function xt(e) {
12
+ const t = j(), { count: s } = t;
13
+ t.unsubscribe(e), s && !t.count && Ae();
14
14
  }
15
- function re(e) {
16
- return G().subscribe(e), () => Et(e);
15
+ function pe(e) {
16
+ return j().subscribe(e), () => xt(e);
17
17
  }
18
- class ie {
18
+ class ue {
19
19
  constructor(t, s = {}) {
20
20
  this.scope = t, this.options = s;
21
21
  }
@@ -31,12 +31,12 @@ class ie {
31
31
  second: "2-digit",
32
32
  fractionalSecondDigits: 3,
33
33
  timeZone: "UTC"
34
- }).format(n), { textColor: i, bgColor: a } = this.options, o = "font-weight: bold;padding: 0 5px;border-radius:5px";
34
+ }).format(n), { textColor: i, bgColor: o } = this.options, a = "font-weight: bold;padding: 0 5px;border-radius:5px";
35
35
  console[t](
36
36
  `%c${r}%c / %c${this.scope}`,
37
- `${o};background-color: lightblue;color:black`,
37
+ `${a};background-color: lightblue;color:black`,
38
38
  "",
39
- `${o};${i ? `color:${i};` : ""}${a ? `background-color:${a}` : ""}`,
39
+ `${a};${i ? `color:${i};` : ""}${o ? `background-color:${o}` : ""}`,
40
40
  ...s
41
41
  );
42
42
  }
@@ -55,21 +55,21 @@ class ie {
55
55
  this.print("log", ...t);
56
56
  }
57
57
  }
58
- const st = new ie("SDK", {
58
+ const nt = new ue("SDK", {
59
59
  bgColor: "forestgreen",
60
60
  textColor: "white"
61
61
  });
62
62
  let X = !1;
63
- const _t = ({ event: e, args: [t] }) => {
64
- st.log("Event received:", t === void 0 ? { name: e } : { name: e, data: t });
63
+ const ft = ({ name: e, payload: t }) => {
64
+ nt.log("Event received:", t ? { name: e, payload: t } : { name: e });
65
65
  };
66
- function oe(e) {
67
- X !== e && (X = e, e ? re(_t) : Et(_t));
66
+ function le(e) {
67
+ X !== e && (X = e, e ? pe(ft) : xt(ft));
68
68
  }
69
- function ae(...e) {
70
- X && st.log(...e);
69
+ function de(...e) {
70
+ X && nt.log(...e);
71
71
  }
72
- class H {
72
+ class N {
73
73
  constructor() {
74
74
  c(this, "listeners", /* @__PURE__ */ new Map()), c(this, "listenersCount", 0), c(this, "subscribeListeners", []);
75
75
  }
@@ -142,6 +142,17 @@ class H {
142
142
  function tt(e, t, s) {
143
143
  return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
144
144
  }
145
+ function Ct(...e) {
146
+ let t = !1;
147
+ const s = [...e];
148
+ return [
149
+ (n) => !t && s.push(n),
150
+ () => {
151
+ t || (t = !0, s.forEach((n) => n()));
152
+ },
153
+ t
154
+ ];
155
+ }
145
156
  class W extends Error {
146
157
  constructor(t, s, n) {
147
158
  super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, W.prototype);
@@ -150,11 +161,11 @@ class W extends Error {
150
161
  function m(e, t, s) {
151
162
  return new W(e, t, s);
152
163
  }
153
- const ce = "ERR_METHOD_UNSUPPORTED", he = "ERR_METHOD_PARAMETER_UNSUPPORTED", pe = "ERR_UNKNOWN_ENV", ue = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", le = "ERR_TIMED_OUT", de = "ERR_UNEXPECTED_TYPE", Pt = "ERR_PARSE", _e = "ERR_NAVIGATION_LIST_EMPTY", ge = "ERR_NAVIGATION_CURSOR_INVALID", _n = "ERR_NAVIGATION_ITEM_INVALID", gn = "ERR_SSR_INIT", we = "ERR_INVALID_PATH_BASE";
164
+ const _e = "ERR_METHOD_UNSUPPORTED", we = "ERR_METHOD_PARAMETER_UNSUPPORTED", ge = "ERR_UNKNOWN_ENV", fe = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", me = "ERR_TIMED_OUT", be = "ERR_UNEXPECTED_TYPE", St = "ERR_PARSE", ve = "ERR_NAVIGATION_LIST_EMPTY", ye = "ERR_NAVIGATION_CURSOR_INVALID", dn = "ERR_NAVIGATION_ITEM_INVALID", _n = "ERR_SSR_INIT", Ee = "ERR_INVALID_PATH_BASE";
154
165
  function T() {
155
- return m(de, "Value has unexpected type");
166
+ return m(be, "Value has unexpected type");
156
167
  }
157
- class j {
168
+ class G {
158
169
  constructor(t, s, n) {
159
170
  this.parser = t, this.isOptional = s, this.type = n;
160
171
  }
@@ -170,7 +181,7 @@ class j {
170
181
  return this.parser(t);
171
182
  } catch (s) {
172
183
  throw m(
173
- Pt,
184
+ St,
174
185
  `Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
175
186
  s
176
187
  );
@@ -181,7 +192,7 @@ class j {
181
192
  }
182
193
  }
183
194
  function A(e, t) {
184
- return () => new j(e, !1, t);
195
+ return () => new G(e, !1, t);
185
196
  }
186
197
  const P = A((e) => {
187
198
  if (typeof e == "boolean")
@@ -193,38 +204,38 @@ const P = A((e) => {
193
204
  return !1;
194
205
  throw T();
195
206
  }, "boolean");
196
- function Rt(e, t) {
207
+ function Tt(e, t) {
197
208
  const s = {};
198
209
  for (const n in e) {
199
210
  const r = e[n];
200
211
  if (!r)
201
212
  continue;
202
- let i, a;
213
+ let i, o;
203
214
  if (typeof r == "function" || "parse" in r)
204
- i = n, a = typeof r == "function" ? r : r.parse.bind(r);
215
+ i = n, o = typeof r == "function" ? r : r.parse.bind(r);
205
216
  else {
206
- const { type: o } = r;
207
- i = r.from || n, a = typeof o == "function" ? o : o.parse.bind(o);
217
+ const { type: a } = r;
218
+ i = r.from || n, o = typeof a == "function" ? a : a.parse.bind(a);
208
219
  }
209
220
  try {
210
- const o = a(t(i));
211
- o !== void 0 && (s[n] = o);
212
- } catch (o) {
213
- throw m(Pt, `Unable to parse field "${n}"`, o);
221
+ const a = o(t(i));
222
+ a !== void 0 && (s[n] = a);
223
+ } catch (a) {
224
+ throw m(St, `Unable to parse field "${n}"`, a);
214
225
  }
215
226
  }
216
227
  return s;
217
228
  }
218
- function nt(e) {
229
+ function rt(e) {
219
230
  let t = e;
220
231
  if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
221
232
  throw T();
222
233
  return t;
223
234
  }
224
- function g(e, t) {
225
- return new j((s) => {
226
- const n = nt(s);
227
- return Rt(e, (r) => n[r]);
235
+ function w(e, t) {
236
+ return new G((s) => {
237
+ const n = rt(s);
238
+ return Tt(e, (r) => n[r]);
228
239
  }, !1, t);
229
240
  }
230
241
  const x = A((e) => {
@@ -237,17 +248,17 @@ const x = A((e) => {
237
248
  }
238
249
  throw T();
239
250
  }, "number");
240
- function rt(e) {
251
+ function it(e) {
241
252
  return /^#[\da-f]{6}$/i.test(e);
242
253
  }
243
- function fe(e) {
254
+ function Pe(e) {
244
255
  return /^#[\da-f]{3}$/i.test(e);
245
256
  }
246
- function xt(e) {
257
+ function At(e) {
247
258
  const t = e.replace(/\s/g, "").toLowerCase();
248
- if (rt(t))
259
+ if (it(t))
249
260
  return t;
250
- if (fe(t)) {
261
+ if (Pe(t)) {
251
262
  let n = "#";
252
263
  for (let r = 0; r < 3; r += 1)
253
264
  n += t[1 + r].repeat(2);
@@ -265,26 +276,26 @@ const p = A((e) => {
265
276
  if (typeof e == "string" || typeof e == "number")
266
277
  return e.toString();
267
278
  throw T();
268
- }, "string"), Ct = A((e) => xt(p().parse(e)), "rgb");
269
- function me(e) {
270
- return g({
279
+ }, "string"), It = A((e) => At(p().parse(e)), "rgb");
280
+ function kt(e) {
281
+ return w({
271
282
  eventType: p(),
272
283
  eventData: (t) => t
273
284
  }).parse(e);
274
285
  }
275
- function be() {
286
+ function Re() {
276
287
  ["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
277
288
  delete window[e];
278
289
  });
279
290
  }
280
- function ve(e, t) {
291
+ function et(e, t) {
281
292
  window.dispatchEvent(new MessageEvent("message", {
282
293
  data: JSON.stringify({ eventType: e, eventData: t }),
283
294
  // We specify window.parent to imitate the case, the parent iframe sent us this event.
284
295
  source: window.parent
285
296
  }));
286
297
  }
287
- function ye() {
298
+ function xe() {
288
299
  [
289
300
  ["TelegramGameProxy_receiveEvent"],
290
301
  // Windows Phone.
@@ -296,67 +307,62 @@ function ye() {
296
307
  let t = window;
297
308
  e.forEach((s, n, r) => {
298
309
  if (n === r.length - 1) {
299
- t[s] = ve;
310
+ t[s] = et;
300
311
  return;
301
312
  }
302
313
  s in t || (t[s] = {}), t = t[s];
303
314
  });
304
315
  });
305
316
  }
306
- const Ee = g({
307
- button_id: (e) => e == null ? void 0 : p().parse(e)
308
- }), Pe = {
309
- clipboard_text_received: g({
317
+ const Ce = {
318
+ clipboard_text_received: w({
310
319
  req_id: p(),
311
320
  data: (e) => e === null ? e : p().optional().parse(e)
312
321
  }),
313
- custom_method_invoked: g({
322
+ custom_method_invoked: w({
314
323
  req_id: p(),
315
324
  result: (e) => e,
316
325
  error: p().optional()
317
326
  }),
318
- invoice_closed: g({
319
- slug: p(),
320
- status: p()
321
- }),
322
- phone_requested: g({
323
- status: p()
324
- }),
327
+ invoice_closed: w({ slug: p(), status: p() }),
328
+ phone_requested: w({ status: p() }),
325
329
  popup_closed: {
326
- parse: (e) => Ee.parse(e ?? {})
330
+ parse(e) {
331
+ return w({
332
+ button_id: (t) => t == null ? void 0 : p().parse(t)
333
+ }).parse(e ?? {});
334
+ }
327
335
  },
328
- qr_text_received: g({
329
- data: p().optional()
330
- }),
331
- theme_changed: g({
336
+ qr_text_received: w({ data: p().optional() }),
337
+ theme_changed: w({
332
338
  theme_params: (e) => {
333
- const t = Ct().optional();
334
- return Object.entries(nt(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
339
+ const t = It().optional();
340
+ return Object.entries(rt(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
335
341
  }
336
342
  }),
337
- viewport_changed: g({
343
+ viewport_changed: w({
338
344
  height: x(),
339
345
  width: (e) => e == null ? window.innerWidth : x().parse(e),
340
346
  is_state_stable: P(),
341
347
  is_expanded: P()
342
348
  }),
343
- write_access_requested: g({
344
- status: p()
345
- })
349
+ write_access_requested: w({ status: p() })
346
350
  };
347
- function Re() {
348
- const e = new H();
349
- ye();
350
- let t = [
351
+ function Se() {
352
+ const e = new N(), t = new N();
353
+ t.subscribe((n) => {
354
+ e.emit("event", { name: n.event, payload: n.args[0] });
355
+ }), xe();
356
+ const [, s] = Ct(
351
357
  // Don't forget to remove created handlers.
352
- be,
358
+ Re,
353
359
  // Add "resize" event listener to make sure, we always have fresh viewport information.
354
360
  // Desktop version of Telegram is sometimes not sending the viewport_changed
355
361
  // event. For example, when the MainButton is shown. That's why we should
356
362
  // add our own listener to make sure, viewport information is always fresh.
357
363
  // Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/10
358
364
  tt("resize", () => {
359
- e.emit("viewport_changed", {
365
+ t.emit("viewport_changed", {
360
366
  width: window.innerWidth,
361
367
  height: window.innerHeight,
362
368
  is_state_stable: !0,
@@ -365,69 +371,80 @@ function Re() {
365
371
  }),
366
372
  // Add listener, which handles events sent from the Telegram web application and also events
367
373
  // generated by the local emitEvent function.
368
- tt("message", (s) => {
369
- if (s.source !== window.parent)
374
+ tt("message", (n) => {
375
+ if (n.source !== window.parent)
370
376
  return;
371
- let n;
377
+ let r;
372
378
  try {
373
- n = me(s.data);
379
+ r = kt(n.data);
374
380
  } catch {
375
381
  return;
376
382
  }
377
- const { eventType: r, eventData: i } = n, a = Pe[r];
383
+ const { eventType: i, eventData: o } = r, a = Ce[i];
378
384
  try {
379
- const o = a ? a.parse(i) : i;
380
- e.emit(...o ? [r, o] : [r]);
381
- } catch (o) {
382
- st.error(
383
- `An error occurred processing the "${r}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
384
- n,
385
- o
385
+ const u = a ? a.parse(o) : o;
386
+ t.emit(...u ? [i, u] : [i]);
387
+ } catch (u) {
388
+ nt.error(
389
+ `An error occurred processing the "${i}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
390
+ r,
391
+ u
386
392
  );
387
393
  }
388
394
  }),
389
- // Clear emitter bound events.
390
- () => e.clear()
391
- ];
392
- return [e, () => {
393
- t.forEach((s) => s()), t = [];
394
- }];
395
+ // Clear emitters.
396
+ () => e.clear(),
397
+ () => t.clear()
398
+ );
399
+ return [{
400
+ on: t.on.bind(t),
401
+ off: t.off.bind(t),
402
+ subscribe(n) {
403
+ return e.on("event", n);
404
+ },
405
+ unsubscribe(n) {
406
+ e.off("event", n);
407
+ },
408
+ get count() {
409
+ return t.count + e.count;
410
+ }
411
+ }, s];
395
412
  }
396
- const [xe, Ce] = yt(
413
+ const [Te, Ae] = Rt(
397
414
  (e) => {
398
- const [t, s] = Re(), n = t.off.bind(t);
415
+ const [t, s] = Se(), n = t.off.bind(t);
399
416
  return t.off = (r, i) => {
400
- const { count: a } = t;
401
- n(r, i), a && !t.count && e();
417
+ const { count: o } = t;
418
+ n(r, i), o && !t.count && e();
402
419
  }, [t, s];
403
420
  },
404
421
  ([, e]) => e()
405
422
  );
406
- function G() {
407
- return xe()[0];
423
+ function j() {
424
+ return Te()[0];
408
425
  }
409
426
  function z(e, t) {
410
- G().off(e, t);
427
+ j().off(e, t);
411
428
  }
412
429
  function E(e, t, s) {
413
- return G().on(e, t, s);
430
+ return j().on(e, t, s);
414
431
  }
415
- function M(e) {
432
+ function V(e) {
416
433
  return typeof e == "object" && e !== null && !Array.isArray(e);
417
434
  }
418
- function Se(e, t) {
435
+ function Ie(e, t) {
419
436
  const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
420
437
  for (let i = 0; i < r; i += 1) {
421
- const a = parseInt(s[i] || "0", 10), o = parseInt(n[i] || "0", 10);
422
- if (a !== o)
423
- return a > o ? 1 : -1;
438
+ const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
439
+ if (o !== a)
440
+ return o > a ? 1 : -1;
424
441
  }
425
442
  return 0;
426
443
  }
427
444
  function y(e, t) {
428
- return Se(e, t) <= 0;
445
+ return Ie(e, t) <= 0;
429
446
  }
430
- function S(e, t, s) {
447
+ function C(e, t, s) {
431
448
  if (typeof s == "string") {
432
449
  if (e === "web_app_open_link" && t === "try_instant_view")
433
450
  return y("6.4", s);
@@ -478,79 +495,79 @@ function S(e, t, s) {
478
495
  ].includes(e);
479
496
  }
480
497
  }
481
- function Te(e) {
482
- return "external" in e && M(e.external) && "notify" in e.external && typeof e.external.notify == "function";
498
+ function qt(e) {
499
+ return "external" in e && V(e.external) && "notify" in e.external && typeof e.external.notify == "function";
483
500
  }
484
- function St(e) {
485
- return "TelegramWebviewProxy" in e && M(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
501
+ function Ot(e) {
502
+ return "TelegramWebviewProxy" in e && V(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
486
503
  }
487
- function Tt() {
504
+ function ot() {
488
505
  try {
489
506
  return window.self !== window.top;
490
507
  } catch {
491
508
  return !0;
492
509
  }
493
510
  }
494
- let At = "https://web.telegram.org";
511
+ let Dt = "https://web.telegram.org";
495
512
  function wn(e) {
496
- At = e;
513
+ Dt = e;
497
514
  }
498
- function Ae() {
499
- return At;
515
+ function ke() {
516
+ return Dt;
500
517
  }
501
- function N(e, t, s) {
518
+ function B(e, t, s) {
502
519
  let n = {}, r;
503
520
  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 = Ae() } = n;
505
- if (ae("Posting event:", r ? { event: e, data: r } : { event: e }), Tt()) {
521
+ const { targetOrigin: i = ke() } = n;
522
+ if (de("Posting event:", r ? { event: e, data: r } : { event: e }), ot()) {
506
523
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
507
524
  return;
508
525
  }
509
- if (Te(window)) {
526
+ if (qt(window)) {
510
527
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
511
528
  return;
512
529
  }
513
- if (St(window)) {
530
+ if (Ot(window)) {
514
531
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
515
532
  return;
516
533
  }
517
534
  throw m(
518
- pe,
535
+ ge,
519
536
  "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
537
  );
521
538
  }
522
- function ke(e) {
539
+ function qe(e) {
523
540
  return (t, s) => {
524
- if (!S(t, e))
525
- throw m(ce, `Method "${t}" is unsupported in Mini Apps version ${e}`);
526
- if (M(s)) {
541
+ if (!C(t, e))
542
+ throw m(_e, `Method "${t}" is unsupported in Mini Apps version ${e}`);
543
+ if (V(s)) {
527
544
  let n;
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))
545
+ 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 && !C(t, n, e))
529
546
  throw m(
530
- he,
547
+ we,
531
548
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
532
549
  );
533
550
  }
534
- return N(t, s);
551
+ return B(t, s);
535
552
  };
536
553
  }
537
- function kt(e) {
554
+ function Nt(e) {
538
555
  return ({ req_id: t }) => t === e;
539
556
  }
540
- function It(e) {
541
- return m(le, `Timeout reached: ${e}ms`);
557
+ function Bt(e) {
558
+ return m(me, `Timeout reached: ${e}ms`);
542
559
  }
543
- function Ot(e, t) {
560
+ function Mt(e, t) {
544
561
  return Promise.race([
545
562
  typeof e == "function" ? e() : e,
546
563
  new Promise((s, n) => {
547
564
  setTimeout(() => {
548
- n(It(t));
565
+ n(Bt(t));
549
566
  }, t);
550
567
  })
551
568
  ]);
552
569
  }
553
- async function w(e) {
570
+ async function g(e) {
554
571
  let t;
555
572
  const s = new Promise((h) => {
556
573
  t = h;
@@ -558,22 +575,22 @@ async function w(e) {
558
575
  method: n,
559
576
  event: r,
560
577
  capture: i,
561
- postEvent: a = N,
562
- timeout: o
578
+ postEvent: o = B,
579
+ timeout: a
563
580
  } = e, u = (Array.isArray(r) ? r : [r]).map(
564
581
  (h) => E(h, (v) => (!i || i(v)) && t(v))
565
582
  );
566
583
  try {
567
- return a(n, e.params), await (o ? Ot(s, o) : s);
584
+ return o(n, e.params), await (a ? Mt(s, a) : s);
568
585
  } finally {
569
586
  u.forEach((h) => h());
570
587
  }
571
588
  }
572
- async function q(e, t, s, n = {}) {
589
+ async function O(e, t, s, n = {}) {
573
590
  const {
574
591
  result: r,
575
592
  error: i
576
- } = await w({
593
+ } = await g({
577
594
  ...n,
578
595
  method: "web_app_invoke_custom_method",
579
596
  event: "custom_method_invoked",
@@ -582,30 +599,30 @@ async function q(e, t, s, n = {}) {
582
599
  params: t,
583
600
  req_id: s
584
601
  },
585
- capture: kt(s)
602
+ capture: Nt(s)
586
603
  });
587
604
  if (i)
588
- throw m(ue, i);
605
+ throw m(fe, i);
589
606
  return r;
590
607
  }
591
- function et(...e) {
608
+ function st(...e) {
592
609
  return e.map((t) => {
593
610
  if (typeof t == "string")
594
611
  return t;
595
- if (M(t))
596
- return et(Object.entries(t).map((s) => s[1] && s[0]));
612
+ if (V(t))
613
+ return st(Object.entries(t).map((s) => s[1] && s[0]));
597
614
  if (Array.isArray(t))
598
- return et(...t);
615
+ return st(...t);
599
616
  }).filter(Boolean).join(" ");
600
617
  }
601
- function fn(...e) {
602
- return e.reduce((t, s) => (M(s) && Object.entries(s).forEach(([n, r]) => {
603
- const i = et(t[n], r);
618
+ function gn(...e) {
619
+ return e.reduce((t, s) => (V(s) && Object.entries(s).forEach(([n, r]) => {
620
+ const i = st(t[n], r);
604
621
  i.length && (t[n] = i);
605
622
  }), t), {});
606
623
  }
607
- function qt(e) {
608
- const t = xt(e);
624
+ function Vt(e) {
625
+ const t = At(e);
609
626
  return Math.sqrt(
610
627
  [0.299, 0.587, 0.114].reduce((s, n, r) => {
611
628
  const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
@@ -613,9 +630,9 @@ function qt(e) {
613
630
  }, 0)
614
631
  ) < 120;
615
632
  }
616
- class Ie {
633
+ class Oe {
617
634
  constructor(t) {
618
- c(this, "ee", new H()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
635
+ c(this, "ee", new N()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
619
636
  }
620
637
  /**
621
638
  * Clones current state and returns its copy.
@@ -634,20 +651,20 @@ class Ie {
634
651
  return this.state[t];
635
652
  }
636
653
  }
637
- class it {
654
+ class at {
638
655
  constructor(t) {
639
- c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new Ie(t), this.set = this.state.set.bind(this.state), this.get = this.state.get.bind(this.state), this.clone = this.state.clone.bind(this.state);
656
+ c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new Oe(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
657
  }
641
658
  }
642
- function Dt(e, t) {
643
- return (s) => S(t[s], e);
659
+ function $t(e, t) {
660
+ return (s) => C(t[s], e);
644
661
  }
645
- class ot extends it {
662
+ class ct extends at {
646
663
  constructor(t, s, n) {
647
- super(t), c(this, "supports"), this.supports = Dt(s, n);
664
+ super(t), c(this, "supports"), this.supports = $t(s, n);
648
665
  }
649
666
  }
650
- class Oe extends ot {
667
+ class De extends ct {
651
668
  constructor(t, s, n) {
652
669
  super({ isVisible: t }, s, {
653
670
  show: "web_app_setup_back_button",
@@ -676,19 +693,19 @@ class Oe extends ot {
676
693
  this.isVisible = !0;
677
694
  }
678
695
  }
679
- const Nt = A((e) => e instanceof Date ? e : new Date(x().parse(e) * 1e3), "Date");
680
- function at(e, t) {
681
- return new j((s) => {
696
+ const Lt = A((e) => e instanceof Date ? e : new Date(x().parse(e) * 1e3), "Date");
697
+ function ht(e, t) {
698
+ return new G((s) => {
682
699
  if (typeof s != "string" && !(s instanceof URLSearchParams))
683
700
  throw T();
684
701
  const n = typeof s == "string" ? new URLSearchParams(s) : s;
685
- return Rt(e, (r) => {
702
+ return Tt(e, (r) => {
686
703
  const i = n.get(r);
687
704
  return i === null ? void 0 : i;
688
705
  });
689
706
  }, !1, t);
690
707
  }
691
- const qe = g({
708
+ const Ne = w({
692
709
  id: x(),
693
710
  type: p(),
694
711
  title: p(),
@@ -697,7 +714,7 @@ const qe = g({
697
714
  from: "photo_url"
698
715
  },
699
716
  username: p().optional()
700
- }, "Chat").optional(), gt = g({
717
+ }, "Chat").optional(), mt = w({
701
718
  addedToAttachmentMenu: {
702
719
  type: P().optional(),
703
720
  from: "added_to_attachment_menu"
@@ -733,17 +750,17 @@ const qe = g({
733
750
  },
734
751
  username: p().optional()
735
752
  }, "User").optional();
736
- function Bt() {
737
- return at({
753
+ function Ht() {
754
+ return ht({
738
755
  authDate: {
739
- type: Nt(),
756
+ type: Lt(),
740
757
  from: "auth_date"
741
758
  },
742
759
  canSendAfter: {
743
760
  type: x().optional(),
744
761
  from: "can_send_after"
745
762
  },
746
- chat: qe,
763
+ chat: Ne,
747
764
  chatInstance: {
748
765
  type: p().optional(),
749
766
  from: "chat_instance"
@@ -757,35 +774,35 @@ function Bt() {
757
774
  type: p().optional(),
758
775
  from: "query_id"
759
776
  },
760
- receiver: gt,
777
+ receiver: mt,
761
778
  startParam: {
762
779
  type: p().optional(),
763
780
  from: "start_param"
764
781
  },
765
- user: gt
782
+ user: mt
766
783
  }, "InitData");
767
784
  }
768
- function De(e) {
785
+ function Be(e) {
769
786
  return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
770
787
  }
771
- function Ne(e) {
788
+ function Me(e) {
772
789
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
773
790
  }
774
- const Mt = A(
791
+ const Ut = A(
775
792
  (e) => {
776
- const t = Ct().optional();
777
- return Object.entries(nt(e)).reduce((s, [n, r]) => (s[De(n)] = t.parse(r), s), {});
793
+ const t = It().optional();
794
+ return Object.entries(rt(e)).reduce((s, [n, r]) => (s[Be(n)] = t.parse(r), s), {});
778
795
  },
779
796
  "ThemeParams"
780
797
  );
781
- function Vt(e) {
782
- return at({
798
+ function pt(e) {
799
+ return ht({
783
800
  botInline: {
784
801
  type: P().optional(),
785
802
  from: "tgWebAppBotInline"
786
803
  },
787
804
  initData: {
788
- type: Bt().optional(),
805
+ type: Ht().optional(),
789
806
  from: "tgWebAppData"
790
807
  },
791
808
  initDataRaw: {
@@ -805,7 +822,7 @@ function Vt(e) {
805
822
  from: "tgWebAppStartParam"
806
823
  },
807
824
  themeParams: {
808
- type: Mt(),
825
+ type: Ut(),
809
826
  from: "tgWebAppThemeParams"
810
827
  },
811
828
  version: {
@@ -814,121 +831,110 @@ function Vt(e) {
814
831
  }
815
832
  }).parse(e);
816
833
  }
817
- function $t(e) {
818
- return Vt(
834
+ function Wt(e) {
835
+ return pt(
819
836
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
820
837
  );
821
838
  }
822
- function Be() {
823
- return $t(window.location.href);
839
+ function Ve() {
840
+ return Wt(window.location.href);
824
841
  }
825
- function Lt() {
842
+ function Gt() {
826
843
  return performance.getEntriesByType("navigation")[0];
827
844
  }
828
- function Me() {
829
- const e = Lt();
845
+ function $e() {
846
+ const e = Gt();
830
847
  if (!e)
831
848
  throw new Error("Unable to get first navigation entry.");
832
- return $t(e.name);
849
+ return Wt(e.name);
833
850
  }
834
- function Ut(e) {
851
+ function jt(e) {
835
852
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
836
853
  }
837
- function Ht(e, t) {
838
- sessionStorage.setItem(Ut(e), JSON.stringify(t));
854
+ function zt(e, t) {
855
+ sessionStorage.setItem(jt(e), JSON.stringify(t));
839
856
  }
840
- function Wt(e) {
841
- const t = sessionStorage.getItem(Ut(e));
857
+ function Kt(e) {
858
+ const t = sessionStorage.getItem(jt(e));
842
859
  try {
843
860
  return t ? JSON.parse(t) : void 0;
844
861
  } catch {
845
862
  }
846
863
  }
847
- function Ve() {
848
- return Vt(Wt("launchParams") || "");
864
+ function Le() {
865
+ return pt(Kt("launchParams") || "");
849
866
  }
850
- function $e(e) {
867
+ function Jt(e) {
851
868
  return JSON.stringify(
852
869
  Object.fromEntries(
853
- Object.entries(e).map(([t, s]) => [Ne(t), s])
870
+ Object.entries(e).map(([t, s]) => [Me(t), s])
854
871
  )
855
872
  );
856
873
  }
857
- function Le(e) {
874
+ function He(e) {
858
875
  const {
859
876
  initDataRaw: t,
860
877
  themeParams: s,
861
878
  platform: n,
862
879
  version: r,
863
880
  showSettings: i,
864
- startParam: a,
865
- botInline: o
881
+ startParam: o,
882
+ botInline: a
866
883
  } = e, u = new URLSearchParams();
867
- return u.set("tgWebAppPlatform", n), u.set("tgWebAppThemeParams", $e(s)), u.set("tgWebAppVersion", r), t && u.set("tgWebAppData", t), a && u.set("tgWebAppStartParam", a), typeof i == "boolean" && u.set("tgWebAppShowSettings", i ? "1" : "0"), typeof o == "boolean" && u.set("tgWebAppBotInline", o ? "1" : "0"), u.toString();
884
+ return u.set("tgWebAppPlatform", n), u.set("tgWebAppThemeParams", Jt(s)), u.set("tgWebAppVersion", r), t && u.set("tgWebAppData", t), o && u.set("tgWebAppStartParam", o), typeof i == "boolean" && u.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && u.set("tgWebAppBotInline", a ? "1" : "0"), u.toString();
868
885
  }
869
- function Ue(e) {
870
- Ht("launchParams", Le(e));
886
+ function Ft(e) {
887
+ zt("launchParams", He(e));
871
888
  }
872
- function jt() {
889
+ function Qt() {
873
890
  for (const e of [
874
891
  // Try to retrieve launch parameters from the current location. This method can return
875
892
  // nothing in case, location was changed and then page was reloaded.
876
- Be,
893
+ Ve,
877
894
  // Then, try using the lower level API - window.performance.
878
- Me,
895
+ $e,
879
896
  // Finally, try to extract launch parameters from the session storage.
880
- Ve
897
+ Le
881
898
  ])
882
899
  try {
883
900
  const t = e();
884
- return Ue(t), t;
901
+ return Ft(t), t;
885
902
  } catch {
886
903
  }
887
904
  throw new Error("Unable to retrieve launch parameters from any known source.");
888
905
  }
889
- function Gt() {
890
- const e = Lt();
906
+ function Yt() {
907
+ const e = Gt();
891
908
  return !!(e && e.type === "reload");
892
909
  }
893
- function He() {
910
+ function Ue() {
894
911
  let e = 0;
895
912
  return () => (e += 1).toString();
896
913
  }
897
- function We() {
898
- let e = !1;
899
- const t = [];
900
- return [
901
- (s) => !e && t.push(s),
902
- () => {
903
- e || (e = !0, t.forEach((s) => s()));
904
- },
905
- e
906
- ];
907
- }
908
- const [je] = yt(He);
914
+ const [We] = Rt(Ue);
909
915
  function l(e, t) {
910
916
  return () => {
911
- const s = jt(), n = {
917
+ const s = Qt(), n = {
912
918
  ...s,
913
- postEvent: ke(s.version),
914
- createRequestId: je()
919
+ postEvent: qe(s.version),
920
+ createRequestId: We()
915
921
  };
916
922
  if (typeof e == "function")
917
923
  return e(n);
918
- const [r, i, a] = We(), o = t({
924
+ const [r, i, o] = Ct(), a = t({
919
925
  ...n,
920
926
  // State should only be passed only in case, current page was reloaded. If we don't add
921
927
  // this check, state restoration will work improperly in the web version of Telegram,
922
928
  // when we are always working in the same "session" (tab).
923
- state: Gt() ? Wt(e) : void 0,
929
+ state: Yt() ? Kt(e) : void 0,
924
930
  addCleanup: r
925
- }), u = (h) => (a || r(
931
+ }), u = (h) => (o || r(
926
932
  h.on("change", (v) => {
927
- Ht(e, v);
933
+ zt(e, v);
928
934
  })
929
935
  ), h);
930
936
  return [
931
- o instanceof Promise ? o.then(u) : u(o),
937
+ a instanceof Promise ? a.then(u) : u(a),
932
938
  i
933
939
  ];
934
940
  };
@@ -937,13 +943,13 @@ const Ge = l("backButton", ({
937
943
  postEvent: e,
938
944
  version: t,
939
945
  state: s = { isVisible: !1 }
940
- }) => new Oe(s.isVisible, t, e));
941
- class V extends ot {
946
+ }) => new De(s.isVisible, t, e));
947
+ class $ extends ct {
942
948
  constructor() {
943
949
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
944
950
  }
945
951
  }
946
- function zt(e) {
952
+ function Zt(e) {
947
953
  const t = e.available ? e : {
948
954
  available: !1,
949
955
  device_id: "",
@@ -961,7 +967,7 @@ function zt(e) {
961
967
  accessGranted: t.access_granted
962
968
  };
963
969
  }
964
- class ze extends V {
970
+ class je extends $ {
965
971
  constructor({ postEvent: t, version: s, ...n }) {
966
972
  super(n, s, {
967
973
  auth: "web_app_biometry_request_auth",
@@ -998,7 +1004,7 @@ class ze extends V {
998
1004
  reason: t,
999
1005
  ...s
1000
1006
  }) {
1001
- return this.authPromise || (this.authPromise = w({
1007
+ return this.authPromise || (this.authPromise = g({
1002
1008
  ...s,
1003
1009
  method: "web_app_biometry_request_auth",
1004
1010
  event: "biometry_auth_requested",
@@ -1032,14 +1038,14 @@ class ze extends V {
1032
1038
  * @returns Promise with true, if access was granted.
1033
1039
  */
1034
1040
  requestAccess({ reason: t, ...s } = {}) {
1035
- return this.accessPromise || (this.accessPromise = w({
1041
+ return this.accessPromise || (this.accessPromise = g({
1036
1042
  ...s,
1037
1043
  postEvent: this.postEvent,
1038
1044
  method: "web_app_biometry_request_access",
1039
1045
  event: "biometry_info_received",
1040
1046
  params: { reason: t || "" }
1041
1047
  }).then((n) => {
1042
- const r = zt(n);
1048
+ const r = Zt(n);
1043
1049
  return this.set(r), r.accessGranted;
1044
1050
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1045
1051
  }
@@ -1061,7 +1067,7 @@ class ze extends V {
1061
1067
  */
1062
1068
  async updateToken({ token: t, ...s } = {}) {
1063
1069
  return ["removed", "updated"].includes(
1064
- (await w({
1070
+ (await g({
1065
1071
  ...s,
1066
1072
  postEvent: this.postEvent,
1067
1073
  method: "web_app_biometry_update_token",
@@ -1071,29 +1077,35 @@ class ze extends V {
1071
1077
  );
1072
1078
  }
1073
1079
  }
1074
- async function Ke(e) {
1075
- return zt(
1076
- await w({
1080
+ async function ze(e) {
1081
+ return Zt(
1082
+ await g({
1077
1083
  ...e || {},
1078
1084
  method: "web_app_biometry_get_info",
1079
1085
  event: "biometry_info_received"
1080
1086
  })
1081
1087
  );
1082
1088
  }
1083
- const Je = l(
1089
+ const Ke = l(
1084
1090
  "biometryManager",
1085
- async ({ postEvent: e, version: t, state: s }) => new ze({
1086
- ...s || await Ke({ timeout: 1e3 }),
1091
+ async ({ postEvent: e, version: t, state: s }) => new je({
1092
+ ...s || C("web_app_biometry_get_info", t) ? s || await ze({ timeout: 1e3 }) : {
1093
+ available: !1,
1094
+ accessGranted: !1,
1095
+ accessRequested: !1,
1096
+ tokenSaved: !1,
1097
+ deviceId: ""
1098
+ },
1087
1099
  version: t,
1088
1100
  postEvent: e
1089
1101
  })
1090
1102
  );
1091
- class ct extends it {
1103
+ class ut extends at {
1092
1104
  constructor() {
1093
1105
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
1094
1106
  }
1095
1107
  }
1096
- class Qe extends ct {
1108
+ class Je extends ut {
1097
1109
  constructor(t, s) {
1098
1110
  super({ isConfirmationNeeded: t }), this.postEvent = s;
1099
1111
  }
@@ -1125,14 +1137,14 @@ const Fe = l(
1125
1137
  ({
1126
1138
  postEvent: e,
1127
1139
  state: t = { isConfirmationNeeded: !1 }
1128
- }) => new Qe(t.isConfirmationNeeded, e)
1140
+ }) => new Je(t.isConfirmationNeeded, e)
1129
1141
  );
1130
- class ht {
1142
+ class lt {
1131
1143
  constructor(t, s) {
1132
- c(this, "supports"), this.supports = Dt(t, s);
1144
+ c(this, "supports"), this.supports = $t(t, s);
1133
1145
  }
1134
1146
  }
1135
- function Ye(e) {
1147
+ function Qe(e) {
1136
1148
  if (Array.isArray(e))
1137
1149
  return e;
1138
1150
  if (typeof e == "string")
@@ -1144,9 +1156,9 @@ function Ye(e) {
1144
1156
  }
1145
1157
  throw T();
1146
1158
  }
1147
- class Ze extends j {
1159
+ class Ye extends G {
1148
1160
  constructor(t, s, n) {
1149
- super(Ye, s, n), c(this, "itemParser"), this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
1161
+ super(Qe, s, n), c(this, "itemParser"), this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
1150
1162
  }
1151
1163
  /**
1152
1164
  * Attempts to parse passed value
@@ -1162,13 +1174,13 @@ class Ze extends j {
1162
1174
  return this.itemParser = typeof t == "function" ? t : t.parse.bind(t), this;
1163
1175
  }
1164
1176
  }
1165
- function Xe(e) {
1166
- return new Ze((t) => t, !1, e);
1177
+ function Ze(e) {
1178
+ return new Ye((t) => t, !1, e);
1167
1179
  }
1168
- function wt(e, t) {
1180
+ function bt(e, t) {
1169
1181
  return Object.fromEntries(e.map((s) => [s, t]));
1170
1182
  }
1171
- class ts extends ht {
1183
+ class Xe extends lt {
1172
1184
  constructor(t, s, n) {
1173
1185
  super(t, {
1174
1186
  delete: "web_app_invoke_custom_method",
@@ -1184,7 +1196,7 @@ class ts extends ht {
1184
1196
  */
1185
1197
  async delete(t, s = {}) {
1186
1198
  const n = Array.isArray(t) ? t : [t];
1187
- n.length && await q(
1199
+ n.length && await O(
1188
1200
  "deleteStorageValues",
1189
1201
  { keys: n },
1190
1202
  this.createRequestId(),
@@ -1196,8 +1208,8 @@ class ts extends ht {
1196
1208
  * @param options - request execution options.
1197
1209
  */
1198
1210
  async getKeys(t = {}) {
1199
- return Xe().of(p()).parse(
1200
- await q(
1211
+ return Ze().of(p()).parse(
1212
+ await O(
1201
1213
  "getStorageKeys",
1202
1214
  {},
1203
1215
  this.createRequestId(),
@@ -1208,13 +1220,13 @@ class ts extends ht {
1208
1220
  async get(t, s = {}) {
1209
1221
  const n = Array.isArray(t) ? t : [t];
1210
1222
  if (!n.length)
1211
- return wt(n, "");
1212
- const r = await q(
1223
+ return bt(n, "");
1224
+ const r = await O(
1213
1225
  "getStorageValues",
1214
1226
  { keys: n },
1215
1227
  this.createRequestId(),
1216
1228
  { ...s, postEvent: this.postEvent }
1217
- ), i = g(wt(n, p()), "CloudStorageData").parse(r);
1229
+ ), i = w(bt(n, p()), "CloudStorageData").parse(r);
1218
1230
  return Array.isArray(t) ? i : i[t];
1219
1231
  }
1220
1232
  /**
@@ -1224,7 +1236,7 @@ class ts extends ht {
1224
1236
  * @param options - request execution options.
1225
1237
  */
1226
1238
  async set(t, s, n = {}) {
1227
- await q(
1239
+ await O(
1228
1240
  "saveStorageValue",
1229
1241
  { key: t, value: s },
1230
1242
  this.createRequestId(),
@@ -1232,10 +1244,10 @@ class ts extends ht {
1232
1244
  );
1233
1245
  }
1234
1246
  }
1235
- const es = l(
1236
- ({ createRequestId: e, postEvent: t, version: s }) => new ts(s, e, t)
1247
+ const ts = l(
1248
+ ({ createRequestId: e, postEvent: t, version: s }) => new Xe(s, e, t)
1237
1249
  );
1238
- class ss extends ht {
1250
+ class es extends lt {
1239
1251
  constructor(t, s) {
1240
1252
  super(t, {
1241
1253
  impactOccurred: "web_app_trigger_haptic_feedback",
@@ -1277,10 +1289,10 @@ class ss extends ht {
1277
1289
  this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
1278
1290
  }
1279
1291
  }
1280
- const ns = l(
1281
- ({ version: e, postEvent: t }) => new ss(e, t)
1292
+ const ss = l(
1293
+ ({ version: e, postEvent: t }) => new es(e, t)
1282
1294
  );
1283
- class rs {
1295
+ class ns {
1284
1296
  constructor(t) {
1285
1297
  this.initData = t;
1286
1298
  }
@@ -1353,13 +1365,13 @@ class rs {
1353
1365
  return this.initData.user;
1354
1366
  }
1355
1367
  }
1356
- const is = l(
1357
- ({ initData: e }) => e ? new rs(e) : void 0
1368
+ const rs = l(
1369
+ ({ initData: e }) => e ? new ns(e) : void 0
1358
1370
  );
1359
- function mn(e) {
1360
- return Bt().parse(e);
1371
+ function fn(e) {
1372
+ return Ht().parse(e);
1361
1373
  }
1362
- class os extends V {
1374
+ class is extends $ {
1363
1375
  constructor(t, s, n) {
1364
1376
  super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
1365
1377
  }
@@ -1382,14 +1394,14 @@ class os extends V {
1382
1394
  const { hostname: r, pathname: i } = new URL(t, window.location.href);
1383
1395
  if (r !== "t.me")
1384
1396
  throw new Error(`Incorrect hostname: ${r}`);
1385
- const a = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1386
- if (!a)
1397
+ const o = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1398
+ if (!o)
1387
1399
  throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
1388
- [, , n] = a;
1400
+ [, , n] = o;
1389
1401
  }
1390
1402
  this.isOpened = !0;
1391
1403
  try {
1392
- return (await w({
1404
+ return (await g({
1393
1405
  method: "web_app_open_invoice",
1394
1406
  event: "invoice_closed",
1395
1407
  params: { slug: n },
@@ -1403,13 +1415,19 @@ class os extends V {
1403
1415
  }
1404
1416
  }
1405
1417
  }
1406
- const as = l(
1407
- ({ version: e, postEvent: t }) => new os(!1, e, t)
1418
+ const os = l(
1419
+ ({ version: e, postEvent: t }) => new is(!1, e, t)
1408
1420
  );
1409
- class cs extends it {
1421
+ class as extends at {
1410
1422
  constructor({ postEvent: t, ...s }) {
1411
1423
  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;
1412
1424
  }
1425
+ /**
1426
+ * The MainButton background color.
1427
+ */
1428
+ get bgColor() {
1429
+ return this.get("bgColor");
1430
+ }
1413
1431
  /**
1414
1432
  * Sends current local state to the Telegram application.
1415
1433
  */
@@ -1419,10 +1437,35 @@ class cs extends it {
1419
1437
  is_active: this.isEnabled,
1420
1438
  is_progress_visible: this.isLoaderVisible,
1421
1439
  text: this.text,
1422
- color: this.backgroundColor,
1440
+ color: this.bgColor,
1423
1441
  text_color: this.textColor
1424
1442
  });
1425
1443
  }
1444
+ /**
1445
+ * Disables the MainButton.
1446
+ * @see Does not work on Android: https://github.com/Telegram-Mini-Apps/issues/issues/1
1447
+ */
1448
+ disable() {
1449
+ return this.isEnabled = !1, this;
1450
+ }
1451
+ /**
1452
+ * Enables the MainButton.
1453
+ */
1454
+ enable() {
1455
+ return this.isEnabled = !0, this;
1456
+ }
1457
+ /**
1458
+ * Hides the MainButton.
1459
+ */
1460
+ hide() {
1461
+ return this.isVisible = !1, this;
1462
+ }
1463
+ /**
1464
+ * Hides the MainButton loading indicator.
1465
+ */
1466
+ hideLoader() {
1467
+ return this.isLoaderVisible = !1, this;
1468
+ }
1426
1469
  set isEnabled(t) {
1427
1470
  this.setParams({ isEnabled: t });
1428
1471
  }
@@ -1450,49 +1493,6 @@ class cs extends it {
1450
1493
  get isVisible() {
1451
1494
  return this.get("isVisible");
1452
1495
  }
1453
- /**
1454
- * The MainButton background color.
1455
- */
1456
- get backgroundColor() {
1457
- return this.get("backgroundColor");
1458
- }
1459
- /**
1460
- * The MainButton text.
1461
- */
1462
- get text() {
1463
- return this.get("text");
1464
- }
1465
- /**
1466
- * The MainButton text color.
1467
- */
1468
- get textColor() {
1469
- return this.get("textColor");
1470
- }
1471
- /**
1472
- * Disables the MainButton.
1473
- * @see Does not work on Android: https://github.com/Telegram-Mini-Apps/issues/issues/1
1474
- */
1475
- disable() {
1476
- return this.isEnabled = !1, this;
1477
- }
1478
- /**
1479
- * Enables the MainButton.
1480
- */
1481
- enable() {
1482
- return this.isEnabled = !0, this;
1483
- }
1484
- /**
1485
- * Hides the MainButton.
1486
- */
1487
- hide() {
1488
- return this.isVisible = !1, this;
1489
- }
1490
- /**
1491
- * Hides the MainButton loading indicator.
1492
- */
1493
- hideLoader() {
1494
- return this.isLoaderVisible = !1, this;
1495
- }
1496
1496
  /**
1497
1497
  * Shows the MainButton.
1498
1498
  *
@@ -1524,10 +1524,10 @@ class cs extends it {
1524
1524
  }
1525
1525
  /**
1526
1526
  * Updates current Main Button color.
1527
- * @param backgroundColor - color to set.
1527
+ * @param bgColor - color to set.
1528
1528
  */
1529
- setBackgroundColor(t) {
1530
- return this.setParams({ backgroundColor: t });
1529
+ setBgColor(t) {
1530
+ return this.setParams({ bgColor: t });
1531
1531
  }
1532
1532
  /**
1533
1533
  * Allows setting multiple Main Button parameters.
@@ -1536,8 +1536,20 @@ class cs extends it {
1536
1536
  setParams(t) {
1537
1537
  return this.set(t), this.commit(), this;
1538
1538
  }
1539
+ /**
1540
+ * The MainButton text.
1541
+ */
1542
+ get text() {
1543
+ return this.get("text");
1544
+ }
1545
+ /**
1546
+ * The MainButton text color.
1547
+ */
1548
+ get textColor() {
1549
+ return this.get("textColor");
1550
+ }
1539
1551
  }
1540
- const hs = l(
1552
+ const cs = l(
1541
1553
  "mainButton",
1542
1554
  ({
1543
1555
  postEvent: e,
@@ -1548,13 +1560,13 @@ const hs = l(
1548
1560
  text: "",
1549
1561
  isLoaderVisible: !1,
1550
1562
  textColor: t.buttonTextColor || "#ffffff",
1551
- backgroundColor: t.buttonColor || "#000000"
1563
+ bgColor: t.buttonColor || "#000000"
1552
1564
  }
1553
- }) => new cs({ ...s, postEvent: e })
1565
+ }) => new as({ ...s, postEvent: e })
1554
1566
  );
1555
- function ps() {
1556
- return at({
1557
- contact: g({
1567
+ function hs() {
1568
+ return ht({
1569
+ contact: w({
1558
1570
  userId: {
1559
1571
  type: x(),
1560
1572
  from: "user_id"
@@ -1573,24 +1585,24 @@ function ps() {
1573
1585
  }
1574
1586
  }),
1575
1587
  authDate: {
1576
- type: Nt(),
1588
+ type: Lt(),
1577
1589
  from: "auth_date"
1578
1590
  },
1579
1591
  hash: p()
1580
1592
  }, "RequestedContact");
1581
1593
  }
1582
- function Kt(e, t) {
1594
+ function Xt(e, t) {
1583
1595
  return (s) => {
1584
1596
  const [n, r] = t[s];
1585
- return S(n, r, e);
1597
+ return C(n, r, e);
1586
1598
  };
1587
1599
  }
1588
- function us(e) {
1600
+ function ps(e) {
1589
1601
  return new Promise((t) => {
1590
1602
  setTimeout(t, e);
1591
1603
  });
1592
1604
  }
1593
- class ls extends V {
1605
+ class us extends $ {
1594
1606
  constructor({ postEvent: t, createRequestId: s, version: n, botInline: r, ...i }) {
1595
1607
  super(i, n, {
1596
1608
  requestPhoneAccess: "web_app_request_phone",
@@ -1599,8 +1611,8 @@ class ls extends V {
1599
1611
  setHeaderColor: "web_app_set_header_color",
1600
1612
  setBackgroundColor: "web_app_set_background_color"
1601
1613
  }), 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;
1602
- const a = this.supports.bind(this);
1603
- this.supports = (o) => a(o) ? o !== "switchInlineQuery" || r : !1, this.supportsParam = Kt(n, {
1614
+ const o = this.supports.bind(this);
1615
+ this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Xt(n, {
1604
1616
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1605
1617
  });
1606
1618
  }
@@ -1611,8 +1623,8 @@ class ls extends V {
1611
1623
  async getRequestedContact({
1612
1624
  timeout: t = 1e4
1613
1625
  } = {}) {
1614
- return ps().parse(
1615
- await q(
1626
+ return hs().parse(
1627
+ await O(
1616
1628
  "getRequestedContact",
1617
1629
  {},
1618
1630
  this.createRequestId(),
@@ -1651,7 +1663,7 @@ class ls extends V {
1651
1663
  * True if current Mini App background color is recognized as dark.
1652
1664
  */
1653
1665
  get isDark() {
1654
- return qt(this.bgColor);
1666
+ return Vt(this.bgColor);
1655
1667
  }
1656
1668
  /**
1657
1669
  * Informs the Telegram app that the Mini App is ready to be displayed.
@@ -1680,15 +1692,15 @@ class ls extends V {
1680
1692
  throw new Error("Access denied.");
1681
1693
  const s = Date.now() + t;
1682
1694
  let n = 50;
1683
- return Ot(async () => {
1695
+ return Mt(async () => {
1684
1696
  for (; Date.now() < s; ) {
1685
1697
  try {
1686
1698
  return await this.getRequestedContact();
1687
1699
  } catch {
1688
1700
  }
1689
- await us(n), n += 50;
1701
+ await ps(n), n += 50;
1690
1702
  }
1691
- throw It(t);
1703
+ throw Bt(t);
1692
1704
  }, t);
1693
1705
  }
1694
1706
  /**
@@ -1701,7 +1713,7 @@ class ls extends V {
1701
1713
  * @see requestContact
1702
1714
  */
1703
1715
  async requestPhoneAccess(t = {}) {
1704
- return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = w({
1716
+ return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = g({
1705
1717
  ...t,
1706
1718
  method: "web_app_request_phone",
1707
1719
  event: "phone_requested",
@@ -1713,7 +1725,7 @@ class ls extends V {
1713
1725
  * @param options - additional options.
1714
1726
  */
1715
1727
  async requestWriteAccess(t = {}) {
1716
- return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = w({
1728
+ return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = g({
1717
1729
  ...t,
1718
1730
  method: "web_app_request_write_access",
1719
1731
  event: "write_access_requested",
@@ -1743,7 +1755,7 @@ class ls extends V {
1743
1755
  * @param color - color key or RGB color.
1744
1756
  */
1745
1757
  setHeaderColor(t) {
1746
- this.postEvent("web_app_set_header_color", rt(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
1758
+ this.postEvent("web_app_set_header_color", it(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
1747
1759
  }
1748
1760
  /**
1749
1761
  * Updates current Mini App background color.
@@ -1771,7 +1783,7 @@ class ls extends V {
1771
1783
  this.postEvent("web_app_switch_inline_query", { query: t, chat_types: s });
1772
1784
  }
1773
1785
  }
1774
- const ds = l(
1786
+ const ls = l(
1775
1787
  "miniApp",
1776
1788
  ({
1777
1789
  themeParams: e,
@@ -1781,9 +1793,9 @@ const ds = l(
1781
1793
  headerColor: e.headerBgColor || "#000000"
1782
1794
  },
1783
1795
  ...n
1784
- }) => new ls({ ...n, ...s, botInline: t })
1796
+ }) => new us({ ...n, ...s, botInline: t })
1785
1797
  );
1786
- function _s(e) {
1798
+ function ds(e) {
1787
1799
  const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
1788
1800
  let r;
1789
1801
  if (s.length > 64)
@@ -1793,21 +1805,21 @@ function _s(e) {
1793
1805
  if (n.length > 3)
1794
1806
  throw new Error(`Buttons have incorrect size: ${n.length}`);
1795
1807
  return n.length ? r = n.map((i) => {
1796
- const { id: a = "" } = i;
1797
- if (a.length > 64)
1798
- throw new Error(`Button ID has incorrect size: ${a}`);
1808
+ const { id: o = "" } = i;
1809
+ if (o.length > 64)
1810
+ throw new Error(`Button ID has incorrect size: ${o}`);
1799
1811
  if (!i.type || i.type === "default" || i.type === "destructive") {
1800
- const o = i.text.trim();
1801
- if (!o.length || o.length > 64) {
1812
+ const a = i.text.trim();
1813
+ if (!a.length || a.length > 64) {
1802
1814
  const u = i.type || "default";
1803
1815
  throw new Error(`Button text with type "${u}" has incorrect size: ${i.text.length}`);
1804
1816
  }
1805
- return { ...i, text: o, id: a };
1817
+ return { ...i, text: a, id: o };
1806
1818
  }
1807
- return { ...i, id: a };
1819
+ return { ...i, id: o };
1808
1820
  }) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
1809
1821
  }
1810
- class gs extends V {
1822
+ class _s extends $ {
1811
1823
  constructor(t, s, n) {
1812
1824
  super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
1813
1825
  }
@@ -1836,11 +1848,11 @@ class gs extends V {
1836
1848
  throw new Error("Popup is already opened.");
1837
1849
  this.isOpened = !0;
1838
1850
  try {
1839
- const { button_id: s = null } = await w({
1851
+ const { button_id: s = null } = await g({
1840
1852
  event: "popup_closed",
1841
1853
  method: "web_app_open_popup",
1842
1854
  postEvent: this.postEvent,
1843
- params: _s(t)
1855
+ params: ds(t)
1844
1856
  });
1845
1857
  return s;
1846
1858
  } finally {
@@ -1849,9 +1861,9 @@ class gs extends V {
1849
1861
  }
1850
1862
  }
1851
1863
  const ws = l(
1852
- ({ postEvent: e, version: t }) => new gs(!1, t, e)
1864
+ ({ postEvent: e, version: t }) => new _s(!1, t, e)
1853
1865
  );
1854
- class fs extends V {
1866
+ class gs extends $ {
1855
1867
  constructor(t, s, n) {
1856
1868
  super({ isOpened: t }, s, {
1857
1869
  close: "web_app_close_scan_qr_popup",
@@ -1884,7 +1896,7 @@ class fs extends V {
1884
1896
  throw new Error("QR scanner is already opened.");
1885
1897
  this.isOpened = !0;
1886
1898
  try {
1887
- return (await w({
1899
+ return (await g({
1888
1900
  method: "web_app_open_scan_qr_popup",
1889
1901
  event: ["qr_text_received", "scan_qr_popup_closed"],
1890
1902
  postEvent: this.postEvent,
@@ -1895,10 +1907,10 @@ class fs extends V {
1895
1907
  }
1896
1908
  }
1897
1909
  }
1898
- const ms = l(
1899
- ({ version: e, postEvent: t }) => new fs(!1, e, t)
1910
+ const fs = l(
1911
+ ({ version: e, postEvent: t }) => new gs(!1, e, t)
1900
1912
  );
1901
- class bs extends ot {
1913
+ class ms extends ct {
1902
1914
  constructor(t, s, n) {
1903
1915
  super({ isVisible: t }, s, {
1904
1916
  show: "web_app_setup_settings_button",
@@ -1927,18 +1939,18 @@ class bs extends ot {
1927
1939
  this.isVisible = !0;
1928
1940
  }
1929
1941
  }
1930
- const vs = l(
1942
+ const bs = l(
1931
1943
  "settingsButton",
1932
1944
  ({
1933
1945
  version: e,
1934
1946
  postEvent: t,
1935
1947
  state: s = { isVisible: !1 }
1936
- }) => new bs(s.isVisible, e, t)
1948
+ }) => new ms(s.isVisible, e, t)
1937
1949
  );
1938
- function Jt(e) {
1939
- return Mt().parse(e);
1950
+ function te(e) {
1951
+ return Ut().parse(e);
1940
1952
  }
1941
- class ys extends ct {
1953
+ class vs extends ut {
1942
1954
  /**
1943
1955
  * @since v6.10
1944
1956
  */
@@ -1977,7 +1989,7 @@ class ys extends ct {
1977
1989
  * value is calculated according to theme bg color.
1978
1990
  */
1979
1991
  get isDark() {
1980
- return !this.bgColor || qt(this.bgColor);
1992
+ return !this.bgColor || Vt(this.bgColor);
1981
1993
  }
1982
1994
  get linkColor() {
1983
1995
  return this.get("linkColor");
@@ -2003,7 +2015,7 @@ class ys extends ct {
2003
2015
  */
2004
2016
  listen() {
2005
2017
  return E("theme_changed", (t) => {
2006
- this.set(Jt(t.theme_params));
2018
+ this.set(te(t.theme_params));
2007
2019
  });
2008
2020
  }
2009
2021
  /**
@@ -2016,23 +2028,23 @@ class ys extends ct {
2016
2028
  return this.get("textColor");
2017
2029
  }
2018
2030
  }
2019
- const Es = l(
2031
+ const ys = l(
2020
2032
  "themeParams",
2021
2033
  ({ themeParams: e, state: t = e, addCleanup: s }) => {
2022
- const n = new ys(t);
2034
+ const n = new vs(t);
2023
2035
  return s(n.listen()), n;
2024
2036
  }
2025
2037
  );
2026
- function bn(e = {}) {
2027
- return w({
2038
+ function mn(e = {}) {
2039
+ return g({
2028
2040
  ...e,
2029
2041
  method: "web_app_request_theme",
2030
2042
  event: "theme_changed"
2031
- }).then(Jt);
2043
+ }).then(te);
2032
2044
  }
2033
- class Ps extends ht {
2045
+ class Es extends lt {
2034
2046
  constructor(t, s, n) {
2035
- 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, {
2047
+ super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Xt(t, {
2036
2048
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2037
2049
  });
2038
2050
  }
@@ -2047,7 +2059,7 @@ class Ps extends ht {
2047
2059
  */
2048
2060
  openLink(t, s) {
2049
2061
  const n = new URL(t, window.location.href).toString();
2050
- if (!S("web_app_open_link", this.version)) {
2062
+ if (!C("web_app_open_link", this.version)) {
2051
2063
  window.open(n, "_blank");
2052
2064
  return;
2053
2065
  }
@@ -2066,7 +2078,7 @@ class Ps extends ht {
2066
2078
  const { hostname: s, pathname: n, search: r } = new URL(t, window.location.href);
2067
2079
  if (s !== "t.me")
2068
2080
  throw new Error(`URL has not allowed hostname: ${s}. Only "t.me" is allowed`);
2069
- if (!S("web_app_open_tg_link", this.version)) {
2081
+ if (!C("web_app_open_tg_link", this.version)) {
2070
2082
  window.location.href = t;
2071
2083
  return;
2072
2084
  }
@@ -2081,41 +2093,41 @@ class Ps extends ht {
2081
2093
  async readTextFromClipboard() {
2082
2094
  const t = this.createRequestId(), {
2083
2095
  data: s = null
2084
- } = await w({
2096
+ } = await g({
2085
2097
  method: "web_app_read_text_from_clipboard",
2086
2098
  event: "clipboard_text_received",
2087
2099
  postEvent: this.postEvent,
2088
2100
  params: { req_id: t },
2089
- capture: kt(t)
2101
+ capture: Nt(t)
2090
2102
  });
2091
2103
  return s;
2092
2104
  }
2093
2105
  }
2094
- const Rs = l(
2095
- ({ version: e, postEvent: t, createRequestId: s }) => new Ps(e, s, t)
2106
+ const Ps = l(
2107
+ ({ version: e, postEvent: t, createRequestId: s }) => new Es(e, s, t)
2096
2108
  );
2097
- async function Qt(e = {}) {
2109
+ async function ee(e = {}) {
2098
2110
  const {
2099
2111
  is_expanded: t,
2100
2112
  is_state_stable: s,
2101
2113
  ...n
2102
- } = await w({
2114
+ } = await g({
2103
2115
  ...e,
2104
2116
  method: "web_app_request_viewport",
2105
2117
  event: "viewport_changed"
2106
2118
  });
2107
2119
  return { ...n, isExpanded: t, isStateStable: s };
2108
2120
  }
2109
- function O(e) {
2121
+ function q(e) {
2110
2122
  return e < 0 ? 0 : e;
2111
2123
  }
2112
- class xs extends ct {
2124
+ class Rs extends ut {
2113
2125
  constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
2114
2126
  super({
2115
- height: O(n),
2127
+ height: q(n),
2116
2128
  isExpanded: i,
2117
- stableHeight: O(s),
2118
- width: O(r)
2129
+ stableHeight: q(s),
2130
+ width: q(r)
2119
2131
  }), c(this, "postEvent"), this.postEvent = t;
2120
2132
  }
2121
2133
  /**
@@ -2124,7 +2136,7 @@ class xs extends ct {
2124
2136
  * @param options - options to request fresh data.
2125
2137
  */
2126
2138
  async sync(t) {
2127
- const { isStateStable: s, ...n } = await Qt(t);
2139
+ const { isStateStable: s, ...n } = await ee(t);
2128
2140
  this.set({
2129
2141
  ...n,
2130
2142
  stableHeight: s ? n.height : this.get("stableHeight")
@@ -2177,12 +2189,12 @@ class xs extends ct {
2177
2189
  width: n,
2178
2190
  is_expanded: r,
2179
2191
  is_state_stable: i
2180
- } = t, a = O(s);
2192
+ } = t, o = q(s);
2181
2193
  this.set({
2182
- height: a,
2194
+ height: o,
2183
2195
  isExpanded: r,
2184
- width: O(n),
2185
- ...i ? { stableHeight: a } : {}
2196
+ width: q(n),
2197
+ ...i ? { stableHeight: o } : {}
2186
2198
  });
2187
2199
  });
2188
2200
  }
@@ -2216,23 +2228,23 @@ class xs extends ct {
2216
2228
  return this.stableHeight === this.height;
2217
2229
  }
2218
2230
  }
2219
- const Cs = l(
2231
+ const xs = l(
2220
2232
  "viewport",
2221
2233
  async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
2222
- let r = !1, i = 0, a = 0, o = 0;
2234
+ let r = !1, i = 0, o = 0, a = 0;
2223
2235
  if (e)
2224
- r = e.isExpanded, i = e.height, a = e.width, o = e.stableHeight;
2236
+ r = e.isExpanded, i = e.height, o = e.width, a = e.stableHeight;
2225
2237
  else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2226
- r = !0, i = window.innerHeight, a = window.innerWidth, o = window.innerHeight;
2238
+ r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
2227
2239
  else {
2228
- const h = await Qt({ timeout: 1e3, postEvent: s });
2229
- r = h.isExpanded, i = h.height, a = h.width, o = h.isStateStable ? i : 0;
2240
+ const h = await ee({ timeout: 1e3, postEvent: s });
2241
+ r = h.isExpanded, i = h.height, o = h.width, a = h.isStateStable ? i : 0;
2230
2242
  }
2231
- const u = new xs({
2243
+ const u = new Rs({
2232
2244
  postEvent: s,
2233
2245
  height: i,
2234
- width: a,
2235
- stableHeight: o,
2246
+ width: o,
2247
+ stableHeight: a,
2236
2248
  isExpanded: r
2237
2249
  });
2238
2250
  return n(u.listen()), u;
@@ -2241,24 +2253,24 @@ const Cs = l(
2241
2253
  function R(e, t) {
2242
2254
  document.documentElement.style.setProperty(e, t);
2243
2255
  }
2244
- function vn(e, t, s) {
2245
- s || (s = (o) => `--tg-${o}-color`);
2256
+ function bn(e, t, s) {
2257
+ s || (s = (a) => `--tg-${a}-color`);
2246
2258
  const n = s("header"), r = s("bg"), i = () => {
2247
- const { headerColor: o } = e;
2248
- if (rt(o))
2249
- R(n, o);
2259
+ const { headerColor: a } = e;
2260
+ if (it(a))
2261
+ R(n, a);
2250
2262
  else {
2251
2263
  const { bgColor: u, secondaryBgColor: h } = t;
2252
- o === "bg_color" && u ? R(n, u) : o === "secondary_bg_color" && h && R(n, h);
2264
+ a === "bg_color" && u ? R(n, u) : a === "secondary_bg_color" && h && R(n, h);
2253
2265
  }
2254
2266
  R(r, e.bgColor);
2255
- }, a = [
2267
+ }, o = [
2256
2268
  t.on("change", i),
2257
2269
  e.on("change", i)
2258
2270
  ];
2259
- return i(), () => a.forEach((o) => o());
2271
+ return i(), () => o.forEach((a) => a());
2260
2272
  }
2261
- function yn(e, t) {
2273
+ function vn(e, t) {
2262
2274
  t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
2263
2275
  const s = () => {
2264
2276
  Object.entries(e.getState()).forEach(([n, r]) => {
@@ -2267,23 +2279,23 @@ function yn(e, t) {
2267
2279
  };
2268
2280
  return s(), e.on("change", s);
2269
2281
  }
2270
- function En(e, t) {
2282
+ function yn(e, t) {
2271
2283
  t || (t = (h) => `--tg-viewport-${h}`);
2272
2284
  const [
2273
2285
  s,
2274
2286
  n,
2275
2287
  r
2276
- ] = ["height", "width", "stable-height"].map((h) => t(h)), i = () => R(s, `${e.height}px`), a = () => R(n, `${e.width}px`), o = () => R(r, `${e.stableHeight}px`), u = [
2288
+ ] = ["height", "width", "stable-height"].map((h) => t(h)), i = () => R(s, `${e.height}px`), o = () => R(n, `${e.width}px`), a = () => R(r, `${e.stableHeight}px`), u = [
2277
2289
  e.on("change:height", i),
2278
- e.on("change:width", a),
2279
- e.on("change:stableHeight", o)
2290
+ e.on("change:width", o),
2291
+ e.on("change:stableHeight", a)
2280
2292
  ];
2281
- return i(), a(), o(), () => u.forEach((h) => h());
2293
+ return i(), o(), a(), () => u.forEach((h) => h());
2282
2294
  }
2283
- function Ss(e = !0) {
2295
+ function Cs(e = !0) {
2284
2296
  const t = [
2285
2297
  E("reload_iframe", () => {
2286
- N("iframe_will_reload"), window.location.reload();
2298
+ B("iframe_will_reload"), window.location.reload();
2287
2299
  })
2288
2300
  ], s = () => t.forEach((n) => n());
2289
2301
  if (e) {
@@ -2295,25 +2307,65 @@ function Ss(e = !0) {
2295
2307
  () => document.head.removeChild(n)
2296
2308
  );
2297
2309
  }
2298
- return N("iframe_ready", { reload_supported: !0 }), s;
2310
+ return B("iframe_ready", { reload_supported: !0 }), s;
2299
2311
  }
2300
- function Ts() {
2312
+ function Ss() {
2301
2313
  return typeof window > "u";
2302
2314
  }
2303
- async function Pn() {
2304
- if (St(window))
2315
+ async function En() {
2316
+ if (Ot(window))
2305
2317
  return !0;
2306
2318
  try {
2307
- return await w({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
2319
+ return await g({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
2308
2320
  } catch {
2309
2321
  return !1;
2310
2322
  }
2311
2323
  }
2312
- function As(e) {
2324
+ function Pn(e) {
2325
+ const t = typeof e == "string" ? pt(e) : e;
2326
+ Ft(t);
2327
+ function s(r) {
2328
+ if (typeof r == "string")
2329
+ try {
2330
+ const { eventType: i } = kt(r);
2331
+ i === "web_app_request_theme" && et("theme_changed", {
2332
+ theme_params: JSON.parse(Jt(t.themeParams))
2333
+ }), i === "web_app_request_viewport" && et("viewport_changed", {
2334
+ width: window.innerWidth,
2335
+ height: window.innerHeight,
2336
+ is_state_stable: !0,
2337
+ is_expanded: !0
2338
+ });
2339
+ } catch {
2340
+ }
2341
+ }
2342
+ if (ot()) {
2343
+ const r = window.parent.postMessage.bind(window.parent);
2344
+ window.parent.postMessage = (i) => {
2345
+ s(i), r(i);
2346
+ };
2347
+ return;
2348
+ }
2349
+ if (qt(window)) {
2350
+ const r = window.external.notify.bind(window.external);
2351
+ window.external.notify = (i) => {
2352
+ s(i), r(i);
2353
+ };
2354
+ return;
2355
+ }
2356
+ const n = window.TelegramWebviewProxy;
2357
+ window.TelegramWebviewProxy = {
2358
+ ...n || {},
2359
+ postEvent(...r) {
2360
+ s(JSON.stringify({ eventType: r[0], eventData: r[1] })), n && n.postEvent(...r);
2361
+ }
2362
+ };
2363
+ }
2364
+ function Ts(e) {
2313
2365
  return e instanceof W;
2314
2366
  }
2315
2367
  function Rn(e, t) {
2316
- return As(e) && e.type === t;
2368
+ return Ts(e) && e.type === t;
2317
2369
  }
2318
2370
  function J(e, t) {
2319
2371
  let s, n, r;
@@ -2323,13 +2375,13 @@ function J(e, t) {
2323
2375
  params: n
2324
2376
  });
2325
2377
  }
2326
- class ks {
2327
- constructor(t, s, n = N) {
2328
- if (c(this, "history"), c(this, "ee", new H()), 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)
2329
- throw m(_e, "History should not be empty.");
2378
+ class As {
2379
+ constructor(t, s, n = B) {
2380
+ if (c(this, "history"), c(this, "ee", new N()), 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)
2381
+ throw m(ve, "History should not be empty.");
2330
2382
  if (s < 0 || s >= t.length)
2331
2383
  throw m(
2332
- ge,
2384
+ ye,
2333
2385
  "Index should not be zero and higher or equal than history size."
2334
2386
  );
2335
2387
  this.history = t.map((r) => J(r, ""));
@@ -2444,30 +2496,30 @@ class ks {
2444
2496
  this.postEvent("web_app_setup_back_button", { is_visible: !!this.index });
2445
2497
  }
2446
2498
  }
2447
- function Q({
2499
+ function F({
2448
2500
  params: e,
2449
2501
  ...t
2450
2502
  }) {
2451
2503
  return { ...e || { hash: "", search: "" }, ...t };
2452
2504
  }
2453
- function B(e, t) {
2505
+ function M(e, t) {
2454
2506
  return e.startsWith(t) ? e : `${t}${e}`;
2455
2507
  }
2456
- function L(e) {
2508
+ function H(e) {
2457
2509
  return new URL(
2458
- typeof e == "string" ? e : `${e.pathname || ""}${B(e.search || "", "?")}${B(e.hash || "", "#")}`,
2510
+ typeof e == "string" ? e : `${e.pathname || ""}${M(e.search || "", "?")}${M(e.hash || "", "#")}`,
2459
2511
  "http://a"
2460
2512
  );
2461
2513
  }
2462
2514
  function U(e) {
2463
- const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = L(e);
2515
+ const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = H(e);
2464
2516
  return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
2465
2517
  }
2466
- function F(e, t, s) {
2518
+ function Q(e, t, s) {
2467
2519
  let n, r;
2468
2520
  typeof e == "string" ? n = e : (n = U(e), s = e.state, r = e.id);
2469
- const { pathname: i, search: a, hash: o } = new URL(n, `http://a${B(t, "/")}`);
2470
- return { id: r, pathname: i, params: { hash: o, search: a, state: s } };
2521
+ const { pathname: i, search: o, hash: a } = new URL(n, `http://a${M(t, "/")}`);
2522
+ return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
2471
2523
  }
2472
2524
  async function D(e) {
2473
2525
  return e === 0 ? !0 : Promise.race([
@@ -2490,32 +2542,32 @@ async function Is() {
2490
2542
  for (; e; )
2491
2543
  e = await D(-1);
2492
2544
  }
2493
- function Ft(e) {
2494
- return L(e).pathname;
2545
+ function se(e) {
2546
+ return H(e).pathname;
2495
2547
  }
2496
- const ft = 0, Y = 1, Z = 2;
2497
- class Yt {
2548
+ const vt = 0, Y = 1, Z = 2;
2549
+ class ne {
2498
2550
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2499
- c(this, "navigator"), c(this, "ee", new H()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: a }) => {
2500
- if (a === null)
2551
+ c(this, "navigator"), c(this, "ee", new N()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
2552
+ if (o === null)
2501
2553
  return this.push(this.parsePath(window.location.href));
2502
- a === ft ? window.history.forward() : a === Y && this.back(), a === Z && this.forward();
2554
+ o === vt ? window.history.forward() : o === Y && this.back(), o === Z && this.forward();
2503
2555
  }), c(this, "onNavigatorChange", async ({
2504
- to: a,
2505
- from: o,
2556
+ to: o,
2557
+ from: a,
2506
2558
  delta: u
2507
2559
  }) => {
2508
2560
  this.attached && await this.syncHistory(), this.ee.emit("change", {
2509
2561
  delta: u,
2510
- from: Q(o),
2511
- to: Q(a),
2562
+ from: F(a),
2563
+ to: F(o),
2512
2564
  navigator: this
2513
2565
  });
2514
- }), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new ks(
2515
- t.map((a) => F(a, "/")),
2566
+ }), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new As(
2567
+ t.map((o) => Q(o, "/")),
2516
2568
  s,
2517
2569
  n
2518
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Ft(i || "");
2570
+ ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = se(i || "");
2519
2571
  }
2520
2572
  /**
2521
2573
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2599,7 +2651,7 @@ class Yt {
2599
2651
  * Navigation history.
2600
2652
  */
2601
2653
  get history() {
2602
- return this.navigator.history.map(Q);
2654
+ return this.navigator.history.map(F);
2603
2655
  }
2604
2656
  /**
2605
2657
  * Path, including pathname, search and hash.
@@ -2642,19 +2694,19 @@ class Yt {
2642
2694
  * // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
2643
2695
  */
2644
2696
  parsePath(t) {
2645
- let s = L(t);
2646
- return this.hashMode && (s = L(s.hash.slice(1))), {
2697
+ let s = H(t);
2698
+ return this.hashMode && (s = H(s.hash.slice(1))), {
2647
2699
  pathname: s.pathname,
2648
2700
  search: s.search,
2649
2701
  hash: s.hash
2650
2702
  };
2651
2703
  }
2652
2704
  push(t, s) {
2653
- const n = F(t, this.path), { state: r = s } = n.params;
2705
+ const n = Q(t, this.path), { state: r = s } = n.params;
2654
2706
  this.navigator.push({ ...n, params: { ...n.params, state: r } });
2655
2707
  }
2656
2708
  replace(t, s) {
2657
- const n = F(t, this.path), { state: r = s } = n.params;
2709
+ const n = Q(t, this.path), { state: r = s } = n.params;
2658
2710
  this.navigator.replace({ ...n, params: { ...n.params, state: r } });
2659
2711
  }
2660
2712
  /**
@@ -2663,8 +2715,8 @@ class Yt {
2663
2715
  * @param value - path presented as string or URLLike.
2664
2716
  */
2665
2717
  renderPath(t) {
2666
- const s = (this.base.length === 1 ? "" : this.base) + B(U(t), "/");
2667
- return this.hashMode ? B(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2718
+ const s = (this.base.length === 1 ? "" : this.base) + M(U(t), "/");
2719
+ return this.hashMode ? M(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2668
2720
  }
2669
2721
  /**
2670
2722
  * Synchronizes current navigator state with browser history.
@@ -2672,7 +2724,7 @@ class Yt {
2672
2724
  async syncHistory() {
2673
2725
  window.removeEventListener("popstate", this.onPopState);
2674
2726
  const { state: t } = this, s = this.renderPath(this);
2675
- await Is(), this.hasPrev && this.hasNext ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s), window.history.pushState(Z, ""), await D(-1)) : this.hasPrev ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(Z, ""), await D(-1)) : (window.history.replaceState(ft, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2727
+ await Is(), this.hasPrev && this.hasNext ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s), window.history.pushState(Z, ""), await D(-1)) : this.hasPrev ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(Z, ""), await D(-1)) : (window.history.replaceState(vt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2676
2728
  }
2677
2729
  /**
2678
2730
  * Current query parameters.
@@ -2690,39 +2742,39 @@ class Yt {
2690
2742
  return (this.navigator.current.params || {}).state;
2691
2743
  }
2692
2744
  }
2693
- function Os(e) {
2745
+ function ks(e) {
2694
2746
  e || (e = {});
2695
2747
  const { href: t, hash: s } = window.location;
2696
2748
  let n = U(
2697
2749
  e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
2698
2750
  );
2699
- const r = e.base ? Ft(e.base) : void 0;
2751
+ const r = e.base ? se(e.base) : void 0;
2700
2752
  if (r) {
2701
2753
  if (!n.startsWith(r))
2702
2754
  throw m(
2703
- we,
2755
+ Ee,
2704
2756
  `Path "${n}" expected to be starting with "${r}"`
2705
2757
  );
2706
2758
  n = n.slice(r.length);
2707
2759
  }
2708
- return new Yt([n], 0, e);
2760
+ return new ne([n], 0, e);
2709
2761
  }
2710
2762
  function xn(e) {
2711
2763
  const t = e.match(/#(.+)/);
2712
2764
  return t ? t[1] : null;
2713
2765
  }
2714
2766
  function qs(e, t) {
2715
- if (Gt()) {
2767
+ if (Yt()) {
2716
2768
  const s = sessionStorage.getItem(e);
2717
2769
  if (s)
2718
2770
  try {
2719
2771
  const { index: n, history: r } = JSON.parse(s);
2720
- return new Yt(r, n, t);
2772
+ return new ne(r, n, t);
2721
2773
  } catch (n) {
2722
2774
  console.error("Unable to restore hash navigator state.", n);
2723
2775
  }
2724
2776
  }
2725
- return Os(t);
2777
+ return ks(t);
2726
2778
  }
2727
2779
  function Cn(e, t) {
2728
2780
  const s = qs(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
@@ -2733,31 +2785,36 @@ function Cn(e, t) {
2733
2785
  }
2734
2786
  function d(e, t) {
2735
2787
  function s(n) {
2736
- return (r, i, a) => (o) => {
2737
- const u = o[i] || [], h = { ...o, [r]: n(...u) };
2738
- return /* @__PURE__ */ mt(a, { ...h });
2788
+ return function(i, o, a) {
2789
+ return (u) => {
2790
+ const h = {
2791
+ ...u,
2792
+ [i]: n(o)
2793
+ };
2794
+ return /* @__PURE__ */ yt(a, { ...h });
2795
+ };
2739
2796
  };
2740
2797
  }
2741
2798
  return [s(e), s(t)];
2742
2799
  }
2743
- const Zt = Xt(void 0);
2744
- function Ds() {
2745
- const e = te(Zt);
2800
+ const re = ie(void 0);
2801
+ function Os() {
2802
+ const e = oe(re);
2746
2803
  if (!e)
2747
2804
  throw new Error("useSDK was used outside the SDKProvider.");
2748
2805
  return e;
2749
2806
  }
2750
2807
  function _(e) {
2751
2808
  function t(n) {
2752
- const r = Ds(), [i, a] = bt(
2809
+ const r = Os(), [i, o] = Et(
2753
2810
  n ? void 0 : () => {
2754
- if (Ts())
2811
+ if (Ss())
2755
2812
  throw new Error("Using hooks on the server side, you must explicitly specify ssr = true option");
2756
2813
  return r.use(e);
2757
2814
  }
2758
2815
  );
2759
- return C(() => {
2760
- a(r.use(e));
2816
+ return S(() => {
2817
+ o(r.use(e));
2761
2818
  }, [r]), i;
2762
2819
  }
2763
2820
  function s(n) {
@@ -2770,245 +2827,246 @@ function _(e) {
2770
2827
  }
2771
2828
  return [t, s];
2772
2829
  }
2773
- const [Ns, Bs] = _(Ge), [Sn, Tn] = d(
2774
- Ns,
2775
- Bs
2776
- ), [Ms, Vs] = _(Je), [An, kn] = d(
2777
- Ms,
2778
- Vs
2779
- ), [$s, Ls] = _(Fe), [In, On] = d(
2780
- $s,
2781
- Ls
2782
- ), [Us, Hs] = _(es), [qn, Dn] = d(
2783
- Us,
2830
+ const [Ds, Ns] = _(Ge), [Sn, Tn] = d(
2831
+ Ds,
2832
+ Ns
2833
+ ), [Bs, Ms] = _(Ke), [An, In] = d(
2834
+ Bs,
2835
+ Ms
2836
+ ), [Vs, $s] = _(Fe), [kn, qn] = d(
2837
+ Vs,
2838
+ $s
2839
+ ), [Ls, Hs] = _(ts), [On, Dn] = d(
2840
+ Ls,
2784
2841
  Hs
2785
- ), [Ws, js] = _(ns), [Nn, Bn] = d(
2786
- Ws,
2787
- js
2788
- ), [Gs, zs] = _(is), [Mn, Vn] = d(Gs, zs), [Ks, Js] = _(as), [$n, Ln] = d(Ks, Js), [Qs, Fs] = _(hs), [Un, Hn] = d(Qs, Fs), [Ys, Zs] = _(ds), [Wn, jn] = d(Ys, Zs), [Xs, tn] = _(ws), [Gn, zn] = d(Xs, tn), [en, sn] = _(ms), [Kn, Jn] = d(en, sn), [nn, rn] = _(vs), [Qn, Fn] = d(
2789
- nn,
2790
- rn
2791
- ), [on, an] = _(Es), [Yn, Zn] = d(on, an);
2842
+ ), [Us, Ws] = _(ss), [Nn, Bn] = d(
2843
+ Us,
2844
+ Ws
2845
+ ), [Gs, js] = _(rs), [Mn, Vn] = d(Gs, js), [zs, Ks] = _(os), [$n, Ln] = d(zs, Ks), [Js, Fs] = _(cs), [Hn, Un] = d(Js, Fs), [Qs, Ys] = _(ls), [Wn, Gn] = d(Qs, Ys), [Zs, Xs] = _(ws), [jn, zn] = d(Zs, Xs), [tn, en] = _(fs), [Kn, Jn] = d(tn, en), [sn, nn] = _(bs), [Fn, Qn] = d(
2846
+ sn,
2847
+ nn
2848
+ ), [rn, on] = _(ys), [Yn, Zn] = d(rn, on);
2792
2849
  function Xn() {
2793
- return vt(jt, []);
2850
+ return Pt(Qt, []);
2794
2851
  }
2795
- const [cn, hn] = _(Rs), [tr, er] = d(cn, hn), [pn, un] = _(Cs), [sr, nr] = d(pn, un);
2852
+ const [an, cn] = _(Ps), [tr, er] = d(an, cn), [hn, pn] = _(xs), [sr, nr] = d(hn, pn);
2796
2853
  function rr({ children: e, acceptCustomStyles: t, debug: s }) {
2797
- const n = dt(!0), [r, i] = bt(/* @__PURE__ */ new Map()), a = dt(r), o = ee(
2854
+ const n = gt(!0), [r, i] = Et(/* @__PURE__ */ new Map()), o = gt(r), a = ae(
2798
2855
  (h) => {
2799
2856
  n.current && i((v) => (h && h(v), new Map(v)));
2800
2857
  },
2801
2858
  []
2802
- ), u = vt(() => ({
2859
+ ), u = Pt(() => ({
2803
2860
  use(h, ...v) {
2804
- const pt = r.get(h);
2805
- if (pt)
2806
- return pt;
2861
+ const dt = r.get(h);
2862
+ if (dt)
2863
+ return dt;
2807
2864
  let b, K;
2808
2865
  try {
2809
2866
  b = h(...v);
2810
2867
  } catch (f) {
2811
2868
  K = f;
2812
2869
  }
2813
- function $(f) {
2870
+ function L(f) {
2814
2871
  return r.set(h, f), f;
2815
2872
  }
2816
2873
  if (K)
2817
- return $({ error: K });
2818
- let k;
2819
- if (Array.isArray(b) && (k = b[1], b = b[0]), !b)
2820
- return $({ result: b, cleanup: k });
2821
- function ut(f) {
2874
+ return L({ error: K });
2875
+ let I;
2876
+ if (Array.isArray(b) && (I = b[1], b = b[0]), !b)
2877
+ return L({ result: b, cleanup: I });
2878
+ function _t(f) {
2822
2879
  if ("on" in f) {
2823
- const I = f.on("change", () => o()), lt = k;
2824
- k = () => {
2825
- lt && lt(), I();
2880
+ const k = f.on("change", () => a()), wt = I;
2881
+ I = () => {
2882
+ wt && wt(), k();
2826
2883
  };
2827
2884
  }
2828
- return { result: f, cleanup: k };
2885
+ return { result: f, cleanup: I };
2829
2886
  }
2830
2887
  return b instanceof Promise ? (b.then(
2831
- (f) => o((I) => I.set(h, ut(f))),
2832
- (f) => o((I) => I.set(h, { error: f }))
2833
- ), $({})) : $(ut(b));
2888
+ (f) => a((k) => k.set(h, _t(f))),
2889
+ (f) => a((k) => k.set(h, { error: f }))
2890
+ ), L({})) : L(_t(b));
2834
2891
  }
2835
2892
  }), [r]);
2836
- return C(() => (n.current = !0, () => {
2893
+ return S(() => (n.current = !0, () => {
2837
2894
  n.current = !1;
2838
- }), []), C(() => {
2839
- if (Tt())
2840
- return Ss(t);
2841
- }, [t]), C(() => {
2842
- oe(s || !1);
2843
- }, [s]), C(() => {
2844
- a.current = r;
2845
- }, [r]), C(() => () => {
2846
- a.current.forEach((h) => {
2895
+ }), []), S(() => {
2896
+ if (ot())
2897
+ return Cs(t);
2898
+ }, [t]), S(() => {
2899
+ le(s || !1);
2900
+ }, [s]), S(() => {
2901
+ o.current = r;
2902
+ }, [r]), S(() => () => {
2903
+ o.current.forEach((h) => {
2847
2904
  "cleanup" in h && h.cleanup && h.cleanup();
2848
2905
  });
2849
- }, []), /* @__PURE__ */ mt(Zt.Provider, { value: u, children: e });
2906
+ }, []), /* @__PURE__ */ yt(re.Provider, { value: u, children: e });
2850
2907
  }
2851
2908
  export {
2852
- Oe as BackButton,
2853
- ks as BasicNavigator,
2854
- ze as BiometryManager,
2855
- Yt as BrowserNavigator,
2856
- Qe as ClosingBehavior,
2857
- ts as CloudStorage,
2858
- we as ERR_INVALID_PATH_BASE,
2859
- ue as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2860
- he as ERR_METHOD_PARAMETER_UNSUPPORTED,
2861
- ce as ERR_METHOD_UNSUPPORTED,
2862
- _e as ERR_NAVIGATION_HISTORY_EMPTY,
2863
- ge as ERR_NAVIGATION_INDEX_INVALID,
2864
- _n as ERR_NAVIGATION_ITEM_INVALID,
2865
- Pt as ERR_PARSE,
2866
- gn as ERR_SSR_INIT,
2867
- le as ERR_TIMED_OUT,
2868
- de as ERR_UNEXPECTED_TYPE,
2869
- pe as ERR_UNKNOWN_ENV,
2870
- H as EventEmitter,
2871
- ss as HapticFeedback,
2872
- rs as InitData,
2873
- os as Invoice,
2874
- cs as MainButton,
2875
- ls as MiniApp,
2876
- gs as Popup,
2877
- fs as QRScanner,
2909
+ De as BackButton,
2910
+ As as BasicNavigator,
2911
+ je as BiometryManager,
2912
+ ne as BrowserNavigator,
2913
+ Je as ClosingBehavior,
2914
+ Xe as CloudStorage,
2915
+ Ee as ERR_INVALID_PATH_BASE,
2916
+ fe as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2917
+ we as ERR_METHOD_PARAMETER_UNSUPPORTED,
2918
+ _e as ERR_METHOD_UNSUPPORTED,
2919
+ ve as ERR_NAVIGATION_HISTORY_EMPTY,
2920
+ ye as ERR_NAVIGATION_INDEX_INVALID,
2921
+ dn as ERR_NAVIGATION_ITEM_INVALID,
2922
+ St as ERR_PARSE,
2923
+ _n as ERR_SSR_INIT,
2924
+ me as ERR_TIMED_OUT,
2925
+ be as ERR_UNEXPECTED_TYPE,
2926
+ ge as ERR_UNKNOWN_ENV,
2927
+ N as EventEmitter,
2928
+ es as HapticFeedback,
2929
+ ns as InitData,
2930
+ is as Invoice,
2931
+ as as MainButton,
2932
+ us as MiniApp,
2933
+ _s as Popup,
2934
+ gs as QRScanner,
2878
2935
  W as SDKError,
2879
2936
  rr as SDKProvider,
2880
- bs as SettingsButton,
2881
- ys as ThemeParams,
2882
- Ps as Utils,
2883
- xs as Viewport,
2884
- Xe as array,
2885
- vn as bindMiniAppCSSVars,
2886
- yn as bindThemeParamsCSSVars,
2887
- En as bindViewportCSSVars,
2937
+ ms as SettingsButton,
2938
+ vs as ThemeParams,
2939
+ Es as Utils,
2940
+ Rs as Viewport,
2941
+ Ze as array,
2942
+ bn as bindMiniAppCSSVars,
2943
+ vn as bindThemeParamsCSSVars,
2944
+ yn as bindViewportCSSVars,
2888
2945
  P as boolean,
2889
- kt as captureSameReq,
2890
- et as classNames,
2891
- Se as compareVersions,
2892
- Os as createBrowserNavigatorFromLocation,
2893
- ke as createPostEvent,
2894
- L as createSafeURL,
2895
- Nt as date,
2946
+ Nt as captureSameReq,
2947
+ st as classNames,
2948
+ Ie as compareVersions,
2949
+ ks as createBrowserNavigatorFromLocation,
2950
+ qe as createPostEvent,
2951
+ H as createSafeURL,
2952
+ Lt as date,
2896
2953
  xn as getHash,
2897
- Ft as getPathname,
2954
+ se as getPathname,
2898
2955
  Ge as initBackButton,
2899
- Je as initBiometryManager,
2956
+ Ke as initBiometryManager,
2900
2957
  Fe as initClosingBehavior,
2901
- es as initCloudStorage,
2902
- ns as initHapticFeedback,
2903
- is as initInitData,
2904
- as as initInvoice,
2905
- hs as initMainButton,
2906
- ds as initMiniApp,
2958
+ ts as initCloudStorage,
2959
+ ss as initHapticFeedback,
2960
+ rs as initInitData,
2961
+ os as initInvoice,
2962
+ cs as initMainButton,
2963
+ ls as initMiniApp,
2907
2964
  Cn as initNavigator,
2908
2965
  ws as initPopup,
2909
- ms as initQRScanner,
2910
- vs as initSettingsButton,
2911
- Es as initThemeParams,
2912
- Rs as initUtils,
2913
- Cs as initViewport,
2914
- Ss as initWeb,
2915
- q as invokeCustomMethod,
2916
- qt as isColorDark,
2917
- Tt as isIframe,
2918
- Gt as isPageReload,
2919
- rt as isRGB,
2920
- fe as isRGBShort,
2921
- As as isSDKError,
2966
+ fs as initQRScanner,
2967
+ bs as initSettingsButton,
2968
+ ys as initThemeParams,
2969
+ Ps as initUtils,
2970
+ xs as initViewport,
2971
+ Cs as initWeb,
2972
+ O as invokeCustomMethod,
2973
+ Vt as isColorDark,
2974
+ ot as isIframe,
2975
+ Yt as isPageReload,
2976
+ it as isRGB,
2977
+ Pe as isRGBShort,
2978
+ Ts as isSDKError,
2922
2979
  Rn as isSDKErrorOfType,
2923
- Ts as isSSR,
2924
- Pn as isTMA,
2925
- g as json,
2926
- fn as mergeClassNames,
2980
+ Ss as isSSR,
2981
+ En as isTMA,
2982
+ w as json,
2983
+ gn as mergeClassNames,
2984
+ Pn as mockTelegramEnv,
2927
2985
  x as number,
2928
2986
  z as off,
2929
2987
  E as on,
2930
- mn as parseInitData,
2931
- Vt as parseLaunchParams,
2932
- Jt as parseThemeParams,
2933
- N as postEvent,
2934
- w as request,
2935
- Ke as requestBiometryInfo,
2936
- bn as requestThemeParams,
2937
- Qt as requestViewport,
2938
- jt as retrieveLaunchParams,
2939
- Ct as rgb,
2940
- at as searchParams,
2941
- Le as serializeLaunchParams,
2942
- $e as serializeThemeParams,
2988
+ fn as parseInitData,
2989
+ pt as parseLaunchParams,
2990
+ te as parseThemeParams,
2991
+ B as postEvent,
2992
+ g as request,
2993
+ ze as requestBiometryInfo,
2994
+ mn as requestThemeParams,
2995
+ ee as requestViewport,
2996
+ Qt as retrieveLaunchParams,
2997
+ It as rgb,
2998
+ ht as searchParams,
2999
+ He as serializeLaunchParams,
3000
+ Jt as serializeThemeParams,
2943
3001
  R as setCSSVar,
2944
- oe as setDebug,
3002
+ le as setDebug,
2945
3003
  wn as setTargetOrigin,
2946
3004
  p as string,
2947
- re as subscribe,
2948
- S as supports,
2949
- Ae as targetOrigin,
2950
- xt as toRGB,
2951
- Et as unsubscribe,
3005
+ pe as subscribe,
3006
+ C as supports,
3007
+ ke as targetOrigin,
3008
+ At as toRGB,
3009
+ xt as unsubscribe,
2952
3010
  U as urlToPath,
2953
- Bs as useBackButton,
2954
- Ns as useBackButtonRaw,
2955
- Vs as useBiometryManager,
2956
- Ms as useBiometryManagerRaw,
2957
- Ls as useClosingBehavior,
2958
- $s as useClosingBehaviorRaw,
3011
+ Ns as useBackButton,
3012
+ Ds as useBackButtonRaw,
3013
+ Ms as useBiometryManager,
3014
+ Bs as useBiometryManagerRaw,
3015
+ $s as useClosingBehavior,
3016
+ Vs as useClosingBehaviorRaw,
2959
3017
  Hs as useCloudStorage,
2960
- Us as useCloudStorageRaw,
2961
- js as useHapticFeedback,
2962
- Ws as useHapticFeedbackRaw,
2963
- zs as useInitData,
3018
+ Ls as useCloudStorageRaw,
3019
+ Ws as useHapticFeedback,
3020
+ Us as useHapticFeedbackRaw,
3021
+ js as useInitData,
2964
3022
  Gs as useInitDataRaw,
2965
- Js as useInvoice,
2966
- Ks as useInvoiceRaw,
3023
+ Ks as useInvoice,
3024
+ zs as useInvoiceRaw,
2967
3025
  Xn as useLaunchParams,
2968
3026
  Fs as useMainButton,
2969
- Qs as useMainButtonRaw,
2970
- Zs as useMiniApp,
2971
- Ys as useMiniAppRaw,
2972
- tn as usePopup,
2973
- Xs as usePopupRaw,
2974
- sn as useQRScanner,
2975
- en as useQRScannerRaw,
2976
- Ds as useSDK,
2977
- rn as useSettingsButton,
2978
- nn as useSettingsButtonRaw,
2979
- an as useThemeParams,
2980
- on as useThemeParamsRaw,
2981
- hn as useUtils,
2982
- cn as useUtilsRaw,
2983
- un as useViewport,
2984
- pn as useViewportRaw,
3027
+ Js as useMainButtonRaw,
3028
+ Ys as useMiniApp,
3029
+ Qs as useMiniAppRaw,
3030
+ Xs as usePopup,
3031
+ Zs as usePopupRaw,
3032
+ en as useQRScanner,
3033
+ tn as useQRScannerRaw,
3034
+ Os as useSDK,
3035
+ nn as useSettingsButton,
3036
+ sn as useSettingsButtonRaw,
3037
+ on as useThemeParams,
3038
+ rn as useThemeParamsRaw,
3039
+ cn as useUtils,
3040
+ an as useUtilsRaw,
3041
+ pn as useViewport,
3042
+ hn as useViewportRaw,
2985
3043
  Tn as withBackButton,
2986
3044
  Sn as withBackButtonRaw,
2987
- kn as withBiometryManager,
3045
+ In as withBiometryManager,
2988
3046
  An as withBiometryManagerRaw,
2989
- On as withClosingBehavior,
2990
- In as withClosingBehaviorRaw,
3047
+ qn as withClosingBehavior,
3048
+ kn as withClosingBehaviorRaw,
2991
3049
  Dn as withCloudStorage,
2992
- qn as withCloudStorageRaw,
3050
+ On as withCloudStorageRaw,
2993
3051
  Bn as withHapticFeedback,
2994
3052
  Nn as withHapticFeedbackRaw,
2995
3053
  Vn as withInitData,
2996
3054
  Mn as withInitDataRaw,
2997
3055
  Ln as withInvoice,
2998
3056
  $n as withInvoiceRaw,
2999
- Hn as withMainButton,
3000
- Un as withMainButtonRaw,
3001
- jn as withMiniApp,
3057
+ Un as withMainButton,
3058
+ Hn as withMainButtonRaw,
3059
+ Gn as withMiniApp,
3002
3060
  Wn as withMiniAppRaw,
3003
3061
  zn as withPopup,
3004
- Gn as withPopupRaw,
3062
+ jn as withPopupRaw,
3005
3063
  Jn as withQRScanner,
3006
3064
  Kn as withQRScannerRaw,
3007
- Fn as withSettingsButton,
3008
- Qn as withSettingsButtonRaw,
3065
+ Qn as withSettingsButton,
3066
+ Fn as withSettingsButtonRaw,
3009
3067
  Zn as withThemeParams,
3010
3068
  Yn as withThemeParamsRaw,
3011
- Ot as withTimeout,
3069
+ Mt as withTimeout,
3012
3070
  er as withUtils,
3013
3071
  tr as withUtilsRaw,
3014
3072
  nr as withViewport,