@tma.js/init-data-node 1.3.0 → 1.3.1

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.
@@ -114,14 +114,14 @@ class D extends Error {
114
114
  super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, D.prototype);
115
115
  }
116
116
  }
117
- function f(e, t, s) {
117
+ function g(e, t, s) {
118
118
  return new D(e, t, s);
119
119
  }
120
120
  const Zt = "ERR_UNEXPECTED_TYPE", ht = "ERR_PARSE";
121
121
  function E() {
122
- return f(Zt, "Value has unexpected type");
122
+ return g(Zt, "Value has unexpected type");
123
123
  }
124
- class V {
124
+ class M {
125
125
  constructor(t, s, n) {
126
126
  this.parser = t, this.isOptional = s, this.type = n;
127
127
  }
@@ -136,7 +136,7 @@ class V {
136
136
  try {
137
137
  return this.parser(t);
138
138
  } catch (s) {
139
- throw f(
139
+ throw g(
140
140
  ht,
141
141
  `Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
142
142
  s
@@ -147,10 +147,10 @@ class V {
147
147
  return this.isOptional = true, this;
148
148
  }
149
149
  }
150
- function P(e, t) {
151
- return () => new V(e, false, t);
150
+ function x(e, t) {
151
+ return () => new M(e, false, t);
152
152
  }
153
- const b = P((e) => {
153
+ const w = x((e) => {
154
154
  if (typeof e == "boolean")
155
155
  return e;
156
156
  const t = String(e);
@@ -177,7 +177,7 @@ function pt(e, t) {
177
177
  const a = o(t(i));
178
178
  a !== void 0 && (s[n] = a);
179
179
  } catch (a) {
180
- throw f(ht, `Unable to parse field "${n}"`, a);
180
+ throw g(ht, `Unable to parse field "${n}"`, a);
181
181
  }
182
182
  }
183
183
  return s;
@@ -189,12 +189,12 @@ function Q(e) {
189
189
  return t;
190
190
  }
191
191
  function d(e, t) {
192
- return new V((s) => {
192
+ return new M((s) => {
193
193
  const n = Q(s);
194
194
  return pt(e, (r) => n[r]);
195
195
  }, false, t);
196
196
  }
197
- const y = P((e) => {
197
+ const y = x((e) => {
198
198
  if (typeof e == "number")
199
199
  return e;
200
200
  if (typeof e == "string") {
@@ -228,11 +228,11 @@ function ut(e) {
228
228
  return n + (i.length === 1 ? "0" : "") + i;
229
229
  }, "#");
230
230
  }
231
- const h = P((e) => {
231
+ const h = x((e) => {
232
232
  if (typeof e == "string" || typeof e == "number")
233
233
  return e.toString();
234
234
  throw E();
235
- }, "string"), lt = P((e) => ut(h().parse(e)), "rgb");
235
+ }, "string"), lt = x((e) => ut(h().parse(e)), "rgb");
236
236
  ({
237
237
  clipboard_text_received: d({
238
238
  req_id: h(),
@@ -262,14 +262,14 @@ const h = P((e) => {
262
262
  viewport_changed: d({
263
263
  height: y(),
264
264
  width: (e) => e == null ? window.innerWidth : y().parse(e),
265
- is_state_stable: b(),
266
- is_expanded: b()
265
+ is_state_stable: w(),
266
+ is_expanded: w()
267
267
  }),
268
268
  write_access_requested: d({ status: h() })
269
269
  });
270
- const Pt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
270
+ const xt = x((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
271
271
  function X(e, t) {
272
- return new V((s) => {
272
+ return new M((s) => {
273
273
  if (typeof s != "string" && !(s instanceof URLSearchParams))
274
274
  throw E();
275
275
  const n = typeof s == "string" ? new URLSearchParams(s) : s;
@@ -290,11 +290,11 @@ const de = d({
290
290
  username: h().optional()
291
291
  }, "Chat").optional(), rt = d({
292
292
  addedToAttachmentMenu: {
293
- type: b().optional(),
293
+ type: w().optional(),
294
294
  from: "added_to_attachment_menu"
295
295
  },
296
296
  allowsWriteToPm: {
297
- type: b().optional(),
297
+ type: w().optional(),
298
298
  from: "allows_write_to_pm"
299
299
  },
300
300
  firstName: {
@@ -303,11 +303,11 @@ const de = d({
303
303
  },
304
304
  id: y(),
305
305
  isBot: {
306
- type: b().optional(),
306
+ type: w().optional(),
307
307
  from: "is_bot"
308
308
  },
309
309
  isPremium: {
310
- type: b().optional(),
310
+ type: w().optional(),
311
311
  from: "is_premium"
312
312
  },
313
313
  languageCode: {
@@ -324,10 +324,10 @@ const de = d({
324
324
  },
325
325
  username: h().optional()
326
326
  }, "User").optional();
327
- function xt() {
327
+ function Pt() {
328
328
  return X({
329
329
  authDate: {
330
- type: Pt(),
330
+ type: xt(),
331
331
  from: "auth_date"
332
332
  },
333
333
  canSendAfter: {
@@ -357,7 +357,7 @@ function xt() {
357
357
  }, "InitData");
358
358
  }
359
359
  function as(e) {
360
- return xt().parse(e);
360
+ return Pt().parse(e);
361
361
  }
362
362
  export {
363
363
  signData as a,
@@ -366,4 +366,4 @@ export {
366
366
  sign as s,
367
367
  validate as v
368
368
  };
369
- //# sourceMappingURL=index-uL7oQrpu.js.map
369
+ //# sourceMappingURL=index-Brzmngqx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Brzmngqx.js","sources":["../../src/initDataToSearchParams.ts","../../src/sign.ts","../../src/signData.ts","../../src/validate.ts","../../../sdk/dist/index.js"],"sourcesContent":["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 { SignData, SignDataAsyncFn, SignDataSyncFn } from './types.js';\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 * @returns Signed init data presented as query parameters.\n */\nexport function sign(data: SignData, key: string, authDate: Date, signData: SignDataSyncFn): 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 * @returns Signed init data presented as query parameters.\n */\nexport function sign(\n data: SignData,\n key: string,\n authDate: Date,\n signData: SignDataAsyncFn,\n): Promise<string>;\n\nexport function sign(\n data: SignData,\n key: string,\n authDate: Date,\n signData: SignDataSyncFn | SignDataAsyncFn,\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);\n return typeof sign === 'string' ? processSign(sign) : sign.then(processSign);\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 * @returns Data sign.\n */\nexport function signData(\n data: string,\n key: string,\n createHmac: (data: string, key: string | Buffer) => Buffer,\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 * @returns Data sign.\n */\nexport function signData(\n data: string,\n key: string,\n createHmac: (data: string, key: string | Buffer) => Promise<Buffer>,\n): Promise<string>;\n\nexport function signData(\n data: string,\n key: string,\n createHmac: (data: string, key: string | Buffer) => (Buffer | Promise<Buffer>),\n): string | Promise<string> {\n const keyHmac = createHmac(key, 'WebAppData');\n\n return keyHmac instanceof Promise\n ? keyHmac\n .then(v => createHmac(data, v))\n .then(v => v.toString('hex'))\n : (createHmac(data, keyHmac) as Buffer).toString('hex');\n}\n","import type { InitData, InitDataParsed } from '@tma.js/sdk';\n\nimport { initDataToSearchParams } from './initDataToSearchParams.js';\nimport type { SignDataAsyncFn, SignDataSyncFn } from './types.js';\n\nexport interface ValidateOptions {\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: string,\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: string,\n signData: SignDataAsyncFn,\n options?: ValidateOptions,\n): Promise<void>;\n\nexport function validate(\n value: InitData | InitDataParsed | string | URLSearchParams,\n token: string,\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);\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 as string));\n}\n","var Ut = Object.defineProperty;\nvar Ot = (e, t, s) => t in e ? Ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;\nvar c = (e, t, s) => Ot(e, typeof t != \"symbol\" ? t + \"\" : t, s);\nfunction at(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 ct(e) {\n const t = L(), { count: s } = t;\n t.unsubscribe(e), s && !t.count && ae();\n}\nfunction Ht(e) {\n return L().subscribe(e), () => ct(e);\n}\nclass Gt {\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 Gt(\"SDK\", {\n bgColor: \"forestgreen\",\n textColor: \"white\"\n});\nlet H = !1;\nconst nt = ({ name: e, payload: t }) => {\n F.log(\"Event received:\", t ? { name: e, payload: t } : { name: e });\n};\nfunction Ye(e) {\n H !== e && (H = e, e ? Ht(nt) : ct(nt));\n}\nfunction jt(...e) {\n H && 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];\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 g(e, t, s) {\n return new D(e, t, s);\n}\nconst zt = \"ERR_METHOD_UNSUPPORTED\", Ft = \"ERR_METHOD_PARAMETER_UNSUPPORTED\", Jt = \"ERR_UNKNOWN_ENV\", Qt = \"ERR_INVOKE_CUSTOM_METHOD_RESPONSE\", Yt = \"ERR_TIMED_OUT\", Zt = \"ERR_UNEXPECTED_TYPE\", ht = \"ERR_PARSE\", Kt = \"ERR_NAVIGATION_LIST_EMPTY\", Xt = \"ERR_NAVIGATION_CURSOR_INVALID\", Ze = \"ERR_NAVIGATION_ITEM_INVALID\", Ke = \"ERR_SSR_INIT\", te = \"ERR_INVALID_PATH_BASE\";\nfunction E() {\n return g(Zt, \"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 g(\n ht,\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 pt(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 g(ht, `Unable to parse field \"${n}\"`, a);\n }\n }\n return s;\n}\nfunction Q(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 d(e, t) {\n return new M((s) => {\n const n = Q(s);\n return pt(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\");\nfunction Y(e) {\n return /^#[\\da-f]{6}$/i.test(e);\n}\nfunction ee(e) {\n return /^#[\\da-f]{3}$/i.test(e);\n}\nfunction ut(e) {\n const t = e.replace(/\\s/g, \"\").toLowerCase();\n if (Y(t))\n return t;\n if (ee(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}\nconst h = x((e) => {\n if (typeof e == \"string\" || typeof e == \"number\")\n return e.toString();\n throw E();\n}, \"string\"), lt = x((e) => ut(h().parse(e)), \"rgb\");\nfunction dt(e) {\n return d({\n eventType: h(),\n eventData: (t) => t\n }).parse(e);\n}\nfunction se() {\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 ne() {\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 re = {\n clipboard_text_received: d({\n req_id: h(),\n data: (e) => e === null ? e : h().optional().parse(e)\n }),\n custom_method_invoked: d({\n req_id: h(),\n result: (e) => e,\n error: h().optional()\n }),\n invoice_closed: d({ slug: h(), status: h() }),\n phone_requested: d({ status: h() }),\n popup_closed: {\n parse(e) {\n return d({\n button_id: (t) => t == null ? void 0 : h().parse(t)\n }).parse(e ?? {});\n }\n },\n qr_text_received: d({ data: h().optional() }),\n theme_changed: d({\n theme_params: (e) => {\n const t = lt().optional();\n return Object.entries(Q(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});\n }\n }),\n viewport_changed: d({\n height: y(),\n width: (e) => e == null ? window.innerWidth : y().parse(e),\n is_state_stable: w(),\n is_expanded: w()\n }),\n write_access_requested: d({ status: h() })\n};\nfunction ie() {\n const e = new T(), t = new T();\n t.subscribe((n) => {\n e.emit(\"event\", { name: n.event, payload: n.args[0] });\n }), ne();\n const [, s] = J(\n // Don't forget to remove created handlers.\n se,\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 = dt(n.data);\n } catch {\n return;\n }\n const { eventType: i, eventData: o } = r, a = re[i];\n try {\n const p = a ? a.parse(o) : o;\n t.emit(...p ? [i, p] : [i]);\n } catch (p) {\n F.error(\n `An error occurred processing the \"${i}\" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,\n r,\n p\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 [oe, ae] = at(\n (e) => {\n const [t, s] = ie(), 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 L() {\n return oe()[0];\n}\nfunction V(e, t) {\n L().off(e, t);\n}\nfunction b(e, t, s) {\n return L().on(e, t, s);\n}\nfunction I(e) {\n return typeof e == \"object\" && e !== null && !Array.isArray(e);\n}\nfunction ce(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 f(e, t) {\n return ce(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 f(\"6.4\", s);\n if (t === \"try_browser\")\n return f(\"7.6\", s);\n }\n if (e === \"web_app_set_header_color\" && t === \"color\")\n return f(\"6.9\", s);\n if (e === \"web_app_close\" && t === \"return_back\")\n return f(\"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 f(\"6.1\", t);\n case \"web_app_open_popup\":\n return f(\"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 f(\"6.4\", t);\n case \"web_app_switch_inline_query\":\n return f(\"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 f(\"6.9\", t);\n case \"web_app_setup_settings_button\":\n return f(\"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 f(\"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 _t(e) {\n return \"external\" in e && I(e.external) && \"notify\" in e.external && typeof e.external.notify == \"function\";\n}\nfunction ft(e) {\n return \"TelegramWebviewProxy\" in e && I(e.TelegramWebviewProxy) && \"postEvent\" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == \"function\";\n}\nfunction gt() {\n try {\n return window.self !== window.top;\n } catch {\n return !0;\n }\n}\nlet bt = \"https://web.telegram.org\";\nfunction Xe(e) {\n bt = e;\n}\nfunction he() {\n return bt;\n}\nfunction R(e, t, s) {\n let n = {}, r;\n t === void 0 && s === void 0 ? n = {} : t !== void 0 && s !== void 0 ? (n = s, r = t) : t !== void 0 && (\"targetOrigin\" in t ? n = t : r = t);\n const { targetOrigin: i = he() } = n;\n if (jt(\"Posting event:\", r ? { event: e, data: r } : { event: e }), gt()) {\n window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);\n return;\n }\n if (_t(window)) {\n window.external.notify(JSON.stringify({ eventType: e, eventData: r }));\n return;\n }\n if (ft(window)) {\n window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));\n return;\n }\n throw g(\n Jt,\n \"Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside of Telegram application environment.\"\n );\n}\nfunction pe(e) {\n return (t, s) => {\n if (!v(t, e))\n throw g(zt, `Method \"${t}\" is unsupported in Mini Apps version ${e}`);\n if (I(s)) {\n let n;\n if (t === \"web_app_open_link\" && \"try_instant_view\" in s ? n = \"try_instant_view\" : t === \"web_app_set_header_color\" && \"color\" in s && (n = \"color\"), n && !v(t, n, e))\n throw g(\n Ft,\n `Parameter \"${n}\" of \"${t}\" method is unsupported in Mini Apps version ${e}`\n );\n }\n return R(t, s);\n };\n}\nfunction wt(e) {\n return ({ req_id: t }) => t === e;\n}\nfunction mt(e) {\n return g(Yt, `Timeout reached: ${e}ms`);\n}\nfunction yt(e, t) {\n return Promise.race([\n typeof e == \"function\" ? e() : e,\n new Promise((s, n) => {\n setTimeout(() => {\n n(mt(t));\n }, t);\n })\n ]);\n}\nasync function _(e) {\n let t;\n const s = new Promise((a) => {\n t = a;\n }), { event: n, capture: r, timeout: i } = e, [, o] = J(\n ...(Array.isArray(n) ? n : [n]).map(\n (a) => b(a, (p) => (!r || r(p)) && t(p))\n )\n );\n try {\n return (e.postEvent || R)(e.method, e.params), await (i ? yt(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 _({\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: wt(s)\n });\n if (i)\n throw g(Qt, i);\n return r;\n}\nfunction z(...e) {\n return e.map((t) => {\n if (typeof t == \"string\")\n return t;\n if (I(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 ts(...e) {\n return e.reduce((t, s) => (I(s) && Object.entries(s).forEach(([n, r]) => {\n const i = z(t[n], r);\n i.length && (t[n] = i);\n }), t), {});\n}\nfunction vt(e) {\n const t = ut(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 Z {\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 Et(e, t) {\n return (s) => v(t[s], e);\n}\nclass K extends Z {\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 = Et(n, r);\n }\n}\nclass le extends K {\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\" ? V(\"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 xt = x((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), \"Date\");\nfunction X(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 pt(e, (r) => {\n const i = n.get(r);\n return i === null ? void 0 : i;\n });\n }, !1, t);\n}\nconst de = d({\n id: y(),\n type: h(),\n title: h(),\n photoUrl: {\n type: h().optional(),\n from: \"photo_url\"\n },\n username: h().optional()\n}, \"Chat\").optional(), rt = d({\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: h(),\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: h().optional(),\n from: \"language_code\"\n },\n lastName: {\n type: h().optional(),\n from: \"last_name\"\n },\n photoUrl: {\n type: h().optional(),\n from: \"photo_url\"\n },\n username: h().optional()\n}, \"User\").optional();\nfunction Pt() {\n return X({\n authDate: {\n type: xt(),\n from: \"auth_date\"\n },\n canSendAfter: {\n type: y().optional(),\n from: \"can_send_after\"\n },\n chat: de,\n chatInstance: {\n type: h().optional(),\n from: \"chat_instance\"\n },\n chatType: {\n type: h().optional(),\n from: \"chat_type\"\n },\n hash: h(),\n queryId: {\n type: h().optional(),\n from: \"query_id\"\n },\n receiver: rt,\n startParam: {\n type: h().optional(),\n from: \"start_param\"\n },\n user: rt\n }, \"InitData\");\n}\nfunction _e(e) {\n return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());\n}\nfunction fe(e) {\n return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);\n}\nconst St = x(\n (e) => {\n const t = lt().optional();\n return Object.entries(Q(e)).reduce((s, [n, r]) => (s[_e(n)] = t.parse(r), s), {});\n },\n \"ThemeParams\"\n);\nfunction tt(e) {\n return X({\n botInline: {\n type: w().optional(),\n from: \"tgWebAppBotInline\"\n },\n initData: {\n type: Pt().optional(),\n from: \"tgWebAppData\"\n },\n initDataRaw: {\n type: h().optional(),\n from: \"tgWebAppData\"\n },\n platform: {\n type: h(),\n from: \"tgWebAppPlatform\"\n },\n showSettings: {\n type: w().optional(),\n from: \"tgWebAppShowSettings\"\n },\n startParam: {\n type: h().optional(),\n from: \"tgWebAppStartParam\"\n },\n themeParams: {\n type: St(),\n from: \"tgWebAppThemeParams\"\n },\n version: {\n type: h(),\n from: \"tgWebAppVersion\"\n }\n }).parse(e);\n}\nfunction Ct(e) {\n return tt(\n e.replace(/^[^?#]*[?#]/, \"\").replace(/[?#]/g, \"&\")\n );\n}\nfunction ge() {\n return Ct(window.location.href);\n}\nfunction Tt() {\n return performance.getEntriesByType(\"navigation\")[0];\n}\nfunction be() {\n const e = Tt();\n if (!e)\n throw new Error(\"Unable to get first navigation entry.\");\n return Ct(e.name);\n}\nfunction Rt(e) {\n return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;\n}\nfunction At(e, t) {\n sessionStorage.setItem(Rt(e), JSON.stringify(t));\n}\nfunction It(e) {\n const t = sessionStorage.getItem(Rt(e));\n try {\n return t ? JSON.parse(t) : void 0;\n } catch {\n }\n}\nfunction we() {\n return tt(It(\"launchParams\") || \"\");\n}\nfunction qt(e) {\n return JSON.stringify(\n Object.fromEntries(\n Object.entries(e).map(([t, s]) => [fe(t), s])\n )\n );\n}\nfunction me(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, p = new URLSearchParams();\n return p.set(\"tgWebAppPlatform\", n), p.set(\"tgWebAppThemeParams\", qt(s)), p.set(\"tgWebAppVersion\", r), t && p.set(\"tgWebAppData\", t), o && p.set(\"tgWebAppStartParam\", o), typeof i == \"boolean\" && p.set(\"tgWebAppShowSettings\", i ? \"1\" : \"0\"), typeof a == \"boolean\" && p.set(\"tgWebAppBotInline\", a ? \"1\" : \"0\"), p.toString();\n}\nfunction kt(e) {\n At(\"launchParams\", me(e));\n}\nfunction ye() {\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 ge,\n // Then, try using the lower level API - window.performance.\n be,\n // Finally, try to extract launch parameters from the session storage.\n we\n ])\n try {\n const t = e();\n return kt(t), t;\n } catch {\n }\n throw new Error(\"Unable to retrieve launch parameters from any known source.\");\n}\nfunction Nt() {\n const e = Tt();\n return !!(e && e.type === \"reload\");\n}\nfunction ve() {\n let e = 0;\n return () => (e += 1).toString();\n}\nconst [Ee] = at(ve);\nfunction l(e, t) {\n return () => {\n const s = ye(), n = {\n ...s,\n postEvent: pe(s.version),\n createRequestId: Ee()\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: Nt() ? It(e) : void 0,\n addCleanup: r\n }), p = (u) => (o || r(\n u.on(\"change\", (Wt) => {\n At(e, Wt);\n })\n ), u);\n return [\n a instanceof Promise ? a.then(p) : p(a),\n i\n ];\n };\n}\nconst es = l(\"backButton\", ({\n postEvent: e,\n version: t,\n state: s = { isVisible: !1 }\n}) => new le(s.isVisible, t, e));\nclass q extends K {\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 Dt(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 xe extends q {\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 = _({\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 = _({\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 = Dt(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 _({\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 Pe(e) {\n return Dt(\n await _({\n ...e || {},\n method: \"web_app_biometry_get_info\",\n event: \"biometry_info_received\"\n })\n );\n}\nconst ss = l(\n \"biometryManager\",\n async ({ postEvent: e, version: t, state: s }) => new xe({\n ...s || v(\"web_app_biometry_get_info\", t) ? s || await Pe({ 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 et 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}\nclass Se extends et {\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 ns = l(\n \"closingBehavior\",\n ({\n postEvent: e,\n state: t = { isConfirmationNeeded: !1 }\n }) => new Se(t.isConfirmationNeeded, e)\n);\nclass st {\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 = Et(t, s);\n }\n}\nfunction Ce(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 Te extends M {\n constructor(s, n, r) {\n super(Ce, 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 Re(e) {\n return new Te((t) => t, !1, e);\n}\nfunction it(e, t) {\n return Object.fromEntries(e.map((s) => [s, t]));\n}\nclass Ae extends st {\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 Re().of(h()).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 it(n, \"\");\n const r = await S(\n \"getStorageValues\",\n { keys: n },\n this.createRequestId(),\n { ...s, postEvent: this.postEvent }\n ), i = d(it(n, h()), \"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 rs = l(\n ({ createRequestId: e, postEvent: t, version: s }) => new Ae(s, e, t)\n);\nclass Ie extends st {\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 is = l(\n ({ version: e, postEvent: t }) => new Ie(e, t)\n);\nclass qe {\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 os = l(\n ({ initData: e }) => e ? new qe(e) : void 0\n);\nfunction as(e) {\n return Pt().parse(e);\n}\nclass ke extends q {\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 _({\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 cs = l(\n ({ version: e, postEvent: t }) => new ke(!1, e, t)\n);\nclass Ne extends Z {\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\" ? V(\"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 hs = 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 Ne({ ...s, postEvent: e })\n);\nfunction De() {\n return X({\n contact: d({\n userId: {\n type: y(),\n from: \"user_id\"\n },\n phoneNumber: {\n type: h(),\n from: \"phone_number\"\n },\n firstName: {\n type: h(),\n from: \"first_name\"\n },\n lastName: {\n type: h().optional(),\n from: \"last_name\"\n }\n }),\n authDate: {\n type: xt(),\n from: \"auth_date\"\n },\n hash: h()\n }, \"RequestedContact\");\n}\nfunction Mt(e, t) {\n return (s) => {\n const [n, r] = t[s];\n return v(n, r, e);\n };\n}\nfunction Me(e) {\n return new Promise((t) => {\n setTimeout(t, e);\n });\n}\nclass Le extends q {\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 = (p) => a(p) ? p !== \"switchInlineQuery\" || i : !1, this.supportsParam = Mt(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 De().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 */\n close() {\n this.postEvent(\"web_app_close\");\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 current Mini App background color is recognized as dark.\n */\n get isDark() {\n return vt(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 yt(async () => {\n for (; Date.now() < r; ) {\n try {\n return await this.getRequestedContact();\n } catch {\n }\n await Me(i), i += 50;\n }\n throw mt(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 = _({\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 = _({\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\", Y(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 ps = 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 Ve(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 p = i.type || \"default\";\n throw new Error(`Button text with type \"${p}\" 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 $e extends q {\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 _({\n event: \"popup_closed\",\n method: \"web_app_open_popup\",\n postEvent: this.postEvent,\n params: Ve(t)\n });\n return s;\n } finally {\n this.isOpened = !1;\n }\n }\n}\nconst us = l(\n ({ postEvent: e, version: t }) => new $e(!1, t, e)\n);\nclass Be extends q {\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 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 in case, QR 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(\"QR 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 _({\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 } catch (r) {\n throw this.isOpened = !1, r;\n }\n }\n}\nconst ls = l(\n ({ version: e, postEvent: t }) => new Be(!1, e, t)\n);\nclass We extends K {\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\" ? V(\"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 ds = l(\n \"settingsButton\",\n ({\n version: e,\n postEvent: t,\n state: s = { isVisible: !1 }\n }) => new We(s.isVisible, e, t)\n);\nfunction Lt(e) {\n return St().parse(e);\n}\nclass Ue extends et {\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 || vt(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(Lt(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 _s = l(\n \"themeParams\",\n ({ themeParams: e, state: t = e, addCleanup: s }) => {\n const n = new Ue(t);\n return s(n.listen()), n;\n }\n);\nfunction fs(e = {}) {\n return _({\n ...e,\n method: \"web_app_request_theme\",\n event: \"theme_changed\"\n }).then(Lt);\n}\nclass Oe extends st {\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 = Mt(s, {\n \"openLink.tryInstantView\": [\"web_app_open_link\", \"try_instant_view\"]\n });\n }\n /**\n * Opens a link in an external browser. The Mini App will not be closed.\n *\n * Note that this method can be called only in response to the user\n * interaction with the Mini App interface (e.g. click inside the Mini App\n * or on the main button).\n * @param url - URL to be opened.\n * @param tryInstantView\n */\n openLink(s, n) {\n const r = new URL(s, window.location.href).toString();\n if (!v(\"web_app_open_link\", this.version)) {\n window.open(r, \"_blank\");\n return;\n }\n this.postEvent(\"web_app_open_link\", {\n url: r,\n ...typeof n == \"boolean\" ? { try_instant_view: n } : {}\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 _({\n method: \"web_app_read_text_from_clipboard\",\n event: \"clipboard_text_received\",\n postEvent: this.postEvent,\n params: { req_id: s },\n capture: wt(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()\n );\n }\n}\nconst gs = 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 _({\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 He extends et {\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 bs = 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 p = new He({\n postEvent: s,\n height: i,\n width: o,\n stableHeight: a,\n isExpanded: r\n });\n return n(p.listen()), p;\n }\n);\nfunction m(e, t) {\n document.documentElement.style.setProperty(e, t);\n}\nfunction ws(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 (Y(a))\n m(n, a);\n else {\n const { bgColor: p, secondaryBgColor: u } = t;\n a === \"bg_color\" && p ? m(n, p) : 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 ms(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 ys(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`), p = [\n e.on(\"change:height\", i),\n e.on(\"change:width\", o),\n e.on(\"change:stableHeight\", a)\n ];\n return i(), o(), a(), () => p.forEach((u) => u());\n}\nfunction vs(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 Es() {\n return typeof window > \"u\";\n}\nasync function xs() {\n if (ft(window))\n return !0;\n try {\n return await _({ method: \"web_app_request_theme\", event: \"theme_changed\", timeout: 100 }), !0;\n } catch {\n return !1;\n }\n}\nfunction Ps(e) {\n const t = typeof e == \"string\" ? tt(e) : e;\n kt(t);\n function s(r) {\n if (typeof r == \"string\")\n try {\n const { eventType: i } = dt(r);\n i === \"web_app_request_theme\" && j(\"theme_changed\", {\n theme_params: JSON.parse(qt(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 (gt()) {\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 (_t(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 Ge(e) {\n return e instanceof D;\n}\nfunction Ss(e, t) {\n return Ge(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 je {\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 g(Kt, \"History should not be empty.\");\n if (s < 0 || s >= t.length)\n throw g(\n Xt,\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, V(\"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 A(e, t) {\n return e.startsWith(t) ? e : `${t}${e}`;\n}\nfunction k(e) {\n return new URL(\n typeof e == \"string\" ? e : `${e.pathname || \"\"}${A(e.search || \"\", \"?\")}${A(e.hash || \"\", \"#\")}`,\n \"http://a\"\n );\n}\nfunction N(e) {\n const t = typeof e == \"string\" ? e.startsWith(\"/\") : !!(e.pathname && e.pathname.startsWith(\"/\")), s = k(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 ze() {\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 $t(e) {\n return k(e).pathname;\n}\nconst ot = 0, U = 1, O = 2;\nclass Bt {\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 === ot ? window.history.forward() : t === U && this.back(), t === O && 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 je(\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 = $t(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 = k(t);\n return this.hashMode && (s = k(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 ze(), this.hasPrev && this.hasNext ? (window.history.replaceState(U, \"\"), window.history.pushState(t, \"\", s), window.history.pushState(O, \"\"), await C(-1)) : this.hasPrev ? (window.history.replaceState(U, \"\"), window.history.pushState(t, \"\", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(O, \"\"), await C(-1)) : (window.history.replaceState(ot, \"\"), 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 Fe(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 ? $t(e.base) : void 0;\n if (r) {\n if (!n.startsWith(r))\n throw g(\n te,\n `Path \"${n}\" expected to be starting with \"${r}\"`\n );\n n = n.slice(r.length);\n }\n return new Bt([n], 0, e);\n}\nfunction Cs(e) {\n const t = e.match(/#(.+)/);\n return t ? t[1] : null;\n}\nfunction Je(e, t) {\n if (Nt()) {\n const s = sessionStorage.getItem(e);\n if (s)\n try {\n const { index: n, history: r } = JSON.parse(s);\n return new Bt(\n r,\n n,\n t\n );\n } catch (n) {\n console.error(\"Unable to restore hash navigator state.\", n);\n }\n }\n return Fe(t);\n}\nfunction Ts(e, t) {\n const s = Je(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 je as BasicNavigator,\n xe as BiometryManager,\n Bt as BrowserNavigator,\n Se as ClosingBehavior,\n Ae as CloudStorage,\n te as ERR_INVALID_PATH_BASE,\n Qt as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,\n Ft as ERR_METHOD_PARAMETER_UNSUPPORTED,\n zt as ERR_METHOD_UNSUPPORTED,\n Kt as ERR_NAVIGATION_HISTORY_EMPTY,\n Xt as ERR_NAVIGATION_INDEX_INVALID,\n Ze as ERR_NAVIGATION_ITEM_INVALID,\n ht as ERR_PARSE,\n Ke as ERR_SSR_INIT,\n Yt as ERR_TIMED_OUT,\n Zt as ERR_UNEXPECTED_TYPE,\n Jt as ERR_UNKNOWN_ENV,\n T as EventEmitter,\n Ie as HapticFeedback,\n qe as InitData,\n ke as Invoice,\n Ne as MainButton,\n Le as MiniApp,\n $e as Popup,\n Be as QRScanner,\n D as SDKError,\n We as SettingsButton,\n Ue as ThemeParams,\n Oe as Utils,\n He as Viewport,\n Re as array,\n ws as bindMiniAppCSSVars,\n ms as bindThemeParamsCSSVars,\n ys as bindViewportCSSVars,\n w as boolean,\n wt as captureSameReq,\n z as classNames,\n ce as compareVersions,\n Fe as createBrowserNavigatorFromLocation,\n pe as createPostEvent,\n k as createSafeURL,\n xt as date,\n Cs as getHash,\n $t as getPathname,\n es as initBackButton,\n ss as initBiometryManager,\n ns as initClosingBehavior,\n rs as initCloudStorage,\n is as initHapticFeedback,\n os as initInitData,\n cs as initInvoice,\n hs as initMainButton,\n ps as initMiniApp,\n Ts as initNavigator,\n us as initPopup,\n ls as initQRScanner,\n ds as initSettingsButton,\n _s as initThemeParams,\n gs as initUtils,\n bs as initViewport,\n vs as initWeb,\n S as invokeCustomMethod,\n vt as isColorDark,\n gt as isIframe,\n Nt as isPageReload,\n Y as isRGB,\n ee as isRGBShort,\n Ge as isSDKError,\n Ss as isSDKErrorOfType,\n Es as isSSR,\n xs as isTMA,\n d as json,\n ts as mergeClassNames,\n Ps as mockTelegramEnv,\n y as number,\n V as off,\n b as on,\n as as parseInitData,\n tt as parseLaunchParams,\n Lt as parseThemeParams,\n R as postEvent,\n _ as request,\n Pe as requestBiometryInfo,\n fs as requestThemeParams,\n Vt as requestViewport,\n ye as retrieveLaunchParams,\n lt as rgb,\n X as searchParams,\n me as serializeLaunchParams,\n qt as serializeThemeParams,\n m as setCSSVar,\n Ye as setDebug,\n Xe as setTargetOrigin,\n h as string,\n Ht as subscribe,\n v as supports,\n he as targetOrigin,\n ut as toRGB,\n ct as unsubscribe,\n N as urlToPath,\n yt as withTimeout\n};\n//# sourceMappingURL=index.js.map\n"],"names":["signData","processSign","sign","value"],"mappings":"AAMA,SAAS,gBAAgB,QAAoE;AAC3F,QA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UAAU;AAAA,IACR,MAAM,EAAG,EAAC,SAAU;AAAA,IACpB,MAAM;AAAA,EACP;AAAA,EACD,UAAU;AAAA,IACR,MAAM,EAAG,EAAC,SAAU;AAAA,IACpB,MAAM;AAAA,EACP;AAAA,EACD,UAAU,EAAG,EAAC,SAAU;AAC1B,GAAG,MAAM,EAAE;AACX,SAAS,KAAK;AACZ,SAAO,EAAE;AAAA,IACP,UAAU;AAAA,MACR,MAAM,GAAI;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACD,cAAc;AAAA,MACZ,MAAM,EAAG,EAAC,SAAU;AAAA,MACpB,MAAM;AAAA,IACP;AAAA,IACD,MAAM;AAAA,IACN,cAAc;AAAA,MACZ,MAAM,EAAG,EAAC,SAAU;AAAA,MACpB,MAAM;AAAA,IACP;AAAA,IACD,UAAU;AAAA,MACR,MAAM,EAAG,EAAC,SAAU;AAAA,MACpB,MAAM;AAAA,IACP;AAAA,IACD,MAAM,EAAG;AAAA,IACT,SAAS;AAAA,MACP,MAAM,EAAG,EAAC,SAAU;AAAA,MACpB,MAAM;AAAA,IACP;AAAA,IACD,UAAU;AAAA,IACV,YAAY;AAAA,MACV,MAAM,EAAG,EAAC,SAAU;AAAA,MACpB,MAAM;AAAA,IACP;AAAA,IACD,MAAM;AAAA,EACP,GAAE,UAAU;AACf;AAqmBA,SAAS,GAAG,GAAG;AACb,SAAO,GAAI,EAAC,MAAM,CAAC;AACrB;"}
@@ -115,14 +115,14 @@ class D extends Error {
115
115
  super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, D.prototype);
116
116
  }
117
117
  }
118
- function f(e, t, s) {
118
+ function g(e, t, s) {
119
119
  return new D(e, t, s);
120
120
  }
121
121
  const Zt = "ERR_UNEXPECTED_TYPE", ht = "ERR_PARSE";
122
122
  function E() {
123
- return f(Zt, "Value has unexpected type");
123
+ return g(Zt, "Value has unexpected type");
124
124
  }
125
- class V {
125
+ class M {
126
126
  constructor(t, s, n) {
127
127
  this.parser = t, this.isOptional = s, this.type = n;
128
128
  }
@@ -137,7 +137,7 @@ class V {
137
137
  try {
138
138
  return this.parser(t);
139
139
  } catch (s) {
140
- throw f(
140
+ throw g(
141
141
  ht,
142
142
  `Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
143
143
  s
@@ -148,10 +148,10 @@ class V {
148
148
  return this.isOptional = true, this;
149
149
  }
150
150
  }
151
- function P(e, t) {
152
- return () => new V(e, false, t);
151
+ function x(e, t) {
152
+ return () => new M(e, false, t);
153
153
  }
154
- const b = P((e) => {
154
+ const w = x((e) => {
155
155
  if (typeof e == "boolean")
156
156
  return e;
157
157
  const t = String(e);
@@ -178,7 +178,7 @@ function pt(e, t) {
178
178
  const a = o(t(i));
179
179
  a !== void 0 && (s[n] = a);
180
180
  } catch (a) {
181
- throw f(ht, `Unable to parse field "${n}"`, a);
181
+ throw g(ht, `Unable to parse field "${n}"`, a);
182
182
  }
183
183
  }
184
184
  return s;
@@ -190,12 +190,12 @@ function Q(e) {
190
190
  return t;
191
191
  }
192
192
  function d(e, t) {
193
- return new V((s) => {
193
+ return new M((s) => {
194
194
  const n = Q(s);
195
195
  return pt(e, (r) => n[r]);
196
196
  }, false, t);
197
197
  }
198
- const y = P((e) => {
198
+ const y = x((e) => {
199
199
  if (typeof e == "number")
200
200
  return e;
201
201
  if (typeof e == "string") {
@@ -229,11 +229,11 @@ function ut(e) {
229
229
  return n + (i.length === 1 ? "0" : "") + i;
230
230
  }, "#");
231
231
  }
232
- const h = P((e) => {
232
+ const h = x((e) => {
233
233
  if (typeof e == "string" || typeof e == "number")
234
234
  return e.toString();
235
235
  throw E();
236
- }, "string"), lt = P((e) => ut(h().parse(e)), "rgb");
236
+ }, "string"), lt = x((e) => ut(h().parse(e)), "rgb");
237
237
  ({
238
238
  clipboard_text_received: d({
239
239
  req_id: h(),
@@ -263,14 +263,14 @@ const h = P((e) => {
263
263
  viewport_changed: d({
264
264
  height: y(),
265
265
  width: (e) => e == null ? window.innerWidth : y().parse(e),
266
- is_state_stable: b(),
267
- is_expanded: b()
266
+ is_state_stable: w(),
267
+ is_expanded: w()
268
268
  }),
269
269
  write_access_requested: d({ status: h() })
270
270
  });
271
- const Pt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
271
+ const xt = x((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
272
272
  function X(e, t) {
273
- return new V((s) => {
273
+ return new M((s) => {
274
274
  if (typeof s != "string" && !(s instanceof URLSearchParams))
275
275
  throw E();
276
276
  const n = typeof s == "string" ? new URLSearchParams(s) : s;
@@ -291,11 +291,11 @@ const de = d({
291
291
  username: h().optional()
292
292
  }, "Chat").optional(), rt = d({
293
293
  addedToAttachmentMenu: {
294
- type: b().optional(),
294
+ type: w().optional(),
295
295
  from: "added_to_attachment_menu"
296
296
  },
297
297
  allowsWriteToPm: {
298
- type: b().optional(),
298
+ type: w().optional(),
299
299
  from: "allows_write_to_pm"
300
300
  },
301
301
  firstName: {
@@ -304,11 +304,11 @@ const de = d({
304
304
  },
305
305
  id: y(),
306
306
  isBot: {
307
- type: b().optional(),
307
+ type: w().optional(),
308
308
  from: "is_bot"
309
309
  },
310
310
  isPremium: {
311
- type: b().optional(),
311
+ type: w().optional(),
312
312
  from: "is_premium"
313
313
  },
314
314
  languageCode: {
@@ -325,10 +325,10 @@ const de = d({
325
325
  },
326
326
  username: h().optional()
327
327
  }, "User").optional();
328
- function xt() {
328
+ function Pt() {
329
329
  return X({
330
330
  authDate: {
331
- type: Pt(),
331
+ type: xt(),
332
332
  from: "auth_date"
333
333
  },
334
334
  canSendAfter: {
@@ -358,11 +358,11 @@ function xt() {
358
358
  }, "InitData");
359
359
  }
360
360
  function as(e) {
361
- return xt().parse(e);
361
+ return Pt().parse(e);
362
362
  }
363
363
  exports.as = as;
364
364
  exports.initDataToSearchParams = initDataToSearchParams;
365
365
  exports.sign = sign;
366
366
  exports.signData = signData;
367
367
  exports.validate = validate;
368
- //# sourceMappingURL=index-DihIF0dZ.cjs.map
368
+ //# sourceMappingURL=index-CDcPFeVC.cjs.map