@tma.js/sdk 2.6.1 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dts/bridge/{utils/invokeCustomMethod.d.ts → invokeCustomMethod.d.ts} +2 -2
- package/dist/dts/bridge/methods/createPostEvent.d.ts +3 -2
- package/dist/dts/bridge/methods/postEvent.d.ts +5 -3
- package/dist/dts/bridge/request.d.ts +53 -0
- package/dist/dts/bridge/target-origin.d.ts +8 -3
- package/dist/dts/components/MiniApp/MiniApp.d.ts +3 -2
- package/dist/dts/components/QRScanner/types.d.ts +2 -2
- package/dist/dts/components/Utils/Utils.d.ts +27 -4
- package/dist/dts/env/hasWebviewProxy.d.ts +1 -1
- package/dist/dts/index.d.ts +4 -4
- package/dist/dts/index.low-level.d.ts +3 -3
- package/dist/dts/misc/createCleanup.d.ts +2 -2
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +3 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +499 -514
- package/dist/index.js.map +1 -1
- package/dist/index.low-level.iife.js +3 -1
- package/dist/index.low-level.iife.js.map +1 -1
- package/package.json +1 -1
- package/dist/dts/bridge/utils/request.d.ts +0 -47
- /package/dist/dts/bridge/{utils/captureSameReq.d.ts → captureSameReq.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExecuteWithOptions } from '
|
|
2
|
-
import { CustomMethodName, CustomMethodParams } from '
|
|
1
|
+
import { ExecuteWithOptions } from '../types/index.js';
|
|
2
|
+
import { CustomMethodName, CustomMethodParams } from './methods/types/custom-methods.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Invokes known custom method. Returns method execution result.
|
|
@@ -2,8 +2,9 @@ import { Version } from '../../version/types.js';
|
|
|
2
2
|
import { PostEvent } from './postEvent.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Creates function which checks if specified method and parameters are supported.
|
|
6
|
-
*
|
|
5
|
+
* Creates a function which checks if specified method and parameters are supported.
|
|
6
|
+
*
|
|
7
|
+
* If method or parameters are unsupported, an error will be thrown.
|
|
7
8
|
* @param version - Telegram Mini Apps version.
|
|
8
9
|
* @throws {SDKError} ERR_METHOD_UNSUPPORTED
|
|
9
10
|
* @throws {SDKError} ERR_METHOD_PARAMETER_UNSUPPORTED
|
|
@@ -2,8 +2,10 @@ import { MiniAppsMethodParams, MiniAppsMethodWithOptionalParams, MiniAppsMethodW
|
|
|
2
2
|
|
|
3
3
|
interface PostEventOptions {
|
|
4
4
|
/**
|
|
5
|
-
* Origin used while posting message.
|
|
6
|
-
*
|
|
5
|
+
* Origin used while posting a message.
|
|
6
|
+
*
|
|
7
|
+
* This option is only used if the current environment is browser (Web version of Telegram)
|
|
8
|
+
* and could be used for test purposes.
|
|
7
9
|
* @default 'https://web.telegram.org'
|
|
8
10
|
*/
|
|
9
11
|
targetOrigin?: string;
|
|
@@ -25,7 +27,7 @@ export declare function postEvent<Method extends MiniAppsMethodWithOptionalParam
|
|
|
25
27
|
* @throws {SDKError} ERR_UNKNOWN_ENV
|
|
26
28
|
* @see ERR_UNKNOWN_ENV
|
|
27
29
|
*/
|
|
28
|
-
export declare function postEvent(method: MiniAppsMethodWithoutParams, options?: PostEventOptions): void;
|
|
30
|
+
export declare function postEvent(method: MiniAppsMethodWithoutParams | MiniAppsMethodWithOptionalParams, options?: PostEventOptions): void;
|
|
29
31
|
/**
|
|
30
32
|
* Calls Mini Apps method with parameters.
|
|
31
33
|
* @param method - method name.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ExecuteWithOptions, If, IsNever } from '../types/index.js';
|
|
2
|
+
import { MiniAppsEventName, MiniAppsEventPayload } from './events/types.js';
|
|
3
|
+
import { MiniAppsMethodName, MiniAppsMethodParams } from './methods/types/index.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Returns all possible payloads for the specified events array.
|
|
7
|
+
*/
|
|
8
|
+
export type RequestEventsPayloads<E extends MiniAppsEventName[]> = E extends (infer U extends MiniAppsEventName)[] ? MiniAppsEventPayload<U> : never;
|
|
9
|
+
export type RequestCaptureEventsFn<E extends MiniAppsEventName[]> = E extends (infer U extends MiniAppsEventName)[] ? (payload: {
|
|
10
|
+
[K in U]: If<IsNever<MiniAppsEventPayload<K>>, {
|
|
11
|
+
event: K;
|
|
12
|
+
}, {
|
|
13
|
+
event: K;
|
|
14
|
+
payload: MiniAppsEventPayload<K>;
|
|
15
|
+
}>;
|
|
16
|
+
}[U]) => boolean : never;
|
|
17
|
+
export type RequestCaptureEventFn<E extends MiniAppsEventName> = If<IsNever<MiniAppsEventPayload<E>>, () => boolean, (payload: MiniAppsEventPayload<E>) => boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* `request` method options.
|
|
20
|
+
* @see request
|
|
21
|
+
*/
|
|
22
|
+
export type RequestOptions<M extends MiniAppsMethodName, E, C> = {
|
|
23
|
+
/**
|
|
24
|
+
* Mini Apps method name.
|
|
25
|
+
*/
|
|
26
|
+
method: M;
|
|
27
|
+
/**
|
|
28
|
+
* Tracked Mini Apps events.
|
|
29
|
+
*/
|
|
30
|
+
event: E;
|
|
31
|
+
/**
|
|
32
|
+
* Should return true if this event should be captured.
|
|
33
|
+
* A request will be captured if this property is omitted.
|
|
34
|
+
*/
|
|
35
|
+
capture?: C;
|
|
36
|
+
} & ExecuteWithOptions & If<IsNever<MiniAppsMethodParams<M>>, {}, {
|
|
37
|
+
/**
|
|
38
|
+
* List of method parameters.
|
|
39
|
+
*/
|
|
40
|
+
params: MiniAppsMethodParams<M>;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Calls specified Mini Apps method and captures specified event.
|
|
44
|
+
* @param options - method options.
|
|
45
|
+
* @returns Promise which will be resolved with data of the captured event.
|
|
46
|
+
*/
|
|
47
|
+
export declare function request<M extends MiniAppsMethodName, E extends MiniAppsEventName>(options: RequestOptions<M, E, RequestCaptureEventFn<E>>): Promise<MiniAppsEventPayload<E>>;
|
|
48
|
+
/**
|
|
49
|
+
* Calls specified Mini Apps method and captures one of the specified events.
|
|
50
|
+
* @param options - method options.
|
|
51
|
+
* @returns Promise which will be resolved with data of the first captured event.
|
|
52
|
+
*/
|
|
53
|
+
export declare function request<M extends MiniAppsMethodName, E extends MiniAppsEventName[]>(options: RequestOptions<M, E, RequestCaptureEventsFn<E>>): Promise<RequestEventsPayloads<E>>;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Sets new global targetOrigin, used by `postEvent` method.
|
|
3
|
-
*
|
|
4
|
-
* use this method until you know what you are doing.
|
|
2
|
+
* Sets a new global targetOrigin, used by the `postEvent` method.
|
|
3
|
+
* The default value is "https://web.telegram.org".
|
|
4
|
+
* You don't need to use this method until you know what you are doing.
|
|
5
5
|
*
|
|
6
6
|
* This method could be used for test purposes.
|
|
7
7
|
* @param value - new target origin.
|
|
8
|
+
* @see postEvent
|
|
8
9
|
*/
|
|
9
10
|
export declare function setTargetOrigin(value: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Sets the initial target origin.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resetTargetOrigin(): void;
|
|
10
15
|
/**
|
|
11
16
|
* Returns current global target origin.
|
|
12
17
|
*/
|
|
@@ -28,8 +28,9 @@ export declare class MiniApp extends WithSupportsAndTrackableState<MiniAppState,
|
|
|
28
28
|
get bgColor(): RGB;
|
|
29
29
|
/**
|
|
30
30
|
* Closes the Mini App.
|
|
31
|
+
* @param returnBack - should the application be wrapped into the bottom bar.
|
|
31
32
|
*/
|
|
32
|
-
close(): void;
|
|
33
|
+
close(returnBack?: boolean): void;
|
|
33
34
|
/**
|
|
34
35
|
* The Mini App header color.
|
|
35
36
|
* @example "#ffaabb"
|
|
@@ -41,7 +42,7 @@ export declare class MiniApp extends WithSupportsAndTrackableState<MiniAppState,
|
|
|
41
42
|
*/
|
|
42
43
|
get isBotInline(): boolean;
|
|
43
44
|
/**
|
|
44
|
-
* True if current Mini App background color is recognized as dark.
|
|
45
|
+
* True if the current Mini App background color is recognized as dark.
|
|
45
46
|
*/
|
|
46
47
|
get isDark(): boolean;
|
|
47
48
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StateEvents } from '../../classes/State/types.js';
|
|
2
|
-
import {
|
|
2
|
+
import { RequestCaptureEventFn } from '../../bridge/request.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* QRScanner internal state.
|
|
@@ -27,5 +27,5 @@ export interface QRScannerOpenOptions {
|
|
|
27
27
|
/**
|
|
28
28
|
* Function, which should return true, if QR should be captured.
|
|
29
29
|
*/
|
|
30
|
-
capture?:
|
|
30
|
+
capture?: RequestCaptureEventFn<'qr_text_received'>;
|
|
31
31
|
}
|
|
@@ -4,6 +4,16 @@ import { CreateRequestIdFn } from '../../request-id/types.js';
|
|
|
4
4
|
import { SupportsFn } from '../../supports/types.js';
|
|
5
5
|
import { Version } from '../../version/types.js';
|
|
6
6
|
|
|
7
|
+
export interface UtilsOpenLinkOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Attempts to use the instant view mode.
|
|
10
|
+
*/
|
|
11
|
+
tryInstantView?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Attempts to use user preferred browser.
|
|
14
|
+
*/
|
|
15
|
+
tryBrowser?: boolean;
|
|
16
|
+
}
|
|
7
17
|
/**
|
|
8
18
|
* @see API: https://docs.telegram-mini-apps.com/packages/tma-js-sdk/components/utils
|
|
9
19
|
*/
|
|
@@ -13,13 +23,26 @@ export declare class Utils extends WithSupports<'readTextFromClipboard'> {
|
|
|
13
23
|
private readonly postEvent;
|
|
14
24
|
constructor(version: Version, createRequestId: CreateRequestIdFn, postEvent: PostEvent);
|
|
15
25
|
/**
|
|
16
|
-
* Opens a link
|
|
26
|
+
* Opens a link.
|
|
27
|
+
*
|
|
28
|
+
* The Mini App will not be closed.
|
|
29
|
+
*
|
|
30
|
+
* Note that this method can be called only in response to the user
|
|
31
|
+
* interaction with the Mini App interface (e.g. click inside the Mini App or on the main button).
|
|
32
|
+
* @param url - URL to be opened.
|
|
33
|
+
* @param options - additional options.
|
|
34
|
+
*/
|
|
35
|
+
openLink(url: string, options?: UtilsOpenLinkOptions): void;
|
|
36
|
+
/**
|
|
37
|
+
* Opens a link.
|
|
38
|
+
*
|
|
39
|
+
* The Mini App will not be closed.
|
|
17
40
|
*
|
|
18
41
|
* Note that this method can be called only in response to the user
|
|
19
|
-
* interaction with the Mini App interface (e.g. click inside the Mini App
|
|
20
|
-
* or on the main button).
|
|
42
|
+
* interaction with the Mini App interface (e.g. click inside the Mini App or on the main button).
|
|
21
43
|
* @param url - URL to be opened.
|
|
22
|
-
* @param tryInstantView
|
|
44
|
+
* @param tryInstantView - try to use the instant view.
|
|
45
|
+
* @deprecated Use the second argument as an object.
|
|
23
46
|
*/
|
|
24
47
|
openLink(url: string, tryInstantView?: boolean): void;
|
|
25
48
|
/**
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ export { createPostEvent } from './bridge/methods/createPostEvent.js';
|
|
|
10
10
|
export { type PostEvent, postEvent } from './bridge/methods/postEvent.js';
|
|
11
11
|
export * from './bridge/methods/types/index.js';
|
|
12
12
|
export { setTargetOrigin, targetOrigin } from './bridge/target-origin.js';
|
|
13
|
-
export { captureSameReq } from './bridge/
|
|
14
|
-
export { invokeCustomMethod } from './bridge/
|
|
15
|
-
export { request, type RequestOptions, type
|
|
13
|
+
export { captureSameReq } from './bridge/captureSameReq.js';
|
|
14
|
+
export { invokeCustomMethod } from './bridge/invokeCustomMethod.js';
|
|
15
|
+
export { request, type RequestOptions, type RequestCaptureEventFn, type RequestCaptureEventsFn, type RequestEventsPayloads, } from './bridge/request.js';
|
|
16
16
|
/**
|
|
17
17
|
* Classnames.
|
|
18
18
|
*/
|
|
@@ -61,7 +61,7 @@ export { Popup } from './components/Popup/Popup.js';
|
|
|
61
61
|
export type { OpenPopupOptions, OpenPopupOptionsButton, PopupEventListener, PopupEventName, PopupEvents, PopupState, } from './components/Popup/types.js';
|
|
62
62
|
export { initQRScanner } from './components/QRScanner/initQRScanner.js';
|
|
63
63
|
export { QRScanner } from './components/QRScanner/QRScanner.js';
|
|
64
|
-
export type { QRScannerEventListener, QRScannerEventName, QRScannerEvents, QRScannerState, QRScannerOpenOptions } from './components/QRScanner/types.js';
|
|
64
|
+
export type { QRScannerEventListener, QRScannerEventName, QRScannerEvents, QRScannerState, QRScannerOpenOptions, } from './components/QRScanner/types.js';
|
|
65
65
|
export { initSettingsButton } from './components/SettingsButton/initSettingsButton.js';
|
|
66
66
|
export { SettingsButton } from './components/SettingsButton/SettingsButton.js';
|
|
67
67
|
export type { SettingsButtonEventListener, SettingsButtonEventName, SettingsButtonEvents, SettingsButtonState, } from './components/SettingsButton/types.js';
|
|
@@ -8,9 +8,9 @@ export { unsubscribe } from './bridge/events/listening/unsubscribe.js';
|
|
|
8
8
|
export { createPostEvent } from './bridge/methods/createPostEvent.js';
|
|
9
9
|
export { postEvent } from './bridge/methods/postEvent.js';
|
|
10
10
|
export { setTargetOrigin, targetOrigin } from './bridge/target-origin.js';
|
|
11
|
-
export { captureSameReq } from './bridge/
|
|
12
|
-
export { invokeCustomMethod } from './bridge/
|
|
13
|
-
export { request } from './bridge/
|
|
11
|
+
export { captureSameReq } from './bridge/captureSameReq.js';
|
|
12
|
+
export { invokeCustomMethod } from './bridge/invokeCustomMethod.js';
|
|
13
|
+
export { request } from './bridge/request.js';
|
|
14
14
|
/**
|
|
15
15
|
* Debug.
|
|
16
16
|
*/
|
|
@@ -4,8 +4,8 @@ import { CleanupFn } from '../types/index.js';
|
|
|
4
4
|
* Returns a tuple, containing function to add cleanup, call cleanup, and flag showing whether
|
|
5
5
|
* cleanup was called. Cleanup will not be performed in case, it was done before.
|
|
6
6
|
*/
|
|
7
|
-
export declare function createCleanup(...fns: CleanupFn[]): [
|
|
7
|
+
export declare function createCleanup(...fns: (CleanupFn | CleanupFn[])[]): [
|
|
8
8
|
add: (fn: CleanupFn) => void,
|
|
9
|
-
|
|
9
|
+
cleanup: () => void,
|
|
10
10
|
cleanedUp: boolean
|
|
11
11
|
];
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
"use strict";var Se=Object.defineProperty;var Pe=(e,t,s)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var c=(e,t,s)=>Pe(e,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function vt(e,t){let s;const n=()=>{s!==void 0&&t&&t(s),s=void 0};return[()=>s===void 0?s=e(n):s,n]}function K(e){const t=O(),{count:s}=t;t.unsubscribe(e),s&&!t.count&&Me()}function St(e){return O().subscribe(e),()=>K(e)}class Re{constructor(t,s={}){this.scope=t,this.options=s}print(t,...s){const n=new Date,r=Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(n),{textColor:i,bgColor:o}=this.options,a="font-weight: bold;padding: 0 5px;border-radius:5px";console[t](`%c${r}%c / %c${this.scope}`,`${a};background-color: lightblue;color:black`,"",`${a};${i?`color:${i};`:""}${o?`background-color:${o}`:""}`,...s)}error(...t){this.print("error",...t)}log(...t){this.print("log",...t)}}const Q=new Re("SDK",{bgColor:"forestgreen",textColor:"white"});let F=!1;const wt=({name:e,payload:t})=>{Q.log("Event received:",t?{name:e,payload:t}:{name:e})};function Te(e){F!==e&&(F=e,e?St(wt):K(wt))}function Ce(...e){F&&Q.log(...e)}class S{constructor(){c(this,"listeners",new Map);c(this,"listenersCount",0);c(this,"subscribeListeners",[])}clear(){this.listeners.clear(),this.subscribeListeners=[]}get count(){return this.listenersCount+this.subscribeListeners.length}emit(t,...s){this.subscribeListeners.forEach(r=>r({event:t,args:s})),(this.listeners.get(t)||[]).forEach(([r,i])=>{r(...s),i&&this.off(t,r)})}on(t,s,n){let r=this.listeners.get(t);return r||this.listeners.set(t,r=[]),r.push([s,n]),this.listenersCount+=1,()=>this.off(t,s)}off(t,s){const n=this.listeners.get(t)||[];for(let r=0;r<n.length;r+=1)if(s===n[r][0]){n.splice(r,1),this.listenersCount-=1;return}}subscribe(t){return this.subscribeListeners.push(t),()=>this.unsubscribe(t)}unsubscribe(t){for(let s=0;s<this.subscribeListeners.length;s+=1)if(this.subscribeListeners[s]===t){this.subscribeListeners.splice(s,1);return}}}function J(e,t,s){return window.addEventListener(e,t,s),()=>window.removeEventListener(e,t,s)}function X(...e){let t=!1;const s=[...e];return[n=>!t&&s.push(n),()=>{t||(t=!0,s.forEach(n=>n()))},t]}class q extends Error{constructor(t,s,n){super(s,{cause:n}),this.type=t,Object.setPrototypeOf(this,q.prototype)}}function g(e,t,s){return new q(e,t,s)}const Pt="ERR_METHOD_UNSUPPORTED",Rt="ERR_METHOD_PARAMETER_UNSUPPORTED",Tt="ERR_UNKNOWN_ENV",Ct="ERR_INVOKE_CUSTOM_METHOD_RESPONSE",xt="ERR_TIMED_OUT",At="ERR_UNEXPECTED_TYPE",Z="ERR_PARSE",It="ERR_NAVIGATION_LIST_EMPTY",Nt="ERR_NAVIGATION_CURSOR_INVALID",xe="ERR_NAVIGATION_ITEM_INVALID",Ae="ERR_SSR_INIT",qt="ERR_INVALID_PATH_BASE";function R(){return g(At,"Value has unexpected type")}class B{constructor(t,s,n){this.parser=t,this.isOptional=s,this.type=n}parse(t){if(!(this.isOptional&&t===void 0))try{return this.parser(t)}catch(s){throw g(Z,`Unable to parse value${this.type?` as ${this.type}`:""}`,s)}}optional(){return this.isOptional=!0,this}}function T(e,t){return()=>new B(e,!1,t)}const w=T(e=>{if(typeof e=="boolean")return e;const t=String(e);if(t==="1"||t==="true")return!0;if(t==="0"||t==="false")return!1;throw R()},"boolean");function kt(e,t){const s={};for(const n in e){const r=e[n];if(!r)continue;let i,o;if(typeof r=="function"||"parse"in r)i=n,o=typeof r=="function"?r:r.parse.bind(r);else{const{type:a}=r;i=r.from||n,o=typeof a=="function"?a:a.parse.bind(a)}try{const a=o(t(i));a!==void 0&&(s[n]=a)}catch(a){throw g(Z,`Unable to parse field "${n}"`,a)}}return s}function tt(e){let t=e;if(typeof t=="string"&&(t=JSON.parse(t)),typeof t!="object"||t===null||Array.isArray(t))throw R();return t}function l(e,t){return new B(s=>{const n=tt(s);return kt(e,r=>n[r])},!1,t)}const y=T(e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=Number(e);if(!Number.isNaN(t))return t}throw R()},"number");function L(e){return/^#[\da-f]{6}$/i.test(e)}function Dt(e){return/^#[\da-f]{3}$/i.test(e)}function et(e){const t=e.replace(/\s/g,"").toLowerCase();if(L(t))return t;if(Dt(t)){let n="#";for(let r=0;r<3;r+=1)n+=t[1+r].repeat(2);return 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}\)$/);if(!s)throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);return s.slice(1).reduce((n,r)=>{const i=parseInt(r,10).toString(16);return n+(i.length===1?"0":"")+i},"#")}const h=T(e=>{if(typeof e=="string"||typeof e=="number")return e.toString();throw R()},"string"),st=T(e=>et(h().parse(e)),"rgb");function Mt(e){return l({eventType:h(),eventData:t=>t}).parse(e)}function Ie(){["TelegramGameProxy_receiveEvent","TelegramGameProxy","Telegram"].forEach(e=>{delete window[e]})}function Y(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}function Ne(){[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["Telegram","WebView","receiveEvent"]].forEach(e=>{let t=window;e.forEach((s,n,r)=>{if(n===r.length-1){t[s]=Y;return}s in t||(t[s]={}),t=t[s]})})}const qe={clipboard_text_received:l({req_id:h(),data:e=>e===null?e:h().optional().parse(e)}),custom_method_invoked:l({req_id:h(),result:e=>e,error:h().optional()}),invoice_closed:l({slug:h(),status:h()}),phone_requested:l({status:h()}),popup_closed:{parse(e){return l({button_id:t=>t==null?void 0:h().parse(t)}).parse(e??{})}},qr_text_received:l({data:h().optional()}),theme_changed:l({theme_params:e=>{const t=st().optional();return Object.entries(tt(e)).reduce((s,[n,r])=>(s[n]=t.parse(r),s),{})}}),viewport_changed:l({height:y(),width:e=>e==null?window.innerWidth:y().parse(e),is_state_stable:w(),is_expanded:w()}),write_access_requested:l({status:h()})};function ke(){const e=new S,t=new S;t.subscribe(n=>{e.emit("event",{name:n.event,payload:n.args[0]})}),Ne();const[,s]=X(Ie,J("resize",()=>{t.emit("viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0})}),J("message",n=>{if(n.source!==window.parent)return;let r;try{r=Mt(n.data)}catch{return}const{eventType:i,eventData:o}=r,a=qe[i];try{const p=a?a.parse(o):o;t.emit(...p?[i,p]:[i])}catch(p){Q.error(`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`,r,p)}}),()=>e.clear(),()=>t.clear());return[{on:t.on.bind(t),off:t.off.bind(t),subscribe(n){return e.on("event",n)},unsubscribe(n){e.off("event",n)},get count(){return t.count+e.count}},s]}const[De,Me]=vt(e=>{const[t,s]=ke(),n=t.off.bind(t);return t.off=(r,i)=>{const{count:o}=t;n(r,i),o&&!t.count&&e()},[t,s]},([,e])=>e());function O(){return De()[0]}function k(e,t){O().off(e,t)}function b(e,t,s){return O().on(e,t,s)}function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Vt(e,t){const s=e.split("."),n=t.split("."),r=Math.max(s.length,n.length);for(let i=0;i<r;i+=1){const o=parseInt(s[i]||"0",10),a=parseInt(n[i]||"0",10);if(o!==a)return o>a?1:-1}return 0}function f(e,t){return Vt(e,t)<=0}function E(e,t,s){if(typeof s=="string"){if(e==="web_app_open_link"){if(t==="try_instant_view")return f("6.4",s);if(t==="try_browser")return f("7.6",s)}if(e==="web_app_set_header_color"&&t==="color")return f("6.9",s);if(e==="web_app_close"&&t==="return_back")return f("7.6",s)}switch(e){case"web_app_open_tg_link":case"web_app_open_invoice":case"web_app_setup_back_button":case"web_app_set_background_color":case"web_app_set_header_color":case"web_app_trigger_haptic_feedback":return f("6.1",t);case"web_app_open_popup":return f("6.2",t);case"web_app_close_scan_qr_popup":case"web_app_open_scan_qr_popup":case"web_app_read_text_from_clipboard":return f("6.4",t);case"web_app_switch_inline_query":return f("6.7",t);case"web_app_invoke_custom_method":case"web_app_request_write_access":case"web_app_request_phone":return f("6.9",t);case"web_app_setup_settings_button":return f("6.10",t);case"web_app_biometry_get_info":case"web_app_biometry_open_settings":case"web_app_biometry_request_access":case"web_app_biometry_request_auth":case"web_app_biometry_update_token":return f("7.2",t);default:return["iframe_ready","iframe_will_reload","web_app_close","web_app_data_send","web_app_expand","web_app_open_link","web_app_ready","web_app_request_theme","web_app_request_viewport","web_app_setup_main_button","web_app_setup_closing_behavior"].includes(e)}}function Bt(e){return"external"in e&&D(e.external)&&"notify"in e.external&&typeof e.external.notify=="function"}function Lt(e){return"TelegramWebviewProxy"in e&&D(e.TelegramWebviewProxy)&&"postEvent"in e.TelegramWebviewProxy&&typeof e.TelegramWebviewProxy.postEvent=="function"}function nt(){try{return window.self!==window.top}catch{return!0}}let Ot="https://web.telegram.org";function Ve(e){Ot=e}function Ut(){return Ot}function P(e,t,s){let n={},r;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);const{targetOrigin:i=Ut()}=n;if(Ce("Posting event:",r?{event:e,data:r}:{event:e}),nt()){window.parent.postMessage(JSON.stringify({eventType:e,eventData:r}),i);return}if(Bt(window)){window.external.notify(JSON.stringify({eventType:e,eventData:r}));return}if(Lt(window)){window.TelegramWebviewProxy.postEvent(e,JSON.stringify(r));return}throw g(Tt,"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.")}function $t(e){return(t,s)=>{if(!E(t,e))throw g(Pt,`Method "${t}" is unsupported in Mini Apps version ${e}`);if(D(s)){let 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&&!E(t,n,e))throw g(Rt,`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`)}return P(t,s)}}function rt(e){return({req_id:t})=>t===e}function Wt(e){return g(xt,`Timeout reached: ${e}ms`)}function it(e,t){return Promise.race([typeof e=="function"?e():e,new Promise((s,n)=>{setTimeout(()=>{n(Wt(t))},t)})])}async function d(e){let t;const s=new Promise(a=>{t=a}),{event:n,capture:r,timeout:i}=e,[,o]=X(...(Array.isArray(n)?n:[n]).map(a=>b(a,p=>(!r||r(p))&&t(p))));try{return(e.postEvent||P)(e.method,e.params),await(i?it(s,i):s)}finally{o()}}async function v(e,t,s,n={}){const{result:r,error:i}=await d({...n,method:"web_app_invoke_custom_method",event:"custom_method_invoked",params:{method:e,params:t,req_id:s},capture:rt(s)});if(i)throw g(Ct,i);return r}function V(...e){return e.map(t=>{if(typeof t=="string")return t;if(D(t))return V(Object.entries(t).map(s=>s[1]&&s[0]));if(Array.isArray(t))return V(...t)}).filter(Boolean).join(" ")}function Be(...e){return e.reduce((t,s)=>(D(s)&&Object.entries(s).forEach(([n,r])=>{const i=V(t[n],r);i.length&&(t[n]=i)}),t),{})}function ot(e){const t=et(e);return Math.sqrt([.299,.587,.114].reduce((s,n,r)=>{const i=parseInt(t.slice(1+r*2,1+(r+1)*2),16);return s+i*i*n},0))<120}class Le{constructor(t){c(this,"ee",new S);c(this,"on",this.ee.on.bind(this.ee));c(this,"off",this.ee.off.bind(this.ee));this.state=t}clone(){return{...this.state}}set(t,s){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)}get(t){return this.state[t]}}class at{constructor(t){c(this,"state");c(this,"get");c(this,"set");c(this,"clone");this.state=new Le(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)}}function Ht(e,t){return s=>E(t[s],e)}class ct extends at{constructor(s,n,r){super(s);c(this,"supports");this.supports=Ht(n,r)}}class Gt extends ct{constructor(s,n,r){super({isVisible:s},n,{show:"web_app_setup_back_button",hide:"web_app_setup_back_button"});c(this,"on",(s,n)=>s==="click"?b("back_button_pressed",n):this.state.on(s,n));c(this,"off",(s,n)=>s==="click"?k("back_button_pressed",n):this.state.off(s,n));this.postEvent=r}set isVisible(s){this.set("isVisible",s),this.postEvent("web_app_setup_back_button",{is_visible:s})}get isVisible(){return this.get("isVisible")}hide(){this.isVisible=!1}show(){this.isVisible=!0}}const ht=T(e=>e instanceof Date?e:new Date(y().parse(e)*1e3),"Date");function U(e,t){return new B(s=>{if(typeof s!="string"&&!(s instanceof URLSearchParams))throw R();const n=typeof s=="string"?new URLSearchParams(s):s;return kt(e,r=>{const i=n.get(r);return i===null?void 0:i})},!1,t)}const Oe=l({id:y(),type:h(),title:h(),photoUrl:{type:h().optional(),from:"photo_url"},username:h().optional()},"Chat").optional(),mt=l({addedToAttachmentMenu:{type:w().optional(),from:"added_to_attachment_menu"},allowsWriteToPm:{type:w().optional(),from:"allows_write_to_pm"},firstName:{type:h(),from:"first_name"},id:y(),isBot:{type:w().optional(),from:"is_bot"},isPremium:{type:w().optional(),from:"is_premium"},languageCode:{type:h().optional(),from:"language_code"},lastName:{type:h().optional(),from:"last_name"},photoUrl:{type:h().optional(),from:"photo_url"},username:h().optional()},"User").optional();function jt(){return U({authDate:{type:ht(),from:"auth_date"},canSendAfter:{type:y().optional(),from:"can_send_after"},chat:Oe,chatInstance:{type:h().optional(),from:"chat_instance"},chatType:{type:h().optional(),from:"chat_type"},hash:h(),queryId:{type:h().optional(),from:"query_id"},receiver:mt,startParam:{type:h().optional(),from:"start_param"},user:mt},"InitData")}function Ue(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function $e(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}const zt=T(e=>{const t=st().optional();return Object.entries(tt(e)).reduce((s,[n,r])=>(s[Ue(n)]=t.parse(r),s),{})},"ThemeParams");function $(e){return U({botInline:{type:w().optional(),from:"tgWebAppBotInline"},initData:{type:jt().optional(),from:"tgWebAppData"},initDataRaw:{type:h().optional(),from:"tgWebAppData"},platform:{type:h(),from:"tgWebAppPlatform"},showSettings:{type:w().optional(),from:"tgWebAppShowSettings"},startParam:{type:h().optional(),from:"tgWebAppStartParam"},themeParams:{type:zt(),from:"tgWebAppThemeParams"},version:{type:h(),from:"tgWebAppVersion"}}).parse(e)}function Ft(e){return $(e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&"))}function We(){return Ft(window.location.href)}function Jt(){return performance.getEntriesByType("navigation")[0]}function He(){const e=Jt();if(!e)throw new Error("Unable to get first navigation entry.");return Ft(e.name)}function Yt(e){return`tma.js/${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function Kt(e,t){sessionStorage.setItem(Yt(e),JSON.stringify(t))}function Qt(e){const t=sessionStorage.getItem(Yt(e));try{return t?JSON.parse(t):void 0}catch{}}function Ge(){return $(Qt("launchParams")||"")}function pt(e){return JSON.stringify(Object.fromEntries(Object.entries(e).map(([t,s])=>[$e(t),s])))}function Xt(e){const{initDataRaw:t,themeParams:s,platform:n,version:r,showSettings:i,startParam:o,botInline:a}=e,p=new URLSearchParams;return p.set("tgWebAppPlatform",n),p.set("tgWebAppThemeParams",pt(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()}function Zt(e){Kt("launchParams",Xt(e))}function te(){for(const e of[We,He,Ge])try{const t=e();return Zt(t),t}catch{}throw new Error("Unable to retrieve launch parameters from any known source.")}function ut(){const e=Jt();return!!(e&&e.type==="reload")}function je(){let e=0;return()=>(e+=1).toString()}const[ze]=vt(je);function _(e,t){return()=>{const s=te(),n={...s,postEvent:$t(s.version),createRequestId:ze()};if(typeof e=="function")return e(n);const[r,i,o]=X(),a=t({...n,state:ut()?Qt(e):void 0,addCleanup:r}),p=u=>(o||r(u.on("change",ve=>{Kt(e,ve)})),u);return[a instanceof Promise?a.then(p):p(a),i]}}const Fe=_("backButton",({postEvent:e,version:t,state:s={isVisible:!1}})=>new Gt(s.isVisible,t,e));class M extends ct{constructor(){super(...arguments);c(this,"on",this.state.on.bind(this.state));c(this,"off",this.state.off.bind(this.state))}}function ee(e){const t=e.available?e:{available:!1,device_id:"",token_saved:!1,access_requested:!1,access_granted:!1,type:""};return{available:!0,type:t.type,deviceId:t.device_id,tokenSaved:t.token_saved,accessRequested:t.access_requested,accessGranted:t.access_granted}}class se extends M{constructor({postEvent:s,version:n,...r}){super(r,n,{auth:"web_app_biometry_request_auth",openSettings:"web_app_biometry_open_settings",requestAccess:"web_app_biometry_request_access",updateToken:"web_app_biometry_update_token"});c(this,"postEvent");c(this,"authPromise");c(this,"accessPromise");this.postEvent=s}get available(){return this.get("available")}get accessGranted(){return this.get("accessGranted")}get accessRequested(){return this.get("accessRequested")}async authenticate({reason:s,...n}){return this.authPromise||(this.authPromise=d({...n,method:"web_app_biometry_request_auth",event:"biometry_auth_requested",postEvent:this.postEvent,params:{reason:(s||"").trim()}}).then(({token:r})=>r).finally(()=>this.authPromise=void 0)),this.authPromise}get deviceId(){return this.get("deviceId")}openSettings(){this.postEvent("web_app_biometry_open_settings")}requestAccess({reason:s,...n}={}){return this.accessPromise||(this.accessPromise=d({...n,postEvent:this.postEvent,method:"web_app_biometry_request_access",event:"biometry_info_received",params:{reason:s||""}}).then(r=>{const i=ee(r);return this.set(i),i.accessGranted}).finally(()=>this.accessPromise=void 0)),this.accessPromise}get biometryType(){return this.get("biometryType")}get tokenSaved(){return this.get("tokenSaved")}async updateToken({token:s,...n}={}){return["removed","updated"].includes((await d({...n,postEvent:this.postEvent,method:"web_app_biometry_update_token",event:"biometry_token_updated",params:{token:s||""}})).status)}}async function ne(e){return ee(await d({...e||{},method:"web_app_biometry_get_info",event:"biometry_info_received"}))}const Je=_("biometryManager",async({postEvent:e,version:t,state:s})=>new se({...s||E("web_app_biometry_get_info",t)?s||await ne({timeout:1e3}):{available:!1,accessGranted:!1,accessRequested:!1,tokenSaved:!1,deviceId:""},version:t,postEvent:e}));class lt extends at{constructor(){super(...arguments);c(this,"on",this.state.on.bind(this.state));c(this,"off",this.state.off.bind(this.state))}}class re extends lt{constructor(t,s){super({isConfirmationNeeded:t}),this.postEvent=s}set isConfirmationNeeded(t){this.set("isConfirmationNeeded",t),this.postEvent("web_app_setup_closing_behavior",{need_confirmation:t})}get isConfirmationNeeded(){return this.get("isConfirmationNeeded")}disableConfirmation(){this.isConfirmationNeeded=!1}enableConfirmation(){this.isConfirmationNeeded=!0}}const Ye=_("closingBehavior",({postEvent:e,state:t={isConfirmationNeeded:!1}})=>new re(t.isConfirmationNeeded,e));class dt{constructor(t,s){c(this,"supports");this.supports=Ht(t,s)}}function Ke(e){if(Array.isArray(e))return e;if(typeof e=="string")try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch{}throw R()}class Qe extends B{constructor(s,n,r){super(Ke,n,r);c(this,"itemParser");this.itemParser=typeof s=="function"?s:s.parse.bind(s)}parse(s){const n=super.parse(s);return n===void 0?n:n.map(this.itemParser)}of(s){return this.itemParser=typeof s=="function"?s:s.parse.bind(s),this}}function ie(e){return new Qe(t=>t,!1,e)}function yt(e,t){return Object.fromEntries(e.map(s=>[s,t]))}class oe extends dt{constructor(t,s,n){super(t,{delete:"web_app_invoke_custom_method",get:"web_app_invoke_custom_method",getKeys:"web_app_invoke_custom_method",set:"web_app_invoke_custom_method"}),this.createRequestId=s,this.postEvent=n}async delete(t,s={}){const n=Array.isArray(t)?t:[t];n.length&&await v("deleteStorageValues",{keys:n},this.createRequestId(),{...s,postEvent:this.postEvent})}async getKeys(t={}){return ie().of(h()).parse(await v("getStorageKeys",{},this.createRequestId(),{...t,postEvent:this.postEvent}))}async get(t,s={}){const n=Array.isArray(t)?t:[t];if(!n.length)return yt(n,"");const r=await v("getStorageValues",{keys:n},this.createRequestId(),{...s,postEvent:this.postEvent}),i=l(yt(n,h()),"CloudStorageData").parse(r);return Array.isArray(t)?i:i[t]}async set(t,s,n={}){await v("saveStorageValue",{key:t,value:s},this.createRequestId(),{...n,postEvent:this.postEvent})}}const Xe=_(({createRequestId:e,postEvent:t,version:s})=>new oe(s,e,t));class ae extends dt{constructor(t,s){super(t,{impactOccurred:"web_app_trigger_haptic_feedback",notificationOccurred:"web_app_trigger_haptic_feedback",selectionChanged:"web_app_trigger_haptic_feedback"}),this.postEvent=s}impactOccurred(t){this.postEvent("web_app_trigger_haptic_feedback",{type:"impact",impact_style:t})}notificationOccurred(t){this.postEvent("web_app_trigger_haptic_feedback",{type:"notification",notification_type:t})}selectionChanged(){this.postEvent("web_app_trigger_haptic_feedback",{type:"selection_change"})}}const Ze=_(({version:e,postEvent:t})=>new ae(e,t));class ce{constructor(t){this.initData=t}get authDate(){return this.initData.authDate}get canSendAfter(){return this.initData.canSendAfter}get canSendAfterDate(){const{canSendAfter:t}=this;return t?new Date(this.authDate.getTime()+t*1e3):void 0}get chat(){return this.initData.chat}get chatType(){return this.initData.chatType}get chatInstance(){return this.initData.chatInstance}get hash(){return this.initData.hash}get queryId(){return this.initData.queryId}get receiver(){return this.initData.receiver}get startParam(){return this.initData.startParam}get user(){return this.initData.user}}const ts=_(({initData:e})=>e?new ce(e):void 0);function es(e){return jt().parse(e)}class he extends M{constructor(t,s,n){super({isOpened:t},s,{open:"web_app_open_invoice"}),this.postEvent=n}set isOpened(t){this.set("isOpened",t)}get isOpened(){return this.get("isOpened")}async open(t,s){if(this.isOpened)throw new Error("Invoice is already opened");let n;if(!s)n=t;else{const{hostname:r,pathname:i}=new URL(t,window.location.href);if(r!=="t.me")throw new Error(`Incorrect hostname: ${r}`);const o=i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);if(!o)throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');[,,n]=o}this.isOpened=!0;try{return(await d({method:"web_app_open_invoice",event:"invoice_closed",params:{slug:n},postEvent:this.postEvent,capture(i){return n===i.slug}})).status}finally{this.isOpened=!1}}}const ss=_(({version:e,postEvent:t})=>new he(!1,e,t));class pe extends at{constructor({postEvent:s,...n}){super(n);c(this,"postEvent");c(this,"on",(s,n)=>s==="click"?b("main_button_pressed",n):this.state.on(s,n));c(this,"off",(s,n)=>s==="click"?k("main_button_pressed",n):this.state.off(s,n));this.postEvent=s}get bgColor(){return this.get("bgColor")}commit(){this.text!==""&&this.postEvent("web_app_setup_main_button",{is_visible:this.isVisible,is_active:this.isEnabled,is_progress_visible:this.isLoaderVisible,text:this.text,color:this.bgColor,text_color:this.textColor})}disable(){return this.isEnabled=!1,this}enable(){return this.isEnabled=!0,this}hide(){return this.isVisible=!1,this}hideLoader(){return this.isLoaderVisible=!1,this}set isEnabled(s){this.setParams({isEnabled:s})}get isEnabled(){return this.get("isEnabled")}set isLoaderVisible(s){this.setParams({isLoaderVisible:s})}get isLoaderVisible(){return this.get("isLoaderVisible")}set isVisible(s){this.setParams({isVisible:s})}get isVisible(){return this.get("isVisible")}show(){return this.isVisible=!0,this}showLoader(){return this.isLoaderVisible=!0,this}setText(s){return this.setParams({text:s})}setTextColor(s){return this.setParams({textColor:s})}setBgColor(s){return this.setParams({bgColor:s})}setParams(s){return this.set(s),this.commit(),this}get text(){return this.get("text")}get textColor(){return this.get("textColor")}}const ns=_("mainButton",({postEvent:e,themeParams:t,state:s={isVisible:!1,isEnabled:!1,text:"",isLoaderVisible:!1,textColor:t.buttonTextColor||"#ffffff",bgColor:t.buttonColor||"#000000"}})=>new pe({...s,postEvent:e}));function rs(){return U({contact:l({userId:{type:y(),from:"user_id"},phoneNumber:{type:h(),from:"phone_number"},firstName:{type:h(),from:"first_name"},lastName:{type:h().optional(),from:"last_name"}}),authDate:{type:ht(),from:"auth_date"},hash:h()},"RequestedContact")}function ue(e,t){return s=>{const[n,r]=t[s];return E(n,r,e)}}function is(e){return new Promise(t=>{setTimeout(t,e)})}class le extends M{constructor({postEvent:s,createRequestId:n,version:r,botInline:i,...o}){super(o,r,{requestPhoneAccess:"web_app_request_phone",requestWriteAccess:"web_app_request_write_access",switchInlineQuery:"web_app_switch_inline_query",setHeaderColor:"web_app_set_header_color",setBackgroundColor:"web_app_set_background_color"});c(this,"botInline");c(this,"postEvent");c(this,"createRequestId");c(this,"requestPhoneAccessPromise");c(this,"requestWriteAccessPromise");c(this,"supportsParam");this.createRequestId=n,this.postEvent=s,this.botInline=i;const a=this.supports.bind(this);this.supports=p=>a(p)?p!=="switchInlineQuery"||i:!1,this.supportsParam=ue(r,{"setHeaderColor.color":["web_app_set_header_color","color"]})}async getRequestedContact({timeout:s=1e4}={}){return rs().parse(await v("getRequestedContact",{},this.createRequestId(),{postEvent:this.postEvent,timeout:s}))}get bgColor(){return this.get("bgColor")}close(){this.postEvent("web_app_close")}get headerColor(){return this.get("headerColor")}get isBotInline(){return this.botInline}get isDark(){return ot(this.bgColor)}ready(){this.postEvent("web_app_ready")}async requestContact({timeout:s=5e3}={}){try{return await this.getRequestedContact()}catch{}if(await this.requestPhoneAccess()!=="sent")throw new Error("Access denied.");const r=Date.now()+s;let i=50;return it(async()=>{for(;Date.now()<r;){try{return await this.getRequestedContact()}catch{}await is(i),i+=50}throw Wt(s)},s)}async requestPhoneAccess(s={}){return this.requestPhoneAccessPromise||(this.requestPhoneAccessPromise=d({...s,method:"web_app_request_phone",event:"phone_requested",postEvent:this.postEvent}).then(({status:n})=>n).finally(()=>this.requestPhoneAccessPromise=void 0)),this.requestPhoneAccessPromise}async requestWriteAccess(s={}){return this.requestWriteAccessPromise||(this.requestWriteAccessPromise=d({...s,method:"web_app_request_write_access",event:"write_access_requested",postEvent:this.postEvent}).then(({status:n})=>n).finally(()=>this.requestWriteAccessPromise=void 0)),this.requestWriteAccessPromise}sendData(s){const{size:n}=new Blob([s]);if(!n||n>4096)throw new Error(`Passed data has incorrect size: ${n}`);this.postEvent("web_app_data_send",{data:s})}setHeaderColor(s){this.postEvent("web_app_set_header_color",L(s)?{color:s}:{color_key:s}),this.set("headerColor",s)}setBgColor(s){this.postEvent("web_app_set_background_color",{color:s}),this.set("bgColor",s)}switchInlineQuery(s,n=[]){if(!this.supports("switchInlineQuery")&&!this.isBotInline)throw new Error("Method is unsupported because Mini App should be launched in inline mode.");this.postEvent("web_app_switch_inline_query",{query:s,chat_types:n})}}const os=_("miniApp",({themeParams:e,botInline:t=!1,state:s={bgColor:e.bgColor||"#ffffff",headerColor:e.headerBgColor||"#000000"},...n})=>new le({...n,...s,botInline:t}));function as(e){const t=e.message.trim(),s=(e.title||"").trim(),n=e.buttons||[];let r;if(s.length>64)throw new Error(`Title has incorrect size: ${s.length}`);if(!t.length||t.length>256)throw new Error(`Message has incorrect size: ${t.length}`);if(n.length>3)throw new Error(`Buttons have incorrect size: ${n.length}`);return n.length?r=n.map(i=>{const{id:o=""}=i;if(o.length>64)throw new Error(`Button ID has incorrect size: ${o}`);if(!i.type||i.type==="default"||i.type==="destructive"){const a=i.text.trim();if(!a.length||a.length>64){const p=i.type||"default";throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`)}return{...i,text:a,id:o}}return{...i,id:o}}):r=[{type:"close",id:""}],{title:s,message:t,buttons:r}}class de extends M{constructor(t,s,n){super({isOpened:t},s,{open:"web_app_open_popup"}),this.postEvent=n}set isOpened(t){this.set("isOpened",t)}get isOpened(){return this.get("isOpened")}async open(t){if(this.isOpened)throw new Error("Popup is already opened.");this.isOpened=!0;try{const{button_id:s=null}=await d({event:"popup_closed",method:"web_app_open_popup",postEvent:this.postEvent,params:as(t)});return s}finally{this.isOpened=!1}}}const cs=_(({postEvent:e,version:t})=>new de(!1,t,e));class _e extends M{constructor(t,s,n){super({isOpened:t},s,{close:"web_app_close_scan_qr_popup",open:"web_app_open_scan_qr_popup"}),this.postEvent=n}close(){this.postEvent("web_app_close_scan_qr_popup"),this.isOpened=!1}set isOpened(t){this.set("isOpened",t)}get isOpened(){return this.get("isOpened")}async open(t){if(this.isOpened)throw new Error("The scanner is already opened");const{text:s,capture:n}=(typeof t=="string"?{text:t}:t)||{};this.isOpened=!0;try{const i=(await d({method:"web_app_open_scan_qr_popup",event:["qr_text_received","scan_qr_popup_closed"],postEvent:this.postEvent,params:{text:s},capture(o){return o.event==="scan_qr_popup_closed"||!n||n(o.payload)}})||{}).data||null;return i&&this.close(),i}finally{this.isOpened=!1}}}const hs=_(({version:e,postEvent:t})=>new _e(!1,e,t));class fe extends ct{constructor(s,n,r){super({isVisible:s},n,{show:"web_app_setup_settings_button",hide:"web_app_setup_settings_button"});c(this,"on",(s,n)=>s==="click"?b("settings_button_pressed",n):this.state.on(s,n));c(this,"off",(s,n)=>s==="click"?k("settings_button_pressed",n):this.state.off(s,n));this.postEvent=r}set isVisible(s){this.set("isVisible",s),this.postEvent("web_app_setup_settings_button",{is_visible:s})}get isVisible(){return this.get("isVisible")}hide(){this.isVisible=!1}show(){this.isVisible=!0}}const ps=_("settingsButton",({version:e,postEvent:t,state:s={isVisible:!1}})=>new fe(s.isVisible,e,t));function _t(e){return zt().parse(e)}class ge extends lt{get accentTextColor(){return this.get("accentTextColor")}get bgColor(){return this.get("bgColor")}get buttonColor(){return this.get("buttonColor")}get buttonTextColor(){return this.get("buttonTextColor")}get destructiveTextColor(){return this.get("destructiveTextColor")}getState(){return this.clone()}get headerBgColor(){return this.get("headerBgColor")}get hintColor(){return this.get("hintColor")}get isDark(){return!this.bgColor||ot(this.bgColor)}get linkColor(){return this.get("linkColor")}get secondaryBgColor(){return this.get("secondaryBgColor")}get sectionBgColor(){return this.get("sectionBgColor")}get sectionHeaderTextColor(){return this.get("sectionHeaderTextColor")}get sectionSeparatorColor(){return this.get("sectionHeaderTextColor")}listen(){return b("theme_changed",t=>{this.set(_t(t.theme_params))})}get subtitleTextColor(){return this.get("subtitleTextColor")}get textColor(){return this.get("textColor")}}const us=_("themeParams",({themeParams:e,state:t=e,addCleanup:s})=>{const n=new ge(t);return s(n.listen()),n});function ls(e={}){return d({...e,method:"web_app_request_theme",event:"theme_changed"}).then(_t)}class be extends dt{constructor(s,n,r){super(s,{readTextFromClipboard:"web_app_read_text_from_clipboard"});c(this,"supportsParam");this.version=s,this.createRequestId=n,this.postEvent=r,this.supportsParam=ue(s,{"openLink.tryInstantView":["web_app_open_link","try_instant_view"]})}openLink(s,n){const r=new URL(s,window.location.href).toString();if(!E("web_app_open_link",this.version)){window.open(r,"_blank");return}this.postEvent("web_app_open_link",{url:r,...typeof n=="boolean"?{try_instant_view:n}:{}})}openTelegramLink(s){const{hostname:n,pathname:r,search:i}=new URL(s,"https://t.me");if(n!=="t.me")throw new Error(`URL has not allowed hostname: ${n}. Only "t.me" is allowed`);if(!E("web_app_open_tg_link",this.version)){window.location.href=s;return}this.postEvent("web_app_open_tg_link",{path_full:r+i})}async readTextFromClipboard(){const s=this.createRequestId(),{data:n=null}=await d({method:"web_app_read_text_from_clipboard",event:"clipboard_text_received",postEvent:this.postEvent,params:{req_id:s},capture:rt(s)});return n}shareURL(s,n){this.openTelegramLink("https://t.me/share/url?"+new URLSearchParams({url:s,text:n||""}).toString())}}const ds=_(({version:e,postEvent:t,createRequestId:s})=>new be(e,s,t));async function ft(e={}){const{is_expanded:t,is_state_stable:s,...n}=await d({...e,method:"web_app_request_viewport",event:"viewport_changed"});return{...n,isExpanded:t,isStateStable:s}}function C(e){return e<0?0:e}class we extends lt{constructor({postEvent:s,stableHeight:n,height:r,width:i,isExpanded:o}){super({height:C(r),isExpanded:o,stableHeight:C(n),width:C(i)});c(this,"postEvent");this.postEvent=s}async sync(s){const{isStateStable:n,...r}=await ft(s);this.set({...r,stableHeight:n?r.height:this.get("stableHeight")})}get height(){return this.get("height")}get stableHeight(){return this.get("stableHeight")}listen(){return b("viewport_changed",s=>{const{height:n,width:r,is_expanded:i,is_state_stable:o}=s,a=C(n);this.set({height:a,isExpanded:i,width:C(r),...o?{stableHeight:a}:{}})})}get isExpanded(){return this.get("isExpanded")}get width(){return this.get("width")}expand(){this.postEvent("web_app_expand"),this.set("isExpanded",!0)}get isStable(){return this.stableHeight===this.height}}const _s=_("viewport",async({state:e,platform:t,postEvent:s,addCleanup:n})=>{let r=!1,i=0,o=0,a=0;if(e)r=e.isExpanded,i=e.height,o=e.width,a=e.stableHeight;else if(["macos","tdesktop","unigram","webk","weba","web"].includes(t))r=!0,i=window.innerHeight,o=window.innerWidth,a=window.innerHeight;else{const u=await ft({timeout:1e3,postEvent:s});r=u.isExpanded,i=u.height,o=u.width,a=u.isStateStable?i:0}const p=new we({postEvent:s,height:i,width:o,stableHeight:a,isExpanded:r});return n(p.listen()),p});function m(e,t){document.documentElement.style.setProperty(e,t)}function fs(e,t,s){s||(s=a=>`--tg-${a}-color`);const n=s("header"),r=s("bg"),i=()=>{const{headerColor:a}=e;if(L(a))m(n,a);else{const{bgColor:p,secondaryBgColor:u}=t;a==="bg_color"&&p?m(n,p):a==="secondary_bg_color"&&u&&m(n,u)}m(r,e.bgColor)},o=[t.on("change",i),e.on("change",i)];return i(),()=>o.forEach(a=>a())}function gs(e,t){t||(t=n=>`--tg-theme-${n.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`)}`);const s=()=>{Object.entries(e.getState()).forEach(([n,r])=>{r&&m(t(n),r)})};return s(),e.on("change",s)}function bs(e,t){t||(t=u=>`--tg-viewport-${u}`);const[s,n,r]=["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=[e.on("change:height",i),e.on("change:width",o),e.on("change:stableHeight",a)];return i(),o(),a(),()=>p.forEach(u=>u())}function ws(e=!0){const t=[b("reload_iframe",()=>{P("iframe_will_reload"),window.location.reload()})],s=()=>t.forEach(n=>n());if(e){const n=document.createElement("style");n.id="telegram-custom-styles",document.head.appendChild(n),t.push(b("set_custom_style",r=>{n.innerHTML=r}),()=>document.head.removeChild(n))}return P("iframe_ready",{reload_supported:!0}),s}function ms(){return typeof window>"u"}async function ys(){if(Lt(window))return!0;try{return await d({method:"web_app_request_theme",event:"theme_changed",timeout:100}),!0}catch{return!1}}function Es(e){const t=typeof e=="string"?$(e):e;Zt(t);function s(r){if(typeof r=="string")try{const{eventType:i}=Mt(r);i==="web_app_request_theme"&&Y("theme_changed",{theme_params:JSON.parse(pt(t.themeParams))}),i==="web_app_request_viewport"&&Y("viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0})}catch{}}if(nt()){const r=window.parent.postMessage.bind(window.parent);window.parent.postMessage=i=>{s(i),r(i)};return}if(Bt(window)){const r=window.external.notify.bind(window.external);window.external.notify=i=>{s(i),r(i)};return}const n=window.TelegramWebviewProxy;window.TelegramWebviewProxy={...n||{},postEvent(...r){s(JSON.stringify({eventType:r[0],eventData:r[1]})),n&&n.postEvent(...r)}}}function me(e){return e instanceof q}function vs(e,t){return me(e)&&e.type===t}function W(e,t){let s,n,r;return typeof e=="string"?s=e:(s=e.pathname===void 0?t:e.pathname,n=e.params,r=e.id),Object.freeze({id:r||(Math.random()*2**14|0).toString(16),pathname:s,params:n})}class ye{constructor(t,s,n=P){c(this,"history");c(this,"ee",new S);c(this,"attached",!1);c(this,"back",()=>this.go(-1));c(this,"on",this.ee.on.bind(this.ee));c(this,"off",this.ee.off.bind(this.ee));if(this._index=s,this.postEvent=n,t.length===0)throw g(It,"History should not be empty.");if(s<0||s>=t.length)throw g(Nt,"Index should not be zero and higher or equal than history size.");this.history=t.map(r=>W(r,""))}attach(){this.attached||(this.attached=!0,this.sync(),b("back_button_pressed",this.back))}get current(){return this.history[this.index]}detach(){this.attached=!1,k("back_button_pressed",this.back)}forward(){this.go(1)}go(t,s){const n=this.index+t,r=Math.min(Math.max(0,n),this.history.length-1);(n===r||s)&&this.replaceAndMove(r,this.history[r])}goTo(t,s){this.go(t-this.index,s)}get hasPrev(){return this.index>0}get hasNext(){return this.index!==this.history.length-1}get index(){return this._index}push(t){this.hasNext&&this.history.splice(this.index+1),this.replaceAndMove(this.index+1,W(t,this.current.pathname))}replace(t){this.replaceAndMove(this.index,W(t,this.current.pathname))}replaceAndMove(t,s){const n=t-this.index;if(!n&&this.current===s)return;const r=this.current;if(this.index!==t){const i=this._index;this._index=t,this.attached&&i>0!=t>0&&this.sync()}this.history[t]=s,this.ee.emit("change",{navigator:this,from:r,to:this.current,delta:n})}sync(){this.postEvent("web_app_setup_back_button",{is_visible:!!this.index})}}function H({params:e,...t}){return{...e||{hash:"",search:""},...t}}function A(e,t){return e.startsWith(t)?e:`${t}${e}`}function I(e){return new URL(typeof e=="string"?e:`${e.pathname||""}${A(e.search||"","?")}${A(e.hash||"","#")}`,"http://a")}function N(e){const t=typeof e=="string"?e.startsWith("/"):!!(e.pathname&&e.pathname.startsWith("/")),s=I(e);return`${t?s.pathname:s.pathname.slice(1)}${s.search}${s.hash}`}function G(e,t,s){let n,r;typeof e=="string"?n=e:(n=N(e),s=e.state,r=e.id);const{pathname:i,search:o,hash:a}=new URL(n,`http://a${A(t,"/")}`);return{id:r,pathname:i,params:{hash:a,search:o,state:s}}}async function x(e){return e===0?!0:Promise.race([new Promise(t=>{const s=J("popstate",()=>{s(),t(!0)});window.history.go(e)}),new Promise(t=>{setTimeout(t,50,!1)})])}async function Ss(){if(window.history.length<=1||(window.history.pushState(null,""),await x(1-window.history.length)))return;let t=await x(-1);for(;t;)t=await x(-1)}function gt(e){return I(e).pathname}const Et=0,j=1,z=2;class bt{constructor(t,s,{postEvent:n,hashMode:r="classic",base:i}={}){c(this,"navigator");c(this,"ee",new S);c(this,"hashMode");c(this,"base");c(this,"attached",!1);c(this,"onPopState",({state:t})=>{if(t===null)return this.push(this.parsePath(window.location.href));t===Et?window.history.forward():t===j&&this.back(),t===z&&this.forward()});c(this,"onNavigatorChange",async({to:t,from:s,delta:n})=>{this.attached&&await this.syncHistory(),this.ee.emit("change",{delta:n,from:H(s),to:H(t),navigator:this})});c(this,"on",this.ee.on.bind(this.ee));c(this,"off",this.ee.off.bind(this.ee));this.navigator=new ye(t.map(o=>G(o,"/")),s,n),this.navigator.on("change",o=>{this.onNavigatorChange(o)}),this.hashMode=r,this.base=gt(i||"")}async attach(){this.attached||(this.attached=!0,this.navigator.attach(),window.addEventListener("popstate",this.onPopState),await this.syncHistory())}back(){this.navigator.back()}detach(){this.attached=!1,this.navigator.detach(),window.removeEventListener("popstate",this.onPopState)}forward(){return this.navigator.forward()}get index(){return this.navigator.index}get id(){return this.navigator.current.id}go(t,s){return this.navigator.go(t,s)}goTo(t,s){this.navigator.goTo(t,s)}get hash(){return(this.navigator.current.params||{}).hash||""}get hasPrev(){return this.navigator.hasPrev}get hasNext(){return this.navigator.hasNext}get history(){return this.navigator.history.map(H)}get path(){return N(this)}get pathname(){return this.navigator.current.pathname}parsePath(t){let s=I(t);return this.hashMode&&(s=I(s.hash.slice(1))),{pathname:s.pathname,search:s.search,hash:s.hash}}push(t,s){const n=G(t,this.path),{state:r=s}=n.params;this.navigator.push({...n,params:{...n.params,state:r}})}replace(t,s){const n=G(t,this.path),{state:r=s}=n.params;this.navigator.replace({...n,params:{...n.params,state:r}})}renderPath(t){const s=(this.base.length===1?"":this.base)+A(N(t),"/");return this.hashMode?A(s.slice(1),this.hashMode==="classic"?"#":"#/"):s}async syncHistory(){window.removeEventListener("popstate",this.onPopState);const{state:t}=this,s=this.renderPath(this);await Ss(),this.hasPrev&&this.hasNext?(window.history.replaceState(j,""),window.history.pushState(t,"",s),window.history.pushState(z,""),await x(-1)):this.hasPrev?(window.history.replaceState(j,""),window.history.pushState(t,"",s)):this.hasNext?(window.history.replaceState(t,s),window.history.pushState(z,""),await x(-1)):(window.history.replaceState(Et,""),window.history.pushState(t,"",s)),window.addEventListener("popstate",this.onPopState)}get search(){return(this.navigator.current.params||{}).search||""}get state(){return(this.navigator.current.params||{}).state}}function Ee(e){e||(e={});const{href:t,hash:s}=window.location;let n=N(e.hashMode===null?t:s.includes("?")?s.slice(1):`?${s.slice(1)}`);const r=e.base?gt(e.base):void 0;if(r){if(!n.startsWith(r))throw g(qt,`Path "${n}" expected to be starting with "${r}"`);n=n.slice(r.length)}return new bt([n],0,e)}function Ps(e){const t=e.match(/#(.+)/);return t?t[1]:null}function Rs(e,t){if(ut()){const s=sessionStorage.getItem(e);if(s)try{const{index:n,history:r}=JSON.parse(s);return new bt(r,n,t)}catch(n){console.error("Unable to restore hash navigator state.",n)}}return Ee(t)}function Ts(e,t){const s=Rs(e,t),n=()=>sessionStorage.setItem(e,JSON.stringify({index:s.index,history:s.history}));return s.on("change",n),n(),s}exports.BackButton=Gt;exports.BasicNavigator=ye;exports.BiometryManager=se;exports.BrowserNavigator=bt;exports.ClosingBehavior=re;exports.CloudStorage=oe;exports.ERR_INVALID_PATH_BASE=qt;exports.ERR_INVOKE_CUSTOM_METHOD_RESPONSE=Ct;exports.ERR_METHOD_PARAMETER_UNSUPPORTED=Rt;exports.ERR_METHOD_UNSUPPORTED=Pt;exports.ERR_NAVIGATION_HISTORY_EMPTY=It;exports.ERR_NAVIGATION_INDEX_INVALID=Nt;exports.ERR_NAVIGATION_ITEM_INVALID=xe;exports.ERR_PARSE=Z;exports.ERR_SSR_INIT=Ae;exports.ERR_TIMED_OUT=xt;exports.ERR_UNEXPECTED_TYPE=At;exports.ERR_UNKNOWN_ENV=Tt;exports.EventEmitter=S;exports.HapticFeedback=ae;exports.InitData=ce;exports.Invoice=he;exports.MainButton=pe;exports.MiniApp=le;exports.Popup=de;exports.QRScanner=_e;exports.SDKError=q;exports.SettingsButton=fe;exports.ThemeParams=ge;exports.Utils=be;exports.Viewport=we;exports.array=ie;exports.bindMiniAppCSSVars=fs;exports.bindThemeParamsCSSVars=gs;exports.bindViewportCSSVars=bs;exports.boolean=w;exports.captureSameReq=rt;exports.classNames=V;exports.compareVersions=Vt;exports.createBrowserNavigatorFromLocation=Ee;exports.createPostEvent=$t;exports.createSafeURL=I;exports.date=ht;exports.getHash=Ps;exports.getPathname=gt;exports.initBackButton=Fe;exports.initBiometryManager=Je;exports.initClosingBehavior=Ye;exports.initCloudStorage=Xe;exports.initHapticFeedback=Ze;exports.initInitData=ts;exports.initInvoice=ss;exports.initMainButton=ns;exports.initMiniApp=os;exports.initNavigator=Ts;exports.initPopup=cs;exports.initQRScanner=hs;exports.initSettingsButton=ps;exports.initThemeParams=us;exports.initUtils=ds;exports.initViewport=_s;exports.initWeb=ws;exports.invokeCustomMethod=v;exports.isColorDark=ot;exports.isIframe=nt;exports.isPageReload=ut;exports.isRGB=L;exports.isRGBShort=Dt;exports.isSDKError=me;exports.isSDKErrorOfType=vs;exports.isSSR=ms;exports.isTMA=ys;exports.json=l;exports.mergeClassNames=Be;exports.mockTelegramEnv=Es;exports.number=y;exports.off=k;exports.on=b;exports.parseInitData=es;exports.parseLaunchParams=$;exports.parseThemeParams=_t;exports.postEvent=P;exports.request=d;exports.requestBiometryInfo=ne;exports.requestThemeParams=ls;exports.requestViewport=ft;exports.retrieveLaunchParams=te;exports.rgb=st;exports.searchParams=U;exports.serializeLaunchParams=Xt;exports.serializeThemeParams=pt;exports.setCSSVar=m;exports.setDebug=Te;exports.setTargetOrigin=Ve;exports.string=h;exports.subscribe=St;exports.supports=E;exports.targetOrigin=Ut;exports.toRGB=et;exports.unsubscribe=K;exports.urlToPath=N;exports.withTimeout=it;
|
|
1
|
+
"use strict";var Se=Object.defineProperty;var Pe=(e,t,s)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var c=(e,t,s)=>Pe(e,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function yt(e,t){let s;const n=()=>{s!==void 0&&t&&t(s),s=void 0};return[()=>s===void 0?s=e(n):s,n]}function K(e){const t=L(),{count:s}=t;t.unsubscribe(e),s&&!t.count&&Me()}function Et(e){return L().subscribe(e),()=>K(e)}class Re{constructor(t,s={}){this.scope=t,this.options=s}print(t,...s){const n=new Date,r=Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(n),{textColor:i,bgColor:o}=this.options,a="font-weight: bold;padding: 0 5px;border-radius:5px";console[t](`%c${r}%c / %c${this.scope}`,`${a};background-color: lightblue;color:black`,"",`${a};${i?`color:${i};`:""}${o?`background-color:${o}`:""}`,...s)}error(...t){this.print("error",...t)}log(...t){this.print("log",...t)}}const Q=new Re("SDK",{bgColor:"forestgreen",textColor:"white"});let F=!1;const gt=({name:e,payload:t})=>{Q.log("Event received:",t?{name:e,payload:t}:{name:e})};function Te(e){F!==e&&(F=e,e?Et(gt):K(gt))}function Ce(...e){F&&Q.log(...e)}class S{constructor(){c(this,"listeners",new Map);c(this,"listenersCount",0);c(this,"subscribeListeners",[])}clear(){this.listeners.clear(),this.subscribeListeners=[]}get count(){return this.listenersCount+this.subscribeListeners.length}emit(t,...s){this.subscribeListeners.forEach(r=>r({event:t,args:s})),(this.listeners.get(t)||[]).forEach(([r,i])=>{r(...s),i&&this.off(t,r)})}on(t,s,n){let r=this.listeners.get(t);return r||this.listeners.set(t,r=[]),r.push([s,n]),this.listenersCount+=1,()=>this.off(t,s)}off(t,s){const n=this.listeners.get(t)||[];for(let r=0;r<n.length;r+=1)if(s===n[r][0]){n.splice(r,1),this.listenersCount-=1;return}}subscribe(t){return this.subscribeListeners.push(t),()=>this.unsubscribe(t)}unsubscribe(t){for(let s=0;s<this.subscribeListeners.length;s+=1)if(this.subscribeListeners[s]===t){this.subscribeListeners.splice(s,1);return}}}function J(e,t,s){return window.addEventListener(e,t,s),()=>window.removeEventListener(e,t,s)}function X(...e){let t=!1;const s=e.flat(1);return[n=>!t&&s.push(n),()=>{t||(t=!0,s.forEach(n=>n()))},t]}class q extends Error{constructor(t,s,n){super(s,{cause:n}),this.type=t,Object.setPrototypeOf(this,q.prototype)}}function f(e,t,s){return new q(e,t,s)}const vt="ERR_METHOD_UNSUPPORTED",St="ERR_METHOD_PARAMETER_UNSUPPORTED",Pt="ERR_UNKNOWN_ENV",Rt="ERR_INVOKE_CUSTOM_METHOD_RESPONSE",Tt="ERR_TIMED_OUT",Ct="ERR_UNEXPECTED_TYPE",Z="ERR_PARSE",At="ERR_NAVIGATION_LIST_EMPTY",It="ERR_NAVIGATION_CURSOR_INVALID",Ae="ERR_NAVIGATION_ITEM_INVALID",Ie="ERR_SSR_INIT",xt="ERR_INVALID_PATH_BASE";function T(){return f(Ct,"Value has unexpected type")}class B{constructor(t,s,n){this.parser=t,this.isOptional=s,this.type=n}parse(t){if(!(this.isOptional&&t===void 0))try{return this.parser(t)}catch(s){throw f(Z,`Unable to parse value${this.type?` as ${this.type}`:""}`,s)}}optional(){return this.isOptional=!0,this}}function C(e,t){return()=>new B(e,!1,t)}const w=C(e=>{if(typeof e=="boolean")return e;const t=String(e);if(t==="1"||t==="true")return!0;if(t==="0"||t==="false")return!1;throw T()},"boolean");function Nt(e,t){const s={};for(const n in e){const r=e[n];if(!r)continue;let i,o;if(typeof r=="function"||"parse"in r)i=n,o=typeof r=="function"?r:r.parse.bind(r);else{const{type:a}=r;i=r.from||n,o=typeof a=="function"?a:a.parse.bind(a)}try{const a=o(t(i));a!==void 0&&(s[n]=a)}catch(a){throw f(Z,`Unable to parse field "${n}"`,a)}}return s}function qt(e){let t=e;if(typeof t=="string"&&(t=JSON.parse(t)),typeof t!="object"||t===null||Array.isArray(t))throw T();return t}function g(e,t){return new B(s=>{const n=qt(s);return Nt(e,r=>n[r])},!1,t)}const y=C(e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=Number(e);if(!Number.isNaN(t))return t}throw T()},"number"),p=C(e=>{if(typeof e=="string"||typeof e=="number")return e.toString();throw T()},"string");function kt(e){return g({eventType:p(),eventData:t=>t}).parse(e)}function xe(){["TelegramGameProxy_receiveEvent","TelegramGameProxy","Telegram"].forEach(e=>{delete window[e]})}function Y(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}function Ne(){[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["Telegram","WebView","receiveEvent"]].forEach(e=>{let t=window;e.forEach((s,n,r)=>{if(n===r.length-1){t[s]=Y;return}s in t||(t[s]={}),t=t[s]})})}const qe={clipboard_text_received:g({req_id:p(),data:e=>e===null?e:p().optional().parse(e)}),custom_method_invoked:g({req_id:p(),result:e=>e,error:p().optional()}),popup_closed:{parse(e){return g({button_id:t=>t==null?void 0:p().parse(t)}).parse(e??{})}},viewport_changed:g({height:y(),width:e=>e==null?window.innerWidth:y().parse(e),is_state_stable:w(),is_expanded:w()})};function ke(){const e=new S,t=new S;t.subscribe(n=>{e.emit("event",{name:n.event,payload:n.args[0]})}),Ne();const[,s]=X(xe,J("resize",()=>{t.emit("viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0})}),J("message",n=>{if(n.source!==window.parent)return;let r;try{r=kt(n.data)}catch{return}const{eventType:i,eventData:o}=r,a=qe[i];try{const h=a?a.parse(o):o;t.emit(...h?[i,h]:[i])}catch(h){Q.error(`An error occurred processing the "${i}" event from the Telegram application.
|
|
2
|
+
Please, file an issue here:
|
|
3
|
+
https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,r,h)}}),()=>e.clear(),()=>t.clear());return[{on:t.on.bind(t),off:t.off.bind(t),subscribe(n){return e.on("event",n)},unsubscribe(n){e.off("event",n)},get count(){return t.count+e.count}},s]}const[De,Me]=yt(e=>{const[t,s]=ke(),n=t.off.bind(t);return t.off=(r,i)=>{const{count:o}=t;n(r,i),o&&!t.count&&e()},[t,s]},([,e])=>e());function L(){return De()[0]}function k(e,t){L().off(e,t)}function b(e,t,s){return L().on(e,t,s)}function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Dt(e,t){const s=e.split("."),n=t.split("."),r=Math.max(s.length,n.length);for(let i=0;i<r;i+=1){const o=parseInt(s[i]||"0",10),a=parseInt(n[i]||"0",10);if(o!==a)return o>a?1:-1}return 0}function _(e,t){return Dt(e,t)<=0}function E(e,t,s){if(typeof s=="string"){if(e==="web_app_open_link"){if(t==="try_instant_view")return _("6.4",s);if(t==="try_browser")return _("7.6",s)}if(e==="web_app_set_header_color"&&t==="color")return _("6.9",s);if(e==="web_app_close"&&t==="return_back")return _("7.6",s)}switch(e){case"web_app_open_tg_link":case"web_app_open_invoice":case"web_app_setup_back_button":case"web_app_set_background_color":case"web_app_set_header_color":case"web_app_trigger_haptic_feedback":return _("6.1",t);case"web_app_open_popup":return _("6.2",t);case"web_app_close_scan_qr_popup":case"web_app_open_scan_qr_popup":case"web_app_read_text_from_clipboard":return _("6.4",t);case"web_app_switch_inline_query":return _("6.7",t);case"web_app_invoke_custom_method":case"web_app_request_write_access":case"web_app_request_phone":return _("6.9",t);case"web_app_setup_settings_button":return _("6.10",t);case"web_app_biometry_get_info":case"web_app_biometry_open_settings":case"web_app_biometry_request_access":case"web_app_biometry_request_auth":case"web_app_biometry_update_token":return _("7.2",t);default:return["iframe_ready","iframe_will_reload","web_app_close","web_app_data_send","web_app_expand","web_app_open_link","web_app_ready","web_app_request_theme","web_app_request_viewport","web_app_setup_main_button","web_app_setup_closing_behavior"].includes(e)}}function Mt(e){return"external"in e&&D(e.external)&&"notify"in e.external&&typeof e.external.notify=="function"}function Vt(e){return"TelegramWebviewProxy"in e&&D(e.TelegramWebviewProxy)&&"postEvent"in e.TelegramWebviewProxy&&typeof e.TelegramWebviewProxy.postEvent=="function"}function tt(){try{return window.self!==window.top}catch{return!0}}const Ve="https://web.telegram.org";let Bt=Ve;function Be(e){Bt=e}function Lt(){return Bt}function P(e,t,s){let n={},r;if(!t&&!s?n={}:t&&s?(n=s,r=t):t&&("targetOrigin"in t?n=t:r=t),Ce("Posting event:",r?{event:e,data:r}:{event:e}),tt())return window.parent.postMessage(JSON.stringify({eventType:e,eventData:r}),n.targetOrigin||Lt());if(Mt(window)){window.external.notify(JSON.stringify({eventType:e,eventData:r}));return}if(Vt(window)){window.TelegramWebviewProxy.postEvent(e,JSON.stringify(r));return}throw f(Pt,"Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside the Telegram application environment.")}function Ot(e){return(t,s)=>{if(!E(t,e))throw f(vt,`Method "${t}" is unsupported in Mini Apps version ${e}`);if(D(s)&&t==="web_app_set_header_color"&&"color"in s&&!E(t,"color",e))throw f(St,`Parameter "color" of "${t}" method is unsupported in Mini Apps version ${e}`);return P(t,s)}}function et(e){return({req_id:t})=>t===e}function Ut(e){return f(Tt,`Timeout reached: ${e}ms`)}function st(e,t){return Promise.race([typeof e=="function"?e():e,new Promise((s,n)=>{setTimeout(()=>{n(Ut(t))},t)})])}async function l(e){let t;const s=new Promise(a=>t=a),{event:n,capture:r,timeout:i}=e,[,o]=X((Array.isArray(n)?n:[n]).map(a=>b(a,h=>{(!r||(Array.isArray(n)?r({event:a,payload:h}):r(h)))&&t(h)})));try{return(e.postEvent||P)(e.method,e.params),await(i?st(s,i):s)}finally{o()}}async function v(e,t,s,n={}){const{result:r,error:i}=await l({...n,method:"web_app_invoke_custom_method",event:"custom_method_invoked",params:{method:e,params:t,req_id:s},capture:et(s)});if(i)throw f(Rt,i);return r}function V(...e){return e.map(t=>{if(typeof t=="string")return t;if(D(t))return V(Object.entries(t).map(s=>s[1]&&s[0]));if(Array.isArray(t))return V(...t)}).filter(Boolean).join(" ")}function Le(...e){return e.reduce((t,s)=>(D(s)&&Object.entries(s).forEach(([n,r])=>{const i=V(t[n],r);i.length&&(t[n]=i)}),t),{})}function O(e){return/^#[\da-f]{6}$/i.test(e)}function $t(e){return/^#[\da-f]{3}$/i.test(e)}function nt(e){const t=e.replace(/\s/g,"").toLowerCase();if(O(t))return t;if($t(t)){let n="#";for(let r=0;r<3;r+=1)n+=t[1+r].repeat(2);return 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}\)$/);if(!s)throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);return s.slice(1).reduce((n,r)=>{const i=parseInt(r,10).toString(16);return n+(i.length===1?"0":"")+i},"#")}function rt(e){const t=nt(e);return Math.sqrt([.299,.587,.114].reduce((s,n,r)=>{const i=parseInt(t.slice(1+r*2,1+(r+1)*2),16);return s+i*i*n},0))<120}class Oe{constructor(t){c(this,"ee",new S);c(this,"on",this.ee.on.bind(this.ee));c(this,"off",this.ee.off.bind(this.ee));this.state=t}clone(){return{...this.state}}set(t,s){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)}get(t){return this.state[t]}}class it{constructor(t){c(this,"state");c(this,"get");c(this,"set");c(this,"clone");this.state=new Oe(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)}}function Wt(e,t){return s=>E(t[s],e)}class ot extends it{constructor(s,n,r){super(s);c(this,"supports");this.supports=Wt(n,r)}}class Ht extends ot{constructor(s,n,r){super({isVisible:s},n,{show:"web_app_setup_back_button",hide:"web_app_setup_back_button"});c(this,"on",(s,n)=>s==="click"?b("back_button_pressed",n):this.state.on(s,n));c(this,"off",(s,n)=>s==="click"?k("back_button_pressed",n):this.state.off(s,n));this.postEvent=r}set isVisible(s){this.set("isVisible",s),this.postEvent("web_app_setup_back_button",{is_visible:s})}get isVisible(){return this.get("isVisible")}hide(){this.isVisible=!1}show(){this.isVisible=!0}}const at=C(e=>e instanceof Date?e:new Date(y().parse(e)*1e3),"Date");function U(e,t){return new B(s=>{if(typeof s!="string"&&!(s instanceof URLSearchParams))throw T();const n=typeof s=="string"?new URLSearchParams(s):s;return Nt(e,r=>{const i=n.get(r);return i===null?void 0:i})},!1,t)}const Ue=g({id:y(),type:p(),title:p(),photoUrl:{type:p().optional(),from:"photo_url"},username:p().optional()},"Chat").optional(),bt=g({addedToAttachmentMenu:{type:w().optional(),from:"added_to_attachment_menu"},allowsWriteToPm:{type:w().optional(),from:"allows_write_to_pm"},firstName:{type:p(),from:"first_name"},id:y(),isBot:{type:w().optional(),from:"is_bot"},isPremium:{type:w().optional(),from:"is_premium"},languageCode:{type:p().optional(),from:"language_code"},lastName:{type:p().optional(),from:"last_name"},photoUrl:{type:p().optional(),from:"photo_url"},username:p().optional()},"User").optional();function Gt(){return U({authDate:{type:at(),from:"auth_date"},canSendAfter:{type:y().optional(),from:"can_send_after"},chat:Ue,chatInstance:{type:p().optional(),from:"chat_instance"},chatType:{type:p().optional(),from:"chat_type"},hash:p(),queryId:{type:p().optional(),from:"query_id"},receiver:bt,startParam:{type:p().optional(),from:"start_param"},user:bt},"InitData")}const jt=C(e=>nt(p().parse(e)),"rgb");function $e(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function We(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}const zt=C(e=>{const t=jt().optional();return Object.entries(qt(e)).reduce((s,[n,r])=>(s[$e(n)]=t.parse(r),s),{})},"ThemeParams");function $(e){return U({botInline:{type:w().optional(),from:"tgWebAppBotInline"},initData:{type:Gt().optional(),from:"tgWebAppData"},initDataRaw:{type:p().optional(),from:"tgWebAppData"},platform:{type:p(),from:"tgWebAppPlatform"},showSettings:{type:w().optional(),from:"tgWebAppShowSettings"},startParam:{type:p().optional(),from:"tgWebAppStartParam"},themeParams:{type:zt(),from:"tgWebAppThemeParams"},version:{type:p(),from:"tgWebAppVersion"}}).parse(e)}function Ft(e){return $(e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&"))}function He(){return Ft(window.location.href)}function Jt(){return performance.getEntriesByType("navigation")[0]}function Ge(){const e=Jt();if(!e)throw new Error("Unable to get first navigation entry.");return Ft(e.name)}function Yt(e){return`tma.js/${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function Kt(e,t){sessionStorage.setItem(Yt(e),JSON.stringify(t))}function Qt(e){const t=sessionStorage.getItem(Yt(e));try{return t?JSON.parse(t):void 0}catch{}}function je(){return $(Qt("launchParams")||"")}function ct(e){return JSON.stringify(Object.fromEntries(Object.entries(e).map(([t,s])=>[We(t),s])))}function Xt(e){const{initDataRaw:t,themeParams:s,platform:n,version:r,showSettings:i,startParam:o,botInline:a}=e,h=new URLSearchParams;return h.set("tgWebAppPlatform",n),h.set("tgWebAppThemeParams",ct(s)),h.set("tgWebAppVersion",r),t&&h.set("tgWebAppData",t),o&&h.set("tgWebAppStartParam",o),typeof i=="boolean"&&h.set("tgWebAppShowSettings",i?"1":"0"),typeof a=="boolean"&&h.set("tgWebAppBotInline",a?"1":"0"),h.toString()}function Zt(e){Kt("launchParams",Xt(e))}function te(){for(const e of[He,Ge,je])try{const t=e();return Zt(t),t}catch{}throw new Error("Unable to retrieve launch parameters from any known source.")}function ht(){const e=Jt();return!!(e&&e.type==="reload")}function ze(){let e=0;return()=>(e+=1).toString()}const[Fe]=yt(ze);function d(e,t){return()=>{const s=te(),n={...s,postEvent:Ot(s.version),createRequestId:Fe()};if(typeof e=="function")return e(n);const[r,i,o]=X(),a=t({...n,state:ht()?Qt(e):void 0,addCleanup:r}),h=u=>(o||r(u.on("change",ve=>{Kt(e,ve)})),u);return[a instanceof Promise?a.then(h):h(a),i]}}const Je=d("backButton",({postEvent:e,version:t,state:s={isVisible:!1}})=>new Ht(s.isVisible,t,e));class M extends ot{constructor(){super(...arguments);c(this,"on",this.state.on.bind(this.state));c(this,"off",this.state.off.bind(this.state))}}function ee(e){const t=e.available?e:{available:!1,device_id:"",token_saved:!1,access_requested:!1,access_granted:!1,type:""};return{available:!0,type:t.type,deviceId:t.device_id,tokenSaved:t.token_saved,accessRequested:t.access_requested,accessGranted:t.access_granted}}class se extends M{constructor({postEvent:s,version:n,...r}){super(r,n,{auth:"web_app_biometry_request_auth",openSettings:"web_app_biometry_open_settings",requestAccess:"web_app_biometry_request_access",updateToken:"web_app_biometry_update_token"});c(this,"postEvent");c(this,"authPromise");c(this,"accessPromise");this.postEvent=s}get available(){return this.get("available")}get accessGranted(){return this.get("accessGranted")}get accessRequested(){return this.get("accessRequested")}async authenticate({reason:s,...n}){return this.authPromise||(this.authPromise=l({...n,method:"web_app_biometry_request_auth",event:"biometry_auth_requested",postEvent:this.postEvent,params:{reason:(s||"").trim()}}).then(({token:r})=>r).finally(()=>this.authPromise=void 0)),this.authPromise}get deviceId(){return this.get("deviceId")}openSettings(){this.postEvent("web_app_biometry_open_settings")}requestAccess({reason:s,...n}={}){return this.accessPromise||(this.accessPromise=l({...n,postEvent:this.postEvent,method:"web_app_biometry_request_access",event:"biometry_info_received",params:{reason:s||""}}).then(r=>{const i=ee(r);return this.set(i),i.accessGranted}).finally(()=>this.accessPromise=void 0)),this.accessPromise}get biometryType(){return this.get("biometryType")}get tokenSaved(){return this.get("tokenSaved")}async updateToken({token:s,...n}={}){return["removed","updated"].includes((await l({...n,postEvent:this.postEvent,method:"web_app_biometry_update_token",event:"biometry_token_updated",params:{token:s||""}})).status)}}async function ne(e){return ee(await l({...e||{},method:"web_app_biometry_get_info",event:"biometry_info_received"}))}const Ye=d("biometryManager",async({postEvent:e,version:t,state:s})=>new se({...s||E("web_app_biometry_get_info",t)?s||await ne({timeout:1e3}):{available:!1,accessGranted:!1,accessRequested:!1,tokenSaved:!1,deviceId:""},version:t,postEvent:e}));class pt extends it{constructor(){super(...arguments);c(this,"on",this.state.on.bind(this.state));c(this,"off",this.state.off.bind(this.state))}}class re extends pt{constructor(t,s){super({isConfirmationNeeded:t}),this.postEvent=s}set isConfirmationNeeded(t){this.set("isConfirmationNeeded",t),this.postEvent("web_app_setup_closing_behavior",{need_confirmation:t})}get isConfirmationNeeded(){return this.get("isConfirmationNeeded")}disableConfirmation(){this.isConfirmationNeeded=!1}enableConfirmation(){this.isConfirmationNeeded=!0}}const Ke=d("closingBehavior",({postEvent:e,state:t={isConfirmationNeeded:!1}})=>new re(t.isConfirmationNeeded,e));class ut{constructor(t,s){c(this,"supports");this.supports=Wt(t,s)}}function Qe(e){if(Array.isArray(e))return e;if(typeof e=="string")try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch{}throw T()}class Xe extends B{constructor(s,n,r){super(Qe,n,r);c(this,"itemParser");this.itemParser=typeof s=="function"?s:s.parse.bind(s)}parse(s){const n=super.parse(s);return n===void 0?n:n.map(this.itemParser)}of(s){return this.itemParser=typeof s=="function"?s:s.parse.bind(s),this}}function ie(e){return new Xe(t=>t,!1,e)}function wt(e,t){return Object.fromEntries(e.map(s=>[s,t]))}class oe extends ut{constructor(t,s,n){super(t,{delete:"web_app_invoke_custom_method",get:"web_app_invoke_custom_method",getKeys:"web_app_invoke_custom_method",set:"web_app_invoke_custom_method"}),this.createRequestId=s,this.postEvent=n}async delete(t,s={}){const n=Array.isArray(t)?t:[t];n.length&&await v("deleteStorageValues",{keys:n},this.createRequestId(),{...s,postEvent:this.postEvent})}async getKeys(t={}){return ie().of(p()).parse(await v("getStorageKeys",{},this.createRequestId(),{...t,postEvent:this.postEvent}))}async get(t,s={}){const n=Array.isArray(t)?t:[t];if(!n.length)return wt(n,"");const r=await v("getStorageValues",{keys:n},this.createRequestId(),{...s,postEvent:this.postEvent}),i=g(wt(n,p()),"CloudStorageData").parse(r);return Array.isArray(t)?i:i[t]}async set(t,s,n={}){await v("saveStorageValue",{key:t,value:s},this.createRequestId(),{...n,postEvent:this.postEvent})}}const Ze=d(({createRequestId:e,postEvent:t,version:s})=>new oe(s,e,t));class ae extends ut{constructor(t,s){super(t,{impactOccurred:"web_app_trigger_haptic_feedback",notificationOccurred:"web_app_trigger_haptic_feedback",selectionChanged:"web_app_trigger_haptic_feedback"}),this.postEvent=s}impactOccurred(t){this.postEvent("web_app_trigger_haptic_feedback",{type:"impact",impact_style:t})}notificationOccurred(t){this.postEvent("web_app_trigger_haptic_feedback",{type:"notification",notification_type:t})}selectionChanged(){this.postEvent("web_app_trigger_haptic_feedback",{type:"selection_change"})}}const ts=d(({version:e,postEvent:t})=>new ae(e,t));class ce{constructor(t){this.initData=t}get authDate(){return this.initData.authDate}get canSendAfter(){return this.initData.canSendAfter}get canSendAfterDate(){const{canSendAfter:t}=this;return t?new Date(this.authDate.getTime()+t*1e3):void 0}get chat(){return this.initData.chat}get chatType(){return this.initData.chatType}get chatInstance(){return this.initData.chatInstance}get hash(){return this.initData.hash}get queryId(){return this.initData.queryId}get receiver(){return this.initData.receiver}get startParam(){return this.initData.startParam}get user(){return this.initData.user}}const es=d(({initData:e})=>e?new ce(e):void 0);function ss(e){return Gt().parse(e)}class he extends M{constructor(t,s,n){super({isOpened:t},s,{open:"web_app_open_invoice"}),this.postEvent=n}set isOpened(t){this.set("isOpened",t)}get isOpened(){return this.get("isOpened")}async open(t,s){if(this.isOpened)throw new Error("Invoice is already opened");let n;if(!s)n=t;else{const{hostname:r,pathname:i}=new URL(t,window.location.href);if(r!=="t.me")throw new Error(`Incorrect hostname: ${r}`);const o=i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);if(!o)throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');[,,n]=o}this.isOpened=!0;try{return(await l({method:"web_app_open_invoice",event:"invoice_closed",params:{slug:n},postEvent:this.postEvent,capture(i){return n===i.slug}})).status}finally{this.isOpened=!1}}}const ns=d(({version:e,postEvent:t})=>new he(!1,e,t));class pe extends it{constructor({postEvent:s,...n}){super(n);c(this,"postEvent");c(this,"on",(s,n)=>s==="click"?b("main_button_pressed",n):this.state.on(s,n));c(this,"off",(s,n)=>s==="click"?k("main_button_pressed",n):this.state.off(s,n));this.postEvent=s}get bgColor(){return this.get("bgColor")}commit(){this.text!==""&&this.postEvent("web_app_setup_main_button",{is_visible:this.isVisible,is_active:this.isEnabled,is_progress_visible:this.isLoaderVisible,text:this.text,color:this.bgColor,text_color:this.textColor})}disable(){return this.isEnabled=!1,this}enable(){return this.isEnabled=!0,this}hide(){return this.isVisible=!1,this}hideLoader(){return this.isLoaderVisible=!1,this}set isEnabled(s){this.setParams({isEnabled:s})}get isEnabled(){return this.get("isEnabled")}set isLoaderVisible(s){this.setParams({isLoaderVisible:s})}get isLoaderVisible(){return this.get("isLoaderVisible")}set isVisible(s){this.setParams({isVisible:s})}get isVisible(){return this.get("isVisible")}show(){return this.isVisible=!0,this}showLoader(){return this.isLoaderVisible=!0,this}setText(s){return this.setParams({text:s})}setTextColor(s){return this.setParams({textColor:s})}setBgColor(s){return this.setParams({bgColor:s})}setParams(s){return this.set(s),this.commit(),this}get text(){return this.get("text")}get textColor(){return this.get("textColor")}}const rs=d("mainButton",({postEvent:e,themeParams:t,state:s={isVisible:!1,isEnabled:!1,text:"",isLoaderVisible:!1,textColor:t.buttonTextColor||"#ffffff",bgColor:t.buttonColor||"#000000"}})=>new pe({...s,postEvent:e}));function is(){return U({contact:g({userId:{type:y(),from:"user_id"},phoneNumber:{type:p(),from:"phone_number"},firstName:{type:p(),from:"first_name"},lastName:{type:p().optional(),from:"last_name"}}),authDate:{type:at(),from:"auth_date"},hash:p()},"RequestedContact")}function ue(e,t){return s=>{const[n,r]=t[s];return E(n,r,e)}}function os(e){return new Promise(t=>{setTimeout(t,e)})}class le extends M{constructor({postEvent:s,createRequestId:n,version:r,botInline:i,...o}){super(o,r,{requestPhoneAccess:"web_app_request_phone",requestWriteAccess:"web_app_request_write_access",switchInlineQuery:"web_app_switch_inline_query",setHeaderColor:"web_app_set_header_color",setBackgroundColor:"web_app_set_background_color"});c(this,"botInline");c(this,"postEvent");c(this,"createRequestId");c(this,"requestPhoneAccessPromise");c(this,"requestWriteAccessPromise");c(this,"supportsParam");this.createRequestId=n,this.postEvent=s,this.botInline=i;const a=this.supports.bind(this);this.supports=h=>a(h)?h!=="switchInlineQuery"||i:!1,this.supportsParam=ue(r,{"setHeaderColor.color":["web_app_set_header_color","color"]})}async getRequestedContact({timeout:s=1e4}={}){return is().parse(await v("getRequestedContact",{},this.createRequestId(),{postEvent:this.postEvent,timeout:s}))}get bgColor(){return this.get("bgColor")}close(s){this.postEvent("web_app_close",{return_back:s})}get headerColor(){return this.get("headerColor")}get isBotInline(){return this.botInline}get isDark(){return rt(this.bgColor)}ready(){this.postEvent("web_app_ready")}async requestContact({timeout:s=5e3}={}){try{return await this.getRequestedContact()}catch{}if(await this.requestPhoneAccess()!=="sent")throw new Error("Access denied.");const r=Date.now()+s;let i=50;return st(async()=>{for(;Date.now()<r;){try{return await this.getRequestedContact()}catch{}await os(i),i+=50}throw Ut(s)},s)}async requestPhoneAccess(s={}){return this.requestPhoneAccessPromise||(this.requestPhoneAccessPromise=l({...s,method:"web_app_request_phone",event:"phone_requested",postEvent:this.postEvent}).then(({status:n})=>n).finally(()=>this.requestPhoneAccessPromise=void 0)),this.requestPhoneAccessPromise}async requestWriteAccess(s={}){return this.requestWriteAccessPromise||(this.requestWriteAccessPromise=l({...s,method:"web_app_request_write_access",event:"write_access_requested",postEvent:this.postEvent}).then(({status:n})=>n).finally(()=>this.requestWriteAccessPromise=void 0)),this.requestWriteAccessPromise}sendData(s){const{size:n}=new Blob([s]);if(!n||n>4096)throw new Error(`Passed data has incorrect size: ${n}`);this.postEvent("web_app_data_send",{data:s})}setHeaderColor(s){this.postEvent("web_app_set_header_color",O(s)?{color:s}:{color_key:s}),this.set("headerColor",s)}setBgColor(s){this.postEvent("web_app_set_background_color",{color:s}),this.set("bgColor",s)}switchInlineQuery(s,n=[]){if(!this.supports("switchInlineQuery")&&!this.isBotInline)throw new Error("Method is unsupported because Mini App should be launched in inline mode.");this.postEvent("web_app_switch_inline_query",{query:s,chat_types:n})}}const as=d("miniApp",({themeParams:e,botInline:t=!1,state:s={bgColor:e.bgColor||"#ffffff",headerColor:e.headerBgColor||"#000000"},...n})=>new le({...n,...s,botInline:t}));function cs(e){const t=e.message.trim(),s=(e.title||"").trim(),n=e.buttons||[];let r;if(s.length>64)throw new Error(`Title has incorrect size: ${s.length}`);if(!t.length||t.length>256)throw new Error(`Message has incorrect size: ${t.length}`);if(n.length>3)throw new Error(`Buttons have incorrect size: ${n.length}`);return n.length?r=n.map(i=>{const{id:o=""}=i;if(o.length>64)throw new Error(`Button ID has incorrect size: ${o}`);if(!i.type||i.type==="default"||i.type==="destructive"){const a=i.text.trim();if(!a.length||a.length>64){const h=i.type||"default";throw new Error(`Button text with type "${h}" has incorrect size: ${i.text.length}`)}return{...i,text:a,id:o}}return{...i,id:o}}):r=[{type:"close",id:""}],{title:s,message:t,buttons:r}}class de extends M{constructor(t,s,n){super({isOpened:t},s,{open:"web_app_open_popup"}),this.postEvent=n}set isOpened(t){this.set("isOpened",t)}get isOpened(){return this.get("isOpened")}async open(t){if(this.isOpened)throw new Error("Popup is already opened.");this.isOpened=!0;try{const{button_id:s=null}=await l({event:"popup_closed",method:"web_app_open_popup",postEvent:this.postEvent,params:cs(t)});return s}finally{this.isOpened=!1}}}const hs=d(({postEvent:e,version:t})=>new de(!1,t,e));class _e extends M{constructor(t,s,n){super({isOpened:t},s,{close:"web_app_close_scan_qr_popup",open:"web_app_open_scan_qr_popup"}),this.postEvent=n}close(){this.postEvent("web_app_close_scan_qr_popup"),this.isOpened=!1}set isOpened(t){this.set("isOpened",t)}get isOpened(){return this.get("isOpened")}async open(t){if(this.isOpened)throw new Error("The scanner is already opened");const{text:s,capture:n}=(typeof t=="string"?{text:t}:t)||{};this.isOpened=!0;try{const i=(await l({method:"web_app_open_scan_qr_popup",event:["qr_text_received","scan_qr_popup_closed"],postEvent:this.postEvent,params:{text:s},capture(o){return o.event==="scan_qr_popup_closed"||!n||n(o.payload)}})||{}).data||null;return i&&this.close(),i}finally{this.isOpened=!1}}}const ps=d(({version:e,postEvent:t})=>new _e(!1,e,t));class fe extends ot{constructor(s,n,r){super({isVisible:s},n,{show:"web_app_setup_settings_button",hide:"web_app_setup_settings_button"});c(this,"on",(s,n)=>s==="click"?b("settings_button_pressed",n):this.state.on(s,n));c(this,"off",(s,n)=>s==="click"?k("settings_button_pressed",n):this.state.off(s,n));this.postEvent=r}set isVisible(s){this.set("isVisible",s),this.postEvent("web_app_setup_settings_button",{is_visible:s})}get isVisible(){return this.get("isVisible")}hide(){this.isVisible=!1}show(){this.isVisible=!0}}const us=d("settingsButton",({version:e,postEvent:t,state:s={isVisible:!1}})=>new fe(s.isVisible,e,t));function lt(e){return zt().parse(e)}class ge extends pt{get accentTextColor(){return this.get("accentTextColor")}get bgColor(){return this.get("bgColor")}get buttonColor(){return this.get("buttonColor")}get buttonTextColor(){return this.get("buttonTextColor")}get destructiveTextColor(){return this.get("destructiveTextColor")}getState(){return this.clone()}get headerBgColor(){return this.get("headerBgColor")}get hintColor(){return this.get("hintColor")}get isDark(){return!this.bgColor||rt(this.bgColor)}get linkColor(){return this.get("linkColor")}get secondaryBgColor(){return this.get("secondaryBgColor")}get sectionBgColor(){return this.get("sectionBgColor")}get sectionHeaderTextColor(){return this.get("sectionHeaderTextColor")}get sectionSeparatorColor(){return this.get("sectionHeaderTextColor")}listen(){return b("theme_changed",t=>{this.set(lt(t.theme_params))})}get subtitleTextColor(){return this.get("subtitleTextColor")}get textColor(){return this.get("textColor")}}const ls=d("themeParams",({themeParams:e,state:t=e,addCleanup:s})=>{const n=new ge(t);return s(n.listen()),n});function ds(e={}){return l({...e,method:"web_app_request_theme",event:"theme_changed"}).then(lt)}function x(e,t){return e.startsWith(t)?e:`${t}${e}`}function R(e){return new URL(typeof e=="string"?e:`${e.pathname||""}${x(e.search||"","?")}${x(e.hash||"","#")}`,"http://a")}class be extends ut{constructor(s,n,r){super(s,{readTextFromClipboard:"web_app_read_text_from_clipboard"});c(this,"supportsParam");this.version=s,this.createRequestId=n,this.postEvent=r,this.supportsParam=ue(s,{"openLink.tryInstantView":["web_app_open_link","try_instant_view"]})}openLink(s,n){const r=R(s).toString();if(!E("web_app_open_link",this.version)){window.open(r,"_blank");return}const i=typeof n=="boolean"?{tryInstantView:n}:n||{};this.postEvent("web_app_open_link",{url:r,try_browser:i.tryBrowser,try_instant_view:i.tryInstantView})}openTelegramLink(s){const{hostname:n,pathname:r,search:i}=new URL(s,"https://t.me");if(n!=="t.me")throw new Error(`URL has not allowed hostname: ${n}. Only "t.me" is allowed`);if(!E("web_app_open_tg_link",this.version)){window.location.href=s;return}this.postEvent("web_app_open_tg_link",{path_full:r+i})}async readTextFromClipboard(){const s=this.createRequestId(),{data:n=null}=await l({method:"web_app_read_text_from_clipboard",event:"clipboard_text_received",postEvent:this.postEvent,params:{req_id:s},capture:et(s)});return n}shareURL(s,n){this.openTelegramLink("https://t.me/share/url?"+new URLSearchParams({url:s,text:n||""}).toString().replace(/\+/g,"%20"))}}const _s=d(({version:e,postEvent:t,createRequestId:s})=>new be(e,s,t));async function dt(e={}){const{is_expanded:t,is_state_stable:s,...n}=await l({...e,method:"web_app_request_viewport",event:"viewport_changed"});return{...n,isExpanded:t,isStateStable:s}}function A(e){return e<0?0:e}class we extends pt{constructor({postEvent:s,stableHeight:n,height:r,width:i,isExpanded:o}){super({height:A(r),isExpanded:o,stableHeight:A(n),width:A(i)});c(this,"postEvent");this.postEvent=s}async sync(s){const{isStateStable:n,...r}=await dt(s);this.set({...r,stableHeight:n?r.height:this.get("stableHeight")})}get height(){return this.get("height")}get stableHeight(){return this.get("stableHeight")}listen(){return b("viewport_changed",s=>{const{height:n,width:r,is_expanded:i,is_state_stable:o}=s,a=A(n);this.set({height:a,isExpanded:i,width:A(r),...o?{stableHeight:a}:{}})})}get isExpanded(){return this.get("isExpanded")}get width(){return this.get("width")}expand(){this.postEvent("web_app_expand"),this.set("isExpanded",!0)}get isStable(){return this.stableHeight===this.height}}const fs=d("viewport",async({state:e,platform:t,postEvent:s,addCleanup:n})=>{let r=!1,i=0,o=0,a=0;if(e)r=e.isExpanded,i=e.height,o=e.width,a=e.stableHeight;else if(["macos","tdesktop","unigram","webk","weba","web"].includes(t))r=!0,i=window.innerHeight,o=window.innerWidth,a=window.innerHeight;else{const u=await dt({timeout:1e3,postEvent:s});r=u.isExpanded,i=u.height,o=u.width,a=u.isStateStable?i:0}const h=new we({postEvent:s,height:i,width:o,stableHeight:a,isExpanded:r});return n(h.listen()),h});function m(e,t){document.documentElement.style.setProperty(e,t)}function gs(e,t,s){s||(s=a=>`--tg-${a}-color`);const n=s("header"),r=s("bg"),i=()=>{const{headerColor:a}=e;if(O(a))m(n,a);else{const{bgColor:h,secondaryBgColor:u}=t;a==="bg_color"&&h?m(n,h):a==="secondary_bg_color"&&u&&m(n,u)}m(r,e.bgColor)},o=[t.on("change",i),e.on("change",i)];return i(),()=>o.forEach(a=>a())}function bs(e,t){t||(t=n=>`--tg-theme-${n.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`)}`);const s=()=>{Object.entries(e.getState()).forEach(([n,r])=>{r&&m(t(n),r)})};return s(),e.on("change",s)}function ws(e,t){t||(t=u=>`--tg-viewport-${u}`);const[s,n,r]=["height","width","stable-height"].map(u=>t(u)),i=()=>m(s,`${e.height}px`),o=()=>m(n,`${e.width}px`),a=()=>m(r,`${e.stableHeight}px`),h=[e.on("change:height",i),e.on("change:width",o),e.on("change:stableHeight",a)];return i(),o(),a(),()=>h.forEach(u=>u())}function ms(e=!0){const t=[b("reload_iframe",()=>{P("iframe_will_reload"),window.location.reload()})],s=()=>t.forEach(n=>n());if(e){const n=document.createElement("style");n.id="telegram-custom-styles",document.head.appendChild(n),t.push(b("set_custom_style",r=>{n.innerHTML=r}),()=>document.head.removeChild(n))}return P("iframe_ready",{reload_supported:!0}),s}function ys(){return typeof window>"u"}async function Es(){if(Vt(window))return!0;try{return await l({method:"web_app_request_theme",event:"theme_changed",timeout:100}),!0}catch{return!1}}function vs(e){const t=typeof e=="string"?$(e):e;Zt(t);function s(r){if(typeof r=="string")try{const{eventType:i}=kt(r);i==="web_app_request_theme"&&Y("theme_changed",{theme_params:JSON.parse(ct(t.themeParams))}),i==="web_app_request_viewport"&&Y("viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0})}catch{}}if(tt()){const r=window.parent.postMessage.bind(window.parent);window.parent.postMessage=i=>{s(i),r(i)};return}if(Mt(window)){const r=window.external.notify.bind(window.external);window.external.notify=i=>{s(i),r(i)};return}const n=window.TelegramWebviewProxy;window.TelegramWebviewProxy={...n||{},postEvent(...r){s(JSON.stringify({eventType:r[0],eventData:r[1]})),n&&n.postEvent(...r)}}}function me(e){return e instanceof q}function Ss(e,t){return me(e)&&e.type===t}function W(e,t){let s,n,r;return typeof e=="string"?s=e:(s=e.pathname===void 0?t:e.pathname,n=e.params,r=e.id),Object.freeze({id:r||(Math.random()*2**14|0).toString(16),pathname:s,params:n})}class ye{constructor(t,s,n=P){c(this,"history");c(this,"ee",new S);c(this,"attached",!1);c(this,"back",()=>this.go(-1));c(this,"on",this.ee.on.bind(this.ee));c(this,"off",this.ee.off.bind(this.ee));if(this._index=s,this.postEvent=n,t.length===0)throw f(At,"History should not be empty.");if(s<0||s>=t.length)throw f(It,"Index should not be zero and higher or equal than history size.");this.history=t.map(r=>W(r,""))}attach(){this.attached||(this.attached=!0,this.sync(),b("back_button_pressed",this.back))}get current(){return this.history[this.index]}detach(){this.attached=!1,k("back_button_pressed",this.back)}forward(){this.go(1)}go(t,s){const n=this.index+t,r=Math.min(Math.max(0,n),this.history.length-1);(n===r||s)&&this.replaceAndMove(r,this.history[r])}goTo(t,s){this.go(t-this.index,s)}get hasPrev(){return this.index>0}get hasNext(){return this.index!==this.history.length-1}get index(){return this._index}push(t){this.hasNext&&this.history.splice(this.index+1),this.replaceAndMove(this.index+1,W(t,this.current.pathname))}replace(t){this.replaceAndMove(this.index,W(t,this.current.pathname))}replaceAndMove(t,s){const n=t-this.index;if(!n&&this.current===s)return;const r=this.current;if(this.index!==t){const i=this._index;this._index=t,this.attached&&i>0!=t>0&&this.sync()}this.history[t]=s,this.ee.emit("change",{navigator:this,from:r,to:this.current,delta:n})}sync(){this.postEvent("web_app_setup_back_button",{is_visible:!!this.index})}}function H({params:e,...t}){return{...e||{hash:"",search:""},...t}}function N(e){const t=typeof e=="string"?e.startsWith("/"):!!(e.pathname&&e.pathname.startsWith("/")),s=R(e);return`${t?s.pathname:s.pathname.slice(1)}${s.search}${s.hash}`}function G(e,t,s){let n,r;typeof e=="string"?n=e:(n=N(e),s=e.state,r=e.id);const{pathname:i,search:o,hash:a}=new URL(n,`http://a${x(t,"/")}`);return{id:r,pathname:i,params:{hash:a,search:o,state:s}}}async function I(e){return e===0?!0:Promise.race([new Promise(t=>{const s=J("popstate",()=>{s(),t(!0)});window.history.go(e)}),new Promise(t=>{setTimeout(t,50,!1)})])}async function Ps(){if(window.history.length<=1||(window.history.pushState(null,""),await I(1-window.history.length)))return;let t=await I(-1);for(;t;)t=await I(-1)}function _t(e){return R(e).pathname}const mt=0,j=1,z=2;class ft{constructor(t,s,{postEvent:n,hashMode:r="classic",base:i}={}){c(this,"navigator");c(this,"ee",new S);c(this,"hashMode");c(this,"base");c(this,"attached",!1);c(this,"onPopState",({state:t})=>{if(t===null)return this.push(this.parsePath(window.location.href));t===mt?window.history.forward():t===j&&this.back(),t===z&&this.forward()});c(this,"onNavigatorChange",async({to:t,from:s,delta:n})=>{this.attached&&await this.syncHistory(),this.ee.emit("change",{delta:n,from:H(s),to:H(t),navigator:this})});c(this,"on",this.ee.on.bind(this.ee));c(this,"off",this.ee.off.bind(this.ee));this.navigator=new ye(t.map(o=>G(o,"/")),s,n),this.navigator.on("change",o=>{this.onNavigatorChange(o)}),this.hashMode=r,this.base=_t(i||"")}async attach(){this.attached||(this.attached=!0,this.navigator.attach(),window.addEventListener("popstate",this.onPopState),await this.syncHistory())}back(){this.navigator.back()}detach(){this.attached=!1,this.navigator.detach(),window.removeEventListener("popstate",this.onPopState)}forward(){return this.navigator.forward()}get index(){return this.navigator.index}get id(){return this.navigator.current.id}go(t,s){return this.navigator.go(t,s)}goTo(t,s){this.navigator.goTo(t,s)}get hash(){return(this.navigator.current.params||{}).hash||""}get hasPrev(){return this.navigator.hasPrev}get hasNext(){return this.navigator.hasNext}get history(){return this.navigator.history.map(H)}get path(){return N(this)}get pathname(){return this.navigator.current.pathname}parsePath(t){let s=R(t);return this.hashMode&&(s=R(s.hash.slice(1))),{pathname:s.pathname,search:s.search,hash:s.hash}}push(t,s){const n=G(t,this.path),{state:r=s}=n.params;this.navigator.push({...n,params:{...n.params,state:r}})}replace(t,s){const n=G(t,this.path),{state:r=s}=n.params;this.navigator.replace({...n,params:{...n.params,state:r}})}renderPath(t){const s=(this.base.length===1?"":this.base)+x(N(t),"/");return this.hashMode?x(s.slice(1),this.hashMode==="classic"?"#":"#/"):s}async syncHistory(){window.removeEventListener("popstate",this.onPopState);const{state:t}=this,s=this.renderPath(this);await Ps(),this.hasPrev&&this.hasNext?(window.history.replaceState(j,""),window.history.pushState(t,"",s),window.history.pushState(z,""),await I(-1)):this.hasPrev?(window.history.replaceState(j,""),window.history.pushState(t,"",s)):this.hasNext?(window.history.replaceState(t,s),window.history.pushState(z,""),await I(-1)):(window.history.replaceState(mt,""),window.history.pushState(t,"",s)),window.addEventListener("popstate",this.onPopState)}get search(){return(this.navigator.current.params||{}).search||""}get state(){return(this.navigator.current.params||{}).state}}function Ee(e){e||(e={});const{href:t,hash:s}=window.location;let n=N(e.hashMode===null?t:s.includes("?")?s.slice(1):`?${s.slice(1)}`);const r=e.base?_t(e.base):void 0;if(r){if(!n.startsWith(r))throw f(xt,`Path "${n}" expected to be starting with "${r}"`);n=n.slice(r.length)}return new ft([n],0,e)}function Rs(e){const t=e.match(/#(.+)/);return t?t[1]:null}function Ts(e,t){if(ht()){const s=sessionStorage.getItem(e);if(s)try{const{index:n,history:r}=JSON.parse(s);return new ft(r,n,t)}catch(n){console.error("Unable to restore hash navigator state.",n)}}return Ee(t)}function Cs(e,t){const s=Ts(e,t),n=()=>sessionStorage.setItem(e,JSON.stringify({index:s.index,history:s.history}));return s.on("change",n),n(),s}exports.BackButton=Ht;exports.BasicNavigator=ye;exports.BiometryManager=se;exports.BrowserNavigator=ft;exports.ClosingBehavior=re;exports.CloudStorage=oe;exports.ERR_INVALID_PATH_BASE=xt;exports.ERR_INVOKE_CUSTOM_METHOD_RESPONSE=Rt;exports.ERR_METHOD_PARAMETER_UNSUPPORTED=St;exports.ERR_METHOD_UNSUPPORTED=vt;exports.ERR_NAVIGATION_HISTORY_EMPTY=At;exports.ERR_NAVIGATION_INDEX_INVALID=It;exports.ERR_NAVIGATION_ITEM_INVALID=Ae;exports.ERR_PARSE=Z;exports.ERR_SSR_INIT=Ie;exports.ERR_TIMED_OUT=Tt;exports.ERR_UNEXPECTED_TYPE=Ct;exports.ERR_UNKNOWN_ENV=Pt;exports.EventEmitter=S;exports.HapticFeedback=ae;exports.InitData=ce;exports.Invoice=he;exports.MainButton=pe;exports.MiniApp=le;exports.Popup=de;exports.QRScanner=_e;exports.SDKError=q;exports.SettingsButton=fe;exports.ThemeParams=ge;exports.Utils=be;exports.Viewport=we;exports.array=ie;exports.bindMiniAppCSSVars=gs;exports.bindThemeParamsCSSVars=bs;exports.bindViewportCSSVars=ws;exports.boolean=w;exports.captureSameReq=et;exports.classNames=V;exports.compareVersions=Dt;exports.createBrowserNavigatorFromLocation=Ee;exports.createPostEvent=Ot;exports.createSafeURL=R;exports.date=at;exports.getHash=Rs;exports.getPathname=_t;exports.initBackButton=Je;exports.initBiometryManager=Ye;exports.initClosingBehavior=Ke;exports.initCloudStorage=Ze;exports.initHapticFeedback=ts;exports.initInitData=es;exports.initInvoice=ns;exports.initMainButton=rs;exports.initMiniApp=as;exports.initNavigator=Cs;exports.initPopup=hs;exports.initQRScanner=ps;exports.initSettingsButton=us;exports.initThemeParams=ls;exports.initUtils=_s;exports.initViewport=fs;exports.initWeb=ms;exports.invokeCustomMethod=v;exports.isColorDark=rt;exports.isIframe=tt;exports.isPageReload=ht;exports.isRGB=O;exports.isRGBShort=$t;exports.isSDKError=me;exports.isSDKErrorOfType=Ss;exports.isSSR=ys;exports.isTMA=Es;exports.json=g;exports.mergeClassNames=Le;exports.mockTelegramEnv=vs;exports.number=y;exports.off=k;exports.on=b;exports.parseInitData=ss;exports.parseLaunchParams=$;exports.parseThemeParams=lt;exports.postEvent=P;exports.request=l;exports.requestBiometryInfo=ne;exports.requestThemeParams=ds;exports.requestViewport=dt;exports.retrieveLaunchParams=te;exports.rgb=jt;exports.searchParams=U;exports.serializeLaunchParams=Xt;exports.serializeThemeParams=ct;exports.setCSSVar=m;exports.setDebug=Te;exports.setTargetOrigin=Be;exports.string=p;exports.subscribe=Et;exports.supports=E;exports.targetOrigin=Lt;exports.toRGB=nt;exports.unsubscribe=K;exports.urlToPath=N;exports.withTimeout=st;
|
|
2
4
|
//# sourceMappingURL=index.cjs.map
|