@tma.js/sdk 1.2.0 → 1.3.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/index.d.ts +1 -1
- package/dist/dts/init/creators/createViewport.d.ts +2 -9
- package/dist/dts/init/init.d.ts +2 -0
- package/dist/dts/init/types.d.ts +7 -4
- package/dist/dts/mini-app/types.d.ts +1 -1
- package/dist/dts/types/platform.d.ts +1 -1
- package/dist/dts/viewport/index.d.ts +1 -0
- package/dist/dts/viewport/isStableViewportPlatform.d.ts +7 -0
- 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.mjs +407 -410
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/init/creators/createViewport.ts +60 -81
- package/src/init/init.ts +13 -15
- package/src/init/types.ts +8 -4
- package/src/mini-app/contactParser.ts +1 -1
- package/src/mini-app/types.ts +1 -1
- package/src/types/platform.ts +2 -2
- package/src/viewport/index.ts +1 -0
- package/src/viewport/isStableViewportPlatform.ts +10 -0
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (r, t, e) => (
|
|
1
|
+
var Rt = Object.defineProperty;
|
|
2
|
+
var It = (r, t, e) => t in r ? Rt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var o = (r, t, e) => (It(r, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
4
|
function H(r) {
|
|
5
5
|
return typeof r == "object" && r !== null && !Array.isArray(r);
|
|
6
6
|
}
|
|
7
7
|
function ht() {
|
|
8
8
|
return performance.getEntriesByType("navigation")[0] || null;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function Lt() {
|
|
11
11
|
const r = ht();
|
|
12
12
|
return r ? r.type === "reload" : null;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function I() {
|
|
15
15
|
return new TypeError("Value has unexpected type");
|
|
16
16
|
}
|
|
17
17
|
class F extends Error {
|
|
@@ -40,7 +40,7 @@ class z {
|
|
|
40
40
|
return this.isOptional = !0, this;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function $t(r) {
|
|
44
44
|
if (Array.isArray(r))
|
|
45
45
|
return r;
|
|
46
46
|
if (typeof r == "string")
|
|
@@ -50,11 +50,11 @@ function Dt(r) {
|
|
|
50
50
|
return t;
|
|
51
51
|
} catch {
|
|
52
52
|
}
|
|
53
|
-
throw
|
|
53
|
+
throw I();
|
|
54
54
|
}
|
|
55
|
-
class
|
|
55
|
+
class Tt extends z {
|
|
56
56
|
constructor(e, s, n) {
|
|
57
|
-
super(
|
|
57
|
+
super($t, s, n);
|
|
58
58
|
o(this, "itemParser");
|
|
59
59
|
this.itemParser = typeof e == "function" ? e : e.parse.bind(e);
|
|
60
60
|
}
|
|
@@ -66,12 +66,12 @@ class Wt extends z {
|
|
|
66
66
|
return this.itemParser = typeof e == "function" ? e : e.parse.bind(e), this;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function L(r, t) {
|
|
70
70
|
return () => new z(r, !1, t);
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class G extends Error {
|
|
73
73
|
constructor(t, { cause: e, type: s } = {}) {
|
|
74
|
-
super(`Unable to parse field "${t}"${s ? ` as ${s}` : ""}`, { cause: e }), Object.setPrototypeOf(this,
|
|
74
|
+
super(`Unable to parse field "${t}"${s ? ` as ${s}` : ""}`, { cause: e }), Object.setPrototypeOf(this, G.prototype);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
function ut(r, t) {
|
|
@@ -84,27 +84,27 @@ function ut(r, t) {
|
|
|
84
84
|
if (typeof n == "function" || "parse" in n)
|
|
85
85
|
i = s, a = typeof n == "function" ? n : n.parse.bind(n);
|
|
86
86
|
else {
|
|
87
|
-
const { type:
|
|
88
|
-
i = n.from || s, a = typeof
|
|
87
|
+
const { type: u } = n;
|
|
88
|
+
i = n.from || s, a = typeof u == "function" ? u : u.parse.bind(u);
|
|
89
89
|
}
|
|
90
90
|
let c;
|
|
91
|
-
const
|
|
91
|
+
const p = t(i);
|
|
92
92
|
try {
|
|
93
|
-
c = a(
|
|
94
|
-
} catch (
|
|
95
|
-
throw
|
|
96
|
-
type:
|
|
97
|
-
cause:
|
|
98
|
-
}) : new
|
|
93
|
+
c = a(p);
|
|
94
|
+
} catch (u) {
|
|
95
|
+
throw u instanceof F ? new G(i, {
|
|
96
|
+
type: u.type,
|
|
97
|
+
cause: u
|
|
98
|
+
}) : new G(i, { cause: u });
|
|
99
99
|
}
|
|
100
100
|
c !== void 0 && (e[s] = c);
|
|
101
101
|
}
|
|
102
102
|
return e;
|
|
103
103
|
}
|
|
104
|
-
function
|
|
105
|
-
return new
|
|
104
|
+
function Bt(r) {
|
|
105
|
+
return new Tt((t) => t, !1, r);
|
|
106
106
|
}
|
|
107
|
-
const
|
|
107
|
+
const k = L((r) => {
|
|
108
108
|
if (typeof r == "boolean")
|
|
109
109
|
return r;
|
|
110
110
|
const t = String(r);
|
|
@@ -112,8 +112,8 @@ const P = V((r) => {
|
|
|
112
112
|
return !0;
|
|
113
113
|
if (t === "0" || t === "false")
|
|
114
114
|
return !1;
|
|
115
|
-
throw
|
|
116
|
-
}, "boolean"),
|
|
115
|
+
throw I();
|
|
116
|
+
}, "boolean"), q = L((r) => {
|
|
117
117
|
if (typeof r == "number")
|
|
118
118
|
return r;
|
|
119
119
|
if (typeof r == "string") {
|
|
@@ -121,15 +121,15 @@ const P = V((r) => {
|
|
|
121
121
|
if (!Number.isNaN(t))
|
|
122
122
|
return t;
|
|
123
123
|
}
|
|
124
|
-
throw
|
|
125
|
-
}, "number"), pt =
|
|
124
|
+
throw I();
|
|
125
|
+
}, "number"), pt = L((r) => r instanceof Date ? r : new Date(q().parse(r) * 1e3), "Date");
|
|
126
126
|
function Y(r) {
|
|
127
127
|
let t = r;
|
|
128
128
|
if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
|
|
129
|
-
throw
|
|
129
|
+
throw I();
|
|
130
130
|
return t;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function f(r, t) {
|
|
133
133
|
return new z((e) => {
|
|
134
134
|
const s = Y(e);
|
|
135
135
|
return ut(r, (n) => s[n]);
|
|
@@ -138,14 +138,14 @@ function g(r, t) {
|
|
|
138
138
|
function lt(r) {
|
|
139
139
|
return /^#[\da-f]{6}$/i.test(r);
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function Dt(r) {
|
|
142
142
|
return /^#[\da-f]{3}$/i.test(r);
|
|
143
143
|
}
|
|
144
144
|
function dt(r) {
|
|
145
145
|
const t = r.replace(/\s/g, "").toLowerCase();
|
|
146
146
|
if (lt(t))
|
|
147
147
|
return t;
|
|
148
|
-
if (
|
|
148
|
+
if (Dt(t)) {
|
|
149
149
|
let s = "#";
|
|
150
150
|
for (let n = 0; n < 3; n += 1)
|
|
151
151
|
s += t[1 + n].repeat(2);
|
|
@@ -168,15 +168,15 @@ function ft(r) {
|
|
|
168
168
|
}, 0)
|
|
169
169
|
) < 120;
|
|
170
170
|
}
|
|
171
|
-
const h =
|
|
171
|
+
const h = L((r) => {
|
|
172
172
|
if (typeof r == "string" || typeof r == "number")
|
|
173
173
|
return r.toString();
|
|
174
|
-
throw
|
|
175
|
-
}, "string"), gt =
|
|
174
|
+
throw I();
|
|
175
|
+
}, "string"), gt = L((r) => dt(h().parse(r)), "rgb");
|
|
176
176
|
function X(r, t) {
|
|
177
177
|
return new z((e) => {
|
|
178
178
|
if (typeof e != "string" && !(e instanceof URLSearchParams))
|
|
179
|
-
throw
|
|
179
|
+
throw I();
|
|
180
180
|
const s = typeof e == "string" ? new URLSearchParams(e) : e;
|
|
181
181
|
return ut(r, (n) => {
|
|
182
182
|
const i = s.get(n);
|
|
@@ -184,9 +184,9 @@ function X(r, t) {
|
|
|
184
184
|
});
|
|
185
185
|
}, !1, t);
|
|
186
186
|
}
|
|
187
|
-
function
|
|
188
|
-
return
|
|
189
|
-
id:
|
|
187
|
+
function Wt() {
|
|
188
|
+
return f({
|
|
189
|
+
id: q(),
|
|
190
190
|
type: h(),
|
|
191
191
|
title: h(),
|
|
192
192
|
photoUrl: {
|
|
@@ -196,7 +196,7 @@ function Ht() {
|
|
|
196
196
|
username: h().optional()
|
|
197
197
|
}, "Chat");
|
|
198
198
|
}
|
|
199
|
-
class
|
|
199
|
+
class Nt {
|
|
200
200
|
constructor(t) {
|
|
201
201
|
this.initData = t;
|
|
202
202
|
}
|
|
@@ -270,26 +270,26 @@ class Ut {
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
function rt() {
|
|
273
|
-
return
|
|
273
|
+
return f({
|
|
274
274
|
addedToAttachmentMenu: {
|
|
275
|
-
type:
|
|
275
|
+
type: k().optional(),
|
|
276
276
|
from: "added_to_attachment_menu"
|
|
277
277
|
},
|
|
278
278
|
allowsWriteToPm: {
|
|
279
|
-
type:
|
|
279
|
+
type: k().optional(),
|
|
280
280
|
from: "allows_write_to_pm"
|
|
281
281
|
},
|
|
282
282
|
firstName: {
|
|
283
283
|
type: h(),
|
|
284
284
|
from: "first_name"
|
|
285
285
|
},
|
|
286
|
-
id:
|
|
286
|
+
id: q(),
|
|
287
287
|
isBot: {
|
|
288
|
-
type:
|
|
288
|
+
type: k().optional(),
|
|
289
289
|
from: "is_bot"
|
|
290
290
|
},
|
|
291
291
|
isPremium: {
|
|
292
|
-
type:
|
|
292
|
+
type: k().optional(),
|
|
293
293
|
from: "is_premium"
|
|
294
294
|
},
|
|
295
295
|
languageCode: {
|
|
@@ -314,10 +314,10 @@ function wt() {
|
|
|
314
314
|
from: "auth_date"
|
|
315
315
|
},
|
|
316
316
|
canSendAfter: {
|
|
317
|
-
type:
|
|
317
|
+
type: q().optional(),
|
|
318
318
|
from: "can_send_after"
|
|
319
319
|
},
|
|
320
|
-
chat:
|
|
320
|
+
chat: Wt().optional(),
|
|
321
321
|
chatInstance: {
|
|
322
322
|
type: h().optional(),
|
|
323
323
|
from: "chat_instance"
|
|
@@ -339,31 +339,31 @@ function wt() {
|
|
|
339
339
|
user: rt().optional()
|
|
340
340
|
}, "InitData");
|
|
341
341
|
}
|
|
342
|
-
function
|
|
342
|
+
function Xe(r) {
|
|
343
343
|
return wt().parse(r);
|
|
344
344
|
}
|
|
345
|
-
function
|
|
345
|
+
function Ot(r) {
|
|
346
346
|
return r.replace(/(^|_)bg/, (t, e) => `${e}background`).replace(/_([a-z])/g, (t, e) => e.toUpperCase());
|
|
347
347
|
}
|
|
348
|
-
function
|
|
348
|
+
function Ht(r) {
|
|
349
349
|
return r.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`).replace(/(^|_)background/, (t, e) => `${e}bg`);
|
|
350
350
|
}
|
|
351
|
-
const _t =
|
|
351
|
+
const _t = L(
|
|
352
352
|
(r) => {
|
|
353
353
|
const t = gt().optional();
|
|
354
|
-
return Object.entries(Y(r)).reduce((e, [s, n]) => (e[
|
|
354
|
+
return Object.entries(Y(r)).reduce((e, [s, n]) => (e[Ot(s)] = t.parse(n), e), {});
|
|
355
355
|
},
|
|
356
356
|
"ThemeParams"
|
|
357
357
|
);
|
|
358
358
|
function bt(r) {
|
|
359
359
|
return _t().parse(r);
|
|
360
360
|
}
|
|
361
|
-
function
|
|
361
|
+
function tr(r = {}) {
|
|
362
362
|
return m("web_app_request_theme", "theme_changed", r).then(bt);
|
|
363
363
|
}
|
|
364
|
-
function
|
|
364
|
+
function Ut(r) {
|
|
365
365
|
return JSON.stringify(
|
|
366
|
-
Object.entries(r).reduce((t, [e, s]) => (s && (t[
|
|
366
|
+
Object.entries(r).reduce((t, [e, s]) => (s && (t[Ht(e)] = s), t), {})
|
|
367
367
|
);
|
|
368
368
|
}
|
|
369
369
|
class w {
|
|
@@ -448,7 +448,7 @@ class w {
|
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
|
-
class
|
|
451
|
+
class b {
|
|
452
452
|
constructor(t, e) {
|
|
453
453
|
this.state = t, this.ee = e;
|
|
454
454
|
}
|
|
@@ -478,7 +478,7 @@ class _ {
|
|
|
478
478
|
return this.state[t];
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
|
-
class
|
|
481
|
+
class Mt {
|
|
482
482
|
constructor(t) {
|
|
483
483
|
o(this, "ee", new w());
|
|
484
484
|
o(this, "state");
|
|
@@ -490,7 +490,7 @@ class Ft {
|
|
|
490
490
|
* Removes event listener.
|
|
491
491
|
*/
|
|
492
492
|
o(this, "off", this.ee.off.bind(this.ee));
|
|
493
|
-
this.state = new
|
|
493
|
+
this.state = new b(t, this.ee);
|
|
494
494
|
}
|
|
495
495
|
/**
|
|
496
496
|
* @since v6.10
|
|
@@ -579,7 +579,7 @@ class Ft {
|
|
|
579
579
|
function mt() {
|
|
580
580
|
return X({
|
|
581
581
|
botInline: {
|
|
582
|
-
type:
|
|
582
|
+
type: k().optional(),
|
|
583
583
|
from: "tgWebAppBotInline"
|
|
584
584
|
},
|
|
585
585
|
initData: {
|
|
@@ -595,7 +595,7 @@ function mt() {
|
|
|
595
595
|
from: "tgWebAppPlatform"
|
|
596
596
|
},
|
|
597
597
|
showSettings: {
|
|
598
|
-
type:
|
|
598
|
+
type: k().optional(),
|
|
599
599
|
from: "tgWebAppShowSettings"
|
|
600
600
|
},
|
|
601
601
|
themeParams: {
|
|
@@ -611,10 +611,10 @@ function mt() {
|
|
|
611
611
|
function yt(r) {
|
|
612
612
|
return mt().parse(r);
|
|
613
613
|
}
|
|
614
|
-
function
|
|
614
|
+
function jt() {
|
|
615
615
|
return yt(window.location.hash.slice(1));
|
|
616
616
|
}
|
|
617
|
-
function
|
|
617
|
+
function Gt() {
|
|
618
618
|
const r = ht();
|
|
619
619
|
if (!r)
|
|
620
620
|
throw new Error("Unable to get first navigation entry.");
|
|
@@ -623,18 +623,18 @@ function Jt() {
|
|
|
623
623
|
throw new Error("First navigation entry does not contain hash part.");
|
|
624
624
|
return yt(t[1]);
|
|
625
625
|
}
|
|
626
|
-
function
|
|
626
|
+
function Ft() {
|
|
627
627
|
try {
|
|
628
|
-
return
|
|
628
|
+
return Gt();
|
|
629
629
|
} catch {
|
|
630
630
|
}
|
|
631
631
|
try {
|
|
632
|
-
return
|
|
632
|
+
return jt();
|
|
633
633
|
} catch {
|
|
634
634
|
}
|
|
635
635
|
return null;
|
|
636
636
|
}
|
|
637
|
-
function
|
|
637
|
+
function zt(r) {
|
|
638
638
|
const {
|
|
639
639
|
initDataRaw: t,
|
|
640
640
|
themeParams: e,
|
|
@@ -643,30 +643,30 @@ function Zt(r) {
|
|
|
643
643
|
showSettings: i,
|
|
644
644
|
botInline: a
|
|
645
645
|
} = r, c = new URLSearchParams();
|
|
646
|
-
return t && c.set("tgWebAppData", t), c.set("tgWebAppPlatform", s), c.set("tgWebAppThemeParams",
|
|
646
|
+
return t && c.set("tgWebAppData", t), c.set("tgWebAppPlatform", s), c.set("tgWebAppThemeParams", Ut(e)), c.set("tgWebAppVersion", n), typeof i == "boolean" && c.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && c.set("tgWebAppBotInline", a ? "1" : "0"), c.toString();
|
|
647
647
|
}
|
|
648
648
|
const Et = "telegram-mini-apps-launch-params";
|
|
649
|
-
function
|
|
649
|
+
function Jt() {
|
|
650
650
|
const r = sessionStorage.getItem(Et);
|
|
651
651
|
return r ? mt().parse(r) : null;
|
|
652
652
|
}
|
|
653
|
-
function
|
|
654
|
-
sessionStorage.setItem(Et,
|
|
653
|
+
function Qt(r) {
|
|
654
|
+
sessionStorage.setItem(Et, zt(r));
|
|
655
655
|
}
|
|
656
|
-
function
|
|
656
|
+
function Zt() {
|
|
657
657
|
try {
|
|
658
658
|
return window.self !== window.top;
|
|
659
659
|
} catch {
|
|
660
660
|
return !0;
|
|
661
661
|
}
|
|
662
662
|
}
|
|
663
|
-
function
|
|
664
|
-
const r =
|
|
663
|
+
function Kt() {
|
|
664
|
+
const r = Jt(), t = Ft(), e = Lt();
|
|
665
665
|
if (r) {
|
|
666
666
|
if (t)
|
|
667
667
|
return {
|
|
668
668
|
launchParams: t,
|
|
669
|
-
isPageReload:
|
|
669
|
+
isPageReload: Zt() ? e || r.initDataRaw === t.initDataRaw : !0
|
|
670
670
|
};
|
|
671
671
|
if (e)
|
|
672
672
|
return {
|
|
@@ -687,20 +687,20 @@ function Ct() {
|
|
|
687
687
|
const r = window[st];
|
|
688
688
|
if (r)
|
|
689
689
|
return r;
|
|
690
|
-
const t =
|
|
691
|
-
return window[st] = t,
|
|
690
|
+
const t = Kt();
|
|
691
|
+
return window[st] = t, Qt(t.launchParams), t;
|
|
692
692
|
}
|
|
693
|
-
function
|
|
693
|
+
function er() {
|
|
694
694
|
try {
|
|
695
695
|
return Ct(), !0;
|
|
696
696
|
} catch {
|
|
697
697
|
return !1;
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
|
-
function
|
|
700
|
+
function Yt(r) {
|
|
701
701
|
return "external" in r && H(r.external) && "notify" in r.external && typeof r.external.notify == "function";
|
|
702
702
|
}
|
|
703
|
-
function
|
|
703
|
+
function Xt(r) {
|
|
704
704
|
return "TelegramWebviewProxy" in r && H(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
|
|
705
705
|
}
|
|
706
706
|
function vt() {
|
|
@@ -775,31 +775,31 @@ class Pt {
|
|
|
775
775
|
this.print("warn", ...t);
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
|
-
let
|
|
779
|
-
const
|
|
780
|
-
function
|
|
778
|
+
let kt = "https://web.telegram.org";
|
|
779
|
+
const V = new Pt("[SDK]", !1);
|
|
780
|
+
function rr(r) {
|
|
781
781
|
if (r) {
|
|
782
|
-
|
|
782
|
+
V.enable();
|
|
783
783
|
return;
|
|
784
784
|
}
|
|
785
|
-
|
|
785
|
+
V.disable();
|
|
786
786
|
}
|
|
787
|
-
function
|
|
788
|
-
|
|
787
|
+
function sr(r) {
|
|
788
|
+
kt = r;
|
|
789
789
|
}
|
|
790
|
-
function
|
|
791
|
-
return
|
|
790
|
+
function te() {
|
|
791
|
+
return kt;
|
|
792
792
|
}
|
|
793
|
-
const
|
|
793
|
+
const ee = f({
|
|
794
794
|
eventType: h(),
|
|
795
795
|
eventData: (r) => r
|
|
796
796
|
});
|
|
797
|
-
function
|
|
797
|
+
function re(r, t) {
|
|
798
798
|
window.dispatchEvent(new MessageEvent("message", {
|
|
799
799
|
data: JSON.stringify({ eventType: r, eventData: t })
|
|
800
800
|
}));
|
|
801
801
|
}
|
|
802
|
-
function
|
|
802
|
+
function se() {
|
|
803
803
|
const r = window;
|
|
804
804
|
"TelegramGameProxy_receiveEvent" in r || [
|
|
805
805
|
["TelegramGameProxy_receiveEvent"],
|
|
@@ -812,76 +812,76 @@ function oe() {
|
|
|
812
812
|
let e = r;
|
|
813
813
|
t.forEach((s, n, i) => {
|
|
814
814
|
if (n === i.length - 1) {
|
|
815
|
-
e[s] =
|
|
815
|
+
e[s] = re;
|
|
816
816
|
return;
|
|
817
817
|
}
|
|
818
818
|
s in e || (e[s] = {}), e = e[s];
|
|
819
819
|
});
|
|
820
820
|
});
|
|
821
821
|
}
|
|
822
|
-
function
|
|
823
|
-
|
|
822
|
+
function ne(r) {
|
|
823
|
+
se(), window.addEventListener("message", (t) => {
|
|
824
824
|
try {
|
|
825
|
-
const { eventType: e, eventData: s } =
|
|
825
|
+
const { eventType: e, eventData: s } = ee.parse(t.data);
|
|
826
826
|
r(e, s);
|
|
827
827
|
} catch {
|
|
828
828
|
}
|
|
829
829
|
});
|
|
830
830
|
}
|
|
831
|
-
function
|
|
832
|
-
return
|
|
831
|
+
function ie() {
|
|
832
|
+
return f({
|
|
833
833
|
req_id: h(),
|
|
834
834
|
data: (r) => r === null ? r : h().optional().parse(r)
|
|
835
835
|
});
|
|
836
836
|
}
|
|
837
|
-
function
|
|
838
|
-
return
|
|
837
|
+
function oe() {
|
|
838
|
+
return f({
|
|
839
839
|
req_id: h(),
|
|
840
840
|
result: (r) => r,
|
|
841
841
|
error: h().optional()
|
|
842
842
|
});
|
|
843
843
|
}
|
|
844
|
-
function
|
|
845
|
-
return
|
|
844
|
+
function ae() {
|
|
845
|
+
return f({
|
|
846
846
|
slug: h(),
|
|
847
847
|
status: h()
|
|
848
848
|
});
|
|
849
849
|
}
|
|
850
|
-
function
|
|
851
|
-
return
|
|
850
|
+
function ce() {
|
|
851
|
+
return f({ status: h() });
|
|
852
852
|
}
|
|
853
|
-
function
|
|
854
|
-
return
|
|
853
|
+
function he() {
|
|
854
|
+
return f({
|
|
855
855
|
button_id: (r) => r == null ? void 0 : h().parse(r)
|
|
856
856
|
});
|
|
857
857
|
}
|
|
858
|
-
function
|
|
859
|
-
return
|
|
858
|
+
function ue() {
|
|
859
|
+
return f({
|
|
860
860
|
data: h().optional()
|
|
861
861
|
});
|
|
862
862
|
}
|
|
863
|
-
function
|
|
864
|
-
return
|
|
863
|
+
function pe() {
|
|
864
|
+
return f({
|
|
865
865
|
theme_params: (r) => {
|
|
866
866
|
const t = gt().optional();
|
|
867
867
|
return Object.entries(Y(r)).reduce((e, [s, n]) => (e[s] = t.parse(n), e), {});
|
|
868
868
|
}
|
|
869
869
|
});
|
|
870
870
|
}
|
|
871
|
-
function
|
|
872
|
-
return
|
|
873
|
-
height:
|
|
874
|
-
width: (r) => r == null ? window.innerWidth :
|
|
875
|
-
is_state_stable:
|
|
876
|
-
is_expanded:
|
|
871
|
+
function le() {
|
|
872
|
+
return f({
|
|
873
|
+
height: q(),
|
|
874
|
+
width: (r) => r == null ? window.innerWidth : q().parse(r),
|
|
875
|
+
is_state_stable: k(),
|
|
876
|
+
is_expanded: k()
|
|
877
877
|
});
|
|
878
878
|
}
|
|
879
|
-
function
|
|
880
|
-
return
|
|
879
|
+
function de() {
|
|
880
|
+
return f({ status: h() });
|
|
881
881
|
}
|
|
882
|
-
function
|
|
882
|
+
function fe() {
|
|
883
883
|
const r = new w(), t = (e, ...s) => {
|
|
884
|
-
|
|
884
|
+
V.log("Emitting processed event:", e, ...s), r.emit(e, ...s);
|
|
885
885
|
};
|
|
886
886
|
return window.addEventListener("resize", () => {
|
|
887
887
|
t("viewport_changed", {
|
|
@@ -890,33 +890,33 @@ function _e() {
|
|
|
890
890
|
is_state_stable: !0,
|
|
891
891
|
is_expanded: !0
|
|
892
892
|
});
|
|
893
|
-
}),
|
|
894
|
-
|
|
893
|
+
}), ne((e, s) => {
|
|
894
|
+
V.log("Received raw event:", e, s);
|
|
895
895
|
try {
|
|
896
896
|
switch (e) {
|
|
897
897
|
case "viewport_changed":
|
|
898
|
-
return t(e,
|
|
898
|
+
return t(e, le().parse(s));
|
|
899
899
|
case "theme_changed":
|
|
900
|
-
return t(e,
|
|
900
|
+
return t(e, pe().parse(s));
|
|
901
901
|
case "popup_closed":
|
|
902
902
|
return (
|
|
903
903
|
// Sent on desktop.
|
|
904
|
-
s == null ? t(e, {}) : t(e,
|
|
904
|
+
s == null ? t(e, {}) : t(e, he().parse(s))
|
|
905
905
|
);
|
|
906
906
|
case "set_custom_style":
|
|
907
907
|
return t(e, h().parse(s));
|
|
908
908
|
case "qr_text_received":
|
|
909
|
-
return t(e,
|
|
909
|
+
return t(e, ue().parse(s));
|
|
910
910
|
case "clipboard_text_received":
|
|
911
|
-
return t(e,
|
|
911
|
+
return t(e, ie().parse(s));
|
|
912
912
|
case "invoice_closed":
|
|
913
|
-
return t(e,
|
|
913
|
+
return t(e, ae().parse(s));
|
|
914
914
|
case "phone_requested":
|
|
915
|
-
return t("phone_requested",
|
|
915
|
+
return t("phone_requested", ce().parse(s));
|
|
916
916
|
case "custom_method_invoked":
|
|
917
|
-
return t("custom_method_invoked",
|
|
917
|
+
return t("custom_method_invoked", oe().parse(s));
|
|
918
918
|
case "write_access_requested":
|
|
919
|
-
return t("write_access_requested",
|
|
919
|
+
return t("write_access_requested", de().parse(s));
|
|
920
920
|
case "main_button_pressed":
|
|
921
921
|
case "back_button_pressed":
|
|
922
922
|
case "settings_button_pressed":
|
|
@@ -927,31 +927,31 @@ function _e() {
|
|
|
927
927
|
return t(e, s);
|
|
928
928
|
}
|
|
929
929
|
} catch (n) {
|
|
930
|
-
|
|
930
|
+
V.error("Error processing event:", n);
|
|
931
931
|
}
|
|
932
932
|
}), r;
|
|
933
933
|
}
|
|
934
934
|
const Q = "telegram-mini-apps-cached-emitter";
|
|
935
935
|
function U() {
|
|
936
936
|
const r = window;
|
|
937
|
-
return r[Q] === void 0 && (r[Q] =
|
|
937
|
+
return r[Q] === void 0 && (r[Q] = fe()), r[Q];
|
|
938
938
|
}
|
|
939
|
-
function
|
|
939
|
+
function $(r, t) {
|
|
940
940
|
U().off(r, t);
|
|
941
941
|
}
|
|
942
942
|
function y(r, t) {
|
|
943
|
-
return U().on(r, t), () =>
|
|
943
|
+
return U().on(r, t), () => $(r, t);
|
|
944
944
|
}
|
|
945
|
-
function
|
|
946
|
-
return U().once(r, t), () =>
|
|
945
|
+
function nr(r, t) {
|
|
946
|
+
return U().once(r, t), () => $(r, t);
|
|
947
947
|
}
|
|
948
|
-
function
|
|
948
|
+
function ge(r) {
|
|
949
949
|
U().unsubscribe(r);
|
|
950
950
|
}
|
|
951
|
-
function
|
|
952
|
-
return U().subscribe(r), () =>
|
|
951
|
+
function ir(r) {
|
|
952
|
+
return U().subscribe(r), () => ge(r);
|
|
953
953
|
}
|
|
954
|
-
function
|
|
954
|
+
function we(r, t) {
|
|
955
955
|
const e = r.split("."), s = t.split("."), n = Math.max(e.length, s.length);
|
|
956
956
|
for (let i = 0; i < n; i += 1) {
|
|
957
957
|
const a = parseInt(e[i] || "0", 10), c = parseInt(s[i] || "0", 10);
|
|
@@ -960,15 +960,15 @@ function me(r, t) {
|
|
|
960
960
|
}
|
|
961
961
|
return 0;
|
|
962
962
|
}
|
|
963
|
-
function
|
|
964
|
-
return
|
|
963
|
+
function P(r, t) {
|
|
964
|
+
return we(r, t) <= 0;
|
|
965
965
|
}
|
|
966
|
-
function
|
|
966
|
+
function R(r, t, e) {
|
|
967
967
|
if (typeof e == "string") {
|
|
968
968
|
if (r === "web_app_open_link" && t === "try_instant_view")
|
|
969
|
-
return
|
|
969
|
+
return P("6.4", e);
|
|
970
970
|
if (r === "web_app_set_header_color" && t === "color")
|
|
971
|
-
return
|
|
971
|
+
return P("6.9", e);
|
|
972
972
|
}
|
|
973
973
|
switch (r) {
|
|
974
974
|
case "web_app_open_tg_link":
|
|
@@ -977,50 +977,50 @@ function A(r, t, e) {
|
|
|
977
977
|
case "web_app_set_background_color":
|
|
978
978
|
case "web_app_set_header_color":
|
|
979
979
|
case "web_app_trigger_haptic_feedback":
|
|
980
|
-
return
|
|
980
|
+
return P("6.1", t);
|
|
981
981
|
case "web_app_open_popup":
|
|
982
|
-
return
|
|
982
|
+
return P("6.2", t);
|
|
983
983
|
case "web_app_close_scan_qr_popup":
|
|
984
984
|
case "web_app_open_scan_qr_popup":
|
|
985
985
|
case "web_app_read_text_from_clipboard":
|
|
986
|
-
return
|
|
986
|
+
return P("6.4", t);
|
|
987
987
|
case "web_app_switch_inline_query":
|
|
988
|
-
return
|
|
988
|
+
return P("6.7", t);
|
|
989
989
|
case "web_app_invoke_custom_method":
|
|
990
990
|
case "web_app_request_write_access":
|
|
991
991
|
case "web_app_request_phone":
|
|
992
|
-
return
|
|
992
|
+
return P("6.9", t);
|
|
993
993
|
case "web_app_setup_settings_button":
|
|
994
|
-
return
|
|
994
|
+
return P("6.10", t);
|
|
995
995
|
default:
|
|
996
996
|
return !0;
|
|
997
997
|
}
|
|
998
998
|
}
|
|
999
999
|
function E(r, t) {
|
|
1000
|
-
return (e) =>
|
|
1000
|
+
return (e) => R(t[e], r);
|
|
1001
1001
|
}
|
|
1002
|
-
function
|
|
1002
|
+
function St(r, t) {
|
|
1003
1003
|
return (e) => {
|
|
1004
1004
|
const [s, n] = t[e];
|
|
1005
|
-
return
|
|
1005
|
+
return R(s, n, r);
|
|
1006
1006
|
};
|
|
1007
1007
|
}
|
|
1008
|
-
function
|
|
1008
|
+
function d(r, t, e) {
|
|
1009
1009
|
let s = {}, n;
|
|
1010
1010
|
t === void 0 && e === void 0 ? s = {} : t !== void 0 && e !== void 0 ? (s = e, n = t) : t !== void 0 && ("targetOrigin" in t ? s = t : n = t);
|
|
1011
|
-
const { targetOrigin: i =
|
|
1012
|
-
if (
|
|
1011
|
+
const { targetOrigin: i = te() } = s;
|
|
1012
|
+
if (V.log(`Calling method "${r}"`, n), vt()) {
|
|
1013
1013
|
window.parent.postMessage(JSON.stringify({
|
|
1014
1014
|
eventType: r,
|
|
1015
1015
|
eventData: n
|
|
1016
1016
|
}), i);
|
|
1017
1017
|
return;
|
|
1018
1018
|
}
|
|
1019
|
-
if (
|
|
1019
|
+
if (Yt(window)) {
|
|
1020
1020
|
window.external.notify(JSON.stringify({ eventType: r, eventData: n }));
|
|
1021
1021
|
return;
|
|
1022
1022
|
}
|
|
1023
|
-
if (
|
|
1023
|
+
if (Xt(window)) {
|
|
1024
1024
|
window.TelegramWebviewProxy.postEvent(r, JSON.stringify(n));
|
|
1025
1025
|
return;
|
|
1026
1026
|
}
|
|
@@ -1028,16 +1028,16 @@ function f(r, t, e) {
|
|
|
1028
1028
|
"Unable to determine current environment and possible way to send event."
|
|
1029
1029
|
);
|
|
1030
1030
|
}
|
|
1031
|
-
function
|
|
1031
|
+
function _e(r) {
|
|
1032
1032
|
return (t, e) => {
|
|
1033
|
-
if (!
|
|
1033
|
+
if (!R(t, r))
|
|
1034
1034
|
throw new tt(t, r);
|
|
1035
1035
|
if (H(e)) {
|
|
1036
1036
|
let s;
|
|
1037
|
-
if (t === "web_app_open_link" && "try_instant_view" in e ? s = "try_instant_view" : t === "web_app_set_header_color" && "color" in e && (s = "color"), s && !
|
|
1037
|
+
if (t === "web_app_open_link" && "try_instant_view" in e ? s = "try_instant_view" : t === "web_app_set_header_color" && "color" in e && (s = "color"), s && !R(t, s, r))
|
|
1038
1038
|
throw new et(t, s, r);
|
|
1039
1039
|
}
|
|
1040
|
-
return
|
|
1040
|
+
return d(t, e);
|
|
1041
1041
|
};
|
|
1042
1042
|
}
|
|
1043
1043
|
class J extends Error {
|
|
@@ -1045,15 +1045,15 @@ class J extends Error {
|
|
|
1045
1045
|
super(`Async call timeout exceeded. Timeout: ${t}`), Object.setPrototypeOf(this, J.prototype);
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
|
-
function
|
|
1048
|
+
function or(r) {
|
|
1049
1049
|
return r instanceof J;
|
|
1050
1050
|
}
|
|
1051
|
-
function
|
|
1051
|
+
function be(r) {
|
|
1052
1052
|
return new Promise((t) => {
|
|
1053
1053
|
setTimeout(t, r);
|
|
1054
1054
|
});
|
|
1055
1055
|
}
|
|
1056
|
-
function
|
|
1056
|
+
function me(r) {
|
|
1057
1057
|
return new Promise((t, e) => {
|
|
1058
1058
|
setTimeout(e, r, new J(r));
|
|
1059
1059
|
});
|
|
@@ -1061,23 +1061,23 @@ function Ce(r) {
|
|
|
1061
1061
|
function xt(r, t) {
|
|
1062
1062
|
return Promise.race([
|
|
1063
1063
|
r(),
|
|
1064
|
-
|
|
1064
|
+
me(t)
|
|
1065
1065
|
]);
|
|
1066
1066
|
}
|
|
1067
1067
|
function m(r, t, e, s) {
|
|
1068
1068
|
let n, i, a, c;
|
|
1069
1069
|
typeof t == "string" || Array.isArray(t) ? (a = Array.isArray(t) ? t : [t], n = e) : (i = t, a = Array.isArray(e) ? e : [e], n = s), H(i) && typeof i.req_id == "string" && (c = i.req_id);
|
|
1070
|
-
const { postEvent:
|
|
1071
|
-
const
|
|
1072
|
-
c && (!H(M) || M.req_id !== c) || typeof
|
|
1073
|
-
})),
|
|
1070
|
+
const { postEvent: p = d, timeout: u } = n || {}, g = n && "capture" in n ? n.capture : null, _ = () => new Promise((A, l) => {
|
|
1071
|
+
const C = a.map((v) => y(v, (M) => {
|
|
1072
|
+
c && (!H(M) || M.req_id !== c) || typeof g == "function" && !g(M) || (x(), A(M));
|
|
1073
|
+
})), x = () => C.forEach((v) => v());
|
|
1074
1074
|
try {
|
|
1075
|
-
|
|
1076
|
-
} catch (
|
|
1077
|
-
|
|
1075
|
+
p(r, i);
|
|
1076
|
+
} catch (v) {
|
|
1077
|
+
x(), l(v);
|
|
1078
1078
|
}
|
|
1079
1079
|
});
|
|
1080
|
-
return typeof
|
|
1080
|
+
return typeof u == "number" ? xt(_, u) : _();
|
|
1081
1081
|
}
|
|
1082
1082
|
async function N(r, t, e, s = {}) {
|
|
1083
1083
|
const { result: n, error: i } = await m(
|
|
@@ -1094,8 +1094,8 @@ async function N(r, t, e, s = {}) {
|
|
|
1094
1094
|
throw new Error(i);
|
|
1095
1095
|
return n;
|
|
1096
1096
|
}
|
|
1097
|
-
class
|
|
1098
|
-
constructor(t, e, s =
|
|
1097
|
+
class ye {
|
|
1098
|
+
constructor(t, e, s = d) {
|
|
1099
1099
|
o(this, "ee", new w());
|
|
1100
1100
|
o(this, "state");
|
|
1101
1101
|
/**
|
|
@@ -1109,12 +1109,12 @@ class ve {
|
|
|
1109
1109
|
* @param event - event name.
|
|
1110
1110
|
* @param listener - event listener.
|
|
1111
1111
|
*/
|
|
1112
|
-
o(this, "off", (t, e) => t === "click" ?
|
|
1112
|
+
o(this, "off", (t, e) => t === "click" ? $("back_button_pressed", e) : this.ee.off(t, e));
|
|
1113
1113
|
/**
|
|
1114
1114
|
* Checks if specified method is supported by current component.
|
|
1115
1115
|
*/
|
|
1116
1116
|
o(this, "supports");
|
|
1117
|
-
this.postEvent = s, this.state = new
|
|
1117
|
+
this.postEvent = s, this.state = new b({ isVisible: t }, this.ee), this.supports = E(e, {
|
|
1118
1118
|
show: "web_app_setup_back_button",
|
|
1119
1119
|
hide: "web_app_setup_back_button"
|
|
1120
1120
|
});
|
|
@@ -1144,23 +1144,23 @@ class ve {
|
|
|
1144
1144
|
function nt(r, t) {
|
|
1145
1145
|
return r + (r.length > 0 && t.length > 0 ? ` ${t}` : t);
|
|
1146
1146
|
}
|
|
1147
|
-
function
|
|
1147
|
+
function Ee(...r) {
|
|
1148
1148
|
return r.reduce((t, e) => {
|
|
1149
1149
|
let s = "";
|
|
1150
1150
|
return typeof e == "string" ? s = e : typeof e == "object" && e !== null && (s = Object.entries(e).reduce((n, [i, a]) => a ? nt(n, i) : n, "")), nt(t, s);
|
|
1151
1151
|
}, "");
|
|
1152
1152
|
}
|
|
1153
|
-
function
|
|
1153
|
+
function Ce(r) {
|
|
1154
1154
|
return typeof r == "object" && r !== null && !Array.isArray(null);
|
|
1155
1155
|
}
|
|
1156
|
-
function
|
|
1157
|
-
return r.reduce((t, e) => (
|
|
1158
|
-
const i =
|
|
1156
|
+
function ar(...r) {
|
|
1157
|
+
return r.reduce((t, e) => (Ce(e) && Object.entries(e).forEach(([s, n]) => {
|
|
1158
|
+
const i = Ee(t[s], n);
|
|
1159
1159
|
i.length > 0 && (t[s] = i);
|
|
1160
1160
|
}), t), {});
|
|
1161
1161
|
}
|
|
1162
|
-
class
|
|
1163
|
-
constructor(t, e =
|
|
1162
|
+
class ve {
|
|
1163
|
+
constructor(t, e = d) {
|
|
1164
1164
|
o(this, "ee", new w());
|
|
1165
1165
|
o(this, "state");
|
|
1166
1166
|
/**
|
|
@@ -1171,7 +1171,7 @@ class ke {
|
|
|
1171
1171
|
* Removes event listener.
|
|
1172
1172
|
*/
|
|
1173
1173
|
o(this, "off", this.ee.off.bind(this.ee));
|
|
1174
|
-
this.postEvent = e, this.state = new
|
|
1174
|
+
this.postEvent = e, this.state = new b({ isConfirmationNeeded: t }, this.ee);
|
|
1175
1175
|
}
|
|
1176
1176
|
set isConfirmationNeeded(t) {
|
|
1177
1177
|
this.state.set("isConfirmationNeeded", t), this.postEvent("web_app_setup_closing_behavior", { need_confirmation: t });
|
|
@@ -1201,8 +1201,8 @@ class ke {
|
|
|
1201
1201
|
function it(r, t) {
|
|
1202
1202
|
return r.reduce((e, s) => (e[s] = t, e), {});
|
|
1203
1203
|
}
|
|
1204
|
-
class
|
|
1205
|
-
constructor(t, e, s =
|
|
1204
|
+
class Pe {
|
|
1205
|
+
constructor(t, e, s = d) {
|
|
1206
1206
|
/**
|
|
1207
1207
|
* Checks if specified method is supported by current component.
|
|
1208
1208
|
*/
|
|
@@ -1239,13 +1239,13 @@ class xe {
|
|
|
1239
1239
|
this.createRequestId(),
|
|
1240
1240
|
{ ...t, postEvent: this.postEvent }
|
|
1241
1241
|
);
|
|
1242
|
-
return
|
|
1242
|
+
return Bt().of(h()).parse(e);
|
|
1243
1243
|
}
|
|
1244
1244
|
async get(t, e = {}) {
|
|
1245
1245
|
const s = Array.isArray(t) ? t : [t];
|
|
1246
1246
|
if (s.length === 0)
|
|
1247
1247
|
return it(s, "");
|
|
1248
|
-
const n =
|
|
1248
|
+
const n = f(
|
|
1249
1249
|
it(s, h())
|
|
1250
1250
|
), i = await N(
|
|
1251
1251
|
"getStorageValues",
|
|
@@ -1270,8 +1270,8 @@ class xe {
|
|
|
1270
1270
|
);
|
|
1271
1271
|
}
|
|
1272
1272
|
}
|
|
1273
|
-
class
|
|
1274
|
-
constructor(t, e =
|
|
1273
|
+
class ke {
|
|
1274
|
+
constructor(t, e = d) {
|
|
1275
1275
|
/**
|
|
1276
1276
|
* Checks if specified method is supported by current component.
|
|
1277
1277
|
*/
|
|
@@ -1316,7 +1316,7 @@ class qe {
|
|
|
1316
1316
|
this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
|
|
1317
1317
|
}
|
|
1318
1318
|
}
|
|
1319
|
-
function
|
|
1319
|
+
function Se() {
|
|
1320
1320
|
const r = document.createElement("style");
|
|
1321
1321
|
r.id = "telegram-custom-styles", document.head.appendChild(r), y("set_custom_style", (t) => {
|
|
1322
1322
|
r.innerHTML = t;
|
|
@@ -1325,26 +1325,26 @@ function Ae() {
|
|
|
1325
1325
|
function qt(r) {
|
|
1326
1326
|
return `telegram-mini-apps-${r}`;
|
|
1327
1327
|
}
|
|
1328
|
-
function
|
|
1328
|
+
function T(r, t) {
|
|
1329
1329
|
sessionStorage.setItem(qt(r), JSON.stringify(t));
|
|
1330
1330
|
}
|
|
1331
|
-
function
|
|
1331
|
+
function B(r) {
|
|
1332
1332
|
const t = sessionStorage.getItem(qt(r));
|
|
1333
1333
|
return t ? JSON.parse(t) : null;
|
|
1334
1334
|
}
|
|
1335
|
-
function
|
|
1336
|
-
const { isVisible: s = !1 } = r ?
|
|
1335
|
+
function xe(r, t, e) {
|
|
1336
|
+
const { isVisible: s = !1 } = r ? B("back-button") || {} : {}, n = new ye(s, t, e);
|
|
1337
1337
|
return n.on("change", () => {
|
|
1338
|
-
|
|
1338
|
+
T("back-button", { isVisible: n.isVisible });
|
|
1339
1339
|
}), n;
|
|
1340
1340
|
}
|
|
1341
|
-
function
|
|
1342
|
-
const { isConfirmationNeeded: e = !1 } = r ?
|
|
1343
|
-
return s.on("change", () =>
|
|
1341
|
+
function qe(r, t) {
|
|
1342
|
+
const { isConfirmationNeeded: e = !1 } = r ? B("closing-behavior") || {} : {}, s = new ve(e, t);
|
|
1343
|
+
return s.on("change", () => T("closing-behavior", {
|
|
1344
1344
|
isConfirmationNeeded: s.isConfirmationNeeded
|
|
1345
1345
|
})), s;
|
|
1346
1346
|
}
|
|
1347
|
-
class
|
|
1347
|
+
class Ae {
|
|
1348
1348
|
constructor(t) {
|
|
1349
1349
|
o(this, "ee", new w());
|
|
1350
1350
|
o(this, "state");
|
|
@@ -1365,21 +1365,21 @@ class Ie {
|
|
|
1365
1365
|
* @param event - event name.
|
|
1366
1366
|
* @param listener - event listener.
|
|
1367
1367
|
*/
|
|
1368
|
-
o(this, "off", (t, e) => t === "click" ?
|
|
1368
|
+
o(this, "off", (t, e) => t === "click" ? $("main_button_pressed", e) : this.ee.off(t, e));
|
|
1369
1369
|
const {
|
|
1370
|
-
postEvent: e =
|
|
1370
|
+
postEvent: e = d,
|
|
1371
1371
|
text: s,
|
|
1372
1372
|
textColor: n,
|
|
1373
1373
|
backgroundColor: i,
|
|
1374
1374
|
isEnabled: a,
|
|
1375
1375
|
isVisible: c,
|
|
1376
|
-
isLoaderVisible:
|
|
1376
|
+
isLoaderVisible: p
|
|
1377
1377
|
} = t;
|
|
1378
|
-
this.postEvent = e, this.state = new
|
|
1378
|
+
this.postEvent = e, this.state = new b({
|
|
1379
1379
|
backgroundColor: i,
|
|
1380
1380
|
isEnabled: a,
|
|
1381
1381
|
isVisible: c,
|
|
1382
|
-
isLoaderVisible:
|
|
1382
|
+
isLoaderVisible: p,
|
|
1383
1383
|
text: s,
|
|
1384
1384
|
textColor: n
|
|
1385
1385
|
}, this.ee);
|
|
@@ -1509,36 +1509,36 @@ class Ie {
|
|
|
1509
1509
|
return this.state.set(t), this.commit(), this;
|
|
1510
1510
|
}
|
|
1511
1511
|
}
|
|
1512
|
-
function
|
|
1512
|
+
function Ve(r, t, e, s) {
|
|
1513
1513
|
const {
|
|
1514
1514
|
backgroundColor: n = t,
|
|
1515
1515
|
isEnabled: i = !1,
|
|
1516
1516
|
isVisible: a = !1,
|
|
1517
1517
|
isLoaderVisible: c = !1,
|
|
1518
|
-
textColor:
|
|
1519
|
-
text:
|
|
1520
|
-
} = r ?
|
|
1518
|
+
textColor: p = e,
|
|
1519
|
+
text: u = ""
|
|
1520
|
+
} = r ? B("main-button") || {} : {}, g = new Ae({
|
|
1521
1521
|
backgroundColor: n,
|
|
1522
1522
|
isEnabled: i,
|
|
1523
1523
|
isLoaderVisible: c,
|
|
1524
1524
|
isVisible: a,
|
|
1525
1525
|
postEvent: s,
|
|
1526
|
-
text:
|
|
1527
|
-
textColor:
|
|
1528
|
-
}),
|
|
1529
|
-
backgroundColor:
|
|
1530
|
-
isEnabled:
|
|
1531
|
-
isLoaderVisible:
|
|
1532
|
-
isVisible:
|
|
1533
|
-
text:
|
|
1534
|
-
textColor:
|
|
1526
|
+
text: u,
|
|
1527
|
+
textColor: p
|
|
1528
|
+
}), _ = () => T("main-button", {
|
|
1529
|
+
backgroundColor: g.backgroundColor,
|
|
1530
|
+
isEnabled: g.isEnabled,
|
|
1531
|
+
isLoaderVisible: g.isLoaderVisible,
|
|
1532
|
+
isVisible: g.isVisible,
|
|
1533
|
+
text: g.text,
|
|
1534
|
+
textColor: g.textColor
|
|
1535
1535
|
});
|
|
1536
|
-
return
|
|
1536
|
+
return g.on("change", _), g;
|
|
1537
1537
|
}
|
|
1538
|
-
const
|
|
1539
|
-
contact:
|
|
1538
|
+
const Re = X({
|
|
1539
|
+
contact: f({
|
|
1540
1540
|
userId: {
|
|
1541
|
-
type:
|
|
1541
|
+
type: q(),
|
|
1542
1542
|
from: "user_id"
|
|
1543
1543
|
},
|
|
1544
1544
|
phoneNumber: {
|
|
@@ -1550,7 +1550,7 @@ const $e = X({
|
|
|
1550
1550
|
from: "first_name"
|
|
1551
1551
|
},
|
|
1552
1552
|
lastName: {
|
|
1553
|
-
type: h(),
|
|
1553
|
+
type: h().optional(),
|
|
1554
1554
|
from: "last_name"
|
|
1555
1555
|
}
|
|
1556
1556
|
}),
|
|
@@ -1560,7 +1560,7 @@ const $e = X({
|
|
|
1560
1560
|
},
|
|
1561
1561
|
hash: h()
|
|
1562
1562
|
});
|
|
1563
|
-
class
|
|
1563
|
+
class Ie {
|
|
1564
1564
|
constructor(t) {
|
|
1565
1565
|
o(this, "ee", new w());
|
|
1566
1566
|
o(this, "state");
|
|
@@ -1586,20 +1586,20 @@ class Te {
|
|
|
1586
1586
|
*/
|
|
1587
1587
|
o(this, "supportsParam");
|
|
1588
1588
|
const {
|
|
1589
|
-
postEvent: e =
|
|
1589
|
+
postEvent: e = d,
|
|
1590
1590
|
headerColor: s,
|
|
1591
1591
|
backgroundColor: n,
|
|
1592
1592
|
version: i,
|
|
1593
1593
|
botInline: a,
|
|
1594
1594
|
createRequestId: c
|
|
1595
|
-
} = t,
|
|
1595
|
+
} = t, p = E(i, {
|
|
1596
1596
|
requestPhoneAccess: "web_app_request_phone",
|
|
1597
1597
|
requestWriteAccess: "web_app_request_write_access",
|
|
1598
1598
|
switchInlineQuery: "web_app_switch_inline_query",
|
|
1599
1599
|
setHeaderColor: "web_app_set_header_color",
|
|
1600
1600
|
setBackgroundColor: "web_app_set_background_color"
|
|
1601
1601
|
});
|
|
1602
|
-
this.postEvent = e, this.botInline = a, this.createRequestId = c, this.supports = (
|
|
1602
|
+
this.postEvent = e, this.botInline = a, this.createRequestId = c, this.supports = (u) => !(!p(u) || u === "switchInlineQuery" && !a), this.state = new b({ backgroundColor: n, headerColor: s }, this.ee), this.supportsParam = St(i, {
|
|
1603
1603
|
"setHeaderColor.color": ["web_app_set_header_color", "color"]
|
|
1604
1604
|
});
|
|
1605
1605
|
}
|
|
@@ -1615,7 +1615,7 @@ class Te {
|
|
|
1615
1615
|
postEvent: this.postEvent,
|
|
1616
1616
|
timeout: 1e4
|
|
1617
1617
|
}
|
|
1618
|
-
).then((t) =>
|
|
1618
|
+
).then((t) => Re.parse(t));
|
|
1619
1619
|
}
|
|
1620
1620
|
/**
|
|
1621
1621
|
* The Mini App background color.
|
|
@@ -1692,7 +1692,7 @@ class Te {
|
|
|
1692
1692
|
return await this.getRequestedContact();
|
|
1693
1693
|
} catch {
|
|
1694
1694
|
}
|
|
1695
|
-
await
|
|
1695
|
+
await be(n), n += 50;
|
|
1696
1696
|
}
|
|
1697
1697
|
throw new Error("Unable to retrieve requested contact.");
|
|
1698
1698
|
}, t);
|
|
@@ -1778,29 +1778,29 @@ class Te {
|
|
|
1778
1778
|
});
|
|
1779
1779
|
}
|
|
1780
1780
|
}
|
|
1781
|
-
function
|
|
1781
|
+
function Le(r, t, e, s, n, i) {
|
|
1782
1782
|
const {
|
|
1783
1783
|
backgroundColor: a = t,
|
|
1784
1784
|
headerColor: c = "bg_color"
|
|
1785
|
-
} = r ?
|
|
1785
|
+
} = r ? B("mini-app") || {} : {}, p = new Ie({
|
|
1786
1786
|
headerColor: c,
|
|
1787
1787
|
backgroundColor: a,
|
|
1788
1788
|
version: e,
|
|
1789
1789
|
botInline: s,
|
|
1790
1790
|
createRequestId: n,
|
|
1791
1791
|
postEvent: i
|
|
1792
|
-
}),
|
|
1793
|
-
backgroundColor:
|
|
1794
|
-
headerColor:
|
|
1792
|
+
}), u = () => T("mini-app", {
|
|
1793
|
+
backgroundColor: p.backgroundColor,
|
|
1794
|
+
headerColor: p.headerColor
|
|
1795
1795
|
});
|
|
1796
|
-
return
|
|
1796
|
+
return p.on("change", u), p;
|
|
1797
1797
|
}
|
|
1798
|
-
function
|
|
1798
|
+
function $e() {
|
|
1799
1799
|
let r = 0;
|
|
1800
1800
|
return () => (r += 1, r.toString());
|
|
1801
1801
|
}
|
|
1802
|
-
class
|
|
1803
|
-
constructor(t, e, s =
|
|
1802
|
+
class Te {
|
|
1803
|
+
constructor(t, e, s = d) {
|
|
1804
1804
|
o(this, "ee", new w());
|
|
1805
1805
|
o(this, "state");
|
|
1806
1806
|
/**
|
|
@@ -1814,12 +1814,12 @@ class We {
|
|
|
1814
1814
|
* @param event - event name.
|
|
1815
1815
|
* @param listener - event listener.
|
|
1816
1816
|
*/
|
|
1817
|
-
o(this, "off", (t, e) => t === "click" ?
|
|
1817
|
+
o(this, "off", (t, e) => t === "click" ? $("settings_button_pressed", e) : this.ee.off(t, e));
|
|
1818
1818
|
/**
|
|
1819
1819
|
* Checks if specified method is supported by current component.
|
|
1820
1820
|
*/
|
|
1821
1821
|
o(this, "supports");
|
|
1822
|
-
this.postEvent = s, this.state = new
|
|
1822
|
+
this.postEvent = s, this.state = new b({ isVisible: t }, this.ee), this.supports = E(e, {
|
|
1823
1823
|
show: "web_app_setup_settings_button",
|
|
1824
1824
|
hide: "web_app_setup_settings_button"
|
|
1825
1825
|
});
|
|
@@ -1846,16 +1846,19 @@ class We {
|
|
|
1846
1846
|
this.isVisible = !0;
|
|
1847
1847
|
}
|
|
1848
1848
|
}
|
|
1849
|
-
function
|
|
1850
|
-
const { isVisible: s = !1 } = r ?
|
|
1849
|
+
function Be(r, t, e) {
|
|
1850
|
+
const { isVisible: s = !1 } = r ? B("settings-button") || {} : {}, n = new Te(s, t, e);
|
|
1851
1851
|
return n.on("change", () => {
|
|
1852
|
-
|
|
1852
|
+
T("settings-button", { isVisible: n.isVisible });
|
|
1853
1853
|
}), n;
|
|
1854
1854
|
}
|
|
1855
|
-
function
|
|
1856
|
-
const t = new
|
|
1855
|
+
function De(r) {
|
|
1856
|
+
const t = new Mt(r);
|
|
1857
1857
|
return t.listen(), t;
|
|
1858
1858
|
}
|
|
1859
|
+
function We(r) {
|
|
1860
|
+
return ["macos", "tdesktop", "unigram", "web", "weba"].includes(r);
|
|
1861
|
+
}
|
|
1859
1862
|
async function At(r) {
|
|
1860
1863
|
const t = await m("web_app_request_viewport", "viewport_changed", r);
|
|
1861
1864
|
return {
|
|
@@ -1868,7 +1871,7 @@ async function At(r) {
|
|
|
1868
1871
|
function D(r) {
|
|
1869
1872
|
return r < 0 ? 0 : r;
|
|
1870
1873
|
}
|
|
1871
|
-
class
|
|
1874
|
+
class Ne {
|
|
1872
1875
|
constructor(t) {
|
|
1873
1876
|
o(this, "ee", new w());
|
|
1874
1877
|
o(this, "state");
|
|
@@ -1886,9 +1889,9 @@ class G {
|
|
|
1886
1889
|
isExpanded: s,
|
|
1887
1890
|
width: n,
|
|
1888
1891
|
stableHeight: i,
|
|
1889
|
-
postEvent: a =
|
|
1892
|
+
postEvent: a = d
|
|
1890
1893
|
} = t;
|
|
1891
|
-
this.postEvent = a, this.state = new
|
|
1894
|
+
this.postEvent = a, this.state = new b({
|
|
1892
1895
|
height: D(e),
|
|
1893
1896
|
isExpanded: s,
|
|
1894
1897
|
stableHeight: D(i),
|
|
@@ -1997,56 +2000,51 @@ class G {
|
|
|
1997
2000
|
return this.stableHeight === this.height;
|
|
1998
2001
|
}
|
|
1999
2002
|
}
|
|
2000
|
-
function
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2003
|
+
function j(r) {
|
|
2004
|
+
const t = new Ne(r);
|
|
2005
|
+
return t.on("change", () => T("viewport", {
|
|
2006
|
+
height: t.height,
|
|
2007
|
+
isExpanded: t.isExpanded,
|
|
2008
|
+
stableHeight: t.stableHeight,
|
|
2009
|
+
width: t.width
|
|
2010
|
+
})), t.listen(), t;
|
|
2011
|
+
}
|
|
2012
|
+
function Oe(r, t, e, s) {
|
|
2013
|
+
const n = r ? B("viewport") : null;
|
|
2014
|
+
if (n)
|
|
2015
|
+
return j({ ...n, postEvent: e });
|
|
2016
|
+
if (We(t))
|
|
2017
|
+
return j({
|
|
2006
2018
|
height: window.innerHeight,
|
|
2007
2019
|
isExpanded: !0,
|
|
2008
2020
|
postEvent: e,
|
|
2009
2021
|
stableHeight: window.innerHeight,
|
|
2010
2022
|
width: window.innerWidth
|
|
2011
2023
|
});
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
}
|
|
2015
|
-
function It(r) {
|
|
2016
|
-
return r.listen(), r.on("change", () => L("viewport", {
|
|
2017
|
-
height: r.height,
|
|
2018
|
-
isExpanded: r.isExpanded,
|
|
2019
|
-
stableHeight: r.stableHeight,
|
|
2020
|
-
width: r.width
|
|
2021
|
-
})), r;
|
|
2022
|
-
}
|
|
2023
|
-
function He(r, t, e) {
|
|
2024
|
-
const s = It(
|
|
2025
|
-
Vt(r, t, e) || new G({
|
|
2026
|
-
width: 0,
|
|
2027
|
-
height: 0,
|
|
2028
|
-
isExpanded: !1,
|
|
2024
|
+
if (s)
|
|
2025
|
+
return At({
|
|
2029
2026
|
postEvent: e,
|
|
2030
|
-
|
|
2031
|
-
})
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2027
|
+
timeout: 5e3
|
|
2028
|
+
}).then(({ height: a, isStateStable: c, ...p }) => j({
|
|
2029
|
+
...p,
|
|
2030
|
+
height: a,
|
|
2031
|
+
stableHeight: c ? a : 0
|
|
2032
|
+
}));
|
|
2033
|
+
const i = j({
|
|
2034
|
+
width: 0,
|
|
2035
|
+
height: 0,
|
|
2036
|
+
isExpanded: !1,
|
|
2037
|
+
postEvent: e,
|
|
2038
|
+
stableHeight: 0
|
|
2039
|
+
});
|
|
2040
|
+
return i.sync({ postEvent: e, timeout: 5e3 }).catch((a) => {
|
|
2041
|
+
console.error("Unable to actualize viewport state", a);
|
|
2042
|
+
}), i;
|
|
2045
2043
|
}
|
|
2046
2044
|
function S(r, t) {
|
|
2047
2045
|
document.documentElement.style.setProperty(r, t);
|
|
2048
2046
|
}
|
|
2049
|
-
function
|
|
2047
|
+
function He(r, t) {
|
|
2050
2048
|
const e = () => {
|
|
2051
2049
|
S("--tg-background-color", r.backgroundColor);
|
|
2052
2050
|
}, s = () => {
|
|
@@ -2058,7 +2056,7 @@ function Me(r, t) {
|
|
|
2058
2056
|
};
|
|
2059
2057
|
t.on("change", s), r.on("change:backgroundColor", e), r.on("change:headerColor", s), e(), s();
|
|
2060
2058
|
}
|
|
2061
|
-
function
|
|
2059
|
+
function Ue(r) {
|
|
2062
2060
|
const t = () => {
|
|
2063
2061
|
const e = r.getState();
|
|
2064
2062
|
Object.entries(e).forEach(([s, n]) => {
|
|
@@ -2074,7 +2072,7 @@ function ot(r) {
|
|
|
2074
2072
|
const t = () => S("--tg-viewport-height", `${r.height}px`), e = () => S("--tg-viewport-width", `${r.width}px`), s = () => S("--tg-viewport-height", `${r.stableHeight}px`);
|
|
2075
2073
|
r.on("change:height", t), r.on("change:width", e), r.on("change:stableHeight", s), t(), e(), s();
|
|
2076
2074
|
}
|
|
2077
|
-
function
|
|
2075
|
+
function Me(r) {
|
|
2078
2076
|
return typeof r == "object" ? r : r ? {
|
|
2079
2077
|
themeParams: !0,
|
|
2080
2078
|
viewport: !0,
|
|
@@ -2082,10 +2080,10 @@ function Ge(r) {
|
|
|
2082
2080
|
} : {};
|
|
2083
2081
|
}
|
|
2084
2082
|
function at(r, t, e, s) {
|
|
2085
|
-
const n =
|
|
2086
|
-
n.miniApp &&
|
|
2083
|
+
const n = Me(r);
|
|
2084
|
+
n.miniApp && He(t, e), n.themeParams && Ue(e), n.viewport && (s instanceof Promise ? s.then(ot) : ot(s));
|
|
2087
2085
|
}
|
|
2088
|
-
function
|
|
2086
|
+
function je(r) {
|
|
2089
2087
|
const { hostname: t, pathname: e } = new URL(r, window.location.href);
|
|
2090
2088
|
if (t !== "t.me")
|
|
2091
2089
|
throw new Error(`Incorrect hostname: ${t}`);
|
|
@@ -2094,8 +2092,8 @@ function Fe(r) {
|
|
|
2094
2092
|
throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
|
|
2095
2093
|
return s[2];
|
|
2096
2094
|
}
|
|
2097
|
-
class
|
|
2098
|
-
constructor(t, e =
|
|
2095
|
+
class Ge {
|
|
2096
|
+
constructor(t, e = d) {
|
|
2099
2097
|
o(this, "ee", new w());
|
|
2100
2098
|
o(this, "state");
|
|
2101
2099
|
/**
|
|
@@ -2110,7 +2108,7 @@ class ze {
|
|
|
2110
2108
|
* Checks if specified method is supported by current component.
|
|
2111
2109
|
*/
|
|
2112
2110
|
o(this, "supports");
|
|
2113
|
-
this.postEvent = e, this.state = new
|
|
2111
|
+
this.postEvent = e, this.state = new b({ isOpened: !1 }, this.ee), this.supports = E(t, { open: "web_app_open_invoice" });
|
|
2114
2112
|
}
|
|
2115
2113
|
set isOpened(t) {
|
|
2116
2114
|
this.state.set("isOpened", t);
|
|
@@ -2124,7 +2122,7 @@ class ze {
|
|
|
2124
2122
|
async open(t, e) {
|
|
2125
2123
|
if (this.isOpened)
|
|
2126
2124
|
throw new Error("Invoice is already opened");
|
|
2127
|
-
const s = e ?
|
|
2125
|
+
const s = e ? je(t) : t;
|
|
2128
2126
|
this.isOpened = !0;
|
|
2129
2127
|
try {
|
|
2130
2128
|
return (await m(
|
|
@@ -2143,7 +2141,7 @@ class ze {
|
|
|
2143
2141
|
}
|
|
2144
2142
|
}
|
|
2145
2143
|
}
|
|
2146
|
-
function
|
|
2144
|
+
function Fe(r) {
|
|
2147
2145
|
const t = r.message.trim(), e = (r.title || "").trim(), s = r.buttons || [];
|
|
2148
2146
|
let n;
|
|
2149
2147
|
if (e.length > 64)
|
|
@@ -2159,16 +2157,16 @@ function Je(r) {
|
|
|
2159
2157
|
if (i.type === void 0 || i.type === "default" || i.type === "destructive") {
|
|
2160
2158
|
const c = i.text.trim();
|
|
2161
2159
|
if (c.length === 0 || c.length > 64) {
|
|
2162
|
-
const
|
|
2163
|
-
throw new Error(`Button text with type "${
|
|
2160
|
+
const p = i.type || "default";
|
|
2161
|
+
throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
|
|
2164
2162
|
}
|
|
2165
2163
|
return { ...i, text: c, id: a };
|
|
2166
2164
|
}
|
|
2167
2165
|
return { ...i, id: a };
|
|
2168
2166
|
}), { title: e, message: t, buttons: n };
|
|
2169
2167
|
}
|
|
2170
|
-
class
|
|
2171
|
-
constructor(t, e =
|
|
2168
|
+
class ze {
|
|
2169
|
+
constructor(t, e = d) {
|
|
2172
2170
|
o(this, "ee", new w());
|
|
2173
2171
|
o(this, "state");
|
|
2174
2172
|
/**
|
|
@@ -2183,7 +2181,7 @@ class Qe {
|
|
|
2183
2181
|
* Checks if specified method is supported by current component.
|
|
2184
2182
|
*/
|
|
2185
2183
|
o(this, "supports");
|
|
2186
|
-
this.postEvent = e, this.state = new
|
|
2184
|
+
this.postEvent = e, this.state = new b({ isOpened: !1 }, this.ee), this.supports = E(t, { open: "web_app_open_popup" });
|
|
2187
2185
|
}
|
|
2188
2186
|
set isOpened(t) {
|
|
2189
2187
|
this.state.set("isOpened", t);
|
|
@@ -2212,7 +2210,7 @@ class Qe {
|
|
|
2212
2210
|
throw new Error("Popup is already opened.");
|
|
2213
2211
|
return this.isOpened = !0, m(
|
|
2214
2212
|
"web_app_open_popup",
|
|
2215
|
-
|
|
2213
|
+
Fe(t),
|
|
2216
2214
|
"popup_closed",
|
|
2217
2215
|
{ postEvent: this.postEvent }
|
|
2218
2216
|
).then(({ button_id: e = null }) => e).finally(() => {
|
|
@@ -2220,8 +2218,8 @@ class Qe {
|
|
|
2220
2218
|
});
|
|
2221
2219
|
}
|
|
2222
2220
|
}
|
|
2223
|
-
class
|
|
2224
|
-
constructor(t, e =
|
|
2221
|
+
class Je {
|
|
2222
|
+
constructor(t, e = d) {
|
|
2225
2223
|
o(this, "ee", new w());
|
|
2226
2224
|
o(this, "state");
|
|
2227
2225
|
/**
|
|
@@ -2236,7 +2234,7 @@ class Ze {
|
|
|
2236
2234
|
* Checks if specified method is supported by current component.
|
|
2237
2235
|
*/
|
|
2238
2236
|
o(this, "supports");
|
|
2239
|
-
this.postEvent = e, this.state = new
|
|
2237
|
+
this.postEvent = e, this.state = new b({ isOpened: !1 }, this.ee), this.supports = E(t, {
|
|
2240
2238
|
close: "web_app_close_scan_qr_popup",
|
|
2241
2239
|
open: "web_app_open_scan_qr_popup"
|
|
2242
2240
|
});
|
|
@@ -2279,8 +2277,8 @@ class Ze {
|
|
|
2279
2277
|
}
|
|
2280
2278
|
}
|
|
2281
2279
|
}
|
|
2282
|
-
class
|
|
2283
|
-
constructor(t, e, s =
|
|
2280
|
+
class Qe {
|
|
2281
|
+
constructor(t, e, s = d) {
|
|
2284
2282
|
/**
|
|
2285
2283
|
* Checks if specified method is supported by current component.
|
|
2286
2284
|
*/
|
|
@@ -2291,7 +2289,7 @@ class Ke {
|
|
|
2291
2289
|
o(this, "supportsParam");
|
|
2292
2290
|
this.version = t, this.createRequestId = e, this.postEvent = s, this.supports = E(t, {
|
|
2293
2291
|
readTextFromClipboard: "web_app_read_text_from_clipboard"
|
|
2294
|
-
}), this.supportsParam =
|
|
2292
|
+
}), this.supportsParam = St(t, {
|
|
2295
2293
|
"openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
|
|
2296
2294
|
});
|
|
2297
2295
|
}
|
|
@@ -2306,7 +2304,7 @@ class Ke {
|
|
|
2306
2304
|
*/
|
|
2307
2305
|
openLink(t, e) {
|
|
2308
2306
|
const s = new URL(t, window.location.href).toString();
|
|
2309
|
-
if (!
|
|
2307
|
+
if (!R("web_app_open_link", this.version)) {
|
|
2310
2308
|
window.open(s, "_blank");
|
|
2311
2309
|
return;
|
|
2312
2310
|
}
|
|
@@ -2329,7 +2327,7 @@ class Ke {
|
|
|
2329
2327
|
} = new URL(t, window.location.href);
|
|
2330
2328
|
if (e !== "t.me")
|
|
2331
2329
|
throw new Error(`URL has not allowed hostname: ${e}. Only "t.me" is allowed`);
|
|
2332
|
-
if (!
|
|
2330
|
+
if (!R("web_app_open_tg_link", this.version)) {
|
|
2333
2331
|
window.location.href = t;
|
|
2334
2332
|
return;
|
|
2335
2333
|
}
|
|
@@ -2350,81 +2348,79 @@ class Ke {
|
|
|
2350
2348
|
).then(({ data: t = null }) => t);
|
|
2351
2349
|
}
|
|
2352
2350
|
}
|
|
2353
|
-
function
|
|
2351
|
+
function cr(r = {}) {
|
|
2354
2352
|
const {
|
|
2355
2353
|
async: t = !1,
|
|
2356
|
-
|
|
2357
|
-
|
|
2354
|
+
complete: e = t,
|
|
2355
|
+
cssVars: s = !1,
|
|
2356
|
+
acceptCustomStyles: n = !1
|
|
2358
2357
|
} = r;
|
|
2359
2358
|
try {
|
|
2360
2359
|
const {
|
|
2361
2360
|
launchParams: {
|
|
2362
|
-
initData:
|
|
2363
|
-
initDataRaw:
|
|
2364
|
-
version:
|
|
2365
|
-
platform:
|
|
2361
|
+
initData: i,
|
|
2362
|
+
initDataRaw: a,
|
|
2363
|
+
version: c,
|
|
2364
|
+
platform: p,
|
|
2366
2365
|
themeParams: u,
|
|
2367
|
-
botInline:
|
|
2366
|
+
botInline: g = !1
|
|
2368
2367
|
},
|
|
2369
|
-
isPageReload:
|
|
2370
|
-
} = Ct(),
|
|
2371
|
-
vt() && (
|
|
2368
|
+
isPageReload: _
|
|
2369
|
+
} = Ct(), A = $e(), l = _e(c);
|
|
2370
|
+
vt() && (n && Se(), l("iframe_ready", { reload_supported: !0 }), y("reload_iframe", () => window.location.reload()));
|
|
2372
2371
|
const C = {
|
|
2373
|
-
backButton:
|
|
2374
|
-
closingBehavior:
|
|
2375
|
-
cloudStorage: new
|
|
2376
|
-
createRequestId:
|
|
2377
|
-
hapticFeedback: new
|
|
2378
|
-
invoice: new
|
|
2379
|
-
mainButton:
|
|
2380
|
-
|
|
2372
|
+
backButton: xe(_, c, l),
|
|
2373
|
+
closingBehavior: qe(_, l),
|
|
2374
|
+
cloudStorage: new Pe(c, A, l),
|
|
2375
|
+
createRequestId: A,
|
|
2376
|
+
hapticFeedback: new ke(c, l),
|
|
2377
|
+
invoice: new Ge(c, l),
|
|
2378
|
+
mainButton: Ve(
|
|
2379
|
+
_,
|
|
2381
2380
|
u.buttonColor || "#000000",
|
|
2382
2381
|
u.buttonTextColor || "#ffffff",
|
|
2383
|
-
|
|
2382
|
+
l
|
|
2384
2383
|
),
|
|
2385
|
-
miniApp:
|
|
2386
|
-
|
|
2384
|
+
miniApp: Le(
|
|
2385
|
+
_,
|
|
2387
2386
|
u.backgroundColor || "#ffffff",
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2387
|
+
c,
|
|
2388
|
+
g,
|
|
2389
|
+
A,
|
|
2390
|
+
l
|
|
2392
2391
|
),
|
|
2393
|
-
popup: new
|
|
2394
|
-
postEvent:
|
|
2395
|
-
qrScanner: new
|
|
2396
|
-
settingsButton:
|
|
2397
|
-
themeParams:
|
|
2398
|
-
utils: new
|
|
2399
|
-
...
|
|
2400
|
-
initData: new
|
|
2401
|
-
initDataRaw:
|
|
2392
|
+
popup: new ze(c, l),
|
|
2393
|
+
postEvent: l,
|
|
2394
|
+
qrScanner: new Je(c, l),
|
|
2395
|
+
settingsButton: Be(_, c, l),
|
|
2396
|
+
themeParams: De(u),
|
|
2397
|
+
utils: new Qe(c, A, l),
|
|
2398
|
+
...i ? {
|
|
2399
|
+
initData: new Nt(i),
|
|
2400
|
+
initDataRaw: a
|
|
2402
2401
|
} : {}
|
|
2403
|
-
}, x =
|
|
2404
|
-
return x instanceof Promise ? x.then((
|
|
2405
|
-
|
|
2402
|
+
}, x = Oe(_, p, l, e);
|
|
2403
|
+
return x instanceof Promise || e ? Promise.resolve(x).then((v) => (at(
|
|
2404
|
+
s,
|
|
2406
2405
|
C.miniApp,
|
|
2407
2406
|
C.themeParams,
|
|
2408
|
-
|
|
2409
|
-
), {
|
|
2410
|
-
|
|
2411
|
-
viewport: T
|
|
2412
|
-
})) : (at(
|
|
2413
|
-
e,
|
|
2407
|
+
v
|
|
2408
|
+
), { ...C, viewport: v })) : (at(
|
|
2409
|
+
s,
|
|
2414
2410
|
C.miniApp,
|
|
2415
2411
|
C.themeParams,
|
|
2416
2412
|
x
|
|
2417
2413
|
), { ...C, viewport: x });
|
|
2418
|
-
} catch (
|
|
2419
|
-
if (
|
|
2420
|
-
return Promise.reject(
|
|
2421
|
-
throw
|
|
2414
|
+
} catch (i) {
|
|
2415
|
+
if (e)
|
|
2416
|
+
return Promise.reject(i);
|
|
2417
|
+
throw i;
|
|
2422
2418
|
}
|
|
2423
2419
|
}
|
|
2424
2420
|
function W(r, t) {
|
|
2425
2421
|
return r.startsWith(t) ? r : `${t}${r}`;
|
|
2426
2422
|
}
|
|
2427
|
-
function
|
|
2423
|
+
function hr(r) {
|
|
2428
2424
|
const t = r.match(/#(.+)/);
|
|
2429
2425
|
return t ? t[1] : null;
|
|
2430
2426
|
}
|
|
@@ -2441,14 +2437,14 @@ async function O(r) {
|
|
|
2441
2437
|
})
|
|
2442
2438
|
]);
|
|
2443
2439
|
}
|
|
2444
|
-
async function
|
|
2440
|
+
async function Ze() {
|
|
2445
2441
|
if (window.history.length <= 1 || (window.history.pushState(null, ""), await O(1 - window.history.length)))
|
|
2446
2442
|
return;
|
|
2447
2443
|
let t = await O(-1);
|
|
2448
2444
|
for (; t; )
|
|
2449
2445
|
t = await O(-1);
|
|
2450
2446
|
}
|
|
2451
|
-
class
|
|
2447
|
+
class Ke {
|
|
2452
2448
|
constructor(t, e, {
|
|
2453
2449
|
debug: s = !1,
|
|
2454
2450
|
loggerPrefix: n = "Navigator"
|
|
@@ -2481,9 +2477,9 @@ class Xe {
|
|
|
2481
2477
|
const {
|
|
2482
2478
|
pathname: a = "",
|
|
2483
2479
|
search: c,
|
|
2484
|
-
hash:
|
|
2480
|
+
hash: p
|
|
2485
2481
|
} = t;
|
|
2486
|
-
e = a + (c ? W(c, "?") : "") + (
|
|
2482
|
+
e = a + (c ? W(c, "?") : "") + (p ? W(p, "#") : "");
|
|
2487
2483
|
}
|
|
2488
2484
|
const {
|
|
2489
2485
|
pathname: s,
|
|
@@ -2648,7 +2644,7 @@ class Xe {
|
|
|
2648
2644
|
}
|
|
2649
2645
|
}
|
|
2650
2646
|
const ct = 0, Z = 1, K = 2;
|
|
2651
|
-
class
|
|
2647
|
+
class Vt extends Ke {
|
|
2652
2648
|
constructor(e, s, n = {}) {
|
|
2653
2649
|
super(e, s, {
|
|
2654
2650
|
...n,
|
|
@@ -2695,7 +2691,7 @@ class Lt extends Xe {
|
|
|
2695
2691
|
window.location.hash.slice(1),
|
|
2696
2692
|
window.location.href
|
|
2697
2693
|
);
|
|
2698
|
-
return new
|
|
2694
|
+
return new Vt([{ search: s, pathname: n, hash: i }], 0, e);
|
|
2699
2695
|
}
|
|
2700
2696
|
async performGo(e) {
|
|
2701
2697
|
e.updated && (this.attached && await this.syncHistory(), this.emitChanged(e.before, e.after));
|
|
@@ -2712,7 +2708,7 @@ class Lt extends Xe {
|
|
|
2712
2708
|
async syncHistory() {
|
|
2713
2709
|
window.removeEventListener("popstate", this.onPopState);
|
|
2714
2710
|
const e = `#${this.path}`;
|
|
2715
|
-
await
|
|
2711
|
+
await Ze(), d("web_app_setup_back_button", { is_visible: this.canGoBack }), this.canGoBack && this.canGoForward ? (this.logger.log("Setting up history: [<-, *, ->]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", e), window.history.pushState(K, ""), await O(-1)) : this.canGoBack ? (this.logger.log("Setting up history: [<-, *]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", e)) : this.canGoForward ? (this.logger.log("Setting up history: [*, ->]"), window.history.replaceState(null, e), window.history.pushState(K, ""), await O(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ct, ""), window.history.pushState(null, "", e)), window.addEventListener("popstate", this.onPopState);
|
|
2716
2712
|
}
|
|
2717
2713
|
emitChanged(e, s) {
|
|
2718
2714
|
this.ee.emit("change", {
|
|
@@ -2732,66 +2728,67 @@ class Lt extends Xe {
|
|
|
2732
2728
|
* Detaches current navigator from the browser history.
|
|
2733
2729
|
*/
|
|
2734
2730
|
detach() {
|
|
2735
|
-
this.attached && (this.logger.log("Detaching", this), this.attached = !1, window.removeEventListener("popstate", this.onPopState),
|
|
2731
|
+
this.attached && (this.logger.log("Detaching", this), this.attached = !1, window.removeEventListener("popstate", this.onPopState), $("back_button_pressed", this.back));
|
|
2736
2732
|
}
|
|
2737
2733
|
}
|
|
2738
2734
|
export {
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2735
|
+
ye as BackButton,
|
|
2736
|
+
ve as ClosingBehavior,
|
|
2737
|
+
Pe as CloudStorage,
|
|
2738
|
+
ke as HapticFeedback,
|
|
2739
|
+
Vt as HashNavigator,
|
|
2740
|
+
Nt as InitData,
|
|
2741
|
+
Ge as Invoice,
|
|
2742
|
+
Ae as MainButton,
|
|
2747
2743
|
tt as MethodUnsupportedError,
|
|
2748
|
-
|
|
2749
|
-
|
|
2744
|
+
Ie as MiniApp,
|
|
2745
|
+
Ke as Navigator,
|
|
2750
2746
|
et as ParameterUnsupportedError,
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2747
|
+
ze as Popup,
|
|
2748
|
+
Je as QRScanner,
|
|
2749
|
+
Te as SettingsButton,
|
|
2750
|
+
Mt as ThemeParams,
|
|
2755
2751
|
J as TimeoutError,
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2752
|
+
Qe as Utils,
|
|
2753
|
+
Ne as Viewport,
|
|
2754
|
+
Wt as chatParser,
|
|
2755
|
+
Ee as classNames,
|
|
2756
|
+
we as compareVersions,
|
|
2757
|
+
_e as createPostEvent,
|
|
2758
|
+
hr as getHash,
|
|
2759
|
+
cr as init,
|
|
2764
2760
|
wt as initDataParser,
|
|
2765
2761
|
N as invokeCustomMethod,
|
|
2766
2762
|
ft as isColorDark,
|
|
2767
2763
|
vt as isIframe,
|
|
2768
2764
|
lt as isRGB,
|
|
2769
|
-
|
|
2765
|
+
Dt as isRGBShort,
|
|
2770
2766
|
H as isRecord,
|
|
2771
|
-
|
|
2772
|
-
|
|
2767
|
+
We as isStableViewportPlatform,
|
|
2768
|
+
er as isTMA,
|
|
2769
|
+
or as isTimeoutError,
|
|
2773
2770
|
mt as launchParamsParser,
|
|
2774
|
-
|
|
2775
|
-
|
|
2771
|
+
ar as mergeClassNames,
|
|
2772
|
+
$ as off,
|
|
2776
2773
|
y as on,
|
|
2777
|
-
|
|
2778
|
-
|
|
2774
|
+
nr as once,
|
|
2775
|
+
Xe as parseInitData,
|
|
2779
2776
|
yt as parseLaunchParams,
|
|
2780
2777
|
bt as parseThemeParams,
|
|
2781
|
-
|
|
2778
|
+
d as postEvent,
|
|
2782
2779
|
m as request,
|
|
2783
|
-
|
|
2780
|
+
tr as requestThemeParams,
|
|
2784
2781
|
At as requestViewport,
|
|
2785
2782
|
Ct as retrieveLaunchData,
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2783
|
+
zt as serializeLaunchParams,
|
|
2784
|
+
Ut as serializeThemeParams,
|
|
2785
|
+
rr as setDebug,
|
|
2786
|
+
sr as setTargetOrigin,
|
|
2787
|
+
ir as subscribe,
|
|
2788
|
+
R as supports,
|
|
2792
2789
|
_t as themeParamsParser,
|
|
2793
2790
|
dt as toRGB,
|
|
2794
|
-
|
|
2791
|
+
ge as unsubscribe,
|
|
2795
2792
|
rt as userParser,
|
|
2796
2793
|
xt as withTimeout
|
|
2797
2794
|
};
|