@tma.js/sdk 3.1.4 → 3.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dts/composables/AsyncMountable.d.ts +1 -1
- package/dist/dts/composables/Button.d.ts +1 -1
- package/dist/dts/composables/Mountable.d.ts +1 -1
- package/dist/dts/features/BackButton/BackButton.d.ts +1 -1
- package/dist/dts/features/Biometry/Biometry.d.ts +1 -2
- package/dist/dts/features/ClosingBehavior/ClosingBehavior.d.ts +1 -1
- package/dist/dts/features/CloudStorage/CloudStorage.d.ts +1 -1
- package/dist/dts/features/DeviceStorage/DeviceStorage.d.ts +1 -1
- package/dist/dts/features/HapticFeedback/HapticFeedback.d.ts +1 -1
- package/dist/dts/features/InitData/InitData.d.ts +1 -2
- package/dist/dts/features/Invoice/Invoice.d.ts +1 -1
- package/dist/dts/features/LocationManager/LocationManager.d.ts +1 -2
- package/dist/dts/features/MainButton/MainButton.d.ts +1 -1
- package/dist/dts/features/MiniApp/MiniApp.d.ts +1 -1
- package/dist/dts/features/Popup/Popup.d.ts +2 -2
- package/dist/dts/features/Popup/prepareParams.d.ts +1 -1
- package/dist/dts/features/QrScanner/QrScanner.d.ts +3 -4
- package/dist/dts/features/SecondaryButton/SecondaryButton.d.ts +1 -1
- package/dist/dts/features/SecureStorage/SecureStorage.d.ts +1 -1
- package/dist/dts/features/SettingsButton/SettingsButton.d.ts +1 -1
- package/dist/dts/features/SwipeBehavior/SwipeBehavior.d.ts +1 -1
- package/dist/dts/features/ThemeParams/ThemeParams.d.ts +1 -1
- package/dist/dts/features/Viewport/Viewport.d.ts +1 -2
- package/dist/dts/features/emoji-status/requestEmojiStatusAccess.d.ts +1 -1
- package/dist/dts/features/emoji-status/setEmojiStatus.d.ts +2 -2
- package/dist/dts/features/home-screen/checkHomeScreenStatus.d.ts +1 -1
- package/dist/dts/features/links/openLink.d.ts +1 -1
- package/dist/dts/features/links/openTelegramLink.d.ts +1 -1
- package/dist/dts/features/links/shareURL.d.ts +1 -1
- package/dist/dts/features/privacy/requestContact.d.ts +1 -1
- package/dist/dts/features/privacy/requestPhoneAccess.d.ts +1 -1
- package/dist/dts/features/privacy/requestWriteAccess.d.ts +1 -1
- package/dist/dts/features/uncategorized/downloadFile.d.ts +2 -2
- package/dist/dts/features/uncategorized/getCurrentTime.d.ts +1 -1
- package/dist/dts/features/uncategorized/hideKeyboard.d.ts +1 -1
- package/dist/dts/features/uncategorized/readTextFromClipboard.d.ts +1 -1
- package/dist/dts/features/uncategorized/sendData.d.ts +1 -1
- package/dist/dts/features/uncategorized/shareMessage.d.ts +1 -1
- package/dist/dts/features/uncategorized/shareStory.d.ts +2 -2
- package/dist/dts/features/uncategorized/switchInlineQuery.d.ts +2 -2
- package/dist/dts/globals/invokeCustomMethod.d.ts +1 -1
- package/dist/dts/helpers/isColorDark.d.ts +1 -1
- package/dist/dts/init.d.ts +1 -1
- package/dist/dts/with-checks/throwifyWithChecksFp.d.ts +1 -1
- package/dist/dts/with-checks/withChecksFp.d.ts +1 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +3 -3
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +1703 -2081
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _r=Object.defineProperty;var br=(r,t,n)=>t in r?_r(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n;var e=(r,t,n)=>br(r,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@tma.js/signals"),d=require("@tma.js/bridge"),L=require("@tma.js/toolkit"),ot=require("better-promises"),x=require("@tma.js/transformers"),Q=require("error-kid"),E=require("valibot");var gr=function(r,t,n){if(n||arguments.length===2)for(var s=0,i=t.length,o;s<i;s++)(o||!(s in t))&&(o||(o=Array.prototype.slice.call(t,0,s)),o[s]=t[s]);return r.concat(o||Array.prototype.slice.call(t))};function it(r,t,n,s,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 n(t(r.apply(this,arguments)))};case 4:return function(){return s(n(t(r.apply(this,arguments))))};case 5:return function(){return i(s(n(t(r.apply(this,arguments)))))};case 6:return function(){return o(i(s(n(t(r.apply(this,arguments))))))};case 7:return function(){return u(o(i(s(n(t(r.apply(this,arguments)))))))};case 8:return function(){return a(u(o(i(s(n(t(r.apply(this,arguments))))))))};case 9:return function(){return l(a(u(o(i(s(n(t(r.apply(this,arguments)))))))))}}}function c(r,t,n,s,i,o,u,a,l){switch(arguments.length){case 1:return r;case 2:return t(r);case 3:return n(t(r));case 4:return s(n(t(r)));case 5:return i(s(n(t(r))));case 6:return o(i(s(n(t(r)))));case 7:return u(o(i(s(n(t(r))))));case 8:return a(u(o(i(s(n(t(r)))))));case 9:return l(a(u(o(i(s(n(t(r))))))));default:{for(var p=arguments[0],b=1;b<arguments.length;b++)p=arguments[b](p);return p}}}var de=function(r,t){var n=typeof r=="number"?function(s){return s.length>=r}:r;return function(){var s=Array.from(arguments);return n(arguments)?t.apply(this,s):function(i){return t.apply(void 0,gr([i],s,!1))}}},Fr={_tag:"None"},wr=function(r){return{_tag:"Some",value:r}},Cr=function(r){return r._tag==="Left"},at=function(r){return{_tag:"Left",left:r}},ut=function(r){return{_tag:"Right",right:r}},Me={};function Sr(r,t){return function(n){return function(s){return r.ap(r.map(s,function(i){return function(o){return t.ap(i,o)}}),n)}}}function vr(r,t){return function(n){return function(s){return r.map(s,function(i){return t.map(i,n)})}}}function xe(r){return function(t,n){return function(s){return r.chain(s,function(i){return r.map(n(i),function(o){var u;return Object.assign({},i,(u={},u[t]=o,u))})})}}}var R=at,q=ut,yr=de(2,function(r,t){return se(r)?r:t(r.right)}),$e=function(r,t){return c(r,H(t))},ct=function(r,t){return c(r,Ar(t))},Te="Either",H=function(r){return function(t){return se(t)?t:q(r(t.right))}},kr={URI:Te,map:$e},Er=q,Ir=function(r){return function(t){return se(t)?t:se(r)?r:q(t.right(r.right))}},Ar=Ir,Br={URI:Te,map:$e,ap:ct},Pr={URI:Te,map:$e,ap:ct,chain:yr},qr=function(r,t){return function(n){return se(n)?R(r(n.left)):q(t(n.right))}},se=Cr,pt=function(r,t){return function(n){return se(n)?r(n.left):t(n.right)}},fe=pt,Mr=function(r,t){try{return q(r())}catch(n){return R(t(n))}},xr=Er(Me),$r=xe(Pr),rt=$r;function W(r){return typeof r=="function"?r():r}class me{constructor({onMounted:t,restoreState:n,initialState:s,onUnmounted:i,isPageReload:o}){e(this,"_isMounted",g.signal(!1));e(this,"isMounted",g.computed(this._isMounted));e(this,"mount");e(this,"unmount");this.mount=()=>{if(this.isMounted())return q(void 0);const u=W(o)?n():void 0,a=u?q(u):typeof s=="function"?s():q(s);return c(a,H(l=>{g.batch(()=>{this._isMounted.set(!0),t==null||t(l)})}))},this.unmount=()=>{this._isMounted()&&g.batch(()=>{this._isMounted.set(!1),i==null||i()})}}}function Ae(r){const t={};for(const n in r){const s=r[n];s!==void 0&&(t[n]=s)}return t}function ke(r,t){const n=Object.keys(r),s=Object.keys(t);return n.length!==s.length?!1:n.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&r[i]===t[i])}class te{constructor({initialState:t,onChange:n}){e(this,"_state");e(this,"state");e(this,"setState",t=>{const n={...this.state(),...Ae(t)};ke(n,this.state())||this._state.set(n)});this._state=g.signal(t,{equals:ke}),this.state=g.computed(this._state),this.state.sub(n)}getter(t){return g.computed(()=>this._state()[t])}hasDiff(t){return!ke({...this.state(),...Ae(t)},this.state())}}function Z(r,t){return g.computed(()=>d.supports(r,W(t)))}var ae=Fr,_e=wr,Tr=function(r,t){return c(r,Lr(t))},Rr=function(r,t){return c(r,jr(t))},Or="Option",Lr=function(r){return function(t){return le(t)?ae:_e(r(t.value))}},Vr=_e,jr=function(r){return function(t){return le(t)||le(r)?ae:_e(t.value(r.value))}},Dr=de(2,function(r,t){return le(r)?ae:t(r.value)}),Ur={URI:Or,map:Tr,ap:Rr,chain:Dr},le=function(r){return r._tag==="None"},Gr=function(r,t){return function(n){return le(n)?r():t(n.value)}},lt=Gr,Hr=Vr(Me),nt=xe(Ur);function h(r){return Object.assign(L.throwifyFpFn(r),{ifAvailable(...t){return c(r.ifAvailable(...t),lt(()=>({ok:!1}),n=>({ok:!0,data:L.throwifyAnyEither(n)})))}})}function Wr(r){return it(q,r.of)}function Qr(r){return it(R,r.of)}function Kr(r){return vr(r,kr)}function Nr(r){return Sr(r,Br)}function zr(r){return function(t,n){return r.chain(t,function(s){return se(s)?r.of(s):n(s.right)})}}function Jr(r){return function(t,n,s){return r.map(t,qr(n,s))}}function Yr(r){return function(t,n){return function(s){return r.map(s,fe(t,n))}}}var Re=function(r,t){return c(r,Zr(t))},ht=function(r,t){return c(r,Xr(t))},Zr=function(r){return function(t){return function(){return Promise.resolve().then(t).then(r)}}},Xr=function(r){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(r)]).then(function(n){var s=n[0],i=n[1];return s(i)})}}},Oe=function(r){return function(){return Promise.resolve(r)}},en=de(2,function(r,t){return function(){return Promise.resolve().then(r).then(function(n){return t(n)()})}}),Le="Task",Ve={URI:Le,map:Re},dt={of:Oe},tn={URI:Le,map:Re,ap:ht},rn={URI:Le,map:Re,of:Oe,ap:ht,chain:en},nn=function(r,t,n,s){function i(o){return o instanceof n?o:new n(function(u){u(o)})}return new(n||(n=Promise))(function(o,u){function a(b){try{p(s.next(b))}catch(f){u(f)}}function l(b){try{p(s.throw(b))}catch(f){u(f)}}function p(b){b.done?o(b.value):i(b.value).then(a,l)}p((s=s.apply(r,t||[])).next())})},sn=function(r,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,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(s)throw new TypeError("Generator is already executing.");for(;u&&(u=0,p[0]&&(n=0)),n;)try{if(s=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 n.label++,{value:p[1],done:!1};case 5:n.label++,i=p[1],p=[0];continue;case 7:p=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(p[0]===6||p[0]===2)){n=0;continue}if(p[0]===3&&(!o||p[1]>o[0]&&p[1]<o[3])){n.label=p[1];break}if(p[0]===6&&n.label<o[1]){n.label=o[1],o=p;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(p);break}o[2]&&n.ops.pop(),n.trys.pop();continue}p=t.call(r,n)}catch(b){p=[6,b],i=0}finally{s=o=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},O=Qr(dt),M=Wr(dt),ft=Oe,on=Yr(Ve),an=function(r,t){return function(){return nn(void 0,void 0,void 0,function(){var n;return sn(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,r().then(ut)];case 1:return[2,s.sent()];case 2:return n=s.sent(),[2,at(t(n))];case 3:return[2]}})})}},un=function(r,t){return c(r,I(t))},cn=function(r,t){return c(r,pn(t))},I=Kr(Ve),je=de(3,Jr(Ve)),pn=Nr(tn),De=de(2,zr(rn)),ln=M,hn="TaskEither",dn={URI:hn,map:un,ap:cn,chain:De},fn=ln(Me),mn=xe(dn),we=mn,J=De,ue=De;function oe(r){return[r]}class pe extends Q.errorClassWithData("ValidationError",(t,n)=>({input:t,issues:n}),"Validation error"){}class Ce extends Q.errorClass("CSSVarsBoundError","CSS variables are already bound"){}class mt extends Q.errorClassWithData("DeviceStorageMethodError",t=>({error:t}),t=>[t]){}class _t extends Q.errorClassWithData("SecureStorageMethodError",t=>({error:t}),t=>[t]){}class bt extends Q.errorClass("NotAvailableError",oe){}class _n extends Q.errorClass("InvalidEnvError",oe){}class gt extends Q.errorClass("FunctionNotAvailableError",oe){}class z extends Q.errorClass("InvalidArgumentsError",(t,n)=>[t,{cause:n}]){}class Se extends Q.errorClass("ConcurrentCallError",oe){}class Ft extends Q.errorClass("SetEmojiStatusError",t=>[`Failed to set emoji status: ${t}`]){}class Ue extends Q.errorClass("AccessDeniedError",oe){}class wt extends Q.errorClass("FullscreenFailedError",oe){}class Ct extends Q.errorClass("ShareMessageError",oe){}class St extends Q.errorClass("UnknownThemeParamsKeyError",t=>[`Unknown theme params key passed: ${t}`]){}function P(r,t){const n=g.computed(()=>W(t.version)||"100"),s=g.computed(()=>W(t.isTma)),{requires:i,returns:o}=t,u=i?typeof i=="object"?i:{every:[i]}:void 0,a=_=>{if(!t.supports)return!0;const F=t.supports[_];return d.supports(F.method,F.param,n())},l=()=>{if(!u)return;const[_,F]="every"in u?["every",u.every]:["some",u.some];for(let m=0;m<F.length;m++){const $=F[m],D=typeof $=="function"?$():d.supports($,n())?void 0:`it is unsupported in Mini Apps version ${n()}`;if(D&&(_==="every"||m===F.length-1))return D}},p=(..._)=>{for(const F in t.supports)if(t.supports[F].shouldCheck(..._)&&!a(F))return`option ${F} is not supported in Mini Apps version ${n()}`},b=g.computed(()=>!l()),f=g.computed(()=>n()!=="0.0"),C=g.computed(()=>t.isMounted?t.isMounted():!0),w=g.computed(()=>s()&&f()&&b()&&C()),v=_=>{const F=new gt(_);return["task","promise"].includes(t.returns)?O(F):R(F)},y=(..._)=>o==="plain"?Mr(()=>r(..._),F=>F):o==="promise"?an(()=>r(..._),F=>F):r(..._);return Object.assign((..._)=>{var D;const F="Unable to call function:";if(!s())return v(`${F} it can't be called outside Mini Apps`);if(!f())return v(`${F} the SDK was not initialized. Use the SDK init() function`);const m=l();if(m)return v(`${F} ${m}`);const $=p(..._);if($)return v(`${F} ${$}`);if(!C()){const V=(D=t.isMounting)!=null&&D.call(t)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return v(`${F} the component is ${V}`)}return y(..._)},r,{isAvailable:w,ifAvailable(..._){return w()?_e(y(..._)):ae}},u?{isSupported:b}:{},t.supports?{supports:a}:{})}function A(r){return t=>P(t,r)}class ve{constructor({isTma:t,storage:n,onClick:s,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 f=new te({initialState:o,onChange(_){n.set(_)}}),C=new me({initialState:o,isPageReload:u,onMounted:f.setState,restoreState:n.get}),w={version:b,requires:p,isTma:t},v=A({...w,returns:"plain"}),y=A({...w,returns:"either",isMounted:C.isMounted});this.isMounted=C.isMounted,this.isSupported=Z(p,b),this.state=f.state,this.setStateFp=y(_=>{const F={...this.state(),...Ae(_)};return f.hasDiff(F)?c(a(p,l(F)),H(()=>{f.setState(F)})):q(void 0)}),this.setState=h(this.setStateFp),this.onClickFp=v(s),this.onClick=h(this.onClickFp),this.offClickFp=v(i),this.offClick=h(this.offClickFp),this.mountFp=v(()=>{const _=()=>{};return c(C.mount(),fe(_,_))}),this.mount=h(this.mountFp),this.unmount=C.unmount,this.stateSetters=_=>{const F=y(m=>this.setStateFp({[_]:m}));return[h(F),F]},this.stateBoolSetters=_=>{const[,F]=this.stateSetters(_),m=y(()=>F(!1)),$=y(()=>F(!0));return[[h(m),m],[h($),$]]}}stateGetter(t){return g.computed(()=>this.state()[t])}}class vt{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 n=new ve({...t,method:"web_app_setup_back_button",payload:s=>({is_visible:s.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}function S(){return{isTma:g.computed(()=>d.isTMAFp())}}function ce(r){return t=>({...t,...W(r)})}function be(r,t){return g.signal(r,t)}const yt=be(d.postEventFp),ie=(...r)=>yt()(...r),kt=(...r)=>L.throwifyAnyEither(ie(...r)),j=ce({postEvent:ie});function bn(r){return{get:()=>L.getStorageValue(r),set(t){L.setStorageValue(r,t)}}}function gn(){return performance.getEntriesByType("navigation")[0]}function Fn(){const r=gn();return!!r&&r.type==="reload"}function re(r){return ce({storage:bn(r),isPageReload:Fn})}const Be=be("0.0"),k=ce({version:Be});function Ge(r,t){return{...c(S(),j,k,re(r)),onClick(n,s){return d.on(t,n,s)},offClick(n,s){d.off(t,n,s)}}}const wn=new vt(Ge("backButton","back_button_pressed"));class He{constructor({initialState:t,onMounted:n,restoreState:s,onUnmounted:i,isPageReload:o}){e(this,"_isMounted",g.signal(!1));e(this,"isMounted",g.computed(this._isMounted));e(this,"mount");e(this,"unmount");this.mount=u=>{if(this._isMounted())return M(void 0);const a=W(o)?s():void 0;return c(a?M(a):t(u),I(l=>{this._isMounted()||g.batch(()=>{this._isMounted.set(!0),n==null||n(l)})}))},this.unmount=()=>{this._isMounted()&&g.batch(()=>{this._isMounted.set(!1),i==null||i()})}}}function st(){return new bt("Biometry is not available")}function Ee(r){let t=!1,n=!1,s="",i=!1,o="",u=!1;return r.available&&(t=!0,n=r.token_saved,s=r.device_id,i=r.access_requested,o=r.type,u=r.access_granted),{available:t,tokenSaved:n,deviceId:s,type:o,accessGranted:u,accessRequested:i}}class Et{constructor({version:t,request:n,postEvent:s,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=_=>{b.setState(Ee(_))},b=new te({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:i.set}),f=new He({initialState(_){return c(n("web_app_biometry_get_info","biometry_info_received",_),I(Ee))},isPageReload:l,onMounted(_){b.setState(_),o(p)},onUnmounted(){u(p)},restoreState:i.get}),C={version:t,requires:"web_app_biometry_request_auth",isTma:a},w=A({...C,returns:"either"}),v=A({...C,returns:"task"}),y=A({...C,isMounted:f.isMounted,returns:"task"});this.isAvailable=b.getter("available"),this.isMounted=f.isMounted,this.isSupported=Z("web_app_biometry_request_auth",t),this.state=b.state,this.unmount=f.unmount,this.mountFp=v(f.mount),this.authenticateFp=y(_=>this.isAvailable()?c(n("web_app_biometry_request_auth","biometry_auth_requested",{..._,params:{reason:((_||{}).reason||"").trim()}}),I(F=>(b.setState({token:F.token}),F))):O(st())),this.openSettingsFp=w(()=>s("web_app_biometry_open_settings")),this.requestAccessFp=y(_=>c(n("web_app_biometry_request_access","biometry_info_received",{..._,params:{reason:((_||{}).reason||"").trim()}}),J(F=>{const m=Ee(F);return m.available?(b.setState(m),M(m.accessRequested)):O(st())}))),this.updateTokenFp=y((_={})=>{var F;return c(n("web_app_biometry_update_token","biometry_token_updated",{..._,params:{token:_.token||"",reason:(F=_.reason)==null?void 0:F.trim()}}),I(m=>m.status))}),this.authenticate=h(this.authenticateFp),this.openSettings=h(this.openSettingsFp),this.requestAccess=h(this.requestAccessFp),this.updateToken=h(this.updateTokenFp),this.mount=h(this.mountFp)}}const It=(r,t,n)=>d.requestFp(r,t,{postEvent:ie,...n}),We=(r,t,n)=>d.request2Fp(r,t,{postEvent:ie,...n}),Cn=(...r)=>ot.BetterPromise.fn(()=>It(...r)()),Sn=(...r)=>ot.BetterPromise.fn(()=>We(...r)()),U=ce({request:We});function vn(){return new Et({...c(S(),j,k,U,re("biometry")),offInfoReceived(r){d.off("biometry_info_received",r)},onInfoReceived(r){return d.on("biometry_info_received",r)}})}const yn=vn();class At{constructor({postEvent:t,storage:n,isTma:s,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(f){n.set(f)}}),u=new me({onMounted:o.setState,restoreState:n.get,initialState:{isConfirmationEnabled:!1},isPageReload:i}),a={requires:"web_app_setup_closing_behavior",isTma:s},l=A({...a,returns:"plain"}),p=A({...a,returns:"either",isMounted:u.isMounted}),b=f=>f===this.isConfirmationEnabled()?q(void 0):(o.setState({isConfirmationEnabled:f}),t("web_app_setup_closing_behavior",{need_confirmation:f}));this.isConfirmationEnabled=o.getter("isConfirmationEnabled"),this.isMounted=u.isMounted,this.disableConfirmationFp=p(()=>b(!1)),this.enableConfirmationFp=p(()=>b(!0)),this.mountFp=l(()=>{const f=()=>{};return c(u.mount(),fe(f,f))}),this.unmount=u.unmount,this.disableConfirmation=h(this.disableConfirmationFp),this.enableConfirmation=h(this.enableConfirmationFp),this.mount=h(this.mountFp)}}function kn(){return new At(c(S(),re("closingBehavior"),j))}const En=kn();class Bt{constructor({version:t,isTma:n,invokeCustomMethod:s}){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=A({version:t,requires:"web_app_invoke_custom_method",isTma:n,returns:"task"});this.isSupported=Z("web_app_invoke_custom_method",t),this.deleteItemFp=i((o,u)=>{const a=Array.isArray(o)?o:[o];return c(a.length?s("deleteStorageValues",{keys:a},u):M(void 0),I(()=>{}))}),this.getItemFp=i((o,u)=>c(this.getItemsFp([o],u),I(a=>a[o]||""))),this.getItemsFp=i((o,u)=>c(o.length?s("getStorageValues",{keys:o},u):M({}),I(a=>({...o.reduce((l,p)=>(l[p]="",l),{}),...E.parse(E.record(E.string(),E.string()),a)})))),this.getKeysFp=i(o=>c(s("getStorageKeys",{},o),I(u=>E.parse(E.array(E.string()),u)))),this.setItemFp=i((o,u,a)=>c(s("saveStorageValue",{key:o,value:u},a),I(()=>{}))),this.clearFp=i(o=>c(this.getKeysFp(o),J(this.deleteItemFp))),this.deleteItem=h(this.deleteItemFp),this.getItem=h(this.getItemFp),this.getItems=h(this.getItemsFp),this.getKeys=h(this.getKeysFp),this.setItem=h(this.setItemFp),this.clear=h(this.clearFp)}}const Ie=be(0);function ye(){return Ie.set(Ie()+1),Ie().toString()}function Pt(r,t,n){return d.invokeCustomMethodFp(r,t,ye(),{...n||{},postEvent:ie})}const Qe=ce({invokeCustomMethod:Pt});function In(){return new Bt(c(S(),k,Qe))}const An=In();class qt{constructor({isTma:t,request:n,version:s,createRequestId:i}){e(this,"getItemFp");e(this,"getItem");e(this,"setItemFp");e(this,"setItem");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"clearFp");e(this,"clear");const o=A({version:s,requires:"web_app_device_storage_get_key",isTma:t,returns:"task"}),u=(a,l,p)=>{const b=i();return c(n(a,["device_storage_failed",l],{params:{...p,req_id:b},capture:f=>"payload"in f?f.payload.req_id===b:!0}),J(f=>f.event==="device_storage_failed"?O(new mt(f.payload.error||"UNKNOWN_ERROR")):M(f.payload)))};this.getItemFp=o(a=>c(u("web_app_device_storage_get_key","device_storage_key_received",{key:a}),I(l=>l.value))),this.setItemFp=o((a,l)=>c(u("web_app_device_storage_save_key","device_storage_key_saved",{key:a,value:l}),I(()=>{}))),this.deleteItemFp=o(a=>this.setItemFp(a,null)),this.clearFp=o(()=>c(u("web_app_device_storage_clear","device_storage_cleared",{}),I(()=>{}))),this.getItem=h(this.getItemFp),this.setItem=h(this.setItemFp),this.deleteItem=h(this.deleteItemFp),this.clear=h(this.clearFp)}}const Mt=ce({createRequestId:ye});function Bn(){return new qt(c(S(),k,U,Mt))}const Pn=Bn();function qn({request:r,...t}){return P(n=>c(r("web_app_request_emoji_status_access","emoji_status_access_requested",n),I(s=>s.status)),{...t,requires:"web_app_request_emoji_status_access",returns:"task"})}function Mn(){return qn(c(S(),k,U))}const xt=Mn(),xn=h(xt);function $n({request:r,...t}){return P((n,s)=>c(r("web_app_set_emoji_status",["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:n,duration:(s||{}).duration},...s}),ue(i=>i.event==="emoji_status_failed"?O(new Ft(i.payload.error)):M(void 0))),{...t,requires:"web_app_set_emoji_status",returns:"task"})}function Tn(){return $n(c(S(),U,k))}const $t=Tn(),Rn=h($t);class Tt{constructor({postEvent:t,isTma:n,version:s}){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=A({requires:i,isTma:n,version:s,returns:"plain"});this.isSupported=Z(i,s),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=h(this.impactOccurredFp),this.notificationOccurred=h(this.notificationOccurredFp),this.selectionChanged=h(this.selectionChangedFp)}}function On(){return new Tt(c(S(),j,k))}const Ln=On();function Vn({postEvent:r,...t}){return P(()=>r("web_app_add_to_home_screen"),{...t,requires:"web_app_add_to_home_screen",returns:"either"})}function jn(){return Vn(c(S(),k,j))}const Rt=jn(),Dn=h(Rt);function Un({request:r,...t}){return P(n=>c(r("web_app_check_home_screen","home_screen_checked",n),I(s=>s.status||"unknown")),{...t,requires:"web_app_check_home_screen",returns:"task"})}function Gn(){return Un(c(S(),k,U))}const Ot=Gn(),Hn=h(Ot);class Lt{constructor({retrieveInitData:t}){e(this,"_state",g.signal());e(this,"_raw",g.signal());e(this,"state",g.computed(this._state));e(this,"authDate",this.fromState("auth_date"));e(this,"canSendAfter",this.fromState("can_send_after"));e(this,"canSendAfterDate",g.computed(()=>{const t=this.authDate(),n=this.canSendAfter();return n&&t?new Date(t.getTime()+n*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",g.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(lt(()=>{},({raw:n,obj:s})=>{this._state.set(s),this._raw.set(n)}))),this.restore=L.throwifyFpFn(this.restoreFp)}fromState(t){return g.computed(()=>{const n=this._state();return n?n[t]:void 0})}}function Wn(){return new Lt({retrieveInitData(){return c(xr,rt("obj",()=>c(d.retrieveLaunchParamsFp(),H(({tgWebAppData:r})=>r?_e(r):ae))),rt("raw",d.retrieveRawInitDataFp),H(({obj:r,raw:t})=>c(Hr,nt("obj",()=>r),nt("raw",()=>t))))}})}const Qn=Wn();class Vt{constructor({version:t,request:n,isTma:s}){e(this,"isOpened");e(this,"isSupported");e(this,"openSlugFp");e(this,"openSlug");e(this,"openUrlFp");e(this,"openUrl");const i=A({version:t,isTma:s,requires:"web_app_open_invoice",returns:"task"}),o=g.signal(!1),u=()=>{o.set(!1)};this.isSupported=Z("web_app_open_invoice",t),this.isOpened=g.computed(o),this.openSlugFp=i((a,l)=>c(this.isOpened()?O(new Se("Invoice is already opened")):M(void 0),J(()=>(o.set(!0),n("web_app_open_invoice","invoice_closed",{...l,params:{slug:a},capture:p=>a===p.slug}))),je(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 O(new z(`Link has unexpected hostname: ${p}`));const f=b.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return f?this.openSlugFp(f[2],l):O(new z('Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"'))}),this.openUrl=h(this.openUrlFp),this.openSlug=h(this.openSlugFp)}}function Kn(){return new Vt(c(S(),U,k))}const Nn=Kn();function zn({postEvent:r,...t}){return P((n,s={})=>{if(typeof n=="string")try{n=new URL(n)}catch(i){return R(new z(`"${n.toString()}" is invalid URL`,i))}return r("web_app_open_link",{url:n.toString(),try_browser:s.tryBrowser,try_instant_view:s.tryInstantView})},{...t,returns:"either"})}function Jn(){return zn(c(S(),j))}const jt=Jn(),Yn=h(jt);function Zn({postEvent:r,version:t,...n}){return P(s=>{const i=s.toString();return i.match(/^https:\/\/t.me\/.+/)?d.supports("web_app_open_tg_link",W(t))?(s=new URL(s),r("web_app_open_tg_link",{path_full:s.pathname+s.search})):(window.location.href=i,q(void 0)):R(new z(`"${i}" is invalid URL`))},{...n,returns:"either"})}function Xn(){return Zn(c(S(),j,k))}const Ke=Xn(),es=h(Ke);function ts({openTelegramLink:r,...t}){return P((n,s)=>r("https://t.me/share/url?"+new URLSearchParams({url:n,text:s||""}).toString().replace(/\+/g,"%20")),{...t,returns:"either"})}function rs(){return ts({...S(),openTelegramLink:Ke})}const Dt=rs(),ns=h(Dt);function ss(r){let t=!1,n,s;return r.available&&(t=!0,n=r.access_requested,s=r.access_granted),{available:t,accessGranted:s||!1,accessRequested:n||!1}}class Ut{constructor({version:t,request:n,postEvent:s,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 He({isPageReload:u,restoreState:i.get,onMounted:a.setState,initialState(w){return c(n("web_app_check_location","location_checked",w),I(ss))}}),p={version:t,requires:"web_app_check_location",isTma:o},b=A({...p,returns:"either"}),f=A({...p,returns:"task"}),C=A({...p,returns:"task",isMounted:l.isMounted});this.isAvailable=a.getter("available"),this.isAccessRequested=a.getter("accessRequested"),this.isAccessGranted=a.getter("accessGranted"),this.isSupported=Z("web_app_check_location",t),this.isMounted=l.isMounted,this.state=a.state,this.unmount=l.unmount,this.mountFp=f(l.mount),this.openSettingsFp=b(()=>s("web_app_open_location_settings")),this.requestLocationFp=C(w=>c(n("web_app_request_location","location_requested",w),I(v=>{if(!v.available)return a.setState({available:!1}),null;const{available:y,..._}=v;return _}))),this.mount=h(this.mountFp),this.openSettings=h(this.openSettingsFp),this.requestLocation=h(this.requestLocationFp)}}function os(){return new Ut(c(S(),j,k,U,re("locationManager")))}const is=os();class Gt{constructor({defaults:t,...n}){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 s=new ve({...n,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=s.stateGetter(o);return g.computed(()=>a()||W(u))};this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.hasShineEffect=s.stateGetter("hasShineEffect"),this.isEnabled=s.stateGetter("isEnabled"),this.isLoaderVisible=s.stateGetter("isLoaderVisible"),this.text=s.stateGetter("text"),this.isVisible=s.stateGetter("isVisible"),this.isMounted=s.isMounted,this.state=s.state,[this.setBgColor,this.setBgColorFp]=s.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=s.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=s.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=s.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=s.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=s.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=s.stateBoolSetters("isVisible"),this.setParams=s.setState,this.setParamsFp=s.setStateFp,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 Ne(r,t){document.documentElement.style.setProperty(r,t)}function ze(r){document.documentElement.style.removeProperty(r)}function Ht(r){return c(x.toRGBFullFp(r),H(t=>Math.sqrt([.299,.587,.114].reduce((n,s,i)=>{const o=parseInt(t.slice(1+i*2,1+(i+1)*2),16);return n+o*o*s},0))<120))}const Je=L.throwifyFpFn(Ht);class Wt{constructor({initialState:t,onChange:n,offChange:s,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",g.signal(!1));e(this,"isCssVarsBound",g.computed(this._isCssVarsBound));e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"state");e(this,"isDark",g.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=w=>{a.setState(w.theme_params)},p=new me({initialState:()=>q(W(t)),isPageReload:u,onMounted(w){a.setState(w),n(l)},onUnmounted(){s(l)},restoreState:o.get}),b={isTma:i,returns:"either"},f=A(b),C=A({...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(w=>{if(this._isCssVarsBound())return R(new Ce);w||(w=_=>`--tg-theme-${L.snakeToKebab(_)}`);const v=_=>{Object.entries(a.state()).forEach(([F,m])=>{m&&_(F,m)})},y=()=>{v((_,F)=>{Ne(w(_),F)})};return y(),a.state.sub(y),this._isCssVarsBound.set(!0),q(()=>{v(ze),a.state.unsub(y),this._isCssVarsBound.set(!1)})}),this.mountFp=f(p.mount),this.unmount=p.unmount,this.bindCssVars=h(this.bindCssVarsFp),this.mount=h(this.mountFp)}}const Pe=be({});function as(){return new Wt({...c(S(),re("themeParams")),offChange(r){d.off("theme_changed",r)},onChange(r){d.on("theme_changed",r)},initialState:Pe})}const he=as();function Qt(r,t,n){return c(Ge(r,t),s=>({...s,defaults:n}))}const us=new Gt(Qt("mainButton","main_button_pressed",{bgColor:g.computed(()=>he.buttonColor()||"#2481cc"),textColor:g.computed(()=>he.buttonTextColor()||"#ffffff")}));class Kt{constructor({storage:t,isPageReload:n,version:s,postEvent:i,isTma:o,theme:u,onVisibilityChanged:a,offVisibilityChanged:l}){e(this,"isSupported");e(this,"isDark",g.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=m=>{C.setState({isActive:m.is_visible})},b=m=>{[[this.headerColor,"web_app_set_header_color"],[this.bgColor,"web_app_set_background_color"],[this.bottomBarColor,"web_app_set_bottom_bar_color"]].forEach(([$,D])=>{const V=$();if(!x.isRGB(V)&&(D!=="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes(V))){const K=m[V];K&&i(D,{color:K})}})},f=new me({initialState(){return q({bgColor:"bg_color",headerColor:"header_bg_color",bottomBarColor:"bottom_bar_bg_color",isActive:!0})},isPageReload:n,onMounted:m=>{a(p),u.sub(b),C.setState(m)},onUnmounted(){l(p),u.unsub(b)},restoreState:t.get});this.isMounted=f.isMounted,this.mountFp=P(()=>{const m=()=>{};return c(f.mount(),fe(m,m))},{isTma:o,returns:"plain"}),this.mount=h(this.mountFp),this.unmount=f.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 w=m=>x.isRGB(m)?m:W(u)[m],v=m=>g.computed(()=>w(m()));this.isActive=C.getter("isActive"),this.isSupported=g.computed(()=>["web_app_set_header_color","web_app_set_background_color","web_app_set_bottom_bar_color"].some(m=>d.supports(m,W(s))));const y=g.signal(!1);this.isCssVarsBound=g.computed(y),this.bindCssVarsFp=P(m=>{if(y())return R(new Ce);const[$,D]=L.createCbCollector(()=>{y.set(!1)}),V=(K,G)=>{const Y=()=>{Ne(K,G()||null)};Y(),$(G.sub(Y),ze.bind(null,K))};return m||(m=K=>`--tg-${L.camelToKebab(K)}`),V(m("bgColor"),this.bgColorRgb),V(m("bottomBarColor"),this.bottomBarColorRgb),V(m("headerColor"),this.headerColorRgb),y.set(!0),q(D)},{isTma:o,returns:"either",isMounted:this.isMounted}),this.bindCssVars=h(this.bindCssVarsFp);const _=m=>{const $=C.getter(m),D=v($),V={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[m],K=P(G=>{if(G===$())return q(void 0);if(V==="web_app_set_header_color"&&(G==="bg_color"||G==="secondary_bg_color"))return c(i("web_app_set_header_color",{color_key:G}),H(()=>{C.setState({[m]:G})}));const Y=w(G);return c(Y?i(V,{color:Y}):R(new St(G)),H(()=>{C.setState({[m]:G})}))},{isTma:o,version:s,requires:V,isMounted:this.isMounted,returns:"either",supports:m==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:x.isRGB}}:void 0});return[$,D,h(K),K]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=_("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=_("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=_("bottomBarColor");const F=A({isTma:o,returns:"either"});this.closeFp=F(m=>i("web_app_close",{return_back:m})),this.close=h(this.closeFp),this.readyFp=F(()=>i("web_app_ready")),this.ready=h(this.readyFp)}}function cs(){return new Kt({...c(S(),j,k,re("miniApp")),offVisibilityChanged(r){d.off("visibility_changed",r)},onVisibilityChanged(r){d.on("visibility_changed",r)},theme:he.state})}const Nt=cs();function ps(r){const t=r.message.trim(),n=(r.title||"").trim(),s=r.buttons||[];if(n.length>64)return R(new z(`Invalid title: ${n}`));if(!t||t.length>256)return R(new z(`Invalid message: ${t}`));if(s.length>3)return R(new z(`Invalid buttons count: ${s.length}`));const i=[];if(!s.length)i.push({type:"close",id:""});else for(let o=0;o<s.length;o++){const u=s[o],a=u.id||"";if(a.length>64)return R(new z(`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 R(new z(`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 q({title:n,message:t,buttons:i})}class zt{constructor({version:t,isTma:n,request:s}){e(this,"isOpened");e(this,"isSupported");e(this,"showFp");e(this,"show");const i=g.signal(!1),o=()=>{i.set(!1)},u=A({version:t,isTma:n,requires:"web_app_open_popup",returns:"task"});this.isSupported=Z("web_app_open_popup",t),this.isOpened=g.computed(i),this.showFp=u(a=>c(this.isOpened()?O(new Se("A popup is already opened")):M(void 0),ue(()=>ft(ps(a))),J(l=>(i.set(!0),s("web_app_open_popup","popup_closed",{...a,params:l}))),je(l=>(o(),l),l=>(o(),l.button_id)))),this.show=h(this.showFp)}}function ls(){return new zt(c(S(),U,k))}const hs=ls();function ds({request:r,...t}){return P(n=>c(r("web_app_request_phone","phone_requested",n),I(s=>s.status)),{...t,requires:"web_app_request_phone",returns:"task"})}function fs(){return ds(c(S(),k,U))}const Ye=fs(),ms=h(Ye);function _s({invokeCustomMethod:r,requestPhoneAccess:t,...n}){const s=u=>c(r("getRequestedContact",{},{...u,timeout:(u||{}).timeout||5e3}),ue(a=>{const l=E.safeParse(E.string(),a);if(!l.success)return O(new pe(a,l.issues));if(!l.output)return M(void 0);const p=E.safeParse(x.pipeQueryToSchema(E.looseObject({contact:x.pipeJsonToSchema(E.looseObject({user_id:E.number(),phone_number:E.string(),first_name:E.string(),last_name:E.optional(E.string())})),auth_date:E.pipe(E.string(),E.transform(b=>new Date(Number(b)*1e3)),E.date()),hash:E.string()})),l.output);return p.success?M({raw:l.output,parsed:p.output}):O(new pe(l.output,p.issues))})),i=u=>c(s(u),on(a=>pe.is(a)?R(a):q(void 0),a=>q(a))),o=u=>L.BetterTaskEither(async(a,l,p)=>{let b=50;for(;!p.isRejected;){const f=await i(p)();if(f._tag==="Left")return l(f.left);if(f.right)return a(f.right);await new Promise(C=>setTimeout(C,b)),b+=50}},u);return P(u=>L.BetterTaskEither.fn(a=>c(i(a),J(l=>l?M(l):c(t(a),ue(p=>p==="sent"?o(a):O(new Ue("User denied access")))))),u),{...n,returns:"task",requires:"web_app_request_phone"})}function bs(){return _s({...c(S(),Qe,k),requestPhoneAccess:Ye})}function gs({requestContact:r,...t}){return P(r,{...t,returns:"task",requires:"web_app_request_phone"})}function Fs(){return gs({...c(S(),k),requestContact(r){return c(Ze(r),I(t=>t.parsed))}})}const Ze=bs(),ws=h(Ze),Jt=Fs(),Cs=h(Jt);function Ss({request:r,...t}){return P(n=>c(r("web_app_request_write_access","write_access_requested",n),I(s=>s.status)),{...t,requires:"web_app_request_write_access",returns:"task"})}function vs(){return Ss(c(S(),k,U))}const Yt=vs(),ys=h(Yt);class Zt{constructor({version:t,onClosed:n,onTextReceived:s,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=A({...u,returns:"either"}),l=A({...u,returns:"task"}),p=g.signal(!1),b=()=>{p.set(!1)};this.isSupported=Z("web_app_open_scan_qr_popup",t),this.isOpened=g.computed(p),this.captureFp=l(f=>{let C;return c(this.openFp({...f,onCaptured:w=>{f.capture(w)&&(C=w,this.close())}}),I(()=>C))}),this.closeFp=a(()=>c(o("web_app_close_scan_qr_popup"),H(b))),this.openFp=l(f=>c(p()?O(new Se("The QR Scanner is already opened")):async()=>o("web_app_open_scan_qr_popup",{text:f.text}),ue(()=>{p.set(!0);const[C,w]=L.createCbCollector(),v=y=>(w(),p.set(!1),y);return c(L.BetterTaskEither(y=>{C(n(y),p.sub(_=>{_||y()}),s(f.onCaptured))},f),je(v,v))}))),this.open=h(this.openFp),this.capture=h(this.captureFp),this.close=h(this.closeFp)}}function ks(){return new Zt({...c(S(),j,k),onClosed(r){return d.on("scan_qr_popup_closed",r)},onTextReceived(r){return d.on("qr_text_received",t=>{r(t.data)})}})}const Es=ks();class Xt{constructor({defaults:t,...n}){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 s=new ve({...n,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=s.stateGetter(o);return g.computed(()=>a()||W(u))};this.isSupported=Z("web_app_setup_secondary_button",n.version),this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.position=s.stateGetter("position"),this.hasShineEffect=s.stateGetter("hasShineEffect"),this.isEnabled=s.stateGetter("isEnabled"),this.isLoaderVisible=s.stateGetter("isLoaderVisible"),this.text=s.stateGetter("text"),this.isVisible=s.stateGetter("isVisible"),this.isMounted=s.isMounted,this.state=s.state,[this.setPosition,this.setPositionFp]=s.stateSetters("position"),[this.setBgColor,this.setBgColorFp]=s.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=s.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=s.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=s.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=s.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=s.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=s.stateBoolSetters("isVisible"),this.setParams=s.setState,this.setParamsFp=s.setStateFp,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 Is(){return new Xt(Qt("secondaryButton","secondary_button_pressed",{bgColor:g.computed(()=>Nt.bottomBarColorRgb()||"#000000"),textColor:g.computed(()=>he.buttonColor()||"#2481cc")}))}const As=Is();class er{constructor({isTma:t,request:n,version:s,createRequestId:i}){e(this,"getItemFp");e(this,"getItem");e(this,"restoreItemFp");e(this,"restoreItem");e(this,"setItemFp");e(this,"setItem");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"clearFp");e(this,"clear");const o=A({version:s,requires:"web_app_secure_storage_get_key",isTma:t,returns:"task"}),u=(a,l,p)=>{const b=i();return c(n(a,["secure_storage_failed",l],{params:{...p,req_id:b},capture:f=>"payload"in f?f.payload.req_id===b:!0}),J(f=>f.event==="secure_storage_failed"?O(new _t(f.payload.error||"UNKNOWN_ERROR")):M(f.payload)))};this.getItemFp=o(a=>c(u("web_app_secure_storage_get_key","secure_storage_key_received",{key:a}),I(l=>({value:l.value,canRestore:!!l.can_restore})))),this.setItemFp=o((a,l)=>c(u("web_app_secure_storage_save_key","secure_storage_key_saved",{key:a,value:l}),I(()=>{}))),this.deleteItemFp=o(a=>this.setItemFp(a,null)),this.clearFp=o(()=>c(u("web_app_secure_storage_clear","secure_storage_cleared",{}),I(()=>{}))),this.restoreItemFp=o(a=>c(u("web_app_secure_storage_restore_key","secure_storage_key_restored",{key:a}),I(l=>l.value))),this.getItem=h(this.getItemFp),this.setItem=h(this.setItemFp),this.deleteItem=h(this.deleteItemFp),this.clear=h(this.clearFp),this.restoreItem=h(this.restoreItemFp)}}function Bs(){return new er(c(S(),k,U,Mt))}const Ps=Bs();class tr{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 n=new ve({...t,method:"web_app_setup_settings_button",payload:s=>({is_visible:s.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}const qs=new tr(Ge("settingsButton","settings_button_pressed"));class rr{constructor({postEvent:t,storage:n,isTma:s,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={isVerticalEnabled:!0},a=new te({initialState:u,onChange(w){n.set(w)}}),l=new me({initialState:u,isPageReload:i,onMounted:a.setState,restoreState:n.get}),p={requires:"web_app_setup_swipe_behavior",isTma:s,version:o},b=A({...p,returns:"plain"}),f=A({...p,isMounted:l.isMounted,returns:"either"}),C=w=>{const v={isVerticalEnabled:w};return a.hasDiff(v)?c(t("web_app_setup_swipe_behavior",{allow_vertical_swipe:w}),H(()=>{a.setState(v)})):q(void 0)};this.isSupported=Z("web_app_setup_swipe_behavior",o),this.isVerticalEnabled=a.getter("isVerticalEnabled"),this.isMounted=l.isMounted,this.disableVerticalFp=f(()=>C(!1)),this.enableVerticalFp=f(()=>C(!0)),this.mountFp=b(()=>{const w=()=>{};return c(l.mount(),fe(w,w))}),this.unmount=l.unmount,this.disableVertical=h(this.disableVerticalFp),this.enableVertical=h(this.enableVerticalFp),this.mount=h(this.mountFp)}}function Ms(){return new rr(c(S(),j,k,re("swipeBehavior")))}const xs=Ms();async function $s(r){try{const{clipboard:n}=navigator;if(n)return await n.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 Ts({request:r,...t}){return P((n,s,i)=>c(r("web_app_request_file_download","file_download_requested",{...i,params:{url:n,file_name:s}}),J(o=>o.status==="downloading"?M(void 0):O(new Ue("User denied the action")))),{...t,requires:"web_app_request_file_download",returns:"task"})}function Rs(){return Ts(c(S(),U,k))}const nr=Rs(),Os=h(nr);function Ls({invokeCustomMethod:r,...t}){return P(n=>c(r("getCurrentTime",{},n),J(s=>{const i=E.safeParse(E.pipe(E.number(),E.integer(),E.transform(o=>new Date(o*1e3)),E.date()),s);return i.success?M(i.output):O(new pe(s,i.issues))})),{...t,requires:"web_app_invoke_custom_method",returns:"task"})}function Vs(){return Ls(c(S(),Qe,k))}const sr=Vs(),js=h(sr);function Ds({postEvent:r,...t}){return P(()=>r("web_app_hide_keyboard"),{...t,returns:"either",requires:"web_app_hide_keyboard"})}function Us(){return Ds(c(S(),j,k))}const or=Us(),Gs=h(or);function Hs({request:r,createRequestId:t,...n}){return P(s=>{const i=t();return c(r("web_app_read_text_from_clipboard","clipboard_text_received",{...s,params:{req_id:i},capture:d.captureSameReq(i)}),I(({data:o=null})=>o))},{...n,requires:"web_app_read_text_from_clipboard",returns:"task"})}function Ws(){return Hs({...c(S(),k,U),createRequestId:ye})}const ir=Ws(),Qs=h(ir);function ar(r){const t={},n=r.match(/Telegram-Android(?:\/([^ ]+))?(?: (\([^)]+\))?|$)/);if(n){const[,s,i]=n;s&&(t.appVersion=s),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 Ks(){return ar(navigator.userAgent)}function Ns({postEvent:r,...t}){return P(n=>{const{size:s}=new Blob([n]);return!s||s>4096?R(new z(s?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data")):r("web_app_data_send",{data:n})},{...t,returns:"either"})}function zs(){return Ns(c(S(),j))}const ur=zs(),Js=h(ur);function Ys({request:r,...t}){return P((n,s)=>c(r("web_app_send_prepared_message",["prepared_message_failed","prepared_message_sent"],{...s,params:{id:n}}),J(i=>i.event==="prepared_message_failed"?O(new Ct(i.payload.error)):M(void 0))),{...t,requires:"web_app_send_prepared_message",returns:"task"})}function Zs(){return Ys(c(S(),U,k))}const cr=Zs(),Xs=h(cr);function eo({postEvent:r,...t}){return P((n,s={})=>r("web_app_share_to_story",{text:s.text,media_url:n,widget_link:s.widgetLink}),{...t,requires:"web_app_share_to_story",returns:"either"})}function to(){return eo(c(S(),j,k))}const pr=to(),ro=h(pr),qe=be(!1);function no({isInlineMode:r,postEvent:t,...n}){return P((s,i)=>t("web_app_switch_inline_query",{query:s,chat_types:i||[]}),{...n,requires:{every:["web_app_switch_inline_query",()=>W(r)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}function so(){return no({...c(S(),j,k),isInlineMode:qe})}const lr=so(),oo=h(lr);class hr{constructor({storage:t,isPageReload:n,onContentSafeAreaInsetsChanged:s,onSafeAreaInsetsChanged:i,onViewportChanged:o,onFullscreenChanged:u,offContentSafeAreaInsetsChanged:a,offFullscreenChanged:l,offSafeAreaInsetsChanged:p,offViewportChanged:b,request:f,isViewportStable:C,isFullscreen:w,isTma:v,version:y,postEvent:_}){e(this,"state");e(this,"height");e(this,"stableHeight");e(this,"width");e(this,"isExpanded");e(this,"isStable",g.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 F={top:0,right:0,left:0,bottom:0},m=new te({initialState:{contentSafeAreaInsets:F,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:F,stableHeight:0,width:0},onChange:t.set}),$=B=>{m.setState({isExpanded:B.is_expanded,height:B.height,width:B.width,stableHeight:B.is_state_stable?B.height:void 0})},D=B=>{m.setState({isFullscreen:B.is_fullscreen})},V=B=>{m.setState({safeAreaInsets:B})},K=B=>{m.setState({contentSafeAreaInsets:B})},G=new He({initialState(B){const ne=X=>()=>{const[ee,N]=X==="safe-area"?["web_app_request_safe_area","safe_area_changed"]:["web_app_request_content_safe_area","content_safe_area_changed"];return d.supports(ee,W(y))?f(ee,N,B):M({top:0,left:0,right:0,bottom:0})},T=X=>()=>typeof X=="boolean"?M(X):ft(X());return c(fn,we("safeAreaInsets",ne("safe-area")),we("contentSafeAreaInsets",ne("content-safe-area")),we("isFullscreen",T(w)),we("isViewportStable",T(C)),ue(({isViewportStable:X,...ee})=>X?M({...ee,height:window.innerHeight,isExpanded:!0,stableHeight:window.innerHeight,width:window.innerWidth}):c(f("web_app_request_viewport","viewport_changed",B),I(N=>({...ee,height:N.height,isExpanded:N.is_expanded,stableHeight:N.is_state_stable?N.height:0,width:N.width})))))},isPageReload:n,onMounted(B){o($),u(D),i(V),s(K),m.setState(B)},onUnmounted(){b($),l(D),p(V),a(K)},restoreState:t.get}),Y=B=>g.computed(()=>this.safeAreaInsets()[B]),ge=B=>g.computed(()=>this.contentSafeAreaInsets()[B]);this.state=m.state,this.height=m.getter("height"),this.stableHeight=m.getter("stableHeight"),this.width=m.getter("width"),this.isExpanded=m.getter("isExpanded"),this.safeAreaInsets=m.getter("safeAreaInsets"),this.safeAreaInsetTop=Y("top"),this.safeAreaInsetBottom=Y("bottom"),this.safeAreaInsetLeft=Y("left"),this.safeAreaInsetRight=Y("right"),this.contentSafeAreaInsets=m.getter("contentSafeAreaInsets"),this.contentSafeAreaInsetTop=ge("top"),this.contentSafeAreaInsetBottom=ge("bottom"),this.contentSafeAreaInsetLeft=ge("left"),this.contentSafeAreaInsetRight=ge("right");const fr=A({isTma:v,returns:"task"}),Xe=A({isTma:v,returns:"either"}),mr=A({isTma:v,requires:"web_app_request_fullscreen",version:y,returns:"task"}),et=B=>mr(ne=>c(f(B?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],ne),J(T=>T.event==="fullscreen_failed"&&T.payload.error!=="ALREADY_FULLSCREEN"?O(new wt(T.payload.error)):(m.setState({isFullscreen:"is_fullscreen"in T.payload?T.payload.is_fullscreen:!0}),M(void 0)))));this.isMounted=G.isMounted,this.mountFp=fr(G.mount),this.mount=h(this.mountFp),this.isFullscreen=m.getter("isFullscreen"),this.requestFullscreenFp=et(!0),this.requestFullscreen=h(this.requestFullscreenFp),this.exitFullscreenFp=et(!1),this.exitFullscreen=h(this.exitFullscreenFp);const Fe=g.signal(!1);this.isCssVarsBound=g.computed(Fe),this.bindCssVarsFp=Xe(B=>{if(Fe())return R(new Ce);B||(B=T=>`--tg-viewport-${L.camelToKebab(T)}`);const ne=[["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,[X,ee])=>{const N=B(X);if(N){const tt=()=>{Ne(N,`${ee()}px`)};T.push({update:tt,removeListener:ee.sub(tt),cssVar:N})}return T},[]);return ne.forEach(T=>{T.update()}),Fe.set(!0),q(()=>{ne.forEach(T=>{T.removeListener(),ze(T.cssVar)}),Fe.set(!1)})}),this.bindCssVars=h(this.bindCssVarsFp),this.expandFp=Xe(()=>_("web_app_expand")),this.expand=h(this.expandFp)}}function io(){const r=o=>({on:u=>{d.on(o,u)},off:u=>{d.off(o,u)}}),t=r("viewport_changed"),n=r("fullscreen_changed"),s=r("safe_area_changed"),i=r("content_safe_area_changed");return new hr({...c(S(),re("viewport"),k,j,U),isFullscreen(){return c(d.retrieveLaunchParamsFp(),H(o=>!!o.tgWebAppFullscreen))},isViewportStable(){return c(d.retrieveLaunchParamsFp(),H(o=>["macos","tdesktop","unigram","webk","weba","web"].includes(o.tgWebAppPlatform)))},offContentSafeAreaInsetsChanged:i.off,offFullscreenChanged:n.off,offSafeAreaInsetsChanged:s.off,offViewportChanged:t.off,onContentSafeAreaInsetsChanged:i.on,onFullscreenChanged:n.on,onSafeAreaInsetsChanged:s.on,onViewportChanged:t.on})}const ao=io();function dr(r={}){const{version:t,isInlineMode:n,themeParams:s}=r;if(t&&typeof n=="boolean"&&s)Be.set(t),qe.set(n),Pe.set(s);else{const a=c(d.retrieveLaunchParamsFp(),pt(l=>l,l=>{Be.set(t||l.tgWebAppVersion),qe.set(typeof n=="boolean"?n:!!l.tgWebAppBotInline),Pe.set(s||l.tgWebAppThemeParams)}));if(a)return R(a)}r.postEvent&&yt.set(r.postEvent);const[i,o]=L.createCbCollector(d.on("reload_iframe",()=>{d.logger().log("Received a request to reload the page"),kt("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(d.on("set_custom_style",l=>{a.innerHTML=l}),()=>{document.head.removeChild(a)})}return c(ie("iframe_ready",{reload_supported:!0}),H(()=>(d.logger().log("The package was initialized"),o)))}const uo=L.throwifyFpFn(dr);Object.defineProperty(exports,"CancelledError",{enumerable:!0,get:()=>d.CancelledError});Object.defineProperty(exports,"InvalidLaunchParamsError",{enumerable:!0,get:()=>d.InvalidLaunchParamsError});Object.defineProperty(exports,"InvokeCustomMethodFailedError",{enumerable:!0,get:()=>d.InvokeCustomMethodFailedError});Object.defineProperty(exports,"LaunchParamsRetrieveError",{enumerable:!0,get:()=>d.LaunchParamsRetrieveError});Object.defineProperty(exports,"MethodParameterUnsupportedError",{enumerable:!0,get:()=>d.MethodParameterUnsupportedError});Object.defineProperty(exports,"MethodUnsupportedError",{enumerable:!0,get:()=>d.MethodUnsupportedError});Object.defineProperty(exports,"TimeoutError",{enumerable:!0,get:()=>d.TimeoutError});Object.defineProperty(exports,"UnknownEnvError",{enumerable:!0,get:()=>d.UnknownEnvError});Object.defineProperty(exports,"applyPolyfills",{enumerable:!0,get:()=>d.applyPolyfills});Object.defineProperty(exports,"createLogger",{enumerable:!0,get:()=>d.createLogger});Object.defineProperty(exports,"createPostEvent",{enumerable:!0,get:()=>d.createPostEvent});Object.defineProperty(exports,"createStartParam",{enumerable:!0,get:()=>d.createStartParam});Object.defineProperty(exports,"createStartParamFp",{enumerable:!0,get:()=>d.createStartParamFp});Object.defineProperty(exports,"debug",{enumerable:!0,get:()=>d.debug});Object.defineProperty(exports,"decodeBase64Url",{enumerable:!0,get:()=>d.decodeBase64Url});Object.defineProperty(exports,"decodeBase64UrlFp",{enumerable:!0,get:()=>d.decodeBase64UrlFp});Object.defineProperty(exports,"decodeStartParam",{enumerable:!0,get:()=>d.decodeStartParam});Object.defineProperty(exports,"decodeStartParamFp",{enumerable:!0,get:()=>d.decodeStartParamFp});Object.defineProperty(exports,"deepSnakeToCamelObjKeys",{enumerable:!0,get:()=>d.deepSnakeToCamelObjKeys});Object.defineProperty(exports,"emitEvent",{enumerable:!0,get:()=>d.emitEvent});Object.defineProperty(exports,"encodeBase64Url",{enumerable:!0,get:()=>d.encodeBase64Url});Object.defineProperty(exports,"getReleaseVersion",{enumerable:!0,get:()=>d.getReleaseVersion});Object.defineProperty(exports,"isSafeToCreateStartParam",{enumerable:!0,get:()=>d.isSafeToCreateStartParam});Object.defineProperty(exports,"isTMA",{enumerable:!0,get:()=>d.isTMA});Object.defineProperty(exports,"isTMAFp",{enumerable:!0,get:()=>d.isTMAFp});Object.defineProperty(exports,"logger",{enumerable:!0,get:()=>d.logger});Object.defineProperty(exports,"mockTelegramEnv",{enumerable:!0,get:()=>d.mockTelegramEnv});Object.defineProperty(exports,"off",{enumerable:!0,get:()=>d.off});Object.defineProperty(exports,"offAll",{enumerable:!0,get:()=>d.offAll});Object.defineProperty(exports,"on",{enumerable:!0,get:()=>d.on});Object.defineProperty(exports,"retrieveLaunchParams",{enumerable:!0,get:()=>d.retrieveLaunchParams});Object.defineProperty(exports,"retrieveLaunchParamsFp",{enumerable:!0,get:()=>d.retrieveLaunchParamsFp});Object.defineProperty(exports,"retrieveRawInitData",{enumerable:!0,get:()=>d.retrieveRawInitData});Object.defineProperty(exports,"retrieveRawInitDataFp",{enumerable:!0,get:()=>d.retrieveRawInitDataFp});Object.defineProperty(exports,"retrieveRawLaunchParams",{enumerable:!0,get:()=>d.retrieveRawLaunchParams});Object.defineProperty(exports,"retrieveRawLaunchParamsFp",{enumerable:!0,get:()=>d.retrieveRawLaunchParamsFp});Object.defineProperty(exports,"setDebug",{enumerable:!0,get:()=>d.setDebug});Object.defineProperty(exports,"setTargetOrigin",{enumerable:!0,get:()=>d.setTargetOrigin});Object.defineProperty(exports,"supports",{enumerable:!0,get:()=>d.supports});Object.defineProperty(exports,"targetOrigin",{enumerable:!0,get:()=>d.targetOrigin});Object.defineProperty(exports,"isAnyRGB",{enumerable:!0,get:()=>x.isAnyRGB});Object.defineProperty(exports,"isRGB",{enumerable:!0,get:()=>x.isRGB});Object.defineProperty(exports,"isRGBA",{enumerable:!0,get:()=>x.isRGBA});Object.defineProperty(exports,"isRGBAShort",{enumerable:!0,get:()=>x.isRGBAShort});Object.defineProperty(exports,"isRGBShort",{enumerable:!0,get:()=>x.isRGBShort});Object.defineProperty(exports,"parseInitDataQuery",{enumerable:!0,get:()=>x.parseInitDataQuery});Object.defineProperty(exports,"parseInitDataQueryFp",{enumerable:!0,get:()=>x.parseInitDataQueryFp});Object.defineProperty(exports,"parseLaunchParamsQuery",{enumerable:!0,get:()=>x.parseLaunchParamsQuery});Object.defineProperty(exports,"parseLaunchParamsQueryFp",{enumerable:!0,get:()=>x.parseLaunchParamsQueryFp});Object.defineProperty(exports,"serializeInitDataQuery",{enumerable:!0,get:()=>x.serializeInitDataQuery});Object.defineProperty(exports,"serializeLaunchParamsQuery",{enumerable:!0,get:()=>x.serializeLaunchParamsQuery});Object.defineProperty(exports,"toRGB",{enumerable:!0,get:()=>x.toRGB});Object.defineProperty(exports,"toRGBFp",{enumerable:!0,get:()=>x.toRGBFp});Object.defineProperty(exports,"toRGBFull",{enumerable:!0,get:()=>x.toRGBFull});Object.defineProperty(exports,"toRGBFullFp",{enumerable:!0,get:()=>x.toRGBFullFp});exports.AccessDeniedError=Ue;exports.BackButton=vt;exports.Biometry=Et;exports.CSSVarsBoundError=Ce;exports.ClosingBehavior=At;exports.CloudStorage=Bt;exports.ConcurrentCallError=Se;exports.DeviceStorage=qt;exports.DeviceStorageMethodError=mt;exports.FullscreenFailedError=wt;exports.FunctionUnavailableError=gt;exports.HapticFeedback=Tt;exports.InitData=Lt;exports.InvalidArgumentsError=z;exports.InvalidEnvError=_n;exports.Invoice=Vt;exports.LocationManager=Ut;exports.MainButton=Gt;exports.MiniApp=Kt;exports.NotAvailableError=bt;exports.Popup=zt;exports.QrScanner=Zt;exports.SecondaryButton=Xt;exports.SecureStorage=er;exports.SecureStorageMethodError=_t;exports.SetEmojiStatusError=Ft;exports.SettingsButton=tr;exports.ShareMessageError=Ct;exports.SwipeBehavior=rr;exports.ThemeParams=Wt;exports.UnknownThemeParamsKeyError=St;exports.ValidationError=pe;exports.Viewport=hr;exports.addToHomeScreen=Dn;exports.addToHomeScreenFp=Rt;exports.backButton=wn;exports.biometry=yn;exports.checkHomeScreenStatus=Hn;exports.checkHomeScreenStatusFp=Ot;exports.closingBehavior=En;exports.cloudStorage=An;exports.copyTextToClipboard=$s;exports.createRequestId=ye;exports.deviceStorage=Pn;exports.downloadFile=Os;exports.downloadFileFp=nr;exports.getCurrentTime=js;exports.getCurrentTimeFp=sr;exports.hapticFeedback=Ln;exports.hideKeyboard=Gs;exports.hideKeyboardFp=or;exports.init=uo;exports.initData=Qn;exports.initFp=dr;exports.invoice=Nn;exports.invokeCustomMethod=Pt;exports.isColorDark=Je;exports.isColorDarkFp=Ht;exports.locationManager=is;exports.mainButton=us;exports.miniApp=Nt;exports.openLink=Yn;exports.openLinkFp=jt;exports.openTelegramLink=es;exports.openTelegramLinkFp=Ke;exports.popup=hs;exports.postEvent=kt;exports.postEventFp=ie;exports.qrScanner=Es;exports.readTextFromClipboard=Qs;exports.readTextFromClipboardFp=ir;exports.request=Cn;exports.request2=Sn;exports.request2Fp=We;exports.requestContact=Cs;exports.requestContactComplete=ws;exports.requestContactCompleteFp=Ze;exports.requestContactFp=Jt;exports.requestEmojiStatusAccess=xn;exports.requestEmojiStatusAccessFp=xt;exports.requestFp=It;exports.requestPhoneAccess=ms;exports.requestPhoneAccessFp=Ye;exports.requestWriteAccess=ys;exports.requestWriteAccessFp=Yt;exports.retrieveAndroidDeviceData=Ks;exports.retrieveAndroidDeviceDataFrom=ar;exports.secondaryButton=As;exports.secureStorage=Ps;exports.sendData=Js;exports.sendDataFp=ur;exports.setEmojiStatus=Rn;exports.setEmojiStatusFp=$t;exports.settingsButton=qs;exports.shareMessage=Xs;exports.shareMessageFp=cr;exports.shareStory=ro;exports.shareStoryFp=pr;exports.shareURL=ns;exports.shareURLFp=Dt;exports.swipeBehavior=xs;exports.switchInlineQuery=oo;exports.switchInlineQueryFp=lr;exports.themeParams=he;exports.viewport=ao;
|
|
1
|
+
"use strict";var Tt=Object.defineProperty;var Ot=(s,r,n)=>r in s?Tt(s,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[r]=n;var e=(s,r,n)=>Ot(s,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("@tma.js/signals"),h=require("@tma.js/bridge"),x=require("@tma.js/toolkit"),Me=require("better-promises"),A=require("@tma.js/transformers"),t=require("fp-ts"),$=require("error-kid"),v=require("valibot");function j(s){return typeof s=="function"?s():s}class re{constructor({onMounted:r,restoreState:n,initialState:i,onUnmounted:u,isPageReload:a}){e(this,"_isMounted",_.signal(!1));e(this,"isMounted",_.computed(this._isMounted));e(this,"mount");e(this,"unmount");this.mount=()=>{if(this.isMounted())return t.either.right(void 0);const c=j(a)?n():void 0,o=c?t.either.right(c):typeof i=="function"?i():t.either.right(i);return t.function.pipe(o,t.either.map(p=>{_.batch(()=>{this._isMounted.set(!0),r==null||r(p)})}))},this.unmount=()=>{this._isMounted()&&_.batch(()=>{this._isMounted.set(!1),u==null||u()})}}}function de(s){const r={};for(const n in s){const i=s[n];i!==void 0&&(r[n]=i)}return r}function pe(s,r){const n=Object.keys(s),i=Object.keys(r);return n.length!==i.length?!1:n.every(u=>Object.prototype.hasOwnProperty.call(r,u)&&s[u]===r[u])}class z{constructor({initialState:r,onChange:n}){e(this,"_state");e(this,"state");e(this,"setState",r=>{const n={...this.state(),...de(r)};pe(n,this.state())||this._state.set(n)});this._state=_.signal(r,{equals:pe}),this.state=_.computed(this._state),this.state.sub(n)}getter(r){return _.computed(()=>this._state()[r])}hasDiff(r){return!pe({...this.state(),...de(r)},this.state())}}function W(s,r){return _.computed(()=>h.supports(s,j(r)))}function l(s){return Object.assign(x.throwifyFpFn(s),{ifAvailable(...r){return t.function.pipe(s.ifAvailable(...r),t.option.match(()=>({ok:!1}),n=>({ok:!0,data:x.throwifyAnyEither(n)})))}})}function Y(s){return[s]}class ee extends $.errorClassWithData("ValidationError",(r,n)=>({input:r,issues:n}),"Validation error"){}class oe extends $.errorClass("CSSVarsBoundError","CSS variables are already bound"){}class xe extends $.errorClassWithData("DeviceStorageMethodError",r=>({error:r}),r=>[r]){}class Te extends $.errorClassWithData("SecureStorageMethodError",r=>({error:r}),r=>[r]){}class Oe extends $.errorClass("NotAvailableError",Y){}class Vt extends $.errorClass("InvalidEnvError",Y){}class Ve extends $.errorClass("FunctionNotAvailableError",Y){}class U extends $.errorClass("InvalidArgumentsError",(r,n)=>[r,{cause:n}]){}class ae extends $.errorClass("ConcurrentCallError",Y){}class Le extends $.errorClass("SetEmojiStatusError",r=>[`Failed to set emoji status: ${r}`]){}class _e extends $.errorClass("AccessDeniedError",Y){}class Re extends $.errorClass("FullscreenFailedError",Y){}class je extends $.errorClass("ShareMessageError",Y){}class $e extends $.errorClass("UnknownThemeParamsKeyError",r=>[`Unknown theme params key passed: ${r}`]){}function q(s,r){const n=_.computed(()=>j(r.version)||"100"),i=_.computed(()=>j(r.isTma)),{requires:u,returns:a}=r,c=u?typeof u=="object"?u:{every:[u]}:void 0,o=b=>{if(!r.supports)return!0;const g=r.supports[b];return h.supports(g.method,g.param,n())},p=()=>{if(!c)return;const[b,g]="every"in c?["every",c.every]:["some",c.some];for(let d=0;d<g.length;d++){const P=g[d],V=typeof P=="function"?P():h.supports(P,n())?void 0:`it is unsupported in Mini Apps version ${n()}`;if(V&&(b==="every"||d===g.length-1))return V}},m=(...b)=>{for(const g in r.supports)if(r.supports[g].shouldCheck(...b)&&!o(g))return`option ${g} is not supported in Mini Apps version ${n()}`},F=_.computed(()=>!p()),f=_.computed(()=>n()!=="0.0"),w=_.computed(()=>r.isMounted?r.isMounted():!0),C=_.computed(()=>i()&&f()&&F()&&w()),k=b=>{const g=new Ve(b);return["task","promise"].includes(r.returns)?t.taskEither.left(g):t.either.left(g)},E=(...b)=>a==="plain"?t.either.tryCatch(()=>s(...b),g=>g):a==="promise"?t.taskEither.tryCatch(()=>s(...b),g=>g):s(...b);return Object.assign((...b)=>{var V;const g="Unable to call function:";if(!i())return k(`${g} it can't be called outside Mini Apps`);if(!f())return k(`${g} the SDK was not initialized. Use the SDK init() function`);const d=p();if(d)return k(`${g} ${d}`);const P=m(...b);if(P)return k(`${g} ${P}`);if(!w()){const T=(V=r.isMounting)!=null&&V.call(r)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return k(`${g} the component is ${T}`)}return E(...b)},s,{isAvailable:C,ifAvailable(...b){return C()?t.option.some(E(...b)):t.option.none}},c?{isSupported:F}:{},r.supports?{supports:o}:{})}function I(s){return r=>q(r,s)}class ue{constructor({isTma:r,storage:n,onClick:i,offClick:u,initialState:a,isPageReload:c,postEvent:o,payload:p,method:m,version:F}){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 f=new z({initialState:a,onChange(b){n.set(b)}}),w=new re({initialState:a,isPageReload:c,onMounted:f.setState,restoreState:n.get}),C={version:F,requires:m,isTma:r},k=I({...C,returns:"plain"}),E=I({...C,returns:"either",isMounted:w.isMounted});this.isMounted=w.isMounted,this.isSupported=W(m,F),this.state=f.state,this.setStateFp=E(b=>{const g={...this.state(),...de(b)};return f.hasDiff(g)?t.function.pipe(o(m,p(g)),t.either.map(()=>{f.setState(g)})):t.either.right(void 0)}),this.setState=l(this.setStateFp),this.onClickFp=k(i),this.onClick=l(this.onClickFp),this.offClickFp=k(u),this.offClick=l(this.offClickFp),this.mountFp=k(()=>{const b=()=>{};return t.function.pipe(w.mount(),t.either.match(b,b))}),this.mount=l(this.mountFp),this.unmount=w.unmount,this.stateSetters=b=>{const g=E(d=>this.setStateFp({[b]:d}));return[l(g),g]},this.stateBoolSetters=b=>{const[,g]=this.stateSetters(b),d=E(()=>g(!1)),P=E(()=>g(!0));return[[l(d),d],[l(P),P]]}}stateGetter(r){return _.computed(()=>this.state()[r])}}class De{constructor(r){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 n=new ue({...r,method:"web_app_setup_back_button",payload:i=>({is_visible:i.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}function S(){return{isTma:_.computed(()=>h.isTMAFp())}}function X(s){return r=>({...r,...j(s)})}function se(s,r){return _.signal(s,r)}const Ge=se(h.postEventFp),Z=(...s)=>Ge()(...s),Ue=(...s)=>x.throwifyAnyEither(Z(...s)),O=X({postEvent:Z});function Lt(s){return{get:()=>x.getStorageValue(s),set(r){x.setStorageValue(s,r)}}}function Rt(){return performance.getEntriesByType("navigation")[0]}function jt(){const s=Rt();return!!s&&s.type==="reload"}function N(s){return X({storage:Lt(s),isPageReload:jt})}const fe=se("0.0"),y=X({version:fe});function ge(s,r){return{...t.function.pipe(S(),O,y,N(s)),onClick(n,i){return h.on(r,n,i)},offClick(n,i){h.off(r,n,i)}}}const $t=new De(ge("backButton","back_button_pressed"));class Fe{constructor({initialState:r,onMounted:n,restoreState:i,onUnmounted:u,isPageReload:a}){e(this,"_isMounted",_.signal(!1));e(this,"isMounted",_.computed(this._isMounted));e(this,"mount");e(this,"unmount");this.mount=c=>{if(this._isMounted())return t.taskEither.right(void 0);const o=j(a)?i():void 0;return t.function.pipe(o?t.taskEither.right(o):r(c),t.taskEither.map(p=>{this._isMounted()||_.batch(()=>{this._isMounted.set(!0),n==null||n(p)})}))},this.unmount=()=>{this._isMounted()&&_.batch(()=>{this._isMounted.set(!1),u==null||u()})}}}function Pe(){return new Oe("Biometry is not available")}function le(s){let r=!1,n=!1,i="",u=!1,a="",c=!1;return s.available&&(r=!0,n=s.token_saved,i=s.device_id,u=s.access_requested,a=s.type,c=s.access_granted),{available:r,tokenSaved:n,deviceId:i,type:a,accessGranted:c,accessRequested:u}}class He{constructor({version:r,request:n,postEvent:i,storage:u,onInfoReceived:a,offInfoReceived:c,isTma:o,isPageReload:p}){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 m=b=>{F.setState(le(b))},F=new z({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:u.set}),f=new Fe({initialState(b){return t.function.pipe(n("web_app_biometry_get_info","biometry_info_received",b),t.taskEither.map(le))},isPageReload:p,onMounted(b){F.setState(b),a(m)},onUnmounted(){c(m)},restoreState:u.get}),w={version:r,requires:"web_app_biometry_request_auth",isTma:o},C=I({...w,returns:"either"}),k=I({...w,returns:"task"}),E=I({...w,isMounted:f.isMounted,returns:"task"});this.isAvailable=F.getter("available"),this.isMounted=f.isMounted,this.isSupported=W("web_app_biometry_request_auth",r),this.state=F.state,this.unmount=f.unmount,this.mountFp=k(f.mount),this.authenticateFp=E(b=>this.isAvailable()?t.function.pipe(n("web_app_biometry_request_auth","biometry_auth_requested",{...b,params:{reason:((b||{}).reason||"").trim()}}),t.taskEither.map(g=>(F.setState({token:g.token}),g))):t.taskEither.left(Pe())),this.openSettingsFp=C(()=>i("web_app_biometry_open_settings")),this.requestAccessFp=E(b=>t.function.pipe(n("web_app_biometry_request_access","biometry_info_received",{...b,params:{reason:((b||{}).reason||"").trim()}}),t.taskEither.chain(g=>{const d=le(g);return d.available?(F.setState(d),t.taskEither.right(d.accessRequested)):t.taskEither.left(Pe())}))),this.updateTokenFp=E((b={})=>{var g;return t.function.pipe(n("web_app_biometry_update_token","biometry_token_updated",{...b,params:{token:b.token||"",reason:(g=b.reason)==null?void 0:g.trim()}}),t.taskEither.map(d=>d.status))}),this.authenticate=l(this.authenticateFp),this.openSettings=l(this.openSettingsFp),this.requestAccess=l(this.requestAccessFp),this.updateToken=l(this.updateTokenFp),this.mount=l(this.mountFp)}}const We=(s,r,n)=>h.requestFp(s,r,{postEvent:Z,...n}),Ce=(s,r,n)=>h.request2Fp(s,r,{postEvent:Z,...n}),Dt=(...s)=>Me.BetterPromise.fn(()=>We(...s)()),Gt=(...s)=>Me.BetterPromise.fn(()=>Ce(...s)()),L=X({request:Ce});function Ut(){return new He({...t.function.pipe(S(),O,y,L,N("biometry")),offInfoReceived(s){h.off("biometry_info_received",s)},onInfoReceived(s){return h.on("biometry_info_received",s)}})}const Ht=Ut();class Qe{constructor({postEvent:r,storage:n,isTma:i,isPageReload:u}){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 a=new z({initialState:{isConfirmationEnabled:!1},onChange(f){n.set(f)}}),c=new re({onMounted:a.setState,restoreState:n.get,initialState:{isConfirmationEnabled:!1},isPageReload:u}),o={requires:"web_app_setup_closing_behavior",isTma:i},p=I({...o,returns:"plain"}),m=I({...o,returns:"either",isMounted:c.isMounted}),F=f=>f===this.isConfirmationEnabled()?t.either.right(void 0):(a.setState({isConfirmationEnabled:f}),r("web_app_setup_closing_behavior",{need_confirmation:f}));this.isConfirmationEnabled=a.getter("isConfirmationEnabled"),this.isMounted=c.isMounted,this.disableConfirmationFp=m(()=>F(!1)),this.enableConfirmationFp=m(()=>F(!0)),this.mountFp=p(()=>{const f=()=>{};return t.function.pipe(c.mount(),t.either.match(f,f))}),this.unmount=c.unmount,this.disableConfirmation=l(this.disableConfirmationFp),this.enableConfirmation=l(this.enableConfirmationFp),this.mount=l(this.mountFp)}}function Wt(){return new Qe(t.function.pipe(S(),N("closingBehavior"),O))}const Qt=Wt();class Ke{constructor({version:r,isTma:n,invokeCustomMethod:i}){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 u=I({version:r,requires:"web_app_invoke_custom_method",isTma:n,returns:"task"});this.isSupported=W("web_app_invoke_custom_method",r),this.deleteItemFp=u((a,c)=>{const o=Array.isArray(a)?a:[a];return t.function.pipe(o.length?i("deleteStorageValues",{keys:o},c):t.taskEither.right(void 0),t.taskEither.map(()=>{}))}),this.getItemFp=u((a,c)=>t.function.pipe(this.getItemsFp([a],c),t.taskEither.map(o=>o[a]||""))),this.getItemsFp=u((a,c)=>t.function.pipe(a.length?i("getStorageValues",{keys:a},c):t.taskEither.right({}),t.taskEither.map(o=>({...a.reduce((p,m)=>(p[m]="",p),{}),...v.parse(v.record(v.string(),v.string()),o)})))),this.getKeysFp=u(a=>t.function.pipe(i("getStorageKeys",{},a),t.taskEither.map(c=>v.parse(v.array(v.string()),c)))),this.setItemFp=u((a,c,o)=>t.function.pipe(i("saveStorageValue",{key:a,value:c},o),t.taskEither.map(()=>{}))),this.clearFp=u(a=>t.function.pipe(this.getKeysFp(a),t.taskEither.chain(this.deleteItemFp))),this.deleteItem=l(this.deleteItemFp),this.getItem=l(this.getItemFp),this.getItems=l(this.getItemsFp),this.getKeys=l(this.getKeysFp),this.setItem=l(this.setItemFp),this.clear=l(this.clearFp)}}const he=se(0);function ce(){return he.set(he()+1),he().toString()}function ze(s,r,n){return h.invokeCustomMethodFp(s,r,ce(),{...n||{},postEvent:Z})}const we=X({invokeCustomMethod:ze});function Kt(){return new Ke(t.function.pipe(S(),y,we))}const zt=Kt();class Ne{constructor({isTma:r,request:n,version:i,createRequestId:u}){e(this,"getItemFp");e(this,"getItem");e(this,"setItemFp");e(this,"setItem");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"clearFp");e(this,"clear");const a=I({version:i,requires:"web_app_device_storage_get_key",isTma:r,returns:"task"}),c=(o,p,m)=>{const F=u();return t.function.pipe(n(o,["device_storage_failed",p],{params:{...m,req_id:F},capture:f=>"payload"in f?f.payload.req_id===F:!0}),t.taskEither.chain(f=>f.event==="device_storage_failed"?t.taskEither.left(new xe(f.payload.error||"UNKNOWN_ERROR")):t.taskEither.right(f.payload)))};this.getItemFp=a(o=>t.function.pipe(c("web_app_device_storage_get_key","device_storage_key_received",{key:o}),t.taskEither.map(p=>p.value))),this.setItemFp=a((o,p)=>t.function.pipe(c("web_app_device_storage_save_key","device_storage_key_saved",{key:o,value:p}),t.taskEither.map(()=>{}))),this.deleteItemFp=a(o=>this.setItemFp(o,null)),this.clearFp=a(()=>t.function.pipe(c("web_app_device_storage_clear","device_storage_cleared",{}),t.taskEither.map(()=>{}))),this.getItem=l(this.getItemFp),this.setItem=l(this.setItemFp),this.deleteItem=l(this.deleteItemFp),this.clear=l(this.clearFp)}}const Je=X({createRequestId:ce});function Nt(){return new Ne(t.function.pipe(S(),y,L,Je))}const Jt=Nt();function Yt({request:s,...r}){return q(n=>t.function.pipe(s("web_app_request_emoji_status_access","emoji_status_access_requested",n),t.taskEither.map(i=>i.status)),{...r,requires:"web_app_request_emoji_status_access",returns:"task"})}function Zt(){return Yt(t.function.pipe(S(),y,L))}const Ye=Zt(),Xt=l(Ye);function er({request:s,...r}){return q((n,i)=>t.function.pipe(s("web_app_set_emoji_status",["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:n,duration:(i||{}).duration},...i}),t.taskEither.chainW(u=>u.event==="emoji_status_failed"?t.taskEither.left(new Le(u.payload.error)):t.taskEither.right(void 0))),{...r,requires:"web_app_set_emoji_status",returns:"task"})}function tr(){return er(t.function.pipe(S(),L,y))}const Ze=tr(),rr=l(Ze);class Xe{constructor({postEvent:r,isTma:n,version:i}){e(this,"isSupported");e(this,"impactOccurredFp");e(this,"impactOccurred");e(this,"notificationOccurredFp");e(this,"notificationOccurred");e(this,"selectionChangedFp");e(this,"selectionChanged");const u="web_app_trigger_haptic_feedback",a=I({requires:u,isTma:n,version:i,returns:"plain"});this.isSupported=W(u,i),this.impactOccurredFp=a(c=>r(u,{type:"impact",impact_style:c})),this.notificationOccurredFp=a(c=>r(u,{type:"notification",notification_type:c})),this.selectionChangedFp=a(()=>r(u,{type:"selection_change"})),this.impactOccurred=l(this.impactOccurredFp),this.notificationOccurred=l(this.notificationOccurredFp),this.selectionChanged=l(this.selectionChangedFp)}}function sr(){return new Xe(t.function.pipe(S(),O,y))}const nr=sr();function ir({postEvent:s,...r}){return q(()=>s("web_app_add_to_home_screen"),{...r,requires:"web_app_add_to_home_screen",returns:"either"})}function or(){return ir(t.function.pipe(S(),y,O))}const et=or(),ar=l(et);function ur({request:s,...r}){return q(n=>t.function.pipe(s("web_app_check_home_screen","home_screen_checked",n),t.taskEither.map(i=>i.status||"unknown")),{...r,requires:"web_app_check_home_screen",returns:"task"})}function cr(){return ur(t.function.pipe(S(),y,L))}const tt=cr(),pr=l(tt);class rt{constructor({retrieveInitData:r}){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 r=this.authDate(),n=this.canSendAfter();return n&&r?new Date(r.getTime()+n*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=()=>t.function.pipe(r(),t.either.map(t.option.match(()=>{},({raw:n,obj:i})=>{this._state.set(i),this._raw.set(n)}))),this.restore=x.throwifyFpFn(this.restoreFp)}fromState(r){return _.computed(()=>{const n=this._state();return n?n[r]:void 0})}}function lr(){return new rt({retrieveInitData(){return t.function.pipe(t.either.Do,t.either.bindW("obj",()=>t.function.pipe(h.retrieveLaunchParamsFp(),t.either.map(({tgWebAppData:s})=>s?t.option.some(s):t.option.none))),t.either.bindW("raw",h.retrieveRawInitDataFp),t.either.map(({obj:s,raw:r})=>t.function.pipe(t.option.Do,t.option.bind("obj",()=>s),t.option.bind("raw",()=>r))))}})}const hr=lr();class st{constructor({version:r,request:n,isTma:i}){e(this,"isOpened");e(this,"isSupported");e(this,"openSlugFp");e(this,"openSlug");e(this,"openUrlFp");e(this,"openUrl");const u=I({version:r,isTma:i,requires:"web_app_open_invoice",returns:"task"}),a=_.signal(!1),c=()=>{a.set(!1)};this.isSupported=W("web_app_open_invoice",r),this.isOpened=_.computed(a),this.openSlugFp=u((o,p)=>t.function.pipe(this.isOpened()?t.taskEither.left(new ae("Invoice is already opened")):t.taskEither.right(void 0),t.taskEither.chain(()=>(a.set(!0),n("web_app_open_invoice","invoice_closed",{...p,params:{slug:o},capture:m=>o===m.slug}))),t.taskEither.mapBoth(m=>(c(),m),m=>(c(),m.status)))),this.openUrlFp=u((o,p)=>{const{hostname:m,pathname:F}=new URL(o,window.location.href);if(m!=="t.me")return t.taskEither.left(new U(`Link has unexpected hostname: ${m}`));const f=F.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return f?this.openSlugFp(f[2],p):t.taskEither.left(new U('Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"'))}),this.openUrl=l(this.openUrlFp),this.openSlug=l(this.openSlugFp)}}function dr(){return new st(t.function.pipe(S(),L,y))}const fr=dr();function mr({postEvent:s,...r}){return q((n,i={})=>{if(typeof n=="string")try{n=new URL(n)}catch(u){return t.either.left(new U(`"${n.toString()}" is invalid URL`,u))}return s("web_app_open_link",{url:n.toString(),try_browser:i.tryBrowser,try_instant_view:i.tryInstantView})},{...r,returns:"either"})}function br(){return mr(t.function.pipe(S(),O))}const nt=br(),_r=l(nt);function gr({postEvent:s,version:r,...n}){return q(i=>{const u=i.toString();return u.match(/^https:\/\/t.me\/.+/)?h.supports("web_app_open_tg_link",j(r))?(i=new URL(i),s("web_app_open_tg_link",{path_full:i.pathname+i.search})):(window.location.href=u,t.either.right(void 0)):t.either.left(new U(`"${u}" is invalid URL`))},{...n,returns:"either"})}function Fr(){return gr(t.function.pipe(S(),O,y))}const Se=Fr(),Cr=l(Se);function wr({openTelegramLink:s,...r}){return q((n,i)=>s("https://t.me/share/url?"+new URLSearchParams({url:n,text:i||""}).toString().replace(/\+/g,"%20")),{...r,returns:"either"})}function Sr(){return wr({...S(),openTelegramLink:Se})}const it=Sr(),kr=l(it);function Er(s){let r=!1,n,i;return s.available&&(r=!0,n=s.access_requested,i=s.access_granted),{available:r,accessGranted:i||!1,accessRequested:n||!1}}class ot{constructor({version:r,request:n,postEvent:i,storage:u,isTma:a,isPageReload:c}){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 o=new z({initialState:{available:!1,accessGranted:!1,accessRequested:!1},onChange:u.set}),p=new Fe({isPageReload:c,restoreState:u.get,onMounted:o.setState,initialState(C){return t.function.pipe(n("web_app_check_location","location_checked",C),t.taskEither.map(Er))}}),m={version:r,requires:"web_app_check_location",isTma:a},F=I({...m,returns:"either"}),f=I({...m,returns:"task"}),w=I({...m,returns:"task",isMounted:p.isMounted});this.isAvailable=o.getter("available"),this.isAccessRequested=o.getter("accessRequested"),this.isAccessGranted=o.getter("accessGranted"),this.isSupported=W("web_app_check_location",r),this.isMounted=p.isMounted,this.state=o.state,this.unmount=p.unmount,this.mountFp=f(p.mount),this.openSettingsFp=F(()=>i("web_app_open_location_settings")),this.requestLocationFp=w(C=>t.function.pipe(n("web_app_request_location","location_requested",C),t.taskEither.map(k=>{if(!k.available)return o.setState({available:!1}),null;const{available:E,...b}=k;return b}))),this.mount=l(this.mountFp),this.openSettings=l(this.openSettingsFp),this.requestLocation=l(this.requestLocationFp)}}function yr(){return new ot(t.function.pipe(S(),O,y,L,N("locationManager")))}const vr=yr();class at{constructor({defaults:r,...n}){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 i=new ue({...n,version:"100",initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"},method:"web_app_setup_main_button",payload:a=>({has_shine_effect:a.hasShineEffect,is_visible:a.isVisible,is_active:a.isEnabled,is_progress_visible:a.isLoaderVisible,text:a.text,color:a.bgColor,text_color:a.textColor})}),u=(a,c)=>{const o=i.stateGetter(a);return _.computed(()=>o()||j(c))};this.bgColor=u("bgColor",r.bgColor),this.textColor=u("textColor",r.textColor),this.hasShineEffect=i.stateGetter("hasShineEffect"),this.isEnabled=i.stateGetter("isEnabled"),this.isLoaderVisible=i.stateGetter("isLoaderVisible"),this.text=i.stateGetter("text"),this.isVisible=i.stateGetter("isVisible"),this.isMounted=i.isMounted,this.state=i.state,[this.setBgColor,this.setBgColorFp]=i.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=i.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=i.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=i.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=i.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=i.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=i.stateBoolSetters("isVisible"),this.setParams=i.setState,this.setParamsFp=i.setStateFp,this.onClick=i.onClick,this.onClickFp=i.onClickFp,this.offClick=i.offClick,this.offClickFp=i.offClickFp,this.mount=i.mount,this.mountFp=i.mountFp,this.unmount=i.unmount}}function ke(s,r){document.documentElement.style.setProperty(s,r)}function Ee(s){document.documentElement.style.removeProperty(s)}function ut(s){return t.function.pipe(A.toRGBFullFp(s),t.either.map(r=>Math.sqrt([.299,.587,.114].reduce((n,i,u)=>{const a=parseInt(r.slice(1+u*2,1+(u+1)*2),16);return n+a*a*i},0))<120))}const ye=x.throwifyFpFn(ut);class ct{constructor({initialState:r,onChange:n,offChange:i,isTma:u,storage:a,isPageReload:c}){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 r=this.bgColor();return!r||ye(r)}));e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");const o=new z({initialState:{},onChange:a.set}),p=C=>{o.setState(C.theme_params)},m=new re({initialState:()=>t.either.right(j(r)),isPageReload:c,onMounted(C){o.setState(C),n(p)},onUnmounted(){i(p)},restoreState:a.get}),F={isTma:u,returns:"either"},f=I(F),w=I({...F,isMounted:m.isMounted});this.accentTextColor=o.getter("accent_text_color"),this.bgColor=o.getter("bg_color"),this.buttonColor=o.getter("button_color"),this.buttonTextColor=o.getter("button_text_color"),this.bottomBarBgColor=o.getter("bottom_bar_bg_color"),this.destructiveTextColor=o.getter("destructive_text_color"),this.headerBgColor=o.getter("header_bg_color"),this.hintColor=o.getter("hint_color"),this.linkColor=o.getter("link_color"),this.secondaryBgColor=o.getter("secondary_bg_color"),this.sectionBgColor=o.getter("section_bg_color"),this.sectionHeaderTextColor=o.getter("section_header_text_color"),this.sectionSeparatorColor=o.getter("section_separator_color"),this.subtitleTextColor=o.getter("subtitle_text_color"),this.textColor=o.getter("text_color"),this.state=o.state,this.isMounted=m.isMounted,this.bindCssVarsFp=w(C=>{if(this._isCssVarsBound())return t.either.left(new oe);C||(C=b=>`--tg-theme-${x.snakeToKebab(b)}`);const k=b=>{Object.entries(o.state()).forEach(([g,d])=>{d&&b(g,d)})},E=()=>{k((b,g)=>{ke(C(b),g)})};return E(),o.state.sub(E),this._isCssVarsBound.set(!0),t.either.right(()=>{k(Ee),o.state.unsub(E),this._isCssVarsBound.set(!1)})}),this.mountFp=f(m.mount),this.unmount=m.unmount,this.bindCssVars=l(this.bindCssVarsFp),this.mount=l(this.mountFp)}}const me=se({});function Ir(){return new ct({...t.function.pipe(S(),N("themeParams")),offChange(s){h.off("theme_changed",s)},onChange(s){h.on("theme_changed",s)},initialState:me})}const te=Ir();function pt(s,r,n){return t.function.pipe(ge(s,r),i=>({...i,defaults:n}))}const Br=new at(pt("mainButton","main_button_pressed",{bgColor:_.computed(()=>te.buttonColor()||"#2481cc"),textColor:_.computed(()=>te.buttonTextColor()||"#ffffff")}));class lt{constructor({storage:r,isPageReload:n,version:i,postEvent:u,isTma:a,theme:c,onVisibilityChanged:o,offVisibilityChanged:p}){e(this,"isSupported");e(this,"isDark",_.computed(()=>{const r=this.bgColorRgb();return r?ye(r):!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 m=d=>{w.setState({isActive:d.is_visible})},F=d=>{[[this.headerColor,"web_app_set_header_color"],[this.bgColor,"web_app_set_background_color"],[this.bottomBarColor,"web_app_set_bottom_bar_color"]].forEach(([P,V])=>{const T=P();if(!A.isRGB(T)&&(V!=="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes(T))){const D=d[T];D&&u(V,{color:D})}})},f=new re({initialState(){return t.either.right({bgColor:"bg_color",headerColor:"header_bg_color",bottomBarColor:"bottom_bar_bg_color",isActive:!0})},isPageReload:n,onMounted:d=>{o(m),c.sub(F),w.setState(d)},onUnmounted(){p(m),c.unsub(F)},restoreState:r.get});this.isMounted=f.isMounted,this.mountFp=q(()=>{const d=()=>{};return t.function.pipe(f.mount(),t.either.match(d,d))},{isTma:a,returns:"plain"}),this.mount=l(this.mountFp),this.unmount=f.unmount;const w=new z({initialState:{bgColor:"bg_color",bottomBarColor:"bottom_bar_bg_color",headerColor:"bg_color",isActive:!1},onChange:r.set});this.state=w.state;const C=d=>A.isRGB(d)?d:j(c)[d],k=d=>_.computed(()=>C(d()));this.isActive=w.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,j(i))));const E=_.signal(!1);this.isCssVarsBound=_.computed(E),this.bindCssVarsFp=q(d=>{if(E())return t.either.left(new oe);const[P,V]=x.createCbCollector(()=>{E.set(!1)}),T=(D,R)=>{const H=()=>{ke(D,R()||null)};H(),P(R.sub(H),Ee.bind(null,D))};return d||(d=D=>`--tg-${x.camelToKebab(D)}`),T(d("bgColor"),this.bgColorRgb),T(d("bottomBarColor"),this.bottomBarColorRgb),T(d("headerColor"),this.headerColorRgb),E.set(!0),t.either.right(V)},{isTma:a,returns:"either",isMounted:this.isMounted}),this.bindCssVars=l(this.bindCssVarsFp);const b=d=>{const P=w.getter(d),V=k(P),T={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[d],D=q(R=>{if(R===P())return t.either.right(void 0);if(T==="web_app_set_header_color"&&(R==="bg_color"||R==="secondary_bg_color"))return t.function.pipe(u("web_app_set_header_color",{color_key:R}),t.either.map(()=>{w.setState({[d]:R})}));const H=C(R);return t.function.pipe(H?u(T,{color:H}):t.either.left(new $e(R)),t.either.map(()=>{w.setState({[d]:R})}))},{isTma:a,version:i,requires:T,isMounted:this.isMounted,returns:"either",supports:d==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:A.isRGB}}:void 0});return[P,V,l(D),D]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=b("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=b("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=b("bottomBarColor");const g=I({isTma:a,returns:"either"});this.closeFp=g(d=>u("web_app_close",{return_back:d})),this.close=l(this.closeFp),this.readyFp=g(()=>u("web_app_ready")),this.ready=l(this.readyFp)}}function qr(){return new lt({...t.function.pipe(S(),O,y,N("miniApp")),offVisibilityChanged(s){h.off("visibility_changed",s)},onVisibilityChanged(s){h.on("visibility_changed",s)},theme:te.state})}const ht=qr();function Ar(s){const r=s.message.trim(),n=(s.title||"").trim(),i=s.buttons||[];if(n.length>64)return t.either.left(new U(`Invalid title: ${n}`));if(!r||r.length>256)return t.either.left(new U(`Invalid message: ${r}`));if(i.length>3)return t.either.left(new U(`Invalid buttons count: ${i.length}`));const u=[];if(!i.length)u.push({type:"close",id:""});else for(let a=0;a<i.length;a++){const c=i[a],o=c.id||"";if(o.length>64)return t.either.left(new U(`Button with index ${a} has invalid id: ${o}`));if(!c.type||c.type==="default"||c.type==="destructive"){const p=c.text.trim();if(!p||p.length>64)return t.either.left(new U(`Button with index ${a} has invalid text: ${p}`));u.push({type:c.type,text:p,id:o})}else u.push({type:c.type,id:o})}return t.either.right({title:n,message:r,buttons:u})}class dt{constructor({version:r,isTma:n,request:i}){e(this,"isOpened");e(this,"isSupported");e(this,"showFp");e(this,"show");const u=_.signal(!1),a=()=>{u.set(!1)},c=I({version:r,isTma:n,requires:"web_app_open_popup",returns:"task"});this.isSupported=W("web_app_open_popup",r),this.isOpened=_.computed(u),this.showFp=c(o=>t.function.pipe(this.isOpened()?t.taskEither.left(new ae("A popup is already opened")):t.taskEither.right(void 0),t.taskEither.chainW(()=>t.taskEither.fromEither(Ar(o))),t.taskEither.chain(p=>(u.set(!0),i("web_app_open_popup","popup_closed",{...o,params:p}))),t.taskEither.mapBoth(p=>(a(),p),p=>(a(),p.button_id)))),this.show=l(this.showFp)}}function Pr(){return new dt(t.function.pipe(S(),L,y))}const Mr=Pr();function xr({request:s,...r}){return q(n=>t.function.pipe(s("web_app_request_phone","phone_requested",n),t.taskEither.map(i=>i.status)),{...r,requires:"web_app_request_phone",returns:"task"})}function Tr(){return xr(t.function.pipe(S(),y,L))}const ve=Tr(),Or=l(ve);function Vr({invokeCustomMethod:s,requestPhoneAccess:r,...n}){const i=c=>t.function.pipe(s("getRequestedContact",{},{...c,timeout:(c||{}).timeout||5e3}),t.taskEither.chainW(o=>{const p=v.safeParse(v.string(),o);if(!p.success)return t.taskEither.left(new ee(o,p.issues));if(!p.output)return t.taskEither.right(void 0);const m=v.safeParse(A.pipeQueryToSchema(v.looseObject({contact:A.pipeJsonToSchema(v.looseObject({user_id:v.number(),phone_number:v.string(),first_name:v.string(),last_name:v.optional(v.string())})),auth_date:v.pipe(v.string(),v.transform(F=>new Date(Number(F)*1e3)),v.date()),hash:v.string()})),p.output);return m.success?t.taskEither.right({raw:p.output,parsed:m.output}):t.taskEither.left(new ee(p.output,m.issues))})),u=c=>t.function.pipe(i(c),t.taskEither.match(o=>ee.is(o)?t.either.left(o):t.either.right(void 0),o=>t.either.right(o))),a=c=>x.BetterTaskEither(async(o,p,m)=>{let F=50;for(;!m.isRejected;){const f=await u(m)();if(f._tag==="Left")return p(f.left);if(f.right)return o(f.right);await new Promise(w=>setTimeout(w,F)),F+=50}},c);return q(c=>x.BetterTaskEither.fn(o=>t.function.pipe(u(o),t.taskEither.chain(p=>p?t.taskEither.right(p):t.function.pipe(r(o),t.taskEither.chainW(m=>m==="sent"?a(o):t.taskEither.left(new _e("User denied access")))))),c),{...n,returns:"task",requires:"web_app_request_phone"})}function Lr(){return Vr({...t.function.pipe(S(),we,y),requestPhoneAccess:ve})}function Rr({requestContact:s,...r}){return q(s,{...r,returns:"task",requires:"web_app_request_phone"})}function jr(){return Rr({...t.function.pipe(S(),y),requestContact(s){return t.function.pipe(Ie(s),t.taskEither.map(r=>r.parsed))}})}const Ie=Lr(),$r=l(Ie),ft=jr(),Dr=l(ft);function Gr({request:s,...r}){return q(n=>t.function.pipe(s("web_app_request_write_access","write_access_requested",n),t.taskEither.map(i=>i.status)),{...r,requires:"web_app_request_write_access",returns:"task"})}function Ur(){return Gr(t.function.pipe(S(),y,L))}const mt=Ur(),Hr=l(mt);class bt{constructor({version:r,onClosed:n,onTextReceived:i,isTma:u,postEvent:a}){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 c={version:r,requires:"web_app_open_scan_qr_popup",isTma:u},o=I({...c,returns:"either"}),p=I({...c,returns:"task"}),m=_.signal(!1),F=()=>{m.set(!1)};this.isSupported=W("web_app_open_scan_qr_popup",r),this.isOpened=_.computed(m),this.captureFp=p(f=>{let w;return t.function.pipe(this.openFp({...f,onCaptured:C=>{f.capture(C)&&(w=C,this.close())}}),t.taskEither.map(()=>w))}),this.closeFp=o(()=>t.function.pipe(a("web_app_close_scan_qr_popup"),t.either.map(F))),this.openFp=p(f=>t.function.pipe(m()?t.taskEither.left(new ae("The QR Scanner is already opened")):async()=>a("web_app_open_scan_qr_popup",{text:f.text}),t.taskEither.chainW(()=>{m.set(!0);const[w,C]=x.createCbCollector(),k=E=>(C(),m.set(!1),E);return t.function.pipe(x.BetterTaskEither(E=>{w(n(E),m.sub(b=>{b||E()}),i(f.onCaptured))},f),t.taskEither.mapBoth(k,k))}))),this.open=l(this.openFp),this.capture=l(this.captureFp),this.close=l(this.closeFp)}}function Wr(){return new bt({...t.function.pipe(S(),O,y),onClosed(s){return h.on("scan_qr_popup_closed",s)},onTextReceived(s){return h.on("qr_text_received",r=>{s(r.data)})}})}const Qr=Wr();class _t{constructor({defaults:r,...n}){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 i=new ue({...n,initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Cancel",position:"left"},method:"web_app_setup_secondary_button",payload:a=>({has_shine_effect:a.hasShineEffect,is_visible:a.isVisible,is_active:a.isEnabled,is_progress_visible:a.isLoaderVisible,text:a.text,color:a.bgColor,text_color:a.textColor,position:a.position})}),u=(a,c)=>{const o=i.stateGetter(a);return _.computed(()=>o()||j(c))};this.isSupported=W("web_app_setup_secondary_button",n.version),this.bgColor=u("bgColor",r.bgColor),this.textColor=u("textColor",r.textColor),this.position=i.stateGetter("position"),this.hasShineEffect=i.stateGetter("hasShineEffect"),this.isEnabled=i.stateGetter("isEnabled"),this.isLoaderVisible=i.stateGetter("isLoaderVisible"),this.text=i.stateGetter("text"),this.isVisible=i.stateGetter("isVisible"),this.isMounted=i.isMounted,this.state=i.state,[this.setPosition,this.setPositionFp]=i.stateSetters("position"),[this.setBgColor,this.setBgColorFp]=i.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=i.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=i.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=i.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=i.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=i.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=i.stateBoolSetters("isVisible"),this.setParams=i.setState,this.setParamsFp=i.setStateFp,this.onClick=i.onClick,this.onClickFp=i.onClickFp,this.offClick=i.offClick,this.offClickFp=i.offClickFp,this.mount=i.mount,this.mountFp=i.mountFp,this.unmount=i.unmount}}function Kr(){return new _t(pt("secondaryButton","secondary_button_pressed",{bgColor:_.computed(()=>ht.bottomBarColorRgb()||"#000000"),textColor:_.computed(()=>te.buttonColor()||"#2481cc")}))}const zr=Kr();class gt{constructor({isTma:r,request:n,version:i,createRequestId:u}){e(this,"getItemFp");e(this,"getItem");e(this,"restoreItemFp");e(this,"restoreItem");e(this,"setItemFp");e(this,"setItem");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"clearFp");e(this,"clear");const a=I({version:i,requires:"web_app_secure_storage_get_key",isTma:r,returns:"task"}),c=(o,p,m)=>{const F=u();return t.function.pipe(n(o,["secure_storage_failed",p],{params:{...m,req_id:F},capture:f=>"payload"in f?f.payload.req_id===F:!0}),t.taskEither.chain(f=>f.event==="secure_storage_failed"?t.taskEither.left(new Te(f.payload.error||"UNKNOWN_ERROR")):t.taskEither.right(f.payload)))};this.getItemFp=a(o=>t.function.pipe(c("web_app_secure_storage_get_key","secure_storage_key_received",{key:o}),t.taskEither.map(p=>({value:p.value,canRestore:!!p.can_restore})))),this.setItemFp=a((o,p)=>t.function.pipe(c("web_app_secure_storage_save_key","secure_storage_key_saved",{key:o,value:p}),t.taskEither.map(()=>{}))),this.deleteItemFp=a(o=>this.setItemFp(o,null)),this.clearFp=a(()=>t.function.pipe(c("web_app_secure_storage_clear","secure_storage_cleared",{}),t.taskEither.map(()=>{}))),this.restoreItemFp=a(o=>t.function.pipe(c("web_app_secure_storage_restore_key","secure_storage_key_restored",{key:o}),t.taskEither.map(p=>p.value))),this.getItem=l(this.getItemFp),this.setItem=l(this.setItemFp),this.deleteItem=l(this.deleteItemFp),this.clear=l(this.clearFp),this.restoreItem=l(this.restoreItemFp)}}function Nr(){return new gt(t.function.pipe(S(),y,L,Je))}const Jr=Nr();class Ft{constructor(r){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 n=new ue({...r,method:"web_app_setup_settings_button",payload:i=>({is_visible:i.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}const Yr=new Ft(ge("settingsButton","settings_button_pressed"));class Ct{constructor({postEvent:r,storage:n,isTma:i,isPageReload:u,version:a}){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 c={isVerticalEnabled:!0},o=new z({initialState:c,onChange(C){n.set(C)}}),p=new re({initialState:c,isPageReload:u,onMounted:o.setState,restoreState:n.get}),m={requires:"web_app_setup_swipe_behavior",isTma:i,version:a},F=I({...m,returns:"plain"}),f=I({...m,isMounted:p.isMounted,returns:"either"}),w=C=>{const k={isVerticalEnabled:C};return o.hasDiff(k)?t.function.pipe(r("web_app_setup_swipe_behavior",{allow_vertical_swipe:C}),t.either.map(()=>{o.setState(k)})):t.either.right(void 0)};this.isSupported=W("web_app_setup_swipe_behavior",a),this.isVerticalEnabled=o.getter("isVerticalEnabled"),this.isMounted=p.isMounted,this.disableVerticalFp=f(()=>w(!1)),this.enableVerticalFp=f(()=>w(!0)),this.mountFp=F(()=>{const C=()=>{};return t.function.pipe(p.mount(),t.either.match(C,C))}),this.unmount=p.unmount,this.disableVertical=l(this.disableVerticalFp),this.enableVertical=l(this.enableVerticalFp),this.mount=l(this.mountFp)}}function Zr(){return new Ct(t.function.pipe(S(),O,y,N("swipeBehavior")))}const Xr=Zr();async function es(s){try{const{clipboard:n}=navigator;if(n)return await n.writeText(s)}catch{}const r=document.createElement("textarea");r.value=s,r.style.top="0",r.style.left="0",r.style.position="fixed",document.body.appendChild(r),r.focus(),r.select();try{document.execCommand("copy")}finally{document.body.removeChild(r)}}function ts({request:s,...r}){return q((n,i,u)=>t.function.pipe(s("web_app_request_file_download","file_download_requested",{...u,params:{url:n,file_name:i}}),t.taskEither.chain(a=>a.status==="downloading"?t.taskEither.right(void 0):t.taskEither.left(new _e("User denied the action")))),{...r,requires:"web_app_request_file_download",returns:"task"})}function rs(){return ts(t.function.pipe(S(),L,y))}const wt=rs(),ss=l(wt);function ns({invokeCustomMethod:s,...r}){return q(n=>t.function.pipe(s("getCurrentTime",{},n),t.taskEither.chain(i=>{const u=v.safeParse(v.pipe(v.number(),v.integer(),v.transform(a=>new Date(a*1e3)),v.date()),i);return u.success?t.taskEither.right(u.output):t.taskEither.left(new ee(i,u.issues))})),{...r,requires:"web_app_invoke_custom_method",returns:"task"})}function is(){return ns(t.function.pipe(S(),we,y))}const St=is(),os=l(St);function as({postEvent:s,...r}){return q(()=>s("web_app_hide_keyboard"),{...r,returns:"either",requires:"web_app_hide_keyboard"})}function us(){return as(t.function.pipe(S(),O,y))}const kt=us(),cs=l(kt);function ps({request:s,createRequestId:r,...n}){return q(i=>{const u=r();return t.function.pipe(s("web_app_read_text_from_clipboard","clipboard_text_received",{...i,params:{req_id:u},capture:h.captureSameReq(u)}),t.taskEither.map(({data:a=null})=>a))},{...n,requires:"web_app_read_text_from_clipboard",returns:"task"})}function ls(){return ps({...t.function.pipe(S(),y,L),createRequestId:ce})}const Et=ls(),hs=l(Et);function yt(s){const r={},n=s.match(/Telegram-Android(?:\/([^ ]+))?(?: (\([^)]+\))?|$)/);if(n){const[,i,u]=n;i&&(r.appVersion=i),u&&u.slice(1,u.length-1).split(";").forEach(a=>{const[c,o]=a.trim().split(" ");if(c==="Android")r.androidVersion=o;else if(c==="SDK"){const p=parseInt(o,10);p&&(r.sdkVersion=p)}else o?(r.manufacturer=c,r.model=o):r.performanceClass=c})}return r}function ds(){return yt(navigator.userAgent)}function fs({postEvent:s,...r}){return q(n=>{const{size:i}=new Blob([n]);return!i||i>4096?t.either.left(new U(i?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data")):s("web_app_data_send",{data:n})},{...r,returns:"either"})}function ms(){return fs(t.function.pipe(S(),O))}const vt=ms(),bs=l(vt);function _s({request:s,...r}){return q((n,i)=>t.function.pipe(s("web_app_send_prepared_message",["prepared_message_failed","prepared_message_sent"],{...i,params:{id:n}}),t.taskEither.chain(u=>u.event==="prepared_message_failed"?t.taskEither.left(new je(u.payload.error)):t.taskEither.right(void 0))),{...r,requires:"web_app_send_prepared_message",returns:"task"})}function gs(){return _s(t.function.pipe(S(),L,y))}const It=gs(),Fs=l(It);function Cs({postEvent:s,...r}){return q((n,i={})=>s("web_app_share_to_story",{text:i.text,media_url:n,widget_link:i.widgetLink}),{...r,requires:"web_app_share_to_story",returns:"either"})}function ws(){return Cs(t.function.pipe(S(),O,y))}const Bt=ws(),Ss=l(Bt),be=se(!1);function ks({isInlineMode:s,postEvent:r,...n}){return q((i,u)=>r("web_app_switch_inline_query",{query:i,chat_types:u||[]}),{...n,requires:{every:["web_app_switch_inline_query",()=>j(s)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}function Es(){return ks({...t.function.pipe(S(),O,y),isInlineMode:be})}const qt=Es(),ys=l(qt);class At{constructor({storage:r,isPageReload:n,onContentSafeAreaInsetsChanged:i,onSafeAreaInsetsChanged:u,onViewportChanged:a,onFullscreenChanged:c,offContentSafeAreaInsetsChanged:o,offFullscreenChanged:p,offSafeAreaInsetsChanged:m,offViewportChanged:F,request:f,isViewportStable:w,isFullscreen:C,isTma:k,version:E,postEvent:b}){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 g={top:0,right:0,left:0,bottom:0},d=new z({initialState:{contentSafeAreaInsets:g,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:g,stableHeight:0,width:0},onChange:r.set}),P=B=>{d.setState({isExpanded:B.is_expanded,height:B.height,width:B.width,stableHeight:B.is_state_stable?B.height:void 0})},V=B=>{d.setState({isFullscreen:B.is_fullscreen})},T=B=>{d.setState({safeAreaInsets:B})},D=B=>{d.setState({contentSafeAreaInsets:B})},R=new Fe({initialState(B){const J=Q=>()=>{const[K,G]=Q==="safe-area"?["web_app_request_safe_area","safe_area_changed"]:["web_app_request_content_safe_area","content_safe_area_changed"];return h.supports(K,j(E))?f(K,G,B):t.taskEither.right({top:0,left:0,right:0,bottom:0})},M=Q=>()=>typeof Q=="boolean"?t.taskEither.right(Q):t.taskEither.fromEither(Q());return t.function.pipe(t.taskEither.Do,t.taskEither.bindW("safeAreaInsets",J("safe-area")),t.taskEither.bindW("contentSafeAreaInsets",J("content-safe-area")),t.taskEither.bindW("isFullscreen",M(C)),t.taskEither.bindW("isViewportStable",M(w)),t.taskEither.chainW(({isViewportStable:Q,...K})=>Q?t.taskEither.right({...K,height:window.innerHeight,isExpanded:!0,stableHeight:window.innerHeight,width:window.innerWidth}):t.function.pipe(f("web_app_request_viewport","viewport_changed",B),t.taskEither.map(G=>({...K,height:G.height,isExpanded:G.is_expanded,stableHeight:G.is_state_stable?G.height:0,width:G.width})))))},isPageReload:n,onMounted(B){a(P),c(V),u(T),i(D),d.setState(B)},onUnmounted(){F(P),p(V),m(T),o(D)},restoreState:r.get}),H=B=>_.computed(()=>this.safeAreaInsets()[B]),ne=B=>_.computed(()=>this.contentSafeAreaInsets()[B]);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=H("top"),this.safeAreaInsetBottom=H("bottom"),this.safeAreaInsetLeft=H("left"),this.safeAreaInsetRight=H("right"),this.contentSafeAreaInsets=d.getter("contentSafeAreaInsets"),this.contentSafeAreaInsetTop=ne("top"),this.contentSafeAreaInsetBottom=ne("bottom"),this.contentSafeAreaInsetLeft=ne("left"),this.contentSafeAreaInsetRight=ne("right");const Mt=I({isTma:k,returns:"task"}),Be=I({isTma:k,returns:"either"}),xt=I({isTma:k,requires:"web_app_request_fullscreen",version:E,returns:"task"}),qe=B=>xt(J=>t.function.pipe(f(B?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],J),t.taskEither.chain(M=>M.event==="fullscreen_failed"&&M.payload.error!=="ALREADY_FULLSCREEN"?t.taskEither.left(new Re(M.payload.error)):(d.setState({isFullscreen:"is_fullscreen"in M.payload?M.payload.is_fullscreen:!0}),t.taskEither.right(void 0)))));this.isMounted=R.isMounted,this.mountFp=Mt(R.mount),this.mount=l(this.mountFp),this.isFullscreen=d.getter("isFullscreen"),this.requestFullscreenFp=qe(!0),this.requestFullscreen=l(this.requestFullscreenFp),this.exitFullscreenFp=qe(!1),this.exitFullscreen=l(this.exitFullscreenFp);const ie=_.signal(!1);this.isCssVarsBound=_.computed(ie),this.bindCssVarsFp=Be(B=>{if(ie())return t.either.left(new oe);B||(B=M=>`--tg-viewport-${x.camelToKebab(M)}`);const J=[["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((M,[Q,K])=>{const G=B(Q);if(G){const Ae=()=>{ke(G,`${K()}px`)};M.push({update:Ae,removeListener:K.sub(Ae),cssVar:G})}return M},[]);return J.forEach(M=>{M.update()}),ie.set(!0),t.either.right(()=>{J.forEach(M=>{M.removeListener(),Ee(M.cssVar)}),ie.set(!1)})}),this.bindCssVars=l(this.bindCssVarsFp),this.expandFp=Be(()=>b("web_app_expand")),this.expand=l(this.expandFp)}}function vs(){const s=a=>({on:c=>{h.on(a,c)},off:c=>{h.off(a,c)}}),r=s("viewport_changed"),n=s("fullscreen_changed"),i=s("safe_area_changed"),u=s("content_safe_area_changed");return new At({...t.function.pipe(S(),N("viewport"),y,O,L),isFullscreen(){return t.function.pipe(h.retrieveLaunchParamsFp(),t.either.map(a=>!!a.tgWebAppFullscreen))},isViewportStable(){return t.function.pipe(h.retrieveLaunchParamsFp(),t.either.map(a=>["macos","tdesktop","unigram","webk","weba","web"].includes(a.tgWebAppPlatform)))},offContentSafeAreaInsetsChanged:u.off,offFullscreenChanged:n.off,offSafeAreaInsetsChanged:i.off,offViewportChanged:r.off,onContentSafeAreaInsetsChanged:u.on,onFullscreenChanged:n.on,onSafeAreaInsetsChanged:i.on,onViewportChanged:r.on})}const Is=vs();function Pt(s={}){const{version:r,isInlineMode:n,themeParams:i}=s;if(r&&typeof n=="boolean"&&i)fe.set(r),be.set(n),me.set(i);else{const o=t.function.pipe(h.retrieveLaunchParamsFp(),t.either.matchW(p=>p,p=>{fe.set(r||p.tgWebAppVersion),be.set(typeof n=="boolean"?n:!!p.tgWebAppBotInline),me.set(i||p.tgWebAppThemeParams)}));if(o)return t.either.left(o)}s.postEvent&&Ge.set(s.postEvent);const[u,a]=x.createCbCollector(h.on("reload_iframe",()=>{h.logger().log("Received a request to reload the page"),Ue("iframe_will_reload"),window.location.reload()})),{acceptCustomStyles:c=!0}=s;if(c){const o=document.createElement("style");o.id="telegram-custom-styles",document.head.appendChild(o),u(h.on("set_custom_style",p=>{o.innerHTML=p}),()=>{document.head.removeChild(o)})}return t.function.pipe(Z("iframe_ready",{reload_supported:!0}),t.either.map(()=>(h.logger().log("The package was initialized"),a)))}const Bs=x.throwifyFpFn(Pt);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:()=>A.isAnyRGB});Object.defineProperty(exports,"isRGB",{enumerable:!0,get:()=>A.isRGB});Object.defineProperty(exports,"isRGBA",{enumerable:!0,get:()=>A.isRGBA});Object.defineProperty(exports,"isRGBAShort",{enumerable:!0,get:()=>A.isRGBAShort});Object.defineProperty(exports,"isRGBShort",{enumerable:!0,get:()=>A.isRGBShort});Object.defineProperty(exports,"parseInitDataQuery",{enumerable:!0,get:()=>A.parseInitDataQuery});Object.defineProperty(exports,"parseInitDataQueryFp",{enumerable:!0,get:()=>A.parseInitDataQueryFp});Object.defineProperty(exports,"parseLaunchParamsQuery",{enumerable:!0,get:()=>A.parseLaunchParamsQuery});Object.defineProperty(exports,"parseLaunchParamsQueryFp",{enumerable:!0,get:()=>A.parseLaunchParamsQueryFp});Object.defineProperty(exports,"serializeInitDataQuery",{enumerable:!0,get:()=>A.serializeInitDataQuery});Object.defineProperty(exports,"serializeLaunchParamsQuery",{enumerable:!0,get:()=>A.serializeLaunchParamsQuery});Object.defineProperty(exports,"toRGB",{enumerable:!0,get:()=>A.toRGB});Object.defineProperty(exports,"toRGBFp",{enumerable:!0,get:()=>A.toRGBFp});Object.defineProperty(exports,"toRGBFull",{enumerable:!0,get:()=>A.toRGBFull});Object.defineProperty(exports,"toRGBFullFp",{enumerable:!0,get:()=>A.toRGBFullFp});exports.AccessDeniedError=_e;exports.BackButton=De;exports.Biometry=He;exports.CSSVarsBoundError=oe;exports.ClosingBehavior=Qe;exports.CloudStorage=Ke;exports.ConcurrentCallError=ae;exports.DeviceStorage=Ne;exports.DeviceStorageMethodError=xe;exports.FullscreenFailedError=Re;exports.FunctionUnavailableError=Ve;exports.HapticFeedback=Xe;exports.InitData=rt;exports.InvalidArgumentsError=U;exports.InvalidEnvError=Vt;exports.Invoice=st;exports.LocationManager=ot;exports.MainButton=at;exports.MiniApp=lt;exports.NotAvailableError=Oe;exports.Popup=dt;exports.QrScanner=bt;exports.SecondaryButton=_t;exports.SecureStorage=gt;exports.SecureStorageMethodError=Te;exports.SetEmojiStatusError=Le;exports.SettingsButton=Ft;exports.ShareMessageError=je;exports.SwipeBehavior=Ct;exports.ThemeParams=ct;exports.UnknownThemeParamsKeyError=$e;exports.ValidationError=ee;exports.Viewport=At;exports.addToHomeScreen=ar;exports.addToHomeScreenFp=et;exports.backButton=$t;exports.biometry=Ht;exports.checkHomeScreenStatus=pr;exports.checkHomeScreenStatusFp=tt;exports.closingBehavior=Qt;exports.cloudStorage=zt;exports.copyTextToClipboard=es;exports.createRequestId=ce;exports.deviceStorage=Jt;exports.downloadFile=ss;exports.downloadFileFp=wt;exports.getCurrentTime=os;exports.getCurrentTimeFp=St;exports.hapticFeedback=nr;exports.hideKeyboard=cs;exports.hideKeyboardFp=kt;exports.init=Bs;exports.initData=hr;exports.initFp=Pt;exports.invoice=fr;exports.invokeCustomMethod=ze;exports.isColorDark=ye;exports.isColorDarkFp=ut;exports.locationManager=vr;exports.mainButton=Br;exports.miniApp=ht;exports.openLink=_r;exports.openLinkFp=nt;exports.openTelegramLink=Cr;exports.openTelegramLinkFp=Se;exports.popup=Mr;exports.postEvent=Ue;exports.postEventFp=Z;exports.qrScanner=Qr;exports.readTextFromClipboard=hs;exports.readTextFromClipboardFp=Et;exports.request=Dt;exports.request2=Gt;exports.request2Fp=Ce;exports.requestContact=Dr;exports.requestContactComplete=$r;exports.requestContactCompleteFp=Ie;exports.requestContactFp=ft;exports.requestEmojiStatusAccess=Xt;exports.requestEmojiStatusAccessFp=Ye;exports.requestFp=We;exports.requestPhoneAccess=Or;exports.requestPhoneAccessFp=ve;exports.requestWriteAccess=Hr;exports.requestWriteAccessFp=mt;exports.retrieveAndroidDeviceData=ds;exports.retrieveAndroidDeviceDataFrom=yt;exports.secondaryButton=zr;exports.secureStorage=Jr;exports.sendData=bs;exports.sendDataFp=vt;exports.setEmojiStatus=rr;exports.setEmojiStatusFp=Ze;exports.settingsButton=Yr;exports.shareMessage=Fs;exports.shareMessageFp=It;exports.shareStory=Ss;exports.shareStoryFp=Bt;exports.shareURL=kr;exports.shareURLFp=it;exports.swipeBehavior=Xr;exports.switchInlineQuery=ys;exports.switchInlineQueryFp=qt;exports.themeParams=te;exports.viewport=Is;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|