@tma.js/sdk-react 2.1.1 → 2.1.3
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 +711 -687
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { jsx as vt } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as
|
|
3
|
-
var
|
|
4
|
-
function
|
|
2
|
+
import { createContext as se, useContext as ne, useState as yt, useEffect as O, useMemo as Et, useRef as _t, useCallback as gt } from "react";
|
|
3
|
+
var re = Object.defineProperty, ie = (e, t, s) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (ie(e, typeof t != "symbol" ? t + "" : t, s), s);
|
|
4
|
+
function Pt(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 Rt(e) {
|
|
12
12
|
const t = G(), { count: s } = t;
|
|
13
13
|
t.unsubscribe(e), s && !t.count && Te();
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return G().subscribe(e), () =>
|
|
15
|
+
function oe(e) {
|
|
16
|
+
return G().subscribe(e), () => Rt(e);
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class ae {
|
|
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 st = new ae("SDK", {
|
|
59
59
|
bgColor: "forestgreen",
|
|
60
60
|
textColor: "white"
|
|
61
61
|
});
|
|
62
62
|
let X = !1;
|
|
63
|
-
const
|
|
64
|
-
|
|
63
|
+
const wt = ({ event: e, args: [t] }) => {
|
|
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 ce(e) {
|
|
67
|
+
X !== e && (X = e, e ? oe(wt) : Rt(wt));
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
X &&
|
|
69
|
+
function he(...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
|
}
|
|
@@ -147,12 +147,12 @@ class W extends Error {
|
|
|
147
147
|
super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, W.prototype);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function b(e, t, s) {
|
|
151
151
|
return new W(e, t, s);
|
|
152
152
|
}
|
|
153
|
-
const
|
|
154
|
-
function
|
|
155
|
-
return
|
|
153
|
+
const pe = "ERR_METHOD_UNSUPPORTED", ue = "ERR_METHOD_PARAMETER_UNSUPPORTED", le = "ERR_UNKNOWN_ENV", de = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", _e = "ERR_TIMED_OUT", ge = "ERR_UNEXPECTED_TYPE", xt = "ERR_PARSE", we = "ERR_NAVIGATION_LIST_EMPTY", fe = "ERR_NAVIGATION_CURSOR_INVALID", wn = "ERR_NAVIGATION_ITEM_INVALID", fn = "ERR_SSR_INIT", me = "ERR_INVALID_PATH_BASE";
|
|
154
|
+
function S() {
|
|
155
|
+
return b(ge, "Value has unexpected type");
|
|
156
156
|
}
|
|
157
157
|
class j {
|
|
158
158
|
constructor(t, s, n) {
|
|
@@ -169,8 +169,8 @@ class j {
|
|
|
169
169
|
try {
|
|
170
170
|
return this.parser(t);
|
|
171
171
|
} catch (s) {
|
|
172
|
-
throw
|
|
173
|
-
|
|
172
|
+
throw b(
|
|
173
|
+
xt,
|
|
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 T(e, t) {
|
|
184
184
|
return () => new j(e, !1, t);
|
|
185
185
|
}
|
|
186
|
-
const P =
|
|
186
|
+
const P = T((e) => {
|
|
187
187
|
if (typeof e == "boolean")
|
|
188
188
|
return e;
|
|
189
189
|
const t = String(e);
|
|
@@ -191,43 +191,43 @@ const P = A((e) => {
|
|
|
191
191
|
return !0;
|
|
192
192
|
if (t === "0" || t === "false")
|
|
193
193
|
return !1;
|
|
194
|
-
throw
|
|
194
|
+
throw S();
|
|
195
195
|
}, "boolean");
|
|
196
|
-
function
|
|
196
|
+
function Ct(e, t) {
|
|
197
197
|
const s = {};
|
|
198
198
|
for (const n in e) {
|
|
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
|
|
210
|
+
const o = a(t(i));
|
|
211
|
+
o !== void 0 && (s[n] = o);
|
|
212
|
+
} catch (o) {
|
|
213
|
+
throw b(xt, `Unable to parse field "${n}"`, o);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
return s;
|
|
217
217
|
}
|
|
218
|
-
function
|
|
218
|
+
function nt(e) {
|
|
219
219
|
let t = e;
|
|
220
220
|
if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
|
|
221
|
-
throw
|
|
221
|
+
throw S();
|
|
222
222
|
return t;
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function w(e, t) {
|
|
225
225
|
return new j((s) => {
|
|
226
|
-
const n =
|
|
227
|
-
return
|
|
226
|
+
const n = nt(s);
|
|
227
|
+
return Ct(e, (r) => n[r]);
|
|
228
228
|
}, !1, t);
|
|
229
229
|
}
|
|
230
|
-
const x =
|
|
230
|
+
const x = T((e) => {
|
|
231
231
|
if (typeof e == "number")
|
|
232
232
|
return e;
|
|
233
233
|
if (typeof e == "string") {
|
|
@@ -235,17 +235,17 @@ const x = A((e) => {
|
|
|
235
235
|
if (!Number.isNaN(t))
|
|
236
236
|
return t;
|
|
237
237
|
}
|
|
238
|
-
throw
|
|
238
|
+
throw S();
|
|
239
239
|
}, "number");
|
|
240
|
-
function
|
|
240
|
+
function rt(e) {
|
|
241
241
|
return /^#[\da-f]{6}$/i.test(e);
|
|
242
242
|
}
|
|
243
243
|
function be(e) {
|
|
244
244
|
return /^#[\da-f]{3}$/i.test(e);
|
|
245
245
|
}
|
|
246
|
-
function
|
|
246
|
+
function St(e) {
|
|
247
247
|
const t = e.replace(/\s/g, "").toLowerCase();
|
|
248
|
-
if (
|
|
248
|
+
if (rt(t))
|
|
249
249
|
return t;
|
|
250
250
|
if (be(t)) {
|
|
251
251
|
let n = "#";
|
|
@@ -261,13 +261,13 @@ function xt(e) {
|
|
|
261
261
|
return n + (i.length === 1 ? "0" : "") + i;
|
|
262
262
|
}, "#");
|
|
263
263
|
}
|
|
264
|
-
const h =
|
|
264
|
+
const h = T((e) => {
|
|
265
265
|
if (typeof e == "string" || typeof e == "number")
|
|
266
266
|
return e.toString();
|
|
267
|
-
throw
|
|
268
|
-
}, "string"),
|
|
267
|
+
throw S();
|
|
268
|
+
}, "string"), Tt = T((e) => St(h().parse(e)), "rgb");
|
|
269
269
|
function ve(e) {
|
|
270
|
-
return
|
|
270
|
+
return w({
|
|
271
271
|
eventType: h(),
|
|
272
272
|
eventData: (t) => t
|
|
273
273
|
}).parse(e);
|
|
@@ -303,49 +303,49 @@ function Pe() {
|
|
|
303
303
|
});
|
|
304
304
|
});
|
|
305
305
|
}
|
|
306
|
-
const Re =
|
|
306
|
+
const Re = w({
|
|
307
307
|
button_id: (e) => e == null ? void 0 : h().parse(e)
|
|
308
308
|
}), xe = {
|
|
309
|
-
clipboard_text_received:
|
|
309
|
+
clipboard_text_received: w({
|
|
310
310
|
req_id: h(),
|
|
311
311
|
data: (e) => e === null ? e : h().optional().parse(e)
|
|
312
312
|
}),
|
|
313
|
-
custom_method_invoked:
|
|
313
|
+
custom_method_invoked: w({
|
|
314
314
|
req_id: h(),
|
|
315
315
|
result: (e) => e,
|
|
316
316
|
error: h().optional()
|
|
317
317
|
}),
|
|
318
|
-
invoice_closed:
|
|
318
|
+
invoice_closed: w({
|
|
319
319
|
slug: h(),
|
|
320
320
|
status: h()
|
|
321
321
|
}),
|
|
322
|
-
phone_requested:
|
|
322
|
+
phone_requested: w({
|
|
323
323
|
status: h()
|
|
324
324
|
}),
|
|
325
325
|
popup_closed: {
|
|
326
326
|
parse: (e) => Re.parse(e ?? {})
|
|
327
327
|
},
|
|
328
|
-
qr_text_received:
|
|
328
|
+
qr_text_received: w({
|
|
329
329
|
data: h().optional()
|
|
330
330
|
}),
|
|
331
|
-
theme_changed:
|
|
331
|
+
theme_changed: w({
|
|
332
332
|
theme_params: (e) => {
|
|
333
|
-
const t =
|
|
334
|
-
return Object.entries(
|
|
333
|
+
const t = Tt().optional();
|
|
334
|
+
return Object.entries(nt(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
|
|
335
335
|
}
|
|
336
336
|
}),
|
|
337
|
-
viewport_changed:
|
|
337
|
+
viewport_changed: w({
|
|
338
338
|
height: x(),
|
|
339
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:
|
|
343
|
+
write_access_requested: w({
|
|
344
344
|
status: h()
|
|
345
345
|
})
|
|
346
346
|
};
|
|
347
|
-
function
|
|
348
|
-
const e = new
|
|
347
|
+
function Ce() {
|
|
348
|
+
const e = new H();
|
|
349
349
|
Pe();
|
|
350
350
|
let t = [
|
|
351
351
|
// Don't forget to remove created handlers.
|
|
@@ -374,15 +374,15 @@ function Se() {
|
|
|
374
374
|
} catch {
|
|
375
375
|
return;
|
|
376
376
|
}
|
|
377
|
-
const { eventType: r, eventData: i } = n,
|
|
377
|
+
const { eventType: r, eventData: i } = n, a = xe[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 Se() {
|
|
|
393
393
|
t.forEach((s) => s()), t = [];
|
|
394
394
|
}];
|
|
395
395
|
}
|
|
396
|
-
const [
|
|
396
|
+
const [Se, Te] = Pt(
|
|
397
397
|
(e) => {
|
|
398
|
-
const [t, s] =
|
|
398
|
+
const [t, s] = Ce(), 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 Se()[0];
|
|
408
408
|
}
|
|
409
409
|
function z(e, t) {
|
|
410
410
|
G().off(e, t);
|
|
@@ -412,22 +412,22 @@ 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 V(e) {
|
|
416
416
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
417
417
|
}
|
|
418
418
|
function Ae(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
428
|
return Ae(e, t) <= 0;
|
|
429
429
|
}
|
|
430
|
-
function
|
|
430
|
+
function C(e, t, s) {
|
|
431
431
|
if (typeof s == "string") {
|
|
432
432
|
if (e === "web_app_open_link" && t === "try_instant_view")
|
|
433
433
|
return y("6.4", s);
|
|
@@ -479,30 +479,30 @@ function S(e, t, s) {
|
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
481
|
function ke(e) {
|
|
482
|
-
return "external" in e &&
|
|
482
|
+
return "external" in e && V(e.external) && "notify" in e.external && typeof e.external.notify == "function";
|
|
483
483
|
}
|
|
484
|
-
function
|
|
485
|
-
return "TelegramWebviewProxy" in e &&
|
|
484
|
+
function At(e) {
|
|
485
|
+
return "TelegramWebviewProxy" in e && V(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
|
|
486
486
|
}
|
|
487
|
-
function
|
|
487
|
+
function kt() {
|
|
488
488
|
try {
|
|
489
489
|
return window.self !== window.top;
|
|
490
490
|
} catch {
|
|
491
491
|
return !0;
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
-
let
|
|
495
|
-
function
|
|
496
|
-
|
|
494
|
+
let It = "https://web.telegram.org";
|
|
495
|
+
function mn(e) {
|
|
496
|
+
It = e;
|
|
497
497
|
}
|
|
498
498
|
function Ie() {
|
|
499
|
-
return
|
|
499
|
+
return It;
|
|
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 = Ie() } = n;
|
|
505
|
-
if (
|
|
505
|
+
if (he("Posting event:", r ? { event: e, data: r } : { event: e }), kt()) {
|
|
506
506
|
window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
|
|
507
507
|
return;
|
|
508
508
|
}
|
|
@@ -510,47 +510,47 @@ function q(e, t, s) {
|
|
|
510
510
|
window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
|
|
511
511
|
return;
|
|
512
512
|
}
|
|
513
|
-
if (
|
|
513
|
+
if (At(window)) {
|
|
514
514
|
window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
|
|
515
515
|
return;
|
|
516
516
|
}
|
|
517
|
-
throw
|
|
518
|
-
|
|
517
|
+
throw b(
|
|
518
|
+
le,
|
|
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
522
|
function Oe(e) {
|
|
523
523
|
return (t, s) => {
|
|
524
|
-
if (!
|
|
525
|
-
throw
|
|
526
|
-
if (
|
|
524
|
+
if (!C(t, e))
|
|
525
|
+
throw b(pe, `Method "${t}" is unsupported in Mini Apps version ${e}`);
|
|
526
|
+
if (V(s)) {
|
|
527
527
|
let n;
|
|
528
|
-
if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !
|
|
529
|
-
throw
|
|
530
|
-
|
|
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 && !C(t, n, e))
|
|
529
|
+
throw b(
|
|
530
|
+
ue,
|
|
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 Ot(e) {
|
|
538
538
|
return ({ req_id: t }) => t === e;
|
|
539
539
|
}
|
|
540
|
-
function
|
|
541
|
-
return
|
|
540
|
+
function qt(e) {
|
|
541
|
+
return b(_e, `Timeout reached: ${e}ms`);
|
|
542
542
|
}
|
|
543
|
-
function
|
|
543
|
+
function Dt(e, t) {
|
|
544
544
|
return Promise.race([
|
|
545
545
|
typeof e == "function" ? e() : e,
|
|
546
546
|
new Promise((s, n) => {
|
|
547
547
|
setTimeout(() => {
|
|
548
|
-
n(
|
|
548
|
+
n(qt(t));
|
|
549
549
|
}, t);
|
|
550
550
|
})
|
|
551
551
|
]);
|
|
552
552
|
}
|
|
553
|
-
async function
|
|
553
|
+
async function f(e) {
|
|
554
554
|
let t;
|
|
555
555
|
const s = new Promise((u) => {
|
|
556
556
|
t = u;
|
|
@@ -558,22 +558,22 @@ async function m(e) {
|
|
|
558
558
|
method: n,
|
|
559
559
|
event: r,
|
|
560
560
|
capture: i,
|
|
561
|
-
postEvent:
|
|
562
|
-
timeout:
|
|
561
|
+
postEvent: a = N,
|
|
562
|
+
timeout: o
|
|
563
563
|
} = e, p = (Array.isArray(r) ? r : [r]).map(
|
|
564
|
-
(u) => E(u, (
|
|
564
|
+
(u) => E(u, (l) => (!i || i(l)) && t(l))
|
|
565
565
|
);
|
|
566
566
|
try {
|
|
567
|
-
return
|
|
567
|
+
return a(n, e.params), await (o ? Dt(s, o) : s);
|
|
568
568
|
} finally {
|
|
569
569
|
p.forEach((u) => u());
|
|
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 f({
|
|
577
577
|
...n,
|
|
578
578
|
method: "web_app_invoke_custom_method",
|
|
579
579
|
event: "custom_method_invoked",
|
|
@@ -582,30 +582,30 @@ async function I(e, t, s, n = {}) {
|
|
|
582
582
|
params: t,
|
|
583
583
|
req_id: s
|
|
584
584
|
},
|
|
585
|
-
capture:
|
|
585
|
+
capture: Ot(s)
|
|
586
586
|
});
|
|
587
587
|
if (i)
|
|
588
|
-
throw
|
|
588
|
+
throw b(de, 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 (V(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 bn(...e) {
|
|
602
|
+
return e.reduce((t, s) => (V(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
|
|
608
|
-
const t =
|
|
607
|
+
function Nt(e) {
|
|
608
|
+
const t = St(e);
|
|
609
609
|
return Math.sqrt(
|
|
610
610
|
[0.299, 0.587, 0.114].reduce((s, n, r) => {
|
|
611
611
|
const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
|
|
@@ -615,7 +615,7 @@ function qt(e) {
|
|
|
615
615
|
}
|
|
616
616
|
class qe {
|
|
617
617
|
constructor(t) {
|
|
618
|
-
c(this, "ee", new
|
|
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.
|
|
@@ -634,20 +634,20 @@ class qe {
|
|
|
634
634
|
return this.state[t];
|
|
635
635
|
}
|
|
636
636
|
}
|
|
637
|
-
class
|
|
637
|
+
class it {
|
|
638
638
|
constructor(t) {
|
|
639
639
|
c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new qe(t), this.set = this.state.set.bind(this.state), this.get = this.state.get.bind(this.state), this.clone = this.state.clone.bind(this.state);
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
|
-
function
|
|
643
|
-
return (s) =>
|
|
642
|
+
function Bt(e, t) {
|
|
643
|
+
return (s) => C(t[s], e);
|
|
644
644
|
}
|
|
645
|
-
class
|
|
645
|
+
class ot extends it {
|
|
646
646
|
constructor(t, s, n) {
|
|
647
|
-
super(t), c(this, "supports"), this.supports =
|
|
647
|
+
super(t), c(this, "supports"), this.supports = Bt(s, n);
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
|
-
class
|
|
650
|
+
class De extends ot {
|
|
651
651
|
constructor(t, s, n) {
|
|
652
652
|
super({ isVisible: t }, s, {
|
|
653
653
|
show: "web_app_setup_back_button",
|
|
@@ -676,22 +676,19 @@ class Ne extends at {
|
|
|
676
676
|
this.isVisible = !0;
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
}
|
|
682
|
-
const Dt = A((e) => e instanceof Date ? e : new Date(x().parse(e) * 1e3), "Date");
|
|
683
|
-
function ct(e, t) {
|
|
679
|
+
const Vt = T((e) => e instanceof Date ? e : new Date(x().parse(e) * 1e3), "Date");
|
|
680
|
+
function at(e, t) {
|
|
684
681
|
return new j((s) => {
|
|
685
682
|
if (typeof s != "string" && !(s instanceof URLSearchParams))
|
|
686
|
-
throw
|
|
683
|
+
throw S();
|
|
687
684
|
const n = typeof s == "string" ? new URLSearchParams(s) : s;
|
|
688
|
-
return
|
|
685
|
+
return Ct(e, (r) => {
|
|
689
686
|
const i = n.get(r);
|
|
690
687
|
return i === null ? void 0 : i;
|
|
691
688
|
});
|
|
692
689
|
}, !1, t);
|
|
693
690
|
}
|
|
694
|
-
const
|
|
691
|
+
const Ne = w({
|
|
695
692
|
id: x(),
|
|
696
693
|
type: h(),
|
|
697
694
|
title: h(),
|
|
@@ -700,7 +697,7 @@ const De = f({
|
|
|
700
697
|
from: "photo_url"
|
|
701
698
|
},
|
|
702
699
|
username: h().optional()
|
|
703
|
-
}, "Chat").optional(),
|
|
700
|
+
}, "Chat").optional(), ft = w({
|
|
704
701
|
addedToAttachmentMenu: {
|
|
705
702
|
type: P().optional(),
|
|
706
703
|
from: "added_to_attachment_menu"
|
|
@@ -736,17 +733,17 @@ const De = f({
|
|
|
736
733
|
},
|
|
737
734
|
username: h().optional()
|
|
738
735
|
}, "User").optional();
|
|
739
|
-
function
|
|
740
|
-
return
|
|
736
|
+
function Mt() {
|
|
737
|
+
return at({
|
|
741
738
|
authDate: {
|
|
742
|
-
type:
|
|
739
|
+
type: Vt(),
|
|
743
740
|
from: "auth_date"
|
|
744
741
|
},
|
|
745
742
|
canSendAfter: {
|
|
746
743
|
type: x().optional(),
|
|
747
744
|
from: "can_send_after"
|
|
748
745
|
},
|
|
749
|
-
chat:
|
|
746
|
+
chat: Ne,
|
|
750
747
|
chatInstance: {
|
|
751
748
|
type: h().optional(),
|
|
752
749
|
from: "chat_instance"
|
|
@@ -760,35 +757,35 @@ function Vt() {
|
|
|
760
757
|
type: h().optional(),
|
|
761
758
|
from: "query_id"
|
|
762
759
|
},
|
|
763
|
-
receiver:
|
|
760
|
+
receiver: ft,
|
|
764
761
|
startParam: {
|
|
765
762
|
type: h().optional(),
|
|
766
763
|
from: "start_param"
|
|
767
764
|
},
|
|
768
|
-
user:
|
|
765
|
+
user: ft
|
|
769
766
|
}, "InitData");
|
|
770
767
|
}
|
|
771
|
-
function
|
|
768
|
+
function Be(e) {
|
|
772
769
|
return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
|
|
773
770
|
}
|
|
774
|
-
function
|
|
771
|
+
function Ve(e) {
|
|
775
772
|
return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
|
|
776
773
|
}
|
|
777
|
-
const
|
|
774
|
+
const $t = T(
|
|
778
775
|
(e) => {
|
|
779
|
-
const t =
|
|
780
|
-
return Object.entries(
|
|
776
|
+
const t = Tt().optional();
|
|
777
|
+
return Object.entries(nt(e)).reduce((s, [n, r]) => (s[Be(n)] = t.parse(r), s), {});
|
|
781
778
|
},
|
|
782
779
|
"ThemeParams"
|
|
783
780
|
);
|
|
784
|
-
function
|
|
785
|
-
return
|
|
781
|
+
function Lt(e) {
|
|
782
|
+
return at({
|
|
786
783
|
botInline: {
|
|
787
784
|
type: P().optional(),
|
|
788
785
|
from: "tgWebAppBotInline"
|
|
789
786
|
},
|
|
790
787
|
initData: {
|
|
791
|
-
type:
|
|
788
|
+
type: Mt().optional(),
|
|
792
789
|
from: "tgWebAppData"
|
|
793
790
|
},
|
|
794
791
|
initDataRaw: {
|
|
@@ -808,7 +805,7 @@ function Mt(e) {
|
|
|
808
805
|
from: "tgWebAppStartParam"
|
|
809
806
|
},
|
|
810
807
|
themeParams: {
|
|
811
|
-
type:
|
|
808
|
+
type: $t(),
|
|
812
809
|
from: "tgWebAppThemeParams"
|
|
813
810
|
},
|
|
814
811
|
version: {
|
|
@@ -817,62 +814,62 @@ function Mt(e) {
|
|
|
817
814
|
}
|
|
818
815
|
}).parse(e);
|
|
819
816
|
}
|
|
820
|
-
function
|
|
821
|
-
return
|
|
817
|
+
function Ut(e) {
|
|
818
|
+
return Lt(
|
|
822
819
|
e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
|
|
823
820
|
);
|
|
824
821
|
}
|
|
825
822
|
function Me() {
|
|
826
|
-
return
|
|
823
|
+
return Ut(window.location.href);
|
|
827
824
|
}
|
|
828
|
-
function
|
|
825
|
+
function Ht() {
|
|
829
826
|
return performance.getEntriesByType("navigation")[0];
|
|
830
827
|
}
|
|
831
828
|
function $e() {
|
|
832
|
-
const e =
|
|
829
|
+
const e = Ht();
|
|
833
830
|
if (!e)
|
|
834
831
|
throw new Error("Unable to get first navigation entry.");
|
|
835
|
-
return
|
|
832
|
+
return Ut(e.name);
|
|
836
833
|
}
|
|
837
|
-
function
|
|
834
|
+
function Wt(e) {
|
|
838
835
|
return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
|
|
839
836
|
}
|
|
840
|
-
function
|
|
841
|
-
sessionStorage.setItem(
|
|
837
|
+
function jt(e, t) {
|
|
838
|
+
sessionStorage.setItem(Wt(e), JSON.stringify(t));
|
|
842
839
|
}
|
|
843
|
-
function
|
|
844
|
-
const t = sessionStorage.getItem(
|
|
840
|
+
function Gt(e) {
|
|
841
|
+
const t = sessionStorage.getItem(Wt(e));
|
|
845
842
|
try {
|
|
846
843
|
return t ? JSON.parse(t) : void 0;
|
|
847
844
|
} catch {
|
|
848
845
|
}
|
|
849
846
|
}
|
|
850
847
|
function Le() {
|
|
851
|
-
return
|
|
848
|
+
return Lt(Gt("launchParams") || "");
|
|
852
849
|
}
|
|
853
|
-
function
|
|
850
|
+
function Ue(e) {
|
|
854
851
|
return JSON.stringify(
|
|
855
852
|
Object.fromEntries(
|
|
856
|
-
Object.entries(e).map(([t, s]) => [
|
|
853
|
+
Object.entries(e).map(([t, s]) => [Ve(t), s])
|
|
857
854
|
)
|
|
858
855
|
);
|
|
859
856
|
}
|
|
860
|
-
function
|
|
857
|
+
function He(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:
|
|
864
|
+
startParam: a,
|
|
865
|
+
botInline: o
|
|
869
866
|
} = e, p = new URLSearchParams();
|
|
870
|
-
return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams",
|
|
867
|
+
return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", Ue(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();
|
|
871
868
|
}
|
|
872
869
|
function We(e) {
|
|
873
|
-
|
|
870
|
+
jt("launchParams", He(e));
|
|
874
871
|
}
|
|
875
|
-
function
|
|
872
|
+
function zt() {
|
|
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.
|
|
@@ -889,59 +886,64 @@ function jt() {
|
|
|
889
886
|
}
|
|
890
887
|
throw new Error("Unable to retrieve launch parameters from any known source.");
|
|
891
888
|
}
|
|
892
|
-
function
|
|
893
|
-
const e =
|
|
889
|
+
function Kt() {
|
|
890
|
+
const e = Ht();
|
|
894
891
|
return !!(e && e.type === "reload");
|
|
895
892
|
}
|
|
896
893
|
function je() {
|
|
897
894
|
let e = 0;
|
|
898
895
|
return () => (e += 1).toString();
|
|
899
896
|
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
"postEvent function is forbidden to be called on the server side."
|
|
919
|
-
);
|
|
920
|
-
},
|
|
921
|
-
createRequestId: Ge()
|
|
897
|
+
function Ge() {
|
|
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 [ze] = Pt(je);
|
|
909
|
+
function d(e, t) {
|
|
910
|
+
return () => {
|
|
911
|
+
const s = zt(), n = {
|
|
912
|
+
...s,
|
|
913
|
+
postEvent: Oe(s.version),
|
|
914
|
+
createRequestId: ze()
|
|
922
915
|
};
|
|
923
|
-
if (
|
|
924
|
-
return
|
|
925
|
-
const i = t({
|
|
926
|
-
...
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
916
|
+
if (typeof e == "function")
|
|
917
|
+
return e(n);
|
|
918
|
+
const [r, i, a] = Ge(), 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: Kt() ? Gt(e) : void 0,
|
|
924
|
+
addCleanup: r
|
|
925
|
+
}), p = (u) => (a || r(
|
|
926
|
+
u.on("change", (l) => {
|
|
927
|
+
jt(e, l);
|
|
928
|
+
})
|
|
929
|
+
), u);
|
|
930
|
+
return [
|
|
931
|
+
o instanceof Promise ? o.then(p) : p(o),
|
|
932
|
+
i
|
|
933
|
+
];
|
|
932
934
|
};
|
|
933
935
|
}
|
|
934
|
-
const
|
|
936
|
+
const Ke = d("backButton", ({
|
|
935
937
|
postEvent: e,
|
|
936
938
|
version: t,
|
|
937
939
|
state: s = { isVisible: !1 }
|
|
938
|
-
}) => new
|
|
939
|
-
class
|
|
940
|
+
}) => new De(s.isVisible, t, e));
|
|
941
|
+
class M extends ot {
|
|
940
942
|
constructor() {
|
|
941
943
|
super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
|
|
942
944
|
}
|
|
943
945
|
}
|
|
944
|
-
function
|
|
946
|
+
function Jt(e) {
|
|
945
947
|
const t = e.available ? e : {
|
|
946
948
|
available: !1,
|
|
947
949
|
device_id: "",
|
|
@@ -959,7 +961,7 @@ function zt(e) {
|
|
|
959
961
|
accessGranted: t.access_granted
|
|
960
962
|
};
|
|
961
963
|
}
|
|
962
|
-
class
|
|
964
|
+
class Je extends M {
|
|
963
965
|
constructor({ postEvent: t, version: s, ...n }) {
|
|
964
966
|
super(n, s, {
|
|
965
967
|
auth: "web_app_biometry_request_auth",
|
|
@@ -996,7 +998,7 @@ class ft extends V {
|
|
|
996
998
|
reason: t,
|
|
997
999
|
...s
|
|
998
1000
|
}) {
|
|
999
|
-
return this.authPromise || (this.authPromise =
|
|
1001
|
+
return this.authPromise || (this.authPromise = f({
|
|
1000
1002
|
...s,
|
|
1001
1003
|
method: "web_app_biometry_request_auth",
|
|
1002
1004
|
event: "biometry_auth_requested",
|
|
@@ -1030,14 +1032,14 @@ class ft extends V {
|
|
|
1030
1032
|
* @returns Promise with true, if access was granted.
|
|
1031
1033
|
*/
|
|
1032
1034
|
requestAccess({ reason: t, ...s } = {}) {
|
|
1033
|
-
return this.accessPromise || (this.accessPromise =
|
|
1035
|
+
return this.accessPromise || (this.accessPromise = f({
|
|
1034
1036
|
...s,
|
|
1035
1037
|
postEvent: this.postEvent,
|
|
1036
1038
|
method: "web_app_biometry_request_access",
|
|
1037
1039
|
event: "biometry_info_received",
|
|
1038
1040
|
params: { reason: t || "" }
|
|
1039
1041
|
}).then((n) => {
|
|
1040
|
-
const r =
|
|
1042
|
+
const r = Jt(n);
|
|
1041
1043
|
return this.set(r), r.accessGranted;
|
|
1042
1044
|
}).finally(() => this.accessPromise = void 0)), this.accessPromise;
|
|
1043
1045
|
}
|
|
@@ -1059,7 +1061,7 @@ class ft extends V {
|
|
|
1059
1061
|
*/
|
|
1060
1062
|
async updateToken({ token: t, ...s } = {}) {
|
|
1061
1063
|
return ["removed", "updated"].includes(
|
|
1062
|
-
(await
|
|
1064
|
+
(await f({
|
|
1063
1065
|
...s,
|
|
1064
1066
|
postEvent: this.postEvent,
|
|
1065
1067
|
method: "web_app_biometry_update_token",
|
|
@@ -1069,35 +1071,29 @@ class ft extends V {
|
|
|
1069
1071
|
);
|
|
1070
1072
|
}
|
|
1071
1073
|
}
|
|
1072
|
-
async function
|
|
1073
|
-
return
|
|
1074
|
-
await
|
|
1074
|
+
async function Qe(e) {
|
|
1075
|
+
return Jt(
|
|
1076
|
+
await f({
|
|
1075
1077
|
...e || {},
|
|
1076
1078
|
method: "web_app_biometry_get_info",
|
|
1077
1079
|
event: "biometry_info_received"
|
|
1078
1080
|
})
|
|
1079
1081
|
);
|
|
1080
1082
|
}
|
|
1081
|
-
const
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
throw l(
|
|
1086
|
-
nt,
|
|
1087
|
-
"BiometryManager cannot be instantiated on the server side without passing the ssr.state object."
|
|
1088
|
-
);
|
|
1089
|
-
return new ft({
|
|
1090
|
-
...await Ke({ timeout: 1e3 }),
|
|
1083
|
+
const Fe = d(
|
|
1084
|
+
"biometryManager",
|
|
1085
|
+
async ({ postEvent: e, version: t, state: s }) => new Je({
|
|
1086
|
+
...s || await Qe({ timeout: 1e3 }),
|
|
1091
1087
|
version: t,
|
|
1092
1088
|
postEvent: e
|
|
1093
|
-
})
|
|
1094
|
-
|
|
1095
|
-
class
|
|
1089
|
+
})
|
|
1090
|
+
);
|
|
1091
|
+
class ct extends it {
|
|
1096
1092
|
constructor() {
|
|
1097
1093
|
super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
|
|
1098
1094
|
}
|
|
1099
1095
|
}
|
|
1100
|
-
class
|
|
1096
|
+
class Ye extends ct {
|
|
1101
1097
|
constructor(t, s) {
|
|
1102
1098
|
super({ isConfirmationNeeded: t }), this.postEvent = s;
|
|
1103
1099
|
}
|
|
@@ -1124,16 +1120,19 @@ class Qe extends ht {
|
|
|
1124
1120
|
this.isConfirmationNeeded = !0;
|
|
1125
1121
|
}
|
|
1126
1122
|
}
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1123
|
+
const Ze = d(
|
|
1124
|
+
"closingBehavior",
|
|
1125
|
+
({
|
|
1126
|
+
postEvent: e,
|
|
1127
|
+
state: t = { isConfirmationNeeded: !1 }
|
|
1128
|
+
}) => new Ye(t.isConfirmationNeeded, e)
|
|
1129
|
+
);
|
|
1130
|
+
class ht {
|
|
1132
1131
|
constructor(t, s) {
|
|
1133
|
-
c(this, "supports"), this.supports =
|
|
1132
|
+
c(this, "supports"), this.supports = Bt(t, s);
|
|
1134
1133
|
}
|
|
1135
1134
|
}
|
|
1136
|
-
function
|
|
1135
|
+
function Xe(e) {
|
|
1137
1136
|
if (Array.isArray(e))
|
|
1138
1137
|
return e;
|
|
1139
1138
|
if (typeof e == "string")
|
|
@@ -1143,11 +1142,11 @@ function Ye(e) {
|
|
|
1143
1142
|
return t;
|
|
1144
1143
|
} catch {
|
|
1145
1144
|
}
|
|
1146
|
-
throw
|
|
1145
|
+
throw S();
|
|
1147
1146
|
}
|
|
1148
|
-
class
|
|
1147
|
+
class ts extends j {
|
|
1149
1148
|
constructor(t, s, n) {
|
|
1150
|
-
super(
|
|
1149
|
+
super(Xe, s, n), c(this, "itemParser"), this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
|
|
1151
1150
|
}
|
|
1152
1151
|
/**
|
|
1153
1152
|
* Attempts to parse passed value
|
|
@@ -1163,13 +1162,13 @@ class Ze extends j {
|
|
|
1163
1162
|
return this.itemParser = typeof t == "function" ? t : t.parse.bind(t), this;
|
|
1164
1163
|
}
|
|
1165
1164
|
}
|
|
1166
|
-
function
|
|
1167
|
-
return new
|
|
1165
|
+
function es(e) {
|
|
1166
|
+
return new ts((t) => t, !1, e);
|
|
1168
1167
|
}
|
|
1169
1168
|
function mt(e, t) {
|
|
1170
1169
|
return Object.fromEntries(e.map((s) => [s, t]));
|
|
1171
1170
|
}
|
|
1172
|
-
class
|
|
1171
|
+
class ss extends ht {
|
|
1173
1172
|
constructor(t, s, n) {
|
|
1174
1173
|
super(t, {
|
|
1175
1174
|
delete: "web_app_invoke_custom_method",
|
|
@@ -1185,7 +1184,7 @@ class ts extends pt {
|
|
|
1185
1184
|
*/
|
|
1186
1185
|
async delete(t, s = {}) {
|
|
1187
1186
|
const n = Array.isArray(t) ? t : [t];
|
|
1188
|
-
n.length && await
|
|
1187
|
+
n.length && await q(
|
|
1189
1188
|
"deleteStorageValues",
|
|
1190
1189
|
{ keys: n },
|
|
1191
1190
|
this.createRequestId(),
|
|
@@ -1197,8 +1196,8 @@ class ts extends pt {
|
|
|
1197
1196
|
* @param options - request execution options.
|
|
1198
1197
|
*/
|
|
1199
1198
|
async getKeys(t = {}) {
|
|
1200
|
-
return
|
|
1201
|
-
await
|
|
1199
|
+
return es().of(h()).parse(
|
|
1200
|
+
await q(
|
|
1202
1201
|
"getStorageKeys",
|
|
1203
1202
|
{},
|
|
1204
1203
|
this.createRequestId(),
|
|
@@ -1210,12 +1209,12 @@ class ts extends pt {
|
|
|
1210
1209
|
const n = Array.isArray(t) ? t : [t];
|
|
1211
1210
|
if (!n.length)
|
|
1212
1211
|
return mt(n, "");
|
|
1213
|
-
const r = await
|
|
1212
|
+
const r = await q(
|
|
1214
1213
|
"getStorageValues",
|
|
1215
1214
|
{ keys: n },
|
|
1216
1215
|
this.createRequestId(),
|
|
1217
1216
|
{ ...s, postEvent: this.postEvent }
|
|
1218
|
-
), i =
|
|
1217
|
+
), i = w(mt(n, h()), "CloudStorageData").parse(r);
|
|
1219
1218
|
return Array.isArray(t) ? i : i[t];
|
|
1220
1219
|
}
|
|
1221
1220
|
/**
|
|
@@ -1225,7 +1224,7 @@ class ts extends pt {
|
|
|
1225
1224
|
* @param options - request execution options.
|
|
1226
1225
|
*/
|
|
1227
1226
|
async set(t, s, n = {}) {
|
|
1228
|
-
await
|
|
1227
|
+
await q(
|
|
1229
1228
|
"saveStorageValue",
|
|
1230
1229
|
{ key: t, value: s },
|
|
1231
1230
|
this.createRequestId(),
|
|
@@ -1233,10 +1232,10 @@ class ts extends pt {
|
|
|
1233
1232
|
);
|
|
1234
1233
|
}
|
|
1235
1234
|
}
|
|
1236
|
-
const
|
|
1237
|
-
({ createRequestId: e, postEvent: t, version: s }) => new
|
|
1235
|
+
const ns = d(
|
|
1236
|
+
({ createRequestId: e, postEvent: t, version: s }) => new ss(s, e, t)
|
|
1238
1237
|
);
|
|
1239
|
-
class
|
|
1238
|
+
class rs extends ht {
|
|
1240
1239
|
constructor(t, s) {
|
|
1241
1240
|
super(t, {
|
|
1242
1241
|
impactOccurred: "web_app_trigger_haptic_feedback",
|
|
@@ -1278,10 +1277,10 @@ class ss extends pt {
|
|
|
1278
1277
|
this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
|
|
1279
1278
|
}
|
|
1280
1279
|
}
|
|
1281
|
-
const
|
|
1282
|
-
({ version: e, postEvent: t }) => new
|
|
1280
|
+
const is = d(
|
|
1281
|
+
({ version: e, postEvent: t }) => new rs(e, t)
|
|
1283
1282
|
);
|
|
1284
|
-
class
|
|
1283
|
+
class os {
|
|
1285
1284
|
constructor(t) {
|
|
1286
1285
|
this.initData = t;
|
|
1287
1286
|
}
|
|
@@ -1354,13 +1353,13 @@ class rs {
|
|
|
1354
1353
|
return this.initData.user;
|
|
1355
1354
|
}
|
|
1356
1355
|
}
|
|
1357
|
-
const
|
|
1358
|
-
({ initData: e }) => e ? new
|
|
1356
|
+
const as = d(
|
|
1357
|
+
({ initData: e }) => e ? new os(e) : void 0
|
|
1359
1358
|
);
|
|
1360
|
-
function
|
|
1361
|
-
return
|
|
1359
|
+
function vn(e) {
|
|
1360
|
+
return Mt().parse(e);
|
|
1362
1361
|
}
|
|
1363
|
-
class
|
|
1362
|
+
class cs extends M {
|
|
1364
1363
|
constructor(t, s, n) {
|
|
1365
1364
|
super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
|
|
1366
1365
|
}
|
|
@@ -1383,14 +1382,14 @@ class os extends V {
|
|
|
1383
1382
|
const { hostname: r, pathname: i } = new URL(t, window.location.href);
|
|
1384
1383
|
if (r !== "t.me")
|
|
1385
1384
|
throw new Error(`Incorrect hostname: ${r}`);
|
|
1386
|
-
const
|
|
1387
|
-
if (!
|
|
1385
|
+
const a = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
|
|
1386
|
+
if (!a)
|
|
1388
1387
|
throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
|
|
1389
|
-
[, , n] =
|
|
1388
|
+
[, , n] = a;
|
|
1390
1389
|
}
|
|
1391
1390
|
this.isOpened = !0;
|
|
1392
1391
|
try {
|
|
1393
|
-
return (await
|
|
1392
|
+
return (await f({
|
|
1394
1393
|
method: "web_app_open_invoice",
|
|
1395
1394
|
event: "invoice_closed",
|
|
1396
1395
|
params: { slug: n },
|
|
@@ -1404,10 +1403,10 @@ class os extends V {
|
|
|
1404
1403
|
}
|
|
1405
1404
|
}
|
|
1406
1405
|
}
|
|
1407
|
-
const
|
|
1408
|
-
({ version: e, postEvent: t }) => new
|
|
1406
|
+
const hs = d(
|
|
1407
|
+
({ version: e, postEvent: t }) => new cs(!1, e, t)
|
|
1409
1408
|
);
|
|
1410
|
-
class
|
|
1409
|
+
class ps extends it {
|
|
1411
1410
|
constructor({ postEvent: t, ...s }) {
|
|
1412
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;
|
|
1413
1412
|
}
|
|
@@ -1538,21 +1537,24 @@ class cs extends ot {
|
|
|
1538
1537
|
return this.set(t), this.commit(), this;
|
|
1539
1538
|
}
|
|
1540
1539
|
}
|
|
1541
|
-
const
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1540
|
+
const us = d(
|
|
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 ps({ ...s, postEvent: e })
|
|
1554
|
+
);
|
|
1555
|
+
function ls() {
|
|
1556
|
+
return at({
|
|
1557
|
+
contact: w({
|
|
1556
1558
|
userId: {
|
|
1557
1559
|
type: x(),
|
|
1558
1560
|
from: "user_id"
|
|
@@ -1571,24 +1573,24 @@ function ps() {
|
|
|
1571
1573
|
}
|
|
1572
1574
|
}),
|
|
1573
1575
|
authDate: {
|
|
1574
|
-
type:
|
|
1576
|
+
type: Vt(),
|
|
1575
1577
|
from: "auth_date"
|
|
1576
1578
|
},
|
|
1577
1579
|
hash: h()
|
|
1578
1580
|
}, "RequestedContact");
|
|
1579
1581
|
}
|
|
1580
|
-
function
|
|
1582
|
+
function Qt(e, t) {
|
|
1581
1583
|
return (s) => {
|
|
1582
1584
|
const [n, r] = t[s];
|
|
1583
|
-
return
|
|
1585
|
+
return C(n, r, e);
|
|
1584
1586
|
};
|
|
1585
1587
|
}
|
|
1586
|
-
function
|
|
1588
|
+
function ds(e) {
|
|
1587
1589
|
return new Promise((t) => {
|
|
1588
1590
|
setTimeout(t, e);
|
|
1589
1591
|
});
|
|
1590
1592
|
}
|
|
1591
|
-
class
|
|
1593
|
+
class _s extends M {
|
|
1592
1594
|
constructor({ postEvent: t, createRequestId: s, version: n, botInline: r, ...i }) {
|
|
1593
1595
|
super(i, n, {
|
|
1594
1596
|
requestPhoneAccess: "web_app_request_phone",
|
|
@@ -1597,8 +1599,8 @@ class ds extends V {
|
|
|
1597
1599
|
setHeaderColor: "web_app_set_header_color",
|
|
1598
1600
|
setBackgroundColor: "web_app_set_background_color"
|
|
1599
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;
|
|
1600
|
-
const
|
|
1601
|
-
this.supports = (
|
|
1602
|
+
const a = this.supports.bind(this);
|
|
1603
|
+
this.supports = (o) => a(o) ? o !== "switchInlineQuery" || r : !1, this.supportsParam = Qt(n, {
|
|
1602
1604
|
"setHeaderColor.color": ["web_app_set_header_color", "color"]
|
|
1603
1605
|
});
|
|
1604
1606
|
}
|
|
@@ -1609,8 +1611,8 @@ class ds extends V {
|
|
|
1609
1611
|
async getRequestedContact({
|
|
1610
1612
|
timeout: t = 1e4
|
|
1611
1613
|
} = {}) {
|
|
1612
|
-
return
|
|
1613
|
-
await
|
|
1614
|
+
return ls().parse(
|
|
1615
|
+
await q(
|
|
1614
1616
|
"getRequestedContact",
|
|
1615
1617
|
{},
|
|
1616
1618
|
this.createRequestId(),
|
|
@@ -1649,7 +1651,7 @@ class ds extends V {
|
|
|
1649
1651
|
* True if current Mini App background color is recognized as dark.
|
|
1650
1652
|
*/
|
|
1651
1653
|
get isDark() {
|
|
1652
|
-
return
|
|
1654
|
+
return Nt(this.bgColor);
|
|
1653
1655
|
}
|
|
1654
1656
|
/**
|
|
1655
1657
|
* Informs the Telegram app that the Mini App is ready to be displayed.
|
|
@@ -1678,15 +1680,15 @@ class ds extends V {
|
|
|
1678
1680
|
throw new Error("Access denied.");
|
|
1679
1681
|
const s = Date.now() + t;
|
|
1680
1682
|
let n = 50;
|
|
1681
|
-
return
|
|
1683
|
+
return Dt(async () => {
|
|
1682
1684
|
for (; Date.now() < s; ) {
|
|
1683
1685
|
try {
|
|
1684
1686
|
return await this.getRequestedContact();
|
|
1685
1687
|
} catch {
|
|
1686
1688
|
}
|
|
1687
|
-
await
|
|
1689
|
+
await ds(n), n += 50;
|
|
1688
1690
|
}
|
|
1689
|
-
throw
|
|
1691
|
+
throw qt(t);
|
|
1690
1692
|
}, t);
|
|
1691
1693
|
}
|
|
1692
1694
|
/**
|
|
@@ -1699,7 +1701,7 @@ class ds extends V {
|
|
|
1699
1701
|
* @see requestContact
|
|
1700
1702
|
*/
|
|
1701
1703
|
async requestPhoneAccess(t = {}) {
|
|
1702
|
-
return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise =
|
|
1704
|
+
return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = f({
|
|
1703
1705
|
...t,
|
|
1704
1706
|
method: "web_app_request_phone",
|
|
1705
1707
|
event: "phone_requested",
|
|
@@ -1711,7 +1713,7 @@ class ds extends V {
|
|
|
1711
1713
|
* @param options - additional options.
|
|
1712
1714
|
*/
|
|
1713
1715
|
async requestWriteAccess(t = {}) {
|
|
1714
|
-
return this.requestWriteAccessPromise || (this.requestWriteAccessPromise =
|
|
1716
|
+
return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = f({
|
|
1715
1717
|
...t,
|
|
1716
1718
|
method: "web_app_request_write_access",
|
|
1717
1719
|
event: "write_access_requested",
|
|
@@ -1741,7 +1743,7 @@ class ds extends V {
|
|
|
1741
1743
|
* @param color - color key or RGB color.
|
|
1742
1744
|
*/
|
|
1743
1745
|
setHeaderColor(t) {
|
|
1744
|
-
this.postEvent("web_app_set_header_color",
|
|
1746
|
+
this.postEvent("web_app_set_header_color", rt(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
|
|
1745
1747
|
}
|
|
1746
1748
|
/**
|
|
1747
1749
|
* Updates current Mini App background color.
|
|
@@ -1769,16 +1771,19 @@ class ds extends V {
|
|
|
1769
1771
|
this.postEvent("web_app_switch_inline_query", { query: t, chat_types: s });
|
|
1770
1772
|
}
|
|
1771
1773
|
}
|
|
1772
|
-
const
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
}
|
|
1781
|
-
|
|
1774
|
+
const gs = d(
|
|
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 _s({ ...n, ...s, botInline: t })
|
|
1785
|
+
);
|
|
1786
|
+
function ws(e) {
|
|
1782
1787
|
const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
|
|
1783
1788
|
let r;
|
|
1784
1789
|
if (s.length > 64)
|
|
@@ -1788,21 +1793,21 @@ function _s(e) {
|
|
|
1788
1793
|
if (n.length > 3)
|
|
1789
1794
|
throw new Error(`Buttons have incorrect size: ${n.length}`);
|
|
1790
1795
|
return n.length ? r = n.map((i) => {
|
|
1791
|
-
const { id:
|
|
1792
|
-
if (
|
|
1793
|
-
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}`);
|
|
1794
1799
|
if (!i.type || i.type === "default" || i.type === "destructive") {
|
|
1795
|
-
const
|
|
1796
|
-
if (!
|
|
1800
|
+
const o = i.text.trim();
|
|
1801
|
+
if (!o.length || o.length > 64) {
|
|
1797
1802
|
const p = i.type || "default";
|
|
1798
1803
|
throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
|
|
1799
1804
|
}
|
|
1800
|
-
return { ...i, text:
|
|
1805
|
+
return { ...i, text: o, id: a };
|
|
1801
1806
|
}
|
|
1802
|
-
return { ...i, id:
|
|
1807
|
+
return { ...i, id: a };
|
|
1803
1808
|
}) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
|
|
1804
1809
|
}
|
|
1805
|
-
class
|
|
1810
|
+
class fs extends M {
|
|
1806
1811
|
constructor(t, s, n) {
|
|
1807
1812
|
super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
|
|
1808
1813
|
}
|
|
@@ -1831,11 +1836,11 @@ class gs extends V {
|
|
|
1831
1836
|
throw new Error("Popup is already opened.");
|
|
1832
1837
|
this.isOpened = !0;
|
|
1833
1838
|
try {
|
|
1834
|
-
const { button_id: s = null } = await
|
|
1839
|
+
const { button_id: s = null } = await f({
|
|
1835
1840
|
event: "popup_closed",
|
|
1836
1841
|
method: "web_app_open_popup",
|
|
1837
1842
|
postEvent: this.postEvent,
|
|
1838
|
-
params:
|
|
1843
|
+
params: ws(t)
|
|
1839
1844
|
});
|
|
1840
1845
|
return s;
|
|
1841
1846
|
} finally {
|
|
@@ -1843,10 +1848,10 @@ class gs extends V {
|
|
|
1843
1848
|
}
|
|
1844
1849
|
}
|
|
1845
1850
|
}
|
|
1846
|
-
const
|
|
1847
|
-
({ postEvent: e, version: t }) => new
|
|
1851
|
+
const ms = d(
|
|
1852
|
+
({ postEvent: e, version: t }) => new fs(!1, t, e)
|
|
1848
1853
|
);
|
|
1849
|
-
class
|
|
1854
|
+
class bs extends M {
|
|
1850
1855
|
constructor(t, s, n) {
|
|
1851
1856
|
super({ isOpened: t }, s, {
|
|
1852
1857
|
close: "web_app_close_scan_qr_popup",
|
|
@@ -1879,7 +1884,7 @@ class fs extends V {
|
|
|
1879
1884
|
throw new Error("QR scanner is already opened.");
|
|
1880
1885
|
this.isOpened = !0;
|
|
1881
1886
|
try {
|
|
1882
|
-
return (await
|
|
1887
|
+
return (await f({
|
|
1883
1888
|
method: "web_app_open_scan_qr_popup",
|
|
1884
1889
|
event: ["qr_text_received", "scan_qr_popup_closed"],
|
|
1885
1890
|
postEvent: this.postEvent,
|
|
@@ -1890,10 +1895,10 @@ class fs extends V {
|
|
|
1890
1895
|
}
|
|
1891
1896
|
}
|
|
1892
1897
|
}
|
|
1893
|
-
const
|
|
1894
|
-
({ version: e, postEvent: t }) => new
|
|
1898
|
+
const vs = d(
|
|
1899
|
+
({ version: e, postEvent: t }) => new bs(!1, e, t)
|
|
1895
1900
|
);
|
|
1896
|
-
class
|
|
1901
|
+
class ys extends ot {
|
|
1897
1902
|
constructor(t, s, n) {
|
|
1898
1903
|
super({ isVisible: t }, s, {
|
|
1899
1904
|
show: "web_app_setup_settings_button",
|
|
@@ -1922,15 +1927,18 @@ class bs extends at {
|
|
|
1922
1927
|
this.isVisible = !0;
|
|
1923
1928
|
}
|
|
1924
1929
|
}
|
|
1925
|
-
const
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1930
|
+
const Es = d(
|
|
1931
|
+
"settingsButton",
|
|
1932
|
+
({
|
|
1933
|
+
version: e,
|
|
1934
|
+
postEvent: t,
|
|
1935
|
+
state: s = { isVisible: !1 }
|
|
1936
|
+
}) => new ys(s.isVisible, e, t)
|
|
1937
|
+
);
|
|
1938
|
+
function Ft(e) {
|
|
1939
|
+
return $t().parse(e);
|
|
1932
1940
|
}
|
|
1933
|
-
class
|
|
1941
|
+
class Ps extends ct {
|
|
1934
1942
|
/**
|
|
1935
1943
|
* @since v6.10
|
|
1936
1944
|
*/
|
|
@@ -1969,7 +1977,7 @@ class ys extends ht {
|
|
|
1969
1977
|
* value is calculated according to theme bg color.
|
|
1970
1978
|
*/
|
|
1971
1979
|
get isDark() {
|
|
1972
|
-
return !this.bgColor ||
|
|
1980
|
+
return !this.bgColor || Nt(this.bgColor);
|
|
1973
1981
|
}
|
|
1974
1982
|
get linkColor() {
|
|
1975
1983
|
return this.get("linkColor");
|
|
@@ -1995,7 +2003,7 @@ class ys extends ht {
|
|
|
1995
2003
|
*/
|
|
1996
2004
|
listen() {
|
|
1997
2005
|
return E("theme_changed", (t) => {
|
|
1998
|
-
this.set(
|
|
2006
|
+
this.set(Ft(t.theme_params));
|
|
1999
2007
|
});
|
|
2000
2008
|
}
|
|
2001
2009
|
/**
|
|
@@ -2008,20 +2016,23 @@ class ys extends ht {
|
|
|
2008
2016
|
return this.get("textColor");
|
|
2009
2017
|
}
|
|
2010
2018
|
}
|
|
2011
|
-
const
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2019
|
+
const Rs = d(
|
|
2020
|
+
"themeParams",
|
|
2021
|
+
({ themeParams: e, state: t = e, addCleanup: s }) => {
|
|
2022
|
+
const n = new Ps(t);
|
|
2023
|
+
return s(n.listen()), n;
|
|
2024
|
+
}
|
|
2025
|
+
);
|
|
2026
|
+
function yn(e = {}) {
|
|
2027
|
+
return f({
|
|
2017
2028
|
...e,
|
|
2018
2029
|
method: "web_app_request_theme",
|
|
2019
2030
|
event: "theme_changed"
|
|
2020
|
-
}).then(
|
|
2031
|
+
}).then(Ft);
|
|
2021
2032
|
}
|
|
2022
|
-
class
|
|
2033
|
+
class xs extends ht {
|
|
2023
2034
|
constructor(t, s, n) {
|
|
2024
|
-
super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam =
|
|
2035
|
+
super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Qt(t, {
|
|
2025
2036
|
"openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
|
|
2026
2037
|
});
|
|
2027
2038
|
}
|
|
@@ -2036,7 +2047,7 @@ class Ps extends pt {
|
|
|
2036
2047
|
*/
|
|
2037
2048
|
openLink(t, s) {
|
|
2038
2049
|
const n = new URL(t, window.location.href).toString();
|
|
2039
|
-
if (!
|
|
2050
|
+
if (!C("web_app_open_link", this.version)) {
|
|
2040
2051
|
window.open(n, "_blank");
|
|
2041
2052
|
return;
|
|
2042
2053
|
}
|
|
@@ -2055,7 +2066,7 @@ class Ps extends pt {
|
|
|
2055
2066
|
const { hostname: s, pathname: n, search: r } = new URL(t, window.location.href);
|
|
2056
2067
|
if (s !== "t.me")
|
|
2057
2068
|
throw new Error(`URL has not allowed hostname: ${s}. Only "t.me" is allowed`);
|
|
2058
|
-
if (!
|
|
2069
|
+
if (!C("web_app_open_tg_link", this.version)) {
|
|
2059
2070
|
window.location.href = t;
|
|
2060
2071
|
return;
|
|
2061
2072
|
}
|
|
@@ -2070,41 +2081,41 @@ class Ps extends pt {
|
|
|
2070
2081
|
async readTextFromClipboard() {
|
|
2071
2082
|
const t = this.createRequestId(), {
|
|
2072
2083
|
data: s = null
|
|
2073
|
-
} = await
|
|
2084
|
+
} = await f({
|
|
2074
2085
|
method: "web_app_read_text_from_clipboard",
|
|
2075
2086
|
event: "clipboard_text_received",
|
|
2076
2087
|
postEvent: this.postEvent,
|
|
2077
2088
|
params: { req_id: t },
|
|
2078
|
-
capture:
|
|
2089
|
+
capture: Ot(t)
|
|
2079
2090
|
});
|
|
2080
2091
|
return s;
|
|
2081
2092
|
}
|
|
2082
2093
|
}
|
|
2083
|
-
const
|
|
2084
|
-
({ version: e, postEvent: t, createRequestId: s }) => new
|
|
2094
|
+
const Cs = d(
|
|
2095
|
+
({ version: e, postEvent: t, createRequestId: s }) => new xs(e, s, t)
|
|
2085
2096
|
);
|
|
2086
|
-
async function
|
|
2097
|
+
async function Yt(e = {}) {
|
|
2087
2098
|
const {
|
|
2088
2099
|
is_expanded: t,
|
|
2089
2100
|
is_state_stable: s,
|
|
2090
2101
|
...n
|
|
2091
|
-
} = await
|
|
2102
|
+
} = await f({
|
|
2092
2103
|
...e,
|
|
2093
2104
|
method: "web_app_request_viewport",
|
|
2094
2105
|
event: "viewport_changed"
|
|
2095
2106
|
});
|
|
2096
2107
|
return { ...n, isExpanded: t, isStateStable: s };
|
|
2097
2108
|
}
|
|
2098
|
-
function
|
|
2109
|
+
function I(e) {
|
|
2099
2110
|
return e < 0 ? 0 : e;
|
|
2100
2111
|
}
|
|
2101
|
-
class
|
|
2112
|
+
class Ss extends ct {
|
|
2102
2113
|
constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
|
|
2103
2114
|
super({
|
|
2104
|
-
height:
|
|
2115
|
+
height: I(n),
|
|
2105
2116
|
isExpanded: i,
|
|
2106
|
-
stableHeight:
|
|
2107
|
-
width:
|
|
2117
|
+
stableHeight: I(s),
|
|
2118
|
+
width: I(r)
|
|
2108
2119
|
}), c(this, "postEvent"), this.postEvent = t;
|
|
2109
2120
|
}
|
|
2110
2121
|
/**
|
|
@@ -2113,7 +2124,7 @@ class Ft extends ht {
|
|
|
2113
2124
|
* @param options - options to request fresh data.
|
|
2114
2125
|
*/
|
|
2115
2126
|
async sync(t) {
|
|
2116
|
-
const { isStateStable: s, ...n } = await
|
|
2127
|
+
const { isStateStable: s, ...n } = await Yt(t);
|
|
2117
2128
|
this.set({
|
|
2118
2129
|
...n,
|
|
2119
2130
|
stableHeight: s ? n.height : this.get("stableHeight")
|
|
@@ -2166,12 +2177,12 @@ class Ft extends ht {
|
|
|
2166
2177
|
width: n,
|
|
2167
2178
|
is_expanded: r,
|
|
2168
2179
|
is_state_stable: i
|
|
2169
|
-
} = t,
|
|
2180
|
+
} = t, a = I(s);
|
|
2170
2181
|
this.set({
|
|
2171
|
-
height:
|
|
2182
|
+
height: a,
|
|
2172
2183
|
isExpanded: r,
|
|
2173
|
-
width:
|
|
2174
|
-
...i ? { stableHeight:
|
|
2184
|
+
width: I(n),
|
|
2185
|
+
...i ? { stableHeight: a } : {}
|
|
2175
2186
|
});
|
|
2176
2187
|
});
|
|
2177
2188
|
}
|
|
@@ -2205,68 +2216,49 @@ class Ft extends ht {
|
|
|
2205
2216
|
return this.stableHeight === this.height;
|
|
2206
2217
|
}
|
|
2207
2218
|
}
|
|
2208
|
-
|
|
2209
|
-
const {
|
|
2210
|
-
height: s,
|
|
2211
|
-
width: n,
|
|
2212
|
-
isExpanded: r,
|
|
2213
|
-
isStateStable: i
|
|
2214
|
-
} = await Qt({ ...t, postEvent: e });
|
|
2215
|
-
return new Ft({
|
|
2216
|
-
postEvent: e,
|
|
2217
|
-
height: s,
|
|
2218
|
-
width: n,
|
|
2219
|
-
isExpanded: r,
|
|
2220
|
-
stableHeight: i ? s : 0
|
|
2221
|
-
});
|
|
2222
|
-
}
|
|
2223
|
-
function Ss({
|
|
2224
|
-
state: e,
|
|
2225
|
-
platform: t,
|
|
2226
|
-
postEvent: s
|
|
2227
|
-
}) {
|
|
2228
|
-
let n = !1, r = 0, i = 0, o = 0;
|
|
2229
|
-
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({
|
|
2230
|
-
postEvent: s,
|
|
2231
|
-
height: r,
|
|
2232
|
-
width: i,
|
|
2233
|
-
stableHeight: o,
|
|
2234
|
-
isExpanded: n
|
|
2235
|
-
});
|
|
2236
|
-
}
|
|
2237
|
-
const Cs = _(
|
|
2219
|
+
const Ts = d(
|
|
2238
2220
|
"viewport",
|
|
2239
|
-
async (e) => {
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
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 u = await Yt({ timeout: 1e3, postEvent: s });
|
|
2229
|
+
r = u.isExpanded, i = u.height, a = u.width, o = u.isStateStable ? i : 0;
|
|
2230
|
+
}
|
|
2231
|
+
const p = new Ss({
|
|
2232
|
+
postEvent: s,
|
|
2233
|
+
height: i,
|
|
2234
|
+
width: a,
|
|
2235
|
+
stableHeight: o,
|
|
2236
|
+
isExpanded: r
|
|
2237
|
+
});
|
|
2238
|
+
return n(p.listen()), p;
|
|
2247
2239
|
}
|
|
2248
2240
|
);
|
|
2249
2241
|
function R(e, t) {
|
|
2250
2242
|
document.documentElement.style.setProperty(e, t);
|
|
2251
2243
|
}
|
|
2252
|
-
function
|
|
2253
|
-
s || (s = (
|
|
2244
|
+
function En(e, t, s) {
|
|
2245
|
+
s || (s = (o) => `--tg-${o}-color`);
|
|
2254
2246
|
const n = s("header"), r = s("bg"), i = () => {
|
|
2255
|
-
const { headerColor:
|
|
2256
|
-
if (
|
|
2257
|
-
R(n,
|
|
2247
|
+
const { headerColor: o } = e;
|
|
2248
|
+
if (rt(o))
|
|
2249
|
+
R(n, o);
|
|
2258
2250
|
else {
|
|
2259
2251
|
const { bgColor: p, secondaryBgColor: u } = t;
|
|
2260
|
-
|
|
2252
|
+
o === "bg_color" && p ? R(n, p) : o === "secondary_bg_color" && u && R(n, u);
|
|
2261
2253
|
}
|
|
2262
2254
|
R(r, e.bgColor);
|
|
2263
|
-
},
|
|
2255
|
+
}, a = [
|
|
2264
2256
|
t.on("change", i),
|
|
2265
2257
|
e.on("change", i)
|
|
2266
2258
|
];
|
|
2267
|
-
return i(), () =>
|
|
2259
|
+
return i(), () => a.forEach((o) => o());
|
|
2268
2260
|
}
|
|
2269
|
-
function
|
|
2261
|
+
function Pn(e, t) {
|
|
2270
2262
|
t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
|
|
2271
2263
|
const s = () => {
|
|
2272
2264
|
Object.entries(e.getState()).forEach(([n, r]) => {
|
|
@@ -2275,23 +2267,23 @@ function vn(e, t) {
|
|
|
2275
2267
|
};
|
|
2276
2268
|
return s(), e.on("change", s);
|
|
2277
2269
|
}
|
|
2278
|
-
function
|
|
2270
|
+
function Rn(e, t) {
|
|
2279
2271
|
t || (t = (u) => `--tg-viewport-${u}`);
|
|
2280
2272
|
const [
|
|
2281
2273
|
s,
|
|
2282
2274
|
n,
|
|
2283
2275
|
r
|
|
2284
|
-
] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => R(s, `${e.height}px`),
|
|
2276
|
+
] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => R(s, `${e.height}px`), a = () => R(n, `${e.width}px`), o = () => R(r, `${e.stableHeight}px`), p = [
|
|
2285
2277
|
e.on("change:height", i),
|
|
2286
|
-
e.on("change:width",
|
|
2287
|
-
e.on("change:stableHeight",
|
|
2278
|
+
e.on("change:width", a),
|
|
2279
|
+
e.on("change:stableHeight", o)
|
|
2288
2280
|
];
|
|
2289
|
-
return i(),
|
|
2281
|
+
return i(), a(), o(), () => p.forEach((u) => u());
|
|
2290
2282
|
}
|
|
2291
|
-
function
|
|
2283
|
+
function As(e = !0) {
|
|
2292
2284
|
const t = [
|
|
2293
2285
|
E("reload_iframe", () => {
|
|
2294
|
-
|
|
2286
|
+
N("iframe_will_reload"), window.location.reload();
|
|
2295
2287
|
})
|
|
2296
2288
|
], s = () => t.forEach((n) => n());
|
|
2297
2289
|
if (e) {
|
|
@@ -2303,22 +2295,25 @@ function Ts(e = !0) {
|
|
|
2303
2295
|
() => document.head.removeChild(n)
|
|
2304
2296
|
);
|
|
2305
2297
|
}
|
|
2306
|
-
return
|
|
2298
|
+
return N("iframe_ready", { reload_supported: !0 }), s;
|
|
2299
|
+
}
|
|
2300
|
+
function ks() {
|
|
2301
|
+
return typeof window > "u";
|
|
2307
2302
|
}
|
|
2308
|
-
async function
|
|
2309
|
-
if (
|
|
2303
|
+
async function xn() {
|
|
2304
|
+
if (At(window))
|
|
2310
2305
|
return !0;
|
|
2311
2306
|
try {
|
|
2312
|
-
return await
|
|
2307
|
+
return await f({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
|
|
2313
2308
|
} catch {
|
|
2314
2309
|
return !1;
|
|
2315
2310
|
}
|
|
2316
2311
|
}
|
|
2317
|
-
function
|
|
2312
|
+
function Is(e) {
|
|
2318
2313
|
return e instanceof W;
|
|
2319
2314
|
}
|
|
2320
|
-
function
|
|
2321
|
-
return
|
|
2315
|
+
function Cn(e, t) {
|
|
2316
|
+
return Is(e) && e.type === t;
|
|
2322
2317
|
}
|
|
2323
2318
|
function J(e, t) {
|
|
2324
2319
|
let s, n, r;
|
|
@@ -2328,13 +2323,13 @@ function J(e, t) {
|
|
|
2328
2323
|
params: n
|
|
2329
2324
|
});
|
|
2330
2325
|
}
|
|
2331
|
-
class
|
|
2332
|
-
constructor(t, s, n =
|
|
2333
|
-
if (c(this, "history"), c(this, "ee", new
|
|
2334
|
-
throw
|
|
2326
|
+
class Os {
|
|
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 b(we, "History should not be empty.");
|
|
2335
2330
|
if (s < 0 || s >= t.length)
|
|
2336
|
-
throw
|
|
2337
|
-
|
|
2331
|
+
throw b(
|
|
2332
|
+
fe,
|
|
2338
2333
|
"Index should not be zero and higher or equal than history size."
|
|
2339
2334
|
);
|
|
2340
2335
|
this.history = t.map((r) => J(r, ""));
|
|
@@ -2455,26 +2450,26 @@ function Q({
|
|
|
2455
2450
|
}) {
|
|
2456
2451
|
return { ...e || { hash: "", search: "" }, ...t };
|
|
2457
2452
|
}
|
|
2458
|
-
function
|
|
2453
|
+
function B(e, t) {
|
|
2459
2454
|
return e.startsWith(t) ? e : `${t}${e}`;
|
|
2460
2455
|
}
|
|
2461
|
-
function
|
|
2456
|
+
function L(e) {
|
|
2462
2457
|
return new URL(
|
|
2463
|
-
typeof e == "string" ? e : `${e.pathname || ""}${
|
|
2458
|
+
typeof e == "string" ? e : `${e.pathname || ""}${B(e.search || "", "?")}${B(e.hash || "", "#")}`,
|
|
2464
2459
|
"http://a"
|
|
2465
2460
|
);
|
|
2466
2461
|
}
|
|
2467
|
-
function
|
|
2468
|
-
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);
|
|
2469
2464
|
return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
|
|
2470
2465
|
}
|
|
2471
2466
|
function F(e, t, s) {
|
|
2472
2467
|
let n, r;
|
|
2473
|
-
typeof e == "string" ? n = e : (n =
|
|
2474
|
-
const { pathname: i, search:
|
|
2475
|
-
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 } };
|
|
2476
2471
|
}
|
|
2477
|
-
async function
|
|
2472
|
+
async function D(e) {
|
|
2478
2473
|
return e === 0 ? !0 : Promise.race([
|
|
2479
2474
|
new Promise((t) => {
|
|
2480
2475
|
const s = tt("popstate", () => {
|
|
@@ -2488,39 +2483,39 @@ async function O(e) {
|
|
|
2488
2483
|
})
|
|
2489
2484
|
]);
|
|
2490
2485
|
}
|
|
2491
|
-
async function
|
|
2492
|
-
if (window.history.length <= 1 || (window.history.pushState(null, ""), await
|
|
2486
|
+
async function qs() {
|
|
2487
|
+
if (window.history.length <= 1 || (window.history.pushState(null, ""), await D(1 - window.history.length)))
|
|
2493
2488
|
return;
|
|
2494
|
-
let e = await
|
|
2489
|
+
let e = await D(-1);
|
|
2495
2490
|
for (; e; )
|
|
2496
|
-
e = await
|
|
2491
|
+
e = await D(-1);
|
|
2497
2492
|
}
|
|
2498
|
-
function
|
|
2499
|
-
return
|
|
2493
|
+
function Zt(e) {
|
|
2494
|
+
return L(e).pathname;
|
|
2500
2495
|
}
|
|
2501
2496
|
const bt = 0, Y = 1, Z = 2;
|
|
2502
|
-
class
|
|
2503
|
-
constructor(t, s, { postEvent: n, hashMode: r, base: i } = {}) {
|
|
2504
|
-
c(this, "navigator"), c(this, "ee", new
|
|
2505
|
-
if (
|
|
2497
|
+
class Xt {
|
|
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)
|
|
2506
2501
|
return this.push(this.parsePath(window.location.href));
|
|
2507
|
-
|
|
2502
|
+
a === bt ? window.history.forward() : a === Y && this.back(), a === Z && this.forward();
|
|
2508
2503
|
}), c(this, "onNavigatorChange", async ({
|
|
2509
|
-
to:
|
|
2510
|
-
from:
|
|
2504
|
+
to: a,
|
|
2505
|
+
from: o,
|
|
2511
2506
|
delta: p
|
|
2512
2507
|
}) => {
|
|
2513
2508
|
this.attached && await this.syncHistory(), this.ee.emit("change", {
|
|
2514
2509
|
delta: p,
|
|
2515
|
-
from: Q(
|
|
2516
|
-
to: Q(
|
|
2510
|
+
from: Q(o),
|
|
2511
|
+
to: Q(a),
|
|
2517
2512
|
navigator: this
|
|
2518
2513
|
});
|
|
2519
|
-
}), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new
|
|
2520
|
-
t.map((
|
|
2514
|
+
}), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new Os(
|
|
2515
|
+
t.map((a) => F(a, "/")),
|
|
2521
2516
|
s,
|
|
2522
2517
|
n
|
|
2523
|
-
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base =
|
|
2518
|
+
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Zt(i || "");
|
|
2524
2519
|
}
|
|
2525
2520
|
/**
|
|
2526
2521
|
* Attaches current navigator to the browser history allowing navigator to manipulate it.
|
|
@@ -2618,7 +2613,7 @@ class Zt {
|
|
|
2618
2613
|
* "/pathname?search#hash"
|
|
2619
2614
|
*/
|
|
2620
2615
|
get path() {
|
|
2621
|
-
return
|
|
2616
|
+
return U(this);
|
|
2622
2617
|
}
|
|
2623
2618
|
/**
|
|
2624
2619
|
* Current pathname. Always starts with the slash.
|
|
@@ -2647,8 +2642,8 @@ class Zt {
|
|
|
2647
2642
|
* // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
|
|
2648
2643
|
*/
|
|
2649
2644
|
parsePath(t) {
|
|
2650
|
-
let s =
|
|
2651
|
-
return this.hashMode && (s =
|
|
2645
|
+
let s = L(t);
|
|
2646
|
+
return this.hashMode && (s = L(s.hash.slice(1))), {
|
|
2652
2647
|
pathname: s.pathname,
|
|
2653
2648
|
search: s.search,
|
|
2654
2649
|
hash: s.hash
|
|
@@ -2668,8 +2663,8 @@ class Zt {
|
|
|
2668
2663
|
* @param value - path presented as string or URLLike.
|
|
2669
2664
|
*/
|
|
2670
2665
|
renderPath(t) {
|
|
2671
|
-
const s = (this.base.length === 1 ? "" : this.base) +
|
|
2672
|
-
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;
|
|
2673
2668
|
}
|
|
2674
2669
|
/**
|
|
2675
2670
|
* Synchronizes current navigator state with browser history.
|
|
@@ -2677,7 +2672,7 @@ class Zt {
|
|
|
2677
2672
|
async syncHistory() {
|
|
2678
2673
|
window.removeEventListener("popstate", this.onPopState);
|
|
2679
2674
|
const { state: t } = this, s = this.renderPath(this);
|
|
2680
|
-
await
|
|
2675
|
+
await qs(), 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(bt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
|
|
2681
2676
|
}
|
|
2682
2677
|
/**
|
|
2683
2678
|
* Current query parameters.
|
|
@@ -2695,297 +2690,326 @@ class Zt {
|
|
|
2695
2690
|
return (this.navigator.current.params || {}).state;
|
|
2696
2691
|
}
|
|
2697
2692
|
}
|
|
2698
|
-
function
|
|
2693
|
+
function Ds(e) {
|
|
2699
2694
|
e || (e = {});
|
|
2700
2695
|
const { href: t, hash: s } = window.location;
|
|
2701
|
-
let n =
|
|
2702
|
-
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)}`
|
|
2703
2698
|
);
|
|
2704
|
-
const r = e.base ?
|
|
2699
|
+
const r = e.base ? Zt(e.base) : void 0;
|
|
2705
2700
|
if (r) {
|
|
2706
2701
|
if (!n.startsWith(r))
|
|
2707
|
-
throw
|
|
2702
|
+
throw b(
|
|
2708
2703
|
me,
|
|
2709
2704
|
`Path "${n}" expected to be starting with "${r}"`
|
|
2710
2705
|
);
|
|
2711
2706
|
n = n.slice(r.length);
|
|
2712
2707
|
}
|
|
2713
|
-
return new
|
|
2708
|
+
return new Xt([n], 0, e);
|
|
2714
2709
|
}
|
|
2715
|
-
function
|
|
2710
|
+
function Sn(e) {
|
|
2716
2711
|
const t = e.match(/#(.+)/);
|
|
2717
2712
|
return t ? t[1] : null;
|
|
2718
2713
|
}
|
|
2719
|
-
function
|
|
2720
|
-
if (
|
|
2714
|
+
function Ns(e, t) {
|
|
2715
|
+
if (Kt()) {
|
|
2721
2716
|
const s = sessionStorage.getItem(e);
|
|
2722
2717
|
if (s)
|
|
2723
2718
|
try {
|
|
2724
2719
|
const { index: n, history: r } = JSON.parse(s);
|
|
2725
|
-
return new
|
|
2720
|
+
return new Xt(r, n, t);
|
|
2726
2721
|
} catch (n) {
|
|
2727
2722
|
console.error("Unable to restore hash navigator state.", n);
|
|
2728
2723
|
}
|
|
2729
2724
|
}
|
|
2730
|
-
return
|
|
2725
|
+
return Ds(t);
|
|
2731
2726
|
}
|
|
2732
|
-
function
|
|
2733
|
-
const s =
|
|
2727
|
+
function Tn(e, t) {
|
|
2728
|
+
const s = Ns(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
|
|
2734
2729
|
index: s.index,
|
|
2735
2730
|
history: s.history
|
|
2736
2731
|
}));
|
|
2737
2732
|
return s.on("change", n), n(), s;
|
|
2738
2733
|
}
|
|
2739
|
-
function
|
|
2734
|
+
function _(e, t) {
|
|
2740
2735
|
function s(n) {
|
|
2741
|
-
return (r, i,
|
|
2742
|
-
const p =
|
|
2743
|
-
return /* @__PURE__ */ vt(
|
|
2736
|
+
return (r, i, a) => (o) => {
|
|
2737
|
+
const p = o[i] || [], u = { ...o, [r]: n(...p) };
|
|
2738
|
+
return /* @__PURE__ */ vt(a, { ...u });
|
|
2744
2739
|
};
|
|
2745
2740
|
}
|
|
2746
2741
|
return [s(e), s(t)];
|
|
2747
2742
|
}
|
|
2748
|
-
const
|
|
2749
|
-
function
|
|
2750
|
-
const e =
|
|
2743
|
+
const te = se(void 0);
|
|
2744
|
+
function Bs() {
|
|
2745
|
+
const e = ne(te);
|
|
2751
2746
|
if (!e)
|
|
2752
2747
|
throw new Error("useSDK was used outside the SDKProvider.");
|
|
2753
2748
|
return e;
|
|
2754
2749
|
}
|
|
2755
|
-
function
|
|
2756
|
-
|
|
2757
|
-
const r =
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
return
|
|
2765
|
-
|
|
2750
|
+
function g(e) {
|
|
2751
|
+
function t(n) {
|
|
2752
|
+
const r = Bs(), [i, a] = yt(
|
|
2753
|
+
n ? void 0 : () => {
|
|
2754
|
+
if (ks())
|
|
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 O(() => {
|
|
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];
|
|
2766
2772
|
}
|
|
2767
|
-
const [
|
|
2768
|
-
|
|
2769
|
-
Vs
|
|
2770
|
-
), [Bs, Ms] = w(Je), [Tn, An] = g(
|
|
2771
|
-
Bs,
|
|
2773
|
+
const [Vs, Ms] = g(Ke), [An, kn] = _(
|
|
2774
|
+
Vs,
|
|
2772
2775
|
Ms
|
|
2773
|
-
), [$s, Ls] =
|
|
2776
|
+
), [$s, Ls] = g(Fe), [In, On] = _(
|
|
2774
2777
|
$s,
|
|
2775
2778
|
Ls
|
|
2776
|
-
), [
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
), [Ws, js] =
|
|
2779
|
+
), [Us, Hs] = g(Ze), [qn, Dn] = _(
|
|
2780
|
+
Us,
|
|
2781
|
+
Hs
|
|
2782
|
+
), [Ws, js] = g(ns), [Nn, Bn] = _(
|
|
2780
2783
|
Ws,
|
|
2781
2784
|
js
|
|
2782
|
-
), [Gs, zs] =
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
), [
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2785
|
+
), [Gs, zs] = g(is), [Vn, Mn] = _(
|
|
2786
|
+
Gs,
|
|
2787
|
+
zs
|
|
2788
|
+
), [Ks, Js] = g(as), [$n, Ln] = _(Ks, Js), [Qs, Fs] = g(hs), [Un, Hn] = _(Qs, Fs), [Ys, Zs] = g(us), [Wn, jn] = _(Ys, Zs), [Xs, tn] = g(gs), [Gn, zn] = _(Xs, tn), [en, sn] = g(ms), [Kn, Jn] = _(en, sn), [nn, rn] = g(vs), [Qn, Fn] = _(nn, rn), [on, an] = g(Es), [Yn, Zn] = _(
|
|
2789
|
+
on,
|
|
2790
|
+
an
|
|
2791
|
+
), [cn, hn] = g(Rs), [Xn, tr] = _(cn, hn);
|
|
2792
|
+
function er() {
|
|
2793
|
+
return Et(zt, []);
|
|
2794
|
+
}
|
|
2795
|
+
const [pn, un] = g(Cs), [sr, nr] = _(pn, un), [ln, dn] = g(Ts), [rr, ir] = _(ln, dn);
|
|
2796
|
+
function or({ children: e, acceptCustomStyles: t, debug: s }) {
|
|
2797
|
+
const n = _t(!0), r = _t(/* @__PURE__ */ new Map()), [i, a] = yt([]), o = gt(() => a([]), []), p = gt(
|
|
2798
|
+
(l) => {
|
|
2799
|
+
n.current && (l && l(r.current), o());
|
|
2800
|
+
},
|
|
2801
|
+
[o]
|
|
2802
|
+
), u = Et(() => ({
|
|
2803
|
+
use(l, ...ee) {
|
|
2804
|
+
const { current: pt } = r, ut = pt.get(l);
|
|
2798
2805
|
if (ut)
|
|
2799
2806
|
return ut;
|
|
2800
|
-
let
|
|
2807
|
+
let v, K;
|
|
2801
2808
|
try {
|
|
2802
|
-
|
|
2803
|
-
} catch (
|
|
2804
|
-
|
|
2809
|
+
v = l(...ee);
|
|
2810
|
+
} catch (m) {
|
|
2811
|
+
K = m;
|
|
2812
|
+
}
|
|
2813
|
+
function $(m) {
|
|
2814
|
+
return pt.set(l, m), m;
|
|
2805
2815
|
}
|
|
2806
|
-
if (
|
|
2807
|
-
return
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2816
|
+
if (K)
|
|
2817
|
+
return $({ error: K });
|
|
2818
|
+
let A;
|
|
2819
|
+
if (Array.isArray(v) && (A = v[1], v = v[0]), !v)
|
|
2820
|
+
return $({ result: v, cleanup: A });
|
|
2821
|
+
function lt(m) {
|
|
2822
|
+
if ("on" in m) {
|
|
2823
|
+
const k = m.on("change", o), dt = A;
|
|
2824
|
+
A = () => {
|
|
2825
|
+
dt && dt(), k();
|
|
2826
|
+
};
|
|
2827
|
+
}
|
|
2828
|
+
return { result: m, cleanup: A };
|
|
2829
|
+
}
|
|
2830
|
+
return v instanceof Promise ? (v.then(
|
|
2831
|
+
(m) => p((k) => k.set(l, lt(m))),
|
|
2832
|
+
(m) => p((k) => k.set(l, { error: m }))
|
|
2833
|
+
), $({})) : $(lt(v));
|
|
2813
2834
|
}
|
|
2814
|
-
}), [
|
|
2815
|
-
return
|
|
2816
|
-
|
|
2817
|
-
|
|
2835
|
+
}), [i]);
|
|
2836
|
+
return O(() => {
|
|
2837
|
+
if (kt())
|
|
2838
|
+
return As(t);
|
|
2839
|
+
}, [t]), O(() => {
|
|
2840
|
+
ce(s || !1);
|
|
2841
|
+
}, [s]), O(() => () => {
|
|
2818
2842
|
n.current = !1;
|
|
2819
|
-
}, []),
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2843
|
+
}, []), O(() => () => {
|
|
2844
|
+
r.current.forEach((l) => {
|
|
2845
|
+
"cleanup" in l && l.cleanup && l.cleanup();
|
|
2846
|
+
});
|
|
2847
|
+
}, [o]), /* @__PURE__ */ vt(te.Provider, { value: u, children: e });
|
|
2823
2848
|
}
|
|
2824
2849
|
export {
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2850
|
+
De as BackButton,
|
|
2851
|
+
Os as BasicNavigator,
|
|
2852
|
+
Je as BiometryManager,
|
|
2853
|
+
Xt as BrowserNavigator,
|
|
2854
|
+
Ye as ClosingBehavior,
|
|
2855
|
+
ss as CloudStorage,
|
|
2831
2856
|
me as ERR_INVALID_PATH_BASE,
|
|
2832
2857
|
de as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
fs as QRScanner,
|
|
2858
|
+
ue as ERR_METHOD_PARAMETER_UNSUPPORTED,
|
|
2859
|
+
pe as ERR_METHOD_UNSUPPORTED,
|
|
2860
|
+
we as ERR_NAVIGATION_HISTORY_EMPTY,
|
|
2861
|
+
fe as ERR_NAVIGATION_INDEX_INVALID,
|
|
2862
|
+
wn as ERR_NAVIGATION_ITEM_INVALID,
|
|
2863
|
+
xt as ERR_PARSE,
|
|
2864
|
+
fn as ERR_SSR_INIT,
|
|
2865
|
+
_e as ERR_TIMED_OUT,
|
|
2866
|
+
ge as ERR_UNEXPECTED_TYPE,
|
|
2867
|
+
le as ERR_UNKNOWN_ENV,
|
|
2868
|
+
H as EventEmitter,
|
|
2869
|
+
rs as HapticFeedback,
|
|
2870
|
+
os as InitData,
|
|
2871
|
+
cs as Invoice,
|
|
2872
|
+
ps as MainButton,
|
|
2873
|
+
_s as MiniApp,
|
|
2874
|
+
fs as Popup,
|
|
2875
|
+
bs as QRScanner,
|
|
2852
2876
|
W as SDKError,
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2877
|
+
or as SDKProvider,
|
|
2878
|
+
ys as SettingsButton,
|
|
2879
|
+
Ps as ThemeParams,
|
|
2880
|
+
xs as Utils,
|
|
2881
|
+
Ss as Viewport,
|
|
2882
|
+
es as array,
|
|
2883
|
+
En as bindMiniAppCSSVars,
|
|
2884
|
+
Pn as bindThemeParamsCSSVars,
|
|
2885
|
+
Rn as bindViewportCSSVars,
|
|
2862
2886
|
P as boolean,
|
|
2863
|
-
|
|
2887
|
+
Ot as captureSameReq,
|
|
2864
2888
|
et as classNames,
|
|
2865
2889
|
Ae as compareVersions,
|
|
2866
|
-
|
|
2890
|
+
Ds as createBrowserNavigatorFromLocation,
|
|
2867
2891
|
Oe as createPostEvent,
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2892
|
+
L as createSafeURL,
|
|
2893
|
+
Vt as date,
|
|
2894
|
+
Sn as getHash,
|
|
2895
|
+
Zt as getPathname,
|
|
2896
|
+
Ke as initBackButton,
|
|
2897
|
+
Fe as initBiometryManager,
|
|
2898
|
+
Ze as initClosingBehavior,
|
|
2899
|
+
ns as initCloudStorage,
|
|
2900
|
+
is as initHapticFeedback,
|
|
2901
|
+
as as initInitData,
|
|
2902
|
+
hs as initInvoice,
|
|
2903
|
+
us as initMainButton,
|
|
2904
|
+
gs as initMiniApp,
|
|
2905
|
+
Tn as initNavigator,
|
|
2906
|
+
ms as initPopup,
|
|
2907
|
+
vs as initQRScanner,
|
|
2908
|
+
Es as initSettingsButton,
|
|
2909
|
+
Rs as initThemeParams,
|
|
2910
|
+
Cs as initUtils,
|
|
2911
|
+
Ts as initViewport,
|
|
2912
|
+
As as initWeb,
|
|
2913
|
+
q as invokeCustomMethod,
|
|
2914
|
+
Nt as isColorDark,
|
|
2915
|
+
kt as isIframe,
|
|
2916
|
+
Kt as isPageReload,
|
|
2917
|
+
rt as isRGB,
|
|
2894
2918
|
be as isRGBShort,
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2919
|
+
Is as isSDKError,
|
|
2920
|
+
Cn as isSDKErrorOfType,
|
|
2921
|
+
ks as isSSR,
|
|
2922
|
+
xn as isTMA,
|
|
2923
|
+
w as json,
|
|
2924
|
+
bn as mergeClassNames,
|
|
2901
2925
|
x as number,
|
|
2902
2926
|
z as off,
|
|
2903
2927
|
E as on,
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2928
|
+
vn as parseInitData,
|
|
2929
|
+
Lt as parseLaunchParams,
|
|
2930
|
+
Ft as parseThemeParams,
|
|
2931
|
+
N as postEvent,
|
|
2932
|
+
f as request,
|
|
2933
|
+
Qe as requestBiometryInfo,
|
|
2934
|
+
yn as requestThemeParams,
|
|
2935
|
+
Yt as requestViewport,
|
|
2936
|
+
zt as retrieveLaunchParams,
|
|
2937
|
+
Tt as rgb,
|
|
2938
|
+
at as searchParams,
|
|
2939
|
+
He as serializeLaunchParams,
|
|
2940
|
+
Ue as serializeThemeParams,
|
|
2917
2941
|
R as setCSSVar,
|
|
2918
|
-
|
|
2919
|
-
|
|
2942
|
+
ce as setDebug,
|
|
2943
|
+
mn as setTargetOrigin,
|
|
2920
2944
|
h as string,
|
|
2921
|
-
|
|
2922
|
-
|
|
2945
|
+
oe as subscribe,
|
|
2946
|
+
C as supports,
|
|
2923
2947
|
Ie as targetOrigin,
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
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
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2948
|
+
St as toRGB,
|
|
2949
|
+
Rt as unsubscribe,
|
|
2950
|
+
U as urlToPath,
|
|
2951
|
+
Ms as useBackButton,
|
|
2952
|
+
Vs as useBackButtonRaw,
|
|
2953
|
+
Ls as useBiometryManager,
|
|
2954
|
+
$s as useBiometryManagerRaw,
|
|
2955
|
+
Hs as useClosingBehavior,
|
|
2956
|
+
Us as useClosingBehaviorRaw,
|
|
2957
|
+
js as useCloudStorage,
|
|
2958
|
+
Ws as useCloudStorageRaw,
|
|
2959
|
+
zs as useHapticFeedback,
|
|
2960
|
+
Gs as useHapticFeedbackRaw,
|
|
2961
|
+
Js as useInitData,
|
|
2962
|
+
Ks as useInitDataRaw,
|
|
2963
|
+
Fs as useInvoice,
|
|
2964
|
+
Qs as useInvoiceRaw,
|
|
2965
|
+
er as useLaunchParams,
|
|
2966
|
+
Zs as useMainButton,
|
|
2967
|
+
Ys as useMainButtonRaw,
|
|
2968
|
+
tn as useMiniApp,
|
|
2969
|
+
Xs as useMiniAppRaw,
|
|
2970
|
+
sn as usePopup,
|
|
2971
|
+
en as usePopupRaw,
|
|
2972
|
+
rn as useQRScanner,
|
|
2973
|
+
nn as useQRScannerRaw,
|
|
2974
|
+
Bs as useSDK,
|
|
2975
|
+
an as useSettingsButton,
|
|
2976
|
+
on as useSettingsButtonRaw,
|
|
2977
|
+
hn as useThemeParams,
|
|
2978
|
+
cn as useThemeParamsRaw,
|
|
2979
|
+
un as useUtils,
|
|
2980
|
+
pn as useUtilsRaw,
|
|
2981
|
+
dn as useViewport,
|
|
2982
|
+
ln as useViewportRaw,
|
|
2983
|
+
kn as withBackButton,
|
|
2984
|
+
An as withBackButtonRaw,
|
|
2985
|
+
On as withBiometryManager,
|
|
2986
|
+
In as withBiometryManagerRaw,
|
|
2987
|
+
Dn as withClosingBehavior,
|
|
2988
|
+
qn as withClosingBehaviorRaw,
|
|
2989
|
+
Bn as withCloudStorage,
|
|
2990
|
+
Nn as withCloudStorageRaw,
|
|
2991
|
+
Mn as withHapticFeedback,
|
|
2992
|
+
Vn as withHapticFeedbackRaw,
|
|
2993
|
+
Ln as withInitData,
|
|
2994
|
+
$n as withInitDataRaw,
|
|
2995
|
+
Hn as withInvoice,
|
|
2996
|
+
Un as withInvoiceRaw,
|
|
2997
|
+
jn as withMainButton,
|
|
2998
|
+
Wn as withMainButtonRaw,
|
|
2999
|
+
zn as withMiniApp,
|
|
3000
|
+
Gn as withMiniAppRaw,
|
|
3001
|
+
Jn as withPopup,
|
|
3002
|
+
Kn as withPopupRaw,
|
|
3003
|
+
Fn as withQRScanner,
|
|
3004
|
+
Qn as withQRScannerRaw,
|
|
3005
|
+
Zn as withSettingsButton,
|
|
3006
|
+
Yn as withSettingsButtonRaw,
|
|
3007
|
+
tr as withThemeParams,
|
|
3008
|
+
Xn as withThemeParamsRaw,
|
|
3009
|
+
Dt as withTimeout,
|
|
3010
|
+
nr as withUtils,
|
|
3011
|
+
sr as withUtilsRaw,
|
|
3012
|
+
ir as withViewport,
|
|
3013
|
+
rr as withViewportRaw
|
|
2990
3014
|
};
|
|
2991
3015
|
//# sourceMappingURL=index.js.map
|