@tma.js/sdk-react 2.2.7 → 2.2.8
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.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +620 -635
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
var
|
|
1
|
+
import { jsx as Pt } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as ne, useContext as re, useState as rt, useEffect as R, useRef as mt, useCallback as ie, useMemo as oe } from "react";
|
|
3
|
+
var ae = Object.defineProperty, ce = (e, t, s) => t in e ? ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => ce(e, typeof t != "symbol" ? t + "" : t, s);
|
|
4
4
|
function Rt(e, t) {
|
|
5
5
|
let s;
|
|
6
6
|
const n = () => {
|
|
@@ -8,14 +8,14 @@ function Rt(e, t) {
|
|
|
8
8
|
};
|
|
9
9
|
return [() => s === void 0 ? s = e(n) : s, n];
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function xt(e) {
|
|
12
12
|
const t = j(), { count: s } = t;
|
|
13
|
-
t.unsubscribe(e), s && !t.count &&
|
|
13
|
+
t.unsubscribe(e), s && !t.count && Se();
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return j().subscribe(e), () =>
|
|
15
|
+
function he(e) {
|
|
16
|
+
return j().subscribe(e), () => xt(e);
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class pe {
|
|
19
19
|
constructor(t, s = {}) {
|
|
20
20
|
this.scope = t, this.options = s;
|
|
21
21
|
}
|
|
@@ -55,18 +55,18 @@ class ue {
|
|
|
55
55
|
this.print("log", ...t);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
const it = new
|
|
58
|
+
const it = new pe("SDK", {
|
|
59
59
|
bgColor: "forestgreen",
|
|
60
60
|
textColor: "white"
|
|
61
61
|
});
|
|
62
62
|
let X = !1;
|
|
63
|
-
const
|
|
63
|
+
const bt = ({ name: e, payload: t }) => {
|
|
64
64
|
it.log("Event received:", t ? { name: e, payload: t } : { name: e });
|
|
65
65
|
};
|
|
66
|
-
function
|
|
67
|
-
X !== e && (X = e, e ?
|
|
66
|
+
function ue(e) {
|
|
67
|
+
X !== e && (X = e, e ? he(bt) : xt(bt));
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function le(...e) {
|
|
70
70
|
X && it.log(...e);
|
|
71
71
|
}
|
|
72
72
|
class D {
|
|
@@ -144,7 +144,7 @@ function tt(e, t, s) {
|
|
|
144
144
|
}
|
|
145
145
|
function ot(...e) {
|
|
146
146
|
let t = !1;
|
|
147
|
-
const s =
|
|
147
|
+
const s = e.flat(1);
|
|
148
148
|
return [
|
|
149
149
|
(n) => !t && s.push(n),
|
|
150
150
|
() => {
|
|
@@ -158,12 +158,12 @@ class W extends Error {
|
|
|
158
158
|
super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, W.prototype);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function m(e, t, s) {
|
|
162
162
|
return new W(e, t, s);
|
|
163
163
|
}
|
|
164
|
-
const
|
|
164
|
+
const de = "ERR_METHOD_UNSUPPORTED", _e = "ERR_METHOD_PARAMETER_UNSUPPORTED", ge = "ERR_UNKNOWN_ENV", we = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", fe = "ERR_TIMED_OUT", me = "ERR_UNEXPECTED_TYPE", Ct = "ERR_PARSE", be = "ERR_NAVIGATION_LIST_EMPTY", ve = "ERR_NAVIGATION_CURSOR_INVALID", _n = "ERR_NAVIGATION_ITEM_INVALID", gn = "ERR_SSR_INIT", ye = "ERR_INVALID_PATH_BASE";
|
|
165
165
|
function T() {
|
|
166
|
-
return
|
|
166
|
+
return m(me, "Value has unexpected type");
|
|
167
167
|
}
|
|
168
168
|
class G {
|
|
169
169
|
constructor(t, s, n) {
|
|
@@ -180,8 +180,8 @@ class G {
|
|
|
180
180
|
try {
|
|
181
181
|
return this.parser(t);
|
|
182
182
|
} catch (s) {
|
|
183
|
-
throw
|
|
184
|
-
|
|
183
|
+
throw m(
|
|
184
|
+
Ct,
|
|
185
185
|
`Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
|
|
186
186
|
s
|
|
187
187
|
);
|
|
@@ -204,7 +204,7 @@ const E = A((e) => {
|
|
|
204
204
|
return !1;
|
|
205
205
|
throw T();
|
|
206
206
|
}, "boolean");
|
|
207
|
-
function
|
|
207
|
+
function St(e, t) {
|
|
208
208
|
const s = {};
|
|
209
209
|
for (const n in e) {
|
|
210
210
|
const r = e[n];
|
|
@@ -221,24 +221,24 @@ function Tt(e, t) {
|
|
|
221
221
|
const a = o(t(i));
|
|
222
222
|
a !== void 0 && (s[n] = a);
|
|
223
223
|
} catch (a) {
|
|
224
|
-
throw
|
|
224
|
+
throw m(Ct, `Unable to parse field "${n}"`, a);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
return s;
|
|
228
228
|
}
|
|
229
|
-
function
|
|
229
|
+
function Tt(e) {
|
|
230
230
|
let t = e;
|
|
231
231
|
if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
|
|
232
232
|
throw T();
|
|
233
233
|
return t;
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function v(e, t) {
|
|
236
236
|
return new G((s) => {
|
|
237
|
-
const n =
|
|
238
|
-
return
|
|
237
|
+
const n = Tt(s);
|
|
238
|
+
return St(e, (r) => n[r]);
|
|
239
239
|
}, !1, t);
|
|
240
240
|
}
|
|
241
|
-
const
|
|
241
|
+
const x = A((e) => {
|
|
242
242
|
if (typeof e == "number")
|
|
243
243
|
return e;
|
|
244
244
|
if (typeof e == "string") {
|
|
@@ -247,43 +247,18 @@ const R = A((e) => {
|
|
|
247
247
|
return t;
|
|
248
248
|
}
|
|
249
249
|
throw T();
|
|
250
|
-
}, "number")
|
|
251
|
-
function ct(e) {
|
|
252
|
-
return /^#[\da-f]{6}$/i.test(e);
|
|
253
|
-
}
|
|
254
|
-
function Pe(e) {
|
|
255
|
-
return /^#[\da-f]{3}$/i.test(e);
|
|
256
|
-
}
|
|
257
|
-
function At(e) {
|
|
258
|
-
const t = e.replace(/\s/g, "").toLowerCase();
|
|
259
|
-
if (ct(t))
|
|
260
|
-
return t;
|
|
261
|
-
if (Pe(t)) {
|
|
262
|
-
let n = "#";
|
|
263
|
-
for (let r = 0; r < 3; r += 1)
|
|
264
|
-
n += t[1 + r].repeat(2);
|
|
265
|
-
return n;
|
|
266
|
-
}
|
|
267
|
-
const s = t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/) || t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);
|
|
268
|
-
if (!s)
|
|
269
|
-
throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);
|
|
270
|
-
return s.slice(1).reduce((n, r) => {
|
|
271
|
-
const i = parseInt(r, 10).toString(16);
|
|
272
|
-
return n + (i.length === 1 ? "0" : "") + i;
|
|
273
|
-
}, "#");
|
|
274
|
-
}
|
|
275
|
-
const h = A((e) => {
|
|
250
|
+
}, "number"), u = A((e) => {
|
|
276
251
|
if (typeof e == "string" || typeof e == "number")
|
|
277
252
|
return e.toString();
|
|
278
253
|
throw T();
|
|
279
|
-
}, "string")
|
|
280
|
-
function
|
|
281
|
-
return
|
|
282
|
-
eventType:
|
|
254
|
+
}, "string");
|
|
255
|
+
function At(e) {
|
|
256
|
+
return v({
|
|
257
|
+
eventType: u(),
|
|
283
258
|
eventData: (t) => t
|
|
284
259
|
}).parse(e);
|
|
285
260
|
}
|
|
286
|
-
function
|
|
261
|
+
function Ee() {
|
|
287
262
|
["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
|
|
288
263
|
delete window[e];
|
|
289
264
|
});
|
|
@@ -295,7 +270,7 @@ function et(e, t) {
|
|
|
295
270
|
source: window.parent
|
|
296
271
|
}));
|
|
297
272
|
}
|
|
298
|
-
function
|
|
273
|
+
function Pe() {
|
|
299
274
|
[
|
|
300
275
|
["TelegramGameProxy_receiveEvent"],
|
|
301
276
|
// Windows Phone.
|
|
@@ -314,48 +289,38 @@ function Re() {
|
|
|
314
289
|
});
|
|
315
290
|
});
|
|
316
291
|
}
|
|
317
|
-
const
|
|
318
|
-
clipboard_text_received:
|
|
319
|
-
req_id:
|
|
320
|
-
data: (e) => e === null ? e :
|
|
292
|
+
const Re = {
|
|
293
|
+
clipboard_text_received: v({
|
|
294
|
+
req_id: u(),
|
|
295
|
+
data: (e) => e === null ? e : u().optional().parse(e)
|
|
321
296
|
}),
|
|
322
|
-
custom_method_invoked:
|
|
323
|
-
req_id:
|
|
297
|
+
custom_method_invoked: v({
|
|
298
|
+
req_id: u(),
|
|
324
299
|
result: (e) => e,
|
|
325
|
-
error:
|
|
300
|
+
error: u().optional()
|
|
326
301
|
}),
|
|
327
|
-
invoice_closed: w({ slug: h(), status: h() }),
|
|
328
|
-
phone_requested: w({ status: h() }),
|
|
329
302
|
popup_closed: {
|
|
330
303
|
parse(e) {
|
|
331
|
-
return
|
|
332
|
-
button_id: (t) => t == null ? void 0 :
|
|
304
|
+
return v({
|
|
305
|
+
button_id: (t) => t == null ? void 0 : u().parse(t)
|
|
333
306
|
}).parse(e ?? {});
|
|
334
307
|
}
|
|
335
308
|
},
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
const t = It().optional();
|
|
340
|
-
return Object.entries(at(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
|
|
341
|
-
}
|
|
342
|
-
}),
|
|
343
|
-
viewport_changed: w({
|
|
344
|
-
height: R(),
|
|
345
|
-
width: (e) => e == null ? window.innerWidth : R().parse(e),
|
|
309
|
+
viewport_changed: v({
|
|
310
|
+
height: x(),
|
|
311
|
+
width: (e) => e == null ? window.innerWidth : x().parse(e),
|
|
346
312
|
is_state_stable: E(),
|
|
347
313
|
is_expanded: E()
|
|
348
|
-
})
|
|
349
|
-
write_access_requested: w({ status: h() })
|
|
314
|
+
})
|
|
350
315
|
};
|
|
351
|
-
function
|
|
316
|
+
function xe() {
|
|
352
317
|
const e = new D(), t = new D();
|
|
353
318
|
t.subscribe((n) => {
|
|
354
319
|
e.emit("event", { name: n.event, payload: n.args[0] });
|
|
355
|
-
}),
|
|
320
|
+
}), Pe();
|
|
356
321
|
const [, s] = ot(
|
|
357
322
|
// Don't forget to remove created handlers.
|
|
358
|
-
|
|
323
|
+
Ee,
|
|
359
324
|
// Add "resize" event listener to make sure, we always have fresh viewport information.
|
|
360
325
|
// Desktop version of Telegram is sometimes not sending the viewport_changed
|
|
361
326
|
// event. For example, when the MainButton is shown. That's why we should
|
|
@@ -376,19 +341,21 @@ function Se() {
|
|
|
376
341
|
return;
|
|
377
342
|
let r;
|
|
378
343
|
try {
|
|
379
|
-
r =
|
|
344
|
+
r = At(n.data);
|
|
380
345
|
} catch {
|
|
381
346
|
return;
|
|
382
347
|
}
|
|
383
|
-
const { eventType: i, eventData: o } = r, a =
|
|
348
|
+
const { eventType: i, eventData: o } = r, a = Re[i];
|
|
384
349
|
try {
|
|
385
|
-
const
|
|
386
|
-
t.emit(...
|
|
387
|
-
} catch (
|
|
350
|
+
const h = a ? a.parse(o) : o;
|
|
351
|
+
t.emit(...h ? [i, h] : [i]);
|
|
352
|
+
} catch (h) {
|
|
388
353
|
it.error(
|
|
389
|
-
`An error occurred processing the "${i}" event from the Telegram application.
|
|
354
|
+
`An error occurred processing the "${i}" event from the Telegram application.
|
|
355
|
+
Please, file an issue here:
|
|
356
|
+
https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
|
|
390
357
|
r,
|
|
391
|
-
|
|
358
|
+
h
|
|
392
359
|
);
|
|
393
360
|
}
|
|
394
361
|
}),
|
|
@@ -410,9 +377,9 @@ function Se() {
|
|
|
410
377
|
}
|
|
411
378
|
}, s];
|
|
412
379
|
}
|
|
413
|
-
const [
|
|
380
|
+
const [Ce, Se] = Rt(
|
|
414
381
|
(e) => {
|
|
415
|
-
const [t, s] =
|
|
382
|
+
const [t, s] = xe(), n = t.off.bind(t);
|
|
416
383
|
return t.off = (r, i) => {
|
|
417
384
|
const { count: o } = t;
|
|
418
385
|
n(r, i), o && !t.count && e();
|
|
@@ -421,7 +388,7 @@ const [Te, Ae] = Rt(
|
|
|
421
388
|
([, e]) => e()
|
|
422
389
|
);
|
|
423
390
|
function j() {
|
|
424
|
-
return
|
|
391
|
+
return Ce()[0];
|
|
425
392
|
}
|
|
426
393
|
function z(e, t) {
|
|
427
394
|
j().off(e, t);
|
|
@@ -429,10 +396,10 @@ function z(e, t) {
|
|
|
429
396
|
function y(e, t, s) {
|
|
430
397
|
return j().on(e, t, s);
|
|
431
398
|
}
|
|
432
|
-
function
|
|
399
|
+
function L(e) {
|
|
433
400
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
434
401
|
}
|
|
435
|
-
function
|
|
402
|
+
function Te(e, t) {
|
|
436
403
|
const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
|
|
437
404
|
for (let i = 0; i < r; i += 1) {
|
|
438
405
|
const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
|
|
@@ -441,21 +408,21 @@ function Ie(e, t) {
|
|
|
441
408
|
}
|
|
442
409
|
return 0;
|
|
443
410
|
}
|
|
444
|
-
function
|
|
445
|
-
return
|
|
411
|
+
function f(e, t) {
|
|
412
|
+
return Te(e, t) <= 0;
|
|
446
413
|
}
|
|
447
414
|
function C(e, t, s) {
|
|
448
415
|
if (typeof s == "string") {
|
|
449
416
|
if (e === "web_app_open_link") {
|
|
450
417
|
if (t === "try_instant_view")
|
|
451
|
-
return
|
|
418
|
+
return f("6.4", s);
|
|
452
419
|
if (t === "try_browser")
|
|
453
|
-
return
|
|
420
|
+
return f("7.6", s);
|
|
454
421
|
}
|
|
455
422
|
if (e === "web_app_set_header_color" && t === "color")
|
|
456
|
-
return
|
|
423
|
+
return f("6.9", s);
|
|
457
424
|
if (e === "web_app_close" && t === "return_back")
|
|
458
|
-
return
|
|
425
|
+
return f("7.6", s);
|
|
459
426
|
}
|
|
460
427
|
switch (e) {
|
|
461
428
|
case "web_app_open_tg_link":
|
|
@@ -464,27 +431,27 @@ function C(e, t, s) {
|
|
|
464
431
|
case "web_app_set_background_color":
|
|
465
432
|
case "web_app_set_header_color":
|
|
466
433
|
case "web_app_trigger_haptic_feedback":
|
|
467
|
-
return
|
|
434
|
+
return f("6.1", t);
|
|
468
435
|
case "web_app_open_popup":
|
|
469
|
-
return
|
|
436
|
+
return f("6.2", t);
|
|
470
437
|
case "web_app_close_scan_qr_popup":
|
|
471
438
|
case "web_app_open_scan_qr_popup":
|
|
472
439
|
case "web_app_read_text_from_clipboard":
|
|
473
|
-
return
|
|
440
|
+
return f("6.4", t);
|
|
474
441
|
case "web_app_switch_inline_query":
|
|
475
|
-
return
|
|
442
|
+
return f("6.7", t);
|
|
476
443
|
case "web_app_invoke_custom_method":
|
|
477
444
|
case "web_app_request_write_access":
|
|
478
445
|
case "web_app_request_phone":
|
|
479
|
-
return
|
|
446
|
+
return f("6.9", t);
|
|
480
447
|
case "web_app_setup_settings_button":
|
|
481
|
-
return
|
|
448
|
+
return f("6.10", t);
|
|
482
449
|
case "web_app_biometry_get_info":
|
|
483
450
|
case "web_app_biometry_open_settings":
|
|
484
451
|
case "web_app_biometry_request_access":
|
|
485
452
|
case "web_app_biometry_request_auth":
|
|
486
453
|
case "web_app_biometry_update_token":
|
|
487
|
-
return
|
|
454
|
+
return f("7.2", t);
|
|
488
455
|
default:
|
|
489
456
|
return [
|
|
490
457
|
"iframe_ready",
|
|
@@ -501,94 +468,93 @@ function C(e, t, s) {
|
|
|
501
468
|
].includes(e);
|
|
502
469
|
}
|
|
503
470
|
}
|
|
504
|
-
function
|
|
505
|
-
return "external" in e &&
|
|
471
|
+
function It(e) {
|
|
472
|
+
return "external" in e && L(e.external) && "notify" in e.external && typeof e.external.notify == "function";
|
|
506
473
|
}
|
|
507
|
-
function
|
|
508
|
-
return "TelegramWebviewProxy" in e &&
|
|
474
|
+
function kt(e) {
|
|
475
|
+
return "TelegramWebviewProxy" in e && L(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
|
|
509
476
|
}
|
|
510
|
-
function
|
|
477
|
+
function at() {
|
|
511
478
|
try {
|
|
512
479
|
return window.self !== window.top;
|
|
513
480
|
} catch {
|
|
514
481
|
return !0;
|
|
515
482
|
}
|
|
516
483
|
}
|
|
517
|
-
|
|
484
|
+
const Ae = "https://web.telegram.org";
|
|
485
|
+
let Ot = Ae;
|
|
518
486
|
function wn(e) {
|
|
519
|
-
|
|
487
|
+
Ot = e;
|
|
520
488
|
}
|
|
521
|
-
function
|
|
522
|
-
return
|
|
489
|
+
function Ie() {
|
|
490
|
+
return Ot;
|
|
523
491
|
}
|
|
524
|
-
function
|
|
492
|
+
function V(e, t, s) {
|
|
525
493
|
let n = {}, r;
|
|
526
|
-
t
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
if (qt(window)) {
|
|
494
|
+
if (!t && !s ? n = {} : t && s ? (n = s, r = t) : t && ("targetOrigin" in t ? n = t : r = t), le("Posting event:", r ? { event: e, data: r } : { event: e }), at())
|
|
495
|
+
return window.parent.postMessage(
|
|
496
|
+
JSON.stringify({ eventType: e, eventData: r }),
|
|
497
|
+
n.targetOrigin || Ie()
|
|
498
|
+
);
|
|
499
|
+
if (It(window)) {
|
|
533
500
|
window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
|
|
534
501
|
return;
|
|
535
502
|
}
|
|
536
|
-
if (
|
|
503
|
+
if (kt(window)) {
|
|
537
504
|
window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
|
|
538
505
|
return;
|
|
539
506
|
}
|
|
540
|
-
throw
|
|
507
|
+
throw m(
|
|
541
508
|
ge,
|
|
542
|
-
"Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside
|
|
509
|
+
"Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside the Telegram application environment."
|
|
543
510
|
);
|
|
544
511
|
}
|
|
545
|
-
function
|
|
512
|
+
function ke(e) {
|
|
546
513
|
return (t, s) => {
|
|
547
514
|
if (!C(t, e))
|
|
548
|
-
throw
|
|
549
|
-
if (
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
);
|
|
556
|
-
}
|
|
557
|
-
return B(t, s);
|
|
515
|
+
throw m(de, `Method "${t}" is unsupported in Mini Apps version ${e}`);
|
|
516
|
+
if (L(s) && t === "web_app_set_header_color" && "color" in s && !C(t, "color", e))
|
|
517
|
+
throw m(
|
|
518
|
+
_e,
|
|
519
|
+
`Parameter "color" of "${t}" method is unsupported in Mini Apps version ${e}`
|
|
520
|
+
);
|
|
521
|
+
return V(t, s);
|
|
558
522
|
};
|
|
559
523
|
}
|
|
560
|
-
function
|
|
524
|
+
function qt(e) {
|
|
561
525
|
return ({ req_id: t }) => t === e;
|
|
562
526
|
}
|
|
563
|
-
function
|
|
564
|
-
return
|
|
527
|
+
function Nt(e) {
|
|
528
|
+
return m(fe, `Timeout reached: ${e}ms`);
|
|
565
529
|
}
|
|
566
|
-
function
|
|
530
|
+
function Dt(e, t) {
|
|
567
531
|
return Promise.race([
|
|
568
532
|
typeof e == "function" ? e() : e,
|
|
569
533
|
new Promise((s, n) => {
|
|
570
534
|
setTimeout(() => {
|
|
571
|
-
n(
|
|
535
|
+
n(Nt(t));
|
|
572
536
|
}, t);
|
|
573
537
|
})
|
|
574
538
|
]);
|
|
575
539
|
}
|
|
576
540
|
async function g(e) {
|
|
577
541
|
let t;
|
|
578
|
-
const s = new Promise((a) => {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
542
|
+
const s = new Promise((a) => t = a), { event: n, capture: r, timeout: i } = e, [, o] = ot(
|
|
543
|
+
// We need to iterate over all tracked events, and create their event listeners.
|
|
544
|
+
(Array.isArray(n) ? n : [n]).map((a) => y(a, (h) => {
|
|
545
|
+
(!r || (Array.isArray(n) ? r({
|
|
546
|
+
event: a,
|
|
547
|
+
payload: h
|
|
548
|
+
}) : r(h))) && t(h);
|
|
549
|
+
}))
|
|
584
550
|
);
|
|
585
551
|
try {
|
|
586
|
-
return (e.postEvent ||
|
|
552
|
+
return (e.postEvent || V)(e.method, e.params), await (i ? Dt(s, i) : s);
|
|
587
553
|
} finally {
|
|
588
554
|
o();
|
|
589
555
|
}
|
|
590
556
|
}
|
|
591
|
-
async function
|
|
557
|
+
async function q(e, t, s, n = {}) {
|
|
592
558
|
const {
|
|
593
559
|
result: r,
|
|
594
560
|
error: i
|
|
@@ -601,30 +567,54 @@ async function O(e, t, s, n = {}) {
|
|
|
601
567
|
params: t,
|
|
602
568
|
req_id: s
|
|
603
569
|
},
|
|
604
|
-
capture:
|
|
570
|
+
capture: qt(s)
|
|
605
571
|
});
|
|
606
572
|
if (i)
|
|
607
|
-
throw
|
|
573
|
+
throw m(we, i);
|
|
608
574
|
return r;
|
|
609
575
|
}
|
|
610
576
|
function st(...e) {
|
|
611
577
|
return e.map((t) => {
|
|
612
578
|
if (typeof t == "string")
|
|
613
579
|
return t;
|
|
614
|
-
if (
|
|
580
|
+
if (L(t))
|
|
615
581
|
return st(Object.entries(t).map((s) => s[1] && s[0]));
|
|
616
582
|
if (Array.isArray(t))
|
|
617
583
|
return st(...t);
|
|
618
584
|
}).filter(Boolean).join(" ");
|
|
619
585
|
}
|
|
620
|
-
function
|
|
621
|
-
return e.reduce((t, s) => (
|
|
586
|
+
function fn(...e) {
|
|
587
|
+
return e.reduce((t, s) => (L(s) && Object.entries(s).forEach(([n, r]) => {
|
|
622
588
|
const i = st(t[n], r);
|
|
623
589
|
i.length && (t[n] = i);
|
|
624
590
|
}), t), {});
|
|
625
591
|
}
|
|
592
|
+
function ct(e) {
|
|
593
|
+
return /^#[\da-f]{6}$/i.test(e);
|
|
594
|
+
}
|
|
595
|
+
function Oe(e) {
|
|
596
|
+
return /^#[\da-f]{3}$/i.test(e);
|
|
597
|
+
}
|
|
626
598
|
function Vt(e) {
|
|
627
|
-
const t =
|
|
599
|
+
const t = e.replace(/\s/g, "").toLowerCase();
|
|
600
|
+
if (ct(t))
|
|
601
|
+
return t;
|
|
602
|
+
if (Oe(t)) {
|
|
603
|
+
let n = "#";
|
|
604
|
+
for (let r = 0; r < 3; r += 1)
|
|
605
|
+
n += t[1 + r].repeat(2);
|
|
606
|
+
return n;
|
|
607
|
+
}
|
|
608
|
+
const s = t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/) || t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);
|
|
609
|
+
if (!s)
|
|
610
|
+
throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);
|
|
611
|
+
return s.slice(1).reduce((n, r) => {
|
|
612
|
+
const i = parseInt(r, 10).toString(16);
|
|
613
|
+
return n + (i.length === 1 ? "0" : "") + i;
|
|
614
|
+
}, "#");
|
|
615
|
+
}
|
|
616
|
+
function Bt(e) {
|
|
617
|
+
const t = Vt(e);
|
|
628
618
|
return Math.sqrt(
|
|
629
619
|
[0.299, 0.587, 0.114].reduce((s, n, r) => {
|
|
630
620
|
const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
|
|
@@ -632,7 +622,7 @@ function Vt(e) {
|
|
|
632
622
|
}, 0)
|
|
633
623
|
) < 120;
|
|
634
624
|
}
|
|
635
|
-
class
|
|
625
|
+
class qe {
|
|
636
626
|
constructor(t) {
|
|
637
627
|
c(this, "ee", new D()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
|
|
638
628
|
}
|
|
@@ -653,20 +643,20 @@ class Oe {
|
|
|
653
643
|
return this.state[t];
|
|
654
644
|
}
|
|
655
645
|
}
|
|
656
|
-
class
|
|
646
|
+
class ht {
|
|
657
647
|
constructor(t) {
|
|
658
|
-
c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new
|
|
648
|
+
c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new qe(t), this.set = this.state.set.bind(this.state), this.get = this.state.get.bind(this.state), this.clone = this.state.clone.bind(this.state);
|
|
659
649
|
}
|
|
660
650
|
}
|
|
661
|
-
function
|
|
651
|
+
function Mt(e, t) {
|
|
662
652
|
return (s) => C(t[s], e);
|
|
663
653
|
}
|
|
664
|
-
class
|
|
654
|
+
class pt extends ht {
|
|
665
655
|
constructor(t, s, n) {
|
|
666
|
-
super(t), c(this, "supports"), this.supports =
|
|
656
|
+
super(t), c(this, "supports"), this.supports = Mt(s, n);
|
|
667
657
|
}
|
|
668
658
|
}
|
|
669
|
-
class Ne extends
|
|
659
|
+
class Ne extends pt {
|
|
670
660
|
constructor(t, s, n) {
|
|
671
661
|
super({ isVisible: t }, s, {
|
|
672
662
|
show: "web_app_setup_back_button",
|
|
@@ -695,28 +685,28 @@ class Ne extends ut {
|
|
|
695
685
|
this.isVisible = !0;
|
|
696
686
|
}
|
|
697
687
|
}
|
|
698
|
-
const
|
|
699
|
-
function
|
|
688
|
+
const Lt = A((e) => e instanceof Date ? e : new Date(x().parse(e) * 1e3), "Date");
|
|
689
|
+
function ut(e, t) {
|
|
700
690
|
return new G((s) => {
|
|
701
691
|
if (typeof s != "string" && !(s instanceof URLSearchParams))
|
|
702
692
|
throw T();
|
|
703
693
|
const n = typeof s == "string" ? new URLSearchParams(s) : s;
|
|
704
|
-
return
|
|
694
|
+
return St(e, (r) => {
|
|
705
695
|
const i = n.get(r);
|
|
706
696
|
return i === null ? void 0 : i;
|
|
707
697
|
});
|
|
708
698
|
}, !1, t);
|
|
709
699
|
}
|
|
710
|
-
const De =
|
|
711
|
-
id:
|
|
712
|
-
type:
|
|
713
|
-
title:
|
|
700
|
+
const De = v({
|
|
701
|
+
id: x(),
|
|
702
|
+
type: u(),
|
|
703
|
+
title: u(),
|
|
714
704
|
photoUrl: {
|
|
715
|
-
type:
|
|
705
|
+
type: u().optional(),
|
|
716
706
|
from: "photo_url"
|
|
717
707
|
},
|
|
718
|
-
username:
|
|
719
|
-
}, "Chat").optional(),
|
|
708
|
+
username: u().optional()
|
|
709
|
+
}, "Chat").optional(), vt = v({
|
|
720
710
|
addedToAttachmentMenu: {
|
|
721
711
|
type: E().optional(),
|
|
722
712
|
from: "added_to_attachment_menu"
|
|
@@ -726,10 +716,10 @@ const De = w({
|
|
|
726
716
|
from: "allows_write_to_pm"
|
|
727
717
|
},
|
|
728
718
|
firstName: {
|
|
729
|
-
type:
|
|
719
|
+
type: u(),
|
|
730
720
|
from: "first_name"
|
|
731
721
|
},
|
|
732
|
-
id:
|
|
722
|
+
id: x(),
|
|
733
723
|
isBot: {
|
|
734
724
|
type: E().optional(),
|
|
735
725
|
from: "is_bot"
|
|
@@ -739,80 +729,81 @@ const De = w({
|
|
|
739
729
|
from: "is_premium"
|
|
740
730
|
},
|
|
741
731
|
languageCode: {
|
|
742
|
-
type:
|
|
732
|
+
type: u().optional(),
|
|
743
733
|
from: "language_code"
|
|
744
734
|
},
|
|
745
735
|
lastName: {
|
|
746
|
-
type:
|
|
736
|
+
type: u().optional(),
|
|
747
737
|
from: "last_name"
|
|
748
738
|
},
|
|
749
739
|
photoUrl: {
|
|
750
|
-
type:
|
|
740
|
+
type: u().optional(),
|
|
751
741
|
from: "photo_url"
|
|
752
742
|
},
|
|
753
|
-
username:
|
|
743
|
+
username: u().optional()
|
|
754
744
|
}, "User").optional();
|
|
755
|
-
function
|
|
756
|
-
return
|
|
745
|
+
function $t() {
|
|
746
|
+
return ut({
|
|
757
747
|
authDate: {
|
|
758
|
-
type:
|
|
748
|
+
type: Lt(),
|
|
759
749
|
from: "auth_date"
|
|
760
750
|
},
|
|
761
751
|
canSendAfter: {
|
|
762
|
-
type:
|
|
752
|
+
type: x().optional(),
|
|
763
753
|
from: "can_send_after"
|
|
764
754
|
},
|
|
765
755
|
chat: De,
|
|
766
756
|
chatInstance: {
|
|
767
|
-
type:
|
|
757
|
+
type: u().optional(),
|
|
768
758
|
from: "chat_instance"
|
|
769
759
|
},
|
|
770
760
|
chatType: {
|
|
771
|
-
type:
|
|
761
|
+
type: u().optional(),
|
|
772
762
|
from: "chat_type"
|
|
773
763
|
},
|
|
774
|
-
hash:
|
|
764
|
+
hash: u(),
|
|
775
765
|
queryId: {
|
|
776
|
-
type:
|
|
766
|
+
type: u().optional(),
|
|
777
767
|
from: "query_id"
|
|
778
768
|
},
|
|
779
|
-
receiver:
|
|
769
|
+
receiver: vt,
|
|
780
770
|
startParam: {
|
|
781
|
-
type:
|
|
771
|
+
type: u().optional(),
|
|
782
772
|
from: "start_param"
|
|
783
773
|
},
|
|
784
|
-
user:
|
|
774
|
+
user: vt
|
|
785
775
|
}, "InitData");
|
|
786
776
|
}
|
|
777
|
+
const Ve = A((e) => Vt(u().parse(e)), "rgb");
|
|
787
778
|
function Be(e) {
|
|
788
779
|
return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
|
|
789
780
|
}
|
|
790
781
|
function Me(e) {
|
|
791
782
|
return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
|
|
792
783
|
}
|
|
793
|
-
const
|
|
784
|
+
const Ht = A(
|
|
794
785
|
(e) => {
|
|
795
|
-
const t =
|
|
796
|
-
return Object.entries(
|
|
786
|
+
const t = Ve().optional();
|
|
787
|
+
return Object.entries(Tt(e)).reduce((s, [n, r]) => (s[Be(n)] = t.parse(r), s), {});
|
|
797
788
|
},
|
|
798
789
|
"ThemeParams"
|
|
799
790
|
);
|
|
800
|
-
function
|
|
801
|
-
return
|
|
791
|
+
function lt(e) {
|
|
792
|
+
return ut({
|
|
802
793
|
botInline: {
|
|
803
794
|
type: E().optional(),
|
|
804
795
|
from: "tgWebAppBotInline"
|
|
805
796
|
},
|
|
806
797
|
initData: {
|
|
807
|
-
type:
|
|
798
|
+
type: $t().optional(),
|
|
808
799
|
from: "tgWebAppData"
|
|
809
800
|
},
|
|
810
801
|
initDataRaw: {
|
|
811
|
-
type:
|
|
802
|
+
type: u().optional(),
|
|
812
803
|
from: "tgWebAppData"
|
|
813
804
|
},
|
|
814
805
|
platform: {
|
|
815
|
-
type:
|
|
806
|
+
type: u(),
|
|
816
807
|
from: "tgWebAppPlatform"
|
|
817
808
|
},
|
|
818
809
|
showSettings: {
|
|
@@ -820,60 +811,60 @@ function dt(e) {
|
|
|
820
811
|
from: "tgWebAppShowSettings"
|
|
821
812
|
},
|
|
822
813
|
startParam: {
|
|
823
|
-
type:
|
|
814
|
+
type: u().optional(),
|
|
824
815
|
from: "tgWebAppStartParam"
|
|
825
816
|
},
|
|
826
817
|
themeParams: {
|
|
827
|
-
type:
|
|
818
|
+
type: Ht(),
|
|
828
819
|
from: "tgWebAppThemeParams"
|
|
829
820
|
},
|
|
830
821
|
version: {
|
|
831
|
-
type:
|
|
822
|
+
type: u(),
|
|
832
823
|
from: "tgWebAppVersion"
|
|
833
824
|
}
|
|
834
825
|
}).parse(e);
|
|
835
826
|
}
|
|
836
|
-
function
|
|
837
|
-
return
|
|
827
|
+
function Ut(e) {
|
|
828
|
+
return lt(
|
|
838
829
|
e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
|
|
839
830
|
);
|
|
840
831
|
}
|
|
841
|
-
function
|
|
842
|
-
return
|
|
832
|
+
function Le() {
|
|
833
|
+
return Ut(window.location.href);
|
|
843
834
|
}
|
|
844
|
-
function
|
|
835
|
+
function Wt() {
|
|
845
836
|
return performance.getEntriesByType("navigation")[0];
|
|
846
837
|
}
|
|
847
|
-
function
|
|
848
|
-
const e =
|
|
838
|
+
function $e() {
|
|
839
|
+
const e = Wt();
|
|
849
840
|
if (!e)
|
|
850
841
|
throw new Error("Unable to get first navigation entry.");
|
|
851
|
-
return
|
|
842
|
+
return Ut(e.name);
|
|
852
843
|
}
|
|
853
|
-
function
|
|
844
|
+
function Gt(e) {
|
|
854
845
|
return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
|
|
855
846
|
}
|
|
856
|
-
function
|
|
857
|
-
sessionStorage.setItem(
|
|
847
|
+
function jt(e, t) {
|
|
848
|
+
sessionStorage.setItem(Gt(e), JSON.stringify(t));
|
|
858
849
|
}
|
|
859
|
-
function
|
|
860
|
-
const t = sessionStorage.getItem(
|
|
850
|
+
function zt(e) {
|
|
851
|
+
const t = sessionStorage.getItem(Gt(e));
|
|
861
852
|
try {
|
|
862
853
|
return t ? JSON.parse(t) : void 0;
|
|
863
854
|
} catch {
|
|
864
855
|
}
|
|
865
856
|
}
|
|
866
|
-
function
|
|
867
|
-
return
|
|
857
|
+
function He() {
|
|
858
|
+
return lt(zt("launchParams") || "");
|
|
868
859
|
}
|
|
869
|
-
function
|
|
860
|
+
function Kt(e) {
|
|
870
861
|
return JSON.stringify(
|
|
871
862
|
Object.fromEntries(
|
|
872
863
|
Object.entries(e).map(([t, s]) => [Me(t), s])
|
|
873
864
|
)
|
|
874
865
|
);
|
|
875
866
|
}
|
|
876
|
-
function
|
|
867
|
+
function Ue(e) {
|
|
877
868
|
const {
|
|
878
869
|
initDataRaw: t,
|
|
879
870
|
themeParams: s,
|
|
@@ -882,44 +873,44 @@ function He(e) {
|
|
|
882
873
|
showSettings: i,
|
|
883
874
|
startParam: o,
|
|
884
875
|
botInline: a
|
|
885
|
-
} = e,
|
|
886
|
-
return
|
|
876
|
+
} = e, h = new URLSearchParams();
|
|
877
|
+
return h.set("tgWebAppPlatform", n), h.set("tgWebAppThemeParams", Kt(s)), h.set("tgWebAppVersion", r), t && h.set("tgWebAppData", t), o && h.set("tgWebAppStartParam", o), typeof i == "boolean" && h.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && h.set("tgWebAppBotInline", a ? "1" : "0"), h.toString();
|
|
887
878
|
}
|
|
888
|
-
function
|
|
889
|
-
|
|
879
|
+
function Jt(e) {
|
|
880
|
+
jt("launchParams", Ue(e));
|
|
890
881
|
}
|
|
891
882
|
function nt() {
|
|
892
883
|
for (const e of [
|
|
893
884
|
// Try to retrieve launch parameters from the current location. This method can return
|
|
894
885
|
// nothing in case, location was changed and then page was reloaded.
|
|
895
|
-
Ve,
|
|
896
|
-
// Then, try using the lower level API - window.performance.
|
|
897
886
|
Le,
|
|
887
|
+
// Then, try using the lower level API - window.performance.
|
|
888
|
+
$e,
|
|
898
889
|
// Finally, try to extract launch parameters from the session storage.
|
|
899
|
-
|
|
890
|
+
He
|
|
900
891
|
])
|
|
901
892
|
try {
|
|
902
893
|
const t = e();
|
|
903
|
-
return
|
|
894
|
+
return Jt(t), t;
|
|
904
895
|
} catch {
|
|
905
896
|
}
|
|
906
897
|
throw new Error("Unable to retrieve launch parameters from any known source.");
|
|
907
898
|
}
|
|
908
|
-
function
|
|
909
|
-
const e =
|
|
899
|
+
function Ft() {
|
|
900
|
+
const e = Wt();
|
|
910
901
|
return !!(e && e.type === "reload");
|
|
911
902
|
}
|
|
912
|
-
function
|
|
903
|
+
function We() {
|
|
913
904
|
let e = 0;
|
|
914
905
|
return () => (e += 1).toString();
|
|
915
906
|
}
|
|
916
|
-
const [
|
|
907
|
+
const [Ge] = Rt(We);
|
|
917
908
|
function l(e, t) {
|
|
918
909
|
return () => {
|
|
919
910
|
const s = nt(), n = {
|
|
920
911
|
...s,
|
|
921
|
-
postEvent:
|
|
922
|
-
createRequestId:
|
|
912
|
+
postEvent: ke(s.version),
|
|
913
|
+
createRequestId: Ge()
|
|
923
914
|
};
|
|
924
915
|
if (typeof e == "function")
|
|
925
916
|
return e(n);
|
|
@@ -928,30 +919,30 @@ function l(e, t) {
|
|
|
928
919
|
// State should only be passed only in case, current page was reloaded. If we don't add
|
|
929
920
|
// this check, state restoration will work improperly in the web version of Telegram,
|
|
930
921
|
// when we are always working in the same "session" (tab).
|
|
931
|
-
state:
|
|
922
|
+
state: Ft() ? zt(e) : void 0,
|
|
932
923
|
addCleanup: r
|
|
933
|
-
}),
|
|
934
|
-
|
|
935
|
-
|
|
924
|
+
}), h = (p) => (o || r(
|
|
925
|
+
p.on("change", (S) => {
|
|
926
|
+
jt(e, S);
|
|
936
927
|
})
|
|
937
|
-
),
|
|
928
|
+
), p);
|
|
938
929
|
return [
|
|
939
|
-
a instanceof Promise ? a.then(
|
|
930
|
+
a instanceof Promise ? a.then(h) : h(a),
|
|
940
931
|
i
|
|
941
932
|
];
|
|
942
933
|
};
|
|
943
934
|
}
|
|
944
|
-
const
|
|
935
|
+
const je = l("backButton", ({
|
|
945
936
|
postEvent: e,
|
|
946
937
|
version: t,
|
|
947
938
|
state: s = { isVisible: !1 }
|
|
948
939
|
}) => new Ne(s.isVisible, t, e));
|
|
949
|
-
class
|
|
940
|
+
class $ extends pt {
|
|
950
941
|
constructor() {
|
|
951
942
|
super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
|
|
952
943
|
}
|
|
953
944
|
}
|
|
954
|
-
function
|
|
945
|
+
function Qt(e) {
|
|
955
946
|
const t = e.available ? e : {
|
|
956
947
|
available: !1,
|
|
957
948
|
device_id: "",
|
|
@@ -969,7 +960,7 @@ function Yt(e) {
|
|
|
969
960
|
accessGranted: t.access_granted
|
|
970
961
|
};
|
|
971
962
|
}
|
|
972
|
-
class
|
|
963
|
+
class ze extends $ {
|
|
973
964
|
constructor({ postEvent: t, version: s, ...n }) {
|
|
974
965
|
super(n, s, {
|
|
975
966
|
auth: "web_app_biometry_request_auth",
|
|
@@ -1047,7 +1038,7 @@ class je extends L {
|
|
|
1047
1038
|
event: "biometry_info_received",
|
|
1048
1039
|
params: { reason: t || "" }
|
|
1049
1040
|
}).then((n) => {
|
|
1050
|
-
const r =
|
|
1041
|
+
const r = Qt(n);
|
|
1051
1042
|
return this.set(r), r.accessGranted;
|
|
1052
1043
|
}).finally(() => this.accessPromise = void 0)), this.accessPromise;
|
|
1053
1044
|
}
|
|
@@ -1079,8 +1070,8 @@ class je extends L {
|
|
|
1079
1070
|
);
|
|
1080
1071
|
}
|
|
1081
1072
|
}
|
|
1082
|
-
async function
|
|
1083
|
-
return
|
|
1073
|
+
async function Ke(e) {
|
|
1074
|
+
return Qt(
|
|
1084
1075
|
await g({
|
|
1085
1076
|
...e || {},
|
|
1086
1077
|
method: "web_app_biometry_get_info",
|
|
@@ -1088,10 +1079,10 @@ async function ze(e) {
|
|
|
1088
1079
|
})
|
|
1089
1080
|
);
|
|
1090
1081
|
}
|
|
1091
|
-
const
|
|
1082
|
+
const Je = l(
|
|
1092
1083
|
"biometryManager",
|
|
1093
|
-
async ({ postEvent: e, version: t, state: s }) => new
|
|
1094
|
-
...s || C("web_app_biometry_get_info", t) ? s || await
|
|
1084
|
+
async ({ postEvent: e, version: t, state: s }) => new ze({
|
|
1085
|
+
...s || C("web_app_biometry_get_info", t) ? s || await Ke({ timeout: 1e3 }) : {
|
|
1095
1086
|
available: !1,
|
|
1096
1087
|
accessGranted: !1,
|
|
1097
1088
|
accessRequested: !1,
|
|
@@ -1102,12 +1093,12 @@ const Ke = l(
|
|
|
1102
1093
|
postEvent: e
|
|
1103
1094
|
})
|
|
1104
1095
|
);
|
|
1105
|
-
class
|
|
1096
|
+
class dt extends ht {
|
|
1106
1097
|
constructor() {
|
|
1107
1098
|
super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
|
|
1108
1099
|
}
|
|
1109
1100
|
}
|
|
1110
|
-
class
|
|
1101
|
+
class Fe extends dt {
|
|
1111
1102
|
constructor(t, s) {
|
|
1112
1103
|
super({ isConfirmationNeeded: t }), this.postEvent = s;
|
|
1113
1104
|
}
|
|
@@ -1134,19 +1125,19 @@ class Je extends _t {
|
|
|
1134
1125
|
this.isConfirmationNeeded = !0;
|
|
1135
1126
|
}
|
|
1136
1127
|
}
|
|
1137
|
-
const
|
|
1128
|
+
const Qe = l(
|
|
1138
1129
|
"closingBehavior",
|
|
1139
1130
|
({
|
|
1140
1131
|
postEvent: e,
|
|
1141
1132
|
state: t = { isConfirmationNeeded: !1 }
|
|
1142
|
-
}) => new
|
|
1133
|
+
}) => new Fe(t.isConfirmationNeeded, e)
|
|
1143
1134
|
);
|
|
1144
|
-
class
|
|
1135
|
+
class _t {
|
|
1145
1136
|
constructor(t, s) {
|
|
1146
|
-
c(this, "supports"), this.supports =
|
|
1137
|
+
c(this, "supports"), this.supports = Mt(t, s);
|
|
1147
1138
|
}
|
|
1148
1139
|
}
|
|
1149
|
-
function
|
|
1140
|
+
function Ye(e) {
|
|
1150
1141
|
if (Array.isArray(e))
|
|
1151
1142
|
return e;
|
|
1152
1143
|
if (typeof e == "string")
|
|
@@ -1158,9 +1149,9 @@ function Qe(e) {
|
|
|
1158
1149
|
}
|
|
1159
1150
|
throw T();
|
|
1160
1151
|
}
|
|
1161
|
-
class
|
|
1152
|
+
class Ze extends G {
|
|
1162
1153
|
constructor(t, s, n) {
|
|
1163
|
-
super(
|
|
1154
|
+
super(Ye, s, n), c(this, "itemParser"), this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
|
|
1164
1155
|
}
|
|
1165
1156
|
/**
|
|
1166
1157
|
* Attempts to parse passed value
|
|
@@ -1176,13 +1167,13 @@ class Ye extends G {
|
|
|
1176
1167
|
return this.itemParser = typeof t == "function" ? t : t.parse.bind(t), this;
|
|
1177
1168
|
}
|
|
1178
1169
|
}
|
|
1179
|
-
function
|
|
1180
|
-
return new
|
|
1170
|
+
function Xe(e) {
|
|
1171
|
+
return new Ze((t) => t, !1, e);
|
|
1181
1172
|
}
|
|
1182
|
-
function
|
|
1173
|
+
function yt(e, t) {
|
|
1183
1174
|
return Object.fromEntries(e.map((s) => [s, t]));
|
|
1184
1175
|
}
|
|
1185
|
-
class
|
|
1176
|
+
class ts extends _t {
|
|
1186
1177
|
constructor(t, s, n) {
|
|
1187
1178
|
super(t, {
|
|
1188
1179
|
delete: "web_app_invoke_custom_method",
|
|
@@ -1198,7 +1189,7 @@ class Xe extends wt {
|
|
|
1198
1189
|
*/
|
|
1199
1190
|
async delete(t, s = {}) {
|
|
1200
1191
|
const n = Array.isArray(t) ? t : [t];
|
|
1201
|
-
n.length && await
|
|
1192
|
+
n.length && await q(
|
|
1202
1193
|
"deleteStorageValues",
|
|
1203
1194
|
{ keys: n },
|
|
1204
1195
|
this.createRequestId(),
|
|
@@ -1210,8 +1201,8 @@ class Xe extends wt {
|
|
|
1210
1201
|
* @param options - request execution options.
|
|
1211
1202
|
*/
|
|
1212
1203
|
async getKeys(t = {}) {
|
|
1213
|
-
return
|
|
1214
|
-
await
|
|
1204
|
+
return Xe().of(u()).parse(
|
|
1205
|
+
await q(
|
|
1215
1206
|
"getStorageKeys",
|
|
1216
1207
|
{},
|
|
1217
1208
|
this.createRequestId(),
|
|
@@ -1222,13 +1213,13 @@ class Xe extends wt {
|
|
|
1222
1213
|
async get(t, s = {}) {
|
|
1223
1214
|
const n = Array.isArray(t) ? t : [t];
|
|
1224
1215
|
if (!n.length)
|
|
1225
|
-
return
|
|
1226
|
-
const r = await
|
|
1216
|
+
return yt(n, "");
|
|
1217
|
+
const r = await q(
|
|
1227
1218
|
"getStorageValues",
|
|
1228
1219
|
{ keys: n },
|
|
1229
1220
|
this.createRequestId(),
|
|
1230
1221
|
{ ...s, postEvent: this.postEvent }
|
|
1231
|
-
), i =
|
|
1222
|
+
), i = v(yt(n, u()), "CloudStorageData").parse(r);
|
|
1232
1223
|
return Array.isArray(t) ? i : i[t];
|
|
1233
1224
|
}
|
|
1234
1225
|
/**
|
|
@@ -1238,7 +1229,7 @@ class Xe extends wt {
|
|
|
1238
1229
|
* @param options - request execution options.
|
|
1239
1230
|
*/
|
|
1240
1231
|
async set(t, s, n = {}) {
|
|
1241
|
-
await
|
|
1232
|
+
await q(
|
|
1242
1233
|
"saveStorageValue",
|
|
1243
1234
|
{ key: t, value: s },
|
|
1244
1235
|
this.createRequestId(),
|
|
@@ -1246,10 +1237,10 @@ class Xe extends wt {
|
|
|
1246
1237
|
);
|
|
1247
1238
|
}
|
|
1248
1239
|
}
|
|
1249
|
-
const
|
|
1250
|
-
({ createRequestId: e, postEvent: t, version: s }) => new
|
|
1240
|
+
const es = l(
|
|
1241
|
+
({ createRequestId: e, postEvent: t, version: s }) => new ts(s, e, t)
|
|
1251
1242
|
);
|
|
1252
|
-
class
|
|
1243
|
+
class ss extends _t {
|
|
1253
1244
|
constructor(t, s) {
|
|
1254
1245
|
super(t, {
|
|
1255
1246
|
impactOccurred: "web_app_trigger_haptic_feedback",
|
|
@@ -1291,10 +1282,10 @@ class es extends wt {
|
|
|
1291
1282
|
this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
|
|
1292
1283
|
}
|
|
1293
1284
|
}
|
|
1294
|
-
const
|
|
1295
|
-
({ version: e, postEvent: t }) => new
|
|
1285
|
+
const ns = l(
|
|
1286
|
+
({ version: e, postEvent: t }) => new ss(e, t)
|
|
1296
1287
|
);
|
|
1297
|
-
class
|
|
1288
|
+
class rs {
|
|
1298
1289
|
constructor(t) {
|
|
1299
1290
|
this.initData = t;
|
|
1300
1291
|
}
|
|
@@ -1367,13 +1358,13 @@ class ns {
|
|
|
1367
1358
|
return this.initData.user;
|
|
1368
1359
|
}
|
|
1369
1360
|
}
|
|
1370
|
-
const
|
|
1371
|
-
({ initData: e }) => e ? new
|
|
1361
|
+
const is = l(
|
|
1362
|
+
({ initData: e }) => e ? new rs(e) : void 0
|
|
1372
1363
|
);
|
|
1373
|
-
function
|
|
1374
|
-
return
|
|
1364
|
+
function mn(e) {
|
|
1365
|
+
return $t().parse(e);
|
|
1375
1366
|
}
|
|
1376
|
-
class
|
|
1367
|
+
class os extends $ {
|
|
1377
1368
|
constructor(t, s, n) {
|
|
1378
1369
|
super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
|
|
1379
1370
|
}
|
|
@@ -1417,10 +1408,10 @@ class is extends L {
|
|
|
1417
1408
|
}
|
|
1418
1409
|
}
|
|
1419
1410
|
}
|
|
1420
|
-
const
|
|
1421
|
-
({ version: e, postEvent: t }) => new
|
|
1411
|
+
const as = l(
|
|
1412
|
+
({ version: e, postEvent: t }) => new os(!1, e, t)
|
|
1422
1413
|
);
|
|
1423
|
-
class
|
|
1414
|
+
class cs extends ht {
|
|
1424
1415
|
constructor({ postEvent: t, ...s }) {
|
|
1425
1416
|
super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ? y("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;
|
|
1426
1417
|
}
|
|
@@ -1551,7 +1542,7 @@ class as extends pt {
|
|
|
1551
1542
|
return this.get("textColor");
|
|
1552
1543
|
}
|
|
1553
1544
|
}
|
|
1554
|
-
const
|
|
1545
|
+
const hs = l(
|
|
1555
1546
|
"mainButton",
|
|
1556
1547
|
({
|
|
1557
1548
|
postEvent: e,
|
|
@@ -1564,47 +1555,47 @@ const cs = l(
|
|
|
1564
1555
|
textColor: t.buttonTextColor || "#ffffff",
|
|
1565
1556
|
bgColor: t.buttonColor || "#000000"
|
|
1566
1557
|
}
|
|
1567
|
-
}) => new
|
|
1558
|
+
}) => new cs({ ...s, postEvent: e })
|
|
1568
1559
|
);
|
|
1569
|
-
function
|
|
1570
|
-
return
|
|
1571
|
-
contact:
|
|
1560
|
+
function ps() {
|
|
1561
|
+
return ut({
|
|
1562
|
+
contact: v({
|
|
1572
1563
|
userId: {
|
|
1573
|
-
type:
|
|
1564
|
+
type: x(),
|
|
1574
1565
|
from: "user_id"
|
|
1575
1566
|
},
|
|
1576
1567
|
phoneNumber: {
|
|
1577
|
-
type:
|
|
1568
|
+
type: u(),
|
|
1578
1569
|
from: "phone_number"
|
|
1579
1570
|
},
|
|
1580
1571
|
firstName: {
|
|
1581
|
-
type:
|
|
1572
|
+
type: u(),
|
|
1582
1573
|
from: "first_name"
|
|
1583
1574
|
},
|
|
1584
1575
|
lastName: {
|
|
1585
|
-
type:
|
|
1576
|
+
type: u().optional(),
|
|
1586
1577
|
from: "last_name"
|
|
1587
1578
|
}
|
|
1588
1579
|
}),
|
|
1589
1580
|
authDate: {
|
|
1590
|
-
type:
|
|
1581
|
+
type: Lt(),
|
|
1591
1582
|
from: "auth_date"
|
|
1592
1583
|
},
|
|
1593
|
-
hash:
|
|
1584
|
+
hash: u()
|
|
1594
1585
|
}, "RequestedContact");
|
|
1595
1586
|
}
|
|
1596
|
-
function
|
|
1587
|
+
function Yt(e, t) {
|
|
1597
1588
|
return (s) => {
|
|
1598
1589
|
const [n, r] = t[s];
|
|
1599
1590
|
return C(n, r, e);
|
|
1600
1591
|
};
|
|
1601
1592
|
}
|
|
1602
|
-
function
|
|
1593
|
+
function us(e) {
|
|
1603
1594
|
return new Promise((t) => {
|
|
1604
1595
|
setTimeout(t, e);
|
|
1605
1596
|
});
|
|
1606
1597
|
}
|
|
1607
|
-
class
|
|
1598
|
+
class ls extends $ {
|
|
1608
1599
|
constructor({ postEvent: t, createRequestId: s, version: n, botInline: r, ...i }) {
|
|
1609
1600
|
super(i, n, {
|
|
1610
1601
|
requestPhoneAccess: "web_app_request_phone",
|
|
@@ -1614,7 +1605,7 @@ class us extends L {
|
|
|
1614
1605
|
setBackgroundColor: "web_app_set_background_color"
|
|
1615
1606
|
}), 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;
|
|
1616
1607
|
const o = this.supports.bind(this);
|
|
1617
|
-
this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam =
|
|
1608
|
+
this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Yt(n, {
|
|
1618
1609
|
"setHeaderColor.color": ["web_app_set_header_color", "color"]
|
|
1619
1610
|
});
|
|
1620
1611
|
}
|
|
@@ -1625,8 +1616,8 @@ class us extends L {
|
|
|
1625
1616
|
async getRequestedContact({
|
|
1626
1617
|
timeout: t = 1e4
|
|
1627
1618
|
} = {}) {
|
|
1628
|
-
return
|
|
1629
|
-
await
|
|
1619
|
+
return ps().parse(
|
|
1620
|
+
await q(
|
|
1630
1621
|
"getRequestedContact",
|
|
1631
1622
|
{},
|
|
1632
1623
|
this.createRequestId(),
|
|
@@ -1643,9 +1634,10 @@ class us extends L {
|
|
|
1643
1634
|
}
|
|
1644
1635
|
/**
|
|
1645
1636
|
* Closes the Mini App.
|
|
1637
|
+
* @param returnBack - should the application be wrapped into the bottom bar.
|
|
1646
1638
|
*/
|
|
1647
|
-
close() {
|
|
1648
|
-
this.postEvent("web_app_close");
|
|
1639
|
+
close(t) {
|
|
1640
|
+
this.postEvent("web_app_close", { return_back: t });
|
|
1649
1641
|
}
|
|
1650
1642
|
/**
|
|
1651
1643
|
* The Mini App header color.
|
|
@@ -1662,10 +1654,10 @@ class us extends L {
|
|
|
1662
1654
|
return this.botInline;
|
|
1663
1655
|
}
|
|
1664
1656
|
/**
|
|
1665
|
-
* True if current Mini App background color is recognized as dark.
|
|
1657
|
+
* True if the current Mini App background color is recognized as dark.
|
|
1666
1658
|
*/
|
|
1667
1659
|
get isDark() {
|
|
1668
|
-
return
|
|
1660
|
+
return Bt(this.bgColor);
|
|
1669
1661
|
}
|
|
1670
1662
|
/**
|
|
1671
1663
|
* Informs the Telegram app that the Mini App is ready to be displayed.
|
|
@@ -1694,15 +1686,15 @@ class us extends L {
|
|
|
1694
1686
|
throw new Error("Access denied.");
|
|
1695
1687
|
const s = Date.now() + t;
|
|
1696
1688
|
let n = 50;
|
|
1697
|
-
return
|
|
1689
|
+
return Dt(async () => {
|
|
1698
1690
|
for (; Date.now() < s; ) {
|
|
1699
1691
|
try {
|
|
1700
1692
|
return await this.getRequestedContact();
|
|
1701
1693
|
} catch {
|
|
1702
1694
|
}
|
|
1703
|
-
await
|
|
1695
|
+
await us(n), n += 50;
|
|
1704
1696
|
}
|
|
1705
|
-
throw
|
|
1697
|
+
throw Nt(t);
|
|
1706
1698
|
}, t);
|
|
1707
1699
|
}
|
|
1708
1700
|
/**
|
|
@@ -1785,7 +1777,7 @@ class us extends L {
|
|
|
1785
1777
|
this.postEvent("web_app_switch_inline_query", { query: t, chat_types: s });
|
|
1786
1778
|
}
|
|
1787
1779
|
}
|
|
1788
|
-
const
|
|
1780
|
+
const ds = l(
|
|
1789
1781
|
"miniApp",
|
|
1790
1782
|
({
|
|
1791
1783
|
themeParams: e,
|
|
@@ -1795,9 +1787,9 @@ const ls = l(
|
|
|
1795
1787
|
headerColor: e.headerBgColor || "#000000"
|
|
1796
1788
|
},
|
|
1797
1789
|
...n
|
|
1798
|
-
}) => new
|
|
1790
|
+
}) => new ls({ ...n, ...s, botInline: t })
|
|
1799
1791
|
);
|
|
1800
|
-
function
|
|
1792
|
+
function _s(e) {
|
|
1801
1793
|
const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
|
|
1802
1794
|
let r;
|
|
1803
1795
|
if (s.length > 64)
|
|
@@ -1813,15 +1805,15 @@ function ds(e) {
|
|
|
1813
1805
|
if (!i.type || i.type === "default" || i.type === "destructive") {
|
|
1814
1806
|
const a = i.text.trim();
|
|
1815
1807
|
if (!a.length || a.length > 64) {
|
|
1816
|
-
const
|
|
1817
|
-
throw new Error(`Button text with type "${
|
|
1808
|
+
const h = i.type || "default";
|
|
1809
|
+
throw new Error(`Button text with type "${h}" has incorrect size: ${i.text.length}`);
|
|
1818
1810
|
}
|
|
1819
1811
|
return { ...i, text: a, id: o };
|
|
1820
1812
|
}
|
|
1821
1813
|
return { ...i, id: o };
|
|
1822
1814
|
}) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
|
|
1823
1815
|
}
|
|
1824
|
-
class
|
|
1816
|
+
class gs extends $ {
|
|
1825
1817
|
constructor(t, s, n) {
|
|
1826
1818
|
super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
|
|
1827
1819
|
}
|
|
@@ -1854,7 +1846,7 @@ class _s extends L {
|
|
|
1854
1846
|
event: "popup_closed",
|
|
1855
1847
|
method: "web_app_open_popup",
|
|
1856
1848
|
postEvent: this.postEvent,
|
|
1857
|
-
params:
|
|
1849
|
+
params: _s(t)
|
|
1858
1850
|
});
|
|
1859
1851
|
return s;
|
|
1860
1852
|
} finally {
|
|
@@ -1863,9 +1855,9 @@ class _s extends L {
|
|
|
1863
1855
|
}
|
|
1864
1856
|
}
|
|
1865
1857
|
const ws = l(
|
|
1866
|
-
({ postEvent: e, version: t }) => new
|
|
1858
|
+
({ postEvent: e, version: t }) => new gs(!1, t, e)
|
|
1867
1859
|
);
|
|
1868
|
-
class
|
|
1860
|
+
class fs extends $ {
|
|
1869
1861
|
constructor(t, s, n) {
|
|
1870
1862
|
super({ isOpened: t }, s, {
|
|
1871
1863
|
close: "web_app_close_scan_qr_popup",
|
|
@@ -1909,10 +1901,10 @@ class gs extends L {
|
|
|
1909
1901
|
}
|
|
1910
1902
|
// TODO: Streaming mode, allowing to scan several QRs until closed.
|
|
1911
1903
|
}
|
|
1912
|
-
const
|
|
1913
|
-
({ version: e, postEvent: t }) => new
|
|
1904
|
+
const ms = l(
|
|
1905
|
+
({ version: e, postEvent: t }) => new fs(!1, e, t)
|
|
1914
1906
|
);
|
|
1915
|
-
class
|
|
1907
|
+
class bs extends pt {
|
|
1916
1908
|
constructor(t, s, n) {
|
|
1917
1909
|
super({ isVisible: t }, s, {
|
|
1918
1910
|
show: "web_app_setup_settings_button",
|
|
@@ -1941,18 +1933,18 @@ class ms extends ut {
|
|
|
1941
1933
|
this.isVisible = !0;
|
|
1942
1934
|
}
|
|
1943
1935
|
}
|
|
1944
|
-
const
|
|
1936
|
+
const vs = l(
|
|
1945
1937
|
"settingsButton",
|
|
1946
1938
|
({
|
|
1947
1939
|
version: e,
|
|
1948
1940
|
postEvent: t,
|
|
1949
1941
|
state: s = { isVisible: !1 }
|
|
1950
|
-
}) => new
|
|
1942
|
+
}) => new bs(s.isVisible, e, t)
|
|
1951
1943
|
);
|
|
1952
|
-
function
|
|
1953
|
-
return
|
|
1944
|
+
function Zt(e) {
|
|
1945
|
+
return Ht().parse(e);
|
|
1954
1946
|
}
|
|
1955
|
-
class
|
|
1947
|
+
class ys extends dt {
|
|
1956
1948
|
/**
|
|
1957
1949
|
* @since v6.10
|
|
1958
1950
|
*/
|
|
@@ -1991,7 +1983,7 @@ class vs extends _t {
|
|
|
1991
1983
|
* value is calculated according to theme bg color.
|
|
1992
1984
|
*/
|
|
1993
1985
|
get isDark() {
|
|
1994
|
-
return !this.bgColor ||
|
|
1986
|
+
return !this.bgColor || Bt(this.bgColor);
|
|
1995
1987
|
}
|
|
1996
1988
|
get linkColor() {
|
|
1997
1989
|
return this.get("linkColor");
|
|
@@ -2023,7 +2015,7 @@ class vs extends _t {
|
|
|
2023
2015
|
*/
|
|
2024
2016
|
listen() {
|
|
2025
2017
|
return y("theme_changed", (t) => {
|
|
2026
|
-
this.set(
|
|
2018
|
+
this.set(Zt(t.theme_params));
|
|
2027
2019
|
});
|
|
2028
2020
|
}
|
|
2029
2021
|
/**
|
|
@@ -2036,44 +2028,46 @@ class vs extends _t {
|
|
|
2036
2028
|
return this.get("textColor");
|
|
2037
2029
|
}
|
|
2038
2030
|
}
|
|
2039
|
-
const
|
|
2031
|
+
const Es = l(
|
|
2040
2032
|
"themeParams",
|
|
2041
2033
|
({ themeParams: e, state: t = e, addCleanup: s }) => {
|
|
2042
|
-
const n = new
|
|
2034
|
+
const n = new ys(t);
|
|
2043
2035
|
return s(n.listen()), n;
|
|
2044
2036
|
}
|
|
2045
2037
|
);
|
|
2046
|
-
function
|
|
2038
|
+
function bn(e = {}) {
|
|
2047
2039
|
return g({
|
|
2048
2040
|
...e,
|
|
2049
2041
|
method: "web_app_request_theme",
|
|
2050
2042
|
event: "theme_changed"
|
|
2051
|
-
}).then(
|
|
2043
|
+
}).then(Zt);
|
|
2044
|
+
}
|
|
2045
|
+
function B(e, t) {
|
|
2046
|
+
return e.startsWith(t) ? e : `${t}${e}`;
|
|
2047
|
+
}
|
|
2048
|
+
function M(e) {
|
|
2049
|
+
return new URL(
|
|
2050
|
+
typeof e == "string" ? e : `${e.pathname || ""}${B(e.search || "", "?")}${B(e.hash || "", "#")}`,
|
|
2051
|
+
"http://a"
|
|
2052
|
+
);
|
|
2052
2053
|
}
|
|
2053
|
-
class
|
|
2054
|
+
class Ps extends _t {
|
|
2054
2055
|
constructor(t, s, n) {
|
|
2055
|
-
super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam =
|
|
2056
|
+
super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Yt(t, {
|
|
2056
2057
|
"openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
|
|
2057
2058
|
});
|
|
2058
2059
|
}
|
|
2059
|
-
/**
|
|
2060
|
-
* Opens a link in an external browser. The Mini App will not be closed.
|
|
2061
|
-
*
|
|
2062
|
-
* Note that this method can be called only in response to the user
|
|
2063
|
-
* interaction with the Mini App interface (e.g. click inside the Mini App
|
|
2064
|
-
* or on the main button).
|
|
2065
|
-
* @param url - URL to be opened.
|
|
2066
|
-
* @param tryInstantView
|
|
2067
|
-
*/
|
|
2068
2060
|
openLink(t, s) {
|
|
2069
|
-
const n =
|
|
2061
|
+
const n = M(t).toString();
|
|
2070
2062
|
if (!C("web_app_open_link", this.version)) {
|
|
2071
2063
|
window.open(n, "_blank");
|
|
2072
2064
|
return;
|
|
2073
2065
|
}
|
|
2066
|
+
const r = typeof s == "boolean" ? { tryInstantView: s } : s || {};
|
|
2074
2067
|
this.postEvent("web_app_open_link", {
|
|
2075
2068
|
url: n,
|
|
2076
|
-
|
|
2069
|
+
try_browser: r.tryBrowser,
|
|
2070
|
+
try_instant_view: r.tryInstantView
|
|
2077
2071
|
});
|
|
2078
2072
|
}
|
|
2079
2073
|
/**
|
|
@@ -2106,7 +2100,7 @@ class Es extends wt {
|
|
|
2106
2100
|
event: "clipboard_text_received",
|
|
2107
2101
|
postEvent: this.postEvent,
|
|
2108
2102
|
params: { req_id: t },
|
|
2109
|
-
capture:
|
|
2103
|
+
capture: qt(t)
|
|
2110
2104
|
});
|
|
2111
2105
|
return s;
|
|
2112
2106
|
}
|
|
@@ -2122,14 +2116,14 @@ class Es extends wt {
|
|
|
2122
2116
|
*/
|
|
2123
2117
|
shareURL(t, s) {
|
|
2124
2118
|
this.openTelegramLink(
|
|
2125
|
-
"https://t.me/share/url?" + new URLSearchParams({ url: t, text: s || "" }).toString()
|
|
2119
|
+
"https://t.me/share/url?" + new URLSearchParams({ url: t, text: s || "" }).toString().replace(/\+/g, "%20")
|
|
2126
2120
|
);
|
|
2127
2121
|
}
|
|
2128
2122
|
}
|
|
2129
|
-
const
|
|
2130
|
-
({ version: e, postEvent: t, createRequestId: s }) => new
|
|
2123
|
+
const Rs = l(
|
|
2124
|
+
({ version: e, postEvent: t, createRequestId: s }) => new Ps(e, s, t)
|
|
2131
2125
|
);
|
|
2132
|
-
async function
|
|
2126
|
+
async function Xt(e = {}) {
|
|
2133
2127
|
const {
|
|
2134
2128
|
is_expanded: t,
|
|
2135
2129
|
is_state_stable: s,
|
|
@@ -2141,16 +2135,16 @@ async function te(e = {}) {
|
|
|
2141
2135
|
});
|
|
2142
2136
|
return { ...n, isExpanded: t, isStateStable: s };
|
|
2143
2137
|
}
|
|
2144
|
-
function
|
|
2138
|
+
function O(e) {
|
|
2145
2139
|
return e < 0 ? 0 : e;
|
|
2146
2140
|
}
|
|
2147
|
-
class xs extends
|
|
2141
|
+
class xs extends dt {
|
|
2148
2142
|
constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
|
|
2149
2143
|
super({
|
|
2150
|
-
height:
|
|
2144
|
+
height: O(n),
|
|
2151
2145
|
isExpanded: i,
|
|
2152
|
-
stableHeight:
|
|
2153
|
-
width:
|
|
2146
|
+
stableHeight: O(s),
|
|
2147
|
+
width: O(r)
|
|
2154
2148
|
}), c(this, "postEvent"), this.postEvent = t;
|
|
2155
2149
|
}
|
|
2156
2150
|
/**
|
|
@@ -2159,7 +2153,7 @@ class xs extends _t {
|
|
|
2159
2153
|
* @param options - options to request fresh data.
|
|
2160
2154
|
*/
|
|
2161
2155
|
async sync(t) {
|
|
2162
|
-
const { isStateStable: s, ...n } = await
|
|
2156
|
+
const { isStateStable: s, ...n } = await Xt(t);
|
|
2163
2157
|
this.set({
|
|
2164
2158
|
...n,
|
|
2165
2159
|
stableHeight: s ? n.height : this.get("stableHeight")
|
|
@@ -2212,11 +2206,11 @@ class xs extends _t {
|
|
|
2212
2206
|
width: n,
|
|
2213
2207
|
is_expanded: r,
|
|
2214
2208
|
is_state_stable: i
|
|
2215
|
-
} = t, o =
|
|
2209
|
+
} = t, o = O(s);
|
|
2216
2210
|
this.set({
|
|
2217
2211
|
height: o,
|
|
2218
2212
|
isExpanded: r,
|
|
2219
|
-
width:
|
|
2213
|
+
width: O(n),
|
|
2220
2214
|
...i ? { stableHeight: o } : {}
|
|
2221
2215
|
});
|
|
2222
2216
|
});
|
|
@@ -2251,7 +2245,7 @@ class xs extends _t {
|
|
|
2251
2245
|
return this.stableHeight === this.height;
|
|
2252
2246
|
}
|
|
2253
2247
|
}
|
|
2254
|
-
const
|
|
2248
|
+
const Cs = l(
|
|
2255
2249
|
"viewport",
|
|
2256
2250
|
async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
|
|
2257
2251
|
let r = !1, i = 0, o = 0, a = 0;
|
|
@@ -2260,31 +2254,31 @@ const Rs = l(
|
|
|
2260
2254
|
else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
|
|
2261
2255
|
r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
|
|
2262
2256
|
else {
|
|
2263
|
-
const
|
|
2264
|
-
r =
|
|
2257
|
+
const p = await Xt({ timeout: 1e3, postEvent: s });
|
|
2258
|
+
r = p.isExpanded, i = p.height, o = p.width, a = p.isStateStable ? i : 0;
|
|
2265
2259
|
}
|
|
2266
|
-
const
|
|
2260
|
+
const h = new xs({
|
|
2267
2261
|
postEvent: s,
|
|
2268
2262
|
height: i,
|
|
2269
2263
|
width: o,
|
|
2270
2264
|
stableHeight: a,
|
|
2271
2265
|
isExpanded: r
|
|
2272
2266
|
});
|
|
2273
|
-
return n(
|
|
2267
|
+
return n(h.listen()), h;
|
|
2274
2268
|
}
|
|
2275
2269
|
);
|
|
2276
2270
|
function P(e, t) {
|
|
2277
2271
|
document.documentElement.style.setProperty(e, t);
|
|
2278
2272
|
}
|
|
2279
|
-
function
|
|
2273
|
+
function vn(e, t, s) {
|
|
2280
2274
|
s || (s = (a) => `--tg-${a}-color`);
|
|
2281
2275
|
const n = s("header"), r = s("bg"), i = () => {
|
|
2282
2276
|
const { headerColor: a } = e;
|
|
2283
2277
|
if (ct(a))
|
|
2284
2278
|
P(n, a);
|
|
2285
2279
|
else {
|
|
2286
|
-
const { bgColor:
|
|
2287
|
-
a === "bg_color" &&
|
|
2280
|
+
const { bgColor: h, secondaryBgColor: p } = t;
|
|
2281
|
+
a === "bg_color" && h ? P(n, h) : a === "secondary_bg_color" && p && P(n, p);
|
|
2288
2282
|
}
|
|
2289
2283
|
P(r, e.bgColor);
|
|
2290
2284
|
}, o = [
|
|
@@ -2293,7 +2287,7 @@ function bn(e, t, s) {
|
|
|
2293
2287
|
];
|
|
2294
2288
|
return i(), () => o.forEach((a) => a());
|
|
2295
2289
|
}
|
|
2296
|
-
function
|
|
2290
|
+
function yn(e, t) {
|
|
2297
2291
|
t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
|
|
2298
2292
|
const s = () => {
|
|
2299
2293
|
Object.entries(e.getState()).forEach(([n, r]) => {
|
|
@@ -2302,23 +2296,23 @@ function vn(e, t) {
|
|
|
2302
2296
|
};
|
|
2303
2297
|
return s(), e.on("change", s);
|
|
2304
2298
|
}
|
|
2305
|
-
function
|
|
2306
|
-
t || (t = (
|
|
2299
|
+
function En(e, t) {
|
|
2300
|
+
t || (t = (p) => `--tg-viewport-${p}`);
|
|
2307
2301
|
const [
|
|
2308
2302
|
s,
|
|
2309
2303
|
n,
|
|
2310
2304
|
r
|
|
2311
|
-
] = ["height", "width", "stable-height"].map((
|
|
2305
|
+
] = ["height", "width", "stable-height"].map((p) => t(p)), i = () => P(s, `${e.height}px`), o = () => P(n, `${e.width}px`), a = () => P(r, `${e.stableHeight}px`), h = [
|
|
2312
2306
|
e.on("change:height", i),
|
|
2313
2307
|
e.on("change:width", o),
|
|
2314
2308
|
e.on("change:stableHeight", a)
|
|
2315
2309
|
];
|
|
2316
|
-
return i(), o(), a(), () =>
|
|
2310
|
+
return i(), o(), a(), () => h.forEach((p) => p());
|
|
2317
2311
|
}
|
|
2318
|
-
function
|
|
2312
|
+
function Ss(e = !0) {
|
|
2319
2313
|
const t = [
|
|
2320
2314
|
y("reload_iframe", () => {
|
|
2321
|
-
|
|
2315
|
+
V("iframe_will_reload"), window.location.reload();
|
|
2322
2316
|
})
|
|
2323
2317
|
], s = () => t.forEach((n) => n());
|
|
2324
2318
|
if (e) {
|
|
@@ -2330,13 +2324,13 @@ function Cs(e = !0) {
|
|
|
2330
2324
|
() => document.head.removeChild(n)
|
|
2331
2325
|
);
|
|
2332
2326
|
}
|
|
2333
|
-
return
|
|
2327
|
+
return V("iframe_ready", { reload_supported: !0 }), s;
|
|
2334
2328
|
}
|
|
2335
|
-
function
|
|
2329
|
+
function Ts() {
|
|
2336
2330
|
return typeof window > "u";
|
|
2337
2331
|
}
|
|
2338
|
-
async function
|
|
2339
|
-
if (
|
|
2332
|
+
async function Pn() {
|
|
2333
|
+
if (kt(window))
|
|
2340
2334
|
return !0;
|
|
2341
2335
|
try {
|
|
2342
2336
|
return await g({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
|
|
@@ -2344,15 +2338,15 @@ async function En() {
|
|
|
2344
2338
|
return !1;
|
|
2345
2339
|
}
|
|
2346
2340
|
}
|
|
2347
|
-
function
|
|
2348
|
-
const t = typeof e == "string" ?
|
|
2349
|
-
|
|
2341
|
+
function Rn(e) {
|
|
2342
|
+
const t = typeof e == "string" ? lt(e) : e;
|
|
2343
|
+
Jt(t);
|
|
2350
2344
|
function s(r) {
|
|
2351
2345
|
if (typeof r == "string")
|
|
2352
2346
|
try {
|
|
2353
|
-
const { eventType: i } =
|
|
2347
|
+
const { eventType: i } = At(r);
|
|
2354
2348
|
i === "web_app_request_theme" && et("theme_changed", {
|
|
2355
|
-
theme_params: JSON.parse(
|
|
2349
|
+
theme_params: JSON.parse(Kt(t.themeParams))
|
|
2356
2350
|
}), i === "web_app_request_viewport" && et("viewport_changed", {
|
|
2357
2351
|
width: window.innerWidth,
|
|
2358
2352
|
height: window.innerHeight,
|
|
@@ -2362,14 +2356,14 @@ function Pn(e) {
|
|
|
2362
2356
|
} catch {
|
|
2363
2357
|
}
|
|
2364
2358
|
}
|
|
2365
|
-
if (
|
|
2359
|
+
if (at()) {
|
|
2366
2360
|
const r = window.parent.postMessage.bind(window.parent);
|
|
2367
2361
|
window.parent.postMessage = (i) => {
|
|
2368
2362
|
s(i), r(i);
|
|
2369
2363
|
};
|
|
2370
2364
|
return;
|
|
2371
2365
|
}
|
|
2372
|
-
if (
|
|
2366
|
+
if (It(window)) {
|
|
2373
2367
|
const r = window.external.notify.bind(window.external);
|
|
2374
2368
|
window.external.notify = (i) => {
|
|
2375
2369
|
s(i), r(i);
|
|
@@ -2384,11 +2378,11 @@ function Pn(e) {
|
|
|
2384
2378
|
}
|
|
2385
2379
|
};
|
|
2386
2380
|
}
|
|
2387
|
-
function
|
|
2381
|
+
function As(e) {
|
|
2388
2382
|
return e instanceof W;
|
|
2389
2383
|
}
|
|
2390
2384
|
function xn(e, t) {
|
|
2391
|
-
return
|
|
2385
|
+
return As(e) && e.type === t;
|
|
2392
2386
|
}
|
|
2393
2387
|
function J(e, t) {
|
|
2394
2388
|
let s, n, r;
|
|
@@ -2398,13 +2392,13 @@ function J(e, t) {
|
|
|
2398
2392
|
params: n
|
|
2399
2393
|
});
|
|
2400
2394
|
}
|
|
2401
|
-
class
|
|
2402
|
-
constructor(t, s, n =
|
|
2395
|
+
class Is {
|
|
2396
|
+
constructor(t, s, n = V) {
|
|
2403
2397
|
if (c(this, "history"), c(this, "ee", new D()), 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)
|
|
2404
|
-
throw
|
|
2398
|
+
throw m(be, "History should not be empty.");
|
|
2405
2399
|
if (s < 0 || s >= t.length)
|
|
2406
|
-
throw
|
|
2407
|
-
|
|
2400
|
+
throw m(
|
|
2401
|
+
ve,
|
|
2408
2402
|
"Index should not be zero and higher or equal than history size."
|
|
2409
2403
|
);
|
|
2410
2404
|
this.history = t.map((r) => J(r, ""));
|
|
@@ -2525,23 +2519,14 @@ function F({
|
|
|
2525
2519
|
}) {
|
|
2526
2520
|
return { ...e || { hash: "", search: "" }, ...t };
|
|
2527
2521
|
}
|
|
2528
|
-
function M(e, t) {
|
|
2529
|
-
return e.startsWith(t) ? e : `${t}${e}`;
|
|
2530
|
-
}
|
|
2531
|
-
function H(e) {
|
|
2532
|
-
return new URL(
|
|
2533
|
-
typeof e == "string" ? e : `${e.pathname || ""}${M(e.search || "", "?")}${M(e.hash || "", "#")}`,
|
|
2534
|
-
"http://a"
|
|
2535
|
-
);
|
|
2536
|
-
}
|
|
2537
2522
|
function U(e) {
|
|
2538
|
-
const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s =
|
|
2523
|
+
const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = M(e);
|
|
2539
2524
|
return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
|
|
2540
2525
|
}
|
|
2541
2526
|
function Q(e, t, s) {
|
|
2542
2527
|
let n, r;
|
|
2543
2528
|
typeof e == "string" ? n = e : (n = U(e), s = e.state, r = e.id);
|
|
2544
|
-
const { pathname: i, search: o, hash: a } = new URL(n, `http://a${
|
|
2529
|
+
const { pathname: i, search: o, hash: a } = new URL(n, `http://a${B(t, "/")}`);
|
|
2545
2530
|
return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
|
|
2546
2531
|
}
|
|
2547
2532
|
async function N(e) {
|
|
@@ -2558,41 +2543,41 @@ async function N(e) {
|
|
|
2558
2543
|
})
|
|
2559
2544
|
]);
|
|
2560
2545
|
}
|
|
2561
|
-
async function
|
|
2546
|
+
async function ks() {
|
|
2562
2547
|
if (window.history.length <= 1 || (window.history.pushState(null, ""), await N(1 - window.history.length)))
|
|
2563
2548
|
return;
|
|
2564
2549
|
let e = await N(-1);
|
|
2565
2550
|
for (; e; )
|
|
2566
2551
|
e = await N(-1);
|
|
2567
2552
|
}
|
|
2568
|
-
function
|
|
2569
|
-
return
|
|
2553
|
+
function te(e) {
|
|
2554
|
+
return M(e).pathname;
|
|
2570
2555
|
}
|
|
2571
|
-
const
|
|
2572
|
-
class
|
|
2556
|
+
const Et = 0, Y = 1, Z = 2;
|
|
2557
|
+
class ee {
|
|
2573
2558
|
constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
|
|
2574
2559
|
c(this, "navigator"), c(this, "ee", new D()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
|
|
2575
2560
|
if (o === null)
|
|
2576
2561
|
return this.push(this.parsePath(window.location.href));
|
|
2577
|
-
o ===
|
|
2562
|
+
o === Et ? window.history.forward() : o === Y && this.back(), o === Z && this.forward();
|
|
2578
2563
|
}), c(this, "onNavigatorChange", async ({
|
|
2579
2564
|
to: o,
|
|
2580
2565
|
from: a,
|
|
2581
|
-
delta:
|
|
2566
|
+
delta: h
|
|
2582
2567
|
}) => {
|
|
2583
2568
|
this.attached && await this.syncHistory(), this.ee.emit("change", {
|
|
2584
|
-
delta:
|
|
2569
|
+
delta: h,
|
|
2585
2570
|
from: F(a),
|
|
2586
2571
|
to: F(o),
|
|
2587
2572
|
navigator: this
|
|
2588
2573
|
});
|
|
2589
|
-
}), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new
|
|
2574
|
+
}), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new Is(
|
|
2590
2575
|
t.map((o) => Q(o, "/")),
|
|
2591
2576
|
s,
|
|
2592
2577
|
n
|
|
2593
2578
|
), this.navigator.on("change", (o) => {
|
|
2594
2579
|
this.onNavigatorChange(o);
|
|
2595
|
-
}), this.hashMode = r, this.base =
|
|
2580
|
+
}), this.hashMode = r, this.base = te(i || "");
|
|
2596
2581
|
}
|
|
2597
2582
|
/**
|
|
2598
2583
|
* Attaches current navigator to the browser history allowing navigator to manipulate it.
|
|
@@ -2719,8 +2704,8 @@ class se {
|
|
|
2719
2704
|
* // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
|
|
2720
2705
|
*/
|
|
2721
2706
|
parsePath(t) {
|
|
2722
|
-
let s =
|
|
2723
|
-
return this.hashMode && (s =
|
|
2707
|
+
let s = M(t);
|
|
2708
|
+
return this.hashMode && (s = M(s.hash.slice(1))), {
|
|
2724
2709
|
pathname: s.pathname,
|
|
2725
2710
|
search: s.search,
|
|
2726
2711
|
hash: s.hash
|
|
@@ -2740,8 +2725,8 @@ class se {
|
|
|
2740
2725
|
* @param value - path presented as string or URLLike.
|
|
2741
2726
|
*/
|
|
2742
2727
|
renderPath(t) {
|
|
2743
|
-
const s = (this.base.length === 1 ? "" : this.base) +
|
|
2744
|
-
return this.hashMode ?
|
|
2728
|
+
const s = (this.base.length === 1 ? "" : this.base) + B(U(t), "/");
|
|
2729
|
+
return this.hashMode ? B(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
|
|
2745
2730
|
}
|
|
2746
2731
|
/**
|
|
2747
2732
|
* Synchronizes current navigator state with browser history.
|
|
@@ -2749,7 +2734,7 @@ class se {
|
|
|
2749
2734
|
async syncHistory() {
|
|
2750
2735
|
window.removeEventListener("popstate", this.onPopState);
|
|
2751
2736
|
const { state: t } = this, s = this.renderPath(this);
|
|
2752
|
-
await
|
|
2737
|
+
await ks(), this.hasPrev && this.hasNext ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s), window.history.pushState(Z, ""), await N(-1)) : this.hasPrev ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(Z, ""), await N(-1)) : (window.history.replaceState(Et, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
|
|
2753
2738
|
}
|
|
2754
2739
|
/**
|
|
2755
2740
|
* Current query parameters.
|
|
@@ -2767,34 +2752,34 @@ class se {
|
|
|
2767
2752
|
return (this.navigator.current.params || {}).state;
|
|
2768
2753
|
}
|
|
2769
2754
|
}
|
|
2770
|
-
function
|
|
2755
|
+
function Os(e) {
|
|
2771
2756
|
e || (e = {});
|
|
2772
2757
|
const { href: t, hash: s } = window.location;
|
|
2773
2758
|
let n = U(
|
|
2774
2759
|
e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
|
|
2775
2760
|
);
|
|
2776
|
-
const r = e.base ?
|
|
2761
|
+
const r = e.base ? te(e.base) : void 0;
|
|
2777
2762
|
if (r) {
|
|
2778
2763
|
if (!n.startsWith(r))
|
|
2779
|
-
throw
|
|
2780
|
-
|
|
2764
|
+
throw m(
|
|
2765
|
+
ye,
|
|
2781
2766
|
`Path "${n}" expected to be starting with "${r}"`
|
|
2782
2767
|
);
|
|
2783
2768
|
n = n.slice(r.length);
|
|
2784
2769
|
}
|
|
2785
|
-
return new
|
|
2770
|
+
return new ee([n], 0, e);
|
|
2786
2771
|
}
|
|
2787
|
-
function
|
|
2772
|
+
function Cn(e) {
|
|
2788
2773
|
const t = e.match(/#(.+)/);
|
|
2789
2774
|
return t ? t[1] : null;
|
|
2790
2775
|
}
|
|
2791
2776
|
function qs(e, t) {
|
|
2792
|
-
if (
|
|
2777
|
+
if (Ft()) {
|
|
2793
2778
|
const s = sessionStorage.getItem(e);
|
|
2794
2779
|
if (s)
|
|
2795
2780
|
try {
|
|
2796
2781
|
const { index: n, history: r } = JSON.parse(s);
|
|
2797
|
-
return new
|
|
2782
|
+
return new ee(
|
|
2798
2783
|
r,
|
|
2799
2784
|
n,
|
|
2800
2785
|
t
|
|
@@ -2803,9 +2788,9 @@ function qs(e, t) {
|
|
|
2803
2788
|
console.error("Unable to restore hash navigator state.", n);
|
|
2804
2789
|
}
|
|
2805
2790
|
}
|
|
2806
|
-
return
|
|
2791
|
+
return Os(t);
|
|
2807
2792
|
}
|
|
2808
|
-
function
|
|
2793
|
+
function Sn(e, t) {
|
|
2809
2794
|
const s = qs(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
|
|
2810
2795
|
index: s.index,
|
|
2811
2796
|
history: s.history
|
|
@@ -2815,34 +2800,34 @@ function Cn(e, t) {
|
|
|
2815
2800
|
function d(e, t) {
|
|
2816
2801
|
function s(n) {
|
|
2817
2802
|
return function(i, o, a) {
|
|
2818
|
-
return (
|
|
2819
|
-
const
|
|
2820
|
-
...
|
|
2803
|
+
return (h) => {
|
|
2804
|
+
const p = {
|
|
2805
|
+
...h,
|
|
2821
2806
|
[i]: n(o)
|
|
2822
2807
|
};
|
|
2823
|
-
return /* @__PURE__ */
|
|
2808
|
+
return /* @__PURE__ */ Pt(a, { ...p });
|
|
2824
2809
|
};
|
|
2825
2810
|
};
|
|
2826
2811
|
}
|
|
2827
2812
|
return [s(e), s(t)];
|
|
2828
2813
|
}
|
|
2829
|
-
const
|
|
2830
|
-
function
|
|
2831
|
-
const e =
|
|
2814
|
+
const se = ne(void 0);
|
|
2815
|
+
function Ns() {
|
|
2816
|
+
const e = re(se);
|
|
2832
2817
|
if (!e)
|
|
2833
2818
|
throw new Error("useSDK was used outside the SDKProvider.");
|
|
2834
2819
|
return e;
|
|
2835
2820
|
}
|
|
2836
2821
|
function _(e) {
|
|
2837
2822
|
function t(n) {
|
|
2838
|
-
const r =
|
|
2823
|
+
const r = Ns(), [i, o] = rt(
|
|
2839
2824
|
n ? void 0 : () => {
|
|
2840
|
-
if (
|
|
2825
|
+
if (Ts())
|
|
2841
2826
|
throw new Error("Using hooks on the server side, you must explicitly specify ssr = true option");
|
|
2842
2827
|
return r.use(e);
|
|
2843
2828
|
}
|
|
2844
2829
|
);
|
|
2845
|
-
return
|
|
2830
|
+
return R(() => {
|
|
2846
2831
|
o(r.use(e));
|
|
2847
2832
|
}, [r]), i;
|
|
2848
2833
|
}
|
|
@@ -2856,252 +2841,252 @@ function _(e) {
|
|
|
2856
2841
|
}
|
|
2857
2842
|
return [t, s];
|
|
2858
2843
|
}
|
|
2859
|
-
const [
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
), [Bs, Ms] = _(
|
|
2844
|
+
const [Ds, Vs] = _(je), [Tn, An] = d(
|
|
2845
|
+
Ds,
|
|
2846
|
+
Vs
|
|
2847
|
+
), [Bs, Ms] = _(Je), [In, kn] = d(
|
|
2863
2848
|
Bs,
|
|
2864
2849
|
Ms
|
|
2865
|
-
), [
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
), [
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
), [
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
), [
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
), [
|
|
2878
|
-
function
|
|
2850
|
+
), [Ls, $s] = _(Qe), [On, qn] = d(
|
|
2851
|
+
Ls,
|
|
2852
|
+
$s
|
|
2853
|
+
), [Hs, Us] = _(es), [Nn, Dn] = d(
|
|
2854
|
+
Hs,
|
|
2855
|
+
Us
|
|
2856
|
+
), [Ws, Gs] = _(ns), [Vn, Bn] = d(
|
|
2857
|
+
Ws,
|
|
2858
|
+
Gs
|
|
2859
|
+
), [js, zs] = _(is), [Mn, Ln] = d(js, zs), [Ks, Js] = _(as), [$n, Hn] = d(Ks, Js), [Fs, Qs] = _(hs), [Un, Wn] = d(Fs, Qs), [Ys, Zs] = _(ds), [Gn, jn] = d(Ys, Zs), [Xs, tn] = _(ws), [zn, Kn] = d(Xs, tn), [en, sn] = _(ms), [Jn, Fn] = d(en, sn), [nn, rn] = _(vs), [Qn, Yn] = d(
|
|
2860
|
+
nn,
|
|
2861
|
+
rn
|
|
2862
|
+
), [on, an] = _(Es), [Zn, Xn] = d(on, an);
|
|
2863
|
+
function tr(e) {
|
|
2879
2864
|
const [t, s] = rt(() => e ? void 0 : nt());
|
|
2880
|
-
return
|
|
2865
|
+
return R(() => {
|
|
2881
2866
|
e && s(nt());
|
|
2882
2867
|
}, []), t;
|
|
2883
2868
|
}
|
|
2884
|
-
const [
|
|
2885
|
-
function
|
|
2886
|
-
const n =
|
|
2887
|
-
(
|
|
2888
|
-
n.current && i((S) => (
|
|
2869
|
+
const [cn, hn] = _(Rs), [er, sr] = d(cn, hn), [pn, un] = _(Cs), [nr, rr] = d(pn, un);
|
|
2870
|
+
function ir({ children: e, acceptCustomStyles: t, debug: s }) {
|
|
2871
|
+
const n = mt(!0), [r, i] = rt(/* @__PURE__ */ new Map()), o = mt(r), a = ie(
|
|
2872
|
+
(p) => {
|
|
2873
|
+
n.current && i((S) => (p && p(S), new Map(S)));
|
|
2889
2874
|
},
|
|
2890
2875
|
[]
|
|
2891
|
-
),
|
|
2892
|
-
use(
|
|
2893
|
-
const gt = r.get(
|
|
2876
|
+
), h = oe(() => ({
|
|
2877
|
+
use(p, ...S) {
|
|
2878
|
+
const gt = r.get(p);
|
|
2894
2879
|
if (gt)
|
|
2895
2880
|
return gt;
|
|
2896
|
-
let
|
|
2881
|
+
let b, K;
|
|
2897
2882
|
try {
|
|
2898
|
-
|
|
2899
|
-
} catch (
|
|
2900
|
-
K =
|
|
2883
|
+
b = p(...S);
|
|
2884
|
+
} catch (w) {
|
|
2885
|
+
K = w;
|
|
2901
2886
|
}
|
|
2902
|
-
function
|
|
2903
|
-
return r.set(
|
|
2887
|
+
function H(w) {
|
|
2888
|
+
return r.set(p, w), w;
|
|
2904
2889
|
}
|
|
2905
2890
|
if (K)
|
|
2906
|
-
return
|
|
2891
|
+
return H({ error: K });
|
|
2907
2892
|
let I;
|
|
2908
|
-
if (Array.isArray(
|
|
2909
|
-
return
|
|
2910
|
-
function
|
|
2911
|
-
if ("on" in
|
|
2912
|
-
const k =
|
|
2893
|
+
if (Array.isArray(b) && (I = b[1], b = b[0]), !b)
|
|
2894
|
+
return H({ result: b, cleanup: I });
|
|
2895
|
+
function wt(w) {
|
|
2896
|
+
if ("on" in w) {
|
|
2897
|
+
const k = w.on("change", () => a()), ft = I;
|
|
2913
2898
|
I = () => {
|
|
2914
|
-
|
|
2899
|
+
ft && ft(), k();
|
|
2915
2900
|
};
|
|
2916
2901
|
}
|
|
2917
|
-
return { result:
|
|
2902
|
+
return { result: w, cleanup: I };
|
|
2918
2903
|
}
|
|
2919
|
-
return
|
|
2920
|
-
(
|
|
2921
|
-
(
|
|
2922
|
-
),
|
|
2904
|
+
return b instanceof Promise ? (b.then(
|
|
2905
|
+
(w) => a((k) => k.set(p, wt(w))),
|
|
2906
|
+
(w) => a((k) => k.set(p, { error: w }))
|
|
2907
|
+
), H({})) : H(wt(b));
|
|
2923
2908
|
}
|
|
2924
2909
|
}), [r]);
|
|
2925
|
-
return
|
|
2910
|
+
return R(() => (n.current = !0, () => {
|
|
2926
2911
|
n.current = !1;
|
|
2927
|
-
}), []),
|
|
2928
|
-
if (
|
|
2929
|
-
return
|
|
2930
|
-
}, [t]),
|
|
2931
|
-
|
|
2932
|
-
}, [s]),
|
|
2912
|
+
}), []), R(() => {
|
|
2913
|
+
if (at())
|
|
2914
|
+
return Ss(t);
|
|
2915
|
+
}, [t]), R(() => {
|
|
2916
|
+
ue(s || !1);
|
|
2917
|
+
}, [s]), R(() => {
|
|
2933
2918
|
o.current = r;
|
|
2934
|
-
}, [r]),
|
|
2935
|
-
o.current.forEach((
|
|
2936
|
-
"cleanup" in
|
|
2919
|
+
}, [r]), R(() => () => {
|
|
2920
|
+
o.current.forEach((p) => {
|
|
2921
|
+
"cleanup" in p && p.cleanup && p.cleanup();
|
|
2937
2922
|
});
|
|
2938
|
-
}, []), /* @__PURE__ */
|
|
2923
|
+
}, []), /* @__PURE__ */ Pt(se.Provider, { value: h, children: e });
|
|
2939
2924
|
}
|
|
2940
2925
|
export {
|
|
2941
2926
|
Ne as BackButton,
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2927
|
+
Is as BasicNavigator,
|
|
2928
|
+
ze as BiometryManager,
|
|
2929
|
+
ee as BrowserNavigator,
|
|
2930
|
+
Fe as ClosingBehavior,
|
|
2931
|
+
ts as CloudStorage,
|
|
2932
|
+
ye as ERR_INVALID_PATH_BASE,
|
|
2933
|
+
we as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
|
|
2934
|
+
_e as ERR_METHOD_PARAMETER_UNSUPPORTED,
|
|
2935
|
+
de as ERR_METHOD_UNSUPPORTED,
|
|
2936
|
+
be as ERR_NAVIGATION_HISTORY_EMPTY,
|
|
2937
|
+
ve as ERR_NAVIGATION_INDEX_INVALID,
|
|
2938
|
+
_n as ERR_NAVIGATION_ITEM_INVALID,
|
|
2939
|
+
Ct as ERR_PARSE,
|
|
2940
|
+
gn as ERR_SSR_INIT,
|
|
2941
|
+
fe as ERR_TIMED_OUT,
|
|
2942
|
+
me as ERR_UNEXPECTED_TYPE,
|
|
2958
2943
|
ge as ERR_UNKNOWN_ENV,
|
|
2959
2944
|
D as EventEmitter,
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2945
|
+
ss as HapticFeedback,
|
|
2946
|
+
rs as InitData,
|
|
2947
|
+
os as Invoice,
|
|
2948
|
+
cs as MainButton,
|
|
2949
|
+
ls as MiniApp,
|
|
2950
|
+
gs as Popup,
|
|
2951
|
+
fs as QRScanner,
|
|
2967
2952
|
W as SDKError,
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2953
|
+
ir as SDKProvider,
|
|
2954
|
+
bs as SettingsButton,
|
|
2955
|
+
ys as ThemeParams,
|
|
2956
|
+
Ps as Utils,
|
|
2972
2957
|
xs as Viewport,
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2958
|
+
Xe as array,
|
|
2959
|
+
vn as bindMiniAppCSSVars,
|
|
2960
|
+
yn as bindThemeParamsCSSVars,
|
|
2961
|
+
En as bindViewportCSSVars,
|
|
2977
2962
|
E as boolean,
|
|
2978
|
-
|
|
2963
|
+
qt as captureSameReq,
|
|
2979
2964
|
st as classNames,
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2965
|
+
Te as compareVersions,
|
|
2966
|
+
Os as createBrowserNavigatorFromLocation,
|
|
2967
|
+
ke as createPostEvent,
|
|
2968
|
+
M as createSafeURL,
|
|
2969
|
+
Lt as date,
|
|
2970
|
+
Cn as getHash,
|
|
2971
|
+
te as getPathname,
|
|
2972
|
+
je as initBackButton,
|
|
2973
|
+
Je as initBiometryManager,
|
|
2974
|
+
Qe as initClosingBehavior,
|
|
2975
|
+
es as initCloudStorage,
|
|
2976
|
+
ns as initHapticFeedback,
|
|
2977
|
+
is as initInitData,
|
|
2978
|
+
as as initInvoice,
|
|
2979
|
+
hs as initMainButton,
|
|
2980
|
+
ds as initMiniApp,
|
|
2981
|
+
Sn as initNavigator,
|
|
2997
2982
|
ws as initPopup,
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
2983
|
+
ms as initQRScanner,
|
|
2984
|
+
vs as initSettingsButton,
|
|
2985
|
+
Es as initThemeParams,
|
|
2986
|
+
Rs as initUtils,
|
|
2987
|
+
Cs as initViewport,
|
|
2988
|
+
Ss as initWeb,
|
|
2989
|
+
q as invokeCustomMethod,
|
|
2990
|
+
Bt as isColorDark,
|
|
2991
|
+
at as isIframe,
|
|
2992
|
+
Ft as isPageReload,
|
|
3008
2993
|
ct as isRGB,
|
|
3009
|
-
|
|
3010
|
-
|
|
2994
|
+
Oe as isRGBShort,
|
|
2995
|
+
As as isSDKError,
|
|
3011
2996
|
xn as isSDKErrorOfType,
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
2997
|
+
Ts as isSSR,
|
|
2998
|
+
Pn as isTMA,
|
|
2999
|
+
v as json,
|
|
3000
|
+
fn as mergeClassNames,
|
|
3001
|
+
Rn as mockTelegramEnv,
|
|
3002
|
+
x as number,
|
|
3018
3003
|
z as off,
|
|
3019
3004
|
y as on,
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3005
|
+
mn as parseInitData,
|
|
3006
|
+
lt as parseLaunchParams,
|
|
3007
|
+
Zt as parseThemeParams,
|
|
3008
|
+
V as postEvent,
|
|
3024
3009
|
g as request,
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3010
|
+
Ke as requestBiometryInfo,
|
|
3011
|
+
bn as requestThemeParams,
|
|
3012
|
+
Xt as requestViewport,
|
|
3028
3013
|
nt as retrieveLaunchParams,
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3014
|
+
Ve as rgb,
|
|
3015
|
+
ut as searchParams,
|
|
3016
|
+
Ue as serializeLaunchParams,
|
|
3017
|
+
Kt as serializeThemeParams,
|
|
3033
3018
|
P as setCSSVar,
|
|
3034
|
-
|
|
3019
|
+
ue as setDebug,
|
|
3035
3020
|
wn as setTargetOrigin,
|
|
3036
|
-
|
|
3037
|
-
|
|
3021
|
+
u as string,
|
|
3022
|
+
he as subscribe,
|
|
3038
3023
|
C as supports,
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3024
|
+
Ie as targetOrigin,
|
|
3025
|
+
Vt as toRGB,
|
|
3026
|
+
xt as unsubscribe,
|
|
3042
3027
|
U as urlToPath,
|
|
3043
|
-
|
|
3044
|
-
|
|
3028
|
+
Vs as useBackButton,
|
|
3029
|
+
Ds as useBackButtonRaw,
|
|
3045
3030
|
Ms as useBiometryManager,
|
|
3046
3031
|
Bs as useBiometryManagerRaw,
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3032
|
+
$s as useClosingBehavior,
|
|
3033
|
+
Ls as useClosingBehaviorRaw,
|
|
3034
|
+
Us as useCloudStorage,
|
|
3035
|
+
Hs as useCloudStorageRaw,
|
|
3036
|
+
Gs as useHapticFeedback,
|
|
3037
|
+
Ws as useHapticFeedbackRaw,
|
|
3038
|
+
zs as useInitData,
|
|
3039
|
+
js as useInitDataRaw,
|
|
3040
|
+
Js as useInvoice,
|
|
3041
|
+
Ks as useInvoiceRaw,
|
|
3042
|
+
tr as useLaunchParams,
|
|
3043
|
+
Qs as useMainButton,
|
|
3044
|
+
Fs as useMainButtonRaw,
|
|
3045
|
+
Zs as useMiniApp,
|
|
3046
|
+
Ys as useMiniAppRaw,
|
|
3047
|
+
tn as usePopup,
|
|
3048
|
+
Xs as usePopupRaw,
|
|
3049
|
+
sn as useQRScanner,
|
|
3050
|
+
en as useQRScannerRaw,
|
|
3051
|
+
Ns as useSDK,
|
|
3052
|
+
rn as useSettingsButton,
|
|
3053
|
+
nn as useSettingsButtonRaw,
|
|
3054
|
+
an as useThemeParams,
|
|
3055
|
+
on as useThemeParamsRaw,
|
|
3056
|
+
hn as useUtils,
|
|
3057
|
+
cn as useUtilsRaw,
|
|
3058
|
+
un as useViewport,
|
|
3059
|
+
pn as useViewportRaw,
|
|
3060
|
+
An as withBackButton,
|
|
3061
|
+
Tn as withBackButtonRaw,
|
|
3062
|
+
kn as withBiometryManager,
|
|
3063
|
+
In as withBiometryManagerRaw,
|
|
3079
3064
|
qn as withClosingBehavior,
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3065
|
+
On as withClosingBehaviorRaw,
|
|
3066
|
+
Dn as withCloudStorage,
|
|
3067
|
+
Nn as withCloudStorageRaw,
|
|
3083
3068
|
Bn as withHapticFeedback,
|
|
3084
|
-
|
|
3085
|
-
|
|
3069
|
+
Vn as withHapticFeedbackRaw,
|
|
3070
|
+
Ln as withInitData,
|
|
3086
3071
|
Mn as withInitDataRaw,
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3072
|
+
Hn as withInvoice,
|
|
3073
|
+
$n as withInvoiceRaw,
|
|
3074
|
+
Wn as withMainButton,
|
|
3075
|
+
Un as withMainButtonRaw,
|
|
3076
|
+
jn as withMiniApp,
|
|
3077
|
+
Gn as withMiniAppRaw,
|
|
3078
|
+
Kn as withPopup,
|
|
3079
|
+
zn as withPopupRaw,
|
|
3080
|
+
Fn as withQRScanner,
|
|
3081
|
+
Jn as withQRScannerRaw,
|
|
3082
|
+
Yn as withSettingsButton,
|
|
3083
|
+
Qn as withSettingsButtonRaw,
|
|
3084
|
+
Xn as withThemeParams,
|
|
3085
|
+
Zn as withThemeParamsRaw,
|
|
3086
|
+
Dt as withTimeout,
|
|
3087
|
+
sr as withUtils,
|
|
3088
|
+
er as withUtilsRaw,
|
|
3089
|
+
rr as withViewport,
|
|
3090
|
+
nr as withViewportRaw
|
|
3106
3091
|
};
|
|
3107
3092
|
//# sourceMappingURL=index.js.map
|