@tma.js/sdk 3.0.3 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dts/features/QrScanner/QrScanner.d.ts +1 -1
- package/dist/dts/with-checks/withChecksFp.d.ts +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +3 -3
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +404 -406
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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 O=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)?O(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 O(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 j(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(([g,y])=>g===c&&y.once===f.once&&y.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 F(e,t){let n=new Set,r;function i(){return r||(r=j(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 D(e,t){return{kind:"schema",type:"loose_object",reference:D,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 g of h.issues)g.path=[b],(a=r.issues)==null||a.push(g);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 g of f.issues)g.path?g.path.unshift(b):g.path=[b],(u=r.issues)==null||u.push(g);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: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=[],g=()=>{b.forEach(w=>w()),b.splice(0,b.length),f={}},y=new AbortController,v=()=>h()||c();super((w,S)=>{const{abortOnResolve:_=!0,abortOnReject:U=!0}=a;i=k=>{var L,I;v()||(w(k),u=[k],(L=f.resolved)==null||L.forEach(G=>G(k)),(I=f.finalized)==null||I.forEach(G=>G({kind:"resolved",result:k})),g(),_&&y.abort($i(k)))},r=k=>{var L,I;v()||(S(k),l=[k],(L=f.rejected)==null||L.forEach(G=>G(k)),(I=f.finalized)==null||I.forEach(G=>G({kind:"rejected",reason:k})),g(),U&&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:x}=a;if(x){const k=setTimeout(()=>{r(new Pt(x))},x);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,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]}});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 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,g,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:${g}`,"",`${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([C(),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(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(),oo(e))}function Ot(e){return se(nt([C(),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 D({id:de(),photo_url:$(C()),type:C(),title:C(),username:$(C())})}function ur(){return D({added_to_attachment_menu:$(Fe()),allows_write_to_pm:$(Fe()),first_name:C(),id:de(),is_bot:$(Fe()),is_premium:$(Fe()),last_name:$(C()),language_code:$(C()),photo_url:$(C()),username:$(C())})}function lo(){return D({auth_date:se(C(),ue(e=>new Date(Number(e)*1e3)),tt()),can_send_after:$(se(C(),ue(Number),St())),chat:$(me(co())),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 Ot(lo())}function jt(){return It(C(),se(nt([C(),de()]),ue(e=>typeof e=="number"?`#${(e&16777215).toString(16).padStart(6,"0")}`:e),et(ir)))}function po(){const e=$(se(C(),ue(t=>t==="1")));return D({tgWebAppBotInline:e,tgWebAppData:$(cr()),tgWebAppDefaultColors:$(me(jt())),tgWebAppFullscreen:e,tgWebAppPlatform:C(),tgWebAppShowSettings:e,tgWebAppStartParam:$(C()),tgWebAppThemeParams:me(jt()),tgWebAppVersion:C()})}function ho(){return Ot(po())}function lr(){return D({eventType:C(),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(D({TelegramWebviewProxy:D({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:
|
|
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=j(!1),Ur=j("https://web.telegram.org"),ia=e=>{le().log("Event received:",e)},xr=F(Ht);function oa(e){e!==Ht()&&(Ht.set(e),(e?te:ke)("*",ia))}const Gr=F(Ur);function aa(e){Ur.set(e),le().log("New target origin set",e)}const lt=j((...e)=>{window.parent.postMessage(...e)}),le=j(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(D({external:D({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=j(),[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 g=v=>{v&&c(v[0])},y=()=>{s.unsub(g)};s.sub(g),f.on("finalized",y)},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&<.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(D({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 F(()=>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(O,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),R=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,V(t))},Ka=function(e,t){return d(e,Ja(t))},V=Pa(tn),nn=Re(3,Va(tn)),Ja=Ma(Ua),rn=Re(2,La(xa)),Qa=R,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=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 v=t.supports[y];return pe(v.method,v.param,n())},u=()=>{if(!s)return;const[y,v]="every"in s?["every",s.every]:["some",s.some];for(let w=0;w<v.length;w++){const S=v[w],_=typeof S=="function"?S():pe(S,n())?void 0:`it is unsupported in Mini Apps version ${n()}`;if(_&&(y==="every"||w===v.length-1))return _}},l=(...y)=>{for(const v in t.supports)if(t.supports[v].shouldCheck(...y)&&!a(v))return`option ${v} 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()),g=y=>{const v=new ts(y);return["task","promise"].includes(t.returns)?N(v):O(v)};return Object.assign((...y)=>{var U;const v="Unable to call function:";if(!r())return g(`${v} it can't be called outside Mini Apps`);if(!h())return g(`${v} the SDK was not initialized. Use the SDK init() function`);const w=u();if(w)return g(`${v} ${w}`);const S=l(...y);if(S)return g(`${v} ${S}`);if(!f()){const M=(U=t.isMounting)!=null&&U.call(t)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return g(`${v} the component is ${M}`)}const{returns:_}=t;return _==="plain"?ci(()=>e(...y),M=>M):_==="promise"?Na(()=>e(...y),M=>M):e(...y)},e,{isAvailable:b,ifAvailable(...y){return b()?He(e(...y)):Pe}},s?{isSupported:c}:{},t.supports?{supports:a}:{})}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=j(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",j(!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 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(w){n.set(w)}}),b=new Ke({initialState:s,isPageReload:a,onMounted:f.setState,restoreState:n.get}),g={version:h,requires:c,isTma:t},y=T({...g,returns:"plain"}),v=T({...g,returns:"either",isMounted:b.isMounted});this.isMounted=b.isMounted,this.isSupported=ie(c,h),this.state=f.state,this.setStateFp=v(w=>{const S={...this.state(),...on(w)};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 w=()=>{};return d(b.mount(),Oe(w,w))}),this.mount=m(this.mountFp),this.unmount=b.unmount,this.stateSetters=w=>{const S=v(_=>this.setStateFp({[w]:_}));return[m(S),S]},this.stateBoolSetters=w=>{const[,S]=this.stateSetters(w),_=v(()=>S(!1)),U=v(()=>S(!0));return[[m(_),_],[m(U),U]]}}stateGetter(t){return F(()=>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:F(()=>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 j(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",j(!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 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=w=>{h.setState(pn(w))},h=new ge({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:i.set}),f=new ln({initialState(w){return d(n("web_app_biometry_get_info","biometry_info_received",w),V(pn))},isPageReload:l,onMounted(w){h.setState(w),s(c)},onUnmounted(){a(c)},restoreState:i.get}),b={version:t,requires:"web_app_biometry_request_auth",isTma:u},g=T({...b,returns:"either"}),y=T({...b,returns:"task"}),v=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=y(f.mount),this.authenticateFp=v(w=>this.isAvailable()?d(n("web_app_biometry_request_auth","biometry_auth_requested",{...w,params:{reason:((w||{}).reason||"").trim()}}),V(S=>(h.setState({token:S.token}),S))):N(cs)),this.openSettingsFp=g(()=>r("web_app_biometry_open_settings")),this.requestAccessFp=v(w=>d(n("web_app_biometry_request_access","biometry_info_received",{...w,params:{reason:((w||{}).reason||"").trim()}}),he(S=>{const _=pn(S);return _.available?(h.setState(_),R(_.accessRequested)):N(cs)}))),this.updateTokenFp=v((w={})=>{var S;return d(n("web_app_biometry_update_token","biometry_token_updated",{...w,params:{token:w.token||"",reason:(S=w.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: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):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(It(C(),C()),u)})))),this.getKeysFp=i(s=>d(r("getStorageKeys",{},s),V(a=>_e(Bn(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 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),V(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)):R(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),V(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",j());o(this,"_raw",j());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(Jr(()=>{},({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 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=j(!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 ft("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 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 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 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)):O(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(g){return d(n("web_app_check_location","location_checked",g),V($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(g=>d(n("web_app_request_location","location_requested",g),V(y=>{if(!y.available)return u.setState({available:!1}),null;const{available:v,...w}=y;return w}))),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 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 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",j(!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||vn(t)}));o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");const u=new ge({initialState:{},onChange:s.set}),l=g=>{u.setState(g.theme_params)},c=new Ke({initialState:()=>P(Q(t)),isPageReload:a,onMounted(g){u.setState(g),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(g=>{if(this._isCssVarsBound())return O(new ht);g||(g=w=>`--tg-theme-${qi(w)}`);const y=w=>{Object.entries(u.state()).forEach(([S,_])=>{_&&w(S,_)})},v=()=>{y((w,S)=>{gn(g(w),S)})};return v(),u.state.sub(v),this._isCssVarsBound.set(!0),P(()=>{y(wn),u.state.unsub(v),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:F(()=>Ze.buttonColor()||"#2481cc"),textColor:F(()=>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",F(()=>{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(([U,M])=>{const x=U();if(!xe(x)&&(M==="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes(x))){const k=_[x];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=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 g=_=>xe(_)?_:Q(a)[_],y=_=>F(()=>g(_()));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 v=j(!1);this.isCssVarsBound=F(v),this.bindCssVarsFp=B(_=>{if(v())return O(new ht);const[U,M]=st(()=>{v.set(!1)}),x=(k,L)=>{const I=()=>{gn(k,L()||null)};I(),U(L.sub(I),wn.bind(null,k))};return _||(_=k=>`--tg-${jn(k)}`),x(_("bgColor"),this.bgColorRgb),x(_("bottomBarColor"),this.bottomBarColorRgb),x(_("headerColor"),this.headerColorRgb),v.set(!0),P(M)},{isTma:s,returns:"either",isMounted:this.isMounted}),this.bindCssVars=m(this.bindCssVarsFp);const w=_=>{const U=b.getter(_),M=y(U),x={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[_],k=B(L=>{if(L===U())return P(void 0);if(x==="web_app_set_header_color"&&(L==="bg_color"||L==="secondary_bg_color"))return i("web_app_set_header_color",{color_key:L});const I=g(L);return d(I?i(x,{color:I}):O(new is(L)),Z(()=>{b.setState({[_]:I})}))},{isTma:s,version:r,requires:x,isMounted:this.isMounted,returns:"either",supports:_==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:xe}}:void 0});return[U,M,m(k),k]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=w("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=w("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=w("bottomBarColor");const S=T({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 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 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 qs{constructor({version:t,isTma:n,request:r}){o(this,"isOpened");o(this,"isSupported");o(this,"showFp");o(this,"show");const i=j(!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=F(i),this.showFp=a(u=>d(this.isOpened()?N(new ft("A popup is already opened")):R(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),V(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(C(),u);if(!l.success)return N(new ze(u,l.issues));if(!l.output)return R(void 0);const c=Tt(Ot(D({contact:me(D({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),Ha(u=>ze.is(u)?O(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?R(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),V(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),V(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=j(!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:g=>{f.capture(g)&&(b=g,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 ft("The QR Scanner is already opened")):async()=>s("web_app_open_scan_qr_popup",{text:f.text}),Me(()=>{const[b,g]=st(),y=v=>(g(),v);return d(Ue(v=>{b(n(v),r(f.onCaptured))},f),nn(y,y))}))),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 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 Uu=new Ms(ks("secondaryButton","secondary_button_pressed",{bgColor:F(()=>Is.bottomBarColorRgb()||"#000000"),textColor:F(()=>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 g={isVerticalEnabled:b};return a.hasDiff(g)?d(t("web_app_setup_swipe_behavior",{allow_vertical_swipe:b}),Z(()=>{a.setState(g)})):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"?R(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?R(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)}),V(({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?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 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)):R(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:g,isTma:y,version:v,postEvent:w}){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 ge({initialState:{contentSafeAreaInsets:S,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:S,stableHeight:0,width:0},onChange:t.set}),U=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})},x=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(v))?f(ve,re,q):R({top:0,left:0,right:0,bottom:0})},W=fe=>()=>typeof fe=="boolean"?R(fe):Xr(fe());return d(Xa,pt("safeAreaInsets",$e("safe-area")),pt("contentSafeAreaInsets",$e("content-safe-area")),pt("isFullscreen",W(g)),pt("isViewportStable",W(b)),Me(({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(U),a(M),i(x),r(k),_.setState(q)},onUnmounted(){h(U),l(M),c(x),u(k)},restoreState:t.get}),I=q=>F(()=>this.safeAreaInsets()[q]),G=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=G("top"),this.contentSafeAreaInsetBottom=G("bottom"),this.contentSafeAreaInsetLeft=G("left"),this.contentSafeAreaInsetRight=G("right");const Ve=T({isTma:y,returns:"task"}),Ye=T({isTma:y,returns:"either"}),pc=T({isTma:y,requires:"web_app_request_fullscreen",version:v,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}),R(void 0)))));this.isMounted=L.isMounted,this.mountFp=Ve(L.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=j(!1);this.isCssVarsBound=F(_t),this.bindCssVarsFp=Ye(q=>{if(_t())return O(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(()=>w("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 O(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}({});
|
|
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 Se(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 Se(t)?t:P(e(t.right))}},ni={URI:wt,map:gt},ri=P,si=function(e){return function(t){return Se(t)?t:Se(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 Se(n)?D(e(n.left)):P(t(n.right))}},Se=Ys,An=function(e,t){return function(n){return Se(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 S(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 St;function _i(e){return St==null?void 0:St.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 Ct(e){return{kind:"validation",type:"integer",reference:Ct,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&K(this,"integer",t,n),t}}}function ue(e){return{kind:"transformation",type:"transform",reference:ue,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function vi(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}function 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,Si=(e,t,n)=>t in e?yi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mn=(e,t,n)=>Si(e,typeof t!="symbol"?t+"":t,n),Fi=Object.defineProperty,Ci=(e,t,n)=>t in e?Fi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bt=(e,t,n)=>Ci(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 Cn 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,C=()=>h()||c();super((g,w)=>{const{abortOnResolve:m=!0,abortOnReject:M=!0}=a;i=k=>{var V,I;C()||(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(),m&&F.abort($i(k)))},r=k=>{var V,I;C()||(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 Cn(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 Cn((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,Ce=no,ro=function(e){return function(t){return so(t)?t:Ce(e(t.right))}},so=eo,tr=function(e,t){try{return Ce(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 Ce(or(t.toLowerCase()+"f"));if(/^#[\da-f]{4}$/i.test(t))return Ce(or(t.toLowerCase()));if(/^#[\da-f]{6}$/i.test(t))return Ce(t.toLowerCase()+"ff");if(/^#[\da-f]{8}$/i.test(t))return Ce(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?Ce(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),Ct())),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}},So=function(e){return e._tag==="Left"},Fo=function(e){return{_tag:"Left",left:e}},Co=function(e){return{_tag:"Right",right:e}},be=Fo,ee=Co,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=So,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 Sr=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)()})}}),Cr="Task",kr={URI:Cr,map:Sr},Er={of:Fr},No={URI:Cr,map:Sr,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=S(Ht);function oa(e){e!==Ht()&&(Ht.set(e),(e?te:ke)("*",ia))}const Gr=S(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=C=>{C&&c(C[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&<.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 S(()=>pe(e,Q(t)))}var Pe=Qs,He=Zs,ya=function(e,t){return d(e,Ca(t))},Sa=function(e,t){return d(e,Ea(t))},Fa="Option",Ca=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:Sa,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 Se(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=S(()=>Q(t.version)||"100"),r=S(()=>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 m=0;m<w.length;m++){const M=w[m],L=typeof M=="function"?M():pe(M,n())?void 0:`it is unsupported in Mini Apps version ${n()}`;if(L&&(g==="every"||m===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=S(()=>!l()),f=S(()=>n()!=="0.0"),b=S(()=>t.isMounted?t.isMounted():!0),v=S(()=>r()&&f()&&h()&&b()),F=g=>{const w=new ts(g);return["task","promise"].includes(t.returns)?N(w):D(w)},C=(...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 m=l();if(m)return F(`${w} ${m}`);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 C(...g)},e,{isAvailable:v,ifAvailable(...g){return v()?He(C(...g)):Pe}},a?{isSupported:h}:{},t.supports?{supports:u}:{})}function T(e){return t=>B(t,e)}function _(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=S(this._state),this.state.sub(n)}getter(t){return S(()=>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",S(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"}),C=T({...v,returns:"either",isMounted:b.isMounted});this.isMounted=b.isMounted,this.isSupported=ie(c,h),this.state=f.state,this.setStateFp=C(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=_(this.setStateFp),this.onClickFp=F(r),this.onClick=_(this.onClickFp),this.offClickFp=F(i),this.offClick=_(this.offClickFp),this.mountFp=F(()=>{const g=()=>{};return d(b.mount(),Oe(g,g))}),this.mount=_(this.mountFp),this.unmount=b.unmount,this.stateSetters=g=>{const w=C(m=>this.setStateFp({[g]:m}));return[_(w),w]},this.stateBoolSetters=g=>{const[,w]=this.stateSetters(g),m=C(()=>w(!1)),M=C(()=>w(!0));return[[_(m),m],[_(M),M]]}}stateGetter(t){return S(()=>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:S(()=>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",S(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"}),C=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=C(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=C(g=>d(n("web_app_biometry_request_access","biometry_info_received",{...g,params:{reason:((g||{}).reason||"").trim()}}),he(w=>{const m=pn(w);return m.available?(h.setState(m),j(m.accessRequested)):N(cs)}))),this.updateTokenFp=C((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(m=>m.status))}),this.authenticate=_(this.authenticateFp),this.openSettings=_(this.openSettingsFp),this.requestAccess=_(this.requestAccessFp),this.updateToken=_(this.updateTokenFp),this.mount=_(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=_(this.disableConfirmationFp),this.enableConfirmation=_(this.enableConfirmationFp),this.mount=_(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=_(this.deleteItemFp),this.getItem=_(this.getItemFp),this.getItems=_(this.getItemsFp),this.getKeys=_(this.getKeysFp),this.setItem=_(this.setItemFp),this.clear=_(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=_(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=_(_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=_(this.impactOccurredFp),this.notificationOccurred=_(this.notificationOccurredFp),this.selectionChanged=_(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=_(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=_(gs);class ws{constructor({retrieveInitData:t}){o(this,"_state",U());o(this,"_raw",U());o(this,"state",S(this._state));o(this,"authDate",this.fromState("auth_date"));o(this,"canSendAfter",this.fromState("can_send_after"));o(this,"canSendAfterDate",S(()=>{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",S(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 S(()=>{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=S(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=_(this.openUrlFp),this.openSlug=_(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)),Su=_(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)),Cu=_(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 Ss=ku({...E(),openTelegramLink:mn}),Eu=_(Ss);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:C,...g}=F;return g}))),this.mount=_(this.mountFp),this.openSettings=_(this.openSettingsFp),this.requestLocation=_(this.requestLocationFp)}}const Au=new Fs(d(E(),z,A,Y,we("locationManager")));class Cs{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 S(()=>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",S(this._isCssVarsBound));o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"state");o(this,"isDark",S(()=>{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,m])=>{m&&g(w,m)})},C=()=>{F((g,w)=>{gn(v(g),w)})};return C(),u.state.sub(C),this._isCssVarsBound.set(!0),P(()=>{F(wn),u.state.unsub(C),this._isCssVarsBound.set(!1)})}),this.mountFp=f(c.mount),this.unmount=c.unmount,this.bindCssVars=_(this.bindCssVarsFp),this.mount=_(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 Cs(ks("mainButton","main_button_pressed",{bgColor:S(()=>Ze.buttonColor()||"#2481cc"),textColor:S(()=>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",S(()=>{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=m=>{b.setState({isActive:m.is_visible})},h=m=>{[[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=m[O];k&&i(L,{color:k})}})},f=new Ke({initialState(){return P({bgColor:"bg_color",headerColor:"header_bg_color",bottomBarColor:"bottom_bar_bg_color",isActive:!0})},isPageReload:n,onMounted:m=>{u(c),a.sub(h),b.setState(m)},onUnmounted(){l(c),a.unsub(h)},restoreState:t.get});this.isMounted=f.isMounted,this.mountFp=B(()=>{const m=()=>{};return d(f.mount(),Oe(m,m))},{isTma:s,returns:"plain"}),this.mount=_(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=m=>xe(m)?m:Q(a)[m],F=m=>S(()=>v(m()));this.isActive=b.getter("isActive"),this.isSupported=S(()=>["web_app_set_header_color","web_app_set_background_color","web_app_set_bottom_bar_color"].some(m=>pe(m,Q(r))));const C=U(!1);this.isCssVarsBound=S(C),this.bindCssVarsFp=B(m=>{if(C())return D(new ht);const[M,L]=st(()=>{C.set(!1)}),O=(k,V)=>{const I=()=>{gn(k,V()||null)};I(),M(V.sub(I),wn.bind(null,k))};return m||(m=k=>`--tg-${jn(k)}`),O(m("bgColor"),this.bgColorRgb),O(m("bottomBarColor"),this.bottomBarColorRgb),O(m("headerColor"),this.headerColorRgb),C.set(!0),P(L)},{isTma:s,returns:"either",isMounted:this.isMounted}),this.bindCssVars=_(this.bindCssVarsFp);const g=m=>{const M=b.getter(m),L=F(M),O={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[m],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({[m]:I})}))},{isTma:s,version:r,requires:O,isMounted:this.isMounted,returns:"either",supports:m==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:xe}}:void 0});return[M,L,_(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(m=>i("web_app_close",{return_back:m})),this.close=_(this.closeFp),this.readyFp=w(()=>i("web_app_ready")),this.ready=_(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=S(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=_(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=_(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 Sn=Mu({...d(E(),_n,A),requestPhoneAccess:yn}),Vu=_(Sn),Ts=Lu({...d(E(),A),requestContact(e){return d(Sn(e),R(t=>t.parsed))}}),Ru=_(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=_(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=S(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=C=>(v(),C);return d(Ue(C=>{b(n(C),r(f.onCaptured))},f),nn(F,F))}))),this.open=_(this.openFp),this.capture=_(this.captureFp),this.close=_(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 S(()=>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:S(()=>Is.bottomBarColorRgb()||"#000000"),textColor:S(()=>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=_(this.disableVerticalFp),this.enableVertical=_(this.enableVerticalFp),this.mount=_(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=_(Rs);function zu({invokeCustomMethod:e,...t}){return B(n=>d(e("getCurrentTime",{},n),he(r=>{const i=Tt(se(de(),Ct(),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=_(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=_(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=_(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=_(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=_(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=_(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=_(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:C,postEvent:g}){o(this,"state");o(this,"height");o(this,"stableHeight");o(this,"width");o(this,"isExpanded");o(this,"isStable",S(()=>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},m=new ge({initialState:{contentSafeAreaInsets:w,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:w,stableHeight:0,width:0},onChange:t.set}),M=q=>{m.setState({isExpanded:q.is_expanded,height:q.height,width:q.width,stableHeight:q.is_state_stable?q.height:void 0})},L=q=>{m.setState({isFullscreen:q.is_fullscreen})},O=q=>{m.setState({safeAreaInsets:q})},k=q=>{m.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(C))?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),m.setState(q)},onUnmounted(){h(M),l(L),c(O),u(k)},restoreState:t.get}),I=q=>S(()=>this.safeAreaInsets()[q]),G=q=>S(()=>this.contentSafeAreaInsets()[q]);this.state=m.state,this.height=m.getter("height"),this.stableHeight=m.getter("stableHeight"),this.width=m.getter("width"),this.isExpanded=m.getter("isExpanded"),this.safeAreaInsets=m.getter("safeAreaInsets"),this.safeAreaInsetTop=I("top"),this.safeAreaInsetBottom=I("bottom"),this.safeAreaInsetLeft=I("left"),this.safeAreaInsetRight=I("right"),this.contentSafeAreaInsets=m.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:C,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)):(m.setState({isFullscreen:"is_fullscreen"in W?W.is_fullscreen:!0}),j(void 0)))));this.isMounted=V.isMounted,this.mountFp=Ve(V.mount),this.mount=_(this.mountFp),this.isFullscreen=m.getter("isFullscreen"),this.requestFullscreenFp=Ks(!0),this.requestFullscreen=_(this.requestFullscreenFp),this.exitFullscreenFp=Ks(!1),this.exitFullscreen=_(this.exitFullscreenFp);const _t=U(!1);this.isCssVarsBound=S(_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=_(this.bindCssVarsFp),this.expandFp=Ye(()=>g("web_app_expand")),this.expand=_(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=Cs,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=Su,p.openLinkFp=ys,p.openTelegramLink=Cu,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=Sn,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=Ss,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
|