@tma.js/sdk 3.0.2 → 3.0.4

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.
@@ -1,4 +1,4 @@
1
- var cc=Object.defineProperty;var lc=(p,oe,we)=>oe in p?cc(p,oe,{enumerable:!0,configurable:!0,writable:!0,value:we}):p[oe]=we;var o=(p,oe,we)=>lc(p,typeof oe!="symbol"?oe+"":oe,we);this.tmajs=this.tmajs||{};this.tmajs.sdk=function(p){"use strict";var oe=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function we(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function d(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Ve=function(e,t){var n=typeof e=="number"?function(r){return r.length>=e}:e;return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,oe([i],r,!1))}}},Js={_tag:"None"},Qs=function(e){return{_tag:"Some",value:e}},Zs=function(e){return e._tag==="Left"},kn=function(e){return{_tag:"Left",left:e}},En=function(e){return{_tag:"Right",right:e}},_t={};function Ys(e,t){return function(n){return function(r){return e.ap(e.map(r,function(i){return function(s){return t.ap(i,s)}}),n)}}}function Xs(e,t){return function(n){return function(r){return e.map(r,function(i){return t.map(i,n)})}}}function mt(e){return function(t,n){return function(r){return e.chain(r,function(i){return e.map(n(i),function(s){var a;return Object.assign({},i,(a={},a[t]=s,a))})})}}}var O=kn,P=En,ei=Ve(2,function(e,t){return ye(e)?e:t(e.right)}),bt=function(e,t){return d(e,Z(t))},$n=function(e,t){return d(e,si(t))},gt="Either",Z=function(e){return function(t){return ye(t)?t:P(e(t.right))}},ti={URI:gt,map:bt},ni=P,ri=function(e){return function(t){return ye(t)?t:ye(e)?e:P(t.right(e.right))}},si=ri,ii={URI:gt,map:bt,ap:$n},oi={URI:gt,map:bt,ap:$n,chain:ei},ai=function(e,t){return function(n){return ye(n)?O(e(n.left)):P(t(n.right))}},ye=Zs,An=function(e,t){return function(n){return ye(n)?e(n.left):t(n.right)}},Re=An,ui=function(e,t){try{return P(e())}catch(n){return O(t(n))}},ci=ni(_t),li=mt(oi),In=li;let Ae;function pi(e,t){Ae?Ae.set(e,t):t()}function Xe(e){if(Ae)return e();Ae=new Map;try{e()}finally{Ae.forEach(t=>t()),Ae=void 0}}function W(e,t){t||(t={});const n=t.equals||Object.is;let r=[],i=e;const s=c=>{if(!n(i,c)){const h=i;i=c,pi(l,()=>{[...r].forEach(([f,b])=>{f(c,h),b&&u(f,!0)})})}};function a(c){const h=typeof c!="object"?{once:c}:c;return{once:h.once||!1,signal:h.signal||!1}}const u=(c,h)=>{const f=a(h),b=r.findIndex(([v,y])=>v===c&&y.once===f.once&&y.signal===f.signal);b>=0&&r.splice(b,1)},l=Object.assign(function(){return hi(l),i},{destroy(){r=[]},set:s,reset(){s(e)},sub(c,h){return r.push([c,a(h)]),()=>u(c,h)},unsub:u,unsubAll(){r=r.filter(c=>c[1].signal)}});return l}const Oe=[];function hi(e){Oe.length&&Oe[Oe.length-1].add(e)}function F(e,t){let n=new Set,r;function i(){return r||(r=W(a(),t))}function s(){i().set(a())}function a(){n.forEach(c=>{c.unsub(s,{signal:!0})});const u=new Set;let l;Oe.push(u);try{l=e()}finally{Oe.pop()}return u.forEach(c=>{c.sub(s,{signal:!0})}),n=u,l}return Object.assign(function(){return i()()},{destroy(){i().destroy()},sub(...u){return i().sub(...u)},unsub(...u){i().unsub(...u)},unsubAll(...u){i().unsubAll(...u)}})}var ae;function vt(e){return{lang:(e==null?void 0:e.lang)??(ae==null?void 0:ae.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(ae==null?void 0:ae.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(ae==null?void 0:ae.abortPipeEarly)}}var wt;function fi(e){return wt==null?void 0:wt.get(e)}var yt;function di(e){return yt==null?void 0:yt.get(e)}var Ct;function _i(e,t){var n;return(n=Ct==null?void 0:Ct.get(e))==null?void 0:n.get(t)}function mi(e){var n,r;const t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&((r=(n=Object.getPrototypeOf(e))==null?void 0:n.constructor)==null?void 0:r.name))??"null":t}function K(e,t,n,r,i){const s=i&&"input"in i?i.input:n.value,a=(i==null?void 0:i.expected)??e.expects??null,u=(i==null?void 0:i.received)??mi(s),l={kind:e.kind,type:e.type,input:s,expected:a,received:u,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${u}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??_i(e.reference,l.lang)??(c?di(l.lang):null)??r.message??fi(l.lang);h!==void 0&&(l.message=typeof h=="function"?h(l):h),c&&(n.typed=!1),n.issues?n.issues.push(l):n.issues=[l]}function J(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},vt())}}}function qn(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function bi(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}var gi=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function et(e,t){return{kind:"validation",type:"check",reference:et,async:!1,expects:null,requirement:e,message:t,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&K(this,"input",n,r),n}}}function Ft(e){return{kind:"validation",type:"integer",reference:Ft,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&K(this,"integer",t,n),t}}}function ue(e){return{kind:"transformation",type:"transform",reference:ue,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function vi(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}function St(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function kt(e,t){return!e["~run"]({value:t},{abortEarly:!0}).issues}function Bn(){return{kind:"schema",type:"any",reference:Bn,expects:"any",async:!1,get"~standard"(){return J(this)},"~run"(e){return e.typed=!0,e}}}function Tn(e,t){return{kind:"schema",type:"array",reference:Tn,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){var s;const i=n.value;if(Array.isArray(i)){n.typed=!0,n.value=[];for(let a=0;a<i.length;a++){const u=i[a],l=this.item["~run"]({value:u},r);if(l.issues){const c={type:"array",origin:"value",input:i,key:a,value:u};for(const h of l.issues)h.path?h.path.unshift(c):h.path=[c],(s=n.issues)==null||s.push(h);if(n.issues||(n.issues=l.issues),r.abortEarly){n.typed=!1;break}}l.typed||(n.typed=!1),n.value.push(l.value)}}else K(this,"type",n,r);return n}}}function Ce(e){return{kind:"schema",type:"boolean",reference:Ce,expects:"boolean",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:K(this,"type",t,n),t}}}function tt(e){return{kind:"schema",type:"date",reference:tt,expects:"Date",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return t.value instanceof Date?isNaN(t.value)?K(this,"type",t,n,{received:'"Invalid Date"'}):t.typed=!0:K(this,"type",t,n),t}}}function Et(e){return{kind:"schema",type:"function",reference:Et,expects:"Function",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="function"?t.typed=!0:K(this,"type",t,n),t}}}function $t(e,t){return{kind:"schema",type:"instance",reference:$t,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){return n.value instanceof this.class?n.typed=!0:K(this,"type",n,r),n}}}function j(e,t){return{kind:"schema",type:"loose_object",reference:j,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){var s;const i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(const a in this.entries){const u=this.entries[a];if(a in i||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){const l=a in i?i[a]:St(u),c=u["~run"]({value:l},r);if(c.issues){const h={type:"object",origin:"value",input:i,key:a,value:l};for(const f of c.issues)f.path?f.path.unshift(h):f.path=[h],(s=n.issues)==null||s.push(f);if(n.issues||(n.issues=c.issues),r.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value[a]=c.value}else if(u.fallback!==void 0)n.value[a]=vi(u);else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(K(this,"key",n,r,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:i,key:a,value:i[a]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly)for(const a in i)qn(i,a)&&!(a in this.entries)&&(n.value[a]=i[a])}else K(this,"type",n,r);return n}}}function Ie(e,t){return{kind:"schema",type:"nullish",reference:Ie,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return J(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=St(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function de(e){return{kind:"schema",type:"number",reference:de,expects:"number",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:K(this,"type",t,n),t}}}function $(e,t){return{kind:"schema",type:"optional",reference:$,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return J(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=St(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function At(e,t,n){return{kind:"schema",type:"record",reference:At,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return J(this)},"~run"(r,i){var a,u;const s=r.value;if(s&&typeof s=="object"){r.typed=!0,r.value={};for(const l in s)if(qn(s,l)){const c=s[l],h=this.key["~run"]({value:l},i);if(h.issues){const b={type:"object",origin:"key",input:s,key:l,value:c};for(const v of h.issues)v.path=[b],(a=r.issues)==null||a.push(v);if(r.issues||(r.issues=h.issues),i.abortEarly){r.typed=!1;break}}const f=this.value["~run"]({value:c},i);if(f.issues){const b={type:"object",origin:"value",input:s,key:l,value:c};for(const v of f.issues)v.path?v.path.unshift(b):v.path=[b],(u=r.issues)==null||u.push(v);if(r.issues||(r.issues=f.issues),i.abortEarly){r.typed=!1;break}}(!h.typed||!f.typed)&&(r.typed=!1),h.typed&&(r.value[h.value]=f.value)}}else K(this,"type",r,i);return r}}}function C(e){return{kind:"schema",type:"string",reference:C,expects:"string",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:K(this,"type",t,n),t}}}function Pn(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function nt(e,t){return{kind:"schema",type:"union",reference:nt,expects:bi(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){let i,s,a;for(const u of this.options){const l=u["~run"]({value:n.value},r);if(l.typed)if(l.issues)s?s.push(l):s=[l];else{i=l;break}else a?a.push(l):a=[l]}if(i)return i;if(s){if(s.length===1)return s[0];K(this,"type",n,r,{issues:Pn(s)}),n.typed=!0}else{if((a==null?void 0:a.length)===1)return a[0];K(this,"type",n,r,{issues:Pn(a)})}return n}}}function It(){return{kind:"schema",type:"unknown",reference:It,expects:"unknown",async:!1,get"~standard"(){return J(this)},"~run"(e){return e.typed=!0,e}}}function _e(e,t,n){const r=e["~run"]({value:t},vt(n));if(r.issues)throw new gi(r.issues);return r.value}function se(...e){return{...e[0],pipe:e,get"~standard"(){return J(this)},"~run"(t,n){for(const r of e)if(r.kind!=="metadata"){if(t.issues&&(r.kind==="schema"||r.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r["~run"](t,n))}return t}}}function qt(e,t,n){const r=e["~run"]({value:t},vt(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var wi=Object.defineProperty,yi=(e,t,n)=>t in e?wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mn=(e,t,n)=>yi(e,typeof t!="symbol"?t+"":t,n),Ci=Object.defineProperty,Fi=(e,t,n)=>t in e?Ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bt=(e,t,n)=>Fi(e,typeof t!="symbol"?t+"":t,n);function Ln(e){return t=>t instanceof e}function Vn(e,t){const n=class extends Error{constructor(...i){const s=typeof t=="function"?t(...i):typeof t=="string"?[t]:t||[];super(...s),this.name=e}};Bt(n,"is",Ln(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function Si(e,t,n){const r=class extends Vn(e,n){constructor(...s){super(...s),Bt(this,"data"),this.data=t(...s)}};Bt(r,"is",Ln(r));let i=r;return Object.defineProperty(i,"name",{value:e}),i}let Rn=class extends Vn("CancelledError","Promise was canceled"){},Tt=class extends Si("TimeoutError",t=>({timeout:t}),(t,n)=>[`Timeout reached: ${t}ms`,{cause:n}]){};const ki=Symbol("resolved");function Ei(e){return{tag:ki,value:e}}function On(e,t){return e.reject=t.reject,e.resolve=t.resolve,e}let rt=class Sn extends Promise{constructor(t,n){let r,i,s,a;typeof t=="function"?(s=t,a=n||{}):a=t||{};let u,l;const c=()=>!!l,h=()=>!!u;let f={};const b=[],v=()=>{b.forEach(g=>g()),b.splice(0,b.length),f={}},y=new AbortController,w=()=>h()||c();super((g,S)=>{const{abortOnResolve:_=!0,abortOnReject:D=!0}=a;i=k=>{var L,I;w()||(g(k),u=[k],(L=f.resolved)==null||L.forEach(x=>x(k)),(I=f.finalized)==null||I.forEach(x=>x({kind:"resolved",result:k})),v(),_&&y.abort(Ei(k)))},r=k=>{var L,I;w()||(S(k),l=[k],(L=f.rejected)==null||L.forEach(x=>x(k)),(I=f.finalized)==null||I.forEach(x=>x({kind:"rejected",reason:k})),v(),D&&y.abort(k))};const{abortSignal:M}=a;if(M){if(M.aborted)return r(M.reason);const k=()=>{r(M.reason)};M.addEventListener("abort",k,!0),b.push(()=>{M.removeEventListener("abort",k,!0)})}const{timeout:U}=a;if(U){const k=setTimeout(()=>{r(new Tt(U))},U);b.push(()=>{clearTimeout(k)})}try{const k=()=>{},L=s&&s(i,r,{abortSignal:y.signal,get isRejected(){return c()},get isResolved(){return h()},on(I,x){if(u||l){if(I==="finalized"){const Le=u?{kind:"resolved",result:u[0]}:{kind:"rejected",reason:l[0]};x(Le)}else I==="resolved"&&u?x(u[0]):I==="rejected"&&l&&x(l[0]);return k}return f[I]||(f[I]=[]),f[I].push(x),()=>{const Le=f[I]||[],Ye=Le.indexOf(x);Ye>=0&&Le.splice(Ye,1)}},get result(){return u==null?void 0:u[0]},get rejectReason(){return l==null?void 0:l[0]},throwIfRejected(){if(l)throw l[0]}});L instanceof Promise&&L.catch(r)}catch(k){r(k)}}),Mn(this,"reject"),Mn(this,"resolve"),this.reject=r,this.resolve=i}static fn(t,n){return new Sn(async(r,i,s)=>{try{r(await t(s))}catch(a){i(a)}},n)}static resolve(t){return this.fn(()=>t)}static reject(t){return new Sn((n,r)=>{r(t)})}cancel(){this.reject(new Rn)}catch(t){return this.then(void 0,t)}finally(t){return On(super.finally(t),this)}then(t,n){return On(super.then(t,n),this)}};function jn(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function $i(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function Ai(e){return Object.entries(e).reduce((t,[n,r])=>(t[$i(n)]=r,t),{})}function Pt(e){const t=Ai(e);for(const n in t){const r=t[n];r&&typeof r=="object"&&!(r instanceof Date)&&(t[n]=Array.isArray(r)?r.map(Pt):Pt(r))}return t}function Ii(e){return e.replace(/_([a-z])/g,(t,n)=>`-${n.toLowerCase()}`)}function Dn(e){return`tapps/${e}`}function Mt(e,t){sessionStorage.setItem(Dn(e),JSON.stringify(t))}function Un(e){const t=sessionStorage.getItem(Dn(e));try{return t?JSON.parse(t):void 0}catch{}}function st(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(n=>{n()})}]}function xn(e,t){t||(t={});const{textColor:n,bgColor:r,shouldLog:i}=t,s=i===void 0?!0:i,a=typeof s=="boolean"?()=>s:s,u=(l,c,...h)=>{if(c||a()){const f="font-weight:bold;padding:0 5px;border-radius:100px",[b,v,y]={log:["#0089c3","white","INFO"],error:["#ff0000F0","white","ERR"],warn:["#D38E15","white","WARN"]}[l];console[l](`%c${y} ${Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(new Date)}%c %c${e}`,`${f};background-color:${b};color:${v}`,"",`${f};${n?`color:${n};`:""}${r?`background-color:${r}`:""}`,...h)}};return[["log","forceLog"],["warn","forceWarn"],["error","forceError"]].reduce((l,[c,h])=>(l[c]=u.bind(void 0,c,!1),l[h]=u.bind(void 0,c,!0),l),{})}var qi=function(e,t,n){if(arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function Gn(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function qe(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Wn=function(e,t){var n=function(r){return r.length>=e};return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,qi([i],r,!1))}}},Bi=function(e){return e._tag==="Left"},Hn=function(e){return{_tag:"Left",left:e}},Nn=function(e){return{_tag:"Right",right:e}},zn=Hn,Kn=Nn,Jn=Bi,Ti=function(e,t){return function(n){return Jn(n)?e(n.left):t(n.right)}},Lt=Ti;function Pi(e){return Gn(Kn,e.of)}function Mi(e){return Gn(zn,e.of)}function Li(e){return function(t,n){return e.chain(t,function(r){return Jn(r)?e.of(r):n(r.right)})}}function Vi(e){return function(t,n){return function(r){return e.map(r,Lt(t,n))}}}var Qn=function(e,t){return qe(e,Oi(t))},Ri=function(e,t){return qe(e,ji(t))},Oi=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},ji=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Vt=function(e){return function(){return Promise.resolve(e)}},Di=Wn(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),Zn="Task",Ui={URI:Zn,map:Qn},Yn={of:Vt},xi={URI:Zn,map:Qn,of:Vt,ap:Ri,chain:Di},Gi=function(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function u(h){try{c(r.next(h))}catch(f){a(f)}}function l(h){try{c(r.throw(h))}catch(f){a(f)}}function c(h){h.done?s(h.value):i(h.value).then(u,l)}c((r=r.apply(e,[])).next())})},Wi=function(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(c){return function(h){return l([c,h])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(s=c[0]&2?i.return:c[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,c[1])).done)return s;switch(i=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(h){c=[6,h],i=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Hi=Mi(Yn),Ni=Pi(Yn),zi=Vt,Xn=Vi(Ui),Ki=Xn,Ji=function(e,t){return function(){return Gi(void 0,void 0,void 0,function(){var n;return Wi(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e().then(Nn)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,Hn(t(n))];case 3:return[2]}})})}},Qi=Wn(2,Li(xi)),Zi=Qi;function je(e){const t=n=>{throw n};return typeof e=="function"?rt.resolve(qe(e,Xn(t,n=>n))()):qe(e,Lt(t,n=>n))}function X(e){return Object.assign((...t)=>je(e(...t)),e)}const De=Object.assign((e,t)=>qe(Ji(()=>new rt((n,r,i)=>e(s=>n(Kn(s)),s=>n(zn(s)),i),t),n=>n),Zi(Lt(Hi,Ni))),{fn:(e,t)=>De((n,r,i)=>{const s=e(i);qe(typeof s=="function"?s:zi(s),Ki(r,n))()},t)});function Yi(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Xi=function(e){return e._tag==="Left"},eo=function(e){return{_tag:"Left",left:e}},to=function(e){return{_tag:"Right",right:e}},er=eo,Fe=to,no=function(e){return function(t){return ro(t)?t:Fe(e(t.right))}},ro=Xi,tr=function(e,t){try{return Fe(e())}catch(n){return er(t(n))}};function so(e){const t=n=>{const r={};return new URLSearchParams(n).forEach((i,s)=>{const a=r[s];Array.isArray(a)?a.push(i):a===void 0?r[s]=i:r[s]=[a,i]}),_e(e,r)};return se(nt([C(),$t(URLSearchParams)]),et(n=>{try{return t(n),!0}catch{return!1}},"The value doesn't match required schema"),ue(t))}function io(e){return se(C(),et(t=>{try{return JSON.parse(t),!0}catch{return!1}},"Input is not a valid JSON value"),ue(JSON.parse),e)}function me(e){return se(C(),io(e))}function Rt(e){return se(nt([C(),$t(URLSearchParams)]),so(e))}function it(e){return t=>e.test(t)}const nr=it(/^#[\da-f]{3}$/i),rr=it(/^#[\da-f]{4}$/i),Ue=it(/^#[\da-f]{6}$/i),sr=it(/^#[\da-f]{8}$/i);function ir(e){return[Ue,sr,nr,rr].some(t=>t(e))}function or(e){let t="#";for(let n=0;n<e.length-1;n+=1)t+=e[1+n].repeat(2);return t}function ot(e){const t=e.replace(/\s/g,"").toLowerCase();if(/^#[\da-f]{3}$/i.test(t))return Fe(or(t.toLowerCase()+"f"));if(/^#[\da-f]{4}$/i.test(t))return Fe(or(t.toLowerCase()));if(/^#[\da-f]{6}$/i.test(t))return Fe(t.toLowerCase()+"ff");if(/^#[\da-f]{8}$/i.test(t))return Fe(t.toLowerCase());const n=t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/)||t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})\)$/);return n?Fe(n.slice(1).reduce((r,i)=>r+parseInt(i,10).toString(16).padStart(2,"0"),"#").padEnd(9,"f")):er(new Error(`Value "${e}" does not satisfy any of known RGB formats.`))}function ar(e){return Yi(ot(e),no(t=>t.slice(0,7)))}const oo=X(ar),ao=X(ot);function uo(){return j({id:de(),photo_url:$(C()),type:C(),title:C(),username:$(C())})}function ur(){return j({added_to_attachment_menu:$(Ce()),allows_write_to_pm:$(Ce()),first_name:C(),id:de(),is_bot:$(Ce()),is_premium:$(Ce()),last_name:$(C()),language_code:$(C()),photo_url:$(C()),username:$(C())})}function co(){return j({auth_date:se(C(),ue(e=>new Date(Number(e)*1e3)),tt()),can_send_after:$(se(C(),ue(Number),Ft())),chat:$(me(uo())),chat_type:$(C()),chat_instance:$(C()),hash:C(),query_id:$(C()),receiver:$(me(ur())),start_param:$(C()),signature:C(),user:$(me(ur()))})}function cr(){return Rt(co())}function Ot(){return At(C(),se(nt([C(),de()]),ue(e=>typeof e=="number"?`#${(e&16777215).toString(16).padStart(6,"0")}`:e),et(ir)))}function lo(){const e=$(se(C(),ue(t=>t==="1")));return j({tgWebAppBotInline:e,tgWebAppData:$(cr()),tgWebAppDefaultColors:$(me(Ot())),tgWebAppFullscreen:e,tgWebAppPlatform:C(),tgWebAppShowSettings:e,tgWebAppStartParam:$(C()),tgWebAppThemeParams:me(Ot()),tgWebAppVersion:C()})}function po(){return Rt(lo())}function lr(){return j({eventType:C(),eventData:$(It())})}function pr(e){return tr(()=>_e(cr(),e),t=>t)}function at(e){return tr(()=>_e(po(),e),t=>t)}const ho=X(pr),hr=X(at);function fr(e,t){return t||(t=(n,r)=>JSON.stringify(r)),new URLSearchParams(Object.entries(e).reduce((n,[r,i])=>(Array.isArray(i)?n.push(...i.map(s=>[r,String(s)])):i!=null&&n.push([r,i instanceof Date?(i.getTime()/1e3|0).toString():typeof i=="string"||typeof i=="number"?String(i):typeof i=="boolean"?i?"1":"0":t(r,i)]),n),[])).toString()}function dr(e){return fr(e)}function _r(e){return fr(e,(t,n)=>t==="tgWebAppData"?dr(n):JSON.stringify(n))}var fo=Object.defineProperty,_o=(e,t,n)=>t in e?fo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jt=(e,t,n)=>_o(e,typeof t!="symbol"?t+"":t,n);function mr(e){return t=>t instanceof e}function H(e,t){const n=class extends Error{constructor(...s){const a=typeof t=="function"?t(...s):typeof t=="string"?[t]:t||[];super(...a),this.name=e}};jt(n,"is",mr(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function br(e,t,n){const r=class extends H(e,n){constructor(...a){super(...a),jt(this,"data"),this.data=t(...a)}};jt(r,"is",mr(r));let i=r;return Object.defineProperty(i,"name",{value:e}),i}function mo(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(i){i(n)}),(r=e.get("*"))&&r.slice().map(function(i){i(t,n)})}}}function gr(e){return kt(j({TelegramWebviewProxy:j({postEvent:Et()})}),e)}function vr(){try{return window.self!==window.top}catch{return!0}}var bo=function(e,t,n){if(arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function go(e){return e}function xe(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function ce(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Dt=function(e,t){var n=function(r){return r.length>=e};return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,bo([i],r,!1))}}},vo={_tag:"None"},wo=function(e){return{_tag:"Some",value:e}},yo=function(e){return e._tag==="Left"},Co=function(e){return{_tag:"Left",left:e}},Fo=function(e){return{_tag:"Right",right:e}},Se=Co,te=Fo,wr=Dt(2,function(e,t){return Ge(e)?e:t(e.right)}),So=function(e){return function(t){return Ge(t)?t:te(e(t.right))}},ko=function(e){return function(t){return Ge(t)?Se(e(t.left)):t}},Ge=yo,yr=function(e,t){return function(n){return Ge(n)?e(n.left):t(n.right)}},Eo=yr,Ut=yr,$o=Ut,xt=function(e,t){try{return te(e())}catch(n){return Se(t(n))}},Ao=wr,Io=wr,qo=vo,Bo=wo,To=function(e){return e._tag==="None"},Po=function(e,t){return function(n){return To(n)?e():t(n.value)}},Mo=Po;function Lo(e){return xe(te,e.of)}function Vo(e){return xe(Se,e.of)}function Ro(e){return function(t,n){return e.chain(t,function(r){return Ge(r)?e.of(r):n(r.right)})}}function Oo(e){return function(t,n){return function(r){return e.map(r,Ut(t,n))}}}var Cr=function(e,t){return ce(e,Do(t))},jo=function(e,t){return ce(e,Uo(t))},Do=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},Uo=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Fr=function(e){return function(){return Promise.resolve(e)}},xo=Dt(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),Sr="Task",Go={URI:Sr,map:Cr},kr={of:Fr},Wo={URI:Sr,map:Cr,of:Fr,ap:jo,chain:xo},Ho=Vo(kr),Er=Lo(kr),No=Oo(Go),$r=Dt(2,Ro(Wo)),zo=$r,Ko=$r;class Ar extends H("MethodUnsupportedError",(t,n)=>[`Method "${t}" is unsupported in Mini Apps version ${n}`]){}class Ir extends H("MethodParameterUnsupportedError",(t,n,r)=>[`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${r}`]){}class qr extends br("LaunchParamsRetrieveError",t=>({errors:t}),t=>[["Unable to retrieve launch parameters from any known source. Perhaps, you have opened your app outside Telegram?","📖 Refer to docs for more information:","https://docs.telegram-mini-apps.com/packages/tma-js-bridge/environment","","Collected errors:",...t.map(({source:n,error:r})=>`Source: ${n} / ${r instanceof Error?r.message:String(r)}`)].join(`
2
- `)]){}class Br extends H("InvalidLaunchParamsError",(t,n)=>[`Invalid value for launch params: ${t}`,{cause:n}]){}class Tr extends H("UnknownEnvError"){}class Pr extends H("InvokeCustomMethodError",t=>[`Server returned error: ${t}`]){}const Mr="launchParams";function Lr(e){return e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&")}const Be=xe(We,Ao(at)),Jo=X(Be),Gt=xe(We,So(e=>{const t=new URLSearchParams(e).get("tgWebAppData");return t?Bo(t):qo})),Qo=xe(Gt,$o(e=>{throw e},e=>e),Mo(()=>{},e=>e));function We(){const e=[];for(const[t,n]of[[()=>Lr(window.location.href),"window.location.href"],[()=>{const r=performance.getEntriesByType("navigation")[0];return r&&Lr(r.name)},"performance navigation entries"],[()=>Un(Mr),"local storage"]]){const r=t();if(!r){e.push({source:n,error:new Error("Source is empty")});continue}const i=ce(at(r),Eo(s=>s,()=>!0));if(typeof i!="boolean"){e.push({source:n,error:i});continue}return Mt(Mr,r),te(r)}return Se(new qr(e))}const Zo=X(We);function Yo(e,t){const n=new Map,r=mo(),i=(s,a,u=!1)=>{const l=n.get(s)||new Map;n.set(s,l);const c=l.get(a)||[];l.set(a,c);const h=c.findIndex(f=>f[1]===u);if(h>=0&&(r.off(s,c[h][0]),c.splice(h,1),!c.length&&(l.delete(a),!l.size))){const f=n.size;n.delete(s),f&&!n.size&&t()}};return{on(s,a,u){!n.size&&e();const l=()=>{i(s,a,u)},c=(...b)=>{u&&l(),s==="*"?a({name:b[0],payload:b[1]}):a(...b)};r.on(s,c);const h=n.get(s)||new Map;n.set(s,h);const f=h.get(a)||[];return h.set(a,f),f.push([c,u||!1]),l},off:i,emit:r.emit,clear(){const s=n.size;r.all.clear(),n.clear(),s&&t()}}}function ut(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}function Wt(e,t,n){const r=[n],i=e[t];typeof i=="function"&&r.push(i);const s=(...u)=>{r.forEach(l=>l(...u))},a=Object.assign((...u)=>{s(...u)},{unwrap(){const{length:u}=r;if(u===1){delete e[t];return}if(u===2){Or(e,t,r[1]);return}r.unshift(1),Or(e,t,s)}});Rr(e,t,()=>a,u=>r.push(u))}function Vr(e,t){const n=e[t];Rr(e,t,()=>n,r=>{Object.entries(r).forEach(([i,s])=>{n[i]=s})})}function Rr(e,t,n,r){Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:n,set:r})}function Or(e,t,n){Object.defineProperty(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n})}const Xo={clipboard_text_received:j({req_id:C(),data:Ie(C())}),custom_method_invoked:j({req_id:C(),result:$(It()),error:$(C())}),popup_closed:Ie(j({button_id:Ie(C(),()=>{})}),{}),viewport_changed:Ie(j({height:de(),width:Ie(de(),()=>window.innerWidth),is_state_stable:Ce(),is_expanded:Ce()}),()=>({height:window.innerHeight,is_state_stable:!0,is_expanded:!0})),theme_changed:j({theme_params:Ot()})};function jr(e){if(e.source!==window.parent)return;let t;try{t=_e(me(lr()),e.data)}catch{return}const{eventType:n,eventData:r}=t,i=Xo[n];let s;try{s=i?_e(i,r):r}catch(a){return le().forceError([`An error occurred processing the "${n}" event from the Telegram application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose"].join(`
3
- `),t,a)}ea(n,s)}const{on:ee,off:ke,emit:ea,clear:ta}=Yo(()=>{const e=window;!e.TelegramGameProxy&&(e.TelegramGameProxy={}),Wt(e.TelegramGameProxy,"receiveEvent",ut),Vr(e,"TelegramGameProxy"),!e.Telegram&&(e.Telegram={}),!e.Telegram.WebView&&(e.Telegram.WebView={}),Wt(e.Telegram.WebView,"receiveEvent",ut),Vr(e.Telegram,"WebView"),Wt(e,"TelegramGameProxy_receiveEvent",ut),window.addEventListener("message",jr)},()=>{[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["Telegram","WebView","receiveEvent"]].forEach(e=>{const t=window;let n=[void 0,t];for(const s of e)if(n=[n[1],n[1][s]],!n[1])return;const[r,i]=n;"unwrap"in i&&(i.unwrap(),r&&r!==t&&!Object.keys(r).length&&delete t[e[0]])}),window.removeEventListener("message",jr)}),Ht=W(!1),Dr=W("https://web.telegram.org"),na=e=>{le().log("Event received:",e)},Ur=F(Ht);function ra(e){e!==Ht()&&(Ht.set(e),(e?ee:ke)("*",na))}const xr=F(Dr);function sa(e){Dr.set(e),le().log("New target origin set",e)}const ct=W((...e)=>{window.parent.postMessage(...e)}),le=W(xn("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:Ur})),ia=(...e)=>ct()(...e);function oa(e,t){ce(Nt(e,t),ko(n=>{throw n}))}function Nt(e,t){le().log("Posting event:",t?{eventType:e,eventData:t}:{eventType:e});const n=window,r=JSON.stringify({eventType:e,eventData:t});return vr()?(ia(r,xr()),te(void 0)):gr(n)?(n.TelegramWebviewProxy.postEvent(e,JSON.stringify(t)),te(void 0)):kt(j({external:j({notify:Et()})}),n)?(n.external.notify(r),te(void 0)):Se(new Tr)}function zt(e,t,n={}){const{capture:r=()=>!0,postEvent:i=Nt}=n;return ce(async()=>i(e,n.params),Ko(()=>De((s,a,u)=>{const[l,c]=st();(Array.isArray(t)?t:[t]).forEach(h=>{l(ee(h,f=>{(Array.isArray(t)?r({event:h,payload:f}):r(f))&&s(f)}))}),u.on("finalized",c)},n)))}function aa(e,t){const n=Kt(e,t);return typeof n=="function"?rt.fn(()=>je(n)):n}function Kt(e,t){const n=gr(window);if(!e)return n||ce(We(),Ut(()=>!1,()=>!0));if(n)return Er(!0);const{timeout:r=100}=t||{};return ce(zt("web_app_request_theme","theme_changed",{...t,timeout:r}),No(i=>Tt.is(i)?te(!1):Se(i),()=>te(!0)))}function ua({launchParams:e,onEvent:t,resetPostMessage:n}={}){if(e){const s=typeof e=="string"||e instanceof URLSearchParams?e.toString():_r({...e,tgWebAppData:void 0})+(e.tgWebAppData?`&tgWebAppData=${encodeURIComponent(e.tgWebAppData.toString())}`:"");try{hr(s)}catch(a){throw new Br(s,a)}Mt("launchParams",s)}if(vr()){if(!t)return;n&&ct.reset();const s=ct();ct.set((...a)=>{const[u]=a,l=()=>{s(...a)};try{const c=_e(me(lr()),u);t([c.eventType,c.eventData],l)}catch{l()}});return}const r=window.TelegramWebviewProxy||{},i=r.postEvent||(()=>{});window.TelegramWebviewProxy={...r,postEvent(s,a){const u=()=>{i(s,a)};t?t([s,a?JSON.parse(a):void 0],u):u()}},le().log("Environment was mocked by the mockTelegramEnv function")}function Gr(e){return({req_id:t})=>t===e}function Wr(e){return e.split(".").map(Number)}function ca(e,t){const n=Wr(e),r=Wr(t),i=Math.max(n.length,r.length);for(let s=0;s<i;s+=1){const a=n[s]||0,u=r[s]||0;if(a!==u)return a>u?1:-1}return 0}const Hr={"6.0":["iframe_ready","iframe_will_reload","web_app_close","web_app_data_send","web_app_expand","web_app_open_link","web_app_ready","web_app_request_theme","web_app_request_viewport","web_app_setup_main_button","web_app_setup_closing_behavior"],6.1:["web_app_open_tg_link","web_app_open_invoice","web_app_setup_back_button","web_app_set_background_color","web_app_set_header_color","web_app_trigger_haptic_feedback"],6.2:["web_app_open_popup"],6.4:["web_app_close_scan_qr_popup","web_app_open_scan_qr_popup","web_app_read_text_from_clipboard",{method:"web_app_open_link",param:"try_instant_view"}],6.7:["web_app_switch_inline_query"],6.9:["web_app_invoke_custom_method","web_app_request_write_access","web_app_request_phone",{method:"web_app_set_header_color",param:"color"}],"6.10":["web_app_setup_settings_button"],7.2:["web_app_biometry_get_info","web_app_biometry_open_settings","web_app_biometry_request_access","web_app_biometry_request_auth","web_app_biometry_update_token"],7.6:[{method:"web_app_open_link",param:"try_browser"},{method:"web_app_close",param:"return_back"}],7.7:["web_app_setup_swipe_behavior"],7.8:["web_app_share_to_story"],"7.10":["web_app_setup_secondary_button","web_app_set_bottom_bar_color",{method:"web_app_setup_main_button",param:"has_shine_effect"}],"8.0":["web_app_request_safe_area","web_app_request_content_safe_area","web_app_request_fullscreen","web_app_exit_fullscreen","web_app_set_emoji_status","web_app_add_to_home_screen","web_app_check_home_screen","web_app_request_emoji_status_access","web_app_check_location","web_app_open_location_settings","web_app_request_file_download","web_app_request_location","web_app_send_prepared_message","web_app_start_accelerometer","web_app_start_device_orientation","web_app_start_gyroscope","web_app_stop_accelerometer","web_app_stop_device_orientation","web_app_stop_gyroscope","web_app_toggle_orientation_lock"],"9.0":["web_app_device_storage_clear","web_app_device_storage_get_key","web_app_device_storage_save_key","web_app_secure_storage_clear","web_app_secure_storage_get_key","web_app_secure_storage_restore_key","web_app_secure_storage_save_key"],9.1:["web_app_hide_keyboard"]};function Jt(e,t){return Object.keys(Hr).find(n=>Hr[n].some(r=>t?typeof r=="object"&&r.method===e&&r.param===t:r===e))||null}function pe(e,t,n){const r=n?Jt(e,t):Jt(e);return r?ca(r,n||t)<=0:!1}function la(e,t="strict"){const n=typeof t=="function"?t:r=>{const{method:i,version:s}=r,a="param"in r?new Ir(i,r.param,s):new Ar(i,s);if(t==="strict")throw a;return le().forceWarn(a.message)};return(r,i)=>pe(r,e)?r==="web_app_set_header_color"&&kt(j({color:Bn()}),i)&&!pe(r,"color",e)?n({version:e,method:r,param:"color"}):oa(r,i):n({version:e,method:r})}function pa(e,t,n,r){return ce(zt("web_app_invoke_custom_method","custom_method_invoked",{...r||{},params:{method:e,params:t,req_id:n},capture:Gr(n)}),zo(({result:i,error:s})=>s?Ho(new Pr(s)):Er(i)))}function ha(){Object.hasOwn||(Object.hasOwn=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)})}function Qt(e){return xt(()=>decodeURIComponent(atob(e).replace(/-/g,"+").replace(/_/g,"/").split("").map(t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)).join("")),t=>t)}const fa=X(Qt);function Zt(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,n)=>String.fromCharCode(parseInt(`0x${n}`)))).replace(/\+/g,"-").replace(/\//g,"_")}var da=function(e){return xt(function(){return JSON.parse(e)},go)};function Nr(e){const t=Zt(typeof e=="string"?e:JSON.stringify(e));return t.length>512?Se(new Error("Value is too long for start parameter")):te(t)}const _a=X(Nr);function ma(e,t){return je(zr(e,typeof t=="function"?n=>xt(()=>t(n),r=>r):t))}function zr(e,t){return ce(Qt(e),Io(n=>t?typeof t=="function"?t(n):da(n):te(n)))}function ba(e){return Zt(e).length<=512}function Q(e){return typeof e=="function"?e():e}function ie(e,t){return F(()=>pe(e,Q(t)))}var Te=Js,He=Qs,ga=function(e,t){return d(e,ya(t))},va=function(e,t){return d(e,Fa(t))},wa="Option",ya=function(e){return function(t){return Ne(t)?Te:He(e(t.value))}},Ca=He,Fa=function(e){return function(t){return Ne(t)||Ne(e)?Te:He(t.value(e.value))}},Sa=Ve(2,function(e,t){return Ne(e)?Te:t(e.value)}),ka={URI:wa,map:ga,ap:va,chain:Sa},Ne=function(e){return e._tag==="None"},Ea=function(e,t){return function(n){return Ne(n)?e():t(n.value)}},Kr=Ea,$a=Ca(_t),Jr=mt(ka);function Aa(e){return we(P,e.of)}function Ia(e){return we(O,e.of)}function qa(e){return Xs(e,ti)}function Ba(e){return Ys(e,ii)}function Ta(e){return function(t,n){return e.chain(t,function(r){return ye(r)?e.of(r):n(r.right)})}}function Pa(e){return function(t,n,r){return e.map(t,ai(n,r))}}function Ma(e){return function(t,n){return function(r){return e.map(r,Re(t,n))}}}var Yt=function(e,t){return d(e,La(t))},Qr=function(e,t){return d(e,Va(t))},La=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},Va=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Xt=function(e){return function(){return Promise.resolve(e)}},Ra=Ve(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),en="Task",tn={URI:en,map:Yt},Zr={of:Xt},Oa={URI:en,map:Yt,ap:Qr},ja={URI:en,map:Yt,of:Xt,ap:Qr,chain:Ra},Da=function(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function u(h){try{c(r.next(h))}catch(f){a(f)}}function l(h){try{c(r.throw(h))}catch(f){a(f)}}function c(h){h.done?s(h.value):i(h.value).then(u,l)}c((r=r.apply(e,t||[])).next())})},Ua=function(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(c){return function(h){return l([c,h])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(s=c[0]&2?i.return:c[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,c[1])).done)return s;switch(i=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(h){c=[6,h],i=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},N=Ia(Zr),R=Aa(Zr),Yr=Xt,xa=Ma(tn),Ga=function(e,t){return function(){return Da(void 0,void 0,void 0,function(){var n;return Ua(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e().then(En)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,kn(t(n))];case 3:return[2]}})})}},Wa=function(e,t){return d(e,V(t))},Ha=function(e,t){return d(e,Na(t))},V=qa(tn),nn=Ve(3,Pa(tn)),Na=Ba(Oa),rn=Ve(2,Ta(ja)),za=R,Ka="TaskEither",Ja={URI:Ka,map:Wa,ap:Ha,chain:rn},Qa=za(_t),Za=mt(Ja),lt=Za,he=rn,Pe=rn;function Ee(e){return[e]}class ze extends br("ValidationError",(t,n)=>({input:t,issues:n}),"Validation error"){}class pt extends H("CSSVarsBoundError","CSS variables are already bound"){}class Xr extends H("NotAvailableError",Ee){}class Ya extends H("InvalidEnvError",Ee){}class es extends H("FunctionNotAvailableError",Ee){}class ne extends H("InvalidArgumentsError",(t,n)=>[t,{cause:n}]){}class ht extends H("ConcurrentCallError",Ee){}class ts extends H("SetEmojiStatusError",t=>[`Failed to set emoji status: ${t}`]){}class sn extends H("AccessDeniedError",Ee){}class ns extends H("FullscreenFailedError",Ee){}class rs extends H("ShareMessageError",Ee){}class ss extends H("UnknownThemeParamsKeyError",t=>[`Unknown theme params key passed: ${t}`]){}function T(e,t){const n=F(()=>Q(t.version)||"100"),r=F(()=>Q(t.isTma)),{requires:i}=t,s=i?typeof i=="object"?i:{every:[i]}:void 0,a=y=>{if(!t.supports)return!0;const w=t.supports[y];return pe(w.method,w.param,n())},u=()=>{if(!s)return;const[y,w]="every"in s?["every",s.every]:["some",s.some];for(let g=0;g<w.length;g++){const S=w[g],_=typeof S=="function"?S():pe(S,n())?void 0:`it is unsupported in Mini Apps version ${n()}`;if(_&&(y==="every"||g===w.length-1))return _}},l=(...y)=>{for(const w in t.supports)if(t.supports[w].shouldCheck(...y)&&!a(w))return`option ${w} is not supported in Mini Apps version ${n()}`},c=F(()=>!u()),h=F(()=>n()!=="0.0"),f=F(()=>t.isMounted?t.isMounted():!0),b=F(()=>r()&&h()&&c()&&f()),v=y=>{const w=new es(y);return["task","promise"].includes(t.returns)?N(w):O(w)};return Object.assign((...y)=>{var D;const w="Unable to call function:";if(!r())return v(`${w} it can't be called outside Mini Apps`);if(!h())return v(`${w} the SDK was not initialized. Use the SDK init() function`);const g=u();if(g)return v(`${w} ${g}`);const S=l(...y);if(S)return v(`${w} ${S}`);if(!f()){const M=(D=t.isMounting)!=null&&D.call(t)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return v(`${w} the component is ${M}`)}const{returns:_}=t;return _==="plain"?ui(()=>e(...y),M=>M):_==="promise"?Ga(()=>e(...y),M=>M):e(...y)},e,{isAvailable:b,ifAvailable(...y){return b()?He(e(...y)):Te}},s?{isSupported:c}:{},t.supports?{supports:a}:{})}function B(e){return t=>T(t,e)}function m(e){return Object.assign(X(e),{ifAvailable(...t){return d(e.ifAvailable(...t),Kr(()=>({ok:!1}),n=>({ok:!0,data:je(n)})))}})}function on(e){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=r)}return t}function an(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&e[i]===t[i])}class be{constructor({initialState:t,onChange:n}){o(this,"_state");o(this,"state");o(this,"setState",t=>{const n={...this.state(),...on(t)};an(n,this.state())||this._state.set(n)});this._state=W(t,{equals:an}),this.state=F(this._state),this.state.sub(n)}getter(t){return F(()=>this._state()[t])}hasDiff(t){return!an({...this.state(),...on(t)},this.state())}}class Ke{constructor({onMounted:t,restoreState:n,initialState:r,onUnmounted:i,isPageReload:s}){o(this,"_isMounted",W(!1));o(this,"isMounted",F(this._isMounted));o(this,"mount");o(this,"unmount");this.mount=()=>{if(this.isMounted())return P(void 0);const a=Q(s)?n():void 0,u=a?P(a):typeof r=="function"?r():P(r);return d(u,Z(l=>{Xe(()=>{this._isMounted.set(!0),t==null||t(l)})}))},this.unmount=()=>{this._isMounted()&&Xe(()=>{this._isMounted.set(!1),i==null||i()})}}}class ft{constructor({isTma:t,storage:n,onClick:r,offClick:i,initialState:s,isPageReload:a,postEvent:u,payload:l,method:c,version:h}){o(this,"isMounted");o(this,"isSupported");o(this,"state");o(this,"stateSetters");o(this,"stateBoolSetters");o(this,"setStateFp");o(this,"setState");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const f=new be({initialState:s,onChange(g){n.set(g)}}),b=new Ke({initialState:s,isPageReload:a,onMounted:f.setState,restoreState:n.get}),v={version:h,requires:c,isTma:t},y=B({...v,returns:"plain"}),w=B({...v,returns:"either",isMounted:b.isMounted});this.isMounted=b.isMounted,this.isSupported=ie(c,h),this.state=f.state,this.setStateFp=w(g=>{const S={...this.state(),...on(g)};return f.hasDiff(S)?d(u(c,l(S)),Z(()=>{f.setState(S)})):P(void 0)}),this.setState=m(this.setStateFp),this.onClickFp=y(r),this.onClick=m(this.onClickFp),this.offClickFp=y(i),this.offClick=m(this.offClickFp),this.mountFp=y(()=>{const g=()=>{};return d(b.mount(),Re(g,g))}),this.mount=m(this.mountFp),this.unmount=b.unmount,this.stateSetters=g=>{const S=w(_=>this.setStateFp({[g]:_}));return[m(S),S]},this.stateBoolSetters=g=>{const[,S]=this.stateSetters(g),_=w(()=>S(!1)),D=w(()=>S(!0));return[[m(_),_],[m(D),D]]}}stateGetter(t){return F(()=>this.state()[t])}}class is{constructor(t){o(this,"isVisible");o(this,"isMounted");o(this,"isSupported");o(this,"hideFp");o(this,"hide");o(this,"showFp");o(this,"show");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const n=new ft({...t,method:"web_app_setup_back_button",payload:r=>({is_visible:r.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}function E(){return{isTma:F(()=>Kt())}}function Xa(e){return{get:()=>Un(e),set(t){Mt(e,t)}}}function eu(){return performance.getEntriesByType("navigation")[0]}function tu(){const e=eu();return!!e&&e.type==="reload"}function Je(e){return t=>({...t,...Q(e)})}function ge(e){return Je({storage:Xa(e),isPageReload:tu})}function Qe(e,t){return W(e,t)}const os=Qe(Nt),Me=(...e)=>os()(...e),as=(...e)=>je(Me(...e)),z=Je({postEvent:Me}),un=Qe("0.0"),A=Je({version:un});function cn(e,t){return{...d(E(),z,A,ge(e)),onClick(n,r){return ee(t,n,r)},offClick(n,r){ke(t,n,r)}}}const nu=new is(cn("backButton","back_button_pressed"));class ln{constructor({initialState:t,onMounted:n,restoreState:r,onUnmounted:i,isPageReload:s}){o(this,"_isMounted",W(!1));o(this,"isMounted",F(this._isMounted));o(this,"mount");o(this,"unmount");this.mount=a=>{if(this._isMounted())return R(void 0);const u=Q(s)?r():void 0;return d(u?R(u):t(a),V(l=>{this._isMounted()||Xe(()=>{this._isMounted.set(!0),n==null||n(l)})}))},this.unmount=()=>{this._isMounted()&&Xe(()=>{this._isMounted.set(!1),i==null||i()})}}}const us=new Xr("Biometry is not available");function pn(e){let t=!1,n=!1,r="",i=!1,s="",a=!1;return e.available&&(t=!0,n=e.token_saved,r=e.device_id,i=e.access_requested,s=e.type,a=e.access_granted),{available:t,tokenSaved:n,deviceId:r,type:s,accessGranted:a,accessRequested:i}}class cs{constructor({version:t,request:n,postEvent:r,storage:i,onInfoReceived:s,offInfoReceived:a,isTma:u,isPageReload:l}){o(this,"isAvailable");o(this,"isSupported");o(this,"isMounted");o(this,"state");o(this,"authenticateFp");o(this,"authenticate");o(this,"openSettingsFp");o(this,"openSettings");o(this,"requestAccessFp");o(this,"requestAccess");o(this,"updateTokenFp");o(this,"updateToken");o(this,"mountFp");o(this,"mount");o(this,"unmount");const c=g=>{h.setState(pn(g))},h=new be({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:i.set}),f=new ln({initialState(g){return d(n("web_app_biometry_get_info","biometry_info_received",g),V(pn))},isPageReload:l,onMounted(g){h.setState(g),s(c)},onUnmounted(){a(c)},restoreState:i.get}),b={version:t,requires:"web_app_biometry_request_auth",isTma:u},v=B({...b,returns:"either"}),y=B({...b,returns:"task"}),w=B({...b,isMounted:f.isMounted,returns:"task"});this.isAvailable=h.getter("available"),this.isMounted=f.isMounted,this.isSupported=ie("web_app_biometry_request_auth",t),this.state=h.state,this.unmount=f.unmount,this.mountFp=y(f.mount),this.authenticateFp=w(g=>this.isAvailable()?d(n("web_app_biometry_request_auth","biometry_auth_requested",{...g,params:{reason:((g||{}).reason||"").trim()}}),V(S=>(h.setState({token:S.token}),S))):N(us)),this.openSettingsFp=v(()=>r("web_app_biometry_open_settings")),this.requestAccessFp=w(g=>d(n("web_app_biometry_request_access","biometry_info_received",{...g,params:{reason:((g||{}).reason||"").trim()}}),he(S=>{const _=pn(S);return _.available?(h.setState(_),R(_.accessRequested)):N(us)}))),this.updateTokenFp=w((g={})=>{var S;return d(n("web_app_biometry_update_token","biometry_token_updated",{...g,params:{token:g.token||"",reason:(S=g.reason)==null?void 0:S.trim()}}),V(_=>_.status))}),this.authenticate=m(this.authenticateFp),this.openSettings=m(this.openSettingsFp),this.requestAccess=m(this.requestAccessFp),this.updateToken=m(this.updateTokenFp),this.mount=m(this.mountFp)}}const hn=(e,t,n)=>zt(e,t,{postEvent:Me,...n}),ru=(...e)=>rt.fn(()=>hn(...e)()),Y=Je({request:hn}),su=new cs({...d(E(),z,A,Y,ge("biometry")),offInfoReceived(e){ke("biometry_info_received",e)},onInfoReceived(e){return ee("biometry_info_received",e)}});class ls{constructor({postEvent:t,storage:n,isTma:r,isPageReload:i}){o(this,"isConfirmationEnabled");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"disableConfirmationFp");o(this,"disableConfirmation");o(this,"enableConfirmationFp");o(this,"enableConfirmation");const s=new be({initialState:{isConfirmationEnabled:!1},onChange(f){n.set(f)}}),a=new Ke({onMounted:s.setState,restoreState:n.get,initialState:{isConfirmationEnabled:!1},isPageReload:i}),u={requires:"web_app_setup_closing_behavior",isTma:r},l=B({...u,returns:"plain"}),c=B({...u,returns:"either",isMounted:a.isMounted}),h=f=>f===this.isConfirmationEnabled()?P(void 0):(s.setState({isConfirmationEnabled:f}),t("web_app_setup_closing_behavior",{need_confirmation:f}));this.isConfirmationEnabled=s.getter("isConfirmationEnabled"),this.isMounted=a.isMounted,this.disableConfirmationFp=c(()=>h(!1)),this.enableConfirmationFp=c(()=>h(!0)),this.mountFp=l(()=>{const f=()=>{};return d(a.mount(),Re(f,f))}),this.unmount=a.unmount,this.disableConfirmation=m(this.disableConfirmationFp),this.enableConfirmation=m(this.enableConfirmationFp),this.mount=m(this.mountFp)}}const iu=new ls(d(E(),ge("closingBehavior"),z));class ps{constructor({version:t,isTma:n,invokeCustomMethod:r}){o(this,"isSupported");o(this,"deleteItemFp");o(this,"deleteItem");o(this,"getItemFp");o(this,"getItem");o(this,"getItemsFp");o(this,"getItems");o(this,"getKeysFp");o(this,"getKeys");o(this,"setItemFp");o(this,"setItem");o(this,"clearFp");o(this,"clear");const i=B({version:t,requires:"web_app_invoke_custom_method",isTma:n,returns:"task"});this.isSupported=ie("web_app_invoke_custom_method",t),this.deleteItemFp=i((s,a)=>{const u=Array.isArray(s)?s:[s];return d(u.length?r("deleteStorageValues",{keys:u},a):R(void 0),V(()=>{}))}),this.getItemFp=i((s,a)=>d(this.getItemsFp([s],a),V(u=>u[s]||""))),this.getItemsFp=i((s,a)=>d(s.length?r("getStorageValues",{keys:s},a):R({}),V(u=>({...s.reduce((l,c)=>(l[c]="",l),{}),..._e(At(C(),C()),u)})))),this.getKeysFp=i(s=>d(r("getStorageKeys",{},s),V(a=>_e(Tn(C()),a)))),this.setItemFp=i((s,a,u)=>d(r("saveStorageValue",{key:s,value:a},u),V(()=>{}))),this.clearFp=i(s=>d(this.getKeysFp(s),he(this.deleteItemFp))),this.deleteItem=m(this.deleteItemFp),this.getItem=m(this.getItemFp),this.getItems=m(this.getItemsFp),this.getKeys=m(this.getKeysFp),this.setItem=m(this.setItemFp),this.clear=m(this.clearFp)}}const fn=Qe(0);function dn(){return fn.set(fn()+1),fn().toString()}function hs(e,t,n){return pa(e,t,dn(),{...n||{},postEvent:Me})}const _n=Je({invokeCustomMethod:hs}),ou=new ps(d(E(),A,_n));function au({request:e,...t}){return T(n=>d(e("web_app_request_emoji_status_access","emoji_status_access_requested",n),V(r=>r.status)),{...t,requires:"web_app_request_emoji_status_access",returns:"task"})}const fs=au(d(E(),A,Y)),uu=m(fs);function cu({request:e,...t}){return T((n,r)=>d(e("web_app_set_emoji_status",["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:n,duration:(r||{}).duration},...r}),Pe(i=>i&&"error"in i?N(new ts(i.error)):R(void 0))),{...t,requires:"web_app_set_emoji_status",returns:"task"})}const ds=cu(d(E(),Y,A)),lu=m(ds);class _s{constructor({postEvent:t,isTma:n,version:r}){o(this,"isSupported");o(this,"impactOccurredFp");o(this,"impactOccurred");o(this,"notificationOccurredFp");o(this,"notificationOccurred");o(this,"selectionChangedFp");o(this,"selectionChanged");const i="web_app_trigger_haptic_feedback",s=B({requires:i,isTma:n,version:r,returns:"plain"});this.isSupported=ie(i,r),this.impactOccurredFp=s(a=>t(i,{type:"impact",impact_style:a})),this.notificationOccurredFp=s(a=>t(i,{type:"notification",notification_type:a})),this.selectionChangedFp=s(()=>t(i,{type:"selection_change"})),this.impactOccurred=m(this.impactOccurredFp),this.notificationOccurred=m(this.notificationOccurredFp),this.selectionChanged=m(this.selectionChangedFp)}}const pu=new _s(d(E(),z,A));function hu({postEvent:e,...t}){return T(()=>e("web_app_add_to_home_screen"),{...t,requires:"web_app_add_to_home_screen",returns:"either"})}const ms=hu(d(E(),A,z)),fu=m(ms);function du({request:e,...t}){return T(n=>d(e("web_app_check_home_screen","home_screen_checked",n),V(r=>r.status||"unknown")),{...t,requires:"web_app_check_home_screen",returns:"task"})}const bs=du(d(E(),A,Y)),_u=m(bs);class gs{constructor({retrieveInitData:t}){o(this,"_state",W());o(this,"_raw",W());o(this,"state",F(this._state));o(this,"authDate",this.fromState("auth_date"));o(this,"canSendAfter",this.fromState("can_send_after"));o(this,"canSendAfterDate",F(()=>{const t=this.authDate(),n=this.canSendAfter();return n&&t?new Date(t.getTime()+n*1e3):void 0}));o(this,"chat",this.fromState("chat"));o(this,"chatType",this.fromState("chat_type"));o(this,"chatInstance",this.fromState("chat_instance"));o(this,"hash",this.fromState("hash"));o(this,"queryId",this.fromState("query_id"));o(this,"raw",F(this._raw));o(this,"receiver",this.fromState("receiver"));o(this,"signature",this.fromState("signature"));o(this,"startParam",this.fromState("start_param"));o(this,"user",this.fromState("user"));o(this,"restoreFp");o(this,"restore");this.restoreFp=()=>d(t(),Z(Kr(()=>{},({raw:n,obj:r})=>{this._state.set(r),this._raw.set(n)}))),this.restore=X(this.restoreFp)}fromState(t){return F(()=>{const n=this._state();return n?n[t]:void 0})}}const mu=new gs({retrieveInitData(){return d(ci,In("obj",()=>d(Be(),Z(({tgWebAppData:e})=>e?He(e):Te))),In("raw",Gt),Z(({obj:e,raw:t})=>d($a,Jr("obj",()=>e),Jr("raw",()=>t))))}});class vs{constructor({version:t,request:n,isTma:r}){o(this,"isOpened");o(this,"isSupported");o(this,"openSlugFp");o(this,"openSlug");o(this,"openUrlFp");o(this,"openUrl");const i=B({version:t,isTma:r,requires:"web_app_open_invoice",returns:"task"}),s=W(!1),a=()=>{s.set(!1)};this.isSupported=ie("web_app_open_invoice",t),this.isOpened=F(s),this.openSlugFp=i((u,l)=>d(this.isOpened()?N(new ht("Invoice is already opened")):R(void 0),he(()=>(s.set(!0),n("web_app_open_invoice","invoice_closed",{...l,params:{slug:u},capture:c=>u===c.slug}))),nn(c=>(a(),c),c=>(a(),c.status)))),this.openUrlFp=i((u,l)=>{const{hostname:c,pathname:h}=new URL(u,window.location.href);if(c!=="t.me")return N(new ne(`Link has unexpected hostname: ${c}`));const f=h.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return f?this.openSlugFp(f[2],l):N(new ne('Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"'))}),this.openUrl=m(this.openUrlFp),this.openSlug=m(this.openSlugFp)}}const bu=new vs(d(E(),Y,A));function gu({postEvent:e,...t}){return T((n,r={})=>{if(typeof n=="string")try{n=new URL(n)}catch(i){return O(new ne(`"${n.toString()}" is invalid URL`,i))}return e("web_app_open_link",{url:n.toString(),try_browser:r.tryBrowser,try_instant_view:r.tryInstantView})},{...t,returns:"either"})}const ws=gu(d(E(),z)),vu=m(ws);function wu({postEvent:e,version:t,...n}){return T(r=>{const i=r.toString();return i.match(/^https:\/\/t.me\/.+/)?pe("web_app_open_tg_link",Q(t))?(r=new URL(r),e("web_app_open_tg_link",{path_full:r.pathname+r.search})):(window.location.href=i,P(void 0)):O(new ne(`"${i}" is invalid URL`))},{...n,returns:"either"})}const mn=wu(d(E(),z,A)),yu=m(mn);function Cu({openTelegramLink:e,...t}){return T((n,r)=>e("https://t.me/share/url?"+new URLSearchParams({url:n,text:r||""}).toString().replace(/\+/g,"%20")),{...t,returns:"either"})}const ys=Cu({...E(),openTelegramLink:mn}),Fu=m(ys);function Su(e){let t=!1,n,r;return e.available&&(t=!0,n=e.access_requested,r=e.access_granted),{available:t,accessGranted:r||!1,accessRequested:n||!1}}class Cs{constructor({version:t,request:n,postEvent:r,storage:i,isTma:s,isPageReload:a}){o(this,"state");o(this,"isAvailable");o(this,"isAccessGranted");o(this,"isAccessRequested");o(this,"isMounted");o(this,"isSupported");o(this,"openSettingsFp");o(this,"openSettings");o(this,"requestLocationFp");o(this,"requestLocation");o(this,"mountFp");o(this,"mount");o(this,"unmount");const u=new be({initialState:{available:!1,accessGranted:!1,accessRequested:!1},onChange:i.set}),l=new ln({isPageReload:a,restoreState:i.get,onMounted:u.setState,initialState(v){return d(n("web_app_check_location","location_checked",v),V(Su))}}),c={version:t,requires:"web_app_check_location",isTma:s},h=B({...c,returns:"either"}),f=B({...c,returns:"task"}),b=B({...c,returns:"task",isMounted:l.isMounted});this.isAvailable=u.getter("available"),this.isAccessRequested=u.getter("accessRequested"),this.isAccessGranted=u.getter("accessGranted"),this.isSupported=ie("web_app_check_location",t),this.isMounted=l.isMounted,this.state=u.state,this.unmount=l.unmount,this.mountFp=f(l.mount),this.openSettingsFp=h(()=>r("web_app_open_location_settings")),this.requestLocationFp=b(v=>d(n("web_app_request_location","location_requested",v),V(y=>{if(!y.available)return u.setState({available:!1}),null;const{available:w,...g}=y;return g}))),this.mount=m(this.mountFp),this.openSettings=m(this.openSettingsFp),this.requestLocation=m(this.requestLocationFp)}}const ku=new Cs(d(E(),z,A,Y,ge("locationManager")));class Fs{constructor({defaults:t,...n}){o(this,"bgColor");o(this,"hasShineEffect");o(this,"isEnabled");o(this,"isLoaderVisible");o(this,"isVisible");o(this,"isMounted");o(this,"state");o(this,"text");o(this,"textColor");o(this,"showFp");o(this,"show");o(this,"hideFp");o(this,"hide");o(this,"enableFp");o(this,"enable");o(this,"enableShineEffectFp");o(this,"enableShineEffect");o(this,"disableFp");o(this,"disable");o(this,"disableShineEffectFp");o(this,"disableShineEffect");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"setTextColorFp");o(this,"setTextColor");o(this,"setTextFp");o(this,"setText");o(this,"showLoaderFp");o(this,"showLoader");o(this,"hideLoaderFp");o(this,"hideLoader");o(this,"setParamsFp");o(this,"setParams");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");const r=new ft({...n,version:"100",initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"},method:"web_app_setup_main_button",payload:s=>({has_shine_effect:s.hasShineEffect,is_visible:s.isVisible,is_active:s.isEnabled,is_progress_visible:s.isLoaderVisible,text:s.text,color:s.bgColor,text_color:s.textColor})}),i=(s,a)=>{const u=r.stateGetter(s);return F(()=>u()||Q(a))};this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.hasShineEffect=r.stateGetter("hasShineEffect"),this.isEnabled=r.stateGetter("isEnabled"),this.isLoaderVisible=r.stateGetter("isLoaderVisible"),this.text=r.stateGetter("text"),this.isVisible=r.stateGetter("isVisible"),this.isMounted=r.isMounted,this.state=r.state,[this.setBgColor,this.setBgColorFp]=r.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=r.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=r.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=r.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=r.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=r.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=r.stateBoolSetters("isVisible"),this.setParams=r.setState,this.setParamsFp=r.setStateFp,this.onClick=r.onClick,this.onClickFp=r.onClickFp,this.offClick=r.offClick,this.offClickFp=r.offClickFp,this.mount=r.mount,this.mountFp=r.mountFp,this.unmount=r.unmount}}function Ss(e,t,n){return d(cn(e,t),r=>({...r,defaults:n}))}const bn=Qe({});function gn(e,t){document.documentElement.style.setProperty(e,t)}function vn(e){document.documentElement.style.removeProperty(e)}function ks(e){return d(ot(e),Z(t=>Math.sqrt([.299,.587,.114].reduce((n,r,i)=>{const s=parseInt(t.slice(1+i*2,1+(i+1)*2),16);return n+s*s*r},0))<120))}const wn=X(ks);class Es{constructor({initialState:t,onChange:n,offChange:r,isTma:i,storage:s,isPageReload:a}){o(this,"accentTextColor");o(this,"bgColor");o(this,"buttonColor");o(this,"buttonTextColor");o(this,"bottomBarBgColor");o(this,"destructiveTextColor");o(this,"headerBgColor");o(this,"hintColor");o(this,"linkColor");o(this,"secondaryBgColor");o(this,"sectionBgColor");o(this,"sectionHeaderTextColor");o(this,"sectionSeparatorColor");o(this,"subtitleTextColor");o(this,"textColor");o(this,"_isCssVarsBound",W(!1));o(this,"isCssVarsBound",F(this._isCssVarsBound));o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"state");o(this,"isDark",F(()=>{const t=this.bgColor();return!t||wn(t)}));o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");const u=new be({initialState:{},onChange:s.set}),l=v=>{u.setState(v.theme_params)},c=new Ke({initialState:()=>P(Q(t)),isPageReload:a,onMounted(v){u.setState(v),n(l)},onUnmounted(){r(l)},restoreState:s.get}),h={isTma:i,returns:"either"},f=B(h),b=B({...h,isMounted:c.isMounted});this.accentTextColor=u.getter("accent_text_color"),this.bgColor=u.getter("bg_color"),this.buttonColor=u.getter("button_color"),this.buttonTextColor=u.getter("button_text_color"),this.bottomBarBgColor=u.getter("bottom_bar_bg_color"),this.destructiveTextColor=u.getter("destructive_text_color"),this.headerBgColor=u.getter("header_bg_color"),this.hintColor=u.getter("hint_color"),this.linkColor=u.getter("link_color"),this.secondaryBgColor=u.getter("secondary_bg_color"),this.sectionBgColor=u.getter("section_bg_color"),this.sectionHeaderTextColor=u.getter("section_header_text_color"),this.sectionSeparatorColor=u.getter("section_separator_color"),this.subtitleTextColor=u.getter("subtitle_text_color"),this.textColor=u.getter("text_color"),this.state=u.state,this.isMounted=c.isMounted,this.bindCssVarsFp=b(v=>{if(this._isCssVarsBound())return O(new pt);v||(v=g=>`--tg-theme-${Ii(g)}`);const y=g=>{Object.entries(u.state()).forEach(([S,_])=>{_&&g(S,_)})},w=()=>{y((g,S)=>{gn(v(g),S)})};return w(),u.state.sub(w),this._isCssVarsBound.set(!0),P(()=>{y(vn),u.state.unsub(w),this._isCssVarsBound.set(!1)})}),this.mountFp=f(c.mount),this.unmount=c.unmount,this.bindCssVars=m(this.bindCssVarsFp),this.mount=m(this.mountFp)}}const Ze=new Es({...d(E(),ge("themeParams")),offChange(e){ke("theme_changed",e)},onChange(e){ee("theme_changed",e)},initialState:bn}),Eu=new Fs(Ss("mainButton","main_button_pressed",{bgColor:F(()=>Ze.buttonColor()||"#2481cc"),textColor:F(()=>Ze.buttonTextColor()||"#ffffff")}));class $s{constructor({storage:t,isPageReload:n,version:r,postEvent:i,isTma:s,theme:a,onVisibilityChanged:u,offVisibilityChanged:l}){o(this,"isSupported");o(this,"isDark",F(()=>{const t=this.bgColorRgb();return t?wn(t):!1}));o(this,"isActive");o(this,"state");o(this,"isCssVarsBound");o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"bgColor");o(this,"bgColorRgb");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"headerColor");o(this,"headerColorRgb");o(this,"setHeaderColorFp");o(this,"setHeaderColor");o(this,"bottomBarColor");o(this,"bottomBarColorRgb");o(this,"setBottomBarColorFp");o(this,"setBottomBarColor");o(this,"closeFp");o(this,"close");o(this,"readyFp");o(this,"ready");const c=_=>{b.setState({isActive:_.is_visible})},h=_=>{[[this.headerColor,"web_app_set_header_color"],[this.bgColor,"web_app_set_background_color"],[this.bottomBarColor,"web_app_set_bottom_bar_color"]].forEach(([D,M])=>{const U=D();if(!Ue(U)&&(M==="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes(U))){const k=_[U];k&&i(M,{color:k})}})},f=new Ke({initialState(){const _=Q(a);return P({bgColor:_.bg_color||"bg_color",headerColor:_.header_bg_color||"header_bg_color",bottomBarColor:_.bottom_bar_bg_color||"bottom_bar_bg_color",isActive:!0})},isPageReload:n,onMounted:_=>{this.setBgColorFp.ifAvailable(_.bgColor),this.setBottomBarColorFp.ifAvailable(_.bottomBarColor),this.setHeaderColorFp.ifAvailable(_.headerColor),u(c),a.sub(h),b.setState(_)},onUnmounted(){l(c),a.unsub(h)},restoreState:t.get});this.isMounted=f.isMounted,this.mountFp=T(()=>{const _=()=>{};return d(f.mount(),Re(_,_))},{isTma:s,returns:"plain"}),this.mount=m(this.mountFp),this.unmount=f.unmount;const b=new be({initialState:{bgColor:"bg_color",bottomBarColor:"bottom_bar_bg_color",headerColor:"bg_color",isActive:!1},onChange:t.set});this.state=b.state;const v=_=>Ue(_)?_:Q(a)[_],y=_=>F(()=>v(_()));this.isActive=b.getter("isActive"),this.isSupported=F(()=>["web_app_set_header_color","web_app_set_background_color","web_app_set_bottom_bar_color"].some(_=>pe(_,Q(r))));const w=W(!1);this.isCssVarsBound=F(w),this.bindCssVarsFp=T(_=>{if(w())return O(new pt);const[D,M]=st(()=>{w.set(!1)}),U=(k,L)=>{const I=()=>{gn(k,L()||null)};I(),D(L.sub(I),vn.bind(null,k))};return _||(_=k=>`--tg-${jn(k)}`),U(_("bgColor"),this.bgColorRgb),U(_("bottomBarColor"),this.bottomBarColorRgb),U(_("headerColor"),this.headerColorRgb),w.set(!0),P(M)},{isTma:s,returns:"either",isMounted:this.isMounted}),this.bindCssVars=m(this.bindCssVarsFp);const g=_=>{const D=b.getter(_),M=y(D),U={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[_],k=T(L=>{if(L===D())return P(void 0);if(U==="web_app_set_header_color"&&(L==="bg_color"||L==="secondary_bg_color"))return i("web_app_set_header_color",{color_key:L});const I=v(L);return d(I?i(U,{color:I}):O(new ss(L)),Z(()=>{b.setState({[_]:I})}))},{isTma:s,version:r,requires:U,isMounted:this.isMounted,returns:"either",supports:_==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:Ue}}:void 0});return[D,M,m(k),k]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=g("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=g("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=g("bottomBarColor");const S=B({isTma:s,returns:"either"});this.closeFp=S(_=>i("web_app_close",{return_back:_})),this.close=m(this.closeFp),this.readyFp=S(()=>i("web_app_ready")),this.ready=m(this.readyFp)}}const As=new $s({...d(E(),z,A,ge("miniApp")),offVisibilityChanged(e){ke("visibility_changed",e)},onVisibilityChanged(e){ee("visibility_changed",e)},theme:Ze.state});function $u(e){const t=e.message.trim(),n=(e.title||"").trim(),r=e.buttons||[];if(n.length>64)return O(new ne(`Invalid title: ${n}`));if(!t||t.length>256)return O(new ne(`Invalid message: ${t}`));if(r.length>3)return O(new ne(`Invalid buttons count: ${r.length}`));const i=[];if(!r.length)i.push({type:"close",id:""});else for(let s=0;s<r.length;s++){const a=r[s],u=a.id||"";if(u.length>64)return O(new ne(`Button with index ${s} has invalid id: ${u}`));if(!a.type||a.type==="default"||a.type==="destructive"){const l=a.text.trim();if(!l||l.length>64)return O(new ne(`Button with index ${s} has invalid text: ${l}`));i.push({type:a.type,text:l,id:u})}else i.push({type:a.type,id:u})}return P({title:n,message:t,buttons:i})}class Is{constructor({version:t,isTma:n,request:r}){o(this,"isOpened");o(this,"isSupported");o(this,"showFp");o(this,"show");const i=W(!1),s=()=>{i.set(!1)},a=B({version:t,isTma:n,requires:"web_app_open_popup",returns:"task"});this.isSupported=ie("web_app_open_popup",t),this.isOpened=F(i),this.showFp=a(u=>d(this.isOpened()?N(new ht("A popup is already opened")):R(void 0),Pe(()=>Yr($u(u))),he(l=>(i.set(!0),r("web_app_open_popup","popup_closed",{...u,params:l}))),nn(l=>(s(),l),l=>(s(),l.button_id)))),this.show=m(this.showFp)}}const Au=new Is(d(E(),Y,A));function Iu({request:e,...t}){return T(n=>d(e("web_app_request_phone","phone_requested",n),V(r=>r.status)),{...t,requires:"web_app_request_phone",returns:"task"})}const yn=Iu(d(E(),A,Y)),qu=m(yn);function Bu({invokeCustomMethod:e,requestPhoneAccess:t,...n}){const r=a=>d(e("getRequestedContact",{},{...a,timeout:(a||{}).timeout||5e3}),Pe(u=>{const l=qt(C(),u);if(!l.success)return N(new ze(u,l.issues));if(!l.output)return R(void 0);const c=qt(Rt(j({contact:me(j({user_id:de(),phone_number:C(),first_name:C(),last_name:$(C())})),auth_date:se(C(),ue(h=>new Date(Number(h)*1e3)),tt()),hash:C()})),l.output);return c.success?R({raw:l.output,parsed:c.output}):N(new ze(l.output,c.issues))})),i=a=>d(r(a),xa(u=>ze.is(u)?O(u):P(void 0),u=>P(u))),s=a=>De(async(u,l,c)=>{let h=50;for(;!c.isRejected;){const f=await i(c)();if(f._tag==="Left")return l(f.left);if(f.right)return u(f.right);await new Promise(b=>setTimeout(b,h)),h+=50}},a);return T(a=>De.fn(u=>d(i(u),he(l=>l?R(l):d(t(u),Pe(c=>c==="sent"?s(u):N(new sn("User denied access")))))),a),{...n,returns:"task",requires:"web_app_request_phone"})}function Tu({requestContact:e,...t}){return T(e,{...t,returns:"task",requires:"web_app_request_phone"})}const Cn=Bu({...d(E(),_n,A),requestPhoneAccess:yn}),Pu=m(Cn),qs=Tu({...d(E(),A),requestContact(e){return d(Cn(e),V(t=>t.parsed))}}),Mu=m(qs);function Lu({request:e,...t}){return T(n=>d(e("web_app_request_write_access","write_access_requested",n),V(r=>r.status)),{...t,requires:"web_app_request_write_access",returns:"task"})}const Bs=Lu(d(E(),A,Y)),Vu=m(Bs);class Ts{constructor({version:t,onClosed:n,onTextReceived:r,isTma:i,postEvent:s}){o(this,"isOpened");o(this,"isSupported");o(this,"captureFp");o(this,"capture");o(this,"closeFp");o(this,"close");o(this,"openFp");o(this,"open");const a={version:t,requires:"web_app_open_scan_qr_popup",isTma:i},u=B({...a,returns:"either"}),l=B({...a,returns:"task"}),c=W(!1),h=()=>{c.set(!1)};this.isSupported=ie("web_app_open_scan_qr_popup",t),this.isOpened=F(c),this.captureFp=l(f=>{let b;return d(this.openFp({...f,onCaptured:v=>{f.capture(v)&&(b=v,this.close())}}),V(()=>b))}),this.closeFp=u(()=>d(s("web_app_close_scan_qr_popup"),Z(h))),this.openFp=l(f=>d(this.isOpened()?N(new ht("The QR Scanner is already opened")):async()=>s("web_app_open_scan_qr_popup",{text:f.text}),Pe(()=>{const[b,v]=st(),y=w=>(v(),w);return d(De(w=>{b(n(w),r(f.onCaptured))},f),nn(y,y))}))),this.open=m(this.openFp),this.capture=m(this.captureFp),this.close=m(this.closeFp)}}const Ru=new Ts({...d(E(),z,A),onClosed(e){return ee("scan_qr_popup_closed",e)},onTextReceived(e){return ee("qr_text_received",t=>{e(t.data)})}});class Ps{constructor({defaults:t,...n}){o(this,"isSupported");o(this,"position");o(this,"bgColor");o(this,"hasShineEffect");o(this,"isEnabled");o(this,"isLoaderVisible");o(this,"isVisible");o(this,"isMounted");o(this,"state");o(this,"text");o(this,"textColor");o(this,"showFp");o(this,"show");o(this,"hideFp");o(this,"hide");o(this,"enableFp");o(this,"enable");o(this,"enableShineEffectFp");o(this,"enableShineEffect");o(this,"disableFp");o(this,"disable");o(this,"disableShineEffectFp");o(this,"disableShineEffect");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"setTextColorFp");o(this,"setTextColor");o(this,"setTextFp");o(this,"setText");o(this,"setPositionFp");o(this,"setPosition");o(this,"showLoaderFp");o(this,"showLoader");o(this,"hideLoaderFp");o(this,"hideLoader");o(this,"setParamsFp");o(this,"setParams");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");const r=new ft({...n,initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Cancel",position:"left"},method:"web_app_setup_secondary_button",payload:s=>({has_shine_effect:s.hasShineEffect,is_visible:s.isVisible,is_active:s.isEnabled,is_progress_visible:s.isLoaderVisible,text:s.text,color:s.bgColor,text_color:s.textColor,position:s.position})}),i=(s,a)=>{const u=r.stateGetter(s);return F(()=>u()||Q(a))};this.isSupported=ie("web_app_setup_secondary_button",n.version),this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.position=r.stateGetter("position"),this.hasShineEffect=r.stateGetter("hasShineEffect"),this.isEnabled=r.stateGetter("isEnabled"),this.isLoaderVisible=r.stateGetter("isLoaderVisible"),this.text=r.stateGetter("text"),this.isVisible=r.stateGetter("isVisible"),this.isMounted=r.isMounted,this.state=r.state,[this.setPosition,this.setPositionFp]=r.stateSetters("position"),[this.setBgColor,this.setBgColorFp]=r.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=r.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=r.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=r.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=r.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=r.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=r.stateBoolSetters("isVisible"),this.setParams=r.setState,this.setParamsFp=r.setStateFp,this.onClick=r.onClick,this.onClickFp=r.onClickFp,this.offClick=r.offClick,this.offClickFp=r.offClickFp,this.mount=r.mount,this.mountFp=r.mountFp,this.unmount=r.unmount}}const Ou=new Ps(Ss("secondaryButton","secondary_button_pressed",{bgColor:F(()=>As.bottomBarColorRgb()||"#000000"),textColor:F(()=>Ze.buttonColor()||"#2481cc")}));class Ms{constructor(t){o(this,"isVisible");o(this,"isMounted");o(this,"isSupported");o(this,"hideFp");o(this,"hide");o(this,"showFp");o(this,"show");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const n=new ft({...t,method:"web_app_setup_settings_button",payload:r=>({is_visible:r.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}const ju=new Ms(cn("settingsButton","settings_button_pressed"));class Ls{constructor({postEvent:t,storage:n,isTma:r,isPageReload:i,version:s}){o(this,"isSupported");o(this,"isVerticalEnabled");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"disableVerticalFp");o(this,"disableVertical");o(this,"enableVerticalFp");o(this,"enableVertical");const a=new be({initialState:{isVerticalEnabled:!1},onChange(b){n.set(b)}}),u=new Ke({initialState:{isVerticalEnabled:!1},isPageReload:i,onMounted:a.setState,restoreState:n.get}),l={requires:"web_app_setup_swipe_behavior",isTma:r,version:s},c=B({...l,returns:"plain"}),h=B({...l,isMounted:u.isMounted,returns:"either"}),f=b=>{const v={isVerticalEnabled:b};return a.hasDiff(v)?d(t("web_app_setup_swipe_behavior",{allow_vertical_swipe:b}),Z(()=>{a.setState(v)})):P(void 0)};this.isSupported=ie("web_app_setup_swipe_behavior",s),this.isVerticalEnabled=a.getter("isVerticalEnabled"),this.isMounted=u.isMounted,this.disableVerticalFp=h(()=>f(!1)),this.enableVerticalFp=h(()=>f(!0)),this.mountFp=c(()=>{const b=()=>{};return d(u.mount(),Re(b,b))}),this.unmount=u.unmount,this.disableVertical=m(this.disableVerticalFp),this.enableVertical=m(this.enableVerticalFp),this.mount=m(this.mountFp)}}const Du=new Ls(d(E(),z,A,ge("swipeBehavior")));async function Uu(e){try{const{clipboard:n}=navigator;if(n)return await n.writeText(e)}catch{}const t=document.createElement("textarea");t.value=e,t.style.top="0",t.style.left="0",t.style.position="fixed",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}finally{document.body.removeChild(t)}}function xu({request:e,...t}){return T((n,r,i)=>d(e("web_app_request_file_download","file_download_requested",{...i,params:{url:n,file_name:r}}),he(s=>s.status==="downloading"?R(void 0):N(new sn("User denied the action")))),{...t,requires:"web_app_request_file_download",returns:"task"})}const Vs=xu(d(E(),Y,A)),Gu=m(Vs);function Wu({invokeCustomMethod:e,...t}){return T(n=>d(e("getCurrentTime",{},n),he(r=>{const i=qt(se(de(),Ft(),ue(s=>new Date(s*1e3)),tt()),r);return i.success?R(i.output):N(new ze(r,i.issues))})),{...t,requires:"web_app_invoke_custom_method",returns:"task"})}const Rs=Wu(d(E(),_n,A)),Hu=m(Rs);function Nu({postEvent:e,...t}){return T(()=>e("web_app_hide_keyboard"),{...t,returns:"either",requires:"web_app_hide_keyboard"})}const Os=Nu(d(E(),z,A)),zu=m(Os);function Ku({request:e,createRequestId:t,...n}){return T(r=>{const i=t();return d(e("web_app_read_text_from_clipboard","clipboard_text_received",{...r,params:{req_id:i},capture:Gr(i)}),V(({data:s=null})=>s))},{...n,requires:"web_app_read_text_from_clipboard",returns:"task"})}const js=Ku({...d(E(),A,Y),createRequestId:dn}),Ju=m(js);function Ds(e){const t={},n=e.match(/Telegram-Android(?:\/([^ ]+))?(?: (\([^)]+\))?|$)/);if(n){const[,r,i]=n;r&&(t.appVersion=r),i&&i.slice(1,i.length-1).split(";").forEach(s=>{const[a,u]=s.trim().split(" ");if(a==="Android")t.androidVersion=u;else if(a==="SDK"){const l=parseInt(u,10);l&&(t.sdkVersion=l)}else u?(t.manufacturer=a,t.model=u):t.performanceClass=a})}return t}function Qu(){return Ds(navigator.userAgent)}function Zu({postEvent:e,...t}){return T(n=>{const{size:r}=new Blob([n]);return!r||r>4096?O(new ne(r?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data")):e("web_app_data_send",{data:n})},{...t,returns:"either"})}const Us=Zu(d(E(),z)),Yu=m(Us);function Xu({request:e,...t}){return T((n,r)=>d(e("web_app_send_prepared_message",["prepared_message_failed","prepared_message_sent"],{...r,params:{id:n}}),he(i=>i&&"error"in i?N(new rs(i.error)):R(void 0))),{...t,requires:"web_app_send_prepared_message",returns:"task"})}const xs=Xu(d(E(),Y,A)),ec=m(xs);function tc({postEvent:e,...t}){return T((n,r={})=>e("web_app_share_to_story",{text:r.text,media_url:n,widget_link:r.widgetLink}),{...t,requires:"web_app_share_to_story",returns:"either"})}const Gs=tc(d(E(),z,A)),nc=m(Gs),Fn=Qe(!1);function rc({isInlineMode:e,postEvent:t,...n}){return T((r,i)=>t("web_app_switch_inline_query",{query:r,chat_types:i||[]}),{...n,requires:{every:["web_app_switch_inline_query",()=>Q(e)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}const Ws=rc({...d(E(),z,A),isInlineMode:Fn}),sc=m(Ws);class Hs{constructor({storage:t,isPageReload:n,onContentSafeAreaInsetsChanged:r,onSafeAreaInsetsChanged:i,onViewportChanged:s,onFullscreenChanged:a,offContentSafeAreaInsetsChanged:u,offFullscreenChanged:l,offSafeAreaInsetsChanged:c,offViewportChanged:h,request:f,isViewportStable:b,isFullscreen:v,isTma:y,version:w,postEvent:g}){o(this,"state");o(this,"height");o(this,"stableHeight");o(this,"width");o(this,"isExpanded");o(this,"isStable",F(()=>this.height()===this.stableHeight()));o(this,"contentSafeAreaInsets");o(this,"contentSafeAreaInsetTop");o(this,"contentSafeAreaInsetLeft");o(this,"contentSafeAreaInsetRight");o(this,"contentSafeAreaInsetBottom");o(this,"safeAreaInsets");o(this,"safeAreaInsetTop");o(this,"safeAreaInsetLeft");o(this,"safeAreaInsetRight");o(this,"safeAreaInsetBottom");o(this,"isFullscreen");o(this,"requestFullscreenFp");o(this,"requestFullscreen");o(this,"exitFullscreenFp");o(this,"exitFullscreen");o(this,"isCssVarsBound");o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"expandFp");o(this,"expand");const S={top:0,right:0,left:0,bottom:0},_=new be({initialState:{contentSafeAreaInsets:S,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:S,stableHeight:0,width:0},onChange:t.set}),D=q=>{_.setState({isExpanded:q.is_expanded,height:q.height,width:q.width,stableHeight:q.is_state_stable?q.height:void 0})},M=q=>{_.setState({isFullscreen:q.is_fullscreen})},U=q=>{_.setState({safeAreaInsets:q})},k=q=>{_.setState({contentSafeAreaInsets:q})},L=new ln({initialState(q){const $e=fe=>()=>{const[ve,re]=fe==="safe-area"?["web_app_request_safe_area","safe_area_changed"]:["web_app_request_content_safe_area","content_safe_area_changed"];return pe(ve,Q(w))?f(ve,re,q):R({top:0,left:0,right:0,bottom:0})},G=fe=>()=>typeof fe=="boolean"?R(fe):Yr(fe());return d(Qa,lt("safeAreaInsets",$e("safe-area")),lt("contentSafeAreaInsets",$e("content-safe-area")),lt("isFullscreen",G(v)),lt("isViewportStable",G(b)),Pe(({isViewportStable:fe,...ve})=>fe?R({...ve,height:window.innerHeight,isExpanded:!0,stableHeight:window.innerHeight,width:window.innerWidth}):d(f("web_app_request_viewport","viewport_changed",q),V(re=>({...ve,height:re.height,isExpanded:re.is_expanded,stableHeight:re.is_state_stable?re.height:0,width:re.width})))))},isPageReload:n,onMounted(q){s(D),a(M),i(U),r(k),_.setState(q)},onUnmounted(){h(D),l(M),c(U),u(k)},restoreState:t.get}),I=q=>F(()=>this.safeAreaInsets()[q]),x=q=>F(()=>this.contentSafeAreaInsets()[q]);this.state=_.state,this.height=_.getter("height"),this.stableHeight=_.getter("stableHeight"),this.width=_.getter("width"),this.isExpanded=_.getter("isExpanded"),this.safeAreaInsets=_.getter("safeAreaInsets"),this.safeAreaInsetTop=I("top"),this.safeAreaInsetBottom=I("bottom"),this.safeAreaInsetLeft=I("left"),this.safeAreaInsetRight=I("right"),this.contentSafeAreaInsets=_.getter("contentSafeAreaInsets"),this.contentSafeAreaInsetTop=x("top"),this.contentSafeAreaInsetBottom=x("bottom"),this.contentSafeAreaInsetLeft=x("left"),this.contentSafeAreaInsetRight=x("right");const Le=B({isTma:y,returns:"task"}),Ye=B({isTma:y,returns:"either"}),uc=B({isTma:y,requires:"web_app_request_fullscreen",version:w,returns:"task"}),zs=q=>uc($e=>d(f(q?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],$e),he(G=>"error"in G&&G.error!=="ALREADY_FULLSCREEN"?N(new ns(G.error)):(_.setState({isFullscreen:"is_fullscreen"in G?G.is_fullscreen:!0}),R(void 0)))));this.isMounted=L.isMounted,this.mountFp=Le(L.mount),this.mount=m(this.mountFp),this.isFullscreen=_.getter("isFullscreen"),this.requestFullscreenFp=zs(!0),this.requestFullscreen=m(this.requestFullscreenFp),this.exitFullscreenFp=zs(!1),this.exitFullscreen=m(this.exitFullscreenFp);const dt=W(!1);this.isCssVarsBound=F(dt),this.bindCssVarsFp=Ye(q=>{if(dt())return O(new pt);q||(q=G=>`--tg-viewport-${jn(G)}`);const $e=[["height",this.height],["stableHeight",this.stableHeight],["width",this.width],["safeAreaInsetTop",this.safeAreaInsetTop],["safeAreaInsetBottom",this.safeAreaInsetBottom],["safeAreaInsetLeft",this.safeAreaInsetLeft],["safeAreaInsetRight",this.safeAreaInsetRight],["contentSafeAreaInsetTop",this.contentSafeAreaInsetTop],["contentSafeAreaInsetBottom",this.contentSafeAreaInsetBottom],["contentSafeAreaInsetLeft",this.contentSafeAreaInsetLeft],["contentSafeAreaInsetRight",this.contentSafeAreaInsetRight]].reduce((G,[fe,ve])=>{const re=q(fe);if(re){const Ks=()=>{gn(re,`${ve()}px`)};G.push({update:Ks,removeListener:ve.sub(Ks),cssVar:re})}return G},[]);return $e.forEach(G=>{G.update()}),dt.set(!0),P(()=>{$e.forEach(G=>{G.removeListener(),vn(G.cssVar)}),dt.set(!1)})}),this.bindCssVars=m(this.bindCssVarsFp),this.expandFp=Ye(()=>g("web_app_expand")),this.expand=m(this.expandFp)}}function ic(){const e=s=>({on:a=>{ee(s,a)},off:a=>{ke(s,a)}}),t=e("viewport_changed"),n=e("fullscreen_changed"),r=e("safe_area_changed"),i=e("content_safe_area_changed");return new Hs({...d(E(),ge("viewport"),A,z,Y),isFullscreen(){return d(Be(),Z(s=>!!s.tgWebAppFullscreen))},isViewportStable(){return d(Be(),Z(s=>["macos","tdesktop","unigram","webk","weba","web"].includes(s.tgWebAppPlatform)))},offContentSafeAreaInsetsChanged:i.off,offFullscreenChanged:n.off,offSafeAreaInsetsChanged:r.off,offViewportChanged:t.off,onContentSafeAreaInsetsChanged:i.on,onFullscreenChanged:n.on,onSafeAreaInsetsChanged:r.on,onViewportChanged:t.on})}const oc=ic();function Ns(e={}){const{version:t,isInlineMode:n,themeParams:r}=e;if(t&&typeof n=="boolean"&&r)un.set(t),Fn.set(n),bn.set(r);else{const u=d(Be(),An(l=>l,l=>{un.set(t||l.tgWebAppVersion),Fn.set(typeof n=="boolean"?n:!!l.tgWebAppBotInline),bn.set(r||l.tgWebAppThemeParams)}));if(u)return O(u)}e.postEvent&&os.set(e.postEvent);const[i,s]=st(ee("reload_iframe",()=>{le().log("Received a request to reload the page"),as("iframe_will_reload"),window.location.reload()})),{acceptCustomStyles:a=!0}=e;if(a){const u=document.createElement("style");u.id="telegram-custom-styles",document.head.appendChild(u),i(ee("set_custom_style",l=>{u.innerHTML=l}),()=>{document.head.removeChild(u)})}return d(Me("iframe_ready",{reload_supported:!0}),Z(()=>(le().log("The package was initialized"),s)))}const ac=X(Ns);return p.AccessDeniedError=sn,p.BackButton=is,p.Biometry=cs,p.CSSVarsBoundError=pt,p.CancelledError=Rn,p.ClosingBehavior=ls,p.CloudStorage=ps,p.ConcurrentCallError=ht,p.FullscreenFailedError=ns,p.FunctionUnavailableError=es,p.HapticFeedback=_s,p.InitData=gs,p.InvalidArgumentsError=ne,p.InvalidEnvError=Ya,p.InvalidLaunchParamsError=Br,p.Invoice=vs,p.InvokeCustomMethodFailedError=Pr,p.LaunchParamsRetrieveError=qr,p.LocationManager=Cs,p.MainButton=Fs,p.MethodParameterUnsupportedError=Ir,p.MethodUnsupportedError=Ar,p.MiniApp=$s,p.NotAvailableError=Xr,p.Popup=Is,p.QrScanner=Ts,p.SecondaryButton=Ps,p.SetEmojiStatusError=ts,p.SettingsButton=Ms,p.ShareMessageError=rs,p.SwipeBehavior=Ls,p.ThemeParams=Es,p.TimeoutError=Tt,p.UnknownEnvError=Tr,p.UnknownThemeParamsKeyError=ss,p.ValidationError=ze,p.Viewport=Hs,p.addToHomeScreen=fu,p.addToHomeScreenFp=ms,p.applyPolyfills=ha,p.backButton=nu,p.biometry=su,p.checkHomeScreenStatus=_u,p.checkHomeScreenStatusFp=bs,p.closingBehavior=iu,p.cloudStorage=ou,p.copyTextToClipboard=Uu,p.createLogger=xn,p.createPostEvent=la,p.createRequestId=dn,p.createStartParam=_a,p.createStartParamFp=Nr,p.debug=Ur,p.decodeBase64Url=fa,p.decodeBase64UrlFp=Qt,p.decodeStartParam=ma,p.decodeStartParamFp=zr,p.deepSnakeToCamelObjKeys=Pt,p.downloadFile=Gu,p.downloadFileFp=Vs,p.emitEvent=ut,p.encodeBase64Url=Zt,p.getCurrentTime=Hu,p.getCurrentTimeFp=Rs,p.getReleaseVersion=Jt,p.hapticFeedback=pu,p.hideKeyboard=zu,p.hideKeyboardFp=Os,p.init=ac,p.initData=mu,p.initFp=Ns,p.invoice=bu,p.invokeCustomMethod=hs,p.isAnyRGB=ir,p.isColorDark=wn,p.isColorDarkFp=ks,p.isRGB=Ue,p.isRGBA=sr,p.isRGBAShort=rr,p.isRGBShort=nr,p.isSafeToCreateStartParam=ba,p.isTMA=aa,p.isTMAFp=Kt,p.locationManager=ku,p.logger=le,p.mainButton=Eu,p.miniApp=As,p.mockTelegramEnv=ua,p.off=ke,p.offAll=ta,p.on=ee,p.openLink=vu,p.openLinkFp=ws,p.openTelegramLink=yu,p.openTelegramLinkFp=mn,p.parseInitDataQuery=ho,p.parseInitDataQueryFp=pr,p.parseLaunchParamsQuery=hr,p.parseLaunchParamsQueryFp=at,p.popup=Au,p.postEvent=as,p.postEventFp=Me,p.qrScanner=Ru,p.readTextFromClipboard=Ju,p.readTextFromClipboardFp=js,p.request=ru,p.requestContact=Mu,p.requestContactComplete=Pu,p.requestContactCompleteFp=Cn,p.requestContactFp=qs,p.requestEmojiStatusAccess=uu,p.requestEmojiStatusAccessFp=fs,p.requestFp=hn,p.requestPhoneAccess=qu,p.requestPhoneAccessFp=yn,p.requestWriteAccess=Vu,p.requestWriteAccessFp=Bs,p.retrieveAndroidDeviceData=Qu,p.retrieveAndroidDeviceDataFrom=Ds,p.retrieveLaunchParams=Jo,p.retrieveLaunchParamsFp=Be,p.retrieveRawInitData=Qo,p.retrieveRawInitDataFp=Gt,p.retrieveRawLaunchParams=Zo,p.retrieveRawLaunchParamsFp=We,p.secondaryButton=Ou,p.sendData=Yu,p.sendDataFp=Us,p.serializeInitDataQuery=dr,p.serializeLaunchParamsQuery=_r,p.setDebug=ra,p.setEmojiStatus=lu,p.setEmojiStatusFp=ds,p.setTargetOrigin=sa,p.settingsButton=ju,p.shareMessage=ec,p.shareMessageFp=xs,p.shareStory=nc,p.shareStoryFp=Gs,p.shareURL=Fu,p.shareURLFp=ys,p.supports=pe,p.swipeBehavior=Du,p.switchInlineQuery=sc,p.switchInlineQueryFp=Ws,p.targetOrigin=xr,p.themeParams=Ze,p.toRGB=oo,p.toRGBFp=ar,p.toRGBFull=ao,p.toRGBFullFp=ot,p.viewport=oc,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"}),p}({});
1
+ var hc=Object.defineProperty;var fc=(p,oe,ye)=>oe in p?hc(p,oe,{enumerable:!0,configurable:!0,writable:!0,value:ye}):p[oe]=ye;var o=(p,oe,ye)=>fc(p,typeof oe!="symbol"?oe+"":oe,ye);this.tmajs=this.tmajs||{};this.tmajs.sdk=function(p){"use strict";var oe=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function ye(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function d(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Re=function(e,t){var n=typeof e=="number"?function(r){return r.length>=e}:e;return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,oe([i],r,!1))}}},Qs={_tag:"None"},Zs=function(e){return{_tag:"Some",value:e}},Ys=function(e){return e._tag==="Left"},kn=function(e){return{_tag:"Left",left:e}},En=function(e){return{_tag:"Right",right:e}},mt={};function Xs(e,t){return function(n){return function(r){return e.ap(e.map(r,function(i){return function(s){return t.ap(i,s)}}),n)}}}function ei(e,t){return function(n){return function(r){return e.map(r,function(i){return t.map(i,n)})}}}function bt(e){return function(t,n){return function(r){return e.chain(r,function(i){return e.map(n(i),function(s){var a;return Object.assign({},i,(a={},a[t]=s,a))})})}}}var D=kn,P=En,ti=Re(2,function(e,t){return Ce(e)?e:t(e.right)}),gt=function(e,t){return d(e,Z(t))},$n=function(e,t){return d(e,ii(t))},wt="Either",Z=function(e){return function(t){return Ce(t)?t:P(e(t.right))}},ni={URI:wt,map:gt},ri=P,si=function(e){return function(t){return Ce(t)?t:Ce(e)?e:P(t.right(e.right))}},ii=si,oi={URI:wt,map:gt,ap:$n},ai={URI:wt,map:gt,ap:$n,chain:ti},ui=function(e,t){return function(n){return Ce(n)?D(e(n.left)):P(t(n.right))}},Ce=Ys,An=function(e,t){return function(n){return Ce(n)?e(n.left):t(n.right)}},Oe=An,ci=function(e,t){try{return P(e())}catch(n){return D(t(n))}},li=ri(mt),pi=bt(ai),In=pi;let Ae;function hi(e,t){Ae?Ae.set(e,t):t()}function Xe(e){if(Ae)return e();Ae=new Map;try{e()}finally{Ae.forEach(t=>t()),Ae=void 0}}function U(e,t){t||(t={});const n=t.equals||Object.is;let r=[],i=e;const s=c=>{if(!n(i,c)){const h=i;i=c,hi(l,()=>{[...r].forEach(([f,b])=>{f(c,h),b&&u(f,!0)})})}};function a(c){const h=typeof c!="object"?{once:c}:c;return{once:h.once||!1,signal:h.signal||!1}}const u=(c,h)=>{const f=a(h),b=r.findIndex(([v,F])=>v===c&&F.once===f.once&&F.signal===f.signal);b>=0&&r.splice(b,1)},l=Object.assign(function(){return fi(l),i},{destroy(){r=[]},set:s,reset(){s(e)},sub(c,h){return r.push([c,a(h)]),()=>u(c,h)},unsub:u,unsubAll(){r=r.filter(c=>c[1].signal)}});return l}const je=[];function fi(e){je.length&&je[je.length-1].add(e)}function C(e,t){let n=new Set,r;function i(){return r||(r=U(a(),t))}function s(){i().set(a())}function a(){n.forEach(c=>{c.unsub(s,{signal:!0})});const u=new Set;let l;je.push(u);try{l=e()}finally{je.pop()}return u.forEach(c=>{c.sub(s,{signal:!0})}),n=u,l}return Object.assign(function(){return i()()},{destroy(){i().destroy()},sub(...u){return i().sub(...u)},unsub(...u){i().unsub(...u)},unsubAll(...u){i().unsubAll(...u)}})}var ae;function vt(e){return{lang:(e==null?void 0:e.lang)??(ae==null?void 0:ae.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(ae==null?void 0:ae.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(ae==null?void 0:ae.abortPipeEarly)}}var yt;function di(e){return yt==null?void 0:yt.get(e)}var Ct;function _i(e){return Ct==null?void 0:Ct.get(e)}var Ft;function mi(e,t){var n;return(n=Ft==null?void 0:Ft.get(e))==null?void 0:n.get(t)}function bi(e){var n,r;const t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&((r=(n=Object.getPrototypeOf(e))==null?void 0:n.constructor)==null?void 0:r.name))??"null":t}function K(e,t,n,r,i){const s=i&&"input"in i?i.input:n.value,a=(i==null?void 0:i.expected)??e.expects??null,u=(i==null?void 0:i.received)??bi(s),l={kind:e.kind,type:e.type,input:s,expected:a,received:u,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${u}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??mi(e.reference,l.lang)??(c?_i(l.lang):null)??r.message??di(l.lang);h!==void 0&&(l.message=typeof h=="function"?h(l):h),c&&(n.typed=!1),n.issues?n.issues.push(l):n.issues=[l]}function J(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},vt())}}}function qn(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function gi(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}var wi=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function et(e,t){return{kind:"validation",type:"check",reference:et,async:!1,expects:null,requirement:e,message:t,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&K(this,"input",n,r),n}}}function St(e){return{kind:"validation",type:"integer",reference:St,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&K(this,"integer",t,n),t}}}function ue(e){return{kind:"transformation",type:"transform",reference:ue,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function vi(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}function kt(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function Et(e,t){return!e["~run"]({value:t},{abortEarly:!0}).issues}function Tn(){return{kind:"schema",type:"any",reference:Tn,expects:"any",async:!1,get"~standard"(){return J(this)},"~run"(e){return e.typed=!0,e}}}function Bn(e,t){return{kind:"schema",type:"array",reference:Bn,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){var s;const i=n.value;if(Array.isArray(i)){n.typed=!0,n.value=[];for(let a=0;a<i.length;a++){const u=i[a],l=this.item["~run"]({value:u},r);if(l.issues){const c={type:"array",origin:"value",input:i,key:a,value:u};for(const h of l.issues)h.path?h.path.unshift(c):h.path=[c],(s=n.issues)==null||s.push(h);if(n.issues||(n.issues=l.issues),r.abortEarly){n.typed=!1;break}}l.typed||(n.typed=!1),n.value.push(l.value)}}else K(this,"type",n,r);return n}}}function Fe(e){return{kind:"schema",type:"boolean",reference:Fe,expects:"boolean",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:K(this,"type",t,n),t}}}function tt(e){return{kind:"schema",type:"date",reference:tt,expects:"Date",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return t.value instanceof Date?isNaN(t.value)?K(this,"type",t,n,{received:'"Invalid Date"'}):t.typed=!0:K(this,"type",t,n),t}}}function $t(e){return{kind:"schema",type:"function",reference:$t,expects:"Function",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="function"?t.typed=!0:K(this,"type",t,n),t}}}function At(e,t){return{kind:"schema",type:"instance",reference:At,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){return n.value instanceof this.class?n.typed=!0:K(this,"type",n,r),n}}}function x(e,t){return{kind:"schema",type:"loose_object",reference:x,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){var s;const i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(const a in this.entries){const u=this.entries[a];if(a in i||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){const l=a in i?i[a]:kt(u),c=u["~run"]({value:l},r);if(c.issues){const h={type:"object",origin:"value",input:i,key:a,value:l};for(const f of c.issues)f.path?f.path.unshift(h):f.path=[h],(s=n.issues)==null||s.push(f);if(n.issues||(n.issues=c.issues),r.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value[a]=c.value}else if(u.fallback!==void 0)n.value[a]=vi(u);else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(K(this,"key",n,r,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:i,key:a,value:i[a]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly)for(const a in i)qn(i,a)&&!(a in this.entries)&&(n.value[a]=i[a])}else K(this,"type",n,r);return n}}}function Ie(e,t){return{kind:"schema",type:"nullish",reference:Ie,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return J(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=kt(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function de(e){return{kind:"schema",type:"number",reference:de,expects:"number",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:K(this,"type",t,n),t}}}function $(e,t){return{kind:"schema",type:"optional",reference:$,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return J(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=kt(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function It(e,t,n){return{kind:"schema",type:"record",reference:It,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return J(this)},"~run"(r,i){var a,u;const s=r.value;if(s&&typeof s=="object"){r.typed=!0,r.value={};for(const l in s)if(qn(s,l)){const c=s[l],h=this.key["~run"]({value:l},i);if(h.issues){const b={type:"object",origin:"key",input:s,key:l,value:c};for(const v of h.issues)v.path=[b],(a=r.issues)==null||a.push(v);if(r.issues||(r.issues=h.issues),i.abortEarly){r.typed=!1;break}}const f=this.value["~run"]({value:c},i);if(f.issues){const b={type:"object",origin:"value",input:s,key:l,value:c};for(const v of f.issues)v.path?v.path.unshift(b):v.path=[b],(u=r.issues)==null||u.push(v);if(r.issues||(r.issues=f.issues),i.abortEarly){r.typed=!1;break}}(!h.typed||!f.typed)&&(r.typed=!1),h.typed&&(r.value[h.value]=f.value)}}else K(this,"type",r,i);return r}}}function y(e){return{kind:"schema",type:"string",reference:y,expects:"string",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:K(this,"type",t,n),t}}}function Pn(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function nt(e,t){return{kind:"schema",type:"union",reference:nt,expects:gi(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){let i,s,a;for(const u of this.options){const l=u["~run"]({value:n.value},r);if(l.typed)if(l.issues)s?s.push(l):s=[l];else{i=l;break}else a?a.push(l):a=[l]}if(i)return i;if(s){if(s.length===1)return s[0];K(this,"type",n,r,{issues:Pn(s)}),n.typed=!0}else{if((a==null?void 0:a.length)===1)return a[0];K(this,"type",n,r,{issues:Pn(a)})}return n}}}function qt(){return{kind:"schema",type:"unknown",reference:qt,expects:"unknown",async:!1,get"~standard"(){return J(this)},"~run"(e){return e.typed=!0,e}}}function _e(e,t,n){const r=e["~run"]({value:t},vt(n));if(r.issues)throw new wi(r.issues);return r.value}function se(...e){return{...e[0],pipe:e,get"~standard"(){return J(this)},"~run"(t,n){for(const r of e)if(r.kind!=="metadata"){if(t.issues&&(r.kind==="schema"||r.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r["~run"](t,n))}return t}}}function Tt(e,t,n){const r=e["~run"]({value:t},vt(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var yi=Object.defineProperty,Ci=(e,t,n)=>t in e?yi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mn=(e,t,n)=>Ci(e,typeof t!="symbol"?t+"":t,n),Fi=Object.defineProperty,Si=(e,t,n)=>t in e?Fi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bt=(e,t,n)=>Si(e,typeof t!="symbol"?t+"":t,n);function Ln(e){return t=>t instanceof e}function Vn(e,t){const n=class extends Error{constructor(...i){const s=typeof t=="function"?t(...i):typeof t=="string"?[t]:t||[];super(...s),this.name=e}};Bt(n,"is",Ln(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function ki(e,t,n){const r=class extends Vn(e,n){constructor(...s){super(...s),Bt(this,"data"),this.data=t(...s)}};Bt(r,"is",Ln(r));let i=r;return Object.defineProperty(i,"name",{value:e}),i}let Rn=class extends Vn("CancelledError","Promise was canceled"){},Pt=class extends ki("TimeoutError",t=>({timeout:t}),(t,n)=>[`Timeout reached: ${t}ms`,{cause:n}]){};const Ei=Symbol("resolved");function $i(e){return{tag:Ei,value:e}}function On(e,t){return e.reject=t.reject,e.resolve=t.resolve,e}let rt=class Sn extends Promise{constructor(t,n){let r,i,s,a;typeof t=="function"?(s=t,a=n||{}):a=t||{};let u,l;const c=()=>!!l,h=()=>!!u;let f={};const b=[],v=()=>{b.forEach(g=>g()),b.splice(0,b.length),f={}},F=new AbortController,S=()=>h()||c();super((g,w)=>{const{abortOnResolve:_=!0,abortOnReject:M=!0}=a;i=k=>{var V,I;S()||(g(k),u=[k],(V=f.resolved)==null||V.forEach(G=>G(k)),(I=f.finalized)==null||I.forEach(G=>G({kind:"resolved",result:k})),v(),_&&F.abort($i(k)))},r=k=>{var V,I;S()||(w(k),l=[k],(V=f.rejected)==null||V.forEach(G=>G(k)),(I=f.finalized)==null||I.forEach(G=>G({kind:"rejected",reason:k})),v(),M&&F.abort(k))};const{abortSignal:L}=a;if(L){if(L.aborted)return r(L.reason);const k=()=>{r(L.reason)};L.addEventListener("abort",k,!0),b.push(()=>{L.removeEventListener("abort",k,!0)})}const{timeout:O}=a;if(O){const k=setTimeout(()=>{r(new Pt(O))},O);b.push(()=>{clearTimeout(k)})}try{const k=()=>{},V=s&&s(i,r,{abortSignal:F.signal,get isRejected(){return c()},get isResolved(){return h()},on(I,G){if(u||l){if(I==="finalized"){const Ve=u?{kind:"resolved",result:u[0]}:{kind:"rejected",reason:l[0]};G(Ve)}else I==="resolved"&&u?G(u[0]):I==="rejected"&&l&&G(l[0]);return k}return f[I]||(f[I]=[]),f[I].push(G),()=>{const Ve=f[I]||[],Ye=Ve.indexOf(G);Ye>=0&&Ve.splice(Ye,1)}},get result(){return u==null?void 0:u[0]},get rejectReason(){return l==null?void 0:l[0]},throwIfRejected(){if(l)throw l[0]}});V instanceof Promise&&V.catch(r)}catch(k){r(k)}}),Mn(this,"reject"),Mn(this,"resolve"),this.reject=r,this.resolve=i}static fn(t,n){return new Sn(async(r,i,s)=>{try{r(await t(s))}catch(a){i(a)}},n)}static resolve(t){return this.fn(()=>t)}static reject(t){return new Sn((n,r)=>{r(t)})}cancel(){this.reject(new Rn)}catch(t){return this.then(void 0,t)}finally(t){return On(super.finally(t),this)}then(t,n){return On(super.then(t,n),this)}};function jn(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Ai(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function Ii(e){return Object.entries(e).reduce((t,[n,r])=>(t[Ai(n)]=r,t),{})}function Mt(e){const t=Ii(e);for(const n in t){const r=t[n];r&&typeof r=="object"&&!(r instanceof Date)&&(t[n]=Array.isArray(r)?r.map(Mt):Mt(r))}return t}function qi(e){return e.replace(/_([a-z])/g,(t,n)=>`-${n.toLowerCase()}`)}function Dn(e){return`tapps/${e}`}function Lt(e,t){sessionStorage.setItem(Dn(e),JSON.stringify(t))}function Un(e){const t=sessionStorage.getItem(Dn(e));try{return t?JSON.parse(t):void 0}catch{}}function st(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(n=>{n()})}]}function xn(e,t){t||(t={});const{textColor:n,bgColor:r,shouldLog:i}=t,s=i===void 0?!0:i,a=typeof s=="boolean"?()=>s:s,u=(l,c,...h)=>{if(c||a()){const f="font-weight:bold;padding:0 5px;border-radius:100px",[b,v,F]={log:["#0089c3","white","INFO"],error:["#ff0000F0","white","ERR"],warn:["#D38E15","white","WARN"]}[l];console[l](`%c${F} ${Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(new Date)}%c %c${e}`,`${f};background-color:${b};color:${v}`,"",`${f};${n?`color:${n};`:""}${r?`background-color:${r}`:""}`,...h)}};return[["log","forceLog"],["warn","forceWarn"],["error","forceError"]].reduce((l,[c,h])=>(l[c]=u.bind(void 0,c,!1),l[h]=u.bind(void 0,c,!0),l),{})}var Ti=function(e,t,n){if(arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function Gn(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function qe(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Wn=function(e,t){var n=function(r){return r.length>=e};return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,Ti([i],r,!1))}}},Bi=function(e){return e._tag==="Left"},Hn=function(e){return{_tag:"Left",left:e}},Nn=function(e){return{_tag:"Right",right:e}},zn=Hn,Kn=Nn,Jn=Bi,Pi=function(e,t){return function(n){return Jn(n)?e(n.left):t(n.right)}},Vt=Pi;function Mi(e){return Gn(Kn,e.of)}function Li(e){return Gn(zn,e.of)}function Vi(e){return function(t,n){return e.chain(t,function(r){return Jn(r)?e.of(r):n(r.right)})}}function Ri(e){return function(t,n){return function(r){return e.map(r,Vt(t,n))}}}var Qn=function(e,t){return qe(e,ji(t))},Oi=function(e,t){return qe(e,Di(t))},ji=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},Di=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Rt=function(e){return function(){return Promise.resolve(e)}},Ui=Wn(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),Zn="Task",xi={URI:Zn,map:Qn},Yn={of:Rt},Gi={URI:Zn,map:Qn,of:Rt,ap:Oi,chain:Ui},Wi=function(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function u(h){try{c(r.next(h))}catch(f){a(f)}}function l(h){try{c(r.throw(h))}catch(f){a(f)}}function c(h){h.done?s(h.value):i(h.value).then(u,l)}c((r=r.apply(e,[])).next())})},Hi=function(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(c){return function(h){return l([c,h])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(s=c[0]&2?i.return:c[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,c[1])).done)return s;switch(i=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(h){c=[6,h],i=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Ni=Li(Yn),zi=Mi(Yn),Ki=Rt,Xn=Ri(xi),Ji=Xn,Qi=function(e,t){return function(){return Wi(void 0,void 0,void 0,function(){var n;return Hi(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e().then(Nn)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,Hn(t(n))];case 3:return[2]}})})}},Zi=Wn(2,Vi(Gi)),Yi=Zi;function De(e){const t=n=>{throw n};return typeof e=="function"?rt.resolve(qe(e,Xn(t,n=>n))()):qe(e,Vt(t,n=>n))}function X(e){return Object.assign((...t)=>De(e(...t)),e)}const Ue=Object.assign((e,t)=>qe(Qi(()=>new rt((n,r,i)=>e(s=>n(Kn(s)),s=>n(zn(s)),i),t),n=>n),Yi(Vt(Ni,zi))),{fn:(e,t)=>Ue((n,r,i)=>{const s=e(i);qe(typeof s=="function"?s:Ki(s),Ji(r,n))()},t)});function Xi(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var eo=function(e){return e._tag==="Left"},to=function(e){return{_tag:"Left",left:e}},no=function(e){return{_tag:"Right",right:e}},er=to,Se=no,ro=function(e){return function(t){return so(t)?t:Se(e(t.right))}},so=eo,tr=function(e,t){try{return Se(e())}catch(n){return er(t(n))}};function io(e){const t=n=>{const r={};return new URLSearchParams(n).forEach((i,s)=>{const a=r[s];Array.isArray(a)?a.push(i):a===void 0?r[s]=i:r[s]=[a,i]}),_e(e,r)};return se(nt([y(),At(URLSearchParams)]),et(n=>{try{return t(n),!0}catch{return!1}},"The value doesn't match required schema"),ue(t))}function oo(e){return se(y(),et(t=>{try{return JSON.parse(t),!0}catch{return!1}},"Input is not a valid JSON value"),ue(JSON.parse),e)}function me(e){return se(y(),oo(e))}function Ot(e){return se(nt([y(),At(URLSearchParams)]),io(e))}function it(e){return t=>e.test(t)}const nr=it(/^#[\da-f]{3}$/i),rr=it(/^#[\da-f]{4}$/i),xe=it(/^#[\da-f]{6}$/i),sr=it(/^#[\da-f]{8}$/i);function ir(e){return[xe,sr,nr,rr].some(t=>t(e))}function or(e){let t="#";for(let n=0;n<e.length-1;n+=1)t+=e[1+n].repeat(2);return t}function ot(e){const t=e.replace(/\s/g,"").toLowerCase();if(/^#[\da-f]{3}$/i.test(t))return Se(or(t.toLowerCase()+"f"));if(/^#[\da-f]{4}$/i.test(t))return Se(or(t.toLowerCase()));if(/^#[\da-f]{6}$/i.test(t))return Se(t.toLowerCase()+"ff");if(/^#[\da-f]{8}$/i.test(t))return Se(t.toLowerCase());const n=t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/)||t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})\)$/);return n?Se(n.slice(1).reduce((r,i)=>r+parseInt(i,10).toString(16).padStart(2,"0"),"#").padEnd(9,"f")):er(new Error(`Value "${e}" does not satisfy any of known RGB formats.`))}function ar(e){return Xi(ot(e),ro(t=>t.slice(0,7)))}const ao=X(ar),uo=X(ot);function co(){return x({id:de(),photo_url:$(y()),type:y(),title:y(),username:$(y())})}function ur(){return x({added_to_attachment_menu:$(Fe()),allows_write_to_pm:$(Fe()),first_name:y(),id:de(),is_bot:$(Fe()),is_premium:$(Fe()),last_name:$(y()),language_code:$(y()),photo_url:$(y()),username:$(y())})}function lo(){return x({auth_date:se(y(),ue(e=>new Date(Number(e)*1e3)),tt()),can_send_after:$(se(y(),ue(Number),St())),chat:$(me(co())),chat_type:$(y()),chat_instance:$(y()),hash:y(),query_id:$(y()),receiver:$(me(ur())),start_param:$(y()),signature:y(),user:$(me(ur()))})}function cr(){return Ot(lo())}function jt(){return It(y(),se(nt([y(),de()]),ue(e=>typeof e=="number"?`#${(e&16777215).toString(16).padStart(6,"0")}`:e),et(ir)))}function po(){const e=$(se(y(),ue(t=>t==="1")));return x({tgWebAppBotInline:e,tgWebAppData:$(cr()),tgWebAppDefaultColors:$(me(jt())),tgWebAppFullscreen:e,tgWebAppPlatform:y(),tgWebAppShowSettings:e,tgWebAppStartParam:$(y()),tgWebAppThemeParams:me(jt()),tgWebAppVersion:y()})}function ho(){return Ot(po())}function lr(){return x({eventType:y(),eventData:$(qt())})}function pr(e){return tr(()=>_e(cr(),e),t=>t)}function at(e){return tr(()=>_e(ho(),e),t=>t)}const fo=X(pr),hr=X(at);function fr(e,t){return t||(t=(n,r)=>JSON.stringify(r)),new URLSearchParams(Object.entries(e).reduce((n,[r,i])=>(Array.isArray(i)?n.push(...i.map(s=>[r,String(s)])):i!=null&&n.push([r,i instanceof Date?(i.getTime()/1e3|0).toString():typeof i=="string"||typeof i=="number"?String(i):typeof i=="boolean"?i?"1":"0":t(r,i)]),n),[])).toString()}function dr(e){return fr(e)}function _r(e){return fr(e,(t,n)=>t==="tgWebAppData"?dr(n):JSON.stringify(n))}var _o=Object.defineProperty,mo=(e,t,n)=>t in e?_o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Dt=(e,t,n)=>mo(e,typeof t!="symbol"?t+"":t,n);function mr(e){return t=>t instanceof e}function H(e,t){const n=class extends Error{constructor(...s){const a=typeof t=="function"?t(...s):typeof t=="string"?[t]:t||[];super(...a),this.name=e}};Dt(n,"is",mr(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function br(e,t,n){const r=class extends H(e,n){constructor(...a){super(...a),Dt(this,"data"),this.data=t(...a)}};Dt(r,"is",mr(r));let i=r;return Object.defineProperty(i,"name",{value:e}),i}function bo(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(i){i(n)}),(r=e.get("*"))&&r.slice().map(function(i){i(t,n)})}}}function gr(e){return Et(x({TelegramWebviewProxy:x({postEvent:$t()})}),e)}function wr(){try{return window.self!==window.top}catch{return!0}}var go=function(e,t,n){if(arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function wo(e){return e}function Ge(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function ce(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var ut=function(e,t){var n=typeof e=="number"?function(r){return r.length>=e}:e;return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,go([i],r,!1))}}},vo={_tag:"None"},yo=function(e){return{_tag:"Some",value:e}},Co=function(e){return e._tag==="Left"},Fo=function(e){return{_tag:"Left",left:e}},So=function(e){return{_tag:"Right",right:e}},be=Fo,ee=So,vr=ut(2,function(e,t){return Te(e)?e:t(e.right)}),ko=function(e){return function(t){return Te(t)?t:ee(e(t.right))}},Eo=function(e,t){return function(n){return Te(n)?be(e(n.left)):ee(t(n.right))}},$o=function(e){return function(t){return Te(t)?be(e(t.left)):t}},Te=Co,yr=function(e,t){return function(n){return Te(n)?e(n.left):t(n.right)}},Ao=yr,Ut=yr,Io=Ut,xt=function(e,t){try{return ee(e())}catch(n){return be(t(n))}},qo=vr,To=vr,Bo=vo,Po=yo,Mo=function(e){return e._tag==="None"},Lo=function(e,t){return function(n){return Mo(n)?e():t(n.value)}},Vo=Lo;function Ro(e){return Ge(ee,e.of)}function Oo(e){return Ge(be,e.of)}function jo(e){return function(t,n){return e.chain(t,function(r){return Te(r)?e.of(r):n(r.right)})}}function Do(e){return function(t,n,r){return e.map(t,Eo(n,r))}}function Uo(e){return function(t,n){return function(r){return e.map(r,Ut(t,n))}}}var Cr=function(e,t){return ce(e,Go(t))},xo=function(e,t){return ce(e,Wo(t))},Go=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},Wo=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Fr=function(e){return function(){return Promise.resolve(e)}},Ho=ut(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),Sr="Task",kr={URI:Sr,map:Cr},Er={of:Fr},No={URI:Sr,map:Cr,of:Fr,ap:xo,chain:Ho},zo=Oo(Er),$r=Ro(Er),Ko=Uo(kr),Jo=ut(3,Do(kr)),Ar=ut(2,jo(No)),Qo=Ar,Zo=Ar;class Ir extends H("MethodUnsupportedError",(t,n)=>[`Method "${t}" is unsupported in Mini Apps version ${n}`]){}class qr extends H("MethodParameterUnsupportedError",(t,n,r)=>[`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${r}`]){}class Tr extends br("LaunchParamsRetrieveError",t=>({errors:t}),t=>[["Unable to retrieve launch parameters from any known source. Perhaps, you have opened your app outside Telegram?","📖 Refer to docs for more information:","https://docs.telegram-mini-apps.com/packages/tma-js-bridge/environment","","Collected errors:",...t.map(({source:n,error:r})=>`Source: ${n} / ${r instanceof Error?r.message:String(r)}`)].join(`
2
+ `)]){}class Br extends H("InvalidLaunchParamsError",(t,n)=>[`Invalid value for launch params: ${t}`,{cause:n}]){}class Pr extends H("UnknownEnvError"){}class Mr extends H("InvokeCustomMethodError",t=>[`Server returned error: ${t}`]){}const Lr="launchParams";function Vr(e){return e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&")}const Be=Ge(We,qo(at)),Yo=X(Be),Gt=Ge(We,ko(e=>{const t=new URLSearchParams(e).get("tgWebAppData");return t?Po(t):Bo})),Xo=Ge(Gt,Io(e=>{throw e},e=>e),Vo(()=>{},e=>e));function We(){const e=[];for(const[t,n]of[[()=>Vr(window.location.href),"window.location.href"],[()=>{const r=performance.getEntriesByType("navigation")[0];return r&&Vr(r.name)},"performance navigation entries"],[()=>Un(Lr),"local storage"]]){const r=t();if(!r){e.push({source:n,error:new Error("Source is empty")});continue}const i=ce(at(r),Ao(s=>s,()=>!0));if(typeof i!="boolean"){e.push({source:n,error:i});continue}return Lt(Lr,r),ee(r)}return be(new Tr(e))}const ea=X(We);function ta(e,t){const n=new Map,r=bo(),i=(s,a,u=!1)=>{const l=n.get(s)||new Map;n.set(s,l);const c=l.get(a)||[];l.set(a,c);const h=c.findIndex(f=>f[1]===u);if(h>=0&&(r.off(s,c[h][0]),c.splice(h,1),!c.length&&(l.delete(a),!l.size))){const f=n.size;n.delete(s),f&&!n.size&&t()}};return{on(s,a,u){!n.size&&e();const l=()=>{i(s,a,u)},c=(...b)=>{u&&l(),s==="*"?a({name:b[0],payload:b[1]}):a(...b)};r.on(s,c);const h=n.get(s)||new Map;n.set(s,h);const f=h.get(a)||[];return h.set(a,f),f.push([c,u||!1]),l},off:i,emit:r.emit,clear(){const s=n.size;r.all.clear(),n.clear(),s&&t()}}}function ct(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}function Wt(e,t,n){const r=[n],i=e[t];typeof i=="function"&&r.push(i);const s=(...u)=>{r.forEach(l=>l(...u))},a=Object.assign((...u)=>{s(...u)},{unwrap(){const{length:u}=r;if(u===1){delete e[t];return}if(u===2){jr(e,t,r[1]);return}r.unshift(1),jr(e,t,s)}});Or(e,t,()=>a,u=>r.push(u))}function Rr(e,t){const n=e[t];Or(e,t,()=>n,r=>{Object.entries(r).forEach(([i,s])=>{n[i]=s})})}function Or(e,t,n,r){Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:n,set:r})}function jr(e,t,n){Object.defineProperty(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n})}const na={clipboard_text_received:x({req_id:y(),data:Ie(y())}),custom_method_invoked:x({req_id:y(),result:$(qt()),error:$(y())}),popup_closed:Ie(x({button_id:Ie(y(),()=>{})}),{}),viewport_changed:Ie(x({height:de(),width:Ie(de(),()=>window.innerWidth),is_state_stable:Fe(),is_expanded:Fe()}),()=>({height:window.innerHeight,is_state_stable:!0,is_expanded:!0})),theme_changed:x({theme_params:jt()})};function Dr(e){if(e.source!==window.parent)return;let t;try{t=_e(me(lr()),e.data)}catch{return}const{eventType:n,eventData:r}=t,i=na[n];let s;try{s=i?_e(i,r):r}catch(a){return le().forceError([`An error occurred processing the "${n}" event from the Telegram application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose"].join(`
3
+ `),t,a)}ra(n,s)}const{on:te,off:ke,emit:ra,clear:sa}=ta(()=>{const e=window;!e.TelegramGameProxy&&(e.TelegramGameProxy={}),Wt(e.TelegramGameProxy,"receiveEvent",ct),Rr(e,"TelegramGameProxy"),!e.Telegram&&(e.Telegram={}),!e.Telegram.WebView&&(e.Telegram.WebView={}),Wt(e.Telegram.WebView,"receiveEvent",ct),Rr(e.Telegram,"WebView"),Wt(e,"TelegramGameProxy_receiveEvent",ct),window.addEventListener("message",Dr)},()=>{[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["Telegram","WebView","receiveEvent"]].forEach(e=>{const t=window;let n=[void 0,t];for(const s of e)if(n=[n[1],n[1][s]],!n[1])return;const[r,i]=n;"unwrap"in i&&(i.unwrap(),r&&r!==t&&!Object.keys(r).length&&delete t[e[0]])}),window.removeEventListener("message",Dr)}),Ht=U(!1),Ur=U("https://web.telegram.org"),ia=e=>{le().log("Event received:",e)},xr=C(Ht);function oa(e){e!==Ht()&&(Ht.set(e),(e?te:ke)("*",ia))}const Gr=C(Ur);function aa(e){Ur.set(e),le().log("New target origin set",e)}const lt=U((...e)=>{window.parent.postMessage(...e)}),le=U(xn("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:xr})),ua=(...e)=>lt()(...e);function ca(e,t){ce(Nt(e,t),$o(n=>{throw n}))}function Nt(e,t){le().log("Posting event:",t?{eventType:e,eventData:t}:{eventType:e});const n=window,r=JSON.stringify({eventType:e,eventData:t});return wr()?(ua(r,Gr()),ee(void 0)):gr(n)?(n.TelegramWebviewProxy.postEvent(e,JSON.stringify(t)),ee(void 0)):Et(x({external:x({notify:$t()})}),n)?(n.external.notify(r),ee(void 0)):be(new Pr)}function zt(e,t,n={}){const{capture:r=()=>!0,postEvent:i=Nt}=n,s=U(),[a,u]=st();(Array.isArray(t)?t:[t]).forEach(c=>{a(te(c,h=>{(Array.isArray(t)?r({event:c,payload:h}):r(h))&&s.set([h])}))});const l=c=>(u(),c);return ce(async()=>i(e,n.params),Zo(()=>Ue((c,h,f)=>{const b=s();if(b)return c(b[0]);const v=S=>{S&&c(S[0])},F=()=>{s.unsub(v)};s.sub(v),f.on("finalized",F)},n)),Jo(l,l))}function la(e,t){const n=Kt(e,t);return typeof n=="function"?rt.fn(()=>De(n)):n}function Kt(e,t){const n=gr(window);if(!e)return n||ce(We(),Ut(()=>!1,()=>!0));if(n)return $r(!0);const{timeout:r=100}=t||{};return ce(zt("web_app_request_theme","theme_changed",{...t,timeout:r}),Ko(i=>Pt.is(i)?ee(!1):be(i),()=>ee(!0)))}function pa({launchParams:e,onEvent:t,resetPostMessage:n}={}){if(e){const s=typeof e=="string"||e instanceof URLSearchParams?e.toString():_r({...e,tgWebAppData:void 0})+(e.tgWebAppData?`&tgWebAppData=${encodeURIComponent(e.tgWebAppData.toString())}`:"");try{hr(s)}catch(a){throw new Br(s,a)}Lt("launchParams",s)}if(wr()){if(!t)return;n&&lt.reset();const s=lt();lt.set((...a)=>{const[u]=a,l=()=>{s(...a)};try{const c=_e(me(lr()),u);t({name:c.eventType,params:c.eventData},l)}catch{l()}});return}const r=window.TelegramWebviewProxy||{},i=r.postEvent||(()=>{});window.TelegramWebviewProxy={...r,postEvent(s,a){const u=()=>{i(s,a)};t?t({name:s,params:a?JSON.parse(a):void 0},u):u()}},le().log("Environment was mocked by the mockTelegramEnv function")}function Wr(e){return({req_id:t})=>t===e}function Hr(e){return e.split(".").map(Number)}function ha(e,t){const n=Hr(e),r=Hr(t),i=Math.max(n.length,r.length);for(let s=0;s<i;s+=1){const a=n[s]||0,u=r[s]||0;if(a!==u)return a>u?1:-1}return 0}const Nr={"6.0":["iframe_ready","iframe_will_reload","web_app_close","web_app_data_send","web_app_expand","web_app_open_link","web_app_ready","web_app_request_theme","web_app_request_viewport","web_app_setup_main_button","web_app_setup_closing_behavior"],6.1:["web_app_open_tg_link","web_app_open_invoice","web_app_setup_back_button","web_app_set_background_color","web_app_set_header_color","web_app_trigger_haptic_feedback"],6.2:["web_app_open_popup"],6.4:["web_app_close_scan_qr_popup","web_app_open_scan_qr_popup","web_app_read_text_from_clipboard",{method:"web_app_open_link",param:"try_instant_view"}],6.7:["web_app_switch_inline_query"],6.9:["web_app_invoke_custom_method","web_app_request_write_access","web_app_request_phone",{method:"web_app_set_header_color",param:"color"}],"6.10":["web_app_setup_settings_button"],7.2:["web_app_biometry_get_info","web_app_biometry_open_settings","web_app_biometry_request_access","web_app_biometry_request_auth","web_app_biometry_update_token"],7.6:[{method:"web_app_open_link",param:"try_browser"},{method:"web_app_close",param:"return_back"}],7.7:["web_app_setup_swipe_behavior"],7.8:["web_app_share_to_story"],"7.10":["web_app_setup_secondary_button","web_app_set_bottom_bar_color",{method:"web_app_setup_main_button",param:"has_shine_effect"}],"8.0":["web_app_request_safe_area","web_app_request_content_safe_area","web_app_request_fullscreen","web_app_exit_fullscreen","web_app_set_emoji_status","web_app_add_to_home_screen","web_app_check_home_screen","web_app_request_emoji_status_access","web_app_check_location","web_app_open_location_settings","web_app_request_file_download","web_app_request_location","web_app_send_prepared_message","web_app_start_accelerometer","web_app_start_device_orientation","web_app_start_gyroscope","web_app_stop_accelerometer","web_app_stop_device_orientation","web_app_stop_gyroscope","web_app_toggle_orientation_lock"],"9.0":["web_app_device_storage_clear","web_app_device_storage_get_key","web_app_device_storage_save_key","web_app_secure_storage_clear","web_app_secure_storage_get_key","web_app_secure_storage_restore_key","web_app_secure_storage_save_key"],9.1:["web_app_hide_keyboard"]};function Jt(e,t){return Object.keys(Nr).find(n=>Nr[n].some(r=>t?typeof r=="object"&&r.method===e&&r.param===t:r===e))||null}function pe(e,t,n){const r=n?Jt(e,t):Jt(e);return r?ha(r,n||t)<=0:!1}function fa(e,t="strict"){const n=typeof t=="function"?t:r=>{const{method:i,version:s}=r,a="param"in r?new qr(i,r.param,s):new Ir(i,s);if(t==="strict")throw a;return le().forceWarn(a.message)};return(r,i)=>pe(r,e)?r==="web_app_set_header_color"&&Et(x({color:Tn()}),i)&&!pe(r,"color",e)?n({version:e,method:r,param:"color"}):ca(r,i):n({version:e,method:r})}function da(e,t,n,r){return ce(zt("web_app_invoke_custom_method","custom_method_invoked",{...r||{},params:{method:e,params:t,req_id:n},capture:Wr(n)}),Qo(({result:i,error:s})=>s?zo(new Mr(s)):$r(i)))}function _a(){Object.hasOwn||(Object.hasOwn=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)})}function Qt(e){return xt(()=>decodeURIComponent(atob(e).replace(/-/g,"+").replace(/_/g,"/").split("").map(t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)).join("")),t=>t)}const ma=X(Qt);function Zt(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,n)=>String.fromCharCode(parseInt(`0x${n}`)))).replace(/\+/g,"-").replace(/\//g,"_")}var ba=function(e){return xt(function(){return JSON.parse(e)},wo)};function zr(e){const t=Zt(typeof e=="string"?e:JSON.stringify(e));return t.length>512?be(new Error("Value is too long for start parameter")):ee(t)}const ga=X(zr);function wa(e,t){return De(Kr(e,typeof t=="function"?n=>xt(()=>t(n),r=>r):t))}function Kr(e,t){return ce(Qt(e),To(n=>t?typeof t=="function"?t(n):ba(n):ee(n)))}function va(e){return Zt(e).length<=512}function Q(e){return typeof e=="function"?e():e}function ie(e,t){return C(()=>pe(e,Q(t)))}var Pe=Qs,He=Zs,ya=function(e,t){return d(e,Sa(t))},Ca=function(e,t){return d(e,Ea(t))},Fa="Option",Sa=function(e){return function(t){return Ne(t)?Pe:He(e(t.value))}},ka=He,Ea=function(e){return function(t){return Ne(t)||Ne(e)?Pe:He(t.value(e.value))}},$a=Re(2,function(e,t){return Ne(e)?Pe:t(e.value)}),Aa={URI:Fa,map:ya,ap:Ca,chain:$a},Ne=function(e){return e._tag==="None"},Ia=function(e,t){return function(n){return Ne(n)?e():t(n.value)}},Jr=Ia,qa=ka(mt),Qr=bt(Aa);function Ta(e){return ye(P,e.of)}function Ba(e){return ye(D,e.of)}function Pa(e){return ei(e,ni)}function Ma(e){return Xs(e,oi)}function La(e){return function(t,n){return e.chain(t,function(r){return Ce(r)?e.of(r):n(r.right)})}}function Va(e){return function(t,n,r){return e.map(t,ui(n,r))}}function Ra(e){return function(t,n){return function(r){return e.map(r,Oe(t,n))}}}var Yt=function(e,t){return d(e,Oa(t))},Zr=function(e,t){return d(e,ja(t))},Oa=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},ja=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Xt=function(e){return function(){return Promise.resolve(e)}},Da=Re(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),en="Task",tn={URI:en,map:Yt},Yr={of:Xt},Ua={URI:en,map:Yt,ap:Zr},xa={URI:en,map:Yt,of:Xt,ap:Zr,chain:Da},Ga=function(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function u(h){try{c(r.next(h))}catch(f){a(f)}}function l(h){try{c(r.throw(h))}catch(f){a(f)}}function c(h){h.done?s(h.value):i(h.value).then(u,l)}c((r=r.apply(e,t||[])).next())})},Wa=function(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(c){return function(h){return l([c,h])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(s=c[0]&2?i.return:c[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,c[1])).done)return s;switch(i=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(h){c=[6,h],i=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},N=Ba(Yr),j=Ta(Yr),Xr=Xt,Ha=Ra(tn),Na=function(e,t){return function(){return Ga(void 0,void 0,void 0,function(){var n;return Wa(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e().then(En)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,kn(t(n))];case 3:return[2]}})})}},za=function(e,t){return d(e,R(t))},Ka=function(e,t){return d(e,Ja(t))},R=Pa(tn),nn=Re(3,Va(tn)),Ja=Ma(Ua),rn=Re(2,La(xa)),Qa=j,Za="TaskEither",Ya={URI:Za,map:za,ap:Ka,chain:rn},Xa=Qa(mt),eu=bt(Ya),pt=eu,he=rn,Me=rn;function Ee(e){return[e]}class ze extends br("ValidationError",(t,n)=>({input:t,issues:n}),"Validation error"){}class ht extends H("CSSVarsBoundError","CSS variables are already bound"){}class es extends H("NotAvailableError",Ee){}class tu extends H("InvalidEnvError",Ee){}class ts extends H("FunctionNotAvailableError",Ee){}class ne extends H("InvalidArgumentsError",(t,n)=>[t,{cause:n}]){}class ft extends H("ConcurrentCallError",Ee){}class ns extends H("SetEmojiStatusError",t=>[`Failed to set emoji status: ${t}`]){}class sn extends H("AccessDeniedError",Ee){}class rs extends H("FullscreenFailedError",Ee){}class ss extends H("ShareMessageError",Ee){}class is extends H("UnknownThemeParamsKeyError",t=>[`Unknown theme params key passed: ${t}`]){}function B(e,t){const n=C(()=>Q(t.version)||"100"),r=C(()=>Q(t.isTma)),{requires:i,returns:s}=t,a=i?typeof i=="object"?i:{every:[i]}:void 0,u=g=>{if(!t.supports)return!0;const w=t.supports[g];return pe(w.method,w.param,n())},l=()=>{if(!a)return;const[g,w]="every"in a?["every",a.every]:["some",a.some];for(let _=0;_<w.length;_++){const M=w[_],L=typeof M=="function"?M():pe(M,n())?void 0:`it is unsupported in Mini Apps version ${n()}`;if(L&&(g==="every"||_===w.length-1))return L}},c=(...g)=>{for(const w in t.supports)if(t.supports[w].shouldCheck(...g)&&!u(w))return`option ${w} is not supported in Mini Apps version ${n()}`},h=C(()=>!l()),f=C(()=>n()!=="0.0"),b=C(()=>t.isMounted?t.isMounted():!0),v=C(()=>r()&&f()&&h()&&b()),F=g=>{const w=new ts(g);return["task","promise"].includes(t.returns)?N(w):D(w)},S=(...g)=>s==="plain"?ci(()=>e(...g),w=>w):s==="promise"?Na(()=>e(...g),w=>w):e(...g);return Object.assign((...g)=>{var L;const w="Unable to call function:";if(!r())return F(`${w} it can't be called outside Mini Apps`);if(!f())return F(`${w} the SDK was not initialized. Use the SDK init() function`);const _=l();if(_)return F(`${w} ${_}`);const M=c(...g);if(M)return F(`${w} ${M}`);if(!b()){const O=(L=t.isMounting)!=null&&L.call(t)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return F(`${w} the component is ${O}`)}return S(...g)},e,{isAvailable:v,ifAvailable(...g){return v()?He(S(...g)):Pe}},a?{isSupported:h}:{},t.supports?{supports:u}:{})}function T(e){return t=>B(t,e)}function m(e){return Object.assign(X(e),{ifAvailable(...t){return d(e.ifAvailable(...t),Jr(()=>({ok:!1}),n=>({ok:!0,data:De(n)})))}})}function on(e){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=r)}return t}function an(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&e[i]===t[i])}class ge{constructor({initialState:t,onChange:n}){o(this,"_state");o(this,"state");o(this,"setState",t=>{const n={...this.state(),...on(t)};an(n,this.state())||this._state.set(n)});this._state=U(t,{equals:an}),this.state=C(this._state),this.state.sub(n)}getter(t){return C(()=>this._state()[t])}hasDiff(t){return!an({...this.state(),...on(t)},this.state())}}class Ke{constructor({onMounted:t,restoreState:n,initialState:r,onUnmounted:i,isPageReload:s}){o(this,"_isMounted",U(!1));o(this,"isMounted",C(this._isMounted));o(this,"mount");o(this,"unmount");this.mount=()=>{if(this.isMounted())return P(void 0);const a=Q(s)?n():void 0,u=a?P(a):typeof r=="function"?r():P(r);return d(u,Z(l=>{Xe(()=>{this._isMounted.set(!0),t==null||t(l)})}))},this.unmount=()=>{this._isMounted()&&Xe(()=>{this._isMounted.set(!1),i==null||i()})}}}class dt{constructor({isTma:t,storage:n,onClick:r,offClick:i,initialState:s,isPageReload:a,postEvent:u,payload:l,method:c,version:h}){o(this,"isMounted");o(this,"isSupported");o(this,"state");o(this,"stateSetters");o(this,"stateBoolSetters");o(this,"setStateFp");o(this,"setState");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const f=new ge({initialState:s,onChange(g){n.set(g)}}),b=new Ke({initialState:s,isPageReload:a,onMounted:f.setState,restoreState:n.get}),v={version:h,requires:c,isTma:t},F=T({...v,returns:"plain"}),S=T({...v,returns:"either",isMounted:b.isMounted});this.isMounted=b.isMounted,this.isSupported=ie(c,h),this.state=f.state,this.setStateFp=S(g=>{const w={...this.state(),...on(g)};return f.hasDiff(w)?d(u(c,l(w)),Z(()=>{f.setState(w)})):P(void 0)}),this.setState=m(this.setStateFp),this.onClickFp=F(r),this.onClick=m(this.onClickFp),this.offClickFp=F(i),this.offClick=m(this.offClickFp),this.mountFp=F(()=>{const g=()=>{};return d(b.mount(),Oe(g,g))}),this.mount=m(this.mountFp),this.unmount=b.unmount,this.stateSetters=g=>{const w=S(_=>this.setStateFp({[g]:_}));return[m(w),w]},this.stateBoolSetters=g=>{const[,w]=this.stateSetters(g),_=S(()=>w(!1)),M=S(()=>w(!0));return[[m(_),_],[m(M),M]]}}stateGetter(t){return C(()=>this.state()[t])}}class os{constructor(t){o(this,"isVisible");o(this,"isMounted");o(this,"isSupported");o(this,"hideFp");o(this,"hide");o(this,"showFp");o(this,"show");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const n=new dt({...t,method:"web_app_setup_back_button",payload:r=>({is_visible:r.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}function E(){return{isTma:C(()=>Kt())}}function nu(e){return{get:()=>Un(e),set(t){Lt(e,t)}}}function ru(){return performance.getEntriesByType("navigation")[0]}function su(){const e=ru();return!!e&&e.type==="reload"}function Je(e){return t=>({...t,...Q(e)})}function we(e){return Je({storage:nu(e),isPageReload:su})}function Qe(e,t){return U(e,t)}const as=Qe(Nt),Le=(...e)=>as()(...e),us=(...e)=>De(Le(...e)),z=Je({postEvent:Le}),un=Qe("0.0"),A=Je({version:un});function cn(e,t){return{...d(E(),z,A,we(e)),onClick(n,r){return te(t,n,r)},offClick(n,r){ke(t,n,r)}}}const iu=new os(cn("backButton","back_button_pressed"));class ln{constructor({initialState:t,onMounted:n,restoreState:r,onUnmounted:i,isPageReload:s}){o(this,"_isMounted",U(!1));o(this,"isMounted",C(this._isMounted));o(this,"mount");o(this,"unmount");this.mount=a=>{if(this._isMounted())return j(void 0);const u=Q(s)?r():void 0;return d(u?j(u):t(a),R(l=>{this._isMounted()||Xe(()=>{this._isMounted.set(!0),n==null||n(l)})}))},this.unmount=()=>{this._isMounted()&&Xe(()=>{this._isMounted.set(!1),i==null||i()})}}}const cs=new es("Biometry is not available");function pn(e){let t=!1,n=!1,r="",i=!1,s="",a=!1;return e.available&&(t=!0,n=e.token_saved,r=e.device_id,i=e.access_requested,s=e.type,a=e.access_granted),{available:t,tokenSaved:n,deviceId:r,type:s,accessGranted:a,accessRequested:i}}class ls{constructor({version:t,request:n,postEvent:r,storage:i,onInfoReceived:s,offInfoReceived:a,isTma:u,isPageReload:l}){o(this,"isAvailable");o(this,"isSupported");o(this,"isMounted");o(this,"state");o(this,"authenticateFp");o(this,"authenticate");o(this,"openSettingsFp");o(this,"openSettings");o(this,"requestAccessFp");o(this,"requestAccess");o(this,"updateTokenFp");o(this,"updateToken");o(this,"mountFp");o(this,"mount");o(this,"unmount");const c=g=>{h.setState(pn(g))},h=new ge({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:i.set}),f=new ln({initialState(g){return d(n("web_app_biometry_get_info","biometry_info_received",g),R(pn))},isPageReload:l,onMounted(g){h.setState(g),s(c)},onUnmounted(){a(c)},restoreState:i.get}),b={version:t,requires:"web_app_biometry_request_auth",isTma:u},v=T({...b,returns:"either"}),F=T({...b,returns:"task"}),S=T({...b,isMounted:f.isMounted,returns:"task"});this.isAvailable=h.getter("available"),this.isMounted=f.isMounted,this.isSupported=ie("web_app_biometry_request_auth",t),this.state=h.state,this.unmount=f.unmount,this.mountFp=F(f.mount),this.authenticateFp=S(g=>this.isAvailable()?d(n("web_app_biometry_request_auth","biometry_auth_requested",{...g,params:{reason:((g||{}).reason||"").trim()}}),R(w=>(h.setState({token:w.token}),w))):N(cs)),this.openSettingsFp=v(()=>r("web_app_biometry_open_settings")),this.requestAccessFp=S(g=>d(n("web_app_biometry_request_access","biometry_info_received",{...g,params:{reason:((g||{}).reason||"").trim()}}),he(w=>{const _=pn(w);return _.available?(h.setState(_),j(_.accessRequested)):N(cs)}))),this.updateTokenFp=S((g={})=>{var w;return d(n("web_app_biometry_update_token","biometry_token_updated",{...g,params:{token:g.token||"",reason:(w=g.reason)==null?void 0:w.trim()}}),R(_=>_.status))}),this.authenticate=m(this.authenticateFp),this.openSettings=m(this.openSettingsFp),this.requestAccess=m(this.requestAccessFp),this.updateToken=m(this.updateTokenFp),this.mount=m(this.mountFp)}}const hn=(e,t,n)=>zt(e,t,{postEvent:Le,...n}),ou=(...e)=>rt.fn(()=>hn(...e)()),Y=Je({request:hn}),au=new ls({...d(E(),z,A,Y,we("biometry")),offInfoReceived(e){ke("biometry_info_received",e)},onInfoReceived(e){return te("biometry_info_received",e)}});class ps{constructor({postEvent:t,storage:n,isTma:r,isPageReload:i}){o(this,"isConfirmationEnabled");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"disableConfirmationFp");o(this,"disableConfirmation");o(this,"enableConfirmationFp");o(this,"enableConfirmation");const s=new ge({initialState:{isConfirmationEnabled:!1},onChange(f){n.set(f)}}),a=new Ke({onMounted:s.setState,restoreState:n.get,initialState:{isConfirmationEnabled:!1},isPageReload:i}),u={requires:"web_app_setup_closing_behavior",isTma:r},l=T({...u,returns:"plain"}),c=T({...u,returns:"either",isMounted:a.isMounted}),h=f=>f===this.isConfirmationEnabled()?P(void 0):(s.setState({isConfirmationEnabled:f}),t("web_app_setup_closing_behavior",{need_confirmation:f}));this.isConfirmationEnabled=s.getter("isConfirmationEnabled"),this.isMounted=a.isMounted,this.disableConfirmationFp=c(()=>h(!1)),this.enableConfirmationFp=c(()=>h(!0)),this.mountFp=l(()=>{const f=()=>{};return d(a.mount(),Oe(f,f))}),this.unmount=a.unmount,this.disableConfirmation=m(this.disableConfirmationFp),this.enableConfirmation=m(this.enableConfirmationFp),this.mount=m(this.mountFp)}}const uu=new ps(d(E(),we("closingBehavior"),z));class hs{constructor({version:t,isTma:n,invokeCustomMethod:r}){o(this,"isSupported");o(this,"deleteItemFp");o(this,"deleteItem");o(this,"getItemFp");o(this,"getItem");o(this,"getItemsFp");o(this,"getItems");o(this,"getKeysFp");o(this,"getKeys");o(this,"setItemFp");o(this,"setItem");o(this,"clearFp");o(this,"clear");const i=T({version:t,requires:"web_app_invoke_custom_method",isTma:n,returns:"task"});this.isSupported=ie("web_app_invoke_custom_method",t),this.deleteItemFp=i((s,a)=>{const u=Array.isArray(s)?s:[s];return d(u.length?r("deleteStorageValues",{keys:u},a):j(void 0),R(()=>{}))}),this.getItemFp=i((s,a)=>d(this.getItemsFp([s],a),R(u=>u[s]||""))),this.getItemsFp=i((s,a)=>d(s.length?r("getStorageValues",{keys:s},a):j({}),R(u=>({...s.reduce((l,c)=>(l[c]="",l),{}),..._e(It(y(),y()),u)})))),this.getKeysFp=i(s=>d(r("getStorageKeys",{},s),R(a=>_e(Bn(y()),a)))),this.setItemFp=i((s,a,u)=>d(r("saveStorageValue",{key:s,value:a},u),R(()=>{}))),this.clearFp=i(s=>d(this.getKeysFp(s),he(this.deleteItemFp))),this.deleteItem=m(this.deleteItemFp),this.getItem=m(this.getItemFp),this.getItems=m(this.getItemsFp),this.getKeys=m(this.getKeysFp),this.setItem=m(this.setItemFp),this.clear=m(this.clearFp)}}const fn=Qe(0);function dn(){return fn.set(fn()+1),fn().toString()}function fs(e,t,n){return da(e,t,dn(),{...n||{},postEvent:Le})}const _n=Je({invokeCustomMethod:fs}),cu=new hs(d(E(),A,_n));function lu({request:e,...t}){return B(n=>d(e("web_app_request_emoji_status_access","emoji_status_access_requested",n),R(r=>r.status)),{...t,requires:"web_app_request_emoji_status_access",returns:"task"})}const ds=lu(d(E(),A,Y)),pu=m(ds);function hu({request:e,...t}){return B((n,r)=>d(e("web_app_set_emoji_status",["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:n,duration:(r||{}).duration},...r}),Me(i=>i&&"error"in i?N(new ns(i.error)):j(void 0))),{...t,requires:"web_app_set_emoji_status",returns:"task"})}const _s=hu(d(E(),Y,A)),fu=m(_s);class ms{constructor({postEvent:t,isTma:n,version:r}){o(this,"isSupported");o(this,"impactOccurredFp");o(this,"impactOccurred");o(this,"notificationOccurredFp");o(this,"notificationOccurred");o(this,"selectionChangedFp");o(this,"selectionChanged");const i="web_app_trigger_haptic_feedback",s=T({requires:i,isTma:n,version:r,returns:"plain"});this.isSupported=ie(i,r),this.impactOccurredFp=s(a=>t(i,{type:"impact",impact_style:a})),this.notificationOccurredFp=s(a=>t(i,{type:"notification",notification_type:a})),this.selectionChangedFp=s(()=>t(i,{type:"selection_change"})),this.impactOccurred=m(this.impactOccurredFp),this.notificationOccurred=m(this.notificationOccurredFp),this.selectionChanged=m(this.selectionChangedFp)}}const du=new ms(d(E(),z,A));function _u({postEvent:e,...t}){return B(()=>e("web_app_add_to_home_screen"),{...t,requires:"web_app_add_to_home_screen",returns:"either"})}const bs=_u(d(E(),A,z)),mu=m(bs);function bu({request:e,...t}){return B(n=>d(e("web_app_check_home_screen","home_screen_checked",n),R(r=>r.status||"unknown")),{...t,requires:"web_app_check_home_screen",returns:"task"})}const gs=bu(d(E(),A,Y)),gu=m(gs);class ws{constructor({retrieveInitData:t}){o(this,"_state",U());o(this,"_raw",U());o(this,"state",C(this._state));o(this,"authDate",this.fromState("auth_date"));o(this,"canSendAfter",this.fromState("can_send_after"));o(this,"canSendAfterDate",C(()=>{const t=this.authDate(),n=this.canSendAfter();return n&&t?new Date(t.getTime()+n*1e3):void 0}));o(this,"chat",this.fromState("chat"));o(this,"chatType",this.fromState("chat_type"));o(this,"chatInstance",this.fromState("chat_instance"));o(this,"hash",this.fromState("hash"));o(this,"queryId",this.fromState("query_id"));o(this,"raw",C(this._raw));o(this,"receiver",this.fromState("receiver"));o(this,"signature",this.fromState("signature"));o(this,"startParam",this.fromState("start_param"));o(this,"user",this.fromState("user"));o(this,"restoreFp");o(this,"restore");this.restoreFp=()=>d(t(),Z(Jr(()=>{},({raw:n,obj:r})=>{this._state.set(r),this._raw.set(n)}))),this.restore=X(this.restoreFp)}fromState(t){return C(()=>{const n=this._state();return n?n[t]:void 0})}}const wu=new ws({retrieveInitData(){return d(li,In("obj",()=>d(Be(),Z(({tgWebAppData:e})=>e?He(e):Pe))),In("raw",Gt),Z(({obj:e,raw:t})=>d(qa,Qr("obj",()=>e),Qr("raw",()=>t))))}});class vs{constructor({version:t,request:n,isTma:r}){o(this,"isOpened");o(this,"isSupported");o(this,"openSlugFp");o(this,"openSlug");o(this,"openUrlFp");o(this,"openUrl");const i=T({version:t,isTma:r,requires:"web_app_open_invoice",returns:"task"}),s=U(!1),a=()=>{s.set(!1)};this.isSupported=ie("web_app_open_invoice",t),this.isOpened=C(s),this.openSlugFp=i((u,l)=>d(this.isOpened()?N(new ft("Invoice is already opened")):j(void 0),he(()=>(s.set(!0),n("web_app_open_invoice","invoice_closed",{...l,params:{slug:u},capture:c=>u===c.slug}))),nn(c=>(a(),c),c=>(a(),c.status)))),this.openUrlFp=i((u,l)=>{const{hostname:c,pathname:h}=new URL(u,window.location.href);if(c!=="t.me")return N(new ne(`Link has unexpected hostname: ${c}`));const f=h.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return f?this.openSlugFp(f[2],l):N(new ne('Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"'))}),this.openUrl=m(this.openUrlFp),this.openSlug=m(this.openSlugFp)}}const vu=new vs(d(E(),Y,A));function yu({postEvent:e,...t}){return B((n,r={})=>{if(typeof n=="string")try{n=new URL(n)}catch(i){return D(new ne(`"${n.toString()}" is invalid URL`,i))}return e("web_app_open_link",{url:n.toString(),try_browser:r.tryBrowser,try_instant_view:r.tryInstantView})},{...t,returns:"either"})}const ys=yu(d(E(),z)),Cu=m(ys);function Fu({postEvent:e,version:t,...n}){return B(r=>{const i=r.toString();return i.match(/^https:\/\/t.me\/.+/)?pe("web_app_open_tg_link",Q(t))?(r=new URL(r),e("web_app_open_tg_link",{path_full:r.pathname+r.search})):(window.location.href=i,P(void 0)):D(new ne(`"${i}" is invalid URL`))},{...n,returns:"either"})}const mn=Fu(d(E(),z,A)),Su=m(mn);function ku({openTelegramLink:e,...t}){return B((n,r)=>e("https://t.me/share/url?"+new URLSearchParams({url:n,text:r||""}).toString().replace(/\+/g,"%20")),{...t,returns:"either"})}const Cs=ku({...E(),openTelegramLink:mn}),Eu=m(Cs);function $u(e){let t=!1,n,r;return e.available&&(t=!0,n=e.access_requested,r=e.access_granted),{available:t,accessGranted:r||!1,accessRequested:n||!1}}class Fs{constructor({version:t,request:n,postEvent:r,storage:i,isTma:s,isPageReload:a}){o(this,"state");o(this,"isAvailable");o(this,"isAccessGranted");o(this,"isAccessRequested");o(this,"isMounted");o(this,"isSupported");o(this,"openSettingsFp");o(this,"openSettings");o(this,"requestLocationFp");o(this,"requestLocation");o(this,"mountFp");o(this,"mount");o(this,"unmount");const u=new ge({initialState:{available:!1,accessGranted:!1,accessRequested:!1},onChange:i.set}),l=new ln({isPageReload:a,restoreState:i.get,onMounted:u.setState,initialState(v){return d(n("web_app_check_location","location_checked",v),R($u))}}),c={version:t,requires:"web_app_check_location",isTma:s},h=T({...c,returns:"either"}),f=T({...c,returns:"task"}),b=T({...c,returns:"task",isMounted:l.isMounted});this.isAvailable=u.getter("available"),this.isAccessRequested=u.getter("accessRequested"),this.isAccessGranted=u.getter("accessGranted"),this.isSupported=ie("web_app_check_location",t),this.isMounted=l.isMounted,this.state=u.state,this.unmount=l.unmount,this.mountFp=f(l.mount),this.openSettingsFp=h(()=>r("web_app_open_location_settings")),this.requestLocationFp=b(v=>d(n("web_app_request_location","location_requested",v),R(F=>{if(!F.available)return u.setState({available:!1}),null;const{available:S,...g}=F;return g}))),this.mount=m(this.mountFp),this.openSettings=m(this.openSettingsFp),this.requestLocation=m(this.requestLocationFp)}}const Au=new Fs(d(E(),z,A,Y,we("locationManager")));class Ss{constructor({defaults:t,...n}){o(this,"bgColor");o(this,"hasShineEffect");o(this,"isEnabled");o(this,"isLoaderVisible");o(this,"isVisible");o(this,"isMounted");o(this,"state");o(this,"text");o(this,"textColor");o(this,"showFp");o(this,"show");o(this,"hideFp");o(this,"hide");o(this,"enableFp");o(this,"enable");o(this,"enableShineEffectFp");o(this,"enableShineEffect");o(this,"disableFp");o(this,"disable");o(this,"disableShineEffectFp");o(this,"disableShineEffect");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"setTextColorFp");o(this,"setTextColor");o(this,"setTextFp");o(this,"setText");o(this,"showLoaderFp");o(this,"showLoader");o(this,"hideLoaderFp");o(this,"hideLoader");o(this,"setParamsFp");o(this,"setParams");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");const r=new dt({...n,version:"100",initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"},method:"web_app_setup_main_button",payload:s=>({has_shine_effect:s.hasShineEffect,is_visible:s.isVisible,is_active:s.isEnabled,is_progress_visible:s.isLoaderVisible,text:s.text,color:s.bgColor,text_color:s.textColor})}),i=(s,a)=>{const u=r.stateGetter(s);return C(()=>u()||Q(a))};this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.hasShineEffect=r.stateGetter("hasShineEffect"),this.isEnabled=r.stateGetter("isEnabled"),this.isLoaderVisible=r.stateGetter("isLoaderVisible"),this.text=r.stateGetter("text"),this.isVisible=r.stateGetter("isVisible"),this.isMounted=r.isMounted,this.state=r.state,[this.setBgColor,this.setBgColorFp]=r.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=r.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=r.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=r.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=r.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=r.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=r.stateBoolSetters("isVisible"),this.setParams=r.setState,this.setParamsFp=r.setStateFp,this.onClick=r.onClick,this.onClickFp=r.onClickFp,this.offClick=r.offClick,this.offClickFp=r.offClickFp,this.mount=r.mount,this.mountFp=r.mountFp,this.unmount=r.unmount}}function ks(e,t,n){return d(cn(e,t),r=>({...r,defaults:n}))}const bn=Qe({});function gn(e,t){document.documentElement.style.setProperty(e,t)}function wn(e){document.documentElement.style.removeProperty(e)}function Es(e){return d(ot(e),Z(t=>Math.sqrt([.299,.587,.114].reduce((n,r,i)=>{const s=parseInt(t.slice(1+i*2,1+(i+1)*2),16);return n+s*s*r},0))<120))}const vn=X(Es);class $s{constructor({initialState:t,onChange:n,offChange:r,isTma:i,storage:s,isPageReload:a}){o(this,"accentTextColor");o(this,"bgColor");o(this,"buttonColor");o(this,"buttonTextColor");o(this,"bottomBarBgColor");o(this,"destructiveTextColor");o(this,"headerBgColor");o(this,"hintColor");o(this,"linkColor");o(this,"secondaryBgColor");o(this,"sectionBgColor");o(this,"sectionHeaderTextColor");o(this,"sectionSeparatorColor");o(this,"subtitleTextColor");o(this,"textColor");o(this,"_isCssVarsBound",U(!1));o(this,"isCssVarsBound",C(this._isCssVarsBound));o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"state");o(this,"isDark",C(()=>{const t=this.bgColor();return!t||vn(t)}));o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");const u=new ge({initialState:{},onChange:s.set}),l=v=>{u.setState(v.theme_params)},c=new Ke({initialState:()=>P(Q(t)),isPageReload:a,onMounted(v){u.setState(v),n(l)},onUnmounted(){r(l)},restoreState:s.get}),h={isTma:i,returns:"either"},f=T(h),b=T({...h,isMounted:c.isMounted});this.accentTextColor=u.getter("accent_text_color"),this.bgColor=u.getter("bg_color"),this.buttonColor=u.getter("button_color"),this.buttonTextColor=u.getter("button_text_color"),this.bottomBarBgColor=u.getter("bottom_bar_bg_color"),this.destructiveTextColor=u.getter("destructive_text_color"),this.headerBgColor=u.getter("header_bg_color"),this.hintColor=u.getter("hint_color"),this.linkColor=u.getter("link_color"),this.secondaryBgColor=u.getter("secondary_bg_color"),this.sectionBgColor=u.getter("section_bg_color"),this.sectionHeaderTextColor=u.getter("section_header_text_color"),this.sectionSeparatorColor=u.getter("section_separator_color"),this.subtitleTextColor=u.getter("subtitle_text_color"),this.textColor=u.getter("text_color"),this.state=u.state,this.isMounted=c.isMounted,this.bindCssVarsFp=b(v=>{if(this._isCssVarsBound())return D(new ht);v||(v=g=>`--tg-theme-${qi(g)}`);const F=g=>{Object.entries(u.state()).forEach(([w,_])=>{_&&g(w,_)})},S=()=>{F((g,w)=>{gn(v(g),w)})};return S(),u.state.sub(S),this._isCssVarsBound.set(!0),P(()=>{F(wn),u.state.unsub(S),this._isCssVarsBound.set(!1)})}),this.mountFp=f(c.mount),this.unmount=c.unmount,this.bindCssVars=m(this.bindCssVarsFp),this.mount=m(this.mountFp)}}const Ze=new $s({...d(E(),we("themeParams")),offChange(e){ke("theme_changed",e)},onChange(e){te("theme_changed",e)},initialState:bn}),Iu=new Ss(ks("mainButton","main_button_pressed",{bgColor:C(()=>Ze.buttonColor()||"#2481cc"),textColor:C(()=>Ze.buttonTextColor()||"#ffffff")}));class As{constructor({storage:t,isPageReload:n,version:r,postEvent:i,isTma:s,theme:a,onVisibilityChanged:u,offVisibilityChanged:l}){o(this,"isSupported");o(this,"isDark",C(()=>{const t=this.bgColorRgb();return t?vn(t):!1}));o(this,"isActive");o(this,"state");o(this,"isCssVarsBound");o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"bgColor");o(this,"bgColorRgb");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"headerColor");o(this,"headerColorRgb");o(this,"setHeaderColorFp");o(this,"setHeaderColor");o(this,"bottomBarColor");o(this,"bottomBarColorRgb");o(this,"setBottomBarColorFp");o(this,"setBottomBarColor");o(this,"closeFp");o(this,"close");o(this,"readyFp");o(this,"ready");const c=_=>{b.setState({isActive:_.is_visible})},h=_=>{[[this.headerColor,"web_app_set_header_color"],[this.bgColor,"web_app_set_background_color"],[this.bottomBarColor,"web_app_set_bottom_bar_color"]].forEach(([M,L])=>{const O=M();if(!xe(O)&&(L==="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes(O))){const k=_[O];k&&i(L,{color:k})}})},f=new Ke({initialState(){const _=Q(a);return P({bgColor:_.bg_color||"bg_color",headerColor:_.header_bg_color||"header_bg_color",bottomBarColor:_.bottom_bar_bg_color||"bottom_bar_bg_color",isActive:!0})},isPageReload:n,onMounted:_=>{this.setBgColorFp.ifAvailable(_.bgColor),this.setBottomBarColorFp.ifAvailable(_.bottomBarColor),this.setHeaderColorFp.ifAvailable(_.headerColor),u(c),a.sub(h),b.setState(_)},onUnmounted(){l(c),a.unsub(h)},restoreState:t.get});this.isMounted=f.isMounted,this.mountFp=B(()=>{const _=()=>{};return d(f.mount(),Oe(_,_))},{isTma:s,returns:"plain"}),this.mount=m(this.mountFp),this.unmount=f.unmount;const b=new ge({initialState:{bgColor:"bg_color",bottomBarColor:"bottom_bar_bg_color",headerColor:"bg_color",isActive:!1},onChange:t.set});this.state=b.state;const v=_=>xe(_)?_:Q(a)[_],F=_=>C(()=>v(_()));this.isActive=b.getter("isActive"),this.isSupported=C(()=>["web_app_set_header_color","web_app_set_background_color","web_app_set_bottom_bar_color"].some(_=>pe(_,Q(r))));const S=U(!1);this.isCssVarsBound=C(S),this.bindCssVarsFp=B(_=>{if(S())return D(new ht);const[M,L]=st(()=>{S.set(!1)}),O=(k,V)=>{const I=()=>{gn(k,V()||null)};I(),M(V.sub(I),wn.bind(null,k))};return _||(_=k=>`--tg-${jn(k)}`),O(_("bgColor"),this.bgColorRgb),O(_("bottomBarColor"),this.bottomBarColorRgb),O(_("headerColor"),this.headerColorRgb),S.set(!0),P(L)},{isTma:s,returns:"either",isMounted:this.isMounted}),this.bindCssVars=m(this.bindCssVarsFp);const g=_=>{const M=b.getter(_),L=F(M),O={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[_],k=B(V=>{if(V===M())return P(void 0);if(O==="web_app_set_header_color"&&(V==="bg_color"||V==="secondary_bg_color"))return i("web_app_set_header_color",{color_key:V});const I=v(V);return d(I?i(O,{color:I}):D(new is(V)),Z(()=>{b.setState({[_]:I})}))},{isTma:s,version:r,requires:O,isMounted:this.isMounted,returns:"either",supports:_==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:xe}}:void 0});return[M,L,m(k),k]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=g("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=g("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=g("bottomBarColor");const w=T({isTma:s,returns:"either"});this.closeFp=w(_=>i("web_app_close",{return_back:_})),this.close=m(this.closeFp),this.readyFp=w(()=>i("web_app_ready")),this.ready=m(this.readyFp)}}const Is=new As({...d(E(),z,A,we("miniApp")),offVisibilityChanged(e){ke("visibility_changed",e)},onVisibilityChanged(e){te("visibility_changed",e)},theme:Ze.state});function qu(e){const t=e.message.trim(),n=(e.title||"").trim(),r=e.buttons||[];if(n.length>64)return D(new ne(`Invalid title: ${n}`));if(!t||t.length>256)return D(new ne(`Invalid message: ${t}`));if(r.length>3)return D(new ne(`Invalid buttons count: ${r.length}`));const i=[];if(!r.length)i.push({type:"close",id:""});else for(let s=0;s<r.length;s++){const a=r[s],u=a.id||"";if(u.length>64)return D(new ne(`Button with index ${s} has invalid id: ${u}`));if(!a.type||a.type==="default"||a.type==="destructive"){const l=a.text.trim();if(!l||l.length>64)return D(new ne(`Button with index ${s} has invalid text: ${l}`));i.push({type:a.type,text:l,id:u})}else i.push({type:a.type,id:u})}return P({title:n,message:t,buttons:i})}class qs{constructor({version:t,isTma:n,request:r}){o(this,"isOpened");o(this,"isSupported");o(this,"showFp");o(this,"show");const i=U(!1),s=()=>{i.set(!1)},a=T({version:t,isTma:n,requires:"web_app_open_popup",returns:"task"});this.isSupported=ie("web_app_open_popup",t),this.isOpened=C(i),this.showFp=a(u=>d(this.isOpened()?N(new ft("A popup is already opened")):j(void 0),Me(()=>Xr(qu(u))),he(l=>(i.set(!0),r("web_app_open_popup","popup_closed",{...u,params:l}))),nn(l=>(s(),l),l=>(s(),l.button_id)))),this.show=m(this.showFp)}}const Tu=new qs(d(E(),Y,A));function Bu({request:e,...t}){return B(n=>d(e("web_app_request_phone","phone_requested",n),R(r=>r.status)),{...t,requires:"web_app_request_phone",returns:"task"})}const yn=Bu(d(E(),A,Y)),Pu=m(yn);function Mu({invokeCustomMethod:e,requestPhoneAccess:t,...n}){const r=a=>d(e("getRequestedContact",{},{...a,timeout:(a||{}).timeout||5e3}),Me(u=>{const l=Tt(y(),u);if(!l.success)return N(new ze(u,l.issues));if(!l.output)return j(void 0);const c=Tt(Ot(x({contact:me(x({user_id:de(),phone_number:y(),first_name:y(),last_name:$(y())})),auth_date:se(y(),ue(h=>new Date(Number(h)*1e3)),tt()),hash:y()})),l.output);return c.success?j({raw:l.output,parsed:c.output}):N(new ze(l.output,c.issues))})),i=a=>d(r(a),Ha(u=>ze.is(u)?D(u):P(void 0),u=>P(u))),s=a=>Ue(async(u,l,c)=>{let h=50;for(;!c.isRejected;){const f=await i(c)();if(f._tag==="Left")return l(f.left);if(f.right)return u(f.right);await new Promise(b=>setTimeout(b,h)),h+=50}},a);return B(a=>Ue.fn(u=>d(i(u),he(l=>l?j(l):d(t(u),Me(c=>c==="sent"?s(u):N(new sn("User denied access")))))),a),{...n,returns:"task",requires:"web_app_request_phone"})}function Lu({requestContact:e,...t}){return B(e,{...t,returns:"task",requires:"web_app_request_phone"})}const Cn=Mu({...d(E(),_n,A),requestPhoneAccess:yn}),Vu=m(Cn),Ts=Lu({...d(E(),A),requestContact(e){return d(Cn(e),R(t=>t.parsed))}}),Ru=m(Ts);function Ou({request:e,...t}){return B(n=>d(e("web_app_request_write_access","write_access_requested",n),R(r=>r.status)),{...t,requires:"web_app_request_write_access",returns:"task"})}const Bs=Ou(d(E(),A,Y)),ju=m(Bs);class Ps{constructor({version:t,onClosed:n,onTextReceived:r,isTma:i,postEvent:s}){o(this,"isOpened");o(this,"isSupported");o(this,"captureFp");o(this,"capture");o(this,"closeFp");o(this,"close");o(this,"openFp");o(this,"open");const a={version:t,requires:"web_app_open_scan_qr_popup",isTma:i},u=T({...a,returns:"either"}),l=T({...a,returns:"task"}),c=U(!1),h=()=>{c.set(!1)};this.isSupported=ie("web_app_open_scan_qr_popup",t),this.isOpened=C(c),this.captureFp=l(f=>{let b;return d(this.openFp({...f,onCaptured:v=>{f.capture(v)&&(b=v,this.close())}}),R(()=>b))}),this.closeFp=u(()=>d(s("web_app_close_scan_qr_popup"),Z(h))),this.openFp=l(f=>d(this.isOpened()?N(new ft("The QR Scanner is already opened")):async()=>s("web_app_open_scan_qr_popup",{text:f.text}),Me(()=>{const[b,v]=st(),F=S=>(v(),S);return d(Ue(S=>{b(n(S),r(f.onCaptured))},f),nn(F,F))}))),this.open=m(this.openFp),this.capture=m(this.captureFp),this.close=m(this.closeFp)}}const Du=new Ps({...d(E(),z,A),onClosed(e){return te("scan_qr_popup_closed",e)},onTextReceived(e){return te("qr_text_received",t=>{e(t.data)})}});class Ms{constructor({defaults:t,...n}){o(this,"isSupported");o(this,"position");o(this,"bgColor");o(this,"hasShineEffect");o(this,"isEnabled");o(this,"isLoaderVisible");o(this,"isVisible");o(this,"isMounted");o(this,"state");o(this,"text");o(this,"textColor");o(this,"showFp");o(this,"show");o(this,"hideFp");o(this,"hide");o(this,"enableFp");o(this,"enable");o(this,"enableShineEffectFp");o(this,"enableShineEffect");o(this,"disableFp");o(this,"disable");o(this,"disableShineEffectFp");o(this,"disableShineEffect");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"setTextColorFp");o(this,"setTextColor");o(this,"setTextFp");o(this,"setText");o(this,"setPositionFp");o(this,"setPosition");o(this,"showLoaderFp");o(this,"showLoader");o(this,"hideLoaderFp");o(this,"hideLoader");o(this,"setParamsFp");o(this,"setParams");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");const r=new dt({...n,initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Cancel",position:"left"},method:"web_app_setup_secondary_button",payload:s=>({has_shine_effect:s.hasShineEffect,is_visible:s.isVisible,is_active:s.isEnabled,is_progress_visible:s.isLoaderVisible,text:s.text,color:s.bgColor,text_color:s.textColor,position:s.position})}),i=(s,a)=>{const u=r.stateGetter(s);return C(()=>u()||Q(a))};this.isSupported=ie("web_app_setup_secondary_button",n.version),this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.position=r.stateGetter("position"),this.hasShineEffect=r.stateGetter("hasShineEffect"),this.isEnabled=r.stateGetter("isEnabled"),this.isLoaderVisible=r.stateGetter("isLoaderVisible"),this.text=r.stateGetter("text"),this.isVisible=r.stateGetter("isVisible"),this.isMounted=r.isMounted,this.state=r.state,[this.setPosition,this.setPositionFp]=r.stateSetters("position"),[this.setBgColor,this.setBgColorFp]=r.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=r.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=r.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=r.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=r.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=r.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=r.stateBoolSetters("isVisible"),this.setParams=r.setState,this.setParamsFp=r.setStateFp,this.onClick=r.onClick,this.onClickFp=r.onClickFp,this.offClick=r.offClick,this.offClickFp=r.offClickFp,this.mount=r.mount,this.mountFp=r.mountFp,this.unmount=r.unmount}}const Uu=new Ms(ks("secondaryButton","secondary_button_pressed",{bgColor:C(()=>Is.bottomBarColorRgb()||"#000000"),textColor:C(()=>Ze.buttonColor()||"#2481cc")}));class Ls{constructor(t){o(this,"isVisible");o(this,"isMounted");o(this,"isSupported");o(this,"hideFp");o(this,"hide");o(this,"showFp");o(this,"show");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const n=new dt({...t,method:"web_app_setup_settings_button",payload:r=>({is_visible:r.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}const xu=new Ls(cn("settingsButton","settings_button_pressed"));class Vs{constructor({postEvent:t,storage:n,isTma:r,isPageReload:i,version:s}){o(this,"isSupported");o(this,"isVerticalEnabled");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"disableVerticalFp");o(this,"disableVertical");o(this,"enableVerticalFp");o(this,"enableVertical");const a=new ge({initialState:{isVerticalEnabled:!1},onChange(b){n.set(b)}}),u=new Ke({initialState:{isVerticalEnabled:!1},isPageReload:i,onMounted:a.setState,restoreState:n.get}),l={requires:"web_app_setup_swipe_behavior",isTma:r,version:s},c=T({...l,returns:"plain"}),h=T({...l,isMounted:u.isMounted,returns:"either"}),f=b=>{const v={isVerticalEnabled:b};return a.hasDiff(v)?d(t("web_app_setup_swipe_behavior",{allow_vertical_swipe:b}),Z(()=>{a.setState(v)})):P(void 0)};this.isSupported=ie("web_app_setup_swipe_behavior",s),this.isVerticalEnabled=a.getter("isVerticalEnabled"),this.isMounted=u.isMounted,this.disableVerticalFp=h(()=>f(!1)),this.enableVerticalFp=h(()=>f(!0)),this.mountFp=c(()=>{const b=()=>{};return d(u.mount(),Oe(b,b))}),this.unmount=u.unmount,this.disableVertical=m(this.disableVerticalFp),this.enableVertical=m(this.enableVerticalFp),this.mount=m(this.mountFp)}}const Gu=new Vs(d(E(),z,A,we("swipeBehavior")));async function Wu(e){try{const{clipboard:n}=navigator;if(n)return await n.writeText(e)}catch{}const t=document.createElement("textarea");t.value=e,t.style.top="0",t.style.left="0",t.style.position="fixed",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}finally{document.body.removeChild(t)}}function Hu({request:e,...t}){return B((n,r,i)=>d(e("web_app_request_file_download","file_download_requested",{...i,params:{url:n,file_name:r}}),he(s=>s.status==="downloading"?j(void 0):N(new sn("User denied the action")))),{...t,requires:"web_app_request_file_download",returns:"task"})}const Rs=Hu(d(E(),Y,A)),Nu=m(Rs);function zu({invokeCustomMethod:e,...t}){return B(n=>d(e("getCurrentTime",{},n),he(r=>{const i=Tt(se(de(),St(),ue(s=>new Date(s*1e3)),tt()),r);return i.success?j(i.output):N(new ze(r,i.issues))})),{...t,requires:"web_app_invoke_custom_method",returns:"task"})}const Os=zu(d(E(),_n,A)),Ku=m(Os);function Ju({postEvent:e,...t}){return B(()=>e("web_app_hide_keyboard"),{...t,returns:"either",requires:"web_app_hide_keyboard"})}const js=Ju(d(E(),z,A)),Qu=m(js);function Zu({request:e,createRequestId:t,...n}){return B(r=>{const i=t();return d(e("web_app_read_text_from_clipboard","clipboard_text_received",{...r,params:{req_id:i},capture:Wr(i)}),R(({data:s=null})=>s))},{...n,requires:"web_app_read_text_from_clipboard",returns:"task"})}const Ds=Zu({...d(E(),A,Y),createRequestId:dn}),Yu=m(Ds);function Us(e){const t={},n=e.match(/Telegram-Android(?:\/([^ ]+))?(?: (\([^)]+\))?|$)/);if(n){const[,r,i]=n;r&&(t.appVersion=r),i&&i.slice(1,i.length-1).split(";").forEach(s=>{const[a,u]=s.trim().split(" ");if(a==="Android")t.androidVersion=u;else if(a==="SDK"){const l=parseInt(u,10);l&&(t.sdkVersion=l)}else u?(t.manufacturer=a,t.model=u):t.performanceClass=a})}return t}function Xu(){return Us(navigator.userAgent)}function ec({postEvent:e,...t}){return B(n=>{const{size:r}=new Blob([n]);return!r||r>4096?D(new ne(r?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data")):e("web_app_data_send",{data:n})},{...t,returns:"either"})}const xs=ec(d(E(),z)),tc=m(xs);function nc({request:e,...t}){return B((n,r)=>d(e("web_app_send_prepared_message",["prepared_message_failed","prepared_message_sent"],{...r,params:{id:n}}),he(i=>i&&"error"in i?N(new ss(i.error)):j(void 0))),{...t,requires:"web_app_send_prepared_message",returns:"task"})}const Gs=nc(d(E(),Y,A)),rc=m(Gs);function sc({postEvent:e,...t}){return B((n,r={})=>e("web_app_share_to_story",{text:r.text,media_url:n,widget_link:r.widgetLink}),{...t,requires:"web_app_share_to_story",returns:"either"})}const Ws=sc(d(E(),z,A)),ic=m(Ws),Fn=Qe(!1);function oc({isInlineMode:e,postEvent:t,...n}){return B((r,i)=>t("web_app_switch_inline_query",{query:r,chat_types:i||[]}),{...n,requires:{every:["web_app_switch_inline_query",()=>Q(e)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}const Hs=oc({...d(E(),z,A),isInlineMode:Fn}),ac=m(Hs);class Ns{constructor({storage:t,isPageReload:n,onContentSafeAreaInsetsChanged:r,onSafeAreaInsetsChanged:i,onViewportChanged:s,onFullscreenChanged:a,offContentSafeAreaInsetsChanged:u,offFullscreenChanged:l,offSafeAreaInsetsChanged:c,offViewportChanged:h,request:f,isViewportStable:b,isFullscreen:v,isTma:F,version:S,postEvent:g}){o(this,"state");o(this,"height");o(this,"stableHeight");o(this,"width");o(this,"isExpanded");o(this,"isStable",C(()=>this.height()===this.stableHeight()));o(this,"contentSafeAreaInsets");o(this,"contentSafeAreaInsetTop");o(this,"contentSafeAreaInsetLeft");o(this,"contentSafeAreaInsetRight");o(this,"contentSafeAreaInsetBottom");o(this,"safeAreaInsets");o(this,"safeAreaInsetTop");o(this,"safeAreaInsetLeft");o(this,"safeAreaInsetRight");o(this,"safeAreaInsetBottom");o(this,"isFullscreen");o(this,"requestFullscreenFp");o(this,"requestFullscreen");o(this,"exitFullscreenFp");o(this,"exitFullscreen");o(this,"isCssVarsBound");o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"expandFp");o(this,"expand");const w={top:0,right:0,left:0,bottom:0},_=new ge({initialState:{contentSafeAreaInsets:w,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:w,stableHeight:0,width:0},onChange:t.set}),M=q=>{_.setState({isExpanded:q.is_expanded,height:q.height,width:q.width,stableHeight:q.is_state_stable?q.height:void 0})},L=q=>{_.setState({isFullscreen:q.is_fullscreen})},O=q=>{_.setState({safeAreaInsets:q})},k=q=>{_.setState({contentSafeAreaInsets:q})},V=new ln({initialState(q){const $e=fe=>()=>{const[ve,re]=fe==="safe-area"?["web_app_request_safe_area","safe_area_changed"]:["web_app_request_content_safe_area","content_safe_area_changed"];return pe(ve,Q(S))?f(ve,re,q):j({top:0,left:0,right:0,bottom:0})},W=fe=>()=>typeof fe=="boolean"?j(fe):Xr(fe());return d(Xa,pt("safeAreaInsets",$e("safe-area")),pt("contentSafeAreaInsets",$e("content-safe-area")),pt("isFullscreen",W(v)),pt("isViewportStable",W(b)),Me(({isViewportStable:fe,...ve})=>fe?j({...ve,height:window.innerHeight,isExpanded:!0,stableHeight:window.innerHeight,width:window.innerWidth}):d(f("web_app_request_viewport","viewport_changed",q),R(re=>({...ve,height:re.height,isExpanded:re.is_expanded,stableHeight:re.is_state_stable?re.height:0,width:re.width})))))},isPageReload:n,onMounted(q){s(M),a(L),i(O),r(k),_.setState(q)},onUnmounted(){h(M),l(L),c(O),u(k)},restoreState:t.get}),I=q=>C(()=>this.safeAreaInsets()[q]),G=q=>C(()=>this.contentSafeAreaInsets()[q]);this.state=_.state,this.height=_.getter("height"),this.stableHeight=_.getter("stableHeight"),this.width=_.getter("width"),this.isExpanded=_.getter("isExpanded"),this.safeAreaInsets=_.getter("safeAreaInsets"),this.safeAreaInsetTop=I("top"),this.safeAreaInsetBottom=I("bottom"),this.safeAreaInsetLeft=I("left"),this.safeAreaInsetRight=I("right"),this.contentSafeAreaInsets=_.getter("contentSafeAreaInsets"),this.contentSafeAreaInsetTop=G("top"),this.contentSafeAreaInsetBottom=G("bottom"),this.contentSafeAreaInsetLeft=G("left"),this.contentSafeAreaInsetRight=G("right");const Ve=T({isTma:F,returns:"task"}),Ye=T({isTma:F,returns:"either"}),pc=T({isTma:F,requires:"web_app_request_fullscreen",version:S,returns:"task"}),Ks=q=>pc($e=>d(f(q?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],$e),he(W=>"error"in W&&W.error!=="ALREADY_FULLSCREEN"?N(new rs(W.error)):(_.setState({isFullscreen:"is_fullscreen"in W?W.is_fullscreen:!0}),j(void 0)))));this.isMounted=V.isMounted,this.mountFp=Ve(V.mount),this.mount=m(this.mountFp),this.isFullscreen=_.getter("isFullscreen"),this.requestFullscreenFp=Ks(!0),this.requestFullscreen=m(this.requestFullscreenFp),this.exitFullscreenFp=Ks(!1),this.exitFullscreen=m(this.exitFullscreenFp);const _t=U(!1);this.isCssVarsBound=C(_t),this.bindCssVarsFp=Ye(q=>{if(_t())return D(new ht);q||(q=W=>`--tg-viewport-${jn(W)}`);const $e=[["height",this.height],["stableHeight",this.stableHeight],["width",this.width],["safeAreaInsetTop",this.safeAreaInsetTop],["safeAreaInsetBottom",this.safeAreaInsetBottom],["safeAreaInsetLeft",this.safeAreaInsetLeft],["safeAreaInsetRight",this.safeAreaInsetRight],["contentSafeAreaInsetTop",this.contentSafeAreaInsetTop],["contentSafeAreaInsetBottom",this.contentSafeAreaInsetBottom],["contentSafeAreaInsetLeft",this.contentSafeAreaInsetLeft],["contentSafeAreaInsetRight",this.contentSafeAreaInsetRight]].reduce((W,[fe,ve])=>{const re=q(fe);if(re){const Js=()=>{gn(re,`${ve()}px`)};W.push({update:Js,removeListener:ve.sub(Js),cssVar:re})}return W},[]);return $e.forEach(W=>{W.update()}),_t.set(!0),P(()=>{$e.forEach(W=>{W.removeListener(),wn(W.cssVar)}),_t.set(!1)})}),this.bindCssVars=m(this.bindCssVarsFp),this.expandFp=Ye(()=>g("web_app_expand")),this.expand=m(this.expandFp)}}function uc(){const e=s=>({on:a=>{te(s,a)},off:a=>{ke(s,a)}}),t=e("viewport_changed"),n=e("fullscreen_changed"),r=e("safe_area_changed"),i=e("content_safe_area_changed");return new Ns({...d(E(),we("viewport"),A,z,Y),isFullscreen(){return d(Be(),Z(s=>!!s.tgWebAppFullscreen))},isViewportStable(){return d(Be(),Z(s=>["macos","tdesktop","unigram","webk","weba","web"].includes(s.tgWebAppPlatform)))},offContentSafeAreaInsetsChanged:i.off,offFullscreenChanged:n.off,offSafeAreaInsetsChanged:r.off,offViewportChanged:t.off,onContentSafeAreaInsetsChanged:i.on,onFullscreenChanged:n.on,onSafeAreaInsetsChanged:r.on,onViewportChanged:t.on})}const cc=uc();function zs(e={}){const{version:t,isInlineMode:n,themeParams:r}=e;if(t&&typeof n=="boolean"&&r)un.set(t),Fn.set(n),bn.set(r);else{const u=d(Be(),An(l=>l,l=>{un.set(t||l.tgWebAppVersion),Fn.set(typeof n=="boolean"?n:!!l.tgWebAppBotInline),bn.set(r||l.tgWebAppThemeParams)}));if(u)return D(u)}e.postEvent&&as.set(e.postEvent);const[i,s]=st(te("reload_iframe",()=>{le().log("Received a request to reload the page"),us("iframe_will_reload"),window.location.reload()})),{acceptCustomStyles:a=!0}=e;if(a){const u=document.createElement("style");u.id="telegram-custom-styles",document.head.appendChild(u),i(te("set_custom_style",l=>{u.innerHTML=l}),()=>{document.head.removeChild(u)})}return d(Le("iframe_ready",{reload_supported:!0}),Z(()=>(le().log("The package was initialized"),s)))}const lc=X(zs);return p.AccessDeniedError=sn,p.BackButton=os,p.Biometry=ls,p.CSSVarsBoundError=ht,p.CancelledError=Rn,p.ClosingBehavior=ps,p.CloudStorage=hs,p.ConcurrentCallError=ft,p.FullscreenFailedError=rs,p.FunctionUnavailableError=ts,p.HapticFeedback=ms,p.InitData=ws,p.InvalidArgumentsError=ne,p.InvalidEnvError=tu,p.InvalidLaunchParamsError=Br,p.Invoice=vs,p.InvokeCustomMethodFailedError=Mr,p.LaunchParamsRetrieveError=Tr,p.LocationManager=Fs,p.MainButton=Ss,p.MethodParameterUnsupportedError=qr,p.MethodUnsupportedError=Ir,p.MiniApp=As,p.NotAvailableError=es,p.Popup=qs,p.QrScanner=Ps,p.SecondaryButton=Ms,p.SetEmojiStatusError=ns,p.SettingsButton=Ls,p.ShareMessageError=ss,p.SwipeBehavior=Vs,p.ThemeParams=$s,p.TimeoutError=Pt,p.UnknownEnvError=Pr,p.UnknownThemeParamsKeyError=is,p.ValidationError=ze,p.Viewport=Ns,p.addToHomeScreen=mu,p.addToHomeScreenFp=bs,p.applyPolyfills=_a,p.backButton=iu,p.biometry=au,p.checkHomeScreenStatus=gu,p.checkHomeScreenStatusFp=gs,p.closingBehavior=uu,p.cloudStorage=cu,p.copyTextToClipboard=Wu,p.createLogger=xn,p.createPostEvent=fa,p.createRequestId=dn,p.createStartParam=ga,p.createStartParamFp=zr,p.debug=xr,p.decodeBase64Url=ma,p.decodeBase64UrlFp=Qt,p.decodeStartParam=wa,p.decodeStartParamFp=Kr,p.deepSnakeToCamelObjKeys=Mt,p.downloadFile=Nu,p.downloadFileFp=Rs,p.emitEvent=ct,p.encodeBase64Url=Zt,p.getCurrentTime=Ku,p.getCurrentTimeFp=Os,p.getReleaseVersion=Jt,p.hapticFeedback=du,p.hideKeyboard=Qu,p.hideKeyboardFp=js,p.init=lc,p.initData=wu,p.initFp=zs,p.invoice=vu,p.invokeCustomMethod=fs,p.isAnyRGB=ir,p.isColorDark=vn,p.isColorDarkFp=Es,p.isRGB=xe,p.isRGBA=sr,p.isRGBAShort=rr,p.isRGBShort=nr,p.isSafeToCreateStartParam=va,p.isTMA=la,p.isTMAFp=Kt,p.locationManager=Au,p.logger=le,p.mainButton=Iu,p.miniApp=Is,p.mockTelegramEnv=pa,p.off=ke,p.offAll=sa,p.on=te,p.openLink=Cu,p.openLinkFp=ys,p.openTelegramLink=Su,p.openTelegramLinkFp=mn,p.parseInitDataQuery=fo,p.parseInitDataQueryFp=pr,p.parseLaunchParamsQuery=hr,p.parseLaunchParamsQueryFp=at,p.popup=Tu,p.postEvent=us,p.postEventFp=Le,p.qrScanner=Du,p.readTextFromClipboard=Yu,p.readTextFromClipboardFp=Ds,p.request=ou,p.requestContact=Ru,p.requestContactComplete=Vu,p.requestContactCompleteFp=Cn,p.requestContactFp=Ts,p.requestEmojiStatusAccess=pu,p.requestEmojiStatusAccessFp=ds,p.requestFp=hn,p.requestPhoneAccess=Pu,p.requestPhoneAccessFp=yn,p.requestWriteAccess=ju,p.requestWriteAccessFp=Bs,p.retrieveAndroidDeviceData=Xu,p.retrieveAndroidDeviceDataFrom=Us,p.retrieveLaunchParams=Yo,p.retrieveLaunchParamsFp=Be,p.retrieveRawInitData=Xo,p.retrieveRawInitDataFp=Gt,p.retrieveRawLaunchParams=ea,p.retrieveRawLaunchParamsFp=We,p.secondaryButton=Uu,p.sendData=tc,p.sendDataFp=xs,p.serializeInitDataQuery=dr,p.serializeLaunchParamsQuery=_r,p.setDebug=oa,p.setEmojiStatus=fu,p.setEmojiStatusFp=_s,p.setTargetOrigin=aa,p.settingsButton=xu,p.shareMessage=rc,p.shareMessageFp=Gs,p.shareStory=ic,p.shareStoryFp=Ws,p.shareURL=Eu,p.shareURLFp=Cs,p.supports=pe,p.swipeBehavior=Gu,p.switchInlineQuery=ac,p.switchInlineQueryFp=Hs,p.targetOrigin=Gr,p.themeParams=Ze,p.toRGB=ao,p.toRGBFp=ar,p.toRGBFull=uo,p.toRGBFullFp=ot,p.viewport=cc,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"}),p}({});
4
4
  //# sourceMappingURL=index.iife.js.map