@tma.js/sdk 2.0.1 → 2.1.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/components/BackButton/initBackButton.d.ts +1 -1
- package/dist/dts/components/BiometryManager/initBiometryManager.d.ts +1 -1
- package/dist/dts/components/ClosingBehavior/initClosingBehavior.d.ts +1 -1
- package/dist/dts/components/CloudStorage/initCloudStorage.d.ts +1 -1
- package/dist/dts/components/HapticFeedback/initHapticFeedback.d.ts +1 -1
- package/dist/dts/components/InitData/initInitData.d.ts +1 -1
- package/dist/dts/components/Invoice/initInvoice.d.ts +1 -1
- package/dist/dts/components/MainButton/initMainButton.d.ts +1 -1
- package/dist/dts/components/MiniApp/initMiniApp.d.ts +1 -1
- package/dist/dts/components/Popup/initPopup.d.ts +1 -1
- package/dist/dts/components/QRScanner/initQRScanner.d.ts +1 -1
- package/dist/dts/components/SettingsButton/initSettingsButton.d.ts +1 -1
- package/dist/dts/components/ThemeParams/initThemeParams.d.ts +1 -1
- package/dist/dts/components/Utils/initUtils.d.ts +1 -1
- package/dist/dts/components/Viewport/initViewport.d.ts +1 -2
- package/dist/dts/errors/errors.d.ts +1 -5
- package/dist/dts/index.d.ts +1 -1
- package/dist/dts/misc/createCleanup.d.ts +11 -0
- package/dist/dts/misc/createComponentInitFn/createComponentInitFn.d.ts +7 -6
- package/dist/dts/misc/createComponentInitFn/types.d.ts +29 -22
- package/dist/dts/navigation/BrowserNavigator/BrowserNavigator.d.ts +1 -1
- package/dist/dts/navigation/BrowserNavigator/types.d.ts +5 -4
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +608 -614
- package/dist/index.js.map +1 -1
- package/dist/index.low-level.iife.js +1 -1
- package/dist/index.low-level.iife.js.map +1 -1
- package/package.json +1 -1
- package/dist/dts/components/Viewport/initViewportFromRequest.d.ts +0 -10
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (e, t, s) => (
|
|
4
|
-
function
|
|
1
|
+
var Dt = Object.defineProperty;
|
|
2
|
+
var Vt = (e, t, s) => t in e ? Dt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var c = (e, t, s) => (Vt(e, typeof t != "symbol" ? t + "" : t, s), s);
|
|
4
|
+
function it(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
|
|
12
|
-
const t =
|
|
13
|
-
t.unsubscribe(e), s && !t.count &&
|
|
11
|
+
function ot(e) {
|
|
12
|
+
const t = M(), { count: s } = t;
|
|
13
|
+
t.unsubscribe(e), s && !t.count && ne();
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return
|
|
15
|
+
function $t(e) {
|
|
16
|
+
return M().subscribe(e), () => ot(e);
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class Mt {
|
|
19
19
|
constructor(t, s = {}) {
|
|
20
20
|
this.scope = t, this.options = s;
|
|
21
21
|
}
|
|
@@ -31,12 +31,12 @@ class Ut {
|
|
|
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 Ut {
|
|
|
55
55
|
this.print("log", ...t);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
const
|
|
58
|
+
const F = new Mt("SDK", {
|
|
59
59
|
bgColor: "forestgreen",
|
|
60
60
|
textColor: "white"
|
|
61
61
|
});
|
|
62
|
-
let
|
|
63
|
-
const
|
|
64
|
-
|
|
62
|
+
let G = !1;
|
|
63
|
+
const et = ({ event: e, args: [t] }) => {
|
|
64
|
+
F.log("Event received:", t === void 0 ? { name: e } : { name: e, data: t });
|
|
65
65
|
};
|
|
66
|
-
function
|
|
67
|
-
|
|
66
|
+
function Ze(e) {
|
|
67
|
+
G !== e && (G = e, e ? $t(et) : ot(et));
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
|
|
69
|
+
function Lt(...e) {
|
|
70
|
+
G && F.log(...e);
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class D {
|
|
73
73
|
constructor() {
|
|
74
74
|
c(this, "listeners", /* @__PURE__ */ new Map());
|
|
75
75
|
c(this, "listenersCount", 0);
|
|
@@ -141,22 +141,22 @@ class V {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function j(e, t, s) {
|
|
145
145
|
return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
|
|
146
146
|
}
|
|
147
|
-
class
|
|
147
|
+
class V extends Error {
|
|
148
148
|
constructor(t, s, n) {
|
|
149
|
-
super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this,
|
|
149
|
+
super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, V.prototype);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
return new
|
|
152
|
+
function f(e, t, s) {
|
|
153
|
+
return new V(e, t, s);
|
|
154
154
|
}
|
|
155
|
-
const
|
|
156
|
-
function
|
|
157
|
-
return
|
|
155
|
+
const Bt = "ERR_METHOD_UNSUPPORTED", Ot = "ERR_METHOD_PARAMETER_UNSUPPORTED", Ut = "ERR_UNKNOWN_ENV", Wt = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", Ht = "ERR_TIMED_OUT", Gt = "ERR_UNEXPECTED_TYPE", at = "ERR_PARSE", jt = "ERR_NAVIGATION_LIST_EMPTY", zt = "ERR_NAVIGATION_CURSOR_INVALID", Ke = "ERR_NAVIGATION_ITEM_INVALID", Xe = "ERR_SSR_INIT", Ft = "ERR_INVALID_PATH_BASE";
|
|
156
|
+
function E() {
|
|
157
|
+
return f(Gt, "Value has unexpected type");
|
|
158
158
|
}
|
|
159
|
-
class
|
|
159
|
+
class $ {
|
|
160
160
|
constructor(t, s, n) {
|
|
161
161
|
this.parser = t, this.isOptional = s, this.type = n;
|
|
162
162
|
}
|
|
@@ -171,8 +171,8 @@ class M {
|
|
|
171
171
|
try {
|
|
172
172
|
return this.parser(t);
|
|
173
173
|
} catch (s) {
|
|
174
|
-
throw
|
|
175
|
-
|
|
174
|
+
throw f(
|
|
175
|
+
at,
|
|
176
176
|
`Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
|
|
177
177
|
s
|
|
178
178
|
);
|
|
@@ -182,10 +182,10 @@ class M {
|
|
|
182
182
|
return this.isOptional = !0, this;
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
return () => new
|
|
185
|
+
function P(e, t) {
|
|
186
|
+
return () => new $(e, !1, t);
|
|
187
187
|
}
|
|
188
|
-
const w =
|
|
188
|
+
const w = P((e) => {
|
|
189
189
|
if (typeof e == "boolean")
|
|
190
190
|
return e;
|
|
191
191
|
const t = String(e);
|
|
@@ -193,43 +193,43 @@ const w = S((e) => {
|
|
|
193
193
|
return !0;
|
|
194
194
|
if (t === "0" || t === "false")
|
|
195
195
|
return !1;
|
|
196
|
-
throw
|
|
196
|
+
throw E();
|
|
197
197
|
}, "boolean");
|
|
198
|
-
function
|
|
198
|
+
function ct(e, t) {
|
|
199
199
|
const s = {};
|
|
200
200
|
for (const n in e) {
|
|
201
201
|
const r = e[n];
|
|
202
202
|
if (!r)
|
|
203
203
|
continue;
|
|
204
|
-
let i,
|
|
204
|
+
let i, a;
|
|
205
205
|
if (typeof r == "function" || "parse" in r)
|
|
206
|
-
i = n,
|
|
206
|
+
i = n, a = typeof r == "function" ? r : r.parse.bind(r);
|
|
207
207
|
else {
|
|
208
|
-
const { type:
|
|
209
|
-
i = r.from || n,
|
|
208
|
+
const { type: o } = r;
|
|
209
|
+
i = r.from || n, a = typeof o == "function" ? o : o.parse.bind(o);
|
|
210
210
|
}
|
|
211
211
|
try {
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
} catch (
|
|
215
|
-
throw
|
|
212
|
+
const o = a(t(i));
|
|
213
|
+
o !== void 0 && (s[n] = o);
|
|
214
|
+
} catch (o) {
|
|
215
|
+
throw f(at, `Unable to parse field "${n}"`, o);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
return s;
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function J(e) {
|
|
221
221
|
let t = e;
|
|
222
222
|
if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
|
|
223
|
-
throw
|
|
223
|
+
throw E();
|
|
224
224
|
return t;
|
|
225
225
|
}
|
|
226
|
-
function
|
|
227
|
-
return new
|
|
228
|
-
const n =
|
|
229
|
-
return
|
|
226
|
+
function d(e, t) {
|
|
227
|
+
return new $((s) => {
|
|
228
|
+
const n = J(s);
|
|
229
|
+
return ct(e, (r) => n[r]);
|
|
230
230
|
}, !1, t);
|
|
231
231
|
}
|
|
232
|
-
const y =
|
|
232
|
+
const y = P((e) => {
|
|
233
233
|
if (typeof e == "number")
|
|
234
234
|
return e;
|
|
235
235
|
if (typeof e == "string") {
|
|
@@ -237,19 +237,19 @@ const y = S((e) => {
|
|
|
237
237
|
if (!Number.isNaN(t))
|
|
238
238
|
return t;
|
|
239
239
|
}
|
|
240
|
-
throw
|
|
240
|
+
throw E();
|
|
241
241
|
}, "number");
|
|
242
|
-
function
|
|
242
|
+
function Q(e) {
|
|
243
243
|
return /^#[\da-f]{6}$/i.test(e);
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function Jt(e) {
|
|
246
246
|
return /^#[\da-f]{3}$/i.test(e);
|
|
247
247
|
}
|
|
248
|
-
function
|
|
248
|
+
function ht(e) {
|
|
249
249
|
const t = e.replace(/\s/g, "").toLowerCase();
|
|
250
|
-
if (
|
|
250
|
+
if (Q(t))
|
|
251
251
|
return t;
|
|
252
|
-
if (
|
|
252
|
+
if (Jt(t)) {
|
|
253
253
|
let n = "#";
|
|
254
254
|
for (let r = 0; r < 3; r += 1)
|
|
255
255
|
n += t[1 + r].repeat(2);
|
|
@@ -263,30 +263,30 @@ function lt(e) {
|
|
|
263
263
|
return n + (i.length === 1 ? "0" : "") + i;
|
|
264
264
|
}, "#");
|
|
265
265
|
}
|
|
266
|
-
const h =
|
|
266
|
+
const h = P((e) => {
|
|
267
267
|
if (typeof e == "string" || typeof e == "number")
|
|
268
268
|
return e.toString();
|
|
269
|
-
throw
|
|
270
|
-
}, "string"),
|
|
271
|
-
function
|
|
272
|
-
return
|
|
269
|
+
throw E();
|
|
270
|
+
}, "string"), pt = P((e) => ht(h().parse(e)), "rgb");
|
|
271
|
+
function Qt(e) {
|
|
272
|
+
return d({
|
|
273
273
|
eventType: h(),
|
|
274
274
|
eventData: (t) => t
|
|
275
275
|
}).parse(e);
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function Yt() {
|
|
278
278
|
["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
|
|
279
279
|
delete window[e];
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
|
-
function
|
|
282
|
+
function Zt(e, t) {
|
|
283
283
|
window.dispatchEvent(new MessageEvent("message", {
|
|
284
284
|
data: JSON.stringify({ eventType: e, eventData: t }),
|
|
285
285
|
// We specify window.parent to imitate the case, the parent iframe sent us this event.
|
|
286
286
|
source: window.parent
|
|
287
287
|
}));
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function Kt() {
|
|
290
290
|
[
|
|
291
291
|
["TelegramGameProxy_receiveEvent"],
|
|
292
292
|
// Windows Phone.
|
|
@@ -298,66 +298,66 @@ function ne() {
|
|
|
298
298
|
let t = window;
|
|
299
299
|
e.forEach((s, n, r) => {
|
|
300
300
|
if (n === r.length - 1) {
|
|
301
|
-
t[s] =
|
|
301
|
+
t[s] = Zt;
|
|
302
302
|
return;
|
|
303
303
|
}
|
|
304
304
|
s in t || (t[s] = {}), t = t[s];
|
|
305
305
|
});
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
|
-
const
|
|
308
|
+
const Xt = d({
|
|
309
309
|
button_id: (e) => e == null ? void 0 : h().parse(e)
|
|
310
|
-
}),
|
|
311
|
-
clipboard_text_received:
|
|
310
|
+
}), te = {
|
|
311
|
+
clipboard_text_received: d({
|
|
312
312
|
req_id: h(),
|
|
313
313
|
data: (e) => e === null ? e : h().optional().parse(e)
|
|
314
314
|
}),
|
|
315
|
-
custom_method_invoked:
|
|
315
|
+
custom_method_invoked: d({
|
|
316
316
|
req_id: h(),
|
|
317
317
|
result: (e) => e,
|
|
318
318
|
error: h().optional()
|
|
319
319
|
}),
|
|
320
|
-
invoice_closed:
|
|
320
|
+
invoice_closed: d({
|
|
321
321
|
slug: h(),
|
|
322
322
|
status: h()
|
|
323
323
|
}),
|
|
324
|
-
phone_requested:
|
|
324
|
+
phone_requested: d({
|
|
325
325
|
status: h()
|
|
326
326
|
}),
|
|
327
327
|
popup_closed: {
|
|
328
|
-
parse: (e) =>
|
|
328
|
+
parse: (e) => Xt.parse(e ?? {})
|
|
329
329
|
},
|
|
330
|
-
qr_text_received:
|
|
330
|
+
qr_text_received: d({
|
|
331
331
|
data: h().optional()
|
|
332
332
|
}),
|
|
333
|
-
theme_changed:
|
|
333
|
+
theme_changed: d({
|
|
334
334
|
theme_params: (e) => {
|
|
335
|
-
const t =
|
|
336
|
-
return Object.entries(
|
|
335
|
+
const t = pt().optional();
|
|
336
|
+
return Object.entries(J(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
|
|
337
337
|
}
|
|
338
338
|
}),
|
|
339
|
-
viewport_changed:
|
|
339
|
+
viewport_changed: d({
|
|
340
340
|
height: y(),
|
|
341
341
|
width: (e) => e == null ? window.innerWidth : y().parse(e),
|
|
342
342
|
is_state_stable: w(),
|
|
343
343
|
is_expanded: w()
|
|
344
344
|
}),
|
|
345
|
-
write_access_requested:
|
|
345
|
+
write_access_requested: d({
|
|
346
346
|
status: h()
|
|
347
347
|
})
|
|
348
348
|
};
|
|
349
|
-
function
|
|
350
|
-
const e = new
|
|
351
|
-
|
|
349
|
+
function ee() {
|
|
350
|
+
const e = new D();
|
|
351
|
+
Kt();
|
|
352
352
|
let t = [
|
|
353
353
|
// Don't forget to remove created handlers.
|
|
354
|
-
|
|
354
|
+
Yt,
|
|
355
355
|
// Add "resize" event listener to make sure, we always have fresh viewport information.
|
|
356
356
|
// Desktop version of Telegram is sometimes not sending the viewport_changed
|
|
357
357
|
// event. For example, when the MainButton is shown. That's why we should
|
|
358
358
|
// add our own listener to make sure, viewport information is always fresh.
|
|
359
359
|
// Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/10
|
|
360
|
-
|
|
360
|
+
j("resize", () => {
|
|
361
361
|
e.emit("viewport_changed", {
|
|
362
362
|
width: window.innerWidth,
|
|
363
363
|
height: window.innerHeight,
|
|
@@ -367,24 +367,24 @@ function oe() {
|
|
|
367
367
|
}),
|
|
368
368
|
// Add listener, which handles events sent from the Telegram web application and also events
|
|
369
369
|
// generated by the local emitEvent function.
|
|
370
|
-
|
|
370
|
+
j("message", (s) => {
|
|
371
371
|
if (s.source !== window.parent)
|
|
372
372
|
return;
|
|
373
373
|
let n;
|
|
374
374
|
try {
|
|
375
|
-
n =
|
|
375
|
+
n = Qt(s.data);
|
|
376
376
|
} catch {
|
|
377
377
|
return;
|
|
378
378
|
}
|
|
379
|
-
const { eventType: r, eventData: i } = n,
|
|
379
|
+
const { eventType: r, eventData: i } = n, a = te[r];
|
|
380
380
|
try {
|
|
381
|
-
const
|
|
382
|
-
e.emit(...
|
|
383
|
-
} catch (
|
|
384
|
-
|
|
381
|
+
const o = a ? a.parse(i) : i;
|
|
382
|
+
e.emit(...o ? [r, o] : [r]);
|
|
383
|
+
} catch (o) {
|
|
384
|
+
F.error(
|
|
385
385
|
`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`,
|
|
386
386
|
n,
|
|
387
|
-
|
|
387
|
+
o
|
|
388
388
|
);
|
|
389
389
|
}
|
|
390
390
|
}),
|
|
@@ -395,39 +395,39 @@ function oe() {
|
|
|
395
395
|
t.forEach((s) => s()), t = [];
|
|
396
396
|
}];
|
|
397
397
|
}
|
|
398
|
-
const [
|
|
398
|
+
const [se, ne] = it(
|
|
399
399
|
(e) => {
|
|
400
|
-
const [t, s] =
|
|
400
|
+
const [t, s] = ee(), n = t.off.bind(t);
|
|
401
401
|
return t.off = (r, i) => {
|
|
402
|
-
const { count:
|
|
403
|
-
n(r, i),
|
|
402
|
+
const { count: a } = t;
|
|
403
|
+
n(r, i), a && !t.count && e();
|
|
404
404
|
}, [t, s];
|
|
405
405
|
},
|
|
406
406
|
([, e]) => e()
|
|
407
407
|
);
|
|
408
|
-
function
|
|
409
|
-
return
|
|
408
|
+
function M() {
|
|
409
|
+
return se()[0];
|
|
410
410
|
}
|
|
411
|
-
function
|
|
412
|
-
|
|
411
|
+
function L(e, t) {
|
|
412
|
+
M().off(e, t);
|
|
413
413
|
}
|
|
414
414
|
function b(e, t, s) {
|
|
415
|
-
return
|
|
415
|
+
return M().on(e, t, s);
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function T(e) {
|
|
418
418
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
419
419
|
}
|
|
420
|
-
function
|
|
420
|
+
function re(e, t) {
|
|
421
421
|
const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
|
|
422
422
|
for (let i = 0; i < r; i += 1) {
|
|
423
|
-
const
|
|
424
|
-
if (
|
|
425
|
-
return
|
|
423
|
+
const a = parseInt(s[i] || "0", 10), o = parseInt(n[i] || "0", 10);
|
|
424
|
+
if (a !== o)
|
|
425
|
+
return a > o ? 1 : -1;
|
|
426
426
|
}
|
|
427
427
|
return 0;
|
|
428
428
|
}
|
|
429
429
|
function g(e, t) {
|
|
430
|
-
return
|
|
430
|
+
return re(e, t) <= 0;
|
|
431
431
|
}
|
|
432
432
|
function v(e, t, s) {
|
|
433
433
|
if (typeof s == "string") {
|
|
@@ -480,102 +480,102 @@ function v(e, t, s) {
|
|
|
480
480
|
].includes(e);
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
function
|
|
484
|
-
return "external" in e &&
|
|
483
|
+
function ie(e) {
|
|
484
|
+
return "external" in e && T(e.external) && "notify" in e.external && typeof e.external.notify == "function";
|
|
485
485
|
}
|
|
486
|
-
function
|
|
487
|
-
return "TelegramWebviewProxy" in e &&
|
|
486
|
+
function ut(e) {
|
|
487
|
+
return "TelegramWebviewProxy" in e && T(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
|
|
488
488
|
}
|
|
489
|
-
function
|
|
489
|
+
function oe() {
|
|
490
490
|
try {
|
|
491
491
|
return window.self !== window.top;
|
|
492
492
|
} catch {
|
|
493
493
|
return !0;
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
|
-
let
|
|
497
|
-
function
|
|
498
|
-
|
|
496
|
+
let lt = "https://web.telegram.org";
|
|
497
|
+
function ts(e) {
|
|
498
|
+
lt = e;
|
|
499
499
|
}
|
|
500
|
-
function
|
|
501
|
-
return
|
|
500
|
+
function ae() {
|
|
501
|
+
return lt;
|
|
502
502
|
}
|
|
503
|
-
function
|
|
503
|
+
function R(e, t, s) {
|
|
504
504
|
let n = {}, r;
|
|
505
505
|
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);
|
|
506
|
-
const { targetOrigin: i =
|
|
507
|
-
if (
|
|
506
|
+
const { targetOrigin: i = ae() } = n;
|
|
507
|
+
if (Lt("Posting event:", r ? { event: e, data: r } : { event: e }), oe()) {
|
|
508
508
|
window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
|
|
509
509
|
return;
|
|
510
510
|
}
|
|
511
|
-
if (
|
|
511
|
+
if (ie(window)) {
|
|
512
512
|
window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
|
|
513
513
|
return;
|
|
514
514
|
}
|
|
515
|
-
if (
|
|
515
|
+
if (ut(window)) {
|
|
516
516
|
window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
|
|
517
517
|
return;
|
|
518
518
|
}
|
|
519
|
-
throw
|
|
520
|
-
|
|
519
|
+
throw f(
|
|
520
|
+
Ut,
|
|
521
521
|
"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."
|
|
522
522
|
);
|
|
523
523
|
}
|
|
524
|
-
function
|
|
524
|
+
function ce(e) {
|
|
525
525
|
return (t, s) => {
|
|
526
526
|
if (!v(t, e))
|
|
527
|
-
throw
|
|
528
|
-
if (
|
|
527
|
+
throw f(Bt, `Method "${t}" is unsupported in Mini Apps version ${e}`);
|
|
528
|
+
if (T(s)) {
|
|
529
529
|
let n;
|
|
530
530
|
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 && !v(t, n, e))
|
|
531
|
-
throw
|
|
532
|
-
|
|
531
|
+
throw f(
|
|
532
|
+
Ot,
|
|
533
533
|
`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
|
|
534
534
|
);
|
|
535
535
|
}
|
|
536
|
-
return
|
|
536
|
+
return R(t, s);
|
|
537
537
|
};
|
|
538
538
|
}
|
|
539
|
-
function
|
|
539
|
+
function dt(e) {
|
|
540
540
|
return ({ req_id: t }) => t === e;
|
|
541
541
|
}
|
|
542
|
-
function
|
|
543
|
-
return
|
|
542
|
+
function _t(e) {
|
|
543
|
+
return f(Ht, `Timeout reached: ${e}ms`);
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function ft(e, t) {
|
|
546
546
|
return Promise.race([
|
|
547
547
|
typeof e == "function" ? e() : e,
|
|
548
548
|
new Promise((s, n) => {
|
|
549
549
|
setTimeout(() => {
|
|
550
|
-
n(
|
|
550
|
+
n(_t(t));
|
|
551
551
|
}, t);
|
|
552
552
|
})
|
|
553
553
|
]);
|
|
554
554
|
}
|
|
555
|
-
async function
|
|
555
|
+
async function _(e) {
|
|
556
556
|
let t;
|
|
557
|
-
const s = new Promise((
|
|
558
|
-
t =
|
|
557
|
+
const s = new Promise((u) => {
|
|
558
|
+
t = u;
|
|
559
559
|
}), {
|
|
560
560
|
method: n,
|
|
561
561
|
event: r,
|
|
562
562
|
capture: i,
|
|
563
|
-
postEvent:
|
|
564
|
-
timeout:
|
|
563
|
+
postEvent: a = R,
|
|
564
|
+
timeout: o
|
|
565
565
|
} = e, p = (Array.isArray(r) ? r : [r]).map(
|
|
566
|
-
(
|
|
566
|
+
(u) => b(u, (q) => (!i || i(q)) && t(q))
|
|
567
567
|
);
|
|
568
568
|
try {
|
|
569
|
-
return
|
|
569
|
+
return a(n, e.params), await (o ? ft(s, o) : s);
|
|
570
570
|
} finally {
|
|
571
|
-
p.forEach((
|
|
571
|
+
p.forEach((u) => u());
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
|
-
async function
|
|
574
|
+
async function C(e, t, s, n = {}) {
|
|
575
575
|
const {
|
|
576
576
|
result: r,
|
|
577
577
|
error: i
|
|
578
|
-
} = await
|
|
578
|
+
} = await _({
|
|
579
579
|
...n,
|
|
580
580
|
method: "web_app_invoke_custom_method",
|
|
581
581
|
event: "custom_method_invoked",
|
|
@@ -584,30 +584,30 @@ async function R(e, t, s, n = {}) {
|
|
|
584
584
|
params: t,
|
|
585
585
|
req_id: s
|
|
586
586
|
},
|
|
587
|
-
capture:
|
|
587
|
+
capture: dt(s)
|
|
588
588
|
});
|
|
589
589
|
if (i)
|
|
590
|
-
throw
|
|
590
|
+
throw f(Wt, i);
|
|
591
591
|
return r;
|
|
592
592
|
}
|
|
593
|
-
function
|
|
593
|
+
function z(...e) {
|
|
594
594
|
return e.map((t) => {
|
|
595
595
|
if (typeof t == "string")
|
|
596
596
|
return t;
|
|
597
|
-
if (
|
|
598
|
-
return
|
|
597
|
+
if (T(t))
|
|
598
|
+
return z(Object.entries(t).map((s) => s[1] && s[0]));
|
|
599
599
|
if (Array.isArray(t))
|
|
600
|
-
return
|
|
600
|
+
return z(...t);
|
|
601
601
|
}).filter(Boolean).join(" ");
|
|
602
602
|
}
|
|
603
|
-
function
|
|
604
|
-
return e.reduce((t, s) => (
|
|
605
|
-
const i =
|
|
603
|
+
function es(...e) {
|
|
604
|
+
return e.reduce((t, s) => (T(s) && Object.entries(s).forEach(([n, r]) => {
|
|
605
|
+
const i = z(t[n], r);
|
|
606
606
|
i.length && (t[n] = i);
|
|
607
607
|
}), t), {});
|
|
608
608
|
}
|
|
609
|
-
function
|
|
610
|
-
const t =
|
|
609
|
+
function gt(e) {
|
|
610
|
+
const t = ht(e);
|
|
611
611
|
return Math.sqrt(
|
|
612
612
|
[0.299, 0.587, 0.114].reduce((s, n, r) => {
|
|
613
613
|
const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
|
|
@@ -615,9 +615,9 @@ function mt(e) {
|
|
|
615
615
|
}, 0)
|
|
616
616
|
) < 120;
|
|
617
617
|
}
|
|
618
|
-
class
|
|
618
|
+
class he {
|
|
619
619
|
constructor(t) {
|
|
620
|
-
c(this, "ee", new
|
|
620
|
+
c(this, "ee", new D());
|
|
621
621
|
/**
|
|
622
622
|
* Adds new event listener.
|
|
623
623
|
*/
|
|
@@ -635,7 +635,7 @@ class _e {
|
|
|
635
635
|
return { ...this.state };
|
|
636
636
|
}
|
|
637
637
|
set(t, s) {
|
|
638
|
-
Object.entries(typeof t == "string" ? { [t]: s } : t).reduce((r, [i,
|
|
638
|
+
Object.entries(typeof t == "string" ? { [t]: s } : t).reduce((r, [i, a]) => this.state[i] === a || a === void 0 ? r : (this.state[i] = a, this.ee.emit(`change:${i}`, a), !0), !1) && this.ee.emit("change", this.state);
|
|
639
639
|
}
|
|
640
640
|
/**
|
|
641
641
|
* Returns value by specified key.
|
|
@@ -645,7 +645,7 @@ class _e {
|
|
|
645
645
|
return this.state[t];
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
|
-
class
|
|
648
|
+
class Y {
|
|
649
649
|
constructor(t) {
|
|
650
650
|
c(this, "state");
|
|
651
651
|
/**
|
|
@@ -660,23 +660,23 @@ class Z {
|
|
|
660
660
|
* Clones the current state.
|
|
661
661
|
*/
|
|
662
662
|
c(this, "clone");
|
|
663
|
-
this.state = new
|
|
663
|
+
this.state = new he(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);
|
|
664
664
|
}
|
|
665
665
|
}
|
|
666
|
-
function
|
|
666
|
+
function bt(e, t) {
|
|
667
667
|
return (s) => v(t[s], e);
|
|
668
668
|
}
|
|
669
|
-
class
|
|
669
|
+
class Z extends Y {
|
|
670
670
|
constructor(s, n, r) {
|
|
671
671
|
super(s);
|
|
672
672
|
/**
|
|
673
673
|
* @returns True, if specified method is supported by the current component.
|
|
674
674
|
*/
|
|
675
675
|
c(this, "supports");
|
|
676
|
-
this.supports =
|
|
676
|
+
this.supports = bt(n, r);
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
|
-
class
|
|
679
|
+
class pe extends Z {
|
|
680
680
|
constructor(s, n, r) {
|
|
681
681
|
super({ isVisible: s }, n, {
|
|
682
682
|
show: "web_app_setup_back_button",
|
|
@@ -693,7 +693,7 @@ class fe extends X {
|
|
|
693
693
|
* @param event - event to listen.
|
|
694
694
|
* @param listener - listener to remove.
|
|
695
695
|
*/
|
|
696
|
-
c(this, "off", (s, n) => s === "click" ?
|
|
696
|
+
c(this, "off", (s, n) => s === "click" ? L("back_button_pressed", n) : this.state.off(s, n));
|
|
697
697
|
this.postEvent = r;
|
|
698
698
|
}
|
|
699
699
|
set isVisible(s) {
|
|
@@ -718,22 +718,19 @@ class fe extends X {
|
|
|
718
718
|
this.isVisible = !0;
|
|
719
719
|
}
|
|
720
720
|
}
|
|
721
|
-
|
|
722
|
-
return typeof window > "u";
|
|
723
|
-
}
|
|
724
|
-
const vt = S((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
|
|
721
|
+
const wt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
|
|
725
722
|
function K(e, t) {
|
|
726
|
-
return new
|
|
723
|
+
return new $((s) => {
|
|
727
724
|
if (typeof s != "string" && !(s instanceof URLSearchParams))
|
|
728
|
-
throw
|
|
725
|
+
throw E();
|
|
729
726
|
const n = typeof s == "string" ? new URLSearchParams(s) : s;
|
|
730
|
-
return
|
|
727
|
+
return ct(e, (r) => {
|
|
731
728
|
const i = n.get(r);
|
|
732
729
|
return i === null ? void 0 : i;
|
|
733
730
|
});
|
|
734
731
|
}, !1, t);
|
|
735
732
|
}
|
|
736
|
-
const
|
|
733
|
+
const ue = d({
|
|
737
734
|
id: y(),
|
|
738
735
|
type: h(),
|
|
739
736
|
title: h(),
|
|
@@ -742,7 +739,7 @@ const ge = _({
|
|
|
742
739
|
from: "photo_url"
|
|
743
740
|
},
|
|
744
741
|
username: h().optional()
|
|
745
|
-
}, "Chat").optional(),
|
|
742
|
+
}, "Chat").optional(), st = d({
|
|
746
743
|
addedToAttachmentMenu: {
|
|
747
744
|
type: w().optional(),
|
|
748
745
|
from: "added_to_attachment_menu"
|
|
@@ -778,17 +775,17 @@ const ge = _({
|
|
|
778
775
|
},
|
|
779
776
|
username: h().optional()
|
|
780
777
|
}, "User").optional();
|
|
781
|
-
function
|
|
778
|
+
function mt() {
|
|
782
779
|
return K({
|
|
783
780
|
authDate: {
|
|
784
|
-
type:
|
|
781
|
+
type: wt(),
|
|
785
782
|
from: "auth_date"
|
|
786
783
|
},
|
|
787
784
|
canSendAfter: {
|
|
788
785
|
type: y().optional(),
|
|
789
786
|
from: "can_send_after"
|
|
790
787
|
},
|
|
791
|
-
chat:
|
|
788
|
+
chat: ue,
|
|
792
789
|
chatInstance: {
|
|
793
790
|
type: h().optional(),
|
|
794
791
|
from: "chat_instance"
|
|
@@ -802,35 +799,35 @@ function Et() {
|
|
|
802
799
|
type: h().optional(),
|
|
803
800
|
from: "query_id"
|
|
804
801
|
},
|
|
805
|
-
receiver:
|
|
802
|
+
receiver: st,
|
|
806
803
|
startParam: {
|
|
807
804
|
type: h().optional(),
|
|
808
805
|
from: "start_param"
|
|
809
806
|
},
|
|
810
|
-
user:
|
|
807
|
+
user: st
|
|
811
808
|
}, "InitData");
|
|
812
809
|
}
|
|
813
|
-
function
|
|
810
|
+
function le(e) {
|
|
814
811
|
return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
|
|
815
812
|
}
|
|
816
|
-
function
|
|
813
|
+
function de(e) {
|
|
817
814
|
return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
|
|
818
815
|
}
|
|
819
|
-
const
|
|
816
|
+
const yt = P(
|
|
820
817
|
(e) => {
|
|
821
|
-
const t =
|
|
822
|
-
return Object.entries(
|
|
818
|
+
const t = pt().optional();
|
|
819
|
+
return Object.entries(J(e)).reduce((s, [n, r]) => (s[le(n)] = t.parse(r), s), {});
|
|
823
820
|
},
|
|
824
821
|
"ThemeParams"
|
|
825
822
|
);
|
|
826
|
-
function
|
|
823
|
+
function vt(e) {
|
|
827
824
|
return K({
|
|
828
825
|
botInline: {
|
|
829
826
|
type: w().optional(),
|
|
830
827
|
from: "tgWebAppBotInline"
|
|
831
828
|
},
|
|
832
829
|
initData: {
|
|
833
|
-
type:
|
|
830
|
+
type: mt().optional(),
|
|
834
831
|
from: "tgWebAppData"
|
|
835
832
|
},
|
|
836
833
|
initDataRaw: {
|
|
@@ -850,7 +847,7 @@ function St(e) {
|
|
|
850
847
|
from: "tgWebAppStartParam"
|
|
851
848
|
},
|
|
852
849
|
themeParams: {
|
|
853
|
-
type:
|
|
850
|
+
type: yt(),
|
|
854
851
|
from: "tgWebAppThemeParams"
|
|
855
852
|
},
|
|
856
853
|
version: {
|
|
@@ -859,126 +856,131 @@ function St(e) {
|
|
|
859
856
|
}
|
|
860
857
|
}).parse(e);
|
|
861
858
|
}
|
|
862
|
-
function
|
|
863
|
-
return
|
|
859
|
+
function Et(e) {
|
|
860
|
+
return vt(
|
|
864
861
|
e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
|
|
865
862
|
);
|
|
866
863
|
}
|
|
867
|
-
function
|
|
868
|
-
return
|
|
864
|
+
function _e() {
|
|
865
|
+
return Et(window.location.href);
|
|
869
866
|
}
|
|
870
|
-
function
|
|
867
|
+
function Pt() {
|
|
871
868
|
return performance.getEntriesByType("navigation")[0];
|
|
872
869
|
}
|
|
873
|
-
function
|
|
874
|
-
const e =
|
|
870
|
+
function fe() {
|
|
871
|
+
const e = Pt();
|
|
875
872
|
if (!e)
|
|
876
873
|
throw new Error("Unable to get first navigation entry.");
|
|
877
|
-
return
|
|
874
|
+
return Et(e.name);
|
|
878
875
|
}
|
|
879
|
-
function
|
|
876
|
+
function xt(e) {
|
|
880
877
|
return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
|
|
881
878
|
}
|
|
882
|
-
function
|
|
883
|
-
sessionStorage.setItem(
|
|
879
|
+
function Ct(e, t) {
|
|
880
|
+
sessionStorage.setItem(xt(e), JSON.stringify(t));
|
|
884
881
|
}
|
|
885
|
-
function
|
|
886
|
-
const t = sessionStorage.getItem(
|
|
882
|
+
function St(e) {
|
|
883
|
+
const t = sessionStorage.getItem(xt(e));
|
|
887
884
|
try {
|
|
888
885
|
return t ? JSON.parse(t) : void 0;
|
|
889
886
|
} catch {
|
|
890
887
|
}
|
|
891
888
|
}
|
|
892
|
-
function
|
|
893
|
-
return St(
|
|
889
|
+
function ge() {
|
|
890
|
+
return vt(St("launchParams") || "");
|
|
894
891
|
}
|
|
895
|
-
function
|
|
892
|
+
function be(e) {
|
|
896
893
|
return JSON.stringify(
|
|
897
894
|
Object.fromEntries(
|
|
898
|
-
Object.entries(e).map(([t, s]) => [
|
|
895
|
+
Object.entries(e).map(([t, s]) => [de(t), s])
|
|
899
896
|
)
|
|
900
897
|
);
|
|
901
898
|
}
|
|
902
|
-
function
|
|
899
|
+
function we(e) {
|
|
903
900
|
const {
|
|
904
901
|
initDataRaw: t,
|
|
905
902
|
themeParams: s,
|
|
906
903
|
platform: n,
|
|
907
904
|
version: r,
|
|
908
905
|
showSettings: i,
|
|
909
|
-
startParam:
|
|
910
|
-
botInline:
|
|
906
|
+
startParam: a,
|
|
907
|
+
botInline: o
|
|
911
908
|
} = e, p = new URLSearchParams();
|
|
912
|
-
return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams",
|
|
909
|
+
return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", be(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();
|
|
913
910
|
}
|
|
914
|
-
function
|
|
915
|
-
|
|
911
|
+
function me(e) {
|
|
912
|
+
Ct("launchParams", we(e));
|
|
916
913
|
}
|
|
917
|
-
function
|
|
914
|
+
function ye() {
|
|
918
915
|
for (const e of [
|
|
919
916
|
// Try to retrieve launch parameters from the current location. This method can return
|
|
920
917
|
// nothing in case, location was changed and then page was reloaded.
|
|
921
|
-
|
|
918
|
+
_e,
|
|
922
919
|
// Then, try using the lower level API - window.performance.
|
|
923
|
-
|
|
920
|
+
fe,
|
|
924
921
|
// Finally, try to extract launch parameters from the session storage.
|
|
925
|
-
|
|
922
|
+
ge
|
|
926
923
|
])
|
|
927
924
|
try {
|
|
928
925
|
const t = e();
|
|
929
|
-
return
|
|
926
|
+
return me(t), t;
|
|
930
927
|
} catch {
|
|
931
928
|
}
|
|
932
929
|
throw new Error("Unable to retrieve launch parameters from any known source.");
|
|
933
930
|
}
|
|
934
|
-
function
|
|
935
|
-
const e =
|
|
931
|
+
function Rt() {
|
|
932
|
+
const e = Pt();
|
|
936
933
|
return !!(e && e.type === "reload");
|
|
937
934
|
}
|
|
938
|
-
function
|
|
935
|
+
function ve() {
|
|
939
936
|
let e = 0;
|
|
940
937
|
return () => (e += 1).toString();
|
|
941
938
|
}
|
|
942
|
-
|
|
939
|
+
function Ee() {
|
|
940
|
+
let e = !1;
|
|
941
|
+
const t = [];
|
|
942
|
+
return [
|
|
943
|
+
(s) => !e && t.push(s),
|
|
944
|
+
() => {
|
|
945
|
+
e || (e = !0, t.forEach((s) => s()));
|
|
946
|
+
},
|
|
947
|
+
e
|
|
948
|
+
];
|
|
949
|
+
}
|
|
950
|
+
const [Pe] = it(ve);
|
|
943
951
|
function l(e, t) {
|
|
944
|
-
return (
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
J,
|
|
950
|
-
"ssr.options must be specified to initialize component on the server side"
|
|
951
|
-
);
|
|
952
|
-
n = s;
|
|
953
|
-
} else
|
|
954
|
-
n = xe();
|
|
955
|
-
const r = {
|
|
956
|
-
...n,
|
|
957
|
-
postEvent: "version" in n ? de(n.version) : () => {
|
|
958
|
-
throw u(
|
|
959
|
-
Zt,
|
|
960
|
-
"postEvent function is forbidden to be called on the server side."
|
|
961
|
-
);
|
|
962
|
-
},
|
|
963
|
-
createRequestId: Ce()
|
|
952
|
+
return () => {
|
|
953
|
+
const s = ye(), n = {
|
|
954
|
+
...s,
|
|
955
|
+
postEvent: ce(s.version),
|
|
956
|
+
createRequestId: Pe()
|
|
964
957
|
};
|
|
965
|
-
if (
|
|
966
|
-
return
|
|
967
|
-
const i = t({
|
|
968
|
-
...
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
958
|
+
if (typeof e == "function")
|
|
959
|
+
return e(n);
|
|
960
|
+
const [r, i, a] = Ee(), o = t({
|
|
961
|
+
...n,
|
|
962
|
+
// State should only be passed only in case, current page was reloaded. If we don't add
|
|
963
|
+
// this check, state restoration will work improperly in the web version of Telegram,
|
|
964
|
+
// when we are always working in the same "session" (tab).
|
|
965
|
+
state: Rt() ? St(e) : void 0,
|
|
966
|
+
addCleanup: r
|
|
967
|
+
}), p = (u) => (a || r(
|
|
968
|
+
u.on("change", (q) => {
|
|
969
|
+
Ct(e, q);
|
|
970
|
+
})
|
|
971
|
+
), u);
|
|
972
|
+
return [
|
|
973
|
+
o instanceof Promise ? o.then(p) : p(o),
|
|
974
|
+
i
|
|
975
|
+
];
|
|
974
976
|
};
|
|
975
977
|
}
|
|
976
|
-
const
|
|
978
|
+
const ss = l("backButton", ({
|
|
977
979
|
postEvent: e,
|
|
978
980
|
version: t,
|
|
979
981
|
state: s = { isVisible: !1 }
|
|
980
|
-
}) => new
|
|
981
|
-
class
|
|
982
|
+
}) => new pe(s.isVisible, t, e));
|
|
983
|
+
class I extends Z {
|
|
982
984
|
constructor() {
|
|
983
985
|
super(...arguments);
|
|
984
986
|
/**
|
|
@@ -991,7 +993,7 @@ class q extends X {
|
|
|
991
993
|
c(this, "off", this.state.off.bind(this.state));
|
|
992
994
|
}
|
|
993
995
|
}
|
|
994
|
-
function
|
|
996
|
+
function At(e) {
|
|
995
997
|
const t = e.available ? e : {
|
|
996
998
|
available: !1,
|
|
997
999
|
device_id: "",
|
|
@@ -1009,7 +1011,7 @@ function qt(e) {
|
|
|
1009
1011
|
accessGranted: t.access_granted
|
|
1010
1012
|
};
|
|
1011
1013
|
}
|
|
1012
|
-
class
|
|
1014
|
+
class xe extends I {
|
|
1013
1015
|
constructor({ postEvent: s, version: n, ...r }) {
|
|
1014
1016
|
super(r, n, {
|
|
1015
1017
|
auth: "web_app_biometry_request_auth",
|
|
@@ -1050,7 +1052,7 @@ class it extends q {
|
|
|
1050
1052
|
reason: s,
|
|
1051
1053
|
...n
|
|
1052
1054
|
}) {
|
|
1053
|
-
return this.authPromise || (this.authPromise =
|
|
1055
|
+
return this.authPromise || (this.authPromise = _({
|
|
1054
1056
|
...n,
|
|
1055
1057
|
method: "web_app_biometry_request_auth",
|
|
1056
1058
|
event: "biometry_auth_requested",
|
|
@@ -1084,14 +1086,14 @@ class it extends q {
|
|
|
1084
1086
|
* @returns Promise with true, if access was granted.
|
|
1085
1087
|
*/
|
|
1086
1088
|
requestAccess({ reason: s, ...n } = {}) {
|
|
1087
|
-
return this.accessPromise || (this.accessPromise =
|
|
1089
|
+
return this.accessPromise || (this.accessPromise = _({
|
|
1088
1090
|
...n,
|
|
1089
1091
|
postEvent: this.postEvent,
|
|
1090
1092
|
method: "web_app_biometry_request_access",
|
|
1091
1093
|
event: "biometry_info_received",
|
|
1092
1094
|
params: { reason: s || "" }
|
|
1093
1095
|
}).then((r) => {
|
|
1094
|
-
const i =
|
|
1096
|
+
const i = At(r);
|
|
1095
1097
|
return this.set(i), i.accessGranted;
|
|
1096
1098
|
}).finally(() => this.accessPromise = void 0)), this.accessPromise;
|
|
1097
1099
|
}
|
|
@@ -1113,7 +1115,7 @@ class it extends q {
|
|
|
1113
1115
|
*/
|
|
1114
1116
|
async updateToken({ token: s, ...n } = {}) {
|
|
1115
1117
|
return ["removed", "updated"].includes(
|
|
1116
|
-
(await
|
|
1118
|
+
(await _({
|
|
1117
1119
|
...n,
|
|
1118
1120
|
postEvent: this.postEvent,
|
|
1119
1121
|
method: "web_app_biometry_update_token",
|
|
@@ -1123,30 +1125,24 @@ class it extends q {
|
|
|
1123
1125
|
);
|
|
1124
1126
|
}
|
|
1125
1127
|
}
|
|
1126
|
-
async function
|
|
1127
|
-
return
|
|
1128
|
-
await
|
|
1128
|
+
async function Ce(e) {
|
|
1129
|
+
return At(
|
|
1130
|
+
await _({
|
|
1129
1131
|
...e || {},
|
|
1130
1132
|
method: "web_app_biometry_get_info",
|
|
1131
1133
|
event: "biometry_info_received"
|
|
1132
1134
|
})
|
|
1133
1135
|
);
|
|
1134
1136
|
}
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
throw u(
|
|
1140
|
-
J,
|
|
1141
|
-
"BiometryManager cannot be instantiated on the server side without passing the ssr.state object."
|
|
1142
|
-
);
|
|
1143
|
-
return new it({
|
|
1144
|
-
...await Te({ timeout: 1e3 }),
|
|
1137
|
+
const ns = l(
|
|
1138
|
+
"biometryManager",
|
|
1139
|
+
async ({ postEvent: e, version: t, state: s }) => new xe({
|
|
1140
|
+
...s || await Ce({ timeout: 1e3 }),
|
|
1145
1141
|
version: t,
|
|
1146
1142
|
postEvent: e
|
|
1147
|
-
})
|
|
1148
|
-
|
|
1149
|
-
class
|
|
1143
|
+
})
|
|
1144
|
+
);
|
|
1145
|
+
class X extends Y {
|
|
1150
1146
|
constructor() {
|
|
1151
1147
|
super(...arguments);
|
|
1152
1148
|
/**
|
|
@@ -1159,7 +1155,7 @@ class tt extends Z {
|
|
|
1159
1155
|
c(this, "off", this.state.off.bind(this.state));
|
|
1160
1156
|
}
|
|
1161
1157
|
}
|
|
1162
|
-
class
|
|
1158
|
+
class Se extends X {
|
|
1163
1159
|
constructor(t, s) {
|
|
1164
1160
|
super({ isConfirmationNeeded: t }), this.postEvent = s;
|
|
1165
1161
|
}
|
|
@@ -1186,20 +1182,23 @@ class Ae extends tt {
|
|
|
1186
1182
|
this.isConfirmationNeeded = !0;
|
|
1187
1183
|
}
|
|
1188
1184
|
}
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1185
|
+
const rs = l(
|
|
1186
|
+
"closingBehavior",
|
|
1187
|
+
({
|
|
1188
|
+
postEvent: e,
|
|
1189
|
+
state: t = { isConfirmationNeeded: !1 }
|
|
1190
|
+
}) => new Se(t.isConfirmationNeeded, e)
|
|
1191
|
+
);
|
|
1192
|
+
class tt {
|
|
1194
1193
|
constructor(t, s) {
|
|
1195
1194
|
/**
|
|
1196
1195
|
* @returns True, if specified method is supported by the current component.
|
|
1197
1196
|
*/
|
|
1198
1197
|
c(this, "supports");
|
|
1199
|
-
this.supports =
|
|
1198
|
+
this.supports = bt(t, s);
|
|
1200
1199
|
}
|
|
1201
1200
|
}
|
|
1202
|
-
function
|
|
1201
|
+
function Re(e) {
|
|
1203
1202
|
if (Array.isArray(e))
|
|
1204
1203
|
return e;
|
|
1205
1204
|
if (typeof e == "string")
|
|
@@ -1209,11 +1208,11 @@ function Ie(e) {
|
|
|
1209
1208
|
return t;
|
|
1210
1209
|
} catch {
|
|
1211
1210
|
}
|
|
1212
|
-
throw
|
|
1211
|
+
throw E();
|
|
1213
1212
|
}
|
|
1214
|
-
class
|
|
1213
|
+
class Ae extends $ {
|
|
1215
1214
|
constructor(s, n, r) {
|
|
1216
|
-
super(
|
|
1215
|
+
super(Re, n, r);
|
|
1217
1216
|
c(this, "itemParser");
|
|
1218
1217
|
this.itemParser = typeof s == "function" ? s : s.parse.bind(s);
|
|
1219
1218
|
}
|
|
@@ -1231,13 +1230,13 @@ class qe extends M {
|
|
|
1231
1230
|
return this.itemParser = typeof s == "function" ? s : s.parse.bind(s), this;
|
|
1232
1231
|
}
|
|
1233
1232
|
}
|
|
1234
|
-
function
|
|
1235
|
-
return new
|
|
1233
|
+
function Te(e) {
|
|
1234
|
+
return new Ae((t) => t, !1, e);
|
|
1236
1235
|
}
|
|
1237
|
-
function
|
|
1236
|
+
function nt(e, t) {
|
|
1238
1237
|
return Object.fromEntries(e.map((s) => [s, t]));
|
|
1239
1238
|
}
|
|
1240
|
-
class
|
|
1239
|
+
class Ie extends tt {
|
|
1241
1240
|
constructor(t, s, n) {
|
|
1242
1241
|
super(t, {
|
|
1243
1242
|
delete: "web_app_invoke_custom_method",
|
|
@@ -1253,7 +1252,7 @@ class Ne extends et {
|
|
|
1253
1252
|
*/
|
|
1254
1253
|
async delete(t, s = {}) {
|
|
1255
1254
|
const n = Array.isArray(t) ? t : [t];
|
|
1256
|
-
n.length && await
|
|
1255
|
+
n.length && await C(
|
|
1257
1256
|
"deleteStorageValues",
|
|
1258
1257
|
{ keys: n },
|
|
1259
1258
|
this.createRequestId(),
|
|
@@ -1265,8 +1264,8 @@ class Ne extends et {
|
|
|
1265
1264
|
* @param options - request execution options.
|
|
1266
1265
|
*/
|
|
1267
1266
|
async getKeys(t = {}) {
|
|
1268
|
-
return
|
|
1269
|
-
await
|
|
1267
|
+
return Te().of(h()).parse(
|
|
1268
|
+
await C(
|
|
1270
1269
|
"getStorageKeys",
|
|
1271
1270
|
{},
|
|
1272
1271
|
this.createRequestId(),
|
|
@@ -1277,13 +1276,13 @@ class Ne extends et {
|
|
|
1277
1276
|
async get(t, s = {}) {
|
|
1278
1277
|
const n = Array.isArray(t) ? t : [t];
|
|
1279
1278
|
if (!n.length)
|
|
1280
|
-
return
|
|
1281
|
-
const r = await
|
|
1279
|
+
return nt(n, "");
|
|
1280
|
+
const r = await C(
|
|
1282
1281
|
"getStorageValues",
|
|
1283
1282
|
{ keys: n },
|
|
1284
1283
|
this.createRequestId(),
|
|
1285
1284
|
{ ...s, postEvent: this.postEvent }
|
|
1286
|
-
), i =
|
|
1285
|
+
), i = d(nt(n, h()), "CloudStorageData").parse(r);
|
|
1287
1286
|
return Array.isArray(t) ? i : i[t];
|
|
1288
1287
|
}
|
|
1289
1288
|
/**
|
|
@@ -1293,7 +1292,7 @@ class Ne extends et {
|
|
|
1293
1292
|
* @param options - request execution options.
|
|
1294
1293
|
*/
|
|
1295
1294
|
async set(t, s, n = {}) {
|
|
1296
|
-
await
|
|
1295
|
+
await C(
|
|
1297
1296
|
"saveStorageValue",
|
|
1298
1297
|
{ key: t, value: s },
|
|
1299
1298
|
this.createRequestId(),
|
|
@@ -1301,10 +1300,10 @@ class Ne extends et {
|
|
|
1301
1300
|
);
|
|
1302
1301
|
}
|
|
1303
1302
|
}
|
|
1304
|
-
const
|
|
1305
|
-
({ createRequestId: e, postEvent: t, version: s }) => new
|
|
1303
|
+
const is = l(
|
|
1304
|
+
({ createRequestId: e, postEvent: t, version: s }) => new Ie(s, e, t)
|
|
1306
1305
|
);
|
|
1307
|
-
class
|
|
1306
|
+
class qe extends tt {
|
|
1308
1307
|
constructor(t, s) {
|
|
1309
1308
|
super(t, {
|
|
1310
1309
|
impactOccurred: "web_app_trigger_haptic_feedback",
|
|
@@ -1346,10 +1345,10 @@ class De extends et {
|
|
|
1346
1345
|
this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
|
|
1347
1346
|
}
|
|
1348
1347
|
}
|
|
1349
|
-
const
|
|
1350
|
-
({ version: e, postEvent: t }) => new
|
|
1348
|
+
const os = l(
|
|
1349
|
+
({ version: e, postEvent: t }) => new qe(e, t)
|
|
1351
1350
|
);
|
|
1352
|
-
class
|
|
1351
|
+
class ke {
|
|
1353
1352
|
constructor(t) {
|
|
1354
1353
|
this.initData = t;
|
|
1355
1354
|
}
|
|
@@ -1422,13 +1421,13 @@ class Ve {
|
|
|
1422
1421
|
return this.initData.user;
|
|
1423
1422
|
}
|
|
1424
1423
|
}
|
|
1425
|
-
const
|
|
1426
|
-
({ initData: e }) => e ? new
|
|
1424
|
+
const as = l(
|
|
1425
|
+
({ initData: e }) => e ? new ke(e) : void 0
|
|
1427
1426
|
);
|
|
1428
|
-
function
|
|
1429
|
-
return
|
|
1427
|
+
function cs(e) {
|
|
1428
|
+
return mt().parse(e);
|
|
1430
1429
|
}
|
|
1431
|
-
class
|
|
1430
|
+
class Ne extends I {
|
|
1432
1431
|
constructor(t, s, n) {
|
|
1433
1432
|
super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
|
|
1434
1433
|
}
|
|
@@ -1451,14 +1450,14 @@ class $e extends q {
|
|
|
1451
1450
|
const { hostname: r, pathname: i } = new URL(t, window.location.href);
|
|
1452
1451
|
if (r !== "t.me")
|
|
1453
1452
|
throw new Error(`Incorrect hostname: ${r}`);
|
|
1454
|
-
const
|
|
1455
|
-
if (!
|
|
1453
|
+
const a = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
|
|
1454
|
+
if (!a)
|
|
1456
1455
|
throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
|
|
1457
|
-
[, , n] =
|
|
1456
|
+
[, , n] = a;
|
|
1458
1457
|
}
|
|
1459
1458
|
this.isOpened = !0;
|
|
1460
1459
|
try {
|
|
1461
|
-
return (await
|
|
1460
|
+
return (await _({
|
|
1462
1461
|
method: "web_app_open_invoice",
|
|
1463
1462
|
event: "invoice_closed",
|
|
1464
1463
|
params: { slug: n },
|
|
@@ -1472,10 +1471,10 @@ class $e extends q {
|
|
|
1472
1471
|
}
|
|
1473
1472
|
}
|
|
1474
1473
|
}
|
|
1475
|
-
const
|
|
1476
|
-
({ version: e, postEvent: t }) => new
|
|
1474
|
+
const hs = l(
|
|
1475
|
+
({ version: e, postEvent: t }) => new Ne(!1, e, t)
|
|
1477
1476
|
);
|
|
1478
|
-
class
|
|
1477
|
+
class De extends Y {
|
|
1479
1478
|
constructor({ postEvent: s, ...n }) {
|
|
1480
1479
|
super(n);
|
|
1481
1480
|
c(this, "postEvent");
|
|
@@ -1490,7 +1489,7 @@ class Me extends Z {
|
|
|
1490
1489
|
* @param event - event to listen.
|
|
1491
1490
|
* @param listener - listener to remove.
|
|
1492
1491
|
*/
|
|
1493
|
-
c(this, "off", (s, n) => s === "click" ?
|
|
1492
|
+
c(this, "off", (s, n) => s === "click" ? L("main_button_pressed", n) : this.state.off(s, n));
|
|
1494
1493
|
this.postEvent = s;
|
|
1495
1494
|
}
|
|
1496
1495
|
/**
|
|
@@ -1620,21 +1619,24 @@ class Me extends Z {
|
|
|
1620
1619
|
return this.set(s), this.commit(), this;
|
|
1621
1620
|
}
|
|
1622
1621
|
}
|
|
1623
|
-
const
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1622
|
+
const ps = l(
|
|
1623
|
+
"mainButton",
|
|
1624
|
+
({
|
|
1625
|
+
postEvent: e,
|
|
1626
|
+
themeParams: t,
|
|
1627
|
+
state: s = {
|
|
1628
|
+
isVisible: !1,
|
|
1629
|
+
isEnabled: !1,
|
|
1630
|
+
text: "",
|
|
1631
|
+
isLoaderVisible: !1,
|
|
1632
|
+
textColor: t.buttonTextColor || "#ffffff",
|
|
1633
|
+
backgroundColor: t.buttonColor || "#000000"
|
|
1634
|
+
}
|
|
1635
|
+
}) => new De({ ...s, postEvent: e })
|
|
1636
|
+
);
|
|
1637
|
+
function Ve() {
|
|
1636
1638
|
return K({
|
|
1637
|
-
contact:
|
|
1639
|
+
contact: d({
|
|
1638
1640
|
userId: {
|
|
1639
1641
|
type: y(),
|
|
1640
1642
|
from: "user_id"
|
|
@@ -1653,26 +1655,26 @@ function Le() {
|
|
|
1653
1655
|
}
|
|
1654
1656
|
}),
|
|
1655
1657
|
authDate: {
|
|
1656
|
-
type:
|
|
1658
|
+
type: wt(),
|
|
1657
1659
|
from: "auth_date"
|
|
1658
1660
|
},
|
|
1659
1661
|
hash: h()
|
|
1660
1662
|
}, "RequestedContact");
|
|
1661
1663
|
}
|
|
1662
|
-
function
|
|
1664
|
+
function Tt(e, t) {
|
|
1663
1665
|
return (s) => {
|
|
1664
1666
|
const [n, r] = t[s];
|
|
1665
1667
|
return v(n, r, e);
|
|
1666
1668
|
};
|
|
1667
1669
|
}
|
|
1668
|
-
function
|
|
1670
|
+
function $e(e) {
|
|
1669
1671
|
return new Promise((t) => {
|
|
1670
1672
|
setTimeout(t, e);
|
|
1671
1673
|
});
|
|
1672
1674
|
}
|
|
1673
|
-
class
|
|
1674
|
-
constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...
|
|
1675
|
-
super(
|
|
1675
|
+
class Me extends I {
|
|
1676
|
+
constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...a }) {
|
|
1677
|
+
super(a, r, {
|
|
1676
1678
|
requestPhoneAccess: "web_app_request_phone",
|
|
1677
1679
|
requestWriteAccess: "web_app_request_write_access",
|
|
1678
1680
|
switchInlineQuery: "web_app_switch_inline_query",
|
|
@@ -1689,8 +1691,8 @@ class Oe extends q {
|
|
|
1689
1691
|
*/
|
|
1690
1692
|
c(this, "supportsParam");
|
|
1691
1693
|
this.createRequestId = n, this.postEvent = s, this.botInline = i;
|
|
1692
|
-
const
|
|
1693
|
-
this.supports = (p) =>
|
|
1694
|
+
const o = this.supports.bind(this);
|
|
1695
|
+
this.supports = (p) => o(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = Tt(r, {
|
|
1694
1696
|
"setHeaderColor.color": ["web_app_set_header_color", "color"]
|
|
1695
1697
|
});
|
|
1696
1698
|
}
|
|
@@ -1701,8 +1703,8 @@ class Oe extends q {
|
|
|
1701
1703
|
async getRequestedContact({
|
|
1702
1704
|
timeout: s = 1e4
|
|
1703
1705
|
} = {}) {
|
|
1704
|
-
return
|
|
1705
|
-
await
|
|
1706
|
+
return Ve().parse(
|
|
1707
|
+
await C(
|
|
1706
1708
|
"getRequestedContact",
|
|
1707
1709
|
{},
|
|
1708
1710
|
this.createRequestId(),
|
|
@@ -1741,7 +1743,7 @@ class Oe extends q {
|
|
|
1741
1743
|
* True if current Mini App background color is recognized as dark.
|
|
1742
1744
|
*/
|
|
1743
1745
|
get isDark() {
|
|
1744
|
-
return
|
|
1746
|
+
return gt(this.bgColor);
|
|
1745
1747
|
}
|
|
1746
1748
|
/**
|
|
1747
1749
|
* Informs the Telegram app that the Mini App is ready to be displayed.
|
|
@@ -1770,15 +1772,15 @@ class Oe extends q {
|
|
|
1770
1772
|
throw new Error("Access denied.");
|
|
1771
1773
|
const r = Date.now() + s;
|
|
1772
1774
|
let i = 50;
|
|
1773
|
-
return
|
|
1775
|
+
return ft(async () => {
|
|
1774
1776
|
for (; Date.now() < r; ) {
|
|
1775
1777
|
try {
|
|
1776
1778
|
return await this.getRequestedContact();
|
|
1777
1779
|
} catch {
|
|
1778
1780
|
}
|
|
1779
|
-
await
|
|
1781
|
+
await $e(i), i += 50;
|
|
1780
1782
|
}
|
|
1781
|
-
throw
|
|
1783
|
+
throw _t(s);
|
|
1782
1784
|
}, s);
|
|
1783
1785
|
}
|
|
1784
1786
|
/**
|
|
@@ -1791,7 +1793,7 @@ class Oe extends q {
|
|
|
1791
1793
|
* @see requestContact
|
|
1792
1794
|
*/
|
|
1793
1795
|
async requestPhoneAccess(s = {}) {
|
|
1794
|
-
return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise =
|
|
1796
|
+
return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = _({
|
|
1795
1797
|
...s,
|
|
1796
1798
|
method: "web_app_request_phone",
|
|
1797
1799
|
event: "phone_requested",
|
|
@@ -1803,7 +1805,7 @@ class Oe extends q {
|
|
|
1803
1805
|
* @param options - additional options.
|
|
1804
1806
|
*/
|
|
1805
1807
|
async requestWriteAccess(s = {}) {
|
|
1806
|
-
return this.requestWriteAccessPromise || (this.requestWriteAccessPromise =
|
|
1808
|
+
return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = _({
|
|
1807
1809
|
...s,
|
|
1808
1810
|
method: "web_app_request_write_access",
|
|
1809
1811
|
event: "write_access_requested",
|
|
@@ -1833,7 +1835,7 @@ class Oe extends q {
|
|
|
1833
1835
|
* @param color - color key or RGB color.
|
|
1834
1836
|
*/
|
|
1835
1837
|
setHeaderColor(s) {
|
|
1836
|
-
this.postEvent("web_app_set_header_color",
|
|
1838
|
+
this.postEvent("web_app_set_header_color", Q(s) ? { color: s } : { color_key: s }), this.set("headerColor", s);
|
|
1837
1839
|
}
|
|
1838
1840
|
/**
|
|
1839
1841
|
* Updates current Mini App background color.
|
|
@@ -1861,16 +1863,19 @@ class Oe extends q {
|
|
|
1861
1863
|
this.postEvent("web_app_switch_inline_query", { query: s, chat_types: n });
|
|
1862
1864
|
}
|
|
1863
1865
|
}
|
|
1864
|
-
const
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
}
|
|
1873
|
-
|
|
1866
|
+
const us = l(
|
|
1867
|
+
"miniApp",
|
|
1868
|
+
({
|
|
1869
|
+
themeParams: e,
|
|
1870
|
+
botInline: t = !1,
|
|
1871
|
+
state: s = {
|
|
1872
|
+
bgColor: e.bgColor || "#ffffff",
|
|
1873
|
+
headerColor: e.headerBgColor || "#000000"
|
|
1874
|
+
},
|
|
1875
|
+
...n
|
|
1876
|
+
}) => new Me({ ...n, ...s, botInline: t })
|
|
1877
|
+
);
|
|
1878
|
+
function Le(e) {
|
|
1874
1879
|
const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
|
|
1875
1880
|
let r;
|
|
1876
1881
|
if (s.length > 64)
|
|
@@ -1880,21 +1885,21 @@ function Ue(e) {
|
|
|
1880
1885
|
if (n.length > 3)
|
|
1881
1886
|
throw new Error(`Buttons have incorrect size: ${n.length}`);
|
|
1882
1887
|
return n.length ? r = n.map((i) => {
|
|
1883
|
-
const { id:
|
|
1884
|
-
if (
|
|
1885
|
-
throw new Error(`Button ID has incorrect size: ${
|
|
1888
|
+
const { id: a = "" } = i;
|
|
1889
|
+
if (a.length > 64)
|
|
1890
|
+
throw new Error(`Button ID has incorrect size: ${a}`);
|
|
1886
1891
|
if (!i.type || i.type === "default" || i.type === "destructive") {
|
|
1887
|
-
const
|
|
1888
|
-
if (!
|
|
1892
|
+
const o = i.text.trim();
|
|
1893
|
+
if (!o.length || o.length > 64) {
|
|
1889
1894
|
const p = i.type || "default";
|
|
1890
1895
|
throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
|
|
1891
1896
|
}
|
|
1892
|
-
return { ...i, text:
|
|
1897
|
+
return { ...i, text: o, id: a };
|
|
1893
1898
|
}
|
|
1894
|
-
return { ...i, id:
|
|
1899
|
+
return { ...i, id: a };
|
|
1895
1900
|
}) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
|
|
1896
1901
|
}
|
|
1897
|
-
class
|
|
1902
|
+
class Be extends I {
|
|
1898
1903
|
constructor(t, s, n) {
|
|
1899
1904
|
super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
|
|
1900
1905
|
}
|
|
@@ -1923,11 +1928,11 @@ class We extends q {
|
|
|
1923
1928
|
throw new Error("Popup is already opened.");
|
|
1924
1929
|
this.isOpened = !0;
|
|
1925
1930
|
try {
|
|
1926
|
-
const { button_id: s = null } = await
|
|
1931
|
+
const { button_id: s = null } = await _({
|
|
1927
1932
|
event: "popup_closed",
|
|
1928
1933
|
method: "web_app_open_popup",
|
|
1929
1934
|
postEvent: this.postEvent,
|
|
1930
|
-
params:
|
|
1935
|
+
params: Le(t)
|
|
1931
1936
|
});
|
|
1932
1937
|
return s;
|
|
1933
1938
|
} finally {
|
|
@@ -1935,10 +1940,10 @@ class We extends q {
|
|
|
1935
1940
|
}
|
|
1936
1941
|
}
|
|
1937
1942
|
}
|
|
1938
|
-
const
|
|
1939
|
-
({ postEvent: e, version: t }) => new
|
|
1943
|
+
const ls = l(
|
|
1944
|
+
({ postEvent: e, version: t }) => new Be(!1, t, e)
|
|
1940
1945
|
);
|
|
1941
|
-
class
|
|
1946
|
+
class Oe extends I {
|
|
1942
1947
|
constructor(t, s, n) {
|
|
1943
1948
|
super({ isOpened: t }, s, {
|
|
1944
1949
|
close: "web_app_close_scan_qr_popup",
|
|
@@ -1971,7 +1976,7 @@ class He extends q {
|
|
|
1971
1976
|
throw new Error("QR scanner is already opened.");
|
|
1972
1977
|
this.isOpened = !0;
|
|
1973
1978
|
try {
|
|
1974
|
-
return (await
|
|
1979
|
+
return (await _({
|
|
1975
1980
|
method: "web_app_open_scan_qr_popup",
|
|
1976
1981
|
event: ["qr_text_received", "scan_qr_popup_closed"],
|
|
1977
1982
|
postEvent: this.postEvent,
|
|
@@ -1982,10 +1987,10 @@ class He extends q {
|
|
|
1982
1987
|
}
|
|
1983
1988
|
}
|
|
1984
1989
|
}
|
|
1985
|
-
const
|
|
1986
|
-
({ version: e, postEvent: t }) => new
|
|
1990
|
+
const ds = l(
|
|
1991
|
+
({ version: e, postEvent: t }) => new Oe(!1, e, t)
|
|
1987
1992
|
);
|
|
1988
|
-
class
|
|
1993
|
+
class Ue extends Z {
|
|
1989
1994
|
constructor(s, n, r) {
|
|
1990
1995
|
super({ isVisible: s }, n, {
|
|
1991
1996
|
show: "web_app_setup_settings_button",
|
|
@@ -2002,7 +2007,7 @@ class Ge extends X {
|
|
|
2002
2007
|
* @param event - event to listen.
|
|
2003
2008
|
* @param listener - listener to remove.
|
|
2004
2009
|
*/
|
|
2005
|
-
c(this, "off", (s, n) => s === "click" ?
|
|
2010
|
+
c(this, "off", (s, n) => s === "click" ? L("settings_button_pressed", n) : this.state.off(s, n));
|
|
2006
2011
|
this.postEvent = r;
|
|
2007
2012
|
}
|
|
2008
2013
|
set isVisible(s) {
|
|
@@ -2027,15 +2032,18 @@ class Ge extends X {
|
|
|
2027
2032
|
this.isVisible = !0;
|
|
2028
2033
|
}
|
|
2029
2034
|
}
|
|
2030
|
-
const
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2035
|
+
const _s = l(
|
|
2036
|
+
"settingsButton",
|
|
2037
|
+
({
|
|
2038
|
+
version: e,
|
|
2039
|
+
postEvent: t,
|
|
2040
|
+
state: s = { isVisible: !1 }
|
|
2041
|
+
}) => new Ue(s.isVisible, e, t)
|
|
2042
|
+
);
|
|
2043
|
+
function It(e) {
|
|
2044
|
+
return yt().parse(e);
|
|
2037
2045
|
}
|
|
2038
|
-
class
|
|
2046
|
+
class We extends X {
|
|
2039
2047
|
/**
|
|
2040
2048
|
* @since v6.10
|
|
2041
2049
|
*/
|
|
@@ -2074,7 +2082,7 @@ class je extends tt {
|
|
|
2074
2082
|
* value is calculated according to theme bg color.
|
|
2075
2083
|
*/
|
|
2076
2084
|
get isDark() {
|
|
2077
|
-
return !this.bgColor ||
|
|
2085
|
+
return !this.bgColor || gt(this.bgColor);
|
|
2078
2086
|
}
|
|
2079
2087
|
get linkColor() {
|
|
2080
2088
|
return this.get("linkColor");
|
|
@@ -2100,7 +2108,7 @@ class je extends tt {
|
|
|
2100
2108
|
*/
|
|
2101
2109
|
listen() {
|
|
2102
2110
|
return b("theme_changed", (t) => {
|
|
2103
|
-
this.set(
|
|
2111
|
+
this.set(It(t.theme_params));
|
|
2104
2112
|
});
|
|
2105
2113
|
}
|
|
2106
2114
|
/**
|
|
@@ -2113,25 +2121,28 @@ class je extends tt {
|
|
|
2113
2121
|
return this.get("textColor");
|
|
2114
2122
|
}
|
|
2115
2123
|
}
|
|
2116
|
-
const
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2124
|
+
const fs = l(
|
|
2125
|
+
"themeParams",
|
|
2126
|
+
({ themeParams: e, state: t = e, addCleanup: s }) => {
|
|
2127
|
+
const n = new We(t);
|
|
2128
|
+
return s(n.listen()), n;
|
|
2129
|
+
}
|
|
2130
|
+
);
|
|
2131
|
+
function gs(e = {}) {
|
|
2132
|
+
return _({
|
|
2122
2133
|
...e,
|
|
2123
2134
|
method: "web_app_request_theme",
|
|
2124
2135
|
event: "theme_changed"
|
|
2125
|
-
}).then(
|
|
2136
|
+
}).then(It);
|
|
2126
2137
|
}
|
|
2127
|
-
class
|
|
2138
|
+
class He extends tt {
|
|
2128
2139
|
constructor(s, n, r) {
|
|
2129
2140
|
super(s, { readTextFromClipboard: "web_app_read_text_from_clipboard" });
|
|
2130
2141
|
/**
|
|
2131
2142
|
* Checks if specified method parameter is supported by current component.
|
|
2132
2143
|
*/
|
|
2133
2144
|
c(this, "supportsParam");
|
|
2134
|
-
this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam =
|
|
2145
|
+
this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = Tt(s, {
|
|
2135
2146
|
"openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
|
|
2136
2147
|
});
|
|
2137
2148
|
}
|
|
@@ -2180,25 +2191,25 @@ class ze extends et {
|
|
|
2180
2191
|
async readTextFromClipboard() {
|
|
2181
2192
|
const s = this.createRequestId(), {
|
|
2182
2193
|
data: n = null
|
|
2183
|
-
} = await
|
|
2194
|
+
} = await _({
|
|
2184
2195
|
method: "web_app_read_text_from_clipboard",
|
|
2185
2196
|
event: "clipboard_text_received",
|
|
2186
2197
|
postEvent: this.postEvent,
|
|
2187
2198
|
params: { req_id: s },
|
|
2188
|
-
capture:
|
|
2199
|
+
capture: dt(s)
|
|
2189
2200
|
});
|
|
2190
2201
|
return n;
|
|
2191
2202
|
}
|
|
2192
2203
|
}
|
|
2193
|
-
const
|
|
2194
|
-
({ version: e, postEvent: t, createRequestId: s }) => new
|
|
2204
|
+
const bs = l(
|
|
2205
|
+
({ version: e, postEvent: t, createRequestId: s }) => new He(e, s, t)
|
|
2195
2206
|
);
|
|
2196
|
-
async function
|
|
2207
|
+
async function qt(e = {}) {
|
|
2197
2208
|
const {
|
|
2198
2209
|
is_expanded: t,
|
|
2199
2210
|
is_state_stable: s,
|
|
2200
2211
|
...n
|
|
2201
|
-
} = await
|
|
2212
|
+
} = await _({
|
|
2202
2213
|
...e,
|
|
2203
2214
|
method: "web_app_request_viewport",
|
|
2204
2215
|
event: "viewport_changed"
|
|
@@ -2208,11 +2219,11 @@ async function Dt(e = {}) {
|
|
|
2208
2219
|
function x(e) {
|
|
2209
2220
|
return e < 0 ? 0 : e;
|
|
2210
2221
|
}
|
|
2211
|
-
class
|
|
2212
|
-
constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded:
|
|
2222
|
+
class Ge extends X {
|
|
2223
|
+
constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: a }) {
|
|
2213
2224
|
super({
|
|
2214
2225
|
height: x(r),
|
|
2215
|
-
isExpanded:
|
|
2226
|
+
isExpanded: a,
|
|
2216
2227
|
stableHeight: x(n),
|
|
2217
2228
|
width: x(i)
|
|
2218
2229
|
});
|
|
@@ -2225,7 +2236,7 @@ class Vt extends tt {
|
|
|
2225
2236
|
* @param options - options to request fresh data.
|
|
2226
2237
|
*/
|
|
2227
2238
|
async sync(s) {
|
|
2228
|
-
const { isStateStable: n, ...r } = await
|
|
2239
|
+
const { isStateStable: n, ...r } = await qt(s);
|
|
2229
2240
|
this.set({
|
|
2230
2241
|
...r,
|
|
2231
2242
|
stableHeight: n ? r.height : this.get("stableHeight")
|
|
@@ -2277,13 +2288,13 @@ class Vt extends tt {
|
|
|
2277
2288
|
height: n,
|
|
2278
2289
|
width: r,
|
|
2279
2290
|
is_expanded: i,
|
|
2280
|
-
is_state_stable:
|
|
2281
|
-
} = s,
|
|
2291
|
+
is_state_stable: a
|
|
2292
|
+
} = s, o = x(n);
|
|
2282
2293
|
this.set({
|
|
2283
|
-
height:
|
|
2294
|
+
height: o,
|
|
2284
2295
|
isExpanded: i,
|
|
2285
2296
|
width: x(r),
|
|
2286
|
-
...
|
|
2297
|
+
...a ? { stableHeight: o } : {}
|
|
2287
2298
|
});
|
|
2288
2299
|
});
|
|
2289
2300
|
}
|
|
@@ -2317,68 +2328,49 @@ class Vt extends tt {
|
|
|
2317
2328
|
return this.stableHeight === this.height;
|
|
2318
2329
|
}
|
|
2319
2330
|
}
|
|
2320
|
-
|
|
2321
|
-
const {
|
|
2322
|
-
height: s,
|
|
2323
|
-
width: n,
|
|
2324
|
-
isExpanded: r,
|
|
2325
|
-
isStateStable: i
|
|
2326
|
-
} = await Dt({ ...t, postEvent: e });
|
|
2327
|
-
return new Vt({
|
|
2328
|
-
postEvent: e,
|
|
2329
|
-
height: s,
|
|
2330
|
-
width: n,
|
|
2331
|
-
isExpanded: r,
|
|
2332
|
-
stableHeight: i ? s : 0
|
|
2333
|
-
});
|
|
2334
|
-
}
|
|
2335
|
-
function Je({
|
|
2336
|
-
state: e,
|
|
2337
|
-
platform: t,
|
|
2338
|
-
postEvent: s
|
|
2339
|
-
}) {
|
|
2340
|
-
let n = !1, r = 0, i = 0, o = 0;
|
|
2341
|
-
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 Vt({
|
|
2342
|
-
postEvent: s,
|
|
2343
|
-
height: r,
|
|
2344
|
-
width: i,
|
|
2345
|
-
stableHeight: o,
|
|
2346
|
-
isExpanded: n
|
|
2347
|
-
});
|
|
2348
|
-
}
|
|
2349
|
-
const vs = l(
|
|
2331
|
+
const ws = l(
|
|
2350
2332
|
"viewport",
|
|
2351
|
-
async (e) => {
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2333
|
+
async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
|
|
2334
|
+
let r = !1, i = 0, a = 0, o = 0;
|
|
2335
|
+
if (e)
|
|
2336
|
+
r = e.isExpanded, i = e.height, a = e.width, o = e.stableHeight;
|
|
2337
|
+
else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
|
|
2338
|
+
r = !0, i = window.innerHeight, a = window.innerWidth, o = window.innerHeight;
|
|
2339
|
+
else {
|
|
2340
|
+
const u = await qt({ timeout: 1e3, postEvent: s });
|
|
2341
|
+
r = u.isExpanded, i = u.height, a = u.width, o = u.isStateStable ? i : 0;
|
|
2342
|
+
}
|
|
2343
|
+
const p = new Ge({
|
|
2344
|
+
postEvent: s,
|
|
2345
|
+
height: i,
|
|
2346
|
+
width: a,
|
|
2347
|
+
stableHeight: o,
|
|
2348
|
+
isExpanded: r
|
|
2349
|
+
});
|
|
2350
|
+
return n(p.listen()), p;
|
|
2359
2351
|
}
|
|
2360
2352
|
);
|
|
2361
2353
|
function m(e, t) {
|
|
2362
2354
|
document.documentElement.style.setProperty(e, t);
|
|
2363
2355
|
}
|
|
2364
|
-
function
|
|
2365
|
-
s || (s = (
|
|
2356
|
+
function ms(e, t, s) {
|
|
2357
|
+
s || (s = (o) => `--tg-${o}-color`);
|
|
2366
2358
|
const n = s("header"), r = s("bg"), i = () => {
|
|
2367
|
-
const { headerColor:
|
|
2368
|
-
if (
|
|
2369
|
-
m(n,
|
|
2359
|
+
const { headerColor: o } = e;
|
|
2360
|
+
if (Q(o))
|
|
2361
|
+
m(n, o);
|
|
2370
2362
|
else {
|
|
2371
|
-
const { bgColor: p, secondaryBgColor:
|
|
2372
|
-
|
|
2363
|
+
const { bgColor: p, secondaryBgColor: u } = t;
|
|
2364
|
+
o === "bg_color" && p ? m(n, p) : o === "secondary_bg_color" && u && m(n, u);
|
|
2373
2365
|
}
|
|
2374
2366
|
m(r, e.bgColor);
|
|
2375
|
-
},
|
|
2367
|
+
}, a = [
|
|
2376
2368
|
t.on("change", i),
|
|
2377
2369
|
e.on("change", i)
|
|
2378
2370
|
];
|
|
2379
|
-
return i(), () =>
|
|
2371
|
+
return i(), () => a.forEach((o) => o());
|
|
2380
2372
|
}
|
|
2381
|
-
function
|
|
2373
|
+
function ys(e, t) {
|
|
2382
2374
|
t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
|
|
2383
2375
|
const s = () => {
|
|
2384
2376
|
Object.entries(e.getState()).forEach(([n, r]) => {
|
|
@@ -2387,23 +2379,23 @@ function Ps(e, t) {
|
|
|
2387
2379
|
};
|
|
2388
2380
|
return s(), e.on("change", s);
|
|
2389
2381
|
}
|
|
2390
|
-
function
|
|
2391
|
-
t || (t = (
|
|
2382
|
+
function vs(e, t) {
|
|
2383
|
+
t || (t = (u) => `--tg-viewport-${u}`);
|
|
2392
2384
|
const [
|
|
2393
2385
|
s,
|
|
2394
2386
|
n,
|
|
2395
2387
|
r
|
|
2396
|
-
] = ["height", "width", "stable-height"].map((
|
|
2388
|
+
] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => m(s, `${e.height}px`), a = () => m(n, `${e.width}px`), o = () => m(r, `${e.stableHeight}px`), p = [
|
|
2397
2389
|
e.on("change:height", i),
|
|
2398
|
-
e.on("change:width",
|
|
2399
|
-
e.on("change:stableHeight",
|
|
2390
|
+
e.on("change:width", a),
|
|
2391
|
+
e.on("change:stableHeight", o)
|
|
2400
2392
|
];
|
|
2401
|
-
return i(),
|
|
2393
|
+
return i(), a(), o(), () => p.forEach((u) => u());
|
|
2402
2394
|
}
|
|
2403
|
-
function
|
|
2395
|
+
function Es(e = !0) {
|
|
2404
2396
|
const t = [
|
|
2405
2397
|
b("reload_iframe", () => {
|
|
2406
|
-
|
|
2398
|
+
R("iframe_will_reload"), window.location.reload();
|
|
2407
2399
|
})
|
|
2408
2400
|
], s = () => t.forEach((n) => n());
|
|
2409
2401
|
if (e) {
|
|
@@ -2415,24 +2407,27 @@ function xs(e = !0) {
|
|
|
2415
2407
|
() => document.head.removeChild(n)
|
|
2416
2408
|
);
|
|
2417
2409
|
}
|
|
2418
|
-
return
|
|
2410
|
+
return R("iframe_ready", { reload_supported: !0 }), s;
|
|
2411
|
+
}
|
|
2412
|
+
function Ps() {
|
|
2413
|
+
return typeof window > "u";
|
|
2419
2414
|
}
|
|
2420
|
-
async function
|
|
2421
|
-
if (
|
|
2415
|
+
async function xs() {
|
|
2416
|
+
if (ut(window))
|
|
2422
2417
|
return !0;
|
|
2423
2418
|
try {
|
|
2424
|
-
return await
|
|
2419
|
+
return await _({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
|
|
2425
2420
|
} catch {
|
|
2426
2421
|
return !1;
|
|
2427
2422
|
}
|
|
2428
2423
|
}
|
|
2429
|
-
function
|
|
2430
|
-
return e instanceof
|
|
2424
|
+
function je(e) {
|
|
2425
|
+
return e instanceof V;
|
|
2431
2426
|
}
|
|
2432
2427
|
function Cs(e, t) {
|
|
2433
|
-
return
|
|
2428
|
+
return je(e) && e.type === t;
|
|
2434
2429
|
}
|
|
2435
|
-
function
|
|
2430
|
+
function B(e, t) {
|
|
2436
2431
|
let s, n, r;
|
|
2437
2432
|
return typeof e == "string" ? s = e : (s = e.pathname === void 0 ? t : e.pathname, n = e.params, r = e.id), Object.freeze({
|
|
2438
2433
|
id: r || (Math.random() * 2 ** 14 | 0).toString(16),
|
|
@@ -2440,13 +2435,13 @@ function O(e, t) {
|
|
|
2440
2435
|
params: n
|
|
2441
2436
|
});
|
|
2442
2437
|
}
|
|
2443
|
-
class
|
|
2444
|
-
constructor(t, s, n =
|
|
2438
|
+
class ze {
|
|
2439
|
+
constructor(t, s, n = R) {
|
|
2445
2440
|
/**
|
|
2446
2441
|
* Navigation history.
|
|
2447
2442
|
*/
|
|
2448
2443
|
c(this, "history");
|
|
2449
|
-
c(this, "ee", new
|
|
2444
|
+
c(this, "ee", new D());
|
|
2450
2445
|
/**
|
|
2451
2446
|
* True, if current navigator is currently attached.
|
|
2452
2447
|
*/
|
|
@@ -2464,13 +2459,13 @@ class Ye {
|
|
|
2464
2459
|
*/
|
|
2465
2460
|
c(this, "off", this.ee.off.bind(this.ee));
|
|
2466
2461
|
if (this._index = s, this.postEvent = n, t.length === 0)
|
|
2467
|
-
throw
|
|
2462
|
+
throw f(jt, "History should not be empty.");
|
|
2468
2463
|
if (s < 0 || s >= t.length)
|
|
2469
|
-
throw
|
|
2470
|
-
|
|
2464
|
+
throw f(
|
|
2465
|
+
zt,
|
|
2471
2466
|
"Index should not be zero and higher or equal than history size."
|
|
2472
2467
|
);
|
|
2473
|
-
this.history = t.map((r) =>
|
|
2468
|
+
this.history = t.map((r) => B(r, ""));
|
|
2474
2469
|
}
|
|
2475
2470
|
/**
|
|
2476
2471
|
* Allows this navigator to control the `BackButton` visibility state. It also tracks the
|
|
@@ -2489,7 +2484,7 @@ class Ye {
|
|
|
2489
2484
|
* Prevents current navigator from controlling the BackButton visibility state.
|
|
2490
2485
|
*/
|
|
2491
2486
|
detach() {
|
|
2492
|
-
this.attached = !1,
|
|
2487
|
+
this.attached = !1, L("back_button_pressed", this.back);
|
|
2493
2488
|
}
|
|
2494
2489
|
/**
|
|
2495
2490
|
* Goes to the next history item.
|
|
@@ -2545,14 +2540,14 @@ class Ye {
|
|
|
2545
2540
|
* @param item - item to add.
|
|
2546
2541
|
*/
|
|
2547
2542
|
push(t) {
|
|
2548
|
-
this.hasNext && this.history.splice(this.index + 1), this.replaceAndMove(this.index + 1,
|
|
2543
|
+
this.hasNext && this.history.splice(this.index + 1), this.replaceAndMove(this.index + 1, B(t, this.current.pathname));
|
|
2549
2544
|
}
|
|
2550
2545
|
/**
|
|
2551
2546
|
* Replaces the current history item.
|
|
2552
2547
|
* @param item - item to replace the current item with.
|
|
2553
2548
|
*/
|
|
2554
2549
|
replace(t) {
|
|
2555
|
-
this.replaceAndMove(this.index,
|
|
2550
|
+
this.replaceAndMove(this.index, B(t, this.current.pathname));
|
|
2556
2551
|
}
|
|
2557
2552
|
/**
|
|
2558
2553
|
* Sets history item by the specified index.
|
|
@@ -2582,7 +2577,7 @@ class Ye {
|
|
|
2582
2577
|
this.postEvent("web_app_setup_back_button", { is_visible: !!this.index });
|
|
2583
2578
|
}
|
|
2584
2579
|
}
|
|
2585
|
-
function
|
|
2580
|
+
function O({
|
|
2586
2581
|
params: e,
|
|
2587
2582
|
...t
|
|
2588
2583
|
}) {
|
|
@@ -2601,16 +2596,16 @@ function N(e) {
|
|
|
2601
2596
|
const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = k(e);
|
|
2602
2597
|
return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
|
|
2603
2598
|
}
|
|
2604
|
-
function
|
|
2599
|
+
function U(e, t, s) {
|
|
2605
2600
|
let n, r;
|
|
2606
2601
|
typeof e == "string" ? n = e : (n = N(e), s = e.state, r = e.id);
|
|
2607
|
-
const { pathname: i, search:
|
|
2608
|
-
return { id: r, pathname: i, params: { hash:
|
|
2602
|
+
const { pathname: i, search: a, hash: o } = new URL(n, `http://a${A(t, "/")}`);
|
|
2603
|
+
return { id: r, pathname: i, params: { hash: o, search: a, state: s } };
|
|
2609
2604
|
}
|
|
2610
|
-
async function
|
|
2605
|
+
async function S(e) {
|
|
2611
2606
|
return e === 0 ? !0 : Promise.race([
|
|
2612
2607
|
new Promise((t) => {
|
|
2613
|
-
const s =
|
|
2608
|
+
const s = j("popstate", () => {
|
|
2614
2609
|
s(), t(!0);
|
|
2615
2610
|
});
|
|
2616
2611
|
window.history.go(e);
|
|
@@ -2621,21 +2616,21 @@ async function C(e) {
|
|
|
2621
2616
|
})
|
|
2622
2617
|
]);
|
|
2623
2618
|
}
|
|
2624
|
-
async function
|
|
2625
|
-
if (window.history.length <= 1 || (window.history.pushState(null, ""), await
|
|
2619
|
+
async function Fe() {
|
|
2620
|
+
if (window.history.length <= 1 || (window.history.pushState(null, ""), await S(1 - window.history.length)))
|
|
2626
2621
|
return;
|
|
2627
|
-
let t = await
|
|
2622
|
+
let t = await S(-1);
|
|
2628
2623
|
for (; t; )
|
|
2629
|
-
t = await
|
|
2624
|
+
t = await S(-1);
|
|
2630
2625
|
}
|
|
2631
|
-
function
|
|
2626
|
+
function kt(e) {
|
|
2632
2627
|
return k(e).pathname;
|
|
2633
2628
|
}
|
|
2634
|
-
const
|
|
2635
|
-
class
|
|
2636
|
-
constructor(t, s, { postEvent: n, hashMode: r, base: i } = {}) {
|
|
2629
|
+
const rt = 0, W = 1, H = 2;
|
|
2630
|
+
class Nt {
|
|
2631
|
+
constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
|
|
2637
2632
|
c(this, "navigator");
|
|
2638
|
-
c(this, "ee", new
|
|
2633
|
+
c(this, "ee", new D());
|
|
2639
2634
|
c(this, "hashMode");
|
|
2640
2635
|
c(this, "base");
|
|
2641
2636
|
/**
|
|
@@ -2649,7 +2644,7 @@ class Mt {
|
|
|
2649
2644
|
c(this, "onPopState", ({ state: t }) => {
|
|
2650
2645
|
if (t === null)
|
|
2651
2646
|
return this.push(this.parsePath(window.location.href));
|
|
2652
|
-
t ===
|
|
2647
|
+
t === rt ? window.history.forward() : t === W && this.back(), t === H && this.forward();
|
|
2653
2648
|
});
|
|
2654
2649
|
/**
|
|
2655
2650
|
* Underlying navigator change event listener.
|
|
@@ -2661,8 +2656,8 @@ class Mt {
|
|
|
2661
2656
|
}) => {
|
|
2662
2657
|
this.attached && await this.syncHistory(), this.ee.emit("change", {
|
|
2663
2658
|
delta: n,
|
|
2664
|
-
from:
|
|
2665
|
-
to:
|
|
2659
|
+
from: O(s),
|
|
2660
|
+
to: O(t),
|
|
2666
2661
|
navigator: this
|
|
2667
2662
|
});
|
|
2668
2663
|
});
|
|
@@ -2674,11 +2669,11 @@ class Mt {
|
|
|
2674
2669
|
* Removes event listener.
|
|
2675
2670
|
*/
|
|
2676
2671
|
c(this, "off", this.ee.off.bind(this.ee));
|
|
2677
|
-
this.navigator = new
|
|
2678
|
-
t.map((
|
|
2672
|
+
this.navigator = new ze(
|
|
2673
|
+
t.map((a) => U(a, "/")),
|
|
2679
2674
|
s,
|
|
2680
2675
|
n
|
|
2681
|
-
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base =
|
|
2676
|
+
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = kt(i || "");
|
|
2682
2677
|
}
|
|
2683
2678
|
/**
|
|
2684
2679
|
* Attaches current navigator to the browser history allowing navigator to manipulate it.
|
|
@@ -2762,7 +2757,7 @@ class Mt {
|
|
|
2762
2757
|
* Navigation history.
|
|
2763
2758
|
*/
|
|
2764
2759
|
get history() {
|
|
2765
|
-
return this.navigator.history.map(
|
|
2760
|
+
return this.navigator.history.map(O);
|
|
2766
2761
|
}
|
|
2767
2762
|
/**
|
|
2768
2763
|
* Path, including pathname, search and hash.
|
|
@@ -2813,11 +2808,11 @@ class Mt {
|
|
|
2813
2808
|
};
|
|
2814
2809
|
}
|
|
2815
2810
|
push(t, s) {
|
|
2816
|
-
const n =
|
|
2811
|
+
const n = U(t, this.path), { state: r = s } = n.params;
|
|
2817
2812
|
this.navigator.push({ ...n, params: { ...n.params, state: r } });
|
|
2818
2813
|
}
|
|
2819
2814
|
replace(t, s) {
|
|
2820
|
-
const n =
|
|
2815
|
+
const n = U(t, this.path), { state: r = s } = n.params;
|
|
2821
2816
|
this.navigator.replace({ ...n, params: { ...n.params, state: r } });
|
|
2822
2817
|
}
|
|
2823
2818
|
/**
|
|
@@ -2827,7 +2822,7 @@ class Mt {
|
|
|
2827
2822
|
*/
|
|
2828
2823
|
renderPath(t) {
|
|
2829
2824
|
const s = (this.base.length === 1 ? "" : this.base) + A(N(t), "/");
|
|
2830
|
-
return this.hashMode ? A(s.slice(1), this.hashMode === "
|
|
2825
|
+
return this.hashMode ? A(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
|
|
2831
2826
|
}
|
|
2832
2827
|
/**
|
|
2833
2828
|
* Synchronizes current navigator state with browser history.
|
|
@@ -2835,7 +2830,7 @@ class Mt {
|
|
|
2835
2830
|
async syncHistory() {
|
|
2836
2831
|
window.removeEventListener("popstate", this.onPopState);
|
|
2837
2832
|
const { state: t } = this, s = this.renderPath(this);
|
|
2838
|
-
await
|
|
2833
|
+
await Fe(), this.hasPrev && this.hasNext ? (window.history.replaceState(W, ""), window.history.pushState(t, "", s), window.history.pushState(H, ""), await S(-1)) : this.hasPrev ? (window.history.replaceState(W, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(H, ""), await S(-1)) : (window.history.replaceState(rt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
|
|
2839
2834
|
}
|
|
2840
2835
|
/**
|
|
2841
2836
|
* Current query parameters.
|
|
@@ -2853,149 +2848,148 @@ class Mt {
|
|
|
2853
2848
|
return (this.navigator.current.params || {}).state;
|
|
2854
2849
|
}
|
|
2855
2850
|
}
|
|
2856
|
-
function
|
|
2851
|
+
function Je(e) {
|
|
2857
2852
|
e || (e = {});
|
|
2858
2853
|
const { href: t, hash: s } = window.location;
|
|
2859
2854
|
let n = N(
|
|
2860
|
-
e.hashMode ? s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
|
|
2855
|
+
e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
|
|
2861
2856
|
);
|
|
2862
|
-
const r = e.base ?
|
|
2857
|
+
const r = e.base ? kt(e.base) : void 0;
|
|
2863
2858
|
if (r) {
|
|
2864
2859
|
if (!n.startsWith(r))
|
|
2865
|
-
throw
|
|
2866
|
-
|
|
2860
|
+
throw f(
|
|
2861
|
+
Ft,
|
|
2867
2862
|
`Path "${n}" expected to be starting with "${r}"`
|
|
2868
2863
|
);
|
|
2869
2864
|
n = n.slice(r.length);
|
|
2870
2865
|
}
|
|
2871
|
-
return new
|
|
2866
|
+
return new Nt([n], 0, e);
|
|
2872
2867
|
}
|
|
2873
|
-
function
|
|
2868
|
+
function Ss(e) {
|
|
2874
2869
|
const t = e.match(/#(.+)/);
|
|
2875
2870
|
return t ? t[1] : null;
|
|
2876
2871
|
}
|
|
2877
|
-
function
|
|
2878
|
-
if (
|
|
2872
|
+
function Qe(e, t) {
|
|
2873
|
+
if (Rt()) {
|
|
2879
2874
|
const s = sessionStorage.getItem(e);
|
|
2880
2875
|
if (s)
|
|
2881
2876
|
try {
|
|
2882
2877
|
const { index: n, history: r } = JSON.parse(s);
|
|
2883
|
-
return new
|
|
2878
|
+
return new Nt(r, n, t);
|
|
2884
2879
|
} catch (n) {
|
|
2885
2880
|
console.error("Unable to restore hash navigator state.", n);
|
|
2886
2881
|
}
|
|
2887
2882
|
}
|
|
2888
|
-
return
|
|
2883
|
+
return Je(t);
|
|
2889
2884
|
}
|
|
2890
|
-
function
|
|
2891
|
-
const s =
|
|
2885
|
+
function Rs(e, t) {
|
|
2886
|
+
const s = Qe(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
|
|
2892
2887
|
index: s.index,
|
|
2893
2888
|
history: s.history
|
|
2894
2889
|
}));
|
|
2895
2890
|
return s.on("change", n), n(), s;
|
|
2896
2891
|
}
|
|
2897
2892
|
export {
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
Me as
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
Ss as bindViewportCSSVars,
|
|
2893
|
+
pe as BackButton,
|
|
2894
|
+
ze as BasicNavigator,
|
|
2895
|
+
xe as BiometryManager,
|
|
2896
|
+
Nt as BrowserNavigator,
|
|
2897
|
+
Se as ClosingBehavior,
|
|
2898
|
+
Ie as CloudStorage,
|
|
2899
|
+
Ft as ERR_INVALID_PATH_BASE,
|
|
2900
|
+
Wt as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
|
|
2901
|
+
Ot as ERR_METHOD_PARAMETER_UNSUPPORTED,
|
|
2902
|
+
Bt as ERR_METHOD_UNSUPPORTED,
|
|
2903
|
+
jt as ERR_NAVIGATION_HISTORY_EMPTY,
|
|
2904
|
+
zt as ERR_NAVIGATION_INDEX_INVALID,
|
|
2905
|
+
Ke as ERR_NAVIGATION_ITEM_INVALID,
|
|
2906
|
+
at as ERR_PARSE,
|
|
2907
|
+
Xe as ERR_SSR_INIT,
|
|
2908
|
+
Ht as ERR_TIMED_OUT,
|
|
2909
|
+
Gt as ERR_UNEXPECTED_TYPE,
|
|
2910
|
+
Ut as ERR_UNKNOWN_ENV,
|
|
2911
|
+
D as EventEmitter,
|
|
2912
|
+
qe as HapticFeedback,
|
|
2913
|
+
ke as InitData,
|
|
2914
|
+
Ne as Invoice,
|
|
2915
|
+
De as MainButton,
|
|
2916
|
+
Me as MiniApp,
|
|
2917
|
+
Be as Popup,
|
|
2918
|
+
Oe as QRScanner,
|
|
2919
|
+
V as SDKError,
|
|
2920
|
+
Ue as SettingsButton,
|
|
2921
|
+
We as ThemeParams,
|
|
2922
|
+
He as Utils,
|
|
2923
|
+
Ge as Viewport,
|
|
2924
|
+
Te as array,
|
|
2925
|
+
ms as bindMiniAppCSSVars,
|
|
2926
|
+
ys as bindThemeParamsCSSVars,
|
|
2927
|
+
vs as bindViewportCSSVars,
|
|
2934
2928
|
w as boolean,
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2929
|
+
dt as captureSameReq,
|
|
2930
|
+
z as classNames,
|
|
2931
|
+
re as compareVersions,
|
|
2932
|
+
Je as createBrowserNavigatorFromLocation,
|
|
2933
|
+
ce as createPostEvent,
|
|
2940
2934
|
k as createSafeURL,
|
|
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
|
-
|
|
2935
|
+
wt as date,
|
|
2936
|
+
Ss as getHash,
|
|
2937
|
+
kt as getPathname,
|
|
2938
|
+
ss as initBackButton,
|
|
2939
|
+
ns as initBiometryManager,
|
|
2940
|
+
rs as initClosingBehavior,
|
|
2941
|
+
is as initCloudStorage,
|
|
2942
|
+
os as initHapticFeedback,
|
|
2943
|
+
as as initInitData,
|
|
2944
|
+
hs as initInvoice,
|
|
2945
|
+
ps as initMainButton,
|
|
2946
|
+
us as initMiniApp,
|
|
2947
|
+
Rs as initNavigator,
|
|
2948
|
+
ls as initPopup,
|
|
2949
|
+
ds as initQRScanner,
|
|
2950
|
+
_s as initSettingsButton,
|
|
2951
|
+
fs as initThemeParams,
|
|
2952
|
+
bs as initUtils,
|
|
2953
|
+
ws as initViewport,
|
|
2954
|
+
Es as initWeb,
|
|
2955
|
+
C as invokeCustomMethod,
|
|
2956
|
+
gt as isColorDark,
|
|
2957
|
+
oe as isIframe,
|
|
2958
|
+
Rt as isPageReload,
|
|
2959
|
+
Q as isRGB,
|
|
2960
|
+
Jt as isRGBShort,
|
|
2961
|
+
je as isSDKError,
|
|
2968
2962
|
Cs as isSDKErrorOfType,
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2963
|
+
Ps as isSSR,
|
|
2964
|
+
xs as isTMA,
|
|
2965
|
+
d as json,
|
|
2966
|
+
es as mergeClassNames,
|
|
2973
2967
|
y as number,
|
|
2974
|
-
|
|
2968
|
+
L as off,
|
|
2975
2969
|
b as on,
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2970
|
+
cs as parseInitData,
|
|
2971
|
+
vt as parseLaunchParams,
|
|
2972
|
+
It as parseThemeParams,
|
|
2973
|
+
R as postEvent,
|
|
2974
|
+
_ as request,
|
|
2975
|
+
Ce as requestBiometryInfo,
|
|
2976
|
+
gs as requestThemeParams,
|
|
2977
|
+
qt as requestViewport,
|
|
2978
|
+
ye as retrieveLaunchParams,
|
|
2979
|
+
pt as rgb,
|
|
2986
2980
|
K as searchParams,
|
|
2987
|
-
|
|
2988
|
-
|
|
2981
|
+
we as serializeLaunchParams,
|
|
2982
|
+
be as serializeThemeParams,
|
|
2989
2983
|
m as setCSSVar,
|
|
2990
|
-
|
|
2991
|
-
|
|
2984
|
+
Ze as setDebug,
|
|
2985
|
+
ts as setTargetOrigin,
|
|
2992
2986
|
h as string,
|
|
2993
|
-
|
|
2987
|
+
$t as subscribe,
|
|
2994
2988
|
v as supports,
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2989
|
+
ae as targetOrigin,
|
|
2990
|
+
ht as toRGB,
|
|
2991
|
+
ot as unsubscribe,
|
|
2998
2992
|
N as urlToPath,
|
|
2999
|
-
|
|
2993
|
+
ft as withTimeout
|
|
3000
2994
|
};
|
|
3001
2995
|
//# sourceMappingURL=index.js.map
|