@argent/x-shared 1.32.9 → 1.33.0

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.d.ts CHANGED
@@ -15,4 +15,5 @@ export * from './signer';
15
15
  export * from './tokens';
16
16
  export * from './transactions';
17
17
  export * from './utils';
18
+ export * from './providers';
18
19
  export type { BigDecimal } from './bigdecimal/types';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("zod"),a=require("./transactionVersion-DEi2xnLR.js"),w=require("starknet"),L=require("react"),D=require("lodash-es"),_e=require("swr"),Ne=require("@scure/base"),ts=require("ua-parser-js"),ns=require("@scure/bip39"),rs=require("@scure/bip39/wordlists/english"),ss=require("object-hash"),pn=f.z.object({name:f.z.string().optional(),address:f.z.string(),ownerAddress:f.z.string(),chain:f.z.enum(["ethereum","zksync","zksync2","starknet"]),deploymentStatus:f.z.enum(["notDeployed","deploying","deployed","deployError"]),application:f.z.enum(["mobile","webwallet","argentx"]),guardianAddresses:f.z.array(f.z.string()).optional(),enabledGuardianAddresses:f.z.array(f.z.string()).optional(),implClassHash:f.z.string().optional(),proxyClassHash:f.z.string().optional(),salt:f.z.string().optional(),created:f.z.string().optional(),contractVersion:f.z.string().optional(),contractName:f.z.string().optional(),version:f.z.number().optional(),owner:f.z.object({guid:f.z.string().optional(),signerType:f.z.enum(["StarknetKey","EthereumKey"]).optional()}).optional()}),os=f.z.object({address:f.z.string(),guardianAddress:f.z.string().optional(),account:pn}),as=f.z.object({ownerAddress:f.z.string(),signature:f.z.object({r:f.z.string(),s:f.z.string()}),implClassHash:f.z.string().optional(),name:f.z.string().optional(),icon:f.z.string().optional()});function is(e){return"transactionVersion"in e}function cs(e){return"simulateTransaction"in e}function ls(e){return!("simulateTransaction"in e)}const gn=f.z.object({value:f.z.string(),platform:f.z.enum(["ios","argentx","android","webwallet"]).nullable()}),us=f.z.object({preferences:f.z.record(gn)}),Sn=f.z.enum(["mainnet-alpha","sepolia-alpha"]),wn=f.z.enum(["mainnet","sepolia"]);function ds(e){return Sn.safeParse(e).success}function hs(e){return wn.safeParse(e).success}const be=18;function Ue({value:e,decimals:t}){if(t===0)return e.toString();const n=e<0n;e=n?-e:e;const r=e.toString().padStart(t,"0"),s=r.slice(0,-t)||"0",o=r.slice(-t).replace(/0+$/,"");return`${n?"-":""}${s}${o?`.${o}`:""}`}const At=(e,t)=>({decimals:t,value:t>=e.decimals?e.value*BigInt(10)**BigInt(t-e.decimals):e.value/BigInt(10)**BigInt(e.decimals-t)}),yn=e=>{const t=e.value.toString().split("").reverse();let n=0;for(let s=0;s<t.length&&t[s]==="0";s++)n++;const r=e.decimals-n;return At(e,r)},bn=(e,t)=>{const n=Math.max(e.decimals,t.decimals),[r,s]=[e,t].map(o=>At(o,n));return[r.value,s.value,n]},Je=e=>(t,n)=>{const[r,s,o]=bn(t,n);return{decimals:o,value:e(r,s,o)}},He=e=>(t,n)=>{const[r,s]=bn(t,n);return e(r,s)},fs=Je((e,t)=>e+t),ms=Je((e,t)=>e-t),ps=Je((e,t,n)=>{if(t===BigInt(0))throw new Error("Division by zero is not allowed");return e*BigInt(10)**BigInt(n)/t}),gs=(e,t)=>yn({decimals:e.decimals+t.decimals,value:e.value*t.value}),Ss=Je((e,t)=>{if(t===BigInt(0))throw new Error("Modulus by zero is not allowed");return e%t}),Tt=e=>({decimals:e.decimals,value:e.value>=BigInt(0)?e.value:-e.value}),En=He((e,t)=>e===t),ws=He((e,t)=>e<t),ys=He((e,t)=>e>t),bs=He((e,t)=>e<=t),Es=He((e,t)=>e>=t),As=(e,t)=>!En(e,t);function Ts(e){return Ue({value:e,decimals:be})}function vs(e){return a.parseUnits(e,be)}function xs(e){return Ue({value:e,decimals:be})}function vt(e){return a.parseUnits(e,be)}function Is(e){return Tt({value:e,decimals:0}).value}function Cs(e){return Tt(vt(e))}function _s(e,t){return{value:BigInt(e),decimals:t}}const Ns={value:1n,decimals:0};function Bs(e){return f.z.string().refine(t=>/^-?\d+(\.\d+)?$/.test(t),{message:"Invalid number format"}).transform(t=>a.parseUnits(t,e))}const Os=Object.freeze(Object.defineProperty({__proto__:null,ONE:Ns,abs:Tt,absBigInt:Is,add:fs,createUnitsSchema:Bs,div:ps,eq:En,formatCurrency:xs,formatEther:Ts,formatUnits:Ue,gt:ys,gte:Es,lt:ws,lte:bs,mod:Ss,mul:gs,not:As,parseCurrency:vt,parseCurrencyAbs:Cs,parseEther:vs,parseUnits:a.parseUnits,sub:ms,toBigDecimal:_s,toFixedDecimals:At,toTiniestPossibleDecimal:yn},Symbol.toStringTag,{value:"Module"}));class ks{constructor(t,n){this.cachePromise=n.open(t).catch(r=>(console.error(new Error("Failed to open cache",{cause:r})),null))}async get(t){const n=await this.cachePromise;if(!n)throw new Error("No cache available");const r=await n.match(t).catch(()=>{throw new Error("Failed to match cache")});if(!r)throw new Error("Failed to match cache");return r.clone()}async set(t,n){const r=await this.cachePromise;r&&await r.put(t,n).catch(()=>{throw new Error("Failed to match cache")})}async delete(t){const n=await this.cachePromise;return n?n.delete(t):!1}async flush(){const t=await this.cachePromise;if(!t)return;const n=await t.keys();await Promise.allSettled(n.map(r=>t.delete(r)))}}class Rs{constructor(t,n){this.httpService=t,this.baseUrl=n,this.offsetInS=0,this.syncIntervalInMs=60*1e3,this.initialSync=this.syncWithServer(),setInterval(()=>void this.syncWithServer(),this.syncIntervalInMs)}async now(){return await this.initialSync,new Date(Date.now()+this.offsetInS*1e3)}async syncWithServer(){if(typeof window>"u")return;const{time:t}=await this.httpService.get(`${this.baseUrl}/time`),n=Math.floor(Date.now()/1e3),r=t-n;this.offsetInS=r}}class Xe{constructor(t,n="json"){this.requestInit=t,this.responseType=n}async get(t,n){const r=D.isFunction(this.requestInit)?await this.requestInit():this.requestInit,s={...r,...n,method:"GET",headers:{...r==null?void 0:r.headers,...n==null?void 0:n.headers}},o=await fetch(t,s).catch(()=>{throw new a.HttpError(a.HTTP_ERROR_MESSAGE.FAILED_TO_FETCH_URL,0)});if(this.responseType==="json"){if(!o.ok)throw new a.HttpError(o.statusText,o.status);return await o.json()}return o}async post(t,n,r){const s=D.isFunction(this.requestInit)?await this.requestInit():this.requestInit,o={...s,...n,method:"POST",headers:{...s==null?void 0:s.headers,...n==null?void 0:n.headers}},i=await fetch(t,o).catch(()=>{throw new a.HttpError(a.HTTP_ERROR_MESSAGE.FAILED_TO_POST_URL,0)});if(!i.ok)throw new a.HttpError(i.statusText,i.status,await i.json());if(i.status===204)return{};const c=await i.json();if(r)try{return r.parse(c)}catch(l){throw new a.HttpError(l.message,0)}return c}async put(t,n){const r=D.isFunction(this.requestInit)?await this.requestInit():this.requestInit,s={...r,...n,method:"PUT",headers:{...r==null?void 0:r.headers,...n==null?void 0:n.headers}},o=await fetch(t,s).catch(()=>{throw new a.HttpError("Failed to put url",0)});if(!o.ok)throw new a.HttpError(o.statusText,o.status);return await o.json()}async delete(t,n){const r=D.isFunction(this.requestInit)?await this.requestInit():this.requestInit,s={...r,...n,method:"DELETE",headers:{...r==null?void 0:r.headers,...n==null?void 0:n.headers}},o=await fetch(t,s).catch(()=>{throw new a.HttpError("Failed to delete url",0)});if(!o.ok)throw new a.HttpError(o.statusText,o.status)}}const ze=e=>{process.env.NODE_ENV};function Ps(e,t){const n=e.clone(),r=new Headers(n.headers);for(const[s,o]of Object.entries(t))r.set(s,o);return new Response(n.body,{status:n.status,statusText:e.statusText,headers:r})}class Fs{constructor(t,n,r,s){this.dateService=t,this.cacheService=n,this.httpService=r,this.options=s,this.inFlightRequests=new Map}async rawGet(t,n){try{const r=await this.cacheService.get(t),s=await this.dateService.now(),o=new Date(r.headers.get("date")||""),i=s.getTime()-o.getTime();if(i<this.options.freshFor)return ze("🟢 [SWR] Using fresh cache"),r;if(i<this.options.staleFor)return this.fetchAndCache(t,n),ze("🟠 [SWR] Revalidating cache"),r;throw new Error("Cache too old")}catch(r){if(r instanceof a.HttpError)throw r;return ze(),await this.fetchAndCache(t,n)}}async get(t,n){const r=await this.rawGet(t,n);return this.parseResponse(r)}async fetchAndCache(t,n){const r=this.inFlightRequests.get(t);if(!r){const s=this.httpService.get(t,n).then(async o=>{const i=await this.dateService.now();return await this.cacheService.set(t,Ps(o,{date:i.toUTCString()})),o}).finally(()=>{this.inFlightRequests.delete(t)});return this.inFlightRequests.set(t,s),s}return ze(),r}parseResponse(t){if(t.ok)return t.json();throw new a.HttpError(t.statusText,t.status)}}const Be=(e,t,n)=>{const r=new Error(e);r.name="FetcherError",r.url=t.url,r.status=t.status,r.statusText=t.statusText,r.responseText=n;try{const s=JSON.parse(n);r.responseJson=s}catch{}return r},xt=async(e,t)=>{const n=await fetch(e,t),r=await n.text();if(!n.ok)throw Be("An error occurred while fetching",n,r);try{return JSON.parse(r)}catch{throw Be("An error occurred while parsing",n,r)}},Ds=async(e,t)=>{const n=await fetch(e,{method:"POST",...t}),r=await n.text();if(!n.ok)throw Be("An error occurred while fetching",n,r);try{return JSON.parse(r)}catch{throw Be("An error occurred while parsing",n,r)}},Us=e=>({refreshInterval:e,dedupingInterval:e}),Hs=e=>`${e.networkId}::${e.address}`,Ls=()=>{};function An(e,t,n,r){const{cache:s}=_e.useSWRConfig(),o=_e(e&&t,e?n:Ls,r);return L.useEffect(()=>{e||(o.mutate(),s.delete(t))},[e]),o}const $s={revalidateOnFocus:!1,revalidateOnMount:!0,revalidateOnReconnect:!1,refreshWhenOffline:!1,refreshWhenHidden:!1,refreshInterval:0},Tn=async(e,t)=>{try{const{time:n}=await xt(a.urlJoin(e,"time"),{headers:t});return n}catch{throw new Error("failed to request time")}},js=async(e,t)=>{const n=await Tn(e,t);return Math.floor(n)};function vn(e){switch(e){case"mainnet-alpha":case w.constants.NetworkName.SN_MAIN:return w.constants.StarknetChainId.SN_MAIN;case"sepolia-alpha":case w.constants.NetworkName.SN_SEPOLIA:return w.constants.StarknetChainId.SN_SEPOLIA;default:throw new a.NetworkError({code:"NOT_FOUND",message:`Unknown networkId: ${e}`})}}function xn(e){return e.replace(".stark","").split(".").map(r=>w.starknetId.useEncoded(r).toString(10))}function In(e){const t=vn(e);return w.starknetId.getStarknetIdContract(t)}function Cn(e,t){const n=In(t),r=xn(e);try{const o={domain:r,hint:[]};return a.callSchema.parse({contractAddress:n,entrypoint:"domain_to_address",calldata:o})}catch(s){throw new a.CallError({code:"NOT_VALID",options:{error:s}})}}async function _n(e,t,n){if(!t||!n)throw new a.NetworkError({code:"NO_NETWORK_OR_MULTICALL"});let r=null;try{r=Cn(e,t)}catch(c){throw new a.CallError({code:"NOT_VALID",options:{error:c}})}let s,o;try{s=await n.callContract(r),o=s[0]}catch{throw new a.AddressError({code:"STARKNAME_ERROR"})}if(a.isZeroAddress(o))throw new a.AddressError({code:"STARKNAME_NOT_FOUND",message:`${e} not found`});if(!a.isValidAddress(o))throw new a.AddressError({code:"STARKNAME_INVALID_ADDRESS",message:`${e} resolved to an invalid address (${o})`});return a.normalizeAddress(o)}class zs{constructor(t,n,r){this.httpService=t,this.baseUrl=n,this.allowedArgentNameNetworkId=r}async parseAddressOrDomain(t,n,r){if(a.isAddress(t))return a.normalizeAddress(t);try{return await this.getAddressFromDomainName(t,n,r)}catch{throw new a.AddressError({code:"NOT_VALID"})}}async getAddressFromDomainName(t,n,r){if(a.isStarknetId(t))return _n(t,n,r);if(a.isArgentName(t)){if(n!==this.allowedArgentNameNetworkId)throw new a.AddressError({code:"ARGENT_NAME_INVALID_NETWORK",message:`Argent name is only enabled on "${this.allowedArgentNameNetworkId}"`});return a.getAddressFromArgentName(t,this.httpService,this.baseUrl)}throw new a.AddressError({code:"NO_ADDRESS_FROM_DOMAIN"})}}const Nn=["0x25ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918"],J={"0.2.4":"0x033434ad846cdd5f23eb73ff09fe6fddd568284a0fb7d1be20ee482f044dabe2","0.2.3":"0x1a7820094feaf82d53f53f214b81292d717e7bb9a92bb2488092cd306f3993f","0.2.2":"0x3e327de1c40540b98d05cbcb13552008e36f0ec8d61d46956d2f9752c294328","0.2.1":"0x7e28fb0161d10d1cf7fe1f13e7ca57bce062731a3bd04494dfd2d0412699727","0.4.0":"0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f","0.3.1":"0x29927c8af6bccf3f6fda035981e765a7bdbf18a2dc0d630494f8758aa908e2b","0.3.0":"0x1a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003"},Oe={"0.1.1":"0x6e150953b26271a740bf2b6e9bca17cc52c68d765f761295de51ceb8526ee72","0.1.0":"0x737ee2f87ce571a58c6c8da558ec18a07ceb64a6172d5ec46171fbc80077a48"};var Vs=typeof global=="object"&&global&&global.Object===Object&&global,Ms=typeof self=="object"&&self&&self.Object===Object&&self,Qe=Vs||Ms||Function("return this")(),We=Qe.Symbol,Bn=Object.prototype,qs=Bn.hasOwnProperty,Gs=Bn.toString,ve=We?We.toStringTag:void 0;function Ws(e){var t=qs.call(e,ve),n=e[ve];try{e[ve]=void 0;var r=!0}catch{}var s=Gs.call(e);return r&&(t?e[ve]=n:delete e[ve]),s}var Ks=Object.prototype,Zs=Ks.toString;function Ys(e){return Zs.call(e)}var Js="[object Null]",Xs="[object Undefined]",Mt=We?We.toStringTag:void 0;function Qs(e){return e==null?e===void 0?Xs:Js:Mt&&Mt in Object(e)?Ws(e):Ys(e)}function On(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var eo="[object AsyncFunction]",to="[object Function]",no="[object GeneratorFunction]",ro="[object Proxy]";function so(e){if(!On(e))return!1;var t=Qs(e);return t==to||t==no||t==eo||t==ro}var lt=Qe["__core-js_shared__"],qt=function(){var e=/[^.]+$/.exec(lt&&lt.keys&&lt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function oo(e){return!!qt&&qt in e}var ao=Function.prototype,io=ao.toString;function co(e){if(e!=null){try{return io.call(e)}catch{}try{return e+""}catch{}}return""}var lo=/[\\^$.*+?()[\]{}|]/g,uo=/^\[object .+?Constructor\]$/,ho=Function.prototype,fo=Object.prototype,mo=ho.toString,po=fo.hasOwnProperty,go=RegExp("^"+mo.call(po).replace(lo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function So(e){if(!On(e)||oo(e))return!1;var t=so(e)?go:uo;return t.test(co(e))}function wo(e,t){return e==null?void 0:e[t]}function It(e,t){var n=wo(e,t);return So(n)?n:void 0}var ke=It(Object,"create");function yo(){this.__data__=ke?ke(null):{},this.size=0}function bo(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Eo="__lodash_hash_undefined__",Ao=Object.prototype,To=Ao.hasOwnProperty;function vo(e){var t=this.__data__;if(ke){var n=t[e];return n===Eo?void 0:n}return To.call(t,e)?t[e]:void 0}var xo=Object.prototype,Io=xo.hasOwnProperty;function Co(e){var t=this.__data__;return ke?t[e]!==void 0:Io.call(t,e)}var _o="__lodash_hash_undefined__";function No(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=ke&&t===void 0?_o:t,this}function ue(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ue.prototype.clear=yo;ue.prototype.delete=bo;ue.prototype.get=vo;ue.prototype.has=Co;ue.prototype.set=No;function Bo(){this.__data__=[],this.size=0}function Oo(e,t){return e===t||e!==e&&t!==t}function et(e,t){for(var n=e.length;n--;)if(Oo(e[n][0],t))return n;return-1}var ko=Array.prototype,Ro=ko.splice;function Po(e){var t=this.__data__,n=et(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Ro.call(t,n,1),--this.size,!0}function Fo(e){var t=this.__data__,n=et(t,e);return n<0?void 0:t[n][1]}function Do(e){return et(this.__data__,e)>-1}function Uo(e,t){var n=this.__data__,r=et(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Ee(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Ee.prototype.clear=Bo;Ee.prototype.delete=Po;Ee.prototype.get=Fo;Ee.prototype.has=Do;Ee.prototype.set=Uo;var Ho=It(Qe,"Map");function Lo(){this.size=0,this.__data__={hash:new ue,map:new(Ho||Ee),string:new ue}}function $o(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function tt(e,t){var n=e.__data__;return $o(t)?n[typeof t=="string"?"string":"hash"]:n.map}function jo(e){var t=tt(this,e).delete(e);return this.size-=t?1:0,t}function zo(e){return tt(this,e).get(e)}function Vo(e){return tt(this,e).has(e)}function Mo(e,t){var n=tt(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function Ae(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Ae.prototype.clear=Lo;Ae.prototype.delete=jo;Ae.prototype.get=zo;Ae.prototype.has=Vo;Ae.prototype.set=Mo;var qo="__lodash_hash_undefined__";function Go(e){return this.__data__.set(e,qo),this}function Wo(e){return this.__data__.has(e)}function Ke(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Ae;++t<n;)this.add(e[t])}Ke.prototype.add=Ke.prototype.push=Go;Ke.prototype.has=Wo;function Ko(e,t,n,r){for(var s=e.length,o=n+-1;++o<s;)if(t(e[o],o,e))return o;return-1}function Zo(e){return e!==e}function Yo(e,t,n){for(var r=n-1,s=e.length;++r<s;)if(e[r]===t)return r;return-1}function Jo(e,t,n){return t===t?Yo(e,t,n):Ko(e,Zo,n)}function Xo(e,t){var n=e==null?0:e.length;return!!n&&Jo(e,t,0)>-1}function Qo(e,t,n){for(var r=-1,s=e==null?0:e.length;++r<s;)if(n(t,e[r]))return!0;return!1}function ea(e,t){return e.has(t)}var ut=It(Qe,"Set");function ta(){}function kn(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var na=1/0,ra=ut&&1/kn(new ut([,-0]))[1]==na?function(e){return new ut(e)}:ta,sa=200;function oa(e,t,n){var r=-1,s=Xo,o=e.length,i=!0,c=[],l=c;if(n)i=!1,s=Qo;else if(o>=sa){var u=ra(e);if(u)return kn(u);i=!1,s=ea,l=new Ke}else l=c;e:for(;++r<o;){var h=e[r],d=h;if(h=n||h!==0?h:0,i&&d===d){for(var y=l.length;y--;)if(l[y]===d)continue e;c.push(h)}else s(l,d,n)||(l!==c&&l.push(d),c.push(h))}return c}function aa(e,t){return t=typeof t=="function"?t:void 0,e&&e.length?oa(e,void 0,t):[]}function St(e){const t=Object.entries(J),n=Object.entries(Oe);switch(e){case"cairo0":return t.filter(([r])=>a.semver.lt(r,"0.3.0")).map(([,r])=>r);case"cairo1":return t.filter(([r])=>a.semver.gte(r,"0.3.0")).map(([,r])=>r);case"multisig":return n.map(([,r])=>r);default:return t.map(([,r])=>r)}}function Rn(){const e=a.semver.maxSatisfying(Object.keys(J),"*");if(!e)throw new Error(`No argent account contract found: v${e} `);return J[e]}function ia(){const e=a.semver.maxSatisfying(Object.keys(Oe),"*");if(!e)throw new Error(`No argent multisig contract found: v${e} `);return Oe[e]}function Pn(){return Object.entries(J).filter(([e])=>a.semver.gte(e,"0.4.0")).map(([,e])=>e)}function ca(){const e=a.semver.maxSatisfying(Object.keys(J),"<0.3.0");if(!e)throw new Error(`No argent account contract found: v${e} `);return J[e]}function Fn(){const e=Object.entries(J).filter(([n])=>a.semver.gte(n,"0.3.1")).map(([,n])=>n),t=Object.entries(Oe).filter(([n])=>a.semver.gte(n,"0.1.1")).map(([,n])=>n);return[...e,...t]}function la(){return Object.entries(J).filter(([e])=>a.semver.gte(e,"0.4.0")).map(([,e])=>e)}function ua(){const e=a.semver.maxSatisfying(Object.keys(J),">=0.4.0");if(!e)throw new Error(`No ledger account contract found: v${e}`);return J[e]}const Dn=(e,t)=>e.cairoVersion===t.cairoVersion&&a.isEqualAddress(e.accountClassHash,t.accountClassHash);function da(e,t,n=[]){const r=a.implementationSchema.parse({cairoVersion:t.cairoVersion??"1",accountClassHash:t.classHash??Rn()}),s=f.z.array(a.implementationSchema).parse(n),o=[...St("cairo0").map(u=>({cairoVersion:"0",accountClassHash:u})),...St("cairo1").map(u=>({cairoVersion:"1",accountClassHash:u}))],l=aa([r,...s,...o],Dn).map(u=>({implementation:u,address:Ln(u.cairoVersion,u.accountClassHash,e,t.guardian,t.salt)})).find(u=>a.isEqualAddress(u.address,t.address));if(!l)throw new a.AccountError({code:"CALCULATED_ADDRESS_NO_MATCH"});return l.implementation}function Un(e,t,n,r,s,o=Nn[0]){const i=Hn(e,t,n,r);return{classHash:e==="0"?o:t,constructorCalldata:w.CallData.compile(i),addressSalt:s||n}}function Hn(e,t,n,r){const s=e!=="0"&&a.isEqualAddress(a.STANDARD_DEVNET_ACCOUNT_CLASS_HASH,t),o={pubkey:n,...s?{}:{guardian:r||"0"}};if(Pn().some(c=>a.isEqualAddress(c,t))){const c=a.getSignerForMultiSigner(n,a.MultiSigner.Starknet),l=r?new w.CairoOption(w.CairoOptionVariant.Some,a.getSignerForMultiSigner(r,a.MultiSigner.Starknet)):new w.CairoOption(w.CairoOptionVariant.None,null);return{ownerSigner:c,guardianAsOption:l}}return e==="0"?a.constructorCallDataSchemaC0.parse({implementation:t,selector:w.hash.getSelectorFromName("initialize"),calldata:w.CallData.compile(o)}):a.constructorCallDataSchemaC1V1.parse({owner:n,guardian:r})}function Ln(e,t,n,r,s){const o=Un(e,t,n,r,s);return w.hash.calculateContractAddressFromHash(o.addressSalt,o.classHash,o.constructorCalldata,0)}function ha(e,t){const n=L.useRef(e),r=L.useRef();return L.useEffect(()=>{n.current=e},[e]),L.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]),(...s)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n.current(...s),t)}}function fa(e,t){const[n,r]=L.useState(e);return L.useEffect(()=>{const s=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(s)}},[e,t]),n}const $n=f.z.object({name:f.z.enum(["dappland","discord","github","telegram","twitter","website"]),url:f.z.string(),position:f.z.number()}),jn=f.z.object({address:a.addressSchemaArgentBackend,chain:f.z.enum(["ethereum","starknet"])}),zn=f.z.object({dappId:f.z.string(),name:f.z.string(),description:f.z.string().optional(),logoUrl:f.z.string().optional(),dappUrl:f.z.string().optional(),inAppBrowserCompatible:f.z.boolean(),argentVerified:f.z.boolean(),links:f.z.array($n).optional(),contracts:f.z.array(jn).optional(),categories:f.z.array(f.z.string()).optional(),supportedApps:f.z.array(f.z.string()).optional(),brandColor:f.z.string().optional(),executeFromOutsideAllowed:f.z.boolean().default(!1).optional()}),Vn=f.z.array(zn);class ma{constructor(t,n){this.apiBase=t,this.httpService=new Xe(n,"json")}async getAll(){const t=await this.httpService.get(`${this.apiBase}/tokens/dapps`),n=Vn.safeParse(t);if(!n.success)throw new Error("Failed to parse known dapps");return n.data}}function Mn(e){var t;return(t=e==null?void 0:e.links)==null?void 0:t.find(n=>n.name==="dappland")}function pa(e){var t;return(t=Mn(e))==null?void 0:t.url}const Ct=f.object({domain:a.starknetIdSchema,address:a.addressSchema.optional(),avatar:f.string().optional(),status:f.union([f.literal("KNOWN"),f.literal("UNKNOWN")])}),qn=f.array(Ct),Gn=f.object({provider:f.string(),name:f.string(),avatar:f.string().optional()}),Wn=f.object({address:a.addressSchema,status:f.union([f.literal("KNOWN"),f.literal("UNKNOWN")]),resolutions:f.array(Gn).optional()}),Kn=f.array(f.string()),Zn=Wn.array();class ga{constructor(t,n){this.apiBase=t,this.headers=n,this.httpService=new Xe(this.headers,"json")}async getAddressFromMultipleStarknetId(t,n,r){const s=new URLSearchParams(n.map(l=>["domain",l]));r&&s.set("includeAvatar","true");const o=a.urlJoin(this.apiBase,t,"starknet.id",`?${s}`),i=await this.httpService.get(o),c=qn.safeParse(i);if(!c.success)throw new Error("Failed to parse name resolution");return c.data}async getAddressFromStarknetId(t,n,r){const s=a.urlJoin(this.apiBase,t,"starknet.id",n,r?"?includeAvatar=true":""),o=await this.httpService.get(s),i=Ct.safeParse(o);if(!i.success)throw new Error("Failed to parse name resolution");return i.data}async getStarknetIdFromAddress(t,n,r){const s=new URLSearchParams(n.map(l=>["address",l]));r&&s.set("includeAvatar","true");const o=a.urlJoin(this.apiBase,t,"addresses",`?${s}`),i=await this.httpService.get(o),c=Zn.safeParse(i);if(!c.success)throw new Error("Failed to parse name resolution");return c.data}async getProvidersNames(t){const n=a.urlJoin(this.apiBase,t,"providers","name"),r=await this.httpService.get(n),s=Kn.safeParse(r);if(!s.success)throw new Error("Failed to parse name resolution");return s.data}}const _t=e=>e.slice(0,6)+"..."+e.slice(-4);function Gt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Sa(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function nt(e,...t){if(!Sa(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Wt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function wa(e,t){nt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Ve=BigInt(2**32-1),Kt=BigInt(32);function ya(e,t=!1){return t?{h:Number(e&Ve),l:Number(e>>Kt&Ve)}:{h:Number(e>>Kt&Ve)|0,l:Number(e&Ve)|0}}function ba(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:o,l:i}=ya(e[s],t);[n[s],r[s]]=[o,i]}return[n,r]}const Ea=(e,t,n)=>e<<n|t>>>32-n,Aa=(e,t,n)=>t<<n|e>>>32-n,Ta=(e,t,n)=>t<<n-32|e>>>64-n,va=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const xa=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Zt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Ia=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function Yt(e){for(let t=0;t<e.length;t++)e[t]=Ia(e[t])}const Ca=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function _a(e){nt(e);let t="";for(let n=0;n<e.length;n++)t+=Ca[e[n]];return t}function Yn(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Jn(e){return typeof e=="string"&&(e=Yn(e)),nt(e),e}let Na=class{clone(){return this._cloneInto()}};function Ba(e){const t=r=>e().update(Jn(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const Xn=[],Qn=[],er=[],Oa=BigInt(0),xe=BigInt(1),ka=BigInt(2),Ra=BigInt(7),Pa=BigInt(256),Fa=BigInt(113);for(let e=0,t=xe,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Xn.push(2*(5*r+n)),Qn.push((e+1)*(e+2)/2%64);let s=Oa;for(let o=0;o<7;o++)t=(t<<xe^(t>>Ra)*Fa)%Pa,t&ka&&(s^=xe<<(xe<<BigInt(o))-xe);er.push(s)}const[Da,Ua]=ba(er,!0),Jt=(e,t,n)=>n>32?Ta(e,t,n):Ea(e,t,n),Xt=(e,t,n)=>n>32?va(e,t,n):Aa(e,t,n);function Ha(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,l=(i+2)%10,u=n[l],h=n[l+1],d=Jt(u,h,1)^n[c],y=Xt(u,h,1)^n[c+1];for(let g=0;g<50;g+=10)e[i+g]^=d,e[i+g+1]^=y}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=Qn[i],l=Jt(s,o,c),u=Xt(s,o,c),h=Xn[i];s=e[h],o=e[h+1],e[h]=l,e[h+1]=u}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=Da[r],e[1]^=Ua[r]}n.fill(0)}let La=class tr extends Na{constructor(t,n,r,s=!1,o=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Gt(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=xa(this.state)}keccak(){Zt||Yt(this.state32),Ha(this.state32,this.rounds),Zt||Yt(this.state32),this.posOut=0,this.pos=0}update(t){Wt(this);const{blockLen:n,state:r}=this;t=Jn(t);const s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let c=0;c<i;c++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,n&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Wt(this,!1),nt(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Gt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(wa(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new tr(n,r,s,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}};const $a=(e,t,n)=>Ba(()=>new La(t,e,n)),ja=$a(1,136,256/8);function nr(e){return`0x${_a(ja(Yn(e)))}`}const za=e=>{if(!D.isString(e))return;const t=/(\d+)$/,n=e.match(t);if(n)return n[1]},rr=(e,t=!1)=>{if(!D.isString(e))return"";const n=t?e.replace(/[^0-9a-z ]/gi,""):e,s=D.upperCase(n).split(" "),o=za(n),i=s.map(c=>c[0]);return o&&o.length>1&&o.length<n.length?[i[0],o.substring(0,2)].join(""):s.length===1?s[0].substring(0,2):[i[0],i[i.length-1]].join("")},{toBigInt:Va}=w.num,Qt=e=>{const t=e.replace("#","");if(!/^[0-9A-F]{6}$/i.test(t))throw new Error(`Invalid color ${e}`);return`#${t}`},Re=(e,t)=>{const n=Qt(t.background),r=Qt(t.color??"#ffffff"),s=rr(e,!0),o=`<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("zod"),a=require("./transactionVersion-DEi2xnLR.js"),w=require("starknet"),D=require("react"),U=require("lodash-es"),_e=require("swr"),Ne=require("@scure/base"),ns=require("ua-parser-js"),rs=require("@scure/bip39"),ss=require("@scure/bip39/wordlists/english"),os=require("object-hash"),as=require("react/jsx-runtime"),gn=f.z.object({name:f.z.string().optional(),address:f.z.string(),ownerAddress:f.z.string(),chain:f.z.enum(["ethereum","zksync","zksync2","starknet"]),deploymentStatus:f.z.enum(["notDeployed","deploying","deployed","deployError"]),application:f.z.enum(["mobile","webwallet","argentx"]),guardianAddresses:f.z.array(f.z.string()).optional(),enabledGuardianAddresses:f.z.array(f.z.string()).optional(),implClassHash:f.z.string().optional(),proxyClassHash:f.z.string().optional(),salt:f.z.string().optional(),created:f.z.string().optional(),contractVersion:f.z.string().optional(),contractName:f.z.string().optional(),version:f.z.number().optional(),owner:f.z.object({guid:f.z.string().optional(),signerType:f.z.enum(["StarknetKey","EthereumKey"]).optional()}).optional()}),is=f.z.object({address:f.z.string(),guardianAddress:f.z.string().optional(),account:gn}),cs=f.z.object({ownerAddress:f.z.string(),signature:f.z.object({r:f.z.string(),s:f.z.string()}),implClassHash:f.z.string().optional(),name:f.z.string().optional(),icon:f.z.string().optional()});function ls(e){return"transactionVersion"in e}function us(e){return"simulateTransaction"in e}function ds(e){return!("simulateTransaction"in e)}const Sn=f.z.object({value:f.z.string(),platform:f.z.enum(["ios","argentx","android","webwallet"]).nullable()}),hs=f.z.object({preferences:f.z.record(Sn)}),wn=f.z.enum(["mainnet-alpha","sepolia-alpha"]),yn=f.z.enum(["mainnet","sepolia"]);function fs(e){return wn.safeParse(e).success}function ms(e){return yn.safeParse(e).success}const be=18;function Ue({value:e,decimals:t}){if(t===0)return e.toString();const n=e<0n;e=n?-e:e;const r=e.toString().padStart(t,"0"),s=r.slice(0,-t)||"0",o=r.slice(-t).replace(/0+$/,"");return`${n?"-":""}${s}${o?`.${o}`:""}`}const At=(e,t)=>({decimals:t,value:t>=e.decimals?e.value*BigInt(10)**BigInt(t-e.decimals):e.value/BigInt(10)**BigInt(e.decimals-t)}),bn=e=>{const t=e.value.toString().split("").reverse();let n=0;for(let s=0;s<t.length&&t[s]==="0";s++)n++;const r=e.decimals-n;return At(e,r)},En=(e,t)=>{const n=Math.max(e.decimals,t.decimals),[r,s]=[e,t].map(o=>At(o,n));return[r.value,s.value,n]},Je=e=>(t,n)=>{const[r,s,o]=En(t,n);return{decimals:o,value:e(r,s,o)}},Le=e=>(t,n)=>{const[r,s]=En(t,n);return e(r,s)},ps=Je((e,t)=>e+t),gs=Je((e,t)=>e-t),Ss=Je((e,t,n)=>{if(t===BigInt(0))throw new Error("Division by zero is not allowed");return e*BigInt(10)**BigInt(n)/t}),ws=(e,t)=>bn({decimals:e.decimals+t.decimals,value:e.value*t.value}),ys=Je((e,t)=>{if(t===BigInt(0))throw new Error("Modulus by zero is not allowed");return e%t}),Tt=e=>({decimals:e.decimals,value:e.value>=BigInt(0)?e.value:-e.value}),An=Le((e,t)=>e===t),bs=Le((e,t)=>e<t),Es=Le((e,t)=>e>t),As=Le((e,t)=>e<=t),Ts=Le((e,t)=>e>=t),vs=(e,t)=>!An(e,t);function xs(e){return Ue({value:e,decimals:be})}function Is(e){return a.parseUnits(e,be)}function Cs(e){return Ue({value:e,decimals:be})}function vt(e){return a.parseUnits(e,be)}function _s(e){return Tt({value:e,decimals:0}).value}function Ns(e){return Tt(vt(e))}function Bs(e,t){return{value:BigInt(e),decimals:t}}const Os={value:1n,decimals:0};function ks(e){return f.z.string().refine(t=>/^-?\d+(\.\d+)?$/.test(t),{message:"Invalid number format"}).transform(t=>a.parseUnits(t,e))}const Rs=Object.freeze(Object.defineProperty({__proto__:null,ONE:Os,abs:Tt,absBigInt:_s,add:ps,createUnitsSchema:ks,div:Ss,eq:An,formatCurrency:Cs,formatEther:xs,formatUnits:Ue,gt:Es,gte:Ts,lt:bs,lte:As,mod:ys,mul:ws,not:vs,parseCurrency:vt,parseCurrencyAbs:Ns,parseEther:Is,parseUnits:a.parseUnits,sub:gs,toBigDecimal:Bs,toFixedDecimals:At,toTiniestPossibleDecimal:bn},Symbol.toStringTag,{value:"Module"}));class Ps{constructor(t,n){this.cachePromise=n.open(t).catch(r=>(console.error(new Error("Failed to open cache",{cause:r})),null))}async get(t){const n=await this.cachePromise;if(!n)throw new Error("No cache available");const r=await n.match(t).catch(()=>{throw new Error("Failed to match cache")});if(!r)throw new Error("Failed to match cache");return r.clone()}async set(t,n){const r=await this.cachePromise;r&&await r.put(t,n).catch(()=>{throw new Error("Failed to match cache")})}async delete(t){const n=await this.cachePromise;return n?n.delete(t):!1}async flush(){const t=await this.cachePromise;if(!t)return;const n=await t.keys();await Promise.allSettled(n.map(r=>t.delete(r)))}}class Fs{constructor(t,n){this.httpService=t,this.baseUrl=n,this.offsetInS=0,this.syncIntervalInMs=60*1e3,this.initialSync=this.syncWithServer(),setInterval(()=>void this.syncWithServer(),this.syncIntervalInMs)}async now(){return await this.initialSync,new Date(Date.now()+this.offsetInS*1e3)}async syncWithServer(){if(typeof window>"u")return;const{time:t}=await this.httpService.get(`${this.baseUrl}/time`),n=Math.floor(Date.now()/1e3),r=t-n;this.offsetInS=r}}class Xe{constructor(t,n="json"){this.requestInit=t,this.responseType=n}async get(t,n){const r=U.isFunction(this.requestInit)?await this.requestInit():this.requestInit,s={...r,...n,method:"GET",headers:{...r==null?void 0:r.headers,...n==null?void 0:n.headers}},o=await fetch(t,s).catch(()=>{throw new a.HttpError(a.HTTP_ERROR_MESSAGE.FAILED_TO_FETCH_URL,0)});if(this.responseType==="json"){if(!o.ok)throw new a.HttpError(o.statusText,o.status);return await o.json()}return o}async post(t,n,r){const s=U.isFunction(this.requestInit)?await this.requestInit():this.requestInit,o={...s,...n,method:"POST",headers:{...s==null?void 0:s.headers,...n==null?void 0:n.headers}},i=await fetch(t,o).catch(()=>{throw new a.HttpError(a.HTTP_ERROR_MESSAGE.FAILED_TO_POST_URL,0)});if(!i.ok)throw new a.HttpError(i.statusText,i.status,await i.json());if(i.status===204)return{};const c=await i.json();if(r)try{return r.parse(c)}catch(l){throw new a.HttpError(l.message,0)}return c}async put(t,n){const r=U.isFunction(this.requestInit)?await this.requestInit():this.requestInit,s={...r,...n,method:"PUT",headers:{...r==null?void 0:r.headers,...n==null?void 0:n.headers}},o=await fetch(t,s).catch(()=>{throw new a.HttpError("Failed to put url",0)});if(!o.ok)throw new a.HttpError(o.statusText,o.status);return await o.json()}async delete(t,n){const r=U.isFunction(this.requestInit)?await this.requestInit():this.requestInit,s={...r,...n,method:"DELETE",headers:{...r==null?void 0:r.headers,...n==null?void 0:n.headers}},o=await fetch(t,s).catch(()=>{throw new a.HttpError("Failed to delete url",0)});if(!o.ok)throw new a.HttpError(o.statusText,o.status)}}const ze=e=>{process.env.NODE_ENV};function Ds(e,t){const n=e.clone(),r=new Headers(n.headers);for(const[s,o]of Object.entries(t))r.set(s,o);return new Response(n.body,{status:n.status,statusText:e.statusText,headers:r})}class Us{constructor(t,n,r,s){this.dateService=t,this.cacheService=n,this.httpService=r,this.options=s,this.inFlightRequests=new Map}async rawGet(t,n){try{const r=await this.cacheService.get(t),s=await this.dateService.now(),o=new Date(r.headers.get("date")||""),i=s.getTime()-o.getTime();if(i<this.options.freshFor)return ze("🟢 [SWR] Using fresh cache"),r;if(i<this.options.staleFor)return this.fetchAndCache(t,n),ze("🟠 [SWR] Revalidating cache"),r;throw new Error("Cache too old")}catch(r){if(r instanceof a.HttpError)throw r;return ze(),await this.fetchAndCache(t,n)}}async get(t,n){const r=await this.rawGet(t,n);return this.parseResponse(r)}async fetchAndCache(t,n){const r=this.inFlightRequests.get(t);if(!r){const s=this.httpService.get(t,n).then(async o=>{const i=await this.dateService.now();return await this.cacheService.set(t,Ds(o,{date:i.toUTCString()})),o}).finally(()=>{this.inFlightRequests.delete(t)});return this.inFlightRequests.set(t,s),s}return ze(),r}parseResponse(t){if(t.ok)return t.json();throw new a.HttpError(t.statusText,t.status)}}const Be=(e,t,n)=>{const r=new Error(e);r.name="FetcherError",r.url=t.url,r.status=t.status,r.statusText=t.statusText,r.responseText=n;try{const s=JSON.parse(n);r.responseJson=s}catch{}return r},xt=async(e,t)=>{const n=await fetch(e,t),r=await n.text();if(!n.ok)throw Be("An error occurred while fetching",n,r);try{return JSON.parse(r)}catch{throw Be("An error occurred while parsing",n,r)}},Ls=async(e,t)=>{const n=await fetch(e,{method:"POST",...t}),r=await n.text();if(!n.ok)throw Be("An error occurred while fetching",n,r);try{return JSON.parse(r)}catch{throw Be("An error occurred while parsing",n,r)}},Hs=e=>({refreshInterval:e,dedupingInterval:e}),$s=e=>`${e.networkId}::${e.address}`,js=()=>{};function Tn(e,t,n,r){const{cache:s}=_e.useSWRConfig(),o=_e(e&&t,e?n:js,r);return D.useEffect(()=>{e||(o.mutate(),s.delete(t))},[e]),o}const zs={revalidateOnFocus:!1,revalidateOnMount:!0,revalidateOnReconnect:!1,refreshWhenOffline:!1,refreshWhenHidden:!1,refreshInterval:0},vn=async(e,t)=>{try{const{time:n}=await xt(a.urlJoin(e,"time"),{headers:t});return n}catch{throw new Error("failed to request time")}},Vs=async(e,t)=>{const n=await vn(e,t);return Math.floor(n)};function xn(e){switch(e){case"mainnet-alpha":case w.constants.NetworkName.SN_MAIN:return w.constants.StarknetChainId.SN_MAIN;case"sepolia-alpha":case w.constants.NetworkName.SN_SEPOLIA:return w.constants.StarknetChainId.SN_SEPOLIA;default:throw new a.NetworkError({code:"NOT_FOUND",message:`Unknown networkId: ${e}`})}}function In(e){return e.replace(".stark","").split(".").map(r=>w.starknetId.useEncoded(r).toString(10))}function Cn(e){const t=xn(e);return w.starknetId.getStarknetIdContract(t)}function _n(e,t){const n=Cn(t),r=In(e);try{const o={domain:r,hint:[]};return a.callSchema.parse({contractAddress:n,entrypoint:"domain_to_address",calldata:o})}catch(s){throw new a.CallError({code:"NOT_VALID",options:{error:s}})}}async function Nn(e,t,n){if(!t||!n)throw new a.NetworkError({code:"NO_NETWORK_OR_MULTICALL"});let r=null;try{r=_n(e,t)}catch(c){throw new a.CallError({code:"NOT_VALID",options:{error:c}})}let s,o;try{s=await n.callContract(r),o=s[0]}catch{throw new a.AddressError({code:"STARKNAME_ERROR"})}if(a.isZeroAddress(o))throw new a.AddressError({code:"STARKNAME_NOT_FOUND",message:`${e} not found`});if(!a.isValidAddress(o))throw new a.AddressError({code:"STARKNAME_INVALID_ADDRESS",message:`${e} resolved to an invalid address (${o})`});return a.normalizeAddress(o)}class Ms{constructor(t,n,r){this.httpService=t,this.baseUrl=n,this.allowedArgentNameNetworkId=r}async parseAddressOrDomain(t,n,r){if(a.isAddress(t))return a.normalizeAddress(t);try{return await this.getAddressFromDomainName(t,n,r)}catch{throw new a.AddressError({code:"NOT_VALID"})}}async getAddressFromDomainName(t,n,r){if(a.isStarknetId(t))return Nn(t,n,r);if(a.isArgentName(t)){if(n!==this.allowedArgentNameNetworkId)throw new a.AddressError({code:"ARGENT_NAME_INVALID_NETWORK",message:`Argent name is only enabled on "${this.allowedArgentNameNetworkId}"`});return a.getAddressFromArgentName(t,this.httpService,this.baseUrl)}throw new a.AddressError({code:"NO_ADDRESS_FROM_DOMAIN"})}}const Bn=["0x25ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918"],J={"0.2.4":"0x033434ad846cdd5f23eb73ff09fe6fddd568284a0fb7d1be20ee482f044dabe2","0.2.3":"0x1a7820094feaf82d53f53f214b81292d717e7bb9a92bb2488092cd306f3993f","0.2.2":"0x3e327de1c40540b98d05cbcb13552008e36f0ec8d61d46956d2f9752c294328","0.2.1":"0x7e28fb0161d10d1cf7fe1f13e7ca57bce062731a3bd04494dfd2d0412699727","0.4.0":"0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f","0.3.1":"0x29927c8af6bccf3f6fda035981e765a7bdbf18a2dc0d630494f8758aa908e2b","0.3.0":"0x1a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003"},Oe={"0.1.1":"0x6e150953b26271a740bf2b6e9bca17cc52c68d765f761295de51ceb8526ee72","0.1.0":"0x737ee2f87ce571a58c6c8da558ec18a07ceb64a6172d5ec46171fbc80077a48"};var qs=typeof global=="object"&&global&&global.Object===Object&&global,Gs=typeof self=="object"&&self&&self.Object===Object&&self,Qe=qs||Gs||Function("return this")(),We=Qe.Symbol,On=Object.prototype,Ws=On.hasOwnProperty,Ks=On.toString,ve=We?We.toStringTag:void 0;function Zs(e){var t=Ws.call(e,ve),n=e[ve];try{e[ve]=void 0;var r=!0}catch{}var s=Ks.call(e);return r&&(t?e[ve]=n:delete e[ve]),s}var Ys=Object.prototype,Js=Ys.toString;function Xs(e){return Js.call(e)}var Qs="[object Null]",eo="[object Undefined]",Mt=We?We.toStringTag:void 0;function to(e){return e==null?e===void 0?eo:Qs:Mt&&Mt in Object(e)?Zs(e):Xs(e)}function kn(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var no="[object AsyncFunction]",ro="[object Function]",so="[object GeneratorFunction]",oo="[object Proxy]";function ao(e){if(!kn(e))return!1;var t=to(e);return t==ro||t==so||t==no||t==oo}var lt=Qe["__core-js_shared__"],qt=function(){var e=/[^.]+$/.exec(lt&&lt.keys&&lt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function io(e){return!!qt&&qt in e}var co=Function.prototype,lo=co.toString;function uo(e){if(e!=null){try{return lo.call(e)}catch{}try{return e+""}catch{}}return""}var ho=/[\\^$.*+?()[\]{}|]/g,fo=/^\[object .+?Constructor\]$/,mo=Function.prototype,po=Object.prototype,go=mo.toString,So=po.hasOwnProperty,wo=RegExp("^"+go.call(So).replace(ho,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function yo(e){if(!kn(e)||io(e))return!1;var t=ao(e)?wo:fo;return t.test(uo(e))}function bo(e,t){return e==null?void 0:e[t]}function It(e,t){var n=bo(e,t);return yo(n)?n:void 0}var ke=It(Object,"create");function Eo(){this.__data__=ke?ke(null):{},this.size=0}function Ao(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var To="__lodash_hash_undefined__",vo=Object.prototype,xo=vo.hasOwnProperty;function Io(e){var t=this.__data__;if(ke){var n=t[e];return n===To?void 0:n}return xo.call(t,e)?t[e]:void 0}var Co=Object.prototype,_o=Co.hasOwnProperty;function No(e){var t=this.__data__;return ke?t[e]!==void 0:_o.call(t,e)}var Bo="__lodash_hash_undefined__";function Oo(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=ke&&t===void 0?Bo:t,this}function ue(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ue.prototype.clear=Eo;ue.prototype.delete=Ao;ue.prototype.get=Io;ue.prototype.has=No;ue.prototype.set=Oo;function ko(){this.__data__=[],this.size=0}function Ro(e,t){return e===t||e!==e&&t!==t}function et(e,t){for(var n=e.length;n--;)if(Ro(e[n][0],t))return n;return-1}var Po=Array.prototype,Fo=Po.splice;function Do(e){var t=this.__data__,n=et(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Fo.call(t,n,1),--this.size,!0}function Uo(e){var t=this.__data__,n=et(t,e);return n<0?void 0:t[n][1]}function Lo(e){return et(this.__data__,e)>-1}function Ho(e,t){var n=this.__data__,r=et(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Ee(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Ee.prototype.clear=ko;Ee.prototype.delete=Do;Ee.prototype.get=Uo;Ee.prototype.has=Lo;Ee.prototype.set=Ho;var $o=It(Qe,"Map");function jo(){this.size=0,this.__data__={hash:new ue,map:new($o||Ee),string:new ue}}function zo(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function tt(e,t){var n=e.__data__;return zo(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Vo(e){var t=tt(this,e).delete(e);return this.size-=t?1:0,t}function Mo(e){return tt(this,e).get(e)}function qo(e){return tt(this,e).has(e)}function Go(e,t){var n=tt(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function Ae(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Ae.prototype.clear=jo;Ae.prototype.delete=Vo;Ae.prototype.get=Mo;Ae.prototype.has=qo;Ae.prototype.set=Go;var Wo="__lodash_hash_undefined__";function Ko(e){return this.__data__.set(e,Wo),this}function Zo(e){return this.__data__.has(e)}function Ke(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Ae;++t<n;)this.add(e[t])}Ke.prototype.add=Ke.prototype.push=Ko;Ke.prototype.has=Zo;function Yo(e,t,n,r){for(var s=e.length,o=n+-1;++o<s;)if(t(e[o],o,e))return o;return-1}function Jo(e){return e!==e}function Xo(e,t,n){for(var r=n-1,s=e.length;++r<s;)if(e[r]===t)return r;return-1}function Qo(e,t,n){return t===t?Xo(e,t,n):Yo(e,Jo,n)}function ea(e,t){var n=e==null?0:e.length;return!!n&&Qo(e,t,0)>-1}function ta(e,t,n){for(var r=-1,s=e==null?0:e.length;++r<s;)if(n(t,e[r]))return!0;return!1}function na(e,t){return e.has(t)}var ut=It(Qe,"Set");function ra(){}function Rn(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var sa=1/0,oa=ut&&1/Rn(new ut([,-0]))[1]==sa?function(e){return new ut(e)}:ra,aa=200;function ia(e,t,n){var r=-1,s=ea,o=e.length,i=!0,c=[],l=c;if(n)i=!1,s=ta;else if(o>=aa){var u=oa(e);if(u)return Rn(u);i=!1,s=na,l=new Ke}else l=c;e:for(;++r<o;){var h=e[r],d=h;if(h=n||h!==0?h:0,i&&d===d){for(var y=l.length;y--;)if(l[y]===d)continue e;c.push(h)}else s(l,d,n)||(l!==c&&l.push(d),c.push(h))}return c}function ca(e,t){return t=typeof t=="function"?t:void 0,e&&e.length?ia(e,void 0,t):[]}function St(e){const t=Object.entries(J),n=Object.entries(Oe);switch(e){case"cairo0":return t.filter(([r])=>a.semver.lt(r,"0.3.0")).map(([,r])=>r);case"cairo1":return t.filter(([r])=>a.semver.gte(r,"0.3.0")).map(([,r])=>r);case"multisig":return n.map(([,r])=>r);default:return t.map(([,r])=>r)}}function Pn(){const e=a.semver.maxSatisfying(Object.keys(J),"*");if(!e)throw new Error(`No argent account contract found: v${e} `);return J[e]}function la(){const e=a.semver.maxSatisfying(Object.keys(Oe),"*");if(!e)throw new Error(`No argent multisig contract found: v${e} `);return Oe[e]}function Fn(){return Object.entries(J).filter(([e])=>a.semver.gte(e,"0.4.0")).map(([,e])=>e)}function ua(){const e=a.semver.maxSatisfying(Object.keys(J),"<0.3.0");if(!e)throw new Error(`No argent account contract found: v${e} `);return J[e]}function Dn(){const e=Object.entries(J).filter(([n])=>a.semver.gte(n,"0.3.1")).map(([,n])=>n),t=Object.entries(Oe).filter(([n])=>a.semver.gte(n,"0.1.1")).map(([,n])=>n);return[...e,...t]}function da(){return Object.entries(J).filter(([e])=>a.semver.gte(e,"0.4.0")).map(([,e])=>e)}function ha(){const e=a.semver.maxSatisfying(Object.keys(J),">=0.4.0");if(!e)throw new Error(`No ledger account contract found: v${e}`);return J[e]}const Un=(e,t)=>e.cairoVersion===t.cairoVersion&&a.isEqualAddress(e.accountClassHash,t.accountClassHash);function fa(e,t,n=[]){const r=a.implementationSchema.parse({cairoVersion:t.cairoVersion??"1",accountClassHash:t.classHash??Pn()}),s=f.z.array(a.implementationSchema).parse(n),o=[...St("cairo0").map(u=>({cairoVersion:"0",accountClassHash:u})),...St("cairo1").map(u=>({cairoVersion:"1",accountClassHash:u}))],l=ca([r,...s,...o],Un).map(u=>({implementation:u,address:$n(u.cairoVersion,u.accountClassHash,e,t.guardian,t.salt)})).find(u=>a.isEqualAddress(u.address,t.address));if(!l)throw new a.AccountError({code:"CALCULATED_ADDRESS_NO_MATCH"});return l.implementation}function Ln(e,t,n,r,s,o=Bn[0]){const i=Hn(e,t,n,r);return{classHash:e==="0"?o:t,constructorCalldata:w.CallData.compile(i),addressSalt:s||n}}function Hn(e,t,n,r){const s=e!=="0"&&a.isEqualAddress(a.STANDARD_DEVNET_ACCOUNT_CLASS_HASH,t),o={pubkey:n,...s?{}:{guardian:r||"0"}};if(Fn().some(c=>a.isEqualAddress(c,t))){const c=a.getSignerForMultiSigner(n,a.MultiSigner.Starknet),l=r?new w.CairoOption(w.CairoOptionVariant.Some,a.getSignerForMultiSigner(r,a.MultiSigner.Starknet)):new w.CairoOption(w.CairoOptionVariant.None,null);return{ownerSigner:c,guardianAsOption:l}}return e==="0"?a.constructorCallDataSchemaC0.parse({implementation:t,selector:w.hash.getSelectorFromName("initialize"),calldata:w.CallData.compile(o)}):a.constructorCallDataSchemaC1V1.parse({owner:n,guardian:r})}function $n(e,t,n,r,s){const o=Ln(e,t,n,r,s);return w.hash.calculateContractAddressFromHash(o.addressSalt,o.classHash,o.constructorCalldata,0)}function ma(e,t){const n=D.useRef(e),r=D.useRef();return D.useEffect(()=>{n.current=e},[e]),D.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]),(...s)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n.current(...s),t)}}function pa(e,t){const[n,r]=D.useState(e);return D.useEffect(()=>{const s=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(s)}},[e,t]),n}const jn=f.z.object({name:f.z.enum(["dappland","discord","github","telegram","twitter","website"]),url:f.z.string(),position:f.z.number()}),zn=f.z.object({address:a.addressSchemaArgentBackend,chain:f.z.enum(["ethereum","starknet"])}),Vn=f.z.object({dappId:f.z.string(),name:f.z.string(),description:f.z.string().optional(),logoUrl:f.z.string().optional(),dappUrl:f.z.string().optional(),inAppBrowserCompatible:f.z.boolean(),argentVerified:f.z.boolean(),links:f.z.array(jn).optional(),contracts:f.z.array(zn).optional(),categories:f.z.array(f.z.string()).optional(),supportedApps:f.z.array(f.z.string()).optional(),brandColor:f.z.string().optional(),executeFromOutsideAllowed:f.z.boolean().default(!1).optional()}),Mn=f.z.array(Vn);class ga{constructor(t,n){this.apiBase=t,this.httpService=new Xe(n,"json")}async getAll(){const t=await this.httpService.get(`${this.apiBase}/tokens/dapps`),n=Mn.safeParse(t);if(!n.success)throw new Error("Failed to parse known dapps");return n.data}}function qn(e){var t;return(t=e==null?void 0:e.links)==null?void 0:t.find(n=>n.name==="dappland")}function Sa(e){var t;return(t=qn(e))==null?void 0:t.url}const Ct=f.object({domain:a.starknetIdSchema,address:a.addressSchema.optional(),avatar:f.string().optional(),status:f.union([f.literal("KNOWN"),f.literal("UNKNOWN")])}),Gn=f.array(Ct),Wn=f.object({provider:f.string(),name:f.string(),avatar:f.string().optional()}),Kn=f.object({address:a.addressSchema,status:f.union([f.literal("KNOWN"),f.literal("UNKNOWN")]),resolutions:f.array(Wn).optional()}),Zn=f.array(f.string()),Yn=Kn.array();class wa{constructor(t,n){this.apiBase=t,this.headers=n,this.httpService=new Xe(this.headers,"json")}async getAddressFromMultipleStarknetId(t,n,r){const s=new URLSearchParams(n.map(l=>["domain",l]));r&&s.set("includeAvatar","true");const o=a.urlJoin(this.apiBase,t,"starknet.id",`?${s}`),i=await this.httpService.get(o),c=Gn.safeParse(i);if(!c.success)throw new Error("Failed to parse name resolution");return c.data}async getAddressFromStarknetId(t,n,r){const s=a.urlJoin(this.apiBase,t,"starknet.id",n,r?"?includeAvatar=true":""),o=await this.httpService.get(s),i=Ct.safeParse(o);if(!i.success)throw new Error("Failed to parse name resolution");return i.data}async getStarknetIdFromAddress(t,n,r){const s=new URLSearchParams(n.map(l=>["address",l]));r&&s.set("includeAvatar","true");const o=a.urlJoin(this.apiBase,t,"addresses",`?${s}`),i=await this.httpService.get(o),c=Yn.safeParse(i);if(!c.success)throw new Error("Failed to parse name resolution");return c.data}async getProvidersNames(t){const n=a.urlJoin(this.apiBase,t,"providers","name"),r=await this.httpService.get(n),s=Zn.safeParse(r);if(!s.success)throw new Error("Failed to parse name resolution");return s.data}}const _t=e=>e.slice(0,6)+"..."+e.slice(-4);function Gt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function ya(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function nt(e,...t){if(!ya(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Wt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ba(e,t){nt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Ve=BigInt(2**32-1),Kt=BigInt(32);function Ea(e,t=!1){return t?{h:Number(e&Ve),l:Number(e>>Kt&Ve)}:{h:Number(e>>Kt&Ve)|0,l:Number(e&Ve)|0}}function Aa(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:o,l:i}=Ea(e[s],t);[n[s],r[s]]=[o,i]}return[n,r]}const Ta=(e,t,n)=>e<<n|t>>>32-n,va=(e,t,n)=>t<<n|e>>>32-n,xa=(e,t,n)=>t<<n-32|e>>>64-n,Ia=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ca=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Zt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,_a=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function Yt(e){for(let t=0;t<e.length;t++)e[t]=_a(e[t])}const Na=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ba(e){nt(e);let t="";for(let n=0;n<e.length;n++)t+=Na[e[n]];return t}function Jn(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Xn(e){return typeof e=="string"&&(e=Jn(e)),nt(e),e}let Oa=class{clone(){return this._cloneInto()}};function ka(e){const t=r=>e().update(Xn(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const Qn=[],er=[],tr=[],Ra=BigInt(0),xe=BigInt(1),Pa=BigInt(2),Fa=BigInt(7),Da=BigInt(256),Ua=BigInt(113);for(let e=0,t=xe,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Qn.push(2*(5*r+n)),er.push((e+1)*(e+2)/2%64);let s=Ra;for(let o=0;o<7;o++)t=(t<<xe^(t>>Fa)*Ua)%Da,t&Pa&&(s^=xe<<(xe<<BigInt(o))-xe);tr.push(s)}const[La,Ha]=Aa(tr,!0),Jt=(e,t,n)=>n>32?xa(e,t,n):Ta(e,t,n),Xt=(e,t,n)=>n>32?Ia(e,t,n):va(e,t,n);function $a(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,l=(i+2)%10,u=n[l],h=n[l+1],d=Jt(u,h,1)^n[c],y=Xt(u,h,1)^n[c+1];for(let g=0;g<50;g+=10)e[i+g]^=d,e[i+g+1]^=y}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=er[i],l=Jt(s,o,c),u=Xt(s,o,c),h=Qn[i];s=e[h],o=e[h+1],e[h]=l,e[h+1]=u}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=La[r],e[1]^=Ha[r]}n.fill(0)}let ja=class nr extends Oa{constructor(t,n,r,s=!1,o=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Gt(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Ca(this.state)}keccak(){Zt||Yt(this.state32),$a(this.state32,this.rounds),Zt||Yt(this.state32),this.posOut=0,this.pos=0}update(t){Wt(this);const{blockLen:n,state:r}=this;t=Xn(t);const s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let c=0;c<i;c++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,n&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Wt(this,!1),nt(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Gt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(ba(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new nr(n,r,s,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}};const za=(e,t,n)=>ka(()=>new ja(t,e,n)),Va=za(1,136,256/8);function rr(e){return`0x${Ba(Va(Jn(e)))}`}const Ma=e=>{if(!U.isString(e))return;const t=/(\d+)$/,n=e.match(t);if(n)return n[1]},sr=(e,t=!1)=>{if(!U.isString(e))return"";const n=t?e.replace(/[^0-9a-z ]/gi,""):e,s=U.upperCase(n).split(" "),o=Ma(n),i=s.map(c=>c[0]);return o&&o.length>1&&o.length<n.length?[i[0],o.substring(0,2)].join(""):s.length===1?s[0].substring(0,2):[i[0],i[i.length-1]].join("")},{toBigInt:qa}=w.num,Qt=e=>{const t=e.replace("#","");if(!/^[0-9A-F]{6}$/i.test(t))throw new Error(`Invalid color ${e}`);return`#${t}`},Re=(e,t)=>{const n=Qt(t.background),r=Qt(t.color??"#ffffff"),s=sr(e,!0),o=`<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48">
2
2
  <rect width="48" height="48" fill="${n}" />
3
3
  <text x="50%" y="54%" dominant-baseline="middle" text-anchor="middle" font-size="16" font-family="Barlow, Helvetica, Arial, sans-serif" fill="${r}">${s}</text>
4
- </svg>`;return`data:image/svg+xml;base64,${btoa(o)}`},en=["02BBA8","29C5FF","0078A4","FFBF3D","FFA85C","FF875B","FF675C","FF5C72"],sr=e=>{const t=nr(e).slice(-2),n=parseInt(t,16)%en.length;return en[n]},or=e=>{try{return w.num.toHex(Va(w.num.hexToDecimalString(e)))}catch{}return""},Ma=({accountName:e,networkId:t,accountAddress:n,backgroundColor:r})=>{const s=or(n),o=`${t}::${s}`,i=r||sr(o);return Re(e,{background:i})},ar=e=>{const t=w.encode.removeHexPrefix(w.encode.sanitizeHex(w.num.toHex(e))),n=Ne.hex.decode(t);return Ne.base58.encode(n)},qa=e=>e.map(ar),ir=e=>{const t=Ne.base58.decode(e);return w.encode.sanitizeHex(Ne.hex.encode(t))},Ga=e=>e.map(ir);function Wa(e,t){const n=e.getTime(),r=t.getTime(),s=Math.abs(n-r);return Math.floor(s/(1e3*60*60*24))}const Ka=e=>(e||"false")==="true",Za=async(e,t)=>{try{return await e.getClassHashAt(t),!0}catch{return!1}};function Ya(e){return!D.isNil(e)}const Ja=e=>{const t=/^(0|0x([a-f0-9A-F]+)?)$/;return!!(e===""||t.test(e))},K=e=>!isNaN(parseFloat(e))&&isFinite(Number(e)),Xa=(e,t=16)=>{const n=new RegExp(`^[0-9]*.?[0-9]{0,${t}}$`);return e===""?!0:K(e)?!!n.test(e):!1},rt={CURRENCY:{minDecimalPlaces:2,maxDecimalPlaces:10,minDecimalSignificantDigits:2,decimalPlacesWhenZero:2,allowLeadingZerosInDecimalPart:!0},TOKEN:{minDecimalPlaces:4,maxDecimalPlaces:16,minDecimalSignificantDigits:2,decimalPlacesWhenZero:1,allowLeadingZerosInDecimalPart:!0}},cr=(e,t)=>Nt(e,{...rt.CURRENCY,...t||{}}),lr=(e,t)=>Nt(e,{...rt.TOKEN,...t||{}}),Nt=(e,{minDecimalPlaces:t,maxDecimalPlaces:n,minDecimalSignificantDigits:r,decimalPlacesWhenZero:s,allowLeadingZerosInDecimalPart:o}=rt.CURRENCY)=>{if(!K(e))return null;const i=new a.BigNumber(typeof e=="bigint"?e.toString():e);let c;const l=`0.${"".padStart(s-1,"0")}1`;if(i.lt(new a.BigNumber(l))&&!o)c=`0.${"".padStart(s,"0")}`;else if(i.gte(1))c=i.toFormat(t);else{const g=i.toFormat(n).split(".")[1].match(/^0+/),A=o&&g&&g.length?g[0].length:0,m=Math.max(A+r,t);c=i.toFormat(m)}let u=c.replace(/0+$/,"");const h=1+c.indexOf(".")+s;return u.length<h&&(u=c.substring(0,h)),u},ur=(e,t=18)=>{const n=e.replace(",",".");return!e||!K(n)?0n:a.parseUnits(n,Number(t)).value};function ye(e){return w.uint256.bnToUint256(e)}const Qa=(e,t)=>`${e} ${t}${e===1?"":"s"}`,ei=e=>new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{var s;return r.result?t((s=r.result)==null?void 0:s.toString()):n(new Error("Could not read file"))},r.onerror=n,r.onabort=n.bind(null,new Error("User aborted")),r.readAsText(e)});function ti(e){try{return D.upperFirst(D.lowerCase(e))}catch{return e}}const ni=(e,t)=>{const n=new URLSearchParams(t),r=n.size?`?${n}`:"";return a.urlJoin(...a.ensureArray(e),r)};function ri(e){return(...t)=>{e(...t)}}class si extends Error{constructor(t,n){super(`${t}::${n}`),this.name=t,this.code=n,this.name=t}}class tn extends si{constructor(t){super("BackendPaginationError",t)}}const nn=32;class oi{constructor(t,n,r){this.apiBase=t,this.headers=n,this.imageOptimizationUrl=r,this.httpService=new Xe(this.headers,"json")}async getNfts(t,n,r,s=1){const o=this.normalizeAddress(r),i=a.urlJoin(this.apiBase,"pandora",t,n),c=this.pageToPageIndex(s),u=`${a.urlJoin(i,"profile",o,"nfts")}?page=${c}&size=${nn}`,h=await this.httpService.get(u),d=h.content.map(y=>this.mapItem(y,r));return{totalPages:h.totalPages,page:h.number+1,count:d.length,nfts:d}}async getCollection(t,n,r){const s=this.normalizeAddress(r),o=a.urlJoin(this.apiBase,"pandora",t,n),i=a.urlJoin(o,"collection",s),c=`${o}/collection/${s}`,[l,u]=await Promise.all([this.httpService.get(i),this.httpService.get(c)]),h=dt(l),d=u.content.map(y=>this.mapItem(y));return{...h,nfts:{totalPages:u.totalPages,page:u.number,count:d.length,data:d}}}async getNft(t,n,r,s){const o=this.normalizeAddress(r),i=a.urlJoin(this.apiBase,"pandora",t,n),c=a.urlJoin(i,"nft",o,s),l=await this.httpService.get(c);return this.mapItem(l)}async getProfileCollections(t,n,r,s=1,o=!1){const i=this.pageToPageIndex(s),c=this.normalizeAddress(r),l=a.urlJoin(this.apiBase,"pandora",t,n),u=a.urlJoin(l,"profile",c,"collections",`?page=${i}&size=${nn}`),h=await this.httpService.get(u),d=[];for(const y of h.content)if(o){const g=await this.getCollectionMetrics(t,n,y.contractAddress);d.push(dt(y,g))}else d.push(dt(y));return{totalPages:h.totalPages,page:h.number+1,count:d.length,collections:d}}async getCollectionMetrics(t,n,r){const s=this.normalizeAddress(r),o=a.urlJoin(this.apiBase,"pandora",t,n),i=a.urlJoin(o,"collection",s,"metrics");return this.httpService.get(i)}normalizeAddress(t){return a.addressSchemaArgentBackend.parse(t)}pageToPageIndex(t){if(!Number.isInteger(t))throw new tn("notANumber");const n=t-1;if(n<0)throw new tn("tooLow");return n}optimizeImage(t,n,r){if(!t)return;const s=new URLSearchParams({url:t,w:(n??400).toString(),h:(r??400).toString()});return`${this.imageOptimizationUrl}?${s.toString()}`}mapItem(t,n){var s;const r=t.name??t.tokenId;return{token_id:t.tokenId,contract_address:t.contractAddress,name:r,spec:"spec"in t?ai(t.spec):void 0,description:"",best_bid_order:{payment_amount:"bestListPrice"in t?BigInt(t.bestListPrice):void 0},properties:"properties"in t&&t.properties.map(o=>({key:o.key,value:o.value}))||[],image_uri:this.optimizeImage(t.imageUrls.preview)??Re(r,{background:"#15192A",color:"#ffffff"}),image_url_copy:this.optimizeImage(t.imageUrls.full)??Re(r,{background:"#15192A",color:"#ffffff"}),owner:{account_address:((s=t.owner)==null?void 0:s.address)||n},contract_name:_t(t.contractAddress)}}}function ai(e){switch(e){case"erc721":case"starknetErc721":return"ERC721";case"erc1155":case"starknetErc1155":return"ERC1155"}}function dt(e,t){return{contractAddress:a.addressSchema.parse(e.contractAddress),name:e.name||_t(e.contractAddress),description:e.description??"",imageUri:e.imageUrls.preview??Re(e.name||e.contractAddress.replace("0x",""),{background:"#15192A",color:"#ffffff"}),...t&&{owners:{total:t.numberOfItems,unique:t.uniqueOwners},...t.floorPrice&&{floorPrice:BigInt(t.floorPrice)}}}}const dr=async(e,t,n,r,s=1)=>{const o=await e.getNfts(t,n,r,s);if(s<o.totalPages){const i=await dr(e,t,n,r,o.page+1);return{...o,nfts:o.nfts.concat(i.nfts)}}return o},ii=(e,t,n,r,s)=>{const{data:o,...i}=_e(r&&[r,"nfts"],()=>r&&dr(e,t,n,r),{refreshInterval:3e5,...s});return{nfts:o==null?void 0:o.nfts,...i}},ci=(e,t,n,r,s)=>{const{data:o,...i}=_e(r&&[`${r}`,"nfts-collection"],()=>r&&e.getCollection(t,n,r),{refreshInterval:6e4,...s});return{collection:o,...i}},li=(e,t,n,r,s,o)=>{const{data:i,...c}=_e(s&&r&&[`${r}:${s}`,"nft"],()=>s&&r?e.getNft(t,n,r,s):void 0,{refreshInterval:6e4,revalidateOnFocus:!1,revalidateOnMount:!1,...o});return{nft:i,...c}},ui=({image_uri:e,image_url_copy:t})=>{if(e&&t){if(!t.startsWith("ipfs://"))return t;if(!e.startsWith("ipfs://"))return e}return t||e},di=(e,t)=>e.token_id===t.token_id&&a.isEqualAddress(e.contract_address,t.contract_address);function rn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function hi(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function hr(e,...t){if(!hi(e))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Ze(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function fr(e,t){hr(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Me=BigInt(2**32-1),sn=BigInt(32);function fi(e,t=!1){return t?{h:Number(e&Me),l:Number(e>>sn&Me)}:{h:Number(e>>sn&Me)|0,l:Number(e&Me)|0}}function mi(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:o,l:i}=fi(e[s],t);[n[s],r[s]]=[o,i]}return[n,r]}const pi=(e,t,n)=>e<<n|t>>>32-n,gi=(e,t,n)=>t<<n|e>>>32-n,Si=(e,t,n)=>t<<n-32|e>>>64-n,wi=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const yi=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));function bi(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}const ht=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),X=(e,t)=>e<<32-t|e>>>t,Ei=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Ei)throw new Error("Non little-endian hardware is not supported");function mr(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Bt(e){if(typeof e=="string"&&(e=mr(e)),!bi(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}let pr=class{clone(){return this._cloneInto()}};function gr(e){const t=r=>e().update(Bt(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const[Sr,wr,yr]=[[],[],[]],Ai=BigInt(0),Ie=BigInt(1),Ti=BigInt(2),vi=BigInt(7),xi=BigInt(256),Ii=BigInt(113);for(let e=0,t=Ie,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Sr.push(2*(5*r+n)),wr.push((e+1)*(e+2)/2%64);let s=Ai;for(let o=0;o<7;o++)t=(t<<Ie^(t>>vi)*Ii)%xi,t&Ti&&(s^=Ie<<(Ie<<BigInt(o))-Ie);yr.push(s)}const[Ci,_i]=mi(yr,!0),on=(e,t,n)=>n>32?Si(e,t,n):pi(e,t,n),an=(e,t,n)=>n>32?wi(e,t,n):gi(e,t,n);function Ni(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,l=(i+2)%10,u=n[l],h=n[l+1],d=on(u,h,1)^n[c],y=an(u,h,1)^n[c+1];for(let g=0;g<50;g+=10)e[i+g]^=d,e[i+g+1]^=y}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=wr[i],l=on(s,o,c),u=an(s,o,c),h=Sr[i];s=e[h],o=e[h+1],e[h]=l,e[h+1]=u}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=Ci[r],e[1]^=_i[r]}n.fill(0)}class Ot extends pr{constructor(t,n,r,s=!1,o=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,rn(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=yi(this.state)}keccak(){Ni(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){Ze(this);const{blockLen:n,state:r}=this;t=Bt(t);const s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let c=0;c<i;c++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,n&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Ze(this,!1),hr(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return rn(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(fr(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new Ot(n,r,s,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}}const Bi=(e,t,n)=>gr(()=>new Ot(t,e,n)),Oi=Bi(1,136,256/8);function ki(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),c=Number(n&o),l=r?4:0,u=r?0:4;e.setUint32(t+l,i,r),e.setUint32(t+u,c,r)}class Ri extends pr{constructor(t,n,r,s){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ht(this.buffer)}update(t){Ze(this);const{view:n,buffer:r,blockLen:s}=this;t=Bt(t);const o=t.length;for(let i=0;i<o;){const c=Math.min(s-this.pos,o-i);if(c===s){const l=ht(t);for(;s<=o-i;i+=s)this.process(l,i);continue}r.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ze(this),fr(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:o}=this;let{pos:i}=this;n[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(r,0),i=0);for(let d=i;d<s;d++)n[d]=0;ki(r,s-8,BigInt(this.length*8),o),this.process(r,0);const c=ht(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=l/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<u;d++)c.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:s,finished:o,destroyed:i,pos:c}=this;return t.length=s,t.pos=c,t.finished=o,t.destroyed=i,s%n&&t.buffer.set(r),t}}const Pi=(e,t,n)=>e&t^~e&n,Fi=(e,t,n)=>e&t^e&n^t&n,Di=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),se=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),oe=new Uint32Array(64);class Ui extends Ri{constructor(){super(64,32,8,!1),this.A=se[0]|0,this.B=se[1]|0,this.C=se[2]|0,this.D=se[3]|0,this.E=se[4]|0,this.F=se[5]|0,this.G=se[6]|0,this.H=se[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:c,H:l}=this;return[t,n,r,s,o,i,c,l]}set(t,n,r,s,o,i,c,l){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=c|0,this.H=l|0}process(t,n){for(let d=0;d<16;d++,n+=4)oe[d]=t.getUint32(n,!1);for(let d=16;d<64;d++){const y=oe[d-15],g=oe[d-2],A=X(y,7)^X(y,18)^y>>>3,m=X(g,17)^X(g,19)^g>>>10;oe[d]=m+oe[d-7]+A+oe[d-16]|0}let{A:r,B:s,C:o,D:i,E:c,F:l,G:u,H:h}=this;for(let d=0;d<64;d++){const y=X(c,6)^X(c,11)^X(c,25),g=h+y+Pi(c,l,u)+Di[d]+oe[d]|0,m=(X(r,2)^X(r,13)^X(r,22))+Fi(r,s,o)|0;h=u,u=l,l=c,c=i+g|0,i=o,o=s,s=r,r=g+m|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,c=c+this.E|0,l=l+this.F|0,u=u+this.G|0,h=h+this.H|0,this.set(r,s,o,i,c,l,u,h)}roundClean(){oe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const br=gr(()=>new Ui);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Er=BigInt(0),st=BigInt(1),Hi=BigInt(2),ot=e=>e instanceof Uint8Array,Li=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function de(e){if(!ot(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=Li[e[n]];return t}function Ar(e){const t=e.toString(16);return t.length&1?`0${t}`:t}function kt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}function he(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(e.length%2)throw new Error("hex string is invalid: unpadded "+e.length);const t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++){const r=n*2,s=e.slice(r,r+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("invalid byte sequence");t[n]=o}return t}function Y(e){return kt(de(e))}function Rt(e){if(!ot(e))throw new Error("Uint8Array expected");return kt(de(Uint8Array.from(e).reverse()))}const Se=(e,t)=>he(e.toString(16).padStart(t*2,"0")),Tr=(e,t)=>Se(e,t).reverse(),$i=e=>he(Ar(e));function V(e,t,n){let r;if(typeof t=="string")try{r=he(t)}catch(o){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${o}`)}else if(ot(t))r=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(`${e} expected ${n} bytes, got ${s}`);return r}function Pe(...e){const t=new Uint8Array(e.reduce((r,s)=>r+s.length,0));let n=0;return e.forEach(r=>{if(!ot(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}function ji(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function zi(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function Vi(e){let t;for(t=0;e>Er;e>>=st,t+=1);return t}const Mi=(e,t)=>e>>BigInt(t)&st,qi=(e,t,n)=>e|(n?st:Er)<<BigInt(t),at=e=>(Hi<<BigInt(e-1))-st,ft=e=>new Uint8Array(e),cn=e=>Uint8Array.from(e);function vr(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=ft(e),s=ft(e),o=0;const i=()=>{r.fill(1),s.fill(0),o=0},c=(...d)=>n(s,r,...d),l=(d=ft())=>{s=c(cn([0]),d),r=c(),d.length!==0&&(s=c(cn([1]),d),r=c())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const y=[];for(;d<t;){r=c();const g=r.slice();y.push(g),d+=r.length}return Pe(...y)};return(d,y)=>{i(),l(d);let g;for(;!(g=y(u()));)l();return i(),g}}const Gi={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function Le(e,t,n={}){const r=(s,o,i)=>{const c=Gi[o];if(typeof c!="function")throw new Error(`Invalid validator "${o}", expected function`);const l=e[s];if(!(i&&l===void 0)&&!c(l,e))throw new Error(`Invalid param ${String(s)}=${l} (${typeof l}), expected ${o}`)};for(const[s,o]of Object.entries(t))r(s,o,!1);for(const[s,o]of Object.entries(n))r(s,o,!0);return e}const Wi=Object.freeze(Object.defineProperty({__proto__:null,bitGet:Mi,bitLen:Vi,bitMask:at,bitSet:qi,bytesToHex:de,bytesToNumberBE:Y,bytesToNumberLE:Rt,concatBytes:Pe,createHmacDrbg:vr,ensureBytes:V,equalBytes:ji,hexToBytes:he,hexToNumber:kt,numberToBytesBE:Se,numberToBytesLE:Tr,numberToHexUnpadded:Ar,numberToVarBytesBE:$i,utf8ToBytes:zi,validateObject:Le},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const U=BigInt(0),F=BigInt(1),ie=BigInt(2),Ki=BigInt(3),wt=BigInt(4),ln=BigInt(5),un=BigInt(8);BigInt(9);BigInt(16);function M(e,t){const n=e%t;return n>=U?n:t+n}function Zi(e,t,n){if(n<=U||t<U)throw new Error("Expected power/modulo > 0");if(n===F)return U;let r=F;for(;t>U;)t&F&&(r=r*e%n),e=e*e%n,t>>=F;return r}function yt(e,t){if(e===U||t<=U)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=M(e,t),r=t,s=U,o=F;for(;n!==U;){const c=r/n,l=r%n,u=s-o*c;r=n,n=l,s=o,o=u}if(r!==F)throw new Error("invert: does not exist");return M(s,t)}function Yi(e){const t=(e-F)/ie;let n,r,s;for(n=e-F,r=0;n%ie===U;n/=ie,r++);for(s=ie;s<e&&Zi(s,t,e)!==e-F;s++);if(r===1){const i=(e+F)/wt;return function(l,u){const h=l.pow(u,i);if(!l.eql(l.sqr(h),u))throw new Error("Cannot find square root");return h}}const o=(n+F)/ie;return function(c,l){if(c.pow(l,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let u=r,h=c.pow(c.mul(c.ONE,s),n),d=c.pow(l,o),y=c.pow(l,n);for(;!c.eql(y,c.ONE);){if(c.eql(y,c.ZERO))return c.ZERO;let g=1;for(let m=c.sqr(y);g<u&&!c.eql(m,c.ONE);g++)m=c.sqr(m);const A=c.pow(h,F<<BigInt(u-g-1));h=c.sqr(A),d=c.mul(d,A),y=c.mul(y,h),u=g}return d}}function Ji(e){if(e%wt===Ki){const t=(e+F)/wt;return function(r,s){const o=r.pow(s,t);if(!r.eql(r.sqr(o),s))throw new Error("Cannot find square root");return o}}if(e%un===ln){const t=(e-ln)/un;return function(r,s){const o=r.mul(s,ie),i=r.pow(o,t),c=r.mul(s,i),l=r.mul(r.mul(c,ie),i),u=r.mul(c,r.sub(l,r.ONE));if(!r.eql(r.sqr(u),s))throw new Error("Cannot find square root");return u}}return Yi(e)}const Xi=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Pt(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=Xi.reduce((r,s)=>(r[s]="function",r),t);return Le(e,n)}function xr(e,t,n){if(n<U)throw new Error("Expected power > 0");if(n===U)return e.ONE;if(n===F)return t;let r=e.ONE,s=t;for(;n>U;)n&F&&(r=e.mul(r,s)),s=e.sqr(s),n>>=F;return r}function Qi(e,t){const n=new Array(t.length),r=t.reduce((o,i,c)=>e.is0(i)?o:(n[c]=o,e.mul(o,i)),e.ONE),s=e.inv(r);return t.reduceRight((o,i,c)=>e.is0(i)?o:(n[c]=e.mul(o,n[c]),e.mul(o,i)),s),n}function Ft(e,t){const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Dt(e,t,n=!1,r={}){if(e<=U)throw new Error(`Expected Fp ORDER > 0, got ${e}`);const{nBitLength:s,nByteLength:o}=Ft(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=Ji(e),c=Object.freeze({ORDER:e,BITS:s,BYTES:o,MASK:at(s),ZERO:U,ONE:F,create:l=>M(l,e),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return U<=l&&l<e},is0:l=>l===U,isOdd:l=>(l&F)===F,neg:l=>M(-l,e),eql:(l,u)=>l===u,sqr:l=>M(l*l,e),add:(l,u)=>M(l+u,e),sub:(l,u)=>M(l-u,e),mul:(l,u)=>M(l*u,e),pow:(l,u)=>xr(c,l,u),div:(l,u)=>M(l*yt(u,e),e),sqrN:l=>l*l,addN:(l,u)=>l+u,subN:(l,u)=>l-u,mulN:(l,u)=>l*u,inv:l=>yt(l,e),sqrt:r.sqrt||(l=>i(c,l)),invertBatch:l=>Qi(c,l),cmov:(l,u,h)=>h?u:l,toBytes:l=>n?Tr(l,o):Se(l,o),fromBytes:l=>{if(l.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${l.length}`);return n?Rt(l):Y(l)}});return Object.freeze(c)}function ec(e,t,n=!1){e=V("privateHash",e);const r=e.length,s=Ft(t).nByteLength+8;if(s<24||r<s||r>1024)throw new Error(`hashToPrivateScalar: expected ${s}-1024 bytes of input, got ${r}`);const o=n?Rt(e):Y(e);return M(o,t-F)+F}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function tc(e){const{Fp:t}=e;Pt(t);for(const l of["t","roundsFull","roundsPartial"])if(typeof e[l]!="number"||!Number.isSafeInteger(e[l]))throw new Error(`Poseidon: invalid param ${l}=${e[l]} (${typeof e[l]})`);if(e.reversePartialPowIdx!==void 0&&typeof e.reversePartialPowIdx!="boolean")throw new Error(`Poseidon: invalid param reversePartialPowIdx=${e.reversePartialPowIdx}`);let n=e.sboxPower;if(n===void 0&&(n=5),typeof n!="number"||!Number.isSafeInteger(n))throw new Error(`Poseidon wrong sboxPower=${n}`);const r=BigInt(n);let s=l=>xr(t,l,r);if(n===3?s=l=>t.mul(t.sqrN(l),l):n===5&&(s=l=>t.mul(t.sqrN(t.sqrN(l)),l)),e.roundsFull%2!==0)throw new Error(`Poseidon roundsFull is not even: ${e.roundsFull}`);const o=e.roundsFull+e.roundsPartial;if(!Array.isArray(e.roundConstants)||e.roundConstants.length!==o)throw new Error("Poseidon: wrong round constants");const i=e.roundConstants.map(l=>{if(!Array.isArray(l)||l.length!==e.t)throw new Error(`Poseidon wrong round constants: ${l}`);return l.map(u=>{if(typeof u!="bigint"||!t.isValid(u))throw new Error(`Poseidon wrong round constant=${u}`);return t.create(u)})});if(!Array.isArray(e.mds)||e.mds.length!==e.t)throw new Error("Poseidon: wrong MDS matrix");const c=e.mds.map(l=>{if(!Array.isArray(l)||l.length!==e.t)throw new Error(`Poseidon MDS matrix row: ${l}`);return l.map(u=>{if(typeof u!="bigint")throw new Error(`Poseidon MDS matrix value=${u}`);return t.create(u)})});return Object.freeze({...e,rounds:o,sboxFn:s,roundConstants:i,mds:c})}function nc(e){const{t,Fp:n,rounds:r,sboxFn:s,reversePartialPowIdx:o}=tc(e),i=Math.floor(e.roundsFull/2),c=o?t-1:0,l=(h,d,y)=>(h=h.map((g,A)=>n.add(g,e.roundConstants[y][A])),d?h=h.map(g=>s(g)):h[c]=s(h[c]),h=e.mds.map(g=>g.reduce((A,m,S)=>n.add(A,n.mulN(m,h[S])),n.ZERO)),h),u=function(d){if(!Array.isArray(d)||d.length!==t)throw new Error(`Poseidon: wrong values (expected array of bigints with length ${t})`);d=d.map(g=>{if(typeof g!="bigint")throw new Error(`Poseidon: wrong value=${g} (${typeof g})`);return n.create(g)});let y=0;for(let g=0;g<i;g++)d=l(d,!0,y++);for(let g=0;g<e.roundsPartial;g++)d=l(d,!1,y++);for(let g=0;g<i;g++)d=l(d,!0,y++);if(y!==r)throw new Error(`Poseidon: wrong number of rounds: last round=${y}, total=${r}`);return d};return u.roundConstants=e.roundConstants,u}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const rc=BigInt(0),mt=BigInt(1);function sc(e,t){const n=(s,o)=>{const i=o.negate();return s?i:o},r=s=>{const o=Math.ceil(t/s)+1,i=2**(s-1);return{windows:o,windowSize:i}};return{constTimeNegate:n,unsafeLadder(s,o){let i=e.ZERO,c=s;for(;o>rc;)o&mt&&(i=i.add(c)),c=c.double(),o>>=mt;return i},precomputeWindow(s,o){const{windows:i,windowSize:c}=r(o),l=[];let u=s,h=u;for(let d=0;d<i;d++){h=u,l.push(h);for(let y=1;y<c;y++)h=h.add(u),l.push(h);u=h.double()}return l},wNAF(s,o,i){const{windows:c,windowSize:l}=r(s);let u=e.ZERO,h=e.BASE;const d=BigInt(2**s-1),y=2**s,g=BigInt(s);for(let A=0;A<c;A++){const m=A*l;let S=Number(i&d);i>>=g,S>l&&(S-=y,i+=mt);const E=m,T=m+Math.abs(S)-1,x=A%2!==0,B=S<0;S===0?h=h.add(n(x,o[E])):u=u.add(n(B,o[T]))}return{p:u,f:h}},wNAFCached(s,o,i,c){const l=s._WINDOW_SIZE||1;let u=o.get(s);return u||(u=this.precomputeWindow(s,l),l!==1&&o.set(s,c(u))),this.wNAF(l,u,i)}}}function Ir(e){return Pt(e.Fp),Le(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ft(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function oc(e){const t=Ir(e);Le(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:s}=t;if(n){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:ac,hexToBytes:ic}=Wi,ce={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(e){const{Err:t}=ce;if(e.length<2||e[0]!==2)throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:ac(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=ce,n=typeof e=="string"?ic(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:s,l:o}=ce._parseInt(n.subarray(2)),{d:i,l:c}=ce._parseInt(o);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(e){const t=u=>Number.parseInt(u[0],16)&8?"00"+u:u,n=u=>{const h=u.toString(16);return h.length&1?`0${h}`:h},r=t(n(e.s)),s=t(n(e.r)),o=r.length/2,i=s.length/2,c=n(o),l=n(i);return`30${n(i+o+4)}02${l}${s}02${c}${r}`}},Q=BigInt(0),W=BigInt(1);BigInt(2);const dn=BigInt(3);BigInt(4);function cc(e){const t=oc(e),{Fp:n}=t,r=t.toBytes||((A,m,S)=>{const E=m.toAffine();return Pe(Uint8Array.from([4]),n.toBytes(E.x),n.toBytes(E.y))}),s=t.fromBytes||(A=>{const m=A.subarray(1),S=n.fromBytes(m.subarray(0,n.BYTES)),E=n.fromBytes(m.subarray(n.BYTES,2*n.BYTES));return{x:S,y:E}});function o(A){const{a:m,b:S}=t,E=n.sqr(A),T=n.mul(E,A);return n.add(n.add(T,n.mul(A,m)),S)}if(!n.eql(n.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function i(A){return typeof A=="bigint"&&Q<A&&A<t.n}function c(A){if(!i(A))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(A){const{allowedPrivateKeyLengths:m,nByteLength:S,wrapPrivateKey:E,n:T}=t;if(m&&typeof A!="bigint"){if(A instanceof Uint8Array&&(A=de(A)),typeof A!="string"||!m.includes(A.length))throw new Error("Invalid key");A=A.padStart(S*2,"0")}let x;try{x=typeof A=="bigint"?A:Y(V("private key",A,S))}catch{throw new Error(`private key must be ${S} bytes, hex or bigint, not ${typeof A}`)}return E&&(x=M(x,T)),c(x),x}const u=new Map;function h(A){if(!(A instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(m,S,E){if(this.px=m,this.py=S,this.pz=E,m==null||!n.isValid(m))throw new Error("x required");if(S==null||!n.isValid(S))throw new Error("y required");if(E==null||!n.isValid(E))throw new Error("z required")}static fromAffine(m){const{x:S,y:E}=m||{};if(!m||!n.isValid(S)||!n.isValid(E))throw new Error("invalid affine point");if(m instanceof d)throw new Error("projective point not allowed");const T=x=>n.eql(x,n.ZERO);return T(S)&&T(E)?d.ZERO:new d(S,E,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){const S=n.invertBatch(m.map(E=>E.pz));return m.map((E,T)=>E.toAffine(S[T])).map(d.fromAffine)}static fromHex(m){const S=d.fromAffine(s(V("pointHex",m)));return S.assertValidity(),S}static fromPrivateKey(m){return d.BASE.multiply(l(m))}_setWindowSize(m){this._WINDOW_SIZE=m,u.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:m,y:S}=this.toAffine();if(!n.isValid(m)||!n.isValid(S))throw new Error("bad point: x or y not FE");const E=n.sqr(S),T=o(m);if(!n.eql(E,T))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:m}=this.toAffine();if(n.isOdd)return!n.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){h(m);const{px:S,py:E,pz:T}=this,{px:x,py:B,pz:N}=m,v=n.eql(n.mul(S,N),n.mul(x,T)),I=n.eql(n.mul(E,N),n.mul(B,T));return v&&I}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:m,b:S}=t,E=n.mul(S,dn),{px:T,py:x,pz:B}=this;let N=n.ZERO,v=n.ZERO,I=n.ZERO,_=n.mul(T,T),q=n.mul(x,x),P=n.mul(B,B),O=n.mul(T,x);return O=n.add(O,O),I=n.mul(T,B),I=n.add(I,I),N=n.mul(m,I),v=n.mul(E,P),v=n.add(N,v),N=n.sub(q,v),v=n.add(q,v),v=n.mul(N,v),N=n.mul(O,N),I=n.mul(E,I),P=n.mul(m,P),O=n.sub(_,P),O=n.mul(m,O),O=n.add(O,I),I=n.add(_,_),_=n.add(I,_),_=n.add(_,P),_=n.mul(_,O),v=n.add(v,_),P=n.mul(x,B),P=n.add(P,P),_=n.mul(P,O),N=n.sub(N,_),I=n.mul(P,q),I=n.add(I,I),I=n.add(I,I),new d(N,v,I)}add(m){h(m);const{px:S,py:E,pz:T}=this,{px:x,py:B,pz:N}=m;let v=n.ZERO,I=n.ZERO,_=n.ZERO;const q=t.a,P=n.mul(t.b,dn);let O=n.mul(S,x),$=n.mul(E,B),j=n.mul(T,N),ee=n.add(S,E),p=n.add(x,B);ee=n.mul(ee,p),p=n.add(O,$),ee=n.sub(ee,p),p=n.add(S,T);let b=n.add(x,N);return p=n.mul(p,b),b=n.add(O,j),p=n.sub(p,b),b=n.add(E,T),v=n.add(B,N),b=n.mul(b,v),v=n.add($,j),b=n.sub(b,v),_=n.mul(q,p),v=n.mul(P,j),_=n.add(v,_),v=n.sub($,_),_=n.add($,_),I=n.mul(v,_),$=n.add(O,O),$=n.add($,O),j=n.mul(q,j),p=n.mul(P,p),$=n.add($,j),j=n.sub(O,j),j=n.mul(q,j),p=n.add(p,j),O=n.mul($,p),I=n.add(I,O),O=n.mul(b,p),v=n.mul(ee,v),v=n.sub(v,O),O=n.mul(ee,$),_=n.mul(b,_),_=n.add(_,O),new d(v,I,_)}subtract(m){return this.add(m.negate())}is0(){return this.equals(d.ZERO)}wNAF(m){return g.wNAFCached(this,u,m,S=>{const E=n.invertBatch(S.map(T=>T.pz));return S.map((T,x)=>T.toAffine(E[x])).map(d.fromAffine)})}multiplyUnsafe(m){const S=d.ZERO;if(m===Q)return S;if(c(m),m===W)return this;const{endo:E}=t;if(!E)return g.unsafeLadder(this,m);let{k1neg:T,k1:x,k2neg:B,k2:N}=E.splitScalar(m),v=S,I=S,_=this;for(;x>Q||N>Q;)x&W&&(v=v.add(_)),N&W&&(I=I.add(_)),_=_.double(),x>>=W,N>>=W;return T&&(v=v.negate()),B&&(I=I.negate()),I=new d(n.mul(I.px,E.beta),I.py,I.pz),v.add(I)}multiply(m){c(m);let S=m,E,T;const{endo:x}=t;if(x){const{k1neg:B,k1:N,k2neg:v,k2:I}=x.splitScalar(S);let{p:_,f:q}=this.wNAF(N),{p:P,f:O}=this.wNAF(I);_=g.constTimeNegate(B,_),P=g.constTimeNegate(v,P),P=new d(n.mul(P.px,x.beta),P.py,P.pz),E=_.add(P),T=q.add(O)}else{const{p:B,f:N}=this.wNAF(S);E=B,T=N}return d.normalizeZ([E,T])[0]}multiplyAndAddUnsafe(m,S,E){const T=d.BASE,x=(N,v)=>v===Q||v===W||!N.equals(T)?N.multiplyUnsafe(v):N.multiply(v),B=x(this,S).add(x(m,E));return B.is0()?void 0:B}toAffine(m){const{px:S,py:E,pz:T}=this,x=this.is0();m==null&&(m=x?n.ONE:n.inv(T));const B=n.mul(S,m),N=n.mul(E,m),v=n.mul(T,m);if(x)return{x:n.ZERO,y:n.ZERO};if(!n.eql(v,n.ONE))throw new Error("invZ was invalid");return{x:B,y:N}}isTorsionFree(){const{h:m,isTorsionFree:S}=t;if(m===W)return!0;if(S)return S(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:m,clearCofactor:S}=t;return m===W?this:S?S(d,this):this.multiplyUnsafe(t.h)}toRawBytes(m=!0){return this.assertValidity(),r(d,this,m)}toHex(m=!0){return de(this.toRawBytes(m))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const y=t.nBitLength,g=sc(d,t.endo?Math.ceil(y/2):y);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:l,weierstrassEquation:o,isWithinCurveOrder:i}}function lc(e){const t=Ir(e);return Le(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function uc(e){const t=lc(e),{Fp:n,n:r}=t,s=n.BYTES+1,o=2*n.BYTES+1;function i(p){return Q<p&&p<n.ORDER}function c(p){return M(p,r)}function l(p){return yt(p,r)}const{ProjectivePoint:u,normPrivateKeyToScalar:h,weierstrassEquation:d,isWithinCurveOrder:y}=cc({...t,toBytes(p,b,C){const R=b.toAffine(),k=n.toBytes(R.x),H=Pe;return C?H(Uint8Array.from([b.hasEvenY()?2:3]),k):H(Uint8Array.from([4]),k,n.toBytes(R.y))},fromBytes(p){const b=p.length,C=p[0],R=p.subarray(1);if(b===s&&(C===2||C===3)){const k=Y(R);if(!i(k))throw new Error("Point is not on curve");const H=d(k);let G=n.sqrt(H);const z=(G&W)===W;return(C&1)===1!==z&&(G=n.neg(G)),{x:k,y:G}}else if(b===o&&C===4){const k=n.fromBytes(R.subarray(0,n.BYTES)),H=n.fromBytes(R.subarray(n.BYTES,2*n.BYTES));return{x:k,y:H}}else throw new Error(`Point of length ${b} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),g=p=>de(Se(p,t.nByteLength));function A(p){const b=r>>W;return p>b}function m(p){return A(p)?c(-p):p}const S=(p,b,C)=>Y(p.slice(b,C));class E{constructor(b,C,R){this.r=b,this.s=C,this.recovery=R,this.assertValidity()}static fromCompact(b){const C=t.nByteLength;return b=V("compactSignature",b,C*2),new E(S(b,0,C),S(b,C,2*C))}static fromDER(b){const{r:C,s:R}=ce.toSig(V("DER",b));return new E(C,R)}assertValidity(){if(!y(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!y(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(b){return new E(this.r,this.s,b)}recoverPublicKey(b){const{r:C,s:R,recovery:k}=this,H=I(V("msgHash",b));if(k==null||![0,1,2,3].includes(k))throw new Error("recovery id invalid");const G=k===2||k===3?C+t.n:C;if(G>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const z=k&1?"03":"02",te=u.fromHex(z+g(G)),ne=l(G),fe=c(-H*ne),Te=c(R*ne),re=u.BASE.multiplyAndAddUnsafe(te,fe,Te);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return A(this.s)}normalizeS(){return this.hasHighS()?new E(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return he(this.toDERHex())}toDERHex(){return ce.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return he(this.toCompactHex())}toCompactHex(){return g(this.r)+g(this.s)}}const T={isValidPrivateKey(p){try{return h(p),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const p=t.randomBytes(n.BYTES+8),b=ec(p,r);return Se(b,t.nByteLength)},precompute(p=8,b=u.BASE){return b._setWindowSize(p),b.multiply(BigInt(3)),b}};function x(p,b=!0){return u.fromPrivateKey(p).toRawBytes(b)}function B(p){const b=p instanceof Uint8Array,C=typeof p=="string",R=(b||C)&&p.length;return b?R===s||R===o:C?R===2*s||R===2*o:p instanceof u}function N(p,b,C=!0){if(B(p))throw new Error("first arg must be private key");if(!B(b))throw new Error("second arg must be public key");return u.fromHex(b).multiply(h(p)).toRawBytes(C)}const v=t.bits2int||function(p){const b=Y(p),C=p.length*8-t.nBitLength;return C>0?b>>BigInt(C):b},I=t.bits2int_modN||function(p){return c(v(p))},_=at(t.nBitLength);function q(p){if(typeof p!="bigint")throw new Error("bigint expected");if(!(Q<=p&&p<_))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Se(p,t.nByteLength)}function P(p,b,C=O){if(["recovered","canonical"].some(ae=>ae in C))throw new Error("sign() legacy options not supported");const{hash:R,randomBytes:k}=t;let{lowS:H,prehash:G,extraEntropy:z}=C;H==null&&(H=!0),p=V("msgHash",p),G&&(p=V("prehashed msgHash",R(p)));const te=I(p),ne=h(b),fe=[q(ne),q(te)];if(z!=null){const ae=z===!0?k(n.BYTES):z;fe.push(V("extraEntropy",ae,n.BYTES))}const Te=Pe(...fe),re=te;function ct(ae){const me=v(ae);if(!y(me))return;const jt=l(me),pe=u.BASE.multiply(me).toAffine(),Z=c(pe.x);if(Z===Q)return;const ge=c(jt*c(re+Z*ne));if(ge===Q)return;let zt=(pe.x===Z?0:2)|Number(pe.y&W),Vt=ge;return H&&A(ge)&&(Vt=m(ge),zt^=1),new E(Z,Vt,zt)}return{seed:Te,k2sig:ct}}const O={lowS:t.lowS,prehash:!1},$={lowS:t.lowS,prehash:!1};function j(p,b,C=O){const{seed:R,k2sig:k}=P(p,b,C);return vr(t.hash.outputLen,t.nByteLength,t.hmac)(R,k)}u.BASE._setWindowSize(8);function ee(p,b,C,R=$){var pe;const k=p;if(b=V("msgHash",b),C=V("publicKey",C),"strict"in R)throw new Error("options.strict was renamed to lowS");const{lowS:H,prehash:G}=R;let z,te;try{if(typeof k=="string"||k instanceof Uint8Array)try{z=E.fromDER(k)}catch(Z){if(!(Z instanceof ce.Err))throw Z;z=E.fromCompact(k)}else if(typeof k=="object"&&typeof k.r=="bigint"&&typeof k.s=="bigint"){const{r:Z,s:ge}=k;z=new E(Z,ge)}else throw new Error("PARSE");te=u.fromHex(C)}catch(Z){if(Z.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(H&&z.hasHighS())return!1;G&&(b=t.hash(b));const{r:ne,s:fe}=z,Te=I(b),re=l(fe),ct=c(Te*re),ae=c(ne*re),me=(pe=u.BASE.multiplyAndAddUnsafe(te,ct,ae))==null?void 0:pe.toAffine();return me?c(me.x)===ne:!1}return{CURVE:t,getPublicKey:x,getSharedSecret:N,sign:j,verify:ee,ProjectivePoint:u,Signature:E,utils:T}}function bt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function dc(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function Cr(e,...t){if(!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new TypeError(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function hc(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");bt(e.outputLen),bt(e.blockLen)}function fc(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function mc(e,t){Cr(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const qe={number:bt,bool:dc,bytes:Cr,hash:hc,exists:fc,output:mc},pt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const pc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!pc)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function gc(e){if(typeof e!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function Sc(e){if(typeof e=="string"&&(e=gc(e)),!(e instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof e})`);return e}function wc(...e){if(!e.every(r=>r instanceof Uint8Array))throw new Error("Uint8Array list expected");if(e.length===1)return e[0];const t=e.reduce((r,s)=>r+s.length,0),n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const o=e[r];n.set(o,s),s+=o.length}return n}class yc{clone(){return this._cloneInto()}}function bc(e=32){if(pt&&typeof pt.getRandomValues=="function")return pt.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}class _r extends yc{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,qe.hash(t);const r=Sc(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(r.length>s?t.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(t){return qe.exists(this),this.iHash.update(t),this}digestInto(t){qe.exists(this),qe.bytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:s,destroyed:o,blockLen:i,outputLen:c}=this;return t=t,t.finished=s,t.destroyed=o,t.blockLen=i,t.outputLen=c,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Nr=(e,t,n)=>new _r(e,t).update(n).digest();Nr.create=(e,t)=>new _r(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ec(e){return{hash:e,hmac:(t,...n)=>Nr(e,t,wc(...n)),randomBytes:bc}}const hn=BigInt("3618502788666131213697322783095070105526743751716087489154079457884512865583"),Br=252;function fn(e){for(;e[0]===0;)e=e.subarray(1);const t=e.length*8-Br,n=Y(e);return t>0?n>>BigInt(t):n}function Or(e){return typeof e=="string"&&(e=vc(e),e.length&1&&(e="0"+e)),he(e)}const kr=uc({a:BigInt(1),b:BigInt("3141592653589793238462643383279502884197169399375105820974944592307816406665"),Fp:Dt(BigInt("0x800000000000011000000000000000000000000000000000000000000000001")),n:hn,nBitLength:Br,Gx:BigInt("874739451078007766457464989774322083649278607533249481151382481072868806602"),Gy:BigInt("152666792071518830868575557812948353041420400780739481342941381225525861407"),h:BigInt(1),lowS:!1,...Ec(br),bits2int:fn,bits2int_modN:e=>{const t=Y(e).toString(16);return t.length===63&&(e=Or(t+"0")),M(fn(e),hn)}});function Ac(e){return V("",typeof e=="string"?Or(e):e)}const{CURVE:$l,ProjectivePoint:Ce,Signature:jl,utils:zl}=kr;function Tc(e){return`0x${de(e.subarray(1)).replace(/^0+/gm,"")}`}function vc(e){return e.replace(/^0x/i,"")}const Fe=[new Ce(2089986280348253421170679821480865132823066470938446095505822317253594081284n,1713931329540660377023406109199410414810705867260802078187082345529207694986n,1n),new Ce(996781205833008774514500082376783249102396023663454813447423147977397232763n,1668503676786377725805489344771023921079126552019160156920634619255970485781n,1n),new Ce(2251563274489750535117886426533222435294046428347329203627021249169616184184n,1798716007562728905295480679789526322175868328062420237419143593021674992973n,1n),new Ce(2138414695194151160943305727036575959195309218611738193261179310511854807447n,113410276730064486255102093846540133784865286929052426931474106396135072156n,1n),new Ce(2379962749567351885752724891227938183011949129833673362440656643086021394946n,776496453633298175483985398648758586525933812536653089401905292063708816422n,1n)];function Rr(e,t){const n=[];let r=e;for(let s=0;s<248;s++)n.push(r),r=r.double();r=t;for(let s=0;s<4;s++)n.push(r),r=r.double();return n}const xc=Rr(Fe[1],Fe[2]),Ic=Rr(Fe[3],Fe[4]);function Cc(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"){if(!Number.isSafeInteger(e))throw new Error(`Invalid pedersenArg: ${e}`);t=BigInt(e)}else t=Y(Ac(e));if(!(0n<=t&&t<kr.CURVE.Fp.ORDER))throw new Error(`PedersenArg should be 0 <= value < CURVE.P: ${t}`);return t}function mn(e,t,n){let r=Cc(t);for(let s=0;s<252;s++){const o=n[s];if(o.equals(e))throw new Error("Same point");(r&1n)!==0n&&(e=e.add(o)),r>>=1n}return e}function _c(e,t){let n=Fe[0];return n=mn(n,e,xc),n=mn(n,t,Ic),Tc(n.toRawBytes(!0))}const Nc=at(250),Bc=e=>Y(Oi(e))&Nc;Dt(BigInt("14474011154664525231415395255581126252639794253786371766033694892385558855681"));const Oc=Dt(BigInt("3618502788666131213697322783095070105623107215331596699973092056135872020481"));function kc(e,t,n){const r=e.fromBytes(br(mr(`${t}${n}`)));return e.create(r)}const Rc=[[3,1,1],[1,-1,1],[1,1,-2]].map(e=>e.map(BigInt));function Pc(e,t){if(Pt(e.Fp),!Number.isSafeInteger(e.rate)||!Number.isSafeInteger(e.capacity))throw new Error(`Wrong poseidon opts: ${e}`);const n=e.rate+e.capacity,r=e.roundsFull+e.roundsPartial,s=[];for(let i=0;i<r;i++){const c=[];for(let l=0;l<n;l++)c.push(kc(e.Fp,"Hades",n*i+l));s.push(c)}const o=nc({...e,t:n,sboxPower:3,reversePartialPowIdx:!0,mds:t,roundConstants:s});return o.m=n,o.rate=e.rate,o.capacity=e.capacity,o}Pc({Fp:Oc,rate:2,capacity:1,roundsFull:8,roundsPartial:83},Rc);exports.RecoveryStatusEnum=void 0;(function(e){e.NOT_STARTED="NOT_STARTED",e.ONGOING="ONGOING",e.AWAITING_FUNDS="AWAITING_FUNDS",e.AWAITING_COMPLETION="AWAITING_COMPLETION",e.COMPLETED="COMPLETED",e.CANCELLED="CANCELLED",e.ERROR="ERROR"})(exports.RecoveryStatusEnum||(exports.RecoveryStatusEnum={}));const Pr=f.z.object({recoveryId:f.z.number()}),Fc=f.z.object({feeToken:a.addressSchema,signerSignature:f.z.object({type:f.z.literal("StarknetKey"),signer:f.z.object({publicKey:a.hexSchema,r:a.hexSchema,s:a.hexSchema})})}),Fr=f.z.nativeEnum(exports.RecoveryStatusEnum),Ut=f.z.object({recoveryId:f.z.number(),status:Fr,completionTime:f.z.array(f.z.number()).optional()}),Dr=f.z.object({activeRecovery:Ut.optional().or(f.z.null()).optional(),minFees:f.z.record(f.z.number()).optional()}),Ur=f.z.object({recovery:Ut.optional().or(f.z.null()).optional(),minFees:f.z.record(f.z.number()).optional()});exports.StartOnchainRecoveryErrorStatusEnum=void 0;(function(e){e.UNDEPLOYED_ACCOUNT="undeployedAccount",e.NOT_ENOUGH_TO_PAY_FEES="notEnoughToPayFees",e.RECOVERY_ALREADY_EXISTS="recoveryAlreadyExists"})(exports.StartOnchainRecoveryErrorStatusEnum||(exports.StartOnchainRecoveryErrorStatusEnum={}));const Hr=f.z.nativeEnum(exports.StartOnchainRecoveryErrorStatusEnum),Dc=f.z.object({status:Hr});class Uc{constructor(t,n){this.apiBase=t,this.httpService=n}async getRecovery(t,n){const r=a.urlJoin(this.apiBase,"accounts","starknet",t,"recovery",`${n}`),s=await this.httpService.get(r),o=Ur.safeParse(s);return o.error?null:o.data}async getActiveRecovery(t){const n=a.urlJoin(this.apiBase,"accounts","starknet",t,"recovery"),r=await this.httpService.get(n),s=Dr.safeParse(r);return s.error?null:s.data}async startRecovery(t,n,r,s){const{r:o,s:i}=w.ec.starkCurve.sign(_c(Bc(Ne.stringToBytes("utf8","starknet:recovery")),r),s),c={feeToken:n,signerSignature:{type:"StarknetKey",signer:{publicKey:r,r:w.encode.addHexPrefix(o.toString(16)),s:w.encode.addHexPrefix(i.toString(16))}}};return await this.httpService.post(`${this.apiBase}/accounts/starknet/${t}/recovery`,{body:JSON.stringify(c)},Pr)}async completeRecovery(t,n){const r=a.urlJoin(this.apiBase,"accounts","starknet",t,"recovery",`${n}`,"complete");return await this.httpService.post(r)}}async function Hc(){if("brave"in navigator)try{return await navigator.brave.isBrave()}catch{}return!1}let gt;function Lr(){return gt||(gt=new ts.UAParser(navigator.userAgent).getResult()),gt}function $e(e){return Lr().browser.name===e}function Lc(){return $e("Firefox")}function $c(){return $e("Chrome")}function jc(){return $e("Safari")}function zc(){return $e("Edge")}const Vc=f.z.string().refine(e=>ns.validateMnemonic(e,rs.wordlist),"Invalid seedphrase"),Ht=[{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",name:"Ether",symbol:"ETH",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/eth.png"},{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",name:"Ether",symbol:"ETH",decimals:18,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/eth.png"},{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",name:"Ether",symbol:"ETH",decimals:18,networkId:"localhost",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/eth.png"},{address:"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",name:"Starknet",symbol:"STRK",decimals:"18",networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/strk.png"},{address:"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",name:"Starknet",symbol:"STRK",decimals:"18",networkId:"integration",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/strk.png"},{address:"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",name:"Starknet",symbol:"STRK",decimals:"18",networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/strk.png"},{address:"0x00da114221cb83fa859dbdb4c44beeaa0bb37c7537ad5ae66fe5e0efd20e6eb3",name:"DAI",symbol:"DAI",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/dai.png"},{address:"0x03e85bfbb8e2a42b7bead9e88e9a1b19dbccf661471061807292120462396ec9",name:"DAI",symbol:"DAI",decimals:18,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/dai.png"},{address:"0x06f2a0dfeff180133de890ad69c6ba294574c5f34a67890fd22464f348c4d03c",name:"DAI",symbol:"DAI",decimals:18,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/dai.png"},{address:"0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",name:"Wrapped BTC",symbol:"WBTC",decimals:8,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/wbtc.png"},{address:"0x12d537dc323c439dc65c976fad242d5610d27cfb5f31689a0a319b8be7f3d56",name:"Wrapped BTC",symbol:"WBTC",decimals:8,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/wbtc.png"},{address:"0x020d208b9e57a7f92bfa9f61135446e0961afc340378be97dbd317453c0950ae",name:"Wrapped BTC",symbol:"WBTC",decimals:8,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/wbtc.png"},{address:"0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",name:"USD Coin",symbol:"USDC",decimals:6,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdc.png"},{address:"0x005a643907b9a4bc6a55e9069c4fd5fd1f5c79a22470690f75556c4736e34426",name:"USD Coin",symbol:"USDC",decimals:6,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdc.png"},{address:"0x07ab0b8855a61f480b4423c46c32fa7c553f0aac3531bbddaa282d86244f7a23",name:"USD Coin",symbol:"USDC",decimals:6,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdc.png"},{address:"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",name:"Tether USD",symbol:"USDT",decimals:6,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdt.png"},{address:"0x386e8d061177f19b3b485c20e31137e6f6bc497cc635ccdfcab96fadf5add6a",name:"Tether USD",symbol:"USDT",decimals:6,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdt.png"},{address:"0x00585c32b625999e6e5e78645ff8df7a9001cf5cf3eb6b80ccdd16cb64bd3a34",name:"zkLend Token",symbol:"ZEND",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/zend.png"},{address:"0x06ea04cd7e40bfef07c3625e2b3472839093d966bf601568128436466f962fcf",name:"Baby Laika",symbol:"BABYLAIKA",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/babylaika.png"},{address:"0x004a8ff6a7b121c55d5e21af478265c5798f574abaa41efadf569d6939705896",name:"Baby Laika",symbol:"BABYLAIKA",decimals:18,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/babylaika.png"},{address:"0x0782f0ddca11d9950bc3220e35ac82cf868778edb67a5e58b39838544bc4cd0f",name:"Starknet Voting Token",symbol:"vSTRK",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/vstrk.png"},{address:"0x075afe6402ad5a5c20dd25e10ec3b3986acaa647b77e4ae24b0cbc9a54a27a87",name:"Ekubo Protocol",symbol:"EKUBO",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/ekubo.png"}],$r=async(e,t,n)=>{const r=await n.callContract({contractAddress:e,entrypoint:"balanceOf",calldata:[t]});return BigInt(w.num.toHex(w.uint256.uint256ToBN({low:r[0],high:r[1]})))},Mc=async(e,t,n)=>{const r=Ht.filter(o=>o.networkId===e);return(await Promise.allSettled(r.map(o=>t.callContract({contractAddress:o.address,entrypoint:"balanceOf",calldata:[n]})))).reduce((o,i,c)=>{if(i.status==="fulfilled"&&D.isUndefined(i.value)||i.status==="rejected"||i.value[0]==="0x0"&&i.value[1]==="0x0")return o;const l=BigInt(w.num.toHex(w.uint256.uint256ToBN({low:i.value[0],high:i.value[1]}))),u={...r[c],balance:l};return o.push(u),o},[])},qc=async()=>Ht,Gc=({address:e,networkId:t})=>Ht.find(r=>r.address===e&&r.networkId===t),Wc=({amount:e,decimals:t,unitCurrencyValue:n})=>{if(!K(e)||!K(t)||!K(n))return;const r=Number(t),s=BigInt(e)*vt(n.toString()).value;return Ue({value:s,decimals:r+be})},Kc=({unitAmount:e,decimals:t})=>{if(e===void 0||!K(e)||t===void 0||!K(t))return;const n=Number(t);return a.parseUnits(e.toString(),n).value.toString()},Zc=e=>K(e)?Number(e):18,{UINT_256_MAX:Yc}=w.uint256,jr=e=>String(e)===String(Yc),Jc=(e,t="$",n)=>{if(e===void 0||!K(e))return null;const r=cr(e,n);return[t,r].filter(Boolean).join("")},zr="Unlimited",Xc=({amount:e,decimals:t,symbol:n,showPlusSign:r=!1,withSymbol:s=!0,unlimitedText:o=zr,prettyConfigOverrides:i})=>{if(!K(e))return null;let c,l=!1;if(jr(e))c=o;else{const h=Number(t),d=BigInt(e);l=d>0n;const y=h>0?Ue({value:d,decimals:h}):d.toString();c=h>0?lr(y,i):y}const u=[c,s&&n].filter(Boolean).join(" ");return r&&l?`+${u}`:u};var Qc=a.retry,el=Qc;function tl(e,t){function n(r,s){var o=t||{},i;"randomize"in o||(o.randomize=!0),i=el.operation(o);function c(h){s(h||new Error("Aborted"))}function l(h,d){if(h.bail){c(h);return}i.retry(h)?o.onRetry&&o.onRetry(h,d):s(i.mainError())}function u(h){var d;try{d=e(c,h)}catch(y){l(y,h);return}Promise.resolve(d).then(r).catch(function(g){l(g,h)})}i.attempt(u)}return new Promise(n)}var nl=tl;const rl=a.getDefaultExportFromCjs(nl);class sl{constructor(t,n){this.apiBase=t,this.httpService=n,this.TOKENS_INFO_URL="/tokens/info",this.TOKENS_DEFI_DECOMPOSITION_URL="/tokens/defi/decomposition"}async fetchTokensInfoFromBackend(t){const n=a.urlJoin(this.apiBase,this.TOKENS_INFO_URL,t??"","?chain=starknet"),r=await this.httpService.get(n),s=a.apiTokensInfoResponseSchema.safeParse(r);if(s.success)return s.data.tokens;const o=a.apiTokenInfoResponseSchema.safeParse(r);if(o.success)return[o.data]}async fetchAddressTokenBalancesFromBackend(t,n,r){const s=a.urlJoin(this.apiBase,"activity","starknet",n,"account",t,"balance");return(await rl(async c=>{let l;try{l=await this.httpService.get(s)}catch{return c(new Error("Error fetching")),[]}const u=a.apiAccountTokenBalancesSchema.safeParse(l);if(!u.success)return c(new Error("Error parsing response")),[];if(u.data.status!=="initialised")throw new Error("Not initialised yet");return u.data.balances},{retries:5,minTimeout:5e3,...r})).map(c=>({address:c.tokenAddress,balance:c.tokenBalance,networkId:n}))}async fetchDefiDecomposition(t){const n=a.urlJoin(this.apiBase,this.TOKENS_DEFI_DECOMPOSITION_URL,t,"?chain=starknet"),r=await this.httpService.get(n);if(!a.apiDefiPositionsSchema.safeParse(r).success)throw new a.TokenError({code:"TOKEN_DEFI_DECOMPOSITION_PARSING_ERROR"});return r.dapps}}const ol=(e,t,n,r)=>({contractAddress:e,entrypoint:"transfer",calldata:w.CallData.compile({recipient:t,amount:ye(ur(n,r))})}),al=(e,t,n,r)=>({contractAddress:e,entrypoint:"transferFrom",calldata:w.CallData.compile({from_:t,to:n,tokenId:ye(r)})}),il=(e,t,n,r)=>({contractAddress:e,entrypoint:"safeTransferFrom",calldata:w.CallData.compile({from_:t,to:n,tokenId:ye(r),amount:ye(1),data_len:"0"})});function Lt(e){return D.upperCase(e.unit)==="WEI"}function Vr(e){return D.upperCase(e.unit)==="FRI"}function le(e,t){return Lt(e)?{...e,maxFee:t(e.maxFee),overallFee:t(e.overallFee),gasPrice:t(e.gasPrice),gasUsage:t(e.gasUsage)}:{...e,overallFee:t(e.overallFee),gasPrice:t(e.gasPrice),gasUsage:t(e.gasUsage),maxAmount:t(e.maxAmount),maxPricePerUnit:t(e.maxPricePerUnit)}}function we(e){return Lt(e)?{maxFee:e.maxFee}:{amount:e.maxAmount,pricePerUnit:e.maxPricePerUnit}}function Ge(e){return Vr({unit:e})?a.STRK_TOKEN_ADDRESS:a.ETH_TOKEN_ADDRESS}function cl(e,t,n=2){const r=BigInt(10**n),s=BigInt(Math.round(t*10**n));return e*s/r}const ll=[a.STRK_TOKEN_ADDRESS],Mr=(e,t=Zr)=>{if(e.max&&"amount"in e.max)return{...e,...e.max};const n=10000n,{amount:r,pricePerUnit:s,dataGasConsumed:o=0n,dataGasPrice:i=0n}=e,c=r*s+o*i;if(c<0)throw Error("Cannot calculate max fee for negative fee");const l=w.num.toBigInt(a.argentMaxFee({estimatedFee:c})),u=Number(l)/Number(c),h=t(u),d=BigInt(Math.trunc(h*Number(n)));return{...e,amount:r*d/n,pricePerUnit:s*d/n,dataGasConsumed:o*d/n,dataGasPrice:i*d/n}},De=e=>{const{amount:t,pricePerUnit:n,dataGasConsumed:r=0n,dataGasPrice:s=0n}=e;return t*n+r*s},qr=e=>{if(e.max)return"maxFee"in e.max?e.max.maxFee:De(e.max)},Ye=e=>{const t=qr(e);return t||De(Mr(e))},ul=e=>{if(e.deployment&&!a.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=De(e.transactions),n=e.deployment?De(e.deployment):0n;return t+n},dl=e=>{if(e.deployment&&!a.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=e.deployment?Ye(e.deployment):0n,n=Ye(e.transactions);return t+n},hl=(e,t)=>[{contractAddress:e,entrypoint:"transfer",calldata:w.CallData.compile(a.transferCalldataSchema.parse({recipient:t,amount:w.uint256.bnToUint256(BigInt(1))}))}],Gr=(e,t)=>{if(!e)return{transactions:{feeTokenAddress:t??a.ETH_TOKEN_ADDRESS,amount:0n,pricePerUnit:0n,dataGasConsumed:0n,dataGasPrice:0n}};if(!Array.isArray(e))throw Error(`Unexpected simulation response. Expected array. Got ${typeof e}`);if(e.length===1){const n=a.feeEstimationSchema.parse(e[0].feeEstimation);return{transactions:{feeTokenAddress:Ge(n.unit),amount:w.num.toBigInt(n.gasUsage),pricePerUnit:w.num.toBigInt(n.gasPrice),max:we(le(n,w.num.toBigInt)),dataGasConsumed:n.dataGasConsumed?w.num.toBigInt(n.dataGasConsumed):0n,dataGasPrice:n.dataGasPrice?w.num.toBigInt(n.dataGasPrice):0n}}}if(e.length===2){const n=a.feeEstimationSchema.parse(e[0].feeEstimation),r=a.feeEstimationSchema.parse(e[1].feeEstimation);return{deployment:{feeTokenAddress:Ge(n.unit),amount:w.num.toBigInt(n.gasUsage),pricePerUnit:w.num.toBigInt(n.gasPrice),max:we(le(n,w.num.toBigInt)),dataGasConsumed:n.dataGasConsumed?w.num.toBigInt(n.dataGasConsumed):0n,dataGasPrice:n.dataGasPrice?w.num.toBigInt(n.dataGasPrice):0n},transactions:{feeTokenAddress:Ge(r.unit),amount:w.num.toBigInt(r.gasUsage),pricePerUnit:w.num.toBigInt(r.gasPrice),max:we(le(r,w.num.toBigInt)),dataGasConsumed:r.dataGasConsumed?w.num.toBigInt(r.dataGasConsumed):0n,dataGasPrice:r.dataGasPrice?w.num.toBigInt(r.dataGasPrice):0n}}}throw Error("Unexpected simulation response length")},Wr=({transaction:e,nonce:t,chainId:n,version:r,isDeploymentTransaction:s,cairoVersion:o,address:i,appDomain:c})=>{let l=t;s&&e.type!=="DEPLOY_ACCOUNT"&&(l=w.num.toHex(1));const u=a.ensureArray(e.calls);return{type:e.type,chainId:n,cairoVersion:o,nonce:l,version:r,account:i,calls:u,calldata:e.calldata,salt:e.salt,signature:e.signature,classHash:e.classHash,appDomain:c}},Kr=(e,t)=>{const{transactions:n}=e,r=n.map(l=>{if(!l.simulation)throw new a.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});return l}),s=r.map(l=>({...l.simulation,feeEstimation:le(l.simulation.feeEstimation,Number)})),o=Gr(s,t),[i,c]=r.length===1?[r[0],void 0]:[r[1],r[0]];return{...o,transactions:{...o.transactions,dataGasConsumed:o.transactions.dataGasConsumed??0n,dataGasPrice:o.transactions.dataGasPrice??0n,max:we(le(i.simulation.feeEstimation,w.num.toBigInt))},deployment:o.deployment&&c?{...o.deployment,dataGasConsumed:o.deployment.dataGasConsumed??0n,dataGasPrice:o.deployment.dataGasPrice??0n,max:we(le(c.simulation.feeEstimation,w.num.toBigInt))}:void 0}},fl=e=>{const t=Mr(e),n=Ye(e);return{maxFee:n,resourceBounds:{l1_gas:{max_amount:w.num.toHex(n/e.pricePerUnit),max_price_per_unit:w.num.toHex(t.pricePerUnit)},l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"}}}},ml=e=>{const t=Math.sqrt(e);return isNaN(t)?Math.sqrt(2):t},Zr=e=>{const t=Math.cbrt(e);return isNaN(t)?Math.cbrt(2):t},pl=e=>e<1||isNaN(e)?1.1:Math.log(e+1)+1,gl=[a.STRK_TOKEN_ADDRESS];function it({address:e}){return gl.some(t=>a.isEqualAddress(e,t))}function Sl(e){return e?Fn().some(t=>a.isEqualAddress(t,e)):!1}function Et(e){return it({address:e})?w.constants.TRANSACTION_VERSION.V3:w.constants.TRANSACTION_VERSION.V1}function wl(e){return it({address:e})?w.constants.TRANSACTION_VERSION.F3:w.constants.TRANSACTION_VERSION.F1}function yl(e,t){return w.isSierra(t.contract)?it({address:e})?w.constants.TRANSACTION_VERSION.V3:w.constants.TRANSACTION_VERSION.V2:w.constants.TRANSACTION_VERSION.V1}class bl{constructor(t,n){this.apiBase=t,this.httpService=n}async getLabels(){const t=a.urlJoin(this.apiBase,"reviewer","labels");return await this.httpService.get(t)}async getWarnings(){const t=a.urlJoin(this.apiBase,"reviewer","warnings/reasons");return await this.httpService.get(t)}async simulateAndReview(t,n,r,s,o){const i=n.some(c=>c.type==="DEPLOY_ACCOUNT");try{if(!("getChainId"in t))throw new Error("MISSING_METHOD");const c=Et(r),l=i?"0x0":await t.getNonce(),u=await t.getChainId(),h={transactions:n.map(m=>({...Wr({transaction:m,nonce:l,version:c,chainId:u,isDeploymentTransaction:i,appDomain:s,cairoVersion:t.cairoVersion,address:t.address}),type:m.type}))},d=a.urlJoin(this.apiBase,"reviewer","transactions","v2","review","starknet"),y=await this.httpService.post(d,{headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(h)},a.simulateAndReviewSchema);if(y.transactions.some(m=>a.isTransactionSimulationError(m)))return y;const A=Kr(y,r);return{...y,enrichedFeeEstimation:A}}catch(c){return console.error(c),this.fallbackToOnchainFeeEstimation({transactions:n,account:t,isDeploymentTransaction:i,feeTokenAddress:r,accountDeployTransaction:o})}}getCallsFromTx(t){let n;return t.calls&&(n=a.ensureArray(t.calls)),n}async fallbackToOnchainFeeEstimation({transactions:t,account:n,isDeploymentTransaction:r,feeTokenAddress:s,accountDeployTransaction:o}){try{const i=r?this.getCallsFromTx(t[1]):this.getCallsFromTx(t[0]);if(!i)throw new a.ReviewError({code:"NO_CALLS_FOUND"});const c=await this.fetchFeesOnchain({starknetAccount:n,calls:i,isDeployed:!r,feeTokenAddress:s,accountDeployTransaction:o});return{transactions:[],enrichedFeeEstimation:c,isBackendDown:!0}}catch(i){throw console.error(i),new a.ReviewError({message:`${i}`,code:"SIMULATE_AND_REVIEW_FAILED"})}}async fetchFeesOnchain({starknetAccount:t,calls:n,isDeployed:r,feeTokenAddress:s,accountDeployTransaction:o}){try{const i=Et(s),c={transactions:{feeTokenAddress:s,amount:0n,pricePerUnit:0n,dataGasConsumed:0n,dataGasPrice:0n}};if(!r&&o){if("estimateFeeBulk"in t){const l=[{type:w.TransactionType.DEPLOY_ACCOUNT,payload:{classHash:o.classHash,addressSalt:o.salt,constructorCalldata:o.calldata,contractAddress:t.address}},{type:w.TransactionType.INVOKE,payload:n}],[u,h]=await t.estimateFeeBulk(l,{version:i}).catch(d=>{throw console.error(d),d});if(!u.gas_consumed||!u.gas_price||!h.gas_consumed||!h.gas_price)throw new a.ReviewError({code:"ONCHAIN_FEE_ESTIMATION_FAILED",message:"Missing gas_consumed or gas_price"});c.deployment={feeTokenAddress:s,amount:u.gas_consumed,pricePerUnit:u.gas_price,dataGasConsumed:u.data_gas_consumed,dataGasPrice:u.data_gas_price},c.transactions={feeTokenAddress:s,amount:h.gas_consumed,pricePerUnit:h.gas_price,dataGasConsumed:h.data_gas_consumed,dataGasPrice:h.data_gas_price}}}else{const{gas_consumed:l,gas_price:u,data_gas_consumed:h,data_gas_price:d}=await t.estimateFee(n,{skipValidate:!0,version:i});if(!l||!u)throw new a.ReviewError({code:"ONCHAIN_FEE_ESTIMATION_FAILED",message:"Missing gas_consumed or gas_price"});c.transactions={feeTokenAddress:s,amount:l,pricePerUnit:u,dataGasConsumed:h,dataGasPrice:d}}return c}catch(i){throw new a.ReviewError({code:"ONCHAIN_FEE_ESTIMATION_FAILED",message:`${i}`})}}}const El=["account-upgrade","approve","set-approval-for-all","swap","transfer"],Al=e=>({showBalanceChange:L.useMemo(()=>{const n=e==null?void 0:e.some(s=>!D.isEmpty(s.transfers)),r=e==null?void 0:e.some(s=>!D.isEmpty(s.approvals));return e&&(n||r)},[e])}),je=e=>e?e.filter(t=>t.token.type==="erc20"):[],Tl=e=>L.useMemo(()=>je(e),[e]),vl=e=>je(e).length>0,xl=e=>je(e).some(n=>n.amount>0n),Il=e=>je(e).some(n=>n.amount<0n),$t=e=>e?e.filter(t=>t.token.type==="erc721"):[],Cl=e=>L.useMemo(()=>$t(e),[e]),Yr=e=>$t(e).length>0,_l=e=>L.useMemo(()=>Yr(e),[e]),Nl=(e,t)=>L.useMemo(()=>e&&t?[{contractAddress:e.address,entrypoint:"transfer",calldata:w.CallData.compile({recipient:t,amount:ye(e.balance)})}]:[],[e,t]),Bl=({apiData:{apiBaseUrl:e,apiHeaders:t},address:n,network:r,transactionReviewEnabled:s=!0,transactions:o})=>{const i=L.useCallback(async()=>{if(!n||!r)return;if(!e)throw"Transaction review endpoint is not defined";const l=a.urlJoin(e,"reviewer/transactions/review/starknet"),u=D.isArray(o)?o:[o],h={network:r,account:n,calls:u};return xt(l,{method:"POST",headers:{"Content-Type":"application/json",...t},body:JSON.stringify(h)})},[n,r,o]),c=L.useMemo(()=>ss({transactions:o,address:n,network:r}),[o,n,r]);return An(!!s,[c,"transactionReview"],i)},Ol=e=>{if(!e)return{};const t=e.assessment==="warn"&&e.reason!=="contract_is_not_verified",n=e.reason?` (Reason: ${D.lowerCase(e.reason)})`:"",r=t?e.reason==="recipient_is_token_address"?"You are sending tokens to their own address. This is likely to burn them.":`This transaction has been flagged as dangerous. We recommend you reject this transaction unless you are sure.${n}`:void 0;return{warn:t,reason:r}},Jr=e=>{var t;if(e){for(const n of e.reviews)if(((t=n.activity)==null?void 0:t.type)==="swap")return n}},kl=e=>{},Rl=(e,t)=>{var n;if(t){for(const r of t.reviews)if(((n=r.activity)==null?void 0:n.type)===e)return r.activity}},Pl=e=>!!Jr(e),Fl=e=>{var t,n;if(e){for(const r of e.reviews)if((t=r.activity)!=null&&t.type)return{...r,type:(n=r.activity)==null?void 0:n.type}}},Xr=async({feeTokenAddress:e,calls:t,selectedAccount:n,transactionReviewService:r,appDomain:s,accountDeployTransaction:o})=>{const i={type:"INVOKE",calls:a.ensureArray(t)};if(!n||!e)return;const c=o?[o,i]:[i];return{result:await r.simulateAndReview(n,c,e,s,o)}},Qr=async(e,t,n,r)=>{var y,g,A,m,S,E;let s=!1;const o=t.transactions.find(T=>{var x,B;return(B=(x=T==null?void 0:T.simulation)==null?void 0:x.summary)==null?void 0:B.find(N=>N.sent)});if(!o||!((y=o.simulation)!=null&&y.summary))return s;const i=o.simulation.summary.filter(T=>T.sent).map(T=>T.token.address);if(!(((g=t.enrichedFeeEstimation)==null?void 0:g.transactions.feeTokenAddress)&&i.includes((A=t.enrichedFeeEstimation)==null?void 0:A.transactions.feeTokenAddress))||!((S=(m=t.enrichedFeeEstimation)==null?void 0:m.transactions)!=null&&S.max))return s;const l="amount"in t.enrichedFeeEstimation.transactions.max?t.enrichedFeeEstimation.transactions.max.amount*t.enrichedFeeEstimation.transactions.max.pricePerUnit:"maxFee"in t.enrichedFeeEstimation.transactions.max?t.enrichedFeeEstimation.transactions.max.maxFee:void 0,u=(E=o.simulation.summary.find(T=>T.sent&&T.token.address===n))==null?void 0:E.value;if(!l||!u)return s;const h=await $r(n,e,r)??0n;return BigInt(h)>l+BigInt(u)||(s=!0),s},Dl=()=>L.useCallback(async({feeTokenAddress:t,calls:n,selectedAccount:r,transactionReviewService:s,appDomain:o,accountDeployPayload:i,provider:c})=>{if(!r)return;const l=await Xr({feeTokenAddress:t,calls:n,selectedAccount:r,transactionReviewService:s,appDomain:o,accountDeployTransaction:es(i)});if(!l||!l.result||!t)return;const u=await Qr(r.address,l.result,t,c);return{...l.result,isSendingMoreThanBalanceAndGas:u}},[]),es=e=>e?{type:"DEPLOY_ACCOUNT",calldata:e.calldata,classHash:a.hexSchema.parse(e.class_hash),salt:a.hexSchema.parse(e.salt),signature:[]}:void 0;exports.BaseError=a.BaseError;Object.defineProperty(exports,"ESTIMATE_ERROR_MESSAGES",{enumerable:!0,get:()=>a.ESTIMATE_ERROR_MESSAGES});exports.ETH_TOKEN_ADDRESS=a.ETH_TOKEN_ADDRESS;exports.EstimateError=a.EstimateError;exports.EventEmitterProvider=a.EventEmitterProvider;exports.EventsBySelector=a.EventsBySelector;exports.FEE_OVERHEAD=a.FEE_OVERHEAD;Object.defineProperty(exports,"HTTP_ERROR_MESSAGE",{enumerable:!0,get:()=>a.HTTP_ERROR_MESSAGE});exports.HttpError=a.HttpError;Object.defineProperty(exports,"MultiSigner",{enumerable:!0,get:()=>a.MultiSigner});exports.STANDARD_DEVNET_ACCOUNT_CLASS_HASH=a.STANDARD_DEVNET_ACCOUNT_CLASS_HASH;exports.STRK_TOKEN_ADDRESS=a.STRK_TOKEN_ADDRESS;Object.defineProperty(exports,"TOKEN_ERROR_MESSAGES",{enumerable:!0,get:()=>a.TOKEN_ERROR_MESSAGES});exports.TXV1_ACCOUNT_CLASS_HASH=a.TXV1_ACCOUNT_CLASS_HASH;exports.TXV1_MULTISIG_CLASS_HASH=a.TXV1_MULTISIG_CLASS_HASH;exports.TXV3_ACCOUNT_CLASS_HASH=a.TXV3_ACCOUNT_CLASS_HASH;exports.TXV3_MULTISIG_CLASS_HASH=a.TXV3_MULTISIG_CLASS_HASH;exports.TokenError=a.TokenError;exports.abiEntrySchema=a.abiEntrySchema;exports.abiSchema=a.abiSchema;exports.addOwnersCalldataSchema=a.addOwnersCalldataSchema;exports.addPluginCalldataSchema=a.addPluginCalldataSchema;exports.addressInputCharactersAndLengthSchema=a.addressInputCharactersAndLengthSchema;exports.addressInputSchema=a.addressInputSchema;exports.addressOrDomainInputSchema=a.addressOrDomainInputSchema;exports.addressOrDomainSchema=a.addressOrDomainSchema;exports.addressOrEmptyUndefinedSchema=a.addressOrEmptyUndefinedSchema;exports.addressSchema=a.addressSchema;exports.addressSchemaArgentBackend=a.addressSchemaArgentBackend;exports.addressSchemaBase=a.addressSchemaBase;exports.addressSchemaLooseLength=a.addressSchemaLooseLength;exports.addressSchemaStrictLength=a.addressSchemaStrictLength;exports.airdropSchema=a.airdropSchema;exports.apiAccountTokenBalancesSchema=a.apiAccountTokenBalancesSchema;exports.apiAirdropSchema=a.apiAirdropSchema;exports.apiCollateralizedDebtPositionSchema=a.apiCollateralizedDebtPositionSchema;exports.apiCollateralizedDebtPositionsSchema=a.apiCollateralizedDebtPositionsSchema;exports.apiConcentratedLiquidityPositionSchema=a.apiConcentratedLiquidityPositionSchema;exports.apiConcentratedLiquidityPositionsSchema=a.apiConcentratedLiquidityPositionsSchema;exports.apiDefiDecompositionProduct=a.apiDefiDecompositionProduct;exports.apiDefiDecompositionProducts=a.apiDefiDecompositionProducts;exports.apiDefiDecompositionSchema=a.apiDefiDecompositionSchema;exports.apiDefiDecompositionToken=a.apiDefiDecompositionToken;exports.apiDefiPositionsSchema=a.apiDefiPositionsSchema;exports.apiPriceDataResponseSchema=a.apiPriceDataResponseSchema;exports.apiPriceDetailsSchema=a.apiPriceDetailsSchema;exports.apiTokenInfoResponseSchema=a.apiTokenInfoResponseSchema;exports.apiTokenInfoSchema=a.apiTokenInfoSchema;exports.apiTokensInfoResponseSchema=a.apiTokensInfoResponseSchema;exports.apiUnclaimedRewardsSchema=a.apiUnclaimedRewardsSchema;exports.apiWalletResponseSchema=a.apiWalletResponseSchema;exports.argentMaxFee=a.argentMaxFee;exports.argentNameSchema=a.argentNameSchema;exports.bigNumberSchema=a.bigNumberSchema;exports.bigNumberishSchema=a.bigNumberishSchema;exports.booleanToStringSchema=a.booleanToStringSchema;exports.builtinsSchema=a.builtinsSchema;exports.byteCodeSchema=a.byteCodeSchema;exports.cairo1EventSchema=a.cairo1EventSchema;exports.cairoAssemblySchema=a.cairoAssemblySchema;exports.cairoVersionSchema=a.cairoVersionSchema;exports.callDetailsSchema=a.callDetailsSchema;exports.callSchema=a.callSchema;exports.calldataSchema=a.calldataSchema;exports.changeGuardianCalldataSchema=a.changeGuardianCalldataSchema;exports.changeThresholdCalldataSchema=a.changeThresholdCalldataSchema;exports.collateralizedDebtGroupSchema=a.collateralizedDebtGroupSchema;exports.collateralizedDebtPositionSchema=a.collateralizedDebtPositionSchema;exports.collateralizedDebtPositionsSchema=a.collateralizedDebtPositionsSchema;exports.compiledContractClassSchema=a.compiledContractClassSchema;exports.compiledSierraCasmSchema=a.compiledSierraCasmSchema;exports.compiledSierraSchema=a.compiledSierraSchema;exports.compressedProgramSchema=a.compressedProgramSchema;exports.concentratedLiquidityPositionSchema=a.concentratedLiquidityPositionSchema;exports.concentratedLiquidityPositionsSchema=a.concentratedLiquidityPositionsSchema;exports.constructorCallDataSchemaC0=a.constructorCallDataSchemaC0;exports.constructorCallDataSchemaC1V1=a.constructorCallDataSchemaC1V1;exports.contractEntryPointFieldsSchema=a.contractEntryPointFieldsSchema;exports.defiDappsProductsSchema=a.defiDappsProductsSchema;exports.defiPositionSchema=a.defiPositionSchema;exports.defiPositionTypeSchema=a.defiPositionTypeSchema;exports.defiProductSchema=a.defiProductSchema;exports.defiProductsSchema=a.defiProductsSchema;exports.denyTxV3=a.denyTxV3;exports.ensureArray=a.ensureArray;exports.entryPointsByTypeSchema=a.entryPointsByTypeSchema;exports.escapeGuardianCalldataSchema=a.escapeGuardianCalldataSchema;exports.eventAbiSchema=a.eventAbiSchema;exports.eventEntrySchema=a.eventEntrySchema;exports.executeOnPluginCalldataSchema=a.executeOnPluginCalldataSchema;exports.feltSchema=a.feltSchema;exports.findTransfersAndApprovals=a.findTransfersAndApprovals;exports.formatFullAddress=a.formatFullAddress;exports.formatTruncatedAddress=a.formatTruncatedAddress;exports.formatTruncatedSignerKey=a.formatTruncatedSignerKey;exports.formatTruncatedString=a.formatTruncatedString;exports.functionAbiSchema=a.functionAbiSchema;exports.functionAbiTypeSchema=a.functionAbiTypeSchema;exports.getAddressFromArgentName=a.getAddressFromArgentName;exports.getMessageFromTrpcError=a.getMessageFromTrpcError;exports.getPrettyRpcError=a.getPrettyRpcError;exports.getSignerForMultiSigner=a.getSignerForMultiSigner;exports.hexSchema=a.hexSchema;exports.hexSchemaBase=a.hexSchemaBase;exports.implementationSchema=a.implementationSchema;exports.includesAddress=a.includesAddress;exports.inputAmountSchema=a.inputAmountSchema;exports.isAddress=a.isAddress;exports.isArgentName=a.isArgentName;exports.isEqualAddress=a.isEqualAddress;exports.isEqualArgentName=a.isEqualArgentName;exports.isEqualStarknetDomainName=a.isEqualStarknetDomainName;exports.isEqualStarknetId=a.isEqualStarknetId;exports.isStarknetDomainName=a.isStarknetDomainName;exports.isStarknetId=a.isStarknetId;exports.isValidAddress=a.isValidAddress;exports.isValidInputAmount=a.isValidInputAmount;exports.isZeroAddress=a.isZeroAddress;exports.legacyContractClassSchema=a.legacyContractClassSchema;exports.legacyEventSchema=a.legacyEventSchema;exports.looseCalldataSchema=a.looseCalldataSchema;exports.modifySnjsFeeOverhead=a.modifySnjsFeeOverhead;exports.multiTypeSchema=a.multiTypeSchema;exports.normalizeAddress=a.normalizeAddress;exports.normalizeAddressOrDomain=a.normalizeAddressOrDomain;exports.normalizeArgentName=a.normalizeArgentName;exports.normalizeStarknetId=a.normalizeStarknetId;exports.parseAmount=a.parseAmount;exports.productGroupsSchema=a.productGroupsSchema;exports.programSchema=a.programSchema;exports.pythonicHintsSchema=a.pythonicHintsSchema;exports.rawArgsArraySchema=a.rawArgsArraySchema;exports.rawArgsObjectSchema=a.rawArgsObjectSchema;exports.rawArgsSchema=a.rawArgsSchema;exports.removeOwnersCalldataSchema=a.removeOwnersCalldataSchema;exports.removePluginCalldataSchema=a.removePluginCalldataSchema;exports.replaceSignerCalldataSchema=a.replaceSignerCalldataSchema;exports.sierraContractEntryPointFieldsSchema=a.sierraContractEntryPointFieldsSchema;exports.sierraEntryPointsByTypeSchema=a.sierraEntryPointsByTypeSchema;exports.sierraProgramDebugInfoSchema=a.sierraProgramDebugInfoSchema;exports.starknetDomainNameSchema=a.starknetDomainNameSchema;exports.starknetIdSchema=a.starknetIdSchema;exports.stringToBooleanSchema=a.stringToBooleanSchema;exports.structAbiSchema=a.structAbiSchema;exports.transactionReviewTransactionsSchema=a.transactionReviewTransactionsSchema;exports.transactionReviewWarningSchema=a.transactionReviewWarningSchema;exports.transferCalldataSchema=a.transferCalldataSchema;exports.trpcErrorSchema=a.trpcErrorSchema;exports.txVersionSchema=a.txVersionSchema;exports.uint256Schema=a.uint256Schema;exports.unclaimedRewardsSchema=a.unclaimedRewardsSchema;exports.useEmitEvent=a.useEmitEvent;exports.useEventEmitter=a.useEventEmitter;exports.useEventEmitterContext=a.useEventEmitterContext;exports.useEventListener=a.useEventListener;exports.useIsEventEmitterEnabled=a.useIsEventEmitterEnabled;exports.validChecksumAddressSchema=a.validChecksumAddressSchema;exports.validateAddressRangeSchema=a.validateAddressRangeSchema;exports.ARGENT_ACCOUNT_CONTRACT_CLASS_HASHES=J;exports.ARGENT_MULTISIG_CONTRACT_CLASS_HASHES=Oe;exports.AddSmartAccountResponseSchema=os;exports.AddSmartAcountRequestSchema=as;exports.BackendAccountSchema=pn;exports.BackendNftService=oi;exports.C0_PROXY_CONTRACT_CLASS_HASHES=Nn;exports.CacheService=ks;exports.DEFAULT_TOKEN_DECIMALS=be;exports.DateService=Rs;exports.HTTPService=Xe;exports.KnownDappsBackendService=ma;exports.OnchainRecoveryService=Uc;exports.PRETTY_UNLIMITED=zr;exports.ResolveNameService=ga;exports.SWRService=Fs;exports.StarknetAddressService=zs;exports.TokenServiceWeb=sl;exports.TransactionReviewServiceWeb=bl;exports.activeOnchainRecoverySchema=Dr;exports.apiTransactionReviewActivityType=El;exports.argentBackendNetworkIdSchema=wn;exports.argentNetworkIdSchema=Sn;exports.bigDecimal=Os;exports.buildAccountDeployTransaction=es;exports.buildConstructorCalldata=Hn;exports.buildDummyTx=hl;exports.calculateCubeRootAdjustment=Zr;exports.calculateNonLinearAdjustment=pl;exports.calculateSqrtAdjustment=ml;exports.castFeeEstimation=le;exports.checkGasFeeBalance=Qr;exports.classHashSupportsTxV3=Sl;exports.convertTokenAmountToCurrencyValue=Wc;exports.convertTokenUnitAmountWithDecimals=Kc;exports.dappContractSchema=jn;exports.dappLinkSchema=$n;exports.daysBetween=Wa;exports.decodeBase58=ir;exports.decodeBase58Array=Ga;exports.encodeBase58=ar;exports.encodeBase58Array=qa;exports.ensureDecimals=Zc;exports.entryPointToHumanReadable=ti;exports.equalNft=di;exports.erc20TransferTransaction=ol;exports.erc721SafeTransferFromTransaction=il;exports.erc721TransferFromTransaction=al;exports.estimatedFeeToMaxFeeTotal=Ye;exports.estimatedFeeToMaxResourceBounds=fl;exports.estimatedFeeToTotal=De;exports.estimatedFeesToMaxFeeTotal=dl;exports.estimatedFeesToTotal=ul;exports.feeTokenNeedsTxV3Support=it;exports.fetchData=xt;exports.fetcherError=Be;exports.findImplementationForAccount=da;exports.formatAddress=_t;exports.generateAvatarImage=Re;exports.getAccountContractAddress=Ln;exports.getAccountDeploymentPayload=Un;exports.getAccountIdentifier=Hs;exports.getAddressFromStarkName=_n;exports.getArgentAccountClassHashes=St;exports.getArgentAccountClassHashesWithTxV3Support=Fn;exports.getArgentAccountWithMultiSignerClassHashes=Pn;exports.getBackendTimeNowSeconds=js;exports.getBackendTimeSeconds=Tn;exports.getCallFromStarkName=Cn;exports.getChainIdFromNetworkId=vn;exports.getColor=sr;exports.getDapplandLinkForDapp=Mn;exports.getDapplandUrlForDapp=pa;exports.getDisplayWarnAndReasonForTransactionReview=Ol;exports.getERC20Transactions=je;exports.getERC721Transactions=$t;exports.getEstimatedFeeFromBulkSimulation=Gr;exports.getEstimatedFeeFromSimulationAndRespectWatermarkFee=Kr;exports.getInitials=rr;exports.getLastCairo0ArgentAccountClassHash=ca;exports.getLatestArgentAccountClassHash=Rn;exports.getLatestArgentMultisigClassHash=ia;exports.getLatestLedgerAccountClassHash=ua;exports.getLedgerAccountClassHashes=la;exports.getNFTTransferActivity=kl;exports.getNetworkAccountImageUrl=Ma;exports.getNftPicture=ui;exports.getPayloadFromTransaction=Wr;exports.getReviewForTransactions=Xr;exports.getSimulationTxVersionFromFeeToken=wl;exports.getStarknetIdContractAddressFromNetworkId=In;exports.getTokenBalance=$r;exports.getTokens=qc;exports.getTokensBalances=Mc;exports.getTransactionReviewActivityOfType=Rl;exports.getTransactionReviewHasSwap=Pl;exports.getTransactionReviewSwap=Jr;exports.getTransactionReviewWithType=Fl;exports.getTxVersionFromFeeToken=Et;exports.getTxVersionFromFeeTokenForDeclareContract=yl;exports.getUAParserResult=Lr;exports.getUint256CalldataFromBN=ye;exports.getWatermarkedMaxFeeTotal=qr;exports.hasERC20Transactions=vl;exports.hasERC721Transactions=Yr;exports.hasIncomingERC20Transactions=xl;exports.hasOutgoingERC20Transactions=Il;exports.id=nr;exports.isAccountV4=ls;exports.isAccountV5=cs;exports.isAccountV6=is;exports.isAllowedAddressHexInputValue=Ja;exports.isAllowedNumericInputValue=Xa;exports.isArgentBackendNetworkId=hs;exports.isArgentNetworkId=ds;exports.isBraveBrowser=Hc;exports.isBrowser=$e;exports.isChromeBrowser=$c;exports.isContractDeployed=Za;exports.isEdgeBrowser=zc;exports.isEqualImplementation=Dn;exports.isFRI=Vr;exports.isFeatureEnabled=Ka;exports.isFirefoxBrowser=Lc;exports.isNumeric=K;exports.isSafariBrowser=jc;exports.isUnlimitedAmount=jr;exports.isWEI=Lt;exports.knownDappSchema=zn;exports.knownDappsSchema=Vn;exports.multiplyBigIntByFloat=cl;exports.nameProviderResolutionSchema=Gn;exports.nameResolutionAddressSchema=Wn;exports.nameResolutionAddressesSchema=Zn;exports.nameResolutionStarknetIdSchema=Ct;exports.nameResolutionStarknetIdsSchema=qn;exports.nonNullable=Ya;exports.onchainRecoverySchema=Ur;exports.parseAmountValue=ur;exports.pluralise=Qa;exports.postData=Ds;exports.preferencesEndpointPayload=us;exports.preferencesSchema=gn;exports.prettifyCurrencyNumber=cr;exports.prettifyCurrencyValue=Jc;exports.prettifyNumber=Nt;exports.prettifyNumberConfig=rt;exports.prettifyTokenAmount=Xc;exports.prettifyTokenNumber=lr;exports.providersNamesSchema=Kn;exports.readFileAsString=ei;exports.recoveryBaseSchema=Ut;exports.recoveryBodySchema=Fc;exports.recoveryStatusSchema=Fr;exports.seedphraseSchema=Vc;exports.starkNameToCallDataDomain=xn;exports.startOnchainRecoveryErrorSchema=Dc;exports.startOnchainRecoveryErrorStatusSchema=Hr;exports.startOnchainRecoverySchema=Pr;exports.stripAddressZeroPadding=or;exports.swrRefetchDisabledConfig=$s;exports.toMax=we;exports.tokensRequireTxV3Support=ll;exports.unitToFeeTokenAddress=Ge;exports.urlWithQuery=ni;exports.useBalanceChange=Al;exports.useCollection=ci;exports.useConditionallyEnabledSWR=An;exports.useDebounce=ha;exports.useDebouncedValue=fa;exports.useERC20Transactions=Tl;exports.useERC721Transactions=Cl;exports.useHasERC721Transaction=_l;exports.useMaxAmountTransaction=Nl;exports.useNft=li;exports.useNfts=ii;exports.useToken=Gc;exports.useTransactionReview=Bl;exports.useTransactionReviewV2webFetcher=Dl;exports.voidify=ri;exports.withPolling=Us;
4
+ </svg>`;return`data:image/svg+xml;base64,${btoa(o)}`},en=["02BBA8","29C5FF","0078A4","FFBF3D","FFA85C","FF875B","FF675C","FF5C72"],or=e=>{const t=rr(e).slice(-2),n=parseInt(t,16)%en.length;return en[n]},ar=e=>{try{return w.num.toHex(qa(w.num.hexToDecimalString(e)))}catch{}return""},Ga=({accountName:e,networkId:t,accountAddress:n,backgroundColor:r})=>{const s=ar(n),o=`${t}::${s}`,i=r||or(o);return Re(e,{background:i})},ir=e=>{const t=w.encode.removeHexPrefix(w.encode.sanitizeHex(w.num.toHex(e))),n=Ne.hex.decode(t);return Ne.base58.encode(n)},Wa=e=>e.map(ir),cr=e=>{const t=Ne.base58.decode(e);return w.encode.sanitizeHex(Ne.hex.encode(t))},Ka=e=>e.map(cr);function Za(e,t){const n=e.getTime(),r=t.getTime(),s=Math.abs(n-r);return Math.floor(s/(1e3*60*60*24))}const Ya=e=>(e||"false")==="true",Ja=async(e,t)=>{try{return await e.getClassHashAt(t),!0}catch{return!1}};function Xa(e){return!U.isNil(e)}const Qa=e=>{const t=/^(0|0x([a-f0-9A-F]+)?)$/;return!!(e===""||t.test(e))},K=e=>!isNaN(parseFloat(e))&&isFinite(Number(e)),ei=(e,t=16)=>{const n=new RegExp(`^[0-9]*.?[0-9]{0,${t}}$`);return e===""?!0:K(e)?!!n.test(e):!1},rt={CURRENCY:{minDecimalPlaces:2,maxDecimalPlaces:10,minDecimalSignificantDigits:2,decimalPlacesWhenZero:2,allowLeadingZerosInDecimalPart:!0},TOKEN:{minDecimalPlaces:4,maxDecimalPlaces:16,minDecimalSignificantDigits:2,decimalPlacesWhenZero:1,allowLeadingZerosInDecimalPart:!0}},lr=(e,t)=>Nt(e,{...rt.CURRENCY,...t||{}}),ur=(e,t)=>Nt(e,{...rt.TOKEN,...t||{}}),Nt=(e,{minDecimalPlaces:t,maxDecimalPlaces:n,minDecimalSignificantDigits:r,decimalPlacesWhenZero:s,allowLeadingZerosInDecimalPart:o}=rt.CURRENCY)=>{if(!K(e))return null;const i=new a.BigNumber(typeof e=="bigint"?e.toString():e);let c;const l=`0.${"".padStart(s-1,"0")}1`;if(i.lt(new a.BigNumber(l))&&!o)c=`0.${"".padStart(s,"0")}`;else if(i.gte(1))c=i.toFormat(t);else{const g=i.toFormat(n).split(".")[1].match(/^0+/),A=o&&g&&g.length?g[0].length:0,m=Math.max(A+r,t);c=i.toFormat(m)}let u=c.replace(/0+$/,"");const h=1+c.indexOf(".")+s;return u.length<h&&(u=c.substring(0,h)),u},dr=(e,t=18)=>{const n=e.replace(",",".");return!e||!K(n)?0n:a.parseUnits(n,Number(t)).value};function ye(e){return w.uint256.bnToUint256(e)}const ti=(e,t)=>`${e} ${t}${e===1?"":"s"}`,ni=e=>new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{var s;return r.result?t((s=r.result)==null?void 0:s.toString()):n(new Error("Could not read file"))},r.onerror=n,r.onabort=n.bind(null,new Error("User aborted")),r.readAsText(e)});function ri(e){try{return U.upperFirst(U.lowerCase(e))}catch{return e}}const si=(e,t)=>{const n=new URLSearchParams(t),r=n.size?`?${n}`:"";return a.urlJoin(...a.ensureArray(e),r)};function oi(e){return(...t)=>{e(...t)}}class ai extends Error{constructor(t,n){super(`${t}::${n}`),this.name=t,this.code=n,this.name=t}}class tn extends ai{constructor(t){super("BackendPaginationError",t)}}const nn=32;class ii{constructor(t,n,r){this.apiBase=t,this.headers=n,this.imageOptimizationUrl=r,this.httpService=new Xe(this.headers,"json")}async getNfts(t,n,r,s=1){const o=this.normalizeAddress(r),i=a.urlJoin(this.apiBase,"pandora",t,n),c=this.pageToPageIndex(s),u=`${a.urlJoin(i,"profile",o,"nfts")}?page=${c}&size=${nn}`,h=await this.httpService.get(u),d=h.content.map(y=>this.mapItem(y,r));return{totalPages:h.totalPages,page:h.number+1,count:d.length,nfts:d}}async getCollection(t,n,r){const s=this.normalizeAddress(r),o=a.urlJoin(this.apiBase,"pandora",t,n),i=a.urlJoin(o,"collection",s),c=`${o}/collection/${s}`,[l,u]=await Promise.all([this.httpService.get(i),this.httpService.get(c)]),h=dt(l),d=u.content.map(y=>this.mapItem(y));return{...h,nfts:{totalPages:u.totalPages,page:u.number,count:d.length,data:d}}}async getNft(t,n,r,s){const o=this.normalizeAddress(r),i=a.urlJoin(this.apiBase,"pandora",t,n),c=a.urlJoin(i,"nft",o,s),l=await this.httpService.get(c);return this.mapItem(l)}async getProfileCollections(t,n,r,s=1,o=!1){const i=this.pageToPageIndex(s),c=this.normalizeAddress(r),l=a.urlJoin(this.apiBase,"pandora",t,n),u=a.urlJoin(l,"profile",c,"collections",`?page=${i}&size=${nn}`),h=await this.httpService.get(u),d=[];for(const y of h.content)if(o){const g=await this.getCollectionMetrics(t,n,y.contractAddress);d.push(dt(y,g))}else d.push(dt(y));return{totalPages:h.totalPages,page:h.number+1,count:d.length,collections:d}}async getCollectionMetrics(t,n,r){const s=this.normalizeAddress(r),o=a.urlJoin(this.apiBase,"pandora",t,n),i=a.urlJoin(o,"collection",s,"metrics");return this.httpService.get(i)}normalizeAddress(t){return a.addressSchemaArgentBackend.parse(t)}pageToPageIndex(t){if(!Number.isInteger(t))throw new tn("notANumber");const n=t-1;if(n<0)throw new tn("tooLow");return n}optimizeImage(t,n,r){if(!t)return;const s=new URLSearchParams({url:t,w:(n??400).toString(),h:(r??400).toString()});return`${this.imageOptimizationUrl}?${s.toString()}`}mapItem(t,n){var s;const r=t.name??t.tokenId;return{token_id:t.tokenId,contract_address:t.contractAddress,name:r,spec:"spec"in t?ci(t.spec):void 0,description:"",best_bid_order:{payment_amount:"bestListPrice"in t?BigInt(t.bestListPrice):void 0},properties:"properties"in t&&t.properties.map(o=>({key:o.key,value:o.value}))||[],image_uri:this.optimizeImage(t.imageUrls.preview)??Re(r,{background:"#15192A",color:"#ffffff"}),image_url_copy:this.optimizeImage(t.imageUrls.full)??Re(r,{background:"#15192A",color:"#ffffff"}),owner:{account_address:((s=t.owner)==null?void 0:s.address)||n},contract_name:_t(t.contractAddress)}}}function ci(e){switch(e){case"erc721":case"starknetErc721":return"ERC721";case"erc1155":case"starknetErc1155":return"ERC1155"}}function dt(e,t){return{contractAddress:a.addressSchema.parse(e.contractAddress),name:e.name||_t(e.contractAddress),description:e.description??"",imageUri:e.imageUrls.preview??Re(e.name||e.contractAddress.replace("0x",""),{background:"#15192A",color:"#ffffff"}),...t&&{owners:{total:t.numberOfItems,unique:t.uniqueOwners},...t.floorPrice&&{floorPrice:BigInt(t.floorPrice)}}}}const hr=async(e,t,n,r,s=1)=>{const o=await e.getNfts(t,n,r,s);if(s<o.totalPages){const i=await hr(e,t,n,r,o.page+1);return{...o,nfts:o.nfts.concat(i.nfts)}}return o},li=(e,t,n,r,s)=>{const{data:o,...i}=_e(r&&[r,"nfts"],()=>r&&hr(e,t,n,r),{refreshInterval:3e5,...s});return{nfts:o==null?void 0:o.nfts,...i}},ui=(e,t,n,r,s)=>{const{data:o,...i}=_e(r&&[`${r}`,"nfts-collection"],()=>r&&e.getCollection(t,n,r),{refreshInterval:6e4,...s});return{collection:o,...i}},di=(e,t,n,r,s,o)=>{const{data:i,...c}=_e(s&&r&&[`${r}:${s}`,"nft"],()=>s&&r?e.getNft(t,n,r,s):void 0,{refreshInterval:6e4,revalidateOnFocus:!1,revalidateOnMount:!1,...o});return{nft:i,...c}},hi=({image_uri:e,image_url_copy:t})=>{if(e&&t){if(!t.startsWith("ipfs://"))return t;if(!e.startsWith("ipfs://"))return e}return t||e},fi=(e,t)=>e.token_id===t.token_id&&a.isEqualAddress(e.contract_address,t.contract_address);function rn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function mi(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function fr(e,...t){if(!mi(e))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Ze(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function mr(e,t){fr(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Me=BigInt(2**32-1),sn=BigInt(32);function pi(e,t=!1){return t?{h:Number(e&Me),l:Number(e>>sn&Me)}:{h:Number(e>>sn&Me)|0,l:Number(e&Me)|0}}function gi(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:o,l:i}=pi(e[s],t);[n[s],r[s]]=[o,i]}return[n,r]}const Si=(e,t,n)=>e<<n|t>>>32-n,wi=(e,t,n)=>t<<n|e>>>32-n,yi=(e,t,n)=>t<<n-32|e>>>64-n,bi=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ei=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));function Ai(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}const ht=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),X=(e,t)=>e<<32-t|e>>>t,Ti=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Ti)throw new Error("Non little-endian hardware is not supported");function pr(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Bt(e){if(typeof e=="string"&&(e=pr(e)),!Ai(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}let gr=class{clone(){return this._cloneInto()}};function Sr(e){const t=r=>e().update(Bt(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const[wr,yr,br]=[[],[],[]],vi=BigInt(0),Ie=BigInt(1),xi=BigInt(2),Ii=BigInt(7),Ci=BigInt(256),_i=BigInt(113);for(let e=0,t=Ie,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],wr.push(2*(5*r+n)),yr.push((e+1)*(e+2)/2%64);let s=vi;for(let o=0;o<7;o++)t=(t<<Ie^(t>>Ii)*_i)%Ci,t&xi&&(s^=Ie<<(Ie<<BigInt(o))-Ie);br.push(s)}const[Ni,Bi]=gi(br,!0),on=(e,t,n)=>n>32?yi(e,t,n):Si(e,t,n),an=(e,t,n)=>n>32?bi(e,t,n):wi(e,t,n);function Oi(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,l=(i+2)%10,u=n[l],h=n[l+1],d=on(u,h,1)^n[c],y=an(u,h,1)^n[c+1];for(let g=0;g<50;g+=10)e[i+g]^=d,e[i+g+1]^=y}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=yr[i],l=on(s,o,c),u=an(s,o,c),h=wr[i];s=e[h],o=e[h+1],e[h]=l,e[h+1]=u}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=Ni[r],e[1]^=Bi[r]}n.fill(0)}class Ot extends gr{constructor(t,n,r,s=!1,o=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,rn(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Ei(this.state)}keccak(){Oi(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){Ze(this);const{blockLen:n,state:r}=this;t=Bt(t);const s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let c=0;c<i;c++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,n&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Ze(this,!1),fr(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return rn(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(mr(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new Ot(n,r,s,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}}const ki=(e,t,n)=>Sr(()=>new Ot(t,e,n)),Ri=ki(1,136,256/8);function Pi(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),c=Number(n&o),l=r?4:0,u=r?0:4;e.setUint32(t+l,i,r),e.setUint32(t+u,c,r)}class Fi extends gr{constructor(t,n,r,s){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ht(this.buffer)}update(t){Ze(this);const{view:n,buffer:r,blockLen:s}=this;t=Bt(t);const o=t.length;for(let i=0;i<o;){const c=Math.min(s-this.pos,o-i);if(c===s){const l=ht(t);for(;s<=o-i;i+=s)this.process(l,i);continue}r.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ze(this),mr(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:o}=this;let{pos:i}=this;n[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(r,0),i=0);for(let d=i;d<s;d++)n[d]=0;Pi(r,s-8,BigInt(this.length*8),o),this.process(r,0);const c=ht(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=l/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<u;d++)c.setUint32(4*d,h[d],o)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:s,finished:o,destroyed:i,pos:c}=this;return t.length=s,t.pos=c,t.finished=o,t.destroyed=i,s%n&&t.buffer.set(r),t}}const Di=(e,t,n)=>e&t^~e&n,Ui=(e,t,n)=>e&t^e&n^t&n,Li=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),se=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),oe=new Uint32Array(64);class Hi extends Fi{constructor(){super(64,32,8,!1),this.A=se[0]|0,this.B=se[1]|0,this.C=se[2]|0,this.D=se[3]|0,this.E=se[4]|0,this.F=se[5]|0,this.G=se[6]|0,this.H=se[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:c,H:l}=this;return[t,n,r,s,o,i,c,l]}set(t,n,r,s,o,i,c,l){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=c|0,this.H=l|0}process(t,n){for(let d=0;d<16;d++,n+=4)oe[d]=t.getUint32(n,!1);for(let d=16;d<64;d++){const y=oe[d-15],g=oe[d-2],A=X(y,7)^X(y,18)^y>>>3,m=X(g,17)^X(g,19)^g>>>10;oe[d]=m+oe[d-7]+A+oe[d-16]|0}let{A:r,B:s,C:o,D:i,E:c,F:l,G:u,H:h}=this;for(let d=0;d<64;d++){const y=X(c,6)^X(c,11)^X(c,25),g=h+y+Di(c,l,u)+Li[d]+oe[d]|0,m=(X(r,2)^X(r,13)^X(r,22))+Ui(r,s,o)|0;h=u,u=l,l=c,c=i+g|0,i=o,o=s,s=r,r=g+m|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,c=c+this.E|0,l=l+this.F|0,u=u+this.G|0,h=h+this.H|0,this.set(r,s,o,i,c,l,u,h)}roundClean(){oe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Er=Sr(()=>new Hi);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ar=BigInt(0),st=BigInt(1),$i=BigInt(2),ot=e=>e instanceof Uint8Array,ji=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function de(e){if(!ot(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=ji[e[n]];return t}function Tr(e){const t=e.toString(16);return t.length&1?`0${t}`:t}function kt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}function he(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(e.length%2)throw new Error("hex string is invalid: unpadded "+e.length);const t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++){const r=n*2,s=e.slice(r,r+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("invalid byte sequence");t[n]=o}return t}function Y(e){return kt(de(e))}function Rt(e){if(!ot(e))throw new Error("Uint8Array expected");return kt(de(Uint8Array.from(e).reverse()))}const Se=(e,t)=>he(e.toString(16).padStart(t*2,"0")),vr=(e,t)=>Se(e,t).reverse(),zi=e=>he(Tr(e));function V(e,t,n){let r;if(typeof t=="string")try{r=he(t)}catch(o){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${o}`)}else if(ot(t))r=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(`${e} expected ${n} bytes, got ${s}`);return r}function Pe(...e){const t=new Uint8Array(e.reduce((r,s)=>r+s.length,0));let n=0;return e.forEach(r=>{if(!ot(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}function Vi(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Mi(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function qi(e){let t;for(t=0;e>Ar;e>>=st,t+=1);return t}const Gi=(e,t)=>e>>BigInt(t)&st,Wi=(e,t,n)=>e|(n?st:Ar)<<BigInt(t),at=e=>($i<<BigInt(e-1))-st,ft=e=>new Uint8Array(e),cn=e=>Uint8Array.from(e);function xr(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=ft(e),s=ft(e),o=0;const i=()=>{r.fill(1),s.fill(0),o=0},c=(...d)=>n(s,r,...d),l=(d=ft())=>{s=c(cn([0]),d),r=c(),d.length!==0&&(s=c(cn([1]),d),r=c())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const y=[];for(;d<t;){r=c();const g=r.slice();y.push(g),d+=r.length}return Pe(...y)};return(d,y)=>{i(),l(d);let g;for(;!(g=y(u()));)l();return i(),g}}const Ki={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function He(e,t,n={}){const r=(s,o,i)=>{const c=Ki[o];if(typeof c!="function")throw new Error(`Invalid validator "${o}", expected function`);const l=e[s];if(!(i&&l===void 0)&&!c(l,e))throw new Error(`Invalid param ${String(s)}=${l} (${typeof l}), expected ${o}`)};for(const[s,o]of Object.entries(t))r(s,o,!1);for(const[s,o]of Object.entries(n))r(s,o,!0);return e}const Zi=Object.freeze(Object.defineProperty({__proto__:null,bitGet:Gi,bitLen:qi,bitMask:at,bitSet:Wi,bytesToHex:de,bytesToNumberBE:Y,bytesToNumberLE:Rt,concatBytes:Pe,createHmacDrbg:xr,ensureBytes:V,equalBytes:Vi,hexToBytes:he,hexToNumber:kt,numberToBytesBE:Se,numberToBytesLE:vr,numberToHexUnpadded:Tr,numberToVarBytesBE:zi,utf8ToBytes:Mi,validateObject:He},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const L=BigInt(0),F=BigInt(1),ie=BigInt(2),Yi=BigInt(3),wt=BigInt(4),ln=BigInt(5),un=BigInt(8);BigInt(9);BigInt(16);function M(e,t){const n=e%t;return n>=L?n:t+n}function Ji(e,t,n){if(n<=L||t<L)throw new Error("Expected power/modulo > 0");if(n===F)return L;let r=F;for(;t>L;)t&F&&(r=r*e%n),e=e*e%n,t>>=F;return r}function yt(e,t){if(e===L||t<=L)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=M(e,t),r=t,s=L,o=F;for(;n!==L;){const c=r/n,l=r%n,u=s-o*c;r=n,n=l,s=o,o=u}if(r!==F)throw new Error("invert: does not exist");return M(s,t)}function Xi(e){const t=(e-F)/ie;let n,r,s;for(n=e-F,r=0;n%ie===L;n/=ie,r++);for(s=ie;s<e&&Ji(s,t,e)!==e-F;s++);if(r===1){const i=(e+F)/wt;return function(l,u){const h=l.pow(u,i);if(!l.eql(l.sqr(h),u))throw new Error("Cannot find square root");return h}}const o=(n+F)/ie;return function(c,l){if(c.pow(l,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let u=r,h=c.pow(c.mul(c.ONE,s),n),d=c.pow(l,o),y=c.pow(l,n);for(;!c.eql(y,c.ONE);){if(c.eql(y,c.ZERO))return c.ZERO;let g=1;for(let m=c.sqr(y);g<u&&!c.eql(m,c.ONE);g++)m=c.sqr(m);const A=c.pow(h,F<<BigInt(u-g-1));h=c.sqr(A),d=c.mul(d,A),y=c.mul(y,h),u=g}return d}}function Qi(e){if(e%wt===Yi){const t=(e+F)/wt;return function(r,s){const o=r.pow(s,t);if(!r.eql(r.sqr(o),s))throw new Error("Cannot find square root");return o}}if(e%un===ln){const t=(e-ln)/un;return function(r,s){const o=r.mul(s,ie),i=r.pow(o,t),c=r.mul(s,i),l=r.mul(r.mul(c,ie),i),u=r.mul(c,r.sub(l,r.ONE));if(!r.eql(r.sqr(u),s))throw new Error("Cannot find square root");return u}}return Xi(e)}const ec=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Pt(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=ec.reduce((r,s)=>(r[s]="function",r),t);return He(e,n)}function Ir(e,t,n){if(n<L)throw new Error("Expected power > 0");if(n===L)return e.ONE;if(n===F)return t;let r=e.ONE,s=t;for(;n>L;)n&F&&(r=e.mul(r,s)),s=e.sqr(s),n>>=F;return r}function tc(e,t){const n=new Array(t.length),r=t.reduce((o,i,c)=>e.is0(i)?o:(n[c]=o,e.mul(o,i)),e.ONE),s=e.inv(r);return t.reduceRight((o,i,c)=>e.is0(i)?o:(n[c]=e.mul(o,n[c]),e.mul(o,i)),s),n}function Ft(e,t){const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Dt(e,t,n=!1,r={}){if(e<=L)throw new Error(`Expected Fp ORDER > 0, got ${e}`);const{nBitLength:s,nByteLength:o}=Ft(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=Qi(e),c=Object.freeze({ORDER:e,BITS:s,BYTES:o,MASK:at(s),ZERO:L,ONE:F,create:l=>M(l,e),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return L<=l&&l<e},is0:l=>l===L,isOdd:l=>(l&F)===F,neg:l=>M(-l,e),eql:(l,u)=>l===u,sqr:l=>M(l*l,e),add:(l,u)=>M(l+u,e),sub:(l,u)=>M(l-u,e),mul:(l,u)=>M(l*u,e),pow:(l,u)=>Ir(c,l,u),div:(l,u)=>M(l*yt(u,e),e),sqrN:l=>l*l,addN:(l,u)=>l+u,subN:(l,u)=>l-u,mulN:(l,u)=>l*u,inv:l=>yt(l,e),sqrt:r.sqrt||(l=>i(c,l)),invertBatch:l=>tc(c,l),cmov:(l,u,h)=>h?u:l,toBytes:l=>n?vr(l,o):Se(l,o),fromBytes:l=>{if(l.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${l.length}`);return n?Rt(l):Y(l)}});return Object.freeze(c)}function nc(e,t,n=!1){e=V("privateHash",e);const r=e.length,s=Ft(t).nByteLength+8;if(s<24||r<s||r>1024)throw new Error(`hashToPrivateScalar: expected ${s}-1024 bytes of input, got ${r}`);const o=n?Rt(e):Y(e);return M(o,t-F)+F}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function rc(e){const{Fp:t}=e;Pt(t);for(const l of["t","roundsFull","roundsPartial"])if(typeof e[l]!="number"||!Number.isSafeInteger(e[l]))throw new Error(`Poseidon: invalid param ${l}=${e[l]} (${typeof e[l]})`);if(e.reversePartialPowIdx!==void 0&&typeof e.reversePartialPowIdx!="boolean")throw new Error(`Poseidon: invalid param reversePartialPowIdx=${e.reversePartialPowIdx}`);let n=e.sboxPower;if(n===void 0&&(n=5),typeof n!="number"||!Number.isSafeInteger(n))throw new Error(`Poseidon wrong sboxPower=${n}`);const r=BigInt(n);let s=l=>Ir(t,l,r);if(n===3?s=l=>t.mul(t.sqrN(l),l):n===5&&(s=l=>t.mul(t.sqrN(t.sqrN(l)),l)),e.roundsFull%2!==0)throw new Error(`Poseidon roundsFull is not even: ${e.roundsFull}`);const o=e.roundsFull+e.roundsPartial;if(!Array.isArray(e.roundConstants)||e.roundConstants.length!==o)throw new Error("Poseidon: wrong round constants");const i=e.roundConstants.map(l=>{if(!Array.isArray(l)||l.length!==e.t)throw new Error(`Poseidon wrong round constants: ${l}`);return l.map(u=>{if(typeof u!="bigint"||!t.isValid(u))throw new Error(`Poseidon wrong round constant=${u}`);return t.create(u)})});if(!Array.isArray(e.mds)||e.mds.length!==e.t)throw new Error("Poseidon: wrong MDS matrix");const c=e.mds.map(l=>{if(!Array.isArray(l)||l.length!==e.t)throw new Error(`Poseidon MDS matrix row: ${l}`);return l.map(u=>{if(typeof u!="bigint")throw new Error(`Poseidon MDS matrix value=${u}`);return t.create(u)})});return Object.freeze({...e,rounds:o,sboxFn:s,roundConstants:i,mds:c})}function sc(e){const{t,Fp:n,rounds:r,sboxFn:s,reversePartialPowIdx:o}=rc(e),i=Math.floor(e.roundsFull/2),c=o?t-1:0,l=(h,d,y)=>(h=h.map((g,A)=>n.add(g,e.roundConstants[y][A])),d?h=h.map(g=>s(g)):h[c]=s(h[c]),h=e.mds.map(g=>g.reduce((A,m,S)=>n.add(A,n.mulN(m,h[S])),n.ZERO)),h),u=function(d){if(!Array.isArray(d)||d.length!==t)throw new Error(`Poseidon: wrong values (expected array of bigints with length ${t})`);d=d.map(g=>{if(typeof g!="bigint")throw new Error(`Poseidon: wrong value=${g} (${typeof g})`);return n.create(g)});let y=0;for(let g=0;g<i;g++)d=l(d,!0,y++);for(let g=0;g<e.roundsPartial;g++)d=l(d,!1,y++);for(let g=0;g<i;g++)d=l(d,!0,y++);if(y!==r)throw new Error(`Poseidon: wrong number of rounds: last round=${y}, total=${r}`);return d};return u.roundConstants=e.roundConstants,u}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const oc=BigInt(0),mt=BigInt(1);function ac(e,t){const n=(s,o)=>{const i=o.negate();return s?i:o},r=s=>{const o=Math.ceil(t/s)+1,i=2**(s-1);return{windows:o,windowSize:i}};return{constTimeNegate:n,unsafeLadder(s,o){let i=e.ZERO,c=s;for(;o>oc;)o&mt&&(i=i.add(c)),c=c.double(),o>>=mt;return i},precomputeWindow(s,o){const{windows:i,windowSize:c}=r(o),l=[];let u=s,h=u;for(let d=0;d<i;d++){h=u,l.push(h);for(let y=1;y<c;y++)h=h.add(u),l.push(h);u=h.double()}return l},wNAF(s,o,i){const{windows:c,windowSize:l}=r(s);let u=e.ZERO,h=e.BASE;const d=BigInt(2**s-1),y=2**s,g=BigInt(s);for(let A=0;A<c;A++){const m=A*l;let S=Number(i&d);i>>=g,S>l&&(S-=y,i+=mt);const E=m,T=m+Math.abs(S)-1,x=A%2!==0,B=S<0;S===0?h=h.add(n(x,o[E])):u=u.add(n(B,o[T]))}return{p:u,f:h}},wNAFCached(s,o,i,c){const l=s._WINDOW_SIZE||1;let u=o.get(s);return u||(u=this.precomputeWindow(s,l),l!==1&&o.set(s,c(u))),this.wNAF(l,u,i)}}}function Cr(e){return Pt(e.Fp),He(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ft(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ic(e){const t=Cr(e);He(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:s}=t;if(n){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:cc,hexToBytes:lc}=Zi,ce={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(e){const{Err:t}=ce;if(e.length<2||e[0]!==2)throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:cc(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=ce,n=typeof e=="string"?lc(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:s,l:o}=ce._parseInt(n.subarray(2)),{d:i,l:c}=ce._parseInt(o);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(e){const t=u=>Number.parseInt(u[0],16)&8?"00"+u:u,n=u=>{const h=u.toString(16);return h.length&1?`0${h}`:h},r=t(n(e.s)),s=t(n(e.r)),o=r.length/2,i=s.length/2,c=n(o),l=n(i);return`30${n(i+o+4)}02${l}${s}02${c}${r}`}},Q=BigInt(0),W=BigInt(1);BigInt(2);const dn=BigInt(3);BigInt(4);function uc(e){const t=ic(e),{Fp:n}=t,r=t.toBytes||((A,m,S)=>{const E=m.toAffine();return Pe(Uint8Array.from([4]),n.toBytes(E.x),n.toBytes(E.y))}),s=t.fromBytes||(A=>{const m=A.subarray(1),S=n.fromBytes(m.subarray(0,n.BYTES)),E=n.fromBytes(m.subarray(n.BYTES,2*n.BYTES));return{x:S,y:E}});function o(A){const{a:m,b:S}=t,E=n.sqr(A),T=n.mul(E,A);return n.add(n.add(T,n.mul(A,m)),S)}if(!n.eql(n.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function i(A){return typeof A=="bigint"&&Q<A&&A<t.n}function c(A){if(!i(A))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(A){const{allowedPrivateKeyLengths:m,nByteLength:S,wrapPrivateKey:E,n:T}=t;if(m&&typeof A!="bigint"){if(A instanceof Uint8Array&&(A=de(A)),typeof A!="string"||!m.includes(A.length))throw new Error("Invalid key");A=A.padStart(S*2,"0")}let x;try{x=typeof A=="bigint"?A:Y(V("private key",A,S))}catch{throw new Error(`private key must be ${S} bytes, hex or bigint, not ${typeof A}`)}return E&&(x=M(x,T)),c(x),x}const u=new Map;function h(A){if(!(A instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(m,S,E){if(this.px=m,this.py=S,this.pz=E,m==null||!n.isValid(m))throw new Error("x required");if(S==null||!n.isValid(S))throw new Error("y required");if(E==null||!n.isValid(E))throw new Error("z required")}static fromAffine(m){const{x:S,y:E}=m||{};if(!m||!n.isValid(S)||!n.isValid(E))throw new Error("invalid affine point");if(m instanceof d)throw new Error("projective point not allowed");const T=x=>n.eql(x,n.ZERO);return T(S)&&T(E)?d.ZERO:new d(S,E,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){const S=n.invertBatch(m.map(E=>E.pz));return m.map((E,T)=>E.toAffine(S[T])).map(d.fromAffine)}static fromHex(m){const S=d.fromAffine(s(V("pointHex",m)));return S.assertValidity(),S}static fromPrivateKey(m){return d.BASE.multiply(l(m))}_setWindowSize(m){this._WINDOW_SIZE=m,u.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:m,y:S}=this.toAffine();if(!n.isValid(m)||!n.isValid(S))throw new Error("bad point: x or y not FE");const E=n.sqr(S),T=o(m);if(!n.eql(E,T))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:m}=this.toAffine();if(n.isOdd)return!n.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){h(m);const{px:S,py:E,pz:T}=this,{px:x,py:B,pz:N}=m,v=n.eql(n.mul(S,N),n.mul(x,T)),I=n.eql(n.mul(E,N),n.mul(B,T));return v&&I}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:m,b:S}=t,E=n.mul(S,dn),{px:T,py:x,pz:B}=this;let N=n.ZERO,v=n.ZERO,I=n.ZERO,_=n.mul(T,T),q=n.mul(x,x),P=n.mul(B,B),O=n.mul(T,x);return O=n.add(O,O),I=n.mul(T,B),I=n.add(I,I),N=n.mul(m,I),v=n.mul(E,P),v=n.add(N,v),N=n.sub(q,v),v=n.add(q,v),v=n.mul(N,v),N=n.mul(O,N),I=n.mul(E,I),P=n.mul(m,P),O=n.sub(_,P),O=n.mul(m,O),O=n.add(O,I),I=n.add(_,_),_=n.add(I,_),_=n.add(_,P),_=n.mul(_,O),v=n.add(v,_),P=n.mul(x,B),P=n.add(P,P),_=n.mul(P,O),N=n.sub(N,_),I=n.mul(P,q),I=n.add(I,I),I=n.add(I,I),new d(N,v,I)}add(m){h(m);const{px:S,py:E,pz:T}=this,{px:x,py:B,pz:N}=m;let v=n.ZERO,I=n.ZERO,_=n.ZERO;const q=t.a,P=n.mul(t.b,dn);let O=n.mul(S,x),$=n.mul(E,B),j=n.mul(T,N),ee=n.add(S,E),p=n.add(x,B);ee=n.mul(ee,p),p=n.add(O,$),ee=n.sub(ee,p),p=n.add(S,T);let b=n.add(x,N);return p=n.mul(p,b),b=n.add(O,j),p=n.sub(p,b),b=n.add(E,T),v=n.add(B,N),b=n.mul(b,v),v=n.add($,j),b=n.sub(b,v),_=n.mul(q,p),v=n.mul(P,j),_=n.add(v,_),v=n.sub($,_),_=n.add($,_),I=n.mul(v,_),$=n.add(O,O),$=n.add($,O),j=n.mul(q,j),p=n.mul(P,p),$=n.add($,j),j=n.sub(O,j),j=n.mul(q,j),p=n.add(p,j),O=n.mul($,p),I=n.add(I,O),O=n.mul(b,p),v=n.mul(ee,v),v=n.sub(v,O),O=n.mul(ee,$),_=n.mul(b,_),_=n.add(_,O),new d(v,I,_)}subtract(m){return this.add(m.negate())}is0(){return this.equals(d.ZERO)}wNAF(m){return g.wNAFCached(this,u,m,S=>{const E=n.invertBatch(S.map(T=>T.pz));return S.map((T,x)=>T.toAffine(E[x])).map(d.fromAffine)})}multiplyUnsafe(m){const S=d.ZERO;if(m===Q)return S;if(c(m),m===W)return this;const{endo:E}=t;if(!E)return g.unsafeLadder(this,m);let{k1neg:T,k1:x,k2neg:B,k2:N}=E.splitScalar(m),v=S,I=S,_=this;for(;x>Q||N>Q;)x&W&&(v=v.add(_)),N&W&&(I=I.add(_)),_=_.double(),x>>=W,N>>=W;return T&&(v=v.negate()),B&&(I=I.negate()),I=new d(n.mul(I.px,E.beta),I.py,I.pz),v.add(I)}multiply(m){c(m);let S=m,E,T;const{endo:x}=t;if(x){const{k1neg:B,k1:N,k2neg:v,k2:I}=x.splitScalar(S);let{p:_,f:q}=this.wNAF(N),{p:P,f:O}=this.wNAF(I);_=g.constTimeNegate(B,_),P=g.constTimeNegate(v,P),P=new d(n.mul(P.px,x.beta),P.py,P.pz),E=_.add(P),T=q.add(O)}else{const{p:B,f:N}=this.wNAF(S);E=B,T=N}return d.normalizeZ([E,T])[0]}multiplyAndAddUnsafe(m,S,E){const T=d.BASE,x=(N,v)=>v===Q||v===W||!N.equals(T)?N.multiplyUnsafe(v):N.multiply(v),B=x(this,S).add(x(m,E));return B.is0()?void 0:B}toAffine(m){const{px:S,py:E,pz:T}=this,x=this.is0();m==null&&(m=x?n.ONE:n.inv(T));const B=n.mul(S,m),N=n.mul(E,m),v=n.mul(T,m);if(x)return{x:n.ZERO,y:n.ZERO};if(!n.eql(v,n.ONE))throw new Error("invZ was invalid");return{x:B,y:N}}isTorsionFree(){const{h:m,isTorsionFree:S}=t;if(m===W)return!0;if(S)return S(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:m,clearCofactor:S}=t;return m===W?this:S?S(d,this):this.multiplyUnsafe(t.h)}toRawBytes(m=!0){return this.assertValidity(),r(d,this,m)}toHex(m=!0){return de(this.toRawBytes(m))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const y=t.nBitLength,g=ac(d,t.endo?Math.ceil(y/2):y);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:l,weierstrassEquation:o,isWithinCurveOrder:i}}function dc(e){const t=Cr(e);return He(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function hc(e){const t=dc(e),{Fp:n,n:r}=t,s=n.BYTES+1,o=2*n.BYTES+1;function i(p){return Q<p&&p<n.ORDER}function c(p){return M(p,r)}function l(p){return yt(p,r)}const{ProjectivePoint:u,normPrivateKeyToScalar:h,weierstrassEquation:d,isWithinCurveOrder:y}=uc({...t,toBytes(p,b,C){const R=b.toAffine(),k=n.toBytes(R.x),H=Pe;return C?H(Uint8Array.from([b.hasEvenY()?2:3]),k):H(Uint8Array.from([4]),k,n.toBytes(R.y))},fromBytes(p){const b=p.length,C=p[0],R=p.subarray(1);if(b===s&&(C===2||C===3)){const k=Y(R);if(!i(k))throw new Error("Point is not on curve");const H=d(k);let G=n.sqrt(H);const z=(G&W)===W;return(C&1)===1!==z&&(G=n.neg(G)),{x:k,y:G}}else if(b===o&&C===4){const k=n.fromBytes(R.subarray(0,n.BYTES)),H=n.fromBytes(R.subarray(n.BYTES,2*n.BYTES));return{x:k,y:H}}else throw new Error(`Point of length ${b} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),g=p=>de(Se(p,t.nByteLength));function A(p){const b=r>>W;return p>b}function m(p){return A(p)?c(-p):p}const S=(p,b,C)=>Y(p.slice(b,C));class E{constructor(b,C,R){this.r=b,this.s=C,this.recovery=R,this.assertValidity()}static fromCompact(b){const C=t.nByteLength;return b=V("compactSignature",b,C*2),new E(S(b,0,C),S(b,C,2*C))}static fromDER(b){const{r:C,s:R}=ce.toSig(V("DER",b));return new E(C,R)}assertValidity(){if(!y(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!y(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(b){return new E(this.r,this.s,b)}recoverPublicKey(b){const{r:C,s:R,recovery:k}=this,H=I(V("msgHash",b));if(k==null||![0,1,2,3].includes(k))throw new Error("recovery id invalid");const G=k===2||k===3?C+t.n:C;if(G>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const z=k&1?"03":"02",te=u.fromHex(z+g(G)),ne=l(G),fe=c(-H*ne),Te=c(R*ne),re=u.BASE.multiplyAndAddUnsafe(te,fe,Te);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return A(this.s)}normalizeS(){return this.hasHighS()?new E(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return he(this.toDERHex())}toDERHex(){return ce.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return he(this.toCompactHex())}toCompactHex(){return g(this.r)+g(this.s)}}const T={isValidPrivateKey(p){try{return h(p),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const p=t.randomBytes(n.BYTES+8),b=nc(p,r);return Se(b,t.nByteLength)},precompute(p=8,b=u.BASE){return b._setWindowSize(p),b.multiply(BigInt(3)),b}};function x(p,b=!0){return u.fromPrivateKey(p).toRawBytes(b)}function B(p){const b=p instanceof Uint8Array,C=typeof p=="string",R=(b||C)&&p.length;return b?R===s||R===o:C?R===2*s||R===2*o:p instanceof u}function N(p,b,C=!0){if(B(p))throw new Error("first arg must be private key");if(!B(b))throw new Error("second arg must be public key");return u.fromHex(b).multiply(h(p)).toRawBytes(C)}const v=t.bits2int||function(p){const b=Y(p),C=p.length*8-t.nBitLength;return C>0?b>>BigInt(C):b},I=t.bits2int_modN||function(p){return c(v(p))},_=at(t.nBitLength);function q(p){if(typeof p!="bigint")throw new Error("bigint expected");if(!(Q<=p&&p<_))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Se(p,t.nByteLength)}function P(p,b,C=O){if(["recovered","canonical"].some(ae=>ae in C))throw new Error("sign() legacy options not supported");const{hash:R,randomBytes:k}=t;let{lowS:H,prehash:G,extraEntropy:z}=C;H==null&&(H=!0),p=V("msgHash",p),G&&(p=V("prehashed msgHash",R(p)));const te=I(p),ne=h(b),fe=[q(ne),q(te)];if(z!=null){const ae=z===!0?k(n.BYTES):z;fe.push(V("extraEntropy",ae,n.BYTES))}const Te=Pe(...fe),re=te;function ct(ae){const me=v(ae);if(!y(me))return;const jt=l(me),pe=u.BASE.multiply(me).toAffine(),Z=c(pe.x);if(Z===Q)return;const ge=c(jt*c(re+Z*ne));if(ge===Q)return;let zt=(pe.x===Z?0:2)|Number(pe.y&W),Vt=ge;return H&&A(ge)&&(Vt=m(ge),zt^=1),new E(Z,Vt,zt)}return{seed:Te,k2sig:ct}}const O={lowS:t.lowS,prehash:!1},$={lowS:t.lowS,prehash:!1};function j(p,b,C=O){const{seed:R,k2sig:k}=P(p,b,C);return xr(t.hash.outputLen,t.nByteLength,t.hmac)(R,k)}u.BASE._setWindowSize(8);function ee(p,b,C,R=$){var pe;const k=p;if(b=V("msgHash",b),C=V("publicKey",C),"strict"in R)throw new Error("options.strict was renamed to lowS");const{lowS:H,prehash:G}=R;let z,te;try{if(typeof k=="string"||k instanceof Uint8Array)try{z=E.fromDER(k)}catch(Z){if(!(Z instanceof ce.Err))throw Z;z=E.fromCompact(k)}else if(typeof k=="object"&&typeof k.r=="bigint"&&typeof k.s=="bigint"){const{r:Z,s:ge}=k;z=new E(Z,ge)}else throw new Error("PARSE");te=u.fromHex(C)}catch(Z){if(Z.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(H&&z.hasHighS())return!1;G&&(b=t.hash(b));const{r:ne,s:fe}=z,Te=I(b),re=l(fe),ct=c(Te*re),ae=c(ne*re),me=(pe=u.BASE.multiplyAndAddUnsafe(te,ct,ae))==null?void 0:pe.toAffine();return me?c(me.x)===ne:!1}return{CURVE:t,getPublicKey:x,getSharedSecret:N,sign:j,verify:ee,ProjectivePoint:u,Signature:E,utils:T}}function bt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function fc(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function _r(e,...t){if(!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new TypeError(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function mc(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");bt(e.outputLen),bt(e.blockLen)}function pc(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function gc(e,t){_r(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const qe={number:bt,bool:fc,bytes:_r,hash:mc,exists:pc,output:gc},pt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Sc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Sc)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function wc(e){if(typeof e!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function yc(e){if(typeof e=="string"&&(e=wc(e)),!(e instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof e})`);return e}function bc(...e){if(!e.every(r=>r instanceof Uint8Array))throw new Error("Uint8Array list expected");if(e.length===1)return e[0];const t=e.reduce((r,s)=>r+s.length,0),n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const o=e[r];n.set(o,s),s+=o.length}return n}class Ec{clone(){return this._cloneInto()}}function Ac(e=32){if(pt&&typeof pt.getRandomValues=="function")return pt.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}class Nr extends Ec{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,qe.hash(t);const r=yc(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(r.length>s?t.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(t){return qe.exists(this),this.iHash.update(t),this}digestInto(t){qe.exists(this),qe.bytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:s,destroyed:o,blockLen:i,outputLen:c}=this;return t=t,t.finished=s,t.destroyed=o,t.blockLen=i,t.outputLen=c,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Br=(e,t,n)=>new Nr(e,t).update(n).digest();Br.create=(e,t)=>new Nr(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Tc(e){return{hash:e,hmac:(t,...n)=>Br(e,t,bc(...n)),randomBytes:Ac}}const hn=BigInt("3618502788666131213697322783095070105526743751716087489154079457884512865583"),Or=252;function fn(e){for(;e[0]===0;)e=e.subarray(1);const t=e.length*8-Or,n=Y(e);return t>0?n>>BigInt(t):n}function kr(e){return typeof e=="string"&&(e=Ic(e),e.length&1&&(e="0"+e)),he(e)}const Rr=hc({a:BigInt(1),b:BigInt("3141592653589793238462643383279502884197169399375105820974944592307816406665"),Fp:Dt(BigInt("0x800000000000011000000000000000000000000000000000000000000000001")),n:hn,nBitLength:Or,Gx:BigInt("874739451078007766457464989774322083649278607533249481151382481072868806602"),Gy:BigInt("152666792071518830868575557812948353041420400780739481342941381225525861407"),h:BigInt(1),lowS:!1,...Tc(Er),bits2int:fn,bits2int_modN:e=>{const t=Y(e).toString(16);return t.length===63&&(e=kr(t+"0")),M(fn(e),hn)}});function vc(e){return V("",typeof e=="string"?kr(e):e)}const{CURVE:ql,ProjectivePoint:Ce,Signature:Gl,utils:Wl}=Rr;function xc(e){return`0x${de(e.subarray(1)).replace(/^0+/gm,"")}`}function Ic(e){return e.replace(/^0x/i,"")}const Fe=[new Ce(2089986280348253421170679821480865132823066470938446095505822317253594081284n,1713931329540660377023406109199410414810705867260802078187082345529207694986n,1n),new Ce(996781205833008774514500082376783249102396023663454813447423147977397232763n,1668503676786377725805489344771023921079126552019160156920634619255970485781n,1n),new Ce(2251563274489750535117886426533222435294046428347329203627021249169616184184n,1798716007562728905295480679789526322175868328062420237419143593021674992973n,1n),new Ce(2138414695194151160943305727036575959195309218611738193261179310511854807447n,113410276730064486255102093846540133784865286929052426931474106396135072156n,1n),new Ce(2379962749567351885752724891227938183011949129833673362440656643086021394946n,776496453633298175483985398648758586525933812536653089401905292063708816422n,1n)];function Pr(e,t){const n=[];let r=e;for(let s=0;s<248;s++)n.push(r),r=r.double();r=t;for(let s=0;s<4;s++)n.push(r),r=r.double();return n}const Cc=Pr(Fe[1],Fe[2]),_c=Pr(Fe[3],Fe[4]);function Nc(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"){if(!Number.isSafeInteger(e))throw new Error(`Invalid pedersenArg: ${e}`);t=BigInt(e)}else t=Y(vc(e));if(!(0n<=t&&t<Rr.CURVE.Fp.ORDER))throw new Error(`PedersenArg should be 0 <= value < CURVE.P: ${t}`);return t}function mn(e,t,n){let r=Nc(t);for(let s=0;s<252;s++){const o=n[s];if(o.equals(e))throw new Error("Same point");(r&1n)!==0n&&(e=e.add(o)),r>>=1n}return e}function Bc(e,t){let n=Fe[0];return n=mn(n,e,Cc),n=mn(n,t,_c),xc(n.toRawBytes(!0))}const Oc=at(250),kc=e=>Y(Ri(e))&Oc;Dt(BigInt("14474011154664525231415395255581126252639794253786371766033694892385558855681"));const Rc=Dt(BigInt("3618502788666131213697322783095070105623107215331596699973092056135872020481"));function Pc(e,t,n){const r=e.fromBytes(Er(pr(`${t}${n}`)));return e.create(r)}const Fc=[[3,1,1],[1,-1,1],[1,1,-2]].map(e=>e.map(BigInt));function Dc(e,t){if(Pt(e.Fp),!Number.isSafeInteger(e.rate)||!Number.isSafeInteger(e.capacity))throw new Error(`Wrong poseidon opts: ${e}`);const n=e.rate+e.capacity,r=e.roundsFull+e.roundsPartial,s=[];for(let i=0;i<r;i++){const c=[];for(let l=0;l<n;l++)c.push(Pc(e.Fp,"Hades",n*i+l));s.push(c)}const o=sc({...e,t:n,sboxPower:3,reversePartialPowIdx:!0,mds:t,roundConstants:s});return o.m=n,o.rate=e.rate,o.capacity=e.capacity,o}Dc({Fp:Rc,rate:2,capacity:1,roundsFull:8,roundsPartial:83},Fc);exports.RecoveryStatusEnum=void 0;(function(e){e.NOT_STARTED="NOT_STARTED",e.ONGOING="ONGOING",e.AWAITING_FUNDS="AWAITING_FUNDS",e.AWAITING_COMPLETION="AWAITING_COMPLETION",e.COMPLETED="COMPLETED",e.CANCELLED="CANCELLED",e.ERROR="ERROR"})(exports.RecoveryStatusEnum||(exports.RecoveryStatusEnum={}));const Fr=f.z.object({recoveryId:f.z.number()}),Uc=f.z.object({feeToken:a.addressSchema,signerSignature:f.z.object({type:f.z.literal("StarknetKey"),signer:f.z.object({publicKey:a.hexSchema,r:a.hexSchema,s:a.hexSchema})})}),Dr=f.z.nativeEnum(exports.RecoveryStatusEnum),Ut=f.z.object({recoveryId:f.z.number(),status:Dr,completionTime:f.z.array(f.z.number()).optional()}),Ur=f.z.object({activeRecovery:Ut.optional().or(f.z.null()).optional(),minFees:f.z.record(f.z.number()).optional()}),Lr=f.z.object({recovery:Ut.optional().or(f.z.null()).optional(),minFees:f.z.record(f.z.number()).optional()});exports.StartOnchainRecoveryErrorStatusEnum=void 0;(function(e){e.UNDEPLOYED_ACCOUNT="undeployedAccount",e.NOT_ENOUGH_TO_PAY_FEES="notEnoughToPayFees",e.RECOVERY_ALREADY_EXISTS="recoveryAlreadyExists"})(exports.StartOnchainRecoveryErrorStatusEnum||(exports.StartOnchainRecoveryErrorStatusEnum={}));const Hr=f.z.nativeEnum(exports.StartOnchainRecoveryErrorStatusEnum),Lc=f.z.object({status:Hr});class Hc{constructor(t,n){this.apiBase=t,this.httpService=n}async getRecovery(t,n){const r=a.urlJoin(this.apiBase,"accounts","starknet",t,"recovery",`${n}`),s=await this.httpService.get(r),o=Lr.safeParse(s);return o.error?null:o.data}async getActiveRecovery(t){const n=a.urlJoin(this.apiBase,"accounts","starknet",t,"recovery"),r=await this.httpService.get(n),s=Ur.safeParse(r);return s.error?null:s.data}async startRecovery(t,n,r,s){const{r:o,s:i}=w.ec.starkCurve.sign(Bc(kc(Ne.stringToBytes("utf8","starknet:recovery")),r),s),c={feeToken:n,signerSignature:{type:"StarknetKey",signer:{publicKey:r,r:w.encode.addHexPrefix(o.toString(16)),s:w.encode.addHexPrefix(i.toString(16))}}};return await this.httpService.post(`${this.apiBase}/accounts/starknet/${t}/recovery`,{body:JSON.stringify(c)},Fr)}async completeRecovery(t,n){const r=a.urlJoin(this.apiBase,"accounts","starknet",t,"recovery",`${n}`,"complete");return await this.httpService.post(r)}}async function $c(){if("brave"in navigator)try{return await navigator.brave.isBrave()}catch{}return!1}let gt;function $r(){return gt||(gt=new ns.UAParser(navigator.userAgent).getResult()),gt}function $e(e){return $r().browser.name===e}function jc(){return $e("Firefox")}function zc(){return $e("Chrome")}function Vc(){return $e("Safari")}function Mc(){return $e("Edge")}const qc=f.z.string().refine(e=>rs.validateMnemonic(e,ss.wordlist),"Invalid seedphrase"),Lt=[{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",name:"Ether",symbol:"ETH",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/eth.png"},{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",name:"Ether",symbol:"ETH",decimals:18,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/eth.png"},{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",name:"Ether",symbol:"ETH",decimals:18,networkId:"localhost",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/eth.png"},{address:"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",name:"Starknet",symbol:"STRK",decimals:"18",networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/strk.png"},{address:"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",name:"Starknet",symbol:"STRK",decimals:"18",networkId:"integration",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/strk.png"},{address:"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",name:"Starknet",symbol:"STRK",decimals:"18",networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/strk.png"},{address:"0x00da114221cb83fa859dbdb4c44beeaa0bb37c7537ad5ae66fe5e0efd20e6eb3",name:"DAI",symbol:"DAI",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/dai.png"},{address:"0x03e85bfbb8e2a42b7bead9e88e9a1b19dbccf661471061807292120462396ec9",name:"DAI",symbol:"DAI",decimals:18,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/dai.png"},{address:"0x06f2a0dfeff180133de890ad69c6ba294574c5f34a67890fd22464f348c4d03c",name:"DAI",symbol:"DAI",decimals:18,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/dai.png"},{address:"0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",name:"Wrapped BTC",symbol:"WBTC",decimals:8,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/wbtc.png"},{address:"0x12d537dc323c439dc65c976fad242d5610d27cfb5f31689a0a319b8be7f3d56",name:"Wrapped BTC",symbol:"WBTC",decimals:8,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/wbtc.png"},{address:"0x020d208b9e57a7f92bfa9f61135446e0961afc340378be97dbd317453c0950ae",name:"Wrapped BTC",symbol:"WBTC",decimals:8,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/wbtc.png"},{address:"0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",name:"USD Coin",symbol:"USDC",decimals:6,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdc.png"},{address:"0x005a643907b9a4bc6a55e9069c4fd5fd1f5c79a22470690f75556c4736e34426",name:"USD Coin",symbol:"USDC",decimals:6,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdc.png"},{address:"0x07ab0b8855a61f480b4423c46c32fa7c553f0aac3531bbddaa282d86244f7a23",name:"USD Coin",symbol:"USDC",decimals:6,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdc.png"},{address:"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",name:"Tether USD",symbol:"USDT",decimals:6,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdt.png"},{address:"0x386e8d061177f19b3b485c20e31137e6f6bc497cc635ccdfcab96fadf5add6a",name:"Tether USD",symbol:"USDT",decimals:6,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdt.png"},{address:"0x00585c32b625999e6e5e78645ff8df7a9001cf5cf3eb6b80ccdd16cb64bd3a34",name:"zkLend Token",symbol:"ZEND",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/zend.png"},{address:"0x06ea04cd7e40bfef07c3625e2b3472839093d966bf601568128436466f962fcf",name:"Baby Laika",symbol:"BABYLAIKA",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/babylaika.png"},{address:"0x004a8ff6a7b121c55d5e21af478265c5798f574abaa41efadf569d6939705896",name:"Baby Laika",symbol:"BABYLAIKA",decimals:18,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/babylaika.png"},{address:"0x0782f0ddca11d9950bc3220e35ac82cf868778edb67a5e58b39838544bc4cd0f",name:"Starknet Voting Token",symbol:"vSTRK",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/vstrk.png"},{address:"0x075afe6402ad5a5c20dd25e10ec3b3986acaa647b77e4ae24b0cbc9a54a27a87",name:"Ekubo Protocol",symbol:"EKUBO",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/ekubo.png"}],jr=async(e,t,n)=>{const r=await n.callContract({contractAddress:e,entrypoint:"balanceOf",calldata:[t]});return BigInt(w.num.toHex(w.uint256.uint256ToBN({low:r[0],high:r[1]})))},Gc=async(e,t,n)=>{const r=Lt.filter(o=>o.networkId===e);return(await Promise.allSettled(r.map(o=>t.callContract({contractAddress:o.address,entrypoint:"balanceOf",calldata:[n]})))).reduce((o,i,c)=>{if(i.status==="fulfilled"&&U.isUndefined(i.value)||i.status==="rejected"||i.value[0]==="0x0"&&i.value[1]==="0x0")return o;const l=BigInt(w.num.toHex(w.uint256.uint256ToBN({low:i.value[0],high:i.value[1]}))),u={...r[c],balance:l};return o.push(u),o},[])},Wc=async()=>Lt,Kc=({address:e,networkId:t})=>Lt.find(r=>r.address===e&&r.networkId===t),Zc=({amount:e,decimals:t,unitCurrencyValue:n})=>{if(!K(e)||!K(t)||!K(n))return;const r=Number(t),s=BigInt(e)*vt(n.toString()).value;return Ue({value:s,decimals:r+be})},Yc=({unitAmount:e,decimals:t})=>{if(e===void 0||!K(e)||t===void 0||!K(t))return;const n=Number(t);return a.parseUnits(e.toString(),n).value.toString()},Jc=e=>K(e)?Number(e):18,{UINT_256_MAX:Xc}=w.uint256,zr=e=>String(e)===String(Xc),Qc=(e,t="$",n)=>{if(e===void 0||!K(e))return null;const r=lr(e,n);return[t,r].filter(Boolean).join("")},Vr="Unlimited",el=({amount:e,decimals:t,symbol:n,showPlusSign:r=!1,withSymbol:s=!0,unlimitedText:o=Vr,prettyConfigOverrides:i})=>{if(!K(e))return null;let c,l=!1;if(zr(e))c=o;else{const h=Number(t),d=BigInt(e);l=d>0n;const y=h>0?Ue({value:d,decimals:h}):d.toString();c=h>0?ur(y,i):y}const u=[c,s&&n].filter(Boolean).join(" ");return r&&l?`+${u}`:u};var tl=a.retry,nl=tl;function rl(e,t){function n(r,s){var o=t||{},i;"randomize"in o||(o.randomize=!0),i=nl.operation(o);function c(h){s(h||new Error("Aborted"))}function l(h,d){if(h.bail){c(h);return}i.retry(h)?o.onRetry&&o.onRetry(h,d):s(i.mainError())}function u(h){var d;try{d=e(c,h)}catch(y){l(y,h);return}Promise.resolve(d).then(r).catch(function(g){l(g,h)})}i.attempt(u)}return new Promise(n)}var sl=rl;const ol=a.getDefaultExportFromCjs(sl);class al{constructor(t,n){this.apiBase=t,this.httpService=n,this.TOKENS_INFO_URL="/tokens/info",this.TOKENS_DEFI_DECOMPOSITION_URL="/tokens/defi/decomposition"}async fetchTokensInfoFromBackend(t){const n=a.urlJoin(this.apiBase,this.TOKENS_INFO_URL,t??"","?chain=starknet"),r=await this.httpService.get(n),s=a.apiTokensInfoResponseSchema.safeParse(r);if(s.success)return s.data.tokens;const o=a.apiTokenInfoResponseSchema.safeParse(r);if(o.success)return[o.data]}async fetchAddressTokenBalancesFromBackend(t,n,r){const s=a.urlJoin(this.apiBase,"activity","starknet",n,"account",t,"balance");return(await ol(async c=>{let l;try{l=await this.httpService.get(s)}catch{return c(new Error("Error fetching")),[]}const u=a.apiAccountTokenBalancesSchema.safeParse(l);if(!u.success)return c(new Error("Error parsing response")),[];if(u.data.status!=="initialised")throw new Error("Not initialised yet");return u.data.balances},{retries:5,minTimeout:5e3,...r})).map(c=>({address:c.tokenAddress,balance:c.tokenBalance,networkId:n}))}async fetchDefiDecomposition(t){const n=a.urlJoin(this.apiBase,this.TOKENS_DEFI_DECOMPOSITION_URL,t,"?chain=starknet"),r=await this.httpService.get(n);if(!a.apiDefiPositionsSchema.safeParse(r).success)throw new a.TokenError({code:"TOKEN_DEFI_DECOMPOSITION_PARSING_ERROR"});return r.dapps}}const il=(e,t,n,r)=>({contractAddress:e,entrypoint:"transfer",calldata:w.CallData.compile({recipient:t,amount:ye(dr(n,r))})}),cl=(e,t,n,r)=>({contractAddress:e,entrypoint:"transferFrom",calldata:w.CallData.compile({from_:t,to:n,tokenId:ye(r)})}),ll=(e,t,n,r)=>({contractAddress:e,entrypoint:"safeTransferFrom",calldata:w.CallData.compile({from_:t,to:n,tokenId:ye(r),amount:ye(1),data_len:"0"})});function Ht(e){return U.upperCase(e.unit)==="WEI"}function Mr(e){return U.upperCase(e.unit)==="FRI"}function le(e,t){return Ht(e)?{...e,maxFee:t(e.maxFee),overallFee:t(e.overallFee),gasPrice:t(e.gasPrice),gasUsage:t(e.gasUsage)}:{...e,overallFee:t(e.overallFee),gasPrice:t(e.gasPrice),gasUsage:t(e.gasUsage),maxAmount:t(e.maxAmount),maxPricePerUnit:t(e.maxPricePerUnit)}}function we(e){return Ht(e)?{maxFee:e.maxFee}:{amount:e.maxAmount,pricePerUnit:e.maxPricePerUnit}}function Ge(e){return Mr({unit:e})?a.STRK_TOKEN_ADDRESS:a.ETH_TOKEN_ADDRESS}function ul(e,t,n=2){const r=BigInt(10**n),s=BigInt(Math.round(t*10**n));return e*s/r}const dl=[a.STRK_TOKEN_ADDRESS],qr=(e,t=Yr)=>{if(e.max&&"amount"in e.max)return{...e,...e.max};const n=10000n,{amount:r,pricePerUnit:s,dataGasConsumed:o=0n,dataGasPrice:i=0n}=e,c=r*s+o*i;if(c<0)throw Error("Cannot calculate max fee for negative fee");const l=w.num.toBigInt(a.argentMaxFee({estimatedFee:c})),u=Number(l)/Number(c),h=t(u),d=BigInt(Math.trunc(h*Number(n)));return{...e,amount:r*d/n,pricePerUnit:s*d/n,dataGasConsumed:o*d/n,dataGasPrice:i*d/n}},De=e=>{const{amount:t,pricePerUnit:n,dataGasConsumed:r=0n,dataGasPrice:s=0n}=e;return t*n+r*s},Gr=e=>{if(e.max)return"maxFee"in e.max?e.max.maxFee:De(e.max)},Ye=e=>{const t=Gr(e);return t||De(qr(e))},hl=e=>{if(e.deployment&&!a.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=De(e.transactions),n=e.deployment?De(e.deployment):0n;return t+n},fl=e=>{if(e.deployment&&!a.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=e.deployment?Ye(e.deployment):0n,n=Ye(e.transactions);return t+n},ml=(e,t)=>[{contractAddress:e,entrypoint:"transfer",calldata:w.CallData.compile(a.transferCalldataSchema.parse({recipient:t,amount:w.uint256.bnToUint256(BigInt(1))}))}],Wr=(e,t)=>{if(!e)return{transactions:{feeTokenAddress:t??a.ETH_TOKEN_ADDRESS,amount:0n,pricePerUnit:0n,dataGasConsumed:0n,dataGasPrice:0n}};if(!Array.isArray(e))throw Error(`Unexpected simulation response. Expected array. Got ${typeof e}`);if(e.length===1){const n=a.feeEstimationSchema.parse(e[0].feeEstimation);return{transactions:{feeTokenAddress:Ge(n.unit),amount:w.num.toBigInt(n.gasUsage),pricePerUnit:w.num.toBigInt(n.gasPrice),max:we(le(n,w.num.toBigInt)),dataGasConsumed:n.dataGasConsumed?w.num.toBigInt(n.dataGasConsumed):0n,dataGasPrice:n.dataGasPrice?w.num.toBigInt(n.dataGasPrice):0n}}}if(e.length===2){const n=a.feeEstimationSchema.parse(e[0].feeEstimation),r=a.feeEstimationSchema.parse(e[1].feeEstimation);return{deployment:{feeTokenAddress:Ge(n.unit),amount:w.num.toBigInt(n.gasUsage),pricePerUnit:w.num.toBigInt(n.gasPrice),max:we(le(n,w.num.toBigInt)),dataGasConsumed:n.dataGasConsumed?w.num.toBigInt(n.dataGasConsumed):0n,dataGasPrice:n.dataGasPrice?w.num.toBigInt(n.dataGasPrice):0n},transactions:{feeTokenAddress:Ge(r.unit),amount:w.num.toBigInt(r.gasUsage),pricePerUnit:w.num.toBigInt(r.gasPrice),max:we(le(r,w.num.toBigInt)),dataGasConsumed:r.dataGasConsumed?w.num.toBigInt(r.dataGasConsumed):0n,dataGasPrice:r.dataGasPrice?w.num.toBigInt(r.dataGasPrice):0n}}}throw Error("Unexpected simulation response length")},Kr=({transaction:e,nonce:t,chainId:n,version:r,isDeploymentTransaction:s,cairoVersion:o,address:i,appDomain:c})=>{let l=t;s&&e.type!=="DEPLOY_ACCOUNT"&&(l=w.num.toHex(1));const u=a.ensureArray(e.calls);return{type:e.type,chainId:n,cairoVersion:o,nonce:l,version:r,account:i,calls:u,calldata:e.calldata,salt:e.salt,signature:e.signature,classHash:e.classHash,appDomain:c}},Zr=(e,t)=>{const{transactions:n}=e,r=n.map(l=>{if(!l.simulation)throw new a.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});return l}),s=r.map(l=>({...l.simulation,feeEstimation:le(l.simulation.feeEstimation,Number)})),o=Wr(s,t),[i,c]=r.length===1?[r[0],void 0]:[r[1],r[0]];return{...o,transactions:{...o.transactions,dataGasConsumed:o.transactions.dataGasConsumed??0n,dataGasPrice:o.transactions.dataGasPrice??0n,max:we(le(i.simulation.feeEstimation,w.num.toBigInt))},deployment:o.deployment&&c?{...o.deployment,dataGasConsumed:o.deployment.dataGasConsumed??0n,dataGasPrice:o.deployment.dataGasPrice??0n,max:we(le(c.simulation.feeEstimation,w.num.toBigInt))}:void 0}},pl=e=>{const t=qr(e),n=Ye(e);return{maxFee:n,resourceBounds:{l1_gas:{max_amount:w.num.toHex(n/e.pricePerUnit),max_price_per_unit:w.num.toHex(t.pricePerUnit)},l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"}}}},gl=e=>{const t=Math.sqrt(e);return isNaN(t)?Math.sqrt(2):t},Yr=e=>{const t=Math.cbrt(e);return isNaN(t)?Math.cbrt(2):t},Sl=e=>e<1||isNaN(e)?1.1:Math.log(e+1)+1,wl=[a.STRK_TOKEN_ADDRESS];function it({address:e}){return wl.some(t=>a.isEqualAddress(e,t))}function yl(e){return e?Dn().some(t=>a.isEqualAddress(t,e)):!1}function Et(e){return it({address:e})?w.constants.TRANSACTION_VERSION.V3:w.constants.TRANSACTION_VERSION.V1}function bl(e){return it({address:e})?w.constants.TRANSACTION_VERSION.F3:w.constants.TRANSACTION_VERSION.F1}function El(e,t){return w.isSierra(t.contract)?it({address:e})?w.constants.TRANSACTION_VERSION.V3:w.constants.TRANSACTION_VERSION.V2:w.constants.TRANSACTION_VERSION.V1}class Al{constructor(t,n){this.apiBase=t,this.httpService=n}async getLabels(){const t=a.urlJoin(this.apiBase,"reviewer","labels");return await this.httpService.get(t)}async getWarnings(){const t=a.urlJoin(this.apiBase,"reviewer","warnings/reasons");return await this.httpService.get(t)}async simulateAndReview(t,n,r,s,o){const i=n.some(c=>c.type==="DEPLOY_ACCOUNT");try{if(!("getChainId"in t))throw new Error("MISSING_METHOD");const c=Et(r),l=i?"0x0":await t.getNonce(),u=await t.getChainId(),h={transactions:n.map(m=>({...Kr({transaction:m,nonce:l,version:c,chainId:u,isDeploymentTransaction:i,appDomain:s,cairoVersion:t.cairoVersion,address:t.address}),type:m.type}))},d=a.urlJoin(this.apiBase,"reviewer","transactions","v2","review","starknet"),y=await this.httpService.post(d,{headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(h)},a.simulateAndReviewSchema);if(y.transactions.some(m=>a.isTransactionSimulationError(m)))return y;const A=Zr(y,r);return{...y,enrichedFeeEstimation:A}}catch(c){return console.error(c),this.fallbackToOnchainFeeEstimation({transactions:n,account:t,isDeploymentTransaction:i,feeTokenAddress:r,accountDeployTransaction:o})}}getCallsFromTx(t){let n;return t.calls&&(n=a.ensureArray(t.calls)),n}async fallbackToOnchainFeeEstimation({transactions:t,account:n,isDeploymentTransaction:r,feeTokenAddress:s,accountDeployTransaction:o}){try{const i=r?this.getCallsFromTx(t[1]):this.getCallsFromTx(t[0]);if(!i)throw new a.ReviewError({code:"NO_CALLS_FOUND"});const c=await this.fetchFeesOnchain({starknetAccount:n,calls:i,isDeployed:!r,feeTokenAddress:s,accountDeployTransaction:o});return{transactions:[],enrichedFeeEstimation:c,isBackendDown:!0}}catch(i){throw console.error(i),new a.ReviewError({message:`${i}`,code:"SIMULATE_AND_REVIEW_FAILED"})}}async fetchFeesOnchain({starknetAccount:t,calls:n,isDeployed:r,feeTokenAddress:s,accountDeployTransaction:o}){try{const i=Et(s),c={transactions:{feeTokenAddress:s,amount:0n,pricePerUnit:0n,dataGasConsumed:0n,dataGasPrice:0n}};if(!r&&o){if("estimateFeeBulk"in t){const l=[{type:w.TransactionType.DEPLOY_ACCOUNT,payload:{classHash:o.classHash,addressSalt:o.salt,constructorCalldata:o.calldata,contractAddress:t.address}},{type:w.TransactionType.INVOKE,payload:n}],[u,h]=await t.estimateFeeBulk(l,{version:i}).catch(d=>{throw console.error(d),d});if(!u.gas_consumed||!u.gas_price||!h.gas_consumed||!h.gas_price)throw new a.ReviewError({code:"ONCHAIN_FEE_ESTIMATION_FAILED",message:"Missing gas_consumed or gas_price"});c.deployment={feeTokenAddress:s,amount:u.gas_consumed,pricePerUnit:u.gas_price,dataGasConsumed:u.data_gas_consumed,dataGasPrice:u.data_gas_price},c.transactions={feeTokenAddress:s,amount:h.gas_consumed,pricePerUnit:h.gas_price,dataGasConsumed:h.data_gas_consumed,dataGasPrice:h.data_gas_price}}}else{const{gas_consumed:l,gas_price:u,data_gas_consumed:h,data_gas_price:d}=await t.estimateFee(n,{skipValidate:!0,version:i});if(!l||!u)throw new a.ReviewError({code:"ONCHAIN_FEE_ESTIMATION_FAILED",message:"Missing gas_consumed or gas_price"});c.transactions={feeTokenAddress:s,amount:l,pricePerUnit:u,dataGasConsumed:h,dataGasPrice:d}}return c}catch(i){throw new a.ReviewError({code:"ONCHAIN_FEE_ESTIMATION_FAILED",message:`${i}`})}}}const Tl=["account-upgrade","approve","set-approval-for-all","swap","transfer"],vl=e=>({showBalanceChange:D.useMemo(()=>{const n=e==null?void 0:e.some(s=>!U.isEmpty(s.transfers)),r=e==null?void 0:e.some(s=>!U.isEmpty(s.approvals));return e&&(n||r)},[e])}),je=e=>e?e.filter(t=>t.token.type==="erc20"):[],xl=e=>D.useMemo(()=>je(e),[e]),Il=e=>je(e).length>0,Cl=e=>je(e).some(n=>n.amount>0n),_l=e=>je(e).some(n=>n.amount<0n),$t=e=>e?e.filter(t=>t.token.type==="erc721"):[],Nl=e=>D.useMemo(()=>$t(e),[e]),Jr=e=>$t(e).length>0,Bl=e=>D.useMemo(()=>Jr(e),[e]),Ol=(e,t)=>D.useMemo(()=>e&&t?[{contractAddress:e.address,entrypoint:"transfer",calldata:w.CallData.compile({recipient:t,amount:ye(e.balance)})}]:[],[e,t]),kl=({apiData:{apiBaseUrl:e,apiHeaders:t},address:n,network:r,transactionReviewEnabled:s=!0,transactions:o})=>{const i=D.useCallback(async()=>{if(!n||!r)return;if(!e)throw"Transaction review endpoint is not defined";const l=a.urlJoin(e,"reviewer/transactions/review/starknet"),u=U.isArray(o)?o:[o],h={network:r,account:n,calls:u};return xt(l,{method:"POST",headers:{"Content-Type":"application/json",...t},body:JSON.stringify(h)})},[n,r,o]),c=D.useMemo(()=>os({transactions:o,address:n,network:r}),[o,n,r]);return Tn(!!s,[c,"transactionReview"],i)},Rl=e=>{if(!e)return{};const t=e.assessment==="warn"&&e.reason!=="contract_is_not_verified",n=e.reason?` (Reason: ${U.lowerCase(e.reason)})`:"",r=t?e.reason==="recipient_is_token_address"?"You are sending tokens to their own address. This is likely to burn them.":`This transaction has been flagged as dangerous. We recommend you reject this transaction unless you are sure.${n}`:void 0;return{warn:t,reason:r}},Xr=e=>{var t;if(e){for(const n of e.reviews)if(((t=n.activity)==null?void 0:t.type)==="swap")return n}},Pl=e=>{},Fl=(e,t)=>{var n;if(t){for(const r of t.reviews)if(((n=r.activity)==null?void 0:n.type)===e)return r.activity}},Dl=e=>!!Xr(e),Ul=e=>{var t,n;if(e){for(const r of e.reviews)if((t=r.activity)!=null&&t.type)return{...r,type:(n=r.activity)==null?void 0:n.type}}},Qr=async({feeTokenAddress:e,calls:t,selectedAccount:n,transactionReviewService:r,appDomain:s,accountDeployTransaction:o})=>{const i={type:"INVOKE",calls:a.ensureArray(t)};if(!n||!e)return;const c=o?[o,i]:[i];return{result:await r.simulateAndReview(n,c,e,s,o)}},es=async(e,t,n,r)=>{var y,g,A,m,S,E;let s=!1;const o=t.transactions.find(T=>{var x,B;return(B=(x=T==null?void 0:T.simulation)==null?void 0:x.summary)==null?void 0:B.find(N=>N.sent)});if(!o||!((y=o.simulation)!=null&&y.summary))return s;const i=o.simulation.summary.filter(T=>T.sent).map(T=>T.token.address);if(!(((g=t.enrichedFeeEstimation)==null?void 0:g.transactions.feeTokenAddress)&&i.includes((A=t.enrichedFeeEstimation)==null?void 0:A.transactions.feeTokenAddress))||!((S=(m=t.enrichedFeeEstimation)==null?void 0:m.transactions)!=null&&S.max))return s;const l="amount"in t.enrichedFeeEstimation.transactions.max?t.enrichedFeeEstimation.transactions.max.amount*t.enrichedFeeEstimation.transactions.max.pricePerUnit:"maxFee"in t.enrichedFeeEstimation.transactions.max?t.enrichedFeeEstimation.transactions.max.maxFee:void 0,u=(E=o.simulation.summary.find(T=>T.sent&&T.token.address===n))==null?void 0:E.value;if(!l||!u)return s;const h=await jr(n,e,r)??0n;return BigInt(h)>l+BigInt(u)||(s=!0),s},Ll=()=>D.useCallback(async({feeTokenAddress:t,calls:n,selectedAccount:r,transactionReviewService:s,appDomain:o,accountDeployPayload:i,provider:c})=>{if(!r)return;const l=await Qr({feeTokenAddress:t,calls:n,selectedAccount:r,transactionReviewService:s,appDomain:o,accountDeployTransaction:ts(i)});if(!l||!l.result||!t)return;const u=await es(r.address,l.result,t,c);return{...l.result,isSendingMoreThanBalanceAndGas:u}},[]),ts=e=>e?{type:"DEPLOY_ACCOUNT",calldata:e.calldata,classHash:a.hexSchema.parse(e.class_hash),salt:a.hexSchema.parse(e.salt),signature:[]}:void 0;function pn(){return{promise:Promise.resolve()}}function Hl(e){return class extends e{constructor({enabled:t,appVersion:n}){super(),this.enabled=t,this.appVersion=n}track(t,n){return!this.enabled||!super.isLoaded?pn():{promise:super.track(t,{app_version:this.appVersion,...n}).promise}}}}const $l=D.createContext({}),jl=({enabled:e,initialize:t,children:n})=>{const[r,s]=D.useState(!1);return D.useEffect(()=>{!r&&e&&t().then(()=>s(!0))},[r,e,t]),as.jsx($l.Provider,{value:{},children:n})};exports.BaseError=a.BaseError;Object.defineProperty(exports,"ESTIMATE_ERROR_MESSAGES",{enumerable:!0,get:()=>a.ESTIMATE_ERROR_MESSAGES});exports.ETH_TOKEN_ADDRESS=a.ETH_TOKEN_ADDRESS;exports.EstimateError=a.EstimateError;exports.EventEmitterProvider=a.EventEmitterProvider;exports.EventsBySelector=a.EventsBySelector;exports.FEE_OVERHEAD=a.FEE_OVERHEAD;Object.defineProperty(exports,"HTTP_ERROR_MESSAGE",{enumerable:!0,get:()=>a.HTTP_ERROR_MESSAGE});exports.HttpError=a.HttpError;Object.defineProperty(exports,"MultiSigner",{enumerable:!0,get:()=>a.MultiSigner});exports.STANDARD_DEVNET_ACCOUNT_CLASS_HASH=a.STANDARD_DEVNET_ACCOUNT_CLASS_HASH;exports.STRK_TOKEN_ADDRESS=a.STRK_TOKEN_ADDRESS;Object.defineProperty(exports,"TOKEN_ERROR_MESSAGES",{enumerable:!0,get:()=>a.TOKEN_ERROR_MESSAGES});exports.TXV1_ACCOUNT_CLASS_HASH=a.TXV1_ACCOUNT_CLASS_HASH;exports.TXV1_MULTISIG_CLASS_HASH=a.TXV1_MULTISIG_CLASS_HASH;exports.TXV3_ACCOUNT_CLASS_HASH=a.TXV3_ACCOUNT_CLASS_HASH;exports.TXV3_MULTISIG_CLASS_HASH=a.TXV3_MULTISIG_CLASS_HASH;exports.TokenError=a.TokenError;exports.abiEntrySchema=a.abiEntrySchema;exports.abiSchema=a.abiSchema;exports.addOwnersCalldataSchema=a.addOwnersCalldataSchema;exports.addPluginCalldataSchema=a.addPluginCalldataSchema;exports.addressInputCharactersAndLengthSchema=a.addressInputCharactersAndLengthSchema;exports.addressInputSchema=a.addressInputSchema;exports.addressOrDomainInputSchema=a.addressOrDomainInputSchema;exports.addressOrDomainSchema=a.addressOrDomainSchema;exports.addressOrEmptyUndefinedSchema=a.addressOrEmptyUndefinedSchema;exports.addressSchema=a.addressSchema;exports.addressSchemaArgentBackend=a.addressSchemaArgentBackend;exports.addressSchemaBase=a.addressSchemaBase;exports.addressSchemaLooseLength=a.addressSchemaLooseLength;exports.addressSchemaStrictLength=a.addressSchemaStrictLength;exports.airdropSchema=a.airdropSchema;exports.apiAccountTokenBalancesSchema=a.apiAccountTokenBalancesSchema;exports.apiAirdropSchema=a.apiAirdropSchema;exports.apiCollateralizedDebtPositionSchema=a.apiCollateralizedDebtPositionSchema;exports.apiCollateralizedDebtPositionsSchema=a.apiCollateralizedDebtPositionsSchema;exports.apiConcentratedLiquidityPositionSchema=a.apiConcentratedLiquidityPositionSchema;exports.apiConcentratedLiquidityPositionsSchema=a.apiConcentratedLiquidityPositionsSchema;exports.apiDefiDecompositionProduct=a.apiDefiDecompositionProduct;exports.apiDefiDecompositionProducts=a.apiDefiDecompositionProducts;exports.apiDefiDecompositionSchema=a.apiDefiDecompositionSchema;exports.apiDefiDecompositionToken=a.apiDefiDecompositionToken;exports.apiDefiPositionsSchema=a.apiDefiPositionsSchema;exports.apiPriceDataResponseSchema=a.apiPriceDataResponseSchema;exports.apiPriceDetailsSchema=a.apiPriceDetailsSchema;exports.apiTokenInfoResponseSchema=a.apiTokenInfoResponseSchema;exports.apiTokenInfoSchema=a.apiTokenInfoSchema;exports.apiTokensInfoResponseSchema=a.apiTokensInfoResponseSchema;exports.apiUnclaimedRewardsSchema=a.apiUnclaimedRewardsSchema;exports.apiWalletResponseSchema=a.apiWalletResponseSchema;exports.argentMaxFee=a.argentMaxFee;exports.argentNameSchema=a.argentNameSchema;exports.bigNumberSchema=a.bigNumberSchema;exports.bigNumberishSchema=a.bigNumberishSchema;exports.booleanToStringSchema=a.booleanToStringSchema;exports.builtinsSchema=a.builtinsSchema;exports.byteCodeSchema=a.byteCodeSchema;exports.cairo1EventSchema=a.cairo1EventSchema;exports.cairoAssemblySchema=a.cairoAssemblySchema;exports.cairoVersionSchema=a.cairoVersionSchema;exports.callDetailsSchema=a.callDetailsSchema;exports.callSchema=a.callSchema;exports.calldataSchema=a.calldataSchema;exports.changeGuardianCalldataSchema=a.changeGuardianCalldataSchema;exports.changeThresholdCalldataSchema=a.changeThresholdCalldataSchema;exports.collateralizedDebtGroupSchema=a.collateralizedDebtGroupSchema;exports.collateralizedDebtPositionSchema=a.collateralizedDebtPositionSchema;exports.collateralizedDebtPositionsSchema=a.collateralizedDebtPositionsSchema;exports.compiledContractClassSchema=a.compiledContractClassSchema;exports.compiledSierraCasmSchema=a.compiledSierraCasmSchema;exports.compiledSierraSchema=a.compiledSierraSchema;exports.compressedProgramSchema=a.compressedProgramSchema;exports.concentratedLiquidityPositionSchema=a.concentratedLiquidityPositionSchema;exports.concentratedLiquidityPositionsSchema=a.concentratedLiquidityPositionsSchema;exports.constructorCallDataSchemaC0=a.constructorCallDataSchemaC0;exports.constructorCallDataSchemaC1V1=a.constructorCallDataSchemaC1V1;exports.contractEntryPointFieldsSchema=a.contractEntryPointFieldsSchema;exports.defiDappsProductsSchema=a.defiDappsProductsSchema;exports.defiPositionSchema=a.defiPositionSchema;exports.defiPositionTypeSchema=a.defiPositionTypeSchema;exports.defiProductSchema=a.defiProductSchema;exports.defiProductsSchema=a.defiProductsSchema;exports.denyTxV3=a.denyTxV3;exports.ensureArray=a.ensureArray;exports.entryPointsByTypeSchema=a.entryPointsByTypeSchema;exports.escapeGuardianCalldataSchema=a.escapeGuardianCalldataSchema;exports.eventAbiSchema=a.eventAbiSchema;exports.eventEntrySchema=a.eventEntrySchema;exports.executeOnPluginCalldataSchema=a.executeOnPluginCalldataSchema;exports.feltSchema=a.feltSchema;exports.findTransfersAndApprovals=a.findTransfersAndApprovals;exports.formatFullAddress=a.formatFullAddress;exports.formatTruncatedAddress=a.formatTruncatedAddress;exports.formatTruncatedSignerKey=a.formatTruncatedSignerKey;exports.formatTruncatedString=a.formatTruncatedString;exports.functionAbiSchema=a.functionAbiSchema;exports.functionAbiTypeSchema=a.functionAbiTypeSchema;exports.getAddressFromArgentName=a.getAddressFromArgentName;exports.getMessageFromTrpcError=a.getMessageFromTrpcError;exports.getPrettyRpcError=a.getPrettyRpcError;exports.getSignerForMultiSigner=a.getSignerForMultiSigner;exports.hexSchema=a.hexSchema;exports.hexSchemaBase=a.hexSchemaBase;exports.implementationSchema=a.implementationSchema;exports.includesAddress=a.includesAddress;exports.inputAmountSchema=a.inputAmountSchema;exports.isAddress=a.isAddress;exports.isArgentName=a.isArgentName;exports.isEqualAddress=a.isEqualAddress;exports.isEqualArgentName=a.isEqualArgentName;exports.isEqualStarknetDomainName=a.isEqualStarknetDomainName;exports.isEqualStarknetId=a.isEqualStarknetId;exports.isStarknetDomainName=a.isStarknetDomainName;exports.isStarknetId=a.isStarknetId;exports.isValidAddress=a.isValidAddress;exports.isValidInputAmount=a.isValidInputAmount;exports.isZeroAddress=a.isZeroAddress;exports.legacyContractClassSchema=a.legacyContractClassSchema;exports.legacyEventSchema=a.legacyEventSchema;exports.looseCalldataSchema=a.looseCalldataSchema;exports.modifySnjsFeeOverhead=a.modifySnjsFeeOverhead;exports.multiTypeSchema=a.multiTypeSchema;exports.normalizeAddress=a.normalizeAddress;exports.normalizeAddressOrDomain=a.normalizeAddressOrDomain;exports.normalizeArgentName=a.normalizeArgentName;exports.normalizeStarknetId=a.normalizeStarknetId;exports.parseAmount=a.parseAmount;exports.productGroupsSchema=a.productGroupsSchema;exports.programSchema=a.programSchema;exports.pythonicHintsSchema=a.pythonicHintsSchema;exports.rawArgsArraySchema=a.rawArgsArraySchema;exports.rawArgsObjectSchema=a.rawArgsObjectSchema;exports.rawArgsSchema=a.rawArgsSchema;exports.removeOwnersCalldataSchema=a.removeOwnersCalldataSchema;exports.removePluginCalldataSchema=a.removePluginCalldataSchema;exports.replaceSignerCalldataSchema=a.replaceSignerCalldataSchema;exports.sierraContractEntryPointFieldsSchema=a.sierraContractEntryPointFieldsSchema;exports.sierraEntryPointsByTypeSchema=a.sierraEntryPointsByTypeSchema;exports.sierraProgramDebugInfoSchema=a.sierraProgramDebugInfoSchema;exports.starknetDomainNameSchema=a.starknetDomainNameSchema;exports.starknetIdSchema=a.starknetIdSchema;exports.stringToBooleanSchema=a.stringToBooleanSchema;exports.structAbiSchema=a.structAbiSchema;exports.transactionReviewTransactionsSchema=a.transactionReviewTransactionsSchema;exports.transactionReviewWarningSchema=a.transactionReviewWarningSchema;exports.transferCalldataSchema=a.transferCalldataSchema;exports.trpcErrorSchema=a.trpcErrorSchema;exports.txVersionSchema=a.txVersionSchema;exports.uint256Schema=a.uint256Schema;exports.unclaimedRewardsSchema=a.unclaimedRewardsSchema;exports.useEmitEvent=a.useEmitEvent;exports.useEventEmitter=a.useEventEmitter;exports.useEventEmitterContext=a.useEventEmitterContext;exports.useEventListener=a.useEventListener;exports.useIsEventEmitterEnabled=a.useIsEventEmitterEnabled;exports.validChecksumAddressSchema=a.validChecksumAddressSchema;exports.validateAddressRangeSchema=a.validateAddressRangeSchema;exports.ARGENT_ACCOUNT_CONTRACT_CLASS_HASHES=J;exports.ARGENT_MULTISIG_CONTRACT_CLASS_HASHES=Oe;exports.AddSmartAccountResponseSchema=is;exports.AddSmartAcountRequestSchema=cs;exports.BackendAccountSchema=gn;exports.BackendNftService=ii;exports.C0_PROXY_CONTRACT_CLASS_HASHES=Bn;exports.CacheService=Ps;exports.DEFAULT_TOKEN_DECIMALS=be;exports.DateService=Fs;exports.HTTPService=Xe;exports.KnownDappsBackendService=ga;exports.OnchainRecoveryService=Hc;exports.PRETTY_UNLIMITED=Vr;exports.ResolveNameService=wa;exports.SWRService=Us;exports.StarknetAddressService=Ms;exports.TokenServiceWeb=al;exports.TransactionReviewServiceWeb=Al;exports.WebAmplitudeProvider=jl;exports.WebAnalyticsServiceFactory=Hl;exports.activeOnchainRecoverySchema=Ur;exports.apiTransactionReviewActivityType=Tl;exports.argentBackendNetworkIdSchema=yn;exports.argentNetworkIdSchema=wn;exports.bigDecimal=Rs;exports.buildAccountDeployTransaction=ts;exports.buildConstructorCalldata=Hn;exports.buildDummyTx=ml;exports.calculateCubeRootAdjustment=Yr;exports.calculateNonLinearAdjustment=Sl;exports.calculateSqrtAdjustment=gl;exports.castFeeEstimation=le;exports.checkGasFeeBalance=es;exports.classHashSupportsTxV3=yl;exports.convertTokenAmountToCurrencyValue=Zc;exports.convertTokenUnitAmountWithDecimals=Yc;exports.dappContractSchema=zn;exports.dappLinkSchema=jn;exports.daysBetween=Za;exports.decodeBase58=cr;exports.decodeBase58Array=Ka;exports.encodeBase58=ir;exports.encodeBase58Array=Wa;exports.ensureDecimals=Jc;exports.entryPointToHumanReadable=ri;exports.equalNft=fi;exports.erc20TransferTransaction=il;exports.erc721SafeTransferFromTransaction=ll;exports.erc721TransferFromTransaction=cl;exports.estimatedFeeToMaxFeeTotal=Ye;exports.estimatedFeeToMaxResourceBounds=pl;exports.estimatedFeeToTotal=De;exports.estimatedFeesToMaxFeeTotal=fl;exports.estimatedFeesToTotal=hl;exports.feeTokenNeedsTxV3Support=it;exports.fetchData=xt;exports.fetcherError=Be;exports.findImplementationForAccount=fa;exports.formatAddress=_t;exports.generateAvatarImage=Re;exports.getAccountContractAddress=$n;exports.getAccountDeploymentPayload=Ln;exports.getAccountIdentifier=$s;exports.getAddressFromStarkName=Nn;exports.getArgentAccountClassHashes=St;exports.getArgentAccountClassHashesWithTxV3Support=Dn;exports.getArgentAccountWithMultiSignerClassHashes=Fn;exports.getBackendTimeNowSeconds=Vs;exports.getBackendTimeSeconds=vn;exports.getCallFromStarkName=_n;exports.getChainIdFromNetworkId=xn;exports.getColor=or;exports.getDapplandLinkForDapp=qn;exports.getDapplandUrlForDapp=Sa;exports.getDisplayWarnAndReasonForTransactionReview=Rl;exports.getERC20Transactions=je;exports.getERC721Transactions=$t;exports.getEstimatedFeeFromBulkSimulation=Wr;exports.getEstimatedFeeFromSimulationAndRespectWatermarkFee=Zr;exports.getInitials=sr;exports.getLastCairo0ArgentAccountClassHash=ua;exports.getLatestArgentAccountClassHash=Pn;exports.getLatestArgentMultisigClassHash=la;exports.getLatestLedgerAccountClassHash=ha;exports.getLedgerAccountClassHashes=da;exports.getNFTTransferActivity=Pl;exports.getNetworkAccountImageUrl=Ga;exports.getNftPicture=hi;exports.getPayloadFromTransaction=Kr;exports.getReviewForTransactions=Qr;exports.getSimulationTxVersionFromFeeToken=bl;exports.getStarknetIdContractAddressFromNetworkId=Cn;exports.getTokenBalance=jr;exports.getTokens=Wc;exports.getTokensBalances=Gc;exports.getTransactionReviewActivityOfType=Fl;exports.getTransactionReviewHasSwap=Dl;exports.getTransactionReviewSwap=Xr;exports.getTransactionReviewWithType=Ul;exports.getTxVersionFromFeeToken=Et;exports.getTxVersionFromFeeTokenForDeclareContract=El;exports.getUAParserResult=$r;exports.getUint256CalldataFromBN=ye;exports.getWatermarkedMaxFeeTotal=Gr;exports.hasERC20Transactions=Il;exports.hasERC721Transactions=Jr;exports.hasIncomingERC20Transactions=Cl;exports.hasOutgoingERC20Transactions=_l;exports.id=rr;exports.isAccountV4=ds;exports.isAccountV5=us;exports.isAccountV6=ls;exports.isAllowedAddressHexInputValue=Qa;exports.isAllowedNumericInputValue=ei;exports.isArgentBackendNetworkId=ms;exports.isArgentNetworkId=fs;exports.isBraveBrowser=$c;exports.isBrowser=$e;exports.isChromeBrowser=zc;exports.isContractDeployed=Ja;exports.isEdgeBrowser=Mc;exports.isEqualImplementation=Un;exports.isFRI=Mr;exports.isFeatureEnabled=Ya;exports.isFirefoxBrowser=jc;exports.isNumeric=K;exports.isSafariBrowser=Vc;exports.isUnlimitedAmount=zr;exports.isWEI=Ht;exports.knownDappSchema=Vn;exports.knownDappsSchema=Mn;exports.multiplyBigIntByFloat=ul;exports.nameProviderResolutionSchema=Wn;exports.nameResolutionAddressSchema=Kn;exports.nameResolutionAddressesSchema=Yn;exports.nameResolutionStarknetIdSchema=Ct;exports.nameResolutionStarknetIdsSchema=Gn;exports.nonNullable=Xa;exports.onchainRecoverySchema=Lr;exports.parseAmountValue=dr;exports.pluralise=ti;exports.postData=Ls;exports.preferencesEndpointPayload=hs;exports.preferencesSchema=Sn;exports.prettifyCurrencyNumber=lr;exports.prettifyCurrencyValue=Qc;exports.prettifyNumber=Nt;exports.prettifyNumberConfig=rt;exports.prettifyTokenAmount=el;exports.prettifyTokenNumber=ur;exports.providersNamesSchema=Zn;exports.readFileAsString=ni;exports.recoveryBaseSchema=Ut;exports.recoveryBodySchema=Uc;exports.recoveryStatusSchema=Dr;exports.seedphraseSchema=qc;exports.starkNameToCallDataDomain=In;exports.startOnchainRecoveryErrorSchema=Lc;exports.startOnchainRecoveryErrorStatusSchema=Hr;exports.startOnchainRecoverySchema=Fr;exports.stripAddressZeroPadding=ar;exports.swrRefetchDisabledConfig=zs;exports.toMax=we;exports.tokensRequireTxV3Support=dl;exports.unitToFeeTokenAddress=Ge;exports.urlWithQuery=si;exports.useBalanceChange=vl;exports.useCollection=ui;exports.useConditionallyEnabledSWR=Tn;exports.useDebounce=ma;exports.useDebouncedValue=pa;exports.useERC20Transactions=xl;exports.useERC721Transactions=Nl;exports.useHasERC721Transaction=Bl;exports.useMaxAmountTransaction=Ol;exports.useNft=di;exports.useNfts=li;exports.useToken=Kc;exports.useTransactionReview=kl;exports.useTransactionReviewV2webFetcher=Ll;exports.voidify=oi;exports.withPolling=Hs;