@tma.js/sdk-react 2.2.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +574 -538
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
var
|
|
4
|
-
function
|
|
1
|
+
import { jsx as Et } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as ie, useContext as oe, useState as Pt, useEffect as S, useMemo as Rt, useRef as ft, useCallback as ae } from "react";
|
|
3
|
+
var ce = Object.defineProperty, he = (e, t, s) => t in e ? ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (he(e, typeof t != "symbol" ? t + "" : t, s), s);
|
|
4
|
+
function xt(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
|
|
11
|
+
function Ct(e) {
|
|
12
12
|
const t = j(), { count: s } = t;
|
|
13
|
-
t.unsubscribe(e), s && !t.count &&
|
|
13
|
+
t.unsubscribe(e), s && !t.count && Ae();
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return j().subscribe(e), () =>
|
|
15
|
+
function pe(e) {
|
|
16
|
+
return j().subscribe(e), () => Ct(e);
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class ue {
|
|
19
19
|
constructor(t, s = {}) {
|
|
20
20
|
this.scope = t, this.options = s;
|
|
21
21
|
}
|
|
@@ -31,12 +31,12 @@ class oe {
|
|
|
31
31
|
second: "2-digit",
|
|
32
32
|
fractionalSecondDigits: 3,
|
|
33
33
|
timeZone: "UTC"
|
|
34
|
-
}).format(n), { textColor: i, bgColor:
|
|
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
|
-
`${
|
|
37
|
+
`${o};background-color: lightblue;color:black`,
|
|
38
38
|
"",
|
|
39
|
-
`${
|
|
39
|
+
`${o};${i ? `color:${i};` : ""}${a ? `background-color:${a}` : ""}`,
|
|
40
40
|
...s
|
|
41
41
|
);
|
|
42
42
|
}
|
|
@@ -55,21 +55,21 @@ class oe {
|
|
|
55
55
|
this.print("log", ...t);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
const
|
|
58
|
+
const nt = new ue("SDK", {
|
|
59
59
|
bgColor: "forestgreen",
|
|
60
60
|
textColor: "white"
|
|
61
61
|
});
|
|
62
62
|
let X = !1;
|
|
63
|
-
const
|
|
64
|
-
|
|
63
|
+
const mt = ({ name: e, payload: t }) => {
|
|
64
|
+
nt.log("Event received:", t ? { name: e, payload: t } : { name: e });
|
|
65
65
|
};
|
|
66
|
-
function
|
|
67
|
-
X !== e && (X = e, e ?
|
|
66
|
+
function le(e) {
|
|
67
|
+
X !== e && (X = e, e ? pe(mt) : Ct(mt));
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
X &&
|
|
69
|
+
function de(...e) {
|
|
70
|
+
X && nt.log(...e);
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class D {
|
|
73
73
|
constructor() {
|
|
74
74
|
c(this, "listeners", /* @__PURE__ */ new Map()), c(this, "listenersCount", 0), c(this, "subscribeListeners", []);
|
|
75
75
|
}
|
|
@@ -142,7 +142,7 @@ class N {
|
|
|
142
142
|
function tt(e, t, s) {
|
|
143
143
|
return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function rt(...e) {
|
|
146
146
|
let t = !1;
|
|
147
147
|
const s = [...e];
|
|
148
148
|
return [
|
|
@@ -161,9 +161,9 @@ class W extends Error {
|
|
|
161
161
|
function m(e, t, s) {
|
|
162
162
|
return new W(e, t, s);
|
|
163
163
|
}
|
|
164
|
-
const
|
|
164
|
+
const _e = "ERR_METHOD_UNSUPPORTED", we = "ERR_METHOD_PARAMETER_UNSUPPORTED", ge = "ERR_UNKNOWN_ENV", fe = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", me = "ERR_TIMED_OUT", be = "ERR_UNEXPECTED_TYPE", St = "ERR_PARSE", ve = "ERR_NAVIGATION_LIST_EMPTY", ye = "ERR_NAVIGATION_CURSOR_INVALID", dn = "ERR_NAVIGATION_ITEM_INVALID", _n = "ERR_SSR_INIT", Ee = "ERR_INVALID_PATH_BASE";
|
|
165
165
|
function T() {
|
|
166
|
-
return m(
|
|
166
|
+
return m(be, "Value has unexpected type");
|
|
167
167
|
}
|
|
168
168
|
class G {
|
|
169
169
|
constructor(t, s, n) {
|
|
@@ -181,7 +181,7 @@ class G {
|
|
|
181
181
|
return this.parser(t);
|
|
182
182
|
} catch (s) {
|
|
183
183
|
throw m(
|
|
184
|
-
|
|
184
|
+
St,
|
|
185
185
|
`Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
|
|
186
186
|
s
|
|
187
187
|
);
|
|
@@ -194,7 +194,7 @@ class G {
|
|
|
194
194
|
function A(e, t) {
|
|
195
195
|
return () => new G(e, !1, t);
|
|
196
196
|
}
|
|
197
|
-
const
|
|
197
|
+
const E = A((e) => {
|
|
198
198
|
if (typeof e == "boolean")
|
|
199
199
|
return e;
|
|
200
200
|
const t = String(e);
|
|
@@ -204,41 +204,41 @@ const P = A((e) => {
|
|
|
204
204
|
return !1;
|
|
205
205
|
throw T();
|
|
206
206
|
}, "boolean");
|
|
207
|
-
function
|
|
207
|
+
function Tt(e, t) {
|
|
208
208
|
const s = {};
|
|
209
209
|
for (const n in e) {
|
|
210
210
|
const r = e[n];
|
|
211
211
|
if (!r)
|
|
212
212
|
continue;
|
|
213
|
-
let i,
|
|
213
|
+
let i, a;
|
|
214
214
|
if (typeof r == "function" || "parse" in r)
|
|
215
|
-
i = n,
|
|
215
|
+
i = n, a = typeof r == "function" ? r : r.parse.bind(r);
|
|
216
216
|
else {
|
|
217
|
-
const { type:
|
|
218
|
-
i = r.from || n,
|
|
217
|
+
const { type: o } = r;
|
|
218
|
+
i = r.from || n, a = typeof o == "function" ? o : o.parse.bind(o);
|
|
219
219
|
}
|
|
220
220
|
try {
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
} catch (
|
|
224
|
-
throw m(
|
|
221
|
+
const o = a(t(i));
|
|
222
|
+
o !== void 0 && (s[n] = o);
|
|
223
|
+
} catch (o) {
|
|
224
|
+
throw m(St, `Unable to parse field "${n}"`, o);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
return s;
|
|
228
228
|
}
|
|
229
|
-
function
|
|
229
|
+
function it(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 w(e, t) {
|
|
236
236
|
return new G((s) => {
|
|
237
|
-
const n =
|
|
238
|
-
return
|
|
237
|
+
const n = it(s);
|
|
238
|
+
return Tt(e, (r) => n[r]);
|
|
239
239
|
}, !1, t);
|
|
240
240
|
}
|
|
241
|
-
const
|
|
241
|
+
const R = A((e) => {
|
|
242
242
|
if (typeof e == "number")
|
|
243
243
|
return e;
|
|
244
244
|
if (typeof e == "string") {
|
|
@@ -248,17 +248,17 @@ const x = A((e) => {
|
|
|
248
248
|
}
|
|
249
249
|
throw T();
|
|
250
250
|
}, "number");
|
|
251
|
-
function
|
|
251
|
+
function ot(e) {
|
|
252
252
|
return /^#[\da-f]{6}$/i.test(e);
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function Pe(e) {
|
|
255
255
|
return /^#[\da-f]{3}$/i.test(e);
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function At(e) {
|
|
258
258
|
const t = e.replace(/\s/g, "").toLowerCase();
|
|
259
|
-
if (
|
|
259
|
+
if (ot(t))
|
|
260
260
|
return t;
|
|
261
|
-
if (
|
|
261
|
+
if (Pe(t)) {
|
|
262
262
|
let n = "#";
|
|
263
263
|
for (let r = 0; r < 3; r += 1)
|
|
264
264
|
n += t[1 + r].repeat(2);
|
|
@@ -272,30 +272,30 @@ function Ct(e) {
|
|
|
272
272
|
return n + (i.length === 1 ? "0" : "") + i;
|
|
273
273
|
}, "#");
|
|
274
274
|
}
|
|
275
|
-
const
|
|
275
|
+
const h = A((e) => {
|
|
276
276
|
if (typeof e == "string" || typeof e == "number")
|
|
277
277
|
return e.toString();
|
|
278
278
|
throw T();
|
|
279
|
-
}, "string"),
|
|
280
|
-
function
|
|
281
|
-
return
|
|
282
|
-
eventType:
|
|
279
|
+
}, "string"), It = A((e) => At(h().parse(e)), "rgb");
|
|
280
|
+
function kt(e) {
|
|
281
|
+
return w({
|
|
282
|
+
eventType: h(),
|
|
283
283
|
eventData: (t) => t
|
|
284
284
|
}).parse(e);
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function Re() {
|
|
287
287
|
["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
|
|
288
288
|
delete window[e];
|
|
289
289
|
});
|
|
290
290
|
}
|
|
291
|
-
function
|
|
291
|
+
function et(e, t) {
|
|
292
292
|
window.dispatchEvent(new MessageEvent("message", {
|
|
293
293
|
data: JSON.stringify({ eventType: e, eventData: t }),
|
|
294
294
|
// We specify window.parent to imitate the case, the parent iframe sent us this event.
|
|
295
295
|
source: window.parent
|
|
296
296
|
}));
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function xe() {
|
|
299
299
|
[
|
|
300
300
|
["TelegramGameProxy_receiveEvent"],
|
|
301
301
|
// Windows Phone.
|
|
@@ -307,55 +307,55 @@ function Ee() {
|
|
|
307
307
|
let t = window;
|
|
308
308
|
e.forEach((s, n, r) => {
|
|
309
309
|
if (n === r.length - 1) {
|
|
310
|
-
t[s] =
|
|
310
|
+
t[s] = et;
|
|
311
311
|
return;
|
|
312
312
|
}
|
|
313
313
|
s in t || (t[s] = {}), t = t[s];
|
|
314
314
|
});
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
|
-
const
|
|
318
|
-
clipboard_text_received:
|
|
319
|
-
req_id:
|
|
320
|
-
data: (e) => e === null ? e :
|
|
317
|
+
const Ce = {
|
|
318
|
+
clipboard_text_received: w({
|
|
319
|
+
req_id: h(),
|
|
320
|
+
data: (e) => e === null ? e : h().optional().parse(e)
|
|
321
321
|
}),
|
|
322
|
-
custom_method_invoked:
|
|
323
|
-
req_id:
|
|
322
|
+
custom_method_invoked: w({
|
|
323
|
+
req_id: h(),
|
|
324
324
|
result: (e) => e,
|
|
325
|
-
error:
|
|
325
|
+
error: h().optional()
|
|
326
326
|
}),
|
|
327
|
-
invoice_closed:
|
|
328
|
-
phone_requested:
|
|
327
|
+
invoice_closed: w({ slug: h(), status: h() }),
|
|
328
|
+
phone_requested: w({ status: h() }),
|
|
329
329
|
popup_closed: {
|
|
330
330
|
parse(e) {
|
|
331
|
-
return
|
|
332
|
-
button_id: (t) => t == null ? void 0 :
|
|
331
|
+
return w({
|
|
332
|
+
button_id: (t) => t == null ? void 0 : h().parse(t)
|
|
333
333
|
}).parse(e ?? {});
|
|
334
334
|
}
|
|
335
335
|
},
|
|
336
|
-
qr_text_received:
|
|
337
|
-
theme_changed:
|
|
336
|
+
qr_text_received: w({ data: h().optional() }),
|
|
337
|
+
theme_changed: w({
|
|
338
338
|
theme_params: (e) => {
|
|
339
|
-
const t =
|
|
340
|
-
return Object.entries(
|
|
339
|
+
const t = It().optional();
|
|
340
|
+
return Object.entries(it(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
|
|
341
341
|
}
|
|
342
342
|
}),
|
|
343
|
-
viewport_changed:
|
|
344
|
-
height:
|
|
345
|
-
width: (e) => e == null ? window.innerWidth :
|
|
346
|
-
is_state_stable:
|
|
347
|
-
is_expanded:
|
|
343
|
+
viewport_changed: w({
|
|
344
|
+
height: R(),
|
|
345
|
+
width: (e) => e == null ? window.innerWidth : R().parse(e),
|
|
346
|
+
is_state_stable: E(),
|
|
347
|
+
is_expanded: E()
|
|
348
348
|
}),
|
|
349
|
-
write_access_requested:
|
|
349
|
+
write_access_requested: w({ status: h() })
|
|
350
350
|
};
|
|
351
|
-
function
|
|
352
|
-
const e = new
|
|
351
|
+
function Se() {
|
|
352
|
+
const e = new D(), t = new D();
|
|
353
353
|
t.subscribe((n) => {
|
|
354
354
|
e.emit("event", { name: n.event, payload: n.args[0] });
|
|
355
|
-
}),
|
|
356
|
-
const [, s] =
|
|
355
|
+
}), xe();
|
|
356
|
+
const [, s] = rt(
|
|
357
357
|
// Don't forget to remove created handlers.
|
|
358
|
-
|
|
358
|
+
Re,
|
|
359
359
|
// Add "resize" event listener to make sure, we always have fresh viewport information.
|
|
360
360
|
// Desktop version of Telegram is sometimes not sending the viewport_changed
|
|
361
361
|
// event. For example, when the MainButton is shown. That's why we should
|
|
@@ -376,19 +376,19 @@ function Re() {
|
|
|
376
376
|
return;
|
|
377
377
|
let r;
|
|
378
378
|
try {
|
|
379
|
-
r =
|
|
379
|
+
r = kt(n.data);
|
|
380
380
|
} catch {
|
|
381
381
|
return;
|
|
382
382
|
}
|
|
383
|
-
const { eventType: i, eventData:
|
|
383
|
+
const { eventType: i, eventData: a } = r, o = Ce[i];
|
|
384
384
|
try {
|
|
385
|
-
const
|
|
386
|
-
t.emit(...
|
|
387
|
-
} catch (
|
|
388
|
-
|
|
385
|
+
const p = o ? o.parse(a) : a;
|
|
386
|
+
t.emit(...p ? [i, p] : [i]);
|
|
387
|
+
} catch (p) {
|
|
388
|
+
nt.error(
|
|
389
389
|
`An error occurred processing the "${i}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
|
|
390
390
|
r,
|
|
391
|
-
|
|
391
|
+
p
|
|
392
392
|
);
|
|
393
393
|
}
|
|
394
394
|
}),
|
|
@@ -410,46 +410,46 @@ function Re() {
|
|
|
410
410
|
}
|
|
411
411
|
}, s];
|
|
412
412
|
}
|
|
413
|
-
const [
|
|
413
|
+
const [Te, Ae] = xt(
|
|
414
414
|
(e) => {
|
|
415
|
-
const [t, s] =
|
|
415
|
+
const [t, s] = Se(), n = t.off.bind(t);
|
|
416
416
|
return t.off = (r, i) => {
|
|
417
|
-
const { count:
|
|
418
|
-
n(r, i),
|
|
417
|
+
const { count: a } = t;
|
|
418
|
+
n(r, i), a && !t.count && e();
|
|
419
419
|
}, [t, s];
|
|
420
420
|
},
|
|
421
421
|
([, e]) => e()
|
|
422
422
|
);
|
|
423
423
|
function j() {
|
|
424
|
-
return
|
|
424
|
+
return Te()[0];
|
|
425
425
|
}
|
|
426
426
|
function z(e, t) {
|
|
427
427
|
j().off(e, t);
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function y(e, t, s) {
|
|
430
430
|
return j().on(e, t, s);
|
|
431
431
|
}
|
|
432
432
|
function V(e) {
|
|
433
433
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
434
434
|
}
|
|
435
|
-
function
|
|
435
|
+
function Ie(e, t) {
|
|
436
436
|
const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
|
|
437
437
|
for (let i = 0; i < r; i += 1) {
|
|
438
|
-
const
|
|
439
|
-
if (
|
|
440
|
-
return
|
|
438
|
+
const a = parseInt(s[i] || "0", 10), o = parseInt(n[i] || "0", 10);
|
|
439
|
+
if (a !== o)
|
|
440
|
+
return a > o ? 1 : -1;
|
|
441
441
|
}
|
|
442
442
|
return 0;
|
|
443
443
|
}
|
|
444
|
-
function
|
|
445
|
-
return
|
|
444
|
+
function v(e, t) {
|
|
445
|
+
return Ie(e, t) <= 0;
|
|
446
446
|
}
|
|
447
|
-
function
|
|
447
|
+
function x(e, t, s) {
|
|
448
448
|
if (typeof s == "string") {
|
|
449
449
|
if (e === "web_app_open_link" && t === "try_instant_view")
|
|
450
|
-
return
|
|
450
|
+
return v("6.4", s);
|
|
451
451
|
if (e === "web_app_set_header_color" && t === "color")
|
|
452
|
-
return
|
|
452
|
+
return v("6.9", s);
|
|
453
453
|
}
|
|
454
454
|
switch (e) {
|
|
455
455
|
case "web_app_open_tg_link":
|
|
@@ -458,27 +458,27 @@ function C(e, t, s) {
|
|
|
458
458
|
case "web_app_set_background_color":
|
|
459
459
|
case "web_app_set_header_color":
|
|
460
460
|
case "web_app_trigger_haptic_feedback":
|
|
461
|
-
return
|
|
461
|
+
return v("6.1", t);
|
|
462
462
|
case "web_app_open_popup":
|
|
463
|
-
return
|
|
463
|
+
return v("6.2", t);
|
|
464
464
|
case "web_app_close_scan_qr_popup":
|
|
465
465
|
case "web_app_open_scan_qr_popup":
|
|
466
466
|
case "web_app_read_text_from_clipboard":
|
|
467
|
-
return
|
|
467
|
+
return v("6.4", t);
|
|
468
468
|
case "web_app_switch_inline_query":
|
|
469
|
-
return
|
|
469
|
+
return v("6.7", t);
|
|
470
470
|
case "web_app_invoke_custom_method":
|
|
471
471
|
case "web_app_request_write_access":
|
|
472
472
|
case "web_app_request_phone":
|
|
473
|
-
return
|
|
473
|
+
return v("6.9", t);
|
|
474
474
|
case "web_app_setup_settings_button":
|
|
475
|
-
return
|
|
475
|
+
return v("6.10", t);
|
|
476
476
|
case "web_app_biometry_get_info":
|
|
477
477
|
case "web_app_biometry_open_settings":
|
|
478
478
|
case "web_app_biometry_request_access":
|
|
479
479
|
case "web_app_biometry_request_auth":
|
|
480
480
|
case "web_app_biometry_update_token":
|
|
481
|
-
return
|
|
481
|
+
return v("7.2", t);
|
|
482
482
|
default:
|
|
483
483
|
return [
|
|
484
484
|
"iframe_ready",
|
|
@@ -495,102 +495,98 @@ function C(e, t, s) {
|
|
|
495
495
|
].includes(e);
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
|
-
function
|
|
498
|
+
function qt(e) {
|
|
499
499
|
return "external" in e && V(e.external) && "notify" in e.external && typeof e.external.notify == "function";
|
|
500
500
|
}
|
|
501
|
-
function
|
|
501
|
+
function Ot(e) {
|
|
502
502
|
return "TelegramWebviewProxy" in e && V(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
|
|
503
503
|
}
|
|
504
|
-
function
|
|
504
|
+
function at() {
|
|
505
505
|
try {
|
|
506
506
|
return window.self !== window.top;
|
|
507
507
|
} catch {
|
|
508
508
|
return !0;
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
|
-
let
|
|
512
|
-
function
|
|
513
|
-
|
|
511
|
+
let Nt = "https://web.telegram.org";
|
|
512
|
+
function wn(e) {
|
|
513
|
+
Nt = e;
|
|
514
514
|
}
|
|
515
|
-
function
|
|
516
|
-
return
|
|
515
|
+
function ke() {
|
|
516
|
+
return Nt;
|
|
517
517
|
}
|
|
518
518
|
function B(e, t, s) {
|
|
519
519
|
let n = {}, r;
|
|
520
520
|
t === void 0 && s === void 0 ? n = {} : t !== void 0 && s !== void 0 ? (n = s, r = t) : t !== void 0 && ("targetOrigin" in t ? n = t : r = t);
|
|
521
|
-
const { targetOrigin: i =
|
|
522
|
-
if (
|
|
521
|
+
const { targetOrigin: i = ke() } = n;
|
|
522
|
+
if (de("Posting event:", r ? { event: e, data: r } : { event: e }), at()) {
|
|
523
523
|
window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
|
|
524
524
|
return;
|
|
525
525
|
}
|
|
526
|
-
if (
|
|
526
|
+
if (qt(window)) {
|
|
527
527
|
window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
|
|
528
528
|
return;
|
|
529
529
|
}
|
|
530
|
-
if (
|
|
530
|
+
if (Ot(window)) {
|
|
531
531
|
window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
|
|
532
532
|
return;
|
|
533
533
|
}
|
|
534
534
|
throw m(
|
|
535
|
-
|
|
535
|
+
ge,
|
|
536
536
|
"Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside of Telegram application environment."
|
|
537
537
|
);
|
|
538
538
|
}
|
|
539
|
-
function
|
|
539
|
+
function qe(e) {
|
|
540
540
|
return (t, s) => {
|
|
541
|
-
if (!
|
|
542
|
-
throw m(
|
|
541
|
+
if (!x(t, e))
|
|
542
|
+
throw m(_e, `Method "${t}" is unsupported in Mini Apps version ${e}`);
|
|
543
543
|
if (V(s)) {
|
|
544
544
|
let n;
|
|
545
|
-
if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !
|
|
545
|
+
if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !x(t, n, e))
|
|
546
546
|
throw m(
|
|
547
|
-
|
|
547
|
+
we,
|
|
548
548
|
`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
|
|
549
549
|
);
|
|
550
550
|
}
|
|
551
551
|
return B(t, s);
|
|
552
552
|
};
|
|
553
553
|
}
|
|
554
|
-
function
|
|
554
|
+
function Dt(e) {
|
|
555
555
|
return ({ req_id: t }) => t === e;
|
|
556
556
|
}
|
|
557
|
-
function
|
|
558
|
-
return m(
|
|
557
|
+
function Bt(e) {
|
|
558
|
+
return m(me, `Timeout reached: ${e}ms`);
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function Mt(e, t) {
|
|
561
561
|
return Promise.race([
|
|
562
562
|
typeof e == "function" ? e() : e,
|
|
563
563
|
new Promise((s, n) => {
|
|
564
564
|
setTimeout(() => {
|
|
565
|
-
n(
|
|
565
|
+
n(Bt(t));
|
|
566
566
|
}, t);
|
|
567
567
|
})
|
|
568
568
|
]);
|
|
569
569
|
}
|
|
570
|
-
async function
|
|
570
|
+
async function g(e) {
|
|
571
571
|
let t;
|
|
572
|
-
const s = new Promise((
|
|
573
|
-
t =
|
|
574
|
-
}), {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
postEvent: o = B,
|
|
579
|
-
timeout: a
|
|
580
|
-
} = e, u = (Array.isArray(r) ? r : [r]).map(
|
|
581
|
-
(h) => E(h, (v) => (!i || i(v)) && t(v))
|
|
572
|
+
const s = new Promise((o) => {
|
|
573
|
+
t = o;
|
|
574
|
+
}), { event: n, capture: r, timeout: i } = e, [, a] = rt(
|
|
575
|
+
...(Array.isArray(n) ? n : [n]).map(
|
|
576
|
+
(o) => y(o, (p) => (!r || r(p)) && t(p))
|
|
577
|
+
)
|
|
582
578
|
);
|
|
583
579
|
try {
|
|
584
|
-
return
|
|
580
|
+
return (e.postEvent || B)(e.method, e.params), await (i ? Mt(s, i) : s);
|
|
585
581
|
} finally {
|
|
586
|
-
|
|
582
|
+
a();
|
|
587
583
|
}
|
|
588
584
|
}
|
|
589
585
|
async function O(e, t, s, n = {}) {
|
|
590
586
|
const {
|
|
591
587
|
result: r,
|
|
592
588
|
error: i
|
|
593
|
-
} = await
|
|
589
|
+
} = await g({
|
|
594
590
|
...n,
|
|
595
591
|
method: "web_app_invoke_custom_method",
|
|
596
592
|
event: "custom_method_invoked",
|
|
@@ -599,30 +595,30 @@ async function O(e, t, s, n = {}) {
|
|
|
599
595
|
params: t,
|
|
600
596
|
req_id: s
|
|
601
597
|
},
|
|
602
|
-
capture:
|
|
598
|
+
capture: Dt(s)
|
|
603
599
|
});
|
|
604
600
|
if (i)
|
|
605
|
-
throw m(
|
|
601
|
+
throw m(fe, i);
|
|
606
602
|
return r;
|
|
607
603
|
}
|
|
608
|
-
function
|
|
604
|
+
function st(...e) {
|
|
609
605
|
return e.map((t) => {
|
|
610
606
|
if (typeof t == "string")
|
|
611
607
|
return t;
|
|
612
608
|
if (V(t))
|
|
613
|
-
return
|
|
609
|
+
return st(Object.entries(t).map((s) => s[1] && s[0]));
|
|
614
610
|
if (Array.isArray(t))
|
|
615
|
-
return
|
|
611
|
+
return st(...t);
|
|
616
612
|
}).filter(Boolean).join(" ");
|
|
617
613
|
}
|
|
618
|
-
function
|
|
614
|
+
function gn(...e) {
|
|
619
615
|
return e.reduce((t, s) => (V(s) && Object.entries(s).forEach(([n, r]) => {
|
|
620
|
-
const i =
|
|
616
|
+
const i = st(t[n], r);
|
|
621
617
|
i.length && (t[n] = i);
|
|
622
618
|
}), t), {});
|
|
623
619
|
}
|
|
624
|
-
function
|
|
625
|
-
const t =
|
|
620
|
+
function Vt(e) {
|
|
621
|
+
const t = At(e);
|
|
626
622
|
return Math.sqrt(
|
|
627
623
|
[0.299, 0.587, 0.114].reduce((s, n, r) => {
|
|
628
624
|
const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
|
|
@@ -630,9 +626,9 @@ function Dt(e) {
|
|
|
630
626
|
}, 0)
|
|
631
627
|
) < 120;
|
|
632
628
|
}
|
|
633
|
-
class
|
|
629
|
+
class Oe {
|
|
634
630
|
constructor(t) {
|
|
635
|
-
c(this, "ee", new
|
|
631
|
+
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;
|
|
636
632
|
}
|
|
637
633
|
/**
|
|
638
634
|
* Clones current state and returns its copy.
|
|
@@ -651,25 +647,25 @@ class ke {
|
|
|
651
647
|
return this.state[t];
|
|
652
648
|
}
|
|
653
649
|
}
|
|
654
|
-
class
|
|
650
|
+
class ct {
|
|
655
651
|
constructor(t) {
|
|
656
|
-
c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new
|
|
652
|
+
c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new Oe(t), this.set = this.state.set.bind(this.state), this.get = this.state.get.bind(this.state), this.clone = this.state.clone.bind(this.state);
|
|
657
653
|
}
|
|
658
654
|
}
|
|
659
|
-
function
|
|
660
|
-
return (s) =>
|
|
655
|
+
function $t(e, t) {
|
|
656
|
+
return (s) => x(t[s], e);
|
|
661
657
|
}
|
|
662
|
-
class
|
|
658
|
+
class ht extends ct {
|
|
663
659
|
constructor(t, s, n) {
|
|
664
|
-
super(t), c(this, "supports"), this.supports =
|
|
660
|
+
super(t), c(this, "supports"), this.supports = $t(s, n);
|
|
665
661
|
}
|
|
666
662
|
}
|
|
667
|
-
class
|
|
663
|
+
class Ne extends ht {
|
|
668
664
|
constructor(t, s, n) {
|
|
669
665
|
super({ isVisible: t }, s, {
|
|
670
666
|
show: "web_app_setup_back_button",
|
|
671
667
|
hide: "web_app_setup_back_button"
|
|
672
|
-
}), c(this, "on", (r, i) => r === "click" ?
|
|
668
|
+
}), c(this, "on", (r, i) => r === "click" ? y("back_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? z("back_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
|
|
673
669
|
}
|
|
674
670
|
set isVisible(t) {
|
|
675
671
|
this.set("isVisible", t), this.postEvent("web_app_setup_back_button", { is_visible: t });
|
|
@@ -693,248 +689,248 @@ class qe extends ot {
|
|
|
693
689
|
this.isVisible = !0;
|
|
694
690
|
}
|
|
695
691
|
}
|
|
696
|
-
const
|
|
697
|
-
function
|
|
692
|
+
const Lt = A((e) => e instanceof Date ? e : new Date(R().parse(e) * 1e3), "Date");
|
|
693
|
+
function pt(e, t) {
|
|
698
694
|
return new G((s) => {
|
|
699
695
|
if (typeof s != "string" && !(s instanceof URLSearchParams))
|
|
700
696
|
throw T();
|
|
701
697
|
const n = typeof s == "string" ? new URLSearchParams(s) : s;
|
|
702
|
-
return
|
|
698
|
+
return Tt(e, (r) => {
|
|
703
699
|
const i = n.get(r);
|
|
704
700
|
return i === null ? void 0 : i;
|
|
705
701
|
});
|
|
706
702
|
}, !1, t);
|
|
707
703
|
}
|
|
708
|
-
const
|
|
709
|
-
id:
|
|
710
|
-
type:
|
|
711
|
-
title:
|
|
704
|
+
const De = w({
|
|
705
|
+
id: R(),
|
|
706
|
+
type: h(),
|
|
707
|
+
title: h(),
|
|
712
708
|
photoUrl: {
|
|
713
|
-
type:
|
|
709
|
+
type: h().optional(),
|
|
714
710
|
from: "photo_url"
|
|
715
711
|
},
|
|
716
|
-
username:
|
|
717
|
-
}, "Chat").optional(),
|
|
712
|
+
username: h().optional()
|
|
713
|
+
}, "Chat").optional(), bt = w({
|
|
718
714
|
addedToAttachmentMenu: {
|
|
719
|
-
type:
|
|
715
|
+
type: E().optional(),
|
|
720
716
|
from: "added_to_attachment_menu"
|
|
721
717
|
},
|
|
722
718
|
allowsWriteToPm: {
|
|
723
|
-
type:
|
|
719
|
+
type: E().optional(),
|
|
724
720
|
from: "allows_write_to_pm"
|
|
725
721
|
},
|
|
726
722
|
firstName: {
|
|
727
|
-
type:
|
|
723
|
+
type: h(),
|
|
728
724
|
from: "first_name"
|
|
729
725
|
},
|
|
730
|
-
id:
|
|
726
|
+
id: R(),
|
|
731
727
|
isBot: {
|
|
732
|
-
type:
|
|
728
|
+
type: E().optional(),
|
|
733
729
|
from: "is_bot"
|
|
734
730
|
},
|
|
735
731
|
isPremium: {
|
|
736
|
-
type:
|
|
732
|
+
type: E().optional(),
|
|
737
733
|
from: "is_premium"
|
|
738
734
|
},
|
|
739
735
|
languageCode: {
|
|
740
|
-
type:
|
|
736
|
+
type: h().optional(),
|
|
741
737
|
from: "language_code"
|
|
742
738
|
},
|
|
743
739
|
lastName: {
|
|
744
|
-
type:
|
|
740
|
+
type: h().optional(),
|
|
745
741
|
from: "last_name"
|
|
746
742
|
},
|
|
747
743
|
photoUrl: {
|
|
748
|
-
type:
|
|
744
|
+
type: h().optional(),
|
|
749
745
|
from: "photo_url"
|
|
750
746
|
},
|
|
751
|
-
username:
|
|
747
|
+
username: h().optional()
|
|
752
748
|
}, "User").optional();
|
|
753
|
-
function
|
|
754
|
-
return
|
|
749
|
+
function Ht() {
|
|
750
|
+
return pt({
|
|
755
751
|
authDate: {
|
|
756
|
-
type:
|
|
752
|
+
type: Lt(),
|
|
757
753
|
from: "auth_date"
|
|
758
754
|
},
|
|
759
755
|
canSendAfter: {
|
|
760
|
-
type:
|
|
756
|
+
type: R().optional(),
|
|
761
757
|
from: "can_send_after"
|
|
762
758
|
},
|
|
763
|
-
chat:
|
|
759
|
+
chat: De,
|
|
764
760
|
chatInstance: {
|
|
765
|
-
type:
|
|
761
|
+
type: h().optional(),
|
|
766
762
|
from: "chat_instance"
|
|
767
763
|
},
|
|
768
764
|
chatType: {
|
|
769
|
-
type:
|
|
765
|
+
type: h().optional(),
|
|
770
766
|
from: "chat_type"
|
|
771
767
|
},
|
|
772
|
-
hash:
|
|
768
|
+
hash: h(),
|
|
773
769
|
queryId: {
|
|
774
|
-
type:
|
|
770
|
+
type: h().optional(),
|
|
775
771
|
from: "query_id"
|
|
776
772
|
},
|
|
777
|
-
receiver:
|
|
773
|
+
receiver: bt,
|
|
778
774
|
startParam: {
|
|
779
|
-
type:
|
|
775
|
+
type: h().optional(),
|
|
780
776
|
from: "start_param"
|
|
781
777
|
},
|
|
782
|
-
user:
|
|
778
|
+
user: bt
|
|
783
779
|
}, "InitData");
|
|
784
780
|
}
|
|
785
|
-
function
|
|
781
|
+
function Be(e) {
|
|
786
782
|
return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
|
|
787
783
|
}
|
|
788
|
-
function
|
|
784
|
+
function Me(e) {
|
|
789
785
|
return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
|
|
790
786
|
}
|
|
791
|
-
const
|
|
787
|
+
const Ut = A(
|
|
792
788
|
(e) => {
|
|
793
|
-
const t =
|
|
794
|
-
return Object.entries(
|
|
789
|
+
const t = It().optional();
|
|
790
|
+
return Object.entries(it(e)).reduce((s, [n, r]) => (s[Be(n)] = t.parse(r), s), {});
|
|
795
791
|
},
|
|
796
792
|
"ThemeParams"
|
|
797
793
|
);
|
|
798
|
-
function
|
|
799
|
-
return
|
|
794
|
+
function ut(e) {
|
|
795
|
+
return pt({
|
|
800
796
|
botInline: {
|
|
801
|
-
type:
|
|
797
|
+
type: E().optional(),
|
|
802
798
|
from: "tgWebAppBotInline"
|
|
803
799
|
},
|
|
804
800
|
initData: {
|
|
805
|
-
type:
|
|
801
|
+
type: Ht().optional(),
|
|
806
802
|
from: "tgWebAppData"
|
|
807
803
|
},
|
|
808
804
|
initDataRaw: {
|
|
809
|
-
type:
|
|
805
|
+
type: h().optional(),
|
|
810
806
|
from: "tgWebAppData"
|
|
811
807
|
},
|
|
812
808
|
platform: {
|
|
813
|
-
type:
|
|
809
|
+
type: h(),
|
|
814
810
|
from: "tgWebAppPlatform"
|
|
815
811
|
},
|
|
816
812
|
showSettings: {
|
|
817
|
-
type:
|
|
813
|
+
type: E().optional(),
|
|
818
814
|
from: "tgWebAppShowSettings"
|
|
819
815
|
},
|
|
820
816
|
startParam: {
|
|
821
|
-
type:
|
|
817
|
+
type: h().optional(),
|
|
822
818
|
from: "tgWebAppStartParam"
|
|
823
819
|
},
|
|
824
820
|
themeParams: {
|
|
825
|
-
type:
|
|
821
|
+
type: Ut(),
|
|
826
822
|
from: "tgWebAppThemeParams"
|
|
827
823
|
},
|
|
828
824
|
version: {
|
|
829
|
-
type:
|
|
825
|
+
type: h(),
|
|
830
826
|
from: "tgWebAppVersion"
|
|
831
827
|
}
|
|
832
828
|
}).parse(e);
|
|
833
829
|
}
|
|
834
|
-
function
|
|
835
|
-
return
|
|
830
|
+
function Wt(e) {
|
|
831
|
+
return ut(
|
|
836
832
|
e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
|
|
837
833
|
);
|
|
838
834
|
}
|
|
839
|
-
function
|
|
840
|
-
return
|
|
835
|
+
function Ve() {
|
|
836
|
+
return Wt(window.location.href);
|
|
841
837
|
}
|
|
842
|
-
function
|
|
838
|
+
function Gt() {
|
|
843
839
|
return performance.getEntriesByType("navigation")[0];
|
|
844
840
|
}
|
|
845
|
-
function
|
|
846
|
-
const e =
|
|
841
|
+
function $e() {
|
|
842
|
+
const e = Gt();
|
|
847
843
|
if (!e)
|
|
848
844
|
throw new Error("Unable to get first navigation entry.");
|
|
849
|
-
return
|
|
845
|
+
return Wt(e.name);
|
|
850
846
|
}
|
|
851
|
-
function
|
|
847
|
+
function jt(e) {
|
|
852
848
|
return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
|
|
853
849
|
}
|
|
854
|
-
function
|
|
855
|
-
sessionStorage.setItem(
|
|
850
|
+
function zt(e, t) {
|
|
851
|
+
sessionStorage.setItem(jt(e), JSON.stringify(t));
|
|
856
852
|
}
|
|
857
|
-
function
|
|
858
|
-
const t = sessionStorage.getItem(
|
|
853
|
+
function Kt(e) {
|
|
854
|
+
const t = sessionStorage.getItem(jt(e));
|
|
859
855
|
try {
|
|
860
856
|
return t ? JSON.parse(t) : void 0;
|
|
861
857
|
} catch {
|
|
862
858
|
}
|
|
863
859
|
}
|
|
864
|
-
function
|
|
865
|
-
return
|
|
860
|
+
function Le() {
|
|
861
|
+
return ut(Kt("launchParams") || "");
|
|
866
862
|
}
|
|
867
|
-
function
|
|
863
|
+
function Jt(e) {
|
|
868
864
|
return JSON.stringify(
|
|
869
865
|
Object.fromEntries(
|
|
870
|
-
Object.entries(e).map(([t, s]) => [
|
|
866
|
+
Object.entries(e).map(([t, s]) => [Me(t), s])
|
|
871
867
|
)
|
|
872
868
|
);
|
|
873
869
|
}
|
|
874
|
-
function
|
|
870
|
+
function He(e) {
|
|
875
871
|
const {
|
|
876
872
|
initDataRaw: t,
|
|
877
873
|
themeParams: s,
|
|
878
874
|
platform: n,
|
|
879
875
|
version: r,
|
|
880
876
|
showSettings: i,
|
|
881
|
-
startParam:
|
|
882
|
-
botInline:
|
|
883
|
-
} = e,
|
|
884
|
-
return
|
|
877
|
+
startParam: a,
|
|
878
|
+
botInline: o
|
|
879
|
+
} = e, p = new URLSearchParams();
|
|
880
|
+
return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", Jt(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();
|
|
885
881
|
}
|
|
886
|
-
function
|
|
887
|
-
|
|
882
|
+
function Ft(e) {
|
|
883
|
+
zt("launchParams", He(e));
|
|
888
884
|
}
|
|
889
|
-
function
|
|
885
|
+
function Qt() {
|
|
890
886
|
for (const e of [
|
|
891
887
|
// Try to retrieve launch parameters from the current location. This method can return
|
|
892
888
|
// nothing in case, location was changed and then page was reloaded.
|
|
893
|
-
|
|
889
|
+
Ve,
|
|
894
890
|
// Then, try using the lower level API - window.performance.
|
|
895
|
-
|
|
891
|
+
$e,
|
|
896
892
|
// Finally, try to extract launch parameters from the session storage.
|
|
897
|
-
|
|
893
|
+
Le
|
|
898
894
|
])
|
|
899
895
|
try {
|
|
900
896
|
const t = e();
|
|
901
|
-
return
|
|
897
|
+
return Ft(t), t;
|
|
902
898
|
} catch {
|
|
903
899
|
}
|
|
904
900
|
throw new Error("Unable to retrieve launch parameters from any known source.");
|
|
905
901
|
}
|
|
906
|
-
function
|
|
907
|
-
const e =
|
|
902
|
+
function Yt() {
|
|
903
|
+
const e = Gt();
|
|
908
904
|
return !!(e && e.type === "reload");
|
|
909
905
|
}
|
|
910
906
|
function Ue() {
|
|
911
907
|
let e = 0;
|
|
912
908
|
return () => (e += 1).toString();
|
|
913
909
|
}
|
|
914
|
-
const [We] =
|
|
910
|
+
const [We] = xt(Ue);
|
|
915
911
|
function l(e, t) {
|
|
916
912
|
return () => {
|
|
917
|
-
const s =
|
|
913
|
+
const s = Qt(), n = {
|
|
918
914
|
...s,
|
|
919
|
-
postEvent:
|
|
915
|
+
postEvent: qe(s.version),
|
|
920
916
|
createRequestId: We()
|
|
921
917
|
};
|
|
922
918
|
if (typeof e == "function")
|
|
923
919
|
return e(n);
|
|
924
|
-
const [r, i,
|
|
920
|
+
const [r, i, a] = rt(), o = t({
|
|
925
921
|
...n,
|
|
926
922
|
// State should only be passed only in case, current page was reloaded. If we don't add
|
|
927
923
|
// this check, state restoration will work improperly in the web version of Telegram,
|
|
928
924
|
// when we are always working in the same "session" (tab).
|
|
929
|
-
state:
|
|
925
|
+
state: Yt() ? Kt(e) : void 0,
|
|
930
926
|
addCleanup: r
|
|
931
|
-
}),
|
|
932
|
-
|
|
933
|
-
|
|
927
|
+
}), p = (u) => (a || r(
|
|
928
|
+
u.on("change", (C) => {
|
|
929
|
+
zt(e, C);
|
|
934
930
|
})
|
|
935
|
-
),
|
|
931
|
+
), u);
|
|
936
932
|
return [
|
|
937
|
-
|
|
933
|
+
o instanceof Promise ? o.then(p) : p(o),
|
|
938
934
|
i
|
|
939
935
|
];
|
|
940
936
|
};
|
|
@@ -943,13 +939,13 @@ const Ge = l("backButton", ({
|
|
|
943
939
|
postEvent: e,
|
|
944
940
|
version: t,
|
|
945
941
|
state: s = { isVisible: !1 }
|
|
946
|
-
}) => new
|
|
947
|
-
class $ extends
|
|
942
|
+
}) => new Ne(s.isVisible, t, e));
|
|
943
|
+
class $ extends ht {
|
|
948
944
|
constructor() {
|
|
949
945
|
super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
|
|
950
946
|
}
|
|
951
947
|
}
|
|
952
|
-
function
|
|
948
|
+
function Zt(e) {
|
|
953
949
|
const t = e.available ? e : {
|
|
954
950
|
available: !1,
|
|
955
951
|
device_id: "",
|
|
@@ -1004,7 +1000,7 @@ class je extends $ {
|
|
|
1004
1000
|
reason: t,
|
|
1005
1001
|
...s
|
|
1006
1002
|
}) {
|
|
1007
|
-
return this.authPromise || (this.authPromise =
|
|
1003
|
+
return this.authPromise || (this.authPromise = g({
|
|
1008
1004
|
...s,
|
|
1009
1005
|
method: "web_app_biometry_request_auth",
|
|
1010
1006
|
event: "biometry_auth_requested",
|
|
@@ -1038,14 +1034,14 @@ class je extends $ {
|
|
|
1038
1034
|
* @returns Promise with true, if access was granted.
|
|
1039
1035
|
*/
|
|
1040
1036
|
requestAccess({ reason: t, ...s } = {}) {
|
|
1041
|
-
return this.accessPromise || (this.accessPromise =
|
|
1037
|
+
return this.accessPromise || (this.accessPromise = g({
|
|
1042
1038
|
...s,
|
|
1043
1039
|
postEvent: this.postEvent,
|
|
1044
1040
|
method: "web_app_biometry_request_access",
|
|
1045
1041
|
event: "biometry_info_received",
|
|
1046
1042
|
params: { reason: t || "" }
|
|
1047
1043
|
}).then((n) => {
|
|
1048
|
-
const r =
|
|
1044
|
+
const r = Zt(n);
|
|
1049
1045
|
return this.set(r), r.accessGranted;
|
|
1050
1046
|
}).finally(() => this.accessPromise = void 0)), this.accessPromise;
|
|
1051
1047
|
}
|
|
@@ -1067,7 +1063,7 @@ class je extends $ {
|
|
|
1067
1063
|
*/
|
|
1068
1064
|
async updateToken({ token: t, ...s } = {}) {
|
|
1069
1065
|
return ["removed", "updated"].includes(
|
|
1070
|
-
(await
|
|
1066
|
+
(await g({
|
|
1071
1067
|
...s,
|
|
1072
1068
|
postEvent: this.postEvent,
|
|
1073
1069
|
method: "web_app_biometry_update_token",
|
|
@@ -1078,8 +1074,8 @@ class je extends $ {
|
|
|
1078
1074
|
}
|
|
1079
1075
|
}
|
|
1080
1076
|
async function ze(e) {
|
|
1081
|
-
return
|
|
1082
|
-
await
|
|
1077
|
+
return Zt(
|
|
1078
|
+
await g({
|
|
1083
1079
|
...e || {},
|
|
1084
1080
|
method: "web_app_biometry_get_info",
|
|
1085
1081
|
event: "biometry_info_received"
|
|
@@ -1089,7 +1085,7 @@ async function ze(e) {
|
|
|
1089
1085
|
const Ke = l(
|
|
1090
1086
|
"biometryManager",
|
|
1091
1087
|
async ({ postEvent: e, version: t, state: s }) => new je({
|
|
1092
|
-
...s ||
|
|
1088
|
+
...s || x("web_app_biometry_get_info", t) ? s || await ze({ timeout: 1e3 }) : {
|
|
1093
1089
|
available: !1,
|
|
1094
1090
|
accessGranted: !1,
|
|
1095
1091
|
accessRequested: !1,
|
|
@@ -1100,12 +1096,12 @@ const Ke = l(
|
|
|
1100
1096
|
postEvent: e
|
|
1101
1097
|
})
|
|
1102
1098
|
);
|
|
1103
|
-
class
|
|
1099
|
+
class lt extends ct {
|
|
1104
1100
|
constructor() {
|
|
1105
1101
|
super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
|
|
1106
1102
|
}
|
|
1107
1103
|
}
|
|
1108
|
-
class Je extends
|
|
1104
|
+
class Je extends lt {
|
|
1109
1105
|
constructor(t, s) {
|
|
1110
1106
|
super({ isConfirmationNeeded: t }), this.postEvent = s;
|
|
1111
1107
|
}
|
|
@@ -1139,9 +1135,9 @@ const Fe = l(
|
|
|
1139
1135
|
state: t = { isConfirmationNeeded: !1 }
|
|
1140
1136
|
}) => new Je(t.isConfirmationNeeded, e)
|
|
1141
1137
|
);
|
|
1142
|
-
class
|
|
1138
|
+
class dt {
|
|
1143
1139
|
constructor(t, s) {
|
|
1144
|
-
c(this, "supports"), this.supports =
|
|
1140
|
+
c(this, "supports"), this.supports = $t(t, s);
|
|
1145
1141
|
}
|
|
1146
1142
|
}
|
|
1147
1143
|
function Qe(e) {
|
|
@@ -1177,10 +1173,10 @@ class Ye extends G {
|
|
|
1177
1173
|
function Ze(e) {
|
|
1178
1174
|
return new Ye((t) => t, !1, e);
|
|
1179
1175
|
}
|
|
1180
|
-
function
|
|
1176
|
+
function vt(e, t) {
|
|
1181
1177
|
return Object.fromEntries(e.map((s) => [s, t]));
|
|
1182
1178
|
}
|
|
1183
|
-
class Xe extends
|
|
1179
|
+
class Xe extends dt {
|
|
1184
1180
|
constructor(t, s, n) {
|
|
1185
1181
|
super(t, {
|
|
1186
1182
|
delete: "web_app_invoke_custom_method",
|
|
@@ -1208,7 +1204,7 @@ class Xe extends ht {
|
|
|
1208
1204
|
* @param options - request execution options.
|
|
1209
1205
|
*/
|
|
1210
1206
|
async getKeys(t = {}) {
|
|
1211
|
-
return Ze().of(
|
|
1207
|
+
return Ze().of(h()).parse(
|
|
1212
1208
|
await O(
|
|
1213
1209
|
"getStorageKeys",
|
|
1214
1210
|
{},
|
|
@@ -1220,13 +1216,13 @@ class Xe extends ht {
|
|
|
1220
1216
|
async get(t, s = {}) {
|
|
1221
1217
|
const n = Array.isArray(t) ? t : [t];
|
|
1222
1218
|
if (!n.length)
|
|
1223
|
-
return
|
|
1219
|
+
return vt(n, "");
|
|
1224
1220
|
const r = await O(
|
|
1225
1221
|
"getStorageValues",
|
|
1226
1222
|
{ keys: n },
|
|
1227
1223
|
this.createRequestId(),
|
|
1228
1224
|
{ ...s, postEvent: this.postEvent }
|
|
1229
|
-
), i =
|
|
1225
|
+
), i = w(vt(n, h()), "CloudStorageData").parse(r);
|
|
1230
1226
|
return Array.isArray(t) ? i : i[t];
|
|
1231
1227
|
}
|
|
1232
1228
|
/**
|
|
@@ -1247,7 +1243,7 @@ class Xe extends ht {
|
|
|
1247
1243
|
const ts = l(
|
|
1248
1244
|
({ createRequestId: e, postEvent: t, version: s }) => new Xe(s, e, t)
|
|
1249
1245
|
);
|
|
1250
|
-
class es extends
|
|
1246
|
+
class es extends dt {
|
|
1251
1247
|
constructor(t, s) {
|
|
1252
1248
|
super(t, {
|
|
1253
1249
|
impactOccurred: "web_app_trigger_haptic_feedback",
|
|
@@ -1369,7 +1365,7 @@ const rs = l(
|
|
|
1369
1365
|
({ initData: e }) => e ? new ns(e) : void 0
|
|
1370
1366
|
);
|
|
1371
1367
|
function fn(e) {
|
|
1372
|
-
return
|
|
1368
|
+
return Ht().parse(e);
|
|
1373
1369
|
}
|
|
1374
1370
|
class is extends $ {
|
|
1375
1371
|
constructor(t, s, n) {
|
|
@@ -1394,14 +1390,14 @@ class is extends $ {
|
|
|
1394
1390
|
const { hostname: r, pathname: i } = new URL(t, window.location.href);
|
|
1395
1391
|
if (r !== "t.me")
|
|
1396
1392
|
throw new Error(`Incorrect hostname: ${r}`);
|
|
1397
|
-
const
|
|
1398
|
-
if (!
|
|
1393
|
+
const a = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
|
|
1394
|
+
if (!a)
|
|
1399
1395
|
throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
|
|
1400
|
-
[, , n] =
|
|
1396
|
+
[, , n] = a;
|
|
1401
1397
|
}
|
|
1402
1398
|
this.isOpened = !0;
|
|
1403
1399
|
try {
|
|
1404
|
-
return (await
|
|
1400
|
+
return (await g({
|
|
1405
1401
|
method: "web_app_open_invoice",
|
|
1406
1402
|
event: "invoice_closed",
|
|
1407
1403
|
params: { slug: n },
|
|
@@ -1418,9 +1414,9 @@ class is extends $ {
|
|
|
1418
1414
|
const os = l(
|
|
1419
1415
|
({ version: e, postEvent: t }) => new is(!1, e, t)
|
|
1420
1416
|
);
|
|
1421
|
-
class as extends
|
|
1417
|
+
class as extends ct {
|
|
1422
1418
|
constructor({ postEvent: t, ...s }) {
|
|
1423
|
-
super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ?
|
|
1419
|
+
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;
|
|
1424
1420
|
}
|
|
1425
1421
|
/**
|
|
1426
1422
|
* The MainButton background color.
|
|
@@ -1565,36 +1561,36 @@ const cs = l(
|
|
|
1565
1561
|
}) => new as({ ...s, postEvent: e })
|
|
1566
1562
|
);
|
|
1567
1563
|
function hs() {
|
|
1568
|
-
return
|
|
1569
|
-
contact:
|
|
1564
|
+
return pt({
|
|
1565
|
+
contact: w({
|
|
1570
1566
|
userId: {
|
|
1571
|
-
type:
|
|
1567
|
+
type: R(),
|
|
1572
1568
|
from: "user_id"
|
|
1573
1569
|
},
|
|
1574
1570
|
phoneNumber: {
|
|
1575
|
-
type:
|
|
1571
|
+
type: h(),
|
|
1576
1572
|
from: "phone_number"
|
|
1577
1573
|
},
|
|
1578
1574
|
firstName: {
|
|
1579
|
-
type:
|
|
1575
|
+
type: h(),
|
|
1580
1576
|
from: "first_name"
|
|
1581
1577
|
},
|
|
1582
1578
|
lastName: {
|
|
1583
|
-
type:
|
|
1579
|
+
type: h().optional(),
|
|
1584
1580
|
from: "last_name"
|
|
1585
1581
|
}
|
|
1586
1582
|
}),
|
|
1587
1583
|
authDate: {
|
|
1588
|
-
type:
|
|
1584
|
+
type: Lt(),
|
|
1589
1585
|
from: "auth_date"
|
|
1590
1586
|
},
|
|
1591
|
-
hash:
|
|
1587
|
+
hash: h()
|
|
1592
1588
|
}, "RequestedContact");
|
|
1593
1589
|
}
|
|
1594
|
-
function
|
|
1590
|
+
function Xt(e, t) {
|
|
1595
1591
|
return (s) => {
|
|
1596
1592
|
const [n, r] = t[s];
|
|
1597
|
-
return
|
|
1593
|
+
return x(n, r, e);
|
|
1598
1594
|
};
|
|
1599
1595
|
}
|
|
1600
1596
|
function ps(e) {
|
|
@@ -1611,8 +1607,8 @@ class us extends $ {
|
|
|
1611
1607
|
setHeaderColor: "web_app_set_header_color",
|
|
1612
1608
|
setBackgroundColor: "web_app_set_background_color"
|
|
1613
1609
|
}), 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;
|
|
1614
|
-
const
|
|
1615
|
-
this.supports = (
|
|
1610
|
+
const a = this.supports.bind(this);
|
|
1611
|
+
this.supports = (o) => a(o) ? o !== "switchInlineQuery" || r : !1, this.supportsParam = Xt(n, {
|
|
1616
1612
|
"setHeaderColor.color": ["web_app_set_header_color", "color"]
|
|
1617
1613
|
});
|
|
1618
1614
|
}
|
|
@@ -1663,7 +1659,7 @@ class us extends $ {
|
|
|
1663
1659
|
* True if current Mini App background color is recognized as dark.
|
|
1664
1660
|
*/
|
|
1665
1661
|
get isDark() {
|
|
1666
|
-
return
|
|
1662
|
+
return Vt(this.bgColor);
|
|
1667
1663
|
}
|
|
1668
1664
|
/**
|
|
1669
1665
|
* Informs the Telegram app that the Mini App is ready to be displayed.
|
|
@@ -1692,7 +1688,7 @@ class us extends $ {
|
|
|
1692
1688
|
throw new Error("Access denied.");
|
|
1693
1689
|
const s = Date.now() + t;
|
|
1694
1690
|
let n = 50;
|
|
1695
|
-
return
|
|
1691
|
+
return Mt(async () => {
|
|
1696
1692
|
for (; Date.now() < s; ) {
|
|
1697
1693
|
try {
|
|
1698
1694
|
return await this.getRequestedContact();
|
|
@@ -1700,7 +1696,7 @@ class us extends $ {
|
|
|
1700
1696
|
}
|
|
1701
1697
|
await ps(n), n += 50;
|
|
1702
1698
|
}
|
|
1703
|
-
throw
|
|
1699
|
+
throw Bt(t);
|
|
1704
1700
|
}, t);
|
|
1705
1701
|
}
|
|
1706
1702
|
/**
|
|
@@ -1713,7 +1709,7 @@ class us extends $ {
|
|
|
1713
1709
|
* @see requestContact
|
|
1714
1710
|
*/
|
|
1715
1711
|
async requestPhoneAccess(t = {}) {
|
|
1716
|
-
return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise =
|
|
1712
|
+
return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = g({
|
|
1717
1713
|
...t,
|
|
1718
1714
|
method: "web_app_request_phone",
|
|
1719
1715
|
event: "phone_requested",
|
|
@@ -1725,7 +1721,7 @@ class us extends $ {
|
|
|
1725
1721
|
* @param options - additional options.
|
|
1726
1722
|
*/
|
|
1727
1723
|
async requestWriteAccess(t = {}) {
|
|
1728
|
-
return this.requestWriteAccessPromise || (this.requestWriteAccessPromise =
|
|
1724
|
+
return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = g({
|
|
1729
1725
|
...t,
|
|
1730
1726
|
method: "web_app_request_write_access",
|
|
1731
1727
|
event: "write_access_requested",
|
|
@@ -1755,7 +1751,7 @@ class us extends $ {
|
|
|
1755
1751
|
* @param color - color key or RGB color.
|
|
1756
1752
|
*/
|
|
1757
1753
|
setHeaderColor(t) {
|
|
1758
|
-
this.postEvent("web_app_set_header_color",
|
|
1754
|
+
this.postEvent("web_app_set_header_color", ot(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
|
|
1759
1755
|
}
|
|
1760
1756
|
/**
|
|
1761
1757
|
* Updates current Mini App background color.
|
|
@@ -1805,18 +1801,18 @@ function ds(e) {
|
|
|
1805
1801
|
if (n.length > 3)
|
|
1806
1802
|
throw new Error(`Buttons have incorrect size: ${n.length}`);
|
|
1807
1803
|
return n.length ? r = n.map((i) => {
|
|
1808
|
-
const { id:
|
|
1809
|
-
if (
|
|
1810
|
-
throw new Error(`Button ID has incorrect size: ${
|
|
1804
|
+
const { id: a = "" } = i;
|
|
1805
|
+
if (a.length > 64)
|
|
1806
|
+
throw new Error(`Button ID has incorrect size: ${a}`);
|
|
1811
1807
|
if (!i.type || i.type === "default" || i.type === "destructive") {
|
|
1812
|
-
const
|
|
1813
|
-
if (!
|
|
1814
|
-
const
|
|
1815
|
-
throw new Error(`Button text with type "${
|
|
1808
|
+
const o = i.text.trim();
|
|
1809
|
+
if (!o.length || o.length > 64) {
|
|
1810
|
+
const p = i.type || "default";
|
|
1811
|
+
throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
|
|
1816
1812
|
}
|
|
1817
|
-
return { ...i, text:
|
|
1813
|
+
return { ...i, text: o, id: a };
|
|
1818
1814
|
}
|
|
1819
|
-
return { ...i, id:
|
|
1815
|
+
return { ...i, id: a };
|
|
1820
1816
|
}) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
|
|
1821
1817
|
}
|
|
1822
1818
|
class _s extends $ {
|
|
@@ -1848,7 +1844,7 @@ class _s extends $ {
|
|
|
1848
1844
|
throw new Error("Popup is already opened.");
|
|
1849
1845
|
this.isOpened = !0;
|
|
1850
1846
|
try {
|
|
1851
|
-
const { button_id: s = null } = await
|
|
1847
|
+
const { button_id: s = null } = await g({
|
|
1852
1848
|
event: "popup_closed",
|
|
1853
1849
|
method: "web_app_open_popup",
|
|
1854
1850
|
postEvent: this.postEvent,
|
|
@@ -1860,10 +1856,10 @@ class _s extends $ {
|
|
|
1860
1856
|
}
|
|
1861
1857
|
}
|
|
1862
1858
|
}
|
|
1863
|
-
const
|
|
1859
|
+
const ws = l(
|
|
1864
1860
|
({ postEvent: e, version: t }) => new _s(!1, t, e)
|
|
1865
1861
|
);
|
|
1866
|
-
class
|
|
1862
|
+
class gs extends $ {
|
|
1867
1863
|
constructor(t, s, n) {
|
|
1868
1864
|
super({ isOpened: t }, s, {
|
|
1869
1865
|
close: "web_app_close_scan_qr_popup",
|
|
@@ -1885,37 +1881,36 @@ class ws extends $ {
|
|
|
1885
1881
|
get isOpened() {
|
|
1886
1882
|
return this.get("isOpened");
|
|
1887
1883
|
}
|
|
1888
|
-
/**
|
|
1889
|
-
* Opens scanner with specified title shown to user. Method returns promise
|
|
1890
|
-
* with scanned QR content in case, it was scanned. It will contain null in
|
|
1891
|
-
* case, scanner was closed.
|
|
1892
|
-
* @param text - title to display.
|
|
1893
|
-
*/
|
|
1894
1884
|
async open(t) {
|
|
1895
1885
|
if (this.isOpened)
|
|
1896
1886
|
throw new Error("QR scanner is already opened.");
|
|
1887
|
+
const { text: s, capture: n } = (typeof t == "string" ? { text: t } : t) || {};
|
|
1897
1888
|
this.isOpened = !0;
|
|
1898
1889
|
try {
|
|
1899
|
-
|
|
1890
|
+
const r = (await g({
|
|
1900
1891
|
method: "web_app_open_scan_qr_popup",
|
|
1901
1892
|
event: ["qr_text_received", "scan_qr_popup_closed"],
|
|
1902
1893
|
postEvent: this.postEvent,
|
|
1903
|
-
params: { text:
|
|
1894
|
+
params: { text: s },
|
|
1895
|
+
capture(i) {
|
|
1896
|
+
return i.event === "scan_qr_popup_closed" || !n || n(i.payload);
|
|
1897
|
+
}
|
|
1904
1898
|
}) || {}).data || null;
|
|
1905
|
-
|
|
1906
|
-
|
|
1899
|
+
return r && this.close(), r;
|
|
1900
|
+
} catch (r) {
|
|
1901
|
+
throw this.isOpened = !1, r;
|
|
1907
1902
|
}
|
|
1908
1903
|
}
|
|
1909
1904
|
}
|
|
1910
1905
|
const fs = l(
|
|
1911
|
-
({ version: e, postEvent: t }) => new
|
|
1906
|
+
({ version: e, postEvent: t }) => new gs(!1, e, t)
|
|
1912
1907
|
);
|
|
1913
|
-
class ms extends
|
|
1908
|
+
class ms extends ht {
|
|
1914
1909
|
constructor(t, s, n) {
|
|
1915
1910
|
super({ isVisible: t }, s, {
|
|
1916
1911
|
show: "web_app_setup_settings_button",
|
|
1917
1912
|
hide: "web_app_setup_settings_button"
|
|
1918
|
-
}), c(this, "on", (r, i) => r === "click" ?
|
|
1913
|
+
}), c(this, "on", (r, i) => r === "click" ? y("settings_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? z("settings_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
|
|
1919
1914
|
}
|
|
1920
1915
|
set isVisible(t) {
|
|
1921
1916
|
this.set("isVisible", t), this.postEvent("web_app_setup_settings_button", { is_visible: t });
|
|
@@ -1947,10 +1942,10 @@ const bs = l(
|
|
|
1947
1942
|
state: s = { isVisible: !1 }
|
|
1948
1943
|
}) => new ms(s.isVisible, e, t)
|
|
1949
1944
|
);
|
|
1950
|
-
function
|
|
1951
|
-
return
|
|
1945
|
+
function te(e) {
|
|
1946
|
+
return Ut().parse(e);
|
|
1952
1947
|
}
|
|
1953
|
-
class vs extends
|
|
1948
|
+
class vs extends lt {
|
|
1954
1949
|
/**
|
|
1955
1950
|
* @since v6.10
|
|
1956
1951
|
*/
|
|
@@ -1989,7 +1984,7 @@ class vs extends ct {
|
|
|
1989
1984
|
* value is calculated according to theme bg color.
|
|
1990
1985
|
*/
|
|
1991
1986
|
get isDark() {
|
|
1992
|
-
return !this.bgColor ||
|
|
1987
|
+
return !this.bgColor || Vt(this.bgColor);
|
|
1993
1988
|
}
|
|
1994
1989
|
get linkColor() {
|
|
1995
1990
|
return this.get("linkColor");
|
|
@@ -2014,8 +2009,8 @@ class vs extends ct {
|
|
|
2014
2009
|
* @returns Function to stop listening.
|
|
2015
2010
|
*/
|
|
2016
2011
|
listen() {
|
|
2017
|
-
return
|
|
2018
|
-
this.set(
|
|
2012
|
+
return y("theme_changed", (t) => {
|
|
2013
|
+
this.set(te(t.theme_params));
|
|
2019
2014
|
});
|
|
2020
2015
|
}
|
|
2021
2016
|
/**
|
|
@@ -2036,15 +2031,15 @@ const ys = l(
|
|
|
2036
2031
|
}
|
|
2037
2032
|
);
|
|
2038
2033
|
function mn(e = {}) {
|
|
2039
|
-
return
|
|
2034
|
+
return g({
|
|
2040
2035
|
...e,
|
|
2041
2036
|
method: "web_app_request_theme",
|
|
2042
2037
|
event: "theme_changed"
|
|
2043
|
-
}).then(
|
|
2038
|
+
}).then(te);
|
|
2044
2039
|
}
|
|
2045
|
-
class Es extends
|
|
2040
|
+
class Es extends dt {
|
|
2046
2041
|
constructor(t, s, n) {
|
|
2047
|
-
super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam =
|
|
2042
|
+
super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Xt(t, {
|
|
2048
2043
|
"openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
|
|
2049
2044
|
});
|
|
2050
2045
|
}
|
|
@@ -2059,7 +2054,7 @@ class Es extends ht {
|
|
|
2059
2054
|
*/
|
|
2060
2055
|
openLink(t, s) {
|
|
2061
2056
|
const n = new URL(t, window.location.href).toString();
|
|
2062
|
-
if (!
|
|
2057
|
+
if (!x("web_app_open_link", this.version)) {
|
|
2063
2058
|
window.open(n, "_blank");
|
|
2064
2059
|
return;
|
|
2065
2060
|
}
|
|
@@ -2078,7 +2073,7 @@ class Es extends ht {
|
|
|
2078
2073
|
const { hostname: s, pathname: n, search: r } = new URL(t, window.location.href);
|
|
2079
2074
|
if (s !== "t.me")
|
|
2080
2075
|
throw new Error(`URL has not allowed hostname: ${s}. Only "t.me" is allowed`);
|
|
2081
|
-
if (!
|
|
2076
|
+
if (!x("web_app_open_tg_link", this.version)) {
|
|
2082
2077
|
window.location.href = t;
|
|
2083
2078
|
return;
|
|
2084
2079
|
}
|
|
@@ -2093,12 +2088,12 @@ class Es extends ht {
|
|
|
2093
2088
|
async readTextFromClipboard() {
|
|
2094
2089
|
const t = this.createRequestId(), {
|
|
2095
2090
|
data: s = null
|
|
2096
|
-
} = await
|
|
2091
|
+
} = await g({
|
|
2097
2092
|
method: "web_app_read_text_from_clipboard",
|
|
2098
2093
|
event: "clipboard_text_received",
|
|
2099
2094
|
postEvent: this.postEvent,
|
|
2100
2095
|
params: { req_id: t },
|
|
2101
|
-
capture:
|
|
2096
|
+
capture: Dt(t)
|
|
2102
2097
|
});
|
|
2103
2098
|
return s;
|
|
2104
2099
|
}
|
|
@@ -2106,12 +2101,12 @@ class Es extends ht {
|
|
|
2106
2101
|
const Ps = l(
|
|
2107
2102
|
({ version: e, postEvent: t, createRequestId: s }) => new Es(e, s, t)
|
|
2108
2103
|
);
|
|
2109
|
-
async function
|
|
2104
|
+
async function ee(e = {}) {
|
|
2110
2105
|
const {
|
|
2111
2106
|
is_expanded: t,
|
|
2112
2107
|
is_state_stable: s,
|
|
2113
2108
|
...n
|
|
2114
|
-
} = await
|
|
2109
|
+
} = await g({
|
|
2115
2110
|
...e,
|
|
2116
2111
|
method: "web_app_request_viewport",
|
|
2117
2112
|
event: "viewport_changed"
|
|
@@ -2121,7 +2116,7 @@ async function Qt(e = {}) {
|
|
|
2121
2116
|
function q(e) {
|
|
2122
2117
|
return e < 0 ? 0 : e;
|
|
2123
2118
|
}
|
|
2124
|
-
class Rs extends
|
|
2119
|
+
class Rs extends lt {
|
|
2125
2120
|
constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
|
|
2126
2121
|
super({
|
|
2127
2122
|
height: q(n),
|
|
@@ -2136,7 +2131,7 @@ class Rs extends ct {
|
|
|
2136
2131
|
* @param options - options to request fresh data.
|
|
2137
2132
|
*/
|
|
2138
2133
|
async sync(t) {
|
|
2139
|
-
const { isStateStable: s, ...n } = await
|
|
2134
|
+
const { isStateStable: s, ...n } = await ee(t);
|
|
2140
2135
|
this.set({
|
|
2141
2136
|
...n,
|
|
2142
2137
|
stableHeight: s ? n.height : this.get("stableHeight")
|
|
@@ -2183,18 +2178,18 @@ class Rs extends ct {
|
|
|
2183
2178
|
* @returns Function to stop listening.
|
|
2184
2179
|
*/
|
|
2185
2180
|
listen() {
|
|
2186
|
-
return
|
|
2181
|
+
return y("viewport_changed", (t) => {
|
|
2187
2182
|
const {
|
|
2188
2183
|
height: s,
|
|
2189
2184
|
width: n,
|
|
2190
2185
|
is_expanded: r,
|
|
2191
2186
|
is_state_stable: i
|
|
2192
|
-
} = t,
|
|
2187
|
+
} = t, a = q(s);
|
|
2193
2188
|
this.set({
|
|
2194
|
-
height:
|
|
2189
|
+
height: a,
|
|
2195
2190
|
isExpanded: r,
|
|
2196
2191
|
width: q(n),
|
|
2197
|
-
...i ? { stableHeight:
|
|
2192
|
+
...i ? { stableHeight: a } : {}
|
|
2198
2193
|
});
|
|
2199
2194
|
});
|
|
2200
2195
|
}
|
|
@@ -2231,77 +2226,77 @@ class Rs extends ct {
|
|
|
2231
2226
|
const xs = l(
|
|
2232
2227
|
"viewport",
|
|
2233
2228
|
async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
|
|
2234
|
-
let r = !1, i = 0,
|
|
2229
|
+
let r = !1, i = 0, a = 0, o = 0;
|
|
2235
2230
|
if (e)
|
|
2236
|
-
r = e.isExpanded, i = e.height,
|
|
2231
|
+
r = e.isExpanded, i = e.height, a = e.width, o = e.stableHeight;
|
|
2237
2232
|
else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
|
|
2238
|
-
r = !0, i = window.innerHeight,
|
|
2233
|
+
r = !0, i = window.innerHeight, a = window.innerWidth, o = window.innerHeight;
|
|
2239
2234
|
else {
|
|
2240
|
-
const
|
|
2241
|
-
r =
|
|
2235
|
+
const u = await ee({ timeout: 1e3, postEvent: s });
|
|
2236
|
+
r = u.isExpanded, i = u.height, a = u.width, o = u.isStateStable ? i : 0;
|
|
2242
2237
|
}
|
|
2243
|
-
const
|
|
2238
|
+
const p = new Rs({
|
|
2244
2239
|
postEvent: s,
|
|
2245
2240
|
height: i,
|
|
2246
|
-
width:
|
|
2247
|
-
stableHeight:
|
|
2241
|
+
width: a,
|
|
2242
|
+
stableHeight: o,
|
|
2248
2243
|
isExpanded: r
|
|
2249
2244
|
});
|
|
2250
|
-
return n(
|
|
2245
|
+
return n(p.listen()), p;
|
|
2251
2246
|
}
|
|
2252
2247
|
);
|
|
2253
|
-
function
|
|
2248
|
+
function P(e, t) {
|
|
2254
2249
|
document.documentElement.style.setProperty(e, t);
|
|
2255
2250
|
}
|
|
2256
2251
|
function bn(e, t, s) {
|
|
2257
|
-
s || (s = (
|
|
2252
|
+
s || (s = (o) => `--tg-${o}-color`);
|
|
2258
2253
|
const n = s("header"), r = s("bg"), i = () => {
|
|
2259
|
-
const { headerColor:
|
|
2260
|
-
if (
|
|
2261
|
-
|
|
2254
|
+
const { headerColor: o } = e;
|
|
2255
|
+
if (ot(o))
|
|
2256
|
+
P(n, o);
|
|
2262
2257
|
else {
|
|
2263
|
-
const { bgColor:
|
|
2264
|
-
|
|
2258
|
+
const { bgColor: p, secondaryBgColor: u } = t;
|
|
2259
|
+
o === "bg_color" && p ? P(n, p) : o === "secondary_bg_color" && u && P(n, u);
|
|
2265
2260
|
}
|
|
2266
|
-
|
|
2267
|
-
},
|
|
2261
|
+
P(r, e.bgColor);
|
|
2262
|
+
}, a = [
|
|
2268
2263
|
t.on("change", i),
|
|
2269
2264
|
e.on("change", i)
|
|
2270
2265
|
];
|
|
2271
|
-
return i(), () =>
|
|
2266
|
+
return i(), () => a.forEach((o) => o());
|
|
2272
2267
|
}
|
|
2273
2268
|
function vn(e, t) {
|
|
2274
2269
|
t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
|
|
2275
2270
|
const s = () => {
|
|
2276
2271
|
Object.entries(e.getState()).forEach(([n, r]) => {
|
|
2277
|
-
r &&
|
|
2272
|
+
r && P(t(n), r);
|
|
2278
2273
|
});
|
|
2279
2274
|
};
|
|
2280
2275
|
return s(), e.on("change", s);
|
|
2281
2276
|
}
|
|
2282
2277
|
function yn(e, t) {
|
|
2283
|
-
t || (t = (
|
|
2278
|
+
t || (t = (u) => `--tg-viewport-${u}`);
|
|
2284
2279
|
const [
|
|
2285
2280
|
s,
|
|
2286
2281
|
n,
|
|
2287
2282
|
r
|
|
2288
|
-
] = ["height", "width", "stable-height"].map((
|
|
2283
|
+
] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => P(s, `${e.height}px`), a = () => P(n, `${e.width}px`), o = () => P(r, `${e.stableHeight}px`), p = [
|
|
2289
2284
|
e.on("change:height", i),
|
|
2290
|
-
e.on("change:width",
|
|
2291
|
-
e.on("change:stableHeight",
|
|
2285
|
+
e.on("change:width", a),
|
|
2286
|
+
e.on("change:stableHeight", o)
|
|
2292
2287
|
];
|
|
2293
|
-
return i(),
|
|
2288
|
+
return i(), a(), o(), () => p.forEach((u) => u());
|
|
2294
2289
|
}
|
|
2295
2290
|
function Cs(e = !0) {
|
|
2296
2291
|
const t = [
|
|
2297
|
-
|
|
2292
|
+
y("reload_iframe", () => {
|
|
2298
2293
|
B("iframe_will_reload"), window.location.reload();
|
|
2299
2294
|
})
|
|
2300
2295
|
], s = () => t.forEach((n) => n());
|
|
2301
2296
|
if (e) {
|
|
2302
2297
|
const n = document.createElement("style");
|
|
2303
2298
|
n.id = "telegram-custom-styles", document.head.appendChild(n), t.push(
|
|
2304
|
-
|
|
2299
|
+
y("set_custom_style", (r) => {
|
|
2305
2300
|
n.innerHTML = r;
|
|
2306
2301
|
}),
|
|
2307
2302
|
() => document.head.removeChild(n)
|
|
@@ -2313,18 +2308,58 @@ function Ss() {
|
|
|
2313
2308
|
return typeof window > "u";
|
|
2314
2309
|
}
|
|
2315
2310
|
async function En() {
|
|
2316
|
-
if (
|
|
2311
|
+
if (Ot(window))
|
|
2317
2312
|
return !0;
|
|
2318
2313
|
try {
|
|
2319
|
-
return await
|
|
2314
|
+
return await g({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
|
|
2320
2315
|
} catch {
|
|
2321
2316
|
return !1;
|
|
2322
2317
|
}
|
|
2323
2318
|
}
|
|
2319
|
+
function Pn(e) {
|
|
2320
|
+
const t = typeof e == "string" ? ut(e) : e;
|
|
2321
|
+
Ft(t);
|
|
2322
|
+
function s(r) {
|
|
2323
|
+
if (typeof r == "string")
|
|
2324
|
+
try {
|
|
2325
|
+
const { eventType: i } = kt(r);
|
|
2326
|
+
i === "web_app_request_theme" && et("theme_changed", {
|
|
2327
|
+
theme_params: JSON.parse(Jt(t.themeParams))
|
|
2328
|
+
}), i === "web_app_request_viewport" && et("viewport_changed", {
|
|
2329
|
+
width: window.innerWidth,
|
|
2330
|
+
height: window.innerHeight,
|
|
2331
|
+
is_state_stable: !0,
|
|
2332
|
+
is_expanded: !0
|
|
2333
|
+
});
|
|
2334
|
+
} catch {
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
if (at()) {
|
|
2338
|
+
const r = window.parent.postMessage.bind(window.parent);
|
|
2339
|
+
window.parent.postMessage = (i) => {
|
|
2340
|
+
s(i), r(i);
|
|
2341
|
+
};
|
|
2342
|
+
return;
|
|
2343
|
+
}
|
|
2344
|
+
if (qt(window)) {
|
|
2345
|
+
const r = window.external.notify.bind(window.external);
|
|
2346
|
+
window.external.notify = (i) => {
|
|
2347
|
+
s(i), r(i);
|
|
2348
|
+
};
|
|
2349
|
+
return;
|
|
2350
|
+
}
|
|
2351
|
+
const n = window.TelegramWebviewProxy;
|
|
2352
|
+
window.TelegramWebviewProxy = {
|
|
2353
|
+
...n || {},
|
|
2354
|
+
postEvent(...r) {
|
|
2355
|
+
s(JSON.stringify({ eventType: r[0], eventData: r[1] })), n && n.postEvent(...r);
|
|
2356
|
+
}
|
|
2357
|
+
};
|
|
2358
|
+
}
|
|
2324
2359
|
function Ts(e) {
|
|
2325
2360
|
return e instanceof W;
|
|
2326
2361
|
}
|
|
2327
|
-
function
|
|
2362
|
+
function Rn(e, t) {
|
|
2328
2363
|
return Ts(e) && e.type === t;
|
|
2329
2364
|
}
|
|
2330
2365
|
function J(e, t) {
|
|
@@ -2337,11 +2372,11 @@ function J(e, t) {
|
|
|
2337
2372
|
}
|
|
2338
2373
|
class As {
|
|
2339
2374
|
constructor(t, s, n = B) {
|
|
2340
|
-
if (c(this, "history"), c(this, "ee", new
|
|
2341
|
-
throw m(
|
|
2375
|
+
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)
|
|
2376
|
+
throw m(ve, "History should not be empty.");
|
|
2342
2377
|
if (s < 0 || s >= t.length)
|
|
2343
2378
|
throw m(
|
|
2344
|
-
|
|
2379
|
+
ye,
|
|
2345
2380
|
"Index should not be zero and higher or equal than history size."
|
|
2346
2381
|
);
|
|
2347
2382
|
this.history = t.map((r) => J(r, ""));
|
|
@@ -2351,7 +2386,7 @@ class As {
|
|
|
2351
2386
|
* `BackButton` clicks and calls the `back` method.
|
|
2352
2387
|
*/
|
|
2353
2388
|
attach() {
|
|
2354
|
-
this.attached || (this.attached = !0, this.sync(),
|
|
2389
|
+
this.attached || (this.attached = !0, this.sync(), y("back_button_pressed", this.back));
|
|
2355
2390
|
}
|
|
2356
2391
|
/**
|
|
2357
2392
|
* Currently active history item.
|
|
@@ -2478,10 +2513,10 @@ function U(e) {
|
|
|
2478
2513
|
function Q(e, t, s) {
|
|
2479
2514
|
let n, r;
|
|
2480
2515
|
typeof e == "string" ? n = e : (n = U(e), s = e.state, r = e.id);
|
|
2481
|
-
const { pathname: i, search:
|
|
2482
|
-
return { id: r, pathname: i, params: { hash:
|
|
2516
|
+
const { pathname: i, search: a, hash: o } = new URL(n, `http://a${M(t, "/")}`);
|
|
2517
|
+
return { id: r, pathname: i, params: { hash: o, search: a, state: s } };
|
|
2483
2518
|
}
|
|
2484
|
-
async function
|
|
2519
|
+
async function N(e) {
|
|
2485
2520
|
return e === 0 ? !0 : Promise.race([
|
|
2486
2521
|
new Promise((t) => {
|
|
2487
2522
|
const s = tt("popstate", () => {
|
|
@@ -2496,38 +2531,38 @@ async function D(e) {
|
|
|
2496
2531
|
]);
|
|
2497
2532
|
}
|
|
2498
2533
|
async function Is() {
|
|
2499
|
-
if (window.history.length <= 1 || (window.history.pushState(null, ""), await
|
|
2534
|
+
if (window.history.length <= 1 || (window.history.pushState(null, ""), await N(1 - window.history.length)))
|
|
2500
2535
|
return;
|
|
2501
|
-
let e = await
|
|
2536
|
+
let e = await N(-1);
|
|
2502
2537
|
for (; e; )
|
|
2503
|
-
e = await
|
|
2538
|
+
e = await N(-1);
|
|
2504
2539
|
}
|
|
2505
|
-
function
|
|
2540
|
+
function se(e) {
|
|
2506
2541
|
return H(e).pathname;
|
|
2507
2542
|
}
|
|
2508
|
-
const
|
|
2509
|
-
class
|
|
2543
|
+
const yt = 0, Y = 1, Z = 2;
|
|
2544
|
+
class ne {
|
|
2510
2545
|
constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
|
|
2511
|
-
c(this, "navigator"), c(this, "ee", new
|
|
2512
|
-
if (
|
|
2546
|
+
c(this, "navigator"), c(this, "ee", new D()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: a }) => {
|
|
2547
|
+
if (a === null)
|
|
2513
2548
|
return this.push(this.parsePath(window.location.href));
|
|
2514
|
-
|
|
2549
|
+
a === yt ? window.history.forward() : a === Y && this.back(), a === Z && this.forward();
|
|
2515
2550
|
}), c(this, "onNavigatorChange", async ({
|
|
2516
|
-
to:
|
|
2517
|
-
from:
|
|
2518
|
-
delta:
|
|
2551
|
+
to: a,
|
|
2552
|
+
from: o,
|
|
2553
|
+
delta: p
|
|
2519
2554
|
}) => {
|
|
2520
2555
|
this.attached && await this.syncHistory(), this.ee.emit("change", {
|
|
2521
|
-
delta:
|
|
2522
|
-
from: F(
|
|
2523
|
-
to: F(
|
|
2556
|
+
delta: p,
|
|
2557
|
+
from: F(o),
|
|
2558
|
+
to: F(a),
|
|
2524
2559
|
navigator: this
|
|
2525
2560
|
});
|
|
2526
2561
|
}), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new As(
|
|
2527
|
-
t.map((
|
|
2562
|
+
t.map((a) => Q(a, "/")),
|
|
2528
2563
|
s,
|
|
2529
2564
|
n
|
|
2530
|
-
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base =
|
|
2565
|
+
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = se(i || "");
|
|
2531
2566
|
}
|
|
2532
2567
|
/**
|
|
2533
2568
|
* Attaches current navigator to the browser history allowing navigator to manipulate it.
|
|
@@ -2684,7 +2719,7 @@ class Zt {
|
|
|
2684
2719
|
async syncHistory() {
|
|
2685
2720
|
window.removeEventListener("popstate", this.onPopState);
|
|
2686
2721
|
const { state: t } = this, s = this.renderPath(this);
|
|
2687
|
-
await Is(), this.hasPrev && this.hasNext ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s), window.history.pushState(Z, ""), await
|
|
2722
|
+
await Is(), 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(yt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
|
|
2688
2723
|
}
|
|
2689
2724
|
/**
|
|
2690
2725
|
* Current query parameters.
|
|
@@ -2708,35 +2743,35 @@ function ks(e) {
|
|
|
2708
2743
|
let n = U(
|
|
2709
2744
|
e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
|
|
2710
2745
|
);
|
|
2711
|
-
const r = e.base ?
|
|
2746
|
+
const r = e.base ? se(e.base) : void 0;
|
|
2712
2747
|
if (r) {
|
|
2713
2748
|
if (!n.startsWith(r))
|
|
2714
2749
|
throw m(
|
|
2715
|
-
|
|
2750
|
+
Ee,
|
|
2716
2751
|
`Path "${n}" expected to be starting with "${r}"`
|
|
2717
2752
|
);
|
|
2718
2753
|
n = n.slice(r.length);
|
|
2719
2754
|
}
|
|
2720
|
-
return new
|
|
2755
|
+
return new ne([n], 0, e);
|
|
2721
2756
|
}
|
|
2722
|
-
function
|
|
2757
|
+
function xn(e) {
|
|
2723
2758
|
const t = e.match(/#(.+)/);
|
|
2724
2759
|
return t ? t[1] : null;
|
|
2725
2760
|
}
|
|
2726
2761
|
function qs(e, t) {
|
|
2727
|
-
if (
|
|
2762
|
+
if (Yt()) {
|
|
2728
2763
|
const s = sessionStorage.getItem(e);
|
|
2729
2764
|
if (s)
|
|
2730
2765
|
try {
|
|
2731
2766
|
const { index: n, history: r } = JSON.parse(s);
|
|
2732
|
-
return new
|
|
2767
|
+
return new ne(r, n, t);
|
|
2733
2768
|
} catch (n) {
|
|
2734
2769
|
console.error("Unable to restore hash navigator state.", n);
|
|
2735
2770
|
}
|
|
2736
2771
|
}
|
|
2737
2772
|
return ks(t);
|
|
2738
2773
|
}
|
|
2739
|
-
function
|
|
2774
|
+
function Cn(e, t) {
|
|
2740
2775
|
const s = qs(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
|
|
2741
2776
|
index: s.index,
|
|
2742
2777
|
history: s.history
|
|
@@ -2745,28 +2780,28 @@ function xn(e, t) {
|
|
|
2745
2780
|
}
|
|
2746
2781
|
function d(e, t) {
|
|
2747
2782
|
function s(n) {
|
|
2748
|
-
return function(i,
|
|
2749
|
-
return (
|
|
2750
|
-
const
|
|
2751
|
-
...
|
|
2752
|
-
[i]: n(
|
|
2783
|
+
return function(i, a, o) {
|
|
2784
|
+
return (p) => {
|
|
2785
|
+
const u = {
|
|
2786
|
+
...p,
|
|
2787
|
+
[i]: n(a)
|
|
2753
2788
|
};
|
|
2754
|
-
return /* @__PURE__ */
|
|
2789
|
+
return /* @__PURE__ */ Et(o, { ...u });
|
|
2755
2790
|
};
|
|
2756
2791
|
};
|
|
2757
2792
|
}
|
|
2758
2793
|
return [s(e), s(t)];
|
|
2759
2794
|
}
|
|
2760
|
-
const
|
|
2795
|
+
const re = ie(void 0);
|
|
2761
2796
|
function Os() {
|
|
2762
|
-
const e =
|
|
2797
|
+
const e = oe(re);
|
|
2763
2798
|
if (!e)
|
|
2764
2799
|
throw new Error("useSDK was used outside the SDKProvider.");
|
|
2765
2800
|
return e;
|
|
2766
2801
|
}
|
|
2767
2802
|
function _(e) {
|
|
2768
2803
|
function t(n) {
|
|
2769
|
-
const r = Os(), [i,
|
|
2804
|
+
const r = Os(), [i, a] = Pt(
|
|
2770
2805
|
n ? void 0 : () => {
|
|
2771
2806
|
if (Ss())
|
|
2772
2807
|
throw new Error("Using hooks on the server side, you must explicitly specify ssr = true option");
|
|
@@ -2774,7 +2809,7 @@ function _(e) {
|
|
|
2774
2809
|
}
|
|
2775
2810
|
);
|
|
2776
2811
|
return S(() => {
|
|
2777
|
-
|
|
2812
|
+
a(r.use(e));
|
|
2778
2813
|
}, [r]), i;
|
|
2779
2814
|
}
|
|
2780
2815
|
function s(n) {
|
|
@@ -2787,113 +2822,113 @@ function _(e) {
|
|
|
2787
2822
|
}
|
|
2788
2823
|
return [t, s];
|
|
2789
2824
|
}
|
|
2790
|
-
const [
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
), [Bs, Ms] = _(Ke), [
|
|
2825
|
+
const [Ns, Ds] = _(Ge), [Sn, Tn] = d(
|
|
2826
|
+
Ns,
|
|
2827
|
+
Ds
|
|
2828
|
+
), [Bs, Ms] = _(Ke), [An, In] = d(
|
|
2794
2829
|
Bs,
|
|
2795
2830
|
Ms
|
|
2796
|
-
), [Vs, $s] = _(Fe), [
|
|
2831
|
+
), [Vs, $s] = _(Fe), [kn, qn] = d(
|
|
2797
2832
|
Vs,
|
|
2798
2833
|
$s
|
|
2799
|
-
), [Ls, Hs] = _(ts), [
|
|
2834
|
+
), [Ls, Hs] = _(ts), [On, Nn] = d(
|
|
2800
2835
|
Ls,
|
|
2801
2836
|
Hs
|
|
2802
|
-
), [Us, Ws] = _(ss), [Dn,
|
|
2837
|
+
), [Us, Ws] = _(ss), [Dn, Bn] = d(
|
|
2803
2838
|
Us,
|
|
2804
2839
|
Ws
|
|
2805
|
-
), [Gs, js] = _(rs), [
|
|
2840
|
+
), [Gs, js] = _(rs), [Mn, Vn] = d(Gs, js), [zs, Ks] = _(os), [$n, Ln] = d(zs, Ks), [Js, Fs] = _(cs), [Hn, Un] = d(Js, Fs), [Qs, Ys] = _(ls), [Wn, Gn] = d(Qs, Ys), [Zs, Xs] = _(ws), [jn, zn] = d(Zs, Xs), [tn, en] = _(fs), [Kn, Jn] = d(tn, en), [sn, nn] = _(bs), [Fn, Qn] = d(
|
|
2806
2841
|
sn,
|
|
2807
2842
|
nn
|
|
2808
|
-
), [rn, on] = _(ys), [
|
|
2809
|
-
function
|
|
2810
|
-
return
|
|
2811
|
-
}
|
|
2812
|
-
const [an, cn] = _(Ps), [
|
|
2813
|
-
function
|
|
2814
|
-
const n =
|
|
2815
|
-
(
|
|
2816
|
-
n.current && i((
|
|
2843
|
+
), [rn, on] = _(ys), [Yn, Zn] = d(rn, on);
|
|
2844
|
+
function Xn() {
|
|
2845
|
+
return Rt(Qt, []);
|
|
2846
|
+
}
|
|
2847
|
+
const [an, cn] = _(Ps), [tr, er] = d(an, cn), [hn, pn] = _(xs), [sr, nr] = d(hn, pn);
|
|
2848
|
+
function rr({ children: e, acceptCustomStyles: t, debug: s }) {
|
|
2849
|
+
const n = ft(!0), [r, i] = Pt(/* @__PURE__ */ new Map()), a = ft(r), o = ae(
|
|
2850
|
+
(u) => {
|
|
2851
|
+
n.current && i((C) => (u && u(C), new Map(C)));
|
|
2817
2852
|
},
|
|
2818
2853
|
[]
|
|
2819
|
-
),
|
|
2820
|
-
use(
|
|
2821
|
-
const
|
|
2822
|
-
if (
|
|
2823
|
-
return
|
|
2854
|
+
), p = Rt(() => ({
|
|
2855
|
+
use(u, ...C) {
|
|
2856
|
+
const _t = r.get(u);
|
|
2857
|
+
if (_t)
|
|
2858
|
+
return _t;
|
|
2824
2859
|
let b, K;
|
|
2825
2860
|
try {
|
|
2826
|
-
b =
|
|
2861
|
+
b = u(...C);
|
|
2827
2862
|
} catch (f) {
|
|
2828
2863
|
K = f;
|
|
2829
2864
|
}
|
|
2830
2865
|
function L(f) {
|
|
2831
|
-
return r.set(
|
|
2866
|
+
return r.set(u, f), f;
|
|
2832
2867
|
}
|
|
2833
2868
|
if (K)
|
|
2834
2869
|
return L({ error: K });
|
|
2835
2870
|
let I;
|
|
2836
2871
|
if (Array.isArray(b) && (I = b[1], b = b[0]), !b)
|
|
2837
2872
|
return L({ result: b, cleanup: I });
|
|
2838
|
-
function
|
|
2873
|
+
function wt(f) {
|
|
2839
2874
|
if ("on" in f) {
|
|
2840
|
-
const k = f.on("change", () =>
|
|
2875
|
+
const k = f.on("change", () => o()), gt = I;
|
|
2841
2876
|
I = () => {
|
|
2842
|
-
|
|
2877
|
+
gt && gt(), k();
|
|
2843
2878
|
};
|
|
2844
2879
|
}
|
|
2845
2880
|
return { result: f, cleanup: I };
|
|
2846
2881
|
}
|
|
2847
2882
|
return b instanceof Promise ? (b.then(
|
|
2848
|
-
(f) =>
|
|
2849
|
-
(f) =>
|
|
2850
|
-
), L({})) : L(
|
|
2883
|
+
(f) => o((k) => k.set(u, wt(f))),
|
|
2884
|
+
(f) => o((k) => k.set(u, { error: f }))
|
|
2885
|
+
), L({})) : L(wt(b));
|
|
2851
2886
|
}
|
|
2852
2887
|
}), [r]);
|
|
2853
2888
|
return S(() => (n.current = !0, () => {
|
|
2854
2889
|
n.current = !1;
|
|
2855
2890
|
}), []), S(() => {
|
|
2856
|
-
if (
|
|
2891
|
+
if (at())
|
|
2857
2892
|
return Cs(t);
|
|
2858
2893
|
}, [t]), S(() => {
|
|
2859
|
-
|
|
2894
|
+
le(s || !1);
|
|
2860
2895
|
}, [s]), S(() => {
|
|
2861
|
-
|
|
2896
|
+
a.current = r;
|
|
2862
2897
|
}, [r]), S(() => () => {
|
|
2863
|
-
|
|
2864
|
-
"cleanup" in
|
|
2898
|
+
a.current.forEach((u) => {
|
|
2899
|
+
"cleanup" in u && u.cleanup && u.cleanup();
|
|
2865
2900
|
});
|
|
2866
|
-
}, []), /* @__PURE__ */
|
|
2901
|
+
}, []), /* @__PURE__ */ Et(re.Provider, { value: p, children: e });
|
|
2867
2902
|
}
|
|
2868
2903
|
export {
|
|
2869
|
-
|
|
2904
|
+
Ne as BackButton,
|
|
2870
2905
|
As as BasicNavigator,
|
|
2871
2906
|
je as BiometryManager,
|
|
2872
|
-
|
|
2907
|
+
ne as BrowserNavigator,
|
|
2873
2908
|
Je as ClosingBehavior,
|
|
2874
2909
|
Xe as CloudStorage,
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2910
|
+
Ee as ERR_INVALID_PATH_BASE,
|
|
2911
|
+
fe as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
|
|
2912
|
+
we as ERR_METHOD_PARAMETER_UNSUPPORTED,
|
|
2913
|
+
_e as ERR_METHOD_UNSUPPORTED,
|
|
2914
|
+
ve as ERR_NAVIGATION_HISTORY_EMPTY,
|
|
2915
|
+
ye as ERR_NAVIGATION_INDEX_INVALID,
|
|
2881
2916
|
dn as ERR_NAVIGATION_ITEM_INVALID,
|
|
2882
|
-
|
|
2917
|
+
St as ERR_PARSE,
|
|
2883
2918
|
_n as ERR_SSR_INIT,
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2919
|
+
me as ERR_TIMED_OUT,
|
|
2920
|
+
be as ERR_UNEXPECTED_TYPE,
|
|
2921
|
+
ge as ERR_UNKNOWN_ENV,
|
|
2922
|
+
D as EventEmitter,
|
|
2888
2923
|
es as HapticFeedback,
|
|
2889
2924
|
ns as InitData,
|
|
2890
2925
|
is as Invoice,
|
|
2891
2926
|
as as MainButton,
|
|
2892
2927
|
us as MiniApp,
|
|
2893
2928
|
_s as Popup,
|
|
2894
|
-
|
|
2929
|
+
gs as QRScanner,
|
|
2895
2930
|
W as SDKError,
|
|
2896
|
-
|
|
2931
|
+
rr as SDKProvider,
|
|
2897
2932
|
ms as SettingsButton,
|
|
2898
2933
|
vs as ThemeParams,
|
|
2899
2934
|
Es as Utils,
|
|
@@ -2902,16 +2937,16 @@ export {
|
|
|
2902
2937
|
bn as bindMiniAppCSSVars,
|
|
2903
2938
|
vn as bindThemeParamsCSSVars,
|
|
2904
2939
|
yn as bindViewportCSSVars,
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2940
|
+
E as boolean,
|
|
2941
|
+
Dt as captureSameReq,
|
|
2942
|
+
st as classNames,
|
|
2943
|
+
Ie as compareVersions,
|
|
2909
2944
|
ks as createBrowserNavigatorFromLocation,
|
|
2910
|
-
|
|
2945
|
+
qe as createPostEvent,
|
|
2911
2946
|
H as createSafeURL,
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2947
|
+
Lt as date,
|
|
2948
|
+
xn as getHash,
|
|
2949
|
+
se as getPathname,
|
|
2915
2950
|
Ge as initBackButton,
|
|
2916
2951
|
Ke as initBiometryManager,
|
|
2917
2952
|
Fe as initClosingBehavior,
|
|
@@ -2921,8 +2956,8 @@ export {
|
|
|
2921
2956
|
os as initInvoice,
|
|
2922
2957
|
cs as initMainButton,
|
|
2923
2958
|
ls as initMiniApp,
|
|
2924
|
-
|
|
2925
|
-
|
|
2959
|
+
Cn as initNavigator,
|
|
2960
|
+
ws as initPopup,
|
|
2926
2961
|
fs as initQRScanner,
|
|
2927
2962
|
bs as initSettingsButton,
|
|
2928
2963
|
ys as initThemeParams,
|
|
@@ -2930,45 +2965,46 @@ export {
|
|
|
2930
2965
|
xs as initViewport,
|
|
2931
2966
|
Cs as initWeb,
|
|
2932
2967
|
O as invokeCustomMethod,
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2968
|
+
Vt as isColorDark,
|
|
2969
|
+
at as isIframe,
|
|
2970
|
+
Yt as isPageReload,
|
|
2971
|
+
ot as isRGB,
|
|
2972
|
+
Pe as isRGBShort,
|
|
2938
2973
|
Ts as isSDKError,
|
|
2939
|
-
|
|
2974
|
+
Rn as isSDKErrorOfType,
|
|
2940
2975
|
Ss as isSSR,
|
|
2941
2976
|
En as isTMA,
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2977
|
+
w as json,
|
|
2978
|
+
gn as mergeClassNames,
|
|
2979
|
+
Pn as mockTelegramEnv,
|
|
2980
|
+
R as number,
|
|
2945
2981
|
z as off,
|
|
2946
|
-
|
|
2982
|
+
y as on,
|
|
2947
2983
|
fn as parseInitData,
|
|
2948
|
-
|
|
2949
|
-
|
|
2984
|
+
ut as parseLaunchParams,
|
|
2985
|
+
te as parseThemeParams,
|
|
2950
2986
|
B as postEvent,
|
|
2951
|
-
|
|
2987
|
+
g as request,
|
|
2952
2988
|
ze as requestBiometryInfo,
|
|
2953
2989
|
mn as requestThemeParams,
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2990
|
+
ee as requestViewport,
|
|
2991
|
+
Qt as retrieveLaunchParams,
|
|
2992
|
+
It as rgb,
|
|
2993
|
+
pt as searchParams,
|
|
2994
|
+
He as serializeLaunchParams,
|
|
2995
|
+
Jt as serializeThemeParams,
|
|
2996
|
+
P as setCSSVar,
|
|
2997
|
+
le as setDebug,
|
|
2998
|
+
wn as setTargetOrigin,
|
|
2999
|
+
h as string,
|
|
3000
|
+
pe as subscribe,
|
|
3001
|
+
x as supports,
|
|
3002
|
+
ke as targetOrigin,
|
|
3003
|
+
At as toRGB,
|
|
3004
|
+
Ct as unsubscribe,
|
|
2969
3005
|
U as urlToPath,
|
|
2970
|
-
|
|
2971
|
-
|
|
3006
|
+
Ds as useBackButton,
|
|
3007
|
+
Ns as useBackButtonRaw,
|
|
2972
3008
|
Ms as useBiometryManager,
|
|
2973
3009
|
Bs as useBiometryManagerRaw,
|
|
2974
3010
|
$s as useClosingBehavior,
|
|
@@ -2981,7 +3017,7 @@ export {
|
|
|
2981
3017
|
Gs as useInitDataRaw,
|
|
2982
3018
|
Ks as useInvoice,
|
|
2983
3019
|
zs as useInvoiceRaw,
|
|
2984
|
-
|
|
3020
|
+
Xn as useLaunchParams,
|
|
2985
3021
|
Fs as useMainButton,
|
|
2986
3022
|
Js as useMainButtonRaw,
|
|
2987
3023
|
Ys as useMiniApp,
|
|
@@ -2999,36 +3035,36 @@ export {
|
|
|
2999
3035
|
an as useUtilsRaw,
|
|
3000
3036
|
pn as useViewport,
|
|
3001
3037
|
hn as useViewportRaw,
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3038
|
+
Tn as withBackButton,
|
|
3039
|
+
Sn as withBackButtonRaw,
|
|
3040
|
+
In as withBiometryManager,
|
|
3041
|
+
An as withBiometryManagerRaw,
|
|
3042
|
+
qn as withClosingBehavior,
|
|
3043
|
+
kn as withClosingBehaviorRaw,
|
|
3044
|
+
Nn as withCloudStorage,
|
|
3045
|
+
On as withCloudStorageRaw,
|
|
3046
|
+
Bn as withHapticFeedback,
|
|
3011
3047
|
Dn as withHapticFeedbackRaw,
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3048
|
+
Vn as withInitData,
|
|
3049
|
+
Mn as withInitDataRaw,
|
|
3050
|
+
Ln as withInvoice,
|
|
3051
|
+
$n as withInvoiceRaw,
|
|
3052
|
+
Un as withMainButton,
|
|
3053
|
+
Hn as withMainButtonRaw,
|
|
3054
|
+
Gn as withMiniApp,
|
|
3055
|
+
Wn as withMiniAppRaw,
|
|
3056
|
+
zn as withPopup,
|
|
3057
|
+
jn as withPopupRaw,
|
|
3058
|
+
Jn as withQRScanner,
|
|
3059
|
+
Kn as withQRScannerRaw,
|
|
3060
|
+
Qn as withSettingsButton,
|
|
3061
|
+
Fn as withSettingsButtonRaw,
|
|
3062
|
+
Zn as withThemeParams,
|
|
3063
|
+
Yn as withThemeParamsRaw,
|
|
3064
|
+
Mt as withTimeout,
|
|
3065
|
+
er as withUtils,
|
|
3066
|
+
tr as withUtilsRaw,
|
|
3067
|
+
nr as withViewport,
|
|
3068
|
+
sr as withViewportRaw
|
|
3033
3069
|
};
|
|
3034
3070
|
//# sourceMappingURL=index.js.map
|