@tma.js/bridge 2.2.3 → 2.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -3
- 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 +183 -173
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
this.tapps=this.tapps||{};this.tapps.bridge=function(f){"use strict";var j;function We(e){return{lang:(e==null?void 0:e.lang)??(j==null?void 0:j.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(j==null?void 0:j.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(j==null?void 0:j.abortPipeEarly)}}var ue;function Gt(e){return ue==null?void 0:ue.get(e)}var oe;function Jt(e){return oe==null?void 0:oe.get(e)}var ce;function Bt(e,t){var n;return(n=ce==null?void 0:ce.get(e))==null?void 0:n.get(t)}function Kt(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 w(e,t,n,r,s){const a=s&&"input"in s?s.input:n.value,i=(s==null?void 0:s.expected)??e.expects??null,o=(s==null?void 0:s.received)??Kt(a),c={kind:e.kind,type:e.type,input:a,expected:i,received:o,message:`Invalid ${t}: ${i?`Expected ${i} but r`:"R"}eceived ${o}`,requirement:e.requirement,path:s==null?void 0:s.path,issues:s==null?void 0:s.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},u=e.kind==="schema",l=(s==null?void 0:s.message)??e.message??Bt(e.reference,c.lang)??(u?Jt(c.lang):null)??r.message??Gt(c.lang);l!==void 0&&(c.message=typeof l=="function"?l(c):l),u&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function E(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},We())}}}function De(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function Ht(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}var Qt=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function Q(e,t){return{kind:"validation",type:"check",reference:Q,async:!1,expects:null,requirement:e,message:t,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&w(this,"input",n,r),n}}}function Ue(e){return{kind:"validation",type:"integer",reference:Ue,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&w(this,"integer",t,n),t}}}function R(e){return{kind:"transformation",type:"transform",reference:R,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function Xt(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}function le(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function fe(e,t){return!e["~run"]({value:t},{abortEarly:!0}).issues}function Ne(){return{kind:"schema",type:"any",reference:Ne,expects:"any",async:!1,get"~standard"(){return E(this)},"~run"(e){return e.typed=!0,e}}}function I(e){return{kind:"schema",type:"boolean",reference:I,expects:"boolean",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:w(this,"type",t,n),t}}}function xe(e){return{kind:"schema",type:"date",reference:xe,expects:"Date",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,n){return t.value instanceof Date?isNaN(t.value)?w(this,"type",t,n,{received:'"Invalid Date"'}):t.typed=!0:w(this,"type",t,n),t}}}function pe(e){return{kind:"schema",type:"function",reference:pe,expects:"Function",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,n){return typeof t.value=="function"?t.typed=!0:w(this,"type",t,n),t}}}function _e(e,t){return{kind:"schema",type:"instance",reference:_e,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return E(this)},"~run"(n,r){return n.value instanceof this.class?n.typed=!0:w(this,"type",n,r),n}}}function g(e,t){return{kind:"schema",type:"loose_object",reference:g,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return E(this)},"~run"(n,r){var a;const s=n.value;if(s&&typeof s=="object"){n.typed=!0,n.value={};for(const i in this.entries){const o=this.entries[i];if(i in s||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){const c=i in s?s[i]:le(o),u=o["~run"]({value:c},r);if(u.issues){const l={type:"object",origin:"value",input:s,key:i,value:c};for(const p of u.issues)p.path?p.path.unshift(l):p.path=[l],(a=n.issues)==null||a.push(p);if(n.issues||(n.issues=u.issues),r.abortEarly){n.typed=!1;break}}u.typed||(n.typed=!1),n.value[i]=u.value}else if(o.fallback!==void 0)n.value[i]=Xt(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"&&(w(this,"key",n,r,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:s,key:i,value:s[i]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly)for(const i in s)De(s,i)&&!(i in this.entries)&&(n.value[i]=s[i])}else w(this,"type",n,r);return n}}}function L(e,t){return{kind:"schema",type:"nullish",reference:L,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return E(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=le(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function W(e){return{kind:"schema",type:"number",reference:W,expects:"number",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:w(this,"type",t,n),t}}}function d(e,t){return{kind:"schema",type:"optional",reference:d,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return E(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=le(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function ze(e,t,n){return{kind:"schema",type:"record",reference:ze,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return E(this)},"~run"(r,s){var i,o;const a=r.value;if(a&&typeof a=="object"){r.typed=!0,r.value={};for(const c in a)if(De(a,c)){const u=a[c],l=this.key["~run"]({value:c},s);if(l.issues){const h={type:"object",origin:"key",input:a,key:c,value:u};for(const m of l.issues)m.path=[h],(i=r.issues)==null||i.push(m);if(r.issues||(r.issues=l.issues),s.abortEarly){r.typed=!1;break}}const p=this.value["~run"]({value:u},s);if(p.issues){const h={type:"object",origin:"value",input:a,key:c,value:u};for(const m of p.issues)m.path?m.path.unshift(h):m.path=[h],(o=r.issues)==null||o.push(m);if(r.issues||(r.issues=p.issues),s.abortEarly){r.typed=!1;break}}(!l.typed||!p.typed)&&(r.typed=!1),l.typed&&(r.value[l.value]=p.value)}}else w(this,"type",r,s);return r}}}function _(e){return{kind:"schema",type:"string",reference:_,expects:"string",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:w(this,"type",t,n),t}}}function Ve(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function X(e,t){return{kind:"schema",type:"union",reference:X,expects:Ht(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return E(this)},"~run"(n,r){let s,a,i;for(const o of this.options){const c=o["~run"]({value:n.value},r);if(c.typed)if(c.issues)a?a.push(c):a=[c];else{s=c;break}else i?i.push(c):i=[c]}if(s)return s;if(a){if(a.length===1)return a[0];w(this,"type",n,r,{issues:Ve(a)}),n.typed=!0}else{if((i==null?void 0:i.length)===1)return i[0];w(this,"type",n,r,{issues:Ve(i)})}return n}}}function he(){return{kind:"schema",type:"unknown",reference:he,expects:"unknown",async:!1,get"~standard"(){return E(this)},"~run"(e){return e.typed=!0,e}}}function V(e,t,n){const r=e["~run"]({value:t},We(n));if(r.issues)throw new Qt(r.issues);return r.value}function A(...e){return{...e[0],pipe:e,get"~standard"(){return E(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 de(e){return fe(g({TelegramWebviewProxy:g({postEvent:pe()})}),e)}function me(){try{return window.self!==window.top}catch{return!0}}var Yt=Object.defineProperty,Zt=(e,t,n)=>t in e?Yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ge=(e,t,n)=>Zt(e,typeof t!="symbol"?t+"":t,n),en=Object.defineProperty,tn=(e,t,n)=>t in e?en(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ye=(e,t,n)=>tn(e,typeof t!="symbol"?t+"":t,n);function Je(e){return t=>t instanceof e}function Be(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}};ye(n,"is",Je(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function nn(e,t,n){const r=class extends Be(e,n){constructor(...a){super(...a),ye(this,"data"),this.data=t(...a)}};ye(r,"is",Je(r));let s=r;return Object.defineProperty(s,"name",{value:e}),s}class Ke extends Be("CancelledError","Promise was canceled"){}let ve=class extends nn("TimeoutError",t=>({timeout:t}),(t,n)=>[`Timeout reached: ${t}ms`,{cause:n}]){};const rn=Symbol("resolved");function sn(e){return{tag:rn,value:e}}function He(e,t){return e.reject=t.reject,e.resolve=t.resolve,e}class F extends Promise{constructor(t,n){let r,s,a,i;typeof t=="function"?(a=t,i=n||{}):i=t||{};let o,c;const u=()=>!!c,l=()=>!!o;let p={};const h=[],m=()=>{h.forEach(qe=>qe()),h.splice(0,h.length),p={}},$=new AbortController,T=()=>l()||u();super((qe,Mr)=>{const{abortOnResolve:Rr=!0,abortOnReject:Ir=!0}=i;s=y=>{var M,k;T()||(qe(y),o=[y],(M=p.resolved)==null||M.forEach(P=>P(y)),(k=p.finalized)==null||k.forEach(P=>P({kind:"resolved",result:y})),m(),Rr&&$.abort(sn(y)))},r=y=>{var M,k;T()||(Mr(y),c=[y],(M=p.rejected)==null||M.forEach(P=>P(y)),(k=p.finalized)==null||k.forEach(P=>P({kind:"rejected",reason:y})),m(),Ir&&$.abort(y))};const{abortSignal:z}=i;if(z){if(z.aborted)return r(z.reason);const y=()=>{r(z.reason)};z.addEventListener("abort",y,!0),h.push(()=>{z.removeEventListener("abort",y,!0)})}const{timeout:Le}=i;if(Le){const y=setTimeout(()=>{r(new ve(Le))},Le);h.push(()=>{clearTimeout(y)})}try{const y=()=>{},M=a&&a(s,r,{abortSignal:$.signal,get isRejected(){return u()},get isResolved(){return l()},on(k,P){if(o||c){if(k==="finalized"){const ie=o?{kind:"resolved",result:o[0]}:{kind:"rejected",reason:c[0]};P(ie)}else k==="resolved"&&o?P(o[0]):k==="rejected"&&c&&P(c[0]);return y}return p[k]||(p[k]=[]),p[k].push(P),()=>{const ie=p[k]||[],Vt=ie.indexOf(P);Vt>=0&&ie.splice(Vt,1)}},get result(){return o==null?void 0:o[0]},get rejectReason(){return c==null?void 0:c[0]},throwIfRejected(){if(c)throw c[0]}});M instanceof Promise&&M.catch(r)}catch(y){r(y)}}),Ge(this,"reject"),Ge(this,"resolve"),this.reject=r,this.resolve=s}static fn(t,n){return new F(async(r,s,a)=>{try{r(await t(a))}catch(i){s(i)}},n)}static resolve(t){return this.fn(()=>t)}static reject(t){return new F((n,r)=>{r(t)})}cancel(){this.reject(new Ke)}catch(t){return this.then(void 0,t)}finally(t){return He(super.finally(t),this)}then(t,n){return He(super.then(t,n),this)}}var an=function(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,a;r<s;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};function un(e){return e}function Qe(e,t,n,r,s,a,i,o,c){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 s(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return a(s(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return i(a(s(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return o(i(a(s(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(o(i(a(s(r(n(t(e.apply(this,arguments)))))))))}}}function v(e,t,n,r,s,a,i,o,c){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 s(r(n(t(e))));case 6:return a(s(r(n(t(e)))));case 7:return i(a(s(r(n(t(e))))));case 8:return o(i(a(s(r(n(t(e)))))));case 9:return c(o(i(a(s(r(n(t(e))))))));default:{for(var u=arguments[0],l=1;l<arguments.length;l++)u=arguments[l](u);return u}}}var Y=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(s){return t.apply(void 0,an([s],r,!1))}}},on={_tag:"None"},cn=function(e){return{_tag:"Some",value:e}},ln=function(e){return e._tag==="Left"},Xe=function(e){return{_tag:"Left",left:e}},Ye=function(e){return{_tag:"Right",right:e}},fn=on,pn=cn,_n=function(e){return e._tag==="None"},hn=function(e,t){return function(n){return _n(n)?e():t(n.value)}},dn=hn,S=Xe,b=Ye,Ze=Y(2,function(e,t){return D(e)?e:t(e.right)}),mn=function(e){return function(t){return D(t)?t:b(e(t.right))}},yn=function(e,t){return function(n){return D(n)?S(e(n.left)):b(t(n.right))}},vn=function(e){return function(t){return D(t)?S(e(t.left)):t}},D=ln,et=function(e,t){return function(n){return D(n)?e(n.left):t(n.right)}},gn=et,G=et,bn=G,Z=function(e,t){try{return b(e())}catch(n){return S(t(n))}},wn=Ze,En=Ze;function kn(e){return Qe(b,e.of)}function Pn(e){return Qe(S,e.of)}function $n(e){return function(t,n){return e.chain(t,function(r){return D(r)?e.of(r):n(r.right)})}}function Sn(e){return function(t,n,r){return e.map(t,yn(n,r))}}function jn(e){return function(t,n){return function(r){return e.map(r,G(t,n))}}}var An=function(e){return Z(function(){return JSON.parse(e)},un)},tt=function(e,t){return v(e,Tn(t))},On=function(e,t){return v(e,Mn(t))},Tn=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},Mn=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],s=n[1];return r(s)})}}},ge=function(e){return function(){return Promise.resolve(e)}},Rn=Y(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),nt="Task",rt={URI:nt,map:tt},st={of:ge},In={URI:nt,map:tt,of:ge,ap:On,chain:Rn},Fn=function(e,t,n,r){function s(a){return a instanceof n?a:new n(function(i){i(a)})}return new(n||(n=Promise))(function(a,i){function o(l){try{u(r.next(l))}catch(p){i(p)}}function c(l){try{u(r.throw(l))}catch(p){i(p)}}function u(l){l.done?a(l.value):s(l.value).then(o,c)}u((r=r.apply(e,t||[])).next())})},Cn=function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,s,a,i;return i={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function o(u){return function(l){return c([u,l])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(n=0)),n;)try{if(r=1,s&&(a=u[0]&2?s.return:u[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,u[1])).done)return a;switch(s=0,a&&(u=[u[0]&2,a.value]),u[0]){case 0:case 1:a=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,s=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(a=n.trys,!(a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){n.label=u[1];break}if(u[0]===6&&n.label<a[1]){n.label=a[1],a=u;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(u);break}a[2]&&n.ops.pop(),n.trys.pop();continue}u=t.call(e,n)}catch(l){u=[6,l],s=0}finally{r=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},at=Pn(st),be=kn(st),qn=ge,ee=jn(rt),Ln=ee,Wn=function(e,t){return function(){return Fn(void 0,void 0,void 0,function(){var n;return Cn(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e().then(Ye)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,Xe(t(n))];case 3:return[2]}})})}},it=Y(3,Sn(rt)),ut=Y(2,$n(In)),Dn=ut,we=ut;function Un(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function Nn(e){return Object.entries(e).reduce((t,[n,r])=>(t[Un(n)]=r,t),{})}function Ee(e){const t=Nn(e);for(const n in t){const r=t[n];r&&typeof r=="object"&&!(r instanceof Date)&&(t[n]=Array.isArray(r)?r.map(Ee):Ee(r))}return t}function ot(e){return`tapps/${e}`}function ct(e,t){sessionStorage.setItem(ot(e),JSON.stringify(t))}function xn(e){const t=sessionStorage.getItem(ot(e));try{return t?JSON.parse(t):void 0}catch{}}function lt(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(n=>{n()})}]}function ft(e,t){t||(t={});const{textColor:n,bgColor:r,shouldLog:s}=t,a=s===void 0?!0:s,i=typeof a=="boolean"?()=>a:a,o=(c,u,...l)=>{if(u||i()){const p="font-weight:bold;padding:0 5px;border-radius:100px",[h,m,$]={log:["#0089c3","white","INFO"],error:["#ff0000F0","white","ERR"],warn:["#D38E15","white","WARN"]}[c];console[c](`%c${$} ${Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(new Date)}%c %c${e}`,`${p};background-color:${h};color:${m}`,"",`${p};${n?`color:${n};`:""}${r?`background-color:${r}`:""}`,...l)}};return[["log","forceLog"],["warn","forceWarn"],["error","forceError"]].reduce((c,[u,l])=>(c[u]=o.bind(void 0,u,!1),c[l]=o.bind(void 0,u,!0),c),{})}function J(e){const t=n=>{throw n};return typeof e=="function"?F.resolve(v(e,ee(t,n=>n))()):v(e,G(t,n=>n))}function B(e){return Object.assign((...t)=>J(e(...t)),e)}const ke=Object.assign((e,t)=>v(Wn(()=>new F((n,r,s)=>e(a=>n(b(a)),a=>n(S(a)),s),t),n=>n),we(G(at,be))),{fn:(e,t)=>ke((n,r,s)=>{const a=e(s);v(typeof a=="function"?a:qn(a),Ln(r,n))()},t)});var zn=Object.defineProperty,Vn=(e,t,n)=>t in e?zn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pe=(e,t,n)=>Vn(e,typeof t!="symbol"?t+"":t,n);function pt(e){return t=>t instanceof e}function U(e,t){const n=class extends Error{constructor(...a){const i=typeof t=="function"?t(...a):typeof t=="string"?[t]:t||[];super(...i),this.name=e}};Pe(n,"is",pt(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function Gn(e,t,n){const r=class extends U(e,n){constructor(...i){super(...i),Pe(this,"data"),this.data=t(...i)}};Pe(r,"is",pt(r));let s=r;return Object.defineProperty(s,"name",{value:e}),s}class _t extends U("MethodUnsupportedError",(t,n)=>[`Method "${t}" is unsupported in Mini Apps version ${n}`]){}class ht extends U("MethodParameterUnsupportedError",(t,n,r)=>[`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${r}`]){}class dt extends Gn("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
|
|
3
|
-
`),t,
|
|
1
|
+
this.tapps=this.tapps||{};this.tapps.bridge=function(p){"use strict";var j;function Le(e){return{lang:(e==null?void 0:e.lang)??(j==null?void 0:j.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(j==null?void 0:j.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(j==null?void 0:j.abortPipeEarly)}}var ue;function Bt(e){return ue==null?void 0:ue.get(e)}var oe;function Kt(e){return oe==null?void 0:oe.get(e)}var ce;function Ht(e,t){var r;return(r=ce==null?void 0:ce.get(e))==null?void 0:r.get(t)}function Qt(e){var r,n;const t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&((n=(r=Object.getPrototypeOf(e))==null?void 0:r.constructor)==null?void 0:n.name))??"null":t}function w(e,t,r,n,s){const a=s&&"input"in s?s.input:r.value,u=(s==null?void 0:s.expected)??e.expects??null,o=(s==null?void 0:s.received)??Qt(a),c={kind:e.kind,type:e.type,input:a,expected:u,received:o,message:`Invalid ${t}: ${u?`Expected ${u} but r`:"R"}eceived ${o}`,requirement:e.requirement,path:s==null?void 0:s.path,issues:s==null?void 0:s.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},i=e.kind==="schema",l=(s==null?void 0:s.message)??e.message??Ht(e.reference,c.lang)??(i?Kt(c.lang):null)??n.message??Bt(c.lang);l!==void 0&&(c.message=typeof l=="function"?l(c):l),i&&(r.typed=!1),r.issues?r.issues.push(c):r.issues=[c]}function E(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},Le())}}}function De(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function Xt(e,t){const r=[...new Set(e)];return r.length>1?`(${r.join(` ${t} `)})`:r[0]??"never"}var Yt=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function Q(e,t){return{kind:"validation",type:"check",reference:Q,async:!1,expects:null,requirement:e,message:t,"~run"(r,n){return r.typed&&!this.requirement(r.value)&&w(this,"input",r,n),r}}}function Ue(e){return{kind:"validation",type:"integer",reference:Ue,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,r){return t.typed&&!this.requirement(t.value)&&w(this,"integer",t,r),t}}}function R(e){return{kind:"transformation",type:"transform",reference:R,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function Zt(e,t,r){return typeof e.fallback=="function"?e.fallback(t,r):e.fallback}function le(e,t,r){return typeof e.default=="function"?e.default(t,r):e.default}function pe(e,t){return!e["~run"]({value:t},{abortEarly:!0}).issues}function xe(){return{kind:"schema",type:"any",reference:xe,expects:"any",async:!1,get"~standard"(){return E(this)},"~run"(e){return e.typed=!0,e}}}function I(e){return{kind:"schema",type:"boolean",reference:I,expects:"boolean",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,r){return typeof t.value=="boolean"?t.typed=!0:w(this,"type",t,r),t}}}function Ne(e){return{kind:"schema",type:"date",reference:Ne,expects:"Date",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,r){return t.value instanceof Date?isNaN(t.value)?w(this,"type",t,r,{received:'"Invalid Date"'}):t.typed=!0:w(this,"type",t,r),t}}}function fe(e){return{kind:"schema",type:"function",reference:fe,expects:"Function",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,r){return typeof t.value=="function"?t.typed=!0:w(this,"type",t,r),t}}}function _e(e,t){return{kind:"schema",type:"instance",reference:_e,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return E(this)},"~run"(r,n){return r.value instanceof this.class?r.typed=!0:w(this,"type",r,n),r}}}function g(e,t){return{kind:"schema",type:"loose_object",reference:g,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return E(this)},"~run"(r,n){var a;const s=r.value;if(s&&typeof s=="object"){r.typed=!0,r.value={};for(const u in this.entries){const o=this.entries[u];if(u in s||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){const c=u in s?s[u]:le(o),i=o["~run"]({value:c},n);if(i.issues){const l={type:"object",origin:"value",input:s,key:u,value:c};for(const f of i.issues)f.path?f.path.unshift(l):f.path=[l],(a=r.issues)==null||a.push(f);if(r.issues||(r.issues=i.issues),n.abortEarly){r.typed=!1;break}}i.typed||(r.typed=!1),r.value[u]=i.value}else if(o.fallback!==void 0)r.value[u]=Zt(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"&&(w(this,"key",r,n,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:s,key:u,value:s[u]}]}),n.abortEarly))break}if(!r.issues||!n.abortEarly)for(const u in s)De(s,u)&&!(u in this.entries)&&(r.value[u]=s[u])}else w(this,"type",r,n);return r}}}function q(e,t){return{kind:"schema",type:"nullish",reference:q,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return E(this)},"~run"(r,n){return(r.value===null||r.value===void 0)&&(this.default!==void 0&&(r.value=le(this,r,n)),r.value===null||r.value===void 0)?(r.typed=!0,r):this.wrapped["~run"](r,n)}}}function L(e){return{kind:"schema",type:"number",reference:L,expects:"number",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,r){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:w(this,"type",t,r),t}}}function m(e,t){return{kind:"schema",type:"optional",reference:m,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return E(this)},"~run"(r,n){return r.value===void 0&&(this.default!==void 0&&(r.value=le(this,r,n)),r.value===void 0)?(r.typed=!0,r):this.wrapped["~run"](r,n)}}}function ze(e,t,r){return{kind:"schema",type:"record",reference:ze,expects:"Object",async:!1,key:e,value:t,message:r,get"~standard"(){return E(this)},"~run"(n,s){var u,o;const a=n.value;if(a&&typeof a=="object"){n.typed=!0,n.value={};for(const c in a)if(De(a,c)){const i=a[c],l=this.key["~run"]({value:c},s);if(l.issues){const h={type:"object",origin:"key",input:a,key:c,value:i};for(const d of l.issues)d.path=[h],(u=n.issues)==null||u.push(d);if(n.issues||(n.issues=l.issues),s.abortEarly){n.typed=!1;break}}const f=this.value["~run"]({value:i},s);if(f.issues){const h={type:"object",origin:"value",input:a,key:c,value:i};for(const d of f.issues)d.path?d.path.unshift(h):d.path=[h],(o=n.issues)==null||o.push(d);if(n.issues||(n.issues=f.issues),s.abortEarly){n.typed=!1;break}}(!l.typed||!f.typed)&&(n.typed=!1),l.typed&&(n.value[l.value]=f.value)}}else w(this,"type",n,s);return n}}}function _(e){return{kind:"schema",type:"string",reference:_,expects:"string",async:!1,message:e,get"~standard"(){return E(this)},"~run"(t,r){return typeof t.value=="string"?t.typed=!0:w(this,"type",t,r),t}}}function Ve(e){let t;if(e)for(const r of e)t?t.push(...r.issues):t=r.issues;return t}function X(e,t){return{kind:"schema",type:"union",reference:X,expects:Xt(e.map(r=>r.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return E(this)},"~run"(r,n){let s,a,u;for(const o of this.options){const c=o["~run"]({value:r.value},n);if(c.typed)if(c.issues)a?a.push(c):a=[c];else{s=c;break}else u?u.push(c):u=[c]}if(s)return s;if(a){if(a.length===1)return a[0];w(this,"type",r,n,{issues:Ve(a)}),r.typed=!0}else{if((u==null?void 0:u.length)===1)return u[0];w(this,"type",r,n,{issues:Ve(u)})}return r}}}function he(){return{kind:"schema",type:"unknown",reference:he,expects:"unknown",async:!1,get"~standard"(){return E(this)},"~run"(e){return e.typed=!0,e}}}function V(e,t,r){const n=e["~run"]({value:t},Le(r));if(n.issues)throw new Yt(n.issues);return n.value}function A(...e){return{...e[0],pipe:e,get"~standard"(){return E(this)},"~run"(t,r){for(const n of e)if(n.kind!=="metadata"){if(t.issues&&(n.kind==="schema"||n.kind==="transformation")){t.typed=!1;break}(!t.issues||!r.abortEarly&&!r.abortPipeEarly)&&(t=n["~run"](t,r))}return t}}}function me(e){return typeof e=="object"&&!!e&&!Array.isArray(e)&&pe(g({TelegramWebviewProxy:g({postEvent:fe()})}),{TelegramWebviewProxy:e.TelegramWebviewProxy})}function de(){try{return window.self!==window.top}catch{return!0}}var er=Object.defineProperty,tr=(e,t,r)=>t in e?er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ge=(e,t,r)=>tr(e,typeof t!="symbol"?t+"":t,r),rr=Object.defineProperty,nr=(e,t,r)=>t in e?rr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ye=(e,t,r)=>nr(e,typeof t!="symbol"?t+"":t,r);function Je(e){return t=>t instanceof e}function Be(e,t){const r=class extends Error{constructor(...s){const a=typeof t=="function"?t(...s):typeof t=="string"?[t]:t||[];super(...a),this.name=e}};ye(r,"is",Je(r));let n=r;return Object.defineProperty(n,"name",{value:e}),n}function sr(e,t,r){const n=class extends Be(e,r){constructor(...a){super(...a),ye(this,"data"),this.data=t(...a)}};ye(n,"is",Je(n));let s=n;return Object.defineProperty(s,"name",{value:e}),s}class Ke extends Be("CancelledError","Promise was canceled"){}let ve=class extends sr("TimeoutError",t=>({timeout:t}),(t,r)=>[`Timeout reached: ${t}ms`,{cause:r}]){};const ar=Symbol("resolved");function ir(e){return{tag:ar,value:e}}function He(e,t){return e.reject=t.reject,e.resolve=t.resolve,e}class F extends Promise{constructor(t,r){let n,s,a,u;typeof t=="function"?(a=t,u=r||{}):u=t||{};let o,c;const i=()=>!!c,l=()=>!!o;let f={};const h=[],d=()=>{h.forEach(We=>We()),h.splice(0,h.length),f={}},S=new AbortController,T=()=>l()||i();super((We,In)=>{const{abortOnResolve:Fn=!0,abortOnReject:Cn=!0}=u;s=y=>{var M,k;T()||(We(y),o=[y],(M=f.resolved)==null||M.forEach(P=>P(y)),(k=f.finalized)==null||k.forEach(P=>P({kind:"resolved",result:y})),d(),Fn&&S.abort(ir(y)))},n=y=>{var M,k;T()||(In(y),c=[y],(M=f.rejected)==null||M.forEach(P=>P(y)),(k=f.finalized)==null||k.forEach(P=>P({kind:"rejected",reason:y})),d(),Cn&&S.abort(y))};const{abortSignal:z}=u;if(z){if(z.aborted)return n(z.reason);const y=()=>{n(z.reason)};z.addEventListener("abort",y,!0),h.push(()=>{z.removeEventListener("abort",y,!0)})}const{timeout:qe}=u;if(qe){const y=setTimeout(()=>{n(new ve(qe))},qe);h.push(()=>{clearTimeout(y)})}try{const y=()=>{},M=a&&a(s,n,{abortSignal:S.signal,get isRejected(){return i()},get isResolved(){return l()},on(k,P){if(o||c){if(k==="finalized"){const ie=o?{kind:"resolved",result:o[0]}:{kind:"rejected",reason:c[0]};P(ie)}else k==="resolved"&&o?P(o[0]):k==="rejected"&&c&&P(c[0]);return y}return f[k]||(f[k]=[]),f[k].push(P),()=>{const ie=f[k]||[],Vt=ie.indexOf(P);Vt>=0&&ie.splice(Vt,1)}},get result(){return o==null?void 0:o[0]},get rejectReason(){return c==null?void 0:c[0]},throwIfRejected(){if(c)throw c[0]}});M instanceof Promise&&M.catch(n)}catch(y){n(y)}}),Ge(this,"reject"),Ge(this,"resolve"),this.reject=n,this.resolve=s}static fn(t,r){return new F(async(n,s,a)=>{try{n(await t(a))}catch(u){s(u)}},r)}static resolve(t){return this.fn(()=>t)}static reject(t){return new F((r,n)=>{n(t)})}cancel(){this.reject(new Ke)}catch(t){return this.then(void 0,t)}finally(t){return He(super.finally(t),this)}then(t,r){return He(super.then(t,r),this)}}var ur=function(e,t,r){if(r||arguments.length===2)for(var n=0,s=t.length,a;n<s;n++)(a||!(n in t))&&(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))};function or(e){return e}function Qe(e,t,r,n,s,a,u,o,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return r(t(e.apply(this,arguments)))};case 4:return function(){return n(r(t(e.apply(this,arguments))))};case 5:return function(){return s(n(r(t(e.apply(this,arguments)))))};case 6:return function(){return a(s(n(r(t(e.apply(this,arguments))))))};case 7:return function(){return u(a(s(n(r(t(e.apply(this,arguments)))))))};case 8:return function(){return o(u(a(s(n(r(t(e.apply(this,arguments))))))))};case 9:return function(){return c(o(u(a(s(n(r(t(e.apply(this,arguments)))))))))}}}function v(e,t,r,n,s,a,u,o,c){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return r(t(e));case 4:return n(r(t(e)));case 5:return s(n(r(t(e))));case 6:return a(s(n(r(t(e)))));case 7:return u(a(s(n(r(t(e))))));case 8:return o(u(a(s(n(r(t(e)))))));case 9:return c(o(u(a(s(n(r(t(e))))))));default:{for(var i=arguments[0],l=1;l<arguments.length;l++)i=arguments[l](i);return i}}}var Y=function(e,t){var r=typeof e=="number"?function(n){return n.length>=e}:e;return function(){var n=Array.from(arguments);return r(arguments)?t.apply(this,n):function(s){return t.apply(void 0,ur([s],n,!1))}}},cr={_tag:"None"},lr=function(e){return{_tag:"Some",value:e}},pr=function(e){return e._tag==="Left"},Xe=function(e){return{_tag:"Left",left:e}},Ye=function(e){return{_tag:"Right",right:e}},fr=cr,_r=lr,hr=function(e){return e._tag==="None"},mr=function(e,t){return function(r){return hr(r)?e():t(r.value)}},dr=mr,$=Xe,b=Ye,Ze=Y(2,function(e,t){return D(e)?e:t(e.right)}),yr=function(e){return function(t){return D(t)?t:b(e(t.right))}},vr=function(e,t){return function(r){return D(r)?$(e(r.left)):b(t(r.right))}},gr=function(e){return function(t){return D(t)?$(e(t.left)):t}},D=pr,et=function(e,t){return function(r){return D(r)?e(r.left):t(r.right)}},br=et,G=et,wr=G,Z=function(e,t){try{return b(e())}catch(r){return $(t(r))}},Er=Ze,kr=Ze;function Pr(e){return Qe(b,e.of)}function Sr(e){return Qe($,e.of)}function $r(e){return function(t,r){return e.chain(t,function(n){return D(n)?e.of(n):r(n.right)})}}function jr(e){return function(t,r,n){return e.map(t,vr(r,n))}}function Ar(e){return function(t,r){return function(n){return e.map(n,G(t,r))}}}var Or=function(e){return Z(function(){return JSON.parse(e)},or)},tt=function(e,t){return v(e,Mr(t))},Tr=function(e,t){return v(e,Rr(t))},Mr=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},Rr=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(r){var n=r[0],s=r[1];return n(s)})}}},ge=function(e){return function(){return Promise.resolve(e)}},Ir=Y(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(r){return t(r)()})}}),rt="Task",nt={URI:rt,map:tt},st={of:ge},Fr={URI:rt,map:tt,of:ge,ap:Tr,chain:Ir},Cr=function(e,t,r,n){function s(a){return a instanceof r?a:new r(function(u){u(a)})}return new(r||(r=Promise))(function(a,u){function o(l){try{i(n.next(l))}catch(f){u(f)}}function c(l){try{i(n.throw(l))}catch(f){u(f)}}function i(l){l.done?a(l.value):s(l.value).then(o,c)}i((n=n.apply(e,t||[])).next())})},Wr=function(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,s,a,u;return u={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function o(i){return function(l){return c([i,l])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,i[0]&&(r=0)),r;)try{if(n=1,s&&(a=i[0]&2?s.return:i[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,i[1])).done)return a;switch(s=0,a&&(i=[i[0]&2,a.value]),i[0]){case 0:case 1:a=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,s=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!a||i[1]>a[0]&&i[1]<a[3])){r.label=i[1];break}if(i[0]===6&&r.label<a[1]){r.label=a[1],a=i;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(i);break}a[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(l){i=[6,l],s=0}finally{n=a=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},at=Sr(st),be=Pr(st),qr=ge,ee=Ar(nt),Lr=ee,Dr=function(e,t){return function(){return Cr(void 0,void 0,void 0,function(){var r;return Wr(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e().then(Ye)];case 1:return[2,n.sent()];case 2:return r=n.sent(),[2,Xe(t(r))];case 3:return[2]}})})}},it=Y(3,jr(nt)),ut=Y(2,$r(Fr)),Ur=ut,we=ut;function xr(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function Nr(e){return Object.entries(e).reduce((t,[r,n])=>(t[xr(r)]=n,t),{})}function Ee(e){const t=Nr(e);for(const r in t){const n=t[r];n&&typeof n=="object"&&!(n instanceof Date)&&(t[r]=Array.isArray(n)?n.map(Ee):Ee(n))}return t}function ot(e){return`tapps/${e}`}function ct(e,t){sessionStorage.setItem(ot(e),JSON.stringify(t))}function zr(e){const t=sessionStorage.getItem(ot(e));try{return t?JSON.parse(t):void 0}catch{}}function lt(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(r=>{r()})}]}function pt(e,t){t||(t={});const{textColor:r,bgColor:n,shouldLog:s}=t,a=s===void 0?!0:s,u=typeof a=="boolean"?()=>a:a,o=(c,i,...l)=>{if(i||u()){const f="font-weight:bold;padding:0 5px;border-radius:100px",[h,d,S]={log:["#0089c3","white","INFO"],error:["#ff0000F0","white","ERR"],warn:["#D38E15","white","WARN"]}[c];console[c](`%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:${h};color:${d}`,"",`${f};${r?`color:${r};`:""}${n?`background-color:${n}`:""}`,...l)}};return[["log","forceLog"],["warn","forceWarn"],["error","forceError"]].reduce((c,[i,l])=>(c[i]=o.bind(void 0,i,!1),c[l]=o.bind(void 0,i,!0),c),{})}function J(e){const t=r=>{throw r};return typeof e=="function"?F.resolve(v(e,ee(t,r=>r))()):v(e,G(t,r=>r))}function B(e){return Object.assign((...t)=>J(e(...t)),e)}const ke=Object.assign((e,t)=>v(Dr(()=>new F((r,n,s)=>e(a=>r(b(a)),a=>r($(a)),s),t),r=>r),we(G(at,be))),{fn:(e,t)=>ke((r,n,s)=>{const a=e(s);v(typeof a=="function"?a:qr(a),Lr(n,r))()},t)});var Vr=Object.defineProperty,Gr=(e,t,r)=>t in e?Vr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pe=(e,t,r)=>Gr(e,typeof t!="symbol"?t+"":t,r);function ft(e){return t=>t instanceof e}function U(e){const t=class Gt extends Error{constructor(...s){super(...typeof e.super=="function"?e.super(...s):typeof e.super=="string"?[e.super]:e.super||[]),this.name=e.name,Object.setPrototypeOf(this,Gt.prototype)}};Pe(t,"is",ft(t));let r=t;return Object.defineProperty(r,"name",{value:e.name}),r}function Jr(e){const t=class Jt extends U(e){constructor(...s){super(...s),Pe(this,"data"),this.data=e.data(...s),Object.setPrototypeOf(this,Jt.prototype)}};Pe(t,"is",ft(t));let r=t;return Object.defineProperty(r,"name",{value:e.name}),r}class _t extends U({name:"MethodUnsupportedError",super:(t,r)=>[`Method "${t}" is unsupported in Mini Apps version ${r}`]}){}class ht extends U({name:"MethodParameterUnsupportedError",super:(t,r,n)=>[`Parameter "${r}" of "${t}" method is unsupported in Mini Apps version ${n}`]}){}class mt extends Jr({name:"LaunchParamsRetrieveError",data:t=>({errors:t}),super: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:r,error:n})=>`Source: ${r} / ${n instanceof Error?n.message:String(n)}`)].join(`
|
|
2
|
+
`)]}){}class dt extends U({name:"InvalidLaunchParamsError",super:(t,r)=>[`Invalid value for launch params: ${t}`,{cause:r}]}){}class Se extends U({name:"UnknownEnvError"}){}class yt extends U({name:"InvokeCustomMethodError",super:t=>[`Server returned error: ${t}`]}){}function Br(e){const t=r=>{const n={};return new URLSearchParams(r).forEach((s,a)=>{const u=n[a];Array.isArray(u)?u.push(s):u===void 0?n[a]=s:n[a]=[u,s]}),V(e,n)};return A(X([_(),_e(URLSearchParams)]),Q(r=>{try{return t(r),!0}catch{return!1}},"The value doesn't match required schema"),R(t))}function Kr(e){return A(_(),Q(t=>{try{return JSON.parse(t),!0}catch{return!1}},"Input is not a valid JSON value"),R(JSON.parse),e)}function C(e){return A(_(),Kr(e))}function vt(e){return A(X([_(),_e(URLSearchParams)]),Br(e))}function te(e){return t=>e.test(t)}const Hr=te(/^#[\da-f]{3}$/i),Qr=te(/^#[\da-f]{4}$/i),Xr=te(/^#[\da-f]{6}$/i),Yr=te(/^#[\da-f]{8}$/i);function Zr(e){return[Xr,Yr,Hr,Qr].some(t=>t(e))}function en(){return g({id:L(),photo_url:m(_()),type:_(),title:_(),username:m(_())})}function gt(){return g({added_to_attachment_menu:m(I()),allows_write_to_pm:m(I()),first_name:_(),id:L(),is_bot:m(I()),is_premium:m(I()),last_name:m(_()),language_code:m(_()),photo_url:m(_()),username:m(_())})}function tn(){return g({auth_date:A(_(),R(e=>new Date(Number(e)*1e3)),Ne()),can_send_after:m(A(_(),R(Number),Ue())),chat:m(C(en())),chat_type:m(_()),chat_instance:m(_()),hash:_(),query_id:m(_()),receiver:m(C(gt())),start_param:m(_()),signature:_(),user:m(C(gt()))})}function rn(){return vt(tn())}function $e(){return ze(_(),A(X([_(),L()]),R(e=>typeof e=="number"?`#${(e&16777215).toString(16).padStart(6,"0")}`:e),Q(Zr)))}function nn(){const e=m(A(_(),R(t=>t==="1")));return g({tgWebAppBotInline:e,tgWebAppData:m(rn()),tgWebAppDefaultColors:m(C($e())),tgWebAppFullscreen:e,tgWebAppPlatform:_(),tgWebAppShowSettings:e,tgWebAppStartParam:m(_()),tgWebAppThemeParams:C($e()),tgWebAppVersion:_()})}function sn(){return vt(nn())}function bt(){return g({eventType:_(),eventData:m(he())})}function je(e){return Z(()=>V(sn(),e),t=>t)}const an=B(je);function wt(e,t){return t||(t=(r,n)=>JSON.stringify(n)),new URLSearchParams(Object.entries(e).reduce((r,[n,s])=>(Array.isArray(s)?r.push(...s.map(a=>[n,String(a)])):s!=null&&r.push([n,s instanceof Date?(s.getTime()/1e3|0).toString():typeof s=="string"||typeof s=="number"?String(s):typeof s=="boolean"?s?"1":"0":t(n,s)]),r),[])).toString()}function un(e){return wt(e)}function on(e){return wt(e,(t,r)=>t==="tgWebAppData"?un(r):JSON.stringify(r))}const Et="launchParams";function kt(e){return e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&")}function Pt(){return v(K(),Er(je))}const cn=B(Pt);function St(){return v(K(),yr(e=>{const t=new URLSearchParams(e).get("tgWebAppData");return t?_r(t):fr}))}function ln(){return v(St(),wr(e=>{throw e},e=>e),dr(()=>{},e=>e))}function K(){const e=[];for(const[t,r]of[[()=>kt(window.location.href),"window.location.href"],[()=>{const n=performance.getEntriesByType("navigation")[0];return n&&kt(n.name)},"performance navigation entries"],[()=>zr(Et),"local storage"]]){const n=t();if(!n){e.push({source:r,error:new Error("Source is empty")});continue}const s=v(je(n),br(a=>a,()=>!0));if(typeof s!="boolean"){e.push({source:r,error:s});continue}return ct(Et,n),b(n)}return $(new mt(e))}const pn=B(K);function fn(e,t){t()}function W(e,t){t||(t={});const r=t.equals||Object.is;let n=[],s=e;const a=i=>{if(!r(s,i)){const l=s;s=i,fn(c,()=>{[...n].forEach(([f,h])=>{f(i,l),h&&o(f,!0)})})}};function u(i){const l=typeof i!="object"?{once:i}:i;return{once:l.once||!1,signal:l.signal||!1}}const o=(i,l)=>{const f=u(l),h=n.findIndex(([d,S])=>d===i&&S.once===f.once&&S.signal===f.signal);h>=0&&n.splice(h,1)},c=Object.assign(function(){return _n(c),s},{destroy(){n=[]},set:a,reset(){a(e)},sub(i,l){return n.push([i,u(l)]),()=>o(i,l)},unsub:o,unsubAll(){n=n.filter(i=>i[1].signal)}});return c}const H=[];function _n(e){H.length&&H[H.length-1].add(e)}function $t(e,t){let r=new Set,n;function s(){return n||(n=W(u(),t))}function a(){s().set(u())}function u(){r.forEach(i=>{i.unsub(a,{signal:!0})});const o=new Set;let c;H.push(o);try{c=e()}finally{H.pop()}return o.forEach(i=>{i.sub(a,{signal:!0})}),r=o,c}return Object.assign(function(){return s()()},{destroy(){s().destroy()},sub(...o){return s().sub(...o)},unsub(...o){s().unsub(...o)},unsubAll(...o){s().unsubAll(...o)}})}function hn(e){return{all:e=e||new Map,on:function(t,r){var n=e.get(t);n?n.push(r):e.set(t,[r])},off:function(t,r){var n=e.get(t);n&&(r?n.splice(n.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var n=e.get(t);n&&n.slice().map(function(s){s(r)}),(n=e.get("*"))&&n.slice().map(function(s){s(t,r)})}}}function mn(e,t){const r=new Map,n=hn(),s=(a,u,o=!1)=>{const c=r.get(a)||new Map;r.set(a,c);const i=c.get(u)||[];c.set(u,i);const l=i.findIndex(f=>f[1]===o);if(l>=0&&(n.off(a,i[l][0]),i.splice(l,1),!i.length&&(c.delete(u),!c.size))){const f=r.size;r.delete(a),f&&!r.size&&t()}};return{on(a,u,o){!r.size&&e();const c=()=>{s(a,u,o)},i=(...h)=>{o&&c(),a==="*"?u({name:h[0],payload:h[1]}):u(...h)};n.on(a,i);const l=r.get(a)||new Map;r.set(a,l);const f=l.get(u)||[];return l.set(u,f),f.push([i,o||!1]),c},off:s,emit:n.emit,clear(){const a=r.size;n.all.clear(),r.clear(),a&&t()}}}function re(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}const ne=W(!1),Ae=W("https://web.telegram.org"),dn=e=>{O().log("Event received:",e)},Oe=$t(ne);function yn(e){e!==ne()&&(ne.set(e),(e?se:Mt)("*",dn))}const Te=$t(Ae);function vn(e){Ae.set(e),O().log("New target origin set",e)}const x=W((...e)=>{window.parent.postMessage(...e)}),O=W(pt("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:Oe}));function gn(){Rt(),[x,Ae,Te,ne,Oe,O].forEach(e=>{e.unsubAll(),"reset"in e&&e.reset()})}function Me(e,t,r){const n=[r],s=e[t];typeof s=="function"&&n.push(s);const a=(...o)=>{n.forEach(c=>c(...o))},u=Object.assign((...o)=>{a(...o)},{unwrap(){const{length:o}=n;if(o===1){delete e[t];return}if(o===2){Ot(e,t,n[1]);return}n.unshift(1),Ot(e,t,a)}});At(e,t,()=>u,o=>n.push(o))}function jt(e,t){const r=e[t];At(e,t,()=>r,n=>{Object.entries(n).forEach(([s,a])=>{r[s]=a})})}function At(e,t,r,n){Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:r,set:n})}function Ot(e,t,r){Object.defineProperty(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r})}const bn={clipboard_text_received:g({req_id:_(),data:q(_())}),custom_method_invoked:g({req_id:_(),result:m(he()),error:m(_())}),popup_closed:q(g({button_id:q(_(),()=>{})}),{}),viewport_changed:q(g({height:L(),width:q(L(),()=>window.innerWidth),is_state_stable:I(),is_expanded:I()}),()=>({height:window.innerHeight,is_state_stable:!0,is_expanded:!0})),theme_changed:g({theme_params:$e()})};function Tt(e){if(e.source!==window.parent)return;let t;try{t=V(C(bt()),e.data)}catch{return}const{eventType:r,eventData:n}=t,s=bn[r];let a;try{a=s?V(s,n):n}catch(u){return O().forceError([`An error occurred processing the "${r}" event from the Telegram application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose"].join(`
|
|
3
|
+
`),t,u)}wn(r,a)}const{on:se,off:Mt,emit:wn,clear:Rt}=mn(()=>{const e=window;!e.TelegramGameProxy&&(e.TelegramGameProxy={}),Me(e.TelegramGameProxy,"receiveEvent",re),jt(e,"TelegramGameProxy"),!e.Telegram&&(e.Telegram={}),!e.Telegram.WebView&&(e.Telegram.WebView={}),Me(e.Telegram.WebView,"receiveEvent",re),jt(e.Telegram,"WebView"),Me(e,"TelegramGameProxy_receiveEvent",re),window.addEventListener("message",Tt)},()=>{[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["Telegram","WebView","receiveEvent"]].forEach(e=>{const t=window;let r=[void 0,t];for(const a of e)if(r=[r[1],r[1][a]],!r[1])return;const[n,s]=r;"unwrap"in s&&(s.unwrap(),n&&n!==t&&!Object.keys(n).length&&delete t[e[0]])}),window.removeEventListener("message",Tt)}),It=(...e)=>x()(...e);function Ft(e,t){v(N(e,t),gr(r=>{throw r}))}function N(e,t){O().log("Posting event:",t?{eventType:e,eventData:t}:{eventType:e});const r=window,n=JSON.stringify({eventType:e,eventData:t});return de()?(It(n,Te()),b(void 0)):me(r)?(r.TelegramWebviewProxy.postEvent(e,JSON.stringify(t)),b(void 0)):pe(g({external:g({notify:fe()})}),r)?(r.external.notify(n),b(void 0)):$(new Se)}function ae(e,t,r={}){const{capture:n=()=>!0,postEvent:s=N}=r,a=W(),[u,o]=lt();(Array.isArray(t)?t:[t]).forEach(i=>{u(se(i,l=>{const f=Array.isArray(t);n(f?{event:i,payload:l}:l)&&a.set([f?{event:i,payload:l}:l])}))});const c=i=>(o(),i);return v(async()=>s(e,r.params),we(()=>ke((i,l,f)=>{const h=a();if(h)return i(h[0]);const d=T=>{T&&i(T[0])},S=()=>{a.unsub(d)};a.sub(d),f.on("finalized",S)},r)),it(c,c))}function En(e,t,r){const{postEvent:n}=r||{};return J(ae(e,t,{...r,postEvent:n?(...s)=>{try{return n(...s),b(void 0)}catch(a){return $(a)}}:N}))}function kn(e,t){const r=Ct(e,t);return typeof r=="function"?F.fn(()=>J(r)):r}function Ct(e,t){const r=me(window);if(!e)return r||v(K(),G(()=>!1,()=>!0));if(r)return be(!0);const{timeout:n=100}=t||{};return v(ae("web_app_request_theme","theme_changed",{...t,timeout:n}),ee(s=>ve.is(s)||Se.is(s)?b(!1):$(s),()=>b(!0)))}function Pn({launchParams:e,onEvent:t,resetPostMessage:r}={}){if(e){const a=typeof e=="string"||e instanceof URLSearchParams?e.toString():on({...e,tgWebAppData:void 0})+(e.tgWebAppData?`&tgWebAppData=${encodeURIComponent(e.tgWebAppData.toString())}`:"");try{an(a)}catch(u){throw new dt(a,u)}ct("launchParams",a)}if(de()){if(!t)return;r&&x.reset();const a=x();x.set((...u)=>{const[o]=u,c=()=>{a(...u)};try{const i=V(C(bt()),o);t({name:i.eventType,params:i.eventData},c)}catch{c()}});return}const n=window.TelegramWebviewProxy||{},s=n.postEvent||(()=>{});window.TelegramWebviewProxy={...n,postEvent(a,u){const o=()=>{s(a,u)};t?t({name:a,params:u?JSON.parse(u):void 0},o):o()}},O().log("Environment was mocked by the mockTelegramEnv function")}function Wt(e){return({req_id:t})=>t===e}const qt={"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 Re(e,t){return Object.keys(qt).find(n=>qt[n].some(s=>t?typeof s=="object"&&s.method===e&&s.param===t:s===e))||null}function Lt(e){return e.split(".").map(Number)}function Dt(e,t){const r=Lt(e),n=Lt(t),s=Math.max(r.length,n.length);for(let a=0;a<s;a+=1){const u=r[a]||0,o=n[a]||0;if(u!==o)return u>o?1:-1}return 0}function Ie(e,t,r){const n=r?Re(e,t):Re(e);return n?Dt(n,r||t)<=0:!1}function Sn(e,t="strict"){const r=typeof t=="function"?t:n=>{const{method:s,version:a}=n,u="param"in n?new ht(s,n.param,a):new _t(s,a);if(t==="strict")throw u;return O().forceWarn(u.message)};return(n,s)=>Ie(n,e)?n==="web_app_set_header_color"&&pe(g({color:xe()}),s)&&!Ie(n,"color",e)?r({version:e,method:n,param:"color"}):Ft(n,s):r({version:e,method:n})}function Ut(e,t,r,n){return v(ae("web_app_invoke_custom_method","custom_method_invoked",{...n||{},params:{method:e,params:t,req_id:r},capture:Wt(r)}),Ur(({result:s,error:a})=>a?at(new yt(a)):be(s)))}function $n(e,t,r,n){return F.fn(()=>v(Ut(e,t,r,n),ee(s=>{throw s},s=>s))())}function xt(e,t,r={}){const{capture:n=()=>!0,postEvent:s=N}=r,a=W(),[u,o]=lt();(Array.isArray(t)?t:[t]).forEach(i=>{u(se(i,l=>{(Array.isArray(t)?n({event:i,payload:l}):n(l))&&a.set([l])}))});const c=i=>(o(),i);return v(async()=>s(e,r.params),we(()=>ke((i,l,f)=>{const h=a();if(h)return i(h[0]);const d=T=>{T&&i(T[0])},S=()=>{a.unsub(d)};a.sub(d),f.on("finalized",S)},r)),it(c,c))}function jn(e,t,r){const{postEvent:n}=r||{};return J(xt(e,t,{...r,postEvent:n?(...s)=>{try{return n(...s),b(void 0)}catch(a){return $(a)}}:N}))}function An(){Object.hasOwn||(Object.hasOwn=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)})}function Fe(e){return Z(()=>decodeURIComponent(atob(e.replace(/-/g,"+").replace(/_/g,"/")).split("").map(t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)).join("")),t=>t)}const On=B(Fe);function Ce(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,r)=>String.fromCharCode(parseInt(`0x${r}`)))).replace(/\+/g,"-").replace(/\//g,"_")}function Nt(e){const t=Ce(typeof e=="string"?e:JSON.stringify(e));return t.length>512?$(new Error("Value is too long for start parameter")):b(t)}const Tn=B(Nt);function Mn(e,t){return J(zt(e,typeof t=="function"?r=>Z(()=>t(r),n=>n):t))}function zt(e,t){return v(Fe(e),kr(r=>t?typeof t=="function"?t(r):Or(r):b(r)))}function Rn(e){return Ce(e).length<=512}return p.CancelledError=Ke,p.InvalidLaunchParamsError=dt,p.InvokeCustomMethodFailedError=yt,p.LaunchParamsRetrieveError=mt,p.MethodParameterUnsupportedError=ht,p.MethodUnsupportedError=_t,p.TimeoutError=ve,p.UnknownEnvError=Se,p.applyPolyfills=An,p.captureSameReq=Wt,p.compareVersions=Dt,p.createLogger=pt,p.createPostEvent=Sn,p.createStartParam=Tn,p.createStartParamFp=Nt,p.debug=Oe,p.decodeBase64Url=On,p.decodeBase64UrlFp=Fe,p.decodeStartParam=Mn,p.decodeStartParamFp=zt,p.deepSnakeToCamelObjKeys=Ee,p.emitEvent=re,p.encodeBase64Url=Ce,p.getReleaseVersion=Re,p.hasWebviewProxy=me,p.invokeCustomMethod=$n,p.invokeCustomMethodFp=Ut,p.isIframe=de,p.isSafeToCreateStartParam=Rn,p.isTMA=kn,p.isTMAFp=Ct,p.logger=O,p.mockTelegramEnv=Pn,p.off=Mt,p.offAll=Rt,p.on=se,p.postEvent=Ft,p.postEventFp=N,p.postMessage=It,p.postMessageImpl=x,p.request=jn,p.request2=En,p.request2Fp=ae,p.requestFp=xt,p.resetGlobals=gn,p.retrieveLaunchParams=cn,p.retrieveLaunchParamsFp=Pt,p.retrieveRawInitData=ln,p.retrieveRawInitDataFp=St,p.retrieveRawLaunchParams=pn,p.retrieveRawLaunchParamsFp=K,p.setDebug=yn,p.setTargetOrigin=vn,p.supports=Ie,p.targetOrigin=Te,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"}),p}({});
|
|
4
4
|
//# sourceMappingURL=index.iife.js.map
|