@tma.js/sdk 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dts/index.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.iife.js +3 -3
- package/dist/index.js +38 -37
- package/package.json +2 -2
package/dist/dts/index.d.ts
CHANGED
|
@@ -28,6 +28,6 @@ export { isColorDark, isColorDarkFp } from './helpers/isColorDark.js';
|
|
|
28
28
|
export * from './errors.js';
|
|
29
29
|
export { init, initFp, type InitOptions } from './init.js';
|
|
30
30
|
export type { AsyncOptions } from './types.js';
|
|
31
|
-
export { isTMA, isTMAFp, type isTMAError, mockTelegramEnv, off, offAll, on, type EventListener, type SubscribeListener, type Events, type WriteAccessRequestedStatus, type EmojiStatusAccessRequestedStatus, type BiometryAuthRequestStatus, type BiometryTokenUpdateStatus, type BiometryType, type EmojiStatusFailedError, type EventName, type EventPayload, type EventWithoutPayload, type EventWithPayload, type PhoneRequestedStatus, type FullScreenErrorStatus, type HomeScreenStatus, type InvoiceStatus, type SafeAreaInsets, createPostEvent, type CreatePostEventMode, type OnUnsupportedFn, getReleaseVersion, type PostEventFn, type PostEventFpFn, type PostEventError, supports, type AnyHapticFeedbackParams, type AnyInvokeCustomMethodParams, type CreateMethodParams, type CustomMethodName, type ImpactHapticFeedbackParams, type ImpactHapticFeedbackStyle, type CustomMethodsParams, type CustomMethodParams, type MethodName, type MethodVersionedParams, type NotificationHapticFeedbackParams, type NotificationHapticFeedbackType, type Methods, type SelectionHapticFeedbackParams, type MethodNameWithOptionalParams, type MethodNameWithoutParams, type MethodNameWithRequiredParams, type MethodNameWithVersionedParams, type MethodParams, type PopupParams, type BackgroundColor, type BottomBarColor, type HeaderColorKey, type PopupButton, type OpenLinkBrowser, type SecondaryButtonPosition, type SwitchInlineQueryChatType, type InvokeCustomMethodFn, type InvokeCustomMethodOptions, type InvokeCustomMethodFpFn, type InvokeCustomMethodError, type InvokeCustomMethodFpOptions, type RequestCaptureEventFn, type RequestCaptureEventsFn, type RequestCaptureFn, type RequestCaptureFnEventsPayload, type RequestFn, type RequestOptions, type RequestResult, type RequestError, type RequestFpOptions, type RequestFpFn, applyPolyfills, decodeBase64Url, encodeBase64Url, decodeBase64UrlFp, type DecodeBase64UrlError, LaunchParamsRetrieveError, InvalidLaunchParamsError, InvokeCustomMethodFailedError, MethodParameterUnsupportedError, MethodUnsupportedError, UnknownEnvError, setDebug, debug, logger, setTargetOrigin, targetOrigin, retrieveLaunchParams, retrieveRawInitData, retrieveRawInitDataFp, retrieveRawLaunchParams, retrieveRawLaunchParamsFp, retrieveLaunchParamsFp, type RetrieveLaunchParamsError, type RetrieveLaunchParamsResult, type RetrieveRawInitDataError, type RetrieveRawLaunchParamsError, createStartParam, createStartParamFp, decodeStartParam, decodeStartParamFp, isSafeToCreateStartParam, createLogger, deepSnakeToCamelObjKeys, type DeepConvertSnakeKeysToCamelCase, type Logger, type LoggerFn, type LoggerForceFn, type LoggerOptions, type LogLevel, CancelledError, TimeoutError, } from '@tma.js/bridge';
|
|
31
|
+
export { isTMA, isTMAFp, type isTMAError, mockTelegramEnv, emitEvent, off, offAll, on, type EventListener, type SubscribeListener, type Events, type WriteAccessRequestedStatus, type EmojiStatusAccessRequestedStatus, type BiometryAuthRequestStatus, type BiometryTokenUpdateStatus, type BiometryType, type EmojiStatusFailedError, type EventName, type EventPayload, type EventWithoutPayload, type EventWithPayload, type PhoneRequestedStatus, type FullScreenErrorStatus, type HomeScreenStatus, type InvoiceStatus, type SafeAreaInsets, createPostEvent, type CreatePostEventMode, type OnUnsupportedFn, getReleaseVersion, type PostEventFn, type PostEventFpFn, type PostEventError, supports, type AnyHapticFeedbackParams, type AnyInvokeCustomMethodParams, type CreateMethodParams, type CustomMethodName, type ImpactHapticFeedbackParams, type ImpactHapticFeedbackStyle, type CustomMethodsParams, type CustomMethodParams, type MethodName, type MethodVersionedParams, type NotificationHapticFeedbackParams, type NotificationHapticFeedbackType, type Methods, type SelectionHapticFeedbackParams, type MethodNameWithOptionalParams, type MethodNameWithoutParams, type MethodNameWithRequiredParams, type MethodNameWithVersionedParams, type MethodParams, type PopupParams, type BackgroundColor, type BottomBarColor, type HeaderColorKey, type PopupButton, type OpenLinkBrowser, type SecondaryButtonPosition, type SwitchInlineQueryChatType, type InvokeCustomMethodFn, type InvokeCustomMethodOptions, type InvokeCustomMethodFpFn, type InvokeCustomMethodError, type InvokeCustomMethodFpOptions, type RequestCaptureEventFn, type RequestCaptureEventsFn, type RequestCaptureFn, type RequestCaptureFnEventsPayload, type RequestFn, type RequestOptions, type RequestResult, type RequestError, type RequestFpOptions, type RequestFpFn, applyPolyfills, decodeBase64Url, encodeBase64Url, decodeBase64UrlFp, type DecodeBase64UrlError, LaunchParamsRetrieveError, InvalidLaunchParamsError, InvokeCustomMethodFailedError, MethodParameterUnsupportedError, MethodUnsupportedError, UnknownEnvError, setDebug, debug, logger, setTargetOrigin, targetOrigin, retrieveLaunchParams, retrieveRawInitData, retrieveRawInitDataFp, retrieveRawLaunchParams, retrieveRawLaunchParamsFp, retrieveLaunchParamsFp, type RetrieveLaunchParamsError, type RetrieveLaunchParamsResult, type RetrieveRawInitDataError, type RetrieveRawLaunchParamsError, createStartParam, createStartParamFp, decodeStartParam, decodeStartParamFp, isSafeToCreateStartParam, createLogger, deepSnakeToCamelObjKeys, type DeepConvertSnakeKeysToCamelCase, type Logger, type LoggerFn, type LoggerForceFn, type LoggerOptions, type LogLevel, CancelledError, TimeoutError, } from '@tma.js/bridge';
|
|
32
32
|
export { parseInitDataQuery, parseInitDataQueryFp, type ParseInitDataQueryError, parseLaunchParamsQuery, parseLaunchParamsQueryFp, type ParseLaunchParamsQueryError, isRGBShort, isRGBAShort, isRGB, isRGBA, isAnyRGB, toRGBFullFp, toRGBFp, toRGB, toRGBFull, serializeInitDataQuery, type InitDataLike, serializeLaunchParamsQuery, type LaunchParamsLike, } from '@tma.js/transformers';
|
|
33
33
|
export type { RGB, User, Chat, InitData, ChatType, Platform, ThemeParams, LaunchParams, KnownThemeParamsKey, Version, } from '@tma.js/types';
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var cr=Object.defineProperty;var pr=(r,t,s)=>t in r?cr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s;var e=(r,t,s)=>pr(r,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("@tma.js/signals"),h=require("@tma.js/bridge"),O=require("@tma.js/toolkit"),lr=require("better-promises"),q=require("@tma.js/transformers"),K=require("error-kid"),k=require("valibot");var hr=function(r,t,s){if(s||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return r.concat(o||Array.prototype.slice.call(t))};function ot(r,t,s,n,i,o,u,a,l){switch(arguments.length){case 1:return r;case 2:return function(){return t(r.apply(this,arguments))};case 3:return function(){return s(t(r.apply(this,arguments)))};case 4:return function(){return n(s(t(r.apply(this,arguments))))};case 5:return function(){return i(n(s(t(r.apply(this,arguments)))))};case 6:return function(){return o(i(n(s(t(r.apply(this,arguments))))))};case 7:return function(){return u(o(i(n(s(t(r.apply(this,arguments)))))))};case 8:return function(){return a(u(o(i(n(s(t(r.apply(this,arguments))))))))};case 9:return function(){return l(a(u(o(i(n(s(t(r.apply(this,arguments)))))))))}}}function c(r,t,s,n,i,o,u,a,l){switch(arguments.length){case 1:return r;case 2:return t(r);case 3:return s(t(r));case 4:return n(s(t(r)));case 5:return i(n(s(t(r))));case 6:return o(i(n(s(t(r)))));case 7:return u(o(i(n(s(t(r))))));case 8:return a(u(o(i(n(s(t(r)))))));case 9:return l(a(u(o(i(n(s(t(r))))))));default:{for(var p=arguments[0],b=1;b<arguments.length;b++)p=arguments[b](p);return p}}}var he=function(r,t){var s=typeof r=="number"?function(n){return n.length>=r}:r;return function(){var n=Array.from(arguments);return s(arguments)?t.apply(this,n):function(i){return t.apply(void 0,hr([i],n,!1))}}},dr={_tag:"None"},fr=function(r){return{_tag:"Some",value:r}},mr=function(r){return r._tag==="Left"},it=function(r){return{_tag:"Left",left:r}},at=function(r){return{_tag:"Right",right:r}},qe={};function br(r,t){return function(s){return function(n){return r.ap(r.map(n,function(i){return function(o){return t.ap(i,o)}}),s)}}}function _r(r,t){return function(s){return function(n){return r.map(n,function(i){return t.map(i,s)})}}}function xe(r){return function(t,s){return function(n){return r.chain(n,function(i){return r.map(s(i),function(o){var u;return Object.assign({},i,(u={},u[t]=o,u))})})}}}var L=it,I=at,gr=he(2,function(r,t){return ne(r)?r:t(r.right)}),Me=function(r,t){return c(r,H(t))},ut=function(r,t){return c(r,Sr(t))},Te="Either",H=function(r){return function(t){return ne(t)?t:I(r(t.right))}},Fr={URI:Te,map:Me},Cr=I,wr=function(r){return function(t){return ne(t)?t:ne(r)?r:I(t.right(r.right))}},Sr=wr,vr={URI:Te,map:Me,ap:ut},yr={URI:Te,map:Me,ap:ut,chain:gr},kr=function(r,t){return function(s){return ne(s)?L(r(s.left)):I(t(s.right))}},ne=mr,ct=function(r,t){return function(s){return ne(s)?r(s.left):t(s.right)}},de=ct,Er=function(r,t){try{return I(r())}catch(s){return L(t(s))}},Ar=Cr(qe),Br=xe(yr),rt=Br;function D(r){return typeof r=="function"?r():r}function Y(r,t){return _.computed(()=>h.supports(r,D(t)))}var ie=dr,fe=fr,Pr=function(r,t){return c(r,xr(t))},Ir=function(r,t){return c(r,Tr(t))},qr="Option",xr=function(r){return function(t){return pe(t)?ie:fe(r(t.value))}},Mr=fe,Tr=function(r){return function(t){return pe(t)||pe(r)?ie:fe(t.value(r.value))}},Lr=he(2,function(r,t){return pe(r)?ie:t(r.value)}),Or={URI:qr,map:Pr,ap:Ir,chain:Lr},pe=function(r){return r._tag==="None"},Vr=function(r,t){return function(s){return pe(s)?r():t(s.value)}},pt=Vr,Rr=Mr(qe),st=xe(Or);function $r(r){return ot(I,r.of)}function jr(r){return ot(L,r.of)}function Dr(r){return _r(r,Fr)}function Ur(r){return br(r,vr)}function Gr(r){return function(t,s){return r.chain(t,function(n){return ne(n)?r.of(n):s(n.right)})}}function Hr(r){return function(t,s,n){return r.map(t,kr(s,n))}}function Qr(r){return function(t,s){return function(n){return r.map(n,de(t,s))}}}var Le=function(r,t){return c(r,Wr(t))},lt=function(r,t){return c(r,Kr(t))},Wr=function(r){return function(t){return function(){return Promise.resolve().then(t).then(r)}}},Kr=function(r){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(r)]).then(function(s){var n=s[0],i=s[1];return n(i)})}}},Oe=function(r){return function(){return Promise.resolve(r)}},zr=he(2,function(r,t){return function(){return Promise.resolve().then(r).then(function(s){return t(s)()})}}),Ve="Task",Re={URI:Ve,map:Le},ht={of:Oe},Nr={URI:Ve,map:Le,ap:lt},Jr={URI:Ve,map:Le,of:Oe,ap:lt,chain:zr},Yr=function(r,t,s,n){function i(o){return o instanceof s?o:new s(function(u){u(o)})}return new(s||(s=Promise))(function(o,u){function a(b){try{p(n.next(b))}catch(m){u(m)}}function l(b){try{p(n.throw(b))}catch(m){u(m)}}function p(b){b.done?o(b.value):i(b.value).then(a,l)}p((n=n.apply(r,t||[])).next())})},Zr=function(r,t){var s={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,u;return u={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(p){return function(b){return l([p,b])}}function l(p){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,p[0]&&(s=0)),s;)try{if(n=1,i&&(o=p[0]&2?i.return:p[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,p[1])).done)return o;switch(i=0,o&&(p=[p[0]&2,o.value]),p[0]){case 0:case 1:o=p;break;case 4:return s.label++,{value:p[1],done:!1};case 5:s.label++,i=p[1],p=[0];continue;case 7:p=s.ops.pop(),s.trys.pop();continue;default:if(o=s.trys,!(o=o.length>0&&o[o.length-1])&&(p[0]===6||p[0]===2)){s=0;continue}if(p[0]===3&&(!o||p[1]>o[0]&&p[1]<o[3])){s.label=p[1];break}if(p[0]===6&&s.label<o[1]){s.label=o[1],o=p;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(p);break}o[2]&&s.ops.pop(),s.trys.pop();continue}p=t.call(r,s)}catch(b){p=[6,b],i=0}finally{n=o=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},R=jr(ht),M=$r(ht),dt=Oe,Xr=Qr(Re),es=function(r,t){return function(){return Yr(void 0,void 0,void 0,function(){var s;return Zr(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,r().then(at)];case 1:return[2,n.sent()];case 2:return s=n.sent(),[2,it(t(s))];case 3:return[2]}})})}},ts=function(r,t){return c(r,x(t))},rs=function(r,t){return c(r,ss(t))},x=Dr(Re),$e=he(3,Hr(Re)),ss=Ur(Nr),je=he(2,Gr(Jr)),ns=M,os="TaskEither",is={URI:os,map:ts,ap:rs,chain:je},as=ns(qe),us=xe(is),Ce=us,X=je,ae=je;function oe(r){return[r]}class ce extends K.errorClassWithData("ValidationError",(t,s)=>({input:t,issues:s}),"Validation error"){}class we extends K.errorClass("CSSVarsBoundError","CSS variables are already bound"){}class ft extends K.errorClass("NotAvailableError",oe){}class cs extends K.errorClass("InvalidEnvError",oe){}class mt extends K.errorClass("FunctionNotAvailableError",oe){}class J extends K.errorClass("InvalidArgumentsError",(t,s)=>[t,{cause:s}]){}class Se extends K.errorClass("ConcurrentCallError",oe){}class bt extends K.errorClass("SetEmojiStatusError",t=>[`Failed to set emoji status: ${t}`]){}class De extends K.errorClass("AccessDeniedError",oe){}class _t extends K.errorClass("FullscreenFailedError",oe){}class gt extends K.errorClass("ShareMessageError",oe){}class Ft extends K.errorClass("UnknownThemeParamsKeyError",t=>[`Unknown theme params key passed: ${t}`]){}function P(r,t){const s=_.computed(()=>D(t.version)||"100"),n=_.computed(()=>D(t.isTma)),{requires:i}=t,o=i?typeof i=="object"?i:{every:[i]}:void 0,u=w=>{if(!t.supports)return!0;const F=t.supports[w];return h.supports(F.method,F.param,s())},a=()=>{if(!o)return;const[w,F]="every"in o?["every",o.every]:["some",o.some];for(let g=0;g<F.length;g++){const v=F[g],d=typeof v=="function"?v():h.supports(v,s())?void 0:`it is unsupported in Mini Apps version ${s()}`;if(d&&(w==="every"||g===F.length-1))return d}},l=(...w)=>{for(const F in t.supports)if(t.supports[F].shouldCheck(...w)&&!u(F))return`option ${F} is not supported in Mini Apps version ${s()}`},p=_.computed(()=>!a()),b=_.computed(()=>s()!=="0.0"),m=_.computed(()=>t.isMounted?t.isMounted():!0),C=_.computed(()=>n()&&b()&&p()&&m()),S=w=>{const F=new mt(w);return["task","promise"].includes(t.returns)?R(F):L(F)};return Object.assign((...w)=>{var V;const F="Unable to call function:";if(!n())return S(`${F} it can't be called outside Mini Apps`);if(!b())return S(`${F} the SDK was not initialized. Use the SDK init() function`);const g=a();if(g)return S(`${F} ${g}`);const v=l(...w);if(v)return S(`${F} ${v}`);if(!m()){const j=(V=t.isMounting)!=null&&V.call(t)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return S(`${F} the component is ${j}`)}const{returns:d}=t;return d==="plain"?Er(()=>r(...w),j=>j):d==="promise"?es(()=>r(...w),j=>j):r(...w)},r,{isAvailable:C,ifAvailable(...w){return C()?fe(r(...w)):ie}},o?{isSupported:p}:{},t.supports?{supports:u}:{})}function B(r){return t=>P(t,r)}function f(r){return Object.assign(O.throwifyFpFn(r),{ifAvailable(...t){return c(r.ifAvailable(...t),pt(()=>({ok:!1}),s=>({ok:!0,data:O.throwifyAnyEither(s)})))}})}function Ae(r){const t={};for(const s in r){const n=r[s];n!==void 0&&(t[s]=n)}return t}function ye(r,t){const s=Object.keys(r),n=Object.keys(t);return s.length!==n.length?!1:s.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&r[i]===t[i])}class te{constructor({initialState:t,onChange:s}){e(this,"_state");e(this,"state");e(this,"setState",t=>{const s={...this.state(),...Ae(t)};ye(s,this.state())||this._state.set(s)});this._state=_.signal(t,{equals:ye}),this.state=_.computed(this._state),this.state.sub(s)}getter(t){return _.computed(()=>this._state()[t])}hasDiff(t){return!ye({...this.state(),...Ae(t)},this.state())}}class me{constructor({onMounted:t,restoreState:s,initialState:n,onUnmounted:i,isPageReload:o}){e(this,"_isMounted",_.signal(!1));e(this,"isMounted",_.computed(this._isMounted));e(this,"mount");e(this,"unmount");this.mount=()=>{if(this.isMounted())return I(void 0);const u=D(o)?s():void 0,a=u?I(u):typeof n=="function"?n():I(n);return c(a,H(l=>{_.batch(()=>{this._isMounted.set(!0),t==null||t(l)})}))},this.unmount=()=>{this._isMounted()&&_.batch(()=>{this._isMounted.set(!1),i==null||i()})}}}class ve{constructor({isTma:t,storage:s,onClick:n,offClick:i,initialState:o,isPageReload:u,postEvent:a,payload:l,method:p,version:b}){e(this,"isMounted");e(this,"isSupported");e(this,"state");e(this,"stateSetters");e(this,"stateBoolSetters");e(this,"setStateFp");e(this,"setState");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const m=new te({initialState:o,onChange(g){s.set(g)}}),C=new me({initialState:o,isPageReload:u,onMounted:m.setState,restoreState:s.get}),S={version:b,requires:p,isTma:t},w=B({...S,returns:"plain"}),F=B({...S,returns:"either",isMounted:C.isMounted});this.isMounted=C.isMounted,this.isSupported=Y(p,b),this.state=m.state,this.setStateFp=F(g=>{const v={...this.state(),...Ae(g)};return m.hasDiff(v)?c(a(p,l(v)),H(()=>{m.setState(v)})):I(void 0)}),this.setState=f(this.setStateFp),this.onClickFp=w(n),this.onClick=f(this.onClickFp),this.offClickFp=w(i),this.offClick=f(this.offClickFp),this.mountFp=w(()=>{const g=()=>{};return c(C.mount(),de(g,g))}),this.mount=f(this.mountFp),this.unmount=C.unmount,this.stateSetters=g=>{const v=F(d=>this.setStateFp({[g]:d}));return[f(v),v]},this.stateBoolSetters=g=>{const[,v]=this.stateSetters(g),d=F(()=>v(!1)),V=F(()=>v(!0));return[[f(d),d],[f(V),V]]}}stateGetter(t){return _.computed(()=>this.state()[t])}}class Ct{constructor(t){e(this,"isVisible");e(this,"isMounted");e(this,"isSupported");e(this,"hideFp");e(this,"hide");e(this,"showFp");e(this,"show");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const s=new ve({...t,method:"web_app_setup_back_button",payload:n=>({is_visible:n.isVisible}),initialState:{isVisible:!1}});this.isVisible=s.stateGetter("isVisible"),this.isMounted=s.isMounted,this.isSupported=s.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=s.stateBoolSetters("isVisible"),this.onClick=s.onClick,this.onClickFp=s.onClickFp,this.offClick=s.offClick,this.offClickFp=s.offClickFp,this.mount=s.mount,this.mountFp=s.mountFp,this.unmount=s.unmount}}function y(){return{isTma:_.computed(()=>h.isTMAFp())}}function ps(r){return{get:()=>O.getStorageValue(r),set(t){O.setStorageValue(r,t)}}}function ls(){return performance.getEntriesByType("navigation")[0]}function hs(){const r=ls();return!!r&&r.type==="reload"}function be(r){return t=>({...t,...D(r)})}function re(r){return be({storage:ps(r),isPageReload:hs})}function _e(r,t){return _.signal(r,t)}const wt=_e(h.postEventFp),ue=(...r)=>wt()(...r),St=(...r)=>O.throwifyAnyEither(ue(...r)),$=be({postEvent:ue}),Be=_e("0.0"),E=be({version:Be});function Ue(r,t){return{...c(y(),$,E,re(r)),onClick(s,n){return h.on(t,s,n)},offClick(s,n){h.off(t,s,n)}}}const ds=new Ct(Ue("backButton","back_button_pressed"));class Ge{constructor({initialState:t,onMounted:s,restoreState:n,onUnmounted:i,isPageReload:o}){e(this,"_isMounted",_.signal(!1));e(this,"isMounted",_.computed(this._isMounted));e(this,"mount");e(this,"unmount");this.mount=u=>{if(this._isMounted())return M(void 0);const a=D(o)?n():void 0;return c(a?M(a):t(u),x(l=>{this._isMounted()||_.batch(()=>{this._isMounted.set(!0),s==null||s(l)})}))},this.unmount=()=>{this._isMounted()&&_.batch(()=>{this._isMounted.set(!1),i==null||i()})}}}const nt=new ft("Biometry is not available");function ke(r){let t=!1,s=!1,n="",i=!1,o="",u=!1;return r.available&&(t=!0,s=r.token_saved,n=r.device_id,i=r.access_requested,o=r.type,u=r.access_granted),{available:t,tokenSaved:s,deviceId:n,type:o,accessGranted:u,accessRequested:i}}class vt{constructor({version:t,request:s,postEvent:n,storage:i,onInfoReceived:o,offInfoReceived:u,isTma:a,isPageReload:l}){e(this,"isAvailable");e(this,"isSupported");e(this,"isMounted");e(this,"state");e(this,"authenticateFp");e(this,"authenticate");e(this,"openSettingsFp");e(this,"openSettings");e(this,"requestAccessFp");e(this,"requestAccess");e(this,"updateTokenFp");e(this,"updateToken");e(this,"mountFp");e(this,"mount");e(this,"unmount");const p=g=>{b.setState(ke(g))},b=new te({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:i.set}),m=new Ge({initialState(g){return c(s("web_app_biometry_get_info","biometry_info_received",g),x(ke))},isPageReload:l,onMounted(g){b.setState(g),o(p)},onUnmounted(){u(p)},restoreState:i.get}),C={version:t,requires:"web_app_biometry_request_auth",isTma:a},S=B({...C,returns:"either"}),w=B({...C,returns:"task"}),F=B({...C,isMounted:m.isMounted,returns:"task"});this.isAvailable=b.getter("available"),this.isMounted=m.isMounted,this.isSupported=Y("web_app_biometry_request_auth",t),this.state=b.state,this.unmount=m.unmount,this.mountFp=w(m.mount),this.authenticateFp=F(g=>this.isAvailable()?c(s("web_app_biometry_request_auth","biometry_auth_requested",{...g,params:{reason:((g||{}).reason||"").trim()}}),x(v=>(b.setState({token:v.token}),v))):R(nt)),this.openSettingsFp=S(()=>n("web_app_biometry_open_settings")),this.requestAccessFp=F(g=>c(s("web_app_biometry_request_access","biometry_info_received",{...g,params:{reason:((g||{}).reason||"").trim()}}),X(v=>{const d=ke(v);return d.available?(b.setState(d),M(d.accessRequested)):R(nt)}))),this.updateTokenFp=F((g={})=>{var v;return c(s("web_app_biometry_update_token","biometry_token_updated",{...g,params:{token:g.token||"",reason:(v=g.reason)==null?void 0:v.trim()}}),x(d=>d.status))}),this.authenticate=f(this.authenticateFp),this.openSettings=f(this.openSettingsFp),this.requestAccess=f(this.requestAccessFp),this.updateToken=f(this.updateTokenFp),this.mount=f(this.mountFp)}}const He=(r,t,s)=>h.requestFp(r,t,{postEvent:ue,...s}),fs=(...r)=>lr.BetterPromise.fn(()=>He(...r)()),Q=be({request:He}),ms=new vt({...c(y(),$,E,Q,re("biometry")),offInfoReceived(r){h.off("biometry_info_received",r)},onInfoReceived(r){return h.on("biometry_info_received",r)}});class yt{constructor({postEvent:t,storage:s,isTma:n,isPageReload:i}){e(this,"isConfirmationEnabled");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"disableConfirmationFp");e(this,"disableConfirmation");e(this,"enableConfirmationFp");e(this,"enableConfirmation");const o=new te({initialState:{isConfirmationEnabled:!1},onChange(m){s.set(m)}}),u=new me({onMounted:o.setState,restoreState:s.get,initialState:{isConfirmationEnabled:!1},isPageReload:i}),a={requires:"web_app_setup_closing_behavior",isTma:n},l=B({...a,returns:"plain"}),p=B({...a,returns:"either",isMounted:u.isMounted}),b=m=>m===this.isConfirmationEnabled()?I(void 0):(o.setState({isConfirmationEnabled:m}),t("web_app_setup_closing_behavior",{need_confirmation:m}));this.isConfirmationEnabled=o.getter("isConfirmationEnabled"),this.isMounted=u.isMounted,this.disableConfirmationFp=p(()=>b(!1)),this.enableConfirmationFp=p(()=>b(!0)),this.mountFp=l(()=>{const m=()=>{};return c(u.mount(),de(m,m))}),this.unmount=u.unmount,this.disableConfirmation=f(this.disableConfirmationFp),this.enableConfirmation=f(this.enableConfirmationFp),this.mount=f(this.mountFp)}}const bs=new yt(c(y(),re("closingBehavior"),$));class kt{constructor({version:t,isTma:s,invokeCustomMethod:n}){e(this,"isSupported");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"getItemFp");e(this,"getItem");e(this,"getItemsFp");e(this,"getItems");e(this,"getKeysFp");e(this,"getKeys");e(this,"setItemFp");e(this,"setItem");e(this,"clearFp");e(this,"clear");const i=B({version:t,requires:"web_app_invoke_custom_method",isTma:s,returns:"task"});this.isSupported=Y("web_app_invoke_custom_method",t),this.deleteItemFp=i((o,u)=>{const a=Array.isArray(o)?o:[o];return c(a.length?n("deleteStorageValues",{keys:a},u):M(void 0),x(()=>{}))}),this.getItemFp=i((o,u)=>c(this.getItemsFp([o],u),x(a=>a[o]||""))),this.getItemsFp=i((o,u)=>c(o.length?n("getStorageValues",{keys:o},u):M({}),x(a=>({...o.reduce((l,p)=>(l[p]="",l),{}),...k.parse(k.record(k.string(),k.string()),a)})))),this.getKeysFp=i(o=>c(n("getStorageKeys",{},o),x(u=>k.parse(k.array(k.string()),u)))),this.setItemFp=i((o,u,a)=>c(n("saveStorageValue",{key:o,value:u},a),x(()=>{}))),this.clearFp=i(o=>c(this.getKeysFp(o),X(this.deleteItemFp))),this.deleteItem=f(this.deleteItemFp),this.getItem=f(this.getItemFp),this.getItems=f(this.getItemsFp),this.getKeys=f(this.getKeysFp),this.setItem=f(this.setItemFp),this.clear=f(this.clearFp)}}const Ee=_e(0);function Qe(){return Ee.set(Ee()+1),Ee().toString()}function Et(r,t,s){return h.invokeCustomMethodFp(r,t,Qe(),{...s||{},postEvent:ue})}const We=be({invokeCustomMethod:Et}),_s=new kt(c(y(),E,We));function gs({request:r,...t}){return P(s=>c(r("web_app_request_emoji_status_access","emoji_status_access_requested",s),x(n=>n.status)),{...t,requires:"web_app_request_emoji_status_access",returns:"task"})}const At=gs(c(y(),E,Q)),Fs=f(At);function Cs({request:r,...t}){return P((s,n)=>c(r("web_app_set_emoji_status",["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:s,duration:(n||{}).duration},...n}),ae(i=>i&&"error"in i?R(new bt(i.error)):M(void 0))),{...t,requires:"web_app_set_emoji_status",returns:"task"})}const Bt=Cs(c(y(),Q,E)),ws=f(Bt);class Pt{constructor({postEvent:t,isTma:s,version:n}){e(this,"isSupported");e(this,"impactOccurredFp");e(this,"impactOccurred");e(this,"notificationOccurredFp");e(this,"notificationOccurred");e(this,"selectionChangedFp");e(this,"selectionChanged");const i="web_app_trigger_haptic_feedback",o=B({requires:i,isTma:s,version:n,returns:"plain"});this.isSupported=Y(i,n),this.impactOccurredFp=o(u=>t(i,{type:"impact",impact_style:u})),this.notificationOccurredFp=o(u=>t(i,{type:"notification",notification_type:u})),this.selectionChangedFp=o(()=>t(i,{type:"selection_change"})),this.impactOccurred=f(this.impactOccurredFp),this.notificationOccurred=f(this.notificationOccurredFp),this.selectionChanged=f(this.selectionChangedFp)}}const Ss=new Pt(c(y(),$,E));function vs({postEvent:r,...t}){return P(()=>r("web_app_add_to_home_screen"),{...t,requires:"web_app_add_to_home_screen",returns:"either"})}const It=vs(c(y(),E,$)),ys=f(It);function ks({request:r,...t}){return P(s=>c(r("web_app_check_home_screen","home_screen_checked",s),x(n=>n.status||"unknown")),{...t,requires:"web_app_check_home_screen",returns:"task"})}const qt=ks(c(y(),E,Q)),Es=f(qt);class xt{constructor({retrieveInitData:t}){e(this,"_state",_.signal());e(this,"_raw",_.signal());e(this,"state",_.computed(this._state));e(this,"authDate",this.fromState("auth_date"));e(this,"canSendAfter",this.fromState("can_send_after"));e(this,"canSendAfterDate",_.computed(()=>{const t=this.authDate(),s=this.canSendAfter();return s&&t?new Date(t.getTime()+s*1e3):void 0}));e(this,"chat",this.fromState("chat"));e(this,"chatType",this.fromState("chat_type"));e(this,"chatInstance",this.fromState("chat_instance"));e(this,"hash",this.fromState("hash"));e(this,"queryId",this.fromState("query_id"));e(this,"raw",_.computed(this._raw));e(this,"receiver",this.fromState("receiver"));e(this,"signature",this.fromState("signature"));e(this,"startParam",this.fromState("start_param"));e(this,"user",this.fromState("user"));e(this,"restoreFp");e(this,"restore");this.restoreFp=()=>c(t(),H(pt(()=>{},({raw:s,obj:n})=>{this._state.set(n),this._raw.set(s)}))),this.restore=O.throwifyFpFn(this.restoreFp)}fromState(t){return _.computed(()=>{const s=this._state();return s?s[t]:void 0})}}const As=new xt({retrieveInitData(){return c(Ar,rt("obj",()=>c(h.retrieveLaunchParamsFp(),H(({tgWebAppData:r})=>r?fe(r):ie))),rt("raw",h.retrieveRawInitDataFp),H(({obj:r,raw:t})=>c(Rr,st("obj",()=>r),st("raw",()=>t))))}});class Mt{constructor({version:t,request:s,isTma:n}){e(this,"isOpened");e(this,"isSupported");e(this,"openSlugFp");e(this,"openSlug");e(this,"openUrlFp");e(this,"openUrl");const i=B({version:t,isTma:n,requires:"web_app_open_invoice",returns:"task"}),o=_.signal(!1),u=()=>{o.set(!1)};this.isSupported=Y("web_app_open_invoice",t),this.isOpened=_.computed(o),this.openSlugFp=i((a,l)=>c(this.isOpened()?R(new Se("Invoice is already opened")):M(void 0),X(()=>(o.set(!0),s("web_app_open_invoice","invoice_closed",{...l,params:{slug:a},capture:p=>a===p.slug}))),$e(p=>(u(),p),p=>(u(),p.status)))),this.openUrlFp=i((a,l)=>{const{hostname:p,pathname:b}=new URL(a,window.location.href);if(p!=="t.me")return R(new J(`Link has unexpected hostname: ${p}`));const m=b.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return m?this.openSlugFp(m[2],l):R(new J('Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"'))}),this.openUrl=f(this.openUrlFp),this.openSlug=f(this.openSlugFp)}}const Bs=new Mt(c(y(),Q,E));function Ps({postEvent:r,...t}){return P((s,n={})=>{if(typeof s=="string")try{s=new URL(s)}catch(i){return L(new J(`"${s.toString()}" is invalid URL`,i))}return r("web_app_open_link",{url:s.toString(),try_browser:n.tryBrowser,try_instant_view:n.tryInstantView})},{...t,returns:"either"})}const Tt=Ps(c(y(),$)),Is=f(Tt);function qs({postEvent:r,version:t,...s}){return P(n=>{const i=n.toString();return i.match(/^https:\/\/t.me\/.+/)?h.supports("web_app_open_tg_link",D(t))?(n=new URL(n),r("web_app_open_tg_link",{path_full:n.pathname+n.search})):(window.location.href=i,I(void 0)):L(new J(`"${i}" is invalid URL`))},{...s,returns:"either"})}const Ke=qs(c(y(),$,E)),xs=f(Ke);function Ms({openTelegramLink:r,...t}){return P((s,n)=>r("https://t.me/share/url?"+new URLSearchParams({url:s,text:n||""}).toString().replace(/\+/g,"%20")),{...t,returns:"either"})}const Lt=Ms({...y(),openTelegramLink:Ke}),Ts=f(Lt);function Ls(r){let t=!1,s,n;return r.available&&(t=!0,s=r.access_requested,n=r.access_granted),{available:t,accessGranted:n||!1,accessRequested:s||!1}}class Ot{constructor({version:t,request:s,postEvent:n,storage:i,isTma:o,isPageReload:u}){e(this,"state");e(this,"isAvailable");e(this,"isAccessGranted");e(this,"isAccessRequested");e(this,"isMounted");e(this,"isSupported");e(this,"openSettingsFp");e(this,"openSettings");e(this,"requestLocationFp");e(this,"requestLocation");e(this,"mountFp");e(this,"mount");e(this,"unmount");const a=new te({initialState:{available:!1,accessGranted:!1,accessRequested:!1},onChange:i.set}),l=new Ge({isPageReload:u,restoreState:i.get,onMounted:a.setState,initialState(S){return c(s("web_app_check_location","location_checked",S),x(Ls))}}),p={version:t,requires:"web_app_check_location",isTma:o},b=B({...p,returns:"either"}),m=B({...p,returns:"task"}),C=B({...p,returns:"task",isMounted:l.isMounted});this.isAvailable=a.getter("available"),this.isAccessRequested=a.getter("accessRequested"),this.isAccessGranted=a.getter("accessGranted"),this.isSupported=Y("web_app_check_location",t),this.isMounted=l.isMounted,this.state=a.state,this.unmount=l.unmount,this.mountFp=m(l.mount),this.openSettingsFp=b(()=>n("web_app_open_location_settings")),this.requestLocationFp=C(S=>c(s("web_app_request_location","location_requested",S),x(w=>{if(!w.available)return a.setState({available:!1}),null;const{available:F,...g}=w;return g}))),this.mount=f(this.mountFp),this.openSettings=f(this.openSettingsFp),this.requestLocation=f(this.requestLocationFp)}}const Os=new Ot(c(y(),$,E,Q,re("locationManager")));class Vt{constructor({defaults:t,...s}){e(this,"bgColor");e(this,"hasShineEffect");e(this,"isEnabled");e(this,"isLoaderVisible");e(this,"isVisible");e(this,"isMounted");e(this,"state");e(this,"text");e(this,"textColor");e(this,"showFp");e(this,"show");e(this,"hideFp");e(this,"hide");e(this,"enableFp");e(this,"enable");e(this,"enableShineEffectFp");e(this,"enableShineEffect");e(this,"disableFp");e(this,"disable");e(this,"disableShineEffectFp");e(this,"disableShineEffect");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"setTextColorFp");e(this,"setTextColor");e(this,"setTextFp");e(this,"setText");e(this,"showLoaderFp");e(this,"showLoader");e(this,"hideLoaderFp");e(this,"hideLoader");e(this,"setParamsFp");e(this,"setParams");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");const n=new ve({...s,version:"100",initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"},method:"web_app_setup_main_button",payload:o=>({has_shine_effect:o.hasShineEffect,is_visible:o.isVisible,is_active:o.isEnabled,is_progress_visible:o.isLoaderVisible,text:o.text,color:o.bgColor,text_color:o.textColor})}),i=(o,u)=>{const a=n.stateGetter(o);return _.computed(()=>a()||D(u))};this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.hasShineEffect=n.stateGetter("hasShineEffect"),this.isEnabled=n.stateGetter("isEnabled"),this.isLoaderVisible=n.stateGetter("isLoaderVisible"),this.text=n.stateGetter("text"),this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.state=n.state,[this.setBgColor,this.setBgColorFp]=n.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=n.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=n.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=n.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=n.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=n.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.setParams=n.setState,this.setParamsFp=n.setStateFp,this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}function Rt(r,t,s){return c(Ue(r,t),n=>({...n,defaults:s}))}const Pe=_e({});function ze(r,t){document.documentElement.style.setProperty(r,t)}function Ne(r){document.documentElement.style.removeProperty(r)}function $t(r){return c(q.toRGBFullFp(r),H(t=>Math.sqrt([.299,.587,.114].reduce((s,n,i)=>{const o=parseInt(t.slice(1+i*2,1+(i+1)*2),16);return s+o*o*n},0))<120))}const Je=O.throwifyFpFn($t);class jt{constructor({initialState:t,onChange:s,offChange:n,isTma:i,storage:o,isPageReload:u}){e(this,"accentTextColor");e(this,"bgColor");e(this,"buttonColor");e(this,"buttonTextColor");e(this,"bottomBarBgColor");e(this,"destructiveTextColor");e(this,"headerBgColor");e(this,"hintColor");e(this,"linkColor");e(this,"secondaryBgColor");e(this,"sectionBgColor");e(this,"sectionHeaderTextColor");e(this,"sectionSeparatorColor");e(this,"subtitleTextColor");e(this,"textColor");e(this,"_isCssVarsBound",_.signal(!1));e(this,"isCssVarsBound",_.computed(this._isCssVarsBound));e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"state");e(this,"isDark",_.computed(()=>{const t=this.bgColor();return!t||Je(t)}));e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");const a=new te({initialState:{},onChange:o.set}),l=S=>{a.setState(S.theme_params)},p=new me({initialState:()=>I(D(t)),isPageReload:u,onMounted(S){a.setState(S),s(l)},onUnmounted(){n(l)},restoreState:o.get}),b={isTma:i,returns:"either"},m=B(b),C=B({...b,isMounted:p.isMounted});this.accentTextColor=a.getter("accent_text_color"),this.bgColor=a.getter("bg_color"),this.buttonColor=a.getter("button_color"),this.buttonTextColor=a.getter("button_text_color"),this.bottomBarBgColor=a.getter("bottom_bar_bg_color"),this.destructiveTextColor=a.getter("destructive_text_color"),this.headerBgColor=a.getter("header_bg_color"),this.hintColor=a.getter("hint_color"),this.linkColor=a.getter("link_color"),this.secondaryBgColor=a.getter("secondary_bg_color"),this.sectionBgColor=a.getter("section_bg_color"),this.sectionHeaderTextColor=a.getter("section_header_text_color"),this.sectionSeparatorColor=a.getter("section_separator_color"),this.subtitleTextColor=a.getter("subtitle_text_color"),this.textColor=a.getter("text_color"),this.state=a.state,this.isMounted=p.isMounted,this.bindCssVarsFp=C(S=>{if(this._isCssVarsBound())return L(new we);S||(S=g=>`--tg-theme-${O.snakeToKebab(g)}`);const w=g=>{Object.entries(a.state()).forEach(([v,d])=>{d&&g(v,d)})},F=()=>{w((g,v)=>{ze(S(g),v)})};return F(),a.state.sub(F),this._isCssVarsBound.set(!0),I(()=>{w(Ne),a.state.unsub(F),this._isCssVarsBound.set(!1)})}),this.mountFp=m(p.mount),this.unmount=p.unmount,this.bindCssVars=f(this.bindCssVarsFp),this.mount=f(this.mountFp)}}const le=new jt({...c(y(),re("themeParams")),offChange(r){h.off("theme_changed",r)},onChange(r){h.on("theme_changed",r)},initialState:Pe}),Vs=new Vt(Rt("mainButton","main_button_pressed",{bgColor:_.computed(()=>le.buttonColor()||"#2481cc"),textColor:_.computed(()=>le.buttonTextColor()||"#ffffff")}));class Dt{constructor({storage:t,isPageReload:s,version:n,postEvent:i,isTma:o,theme:u,onVisibilityChanged:a,offVisibilityChanged:l}){e(this,"isSupported");e(this,"isDark",_.computed(()=>{const t=this.bgColorRgb();return t?Je(t):!1}));e(this,"isActive");e(this,"state");e(this,"isCssVarsBound");e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"bgColor");e(this,"bgColorRgb");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"headerColor");e(this,"headerColorRgb");e(this,"setHeaderColorFp");e(this,"setHeaderColor");e(this,"bottomBarColor");e(this,"bottomBarColorRgb");e(this,"setBottomBarColorFp");e(this,"setBottomBarColor");e(this,"closeFp");e(this,"close");e(this,"readyFp");e(this,"ready");const p=d=>{C.setState({isActive:d.is_visible})},b=d=>{[[this.headerColor,"web_app_set_header_color"],[this.bgColor,"web_app_set_background_color"],[this.bottomBarColor,"web_app_set_bottom_bar_color"]].forEach(([V,j])=>{const U=V();if(!q.isRGB(U)&&(j==="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes(U))){const G=d[U];G&&i(j,{color:G})}})},m=new me({initialState(){const d=D(u);return I({bgColor:d.bg_color||"bg_color",headerColor:d.header_bg_color||"header_bg_color",bottomBarColor:d.bottom_bar_bg_color||"bottom_bar_bg_color",isActive:!0})},isPageReload:s,onMounted:d=>{this.setBgColorFp.ifAvailable(d.bgColor),this.setBottomBarColorFp.ifAvailable(d.bottomBarColor),this.setHeaderColorFp.ifAvailable(d.headerColor),a(p),u.sub(b),C.setState(d)},onUnmounted(){l(p),u.unsub(b)},restoreState:t.get});this.isMounted=m.isMounted,this.mountFp=P(()=>{const d=()=>{};return c(m.mount(),de(d,d))},{isTma:o,returns:"plain"}),this.mount=f(this.mountFp),this.unmount=m.unmount;const C=new te({initialState:{bgColor:"bg_color",bottomBarColor:"bottom_bar_bg_color",headerColor:"bg_color",isActive:!1},onChange:t.set});this.state=C.state;const S=d=>q.isRGB(d)?d:D(u)[d],w=d=>_.computed(()=>S(d()));this.isActive=C.getter("isActive"),this.isSupported=_.computed(()=>["web_app_set_header_color","web_app_set_background_color","web_app_set_bottom_bar_color"].some(d=>h.supports(d,D(n))));const F=_.signal(!1);this.isCssVarsBound=_.computed(F),this.bindCssVarsFp=P(d=>{if(F())return L(new we);const[V,j]=O.createCbCollector(()=>{F.set(!1)}),U=(G,W)=>{const z=()=>{ze(G,W()||null)};z(),V(W.sub(z),Ne.bind(null,G))};return d||(d=G=>`--tg-${O.camelToKebab(G)}`),U(d("bgColor"),this.bgColorRgb),U(d("bottomBarColor"),this.bottomBarColorRgb),U(d("headerColor"),this.headerColorRgb),F.set(!0),I(j)},{isTma:o,returns:"either",isMounted:this.isMounted}),this.bindCssVars=f(this.bindCssVarsFp);const g=d=>{const V=C.getter(d),j=w(V),U={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[d],G=P(W=>{if(W===V())return I(void 0);if(U==="web_app_set_header_color"&&(W==="bg_color"||W==="secondary_bg_color"))return i("web_app_set_header_color",{color_key:W});const z=S(W);return c(z?i(U,{color:z}):L(new Ft(W)),H(()=>{C.setState({[d]:z})}))},{isTma:o,version:n,requires:U,isMounted:this.isMounted,returns:"either",supports:d==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:q.isRGB}}:void 0});return[V,j,f(G),G]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=g("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=g("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=g("bottomBarColor");const v=B({isTma:o,returns:"either"});this.closeFp=v(d=>i("web_app_close",{return_back:d})),this.close=f(this.closeFp),this.readyFp=v(()=>i("web_app_ready")),this.ready=f(this.readyFp)}}const Ut=new Dt({...c(y(),$,E,re("miniApp")),offVisibilityChanged(r){h.off("visibility_changed",r)},onVisibilityChanged(r){h.on("visibility_changed",r)},theme:le.state});function Rs(r){const t=r.message.trim(),s=(r.title||"").trim(),n=r.buttons||[];if(s.length>64)return L(new J(`Invalid title: ${s}`));if(!t||t.length>256)return L(new J(`Invalid message: ${t}`));if(n.length>3)return L(new J(`Invalid buttons count: ${n.length}`));const i=[];if(!n.length)i.push({type:"close",id:""});else for(let o=0;o<n.length;o++){const u=n[o],a=u.id||"";if(a.length>64)return L(new J(`Button with index ${o} has invalid id: ${a}`));if(!u.type||u.type==="default"||u.type==="destructive"){const l=u.text.trim();if(!l||l.length>64)return L(new J(`Button with index ${o} has invalid text: ${l}`));i.push({type:u.type,text:l,id:a})}else i.push({type:u.type,id:a})}return I({title:s,message:t,buttons:i})}class Gt{constructor({version:t,isTma:s,request:n}){e(this,"isOpened");e(this,"isSupported");e(this,"showFp");e(this,"show");const i=_.signal(!1),o=()=>{i.set(!1)},u=B({version:t,isTma:s,requires:"web_app_open_popup",returns:"task"});this.isSupported=Y("web_app_open_popup",t),this.isOpened=_.computed(i),this.showFp=u(a=>c(this.isOpened()?R(new Se("A popup is already opened")):M(void 0),ae(()=>dt(Rs(a))),X(l=>(i.set(!0),n("web_app_open_popup","popup_closed",{...a,params:l}))),$e(l=>(o(),l),l=>(o(),l.button_id)))),this.show=f(this.showFp)}}const $s=new Gt(c(y(),Q,E));function js({request:r,...t}){return P(s=>c(r("web_app_request_phone","phone_requested",s),x(n=>n.status)),{...t,requires:"web_app_request_phone",returns:"task"})}const Ye=js(c(y(),E,Q)),Ds=f(Ye);function Us({invokeCustomMethod:r,requestPhoneAccess:t,...s}){const n=u=>c(r("getRequestedContact",{},{...u,timeout:(u||{}).timeout||5e3}),ae(a=>{const l=k.safeParse(k.string(),a);if(!l.success)return R(new ce(a,l.issues));if(!l.output)return M(void 0);const p=k.safeParse(q.pipeQueryToSchema(k.looseObject({contact:q.pipeJsonToSchema(k.looseObject({user_id:k.number(),phone_number:k.string(),first_name:k.string(),last_name:k.optional(k.string())})),auth_date:k.pipe(k.string(),k.transform(b=>new Date(Number(b)*1e3)),k.date()),hash:k.string()})),l.output);return p.success?M({raw:l.output,parsed:p.output}):R(new ce(l.output,p.issues))})),i=u=>c(n(u),Xr(a=>ce.is(a)?L(a):I(void 0),a=>I(a))),o=u=>O.BetterTaskEither(async(a,l,p)=>{let b=50;for(;!p.isRejected;){const m=await i(p)();if(m._tag==="Left")return l(m.left);if(m.right)return a(m.right);await new Promise(C=>setTimeout(C,b)),b+=50}},u);return P(u=>O.BetterTaskEither.fn(a=>c(i(a),X(l=>l?M(l):c(t(a),ae(p=>p==="sent"?o(a):R(new De("User denied access")))))),u),{...s,returns:"task",requires:"web_app_request_phone"})}function Gs({requestContact:r,...t}){return P(r,{...t,returns:"task",requires:"web_app_request_phone"})}const Ze=Us({...c(y(),We,E),requestPhoneAccess:Ye}),Hs=f(Ze),Ht=Gs({...c(y(),E),requestContact(r){return c(Ze(r),x(t=>t.parsed))}}),Qs=f(Ht);function Ws({request:r,...t}){return P(s=>c(r("web_app_request_write_access","write_access_requested",s),x(n=>n.status)),{...t,requires:"web_app_request_write_access",returns:"task"})}const Qt=Ws(c(y(),E,Q)),Ks=f(Qt);class Wt{constructor({version:t,onClosed:s,onTextReceived:n,isTma:i,postEvent:o}){e(this,"isOpened");e(this,"isSupported");e(this,"captureFp");e(this,"capture");e(this,"closeFp");e(this,"close");e(this,"openFp");e(this,"open");const u={version:t,requires:"web_app_open_scan_qr_popup",isTma:i},a=B({...u,returns:"either"}),l=B({...u,returns:"task"}),p=_.signal(!1),b=()=>{p.set(!1)};this.isSupported=Y("web_app_open_scan_qr_popup",t),this.isOpened=_.computed(p),this.captureFp=l(m=>{let C;return c(this.openFp({...m,onCaptured:S=>{m.capture(S)&&(C=S,this.close())}}),x(()=>C))}),this.closeFp=a(()=>c(o("web_app_close_scan_qr_popup"),H(b))),this.openFp=l(m=>c(this.isOpened()?R(new Se("The QR Scanner is already opened")):async()=>o("web_app_open_scan_qr_popup",{text:m.text}),ae(()=>{const[C,S]=O.createCbCollector(),w=F=>(S(),F);return c(O.BetterTaskEither(F=>{C(s(F),n(m.onCaptured))},m),$e(w,w))}))),this.open=f(this.openFp),this.capture=f(this.captureFp),this.close=f(this.closeFp)}}const zs=new Wt({...c(y(),$,E),onClosed(r){return h.on("scan_qr_popup_closed",r)},onTextReceived(r){return h.on("qr_text_received",t=>{r(t.data)})}});class Kt{constructor({defaults:t,...s}){e(this,"isSupported");e(this,"position");e(this,"bgColor");e(this,"hasShineEffect");e(this,"isEnabled");e(this,"isLoaderVisible");e(this,"isVisible");e(this,"isMounted");e(this,"state");e(this,"text");e(this,"textColor");e(this,"showFp");e(this,"show");e(this,"hideFp");e(this,"hide");e(this,"enableFp");e(this,"enable");e(this,"enableShineEffectFp");e(this,"enableShineEffect");e(this,"disableFp");e(this,"disable");e(this,"disableShineEffectFp");e(this,"disableShineEffect");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"setTextColorFp");e(this,"setTextColor");e(this,"setTextFp");e(this,"setText");e(this,"setPositionFp");e(this,"setPosition");e(this,"showLoaderFp");e(this,"showLoader");e(this,"hideLoaderFp");e(this,"hideLoader");e(this,"setParamsFp");e(this,"setParams");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");const n=new ve({...s,initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Cancel",position:"left"},method:"web_app_setup_secondary_button",payload:o=>({has_shine_effect:o.hasShineEffect,is_visible:o.isVisible,is_active:o.isEnabled,is_progress_visible:o.isLoaderVisible,text:o.text,color:o.bgColor,text_color:o.textColor,position:o.position})}),i=(o,u)=>{const a=n.stateGetter(o);return _.computed(()=>a()||D(u))};this.isSupported=Y("web_app_setup_secondary_button",s.version),this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.position=n.stateGetter("position"),this.hasShineEffect=n.stateGetter("hasShineEffect"),this.isEnabled=n.stateGetter("isEnabled"),this.isLoaderVisible=n.stateGetter("isLoaderVisible"),this.text=n.stateGetter("text"),this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.state=n.state,[this.setPosition,this.setPositionFp]=n.stateSetters("position"),[this.setBgColor,this.setBgColorFp]=n.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=n.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=n.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=n.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=n.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=n.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.setParams=n.setState,this.setParamsFp=n.setStateFp,this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}const Ns=new Kt(Rt("secondaryButton","secondary_button_pressed",{bgColor:_.computed(()=>Ut.bottomBarColorRgb()||"#000000"),textColor:_.computed(()=>le.buttonColor()||"#2481cc")}));class zt{constructor(t){e(this,"isVisible");e(this,"isMounted");e(this,"isSupported");e(this,"hideFp");e(this,"hide");e(this,"showFp");e(this,"show");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const s=new ve({...t,method:"web_app_setup_settings_button",payload:n=>({is_visible:n.isVisible}),initialState:{isVisible:!1}});this.isVisible=s.stateGetter("isVisible"),this.isMounted=s.isMounted,this.isSupported=s.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=s.stateBoolSetters("isVisible"),this.onClick=s.onClick,this.onClickFp=s.onClickFp,this.offClick=s.offClick,this.offClickFp=s.offClickFp,this.mount=s.mount,this.mountFp=s.mountFp,this.unmount=s.unmount}}const Js=new zt(Ue("settingsButton","settings_button_pressed"));class Nt{constructor({postEvent:t,storage:s,isTma:n,isPageReload:i,version:o}){e(this,"isSupported");e(this,"isVerticalEnabled");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"disableVerticalFp");e(this,"disableVertical");e(this,"enableVerticalFp");e(this,"enableVertical");const u=new te({initialState:{isVerticalEnabled:!1},onChange(C){s.set(C)}}),a=new me({initialState:{isVerticalEnabled:!1},isPageReload:i,onMounted:u.setState,restoreState:s.get}),l={requires:"web_app_setup_swipe_behavior",isTma:n,version:o},p=B({...l,returns:"plain"}),b=B({...l,isMounted:a.isMounted,returns:"either"}),m=C=>{const S={isVerticalEnabled:C};return u.hasDiff(S)?c(t("web_app_setup_swipe_behavior",{allow_vertical_swipe:C}),H(()=>{u.setState(S)})):I(void 0)};this.isSupported=Y("web_app_setup_swipe_behavior",o),this.isVerticalEnabled=u.getter("isVerticalEnabled"),this.isMounted=a.isMounted,this.disableVerticalFp=b(()=>m(!1)),this.enableVerticalFp=b(()=>m(!0)),this.mountFp=p(()=>{const C=()=>{};return c(a.mount(),de(C,C))}),this.unmount=a.unmount,this.disableVertical=f(this.disableVerticalFp),this.enableVertical=f(this.enableVerticalFp),this.mount=f(this.mountFp)}}const Ys=new Nt(c(y(),$,E,re("swipeBehavior")));async function Zs(r){try{const{clipboard:s}=navigator;if(s)return await s.writeText(r)}catch{}const t=document.createElement("textarea");t.value=r,t.style.top="0",t.style.left="0",t.style.position="fixed",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}finally{document.body.removeChild(t)}}function Xs({request:r,...t}){return P((s,n,i)=>c(r("web_app_request_file_download","file_download_requested",{...i,params:{url:s,file_name:n}}),X(o=>o.status==="downloading"?M(void 0):R(new De("User denied the action")))),{...t,requires:"web_app_request_file_download",returns:"task"})}const Jt=Xs(c(y(),Q,E)),en=f(Jt);function tn({invokeCustomMethod:r,...t}){return P(s=>c(r("getCurrentTime",{},s),X(n=>{const i=k.safeParse(k.pipe(k.number(),k.integer(),k.transform(o=>new Date(o*1e3)),k.date()),n);return i.success?M(i.output):R(new ce(n,i.issues))})),{...t,requires:"web_app_invoke_custom_method",returns:"task"})}const Yt=tn(c(y(),We,E)),rn=f(Yt);function sn({postEvent:r,...t}){return P(()=>r("web_app_hide_keyboard"),{...t,returns:"either",requires:"web_app_hide_keyboard"})}const Zt=sn(c(y(),$,E)),nn=f(Zt);function on({request:r,createRequestId:t,...s}){return P(n=>{const i=t();return c(r("web_app_read_text_from_clipboard","clipboard_text_received",{...n,params:{req_id:i},capture:h.captureSameReq(i)}),x(({data:o=null})=>o))},{...s,requires:"web_app_read_text_from_clipboard",returns:"task"})}const Xt=on({...c(y(),E,Q),createRequestId:Qe}),an=f(Xt);function er(r){const t={},s=r.match(/Telegram-Android(?:\/([^ ]+))?(?: (\([^)]+\))?|$)/);if(s){const[,n,i]=s;n&&(t.appVersion=n),i&&i.slice(1,i.length-1).split(";").forEach(o=>{const[u,a]=o.trim().split(" ");if(u==="Android")t.androidVersion=a;else if(u==="SDK"){const l=parseInt(a,10);l&&(t.sdkVersion=l)}else a?(t.manufacturer=u,t.model=a):t.performanceClass=u})}return t}function un(){return er(navigator.userAgent)}function cn({postEvent:r,...t}){return P(s=>{const{size:n}=new Blob([s]);return!n||n>4096?L(new J(n?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data")):r("web_app_data_send",{data:s})},{...t,returns:"either"})}const tr=cn(c(y(),$)),pn=f(tr);function ln({request:r,...t}){return P((s,n)=>c(r("web_app_send_prepared_message",["prepared_message_failed","prepared_message_sent"],{...n,params:{id:s}}),X(i=>i&&"error"in i?R(new gt(i.error)):M(void 0))),{...t,requires:"web_app_send_prepared_message",returns:"task"})}const rr=ln(c(y(),Q,E)),hn=f(rr);function dn({postEvent:r,...t}){return P((s,n={})=>r("web_app_share_to_story",{text:n.text,media_url:s,widget_link:n.widgetLink}),{...t,requires:"web_app_share_to_story",returns:"either"})}const sr=dn(c(y(),$,E)),fn=f(sr),Ie=_e(!1);function mn({isInlineMode:r,postEvent:t,...s}){return P((n,i)=>t("web_app_switch_inline_query",{query:n,chat_types:i||[]}),{...s,requires:{every:["web_app_switch_inline_query",()=>D(r)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}const nr=mn({...c(y(),$,E),isInlineMode:Ie}),bn=f(nr);class or{constructor({storage:t,isPageReload:s,onContentSafeAreaInsetsChanged:n,onSafeAreaInsetsChanged:i,onViewportChanged:o,onFullscreenChanged:u,offContentSafeAreaInsetsChanged:a,offFullscreenChanged:l,offSafeAreaInsetsChanged:p,offViewportChanged:b,request:m,isViewportStable:C,isFullscreen:S,isTma:w,version:F,postEvent:g}){e(this,"state");e(this,"height");e(this,"stableHeight");e(this,"width");e(this,"isExpanded");e(this,"isStable",_.computed(()=>this.height()===this.stableHeight()));e(this,"contentSafeAreaInsets");e(this,"contentSafeAreaInsetTop");e(this,"contentSafeAreaInsetLeft");e(this,"contentSafeAreaInsetRight");e(this,"contentSafeAreaInsetBottom");e(this,"safeAreaInsets");e(this,"safeAreaInsetTop");e(this,"safeAreaInsetLeft");e(this,"safeAreaInsetRight");e(this,"safeAreaInsetBottom");e(this,"isFullscreen");e(this,"requestFullscreenFp");e(this,"requestFullscreen");e(this,"exitFullscreenFp");e(this,"exitFullscreen");e(this,"isCssVarsBound");e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"expandFp");e(this,"expand");const v={top:0,right:0,left:0,bottom:0},d=new te({initialState:{contentSafeAreaInsets:v,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:v,stableHeight:0,width:0},onChange:t.set}),V=A=>{d.setState({isExpanded:A.is_expanded,height:A.height,width:A.width,stableHeight:A.is_state_stable?A.height:void 0})},j=A=>{d.setState({isFullscreen:A.is_fullscreen})},U=A=>{d.setState({safeAreaInsets:A})},G=A=>{d.setState({contentSafeAreaInsets:A})},W=new Ge({initialState(A){const se=Z=>()=>{const[ee,N]=Z==="safe-area"?["web_app_request_safe_area","safe_area_changed"]:["web_app_request_content_safe_area","content_safe_area_changed"];return h.supports(ee,D(F))?m(ee,N,A):M({top:0,left:0,right:0,bottom:0})},T=Z=>()=>typeof Z=="boolean"?M(Z):dt(Z());return c(as,Ce("safeAreaInsets",se("safe-area")),Ce("contentSafeAreaInsets",se("content-safe-area")),Ce("isFullscreen",T(S)),Ce("isViewportStable",T(C)),ae(({isViewportStable:Z,...ee})=>Z?M({...ee,height:window.innerHeight,isExpanded:!0,stableHeight:window.innerHeight,width:window.innerWidth}):c(m("web_app_request_viewport","viewport_changed",A),x(N=>({...ee,height:N.height,isExpanded:N.is_expanded,stableHeight:N.is_state_stable?N.height:0,width:N.width})))))},isPageReload:s,onMounted(A){o(V),u(j),i(U),n(G),d.setState(A)},onUnmounted(){b(V),l(j),p(U),a(G)},restoreState:t.get}),z=A=>_.computed(()=>this.safeAreaInsets()[A]),ge=A=>_.computed(()=>this.contentSafeAreaInsets()[A]);this.state=d.state,this.height=d.getter("height"),this.stableHeight=d.getter("stableHeight"),this.width=d.getter("width"),this.isExpanded=d.getter("isExpanded"),this.safeAreaInsets=d.getter("safeAreaInsets"),this.safeAreaInsetTop=z("top"),this.safeAreaInsetBottom=z("bottom"),this.safeAreaInsetLeft=z("left"),this.safeAreaInsetRight=z("right"),this.contentSafeAreaInsets=d.getter("contentSafeAreaInsets"),this.contentSafeAreaInsetTop=ge("top"),this.contentSafeAreaInsetBottom=ge("bottom"),this.contentSafeAreaInsetLeft=ge("left"),this.contentSafeAreaInsetRight=ge("right");const ar=B({isTma:w,returns:"task"}),Xe=B({isTma:w,returns:"either"}),ur=B({isTma:w,requires:"web_app_request_fullscreen",version:F,returns:"task"}),et=A=>ur(se=>c(m(A?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],se),X(T=>"error"in T&&T.error!=="ALREADY_FULLSCREEN"?R(new _t(T.error)):(d.setState({isFullscreen:"is_fullscreen"in T?T.is_fullscreen:!0}),M(void 0)))));this.isMounted=W.isMounted,this.mountFp=ar(W.mount),this.mount=f(this.mountFp),this.isFullscreen=d.getter("isFullscreen"),this.requestFullscreenFp=et(!0),this.requestFullscreen=f(this.requestFullscreenFp),this.exitFullscreenFp=et(!1),this.exitFullscreen=f(this.exitFullscreenFp);const Fe=_.signal(!1);this.isCssVarsBound=_.computed(Fe),this.bindCssVarsFp=Xe(A=>{if(Fe())return L(new we);A||(A=T=>`--tg-viewport-${O.camelToKebab(T)}`);const se=[["height",this.height],["stableHeight",this.stableHeight],["width",this.width],["safeAreaInsetTop",this.safeAreaInsetTop],["safeAreaInsetBottom",this.safeAreaInsetBottom],["safeAreaInsetLeft",this.safeAreaInsetLeft],["safeAreaInsetRight",this.safeAreaInsetRight],["contentSafeAreaInsetTop",this.contentSafeAreaInsetTop],["contentSafeAreaInsetBottom",this.contentSafeAreaInsetBottom],["contentSafeAreaInsetLeft",this.contentSafeAreaInsetLeft],["contentSafeAreaInsetRight",this.contentSafeAreaInsetRight]].reduce((T,[Z,ee])=>{const N=A(Z);if(N){const tt=()=>{ze(N,`${ee()}px`)};T.push({update:tt,removeListener:ee.sub(tt),cssVar:N})}return T},[]);return se.forEach(T=>{T.update()}),Fe.set(!0),I(()=>{se.forEach(T=>{T.removeListener(),Ne(T.cssVar)}),Fe.set(!1)})}),this.bindCssVars=f(this.bindCssVarsFp),this.expandFp=Xe(()=>g("web_app_expand")),this.expand=f(this.expandFp)}}function _n(){const r=o=>({on:u=>{h.on(o,u)},off:u=>{h.off(o,u)}}),t=r("viewport_changed"),s=r("fullscreen_changed"),n=r("safe_area_changed"),i=r("content_safe_area_changed");return new or({...c(y(),re("viewport"),E,$,Q),isFullscreen(){return c(h.retrieveLaunchParamsFp(),H(o=>!!o.tgWebAppFullscreen))},isViewportStable(){return c(h.retrieveLaunchParamsFp(),H(o=>["macos","tdesktop","unigram","webk","weba","web"].includes(o.tgWebAppPlatform)))},offContentSafeAreaInsetsChanged:i.off,offFullscreenChanged:s.off,offSafeAreaInsetsChanged:n.off,offViewportChanged:t.off,onContentSafeAreaInsetsChanged:i.on,onFullscreenChanged:s.on,onSafeAreaInsetsChanged:n.on,onViewportChanged:t.on})}const gn=_n();function ir(r={}){const{version:t,isInlineMode:s,themeParams:n}=r;if(t&&typeof s=="boolean"&&n)Be.set(t),Ie.set(s),Pe.set(n);else{const a=c(h.retrieveLaunchParamsFp(),ct(l=>l,l=>{Be.set(t||l.tgWebAppVersion),Ie.set(typeof s=="boolean"?s:!!l.tgWebAppBotInline),Pe.set(n||l.tgWebAppThemeParams)}));if(a)return L(a)}r.postEvent&&wt.set(r.postEvent);const[i,o]=O.createCbCollector(h.on("reload_iframe",()=>{h.logger().log("Received a request to reload the page"),St("iframe_will_reload"),window.location.reload()})),{acceptCustomStyles:u=!0}=r;if(u){const a=document.createElement("style");a.id="telegram-custom-styles",document.head.appendChild(a),i(h.on("set_custom_style",l=>{a.innerHTML=l}),()=>{document.head.removeChild(a)})}return c(ue("iframe_ready",{reload_supported:!0}),H(()=>(h.logger().log("The package was initialized"),o)))}const Fn=O.throwifyFpFn(ir);Object.defineProperty(exports,"CancelledError",{enumerable:!0,get:()=>h.CancelledError});Object.defineProperty(exports,"InvalidLaunchParamsError",{enumerable:!0,get:()=>h.InvalidLaunchParamsError});Object.defineProperty(exports,"InvokeCustomMethodFailedError",{enumerable:!0,get:()=>h.InvokeCustomMethodFailedError});Object.defineProperty(exports,"LaunchParamsRetrieveError",{enumerable:!0,get:()=>h.LaunchParamsRetrieveError});Object.defineProperty(exports,"MethodParameterUnsupportedError",{enumerable:!0,get:()=>h.MethodParameterUnsupportedError});Object.defineProperty(exports,"MethodUnsupportedError",{enumerable:!0,get:()=>h.MethodUnsupportedError});Object.defineProperty(exports,"TimeoutError",{enumerable:!0,get:()=>h.TimeoutError});Object.defineProperty(exports,"UnknownEnvError",{enumerable:!0,get:()=>h.UnknownEnvError});Object.defineProperty(exports,"applyPolyfills",{enumerable:!0,get:()=>h.applyPolyfills});Object.defineProperty(exports,"createLogger",{enumerable:!0,get:()=>h.createLogger});Object.defineProperty(exports,"createPostEvent",{enumerable:!0,get:()=>h.createPostEvent});Object.defineProperty(exports,"createStartParam",{enumerable:!0,get:()=>h.createStartParam});Object.defineProperty(exports,"createStartParamFp",{enumerable:!0,get:()=>h.createStartParamFp});Object.defineProperty(exports,"debug",{enumerable:!0,get:()=>h.debug});Object.defineProperty(exports,"decodeBase64Url",{enumerable:!0,get:()=>h.decodeBase64Url});Object.defineProperty(exports,"decodeBase64UrlFp",{enumerable:!0,get:()=>h.decodeBase64UrlFp});Object.defineProperty(exports,"decodeStartParam",{enumerable:!0,get:()=>h.decodeStartParam});Object.defineProperty(exports,"decodeStartParamFp",{enumerable:!0,get:()=>h.decodeStartParamFp});Object.defineProperty(exports,"deepSnakeToCamelObjKeys",{enumerable:!0,get:()=>h.deepSnakeToCamelObjKeys});Object.defineProperty(exports,"encodeBase64Url",{enumerable:!0,get:()=>h.encodeBase64Url});Object.defineProperty(exports,"getReleaseVersion",{enumerable:!0,get:()=>h.getReleaseVersion});Object.defineProperty(exports,"isSafeToCreateStartParam",{enumerable:!0,get:()=>h.isSafeToCreateStartParam});Object.defineProperty(exports,"isTMA",{enumerable:!0,get:()=>h.isTMA});Object.defineProperty(exports,"isTMAFp",{enumerable:!0,get:()=>h.isTMAFp});Object.defineProperty(exports,"logger",{enumerable:!0,get:()=>h.logger});Object.defineProperty(exports,"mockTelegramEnv",{enumerable:!0,get:()=>h.mockTelegramEnv});Object.defineProperty(exports,"off",{enumerable:!0,get:()=>h.off});Object.defineProperty(exports,"offAll",{enumerable:!0,get:()=>h.offAll});Object.defineProperty(exports,"on",{enumerable:!0,get:()=>h.on});Object.defineProperty(exports,"retrieveLaunchParams",{enumerable:!0,get:()=>h.retrieveLaunchParams});Object.defineProperty(exports,"retrieveLaunchParamsFp",{enumerable:!0,get:()=>h.retrieveLaunchParamsFp});Object.defineProperty(exports,"retrieveRawInitData",{enumerable:!0,get:()=>h.retrieveRawInitData});Object.defineProperty(exports,"retrieveRawInitDataFp",{enumerable:!0,get:()=>h.retrieveRawInitDataFp});Object.defineProperty(exports,"retrieveRawLaunchParams",{enumerable:!0,get:()=>h.retrieveRawLaunchParams});Object.defineProperty(exports,"retrieveRawLaunchParamsFp",{enumerable:!0,get:()=>h.retrieveRawLaunchParamsFp});Object.defineProperty(exports,"setDebug",{enumerable:!0,get:()=>h.setDebug});Object.defineProperty(exports,"setTargetOrigin",{enumerable:!0,get:()=>h.setTargetOrigin});Object.defineProperty(exports,"supports",{enumerable:!0,get:()=>h.supports});Object.defineProperty(exports,"targetOrigin",{enumerable:!0,get:()=>h.targetOrigin});Object.defineProperty(exports,"isAnyRGB",{enumerable:!0,get:()=>q.isAnyRGB});Object.defineProperty(exports,"isRGB",{enumerable:!0,get:()=>q.isRGB});Object.defineProperty(exports,"isRGBA",{enumerable:!0,get:()=>q.isRGBA});Object.defineProperty(exports,"isRGBAShort",{enumerable:!0,get:()=>q.isRGBAShort});Object.defineProperty(exports,"isRGBShort",{enumerable:!0,get:()=>q.isRGBShort});Object.defineProperty(exports,"parseInitDataQuery",{enumerable:!0,get:()=>q.parseInitDataQuery});Object.defineProperty(exports,"parseInitDataQueryFp",{enumerable:!0,get:()=>q.parseInitDataQueryFp});Object.defineProperty(exports,"parseLaunchParamsQuery",{enumerable:!0,get:()=>q.parseLaunchParamsQuery});Object.defineProperty(exports,"parseLaunchParamsQueryFp",{enumerable:!0,get:()=>q.parseLaunchParamsQueryFp});Object.defineProperty(exports,"serializeInitDataQuery",{enumerable:!0,get:()=>q.serializeInitDataQuery});Object.defineProperty(exports,"serializeLaunchParamsQuery",{enumerable:!0,get:()=>q.serializeLaunchParamsQuery});Object.defineProperty(exports,"toRGB",{enumerable:!0,get:()=>q.toRGB});Object.defineProperty(exports,"toRGBFp",{enumerable:!0,get:()=>q.toRGBFp});Object.defineProperty(exports,"toRGBFull",{enumerable:!0,get:()=>q.toRGBFull});Object.defineProperty(exports,"toRGBFullFp",{enumerable:!0,get:()=>q.toRGBFullFp});exports.AccessDeniedError=De;exports.BackButton=Ct;exports.Biometry=vt;exports.CSSVarsBoundError=we;exports.ClosingBehavior=yt;exports.CloudStorage=kt;exports.ConcurrentCallError=Se;exports.FullscreenFailedError=_t;exports.FunctionUnavailableError=mt;exports.HapticFeedback=Pt;exports.InitData=xt;exports.InvalidArgumentsError=J;exports.InvalidEnvError=cs;exports.Invoice=Mt;exports.LocationManager=Ot;exports.MainButton=Vt;exports.MiniApp=Dt;exports.NotAvailableError=ft;exports.Popup=Gt;exports.QrScanner=Wt;exports.SecondaryButton=Kt;exports.SetEmojiStatusError=bt;exports.SettingsButton=zt;exports.ShareMessageError=gt;exports.SwipeBehavior=Nt;exports.ThemeParams=jt;exports.UnknownThemeParamsKeyError=Ft;exports.ValidationError=ce;exports.Viewport=or;exports.addToHomeScreen=ys;exports.addToHomeScreenFp=It;exports.backButton=ds;exports.biometry=ms;exports.checkHomeScreenStatus=Es;exports.checkHomeScreenStatusFp=qt;exports.closingBehavior=bs;exports.cloudStorage=_s;exports.copyTextToClipboard=Zs;exports.createRequestId=Qe;exports.downloadFile=en;exports.downloadFileFp=Jt;exports.getCurrentTime=rn;exports.getCurrentTimeFp=Yt;exports.hapticFeedback=Ss;exports.hideKeyboard=nn;exports.hideKeyboardFp=Zt;exports.init=Fn;exports.initData=As;exports.initFp=ir;exports.invoice=Bs;exports.invokeCustomMethod=Et;exports.isColorDark=Je;exports.isColorDarkFp=$t;exports.locationManager=Os;exports.mainButton=Vs;exports.miniApp=Ut;exports.openLink=Is;exports.openLinkFp=Tt;exports.openTelegramLink=xs;exports.openTelegramLinkFp=Ke;exports.popup=$s;exports.postEvent=St;exports.postEventFp=ue;exports.qrScanner=zs;exports.readTextFromClipboard=an;exports.readTextFromClipboardFp=Xt;exports.request=fs;exports.requestContact=Qs;exports.requestContactComplete=Hs;exports.requestContactCompleteFp=Ze;exports.requestContactFp=Ht;exports.requestEmojiStatusAccess=Fs;exports.requestEmojiStatusAccessFp=At;exports.requestFp=He;exports.requestPhoneAccess=Ds;exports.requestPhoneAccessFp=Ye;exports.requestWriteAccess=Ks;exports.requestWriteAccessFp=Qt;exports.retrieveAndroidDeviceData=un;exports.retrieveAndroidDeviceDataFrom=er;exports.secondaryButton=Ns;exports.sendData=pn;exports.sendDataFp=tr;exports.setEmojiStatus=ws;exports.setEmojiStatusFp=Bt;exports.settingsButton=Js;exports.shareMessage=hn;exports.shareMessageFp=rr;exports.shareStory=fn;exports.shareStoryFp=sr;exports.shareURL=Ts;exports.shareURLFp=Lt;exports.swipeBehavior=Ys;exports.switchInlineQuery=bn;exports.switchInlineQueryFp=nr;exports.themeParams=le;exports.viewport=gn;
|
|
1
|
+
"use strict";var cr=Object.defineProperty;var pr=(r,t,s)=>t in r?cr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s;var e=(r,t,s)=>pr(r,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("@tma.js/signals"),h=require("@tma.js/bridge"),O=require("@tma.js/toolkit"),lr=require("better-promises"),q=require("@tma.js/transformers"),K=require("error-kid"),k=require("valibot");var hr=function(r,t,s){if(s||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return r.concat(o||Array.prototype.slice.call(t))};function ot(r,t,s,n,i,o,u,a,l){switch(arguments.length){case 1:return r;case 2:return function(){return t(r.apply(this,arguments))};case 3:return function(){return s(t(r.apply(this,arguments)))};case 4:return function(){return n(s(t(r.apply(this,arguments))))};case 5:return function(){return i(n(s(t(r.apply(this,arguments)))))};case 6:return function(){return o(i(n(s(t(r.apply(this,arguments))))))};case 7:return function(){return u(o(i(n(s(t(r.apply(this,arguments)))))))};case 8:return function(){return a(u(o(i(n(s(t(r.apply(this,arguments))))))))};case 9:return function(){return l(a(u(o(i(n(s(t(r.apply(this,arguments)))))))))}}}function c(r,t,s,n,i,o,u,a,l){switch(arguments.length){case 1:return r;case 2:return t(r);case 3:return s(t(r));case 4:return n(s(t(r)));case 5:return i(n(s(t(r))));case 6:return o(i(n(s(t(r)))));case 7:return u(o(i(n(s(t(r))))));case 8:return a(u(o(i(n(s(t(r)))))));case 9:return l(a(u(o(i(n(s(t(r))))))));default:{for(var p=arguments[0],b=1;b<arguments.length;b++)p=arguments[b](p);return p}}}var he=function(r,t){var s=typeof r=="number"?function(n){return n.length>=r}:r;return function(){var n=Array.from(arguments);return s(arguments)?t.apply(this,n):function(i){return t.apply(void 0,hr([i],n,!1))}}},dr={_tag:"None"},fr=function(r){return{_tag:"Some",value:r}},mr=function(r){return r._tag==="Left"},it=function(r){return{_tag:"Left",left:r}},at=function(r){return{_tag:"Right",right:r}},qe={};function br(r,t){return function(s){return function(n){return r.ap(r.map(n,function(i){return function(o){return t.ap(i,o)}}),s)}}}function _r(r,t){return function(s){return function(n){return r.map(n,function(i){return t.map(i,s)})}}}function xe(r){return function(t,s){return function(n){return r.chain(n,function(i){return r.map(s(i),function(o){var u;return Object.assign({},i,(u={},u[t]=o,u))})})}}}var L=it,I=at,gr=he(2,function(r,t){return ne(r)?r:t(r.right)}),Me=function(r,t){return c(r,H(t))},ut=function(r,t){return c(r,Sr(t))},Te="Either",H=function(r){return function(t){return ne(t)?t:I(r(t.right))}},Fr={URI:Te,map:Me},Cr=I,wr=function(r){return function(t){return ne(t)?t:ne(r)?r:I(t.right(r.right))}},Sr=wr,vr={URI:Te,map:Me,ap:ut},yr={URI:Te,map:Me,ap:ut,chain:gr},kr=function(r,t){return function(s){return ne(s)?L(r(s.left)):I(t(s.right))}},ne=mr,ct=function(r,t){return function(s){return ne(s)?r(s.left):t(s.right)}},de=ct,Er=function(r,t){try{return I(r())}catch(s){return L(t(s))}},Ar=Cr(qe),Br=xe(yr),rt=Br;function D(r){return typeof r=="function"?r():r}function Y(r,t){return _.computed(()=>h.supports(r,D(t)))}var ie=dr,fe=fr,Pr=function(r,t){return c(r,xr(t))},Ir=function(r,t){return c(r,Tr(t))},qr="Option",xr=function(r){return function(t){return pe(t)?ie:fe(r(t.value))}},Mr=fe,Tr=function(r){return function(t){return pe(t)||pe(r)?ie:fe(t.value(r.value))}},Lr=he(2,function(r,t){return pe(r)?ie:t(r.value)}),Or={URI:qr,map:Pr,ap:Ir,chain:Lr},pe=function(r){return r._tag==="None"},Vr=function(r,t){return function(s){return pe(s)?r():t(s.value)}},pt=Vr,Rr=Mr(qe),st=xe(Or);function $r(r){return ot(I,r.of)}function jr(r){return ot(L,r.of)}function Dr(r){return _r(r,Fr)}function Ur(r){return br(r,vr)}function Gr(r){return function(t,s){return r.chain(t,function(n){return ne(n)?r.of(n):s(n.right)})}}function Hr(r){return function(t,s,n){return r.map(t,kr(s,n))}}function Qr(r){return function(t,s){return function(n){return r.map(n,de(t,s))}}}var Le=function(r,t){return c(r,Wr(t))},lt=function(r,t){return c(r,Kr(t))},Wr=function(r){return function(t){return function(){return Promise.resolve().then(t).then(r)}}},Kr=function(r){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(r)]).then(function(s){var n=s[0],i=s[1];return n(i)})}}},Oe=function(r){return function(){return Promise.resolve(r)}},zr=he(2,function(r,t){return function(){return Promise.resolve().then(r).then(function(s){return t(s)()})}}),Ve="Task",Re={URI:Ve,map:Le},ht={of:Oe},Nr={URI:Ve,map:Le,ap:lt},Jr={URI:Ve,map:Le,of:Oe,ap:lt,chain:zr},Yr=function(r,t,s,n){function i(o){return o instanceof s?o:new s(function(u){u(o)})}return new(s||(s=Promise))(function(o,u){function a(b){try{p(n.next(b))}catch(m){u(m)}}function l(b){try{p(n.throw(b))}catch(m){u(m)}}function p(b){b.done?o(b.value):i(b.value).then(a,l)}p((n=n.apply(r,t||[])).next())})},Zr=function(r,t){var s={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,u;return u={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(p){return function(b){return l([p,b])}}function l(p){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,p[0]&&(s=0)),s;)try{if(n=1,i&&(o=p[0]&2?i.return:p[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,p[1])).done)return o;switch(i=0,o&&(p=[p[0]&2,o.value]),p[0]){case 0:case 1:o=p;break;case 4:return s.label++,{value:p[1],done:!1};case 5:s.label++,i=p[1],p=[0];continue;case 7:p=s.ops.pop(),s.trys.pop();continue;default:if(o=s.trys,!(o=o.length>0&&o[o.length-1])&&(p[0]===6||p[0]===2)){s=0;continue}if(p[0]===3&&(!o||p[1]>o[0]&&p[1]<o[3])){s.label=p[1];break}if(p[0]===6&&s.label<o[1]){s.label=o[1],o=p;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(p);break}o[2]&&s.ops.pop(),s.trys.pop();continue}p=t.call(r,s)}catch(b){p=[6,b],i=0}finally{n=o=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},R=jr(ht),M=$r(ht),dt=Oe,Xr=Qr(Re),es=function(r,t){return function(){return Yr(void 0,void 0,void 0,function(){var s;return Zr(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,r().then(at)];case 1:return[2,n.sent()];case 2:return s=n.sent(),[2,it(t(s))];case 3:return[2]}})})}},ts=function(r,t){return c(r,x(t))},rs=function(r,t){return c(r,ss(t))},x=Dr(Re),$e=he(3,Hr(Re)),ss=Ur(Nr),je=he(2,Gr(Jr)),ns=M,os="TaskEither",is={URI:os,map:ts,ap:rs,chain:je},as=ns(qe),us=xe(is),Ce=us,X=je,ae=je;function oe(r){return[r]}class ce extends K.errorClassWithData("ValidationError",(t,s)=>({input:t,issues:s}),"Validation error"){}class we extends K.errorClass("CSSVarsBoundError","CSS variables are already bound"){}class ft extends K.errorClass("NotAvailableError",oe){}class cs extends K.errorClass("InvalidEnvError",oe){}class mt extends K.errorClass("FunctionNotAvailableError",oe){}class J extends K.errorClass("InvalidArgumentsError",(t,s)=>[t,{cause:s}]){}class Se extends K.errorClass("ConcurrentCallError",oe){}class bt extends K.errorClass("SetEmojiStatusError",t=>[`Failed to set emoji status: ${t}`]){}class De extends K.errorClass("AccessDeniedError",oe){}class _t extends K.errorClass("FullscreenFailedError",oe){}class gt extends K.errorClass("ShareMessageError",oe){}class Ft extends K.errorClass("UnknownThemeParamsKeyError",t=>[`Unknown theme params key passed: ${t}`]){}function P(r,t){const s=_.computed(()=>D(t.version)||"100"),n=_.computed(()=>D(t.isTma)),{requires:i}=t,o=i?typeof i=="object"?i:{every:[i]}:void 0,u=w=>{if(!t.supports)return!0;const F=t.supports[w];return h.supports(F.method,F.param,s())},a=()=>{if(!o)return;const[w,F]="every"in o?["every",o.every]:["some",o.some];for(let g=0;g<F.length;g++){const v=F[g],d=typeof v=="function"?v():h.supports(v,s())?void 0:`it is unsupported in Mini Apps version ${s()}`;if(d&&(w==="every"||g===F.length-1))return d}},l=(...w)=>{for(const F in t.supports)if(t.supports[F].shouldCheck(...w)&&!u(F))return`option ${F} is not supported in Mini Apps version ${s()}`},p=_.computed(()=>!a()),b=_.computed(()=>s()!=="0.0"),m=_.computed(()=>t.isMounted?t.isMounted():!0),C=_.computed(()=>n()&&b()&&p()&&m()),S=w=>{const F=new mt(w);return["task","promise"].includes(t.returns)?R(F):L(F)};return Object.assign((...w)=>{var V;const F="Unable to call function:";if(!n())return S(`${F} it can't be called outside Mini Apps`);if(!b())return S(`${F} the SDK was not initialized. Use the SDK init() function`);const g=a();if(g)return S(`${F} ${g}`);const v=l(...w);if(v)return S(`${F} ${v}`);if(!m()){const j=(V=t.isMounting)!=null&&V.call(t)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return S(`${F} the component is ${j}`)}const{returns:d}=t;return d==="plain"?Er(()=>r(...w),j=>j):d==="promise"?es(()=>r(...w),j=>j):r(...w)},r,{isAvailable:C,ifAvailable(...w){return C()?fe(r(...w)):ie}},o?{isSupported:p}:{},t.supports?{supports:u}:{})}function B(r){return t=>P(t,r)}function f(r){return Object.assign(O.throwifyFpFn(r),{ifAvailable(...t){return c(r.ifAvailable(...t),pt(()=>({ok:!1}),s=>({ok:!0,data:O.throwifyAnyEither(s)})))}})}function Ae(r){const t={};for(const s in r){const n=r[s];n!==void 0&&(t[s]=n)}return t}function ye(r,t){const s=Object.keys(r),n=Object.keys(t);return s.length!==n.length?!1:s.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&r[i]===t[i])}class te{constructor({initialState:t,onChange:s}){e(this,"_state");e(this,"state");e(this,"setState",t=>{const s={...this.state(),...Ae(t)};ye(s,this.state())||this._state.set(s)});this._state=_.signal(t,{equals:ye}),this.state=_.computed(this._state),this.state.sub(s)}getter(t){return _.computed(()=>this._state()[t])}hasDiff(t){return!ye({...this.state(),...Ae(t)},this.state())}}class me{constructor({onMounted:t,restoreState:s,initialState:n,onUnmounted:i,isPageReload:o}){e(this,"_isMounted",_.signal(!1));e(this,"isMounted",_.computed(this._isMounted));e(this,"mount");e(this,"unmount");this.mount=()=>{if(this.isMounted())return I(void 0);const u=D(o)?s():void 0,a=u?I(u):typeof n=="function"?n():I(n);return c(a,H(l=>{_.batch(()=>{this._isMounted.set(!0),t==null||t(l)})}))},this.unmount=()=>{this._isMounted()&&_.batch(()=>{this._isMounted.set(!1),i==null||i()})}}}class ve{constructor({isTma:t,storage:s,onClick:n,offClick:i,initialState:o,isPageReload:u,postEvent:a,payload:l,method:p,version:b}){e(this,"isMounted");e(this,"isSupported");e(this,"state");e(this,"stateSetters");e(this,"stateBoolSetters");e(this,"setStateFp");e(this,"setState");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const m=new te({initialState:o,onChange(g){s.set(g)}}),C=new me({initialState:o,isPageReload:u,onMounted:m.setState,restoreState:s.get}),S={version:b,requires:p,isTma:t},w=B({...S,returns:"plain"}),F=B({...S,returns:"either",isMounted:C.isMounted});this.isMounted=C.isMounted,this.isSupported=Y(p,b),this.state=m.state,this.setStateFp=F(g=>{const v={...this.state(),...Ae(g)};return m.hasDiff(v)?c(a(p,l(v)),H(()=>{m.setState(v)})):I(void 0)}),this.setState=f(this.setStateFp),this.onClickFp=w(n),this.onClick=f(this.onClickFp),this.offClickFp=w(i),this.offClick=f(this.offClickFp),this.mountFp=w(()=>{const g=()=>{};return c(C.mount(),de(g,g))}),this.mount=f(this.mountFp),this.unmount=C.unmount,this.stateSetters=g=>{const v=F(d=>this.setStateFp({[g]:d}));return[f(v),v]},this.stateBoolSetters=g=>{const[,v]=this.stateSetters(g),d=F(()=>v(!1)),V=F(()=>v(!0));return[[f(d),d],[f(V),V]]}}stateGetter(t){return _.computed(()=>this.state()[t])}}class Ct{constructor(t){e(this,"isVisible");e(this,"isMounted");e(this,"isSupported");e(this,"hideFp");e(this,"hide");e(this,"showFp");e(this,"show");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const s=new ve({...t,method:"web_app_setup_back_button",payload:n=>({is_visible:n.isVisible}),initialState:{isVisible:!1}});this.isVisible=s.stateGetter("isVisible"),this.isMounted=s.isMounted,this.isSupported=s.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=s.stateBoolSetters("isVisible"),this.onClick=s.onClick,this.onClickFp=s.onClickFp,this.offClick=s.offClick,this.offClickFp=s.offClickFp,this.mount=s.mount,this.mountFp=s.mountFp,this.unmount=s.unmount}}function y(){return{isTma:_.computed(()=>h.isTMAFp())}}function ps(r){return{get:()=>O.getStorageValue(r),set(t){O.setStorageValue(r,t)}}}function ls(){return performance.getEntriesByType("navigation")[0]}function hs(){const r=ls();return!!r&&r.type==="reload"}function be(r){return t=>({...t,...D(r)})}function re(r){return be({storage:ps(r),isPageReload:hs})}function _e(r,t){return _.signal(r,t)}const wt=_e(h.postEventFp),ue=(...r)=>wt()(...r),St=(...r)=>O.throwifyAnyEither(ue(...r)),$=be({postEvent:ue}),Be=_e("0.0"),E=be({version:Be});function Ue(r,t){return{...c(y(),$,E,re(r)),onClick(s,n){return h.on(t,s,n)},offClick(s,n){h.off(t,s,n)}}}const ds=new Ct(Ue("backButton","back_button_pressed"));class Ge{constructor({initialState:t,onMounted:s,restoreState:n,onUnmounted:i,isPageReload:o}){e(this,"_isMounted",_.signal(!1));e(this,"isMounted",_.computed(this._isMounted));e(this,"mount");e(this,"unmount");this.mount=u=>{if(this._isMounted())return M(void 0);const a=D(o)?n():void 0;return c(a?M(a):t(u),x(l=>{this._isMounted()||_.batch(()=>{this._isMounted.set(!0),s==null||s(l)})}))},this.unmount=()=>{this._isMounted()&&_.batch(()=>{this._isMounted.set(!1),i==null||i()})}}}const nt=new ft("Biometry is not available");function ke(r){let t=!1,s=!1,n="",i=!1,o="",u=!1;return r.available&&(t=!0,s=r.token_saved,n=r.device_id,i=r.access_requested,o=r.type,u=r.access_granted),{available:t,tokenSaved:s,deviceId:n,type:o,accessGranted:u,accessRequested:i}}class vt{constructor({version:t,request:s,postEvent:n,storage:i,onInfoReceived:o,offInfoReceived:u,isTma:a,isPageReload:l}){e(this,"isAvailable");e(this,"isSupported");e(this,"isMounted");e(this,"state");e(this,"authenticateFp");e(this,"authenticate");e(this,"openSettingsFp");e(this,"openSettings");e(this,"requestAccessFp");e(this,"requestAccess");e(this,"updateTokenFp");e(this,"updateToken");e(this,"mountFp");e(this,"mount");e(this,"unmount");const p=g=>{b.setState(ke(g))},b=new te({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:i.set}),m=new Ge({initialState(g){return c(s("web_app_biometry_get_info","biometry_info_received",g),x(ke))},isPageReload:l,onMounted(g){b.setState(g),o(p)},onUnmounted(){u(p)},restoreState:i.get}),C={version:t,requires:"web_app_biometry_request_auth",isTma:a},S=B({...C,returns:"either"}),w=B({...C,returns:"task"}),F=B({...C,isMounted:m.isMounted,returns:"task"});this.isAvailable=b.getter("available"),this.isMounted=m.isMounted,this.isSupported=Y("web_app_biometry_request_auth",t),this.state=b.state,this.unmount=m.unmount,this.mountFp=w(m.mount),this.authenticateFp=F(g=>this.isAvailable()?c(s("web_app_biometry_request_auth","biometry_auth_requested",{...g,params:{reason:((g||{}).reason||"").trim()}}),x(v=>(b.setState({token:v.token}),v))):R(nt)),this.openSettingsFp=S(()=>n("web_app_biometry_open_settings")),this.requestAccessFp=F(g=>c(s("web_app_biometry_request_access","biometry_info_received",{...g,params:{reason:((g||{}).reason||"").trim()}}),X(v=>{const d=ke(v);return d.available?(b.setState(d),M(d.accessRequested)):R(nt)}))),this.updateTokenFp=F((g={})=>{var v;return c(s("web_app_biometry_update_token","biometry_token_updated",{...g,params:{token:g.token||"",reason:(v=g.reason)==null?void 0:v.trim()}}),x(d=>d.status))}),this.authenticate=f(this.authenticateFp),this.openSettings=f(this.openSettingsFp),this.requestAccess=f(this.requestAccessFp),this.updateToken=f(this.updateTokenFp),this.mount=f(this.mountFp)}}const He=(r,t,s)=>h.requestFp(r,t,{postEvent:ue,...s}),fs=(...r)=>lr.BetterPromise.fn(()=>He(...r)()),Q=be({request:He}),ms=new vt({...c(y(),$,E,Q,re("biometry")),offInfoReceived(r){h.off("biometry_info_received",r)},onInfoReceived(r){return h.on("biometry_info_received",r)}});class yt{constructor({postEvent:t,storage:s,isTma:n,isPageReload:i}){e(this,"isConfirmationEnabled");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"disableConfirmationFp");e(this,"disableConfirmation");e(this,"enableConfirmationFp");e(this,"enableConfirmation");const o=new te({initialState:{isConfirmationEnabled:!1},onChange(m){s.set(m)}}),u=new me({onMounted:o.setState,restoreState:s.get,initialState:{isConfirmationEnabled:!1},isPageReload:i}),a={requires:"web_app_setup_closing_behavior",isTma:n},l=B({...a,returns:"plain"}),p=B({...a,returns:"either",isMounted:u.isMounted}),b=m=>m===this.isConfirmationEnabled()?I(void 0):(o.setState({isConfirmationEnabled:m}),t("web_app_setup_closing_behavior",{need_confirmation:m}));this.isConfirmationEnabled=o.getter("isConfirmationEnabled"),this.isMounted=u.isMounted,this.disableConfirmationFp=p(()=>b(!1)),this.enableConfirmationFp=p(()=>b(!0)),this.mountFp=l(()=>{const m=()=>{};return c(u.mount(),de(m,m))}),this.unmount=u.unmount,this.disableConfirmation=f(this.disableConfirmationFp),this.enableConfirmation=f(this.enableConfirmationFp),this.mount=f(this.mountFp)}}const bs=new yt(c(y(),re("closingBehavior"),$));class kt{constructor({version:t,isTma:s,invokeCustomMethod:n}){e(this,"isSupported");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"getItemFp");e(this,"getItem");e(this,"getItemsFp");e(this,"getItems");e(this,"getKeysFp");e(this,"getKeys");e(this,"setItemFp");e(this,"setItem");e(this,"clearFp");e(this,"clear");const i=B({version:t,requires:"web_app_invoke_custom_method",isTma:s,returns:"task"});this.isSupported=Y("web_app_invoke_custom_method",t),this.deleteItemFp=i((o,u)=>{const a=Array.isArray(o)?o:[o];return c(a.length?n("deleteStorageValues",{keys:a},u):M(void 0),x(()=>{}))}),this.getItemFp=i((o,u)=>c(this.getItemsFp([o],u),x(a=>a[o]||""))),this.getItemsFp=i((o,u)=>c(o.length?n("getStorageValues",{keys:o},u):M({}),x(a=>({...o.reduce((l,p)=>(l[p]="",l),{}),...k.parse(k.record(k.string(),k.string()),a)})))),this.getKeysFp=i(o=>c(n("getStorageKeys",{},o),x(u=>k.parse(k.array(k.string()),u)))),this.setItemFp=i((o,u,a)=>c(n("saveStorageValue",{key:o,value:u},a),x(()=>{}))),this.clearFp=i(o=>c(this.getKeysFp(o),X(this.deleteItemFp))),this.deleteItem=f(this.deleteItemFp),this.getItem=f(this.getItemFp),this.getItems=f(this.getItemsFp),this.getKeys=f(this.getKeysFp),this.setItem=f(this.setItemFp),this.clear=f(this.clearFp)}}const Ee=_e(0);function Qe(){return Ee.set(Ee()+1),Ee().toString()}function Et(r,t,s){return h.invokeCustomMethodFp(r,t,Qe(),{...s||{},postEvent:ue})}const We=be({invokeCustomMethod:Et}),_s=new kt(c(y(),E,We));function gs({request:r,...t}){return P(s=>c(r("web_app_request_emoji_status_access","emoji_status_access_requested",s),x(n=>n.status)),{...t,requires:"web_app_request_emoji_status_access",returns:"task"})}const At=gs(c(y(),E,Q)),Fs=f(At);function Cs({request:r,...t}){return P((s,n)=>c(r("web_app_set_emoji_status",["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:s,duration:(n||{}).duration},...n}),ae(i=>i&&"error"in i?R(new bt(i.error)):M(void 0))),{...t,requires:"web_app_set_emoji_status",returns:"task"})}const Bt=Cs(c(y(),Q,E)),ws=f(Bt);class Pt{constructor({postEvent:t,isTma:s,version:n}){e(this,"isSupported");e(this,"impactOccurredFp");e(this,"impactOccurred");e(this,"notificationOccurredFp");e(this,"notificationOccurred");e(this,"selectionChangedFp");e(this,"selectionChanged");const i="web_app_trigger_haptic_feedback",o=B({requires:i,isTma:s,version:n,returns:"plain"});this.isSupported=Y(i,n),this.impactOccurredFp=o(u=>t(i,{type:"impact",impact_style:u})),this.notificationOccurredFp=o(u=>t(i,{type:"notification",notification_type:u})),this.selectionChangedFp=o(()=>t(i,{type:"selection_change"})),this.impactOccurred=f(this.impactOccurredFp),this.notificationOccurred=f(this.notificationOccurredFp),this.selectionChanged=f(this.selectionChangedFp)}}const Ss=new Pt(c(y(),$,E));function vs({postEvent:r,...t}){return P(()=>r("web_app_add_to_home_screen"),{...t,requires:"web_app_add_to_home_screen",returns:"either"})}const It=vs(c(y(),E,$)),ys=f(It);function ks({request:r,...t}){return P(s=>c(r("web_app_check_home_screen","home_screen_checked",s),x(n=>n.status||"unknown")),{...t,requires:"web_app_check_home_screen",returns:"task"})}const qt=ks(c(y(),E,Q)),Es=f(qt);class xt{constructor({retrieveInitData:t}){e(this,"_state",_.signal());e(this,"_raw",_.signal());e(this,"state",_.computed(this._state));e(this,"authDate",this.fromState("auth_date"));e(this,"canSendAfter",this.fromState("can_send_after"));e(this,"canSendAfterDate",_.computed(()=>{const t=this.authDate(),s=this.canSendAfter();return s&&t?new Date(t.getTime()+s*1e3):void 0}));e(this,"chat",this.fromState("chat"));e(this,"chatType",this.fromState("chat_type"));e(this,"chatInstance",this.fromState("chat_instance"));e(this,"hash",this.fromState("hash"));e(this,"queryId",this.fromState("query_id"));e(this,"raw",_.computed(this._raw));e(this,"receiver",this.fromState("receiver"));e(this,"signature",this.fromState("signature"));e(this,"startParam",this.fromState("start_param"));e(this,"user",this.fromState("user"));e(this,"restoreFp");e(this,"restore");this.restoreFp=()=>c(t(),H(pt(()=>{},({raw:s,obj:n})=>{this._state.set(n),this._raw.set(s)}))),this.restore=O.throwifyFpFn(this.restoreFp)}fromState(t){return _.computed(()=>{const s=this._state();return s?s[t]:void 0})}}const As=new xt({retrieveInitData(){return c(Ar,rt("obj",()=>c(h.retrieveLaunchParamsFp(),H(({tgWebAppData:r})=>r?fe(r):ie))),rt("raw",h.retrieveRawInitDataFp),H(({obj:r,raw:t})=>c(Rr,st("obj",()=>r),st("raw",()=>t))))}});class Mt{constructor({version:t,request:s,isTma:n}){e(this,"isOpened");e(this,"isSupported");e(this,"openSlugFp");e(this,"openSlug");e(this,"openUrlFp");e(this,"openUrl");const i=B({version:t,isTma:n,requires:"web_app_open_invoice",returns:"task"}),o=_.signal(!1),u=()=>{o.set(!1)};this.isSupported=Y("web_app_open_invoice",t),this.isOpened=_.computed(o),this.openSlugFp=i((a,l)=>c(this.isOpened()?R(new Se("Invoice is already opened")):M(void 0),X(()=>(o.set(!0),s("web_app_open_invoice","invoice_closed",{...l,params:{slug:a},capture:p=>a===p.slug}))),$e(p=>(u(),p),p=>(u(),p.status)))),this.openUrlFp=i((a,l)=>{const{hostname:p,pathname:b}=new URL(a,window.location.href);if(p!=="t.me")return R(new J(`Link has unexpected hostname: ${p}`));const m=b.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return m?this.openSlugFp(m[2],l):R(new J('Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"'))}),this.openUrl=f(this.openUrlFp),this.openSlug=f(this.openSlugFp)}}const Bs=new Mt(c(y(),Q,E));function Ps({postEvent:r,...t}){return P((s,n={})=>{if(typeof s=="string")try{s=new URL(s)}catch(i){return L(new J(`"${s.toString()}" is invalid URL`,i))}return r("web_app_open_link",{url:s.toString(),try_browser:n.tryBrowser,try_instant_view:n.tryInstantView})},{...t,returns:"either"})}const Tt=Ps(c(y(),$)),Is=f(Tt);function qs({postEvent:r,version:t,...s}){return P(n=>{const i=n.toString();return i.match(/^https:\/\/t.me\/.+/)?h.supports("web_app_open_tg_link",D(t))?(n=new URL(n),r("web_app_open_tg_link",{path_full:n.pathname+n.search})):(window.location.href=i,I(void 0)):L(new J(`"${i}" is invalid URL`))},{...s,returns:"either"})}const Ke=qs(c(y(),$,E)),xs=f(Ke);function Ms({openTelegramLink:r,...t}){return P((s,n)=>r("https://t.me/share/url?"+new URLSearchParams({url:s,text:n||""}).toString().replace(/\+/g,"%20")),{...t,returns:"either"})}const Lt=Ms({...y(),openTelegramLink:Ke}),Ts=f(Lt);function Ls(r){let t=!1,s,n;return r.available&&(t=!0,s=r.access_requested,n=r.access_granted),{available:t,accessGranted:n||!1,accessRequested:s||!1}}class Ot{constructor({version:t,request:s,postEvent:n,storage:i,isTma:o,isPageReload:u}){e(this,"state");e(this,"isAvailable");e(this,"isAccessGranted");e(this,"isAccessRequested");e(this,"isMounted");e(this,"isSupported");e(this,"openSettingsFp");e(this,"openSettings");e(this,"requestLocationFp");e(this,"requestLocation");e(this,"mountFp");e(this,"mount");e(this,"unmount");const a=new te({initialState:{available:!1,accessGranted:!1,accessRequested:!1},onChange:i.set}),l=new Ge({isPageReload:u,restoreState:i.get,onMounted:a.setState,initialState(S){return c(s("web_app_check_location","location_checked",S),x(Ls))}}),p={version:t,requires:"web_app_check_location",isTma:o},b=B({...p,returns:"either"}),m=B({...p,returns:"task"}),C=B({...p,returns:"task",isMounted:l.isMounted});this.isAvailable=a.getter("available"),this.isAccessRequested=a.getter("accessRequested"),this.isAccessGranted=a.getter("accessGranted"),this.isSupported=Y("web_app_check_location",t),this.isMounted=l.isMounted,this.state=a.state,this.unmount=l.unmount,this.mountFp=m(l.mount),this.openSettingsFp=b(()=>n("web_app_open_location_settings")),this.requestLocationFp=C(S=>c(s("web_app_request_location","location_requested",S),x(w=>{if(!w.available)return a.setState({available:!1}),null;const{available:F,...g}=w;return g}))),this.mount=f(this.mountFp),this.openSettings=f(this.openSettingsFp),this.requestLocation=f(this.requestLocationFp)}}const Os=new Ot(c(y(),$,E,Q,re("locationManager")));class Vt{constructor({defaults:t,...s}){e(this,"bgColor");e(this,"hasShineEffect");e(this,"isEnabled");e(this,"isLoaderVisible");e(this,"isVisible");e(this,"isMounted");e(this,"state");e(this,"text");e(this,"textColor");e(this,"showFp");e(this,"show");e(this,"hideFp");e(this,"hide");e(this,"enableFp");e(this,"enable");e(this,"enableShineEffectFp");e(this,"enableShineEffect");e(this,"disableFp");e(this,"disable");e(this,"disableShineEffectFp");e(this,"disableShineEffect");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"setTextColorFp");e(this,"setTextColor");e(this,"setTextFp");e(this,"setText");e(this,"showLoaderFp");e(this,"showLoader");e(this,"hideLoaderFp");e(this,"hideLoader");e(this,"setParamsFp");e(this,"setParams");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");const n=new ve({...s,version:"100",initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"},method:"web_app_setup_main_button",payload:o=>({has_shine_effect:o.hasShineEffect,is_visible:o.isVisible,is_active:o.isEnabled,is_progress_visible:o.isLoaderVisible,text:o.text,color:o.bgColor,text_color:o.textColor})}),i=(o,u)=>{const a=n.stateGetter(o);return _.computed(()=>a()||D(u))};this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.hasShineEffect=n.stateGetter("hasShineEffect"),this.isEnabled=n.stateGetter("isEnabled"),this.isLoaderVisible=n.stateGetter("isLoaderVisible"),this.text=n.stateGetter("text"),this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.state=n.state,[this.setBgColor,this.setBgColorFp]=n.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=n.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=n.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=n.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=n.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=n.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.setParams=n.setState,this.setParamsFp=n.setStateFp,this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}function Rt(r,t,s){return c(Ue(r,t),n=>({...n,defaults:s}))}const Pe=_e({});function ze(r,t){document.documentElement.style.setProperty(r,t)}function Ne(r){document.documentElement.style.removeProperty(r)}function $t(r){return c(q.toRGBFullFp(r),H(t=>Math.sqrt([.299,.587,.114].reduce((s,n,i)=>{const o=parseInt(t.slice(1+i*2,1+(i+1)*2),16);return s+o*o*n},0))<120))}const Je=O.throwifyFpFn($t);class jt{constructor({initialState:t,onChange:s,offChange:n,isTma:i,storage:o,isPageReload:u}){e(this,"accentTextColor");e(this,"bgColor");e(this,"buttonColor");e(this,"buttonTextColor");e(this,"bottomBarBgColor");e(this,"destructiveTextColor");e(this,"headerBgColor");e(this,"hintColor");e(this,"linkColor");e(this,"secondaryBgColor");e(this,"sectionBgColor");e(this,"sectionHeaderTextColor");e(this,"sectionSeparatorColor");e(this,"subtitleTextColor");e(this,"textColor");e(this,"_isCssVarsBound",_.signal(!1));e(this,"isCssVarsBound",_.computed(this._isCssVarsBound));e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"state");e(this,"isDark",_.computed(()=>{const t=this.bgColor();return!t||Je(t)}));e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");const a=new te({initialState:{},onChange:o.set}),l=S=>{a.setState(S.theme_params)},p=new me({initialState:()=>I(D(t)),isPageReload:u,onMounted(S){a.setState(S),s(l)},onUnmounted(){n(l)},restoreState:o.get}),b={isTma:i,returns:"either"},m=B(b),C=B({...b,isMounted:p.isMounted});this.accentTextColor=a.getter("accent_text_color"),this.bgColor=a.getter("bg_color"),this.buttonColor=a.getter("button_color"),this.buttonTextColor=a.getter("button_text_color"),this.bottomBarBgColor=a.getter("bottom_bar_bg_color"),this.destructiveTextColor=a.getter("destructive_text_color"),this.headerBgColor=a.getter("header_bg_color"),this.hintColor=a.getter("hint_color"),this.linkColor=a.getter("link_color"),this.secondaryBgColor=a.getter("secondary_bg_color"),this.sectionBgColor=a.getter("section_bg_color"),this.sectionHeaderTextColor=a.getter("section_header_text_color"),this.sectionSeparatorColor=a.getter("section_separator_color"),this.subtitleTextColor=a.getter("subtitle_text_color"),this.textColor=a.getter("text_color"),this.state=a.state,this.isMounted=p.isMounted,this.bindCssVarsFp=C(S=>{if(this._isCssVarsBound())return L(new we);S||(S=g=>`--tg-theme-${O.snakeToKebab(g)}`);const w=g=>{Object.entries(a.state()).forEach(([v,d])=>{d&&g(v,d)})},F=()=>{w((g,v)=>{ze(S(g),v)})};return F(),a.state.sub(F),this._isCssVarsBound.set(!0),I(()=>{w(Ne),a.state.unsub(F),this._isCssVarsBound.set(!1)})}),this.mountFp=m(p.mount),this.unmount=p.unmount,this.bindCssVars=f(this.bindCssVarsFp),this.mount=f(this.mountFp)}}const le=new jt({...c(y(),re("themeParams")),offChange(r){h.off("theme_changed",r)},onChange(r){h.on("theme_changed",r)},initialState:Pe}),Vs=new Vt(Rt("mainButton","main_button_pressed",{bgColor:_.computed(()=>le.buttonColor()||"#2481cc"),textColor:_.computed(()=>le.buttonTextColor()||"#ffffff")}));class Dt{constructor({storage:t,isPageReload:s,version:n,postEvent:i,isTma:o,theme:u,onVisibilityChanged:a,offVisibilityChanged:l}){e(this,"isSupported");e(this,"isDark",_.computed(()=>{const t=this.bgColorRgb();return t?Je(t):!1}));e(this,"isActive");e(this,"state");e(this,"isCssVarsBound");e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"bgColor");e(this,"bgColorRgb");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"headerColor");e(this,"headerColorRgb");e(this,"setHeaderColorFp");e(this,"setHeaderColor");e(this,"bottomBarColor");e(this,"bottomBarColorRgb");e(this,"setBottomBarColorFp");e(this,"setBottomBarColor");e(this,"closeFp");e(this,"close");e(this,"readyFp");e(this,"ready");const p=d=>{C.setState({isActive:d.is_visible})},b=d=>{[[this.headerColor,"web_app_set_header_color"],[this.bgColor,"web_app_set_background_color"],[this.bottomBarColor,"web_app_set_bottom_bar_color"]].forEach(([V,j])=>{const U=V();if(!q.isRGB(U)&&(j==="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes(U))){const G=d[U];G&&i(j,{color:G})}})},m=new me({initialState(){const d=D(u);return I({bgColor:d.bg_color||"bg_color",headerColor:d.header_bg_color||"header_bg_color",bottomBarColor:d.bottom_bar_bg_color||"bottom_bar_bg_color",isActive:!0})},isPageReload:s,onMounted:d=>{this.setBgColorFp.ifAvailable(d.bgColor),this.setBottomBarColorFp.ifAvailable(d.bottomBarColor),this.setHeaderColorFp.ifAvailable(d.headerColor),a(p),u.sub(b),C.setState(d)},onUnmounted(){l(p),u.unsub(b)},restoreState:t.get});this.isMounted=m.isMounted,this.mountFp=P(()=>{const d=()=>{};return c(m.mount(),de(d,d))},{isTma:o,returns:"plain"}),this.mount=f(this.mountFp),this.unmount=m.unmount;const C=new te({initialState:{bgColor:"bg_color",bottomBarColor:"bottom_bar_bg_color",headerColor:"bg_color",isActive:!1},onChange:t.set});this.state=C.state;const S=d=>q.isRGB(d)?d:D(u)[d],w=d=>_.computed(()=>S(d()));this.isActive=C.getter("isActive"),this.isSupported=_.computed(()=>["web_app_set_header_color","web_app_set_background_color","web_app_set_bottom_bar_color"].some(d=>h.supports(d,D(n))));const F=_.signal(!1);this.isCssVarsBound=_.computed(F),this.bindCssVarsFp=P(d=>{if(F())return L(new we);const[V,j]=O.createCbCollector(()=>{F.set(!1)}),U=(G,W)=>{const z=()=>{ze(G,W()||null)};z(),V(W.sub(z),Ne.bind(null,G))};return d||(d=G=>`--tg-${O.camelToKebab(G)}`),U(d("bgColor"),this.bgColorRgb),U(d("bottomBarColor"),this.bottomBarColorRgb),U(d("headerColor"),this.headerColorRgb),F.set(!0),I(j)},{isTma:o,returns:"either",isMounted:this.isMounted}),this.bindCssVars=f(this.bindCssVarsFp);const g=d=>{const V=C.getter(d),j=w(V),U={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[d],G=P(W=>{if(W===V())return I(void 0);if(U==="web_app_set_header_color"&&(W==="bg_color"||W==="secondary_bg_color"))return i("web_app_set_header_color",{color_key:W});const z=S(W);return c(z?i(U,{color:z}):L(new Ft(W)),H(()=>{C.setState({[d]:z})}))},{isTma:o,version:n,requires:U,isMounted:this.isMounted,returns:"either",supports:d==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:q.isRGB}}:void 0});return[V,j,f(G),G]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=g("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=g("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=g("bottomBarColor");const v=B({isTma:o,returns:"either"});this.closeFp=v(d=>i("web_app_close",{return_back:d})),this.close=f(this.closeFp),this.readyFp=v(()=>i("web_app_ready")),this.ready=f(this.readyFp)}}const Ut=new Dt({...c(y(),$,E,re("miniApp")),offVisibilityChanged(r){h.off("visibility_changed",r)},onVisibilityChanged(r){h.on("visibility_changed",r)},theme:le.state});function Rs(r){const t=r.message.trim(),s=(r.title||"").trim(),n=r.buttons||[];if(s.length>64)return L(new J(`Invalid title: ${s}`));if(!t||t.length>256)return L(new J(`Invalid message: ${t}`));if(n.length>3)return L(new J(`Invalid buttons count: ${n.length}`));const i=[];if(!n.length)i.push({type:"close",id:""});else for(let o=0;o<n.length;o++){const u=n[o],a=u.id||"";if(a.length>64)return L(new J(`Button with index ${o} has invalid id: ${a}`));if(!u.type||u.type==="default"||u.type==="destructive"){const l=u.text.trim();if(!l||l.length>64)return L(new J(`Button with index ${o} has invalid text: ${l}`));i.push({type:u.type,text:l,id:a})}else i.push({type:u.type,id:a})}return I({title:s,message:t,buttons:i})}class Gt{constructor({version:t,isTma:s,request:n}){e(this,"isOpened");e(this,"isSupported");e(this,"showFp");e(this,"show");const i=_.signal(!1),o=()=>{i.set(!1)},u=B({version:t,isTma:s,requires:"web_app_open_popup",returns:"task"});this.isSupported=Y("web_app_open_popup",t),this.isOpened=_.computed(i),this.showFp=u(a=>c(this.isOpened()?R(new Se("A popup is already opened")):M(void 0),ae(()=>dt(Rs(a))),X(l=>(i.set(!0),n("web_app_open_popup","popup_closed",{...a,params:l}))),$e(l=>(o(),l),l=>(o(),l.button_id)))),this.show=f(this.showFp)}}const $s=new Gt(c(y(),Q,E));function js({request:r,...t}){return P(s=>c(r("web_app_request_phone","phone_requested",s),x(n=>n.status)),{...t,requires:"web_app_request_phone",returns:"task"})}const Ye=js(c(y(),E,Q)),Ds=f(Ye);function Us({invokeCustomMethod:r,requestPhoneAccess:t,...s}){const n=u=>c(r("getRequestedContact",{},{...u,timeout:(u||{}).timeout||5e3}),ae(a=>{const l=k.safeParse(k.string(),a);if(!l.success)return R(new ce(a,l.issues));if(!l.output)return M(void 0);const p=k.safeParse(q.pipeQueryToSchema(k.looseObject({contact:q.pipeJsonToSchema(k.looseObject({user_id:k.number(),phone_number:k.string(),first_name:k.string(),last_name:k.optional(k.string())})),auth_date:k.pipe(k.string(),k.transform(b=>new Date(Number(b)*1e3)),k.date()),hash:k.string()})),l.output);return p.success?M({raw:l.output,parsed:p.output}):R(new ce(l.output,p.issues))})),i=u=>c(n(u),Xr(a=>ce.is(a)?L(a):I(void 0),a=>I(a))),o=u=>O.BetterTaskEither(async(a,l,p)=>{let b=50;for(;!p.isRejected;){const m=await i(p)();if(m._tag==="Left")return l(m.left);if(m.right)return a(m.right);await new Promise(C=>setTimeout(C,b)),b+=50}},u);return P(u=>O.BetterTaskEither.fn(a=>c(i(a),X(l=>l?M(l):c(t(a),ae(p=>p==="sent"?o(a):R(new De("User denied access")))))),u),{...s,returns:"task",requires:"web_app_request_phone"})}function Gs({requestContact:r,...t}){return P(r,{...t,returns:"task",requires:"web_app_request_phone"})}const Ze=Us({...c(y(),We,E),requestPhoneAccess:Ye}),Hs=f(Ze),Ht=Gs({...c(y(),E),requestContact(r){return c(Ze(r),x(t=>t.parsed))}}),Qs=f(Ht);function Ws({request:r,...t}){return P(s=>c(r("web_app_request_write_access","write_access_requested",s),x(n=>n.status)),{...t,requires:"web_app_request_write_access",returns:"task"})}const Qt=Ws(c(y(),E,Q)),Ks=f(Qt);class Wt{constructor({version:t,onClosed:s,onTextReceived:n,isTma:i,postEvent:o}){e(this,"isOpened");e(this,"isSupported");e(this,"captureFp");e(this,"capture");e(this,"closeFp");e(this,"close");e(this,"openFp");e(this,"open");const u={version:t,requires:"web_app_open_scan_qr_popup",isTma:i},a=B({...u,returns:"either"}),l=B({...u,returns:"task"}),p=_.signal(!1),b=()=>{p.set(!1)};this.isSupported=Y("web_app_open_scan_qr_popup",t),this.isOpened=_.computed(p),this.captureFp=l(m=>{let C;return c(this.openFp({...m,onCaptured:S=>{m.capture(S)&&(C=S,this.close())}}),x(()=>C))}),this.closeFp=a(()=>c(o("web_app_close_scan_qr_popup"),H(b))),this.openFp=l(m=>c(this.isOpened()?R(new Se("The QR Scanner is already opened")):async()=>o("web_app_open_scan_qr_popup",{text:m.text}),ae(()=>{const[C,S]=O.createCbCollector(),w=F=>(S(),F);return c(O.BetterTaskEither(F=>{C(s(F),n(m.onCaptured))},m),$e(w,w))}))),this.open=f(this.openFp),this.capture=f(this.captureFp),this.close=f(this.closeFp)}}const zs=new Wt({...c(y(),$,E),onClosed(r){return h.on("scan_qr_popup_closed",r)},onTextReceived(r){return h.on("qr_text_received",t=>{r(t.data)})}});class Kt{constructor({defaults:t,...s}){e(this,"isSupported");e(this,"position");e(this,"bgColor");e(this,"hasShineEffect");e(this,"isEnabled");e(this,"isLoaderVisible");e(this,"isVisible");e(this,"isMounted");e(this,"state");e(this,"text");e(this,"textColor");e(this,"showFp");e(this,"show");e(this,"hideFp");e(this,"hide");e(this,"enableFp");e(this,"enable");e(this,"enableShineEffectFp");e(this,"enableShineEffect");e(this,"disableFp");e(this,"disable");e(this,"disableShineEffectFp");e(this,"disableShineEffect");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"setTextColorFp");e(this,"setTextColor");e(this,"setTextFp");e(this,"setText");e(this,"setPositionFp");e(this,"setPosition");e(this,"showLoaderFp");e(this,"showLoader");e(this,"hideLoaderFp");e(this,"hideLoader");e(this,"setParamsFp");e(this,"setParams");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");const n=new ve({...s,initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Cancel",position:"left"},method:"web_app_setup_secondary_button",payload:o=>({has_shine_effect:o.hasShineEffect,is_visible:o.isVisible,is_active:o.isEnabled,is_progress_visible:o.isLoaderVisible,text:o.text,color:o.bgColor,text_color:o.textColor,position:o.position})}),i=(o,u)=>{const a=n.stateGetter(o);return _.computed(()=>a()||D(u))};this.isSupported=Y("web_app_setup_secondary_button",s.version),this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.position=n.stateGetter("position"),this.hasShineEffect=n.stateGetter("hasShineEffect"),this.isEnabled=n.stateGetter("isEnabled"),this.isLoaderVisible=n.stateGetter("isLoaderVisible"),this.text=n.stateGetter("text"),this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.state=n.state,[this.setPosition,this.setPositionFp]=n.stateSetters("position"),[this.setBgColor,this.setBgColorFp]=n.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=n.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=n.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=n.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=n.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=n.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.setParams=n.setState,this.setParamsFp=n.setStateFp,this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}const Ns=new Kt(Rt("secondaryButton","secondary_button_pressed",{bgColor:_.computed(()=>Ut.bottomBarColorRgb()||"#000000"),textColor:_.computed(()=>le.buttonColor()||"#2481cc")}));class zt{constructor(t){e(this,"isVisible");e(this,"isMounted");e(this,"isSupported");e(this,"hideFp");e(this,"hide");e(this,"showFp");e(this,"show");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const s=new ve({...t,method:"web_app_setup_settings_button",payload:n=>({is_visible:n.isVisible}),initialState:{isVisible:!1}});this.isVisible=s.stateGetter("isVisible"),this.isMounted=s.isMounted,this.isSupported=s.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=s.stateBoolSetters("isVisible"),this.onClick=s.onClick,this.onClickFp=s.onClickFp,this.offClick=s.offClick,this.offClickFp=s.offClickFp,this.mount=s.mount,this.mountFp=s.mountFp,this.unmount=s.unmount}}const Js=new zt(Ue("settingsButton","settings_button_pressed"));class Nt{constructor({postEvent:t,storage:s,isTma:n,isPageReload:i,version:o}){e(this,"isSupported");e(this,"isVerticalEnabled");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"disableVerticalFp");e(this,"disableVertical");e(this,"enableVerticalFp");e(this,"enableVertical");const u=new te({initialState:{isVerticalEnabled:!1},onChange(C){s.set(C)}}),a=new me({initialState:{isVerticalEnabled:!1},isPageReload:i,onMounted:u.setState,restoreState:s.get}),l={requires:"web_app_setup_swipe_behavior",isTma:n,version:o},p=B({...l,returns:"plain"}),b=B({...l,isMounted:a.isMounted,returns:"either"}),m=C=>{const S={isVerticalEnabled:C};return u.hasDiff(S)?c(t("web_app_setup_swipe_behavior",{allow_vertical_swipe:C}),H(()=>{u.setState(S)})):I(void 0)};this.isSupported=Y("web_app_setup_swipe_behavior",o),this.isVerticalEnabled=u.getter("isVerticalEnabled"),this.isMounted=a.isMounted,this.disableVerticalFp=b(()=>m(!1)),this.enableVerticalFp=b(()=>m(!0)),this.mountFp=p(()=>{const C=()=>{};return c(a.mount(),de(C,C))}),this.unmount=a.unmount,this.disableVertical=f(this.disableVerticalFp),this.enableVertical=f(this.enableVerticalFp),this.mount=f(this.mountFp)}}const Ys=new Nt(c(y(),$,E,re("swipeBehavior")));async function Zs(r){try{const{clipboard:s}=navigator;if(s)return await s.writeText(r)}catch{}const t=document.createElement("textarea");t.value=r,t.style.top="0",t.style.left="0",t.style.position="fixed",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}finally{document.body.removeChild(t)}}function Xs({request:r,...t}){return P((s,n,i)=>c(r("web_app_request_file_download","file_download_requested",{...i,params:{url:s,file_name:n}}),X(o=>o.status==="downloading"?M(void 0):R(new De("User denied the action")))),{...t,requires:"web_app_request_file_download",returns:"task"})}const Jt=Xs(c(y(),Q,E)),en=f(Jt);function tn({invokeCustomMethod:r,...t}){return P(s=>c(r("getCurrentTime",{},s),X(n=>{const i=k.safeParse(k.pipe(k.number(),k.integer(),k.transform(o=>new Date(o*1e3)),k.date()),n);return i.success?M(i.output):R(new ce(n,i.issues))})),{...t,requires:"web_app_invoke_custom_method",returns:"task"})}const Yt=tn(c(y(),We,E)),rn=f(Yt);function sn({postEvent:r,...t}){return P(()=>r("web_app_hide_keyboard"),{...t,returns:"either",requires:"web_app_hide_keyboard"})}const Zt=sn(c(y(),$,E)),nn=f(Zt);function on({request:r,createRequestId:t,...s}){return P(n=>{const i=t();return c(r("web_app_read_text_from_clipboard","clipboard_text_received",{...n,params:{req_id:i},capture:h.captureSameReq(i)}),x(({data:o=null})=>o))},{...s,requires:"web_app_read_text_from_clipboard",returns:"task"})}const Xt=on({...c(y(),E,Q),createRequestId:Qe}),an=f(Xt);function er(r){const t={},s=r.match(/Telegram-Android(?:\/([^ ]+))?(?: (\([^)]+\))?|$)/);if(s){const[,n,i]=s;n&&(t.appVersion=n),i&&i.slice(1,i.length-1).split(";").forEach(o=>{const[u,a]=o.trim().split(" ");if(u==="Android")t.androidVersion=a;else if(u==="SDK"){const l=parseInt(a,10);l&&(t.sdkVersion=l)}else a?(t.manufacturer=u,t.model=a):t.performanceClass=u})}return t}function un(){return er(navigator.userAgent)}function cn({postEvent:r,...t}){return P(s=>{const{size:n}=new Blob([s]);return!n||n>4096?L(new J(n?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data")):r("web_app_data_send",{data:s})},{...t,returns:"either"})}const tr=cn(c(y(),$)),pn=f(tr);function ln({request:r,...t}){return P((s,n)=>c(r("web_app_send_prepared_message",["prepared_message_failed","prepared_message_sent"],{...n,params:{id:s}}),X(i=>i&&"error"in i?R(new gt(i.error)):M(void 0))),{...t,requires:"web_app_send_prepared_message",returns:"task"})}const rr=ln(c(y(),Q,E)),hn=f(rr);function dn({postEvent:r,...t}){return P((s,n={})=>r("web_app_share_to_story",{text:n.text,media_url:s,widget_link:n.widgetLink}),{...t,requires:"web_app_share_to_story",returns:"either"})}const sr=dn(c(y(),$,E)),fn=f(sr),Ie=_e(!1);function mn({isInlineMode:r,postEvent:t,...s}){return P((n,i)=>t("web_app_switch_inline_query",{query:n,chat_types:i||[]}),{...s,requires:{every:["web_app_switch_inline_query",()=>D(r)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}const nr=mn({...c(y(),$,E),isInlineMode:Ie}),bn=f(nr);class or{constructor({storage:t,isPageReload:s,onContentSafeAreaInsetsChanged:n,onSafeAreaInsetsChanged:i,onViewportChanged:o,onFullscreenChanged:u,offContentSafeAreaInsetsChanged:a,offFullscreenChanged:l,offSafeAreaInsetsChanged:p,offViewportChanged:b,request:m,isViewportStable:C,isFullscreen:S,isTma:w,version:F,postEvent:g}){e(this,"state");e(this,"height");e(this,"stableHeight");e(this,"width");e(this,"isExpanded");e(this,"isStable",_.computed(()=>this.height()===this.stableHeight()));e(this,"contentSafeAreaInsets");e(this,"contentSafeAreaInsetTop");e(this,"contentSafeAreaInsetLeft");e(this,"contentSafeAreaInsetRight");e(this,"contentSafeAreaInsetBottom");e(this,"safeAreaInsets");e(this,"safeAreaInsetTop");e(this,"safeAreaInsetLeft");e(this,"safeAreaInsetRight");e(this,"safeAreaInsetBottom");e(this,"isFullscreen");e(this,"requestFullscreenFp");e(this,"requestFullscreen");e(this,"exitFullscreenFp");e(this,"exitFullscreen");e(this,"isCssVarsBound");e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"expandFp");e(this,"expand");const v={top:0,right:0,left:0,bottom:0},d=new te({initialState:{contentSafeAreaInsets:v,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:v,stableHeight:0,width:0},onChange:t.set}),V=A=>{d.setState({isExpanded:A.is_expanded,height:A.height,width:A.width,stableHeight:A.is_state_stable?A.height:void 0})},j=A=>{d.setState({isFullscreen:A.is_fullscreen})},U=A=>{d.setState({safeAreaInsets:A})},G=A=>{d.setState({contentSafeAreaInsets:A})},W=new Ge({initialState(A){const se=Z=>()=>{const[ee,N]=Z==="safe-area"?["web_app_request_safe_area","safe_area_changed"]:["web_app_request_content_safe_area","content_safe_area_changed"];return h.supports(ee,D(F))?m(ee,N,A):M({top:0,left:0,right:0,bottom:0})},T=Z=>()=>typeof Z=="boolean"?M(Z):dt(Z());return c(as,Ce("safeAreaInsets",se("safe-area")),Ce("contentSafeAreaInsets",se("content-safe-area")),Ce("isFullscreen",T(S)),Ce("isViewportStable",T(C)),ae(({isViewportStable:Z,...ee})=>Z?M({...ee,height:window.innerHeight,isExpanded:!0,stableHeight:window.innerHeight,width:window.innerWidth}):c(m("web_app_request_viewport","viewport_changed",A),x(N=>({...ee,height:N.height,isExpanded:N.is_expanded,stableHeight:N.is_state_stable?N.height:0,width:N.width})))))},isPageReload:s,onMounted(A){o(V),u(j),i(U),n(G),d.setState(A)},onUnmounted(){b(V),l(j),p(U),a(G)},restoreState:t.get}),z=A=>_.computed(()=>this.safeAreaInsets()[A]),ge=A=>_.computed(()=>this.contentSafeAreaInsets()[A]);this.state=d.state,this.height=d.getter("height"),this.stableHeight=d.getter("stableHeight"),this.width=d.getter("width"),this.isExpanded=d.getter("isExpanded"),this.safeAreaInsets=d.getter("safeAreaInsets"),this.safeAreaInsetTop=z("top"),this.safeAreaInsetBottom=z("bottom"),this.safeAreaInsetLeft=z("left"),this.safeAreaInsetRight=z("right"),this.contentSafeAreaInsets=d.getter("contentSafeAreaInsets"),this.contentSafeAreaInsetTop=ge("top"),this.contentSafeAreaInsetBottom=ge("bottom"),this.contentSafeAreaInsetLeft=ge("left"),this.contentSafeAreaInsetRight=ge("right");const ar=B({isTma:w,returns:"task"}),Xe=B({isTma:w,returns:"either"}),ur=B({isTma:w,requires:"web_app_request_fullscreen",version:F,returns:"task"}),et=A=>ur(se=>c(m(A?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],se),X(T=>"error"in T&&T.error!=="ALREADY_FULLSCREEN"?R(new _t(T.error)):(d.setState({isFullscreen:"is_fullscreen"in T?T.is_fullscreen:!0}),M(void 0)))));this.isMounted=W.isMounted,this.mountFp=ar(W.mount),this.mount=f(this.mountFp),this.isFullscreen=d.getter("isFullscreen"),this.requestFullscreenFp=et(!0),this.requestFullscreen=f(this.requestFullscreenFp),this.exitFullscreenFp=et(!1),this.exitFullscreen=f(this.exitFullscreenFp);const Fe=_.signal(!1);this.isCssVarsBound=_.computed(Fe),this.bindCssVarsFp=Xe(A=>{if(Fe())return L(new we);A||(A=T=>`--tg-viewport-${O.camelToKebab(T)}`);const se=[["height",this.height],["stableHeight",this.stableHeight],["width",this.width],["safeAreaInsetTop",this.safeAreaInsetTop],["safeAreaInsetBottom",this.safeAreaInsetBottom],["safeAreaInsetLeft",this.safeAreaInsetLeft],["safeAreaInsetRight",this.safeAreaInsetRight],["contentSafeAreaInsetTop",this.contentSafeAreaInsetTop],["contentSafeAreaInsetBottom",this.contentSafeAreaInsetBottom],["contentSafeAreaInsetLeft",this.contentSafeAreaInsetLeft],["contentSafeAreaInsetRight",this.contentSafeAreaInsetRight]].reduce((T,[Z,ee])=>{const N=A(Z);if(N){const tt=()=>{ze(N,`${ee()}px`)};T.push({update:tt,removeListener:ee.sub(tt),cssVar:N})}return T},[]);return se.forEach(T=>{T.update()}),Fe.set(!0),I(()=>{se.forEach(T=>{T.removeListener(),Ne(T.cssVar)}),Fe.set(!1)})}),this.bindCssVars=f(this.bindCssVarsFp),this.expandFp=Xe(()=>g("web_app_expand")),this.expand=f(this.expandFp)}}function _n(){const r=o=>({on:u=>{h.on(o,u)},off:u=>{h.off(o,u)}}),t=r("viewport_changed"),s=r("fullscreen_changed"),n=r("safe_area_changed"),i=r("content_safe_area_changed");return new or({...c(y(),re("viewport"),E,$,Q),isFullscreen(){return c(h.retrieveLaunchParamsFp(),H(o=>!!o.tgWebAppFullscreen))},isViewportStable(){return c(h.retrieveLaunchParamsFp(),H(o=>["macos","tdesktop","unigram","webk","weba","web"].includes(o.tgWebAppPlatform)))},offContentSafeAreaInsetsChanged:i.off,offFullscreenChanged:s.off,offSafeAreaInsetsChanged:n.off,offViewportChanged:t.off,onContentSafeAreaInsetsChanged:i.on,onFullscreenChanged:s.on,onSafeAreaInsetsChanged:n.on,onViewportChanged:t.on})}const gn=_n();function ir(r={}){const{version:t,isInlineMode:s,themeParams:n}=r;if(t&&typeof s=="boolean"&&n)Be.set(t),Ie.set(s),Pe.set(n);else{const a=c(h.retrieveLaunchParamsFp(),ct(l=>l,l=>{Be.set(t||l.tgWebAppVersion),Ie.set(typeof s=="boolean"?s:!!l.tgWebAppBotInline),Pe.set(n||l.tgWebAppThemeParams)}));if(a)return L(a)}r.postEvent&&wt.set(r.postEvent);const[i,o]=O.createCbCollector(h.on("reload_iframe",()=>{h.logger().log("Received a request to reload the page"),St("iframe_will_reload"),window.location.reload()})),{acceptCustomStyles:u=!0}=r;if(u){const a=document.createElement("style");a.id="telegram-custom-styles",document.head.appendChild(a),i(h.on("set_custom_style",l=>{a.innerHTML=l}),()=>{document.head.removeChild(a)})}return c(ue("iframe_ready",{reload_supported:!0}),H(()=>(h.logger().log("The package was initialized"),o)))}const Fn=O.throwifyFpFn(ir);Object.defineProperty(exports,"CancelledError",{enumerable:!0,get:()=>h.CancelledError});Object.defineProperty(exports,"InvalidLaunchParamsError",{enumerable:!0,get:()=>h.InvalidLaunchParamsError});Object.defineProperty(exports,"InvokeCustomMethodFailedError",{enumerable:!0,get:()=>h.InvokeCustomMethodFailedError});Object.defineProperty(exports,"LaunchParamsRetrieveError",{enumerable:!0,get:()=>h.LaunchParamsRetrieveError});Object.defineProperty(exports,"MethodParameterUnsupportedError",{enumerable:!0,get:()=>h.MethodParameterUnsupportedError});Object.defineProperty(exports,"MethodUnsupportedError",{enumerable:!0,get:()=>h.MethodUnsupportedError});Object.defineProperty(exports,"TimeoutError",{enumerable:!0,get:()=>h.TimeoutError});Object.defineProperty(exports,"UnknownEnvError",{enumerable:!0,get:()=>h.UnknownEnvError});Object.defineProperty(exports,"applyPolyfills",{enumerable:!0,get:()=>h.applyPolyfills});Object.defineProperty(exports,"createLogger",{enumerable:!0,get:()=>h.createLogger});Object.defineProperty(exports,"createPostEvent",{enumerable:!0,get:()=>h.createPostEvent});Object.defineProperty(exports,"createStartParam",{enumerable:!0,get:()=>h.createStartParam});Object.defineProperty(exports,"createStartParamFp",{enumerable:!0,get:()=>h.createStartParamFp});Object.defineProperty(exports,"debug",{enumerable:!0,get:()=>h.debug});Object.defineProperty(exports,"decodeBase64Url",{enumerable:!0,get:()=>h.decodeBase64Url});Object.defineProperty(exports,"decodeBase64UrlFp",{enumerable:!0,get:()=>h.decodeBase64UrlFp});Object.defineProperty(exports,"decodeStartParam",{enumerable:!0,get:()=>h.decodeStartParam});Object.defineProperty(exports,"decodeStartParamFp",{enumerable:!0,get:()=>h.decodeStartParamFp});Object.defineProperty(exports,"deepSnakeToCamelObjKeys",{enumerable:!0,get:()=>h.deepSnakeToCamelObjKeys});Object.defineProperty(exports,"emitEvent",{enumerable:!0,get:()=>h.emitEvent});Object.defineProperty(exports,"encodeBase64Url",{enumerable:!0,get:()=>h.encodeBase64Url});Object.defineProperty(exports,"getReleaseVersion",{enumerable:!0,get:()=>h.getReleaseVersion});Object.defineProperty(exports,"isSafeToCreateStartParam",{enumerable:!0,get:()=>h.isSafeToCreateStartParam});Object.defineProperty(exports,"isTMA",{enumerable:!0,get:()=>h.isTMA});Object.defineProperty(exports,"isTMAFp",{enumerable:!0,get:()=>h.isTMAFp});Object.defineProperty(exports,"logger",{enumerable:!0,get:()=>h.logger});Object.defineProperty(exports,"mockTelegramEnv",{enumerable:!0,get:()=>h.mockTelegramEnv});Object.defineProperty(exports,"off",{enumerable:!0,get:()=>h.off});Object.defineProperty(exports,"offAll",{enumerable:!0,get:()=>h.offAll});Object.defineProperty(exports,"on",{enumerable:!0,get:()=>h.on});Object.defineProperty(exports,"retrieveLaunchParams",{enumerable:!0,get:()=>h.retrieveLaunchParams});Object.defineProperty(exports,"retrieveLaunchParamsFp",{enumerable:!0,get:()=>h.retrieveLaunchParamsFp});Object.defineProperty(exports,"retrieveRawInitData",{enumerable:!0,get:()=>h.retrieveRawInitData});Object.defineProperty(exports,"retrieveRawInitDataFp",{enumerable:!0,get:()=>h.retrieveRawInitDataFp});Object.defineProperty(exports,"retrieveRawLaunchParams",{enumerable:!0,get:()=>h.retrieveRawLaunchParams});Object.defineProperty(exports,"retrieveRawLaunchParamsFp",{enumerable:!0,get:()=>h.retrieveRawLaunchParamsFp});Object.defineProperty(exports,"setDebug",{enumerable:!0,get:()=>h.setDebug});Object.defineProperty(exports,"setTargetOrigin",{enumerable:!0,get:()=>h.setTargetOrigin});Object.defineProperty(exports,"supports",{enumerable:!0,get:()=>h.supports});Object.defineProperty(exports,"targetOrigin",{enumerable:!0,get:()=>h.targetOrigin});Object.defineProperty(exports,"isAnyRGB",{enumerable:!0,get:()=>q.isAnyRGB});Object.defineProperty(exports,"isRGB",{enumerable:!0,get:()=>q.isRGB});Object.defineProperty(exports,"isRGBA",{enumerable:!0,get:()=>q.isRGBA});Object.defineProperty(exports,"isRGBAShort",{enumerable:!0,get:()=>q.isRGBAShort});Object.defineProperty(exports,"isRGBShort",{enumerable:!0,get:()=>q.isRGBShort});Object.defineProperty(exports,"parseInitDataQuery",{enumerable:!0,get:()=>q.parseInitDataQuery});Object.defineProperty(exports,"parseInitDataQueryFp",{enumerable:!0,get:()=>q.parseInitDataQueryFp});Object.defineProperty(exports,"parseLaunchParamsQuery",{enumerable:!0,get:()=>q.parseLaunchParamsQuery});Object.defineProperty(exports,"parseLaunchParamsQueryFp",{enumerable:!0,get:()=>q.parseLaunchParamsQueryFp});Object.defineProperty(exports,"serializeInitDataQuery",{enumerable:!0,get:()=>q.serializeInitDataQuery});Object.defineProperty(exports,"serializeLaunchParamsQuery",{enumerable:!0,get:()=>q.serializeLaunchParamsQuery});Object.defineProperty(exports,"toRGB",{enumerable:!0,get:()=>q.toRGB});Object.defineProperty(exports,"toRGBFp",{enumerable:!0,get:()=>q.toRGBFp});Object.defineProperty(exports,"toRGBFull",{enumerable:!0,get:()=>q.toRGBFull});Object.defineProperty(exports,"toRGBFullFp",{enumerable:!0,get:()=>q.toRGBFullFp});exports.AccessDeniedError=De;exports.BackButton=Ct;exports.Biometry=vt;exports.CSSVarsBoundError=we;exports.ClosingBehavior=yt;exports.CloudStorage=kt;exports.ConcurrentCallError=Se;exports.FullscreenFailedError=_t;exports.FunctionUnavailableError=mt;exports.HapticFeedback=Pt;exports.InitData=xt;exports.InvalidArgumentsError=J;exports.InvalidEnvError=cs;exports.Invoice=Mt;exports.LocationManager=Ot;exports.MainButton=Vt;exports.MiniApp=Dt;exports.NotAvailableError=ft;exports.Popup=Gt;exports.QrScanner=Wt;exports.SecondaryButton=Kt;exports.SetEmojiStatusError=bt;exports.SettingsButton=zt;exports.ShareMessageError=gt;exports.SwipeBehavior=Nt;exports.ThemeParams=jt;exports.UnknownThemeParamsKeyError=Ft;exports.ValidationError=ce;exports.Viewport=or;exports.addToHomeScreen=ys;exports.addToHomeScreenFp=It;exports.backButton=ds;exports.biometry=ms;exports.checkHomeScreenStatus=Es;exports.checkHomeScreenStatusFp=qt;exports.closingBehavior=bs;exports.cloudStorage=_s;exports.copyTextToClipboard=Zs;exports.createRequestId=Qe;exports.downloadFile=en;exports.downloadFileFp=Jt;exports.getCurrentTime=rn;exports.getCurrentTimeFp=Yt;exports.hapticFeedback=Ss;exports.hideKeyboard=nn;exports.hideKeyboardFp=Zt;exports.init=Fn;exports.initData=As;exports.initFp=ir;exports.invoice=Bs;exports.invokeCustomMethod=Et;exports.isColorDark=Je;exports.isColorDarkFp=$t;exports.locationManager=Os;exports.mainButton=Vs;exports.miniApp=Ut;exports.openLink=Is;exports.openLinkFp=Tt;exports.openTelegramLink=xs;exports.openTelegramLinkFp=Ke;exports.popup=$s;exports.postEvent=St;exports.postEventFp=ue;exports.qrScanner=zs;exports.readTextFromClipboard=an;exports.readTextFromClipboardFp=Xt;exports.request=fs;exports.requestContact=Qs;exports.requestContactComplete=Hs;exports.requestContactCompleteFp=Ze;exports.requestContactFp=Ht;exports.requestEmojiStatusAccess=Fs;exports.requestEmojiStatusAccessFp=At;exports.requestFp=He;exports.requestPhoneAccess=Ds;exports.requestPhoneAccessFp=Ye;exports.requestWriteAccess=Ks;exports.requestWriteAccessFp=Qt;exports.retrieveAndroidDeviceData=un;exports.retrieveAndroidDeviceDataFrom=er;exports.secondaryButton=Ns;exports.sendData=pn;exports.sendDataFp=tr;exports.setEmojiStatus=ws;exports.setEmojiStatusFp=Bt;exports.settingsButton=Js;exports.shareMessage=hn;exports.shareMessageFp=rr;exports.shareStory=fn;exports.shareStoryFp=sr;exports.shareURL=Ts;exports.shareURLFp=Lt;exports.swipeBehavior=Ys;exports.switchInlineQuery=bn;exports.switchInlineQueryFp=nr;exports.themeParams=le;exports.viewport=gn;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var cc=Object.defineProperty;var lc=(p,oe,we)=>oe in p?cc(p,oe,{enumerable:!0,configurable:!0,writable:!0,value:we}):p[oe]=we;var o=(p,oe,we)=>lc(p,typeof oe!="symbol"?oe+"":oe,we);this.tmajs=this.tmajs||{};this.tmajs.sdk=function(p){"use strict";var oe=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function we(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function d(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Ve=function(e,t){var n=typeof e=="number"?function(r){return r.length>=e}:e;return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,oe([i],r,!1))}}},Js={_tag:"None"},Qs=function(e){return{_tag:"Some",value:e}},Zs=function(e){return e._tag==="Left"},kn=function(e){return{_tag:"Left",left:e}},En=function(e){return{_tag:"Right",right:e}},dt={};function Ys(e,t){return function(n){return function(r){return e.ap(e.map(r,function(i){return function(s){return t.ap(i,s)}}),n)}}}function Xs(e,t){return function(n){return function(r){return e.map(r,function(i){return t.map(i,n)})}}}function _t(e){return function(t,n){return function(r){return e.chain(r,function(i){return e.map(n(i),function(s){var a;return Object.assign({},i,(a={},a[t]=s,a))})})}}}var O=kn,P=En,ei=Ve(2,function(e,t){return ye(e)?e:t(e.right)}),mt=function(e,t){return d(e,Z(t))},$n=function(e,t){return d(e,si(t))},bt="Either",Z=function(e){return function(t){return ye(t)?t:P(e(t.right))}},ti={URI:bt,map:mt},ni=P,ri=function(e){return function(t){return ye(t)?t:ye(e)?e:P(t.right(e.right))}},si=ri,ii={URI:bt,map:mt,ap:$n},oi={URI:bt,map:mt,ap:$n,chain:ei},ai=function(e,t){return function(n){return ye(n)?O(e(n.left)):P(t(n.right))}},ye=Zs,An=function(e,t){return function(n){return ye(n)?e(n.left):t(n.right)}},Re=An,ui=function(e,t){try{return P(e())}catch(n){return O(t(n))}},ci=ni(dt),li=_t(oi),In=li;let Ae;function pi(e,t){Ae?Ae.set(e,t):t()}function Xe(e){if(Ae)return e();Ae=new Map;try{e()}finally{Ae.forEach(t=>t()),Ae=void 0}}function W(e,t){t||(t={});const n=t.equals||Object.is;let r=[],i=e;const s=c=>{if(!n(i,c)){const h=i;i=c,pi(l,()=>{[...r].forEach(([f,b])=>{f(c,h),b&&u(f,!0)})})}};function a(c){const h=typeof c!="object"?{once:c}:c;return{once:h.once||!1,signal:h.signal||!1}}const u=(c,h)=>{const f=a(h),b=r.findIndex(([v,y])=>v===c&&y.once===f.once&&y.signal===f.signal);b>=0&&r.splice(b,1)},l=Object.assign(function(){return hi(l),i},{destroy(){r=[]},set:s,reset(){s(e)},sub(c,h){return r.push([c,a(h)]),()=>u(c,h)},unsub:u,unsubAll(){r=r.filter(c=>c[1].signal)}});return l}const Oe=[];function hi(e){Oe.length&&Oe[Oe.length-1].add(e)}function F(e,t){let n=new Set,r;function i(){return r||(r=W(a(),t))}function s(){i().set(a())}function a(){n.forEach(c=>{c.unsub(s,{signal:!0})});const u=new Set;let l;Oe.push(u);try{l=e()}finally{Oe.pop()}return u.forEach(c=>{c.sub(s,{signal:!0})}),n=u,l}return Object.assign(function(){return i()()},{destroy(){i().destroy()},sub(...u){return i().sub(...u)},unsub(...u){i().unsub(...u)},unsubAll(...u){i().unsubAll(...u)}})}var ae;function gt(e){return{lang:(e==null?void 0:e.lang)??(ae==null?void 0:ae.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(ae==null?void 0:ae.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(ae==null?void 0:ae.abortPipeEarly)}}var vt;function fi(e){return vt==null?void 0:vt.get(e)}var wt;function di(e){return wt==null?void 0:wt.get(e)}var yt;function _i(e,t){var n;return(n=yt==null?void 0:yt.get(e))==null?void 0:n.get(t)}function mi(e){var n,r;const t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&((r=(n=Object.getPrototypeOf(e))==null?void 0:n.constructor)==null?void 0:r.name))??"null":t}function K(e,t,n,r,i){const s=i&&"input"in i?i.input:n.value,a=(i==null?void 0:i.expected)??e.expects??null,u=(i==null?void 0:i.received)??mi(s),l={kind:e.kind,type:e.type,input:s,expected:a,received:u,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${u}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??_i(e.reference,l.lang)??(c?di(l.lang):null)??r.message??fi(l.lang);h!==void 0&&(l.message=typeof h=="function"?h(l):h),c&&(n.typed=!1),n.issues?n.issues.push(l):n.issues=[l]}function J(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},gt())}}}function qn(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function bi(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}var gi=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function et(e,t){return{kind:"validation",type:"check",reference:et,async:!1,expects:null,requirement:e,message:t,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&K(this,"input",n,r),n}}}function Ct(e){return{kind:"validation",type:"integer",reference:Ct,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&K(this,"integer",t,n),t}}}function ue(e){return{kind:"transformation",type:"transform",reference:ue,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function vi(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}function Ft(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function St(e,t){return!e["~run"]({value:t},{abortEarly:!0}).issues}function Bn(){return{kind:"schema",type:"any",reference:Bn,expects:"any",async:!1,get"~standard"(){return J(this)},"~run"(e){return e.typed=!0,e}}}function Tn(e,t){return{kind:"schema",type:"array",reference:Tn,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){var s;const i=n.value;if(Array.isArray(i)){n.typed=!0,n.value=[];for(let a=0;a<i.length;a++){const u=i[a],l=this.item["~run"]({value:u},r);if(l.issues){const c={type:"array",origin:"value",input:i,key:a,value:u};for(const h of l.issues)h.path?h.path.unshift(c):h.path=[c],(s=n.issues)==null||s.push(h);if(n.issues||(n.issues=l.issues),r.abortEarly){n.typed=!1;break}}l.typed||(n.typed=!1),n.value.push(l.value)}}else K(this,"type",n,r);return n}}}function Ce(e){return{kind:"schema",type:"boolean",reference:Ce,expects:"boolean",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:K(this,"type",t,n),t}}}function tt(e){return{kind:"schema",type:"date",reference:tt,expects:"Date",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return t.value instanceof Date?isNaN(t.value)?K(this,"type",t,n,{received:'"Invalid Date"'}):t.typed=!0:K(this,"type",t,n),t}}}function kt(e){return{kind:"schema",type:"function",reference:kt,expects:"Function",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="function"?t.typed=!0:K(this,"type",t,n),t}}}function Et(e,t){return{kind:"schema",type:"instance",reference:Et,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){return n.value instanceof this.class?n.typed=!0:K(this,"type",n,r),n}}}function j(e,t){return{kind:"schema",type:"loose_object",reference:j,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){var s;const i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(const a in this.entries){const u=this.entries[a];if(a in i||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){const l=a in i?i[a]:Ft(u),c=u["~run"]({value:l},r);if(c.issues){const h={type:"object",origin:"value",input:i,key:a,value:l};for(const f of c.issues)f.path?f.path.unshift(h):f.path=[h],(s=n.issues)==null||s.push(f);if(n.issues||(n.issues=c.issues),r.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value[a]=c.value}else if(u.fallback!==void 0)n.value[a]=vi(u);else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(K(this,"key",n,r,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:i,key:a,value:i[a]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly)for(const a in i)qn(i,a)&&!(a in this.entries)&&(n.value[a]=i[a])}else K(this,"type",n,r);return n}}}function Ie(e,t){return{kind:"schema",type:"nullish",reference:Ie,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return J(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=Ft(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function de(e){return{kind:"schema",type:"number",reference:de,expects:"number",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:K(this,"type",t,n),t}}}function $(e,t){return{kind:"schema",type:"optional",reference:$,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return J(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=Ft(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function $t(e,t,n){return{kind:"schema",type:"record",reference:$t,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return J(this)},"~run"(r,i){var a,u;const s=r.value;if(s&&typeof s=="object"){r.typed=!0,r.value={};for(const l in s)if(qn(s,l)){const c=s[l],h=this.key["~run"]({value:l},i);if(h.issues){const b={type:"object",origin:"key",input:s,key:l,value:c};for(const v of h.issues)v.path=[b],(a=r.issues)==null||a.push(v);if(r.issues||(r.issues=h.issues),i.abortEarly){r.typed=!1;break}}const f=this.value["~run"]({value:c},i);if(f.issues){const b={type:"object",origin:"value",input:s,key:l,value:c};for(const v of f.issues)v.path?v.path.unshift(b):v.path=[b],(u=r.issues)==null||u.push(v);if(r.issues||(r.issues=f.issues),i.abortEarly){r.typed=!1;break}}(!h.typed||!f.typed)&&(r.typed=!1),h.typed&&(r.value[h.value]=f.value)}}else K(this,"type",r,i);return r}}}function C(e){return{kind:"schema",type:"string",reference:C,expects:"string",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:K(this,"type",t,n),t}}}function Pn(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function nt(e,t){return{kind:"schema",type:"union",reference:nt,expects:bi(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){let i,s,a;for(const u of this.options){const l=u["~run"]({value:n.value},r);if(l.typed)if(l.issues)s?s.push(l):s=[l];else{i=l;break}else a?a.push(l):a=[l]}if(i)return i;if(s){if(s.length===1)return s[0];K(this,"type",n,r,{issues:Pn(s)}),n.typed=!0}else{if((a==null?void 0:a.length)===1)return a[0];K(this,"type",n,r,{issues:Pn(a)})}return n}}}function At(){return{kind:"schema",type:"unknown",reference:At,expects:"unknown",async:!1,get"~standard"(){return J(this)},"~run"(e){return e.typed=!0,e}}}function _e(e,t,n){const r=e["~run"]({value:t},gt(n));if(r.issues)throw new gi(r.issues);return r.value}function se(...e){return{...e[0],pipe:e,get"~standard"(){return J(this)},"~run"(t,n){for(const r of e)if(r.kind!=="metadata"){if(t.issues&&(r.kind==="schema"||r.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r["~run"](t,n))}return t}}}function It(e,t,n){const r=e["~run"]({value:t},gt(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var wi=Object.defineProperty,yi=(e,t,n)=>t in e?wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mn=(e,t,n)=>yi(e,typeof t!="symbol"?t+"":t,n),Ci=Object.defineProperty,Fi=(e,t,n)=>t in e?Ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qt=(e,t,n)=>Fi(e,typeof t!="symbol"?t+"":t,n);function Ln(e){return t=>t instanceof e}function Vn(e,t){const n=class extends Error{constructor(...i){const s=typeof t=="function"?t(...i):typeof t=="string"?[t]:t||[];super(...s),this.name=e}};qt(n,"is",Ln(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function Si(e,t,n){const r=class extends Vn(e,n){constructor(...s){super(...s),qt(this,"data"),this.data=t(...s)}};qt(r,"is",Ln(r));let i=r;return Object.defineProperty(i,"name",{value:e}),i}let Rn=class extends Vn("CancelledError","Promise was canceled"){},Bt=class extends Si("TimeoutError",t=>({timeout:t}),(t,n)=>[`Timeout reached: ${t}ms`,{cause:n}]){};const ki=Symbol("resolved");function Ei(e){return{tag:ki,value:e}}function On(e,t){return e.reject=t.reject,e.resolve=t.resolve,e}let rt=class Sn extends Promise{constructor(t,n){let r,i,s,a;typeof t=="function"?(s=t,a=n||{}):a=t||{};let u,l;const c=()=>!!l,h=()=>!!u;let f={};const b=[],v=()=>{b.forEach(g=>g()),b.splice(0,b.length),f={}},y=new AbortController,w=()=>h()||c();super((g,S)=>{const{abortOnResolve:_=!0,abortOnReject:D=!0}=a;i=k=>{var L,I;w()||(g(k),u=[k],(L=f.resolved)==null||L.forEach(x=>x(k)),(I=f.finalized)==null||I.forEach(x=>x({kind:"resolved",result:k})),v(),_&&y.abort(Ei(k)))},r=k=>{var L,I;w()||(S(k),l=[k],(L=f.rejected)==null||L.forEach(x=>x(k)),(I=f.finalized)==null||I.forEach(x=>x({kind:"rejected",reason:k})),v(),D&&y.abort(k))};const{abortSignal:M}=a;if(M){if(M.aborted)return r(M.reason);const k=()=>{r(M.reason)};M.addEventListener("abort",k,!0),b.push(()=>{M.removeEventListener("abort",k,!0)})}const{timeout:U}=a;if(U){const k=setTimeout(()=>{r(new Bt(U))},U);b.push(()=>{clearTimeout(k)})}try{const k=()=>{},L=s&&s(i,r,{abortSignal:y.signal,get isRejected(){return c()},get isResolved(){return h()},on(I,x){if(u||l){if(I==="finalized"){const Le=u?{kind:"resolved",result:u[0]}:{kind:"rejected",reason:l[0]};x(Le)}else I==="resolved"&&u?x(u[0]):I==="rejected"&&l&&x(l[0]);return k}return f[I]||(f[I]=[]),f[I].push(x),()=>{const Le=f[I]||[],Ye=Le.indexOf(x);Ye>=0&&Le.splice(Ye,1)}},get result(){return u==null?void 0:u[0]},get rejectReason(){return l==null?void 0:l[0]},throwIfRejected(){if(l)throw l[0]}});L instanceof Promise&&L.catch(r)}catch(k){r(k)}}),Mn(this,"reject"),Mn(this,"resolve"),this.reject=r,this.resolve=i}static fn(t,n){return new Sn(async(r,i,s)=>{try{r(await t(s))}catch(a){i(a)}},n)}static resolve(t){return this.fn(()=>t)}static reject(t){return new Sn((n,r)=>{r(t)})}cancel(){this.reject(new Rn)}catch(t){return this.then(void 0,t)}finally(t){return On(super.finally(t),this)}then(t,n){return On(super.then(t,n),this)}};function jn(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function $i(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function Ai(e){return Object.entries(e).reduce((t,[n,r])=>(t[$i(n)]=r,t),{})}function Tt(e){const t=Ai(e);for(const n in t){const r=t[n];r&&typeof r=="object"&&!(r instanceof Date)&&(t[n]=Array.isArray(r)?r.map(Tt):Tt(r))}return t}function Ii(e){return e.replace(/_([a-z])/g,(t,n)=>`-${n.toLowerCase()}`)}function Dn(e){return`tapps/${e}`}function Pt(e,t){sessionStorage.setItem(Dn(e),JSON.stringify(t))}function Un(e){const t=sessionStorage.getItem(Dn(e));try{return t?JSON.parse(t):void 0}catch{}}function st(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(n=>{n()})}]}function xn(e,t){t||(t={});const{textColor:n,bgColor:r,shouldLog:i}=t,s=i===void 0?!0:i,a=typeof s=="boolean"?()=>s:s,u=(l,c,...h)=>{if(c||a()){const f="font-weight:bold;padding:0 5px;border-radius:100px",[b,v,y]={log:["#0089c3","white","INFO"],error:["#ff0000F0","white","ERR"],warn:["#D38E15","white","WARN"]}[l];console[l](`%c${y} ${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:${b};color:${v}`,"",`${f};${n?`color:${n};`:""}${r?`background-color:${r}`:""}`,...h)}};return[["log","forceLog"],["warn","forceWarn"],["error","forceError"]].reduce((l,[c,h])=>(l[c]=u.bind(void 0,c,!1),l[h]=u.bind(void 0,c,!0),l),{})}var qi=function(e,t,n){if(arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function Gn(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function qe(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Wn=function(e,t){var n=function(r){return r.length>=e};return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,qi([i],r,!1))}}},Bi=function(e){return e._tag==="Left"},Hn=function(e){return{_tag:"Left",left:e}},Nn=function(e){return{_tag:"Right",right:e}},zn=Hn,Kn=Nn,Jn=Bi,Ti=function(e,t){return function(n){return Jn(n)?e(n.left):t(n.right)}},Mt=Ti;function Pi(e){return Gn(Kn,e.of)}function Mi(e){return Gn(zn,e.of)}function Li(e){return function(t,n){return e.chain(t,function(r){return Jn(r)?e.of(r):n(r.right)})}}function Vi(e){return function(t,n){return function(r){return e.map(r,Mt(t,n))}}}var Qn=function(e,t){return qe(e,Oi(t))},Ri=function(e,t){return qe(e,ji(t))},Oi=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},ji=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Lt=function(e){return function(){return Promise.resolve(e)}},Di=Wn(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),Zn="Task",Ui={URI:Zn,map:Qn},Yn={of:Lt},xi={URI:Zn,map:Qn,of:Lt,ap:Ri,chain:Di},Gi=function(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function u(h){try{c(r.next(h))}catch(f){a(f)}}function l(h){try{c(r.throw(h))}catch(f){a(f)}}function c(h){h.done?s(h.value):i(h.value).then(u,l)}c((r=r.apply(e,[])).next())})},Wi=function(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(c){return function(h){return l([c,h])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(s=c[0]&2?i.return:c[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,c[1])).done)return s;switch(i=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(h){c=[6,h],i=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Hi=Mi(Yn),Ni=Pi(Yn),zi=Lt,Xn=Vi(Ui),Ki=Xn,Ji=function(e,t){return function(){return Gi(void 0,void 0,void 0,function(){var n;return Wi(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e().then(Nn)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,Hn(t(n))];case 3:return[2]}})})}},Qi=Wn(2,Li(xi)),Zi=Qi;function je(e){const t=n=>{throw n};return typeof e=="function"?rt.resolve(qe(e,Xn(t,n=>n))()):qe(e,Mt(t,n=>n))}function X(e){return Object.assign((...t)=>je(e(...t)),e)}const De=Object.assign((e,t)=>qe(Ji(()=>new rt((n,r,i)=>e(s=>n(Kn(s)),s=>n(zn(s)),i),t),n=>n),Zi(Mt(Hi,Ni))),{fn:(e,t)=>De((n,r,i)=>{const s=e(i);qe(typeof s=="function"?s:zi(s),Ki(r,n))()},t)});function Yi(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Xi=function(e){return e._tag==="Left"},eo=function(e){return{_tag:"Left",left:e}},to=function(e){return{_tag:"Right",right:e}},er=eo,Fe=to,no=function(e){return function(t){return ro(t)?t:Fe(e(t.right))}},ro=Xi,tr=function(e,t){try{return Fe(e())}catch(n){return er(t(n))}};function so(e){const t=n=>{const r={};return new URLSearchParams(n).forEach((i,s)=>{const a=r[s];Array.isArray(a)?a.push(i):a===void 0?r[s]=i:r[s]=[a,i]}),_e(e,r)};return se(nt([C(),Et(URLSearchParams)]),et(n=>{try{return t(n),!0}catch{return!1}},"The value doesn't match required schema"),ue(t))}function io(e){return se(C(),et(t=>{try{return JSON.parse(t),!0}catch{return!1}},"Input is not a valid JSON value"),ue(JSON.parse),e)}function me(e){return se(C(),io(e))}function Vt(e){return se(nt([C(),Et(URLSearchParams)]),so(e))}function it(e){return t=>e.test(t)}const nr=it(/^#[\da-f]{3}$/i),rr=it(/^#[\da-f]{4}$/i),Ue=it(/^#[\da-f]{6}$/i),sr=it(/^#[\da-f]{8}$/i);function ir(e){return[Ue,sr,nr,rr].some(t=>t(e))}function or(e){let t="#";for(let n=0;n<e.length-1;n+=1)t+=e[1+n].repeat(2);return t}function ot(e){const t=e.replace(/\s/g,"").toLowerCase();if(/^#[\da-f]{3}$/i.test(t))return Fe(or(t.toLowerCase()+"f"));if(/^#[\da-f]{4}$/i.test(t))return Fe(or(t.toLowerCase()));if(/^#[\da-f]{6}$/i.test(t))return Fe(t.toLowerCase()+"ff");if(/^#[\da-f]{8}$/i.test(t))return Fe(t.toLowerCase());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})\)$/);return n?Fe(n.slice(1).reduce((r,i)=>r+parseInt(i,10).toString(16).padStart(2,"0"),"#").padEnd(9,"f")):er(new Error(`Value "${e}" does not satisfy any of known RGB formats.`))}function ar(e){return Yi(ot(e),no(t=>t.slice(0,7)))}const oo=X(ar),ao=X(ot);function uo(){return j({id:de(),photo_url:$(C()),type:C(),title:C(),username:$(C())})}function ur(){return j({added_to_attachment_menu:$(Ce()),allows_write_to_pm:$(Ce()),first_name:C(),id:de(),is_bot:$(Ce()),is_premium:$(Ce()),last_name:$(C()),language_code:$(C()),photo_url:$(C()),username:$(C())})}function co(){return j({auth_date:se(C(),ue(e=>new Date(Number(e)*1e3)),tt()),can_send_after:$(se(C(),ue(Number),Ct())),chat:$(me(uo())),chat_type:$(C()),chat_instance:$(C()),hash:C(),query_id:$(C()),receiver:$(me(ur())),start_param:$(C()),signature:C(),user:$(me(ur()))})}function cr(){return Vt(co())}function Rt(){return $t(C(),se(nt([C(),de()]),ue(e=>typeof e=="number"?`#${(e&16777215).toString(16).padStart(6,"0")}`:e),et(ir)))}function lo(){const e=$(se(C(),ue(t=>t==="1")));return j({tgWebAppBotInline:e,tgWebAppData:$(cr()),tgWebAppDefaultColors:$(me(Rt())),tgWebAppFullscreen:e,tgWebAppPlatform:C(),tgWebAppShowSettings:e,tgWebAppStartParam:$(C()),tgWebAppThemeParams:me(Rt()),tgWebAppVersion:C()})}function po(){return Vt(lo())}function lr(){return j({eventType:C(),eventData:$(At())})}function pr(e){return tr(()=>_e(cr(),e),t=>t)}function at(e){return tr(()=>_e(po(),e),t=>t)}const ho=X(pr),hr=X(at);function fr(e,t){return t||(t=(n,r)=>JSON.stringify(r)),new URLSearchParams(Object.entries(e).reduce((n,[r,i])=>(Array.isArray(i)?n.push(...i.map(s=>[r,String(s)])):i!=null&&n.push([r,i instanceof Date?(i.getTime()/1e3|0).toString():typeof i=="string"||typeof i=="number"?String(i):typeof i=="boolean"?i?"1":"0":t(r,i)]),n),[])).toString()}function dr(e){return fr(e)}function _r(e){return fr(e,(t,n)=>t==="tgWebAppData"?dr(n):JSON.stringify(n))}var fo=Object.defineProperty,_o=(e,t,n)=>t in e?fo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ot=(e,t,n)=>_o(e,typeof t!="symbol"?t+"":t,n);function mr(e){return t=>t instanceof e}function H(e,t){const n=class extends Error{constructor(...s){const a=typeof t=="function"?t(...s):typeof t=="string"?[t]:t||[];super(...a),this.name=e}};Ot(n,"is",mr(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function br(e,t,n){const r=class extends H(e,n){constructor(...a){super(...a),Ot(this,"data"),this.data=t(...a)}};Ot(r,"is",mr(r));let i=r;return Object.defineProperty(i,"name",{value:e}),i}function mo(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(i){i(n)}),(r=e.get("*"))&&r.slice().map(function(i){i(t,n)})}}}function gr(e){return St(j({TelegramWebviewProxy:j({postEvent:kt()})}),e)}function vr(){try{return window.self!==window.top}catch{return!0}}var bo=function(e,t,n){if(arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function go(e){return e}function xe(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function ce(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var jt=function(e,t){var n=function(r){return r.length>=e};return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,bo([i],r,!1))}}},vo={_tag:"None"},wo=function(e){return{_tag:"Some",value:e}},yo=function(e){return e._tag==="Left"},Co=function(e){return{_tag:"Left",left:e}},Fo=function(e){return{_tag:"Right",right:e}},Se=Co,te=Fo,wr=jt(2,function(e,t){return Ge(e)?e:t(e.right)}),So=function(e){return function(t){return Ge(t)?t:te(e(t.right))}},ko=function(e){return function(t){return Ge(t)?Se(e(t.left)):t}},Ge=yo,yr=function(e,t){return function(n){return Ge(n)?e(n.left):t(n.right)}},Eo=yr,Dt=yr,$o=Dt,Ut=function(e,t){try{return te(e())}catch(n){return Se(t(n))}},Ao=wr,Io=wr,qo=vo,Bo=wo,To=function(e){return e._tag==="None"},Po=function(e,t){return function(n){return To(n)?e():t(n.value)}},Mo=Po;function Lo(e){return xe(te,e.of)}function Vo(e){return xe(Se,e.of)}function Ro(e){return function(t,n){return e.chain(t,function(r){return Ge(r)?e.of(r):n(r.right)})}}function Oo(e){return function(t,n){return function(r){return e.map(r,Dt(t,n))}}}var Cr=function(e,t){return ce(e,Do(t))},jo=function(e,t){return ce(e,Uo(t))},Do=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},Uo=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Fr=function(e){return function(){return Promise.resolve(e)}},xo=jt(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),Sr="Task",Go={URI:Sr,map:Cr},kr={of:Fr},Wo={URI:Sr,map:Cr,of:Fr,ap:jo,chain:xo},Ho=Vo(kr),Er=Lo(kr),No=Oo(Go),$r=jt(2,Ro(Wo)),zo=$r,Ko=$r;class Ar extends H("MethodUnsupportedError",(t,n)=>[`Method "${t}" is unsupported in Mini Apps version ${n}`]){}class Ir extends H("MethodParameterUnsupportedError",(t,n,r)=>[`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${r}`]){}class qr extends br("LaunchParamsRetrieveError",t=>({errors:t}),t=>[["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/tma-js-bridge/environment","","Collected errors:",...t.map(({source:n,error:r})=>`Source: ${n} / ${r instanceof Error?r.message:String(r)}`)].join(`
|
|
2
|
-
`)]){}class Br extends H("InvalidLaunchParamsError",(t,n)=>[`Invalid value for launch params: ${t}`,{cause:n}]){}class Tr extends H("UnknownEnvError"){}class Pr extends H("InvokeCustomMethodError",t=>[`Server returned error: ${t}`]){}const Mr="launchParams";function Lr(e){return e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&")}const Be=xe(We,Ao(at)),Jo=X(Be),
|
|
3
|
-
`),t,a)}ea(n,s)}const{on:ee,off:ke,emit:ea,clear:ta}=Yo(()=>{const e=window;!e.TelegramGameProxy&&(e.TelegramGameProxy={}),Wt(e.TelegramGameProxy,"receiveEvent",Gt),Vr(e,"TelegramGameProxy"),!e.Telegram&&(e.Telegram={}),!e.Telegram.WebView&&(e.Telegram.WebView={}),Wt(e.Telegram.WebView,"receiveEvent",Gt),Vr(e.Telegram,"WebView"),Wt(e,"TelegramGameProxy_receiveEvent",Gt),window.addEventListener("message",jr)},()=>{[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["Telegram","WebView","receiveEvent"]].forEach(e=>{const t=window;let n=[void 0,t];for(const s of e)if(n=[n[1],n[1][s]],!n[1])return;const[r,i]=n;"unwrap"in i&&(i.unwrap(),r&&r!==t&&!Object.keys(r).length&&delete t[e[0]])}),window.removeEventListener("message",jr)}),Ht=W(!1),Dr=W("https://web.telegram.org"),na=e=>{le().log("Event received:",e)},Ur=F(Ht);function ra(e){e!==Ht()&&(Ht.set(e),(e?ee:ke)("*",na))}const xr=F(Dr);function sa(e){Dr.set(e),le().log("New target origin set",e)}const ut=W((...e)=>{window.parent.postMessage(...e)}),le=W(xn("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:Ur})),ia=(...e)=>ut()(...e);function oa(e,t){ce(Nt(e,t),ko(n=>{throw n}))}function Nt(e,t){le().log("Posting event:",t?{eventType:e,eventData:t}:{eventType:e});const n=window,r=JSON.stringify({eventType:e,eventData:t});return vr()?(ia(r,xr()),te(void 0)):gr(n)?(n.TelegramWebviewProxy.postEvent(e,JSON.stringify(t)),te(void 0)):St(j({external:j({notify:kt()})}),n)?(n.external.notify(r),te(void 0)):Se(new Tr)}function zt(e,t,n={}){const{capture:r=()=>!0,postEvent:i=Nt}=n;return ce(async()=>i(e,n.params),Ko(()=>De((s,a,u)=>{const[l,c]=st();(Array.isArray(t)?t:[t]).forEach(h=>{l(ee(h,f=>{(Array.isArray(t)?r({event:h,payload:f}):r(f))&&s(f)}))}),u.on("finalized",c)},n)))}function aa(e,t){const n=Kt(e,t);return typeof n=="function"?rt.fn(()=>je(n)):n}function Kt(e,t){const n=gr(window);if(!e)return n||ce(We(),Dt(()=>!1,()=>!0));if(n)return Er(!0);const{timeout:r=100}=t||{};return ce(zt("web_app_request_theme","theme_changed",{...t,timeout:r}),No(i=>Bt.is(i)?te(!1):Se(i),()=>te(!0)))}function ua({launchParams:e,onEvent:t,resetPostMessage:n}={}){if(e){const s=typeof e=="string"||e instanceof URLSearchParams?e.toString():_r({...e,tgWebAppData:void 0})+(e.tgWebAppData?`&tgWebAppData=${encodeURIComponent(e.tgWebAppData.toString())}`:"");try{hr(s)}catch(a){throw new Br(s,a)}Pt("launchParams",s)}if(vr()){if(!t)return;n&&ut.reset();const s=ut();ut.set((...a)=>{const[u]=a,l=()=>{s(...a)};try{const c=_e(me(lr()),u);t([c.eventType,c.eventData],l)}catch{l()}});return}const r=window.TelegramWebviewProxy||{},i=r.postEvent||(()=>{});window.TelegramWebviewProxy={...r,postEvent(s,a){const u=()=>{i(s,a)};t?t([s,a?JSON.parse(a):void 0],u):u()}},le().log("Environment was mocked by the mockTelegramEnv function")}function Gr(e){return({req_id:t})=>t===e}function Wr(e){return e.split(".").map(Number)}function ca(e,t){const n=Wr(e),r=Wr(t),i=Math.max(n.length,r.length);for(let s=0;s<i;s+=1){const a=n[s]||0,u=r[s]||0;if(a!==u)return a>u?1:-1}return 0}const Hr={"6.0":["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"],6.1:["web_app_open_tg_link","web_app_open_invoice","web_app_setup_back_button","web_app_set_background_color","web_app_set_header_color","web_app_trigger_haptic_feedback"],6.2:["web_app_open_popup"],6.4:["web_app_close_scan_qr_popup","web_app_open_scan_qr_popup","web_app_read_text_from_clipboard",{method:"web_app_open_link",param:"try_instant_view"}],6.7:["web_app_switch_inline_query"],6.9:["web_app_invoke_custom_method","web_app_request_write_access","web_app_request_phone",{method:"web_app_set_header_color",param:"color"}],"6.10":["web_app_setup_settings_button"],7.2:["web_app_biometry_get_info","web_app_biometry_open_settings","web_app_biometry_request_access","web_app_biometry_request_auth","web_app_biometry_update_token"],7.6:[{method:"web_app_open_link",param:"try_browser"},{method:"web_app_close",param:"return_back"}],7.7:["web_app_setup_swipe_behavior"],7.8:["web_app_share_to_story"],"7.10":["web_app_setup_secondary_button","web_app_set_bottom_bar_color",{method:"web_app_setup_main_button",param:"has_shine_effect"}],"8.0":["web_app_request_safe_area","web_app_request_content_safe_area","web_app_request_fullscreen","web_app_exit_fullscreen","web_app_set_emoji_status","web_app_add_to_home_screen","web_app_check_home_screen","web_app_request_emoji_status_access","web_app_check_location","web_app_open_location_settings","web_app_request_file_download","web_app_request_location","web_app_send_prepared_message","web_app_start_accelerometer","web_app_start_device_orientation","web_app_start_gyroscope","web_app_stop_accelerometer","web_app_stop_device_orientation","web_app_stop_gyroscope","web_app_toggle_orientation_lock"],"9.0":["web_app_device_storage_clear","web_app_device_storage_get_key","web_app_device_storage_save_key","web_app_secure_storage_clear","web_app_secure_storage_get_key","web_app_secure_storage_restore_key","web_app_secure_storage_save_key"],9.1:["web_app_hide_keyboard"]};function Jt(e,t){return Object.keys(Hr).find(n=>Hr[n].some(r=>t?typeof r=="object"&&r.method===e&&r.param===t:r===e))||null}function pe(e,t,n){const r=n?Jt(e,t):Jt(e);return r?ca(r,n||t)<=0:!1}function la(e,t="strict"){const n=typeof t=="function"?t:r=>{const{method:i,version:s}=r,a="param"in r?new Ir(i,r.param,s):new Ar(i,s);if(t==="strict")throw a;return le().forceWarn(a.message)};return(r,i)=>pe(r,e)?r==="web_app_set_header_color"&&St(j({color:Bn()}),i)&&!pe(r,"color",e)?n({version:e,method:r,param:"color"}):oa(r,i):n({version:e,method:r})}function pa(e,t,n,r){return ce(zt("web_app_invoke_custom_method","custom_method_invoked",{...r||{},params:{method:e,params:t,req_id:n},capture:Gr(n)}),zo(({result:i,error:s})=>s?Ho(new Pr(s)):Er(i)))}function ha(){Object.hasOwn||(Object.hasOwn=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)})}function Qt(e){return Ut(()=>decodeURIComponent(atob(e).replace(/-/g,"+").replace(/_/g,"/").split("").map(t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)).join("")),t=>t)}const fa=X(Qt);function Zt(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,n)=>String.fromCharCode(parseInt(`0x${n}`)))).replace(/\+/g,"-").replace(/\//g,"_")}var da=function(e){return Ut(function(){return JSON.parse(e)},go)};function Nr(e){const t=Zt(typeof e=="string"?e:JSON.stringify(e));return t.length>512?Se(new Error("Value is too long for start parameter")):te(t)}const _a=X(Nr);function ma(e,t){return je(zr(e,typeof t=="function"?n=>Ut(()=>t(n),r=>r):t))}function zr(e,t){return ce(Qt(e),Io(n=>t?typeof t=="function"?t(n):da(n):te(n)))}function ba(e){return Zt(e).length<=512}function Q(e){return typeof e=="function"?e():e}function ie(e,t){return F(()=>pe(e,Q(t)))}var Te=Js,He=Qs,ga=function(e,t){return d(e,ya(t))},va=function(e,t){return d(e,Fa(t))},wa="Option",ya=function(e){return function(t){return Ne(t)?Te:He(e(t.value))}},Ca=He,Fa=function(e){return function(t){return Ne(t)||Ne(e)?Te:He(t.value(e.value))}},Sa=Ve(2,function(e,t){return Ne(e)?Te:t(e.value)}),ka={URI:wa,map:ga,ap:va,chain:Sa},Ne=function(e){return e._tag==="None"},Ea=function(e,t){return function(n){return Ne(n)?e():t(n.value)}},Kr=Ea,$a=Ca(dt),Jr=_t(ka);function Aa(e){return we(P,e.of)}function Ia(e){return we(O,e.of)}function qa(e){return Xs(e,ti)}function Ba(e){return Ys(e,ii)}function Ta(e){return function(t,n){return e.chain(t,function(r){return ye(r)?e.of(r):n(r.right)})}}function Pa(e){return function(t,n,r){return e.map(t,ai(n,r))}}function Ma(e){return function(t,n){return function(r){return e.map(r,Re(t,n))}}}var Yt=function(e,t){return d(e,La(t))},Qr=function(e,t){return d(e,Va(t))},La=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},Va=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Xt=function(e){return function(){return Promise.resolve(e)}},Ra=Ve(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),en="Task",tn={URI:en,map:Yt},Zr={of:Xt},Oa={URI:en,map:Yt,ap:Qr},ja={URI:en,map:Yt,of:Xt,ap:Qr,chain:Ra},Da=function(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function u(h){try{c(r.next(h))}catch(f){a(f)}}function l(h){try{c(r.throw(h))}catch(f){a(f)}}function c(h){h.done?s(h.value):i(h.value).then(u,l)}c((r=r.apply(e,t||[])).next())})},Ua=function(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(c){return function(h){return l([c,h])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(s=c[0]&2?i.return:c[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,c[1])).done)return s;switch(i=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(h){c=[6,h],i=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},N=Ia(Zr),R=Aa(Zr),Yr=Xt,xa=Ma(tn),Ga=function(e,t){return function(){return Da(void 0,void 0,void 0,function(){var n;return Ua(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e().then(En)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,kn(t(n))];case 3:return[2]}})})}},Wa=function(e,t){return d(e,V(t))},Ha=function(e,t){return d(e,Na(t))},V=qa(tn),nn=Ve(3,Pa(tn)),Na=Ba(Oa),rn=Ve(2,Ta(ja)),za=R,Ka="TaskEither",Ja={URI:Ka,map:Wa,ap:Ha,chain:rn},Qa=za(dt),Za=_t(Ja),ct=Za,he=rn,Pe=rn;function Ee(e){return[e]}class ze extends br("ValidationError",(t,n)=>({input:t,issues:n}),"Validation error"){}class lt extends H("CSSVarsBoundError","CSS variables are already bound"){}class Xr extends H("NotAvailableError",Ee){}class Ya extends H("InvalidEnvError",Ee){}class es extends H("FunctionNotAvailableError",Ee){}class ne extends H("InvalidArgumentsError",(t,n)=>[t,{cause:n}]){}class pt extends H("ConcurrentCallError",Ee){}class ts extends H("SetEmojiStatusError",t=>[`Failed to set emoji status: ${t}`]){}class sn extends H("AccessDeniedError",Ee){}class ns extends H("FullscreenFailedError",Ee){}class rs extends H("ShareMessageError",Ee){}class ss extends H("UnknownThemeParamsKeyError",t=>[`Unknown theme params key passed: ${t}`]){}function T(e,t){const n=F(()=>Q(t.version)||"100"),r=F(()=>Q(t.isTma)),{requires:i}=t,s=i?typeof i=="object"?i:{every:[i]}:void 0,a=y=>{if(!t.supports)return!0;const w=t.supports[y];return pe(w.method,w.param,n())},u=()=>{if(!s)return;const[y,w]="every"in s?["every",s.every]:["some",s.some];for(let g=0;g<w.length;g++){const S=w[g],_=typeof S=="function"?S():pe(S,n())?void 0:`it is unsupported in Mini Apps version ${n()}`;if(_&&(y==="every"||g===w.length-1))return _}},l=(...y)=>{for(const w in t.supports)if(t.supports[w].shouldCheck(...y)&&!a(w))return`option ${w} is not supported in Mini Apps version ${n()}`},c=F(()=>!u()),h=F(()=>n()!=="0.0"),f=F(()=>t.isMounted?t.isMounted():!0),b=F(()=>r()&&h()&&c()&&f()),v=y=>{const w=new es(y);return["task","promise"].includes(t.returns)?N(w):O(w)};return Object.assign((...y)=>{var D;const w="Unable to call function:";if(!r())return v(`${w} it can't be called outside Mini Apps`);if(!h())return v(`${w} the SDK was not initialized. Use the SDK init() function`);const g=u();if(g)return v(`${w} ${g}`);const S=l(...y);if(S)return v(`${w} ${S}`);if(!f()){const M=(D=t.isMounting)!=null&&D.call(t)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return v(`${w} the component is ${M}`)}const{returns:_}=t;return _==="plain"?ui(()=>e(...y),M=>M):_==="promise"?Ga(()=>e(...y),M=>M):e(...y)},e,{isAvailable:b,ifAvailable(...y){return b()?He(e(...y)):Te}},s?{isSupported:c}:{},t.supports?{supports:a}:{})}function B(e){return t=>T(t,e)}function m(e){return Object.assign(X(e),{ifAvailable(...t){return d(e.ifAvailable(...t),Kr(()=>({ok:!1}),n=>({ok:!0,data:je(n)})))}})}function on(e){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=r)}return t}function an(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&e[i]===t[i])}class be{constructor({initialState:t,onChange:n}){o(this,"_state");o(this,"state");o(this,"setState",t=>{const n={...this.state(),...on(t)};an(n,this.state())||this._state.set(n)});this._state=W(t,{equals:an}),this.state=F(this._state),this.state.sub(n)}getter(t){return F(()=>this._state()[t])}hasDiff(t){return!an({...this.state(),...on(t)},this.state())}}class Ke{constructor({onMounted:t,restoreState:n,initialState:r,onUnmounted:i,isPageReload:s}){o(this,"_isMounted",W(!1));o(this,"isMounted",F(this._isMounted));o(this,"mount");o(this,"unmount");this.mount=()=>{if(this.isMounted())return P(void 0);const a=Q(s)?n():void 0,u=a?P(a):typeof r=="function"?r():P(r);return d(u,Z(l=>{Xe(()=>{this._isMounted.set(!0),t==null||t(l)})}))},this.unmount=()=>{this._isMounted()&&Xe(()=>{this._isMounted.set(!1),i==null||i()})}}}class ht{constructor({isTma:t,storage:n,onClick:r,offClick:i,initialState:s,isPageReload:a,postEvent:u,payload:l,method:c,version:h}){o(this,"isMounted");o(this,"isSupported");o(this,"state");o(this,"stateSetters");o(this,"stateBoolSetters");o(this,"setStateFp");o(this,"setState");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const f=new be({initialState:s,onChange(g){n.set(g)}}),b=new Ke({initialState:s,isPageReload:a,onMounted:f.setState,restoreState:n.get}),v={version:h,requires:c,isTma:t},y=B({...v,returns:"plain"}),w=B({...v,returns:"either",isMounted:b.isMounted});this.isMounted=b.isMounted,this.isSupported=ie(c,h),this.state=f.state,this.setStateFp=w(g=>{const S={...this.state(),...on(g)};return f.hasDiff(S)?d(u(c,l(S)),Z(()=>{f.setState(S)})):P(void 0)}),this.setState=m(this.setStateFp),this.onClickFp=y(r),this.onClick=m(this.onClickFp),this.offClickFp=y(i),this.offClick=m(this.offClickFp),this.mountFp=y(()=>{const g=()=>{};return d(b.mount(),Re(g,g))}),this.mount=m(this.mountFp),this.unmount=b.unmount,this.stateSetters=g=>{const S=w(_=>this.setStateFp({[g]:_}));return[m(S),S]},this.stateBoolSetters=g=>{const[,S]=this.stateSetters(g),_=w(()=>S(!1)),D=w(()=>S(!0));return[[m(_),_],[m(D),D]]}}stateGetter(t){return F(()=>this.state()[t])}}class is{constructor(t){o(this,"isVisible");o(this,"isMounted");o(this,"isSupported");o(this,"hideFp");o(this,"hide");o(this,"showFp");o(this,"show");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const n=new ht({...t,method:"web_app_setup_back_button",payload:r=>({is_visible:r.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}function E(){return{isTma:F(()=>Kt())}}function Xa(e){return{get:()=>Un(e),set(t){Pt(e,t)}}}function eu(){return performance.getEntriesByType("navigation")[0]}function tu(){const e=eu();return!!e&&e.type==="reload"}function Je(e){return t=>({...t,...Q(e)})}function ge(e){return Je({storage:Xa(e),isPageReload:tu})}function Qe(e,t){return W(e,t)}const os=Qe(Nt),Me=(...e)=>os()(...e),as=(...e)=>je(Me(...e)),z=Je({postEvent:Me}),un=Qe("0.0"),A=Je({version:un});function cn(e,t){return{...d(E(),z,A,ge(e)),onClick(n,r){return ee(t,n,r)},offClick(n,r){ke(t,n,r)}}}const nu=new is(cn("backButton","back_button_pressed"));class ln{constructor({initialState:t,onMounted:n,restoreState:r,onUnmounted:i,isPageReload:s}){o(this,"_isMounted",W(!1));o(this,"isMounted",F(this._isMounted));o(this,"mount");o(this,"unmount");this.mount=a=>{if(this._isMounted())return R(void 0);const u=Q(s)?r():void 0;return d(u?R(u):t(a),V(l=>{this._isMounted()||Xe(()=>{this._isMounted.set(!0),n==null||n(l)})}))},this.unmount=()=>{this._isMounted()&&Xe(()=>{this._isMounted.set(!1),i==null||i()})}}}const us=new Xr("Biometry is not available");function pn(e){let t=!1,n=!1,r="",i=!1,s="",a=!1;return e.available&&(t=!0,n=e.token_saved,r=e.device_id,i=e.access_requested,s=e.type,a=e.access_granted),{available:t,tokenSaved:n,deviceId:r,type:s,accessGranted:a,accessRequested:i}}class cs{constructor({version:t,request:n,postEvent:r,storage:i,onInfoReceived:s,offInfoReceived:a,isTma:u,isPageReload:l}){o(this,"isAvailable");o(this,"isSupported");o(this,"isMounted");o(this,"state");o(this,"authenticateFp");o(this,"authenticate");o(this,"openSettingsFp");o(this,"openSettings");o(this,"requestAccessFp");o(this,"requestAccess");o(this,"updateTokenFp");o(this,"updateToken");o(this,"mountFp");o(this,"mount");o(this,"unmount");const c=g=>{h.setState(pn(g))},h=new be({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:i.set}),f=new ln({initialState(g){return d(n("web_app_biometry_get_info","biometry_info_received",g),V(pn))},isPageReload:l,onMounted(g){h.setState(g),s(c)},onUnmounted(){a(c)},restoreState:i.get}),b={version:t,requires:"web_app_biometry_request_auth",isTma:u},v=B({...b,returns:"either"}),y=B({...b,returns:"task"}),w=B({...b,isMounted:f.isMounted,returns:"task"});this.isAvailable=h.getter("available"),this.isMounted=f.isMounted,this.isSupported=ie("web_app_biometry_request_auth",t),this.state=h.state,this.unmount=f.unmount,this.mountFp=y(f.mount),this.authenticateFp=w(g=>this.isAvailable()?d(n("web_app_biometry_request_auth","biometry_auth_requested",{...g,params:{reason:((g||{}).reason||"").trim()}}),V(S=>(h.setState({token:S.token}),S))):N(us)),this.openSettingsFp=v(()=>r("web_app_biometry_open_settings")),this.requestAccessFp=w(g=>d(n("web_app_biometry_request_access","biometry_info_received",{...g,params:{reason:((g||{}).reason||"").trim()}}),he(S=>{const _=pn(S);return _.available?(h.setState(_),R(_.accessRequested)):N(us)}))),this.updateTokenFp=w((g={})=>{var S;return d(n("web_app_biometry_update_token","biometry_token_updated",{...g,params:{token:g.token||"",reason:(S=g.reason)==null?void 0:S.trim()}}),V(_=>_.status))}),this.authenticate=m(this.authenticateFp),this.openSettings=m(this.openSettingsFp),this.requestAccess=m(this.requestAccessFp),this.updateToken=m(this.updateTokenFp),this.mount=m(this.mountFp)}}const hn=(e,t,n)=>zt(e,t,{postEvent:Me,...n}),ru=(...e)=>rt.fn(()=>hn(...e)()),Y=Je({request:hn}),su=new cs({...d(E(),z,A,Y,ge("biometry")),offInfoReceived(e){ke("biometry_info_received",e)},onInfoReceived(e){return ee("biometry_info_received",e)}});class ls{constructor({postEvent:t,storage:n,isTma:r,isPageReload:i}){o(this,"isConfirmationEnabled");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"disableConfirmationFp");o(this,"disableConfirmation");o(this,"enableConfirmationFp");o(this,"enableConfirmation");const s=new be({initialState:{isConfirmationEnabled:!1},onChange(f){n.set(f)}}),a=new Ke({onMounted:s.setState,restoreState:n.get,initialState:{isConfirmationEnabled:!1},isPageReload:i}),u={requires:"web_app_setup_closing_behavior",isTma:r},l=B({...u,returns:"plain"}),c=B({...u,returns:"either",isMounted:a.isMounted}),h=f=>f===this.isConfirmationEnabled()?P(void 0):(s.setState({isConfirmationEnabled:f}),t("web_app_setup_closing_behavior",{need_confirmation:f}));this.isConfirmationEnabled=s.getter("isConfirmationEnabled"),this.isMounted=a.isMounted,this.disableConfirmationFp=c(()=>h(!1)),this.enableConfirmationFp=c(()=>h(!0)),this.mountFp=l(()=>{const f=()=>{};return d(a.mount(),Re(f,f))}),this.unmount=a.unmount,this.disableConfirmation=m(this.disableConfirmationFp),this.enableConfirmation=m(this.enableConfirmationFp),this.mount=m(this.mountFp)}}const iu=new ls(d(E(),ge("closingBehavior"),z));class ps{constructor({version:t,isTma:n,invokeCustomMethod:r}){o(this,"isSupported");o(this,"deleteItemFp");o(this,"deleteItem");o(this,"getItemFp");o(this,"getItem");o(this,"getItemsFp");o(this,"getItems");o(this,"getKeysFp");o(this,"getKeys");o(this,"setItemFp");o(this,"setItem");o(this,"clearFp");o(this,"clear");const i=B({version:t,requires:"web_app_invoke_custom_method",isTma:n,returns:"task"});this.isSupported=ie("web_app_invoke_custom_method",t),this.deleteItemFp=i((s,a)=>{const u=Array.isArray(s)?s:[s];return d(u.length?r("deleteStorageValues",{keys:u},a):R(void 0),V(()=>{}))}),this.getItemFp=i((s,a)=>d(this.getItemsFp([s],a),V(u=>u[s]||""))),this.getItemsFp=i((s,a)=>d(s.length?r("getStorageValues",{keys:s},a):R({}),V(u=>({...s.reduce((l,c)=>(l[c]="",l),{}),..._e($t(C(),C()),u)})))),this.getKeysFp=i(s=>d(r("getStorageKeys",{},s),V(a=>_e(Tn(C()),a)))),this.setItemFp=i((s,a,u)=>d(r("saveStorageValue",{key:s,value:a},u),V(()=>{}))),this.clearFp=i(s=>d(this.getKeysFp(s),he(this.deleteItemFp))),this.deleteItem=m(this.deleteItemFp),this.getItem=m(this.getItemFp),this.getItems=m(this.getItemsFp),this.getKeys=m(this.getKeysFp),this.setItem=m(this.setItemFp),this.clear=m(this.clearFp)}}const fn=Qe(0);function dn(){return fn.set(fn()+1),fn().toString()}function hs(e,t,n){return pa(e,t,dn(),{...n||{},postEvent:Me})}const _n=Je({invokeCustomMethod:hs}),ou=new ps(d(E(),A,_n));function au({request:e,...t}){return T(n=>d(e("web_app_request_emoji_status_access","emoji_status_access_requested",n),V(r=>r.status)),{...t,requires:"web_app_request_emoji_status_access",returns:"task"})}const fs=au(d(E(),A,Y)),uu=m(fs);function cu({request:e,...t}){return T((n,r)=>d(e("web_app_set_emoji_status",["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:n,duration:(r||{}).duration},...r}),Pe(i=>i&&"error"in i?N(new ts(i.error)):R(void 0))),{...t,requires:"web_app_set_emoji_status",returns:"task"})}const ds=cu(d(E(),Y,A)),lu=m(ds);class _s{constructor({postEvent:t,isTma:n,version:r}){o(this,"isSupported");o(this,"impactOccurredFp");o(this,"impactOccurred");o(this,"notificationOccurredFp");o(this,"notificationOccurred");o(this,"selectionChangedFp");o(this,"selectionChanged");const i="web_app_trigger_haptic_feedback",s=B({requires:i,isTma:n,version:r,returns:"plain"});this.isSupported=ie(i,r),this.impactOccurredFp=s(a=>t(i,{type:"impact",impact_style:a})),this.notificationOccurredFp=s(a=>t(i,{type:"notification",notification_type:a})),this.selectionChangedFp=s(()=>t(i,{type:"selection_change"})),this.impactOccurred=m(this.impactOccurredFp),this.notificationOccurred=m(this.notificationOccurredFp),this.selectionChanged=m(this.selectionChangedFp)}}const pu=new _s(d(E(),z,A));function hu({postEvent:e,...t}){return T(()=>e("web_app_add_to_home_screen"),{...t,requires:"web_app_add_to_home_screen",returns:"either"})}const ms=hu(d(E(),A,z)),fu=m(ms);function du({request:e,...t}){return T(n=>d(e("web_app_check_home_screen","home_screen_checked",n),V(r=>r.status||"unknown")),{...t,requires:"web_app_check_home_screen",returns:"task"})}const bs=du(d(E(),A,Y)),_u=m(bs);class gs{constructor({retrieveInitData:t}){o(this,"_state",W());o(this,"_raw",W());o(this,"state",F(this._state));o(this,"authDate",this.fromState("auth_date"));o(this,"canSendAfter",this.fromState("can_send_after"));o(this,"canSendAfterDate",F(()=>{const t=this.authDate(),n=this.canSendAfter();return n&&t?new Date(t.getTime()+n*1e3):void 0}));o(this,"chat",this.fromState("chat"));o(this,"chatType",this.fromState("chat_type"));o(this,"chatInstance",this.fromState("chat_instance"));o(this,"hash",this.fromState("hash"));o(this,"queryId",this.fromState("query_id"));o(this,"raw",F(this._raw));o(this,"receiver",this.fromState("receiver"));o(this,"signature",this.fromState("signature"));o(this,"startParam",this.fromState("start_param"));o(this,"user",this.fromState("user"));o(this,"restoreFp");o(this,"restore");this.restoreFp=()=>d(t(),Z(Kr(()=>{},({raw:n,obj:r})=>{this._state.set(r),this._raw.set(n)}))),this.restore=X(this.restoreFp)}fromState(t){return F(()=>{const n=this._state();return n?n[t]:void 0})}}const mu=new gs({retrieveInitData(){return d(ci,In("obj",()=>d(Be(),Z(({tgWebAppData:e})=>e?He(e):Te))),In("raw",xt),Z(({obj:e,raw:t})=>d($a,Jr("obj",()=>e),Jr("raw",()=>t))))}});class vs{constructor({version:t,request:n,isTma:r}){o(this,"isOpened");o(this,"isSupported");o(this,"openSlugFp");o(this,"openSlug");o(this,"openUrlFp");o(this,"openUrl");const i=B({version:t,isTma:r,requires:"web_app_open_invoice",returns:"task"}),s=W(!1),a=()=>{s.set(!1)};this.isSupported=ie("web_app_open_invoice",t),this.isOpened=F(s),this.openSlugFp=i((u,l)=>d(this.isOpened()?N(new pt("Invoice is already opened")):R(void 0),he(()=>(s.set(!0),n("web_app_open_invoice","invoice_closed",{...l,params:{slug:u},capture:c=>u===c.slug}))),nn(c=>(a(),c),c=>(a(),c.status)))),this.openUrlFp=i((u,l)=>{const{hostname:c,pathname:h}=new URL(u,window.location.href);if(c!=="t.me")return N(new ne(`Link has unexpected hostname: ${c}`));const f=h.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return f?this.openSlugFp(f[2],l):N(new ne('Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"'))}),this.openUrl=m(this.openUrlFp),this.openSlug=m(this.openSlugFp)}}const bu=new vs(d(E(),Y,A));function gu({postEvent:e,...t}){return T((n,r={})=>{if(typeof n=="string")try{n=new URL(n)}catch(i){return O(new ne(`"${n.toString()}" is invalid URL`,i))}return e("web_app_open_link",{url:n.toString(),try_browser:r.tryBrowser,try_instant_view:r.tryInstantView})},{...t,returns:"either"})}const ws=gu(d(E(),z)),vu=m(ws);function wu({postEvent:e,version:t,...n}){return T(r=>{const i=r.toString();return i.match(/^https:\/\/t.me\/.+/)?pe("web_app_open_tg_link",Q(t))?(r=new URL(r),e("web_app_open_tg_link",{path_full:r.pathname+r.search})):(window.location.href=i,P(void 0)):O(new ne(`"${i}" is invalid URL`))},{...n,returns:"either"})}const mn=wu(d(E(),z,A)),yu=m(mn);function Cu({openTelegramLink:e,...t}){return T((n,r)=>e("https://t.me/share/url?"+new URLSearchParams({url:n,text:r||""}).toString().replace(/\+/g,"%20")),{...t,returns:"either"})}const ys=Cu({...E(),openTelegramLink:mn}),Fu=m(ys);function Su(e){let t=!1,n,r;return e.available&&(t=!0,n=e.access_requested,r=e.access_granted),{available:t,accessGranted:r||!1,accessRequested:n||!1}}class Cs{constructor({version:t,request:n,postEvent:r,storage:i,isTma:s,isPageReload:a}){o(this,"state");o(this,"isAvailable");o(this,"isAccessGranted");o(this,"isAccessRequested");o(this,"isMounted");o(this,"isSupported");o(this,"openSettingsFp");o(this,"openSettings");o(this,"requestLocationFp");o(this,"requestLocation");o(this,"mountFp");o(this,"mount");o(this,"unmount");const u=new be({initialState:{available:!1,accessGranted:!1,accessRequested:!1},onChange:i.set}),l=new ln({isPageReload:a,restoreState:i.get,onMounted:u.setState,initialState(v){return d(n("web_app_check_location","location_checked",v),V(Su))}}),c={version:t,requires:"web_app_check_location",isTma:s},h=B({...c,returns:"either"}),f=B({...c,returns:"task"}),b=B({...c,returns:"task",isMounted:l.isMounted});this.isAvailable=u.getter("available"),this.isAccessRequested=u.getter("accessRequested"),this.isAccessGranted=u.getter("accessGranted"),this.isSupported=ie("web_app_check_location",t),this.isMounted=l.isMounted,this.state=u.state,this.unmount=l.unmount,this.mountFp=f(l.mount),this.openSettingsFp=h(()=>r("web_app_open_location_settings")),this.requestLocationFp=b(v=>d(n("web_app_request_location","location_requested",v),V(y=>{if(!y.available)return u.setState({available:!1}),null;const{available:w,...g}=y;return g}))),this.mount=m(this.mountFp),this.openSettings=m(this.openSettingsFp),this.requestLocation=m(this.requestLocationFp)}}const ku=new Cs(d(E(),z,A,Y,ge("locationManager")));class Fs{constructor({defaults:t,...n}){o(this,"bgColor");o(this,"hasShineEffect");o(this,"isEnabled");o(this,"isLoaderVisible");o(this,"isVisible");o(this,"isMounted");o(this,"state");o(this,"text");o(this,"textColor");o(this,"showFp");o(this,"show");o(this,"hideFp");o(this,"hide");o(this,"enableFp");o(this,"enable");o(this,"enableShineEffectFp");o(this,"enableShineEffect");o(this,"disableFp");o(this,"disable");o(this,"disableShineEffectFp");o(this,"disableShineEffect");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"setTextColorFp");o(this,"setTextColor");o(this,"setTextFp");o(this,"setText");o(this,"showLoaderFp");o(this,"showLoader");o(this,"hideLoaderFp");o(this,"hideLoader");o(this,"setParamsFp");o(this,"setParams");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");const r=new ht({...n,version:"100",initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"},method:"web_app_setup_main_button",payload:s=>({has_shine_effect:s.hasShineEffect,is_visible:s.isVisible,is_active:s.isEnabled,is_progress_visible:s.isLoaderVisible,text:s.text,color:s.bgColor,text_color:s.textColor})}),i=(s,a)=>{const u=r.stateGetter(s);return F(()=>u()||Q(a))};this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.hasShineEffect=r.stateGetter("hasShineEffect"),this.isEnabled=r.stateGetter("isEnabled"),this.isLoaderVisible=r.stateGetter("isLoaderVisible"),this.text=r.stateGetter("text"),this.isVisible=r.stateGetter("isVisible"),this.isMounted=r.isMounted,this.state=r.state,[this.setBgColor,this.setBgColorFp]=r.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=r.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=r.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=r.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=r.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=r.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=r.stateBoolSetters("isVisible"),this.setParams=r.setState,this.setParamsFp=r.setStateFp,this.onClick=r.onClick,this.onClickFp=r.onClickFp,this.offClick=r.offClick,this.offClickFp=r.offClickFp,this.mount=r.mount,this.mountFp=r.mountFp,this.unmount=r.unmount}}function Ss(e,t,n){return d(cn(e,t),r=>({...r,defaults:n}))}const bn=Qe({});function gn(e,t){document.documentElement.style.setProperty(e,t)}function vn(e){document.documentElement.style.removeProperty(e)}function ks(e){return d(ot(e),Z(t=>Math.sqrt([.299,.587,.114].reduce((n,r,i)=>{const s=parseInt(t.slice(1+i*2,1+(i+1)*2),16);return n+s*s*r},0))<120))}const wn=X(ks);class Es{constructor({initialState:t,onChange:n,offChange:r,isTma:i,storage:s,isPageReload:a}){o(this,"accentTextColor");o(this,"bgColor");o(this,"buttonColor");o(this,"buttonTextColor");o(this,"bottomBarBgColor");o(this,"destructiveTextColor");o(this,"headerBgColor");o(this,"hintColor");o(this,"linkColor");o(this,"secondaryBgColor");o(this,"sectionBgColor");o(this,"sectionHeaderTextColor");o(this,"sectionSeparatorColor");o(this,"subtitleTextColor");o(this,"textColor");o(this,"_isCssVarsBound",W(!1));o(this,"isCssVarsBound",F(this._isCssVarsBound));o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"state");o(this,"isDark",F(()=>{const t=this.bgColor();return!t||wn(t)}));o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");const u=new be({initialState:{},onChange:s.set}),l=v=>{u.setState(v.theme_params)},c=new Ke({initialState:()=>P(Q(t)),isPageReload:a,onMounted(v){u.setState(v),n(l)},onUnmounted(){r(l)},restoreState:s.get}),h={isTma:i,returns:"either"},f=B(h),b=B({...h,isMounted:c.isMounted});this.accentTextColor=u.getter("accent_text_color"),this.bgColor=u.getter("bg_color"),this.buttonColor=u.getter("button_color"),this.buttonTextColor=u.getter("button_text_color"),this.bottomBarBgColor=u.getter("bottom_bar_bg_color"),this.destructiveTextColor=u.getter("destructive_text_color"),this.headerBgColor=u.getter("header_bg_color"),this.hintColor=u.getter("hint_color"),this.linkColor=u.getter("link_color"),this.secondaryBgColor=u.getter("secondary_bg_color"),this.sectionBgColor=u.getter("section_bg_color"),this.sectionHeaderTextColor=u.getter("section_header_text_color"),this.sectionSeparatorColor=u.getter("section_separator_color"),this.subtitleTextColor=u.getter("subtitle_text_color"),this.textColor=u.getter("text_color"),this.state=u.state,this.isMounted=c.isMounted,this.bindCssVarsFp=b(v=>{if(this._isCssVarsBound())return O(new lt);v||(v=g=>`--tg-theme-${Ii(g)}`);const y=g=>{Object.entries(u.state()).forEach(([S,_])=>{_&&g(S,_)})},w=()=>{y((g,S)=>{gn(v(g),S)})};return w(),u.state.sub(w),this._isCssVarsBound.set(!0),P(()=>{y(vn),u.state.unsub(w),this._isCssVarsBound.set(!1)})}),this.mountFp=f(c.mount),this.unmount=c.unmount,this.bindCssVars=m(this.bindCssVarsFp),this.mount=m(this.mountFp)}}const Ze=new Es({...d(E(),ge("themeParams")),offChange(e){ke("theme_changed",e)},onChange(e){ee("theme_changed",e)},initialState:bn}),Eu=new Fs(Ss("mainButton","main_button_pressed",{bgColor:F(()=>Ze.buttonColor()||"#2481cc"),textColor:F(()=>Ze.buttonTextColor()||"#ffffff")}));class $s{constructor({storage:t,isPageReload:n,version:r,postEvent:i,isTma:s,theme:a,onVisibilityChanged:u,offVisibilityChanged:l}){o(this,"isSupported");o(this,"isDark",F(()=>{const t=this.bgColorRgb();return t?wn(t):!1}));o(this,"isActive");o(this,"state");o(this,"isCssVarsBound");o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"bgColor");o(this,"bgColorRgb");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"headerColor");o(this,"headerColorRgb");o(this,"setHeaderColorFp");o(this,"setHeaderColor");o(this,"bottomBarColor");o(this,"bottomBarColorRgb");o(this,"setBottomBarColorFp");o(this,"setBottomBarColor");o(this,"closeFp");o(this,"close");o(this,"readyFp");o(this,"ready");const c=_=>{b.setState({isActive:_.is_visible})},h=_=>{[[this.headerColor,"web_app_set_header_color"],[this.bgColor,"web_app_set_background_color"],[this.bottomBarColor,"web_app_set_bottom_bar_color"]].forEach(([D,M])=>{const U=D();if(!Ue(U)&&(M==="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes(U))){const k=_[U];k&&i(M,{color:k})}})},f=new Ke({initialState(){const _=Q(a);return P({bgColor:_.bg_color||"bg_color",headerColor:_.header_bg_color||"header_bg_color",bottomBarColor:_.bottom_bar_bg_color||"bottom_bar_bg_color",isActive:!0})},isPageReload:n,onMounted:_=>{this.setBgColorFp.ifAvailable(_.bgColor),this.setBottomBarColorFp.ifAvailable(_.bottomBarColor),this.setHeaderColorFp.ifAvailable(_.headerColor),u(c),a.sub(h),b.setState(_)},onUnmounted(){l(c),a.unsub(h)},restoreState:t.get});this.isMounted=f.isMounted,this.mountFp=T(()=>{const _=()=>{};return d(f.mount(),Re(_,_))},{isTma:s,returns:"plain"}),this.mount=m(this.mountFp),this.unmount=f.unmount;const b=new be({initialState:{bgColor:"bg_color",bottomBarColor:"bottom_bar_bg_color",headerColor:"bg_color",isActive:!1},onChange:t.set});this.state=b.state;const v=_=>Ue(_)?_:Q(a)[_],y=_=>F(()=>v(_()));this.isActive=b.getter("isActive"),this.isSupported=F(()=>["web_app_set_header_color","web_app_set_background_color","web_app_set_bottom_bar_color"].some(_=>pe(_,Q(r))));const w=W(!1);this.isCssVarsBound=F(w),this.bindCssVarsFp=T(_=>{if(w())return O(new lt);const[D,M]=st(()=>{w.set(!1)}),U=(k,L)=>{const I=()=>{gn(k,L()||null)};I(),D(L.sub(I),vn.bind(null,k))};return _||(_=k=>`--tg-${jn(k)}`),U(_("bgColor"),this.bgColorRgb),U(_("bottomBarColor"),this.bottomBarColorRgb),U(_("headerColor"),this.headerColorRgb),w.set(!0),P(M)},{isTma:s,returns:"either",isMounted:this.isMounted}),this.bindCssVars=m(this.bindCssVarsFp);const g=_=>{const D=b.getter(_),M=y(D),U={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[_],k=T(L=>{if(L===D())return P(void 0);if(U==="web_app_set_header_color"&&(L==="bg_color"||L==="secondary_bg_color"))return i("web_app_set_header_color",{color_key:L});const I=v(L);return d(I?i(U,{color:I}):O(new ss(L)),Z(()=>{b.setState({[_]:I})}))},{isTma:s,version:r,requires:U,isMounted:this.isMounted,returns:"either",supports:_==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:Ue}}:void 0});return[D,M,m(k),k]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=g("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=g("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=g("bottomBarColor");const S=B({isTma:s,returns:"either"});this.closeFp=S(_=>i("web_app_close",{return_back:_})),this.close=m(this.closeFp),this.readyFp=S(()=>i("web_app_ready")),this.ready=m(this.readyFp)}}const As=new $s({...d(E(),z,A,ge("miniApp")),offVisibilityChanged(e){ke("visibility_changed",e)},onVisibilityChanged(e){ee("visibility_changed",e)},theme:Ze.state});function $u(e){const t=e.message.trim(),n=(e.title||"").trim(),r=e.buttons||[];if(n.length>64)return O(new ne(`Invalid title: ${n}`));if(!t||t.length>256)return O(new ne(`Invalid message: ${t}`));if(r.length>3)return O(new ne(`Invalid buttons count: ${r.length}`));const i=[];if(!r.length)i.push({type:"close",id:""});else for(let s=0;s<r.length;s++){const a=r[s],u=a.id||"";if(u.length>64)return O(new ne(`Button with index ${s} has invalid id: ${u}`));if(!a.type||a.type==="default"||a.type==="destructive"){const l=a.text.trim();if(!l||l.length>64)return O(new ne(`Button with index ${s} has invalid text: ${l}`));i.push({type:a.type,text:l,id:u})}else i.push({type:a.type,id:u})}return P({title:n,message:t,buttons:i})}class Is{constructor({version:t,isTma:n,request:r}){o(this,"isOpened");o(this,"isSupported");o(this,"showFp");o(this,"show");const i=W(!1),s=()=>{i.set(!1)},a=B({version:t,isTma:n,requires:"web_app_open_popup",returns:"task"});this.isSupported=ie("web_app_open_popup",t),this.isOpened=F(i),this.showFp=a(u=>d(this.isOpened()?N(new pt("A popup is already opened")):R(void 0),Pe(()=>Yr($u(u))),he(l=>(i.set(!0),r("web_app_open_popup","popup_closed",{...u,params:l}))),nn(l=>(s(),l),l=>(s(),l.button_id)))),this.show=m(this.showFp)}}const Au=new Is(d(E(),Y,A));function Iu({request:e,...t}){return T(n=>d(e("web_app_request_phone","phone_requested",n),V(r=>r.status)),{...t,requires:"web_app_request_phone",returns:"task"})}const yn=Iu(d(E(),A,Y)),qu=m(yn);function Bu({invokeCustomMethod:e,requestPhoneAccess:t,...n}){const r=a=>d(e("getRequestedContact",{},{...a,timeout:(a||{}).timeout||5e3}),Pe(u=>{const l=It(C(),u);if(!l.success)return N(new ze(u,l.issues));if(!l.output)return R(void 0);const c=It(Vt(j({contact:me(j({user_id:de(),phone_number:C(),first_name:C(),last_name:$(C())})),auth_date:se(C(),ue(h=>new Date(Number(h)*1e3)),tt()),hash:C()})),l.output);return c.success?R({raw:l.output,parsed:c.output}):N(new ze(l.output,c.issues))})),i=a=>d(r(a),xa(u=>ze.is(u)?O(u):P(void 0),u=>P(u))),s=a=>De(async(u,l,c)=>{let h=50;for(;!c.isRejected;){const f=await i(c)();if(f._tag==="Left")return l(f.left);if(f.right)return u(f.right);await new Promise(b=>setTimeout(b,h)),h+=50}},a);return T(a=>De.fn(u=>d(i(u),he(l=>l?R(l):d(t(u),Pe(c=>c==="sent"?s(u):N(new sn("User denied access")))))),a),{...n,returns:"task",requires:"web_app_request_phone"})}function Tu({requestContact:e,...t}){return T(e,{...t,returns:"task",requires:"web_app_request_phone"})}const Cn=Bu({...d(E(),_n,A),requestPhoneAccess:yn}),Pu=m(Cn),qs=Tu({...d(E(),A),requestContact(e){return d(Cn(e),V(t=>t.parsed))}}),Mu=m(qs);function Lu({request:e,...t}){return T(n=>d(e("web_app_request_write_access","write_access_requested",n),V(r=>r.status)),{...t,requires:"web_app_request_write_access",returns:"task"})}const Bs=Lu(d(E(),A,Y)),Vu=m(Bs);class Ts{constructor({version:t,onClosed:n,onTextReceived:r,isTma:i,postEvent:s}){o(this,"isOpened");o(this,"isSupported");o(this,"captureFp");o(this,"capture");o(this,"closeFp");o(this,"close");o(this,"openFp");o(this,"open");const a={version:t,requires:"web_app_open_scan_qr_popup",isTma:i},u=B({...a,returns:"either"}),l=B({...a,returns:"task"}),c=W(!1),h=()=>{c.set(!1)};this.isSupported=ie("web_app_open_scan_qr_popup",t),this.isOpened=F(c),this.captureFp=l(f=>{let b;return d(this.openFp({...f,onCaptured:v=>{f.capture(v)&&(b=v,this.close())}}),V(()=>b))}),this.closeFp=u(()=>d(s("web_app_close_scan_qr_popup"),Z(h))),this.openFp=l(f=>d(this.isOpened()?N(new pt("The QR Scanner is already opened")):async()=>s("web_app_open_scan_qr_popup",{text:f.text}),Pe(()=>{const[b,v]=st(),y=w=>(v(),w);return d(De(w=>{b(n(w),r(f.onCaptured))},f),nn(y,y))}))),this.open=m(this.openFp),this.capture=m(this.captureFp),this.close=m(this.closeFp)}}const Ru=new Ts({...d(E(),z,A),onClosed(e){return ee("scan_qr_popup_closed",e)},onTextReceived(e){return ee("qr_text_received",t=>{e(t.data)})}});class Ps{constructor({defaults:t,...n}){o(this,"isSupported");o(this,"position");o(this,"bgColor");o(this,"hasShineEffect");o(this,"isEnabled");o(this,"isLoaderVisible");o(this,"isVisible");o(this,"isMounted");o(this,"state");o(this,"text");o(this,"textColor");o(this,"showFp");o(this,"show");o(this,"hideFp");o(this,"hide");o(this,"enableFp");o(this,"enable");o(this,"enableShineEffectFp");o(this,"enableShineEffect");o(this,"disableFp");o(this,"disable");o(this,"disableShineEffectFp");o(this,"disableShineEffect");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"setTextColorFp");o(this,"setTextColor");o(this,"setTextFp");o(this,"setText");o(this,"setPositionFp");o(this,"setPosition");o(this,"showLoaderFp");o(this,"showLoader");o(this,"hideLoaderFp");o(this,"hideLoader");o(this,"setParamsFp");o(this,"setParams");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");const r=new ht({...n,initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Cancel",position:"left"},method:"web_app_setup_secondary_button",payload:s=>({has_shine_effect:s.hasShineEffect,is_visible:s.isVisible,is_active:s.isEnabled,is_progress_visible:s.isLoaderVisible,text:s.text,color:s.bgColor,text_color:s.textColor,position:s.position})}),i=(s,a)=>{const u=r.stateGetter(s);return F(()=>u()||Q(a))};this.isSupported=ie("web_app_setup_secondary_button",n.version),this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.position=r.stateGetter("position"),this.hasShineEffect=r.stateGetter("hasShineEffect"),this.isEnabled=r.stateGetter("isEnabled"),this.isLoaderVisible=r.stateGetter("isLoaderVisible"),this.text=r.stateGetter("text"),this.isVisible=r.stateGetter("isVisible"),this.isMounted=r.isMounted,this.state=r.state,[this.setPosition,this.setPositionFp]=r.stateSetters("position"),[this.setBgColor,this.setBgColorFp]=r.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=r.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=r.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=r.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=r.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=r.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=r.stateBoolSetters("isVisible"),this.setParams=r.setState,this.setParamsFp=r.setStateFp,this.onClick=r.onClick,this.onClickFp=r.onClickFp,this.offClick=r.offClick,this.offClickFp=r.offClickFp,this.mount=r.mount,this.mountFp=r.mountFp,this.unmount=r.unmount}}const Ou=new Ps(Ss("secondaryButton","secondary_button_pressed",{bgColor:F(()=>As.bottomBarColorRgb()||"#000000"),textColor:F(()=>Ze.buttonColor()||"#2481cc")}));class Ms{constructor(t){o(this,"isVisible");o(this,"isMounted");o(this,"isSupported");o(this,"hideFp");o(this,"hide");o(this,"showFp");o(this,"show");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const n=new ht({...t,method:"web_app_setup_settings_button",payload:r=>({is_visible:r.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}const ju=new Ms(cn("settingsButton","settings_button_pressed"));class Ls{constructor({postEvent:t,storage:n,isTma:r,isPageReload:i,version:s}){o(this,"isSupported");o(this,"isVerticalEnabled");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"disableVerticalFp");o(this,"disableVertical");o(this,"enableVerticalFp");o(this,"enableVertical");const a=new be({initialState:{isVerticalEnabled:!1},onChange(b){n.set(b)}}),u=new Ke({initialState:{isVerticalEnabled:!1},isPageReload:i,onMounted:a.setState,restoreState:n.get}),l={requires:"web_app_setup_swipe_behavior",isTma:r,version:s},c=B({...l,returns:"plain"}),h=B({...l,isMounted:u.isMounted,returns:"either"}),f=b=>{const v={isVerticalEnabled:b};return a.hasDiff(v)?d(t("web_app_setup_swipe_behavior",{allow_vertical_swipe:b}),Z(()=>{a.setState(v)})):P(void 0)};this.isSupported=ie("web_app_setup_swipe_behavior",s),this.isVerticalEnabled=a.getter("isVerticalEnabled"),this.isMounted=u.isMounted,this.disableVerticalFp=h(()=>f(!1)),this.enableVerticalFp=h(()=>f(!0)),this.mountFp=c(()=>{const b=()=>{};return d(u.mount(),Re(b,b))}),this.unmount=u.unmount,this.disableVertical=m(this.disableVerticalFp),this.enableVertical=m(this.enableVerticalFp),this.mount=m(this.mountFp)}}const Du=new Ls(d(E(),z,A,ge("swipeBehavior")));async function Uu(e){try{const{clipboard:n}=navigator;if(n)return await n.writeText(e)}catch{}const t=document.createElement("textarea");t.value=e,t.style.top="0",t.style.left="0",t.style.position="fixed",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}finally{document.body.removeChild(t)}}function xu({request:e,...t}){return T((n,r,i)=>d(e("web_app_request_file_download","file_download_requested",{...i,params:{url:n,file_name:r}}),he(s=>s.status==="downloading"?R(void 0):N(new sn("User denied the action")))),{...t,requires:"web_app_request_file_download",returns:"task"})}const Vs=xu(d(E(),Y,A)),Gu=m(Vs);function Wu({invokeCustomMethod:e,...t}){return T(n=>d(e("getCurrentTime",{},n),he(r=>{const i=It(se(de(),Ct(),ue(s=>new Date(s*1e3)),tt()),r);return i.success?R(i.output):N(new ze(r,i.issues))})),{...t,requires:"web_app_invoke_custom_method",returns:"task"})}const Rs=Wu(d(E(),_n,A)),Hu=m(Rs);function Nu({postEvent:e,...t}){return T(()=>e("web_app_hide_keyboard"),{...t,returns:"either",requires:"web_app_hide_keyboard"})}const Os=Nu(d(E(),z,A)),zu=m(Os);function Ku({request:e,createRequestId:t,...n}){return T(r=>{const i=t();return d(e("web_app_read_text_from_clipboard","clipboard_text_received",{...r,params:{req_id:i},capture:Gr(i)}),V(({data:s=null})=>s))},{...n,requires:"web_app_read_text_from_clipboard",returns:"task"})}const js=Ku({...d(E(),A,Y),createRequestId:dn}),Ju=m(js);function Ds(e){const t={},n=e.match(/Telegram-Android(?:\/([^ ]+))?(?: (\([^)]+\))?|$)/);if(n){const[,r,i]=n;r&&(t.appVersion=r),i&&i.slice(1,i.length-1).split(";").forEach(s=>{const[a,u]=s.trim().split(" ");if(a==="Android")t.androidVersion=u;else if(a==="SDK"){const l=parseInt(u,10);l&&(t.sdkVersion=l)}else u?(t.manufacturer=a,t.model=u):t.performanceClass=a})}return t}function Qu(){return Ds(navigator.userAgent)}function Zu({postEvent:e,...t}){return T(n=>{const{size:r}=new Blob([n]);return!r||r>4096?O(new ne(r?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data")):e("web_app_data_send",{data:n})},{...t,returns:"either"})}const Us=Zu(d(E(),z)),Yu=m(Us);function Xu({request:e,...t}){return T((n,r)=>d(e("web_app_send_prepared_message",["prepared_message_failed","prepared_message_sent"],{...r,params:{id:n}}),he(i=>i&&"error"in i?N(new rs(i.error)):R(void 0))),{...t,requires:"web_app_send_prepared_message",returns:"task"})}const xs=Xu(d(E(),Y,A)),ec=m(xs);function tc({postEvent:e,...t}){return T((n,r={})=>e("web_app_share_to_story",{text:r.text,media_url:n,widget_link:r.widgetLink}),{...t,requires:"web_app_share_to_story",returns:"either"})}const Gs=tc(d(E(),z,A)),nc=m(Gs),Fn=Qe(!1);function rc({isInlineMode:e,postEvent:t,...n}){return T((r,i)=>t("web_app_switch_inline_query",{query:r,chat_types:i||[]}),{...n,requires:{every:["web_app_switch_inline_query",()=>Q(e)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}const Ws=rc({...d(E(),z,A),isInlineMode:Fn}),sc=m(Ws);class Hs{constructor({storage:t,isPageReload:n,onContentSafeAreaInsetsChanged:r,onSafeAreaInsetsChanged:i,onViewportChanged:s,onFullscreenChanged:a,offContentSafeAreaInsetsChanged:u,offFullscreenChanged:l,offSafeAreaInsetsChanged:c,offViewportChanged:h,request:f,isViewportStable:b,isFullscreen:v,isTma:y,version:w,postEvent:g}){o(this,"state");o(this,"height");o(this,"stableHeight");o(this,"width");o(this,"isExpanded");o(this,"isStable",F(()=>this.height()===this.stableHeight()));o(this,"contentSafeAreaInsets");o(this,"contentSafeAreaInsetTop");o(this,"contentSafeAreaInsetLeft");o(this,"contentSafeAreaInsetRight");o(this,"contentSafeAreaInsetBottom");o(this,"safeAreaInsets");o(this,"safeAreaInsetTop");o(this,"safeAreaInsetLeft");o(this,"safeAreaInsetRight");o(this,"safeAreaInsetBottom");o(this,"isFullscreen");o(this,"requestFullscreenFp");o(this,"requestFullscreen");o(this,"exitFullscreenFp");o(this,"exitFullscreen");o(this,"isCssVarsBound");o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"expandFp");o(this,"expand");const S={top:0,right:0,left:0,bottom:0},_=new be({initialState:{contentSafeAreaInsets:S,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:S,stableHeight:0,width:0},onChange:t.set}),D=q=>{_.setState({isExpanded:q.is_expanded,height:q.height,width:q.width,stableHeight:q.is_state_stable?q.height:void 0})},M=q=>{_.setState({isFullscreen:q.is_fullscreen})},U=q=>{_.setState({safeAreaInsets:q})},k=q=>{_.setState({contentSafeAreaInsets:q})},L=new ln({initialState(q){const $e=fe=>()=>{const[ve,re]=fe==="safe-area"?["web_app_request_safe_area","safe_area_changed"]:["web_app_request_content_safe_area","content_safe_area_changed"];return pe(ve,Q(w))?f(ve,re,q):R({top:0,left:0,right:0,bottom:0})},G=fe=>()=>typeof fe=="boolean"?R(fe):Yr(fe());return d(Qa,ct("safeAreaInsets",$e("safe-area")),ct("contentSafeAreaInsets",$e("content-safe-area")),ct("isFullscreen",G(v)),ct("isViewportStable",G(b)),Pe(({isViewportStable:fe,...ve})=>fe?R({...ve,height:window.innerHeight,isExpanded:!0,stableHeight:window.innerHeight,width:window.innerWidth}):d(f("web_app_request_viewport","viewport_changed",q),V(re=>({...ve,height:re.height,isExpanded:re.is_expanded,stableHeight:re.is_state_stable?re.height:0,width:re.width})))))},isPageReload:n,onMounted(q){s(D),a(M),i(U),r(k),_.setState(q)},onUnmounted(){h(D),l(M),c(U),u(k)},restoreState:t.get}),I=q=>F(()=>this.safeAreaInsets()[q]),x=q=>F(()=>this.contentSafeAreaInsets()[q]);this.state=_.state,this.height=_.getter("height"),this.stableHeight=_.getter("stableHeight"),this.width=_.getter("width"),this.isExpanded=_.getter("isExpanded"),this.safeAreaInsets=_.getter("safeAreaInsets"),this.safeAreaInsetTop=I("top"),this.safeAreaInsetBottom=I("bottom"),this.safeAreaInsetLeft=I("left"),this.safeAreaInsetRight=I("right"),this.contentSafeAreaInsets=_.getter("contentSafeAreaInsets"),this.contentSafeAreaInsetTop=x("top"),this.contentSafeAreaInsetBottom=x("bottom"),this.contentSafeAreaInsetLeft=x("left"),this.contentSafeAreaInsetRight=x("right");const Le=B({isTma:y,returns:"task"}),Ye=B({isTma:y,returns:"either"}),uc=B({isTma:y,requires:"web_app_request_fullscreen",version:w,returns:"task"}),zs=q=>uc($e=>d(f(q?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],$e),he(G=>"error"in G&&G.error!=="ALREADY_FULLSCREEN"?N(new ns(G.error)):(_.setState({isFullscreen:"is_fullscreen"in G?G.is_fullscreen:!0}),R(void 0)))));this.isMounted=L.isMounted,this.mountFp=Le(L.mount),this.mount=m(this.mountFp),this.isFullscreen=_.getter("isFullscreen"),this.requestFullscreenFp=zs(!0),this.requestFullscreen=m(this.requestFullscreenFp),this.exitFullscreenFp=zs(!1),this.exitFullscreen=m(this.exitFullscreenFp);const ft=W(!1);this.isCssVarsBound=F(ft),this.bindCssVarsFp=Ye(q=>{if(ft())return O(new lt);q||(q=G=>`--tg-viewport-${jn(G)}`);const $e=[["height",this.height],["stableHeight",this.stableHeight],["width",this.width],["safeAreaInsetTop",this.safeAreaInsetTop],["safeAreaInsetBottom",this.safeAreaInsetBottom],["safeAreaInsetLeft",this.safeAreaInsetLeft],["safeAreaInsetRight",this.safeAreaInsetRight],["contentSafeAreaInsetTop",this.contentSafeAreaInsetTop],["contentSafeAreaInsetBottom",this.contentSafeAreaInsetBottom],["contentSafeAreaInsetLeft",this.contentSafeAreaInsetLeft],["contentSafeAreaInsetRight",this.contentSafeAreaInsetRight]].reduce((G,[fe,ve])=>{const re=q(fe);if(re){const Ks=()=>{gn(re,`${ve()}px`)};G.push({update:Ks,removeListener:ve.sub(Ks),cssVar:re})}return G},[]);return $e.forEach(G=>{G.update()}),ft.set(!0),P(()=>{$e.forEach(G=>{G.removeListener(),vn(G.cssVar)}),ft.set(!1)})}),this.bindCssVars=m(this.bindCssVarsFp),this.expandFp=Ye(()=>g("web_app_expand")),this.expand=m(this.expandFp)}}function ic(){const e=s=>({on:a=>{ee(s,a)},off:a=>{ke(s,a)}}),t=e("viewport_changed"),n=e("fullscreen_changed"),r=e("safe_area_changed"),i=e("content_safe_area_changed");return new Hs({...d(E(),ge("viewport"),A,z,Y),isFullscreen(){return d(Be(),Z(s=>!!s.tgWebAppFullscreen))},isViewportStable(){return d(Be(),Z(s=>["macos","tdesktop","unigram","webk","weba","web"].includes(s.tgWebAppPlatform)))},offContentSafeAreaInsetsChanged:i.off,offFullscreenChanged:n.off,offSafeAreaInsetsChanged:r.off,offViewportChanged:t.off,onContentSafeAreaInsetsChanged:i.on,onFullscreenChanged:n.on,onSafeAreaInsetsChanged:r.on,onViewportChanged:t.on})}const oc=ic();function Ns(e={}){const{version:t,isInlineMode:n,themeParams:r}=e;if(t&&typeof n=="boolean"&&r)un.set(t),Fn.set(n),bn.set(r);else{const u=d(Be(),An(l=>l,l=>{un.set(t||l.tgWebAppVersion),Fn.set(typeof n=="boolean"?n:!!l.tgWebAppBotInline),bn.set(r||l.tgWebAppThemeParams)}));if(u)return O(u)}e.postEvent&&os.set(e.postEvent);const[i,s]=st(ee("reload_iframe",()=>{le().log("Received a request to reload the page"),as("iframe_will_reload"),window.location.reload()})),{acceptCustomStyles:a=!0}=e;if(a){const u=document.createElement("style");u.id="telegram-custom-styles",document.head.appendChild(u),i(ee("set_custom_style",l=>{u.innerHTML=l}),()=>{document.head.removeChild(u)})}return d(Me("iframe_ready",{reload_supported:!0}),Z(()=>(le().log("The package was initialized"),s)))}const ac=X(Ns);return p.AccessDeniedError=sn,p.BackButton=is,p.Biometry=cs,p.CSSVarsBoundError=lt,p.CancelledError=Rn,p.ClosingBehavior=ls,p.CloudStorage=ps,p.ConcurrentCallError=pt,p.FullscreenFailedError=ns,p.FunctionUnavailableError=es,p.HapticFeedback=_s,p.InitData=gs,p.InvalidArgumentsError=ne,p.InvalidEnvError=Ya,p.InvalidLaunchParamsError=Br,p.Invoice=vs,p.InvokeCustomMethodFailedError=Pr,p.LaunchParamsRetrieveError=qr,p.LocationManager=Cs,p.MainButton=Fs,p.MethodParameterUnsupportedError=Ir,p.MethodUnsupportedError=Ar,p.MiniApp=$s,p.NotAvailableError=Xr,p.Popup=Is,p.QrScanner=Ts,p.SecondaryButton=Ps,p.SetEmojiStatusError=ts,p.SettingsButton=Ms,p.ShareMessageError=rs,p.SwipeBehavior=Ls,p.ThemeParams=Es,p.TimeoutError=Bt,p.UnknownEnvError=Tr,p.UnknownThemeParamsKeyError=ss,p.ValidationError=ze,p.Viewport=Hs,p.addToHomeScreen=fu,p.addToHomeScreenFp=ms,p.applyPolyfills=ha,p.backButton=nu,p.biometry=su,p.checkHomeScreenStatus=_u,p.checkHomeScreenStatusFp=bs,p.closingBehavior=iu,p.cloudStorage=ou,p.copyTextToClipboard=Uu,p.createLogger=xn,p.createPostEvent=la,p.createRequestId=dn,p.createStartParam=_a,p.createStartParamFp=Nr,p.debug=Ur,p.decodeBase64Url=fa,p.decodeBase64UrlFp=Qt,p.decodeStartParam=ma,p.decodeStartParamFp=zr,p.deepSnakeToCamelObjKeys=Tt,p.downloadFile=Gu,p.downloadFileFp=Vs,p.encodeBase64Url=Zt,p.getCurrentTime=Hu,p.getCurrentTimeFp=Rs,p.getReleaseVersion=Jt,p.hapticFeedback=pu,p.hideKeyboard=zu,p.hideKeyboardFp=Os,p.init=ac,p.initData=mu,p.initFp=Ns,p.invoice=bu,p.invokeCustomMethod=hs,p.isAnyRGB=ir,p.isColorDark=wn,p.isColorDarkFp=ks,p.isRGB=Ue,p.isRGBA=sr,p.isRGBAShort=rr,p.isRGBShort=nr,p.isSafeToCreateStartParam=ba,p.isTMA=aa,p.isTMAFp=Kt,p.locationManager=ku,p.logger=le,p.mainButton=Eu,p.miniApp=As,p.mockTelegramEnv=ua,p.off=ke,p.offAll=ta,p.on=ee,p.openLink=vu,p.openLinkFp=ws,p.openTelegramLink=yu,p.openTelegramLinkFp=mn,p.parseInitDataQuery=ho,p.parseInitDataQueryFp=pr,p.parseLaunchParamsQuery=hr,p.parseLaunchParamsQueryFp=at,p.popup=Au,p.postEvent=as,p.postEventFp=Me,p.qrScanner=Ru,p.readTextFromClipboard=Ju,p.readTextFromClipboardFp=js,p.request=ru,p.requestContact=Mu,p.requestContactComplete=Pu,p.requestContactCompleteFp=Cn,p.requestContactFp=qs,p.requestEmojiStatusAccess=uu,p.requestEmojiStatusAccessFp=fs,p.requestFp=hn,p.requestPhoneAccess=qu,p.requestPhoneAccessFp=yn,p.requestWriteAccess=Vu,p.requestWriteAccessFp=Bs,p.retrieveAndroidDeviceData=Qu,p.retrieveAndroidDeviceDataFrom=Ds,p.retrieveLaunchParams=Jo,p.retrieveLaunchParamsFp=Be,p.retrieveRawInitData=Qo,p.retrieveRawInitDataFp=xt,p.retrieveRawLaunchParams=Zo,p.retrieveRawLaunchParamsFp=We,p.secondaryButton=Ou,p.sendData=Yu,p.sendDataFp=Us,p.serializeInitDataQuery=dr,p.serializeLaunchParamsQuery=_r,p.setDebug=ra,p.setEmojiStatus=lu,p.setEmojiStatusFp=ds,p.setTargetOrigin=sa,p.settingsButton=ju,p.shareMessage=ec,p.shareMessageFp=xs,p.shareStory=nc,p.shareStoryFp=Gs,p.shareURL=Fu,p.shareURLFp=ys,p.supports=pe,p.swipeBehavior=Du,p.switchInlineQuery=sc,p.switchInlineQueryFp=Ws,p.targetOrigin=xr,p.themeParams=Ze,p.toRGB=oo,p.toRGBFp=ar,p.toRGBFull=ao,p.toRGBFullFp=ot,p.viewport=oc,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"}),p}({});
|
|
1
|
+
var cc=Object.defineProperty;var lc=(p,oe,we)=>oe in p?cc(p,oe,{enumerable:!0,configurable:!0,writable:!0,value:we}):p[oe]=we;var o=(p,oe,we)=>lc(p,typeof oe!="symbol"?oe+"":oe,we);this.tmajs=this.tmajs||{};this.tmajs.sdk=function(p){"use strict";var oe=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function we(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function d(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Ve=function(e,t){var n=typeof e=="number"?function(r){return r.length>=e}:e;return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,oe([i],r,!1))}}},Js={_tag:"None"},Qs=function(e){return{_tag:"Some",value:e}},Zs=function(e){return e._tag==="Left"},kn=function(e){return{_tag:"Left",left:e}},En=function(e){return{_tag:"Right",right:e}},_t={};function Ys(e,t){return function(n){return function(r){return e.ap(e.map(r,function(i){return function(s){return t.ap(i,s)}}),n)}}}function Xs(e,t){return function(n){return function(r){return e.map(r,function(i){return t.map(i,n)})}}}function mt(e){return function(t,n){return function(r){return e.chain(r,function(i){return e.map(n(i),function(s){var a;return Object.assign({},i,(a={},a[t]=s,a))})})}}}var O=kn,P=En,ei=Ve(2,function(e,t){return ye(e)?e:t(e.right)}),bt=function(e,t){return d(e,Z(t))},$n=function(e,t){return d(e,si(t))},gt="Either",Z=function(e){return function(t){return ye(t)?t:P(e(t.right))}},ti={URI:gt,map:bt},ni=P,ri=function(e){return function(t){return ye(t)?t:ye(e)?e:P(t.right(e.right))}},si=ri,ii={URI:gt,map:bt,ap:$n},oi={URI:gt,map:bt,ap:$n,chain:ei},ai=function(e,t){return function(n){return ye(n)?O(e(n.left)):P(t(n.right))}},ye=Zs,An=function(e,t){return function(n){return ye(n)?e(n.left):t(n.right)}},Re=An,ui=function(e,t){try{return P(e())}catch(n){return O(t(n))}},ci=ni(_t),li=mt(oi),In=li;let Ae;function pi(e,t){Ae?Ae.set(e,t):t()}function Xe(e){if(Ae)return e();Ae=new Map;try{e()}finally{Ae.forEach(t=>t()),Ae=void 0}}function W(e,t){t||(t={});const n=t.equals||Object.is;let r=[],i=e;const s=c=>{if(!n(i,c)){const h=i;i=c,pi(l,()=>{[...r].forEach(([f,b])=>{f(c,h),b&&u(f,!0)})})}};function a(c){const h=typeof c!="object"?{once:c}:c;return{once:h.once||!1,signal:h.signal||!1}}const u=(c,h)=>{const f=a(h),b=r.findIndex(([v,y])=>v===c&&y.once===f.once&&y.signal===f.signal);b>=0&&r.splice(b,1)},l=Object.assign(function(){return hi(l),i},{destroy(){r=[]},set:s,reset(){s(e)},sub(c,h){return r.push([c,a(h)]),()=>u(c,h)},unsub:u,unsubAll(){r=r.filter(c=>c[1].signal)}});return l}const Oe=[];function hi(e){Oe.length&&Oe[Oe.length-1].add(e)}function F(e,t){let n=new Set,r;function i(){return r||(r=W(a(),t))}function s(){i().set(a())}function a(){n.forEach(c=>{c.unsub(s,{signal:!0})});const u=new Set;let l;Oe.push(u);try{l=e()}finally{Oe.pop()}return u.forEach(c=>{c.sub(s,{signal:!0})}),n=u,l}return Object.assign(function(){return i()()},{destroy(){i().destroy()},sub(...u){return i().sub(...u)},unsub(...u){i().unsub(...u)},unsubAll(...u){i().unsubAll(...u)}})}var ae;function vt(e){return{lang:(e==null?void 0:e.lang)??(ae==null?void 0:ae.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(ae==null?void 0:ae.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(ae==null?void 0:ae.abortPipeEarly)}}var wt;function fi(e){return wt==null?void 0:wt.get(e)}var yt;function di(e){return yt==null?void 0:yt.get(e)}var Ct;function _i(e,t){var n;return(n=Ct==null?void 0:Ct.get(e))==null?void 0:n.get(t)}function mi(e){var n,r;const t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&((r=(n=Object.getPrototypeOf(e))==null?void 0:n.constructor)==null?void 0:r.name))??"null":t}function K(e,t,n,r,i){const s=i&&"input"in i?i.input:n.value,a=(i==null?void 0:i.expected)??e.expects??null,u=(i==null?void 0:i.received)??mi(s),l={kind:e.kind,type:e.type,input:s,expected:a,received:u,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${u}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??_i(e.reference,l.lang)??(c?di(l.lang):null)??r.message??fi(l.lang);h!==void 0&&(l.message=typeof h=="function"?h(l):h),c&&(n.typed=!1),n.issues?n.issues.push(l):n.issues=[l]}function J(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},vt())}}}function qn(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function bi(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}var gi=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function et(e,t){return{kind:"validation",type:"check",reference:et,async:!1,expects:null,requirement:e,message:t,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&K(this,"input",n,r),n}}}function Ft(e){return{kind:"validation",type:"integer",reference:Ft,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&K(this,"integer",t,n),t}}}function ue(e){return{kind:"transformation",type:"transform",reference:ue,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function vi(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}function St(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function kt(e,t){return!e["~run"]({value:t},{abortEarly:!0}).issues}function Bn(){return{kind:"schema",type:"any",reference:Bn,expects:"any",async:!1,get"~standard"(){return J(this)},"~run"(e){return e.typed=!0,e}}}function Tn(e,t){return{kind:"schema",type:"array",reference:Tn,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){var s;const i=n.value;if(Array.isArray(i)){n.typed=!0,n.value=[];for(let a=0;a<i.length;a++){const u=i[a],l=this.item["~run"]({value:u},r);if(l.issues){const c={type:"array",origin:"value",input:i,key:a,value:u};for(const h of l.issues)h.path?h.path.unshift(c):h.path=[c],(s=n.issues)==null||s.push(h);if(n.issues||(n.issues=l.issues),r.abortEarly){n.typed=!1;break}}l.typed||(n.typed=!1),n.value.push(l.value)}}else K(this,"type",n,r);return n}}}function Ce(e){return{kind:"schema",type:"boolean",reference:Ce,expects:"boolean",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:K(this,"type",t,n),t}}}function tt(e){return{kind:"schema",type:"date",reference:tt,expects:"Date",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return t.value instanceof Date?isNaN(t.value)?K(this,"type",t,n,{received:'"Invalid Date"'}):t.typed=!0:K(this,"type",t,n),t}}}function Et(e){return{kind:"schema",type:"function",reference:Et,expects:"Function",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="function"?t.typed=!0:K(this,"type",t,n),t}}}function $t(e,t){return{kind:"schema",type:"instance",reference:$t,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){return n.value instanceof this.class?n.typed=!0:K(this,"type",n,r),n}}}function j(e,t){return{kind:"schema",type:"loose_object",reference:j,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){var s;const i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(const a in this.entries){const u=this.entries[a];if(a in i||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){const l=a in i?i[a]:St(u),c=u["~run"]({value:l},r);if(c.issues){const h={type:"object",origin:"value",input:i,key:a,value:l};for(const f of c.issues)f.path?f.path.unshift(h):f.path=[h],(s=n.issues)==null||s.push(f);if(n.issues||(n.issues=c.issues),r.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value[a]=c.value}else if(u.fallback!==void 0)n.value[a]=vi(u);else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(K(this,"key",n,r,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:i,key:a,value:i[a]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly)for(const a in i)qn(i,a)&&!(a in this.entries)&&(n.value[a]=i[a])}else K(this,"type",n,r);return n}}}function Ie(e,t){return{kind:"schema",type:"nullish",reference:Ie,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return J(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=St(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function de(e){return{kind:"schema",type:"number",reference:de,expects:"number",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:K(this,"type",t,n),t}}}function $(e,t){return{kind:"schema",type:"optional",reference:$,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return J(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=St(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function At(e,t,n){return{kind:"schema",type:"record",reference:At,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return J(this)},"~run"(r,i){var a,u;const s=r.value;if(s&&typeof s=="object"){r.typed=!0,r.value={};for(const l in s)if(qn(s,l)){const c=s[l],h=this.key["~run"]({value:l},i);if(h.issues){const b={type:"object",origin:"key",input:s,key:l,value:c};for(const v of h.issues)v.path=[b],(a=r.issues)==null||a.push(v);if(r.issues||(r.issues=h.issues),i.abortEarly){r.typed=!1;break}}const f=this.value["~run"]({value:c},i);if(f.issues){const b={type:"object",origin:"value",input:s,key:l,value:c};for(const v of f.issues)v.path?v.path.unshift(b):v.path=[b],(u=r.issues)==null||u.push(v);if(r.issues||(r.issues=f.issues),i.abortEarly){r.typed=!1;break}}(!h.typed||!f.typed)&&(r.typed=!1),h.typed&&(r.value[h.value]=f.value)}}else K(this,"type",r,i);return r}}}function C(e){return{kind:"schema",type:"string",reference:C,expects:"string",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:K(this,"type",t,n),t}}}function Pn(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function nt(e,t){return{kind:"schema",type:"union",reference:nt,expects:bi(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){let i,s,a;for(const u of this.options){const l=u["~run"]({value:n.value},r);if(l.typed)if(l.issues)s?s.push(l):s=[l];else{i=l;break}else a?a.push(l):a=[l]}if(i)return i;if(s){if(s.length===1)return s[0];K(this,"type",n,r,{issues:Pn(s)}),n.typed=!0}else{if((a==null?void 0:a.length)===1)return a[0];K(this,"type",n,r,{issues:Pn(a)})}return n}}}function It(){return{kind:"schema",type:"unknown",reference:It,expects:"unknown",async:!1,get"~standard"(){return J(this)},"~run"(e){return e.typed=!0,e}}}function _e(e,t,n){const r=e["~run"]({value:t},vt(n));if(r.issues)throw new gi(r.issues);return r.value}function se(...e){return{...e[0],pipe:e,get"~standard"(){return J(this)},"~run"(t,n){for(const r of e)if(r.kind!=="metadata"){if(t.issues&&(r.kind==="schema"||r.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r["~run"](t,n))}return t}}}function qt(e,t,n){const r=e["~run"]({value:t},vt(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var wi=Object.defineProperty,yi=(e,t,n)=>t in e?wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mn=(e,t,n)=>yi(e,typeof t!="symbol"?t+"":t,n),Ci=Object.defineProperty,Fi=(e,t,n)=>t in e?Ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bt=(e,t,n)=>Fi(e,typeof t!="symbol"?t+"":t,n);function Ln(e){return t=>t instanceof e}function Vn(e,t){const n=class extends Error{constructor(...i){const s=typeof t=="function"?t(...i):typeof t=="string"?[t]:t||[];super(...s),this.name=e}};Bt(n,"is",Ln(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function Si(e,t,n){const r=class extends Vn(e,n){constructor(...s){super(...s),Bt(this,"data"),this.data=t(...s)}};Bt(r,"is",Ln(r));let i=r;return Object.defineProperty(i,"name",{value:e}),i}let Rn=class extends Vn("CancelledError","Promise was canceled"){},Tt=class extends Si("TimeoutError",t=>({timeout:t}),(t,n)=>[`Timeout reached: ${t}ms`,{cause:n}]){};const ki=Symbol("resolved");function Ei(e){return{tag:ki,value:e}}function On(e,t){return e.reject=t.reject,e.resolve=t.resolve,e}let rt=class Sn extends Promise{constructor(t,n){let r,i,s,a;typeof t=="function"?(s=t,a=n||{}):a=t||{};let u,l;const c=()=>!!l,h=()=>!!u;let f={};const b=[],v=()=>{b.forEach(g=>g()),b.splice(0,b.length),f={}},y=new AbortController,w=()=>h()||c();super((g,S)=>{const{abortOnResolve:_=!0,abortOnReject:D=!0}=a;i=k=>{var L,I;w()||(g(k),u=[k],(L=f.resolved)==null||L.forEach(x=>x(k)),(I=f.finalized)==null||I.forEach(x=>x({kind:"resolved",result:k})),v(),_&&y.abort(Ei(k)))},r=k=>{var L,I;w()||(S(k),l=[k],(L=f.rejected)==null||L.forEach(x=>x(k)),(I=f.finalized)==null||I.forEach(x=>x({kind:"rejected",reason:k})),v(),D&&y.abort(k))};const{abortSignal:M}=a;if(M){if(M.aborted)return r(M.reason);const k=()=>{r(M.reason)};M.addEventListener("abort",k,!0),b.push(()=>{M.removeEventListener("abort",k,!0)})}const{timeout:U}=a;if(U){const k=setTimeout(()=>{r(new Tt(U))},U);b.push(()=>{clearTimeout(k)})}try{const k=()=>{},L=s&&s(i,r,{abortSignal:y.signal,get isRejected(){return c()},get isResolved(){return h()},on(I,x){if(u||l){if(I==="finalized"){const Le=u?{kind:"resolved",result:u[0]}:{kind:"rejected",reason:l[0]};x(Le)}else I==="resolved"&&u?x(u[0]):I==="rejected"&&l&&x(l[0]);return k}return f[I]||(f[I]=[]),f[I].push(x),()=>{const Le=f[I]||[],Ye=Le.indexOf(x);Ye>=0&&Le.splice(Ye,1)}},get result(){return u==null?void 0:u[0]},get rejectReason(){return l==null?void 0:l[0]},throwIfRejected(){if(l)throw l[0]}});L instanceof Promise&&L.catch(r)}catch(k){r(k)}}),Mn(this,"reject"),Mn(this,"resolve"),this.reject=r,this.resolve=i}static fn(t,n){return new Sn(async(r,i,s)=>{try{r(await t(s))}catch(a){i(a)}},n)}static resolve(t){return this.fn(()=>t)}static reject(t){return new Sn((n,r)=>{r(t)})}cancel(){this.reject(new Rn)}catch(t){return this.then(void 0,t)}finally(t){return On(super.finally(t),this)}then(t,n){return On(super.then(t,n),this)}};function jn(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function $i(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function Ai(e){return Object.entries(e).reduce((t,[n,r])=>(t[$i(n)]=r,t),{})}function Pt(e){const t=Ai(e);for(const n in t){const r=t[n];r&&typeof r=="object"&&!(r instanceof Date)&&(t[n]=Array.isArray(r)?r.map(Pt):Pt(r))}return t}function Ii(e){return e.replace(/_([a-z])/g,(t,n)=>`-${n.toLowerCase()}`)}function Dn(e){return`tapps/${e}`}function Mt(e,t){sessionStorage.setItem(Dn(e),JSON.stringify(t))}function Un(e){const t=sessionStorage.getItem(Dn(e));try{return t?JSON.parse(t):void 0}catch{}}function st(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(n=>{n()})}]}function xn(e,t){t||(t={});const{textColor:n,bgColor:r,shouldLog:i}=t,s=i===void 0?!0:i,a=typeof s=="boolean"?()=>s:s,u=(l,c,...h)=>{if(c||a()){const f="font-weight:bold;padding:0 5px;border-radius:100px",[b,v,y]={log:["#0089c3","white","INFO"],error:["#ff0000F0","white","ERR"],warn:["#D38E15","white","WARN"]}[l];console[l](`%c${y} ${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:${b};color:${v}`,"",`${f};${n?`color:${n};`:""}${r?`background-color:${r}`:""}`,...h)}};return[["log","forceLog"],["warn","forceWarn"],["error","forceError"]].reduce((l,[c,h])=>(l[c]=u.bind(void 0,c,!1),l[h]=u.bind(void 0,c,!0),l),{})}var qi=function(e,t,n){if(arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function Gn(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function qe(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Wn=function(e,t){var n=function(r){return r.length>=e};return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,qi([i],r,!1))}}},Bi=function(e){return e._tag==="Left"},Hn=function(e){return{_tag:"Left",left:e}},Nn=function(e){return{_tag:"Right",right:e}},zn=Hn,Kn=Nn,Jn=Bi,Ti=function(e,t){return function(n){return Jn(n)?e(n.left):t(n.right)}},Lt=Ti;function Pi(e){return Gn(Kn,e.of)}function Mi(e){return Gn(zn,e.of)}function Li(e){return function(t,n){return e.chain(t,function(r){return Jn(r)?e.of(r):n(r.right)})}}function Vi(e){return function(t,n){return function(r){return e.map(r,Lt(t,n))}}}var Qn=function(e,t){return qe(e,Oi(t))},Ri=function(e,t){return qe(e,ji(t))},Oi=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},ji=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Vt=function(e){return function(){return Promise.resolve(e)}},Di=Wn(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),Zn="Task",Ui={URI:Zn,map:Qn},Yn={of:Vt},xi={URI:Zn,map:Qn,of:Vt,ap:Ri,chain:Di},Gi=function(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function u(h){try{c(r.next(h))}catch(f){a(f)}}function l(h){try{c(r.throw(h))}catch(f){a(f)}}function c(h){h.done?s(h.value):i(h.value).then(u,l)}c((r=r.apply(e,[])).next())})},Wi=function(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(c){return function(h){return l([c,h])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(s=c[0]&2?i.return:c[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,c[1])).done)return s;switch(i=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(h){c=[6,h],i=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Hi=Mi(Yn),Ni=Pi(Yn),zi=Vt,Xn=Vi(Ui),Ki=Xn,Ji=function(e,t){return function(){return Gi(void 0,void 0,void 0,function(){var n;return Wi(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e().then(Nn)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,Hn(t(n))];case 3:return[2]}})})}},Qi=Wn(2,Li(xi)),Zi=Qi;function je(e){const t=n=>{throw n};return typeof e=="function"?rt.resolve(qe(e,Xn(t,n=>n))()):qe(e,Lt(t,n=>n))}function X(e){return Object.assign((...t)=>je(e(...t)),e)}const De=Object.assign((e,t)=>qe(Ji(()=>new rt((n,r,i)=>e(s=>n(Kn(s)),s=>n(zn(s)),i),t),n=>n),Zi(Lt(Hi,Ni))),{fn:(e,t)=>De((n,r,i)=>{const s=e(i);qe(typeof s=="function"?s:zi(s),Ki(r,n))()},t)});function Yi(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Xi=function(e){return e._tag==="Left"},eo=function(e){return{_tag:"Left",left:e}},to=function(e){return{_tag:"Right",right:e}},er=eo,Fe=to,no=function(e){return function(t){return ro(t)?t:Fe(e(t.right))}},ro=Xi,tr=function(e,t){try{return Fe(e())}catch(n){return er(t(n))}};function so(e){const t=n=>{const r={};return new URLSearchParams(n).forEach((i,s)=>{const a=r[s];Array.isArray(a)?a.push(i):a===void 0?r[s]=i:r[s]=[a,i]}),_e(e,r)};return se(nt([C(),$t(URLSearchParams)]),et(n=>{try{return t(n),!0}catch{return!1}},"The value doesn't match required schema"),ue(t))}function io(e){return se(C(),et(t=>{try{return JSON.parse(t),!0}catch{return!1}},"Input is not a valid JSON value"),ue(JSON.parse),e)}function me(e){return se(C(),io(e))}function Rt(e){return se(nt([C(),$t(URLSearchParams)]),so(e))}function it(e){return t=>e.test(t)}const nr=it(/^#[\da-f]{3}$/i),rr=it(/^#[\da-f]{4}$/i),Ue=it(/^#[\da-f]{6}$/i),sr=it(/^#[\da-f]{8}$/i);function ir(e){return[Ue,sr,nr,rr].some(t=>t(e))}function or(e){let t="#";for(let n=0;n<e.length-1;n+=1)t+=e[1+n].repeat(2);return t}function ot(e){const t=e.replace(/\s/g,"").toLowerCase();if(/^#[\da-f]{3}$/i.test(t))return Fe(or(t.toLowerCase()+"f"));if(/^#[\da-f]{4}$/i.test(t))return Fe(or(t.toLowerCase()));if(/^#[\da-f]{6}$/i.test(t))return Fe(t.toLowerCase()+"ff");if(/^#[\da-f]{8}$/i.test(t))return Fe(t.toLowerCase());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})\)$/);return n?Fe(n.slice(1).reduce((r,i)=>r+parseInt(i,10).toString(16).padStart(2,"0"),"#").padEnd(9,"f")):er(new Error(`Value "${e}" does not satisfy any of known RGB formats.`))}function ar(e){return Yi(ot(e),no(t=>t.slice(0,7)))}const oo=X(ar),ao=X(ot);function uo(){return j({id:de(),photo_url:$(C()),type:C(),title:C(),username:$(C())})}function ur(){return j({added_to_attachment_menu:$(Ce()),allows_write_to_pm:$(Ce()),first_name:C(),id:de(),is_bot:$(Ce()),is_premium:$(Ce()),last_name:$(C()),language_code:$(C()),photo_url:$(C()),username:$(C())})}function co(){return j({auth_date:se(C(),ue(e=>new Date(Number(e)*1e3)),tt()),can_send_after:$(se(C(),ue(Number),Ft())),chat:$(me(uo())),chat_type:$(C()),chat_instance:$(C()),hash:C(),query_id:$(C()),receiver:$(me(ur())),start_param:$(C()),signature:C(),user:$(me(ur()))})}function cr(){return Rt(co())}function Ot(){return At(C(),se(nt([C(),de()]),ue(e=>typeof e=="number"?`#${(e&16777215).toString(16).padStart(6,"0")}`:e),et(ir)))}function lo(){const e=$(se(C(),ue(t=>t==="1")));return j({tgWebAppBotInline:e,tgWebAppData:$(cr()),tgWebAppDefaultColors:$(me(Ot())),tgWebAppFullscreen:e,tgWebAppPlatform:C(),tgWebAppShowSettings:e,tgWebAppStartParam:$(C()),tgWebAppThemeParams:me(Ot()),tgWebAppVersion:C()})}function po(){return Rt(lo())}function lr(){return j({eventType:C(),eventData:$(It())})}function pr(e){return tr(()=>_e(cr(),e),t=>t)}function at(e){return tr(()=>_e(po(),e),t=>t)}const ho=X(pr),hr=X(at);function fr(e,t){return t||(t=(n,r)=>JSON.stringify(r)),new URLSearchParams(Object.entries(e).reduce((n,[r,i])=>(Array.isArray(i)?n.push(...i.map(s=>[r,String(s)])):i!=null&&n.push([r,i instanceof Date?(i.getTime()/1e3|0).toString():typeof i=="string"||typeof i=="number"?String(i):typeof i=="boolean"?i?"1":"0":t(r,i)]),n),[])).toString()}function dr(e){return fr(e)}function _r(e){return fr(e,(t,n)=>t==="tgWebAppData"?dr(n):JSON.stringify(n))}var fo=Object.defineProperty,_o=(e,t,n)=>t in e?fo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jt=(e,t,n)=>_o(e,typeof t!="symbol"?t+"":t,n);function mr(e){return t=>t instanceof e}function H(e,t){const n=class extends Error{constructor(...s){const a=typeof t=="function"?t(...s):typeof t=="string"?[t]:t||[];super(...a),this.name=e}};jt(n,"is",mr(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function br(e,t,n){const r=class extends H(e,n){constructor(...a){super(...a),jt(this,"data"),this.data=t(...a)}};jt(r,"is",mr(r));let i=r;return Object.defineProperty(i,"name",{value:e}),i}function mo(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(i){i(n)}),(r=e.get("*"))&&r.slice().map(function(i){i(t,n)})}}}function gr(e){return kt(j({TelegramWebviewProxy:j({postEvent:Et()})}),e)}function vr(){try{return window.self!==window.top}catch{return!0}}var bo=function(e,t,n){if(arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function go(e){return e}function xe(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function ce(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Dt=function(e,t){var n=function(r){return r.length>=e};return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,bo([i],r,!1))}}},vo={_tag:"None"},wo=function(e){return{_tag:"Some",value:e}},yo=function(e){return e._tag==="Left"},Co=function(e){return{_tag:"Left",left:e}},Fo=function(e){return{_tag:"Right",right:e}},Se=Co,te=Fo,wr=Dt(2,function(e,t){return Ge(e)?e:t(e.right)}),So=function(e){return function(t){return Ge(t)?t:te(e(t.right))}},ko=function(e){return function(t){return Ge(t)?Se(e(t.left)):t}},Ge=yo,yr=function(e,t){return function(n){return Ge(n)?e(n.left):t(n.right)}},Eo=yr,Ut=yr,$o=Ut,xt=function(e,t){try{return te(e())}catch(n){return Se(t(n))}},Ao=wr,Io=wr,qo=vo,Bo=wo,To=function(e){return e._tag==="None"},Po=function(e,t){return function(n){return To(n)?e():t(n.value)}},Mo=Po;function Lo(e){return xe(te,e.of)}function Vo(e){return xe(Se,e.of)}function Ro(e){return function(t,n){return e.chain(t,function(r){return Ge(r)?e.of(r):n(r.right)})}}function Oo(e){return function(t,n){return function(r){return e.map(r,Ut(t,n))}}}var Cr=function(e,t){return ce(e,Do(t))},jo=function(e,t){return ce(e,Uo(t))},Do=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},Uo=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Fr=function(e){return function(){return Promise.resolve(e)}},xo=Dt(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),Sr="Task",Go={URI:Sr,map:Cr},kr={of:Fr},Wo={URI:Sr,map:Cr,of:Fr,ap:jo,chain:xo},Ho=Vo(kr),Er=Lo(kr),No=Oo(Go),$r=Dt(2,Ro(Wo)),zo=$r,Ko=$r;class Ar extends H("MethodUnsupportedError",(t,n)=>[`Method "${t}" is unsupported in Mini Apps version ${n}`]){}class Ir extends H("MethodParameterUnsupportedError",(t,n,r)=>[`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${r}`]){}class qr extends br("LaunchParamsRetrieveError",t=>({errors:t}),t=>[["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/tma-js-bridge/environment","","Collected errors:",...t.map(({source:n,error:r})=>`Source: ${n} / ${r instanceof Error?r.message:String(r)}`)].join(`
|
|
2
|
+
`)]){}class Br extends H("InvalidLaunchParamsError",(t,n)=>[`Invalid value for launch params: ${t}`,{cause:n}]){}class Tr extends H("UnknownEnvError"){}class Pr extends H("InvokeCustomMethodError",t=>[`Server returned error: ${t}`]){}const Mr="launchParams";function Lr(e){return e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&")}const Be=xe(We,Ao(at)),Jo=X(Be),Gt=xe(We,So(e=>{const t=new URLSearchParams(e).get("tgWebAppData");return t?Bo(t):qo})),Qo=xe(Gt,$o(e=>{throw e},e=>e),Mo(()=>{},e=>e));function We(){const e=[];for(const[t,n]of[[()=>Lr(window.location.href),"window.location.href"],[()=>{const r=performance.getEntriesByType("navigation")[0];return r&&Lr(r.name)},"performance navigation entries"],[()=>Un(Mr),"local storage"]]){const r=t();if(!r){e.push({source:n,error:new Error("Source is empty")});continue}const i=ce(at(r),Eo(s=>s,()=>!0));if(typeof i!="boolean"){e.push({source:n,error:i});continue}return Mt(Mr,r),te(r)}return Se(new qr(e))}const Zo=X(We);function Yo(e,t){const n=new Map,r=mo(),i=(s,a,u=!1)=>{const l=n.get(s)||new Map;n.set(s,l);const c=l.get(a)||[];l.set(a,c);const h=c.findIndex(f=>f[1]===u);if(h>=0&&(r.off(s,c[h][0]),c.splice(h,1),!c.length&&(l.delete(a),!l.size))){const f=n.size;n.delete(s),f&&!n.size&&t()}};return{on(s,a,u){!n.size&&e();const l=()=>{i(s,a,u)},c=(...b)=>{u&&l(),s==="*"?a({name:b[0],payload:b[1]}):a(...b)};r.on(s,c);const h=n.get(s)||new Map;n.set(s,h);const f=h.get(a)||[];return h.set(a,f),f.push([c,u||!1]),l},off:i,emit:r.emit,clear(){const s=n.size;r.all.clear(),n.clear(),s&&t()}}}function ut(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}function Wt(e,t,n){const r=[n],i=e[t];typeof i=="function"&&r.push(i);const s=(...u)=>{r.forEach(l=>l(...u))},a=Object.assign((...u)=>{s(...u)},{unwrap(){const{length:u}=r;if(u===1){delete e[t];return}if(u===2){Or(e,t,r[1]);return}r.unshift(1),Or(e,t,s)}});Rr(e,t,()=>a,u=>r.push(u))}function Vr(e,t){const n=e[t];Rr(e,t,()=>n,r=>{Object.entries(r).forEach(([i,s])=>{n[i]=s})})}function Rr(e,t,n,r){Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:n,set:r})}function Or(e,t,n){Object.defineProperty(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n})}const Xo={clipboard_text_received:j({req_id:C(),data:Ie(C())}),custom_method_invoked:j({req_id:C(),result:$(It()),error:$(C())}),popup_closed:Ie(j({button_id:Ie(C(),()=>{})}),{}),viewport_changed:Ie(j({height:de(),width:Ie(de(),()=>window.innerWidth),is_state_stable:Ce(),is_expanded:Ce()}),()=>({height:window.innerHeight,is_state_stable:!0,is_expanded:!0})),theme_changed:j({theme_params:Ot()})};function jr(e){if(e.source!==window.parent)return;let t;try{t=_e(me(lr()),e.data)}catch{return}const{eventType:n,eventData:r}=t,i=Xo[n];let s;try{s=i?_e(i,r):r}catch(a){return le().forceError([`An error occurred processing the "${n}" event from the Telegram application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose"].join(`
|
|
3
|
+
`),t,a)}ea(n,s)}const{on:ee,off:ke,emit:ea,clear:ta}=Yo(()=>{const e=window;!e.TelegramGameProxy&&(e.TelegramGameProxy={}),Wt(e.TelegramGameProxy,"receiveEvent",ut),Vr(e,"TelegramGameProxy"),!e.Telegram&&(e.Telegram={}),!e.Telegram.WebView&&(e.Telegram.WebView={}),Wt(e.Telegram.WebView,"receiveEvent",ut),Vr(e.Telegram,"WebView"),Wt(e,"TelegramGameProxy_receiveEvent",ut),window.addEventListener("message",jr)},()=>{[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["Telegram","WebView","receiveEvent"]].forEach(e=>{const t=window;let n=[void 0,t];for(const s of e)if(n=[n[1],n[1][s]],!n[1])return;const[r,i]=n;"unwrap"in i&&(i.unwrap(),r&&r!==t&&!Object.keys(r).length&&delete t[e[0]])}),window.removeEventListener("message",jr)}),Ht=W(!1),Dr=W("https://web.telegram.org"),na=e=>{le().log("Event received:",e)},Ur=F(Ht);function ra(e){e!==Ht()&&(Ht.set(e),(e?ee:ke)("*",na))}const xr=F(Dr);function sa(e){Dr.set(e),le().log("New target origin set",e)}const ct=W((...e)=>{window.parent.postMessage(...e)}),le=W(xn("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:Ur})),ia=(...e)=>ct()(...e);function oa(e,t){ce(Nt(e,t),ko(n=>{throw n}))}function Nt(e,t){le().log("Posting event:",t?{eventType:e,eventData:t}:{eventType:e});const n=window,r=JSON.stringify({eventType:e,eventData:t});return vr()?(ia(r,xr()),te(void 0)):gr(n)?(n.TelegramWebviewProxy.postEvent(e,JSON.stringify(t)),te(void 0)):kt(j({external:j({notify:Et()})}),n)?(n.external.notify(r),te(void 0)):Se(new Tr)}function zt(e,t,n={}){const{capture:r=()=>!0,postEvent:i=Nt}=n;return ce(async()=>i(e,n.params),Ko(()=>De((s,a,u)=>{const[l,c]=st();(Array.isArray(t)?t:[t]).forEach(h=>{l(ee(h,f=>{(Array.isArray(t)?r({event:h,payload:f}):r(f))&&s(f)}))}),u.on("finalized",c)},n)))}function aa(e,t){const n=Kt(e,t);return typeof n=="function"?rt.fn(()=>je(n)):n}function Kt(e,t){const n=gr(window);if(!e)return n||ce(We(),Ut(()=>!1,()=>!0));if(n)return Er(!0);const{timeout:r=100}=t||{};return ce(zt("web_app_request_theme","theme_changed",{...t,timeout:r}),No(i=>Tt.is(i)?te(!1):Se(i),()=>te(!0)))}function ua({launchParams:e,onEvent:t,resetPostMessage:n}={}){if(e){const s=typeof e=="string"||e instanceof URLSearchParams?e.toString():_r({...e,tgWebAppData:void 0})+(e.tgWebAppData?`&tgWebAppData=${encodeURIComponent(e.tgWebAppData.toString())}`:"");try{hr(s)}catch(a){throw new Br(s,a)}Mt("launchParams",s)}if(vr()){if(!t)return;n&&ct.reset();const s=ct();ct.set((...a)=>{const[u]=a,l=()=>{s(...a)};try{const c=_e(me(lr()),u);t([c.eventType,c.eventData],l)}catch{l()}});return}const r=window.TelegramWebviewProxy||{},i=r.postEvent||(()=>{});window.TelegramWebviewProxy={...r,postEvent(s,a){const u=()=>{i(s,a)};t?t([s,a?JSON.parse(a):void 0],u):u()}},le().log("Environment was mocked by the mockTelegramEnv function")}function Gr(e){return({req_id:t})=>t===e}function Wr(e){return e.split(".").map(Number)}function ca(e,t){const n=Wr(e),r=Wr(t),i=Math.max(n.length,r.length);for(let s=0;s<i;s+=1){const a=n[s]||0,u=r[s]||0;if(a!==u)return a>u?1:-1}return 0}const Hr={"6.0":["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"],6.1:["web_app_open_tg_link","web_app_open_invoice","web_app_setup_back_button","web_app_set_background_color","web_app_set_header_color","web_app_trigger_haptic_feedback"],6.2:["web_app_open_popup"],6.4:["web_app_close_scan_qr_popup","web_app_open_scan_qr_popup","web_app_read_text_from_clipboard",{method:"web_app_open_link",param:"try_instant_view"}],6.7:["web_app_switch_inline_query"],6.9:["web_app_invoke_custom_method","web_app_request_write_access","web_app_request_phone",{method:"web_app_set_header_color",param:"color"}],"6.10":["web_app_setup_settings_button"],7.2:["web_app_biometry_get_info","web_app_biometry_open_settings","web_app_biometry_request_access","web_app_biometry_request_auth","web_app_biometry_update_token"],7.6:[{method:"web_app_open_link",param:"try_browser"},{method:"web_app_close",param:"return_back"}],7.7:["web_app_setup_swipe_behavior"],7.8:["web_app_share_to_story"],"7.10":["web_app_setup_secondary_button","web_app_set_bottom_bar_color",{method:"web_app_setup_main_button",param:"has_shine_effect"}],"8.0":["web_app_request_safe_area","web_app_request_content_safe_area","web_app_request_fullscreen","web_app_exit_fullscreen","web_app_set_emoji_status","web_app_add_to_home_screen","web_app_check_home_screen","web_app_request_emoji_status_access","web_app_check_location","web_app_open_location_settings","web_app_request_file_download","web_app_request_location","web_app_send_prepared_message","web_app_start_accelerometer","web_app_start_device_orientation","web_app_start_gyroscope","web_app_stop_accelerometer","web_app_stop_device_orientation","web_app_stop_gyroscope","web_app_toggle_orientation_lock"],"9.0":["web_app_device_storage_clear","web_app_device_storage_get_key","web_app_device_storage_save_key","web_app_secure_storage_clear","web_app_secure_storage_get_key","web_app_secure_storage_restore_key","web_app_secure_storage_save_key"],9.1:["web_app_hide_keyboard"]};function Jt(e,t){return Object.keys(Hr).find(n=>Hr[n].some(r=>t?typeof r=="object"&&r.method===e&&r.param===t:r===e))||null}function pe(e,t,n){const r=n?Jt(e,t):Jt(e);return r?ca(r,n||t)<=0:!1}function la(e,t="strict"){const n=typeof t=="function"?t:r=>{const{method:i,version:s}=r,a="param"in r?new Ir(i,r.param,s):new Ar(i,s);if(t==="strict")throw a;return le().forceWarn(a.message)};return(r,i)=>pe(r,e)?r==="web_app_set_header_color"&&kt(j({color:Bn()}),i)&&!pe(r,"color",e)?n({version:e,method:r,param:"color"}):oa(r,i):n({version:e,method:r})}function pa(e,t,n,r){return ce(zt("web_app_invoke_custom_method","custom_method_invoked",{...r||{},params:{method:e,params:t,req_id:n},capture:Gr(n)}),zo(({result:i,error:s})=>s?Ho(new Pr(s)):Er(i)))}function ha(){Object.hasOwn||(Object.hasOwn=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)})}function Qt(e){return xt(()=>decodeURIComponent(atob(e).replace(/-/g,"+").replace(/_/g,"/").split("").map(t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)).join("")),t=>t)}const fa=X(Qt);function Zt(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,n)=>String.fromCharCode(parseInt(`0x${n}`)))).replace(/\+/g,"-").replace(/\//g,"_")}var da=function(e){return xt(function(){return JSON.parse(e)},go)};function Nr(e){const t=Zt(typeof e=="string"?e:JSON.stringify(e));return t.length>512?Se(new Error("Value is too long for start parameter")):te(t)}const _a=X(Nr);function ma(e,t){return je(zr(e,typeof t=="function"?n=>xt(()=>t(n),r=>r):t))}function zr(e,t){return ce(Qt(e),Io(n=>t?typeof t=="function"?t(n):da(n):te(n)))}function ba(e){return Zt(e).length<=512}function Q(e){return typeof e=="function"?e():e}function ie(e,t){return F(()=>pe(e,Q(t)))}var Te=Js,He=Qs,ga=function(e,t){return d(e,ya(t))},va=function(e,t){return d(e,Fa(t))},wa="Option",ya=function(e){return function(t){return Ne(t)?Te:He(e(t.value))}},Ca=He,Fa=function(e){return function(t){return Ne(t)||Ne(e)?Te:He(t.value(e.value))}},Sa=Ve(2,function(e,t){return Ne(e)?Te:t(e.value)}),ka={URI:wa,map:ga,ap:va,chain:Sa},Ne=function(e){return e._tag==="None"},Ea=function(e,t){return function(n){return Ne(n)?e():t(n.value)}},Kr=Ea,$a=Ca(_t),Jr=mt(ka);function Aa(e){return we(P,e.of)}function Ia(e){return we(O,e.of)}function qa(e){return Xs(e,ti)}function Ba(e){return Ys(e,ii)}function Ta(e){return function(t,n){return e.chain(t,function(r){return ye(r)?e.of(r):n(r.right)})}}function Pa(e){return function(t,n,r){return e.map(t,ai(n,r))}}function Ma(e){return function(t,n){return function(r){return e.map(r,Re(t,n))}}}var Yt=function(e,t){return d(e,La(t))},Qr=function(e,t){return d(e,Va(t))},La=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},Va=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Xt=function(e){return function(){return Promise.resolve(e)}},Ra=Ve(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),en="Task",tn={URI:en,map:Yt},Zr={of:Xt},Oa={URI:en,map:Yt,ap:Qr},ja={URI:en,map:Yt,of:Xt,ap:Qr,chain:Ra},Da=function(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function u(h){try{c(r.next(h))}catch(f){a(f)}}function l(h){try{c(r.throw(h))}catch(f){a(f)}}function c(h){h.done?s(h.value):i(h.value).then(u,l)}c((r=r.apply(e,t||[])).next())})},Ua=function(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(c){return function(h){return l([c,h])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(s=c[0]&2?i.return:c[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,c[1])).done)return s;switch(i=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(h){c=[6,h],i=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},N=Ia(Zr),R=Aa(Zr),Yr=Xt,xa=Ma(tn),Ga=function(e,t){return function(){return Da(void 0,void 0,void 0,function(){var n;return Ua(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e().then(En)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,kn(t(n))];case 3:return[2]}})})}},Wa=function(e,t){return d(e,V(t))},Ha=function(e,t){return d(e,Na(t))},V=qa(tn),nn=Ve(3,Pa(tn)),Na=Ba(Oa),rn=Ve(2,Ta(ja)),za=R,Ka="TaskEither",Ja={URI:Ka,map:Wa,ap:Ha,chain:rn},Qa=za(_t),Za=mt(Ja),lt=Za,he=rn,Pe=rn;function Ee(e){return[e]}class ze extends br("ValidationError",(t,n)=>({input:t,issues:n}),"Validation error"){}class pt extends H("CSSVarsBoundError","CSS variables are already bound"){}class Xr extends H("NotAvailableError",Ee){}class Ya extends H("InvalidEnvError",Ee){}class es extends H("FunctionNotAvailableError",Ee){}class ne extends H("InvalidArgumentsError",(t,n)=>[t,{cause:n}]){}class ht extends H("ConcurrentCallError",Ee){}class ts extends H("SetEmojiStatusError",t=>[`Failed to set emoji status: ${t}`]){}class sn extends H("AccessDeniedError",Ee){}class ns extends H("FullscreenFailedError",Ee){}class rs extends H("ShareMessageError",Ee){}class ss extends H("UnknownThemeParamsKeyError",t=>[`Unknown theme params key passed: ${t}`]){}function T(e,t){const n=F(()=>Q(t.version)||"100"),r=F(()=>Q(t.isTma)),{requires:i}=t,s=i?typeof i=="object"?i:{every:[i]}:void 0,a=y=>{if(!t.supports)return!0;const w=t.supports[y];return pe(w.method,w.param,n())},u=()=>{if(!s)return;const[y,w]="every"in s?["every",s.every]:["some",s.some];for(let g=0;g<w.length;g++){const S=w[g],_=typeof S=="function"?S():pe(S,n())?void 0:`it is unsupported in Mini Apps version ${n()}`;if(_&&(y==="every"||g===w.length-1))return _}},l=(...y)=>{for(const w in t.supports)if(t.supports[w].shouldCheck(...y)&&!a(w))return`option ${w} is not supported in Mini Apps version ${n()}`},c=F(()=>!u()),h=F(()=>n()!=="0.0"),f=F(()=>t.isMounted?t.isMounted():!0),b=F(()=>r()&&h()&&c()&&f()),v=y=>{const w=new es(y);return["task","promise"].includes(t.returns)?N(w):O(w)};return Object.assign((...y)=>{var D;const w="Unable to call function:";if(!r())return v(`${w} it can't be called outside Mini Apps`);if(!h())return v(`${w} the SDK was not initialized. Use the SDK init() function`);const g=u();if(g)return v(`${w} ${g}`);const S=l(...y);if(S)return v(`${w} ${S}`);if(!f()){const M=(D=t.isMounting)!=null&&D.call(t)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return v(`${w} the component is ${M}`)}const{returns:_}=t;return _==="plain"?ui(()=>e(...y),M=>M):_==="promise"?Ga(()=>e(...y),M=>M):e(...y)},e,{isAvailable:b,ifAvailable(...y){return b()?He(e(...y)):Te}},s?{isSupported:c}:{},t.supports?{supports:a}:{})}function B(e){return t=>T(t,e)}function m(e){return Object.assign(X(e),{ifAvailable(...t){return d(e.ifAvailable(...t),Kr(()=>({ok:!1}),n=>({ok:!0,data:je(n)})))}})}function on(e){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=r)}return t}function an(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&e[i]===t[i])}class be{constructor({initialState:t,onChange:n}){o(this,"_state");o(this,"state");o(this,"setState",t=>{const n={...this.state(),...on(t)};an(n,this.state())||this._state.set(n)});this._state=W(t,{equals:an}),this.state=F(this._state),this.state.sub(n)}getter(t){return F(()=>this._state()[t])}hasDiff(t){return!an({...this.state(),...on(t)},this.state())}}class Ke{constructor({onMounted:t,restoreState:n,initialState:r,onUnmounted:i,isPageReload:s}){o(this,"_isMounted",W(!1));o(this,"isMounted",F(this._isMounted));o(this,"mount");o(this,"unmount");this.mount=()=>{if(this.isMounted())return P(void 0);const a=Q(s)?n():void 0,u=a?P(a):typeof r=="function"?r():P(r);return d(u,Z(l=>{Xe(()=>{this._isMounted.set(!0),t==null||t(l)})}))},this.unmount=()=>{this._isMounted()&&Xe(()=>{this._isMounted.set(!1),i==null||i()})}}}class ft{constructor({isTma:t,storage:n,onClick:r,offClick:i,initialState:s,isPageReload:a,postEvent:u,payload:l,method:c,version:h}){o(this,"isMounted");o(this,"isSupported");o(this,"state");o(this,"stateSetters");o(this,"stateBoolSetters");o(this,"setStateFp");o(this,"setState");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const f=new be({initialState:s,onChange(g){n.set(g)}}),b=new Ke({initialState:s,isPageReload:a,onMounted:f.setState,restoreState:n.get}),v={version:h,requires:c,isTma:t},y=B({...v,returns:"plain"}),w=B({...v,returns:"either",isMounted:b.isMounted});this.isMounted=b.isMounted,this.isSupported=ie(c,h),this.state=f.state,this.setStateFp=w(g=>{const S={...this.state(),...on(g)};return f.hasDiff(S)?d(u(c,l(S)),Z(()=>{f.setState(S)})):P(void 0)}),this.setState=m(this.setStateFp),this.onClickFp=y(r),this.onClick=m(this.onClickFp),this.offClickFp=y(i),this.offClick=m(this.offClickFp),this.mountFp=y(()=>{const g=()=>{};return d(b.mount(),Re(g,g))}),this.mount=m(this.mountFp),this.unmount=b.unmount,this.stateSetters=g=>{const S=w(_=>this.setStateFp({[g]:_}));return[m(S),S]},this.stateBoolSetters=g=>{const[,S]=this.stateSetters(g),_=w(()=>S(!1)),D=w(()=>S(!0));return[[m(_),_],[m(D),D]]}}stateGetter(t){return F(()=>this.state()[t])}}class is{constructor(t){o(this,"isVisible");o(this,"isMounted");o(this,"isSupported");o(this,"hideFp");o(this,"hide");o(this,"showFp");o(this,"show");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const n=new ft({...t,method:"web_app_setup_back_button",payload:r=>({is_visible:r.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}function E(){return{isTma:F(()=>Kt())}}function Xa(e){return{get:()=>Un(e),set(t){Mt(e,t)}}}function eu(){return performance.getEntriesByType("navigation")[0]}function tu(){const e=eu();return!!e&&e.type==="reload"}function Je(e){return t=>({...t,...Q(e)})}function ge(e){return Je({storage:Xa(e),isPageReload:tu})}function Qe(e,t){return W(e,t)}const os=Qe(Nt),Me=(...e)=>os()(...e),as=(...e)=>je(Me(...e)),z=Je({postEvent:Me}),un=Qe("0.0"),A=Je({version:un});function cn(e,t){return{...d(E(),z,A,ge(e)),onClick(n,r){return ee(t,n,r)},offClick(n,r){ke(t,n,r)}}}const nu=new is(cn("backButton","back_button_pressed"));class ln{constructor({initialState:t,onMounted:n,restoreState:r,onUnmounted:i,isPageReload:s}){o(this,"_isMounted",W(!1));o(this,"isMounted",F(this._isMounted));o(this,"mount");o(this,"unmount");this.mount=a=>{if(this._isMounted())return R(void 0);const u=Q(s)?r():void 0;return d(u?R(u):t(a),V(l=>{this._isMounted()||Xe(()=>{this._isMounted.set(!0),n==null||n(l)})}))},this.unmount=()=>{this._isMounted()&&Xe(()=>{this._isMounted.set(!1),i==null||i()})}}}const us=new Xr("Biometry is not available");function pn(e){let t=!1,n=!1,r="",i=!1,s="",a=!1;return e.available&&(t=!0,n=e.token_saved,r=e.device_id,i=e.access_requested,s=e.type,a=e.access_granted),{available:t,tokenSaved:n,deviceId:r,type:s,accessGranted:a,accessRequested:i}}class cs{constructor({version:t,request:n,postEvent:r,storage:i,onInfoReceived:s,offInfoReceived:a,isTma:u,isPageReload:l}){o(this,"isAvailable");o(this,"isSupported");o(this,"isMounted");o(this,"state");o(this,"authenticateFp");o(this,"authenticate");o(this,"openSettingsFp");o(this,"openSettings");o(this,"requestAccessFp");o(this,"requestAccess");o(this,"updateTokenFp");o(this,"updateToken");o(this,"mountFp");o(this,"mount");o(this,"unmount");const c=g=>{h.setState(pn(g))},h=new be({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:i.set}),f=new ln({initialState(g){return d(n("web_app_biometry_get_info","biometry_info_received",g),V(pn))},isPageReload:l,onMounted(g){h.setState(g),s(c)},onUnmounted(){a(c)},restoreState:i.get}),b={version:t,requires:"web_app_biometry_request_auth",isTma:u},v=B({...b,returns:"either"}),y=B({...b,returns:"task"}),w=B({...b,isMounted:f.isMounted,returns:"task"});this.isAvailable=h.getter("available"),this.isMounted=f.isMounted,this.isSupported=ie("web_app_biometry_request_auth",t),this.state=h.state,this.unmount=f.unmount,this.mountFp=y(f.mount),this.authenticateFp=w(g=>this.isAvailable()?d(n("web_app_biometry_request_auth","biometry_auth_requested",{...g,params:{reason:((g||{}).reason||"").trim()}}),V(S=>(h.setState({token:S.token}),S))):N(us)),this.openSettingsFp=v(()=>r("web_app_biometry_open_settings")),this.requestAccessFp=w(g=>d(n("web_app_biometry_request_access","biometry_info_received",{...g,params:{reason:((g||{}).reason||"").trim()}}),he(S=>{const _=pn(S);return _.available?(h.setState(_),R(_.accessRequested)):N(us)}))),this.updateTokenFp=w((g={})=>{var S;return d(n("web_app_biometry_update_token","biometry_token_updated",{...g,params:{token:g.token||"",reason:(S=g.reason)==null?void 0:S.trim()}}),V(_=>_.status))}),this.authenticate=m(this.authenticateFp),this.openSettings=m(this.openSettingsFp),this.requestAccess=m(this.requestAccessFp),this.updateToken=m(this.updateTokenFp),this.mount=m(this.mountFp)}}const hn=(e,t,n)=>zt(e,t,{postEvent:Me,...n}),ru=(...e)=>rt.fn(()=>hn(...e)()),Y=Je({request:hn}),su=new cs({...d(E(),z,A,Y,ge("biometry")),offInfoReceived(e){ke("biometry_info_received",e)},onInfoReceived(e){return ee("biometry_info_received",e)}});class ls{constructor({postEvent:t,storage:n,isTma:r,isPageReload:i}){o(this,"isConfirmationEnabled");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"disableConfirmationFp");o(this,"disableConfirmation");o(this,"enableConfirmationFp");o(this,"enableConfirmation");const s=new be({initialState:{isConfirmationEnabled:!1},onChange(f){n.set(f)}}),a=new Ke({onMounted:s.setState,restoreState:n.get,initialState:{isConfirmationEnabled:!1},isPageReload:i}),u={requires:"web_app_setup_closing_behavior",isTma:r},l=B({...u,returns:"plain"}),c=B({...u,returns:"either",isMounted:a.isMounted}),h=f=>f===this.isConfirmationEnabled()?P(void 0):(s.setState({isConfirmationEnabled:f}),t("web_app_setup_closing_behavior",{need_confirmation:f}));this.isConfirmationEnabled=s.getter("isConfirmationEnabled"),this.isMounted=a.isMounted,this.disableConfirmationFp=c(()=>h(!1)),this.enableConfirmationFp=c(()=>h(!0)),this.mountFp=l(()=>{const f=()=>{};return d(a.mount(),Re(f,f))}),this.unmount=a.unmount,this.disableConfirmation=m(this.disableConfirmationFp),this.enableConfirmation=m(this.enableConfirmationFp),this.mount=m(this.mountFp)}}const iu=new ls(d(E(),ge("closingBehavior"),z));class ps{constructor({version:t,isTma:n,invokeCustomMethod:r}){o(this,"isSupported");o(this,"deleteItemFp");o(this,"deleteItem");o(this,"getItemFp");o(this,"getItem");o(this,"getItemsFp");o(this,"getItems");o(this,"getKeysFp");o(this,"getKeys");o(this,"setItemFp");o(this,"setItem");o(this,"clearFp");o(this,"clear");const i=B({version:t,requires:"web_app_invoke_custom_method",isTma:n,returns:"task"});this.isSupported=ie("web_app_invoke_custom_method",t),this.deleteItemFp=i((s,a)=>{const u=Array.isArray(s)?s:[s];return d(u.length?r("deleteStorageValues",{keys:u},a):R(void 0),V(()=>{}))}),this.getItemFp=i((s,a)=>d(this.getItemsFp([s],a),V(u=>u[s]||""))),this.getItemsFp=i((s,a)=>d(s.length?r("getStorageValues",{keys:s},a):R({}),V(u=>({...s.reduce((l,c)=>(l[c]="",l),{}),..._e(At(C(),C()),u)})))),this.getKeysFp=i(s=>d(r("getStorageKeys",{},s),V(a=>_e(Tn(C()),a)))),this.setItemFp=i((s,a,u)=>d(r("saveStorageValue",{key:s,value:a},u),V(()=>{}))),this.clearFp=i(s=>d(this.getKeysFp(s),he(this.deleteItemFp))),this.deleteItem=m(this.deleteItemFp),this.getItem=m(this.getItemFp),this.getItems=m(this.getItemsFp),this.getKeys=m(this.getKeysFp),this.setItem=m(this.setItemFp),this.clear=m(this.clearFp)}}const fn=Qe(0);function dn(){return fn.set(fn()+1),fn().toString()}function hs(e,t,n){return pa(e,t,dn(),{...n||{},postEvent:Me})}const _n=Je({invokeCustomMethod:hs}),ou=new ps(d(E(),A,_n));function au({request:e,...t}){return T(n=>d(e("web_app_request_emoji_status_access","emoji_status_access_requested",n),V(r=>r.status)),{...t,requires:"web_app_request_emoji_status_access",returns:"task"})}const fs=au(d(E(),A,Y)),uu=m(fs);function cu({request:e,...t}){return T((n,r)=>d(e("web_app_set_emoji_status",["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:n,duration:(r||{}).duration},...r}),Pe(i=>i&&"error"in i?N(new ts(i.error)):R(void 0))),{...t,requires:"web_app_set_emoji_status",returns:"task"})}const ds=cu(d(E(),Y,A)),lu=m(ds);class _s{constructor({postEvent:t,isTma:n,version:r}){o(this,"isSupported");o(this,"impactOccurredFp");o(this,"impactOccurred");o(this,"notificationOccurredFp");o(this,"notificationOccurred");o(this,"selectionChangedFp");o(this,"selectionChanged");const i="web_app_trigger_haptic_feedback",s=B({requires:i,isTma:n,version:r,returns:"plain"});this.isSupported=ie(i,r),this.impactOccurredFp=s(a=>t(i,{type:"impact",impact_style:a})),this.notificationOccurredFp=s(a=>t(i,{type:"notification",notification_type:a})),this.selectionChangedFp=s(()=>t(i,{type:"selection_change"})),this.impactOccurred=m(this.impactOccurredFp),this.notificationOccurred=m(this.notificationOccurredFp),this.selectionChanged=m(this.selectionChangedFp)}}const pu=new _s(d(E(),z,A));function hu({postEvent:e,...t}){return T(()=>e("web_app_add_to_home_screen"),{...t,requires:"web_app_add_to_home_screen",returns:"either"})}const ms=hu(d(E(),A,z)),fu=m(ms);function du({request:e,...t}){return T(n=>d(e("web_app_check_home_screen","home_screen_checked",n),V(r=>r.status||"unknown")),{...t,requires:"web_app_check_home_screen",returns:"task"})}const bs=du(d(E(),A,Y)),_u=m(bs);class gs{constructor({retrieveInitData:t}){o(this,"_state",W());o(this,"_raw",W());o(this,"state",F(this._state));o(this,"authDate",this.fromState("auth_date"));o(this,"canSendAfter",this.fromState("can_send_after"));o(this,"canSendAfterDate",F(()=>{const t=this.authDate(),n=this.canSendAfter();return n&&t?new Date(t.getTime()+n*1e3):void 0}));o(this,"chat",this.fromState("chat"));o(this,"chatType",this.fromState("chat_type"));o(this,"chatInstance",this.fromState("chat_instance"));o(this,"hash",this.fromState("hash"));o(this,"queryId",this.fromState("query_id"));o(this,"raw",F(this._raw));o(this,"receiver",this.fromState("receiver"));o(this,"signature",this.fromState("signature"));o(this,"startParam",this.fromState("start_param"));o(this,"user",this.fromState("user"));o(this,"restoreFp");o(this,"restore");this.restoreFp=()=>d(t(),Z(Kr(()=>{},({raw:n,obj:r})=>{this._state.set(r),this._raw.set(n)}))),this.restore=X(this.restoreFp)}fromState(t){return F(()=>{const n=this._state();return n?n[t]:void 0})}}const mu=new gs({retrieveInitData(){return d(ci,In("obj",()=>d(Be(),Z(({tgWebAppData:e})=>e?He(e):Te))),In("raw",Gt),Z(({obj:e,raw:t})=>d($a,Jr("obj",()=>e),Jr("raw",()=>t))))}});class vs{constructor({version:t,request:n,isTma:r}){o(this,"isOpened");o(this,"isSupported");o(this,"openSlugFp");o(this,"openSlug");o(this,"openUrlFp");o(this,"openUrl");const i=B({version:t,isTma:r,requires:"web_app_open_invoice",returns:"task"}),s=W(!1),a=()=>{s.set(!1)};this.isSupported=ie("web_app_open_invoice",t),this.isOpened=F(s),this.openSlugFp=i((u,l)=>d(this.isOpened()?N(new ht("Invoice is already opened")):R(void 0),he(()=>(s.set(!0),n("web_app_open_invoice","invoice_closed",{...l,params:{slug:u},capture:c=>u===c.slug}))),nn(c=>(a(),c),c=>(a(),c.status)))),this.openUrlFp=i((u,l)=>{const{hostname:c,pathname:h}=new URL(u,window.location.href);if(c!=="t.me")return N(new ne(`Link has unexpected hostname: ${c}`));const f=h.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return f?this.openSlugFp(f[2],l):N(new ne('Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"'))}),this.openUrl=m(this.openUrlFp),this.openSlug=m(this.openSlugFp)}}const bu=new vs(d(E(),Y,A));function gu({postEvent:e,...t}){return T((n,r={})=>{if(typeof n=="string")try{n=new URL(n)}catch(i){return O(new ne(`"${n.toString()}" is invalid URL`,i))}return e("web_app_open_link",{url:n.toString(),try_browser:r.tryBrowser,try_instant_view:r.tryInstantView})},{...t,returns:"either"})}const ws=gu(d(E(),z)),vu=m(ws);function wu({postEvent:e,version:t,...n}){return T(r=>{const i=r.toString();return i.match(/^https:\/\/t.me\/.+/)?pe("web_app_open_tg_link",Q(t))?(r=new URL(r),e("web_app_open_tg_link",{path_full:r.pathname+r.search})):(window.location.href=i,P(void 0)):O(new ne(`"${i}" is invalid URL`))},{...n,returns:"either"})}const mn=wu(d(E(),z,A)),yu=m(mn);function Cu({openTelegramLink:e,...t}){return T((n,r)=>e("https://t.me/share/url?"+new URLSearchParams({url:n,text:r||""}).toString().replace(/\+/g,"%20")),{...t,returns:"either"})}const ys=Cu({...E(),openTelegramLink:mn}),Fu=m(ys);function Su(e){let t=!1,n,r;return e.available&&(t=!0,n=e.access_requested,r=e.access_granted),{available:t,accessGranted:r||!1,accessRequested:n||!1}}class Cs{constructor({version:t,request:n,postEvent:r,storage:i,isTma:s,isPageReload:a}){o(this,"state");o(this,"isAvailable");o(this,"isAccessGranted");o(this,"isAccessRequested");o(this,"isMounted");o(this,"isSupported");o(this,"openSettingsFp");o(this,"openSettings");o(this,"requestLocationFp");o(this,"requestLocation");o(this,"mountFp");o(this,"mount");o(this,"unmount");const u=new be({initialState:{available:!1,accessGranted:!1,accessRequested:!1},onChange:i.set}),l=new ln({isPageReload:a,restoreState:i.get,onMounted:u.setState,initialState(v){return d(n("web_app_check_location","location_checked",v),V(Su))}}),c={version:t,requires:"web_app_check_location",isTma:s},h=B({...c,returns:"either"}),f=B({...c,returns:"task"}),b=B({...c,returns:"task",isMounted:l.isMounted});this.isAvailable=u.getter("available"),this.isAccessRequested=u.getter("accessRequested"),this.isAccessGranted=u.getter("accessGranted"),this.isSupported=ie("web_app_check_location",t),this.isMounted=l.isMounted,this.state=u.state,this.unmount=l.unmount,this.mountFp=f(l.mount),this.openSettingsFp=h(()=>r("web_app_open_location_settings")),this.requestLocationFp=b(v=>d(n("web_app_request_location","location_requested",v),V(y=>{if(!y.available)return u.setState({available:!1}),null;const{available:w,...g}=y;return g}))),this.mount=m(this.mountFp),this.openSettings=m(this.openSettingsFp),this.requestLocation=m(this.requestLocationFp)}}const ku=new Cs(d(E(),z,A,Y,ge("locationManager")));class Fs{constructor({defaults:t,...n}){o(this,"bgColor");o(this,"hasShineEffect");o(this,"isEnabled");o(this,"isLoaderVisible");o(this,"isVisible");o(this,"isMounted");o(this,"state");o(this,"text");o(this,"textColor");o(this,"showFp");o(this,"show");o(this,"hideFp");o(this,"hide");o(this,"enableFp");o(this,"enable");o(this,"enableShineEffectFp");o(this,"enableShineEffect");o(this,"disableFp");o(this,"disable");o(this,"disableShineEffectFp");o(this,"disableShineEffect");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"setTextColorFp");o(this,"setTextColor");o(this,"setTextFp");o(this,"setText");o(this,"showLoaderFp");o(this,"showLoader");o(this,"hideLoaderFp");o(this,"hideLoader");o(this,"setParamsFp");o(this,"setParams");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");const r=new ft({...n,version:"100",initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"},method:"web_app_setup_main_button",payload:s=>({has_shine_effect:s.hasShineEffect,is_visible:s.isVisible,is_active:s.isEnabled,is_progress_visible:s.isLoaderVisible,text:s.text,color:s.bgColor,text_color:s.textColor})}),i=(s,a)=>{const u=r.stateGetter(s);return F(()=>u()||Q(a))};this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.hasShineEffect=r.stateGetter("hasShineEffect"),this.isEnabled=r.stateGetter("isEnabled"),this.isLoaderVisible=r.stateGetter("isLoaderVisible"),this.text=r.stateGetter("text"),this.isVisible=r.stateGetter("isVisible"),this.isMounted=r.isMounted,this.state=r.state,[this.setBgColor,this.setBgColorFp]=r.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=r.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=r.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=r.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=r.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=r.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=r.stateBoolSetters("isVisible"),this.setParams=r.setState,this.setParamsFp=r.setStateFp,this.onClick=r.onClick,this.onClickFp=r.onClickFp,this.offClick=r.offClick,this.offClickFp=r.offClickFp,this.mount=r.mount,this.mountFp=r.mountFp,this.unmount=r.unmount}}function Ss(e,t,n){return d(cn(e,t),r=>({...r,defaults:n}))}const bn=Qe({});function gn(e,t){document.documentElement.style.setProperty(e,t)}function vn(e){document.documentElement.style.removeProperty(e)}function ks(e){return d(ot(e),Z(t=>Math.sqrt([.299,.587,.114].reduce((n,r,i)=>{const s=parseInt(t.slice(1+i*2,1+(i+1)*2),16);return n+s*s*r},0))<120))}const wn=X(ks);class Es{constructor({initialState:t,onChange:n,offChange:r,isTma:i,storage:s,isPageReload:a}){o(this,"accentTextColor");o(this,"bgColor");o(this,"buttonColor");o(this,"buttonTextColor");o(this,"bottomBarBgColor");o(this,"destructiveTextColor");o(this,"headerBgColor");o(this,"hintColor");o(this,"linkColor");o(this,"secondaryBgColor");o(this,"sectionBgColor");o(this,"sectionHeaderTextColor");o(this,"sectionSeparatorColor");o(this,"subtitleTextColor");o(this,"textColor");o(this,"_isCssVarsBound",W(!1));o(this,"isCssVarsBound",F(this._isCssVarsBound));o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"state");o(this,"isDark",F(()=>{const t=this.bgColor();return!t||wn(t)}));o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");const u=new be({initialState:{},onChange:s.set}),l=v=>{u.setState(v.theme_params)},c=new Ke({initialState:()=>P(Q(t)),isPageReload:a,onMounted(v){u.setState(v),n(l)},onUnmounted(){r(l)},restoreState:s.get}),h={isTma:i,returns:"either"},f=B(h),b=B({...h,isMounted:c.isMounted});this.accentTextColor=u.getter("accent_text_color"),this.bgColor=u.getter("bg_color"),this.buttonColor=u.getter("button_color"),this.buttonTextColor=u.getter("button_text_color"),this.bottomBarBgColor=u.getter("bottom_bar_bg_color"),this.destructiveTextColor=u.getter("destructive_text_color"),this.headerBgColor=u.getter("header_bg_color"),this.hintColor=u.getter("hint_color"),this.linkColor=u.getter("link_color"),this.secondaryBgColor=u.getter("secondary_bg_color"),this.sectionBgColor=u.getter("section_bg_color"),this.sectionHeaderTextColor=u.getter("section_header_text_color"),this.sectionSeparatorColor=u.getter("section_separator_color"),this.subtitleTextColor=u.getter("subtitle_text_color"),this.textColor=u.getter("text_color"),this.state=u.state,this.isMounted=c.isMounted,this.bindCssVarsFp=b(v=>{if(this._isCssVarsBound())return O(new pt);v||(v=g=>`--tg-theme-${Ii(g)}`);const y=g=>{Object.entries(u.state()).forEach(([S,_])=>{_&&g(S,_)})},w=()=>{y((g,S)=>{gn(v(g),S)})};return w(),u.state.sub(w),this._isCssVarsBound.set(!0),P(()=>{y(vn),u.state.unsub(w),this._isCssVarsBound.set(!1)})}),this.mountFp=f(c.mount),this.unmount=c.unmount,this.bindCssVars=m(this.bindCssVarsFp),this.mount=m(this.mountFp)}}const Ze=new Es({...d(E(),ge("themeParams")),offChange(e){ke("theme_changed",e)},onChange(e){ee("theme_changed",e)},initialState:bn}),Eu=new Fs(Ss("mainButton","main_button_pressed",{bgColor:F(()=>Ze.buttonColor()||"#2481cc"),textColor:F(()=>Ze.buttonTextColor()||"#ffffff")}));class $s{constructor({storage:t,isPageReload:n,version:r,postEvent:i,isTma:s,theme:a,onVisibilityChanged:u,offVisibilityChanged:l}){o(this,"isSupported");o(this,"isDark",F(()=>{const t=this.bgColorRgb();return t?wn(t):!1}));o(this,"isActive");o(this,"state");o(this,"isCssVarsBound");o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"bgColor");o(this,"bgColorRgb");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"headerColor");o(this,"headerColorRgb");o(this,"setHeaderColorFp");o(this,"setHeaderColor");o(this,"bottomBarColor");o(this,"bottomBarColorRgb");o(this,"setBottomBarColorFp");o(this,"setBottomBarColor");o(this,"closeFp");o(this,"close");o(this,"readyFp");o(this,"ready");const c=_=>{b.setState({isActive:_.is_visible})},h=_=>{[[this.headerColor,"web_app_set_header_color"],[this.bgColor,"web_app_set_background_color"],[this.bottomBarColor,"web_app_set_bottom_bar_color"]].forEach(([D,M])=>{const U=D();if(!Ue(U)&&(M==="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes(U))){const k=_[U];k&&i(M,{color:k})}})},f=new Ke({initialState(){const _=Q(a);return P({bgColor:_.bg_color||"bg_color",headerColor:_.header_bg_color||"header_bg_color",bottomBarColor:_.bottom_bar_bg_color||"bottom_bar_bg_color",isActive:!0})},isPageReload:n,onMounted:_=>{this.setBgColorFp.ifAvailable(_.bgColor),this.setBottomBarColorFp.ifAvailable(_.bottomBarColor),this.setHeaderColorFp.ifAvailable(_.headerColor),u(c),a.sub(h),b.setState(_)},onUnmounted(){l(c),a.unsub(h)},restoreState:t.get});this.isMounted=f.isMounted,this.mountFp=T(()=>{const _=()=>{};return d(f.mount(),Re(_,_))},{isTma:s,returns:"plain"}),this.mount=m(this.mountFp),this.unmount=f.unmount;const b=new be({initialState:{bgColor:"bg_color",bottomBarColor:"bottom_bar_bg_color",headerColor:"bg_color",isActive:!1},onChange:t.set});this.state=b.state;const v=_=>Ue(_)?_:Q(a)[_],y=_=>F(()=>v(_()));this.isActive=b.getter("isActive"),this.isSupported=F(()=>["web_app_set_header_color","web_app_set_background_color","web_app_set_bottom_bar_color"].some(_=>pe(_,Q(r))));const w=W(!1);this.isCssVarsBound=F(w),this.bindCssVarsFp=T(_=>{if(w())return O(new pt);const[D,M]=st(()=>{w.set(!1)}),U=(k,L)=>{const I=()=>{gn(k,L()||null)};I(),D(L.sub(I),vn.bind(null,k))};return _||(_=k=>`--tg-${jn(k)}`),U(_("bgColor"),this.bgColorRgb),U(_("bottomBarColor"),this.bottomBarColorRgb),U(_("headerColor"),this.headerColorRgb),w.set(!0),P(M)},{isTma:s,returns:"either",isMounted:this.isMounted}),this.bindCssVars=m(this.bindCssVarsFp);const g=_=>{const D=b.getter(_),M=y(D),U={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[_],k=T(L=>{if(L===D())return P(void 0);if(U==="web_app_set_header_color"&&(L==="bg_color"||L==="secondary_bg_color"))return i("web_app_set_header_color",{color_key:L});const I=v(L);return d(I?i(U,{color:I}):O(new ss(L)),Z(()=>{b.setState({[_]:I})}))},{isTma:s,version:r,requires:U,isMounted:this.isMounted,returns:"either",supports:_==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:Ue}}:void 0});return[D,M,m(k),k]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=g("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=g("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=g("bottomBarColor");const S=B({isTma:s,returns:"either"});this.closeFp=S(_=>i("web_app_close",{return_back:_})),this.close=m(this.closeFp),this.readyFp=S(()=>i("web_app_ready")),this.ready=m(this.readyFp)}}const As=new $s({...d(E(),z,A,ge("miniApp")),offVisibilityChanged(e){ke("visibility_changed",e)},onVisibilityChanged(e){ee("visibility_changed",e)},theme:Ze.state});function $u(e){const t=e.message.trim(),n=(e.title||"").trim(),r=e.buttons||[];if(n.length>64)return O(new ne(`Invalid title: ${n}`));if(!t||t.length>256)return O(new ne(`Invalid message: ${t}`));if(r.length>3)return O(new ne(`Invalid buttons count: ${r.length}`));const i=[];if(!r.length)i.push({type:"close",id:""});else for(let s=0;s<r.length;s++){const a=r[s],u=a.id||"";if(u.length>64)return O(new ne(`Button with index ${s} has invalid id: ${u}`));if(!a.type||a.type==="default"||a.type==="destructive"){const l=a.text.trim();if(!l||l.length>64)return O(new ne(`Button with index ${s} has invalid text: ${l}`));i.push({type:a.type,text:l,id:u})}else i.push({type:a.type,id:u})}return P({title:n,message:t,buttons:i})}class Is{constructor({version:t,isTma:n,request:r}){o(this,"isOpened");o(this,"isSupported");o(this,"showFp");o(this,"show");const i=W(!1),s=()=>{i.set(!1)},a=B({version:t,isTma:n,requires:"web_app_open_popup",returns:"task"});this.isSupported=ie("web_app_open_popup",t),this.isOpened=F(i),this.showFp=a(u=>d(this.isOpened()?N(new ht("A popup is already opened")):R(void 0),Pe(()=>Yr($u(u))),he(l=>(i.set(!0),r("web_app_open_popup","popup_closed",{...u,params:l}))),nn(l=>(s(),l),l=>(s(),l.button_id)))),this.show=m(this.showFp)}}const Au=new Is(d(E(),Y,A));function Iu({request:e,...t}){return T(n=>d(e("web_app_request_phone","phone_requested",n),V(r=>r.status)),{...t,requires:"web_app_request_phone",returns:"task"})}const yn=Iu(d(E(),A,Y)),qu=m(yn);function Bu({invokeCustomMethod:e,requestPhoneAccess:t,...n}){const r=a=>d(e("getRequestedContact",{},{...a,timeout:(a||{}).timeout||5e3}),Pe(u=>{const l=qt(C(),u);if(!l.success)return N(new ze(u,l.issues));if(!l.output)return R(void 0);const c=qt(Rt(j({contact:me(j({user_id:de(),phone_number:C(),first_name:C(),last_name:$(C())})),auth_date:se(C(),ue(h=>new Date(Number(h)*1e3)),tt()),hash:C()})),l.output);return c.success?R({raw:l.output,parsed:c.output}):N(new ze(l.output,c.issues))})),i=a=>d(r(a),xa(u=>ze.is(u)?O(u):P(void 0),u=>P(u))),s=a=>De(async(u,l,c)=>{let h=50;for(;!c.isRejected;){const f=await i(c)();if(f._tag==="Left")return l(f.left);if(f.right)return u(f.right);await new Promise(b=>setTimeout(b,h)),h+=50}},a);return T(a=>De.fn(u=>d(i(u),he(l=>l?R(l):d(t(u),Pe(c=>c==="sent"?s(u):N(new sn("User denied access")))))),a),{...n,returns:"task",requires:"web_app_request_phone"})}function Tu({requestContact:e,...t}){return T(e,{...t,returns:"task",requires:"web_app_request_phone"})}const Cn=Bu({...d(E(),_n,A),requestPhoneAccess:yn}),Pu=m(Cn),qs=Tu({...d(E(),A),requestContact(e){return d(Cn(e),V(t=>t.parsed))}}),Mu=m(qs);function Lu({request:e,...t}){return T(n=>d(e("web_app_request_write_access","write_access_requested",n),V(r=>r.status)),{...t,requires:"web_app_request_write_access",returns:"task"})}const Bs=Lu(d(E(),A,Y)),Vu=m(Bs);class Ts{constructor({version:t,onClosed:n,onTextReceived:r,isTma:i,postEvent:s}){o(this,"isOpened");o(this,"isSupported");o(this,"captureFp");o(this,"capture");o(this,"closeFp");o(this,"close");o(this,"openFp");o(this,"open");const a={version:t,requires:"web_app_open_scan_qr_popup",isTma:i},u=B({...a,returns:"either"}),l=B({...a,returns:"task"}),c=W(!1),h=()=>{c.set(!1)};this.isSupported=ie("web_app_open_scan_qr_popup",t),this.isOpened=F(c),this.captureFp=l(f=>{let b;return d(this.openFp({...f,onCaptured:v=>{f.capture(v)&&(b=v,this.close())}}),V(()=>b))}),this.closeFp=u(()=>d(s("web_app_close_scan_qr_popup"),Z(h))),this.openFp=l(f=>d(this.isOpened()?N(new ht("The QR Scanner is already opened")):async()=>s("web_app_open_scan_qr_popup",{text:f.text}),Pe(()=>{const[b,v]=st(),y=w=>(v(),w);return d(De(w=>{b(n(w),r(f.onCaptured))},f),nn(y,y))}))),this.open=m(this.openFp),this.capture=m(this.captureFp),this.close=m(this.closeFp)}}const Ru=new Ts({...d(E(),z,A),onClosed(e){return ee("scan_qr_popup_closed",e)},onTextReceived(e){return ee("qr_text_received",t=>{e(t.data)})}});class Ps{constructor({defaults:t,...n}){o(this,"isSupported");o(this,"position");o(this,"bgColor");o(this,"hasShineEffect");o(this,"isEnabled");o(this,"isLoaderVisible");o(this,"isVisible");o(this,"isMounted");o(this,"state");o(this,"text");o(this,"textColor");o(this,"showFp");o(this,"show");o(this,"hideFp");o(this,"hide");o(this,"enableFp");o(this,"enable");o(this,"enableShineEffectFp");o(this,"enableShineEffect");o(this,"disableFp");o(this,"disable");o(this,"disableShineEffectFp");o(this,"disableShineEffect");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"setTextColorFp");o(this,"setTextColor");o(this,"setTextFp");o(this,"setText");o(this,"setPositionFp");o(this,"setPosition");o(this,"showLoaderFp");o(this,"showLoader");o(this,"hideLoaderFp");o(this,"hideLoader");o(this,"setParamsFp");o(this,"setParams");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");const r=new ft({...n,initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Cancel",position:"left"},method:"web_app_setup_secondary_button",payload:s=>({has_shine_effect:s.hasShineEffect,is_visible:s.isVisible,is_active:s.isEnabled,is_progress_visible:s.isLoaderVisible,text:s.text,color:s.bgColor,text_color:s.textColor,position:s.position})}),i=(s,a)=>{const u=r.stateGetter(s);return F(()=>u()||Q(a))};this.isSupported=ie("web_app_setup_secondary_button",n.version),this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.position=r.stateGetter("position"),this.hasShineEffect=r.stateGetter("hasShineEffect"),this.isEnabled=r.stateGetter("isEnabled"),this.isLoaderVisible=r.stateGetter("isLoaderVisible"),this.text=r.stateGetter("text"),this.isVisible=r.stateGetter("isVisible"),this.isMounted=r.isMounted,this.state=r.state,[this.setPosition,this.setPositionFp]=r.stateSetters("position"),[this.setBgColor,this.setBgColorFp]=r.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=r.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=r.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=r.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=r.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=r.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=r.stateBoolSetters("isVisible"),this.setParams=r.setState,this.setParamsFp=r.setStateFp,this.onClick=r.onClick,this.onClickFp=r.onClickFp,this.offClick=r.offClick,this.offClickFp=r.offClickFp,this.mount=r.mount,this.mountFp=r.mountFp,this.unmount=r.unmount}}const Ou=new Ps(Ss("secondaryButton","secondary_button_pressed",{bgColor:F(()=>As.bottomBarColorRgb()||"#000000"),textColor:F(()=>Ze.buttonColor()||"#2481cc")}));class Ms{constructor(t){o(this,"isVisible");o(this,"isMounted");o(this,"isSupported");o(this,"hideFp");o(this,"hide");o(this,"showFp");o(this,"show");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const n=new ft({...t,method:"web_app_setup_settings_button",payload:r=>({is_visible:r.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}const ju=new Ms(cn("settingsButton","settings_button_pressed"));class Ls{constructor({postEvent:t,storage:n,isTma:r,isPageReload:i,version:s}){o(this,"isSupported");o(this,"isVerticalEnabled");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"disableVerticalFp");o(this,"disableVertical");o(this,"enableVerticalFp");o(this,"enableVertical");const a=new be({initialState:{isVerticalEnabled:!1},onChange(b){n.set(b)}}),u=new Ke({initialState:{isVerticalEnabled:!1},isPageReload:i,onMounted:a.setState,restoreState:n.get}),l={requires:"web_app_setup_swipe_behavior",isTma:r,version:s},c=B({...l,returns:"plain"}),h=B({...l,isMounted:u.isMounted,returns:"either"}),f=b=>{const v={isVerticalEnabled:b};return a.hasDiff(v)?d(t("web_app_setup_swipe_behavior",{allow_vertical_swipe:b}),Z(()=>{a.setState(v)})):P(void 0)};this.isSupported=ie("web_app_setup_swipe_behavior",s),this.isVerticalEnabled=a.getter("isVerticalEnabled"),this.isMounted=u.isMounted,this.disableVerticalFp=h(()=>f(!1)),this.enableVerticalFp=h(()=>f(!0)),this.mountFp=c(()=>{const b=()=>{};return d(u.mount(),Re(b,b))}),this.unmount=u.unmount,this.disableVertical=m(this.disableVerticalFp),this.enableVertical=m(this.enableVerticalFp),this.mount=m(this.mountFp)}}const Du=new Ls(d(E(),z,A,ge("swipeBehavior")));async function Uu(e){try{const{clipboard:n}=navigator;if(n)return await n.writeText(e)}catch{}const t=document.createElement("textarea");t.value=e,t.style.top="0",t.style.left="0",t.style.position="fixed",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}finally{document.body.removeChild(t)}}function xu({request:e,...t}){return T((n,r,i)=>d(e("web_app_request_file_download","file_download_requested",{...i,params:{url:n,file_name:r}}),he(s=>s.status==="downloading"?R(void 0):N(new sn("User denied the action")))),{...t,requires:"web_app_request_file_download",returns:"task"})}const Vs=xu(d(E(),Y,A)),Gu=m(Vs);function Wu({invokeCustomMethod:e,...t}){return T(n=>d(e("getCurrentTime",{},n),he(r=>{const i=qt(se(de(),Ft(),ue(s=>new Date(s*1e3)),tt()),r);return i.success?R(i.output):N(new ze(r,i.issues))})),{...t,requires:"web_app_invoke_custom_method",returns:"task"})}const Rs=Wu(d(E(),_n,A)),Hu=m(Rs);function Nu({postEvent:e,...t}){return T(()=>e("web_app_hide_keyboard"),{...t,returns:"either",requires:"web_app_hide_keyboard"})}const Os=Nu(d(E(),z,A)),zu=m(Os);function Ku({request:e,createRequestId:t,...n}){return T(r=>{const i=t();return d(e("web_app_read_text_from_clipboard","clipboard_text_received",{...r,params:{req_id:i},capture:Gr(i)}),V(({data:s=null})=>s))},{...n,requires:"web_app_read_text_from_clipboard",returns:"task"})}const js=Ku({...d(E(),A,Y),createRequestId:dn}),Ju=m(js);function Ds(e){const t={},n=e.match(/Telegram-Android(?:\/([^ ]+))?(?: (\([^)]+\))?|$)/);if(n){const[,r,i]=n;r&&(t.appVersion=r),i&&i.slice(1,i.length-1).split(";").forEach(s=>{const[a,u]=s.trim().split(" ");if(a==="Android")t.androidVersion=u;else if(a==="SDK"){const l=parseInt(u,10);l&&(t.sdkVersion=l)}else u?(t.manufacturer=a,t.model=u):t.performanceClass=a})}return t}function Qu(){return Ds(navigator.userAgent)}function Zu({postEvent:e,...t}){return T(n=>{const{size:r}=new Blob([n]);return!r||r>4096?O(new ne(r?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data")):e("web_app_data_send",{data:n})},{...t,returns:"either"})}const Us=Zu(d(E(),z)),Yu=m(Us);function Xu({request:e,...t}){return T((n,r)=>d(e("web_app_send_prepared_message",["prepared_message_failed","prepared_message_sent"],{...r,params:{id:n}}),he(i=>i&&"error"in i?N(new rs(i.error)):R(void 0))),{...t,requires:"web_app_send_prepared_message",returns:"task"})}const xs=Xu(d(E(),Y,A)),ec=m(xs);function tc({postEvent:e,...t}){return T((n,r={})=>e("web_app_share_to_story",{text:r.text,media_url:n,widget_link:r.widgetLink}),{...t,requires:"web_app_share_to_story",returns:"either"})}const Gs=tc(d(E(),z,A)),nc=m(Gs),Fn=Qe(!1);function rc({isInlineMode:e,postEvent:t,...n}){return T((r,i)=>t("web_app_switch_inline_query",{query:r,chat_types:i||[]}),{...n,requires:{every:["web_app_switch_inline_query",()=>Q(e)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}const Ws=rc({...d(E(),z,A),isInlineMode:Fn}),sc=m(Ws);class Hs{constructor({storage:t,isPageReload:n,onContentSafeAreaInsetsChanged:r,onSafeAreaInsetsChanged:i,onViewportChanged:s,onFullscreenChanged:a,offContentSafeAreaInsetsChanged:u,offFullscreenChanged:l,offSafeAreaInsetsChanged:c,offViewportChanged:h,request:f,isViewportStable:b,isFullscreen:v,isTma:y,version:w,postEvent:g}){o(this,"state");o(this,"height");o(this,"stableHeight");o(this,"width");o(this,"isExpanded");o(this,"isStable",F(()=>this.height()===this.stableHeight()));o(this,"contentSafeAreaInsets");o(this,"contentSafeAreaInsetTop");o(this,"contentSafeAreaInsetLeft");o(this,"contentSafeAreaInsetRight");o(this,"contentSafeAreaInsetBottom");o(this,"safeAreaInsets");o(this,"safeAreaInsetTop");o(this,"safeAreaInsetLeft");o(this,"safeAreaInsetRight");o(this,"safeAreaInsetBottom");o(this,"isFullscreen");o(this,"requestFullscreenFp");o(this,"requestFullscreen");o(this,"exitFullscreenFp");o(this,"exitFullscreen");o(this,"isCssVarsBound");o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"expandFp");o(this,"expand");const S={top:0,right:0,left:0,bottom:0},_=new be({initialState:{contentSafeAreaInsets:S,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:S,stableHeight:0,width:0},onChange:t.set}),D=q=>{_.setState({isExpanded:q.is_expanded,height:q.height,width:q.width,stableHeight:q.is_state_stable?q.height:void 0})},M=q=>{_.setState({isFullscreen:q.is_fullscreen})},U=q=>{_.setState({safeAreaInsets:q})},k=q=>{_.setState({contentSafeAreaInsets:q})},L=new ln({initialState(q){const $e=fe=>()=>{const[ve,re]=fe==="safe-area"?["web_app_request_safe_area","safe_area_changed"]:["web_app_request_content_safe_area","content_safe_area_changed"];return pe(ve,Q(w))?f(ve,re,q):R({top:0,left:0,right:0,bottom:0})},G=fe=>()=>typeof fe=="boolean"?R(fe):Yr(fe());return d(Qa,lt("safeAreaInsets",$e("safe-area")),lt("contentSafeAreaInsets",$e("content-safe-area")),lt("isFullscreen",G(v)),lt("isViewportStable",G(b)),Pe(({isViewportStable:fe,...ve})=>fe?R({...ve,height:window.innerHeight,isExpanded:!0,stableHeight:window.innerHeight,width:window.innerWidth}):d(f("web_app_request_viewport","viewport_changed",q),V(re=>({...ve,height:re.height,isExpanded:re.is_expanded,stableHeight:re.is_state_stable?re.height:0,width:re.width})))))},isPageReload:n,onMounted(q){s(D),a(M),i(U),r(k),_.setState(q)},onUnmounted(){h(D),l(M),c(U),u(k)},restoreState:t.get}),I=q=>F(()=>this.safeAreaInsets()[q]),x=q=>F(()=>this.contentSafeAreaInsets()[q]);this.state=_.state,this.height=_.getter("height"),this.stableHeight=_.getter("stableHeight"),this.width=_.getter("width"),this.isExpanded=_.getter("isExpanded"),this.safeAreaInsets=_.getter("safeAreaInsets"),this.safeAreaInsetTop=I("top"),this.safeAreaInsetBottom=I("bottom"),this.safeAreaInsetLeft=I("left"),this.safeAreaInsetRight=I("right"),this.contentSafeAreaInsets=_.getter("contentSafeAreaInsets"),this.contentSafeAreaInsetTop=x("top"),this.contentSafeAreaInsetBottom=x("bottom"),this.contentSafeAreaInsetLeft=x("left"),this.contentSafeAreaInsetRight=x("right");const Le=B({isTma:y,returns:"task"}),Ye=B({isTma:y,returns:"either"}),uc=B({isTma:y,requires:"web_app_request_fullscreen",version:w,returns:"task"}),zs=q=>uc($e=>d(f(q?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],$e),he(G=>"error"in G&&G.error!=="ALREADY_FULLSCREEN"?N(new ns(G.error)):(_.setState({isFullscreen:"is_fullscreen"in G?G.is_fullscreen:!0}),R(void 0)))));this.isMounted=L.isMounted,this.mountFp=Le(L.mount),this.mount=m(this.mountFp),this.isFullscreen=_.getter("isFullscreen"),this.requestFullscreenFp=zs(!0),this.requestFullscreen=m(this.requestFullscreenFp),this.exitFullscreenFp=zs(!1),this.exitFullscreen=m(this.exitFullscreenFp);const dt=W(!1);this.isCssVarsBound=F(dt),this.bindCssVarsFp=Ye(q=>{if(dt())return O(new pt);q||(q=G=>`--tg-viewport-${jn(G)}`);const $e=[["height",this.height],["stableHeight",this.stableHeight],["width",this.width],["safeAreaInsetTop",this.safeAreaInsetTop],["safeAreaInsetBottom",this.safeAreaInsetBottom],["safeAreaInsetLeft",this.safeAreaInsetLeft],["safeAreaInsetRight",this.safeAreaInsetRight],["contentSafeAreaInsetTop",this.contentSafeAreaInsetTop],["contentSafeAreaInsetBottom",this.contentSafeAreaInsetBottom],["contentSafeAreaInsetLeft",this.contentSafeAreaInsetLeft],["contentSafeAreaInsetRight",this.contentSafeAreaInsetRight]].reduce((G,[fe,ve])=>{const re=q(fe);if(re){const Ks=()=>{gn(re,`${ve()}px`)};G.push({update:Ks,removeListener:ve.sub(Ks),cssVar:re})}return G},[]);return $e.forEach(G=>{G.update()}),dt.set(!0),P(()=>{$e.forEach(G=>{G.removeListener(),vn(G.cssVar)}),dt.set(!1)})}),this.bindCssVars=m(this.bindCssVarsFp),this.expandFp=Ye(()=>g("web_app_expand")),this.expand=m(this.expandFp)}}function ic(){const e=s=>({on:a=>{ee(s,a)},off:a=>{ke(s,a)}}),t=e("viewport_changed"),n=e("fullscreen_changed"),r=e("safe_area_changed"),i=e("content_safe_area_changed");return new Hs({...d(E(),ge("viewport"),A,z,Y),isFullscreen(){return d(Be(),Z(s=>!!s.tgWebAppFullscreen))},isViewportStable(){return d(Be(),Z(s=>["macos","tdesktop","unigram","webk","weba","web"].includes(s.tgWebAppPlatform)))},offContentSafeAreaInsetsChanged:i.off,offFullscreenChanged:n.off,offSafeAreaInsetsChanged:r.off,offViewportChanged:t.off,onContentSafeAreaInsetsChanged:i.on,onFullscreenChanged:n.on,onSafeAreaInsetsChanged:r.on,onViewportChanged:t.on})}const oc=ic();function Ns(e={}){const{version:t,isInlineMode:n,themeParams:r}=e;if(t&&typeof n=="boolean"&&r)un.set(t),Fn.set(n),bn.set(r);else{const u=d(Be(),An(l=>l,l=>{un.set(t||l.tgWebAppVersion),Fn.set(typeof n=="boolean"?n:!!l.tgWebAppBotInline),bn.set(r||l.tgWebAppThemeParams)}));if(u)return O(u)}e.postEvent&&os.set(e.postEvent);const[i,s]=st(ee("reload_iframe",()=>{le().log("Received a request to reload the page"),as("iframe_will_reload"),window.location.reload()})),{acceptCustomStyles:a=!0}=e;if(a){const u=document.createElement("style");u.id="telegram-custom-styles",document.head.appendChild(u),i(ee("set_custom_style",l=>{u.innerHTML=l}),()=>{document.head.removeChild(u)})}return d(Me("iframe_ready",{reload_supported:!0}),Z(()=>(le().log("The package was initialized"),s)))}const ac=X(Ns);return p.AccessDeniedError=sn,p.BackButton=is,p.Biometry=cs,p.CSSVarsBoundError=pt,p.CancelledError=Rn,p.ClosingBehavior=ls,p.CloudStorage=ps,p.ConcurrentCallError=ht,p.FullscreenFailedError=ns,p.FunctionUnavailableError=es,p.HapticFeedback=_s,p.InitData=gs,p.InvalidArgumentsError=ne,p.InvalidEnvError=Ya,p.InvalidLaunchParamsError=Br,p.Invoice=vs,p.InvokeCustomMethodFailedError=Pr,p.LaunchParamsRetrieveError=qr,p.LocationManager=Cs,p.MainButton=Fs,p.MethodParameterUnsupportedError=Ir,p.MethodUnsupportedError=Ar,p.MiniApp=$s,p.NotAvailableError=Xr,p.Popup=Is,p.QrScanner=Ts,p.SecondaryButton=Ps,p.SetEmojiStatusError=ts,p.SettingsButton=Ms,p.ShareMessageError=rs,p.SwipeBehavior=Ls,p.ThemeParams=Es,p.TimeoutError=Tt,p.UnknownEnvError=Tr,p.UnknownThemeParamsKeyError=ss,p.ValidationError=ze,p.Viewport=Hs,p.addToHomeScreen=fu,p.addToHomeScreenFp=ms,p.applyPolyfills=ha,p.backButton=nu,p.biometry=su,p.checkHomeScreenStatus=_u,p.checkHomeScreenStatusFp=bs,p.closingBehavior=iu,p.cloudStorage=ou,p.copyTextToClipboard=Uu,p.createLogger=xn,p.createPostEvent=la,p.createRequestId=dn,p.createStartParam=_a,p.createStartParamFp=Nr,p.debug=Ur,p.decodeBase64Url=fa,p.decodeBase64UrlFp=Qt,p.decodeStartParam=ma,p.decodeStartParamFp=zr,p.deepSnakeToCamelObjKeys=Pt,p.downloadFile=Gu,p.downloadFileFp=Vs,p.emitEvent=ut,p.encodeBase64Url=Zt,p.getCurrentTime=Hu,p.getCurrentTimeFp=Rs,p.getReleaseVersion=Jt,p.hapticFeedback=pu,p.hideKeyboard=zu,p.hideKeyboardFp=Os,p.init=ac,p.initData=mu,p.initFp=Ns,p.invoice=bu,p.invokeCustomMethod=hs,p.isAnyRGB=ir,p.isColorDark=wn,p.isColorDarkFp=ks,p.isRGB=Ue,p.isRGBA=sr,p.isRGBAShort=rr,p.isRGBShort=nr,p.isSafeToCreateStartParam=ba,p.isTMA=aa,p.isTMAFp=Kt,p.locationManager=ku,p.logger=le,p.mainButton=Eu,p.miniApp=As,p.mockTelegramEnv=ua,p.off=ke,p.offAll=ta,p.on=ee,p.openLink=vu,p.openLinkFp=ws,p.openTelegramLink=yu,p.openTelegramLinkFp=mn,p.parseInitDataQuery=ho,p.parseInitDataQueryFp=pr,p.parseLaunchParamsQuery=hr,p.parseLaunchParamsQueryFp=at,p.popup=Au,p.postEvent=as,p.postEventFp=Me,p.qrScanner=Ru,p.readTextFromClipboard=Ju,p.readTextFromClipboardFp=js,p.request=ru,p.requestContact=Mu,p.requestContactComplete=Pu,p.requestContactCompleteFp=Cn,p.requestContactFp=qs,p.requestEmojiStatusAccess=uu,p.requestEmojiStatusAccessFp=fs,p.requestFp=hn,p.requestPhoneAccess=qu,p.requestPhoneAccessFp=yn,p.requestWriteAccess=Vu,p.requestWriteAccessFp=Bs,p.retrieveAndroidDeviceData=Qu,p.retrieveAndroidDeviceDataFrom=Ds,p.retrieveLaunchParams=Jo,p.retrieveLaunchParamsFp=Be,p.retrieveRawInitData=Qo,p.retrieveRawInitDataFp=Gt,p.retrieveRawLaunchParams=Zo,p.retrieveRawLaunchParamsFp=We,p.secondaryButton=Ou,p.sendData=Yu,p.sendDataFp=Us,p.serializeInitDataQuery=dr,p.serializeLaunchParamsQuery=_r,p.setDebug=ra,p.setEmojiStatus=lu,p.setEmojiStatusFp=ds,p.setTargetOrigin=sa,p.settingsButton=ju,p.shareMessage=ec,p.shareMessageFp=xs,p.shareStory=nc,p.shareStoryFp=Gs,p.shareURL=Fu,p.shareURLFp=ys,p.supports=pe,p.swipeBehavior=Du,p.switchInlineQuery=sc,p.switchInlineQueryFp=Ws,p.targetOrigin=xr,p.themeParams=Ze,p.toRGB=oo,p.toRGBFp=ar,p.toRGBFull=ao,p.toRGBFullFp=ot,p.viewport=oc,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"}),p}({});
|
|
4
4
|
//# sourceMappingURL=index.iife.js.map
|
package/dist/index.js
CHANGED
|
@@ -3,11 +3,11 @@ var Le = (s, e, r) => e in s ? $e(s, e, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var t = (s, e, r) => Le(s, typeof e != "symbol" ? e + "" : e, r);
|
|
4
4
|
import { computed as w, signal as j, batch as Ct } from "@tma.js/signals";
|
|
5
5
|
import { supports as ot, isTMAFp as Re, postEventFp as Pe, off as ct, on as Y, requestFp as Oe, invokeCustomMethodFp as De, retrieveRawInitDataFp as Ue, retrieveLaunchParamsFp as St, captureSameReq as Ge, logger as re } from "@tma.js/bridge";
|
|
6
|
-
import { CancelledError as lo, InvalidLaunchParamsError as po, InvokeCustomMethodFailedError as ho, LaunchParamsRetrieveError as fo, MethodParameterUnsupportedError as _o, MethodUnsupportedError as mo, TimeoutError as bo, UnknownEnvError as go, applyPolyfills as wo, createLogger as Fo, createPostEvent as Co, createStartParam as So, createStartParamFp as vo, debug as yo, decodeBase64Url as ko, decodeBase64UrlFp as Eo, decodeStartParam as Ao, decodeStartParamFp as Io, deepSnakeToCamelObjKeys as Bo,
|
|
6
|
+
import { CancelledError as lo, InvalidLaunchParamsError as po, InvokeCustomMethodFailedError as ho, LaunchParamsRetrieveError as fo, MethodParameterUnsupportedError as _o, MethodUnsupportedError as mo, TimeoutError as bo, UnknownEnvError as go, applyPolyfills as wo, createLogger as Fo, createPostEvent as Co, createStartParam as So, createStartParamFp as vo, debug as yo, decodeBase64Url as ko, decodeBase64UrlFp as Eo, decodeStartParam as Ao, decodeStartParamFp as Io, deepSnakeToCamelObjKeys as Bo, emitEvent as xo, encodeBase64Url as qo, getReleaseVersion as Mo, isSafeToCreateStartParam as Vo, isTMA as To, isTMAFp as $o, logger as Lo, mockTelegramEnv as Ro, off as Po, offAll as Oo, on as Do, retrieveLaunchParams as Uo, retrieveLaunchParamsFp as Go, retrieveRawInitData as jo, retrieveRawInitDataFp as Ho, retrieveRawLaunchParams as Wo, retrieveRawLaunchParamsFp as Ko, setDebug as Qo, setTargetOrigin as zo, supports as No, targetOrigin as Jo } from "@tma.js/bridge";
|
|
7
7
|
import { throwifyFpFn as yt, throwifyAnyEither as ce, getStorageValue as je, setStorageValue as He, snakeToKebab as We, createCbCollector as Lt, camelToKebab as le, BetterTaskEither as xt } from "@tma.js/toolkit";
|
|
8
8
|
import { BetterPromise as Ke } from "better-promises";
|
|
9
9
|
import { toRGBFullFp as Qe, isRGB as Et, pipeQueryToSchema as ze, pipeJsonToSchema as Ne } from "@tma.js/transformers";
|
|
10
|
-
import { isAnyRGB as
|
|
10
|
+
import { isAnyRGB as Zo, isRGB as Xo, isRGBA as ti, isRGBAShort as ei, isRGBShort as si, parseInitDataQuery as ri, parseInitDataQueryFp as ni, parseLaunchParamsQuery as oi, parseLaunchParamsQueryFp as ii, serializeInitDataQuery as ai, serializeLaunchParamsQuery as ui, toRGB as ci, toRGBFp as li, toRGBFull as pi, toRGBFullFp as hi } from "@tma.js/transformers";
|
|
11
11
|
import { errorClassWithData as Je, errorClass as K } from "error-kid";
|
|
12
12
|
import { parse as ne, record as Ye, string as J, array as Ze, safeParse as qt, looseObject as oe, pipe as pe, transform as he, date as de, optional as Xe, number as fe, integer as ts } from "valibot";
|
|
13
13
|
var es = function(s, e, r) {
|
|
@@ -3881,10 +3881,11 @@ export {
|
|
|
3881
3881
|
Bo as deepSnakeToCamelObjKeys,
|
|
3882
3882
|
Yn as downloadFile,
|
|
3883
3883
|
Nr as downloadFileFp,
|
|
3884
|
-
xo as
|
|
3884
|
+
xo as emitEvent,
|
|
3885
|
+
qo as encodeBase64Url,
|
|
3885
3886
|
Zn as getCurrentTime,
|
|
3886
3887
|
Yr as getCurrentTimeFp,
|
|
3887
|
-
|
|
3888
|
+
Mo as getReleaseVersion,
|
|
3888
3889
|
qn as hapticFeedback,
|
|
3889
3890
|
Xn as hideKeyboard,
|
|
3890
3891
|
Xr as hideKeyboardFp,
|
|
@@ -3893,32 +3894,32 @@ export {
|
|
|
3893
3894
|
fn as initFp,
|
|
3894
3895
|
$n as invoice,
|
|
3895
3896
|
hr as invokeCustomMethod,
|
|
3896
|
-
|
|
3897
|
+
Zo as isAnyRGB,
|
|
3897
3898
|
xe as isColorDark,
|
|
3898
3899
|
Mr as isColorDarkFp,
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3900
|
+
Xo as isRGB,
|
|
3901
|
+
ti as isRGBA,
|
|
3902
|
+
ei as isRGBAShort,
|
|
3903
|
+
si as isRGBShort,
|
|
3904
|
+
Vo as isSafeToCreateStartParam,
|
|
3905
|
+
To as isTMA,
|
|
3906
|
+
$o as isTMAFp,
|
|
3906
3907
|
On as locationManager,
|
|
3907
|
-
|
|
3908
|
+
Lo as logger,
|
|
3908
3909
|
Dn as mainButton,
|
|
3909
3910
|
$r as miniApp,
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3911
|
+
Ro as mockTelegramEnv,
|
|
3912
|
+
Po as off,
|
|
3913
|
+
Oo as offAll,
|
|
3914
|
+
Do as on,
|
|
3914
3915
|
Ln as openLink,
|
|
3915
3916
|
kr as openLinkFp,
|
|
3916
3917
|
Rn as openTelegramLink,
|
|
3917
3918
|
Ie as openTelegramLinkFp,
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3919
|
+
ri as parseInitDataQuery,
|
|
3920
|
+
ni as parseInitDataQueryFp,
|
|
3921
|
+
oi as parseLaunchParamsQuery,
|
|
3922
|
+
ii as parseLaunchParamsQueryFp,
|
|
3922
3923
|
Un as popup,
|
|
3923
3924
|
ur as postEvent,
|
|
3924
3925
|
mt as postEventFp,
|
|
@@ -3939,21 +3940,21 @@ export {
|
|
|
3939
3940
|
jr as requestWriteAccessFp,
|
|
3940
3941
|
eo as retrieveAndroidDeviceData,
|
|
3941
3942
|
sn as retrieveAndroidDeviceDataFrom,
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3943
|
+
Uo as retrieveLaunchParams,
|
|
3944
|
+
Go as retrieveLaunchParamsFp,
|
|
3945
|
+
jo as retrieveRawInitData,
|
|
3946
|
+
Ho as retrieveRawInitDataFp,
|
|
3947
|
+
Wo as retrieveRawLaunchParams,
|
|
3948
|
+
Ko as retrieveRawLaunchParamsFp,
|
|
3948
3949
|
Qn as secondaryButton,
|
|
3949
3950
|
so as sendData,
|
|
3950
3951
|
nn as sendDataFp,
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3952
|
+
ai as serializeInitDataQuery,
|
|
3953
|
+
ui as serializeLaunchParamsQuery,
|
|
3954
|
+
Qo as setDebug,
|
|
3954
3955
|
xn as setEmojiStatus,
|
|
3955
3956
|
mr as setEmojiStatusFp,
|
|
3956
|
-
|
|
3957
|
+
zo as setTargetOrigin,
|
|
3957
3958
|
zn as settingsButton,
|
|
3958
3959
|
ro as shareMessage,
|
|
3959
3960
|
an as shareMessageFp,
|
|
@@ -3961,16 +3962,16 @@ export {
|
|
|
3961
3962
|
cn as shareStoryFp,
|
|
3962
3963
|
Pn as shareURL,
|
|
3963
3964
|
Ir as shareURLFp,
|
|
3964
|
-
|
|
3965
|
+
No as supports,
|
|
3965
3966
|
Nn as swipeBehavior,
|
|
3966
3967
|
oo as switchInlineQuery,
|
|
3967
3968
|
pn as switchInlineQueryFp,
|
|
3968
|
-
|
|
3969
|
+
Jo as targetOrigin,
|
|
3969
3970
|
vt as themeParams,
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3971
|
+
ci as toRGB,
|
|
3972
|
+
li as toRGBFp,
|
|
3973
|
+
pi as toRGBFull,
|
|
3974
|
+
hi as toRGBFullFp,
|
|
3974
3975
|
io as viewport
|
|
3975
3976
|
};
|
|
3976
3977
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tma.js/sdk",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "TypeScript Source Development Kit for Telegram Mini Apps client application.",
|
|
5
5
|
"author": "Vladislav Kibenko <wolfram.deus@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"error-kid": "^1.0.2",
|
|
40
40
|
"fp-ts": "^2.16.11",
|
|
41
41
|
"valibot": "^1.1.0",
|
|
42
|
-
"@tma.js/bridge": "^2.1.1",
|
|
43
42
|
"@tma.js/signals": "^1.0.1",
|
|
43
|
+
"@tma.js/bridge": "^2.1.1",
|
|
44
44
|
"@tma.js/toolkit": "^1.0.2",
|
|
45
45
|
"@tma.js/transformers": "^1.1.1",
|
|
46
46
|
"@tma.js/types": "^1.0.2"
|