New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@telegram-apps/sdk

Package Overview
Dependencies
Maintainers
0
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@telegram-apps/sdk - npm Package Compare versions

Comparing version

to
2.10.0

2

dist/dts/scopes/components/mini-app/exports.d.ts
export { bindCssVars as bindMiniAppCssVars, close as closeMiniApp, isSupported as isMiniAppSupported, mount as mountMiniApp, ready as miniAppReady, setHeaderColor as setMiniAppHeaderColor, setBackgroundColor as setMiniAppBackgroundColor, setBottomBarColor as setMiniAppBottomBarColor, unmount as unmountMiniApp, } from './methods.js';
export { backgroundColor as miniAppBackgroundColor, bottomBarColor as miniAppBottomBarColor, bottomBarColorRGB as miniAppBottomBarColorRGB, headerColor as miniAppHeaderColor, headerColorRGB as miniAppHeaderColorRGB, isMounted as isMiniAppMounted, isCssVarsBound as isMiniAppCssVarsBound, isDark as isMiniAppDark, state as miniAppState, } from './signals.js';
export { backgroundColor as miniAppBackgroundColor, backgroundColorRGB as miniAppBackgroundColorRGB, bottomBarColor as miniAppBottomBarColor, bottomBarColorRGB as miniAppBottomBarColorRGB, headerColor as miniAppHeaderColor, headerColorRGB as miniAppHeaderColorRGB, isMounted as isMiniAppMounted, isCssVarsBound as isMiniAppCssVarsBound, isDark as isMiniAppDark, isActive as isMiniAppActive, state as miniAppState, } from './signals.js';
export type { HeaderColor as MiniAppHeaderColor, GetCssVarNameFn as MiniAppGetCssVarNameFn, State as MiniAppState, } from './types.js';
export * as miniApp from './exports.variable.js';

@@ -50,4 +50,8 @@ import { Computed } from '@telegram-apps/signals';

/**
* Signal indicating if the mini app is currently active.
*/
export declare const isActive: import('@telegram-apps/signals').Signal<boolean>;
/**
* Complete component state.
*/
export declare const state: Computed<State>;

@@ -10,2 +10,3 @@ import { HeaderColorKey, BottomBarColor, RGB, BackgroundColor } from '@telegram-apps/bridge';

headerColor: HeaderColor;
isActive: boolean;
}

