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