@tma.js/sdk-react 2.1.4 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dts/SDKProvider/SDKProvider.types.d.ts +3 -4
- package/dist/dts/createHOCs.d.ts +6 -10
- package/dist/dts/createHooks.d.ts +6 -7
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +604 -587
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as mt } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as
|
|
3
|
-
var
|
|
2
|
+
import { createContext as te, useContext as ee, useState as bt, useEffect as S, useMemo as vt, useRef as dt, useCallback as se } from "react";
|
|
3
|
+
var ne = Object.defineProperty, re = (e, t, s) => t in e ? ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (re(e, typeof t != "symbol" ? t + "" : t, s), s);
|
|
4
4
|
function yt(e, t) {
|
|
5
5
|
let s;
|
|
6
6
|
const n = () => {
|
|
@@ -9,13 +9,13 @@ function yt(e, t) {
|
|
|
9
9
|
return [() => s === void 0 ? s = e(n) : s, n];
|
|
10
10
|
}
|
|
11
11
|
function Et(e) {
|
|
12
|
-
const t =
|
|
12
|
+
const t = j(), { count: s } = t;
|
|
13
13
|
t.unsubscribe(e), s && !t.count && Ce();
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return
|
|
15
|
+
function ie(e) {
|
|
16
|
+
return j().subscribe(e), () => Et(e);
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class oe {
|
|
19
19
|
constructor(t, s = {}) {
|
|
20
20
|
this.scope = t, this.options = s;
|
|
21
21
|
}
|
|
@@ -31,12 +31,12 @@ class ie {
|
|
|
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: o } = this.options, a = "font-weight: bold;padding: 0 5px;border-radius:5px";
|
|
35
35
|
console[t](
|
|
36
36
|
`%c${r}%c / %c${this.scope}`,
|
|
37
|
-
`${
|
|
37
|
+
`${a};background-color: lightblue;color:black`,
|
|
38
38
|
"",
|
|
39
|
-
`${
|
|
39
|
+
`${a};${i ? `color:${i};` : ""}${o ? `background-color:${o}` : ""}`,
|
|
40
40
|
...s
|
|
41
41
|
);
|
|
42
42
|
}
|
|
@@ -55,21 +55,21 @@ class ie {
|
|
|
55
55
|
this.print("log", ...t);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
const st = new
|
|
58
|
+
const st = new oe("SDK", {
|
|
59
59
|
bgColor: "forestgreen",
|
|
60
60
|
textColor: "white"
|
|
61
61
|
});
|
|
62
62
|
let X = !1;
|
|
63
|
-
const _t = ({
|
|
64
|
-
st.log("Event received:", t
|
|
63
|
+
const _t = ({ name: e, payload: t }) => {
|
|
64
|
+
st.log("Event received:", t ? { name: e, payload: t } : { name: e });
|
|
65
65
|
};
|
|
66
|
-
function
|
|
67
|
-
X !== e && (X = e, e ?
|
|
66
|
+
function ae(e) {
|
|
67
|
+
X !== e && (X = e, e ? ie(_t) : Et(_t));
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function ce(...e) {
|
|
70
70
|
X && st.log(...e);
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class N {
|
|
73
73
|
constructor() {
|
|
74
74
|
c(this, "listeners", /* @__PURE__ */ new Map()), c(this, "listenersCount", 0), c(this, "subscribeListeners", []);
|
|
75
75
|
}
|
|
@@ -142,6 +142,17 @@ class H {
|
|
|
142
142
|
function tt(e, t, s) {
|
|
143
143
|
return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
|
|
144
144
|
}
|
|
145
|
+
function Pt(...e) {
|
|
146
|
+
let t = !1;
|
|
147
|
+
const s = [...e];
|
|
148
|
+
return [
|
|
149
|
+
(n) => !t && s.push(n),
|
|
150
|
+
() => {
|
|
151
|
+
t || (t = !0, s.forEach((n) => n()));
|
|
152
|
+
},
|
|
153
|
+
t
|
|
154
|
+
];
|
|
155
|
+
}
|
|
145
156
|
class W extends Error {
|
|
146
157
|
constructor(t, s, n) {
|
|
147
158
|
super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, W.prototype);
|
|
@@ -150,11 +161,11 @@ class W extends Error {
|
|
|
150
161
|
function m(e, t, s) {
|
|
151
162
|
return new W(e, t, s);
|
|
152
163
|
}
|
|
153
|
-
const
|
|
164
|
+
const he = "ERR_METHOD_UNSUPPORTED", pe = "ERR_METHOD_PARAMETER_UNSUPPORTED", ue = "ERR_UNKNOWN_ENV", le = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", de = "ERR_TIMED_OUT", _e = "ERR_UNEXPECTED_TYPE", Rt = "ERR_PARSE", ge = "ERR_NAVIGATION_LIST_EMPTY", we = "ERR_NAVIGATION_CURSOR_INVALID", dn = "ERR_NAVIGATION_ITEM_INVALID", _n = "ERR_SSR_INIT", fe = "ERR_INVALID_PATH_BASE";
|
|
154
165
|
function T() {
|
|
155
|
-
return m(
|
|
166
|
+
return m(_e, "Value has unexpected type");
|
|
156
167
|
}
|
|
157
|
-
class
|
|
168
|
+
class G {
|
|
158
169
|
constructor(t, s, n) {
|
|
159
170
|
this.parser = t, this.isOptional = s, this.type = n;
|
|
160
171
|
}
|
|
@@ -170,7 +181,7 @@ class j {
|
|
|
170
181
|
return this.parser(t);
|
|
171
182
|
} catch (s) {
|
|
172
183
|
throw m(
|
|
173
|
-
|
|
184
|
+
Rt,
|
|
174
185
|
`Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
|
|
175
186
|
s
|
|
176
187
|
);
|
|
@@ -181,7 +192,7 @@ class j {
|
|
|
181
192
|
}
|
|
182
193
|
}
|
|
183
194
|
function A(e, t) {
|
|
184
|
-
return () => new
|
|
195
|
+
return () => new G(e, !1, t);
|
|
185
196
|
}
|
|
186
197
|
const P = A((e) => {
|
|
187
198
|
if (typeof e == "boolean")
|
|
@@ -193,24 +204,24 @@ const P = A((e) => {
|
|
|
193
204
|
return !1;
|
|
194
205
|
throw T();
|
|
195
206
|
}, "boolean");
|
|
196
|
-
function
|
|
207
|
+
function xt(e, t) {
|
|
197
208
|
const s = {};
|
|
198
209
|
for (const n in e) {
|
|
199
210
|
const r = e[n];
|
|
200
211
|
if (!r)
|
|
201
212
|
continue;
|
|
202
|
-
let i,
|
|
213
|
+
let i, o;
|
|
203
214
|
if (typeof r == "function" || "parse" in r)
|
|
204
|
-
i = n,
|
|
215
|
+
i = n, o = typeof r == "function" ? r : r.parse.bind(r);
|
|
205
216
|
else {
|
|
206
|
-
const { type:
|
|
207
|
-
i = r.from || n,
|
|
217
|
+
const { type: a } = r;
|
|
218
|
+
i = r.from || n, o = typeof a == "function" ? a : a.parse.bind(a);
|
|
208
219
|
}
|
|
209
220
|
try {
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
} catch (
|
|
213
|
-
throw m(
|
|
221
|
+
const a = o(t(i));
|
|
222
|
+
a !== void 0 && (s[n] = a);
|
|
223
|
+
} catch (a) {
|
|
224
|
+
throw m(Rt, `Unable to parse field "${n}"`, a);
|
|
214
225
|
}
|
|
215
226
|
}
|
|
216
227
|
return s;
|
|
@@ -222,9 +233,9 @@ function nt(e) {
|
|
|
222
233
|
return t;
|
|
223
234
|
}
|
|
224
235
|
function g(e, t) {
|
|
225
|
-
return new
|
|
236
|
+
return new G((s) => {
|
|
226
237
|
const n = nt(s);
|
|
227
|
-
return
|
|
238
|
+
return xt(e, (r) => n[r]);
|
|
228
239
|
}, !1, t);
|
|
229
240
|
}
|
|
230
241
|
const x = A((e) => {
|
|
@@ -240,14 +251,14 @@ const x = A((e) => {
|
|
|
240
251
|
function rt(e) {
|
|
241
252
|
return /^#[\da-f]{6}$/i.test(e);
|
|
242
253
|
}
|
|
243
|
-
function
|
|
254
|
+
function me(e) {
|
|
244
255
|
return /^#[\da-f]{3}$/i.test(e);
|
|
245
256
|
}
|
|
246
|
-
function
|
|
257
|
+
function Ct(e) {
|
|
247
258
|
const t = e.replace(/\s/g, "").toLowerCase();
|
|
248
259
|
if (rt(t))
|
|
249
260
|
return t;
|
|
250
|
-
if (
|
|
261
|
+
if (me(t)) {
|
|
251
262
|
let n = "#";
|
|
252
263
|
for (let r = 0; r < 3; r += 1)
|
|
253
264
|
n += t[1 + r].repeat(2);
|
|
@@ -265,26 +276,26 @@ const p = A((e) => {
|
|
|
265
276
|
if (typeof e == "string" || typeof e == "number")
|
|
266
277
|
return e.toString();
|
|
267
278
|
throw T();
|
|
268
|
-
}, "string"),
|
|
269
|
-
function
|
|
279
|
+
}, "string"), St = A((e) => Ct(p().parse(e)), "rgb");
|
|
280
|
+
function be(e) {
|
|
270
281
|
return g({
|
|
271
282
|
eventType: p(),
|
|
272
283
|
eventData: (t) => t
|
|
273
284
|
}).parse(e);
|
|
274
285
|
}
|
|
275
|
-
function
|
|
286
|
+
function ve() {
|
|
276
287
|
["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
|
|
277
288
|
delete window[e];
|
|
278
289
|
});
|
|
279
290
|
}
|
|
280
|
-
function
|
|
291
|
+
function ye(e, t) {
|
|
281
292
|
window.dispatchEvent(new MessageEvent("message", {
|
|
282
293
|
data: JSON.stringify({ eventType: e, eventData: t }),
|
|
283
294
|
// We specify window.parent to imitate the case, the parent iframe sent us this event.
|
|
284
295
|
source: window.parent
|
|
285
296
|
}));
|
|
286
297
|
}
|
|
287
|
-
function
|
|
298
|
+
function Ee() {
|
|
288
299
|
[
|
|
289
300
|
["TelegramGameProxy_receiveEvent"],
|
|
290
301
|
// Windows Phone.
|
|
@@ -296,16 +307,14 @@ function ye() {
|
|
|
296
307
|
let t = window;
|
|
297
308
|
e.forEach((s, n, r) => {
|
|
298
309
|
if (n === r.length - 1) {
|
|
299
|
-
t[s] =
|
|
310
|
+
t[s] = ye;
|
|
300
311
|
return;
|
|
301
312
|
}
|
|
302
313
|
s in t || (t[s] = {}), t = t[s];
|
|
303
314
|
});
|
|
304
315
|
});
|
|
305
316
|
}
|
|
306
|
-
const
|
|
307
|
-
button_id: (e) => e == null ? void 0 : p().parse(e)
|
|
308
|
-
}), Pe = {
|
|
317
|
+
const Pe = {
|
|
309
318
|
clipboard_text_received: g({
|
|
310
319
|
req_id: p(),
|
|
311
320
|
data: (e) => e === null ? e : p().optional().parse(e)
|
|
@@ -315,22 +324,19 @@ const Ee = g({
|
|
|
315
324
|
result: (e) => e,
|
|
316
325
|
error: p().optional()
|
|
317
326
|
}),
|
|
318
|
-
invoice_closed: g({
|
|
319
|
-
|
|
320
|
-
status: p()
|
|
321
|
-
}),
|
|
322
|
-
phone_requested: g({
|
|
323
|
-
status: p()
|
|
324
|
-
}),
|
|
327
|
+
invoice_closed: g({ slug: p(), status: p() }),
|
|
328
|
+
phone_requested: g({ status: p() }),
|
|
325
329
|
popup_closed: {
|
|
326
|
-
parse
|
|
330
|
+
parse(e) {
|
|
331
|
+
return g({
|
|
332
|
+
button_id: (t) => t == null ? void 0 : p().parse(t)
|
|
333
|
+
}).parse(e ?? {});
|
|
334
|
+
}
|
|
327
335
|
},
|
|
328
|
-
qr_text_received: g({
|
|
329
|
-
data: p().optional()
|
|
330
|
-
}),
|
|
336
|
+
qr_text_received: g({ data: p().optional() }),
|
|
331
337
|
theme_changed: g({
|
|
332
338
|
theme_params: (e) => {
|
|
333
|
-
const t =
|
|
339
|
+
const t = St().optional();
|
|
334
340
|
return Object.entries(nt(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
|
|
335
341
|
}
|
|
336
342
|
}),
|
|
@@ -340,23 +346,23 @@ const Ee = g({
|
|
|
340
346
|
is_state_stable: P(),
|
|
341
347
|
is_expanded: P()
|
|
342
348
|
}),
|
|
343
|
-
write_access_requested: g({
|
|
344
|
-
status: p()
|
|
345
|
-
})
|
|
349
|
+
write_access_requested: g({ status: p() })
|
|
346
350
|
};
|
|
347
351
|
function Re() {
|
|
348
|
-
const e = new
|
|
349
|
-
|
|
350
|
-
|
|
352
|
+
const e = new N(), t = new N();
|
|
353
|
+
t.subscribe((n) => {
|
|
354
|
+
e.emit("event", { name: n.event, payload: n.args[0] });
|
|
355
|
+
}), Ee();
|
|
356
|
+
const [, s] = Pt(
|
|
351
357
|
// Don't forget to remove created handlers.
|
|
352
|
-
|
|
358
|
+
ve,
|
|
353
359
|
// Add "resize" event listener to make sure, we always have fresh viewport information.
|
|
354
360
|
// Desktop version of Telegram is sometimes not sending the viewport_changed
|
|
355
361
|
// event. For example, when the MainButton is shown. That's why we should
|
|
356
362
|
// add our own listener to make sure, viewport information is always fresh.
|
|
357
363
|
// Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/10
|
|
358
364
|
tt("resize", () => {
|
|
359
|
-
|
|
365
|
+
t.emit("viewport_changed", {
|
|
360
366
|
width: window.innerWidth,
|
|
361
367
|
height: window.innerHeight,
|
|
362
368
|
is_state_stable: !0,
|
|
@@ -365,69 +371,80 @@ function Re() {
|
|
|
365
371
|
}),
|
|
366
372
|
// Add listener, which handles events sent from the Telegram web application and also events
|
|
367
373
|
// generated by the local emitEvent function.
|
|
368
|
-
tt("message", (
|
|
369
|
-
if (
|
|
374
|
+
tt("message", (n) => {
|
|
375
|
+
if (n.source !== window.parent)
|
|
370
376
|
return;
|
|
371
|
-
let
|
|
377
|
+
let r;
|
|
372
378
|
try {
|
|
373
|
-
|
|
379
|
+
r = be(n.data);
|
|
374
380
|
} catch {
|
|
375
381
|
return;
|
|
376
382
|
}
|
|
377
|
-
const { eventType:
|
|
383
|
+
const { eventType: i, eventData: o } = r, a = Pe[i];
|
|
378
384
|
try {
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
} catch (
|
|
385
|
+
const u = a ? a.parse(o) : o;
|
|
386
|
+
t.emit(...u ? [i, u] : [i]);
|
|
387
|
+
} catch (u) {
|
|
382
388
|
st.error(
|
|
383
|
-
`An error occurred processing the "${
|
|
384
|
-
|
|
385
|
-
|
|
389
|
+
`An error occurred processing the "${i}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
|
|
390
|
+
r,
|
|
391
|
+
u
|
|
386
392
|
);
|
|
387
393
|
}
|
|
388
394
|
}),
|
|
389
|
-
// Clear
|
|
390
|
-
() => e.clear()
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
+
// Clear emitters.
|
|
396
|
+
() => e.clear(),
|
|
397
|
+
() => t.clear()
|
|
398
|
+
);
|
|
399
|
+
return [{
|
|
400
|
+
on: t.on.bind(t),
|
|
401
|
+
off: t.off.bind(t),
|
|
402
|
+
subscribe(n) {
|
|
403
|
+
return e.on("event", n);
|
|
404
|
+
},
|
|
405
|
+
unsubscribe(n) {
|
|
406
|
+
e.off("event", n);
|
|
407
|
+
},
|
|
408
|
+
get count() {
|
|
409
|
+
return t.count + e.count;
|
|
410
|
+
}
|
|
411
|
+
}, s];
|
|
395
412
|
}
|
|
396
413
|
const [xe, Ce] = yt(
|
|
397
414
|
(e) => {
|
|
398
415
|
const [t, s] = Re(), n = t.off.bind(t);
|
|
399
416
|
return t.off = (r, i) => {
|
|
400
|
-
const { count:
|
|
401
|
-
n(r, i),
|
|
417
|
+
const { count: o } = t;
|
|
418
|
+
n(r, i), o && !t.count && e();
|
|
402
419
|
}, [t, s];
|
|
403
420
|
},
|
|
404
421
|
([, e]) => e()
|
|
405
422
|
);
|
|
406
|
-
function
|
|
423
|
+
function j() {
|
|
407
424
|
return xe()[0];
|
|
408
425
|
}
|
|
409
426
|
function z(e, t) {
|
|
410
|
-
|
|
427
|
+
j().off(e, t);
|
|
411
428
|
}
|
|
412
429
|
function E(e, t, s) {
|
|
413
|
-
return
|
|
430
|
+
return j().on(e, t, s);
|
|
414
431
|
}
|
|
415
|
-
function
|
|
432
|
+
function V(e) {
|
|
416
433
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
417
434
|
}
|
|
418
435
|
function Se(e, t) {
|
|
419
436
|
const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
|
|
420
437
|
for (let i = 0; i < r; i += 1) {
|
|
421
|
-
const
|
|
422
|
-
if (
|
|
423
|
-
return
|
|
438
|
+
const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
|
|
439
|
+
if (o !== a)
|
|
440
|
+
return o > a ? 1 : -1;
|
|
424
441
|
}
|
|
425
442
|
return 0;
|
|
426
443
|
}
|
|
427
444
|
function y(e, t) {
|
|
428
445
|
return Se(e, t) <= 0;
|
|
429
446
|
}
|
|
430
|
-
function
|
|
447
|
+
function C(e, t, s) {
|
|
431
448
|
if (typeof s == "string") {
|
|
432
449
|
if (e === "web_app_open_link" && t === "try_instant_view")
|
|
433
450
|
return y("6.4", s);
|
|
@@ -479,30 +496,30 @@ function S(e, t, s) {
|
|
|
479
496
|
}
|
|
480
497
|
}
|
|
481
498
|
function Te(e) {
|
|
482
|
-
return "external" in e &&
|
|
499
|
+
return "external" in e && V(e.external) && "notify" in e.external && typeof e.external.notify == "function";
|
|
483
500
|
}
|
|
484
|
-
function
|
|
485
|
-
return "TelegramWebviewProxy" in e &&
|
|
501
|
+
function Tt(e) {
|
|
502
|
+
return "TelegramWebviewProxy" in e && V(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
|
|
486
503
|
}
|
|
487
|
-
function
|
|
504
|
+
function At() {
|
|
488
505
|
try {
|
|
489
506
|
return window.self !== window.top;
|
|
490
507
|
} catch {
|
|
491
508
|
return !0;
|
|
492
509
|
}
|
|
493
510
|
}
|
|
494
|
-
let
|
|
495
|
-
function
|
|
496
|
-
|
|
511
|
+
let It = "https://web.telegram.org";
|
|
512
|
+
function gn(e) {
|
|
513
|
+
It = e;
|
|
497
514
|
}
|
|
498
515
|
function Ae() {
|
|
499
|
-
return
|
|
516
|
+
return It;
|
|
500
517
|
}
|
|
501
|
-
function
|
|
518
|
+
function B(e, t, s) {
|
|
502
519
|
let n = {}, r;
|
|
503
520
|
t === void 0 && s === void 0 ? n = {} : t !== void 0 && s !== void 0 ? (n = s, r = t) : t !== void 0 && ("targetOrigin" in t ? n = t : r = t);
|
|
504
521
|
const { targetOrigin: i = Ae() } = n;
|
|
505
|
-
if (
|
|
522
|
+
if (ce("Posting event:", r ? { event: e, data: r } : { event: e }), At()) {
|
|
506
523
|
window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
|
|
507
524
|
return;
|
|
508
525
|
}
|
|
@@ -510,42 +527,42 @@ function N(e, t, s) {
|
|
|
510
527
|
window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
|
|
511
528
|
return;
|
|
512
529
|
}
|
|
513
|
-
if (
|
|
530
|
+
if (Tt(window)) {
|
|
514
531
|
window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
|
|
515
532
|
return;
|
|
516
533
|
}
|
|
517
534
|
throw m(
|
|
518
|
-
|
|
535
|
+
ue,
|
|
519
536
|
"Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside of Telegram application environment."
|
|
520
537
|
);
|
|
521
538
|
}
|
|
522
|
-
function
|
|
539
|
+
function Ie(e) {
|
|
523
540
|
return (t, s) => {
|
|
524
|
-
if (!
|
|
525
|
-
throw m(
|
|
526
|
-
if (
|
|
541
|
+
if (!C(t, e))
|
|
542
|
+
throw m(he, `Method "${t}" is unsupported in Mini Apps version ${e}`);
|
|
543
|
+
if (V(s)) {
|
|
527
544
|
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 && !
|
|
545
|
+
if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !C(t, n, e))
|
|
529
546
|
throw m(
|
|
530
|
-
|
|
547
|
+
pe,
|
|
531
548
|
`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
|
|
532
549
|
);
|
|
533
550
|
}
|
|
534
|
-
return
|
|
551
|
+
return B(t, s);
|
|
535
552
|
};
|
|
536
553
|
}
|
|
537
554
|
function kt(e) {
|
|
538
555
|
return ({ req_id: t }) => t === e;
|
|
539
556
|
}
|
|
540
|
-
function
|
|
541
|
-
return m(
|
|
557
|
+
function qt(e) {
|
|
558
|
+
return m(de, `Timeout reached: ${e}ms`);
|
|
542
559
|
}
|
|
543
560
|
function Ot(e, t) {
|
|
544
561
|
return Promise.race([
|
|
545
562
|
typeof e == "function" ? e() : e,
|
|
546
563
|
new Promise((s, n) => {
|
|
547
564
|
setTimeout(() => {
|
|
548
|
-
n(
|
|
565
|
+
n(qt(t));
|
|
549
566
|
}, t);
|
|
550
567
|
})
|
|
551
568
|
]);
|
|
@@ -558,18 +575,18 @@ async function w(e) {
|
|
|
558
575
|
method: n,
|
|
559
576
|
event: r,
|
|
560
577
|
capture: i,
|
|
561
|
-
postEvent:
|
|
562
|
-
timeout:
|
|
578
|
+
postEvent: o = B,
|
|
579
|
+
timeout: a
|
|
563
580
|
} = e, u = (Array.isArray(r) ? r : [r]).map(
|
|
564
581
|
(h) => E(h, (v) => (!i || i(v)) && t(v))
|
|
565
582
|
);
|
|
566
583
|
try {
|
|
567
|
-
return
|
|
584
|
+
return o(n, e.params), await (a ? Ot(s, a) : s);
|
|
568
585
|
} finally {
|
|
569
586
|
u.forEach((h) => h());
|
|
570
587
|
}
|
|
571
588
|
}
|
|
572
|
-
async function
|
|
589
|
+
async function O(e, t, s, n = {}) {
|
|
573
590
|
const {
|
|
574
591
|
result: r,
|
|
575
592
|
error: i
|
|
@@ -585,27 +602,27 @@ async function q(e, t, s, n = {}) {
|
|
|
585
602
|
capture: kt(s)
|
|
586
603
|
});
|
|
587
604
|
if (i)
|
|
588
|
-
throw m(
|
|
605
|
+
throw m(le, i);
|
|
589
606
|
return r;
|
|
590
607
|
}
|
|
591
608
|
function et(...e) {
|
|
592
609
|
return e.map((t) => {
|
|
593
610
|
if (typeof t == "string")
|
|
594
611
|
return t;
|
|
595
|
-
if (
|
|
612
|
+
if (V(t))
|
|
596
613
|
return et(Object.entries(t).map((s) => s[1] && s[0]));
|
|
597
614
|
if (Array.isArray(t))
|
|
598
615
|
return et(...t);
|
|
599
616
|
}).filter(Boolean).join(" ");
|
|
600
617
|
}
|
|
601
|
-
function
|
|
602
|
-
return e.reduce((t, s) => (
|
|
618
|
+
function wn(...e) {
|
|
619
|
+
return e.reduce((t, s) => (V(s) && Object.entries(s).forEach(([n, r]) => {
|
|
603
620
|
const i = et(t[n], r);
|
|
604
621
|
i.length && (t[n] = i);
|
|
605
622
|
}), t), {});
|
|
606
623
|
}
|
|
607
|
-
function
|
|
608
|
-
const t =
|
|
624
|
+
function Dt(e) {
|
|
625
|
+
const t = Ct(e);
|
|
609
626
|
return Math.sqrt(
|
|
610
627
|
[0.299, 0.587, 0.114].reduce((s, n, r) => {
|
|
611
628
|
const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
|
|
@@ -613,9 +630,9 @@ function qt(e) {
|
|
|
613
630
|
}, 0)
|
|
614
631
|
) < 120;
|
|
615
632
|
}
|
|
616
|
-
class
|
|
633
|
+
class ke {
|
|
617
634
|
constructor(t) {
|
|
618
|
-
c(this, "ee", new
|
|
635
|
+
c(this, "ee", new N()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
|
|
619
636
|
}
|
|
620
637
|
/**
|
|
621
638
|
* Clones current state and returns its copy.
|
|
@@ -636,18 +653,18 @@ class Ie {
|
|
|
636
653
|
}
|
|
637
654
|
class it {
|
|
638
655
|
constructor(t) {
|
|
639
|
-
c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new
|
|
656
|
+
c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new ke(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
657
|
}
|
|
641
658
|
}
|
|
642
|
-
function
|
|
643
|
-
return (s) =>
|
|
659
|
+
function Nt(e, t) {
|
|
660
|
+
return (s) => C(t[s], e);
|
|
644
661
|
}
|
|
645
662
|
class ot extends it {
|
|
646
663
|
constructor(t, s, n) {
|
|
647
|
-
super(t), c(this, "supports"), this.supports =
|
|
664
|
+
super(t), c(this, "supports"), this.supports = Nt(s, n);
|
|
648
665
|
}
|
|
649
666
|
}
|
|
650
|
-
class
|
|
667
|
+
class qe extends ot {
|
|
651
668
|
constructor(t, s, n) {
|
|
652
669
|
super({ isVisible: t }, s, {
|
|
653
670
|
show: "web_app_setup_back_button",
|
|
@@ -676,19 +693,19 @@ class Oe extends ot {
|
|
|
676
693
|
this.isVisible = !0;
|
|
677
694
|
}
|
|
678
695
|
}
|
|
679
|
-
const
|
|
696
|
+
const Bt = A((e) => e instanceof Date ? e : new Date(x().parse(e) * 1e3), "Date");
|
|
680
697
|
function at(e, t) {
|
|
681
|
-
return new
|
|
698
|
+
return new G((s) => {
|
|
682
699
|
if (typeof s != "string" && !(s instanceof URLSearchParams))
|
|
683
700
|
throw T();
|
|
684
701
|
const n = typeof s == "string" ? new URLSearchParams(s) : s;
|
|
685
|
-
return
|
|
702
|
+
return xt(e, (r) => {
|
|
686
703
|
const i = n.get(r);
|
|
687
704
|
return i === null ? void 0 : i;
|
|
688
705
|
});
|
|
689
706
|
}, !1, t);
|
|
690
707
|
}
|
|
691
|
-
const
|
|
708
|
+
const Oe = g({
|
|
692
709
|
id: x(),
|
|
693
710
|
type: p(),
|
|
694
711
|
title: p(),
|
|
@@ -733,17 +750,17 @@ const qe = g({
|
|
|
733
750
|
},
|
|
734
751
|
username: p().optional()
|
|
735
752
|
}, "User").optional();
|
|
736
|
-
function
|
|
753
|
+
function Mt() {
|
|
737
754
|
return at({
|
|
738
755
|
authDate: {
|
|
739
|
-
type:
|
|
756
|
+
type: Bt(),
|
|
740
757
|
from: "auth_date"
|
|
741
758
|
},
|
|
742
759
|
canSendAfter: {
|
|
743
760
|
type: x().optional(),
|
|
744
761
|
from: "can_send_after"
|
|
745
762
|
},
|
|
746
|
-
chat:
|
|
763
|
+
chat: Oe,
|
|
747
764
|
chatInstance: {
|
|
748
765
|
type: p().optional(),
|
|
749
766
|
from: "chat_instance"
|
|
@@ -771,21 +788,21 @@ function De(e) {
|
|
|
771
788
|
function Ne(e) {
|
|
772
789
|
return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
|
|
773
790
|
}
|
|
774
|
-
const
|
|
791
|
+
const Vt = A(
|
|
775
792
|
(e) => {
|
|
776
|
-
const t =
|
|
793
|
+
const t = St().optional();
|
|
777
794
|
return Object.entries(nt(e)).reduce((s, [n, r]) => (s[De(n)] = t.parse(r), s), {});
|
|
778
795
|
},
|
|
779
796
|
"ThemeParams"
|
|
780
797
|
);
|
|
781
|
-
function
|
|
798
|
+
function $t(e) {
|
|
782
799
|
return at({
|
|
783
800
|
botInline: {
|
|
784
801
|
type: P().optional(),
|
|
785
802
|
from: "tgWebAppBotInline"
|
|
786
803
|
},
|
|
787
804
|
initData: {
|
|
788
|
-
type:
|
|
805
|
+
type: Mt().optional(),
|
|
789
806
|
from: "tgWebAppData"
|
|
790
807
|
},
|
|
791
808
|
initDataRaw: {
|
|
@@ -805,7 +822,7 @@ function Vt(e) {
|
|
|
805
822
|
from: "tgWebAppStartParam"
|
|
806
823
|
},
|
|
807
824
|
themeParams: {
|
|
808
|
-
type:
|
|
825
|
+
type: Vt(),
|
|
809
826
|
from: "tgWebAppThemeParams"
|
|
810
827
|
},
|
|
811
828
|
version: {
|
|
@@ -814,30 +831,30 @@ function Vt(e) {
|
|
|
814
831
|
}
|
|
815
832
|
}).parse(e);
|
|
816
833
|
}
|
|
817
|
-
function
|
|
818
|
-
return
|
|
834
|
+
function Lt(e) {
|
|
835
|
+
return $t(
|
|
819
836
|
e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
|
|
820
837
|
);
|
|
821
838
|
}
|
|
822
839
|
function Be() {
|
|
823
|
-
return
|
|
840
|
+
return Lt(window.location.href);
|
|
824
841
|
}
|
|
825
|
-
function
|
|
842
|
+
function Ht() {
|
|
826
843
|
return performance.getEntriesByType("navigation")[0];
|
|
827
844
|
}
|
|
828
845
|
function Me() {
|
|
829
|
-
const e =
|
|
846
|
+
const e = Ht();
|
|
830
847
|
if (!e)
|
|
831
848
|
throw new Error("Unable to get first navigation entry.");
|
|
832
|
-
return
|
|
849
|
+
return Lt(e.name);
|
|
833
850
|
}
|
|
834
851
|
function Ut(e) {
|
|
835
852
|
return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
|
|
836
853
|
}
|
|
837
|
-
function
|
|
854
|
+
function Wt(e, t) {
|
|
838
855
|
sessionStorage.setItem(Ut(e), JSON.stringify(t));
|
|
839
856
|
}
|
|
840
|
-
function
|
|
857
|
+
function Gt(e) {
|
|
841
858
|
const t = sessionStorage.getItem(Ut(e));
|
|
842
859
|
try {
|
|
843
860
|
return t ? JSON.parse(t) : void 0;
|
|
@@ -845,7 +862,7 @@ function Wt(e) {
|
|
|
845
862
|
}
|
|
846
863
|
}
|
|
847
864
|
function Ve() {
|
|
848
|
-
return
|
|
865
|
+
return $t(Gt("launchParams") || "");
|
|
849
866
|
}
|
|
850
867
|
function $e(e) {
|
|
851
868
|
return JSON.stringify(
|
|
@@ -861,13 +878,13 @@ function Le(e) {
|
|
|
861
878
|
platform: n,
|
|
862
879
|
version: r,
|
|
863
880
|
showSettings: i,
|
|
864
|
-
startParam:
|
|
865
|
-
botInline:
|
|
881
|
+
startParam: o,
|
|
882
|
+
botInline: a
|
|
866
883
|
} = e, u = new URLSearchParams();
|
|
867
|
-
return u.set("tgWebAppPlatform", n), u.set("tgWebAppThemeParams", $e(s)), u.set("tgWebAppVersion", r), t && u.set("tgWebAppData", t),
|
|
884
|
+
return u.set("tgWebAppPlatform", n), u.set("tgWebAppThemeParams", $e(s)), u.set("tgWebAppVersion", r), t && u.set("tgWebAppData", t), o && u.set("tgWebAppStartParam", o), typeof i == "boolean" && u.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && u.set("tgWebAppBotInline", a ? "1" : "0"), u.toString();
|
|
868
885
|
}
|
|
869
|
-
function
|
|
870
|
-
|
|
886
|
+
function He(e) {
|
|
887
|
+
Wt("launchParams", Le(e));
|
|
871
888
|
}
|
|
872
889
|
function jt() {
|
|
873
890
|
for (const e of [
|
|
@@ -881,54 +898,43 @@ function jt() {
|
|
|
881
898
|
])
|
|
882
899
|
try {
|
|
883
900
|
const t = e();
|
|
884
|
-
return
|
|
901
|
+
return He(t), t;
|
|
885
902
|
} catch {
|
|
886
903
|
}
|
|
887
904
|
throw new Error("Unable to retrieve launch parameters from any known source.");
|
|
888
905
|
}
|
|
889
|
-
function
|
|
890
|
-
const e =
|
|
906
|
+
function zt() {
|
|
907
|
+
const e = Ht();
|
|
891
908
|
return !!(e && e.type === "reload");
|
|
892
909
|
}
|
|
893
|
-
function
|
|
910
|
+
function Ue() {
|
|
894
911
|
let e = 0;
|
|
895
912
|
return () => (e += 1).toString();
|
|
896
913
|
}
|
|
897
|
-
|
|
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);
|
|
914
|
+
const [We] = yt(Ue);
|
|
909
915
|
function l(e, t) {
|
|
910
916
|
return () => {
|
|
911
917
|
const s = jt(), n = {
|
|
912
918
|
...s,
|
|
913
|
-
postEvent:
|
|
914
|
-
createRequestId:
|
|
919
|
+
postEvent: Ie(s.version),
|
|
920
|
+
createRequestId: We()
|
|
915
921
|
};
|
|
916
922
|
if (typeof e == "function")
|
|
917
923
|
return e(n);
|
|
918
|
-
const [r, i,
|
|
924
|
+
const [r, i, o] = Pt(), a = t({
|
|
919
925
|
...n,
|
|
920
926
|
// State should only be passed only in case, current page was reloaded. If we don't add
|
|
921
927
|
// this check, state restoration will work improperly in the web version of Telegram,
|
|
922
928
|
// when we are always working in the same "session" (tab).
|
|
923
|
-
state:
|
|
929
|
+
state: zt() ? Gt(e) : void 0,
|
|
924
930
|
addCleanup: r
|
|
925
|
-
}), u = (h) => (
|
|
931
|
+
}), u = (h) => (o || r(
|
|
926
932
|
h.on("change", (v) => {
|
|
927
|
-
|
|
933
|
+
Wt(e, v);
|
|
928
934
|
})
|
|
929
935
|
), h);
|
|
930
936
|
return [
|
|
931
|
-
|
|
937
|
+
a instanceof Promise ? a.then(u) : u(a),
|
|
932
938
|
i
|
|
933
939
|
];
|
|
934
940
|
};
|
|
@@ -937,13 +943,13 @@ const Ge = l("backButton", ({
|
|
|
937
943
|
postEvent: e,
|
|
938
944
|
version: t,
|
|
939
945
|
state: s = { isVisible: !1 }
|
|
940
|
-
}) => new
|
|
941
|
-
class
|
|
946
|
+
}) => new qe(s.isVisible, t, e));
|
|
947
|
+
class $ extends ot {
|
|
942
948
|
constructor() {
|
|
943
949
|
super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
|
|
944
950
|
}
|
|
945
951
|
}
|
|
946
|
-
function
|
|
952
|
+
function Kt(e) {
|
|
947
953
|
const t = e.available ? e : {
|
|
948
954
|
available: !1,
|
|
949
955
|
device_id: "",
|
|
@@ -961,7 +967,7 @@ function zt(e) {
|
|
|
961
967
|
accessGranted: t.access_granted
|
|
962
968
|
};
|
|
963
969
|
}
|
|
964
|
-
class
|
|
970
|
+
class je extends $ {
|
|
965
971
|
constructor({ postEvent: t, version: s, ...n }) {
|
|
966
972
|
super(n, s, {
|
|
967
973
|
auth: "web_app_biometry_request_auth",
|
|
@@ -1039,7 +1045,7 @@ class ze extends V {
|
|
|
1039
1045
|
event: "biometry_info_received",
|
|
1040
1046
|
params: { reason: t || "" }
|
|
1041
1047
|
}).then((n) => {
|
|
1042
|
-
const r =
|
|
1048
|
+
const r = Kt(n);
|
|
1043
1049
|
return this.set(r), r.accessGranted;
|
|
1044
1050
|
}).finally(() => this.accessPromise = void 0)), this.accessPromise;
|
|
1045
1051
|
}
|
|
@@ -1071,8 +1077,8 @@ class ze extends V {
|
|
|
1071
1077
|
);
|
|
1072
1078
|
}
|
|
1073
1079
|
}
|
|
1074
|
-
async function
|
|
1075
|
-
return
|
|
1080
|
+
async function ze(e) {
|
|
1081
|
+
return Kt(
|
|
1076
1082
|
await w({
|
|
1077
1083
|
...e || {},
|
|
1078
1084
|
method: "web_app_biometry_get_info",
|
|
@@ -1080,10 +1086,16 @@ async function Ke(e) {
|
|
|
1080
1086
|
})
|
|
1081
1087
|
);
|
|
1082
1088
|
}
|
|
1083
|
-
const
|
|
1089
|
+
const Ke = l(
|
|
1084
1090
|
"biometryManager",
|
|
1085
|
-
async ({ postEvent: e, version: t, state: s }) => new
|
|
1086
|
-
...s || await
|
|
1091
|
+
async ({ postEvent: e, version: t, state: s }) => new je({
|
|
1092
|
+
...s || C("web_app_biometry_get_info", t) ? s || await ze({ timeout: 1e3 }) : {
|
|
1093
|
+
available: !1,
|
|
1094
|
+
accessGranted: !1,
|
|
1095
|
+
accessRequested: !1,
|
|
1096
|
+
tokenSaved: !1,
|
|
1097
|
+
deviceId: ""
|
|
1098
|
+
},
|
|
1087
1099
|
version: t,
|
|
1088
1100
|
postEvent: e
|
|
1089
1101
|
})
|
|
@@ -1093,7 +1105,7 @@ class ct extends it {
|
|
|
1093
1105
|
super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
|
|
1094
1106
|
}
|
|
1095
1107
|
}
|
|
1096
|
-
class
|
|
1108
|
+
class Je extends ct {
|
|
1097
1109
|
constructor(t, s) {
|
|
1098
1110
|
super({ isConfirmationNeeded: t }), this.postEvent = s;
|
|
1099
1111
|
}
|
|
@@ -1125,14 +1137,14 @@ const Fe = l(
|
|
|
1125
1137
|
({
|
|
1126
1138
|
postEvent: e,
|
|
1127
1139
|
state: t = { isConfirmationNeeded: !1 }
|
|
1128
|
-
}) => new
|
|
1140
|
+
}) => new Je(t.isConfirmationNeeded, e)
|
|
1129
1141
|
);
|
|
1130
1142
|
class ht {
|
|
1131
1143
|
constructor(t, s) {
|
|
1132
|
-
c(this, "supports"), this.supports =
|
|
1144
|
+
c(this, "supports"), this.supports = Nt(t, s);
|
|
1133
1145
|
}
|
|
1134
1146
|
}
|
|
1135
|
-
function
|
|
1147
|
+
function Qe(e) {
|
|
1136
1148
|
if (Array.isArray(e))
|
|
1137
1149
|
return e;
|
|
1138
1150
|
if (typeof e == "string")
|
|
@@ -1144,9 +1156,9 @@ function Ye(e) {
|
|
|
1144
1156
|
}
|
|
1145
1157
|
throw T();
|
|
1146
1158
|
}
|
|
1147
|
-
class
|
|
1159
|
+
class Ye extends G {
|
|
1148
1160
|
constructor(t, s, n) {
|
|
1149
|
-
super(
|
|
1161
|
+
super(Qe, s, n), c(this, "itemParser"), this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
|
|
1150
1162
|
}
|
|
1151
1163
|
/**
|
|
1152
1164
|
* Attempts to parse passed value
|
|
@@ -1162,13 +1174,13 @@ class Ze extends j {
|
|
|
1162
1174
|
return this.itemParser = typeof t == "function" ? t : t.parse.bind(t), this;
|
|
1163
1175
|
}
|
|
1164
1176
|
}
|
|
1165
|
-
function
|
|
1166
|
-
return new
|
|
1177
|
+
function Ze(e) {
|
|
1178
|
+
return new Ye((t) => t, !1, e);
|
|
1167
1179
|
}
|
|
1168
1180
|
function wt(e, t) {
|
|
1169
1181
|
return Object.fromEntries(e.map((s) => [s, t]));
|
|
1170
1182
|
}
|
|
1171
|
-
class
|
|
1183
|
+
class Xe extends ht {
|
|
1172
1184
|
constructor(t, s, n) {
|
|
1173
1185
|
super(t, {
|
|
1174
1186
|
delete: "web_app_invoke_custom_method",
|
|
@@ -1184,7 +1196,7 @@ class ts extends ht {
|
|
|
1184
1196
|
*/
|
|
1185
1197
|
async delete(t, s = {}) {
|
|
1186
1198
|
const n = Array.isArray(t) ? t : [t];
|
|
1187
|
-
n.length && await
|
|
1199
|
+
n.length && await O(
|
|
1188
1200
|
"deleteStorageValues",
|
|
1189
1201
|
{ keys: n },
|
|
1190
1202
|
this.createRequestId(),
|
|
@@ -1196,8 +1208,8 @@ class ts extends ht {
|
|
|
1196
1208
|
* @param options - request execution options.
|
|
1197
1209
|
*/
|
|
1198
1210
|
async getKeys(t = {}) {
|
|
1199
|
-
return
|
|
1200
|
-
await
|
|
1211
|
+
return Ze().of(p()).parse(
|
|
1212
|
+
await O(
|
|
1201
1213
|
"getStorageKeys",
|
|
1202
1214
|
{},
|
|
1203
1215
|
this.createRequestId(),
|
|
@@ -1209,7 +1221,7 @@ class ts extends ht {
|
|
|
1209
1221
|
const n = Array.isArray(t) ? t : [t];
|
|
1210
1222
|
if (!n.length)
|
|
1211
1223
|
return wt(n, "");
|
|
1212
|
-
const r = await
|
|
1224
|
+
const r = await O(
|
|
1213
1225
|
"getStorageValues",
|
|
1214
1226
|
{ keys: n },
|
|
1215
1227
|
this.createRequestId(),
|
|
@@ -1224,7 +1236,7 @@ class ts extends ht {
|
|
|
1224
1236
|
* @param options - request execution options.
|
|
1225
1237
|
*/
|
|
1226
1238
|
async set(t, s, n = {}) {
|
|
1227
|
-
await
|
|
1239
|
+
await O(
|
|
1228
1240
|
"saveStorageValue",
|
|
1229
1241
|
{ key: t, value: s },
|
|
1230
1242
|
this.createRequestId(),
|
|
@@ -1232,10 +1244,10 @@ class ts extends ht {
|
|
|
1232
1244
|
);
|
|
1233
1245
|
}
|
|
1234
1246
|
}
|
|
1235
|
-
const
|
|
1236
|
-
({ createRequestId: e, postEvent: t, version: s }) => new
|
|
1247
|
+
const ts = l(
|
|
1248
|
+
({ createRequestId: e, postEvent: t, version: s }) => new Xe(s, e, t)
|
|
1237
1249
|
);
|
|
1238
|
-
class
|
|
1250
|
+
class es extends ht {
|
|
1239
1251
|
constructor(t, s) {
|
|
1240
1252
|
super(t, {
|
|
1241
1253
|
impactOccurred: "web_app_trigger_haptic_feedback",
|
|
@@ -1277,10 +1289,10 @@ class ss extends ht {
|
|
|
1277
1289
|
this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
|
|
1278
1290
|
}
|
|
1279
1291
|
}
|
|
1280
|
-
const
|
|
1281
|
-
({ version: e, postEvent: t }) => new
|
|
1292
|
+
const ss = l(
|
|
1293
|
+
({ version: e, postEvent: t }) => new es(e, t)
|
|
1282
1294
|
);
|
|
1283
|
-
class
|
|
1295
|
+
class ns {
|
|
1284
1296
|
constructor(t) {
|
|
1285
1297
|
this.initData = t;
|
|
1286
1298
|
}
|
|
@@ -1353,13 +1365,13 @@ class rs {
|
|
|
1353
1365
|
return this.initData.user;
|
|
1354
1366
|
}
|
|
1355
1367
|
}
|
|
1356
|
-
const
|
|
1357
|
-
({ initData: e }) => e ? new
|
|
1368
|
+
const rs = l(
|
|
1369
|
+
({ initData: e }) => e ? new ns(e) : void 0
|
|
1358
1370
|
);
|
|
1359
|
-
function
|
|
1360
|
-
return
|
|
1371
|
+
function fn(e) {
|
|
1372
|
+
return Mt().parse(e);
|
|
1361
1373
|
}
|
|
1362
|
-
class
|
|
1374
|
+
class is extends $ {
|
|
1363
1375
|
constructor(t, s, n) {
|
|
1364
1376
|
super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
|
|
1365
1377
|
}
|
|
@@ -1382,10 +1394,10 @@ class os extends V {
|
|
|
1382
1394
|
const { hostname: r, pathname: i } = new URL(t, window.location.href);
|
|
1383
1395
|
if (r !== "t.me")
|
|
1384
1396
|
throw new Error(`Incorrect hostname: ${r}`);
|
|
1385
|
-
const
|
|
1386
|
-
if (!
|
|
1397
|
+
const o = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
|
|
1398
|
+
if (!o)
|
|
1387
1399
|
throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
|
|
1388
|
-
[, , n] =
|
|
1400
|
+
[, , n] = o;
|
|
1389
1401
|
}
|
|
1390
1402
|
this.isOpened = !0;
|
|
1391
1403
|
try {
|
|
@@ -1403,13 +1415,19 @@ class os extends V {
|
|
|
1403
1415
|
}
|
|
1404
1416
|
}
|
|
1405
1417
|
}
|
|
1406
|
-
const
|
|
1407
|
-
({ version: e, postEvent: t }) => new
|
|
1418
|
+
const os = l(
|
|
1419
|
+
({ version: e, postEvent: t }) => new is(!1, e, t)
|
|
1408
1420
|
);
|
|
1409
|
-
class
|
|
1421
|
+
class as extends it {
|
|
1410
1422
|
constructor({ postEvent: t, ...s }) {
|
|
1411
1423
|
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;
|
|
1412
1424
|
}
|
|
1425
|
+
/**
|
|
1426
|
+
* The MainButton background color.
|
|
1427
|
+
*/
|
|
1428
|
+
get bgColor() {
|
|
1429
|
+
return this.get("bgColor");
|
|
1430
|
+
}
|
|
1413
1431
|
/**
|
|
1414
1432
|
* Sends current local state to the Telegram application.
|
|
1415
1433
|
*/
|
|
@@ -1419,10 +1437,35 @@ class cs extends it {
|
|
|
1419
1437
|
is_active: this.isEnabled,
|
|
1420
1438
|
is_progress_visible: this.isLoaderVisible,
|
|
1421
1439
|
text: this.text,
|
|
1422
|
-
color: this.
|
|
1440
|
+
color: this.bgColor,
|
|
1423
1441
|
text_color: this.textColor
|
|
1424
1442
|
});
|
|
1425
1443
|
}
|
|
1444
|
+
/**
|
|
1445
|
+
* Disables the MainButton.
|
|
1446
|
+
* @see Does not work on Android: https://github.com/Telegram-Mini-Apps/issues/issues/1
|
|
1447
|
+
*/
|
|
1448
|
+
disable() {
|
|
1449
|
+
return this.isEnabled = !1, this;
|
|
1450
|
+
}
|
|
1451
|
+
/**
|
|
1452
|
+
* Enables the MainButton.
|
|
1453
|
+
*/
|
|
1454
|
+
enable() {
|
|
1455
|
+
return this.isEnabled = !0, this;
|
|
1456
|
+
}
|
|
1457
|
+
/**
|
|
1458
|
+
* Hides the MainButton.
|
|
1459
|
+
*/
|
|
1460
|
+
hide() {
|
|
1461
|
+
return this.isVisible = !1, this;
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* Hides the MainButton loading indicator.
|
|
1465
|
+
*/
|
|
1466
|
+
hideLoader() {
|
|
1467
|
+
return this.isLoaderVisible = !1, this;
|
|
1468
|
+
}
|
|
1426
1469
|
set isEnabled(t) {
|
|
1427
1470
|
this.setParams({ isEnabled: t });
|
|
1428
1471
|
}
|
|
@@ -1450,49 +1493,6 @@ class cs extends it {
|
|
|
1450
1493
|
get isVisible() {
|
|
1451
1494
|
return this.get("isVisible");
|
|
1452
1495
|
}
|
|
1453
|
-
/**
|
|
1454
|
-
* The MainButton background color.
|
|
1455
|
-
*/
|
|
1456
|
-
get backgroundColor() {
|
|
1457
|
-
return this.get("backgroundColor");
|
|
1458
|
-
}
|
|
1459
|
-
/**
|
|
1460
|
-
* The MainButton text.
|
|
1461
|
-
*/
|
|
1462
|
-
get text() {
|
|
1463
|
-
return this.get("text");
|
|
1464
|
-
}
|
|
1465
|
-
/**
|
|
1466
|
-
* The MainButton text color.
|
|
1467
|
-
*/
|
|
1468
|
-
get textColor() {
|
|
1469
|
-
return this.get("textColor");
|
|
1470
|
-
}
|
|
1471
|
-
/**
|
|
1472
|
-
* Disables the MainButton.
|
|
1473
|
-
* @see Does not work on Android: https://github.com/Telegram-Mini-Apps/issues/issues/1
|
|
1474
|
-
*/
|
|
1475
|
-
disable() {
|
|
1476
|
-
return this.isEnabled = !1, this;
|
|
1477
|
-
}
|
|
1478
|
-
/**
|
|
1479
|
-
* Enables the MainButton.
|
|
1480
|
-
*/
|
|
1481
|
-
enable() {
|
|
1482
|
-
return this.isEnabled = !0, this;
|
|
1483
|
-
}
|
|
1484
|
-
/**
|
|
1485
|
-
* Hides the MainButton.
|
|
1486
|
-
*/
|
|
1487
|
-
hide() {
|
|
1488
|
-
return this.isVisible = !1, this;
|
|
1489
|
-
}
|
|
1490
|
-
/**
|
|
1491
|
-
* Hides the MainButton loading indicator.
|
|
1492
|
-
*/
|
|
1493
|
-
hideLoader() {
|
|
1494
|
-
return this.isLoaderVisible = !1, this;
|
|
1495
|
-
}
|
|
1496
1496
|
/**
|
|
1497
1497
|
* Shows the MainButton.
|
|
1498
1498
|
*
|
|
@@ -1524,10 +1524,10 @@ class cs extends it {
|
|
|
1524
1524
|
}
|
|
1525
1525
|
/**
|
|
1526
1526
|
* Updates current Main Button color.
|
|
1527
|
-
* @param
|
|
1527
|
+
* @param bgColor - color to set.
|
|
1528
1528
|
*/
|
|
1529
|
-
|
|
1530
|
-
return this.setParams({
|
|
1529
|
+
setBgColor(t) {
|
|
1530
|
+
return this.setParams({ bgColor: t });
|
|
1531
1531
|
}
|
|
1532
1532
|
/**
|
|
1533
1533
|
* Allows setting multiple Main Button parameters.
|
|
@@ -1536,8 +1536,20 @@ class cs extends it {
|
|
|
1536
1536
|
setParams(t) {
|
|
1537
1537
|
return this.set(t), this.commit(), this;
|
|
1538
1538
|
}
|
|
1539
|
+
/**
|
|
1540
|
+
* The MainButton text.
|
|
1541
|
+
*/
|
|
1542
|
+
get text() {
|
|
1543
|
+
return this.get("text");
|
|
1544
|
+
}
|
|
1545
|
+
/**
|
|
1546
|
+
* The MainButton text color.
|
|
1547
|
+
*/
|
|
1548
|
+
get textColor() {
|
|
1549
|
+
return this.get("textColor");
|
|
1550
|
+
}
|
|
1539
1551
|
}
|
|
1540
|
-
const
|
|
1552
|
+
const cs = l(
|
|
1541
1553
|
"mainButton",
|
|
1542
1554
|
({
|
|
1543
1555
|
postEvent: e,
|
|
@@ -1548,11 +1560,11 @@ const hs = l(
|
|
|
1548
1560
|
text: "",
|
|
1549
1561
|
isLoaderVisible: !1,
|
|
1550
1562
|
textColor: t.buttonTextColor || "#ffffff",
|
|
1551
|
-
|
|
1563
|
+
bgColor: t.buttonColor || "#000000"
|
|
1552
1564
|
}
|
|
1553
|
-
}) => new
|
|
1565
|
+
}) => new as({ ...s, postEvent: e })
|
|
1554
1566
|
);
|
|
1555
|
-
function
|
|
1567
|
+
function hs() {
|
|
1556
1568
|
return at({
|
|
1557
1569
|
contact: g({
|
|
1558
1570
|
userId: {
|
|
@@ -1573,24 +1585,24 @@ function ps() {
|
|
|
1573
1585
|
}
|
|
1574
1586
|
}),
|
|
1575
1587
|
authDate: {
|
|
1576
|
-
type:
|
|
1588
|
+
type: Bt(),
|
|
1577
1589
|
from: "auth_date"
|
|
1578
1590
|
},
|
|
1579
1591
|
hash: p()
|
|
1580
1592
|
}, "RequestedContact");
|
|
1581
1593
|
}
|
|
1582
|
-
function
|
|
1594
|
+
function Jt(e, t) {
|
|
1583
1595
|
return (s) => {
|
|
1584
1596
|
const [n, r] = t[s];
|
|
1585
|
-
return
|
|
1597
|
+
return C(n, r, e);
|
|
1586
1598
|
};
|
|
1587
1599
|
}
|
|
1588
|
-
function
|
|
1600
|
+
function ps(e) {
|
|
1589
1601
|
return new Promise((t) => {
|
|
1590
1602
|
setTimeout(t, e);
|
|
1591
1603
|
});
|
|
1592
1604
|
}
|
|
1593
|
-
class
|
|
1605
|
+
class us extends $ {
|
|
1594
1606
|
constructor({ postEvent: t, createRequestId: s, version: n, botInline: r, ...i }) {
|
|
1595
1607
|
super(i, n, {
|
|
1596
1608
|
requestPhoneAccess: "web_app_request_phone",
|
|
@@ -1599,8 +1611,8 @@ class ls extends V {
|
|
|
1599
1611
|
setHeaderColor: "web_app_set_header_color",
|
|
1600
1612
|
setBackgroundColor: "web_app_set_background_color"
|
|
1601
1613
|
}), 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
|
|
1603
|
-
this.supports = (
|
|
1614
|
+
const o = this.supports.bind(this);
|
|
1615
|
+
this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Jt(n, {
|
|
1604
1616
|
"setHeaderColor.color": ["web_app_set_header_color", "color"]
|
|
1605
1617
|
});
|
|
1606
1618
|
}
|
|
@@ -1611,8 +1623,8 @@ class ls extends V {
|
|
|
1611
1623
|
async getRequestedContact({
|
|
1612
1624
|
timeout: t = 1e4
|
|
1613
1625
|
} = {}) {
|
|
1614
|
-
return
|
|
1615
|
-
await
|
|
1626
|
+
return hs().parse(
|
|
1627
|
+
await O(
|
|
1616
1628
|
"getRequestedContact",
|
|
1617
1629
|
{},
|
|
1618
1630
|
this.createRequestId(),
|
|
@@ -1651,7 +1663,7 @@ class ls extends V {
|
|
|
1651
1663
|
* True if current Mini App background color is recognized as dark.
|
|
1652
1664
|
*/
|
|
1653
1665
|
get isDark() {
|
|
1654
|
-
return
|
|
1666
|
+
return Dt(this.bgColor);
|
|
1655
1667
|
}
|
|
1656
1668
|
/**
|
|
1657
1669
|
* Informs the Telegram app that the Mini App is ready to be displayed.
|
|
@@ -1686,9 +1698,9 @@ class ls extends V {
|
|
|
1686
1698
|
return await this.getRequestedContact();
|
|
1687
1699
|
} catch {
|
|
1688
1700
|
}
|
|
1689
|
-
await
|
|
1701
|
+
await ps(n), n += 50;
|
|
1690
1702
|
}
|
|
1691
|
-
throw
|
|
1703
|
+
throw qt(t);
|
|
1692
1704
|
}, t);
|
|
1693
1705
|
}
|
|
1694
1706
|
/**
|
|
@@ -1771,7 +1783,7 @@ class ls extends V {
|
|
|
1771
1783
|
this.postEvent("web_app_switch_inline_query", { query: t, chat_types: s });
|
|
1772
1784
|
}
|
|
1773
1785
|
}
|
|
1774
|
-
const
|
|
1786
|
+
const ls = l(
|
|
1775
1787
|
"miniApp",
|
|
1776
1788
|
({
|
|
1777
1789
|
themeParams: e,
|
|
@@ -1781,9 +1793,9 @@ const ds = l(
|
|
|
1781
1793
|
headerColor: e.headerBgColor || "#000000"
|
|
1782
1794
|
},
|
|
1783
1795
|
...n
|
|
1784
|
-
}) => new
|
|
1796
|
+
}) => new us({ ...n, ...s, botInline: t })
|
|
1785
1797
|
);
|
|
1786
|
-
function
|
|
1798
|
+
function ds(e) {
|
|
1787
1799
|
const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
|
|
1788
1800
|
let r;
|
|
1789
1801
|
if (s.length > 64)
|
|
@@ -1793,21 +1805,21 @@ function _s(e) {
|
|
|
1793
1805
|
if (n.length > 3)
|
|
1794
1806
|
throw new Error(`Buttons have incorrect size: ${n.length}`);
|
|
1795
1807
|
return n.length ? r = n.map((i) => {
|
|
1796
|
-
const { id:
|
|
1797
|
-
if (
|
|
1798
|
-
throw new Error(`Button ID has incorrect size: ${
|
|
1808
|
+
const { id: o = "" } = i;
|
|
1809
|
+
if (o.length > 64)
|
|
1810
|
+
throw new Error(`Button ID has incorrect size: ${o}`);
|
|
1799
1811
|
if (!i.type || i.type === "default" || i.type === "destructive") {
|
|
1800
|
-
const
|
|
1801
|
-
if (!
|
|
1812
|
+
const a = i.text.trim();
|
|
1813
|
+
if (!a.length || a.length > 64) {
|
|
1802
1814
|
const u = i.type || "default";
|
|
1803
1815
|
throw new Error(`Button text with type "${u}" has incorrect size: ${i.text.length}`);
|
|
1804
1816
|
}
|
|
1805
|
-
return { ...i, text:
|
|
1817
|
+
return { ...i, text: a, id: o };
|
|
1806
1818
|
}
|
|
1807
|
-
return { ...i, id:
|
|
1819
|
+
return { ...i, id: o };
|
|
1808
1820
|
}) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
|
|
1809
1821
|
}
|
|
1810
|
-
class
|
|
1822
|
+
class _s extends $ {
|
|
1811
1823
|
constructor(t, s, n) {
|
|
1812
1824
|
super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
|
|
1813
1825
|
}
|
|
@@ -1840,7 +1852,7 @@ class gs extends V {
|
|
|
1840
1852
|
event: "popup_closed",
|
|
1841
1853
|
method: "web_app_open_popup",
|
|
1842
1854
|
postEvent: this.postEvent,
|
|
1843
|
-
params:
|
|
1855
|
+
params: ds(t)
|
|
1844
1856
|
});
|
|
1845
1857
|
return s;
|
|
1846
1858
|
} finally {
|
|
@@ -1848,10 +1860,10 @@ class gs extends V {
|
|
|
1848
1860
|
}
|
|
1849
1861
|
}
|
|
1850
1862
|
}
|
|
1851
|
-
const
|
|
1852
|
-
({ postEvent: e, version: t }) => new
|
|
1863
|
+
const gs = l(
|
|
1864
|
+
({ postEvent: e, version: t }) => new _s(!1, t, e)
|
|
1853
1865
|
);
|
|
1854
|
-
class
|
|
1866
|
+
class ws extends $ {
|
|
1855
1867
|
constructor(t, s, n) {
|
|
1856
1868
|
super({ isOpened: t }, s, {
|
|
1857
1869
|
close: "web_app_close_scan_qr_popup",
|
|
@@ -1895,10 +1907,10 @@ class fs extends V {
|
|
|
1895
1907
|
}
|
|
1896
1908
|
}
|
|
1897
1909
|
}
|
|
1898
|
-
const
|
|
1899
|
-
({ version: e, postEvent: t }) => new
|
|
1910
|
+
const fs = l(
|
|
1911
|
+
({ version: e, postEvent: t }) => new ws(!1, e, t)
|
|
1900
1912
|
);
|
|
1901
|
-
class
|
|
1913
|
+
class ms extends ot {
|
|
1902
1914
|
constructor(t, s, n) {
|
|
1903
1915
|
super({ isVisible: t }, s, {
|
|
1904
1916
|
show: "web_app_setup_settings_button",
|
|
@@ -1927,18 +1939,18 @@ class bs extends ot {
|
|
|
1927
1939
|
this.isVisible = !0;
|
|
1928
1940
|
}
|
|
1929
1941
|
}
|
|
1930
|
-
const
|
|
1942
|
+
const bs = l(
|
|
1931
1943
|
"settingsButton",
|
|
1932
1944
|
({
|
|
1933
1945
|
version: e,
|
|
1934
1946
|
postEvent: t,
|
|
1935
1947
|
state: s = { isVisible: !1 }
|
|
1936
|
-
}) => new
|
|
1948
|
+
}) => new ms(s.isVisible, e, t)
|
|
1937
1949
|
);
|
|
1938
|
-
function
|
|
1939
|
-
return
|
|
1950
|
+
function Ft(e) {
|
|
1951
|
+
return Vt().parse(e);
|
|
1940
1952
|
}
|
|
1941
|
-
class
|
|
1953
|
+
class vs extends ct {
|
|
1942
1954
|
/**
|
|
1943
1955
|
* @since v6.10
|
|
1944
1956
|
*/
|
|
@@ -1977,7 +1989,7 @@ class ys extends ct {
|
|
|
1977
1989
|
* value is calculated according to theme bg color.
|
|
1978
1990
|
*/
|
|
1979
1991
|
get isDark() {
|
|
1980
|
-
return !this.bgColor ||
|
|
1992
|
+
return !this.bgColor || Dt(this.bgColor);
|
|
1981
1993
|
}
|
|
1982
1994
|
get linkColor() {
|
|
1983
1995
|
return this.get("linkColor");
|
|
@@ -2003,7 +2015,7 @@ class ys extends ct {
|
|
|
2003
2015
|
*/
|
|
2004
2016
|
listen() {
|
|
2005
2017
|
return E("theme_changed", (t) => {
|
|
2006
|
-
this.set(
|
|
2018
|
+
this.set(Ft(t.theme_params));
|
|
2007
2019
|
});
|
|
2008
2020
|
}
|
|
2009
2021
|
/**
|
|
@@ -2016,23 +2028,23 @@ class ys extends ct {
|
|
|
2016
2028
|
return this.get("textColor");
|
|
2017
2029
|
}
|
|
2018
2030
|
}
|
|
2019
|
-
const
|
|
2031
|
+
const ys = l(
|
|
2020
2032
|
"themeParams",
|
|
2021
2033
|
({ themeParams: e, state: t = e, addCleanup: s }) => {
|
|
2022
|
-
const n = new
|
|
2034
|
+
const n = new vs(t);
|
|
2023
2035
|
return s(n.listen()), n;
|
|
2024
2036
|
}
|
|
2025
2037
|
);
|
|
2026
|
-
function
|
|
2038
|
+
function mn(e = {}) {
|
|
2027
2039
|
return w({
|
|
2028
2040
|
...e,
|
|
2029
2041
|
method: "web_app_request_theme",
|
|
2030
2042
|
event: "theme_changed"
|
|
2031
|
-
}).then(
|
|
2043
|
+
}).then(Ft);
|
|
2032
2044
|
}
|
|
2033
|
-
class
|
|
2045
|
+
class Es extends ht {
|
|
2034
2046
|
constructor(t, s, n) {
|
|
2035
|
-
super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam =
|
|
2047
|
+
super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Jt(t, {
|
|
2036
2048
|
"openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
|
|
2037
2049
|
});
|
|
2038
2050
|
}
|
|
@@ -2047,7 +2059,7 @@ class Ps extends ht {
|
|
|
2047
2059
|
*/
|
|
2048
2060
|
openLink(t, s) {
|
|
2049
2061
|
const n = new URL(t, window.location.href).toString();
|
|
2050
|
-
if (!
|
|
2062
|
+
if (!C("web_app_open_link", this.version)) {
|
|
2051
2063
|
window.open(n, "_blank");
|
|
2052
2064
|
return;
|
|
2053
2065
|
}
|
|
@@ -2066,7 +2078,7 @@ class Ps extends ht {
|
|
|
2066
2078
|
const { hostname: s, pathname: n, search: r } = new URL(t, window.location.href);
|
|
2067
2079
|
if (s !== "t.me")
|
|
2068
2080
|
throw new Error(`URL has not allowed hostname: ${s}. Only "t.me" is allowed`);
|
|
2069
|
-
if (!
|
|
2081
|
+
if (!C("web_app_open_tg_link", this.version)) {
|
|
2070
2082
|
window.location.href = t;
|
|
2071
2083
|
return;
|
|
2072
2084
|
}
|
|
@@ -2091,8 +2103,8 @@ class Ps extends ht {
|
|
|
2091
2103
|
return s;
|
|
2092
2104
|
}
|
|
2093
2105
|
}
|
|
2094
|
-
const
|
|
2095
|
-
({ version: e, postEvent: t, createRequestId: s }) => new
|
|
2106
|
+
const Ps = l(
|
|
2107
|
+
({ version: e, postEvent: t, createRequestId: s }) => new Es(e, s, t)
|
|
2096
2108
|
);
|
|
2097
2109
|
async function Qt(e = {}) {
|
|
2098
2110
|
const {
|
|
@@ -2106,16 +2118,16 @@ async function Qt(e = {}) {
|
|
|
2106
2118
|
});
|
|
2107
2119
|
return { ...n, isExpanded: t, isStateStable: s };
|
|
2108
2120
|
}
|
|
2109
|
-
function
|
|
2121
|
+
function q(e) {
|
|
2110
2122
|
return e < 0 ? 0 : e;
|
|
2111
2123
|
}
|
|
2112
|
-
class
|
|
2124
|
+
class Rs extends ct {
|
|
2113
2125
|
constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
|
|
2114
2126
|
super({
|
|
2115
|
-
height:
|
|
2127
|
+
height: q(n),
|
|
2116
2128
|
isExpanded: i,
|
|
2117
|
-
stableHeight:
|
|
2118
|
-
width:
|
|
2129
|
+
stableHeight: q(s),
|
|
2130
|
+
width: q(r)
|
|
2119
2131
|
}), c(this, "postEvent"), this.postEvent = t;
|
|
2120
2132
|
}
|
|
2121
2133
|
/**
|
|
@@ -2177,12 +2189,12 @@ class xs extends ct {
|
|
|
2177
2189
|
width: n,
|
|
2178
2190
|
is_expanded: r,
|
|
2179
2191
|
is_state_stable: i
|
|
2180
|
-
} = t,
|
|
2192
|
+
} = t, o = q(s);
|
|
2181
2193
|
this.set({
|
|
2182
|
-
height:
|
|
2194
|
+
height: o,
|
|
2183
2195
|
isExpanded: r,
|
|
2184
|
-
width:
|
|
2185
|
-
...i ? { stableHeight:
|
|
2196
|
+
width: q(n),
|
|
2197
|
+
...i ? { stableHeight: o } : {}
|
|
2186
2198
|
});
|
|
2187
2199
|
});
|
|
2188
2200
|
}
|
|
@@ -2216,23 +2228,23 @@ class xs extends ct {
|
|
|
2216
2228
|
return this.stableHeight === this.height;
|
|
2217
2229
|
}
|
|
2218
2230
|
}
|
|
2219
|
-
const
|
|
2231
|
+
const xs = l(
|
|
2220
2232
|
"viewport",
|
|
2221
2233
|
async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
|
|
2222
|
-
let r = !1, i = 0,
|
|
2234
|
+
let r = !1, i = 0, o = 0, a = 0;
|
|
2223
2235
|
if (e)
|
|
2224
|
-
r = e.isExpanded, i = e.height,
|
|
2236
|
+
r = e.isExpanded, i = e.height, o = e.width, a = e.stableHeight;
|
|
2225
2237
|
else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
|
|
2226
|
-
r = !0, i = window.innerHeight,
|
|
2238
|
+
r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
|
|
2227
2239
|
else {
|
|
2228
2240
|
const h = await Qt({ timeout: 1e3, postEvent: s });
|
|
2229
|
-
r = h.isExpanded, i = h.height,
|
|
2241
|
+
r = h.isExpanded, i = h.height, o = h.width, a = h.isStateStable ? i : 0;
|
|
2230
2242
|
}
|
|
2231
|
-
const u = new
|
|
2243
|
+
const u = new Rs({
|
|
2232
2244
|
postEvent: s,
|
|
2233
2245
|
height: i,
|
|
2234
|
-
width:
|
|
2235
|
-
stableHeight:
|
|
2246
|
+
width: o,
|
|
2247
|
+
stableHeight: a,
|
|
2236
2248
|
isExpanded: r
|
|
2237
2249
|
});
|
|
2238
2250
|
return n(u.listen()), u;
|
|
@@ -2241,24 +2253,24 @@ const Cs = l(
|
|
|
2241
2253
|
function R(e, t) {
|
|
2242
2254
|
document.documentElement.style.setProperty(e, t);
|
|
2243
2255
|
}
|
|
2244
|
-
function
|
|
2245
|
-
s || (s = (
|
|
2256
|
+
function bn(e, t, s) {
|
|
2257
|
+
s || (s = (a) => `--tg-${a}-color`);
|
|
2246
2258
|
const n = s("header"), r = s("bg"), i = () => {
|
|
2247
|
-
const { headerColor:
|
|
2248
|
-
if (rt(
|
|
2249
|
-
R(n,
|
|
2259
|
+
const { headerColor: a } = e;
|
|
2260
|
+
if (rt(a))
|
|
2261
|
+
R(n, a);
|
|
2250
2262
|
else {
|
|
2251
2263
|
const { bgColor: u, secondaryBgColor: h } = t;
|
|
2252
|
-
|
|
2264
|
+
a === "bg_color" && u ? R(n, u) : a === "secondary_bg_color" && h && R(n, h);
|
|
2253
2265
|
}
|
|
2254
2266
|
R(r, e.bgColor);
|
|
2255
|
-
},
|
|
2267
|
+
}, o = [
|
|
2256
2268
|
t.on("change", i),
|
|
2257
2269
|
e.on("change", i)
|
|
2258
2270
|
];
|
|
2259
|
-
return i(), () =>
|
|
2271
|
+
return i(), () => o.forEach((a) => a());
|
|
2260
2272
|
}
|
|
2261
|
-
function
|
|
2273
|
+
function vn(e, t) {
|
|
2262
2274
|
t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
|
|
2263
2275
|
const s = () => {
|
|
2264
2276
|
Object.entries(e.getState()).forEach(([n, r]) => {
|
|
@@ -2267,23 +2279,23 @@ function yn(e, t) {
|
|
|
2267
2279
|
};
|
|
2268
2280
|
return s(), e.on("change", s);
|
|
2269
2281
|
}
|
|
2270
|
-
function
|
|
2282
|
+
function yn(e, t) {
|
|
2271
2283
|
t || (t = (h) => `--tg-viewport-${h}`);
|
|
2272
2284
|
const [
|
|
2273
2285
|
s,
|
|
2274
2286
|
n,
|
|
2275
2287
|
r
|
|
2276
|
-
] = ["height", "width", "stable-height"].map((h) => t(h)), i = () => R(s, `${e.height}px`),
|
|
2288
|
+
] = ["height", "width", "stable-height"].map((h) => t(h)), i = () => R(s, `${e.height}px`), o = () => R(n, `${e.width}px`), a = () => R(r, `${e.stableHeight}px`), u = [
|
|
2277
2289
|
e.on("change:height", i),
|
|
2278
|
-
e.on("change:width",
|
|
2279
|
-
e.on("change:stableHeight",
|
|
2290
|
+
e.on("change:width", o),
|
|
2291
|
+
e.on("change:stableHeight", a)
|
|
2280
2292
|
];
|
|
2281
|
-
return i(),
|
|
2293
|
+
return i(), o(), a(), () => u.forEach((h) => h());
|
|
2282
2294
|
}
|
|
2283
|
-
function
|
|
2295
|
+
function Cs(e = !0) {
|
|
2284
2296
|
const t = [
|
|
2285
2297
|
E("reload_iframe", () => {
|
|
2286
|
-
|
|
2298
|
+
B("iframe_will_reload"), window.location.reload();
|
|
2287
2299
|
})
|
|
2288
2300
|
], s = () => t.forEach((n) => n());
|
|
2289
2301
|
if (e) {
|
|
@@ -2295,13 +2307,13 @@ function Ss(e = !0) {
|
|
|
2295
2307
|
() => document.head.removeChild(n)
|
|
2296
2308
|
);
|
|
2297
2309
|
}
|
|
2298
|
-
return
|
|
2310
|
+
return B("iframe_ready", { reload_supported: !0 }), s;
|
|
2299
2311
|
}
|
|
2300
|
-
function
|
|
2312
|
+
function Ss() {
|
|
2301
2313
|
return typeof window > "u";
|
|
2302
2314
|
}
|
|
2303
|
-
async function
|
|
2304
|
-
if (
|
|
2315
|
+
async function En() {
|
|
2316
|
+
if (Tt(window))
|
|
2305
2317
|
return !0;
|
|
2306
2318
|
try {
|
|
2307
2319
|
return await w({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
|
|
@@ -2309,11 +2321,11 @@ async function Pn() {
|
|
|
2309
2321
|
return !1;
|
|
2310
2322
|
}
|
|
2311
2323
|
}
|
|
2312
|
-
function
|
|
2324
|
+
function Ts(e) {
|
|
2313
2325
|
return e instanceof W;
|
|
2314
2326
|
}
|
|
2315
|
-
function
|
|
2316
|
-
return
|
|
2327
|
+
function Pn(e, t) {
|
|
2328
|
+
return Ts(e) && e.type === t;
|
|
2317
2329
|
}
|
|
2318
2330
|
function J(e, t) {
|
|
2319
2331
|
let s, n, r;
|
|
@@ -2323,13 +2335,13 @@ function J(e, t) {
|
|
|
2323
2335
|
params: n
|
|
2324
2336
|
});
|
|
2325
2337
|
}
|
|
2326
|
-
class
|
|
2327
|
-
constructor(t, s, n =
|
|
2328
|
-
if (c(this, "history"), c(this, "ee", new
|
|
2329
|
-
throw m(
|
|
2338
|
+
class As {
|
|
2339
|
+
constructor(t, s, n = B) {
|
|
2340
|
+
if (c(this, "history"), c(this, "ee", new N()), 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)
|
|
2341
|
+
throw m(ge, "History should not be empty.");
|
|
2330
2342
|
if (s < 0 || s >= t.length)
|
|
2331
2343
|
throw m(
|
|
2332
|
-
|
|
2344
|
+
we,
|
|
2333
2345
|
"Index should not be zero and higher or equal than history size."
|
|
2334
2346
|
);
|
|
2335
2347
|
this.history = t.map((r) => J(r, ""));
|
|
@@ -2444,30 +2456,30 @@ class ks {
|
|
|
2444
2456
|
this.postEvent("web_app_setup_back_button", { is_visible: !!this.index });
|
|
2445
2457
|
}
|
|
2446
2458
|
}
|
|
2447
|
-
function
|
|
2459
|
+
function F({
|
|
2448
2460
|
params: e,
|
|
2449
2461
|
...t
|
|
2450
2462
|
}) {
|
|
2451
2463
|
return { ...e || { hash: "", search: "" }, ...t };
|
|
2452
2464
|
}
|
|
2453
|
-
function
|
|
2465
|
+
function M(e, t) {
|
|
2454
2466
|
return e.startsWith(t) ? e : `${t}${e}`;
|
|
2455
2467
|
}
|
|
2456
|
-
function
|
|
2468
|
+
function H(e) {
|
|
2457
2469
|
return new URL(
|
|
2458
|
-
typeof e == "string" ? e : `${e.pathname || ""}${
|
|
2470
|
+
typeof e == "string" ? e : `${e.pathname || ""}${M(e.search || "", "?")}${M(e.hash || "", "#")}`,
|
|
2459
2471
|
"http://a"
|
|
2460
2472
|
);
|
|
2461
2473
|
}
|
|
2462
2474
|
function U(e) {
|
|
2463
|
-
const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s =
|
|
2475
|
+
const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = H(e);
|
|
2464
2476
|
return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
|
|
2465
2477
|
}
|
|
2466
|
-
function
|
|
2478
|
+
function Q(e, t, s) {
|
|
2467
2479
|
let n, r;
|
|
2468
2480
|
typeof e == "string" ? n = e : (n = U(e), s = e.state, r = e.id);
|
|
2469
|
-
const { pathname: i, search:
|
|
2470
|
-
return { id: r, pathname: i, params: { hash:
|
|
2481
|
+
const { pathname: i, search: o, hash: a } = new URL(n, `http://a${M(t, "/")}`);
|
|
2482
|
+
return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
|
|
2471
2483
|
}
|
|
2472
2484
|
async function D(e) {
|
|
2473
2485
|
return e === 0 ? !0 : Promise.race([
|
|
@@ -2490,32 +2502,32 @@ async function Is() {
|
|
|
2490
2502
|
for (; e; )
|
|
2491
2503
|
e = await D(-1);
|
|
2492
2504
|
}
|
|
2493
|
-
function
|
|
2494
|
-
return
|
|
2505
|
+
function Yt(e) {
|
|
2506
|
+
return H(e).pathname;
|
|
2495
2507
|
}
|
|
2496
2508
|
const ft = 0, Y = 1, Z = 2;
|
|
2497
|
-
class
|
|
2509
|
+
class Zt {
|
|
2498
2510
|
constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
|
|
2499
|
-
c(this, "navigator"), c(this, "ee", new
|
|
2500
|
-
if (
|
|
2511
|
+
c(this, "navigator"), c(this, "ee", new N()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
|
|
2512
|
+
if (o === null)
|
|
2501
2513
|
return this.push(this.parsePath(window.location.href));
|
|
2502
|
-
|
|
2514
|
+
o === ft ? window.history.forward() : o === Y && this.back(), o === Z && this.forward();
|
|
2503
2515
|
}), c(this, "onNavigatorChange", async ({
|
|
2504
|
-
to:
|
|
2505
|
-
from:
|
|
2516
|
+
to: o,
|
|
2517
|
+
from: a,
|
|
2506
2518
|
delta: u
|
|
2507
2519
|
}) => {
|
|
2508
2520
|
this.attached && await this.syncHistory(), this.ee.emit("change", {
|
|
2509
2521
|
delta: u,
|
|
2510
|
-
from:
|
|
2511
|
-
to:
|
|
2522
|
+
from: F(a),
|
|
2523
|
+
to: F(o),
|
|
2512
2524
|
navigator: this
|
|
2513
2525
|
});
|
|
2514
|
-
}), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new
|
|
2515
|
-
t.map((
|
|
2526
|
+
}), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new As(
|
|
2527
|
+
t.map((o) => Q(o, "/")),
|
|
2516
2528
|
s,
|
|
2517
2529
|
n
|
|
2518
|
-
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base =
|
|
2530
|
+
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Yt(i || "");
|
|
2519
2531
|
}
|
|
2520
2532
|
/**
|
|
2521
2533
|
* Attaches current navigator to the browser history allowing navigator to manipulate it.
|
|
@@ -2599,7 +2611,7 @@ class Yt {
|
|
|
2599
2611
|
* Navigation history.
|
|
2600
2612
|
*/
|
|
2601
2613
|
get history() {
|
|
2602
|
-
return this.navigator.history.map(
|
|
2614
|
+
return this.navigator.history.map(F);
|
|
2603
2615
|
}
|
|
2604
2616
|
/**
|
|
2605
2617
|
* Path, including pathname, search and hash.
|
|
@@ -2642,19 +2654,19 @@ class Yt {
|
|
|
2642
2654
|
* // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
|
|
2643
2655
|
*/
|
|
2644
2656
|
parsePath(t) {
|
|
2645
|
-
let s =
|
|
2646
|
-
return this.hashMode && (s =
|
|
2657
|
+
let s = H(t);
|
|
2658
|
+
return this.hashMode && (s = H(s.hash.slice(1))), {
|
|
2647
2659
|
pathname: s.pathname,
|
|
2648
2660
|
search: s.search,
|
|
2649
2661
|
hash: s.hash
|
|
2650
2662
|
};
|
|
2651
2663
|
}
|
|
2652
2664
|
push(t, s) {
|
|
2653
|
-
const n =
|
|
2665
|
+
const n = Q(t, this.path), { state: r = s } = n.params;
|
|
2654
2666
|
this.navigator.push({ ...n, params: { ...n.params, state: r } });
|
|
2655
2667
|
}
|
|
2656
2668
|
replace(t, s) {
|
|
2657
|
-
const n =
|
|
2669
|
+
const n = Q(t, this.path), { state: r = s } = n.params;
|
|
2658
2670
|
this.navigator.replace({ ...n, params: { ...n.params, state: r } });
|
|
2659
2671
|
}
|
|
2660
2672
|
/**
|
|
@@ -2663,8 +2675,8 @@ class Yt {
|
|
|
2663
2675
|
* @param value - path presented as string or URLLike.
|
|
2664
2676
|
*/
|
|
2665
2677
|
renderPath(t) {
|
|
2666
|
-
const s = (this.base.length === 1 ? "" : this.base) +
|
|
2667
|
-
return this.hashMode ?
|
|
2678
|
+
const s = (this.base.length === 1 ? "" : this.base) + M(U(t), "/");
|
|
2679
|
+
return this.hashMode ? M(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
|
|
2668
2680
|
}
|
|
2669
2681
|
/**
|
|
2670
2682
|
* Synchronizes current navigator state with browser history.
|
|
@@ -2690,41 +2702,41 @@ class Yt {
|
|
|
2690
2702
|
return (this.navigator.current.params || {}).state;
|
|
2691
2703
|
}
|
|
2692
2704
|
}
|
|
2693
|
-
function
|
|
2705
|
+
function ks(e) {
|
|
2694
2706
|
e || (e = {});
|
|
2695
2707
|
const { href: t, hash: s } = window.location;
|
|
2696
2708
|
let n = U(
|
|
2697
2709
|
e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
|
|
2698
2710
|
);
|
|
2699
|
-
const r = e.base ?
|
|
2711
|
+
const r = e.base ? Yt(e.base) : void 0;
|
|
2700
2712
|
if (r) {
|
|
2701
2713
|
if (!n.startsWith(r))
|
|
2702
2714
|
throw m(
|
|
2703
|
-
|
|
2715
|
+
fe,
|
|
2704
2716
|
`Path "${n}" expected to be starting with "${r}"`
|
|
2705
2717
|
);
|
|
2706
2718
|
n = n.slice(r.length);
|
|
2707
2719
|
}
|
|
2708
|
-
return new
|
|
2720
|
+
return new Zt([n], 0, e);
|
|
2709
2721
|
}
|
|
2710
|
-
function
|
|
2722
|
+
function Rn(e) {
|
|
2711
2723
|
const t = e.match(/#(.+)/);
|
|
2712
2724
|
return t ? t[1] : null;
|
|
2713
2725
|
}
|
|
2714
2726
|
function qs(e, t) {
|
|
2715
|
-
if (
|
|
2727
|
+
if (zt()) {
|
|
2716
2728
|
const s = sessionStorage.getItem(e);
|
|
2717
2729
|
if (s)
|
|
2718
2730
|
try {
|
|
2719
2731
|
const { index: n, history: r } = JSON.parse(s);
|
|
2720
|
-
return new
|
|
2732
|
+
return new Zt(r, n, t);
|
|
2721
2733
|
} catch (n) {
|
|
2722
2734
|
console.error("Unable to restore hash navigator state.", n);
|
|
2723
2735
|
}
|
|
2724
2736
|
}
|
|
2725
|
-
return
|
|
2737
|
+
return ks(t);
|
|
2726
2738
|
}
|
|
2727
|
-
function
|
|
2739
|
+
function xn(e, t) {
|
|
2728
2740
|
const s = qs(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
|
|
2729
2741
|
index: s.index,
|
|
2730
2742
|
history: s.history
|
|
@@ -2733,31 +2745,36 @@ function Cn(e, t) {
|
|
|
2733
2745
|
}
|
|
2734
2746
|
function d(e, t) {
|
|
2735
2747
|
function s(n) {
|
|
2736
|
-
return (
|
|
2737
|
-
|
|
2738
|
-
|
|
2748
|
+
return function(i, o, a) {
|
|
2749
|
+
return (u) => {
|
|
2750
|
+
const h = {
|
|
2751
|
+
...u,
|
|
2752
|
+
[i]: n(o)
|
|
2753
|
+
};
|
|
2754
|
+
return /* @__PURE__ */ mt(a, { ...h });
|
|
2755
|
+
};
|
|
2739
2756
|
};
|
|
2740
2757
|
}
|
|
2741
2758
|
return [s(e), s(t)];
|
|
2742
2759
|
}
|
|
2743
|
-
const
|
|
2744
|
-
function
|
|
2745
|
-
const e =
|
|
2760
|
+
const Xt = te(void 0);
|
|
2761
|
+
function Os() {
|
|
2762
|
+
const e = ee(Xt);
|
|
2746
2763
|
if (!e)
|
|
2747
2764
|
throw new Error("useSDK was used outside the SDKProvider.");
|
|
2748
2765
|
return e;
|
|
2749
2766
|
}
|
|
2750
2767
|
function _(e) {
|
|
2751
2768
|
function t(n) {
|
|
2752
|
-
const r =
|
|
2769
|
+
const r = Os(), [i, o] = bt(
|
|
2753
2770
|
n ? void 0 : () => {
|
|
2754
|
-
if (
|
|
2771
|
+
if (Ss())
|
|
2755
2772
|
throw new Error("Using hooks on the server side, you must explicitly specify ssr = true option");
|
|
2756
2773
|
return r.use(e);
|
|
2757
2774
|
}
|
|
2758
2775
|
);
|
|
2759
|
-
return
|
|
2760
|
-
|
|
2776
|
+
return S(() => {
|
|
2777
|
+
o(r.use(e));
|
|
2761
2778
|
}, [r]), i;
|
|
2762
2779
|
}
|
|
2763
2780
|
function s(n) {
|
|
@@ -2770,31 +2787,31 @@ function _(e) {
|
|
|
2770
2787
|
}
|
|
2771
2788
|
return [t, s];
|
|
2772
2789
|
}
|
|
2773
|
-
const [
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
), [
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
), [$s
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
), [
|
|
2783
|
-
|
|
2790
|
+
const [Ds, Ns] = _(Ge), [Cn, Sn] = d(
|
|
2791
|
+
Ds,
|
|
2792
|
+
Ns
|
|
2793
|
+
), [Bs, Ms] = _(Ke), [Tn, An] = d(
|
|
2794
|
+
Bs,
|
|
2795
|
+
Ms
|
|
2796
|
+
), [Vs, $s] = _(Fe), [In, kn] = d(
|
|
2797
|
+
Vs,
|
|
2798
|
+
$s
|
|
2799
|
+
), [Ls, Hs] = _(ts), [qn, On] = d(
|
|
2800
|
+
Ls,
|
|
2784
2801
|
Hs
|
|
2785
|
-
), [
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
), [Gs,
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
), [
|
|
2792
|
-
function
|
|
2802
|
+
), [Us, Ws] = _(ss), [Dn, Nn] = d(
|
|
2803
|
+
Us,
|
|
2804
|
+
Ws
|
|
2805
|
+
), [Gs, js] = _(rs), [Bn, Mn] = d(Gs, js), [zs, Ks] = _(os), [Vn, $n] = d(zs, Ks), [Js, Fs] = _(cs), [Ln, Hn] = d(Js, Fs), [Qs, Ys] = _(ls), [Un, Wn] = d(Qs, Ys), [Zs, Xs] = _(gs), [Gn, jn] = d(Zs, Xs), [tn, en] = _(fs), [zn, Kn] = d(tn, en), [sn, nn] = _(bs), [Jn, Fn] = d(
|
|
2806
|
+
sn,
|
|
2807
|
+
nn
|
|
2808
|
+
), [rn, on] = _(ys), [Qn, Yn] = d(rn, on);
|
|
2809
|
+
function Zn() {
|
|
2793
2810
|
return vt(jt, []);
|
|
2794
2811
|
}
|
|
2795
|
-
const [
|
|
2796
|
-
function
|
|
2797
|
-
const n = dt(!0), [r, i] = bt(/* @__PURE__ */ new Map()),
|
|
2812
|
+
const [an, cn] = _(Ps), [Xn, tr] = d(an, cn), [hn, pn] = _(xs), [er, sr] = d(hn, pn);
|
|
2813
|
+
function nr({ children: e, acceptCustomStyles: t, debug: s }) {
|
|
2814
|
+
const n = dt(!0), [r, i] = bt(/* @__PURE__ */ new Map()), o = dt(r), a = se(
|
|
2798
2815
|
(h) => {
|
|
2799
2816
|
n.current && i((v) => (h && h(v), new Map(v)));
|
|
2800
2817
|
},
|
|
@@ -2810,208 +2827,208 @@ function rr({ children: e, acceptCustomStyles: t, debug: s }) {
|
|
|
2810
2827
|
} catch (f) {
|
|
2811
2828
|
K = f;
|
|
2812
2829
|
}
|
|
2813
|
-
function
|
|
2830
|
+
function L(f) {
|
|
2814
2831
|
return r.set(h, f), f;
|
|
2815
2832
|
}
|
|
2816
2833
|
if (K)
|
|
2817
|
-
return
|
|
2818
|
-
let
|
|
2819
|
-
if (Array.isArray(b) && (
|
|
2820
|
-
return
|
|
2834
|
+
return L({ error: K });
|
|
2835
|
+
let I;
|
|
2836
|
+
if (Array.isArray(b) && (I = b[1], b = b[0]), !b)
|
|
2837
|
+
return L({ result: b, cleanup: I });
|
|
2821
2838
|
function ut(f) {
|
|
2822
2839
|
if ("on" in f) {
|
|
2823
|
-
const
|
|
2824
|
-
|
|
2825
|
-
lt && lt(),
|
|
2840
|
+
const k = f.on("change", () => a()), lt = I;
|
|
2841
|
+
I = () => {
|
|
2842
|
+
lt && lt(), k();
|
|
2826
2843
|
};
|
|
2827
2844
|
}
|
|
2828
|
-
return { result: f, cleanup:
|
|
2845
|
+
return { result: f, cleanup: I };
|
|
2829
2846
|
}
|
|
2830
2847
|
return b instanceof Promise ? (b.then(
|
|
2831
|
-
(f) =>
|
|
2832
|
-
(f) =>
|
|
2833
|
-
),
|
|
2848
|
+
(f) => a((k) => k.set(h, ut(f))),
|
|
2849
|
+
(f) => a((k) => k.set(h, { error: f }))
|
|
2850
|
+
), L({})) : L(ut(b));
|
|
2834
2851
|
}
|
|
2835
2852
|
}), [r]);
|
|
2836
|
-
return
|
|
2853
|
+
return S(() => (n.current = !0, () => {
|
|
2837
2854
|
n.current = !1;
|
|
2838
|
-
}), []),
|
|
2839
|
-
if (
|
|
2840
|
-
return
|
|
2841
|
-
}, [t]),
|
|
2842
|
-
|
|
2843
|
-
}, [s]),
|
|
2844
|
-
|
|
2845
|
-
}, [r]),
|
|
2846
|
-
|
|
2855
|
+
}), []), S(() => {
|
|
2856
|
+
if (At())
|
|
2857
|
+
return Cs(t);
|
|
2858
|
+
}, [t]), S(() => {
|
|
2859
|
+
ae(s || !1);
|
|
2860
|
+
}, [s]), S(() => {
|
|
2861
|
+
o.current = r;
|
|
2862
|
+
}, [r]), S(() => () => {
|
|
2863
|
+
o.current.forEach((h) => {
|
|
2847
2864
|
"cleanup" in h && h.cleanup && h.cleanup();
|
|
2848
2865
|
});
|
|
2849
|
-
}, []), /* @__PURE__ */ mt(
|
|
2866
|
+
}, []), /* @__PURE__ */ mt(Xt.Provider, { value: u, children: e });
|
|
2850
2867
|
}
|
|
2851
2868
|
export {
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2869
|
+
qe as BackButton,
|
|
2870
|
+
As as BasicNavigator,
|
|
2871
|
+
je as BiometryManager,
|
|
2872
|
+
Zt as BrowserNavigator,
|
|
2873
|
+
Je as ClosingBehavior,
|
|
2874
|
+
Xe as CloudStorage,
|
|
2875
|
+
fe as ERR_INVALID_PATH_BASE,
|
|
2876
|
+
le as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
|
|
2877
|
+
pe as ERR_METHOD_PARAMETER_UNSUPPORTED,
|
|
2878
|
+
he as ERR_METHOD_UNSUPPORTED,
|
|
2879
|
+
ge as ERR_NAVIGATION_HISTORY_EMPTY,
|
|
2880
|
+
we as ERR_NAVIGATION_INDEX_INVALID,
|
|
2881
|
+
dn as ERR_NAVIGATION_ITEM_INVALID,
|
|
2882
|
+
Rt as ERR_PARSE,
|
|
2883
|
+
_n as ERR_SSR_INIT,
|
|
2884
|
+
de as ERR_TIMED_OUT,
|
|
2885
|
+
_e as ERR_UNEXPECTED_TYPE,
|
|
2886
|
+
ue as ERR_UNKNOWN_ENV,
|
|
2887
|
+
N as EventEmitter,
|
|
2888
|
+
es as HapticFeedback,
|
|
2889
|
+
ns as InitData,
|
|
2890
|
+
is as Invoice,
|
|
2891
|
+
as as MainButton,
|
|
2892
|
+
us as MiniApp,
|
|
2893
|
+
_s as Popup,
|
|
2894
|
+
ws as QRScanner,
|
|
2878
2895
|
W as SDKError,
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2896
|
+
nr as SDKProvider,
|
|
2897
|
+
ms as SettingsButton,
|
|
2898
|
+
vs as ThemeParams,
|
|
2899
|
+
Es as Utils,
|
|
2900
|
+
Rs as Viewport,
|
|
2901
|
+
Ze as array,
|
|
2902
|
+
bn as bindMiniAppCSSVars,
|
|
2903
|
+
vn as bindThemeParamsCSSVars,
|
|
2904
|
+
yn as bindViewportCSSVars,
|
|
2888
2905
|
P as boolean,
|
|
2889
2906
|
kt as captureSameReq,
|
|
2890
2907
|
et as classNames,
|
|
2891
2908
|
Se as compareVersions,
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2909
|
+
ks as createBrowserNavigatorFromLocation,
|
|
2910
|
+
Ie as createPostEvent,
|
|
2911
|
+
H as createSafeURL,
|
|
2912
|
+
Bt as date,
|
|
2913
|
+
Rn as getHash,
|
|
2914
|
+
Yt as getPathname,
|
|
2898
2915
|
Ge as initBackButton,
|
|
2899
|
-
|
|
2916
|
+
Ke as initBiometryManager,
|
|
2900
2917
|
Fe as initClosingBehavior,
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2918
|
+
ts as initCloudStorage,
|
|
2919
|
+
ss as initHapticFeedback,
|
|
2920
|
+
rs as initInitData,
|
|
2921
|
+
os as initInvoice,
|
|
2922
|
+
cs as initMainButton,
|
|
2923
|
+
ls as initMiniApp,
|
|
2924
|
+
xn as initNavigator,
|
|
2925
|
+
gs as initPopup,
|
|
2926
|
+
fs as initQRScanner,
|
|
2927
|
+
bs as initSettingsButton,
|
|
2928
|
+
ys as initThemeParams,
|
|
2929
|
+
Ps as initUtils,
|
|
2930
|
+
xs as initViewport,
|
|
2931
|
+
Cs as initWeb,
|
|
2932
|
+
O as invokeCustomMethod,
|
|
2933
|
+
Dt as isColorDark,
|
|
2934
|
+
At as isIframe,
|
|
2935
|
+
zt as isPageReload,
|
|
2919
2936
|
rt as isRGB,
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2937
|
+
me as isRGBShort,
|
|
2938
|
+
Ts as isSDKError,
|
|
2939
|
+
Pn as isSDKErrorOfType,
|
|
2940
|
+
Ss as isSSR,
|
|
2941
|
+
En as isTMA,
|
|
2925
2942
|
g as json,
|
|
2926
|
-
|
|
2943
|
+
wn as mergeClassNames,
|
|
2927
2944
|
x as number,
|
|
2928
2945
|
z as off,
|
|
2929
2946
|
E as on,
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2947
|
+
fn as parseInitData,
|
|
2948
|
+
$t as parseLaunchParams,
|
|
2949
|
+
Ft as parseThemeParams,
|
|
2950
|
+
B as postEvent,
|
|
2934
2951
|
w as request,
|
|
2935
|
-
|
|
2936
|
-
|
|
2952
|
+
ze as requestBiometryInfo,
|
|
2953
|
+
mn as requestThemeParams,
|
|
2937
2954
|
Qt as requestViewport,
|
|
2938
2955
|
jt as retrieveLaunchParams,
|
|
2939
|
-
|
|
2956
|
+
St as rgb,
|
|
2940
2957
|
at as searchParams,
|
|
2941
2958
|
Le as serializeLaunchParams,
|
|
2942
2959
|
$e as serializeThemeParams,
|
|
2943
2960
|
R as setCSSVar,
|
|
2944
|
-
|
|
2945
|
-
|
|
2961
|
+
ae as setDebug,
|
|
2962
|
+
gn as setTargetOrigin,
|
|
2946
2963
|
p as string,
|
|
2947
|
-
|
|
2948
|
-
|
|
2964
|
+
ie as subscribe,
|
|
2965
|
+
C as supports,
|
|
2949
2966
|
Ae as targetOrigin,
|
|
2950
|
-
|
|
2967
|
+
Ct as toRGB,
|
|
2951
2968
|
Et as unsubscribe,
|
|
2952
2969
|
U as urlToPath,
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2970
|
+
Ns as useBackButton,
|
|
2971
|
+
Ds as useBackButtonRaw,
|
|
2972
|
+
Ms as useBiometryManager,
|
|
2973
|
+
Bs as useBiometryManagerRaw,
|
|
2974
|
+
$s as useClosingBehavior,
|
|
2975
|
+
Vs as useClosingBehaviorRaw,
|
|
2959
2976
|
Hs as useCloudStorage,
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2977
|
+
Ls as useCloudStorageRaw,
|
|
2978
|
+
Ws as useHapticFeedback,
|
|
2979
|
+
Us as useHapticFeedbackRaw,
|
|
2980
|
+
js as useInitData,
|
|
2964
2981
|
Gs as useInitDataRaw,
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2982
|
+
Ks as useInvoice,
|
|
2983
|
+
zs as useInvoiceRaw,
|
|
2984
|
+
Zn as useLaunchParams,
|
|
2968
2985
|
Fs as useMainButton,
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2986
|
+
Js as useMainButtonRaw,
|
|
2987
|
+
Ys as useMiniApp,
|
|
2988
|
+
Qs as useMiniAppRaw,
|
|
2989
|
+
Xs as usePopup,
|
|
2990
|
+
Zs as usePopupRaw,
|
|
2991
|
+
en as useQRScanner,
|
|
2992
|
+
tn as useQRScannerRaw,
|
|
2993
|
+
Os as useSDK,
|
|
2994
|
+
nn as useSettingsButton,
|
|
2995
|
+
sn as useSettingsButtonRaw,
|
|
2996
|
+
on as useThemeParams,
|
|
2997
|
+
rn as useThemeParamsRaw,
|
|
2998
|
+
cn as useUtils,
|
|
2999
|
+
an as useUtilsRaw,
|
|
3000
|
+
pn as useViewport,
|
|
3001
|
+
hn as useViewportRaw,
|
|
3002
|
+
Sn as withBackButton,
|
|
3003
|
+
Cn as withBackButtonRaw,
|
|
3004
|
+
An as withBiometryManager,
|
|
3005
|
+
Tn as withBiometryManagerRaw,
|
|
3006
|
+
kn as withClosingBehavior,
|
|
2990
3007
|
In as withClosingBehaviorRaw,
|
|
2991
|
-
|
|
3008
|
+
On as withCloudStorage,
|
|
2992
3009
|
qn as withCloudStorageRaw,
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
3010
|
+
Nn as withHapticFeedback,
|
|
3011
|
+
Dn as withHapticFeedbackRaw,
|
|
3012
|
+
Mn as withInitData,
|
|
3013
|
+
Bn as withInitDataRaw,
|
|
3014
|
+
$n as withInvoice,
|
|
3015
|
+
Vn as withInvoiceRaw,
|
|
2999
3016
|
Hn as withMainButton,
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3017
|
+
Ln as withMainButtonRaw,
|
|
3018
|
+
Wn as withMiniApp,
|
|
3019
|
+
Un as withMiniAppRaw,
|
|
3020
|
+
jn as withPopup,
|
|
3004
3021
|
Gn as withPopupRaw,
|
|
3005
|
-
|
|
3006
|
-
|
|
3022
|
+
Kn as withQRScanner,
|
|
3023
|
+
zn as withQRScannerRaw,
|
|
3007
3024
|
Fn as withSettingsButton,
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3025
|
+
Jn as withSettingsButtonRaw,
|
|
3026
|
+
Yn as withThemeParams,
|
|
3027
|
+
Qn as withThemeParamsRaw,
|
|
3011
3028
|
Ot as withTimeout,
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3029
|
+
tr as withUtils,
|
|
3030
|
+
Xn as withUtilsRaw,
|
|
3031
|
+
sr as withViewport,
|
|
3032
|
+
er as withViewportRaw
|
|
3016
3033
|
};
|
|
3017
3034
|
//# sourceMappingURL=index.js.map
|