@tma.js/sdk 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/dts/components/BackButton/initBackButton.d.ts +1 -1
  2. package/dist/dts/components/BiometryManager/initBiometryManager.d.ts +1 -1
  3. package/dist/dts/components/ClosingBehavior/initClosingBehavior.d.ts +1 -1
  4. package/dist/dts/components/CloudStorage/initCloudStorage.d.ts +1 -1
  5. package/dist/dts/components/HapticFeedback/initHapticFeedback.d.ts +1 -1
  6. package/dist/dts/components/InitData/initInitData.d.ts +1 -1
  7. package/dist/dts/components/Invoice/initInvoice.d.ts +1 -1
  8. package/dist/dts/components/MainButton/initMainButton.d.ts +1 -1
  9. package/dist/dts/components/MiniApp/initMiniApp.d.ts +1 -1
  10. package/dist/dts/components/Popup/initPopup.d.ts +1 -1
  11. package/dist/dts/components/QRScanner/initQRScanner.d.ts +1 -1
  12. package/dist/dts/components/SettingsButton/initSettingsButton.d.ts +1 -1
  13. package/dist/dts/components/ThemeParams/initThemeParams.d.ts +1 -1
  14. package/dist/dts/components/Utils/initUtils.d.ts +1 -1
  15. package/dist/dts/components/Viewport/initViewport.d.ts +1 -2
  16. package/dist/dts/index.d.ts +1 -1
  17. package/dist/dts/misc/createCleanup.d.ts +11 -0
  18. package/dist/dts/misc/createComponentInitFn/createComponentInitFn.d.ts +7 -6
  19. package/dist/dts/misc/createComponentInitFn/types.d.ts +28 -20
  20. package/dist/dts/navigation/BrowserNavigator/BrowserNavigator.d.ts +1 -1
  21. package/dist/dts/navigation/BrowserNavigator/types.d.ts +5 -4
  22. package/dist/index.cjs +1 -1
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.iife.js +1 -1
  25. package/dist/index.iife.js.map +1 -1
  26. package/dist/index.js +581 -576
  27. package/dist/index.js.map +1 -1
  28. package/package.json +1 -1
  29. package/dist/dts/components/Viewport/initViewportFromRequest.d.ts +0 -10
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
- var Lt = Object.defineProperty;
2
- var Bt = (e, t, s) => t in e ? Lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var c = (e, t, s) => (Bt(e, typeof t != "symbol" ? t + "" : t, s), s);
4
- function at(e, t) {
1
+ var Dt = Object.defineProperty;
2
+ var Vt = (e, t, s) => t in e ? Dt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var c = (e, t, s) => (Vt(e, typeof t != "symbol" ? t + "" : t, s), s);
4
+ function it(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 ct(e) {
12
- const t = L(), { count: s } = t;
13
- t.unsubscribe(e), s && !t.count && ae();
11
+ function ot(e) {
12
+ const t = M(), { count: s } = t;
13
+ t.unsubscribe(e), s && !t.count && ne();
14
14
  }
15
- function Ot(e) {
16
- return L().subscribe(e), () => ct(e);
15
+ function $t(e) {
16
+ return M().subscribe(e), () => ot(e);
17
17
  }
18
- class Ut {
18
+ class Mt {
19
19
  constructor(t, s = {}) {
20
20
  this.scope = t, this.options = s;
21
21
  }
@@ -31,12 +31,12 @@ class Ut {
31
31
  second: "2-digit",
32
32
  fractionalSecondDigits: 3,
33
33
  timeZone: "UTC"
34
- }).format(n), { textColor: i, bgColor: o } = this.options, a = "font-weight: bold;padding: 0 5px;border-radius:5px";
34
+ }).format(n), { textColor: i, bgColor: a } = this.options, o = "font-weight: bold;padding: 0 5px;border-radius:5px";
35
35
  console[t](
36
36
  `%c${r}%c / %c${this.scope}`,
37
- `${a};background-color: lightblue;color:black`,
37
+ `${o};background-color: lightblue;color:black`,
38
38
  "",
39
- `${a};${i ? `color:${i};` : ""}${o ? `background-color:${o}` : ""}`,
39
+ `${o};${i ? `color:${i};` : ""}${a ? `background-color:${a}` : ""}`,
40
40
  ...s
41
41
  );
42
42
  }
@@ -55,21 +55,21 @@ class Ut {
55
55
  this.print("log", ...t);
56
56
  }
57
57
  }
58
- const D = new Ut("SDK", {
58
+ const F = new Mt("SDK", {
59
59
  bgColor: "forestgreen",
60
60
  textColor: "white"
61
61
  });
62
- let j = !1;
63
- const st = ({ event: e, args: [t] }) => {
64
- D.log("Event received:", t === void 0 ? { name: e } : { name: e, data: t });
62
+ let G = !1;
63
+ const et = ({ event: e, args: [t] }) => {
64
+ F.log("Event received:", t === void 0 ? { name: e } : { name: e, data: t });
65
65
  };
66
- function ts(e) {
67
- j !== e && (j = e, e ? Ot(st) : ct(st));
66
+ function Ze(e) {
67
+ G !== e && (G = e, e ? $t(et) : ot(et));
68
68
  }
69
- function Wt(...e) {
70
- j && D.log(...e);
69
+ function Lt(...e) {
70
+ G && F.log(...e);
71
71
  }
72
- class V {
72
+ class D {
73
73
  constructor() {
74
74
  c(this, "listeners", /* @__PURE__ */ new Map());
75
75
  c(this, "listenersCount", 0);
@@ -141,22 +141,22 @@ class V {
141
141
  }
142
142
  }
143
143
  }
144
- function F(e, t, s) {
144
+ function j(e, t, s) {
145
145
  return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
146
146
  }
147
- class $ extends Error {
147
+ class V extends Error {
148
148
  constructor(t, s, n) {
149
- super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, $.prototype);
149
+ super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, V.prototype);
150
150
  }
151
151
  }
152
152
  function f(e, t, s) {
153
- return new $(e, t, s);
153
+ return new V(e, t, s);
154
154
  }
155
- const Ht = "ERR_METHOD_UNSUPPORTED", Gt = "ERR_METHOD_PARAMETER_UNSUPPORTED", jt = "ERR_UNKNOWN_ENV", Ft = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", zt = "ERR_TIMED_OUT", Jt = "ERR_UNEXPECTED_TYPE", ht = "ERR_PARSE", Qt = "ERR_NAVIGATION_LIST_EMPTY", Yt = "ERR_NAVIGATION_CURSOR_INVALID", es = "ERR_NAVIGATION_ITEM_INVALID", pt = "ERR_SSR_INIT", Zt = "ERR_INVALID_PATH_BASE";
156
- function P() {
157
- return f(Jt, "Value has unexpected type");
155
+ const Bt = "ERR_METHOD_UNSUPPORTED", Ot = "ERR_METHOD_PARAMETER_UNSUPPORTED", Ut = "ERR_UNKNOWN_ENV", Wt = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", Ht = "ERR_TIMED_OUT", Gt = "ERR_UNEXPECTED_TYPE", at = "ERR_PARSE", jt = "ERR_NAVIGATION_LIST_EMPTY", zt = "ERR_NAVIGATION_CURSOR_INVALID", Ke = "ERR_NAVIGATION_ITEM_INVALID", Xe = "ERR_SSR_INIT", Ft = "ERR_INVALID_PATH_BASE";
156
+ function E() {
157
+ return f(Gt, "Value has unexpected type");
158
158
  }
159
- class M {
159
+ class $ {
160
160
  constructor(t, s, n) {
161
161
  this.parser = t, this.isOptional = s, this.type = n;
162
162
  }
@@ -172,7 +172,7 @@ class M {
172
172
  return this.parser(t);
173
173
  } catch (s) {
174
174
  throw f(
175
- ht,
175
+ at,
176
176
  `Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
177
177
  s
178
178
  );
@@ -182,10 +182,10 @@ class M {
182
182
  return this.isOptional = !0, this;
183
183
  }
184
184
  }
185
- function x(e, t) {
186
- return () => new M(e, !1, t);
185
+ function P(e, t) {
186
+ return () => new $(e, !1, t);
187
187
  }
188
- const w = x((e) => {
188
+ const w = P((e) => {
189
189
  if (typeof e == "boolean")
190
190
  return e;
191
191
  const t = String(e);
@@ -193,26 +193,26 @@ const w = x((e) => {
193
193
  return !0;
194
194
  if (t === "0" || t === "false")
195
195
  return !1;
196
- throw P();
196
+ throw E();
197
197
  }, "boolean");
198
- function ut(e, t) {
198
+ function ct(e, t) {
199
199
  const s = {};
200
200
  for (const n in e) {
201
201
  const r = e[n];
202
202
  if (!r)
203
203
  continue;
204
- let i, o;
204
+ let i, a;
205
205
  if (typeof r == "function" || "parse" in r)
206
- i = n, o = typeof r == "function" ? r : r.parse.bind(r);
206
+ i = n, a = typeof r == "function" ? r : r.parse.bind(r);
207
207
  else {
208
- const { type: a } = r;
209
- i = r.from || n, o = typeof a == "function" ? a : a.parse.bind(a);
208
+ const { type: o } = r;
209
+ i = r.from || n, a = typeof o == "function" ? o : o.parse.bind(o);
210
210
  }
211
211
  try {
212
- const a = o(t(i));
213
- a !== void 0 && (s[n] = a);
214
- } catch (a) {
215
- throw f(ht, `Unable to parse field "${n}"`, a);
212
+ const o = a(t(i));
213
+ o !== void 0 && (s[n] = o);
214
+ } catch (o) {
215
+ throw f(at, `Unable to parse field "${n}"`, o);
216
216
  }
217
217
  }
218
218
  return s;
@@ -220,16 +220,16 @@ function ut(e, t) {
220
220
  function J(e) {
221
221
  let t = e;
222
222
  if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
223
- throw P();
223
+ throw E();
224
224
  return t;
225
225
  }
226
226
  function d(e, t) {
227
- return new M((s) => {
227
+ return new $((s) => {
228
228
  const n = J(s);
229
- return ut(e, (r) => n[r]);
229
+ return ct(e, (r) => n[r]);
230
230
  }, !1, t);
231
231
  }
232
- const v = x((e) => {
232
+ const y = P((e) => {
233
233
  if (typeof e == "number")
234
234
  return e;
235
235
  if (typeof e == "string") {
@@ -237,19 +237,19 @@ const v = x((e) => {
237
237
  if (!Number.isNaN(t))
238
238
  return t;
239
239
  }
240
- throw P();
240
+ throw E();
241
241
  }, "number");
242
242
  function Q(e) {
243
243
  return /^#[\da-f]{6}$/i.test(e);
244
244
  }
245
- function Xt(e) {
245
+ function Jt(e) {
246
246
  return /^#[\da-f]{3}$/i.test(e);
247
247
  }
248
- function lt(e) {
248
+ function ht(e) {
249
249
  const t = e.replace(/\s/g, "").toLowerCase();
250
250
  if (Q(t))
251
251
  return t;
252
- if (Xt(t)) {
252
+ if (Jt(t)) {
253
253
  let n = "#";
254
254
  for (let r = 0; r < 3; r += 1)
255
255
  n += t[1 + r].repeat(2);
@@ -263,30 +263,30 @@ function lt(e) {
263
263
  return n + (i.length === 1 ? "0" : "") + i;
264
264
  }, "#");
265
265
  }
266
- const h = x((e) => {
266
+ const h = P((e) => {
267
267
  if (typeof e == "string" || typeof e == "number")
268
268
  return e.toString();
269
- throw P();
270
- }, "string"), dt = x((e) => lt(h().parse(e)), "rgb");
271
- function Kt(e) {
269
+ throw E();
270
+ }, "string"), pt = P((e) => ht(h().parse(e)), "rgb");
271
+ function Qt(e) {
272
272
  return d({
273
273
  eventType: h(),
274
274
  eventData: (t) => t
275
275
  }).parse(e);
276
276
  }
277
- function te() {
277
+ function Yt() {
278
278
  ["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
279
279
  delete window[e];
280
280
  });
281
281
  }
282
- function ee(e, t) {
282
+ function Zt(e, t) {
283
283
  window.dispatchEvent(new MessageEvent("message", {
284
284
  data: JSON.stringify({ eventType: e, eventData: t }),
285
285
  // We specify window.parent to imitate the case, the parent iframe sent us this event.
286
286
  source: window.parent
287
287
  }));
288
288
  }
289
- function se() {
289
+ function Kt() {
290
290
  [
291
291
  ["TelegramGameProxy_receiveEvent"],
292
292
  // Windows Phone.
@@ -298,16 +298,16 @@ function se() {
298
298
  let t = window;
299
299
  e.forEach((s, n, r) => {
300
300
  if (n === r.length - 1) {
301
- t[s] = ee;
301
+ t[s] = Zt;
302
302
  return;
303
303
  }
304
304
  s in t || (t[s] = {}), t = t[s];
305
305
  });
306
306
  });
307
307
  }
308
- const ne = d({
308
+ const Xt = d({
309
309
  button_id: (e) => e == null ? void 0 : h().parse(e)
310
- }), re = {
310
+ }), te = {
311
311
  clipboard_text_received: d({
312
312
  req_id: h(),
313
313
  data: (e) => e === null ? e : h().optional().parse(e)
@@ -325,20 +325,20 @@ const ne = d({
325
325
  status: h()
326
326
  }),
327
327
  popup_closed: {
328
- parse: (e) => ne.parse(e ?? {})
328
+ parse: (e) => Xt.parse(e ?? {})
329
329
  },
330
330
  qr_text_received: d({
331
331
  data: h().optional()
332
332
  }),
333
333
  theme_changed: d({
334
334
  theme_params: (e) => {
335
- const t = dt().optional();
335
+ const t = pt().optional();
336
336
  return Object.entries(J(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
337
337
  }
338
338
  }),
339
339
  viewport_changed: d({
340
- height: v(),
341
- width: (e) => e == null ? window.innerWidth : v().parse(e),
340
+ height: y(),
341
+ width: (e) => e == null ? window.innerWidth : y().parse(e),
342
342
  is_state_stable: w(),
343
343
  is_expanded: w()
344
344
  }),
@@ -346,18 +346,18 @@ const ne = d({
346
346
  status: h()
347
347
  })
348
348
  };
349
- function ie() {
350
- const e = new V();
351
- se();
349
+ function ee() {
350
+ const e = new D();
351
+ Kt();
352
352
  let t = [
353
353
  // Don't forget to remove created handlers.
354
- te,
354
+ Yt,
355
355
  // Add "resize" event listener to make sure, we always have fresh viewport information.
356
356
  // Desktop version of Telegram is sometimes not sending the viewport_changed
357
357
  // event. For example, when the MainButton is shown. That's why we should
358
358
  // add our own listener to make sure, viewport information is always fresh.
359
359
  // Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/10
360
- F("resize", () => {
360
+ j("resize", () => {
361
361
  e.emit("viewport_changed", {
362
362
  width: window.innerWidth,
363
363
  height: window.innerHeight,
@@ -367,24 +367,24 @@ function ie() {
367
367
  }),
368
368
  // Add listener, which handles events sent from the Telegram web application and also events
369
369
  // generated by the local emitEvent function.
370
- F("message", (s) => {
370
+ j("message", (s) => {
371
371
  if (s.source !== window.parent)
372
372
  return;
373
373
  let n;
374
374
  try {
375
- n = Kt(s.data);
375
+ n = Qt(s.data);
376
376
  } catch {
377
377
  return;
378
378
  }
379
- const { eventType: r, eventData: i } = n, o = re[r];
379
+ const { eventType: r, eventData: i } = n, a = te[r];
380
380
  try {
381
- const a = o ? o.parse(i) : i;
382
- e.emit(...a ? [r, a] : [r]);
383
- } catch (a) {
384
- D.error(
381
+ const o = a ? a.parse(i) : i;
382
+ e.emit(...o ? [r, o] : [r]);
383
+ } catch (o) {
384
+ F.error(
385
385
  `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`,
386
386
  n,
387
- a
387
+ o
388
388
  );
389
389
  }
390
390
  }),
@@ -395,41 +395,41 @@ function ie() {
395
395
  t.forEach((s) => s()), t = [];
396
396
  }];
397
397
  }
398
- const [oe, ae] = at(
398
+ const [se, ne] = it(
399
399
  (e) => {
400
- const [t, s] = ie(), n = t.off.bind(t);
400
+ const [t, s] = ee(), n = t.off.bind(t);
401
401
  return t.off = (r, i) => {
402
- const { count: o } = t;
403
- n(r, i), o && !t.count && e();
402
+ const { count: a } = t;
403
+ n(r, i), a && !t.count && e();
404
404
  }, [t, s];
405
405
  },
406
406
  ([, e]) => e()
407
407
  );
408
- function L() {
409
- return oe()[0];
408
+ function M() {
409
+ return se()[0];
410
410
  }
411
- function B(e, t) {
412
- L().off(e, t);
411
+ function L(e, t) {
412
+ M().off(e, t);
413
413
  }
414
414
  function b(e, t, s) {
415
- return L().on(e, t, s);
415
+ return M().on(e, t, s);
416
416
  }
417
- function I(e) {
417
+ function T(e) {
418
418
  return typeof e == "object" && e !== null && !Array.isArray(e);
419
419
  }
420
- function ce(e, t) {
420
+ function re(e, t) {
421
421
  const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
422
422
  for (let i = 0; i < r; i += 1) {
423
- const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
424
- if (o !== a)
425
- return o > a ? 1 : -1;
423
+ const a = parseInt(s[i] || "0", 10), o = parseInt(n[i] || "0", 10);
424
+ if (a !== o)
425
+ return a > o ? 1 : -1;
426
426
  }
427
427
  return 0;
428
428
  }
429
429
  function g(e, t) {
430
- return ce(e, t) <= 0;
430
+ return re(e, t) <= 0;
431
431
  }
432
- function E(e, t, s) {
432
+ function v(e, t, s) {
433
433
  if (typeof s == "string") {
434
434
  if (e === "web_app_open_link" && t === "try_instant_view")
435
435
  return g("6.4", s);
@@ -480,95 +480,95 @@ function E(e, t, s) {
480
480
  ].includes(e);
481
481
  }
482
482
  }
483
- function he(e) {
484
- return "external" in e && I(e.external) && "notify" in e.external && typeof e.external.notify == "function";
483
+ function ie(e) {
484
+ return "external" in e && T(e.external) && "notify" in e.external && typeof e.external.notify == "function";
485
485
  }
486
- function _t(e) {
487
- return "TelegramWebviewProxy" in e && I(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
486
+ function ut(e) {
487
+ return "TelegramWebviewProxy" in e && T(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
488
488
  }
489
- function pe() {
489
+ function oe() {
490
490
  try {
491
491
  return window.self !== window.top;
492
492
  } catch {
493
493
  return !0;
494
494
  }
495
495
  }
496
- let ft = "https://web.telegram.org";
497
- function ss(e) {
498
- ft = e;
496
+ let lt = "https://web.telegram.org";
497
+ function ts(e) {
498
+ lt = e;
499
499
  }
500
- function ue() {
501
- return ft;
500
+ function ae() {
501
+ return lt;
502
502
  }
503
- function A(e, t, s) {
503
+ function R(e, t, s) {
504
504
  let n = {}, r;
505
505
  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);
506
- const { targetOrigin: i = ue() } = n;
507
- if (Wt("Posting event:", r ? { event: e, data: r } : { event: e }), pe()) {
506
+ const { targetOrigin: i = ae() } = n;
507
+ if (Lt("Posting event:", r ? { event: e, data: r } : { event: e }), oe()) {
508
508
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
509
509
  return;
510
510
  }
511
- if (he(window)) {
511
+ if (ie(window)) {
512
512
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
513
513
  return;
514
514
  }
515
- if (_t(window)) {
515
+ if (ut(window)) {
516
516
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
517
517
  return;
518
518
  }
519
519
  throw f(
520
- jt,
520
+ Ut,
521
521
  "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."
522
522
  );
523
523
  }
524
- function le(e) {
524
+ function ce(e) {
525
525
  return (t, s) => {
526
- if (!E(t, e))
527
- throw f(Ht, `Method "${t}" is unsupported in Mini Apps version ${e}`);
528
- if (I(s)) {
526
+ if (!v(t, e))
527
+ throw f(Bt, `Method "${t}" is unsupported in Mini Apps version ${e}`);
528
+ if (T(s)) {
529
529
  let n;
530
- 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 && !E(t, n, e))
530
+ 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 && !v(t, n, e))
531
531
  throw f(
532
- Gt,
532
+ Ot,
533
533
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
534
534
  );
535
535
  }
536
- return A(t, s);
536
+ return R(t, s);
537
537
  };
538
538
  }
539
- function gt(e) {
539
+ function dt(e) {
540
540
  return ({ req_id: t }) => t === e;
541
541
  }
542
- function bt(e) {
543
- return f(zt, `Timeout reached: ${e}ms`);
542
+ function _t(e) {
543
+ return f(Ht, `Timeout reached: ${e}ms`);
544
544
  }
545
- function wt(e, t) {
545
+ function ft(e, t) {
546
546
  return Promise.race([
547
547
  typeof e == "function" ? e() : e,
548
548
  new Promise((s, n) => {
549
549
  setTimeout(() => {
550
- n(bt(t));
550
+ n(_t(t));
551
551
  }, t);
552
552
  })
553
553
  ]);
554
554
  }
555
555
  async function _(e) {
556
556
  let t;
557
- const s = new Promise((l) => {
558
- t = l;
557
+ const s = new Promise((u) => {
558
+ t = u;
559
559
  }), {
560
560
  method: n,
561
561
  event: r,
562
562
  capture: i,
563
- postEvent: o = A,
564
- timeout: a
563
+ postEvent: a = R,
564
+ timeout: o
565
565
  } = e, p = (Array.isArray(r) ? r : [r]).map(
566
- (l) => b(l, (et) => (!i || i(et)) && t(et))
566
+ (u) => b(u, (q) => (!i || i(q)) && t(q))
567
567
  );
568
568
  try {
569
- return o(n, e.params), await (a ? wt(s, a) : s);
569
+ return a(n, e.params), await (o ? ft(s, o) : s);
570
570
  } finally {
571
- p.forEach((l) => l());
571
+ p.forEach((u) => u());
572
572
  }
573
573
  }
574
574
  async function C(e, t, s, n = {}) {
@@ -584,30 +584,30 @@ async function C(e, t, s, n = {}) {
584
584
  params: t,
585
585
  req_id: s
586
586
  },
587
- capture: gt(s)
587
+ capture: dt(s)
588
588
  });
589
589
  if (i)
590
- throw f(Ft, i);
590
+ throw f(Wt, i);
591
591
  return r;
592
592
  }
593
593
  function z(...e) {
594
594
  return e.map((t) => {
595
595
  if (typeof t == "string")
596
596
  return t;
597
- if (I(t))
597
+ if (T(t))
598
598
  return z(Object.entries(t).map((s) => s[1] && s[0]));
599
599
  if (Array.isArray(t))
600
600
  return z(...t);
601
601
  }).filter(Boolean).join(" ");
602
602
  }
603
- function ns(...e) {
604
- return e.reduce((t, s) => (I(s) && Object.entries(s).forEach(([n, r]) => {
603
+ function es(...e) {
604
+ return e.reduce((t, s) => (T(s) && Object.entries(s).forEach(([n, r]) => {
605
605
  const i = z(t[n], r);
606
606
  i.length && (t[n] = i);
607
607
  }), t), {});
608
608
  }
609
- function mt(e) {
610
- const t = lt(e);
609
+ function gt(e) {
610
+ const t = ht(e);
611
611
  return Math.sqrt(
612
612
  [0.299, 0.587, 0.114].reduce((s, n, r) => {
613
613
  const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
@@ -615,9 +615,9 @@ function mt(e) {
615
615
  }, 0)
616
616
  ) < 120;
617
617
  }
618
- class de {
618
+ class he {
619
619
  constructor(t) {
620
- c(this, "ee", new V());
620
+ c(this, "ee", new D());
621
621
  /**
622
622
  * Adds new event listener.
623
623
  */
@@ -635,7 +635,7 @@ class de {
635
635
  return { ...this.state };
636
636
  }
637
637
  set(t, s) {
638
- Object.entries(typeof t == "string" ? { [t]: s } : t).reduce((r, [i, o]) => this.state[i] === o || o === void 0 ? r : (this.state[i] = o, this.ee.emit(`change:${i}`, o), !0), !1) && this.ee.emit("change", this.state);
638
+ Object.entries(typeof t == "string" ? { [t]: s } : t).reduce((r, [i, a]) => this.state[i] === a || a === void 0 ? r : (this.state[i] = a, this.ee.emit(`change:${i}`, a), !0), !1) && this.ee.emit("change", this.state);
639
639
  }
640
640
  /**
641
641
  * Returns value by specified key.
@@ -660,11 +660,11 @@ class Y {
660
660
  * Clones the current state.
661
661
  */
662
662
  c(this, "clone");
663
- this.state = new de(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);
663
+ this.state = new he(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);
664
664
  }
665
665
  }
666
- function yt(e, t) {
667
- return (s) => E(t[s], e);
666
+ function bt(e, t) {
667
+ return (s) => v(t[s], e);
668
668
  }
669
669
  class Z extends Y {
670
670
  constructor(s, n, r) {
@@ -673,10 +673,10 @@ class Z extends Y {
673
673
  * @returns True, if specified method is supported by the current component.
674
674
  */
675
675
  c(this, "supports");
676
- this.supports = yt(n, r);
676
+ this.supports = bt(n, r);
677
677
  }
678
678
  }
679
- class _e extends Z {
679
+ class pe extends Z {
680
680
  constructor(s, n, r) {
681
681
  super({ isVisible: s }, n, {
682
682
  show: "web_app_setup_back_button",
@@ -693,7 +693,7 @@ class _e extends Z {
693
693
  * @param event - event to listen.
694
694
  * @param listener - listener to remove.
695
695
  */
696
- c(this, "off", (s, n) => s === "click" ? B("back_button_pressed", n) : this.state.off(s, n));
696
+ c(this, "off", (s, n) => s === "click" ? L("back_button_pressed", n) : this.state.off(s, n));
697
697
  this.postEvent = r;
698
698
  }
699
699
  set isVisible(s) {
@@ -718,23 +718,20 @@ class _e extends Z {
718
718
  this.isVisible = !0;
719
719
  }
720
720
  }
721
- function y() {
722
- return typeof window > "u";
723
- }
724
- const vt = x((e) => e instanceof Date ? e : new Date(v().parse(e) * 1e3), "Date");
725
- function X(e, t) {
726
- return new M((s) => {
721
+ const wt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
722
+ function K(e, t) {
723
+ return new $((s) => {
727
724
  if (typeof s != "string" && !(s instanceof URLSearchParams))
728
- throw P();
725
+ throw E();
729
726
  const n = typeof s == "string" ? new URLSearchParams(s) : s;
730
- return ut(e, (r) => {
727
+ return ct(e, (r) => {
731
728
  const i = n.get(r);
732
729
  return i === null ? void 0 : i;
733
730
  });
734
731
  }, !1, t);
735
732
  }
736
- const fe = d({
737
- id: v(),
733
+ const ue = d({
734
+ id: y(),
738
735
  type: h(),
739
736
  title: h(),
740
737
  photoUrl: {
@@ -742,7 +739,7 @@ const fe = d({
742
739
  from: "photo_url"
743
740
  },
744
741
  username: h().optional()
745
- }, "Chat").optional(), nt = d({
742
+ }, "Chat").optional(), st = d({
746
743
  addedToAttachmentMenu: {
747
744
  type: w().optional(),
748
745
  from: "added_to_attachment_menu"
@@ -755,7 +752,7 @@ const fe = d({
755
752
  type: h(),
756
753
  from: "first_name"
757
754
  },
758
- id: v(),
755
+ id: y(),
759
756
  isBot: {
760
757
  type: w().optional(),
761
758
  from: "is_bot"
@@ -778,17 +775,17 @@ const fe = d({
778
775
  },
779
776
  username: h().optional()
780
777
  }, "User").optional();
781
- function Et() {
782
- return X({
778
+ function mt() {
779
+ return K({
783
780
  authDate: {
784
- type: vt(),
781
+ type: wt(),
785
782
  from: "auth_date"
786
783
  },
787
784
  canSendAfter: {
788
- type: v().optional(),
785
+ type: y().optional(),
789
786
  from: "can_send_after"
790
787
  },
791
- chat: fe,
788
+ chat: ue,
792
789
  chatInstance: {
793
790
  type: h().optional(),
794
791
  from: "chat_instance"
@@ -802,35 +799,35 @@ function Et() {
802
799
  type: h().optional(),
803
800
  from: "query_id"
804
801
  },
805
- receiver: nt,
802
+ receiver: st,
806
803
  startParam: {
807
804
  type: h().optional(),
808
805
  from: "start_param"
809
806
  },
810
- user: nt
807
+ user: st
811
808
  }, "InitData");
812
809
  }
813
- function ge(e) {
810
+ function le(e) {
814
811
  return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
815
812
  }
816
- function be(e) {
813
+ function de(e) {
817
814
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
818
815
  }
819
- const Pt = x(
816
+ const yt = P(
820
817
  (e) => {
821
- const t = dt().optional();
822
- return Object.entries(J(e)).reduce((s, [n, r]) => (s[ge(n)] = t.parse(r), s), {});
818
+ const t = pt().optional();
819
+ return Object.entries(J(e)).reduce((s, [n, r]) => (s[le(n)] = t.parse(r), s), {});
823
820
  },
824
821
  "ThemeParams"
825
822
  );
826
- function xt(e) {
827
- return X({
823
+ function vt(e) {
824
+ return K({
828
825
  botInline: {
829
826
  type: w().optional(),
830
827
  from: "tgWebAppBotInline"
831
828
  },
832
829
  initData: {
833
- type: Et().optional(),
830
+ type: mt().optional(),
834
831
  from: "tgWebAppData"
835
832
  },
836
833
  initDataRaw: {
@@ -850,7 +847,7 @@ function xt(e) {
850
847
  from: "tgWebAppStartParam"
851
848
  },
852
849
  themeParams: {
853
- type: Pt(),
850
+ type: yt(),
854
851
  from: "tgWebAppThemeParams"
855
852
  },
856
853
  version: {
@@ -859,116 +856,131 @@ function xt(e) {
859
856
  }
860
857
  }).parse(e);
861
858
  }
862
- function St(e) {
863
- return xt(
859
+ function Et(e) {
860
+ return vt(
864
861
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
865
862
  );
866
863
  }
867
- function we() {
868
- return St(window.location.href);
864
+ function _e() {
865
+ return Et(window.location.href);
869
866
  }
870
- function Ct() {
867
+ function Pt() {
871
868
  return performance.getEntriesByType("navigation")[0];
872
869
  }
873
- function me() {
874
- const e = Ct();
870
+ function fe() {
871
+ const e = Pt();
875
872
  if (!e)
876
873
  throw new Error("Unable to get first navigation entry.");
877
- return St(e.name);
874
+ return Et(e.name);
878
875
  }
879
- function Rt(e) {
876
+ function xt(e) {
880
877
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
881
878
  }
882
- function At(e, t) {
883
- sessionStorage.setItem(Rt(e), JSON.stringify(t));
879
+ function Ct(e, t) {
880
+ sessionStorage.setItem(xt(e), JSON.stringify(t));
884
881
  }
885
- function Tt(e) {
886
- const t = sessionStorage.getItem(Rt(e));
882
+ function St(e) {
883
+ const t = sessionStorage.getItem(xt(e));
887
884
  try {
888
885
  return t ? JSON.parse(t) : void 0;
889
886
  } catch {
890
887
  }
891
888
  }
892
- function ye() {
893
- return xt(Tt("launchParams") || "");
889
+ function ge() {
890
+ return vt(St("launchParams") || "");
894
891
  }
895
- function ve(e) {
892
+ function be(e) {
896
893
  return JSON.stringify(
897
894
  Object.fromEntries(
898
- Object.entries(e).map(([t, s]) => [be(t), s])
895
+ Object.entries(e).map(([t, s]) => [de(t), s])
899
896
  )
900
897
  );
901
898
  }
902
- function Ee(e) {
899
+ function we(e) {
903
900
  const {
904
901
  initDataRaw: t,
905
902
  themeParams: s,
906
903
  platform: n,
907
904
  version: r,
908
905
  showSettings: i,
909
- startParam: o,
910
- botInline: a
906
+ startParam: a,
907
+ botInline: o
911
908
  } = e, p = new URLSearchParams();
912
- return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", ve(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();
909
+ return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", be(s)), p.set("tgWebAppVersion", r), t && p.set("tgWebAppData", t), a && p.set("tgWebAppStartParam", a), typeof i == "boolean" && p.set("tgWebAppShowSettings", i ? "1" : "0"), typeof o == "boolean" && p.set("tgWebAppBotInline", o ? "1" : "0"), p.toString();
913
910
  }
914
- function Pe(e) {
915
- At("launchParams", Ee(e));
911
+ function me(e) {
912
+ Ct("launchParams", we(e));
916
913
  }
917
- function xe() {
914
+ function ye() {
918
915
  for (const e of [
919
916
  // Try to retrieve launch parameters from the current location. This method can return
920
917
  // nothing in case, location was changed and then page was reloaded.
921
- we,
918
+ _e,
922
919
  // Then, try using the lower level API - window.performance.
923
- me,
920
+ fe,
924
921
  // Finally, try to extract launch parameters from the session storage.
925
- ye
922
+ ge
926
923
  ])
927
924
  try {
928
925
  const t = e();
929
- return Pe(t), t;
926
+ return me(t), t;
930
927
  } catch {
931
928
  }
932
929
  throw new Error("Unable to retrieve launch parameters from any known source.");
933
930
  }
934
- function It() {
935
- const e = Ct();
931
+ function Rt() {
932
+ const e = Pt();
936
933
  return !!(e && e.type === "reload");
937
934
  }
938
- function Se() {
935
+ function ve() {
939
936
  let e = 0;
940
937
  return () => (e += 1).toString();
941
938
  }
942
- const [Ce] = at(Se);
943
- function u(e, t) {
944
- return ({ ssr: s } = {}) => {
945
- const n = y() ? {
946
- version: "6.0",
947
- themeParams: {},
948
- platform: "unknown",
949
- ...s || {}
950
- } : xe(), r = {
951
- ...n,
952
- postEvent: y() ? () => null : le(n.version),
953
- createRequestId: Ce()
939
+ function Ee() {
940
+ let e = !1;
941
+ const t = [];
942
+ return [
943
+ (s) => !e && t.push(s),
944
+ () => {
945
+ e || (e = !0, t.forEach((s) => s()));
946
+ },
947
+ e
948
+ ];
949
+ }
950
+ const [Pe] = it(ve);
951
+ function l(e, t) {
952
+ return () => {
953
+ const s = ye(), n = {
954
+ ...s,
955
+ postEvent: ce(s.version),
956
+ createRequestId: Pe()
954
957
  };
955
- if (y() || typeof e == "function")
956
- return typeof e == "function" ? e(r) : t(r);
957
- const i = t({
958
- ...r,
959
- state: It() ? Tt(e) : void 0
960
- }), o = (a) => (a.on("change", (p) => {
961
- At(e, p);
962
- }), a);
963
- return i instanceof Promise ? i.then(o) : o(i);
958
+ if (typeof e == "function")
959
+ return e(n);
960
+ const [r, i, a] = Ee(), o = t({
961
+ ...n,
962
+ // State should only be passed only in case, current page was reloaded. If we don't add
963
+ // this check, state restoration will work improperly in the web version of Telegram,
964
+ // when we are always working in the same "session" (tab).
965
+ state: Rt() ? St(e) : void 0,
966
+ addCleanup: r
967
+ }), p = (u) => (a || r(
968
+ u.on("change", (q) => {
969
+ Ct(e, q);
970
+ })
971
+ ), u);
972
+ return [
973
+ o instanceof Promise ? o.then(p) : p(o),
974
+ i
975
+ ];
964
976
  };
965
977
  }
966
- const rs = u("backButton", ({
978
+ const ss = l("backButton", ({
967
979
  postEvent: e,
968
980
  version: t,
969
981
  state: s = { isVisible: !1 }
970
- }) => new _e(s.isVisible, t, e));
971
- class q extends Z {
982
+ }) => new pe(s.isVisible, t, e));
983
+ class I extends Z {
972
984
  constructor() {
973
985
  super(...arguments);
974
986
  /**
@@ -981,7 +993,7 @@ class q extends Z {
981
993
  c(this, "off", this.state.off.bind(this.state));
982
994
  }
983
995
  }
984
- function qt(e) {
996
+ function At(e) {
985
997
  const t = e.available ? e : {
986
998
  available: !1,
987
999
  device_id: "",
@@ -999,7 +1011,7 @@ function qt(e) {
999
1011
  accessGranted: t.access_granted
1000
1012
  };
1001
1013
  }
1002
- class rt extends q {
1014
+ class xe extends I {
1003
1015
  constructor({ postEvent: s, version: n, ...r }) {
1004
1016
  super(r, n, {
1005
1017
  auth: "web_app_biometry_request_auth",
@@ -1081,7 +1093,7 @@ class rt extends q {
1081
1093
  event: "biometry_info_received",
1082
1094
  params: { reason: s || "" }
1083
1095
  }).then((r) => {
1084
- const i = qt(r);
1096
+ const i = At(r);
1085
1097
  return this.set(i), i.accessGranted;
1086
1098
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1087
1099
  }
@@ -1113,8 +1125,8 @@ class rt extends q {
1113
1125
  );
1114
1126
  }
1115
1127
  }
1116
- async function Re(e) {
1117
- return qt(
1128
+ async function Ce(e) {
1129
+ return At(
1118
1130
  await _({
1119
1131
  ...e || {},
1120
1132
  method: "web_app_biometry_get_info",
@@ -1122,21 +1134,15 @@ async function Re(e) {
1122
1134
  })
1123
1135
  );
1124
1136
  }
1125
- const is = u("biometryManager", async ({ postEvent: e, version: t, state: s }) => {
1126
- if (s)
1127
- return new rt({ ...s, version: t, postEvent: e });
1128
- if (y())
1129
- throw f(
1130
- pt,
1131
- "BiometryManager cannot be instantiated on the server side without passing the ssr.state object."
1132
- );
1133
- return new rt({
1134
- ...await Re({ timeout: 1e3 }),
1137
+ const ns = l(
1138
+ "biometryManager",
1139
+ async ({ postEvent: e, version: t, state: s }) => new xe({
1140
+ ...s || await Ce({ timeout: 1e3 }),
1135
1141
  version: t,
1136
1142
  postEvent: e
1137
- });
1138
- });
1139
- class K extends Y {
1143
+ })
1144
+ );
1145
+ class X extends Y {
1140
1146
  constructor() {
1141
1147
  super(...arguments);
1142
1148
  /**
@@ -1149,7 +1155,7 @@ class K extends Y {
1149
1155
  c(this, "off", this.state.off.bind(this.state));
1150
1156
  }
1151
1157
  }
1152
- class Ae extends K {
1158
+ class Se extends X {
1153
1159
  constructor(t, s) {
1154
1160
  super({ isConfirmationNeeded: t }), this.postEvent = s;
1155
1161
  }
@@ -1176,20 +1182,23 @@ class Ae extends K {
1176
1182
  this.isConfirmationNeeded = !0;
1177
1183
  }
1178
1184
  }
1179
- const os = u("closingBehavior", ({
1180
- postEvent: e,
1181
- state: t = { isConfirmationNeeded: !1 }
1182
- }) => new Ae(t.isConfirmationNeeded, e));
1185
+ const rs = l(
1186
+ "closingBehavior",
1187
+ ({
1188
+ postEvent: e,
1189
+ state: t = { isConfirmationNeeded: !1 }
1190
+ }) => new Se(t.isConfirmationNeeded, e)
1191
+ );
1183
1192
  class tt {
1184
1193
  constructor(t, s) {
1185
1194
  /**
1186
1195
  * @returns True, if specified method is supported by the current component.
1187
1196
  */
1188
1197
  c(this, "supports");
1189
- this.supports = yt(t, s);
1198
+ this.supports = bt(t, s);
1190
1199
  }
1191
1200
  }
1192
- function Te(e) {
1201
+ function Re(e) {
1193
1202
  if (Array.isArray(e))
1194
1203
  return e;
1195
1204
  if (typeof e == "string")
@@ -1199,11 +1208,11 @@ function Te(e) {
1199
1208
  return t;
1200
1209
  } catch {
1201
1210
  }
1202
- throw P();
1211
+ throw E();
1203
1212
  }
1204
- class Ie extends M {
1213
+ class Ae extends $ {
1205
1214
  constructor(s, n, r) {
1206
- super(Te, n, r);
1215
+ super(Re, n, r);
1207
1216
  c(this, "itemParser");
1208
1217
  this.itemParser = typeof s == "function" ? s : s.parse.bind(s);
1209
1218
  }
@@ -1221,13 +1230,13 @@ class Ie extends M {
1221
1230
  return this.itemParser = typeof s == "function" ? s : s.parse.bind(s), this;
1222
1231
  }
1223
1232
  }
1224
- function qe(e) {
1225
- return new Ie((t) => t, !1, e);
1233
+ function Te(e) {
1234
+ return new Ae((t) => t, !1, e);
1226
1235
  }
1227
- function it(e, t) {
1236
+ function nt(e, t) {
1228
1237
  return Object.fromEntries(e.map((s) => [s, t]));
1229
1238
  }
1230
- class ke extends tt {
1239
+ class Ie extends tt {
1231
1240
  constructor(t, s, n) {
1232
1241
  super(t, {
1233
1242
  delete: "web_app_invoke_custom_method",
@@ -1255,7 +1264,7 @@ class ke extends tt {
1255
1264
  * @param options - request execution options.
1256
1265
  */
1257
1266
  async getKeys(t = {}) {
1258
- return qe().of(h()).parse(
1267
+ return Te().of(h()).parse(
1259
1268
  await C(
1260
1269
  "getStorageKeys",
1261
1270
  {},
@@ -1267,13 +1276,13 @@ class ke extends tt {
1267
1276
  async get(t, s = {}) {
1268
1277
  const n = Array.isArray(t) ? t : [t];
1269
1278
  if (!n.length)
1270
- return it(n, "");
1279
+ return nt(n, "");
1271
1280
  const r = await C(
1272
1281
  "getStorageValues",
1273
1282
  { keys: n },
1274
1283
  this.createRequestId(),
1275
1284
  { ...s, postEvent: this.postEvent }
1276
- ), i = d(it(n, h()), "CloudStorageData").parse(r);
1285
+ ), i = d(nt(n, h()), "CloudStorageData").parse(r);
1277
1286
  return Array.isArray(t) ? i : i[t];
1278
1287
  }
1279
1288
  /**
@@ -1291,10 +1300,10 @@ class ke extends tt {
1291
1300
  );
1292
1301
  }
1293
1302
  }
1294
- const as = u(
1295
- ({ createRequestId: e, postEvent: t, version: s }) => new ke(s, e, t)
1303
+ const is = l(
1304
+ ({ createRequestId: e, postEvent: t, version: s }) => new Ie(s, e, t)
1296
1305
  );
1297
- class Ne extends tt {
1306
+ class qe extends tt {
1298
1307
  constructor(t, s) {
1299
1308
  super(t, {
1300
1309
  impactOccurred: "web_app_trigger_haptic_feedback",
@@ -1336,10 +1345,10 @@ class Ne extends tt {
1336
1345
  this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
1337
1346
  }
1338
1347
  }
1339
- const cs = u(
1340
- ({ version: e, postEvent: t }) => new Ne(e, t)
1348
+ const os = l(
1349
+ ({ version: e, postEvent: t }) => new qe(e, t)
1341
1350
  );
1342
- class De {
1351
+ class ke {
1343
1352
  constructor(t) {
1344
1353
  this.initData = t;
1345
1354
  }
@@ -1412,13 +1421,13 @@ class De {
1412
1421
  return this.initData.user;
1413
1422
  }
1414
1423
  }
1415
- const hs = u(
1416
- ({ initData: e }) => e ? new De(e) : void 0
1424
+ const as = l(
1425
+ ({ initData: e }) => e ? new ke(e) : void 0
1417
1426
  );
1418
- function ps(e) {
1419
- return Et().parse(e);
1427
+ function cs(e) {
1428
+ return mt().parse(e);
1420
1429
  }
1421
- class Ve extends q {
1430
+ class Ne extends I {
1422
1431
  constructor(t, s, n) {
1423
1432
  super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
1424
1433
  }
@@ -1441,10 +1450,10 @@ class Ve extends q {
1441
1450
  const { hostname: r, pathname: i } = new URL(t, window.location.href);
1442
1451
  if (r !== "t.me")
1443
1452
  throw new Error(`Incorrect hostname: ${r}`);
1444
- const o = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1445
- if (!o)
1453
+ const a = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1454
+ if (!a)
1446
1455
  throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
1447
- [, , n] = o;
1456
+ [, , n] = a;
1448
1457
  }
1449
1458
  this.isOpened = !0;
1450
1459
  try {
@@ -1462,10 +1471,10 @@ class Ve extends q {
1462
1471
  }
1463
1472
  }
1464
1473
  }
1465
- const us = u(
1466
- ({ version: e, postEvent: t }) => new Ve(!1, e, t)
1474
+ const hs = l(
1475
+ ({ version: e, postEvent: t }) => new Ne(!1, e, t)
1467
1476
  );
1468
- class $e extends Y {
1477
+ class De extends Y {
1469
1478
  constructor({ postEvent: s, ...n }) {
1470
1479
  super(n);
1471
1480
  c(this, "postEvent");
@@ -1480,7 +1489,7 @@ class $e extends Y {
1480
1489
  * @param event - event to listen.
1481
1490
  * @param listener - listener to remove.
1482
1491
  */
1483
- c(this, "off", (s, n) => s === "click" ? B("main_button_pressed", n) : this.state.off(s, n));
1492
+ c(this, "off", (s, n) => s === "click" ? L("main_button_pressed", n) : this.state.off(s, n));
1484
1493
  this.postEvent = s;
1485
1494
  }
1486
1495
  /**
@@ -1610,23 +1619,26 @@ class $e extends Y {
1610
1619
  return this.set(s), this.commit(), this;
1611
1620
  }
1612
1621
  }
1613
- const ls = u("mainButton", ({
1614
- postEvent: e,
1615
- themeParams: t,
1616
- state: s = {
1617
- isVisible: !1,
1618
- isEnabled: !1,
1619
- text: "",
1620
- isLoaderVisible: !1,
1621
- textColor: t.buttonTextColor || "#ffffff",
1622
- backgroundColor: t.buttonColor || "#000000"
1623
- }
1624
- }) => new $e({ ...s, postEvent: e }));
1625
- function Me() {
1626
- return X({
1622
+ const ps = l(
1623
+ "mainButton",
1624
+ ({
1625
+ postEvent: e,
1626
+ themeParams: t,
1627
+ state: s = {
1628
+ isVisible: !1,
1629
+ isEnabled: !1,
1630
+ text: "",
1631
+ isLoaderVisible: !1,
1632
+ textColor: t.buttonTextColor || "#ffffff",
1633
+ backgroundColor: t.buttonColor || "#000000"
1634
+ }
1635
+ }) => new De({ ...s, postEvent: e })
1636
+ );
1637
+ function Ve() {
1638
+ return K({
1627
1639
  contact: d({
1628
1640
  userId: {
1629
- type: v(),
1641
+ type: y(),
1630
1642
  from: "user_id"
1631
1643
  },
1632
1644
  phoneNumber: {
@@ -1643,26 +1655,26 @@ function Me() {
1643
1655
  }
1644
1656
  }),
1645
1657
  authDate: {
1646
- type: vt(),
1658
+ type: wt(),
1647
1659
  from: "auth_date"
1648
1660
  },
1649
1661
  hash: h()
1650
1662
  }, "RequestedContact");
1651
1663
  }
1652
- function kt(e, t) {
1664
+ function Tt(e, t) {
1653
1665
  return (s) => {
1654
1666
  const [n, r] = t[s];
1655
- return E(n, r, e);
1667
+ return v(n, r, e);
1656
1668
  };
1657
1669
  }
1658
- function Le(e) {
1670
+ function $e(e) {
1659
1671
  return new Promise((t) => {
1660
1672
  setTimeout(t, e);
1661
1673
  });
1662
1674
  }
1663
- class Be extends q {
1664
- constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...o }) {
1665
- super(o, r, {
1675
+ class Me extends I {
1676
+ constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...a }) {
1677
+ super(a, r, {
1666
1678
  requestPhoneAccess: "web_app_request_phone",
1667
1679
  requestWriteAccess: "web_app_request_write_access",
1668
1680
  switchInlineQuery: "web_app_switch_inline_query",
@@ -1679,8 +1691,8 @@ class Be extends q {
1679
1691
  */
1680
1692
  c(this, "supportsParam");
1681
1693
  this.createRequestId = n, this.postEvent = s, this.botInline = i;
1682
- const a = this.supports.bind(this);
1683
- this.supports = (p) => a(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = kt(r, {
1694
+ const o = this.supports.bind(this);
1695
+ this.supports = (p) => o(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = Tt(r, {
1684
1696
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1685
1697
  });
1686
1698
  }
@@ -1691,7 +1703,7 @@ class Be extends q {
1691
1703
  async getRequestedContact({
1692
1704
  timeout: s = 1e4
1693
1705
  } = {}) {
1694
- return Me().parse(
1706
+ return Ve().parse(
1695
1707
  await C(
1696
1708
  "getRequestedContact",
1697
1709
  {},
@@ -1731,7 +1743,7 @@ class Be extends q {
1731
1743
  * True if current Mini App background color is recognized as dark.
1732
1744
  */
1733
1745
  get isDark() {
1734
- return mt(this.bgColor);
1746
+ return gt(this.bgColor);
1735
1747
  }
1736
1748
  /**
1737
1749
  * Informs the Telegram app that the Mini App is ready to be displayed.
@@ -1760,15 +1772,15 @@ class Be extends q {
1760
1772
  throw new Error("Access denied.");
1761
1773
  const r = Date.now() + s;
1762
1774
  let i = 50;
1763
- return wt(async () => {
1775
+ return ft(async () => {
1764
1776
  for (; Date.now() < r; ) {
1765
1777
  try {
1766
1778
  return await this.getRequestedContact();
1767
1779
  } catch {
1768
1780
  }
1769
- await Le(i), i += 50;
1781
+ await $e(i), i += 50;
1770
1782
  }
1771
- throw bt(s);
1783
+ throw _t(s);
1772
1784
  }, s);
1773
1785
  }
1774
1786
  /**
@@ -1851,16 +1863,19 @@ class Be extends q {
1851
1863
  this.postEvent("web_app_switch_inline_query", { query: s, chat_types: n });
1852
1864
  }
1853
1865
  }
1854
- const ds = u("miniApp", ({
1855
- themeParams: e,
1856
- botInline: t = !1,
1857
- state: s = {
1858
- bgColor: e.bgColor || "#ffffff",
1859
- headerColor: e.headerBgColor || "#000000"
1860
- },
1861
- ...n
1862
- }) => new Be({ ...n, ...s, botInline: t }));
1863
- function Oe(e) {
1866
+ const us = l(
1867
+ "miniApp",
1868
+ ({
1869
+ themeParams: e,
1870
+ botInline: t = !1,
1871
+ state: s = {
1872
+ bgColor: e.bgColor || "#ffffff",
1873
+ headerColor: e.headerBgColor || "#000000"
1874
+ },
1875
+ ...n
1876
+ }) => new Me({ ...n, ...s, botInline: t })
1877
+ );
1878
+ function Le(e) {
1864
1879
  const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
1865
1880
  let r;
1866
1881
  if (s.length > 64)
@@ -1870,21 +1885,21 @@ function Oe(e) {
1870
1885
  if (n.length > 3)
1871
1886
  throw new Error(`Buttons have incorrect size: ${n.length}`);
1872
1887
  return n.length ? r = n.map((i) => {
1873
- const { id: o = "" } = i;
1874
- if (o.length > 64)
1875
- throw new Error(`Button ID has incorrect size: ${o}`);
1888
+ const { id: a = "" } = i;
1889
+ if (a.length > 64)
1890
+ throw new Error(`Button ID has incorrect size: ${a}`);
1876
1891
  if (!i.type || i.type === "default" || i.type === "destructive") {
1877
- const a = i.text.trim();
1878
- if (!a.length || a.length > 64) {
1892
+ const o = i.text.trim();
1893
+ if (!o.length || o.length > 64) {
1879
1894
  const p = i.type || "default";
1880
1895
  throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
1881
1896
  }
1882
- return { ...i, text: a, id: o };
1897
+ return { ...i, text: o, id: a };
1883
1898
  }
1884
- return { ...i, id: o };
1899
+ return { ...i, id: a };
1885
1900
  }) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
1886
1901
  }
1887
- class Ue extends q {
1902
+ class Be extends I {
1888
1903
  constructor(t, s, n) {
1889
1904
  super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
1890
1905
  }
@@ -1917,7 +1932,7 @@ class Ue extends q {
1917
1932
  event: "popup_closed",
1918
1933
  method: "web_app_open_popup",
1919
1934
  postEvent: this.postEvent,
1920
- params: Oe(t)
1935
+ params: Le(t)
1921
1936
  });
1922
1937
  return s;
1923
1938
  } finally {
@@ -1925,10 +1940,10 @@ class Ue extends q {
1925
1940
  }
1926
1941
  }
1927
1942
  }
1928
- const _s = u(
1929
- ({ postEvent: e, version: t }) => new Ue(!1, t, e)
1943
+ const ls = l(
1944
+ ({ postEvent: e, version: t }) => new Be(!1, t, e)
1930
1945
  );
1931
- class We extends q {
1946
+ class Oe extends I {
1932
1947
  constructor(t, s, n) {
1933
1948
  super({ isOpened: t }, s, {
1934
1949
  close: "web_app_close_scan_qr_popup",
@@ -1972,10 +1987,10 @@ class We extends q {
1972
1987
  }
1973
1988
  }
1974
1989
  }
1975
- const fs = u(
1976
- ({ version: e, postEvent: t }) => new We(!1, e, t)
1990
+ const ds = l(
1991
+ ({ version: e, postEvent: t }) => new Oe(!1, e, t)
1977
1992
  );
1978
- class He extends Z {
1993
+ class Ue extends Z {
1979
1994
  constructor(s, n, r) {
1980
1995
  super({ isVisible: s }, n, {
1981
1996
  show: "web_app_setup_settings_button",
@@ -1992,7 +2007,7 @@ class He extends Z {
1992
2007
  * @param event - event to listen.
1993
2008
  * @param listener - listener to remove.
1994
2009
  */
1995
- c(this, "off", (s, n) => s === "click" ? B("settings_button_pressed", n) : this.state.off(s, n));
2010
+ c(this, "off", (s, n) => s === "click" ? L("settings_button_pressed", n) : this.state.off(s, n));
1996
2011
  this.postEvent = r;
1997
2012
  }
1998
2013
  set isVisible(s) {
@@ -2017,15 +2032,18 @@ class He extends Z {
2017
2032
  this.isVisible = !0;
2018
2033
  }
2019
2034
  }
2020
- const gs = u("settingsButton", ({
2021
- version: e,
2022
- postEvent: t,
2023
- state: s = { isVisible: !1 }
2024
- }) => new He(s.isVisible, e, t));
2025
- function Nt(e) {
2026
- return Pt().parse(e);
2035
+ const _s = l(
2036
+ "settingsButton",
2037
+ ({
2038
+ version: e,
2039
+ postEvent: t,
2040
+ state: s = { isVisible: !1 }
2041
+ }) => new Ue(s.isVisible, e, t)
2042
+ );
2043
+ function It(e) {
2044
+ return yt().parse(e);
2027
2045
  }
2028
- class Ge extends K {
2046
+ class We extends X {
2029
2047
  /**
2030
2048
  * @since v6.10
2031
2049
  */
@@ -2064,7 +2082,7 @@ class Ge extends K {
2064
2082
  * value is calculated according to theme bg color.
2065
2083
  */
2066
2084
  get isDark() {
2067
- return !this.bgColor || mt(this.bgColor);
2085
+ return !this.bgColor || gt(this.bgColor);
2068
2086
  }
2069
2087
  get linkColor() {
2070
2088
  return this.get("linkColor");
@@ -2090,7 +2108,7 @@ class Ge extends K {
2090
2108
  */
2091
2109
  listen() {
2092
2110
  return b("theme_changed", (t) => {
2093
- this.set(Nt(t.theme_params));
2111
+ this.set(It(t.theme_params));
2094
2112
  });
2095
2113
  }
2096
2114
  /**
@@ -2103,25 +2121,28 @@ class Ge extends K {
2103
2121
  return this.get("textColor");
2104
2122
  }
2105
2123
  }
2106
- const bs = u("themeParams", ({ themeParams: e, state: t = e }) => {
2107
- const s = new Ge(t);
2108
- return y() || s.listen(), s;
2109
- });
2110
- function ws(e = {}) {
2124
+ const fs = l(
2125
+ "themeParams",
2126
+ ({ themeParams: e, state: t = e, addCleanup: s }) => {
2127
+ const n = new We(t);
2128
+ return s(n.listen()), n;
2129
+ }
2130
+ );
2131
+ function gs(e = {}) {
2111
2132
  return _({
2112
2133
  ...e,
2113
2134
  method: "web_app_request_theme",
2114
2135
  event: "theme_changed"
2115
- }).then(Nt);
2136
+ }).then(It);
2116
2137
  }
2117
- class je extends tt {
2138
+ class He extends tt {
2118
2139
  constructor(s, n, r) {
2119
2140
  super(s, { readTextFromClipboard: "web_app_read_text_from_clipboard" });
2120
2141
  /**
2121
2142
  * Checks if specified method parameter is supported by current component.
2122
2143
  */
2123
2144
  c(this, "supportsParam");
2124
- this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = kt(s, {
2145
+ this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = Tt(s, {
2125
2146
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2126
2147
  });
2127
2148
  }
@@ -2136,7 +2157,7 @@ class je extends tt {
2136
2157
  */
2137
2158
  openLink(s, n) {
2138
2159
  const r = new URL(s, window.location.href).toString();
2139
- if (!E("web_app_open_link", this.version)) {
2160
+ if (!v("web_app_open_link", this.version)) {
2140
2161
  window.open(r, "_blank");
2141
2162
  return;
2142
2163
  }
@@ -2155,7 +2176,7 @@ class je extends tt {
2155
2176
  const { hostname: n, pathname: r, search: i } = new URL(s, window.location.href);
2156
2177
  if (n !== "t.me")
2157
2178
  throw new Error(`URL has not allowed hostname: ${n}. Only "t.me" is allowed`);
2158
- if (!E("web_app_open_tg_link", this.version)) {
2179
+ if (!v("web_app_open_tg_link", this.version)) {
2159
2180
  window.location.href = s;
2160
2181
  return;
2161
2182
  }
@@ -2175,15 +2196,15 @@ class je extends tt {
2175
2196
  event: "clipboard_text_received",
2176
2197
  postEvent: this.postEvent,
2177
2198
  params: { req_id: s },
2178
- capture: gt(s)
2199
+ capture: dt(s)
2179
2200
  });
2180
2201
  return n;
2181
2202
  }
2182
2203
  }
2183
- const ms = u(
2184
- ({ version: e, postEvent: t, createRequestId: s }) => new je(e, s, t)
2204
+ const bs = l(
2205
+ ({ version: e, postEvent: t, createRequestId: s }) => new He(e, s, t)
2185
2206
  );
2186
- async function Dt(e = {}) {
2207
+ async function qt(e = {}) {
2187
2208
  const {
2188
2209
  is_expanded: t,
2189
2210
  is_state_stable: s,
@@ -2195,16 +2216,16 @@ async function Dt(e = {}) {
2195
2216
  });
2196
2217
  return { ...n, isExpanded: t, isStateStable: s };
2197
2218
  }
2198
- function S(e) {
2219
+ function x(e) {
2199
2220
  return e < 0 ? 0 : e;
2200
2221
  }
2201
- class Vt extends K {
2202
- constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: o }) {
2222
+ class Ge extends X {
2223
+ constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: a }) {
2203
2224
  super({
2204
- height: S(r),
2205
- isExpanded: o,
2206
- stableHeight: S(n),
2207
- width: S(i)
2225
+ height: x(r),
2226
+ isExpanded: a,
2227
+ stableHeight: x(n),
2228
+ width: x(i)
2208
2229
  });
2209
2230
  c(this, "postEvent");
2210
2231
  this.postEvent = s;
@@ -2215,7 +2236,7 @@ class Vt extends K {
2215
2236
  * @param options - options to request fresh data.
2216
2237
  */
2217
2238
  async sync(s) {
2218
- const { isStateStable: n, ...r } = await Dt(s);
2239
+ const { isStateStable: n, ...r } = await qt(s);
2219
2240
  this.set({
2220
2241
  ...r,
2221
2242
  stableHeight: n ? r.height : this.get("stableHeight")
@@ -2267,13 +2288,13 @@ class Vt extends K {
2267
2288
  height: n,
2268
2289
  width: r,
2269
2290
  is_expanded: i,
2270
- is_state_stable: o
2271
- } = s, a = S(n);
2291
+ is_state_stable: a
2292
+ } = s, o = x(n);
2272
2293
  this.set({
2273
- height: a,
2294
+ height: o,
2274
2295
  isExpanded: i,
2275
- width: S(r),
2276
- ...o ? { stableHeight: a } : {}
2296
+ width: x(r),
2297
+ ...a ? { stableHeight: o } : {}
2277
2298
  });
2278
2299
  });
2279
2300
  }
@@ -2307,68 +2328,49 @@ class Vt extends K {
2307
2328
  return this.stableHeight === this.height;
2308
2329
  }
2309
2330
  }
2310
- async function Fe(e, t = {}) {
2311
- const {
2312
- height: s,
2313
- width: n,
2314
- isExpanded: r,
2315
- isStateStable: i
2316
- } = await Dt({ ...t, postEvent: e });
2317
- return new Vt({
2318
- postEvent: e,
2319
- height: s,
2320
- width: n,
2321
- isExpanded: r,
2322
- stableHeight: i ? s : 0
2323
- });
2324
- }
2325
- function ze({
2326
- state: e,
2327
- platform: t,
2328
- postEvent: s
2329
- }) {
2330
- let n = !1, r = 0, i = 0, o = 0;
2331
- return e ? (n = e.isExpanded, r = e.height, i = e.width, o = e.stableHeight) : ["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t) && (n = !0, r = window.innerHeight, i = window.innerWidth, o = window.innerHeight), new Vt({
2332
- postEvent: s,
2333
- height: r,
2334
- width: i,
2335
- stableHeight: o,
2336
- isExpanded: n
2337
- });
2338
- }
2339
- const ys = u(
2331
+ const ws = l(
2340
2332
  "viewport",
2341
- async (e) => {
2342
- if (y() && !e.state)
2343
- throw f(
2344
- pt,
2345
- "Viewport cannot be instantiated on the server side without passing the ssr.state object."
2346
- );
2347
- let t = ze(e);
2348
- return y() || (t.width === 0 && await Fe(e.postEvent, { timeout: 1e3 }).then((s) => t = s).catch((s) => D.error("Unable to sync viewport state", s)), t.listen()), t;
2333
+ async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
2334
+ let r = !1, i = 0, a = 0, o = 0;
2335
+ if (e)
2336
+ r = e.isExpanded, i = e.height, a = e.width, o = e.stableHeight;
2337
+ else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2338
+ r = !0, i = window.innerHeight, a = window.innerWidth, o = window.innerHeight;
2339
+ else {
2340
+ const u = await qt({ timeout: 1e3, postEvent: s });
2341
+ r = u.isExpanded, i = u.height, a = u.width, o = u.isStateStable ? i : 0;
2342
+ }
2343
+ const p = new Ge({
2344
+ postEvent: s,
2345
+ height: i,
2346
+ width: a,
2347
+ stableHeight: o,
2348
+ isExpanded: r
2349
+ });
2350
+ return n(p.listen()), p;
2349
2351
  }
2350
2352
  );
2351
2353
  function m(e, t) {
2352
2354
  document.documentElement.style.setProperty(e, t);
2353
2355
  }
2354
- function vs(e, t, s) {
2355
- s || (s = (a) => `--tg-${a}-color`);
2356
+ function ms(e, t, s) {
2357
+ s || (s = (o) => `--tg-${o}-color`);
2356
2358
  const n = s("header"), r = s("bg"), i = () => {
2357
- const { headerColor: a } = e;
2358
- if (Q(a))
2359
- m(n, a);
2359
+ const { headerColor: o } = e;
2360
+ if (Q(o))
2361
+ m(n, o);
2360
2362
  else {
2361
- const { bgColor: p, secondaryBgColor: l } = t;
2362
- a === "bg_color" && p ? m(n, p) : a === "secondary_bg_color" && l && m(n, l);
2363
+ const { bgColor: p, secondaryBgColor: u } = t;
2364
+ o === "bg_color" && p ? m(n, p) : o === "secondary_bg_color" && u && m(n, u);
2363
2365
  }
2364
2366
  m(r, e.bgColor);
2365
- }, o = [
2367
+ }, a = [
2366
2368
  t.on("change", i),
2367
2369
  e.on("change", i)
2368
2370
  ];
2369
- return i(), () => o.forEach((a) => a());
2371
+ return i(), () => a.forEach((o) => o());
2370
2372
  }
2371
- function Es(e, t) {
2373
+ function ys(e, t) {
2372
2374
  t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
2373
2375
  const s = () => {
2374
2376
  Object.entries(e.getState()).forEach(([n, r]) => {
@@ -2377,23 +2379,23 @@ function Es(e, t) {
2377
2379
  };
2378
2380
  return s(), e.on("change", s);
2379
2381
  }
2380
- function Ps(e, t) {
2381
- t || (t = (l) => `--tg-viewport-${l}`);
2382
+ function vs(e, t) {
2383
+ t || (t = (u) => `--tg-viewport-${u}`);
2382
2384
  const [
2383
2385
  s,
2384
2386
  n,
2385
2387
  r
2386
- ] = ["height", "width", "stable-height"].map((l) => t(l)), i = () => m(s, `${e.height}px`), o = () => m(n, `${e.width}px`), a = () => m(r, `${e.stableHeight}px`), p = [
2388
+ ] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => m(s, `${e.height}px`), a = () => m(n, `${e.width}px`), o = () => m(r, `${e.stableHeight}px`), p = [
2387
2389
  e.on("change:height", i),
2388
- e.on("change:width", o),
2389
- e.on("change:stableHeight", a)
2390
+ e.on("change:width", a),
2391
+ e.on("change:stableHeight", o)
2390
2392
  ];
2391
- return i(), o(), a(), () => p.forEach((l) => l());
2393
+ return i(), a(), o(), () => p.forEach((u) => u());
2392
2394
  }
2393
- function xs(e = !0) {
2395
+ function Es(e = !0) {
2394
2396
  const t = [
2395
2397
  b("reload_iframe", () => {
2396
- A("iframe_will_reload"), window.location.reload();
2398
+ R("iframe_will_reload"), window.location.reload();
2397
2399
  })
2398
2400
  ], s = () => t.forEach((n) => n());
2399
2401
  if (e) {
@@ -2405,10 +2407,13 @@ function xs(e = !0) {
2405
2407
  () => document.head.removeChild(n)
2406
2408
  );
2407
2409
  }
2408
- return A("iframe_ready", { reload_supported: !0 }), s;
2410
+ return R("iframe_ready", { reload_supported: !0 }), s;
2411
+ }
2412
+ function Ps() {
2413
+ return typeof window > "u";
2409
2414
  }
2410
- async function Ss() {
2411
- if (_t(window))
2415
+ async function xs() {
2416
+ if (ut(window))
2412
2417
  return !0;
2413
2418
  try {
2414
2419
  return await _({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
@@ -2416,13 +2421,13 @@ async function Ss() {
2416
2421
  return !1;
2417
2422
  }
2418
2423
  }
2419
- function Je(e) {
2420
- return e instanceof $;
2424
+ function je(e) {
2425
+ return e instanceof V;
2421
2426
  }
2422
2427
  function Cs(e, t) {
2423
- return Je(e) && e.type === t;
2428
+ return je(e) && e.type === t;
2424
2429
  }
2425
- function O(e, t) {
2430
+ function B(e, t) {
2426
2431
  let s, n, r;
2427
2432
  return typeof e == "string" ? s = e : (s = e.pathname === void 0 ? t : e.pathname, n = e.params, r = e.id), Object.freeze({
2428
2433
  id: r || (Math.random() * 2 ** 14 | 0).toString(16),
@@ -2430,13 +2435,13 @@ function O(e, t) {
2430
2435
  params: n
2431
2436
  });
2432
2437
  }
2433
- class Qe {
2434
- constructor(t, s, n = A) {
2438
+ class ze {
2439
+ constructor(t, s, n = R) {
2435
2440
  /**
2436
2441
  * Navigation history.
2437
2442
  */
2438
2443
  c(this, "history");
2439
- c(this, "ee", new V());
2444
+ c(this, "ee", new D());
2440
2445
  /**
2441
2446
  * True, if current navigator is currently attached.
2442
2447
  */
@@ -2454,13 +2459,13 @@ class Qe {
2454
2459
  */
2455
2460
  c(this, "off", this.ee.off.bind(this.ee));
2456
2461
  if (this._index = s, this.postEvent = n, t.length === 0)
2457
- throw f(Qt, "History should not be empty.");
2462
+ throw f(jt, "History should not be empty.");
2458
2463
  if (s < 0 || s >= t.length)
2459
2464
  throw f(
2460
- Yt,
2465
+ zt,
2461
2466
  "Index should not be zero and higher or equal than history size."
2462
2467
  );
2463
- this.history = t.map((r) => O(r, ""));
2468
+ this.history = t.map((r) => B(r, ""));
2464
2469
  }
2465
2470
  /**
2466
2471
  * Allows this navigator to control the `BackButton` visibility state. It also tracks the
@@ -2479,7 +2484,7 @@ class Qe {
2479
2484
  * Prevents current navigator from controlling the BackButton visibility state.
2480
2485
  */
2481
2486
  detach() {
2482
- this.attached = !1, B("back_button_pressed", this.back);
2487
+ this.attached = !1, L("back_button_pressed", this.back);
2483
2488
  }
2484
2489
  /**
2485
2490
  * Goes to the next history item.
@@ -2535,14 +2540,14 @@ class Qe {
2535
2540
  * @param item - item to add.
2536
2541
  */
2537
2542
  push(t) {
2538
- this.hasNext && this.history.splice(this.index + 1), this.replaceAndMove(this.index + 1, O(t, this.current.pathname));
2543
+ this.hasNext && this.history.splice(this.index + 1), this.replaceAndMove(this.index + 1, B(t, this.current.pathname));
2539
2544
  }
2540
2545
  /**
2541
2546
  * Replaces the current history item.
2542
2547
  * @param item - item to replace the current item with.
2543
2548
  */
2544
2549
  replace(t) {
2545
- this.replaceAndMove(this.index, O(t, this.current.pathname));
2550
+ this.replaceAndMove(this.index, B(t, this.current.pathname));
2546
2551
  }
2547
2552
  /**
2548
2553
  * Sets history item by the specified index.
@@ -2572,18 +2577,18 @@ class Qe {
2572
2577
  this.postEvent("web_app_setup_back_button", { is_visible: !!this.index });
2573
2578
  }
2574
2579
  }
2575
- function U({
2580
+ function O({
2576
2581
  params: e,
2577
2582
  ...t
2578
2583
  }) {
2579
2584
  return { ...e || { hash: "", search: "" }, ...t };
2580
2585
  }
2581
- function T(e, t) {
2586
+ function A(e, t) {
2582
2587
  return e.startsWith(t) ? e : `${t}${e}`;
2583
2588
  }
2584
2589
  function k(e) {
2585
2590
  return new URL(
2586
- typeof e == "string" ? e : `${e.pathname || ""}${T(e.search || "", "?")}${T(e.hash || "", "#")}`,
2591
+ typeof e == "string" ? e : `${e.pathname || ""}${A(e.search || "", "?")}${A(e.hash || "", "#")}`,
2587
2592
  "http://a"
2588
2593
  );
2589
2594
  }
@@ -2591,16 +2596,16 @@ function N(e) {
2591
2596
  const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = k(e);
2592
2597
  return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
2593
2598
  }
2594
- function W(e, t, s) {
2599
+ function U(e, t, s) {
2595
2600
  let n, r;
2596
2601
  typeof e == "string" ? n = e : (n = N(e), s = e.state, r = e.id);
2597
- const { pathname: i, search: o, hash: a } = new URL(n, `http://a${T(t, "/")}`);
2598
- return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
2602
+ const { pathname: i, search: a, hash: o } = new URL(n, `http://a${A(t, "/")}`);
2603
+ return { id: r, pathname: i, params: { hash: o, search: a, state: s } };
2599
2604
  }
2600
- async function R(e) {
2605
+ async function S(e) {
2601
2606
  return e === 0 ? !0 : Promise.race([
2602
2607
  new Promise((t) => {
2603
- const s = F("popstate", () => {
2608
+ const s = j("popstate", () => {
2604
2609
  s(), t(!0);
2605
2610
  });
2606
2611
  window.history.go(e);
@@ -2611,21 +2616,21 @@ async function R(e) {
2611
2616
  })
2612
2617
  ]);
2613
2618
  }
2614
- async function Ye() {
2615
- if (window.history.length <= 1 || (window.history.pushState(null, ""), await R(1 - window.history.length)))
2619
+ async function Fe() {
2620
+ if (window.history.length <= 1 || (window.history.pushState(null, ""), await S(1 - window.history.length)))
2616
2621
  return;
2617
- let t = await R(-1);
2622
+ let t = await S(-1);
2618
2623
  for (; t; )
2619
- t = await R(-1);
2624
+ t = await S(-1);
2620
2625
  }
2621
- function $t(e) {
2626
+ function kt(e) {
2622
2627
  return k(e).pathname;
2623
2628
  }
2624
- const ot = 0, H = 1, G = 2;
2625
- class Mt {
2626
- constructor(t, s, { postEvent: n, hashMode: r, base: i } = {}) {
2629
+ const rt = 0, W = 1, H = 2;
2630
+ class Nt {
2631
+ constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2627
2632
  c(this, "navigator");
2628
- c(this, "ee", new V());
2633
+ c(this, "ee", new D());
2629
2634
  c(this, "hashMode");
2630
2635
  c(this, "base");
2631
2636
  /**
@@ -2639,7 +2644,7 @@ class Mt {
2639
2644
  c(this, "onPopState", ({ state: t }) => {
2640
2645
  if (t === null)
2641
2646
  return this.push(this.parsePath(window.location.href));
2642
- t === ot ? window.history.forward() : t === H && this.back(), t === G && this.forward();
2647
+ t === rt ? window.history.forward() : t === W && this.back(), t === H && this.forward();
2643
2648
  });
2644
2649
  /**
2645
2650
  * Underlying navigator change event listener.
@@ -2651,8 +2656,8 @@ class Mt {
2651
2656
  }) => {
2652
2657
  this.attached && await this.syncHistory(), this.ee.emit("change", {
2653
2658
  delta: n,
2654
- from: U(s),
2655
- to: U(t),
2659
+ from: O(s),
2660
+ to: O(t),
2656
2661
  navigator: this
2657
2662
  });
2658
2663
  });
@@ -2664,11 +2669,11 @@ class Mt {
2664
2669
  * Removes event listener.
2665
2670
  */
2666
2671
  c(this, "off", this.ee.off.bind(this.ee));
2667
- this.navigator = new Qe(
2668
- t.map((o) => W(o, "/")),
2672
+ this.navigator = new ze(
2673
+ t.map((a) => U(a, "/")),
2669
2674
  s,
2670
2675
  n
2671
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = $t(i || "");
2676
+ ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = kt(i || "");
2672
2677
  }
2673
2678
  /**
2674
2679
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2752,7 +2757,7 @@ class Mt {
2752
2757
  * Navigation history.
2753
2758
  */
2754
2759
  get history() {
2755
- return this.navigator.history.map(U);
2760
+ return this.navigator.history.map(O);
2756
2761
  }
2757
2762
  /**
2758
2763
  * Path, including pathname, search and hash.
@@ -2803,11 +2808,11 @@ class Mt {
2803
2808
  };
2804
2809
  }
2805
2810
  push(t, s) {
2806
- const n = W(t, this.path), { state: r = s } = n.params;
2811
+ const n = U(t, this.path), { state: r = s } = n.params;
2807
2812
  this.navigator.push({ ...n, params: { ...n.params, state: r } });
2808
2813
  }
2809
2814
  replace(t, s) {
2810
- const n = W(t, this.path), { state: r = s } = n.params;
2815
+ const n = U(t, this.path), { state: r = s } = n.params;
2811
2816
  this.navigator.replace({ ...n, params: { ...n.params, state: r } });
2812
2817
  }
2813
2818
  /**
@@ -2816,8 +2821,8 @@ class Mt {
2816
2821
  * @param value - path presented as string or URLLike.
2817
2822
  */
2818
2823
  renderPath(t) {
2819
- const s = (this.base.length === 1 ? "" : this.base) + T(N(t), "/");
2820
- return this.hashMode ? T(s.slice(1), this.hashMode === "default" ? "#" : "#/") : s;
2824
+ const s = (this.base.length === 1 ? "" : this.base) + A(N(t), "/");
2825
+ return this.hashMode ? A(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2821
2826
  }
2822
2827
  /**
2823
2828
  * Synchronizes current navigator state with browser history.
@@ -2825,7 +2830,7 @@ class Mt {
2825
2830
  async syncHistory() {
2826
2831
  window.removeEventListener("popstate", this.onPopState);
2827
2832
  const { state: t } = this, s = this.renderPath(this);
2828
- await Ye(), this.hasPrev && this.hasNext ? (window.history.replaceState(H, ""), window.history.pushState(t, "", s), window.history.pushState(G, ""), await R(-1)) : this.hasPrev ? (window.history.replaceState(H, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(G, ""), await R(-1)) : (window.history.replaceState(ot, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2833
+ await Fe(), this.hasPrev && this.hasNext ? (window.history.replaceState(W, ""), window.history.pushState(t, "", s), window.history.pushState(H, ""), await S(-1)) : this.hasPrev ? (window.history.replaceState(W, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(H, ""), await S(-1)) : (window.history.replaceState(rt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2829
2834
  }
2830
2835
  /**
2831
2836
  * Current query parameters.
@@ -2843,148 +2848,148 @@ class Mt {
2843
2848
  return (this.navigator.current.params || {}).state;
2844
2849
  }
2845
2850
  }
2846
- function Ze(e) {
2851
+ function Je(e) {
2847
2852
  e || (e = {});
2848
2853
  const { href: t, hash: s } = window.location;
2849
2854
  let n = N(
2850
- e.hashMode ? s.includes("?") ? s.slice(1) : `?${s.slice(1)}` : t
2855
+ e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
2851
2856
  );
2852
- const r = e.base ? $t(e.base) : void 0;
2857
+ const r = e.base ? kt(e.base) : void 0;
2853
2858
  if (r) {
2854
2859
  if (!n.startsWith(r))
2855
2860
  throw f(
2856
- Zt,
2861
+ Ft,
2857
2862
  `Path "${n}" expected to be starting with "${r}"`
2858
2863
  );
2859
2864
  n = n.slice(r.length);
2860
2865
  }
2861
- return new Mt([n], 0, e);
2866
+ return new Nt([n], 0, e);
2862
2867
  }
2863
- function Rs(e) {
2868
+ function Ss(e) {
2864
2869
  const t = e.match(/#(.+)/);
2865
2870
  return t ? t[1] : null;
2866
2871
  }
2867
- function Xe(e, t) {
2868
- if (It()) {
2872
+ function Qe(e, t) {
2873
+ if (Rt()) {
2869
2874
  const s = sessionStorage.getItem(e);
2870
2875
  if (s)
2871
2876
  try {
2872
2877
  const { index: n, history: r } = JSON.parse(s);
2873
- return new Mt(r, n, t);
2878
+ return new Nt(r, n, t);
2874
2879
  } catch (n) {
2875
2880
  console.error("Unable to restore hash navigator state.", n);
2876
2881
  }
2877
2882
  }
2878
- return Ze(t);
2883
+ return Je(t);
2879
2884
  }
2880
- function As(e, t) {
2881
- const s = Xe(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2885
+ function Rs(e, t) {
2886
+ const s = Qe(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2882
2887
  index: s.index,
2883
2888
  history: s.history
2884
2889
  }));
2885
2890
  return s.on("change", n), n(), s;
2886
2891
  }
2887
2892
  export {
2888
- _e as BackButton,
2889
- Qe as BasicNavigator,
2890
- rt as BiometryManager,
2891
- Mt as BrowserNavigator,
2892
- Ae as ClosingBehavior,
2893
- ke as CloudStorage,
2894
- Zt as ERR_INVALID_PATH_BASE,
2895
- Ft as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2896
- Gt as ERR_METHOD_PARAMETER_UNSUPPORTED,
2897
- Ht as ERR_METHOD_UNSUPPORTED,
2898
- Qt as ERR_NAVIGATION_HISTORY_EMPTY,
2899
- Yt as ERR_NAVIGATION_INDEX_INVALID,
2900
- es as ERR_NAVIGATION_ITEM_INVALID,
2901
- ht as ERR_PARSE,
2902
- pt as ERR_SSR_INIT,
2903
- zt as ERR_TIMED_OUT,
2904
- Jt as ERR_UNEXPECTED_TYPE,
2905
- jt as ERR_UNKNOWN_ENV,
2906
- V as EventEmitter,
2907
- Ne as HapticFeedback,
2908
- De as InitData,
2909
- Ve as Invoice,
2910
- $e as MainButton,
2911
- Be as MiniApp,
2912
- Ue as Popup,
2913
- We as QRScanner,
2914
- $ as SDKError,
2915
- He as SettingsButton,
2916
- Ge as ThemeParams,
2917
- je as Utils,
2918
- Vt as Viewport,
2919
- qe as array,
2920
- vs as bindMiniAppCSSVars,
2921
- Es as bindThemeParamsCSSVars,
2922
- Ps as bindViewportCSSVars,
2893
+ pe as BackButton,
2894
+ ze as BasicNavigator,
2895
+ xe as BiometryManager,
2896
+ Nt as BrowserNavigator,
2897
+ Se as ClosingBehavior,
2898
+ Ie as CloudStorage,
2899
+ Ft as ERR_INVALID_PATH_BASE,
2900
+ Wt as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2901
+ Ot as ERR_METHOD_PARAMETER_UNSUPPORTED,
2902
+ Bt as ERR_METHOD_UNSUPPORTED,
2903
+ jt as ERR_NAVIGATION_HISTORY_EMPTY,
2904
+ zt as ERR_NAVIGATION_INDEX_INVALID,
2905
+ Ke as ERR_NAVIGATION_ITEM_INVALID,
2906
+ at as ERR_PARSE,
2907
+ Xe as ERR_SSR_INIT,
2908
+ Ht as ERR_TIMED_OUT,
2909
+ Gt as ERR_UNEXPECTED_TYPE,
2910
+ Ut as ERR_UNKNOWN_ENV,
2911
+ D as EventEmitter,
2912
+ qe as HapticFeedback,
2913
+ ke as InitData,
2914
+ Ne as Invoice,
2915
+ De as MainButton,
2916
+ Me as MiniApp,
2917
+ Be as Popup,
2918
+ Oe as QRScanner,
2919
+ V as SDKError,
2920
+ Ue as SettingsButton,
2921
+ We as ThemeParams,
2922
+ He as Utils,
2923
+ Ge as Viewport,
2924
+ Te as array,
2925
+ ms as bindMiniAppCSSVars,
2926
+ ys as bindThemeParamsCSSVars,
2927
+ vs as bindViewportCSSVars,
2923
2928
  w as boolean,
2924
- gt as captureSameReq,
2929
+ dt as captureSameReq,
2925
2930
  z as classNames,
2926
- ce as compareVersions,
2927
- Ze as createBrowserNavigatorFromLocation,
2928
- le as createPostEvent,
2931
+ re as compareVersions,
2932
+ Je as createBrowserNavigatorFromLocation,
2933
+ ce as createPostEvent,
2929
2934
  k as createSafeURL,
2930
- vt as date,
2931
- Rs as getHash,
2932
- $t as getPathname,
2933
- rs as initBackButton,
2934
- is as initBiometryManager,
2935
- os as initClosingBehavior,
2936
- as as initCloudStorage,
2937
- cs as initHapticFeedback,
2938
- hs as initInitData,
2939
- us as initInvoice,
2940
- ls as initMainButton,
2941
- ds as initMiniApp,
2942
- As as initNavigator,
2943
- _s as initPopup,
2944
- fs as initQRScanner,
2945
- gs as initSettingsButton,
2946
- bs as initThemeParams,
2947
- ms as initUtils,
2948
- ys as initViewport,
2949
- xs as initWeb,
2935
+ wt as date,
2936
+ Ss as getHash,
2937
+ kt as getPathname,
2938
+ ss as initBackButton,
2939
+ ns as initBiometryManager,
2940
+ rs as initClosingBehavior,
2941
+ is as initCloudStorage,
2942
+ os as initHapticFeedback,
2943
+ as as initInitData,
2944
+ hs as initInvoice,
2945
+ ps as initMainButton,
2946
+ us as initMiniApp,
2947
+ Rs as initNavigator,
2948
+ ls as initPopup,
2949
+ ds as initQRScanner,
2950
+ _s as initSettingsButton,
2951
+ fs as initThemeParams,
2952
+ bs as initUtils,
2953
+ ws as initViewport,
2954
+ Es as initWeb,
2950
2955
  C as invokeCustomMethod,
2951
- mt as isColorDark,
2952
- pe as isIframe,
2953
- It as isPageReload,
2956
+ gt as isColorDark,
2957
+ oe as isIframe,
2958
+ Rt as isPageReload,
2954
2959
  Q as isRGB,
2955
- Xt as isRGBShort,
2956
- Je as isSDKError,
2960
+ Jt as isRGBShort,
2961
+ je as isSDKError,
2957
2962
  Cs as isSDKErrorOfType,
2958
- y as isSSR,
2959
- Ss as isTMA,
2963
+ Ps as isSSR,
2964
+ xs as isTMA,
2960
2965
  d as json,
2961
- ns as mergeClassNames,
2962
- v as number,
2963
- B as off,
2966
+ es as mergeClassNames,
2967
+ y as number,
2968
+ L as off,
2964
2969
  b as on,
2965
- ps as parseInitData,
2966
- xt as parseLaunchParams,
2967
- Nt as parseThemeParams,
2968
- A as postEvent,
2970
+ cs as parseInitData,
2971
+ vt as parseLaunchParams,
2972
+ It as parseThemeParams,
2973
+ R as postEvent,
2969
2974
  _ as request,
2970
- Re as requestBiometryInfo,
2971
- ws as requestThemeParams,
2972
- Dt as requestViewport,
2973
- xe as retrieveLaunchParams,
2974
- dt as rgb,
2975
- X as searchParams,
2976
- Ee as serializeLaunchParams,
2977
- ve as serializeThemeParams,
2975
+ Ce as requestBiometryInfo,
2976
+ gs as requestThemeParams,
2977
+ qt as requestViewport,
2978
+ ye as retrieveLaunchParams,
2979
+ pt as rgb,
2980
+ K as searchParams,
2981
+ we as serializeLaunchParams,
2982
+ be as serializeThemeParams,
2978
2983
  m as setCSSVar,
2979
- ts as setDebug,
2980
- ss as setTargetOrigin,
2984
+ Ze as setDebug,
2985
+ ts as setTargetOrigin,
2981
2986
  h as string,
2982
- Ot as subscribe,
2983
- E as supports,
2984
- ue as targetOrigin,
2985
- lt as toRGB,
2986
- ct as unsubscribe,
2987
+ $t as subscribe,
2988
+ v as supports,
2989
+ ae as targetOrigin,
2990
+ ht as toRGB,
2991
+ ot as unsubscribe,
2987
2992
  N as urlToPath,
2988
- wt as withTimeout
2993
+ ft as withTimeout
2989
2994
  };
2990
2995
  //# sourceMappingURL=index.js.map