UNPKG

@safe-stars/components

Version:

React component library for buying Telegram Stars in Telegram Mini Apps via Safe Stars.

1 lines 898 kB
"use strict";const H=require("react/jsx-runtime"),Ke=require("react"),Va=require("@tonconnect/ui-react"),xr=require("viem"),Ha=require("wagmi"),jf=require("@tanstack/react-query"),Qw=require("@reown/appkit-adapter-wagmi"),Ww=require("@telegram-apps/sdk-react"),Xi=require("@ton/ton"),Jc=require("@ton/core"),zw=Symbol(),Sd=Object.getPrototypeOf,$l=new WeakMap,Yw=t=>t&&($l.has(t)?$l.get(t):Sd(t)===Object.prototype||Sd(t)===Array.prototype),Gw=t=>Yw(t)&&t[zw]||null,Nd=(t,e=!0)=>{$l.set(t,e)},nc={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_ALCHEMY_API_KEY:"AVZOLX4DZCb05tWceBfY3SV3tF3NSNsF",VITE_API_URL:"https://tg-stars.open-lend.io",VITE_TON_API_KEY:"471a2394ca78b1282cd32211ca061f9a6a2dc7852edd99969c0825d429137c68"},$c=t=>typeof t=="object"&&t!==null,Qn=new WeakMap,ho=new WeakSet,Zw=(t=Object.is,e=(l,u)=>new Proxy(l,u),r=l=>$c(l)&&!ho.has(l)&&(Array.isArray(l)||!(Symbol.iterator in l))&&!(l instanceof WeakMap)&&!(l instanceof WeakSet)&&!(l instanceof Error)&&!(l instanceof Number)&&!(l instanceof Date)&&!(l instanceof String)&&!(l instanceof RegExp)&&!(l instanceof ArrayBuffer),n=l=>{switch(l.status){case"fulfilled":return l.value;case"rejected":throw l.reason;default:throw l}},s=new WeakMap,i=(l,u,d=n)=>{const f=s.get(l);if((f==null?void 0:f[0])===u)return f[1];const g=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l));return Nd(g,!0),s.set(l,[u,g]),Reflect.ownKeys(l).forEach(m=>{if(Object.getOwnPropertyDescriptor(g,m))return;const w=Reflect.get(l,m),{enumerable:E}=Reflect.getOwnPropertyDescriptor(l,m),I={value:w,enumerable:E,configurable:!0};if(ho.has(w))Nd(w,!1);else if(w instanceof Promise)delete I.value,I.get=()=>d(w);else if(Qn.has(w)){const[S,R]=Qn.get(w);I.value=i(S,R(),d)}Object.defineProperty(g,m,I)}),Object.preventExtensions(g)},o=new WeakMap,a=[1,1],c=l=>{if(!$c(l))throw new Error("object required");const u=o.get(l);if(u)return u;let d=a[0];const f=new Set,g=(P,Q=++a[0])=>{d!==Q&&(d=Q,f.forEach(j=>j(P,Q)))};let m=a[1];const w=(P=++a[1])=>(m!==P&&!f.size&&(m=P,I.forEach(([Q])=>{const j=Q[1](P);j>d&&(d=j)})),d),E=P=>(Q,j)=>{const W=[...Q];W[1]=[P,...W[1]],g(W,j)},I=new Map,S=(P,Q)=>{if((nc?"production":void 0)!=="production"&&I.has(P))throw new Error("prop listener already exists");if(f.size){const j=Q[3](E(P));I.set(P,[Q,j])}else I.set(P,[Q])},R=P=>{var Q;const j=I.get(P);j&&(I.delete(P),(Q=j[1])==null||Q.call(j))},T=P=>(f.add(P),f.size===1&&I.forEach(([j,W],le)=>{if((nc?"production":void 0)!=="production"&&W)throw new Error("remove already exists");const q=j[3](E(le));I.set(le,[j,q])}),()=>{f.delete(P),f.size===0&&I.forEach(([j,W],le)=>{W&&(W(),I.set(le,[j]))})}),B=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l)),F=e(B,{deleteProperty(P,Q){const j=Reflect.get(P,Q);R(Q);const W=Reflect.deleteProperty(P,Q);return W&&g(["delete",[Q],j]),W},set(P,Q,j,W){const le=Reflect.has(P,Q),q=Reflect.get(P,Q,W);if(le&&(t(q,j)||o.has(j)&&t(q,o.get(j))))return!0;R(Q),$c(j)&&(j=Gw(j)||j);let C=j;if(j instanceof Promise)j.then(v=>{j.status="fulfilled",j.value=v,g(["resolve",[Q],v])}).catch(v=>{j.status="rejected",j.reason=v,g(["reject",[Q],v])});else{!Qn.has(j)&&r(j)&&(C=c(j));const v=!ho.has(C)&&Qn.get(C);v&&S(Q,v)}return Reflect.set(P,Q,C,W),g(["set",[Q],j,q]),!0}});o.set(l,F);const L=[B,w,i,T];return Qn.set(F,L),Reflect.ownKeys(l).forEach(P=>{const Q=Object.getOwnPropertyDescriptor(l,P);"value"in Q&&(F[P]=l[P],delete Q.value,delete Q.writable),Object.defineProperty(B,P,Q)}),F})=>[c,Qn,ho,t,e,r,n,s,i,o,a],[Xw]=Zw();function at(t={}){return Xw(t)}function Qt(t,e,r){const n=Qn.get(t);(nc?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let s;const i=[],o=n[3];let a=!1;const l=o(u=>{i.push(u),s||(s=Promise.resolve().then(()=>{s=void 0,a&&e(i.splice(0))}))});return a=!0,()=>{a=!1,l()}}function To(t,e){const r=Qn.get(t);(nc?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");const[n,s,i]=r;return i(n,s(),e)}function Ts(t){return ho.add(t),t}function zt(t,e,r,n){let s=t[e];return Qt(t,()=>{const i=t[e];Object.is(s,i)||r(s=i)})}function Jw(t){const e=at({data:Array.from([]),has(r){return this.data.some(n=>n[0]===r)},set(r,n){const s=this.data.find(i=>i[0]===r);return s?s[1]=n:this.data.push([r,n]),this},get(r){var n;return(n=this.data.find(s=>s[0]===r))==null?void 0:n[1]},delete(r){const n=this.data.findIndex(s=>s[0]===r);return n===-1?!1:(this.data.splice(n,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},toJSON(){return new Map(this.data)},forEach(r){this.data.forEach(n=>{r(n[1],n[0],this)})},keys(){return this.data.map(r=>r[0]).values()},values(){return this.data.map(r=>r[1]).values()},entries(){return new Map(this.data).entries()},get[Symbol.toStringTag](){return"Map"},[Symbol.iterator](){return this.entries()}});return Object.defineProperties(e,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(e),e}var Hr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ta(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function $w(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}),r}const qf={caipNetworkIdToNumber(t){return t?Number(t.split(":")[1]):void 0},parseEvmChainId(t){return typeof t=="string"?this.caipNetworkIdToNumber(t):t},getNetworksByNamespace(t,e){return(t==null?void 0:t.filter(r=>r.chainNamespace===e))||[]},getFirstNetworkByNamespace(t,e){return this.getNetworksByNamespace(t,e)[0]}};var eA=20,tA=1,Ps=1e6,Rd=1e6,rA=-7,nA=21,sA=!1,ra="[big.js] ",js=ra+"Invalid ",Rc=js+"decimal places",iA=js+"rounding mode",Vf=ra+"Division by zero",Ye={},hn=void 0,oA=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function Hf(){function t(e){var r=this;if(!(r instanceof t))return e===hn?Hf():new t(e);if(e instanceof t)r.s=e.s,r.e=e.e,r.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(js+"value");e=e===0&&1/e<0?"-0":String(e)}aA(r,e)}r.constructor=t}return t.prototype=Ye,t.DP=eA,t.RM=tA,t.NE=rA,t.PE=nA,t.strict=sA,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function aA(t,e){var r,n,s;if(!oA.test(e))throw Error(js+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),s=e.length,n=0;n<s&&e.charAt(n)=="0";)++n;if(n==s)t.c=[t.e=0];else{for(;s>0&&e.charAt(--s)=="0";);for(t.e=r-n-1,t.c=[],r=0;n<=s;)t.c[r++]=+e.charAt(n++)}return t}function qs(t,e,r,n){var s=t.c;if(r===hn&&(r=t.constructor.RM),r!==0&&r!==1&&r!==2&&r!==3)throw Error(iA);if(e<1)n=r===3&&(n||!!s[0])||e===0&&(r===1&&s[0]>=5||r===2&&(s[0]>5||s[0]===5&&(n||s[1]!==hn))),s.length=1,n?(t.e=t.e-e+1,s[0]=1):s[0]=t.e=0;else if(e<s.length){if(n=r===1&&s[e]>=5||r===2&&(s[e]>5||s[e]===5&&(n||s[e+1]!==hn||s[e-1]&1))||r===3&&(n||!!s[0]),s.length=e,n){for(;++s[--e]>9;)if(s[e]=0,e===0){++t.e,s.unshift(1);break}}for(e=s.length;!s[--e];)s.pop()}return t}function Vs(t,e,r){var n=t.e,s=t.c.join(""),i=s.length;if(e)s=s.charAt(0)+(i>1?"."+s.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)s="0"+s;s="0."+s}else if(n>0)if(++n>i)for(n-=i;n--;)s+="0";else n<i&&(s=s.slice(0,n)+"."+s.slice(n));else i>1&&(s=s.charAt(0)+"."+s.slice(1));return t.s<0&&r?"-"+s:s}Ye.abs=function(){var t=new this.constructor(this);return t.s=1,t};Ye.cmp=function(t){var e,r=this,n=r.c,s=(t=new r.constructor(t)).c,i=r.s,o=t.s,a=r.e,c=t.e;if(!n[0]||!s[0])return n[0]?i:s[0]?-o:0;if(i!=o)return i;if(e=i<0,a!=c)return a>c^e?1:-1;for(o=(a=n.length)<(c=s.length)?a:c,i=-1;++i<o;)if(n[i]!=s[i])return n[i]>s[i]^e?1:-1;return a==c?0:a>c^e?1:-1};Ye.div=function(t){var e=this,r=e.constructor,n=e.c,s=(t=new r(t)).c,i=e.s==t.s?1:-1,o=r.DP;if(o!==~~o||o<0||o>Ps)throw Error(Rc);if(!s[0])throw Error(Vf);if(!n[0])return t.s=i,t.c=[t.e=0],t;var a,c,l,u,d,f=s.slice(),g=a=s.length,m=n.length,w=n.slice(0,a),E=w.length,I=t,S=I.c=[],R=0,T=o+(I.e=e.e-t.e)+1;for(I.s=i,i=T<0?0:T,f.unshift(0);E++<a;)w.push(0);do{for(l=0;l<10;l++){if(a!=(E=w.length))u=a>E?1:-1;else for(d=-1,u=0;++d<a;)if(s[d]!=w[d]){u=s[d]>w[d]?1:-1;break}if(u<0){for(c=E==a?s:f;E;){if(w[--E]<c[E]){for(d=E;d&&!w[--d];)w[d]=9;--w[d],w[E]+=10}w[E]-=c[E]}for(;!w[0];)w.shift()}else break}S[R++]=u?l:++l,w[0]&&u?w[E]=n[g]||0:w=[n[g]]}while((g++<m||w[0]!==hn)&&i--);return!S[0]&&R!=1&&(S.shift(),I.e--,T--),R>T&&qs(I,T,r.RM,w[0]!==hn),I};Ye.eq=function(t){return this.cmp(t)===0};Ye.gt=function(t){return this.cmp(t)>0};Ye.gte=function(t){return this.cmp(t)>-1};Ye.lt=function(t){return this.cmp(t)<0};Ye.lte=function(t){return this.cmp(t)<1};Ye.minus=Ye.sub=function(t){var e,r,n,s,i=this,o=i.constructor,a=i.s,c=(t=new o(t)).s;if(a!=c)return t.s=-c,i.plus(t);var l=i.c.slice(),u=i.e,d=t.c,f=t.e;if(!l[0]||!d[0])return d[0]?t.s=-c:l[0]?t=new o(i):t.s=1,t;if(a=u-f){for((s=a<0)?(a=-a,n=l):(f=u,n=d),n.reverse(),c=a;c--;)n.push(0);n.reverse()}else for(r=((s=l.length<d.length)?l:d).length,a=c=0;c<r;c++)if(l[c]!=d[c]){s=l[c]<d[c];break}if(s&&(n=l,l=d,d=n,t.s=-t.s),(c=(r=d.length)-(e=l.length))>0)for(;c--;)l[e++]=0;for(c=e;r>a;){if(l[--r]<d[r]){for(e=r;e&&!l[--e];)l[e]=9;--l[e],l[r]+=10}l[r]-=d[r]}for(;l[--c]===0;)l.pop();for(;l[0]===0;)l.shift(),--f;return l[0]||(t.s=1,l=[f=0]),t.c=l,t.e=f,t};Ye.mod=function(t){var e,r=this,n=r.constructor,s=r.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(Vf);return r.s=t.s=1,e=t.cmp(r)==1,r.s=s,t.s=i,e?new n(r):(s=n.DP,i=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=s,n.RM=i,this.minus(r.times(t)))};Ye.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};Ye.plus=Ye.add=function(t){var e,r,n,s=this,i=s.constructor;if(t=new i(t),s.s!=t.s)return t.s=-t.s,s.minus(t);var o=s.e,a=s.c,c=t.e,l=t.c;if(!a[0]||!l[0])return l[0]||(a[0]?t=new i(s):t.s=s.s),t;if(a=a.slice(),e=o-c){for(e>0?(c=o,n=l):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-l.length<0&&(n=l,l=a,a=n),e=l.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+l[e]+r)/10|0;for(r&&(a.unshift(r),++c),e=a.length;a[--e]===0;)a.pop();return t.c=a,t.e=c,t};Ye.pow=function(t){var e=this,r=new e.constructor("1"),n=r,s=t<0;if(t!==~~t||t<-Rd||t>Rd)throw Error(js+"exponent");for(s&&(t=-t);t&1&&(n=n.times(e)),t>>=1,!!t;)e=e.times(e);return s?r.div(n):n};Ye.prec=function(t,e){if(t!==~~t||t<1||t>Ps)throw Error(js+"precision");return qs(new this.constructor(this),t,e)};Ye.round=function(t,e){if(t===hn)t=0;else if(t!==~~t||t<-Ps||t>Ps)throw Error(Rc);return qs(new this.constructor(this),t+this.e+1,e)};Ye.sqrt=function(){var t,e,r,n=this,s=n.constructor,i=n.s,o=n.e,a=new s("0.5");if(!n.c[0])return new s(n);if(i<0)throw Error(ra+"No square root");i=Math.sqrt(+Vs(n,!0,!0)),i===0||i===1/0?(e=n.c.join(""),e.length+o&1||(e+="0"),i=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),t=new s((i==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+o)):t=new s(i+""),o=t.e+(s.DP+=4);do r=t,t=a.times(r.plus(n.div(r)));while(r.c.slice(0,o).join("")!==t.c.slice(0,o).join(""));return qs(t,(s.DP-=4)+t.e+1,s.RM)};Ye.times=Ye.mul=function(t){var e,r=this,n=r.constructor,s=r.c,i=(t=new n(t)).c,o=s.length,a=i.length,c=r.e,l=t.e;if(t.s=r.s==t.s?1:-1,!s[0]||!i[0])return t.c=[t.e=0],t;for(t.e=c+l,o<a&&(e=s,s=i,i=e,l=o,o=a,a=l),e=new Array(l=o+a);l--;)e[l]=0;for(c=a;c--;){for(a=0,l=o+c;l>c;)a=e[l]+i[c]*s[l-c-1]+a,e[l--]=a%10,a=a/10|0;e[l]=a}for(a?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t};Ye.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==hn){if(t!==~~t||t<0||t>Ps)throw Error(Rc);for(r=qs(new r.constructor(r),++t,e);r.c.length<t;)r.c.push(0)}return Vs(r,!0,!!n)};Ye.toFixed=function(t,e){var r=this,n=r.c[0];if(t!==hn){if(t!==~~t||t<0||t>Ps)throw Error(Rc);for(r=qs(new r.constructor(r),t+r.e+1,e),t=t+r.e+1;r.c.length<t;)r.c.push(0)}return Vs(r,!1,!!n)};Ye[Symbol.for("nodejs.util.inspect.custom")]=Ye.toJSON=Ye.toString=function(){var t=this,e=t.constructor;return Vs(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};Ye.toNumber=function(){var t=+Vs(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(ra+"Imprecise conversion");return t};Ye.toPrecision=function(t,e){var r=this,n=r.constructor,s=r.c[0];if(t!==hn){if(t!==~~t||t<1||t>Ps)throw Error(js+"precision");for(r=qs(new n(r),t,e);r.c.length<t;)r.c.push(0)}return Vs(r,t<=r.e||r.e<=n.NE||r.e>=n.PE,!!s)};Ye.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(ra+"valueOf disallowed");return Vs(t,t.e<=e.NE||t.e>=e.PE,!0)};var Ji=Hf();const Kf={bigNumber(t){return t?new Ji(t):new Ji(0)},multiply(t,e){if(t===void 0||e===void 0)return new Ji(0);const r=new Ji(t),n=new Ji(e);return r.times(n)},formatNumberToLocalString(t,e=2){return t===void 0?"0.00":typeof t=="number"?t.toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e}):parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e})},parseLocalStringToNumber(t){return t===void 0?0:parseFloat(t.replace(/,/gu,""))}},cA=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],lA=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],uA=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}];function dA(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Qf={exports:{}},wt=Qf.exports={},on,an;function eu(){throw new Error("setTimeout has not been defined")}function tu(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?on=setTimeout:on=eu}catch{on=eu}try{typeof clearTimeout=="function"?an=clearTimeout:an=tu}catch{an=tu}})();function Wf(t){if(on===setTimeout)return setTimeout(t,0);if((on===eu||!on)&&setTimeout)return on=setTimeout,setTimeout(t,0);try{return on(t,0)}catch{try{return on.call(null,t,0)}catch{return on.call(this,t,0)}}}function hA(t){if(an===clearTimeout)return clearTimeout(t);if((an===tu||!an)&&clearTimeout)return an=clearTimeout,clearTimeout(t);try{return an(t)}catch{try{return an.call(null,t)}catch{return an.call(this,t)}}}var Pn=[],Si=!1,Cs,Ka=-1;function pA(){!Si||!Cs||(Si=!1,Cs.length?Pn=Cs.concat(Pn):Ka=-1,Pn.length&&zf())}function zf(){if(!Si){var t=Wf(pA);Si=!0;for(var e=Pn.length;e;){for(Cs=Pn,Pn=[];++Ka<e;)Cs&&Cs[Ka].run();Ka=-1,e=Pn.length}Cs=null,Si=!1,hA(t)}}wt.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];Pn.push(new Yf(t,e)),Pn.length===1&&!Si&&Wf(zf)};function Yf(t,e){this.fun=t,this.array=e}Yf.prototype.run=function(){this.fun.apply(null,this.array)};wt.title="browser";wt.browser=!0;wt.env={};wt.argv=[];wt.version="";wt.versions={};function Un(){}wt.on=Un;wt.addListener=Un;wt.once=Un;wt.off=Un;wt.removeListener=Un;wt.removeAllListeners=Un;wt.emit=Un;wt.prependListener=Un;wt.prependOnceListener=Un;wt.listeners=function(t){return[]};wt.binding=function(t){throw new Error("process.binding is not supported")};wt.cwd=function(){return"/"};wt.chdir=function(t){throw new Error("process.chdir is not supported")};wt.umask=function(){return 0};var fA=Qf.exports;const je=dA(fA),ee={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"ID_AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin",cosmos:"Cosmos"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],HTTP_STATUS_CODES:{SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network",SECURE_SITE_SDK_ORIGIN:(typeof je<"u"&&typeof je.env<"u"?je.env.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org"},Gf={getERC20Abi:t=>ee.USDT_CONTRACT_ADDRESSES.includes(t)?uA:cA,getSwapAbi:()=>lA},Nn={validateCaipAddress(t){var e;if(((e=t.split(":"))==null?void 0:e.length)!==3)throw new Error("Invalid CAIP Address");return t},parseCaipAddress(t){const e=t.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${t}`);const[r,n,s]=e;if(!r||!n||!s)throw new Error(`Invalid CAIP-10 address: ${t}`);return{chainNamespace:r,chainId:n,address:s}},parseCaipNetworkId(t){const e=t.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${t}`);const[r,n]=e;if(!r||!n)throw new Error(`Invalid CAIP-2 network id: ${t}`);return{chainNamespace:r,chainId:n}}},ve={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache",PREFERRED_ACCOUNT_TYPES:"@appkit/preferred_account_types",CONNECTIONS:"@appkit/connections"};function el(t){if(!t)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${t}:connected_connector_id`}const Ce={setItem(t,e){po()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(po())return localStorage.getItem(t)||void 0},removeItem(t){po()&&localStorage.removeItem(t)},clear(){po()&&localStorage.clear()}};function po(){return typeof window<"u"&&typeof localStorage<"u"}function dn(t,e){return e==="light"?{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":(t==null?void 0:t["--w3m-accent"])||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}const tl=(typeof je<"u"&&typeof je.env<"u"?je.env.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",gA=[{label:"Coinbase",name:"coinbase",feeRange:"1-2%",url:"",supportedChains:["eip155"]},{label:"Meld.io",name:"meld",feeRange:"1-2%",url:"https://meldcrypto.com",supportedChains:["eip155","solana"]}],mA="WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU",Nt={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:tl,SECURE_SITE_DASHBOARD:`${tl}/dashboard`,SECURE_SITE_FAVICON:`${tl}/images/favicon.png`,RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],WC_COINBASE_PAY_SDK_CHAINS:["ethereum","arbitrum","polygon","berachain","avalanche-c-chain","optimism","celo","base"],WC_COINBASE_PAY_SDK_FALLBACK_CHAIN:"ethereum",WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP:{Ethereum:"ethereum","Arbitrum One":"arbitrum",Polygon:"polygon",Berachain:"berachain",Avalanche:"avalanche-c-chain","OP Mainnet":"optimism",Celo:"celo",Base:"base"},WC_COINBASE_ONRAMP_APP_ID:"bf18c88d-495a-463b-b249-0b9d3656cf5e",SWAP_SUGGESTED_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP"],SWAP_POPULAR_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP","METAL","DAI","CHAMP","WOLF","SALE","BAL","BUSD","MUST","BTCpx","ROUTE","HEX","WELT","amDAI","VSQ","VISION","AURUM","pSP","SNX","VC","LINK","CHP","amUSDT","SPHERE","FOX","GIDDY","GFC","OMEN","OX_OLD","DE","WNT"],BALANCE_SUPPORTED_CHAINS:["eip155","solana"],SWAP_SUPPORTED_NETWORKS:["eip155:1","eip155:42161","eip155:10","eip155:324","eip155:8453","eip155:56","eip155:137","eip155:100","eip155:43114","eip155:250","eip155:8217","eip155:1313161554"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:["eip155","solana"],ACTIVITY_ENABLED_CHAIN_NAMESPACES:["eip155"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x",cosmos:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in the wallet app",WEB:"Open and continue in the wallet app"},SEND_SUPPORTED_NAMESPACES:["eip155","solana"],DEFAULT_FEATURES:{swaps:!0,onramp:!0,receive:!0,send:!0,email:!0,emailShowWallets:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],history:!0,analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0,pay:!1},DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"}},oe={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired(t,e){return Date.now()-t>e},getActiveNetworkProps(){const t=oe.getActiveNamespace(),e=oe.getActiveCaipNetworkId(),r=e?e.split(":")[1]:void 0,n=r?isNaN(Number(r))?r:Number(r):void 0;return{namespace:t,caipNetworkId:e,chainId:n}},setWalletConnectDeepLink({name:t,href:e}){try{Ce.setItem(ve.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=Ce.getItem(ve.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{Ce.removeItem(ve.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{Ce.setItem(ve.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{Ce.setItem(ve.ACTIVE_CAIP_NETWORK_ID,t),oe.setActiveNamespace(t.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return Ce.getItem(ve.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{Ce.removeItem(ve.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=el(t);Ce.removeItem(e)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(t){try{const e=oe.getRecentWallets();e.find(n=>n.id===t.id)||(e.unshift(t),e.length>2&&e.pop(),Ce.setItem(ve.RECENT_WALLETS,JSON.stringify(e)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=Ce.getItem(ve.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(t,e){try{const r=el(t);Ce.setItem(r,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return Ce.getItem(ve.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=el(t);return Ce.getItem(e)}catch{console.info("Unable to get connected connector id in namespace ",t)}},setConnectedSocialProvider(t){try{Ce.setItem(ve.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return Ce.getItem(ve.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{Ce.removeItem(ve.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return Ce.getItem(ve.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var r;const t=Ce.getItem(ve.ACTIVE_CAIP_NETWORK_ID);return(r=t==null?void 0:t.split(":"))==null?void 0:r[1]},setConnectionStatus(t){try{Ce.setItem(ve.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return Ce.getItem(ve.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=Ce.getItem(ve.CONNECTED_NAMESPACES);return t!=null&&t.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));Ce.setItem(ve.CONNECTED_NAMESPACES,e.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(t){try{const e=oe.getConnectedNamespaces();e.includes(t)||(e.push(t),oe.setConnectedNamespaces(e))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(t){try{const e=oe.getConnectedNamespaces(),r=e.indexOf(t);r>-1&&(e.splice(r,1),oe.setConnectedNamespaces(e))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return Ce.getItem(ve.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{Ce.setItem(ve.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{Ce.removeItem(ve.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=Ce.getItem(ve.PORTFOLIO_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromBalanceCache(t){try{const e=oe.getBalanceCache();Ce.setItem(ve.PORTFOLIO_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getBalanceCacheForCaipAddress(t){try{const r=oe.getBalanceCache()[t];if(r&&!this.isCacheExpired(r.timestamp,this.cacheExpiry.portfolio))return r.balance;oe.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateBalanceCache(t){try{const e=oe.getBalanceCache();e[t.caipAddress]=t,Ce.setItem(ve.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=Ce.getItem(ve.NATIVE_BALANCE_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromNativeBalanceCache(t){try{const e=oe.getBalanceCache();Ce.setItem(ve.NATIVE_BALANCE_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getNativeBalanceCacheForCaipAddress(t){try{const r=oe.getNativeBalanceCache()[t];if(r&&!this.isCacheExpired(r.timestamp,this.cacheExpiry.nativeBalance))return r;console.info("Discarding cache for address",t),oe.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateNativeBalanceCache(t){try{const e=oe.getNativeBalanceCache();e[t.caipAddress]=t,Ce.setItem(ve.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=Ce.getItem(ve.ENS_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get ens name cache")}return t},getEnsFromCacheForAddress(t){try{const r=oe.getEnsCache()[t];if(r&&!this.isCacheExpired(r.timestamp,this.cacheExpiry.ens))return r.ens;oe.removeEnsFromCache(t)}catch{console.info("Unable to get ens name from cache",t)}},updateEnsCache(t){try{const e=oe.getEnsCache();e[t.address]=t,Ce.setItem(ve.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=oe.getEnsCache();Ce.setItem(ve.ENS_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove ens name from cache",t)}},getIdentityCache(){let t={};try{const e=Ce.getItem(ve.IDENTITY_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get identity cache")}return t},getIdentityFromCacheForAddress(t){try{const r=oe.getIdentityCache()[t];if(r&&!this.isCacheExpired(r.timestamp,this.cacheExpiry.identity))return r.identity;oe.removeIdentityFromCache(t)}catch{console.info("Unable to get identity from cache",t)}},updateIdentityCache(t){try{const e=oe.getIdentityCache();e[t.address]={identity:t.identity,timestamp:t.timestamp},Ce.setItem(ve.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=oe.getIdentityCache();Ce.setItem(ve.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},clearAddressCache(){try{Ce.removeItem(ve.PORTFOLIO_CACHE),Ce.removeItem(ve.NATIVE_BALANCE_CACHE),Ce.removeItem(ve.ENS_CACHE),Ce.removeItem(ve.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(t){try{Ce.setItem(ve.PREFERRED_ACCOUNT_TYPES,JSON.stringify(t))}catch{console.info("Unable to set preferred account types",t)}},getPreferredAccountTypes(){try{const t=Ce.getItem(ve.PREFERRED_ACCOUNT_TYPES);return t?JSON.parse(t):{}}catch{console.info("Unable to get preferred account types")}return{}},setConnections(t,e){try{const r={...oe.getConnections(),[e]:t};Ce.setItem(ve.CONNECTIONS,JSON.stringify(r))}catch(r){console.error("Unable to sync connections to storage",r)}},getConnections(){try{const t=Ce.getItem(ve.CONNECTIONS);return t?JSON.parse(t):{}}catch(t){return console.error("Unable to get connections from storage",t),{}}}},Ae={isMobile(){var t;return this.isClient()?!!((t=window==null?void 0:window.matchMedia("(pointer:coarse)"))!=null&&t.matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(t,e=""){return t==null?void 0:t.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return Ae.isMobile()&&t.includes("android")},isIos(){if(!this.isMobile())return!1;const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){return this.isClient()?(window==null?void 0:window.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(t){return t?t-Date.now()<=Nt.TEN_SEC_MS:!0},isAllowedRetry(t,e=Nt.ONE_SEC_MS){return Date.now()-t>=e},copyToClopboard(t){navigator.clipboard.writeText(t)},isIframe(){try{return(window==null?void 0:window.self)!==(window==null?void 0:window.top)}catch{return!1}},getPairingExpiry(){return Date.now()+Nt.FOUR_MINUTES_MS},getNetworkId(t){return t==null?void 0:t.split(":")[1]},getPlainAddress(t){return t==null?void 0:t.split(":")[2]},async wait(t){return new Promise(e=>{setTimeout(e,t)})},debounce(t,e=500){let r;return(...n)=>{function s(){t(...n)}r&&clearTimeout(r),r=setTimeout(s,e)}},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},formatNativeUrl(t,e,r=null){if(Ae.isHttpUrl(t))return this.formatUniversalUrl(t,e);let n=t,s=r;n.includes("://")||(n=t.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),s&&!(s!=null&&s.endsWith("/"))&&(s=`${s}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const i=encodeURIComponent(e);return{redirect:`${n}wc?uri=${i}`,redirectUniversalLink:s?`${s}wc?uri=${i}`:void 0,href:n}},formatUniversalUrl(t,e){if(!Ae.isHttpUrl(t))return this.formatNativeUrl(t,e);let r=t;r.endsWith("/")||(r=`${r}/`);const n=encodeURIComponent(e);return{redirect:`${r}wc?uri=${n}`,href:r}},getOpenTargetForPlatform(t){return t==="popupWindow"?t:this.isTelegram()?oe.getTelegramSocialProvider()?"_top":"_blank":t},openHref(t,e,r){window==null||window.open(t,this.getOpenTargetForPlatform(e),r||"noreferrer noopener")},returnOpenHref(t,e,r){return window==null?void 0:window.open(t,this.getOpenTargetForPlatform(e),r||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},isPWA(){var r,n,s;if(typeof window>"u")return!1;const t=(n=(r=window.matchMedia)==null?void 0:r.call(window,"(display-mode: standalone)"))==null?void 0:n.matches,e=(s=window==null?void 0:window.navigator)==null?void 0:s.standalone;return!!(t||e)},async preloadImage(t){const e=new Promise((r,n)=>{const s=new Image;s.onload=r,s.onerror=n,s.crossOrigin="anonymous",s.src=t});return Promise.race([e,Ae.wait(2e3)])},formatBalance(t,e){let r="0.000";if(typeof t=="string"){const n=Number(t);if(n){const s=Math.floor(n*1e3)/1e3;s&&(r=s.toString())}}return`${r}${e?` ${e}`:""}`},formatBalance2(t,e){var n;let r;if(t==="0")r="0";else if(typeof t=="string"){const s=Number(t);s&&(r=(n=s.toString().match(/^-?\d+(?:\.\d{0,3})?/u))==null?void 0:n[0])}return{value:r??"0",rest:r==="0"?"000":"",symbol:e}},getApiUrl(){return ee.W3M_API_URL},getBlockchainApiUrl(){return ee.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return ee.PULSE_API_URL},getUUID(){return crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})},parseError(t){var e,r;return typeof t=="string"?t:typeof((r=(e=t==null?void 0:t.issues)==null?void 0:e[0])==null?void 0:r.message)=="string"?t.issues[0].message:t instanceof Error?t.message:"Unknown error"},sortRequestedNetworks(t,e=[]){const r={};return e&&t&&(t.forEach((n,s)=>{r[n]=s}),e.sort((n,s)=>{const i=r[n.id],o=r[s.id];return i!==void 0&&o!==void 0?i-o:i!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(t){let e=0;for(const r of t)e+=r.value??0;return e},formatTokenBalance(t){const e=t.toFixed(2),[r,n]=e.split(".");return{dollars:r,pennies:n}},isAddress(t,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)||/^(?:0x)?[0-9A-F]{40}$/iu.test(t))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(t);default:return!1}},uniqueBy(t,e){const r=new Set;return t.filter(n=>{const s=n[e];return r.has(s)?!1:(r.add(s),!0)})},generateSdkVersion(t,e,r){const s=t.length===0?Nt.ADAPTER_TYPES.UNIVERSAL:t.map(i=>i.adapterType).join(",");return`${e}-${s}-${r}`},createAccount(t,e,r,n,s){return{namespace:t,address:e,type:r,publicKey:n,path:s}},isCaipAddress(t){if(typeof t!="string")return!1;const e=t.split(":"),r=e[0];return e.filter(Boolean).length===3&&r in ee.CHAIN_NAME_MAP},isMac(){const t=window==null?void 0:window.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(window==null?void 0:window.location.href)}`,r="state=";if(new URL(t).host==="auth.magic.link"){const s="provider_authorization_url=",i=t.substring(t.indexOf(s)+s.length),o=this.injectIntoUrl(decodeURIComponent(i),r,e);return t.replace(i,encodeURIComponent(o))}return this.injectIntoUrl(t,r,e)},injectIntoUrl(t,e,r){const n=t.indexOf(e);if(n===-1)throw new Error(`${e} parameter not found in the URL: ${t}`);const s=t.indexOf("&",n),i=e.length,o=s!==-1?s:t.length,a=t.substring(0,n+i),c=t.substring(n+i,o),l=t.substring(s),u=c+r;return a+u+l}};async function $i(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class na{constructor({baseUrl:e,clientId:r}){this.baseUrl=e,this.clientId=r}async get({headers:e,signal:r,cache:n,...s}){const i=this.createUrl(s);return(await $i(i,{method:"GET",headers:e,signal:r,cache:n})).json()}async getBlob({headers:e,signal:r,...n}){const s=this.createUrl(n);return(await $i(s,{method:"GET",headers:e,signal:r})).blob()}async post({body:e,headers:r,signal:n,...s}){const i=this.createUrl(s);return(await $i(i,{method:"POST",headers:r,body:e?JSON.stringify(e):void 0,signal:n})).json()}async put({body:e,headers:r,signal:n,...s}){const i=this.createUrl(s);return(await $i(i,{method:"PUT",headers:r,body:e?JSON.stringify(e):void 0,signal:n})).json()}async delete({body:e,headers:r,signal:n,...s}){const i=this.createUrl(s);return(await $i(i,{method:"DELETE",headers:r,body:e?JSON.stringify(e):void 0,signal:n})).json()}createUrl({path:e,params:r}){const n=new URL(e,this.baseUrl);return r&&Object.entries(r).forEach(([s,i])=>{i&&n.searchParams.append(s,i)}),this.clientId&&n.searchParams.append("clientId",this.clientId),n}}const wA={getFeatureValue(t,e){const r=e==null?void 0:e[t];return r===void 0?Nt.DEFAULT_FEATURES[t]:r},filterSocialsByPlatform(t){if(!t||!t.length)return t;if(Ae.isTelegram()){if(Ae.isIos())return t.filter(e=>e!=="google");if(Ae.isMac())return t.filter(e=>e!=="x");if(Ae.isAndroid())return t.filter(e=>!["facebook","x"].includes(e))}return t}},ge=at({features:Nt.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:Nt.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0,experimental_preferUniversalLinks:!1}),z={state:ge,subscribeKey(t,e){return zt(ge,t,e)},setOptions(t){Object.assign(ge,t)},setFeatures(t){if(!t)return;ge.features||(ge.features=Nt.DEFAULT_FEATURES);const e={...ge.features,...t};ge.features=e,ge.features.socials&&(ge.features.socials=wA.filterSocialsByPlatform(ge.features.socials))},setProjectId(t){ge.projectId=t},setCustomRpcUrls(t){ge.customRpcUrls=t},setAllWallets(t){ge.allWallets=t},setIncludeWalletIds(t){ge.includeWalletIds=t},setExcludeWalletIds(t){ge.excludeWalletIds=t},setFeaturedWalletIds(t){ge.featuredWalletIds=t},setTokens(t){ge.tokens=t},setTermsConditionsUrl(t){ge.termsConditionsUrl=t},setPrivacyPolicyUrl(t){ge.privacyPolicyUrl=t},setCustomWallets(t){ge.customWallets=t},setIsSiweEnabled(t){ge.isSiweEnabled=t},setIsUniversalProvider(t){ge.isUniversalProvider=t},setSdkVersion(t){ge.sdkVersion=t},setMetadata(t){ge.metadata=t},setDisableAppend(t){ge.disableAppend=t},setEIP6963Enabled(t){ge.enableEIP6963=t},setDebug(t){ge.debug=t},setEnableWalletConnect(t){ge.enableWalletConnect=t},setEnableWalletGuide(t){ge.enableWalletGuide=t},setEnableAuthLogger(t){ge.enableAuthLogger=t},setEnableWallets(t){ge.enableWallets=t},setPreferUniversalLinks(t){ge.experimental_preferUniversalLinks=t},setHasMultipleAddresses(t){ge.hasMultipleAddresses=t},setSIWX(t){ge.siwx=t},setConnectMethodsOrder(t){ge.features={...ge.features,connectMethodsOrder:t}},setWalletFeaturesOrder(t){ge.features={...ge.features,walletFeaturesOrder:t}},setSocialsOrder(t){ge.features={...ge.features,socials:t}},setCollapseWallets(t){ge.features={...ge.features,collapseWallets:t}},setEnableEmbedded(t){ge.enableEmbedded=t},setAllowUnsupportedChain(t){ge.allowUnsupportedChain=t},setManualWCControl(t){ge.manualWCControl=t},setEnableNetworkSwitch(t){ge.enableNetworkSwitch=t},setDefaultAccountTypes(t={}){Object.entries(t).forEach(([e,r])=>{r&&(ge.defaultAccountTypes[e]=r)})},setUniversalProviderConfigOverride(t){ge.universalProviderConfigOverride=t},getUniversalProviderConfigOverride(){return ge.universalProviderConfigOverride},getSnapshot(){return To(ge)}},AA=Object.freeze({enabled:!0,events:[]}),yA=new na({baseUrl:Ae.getAnalyticsUrl(),clientId:null}),EA=5,CA=60*1e3,Ln=at({...AA}),bA={state:Ln,subscribeKey(t,e){return zt(Ln,t,e)},async sendError(t,e){if(!Ln.enabled)return;const r=Date.now();if(Ln.events.filter(i=>{const o=new Date(i.properties.timestamp||"").getTime();return r-o<CA}).length>=EA)return;const s={type:"error",event:e,properties:{errorType:t.name,errorMessage:t.message,stackTrace:t.stack,timestamp:new Date().toISOString()}};Ln.events.push(s);try{if(typeof window>"u")return;const{projectId:i,sdkType:o,sdkVersion:a}=z.state;await yA.post({path:"/e",params:{projectId:i,st:o,sv:a||"html-wagmi-4.2.2"},body:{eventId:Ae.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:new Date().toISOString(),props:{type:"error",event:e,errorType:t.name,errorMessage:t.message,stackTrace:t.stack}}})}catch(i){console.error("Error sending telemetry event:",i)}},enable(){Ln.enabled=!0},disable(){Ln.enabled=!1},clearEvents(){Ln.events=[]}};class Po extends Error{constructor(e,r,n){super(e),this.name="AppKitError",this.category=r,this.originalError=n,Error.captureStackTrace&&Error.captureStackTrace(this,Po)}}function Od(t,e){const r=t instanceof Po?t:new Po(t instanceof Error?t.message:String(t),e,t);throw bA.sendError(r,r.category),r}function br(t,e="INTERNAL_SDK_ERROR"){const r={};return Object.keys(t).forEach(n=>{const s=t[n];if(typeof s=="function"){let i=s;s.constructor.name==="AsyncFunction"?i=async(...o)=>{try{return await s(...o)}catch(a){return Od(a,e)}}:i=(...o)=>{try{return s(...o)}catch(a){return Od(a,e)}},r[n]=i}else r[n]=s}),r}const vA={handleMobileDeeplinkRedirect(t){const e=window.location.href,r=encodeURIComponent(e);if(t==="Phantom"&&!("phantom"in window)){const n=e.startsWith("https")?"https":"http",s=e.split("/")[2],i=encodeURIComponent(`${n}://${s}`);window.location.href=`https://phantom.app/ul/browse/${r}?ref=${i}`}N.state.activeChain===ee.CHAIN.SOLANA&&t==="Coinbase Wallet"&&!("coinbaseSolana"in window)&&(window.location.href=`https://go.cb-w.com/dapp?cb_url=${r}`)}},pr=at({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),IA={state:pr,subscribeNetworkImages(t){return Qt(pr.networkImages,()=>t(pr.networkImages))},subscribeKey(t,e){return zt(pr,t,e)},subscribe(t){return Qt(pr,()=>t(pr))},setWalletImage(t,e){pr.walletImages[t]=e},setNetworkImage(t,e){pr.networkImages[t]=e},setChainImage(t,e){pr.chainImages[t]=e},setConnectorImage(t,e){pr.connectorImages={...pr.connectorImages,[t]:e}},setTokenImage(t,e){pr.tokenImages[t]=e},setCurrencyImage(t,e){pr.currencyImages[t]=e}},Dr=br(IA),SA={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00",cosmos:""},rl=at({networkImagePromises:{}}),Wu={async fetchWalletImage(t){if(t)return await fe._fetchWalletImage(t),this.getWalletImageById(t)},async fetchNetworkImage(t){if(!t)return;const e=this.getNetworkImageById(t);return e||(rl.networkImagePromises[t]||(rl.networkImagePromises[t]=fe._fetchNetworkImage(t)),await rl.networkImagePromises[t],this.getNetworkImageById(t))},getWalletImageById(t){if(t)return Dr.state.walletImages[t]},getWalletImage(t){if(t!=null&&t.image_url)return t==null?void 0:t.image_url;if(t!=null&&t.image_id)return Dr.state.walletImages[t.image_id]},getNetworkImage(t){var e,r,n;if((e=t==null?void 0:t.assets)!=null&&e.imageUrl)return(r=t==null?void 0:t.assets)==null?void 0:r.imageUrl;if((n=t==null?void 0:t.assets)!=null&&n.imageId)return Dr.state.networkImages[t.assets.imageId]},getNetworkImageById(t){if(t)return Dr.state.networkImages[t]},getConnectorImage(t){if(t!=null&&t.imageUrl)return t.imageUrl;if(t!=null&&t.imageId)return Dr.state.connectorImages[t.imageId]},getChainImage(t){return Dr.state.networkImages[SA[t]]}},Mn=at({message:"",variant:"info",open:!1}),NA={state:Mn,subscribeKey(t,e){return zt(Mn,t,e)},open(t,e){const{debug:r}=z.state,{shortMessage:n,longMessage:s}=t;r&&(Mn.message=n,Mn.variant=e,Mn.open=!0),s&&console.error(typeof s=="function"?s():s)},close(){Mn.open=!1,Mn.message="",Mn.variant="info"}},ln=br(NA),RA=Ae.getAnalyticsUrl(),OA=new na({baseUrl:RA,clientId:null}),TA=["MODAL_CREATED"],yn=at({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),it={state:yn,subscribe(t){return Qt(yn,()=>t(yn))},getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:r}=z.state;return{projectId:t,st:e,sv:r||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(t){try{const e=ue.state.address;if(TA.includes(t.data.event)||typeof window>"u")return;await OA.post({path:"/e",params:it.getSdkProperties(),body:{eventId:Ae.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:t.timestamp,props:{...t.data,address:e}}}),yn.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===ee.HTTP_STATUS_CODES.FORBIDDEN&&!yn.reportedErrors.FORBIDDEN&&(ln.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${po()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),yn.reportedErrors.FORBIDDEN=!0)}},sendEvent(t){var e;yn.timestamp=Date.now(),yn.data=t,(e=z.state.features)!=null&&e.analytics&&it._sendAnalyticsEvent(yn)}},nl={PHANTOM:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",COINBASE:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393"},PA=Ae.getApiUrl(),fr=new na({baseUrl:PA,clientId:null}),xA=40,Td=4,DA=20,Ie=at({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],filteredWallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),fe={state:Ie,subscribeKey(t,e){return zt(Ie,t,e)},_getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:r}=z.state;return{projectId:t,st:e||"appkit",sv:r||"html-wagmi-4.2.2"}},_filterOutExtensions(t){return z.state.isUniversalProvider?t.filter(e=>!!(e.mobile_link||e.desktop_link||e.webapp_link)):t},async _fetchWalletImage(t){const e=`${fr.baseUrl}/getWalletImage/${t}`,r=await fr.getBlob({path:e,params:fe._getSdkProperties()});Dr.setWalletImage(t,URL.createObjectURL(r))},async _fetchNetworkImage(t){const e=`${fr.baseUrl}/public/getAssetImage/${t}`,r=await fr.getBlob({path:e,params:fe._getSdkProperties()});Dr.setNetworkImage(t,URL.createObjectURL(r))},async _fetchConnectorImage(t){const e=`${fr.baseUrl}/public/getAssetImage/${t}`,r=await fr.getBlob({path:e,params:fe._getSdkProperties()});Dr.setConnectorImage(t,URL.createObjectURL(r))},async _fetchCurrencyImage(t){const e=`${fr.baseUrl}/public/getCurrencyImage/${t}`,r=await fr.getBlob({path:e,params:fe._getSdkProperties()});Dr.setCurrencyImage(t,URL.createObjectURL(r))},async _fetchTokenImage(t){const e=`${fr.baseUrl}/public/getTokenImage/${t}`,r=await fr.getBlob({path:e,params:fe._getSdkProperties()});Dr.setTokenImage(t,URL.createObjectURL(r))},_filterWalletsByPlatform(t){return Ae.isMobile()?t==null?void 0:t.filter(r=>r.mobile_link||r.id===nl.COINBASE||r.id===nl.PHANTOM&&N.state.activeChain==="solana"):t},async fetchAllowedOrigins(){try{const{allowedOrigins:t}=await fr.get({path:"/projects/v1/origins",params:fe._getSdkProperties()});return t}catch{return[]}},async fetchNetworkImages(){const t=N.getAllRequestedCaipNetworks(),e=t==null?void 0:t.map(({assets:r})=>r==null?void 0:r.imageId).filter(Boolean).filter(r=>!Wu.getNetworkImageById(r));e&&await Promise.allSettled(e.map(r=>fe._fetchNetworkImage(r)))},async fetchConnectorImages(){const{connectors:t}=ne.state,e=t.map(({imageId:r})=>r).filter(Boolean);await Promise.allSettled(e.map(r=>fe._fetchConnectorImage(r)))},async fetchCurrencyImages(t=[]){await Promise.allSettled(t.map(e=>fe._fetchCurrencyImage(e)))},async fetchTokenImages(t=[]){await Promise.allSettled(t.map(e=>fe._fetchTokenImage(e)))},async fetchWallets(t){var i;const e=t.exclude??[];fe._getSdkProperties().sv.startsWith("html-core-")&&e.push(...Object.values(nl));const n=await fr.get({path:"/getWallets",params:{...fe._getSdkProperties(),...t,page:String(t.page),entries:String(t.entries),include:(i=t.include)==null?void 0:i.join(","),exclude:e.join(",")}});return{data:fe._filterWalletsByPlatform(n==null?void 0:n.data)||[],count:n==null?void 0:n.count}},async fetchFeaturedWallets(){const{featuredWalletIds:t}=z.state;if(t!=null&&t.length){const e={...fe._getSdkProperties(),page:1,entries:(t==null?void 0:t.length)??Td,include:t},{data:r}=await fe.fetchWallets(e);r.sort((s,i)=>t.indexOf(s.id)-t.indexOf(i.id));const n=r.map(s=>s.image_id).filter(Boolean);await Promise.allSettled(n.map(s=>fe._fetchWalletImage(s))),Ie.featured=r,Ie.allFeatured=r}},async fetchRecommendedWallets(){try{Ie.isFetchingRecommendedWallets=!0;const{includeWalletIds:t,excludeWalletIds:e,featuredWalletIds:r}=z.state,n=[...e??[],...r??[]].filter(Boolean),s=N.getRequestedCaipNetworkIds().join(","),i={page:1,entries:Td,include:t,exclude:n,chains:s},{data:o,count:a}=await fe.fetchWallets(i),c=oe.getRecentWallets(),l=o.map(d=>d.image_id).filter(Boolean),u=c.map(d=>d.image_id).filter(Boolean);await Promise.allSettled([...l,...u].map(d=>fe._fetchWalletImage(d))),Ie.recommended=o,Ie.allRecommended=o,Ie.count=a??0}catch{}finally{Ie.isFetchingRecommendedWallet