@@ -12,0 +13,0 @@ export interface GetCssVarNameFn {

@@ -1,5 +0,5 @@

this.telegramApps=this.telegramApps||{};this.telegramApps.sdk=function(n){"use strict";class Q extends Error{constructor(t,o,r){super(typeof o=="object"?o.message:o||t,{cause:typeof o=="object"?o.cause:r}),this.type=t,Object.setPrototypeOf(this,Q.prototype)}}function lo(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function fi(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}const _o="ERR_INVALID_VALUE",fo="ERR_UNEXPECTED_VALUE",po="ERR_UNEXPECTED_TYPE",jt="ERR_PARSE";function mo(e,t){const o={};for(const r in e){const s=e[r];if(!s)continue;let a,i;typeof s=="function"?(a=r,i=s):[a,i]=s;try{const c=i(t(a));c!==void 0&&(o[r]=c)}catch(c){throw new Q(jt,`Parser for "${r}" property failed${a===r?"":`. Source field: "${a}"`}`,c)}}return o}function qt(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch(o){throw new Q(_o,{cause:o})}if(typeof t!="object"||!t||Array.isArray(t))throw new Q(fo);return t}function j(e,t){return o=>{const r=s=>{if(!(o&&s===void 0))try{return t(s)}catch(a){throw new Q(jt,{message:`"${e}" transformer failed to parse the value`,cause:a})}};return Object.assign(r,{isValid(s){try{return r(s),!0}catch{return!1}}})}}function He(e,t){return j(t||"object",o=>{const r=qt(o);return mo(e,s=>r[s])})}function Ae(e){throw new Q(po,`Unexpected value received: ${JSON.stringify(e)}`)}const di=j("boolean",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;Ae(e)}),q=j("string",e=>{if(typeof e=="string"||typeof e=="number")return e.toString();Ae(e)}),Fe=j("number",e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=Number(e);if(!Number.isNaN(t))return t}Ae(e)}),Ut=j("date",e=>e instanceof Date?e:new Date(Fe()(e)*1e3));function ho(e,t){return j(t||"searchParams",o=>{typeof o!="string"&&!(o instanceof URLSearchParams)&&Ae(o);const r=typeof o=="string"?new URLSearchParams(o):o;return mo(e,s=>{const a=r.get(s);return a===null?void 0:a})})}function Ht(e){for(const t in e)e[t]=[lo(t),e[t]];return e}const pi=e=>{const t=Fe(),o=Fe(!0),r=q(),s=q(!0),a=di(!0),i=He(Ht({addedToAttachmentMenu:a,allowsWriteToPm:a,firstName:r,id:t,isBot:a,isPremium:a,languageCode:s,lastName:s,photoUrl:s,username:s}),"User")(!0);return ho(Ht({authDate:Ut(),canSendAfter:o,chat:He(Ht({id:t,type:r,title:r,photoUrl:s,username:s}),"Chat")(!0),chatInstance:s,chatType:s,hash:r,queryId:s,receiver:i,startParam:s,signature:r,user:i}),"initData")(e)};function te(e){return/^#[\da-f]{6}$/i.test(e)}function bo(e){return/^#[\da-f]{3}$/i.test(e)}function Ft(e){const t=e.replace(/\s/g,"").toLowerCase();if(te(t))return t;if(bo(t)){let r="#";for(let s=0;s<3;s+=1)r+=t[1+s].repeat(2);return r}const o=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(!o)throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);return o.slice(1).reduce((r,s)=>{const a=parseInt(s,10).toString(16);return r+(a.length===1?"0":"")+a},"#")}const mi=j("rgb",e=>Ft(q()(e))),hi=j("themeParams",e=>{const t=mi(!0);return Object.entries(qt(e)).reduce((o,[r,s])=>(o[fi(r)]=t(s),o),{})});function Wt(e){return JSON.stringify(Object.fromEntries(Object.entries(e).map(([t,o])=>[lo(t),o])))}function bi(e){const{initDataRaw:t,startParam:o,showSettings:r,botInline:s,fullscreen:a,defaultColors:i}=e,c=new URLSearchParams;return c.set("tgWebAppPlatform",e.platform),c.set("tgWebAppThemeParams",Wt(e.themeParams)),c.set("tgWebAppVersion",e.version),t&&c.set("tgWebAppData",t),o&&c.set("tgWebAppStartParam",o),typeof r=="boolean"&&c.set("tgWebAppShowSettings",r?"1":"0"),typeof s=="boolean"&&c.set("tgWebAppBotInline",s?"1":"0"),typeof a=="boolean"&&c.set("tgWebAppFullscreen",a?"1":"0"),i&&c.set("tgWebAppDefaultColors",Wt(i)),c.toString()}function Ei(e,t){return j("array",o=>{let r;if(Array.isArray(o))r=o;else if(typeof o=="string")try{const s=JSON.parse(o);Array.isArray(s)&&(r=s)}catch{}return r||Ae(o),r.map(e)})}function Gt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function We(...e){return e.map(t=>{if(typeof t=="string")return t;if(Gt(t))return We(Object.entries(t).map(o=>o[1]&&o[0]));if(Array.isArray(t))return We(...t)}).filter(Boolean).join(" ")}function gi(...e){return e.reduce((t,o)=>(Gt(o)&&Object.entries(o).forEach(([r,s])=>{const a=We(t[r],s);a&&(t[r]=a)}),t),{})}class J extends Error{constructor(t,o,r){super(typeof o=="object"?o.message:o||t,{cause:typeof o=="object"?o.cause:r}),this.type=t,Object.setPrototypeOf(this,J.prototype)}}function Eo(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function wi(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}const Si="ERR_INVALID_VALUE",yi="ERR_UNEXPECTED_VALUE",Ai="ERR_UNEXPECTED_TYPE",go="ERR_PARSE";function wo(e,t){const o={};for(const r in e){const s=e[r];if(!s)continue;let a,i;typeof s=="function"?(a=r,i=s):[a,i]=s;try{const c=i(t(a));c!==void 0&&(o[r]=c)}catch(c){throw new J(go,`Parser for "${r}" property failed${a===r?"":`. Source field: "${a}"`}`,c)}}return o}function So(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch(o){throw new J(Si,{cause:o})}if(typeof t!="object"||!t||Array.isArray(t))throw new J(yi);return t}function D(e,t){return o=>{const r=s=>{if(!(o&&s===void 0))try{return t(s)}catch(a){throw new J(go,{message:`"${e}" transformer failed to parse the value`,cause:a})}};return Object.assign(r,{isValid(s){try{return r(s),!0}catch{return!1}}})}}function M(e,t){return D(t||"object",o=>{const r=So(o);return wo(e,s=>r[s])})}function Ce(e){throw new J(Ai,`Unexpected value received: ${JSON.stringify(e)}`)}const Ge=D("boolean",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;Ce(e)}),v=D("string",e=>{if(typeof e=="string"||typeof e=="number")return e.toString();Ce(e)}),Re=D("number",e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=Number(e);if(!Number.isNaN(t))return t}Ce(e)}),Ci=D("date",e=>e instanceof Date?e:new Date(Re()(e)*1e3));function yo(e,t){return D(t||"searchParams",o=>{typeof o!="string"&&!(o instanceof URLSearchParams)&&Ce(o);const r=typeof o=="string"?new URLSearchParams(o):o;return wo(e,s=>{const a=r.get(s);return a===null?void 0:a})})}function zt(e){for(const t in e)e[t]=[Eo(t),e[t]];return e}const Ri=e=>{const t=Re(),o=Re(!0),r=v(),s=v(!0),a=Ge(!0),i=M(zt({addedToAttachmentMenu:a,allowsWriteToPm:a,firstName:r,id:t,isBot:a,isPremium:a,languageCode:s,lastName:s,photoUrl:s,username:s}),"User")(!0);return yo(zt({authDate:Ci(),canSendAfter:o,chat:M(zt({id:t,type:r,title:r,photoUrl:s,username:s}),"Chat")(!0),chatInstance:s,chatType:s,hash:r,queryId:s,receiver:i,startParam:s,signature:r,user:i}),"initData")(e)};function Ti(e){return/^#[\da-f]{6}$/i.test(e)}function vi(e){return/^#[\da-f]{3}$/i.test(e)}function $i(e){const t=e.replace(/\s/g,"").toLowerCase();if(Ti(t))return t;if(vi(t)){let r="#";for(let s=0;s<3;s+=1)r+=t[1+s].repeat(2);return r}const o=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(!o)throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);return o.slice(1).reduce((r,s)=>{const a=parseInt(s,10).toString(16);return r+(a.length===1?"0":"")+a},"#")}const Pi=D("rgb",e=>$i(v()(e))),Ao=D("themeParams",e=>{const t=Pi(!0);return Object.entries(So(e)).reduce((o,[r,s])=>(o[wi(r)]=t(s),o),{})});function Qt(e){return JSON.stringify(Object.fromEntries(Object.entries(e).map(([t,o])=>[Eo(t),o])))}const Oi=e=>{const t=v(),o=v(!0),r=Ge(!0);return yo({botInline:["tgWebAppBotInline",r],defaultColors:["tgWebAppDefaultColors",Ao(!0)],fullscreen:["tgWebAppFullscreen",r],initData:["tgWebAppData",Ri(!0)],initDataRaw:["tgWebAppData",o],platform:["tgWebAppPlatform",t],showSettings:["tgWebAppShowSettings",r],startParam:["tgWebAppStartParam",o],themeParams:["tgWebAppThemeParams",Ao()],version:["tgWebAppVersion",t]},"launchParams")(e)};function Bi(e){const{initDataRaw:t,startParam:o,showSettings:r,botInline:s,fullscreen:a,defaultColors:i}=e,c=new URLSearchParams;return c.set("tgWebAppPlatform",e.platform),c.set("tgWebAppThemeParams",Qt(e.themeParams)),c.set("tgWebAppVersion",e.version),t&&c.set("tgWebAppData",t),o&&c.set("tgWebAppStartParam",o),typeof r=="boolean"&&c.set("tgWebAppShowSettings",r?"1":"0"),typeof s=="boolean"&&c.set("tgWebAppBotInline",s?"1":"0"),typeof a=="boolean"&&c.set("tgWebAppFullscreen",a?"1":"0"),i&&c.set("tgWebAppDefaultColors",Qt(i)),c.toString()}const Co=M({eventType:v(),eventData:e=>e},"miniAppsMessage"),Ro=D("fn",e=>{if(typeof e=="function")return e;Ce(e)});function Ii(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}const Di=M({TelegramWebviewProxy:M({postEvent:Ro()})()});function To(e){return Di().isValid(e)}function vo(){try{return window.self!==window.top}catch{return!0}}var Mi=Object.defineProperty,Ni=(e,t,o)=>t in e?Mi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,$o=(e,t,o)=>Ni(e,typeof t!="symbol"?t+"":t,o);let _=class _i extends Error{constructor(t,o,r){super(typeof o=="object"?o.message:o||t,{cause:typeof o=="object"?o.cause:r}),this.type=t,Object.setPrototypeOf(this,_i.prototype)}};function Jt(e,t,o){return e.addEventListener(t,o),()=>e.removeEventListener(t,o)}function ne(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(o=>{o()})}]}function ki(e,t){return e instanceof _&&e.type===t}function Yt(e){return t=>ki(t,e)}const Zt="ERR_ABORTED",Kt="ERR_CANCELED",Xt="ERR_TIMED_OUT";function Po(e){return new _(Zt,{cause:e})}const Li=Yt(Xt),Vi=Yt(Zt),ji=Yt(Kt);function Oo(e,t){return e.reject=t.reject,e}class b extends Promise{constructor(t,o){let r,s;typeof t=="function"?(r=t,s=o):s=t;let a,i;super((c,f)=>{s||(s={});const{abortSignal:l}=s;if(l&&l.aborted)return f(Po(l.reason));const[m,S]=ne(),C=h=>(...ee)=>(S(),h(...ee)),F=new AbortController,{signal:T}=F;i=C(h=>{F.abort(h),f(h)}),a=C(c),l&&m(Jt(l,"abort",()=>{i(Po(l.reason))}));const{timeout:E}=s;if(E){const h=setTimeout(()=>{i(new _(Xt,`Timeout reached: ${E}ms`))},E);m(()=>{clearTimeout(h)})}r&&r(a,i,T)}),$o(this,"reject"),this.reject=i}static withFn(t,o){return new b((r,s,a)=>{try{const i=t(a);return i instanceof Promise?i.then(r,s):r(i)}catch(i){s(i)}},o)}static resolve(t){return new b(o=>{o(t)})}static reject(t){return new b((o,r)=>{r(t)})}cancel(){this.reject(new _(Kt))}catch(t){return this.then(void 0,t)}finally(t){return Oo(super.finally(t),this)}then(t,o){return Oo(super.then(t,o),this)}}function Bo(e,t){return e.resolve=t.resolve,e}let qi=class Vt extends b{constructor(t,o){let r,s;typeof t=="function"?(r=t,s=o):s=t;let a;super((i,c,f)=>{a=i,r&&r(i,c,f)},s),$o(this,"resolve"),this.resolve=a}static withFn(t,o){return new Vt((r,s,a)=>b.withFn(t,{abortSignal:a}).then(r,s),o)}static resolve(t){return new Vt(o=>{o(t)})}static reject(t){return new Vt((o,r)=>{r(t)})}catch(t){return this.then(void 0,t)}finally(t){return Bo(super.finally(t),this)}then(t,o){return Bo(super.then(t,o),this)}};function Ui(e,t){return new b(o=>{setTimeout(o,e)},{abortSignal:t})}function Io(e){return`tapps/${e}`}function $(e,t){sessionStorage.setItem(Io(e),JSON.stringify(t))}function P(e){const t=sessionStorage.getItem(Io(e));try{return t?JSON.parse(t):void 0}catch{}}function xt(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Hi(e,t){t||(t={});const{textColor:o,bgColor:r,shouldLog:s=!0}=t;function a(i,...c){if(!s||typeof s=="function"&&!s())return;const f="font-weight:bold;padding:0 5px;border-radius:5px";console[i](`%c${Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(new Date)}%c / %c${e}`,`${f};background-color: lightblue;color:black`,"",`${f};${o?`color:${o};`:""}${r?`background-color:${r}`:""}`,...c)}return[function(...i){a("log",...i)},function(...i){a("error",...i)}]}function ze(e,t){document.documentElement.style.setProperty(e,t)}function Qe(e){document.documentElement.style.removeProperty(e)}function Fi(e,t){t()}function oe(e,t){t||(t={});const o=t.equals||Object.is;let r=[],s=e;const a=l=>{if(!o(s,l)){const m=s;s=l,Fi(f,()=>{[...r].forEach(([S,C])=>{S(l,m),C&&c(S,!0)})})}};function i(l){const m=typeof l!="object"?{once:l}:l;return{once:m.once||!1,signal:m.signal||!1}}const c=(l,m)=>{const S=i(m),C=r.findIndex(([F,T])=>F===l&&T.once===S.once&&T.signal===S.signal);C>=0&&r.splice(C,1)},f=Object.assign(function(){return Wi(f),s},{destroy(){r=[]},set:a,reset(){a(e)},sub(l,m){return r.push([l,i(m)]),()=>c(l,m)},unsub:c,unsubAll(){r=r.filter(l=>l[1].signal)}});return f}const en=[];function Wi(e){en.length&&en[en.length-1].add(e)}const Do=oe(!1),[tn,Gi]=Hi("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:Do}),zi={clipboard_text_received:M({req_id:v(),data:e=>e===null?e:v(!0)(e)},"clipboard_text_received"),custom_method_invoked:M({req_id:v(),result:e=>e,error:v(!0)},"custom_method_invoked"),popup_closed:D("popup_closed",e=>e?M({button_id:t=>t==null?void 0:v()(t)})()(e):{}),viewport_changed:M({height:Re(),width:e=>e==null?window.innerWidth:Re()(e),is_state_stable:Ge(),is_expanded:Ge()},"viewport_changed")};function Qi(e){const t=window,[,o]=ne(Jt(t,"message",r=>{if(r.source!==t.parent)return;let s;try{s=Co()(r.data)}catch{return}const{eventType:a,eventData:i}=s,c=zi[a];try{const f=c?c()(i):i;tn("Event received:",f?{eventType:a,eventData:f}:{eventType:a}),e([a,f])}catch(f){Gi([`An error occurred processing the "${a}" event from the Telegram application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/telegram-apps/issues/new/choose"].join(`
`),s,f)}}));return o}const nn=oe(),Mo=oe();function No(){return Mo()||Mo.set(Qi(nn.set)),nn}const on=oe({});function ko(e){let t=on()[e];return t||(t=oe(void 0,{equals(){return!1}}),No().sub(o=>{o&&o[0]===e&&t.set(o[1])}),on.set({...on(),[e]:t})),t}function g(e,t,o){return ko(e).sub(t,o)}const Lo="ERR_METHOD_UNSUPPORTED",Vo="ERR_RETRIEVE_LP_FAILED",jo="ERR_METHOD_PARAMETER_UNSUPPORTED",rn="ERR_UNKNOWN_ENV",qo="ERR_INVOKE_CUSTOM_METHOD_RESPONSE",Uo=oe("https://web.telegram.org");function Je(e,t){tn("Posting event:",t?{eventType:e,eventData:t}:{eventType:e});const o=window;if(To(o)){o.TelegramWebviewProxy.postEvent(e,JSON.stringify(t));return}const r=JSON.stringify({eventType:e,eventData:t});if(vo())return o.parent.postMessage(r,Uo());const{external:s}=o;if(M({notify:Ro()})().isValid(s)){s.notify(r);return}throw new _(rn)}function Ye(e,t,o){o||(o={});const{capture:r}=o,[s,a]=ne();return new b(i=>{(Array.isArray(t)?t:[t]).forEach(c=>{s(g(c,f=>{(!r||(Array.isArray(t)?r({event:c,payload:f}):r(f)))&&i(f)}))}),(o.postEvent||Je)(e,o.params)},o).finally(a)}function sn(e){return Oi()(e)}function Ho(e){return sn(e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&"))}function Ji(){return Ho(window.location.href)}function Yi(){const e=performance.getEntriesByType("navigation")[0];if(!e)throw new Error("Unable to get first navigation entry.");return Ho(e.name)}const Zi="launchParams";function Ki(){return sn(P(Zi)||"")}function Fo(e){$("launchParams",Bi(e))}function Wo(e){return e instanceof Error?e.message+(e.cause?`
${Wo(e.cause)}`:""):JSON.stringify(e)}function Y(){const e=[];for(const t of[Ji,Yi,Ki])try{const o=t();return Fo(o),o}catch(o){e.push(o)}throw new _(Vo,["Unable to retrieve launch parameters from any known source. Perhaps, you have opened your app outside Telegram?","📖 Refer to docs for more information:","https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk/environment","Collected errors:",...e.map(t=>`— ${Wo(t)}`)].join(`
`))}function an(e){if(e==="simple")try{return Y(),!0}catch{return!1}return b.withFn(async()=>{if(To(window))return!0;try{return await Ye("web_app_request_theme","theme_changed",{timeout:100}),!0}catch{return!1}},e)}function Ze(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}function Xi(e,t){if(typeof t=="string")try{const{eventType:o}=Co()(t);o==="web_app_request_theme"&&Ze("theme_changed",{theme_params:JSON.parse(Qt(e))}),o==="web_app_request_viewport"&&Ze("viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0})}catch{}}function xi(e){var t;const o=typeof e=="string"?sn(e):e;Fo(o);const r=(t=window.TelegramWebviewProxy)==null?void 0:t.postEvent;window.TelegramWebviewProxy={postEvent(s,a){Xi(o.themeParams,JSON.stringify({eventType:s,eventData:a})),r==null||r(s,a)}},tn("Environment was mocked by the mockTelegramEnv function")}function Go(){[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["Telegram","WebView","receiveEvent"]].forEach(e=>{let t=window;e.forEach((o,r,s)=>{if(r===s.length-1){t[o]=Ze;return}o in t||(t[o]={}),t=t[o]})})}function zo(){["TelegramGameProxy_receiveEvent","TelegramGameProxy","Telegram"].forEach(e=>{delete window[e]})}function O(e,t,o){ko(e).unsub(t,o)}function ec(e,t){return No().sub(e,t)}function tc(e,t){nn.unsub(e,t)}function Qo(e){return({req_id:t})=>t===e}function Jo(e){return e.split(".").map(Number)}function Yo(e,t){const o=Jo(e),r=Jo(t),s=Math.max(o.length,r.length);for(let a=0;a<s;a+=1){const i=o[a]||0,c=r[a]||0;if(i!==c)return i>c?1:-1}return 0}function w(e,t){return Yo(e,t)<=0}function W(e,t,o){if(typeof o=="string"){if(e==="web_app_open_link"){if(t==="try_instant_view")return w("6.4",o);if(t==="try_browser")return w("7.6",o)}if(e==="web_app_set_header_color"&&t==="color")return w("6.9",o);if(e==="web_app_close"&&t==="return_back")return w("7.6",o);if(e==="web_app_setup_main_button"&&t==="has_shine_effect")return w("7.10",o)}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 w("6.1",t);case"web_app_open_popup":return w("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 w("6.4",t);case"web_app_switch_inline_query":return w("6.7",t);case"web_app_invoke_custom_method":case"web_app_request_write_access":case"web_app_request_phone":return w("6.9",t);case"web_app_setup_settings_button":return w("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 w("7.2",t);case"web_app_setup_swipe_behavior":return w("7.7",t);case"web_app_share_to_story":return w("7.8",t);case"web_app_setup_secondary_button":case"web_app_set_bottom_bar_color":return w("7.10",t);case"web_app_request_safe_area":case"web_app_request_content_safe_area":case"web_app_request_fullscreen":case"web_app_exit_fullscreen":case"web_app_set_emoji_status":case"web_app_request_emoji_status_access":return w("8.0",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 Zo(e,t){t||(t="strict");const o=typeof t=="function"?t:r=>{const{method:s,version:a}=r;let i,c;if("param"in r?(i=`Parameter "${r.param}" of "${s}" method is unsupported in Mini Apps version ${a}`,c=jo):(i=`Method "${s}" is unsupported in Mini Apps version ${a}`,c=Lo),t==="strict")throw new _(c,i);return console.warn(i)};return(r,s)=>W(r,e)?Ii(s)&&r==="web_app_set_header_color"&&"color"in s&&!W(r,"color",e)?o({version:e,method:r,param:"color"}):Je(r,s):o({version:e,method:r})}function Ko(e,t,o,r){return Ye("web_app_invoke_custom_method","custom_method_invoked",{...r||{},params:{method:e,params:t,req_id:o},capture:Qo(o)}).then(({result:s,error:a})=>{if(a)throw new _(qo,a);return s})}function nc(){return performance.getEntriesByType("navigation")[0]}function N(){const e=nc();return!!e&&e.type==="reload"}let re;function oc(e,t){re&&re.set(e,t)||t()}function cn(e){if(re)return e();re=new Map;try{e()}finally{re.forEach(t=>t()),re=void 0}}function u(e,t){t||(t={});const o=t.equals||Object.is;let r=[],s=e;const a=l=>{if(!o(s,l)){const m=s;s=l,oc(f,()=>{[...r].forEach(([S,C])=>{S(l,m),C&&c(S,!0)})})}};function i(l){const m=typeof l!="object"?{once:l}:l;return{once:m.once||!1,signal:m.signal||!1}}const c=(l,m)=>{const S=i(m),C=r.findIndex(([F,T])=>F===l&&T.once===S.once&&T.signal===S.signal);C>=0&&r.splice(C,1)},f=Object.assign(function(){return rc(f),s},{destroy(){r=[]},set:a,reset(){a(e)},sub(l,m){return r.push([l,i(m)]),()=>c(l,m)},unsub:c,unsubAll(){r=r.filter(l=>l[1].signal)}});return f}const Te=[];function rc(e){Te.length&&Te[Te.length-1].add(e)}function d(e,t){let o=new Set,r;function s(){return r||(r=u(i(),t))}function a(){s().set(i())}function i(){o.forEach(l=>{l.unsub(a,{signal:!0})});const c=new Set;let f;Te.push(c);try{f=e()}finally{Te.pop()}return c.forEach(l=>{l.sub(a,{signal:!0})}),o=c,f}return Object.assign(function(){return s()()},{destroy(){s().destroy()},sub(...c){return s().sub(...c)},unsub(...c){s().unsub(...c)},unsubAll(...c){s().unsubAll(...c)}})}const Xo=u((()=>{let e=0;return()=>(e+=1).toString()})()),un=u(Je),k=u("0.0");function sc(e){e||(e={});const{postEvent:t}=e,o=e.version||Y().version;k.set(o),un.set(typeof t=="function"?t:Zo(o))}function xo(){return Xo()()}function se(e,t,o){return Ko(e,t,xo(),{...o||{},postEvent:p})}const y=(e,t,o)=>(o||(o={}),o.postEvent||(o.postEvent=p),Ye(e,t,o)),p=(e,t)=>un()(e,t);function L(e){return d(()=>W(e,k()))}const ae="ERR_POPUP_INVALID_PARAMS",Ke="ERR_INVALID_URL",er="ERR_INVALID_SLUG",tr="ERR_DATA_INVALID_SIZE",nr="ERR_ACCESS_DENIED",G="ERR_ALREADY_REQUESTING",Xe="ERR_ALREADY_OPENED",or="ERR_ALREADY_MOUNTING",rr="ERR_VARS_ALREADY_BOUND",sr="ERR_NOT_AVAILABLE",ar="ERR_NOT_INITIALIZED",ln="ERR_NOT_SUPPORTED",ir="ERR_NOT_MOUNTED",cr="ERR_FULLSCREEN_FAILED",ur="ERR_EMOJI_STATUS_SET_FAILED";function _n(){return typeof window>"u"}function R(e,t,{isSupported:o,isMounted:r,component:s,supports:a}={}){const i=`${s?`${s}.`:""}${e}()`;o=o?Array.isArray(o)||typeof o=="object"&&"any"in o?o:[o]:void 0;function c(E){if(a){const h=a[E];return W(h[0],h[1],k())}return!0}const f=()=>{if(!o)return;const E=`it is unsupported in Mini Apps version ${k()}`;function h(I){return typeof I=="string"?W(I,k())?void 0:E:I.fn()?void 0:I.error}if(Array.isArray(o)){for(const I of o){const li=h(I);if(li)return li}return}let ee;for(const I of o.any)if(ee=h(I),!ee)return;return E},l=(...E)=>{if(a){for(const h in a)if(a[h][2](...E)&&!c(h))return`option ${h} is not supported in Mini Apps version ${k()}`}},m=d(()=>!f()),S=d(()=>k()!=="0.0"),C=d(()=>!r||r()),F=d(()=>an("simple")&&!_n()&&S()&&m()&&C());let T;if(a){T={};for(const E in a)T[E]=d(()=>c(E))}return Object.assign((...E)=>{const h=`Unable to call the ${i} ${s?"method":"function"}:`;if(_n()||!an("simple"))throw new _(rn,`${h} it can't be called outside Mini Apps`);if(!S())throw new _(ar,`${h} the SDK was not initialized. Use the SDK init() function`);const ee=f();if(ee)throw new _(ln,`${h} ${ee}`);const I=l(...E);if(I)throw new _(ln,`${h} ${I}`);if(!C())throw new _(ir,`${h} the component is not mounted. Use the ${s}.mount() method`);return t(...E)},t,{isAvailable:F,ifAvailable(...E){return F()?t(...E):void 0}},o?{isSupported:m}:{},T?{supports:T}:{})}function xe(e,t){return t||(t={}),(o,r,s,a)=>R(o,r,{...t,isSupported:s||t.isSupported,supports:a,component:e})}function Z(e,t,o){return xe(e,{isSupported:o,isMounted:t})}function B(e,t){return xe(e,{isSupported:t})}const et="web_app_setup_back_button",lr="back_button_pressed",tt="backButton",nt=u(!1),ie=u(!1),_r=L(et),fr=Z(tt,ie,et),fn=B(tt,et),dr=fr("hide",()=>{dn(!1)}),pr=fn("mount",()=>{ie()||(dn(N()&&P(tt)||!1),ie.set(!0))});function dn(e){e!==nt()&&(p(et,{is_visible:e}),$(tt,e),nt.set(e))}const mr=fn("onClick",e=>g(lr,e)),hr=fn("offClick",e=>{O(lr,e)}),br=fr("show",()=>{dn(!0)});function Er(){ie.set(!1)}const ac=Object.freeze(Object.defineProperty({__proto__:null,hide:dr,isMounted:ie,isSupported:_r,isVisible:nt,mount:pr,offClick:hr,onClick:mr,show:br,unmount:Er},Symbol.toStringTag,{value:"Module"}));function ot(e,t,o,r,s){const a=s===void 0||s?b:Promise;return Object.assign((...i)=>a.resolve().then(async()=>{if(o()){const f=t();throw r.set(f),f}cn(()=>{o.set(a.resolve(e(...i))),r.set(void 0)});let c;try{c=[!0,await o()]}catch(f){c=[!1,f]}if(cn(()=>{o.set(void 0),r.set(c[0]?void 0:c[1])}),!c[0])throw c[1];return c[1]}),e)}function gr(e,t,o,r,s,a){const i=ot(t,()=>new _(or,`The ${e} component is already mounting`),s,a);return c=>b.resolve().then(async()=>{if(!r()){const f=await i(c);cn(()=>{r.set(!0),o(f)})}})}const U=xe,ve=u({available:!1}),$e=u(!1),Pe=u(!1),Oe=u(!1),wr=d(()=>!!mn()),pn=u(),mn=u(),ic=d(()=>{const e=ve();return e&&e.available});function hn(e){return e.available?{available:!0,tokenSaved:e.token_saved,deviceId:e.device_id,accessRequested:e.access_requested,type:e.type,accessGranted:e.access_granted}:{available:!1}}const Sr="web_app_biometry_get_info",yr=R("requestBiometry",e=>y(Sr,"biometry_info_received",e).then(hn),{isSupported:Sr}),rt="web_app_biometry_request_auth",cc="web_app_biometry_request_access",uc="web_app_biometry_open_settings",lc="web_app_biometry_update_token",bn="biometry_info_received",ce="biometry",Ar=L(rt),_c=U(ce),fc=B(ce,rt),En=Z(ce,Oe,rt);function Cr(){throw new _(sr,"Biometry is not available")}const Rr=En("authenticate",e=>b.withFn(async t=>{if($e())throw new _(G,"Authentication is already in progress");const o=ve();(!o||!o.available)&&Cr(),$e.set(!0);try{const r=await y(rt,"biometry_auth_requested",{abortSignal:t,params:{reason:((e||{}).reason||"").trim()}}),{token:s}=r;return typeof s=="string"&&st({...o,token:s}),r}finally{$e.set(!1)}},e)),Tr=fc("openSettings",()=>{p(uc)}),vr=En("requestAccess",e=>b.withFn(async t=>{if(Pe())throw new _(G,"Access request is already in progress");Pe.set(!0);try{const o=await y(cc,bn,{abortSignal:t,params:{reason:(e||{}).reason||""}}).then(hn);return o.available||Cr(),st(o),o.accessGranted}finally{Pe.set(!1)}},e)),$r=_c("mount",gr(ce,e=>{const t=N()&&P(ce);return t||yr(e)},e=>{g(bn,Pr),st(e)},Oe,mn,pn)),Pr=e=>{st(hn(e))};function st(e){ve.set(e),$(ce,e)}function Or(){O(bn,Pr),Oe.set(!1)}const Br=En("updateToken",e=>(e||(e={}),y(lc,"biometry_token_updated",{...e,params:{token:e.token||"",reason:e.reason}}).then(t=>t.status))),dc=Object.freeze(Object.defineProperty({__proto__:null,authenticate:Rr,isAuthenticating:$e,isAvailable:ic,isMounted:Oe,isMounting:wr,isRequestingAccess:Pe,isSupported:Ar,mount:$r,mountError:pn,mountPromise:mn,openSettings:Tr,requestAccess:vr,state:ve,unmount:Or,updateToken:Br},Symbol.toStringTag,{value:"Module"}));function at(e,t){return xe(e,{isMounted:t})}const it="closingBehavior",ct=u(!1),ue=u(!1),Ir=at(it,ue),pc=U(it),Dr=Ir("disableConfirmation",()=>{gn(!1)}),Mr=Ir("enableConfirmation",()=>{gn(!0)}),Nr=pc("mount",()=>{ue()||(gn(N()&&P(it)||!1),ue.set(!0))});function gn(e){e!==ct()&&(p("web_app_setup_closing_behavior",{need_confirmation:e}),$(it,e),ct.set(e))}function kr(){ue.set(!1)}const mc=Object.freeze(Object.defineProperty({__proto__:null,disableConfirmation:Dr,enableConfirmation:Mr,isConfirmationEnabled:ct,isMounted:ue,mount:Nr,unmount:kr},Symbol.toStringTag,{value:"Module"})),Lr="web_app_invoke_custom_method",ut=B("cloudStorage",Lr),Vr=L(Lr),jr=ut("deleteItem",(e,t)=>{const o=Array.isArray(e)?e:[e];return o.length?se("deleteStorageValues",{keys:o},t).then():b.resolve()});function hc(e,t){const o=Array.isArray(e)?e:[e];return o.length?se("getStorageValues",{keys:o},t).then(r=>{const s=He(Object.fromEntries(o.map(a=>[a,q()])))()(r);return Array.isArray(e)?s:s[e]}):b.resolve(typeof e=="string"?"":{})}const qr=ut("getItem",hc),Ur=ut("getKeys",e=>se("getStorageKeys",{},e).then(Ei(q())())),Hr=ut("setItem",(e,t,o)=>se("saveStorageValue",{key:e,value:t},o).then()),bc=Object.freeze(Object.defineProperty({__proto__:null,deleteItem:jr,getItem:qr,getKeys:Ur,isSupported:Vr,setItem:Hr},Symbol.toStringTag,{value:"Module"})),Be="web_app_trigger_haptic_feedback",wn=B("hapticFeedback",Be),Fr=L(Be),Wr=wn("impactOccurred",e=>{p(Be,{type:"impact",impact_style:e})}),Gr=wn("notificationOccurred",e=>{p(Be,{type:"notification",notification_type:e})}),zr=wn("selectionChanged",()=>{p(Be,{type:"selection_change"})}),Ec=Object.freeze(Object.defineProperty({__proto__:null,impactOccurred:Wr,isSupported:Fr,notificationOccurred:Gr,selectionChanged:zr},Symbol.toStringTag,{value:"Module"})),lt=u(void 0);function V(e){return d(()=>{const t=lt();return t?t[e]:void 0})}const Sn=V("authDate"),yn=V("canSendAfter"),Qr=d(()=>{const e=Sn(),t=yn();return t&&e?new Date(e.getTime()+t*1e3):void 0}),Jr=V("chat"),Yr=V("chatType"),Zr=V("chatInstance"),Kr=V("hash"),Xr=V("queryId"),An=u(),xr=V("receiver");function es(){const e=Y();lt.set(e.initData),An.set(e.initDataRaw)}const ts=V("startParam"),ns=V("user"),gc=Object.freeze(Object.defineProperty({__proto__:null,authDate:Sn,canSendAfter:yn,canSendAfterDate:Qr,chat:Jr,chatInstance:Zr,chatType:Yr,hash:Kr,queryId:Xr,raw:An,receiver:xr,restore:es,startParam:ts,state:lt,user:ns},Symbol.toStringTag,{value:"Module"}));function wc(e){return pi()(e)}const Cn="web_app_open_invoice",Sc=B("invoice",Cn),Ie=u(!1),os=L(Cn);async function rs(e,t,o){if(Ie())throw new _(Xe,"An invoice is already opened");let r;if(t==="url"){const{hostname:s,pathname:a}=new URL(e,window.location.href);if(s!=="t.me")throw new _(Ke,`Link has unexpected hostname: ${s}`);const i=a.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);if(!i)throw new _(er,'Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"');[,,r]=i}else r=e,o=t;return Ie.set(!0),y(Cn,"invoice_closed",{...o,params:{slug:r},capture:s=>r===s.slug}).then(s=>s.status).finally(()=>{Ie.set(!1)})}const ss=Sc("open",rs),yc=Object.freeze(Object.defineProperty({__proto__:null,_open:rs,isOpened:Ie,isSupported:os,open:ss},Symbol.toStringTag,{value:"Module"}));function as(e){return Object.fromEntries(Object.entries(e).filter(t=>t[1]!==void 0))}function Rn(e){const t=Ft(e);return Math.sqrt([.299,.587,.114].reduce((o,r,s)=>{const a=parseInt(t.slice(1+s*2,1+(s+1)*2),16);return o+a*a*r},0))<120}const le=u(!1),De=u(!1),H=u({});function A(e){return d(()=>H()[e])}const is=A("accentTextColor"),_t=A("bgColor"),ft=A("buttonColor"),Tn=A("buttonTextColor"),vn=A("bottomBarBgColor"),cs=A("destructiveTextColor"),us=A("headerBgColor"),ls=A("hintColor"),_s=d(()=>{const{bgColor:e}=H();return!e||Rn(e)}),fs=A("linkColor"),Me=A("secondaryBgColor"),ds=A("sectionBgColor"),ps=A("sectionHeaderTextColor"),ms=A("sectionSeparatorColor"),hs=A("subtitleTextColor"),bs=A("textColor");function K(e){return d(()=>dt()[e])}const Ne=u({hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"}),dt=d(()=>{const e=Ne();return{...e,backgroundColor:e.backgroundColor||ft()||"#2481cc",textColor:e.textColor||Tn()||"#ffffff"}}),_e=u(!1),Es=K("backgroundColor"),gs=K("hasShineEffect"),ws=K("isEnabled"),Ss=K("isLoaderVisible"),ys=K("isVisible"),As=K("text"),Cs=K("textColor"),Ac="web_app_setup_main_button",Rs="main_button_pressed",pt="mainButton",$n=U(pt),Cc=at(pt,_e),Ts=$n("mount",()=>{if(!_e()){const e=N()&&P(pt);e&&Ne.set(e),_e.set(!0)}}),vs=$n("onClick",e=>g(Rs,e)),$s=$n("offClick",e=>{O(Rs,e)}),Ps=Cc("setParams",e=>{Ne.set({...Ne(),...as(e)}),$(pt,Ne());const t=dt();t.text&&p(Ac,{color:t.backgroundColor,has_shine_effect:t.hasShineEffect,is_active:t.isEnabled,is_progress_visible:t.isLoaderVisible,is_visible:t.isVisible,text:t.text,text_color:t.textColor})});function Os(){_e.set(!1)}const Rc=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:Es,hasShineEffect:gs,isEnabled:ws,isLoaderVisible:Ss,isMounted:_e,isVisible:ys,mount:Ts,offClick:$s,onClick:vs,setParams:Ps,state:dt,text:As,textColor:Cs,unmount:Os},Symbol.toStringTag,{value:"Module"}));function Pn(){throw new _(rr,"CSS variables are already bound")}function Bs(e){return hi()(e)}const mt="themeParams",Is="theme_changed",Tc=U(mt),Ds=at(mt,le)("bindCssVars",e=>{De()&&Pn(),e||(e=r=>`--tg-theme-${xt(r)}`);function t(r){Object.entries(H()).forEach(([s,a])=>{a&&r(s,a)})}function o(){t((r,s)=>{ze(e(r),s)})}return o(),H.sub(o),De.set(!0),()=>{t(Qe),H.unsub(o),De.set(!1)}}),On=Tc("mount",()=>{le()||(g(Is,Ms),H.set(N()&&P(mt)||Y().themeParams),le.set(!0))}),Ms=e=>{const t=Bs(e.theme_params);H.set(t),$(mt,t)};function Ns(){O(Is,Ms),le.set(!1)}function ks(e){return d(()=>{const t=e();return te(t)?t:t==="bg_color"?_t():Me()})}const fe=u("bg_color"),Bn=ks(fe),de=u("bottom_bar_bg_color"),ht=d(()=>{const e=de();return te(e)?e:e==="bottom_bar_bg_color"?vn()||Me():e==="secondary_bg_color"?Me():_t()}),pe=u("bg_color"),In=ks(pe),me=u(!1),ke=u(!1),Ls=d(()=>{const e=Bn();return e?Rn(e):!1}),Dn=d(()=>({backgroundColor:fe(),bottomBarColor:de(),headerColor:pe()})),Mn="web_app_set_background_color",Nn="web_app_set_bottom_bar_color",bt="web_app_set_header_color",Le="miniApp",kn={any:[Mn,Nn,bt]},Vs=d(()=>kn.any.some(e=>W(e,k()))),js=U(Le),vc=B(Le,kn),Et=Z(Le,me,kn),qs=Et("bindCssVars",e=>{ke()&&Pn();const[t,o]=ne();function r(s,a){function i(){ze(s,a()||null)}i(),t(a.sub(i),Qe.bind(null,s))}return e||(e=s=>`--tg-${xt(s)}`),r(e("bgColor"),Bn),r(e("bottomBarColor"),ht),r(e("headerColor"),In),t(()=>{ke.set(!1)}),ke.set(!0),o}),Us=js("close",e=>{p("web_app_close",{return_back:e})}),Hs=vc("mount",()=>{if(!me()){const e=N()&&P(Le);On(),Vn.ifAvailable(e?e.backgroundColor:"bg_color"),jn.ifAvailable(e?e.bottomBarColor:"bottom_bar_bg_color"),qn.ifAvailable(e?e.headerColor:"bg_color"),me.set(!0)}}),Fs=js("ready",()=>{p("web_app_ready")});function Ln(){$(Le,Dn())}const Vn=Et("setBackgroundColor",e=>{e!==fe()&&(p(Mn,{color:e}),fe.set(e),Ln())},Mn),jn=Et("setBottomBarColor",e=>{e!==de()&&(p(Nn,{color:e}),de.set(e),Ln())},Nn),qn=Et("setHeaderColor",e=>{e!==pe()&&(p(bt,te(e)?{color:e}:{color_key:e}),pe.set(e),Ln())},bt,{rgb:[bt,"color",te]});function Ws(){me.set(!1)}const $c=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:fe,backgroundColorRGB:Bn,bindCssVars:qs,bottomBarColor:de,bottomBarColorRGB:ht,close:Us,headerColor:pe,headerColorRGB:In,isCssVarsBound:ke,isDark:Ls,isMounted:me,isSupported:Vs,mount:Hs,ready:Fs,setBackgroundColor:Vn,setBottomBarColor:jn,setHeaderColor:qn,state:Dn,unmount:Ws},Symbol.toStringTag,{value:"Module"}));function Pc(e){const t=e.message.trim(),o=(e.title||"").trim(),r=e.buttons||[];if(o.length>64)throw new _(ae,`Invalid title: ${o}`);if(!t||t.length>256)throw new _(ae,`Invalid message: ${t}`);if(r.length>3)throw new _(ae,`Invalid buttons count: ${r.length}`);return{title:o,message:t,buttons:r.length?r.map((s,a)=>{const i=s.id||"";if(i.length>64)throw new _(ae,`Button with index ${a} has invalid id: ${i}`);if(!s.type||s.type==="default"||s.type==="destructive"){const c=s.text.trim();if(!c||c.length>64)throw new _(ae,`Button with index ${a} has invalid text: ${c}`);return{type:s.type,text:c,id:i}}return{type:s.type,id:i}}):[{type:"close",id:""}]}}const Un="web_app_open_popup",Oc=B("popup",Un),Ve=u(!1),Gs=L(Un),zs=Oc("open",async e=>{if(Ve())throw new _(Xe,"A popup is already opened");Ve.set(!0);try{const{button_id:t=null}=await y(Un,"popup_closed",{...e,params:Pc(e)});return t}finally{Ve.set(!1)}}),Bc=Object.freeze(Object.defineProperty({__proto__:null,isOpened:Ve,isSupported:Gs,open:zs},Symbol.toStringTag,{value:"Module"})),Ic="web_app_close_scan_qr_popup",Hn="web_app_open_scan_qr_popup",Dc="scan_qr_popup_closed",Mc="qr_text_received",Qs=B("qrScanner",Hn),gt=Qs("close",()=>{X.set(!1),p(Ic)}),X=u(!1),Js=L(Hn);function Nc(e){return b.withFn(t=>{if(X())throw new _(Xe,"The QR Scanner is already opened");X.set(!0),e||(e={});const{onCaptured:o,text:r,capture:s}=e,[,a]=ne(X.sub(()=>{i.resolve()}),g(Dc,()=>{X.set(!1)}),g(Mc,c=>{o?o(c.data):(!s||s(c.data))&&(i.resolve(c.data),gt())})),i=new qi({abortSignal:t}).catch(gt).finally(a);return(e.postEvent||p)(Hn,{text:r}),i},e)}const Ys=Qs("open",Nc),kc=Object.freeze(Object.defineProperty({__proto__:null,close:gt,isOpened:X,isSupported:Js,open:Ys},Symbol.toStringTag,{value:"Module"}));function z(e){return d(()=>wt()[e])}const je=u({hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,position:"left",text:"Cancel"}),wt=d(()=>{const e=je();return{...e,backgroundColor:e.backgroundColor||ht()||"#000000",textColor:e.textColor||ft()||"#2481cc"}}),he=u(!1),Zs=z("backgroundColor"),Ks=z("hasShineEffect"),Xs=z("isEnabled"),xs=z("isLoaderVisible"),ea=z("isVisible"),ta=z("position"),na=z("text"),oa=z("textColor"),St="web_app_setup_secondary_button",ra="secondary_button_pressed",yt="secondaryButton",Fn=B(yt,St),Lc=Z(yt,he,St),sa=L(St),aa=Fn("mount",()=>{if(!he()){const e=N()&&P(yt);e&&je.set(e),he.set(!0)}}),ia=Fn("onClick",e=>g(ra,e)),ca=Fn("offClick",e=>{O(ra,e)}),ua=Lc("setParams",e=>{je.set({...je(),...Object.fromEntries(Object.entries(e).filter(([,o])=>o!==void 0))}),$(yt,je());const t=wt();t.text&&p(St,{color:t.backgroundColor,has_shine_effect:t.hasShineEffect,is_active:t.isEnabled,is_progress_visible:t.isLoaderVisible,is_visible:t.isVisible,position:t.position,text:t.text,text_color:t.textColor})});function la(){he.set(!1)}const Vc=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:Zs,hasShineEffect:Ks,isEnabled:Xs,isLoaderVisible:xs,isMounted:he,isSupported:sa,isVisible:ea,mount:aa,offClick:ca,onClick:ia,position:ta,setParams:ua,state:wt,text:na,textColor:oa,unmount:la},Symbol.toStringTag,{value:"Module"})),At="web_app_setup_settings_button",_a="settings_button_pressed",Ct="settingsButton",Rt=u(!1),be=u(!1),fa=L(At),Wn=B(Ct,At),da=Z(Ct,be,At),pa=da("hide",()=>{Gn(!1)}),ma=Wn("mount",()=>{be()||(Gn(N()&&P(Ct)||!1),be.set(!0))});function Gn(e){e!==Rt()&&(p(At,{is_visible:e}),$(Ct,e),Rt.set(e))}const ha=Wn("onClick",e=>g(_a,e)),ba=Wn("offClick",e=>{O(_a,e)}),Ea=da("show",()=>{Gn(!0)});function ga(){be.set(!1)}const jc=Object.freeze(Object.defineProperty({__proto__:null,hide:pa,isMounted:be,isSupported:fa,isVisible:Rt,mount:ma,offClick:ba,onClick:ha,show:Ea,unmount:ga},Symbol.toStringTag,{value:"Module"})),Tt="web_app_setup_swipe_behavior",vt="swipeBehavior",Ee=u(!1),wa=L(Tt),$t=u(!0),qc=B(vt,Tt),Sa=Z(vt,Ee,Tt),ya=Sa("disableVertical",()=>{zn(!1)}),Aa=Sa("enableVertical",()=>{zn(!0)}),Ca=qc("mount",()=>{Ee()||(zn(N()&&P(vt)||!1,!0),Ee.set(!0))});function zn(e,t){(e!==$t()||t)&&(p(Tt,{allow_vertical_swipe:e}),$(vt,e),$t.set(e))}function Ra(){Ee.set(!1)}const Uc=Object.freeze(Object.defineProperty({__proto__:null,disableVertical:ya,enableVertical:Aa,isMounted:Ee,isSupported:wa,isVerticalEnabled:$t,mount:Ca,unmount:Ra},Symbol.toStringTag,{value:"Module"})),Hc=Object.freeze(Object.defineProperty({__proto__:null,accentTextColor:is,backgroundColor:_t,bindCssVars:Ds,bottomBarBgColor:vn,buttonColor:ft,buttonTextColor:Tn,destructiveTextColor:cs,headerBackgroundColor:us,hintColor:ls,isCssVarsBound:De,isDark:_s,isMounted:le,linkColor:fs,mount:On,secondaryBackgroundColor:Me,sectionBackgroundColor:ds,sectionHeaderTextColor:ps,sectionSeparatorColor:ms,state:H,subtitleTextColor:hs,textColor:bs,unmount:Ns},Symbol.toStringTag,{value:"Module"})),ge="viewport",Ta="web_app_request_fullscreen",Fc="fullscreen_failed",Qn="fullscreen_changed",va="safe_area_changed",$a="content_safe_area_changed",Pa="viewport_changed",Oa="web_app_request_safe_area",Ba="web_app_request_content_safe_area",Ia={left:0,top:0,bottom:0,right:0};function Jn(e){return Math.max(e,0)}const we=u({contentSafeAreaInsets:Ia,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:Ia,stableHeight:0,width:0});function x(e){return d(()=>we()[e])}function Se(e){const{height:t,stableHeight:o,width:r}=e;we.set({...we(),...as({...e,height:t?Jn(t):void 0,width:r?Jn(r):void 0,stableHeight:o?Jn(o):void 0})}),$(ge,we())}function Wc(){return P(ge)}const Yn=x("isFullscreen"),Pt=u(),Da=d(()=>!!Pt()),Zn=u(),ye=u(!1),Ma=d(()=>!!qe()),Kn=u(void 0),qe=u(),Gc=Z(ge,ye,Ta);function Na(e,t){return Gc(e,ot(o=>y(t,[Qn,Fc],o).then(r=>{if("error"in r){if(r.error==="ALREADY_FULLSCREEN")return!0;throw new _(cr,"Fullscreen request failed",r.error)}return r.is_fullscreen}).then(r=>{r!==Yn()&&Se({isFullscreen:r})}),()=>new _(G,"Fullscreen mode change is already being requested"),Pt,Zn))}const ka=Na("requestFullscreen",Ta),La=Na("exitFullscreen","web_app_exit_fullscreen"),Va=U(ge),zc=at(ge,ye);function Ot(e){return d(()=>Bt()[e])}const Bt=x("safeAreaInsets"),Xn=Ot("bottom"),xn=Ot("left"),eo=Ot("right"),to=Ot("top");function It(e){return d(()=>Dt()[e])}const Dt=x("contentSafeAreaInsets"),no=It("bottom"),oo=It("left"),ro=It("right"),so=It("top"),ja=R("requestContentSafeAreaInsets",e=>y(Ba,"content_safe_area_changed",e),{isSupported:Ba}),qa=R("requestSafeAreaInsets",e=>y(Oa,"safe_area_changed",e),{isSupported:Oa});function Ua(e){return y("web_app_request_viewport","viewport_changed",e).then(t=>({height:t.height,width:t.width,isExpanded:t.is_expanded,isStable:t.is_state_stable}))}const Ha=e=>{const{height:t}=e;Se({isExpanded:e.is_expanded,height:t,width:e.width,stableHeight:e.is_state_stable?t:void 0})},Fa=e=>{Se({isFullscreen:e.is_fullscreen})},Wa=e=>{Se({safeAreaInsets:e})},Ga=e=>{Se({contentSafeAreaInsets:e})},za=Va("mount",gr(ge,e=>b.resolve().then(async()=>{const t=N()&&Wc();if(t)return t;const[o,r]=await b.all([qa.ifAvailable(e)||Bt(),ja.ifAvailable(e)||Dt()]),s=Y(),a={contentSafeAreaInsets:r,isFullscreen:!!s.fullscreen,safeAreaInsets:o};if(["macos","tdesktop","unigram","webk","weba","web"].includes(s.platform)){const i=window;return{...a,height:i.innerHeight,isExpanded:!0,stableHeight:i.innerHeight,width:i.innerWidth}}return Ua(e).then(i=>({...a,height:i.height,isExpanded:i.isExpanded,stableHeight:i.isStable?i.height:0,width:i.width}))}),e=>{g(Pa,Ha),g(Qn,Fa),g(va,Wa),g($a,Ga),Se(e)},ye,qe,Kn));function Qa(){const e=qe();e&&e.cancel(),O(Pa,Ha),O(Qn,Fa),O(va,Wa),O($a,Ga),ye.set(!1)}const Ue=u(!1),Mt=x("height"),Nt=x("stableHeight"),ao=x("width"),Ja=zc("bindCssVars",e=>{Ue()&&Pn(),e||(e=o=>`--tg-viewport-${xt(o)}`);const t=[["height",Mt],["stableHeight",Nt],["width",ao],["safeAreaInsetTop",to],["safeAreaInsetBottom",Xn],["safeAreaInsetLeft",xn],["safeAreaInsetRight",eo],["contentSafeAreaInsetTop",so],["contentSafeAreaInsetBottom",no],["contentSafeAreaInsetLeft",oo],["contentSafeAreaInsetRight",ro]].reduce((o,[r,s])=>{const a=e(r);if(a){const i=()=>{ze(a,`${s()}px`)};o.push([i,s.sub(i),a])}return o},[]);return t.forEach(o=>{o[0]()}),Ue.set(!0),()=>{t.forEach(o=>{o[1](),Qe(o[2])}),Ue.set(!1)}}),Ya=Va("expand",()=>{p("web_app_expand")}),Za=x("isExpanded"),Ka=d(()=>Mt()===Nt()),Qc=Object.freeze(Object.defineProperty({__proto__:null,bindCssVars:Ja,changeFullscreenError:Zn,changeFullscreenPromise:Pt,contentSafeAreaInsetBottom:no,contentSafeAreaInsetLeft:oo,contentSafeAreaInsetRight:ro,contentSafeAreaInsetTop:so,contentSafeAreaInsets:Dt,exitFullscreen:La,expand:Ya,height:Mt,isChangingFullscreen:Da,isCssVarsBound:Ue,isExpanded:Za,isFullscreen:Yn,isMounted:ye,isMounting:Ma,isStable:Ka,mount:za,mountError:Kn,mountPromise:qe,requestFullscreen:ka,safeAreaInsetBottom:Xn,safeAreaInsetLeft:xn,safeAreaInsetRight:eo,safeAreaInsetTop:to,safeAreaInsets:Bt,stableHeight:Nt,state:we,unmount:Qa,width:ao},Symbol.toStringTag,{value:"Module"})),Xa="web_app_request_emoji_status_access",io=u(),xa=u(),Jc=d(()=>!!io()),Yc=R("requestEmojiStatusAccess",ot(()=>y(Xa,"emoji_status_access_requested").then(e=>e.status),()=>new _(G,"Emoji status access request is currently in progress"),io,xa,!1),{isSupported:Xa}),ei="web_app_set_emoji_status",co=u(),ti=u(),Zc=d(()=>!!co()),Kc=R("setEmojiStatus",ot(async(e,t)=>{const o=await y(ei,["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:e,duration:t}});if(o&&"error"in o)throw new _(ur,"Failed to set emoji status",o.error)},()=>new _(G,"Emoji status set request is currently in progress"),co,ti,!1),{isSupported:ei}),Xc=U()("openLink",(e,t)=>{if(typeof e=="string")try{e=new URL(e)}catch(o){throw new _(Ke,`"${e.toString()}" is invalid URL`,o)}t||(t={}),p("web_app_open_link",{url:e.toString(),try_browser:t.tryBrowser,try_instant_view:t.tryInstantView})}),ni="web_app_open_tg_link",oi=U()("openTelegramLink",e=>{const t=e.toString();if(!t.match(/^https:\/\/t.me\/.+/))throw new _(Ke,`"${t}" is invalid URL`);if(!W(ni,k())){window.location.href=t;return}e=new URL(e),p(ni,{path_full:e.pathname+e.search})}),xc=U()("shareURL",(e,t)=>{oi("https://t.me/share/url?"+new URLSearchParams({url:e,text:t||""}).toString().replace(/\+/g,"%20"))}),uo="web_app_request_phone",kt=u(!1),ri=R("requestPhoneAccess",e=>{if(kt())throw new _(G,"Phone access request is currently in progress");return kt.set(!0),y(uo,"phone_requested",e).then(t=>t.status).finally(()=>{kt.set(!1)})},{isSupported:uo});function si(e){return e||(e={}),se("getRequestedContact",{},{...e,timeout:e.timeout||5e3}).then(ho({contact:He({userId:["user_id",Fe()],phoneNumber:["phone_number",q()],firstName:["first_name",q()],lastName:["last_name",q(!0)]})(),authDate:["auth_date",Ut()],hash:q()})())}const eu=R("requestContact",e=>b.withFn(async t=>{const o={abortSignal:t};try{return await si(o)}catch{}if(await ri(o)!=="sent")throw new _(nr,"User denied access");let s=50;for(;!t.aborted;){try{return await si(o)}catch{}await Ui(s),s+=50}return null},e),{isSupported:uo}),ai="web_app_request_write_access",Lt=u(!1),tu=R("requestWriteAccess",e=>{if(Lt())throw new _(G,"Write access request is currently in progress");return Lt.set(!0),y(ai,"write_access_requested",e).then(t=>t.status).finally(()=>{Lt.set(!1)})},{isSupported:ai}),nu=R("getCurrentTime",e=>se("getCurrentTime",{},e).then(Ut()),{isSupported:"web_app_invoke_custom_method"}),ii="web_app_read_text_from_clipboard",ou=R("readTextFromClipboard",e=>{const t=xo();return y(ii,"clipboard_text_received",{...e,params:{req_id:t},capture:Qo(t)}).then(({data:o=null})=>o)},{isSupported:ii}),ru=R("sendData",e=>{const{size:t}=new Blob([e]);if(!t||t>4096)throw new _(tr,t?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data");p("web_app_data_send",{data:e})}),ci="web_app_share_to_story",su=R("shareStory",(e,t)=>{t||(t={}),p(ci,{text:t.text,media_url:e,widget_link:t.widgetLink})},{isSupported:ci}),ui="web_app_switch_inline_query",au=R("switchInlineQuery",(e,t)=>{p(ui,{query:e,chat_types:t||[]})},{isSupported:[ui,{fn:()=>!!Y().botInline,error:"Mini App should be ran in Bot inline mode"}]});function iu(e){try{return{result:e()}}catch(t){return{error:t}}}function cu(e){sc(e),Go();const[t,o]=ne(g("reload_iframe",()=>{p("iframe_will_reload"),window.location.reload()}),zo),{acceptCustomStyles:r=!0}=e||{};if(r){const s=document.createElement("style");s.id="telegram-custom-styles",document.head.appendChild(s),t(g("set_custom_style",a=>{s.innerHTML=a}),()=>{document.head.removeChild(s)})}return p("iframe_ready",{reload_supported:!0}),o}return n.$createRequestId=Xo,n.$debug=Do,n.$postEvent=un,n.$targetOrigin=Uo,n.$version=k,n.CancelablePromise=b,n.ERR_ABORTED=Zt,n.ERR_ACCESS_DENIED=nr,n.ERR_ALREADY_MOUNTING=or,n.ERR_ALREADY_OPENED=Xe,n.ERR_ALREADY_REQUESTING=G,n.ERR_CANCELED=Kt,n.ERR_CSS_VARS_ALREADY_BOUND=rr,n.ERR_CUSTOM_METHOD_ERR_RESPONSE=qo,n.ERR_DATA_INVALID_SIZE=tr,n.ERR_EMOJI_STATUS_SET_FAILED=ur,n.ERR_FULLSCREEN_FAILED=cr,n.ERR_INVALID_SLUG=er,n.ERR_INVALID_URL=Ke,n.ERR_INVALID_VALUE=_o,n.ERR_METHOD_PARAMETER_UNSUPPORTED=jo,n.ERR_METHOD_UNSUPPORTED=Lo,n.ERR_NOT_AVAILABLE=sr,n.ERR_NOT_INITIALIZED=ar,n.ERR_NOT_MOUNTED=ir,n.ERR_NOT_SUPPORTED=ln,n.ERR_PARSE=jt,n.ERR_POPUP_INVALID_PARAMS=ae,n.ERR_RETRIEVE_LP_FAILED=Vo,n.ERR_TIMED_OUT=Xt,n.ERR_UNEXPECTED_TYPE=po,n.ERR_UNEXPECTED_VALUE=fo,n.ERR_UNKNOWN_ENV=rn,n.TypedError=_,n.addEventListener=Jt,n.authenticateBiometry=Rr,n.backButton=ac,n.bindMiniAppCssVars=qs,n.bindThemeParamsCssVars=Ds,n.bindViewportCssVars=Ja,n.biometry=dc,n.biometryMountError=pn,n.biometryState=ve,n.changeFullscreenError=Zn,n.changeFullscreenPromise=Pt,n.classNames=We,n.closeMiniApp=Us,n.closeQrScanner=gt,n.closingBehavior=mc,n.cloudStorage=bc,n.compareVersions=Yo,n.createPostEvent=Zo,n.defineEventHandlers=Go,n.deleteCloudStorageItem=jr,n.deleteCssVar=Qe,n.disableClosingConfirmation=Dr,n.disableVerticalSwipes=ya,n.emitMiniAppsEvent=Ze,n.enableClosingConfirmation=Mr,n.enableVerticalSwipes=Aa,n.exitFullscreen=La,n.expandViewport=Ya,n.getCloudStorageItem=qr,n.getCloudStorageKeys=Ur,n.getCurrentTime=nu,n.hapticFeedback=Ec,n.hapticFeedbackImpactOccurred=Wr,n.hapticFeedbackNotificationOccurred=Gr,n.hapticFeedbackSelectionChanged=zr,n.hideBackButton=dr,n.hideSettingsButton=pa,n.init=cu,n.initData=gc,n.initDataAuthDate=Sn,n.initDataCanSendAfter=yn,n.initDataCanSendAfterDate=Qr,n.initDataChat=Jr,n.initDataChatInstance=Zr,n.initDataChatType=Yr,n.initDataHash=Kr,n.initDataQueryId=Xr,n.initDataRaw=An,n.initDataReceiver=xr,n.initDataStartParam=ts,n.initDataState=lt,n.initDataUser=ns,n.invoice=yc,n.invokeCustomMethod=Ko,n.isAbortError=Vi,n.isAuthenticatingBiometry=$e,n.isBackButtonMounted=ie,n.isBackButtonSupported=_r,n.isBackButtonVisible=nt,n.isBiometryMounted=Oe,n.isBiometryMounting=wr,n.isBiometrySupported=Ar,n.isCanceledError=ji,n.isChangingFullscreen=Da,n.isClosingBehaviorMounted=ue,n.isClosingConfirmationEnabled=ct,n.isCloudStorageSupported=Vr,n.isColorDark=Rn,n.isFullscreen=Yn,n.isHapticFeedbackSupported=Fr,n.isIframe=vo,n.isInvoiceOpened=Ie,n.isInvoiceSupported=os,n.isMainButtonEnabled=ws,n.isMainButtonLoaderVisible=Ss,n.isMainButtonMounted=_e,n.isMainButtonVisible=ys,n.isMiniAppCssVarsBound=ke,n.isMiniAppDark=Ls,n.isMiniAppMounted=me,n.isMiniAppSupported=Vs,n.isPopupOpened=Ve,n.isPopupSupported=Gs,n.isQrScannerOpened=X,n.isQrScannerSupported=Js,n.isRGB=te,n.isRGBShort=bo,n.isRecord=Gt,n.isRequestingBiometryAccess=Pe,n.isRequestingEmojiStatusAccess=Jc,n.isRequestingPhoneAccess=kt,n.isRequestingWriteAccess=Lt,n.isSSR=_n,n.isSecondaryButtonEnabled=Xs,n.isSecondaryButtonLoaderVisible=xs,n.isSecondaryButtonMounted=he,n.isSecondaryButtonSupported=sa,n.isSecondaryButtonVisible=ea,n.isSettingEmojiStatus=Zc,n.isSettingsButtonMounted=be,n.isSettingsButtonSupported=fa,n.isSettingsButtonVisible=Rt,n.isSwipeBehaviorMounted=Ee,n.isSwipeBehaviorSupported=wa,n.isTMA=an,n.isThemeParamsCssVarsBound=De,n.isThemeParamsDark=_s,n.isThemeParamsMounted=le,n.isTimeoutError=Li,n.isVerticalSwipesEnabled=$t,n.isViewportCssVarsBound=Ue,n.isViewportExpanded=Za,n.isViewportMounted=ye,n.isViewportMounting=Ma,n.isViewportStable=Ka,n.mainButton=Rc,n.mainButtonBackgroundColor=Es,n.mainButtonHasShineEffect=gs,n.mainButtonState=dt,n.mainButtonText=As,n.mainButtonTextColor=Cs,n.mergeClassNames=gi,n.miniApp=$c,n.miniAppBackgroundColor=fe,n.miniAppBottomBarColor=de,n.miniAppBottomBarColorRGB=ht,n.miniAppHeaderColor=pe,n.miniAppHeaderColorRGB=In,n.miniAppReady=Fs,n.miniAppState=Dn,n.mockTelegramEnv=xi,n.mountBackButton=pr,n.mountBiometry=$r,n.mountClosingBehavior=Nr,n.mountMainButton=Ts,n.mountMiniApp=Hs,n.mountSecondaryButton=aa,n.mountSettingsButton=ma,n.mountSwipeBehavior=Ca,n.mountThemeParams=On,n.mountViewport=za,n.off=O,n.offBackButtonClick=hr,n.offMainButtonClick=$s,n.offSecondaryButtonClick=ca,n.offSettingsButtonClick=ba,n.on=g,n.onBackButtonClick=mr,n.onMainButtonClick=vs,n.onSecondaryButtonClick=ia,n.onSettingsButtonClick=ha,n.openBiometrySettings=Tr,n.openInvoice=ss,n.openLink=Xc,n.openPopup=zs,n.openQrScanner=Ys,n.openTelegramLink=oi,n.parseInitData=wc,n.parseThemeParams=Bs,n.popup=Bc,n.postEvent=Je,n.qrScanner=kc,n.readTextFromClipboard=ou,n.removeEventHandlers=zo,n.request=Ye,n.requestBiometry=yr,n.requestBiometryAccess=vr,n.requestContact=eu,n.requestContentSafeAreaInsets=ja,n.requestEmojiStatusAccess=Yc,n.requestEmojiStatusAccessError=xa,n.requestEmojiStatusAccessPromise=io,n.requestFullscreen=ka,n.requestPhoneAccess=ri,n.requestSafeAreaInsets=qa,n.requestViewport=Ua,n.requestWriteAccess=tu,n.restoreInitData=es,n.retrieveLaunchParams=Y,n.safeCall=iu,n.secondaryButton=Vc,n.secondaryButtonBackgroundColor=Zs,n.secondaryButtonHasShineEffect=Ks,n.secondaryButtonPosition=ta,n.secondaryButtonState=wt,n.secondaryButtonText=na,n.secondaryButtonTextColor=oa,n.sendData=ru,n.serializeLaunchParams=bi,n.serializeThemeParams=Wt,n.setCloudStorageItem=Hr,n.setCssVar=ze,n.setEmojiStatus=Kc,n.setEmojiStatusError=ti,n.setEmojiStatusPromise=co,n.setMainButtonParams=Ps,n.setMiniAppBackgroundColor=Vn,n.setMiniAppBottomBarColor=jn,n.setMiniAppHeaderColor=qn,n.setSecondaryButtonParams=ua,n.settingsButton=jc,n.shareStory=su,n.shareURL=xc,n.showBackButton=br,n.showSettingsButton=Ea,n.subscribe=ec,n.supports=W,n.swipeBehavior=Uc,n.switchInlineQuery=au,n.themeParams=Hc,n.themeParamsAccentTextColor=is,n.themeParamsBackgroundColor=_t,n.themeParamsBottomBarBgColor=vn,n.themeParamsButtonColor=ft,n.themeParamsButtonTextColor=Tn,n.themeParamsDestructiveTextColor=cs,n.themeParamsHeaderBackgroundColor=us,n.themeParamsHintColor=ls,n.themeParamsLinkColor=fs,n.themeParamsSecondaryBackgroundColor=Me,n.themeParamsSectionBackgroundColor=ds,n.themeParamsSectionHeaderTextColor=ps,n.themeParamsSectionSeparatorColor=ms,n.themeParamsState=H,n.themeParamsSubtitleTextColor=hs,n.themeParamsTextColor=bs,n.toRGB=Ft,n.toRecord=qt,n.unmountBackButton=Er,n.unmountBiometry=Or,n.unmountClosingBehavior=kr,n.unmountMainButton=Os,n.unmountMiniApp=Ws,n.unmountSecondaryButton=la,n.unmountSettingsButton=ga,n.unmountSwipeBehavior=Ra,n.unmountThemeParams=Ns,n.unmountViewport=Qa,n.unsubscribe=tc,n.updateBiometryToken=Br,n.viewport=Qc,n.viewportContentSafeAreaInsetBottom=no,n.viewportContentSafeAreaInsetLeft=oo,n.viewportContentSafeAreaInsetRight=ro,n.viewportContentSafeAreaInsetTop=so,n.viewportContentSafeAreaInsets=Dt,n.viewportHeight=Mt,n.viewportMountError=Kn,n.viewportMountPromise=qe,n.viewportSafeAreaInsetBottom=Xn,n.viewportSafeAreaInsetLeft=xn,n.viewportSafeAreaInsetRight=eo,n.viewportSafeAreaInsetTop=to,n.viewportSafeAreaInsets=Bt,n.viewportStableHeight=Nt,n.viewportState=we,n.viewportWidth=ao,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n}({});
this.telegramApps=this.telegramApps||{};this.telegramApps.sdk=function(n){"use strict";class Q extends Error{constructor(t,o,r){super(typeof o=="object"?o.message:o||t,{cause:typeof o=="object"?o.cause:r}),this.type=t,Object.setPrototypeOf(this,Q.prototype)}}function _o(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function mi(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}const fo="ERR_INVALID_VALUE",po="ERR_UNEXPECTED_VALUE",mo="ERR_UNEXPECTED_TYPE",Ht="ERR_PARSE";function ho(e,t){const o={};for(const r in e){const s=e[r];if(!s)continue;let a,i;typeof s=="function"?(a=r,i=s):[a,i]=s;try{const c=i(t(a));c!==void 0&&(o[r]=c)}catch(c){throw new Q(Ht,`Parser for "${r}" property failed${a===r?"":`. Source field: "${a}"`}`,c)}}return o}function Ft(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch(o){throw new Q(fo,{cause:o})}if(typeof t!="object"||!t||Array.isArray(t))throw new Q(po);return t}function j(e,t){return o=>{const r=s=>{if(!(o&&s===void 0))try{return t(s)}catch(a){throw new Q(Ht,{message:`"${e}" transformer failed to parse the value`,cause:a})}};return Object.assign(r,{isValid(s){try{return r(s),!0}catch{return!1}}})}}function Fe(e,t){return j(t||"object",o=>{const r=Ft(o);return ho(e,s=>r[s])})}function Ae(e){throw new Q(mo,`Unexpected value received: ${JSON.stringify(e)}`)}const hi=j("boolean",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;Ae(e)}),q=j("string",e=>{if(typeof e=="string"||typeof e=="number")return e.toString();Ae(e)}),We=j("number",e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=Number(e);if(!Number.isNaN(t))return t}Ae(e)}),Wt=j("date",e=>e instanceof Date?e:new Date(We()(e)*1e3));function bo(e,t){return j(t||"searchParams",o=>{typeof o!="string"&&!(o instanceof URLSearchParams)&&Ae(o);const r=typeof o=="string"?new URLSearchParams(o):o;return ho(e,s=>{const a=r.get(s);return a===null?void 0:a})})}function Gt(e){for(const t in e)e[t]=[_o(t),e[t]];return e}const bi=e=>{const t=We(),o=We(!0),r=q(),s=q(!0),a=hi(!0),i=Fe(Gt({addedToAttachmentMenu:a,allowsWriteToPm:a,firstName:r,id:t,isBot:a,isPremium:a,languageCode:s,lastName:s,photoUrl:s,username:s}),"User")(!0);return bo(Gt({authDate:Wt(),canSendAfter:o,chat:Fe(Gt({id:t,type:r,title:r,photoUrl:s,username:s}),"Chat")(!0),chatInstance:s,chatType:s,hash:r,queryId:s,receiver:i,startParam:s,signature:r,user:i}),"initData")(e)};function te(e){return/^#[\da-f]{6}$/i.test(e)}function Eo(e){return/^#[\da-f]{3}$/i.test(e)}function zt(e){const t=e.replace(/\s/g,"").toLowerCase();if(te(t))return t;if(Eo(t)){let r="#";for(let s=0;s<3;s+=1)r+=t[1+s].repeat(2);return r}const o=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(!o)throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);return o.slice(1).reduce((r,s)=>{const a=parseInt(s,10).toString(16);return r+(a.length===1?"0":"")+a},"#")}const Ei=j("rgb",e=>zt(q()(e))),gi=j("themeParams",e=>{const t=Ei(!0);return Object.entries(Ft(e)).reduce((o,[r,s])=>(o[mi(r)]=t(s),o),{})});function Qt(e){return JSON.stringify(Object.fromEntries(Object.entries(e).map(([t,o])=>[_o(t),o])))}function wi(e){const{initDataRaw:t,startParam:o,showSettings:r,botInline:s,fullscreen:a,defaultColors:i}=e,c=new URLSearchParams;return c.set("tgWebAppPlatform",e.platform),c.set("tgWebAppThemeParams",Qt(e.themeParams)),c.set("tgWebAppVersion",e.version),t&&c.set("tgWebAppData",t),o&&c.set("tgWebAppStartParam",o),typeof r=="boolean"&&c.set("tgWebAppShowSettings",r?"1":"0"),typeof s=="boolean"&&c.set("tgWebAppBotInline",s?"1":"0"),typeof a=="boolean"&&c.set("tgWebAppFullscreen",a?"1":"0"),i&&c.set("tgWebAppDefaultColors",Qt(i)),c.toString()}function Si(e,t){return j("array",o=>{let r;if(Array.isArray(o))r=o;else if(typeof o=="string")try{const s=JSON.parse(o);Array.isArray(s)&&(r=s)}catch{}return r||Ae(o),r.map(e)})}function Yt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ge(...e){return e.map(t=>{if(typeof t=="string")return t;if(Yt(t))return Ge(Object.entries(t).map(o=>o[1]&&o[0]));if(Array.isArray(t))return Ge(...t)}).filter(Boolean).join(" ")}function yi(...e){return e.reduce((t,o)=>(Yt(o)&&Object.entries(o).forEach(([r,s])=>{const a=Ge(t[r],s);a&&(t[r]=a)}),t),{})}class Y extends Error{constructor(t,o,r){super(typeof o=="object"?o.message:o||t,{cause:typeof o=="object"?o.cause:r}),this.type=t,Object.setPrototypeOf(this,Y.prototype)}}function go(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Ai(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}const Ci="ERR_INVALID_VALUE",Ri="ERR_UNEXPECTED_VALUE",vi="ERR_UNEXPECTED_TYPE",wo="ERR_PARSE";function So(e,t){const o={};for(const r in e){const s=e[r];if(!s)continue;let a,i;typeof s=="function"?(a=r,i=s):[a,i]=s;try{const c=i(t(a));c!==void 0&&(o[r]=c)}catch(c){throw new Y(wo,`Parser for "${r}" property failed${a===r?"":`. Source field: "${a}"`}`,c)}}return o}function yo(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch(o){throw new Y(Ci,{cause:o})}if(typeof t!="object"||!t||Array.isArray(t))throw new Y(Ri);return t}function D(e,t){return o=>{const r=s=>{if(!(o&&s===void 0))try{return t(s)}catch(a){throw new Y(wo,{message:`"${e}" transformer failed to parse the value`,cause:a})}};return Object.assign(r,{isValid(s){try{return r(s),!0}catch{return!1}}})}}function M(e,t){return D(t||"object",o=>{const r=yo(o);return So(e,s=>r[s])})}function Ce(e){throw new Y(vi,`Unexpected value received: ${JSON.stringify(e)}`)}const ze=D("boolean",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;Ce(e)}),$=D("string",e=>{if(typeof e=="string"||typeof e=="number")return e.toString();Ce(e)}),Re=D("number",e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=Number(e);if(!Number.isNaN(t))return t}Ce(e)}),Ti=D("date",e=>e instanceof Date?e:new Date(Re()(e)*1e3));function Ao(e,t){return D(t||"searchParams",o=>{typeof o!="string"&&!(o instanceof URLSearchParams)&&Ce(o);const r=typeof o=="string"?new URLSearchParams(o):o;return So(e,s=>{const a=r.get(s);return a===null?void 0:a})})}function Jt(e){for(const t in e)e[t]=[go(t),e[t]];return e}const $i=e=>{const t=Re(),o=Re(!0),r=$(),s=$(!0),a=ze(!0),i=M(Jt({addedToAttachmentMenu:a,allowsWriteToPm:a,firstName:r,id:t,isBot:a,isPremium:a,languageCode:s,lastName:s,photoUrl:s,username:s}),"User")(!0);return Ao(Jt({authDate:Ti(),canSendAfter:o,chat:M(Jt({id:t,type:r,title:r,photoUrl:s,username:s}),"Chat")(!0),chatInstance:s,chatType:s,hash:r,queryId:s,receiver:i,startParam:s,signature:r,user:i}),"initData")(e)};function Pi(e){return/^#[\da-f]{6}$/i.test(e)}function Oi(e){return/^#[\da-f]{3}$/i.test(e)}function Bi(e){const t=e.replace(/\s/g,"").toLowerCase();if(Pi(t))return t;if(Oi(t)){let r="#";for(let s=0;s<3;s+=1)r+=t[1+s].repeat(2);return r}const o=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(!o)throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);return o.slice(1).reduce((r,s)=>{const a=parseInt(s,10).toString(16);return r+(a.length===1?"0":"")+a},"#")}const Ii=D("rgb",e=>Bi($()(e))),Co=D("themeParams",e=>{const t=Ii(!0);return Object.entries(yo(e)).reduce((o,[r,s])=>(o[Ai(r)]=t(s),o),{})});function Zt(e){return JSON.stringify(Object.fromEntries(Object.entries(e).map(([t,o])=>[go(t),o])))}const Di=e=>{const t=$(),o=$(!0),r=ze(!0);return Ao({botInline:["tgWebAppBotInline",r],defaultColors:["tgWebAppDefaultColors",Co(!0)],fullscreen:["tgWebAppFullscreen",r],initData:["tgWebAppData",$i(!0)],initDataRaw:["tgWebAppData",o],platform:["tgWebAppPlatform",t],showSettings:["tgWebAppShowSettings",r],startParam:["tgWebAppStartParam",o],themeParams:["tgWebAppThemeParams",Co()],version:["tgWebAppVersion",t]},"launchParams")(e)};function Mi(e){const{initDataRaw:t,startParam:o,showSettings:r,botInline:s,fullscreen:a,defaultColors:i}=e,c=new URLSearchParams;return c.set("tgWebAppPlatform",e.platform),c.set("tgWebAppThemeParams",Zt(e.themeParams)),c.set("tgWebAppVersion",e.version),t&&c.set("tgWebAppData",t),o&&c.set("tgWebAppStartParam",o),typeof r=="boolean"&&c.set("tgWebAppShowSettings",r?"1":"0"),typeof s=="boolean"&&c.set("tgWebAppBotInline",s?"1":"0"),typeof a=="boolean"&&c.set("tgWebAppFullscreen",a?"1":"0"),i&&c.set("tgWebAppDefaultColors",Zt(i)),c.toString()}const Ro=M({eventType:$(),eventData:e=>e},"miniAppsMessage"),vo=D("fn",e=>{if(typeof e=="function")return e;Ce(e)});function Ni(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}const ki=M({TelegramWebviewProxy:M({postEvent:vo()})()});function To(e){return ki().isValid(e)}function $o(){try{return window.self!==window.top}catch{return!0}}var Li=Object.defineProperty,Vi=(e,t,o)=>t in e?Li(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,Po=(e,t,o)=>Vi(e,typeof t!="symbol"?t+"":t,o);let _=class pi extends Error{constructor(t,o,r){super(typeof o=="object"?o.message:o||t,{cause:typeof o=="object"?o.cause:r}),this.type=t,Object.setPrototypeOf(this,pi.prototype)}};function Kt(e,t,o){return e.addEventListener(t,o),()=>e.removeEventListener(t,o)}function ne(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(o=>{o()})}]}function ji(e,t){return e instanceof _&&e.type===t}function Xt(e){return t=>ji(t,e)}const xt="ERR_ABORTED",en="ERR_CANCELED",tn="ERR_TIMED_OUT";function Oo(e){return new _(xt,{cause:e})}const qi=Xt(tn),Ui=Xt(xt),Hi=Xt(en);function Bo(e,t){return e.reject=t.reject,e}class b extends Promise{constructor(t,o){let r,s;typeof t=="function"?(r=t,s=o):s=t;let a,i;super((c,f)=>{s||(s={});const{abortSignal:l}=s;if(l&&l.aborted)return f(Oo(l.reason));const[m,S]=ne(),C=h=>(...ee)=>(S(),h(...ee)),F=new AbortController,{signal:T}=F;i=C(h=>{F.abort(h),f(h)}),a=C(c),l&&m(Kt(l,"abort",()=>{i(Oo(l.reason))}));const{timeout:E}=s;if(E){const h=setTimeout(()=>{i(new _(tn,`Timeout reached: ${E}ms`))},E);m(()=>{clearTimeout(h)})}r&&r(a,i,T)}),Po(this,"reject"),this.reject=i}static withFn(t,o){return new b((r,s,a)=>{try{const i=t(a);return i instanceof Promise?i.then(r,s):r(i)}catch(i){s(i)}},o)}static resolve(t){return new b(o=>{o(t)})}static reject(t){return new b((o,r)=>{r(t)})}cancel(){this.reject(new _(en))}catch(t){return this.then(void 0,t)}finally(t){return Bo(super.finally(t),this)}then(t,o){return Bo(super.then(t,o),this)}}function Io(e,t){return e.resolve=t.resolve,e}let Fi=class Ut extends b{constructor(t,o){let r,s;typeof t=="function"?(r=t,s=o):s=t;let a;super((i,c,f)=>{a=i,r&&r(i,c,f)},s),Po(this,"resolve"),this.resolve=a}static withFn(t,o){return new Ut((r,s,a)=>b.withFn(t,{abortSignal:a}).then(r,s),o)}static resolve(t){return new Ut(o=>{o(t)})}static reject(t){return new Ut((o,r)=>{r(t)})}catch(t){return this.then(void 0,t)}finally(t){return Io(super.finally(t),this)}then(t,o){return Io(super.then(t,o),this)}};function Wi(e,t){return new b(o=>{setTimeout(o,e)},{abortSignal:t})}function Do(e){return`tapps/${e}`}function P(e,t){sessionStorage.setItem(Do(e),JSON.stringify(t))}function O(e){const t=sessionStorage.getItem(Do(e));try{return t?JSON.parse(t):void 0}catch{}}function nn(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Gi(e,t){t||(t={});const{textColor:o,bgColor:r,shouldLog:s=!0}=t;function a(i,...c){if(!s||typeof s=="function"&&!s())return;const f="font-weight:bold;padding:0 5px;border-radius:5px";console[i](`%c${Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(new Date)}%c / %c${e}`,`${f};background-color: lightblue;color:black`,"",`${f};${o?`color:${o};`:""}${r?`background-color:${r}`:""}`,...c)}return[function(...i){a("log",...i)},function(...i){a("error",...i)}]}function Qe(e,t){document.documentElement.style.setProperty(e,t)}function Ye(e){document.documentElement.style.removeProperty(e)}function zi(e,t){t()}function oe(e,t){t||(t={});const o=t.equals||Object.is;let r=[],s=e;const a=l=>{if(!o(s,l)){const m=s;s=l,zi(f,()=>{[...r].forEach(([S,C])=>{S(l,m),C&&c(S,!0)})})}};function i(l){const m=typeof l!="object"?{once:l}:l;return{once:m.once||!1,signal:m.signal||!1}}const c=(l,m)=>{const S=i(m),C=r.findIndex(([F,T])=>F===l&&T.once===S.once&&T.signal===S.signal);C>=0&&r.splice(C,1)},f=Object.assign(function(){return Qi(f),s},{destroy(){r=[]},set:a,reset(){a(e)},sub(l,m){return r.push([l,i(m)]),()=>c(l,m)},unsub:c,unsubAll(){r=r.filter(l=>l[1].signal)}});return f}const on=[];function Qi(e){on.length&&on[on.length-1].add(e)}const Mo=oe(!1),[rn,Yi]=Gi("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:Mo}),Ji={clipboard_text_received:M({req_id:$(),data:e=>e===null?e:$(!0)(e)},"clipboard_text_received"),custom_method_invoked:M({req_id:$(),result:e=>e,error:$(!0)},"custom_method_invoked"),popup_closed:D("popup_closed",e=>e?M({button_id:t=>t==null?void 0:$()(t)})()(e):{}),viewport_changed:M({height:Re(),width:e=>e==null?window.innerWidth:Re()(e),is_state_stable:ze(),is_expanded:ze()},"viewport_changed")};function Zi(e){const t=window,[,o]=ne(Kt(t,"message",r=>{if(r.source!==t.parent)return;let s;try{s=Ro()(r.data)}catch{return}const{eventType:a,eventData:i}=s,c=Ji[a];try{const f=c?c()(i):i;rn("Event received:",f?{eventType:a,eventData:f}:{eventType:a}),e([a,f])}catch(f){Yi([`An error occurred processing the "${a}" event from the Telegram application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/telegram-apps/issues/new/choose"].join(`
`),s,f)}}));return o}const sn=oe(),No=oe();function ko(){return No()||No.set(Zi(sn.set)),sn}const an=oe({});function Lo(e){let t=an()[e];return t||(t=oe(void 0,{equals(){return!1}}),ko().sub(o=>{o&&o[0]===e&&t.set(o[1])}),an.set({...an(),[e]:t})),t}function g(e,t,o){return Lo(e).sub(t,o)}const Vo="ERR_METHOD_UNSUPPORTED",jo="ERR_RETRIEVE_LP_FAILED",qo="ERR_METHOD_PARAMETER_UNSUPPORTED",cn="ERR_UNKNOWN_ENV",Uo="ERR_INVOKE_CUSTOM_METHOD_RESPONSE",Ho=oe("https://web.telegram.org");function Je(e,t){rn("Posting event:",t?{eventType:e,eventData:t}:{eventType:e});const o=window;if(To(o)){o.TelegramWebviewProxy.postEvent(e,JSON.stringify(t));return}const r=JSON.stringify({eventType:e,eventData:t});if($o())return o.parent.postMessage(r,Ho());const{external:s}=o;if(M({notify:vo()})().isValid(s)){s.notify(r);return}throw new _(cn)}function Ze(e,t,o){o||(o={});const{capture:r}=o,[s,a]=ne();return new b(i=>{(Array.isArray(t)?t:[t]).forEach(c=>{s(g(c,f=>{(!r||(Array.isArray(t)?r({event:c,payload:f}):r(f)))&&i(f)}))}),(o.postEvent||Je)(e,o.params)},o).finally(a)}function un(e){return Di()(e)}function Fo(e){return un(e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&"))}function Ki(){return Fo(window.location.href)}function Xi(){const e=performance.getEntriesByType("navigation")[0];if(!e)throw new Error("Unable to get first navigation entry.");return Fo(e.name)}const xi="launchParams";function ec(){return un(O(xi)||"")}function Wo(e){P("launchParams",Mi(e))}function Go(e){return e instanceof Error?e.message+(e.cause?`
${Go(e.cause)}`:""):JSON.stringify(e)}function J(){const e=[];for(const t of[Ki,Xi,ec])try{const o=t();return Wo(o),o}catch(o){e.push(o)}throw new _(jo,["Unable to retrieve launch parameters from any known source. Perhaps, you have opened your app outside Telegram?","📖 Refer to docs for more information:","https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk/environment","Collected errors:",...e.map(t=>`— ${Go(t)}`)].join(`
`))}function ln(e){if(e==="simple")try{return J(),!0}catch{return!1}return b.withFn(async()=>{if(To(window))return!0;try{return await Ze("web_app_request_theme","theme_changed",{timeout:100}),!0}catch{return!1}},e)}function Ke(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}function tc(e,t){if(typeof t=="string")try{const{eventType:o}=Ro()(t);o==="web_app_request_theme"&&Ke("theme_changed",{theme_params:JSON.parse(Zt(e))}),o==="web_app_request_viewport"&&Ke("viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0})}catch{}}function nc(e){var t;const o=typeof e=="string"?un(e):e;Wo(o);const r=(t=window.TelegramWebviewProxy)==null?void 0:t.postEvent;window.TelegramWebviewProxy={postEvent(s,a){tc(o.themeParams,JSON.stringify({eventType:s,eventData:a})),r==null||r(s,a)}},rn("Environment was mocked by the mockTelegramEnv function")}function zo(){[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["Telegram","WebView","receiveEvent"]].forEach(e=>{let t=window;e.forEach((o,r,s)=>{if(r===s.length-1){t[o]=Ke;return}o in t||(t[o]={}),t=t[o]})})}function Qo(){["TelegramGameProxy_receiveEvent","TelegramGameProxy","Telegram"].forEach(e=>{delete window[e]})}function v(e,t,o){Lo(e).unsub(t,o)}function oc(e,t){return ko().sub(e,t)}function rc(e,t){sn.unsub(e,t)}function Yo(e){return({req_id:t})=>t===e}function Jo(e){return e.split(".").map(Number)}function Zo(e,t){const o=Jo(e),r=Jo(t),s=Math.max(o.length,r.length);for(let a=0;a<s;a+=1){const i=o[a]||0,c=r[a]||0;if(i!==c)return i>c?1:-1}return 0}function w(e,t){return Zo(e,t)<=0}function W(e,t,o){if(typeof o=="string"){if(e==="web_app_open_link"){if(t==="try_instant_view")return w("6.4",o);if(t==="try_browser")return w("7.6",o)}if(e==="web_app_set_header_color"&&t==="color")return w("6.9",o);if(e==="web_app_close"&&t==="return_back")return w("7.6",o);if(e==="web_app_setup_main_button"&&t==="has_shine_effect")return w("7.10",o)}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 w("6.1",t);case"web_app_open_popup":return w("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 w("6.4",t);case"web_app_switch_inline_query":return w("6.7",t);case"web_app_invoke_custom_method":case"web_app_request_write_access":case"web_app_request_phone":return w("6.9",t);case"web_app_setup_settings_button":return w("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 w("7.2",t);case"web_app_setup_swipe_behavior":return w("7.7",t);case"web_app_share_to_story":return w("7.8",t);case"web_app_setup_secondary_button":case"web_app_set_bottom_bar_color":return w("7.10",t);case"web_app_request_safe_area":case"web_app_request_content_safe_area":case"web_app_request_fullscreen":case"web_app_exit_fullscreen":case"web_app_set_emoji_status":case"web_app_request_emoji_status_access":return w("8.0",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 Ko(e,t){t||(t="strict");const o=typeof t=="function"?t:r=>{const{method:s,version:a}=r;let i,c;if("param"in r?(i=`Parameter "${r.param}" of "${s}" method is unsupported in Mini Apps version ${a}`,c=qo):(i=`Method "${s}" is unsupported in Mini Apps version ${a}`,c=Vo),t==="strict")throw new _(c,i);return console.warn(i)};return(r,s)=>W(r,e)?Ni(s)&&r==="web_app_set_header_color"&&"color"in s&&!W(r,"color",e)?o({version:e,method:r,param:"color"}):Je(r,s):o({version:e,method:r})}function Xo(e,t,o,r){return Ze("web_app_invoke_custom_method","custom_method_invoked",{...r||{},params:{method:e,params:t,req_id:o},capture:Yo(o)}).then(({result:s,error:a})=>{if(a)throw new _(Uo,a);return s})}function sc(){return performance.getEntriesByType("navigation")[0]}function N(){const e=sc();return!!e&&e.type==="reload"}let re;function ac(e,t){re&&re.set(e,t)||t()}function _n(e){if(re)return e();re=new Map;try{e()}finally{re.forEach(t=>t()),re=void 0}}function u(e,t){t||(t={});const o=t.equals||Object.is;let r=[],s=e;const a=l=>{if(!o(s,l)){const m=s;s=l,ac(f,()=>{[...r].forEach(([S,C])=>{S(l,m),C&&c(S,!0)})})}};function i(l){const m=typeof l!="object"?{once:l}:l;return{once:m.once||!1,signal:m.signal||!1}}const c=(l,m)=>{const S=i(m),C=r.findIndex(([F,T])=>F===l&&T.once===S.once&&T.signal===S.signal);C>=0&&r.splice(C,1)},f=Object.assign(function(){return ic(f),s},{destroy(){r=[]},set:a,reset(){a(e)},sub(l,m){return r.push([l,i(m)]),()=>c(l,m)},unsub:c,unsubAll(){r=r.filter(l=>l[1].signal)}});return f}const ve=[];function ic(e){ve.length&&ve[ve.length-1].add(e)}function d(e,t){let o=new Set,r;function s(){return r||(r=u(i(),t))}function a(){s().set(i())}function i(){o.forEach(l=>{l.unsub(a,{signal:!0})});const c=new Set;let f;ve.push(c);try{f=e()}finally{ve.pop()}return c.forEach(l=>{l.sub(a,{signal:!0})}),o=c,f}return Object.assign(function(){return s()()},{destroy(){s().destroy()},sub(...c){return s().sub(...c)},unsub(...c){s().unsub(...c)},unsubAll(...c){s().unsubAll(...c)}})}const xo=u((()=>{let e=0;return()=>(e+=1).toString()})()),fn=u(Je),k=u("0.0");function cc(e){e||(e={});const{postEvent:t}=e,o=e.version||J().version;k.set(o),fn.set(typeof t=="function"?t:Ko(o))}function er(){return xo()()}function se(e,t,o){return Xo(e,t,er(),{...o||{},postEvent:p})}const y=(e,t,o)=>(o||(o={}),o.postEvent||(o.postEvent=p),Ze(e,t,o)),p=(e,t)=>fn()(e,t);function L(e){return d(()=>W(e,k()))}const ae="ERR_POPUP_INVALID_PARAMS",Xe="ERR_INVALID_URL",tr="ERR_INVALID_SLUG",nr="ERR_DATA_INVALID_SIZE",or="ERR_ACCESS_DENIED",G="ERR_ALREADY_REQUESTING",xe="ERR_ALREADY_OPENED",rr="ERR_ALREADY_MOUNTING",sr="ERR_VARS_ALREADY_BOUND",ar="ERR_NOT_AVAILABLE",ir="ERR_NOT_INITIALIZED",dn="ERR_NOT_SUPPORTED",cr="ERR_NOT_MOUNTED",ur="ERR_FULLSCREEN_FAILED",lr="ERR_EMOJI_STATUS_SET_FAILED";function pn(){return typeof window>"u"}function R(e,t,{isSupported:o,isMounted:r,component:s,supports:a}={}){const i=`${s?`${s}.`:""}${e}()`;o=o?Array.isArray(o)||typeof o=="object"&&"any"in o?o:[o]:void 0;function c(E){if(a){const h=a[E];return W(h[0],h[1],k())}return!0}const f=()=>{if(!o)return;const E=`it is unsupported in Mini Apps version ${k()}`;function h(I){return typeof I=="string"?W(I,k())?void 0:E:I.fn()?void 0:I.error}if(Array.isArray(o)){for(const I of o){const di=h(I);if(di)return di}return}let ee;for(const I of o.any)if(ee=h(I),!ee)return;return E},l=(...E)=>{if(a){for(const h in a)if(a[h][2](...E)&&!c(h))return`option ${h} is not supported in Mini Apps version ${k()}`}},m=d(()=>!f()),S=d(()=>k()!=="0.0"),C=d(()=>!r||r()),F=d(()=>ln("simple")&&!pn()&&S()&&m()&&C());let T;if(a){T={};for(const E in a)T[E]=d(()=>c(E))}return Object.assign((...E)=>{const h=`Unable to call the ${i} ${s?"method":"function"}:`;if(pn()||!ln("simple"))throw new _(cn,`${h} it can't be called outside Mini Apps`);if(!S())throw new _(ir,`${h} the SDK was not initialized. Use the SDK init() function`);const ee=f();if(ee)throw new _(dn,`${h} ${ee}`);const I=l(...E);if(I)throw new _(dn,`${h} ${I}`);if(!C())throw new _(cr,`${h} the component is not mounted. Use the ${s}.mount() method`);return t(...E)},t,{isAvailable:F,ifAvailable(...E){return F()?t(...E):void 0}},o?{isSupported:m}:{},T?{supports:T}:{})}function et(e,t){return t||(t={}),(o,r,s,a)=>R(o,r,{...t,isSupported:s||t.isSupported,supports:a,component:e})}function Z(e,t,o){return et(e,{isSupported:o,isMounted:t})}function B(e,t){return et(e,{isSupported:t})}const tt="web_app_setup_back_button",_r="back_button_pressed",nt="backButton",ot=u(!1),ie=u(!1),fr=L(tt),dr=Z(nt,ie,tt),mn=B(nt,tt),pr=dr("hide",()=>{hn(!1)}),mr=mn("mount",()=>{ie()||(hn(N()&&O(nt)||!1),ie.set(!0))});function hn(e){e!==ot()&&(p(tt,{is_visible:e}),P(nt,e),ot.set(e))}const hr=mn("onClick",e=>g(_r,e)),br=mn("offClick",e=>{v(_r,e)}),Er=dr("show",()=>{hn(!0)});function gr(){ie.set(!1)}const uc=Object.freeze(Object.defineProperty({__proto__:null,hide:pr,isMounted:ie,isSupported:fr,isVisible:ot,mount:mr,offClick:br,onClick:hr,show:Er,unmount:gr},Symbol.toStringTag,{value:"Module"}));function rt(e,t,o,r,s){const a=s===void 0||s?b:Promise;return Object.assign((...i)=>a.resolve().then(async()=>{if(o()){const f=t();throw r.set(f),f}_n(()=>{o.set(a.resolve(e(...i))),r.set(void 0)});let c;try{c=[!0,await o()]}catch(f){c=[!1,f]}if(_n(()=>{o.set(void 0),r.set(c[0]?void 0:c[1])}),!c[0])throw c[1];return c[1]}),e)}function wr(e,t,o,r,s,a){const i=rt(t,()=>new _(rr,`The ${e} component is already mounting`),s,a);return c=>b.resolve().then(async()=>{if(!r()){const f=await i(c);_n(()=>{r.set(!0),o(f)})}})}const U=et,Te=u({available:!1}),$e=u(!1),Pe=u(!1),Oe=u(!1),Sr=d(()=>!!En()),bn=u(),En=u(),lc=d(()=>{const e=Te();return e&&e.available});function gn(e){return e.available?{available:!0,tokenSaved:e.token_saved,deviceId:e.device_id,accessRequested:e.access_requested,type:e.type,accessGranted:e.access_granted}:{available:!1}}const yr="web_app_biometry_get_info",Ar=R("requestBiometry",e=>y(yr,"biometry_info_received",e).then(gn),{isSupported:yr}),st="web_app_biometry_request_auth",_c="web_app_biometry_request_access",fc="web_app_biometry_open_settings",dc="web_app_biometry_update_token",wn="biometry_info_received",ce="biometry",Cr=L(st),pc=U(ce),mc=B(ce,st),Sn=Z(ce,Oe,st);function Rr(){throw new _(ar,"Biometry is not available")}const vr=Sn("authenticate",e=>b.withFn(async t=>{if($e())throw new _(G,"Authentication is already in progress");const o=Te();(!o||!o.available)&&Rr(),$e.set(!0);try{const r=await y(st,"biometry_auth_requested",{abortSignal:t,params:{reason:((e||{}).reason||"").trim()}}),{token:s}=r;return typeof s=="string"&&at({...o,token:s}),r}finally{$e.set(!1)}},e)),Tr=mc("openSettings",()=>{p(fc)}),$r=Sn("requestAccess",e=>b.withFn(async t=>{if(Pe())throw new _(G,"Access request is already in progress");Pe.set(!0);try{const o=await y(_c,wn,{abortSignal:t,params:{reason:(e||{}).reason||""}}).then(gn);return o.available||Rr(),at(o),o.accessGranted}finally{Pe.set(!1)}},e)),Pr=pc("mount",wr(ce,e=>{const t=N()&&O(ce);return t||Ar(e)},e=>{g(wn,Or),at(e)},Oe,En,bn)),Or=e=>{at(gn(e))};function at(e){Te.set(e),P(ce,e)}function Br(){v(wn,Or),Oe.set(!1)}const Ir=Sn("updateToken",e=>(e||(e={}),y(dc,"biometry_token_updated",{...e,params:{token:e.token||"",reason:e.reason}}).then(t=>t.status))),hc=Object.freeze(Object.defineProperty({__proto__:null,authenticate:vr,isAuthenticating:$e,isAvailable:lc,isMounted:Oe,isMounting:Sr,isRequestingAccess:Pe,isSupported:Cr,mount:Pr,mountError:bn,mountPromise:En,openSettings:Tr,requestAccess:$r,state:Te,unmount:Br,updateToken:Ir},Symbol.toStringTag,{value:"Module"}));function it(e,t){return et(e,{isMounted:t})}const ct="closingBehavior",ut=u(!1),ue=u(!1),Dr=it(ct,ue),bc=U(ct),Mr=Dr("disableConfirmation",()=>{yn(!1)}),Nr=Dr("enableConfirmation",()=>{yn(!0)}),kr=bc("mount",()=>{ue()||(yn(N()&&O(ct)||!1),ue.set(!0))});function yn(e){e!==ut()&&(p("web_app_setup_closing_behavior",{need_confirmation:e}),P(ct,e),ut.set(e))}function Lr(){ue.set(!1)}const Ec=Object.freeze(Object.defineProperty({__proto__:null,disableConfirmation:Mr,enableConfirmation:Nr,isConfirmationEnabled:ut,isMounted:ue,mount:kr,unmount:Lr},Symbol.toStringTag,{value:"Module"})),Vr="web_app_invoke_custom_method",lt=B("cloudStorage",Vr),jr=L(Vr),qr=lt("deleteItem",(e,t)=>{const o=Array.isArray(e)?e:[e];return o.length?se("deleteStorageValues",{keys:o},t).then():b.resolve()});function gc(e,t){const o=Array.isArray(e)?e:[e];return o.length?se("getStorageValues",{keys:o},t).then(r=>{const s=Fe(Object.fromEntries(o.map(a=>[a,q()])))()(r);return Array.isArray(e)?s:s[e]}):b.resolve(typeof e=="string"?"":{})}const Ur=lt("getItem",gc),Hr=lt("getKeys",e=>se("getStorageKeys",{},e).then(Si(q())())),Fr=lt("setItem",(e,t,o)=>se("saveStorageValue",{key:e,value:t},o).then()),wc=Object.freeze(Object.defineProperty({__proto__:null,deleteItem:qr,getItem:Ur,getKeys:Hr,isSupported:jr,setItem:Fr},Symbol.toStringTag,{value:"Module"})),Be="web_app_trigger_haptic_feedback",An=B("hapticFeedback",Be),Wr=L(Be),Gr=An("impactOccurred",e=>{p(Be,{type:"impact",impact_style:e})}),zr=An("notificationOccurred",e=>{p(Be,{type:"notification",notification_type:e})}),Qr=An("selectionChanged",()=>{p(Be,{type:"selection_change"})}),Sc=Object.freeze(Object.defineProperty({__proto__:null,impactOccurred:Gr,isSupported:Wr,notificationOccurred:zr,selectionChanged:Qr},Symbol.toStringTag,{value:"Module"})),_t=u(void 0);function V(e){return d(()=>{const t=_t();return t?t[e]:void 0})}const Cn=V("authDate"),Rn=V("canSendAfter"),Yr=d(()=>{const e=Cn(),t=Rn();return t&&e?new Date(e.getTime()+t*1e3):void 0}),Jr=V("chat"),Zr=V("chatType"),Kr=V("chatInstance"),Xr=V("hash"),xr=V("queryId"),vn=u(),es=V("receiver");function ts(){const e=J();_t.set(e.initData),vn.set(e.initDataRaw)}const ns=V("startParam"),os=V("user"),yc=Object.freeze(Object.defineProperty({__proto__:null,authDate:Cn,canSendAfter:Rn,canSendAfterDate:Yr,chat:Jr,chatInstance:Kr,chatType:Zr,hash:Xr,queryId:xr,raw:vn,receiver:es,restore:ts,startParam:ns,state:_t,user:os},Symbol.toStringTag,{value:"Module"}));function Ac(e){return bi()(e)}const Tn="web_app_open_invoice",Cc=B("invoice",Tn),Ie=u(!1),rs=L(Tn);async function ss(e,t,o){if(Ie())throw new _(xe,"An invoice is already opened");let r;if(t==="url"){const{hostname:s,pathname:a}=new URL(e,window.location.href);if(s!=="t.me")throw new _(Xe,`Link has unexpected hostname: ${s}`);const i=a.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);if(!i)throw new _(tr,'Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"');[,,r]=i}else r=e,o=t;return Ie.set(!0),y(Tn,"invoice_closed",{...o,params:{slug:r},capture:s=>r===s.slug}).then(s=>s.status).finally(()=>{Ie.set(!1)})}const as=Cc("open",ss),Rc=Object.freeze(Object.defineProperty({__proto__:null,_open:ss,isOpened:Ie,isSupported:rs,open:as},Symbol.toStringTag,{value:"Module"}));function is(e){return Object.fromEntries(Object.entries(e).filter(t=>t[1]!==void 0))}function $n(e){const t=zt(e);return Math.sqrt([.299,.587,.114].reduce((o,r,s)=>{const a=parseInt(t.slice(1+s*2,1+(s+1)*2),16);return o+a*a*r},0))<120}const le=u(!1),De=u(!1),H=u({});function A(e){return d(()=>H()[e])}const cs=A("accentTextColor"),ft=A("bgColor"),dt=A("buttonColor"),Pn=A("buttonTextColor"),On=A("bottomBarBgColor"),us=A("destructiveTextColor"),ls=A("headerBgColor"),_s=A("hintColor"),fs=d(()=>{const{bgColor:e}=H();return!e||$n(e)}),ds=A("linkColor"),Me=A("secondaryBgColor"),ps=A("sectionBgColor"),ms=A("sectionHeaderTextColor"),hs=A("sectionSeparatorColor"),bs=A("subtitleTextColor"),Es=A("textColor");function K(e){return d(()=>pt()[e])}const Ne=u({hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"}),pt=d(()=>{const e=Ne();return{...e,backgroundColor:e.backgroundColor||dt()||"#2481cc",textColor:e.textColor||Pn()||"#ffffff"}}),_e=u(!1),gs=K("backgroundColor"),ws=K("hasShineEffect"),Ss=K("isEnabled"),ys=K("isLoaderVisible"),As=K("isVisible"),Cs=K("text"),Rs=K("textColor"),vc="web_app_setup_main_button",vs="main_button_pressed",mt="mainButton",Bn=U(mt),Tc=it(mt,_e),Ts=Bn("mount",()=>{if(!_e()){const e=N()&&O(mt);e&&Ne.set(e),_e.set(!0)}}),$s=Bn("onClick",e=>g(vs,e)),Ps=Bn("offClick",e=>{v(vs,e)}),Os=Tc("setParams",e=>{Ne.set({...Ne(),...is(e)}),P(mt,Ne());const t=pt();t.text&&p(vc,{color:t.backgroundColor,has_shine_effect:t.hasShineEffect,is_active:t.isEnabled,is_progress_visible:t.isLoaderVisible,is_visible:t.isVisible,text:t.text,text_color:t.textColor})});function Bs(){_e.set(!1)}const $c=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:gs,hasShineEffect:ws,isEnabled:Ss,isLoaderVisible:ys,isMounted:_e,isVisible:As,mount:Ts,offClick:Ps,onClick:$s,setParams:Os,state:pt,text:Cs,textColor:Rs,unmount:Bs},Symbol.toStringTag,{value:"Module"}));function In(){throw new _(sr,"CSS variables are already bound")}function Is(e){return gi()(e)}const ht="themeParams",Ds="theme_changed",Pc=U(ht),Ms=it(ht,le)("bindCssVars",e=>{De()&&In(),e||(e=r=>`--tg-theme-${nn(r)}`);function t(r){Object.entries(H()).forEach(([s,a])=>{a&&r(s,a)})}function o(){t((r,s)=>{Qe(e(r),s)})}return o(),H.sub(o),De.set(!0),()=>{t(Ye),H.unsub(o),De.set(!1)}}),Dn=Pc("mount",()=>{le()||(g(Ds,Ns),H.set(N()&&O(ht)||J().themeParams),le.set(!0))}),Ns=e=>{const t=Is(e.theme_params);H.set(t),P(ht,t)};function ks(){v(Ds,Ns),le.set(!1)}function Ls(e){return d(()=>{const t=e();return te(t)?t:t==="bg_color"?ft():Me()})}const fe=u("bg_color"),bt=Ls(fe),de=u("bottom_bar_bg_color"),Et=d(()=>{const e=de();return te(e)?e:e==="bottom_bar_bg_color"?On()||Me():e==="secondary_bg_color"?Me():ft()}),pe=u("bg_color"),Mn=Ls(pe),me=u(!1),ke=u(!1),Vs=d(()=>{const e=bt();return e?$n(e):!1}),Le=u(!0),Nn=d(()=>({backgroundColor:fe(),bottomBarColor:de(),headerColor:pe(),isActive:Le()})),kn="web_app_set_background_color",Ln="web_app_set_bottom_bar_color",gt="web_app_set_header_color",js="visibility_changed",Ve="miniApp",Vn={any:[kn,Ln,gt]},qs=d(()=>Vn.any.some(e=>W(e,k()))),Us=U(Ve),Oc=B(Ve,Vn),wt=Z(Ve,me,Vn),Hs=wt("bindCssVars",e=>{ke()&&In();const[t,o]=ne();function r(s,a){function i(){Qe(s,a()||null)}i(),t(a.sub(i),Ye.bind(null,s))}return e||(e=s=>`--tg-${nn(s)}`),r(e("bgColor"),bt),r(e("bottomBarColor"),Et),r(e("headerColor"),Mn),t(()=>{ke.set(!1)}),ke.set(!0),o}),Fs=Us("close",e=>{p("web_app_close",{return_back:e})}),Ws=e=>{Le.set(e.is_visible),St()},Gs=Oc("mount",()=>{if(!me()){const e=N()&&O(Ve);Dn(),jn.ifAvailable(e?e.backgroundColor:"bg_color"),qn.ifAvailable(e?e.bottomBarColor:"bottom_bar_bg_color"),Un.ifAvailable(e?e.headerColor:"bg_color"),Le.set(e?e.isActive:!0),g(js,Ws),me.set(!0)}}),zs=Us("ready",()=>{p("web_app_ready")});function St(){P(Ve,Nn())}const jn=wt("setBackgroundColor",e=>{e!==fe()&&(p(kn,{color:e}),fe.set(e),St())},kn),qn=wt("setBottomBarColor",e=>{e!==de()&&(p(Ln,{color:e}),de.set(e),St())},Ln),Un=wt("setHeaderColor",e=>{e!==pe()&&(p(gt,te(e)?{color:e}:{color_key:e}),pe.set(e),St())},gt,{rgb:[gt,"color",te]});function Qs(){v(js,Ws),me.set(!1)}const Bc=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:fe,backgroundColorRGB:bt,bindCssVars:Hs,bottomBarColor:de,bottomBarColorRGB:Et,close:Fs,headerColor:pe,headerColorRGB:Mn,isActive:Le,isCssVarsBound:ke,isDark:Vs,isMounted:me,isSupported:qs,mount:Gs,ready:zs,setBackgroundColor:jn,setBottomBarColor:qn,setHeaderColor:Un,state:Nn,unmount:Qs},Symbol.toStringTag,{value:"Module"}));function Ic(e){const t=e.message.trim(),o=(e.title||"").trim(),r=e.buttons||[];if(o.length>64)throw new _(ae,`Invalid title: ${o}`);if(!t||t.length>256)throw new _(ae,`Invalid message: ${t}`);if(r.length>3)throw new _(ae,`Invalid buttons count: ${r.length}`);return{title:o,message:t,buttons:r.length?r.map((s,a)=>{const i=s.id||"";if(i.length>64)throw new _(ae,`Button with index ${a} has invalid id: ${i}`);if(!s.type||s.type==="default"||s.type==="destructive"){const c=s.text.trim();if(!c||c.length>64)throw new _(ae,`Button with index ${a} has invalid text: ${c}`);return{type:s.type,text:c,id:i}}return{type:s.type,id:i}}):[{type:"close",id:""}]}}const Hn="web_app_open_popup",Dc=B("popup",Hn),je=u(!1),Ys=L(Hn),Js=Dc("open",async e=>{if(je())throw new _(xe,"A popup is already opened");je.set(!0);try{const{button_id:t=null}=await y(Hn,"popup_closed",{...e,params:Ic(e)});return t}finally{je.set(!1)}}),Mc=Object.freeze(Object.defineProperty({__proto__:null,isOpened:je,isSupported:Ys,open:Js},Symbol.toStringTag,{value:"Module"})),Nc="web_app_close_scan_qr_popup",Fn="web_app_open_scan_qr_popup",kc="scan_qr_popup_closed",Lc="qr_text_received",Zs=B("qrScanner",Fn),yt=Zs("close",()=>{X.set(!1),p(Nc)}),X=u(!1),Ks=L(Fn);function Vc(e){return b.withFn(t=>{if(X())throw new _(xe,"The QR Scanner is already opened");X.set(!0),e||(e={});const{onCaptured:o,text:r,capture:s}=e,[,a]=ne(X.sub(()=>{i.resolve()}),g(kc,()=>{X.set(!1)}),g(Lc,c=>{o?o(c.data):(!s||s(c.data))&&(i.resolve(c.data),yt())})),i=new Fi({abortSignal:t}).catch(yt).finally(a);return(e.postEvent||p)(Fn,{text:r}),i},e)}const Xs=Zs("open",Vc),jc=Object.freeze(Object.defineProperty({__proto__:null,close:yt,isOpened:X,isSupported:Ks,open:Xs},Symbol.toStringTag,{value:"Module"}));function z(e){return d(()=>At()[e])}const qe=u({hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,position:"left",text:"Cancel"}),At=d(()=>{const e=qe();return{...e,backgroundColor:e.backgroundColor||Et()||"#000000",textColor:e.textColor||dt()||"#2481cc"}}),he=u(!1),xs=z("backgroundColor"),ea=z("hasShineEffect"),ta=z("isEnabled"),na=z("isLoaderVisible"),oa=z("isVisible"),ra=z("position"),sa=z("text"),aa=z("textColor"),Ct="web_app_setup_secondary_button",ia="secondary_button_pressed",Rt="secondaryButton",Wn=B(Rt,Ct),qc=Z(Rt,he,Ct),ca=L(Ct),ua=Wn("mount",()=>{if(!he()){const e=N()&&O(Rt);e&&qe.set(e),he.set(!0)}}),la=Wn("onClick",e=>g(ia,e)),_a=Wn("offClick",e=>{v(ia,e)}),fa=qc("setParams",e=>{qe.set({...qe(),...Object.fromEntries(Object.entries(e).filter(([,o])=>o!==void 0))}),P(Rt,qe());const t=At();t.text&&p(Ct,{color:t.backgroundColor,has_shine_effect:t.hasShineEffect,is_active:t.isEnabled,is_progress_visible:t.isLoaderVisible,is_visible:t.isVisible,position:t.position,text:t.text,text_color:t.textColor})});function da(){he.set(!1)}const Uc=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:xs,hasShineEffect:ea,isEnabled:ta,isLoaderVisible:na,isMounted:he,isSupported:ca,isVisible:oa,mount:ua,offClick:_a,onClick:la,position:ra,setParams:fa,state:At,text:sa,textColor:aa,unmount:da},Symbol.toStringTag,{value:"Module"})),vt="web_app_setup_settings_button",pa="settings_button_pressed",Tt="settingsButton",$t=u(!1),be=u(!1),ma=L(vt),Gn=B(Tt,vt),ha=Z(Tt,be,vt),ba=ha("hide",()=>{zn(!1)}),Ea=Gn("mount",()=>{be()||(zn(N()&&O(Tt)||!1),be.set(!0))});function zn(e){e!==$t()&&(p(vt,{is_visible:e}),P(Tt,e),$t.set(e))}const ga=Gn("onClick",e=>g(pa,e)),wa=Gn("offClick",e=>{v(pa,e)}),Sa=ha("show",()=>{zn(!0)});function ya(){be.set(!1)}const Hc=Object.freeze(Object.defineProperty({__proto__:null,hide:ba,isMounted:be,isSupported:ma,isVisible:$t,mount:Ea,offClick:wa,onClick:ga,show:Sa,unmount:ya},Symbol.toStringTag,{value:"Module"})),Pt="web_app_setup_swipe_behavior",Ot="swipeBehavior",Ee=u(!1),Aa=L(Pt),Bt=u(!0),Fc=B(Ot,Pt),Ca=Z(Ot,Ee,Pt),Ra=Ca("disableVertical",()=>{Qn(!1)}),va=Ca("enableVertical",()=>{Qn(!0)}),Ta=Fc("mount",()=>{Ee()||(Qn(N()&&O(Ot)||!1,!0),Ee.set(!0))});function Qn(e,t){(e!==Bt()||t)&&(p(Pt,{allow_vertical_swipe:e}),P(Ot,e),Bt.set(e))}function $a(){Ee.set(!1)}const Wc=Object.freeze(Object.defineProperty({__proto__:null,disableVertical:Ra,enableVertical:va,isMounted:Ee,isSupported:Aa,isVerticalEnabled:Bt,mount:Ta,unmount:$a},Symbol.toStringTag,{value:"Module"})),Gc=Object.freeze(Object.defineProperty({__proto__:null,accentTextColor:cs,backgroundColor:ft,bindCssVars:Ms,bottomBarBgColor:On,buttonColor:dt,buttonTextColor:Pn,destructiveTextColor:us,headerBackgroundColor:ls,hintColor:_s,isCssVarsBound:De,isDark:fs,isMounted:le,linkColor:ds,mount:Dn,secondaryBackgroundColor:Me,sectionBackgroundColor:ps,sectionHeaderTextColor:ms,sectionSeparatorColor:hs,state:H,subtitleTextColor:bs,textColor:Es,unmount:ks},Symbol.toStringTag,{value:"Module"})),ge="viewport",Pa="web_app_request_fullscreen",zc="fullscreen_failed",Yn="fullscreen_changed",Oa="safe_area_changed",Ba="content_safe_area_changed",Ia="viewport_changed",Da="web_app_request_safe_area",Ma="web_app_request_content_safe_area",Na={left:0,top:0,bottom:0,right:0};function Jn(e){return Math.max(e,0)}const we=u({contentSafeAreaInsets:Na,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:Na,stableHeight:0,width:0});function x(e){return d(()=>we()[e])}function Se(e){const{height:t,stableHeight:o,width:r}=e;we.set({...we(),...is({...e,height:t?Jn(t):void 0,width:r?Jn(r):void 0,stableHeight:o?Jn(o):void 0})}),P(ge,we())}function Qc(){return O(ge)}const Zn=x("isFullscreen"),It=u(),ka=d(()=>!!It()),Kn=u(),ye=u(!1),La=d(()=>!!Ue()),Xn=u(void 0),Ue=u(),Yc=Z(ge,ye,Pa);function Va(e,t){return Yc(e,rt(o=>y(t,[Yn,zc],o).then(r=>{if("error"in r){if(r.error==="ALREADY_FULLSCREEN")return!0;throw new _(ur,"Fullscreen request failed",r.error)}return r.is_fullscreen}).then(r=>{r!==Zn()&&Se({isFullscreen:r})}),()=>new _(G,"Fullscreen mode change is already being requested"),It,Kn))}const ja=Va("requestFullscreen",Pa),qa=Va("exitFullscreen","web_app_exit_fullscreen"),Ua=U(ge),Jc=it(ge,ye);function Dt(e){return d(()=>Mt()[e])}const Mt=x("safeAreaInsets"),xn=Dt("bottom"),eo=Dt("left"),to=Dt("right"),no=Dt("top");function Nt(e){return d(()=>kt()[e])}const kt=x("contentSafeAreaInsets"),oo=Nt("bottom"),ro=Nt("left"),so=Nt("right"),ao=Nt("top"),Ha=R("requestContentSafeAreaInsets",e=>y(Ma,"content_safe_area_changed",e),{isSupported:Ma}),Fa=R("requestSafeAreaInsets",e=>y(Da,"safe_area_changed",e),{isSupported:Da});function Wa(e){return y("web_app_request_viewport","viewport_changed",e).then(t=>({height:t.height,width:t.width,isExpanded:t.is_expanded,isStable:t.is_state_stable}))}const Ga=e=>{const{height:t}=e;Se({isExpanded:e.is_expanded,height:t,width:e.width,stableHeight:e.is_state_stable?t:void 0})},za=e=>{Se({isFullscreen:e.is_fullscreen})},Qa=e=>{Se({safeAreaInsets:e})},Ya=e=>{Se({contentSafeAreaInsets:e})},Ja=Ua("mount",wr(ge,e=>b.resolve().then(async()=>{const t=N()&&Qc();if(t)return t;const[o,r]=await b.all([Fa.ifAvailable(e)||Mt(),Ha.ifAvailable(e)||kt()]),s=J(),a={contentSafeAreaInsets:r,isFullscreen:!!s.fullscreen,safeAreaInsets:o};if(["macos","tdesktop","unigram","webk","weba","web"].includes(s.platform)){const i=window;return{...a,height:i.innerHeight,isExpanded:!0,stableHeight:i.innerHeight,width:i.innerWidth}}return Wa(e).then(i=>({...a,height:i.height,isExpanded:i.isExpanded,stableHeight:i.isStable?i.height:0,width:i.width}))}),e=>{g(Ia,Ga),g(Yn,za),g(Oa,Qa),g(Ba,Ya),Se(e)},ye,Ue,Xn));function Za(){const e=Ue();e&&e.cancel(),v(Ia,Ga),v(Yn,za),v(Oa,Qa),v(Ba,Ya),ye.set(!1)}const He=u(!1),Lt=x("height"),Vt=x("stableHeight"),io=x("width"),Ka=Jc("bindCssVars",e=>{He()&&In(),e||(e=o=>`--tg-viewport-${nn(o)}`);const t=[["height",Lt],["stableHeight",Vt],["width",io],["safeAreaInsetTop",no],["safeAreaInsetBottom",xn],["safeAreaInsetLeft",eo],["safeAreaInsetRight",to],["contentSafeAreaInsetTop",ao],["contentSafeAreaInsetBottom",oo],["contentSafeAreaInsetLeft",ro],["contentSafeAreaInsetRight",so]].reduce((o,[r,s])=>{const a=e(r);if(a){const i=()=>{Qe(a,`${s()}px`)};o.push([i,s.sub(i),a])}return o},[]);return t.forEach(o=>{o[0]()}),He.set(!0),()=>{t.forEach(o=>{o[1](),Ye(o[2])}),He.set(!1)}}),Xa=Ua("expand",()=>{p("web_app_expand")}),xa=x("isExpanded"),ei=d(()=>Lt()===Vt()),Zc=Object.freeze(Object.defineProperty({__proto__:null,bindCssVars:Ka,changeFullscreenError:Kn,changeFullscreenPromise:It,contentSafeAreaInsetBottom:oo,contentSafeAreaInsetLeft:ro,contentSafeAreaInsetRight:so,contentSafeAreaInsetTop:ao,contentSafeAreaInsets:kt,exitFullscreen:qa,expand:Xa,height:Lt,isChangingFullscreen:ka,isCssVarsBound:He,isExpanded:xa,isFullscreen:Zn,isMounted:ye,isMounting:La,isStable:ei,mount:Ja,mountError:Xn,mountPromise:Ue,requestFullscreen:ja,safeAreaInsetBottom:xn,safeAreaInsetLeft:eo,safeAreaInsetRight:to,safeAreaInsetTop:no,safeAreaInsets:Mt,stableHeight:Vt,state:we,unmount:Za,width:io},Symbol.toStringTag,{value:"Module"})),ti="web_app_request_emoji_status_access",co=u(),ni=u(),Kc=d(()=>!!co()),Xc=R("requestEmojiStatusAccess",rt(()=>y(ti,"emoji_status_access_requested").then(e=>e.status),()=>new _(G,"Emoji status access request is currently in progress"),co,ni,!1),{isSupported:ti}),oi="web_app_set_emoji_status",uo=u(),ri=u(),xc=d(()=>!!uo()),eu=R("setEmojiStatus",rt(async(e,t)=>{const o=await y(oi,["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:e,duration:t}});if(o&&"error"in o)throw new _(lr,"Failed to set emoji status",o.error)},()=>new _(G,"Emoji status set request is currently in progress"),uo,ri,!1),{isSupported:oi}),tu=U()("openLink",(e,t)=>{if(typeof e=="string")try{e=new URL(e)}catch(o){throw new _(Xe,`"${e.toString()}" is invalid URL`,o)}t||(t={}),p("web_app_open_link",{url:e.toString(),try_browser:t.tryBrowser,try_instant_view:t.tryInstantView})}),si="web_app_open_tg_link",ai=U()("openTelegramLink",e=>{const t=e.toString();if(!t.match(/^https:\/\/t.me\/.+/))throw new _(Xe,`"${t}" is invalid URL`);if(!W(si,k())){window.location.href=t;return}e=new URL(e),p(si,{path_full:e.pathname+e.search})}),nu=U()("shareURL",(e,t)=>{ai("https://t.me/share/url?"+new URLSearchParams({url:e,text:t||""}).toString().replace(/\+/g,"%20"))}),lo="web_app_request_phone",jt=u(!1),ii=R("requestPhoneAccess",e=>{if(jt())throw new _(G,"Phone access request is currently in progress");return jt.set(!0),y(lo,"phone_requested",e).then(t=>t.status).finally(()=>{jt.set(!1)})},{isSupported:lo});function ci(e){return e||(e={}),se("getRequestedContact",{},{...e,timeout:e.timeout||5e3}).then(bo({contact:Fe({userId:["user_id",We()],phoneNumber:["phone_number",q()],firstName:["first_name",q()],lastName:["last_name",q(!0)]})(),authDate:["auth_date",Wt()],hash:q()})())}const ou=R("requestContact",e=>b.withFn(async t=>{const o={abortSignal:t};try{return await ci(o)}catch{}if(await ii(o)!=="sent")throw new _(or,"User denied access");let s=50;for(;!t.aborted;){try{return await ci(o)}catch{}await Wi(s),s+=50}return null},e),{isSupported:lo}),ui="web_app_request_write_access",qt=u(!1),ru=R("requestWriteAccess",e=>{if(qt())throw new _(G,"Write access request is currently in progress");return qt.set(!0),y(ui,"write_access_requested",e).then(t=>t.status).finally(()=>{qt.set(!1)})},{isSupported:ui}),su=R("getCurrentTime",e=>se("getCurrentTime",{},e).then(Wt()),{isSupported:"web_app_invoke_custom_method"}),li="web_app_read_text_from_clipboard",au=R("readTextFromClipboard",e=>{const t=er();return y(li,"clipboard_text_received",{...e,params:{req_id:t},capture:Yo(t)}).then(({data:o=null})=>o)},{isSupported:li}),iu=R("sendData",e=>{const{size:t}=new Blob([e]);if(!t||t>4096)throw new _(nr,t?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data");p("web_app_data_send",{data:e})}),_i="web_app_share_to_story",cu=R("shareStory",(e,t)=>{t||(t={}),p(_i,{text:t.text,media_url:e,widget_link:t.widgetLink})},{isSupported:_i}),fi="web_app_switch_inline_query",uu=R("switchInlineQuery",(e,t)=>{p(fi,{query:e,chat_types:t||[]})},{isSupported:[fi,{fn:()=>!!J().botInline,error:"Mini App should be ran in Bot inline mode"}]});function lu(e){try{return{result:e()}}catch(t){return{error:t}}}function _u(e){cc(e),zo();const[t,o]=ne(g("reload_iframe",()=>{p("iframe_will_reload"),window.location.reload()}),Qo),{acceptCustomStyles:r=!0}=e||{};if(r){const s=document.createElement("style");s.id="telegram-custom-styles",document.head.appendChild(s),t(g("set_custom_style",a=>{s.innerHTML=a}),()=>{document.head.removeChild(s)})}return p("iframe_ready",{reload_supported:!0}),o}return n.$createRequestId=xo,n.$debug=Mo,n.$postEvent=fn,n.$targetOrigin=Ho,n.$version=k,n.CancelablePromise=b,n.ERR_ABORTED=xt,n.ERR_ACCESS_DENIED=or,n.ERR_ALREADY_MOUNTING=rr,n.ERR_ALREADY_OPENED=xe,n.ERR_ALREADY_REQUESTING=G,n.ERR_CANCELED=en,n.ERR_CSS_VARS_ALREADY_BOUND=sr,n.ERR_CUSTOM_METHOD_ERR_RESPONSE=Uo,n.ERR_DATA_INVALID_SIZE=nr,n.ERR_EMOJI_STATUS_SET_FAILED=lr,n.ERR_FULLSCREEN_FAILED=ur,n.ERR_INVALID_SLUG=tr,n.ERR_INVALID_URL=Xe,n.ERR_INVALID_VALUE=fo,n.ERR_METHOD_PARAMETER_UNSUPPORTED=qo,n.ERR_METHOD_UNSUPPORTED=Vo,n.ERR_NOT_AVAILABLE=ar,n.ERR_NOT_INITIALIZED=ir,n.ERR_NOT_MOUNTED=cr,n.ERR_NOT_SUPPORTED=dn,n.ERR_PARSE=Ht,n.ERR_POPUP_INVALID_PARAMS=ae,n.ERR_RETRIEVE_LP_FAILED=jo,n.ERR_TIMED_OUT=tn,n.ERR_UNEXPECTED_TYPE=mo,n.ERR_UNEXPECTED_VALUE=po,n.ERR_UNKNOWN_ENV=cn,n.TypedError=_,n.addEventListener=Kt,n.authenticateBiometry=vr,n.backButton=uc,n.bindMiniAppCssVars=Hs,n.bindThemeParamsCssVars=Ms,n.bindViewportCssVars=Ka,n.biometry=hc,n.biometryMountError=bn,n.biometryState=Te,n.changeFullscreenError=Kn,n.changeFullscreenPromise=It,n.classNames=Ge,n.closeMiniApp=Fs,n.closeQrScanner=yt,n.closingBehavior=Ec,n.cloudStorage=wc,n.compareVersions=Zo,n.createPostEvent=Ko,n.defineEventHandlers=zo,n.deleteCloudStorageItem=qr,n.deleteCssVar=Ye,n.disableClosingConfirmation=Mr,n.disableVerticalSwipes=Ra,n.emitMiniAppsEvent=Ke,n.enableClosingConfirmation=Nr,n.enableVerticalSwipes=va,n.exitFullscreen=qa,n.expandViewport=Xa,n.getCloudStorageItem=Ur,n.getCloudStorageKeys=Hr,n.getCurrentTime=su,n.hapticFeedback=Sc,n.hapticFeedbackImpactOccurred=Gr,n.hapticFeedbackNotificationOccurred=zr,n.hapticFeedbackSelectionChanged=Qr,n.hideBackButton=pr,n.hideSettingsButton=ba,n.init=_u,n.initData=yc,n.initDataAuthDate=Cn,n.initDataCanSendAfter=Rn,n.initDataCanSendAfterDate=Yr,n.initDataChat=Jr,n.initDataChatInstance=Kr,n.initDataChatType=Zr,n.initDataHash=Xr,n.initDataQueryId=xr,n.initDataRaw=vn,n.initDataReceiver=es,n.initDataStartParam=ns,n.initDataState=_t,n.initDataUser=os,n.invoice=Rc,n.invokeCustomMethod=Xo,n.isAbortError=Ui,n.isAuthenticatingBiometry=$e,n.isBackButtonMounted=ie,n.isBackButtonSupported=fr,n.isBackButtonVisible=ot,n.isBiometryMounted=Oe,n.isBiometryMounting=Sr,n.isBiometrySupported=Cr,n.isCanceledError=Hi,n.isChangingFullscreen=ka,n.isClosingBehaviorMounted=ue,n.isClosingConfirmationEnabled=ut,n.isCloudStorageSupported=jr,n.isColorDark=$n,n.isFullscreen=Zn,n.isHapticFeedbackSupported=Wr,n.isIframe=$o,n.isInvoiceOpened=Ie,n.isInvoiceSupported=rs,n.isMainButtonEnabled=Ss,n.isMainButtonLoaderVisible=ys,n.isMainButtonMounted=_e,n.isMainButtonVisible=As,n.isMiniAppActive=Le,n.isMiniAppCssVarsBound=ke,n.isMiniAppDark=Vs,n.isMiniAppMounted=me,n.isMiniAppSupported=qs,n.isPopupOpened=je,n.isPopupSupported=Ys,n.isQrScannerOpened=X,n.isQrScannerSupported=Ks,n.isRGB=te,n.isRGBShort=Eo,n.isRecord=Yt,n.isRequestingBiometryAccess=Pe,n.isRequestingEmojiStatusAccess=Kc,n.isRequestingPhoneAccess=jt,n.isRequestingWriteAccess=qt,n.isSSR=pn,n.isSecondaryButtonEnabled=ta,n.isSecondaryButtonLoaderVisible=na,n.isSecondaryButtonMounted=he,n.isSecondaryButtonSupported=ca,n.isSecondaryButtonVisible=oa,n.isSettingEmojiStatus=xc,n.isSettingsButtonMounted=be,n.isSettingsButtonSupported=ma,n.isSettingsButtonVisible=$t,n.isSwipeBehaviorMounted=Ee,n.isSwipeBehaviorSupported=Aa,n.isTMA=ln,n.isThemeParamsCssVarsBound=De,n.isThemeParamsDark=fs,n.isThemeParamsMounted=le,n.isTimeoutError=qi,n.isVerticalSwipesEnabled=Bt,n.isViewportCssVarsBound=He,n.isViewportExpanded=xa,n.isViewportMounted=ye,n.isViewportMounting=La,n.isViewportStable=ei,n.mainButton=$c,n.mainButtonBackgroundColor=gs,n.mainButtonHasShineEffect=ws,n.mainButtonState=pt,n.mainButtonText=Cs,n.mainButtonTextColor=Rs,n.mergeClassNames=yi,n.miniApp=Bc,n.miniAppBackgroundColor=fe,n.miniAppBackgroundColorRGB=bt,n.miniAppBottomBarColor=de,n.miniAppBottomBarColorRGB=Et,n.miniAppHeaderColor=pe,n.miniAppHeaderColorRGB=Mn,n.miniAppReady=zs,n.miniAppState=Nn,n.mockTelegramEnv=nc,n.mountBackButton=mr,n.mountBiometry=Pr,n.mountClosingBehavior=kr,n.mountMainButton=Ts,n.mountMiniApp=Gs,n.mountSecondaryButton=ua,n.mountSettingsButton=Ea,n.mountSwipeBehavior=Ta,n.mountThemeParams=Dn,n.mountViewport=Ja,n.off=v,n.offBackButtonClick=br,n.offMainButtonClick=Ps,n.offSecondaryButtonClick=_a,n.offSettingsButtonClick=wa,n.on=g,n.onBackButtonClick=hr,n.onMainButtonClick=$s,n.onSecondaryButtonClick=la,n.onSettingsButtonClick=ga,n.openBiometrySettings=Tr,n.openInvoice=as,n.openLink=tu,n.openPopup=Js,n.openQrScanner=Xs,n.openTelegramLink=ai,n.parseInitData=Ac,n.parseThemeParams=Is,n.popup=Mc,n.postEvent=Je,n.qrScanner=jc,n.readTextFromClipboard=au,n.removeEventHandlers=Qo,n.request=Ze,n.requestBiometry=Ar,n.requestBiometryAccess=$r,n.requestContact=ou,n.requestContentSafeAreaInsets=Ha,n.requestEmojiStatusAccess=Xc,n.requestEmojiStatusAccessError=ni,n.requestEmojiStatusAccessPromise=co,n.requestFullscreen=ja,n.requestPhoneAccess=ii,n.requestSafeAreaInsets=Fa,n.requestViewport=Wa,n.requestWriteAccess=ru,n.restoreInitData=ts,n.retrieveLaunchParams=J,n.safeCall=lu,n.secondaryButton=Uc,n.secondaryButtonBackgroundColor=xs,n.secondaryButtonHasShineEffect=ea,n.secondaryButtonPosition=ra,n.secondaryButtonState=At,n.secondaryButtonText=sa,n.secondaryButtonTextColor=aa,n.sendData=iu,n.serializeLaunchParams=wi,n.serializeThemeParams=Qt,n.setCloudStorageItem=Fr,n.setCssVar=Qe,n.setEmojiStatus=eu,n.setEmojiStatusError=ri,n.setEmojiStatusPromise=uo,n.setMainButtonParams=Os,n.setMiniAppBackgroundColor=jn,n.setMiniAppBottomBarColor=qn,n.setMiniAppHeaderColor=Un,n.setSecondaryButtonParams=fa,n.settingsButton=Hc,n.shareStory=cu,n.shareURL=nu,n.showBackButton=Er,n.showSettingsButton=Sa,n.subscribe=oc,n.supports=W,n.swipeBehavior=Wc,n.switchInlineQuery=uu,n.themeParams=Gc,n.themeParamsAccentTextColor=cs,n.themeParamsBackgroundColor=ft,n.themeParamsBottomBarBgColor=On,n.themeParamsButtonColor=dt,n.themeParamsButtonTextColor=Pn,n.themeParamsDestructiveTextColor=us,n.themeParamsHeaderBackgroundColor=ls,n.themeParamsHintColor=_s,n.themeParamsLinkColor=ds,n.themeParamsSecondaryBackgroundColor=Me,n.themeParamsSectionBackgroundColor=ps,n.themeParamsSectionHeaderTextColor=ms,n.themeParamsSectionSeparatorColor=hs,n.themeParamsState=H,n.themeParamsSubtitleTextColor=bs,n.themeParamsTextColor=Es,n.toRGB=zt,n.toRecord=Ft,n.unmountBackButton=gr,n.unmountBiometry=Br,n.unmountClosingBehavior=Lr,n.unmountMainButton=Bs,n.unmountMiniApp=Qs,n.unmountSecondaryButton=da,n.unmountSettingsButton=ya,n.unmountSwipeBehavior=$a,n.unmountThemeParams=ks,n.unmountViewport=Za,n.unsubscribe=rc,n.updateBiometryToken=Ir,n.viewport=Zc,n.viewportContentSafeAreaInsetBottom=oo,n.viewportContentSafeAreaInsetLeft=ro,n.viewportContentSafeAreaInsetRight=so,n.viewportContentSafeAreaInsetTop=ao,n.viewportContentSafeAreaInsets=kt,n.viewportHeight=Lt,n.viewportMountError=Xn,n.viewportMountPromise=Ue,n.viewportSafeAreaInsetBottom=xn,n.viewportSafeAreaInsetLeft=eo,n.viewportSafeAreaInsetRight=to,n.viewportSafeAreaInsetTop=no,n.viewportSafeAreaInsets=Mt,n.viewportStableHeight=Vt,n.viewportState=we,n.viewportWidth=io,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),n}({});
//# sourceMappingURL=index.iife.js.map
{
"name": "@telegram-apps/sdk",
"version": "2.9.1",
"version": "2.10.0",
"description": "TypeScript Source Development Kit for Telegram Mini Apps client application.",

@@ -42,4 +42,4 @@ "author": "Vladislav Kibenko <wolfram.deus@gmail.com>",

"@telegram-apps/toolkit": "^1.0.0",
"@telegram-apps/bridge": "^1.7.1",
"@telegram-apps/navigation": "^1.0.9",
"@telegram-apps/bridge": "^1.8.0",
"@telegram-apps/navigation": "^1.0.10",
"@telegram-apps/signals": "^1.1.0"

@@ -46,0 +46,0 @@ },

@@ -14,2 +14,3 @@ export {

backgroundColor as miniAppBackgroundColor,
backgroundColorRGB as miniAppBackgroundColorRGB,
bottomBarColor as miniAppBottomBarColor,

@@ -22,2 +23,3 @@ bottomBarColorRGB as miniAppBottomBarColorRGB,

isDark as isMiniAppDark,
isActive as isMiniAppActive,
state as miniAppState,

@@ -24,0 +26,0 @@ } from './signals.js';

@@ -9,5 +9,9 @@ import {

supports,
on,
off,
type EventListener,
type RGB,
type BottomBarColor,
type BackgroundColor, MethodName,
type BackgroundColor,
type MethodName,
} from '@telegram-apps/bridge';

@@ -35,2 +39,3 @@ import { isRGB } from '@telegram-apps/transformers';

backgroundColorRGB,
isActive,
} from './signals.js';

@@ -44,2 +49,3 @@ import type { GetCssVarNameFn, HeaderColor, State } from './types.js';

const SET_HEADER_COLOR_METHOD = 'web_app_set_header_color';
const VISIBILITY_CHANGED_EVENT = 'visibility_changed';
const COMPONENT_NAME = 'miniApp';

@@ -144,2 +150,7 @@

const onVisibilityChanged: EventListener<'visibility_changed'> = (data) => {
isActive.set(data.is_visible);
saveState();
};
/**

@@ -172,3 +183,6 @@ * Mounts the component.

setHeaderColor.ifAvailable(s ? s.headerColor : 'bg_color');
isActive.set(s ? s.isActive : true);
on(VISIBILITY_CHANGED_EVENT, onVisibilityChanged);
isMounted.set(true);

@@ -288,3 +302,4 @@ }

export function unmount(): void {
off(VISIBILITY_CHANGED_EVENT, onVisibilityChanged);
isMounted.set(false);
}

@@ -95,2 +95,7 @@ import { Computed, computed, signal } from '@telegram-apps/signals';

/**
* Signal indicating if the mini app is currently active.
*/
export const isActive = signal(true);
/**
* Complete component state.

@@ -102,2 +107,3 @@ */

headerColor: headerColor(),
isActive: isActive(),
}));

@@ -12,2 +12,3 @@ import type { HeaderColorKey, BottomBarColor, RGB, BackgroundColor } from '@telegram-apps/bridge';

headerColor: HeaderColor;
isActive: boolean;
}

