@tma.js/sdk 3.0.0 → 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/README.md +1 -1
- package/dist/dts/index.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.iife.js +3 -3
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +38 -37
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[docs-badge]: https://img.shields.io/badge/documentation-blue?logo=gitbook&logoColor=white
|
|
6
6
|
|
|
7
|
-
[link]: https://github.com/Telegram-Mini-Apps/
|
|
7
|
+
[link]: https://github.com/Telegram-Mini-Apps/tma.js/tree/master/tma.js/sdk
|
|
8
8
|
|
|
9
9
|
[docs-link]: https://docs.telegram-mini-apps.com/packages/tma-js-sdk
|
|
10
10
|
|
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
|