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