@@ -14,0 +15,0 @@

@@ -12,3 +12,3 @@ import { isPageReload } from '@telegram-apps/navigation';

SA_CHANGED_EVENT,
VIEWPORT_CHANGED_EVENT
VIEWPORT_CHANGED_EVENT,
} from '../../const.js';

@@ -24,3 +24,8 @@ import { isMounted, mountPromise, mountError } from '../../signals/mounting.js';

import { onContentSafeAreaChanged, onFullscreenChanged, onSafeAreaChanged, onViewportChanged } from './shared.js';
import {
onContentSafeAreaChanged,
onFullscreenChanged,
onSafeAreaChanged,
onViewportChanged,
} from './shared.js';

@@ -27,0 +32,0 @@ /**

import { off } from '@telegram-apps/bridge';
import { CSA_CHANGED_EVENT, FS_CHANGED_EVENT, SA_CHANGED_EVENT, VIEWPORT_CHANGED_EVENT } from '../../const.js';
import {
CSA_CHANGED_EVENT,
FS_CHANGED_EVENT,
SA_CHANGED_EVENT,
VIEWPORT_CHANGED_EVENT,
} from '../../const.js';
import { isMounted, mountPromise } from '../../signals/mounting.js';
import { onContentSafeAreaChanged, onFullscreenChanged, onSafeAreaChanged, onViewportChanged } from './shared.js';
import {
onContentSafeAreaChanged,
onFullscreenChanged,
onSafeAreaChanged,
onViewportChanged,
} from './shared.js';

@@ -8,0 +18,0 @@ /**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet