@tma.js/init-data-node 1.3.2 → 1.4.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/entries/{index-Brzmngqx.js → index-B-IiSE5b.js} +65 -92
- package/dist/entries/index-B-IiSE5b.js.map +1 -0
- package/dist/entries/{index-CDcPFeVC.cjs → index-DQxFLF1J.cjs} +65 -92
- package/dist/entries/index-DQxFLF1J.cjs.map +1 -0
- package/dist/entries/node.cjs +13 -8
- package/dist/entries/node.cjs.map +1 -1
- package/dist/entries/node.d.ts +13 -4
- package/dist/entries/node.js +15 -10
- package/dist/entries/node.js.map +1 -1
- package/dist/entries/shared.d.ts +1 -1
- package/dist/entries/web.cjs +26 -21
- package/dist/entries/web.cjs.map +1 -1
- package/dist/entries/web.d.ts +13 -4
- package/dist/entries/web.js +27 -22
- package/dist/entries/web.js.map +1 -1
- package/dist/hashToken.d.ts +3 -0
- package/dist/sign.d.ts +6 -3
- package/dist/signData.d.ts +7 -3
- package/dist/types.d.ts +18 -4
- package/dist/validate.d.ts +4 -4
- package/package.json +2 -2
- package/dist/entries/index-Brzmngqx.js.map +0 -1
- package/dist/entries/index-CDcPFeVC.cjs.map +0 -1
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
function hashToken(token, createHmac) {
|
|
2
|
+
return createHmac(token, "WebAppData");
|
|
3
|
+
}
|
|
1
4
|
function removeUndefined(object) {
|
|
2
5
|
const result = {};
|
|
3
6
|
for (const key in object) {
|
|
@@ -50,7 +53,7 @@ function initDataToSearchParams({
|
|
|
50
53
|
})
|
|
51
54
|
);
|
|
52
55
|
}
|
|
53
|
-
function sign(data, key, authDate, signData2) {
|
|
56
|
+
function sign(data, key, authDate, signData2, options) {
|
|
54
57
|
const sp = initDataToSearchParams({
|
|
55
58
|
...data,
|
|
56
59
|
authDate
|
|
@@ -60,12 +63,16 @@ function sign(data, key, authDate, signData2) {
|
|
|
60
63
|
sp.append("hash", s);
|
|
61
64
|
return sp.toString();
|
|
62
65
|
}
|
|
63
|
-
const sign2 = signData2(pairs.join("\n"), key);
|
|
66
|
+
const sign2 = signData2(pairs.join("\n"), key, options);
|
|
64
67
|
return typeof sign2 === "string" ? processSign2(sign2) : sign2.then(processSign2);
|
|
65
68
|
}
|
|
66
|
-
function signData(data, key, createHmac) {
|
|
67
|
-
const keyHmac =
|
|
68
|
-
|
|
69
|
+
function signData(data, key, createHmac, options = {}) {
|
|
70
|
+
const keyHmac = options.tokenHashed ? key : hashToken(key, createHmac);
|
|
71
|
+
if (keyHmac instanceof Promise) {
|
|
72
|
+
return keyHmac.then((v) => createHmac(data, v)).then((v) => v.toString("hex"));
|
|
73
|
+
}
|
|
74
|
+
const hmac = createHmac(data, typeof keyHmac === "string" ? Buffer.from(keyHmac, "hex") : keyHmac);
|
|
75
|
+
return hmac instanceof Promise ? hmac.then((v) => v.toString("hex")) : hmac.toString("hex");
|
|
69
76
|
}
|
|
70
77
|
function processSign(actual, expected) {
|
|
71
78
|
if (actual !== expected) {
|
|
@@ -106,7 +113,7 @@ function validate(value, token, signData2, options = {}) {
|
|
|
106
113
|
}
|
|
107
114
|
}
|
|
108
115
|
pairs.sort();
|
|
109
|
-
const sign2 = signData2(pairs.join("\n"), token);
|
|
116
|
+
const sign2 = signData2(pairs.join("\n"), token, options);
|
|
110
117
|
return typeof sign2 === "string" ? processSign(sign2, hash) : sign2.then((v) => processSign(v, hash));
|
|
111
118
|
}
|
|
112
119
|
class D extends Error {
|
|
@@ -114,12 +121,12 @@ class D extends Error {
|
|
|
114
121
|
super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, D.prototype);
|
|
115
122
|
}
|
|
116
123
|
}
|
|
117
|
-
function
|
|
124
|
+
function f(e, t, s) {
|
|
118
125
|
return new D(e, t, s);
|
|
119
126
|
}
|
|
120
|
-
const
|
|
127
|
+
const Yt = "ERR_UNEXPECTED_TYPE", ct = "ERR_PARSE";
|
|
121
128
|
function E() {
|
|
122
|
-
return
|
|
129
|
+
return f(Yt, "Value has unexpected type");
|
|
123
130
|
}
|
|
124
131
|
class M {
|
|
125
132
|
constructor(t, s, n) {
|
|
@@ -136,8 +143,8 @@ class M {
|
|
|
136
143
|
try {
|
|
137
144
|
return this.parser(t);
|
|
138
145
|
} catch (s) {
|
|
139
|
-
throw
|
|
140
|
-
|
|
146
|
+
throw f(
|
|
147
|
+
ct,
|
|
141
148
|
`Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
|
|
142
149
|
s
|
|
143
150
|
);
|
|
@@ -160,7 +167,7 @@ const w = x((e) => {
|
|
|
160
167
|
return false;
|
|
161
168
|
throw E();
|
|
162
169
|
}, "boolean");
|
|
163
|
-
function
|
|
170
|
+
function ht(e, t) {
|
|
164
171
|
const s = {};
|
|
165
172
|
for (const n in e) {
|
|
166
173
|
const r = e[n];
|
|
@@ -177,21 +184,21 @@ function pt(e, t) {
|
|
|
177
184
|
const a = o(t(i));
|
|
178
185
|
a !== void 0 && (s[n] = a);
|
|
179
186
|
} catch (a) {
|
|
180
|
-
throw
|
|
187
|
+
throw f(ct, `Unable to parse field "${n}"`, a);
|
|
181
188
|
}
|
|
182
189
|
}
|
|
183
190
|
return s;
|
|
184
191
|
}
|
|
185
|
-
function
|
|
192
|
+
function pt(e) {
|
|
186
193
|
let t = e;
|
|
187
194
|
if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
|
|
188
195
|
throw E();
|
|
189
196
|
return t;
|
|
190
197
|
}
|
|
191
|
-
function
|
|
198
|
+
function g(e, t) {
|
|
192
199
|
return new M((s) => {
|
|
193
|
-
const n =
|
|
194
|
-
return
|
|
200
|
+
const n = pt(s);
|
|
201
|
+
return ht(e, (r) => n[r]);
|
|
195
202
|
}, false, t);
|
|
196
203
|
}
|
|
197
204
|
const y = x((e) => {
|
|
@@ -203,92 +210,57 @@ const y = x((e) => {
|
|
|
203
210
|
return t;
|
|
204
211
|
}
|
|
205
212
|
throw E();
|
|
206
|
-
}, "number")
|
|
207
|
-
function Y(e) {
|
|
208
|
-
return /^#[\da-f]{6}$/i.test(e);
|
|
209
|
-
}
|
|
210
|
-
function ee(e) {
|
|
211
|
-
return /^#[\da-f]{3}$/i.test(e);
|
|
212
|
-
}
|
|
213
|
-
function ut(e) {
|
|
214
|
-
const t = e.replace(/\s/g, "").toLowerCase();
|
|
215
|
-
if (Y(t))
|
|
216
|
-
return t;
|
|
217
|
-
if (ee(t)) {
|
|
218
|
-
let n = "#";
|
|
219
|
-
for (let r = 0; r < 3; r += 1)
|
|
220
|
-
n += t[1 + r].repeat(2);
|
|
221
|
-
return n;
|
|
222
|
-
}
|
|
223
|
-
const s = t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/) || t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);
|
|
224
|
-
if (!s)
|
|
225
|
-
throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);
|
|
226
|
-
return s.slice(1).reduce((n, r) => {
|
|
227
|
-
const i = parseInt(r, 10).toString(16);
|
|
228
|
-
return n + (i.length === 1 ? "0" : "") + i;
|
|
229
|
-
}, "#");
|
|
230
|
-
}
|
|
231
|
-
const h = x((e) => {
|
|
213
|
+
}, "number"), p = x((e) => {
|
|
232
214
|
if (typeof e == "string" || typeof e == "number")
|
|
233
215
|
return e.toString();
|
|
234
216
|
throw E();
|
|
235
|
-
}, "string")
|
|
217
|
+
}, "string");
|
|
236
218
|
({
|
|
237
|
-
clipboard_text_received:
|
|
238
|
-
req_id:
|
|
239
|
-
data: (e) => e === null ? e :
|
|
219
|
+
clipboard_text_received: g({
|
|
220
|
+
req_id: p(),
|
|
221
|
+
data: (e) => e === null ? e : p().optional().parse(e)
|
|
240
222
|
}),
|
|
241
|
-
custom_method_invoked:
|
|
242
|
-
req_id:
|
|
223
|
+
custom_method_invoked: g({
|
|
224
|
+
req_id: p(),
|
|
243
225
|
result: (e) => e,
|
|
244
|
-
error:
|
|
226
|
+
error: p().optional()
|
|
245
227
|
}),
|
|
246
|
-
invoice_closed: d({ slug: h(), status: h() }),
|
|
247
|
-
phone_requested: d({ status: h() }),
|
|
248
228
|
popup_closed: {
|
|
249
229
|
parse(e) {
|
|
250
|
-
return
|
|
251
|
-
button_id: (t) => t == null ? void 0 :
|
|
230
|
+
return g({
|
|
231
|
+
button_id: (t) => t == null ? void 0 : p().parse(t)
|
|
252
232
|
}).parse(e ?? {});
|
|
253
233
|
}
|
|
254
234
|
},
|
|
255
|
-
|
|
256
|
-
theme_changed: d({
|
|
257
|
-
theme_params: (e) => {
|
|
258
|
-
const t = lt().optional();
|
|
259
|
-
return Object.entries(Q(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
|
|
260
|
-
}
|
|
261
|
-
}),
|
|
262
|
-
viewport_changed: d({
|
|
235
|
+
viewport_changed: g({
|
|
263
236
|
height: y(),
|
|
264
237
|
width: (e) => e == null ? window.innerWidth : y().parse(e),
|
|
265
238
|
is_state_stable: w(),
|
|
266
239
|
is_expanded: w()
|
|
267
|
-
})
|
|
268
|
-
write_access_requested: d({ status: h() })
|
|
240
|
+
})
|
|
269
241
|
});
|
|
270
|
-
const
|
|
271
|
-
function
|
|
242
|
+
const Et = x((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
|
|
243
|
+
function K(e, t) {
|
|
272
244
|
return new M((s) => {
|
|
273
245
|
if (typeof s != "string" && !(s instanceof URLSearchParams))
|
|
274
246
|
throw E();
|
|
275
247
|
const n = typeof s == "string" ? new URLSearchParams(s) : s;
|
|
276
|
-
return
|
|
248
|
+
return ht(e, (r) => {
|
|
277
249
|
const i = n.get(r);
|
|
278
250
|
return i === null ? void 0 : i;
|
|
279
251
|
});
|
|
280
252
|
}, false, t);
|
|
281
253
|
}
|
|
282
|
-
const de =
|
|
254
|
+
const de = g({
|
|
283
255
|
id: y(),
|
|
284
|
-
type:
|
|
285
|
-
title:
|
|
256
|
+
type: p(),
|
|
257
|
+
title: p(),
|
|
286
258
|
photoUrl: {
|
|
287
|
-
type:
|
|
259
|
+
type: p().optional(),
|
|
288
260
|
from: "photo_url"
|
|
289
261
|
},
|
|
290
|
-
username:
|
|
291
|
-
}, "Chat").optional(),
|
|
262
|
+
username: p().optional()
|
|
263
|
+
}, "Chat").optional(), nt = g({
|
|
292
264
|
addedToAttachmentMenu: {
|
|
293
265
|
type: w().optional(),
|
|
294
266
|
from: "added_to_attachment_menu"
|
|
@@ -298,7 +270,7 @@ const de = d({
|
|
|
298
270
|
from: "allows_write_to_pm"
|
|
299
271
|
},
|
|
300
272
|
firstName: {
|
|
301
|
-
type:
|
|
273
|
+
type: p(),
|
|
302
274
|
from: "first_name"
|
|
303
275
|
},
|
|
304
276
|
id: y(),
|
|
@@ -311,23 +283,23 @@ const de = d({
|
|
|
311
283
|
from: "is_premium"
|
|
312
284
|
},
|
|
313
285
|
languageCode: {
|
|
314
|
-
type:
|
|
286
|
+
type: p().optional(),
|
|
315
287
|
from: "language_code"
|
|
316
288
|
},
|
|
317
289
|
lastName: {
|
|
318
|
-
type:
|
|
290
|
+
type: p().optional(),
|
|
319
291
|
from: "last_name"
|
|
320
292
|
},
|
|
321
293
|
photoUrl: {
|
|
322
|
-
type:
|
|
294
|
+
type: p().optional(),
|
|
323
295
|
from: "photo_url"
|
|
324
296
|
},
|
|
325
|
-
username:
|
|
297
|
+
username: p().optional()
|
|
326
298
|
}, "User").optional();
|
|
327
|
-
function
|
|
328
|
-
return
|
|
299
|
+
function xt() {
|
|
300
|
+
return K({
|
|
329
301
|
authDate: {
|
|
330
|
-
type:
|
|
302
|
+
type: Et(),
|
|
331
303
|
from: "auth_date"
|
|
332
304
|
},
|
|
333
305
|
canSendAfter: {
|
|
@@ -336,34 +308,35 @@ function Pt() {
|
|
|
336
308
|
},
|
|
337
309
|
chat: de,
|
|
338
310
|
chatInstance: {
|
|
339
|
-
type:
|
|
311
|
+
type: p().optional(),
|
|
340
312
|
from: "chat_instance"
|
|
341
313
|
},
|
|
342
314
|
chatType: {
|
|
343
|
-
type:
|
|
315
|
+
type: p().optional(),
|
|
344
316
|
from: "chat_type"
|
|
345
317
|
},
|
|
346
|
-
hash:
|
|
318
|
+
hash: p(),
|
|
347
319
|
queryId: {
|
|
348
|
-
type:
|
|
320
|
+
type: p().optional(),
|
|
349
321
|
from: "query_id"
|
|
350
322
|
},
|
|
351
|
-
receiver:
|
|
323
|
+
receiver: nt,
|
|
352
324
|
startParam: {
|
|
353
|
-
type:
|
|
325
|
+
type: p().optional(),
|
|
354
326
|
from: "start_param"
|
|
355
327
|
},
|
|
356
|
-
user:
|
|
328
|
+
user: nt
|
|
357
329
|
}, "InitData");
|
|
358
330
|
}
|
|
359
|
-
function
|
|
360
|
-
return
|
|
331
|
+
function cs(e) {
|
|
332
|
+
return xt().parse(e);
|
|
361
333
|
}
|
|
362
334
|
export {
|
|
363
335
|
signData as a,
|
|
364
|
-
|
|
336
|
+
cs as c,
|
|
337
|
+
hashToken as h,
|
|
365
338
|
initDataToSearchParams as i,
|
|
366
339
|
sign as s,
|
|
367
340
|
validate as v
|
|
368
341
|
};
|
|
369
|
-
//# sourceMappingURL=index-
|
|
342
|
+
//# sourceMappingURL=index-B-IiSE5b.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-B-IiSE5b.js","sources":["../../src/hashToken.ts","../../src/initDataToSearchParams.ts","../../src/sign.ts","../../src/signData.ts","../../src/validate.ts","../../../sdk/dist/index.js"],"sourcesContent":["import type { CreateHmacFn } from './types.js';\n\nexport function hashToken<H extends CreateHmacFn<any>>(\n token: string | Buffer,\n createHmac: H\n): ReturnType<H> {\n return createHmac(token, 'WebAppData') as ReturnType<H>;\n}\n","import type { InitDataParsed, User } from '@tma.js/sdk';\n\n/**\n * Removes undefined properties from the object.\n * @param object - object to remove properties from.\n */\nfunction removeUndefined(object: Record<string, string | undefined>): Record<string, string> {\n const result: Record<string, string> = {};\n for (const key in object) {\n const v = object[key];\n if (v !== undefined) {\n result[key] = v;\n }\n }\n return result;\n}\n\n/**\n * Serializes user information.\n * @param user - user information.\n */\nfunction serializeUser(user: User | undefined): string | undefined {\n return user\n ? JSON.stringify({\n added_to_attachment_menu: user.addedToAttachmentMenu,\n allows_write_to_pm: user.allowsWriteToPm,\n first_name: user.firstName,\n id: user.id,\n is_bot: user.isBot,\n is_premium: user.isPremium,\n language_code: user.languageCode,\n last_name: user.lastName,\n photo_url: user.photoUrl,\n username: user.username,\n })\n : undefined;\n}\n\nexport function initDataToSearchParams({\n chat,\n receiver,\n user,\n ...data\n}: Partial<InitDataParsed>): URLSearchParams {\n return new URLSearchParams(\n removeUndefined({\n auth_date: data.authDate\n ? ((+data.authDate / 1000) | 0).toString()\n : undefined,\n can_send_after: data.canSendAfter?.toString(),\n chat: chat\n ? JSON.stringify({\n id: chat.id,\n type: chat.type,\n title: chat.title,\n photo_url: chat.type,\n username: chat.username,\n })\n : undefined,\n chat_instance: data.chatInstance,\n chat_type: data.chatType || undefined,\n hash: data.hash,\n query_id: data.queryId,\n receiver: serializeUser(receiver),\n start_param: data.startParam || undefined,\n user: serializeUser(user),\n }),\n );\n}","import { initDataToSearchParams } from './initDataToSearchParams.js';\n\nimport type { SharedOptions, SignData, SignDataAsyncFn, SignDataSyncFn, Text } from './types.js';\n\nexport type SignOptions = SharedOptions;\n\n/**\n * Signs specified init data.\n * @param data - init data to sign.\n * @param authDate - date, when this init data should be signed.\n * @param key - private key.\n * @param signData - function signing data.\n * @param options - additional options.\n * @returns Signed init data presented as query parameters.\n */\nexport function sign(\n data: SignData,\n key: Text,\n authDate: Date,\n signData: SignDataSyncFn,\n options?: SignOptions,\n): string;\n\n/**\n * Signs specified init data.\n * @param data - init data to sign.\n * @param authDate - date, when this init data should be signed.\n * @param key - private key.\n * @param signData - function signing data.\n * @param options - additional options.\n * @returns Signed init data presented as query parameters.\n */\nexport function sign(\n data: SignData,\n key: Text,\n authDate: Date,\n signData: SignDataAsyncFn,\n options?: SignOptions,\n): Promise<string>;\n\nexport function sign(\n data: SignData,\n key: Text,\n authDate: Date,\n signData: SignDataSyncFn | SignDataAsyncFn,\n options?: SignOptions,\n): string | Promise<string> {\n // Create search parameters, which will be signed further.\n const sp = initDataToSearchParams({\n ...data,\n authDate,\n });\n\n // Convert search params to pairs and sort the final array.\n const pairs = [...sp.entries()]\n .map(([name, value]) => `${name}=${value}`)\n .sort();\n\n // Compute sign, append it to the params and return.\n function processSign(s: string): string {\n sp.append('hash', s);\n return sp.toString();\n }\n\n const sign = signData(pairs.join('\\n'), key, options);\n return typeof sign === 'string' ? processSign(sign) : sign.then(processSign);\n}\n","import { hashToken } from './hashToken.js';\nimport type { CreateHmacFn, SharedOptions, Text } from './types.js';\n\nexport type SignDataOptions = SharedOptions;\n\n/**\n * Signs specified data with the passed token.\n * @param data - data to sign.\n * @param key - private key.\n * @param createHmac - function to create HMAC-SHA256.\n * @param options - additional method options.\n * @returns Data sign.\n */\nexport function signData(\n data: Text,\n key: Text,\n createHmac: CreateHmacFn<false>,\n options?: SignDataOptions,\n): string;\n\n/**\n * Signs specified data with the passed token.\n * @param data - data to sign.\n * @param key - private key.\n * @param createHmac - function to create HMAC-SHA256.\n * @param options - additional method options.\n * @returns Data sign.\n */\nexport function signData(\n data: Text,\n key: Text,\n createHmac: CreateHmacFn<true>,\n options?: SignDataOptions,\n): Promise<string>;\n\nexport function signData(\n data: Text,\n key: Text,\n createHmac: CreateHmacFn<boolean>,\n options: SignDataOptions = {},\n): string | Promise<string> {\n const keyHmac = options.tokenHashed ? key : hashToken(key, createHmac);\n if (keyHmac instanceof Promise) {\n return keyHmac\n .then(v => createHmac(data, v))\n .then(v => v.toString('hex'));\n }\n\n const hmac = createHmac(data, typeof keyHmac === 'string'\n ? Buffer.from(keyHmac, 'hex')\n : keyHmac);\n return hmac instanceof Promise\n ? hmac.then(v => v.toString('hex'))\n : hmac.toString('hex');\n}\n","import type { InitData, InitDataParsed } from '@tma.js/sdk';\n\nimport { initDataToSearchParams } from './initDataToSearchParams.js';\nimport type { SharedOptions, SignDataAsyncFn, SignDataSyncFn, Text } from './types.js';\n\nexport interface ValidateOptions extends SharedOptions {\n /**\n * Time in seconds which states, how long from creation time init data is considered valid.\n *\n * In other words, in case when authDate + expiresIn is before current time, init data is\n * recognized as expired.\n *\n * In case this value is equal to 0, the function does not check init data expiration.\n * @default 86400 (1 day)\n */\n expiresIn?: number;\n}\n\nfunction processSign(actual: string, expected: string): void | never {\n if (actual !== expected) {\n throw new Error('Signature is invalid');\n }\n return;\n}\n\n/**\n * Validates passed init data.\n * @param value - value to check.\n * @param token - bot secret token.\n * @param signData - function signing data.\n * @param options - additional validation options.\n * @throws {TypeError} \"auth_date\" should present integer\n * @throws {Error} \"hash\" is empty or not found\n * @throws {Error} \"auth_date\" is empty or not found\n * @throws {Error} Init data expired\n */\nexport function validate(\n value: InitData | InitDataParsed | string | URLSearchParams,\n token: Text,\n signData: SignDataSyncFn,\n options?: ValidateOptions,\n): void | never;\n\n/**\n * Validates passed init data.\n * @param value - value to check.\n * @param token - bot secret token.\n * @param signData - function signing data.\n * @param options - additional validation options.\n * @throws {TypeError} \"auth_date\" should present integer\n * @throws {Error} \"hash\" is empty or not found\n * @throws {Error} \"auth_date\" is empty or not found\n * @throws {Error} Init data expired\n */\nexport function validate(\n value: InitData | InitDataParsed | string | URLSearchParams,\n token: Text,\n signData: SignDataAsyncFn,\n options?: ValidateOptions,\n): Promise<void>;\n\nexport function validate(\n value: InitData | InitDataParsed | string | URLSearchParams,\n token: Text,\n signData: SignDataSyncFn | SignDataAsyncFn,\n options: ValidateOptions = {},\n): void | never | Promise<void> {\n // Init data required params.\n let authDate: Date | undefined;\n let hash: string | undefined;\n\n // All search params pairs presented as `k=v`.\n const pairs: string[] = [];\n\n // Iterate over all key-value pairs of parsed parameters and find required\n // parameters.\n new URLSearchParams(\n typeof value === 'string' || value instanceof URLSearchParams\n ? value\n : initDataToSearchParams(value),\n ).forEach((value, key) => {\n if (key === 'hash') {\n hash = value;\n return;\n }\n\n if (key === 'auth_date') {\n const authDateNum = parseInt(value, 10);\n\n if (Number.isNaN(authDateNum)) {\n throw new TypeError('\"auth_date\" should present integer');\n }\n authDate = new Date(authDateNum * 1000);\n }\n\n pairs.push(`${key}=${value}`);\n });\n\n // Hash and auth date always required.\n if (!hash) {\n throw new Error('\"hash\" is empty or not found');\n }\n\n if (!authDate) {\n throw new Error('\"auth_date\" is empty or not found');\n }\n\n // In case, expiration time passed, we do additional parameters check.\n const { expiresIn = 86400 } = options;\n if (expiresIn > 0) {\n // Check if init data expired.\n if (+authDate + expiresIn * 1000 < Date.now()) {\n throw new Error('Init data expired');\n }\n }\n\n // According to docs, we sort all the pairs in alphabetical order.\n pairs.sort();\n\n const sign = signData(pairs.join('\\n'), token, options);\n\n return typeof sign === 'string'\n ? processSign(sign, hash)\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n : sign.then(v => processSign(v, hash!));\n}\n","var Wt = Object.defineProperty;\nvar Ut = (e, t, s) => t in e ? Wt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;\nvar c = (e, t, s) => Ut(e, typeof t != \"symbol\" ? t + \"\" : t, s);\nfunction ot(e, t) {\n let s;\n const n = () => {\n s !== void 0 && t && t(s), s = void 0;\n };\n return [() => s === void 0 ? s = e(n) : s, n];\n}\nfunction at(e) {\n const t = V(), { count: s } = t;\n t.unsubscribe(e), s && !t.count && ie();\n}\nfunction Ht(e) {\n return V().subscribe(e), () => at(e);\n}\nclass Ot {\n constructor(t, s = {}) {\n this.scope = t, this.options = s;\n }\n /**\n * Prints message into a console in case, logger is currently enabled.\n * @param level - log level.\n * @param args - arguments.\n */\n print(t, ...s) {\n const n = /* @__PURE__ */ new Date(), r = Intl.DateTimeFormat(\"en-GB\", {\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n fractionalSecondDigits: 3,\n timeZone: \"UTC\"\n }).format(n), { textColor: i, bgColor: o } = this.options, a = \"font-weight: bold;padding: 0 5px;border-radius:5px\";\n console[t](\n `%c${r}%c / %c${this.scope}`,\n `${a};background-color: lightblue;color:black`,\n \"\",\n `${a};${i ? `color:${i};` : \"\"}${o ? `background-color:${o}` : \"\"}`,\n ...s\n );\n }\n /**\n * Prints error message into a console.\n * @param args\n */\n error(...t) {\n this.print(\"error\", ...t);\n }\n /**\n * Prints log message into a console.\n * @param args\n */\n log(...t) {\n this.print(\"log\", ...t);\n }\n}\nconst F = new Ot(\"SDK\", {\n bgColor: \"forestgreen\",\n textColor: \"white\"\n});\nlet O = !1;\nconst st = ({ name: e, payload: t }) => {\n F.log(\"Event received:\", t ? { name: e, payload: t } : { name: e });\n};\nfunction Ze(e) {\n O !== e && (O = e, e ? Ht(st) : at(st));\n}\nfunction Gt(...e) {\n O && F.log(...e);\n}\nclass T {\n constructor() {\n c(this, \"listeners\", /* @__PURE__ */ new Map());\n c(this, \"listenersCount\", 0);\n c(this, \"subscribeListeners\", []);\n }\n /**\n * Removes all event listeners.\n */\n clear() {\n this.listeners.clear(), this.subscribeListeners = [];\n }\n /**\n * Returns count of bound listeners.\n */\n get count() {\n return this.listenersCount + this.subscribeListeners.length;\n }\n emit(t, ...s) {\n this.subscribeListeners.forEach((r) => r({\n event: t,\n args: s\n })), (this.listeners.get(t) || []).forEach(([r, i]) => {\n r(...s), i && this.off(t, r);\n });\n }\n /**\n * Adds new event listener.\n * @param event - event name.\n * @param listener - event listener.\n * @param once - should listener be called only once.\n * @returns Function to remove bound event listener.\n */\n on(t, s, n) {\n let r = this.listeners.get(t);\n return r || this.listeners.set(t, r = []), r.push([s, n]), this.listenersCount += 1, () => this.off(t, s);\n }\n /**\n * Removes event listener. In case, specified listener was bound several times, it removes\n * only a single one.\n * @param event - event name.\n * @param listener - event listener.\n */\n off(t, s) {\n const n = this.listeners.get(t) || [];\n for (let r = 0; r < n.length; r += 1)\n if (s === n[r][0]) {\n n.splice(r, 1), this.listenersCount -= 1;\n return;\n }\n }\n /**\n * Adds a new event listener for all events.\n * @param listener - event listener.\n * @returns Function to remove event listener.\n */\n subscribe(t) {\n return this.subscribeListeners.push(t), () => this.unsubscribe(t);\n }\n /**\n * Removes global event listener. In case, specified listener was bound several times, it removes\n * only a single one.\n * @param listener - event listener.\n */\n unsubscribe(t) {\n for (let s = 0; s < this.subscribeListeners.length; s += 1)\n if (this.subscribeListeners[s] === t) {\n this.subscribeListeners.splice(s, 1);\n return;\n }\n }\n}\nfunction G(e, t, s) {\n return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);\n}\nfunction J(...e) {\n let t = !1;\n const s = e.flat(1);\n return [\n (n) => !t && s.push(n),\n () => {\n t || (t = !0, s.forEach((n) => n()));\n },\n t\n ];\n}\nclass D extends Error {\n constructor(t, s, n) {\n super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, D.prototype);\n }\n}\nfunction f(e, t, s) {\n return new D(e, t, s);\n}\nconst jt = \"ERR_METHOD_UNSUPPORTED\", zt = \"ERR_METHOD_PARAMETER_UNSUPPORTED\", Ft = \"ERR_UNKNOWN_ENV\", Jt = \"ERR_INVOKE_CUSTOM_METHOD_RESPONSE\", Qt = \"ERR_TIMED_OUT\", Yt = \"ERR_UNEXPECTED_TYPE\", ct = \"ERR_PARSE\", Zt = \"ERR_NAVIGATION_LIST_EMPTY\", Kt = \"ERR_NAVIGATION_CURSOR_INVALID\", Ke = \"ERR_NAVIGATION_ITEM_INVALID\", Xe = \"ERR_SSR_INIT\", Xt = \"ERR_INVALID_PATH_BASE\";\nfunction E() {\n return f(Yt, \"Value has unexpected type\");\n}\nclass M {\n constructor(t, s, n) {\n this.parser = t, this.isOptional = s, this.type = n;\n }\n /**\n * Attempts to parse passed value\n * @param value - value to parse.\n * @throws {SDKError} ERR_PARSE\n * @see ERR_PARSE\n */\n parse(t) {\n if (!(this.isOptional && t === void 0))\n try {\n return this.parser(t);\n } catch (s) {\n throw f(\n ct,\n `Unable to parse value${this.type ? ` as ${this.type}` : \"\"}`,\n s\n );\n }\n }\n optional() {\n return this.isOptional = !0, this;\n }\n}\nfunction x(e, t) {\n return () => new M(e, !1, t);\n}\nconst w = x((e) => {\n if (typeof e == \"boolean\")\n return e;\n const t = String(e);\n if (t === \"1\" || t === \"true\")\n return !0;\n if (t === \"0\" || t === \"false\")\n return !1;\n throw E();\n}, \"boolean\");\nfunction ht(e, t) {\n const s = {};\n for (const n in e) {\n const r = e[n];\n if (!r)\n continue;\n let i, o;\n if (typeof r == \"function\" || \"parse\" in r)\n i = n, o = typeof r == \"function\" ? r : r.parse.bind(r);\n else {\n const { type: a } = r;\n i = r.from || n, o = typeof a == \"function\" ? a : a.parse.bind(a);\n }\n try {\n const a = o(t(i));\n a !== void 0 && (s[n] = a);\n } catch (a) {\n throw f(ct, `Unable to parse field \"${n}\"`, a);\n }\n }\n return s;\n}\nfunction pt(e) {\n let t = e;\n if (typeof t == \"string\" && (t = JSON.parse(t)), typeof t != \"object\" || t === null || Array.isArray(t))\n throw E();\n return t;\n}\nfunction g(e, t) {\n return new M((s) => {\n const n = pt(s);\n return ht(e, (r) => n[r]);\n }, !1, t);\n}\nconst y = x((e) => {\n if (typeof e == \"number\")\n return e;\n if (typeof e == \"string\") {\n const t = Number(e);\n if (!Number.isNaN(t))\n return t;\n }\n throw E();\n}, \"number\"), p = x((e) => {\n if (typeof e == \"string\" || typeof e == \"number\")\n return e.toString();\n throw E();\n}, \"string\");\nfunction ut(e) {\n return g({\n eventType: p(),\n eventData: (t) => t\n }).parse(e);\n}\nfunction te() {\n [\"TelegramGameProxy_receiveEvent\", \"TelegramGameProxy\", \"Telegram\"].forEach((e) => {\n delete window[e];\n });\n}\nfunction j(e, t) {\n window.dispatchEvent(new MessageEvent(\"message\", {\n data: JSON.stringify({ eventType: e, eventData: t }),\n // We specify window.parent to imitate the case, the parent iframe sent us this event.\n source: window.parent\n }));\n}\nfunction ee() {\n [\n [\"TelegramGameProxy_receiveEvent\"],\n // Windows Phone.\n [\"TelegramGameProxy\", \"receiveEvent\"],\n // Desktop.\n [\"Telegram\", \"WebView\", \"receiveEvent\"]\n // Android and iOS.\n ].forEach((e) => {\n let t = window;\n e.forEach((s, n, r) => {\n if (n === r.length - 1) {\n t[s] = j;\n return;\n }\n s in t || (t[s] = {}), t = t[s];\n });\n });\n}\nconst se = {\n clipboard_text_received: g({\n req_id: p(),\n data: (e) => e === null ? e : p().optional().parse(e)\n }),\n custom_method_invoked: g({\n req_id: p(),\n result: (e) => e,\n error: p().optional()\n }),\n popup_closed: {\n parse(e) {\n return g({\n button_id: (t) => t == null ? void 0 : p().parse(t)\n }).parse(e ?? {});\n }\n },\n viewport_changed: g({\n height: y(),\n width: (e) => e == null ? window.innerWidth : y().parse(e),\n is_state_stable: w(),\n is_expanded: w()\n })\n};\nfunction ne() {\n const e = new T(), t = new T();\n t.subscribe((n) => {\n e.emit(\"event\", { name: n.event, payload: n.args[0] });\n }), ee();\n const [, s] = J(\n // Don't forget to remove created handlers.\n te,\n // Add \"resize\" event listener to make sure, we always have fresh viewport information.\n // Desktop version of Telegram is sometimes not sending the viewport_changed\n // event. For example, when the MainButton is shown. That's why we should\n // add our own listener to make sure, viewport information is always fresh.\n // Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/10\n G(\"resize\", () => {\n t.emit(\"viewport_changed\", {\n width: window.innerWidth,\n height: window.innerHeight,\n is_state_stable: !0,\n is_expanded: !0\n });\n }),\n // Add listener, which handles events sent from the Telegram web application and also events\n // generated by the local emitEvent function.\n G(\"message\", (n) => {\n if (n.source !== window.parent)\n return;\n let r;\n try {\n r = ut(n.data);\n } catch {\n return;\n }\n const { eventType: i, eventData: o } = r, a = se[i];\n try {\n const h = a ? a.parse(o) : o;\n t.emit(...h ? [i, h] : [i]);\n } catch (h) {\n F.error(\n `An error occurred processing the \"${i}\" event from the Telegram application.\nPlease, file an issue here:\nhttps://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,\n r,\n h\n );\n }\n }),\n // Clear emitters.\n () => e.clear(),\n () => t.clear()\n );\n return [{\n on: t.on.bind(t),\n off: t.off.bind(t),\n subscribe(n) {\n return e.on(\"event\", n);\n },\n unsubscribe(n) {\n e.off(\"event\", n);\n },\n get count() {\n return t.count + e.count;\n }\n }, s];\n}\nconst [re, ie] = ot(\n (e) => {\n const [t, s] = ne(), n = t.off.bind(t);\n return t.off = (r, i) => {\n const { count: o } = t;\n n(r, i), o && !t.count && e();\n }, [t, s];\n },\n ([, e]) => e()\n);\nfunction V() {\n return re()[0];\n}\nfunction L(e, t) {\n V().off(e, t);\n}\nfunction b(e, t, s) {\n return V().on(e, t, s);\n}\nfunction q(e) {\n return typeof e == \"object\" && e !== null && !Array.isArray(e);\n}\nfunction oe(e, t) {\n const s = e.split(\".\"), n = t.split(\".\"), r = Math.max(s.length, n.length);\n for (let i = 0; i < r; i += 1) {\n const o = parseInt(s[i] || \"0\", 10), a = parseInt(n[i] || \"0\", 10);\n if (o !== a)\n return o > a ? 1 : -1;\n }\n return 0;\n}\nfunction _(e, t) {\n return oe(e, t) <= 0;\n}\nfunction v(e, t, s) {\n if (typeof s == \"string\") {\n if (e === \"web_app_open_link\") {\n if (t === \"try_instant_view\")\n return _(\"6.4\", s);\n if (t === \"try_browser\")\n return _(\"7.6\", s);\n }\n if (e === \"web_app_set_header_color\" && t === \"color\")\n return _(\"6.9\", s);\n if (e === \"web_app_close\" && t === \"return_back\")\n return _(\"7.6\", s);\n }\n switch (e) {\n case \"web_app_open_tg_link\":\n case \"web_app_open_invoice\":\n case \"web_app_setup_back_button\":\n case \"web_app_set_background_color\":\n case \"web_app_set_header_color\":\n case \"web_app_trigger_haptic_feedback\":\n return _(\"6.1\", t);\n case \"web_app_open_popup\":\n return _(\"6.2\", t);\n case \"web_app_close_scan_qr_popup\":\n case \"web_app_open_scan_qr_popup\":\n case \"web_app_read_text_from_clipboard\":\n return _(\"6.4\", t);\n case \"web_app_switch_inline_query\":\n return _(\"6.7\", t);\n case \"web_app_invoke_custom_method\":\n case \"web_app_request_write_access\":\n case \"web_app_request_phone\":\n return _(\"6.9\", t);\n case \"web_app_setup_settings_button\":\n return _(\"6.10\", t);\n case \"web_app_biometry_get_info\":\n case \"web_app_biometry_open_settings\":\n case \"web_app_biometry_request_access\":\n case \"web_app_biometry_request_auth\":\n case \"web_app_biometry_update_token\":\n return _(\"7.2\", t);\n default:\n return [\n \"iframe_ready\",\n \"iframe_will_reload\",\n \"web_app_close\",\n \"web_app_data_send\",\n \"web_app_expand\",\n \"web_app_open_link\",\n \"web_app_ready\",\n \"web_app_request_theme\",\n \"web_app_request_viewport\",\n \"web_app_setup_main_button\",\n \"web_app_setup_closing_behavior\"\n ].includes(e);\n }\n}\nfunction lt(e) {\n return \"external\" in e && q(e.external) && \"notify\" in e.external && typeof e.external.notify == \"function\";\n}\nfunction dt(e) {\n return \"TelegramWebviewProxy\" in e && q(e.TelegramWebviewProxy) && \"postEvent\" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == \"function\";\n}\nfunction _t() {\n try {\n return window.self !== window.top;\n } catch {\n return !0;\n }\n}\nconst ae = \"https://web.telegram.org\";\nlet ft = ae;\nfunction ts(e) {\n ft = e;\n}\nfunction ce() {\n return ft;\n}\nfunction R(e, t, s) {\n let n = {}, r;\n if (!t && !s ? n = {} : t && s ? (n = s, r = t) : t && (\"targetOrigin\" in t ? n = t : r = t), Gt(\"Posting event:\", r ? { event: e, data: r } : { event: e }), _t())\n return window.parent.postMessage(\n JSON.stringify({ eventType: e, eventData: r }),\n n.targetOrigin || ce()\n );\n if (lt(window)) {\n window.external.notify(JSON.stringify({ eventType: e, eventData: r }));\n return;\n }\n if (dt(window)) {\n window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));\n return;\n }\n throw f(\n Ft,\n \"Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside the Telegram application environment.\"\n );\n}\nfunction he(e) {\n return (t, s) => {\n if (!v(t, e))\n throw f(jt, `Method \"${t}\" is unsupported in Mini Apps version ${e}`);\n if (q(s) && t === \"web_app_set_header_color\" && \"color\" in s && !v(t, \"color\", e))\n throw f(\n zt,\n `Parameter \"color\" of \"${t}\" method is unsupported in Mini Apps version ${e}`\n );\n return R(t, s);\n };\n}\nfunction gt(e) {\n return ({ req_id: t }) => t === e;\n}\nfunction bt(e) {\n return f(Qt, `Timeout reached: ${e}ms`);\n}\nfunction wt(e, t) {\n return Promise.race([\n typeof e == \"function\" ? e() : e,\n new Promise((s, n) => {\n setTimeout(() => {\n n(bt(t));\n }, t);\n })\n ]);\n}\nasync function d(e) {\n let t;\n const s = new Promise((a) => t = a), { event: n, capture: r, timeout: i } = e, [, o] = J(\n // We need to iterate over all tracked events, and create their event listeners.\n (Array.isArray(n) ? n : [n]).map((a) => b(a, (h) => {\n (!r || (Array.isArray(n) ? r({\n event: a,\n payload: h\n }) : r(h))) && t(h);\n }))\n );\n try {\n return (e.postEvent || R)(e.method, e.params), await (i ? wt(s, i) : s);\n } finally {\n o();\n }\n}\nasync function S(e, t, s, n = {}) {\n const {\n result: r,\n error: i\n } = await d({\n ...n,\n method: \"web_app_invoke_custom_method\",\n event: \"custom_method_invoked\",\n params: {\n method: e,\n params: t,\n req_id: s\n },\n capture: gt(s)\n });\n if (i)\n throw f(Jt, i);\n return r;\n}\nfunction z(...e) {\n return e.map((t) => {\n if (typeof t == \"string\")\n return t;\n if (q(t))\n return z(Object.entries(t).map((s) => s[1] && s[0]));\n if (Array.isArray(t))\n return z(...t);\n }).filter(Boolean).join(\" \");\n}\nfunction es(...e) {\n return e.reduce((t, s) => (q(s) && Object.entries(s).forEach(([n, r]) => {\n const i = z(t[n], r);\n i.length && (t[n] = i);\n }), t), {});\n}\nfunction Q(e) {\n return /^#[\\da-f]{6}$/i.test(e);\n}\nfunction pe(e) {\n return /^#[\\da-f]{3}$/i.test(e);\n}\nfunction mt(e) {\n const t = e.replace(/\\s/g, \"\").toLowerCase();\n if (Q(t))\n return t;\n if (pe(t)) {\n let n = \"#\";\n for (let r = 0; r < 3; r += 1)\n n += t[1 + r].repeat(2);\n return n;\n }\n const s = t.match(/^rgb\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3})\\)$/) || t.match(/^rgba\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),\\d{1,3}\\)$/);\n if (!s)\n throw new Error(`Value \"${e}\" does not satisfy any of known RGB formats.`);\n return s.slice(1).reduce((n, r) => {\n const i = parseInt(r, 10).toString(16);\n return n + (i.length === 1 ? \"0\" : \"\") + i;\n }, \"#\");\n}\nfunction yt(e) {\n const t = mt(e);\n return Math.sqrt(\n [0.299, 0.587, 0.114].reduce((s, n, r) => {\n const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);\n return s + i * i * n;\n }, 0)\n ) < 120;\n}\nclass ue {\n constructor(t) {\n c(this, \"ee\", new T());\n /**\n * Adds new event listener.\n */\n c(this, \"on\", this.ee.on.bind(this.ee));\n /**\n * Removes event listener.\n */\n c(this, \"off\", this.ee.off.bind(this.ee));\n this.state = t;\n }\n /**\n * Clones current state and returns its copy.\n */\n clone() {\n return { ...this.state };\n }\n set(t, s) {\n Object.entries(typeof t == \"string\" ? { [t]: s } : t).reduce((r, [i, o]) => this.state[i] === o || o === void 0 ? r : (this.state[i] = o, this.ee.emit(`change:${i}`, o), !0), !1) && this.ee.emit(\"change\", this.state);\n }\n /**\n * Returns value by specified key.\n * @param key - state key.\n */\n get(t) {\n return this.state[t];\n }\n}\nclass Y {\n constructor(t) {\n c(this, \"state\");\n /**\n * Gets the state value.\n */\n c(this, \"get\");\n /**\n * Sets the state value.\n */\n c(this, \"set\");\n /**\n * Clones the current state.\n */\n c(this, \"clone\");\n this.state = new ue(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);\n }\n}\nfunction vt(e, t) {\n return (s) => v(t[s], e);\n}\nclass Z extends Y {\n constructor(s, n, r) {\n super(s);\n /**\n * @returns True, if specified method is supported by the current component.\n */\n c(this, \"supports\");\n this.supports = vt(n, r);\n }\n}\nclass le extends Z {\n constructor(s, n, r) {\n super({ isVisible: s }, n, {\n show: \"web_app_setup_back_button\",\n hide: \"web_app_setup_back_button\"\n });\n /**\n * Adds a new event listener.\n * @param event - event to listen.\n * @param listener - listener to add.\n */\n c(this, \"on\", (s, n) => s === \"click\" ? b(\"back_button_pressed\", n) : this.state.on(s, n));\n /**\n * Removes the event listener.\n * @param event - event to listen.\n * @param listener - listener to remove.\n */\n c(this, \"off\", (s, n) => s === \"click\" ? L(\"back_button_pressed\", n) : this.state.off(s, n));\n this.postEvent = r;\n }\n set isVisible(s) {\n this.set(\"isVisible\", s), this.postEvent(\"web_app_setup_back_button\", { is_visible: s });\n }\n /**\n * True if BackButton is currently visible.\n */\n get isVisible() {\n return this.get(\"isVisible\");\n }\n /**\n * Hides the BackButton.\n */\n hide() {\n this.isVisible = !1;\n }\n /**\n * Shows the BackButton.\n */\n show() {\n this.isVisible = !0;\n }\n}\nconst Et = x((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), \"Date\");\nfunction K(e, t) {\n return new M((s) => {\n if (typeof s != \"string\" && !(s instanceof URLSearchParams))\n throw E();\n const n = typeof s == \"string\" ? new URLSearchParams(s) : s;\n return ht(e, (r) => {\n const i = n.get(r);\n return i === null ? void 0 : i;\n });\n }, !1, t);\n}\nconst de = g({\n id: y(),\n type: p(),\n title: p(),\n photoUrl: {\n type: p().optional(),\n from: \"photo_url\"\n },\n username: p().optional()\n}, \"Chat\").optional(), nt = g({\n addedToAttachmentMenu: {\n type: w().optional(),\n from: \"added_to_attachment_menu\"\n },\n allowsWriteToPm: {\n type: w().optional(),\n from: \"allows_write_to_pm\"\n },\n firstName: {\n type: p(),\n from: \"first_name\"\n },\n id: y(),\n isBot: {\n type: w().optional(),\n from: \"is_bot\"\n },\n isPremium: {\n type: w().optional(),\n from: \"is_premium\"\n },\n languageCode: {\n type: p().optional(),\n from: \"language_code\"\n },\n lastName: {\n type: p().optional(),\n from: \"last_name\"\n },\n photoUrl: {\n type: p().optional(),\n from: \"photo_url\"\n },\n username: p().optional()\n}, \"User\").optional();\nfunction xt() {\n return K({\n authDate: {\n type: Et(),\n from: \"auth_date\"\n },\n canSendAfter: {\n type: y().optional(),\n from: \"can_send_after\"\n },\n chat: de,\n chatInstance: {\n type: p().optional(),\n from: \"chat_instance\"\n },\n chatType: {\n type: p().optional(),\n from: \"chat_type\"\n },\n hash: p(),\n queryId: {\n type: p().optional(),\n from: \"query_id\"\n },\n receiver: nt,\n startParam: {\n type: p().optional(),\n from: \"start_param\"\n },\n user: nt\n }, \"InitData\");\n}\nconst _e = x((e) => mt(p().parse(e)), \"rgb\");\nfunction fe(e) {\n return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());\n}\nfunction ge(e) {\n return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);\n}\nconst Pt = x(\n (e) => {\n const t = _e().optional();\n return Object.entries(pt(e)).reduce((s, [n, r]) => (s[fe(n)] = t.parse(r), s), {});\n },\n \"ThemeParams\"\n);\nfunction X(e) {\n return K({\n botInline: {\n type: w().optional(),\n from: \"tgWebAppBotInline\"\n },\n initData: {\n type: xt().optional(),\n from: \"tgWebAppData\"\n },\n initDataRaw: {\n type: p().optional(),\n from: \"tgWebAppData\"\n },\n platform: {\n type: p(),\n from: \"tgWebAppPlatform\"\n },\n showSettings: {\n type: w().optional(),\n from: \"tgWebAppShowSettings\"\n },\n startParam: {\n type: p().optional(),\n from: \"tgWebAppStartParam\"\n },\n themeParams: {\n type: Pt(),\n from: \"tgWebAppThemeParams\"\n },\n version: {\n type: p(),\n from: \"tgWebAppVersion\"\n }\n }).parse(e);\n}\nfunction St(e) {\n return X(\n e.replace(/^[^?#]*[?#]/, \"\").replace(/[?#]/g, \"&\")\n );\n}\nfunction be() {\n return St(window.location.href);\n}\nfunction Ct() {\n return performance.getEntriesByType(\"navigation\")[0];\n}\nfunction we() {\n const e = Ct();\n if (!e)\n throw new Error(\"Unable to get first navigation entry.\");\n return St(e.name);\n}\nfunction Tt(e) {\n return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;\n}\nfunction Rt(e, t) {\n sessionStorage.setItem(Tt(e), JSON.stringify(t));\n}\nfunction At(e) {\n const t = sessionStorage.getItem(Tt(e));\n try {\n return t ? JSON.parse(t) : void 0;\n } catch {\n }\n}\nfunction me() {\n return X(At(\"launchParams\") || \"\");\n}\nfunction It(e) {\n return JSON.stringify(\n Object.fromEntries(\n Object.entries(e).map(([t, s]) => [ge(t), s])\n )\n );\n}\nfunction ye(e) {\n const {\n initDataRaw: t,\n themeParams: s,\n platform: n,\n version: r,\n showSettings: i,\n startParam: o,\n botInline: a\n } = e, h = new URLSearchParams();\n return h.set(\"tgWebAppPlatform\", n), h.set(\"tgWebAppThemeParams\", It(s)), h.set(\"tgWebAppVersion\", r), t && h.set(\"tgWebAppData\", t), o && h.set(\"tgWebAppStartParam\", o), typeof i == \"boolean\" && h.set(\"tgWebAppShowSettings\", i ? \"1\" : \"0\"), typeof a == \"boolean\" && h.set(\"tgWebAppBotInline\", a ? \"1\" : \"0\"), h.toString();\n}\nfunction qt(e) {\n Rt(\"launchParams\", ye(e));\n}\nfunction ve() {\n for (const e of [\n // Try to retrieve launch parameters from the current location. This method can return\n // nothing in case, location was changed and then page was reloaded.\n be,\n // Then, try using the lower level API - window.performance.\n we,\n // Finally, try to extract launch parameters from the session storage.\n me\n ])\n try {\n const t = e();\n return qt(t), t;\n } catch {\n }\n throw new Error(\"Unable to retrieve launch parameters from any known source.\");\n}\nfunction kt() {\n const e = Ct();\n return !!(e && e.type === \"reload\");\n}\nfunction Ee() {\n let e = 0;\n return () => (e += 1).toString();\n}\nconst [xe] = ot(Ee);\nfunction l(e, t) {\n return () => {\n const s = ve(), n = {\n ...s,\n postEvent: he(s.version),\n createRequestId: xe()\n };\n if (typeof e == \"function\")\n return e(n);\n const [r, i, o] = J(), a = t({\n ...n,\n // State should only be passed only in case, current page was reloaded. If we don't add\n // this check, state restoration will work improperly in the web version of Telegram,\n // when we are always working in the same \"session\" (tab).\n state: kt() ? At(e) : void 0,\n addCleanup: r\n }), h = (u) => (o || r(\n u.on(\"change\", (Bt) => {\n Rt(e, Bt);\n })\n ), u);\n return [\n a instanceof Promise ? a.then(h) : h(a),\n i\n ];\n };\n}\nconst ss = l(\"backButton\", ({\n postEvent: e,\n version: t,\n state: s = { isVisible: !1 }\n}) => new le(s.isVisible, t, e));\nclass k extends Z {\n constructor() {\n super(...arguments);\n /**\n * Adds a new event listener.\n */\n c(this, \"on\", this.state.on.bind(this.state));\n /**\n * Removes the event listener.\n */\n c(this, \"off\", this.state.off.bind(this.state));\n }\n}\nfunction Nt(e) {\n const t = e.available ? e : {\n available: !1,\n device_id: \"\",\n token_saved: !1,\n access_requested: !1,\n access_granted: !1,\n type: \"\"\n };\n return {\n available: !0,\n type: t.type,\n deviceId: t.device_id,\n tokenSaved: t.token_saved,\n accessRequested: t.access_requested,\n accessGranted: t.access_granted\n };\n}\nclass Pe extends k {\n constructor({ postEvent: s, version: n, ...r }) {\n super(r, n, {\n auth: \"web_app_biometry_request_auth\",\n openSettings: \"web_app_biometry_open_settings\",\n requestAccess: \"web_app_biometry_request_access\",\n updateToken: \"web_app_biometry_update_token\"\n });\n c(this, \"postEvent\");\n c(this, \"authPromise\");\n c(this, \"accessPromise\");\n this.postEvent = s;\n }\n /**\n * Shows whether biometry is available.\n */\n get available() {\n return this.get(\"available\");\n }\n /**\n * Shows whether permission to use biometrics has been granted.\n */\n get accessGranted() {\n return this.get(\"accessGranted\");\n }\n /**\n * Shows whether if permission to use biometrics has been requested.\n */\n get accessRequested() {\n return this.get(\"accessRequested\");\n }\n /**\n * Authenticates the user using biometrics.\n * @param options - method options.\n * @since 7.2\n * @returns Token from the local secure storage, if authentication was successful.\n */\n async authenticate({\n reason: s,\n ...n\n }) {\n return this.authPromise || (this.authPromise = d({\n ...n,\n method: \"web_app_biometry_request_auth\",\n event: \"biometry_auth_requested\",\n postEvent: this.postEvent,\n params: {\n // TODO: Check if reason is empty works fine.\n reason: (s || \"\").trim()\n }\n }).then(({ token: r }) => r).finally(() => this.authPromise = void 0)), this.authPromise;\n }\n /**\n * A unique device identifier that can be used to match the token to the device.\n */\n get deviceId() {\n return this.get(\"deviceId\");\n }\n /**\n * Opens the biometric access settings for bots. Useful when you need to request biometrics\n * access to users who haven't granted it yet.\n *\n * _Note that this method can be called only in response to user interaction with the Mini App\n * interface (e.g. a click inside the Mini App or on the main button)_.\n * @since 7.2\n */\n openSettings() {\n this.postEvent(\"web_app_biometry_open_settings\");\n }\n /**\n * Requests permission to use biometrics.\n * @since 7.2\n * @returns Promise with true, if access was granted.\n */\n requestAccess({ reason: s, ...n } = {}) {\n return this.accessPromise || (this.accessPromise = d({\n ...n,\n postEvent: this.postEvent,\n method: \"web_app_biometry_request_access\",\n event: \"biometry_info_received\",\n params: { reason: s || \"\" }\n }).then((r) => {\n const i = Nt(r);\n return this.set(i), i.accessGranted;\n }).finally(() => this.accessPromise = void 0)), this.accessPromise;\n }\n /**\n * The type of biometrics currently available on the device.\n */\n get biometryType() {\n return this.get(\"biometryType\");\n }\n /**\n * Shows whether token was saved previously in the local secure storage.\n */\n get tokenSaved() {\n return this.get(\"tokenSaved\");\n }\n /**\n * Updates the biometric token in a secure storage on the device.\n * @returns Promise with `true`, if token was updated.\n */\n async updateToken({ token: s, ...n } = {}) {\n return [\"removed\", \"updated\"].includes(\n (await d({\n ...n,\n postEvent: this.postEvent,\n method: \"web_app_biometry_update_token\",\n event: \"biometry_token_updated\",\n params: { token: s || \"\" }\n })).status\n );\n }\n}\nasync function Se(e) {\n return Nt(\n await d({\n ...e || {},\n method: \"web_app_biometry_get_info\",\n event: \"biometry_info_received\"\n })\n );\n}\nconst ns = l(\n \"biometryManager\",\n async ({ postEvent: e, version: t, state: s }) => new Pe({\n ...s || v(\"web_app_biometry_get_info\", t) ? s || await Se({ timeout: 1e3 }) : {\n available: !1,\n accessGranted: !1,\n accessRequested: !1,\n tokenSaved: !1,\n deviceId: \"\"\n },\n version: t,\n postEvent: e\n })\n);\nclass tt extends Y {\n constructor() {\n super(...arguments);\n /**\n * Adds a new event listener.\n */\n c(this, \"on\", this.state.on.bind(this.state));\n /**\n * Removes the event listener.\n */\n c(this, \"off\", this.state.off.bind(this.state));\n }\n}\nclass Ce extends tt {\n constructor(t, s) {\n super({ isConfirmationNeeded: t }), this.postEvent = s;\n }\n set isConfirmationNeeded(t) {\n this.set(\"isConfirmationNeeded\", t), this.postEvent(\"web_app_setup_closing_behavior\", { need_confirmation: t });\n }\n /**\n * True, if the confirmation dialog should be shown while the user is trying to close\n * the Mini App.\n */\n get isConfirmationNeeded() {\n return this.get(\"isConfirmationNeeded\");\n }\n /**\n * Disables the confirmation dialog when closing the Mini App.\n */\n disableConfirmation() {\n this.isConfirmationNeeded = !1;\n }\n /**\n * Enables the confirmation dialog when closing the Mini App.\n */\n enableConfirmation() {\n this.isConfirmationNeeded = !0;\n }\n}\nconst rs = l(\n \"closingBehavior\",\n ({\n postEvent: e,\n state: t = { isConfirmationNeeded: !1 }\n }) => new Ce(t.isConfirmationNeeded, e)\n);\nclass et {\n constructor(t, s) {\n /**\n * @returns True, if specified method is supported by the current component.\n */\n c(this, \"supports\");\n this.supports = vt(t, s);\n }\n}\nfunction Te(e) {\n if (Array.isArray(e))\n return e;\n if (typeof e == \"string\")\n try {\n const t = JSON.parse(e);\n if (Array.isArray(t))\n return t;\n } catch {\n }\n throw E();\n}\nclass Re extends M {\n constructor(s, n, r) {\n super(Te, n, r);\n c(this, \"itemParser\");\n this.itemParser = typeof s == \"function\" ? s : s.parse.bind(s);\n }\n /**\n * Attempts to parse passed value\n * @param value - value to parse.\n * @throws {SDKError} ERR_PARSE\n * @see ERR_PARSE\n */\n parse(s) {\n const n = super.parse(s);\n return n === void 0 ? n : n.map(this.itemParser);\n }\n of(s) {\n return this.itemParser = typeof s == \"function\" ? s : s.parse.bind(s), this;\n }\n}\nfunction Ae(e) {\n return new Re((t) => t, !1, e);\n}\nfunction rt(e, t) {\n return Object.fromEntries(e.map((s) => [s, t]));\n}\nclass Ie extends et {\n constructor(t, s, n) {\n super(t, {\n delete: \"web_app_invoke_custom_method\",\n get: \"web_app_invoke_custom_method\",\n getKeys: \"web_app_invoke_custom_method\",\n set: \"web_app_invoke_custom_method\"\n }), this.createRequestId = s, this.postEvent = n;\n }\n /**\n * Deletes specified key or keys from the cloud storage.\n * @param keyOrKeys - key or keys to delete.\n * @param options - request execution options.\n */\n async delete(t, s = {}) {\n const n = Array.isArray(t) ? t : [t];\n n.length && await S(\n \"deleteStorageValues\",\n { keys: n },\n this.createRequestId(),\n { ...s, postEvent: this.postEvent }\n );\n }\n /**\n * Returns list of all keys presented in the cloud storage.\n * @param options - request execution options.\n */\n async getKeys(t = {}) {\n return Ae().of(p()).parse(\n await S(\n \"getStorageKeys\",\n {},\n this.createRequestId(),\n { ...t, postEvent: this.postEvent }\n )\n );\n }\n async get(t, s = {}) {\n const n = Array.isArray(t) ? t : [t];\n if (!n.length)\n return rt(n, \"\");\n const r = await S(\n \"getStorageValues\",\n { keys: n },\n this.createRequestId(),\n { ...s, postEvent: this.postEvent }\n ), i = g(rt(n, p()), \"CloudStorageData\").parse(r);\n return Array.isArray(t) ? i : i[t];\n }\n /**\n * Saves specified value by key.\n * @param key - storage key.\n * @param value - storage value.\n * @param options - request execution options.\n */\n async set(t, s, n = {}) {\n await S(\n \"saveStorageValue\",\n { key: t, value: s },\n this.createRequestId(),\n { ...n, postEvent: this.postEvent }\n );\n }\n}\nconst is = l(\n ({ createRequestId: e, postEvent: t, version: s }) => new Ie(s, e, t)\n);\nclass qe extends et {\n constructor(t, s) {\n super(t, {\n impactOccurred: \"web_app_trigger_haptic_feedback\",\n notificationOccurred: \"web_app_trigger_haptic_feedback\",\n selectionChanged: \"web_app_trigger_haptic_feedback\"\n }), this.postEvent = s;\n }\n /**\n * A method tells that an impact occurred. The Telegram app may play the\n * appropriate haptics based on style value passed.\n * @param style - impact style.\n */\n impactOccurred(t) {\n this.postEvent(\"web_app_trigger_haptic_feedback\", {\n type: \"impact\",\n impact_style: t\n });\n }\n /**\n * A method tells that a task or action has succeeded, failed, or produced\n * a warning. The Telegram app may play the appropriate haptics based on\n * type value passed.\n * @param type - notification type.\n */\n notificationOccurred(t) {\n this.postEvent(\"web_app_trigger_haptic_feedback\", {\n type: \"notification\",\n notification_type: t\n });\n }\n /**\n * A method tells that the user has changed a selection. The Telegram app\n * may play the appropriate haptics.\n *\n * Do not use this feedback when the user makes or confirms a selection;\n * use it only when the selection changes.\n */\n selectionChanged() {\n this.postEvent(\"web_app_trigger_haptic_feedback\", { type: \"selection_change\" });\n }\n}\nconst os = l(\n ({ version: e, postEvent: t }) => new qe(e, t)\n);\nclass ke {\n constructor(t) {\n this.initData = t;\n }\n /**\n * @see InitDataParsed.authDate\n */\n get authDate() {\n return this.initData.authDate;\n }\n /**\n * @see InitDataParsed.canSendAfter\n */\n get canSendAfter() {\n return this.initData.canSendAfter;\n }\n /**\n * Date after which it is allowed to call\n * the [answerWebAppQuery](https://core.telegram.org/bots/api#answerwebappquery) method.\n */\n get canSendAfterDate() {\n const { canSendAfter: t } = this;\n return t ? new Date(this.authDate.getTime() + t * 1e3) : void 0;\n }\n /**\n * @see InitDataParsed.chat\n */\n get chat() {\n return this.initData.chat;\n }\n /**\n * @see InitDataParsed.chatType\n */\n get chatType() {\n return this.initData.chatType;\n }\n /**\n * @see InitDataParsed.chatInstance\n */\n get chatInstance() {\n return this.initData.chatInstance;\n }\n /**\n * @see InitDataParsed.hash\n */\n get hash() {\n return this.initData.hash;\n }\n /**\n * @see InitDataParsed.queryId\n */\n get queryId() {\n return this.initData.queryId;\n }\n /**\n * @see InitDataParsed.receiver\n */\n get receiver() {\n return this.initData.receiver;\n }\n /**\n * @see InitDataParsed.startParam\n */\n get startParam() {\n return this.initData.startParam;\n }\n /**\n * @see InitDataParsed.user\n */\n get user() {\n return this.initData.user;\n }\n}\nconst as = l(\n ({ initData: e }) => e ? new ke(e) : void 0\n);\nfunction cs(e) {\n return xt().parse(e);\n}\nclass Ne extends k {\n constructor(t, s, n) {\n super({ isOpened: t }, s, { open: \"web_app_open_invoice\" }), this.postEvent = n;\n }\n set isOpened(t) {\n this.set(\"isOpened\", t);\n }\n /**\n * True if invoice is currently opened.\n */\n get isOpened() {\n return this.get(\"isOpened\");\n }\n async open(t, s) {\n if (this.isOpened)\n throw new Error(\"Invoice is already opened\");\n let n;\n if (!s)\n n = t;\n else {\n const { hostname: r, pathname: i } = new URL(t, window.location.href);\n if (r !== \"t.me\")\n throw new Error(`Incorrect hostname: ${r}`);\n const o = i.match(/^\\/(\\$|invoice\\/)([A-Za-z0-9\\-_=]+)$/);\n if (!o)\n throw new Error('Link pathname has incorrect format. Expected to receive \"/invoice/{slug}\" or \"/${slug}\"');\n [, , n] = o;\n }\n this.isOpened = !0;\n try {\n return (await d({\n method: \"web_app_open_invoice\",\n event: \"invoice_closed\",\n params: { slug: n },\n postEvent: this.postEvent,\n capture(i) {\n return n === i.slug;\n }\n })).status;\n } finally {\n this.isOpened = !1;\n }\n }\n}\nconst hs = l(\n ({ version: e, postEvent: t }) => new Ne(!1, e, t)\n);\nclass De extends Y {\n constructor({ postEvent: s, ...n }) {\n super(n);\n c(this, \"postEvent\");\n /**\n * Adds a new event listener.\n * @param event - event to listen.\n * @param listener - listener to add.\n */\n c(this, \"on\", (s, n) => s === \"click\" ? b(\"main_button_pressed\", n) : this.state.on(s, n));\n /**\n * Removes the event listener.\n * @param event - event to listen.\n * @param listener - listener to remove.\n */\n c(this, \"off\", (s, n) => s === \"click\" ? L(\"main_button_pressed\", n) : this.state.off(s, n));\n this.postEvent = s;\n }\n /**\n * The MainButton background color.\n */\n get bgColor() {\n return this.get(\"bgColor\");\n }\n /**\n * Sends current local state to the Telegram application.\n */\n commit() {\n this.text !== \"\" && this.postEvent(\"web_app_setup_main_button\", {\n is_visible: this.isVisible,\n is_active: this.isEnabled,\n is_progress_visible: this.isLoaderVisible,\n text: this.text,\n color: this.bgColor,\n text_color: this.textColor\n });\n }\n /**\n * Disables the MainButton.\n * @see Does not work on Android: https://github.com/Telegram-Mini-Apps/issues/issues/1\n */\n disable() {\n return this.isEnabled = !1, this;\n }\n /**\n * Enables the MainButton.\n */\n enable() {\n return this.isEnabled = !0, this;\n }\n /**\n * Hides the MainButton.\n */\n hide() {\n return this.isVisible = !1, this;\n }\n /**\n * Hides the MainButton loading indicator.\n */\n hideLoader() {\n return this.isLoaderVisible = !1, this;\n }\n set isEnabled(s) {\n this.setParams({ isEnabled: s });\n }\n /**\n * True if the MainButton is enabled.\n */\n get isEnabled() {\n return this.get(\"isEnabled\");\n }\n set isLoaderVisible(s) {\n this.setParams({ isLoaderVisible: s });\n }\n /**\n * True if the MainButton loader is visible.\n */\n get isLoaderVisible() {\n return this.get(\"isLoaderVisible\");\n }\n set isVisible(s) {\n this.setParams({ isVisible: s });\n }\n /**\n * True if the MainButton is visible.\n */\n get isVisible() {\n return this.get(\"isVisible\");\n }\n /**\n * Shows the MainButton.\n *\n * Note that opening the Mini App from the attachment menu hides the main button until the\n * user interacts with the Mini App interface.\n */\n show() {\n return this.isVisible = !0, this;\n }\n /**\n * Shows a loading indicator on the Main Button.\n */\n showLoader() {\n return this.isLoaderVisible = !0, this;\n }\n /**\n * Sets a new MainButton text. Minimal length for the text is 1 symbol, and maximum is 64 symbols.\n * @param text - a new text.\n */\n setText(s) {\n return this.setParams({ text: s });\n }\n /**\n * Sets a new Main Button text color.\n * @param textColor - new text color.\n */\n setTextColor(s) {\n return this.setParams({ textColor: s });\n }\n /**\n * Updates current Main Button color.\n * @param bgColor - color to set.\n */\n setBgColor(s) {\n return this.setParams({ bgColor: s });\n }\n /**\n * Allows setting multiple Main Button parameters.\n * @param params - Main Button parameters.\n */\n setParams(s) {\n return this.set(s), this.commit(), this;\n }\n /**\n * The MainButton text.\n */\n get text() {\n return this.get(\"text\");\n }\n /**\n * The MainButton text color.\n */\n get textColor() {\n return this.get(\"textColor\");\n }\n}\nconst ps = l(\n \"mainButton\",\n ({\n postEvent: e,\n themeParams: t,\n state: s = {\n isVisible: !1,\n isEnabled: !1,\n text: \"\",\n isLoaderVisible: !1,\n textColor: t.buttonTextColor || \"#ffffff\",\n bgColor: t.buttonColor || \"#000000\"\n }\n }) => new De({ ...s, postEvent: e })\n);\nfunction Me() {\n return K({\n contact: g({\n userId: {\n type: y(),\n from: \"user_id\"\n },\n phoneNumber: {\n type: p(),\n from: \"phone_number\"\n },\n firstName: {\n type: p(),\n from: \"first_name\"\n },\n lastName: {\n type: p().optional(),\n from: \"last_name\"\n }\n }),\n authDate: {\n type: Et(),\n from: \"auth_date\"\n },\n hash: p()\n }, \"RequestedContact\");\n}\nfunction Dt(e, t) {\n return (s) => {\n const [n, r] = t[s];\n return v(n, r, e);\n };\n}\nfunction Ve(e) {\n return new Promise((t) => {\n setTimeout(t, e);\n });\n}\nclass Le extends k {\n constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...o }) {\n super(o, r, {\n requestPhoneAccess: \"web_app_request_phone\",\n requestWriteAccess: \"web_app_request_write_access\",\n switchInlineQuery: \"web_app_switch_inline_query\",\n setHeaderColor: \"web_app_set_header_color\",\n setBackgroundColor: \"web_app_set_background_color\"\n });\n c(this, \"botInline\");\n c(this, \"postEvent\");\n c(this, \"createRequestId\");\n c(this, \"requestPhoneAccessPromise\");\n c(this, \"requestWriteAccessPromise\");\n /**\n * Checks if specified method parameter is supported by current component.\n */\n c(this, \"supportsParam\");\n this.createRequestId = n, this.postEvent = s, this.botInline = i;\n const a = this.supports.bind(this);\n this.supports = (h) => a(h) ? h !== \"switchInlineQuery\" || i : !1, this.supportsParam = Dt(r, {\n \"setHeaderColor.color\": [\"web_app_set_header_color\", \"color\"]\n });\n }\n /**\n * Attempts to get requested contact.\n * @param timeout - request timeout.\n */\n async getRequestedContact({\n timeout: s = 1e4\n } = {}) {\n return Me().parse(\n await S(\n \"getRequestedContact\",\n {},\n this.createRequestId(),\n { postEvent: this.postEvent, timeout: s }\n )\n );\n }\n /**\n * The Mini App background color.\n * @example \"#ffaabb\"\n */\n get bgColor() {\n return this.get(\"bgColor\");\n }\n /**\n * Closes the Mini App.\n * @param returnBack - should the application be wrapped into the bottom bar.\n */\n close(s) {\n this.postEvent(\"web_app_close\", { return_back: s });\n }\n /**\n * The Mini App header color.\n * @example \"#ffaabb\"\n * @example \"bg_color\"\n */\n get headerColor() {\n return this.get(\"headerColor\");\n }\n /**\n * True if the Mini App is currently launched in bot inline mode.\n */\n get isBotInline() {\n return this.botInline;\n }\n /**\n * True if the current Mini App background color is recognized as dark.\n */\n get isDark() {\n return yt(this.bgColor);\n }\n /**\n * Informs the Telegram app that the Mini App is ready to be displayed.\n *\n * It is recommended to call this method as early as possible, as soon as all essential\n * interface elements loaded. Once this method called, the loading placeholder is hidden\n * and the Mini App shown.\n *\n * If the method not called, the placeholder will be hidden only when the page fully loaded.\n */\n ready() {\n this.postEvent(\"web_app_ready\");\n }\n /**\n * Requests current user contact information. In contrary to requestPhoneAccess, this method\n * returns promise with contact information that rejects in case, user denied access, or request\n * failed.\n * @param options - additional options.\n */\n async requestContact({ timeout: s = 5e3 } = {}) {\n try {\n return await this.getRequestedContact();\n } catch {\n }\n if (await this.requestPhoneAccess() !== \"sent\")\n throw new Error(\"Access denied.\");\n const r = Date.now() + s;\n let i = 50;\n return wt(async () => {\n for (; Date.now() < r; ) {\n try {\n return await this.getRequestedContact();\n } catch {\n }\n await Ve(i), i += 50;\n }\n throw bt(s);\n }, s);\n }\n /**\n * Requests current user phone access. Method returns promise, which resolves\n * status of the request. In case, user accepted the request, Mini App bot will receive\n * the according notification.\n *\n * To obtain the retrieved information instead, utilize the `requestContact` method.\n * @param options - additional options.\n * @see requestContact\n */\n async requestPhoneAccess(s = {}) {\n return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = d({\n ...s,\n method: \"web_app_request_phone\",\n event: \"phone_requested\",\n postEvent: this.postEvent\n }).then(({ status: n }) => n).finally(() => this.requestPhoneAccessPromise = void 0)), this.requestPhoneAccessPromise;\n }\n /**\n * Requests write message access to current user.\n * @param options - additional options.\n */\n async requestWriteAccess(s = {}) {\n return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = d({\n ...s,\n method: \"web_app_request_write_access\",\n event: \"write_access_requested\",\n postEvent: this.postEvent\n }).then(({ status: n }) => n).finally(() => this.requestWriteAccessPromise = void 0)), this.requestWriteAccessPromise;\n }\n /**\n * A method used to send data to the bot. When this method called, a service message sent to\n * the bot containing the data of the length up to 4096 bytes, and the Mini App closed. See the\n * field `web_app_data` in the class [Message](https://core.telegram.org/bots/api#message).\n *\n * This method is only available for Mini Apps launched via a Keyboard button.\n * @param data - data to send to bot.\n * @throws {Error} data has incorrect size.\n */\n sendData(s) {\n const { size: n } = new Blob([s]);\n if (!n || n > 4096)\n throw new Error(`Passed data has incorrect size: ${n}`);\n this.postEvent(\"web_app_data_send\", { data: s });\n }\n /**\n * Updates current Mini App header color.\n *\n * @see No effect on desktop: https://github.com/Telegram-Mini-Apps/tma.js/issues/9\n * @see Works incorrectly in Android: https://github.com/Telegram-Mini-Apps/tma.js/issues/8\n * @param color - color key or RGB color.\n */\n setHeaderColor(s) {\n this.postEvent(\"web_app_set_header_color\", Q(s) ? { color: s } : { color_key: s }), this.set(\"headerColor\", s);\n }\n /**\n * Updates current Mini App background color.\n *\n * @see No effect on desktop: https://github.com/Telegram-Mini-Apps/tma.js/issues/9\n * @see Works incorrectly in Android: https://github.com/Telegram-Mini-Apps/tma.js/issues/8\n * @param color - RGB color.\n */\n setBgColor(s) {\n this.postEvent(\"web_app_set_background_color\", { color: s }), this.set(\"bgColor\", s);\n }\n /**\n * Inserts the bot's username and the specified inline query in the current chat's input field.\n * Query may be empty, in which case only the bot's username will be inserted. The client prompts\n * the user to choose a specific chat, then opens that chat and inserts the bot's username and\n * the specified inline query in the input field.\n * @param text - text which should be inserted in the input after the current bot name. Max\n * length is 256 symbols.\n * @param chatTypes - List of chat types which could be chosen to send the message. Could be\n * empty list.\n */\n switchInlineQuery(s, n = []) {\n if (!this.supports(\"switchInlineQuery\") && !this.isBotInline)\n throw new Error(\"Method is unsupported because Mini App should be launched in inline mode.\");\n this.postEvent(\"web_app_switch_inline_query\", { query: s, chat_types: n });\n }\n}\nconst us = l(\n \"miniApp\",\n ({\n themeParams: e,\n botInline: t = !1,\n state: s = {\n bgColor: e.bgColor || \"#ffffff\",\n headerColor: e.headerBgColor || \"#000000\"\n },\n ...n\n }) => new Le({ ...n, ...s, botInline: t })\n);\nfunction $e(e) {\n const t = e.message.trim(), s = (e.title || \"\").trim(), n = e.buttons || [];\n let r;\n if (s.length > 64)\n throw new Error(`Title has incorrect size: ${s.length}`);\n if (!t.length || t.length > 256)\n throw new Error(`Message has incorrect size: ${t.length}`);\n if (n.length > 3)\n throw new Error(`Buttons have incorrect size: ${n.length}`);\n return n.length ? r = n.map((i) => {\n const { id: o = \"\" } = i;\n if (o.length > 64)\n throw new Error(`Button ID has incorrect size: ${o}`);\n if (!i.type || i.type === \"default\" || i.type === \"destructive\") {\n const a = i.text.trim();\n if (!a.length || a.length > 64) {\n const h = i.type || \"default\";\n throw new Error(`Button text with type \"${h}\" has incorrect size: ${i.text.length}`);\n }\n return { ...i, text: a, id: o };\n }\n return { ...i, id: o };\n }) : r = [{ type: \"close\", id: \"\" }], { title: s, message: t, buttons: r };\n}\nclass Be extends k {\n constructor(t, s, n) {\n super({ isOpened: t }, s, { open: \"web_app_open_popup\" }), this.postEvent = n;\n }\n set isOpened(t) {\n this.set(\"isOpened\", t);\n }\n /**\n * True if the Popup is opened.\n */\n get isOpened() {\n return this.get(\"isOpened\");\n }\n /**\n * A method that shows a native popup described by the `params` argument.\n * Promise will be resolved when popup is closed. Resolved value will have\n * an identifier of pressed button.\n *\n * In case, user clicked outside the popup or clicked top right popup close\n * button, null will be returned.\n *\n * @param options - popup parameters.\n * @throws {Error} Popup is already opened.\n */\n async open(t) {\n if (this.isOpened)\n throw new Error(\"Popup is already opened.\");\n this.isOpened = !0;\n try {\n const { button_id: s = null } = await d({\n event: \"popup_closed\",\n method: \"web_app_open_popup\",\n postEvent: this.postEvent,\n params: $e(t)\n });\n return s;\n } finally {\n this.isOpened = !1;\n }\n }\n}\nconst ls = l(\n ({ postEvent: e, version: t }) => new Be(!1, t, e)\n);\nclass We extends k {\n constructor(t, s, n) {\n super({ isOpened: t }, s, {\n close: \"web_app_close_scan_qr_popup\",\n open: \"web_app_open_scan_qr_popup\"\n }), this.postEvent = n;\n }\n /**\n * Closes the scanner.\n */\n close() {\n this.postEvent(\"web_app_close_scan_qr_popup\"), this.isOpened = !1;\n }\n set isOpened(t) {\n this.set(\"isOpened\", t);\n }\n /**\n * Returns true if the scanner is currently opened.\n */\n get isOpened() {\n return this.get(\"isOpened\");\n }\n async open(t) {\n if (this.isOpened)\n throw new Error(\"The scanner is already opened\");\n const { text: s, capture: n } = (typeof t == \"string\" ? { text: t } : t) || {};\n this.isOpened = !0;\n try {\n const i = (await d({\n method: \"web_app_open_scan_qr_popup\",\n event: [\"qr_text_received\", \"scan_qr_popup_closed\"],\n postEvent: this.postEvent,\n params: { text: s },\n capture(o) {\n return o.event === \"scan_qr_popup_closed\" || !n || n(o.payload);\n }\n }) || {}).data || null;\n return i && this.close(), i;\n } finally {\n this.isOpened = !1;\n }\n }\n // TODO: Streaming mode, allowing to scan several QRs until closed.\n}\nconst ds = l(\n ({ version: e, postEvent: t }) => new We(!1, e, t)\n);\nclass Ue extends Z {\n constructor(s, n, r) {\n super({ isVisible: s }, n, {\n show: \"web_app_setup_settings_button\",\n hide: \"web_app_setup_settings_button\"\n });\n /**\n * Adds a new event listener.\n * @param event - event to listen.\n * @param listener - listener to add.\n */\n c(this, \"on\", (s, n) => s === \"click\" ? b(\"settings_button_pressed\", n) : this.state.on(s, n));\n /**\n * Removes the event listener.\n * @param event - event to listen.\n * @param listener - listener to remove.\n */\n c(this, \"off\", (s, n) => s === \"click\" ? L(\"settings_button_pressed\", n) : this.state.off(s, n));\n this.postEvent = r;\n }\n set isVisible(s) {\n this.set(\"isVisible\", s), this.postEvent(\"web_app_setup_settings_button\", { is_visible: s });\n }\n /**\n * True if the SettingsButton is visible.\n */\n get isVisible() {\n return this.get(\"isVisible\");\n }\n /**\n * Hides the SettingsButton.\n */\n hide() {\n this.isVisible = !1;\n }\n /**\n * Shows the SettingsButton.\n */\n show() {\n this.isVisible = !0;\n }\n}\nconst _s = l(\n \"settingsButton\",\n ({\n version: e,\n postEvent: t,\n state: s = { isVisible: !1 }\n }) => new Ue(s.isVisible, e, t)\n);\nfunction Mt(e) {\n return Pt().parse(e);\n}\nclass He extends tt {\n /**\n * @since v6.10\n */\n get accentTextColor() {\n return this.get(\"accentTextColor\");\n }\n get bgColor() {\n return this.get(\"bgColor\");\n }\n get buttonColor() {\n return this.get(\"buttonColor\");\n }\n get buttonTextColor() {\n return this.get(\"buttonTextColor\");\n }\n get destructiveTextColor() {\n return this.get(\"destructiveTextColor\");\n }\n /**\n * Returns the copy of the internal state of the current component instance.\n */\n getState() {\n return this.clone();\n }\n /**\n * @since v6.10\n */\n get headerBgColor() {\n return this.get(\"headerBgColor\");\n }\n get hintColor() {\n return this.get(\"hintColor\");\n }\n /**\n * @returns True in case, current color scheme is recognized as dark. This\n * value is calculated according to theme bg color.\n */\n get isDark() {\n return !this.bgColor || yt(this.bgColor);\n }\n get linkColor() {\n return this.get(\"linkColor\");\n }\n get secondaryBgColor() {\n return this.get(\"secondaryBgColor\");\n }\n /**\n * @since v6.10\n */\n get sectionBgColor() {\n return this.get(\"sectionBgColor\");\n }\n /**\n * @since v6.10\n */\n get sectionHeaderTextColor() {\n return this.get(\"sectionHeaderTextColor\");\n }\n /**\n * @since v7.6\n */\n get sectionSeparatorColor() {\n return this.get(\"sectionHeaderTextColor\");\n }\n /**\n * Starts listening to the external theme changes and applies them.\n * @returns Function to stop listening.\n */\n listen() {\n return b(\"theme_changed\", (t) => {\n this.set(Mt(t.theme_params));\n });\n }\n /**\n * @since v6.10\n */\n get subtitleTextColor() {\n return this.get(\"subtitleTextColor\");\n }\n get textColor() {\n return this.get(\"textColor\");\n }\n}\nconst fs = l(\n \"themeParams\",\n ({ themeParams: e, state: t = e, addCleanup: s }) => {\n const n = new He(t);\n return s(n.listen()), n;\n }\n);\nfunction gs(e = {}) {\n return d({\n ...e,\n method: \"web_app_request_theme\",\n event: \"theme_changed\"\n }).then(Mt);\n}\nfunction A(e, t) {\n return e.startsWith(t) ? e : `${t}${e}`;\n}\nfunction I(e) {\n return new URL(\n typeof e == \"string\" ? e : `${e.pathname || \"\"}${A(e.search || \"\", \"?\")}${A(e.hash || \"\", \"#\")}`,\n \"http://a\"\n );\n}\nclass Oe extends et {\n constructor(s, n, r) {\n super(s, { readTextFromClipboard: \"web_app_read_text_from_clipboard\" });\n /**\n * Checks if specified method parameter is supported by current component.\n */\n c(this, \"supportsParam\");\n this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = Dt(s, {\n \"openLink.tryInstantView\": [\"web_app_open_link\", \"try_instant_view\"]\n });\n }\n openLink(s, n) {\n const r = I(s).toString();\n if (!v(\"web_app_open_link\", this.version)) {\n window.open(r, \"_blank\");\n return;\n }\n const i = typeof n == \"boolean\" ? { tryInstantView: n } : n || {};\n this.postEvent(\"web_app_open_link\", {\n url: r,\n try_browser: i.tryBrowser,\n try_instant_view: i.tryInstantView\n });\n }\n /**\n * Opens a Telegram link inside Telegram app. The Mini App will be closed. It expects passing\n * link in full format, with hostname \"t.me\".\n * @param url - URL to be opened.\n * @throws {Error} URL has not allowed hostname.\n */\n openTelegramLink(s) {\n const { hostname: n, pathname: r, search: i } = new URL(s, \"https://t.me\");\n if (n !== \"t.me\")\n throw new Error(`URL has not allowed hostname: ${n}. Only \"t.me\" is allowed`);\n if (!v(\"web_app_open_tg_link\", this.version)) {\n window.location.href = s;\n return;\n }\n this.postEvent(\"web_app_open_tg_link\", { path_full: r + i });\n }\n /**\n * Reads text from clipboard and returns string or null. null is returned\n * in cases:\n * - Value in clipboard is not text\n * - Access to clipboard is not allowed\n */\n async readTextFromClipboard() {\n const s = this.createRequestId(), {\n data: n = null\n } = await d({\n method: \"web_app_read_text_from_clipboard\",\n event: \"clipboard_text_received\",\n postEvent: this.postEvent,\n params: { req_id: s },\n capture: gt(s)\n });\n return n;\n }\n /**\n * Shares specified URL with the passed to the chats, selected by user. After being called,\n * it closes the mini application.\n *\n * This method uses Telegram's Share Links.\n * @param url - URL to share.\n * @param text - text to append after the URL.\n * @see https://core.telegram.org/api/links#share-links\n * @see https://core.telegram.org/widgets/share#custom-buttons\n */\n shareURL(s, n) {\n this.openTelegramLink(\n \"https://t.me/share/url?\" + new URLSearchParams({ url: s, text: n || \"\" }).toString().replace(/\\+/g, \"%20\")\n );\n }\n}\nconst bs = l(\n ({ version: e, postEvent: t, createRequestId: s }) => new Oe(e, s, t)\n);\nasync function Vt(e = {}) {\n const {\n is_expanded: t,\n is_state_stable: s,\n ...n\n } = await d({\n ...e,\n method: \"web_app_request_viewport\",\n event: \"viewport_changed\"\n });\n return { ...n, isExpanded: t, isStateStable: s };\n}\nfunction P(e) {\n return e < 0 ? 0 : e;\n}\nclass Ge extends tt {\n constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: o }) {\n super({\n height: P(r),\n isExpanded: o,\n stableHeight: P(n),\n width: P(i)\n });\n c(this, \"postEvent\");\n this.postEvent = s;\n }\n /**\n * Requests viewport information from the Telegram application and updates current Viewport\n * instance.\n * @param options - options to request fresh data.\n */\n async sync(s) {\n const { isStateStable: n, ...r } = await Vt(s);\n this.set({\n ...r,\n stableHeight: n ? r.height : this.get(\"stableHeight\")\n });\n }\n /**\n * The current height of the **visible area** of the Mini App.\n *\n * The application can display just the top part of the Mini App, with its lower part remaining\n * outside the screen area. From this position, the user can \"pull\" the Mini App to its\n * maximum height, while the bot can do the same by calling `expand` method. As the position of\n * the Mini App changes, the current height value of the visible area will be updated in real\n * time.\n *\n * Please note that the refresh rate of this value is not sufficient to smoothly follow the\n * lower border of the window. It should not be used to pin interface elements to the bottom\n * of the visible area. It's more appropriate to use the value of the `stableHeight`\n * field for this purpose.\n *\n * @see stableHeight\n */\n get height() {\n return this.get(\"height\");\n }\n /**\n * The height of the visible area of the Mini App in its last stable state.\n *\n * The application can display just the top part of the Mini App, with its lower part remaining\n * outside the screen area. From this position, the user can \"pull\" the Mini App to its\n * maximum height, while the application can do the same by calling `expand` method.\n *\n * Unlike the value of `height`, the value of `stableHeight` does not change as the position\n * of the Mini App changes with user gestures or during animations. The value of `stableHeight`\n * will be updated after all gestures and animations are completed and\n * the Mini App reaches its final size.\n *\n * @see height\n */\n get stableHeight() {\n return this.get(\"stableHeight\");\n }\n /**\n * Starts listening to viewport changes and applies them.\n * @returns Function to stop listening.\n */\n listen() {\n return b(\"viewport_changed\", (s) => {\n const {\n height: n,\n width: r,\n is_expanded: i,\n is_state_stable: o\n } = s, a = P(n);\n this.set({\n height: a,\n isExpanded: i,\n width: P(r),\n ...o ? { stableHeight: a } : {}\n });\n });\n }\n /**\n * True if the Mini App is expanded to the maximum available height. Otherwise, if\n * the Mini App occupies part of the screen and can be expanded to the full height using\n * `expand` method.\n * @see expand\n */\n get isExpanded() {\n return this.get(\"isExpanded\");\n }\n /**\n * Current visible area width.\n */\n get width() {\n return this.get(\"width\");\n }\n /**\n * A method that expands the Mini App to the maximum available height. To find out if the Mini\n * App is expanded to the maximum height, refer to the value of the `isExpanded`.\n * @see isExpanded\n */\n expand() {\n this.postEvent(\"web_app_expand\"), this.set(\"isExpanded\", !0);\n }\n /**\n * True if the current viewport height is stable and is not going to change in the next moment.\n */\n get isStable() {\n return this.stableHeight === this.height;\n }\n}\nconst ws = l(\n \"viewport\",\n async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {\n let r = !1, i = 0, o = 0, a = 0;\n if (e)\n r = e.isExpanded, i = e.height, o = e.width, a = e.stableHeight;\n else if ([\"macos\", \"tdesktop\", \"unigram\", \"webk\", \"weba\", \"web\"].includes(t))\n r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;\n else {\n const u = await Vt({ timeout: 1e3, postEvent: s });\n r = u.isExpanded, i = u.height, o = u.width, a = u.isStateStable ? i : 0;\n }\n const h = new Ge({\n postEvent: s,\n height: i,\n width: o,\n stableHeight: a,\n isExpanded: r\n });\n return n(h.listen()), h;\n }\n);\nfunction m(e, t) {\n document.documentElement.style.setProperty(e, t);\n}\nfunction ms(e, t, s) {\n s || (s = (a) => `--tg-${a}-color`);\n const n = s(\"header\"), r = s(\"bg\"), i = () => {\n const { headerColor: a } = e;\n if (Q(a))\n m(n, a);\n else {\n const { bgColor: h, secondaryBgColor: u } = t;\n a === \"bg_color\" && h ? m(n, h) : a === \"secondary_bg_color\" && u && m(n, u);\n }\n m(r, e.bgColor);\n }, o = [\n t.on(\"change\", i),\n e.on(\"change\", i)\n ];\n return i(), () => o.forEach((a) => a());\n}\nfunction ys(e, t) {\n t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);\n const s = () => {\n Object.entries(e.getState()).forEach(([n, r]) => {\n r && m(t(n), r);\n });\n };\n return s(), e.on(\"change\", s);\n}\nfunction vs(e, t) {\n t || (t = (u) => `--tg-viewport-${u}`);\n const [\n s,\n n,\n r\n ] = [\"height\", \"width\", \"stable-height\"].map((u) => t(u)), i = () => m(s, `${e.height}px`), o = () => m(n, `${e.width}px`), a = () => m(r, `${e.stableHeight}px`), h = [\n e.on(\"change:height\", i),\n e.on(\"change:width\", o),\n e.on(\"change:stableHeight\", a)\n ];\n return i(), o(), a(), () => h.forEach((u) => u());\n}\nfunction Es(e = !0) {\n const t = [\n b(\"reload_iframe\", () => {\n R(\"iframe_will_reload\"), window.location.reload();\n })\n ], s = () => t.forEach((n) => n());\n if (e) {\n const n = document.createElement(\"style\");\n n.id = \"telegram-custom-styles\", document.head.appendChild(n), t.push(\n b(\"set_custom_style\", (r) => {\n n.innerHTML = r;\n }),\n () => document.head.removeChild(n)\n );\n }\n return R(\"iframe_ready\", { reload_supported: !0 }), s;\n}\nfunction xs() {\n return typeof window > \"u\";\n}\nasync function Ps() {\n if (dt(window))\n return !0;\n try {\n return await d({ method: \"web_app_request_theme\", event: \"theme_changed\", timeout: 100 }), !0;\n } catch {\n return !1;\n }\n}\nfunction Ss(e) {\n const t = typeof e == \"string\" ? X(e) : e;\n qt(t);\n function s(r) {\n if (typeof r == \"string\")\n try {\n const { eventType: i } = ut(r);\n i === \"web_app_request_theme\" && j(\"theme_changed\", {\n theme_params: JSON.parse(It(t.themeParams))\n }), i === \"web_app_request_viewport\" && j(\"viewport_changed\", {\n width: window.innerWidth,\n height: window.innerHeight,\n is_state_stable: !0,\n is_expanded: !0\n });\n } catch {\n }\n }\n if (_t()) {\n const r = window.parent.postMessage.bind(window.parent);\n window.parent.postMessage = (i) => {\n s(i), r(i);\n };\n return;\n }\n if (lt(window)) {\n const r = window.external.notify.bind(window.external);\n window.external.notify = (i) => {\n s(i), r(i);\n };\n return;\n }\n const n = window.TelegramWebviewProxy;\n window.TelegramWebviewProxy = {\n ...n || {},\n postEvent(...r) {\n s(JSON.stringify({ eventType: r[0], eventData: r[1] })), n && n.postEvent(...r);\n }\n };\n}\nfunction je(e) {\n return e instanceof D;\n}\nfunction Cs(e, t) {\n return je(e) && e.type === t;\n}\nfunction $(e, t) {\n let s, n, r;\n return typeof e == \"string\" ? s = e : (s = e.pathname === void 0 ? t : e.pathname, n = e.params, r = e.id), Object.freeze({\n id: r || (Math.random() * 2 ** 14 | 0).toString(16),\n pathname: s,\n params: n\n });\n}\nclass ze {\n constructor(t, s, n = R) {\n /**\n * Navigation history.\n */\n c(this, \"history\");\n c(this, \"ee\", new T());\n /**\n * True, if current navigator is currently attached.\n */\n c(this, \"attached\", !1);\n /**\n * Goes to the previous history item.\n */\n c(this, \"back\", () => this.go(-1));\n /**\n * Adds new event listener.\n */\n c(this, \"on\", this.ee.on.bind(this.ee));\n /**\n * Removes event listener.\n */\n c(this, \"off\", this.ee.off.bind(this.ee));\n if (this._index = s, this.postEvent = n, t.length === 0)\n throw f(Zt, \"History should not be empty.\");\n if (s < 0 || s >= t.length)\n throw f(\n Kt,\n \"Index should not be zero and higher or equal than history size.\"\n );\n this.history = t.map((r) => $(r, \"\"));\n }\n /**\n * Allows this navigator to control the `BackButton` visibility state. It also tracks the\n * `BackButton` clicks and calls the `back` method.\n */\n attach() {\n this.attached || (this.attached = !0, this.sync(), b(\"back_button_pressed\", this.back));\n }\n /**\n * Currently active history item.\n */\n get current() {\n return this.history[this.index];\n }\n /**\n * Prevents current navigator from controlling the BackButton visibility state.\n */\n detach() {\n this.attached = !1, L(\"back_button_pressed\", this.back);\n }\n /**\n * Goes to the next history item.\n */\n forward() {\n this.go(1);\n }\n /**\n * Changes currently active history item index by the specified delta. This method doesn't\n * change index in case, the updated index points to the non-existing history item. This behavior\n * is preserved until the `fit` argument is specified.\n * @param delta - index delta.\n * @param fit - cuts the delta argument to fit the bounds `[0, history.length - 1]`.\n */\n go(t, s) {\n const n = this.index + t, r = Math.min(\n Math.max(0, n),\n this.history.length - 1\n );\n (n === r || s) && this.replaceAndMove(r, this.history[r]);\n }\n /**\n * Goes to the specified index. Method does nothing in case, passed index is out of bounds.\n *\n * If \"fit\" option was specified and index is out of bounds, it will be cut to the nearest\n * bound.\n * @param index - target index.\n * @param fit - cuts the index argument to fit the bounds `[0, history.length - 1]`.\n */\n goTo(t, s) {\n this.go(t - this.index, s);\n }\n /**\n * True if navigator has items before the current item.\n */\n get hasPrev() {\n return this.index > 0;\n }\n /**\n * True if navigator has items after the current item.\n */\n get hasNext() {\n return this.index !== this.history.length - 1;\n }\n /**\n * Currently active history item index.\n */\n get index() {\n return this._index;\n }\n /**\n * Adds a new history item removing all after the current one.\n * @param item - item to add.\n */\n push(t) {\n this.hasNext && this.history.splice(this.index + 1), this.replaceAndMove(this.index + 1, $(t, this.current.pathname));\n }\n /**\n * Replaces the current history item.\n * @param item - item to replace the current item with.\n */\n replace(t) {\n this.replaceAndMove(this.index, $(t, this.current.pathname));\n }\n /**\n * Sets history item by the specified index.\n * @param index - history item index to replace.\n * @param historyItem - history item to set.\n */\n replaceAndMove(t, s) {\n const n = t - this.index;\n if (!n && this.current === s)\n return;\n const r = this.current;\n if (this.index !== t) {\n const i = this._index;\n this._index = t, this.attached && i > 0 != t > 0 && this.sync();\n }\n this.history[t] = s, this.ee.emit(\"change\", {\n navigator: this,\n from: r,\n to: this.current,\n delta: n\n });\n }\n /**\n * Actualizes the `BackButton` visibility state.\n */\n sync() {\n this.postEvent(\"web_app_setup_back_button\", { is_visible: !!this.index });\n }\n}\nfunction B({\n params: e,\n ...t\n}) {\n return { ...e || { hash: \"\", search: \"\" }, ...t };\n}\nfunction N(e) {\n const t = typeof e == \"string\" ? e.startsWith(\"/\") : !!(e.pathname && e.pathname.startsWith(\"/\")), s = I(e);\n return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;\n}\nfunction W(e, t, s) {\n let n, r;\n typeof e == \"string\" ? n = e : (n = N(e), s = e.state, r = e.id);\n const { pathname: i, search: o, hash: a } = new URL(n, `http://a${A(t, \"/\")}`);\n return { id: r, pathname: i, params: { hash: a, search: o, state: s } };\n}\nasync function C(e) {\n return e === 0 ? !0 : Promise.race([\n new Promise((t) => {\n const s = G(\"popstate\", () => {\n s(), t(!0);\n });\n window.history.go(e);\n }),\n // Usually, it takes about 1ms to emit this event, but we use some buffer.\n new Promise((t) => {\n setTimeout(t, 50, !1);\n })\n ]);\n}\nasync function Fe() {\n if (window.history.length <= 1 || (window.history.pushState(null, \"\"), await C(1 - window.history.length)))\n return;\n let t = await C(-1);\n for (; t; )\n t = await C(-1);\n}\nfunction Lt(e) {\n return I(e).pathname;\n}\nconst it = 0, U = 1, H = 2;\nclass $t {\n constructor(t, s, { postEvent: n, hashMode: r = \"classic\", base: i } = {}) {\n c(this, \"navigator\");\n c(this, \"ee\", new T());\n c(this, \"hashMode\");\n c(this, \"base\");\n /**\n * Shows whether the navigator is currently attached to the browser history.\n */\n c(this, \"attached\", !1);\n /**\n * Handles the window \"popstate\" event.\n * @param state - event state.\n */\n c(this, \"onPopState\", ({ state: t }) => {\n if (t === null)\n return this.push(this.parsePath(window.location.href));\n t === it ? window.history.forward() : t === U && this.back(), t === H && this.forward();\n });\n /**\n * Underlying navigator change event listener.\n */\n c(this, \"onNavigatorChange\", async ({\n to: t,\n from: s,\n delta: n\n }) => {\n this.attached && await this.syncHistory(), this.ee.emit(\"change\", {\n delta: n,\n from: B(s),\n to: B(t),\n navigator: this\n });\n });\n /**\n * Adds new event listener.\n */\n c(this, \"on\", this.ee.on.bind(this.ee));\n /**\n * Removes event listener.\n */\n c(this, \"off\", this.ee.off.bind(this.ee));\n this.navigator = new ze(\n t.map((o) => W(o, \"/\")),\n s,\n n\n ), this.navigator.on(\"change\", (o) => {\n this.onNavigatorChange(o);\n }), this.hashMode = r, this.base = Lt(i || \"\");\n }\n /**\n * Attaches current navigator to the browser history allowing navigator to manipulate it.\n */\n async attach() {\n this.attached || (this.attached = !0, this.navigator.attach(), window.addEventListener(\"popstate\", this.onPopState), await this.syncHistory());\n }\n /**\n * Goes back in history by 1.\n */\n back() {\n this.navigator.back();\n }\n /**\n * Detaches current navigator from the browser history.\n */\n detach() {\n this.attached = !1, this.navigator.detach(), window.removeEventListener(\"popstate\", this.onPopState);\n }\n /**\n * Goes forward in history.\n */\n forward() {\n return this.navigator.forward();\n }\n /**\n * Current history cursor.\n */\n get index() {\n return this.navigator.index;\n }\n /**\n * Current history item identifier.\n */\n get id() {\n return this.navigator.current.id;\n }\n /**\n * Changes currently active history item index by the specified delta. This method doesn't\n * change index in case, the updated index points to the non-existing history item. This behavior\n * is preserved until the `fit` argument is specified.\n * @param delta - index delta.\n * @param fit - cuts the delta argument to fit the bounds `[0, history.length - 1]`.\n */\n go(t, s) {\n return this.navigator.go(t, s);\n }\n /**\n * Goes to the specified index. Method does nothing in case, passed index is out of bounds.\n *\n * If \"fit\" option was specified and index is out of bounds, it will be cut to the nearest\n * bound.\n * @param index - target index.\n * @param fit - cuts the index argument to fit the bounds `[0, history.length - 1]`.\n */\n goTo(t, s) {\n this.navigator.goTo(t, s);\n }\n /**\n * Current history item hash.\n * @see URL.hash\n * @example\n * \"\", \"#my-hash\"\n */\n get hash() {\n return (this.navigator.current.params || {}).hash || \"\";\n }\n /**\n * True if navigator has items before the current item.\n */\n get hasPrev() {\n return this.navigator.hasPrev;\n }\n /**\n * True if navigator has items after the current item.\n */\n get hasNext() {\n return this.navigator.hasNext;\n }\n /**\n * Navigation history.\n */\n get history() {\n return this.navigator.history.map(B);\n }\n /**\n * Path, including pathname, search and hash.\n * @example Pathname only.\n * \"/pathname\"\n * @example Pathname + search.\n * \"/pathname?search\"\n * @example Pathname + hash.\n * \"/pathname#hash\"\n * @example Pathname + search + hash.\n * \"/pathname?search#hash\"\n */\n get path() {\n return N(this);\n }\n /**\n * Current pathname. Always starts with the slash.\n * @see URL.pathname\n * @example\n * \"/\", \"/abc\"\n */\n get pathname() {\n return this.navigator.current.pathname;\n }\n /**\n * Depending on the current navigation type, parses incoming path and returns it presented as\n * an object. In other words, this method parses the passed path and returns object, describing\n * how the navigator \"sees\" it.\n *\n * @example Hash mode is omitted.\n * parsePath('/abc?a=1#hash');\n * // { pathname: '/abc', search: '?a=1', hash: '#hash' }\n * parsePath('http://example.com/abc?a=1#hash');\n * // { pathname: '/abc', search: '?a=1', hash: '#hash' }\n *\n * @example Hash mode is enabled.\n * parsePath('/abc?a=1#tma?is=cool#yeah');\n * // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }\n * parsePath('http://example.com/abc?a=1#tma?is=cool#yeah');\n * // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }\n */\n parsePath(t) {\n let s = I(t);\n return this.hashMode && (s = I(s.hash.slice(1))), {\n pathname: s.pathname,\n search: s.search,\n hash: s.hash\n };\n }\n push(t, s) {\n const n = W(t, this.path), { state: r = s } = n.params;\n this.navigator.push({ ...n, params: { ...n.params, state: r } });\n }\n replace(t, s) {\n const n = W(t, this.path), { state: r = s } = n.params;\n this.navigator.replace({ ...n, params: { ...n.params, state: r } });\n }\n /**\n * Combines the navigator `base` property with the passed path data applying the navigator\n * navigation mode.\n * @param value - path presented as string or URLLike.\n */\n renderPath(t) {\n const s = (this.base.length === 1 ? \"\" : this.base) + A(N(t), \"/\");\n return this.hashMode ? A(s.slice(1), this.hashMode === \"classic\" ? \"#\" : \"#/\") : s;\n }\n /**\n * Synchronizes current navigator state with browser history.\n */\n async syncHistory() {\n window.removeEventListener(\"popstate\", this.onPopState);\n const { state: t } = this, s = this.renderPath(this);\n await Fe(), this.hasPrev && this.hasNext ? (window.history.replaceState(U, \"\"), window.history.pushState(t, \"\", s), window.history.pushState(H, \"\"), await C(-1)) : this.hasPrev ? (window.history.replaceState(U, \"\"), window.history.pushState(t, \"\", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(H, \"\"), await C(-1)) : (window.history.replaceState(it, \"\"), window.history.pushState(t, \"\", s)), window.addEventListener(\"popstate\", this.onPopState);\n }\n /**\n * Current query parameters.\n * @see URL.search\n * @example\n * \"\", \"?\", \"?a=1\"\n */\n get search() {\n return (this.navigator.current.params || {}).search || \"\";\n }\n /**\n * Current history item state.\n */\n get state() {\n return (this.navigator.current.params || {}).state;\n }\n}\nfunction Je(e) {\n e || (e = {});\n const { href: t, hash: s } = window.location;\n let n = N(\n e.hashMode === null ? t : s.includes(\"?\") ? s.slice(1) : `?${s.slice(1)}`\n );\n const r = e.base ? Lt(e.base) : void 0;\n if (r) {\n if (!n.startsWith(r))\n throw f(\n Xt,\n `Path \"${n}\" expected to be starting with \"${r}\"`\n );\n n = n.slice(r.length);\n }\n return new $t([n], 0, e);\n}\nfunction Ts(e) {\n const t = e.match(/#(.+)/);\n return t ? t[1] : null;\n}\nfunction Qe(e, t) {\n if (kt()) {\n const s = sessionStorage.getItem(e);\n if (s)\n try {\n const { index: n, history: r } = JSON.parse(s);\n return new $t(\n r,\n n,\n t\n );\n } catch (n) {\n console.error(\"Unable to restore hash navigator state.\", n);\n }\n }\n return Je(t);\n}\nfunction Rs(e, t) {\n const s = Qe(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({\n index: s.index,\n history: s.history\n }));\n return s.on(\"change\", n), n(), s;\n}\nexport {\n le as BackButton,\n ze as BasicNavigator,\n Pe as BiometryManager,\n $t as BrowserNavigator,\n Ce as ClosingBehavior,\n Ie as CloudStorage,\n Xt as ERR_INVALID_PATH_BASE,\n Jt as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,\n zt as ERR_METHOD_PARAMETER_UNSUPPORTED,\n jt as ERR_METHOD_UNSUPPORTED,\n Zt as ERR_NAVIGATION_HISTORY_EMPTY,\n Kt as ERR_NAVIGATION_INDEX_INVALID,\n Ke as ERR_NAVIGATION_ITEM_INVALID,\n ct as ERR_PARSE,\n Xe as ERR_SSR_INIT,\n Qt as ERR_TIMED_OUT,\n Yt as ERR_UNEXPECTED_TYPE,\n Ft as ERR_UNKNOWN_ENV,\n T as EventEmitter,\n qe as HapticFeedback,\n ke as InitData,\n Ne as Invoice,\n De as MainButton,\n Le as MiniApp,\n Be as Popup,\n We as QRScanner,\n D as SDKError,\n Ue as SettingsButton,\n He as ThemeParams,\n Oe as Utils,\n Ge as Viewport,\n Ae as array,\n ms as bindMiniAppCSSVars,\n ys as bindThemeParamsCSSVars,\n vs as bindViewportCSSVars,\n w as boolean,\n gt as captureSameReq,\n z as classNames,\n oe as compareVersions,\n Je as createBrowserNavigatorFromLocation,\n he as createPostEvent,\n I as createSafeURL,\n Et as date,\n Ts as getHash,\n Lt as getPathname,\n ss as initBackButton,\n ns as initBiometryManager,\n rs as initClosingBehavior,\n is as initCloudStorage,\n os as initHapticFeedback,\n as as initInitData,\n hs as initInvoice,\n ps as initMainButton,\n us as initMiniApp,\n Rs as initNavigator,\n ls as initPopup,\n ds as initQRScanner,\n _s as initSettingsButton,\n fs as initThemeParams,\n bs as initUtils,\n ws as initViewport,\n Es as initWeb,\n S as invokeCustomMethod,\n yt as isColorDark,\n _t as isIframe,\n kt as isPageReload,\n Q as isRGB,\n pe as isRGBShort,\n je as isSDKError,\n Cs as isSDKErrorOfType,\n xs as isSSR,\n Ps as isTMA,\n g as json,\n es as mergeClassNames,\n Ss as mockTelegramEnv,\n y as number,\n L as off,\n b as on,\n cs as parseInitData,\n X as parseLaunchParams,\n Mt as parseThemeParams,\n R as postEvent,\n d as request,\n Se as requestBiometryInfo,\n gs as requestThemeParams,\n Vt as requestViewport,\n ve as retrieveLaunchParams,\n _e as rgb,\n K as searchParams,\n ye as serializeLaunchParams,\n It as serializeThemeParams,\n m as setCSSVar,\n Ze as setDebug,\n ts as setTargetOrigin,\n p as string,\n Ht as subscribe,\n v as supports,\n ce as targetOrigin,\n mt as toRGB,\n at as unsubscribe,\n N as urlToPath,\n wt as withTimeout\n};\n//# sourceMappingURL=index.js.map\n"],"names":["signData","processSign","sign","value"],"mappings":"AAEgB,SAAA,UACd,OACA,YACe;AACR,SAAA,WAAW,OAAO,YAAY;AACvC;ACDA,SAAS,gBAAgB,QAAoE;AAC3F,QAAM,SAAiC,CAAA;AACvC,aAAW,OAAO,QAAQ;AAClB,UAAA,IAAI,OAAO,GAAG;AACpB,QAAI,MAAM,QAAW;AACnB,aAAO,GAAG,IAAI;AAAA,IAChB;AAAA,EACF;AACO,SAAA;AACT;AAMA,SAAS,cAAc,MAA4C;AAC1D,SAAA,OACH,KAAK,UAAU;AAAA,IACf,0BAA0B,KAAK;AAAA,IAC/B,oBAAoB,KAAK;AAAA,IACzB,YAAY,KAAK;AAAA,IACjB,IAAI,KAAK;AAAA,IACT,QAAQ,KAAK;AAAA,IACb,YAAY,KAAK;AAAA,IACjB,eAAe,KAAK;AAAA,IACpB,WAAW,KAAK;AAAA,IAChB,WAAW,KAAK;AAAA,IAChB,UAAU,KAAK;AAAA,EAAA,CAChB,IACC;AACN;AAEO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA6C;ADzC7B;AC0Cd,SAAO,IAAI;AA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