@tma.js/sdk-react 2.1.2 → 2.1.4
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/dts/SDKProvider/SDKProvider.types.d.ts +6 -3
- package/dist/dts/createHooks.d.ts +14 -16
- package/dist/dts/hooks-hocs/back-button.d.ts +2 -2
- package/dist/dts/hooks-hocs/biometry-manager.d.ts +2 -2
- package/dist/dts/hooks-hocs/closing-behavior.d.ts +2 -2
- package/dist/dts/hooks-hocs/cloud-storage.d.ts +2 -2
- package/dist/dts/hooks-hocs/haptic-feedback.d.ts +2 -2
- package/dist/dts/hooks-hocs/init-data.d.ts +2 -2
- package/dist/dts/hooks-hocs/invoice.d.ts +2 -8
- package/dist/dts/hooks-hocs/main-button.d.ts +2 -2
- package/dist/dts/hooks-hocs/mini-app.d.ts +2 -2
- package/dist/dts/hooks-hocs/popup.d.ts +2 -2
- package/dist/dts/hooks-hocs/qr-scanner.d.ts +2 -2
- package/dist/dts/hooks-hocs/settings-button.d.ts +2 -2
- package/dist/dts/hooks-hocs/theme-params.d.ts +2 -2
- package/dist/dts/hooks-hocs/utils.d.ts +2 -2
- package/dist/dts/hooks-hocs/viewport.d.ts +2 -2
- package/dist/dts/index.d.ts +15 -15
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +701 -664
- 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 mt } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as Xt, useContext as te, useState as bt, useEffect as C, useMemo as vt, useRef as dt, useCallback as ee } from "react";
|
|
3
|
+
var se = Object.defineProperty, ne = (e, t, s) => t in e ? se(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (ne(e, typeof t != "symbol" ? t + "" : t, s), s);
|
|
4
|
+
function yt(e, t) {
|
|
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 Et(e) {
|
|
12
12
|
const t = G(), { count: s } = t;
|
|
13
|
-
t.unsubscribe(e), s && !t.count &&
|
|
13
|
+
t.unsubscribe(e), s && !t.count && Ce();
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return G().subscribe(e), () =>
|
|
15
|
+
function re(e) {
|
|
16
|
+
return G().subscribe(e), () => Et(e);
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class ie {
|
|
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,23 +55,23 @@ class oe {
|
|
|
55
55
|
this.print("log", ...t);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
const
|
|
58
|
+
const st = new ie("SDK", {
|
|
59
59
|
bgColor: "forestgreen",
|
|
60
60
|
textColor: "white"
|
|
61
61
|
});
|
|
62
62
|
let X = !1;
|
|
63
63
|
const _t = ({ event: e, args: [t] }) => {
|
|
64
|
-
|
|
64
|
+
st.log("Event received:", t === void 0 ? { name: e } : { name: e, data: t });
|
|
65
65
|
};
|
|
66
|
-
function
|
|
67
|
-
X !== e && (X = e, e ?
|
|
66
|
+
function oe(e) {
|
|
67
|
+
X !== e && (X = e, e ? re(_t) : Et(_t));
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
X &&
|
|
69
|
+
function ae(...e) {
|
|
70
|
+
X && st.log(...e);
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class H {
|
|
73
73
|
constructor() {
|
|
74
|
-
|
|
74
|
+
c(this, "listeners", /* @__PURE__ */ new Map()), c(this, "listenersCount", 0), c(this, "subscribeListeners", []);
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Removes all event listeners.
|
|
@@ -150,9 +150,9 @@ class W extends Error {
|
|
|
150
150
|
function m(e, t, s) {
|
|
151
151
|
return new W(e, t, s);
|
|
152
152
|
}
|
|
153
|
-
const ce = "ERR_METHOD_UNSUPPORTED",
|
|
153
|
+
const ce = "ERR_METHOD_UNSUPPORTED", he = "ERR_METHOD_PARAMETER_UNSUPPORTED", pe = "ERR_UNKNOWN_ENV", ue = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", le = "ERR_TIMED_OUT", de = "ERR_UNEXPECTED_TYPE", Pt = "ERR_PARSE", _e = "ERR_NAVIGATION_LIST_EMPTY", ge = "ERR_NAVIGATION_CURSOR_INVALID", _n = "ERR_NAVIGATION_ITEM_INVALID", gn = "ERR_SSR_INIT", we = "ERR_INVALID_PATH_BASE";
|
|
154
154
|
function T() {
|
|
155
|
-
return m(
|
|
155
|
+
return m(de, "Value has unexpected type");
|
|
156
156
|
}
|
|
157
157
|
class j {
|
|
158
158
|
constructor(t, s, n) {
|
|
@@ -170,7 +170,7 @@ class j {
|
|
|
170
170
|
return this.parser(t);
|
|
171
171
|
} catch (s) {
|
|
172
172
|
throw m(
|
|
173
|
-
|
|
173
|
+
Pt,
|
|
174
174
|
`Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
|
|
175
175
|
s
|
|
176
176
|
);
|
|
@@ -180,10 +180,10 @@ class j {
|
|
|
180
180
|
return this.isOptional = !0, this;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function A(e, t) {
|
|
184
184
|
return () => new j(e, !1, t);
|
|
185
185
|
}
|
|
186
|
-
const P =
|
|
186
|
+
const P = A((e) => {
|
|
187
187
|
if (typeof e == "boolean")
|
|
188
188
|
return e;
|
|
189
189
|
const t = String(e);
|
|
@@ -199,18 +199,18 @@ function Rt(e, t) {
|
|
|
199
199
|
const r = e[n];
|
|
200
200
|
if (!r)
|
|
201
201
|
continue;
|
|
202
|
-
let i,
|
|
202
|
+
let i, a;
|
|
203
203
|
if (typeof r == "function" || "parse" in r)
|
|
204
|
-
i = n,
|
|
204
|
+
i = n, a = typeof r == "function" ? r : r.parse.bind(r);
|
|
205
205
|
else {
|
|
206
|
-
const { type:
|
|
207
|
-
i = r.from || n,
|
|
206
|
+
const { type: o } = r;
|
|
207
|
+
i = r.from || n, a = typeof o == "function" ? o : o.parse.bind(o);
|
|
208
208
|
}
|
|
209
209
|
try {
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
} catch (
|
|
213
|
-
throw m(
|
|
210
|
+
const o = a(t(i));
|
|
211
|
+
o !== void 0 && (s[n] = o);
|
|
212
|
+
} catch (o) {
|
|
213
|
+
throw m(Pt, `Unable to parse field "${n}"`, o);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
return s;
|
|
@@ -221,13 +221,13 @@ function nt(e) {
|
|
|
221
221
|
throw T();
|
|
222
222
|
return t;
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function g(e, t) {
|
|
225
225
|
return new j((s) => {
|
|
226
226
|
const n = nt(s);
|
|
227
227
|
return Rt(e, (r) => n[r]);
|
|
228
228
|
}, !1, t);
|
|
229
229
|
}
|
|
230
|
-
const
|
|
230
|
+
const x = A((e) => {
|
|
231
231
|
if (typeof e == "number")
|
|
232
232
|
return e;
|
|
233
233
|
if (typeof e == "string") {
|
|
@@ -240,14 +240,14 @@ const C = k((e) => {
|
|
|
240
240
|
function rt(e) {
|
|
241
241
|
return /^#[\da-f]{6}$/i.test(e);
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function fe(e) {
|
|
244
244
|
return /^#[\da-f]{3}$/i.test(e);
|
|
245
245
|
}
|
|
246
246
|
function xt(e) {
|
|
247
247
|
const t = e.replace(/\s/g, "").toLowerCase();
|
|
248
248
|
if (rt(t))
|
|
249
249
|
return t;
|
|
250
|
-
if (
|
|
250
|
+
if (fe(t)) {
|
|
251
251
|
let n = "#";
|
|
252
252
|
for (let r = 0; r < 3; r += 1)
|
|
253
253
|
n += t[1 + r].repeat(2);
|
|
@@ -261,30 +261,30 @@ function xt(e) {
|
|
|
261
261
|
return n + (i.length === 1 ? "0" : "") + i;
|
|
262
262
|
}, "#");
|
|
263
263
|
}
|
|
264
|
-
const
|
|
264
|
+
const p = A((e) => {
|
|
265
265
|
if (typeof e == "string" || typeof e == "number")
|
|
266
266
|
return e.toString();
|
|
267
267
|
throw T();
|
|
268
|
-
}, "string"), Ct =
|
|
269
|
-
function
|
|
270
|
-
return
|
|
271
|
-
eventType:
|
|
268
|
+
}, "string"), Ct = A((e) => xt(p().parse(e)), "rgb");
|
|
269
|
+
function me(e) {
|
|
270
|
+
return g({
|
|
271
|
+
eventType: p(),
|
|
272
272
|
eventData: (t) => t
|
|
273
273
|
}).parse(e);
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function be() {
|
|
276
276
|
["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
|
|
277
277
|
delete window[e];
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function ve(e, t) {
|
|
281
281
|
window.dispatchEvent(new MessageEvent("message", {
|
|
282
282
|
data: JSON.stringify({ eventType: e, eventData: t }),
|
|
283
283
|
// We specify window.parent to imitate the case, the parent iframe sent us this event.
|
|
284
284
|
source: window.parent
|
|
285
285
|
}));
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function ye() {
|
|
288
288
|
[
|
|
289
289
|
["TelegramGameProxy_receiveEvent"],
|
|
290
290
|
// Windows Phone.
|
|
@@ -296,60 +296,60 @@ function Ee() {
|
|
|
296
296
|
let t = window;
|
|
297
297
|
e.forEach((s, n, r) => {
|
|
298
298
|
if (n === r.length - 1) {
|
|
299
|
-
t[s] =
|
|
299
|
+
t[s] = ve;
|
|
300
300
|
return;
|
|
301
301
|
}
|
|
302
302
|
s in t || (t[s] = {}), t = t[s];
|
|
303
303
|
});
|
|
304
304
|
});
|
|
305
305
|
}
|
|
306
|
-
const
|
|
307
|
-
button_id: (e) => e == null ? void 0 :
|
|
308
|
-
}),
|
|
309
|
-
clipboard_text_received:
|
|
310
|
-
req_id:
|
|
311
|
-
data: (e) => e === null ? e :
|
|
306
|
+
const Ee = g({
|
|
307
|
+
button_id: (e) => e == null ? void 0 : p().parse(e)
|
|
308
|
+
}), Pe = {
|
|
309
|
+
clipboard_text_received: g({
|
|
310
|
+
req_id: p(),
|
|
311
|
+
data: (e) => e === null ? e : p().optional().parse(e)
|
|
312
312
|
}),
|
|
313
|
-
custom_method_invoked:
|
|
314
|
-
req_id:
|
|
313
|
+
custom_method_invoked: g({
|
|
314
|
+
req_id: p(),
|
|
315
315
|
result: (e) => e,
|
|
316
|
-
error:
|
|
316
|
+
error: p().optional()
|
|
317
317
|
}),
|
|
318
|
-
invoice_closed:
|
|
319
|
-
slug:
|
|
320
|
-
status:
|
|
318
|
+
invoice_closed: g({
|
|
319
|
+
slug: p(),
|
|
320
|
+
status: p()
|
|
321
321
|
}),
|
|
322
|
-
phone_requested:
|
|
323
|
-
status:
|
|
322
|
+
phone_requested: g({
|
|
323
|
+
status: p()
|
|
324
324
|
}),
|
|
325
325
|
popup_closed: {
|
|
326
|
-
parse: (e) =>
|
|
326
|
+
parse: (e) => Ee.parse(e ?? {})
|
|
327
327
|
},
|
|
328
|
-
qr_text_received:
|
|
329
|
-
data:
|
|
328
|
+
qr_text_received: g({
|
|
329
|
+
data: p().optional()
|
|
330
330
|
}),
|
|
331
|
-
theme_changed:
|
|
331
|
+
theme_changed: g({
|
|
332
332
|
theme_params: (e) => {
|
|
333
333
|
const t = Ct().optional();
|
|
334
334
|
return Object.entries(nt(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
|
|
335
335
|
}
|
|
336
336
|
}),
|
|
337
|
-
viewport_changed:
|
|
338
|
-
height:
|
|
339
|
-
width: (e) => e == null ? window.innerWidth :
|
|
337
|
+
viewport_changed: g({
|
|
338
|
+
height: x(),
|
|
339
|
+
width: (e) => e == null ? window.innerWidth : x().parse(e),
|
|
340
340
|
is_state_stable: P(),
|
|
341
341
|
is_expanded: P()
|
|
342
342
|
}),
|
|
343
|
-
write_access_requested:
|
|
344
|
-
status:
|
|
343
|
+
write_access_requested: g({
|
|
344
|
+
status: p()
|
|
345
345
|
})
|
|
346
346
|
};
|
|
347
|
-
function
|
|
348
|
-
const e = new
|
|
349
|
-
|
|
347
|
+
function Re() {
|
|
348
|
+
const e = new H();
|
|
349
|
+
ye();
|
|
350
350
|
let t = [
|
|
351
351
|
// Don't forget to remove created handlers.
|
|
352
|
-
|
|
352
|
+
be,
|
|
353
353
|
// Add "resize" event listener to make sure, we always have fresh viewport information.
|
|
354
354
|
// Desktop version of Telegram is sometimes not sending the viewport_changed
|
|
355
355
|
// event. For example, when the MainButton is shown. That's why we should
|
|
@@ -370,19 +370,19 @@ function xe() {
|
|
|
370
370
|
return;
|
|
371
371
|
let n;
|
|
372
372
|
try {
|
|
373
|
-
n =
|
|
373
|
+
n = me(s.data);
|
|
374
374
|
} catch {
|
|
375
375
|
return;
|
|
376
376
|
}
|
|
377
|
-
const { eventType: r, eventData: i } = n,
|
|
377
|
+
const { eventType: r, eventData: i } = n, a = Pe[r];
|
|
378
378
|
try {
|
|
379
|
-
const
|
|
380
|
-
e.emit(...
|
|
381
|
-
} catch (
|
|
382
|
-
|
|
379
|
+
const o = a ? a.parse(i) : i;
|
|
380
|
+
e.emit(...o ? [r, o] : [r]);
|
|
381
|
+
} catch (o) {
|
|
382
|
+
st.error(
|
|
383
383
|
`An error occurred processing the "${r}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
|
|
384
384
|
n,
|
|
385
|
-
|
|
385
|
+
o
|
|
386
386
|
);
|
|
387
387
|
}
|
|
388
388
|
}),
|
|
@@ -393,18 +393,18 @@ function xe() {
|
|
|
393
393
|
t.forEach((s) => s()), t = [];
|
|
394
394
|
}];
|
|
395
395
|
}
|
|
396
|
-
const [
|
|
396
|
+
const [xe, Ce] = yt(
|
|
397
397
|
(e) => {
|
|
398
|
-
const [t, s] =
|
|
398
|
+
const [t, s] = Re(), n = t.off.bind(t);
|
|
399
399
|
return t.off = (r, i) => {
|
|
400
|
-
const { count:
|
|
401
|
-
n(r, i),
|
|
400
|
+
const { count: a } = t;
|
|
401
|
+
n(r, i), a && !t.count && e();
|
|
402
402
|
}, [t, s];
|
|
403
403
|
},
|
|
404
404
|
([, e]) => e()
|
|
405
405
|
);
|
|
406
406
|
function G() {
|
|
407
|
-
return
|
|
407
|
+
return xe()[0];
|
|
408
408
|
}
|
|
409
409
|
function z(e, t) {
|
|
410
410
|
G().off(e, t);
|
|
@@ -412,20 +412,20 @@ function z(e, t) {
|
|
|
412
412
|
function E(e, t, s) {
|
|
413
413
|
return G().on(e, t, s);
|
|
414
414
|
}
|
|
415
|
-
function
|
|
415
|
+
function M(e) {
|
|
416
416
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
417
417
|
}
|
|
418
|
-
function
|
|
418
|
+
function Se(e, t) {
|
|
419
419
|
const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
|
|
420
420
|
for (let i = 0; i < r; i += 1) {
|
|
421
|
-
const
|
|
422
|
-
if (
|
|
423
|
-
return
|
|
421
|
+
const a = parseInt(s[i] || "0", 10), o = parseInt(n[i] || "0", 10);
|
|
422
|
+
if (a !== o)
|
|
423
|
+
return a > o ? 1 : -1;
|
|
424
424
|
}
|
|
425
425
|
return 0;
|
|
426
426
|
}
|
|
427
427
|
function y(e, t) {
|
|
428
|
-
return
|
|
428
|
+
return Se(e, t) <= 0;
|
|
429
429
|
}
|
|
430
430
|
function S(e, t, s) {
|
|
431
431
|
if (typeof s == "string") {
|
|
@@ -478,11 +478,11 @@ function S(e, t, s) {
|
|
|
478
478
|
].includes(e);
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
|
-
function
|
|
482
|
-
return "external" in e &&
|
|
481
|
+
function Te(e) {
|
|
482
|
+
return "external" in e && M(e.external) && "notify" in e.external && typeof e.external.notify == "function";
|
|
483
483
|
}
|
|
484
484
|
function St(e) {
|
|
485
|
-
return "TelegramWebviewProxy" in e &&
|
|
485
|
+
return "TelegramWebviewProxy" in e && M(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
|
|
486
486
|
}
|
|
487
487
|
function Tt() {
|
|
488
488
|
try {
|
|
@@ -491,22 +491,22 @@ function Tt() {
|
|
|
491
491
|
return !0;
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
-
let
|
|
495
|
-
function
|
|
496
|
-
|
|
494
|
+
let At = "https://web.telegram.org";
|
|
495
|
+
function wn(e) {
|
|
496
|
+
At = e;
|
|
497
497
|
}
|
|
498
498
|
function Ae() {
|
|
499
|
-
return
|
|
499
|
+
return At;
|
|
500
500
|
}
|
|
501
|
-
function
|
|
501
|
+
function N(e, t, s) {
|
|
502
502
|
let n = {}, r;
|
|
503
503
|
t === void 0 && s === void 0 ? n = {} : t !== void 0 && s !== void 0 ? (n = s, r = t) : t !== void 0 && ("targetOrigin" in t ? n = t : r = t);
|
|
504
504
|
const { targetOrigin: i = Ae() } = n;
|
|
505
|
-
if (
|
|
505
|
+
if (ae("Posting event:", r ? { event: e, data: r } : { event: e }), Tt()) {
|
|
506
506
|
window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
|
|
507
507
|
return;
|
|
508
508
|
}
|
|
509
|
-
if (
|
|
509
|
+
if (Te(window)) {
|
|
510
510
|
window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
|
|
511
511
|
return;
|
|
512
512
|
}
|
|
@@ -515,32 +515,32 @@ function O(e, t, s) {
|
|
|
515
515
|
return;
|
|
516
516
|
}
|
|
517
517
|
throw m(
|
|
518
|
-
|
|
518
|
+
pe,
|
|
519
519
|
"Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside of Telegram application environment."
|
|
520
520
|
);
|
|
521
521
|
}
|
|
522
|
-
function
|
|
522
|
+
function ke(e) {
|
|
523
523
|
return (t, s) => {
|
|
524
524
|
if (!S(t, e))
|
|
525
525
|
throw m(ce, `Method "${t}" is unsupported in Mini Apps version ${e}`);
|
|
526
|
-
if (
|
|
526
|
+
if (M(s)) {
|
|
527
527
|
let n;
|
|
528
528
|
if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !S(t, n, e))
|
|
529
529
|
throw m(
|
|
530
|
-
|
|
530
|
+
he,
|
|
531
531
|
`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
|
|
532
532
|
);
|
|
533
533
|
}
|
|
534
|
-
return
|
|
534
|
+
return N(t, s);
|
|
535
535
|
};
|
|
536
536
|
}
|
|
537
|
-
function
|
|
537
|
+
function kt(e) {
|
|
538
538
|
return ({ req_id: t }) => t === e;
|
|
539
539
|
}
|
|
540
540
|
function It(e) {
|
|
541
541
|
return m(le, `Timeout reached: ${e}ms`);
|
|
542
542
|
}
|
|
543
|
-
function
|
|
543
|
+
function Ot(e, t) {
|
|
544
544
|
return Promise.race([
|
|
545
545
|
typeof e == "function" ? e() : e,
|
|
546
546
|
new Promise((s, n) => {
|
|
@@ -550,30 +550,30 @@ function qt(e, t) {
|
|
|
550
550
|
})
|
|
551
551
|
]);
|
|
552
552
|
}
|
|
553
|
-
async function
|
|
553
|
+
async function w(e) {
|
|
554
554
|
let t;
|
|
555
|
-
const s = new Promise((
|
|
556
|
-
t =
|
|
555
|
+
const s = new Promise((h) => {
|
|
556
|
+
t = h;
|
|
557
557
|
}), {
|
|
558
558
|
method: n,
|
|
559
559
|
event: r,
|
|
560
560
|
capture: i,
|
|
561
|
-
postEvent:
|
|
562
|
-
timeout:
|
|
563
|
-
} = e,
|
|
564
|
-
(
|
|
561
|
+
postEvent: a = N,
|
|
562
|
+
timeout: o
|
|
563
|
+
} = e, u = (Array.isArray(r) ? r : [r]).map(
|
|
564
|
+
(h) => E(h, (v) => (!i || i(v)) && t(v))
|
|
565
565
|
);
|
|
566
566
|
try {
|
|
567
|
-
return
|
|
567
|
+
return a(n, e.params), await (o ? Ot(s, o) : s);
|
|
568
568
|
} finally {
|
|
569
|
-
|
|
569
|
+
u.forEach((h) => h());
|
|
570
570
|
}
|
|
571
571
|
}
|
|
572
|
-
async function
|
|
572
|
+
async function q(e, t, s, n = {}) {
|
|
573
573
|
const {
|
|
574
574
|
result: r,
|
|
575
575
|
error: i
|
|
576
|
-
} = await
|
|
576
|
+
} = await w({
|
|
577
577
|
...n,
|
|
578
578
|
method: "web_app_invoke_custom_method",
|
|
579
579
|
event: "custom_method_invoked",
|
|
@@ -582,29 +582,29 @@ async function I(e, t, s, n = {}) {
|
|
|
582
582
|
params: t,
|
|
583
583
|
req_id: s
|
|
584
584
|
},
|
|
585
|
-
capture:
|
|
585
|
+
capture: kt(s)
|
|
586
586
|
});
|
|
587
587
|
if (i)
|
|
588
|
-
throw m(
|
|
588
|
+
throw m(ue, i);
|
|
589
589
|
return r;
|
|
590
590
|
}
|
|
591
591
|
function et(...e) {
|
|
592
592
|
return e.map((t) => {
|
|
593
593
|
if (typeof t == "string")
|
|
594
594
|
return t;
|
|
595
|
-
if (
|
|
595
|
+
if (M(t))
|
|
596
596
|
return et(Object.entries(t).map((s) => s[1] && s[0]));
|
|
597
597
|
if (Array.isArray(t))
|
|
598
598
|
return et(...t);
|
|
599
599
|
}).filter(Boolean).join(" ");
|
|
600
600
|
}
|
|
601
|
-
function
|
|
602
|
-
return e.reduce((t, s) => (
|
|
601
|
+
function fn(...e) {
|
|
602
|
+
return e.reduce((t, s) => (M(s) && Object.entries(s).forEach(([n, r]) => {
|
|
603
603
|
const i = et(t[n], r);
|
|
604
604
|
i.length && (t[n] = i);
|
|
605
605
|
}), t), {});
|
|
606
606
|
}
|
|
607
|
-
function
|
|
607
|
+
function qt(e) {
|
|
608
608
|
const t = xt(e);
|
|
609
609
|
return Math.sqrt(
|
|
610
610
|
[0.299, 0.587, 0.114].reduce((s, n, r) => {
|
|
@@ -613,9 +613,9 @@ function Ot(e) {
|
|
|
613
613
|
}, 0)
|
|
614
614
|
) < 120;
|
|
615
615
|
}
|
|
616
|
-
class
|
|
616
|
+
class Ie {
|
|
617
617
|
constructor(t) {
|
|
618
|
-
|
|
618
|
+
c(this, "ee", new H()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
|
|
619
619
|
}
|
|
620
620
|
/**
|
|
621
621
|
* Clones current state and returns its copy.
|
|
@@ -636,7 +636,7 @@ class qe {
|
|
|
636
636
|
}
|
|
637
637
|
class it {
|
|
638
638
|
constructor(t) {
|
|
639
|
-
|
|
639
|
+
c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new Ie(t), this.set = this.state.set.bind(this.state), this.get = this.state.get.bind(this.state), this.clone = this.state.clone.bind(this.state);
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
642
|
function Dt(e, t) {
|
|
@@ -644,7 +644,7 @@ function Dt(e, t) {
|
|
|
644
644
|
}
|
|
645
645
|
class ot extends it {
|
|
646
646
|
constructor(t, s, n) {
|
|
647
|
-
super(t),
|
|
647
|
+
super(t), c(this, "supports"), this.supports = Dt(s, n);
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
650
|
class Oe extends ot {
|
|
@@ -652,7 +652,7 @@ class Oe extends ot {
|
|
|
652
652
|
super({ isVisible: t }, s, {
|
|
653
653
|
show: "web_app_setup_back_button",
|
|
654
654
|
hide: "web_app_setup_back_button"
|
|
655
|
-
}),
|
|
655
|
+
}), c(this, "on", (r, i) => r === "click" ? E("back_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? z("back_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
|
|
656
656
|
}
|
|
657
657
|
set isVisible(t) {
|
|
658
658
|
this.set("isVisible", t), this.postEvent("web_app_setup_back_button", { is_visible: t });
|
|
@@ -676,10 +676,7 @@ class Oe extends ot {
|
|
|
676
676
|
this.isVisible = !0;
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
|
-
|
|
680
|
-
return typeof window > "u";
|
|
681
|
-
}
|
|
682
|
-
const Nt = k((e) => e instanceof Date ? e : new Date(C().parse(e) * 1e3), "Date");
|
|
679
|
+
const Nt = A((e) => e instanceof Date ? e : new Date(x().parse(e) * 1e3), "Date");
|
|
683
680
|
function at(e, t) {
|
|
684
681
|
return new j((s) => {
|
|
685
682
|
if (typeof s != "string" && !(s instanceof URLSearchParams))
|
|
@@ -691,16 +688,16 @@ function at(e, t) {
|
|
|
691
688
|
});
|
|
692
689
|
}, !1, t);
|
|
693
690
|
}
|
|
694
|
-
const
|
|
695
|
-
id:
|
|
696
|
-
type:
|
|
697
|
-
title:
|
|
691
|
+
const qe = g({
|
|
692
|
+
id: x(),
|
|
693
|
+
type: p(),
|
|
694
|
+
title: p(),
|
|
698
695
|
photoUrl: {
|
|
699
|
-
type:
|
|
696
|
+
type: p().optional(),
|
|
700
697
|
from: "photo_url"
|
|
701
698
|
},
|
|
702
|
-
username:
|
|
703
|
-
}, "Chat").optional(), gt =
|
|
699
|
+
username: p().optional()
|
|
700
|
+
}, "Chat").optional(), gt = g({
|
|
704
701
|
addedToAttachmentMenu: {
|
|
705
702
|
type: P().optional(),
|
|
706
703
|
from: "added_to_attachment_menu"
|
|
@@ -710,10 +707,10 @@ const De = w({
|
|
|
710
707
|
from: "allows_write_to_pm"
|
|
711
708
|
},
|
|
712
709
|
firstName: {
|
|
713
|
-
type:
|
|
710
|
+
type: p(),
|
|
714
711
|
from: "first_name"
|
|
715
712
|
},
|
|
716
|
-
id:
|
|
713
|
+
id: x(),
|
|
717
714
|
isBot: {
|
|
718
715
|
type: P().optional(),
|
|
719
716
|
from: "is_bot"
|
|
@@ -723,18 +720,18 @@ const De = w({
|
|
|
723
720
|
from: "is_premium"
|
|
724
721
|
},
|
|
725
722
|
languageCode: {
|
|
726
|
-
type:
|
|
723
|
+
type: p().optional(),
|
|
727
724
|
from: "language_code"
|
|
728
725
|
},
|
|
729
726
|
lastName: {
|
|
730
|
-
type:
|
|
727
|
+
type: p().optional(),
|
|
731
728
|
from: "last_name"
|
|
732
729
|
},
|
|
733
730
|
photoUrl: {
|
|
734
|
-
type:
|
|
731
|
+
type: p().optional(),
|
|
735
732
|
from: "photo_url"
|
|
736
733
|
},
|
|
737
|
-
username:
|
|
734
|
+
username: p().optional()
|
|
738
735
|
}, "User").optional();
|
|
739
736
|
function Bt() {
|
|
740
737
|
return at({
|
|
@@ -743,45 +740,45 @@ function Bt() {
|
|
|
743
740
|
from: "auth_date"
|
|
744
741
|
},
|
|
745
742
|
canSendAfter: {
|
|
746
|
-
type:
|
|
743
|
+
type: x().optional(),
|
|
747
744
|
from: "can_send_after"
|
|
748
745
|
},
|
|
749
|
-
chat:
|
|
746
|
+
chat: qe,
|
|
750
747
|
chatInstance: {
|
|
751
|
-
type:
|
|
748
|
+
type: p().optional(),
|
|
752
749
|
from: "chat_instance"
|
|
753
750
|
},
|
|
754
751
|
chatType: {
|
|
755
|
-
type:
|
|
752
|
+
type: p().optional(),
|
|
756
753
|
from: "chat_type"
|
|
757
754
|
},
|
|
758
|
-
hash:
|
|
755
|
+
hash: p(),
|
|
759
756
|
queryId: {
|
|
760
|
-
type:
|
|
757
|
+
type: p().optional(),
|
|
761
758
|
from: "query_id"
|
|
762
759
|
},
|
|
763
760
|
receiver: gt,
|
|
764
761
|
startParam: {
|
|
765
|
-
type:
|
|
762
|
+
type: p().optional(),
|
|
766
763
|
from: "start_param"
|
|
767
764
|
},
|
|
768
765
|
user: gt
|
|
769
766
|
}, "InitData");
|
|
770
767
|
}
|
|
771
|
-
function
|
|
768
|
+
function De(e) {
|
|
772
769
|
return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
|
|
773
770
|
}
|
|
774
|
-
function
|
|
771
|
+
function Ne(e) {
|
|
775
772
|
return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
|
|
776
773
|
}
|
|
777
|
-
const
|
|
774
|
+
const Mt = A(
|
|
778
775
|
(e) => {
|
|
779
776
|
const t = Ct().optional();
|
|
780
|
-
return Object.entries(nt(e)).reduce((s, [n, r]) => (s[
|
|
777
|
+
return Object.entries(nt(e)).reduce((s, [n, r]) => (s[De(n)] = t.parse(r), s), {});
|
|
781
778
|
},
|
|
782
779
|
"ThemeParams"
|
|
783
780
|
);
|
|
784
|
-
function
|
|
781
|
+
function Vt(e) {
|
|
785
782
|
return at({
|
|
786
783
|
botInline: {
|
|
787
784
|
type: P().optional(),
|
|
@@ -792,11 +789,11 @@ function Mt(e) {
|
|
|
792
789
|
from: "tgWebAppData"
|
|
793
790
|
},
|
|
794
791
|
initDataRaw: {
|
|
795
|
-
type:
|
|
792
|
+
type: p().optional(),
|
|
796
793
|
from: "tgWebAppData"
|
|
797
794
|
},
|
|
798
795
|
platform: {
|
|
799
|
-
type:
|
|
796
|
+
type: p(),
|
|
800
797
|
from: "tgWebAppPlatform"
|
|
801
798
|
},
|
|
802
799
|
showSettings: {
|
|
@@ -804,25 +801,25 @@ function Mt(e) {
|
|
|
804
801
|
from: "tgWebAppShowSettings"
|
|
805
802
|
},
|
|
806
803
|
startParam: {
|
|
807
|
-
type:
|
|
804
|
+
type: p().optional(),
|
|
808
805
|
from: "tgWebAppStartParam"
|
|
809
806
|
},
|
|
810
807
|
themeParams: {
|
|
811
|
-
type:
|
|
808
|
+
type: Mt(),
|
|
812
809
|
from: "tgWebAppThemeParams"
|
|
813
810
|
},
|
|
814
811
|
version: {
|
|
815
|
-
type:
|
|
812
|
+
type: p(),
|
|
816
813
|
from: "tgWebAppVersion"
|
|
817
814
|
}
|
|
818
815
|
}).parse(e);
|
|
819
816
|
}
|
|
820
817
|
function $t(e) {
|
|
821
|
-
return
|
|
818
|
+
return Vt(
|
|
822
819
|
e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
|
|
823
820
|
);
|
|
824
821
|
}
|
|
825
|
-
function
|
|
822
|
+
function Be() {
|
|
826
823
|
return $t(window.location.href);
|
|
827
824
|
}
|
|
828
825
|
function Lt() {
|
|
@@ -834,53 +831,53 @@ function Me() {
|
|
|
834
831
|
throw new Error("Unable to get first navigation entry.");
|
|
835
832
|
return $t(e.name);
|
|
836
833
|
}
|
|
837
|
-
function
|
|
834
|
+
function Ut(e) {
|
|
838
835
|
return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
|
|
839
836
|
}
|
|
840
|
-
function
|
|
841
|
-
sessionStorage.setItem(
|
|
837
|
+
function Ht(e, t) {
|
|
838
|
+
sessionStorage.setItem(Ut(e), JSON.stringify(t));
|
|
842
839
|
}
|
|
843
840
|
function Wt(e) {
|
|
844
|
-
const t = sessionStorage.getItem(
|
|
841
|
+
const t = sessionStorage.getItem(Ut(e));
|
|
845
842
|
try {
|
|
846
843
|
return t ? JSON.parse(t) : void 0;
|
|
847
844
|
} catch {
|
|
848
845
|
}
|
|
849
846
|
}
|
|
850
|
-
function
|
|
851
|
-
return
|
|
847
|
+
function Ve() {
|
|
848
|
+
return Vt(Wt("launchParams") || "");
|
|
852
849
|
}
|
|
853
|
-
function
|
|
850
|
+
function $e(e) {
|
|
854
851
|
return JSON.stringify(
|
|
855
852
|
Object.fromEntries(
|
|
856
|
-
Object.entries(e).map(([t, s]) => [
|
|
853
|
+
Object.entries(e).map(([t, s]) => [Ne(t), s])
|
|
857
854
|
)
|
|
858
855
|
);
|
|
859
856
|
}
|
|
860
|
-
function
|
|
857
|
+
function Le(e) {
|
|
861
858
|
const {
|
|
862
859
|
initDataRaw: t,
|
|
863
860
|
themeParams: s,
|
|
864
861
|
platform: n,
|
|
865
862
|
version: r,
|
|
866
863
|
showSettings: i,
|
|
867
|
-
startParam:
|
|
868
|
-
botInline:
|
|
869
|
-
} = e,
|
|
870
|
-
return
|
|
864
|
+
startParam: a,
|
|
865
|
+
botInline: o
|
|
866
|
+
} = e, u = new URLSearchParams();
|
|
867
|
+
return u.set("tgWebAppPlatform", n), u.set("tgWebAppThemeParams", $e(s)), u.set("tgWebAppVersion", r), t && u.set("tgWebAppData", t), a && u.set("tgWebAppStartParam", a), typeof i == "boolean" && u.set("tgWebAppShowSettings", i ? "1" : "0"), typeof o == "boolean" && u.set("tgWebAppBotInline", o ? "1" : "0"), u.toString();
|
|
871
868
|
}
|
|
872
869
|
function Ue(e) {
|
|
873
|
-
|
|
870
|
+
Ht("launchParams", Le(e));
|
|
874
871
|
}
|
|
875
872
|
function jt() {
|
|
876
873
|
for (const e of [
|
|
877
874
|
// Try to retrieve launch parameters from the current location. This method can return
|
|
878
875
|
// nothing in case, location was changed and then page was reloaded.
|
|
879
|
-
|
|
876
|
+
Be,
|
|
880
877
|
// Then, try using the lower level API - window.performance.
|
|
881
878
|
Me,
|
|
882
879
|
// Finally, try to extract launch parameters from the session storage.
|
|
883
|
-
|
|
880
|
+
Ve
|
|
884
881
|
])
|
|
885
882
|
try {
|
|
886
883
|
const t = e();
|
|
@@ -893,32 +890,47 @@ function Gt() {
|
|
|
893
890
|
const e = Lt();
|
|
894
891
|
return !!(e && e.type === "reload");
|
|
895
892
|
}
|
|
896
|
-
function
|
|
893
|
+
function He() {
|
|
897
894
|
let e = 0;
|
|
898
895
|
return () => (e += 1).toString();
|
|
899
896
|
}
|
|
900
|
-
|
|
897
|
+
function We() {
|
|
898
|
+
let e = !1;
|
|
899
|
+
const t = [];
|
|
900
|
+
return [
|
|
901
|
+
(s) => !e && t.push(s),
|
|
902
|
+
() => {
|
|
903
|
+
e || (e = !0, t.forEach((s) => s()));
|
|
904
|
+
},
|
|
905
|
+
e
|
|
906
|
+
];
|
|
907
|
+
}
|
|
908
|
+
const [je] = yt(He);
|
|
901
909
|
function l(e, t) {
|
|
902
|
-
return (
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
platform: "unknown",
|
|
907
|
-
...s || {}
|
|
908
|
-
} : jt(), r = {
|
|
909
|
-
...n,
|
|
910
|
-
postEvent: x() ? () => null : Ie(n.version),
|
|
910
|
+
return () => {
|
|
911
|
+
const s = jt(), n = {
|
|
912
|
+
...s,
|
|
913
|
+
postEvent: ke(s.version),
|
|
911
914
|
createRequestId: je()
|
|
912
915
|
};
|
|
913
|
-
if (
|
|
914
|
-
return
|
|
915
|
-
const i = t({
|
|
916
|
-
...
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
916
|
+
if (typeof e == "function")
|
|
917
|
+
return e(n);
|
|
918
|
+
const [r, i, a] = We(), o = t({
|
|
919
|
+
...n,
|
|
920
|
+
// State should only be passed only in case, current page was reloaded. If we don't add
|
|
921
|
+
// this check, state restoration will work improperly in the web version of Telegram,
|
|
922
|
+
// when we are always working in the same "session" (tab).
|
|
923
|
+
state: Gt() ? Wt(e) : void 0,
|
|
924
|
+
addCleanup: r
|
|
925
|
+
}), u = (h) => (a || r(
|
|
926
|
+
h.on("change", (v) => {
|
|
927
|
+
Ht(e, v);
|
|
928
|
+
})
|
|
929
|
+
), h);
|
|
930
|
+
return [
|
|
931
|
+
o instanceof Promise ? o.then(u) : u(o),
|
|
932
|
+
i
|
|
933
|
+
];
|
|
922
934
|
};
|
|
923
935
|
}
|
|
924
936
|
const Ge = l("backButton", ({
|
|
@@ -926,9 +938,9 @@ const Ge = l("backButton", ({
|
|
|
926
938
|
version: t,
|
|
927
939
|
state: s = { isVisible: !1 }
|
|
928
940
|
}) => new Oe(s.isVisible, t, e));
|
|
929
|
-
class
|
|
941
|
+
class V extends ot {
|
|
930
942
|
constructor() {
|
|
931
|
-
super(...arguments),
|
|
943
|
+
super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
|
|
932
944
|
}
|
|
933
945
|
}
|
|
934
946
|
function zt(e) {
|
|
@@ -949,14 +961,14 @@ function zt(e) {
|
|
|
949
961
|
accessGranted: t.access_granted
|
|
950
962
|
};
|
|
951
963
|
}
|
|
952
|
-
class
|
|
964
|
+
class ze extends V {
|
|
953
965
|
constructor({ postEvent: t, version: s, ...n }) {
|
|
954
966
|
super(n, s, {
|
|
955
967
|
auth: "web_app_biometry_request_auth",
|
|
956
968
|
openSettings: "web_app_biometry_open_settings",
|
|
957
969
|
requestAccess: "web_app_biometry_request_access",
|
|
958
970
|
updateToken: "web_app_biometry_update_token"
|
|
959
|
-
}),
|
|
971
|
+
}), c(this, "postEvent"), c(this, "authPromise"), c(this, "accessPromise"), this.postEvent = t;
|
|
960
972
|
}
|
|
961
973
|
/**
|
|
962
974
|
* Shows whether biometry is available.
|
|
@@ -986,7 +998,7 @@ class wt extends B {
|
|
|
986
998
|
reason: t,
|
|
987
999
|
...s
|
|
988
1000
|
}) {
|
|
989
|
-
return this.authPromise || (this.authPromise =
|
|
1001
|
+
return this.authPromise || (this.authPromise = w({
|
|
990
1002
|
...s,
|
|
991
1003
|
method: "web_app_biometry_request_auth",
|
|
992
1004
|
event: "biometry_auth_requested",
|
|
@@ -1020,7 +1032,7 @@ class wt extends B {
|
|
|
1020
1032
|
* @returns Promise with true, if access was granted.
|
|
1021
1033
|
*/
|
|
1022
1034
|
requestAccess({ reason: t, ...s } = {}) {
|
|
1023
|
-
return this.accessPromise || (this.accessPromise =
|
|
1035
|
+
return this.accessPromise || (this.accessPromise = w({
|
|
1024
1036
|
...s,
|
|
1025
1037
|
postEvent: this.postEvent,
|
|
1026
1038
|
method: "web_app_biometry_request_access",
|
|
@@ -1049,7 +1061,7 @@ class wt extends B {
|
|
|
1049
1061
|
*/
|
|
1050
1062
|
async updateToken({ token: t, ...s } = {}) {
|
|
1051
1063
|
return ["removed", "updated"].includes(
|
|
1052
|
-
(await
|
|
1064
|
+
(await w({
|
|
1053
1065
|
...s,
|
|
1054
1066
|
postEvent: this.postEvent,
|
|
1055
1067
|
method: "web_app_biometry_update_token",
|
|
@@ -1059,35 +1071,29 @@ class wt extends B {
|
|
|
1059
1071
|
);
|
|
1060
1072
|
}
|
|
1061
1073
|
}
|
|
1062
|
-
async function
|
|
1074
|
+
async function Ke(e) {
|
|
1063
1075
|
return zt(
|
|
1064
|
-
await
|
|
1076
|
+
await w({
|
|
1065
1077
|
...e || {},
|
|
1066
1078
|
method: "web_app_biometry_get_info",
|
|
1067
1079
|
event: "biometry_info_received"
|
|
1068
1080
|
})
|
|
1069
1081
|
);
|
|
1070
1082
|
}
|
|
1071
|
-
const
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
throw m(
|
|
1076
|
-
Pt,
|
|
1077
|
-
"BiometryManager cannot be instantiated on the server side without passing the ssr.state object."
|
|
1078
|
-
);
|
|
1079
|
-
return new wt({
|
|
1080
|
-
...await ze({ timeout: 1e3 }),
|
|
1083
|
+
const Je = l(
|
|
1084
|
+
"biometryManager",
|
|
1085
|
+
async ({ postEvent: e, version: t, state: s }) => new ze({
|
|
1086
|
+
...s || await Ke({ timeout: 1e3 }),
|
|
1081
1087
|
version: t,
|
|
1082
1088
|
postEvent: e
|
|
1083
|
-
})
|
|
1084
|
-
|
|
1085
|
-
class
|
|
1089
|
+
})
|
|
1090
|
+
);
|
|
1091
|
+
class ct extends it {
|
|
1086
1092
|
constructor() {
|
|
1087
|
-
super(...arguments),
|
|
1093
|
+
super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
|
|
1088
1094
|
}
|
|
1089
1095
|
}
|
|
1090
|
-
class
|
|
1096
|
+
class Qe extends ct {
|
|
1091
1097
|
constructor(t, s) {
|
|
1092
1098
|
super({ isConfirmationNeeded: t }), this.postEvent = s;
|
|
1093
1099
|
}
|
|
@@ -1114,16 +1120,19 @@ class Je extends ht {
|
|
|
1114
1120
|
this.isConfirmationNeeded = !0;
|
|
1115
1121
|
}
|
|
1116
1122
|
}
|
|
1117
|
-
const
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1123
|
+
const Fe = l(
|
|
1124
|
+
"closingBehavior",
|
|
1125
|
+
({
|
|
1126
|
+
postEvent: e,
|
|
1127
|
+
state: t = { isConfirmationNeeded: !1 }
|
|
1128
|
+
}) => new Qe(t.isConfirmationNeeded, e)
|
|
1129
|
+
);
|
|
1130
|
+
class ht {
|
|
1122
1131
|
constructor(t, s) {
|
|
1123
|
-
|
|
1132
|
+
c(this, "supports"), this.supports = Dt(t, s);
|
|
1124
1133
|
}
|
|
1125
1134
|
}
|
|
1126
|
-
function
|
|
1135
|
+
function Ye(e) {
|
|
1127
1136
|
if (Array.isArray(e))
|
|
1128
1137
|
return e;
|
|
1129
1138
|
if (typeof e == "string")
|
|
@@ -1135,9 +1144,9 @@ function Fe(e) {
|
|
|
1135
1144
|
}
|
|
1136
1145
|
throw T();
|
|
1137
1146
|
}
|
|
1138
|
-
class
|
|
1147
|
+
class Ze extends j {
|
|
1139
1148
|
constructor(t, s, n) {
|
|
1140
|
-
super(
|
|
1149
|
+
super(Ye, s, n), c(this, "itemParser"), this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
|
|
1141
1150
|
}
|
|
1142
1151
|
/**
|
|
1143
1152
|
* Attempts to parse passed value
|
|
@@ -1153,13 +1162,13 @@ class Ye extends j {
|
|
|
1153
1162
|
return this.itemParser = typeof t == "function" ? t : t.parse.bind(t), this;
|
|
1154
1163
|
}
|
|
1155
1164
|
}
|
|
1156
|
-
function
|
|
1157
|
-
return new
|
|
1165
|
+
function Xe(e) {
|
|
1166
|
+
return new Ze((t) => t, !1, e);
|
|
1158
1167
|
}
|
|
1159
|
-
function
|
|
1168
|
+
function wt(e, t) {
|
|
1160
1169
|
return Object.fromEntries(e.map((s) => [s, t]));
|
|
1161
1170
|
}
|
|
1162
|
-
class
|
|
1171
|
+
class ts extends ht {
|
|
1163
1172
|
constructor(t, s, n) {
|
|
1164
1173
|
super(t, {
|
|
1165
1174
|
delete: "web_app_invoke_custom_method",
|
|
@@ -1175,7 +1184,7 @@ class Xe extends ct {
|
|
|
1175
1184
|
*/
|
|
1176
1185
|
async delete(t, s = {}) {
|
|
1177
1186
|
const n = Array.isArray(t) ? t : [t];
|
|
1178
|
-
n.length && await
|
|
1187
|
+
n.length && await q(
|
|
1179
1188
|
"deleteStorageValues",
|
|
1180
1189
|
{ keys: n },
|
|
1181
1190
|
this.createRequestId(),
|
|
@@ -1187,8 +1196,8 @@ class Xe extends ct {
|
|
|
1187
1196
|
* @param options - request execution options.
|
|
1188
1197
|
*/
|
|
1189
1198
|
async getKeys(t = {}) {
|
|
1190
|
-
return
|
|
1191
|
-
await
|
|
1199
|
+
return Xe().of(p()).parse(
|
|
1200
|
+
await q(
|
|
1192
1201
|
"getStorageKeys",
|
|
1193
1202
|
{},
|
|
1194
1203
|
this.createRequestId(),
|
|
@@ -1199,13 +1208,13 @@ class Xe extends ct {
|
|
|
1199
1208
|
async get(t, s = {}) {
|
|
1200
1209
|
const n = Array.isArray(t) ? t : [t];
|
|
1201
1210
|
if (!n.length)
|
|
1202
|
-
return
|
|
1203
|
-
const r = await
|
|
1211
|
+
return wt(n, "");
|
|
1212
|
+
const r = await q(
|
|
1204
1213
|
"getStorageValues",
|
|
1205
1214
|
{ keys: n },
|
|
1206
1215
|
this.createRequestId(),
|
|
1207
1216
|
{ ...s, postEvent: this.postEvent }
|
|
1208
|
-
), i =
|
|
1217
|
+
), i = g(wt(n, p()), "CloudStorageData").parse(r);
|
|
1209
1218
|
return Array.isArray(t) ? i : i[t];
|
|
1210
1219
|
}
|
|
1211
1220
|
/**
|
|
@@ -1215,7 +1224,7 @@ class Xe extends ct {
|
|
|
1215
1224
|
* @param options - request execution options.
|
|
1216
1225
|
*/
|
|
1217
1226
|
async set(t, s, n = {}) {
|
|
1218
|
-
await
|
|
1227
|
+
await q(
|
|
1219
1228
|
"saveStorageValue",
|
|
1220
1229
|
{ key: t, value: s },
|
|
1221
1230
|
this.createRequestId(),
|
|
@@ -1223,10 +1232,10 @@ class Xe extends ct {
|
|
|
1223
1232
|
);
|
|
1224
1233
|
}
|
|
1225
1234
|
}
|
|
1226
|
-
const
|
|
1227
|
-
({ createRequestId: e, postEvent: t, version: s }) => new
|
|
1235
|
+
const es = l(
|
|
1236
|
+
({ createRequestId: e, postEvent: t, version: s }) => new ts(s, e, t)
|
|
1228
1237
|
);
|
|
1229
|
-
class
|
|
1238
|
+
class ss extends ht {
|
|
1230
1239
|
constructor(t, s) {
|
|
1231
1240
|
super(t, {
|
|
1232
1241
|
impactOccurred: "web_app_trigger_haptic_feedback",
|
|
@@ -1268,10 +1277,10 @@ class es extends ct {
|
|
|
1268
1277
|
this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
|
|
1269
1278
|
}
|
|
1270
1279
|
}
|
|
1271
|
-
const
|
|
1272
|
-
({ version: e, postEvent: t }) => new
|
|
1280
|
+
const ns = l(
|
|
1281
|
+
({ version: e, postEvent: t }) => new ss(e, t)
|
|
1273
1282
|
);
|
|
1274
|
-
class
|
|
1283
|
+
class rs {
|
|
1275
1284
|
constructor(t) {
|
|
1276
1285
|
this.initData = t;
|
|
1277
1286
|
}
|
|
@@ -1344,13 +1353,13 @@ class ns {
|
|
|
1344
1353
|
return this.initData.user;
|
|
1345
1354
|
}
|
|
1346
1355
|
}
|
|
1347
|
-
const
|
|
1348
|
-
({ initData: e }) => e ? new
|
|
1356
|
+
const is = l(
|
|
1357
|
+
({ initData: e }) => e ? new rs(e) : void 0
|
|
1349
1358
|
);
|
|
1350
|
-
function
|
|
1359
|
+
function mn(e) {
|
|
1351
1360
|
return Bt().parse(e);
|
|
1352
1361
|
}
|
|
1353
|
-
class
|
|
1362
|
+
class os extends V {
|
|
1354
1363
|
constructor(t, s, n) {
|
|
1355
1364
|
super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
|
|
1356
1365
|
}
|
|
@@ -1373,14 +1382,14 @@ class is extends B {
|
|
|
1373
1382
|
const { hostname: r, pathname: i } = new URL(t, window.location.href);
|
|
1374
1383
|
if (r !== "t.me")
|
|
1375
1384
|
throw new Error(`Incorrect hostname: ${r}`);
|
|
1376
|
-
const
|
|
1377
|
-
if (!
|
|
1385
|
+
const a = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
|
|
1386
|
+
if (!a)
|
|
1378
1387
|
throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
|
|
1379
|
-
[, , n] =
|
|
1388
|
+
[, , n] = a;
|
|
1380
1389
|
}
|
|
1381
1390
|
this.isOpened = !0;
|
|
1382
1391
|
try {
|
|
1383
|
-
return (await
|
|
1392
|
+
return (await w({
|
|
1384
1393
|
method: "web_app_open_invoice",
|
|
1385
1394
|
event: "invoice_closed",
|
|
1386
1395
|
params: { slug: n },
|
|
@@ -1394,12 +1403,12 @@ class is extends B {
|
|
|
1394
1403
|
}
|
|
1395
1404
|
}
|
|
1396
1405
|
}
|
|
1397
|
-
const
|
|
1398
|
-
({ version: e, postEvent: t }) => new
|
|
1406
|
+
const as = l(
|
|
1407
|
+
({ version: e, postEvent: t }) => new os(!1, e, t)
|
|
1399
1408
|
);
|
|
1400
|
-
class
|
|
1409
|
+
class cs extends it {
|
|
1401
1410
|
constructor({ postEvent: t, ...s }) {
|
|
1402
|
-
super(s),
|
|
1411
|
+
super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ? E("main_button_pressed", r) : this.state.on(n, r)), c(this, "off", (n, r) => n === "click" ? z("main_button_pressed", r) : this.state.off(n, r)), this.postEvent = t;
|
|
1403
1412
|
}
|
|
1404
1413
|
/**
|
|
1405
1414
|
* Sends current local state to the Telegram application.
|
|
@@ -1528,35 +1537,38 @@ class as extends it {
|
|
|
1528
1537
|
return this.set(t), this.commit(), this;
|
|
1529
1538
|
}
|
|
1530
1539
|
}
|
|
1531
|
-
const hs = l(
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1540
|
+
const hs = l(
|
|
1541
|
+
"mainButton",
|
|
1542
|
+
({
|
|
1543
|
+
postEvent: e,
|
|
1544
|
+
themeParams: t,
|
|
1545
|
+
state: s = {
|
|
1546
|
+
isVisible: !1,
|
|
1547
|
+
isEnabled: !1,
|
|
1548
|
+
text: "",
|
|
1549
|
+
isLoaderVisible: !1,
|
|
1550
|
+
textColor: t.buttonTextColor || "#ffffff",
|
|
1551
|
+
backgroundColor: t.buttonColor || "#000000"
|
|
1552
|
+
}
|
|
1553
|
+
}) => new cs({ ...s, postEvent: e })
|
|
1554
|
+
);
|
|
1555
|
+
function ps() {
|
|
1544
1556
|
return at({
|
|
1545
|
-
contact:
|
|
1557
|
+
contact: g({
|
|
1546
1558
|
userId: {
|
|
1547
|
-
type:
|
|
1559
|
+
type: x(),
|
|
1548
1560
|
from: "user_id"
|
|
1549
1561
|
},
|
|
1550
1562
|
phoneNumber: {
|
|
1551
|
-
type:
|
|
1563
|
+
type: p(),
|
|
1552
1564
|
from: "phone_number"
|
|
1553
1565
|
},
|
|
1554
1566
|
firstName: {
|
|
1555
|
-
type:
|
|
1567
|
+
type: p(),
|
|
1556
1568
|
from: "first_name"
|
|
1557
1569
|
},
|
|
1558
1570
|
lastName: {
|
|
1559
|
-
type:
|
|
1571
|
+
type: p().optional(),
|
|
1560
1572
|
from: "last_name"
|
|
1561
1573
|
}
|
|
1562
1574
|
}),
|
|
@@ -1564,7 +1576,7 @@ function cs() {
|
|
|
1564
1576
|
type: Nt(),
|
|
1565
1577
|
from: "auth_date"
|
|
1566
1578
|
},
|
|
1567
|
-
hash:
|
|
1579
|
+
hash: p()
|
|
1568
1580
|
}, "RequestedContact");
|
|
1569
1581
|
}
|
|
1570
1582
|
function Kt(e, t) {
|
|
@@ -1573,12 +1585,12 @@ function Kt(e, t) {
|
|
|
1573
1585
|
return S(n, r, e);
|
|
1574
1586
|
};
|
|
1575
1587
|
}
|
|
1576
|
-
function
|
|
1588
|
+
function us(e) {
|
|
1577
1589
|
return new Promise((t) => {
|
|
1578
1590
|
setTimeout(t, e);
|
|
1579
1591
|
});
|
|
1580
1592
|
}
|
|
1581
|
-
class
|
|
1593
|
+
class ls extends V {
|
|
1582
1594
|
constructor({ postEvent: t, createRequestId: s, version: n, botInline: r, ...i }) {
|
|
1583
1595
|
super(i, n, {
|
|
1584
1596
|
requestPhoneAccess: "web_app_request_phone",
|
|
@@ -1586,9 +1598,9 @@ class us extends B {
|
|
|
1586
1598
|
switchInlineQuery: "web_app_switch_inline_query",
|
|
1587
1599
|
setHeaderColor: "web_app_set_header_color",
|
|
1588
1600
|
setBackgroundColor: "web_app_set_background_color"
|
|
1589
|
-
}),
|
|
1590
|
-
const
|
|
1591
|
-
this.supports = (
|
|
1601
|
+
}), c(this, "botInline"), c(this, "postEvent"), c(this, "createRequestId"), c(this, "requestPhoneAccessPromise"), c(this, "requestWriteAccessPromise"), c(this, "supportsParam"), this.createRequestId = s, this.postEvent = t, this.botInline = r;
|
|
1602
|
+
const a = this.supports.bind(this);
|
|
1603
|
+
this.supports = (o) => a(o) ? o !== "switchInlineQuery" || r : !1, this.supportsParam = Kt(n, {
|
|
1592
1604
|
"setHeaderColor.color": ["web_app_set_header_color", "color"]
|
|
1593
1605
|
});
|
|
1594
1606
|
}
|
|
@@ -1599,8 +1611,8 @@ class us extends B {
|
|
|
1599
1611
|
async getRequestedContact({
|
|
1600
1612
|
timeout: t = 1e4
|
|
1601
1613
|
} = {}) {
|
|
1602
|
-
return
|
|
1603
|
-
await
|
|
1614
|
+
return ps().parse(
|
|
1615
|
+
await q(
|
|
1604
1616
|
"getRequestedContact",
|
|
1605
1617
|
{},
|
|
1606
1618
|
this.createRequestId(),
|
|
@@ -1639,7 +1651,7 @@ class us extends B {
|
|
|
1639
1651
|
* True if current Mini App background color is recognized as dark.
|
|
1640
1652
|
*/
|
|
1641
1653
|
get isDark() {
|
|
1642
|
-
return
|
|
1654
|
+
return qt(this.bgColor);
|
|
1643
1655
|
}
|
|
1644
1656
|
/**
|
|
1645
1657
|
* Informs the Telegram app that the Mini App is ready to be displayed.
|
|
@@ -1668,13 +1680,13 @@ class us extends B {
|
|
|
1668
1680
|
throw new Error("Access denied.");
|
|
1669
1681
|
const s = Date.now() + t;
|
|
1670
1682
|
let n = 50;
|
|
1671
|
-
return
|
|
1683
|
+
return Ot(async () => {
|
|
1672
1684
|
for (; Date.now() < s; ) {
|
|
1673
1685
|
try {
|
|
1674
1686
|
return await this.getRequestedContact();
|
|
1675
1687
|
} catch {
|
|
1676
1688
|
}
|
|
1677
|
-
await
|
|
1689
|
+
await us(n), n += 50;
|
|
1678
1690
|
}
|
|
1679
1691
|
throw It(t);
|
|
1680
1692
|
}, t);
|
|
@@ -1689,7 +1701,7 @@ class us extends B {
|
|
|
1689
1701
|
* @see requestContact
|
|
1690
1702
|
*/
|
|
1691
1703
|
async requestPhoneAccess(t = {}) {
|
|
1692
|
-
return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise =
|
|
1704
|
+
return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = w({
|
|
1693
1705
|
...t,
|
|
1694
1706
|
method: "web_app_request_phone",
|
|
1695
1707
|
event: "phone_requested",
|
|
@@ -1701,7 +1713,7 @@ class us extends B {
|
|
|
1701
1713
|
* @param options - additional options.
|
|
1702
1714
|
*/
|
|
1703
1715
|
async requestWriteAccess(t = {}) {
|
|
1704
|
-
return this.requestWriteAccessPromise || (this.requestWriteAccessPromise =
|
|
1716
|
+
return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = w({
|
|
1705
1717
|
...t,
|
|
1706
1718
|
method: "web_app_request_write_access",
|
|
1707
1719
|
event: "write_access_requested",
|
|
@@ -1759,16 +1771,19 @@ class us extends B {
|
|
|
1759
1771
|
this.postEvent("web_app_switch_inline_query", { query: t, chat_types: s });
|
|
1760
1772
|
}
|
|
1761
1773
|
}
|
|
1762
|
-
const ds = l(
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
}
|
|
1771
|
-
|
|
1774
|
+
const ds = l(
|
|
1775
|
+
"miniApp",
|
|
1776
|
+
({
|
|
1777
|
+
themeParams: e,
|
|
1778
|
+
botInline: t = !1,
|
|
1779
|
+
state: s = {
|
|
1780
|
+
bgColor: e.bgColor || "#ffffff",
|
|
1781
|
+
headerColor: e.headerBgColor || "#000000"
|
|
1782
|
+
},
|
|
1783
|
+
...n
|
|
1784
|
+
}) => new ls({ ...n, ...s, botInline: t })
|
|
1785
|
+
);
|
|
1786
|
+
function _s(e) {
|
|
1772
1787
|
const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
|
|
1773
1788
|
let r;
|
|
1774
1789
|
if (s.length > 64)
|
|
@@ -1778,21 +1793,21 @@ function ls(e) {
|
|
|
1778
1793
|
if (n.length > 3)
|
|
1779
1794
|
throw new Error(`Buttons have incorrect size: ${n.length}`);
|
|
1780
1795
|
return n.length ? r = n.map((i) => {
|
|
1781
|
-
const { id:
|
|
1782
|
-
if (
|
|
1783
|
-
throw new Error(`Button ID has incorrect size: ${
|
|
1796
|
+
const { id: a = "" } = i;
|
|
1797
|
+
if (a.length > 64)
|
|
1798
|
+
throw new Error(`Button ID has incorrect size: ${a}`);
|
|
1784
1799
|
if (!i.type || i.type === "default" || i.type === "destructive") {
|
|
1785
|
-
const
|
|
1786
|
-
if (!
|
|
1787
|
-
const
|
|
1788
|
-
throw new Error(`Button text with type "${
|
|
1800
|
+
const o = i.text.trim();
|
|
1801
|
+
if (!o.length || o.length > 64) {
|
|
1802
|
+
const u = i.type || "default";
|
|
1803
|
+
throw new Error(`Button text with type "${u}" has incorrect size: ${i.text.length}`);
|
|
1789
1804
|
}
|
|
1790
|
-
return { ...i, text:
|
|
1805
|
+
return { ...i, text: o, id: a };
|
|
1791
1806
|
}
|
|
1792
|
-
return { ...i, id:
|
|
1807
|
+
return { ...i, id: a };
|
|
1793
1808
|
}) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
|
|
1794
1809
|
}
|
|
1795
|
-
class
|
|
1810
|
+
class gs extends V {
|
|
1796
1811
|
constructor(t, s, n) {
|
|
1797
1812
|
super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
|
|
1798
1813
|
}
|
|
@@ -1821,11 +1836,11 @@ class _s extends B {
|
|
|
1821
1836
|
throw new Error("Popup is already opened.");
|
|
1822
1837
|
this.isOpened = !0;
|
|
1823
1838
|
try {
|
|
1824
|
-
const { button_id: s = null } = await
|
|
1839
|
+
const { button_id: s = null } = await w({
|
|
1825
1840
|
event: "popup_closed",
|
|
1826
1841
|
method: "web_app_open_popup",
|
|
1827
1842
|
postEvent: this.postEvent,
|
|
1828
|
-
params:
|
|
1843
|
+
params: _s(t)
|
|
1829
1844
|
});
|
|
1830
1845
|
return s;
|
|
1831
1846
|
} finally {
|
|
@@ -1833,10 +1848,10 @@ class _s extends B {
|
|
|
1833
1848
|
}
|
|
1834
1849
|
}
|
|
1835
1850
|
}
|
|
1836
|
-
const
|
|
1837
|
-
({ postEvent: e, version: t }) => new
|
|
1851
|
+
const ws = l(
|
|
1852
|
+
({ postEvent: e, version: t }) => new gs(!1, t, e)
|
|
1838
1853
|
);
|
|
1839
|
-
class
|
|
1854
|
+
class fs extends V {
|
|
1840
1855
|
constructor(t, s, n) {
|
|
1841
1856
|
super({ isOpened: t }, s, {
|
|
1842
1857
|
close: "web_app_close_scan_qr_popup",
|
|
@@ -1869,7 +1884,7 @@ class ws extends B {
|
|
|
1869
1884
|
throw new Error("QR scanner is already opened.");
|
|
1870
1885
|
this.isOpened = !0;
|
|
1871
1886
|
try {
|
|
1872
|
-
return (await
|
|
1887
|
+
return (await w({
|
|
1873
1888
|
method: "web_app_open_scan_qr_popup",
|
|
1874
1889
|
event: ["qr_text_received", "scan_qr_popup_closed"],
|
|
1875
1890
|
postEvent: this.postEvent,
|
|
@@ -1880,15 +1895,15 @@ class ws extends B {
|
|
|
1880
1895
|
}
|
|
1881
1896
|
}
|
|
1882
1897
|
}
|
|
1883
|
-
const
|
|
1884
|
-
({ version: e, postEvent: t }) => new
|
|
1898
|
+
const ms = l(
|
|
1899
|
+
({ version: e, postEvent: t }) => new fs(!1, e, t)
|
|
1885
1900
|
);
|
|
1886
|
-
class
|
|
1901
|
+
class bs extends ot {
|
|
1887
1902
|
constructor(t, s, n) {
|
|
1888
1903
|
super({ isVisible: t }, s, {
|
|
1889
1904
|
show: "web_app_setup_settings_button",
|
|
1890
1905
|
hide: "web_app_setup_settings_button"
|
|
1891
|
-
}),
|
|
1906
|
+
}), c(this, "on", (r, i) => r === "click" ? E("settings_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? z("settings_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
|
|
1892
1907
|
}
|
|
1893
1908
|
set isVisible(t) {
|
|
1894
1909
|
this.set("isVisible", t), this.postEvent("web_app_setup_settings_button", { is_visible: t });
|
|
@@ -1912,15 +1927,18 @@ class ms extends ot {
|
|
|
1912
1927
|
this.isVisible = !0;
|
|
1913
1928
|
}
|
|
1914
1929
|
}
|
|
1915
|
-
const
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1930
|
+
const vs = l(
|
|
1931
|
+
"settingsButton",
|
|
1932
|
+
({
|
|
1933
|
+
version: e,
|
|
1934
|
+
postEvent: t,
|
|
1935
|
+
state: s = { isVisible: !1 }
|
|
1936
|
+
}) => new bs(s.isVisible, e, t)
|
|
1937
|
+
);
|
|
1920
1938
|
function Jt(e) {
|
|
1921
|
-
return
|
|
1939
|
+
return Mt().parse(e);
|
|
1922
1940
|
}
|
|
1923
|
-
class
|
|
1941
|
+
class ys extends ct {
|
|
1924
1942
|
/**
|
|
1925
1943
|
* @since v6.10
|
|
1926
1944
|
*/
|
|
@@ -1959,7 +1977,7 @@ class vs extends ht {
|
|
|
1959
1977
|
* value is calculated according to theme bg color.
|
|
1960
1978
|
*/
|
|
1961
1979
|
get isDark() {
|
|
1962
|
-
return !this.bgColor ||
|
|
1980
|
+
return !this.bgColor || qt(this.bgColor);
|
|
1963
1981
|
}
|
|
1964
1982
|
get linkColor() {
|
|
1965
1983
|
return this.get("linkColor");
|
|
@@ -1998,20 +2016,23 @@ class vs extends ht {
|
|
|
1998
2016
|
return this.get("textColor");
|
|
1999
2017
|
}
|
|
2000
2018
|
}
|
|
2001
|
-
const
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2019
|
+
const Es = l(
|
|
2020
|
+
"themeParams",
|
|
2021
|
+
({ themeParams: e, state: t = e, addCleanup: s }) => {
|
|
2022
|
+
const n = new ys(t);
|
|
2023
|
+
return s(n.listen()), n;
|
|
2024
|
+
}
|
|
2025
|
+
);
|
|
2026
|
+
function bn(e = {}) {
|
|
2027
|
+
return w({
|
|
2007
2028
|
...e,
|
|
2008
2029
|
method: "web_app_request_theme",
|
|
2009
2030
|
event: "theme_changed"
|
|
2010
2031
|
}).then(Jt);
|
|
2011
2032
|
}
|
|
2012
|
-
class
|
|
2033
|
+
class Ps extends ht {
|
|
2013
2034
|
constructor(t, s, n) {
|
|
2014
|
-
super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }),
|
|
2035
|
+
super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Kt(t, {
|
|
2015
2036
|
"openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
|
|
2016
2037
|
});
|
|
2017
2038
|
}
|
|
@@ -2060,42 +2081,42 @@ class Es extends ct {
|
|
|
2060
2081
|
async readTextFromClipboard() {
|
|
2061
2082
|
const t = this.createRequestId(), {
|
|
2062
2083
|
data: s = null
|
|
2063
|
-
} = await
|
|
2084
|
+
} = await w({
|
|
2064
2085
|
method: "web_app_read_text_from_clipboard",
|
|
2065
2086
|
event: "clipboard_text_received",
|
|
2066
2087
|
postEvent: this.postEvent,
|
|
2067
2088
|
params: { req_id: t },
|
|
2068
|
-
capture:
|
|
2089
|
+
capture: kt(t)
|
|
2069
2090
|
});
|
|
2070
2091
|
return s;
|
|
2071
2092
|
}
|
|
2072
2093
|
}
|
|
2073
|
-
const
|
|
2074
|
-
({ version: e, postEvent: t, createRequestId: s }) => new
|
|
2094
|
+
const Rs = l(
|
|
2095
|
+
({ version: e, postEvent: t, createRequestId: s }) => new Ps(e, s, t)
|
|
2075
2096
|
);
|
|
2076
2097
|
async function Qt(e = {}) {
|
|
2077
2098
|
const {
|
|
2078
2099
|
is_expanded: t,
|
|
2079
2100
|
is_state_stable: s,
|
|
2080
2101
|
...n
|
|
2081
|
-
} = await
|
|
2102
|
+
} = await w({
|
|
2082
2103
|
...e,
|
|
2083
2104
|
method: "web_app_request_viewport",
|
|
2084
2105
|
event: "viewport_changed"
|
|
2085
2106
|
});
|
|
2086
2107
|
return { ...n, isExpanded: t, isStateStable: s };
|
|
2087
2108
|
}
|
|
2088
|
-
function
|
|
2109
|
+
function O(e) {
|
|
2089
2110
|
return e < 0 ? 0 : e;
|
|
2090
2111
|
}
|
|
2091
|
-
class
|
|
2112
|
+
class xs extends ct {
|
|
2092
2113
|
constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
|
|
2093
2114
|
super({
|
|
2094
|
-
height:
|
|
2115
|
+
height: O(n),
|
|
2095
2116
|
isExpanded: i,
|
|
2096
|
-
stableHeight:
|
|
2097
|
-
width:
|
|
2098
|
-
}),
|
|
2117
|
+
stableHeight: O(s),
|
|
2118
|
+
width: O(r)
|
|
2119
|
+
}), c(this, "postEvent"), this.postEvent = t;
|
|
2099
2120
|
}
|
|
2100
2121
|
/**
|
|
2101
2122
|
* Requests viewport information from the Telegram application and updates current Viewport
|
|
@@ -2156,12 +2177,12 @@ class Ft extends ht {
|
|
|
2156
2177
|
width: n,
|
|
2157
2178
|
is_expanded: r,
|
|
2158
2179
|
is_state_stable: i
|
|
2159
|
-
} = t,
|
|
2180
|
+
} = t, a = O(s);
|
|
2160
2181
|
this.set({
|
|
2161
|
-
height:
|
|
2182
|
+
height: a,
|
|
2162
2183
|
isExpanded: r,
|
|
2163
|
-
width:
|
|
2164
|
-
...i ? { stableHeight:
|
|
2184
|
+
width: O(n),
|
|
2185
|
+
...i ? { stableHeight: a } : {}
|
|
2165
2186
|
});
|
|
2166
2187
|
});
|
|
2167
2188
|
}
|
|
@@ -2195,68 +2216,49 @@ class Ft extends ht {
|
|
|
2195
2216
|
return this.stableHeight === this.height;
|
|
2196
2217
|
}
|
|
2197
2218
|
}
|
|
2198
|
-
async function Rs(e, t = {}) {
|
|
2199
|
-
const {
|
|
2200
|
-
height: s,
|
|
2201
|
-
width: n,
|
|
2202
|
-
isExpanded: r,
|
|
2203
|
-
isStateStable: i
|
|
2204
|
-
} = await Qt({ ...t, postEvent: e });
|
|
2205
|
-
return new Ft({
|
|
2206
|
-
postEvent: e,
|
|
2207
|
-
height: s,
|
|
2208
|
-
width: n,
|
|
2209
|
-
isExpanded: r,
|
|
2210
|
-
stableHeight: i ? s : 0
|
|
2211
|
-
});
|
|
2212
|
-
}
|
|
2213
|
-
function xs({
|
|
2214
|
-
state: e,
|
|
2215
|
-
platform: t,
|
|
2216
|
-
postEvent: s
|
|
2217
|
-
}) {
|
|
2218
|
-
let n = !1, r = 0, i = 0, o = 0;
|
|
2219
|
-
return e ? (n = e.isExpanded, r = e.height, i = e.width, o = e.stableHeight) : ["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t) && (n = !0, r = window.innerHeight, i = window.innerWidth, o = window.innerHeight), new Ft({
|
|
2220
|
-
postEvent: s,
|
|
2221
|
-
height: r,
|
|
2222
|
-
width: i,
|
|
2223
|
-
stableHeight: o,
|
|
2224
|
-
isExpanded: n
|
|
2225
|
-
});
|
|
2226
|
-
}
|
|
2227
2219
|
const Cs = l(
|
|
2228
2220
|
"viewport",
|
|
2229
|
-
async (e) => {
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2221
|
+
async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
|
|
2222
|
+
let r = !1, i = 0, a = 0, o = 0;
|
|
2223
|
+
if (e)
|
|
2224
|
+
r = e.isExpanded, i = e.height, a = e.width, o = e.stableHeight;
|
|
2225
|
+
else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
|
|
2226
|
+
r = !0, i = window.innerHeight, a = window.innerWidth, o = window.innerHeight;
|
|
2227
|
+
else {
|
|
2228
|
+
const h = await Qt({ timeout: 1e3, postEvent: s });
|
|
2229
|
+
r = h.isExpanded, i = h.height, a = h.width, o = h.isStateStable ? i : 0;
|
|
2230
|
+
}
|
|
2231
|
+
const u = new xs({
|
|
2232
|
+
postEvent: s,
|
|
2233
|
+
height: i,
|
|
2234
|
+
width: a,
|
|
2235
|
+
stableHeight: o,
|
|
2236
|
+
isExpanded: r
|
|
2237
|
+
});
|
|
2238
|
+
return n(u.listen()), u;
|
|
2237
2239
|
}
|
|
2238
2240
|
);
|
|
2239
2241
|
function R(e, t) {
|
|
2240
2242
|
document.documentElement.style.setProperty(e, t);
|
|
2241
2243
|
}
|
|
2242
|
-
function
|
|
2243
|
-
s || (s = (
|
|
2244
|
+
function vn(e, t, s) {
|
|
2245
|
+
s || (s = (o) => `--tg-${o}-color`);
|
|
2244
2246
|
const n = s("header"), r = s("bg"), i = () => {
|
|
2245
|
-
const { headerColor:
|
|
2246
|
-
if (rt(
|
|
2247
|
-
R(n,
|
|
2247
|
+
const { headerColor: o } = e;
|
|
2248
|
+
if (rt(o))
|
|
2249
|
+
R(n, o);
|
|
2248
2250
|
else {
|
|
2249
|
-
const { bgColor:
|
|
2250
|
-
|
|
2251
|
+
const { bgColor: u, secondaryBgColor: h } = t;
|
|
2252
|
+
o === "bg_color" && u ? R(n, u) : o === "secondary_bg_color" && h && R(n, h);
|
|
2251
2253
|
}
|
|
2252
2254
|
R(r, e.bgColor);
|
|
2253
|
-
},
|
|
2255
|
+
}, a = [
|
|
2254
2256
|
t.on("change", i),
|
|
2255
2257
|
e.on("change", i)
|
|
2256
2258
|
];
|
|
2257
|
-
return i(), () =>
|
|
2259
|
+
return i(), () => a.forEach((o) => o());
|
|
2258
2260
|
}
|
|
2259
|
-
function
|
|
2261
|
+
function yn(e, t) {
|
|
2260
2262
|
t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
|
|
2261
2263
|
const s = () => {
|
|
2262
2264
|
Object.entries(e.getState()).forEach(([n, r]) => {
|
|
@@ -2265,23 +2267,23 @@ function bn(e, t) {
|
|
|
2265
2267
|
};
|
|
2266
2268
|
return s(), e.on("change", s);
|
|
2267
2269
|
}
|
|
2268
|
-
function
|
|
2269
|
-
t || (t = (
|
|
2270
|
+
function En(e, t) {
|
|
2271
|
+
t || (t = (h) => `--tg-viewport-${h}`);
|
|
2270
2272
|
const [
|
|
2271
2273
|
s,
|
|
2272
2274
|
n,
|
|
2273
2275
|
r
|
|
2274
|
-
] = ["height", "width", "stable-height"].map((
|
|
2276
|
+
] = ["height", "width", "stable-height"].map((h) => t(h)), i = () => R(s, `${e.height}px`), a = () => R(n, `${e.width}px`), o = () => R(r, `${e.stableHeight}px`), u = [
|
|
2275
2277
|
e.on("change:height", i),
|
|
2276
|
-
e.on("change:width",
|
|
2277
|
-
e.on("change:stableHeight",
|
|
2278
|
+
e.on("change:width", a),
|
|
2279
|
+
e.on("change:stableHeight", o)
|
|
2278
2280
|
];
|
|
2279
|
-
return i(),
|
|
2281
|
+
return i(), a(), o(), () => u.forEach((h) => h());
|
|
2280
2282
|
}
|
|
2281
2283
|
function Ss(e = !0) {
|
|
2282
2284
|
const t = [
|
|
2283
2285
|
E("reload_iframe", () => {
|
|
2284
|
-
|
|
2286
|
+
N("iframe_will_reload"), window.location.reload();
|
|
2285
2287
|
})
|
|
2286
2288
|
], s = () => t.forEach((n) => n());
|
|
2287
2289
|
if (e) {
|
|
@@ -2293,22 +2295,25 @@ function Ss(e = !0) {
|
|
|
2293
2295
|
() => document.head.removeChild(n)
|
|
2294
2296
|
);
|
|
2295
2297
|
}
|
|
2296
|
-
return
|
|
2298
|
+
return N("iframe_ready", { reload_supported: !0 }), s;
|
|
2297
2299
|
}
|
|
2298
|
-
|
|
2300
|
+
function Ts() {
|
|
2301
|
+
return typeof window > "u";
|
|
2302
|
+
}
|
|
2303
|
+
async function Pn() {
|
|
2299
2304
|
if (St(window))
|
|
2300
2305
|
return !0;
|
|
2301
2306
|
try {
|
|
2302
|
-
return await
|
|
2307
|
+
return await w({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
|
|
2303
2308
|
} catch {
|
|
2304
2309
|
return !1;
|
|
2305
2310
|
}
|
|
2306
2311
|
}
|
|
2307
|
-
function
|
|
2312
|
+
function As(e) {
|
|
2308
2313
|
return e instanceof W;
|
|
2309
2314
|
}
|
|
2310
|
-
function
|
|
2311
|
-
return
|
|
2315
|
+
function Rn(e, t) {
|
|
2316
|
+
return As(e) && e.type === t;
|
|
2312
2317
|
}
|
|
2313
2318
|
function J(e, t) {
|
|
2314
2319
|
let s, n, r;
|
|
@@ -2319,12 +2324,12 @@ function J(e, t) {
|
|
|
2319
2324
|
});
|
|
2320
2325
|
}
|
|
2321
2326
|
class ks {
|
|
2322
|
-
constructor(t, s, n =
|
|
2323
|
-
if (
|
|
2324
|
-
throw m(
|
|
2327
|
+
constructor(t, s, n = N) {
|
|
2328
|
+
if (c(this, "history"), c(this, "ee", new H()), c(this, "attached", !1), c(this, "back", () => this.go(-1)), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this._index = s, this.postEvent = n, t.length === 0)
|
|
2329
|
+
throw m(_e, "History should not be empty.");
|
|
2325
2330
|
if (s < 0 || s >= t.length)
|
|
2326
2331
|
throw m(
|
|
2327
|
-
|
|
2332
|
+
ge,
|
|
2328
2333
|
"Index should not be zero and higher or equal than history size."
|
|
2329
2334
|
);
|
|
2330
2335
|
this.history = t.map((r) => J(r, ""));
|
|
@@ -2445,26 +2450,26 @@ function Q({
|
|
|
2445
2450
|
}) {
|
|
2446
2451
|
return { ...e || { hash: "", search: "" }, ...t };
|
|
2447
2452
|
}
|
|
2448
|
-
function
|
|
2453
|
+
function B(e, t) {
|
|
2449
2454
|
return e.startsWith(t) ? e : `${t}${e}`;
|
|
2450
2455
|
}
|
|
2451
|
-
function
|
|
2456
|
+
function L(e) {
|
|
2452
2457
|
return new URL(
|
|
2453
|
-
typeof e == "string" ? e : `${e.pathname || ""}${
|
|
2458
|
+
typeof e == "string" ? e : `${e.pathname || ""}${B(e.search || "", "?")}${B(e.hash || "", "#")}`,
|
|
2454
2459
|
"http://a"
|
|
2455
2460
|
);
|
|
2456
2461
|
}
|
|
2457
|
-
function
|
|
2458
|
-
const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s =
|
|
2462
|
+
function U(e) {
|
|
2463
|
+
const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = L(e);
|
|
2459
2464
|
return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
|
|
2460
2465
|
}
|
|
2461
2466
|
function F(e, t, s) {
|
|
2462
2467
|
let n, r;
|
|
2463
|
-
typeof e == "string" ? n = e : (n =
|
|
2464
|
-
const { pathname: i, search:
|
|
2465
|
-
return { id: r, pathname: i, params: { hash:
|
|
2468
|
+
typeof e == "string" ? n = e : (n = U(e), s = e.state, r = e.id);
|
|
2469
|
+
const { pathname: i, search: a, hash: o } = new URL(n, `http://a${B(t, "/")}`);
|
|
2470
|
+
return { id: r, pathname: i, params: { hash: o, search: a, state: s } };
|
|
2466
2471
|
}
|
|
2467
|
-
async function
|
|
2472
|
+
async function D(e) {
|
|
2468
2473
|
return e === 0 ? !0 : Promise.race([
|
|
2469
2474
|
new Promise((t) => {
|
|
2470
2475
|
const s = tt("popstate", () => {
|
|
@@ -2478,39 +2483,39 @@ async function q(e) {
|
|
|
2478
2483
|
})
|
|
2479
2484
|
]);
|
|
2480
2485
|
}
|
|
2481
|
-
async function
|
|
2482
|
-
if (window.history.length <= 1 || (window.history.pushState(null, ""), await
|
|
2486
|
+
async function Is() {
|
|
2487
|
+
if (window.history.length <= 1 || (window.history.pushState(null, ""), await D(1 - window.history.length)))
|
|
2483
2488
|
return;
|
|
2484
|
-
let e = await
|
|
2489
|
+
let e = await D(-1);
|
|
2485
2490
|
for (; e; )
|
|
2486
|
-
e = await
|
|
2491
|
+
e = await D(-1);
|
|
2487
2492
|
}
|
|
2488
|
-
function
|
|
2489
|
-
return
|
|
2493
|
+
function Ft(e) {
|
|
2494
|
+
return L(e).pathname;
|
|
2490
2495
|
}
|
|
2491
|
-
const
|
|
2492
|
-
class
|
|
2493
|
-
constructor(t, s, { postEvent: n, hashMode: r, base: i } = {}) {
|
|
2494
|
-
|
|
2495
|
-
if (
|
|
2496
|
+
const ft = 0, Y = 1, Z = 2;
|
|
2497
|
+
class Yt {
|
|
2498
|
+
constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
|
|
2499
|
+
c(this, "navigator"), c(this, "ee", new H()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: a }) => {
|
|
2500
|
+
if (a === null)
|
|
2496
2501
|
return this.push(this.parsePath(window.location.href));
|
|
2497
|
-
|
|
2498
|
-
}),
|
|
2499
|
-
to:
|
|
2500
|
-
from:
|
|
2501
|
-
delta:
|
|
2502
|
+
a === ft ? window.history.forward() : a === Y && this.back(), a === Z && this.forward();
|
|
2503
|
+
}), c(this, "onNavigatorChange", async ({
|
|
2504
|
+
to: a,
|
|
2505
|
+
from: o,
|
|
2506
|
+
delta: u
|
|
2502
2507
|
}) => {
|
|
2503
2508
|
this.attached && await this.syncHistory(), this.ee.emit("change", {
|
|
2504
|
-
delta:
|
|
2505
|
-
from: Q(
|
|
2506
|
-
to: Q(
|
|
2509
|
+
delta: u,
|
|
2510
|
+
from: Q(o),
|
|
2511
|
+
to: Q(a),
|
|
2507
2512
|
navigator: this
|
|
2508
2513
|
});
|
|
2509
|
-
}),
|
|
2510
|
-
t.map((
|
|
2514
|
+
}), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new ks(
|
|
2515
|
+
t.map((a) => F(a, "/")),
|
|
2511
2516
|
s,
|
|
2512
2517
|
n
|
|
2513
|
-
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base =
|
|
2518
|
+
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Ft(i || "");
|
|
2514
2519
|
}
|
|
2515
2520
|
/**
|
|
2516
2521
|
* Attaches current navigator to the browser history allowing navigator to manipulate it.
|
|
@@ -2608,7 +2613,7 @@ class Zt {
|
|
|
2608
2613
|
* "/pathname?search#hash"
|
|
2609
2614
|
*/
|
|
2610
2615
|
get path() {
|
|
2611
|
-
return
|
|
2616
|
+
return U(this);
|
|
2612
2617
|
}
|
|
2613
2618
|
/**
|
|
2614
2619
|
* Current pathname. Always starts with the slash.
|
|
@@ -2637,8 +2642,8 @@ class Zt {
|
|
|
2637
2642
|
* // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
|
|
2638
2643
|
*/
|
|
2639
2644
|
parsePath(t) {
|
|
2640
|
-
let s =
|
|
2641
|
-
return this.hashMode && (s =
|
|
2645
|
+
let s = L(t);
|
|
2646
|
+
return this.hashMode && (s = L(s.hash.slice(1))), {
|
|
2642
2647
|
pathname: s.pathname,
|
|
2643
2648
|
search: s.search,
|
|
2644
2649
|
hash: s.hash
|
|
@@ -2658,8 +2663,8 @@ class Zt {
|
|
|
2658
2663
|
* @param value - path presented as string or URLLike.
|
|
2659
2664
|
*/
|
|
2660
2665
|
renderPath(t) {
|
|
2661
|
-
const s = (this.base.length === 1 ? "" : this.base) +
|
|
2662
|
-
return this.hashMode ?
|
|
2666
|
+
const s = (this.base.length === 1 ? "" : this.base) + B(U(t), "/");
|
|
2667
|
+
return this.hashMode ? B(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
|
|
2663
2668
|
}
|
|
2664
2669
|
/**
|
|
2665
2670
|
* Synchronizes current navigator state with browser history.
|
|
@@ -2667,7 +2672,7 @@ class Zt {
|
|
|
2667
2672
|
async syncHistory() {
|
|
2668
2673
|
window.removeEventListener("popstate", this.onPopState);
|
|
2669
2674
|
const { state: t } = this, s = this.renderPath(this);
|
|
2670
|
-
await
|
|
2675
|
+
await Is(), this.hasPrev && this.hasNext ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s), window.history.pushState(Z, ""), await D(-1)) : this.hasPrev ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(Z, ""), await D(-1)) : (window.history.replaceState(ft, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
|
|
2671
2676
|
}
|
|
2672
2677
|
/**
|
|
2673
2678
|
* Current query parameters.
|
|
@@ -2685,24 +2690,24 @@ class Zt {
|
|
|
2685
2690
|
return (this.navigator.current.params || {}).state;
|
|
2686
2691
|
}
|
|
2687
2692
|
}
|
|
2688
|
-
function
|
|
2693
|
+
function Os(e) {
|
|
2689
2694
|
e || (e = {});
|
|
2690
2695
|
const { href: t, hash: s } = window.location;
|
|
2691
|
-
let n =
|
|
2692
|
-
e.hashMode ? s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
|
|
2696
|
+
let n = U(
|
|
2697
|
+
e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
|
|
2693
2698
|
);
|
|
2694
|
-
const r = e.base ?
|
|
2699
|
+
const r = e.base ? Ft(e.base) : void 0;
|
|
2695
2700
|
if (r) {
|
|
2696
2701
|
if (!n.startsWith(r))
|
|
2697
2702
|
throw m(
|
|
2698
|
-
|
|
2703
|
+
we,
|
|
2699
2704
|
`Path "${n}" expected to be starting with "${r}"`
|
|
2700
2705
|
);
|
|
2701
2706
|
n = n.slice(r.length);
|
|
2702
2707
|
}
|
|
2703
|
-
return new
|
|
2708
|
+
return new Yt([n], 0, e);
|
|
2704
2709
|
}
|
|
2705
|
-
function
|
|
2710
|
+
function xn(e) {
|
|
2706
2711
|
const t = e.match(/#(.+)/);
|
|
2707
2712
|
return t ? t[1] : null;
|
|
2708
2713
|
}
|
|
@@ -2712,269 +2717,301 @@ function qs(e, t) {
|
|
|
2712
2717
|
if (s)
|
|
2713
2718
|
try {
|
|
2714
2719
|
const { index: n, history: r } = JSON.parse(s);
|
|
2715
|
-
return new
|
|
2720
|
+
return new Yt(r, n, t);
|
|
2716
2721
|
} catch (n) {
|
|
2717
2722
|
console.error("Unable to restore hash navigator state.", n);
|
|
2718
2723
|
}
|
|
2719
2724
|
}
|
|
2720
|
-
return
|
|
2725
|
+
return Os(t);
|
|
2721
2726
|
}
|
|
2722
|
-
function
|
|
2727
|
+
function Cn(e, t) {
|
|
2723
2728
|
const s = qs(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
|
|
2724
2729
|
index: s.index,
|
|
2725
2730
|
history: s.history
|
|
2726
2731
|
}));
|
|
2727
2732
|
return s.on("change", n), n(), s;
|
|
2728
2733
|
}
|
|
2729
|
-
function
|
|
2734
|
+
function d(e, t) {
|
|
2730
2735
|
function s(n) {
|
|
2731
|
-
return (r, i,
|
|
2732
|
-
const
|
|
2733
|
-
return /* @__PURE__ */
|
|
2736
|
+
return (r, i, a) => (o) => {
|
|
2737
|
+
const u = o[i] || [], h = { ...o, [r]: n(...u) };
|
|
2738
|
+
return /* @__PURE__ */ mt(a, { ...h });
|
|
2734
2739
|
};
|
|
2735
2740
|
}
|
|
2736
2741
|
return [s(e), s(t)];
|
|
2737
2742
|
}
|
|
2738
|
-
const
|
|
2739
|
-
function
|
|
2740
|
-
const e =
|
|
2743
|
+
const Zt = Xt(void 0);
|
|
2744
|
+
function Ds() {
|
|
2745
|
+
const e = te(Zt);
|
|
2741
2746
|
if (!e)
|
|
2742
2747
|
throw new Error("useSDK was used outside the SDKProvider.");
|
|
2743
2748
|
return e;
|
|
2744
2749
|
}
|
|
2745
|
-
function
|
|
2746
|
-
|
|
2747
|
-
const r =
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
return
|
|
2755
|
-
|
|
2750
|
+
function _(e) {
|
|
2751
|
+
function t(n) {
|
|
2752
|
+
const r = Ds(), [i, a] = bt(
|
|
2753
|
+
n ? void 0 : () => {
|
|
2754
|
+
if (Ts())
|
|
2755
|
+
throw new Error("Using hooks on the server side, you must explicitly specify ssr = true option");
|
|
2756
|
+
return r.use(e);
|
|
2757
|
+
}
|
|
2758
|
+
);
|
|
2759
|
+
return C(() => {
|
|
2760
|
+
a(r.use(e));
|
|
2761
|
+
}, [r]), i;
|
|
2762
|
+
}
|
|
2763
|
+
function s(n) {
|
|
2764
|
+
const r = t(n);
|
|
2765
|
+
if (r) {
|
|
2766
|
+
if ("error" in r)
|
|
2767
|
+
throw r.error;
|
|
2768
|
+
return r.result;
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
return [t, s];
|
|
2756
2772
|
}
|
|
2757
|
-
const [
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
), [
|
|
2761
|
-
Bs,
|
|
2762
|
-
Vs
|
|
2763
|
-
), [Ms, $s] = g(Qe), [kn, An] = _(
|
|
2773
|
+
const [Ns, Bs] = _(Ge), [Sn, Tn] = d(
|
|
2774
|
+
Ns,
|
|
2775
|
+
Bs
|
|
2776
|
+
), [Ms, Vs] = _(Je), [An, kn] = d(
|
|
2764
2777
|
Ms,
|
|
2765
|
-
|
|
2766
|
-
), [
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
), [Us,
|
|
2778
|
+
Vs
|
|
2779
|
+
), [$s, Ls] = _(Fe), [In, On] = d(
|
|
2780
|
+
$s,
|
|
2781
|
+
Ls
|
|
2782
|
+
), [Us, Hs] = _(es), [qn, Dn] = d(
|
|
2770
2783
|
Us,
|
|
2771
|
-
|
|
2772
|
-
), [
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
), [
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2784
|
+
Hs
|
|
2785
|
+
), [Ws, js] = _(ns), [Nn, Bn] = d(
|
|
2786
|
+
Ws,
|
|
2787
|
+
js
|
|
2788
|
+
), [Gs, zs] = _(is), [Mn, Vn] = d(Gs, zs), [Ks, Js] = _(as), [$n, Ln] = d(Ks, Js), [Qs, Fs] = _(hs), [Un, Hn] = d(Qs, Fs), [Ys, Zs] = _(ds), [Wn, jn] = d(Ys, Zs), [Xs, tn] = _(ws), [Gn, zn] = d(Xs, tn), [en, sn] = _(ms), [Kn, Jn] = d(en, sn), [nn, rn] = _(vs), [Qn, Fn] = d(
|
|
2789
|
+
nn,
|
|
2790
|
+
rn
|
|
2791
|
+
), [on, an] = _(Es), [Yn, Zn] = d(on, an);
|
|
2792
|
+
function Xn() {
|
|
2793
|
+
return vt(jt, []);
|
|
2794
|
+
}
|
|
2795
|
+
const [cn, hn] = _(Rs), [tr, er] = d(cn, hn), [pn, un] = _(Cs), [sr, nr] = d(pn, un);
|
|
2796
|
+
function rr({ children: e, acceptCustomStyles: t, debug: s }) {
|
|
2797
|
+
const n = dt(!0), [r, i] = bt(/* @__PURE__ */ new Map()), a = dt(r), o = ee(
|
|
2798
|
+
(h) => {
|
|
2799
|
+
n.current && i((v) => (h && h(v), new Map(v)));
|
|
2800
|
+
},
|
|
2801
|
+
[]
|
|
2802
|
+
), u = vt(() => ({
|
|
2803
|
+
use(h, ...v) {
|
|
2804
|
+
const pt = r.get(h);
|
|
2788
2805
|
if (pt)
|
|
2789
2806
|
return pt;
|
|
2790
|
-
let b;
|
|
2807
|
+
let b, K;
|
|
2791
2808
|
try {
|
|
2792
|
-
b =
|
|
2793
|
-
} catch (
|
|
2794
|
-
|
|
2809
|
+
b = h(...v);
|
|
2810
|
+
} catch (f) {
|
|
2811
|
+
K = f;
|
|
2812
|
+
}
|
|
2813
|
+
function $(f) {
|
|
2814
|
+
return r.set(h, f), f;
|
|
2795
2815
|
}
|
|
2796
|
-
if (
|
|
2797
|
-
return
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2816
|
+
if (K)
|
|
2817
|
+
return $({ error: K });
|
|
2818
|
+
let k;
|
|
2819
|
+
if (Array.isArray(b) && (k = b[1], b = b[0]), !b)
|
|
2820
|
+
return $({ result: b, cleanup: k });
|
|
2821
|
+
function ut(f) {
|
|
2822
|
+
if ("on" in f) {
|
|
2823
|
+
const I = f.on("change", () => o()), lt = k;
|
|
2824
|
+
k = () => {
|
|
2825
|
+
lt && lt(), I();
|
|
2826
|
+
};
|
|
2827
|
+
}
|
|
2828
|
+
return { result: f, cleanup: k };
|
|
2829
|
+
}
|
|
2830
|
+
return b instanceof Promise ? (b.then(
|
|
2831
|
+
(f) => o((I) => I.set(h, ut(f))),
|
|
2832
|
+
(f) => o((I) => I.set(h, { error: f }))
|
|
2833
|
+
), $({})) : $(ut(b));
|
|
2803
2834
|
}
|
|
2804
2835
|
}), [r]);
|
|
2805
|
-
return
|
|
2806
|
-
ae(s || !1);
|
|
2807
|
-
}, [s]), M(() => () => {
|
|
2836
|
+
return C(() => (n.current = !0, () => {
|
|
2808
2837
|
n.current = !1;
|
|
2809
|
-
}, []),
|
|
2838
|
+
}), []), C(() => {
|
|
2810
2839
|
if (Tt())
|
|
2811
2840
|
return Ss(t);
|
|
2812
|
-
}, [t]),
|
|
2841
|
+
}, [t]), C(() => {
|
|
2842
|
+
oe(s || !1);
|
|
2843
|
+
}, [s]), C(() => {
|
|
2844
|
+
a.current = r;
|
|
2845
|
+
}, [r]), C(() => () => {
|
|
2846
|
+
a.current.forEach((h) => {
|
|
2847
|
+
"cleanup" in h && h.cleanup && h.cleanup();
|
|
2848
|
+
});
|
|
2849
|
+
}, []), /* @__PURE__ */ mt(Zt.Provider, { value: u, children: e });
|
|
2813
2850
|
}
|
|
2814
2851
|
export {
|
|
2815
2852
|
Oe as BackButton,
|
|
2816
2853
|
ks as BasicNavigator,
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2854
|
+
ze as BiometryManager,
|
|
2855
|
+
Yt as BrowserNavigator,
|
|
2856
|
+
Qe as ClosingBehavior,
|
|
2857
|
+
ts as CloudStorage,
|
|
2858
|
+
we as ERR_INVALID_PATH_BASE,
|
|
2859
|
+
ue as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
|
|
2860
|
+
he as ERR_METHOD_PARAMETER_UNSUPPORTED,
|
|
2824
2861
|
ce as ERR_METHOD_UNSUPPORTED,
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2862
|
+
_e as ERR_NAVIGATION_HISTORY_EMPTY,
|
|
2863
|
+
ge as ERR_NAVIGATION_INDEX_INVALID,
|
|
2864
|
+
_n as ERR_NAVIGATION_ITEM_INVALID,
|
|
2865
|
+
Pt as ERR_PARSE,
|
|
2866
|
+
gn as ERR_SSR_INIT,
|
|
2830
2867
|
le as ERR_TIMED_OUT,
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2868
|
+
de as ERR_UNEXPECTED_TYPE,
|
|
2869
|
+
pe as ERR_UNKNOWN_ENV,
|
|
2870
|
+
H as EventEmitter,
|
|
2871
|
+
ss as HapticFeedback,
|
|
2872
|
+
rs as InitData,
|
|
2873
|
+
os as Invoice,
|
|
2874
|
+
cs as MainButton,
|
|
2875
|
+
ls as MiniApp,
|
|
2876
|
+
gs as Popup,
|
|
2877
|
+
fs as QRScanner,
|
|
2841
2878
|
W as SDKError,
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2879
|
+
rr as SDKProvider,
|
|
2880
|
+
bs as SettingsButton,
|
|
2881
|
+
ys as ThemeParams,
|
|
2882
|
+
Ps as Utils,
|
|
2883
|
+
xs as Viewport,
|
|
2884
|
+
Xe as array,
|
|
2885
|
+
vn as bindMiniAppCSSVars,
|
|
2886
|
+
yn as bindThemeParamsCSSVars,
|
|
2887
|
+
En as bindViewportCSSVars,
|
|
2851
2888
|
P as boolean,
|
|
2852
|
-
|
|
2889
|
+
kt as captureSameReq,
|
|
2853
2890
|
et as classNames,
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2891
|
+
Se as compareVersions,
|
|
2892
|
+
Os as createBrowserNavigatorFromLocation,
|
|
2893
|
+
ke as createPostEvent,
|
|
2894
|
+
L as createSafeURL,
|
|
2858
2895
|
Nt as date,
|
|
2859
|
-
|
|
2860
|
-
|
|
2896
|
+
xn as getHash,
|
|
2897
|
+
Ft as getPathname,
|
|
2861
2898
|
Ge as initBackButton,
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2899
|
+
Je as initBiometryManager,
|
|
2900
|
+
Fe as initClosingBehavior,
|
|
2901
|
+
es as initCloudStorage,
|
|
2902
|
+
ns as initHapticFeedback,
|
|
2903
|
+
is as initInitData,
|
|
2904
|
+
as as initInvoice,
|
|
2868
2905
|
hs as initMainButton,
|
|
2869
2906
|
ds as initMiniApp,
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2907
|
+
Cn as initNavigator,
|
|
2908
|
+
ws as initPopup,
|
|
2909
|
+
ms as initQRScanner,
|
|
2910
|
+
vs as initSettingsButton,
|
|
2911
|
+
Es as initThemeParams,
|
|
2912
|
+
Rs as initUtils,
|
|
2876
2913
|
Cs as initViewport,
|
|
2877
2914
|
Ss as initWeb,
|
|
2878
|
-
|
|
2879
|
-
|
|
2915
|
+
q as invokeCustomMethod,
|
|
2916
|
+
qt as isColorDark,
|
|
2880
2917
|
Tt as isIframe,
|
|
2881
2918
|
Gt as isPageReload,
|
|
2882
2919
|
rt as isRGB,
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2920
|
+
fe as isRGBShort,
|
|
2921
|
+
As as isSDKError,
|
|
2922
|
+
Rn as isSDKErrorOfType,
|
|
2923
|
+
Ts as isSSR,
|
|
2924
|
+
Pn as isTMA,
|
|
2925
|
+
g as json,
|
|
2926
|
+
fn as mergeClassNames,
|
|
2927
|
+
x as number,
|
|
2891
2928
|
z as off,
|
|
2892
2929
|
E as on,
|
|
2893
|
-
|
|
2894
|
-
|
|
2930
|
+
mn as parseInitData,
|
|
2931
|
+
Vt as parseLaunchParams,
|
|
2895
2932
|
Jt as parseThemeParams,
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2933
|
+
N as postEvent,
|
|
2934
|
+
w as request,
|
|
2935
|
+
Ke as requestBiometryInfo,
|
|
2936
|
+
bn as requestThemeParams,
|
|
2900
2937
|
Qt as requestViewport,
|
|
2901
2938
|
jt as retrieveLaunchParams,
|
|
2902
2939
|
Ct as rgb,
|
|
2903
2940
|
at as searchParams,
|
|
2904
|
-
|
|
2905
|
-
|
|
2941
|
+
Le as serializeLaunchParams,
|
|
2942
|
+
$e as serializeThemeParams,
|
|
2906
2943
|
R as setCSSVar,
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2944
|
+
oe as setDebug,
|
|
2945
|
+
wn as setTargetOrigin,
|
|
2946
|
+
p as string,
|
|
2947
|
+
re as subscribe,
|
|
2911
2948
|
S as supports,
|
|
2912
2949
|
Ae as targetOrigin,
|
|
2913
2950
|
xt as toRGB,
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2951
|
+
Et as unsubscribe,
|
|
2952
|
+
U as urlToPath,
|
|
2953
|
+
Bs as useBackButton,
|
|
2954
|
+
Ns as useBackButtonRaw,
|
|
2918
2955
|
Vs as useBiometryManager,
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2956
|
+
Ms as useBiometryManagerRaw,
|
|
2957
|
+
Ls as useClosingBehavior,
|
|
2958
|
+
$s as useClosingBehaviorRaw,
|
|
2922
2959
|
Hs as useCloudStorage,
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2960
|
+
Us as useCloudStorageRaw,
|
|
2961
|
+
js as useHapticFeedback,
|
|
2962
|
+
Ws as useHapticFeedbackRaw,
|
|
2963
|
+
zs as useInitData,
|
|
2964
|
+
Gs as useInitDataRaw,
|
|
2965
|
+
Js as useInvoice,
|
|
2966
|
+
Ks as useInvoiceRaw,
|
|
2967
|
+
Xn as useLaunchParams,
|
|
2968
|
+
Fs as useMainButton,
|
|
2969
|
+
Qs as useMainButtonRaw,
|
|
2970
|
+
Zs as useMiniApp,
|
|
2971
|
+
Ys as useMiniAppRaw,
|
|
2972
|
+
tn as usePopup,
|
|
2973
|
+
Xs as usePopupRaw,
|
|
2974
|
+
sn as useQRScanner,
|
|
2975
|
+
en as useQRScannerRaw,
|
|
2976
|
+
Ds as useSDK,
|
|
2977
|
+
rn as useSettingsButton,
|
|
2978
|
+
nn as useSettingsButtonRaw,
|
|
2979
|
+
an as useThemeParams,
|
|
2980
|
+
on as useThemeParamsRaw,
|
|
2944
2981
|
hn as useUtils,
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2982
|
+
cn as useUtilsRaw,
|
|
2983
|
+
un as useViewport,
|
|
2984
|
+
pn as useViewportRaw,
|
|
2985
|
+
Tn as withBackButton,
|
|
2986
|
+
Sn as withBackButtonRaw,
|
|
2987
|
+
kn as withBiometryManager,
|
|
2988
|
+
An as withBiometryManagerRaw,
|
|
2989
|
+
On as withClosingBehavior,
|
|
2990
|
+
In as withClosingBehaviorRaw,
|
|
2991
|
+
Dn as withCloudStorage,
|
|
2992
|
+
qn as withCloudStorageRaw,
|
|
2993
|
+
Bn as withHapticFeedback,
|
|
2994
|
+
Nn as withHapticFeedbackRaw,
|
|
2995
|
+
Vn as withInitData,
|
|
2996
|
+
Mn as withInitDataRaw,
|
|
2997
|
+
Ln as withInvoice,
|
|
2998
|
+
$n as withInvoiceRaw,
|
|
2999
|
+
Hn as withMainButton,
|
|
3000
|
+
Un as withMainButtonRaw,
|
|
3001
|
+
jn as withMiniApp,
|
|
3002
|
+
Wn as withMiniAppRaw,
|
|
3003
|
+
zn as withPopup,
|
|
3004
|
+
Gn as withPopupRaw,
|
|
3005
|
+
Jn as withQRScanner,
|
|
3006
|
+
Kn as withQRScannerRaw,
|
|
3007
|
+
Fn as withSettingsButton,
|
|
3008
|
+
Qn as withSettingsButtonRaw,
|
|
3009
|
+
Zn as withThemeParams,
|
|
3010
|
+
Yn as withThemeParamsRaw,
|
|
3011
|
+
Ot as withTimeout,
|
|
3012
|
+
er as withUtils,
|
|
3013
|
+
tr as withUtilsRaw,
|
|
3014
|
+
nr as withViewport,
|
|
3015
|
+
sr as withViewportRaw
|
|
2979
3016
|
};
|
|
2980
3017
|
//# sourceMappingURL=index.js.map
|