@ar.io/sdk 3.17.2-alpha.1 → 3.17.2

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.
@@ -148,7 +148,7 @@ Use Chrome, Firefox or Internet Explorer 11`)},$5=en.Buffer,bX=Ph.Transform,bi(W
148
148
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(r){return r instanceof this?r:new this(r)}static concat(r,...a){let l=new this(r);return a.forEach(i=>l.set(i)),l}static accessor(r){let l=(this[oUt]=this[oUt]={accessors:{}}).accessors,i=this.prototype;function c(b){let g=kw(b);l[g]||(S8e(i,b),l[g]=!0)}return Ye.isArray(r)?r.forEach(c):c(r),this}};H3.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Ye.reduceDescriptors(H3.prototype,({value:e},r)=>{let a=r[0].toUpperCase()+r.slice(1);return{get:()=>e,set(l){this[a]=l}}});Ye.freezeMethods(H3);var Yo=H3;function Iw(e,r){let a=this||F3,l=r||a,i=Yo.from(l.headers),c=l.data;return Ye.forEach(e,function(g){c=g.call(a,c,i.normalize(),r?r.status:void 0)}),i.normalize(),c}Et();Rt();At();function Tw(e){return!!(e&&e.__CANCEL__)}Et();Rt();At();function sUt(e,r,a){Xr.call(this,e??"canceled",Xr.ERR_CANCELED,r,a),this.name="CanceledError"}Ye.inherits(sUt,Xr,{__CANCEL__:!0});var Vd=sUt;Et();Rt();At();Et();Rt();At();Et();Rt();At();function Bw(e,r,a){let l=a.config.validateStatus;!a.status||!l||l(a.status)?e(a):r(new Xr("Request failed with status code "+a.status,[Xr.ERR_BAD_REQUEST,Xr.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a))}Et();Rt();At();function Iat(e){let r=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return r&&r[1]||""}Et();Rt();At();Et();Rt();At();function x8e(e,r){e=e||10;let a=new Array(e),l=new Array(e),i=0,c=0,b;return r=r!==void 0?r:1e3,function(M){let y=Date.now(),w=l[c];b||(b=y),a[i]=M,l[i]=y;let S=c,_=0;for(;S!==i;)_+=a[S++],S=S%e;if(i=(i+1)%e,i===c&&(c=(c+1)%e),y-b<r)return;let x=w&&y-w;return x?Math.round(_*1e3/x):void 0}}var fUt=x8e;Et();Rt();At();function E8e(e,r){let a=0,l=1e3/r,i,c,b=(y,w=Date.now())=>{a=w,i=null,c&&(clearTimeout(c),c=null),e.apply(null,y)};return[(...y)=>{let w=Date.now(),S=w-a;S>=l?b(y,w):(i=y,c||(c=setTimeout(()=>{c=null,b(i)},l-S)))},()=>i&&b(i)]}var hUt=E8e;var K3=(e,r,a=3)=>{let l=0,i=fUt(50,250);return hUt(c=>{let b=c.loaded,g=c.lengthComputable?c.total:void 0,M=b-l,y=i(M),w=b<=g;l=b;let S={loaded:b,total:g,progress:g?b/g:void 0,bytes:M,rate:y||void 0,estimated:y&&g&&w?(g-b)/y:void 0,event:c,lengthComputable:g!=null,[r?"download":"upload"]:!0};e(S)},a)},Tat=(e,r)=>{let a=e!=null;return[l=>r[0]({lengthComputable:a,total:e,loaded:l}),r[1]]},Bat=e=>(...r)=>Ye.asap(()=>e(...r));Et();Rt();At();Et();Rt();At();var uUt=Qa.hasStandardBrowserEnv?((e,r)=>a=>(a=new URL(a,Qa.origin),e.protocol===a.protocol&&e.host===a.host&&(r||e.port===a.port)))(new URL(Qa.origin),Qa.navigator&&/(msie|trident)/i.test(Qa.navigator.userAgent)):()=>!0;Et();Rt();At();var lUt=Qa.hasStandardBrowserEnv?{write(e,r,a,l,i,c){let b=[e+"="+encodeURIComponent(r)];Ye.isNumber(a)&&b.push("expires="+new Date(a).toGMTString()),Ye.isString(l)&&b.push("path="+l),Ye.isString(i)&&b.push("domain="+i),c===!0&&b.push("secure"),document.cookie=b.join("; ")},read(e){let r=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};Et();Rt();At();Et();Rt();At();function Pat(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}Et();Rt();At();function Nat(e,r){return r?e.replace(/\/?\/$/,"")+"/"+r.replace(/^\/+/,""):e}function Pw(e,r,a){let l=!Pat(r);return e&&(l||a==!1)?Nat(e,r):r}Et();Rt();At();var dUt=e=>e instanceof Yo?{...e}:e;function Bl(e,r){r=r||{};let a={};function l(y,w,S,_){return Ye.isPlainObject(y)&&Ye.isPlainObject(w)?Ye.merge.call({caseless:_},y,w):Ye.isPlainObject(w)?Ye.merge({},w):Ye.isArray(w)?w.slice():w}function i(y,w,S,_){if(Ye.isUndefined(w)){if(!Ye.isUndefined(y))return l(void 0,y,S,_)}else return l(y,w,S,_)}function c(y,w){if(!Ye.isUndefined(w))return l(void 0,w)}function b(y,w){if(Ye.isUndefined(w)){if(!Ye.isUndefined(y))return l(void 0,y)}else return l(void 0,w)}function g(y,w,S){if(S in r)return l(y,w);if(S in e)return l(void 0,y)}let M={url:c,method:c,data:c,baseURL:b,transformRequest:b,transformResponse:b,paramsSerializer:b,timeout:b,timeoutMessage:b,withCredentials:b,withXSRFToken:b,adapter:b,responseType:b,xsrfCookieName:b,xsrfHeaderName:b,onUploadProgress:b,onDownloadProgress:b,decompress:b,maxContentLength:b,maxBodyLength:b,beforeRedirect:b,transport:b,httpAgent:b,httpsAgent:b,cancelToken:b,socketPath:b,responseEncoding:b,validateStatus:g,headers:(y,w,S)=>i(dUt(y),dUt(w),S,!0)};return Ye.forEach(Object.keys(Object.assign({},e,r)),function(w){let S=M[w]||i,_=S(e[w],r[w],w);Ye.isUndefined(_)&&S!==g||(a[w]=_)}),a}var tP=e=>{let r=Bl({},e),{data:a,withXSRFToken:l,xsrfHeaderName:i,xsrfCookieName:c,headers:b,auth:g}=r;r.headers=b=Yo.from(b),r.url=Rw(Pw(r.baseURL,r.url,r.allowAbsoluteUrls),e.params,e.paramsSerializer),g&&b.set("Authorization","Basic "+btoa((g.username||"")+":"+(g.password?unescape(encodeURIComponent(g.password)):"")));let M;if(Ye.isFormData(a)){if(Qa.hasStandardBrowserEnv||Qa.hasStandardBrowserWebWorkerEnv)b.setContentType(void 0);else if((M=b.getContentType())!==!1){let[y,...w]=M?M.split(";").map(S=>S.trim()).filter(Boolean):[];b.setContentType([y||"multipart/form-data",...w].join("; "))}}if(Qa.hasStandardBrowserEnv&&(l&&Ye.isFunction(l)&&(l=l(r)),l||l!==!1&&uUt(r.url))){let y=i&&c&&lUt.read(c);y&&b.set(i,y)}return r};var A8e=typeof XMLHttpRequest<"u",cUt=A8e&&function(e){return new Promise(function(a,l){let i=tP(e),c=i.data,b=Yo.from(i.headers).normalize(),{responseType:g,onUploadProgress:M,onDownloadProgress:y}=i,w,S,_,x,A;function k(){x&&x(),A&&A(),i.cancelToken&&i.cancelToken.unsubscribe(w),i.signal&&i.signal.removeEventListener("abort",w)}let B=new XMLHttpRequest;B.open(i.method.toUpperCase(),i.url,!0),B.timeout=i.timeout;function P(){if(!B)return;let C=Yo.from("getAllResponseHeaders"in B&&B.getAllResponseHeaders()),W={data:!g||g==="text"||g==="json"?B.responseText:B.response,status:B.status,statusText:B.statusText,headers:C,config:e,request:B};Bw(function(U){a(U),k()},function(U){l(U),k()},W),B=null}"onloadend"in B?B.onloadend=P:B.onreadystatechange=function(){!B||B.readyState!==4||B.status===0&&!(B.responseURL&&B.responseURL.indexOf("file:")===0)||setTimeout(P)},B.onabort=function(){B&&(l(new Xr("Request aborted",Xr.ECONNABORTED,e,B)),B=null)},B.onerror=function(){l(new Xr("Network Error",Xr.ERR_NETWORK,e,B)),B=null},B.ontimeout=function(){let K=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",W=i.transitional||JB;i.timeoutErrorMessage&&(K=i.timeoutErrorMessage),l(new Xr(K,W.clarifyTimeoutError?Xr.ETIMEDOUT:Xr.ECONNABORTED,e,B)),B=null},c===void 0&&b.setContentType(null),"setRequestHeader"in B&&Ye.forEach(b.toJSON(),function(K,W){B.setRequestHeader(W,K)}),Ye.isUndefined(i.withCredentials)||(B.withCredentials=!!i.withCredentials),g&&g!=="json"&&(B.responseType=i.responseType),y&&([_,A]=K3(y,!0),B.addEventListener("progress",_)),M&&B.upload&&([S,x]=K3(M),B.upload.addEventListener("progress",S),B.upload.addEventListener("loadend",x)),(i.cancelToken||i.signal)&&(w=C=>{B&&(l(!C||C.type?new Vd(null,e,B):C),B.abort(),B=null)},i.cancelToken&&i.cancelToken.subscribe(w),i.signal&&(i.signal.aborted?w():i.signal.addEventListener("abort",w)));let O=Iat(i.url);if(O&&Qa.protocols.indexOf(O)===-1){l(new Xr("Unsupported protocol "+O+":",Xr.ERR_BAD_REQUEST,e));return}B.send(c||null)})};Et();Rt();At();Et();Rt();At();var R8e=(e,r)=>{let{length:a}=e=e?e.filter(Boolean):[];if(r||a){let l=new AbortController,i,c=function(y){if(!i){i=!0,g();let w=y instanceof Error?y:this.reason;l.abort(w instanceof Xr?w:new Vd(w instanceof Error?w.message:w))}},b=r&&setTimeout(()=>{b=null,c(new Xr(`timeout ${r} of ms exceeded`,Xr.ETIMEDOUT))},r),g=()=>{e&&(b&&clearTimeout(b),b=null,e.forEach(y=>{y.unsubscribe?y.unsubscribe(c):y.removeEventListener("abort",c)}),e=null)};e.forEach(y=>y.addEventListener("abort",c));let{signal:M}=l;return M.unsubscribe=()=>Ye.asap(g),M}},pUt=R8e;Et();Rt();At();var k8e=function*(e,r){let a=e.byteLength;if(!r||a<r){yield e;return}let l=0,i;for(;l<a;)i=l+r,yield e.slice(l,i),l=i},I8e=async function*(e,r){for await(let a of T8e(e))yield*k8e(a,r)},T8e=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let r=e.getReader();try{for(;;){let{done:a,value:l}=await r.read();if(a)break;yield l}}finally{await r.cancel()}},Oat=(e,r,a,l)=>{let i=I8e(e,r),c=0,b,g=M=>{b||(b=!0,l&&l(M))};return new ReadableStream({async pull(M){try{let{done:y,value:w}=await i.next();if(y){g(),M.close();return}let S=w.byteLength;if(a){let _=c+=S;a(_)}M.enqueue(new Uint8Array(w))}catch(y){throw g(y),y}},cancel(M){return g(M),i.return()}},{highWaterMark:2})};var rP=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",vUt=rP&&typeof ReadableStream=="function",B8e=rP&&(typeof TextEncoder=="function"?(e=>r=>e.encode(r))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),bUt=(e,...r)=>{try{return!!e(...r)}catch{return!1}},P8e=vUt&&bUt(()=>{let e=!1,r=new Request(Qa.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!r}),mUt=64*1024,Cat=vUt&&bUt(()=>Ye.isReadableStream(new Response("").body)),eP={stream:Cat&&(e=>e.body)};rP&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(r=>{!eP[r]&&(eP[r]=Ye.isFunction(e[r])?a=>a[r]():(a,l)=>{throw new Xr(`Response type '${r}' is not supported`,Xr.ERR_NOT_SUPPORT,l)})})})(new Response);var N8e=async e=>{if(e==null)return 0;if(Ye.isBlob(e))return e.size;if(Ye.isSpecCompliantForm(e))return(await new Request(Qa.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(Ye.isArrayBufferView(e)||Ye.isArrayBuffer(e))return e.byteLength;if(Ye.isURLSearchParams(e)&&(e=e+""),Ye.isString(e))return(await B8e(e)).byteLength},O8e=async(e,r)=>{let a=Ye.toFiniteNumber(e.getContentLength());return a??N8e(r)},gUt=rP&&(async e=>{let{url:r,method:a,data:l,signal:i,cancelToken:c,timeout:b,onDownloadProgress:g,onUploadProgress:M,responseType:y,headers:w,withCredentials:S="same-origin",fetchOptions:_}=tP(e);y=y?(y+"").toLowerCase():"text";let x=pUt([i,c&&c.toAbortSignal()],b),A,k=x&&x.unsubscribe&&(()=>{x.unsubscribe()}),B;try{if(M&&P8e&&a!=="get"&&a!=="head"&&(B=await O8e(w,l))!==0){let W=new Request(r,{method:"POST",body:l,duplex:"half"}),J;if(Ye.isFormData(l)&&(J=W.headers.get("content-type"))&&w.setContentType(J),W.body){let[U,q]=Tat(B,K3(Bat(M)));l=Oat(W.body,mUt,U,q)}}Ye.isString(S)||(S=S?"include":"omit");let P="credentials"in Request.prototype;A=new Request(r,{..._,signal:x,method:a.toUpperCase(),headers:w.normalize().toJSON(),body:l,duplex:"half",credentials:P?S:void 0});let O=await fetch(A),C=Cat&&(y==="stream"||y==="response");if(Cat&&(g||C&&k)){let W={};["status","statusText","headers"].forEach(V=>{W[V]=O[V]});let J=Ye.toFiniteNumber(O.headers.get("content-length")),[U,q]=g&&Tat(J,K3(Bat(g),!0))||[];O=new Response(Oat(O.body,mUt,U,()=>{q&&q(),k&&k()}),W)}y=y||"text";let K=await eP[Ye.findKey(eP,y)||"text"](O,e);return!C&&k&&k(),await new Promise((W,J)=>{Bw(W,J,{data:K,headers:Yo.from(O.headers),status:O.status,statusText:O.statusText,config:e,request:A})})}catch(P){throw k&&k(),P&&P.name==="TypeError"&&/fetch/i.test(P.message)?Object.assign(new Xr("Network Error",Xr.ERR_NETWORK,e,A),{cause:P.cause||P}):Xr.from(P,P&&P.code,e,A)}});var Lat={http:VB,xhr:cUt,fetch:gUt};Ye.forEach(Lat,(e,r)=>{if(e){try{Object.defineProperty(e,"name",{value:r})}catch{}Object.defineProperty(e,"adapterName",{value:r})}});var yUt=e=>`- ${e}`,C8e=e=>Ye.isFunction(e)||e===null||e===!1,iP={getAdapter:e=>{e=Ye.isArray(e)?e:[e];let{length:r}=e,a,l,i={};for(let c=0;c<r;c++){a=e[c];let b;if(l=a,!C8e(a)&&(l=Lat[(b=String(a)).toLowerCase()],l===void 0))throw new Xr(`Unknown adapter '${b}'`);if(l)break;i[b||"#"+c]=l}if(!l){let c=Object.entries(i).map(([g,M])=>`adapter ${g} `+(M===!1?"is not supported by the environment":"is not available in the build")),b=r?c.length>1?`since :
149
149
  `+c.map(yUt).join(`
150
150
  `):" "+yUt(c[0]):"as no adapter specified";throw new Xr("There is no suitable adapter to dispatch the request "+b,"ERR_NOT_SUPPORT")}return l},adapters:Lat};function Dat(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Vd(null,e)}function nP(e){return Dat(e),e.headers=Yo.from(e.headers),e.data=Iw.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),iP.getAdapter(e.adapter||F3.adapter)(e).then(function(l){return Dat(e),l.data=Iw.call(e,e.transformResponse,l),l.headers=Yo.from(l.headers),l},function(l){return Tw(l)||(Dat(e),l&&l.response&&(l.response.data=Iw.call(e,e.transformResponse,l.response),l.response.headers=Yo.from(l.response.headers))),Promise.reject(l)})}Et();Rt();At();Et();Rt();At();var aP="1.8.4";var oP={};["object","boolean","number","function","string","symbol"].forEach((e,r)=>{oP[e]=function(l){return typeof l===e||"a"+(r<1?"n ":" ")+e}});var wUt={};oP.transitional=function(r,a,l){function i(c,b){return"[Axios v"+aP+"] Transitional option '"+c+"'"+b+(l?". "+l:"")}return(c,b,g)=>{if(r===!1)throw new Xr(i(b," has been removed"+(a?" in "+a:"")),Xr.ERR_DEPRECATED);return a&&!wUt[b]&&(wUt[b]=!0,console.warn(i(b," has been deprecated since v"+a+" and will be removed in the near future"))),r?r(c,b,g):!0}};oP.spelling=function(r){return(a,l)=>(console.warn(`${l} is likely a misspelling of ${r}`),!0)};function L8e(e,r,a){if(typeof e!="object")throw new Xr("options must be an object",Xr.ERR_BAD_OPTION_VALUE);let l=Object.keys(e),i=l.length;for(;i-- >0;){let c=l[i],b=r[c];if(b){let g=e[c],M=g===void 0||b(g,c,e);if(M!==!0)throw new Xr("option "+c+" must be "+M,Xr.ERR_BAD_OPTION_VALUE);continue}if(a!==!0)throw new Xr("Unknown option "+c,Xr.ERR_BAD_OPTION)}}var Nw={assertOptions:L8e,validators:oP};var Yd=Nw.validators,Z3=class{constructor(r){this.defaults=r,this.interceptors={request:new _at,response:new _at}}async request(r,a){try{return await this._request(r,a)}catch(l){if(l instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;let c=i.stack?i.stack.replace(/^.+\n/,""):"";try{l.stack?c&&!String(l.stack).endsWith(c.replace(/^.+\n.+\n/,""))&&(l.stack+=`
151
- `+c):l.stack=c}catch{}}throw l}}_request(r,a){typeof r=="string"?(a=a||{},a.url=r):a=r||{},a=Bl(this.defaults,a);let{transitional:l,paramsSerializer:i,headers:c}=a;l!==void 0&&Nw.assertOptions(l,{silentJSONParsing:Yd.transitional(Yd.boolean),forcedJSONParsing:Yd.transitional(Yd.boolean),clarifyTimeoutError:Yd.transitional(Yd.boolean)},!1),i!=null&&(Ye.isFunction(i)?a.paramsSerializer={serialize:i}:Nw.assertOptions(i,{encode:Yd.function,serialize:Yd.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),Nw.assertOptions(a,{baseUrl:Yd.spelling("baseURL"),withXsrfToken:Yd.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let b=c&&Ye.merge(c.common,c[a.method]);c&&Ye.forEach(["delete","get","head","post","put","patch","common"],A=>{delete c[A]}),a.headers=Yo.concat(b,c);let g=[],M=!0;this.interceptors.request.forEach(function(k){typeof k.runWhen=="function"&&k.runWhen(a)===!1||(M=M&&k.synchronous,g.unshift(k.fulfilled,k.rejected))});let y=[];this.interceptors.response.forEach(function(k){y.push(k.fulfilled,k.rejected)});let w,S=0,_;if(!M){let A=[nP.bind(this),void 0];for(A.unshift.apply(A,g),A.push.apply(A,y),_=A.length,w=Promise.resolve(a);S<_;)w=w.then(A[S++],A[S++]);return w}_=g.length;let x=a;for(S=0;S<_;){let A=g[S++],k=g[S++];try{x=A(x)}catch(B){k.call(this,B);break}}try{w=nP.call(this,x)}catch(A){return Promise.reject(A)}for(S=0,_=y.length;S<_;)w=w.then(y[S++],y[S++]);return w}getUri(r){r=Bl(this.defaults,r);let a=Pw(r.baseURL,r.url,r.allowAbsoluteUrls);return Rw(a,r.params,r.paramsSerializer)}};Ye.forEach(["delete","get","head","options"],function(r){Z3.prototype[r]=function(a,l){return this.request(Bl(l||{},{method:r,url:a,data:(l||{}).data}))}});Ye.forEach(["post","put","patch"],function(r){function a(l){return function(c,b,g){return this.request(Bl(g||{},{method:r,headers:l?{"Content-Type":"multipart/form-data"}:{},url:c,data:b}))}}Z3.prototype[r]=a(),Z3.prototype[r+"Form"]=a(!0)});var Ow=Z3;Et();Rt();At();var $at=class e{constructor(r){if(typeof r!="function")throw new TypeError("executor must be a function.");let a;this.promise=new Promise(function(c){a=c});let l=this;this.promise.then(i=>{if(!l._listeners)return;let c=l._listeners.length;for(;c-- >0;)l._listeners[c](i);l._listeners=null}),this.promise.then=i=>{let c,b=new Promise(g=>{l.subscribe(g),c=g}).then(i);return b.cancel=function(){l.unsubscribe(c)},b},r(function(c,b,g){l.reason||(l.reason=new Vd(c,b,g),a(l.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(r){if(this.reason){r(this.reason);return}this._listeners?this._listeners.push(r):this._listeners=[r]}unsubscribe(r){if(!this._listeners)return;let a=this._listeners.indexOf(r);a!==-1&&this._listeners.splice(a,1)}toAbortSignal(){let r=new AbortController,a=l=>{r.abort(l)};return this.subscribe(a),r.signal.unsubscribe=()=>this.unsubscribe(a),r.signal}static source(){let r;return{token:new e(function(i){r=i}),cancel:r}}},MUt=$at;Et();Rt();At();function qat(e){return function(a){return e.apply(null,a)}}Et();Rt();At();function Uat(e){return Ye.isObject(e)&&e.isAxiosError===!0}Et();Rt();At();var jat={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(jat).forEach(([e,r])=>{jat[r]=e});var _Ut=jat;function SUt(e){let r=new Ow(e),a=xw(Ow.prototype.request,r);return Ye.extend(a,Ow.prototype,r,{allOwnKeys:!0}),Ye.extend(a,r,null,{allOwnKeys:!0}),a.create=function(i){return SUt(Bl(e,i))},a}var Bo=SUt(F3);Bo.Axios=Ow;Bo.CanceledError=Vd;Bo.CancelToken=MUt;Bo.isCancel=Tw;Bo.VERSION=aP;Bo.toFormData=Fm;Bo.AxiosError=Xr;Bo.Cancel=Bo.CanceledError;Bo.all=function(r){return Promise.all(r)};Bo.spread=qat;Bo.isAxiosError=Uat;Bo.mergeConfig=Bl;Bo.AxiosHeaders=Yo;Bo.formToJSON=e=>XB(Ye.isHTMLForm(e)?new FormData(e):e);Bo.getAdapter=iP.getAdapter;Bo.HttpStatusCode=_Ut;Bo.default=Bo;var sP=Bo;var{Axios:qGe,AxiosError:UGe,CanceledError:jGe,isCancel:zGe,CancelToken:FGe,VERSION:HGe,all:KGe,Cancel:ZGe,isAxiosError:WGe,spread:GGe,toFormData:VGe,AxiosHeaders:YGe,HttpStatusCode:JGe,formToJSON:XGe,getAdapter:QGe,mergeConfig:tVe}=sP;Et();Rt();At();var RUt=An(EUt(),1),zat="axios-retry";function kUt(e){let r=["ERR_CANCELED","ECONNABORTED"];return e.response||!e.code||r.includes(e.code)?!1:(0,RUt.default)(e)}var IUt=["get","head","options"],$8e=IUt.concat(["put","delete"]);function Fat(e){return e.code!=="ECONNABORTED"&&(!e.response||e.response.status===429||e.response.status>=500&&e.response.status<=599)}function q8e(e){return e.config?.method?Fat(e)&&IUt.indexOf(e.config.method)!==-1:!1}function TUt(e){return e.config?.method?Fat(e)&&$8e.indexOf(e.config.method)!==-1:!1}function BUt(e){return kUt(e)||TUt(e)}function Hat(e=void 0){let r=e?.response?.headers["retry-after"];if(!r)return 0;let a=(Number(r)||0)*1e3;return a===0&&(a=(new Date(r).valueOf()||0)-Date.now()),Math.max(0,a)}function U8e(e=0,r=void 0){return Math.max(0,Hat(r))}function j8e(e=0,r=void 0,a=100){let l=2**e*a,i=Math.max(l,Hat(r)),c=i*.2*Math.random();return i+c}function z8e(e=100){return(r=0,a=void 0)=>{let l=r*e;return Math.max(l,Hat(a))}}var F8e={retries:3,retryCondition:BUt,retryDelay:U8e,shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function H8e(e,r){return{...F8e,...r,...e[zat]}}function AUt(e,r,a=!1){let l=H8e(e,r||{});return l.retryCount=l.retryCount||0,(!l.lastRequestTime||a)&&(l.lastRequestTime=Date.now()),e[zat]=l,l}function K8e(e,r){e.defaults.agent===r.agent&&delete r.agent,e.defaults.httpAgent===r.httpAgent&&delete r.httpAgent,e.defaults.httpsAgent===r.httpsAgent&&delete r.httpsAgent}async function Z8e(e,r){let{retries:a,retryCondition:l}=e,i=(e.retryCount||0)<a&&l(r);if(typeof i=="object")try{return await i!==!1}catch{return!1}return i}async function W8e(e,r,a,l){r.retryCount+=1;let{retryDelay:i,shouldResetTimeout:c,onRetry:b}=r,g=i(r.retryCount,a);if(K8e(e,l),!c&&l.timeout&&r.lastRequestTime){let M=Date.now()-r.lastRequestTime,y=l.timeout-M-g;if(y<=0)return Promise.reject(a);l.timeout=y}return l.transformRequest=[M=>M],await b(r.retryCount,a,l),l.signal?.aborted?Promise.resolve(e(l)):new Promise(M=>{let y=()=>{clearTimeout(w),M(e(l))},w=setTimeout(()=>{M(e(l)),l.signal?.removeEventListener&&l.signal.removeEventListener("abort",y)},g);l.signal?.addEventListener&&l.signal.addEventListener("abort",y,{once:!0})})}async function G8e(e,r){e.retryCount>=e.retries&&await e.onMaxRetryTimesExceeded(r,e.retryCount)}var Hm=(e,r)=>{let a=e.interceptors.request.use(i=>(AUt(i,r,!0),i[zat]?.validateResponse&&(i.validateStatus=()=>!1),i)),l=e.interceptors.response.use(null,async i=>{let{config:c}=i;if(!c)return Promise.reject(i);let b=AUt(c,r);return i.response&&b.validateResponse?.(i.response)?i.response:await Z8e(b,i)?W8e(e,b,i,c):(await G8e(b,i),Promise.reject(i))});return{requestInterceptorId:a,responseInterceptorId:l}};Hm.isNetworkError=kUt;Hm.isSafeRequestError=q8e;Hm.isIdempotentRequestError=TUt;Hm.isNetworkOrIdempotentRequestError=BUt;Hm.exponentialDelay=j8e;Hm.linearDelay=z8e;Hm.isRetryableError=Fat;var fP=Hm;var PUt=({axiosConfig:e={},logger:r=To.default,retryConfig:a={retries:5,retryDelay:fP.exponentialDelay,retryCondition:l=>fP.isRetryableError(l),onRetry(l,i,c){r.error(`Retrying request ${c.url} attempt ${l}`,i)}}}={})=>{let l=sP.create({...e,maxRedirects:0,headers:{...e.headers,"x-source-version":`${D3}`,"x-source-identifier":"ar-io-sdk"},validateStatus:()=>!0});return fP(l,a),l};Et();Rt();At();var Kat=({baseUrl:e,params:r})=>{let a=new URL(e);return Object.entries(r).forEach(([l,i])=>{if(i!=null)if(Array.isArray(i)&&i.length>0)for(let c of i)c!=null&&a.searchParams.append(l,c.toString());else a.searchParams.set(l,i.toString())}),a.toString()};async function V8e({signer:e,nonce:r=mat()}){let a,l,i=hP(e)?Hr.ARWEAVE:e.signatureType;switch(hP(e)?a=q3(Kt.from(await e.signMessage(Uint8Array.from(Kt.from(r))))):e instanceof al?a=q3(Kt.from(await e.signer.signMessage(Uint8Array.from(Kt.from(r))))):(e instanceof Wu||e instanceof Is||e instanceof av)&&("setPublicKey"in e&&e.publicKey===void 0&&await e.setPublicKey(),a=q3(Kt.from(await e.sign(Uint8Array.from(Kt.from(r)))))),i){case Hr.ARWEAVE:hP(e)?l=await e.getActivePublicKey():"setPublicKey"in e&&(await e.setPublicKey(),l=q3(e.publicKey));break;case Hr.ETHEREUM:if("publicKey"in e)l="0x"+e.publicKey.toString("hex");else throw new Error("Public key not found");break;default:throw new Error(`Unsupported signer type for signing requests: ${i}`)}if(l===void 0||a===void 0)throw new Error("Public key or signature not found");return{"x-public-key":l,"x-nonce":r,"x-signature":a,"x-signature-type":i.toString()}}var Cw=class{static init(r){let{signer:a,paymentUrl:l,axios:i,logger:c}=r??{};return a!==void 0?new Km({signer:a,paymentUrl:l,axios:i,logger:c}):new uP({paymentUrl:l,axios:i,logger:c})}},uP=class{paymentUrl;axios;logger;constructor({paymentUrl:r="https://payment.ardrive.io",axios:a=PUt(),logger:l=To.default}){this.paymentUrl=r,this.axios=a,this.logger=l}async getArNSPriceDetails({intent:r,name:a,quantity:l,type:i,years:c}){let b=Kat({baseUrl:`${this.paymentUrl}/v1/arns/price/${r}/${a}`,params:{increaseQty:l,type:i,years:c}}),{data:g,status:M}=await this.axios.get(b);if(this.logger.debug("getArNSPriceDetails",{intent:r,name:a,quantity:l,type:i,years:c,data:g,status:M}),M!==200)throw new Error("Failed to get ArNS purchase price "+JSON.stringify(g));if(!g.winc||!g.mARIO)throw new Error("Invalid response from Turbo "+JSON.stringify(g));return{winc:g.winc,mARIO:new Sw(+g.mARIO)}}async getPrice(r){let{winc:a}=await this.getArNSPriceDetails(r);return+a}},Km=class extends uP{signer;constructor({signer:r,...a}){if(super(a),!Zat(r))throw new Error("Signer must be a TurboArNSSigner");this.signer=r}async initiateArNSPurchase({intent:r,name:a,quantity:l,type:i,processId:c,years:b,paidBy:g=[],referrer:M}){let y=Kat({baseUrl:`${this.paymentUrl}/v1/arns/purchase/${r}/${a}`,params:{increaseQty:l,processId:c,type:i,years:b,paidBy:g,referrer:M}}),w=await V8e({signer:this.signer}),{data:S,status:_}=await this.axios.post(y,null,{headers:w});if(this.logger.debug("Initiated ArNS purchase",{intent:r,name:a,quantity:l,processId:c,type:i,years:b,data:S,status:_}),_!==200)throw new Error("Failed to initiate ArNS purchase "+JSON.stringify(S));return{id:S.arioWriteResult.id,result:S.purchaseReceipt}}};function hP(e){return typeof e=="object"&&e!==null&&"signMessage"in e&&"getActivePublicKey"in e}function Zat(e){let r=hP(e),a=e instanceof Is||e instanceof av||e instanceof Wu||e instanceof al;return r||a}var Dw=class{static init(r){return r!==void 0&&"signer"in r?new Lw(r):new W3(r)}static mainnet(r){return r!==void 0&&"signer"in r?new Lw({...r,process:new Ea({processId:qf,ao:jh({MODE:"legacy",CU_URL:"https://cu.ardrive.io",...r?.process?.ao})})}):new W3({...r,process:new Ea({processId:qf,ao:jh({CU_URL:"https://cu.ardrive.io",MODE:"legacy",...r?.process?.ao})})})}static testnet(r){return r!==void 0&&"signer"in r?lat({arioInstance:new Lw({...r,process:new Ea({processId:SZ,ao:jh({MODE:"legacy",CU_URL:"https://cu.ardrive.io",...r?.process?.ao})})}),faucetApiUrl:r?.faucetUrl}):lat({arioInstance:new W3({...r,process:new Ea({processId:SZ,ao:jh({MODE:"legacy",CU_URL:"https://cu.ardrive.io",...r?.process?.ao})})}),faucetApiUrl:r?.faucetUrl})}},W3=class{process;epochSettings;arweave;hyperbeamUrl;paymentProvider;logger=To.default;constructor(r){if(this.arweave=r?.arweave??HB,this.hyperbeamUrl=r?.hyperbeamUrl,r===void 0||Object.keys(r).length===0)this.process=new Ea({processId:qf});else if(Wm(r))this.process=r.process;else if(Gm(r))this.process=new Ea({processId:r.processId});else throw new Kd;this.paymentProvider=Cw.init({paymentUrl:r?.paymentUrl})}async getInfo(){return this.process.read({tags:[{name:"Action",value:"Info"}]})}async getTokenSupply(){return this.process.read({tags:[{name:"Action",value:"Total-Token-Supply"}]})}async computeEpochIndexForTimestamp(r){let a=await this.getEpochSettings(),l=a.epochZeroStartTimestamp,i=a.durationMs;return Math.floor((r-l)/i)}async computeCurrentEpochIndex(){return this.computeEpochIndexForTimestamp(Date.now())}async computeEpochIndex(r){let a=r?.epochIndex;if(a!==void 0)return a;let l=r?.timestamp;if(l!==void 0)return this.computeEpochIndexForTimestamp(l)}async getEpochSettings(){return this.epochSettings??=await this.process.read({tags:[{name:"Action",value:"Epoch-Settings"}]})}async getEpoch(r){let a=await this.computeEpochIndex(r),l=await this.computeCurrentEpochIndex();if(a!==void 0&&a<l){let c=await U6({arweave:this.arweave,epochIndex:a,processId:this.process.processId,ao:this.process.ao});if(!c)throw new Error("Epoch data not found for epoch index "+a);return OUt(c)}let i=[{name:"Action",value:"Epoch"},{name:"Epoch-Index",value:l.toString()}];return this.process.read({tags:qa(i)})}async getArNSRecord({name:r}){return this.process.read({tags:[{name:"Action",value:"Record"},{name:"Name",value:r}]})}async getArNSRecords(r){return this.process.read({tags:[{name:"Action",value:"Paginated-Records"},...ff(r)]})}async getArNSReservedNames(r){return this.process.read({tags:[{name:"Action",value:"Reserved-Names"},...ff(r)]})}async getArNSReservedName({name:r}){return this.process.read({tags:[{name:"Action",value:"Reserved-Name"},{name:"Name",value:r}]})}async getBalance({address:r}){return this.process.read({tags:[{name:"Action",value:"Balance"},{name:"Address",value:r}]})}async getBalances(r){return this.process.read({tags:[{name:"Action",value:"Paginated-Balances"},...ff(r)]})}async getVault({address:r,vaultId:a}){return this.process.read({tags:[{name:"Action",value:"Vault"},{name:"Address",value:r},{name:"Vault-Id",value:a}]})}async getVaults(r){return this.process.read({tags:[{name:"Action",value:"Paginated-Vaults"},...ff(r)]})}async getGateway({address:r}){return this.process.read({tags:[{name:"Action",value:"Gateway"},{name:"Address",value:r}]})}async getGatewayDelegates({address:r,...a}){return this.process.read({tags:[{name:"Action",value:"Paginated-Delegates"},{name:"Address",value:r},...ff(a)]})}async getGatewayDelegateAllowList({address:r,...a}){return this.process.read({tags:[{name:"Action",value:"Paginated-Allowed-Delegates"},{name:"Address",value:r},...ff(a)]})}async getGateways(r){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateways"},...ff(r)]})}async getCurrentEpoch(){return this.process.read({tags:[{name:"Action",value:"Epoch"}]})}async getPrescribedObservers(r){let a=await this.computeEpochIndex(r),l=await this.computeCurrentEpochIndex();if(a!==void 0&&a<l){let c=await U6({ao:this.process.ao,arweave:this.arweave,epochIndex:a,processId:this.process.processId});if(!c)throw new Error("Epoch data not found for epoch index "+a);return c.prescribedObservers}let i=[{name:"Action",value:"Epoch-Prescribed-Observers"},{name:"Epoch-Index",value:l.toString()}];return this.process.read({tags:qa(i)})}async getPrescribedNames(r){let a=await this.computeEpochIndex(r),l=await this.computeCurrentEpochIndex();if(a!==void 0&&a<l){let c=await U6({arweave:this.arweave,epochIndex:a,processId:this.process.processId,ao:this.process.ao});if(!c)throw new Error("Epoch data not found for epoch index "+a);return c.prescribedNames}let i=[{name:"Action",value:"Epoch-Prescribed-Names"},{name:"Epoch-Index",value:l.toString()}];return this.process.read({tags:qa(i)})}async getObservations(r){let a=await this.computeEpochIndex(r),l=await this.computeCurrentEpochIndex();if(a!==void 0&&a<l){let c=await U6({arweave:this.arweave,epochIndex:a,processId:this.process.processId,ao:this.process.ao});if(!c)throw new Error("Epoch data not found for epoch index "+a);return c.observations}let i=[{name:"Action",value:"Epoch-Observations"},{name:"Epoch-Index",value:l.toString()}];return this.process.read({tags:qa(i)})}async getDistributions(r){let a=await this.computeEpochIndex(r),l=await this.computeCurrentEpochIndex();if(a!==void 0&&a<l){let c=await U6({arweave:this.arweave,epochIndex:a,processId:this.process.processId,ao:this.process.ao});if(c===void 0)throw new Error("Epoch data not found for epoch index "+a);return c.distributions}let i=[{name:"Action",value:"Epoch-Distributions"},{name:"Epoch-Index",value:l.toString()}];return this.process.read({tags:qa(i)})}async getEligibleEpochRewards(r,a){let l=await this.computeEpochIndex(r),i=await this.computeCurrentEpochIndex();if(l!==void 0&&l<i){let b=await U6({arweave:this.arweave,epochIndex:l,processId:this.process.processId,ao:this.process.ao});if(!b)throw new Error("Epoch data not found for epoch index "+l);return NUt(b,a)}let c=[{name:"Action",value:"Epoch-Eligible-Rewards"},...ff(a)];return this.process.read({tags:qa(c)})}async getTokenCost({intent:r,type:a,years:l,name:i,quantity:c,fromAddress:b}){let M=[{name:"Action",value:"Token-Cost"},{name:"Intent",value:r==="Buy-Record"?"Buy-Name":r},{name:"Name",value:i},{name:"Years",value:l?.toString()},{name:"Quantity",value:c?.toString()},{name:"Purchase-Type",value:a}];return this.process.read({tags:qa(M),fromAddress:b})}async getCostDetails({intent:r,type:a,years:l,name:i,quantity:c,fromAddress:b,fundFrom:g}){let M=r==="Buy-Record"?"Buy-Name":r;if(g==="turbo"){let{mARIO:w,winc:S}=await this.paymentProvider.getArNSPriceDetails({intent:M,name:i,quantity:c,type:a,years:l});return{tokenCost:w.valueOf(),wincQty:S,discounts:[]}}let y=[{name:"Action",value:"Cost-Details"},{name:"Intent",value:M},{name:"Name",value:i},{name:"Years",value:l?.toString()},{name:"Quantity",value:c?.toString()},{name:"Purchase-Type",value:a},{name:"Fund-From",value:g}];return this.process.read({tags:qa(y),fromAddress:b})}async getRegistrationFees(){return this.process.read({tags:[{name:"Action",value:"Registration-Fees"}]})}async getDemandFactor(){return this.process.read({tags:[{name:"Action",value:"Demand-Factor"}]})}async getDemandFactorSettings(){return this.process.read({tags:[{name:"Action",value:"Demand-Factor-Settings"}]})}async getArNSReturnedNames(r){return this.process.read({tags:[{name:"Action",value:"Returned-Names"},...ff(r)]})}async getArNSReturnedName({name:r}){let a=[{name:"Action",value:"Returned-Name"},{name:"Name",value:r}];return this.process.read({tags:a})}async getDelegations(r){let a=[{name:"Action",value:"Paginated-Delegations"},{name:"Address",value:r.address},...ff(r)];return this.process.read({tags:qa(a)})}async getAllowedDelegates(r){return this.getGatewayDelegateAllowList(r)}async getGatewayVaults(r){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateway-Vaults"},{name:"Address",value:r.address},...ff(r)]})}async getPrimaryNameRequest(r){let a=[{name:"Action",value:"Primary-Name-Request"},{name:"Initiator",value:r.initiator}];return this.process.read({tags:a})}async getPrimaryNameRequests(r){return this.process.read({tags:[{name:"Action",value:"Primary-Name-Requests"},...ff(r)]})}async getPrimaryName(r){let a=[{name:"Action",value:"Primary-Name"},{name:"Address",value:r?.address},{name:"Name",value:r?.name}];return this.process.read({tags:qa(a)})}async getPrimaryNames(r){return this.process.read({tags:[{name:"Action",value:"Primary-Names"},...ff(r)]})}async getRedelegationFee(r){return this.process.read({tags:[{name:"Action",value:"Redelegation-Fee"},{name:"Address",value:r.address}]})}async getGatewayRegistrySettings(){return this.process.read({tags:[{name:"Action",value:"Gateway-Registry-Settings"}]})}async getAllDelegates(r){return this.process.read({tags:[{name:"Action",value:"All-Paginated-Delegates"},...ff(r)]})}async getAllGatewayVaults(r){return this.process.read({tags:[{name:"Action",value:"All-Gateway-Vaults"},...ff(r)]})}async resolveArNSName({name:r}){let a=r.lastIndexOf("_"),l=a===-1?r:r.slice(a+1),i=a===-1?"@":r.slice(0,a),c=await this.getArNSRecord({name:l});if(c===void 0||c.processId===void 0)throw new Error(`Base ArNS name ${l} not found on ARIO contract (${this.process.processId}).`);let b=j6.init({process:new Ea({ao:this.process.ao,processId:c.processId})}),[g,M]=await Promise.all([b.getOwner(),b.getRecord({undername:i})]);if(M===void 0)throw new Error(`Record for ${i} not found on ANT.`);if(M.ttlSeconds===void 0||M.transactionId===void 0)throw new Error(`Invalid record on ANT. Must have ttlSeconds and transactionId. Record: ${JSON.stringify(M)}`);return{name:r,owner:g,txId:M.transactionId,ttlSeconds:M.ttlSeconds,priority:M.priority,processId:c.processId,undernameLimit:c.undernameLimit,type:c.type}}async getArNSRecordsForAddress(r){let{antRegistryId:a=Fp,address:l}=r,i=E1.init({hyperbeamUrl:this.hyperbeamUrl,process:new Ea({ao:this.process.ao,processId:a})}),{Controlled:c=[],Owned:b=[]}=await i.accessControlList({address:l}),g=new Set([...c,...b]);return g.size===0?{items:[],hasMore:!1,nextCursor:void 0,limit:r.limit??1e3,totalItems:0,sortOrder:r.sortOrder??"asc"}:await this.getArNSRecords({...r,filters:{processId:Array.from(g)}})}},Lw=class extends W3{signer;paymentProvider;constructor({signer:r,paymentUrl:a,...l}){l===void 0?super({process:new Ea({processId:qf})}):super(l),this.signer=Zm(r),this.paymentProvider=Cw.init({signer:Zat(r)?r:void 0,paymentUrl:a})}async transfer({target:r,qty:a},l){let{tags:i=[]}=l||{};return this.process.send({tags:[...i,{name:"Action",value:"Transfer"},{name:"Recipient",value:r},{name:"Quantity",value:a.valueOf().toString()}],signer:this.signer})}async vaultedTransfer({recipient:r,quantity:a,lockLengthMs:l,revokable:i=!1},c){let{tags:b=[]}=c||{};return this.process.send({tags:[...b,{name:"Action",value:"Vaulted-Transfer"},{name:"Recipient",value:r},{name:"Quantity",value:a.toString()},{name:"Lock-Length",value:l.toString()},{name:"Revokable",value:`${i}`}],signer:this.signer})}async revokeVault({vaultId:r,recipient:a},l){let{tags:i=[]}=l||{};return this.process.send({tags:[...i,{name:"Action",value:"Revoke-Vault"},{name:"Vault-Id",value:r},{name:"Recipient",value:a}],signer:this.signer})}async createVault({lockLengthMs:r,quantity:a},l){let{tags:i=[]}=l||{};return this.process.send({tags:[...i,{name:"Action",value:"Create-Vault"},{name:"Lock-Length",value:r.toString()},{name:"Quantity",value:a.toString()}],signer:this.signer})}async extendVault({vaultId:r,extendLengthMs:a},l){let{tags:i=[]}=l||{};return this.process.send({tags:[...i,{name:"Action",value:"Extend-Vault"},{name:"Vault-Id",value:r},{name:"Extend-Length",value:a.toString()}],signer:this.signer})}async increaseVault({vaultId:r,quantity:a},l){let{tags:i=[]}=l||{};return this.process.send({tags:[...i,{name:"Action",value:"Increase-Vault"},{name:"Vault-Id",value:r},{name:"Quantity",value:a.toString()}],signer:this.signer})}async joinNetwork({operatorStake:r,allowDelegatedStaking:a,allowedDelegates:l,delegateRewardShareRatio:i,fqdn:c,label:b,minDelegatedStake:g,note:M,port:y,properties:w,protocol:S,autoStake:_,observerAddress:x},A){let{tags:k=[]}=A||{},B=[...k,{name:"Action",value:"Join-Network"},{name:"Operator-Stake",value:r.valueOf().toString()},{name:"Allow-Delegated-Staking",value:a?.toString()},{name:"Allowed-Delegates",value:l?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:i?.toString()},{name:"FQDN",value:c},{name:"Label",value:b},{name:"Min-Delegated-Stake",value:g?.valueOf().toString()},{name:"Note",value:M},{name:"Port",value:y?.toString()},{name:"Properties",value:w},{name:"Protocol",value:S},{name:"Auto-Stake",value:_?.toString()},{name:"Observer-Address",value:x}];return this.process.send({signer:this.signer,tags:qa(B)})}async leaveNetwork(r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Leave-Network"}]})}async updateGatewaySettings({allowDelegatedStaking:r,allowedDelegates:a,delegateRewardShareRatio:l,fqdn:i,label:c,minDelegatedStake:b,note:g,port:M,properties:y,protocol:w,autoStake:S,observerAddress:_},x){let{tags:A=[]}=x||{},k=[...A,{name:"Action",value:"Update-Gateway-Settings"},{name:"Label",value:c},{name:"Note",value:g},{name:"FQDN",value:i},{name:"Port",value:M?.toString()},{name:"Properties",value:y},{name:"Protocol",value:w},{name:"Observer-Address",value:_},{name:"Allow-Delegated-Staking",value:r?.toString()},{name:"Allowed-Delegates",value:a?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:l?.toString()},{name:"Min-Delegated-Stake",value:b?.valueOf().toString()},{name:"Auto-Stake",value:S?.toString()}];return this.process.send({signer:this.signer,tags:qa(k)})}async delegateStake(r,a){let{tags:l=[]}=a||{};return this.process.send({signer:this.signer,tags:[...l,{name:"Action",value:"Delegate-Stake"},{name:"Target",value:r.target},{name:"Quantity",value:r.stakeQty.valueOf().toString()}]})}async decreaseDelegateStake(r,a){let{tags:l=[]}=a||{};return this.process.send({signer:this.signer,tags:[...l,{name:"Action",value:"Decrease-Delegate-Stake"},{name:"Target",value:r.target},{name:"Quantity",value:r.decreaseQty.valueOf().toString()},{name:"Instant",value:`${r.instant||!1}`}]})}async instantWithdrawal(r,a){let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Instant-Withdrawal"},{name:"Vault-Id",value:r.vaultId},{name:"Address",value:r.gatewayAddress}];return this.process.send({signer:this.signer,tags:qa(i)})}async increaseOperatorStake(r,a){let{tags:l=[]}=a||{};return this.process.send({signer:this.signer,tags:[...l,{name:"Action",value:"Increase-Operator-Stake"},{name:"Quantity",value:r.increaseQty.valueOf().toString()}]})}async decreaseOperatorStake(r,a){let{tags:l=[]}=a||{};return this.process.send({signer:this.signer,tags:[...l,{name:"Action",value:"Decrease-Operator-Stake"},{name:"Quantity",value:r.decreaseQty.valueOf().toString()},{name:"Instant",value:`${r.instant||!1}`}]})}async saveObservations(r,a){let{tags:l=[]}=a||{};return this.process.send({signer:this.signer,tags:[...l,{name:"Action",value:"Save-Observations"},{name:"Report-Tx-Id",value:r.reportTxId},{name:"Failed-Gateways",value:r.failedGateways.join(",")}]})}async buyRecord(r,a){if(r.processId===void 0)try{r.processId=await j6.spawn({signer:this.signer,ao:this.process.ao,logger:this.logger,onSigningProgress:a?.onSigningProgress})}catch(c){throw this.logger.error("Failed to spawn ANT for name purchase.",{error:c}),c}if(a?.onSigningProgress?.("buying-name",{name:r.name,years:r.years,type:r.type,processId:r.processId,fundFrom:r.fundFrom,referrer:r.referrer}),r.fundFrom==="turbo"){if(!(this.paymentProvider instanceof Km))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Buy-Name",name:r.name,years:r.years,type:r.type,processId:r.processId,paidBy:r.paidBy})}let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Buy-Name"},{name:"Name",value:r.name},{name:"Years",value:r.years?.toString()??"1"},{name:"Process-Id",value:r.processId},{name:"Purchase-Type",value:r.type||"lease"},{name:"Fund-From",value:r.fundFrom},{name:"Referrer",value:r.referrer}];return this.process.send({signer:this.signer,tags:qa(i)})}async upgradeRecord(r,a){if(r.fundFrom==="turbo"){if(!(this.paymentProvider instanceof Km))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Upgrade-Name",name:r.name})}let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Upgrade-Name"},{name:"Name",value:r.name},{name:"Fund-From",value:r.fundFrom},{name:"Referrer",value:r.referrer}];return this.process.send({signer:this.signer,tags:qa(i)})}async extendLease(r,a){if(r.fundFrom==="turbo"){if(!(this.paymentProvider instanceof Km))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Extend-Lease",name:r.name,years:r.years})}let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Extend-Lease"},{name:"Name",value:r.name},{name:"Years",value:r.years.toString()},{name:"Fund-From",value:r.fundFrom},{name:"Referrer",value:r.referrer}];return this.process.send({signer:this.signer,tags:qa(i)})}async increaseUndernameLimit(r,a){if(r.fundFrom==="turbo"){if(!(this.paymentProvider instanceof Km))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Increase-Undername-Limit",quantity:r.increaseCount,name:r.name})}let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Increase-Undername-Limit"},{name:"Name",value:r.name},{name:"Quantity",value:r.increaseCount.toString()},{name:"Fund-From",value:r.fundFrom},{name:"Referrer",value:r.referrer}];return this.process.send({signer:this.signer,tags:qa(i)})}async cancelWithdrawal(r,a){let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Cancel-Withdrawal"},{name:"Vault-Id",value:r.vaultId},{name:"Address",value:r.gatewayAddress}];return this.process.send({signer:this.signer,tags:qa(i)})}async requestPrimaryName(r,a){if(r.fundFrom==="turbo")throw new Error("Turbo funding is not yet supported for primary name requests");let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Request-Primary-Name"},{name:"Name",value:r.name},{name:"Fund-From",value:r.fundFrom}];return this.process.send({signer:this.signer,tags:qa(i)})}async redelegateStake(r,a){let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Redelegate-Stake"},{name:"Target",value:r.target},{name:"Source",value:r.source},{name:"Quantity",value:r.stakeQty.valueOf().toString()},{name:"Vault-Id",value:r.vaultId}];return this.process.send({signer:this.signer,tags:qa(i)})}};var RJe=async({address:e,registry:r=E1.init()})=>{let a=await r.accessControlList({address:e});return[...new Set([...a.Owned,...a.Controlled])]};function CUt(e,r){return new Promise((a,l)=>{let i=setTimeout(()=>{l(new Error("Timeout"))},e);r.then(c=>{clearTimeout(i),a(c)}).catch(c=>{clearTimeout(i),l(c)})})}var LUt=class extends Pnt.default{contract;timeoutMs;throttle;logger;strict;antAoClient;constructor({contract:r=Dw.init({processId:qf}),timeoutMs:a=6e4,concurrency:l=30,logger:i=To.default,strict:c=!1,antAoClient:b=jh({MODE:"legacy"})}={}){super(),this.contract=r,this.timeoutMs=a,this.throttle=Z$t(l),this.logger=i,this.strict=c,this.antAoClient=b}async fetchProcessesOwnedByWallet({address:r,pageSize:a,antRegistry:l=E1.init()}){let i={},c=await l.accessControlList({address:r}),b=new Set([...c.Owned,...c.Controlled]);await CUt(this.timeoutMs,Y8e({contract:this.contract,emitter:this,pageSize:a})).catch(M=>(this.emit("error",`Error getting ArNS records: ${M}`),this.logger.error("Error getting ArNS records",{message:M?.message,stack:M?.stack}),{})).then(M=>{Object.entries(M).forEach(([y,w])=>{b.has(w.processId)&&(i[w.processId]==null&&(i[w.processId]={state:void 0,names:{}}),i[w.processId].names[y]=w)})});let g=Object.keys(i).length;this.emit("progress",0,g),await Promise.all(Object.keys(i).map(async(M,y)=>this.throttle(async()=>{if(i[M].state!==void 0){this.emit("progress",y+1,g);return}let w=j6.init({process:new Ea({processId:M,ao:this.antAoClient}),strict:this.strict}),S=await CUt(this.timeoutMs,w.getState()).catch(_=>{this.emit("error",`Error getting state for process ${M}: ${_}`)});(S?.Owner===r||S?.Controllers.includes(r))&&(i[M].state=S,this.emit("process",M,i[M])),this.emit("progress",y+1,g)}))),this.emit("end",i)}},Y8e=async({contract:e=Dw.init({processId:qf}),emitter:r,logger:a=To.default,pageSize:l=1e3})=>{let i,c=Date.now(),b={};do{let g=await e.getArNSRecords({cursor:i,limit:l}).catch(M=>{a?.error("Error getting ArNS records",{message:M?.message,stack:M?.stack}),r?.emit("arns:error",`Error getting ArNS records: ${M}`)});if(!g)return{};g.items.forEach(M=>{let{name:y,...w}=M;b[y]=w}),a.debug("Fetched page of ArNS records",{totalRecordCount:g.totalItems,fetchedRecordCount:Object.keys(b).length,cursor:g.nextCursor}),r?.emit("arns:pageLoaded",{totalRecordCount:g.totalItems,fetchedRecordCount:Object.keys(b).length,records:g.items,cursor:g.nextCursor}),i=g.nextCursor}while(i!==void 0);return r?.emit("arns:end",b),a.debug("Fetched all ArNS records",{totalRecordCount:Object.keys(b).length,durationMs:Date.now()-c}),b};var Ea=class{logger;ao;processId;constructor({processId:r,ao:a=jh({MODE:"legacy"}),logger:l=To.default}){this.processId=r,this.logger=l,this.ao=a}isMessageDataEmpty(r){return r===void 0||r==="null"||r===""||r===null}async read({tags:r,retries:a=3,fromAddress:l}){this.logger.debug("Evaluating read interaction on process",{tags:r,processId:this.processId});let i={process:this.processId,tags:r};l!==void 0&&(i.Owner=l);let c=0,b;for(;c<a;)try{b=await this.ao.dryrun(i);break}catch(w){if(c++,this.logger.debug(`Read attempt ${c} failed`,{error:w?.message,stack:w?.stack,tags:r,processId:this.processId}),c>=a)throw this.logger.debug("Maximum read attempts exceeded",{error:w?.message,stack:w?.stack,tags:r,processId:this.processId,ao:JSON.stringify(this.ao)}),new Error(`Failed to evaluate dry-run on process ${this.processId}.`,{cause:w});await new Promise(S=>setTimeout(S,2**c*1e3))}if(b===void 0)throw new Error("Unexpected error when evaluating read interaction");this.logger.debug("Read interaction result",{result:b,processId:this.processId});let g=lP(b);if(g!==void 0)throw new Error(g);if(b.Messages===void 0||b.Messages.length===0)throw this.logger.debug(`Empty result - process ${this.processId} does not support provided action.`,{result:b,tags:r,processId:this.processId}),new Error(b.message||`Process ${this.processId} did not return a valid response. Response: ${JSON.stringify(b)}`);let M=b.Messages?.[0]?.Data;return this.isMessageDataEmpty(M)?void 0:Tnt(M)}async send({tags:r,data:a,signer:l,retries:i=3}){let c,b=F$t(32);try{this.logger.debug("Evaluating send interaction on contract",{tags:r,data:a,processId:this.processId}),c=await this.ao.message({process:this.processId,tags:[...r,{name:"AR-IO-SDK",value:D3}],data:a,signer:l,anchor:b}),this.logger.debug("Sent message to process",{messageId:c,processId:this.processId,anchor:b})}catch(S){throw this.logger.debug("Error sending message to process",{error:S?.message,stack:S?.stack,processId:this.processId,tags:r}),S}if(c===void 0)throw new Error("Failed to send message to process.");let g,M=0;for(;M<i;)try{g=await this.ao.result({message:c,process:this.processId}),this.logger.debug("Message result",{result:g,messageId:c,processId:this.processId});break}catch(S){if(M++,this.logger.debug("Retrying send interaction",{attempts:M,retries:i,error:S?.message,processId:this.processId}),M>=i)return this.logger.debug(`Message was sent to process ${this.processId} with id ${c} but result was not returned. Review transactions for more details.`,{error:S?.message,stack:S?.stack,tags:r,processId:this.processId,messageId:c}),{id:c};await new Promise(_=>setTimeout(_,2**M*2e3))}if(g===void 0)return this.logger.debug(`Message was sent to process ${this.processId} with id ${c} but the result was not returned. Review transactions for more details.`,{tags:r,processId:this.processId,messageId:c}),{id:c};let y=lP(g);if(y!==void 0)throw new OB(y);if(g.Messages?.length===0||g.Messages===void 0)return{id:c};if(this.isMessageDataEmpty(g.Messages[0].Data))return{id:c};let w=Tnt(g.Messages[0].Data);return this.logger.debug("Message result data",{resultData:w,messageId:c,processId:this.processId}),{id:c,result:w}}};var G3=class{static init(r){return r!==void 0&&"signer"in r?new Wat(r):new dP(r)}},dP=class{process;constructor(r){if(r===void 0||Object.keys(r).length===0)this.process=new Ea({processId:Fp});else if(Wm(r))this.process=r.process;else if(Gm(r))this.process=new Ea({processId:r.processId});else throw new Kd}async getANTVersions(){let r=await this.process.read({tags:[{name:"Action",value:"Get-Versions"}]});return Object.fromEntries(Object.entries(r).sort(([a],[l])=>a.localeCompare(l)))}async getLatestANTVersion(){let r=await this.getANTVersions(),a=Object.entries(r).at(-1);if(!a)throw new Error("No version found");return{version:a[0],...a[1]}}},Wat=class extends dP{signer;constructor({signer:r,...a}){super(a),this.signer=Zm(r)}async addVersion(r,a){let{version:l,moduleId:i,luaSourceId:c,notes:b}=r;return this.process.send({tags:qa([{name:"Action",value:"Add-Version"},{name:"Version",value:l},{name:"Module-Id",value:i},{name:"Lua-Source-Id",value:c},{name:"Notes",value:b},...a?.tags??[]]),signer:this.signer})}};var j6=class{static get versions(){return G3.init()}static spawn=DUt;static init(r){return r!==void 0&&"signer"in r?new Gat(r):new cP(r)}},cP=class{process;processId;strict;hyperbeamUrl;checkHyperBeamPromise;logger=To.default;constructor(r){if(this.strict=r.strict||!1,Wm(r))this.process=r.process;else if(Gm(r))this.process=new Ea({processId:r.processId});else throw new Kd;this.processId=this.process.processId,r.hyperbeamUrl!==void 0&&(this.hyperbeamUrl=new URL(r.hyperbeamUrl),this.logger.debug(`Using HyperBEAM node for process ${this.processId}`,{hyperbeamUrl:this.hyperbeamUrl}))}checkHyperBeamCompatibility(){return this.hyperbeamUrl===void 0?Promise.resolve(!1):this.checkHyperBeamPromise!==void 0?this.checkHyperBeamPromise:(this.checkHyperBeamPromise=fetch(`${this.hyperbeamUrl.toString()}${this.processId}~process@1.0/now/cache`,{method:"HEAD",signal:AbortSignal.timeout(5e3)}).then(r=>!!r.ok),this.checkHyperBeamPromise)}async getState({strict:r}={strict:this.strict}){if(await this.checkHyperBeamCompatibility()){let i=0;for(;i<3;)try{let c=await fetch(`${this.hyperbeamUrl}${this.processId}~process@1.0/compute/cache/serialize~json@1.0`,{method:"GET",redirect:"follow",mode:"cors",headers:{"Content-Type":"application/json"}});if(c.status!==200)throw new Error(`Failed to fetch ant state: ${c?.statusText??"Unknown error"}`);let b=await c.json();if(!L$t(b))break;return D$t(b)}catch(c){this.logger.error(`Failed to fetch process state from HyperBEAM (attempt ${i+1} / 3)`,{cause:c}),i++,await new Promise(b=>setTimeout(b,1e3*i**2))}}let a=[{name:"Action",value:"State"}],l=await this.process.read({tags:a});return r&&Zd(AZ.passthrough().and(kr.object({Records:kr.record(kr.string(),Ix.passthrough())})),l),l}async getInfo({strict:r}={strict:this.strict}){if(await this.checkHyperBeamCompatibility()){let i=await this.getState();return{Name:i.Name,Ticker:i.Ticker,Description:i.Description,Keywords:i.Keywords,Denomination:i.Denomination.toString(),Owner:i.Owner,Logo:i.Logo,"Total-Supply":i.TotalSupply.toString(),Handlers:[]}}let a=[{name:"Action",value:"Info"}],l=await this.process.read({tags:a});return r&&Zd(ZMt.passthrough(),l),l}async getLogo(){return(await this.getInfo()).Logo}async getRecord({undername:r},{strict:a}={strict:this.strict}){if(await this.checkHyperBeamCompatibility()){let c=(await this.getRecords())[r];if(c===void 0)throw new Error("Record not found");return c}let l=await this.process.read({tags:[{name:"Action",value:"Record"},{name:"Sub-Domain",value:r}]});return a&&Zd(Ix.passthrough(),l),l}async getRecords({strict:r}={strict:this.strict}){if(await this.checkHyperBeamCompatibility()){let i=await this.getState();return Int(i.Records)}let a=[{name:"Action",value:"Records"}],l=await this.process.read({tags:a});return r&&Zd(Tx,l),Int(l)}async getOwner({strict:r}={strict:this.strict}){return await this.checkHyperBeamCompatibility()?(await this.getState()).Owner:(await this.getInfo({strict:r})).Owner}async getControllers({strict:r}={strict:this.strict}){if(await this.checkHyperBeamCompatibility())return(await this.getState()).Controllers;let a=[{name:"Action",value:"Controllers"}],l=await this.process.read({tags:a});return r&&Zd(Bx,l),l}async getName({strict:r}={strict:this.strict}){return await this.checkHyperBeamCompatibility()?(await this.getState()).Name:(await this.getInfo({strict:r})).Name}async getTicker({strict:r}={strict:this.strict}){return await this.checkHyperBeamCompatibility()?(await this.getState()).Ticker:(await this.getInfo({strict:r})).Ticker}async getBalances({strict:r}={strict:this.strict}){let l=(await this.getState()).Balances;return r&&Zd(Px,l),l}async getBalance({address:r},{strict:a}={strict:this.strict}){if(await this.checkHyperBeamCompatibility())return(await this.getBalances())[r]??0;let l=[{name:"Action",value:"Balance"},{name:"Recipient",value:r}],i=await this.process.read({tags:l});return a&&Zd(kr.number(),i),i}async getHandlers(){if(await this.checkHyperBeamCompatibility())throw new Error("Handlers are not supported on HyperBeam");let r=await this.getInfo();return r.Handlers??r.HandlerNames}},Gat=class extends cP{signer;constructor({signer:r,...a}){super(a),this.signer=Zm(r)}async transfer({target:r},a){let l=[...a?.tags??[],{name:"Action",value:"Transfer"},{name:"Recipient",value:r}];return this.process.send({tags:l,signer:this.signer})}async addController({controller:r},a){let l=[...a?.tags??[],{name:"Action",value:"Add-Controller"},{name:"Controller",value:r}];return this.process.send({tags:l,signer:this.signer})}async removeController({controller:r},a){let l=[...a?.tags??[],{name:"Action",value:"Remove-Controller"},{name:"Controller",value:r}];return this.process.send({tags:l,signer:this.signer})}async setRecord({undername:r,transactionId:a,ttlSeconds:l},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:r},{name:"Transaction-Id",value:a},{name:"TTL-Seconds",value:l.toString()}],signer:this.signer})}async setBaseNameRecord({transactionId:r,ttlSeconds:a},l){return this.setRecord({transactionId:r,ttlSeconds:a,undername:"@"},l)}async setUndernameRecord({undername:r,transactionId:a,ttlSeconds:l},i){return this.setRecord({undername:r,transactionId:a,ttlSeconds:l},i)}async removeUndernameRecord({undername:r}){return this.removeRecord({undername:r})}async removeRecord({undername:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Remove-Record"},{name:"Sub-Domain",value:r}],signer:this.signer})}async setTicker({ticker:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Set-Ticker"},{name:"Ticker",value:r}],signer:this.signer})}async setName({name:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Set-Name"},{name:"Name",value:r}],signer:this.signer})}async setDescription({description:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Set-Description"},{name:"Description",value:r}],signer:this.signer})}async setKeywords({keywords:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Set-Keywords"},{name:"Keywords",value:JSON.stringify(r)}],signer:this.signer})}async setLogo({txId:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Set-Logo"},{name:"Logo",value:r}],signer:this.signer})}async releaseName({name:r,arioProcessId:a},l){return this.process.send({tags:[...l?.tags??[],{name:"Action",value:"Release-Name"},{name:"Name",value:r},{name:"IO-Process-Id",value:a},{name:"ARIO-Process-Id",value:a}],signer:this.signer})}async reassignName({name:r,arioProcessId:a,antProcessId:l},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Reassign-Name"},{name:"Name",value:r},{name:"IO-Process-Id",value:a},{name:"ARIO-Process-Id",value:a},{name:"Process-Id",value:l}],signer:this.signer})}async approvePrimaryNameRequest({name:r,address:a,arioProcessId:l},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Approve-Primary-Name"},{name:"Name",value:r},{name:"Recipient",value:a},{name:"IO-Process-Id",value:l},{name:"ARIO-Process-Id",value:l}],signer:this.signer})}async removePrimaryNames({names:r,arioProcessId:a,notifyOwners:l=!1},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Remove-Primary-Names"},{name:"Names",value:r.join(",")},{name:"IO-Process-Id",value:a},{name:"ARIO-Process-Id",value:a},{name:"Notify-Owners",value:l.toString()}],signer:this.signer})}};var E1=class{static init(r){return r!==void 0&&"signer"in r?new Vat(r):new pP(r)}},pP=class{process;hyperbeamUrl;checkHyperBeamPromise;logger;constructor(r){if(this.logger=r?.logger??To.default,r===void 0||Object.keys(r).length===0)this.process=new Ea({processId:Fp});else if(Wm(r))this.process=r.process;else if(Gm(r))this.process=new Ea({processId:r.processId});else throw new Kd;r?.hyperbeamUrl!==void 0&&(this.hyperbeamUrl=new URL(r.hyperbeamUrl).toString(),this.checkHyperBeamPromise=this.checkHyperBeamCompatibility())}async checkHyperBeamCompatibility(){return this.hyperbeamUrl===void 0?Promise.resolve(!1):this.checkHyperBeamPromise!==void 0?this.checkHyperBeamPromise:(this.logger.debug("Checking HyperBeam compatibility"),this.checkHyperBeamPromise=fetch(`${this.hyperbeamUrl.toString()}${this.process.processId}~process@1.0/now/cache/acl`,{method:"HEAD",signal:AbortSignal.timeout(5e3)}).then(r=>r.ok?(this.logger.debug("HyperBeam compatible"),!0):(this.logger.debug("HyperBeam not compatible"),!1)),this.checkHyperBeamPromise)}async accessControlList({address:r}){if(await this.checkHyperBeamCompatibility()){let a=0;for(;a<3;)try{this.logger.debug("Fetching ant registry acl for address from hyperbeam",r);let l=await fetch(`${this.hyperbeamUrl?.toString()}${this.process.processId}~process@1.0/now/cache/acl/${r}/serialize~json@1.0`);if(l.status!==200)throw this.logger.debug("Failed to fetch ant registry acl for address from hyperbeam",r,l.status,l.statusText),new Error(`Failed to fetch ant registry acl for address ${r}: ${l?.statusText??"Unknown error"}`);this.logger.debug("Fetched ant registry acl for address from hyperbeam",r);let i=await l.json();return{Owned:i.Owned,Controlled:i.Controlled}}catch{a++,this.logger.debug("Failed to fetch ant registry acl for address from hyperbeam",r,a),await new Promise(i=>setTimeout(i,1e3*a**2))}}return this.logger.debug("Fetching ant registry acl for address from process",r),this.process.read({tags:[{name:"Action",value:"Access-Control-List"},{name:"Address",value:r}]})}async getAntsForAddress({address:r}){return this.accessControlList({address:r})}},Vat=class extends pP{signer;constructor({signer:r,...a}){super(a),this.signer=Zm(r)}async register({processId:r}){return this.process.send({tags:[{name:"Action",value:"Register"},{name:"Process-Id",value:r}],signer:this.signer})}};async function DUt({signer:e,module:r,ao:a=jh({MODE:"legacy"}),scheduler:l=zMt,state:i,antRegistryId:c=Fp,logger:b=To.default,authority:g=jMt,onSigningProgress:M=(y,w)=>{b.debug("Signing progress",{name:y,payload:w})}}){i&&Zd(KMt,i);let y;if(r===void 0){let k=G3.init({process:new Ea({processId:c,ao:a,logger:b})}),{moduleId:B,version:P}=await k.getLatestANTVersion();b.debug("Spawning new ANT with latest module from ANT registry",{moduleId:B,version:P,antRegistryId:c}),r=B,y=P}M?.("spawning-ant",{moduleId:r,antRegistryId:c,version:y,state:i});let w=await a.spawn({module:r,scheduler:l,signer:e,data:i?JSON.stringify(i):void 0,tags:[{name:"Authority",value:g},{name:"ANT-Registry-Id",value:c}]});if(i!==void 0){let k,B=0;for(;B<5&&k===void 0;)try{k===void 0&&(k=await a.result({process:w,message:w}));break}catch(P){b.debug("Retrying ANT boot result fetch",{processId:w,module:r,scheduler:l,attempts:B,error:P}),B++,await new Promise(O=>setTimeout(O,1e3*B**2))}if(k===void 0||k.Messages?.some(P=>P?.Tags?.some(O=>O.value==="Invalid-Boot-Notice"))){if(k===void 0)throw new Error("Failed to get boot result");let P=lP(k);throw b.error("ANT failed to boot correctly",{processId:w,module:r,scheduler:l,bootRes:k,bootError:P}),new Error(`ANT failed to boot correctly: ${P}`)}}M?.("verifying-state",{processId:w,moduleId:r,antRegistryId:c});let S;try{let k=new Ea({processId:w,ao:a,logger:b}),{id:B}=await k.send({tags:[{name:"Action",value:"State"}],signer:e}),P=await a.result({process:w,message:B});if(P===void 0)throw new Error("Failed to get state result");let{Owner:O}=JSON.parse(P.Messages?.[0]?.Data??"{}");S=O,b.debug("Successfully spawned new ANT and validated owner",{processId:w,module:r,owner:S})}catch(k){throw b.error("Failed to validate owner of spawned ANT",{processId:w,module:r,error:k}),k}if(S===void 0)throw new Error(`Spawning ANT (${w}) failed to set owner`);M?.("registering-ant",{processId:w,antRegistryId:c,owner:S});let _=E1.init({signer:e,processId:c}),x=0,A=5;for(;x<A;)try{let k=await _.accessControlList({address:S});if(k===void 0)throw new Error("ACL not found for owner");let{Owned:B}=k;if(!B.includes(w))throw new Error(`Spawned ANT (${w}) not found in registry for owner ${S}`);return w}catch(k){b.debug("Retrying ANT registry access control list fetch",{owner:S,antRegistryId:c,attempts:x,error:k}),x++,await new Promise(B=>setTimeout(B,1e3*x**2))}return w}async function EQe({signer:e,processId:r,luaCodeTxId:a=UMt,ao:l=jh({MODE:"legacy"}),logger:i=To.default,arweave:c=HB}){let b=new Ea({processId:r,ao:l,logger:i});i.warn("Directly running an Eval on a process is not encouraged.");let{api:{host:g,port:M,protocol:y}}=c.getConfig(),w=await fetch(`${y}://${g}:${M}/${a}`).then(_=>_.text()),{id:S}=await b.send({tags:[{name:"Action",value:"Eval"},{name:"App-Name",value:"ArNS-ANT"},{name:"Source-Code-TX-ID",value:a}],data:w,signer:e});return i.debug("Evolved ANT",{processId:r,luaCodeTxId:a,evalMsgId:S}),S}function J8e(e){let r=kr.object({name:kr.string(),value:kr.union([kr.string(),kr.number()])}),a=kr.function().args(kr.object({data:kr.union([kr.string(),kr.instanceof(Kt)]),tags:kr.array(r).optional(),target:kr.string().optional(),anchor:kr.string().optional()})).returns(kr.promise(kr.object({id:kr.string(),raw:kr.instanceof(ArrayBuffer)})));try{return a.parse(e),!0}catch{return!1}}function Zm(e){return J8e(e)?e:"publicKey"in e?async({data:a,tags:l,target:i,anchor:c})=>{if(e.publicKey===void 0&&"setPublicKey"in e&&typeof e.setPublicKey=="function"&&await e.setPublicKey(),e instanceof al){let M=await e.signer.signDataItem({data:a,tags:l,target:i,anchor:c}),y=new vg(Kt.from(M));return{id:await y.id,raw:await y.getRaw()}}let b=b4(a,e,{tags:l,target:i,anchor:c});return b.sign(e).then(async()=>({id:await b.id,raw:await b.getRaw()}))}:k$t(e)}var X8e="-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI",Q8e="Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A";function AQe({owner:e,targetId:r,ttlSeconds:a=3600,keywords:l=[],controllers:i=[],description:c="",ticker:b="aos",name:g="ANT",logo:M=Q8e}){return{ticker:b,name:g,description:c,keywords:l,owner:e,controllers:[e,...i],balances:{[e]:1},records:{"@":{transactionId:r??X8e.toString(),ttlSeconds:a}},logo:M}}function Yat(e){return kr.object({startTimestamp:kr.number(),startHeight:kr.number(),distributions:kr.any(),endTimestamp:kr.number(),prescribedObservers:kr.any(),prescribedNames:kr.array(kr.string()),observations:kr.any(),epochIndex:kr.number()}).parse(e)}function lP(e){let a=e.Error??e.Messages?.[0]?.Tags?.find(l=>l.name==="Error")?.value;if(a!==void 0){let l=a.match(/\[string "(.+)"\]:(\d+):\s*(.*)/);if(l){let[,,i,c]=l;return`${$Ut(c).trim()} (line ${i.trim()})`.trim()}return $Ut(a)}}function $Ut(e){return e.replace(new RegExp("\x1B[\\[\\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]","g"),"").trim()}var qUt=e=>Rx.test(e);function qQe(e){return e!==void 0&&!isNaN(parseInt(e.toString()))}var qa=e=>e.filter(r=>r.value!==void 0&&r.value!==""),ff=e=>{let r=[{name:"Cursor",value:e?.cursor?.toString()},{name:"Limit",value:e?.limit?.toString()},{name:"Sort-By",value:e?.sortBy?.toString()},{name:"Sort-Order",value:e?.sortOrder?.toString()},...e?.filters?[{name:"Filters",value:JSON.stringify(e.filters)}]:[]];return qa(r)},tye=async({arweave:e,epochIndex:r,processId:a=qf,retries:l=3,gqlUrl:i="https://arweave-search.goldsky.com/graphql"})=>{let c=rye({epochIndex:r,processId:a});for(let b=0;b<l;b++)try{let g=await fetch(i,{method:"POST",body:c,headers:{"Content-Type":"application/json"}}).then(w=>w.json());if(g?.data?.transactions?.edges?.length===0)return;let M=g.data.transactions.edges[0].node.id,y=await e.api.get(M);return Yat(y.data)}catch(g){if(b===l-1)throw g;await new Promise(M=>setTimeout(M,Math.pow(2,b)*1e3))}},U6=async({arweave:e,ao:r,epochIndex:a,processId:l=qf})=>{let i=await tye({arweave:e,epochIndex:a,processId:l});if(i)return i;let c=await eye({ao:r,epochIndex:a,processId:l});if(c)return c},eye=async({ao:e,epochIndex:r,processId:a=qf,gqlUrl:l="https://arweave-search.goldsky.com/graphql"})=>{let i=iye({epochIndex:r,processId:a}),b=await(await fetch(l,{method:"POST",body:i,headers:{"Content-Type":"application/json"}})).json();if(b.data.transactions.edges.length!==0)for(let g of b.data.transactions.edges){let M=g.node.id,y=await e.result({message:M,process:a}).catch(()=>{});if(y)for(let w of y?.Messages??[]){let S=JSON.parse(w.Data),_=w.Tags;if(_.some(x=>x.name==="Action"&&x.value==="Epoch-Distribution-Notice")&&_.some(x=>x.name==="Epoch-Index"&&x.value===r.toString()))return Yat(S)}}},rye=({epochIndex:e,processId:r=qf,authorities:a=["fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY"]})=>JSON.stringify({query:`
151
+ `+c):l.stack=c}catch{}}throw l}}_request(r,a){typeof r=="string"?(a=a||{},a.url=r):a=r||{},a=Bl(this.defaults,a);let{transitional:l,paramsSerializer:i,headers:c}=a;l!==void 0&&Nw.assertOptions(l,{silentJSONParsing:Yd.transitional(Yd.boolean),forcedJSONParsing:Yd.transitional(Yd.boolean),clarifyTimeoutError:Yd.transitional(Yd.boolean)},!1),i!=null&&(Ye.isFunction(i)?a.paramsSerializer={serialize:i}:Nw.assertOptions(i,{encode:Yd.function,serialize:Yd.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),Nw.assertOptions(a,{baseUrl:Yd.spelling("baseURL"),withXsrfToken:Yd.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let b=c&&Ye.merge(c.common,c[a.method]);c&&Ye.forEach(["delete","get","head","post","put","patch","common"],A=>{delete c[A]}),a.headers=Yo.concat(b,c);let g=[],M=!0;this.interceptors.request.forEach(function(k){typeof k.runWhen=="function"&&k.runWhen(a)===!1||(M=M&&k.synchronous,g.unshift(k.fulfilled,k.rejected))});let y=[];this.interceptors.response.forEach(function(k){y.push(k.fulfilled,k.rejected)});let w,S=0,_;if(!M){let A=[nP.bind(this),void 0];for(A.unshift.apply(A,g),A.push.apply(A,y),_=A.length,w=Promise.resolve(a);S<_;)w=w.then(A[S++],A[S++]);return w}_=g.length;let x=a;for(S=0;S<_;){let A=g[S++],k=g[S++];try{x=A(x)}catch(B){k.call(this,B);break}}try{w=nP.call(this,x)}catch(A){return Promise.reject(A)}for(S=0,_=y.length;S<_;)w=w.then(y[S++],y[S++]);return w}getUri(r){r=Bl(this.defaults,r);let a=Pw(r.baseURL,r.url,r.allowAbsoluteUrls);return Rw(a,r.params,r.paramsSerializer)}};Ye.forEach(["delete","get","head","options"],function(r){Z3.prototype[r]=function(a,l){return this.request(Bl(l||{},{method:r,url:a,data:(l||{}).data}))}});Ye.forEach(["post","put","patch"],function(r){function a(l){return function(c,b,g){return this.request(Bl(g||{},{method:r,headers:l?{"Content-Type":"multipart/form-data"}:{},url:c,data:b}))}}Z3.prototype[r]=a(),Z3.prototype[r+"Form"]=a(!0)});var Ow=Z3;Et();Rt();At();var $at=class e{constructor(r){if(typeof r!="function")throw new TypeError("executor must be a function.");let a;this.promise=new Promise(function(c){a=c});let l=this;this.promise.then(i=>{if(!l._listeners)return;let c=l._listeners.length;for(;c-- >0;)l._listeners[c](i);l._listeners=null}),this.promise.then=i=>{let c,b=new Promise(g=>{l.subscribe(g),c=g}).then(i);return b.cancel=function(){l.unsubscribe(c)},b},r(function(c,b,g){l.reason||(l.reason=new Vd(c,b,g),a(l.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(r){if(this.reason){r(this.reason);return}this._listeners?this._listeners.push(r):this._listeners=[r]}unsubscribe(r){if(!this._listeners)return;let a=this._listeners.indexOf(r);a!==-1&&this._listeners.splice(a,1)}toAbortSignal(){let r=new AbortController,a=l=>{r.abort(l)};return this.subscribe(a),r.signal.unsubscribe=()=>this.unsubscribe(a),r.signal}static source(){let r;return{token:new e(function(i){r=i}),cancel:r}}},MUt=$at;Et();Rt();At();function qat(e){return function(a){return e.apply(null,a)}}Et();Rt();At();function Uat(e){return Ye.isObject(e)&&e.isAxiosError===!0}Et();Rt();At();var jat={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(jat).forEach(([e,r])=>{jat[r]=e});var _Ut=jat;function SUt(e){let r=new Ow(e),a=xw(Ow.prototype.request,r);return Ye.extend(a,Ow.prototype,r,{allOwnKeys:!0}),Ye.extend(a,r,null,{allOwnKeys:!0}),a.create=function(i){return SUt(Bl(e,i))},a}var Bo=SUt(F3);Bo.Axios=Ow;Bo.CanceledError=Vd;Bo.CancelToken=MUt;Bo.isCancel=Tw;Bo.VERSION=aP;Bo.toFormData=Fm;Bo.AxiosError=Xr;Bo.Cancel=Bo.CanceledError;Bo.all=function(r){return Promise.all(r)};Bo.spread=qat;Bo.isAxiosError=Uat;Bo.mergeConfig=Bl;Bo.AxiosHeaders=Yo;Bo.formToJSON=e=>XB(Ye.isHTMLForm(e)?new FormData(e):e);Bo.getAdapter=iP.getAdapter;Bo.HttpStatusCode=_Ut;Bo.default=Bo;var sP=Bo;var{Axios:qGe,AxiosError:UGe,CanceledError:jGe,isCancel:zGe,CancelToken:FGe,VERSION:HGe,all:KGe,Cancel:ZGe,isAxiosError:WGe,spread:GGe,toFormData:VGe,AxiosHeaders:YGe,HttpStatusCode:JGe,formToJSON:XGe,getAdapter:QGe,mergeConfig:tVe}=sP;Et();Rt();At();var RUt=An(EUt(),1),zat="axios-retry";function kUt(e){let r=["ERR_CANCELED","ECONNABORTED"];return e.response||!e.code||r.includes(e.code)?!1:(0,RUt.default)(e)}var IUt=["get","head","options"],$8e=IUt.concat(["put","delete"]);function Fat(e){return e.code!=="ECONNABORTED"&&(!e.response||e.response.status===429||e.response.status>=500&&e.response.status<=599)}function q8e(e){return e.config?.method?Fat(e)&&IUt.indexOf(e.config.method)!==-1:!1}function TUt(e){return e.config?.method?Fat(e)&&$8e.indexOf(e.config.method)!==-1:!1}function BUt(e){return kUt(e)||TUt(e)}function Hat(e=void 0){let r=e?.response?.headers["retry-after"];if(!r)return 0;let a=(Number(r)||0)*1e3;return a===0&&(a=(new Date(r).valueOf()||0)-Date.now()),Math.max(0,a)}function U8e(e=0,r=void 0){return Math.max(0,Hat(r))}function j8e(e=0,r=void 0,a=100){let l=2**e*a,i=Math.max(l,Hat(r)),c=i*.2*Math.random();return i+c}function z8e(e=100){return(r=0,a=void 0)=>{let l=r*e;return Math.max(l,Hat(a))}}var F8e={retries:3,retryCondition:BUt,retryDelay:U8e,shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function H8e(e,r){return{...F8e,...r,...e[zat]}}function AUt(e,r,a=!1){let l=H8e(e,r||{});return l.retryCount=l.retryCount||0,(!l.lastRequestTime||a)&&(l.lastRequestTime=Date.now()),e[zat]=l,l}function K8e(e,r){e.defaults.agent===r.agent&&delete r.agent,e.defaults.httpAgent===r.httpAgent&&delete r.httpAgent,e.defaults.httpsAgent===r.httpsAgent&&delete r.httpsAgent}async function Z8e(e,r){let{retries:a,retryCondition:l}=e,i=(e.retryCount||0)<a&&l(r);if(typeof i=="object")try{return await i!==!1}catch{return!1}return i}async function W8e(e,r,a,l){r.retryCount+=1;let{retryDelay:i,shouldResetTimeout:c,onRetry:b}=r,g=i(r.retryCount,a);if(K8e(e,l),!c&&l.timeout&&r.lastRequestTime){let M=Date.now()-r.lastRequestTime,y=l.timeout-M-g;if(y<=0)return Promise.reject(a);l.timeout=y}return l.transformRequest=[M=>M],await b(r.retryCount,a,l),l.signal?.aborted?Promise.resolve(e(l)):new Promise(M=>{let y=()=>{clearTimeout(w),M(e(l))},w=setTimeout(()=>{M(e(l)),l.signal?.removeEventListener&&l.signal.removeEventListener("abort",y)},g);l.signal?.addEventListener&&l.signal.addEventListener("abort",y,{once:!0})})}async function G8e(e,r){e.retryCount>=e.retries&&await e.onMaxRetryTimesExceeded(r,e.retryCount)}var Hm=(e,r)=>{let a=e.interceptors.request.use(i=>(AUt(i,r,!0),i[zat]?.validateResponse&&(i.validateStatus=()=>!1),i)),l=e.interceptors.response.use(null,async i=>{let{config:c}=i;if(!c)return Promise.reject(i);let b=AUt(c,r);return i.response&&b.validateResponse?.(i.response)?i.response:await Z8e(b,i)?W8e(e,b,i,c):(await G8e(b,i),Promise.reject(i))});return{requestInterceptorId:a,responseInterceptorId:l}};Hm.isNetworkError=kUt;Hm.isSafeRequestError=q8e;Hm.isIdempotentRequestError=TUt;Hm.isNetworkOrIdempotentRequestError=BUt;Hm.exponentialDelay=j8e;Hm.linearDelay=z8e;Hm.isRetryableError=Fat;var fP=Hm;var PUt=({axiosConfig:e={},logger:r=To.default,retryConfig:a={retries:5,retryDelay:fP.exponentialDelay,retryCondition:l=>fP.isRetryableError(l),onRetry(l,i,c){r.error(`Retrying request ${c.url} attempt ${l}`,i)}}}={})=>{let l=sP.create({...e,maxRedirects:0,headers:{...e.headers,"x-source-version":`${D3}`,"x-source-identifier":"ar-io-sdk"},validateStatus:()=>!0});return fP(l,a),l};Et();Rt();At();var Kat=({baseUrl:e,params:r})=>{let a=new URL(e);return Object.entries(r).forEach(([l,i])=>{if(i!=null)if(Array.isArray(i)&&i.length>0)for(let c of i)c!=null&&a.searchParams.append(l,c.toString());else a.searchParams.set(l,i.toString())}),a.toString()};async function V8e({signer:e,nonce:r=mat()}){let a,l,i=hP(e)?Hr.ARWEAVE:e.signatureType;switch(hP(e)?a=q3(Kt.from(await e.signMessage(Uint8Array.from(Kt.from(r))))):e instanceof al?a=q3(Kt.from(await e.signer.signMessage(Uint8Array.from(Kt.from(r))))):(e instanceof Wu||e instanceof Is||e instanceof av)&&("setPublicKey"in e&&e.publicKey===void 0&&await e.setPublicKey(),a=q3(Kt.from(await e.sign(Uint8Array.from(Kt.from(r)))))),i){case Hr.ARWEAVE:hP(e)?l=await e.getActivePublicKey():"setPublicKey"in e&&(await e.setPublicKey(),l=q3(e.publicKey));break;case Hr.ETHEREUM:if("publicKey"in e)l="0x"+e.publicKey.toString("hex");else throw new Error("Public key not found");break;default:throw new Error(`Unsupported signer type for signing requests: ${i}`)}if(l===void 0||a===void 0)throw new Error("Public key or signature not found");return{"x-public-key":l,"x-nonce":r,"x-signature":a,"x-signature-type":i.toString()}}var Cw=class{static init(r){let{signer:a,paymentUrl:l,axios:i,logger:c}=r??{};return a!==void 0?new Km({signer:a,paymentUrl:l,axios:i,logger:c}):new uP({paymentUrl:l,axios:i,logger:c})}},uP=class{paymentUrl;axios;logger;constructor({paymentUrl:r="https://payment.ardrive.io",axios:a=PUt(),logger:l=To.default}){this.paymentUrl=r,this.axios=a,this.logger=l}async getArNSPriceDetails({intent:r,name:a,quantity:l,type:i,years:c}){let b=Kat({baseUrl:`${this.paymentUrl}/v1/arns/price/${r}/${a}`,params:{increaseQty:l,type:i,years:c}}),{data:g,status:M}=await this.axios.get(b);if(this.logger.debug("getArNSPriceDetails",{intent:r,name:a,quantity:l,type:i,years:c,data:g,status:M}),M!==200)throw new Error("Failed to get ArNS purchase price "+JSON.stringify(g));if(!g.winc||!g.mARIO)throw new Error("Invalid response from Turbo "+JSON.stringify(g));return{winc:g.winc,mARIO:new Sw(+g.mARIO)}}async getPrice(r){let{winc:a}=await this.getArNSPriceDetails(r);return+a}},Km=class extends uP{signer;constructor({signer:r,...a}){if(super(a),!Zat(r))throw new Error("Signer must be a TurboArNSSigner");this.signer=r}async initiateArNSPurchase({intent:r,name:a,quantity:l,type:i,processId:c,years:b,paidBy:g=[],referrer:M}){let y=Kat({baseUrl:`${this.paymentUrl}/v1/arns/purchase/${r}/${a}`,params:{increaseQty:l,processId:c,type:i,years:b,paidBy:g,referrer:M}}),w=await V8e({signer:this.signer}),{data:S,status:_}=await this.axios.post(y,null,{headers:w});if(this.logger.debug("Initiated ArNS purchase",{intent:r,name:a,quantity:l,processId:c,type:i,years:b,data:S,status:_}),_!==200)throw new Error("Failed to initiate ArNS purchase "+JSON.stringify(S));return{id:S.arioWriteResult.id,result:S.purchaseReceipt}}};function hP(e){return typeof e=="object"&&e!==null&&"signMessage"in e&&"getActivePublicKey"in e}function Zat(e){let r=hP(e),a=e instanceof Is||e instanceof av||e instanceof Wu||e instanceof al;return r||a}var Dw=class{static init(r){return r!==void 0&&"signer"in r?new Lw(r):new W3(r)}static mainnet(r){return r!==void 0&&"signer"in r?new Lw({...r,process:new Ea({processId:qf,ao:jh({MODE:"legacy",CU_URL:"https://cu.ardrive.io",...r?.process?.ao})})}):new W3({...r,process:new Ea({processId:qf,ao:jh({CU_URL:"https://cu.ardrive.io",MODE:"legacy",...r?.process?.ao})})})}static testnet(r){return r!==void 0&&"signer"in r?lat({arioInstance:new Lw({...r,process:new Ea({processId:SZ,ao:jh({MODE:"legacy",CU_URL:"https://cu.ardrive.io",...r?.process?.ao})})}),faucetApiUrl:r?.faucetUrl}):lat({arioInstance:new W3({...r,process:new Ea({processId:SZ,ao:jh({MODE:"legacy",CU_URL:"https://cu.ardrive.io",...r?.process?.ao})})}),faucetApiUrl:r?.faucetUrl})}},W3=class{process;epochSettings;arweave;paymentProvider;logger=To.default;constructor(r){if(this.arweave=r?.arweave??HB,r===void 0||Object.keys(r).length===0)this.process=new Ea({processId:qf});else if(Wm(r))this.process=r.process;else if(Gm(r))this.process=new Ea({processId:r.processId});else throw new Kd;this.paymentProvider=Cw.init({paymentUrl:r?.paymentUrl})}async getInfo(){return this.process.read({tags:[{name:"Action",value:"Info"}]})}async getTokenSupply(){return this.process.read({tags:[{name:"Action",value:"Total-Token-Supply"}]})}async computeEpochIndexForTimestamp(r){let a=await this.getEpochSettings(),l=a.epochZeroStartTimestamp,i=a.durationMs;return Math.floor((r-l)/i)}async computeCurrentEpochIndex(){return this.computeEpochIndexForTimestamp(Date.now())}async computeEpochIndex(r){let a=r?.epochIndex;if(a!==void 0)return a;let l=r?.timestamp;if(l!==void 0)return this.computeEpochIndexForTimestamp(l)}async getEpochSettings(){return this.epochSettings??=await this.process.read({tags:[{name:"Action",value:"Epoch-Settings"}]})}async getEpoch(r){let a=await this.computeEpochIndex(r),l=await this.computeCurrentEpochIndex();if(a!==void 0&&a<l){let c=await U6({arweave:this.arweave,epochIndex:a,processId:this.process.processId,ao:this.process.ao});if(!c)throw new Error("Epoch data not found for epoch index "+a);return OUt(c)}let i=[{name:"Action",value:"Epoch"},{name:"Epoch-Index",value:l.toString()}];return this.process.read({tags:qa(i)})}async getArNSRecord({name:r}){return this.process.read({tags:[{name:"Action",value:"Record"},{name:"Name",value:r}]})}async getArNSRecords(r){return this.process.read({tags:[{name:"Action",value:"Paginated-Records"},...ff(r)]})}async getArNSReservedNames(r){return this.process.read({tags:[{name:"Action",value:"Reserved-Names"},...ff(r)]})}async getArNSReservedName({name:r}){return this.process.read({tags:[{name:"Action",value:"Reserved-Name"},{name:"Name",value:r}]})}async getBalance({address:r}){return this.process.read({tags:[{name:"Action",value:"Balance"},{name:"Address",value:r}]})}async getBalances(r){return this.process.read({tags:[{name:"Action",value:"Paginated-Balances"},...ff(r)]})}async getVault({address:r,vaultId:a}){return this.process.read({tags:[{name:"Action",value:"Vault"},{name:"Address",value:r},{name:"Vault-Id",value:a}]})}async getVaults(r){return this.process.read({tags:[{name:"Action",value:"Paginated-Vaults"},...ff(r)]})}async getGateway({address:r}){return this.process.read({tags:[{name:"Action",value:"Gateway"},{name:"Address",value:r}]})}async getGatewayDelegates({address:r,...a}){return this.process.read({tags:[{name:"Action",value:"Paginated-Delegates"},{name:"Address",value:r},...ff(a)]})}async getGatewayDelegateAllowList({address:r,...a}){return this.process.read({tags:[{name:"Action",value:"Paginated-Allowed-Delegates"},{name:"Address",value:r},...ff(a)]})}async getGateways(r){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateways"},...ff(r)]})}async getCurrentEpoch(){return this.process.read({tags:[{name:"Action",value:"Epoch"}]})}async getPrescribedObservers(r){let a=await this.computeEpochIndex(r),l=await this.computeCurrentEpochIndex();if(a!==void 0&&a<l){let c=await U6({ao:this.process.ao,arweave:this.arweave,epochIndex:a,processId:this.process.processId});if(!c)throw new Error("Epoch data not found for epoch index "+a);return c.prescribedObservers}let i=[{name:"Action",value:"Epoch-Prescribed-Observers"},{name:"Epoch-Index",value:l.toString()}];return this.process.read({tags:qa(i)})}async getPrescribedNames(r){let a=await this.computeEpochIndex(r),l=await this.computeCurrentEpochIndex();if(a!==void 0&&a<l){let c=await U6({arweave:this.arweave,epochIndex:a,processId:this.process.processId,ao:this.process.ao});if(!c)throw new Error("Epoch data not found for epoch index "+a);return c.prescribedNames}let i=[{name:"Action",value:"Epoch-Prescribed-Names"},{name:"Epoch-Index",value:l.toString()}];return this.process.read({tags:qa(i)})}async getObservations(r){let a=await this.computeEpochIndex(r),l=await this.computeCurrentEpochIndex();if(a!==void 0&&a<l){let c=await U6({arweave:this.arweave,epochIndex:a,processId:this.process.processId,ao:this.process.ao});if(!c)throw new Error("Epoch data not found for epoch index "+a);return c.observations}let i=[{name:"Action",value:"Epoch-Observations"},{name:"Epoch-Index",value:l.toString()}];return this.process.read({tags:qa(i)})}async getDistributions(r){let a=await this.computeEpochIndex(r),l=await this.computeCurrentEpochIndex();if(a!==void 0&&a<l){let c=await U6({arweave:this.arweave,epochIndex:a,processId:this.process.processId,ao:this.process.ao});if(c===void 0)throw new Error("Epoch data not found for epoch index "+a);return c.distributions}let i=[{name:"Action",value:"Epoch-Distributions"},{name:"Epoch-Index",value:l.toString()}];return this.process.read({tags:qa(i)})}async getEligibleEpochRewards(r,a){let l=await this.computeEpochIndex(r),i=await this.computeCurrentEpochIndex();if(l!==void 0&&l<i){let b=await U6({arweave:this.arweave,epochIndex:l,processId:this.process.processId,ao:this.process.ao});if(!b)throw new Error("Epoch data not found for epoch index "+l);return NUt(b,a)}let c=[{name:"Action",value:"Epoch-Eligible-Rewards"},...ff(a)];return this.process.read({tags:qa(c)})}async getTokenCost({intent:r,type:a,years:l,name:i,quantity:c,fromAddress:b}){let M=[{name:"Action",value:"Token-Cost"},{name:"Intent",value:r==="Buy-Record"?"Buy-Name":r},{name:"Name",value:i},{name:"Years",value:l?.toString()},{name:"Quantity",value:c?.toString()},{name:"Purchase-Type",value:a}];return this.process.read({tags:qa(M),fromAddress:b})}async getCostDetails({intent:r,type:a,years:l,name:i,quantity:c,fromAddress:b,fundFrom:g}){let M=r==="Buy-Record"?"Buy-Name":r;if(g==="turbo"){let{mARIO:w,winc:S}=await this.paymentProvider.getArNSPriceDetails({intent:M,name:i,quantity:c,type:a,years:l});return{tokenCost:w.valueOf(),wincQty:S,discounts:[]}}let y=[{name:"Action",value:"Cost-Details"},{name:"Intent",value:M},{name:"Name",value:i},{name:"Years",value:l?.toString()},{name:"Quantity",value:c?.toString()},{name:"Purchase-Type",value:a},{name:"Fund-From",value:g}];return this.process.read({tags:qa(y),fromAddress:b})}async getRegistrationFees(){return this.process.read({tags:[{name:"Action",value:"Registration-Fees"}]})}async getDemandFactor(){return this.process.read({tags:[{name:"Action",value:"Demand-Factor"}]})}async getDemandFactorSettings(){return this.process.read({tags:[{name:"Action",value:"Demand-Factor-Settings"}]})}async getArNSReturnedNames(r){return this.process.read({tags:[{name:"Action",value:"Returned-Names"},...ff(r)]})}async getArNSReturnedName({name:r}){let a=[{name:"Action",value:"Returned-Name"},{name:"Name",value:r}];return this.process.read({tags:a})}async getDelegations(r){let a=[{name:"Action",value:"Paginated-Delegations"},{name:"Address",value:r.address},...ff(r)];return this.process.read({tags:qa(a)})}async getAllowedDelegates(r){return this.getGatewayDelegateAllowList(r)}async getGatewayVaults(r){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateway-Vaults"},{name:"Address",value:r.address},...ff(r)]})}async getPrimaryNameRequest(r){let a=[{name:"Action",value:"Primary-Name-Request"},{name:"Initiator",value:r.initiator}];return this.process.read({tags:a})}async getPrimaryNameRequests(r){return this.process.read({tags:[{name:"Action",value:"Primary-Name-Requests"},...ff(r)]})}async getPrimaryName(r){let a=[{name:"Action",value:"Primary-Name"},{name:"Address",value:r?.address},{name:"Name",value:r?.name}];return this.process.read({tags:qa(a)})}async getPrimaryNames(r){return this.process.read({tags:[{name:"Action",value:"Primary-Names"},...ff(r)]})}async getRedelegationFee(r){return this.process.read({tags:[{name:"Action",value:"Redelegation-Fee"},{name:"Address",value:r.address}]})}async getGatewayRegistrySettings(){return this.process.read({tags:[{name:"Action",value:"Gateway-Registry-Settings"}]})}async getAllDelegates(r){return this.process.read({tags:[{name:"Action",value:"All-Paginated-Delegates"},...ff(r)]})}async getAllGatewayVaults(r){return this.process.read({tags:[{name:"Action",value:"All-Gateway-Vaults"},...ff(r)]})}async resolveArNSName({name:r}){let a=r.lastIndexOf("_"),l=a===-1?r:r.slice(a+1),i=a===-1?"@":r.slice(0,a),c=await this.getArNSRecord({name:l});if(c===void 0||c.processId===void 0)throw new Error(`Base ArNS name ${l} not found on ARIO contract (${this.process.processId}).`);let b=j6.init({process:new Ea({ao:this.process.ao,processId:c.processId})}),[g,M]=await Promise.all([b.getOwner(),b.getRecord({undername:i})]);if(M===void 0)throw new Error(`Record for ${i} not found on ANT.`);if(M.ttlSeconds===void 0||M.transactionId===void 0)throw new Error(`Invalid record on ANT. Must have ttlSeconds and transactionId. Record: ${JSON.stringify(M)}`);return{name:r,owner:g,txId:M.transactionId,ttlSeconds:M.ttlSeconds,priority:M.priority,processId:c.processId,undernameLimit:c.undernameLimit,type:c.type}}async getArNSRecordsForAddress(r){let{antRegistryId:a=Fp,address:l}=r,i=E1.init({process:new Ea({ao:this.process.ao,processId:a})}),{Controlled:c=[],Owned:b=[]}=await i.accessControlList({address:l}),g=new Set([...c,...b]);return g.size===0?{items:[],hasMore:!1,nextCursor:void 0,limit:r.limit??1e3,totalItems:0,sortOrder:r.sortOrder??"asc"}:await this.getArNSRecords({...r,filters:{processId:Array.from(g)}})}},Lw=class extends W3{signer;paymentProvider;constructor({signer:r,paymentUrl:a,...l}){l===void 0?super({process:new Ea({processId:qf})}):super(l),this.signer=Zm(r),this.paymentProvider=Cw.init({signer:Zat(r)?r:void 0,paymentUrl:a})}async transfer({target:r,qty:a},l){let{tags:i=[]}=l||{};return this.process.send({tags:[...i,{name:"Action",value:"Transfer"},{name:"Recipient",value:r},{name:"Quantity",value:a.valueOf().toString()}],signer:this.signer})}async vaultedTransfer({recipient:r,quantity:a,lockLengthMs:l,revokable:i=!1},c){let{tags:b=[]}=c||{};return this.process.send({tags:[...b,{name:"Action",value:"Vaulted-Transfer"},{name:"Recipient",value:r},{name:"Quantity",value:a.toString()},{name:"Lock-Length",value:l.toString()},{name:"Revokable",value:`${i}`}],signer:this.signer})}async revokeVault({vaultId:r,recipient:a},l){let{tags:i=[]}=l||{};return this.process.send({tags:[...i,{name:"Action",value:"Revoke-Vault"},{name:"Vault-Id",value:r},{name:"Recipient",value:a}],signer:this.signer})}async createVault({lockLengthMs:r,quantity:a},l){let{tags:i=[]}=l||{};return this.process.send({tags:[...i,{name:"Action",value:"Create-Vault"},{name:"Lock-Length",value:r.toString()},{name:"Quantity",value:a.toString()}],signer:this.signer})}async extendVault({vaultId:r,extendLengthMs:a},l){let{tags:i=[]}=l||{};return this.process.send({tags:[...i,{name:"Action",value:"Extend-Vault"},{name:"Vault-Id",value:r},{name:"Extend-Length",value:a.toString()}],signer:this.signer})}async increaseVault({vaultId:r,quantity:a},l){let{tags:i=[]}=l||{};return this.process.send({tags:[...i,{name:"Action",value:"Increase-Vault"},{name:"Vault-Id",value:r},{name:"Quantity",value:a.toString()}],signer:this.signer})}async joinNetwork({operatorStake:r,allowDelegatedStaking:a,allowedDelegates:l,delegateRewardShareRatio:i,fqdn:c,label:b,minDelegatedStake:g,note:M,port:y,properties:w,protocol:S,autoStake:_,observerAddress:x},A){let{tags:k=[]}=A||{},B=[...k,{name:"Action",value:"Join-Network"},{name:"Operator-Stake",value:r.valueOf().toString()},{name:"Allow-Delegated-Staking",value:a?.toString()},{name:"Allowed-Delegates",value:l?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:i?.toString()},{name:"FQDN",value:c},{name:"Label",value:b},{name:"Min-Delegated-Stake",value:g?.valueOf().toString()},{name:"Note",value:M},{name:"Port",value:y?.toString()},{name:"Properties",value:w},{name:"Protocol",value:S},{name:"Auto-Stake",value:_?.toString()},{name:"Observer-Address",value:x}];return this.process.send({signer:this.signer,tags:qa(B)})}async leaveNetwork(r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Leave-Network"}]})}async updateGatewaySettings({allowDelegatedStaking:r,allowedDelegates:a,delegateRewardShareRatio:l,fqdn:i,label:c,minDelegatedStake:b,note:g,port:M,properties:y,protocol:w,autoStake:S,observerAddress:_},x){let{tags:A=[]}=x||{},k=[...A,{name:"Action",value:"Update-Gateway-Settings"},{name:"Label",value:c},{name:"Note",value:g},{name:"FQDN",value:i},{name:"Port",value:M?.toString()},{name:"Properties",value:y},{name:"Protocol",value:w},{name:"Observer-Address",value:_},{name:"Allow-Delegated-Staking",value:r?.toString()},{name:"Allowed-Delegates",value:a?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:l?.toString()},{name:"Min-Delegated-Stake",value:b?.valueOf().toString()},{name:"Auto-Stake",value:S?.toString()}];return this.process.send({signer:this.signer,tags:qa(k)})}async delegateStake(r,a){let{tags:l=[]}=a||{};return this.process.send({signer:this.signer,tags:[...l,{name:"Action",value:"Delegate-Stake"},{name:"Target",value:r.target},{name:"Quantity",value:r.stakeQty.valueOf().toString()}]})}async decreaseDelegateStake(r,a){let{tags:l=[]}=a||{};return this.process.send({signer:this.signer,tags:[...l,{name:"Action",value:"Decrease-Delegate-Stake"},{name:"Target",value:r.target},{name:"Quantity",value:r.decreaseQty.valueOf().toString()},{name:"Instant",value:`${r.instant||!1}`}]})}async instantWithdrawal(r,a){let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Instant-Withdrawal"},{name:"Vault-Id",value:r.vaultId},{name:"Address",value:r.gatewayAddress}];return this.process.send({signer:this.signer,tags:qa(i)})}async increaseOperatorStake(r,a){let{tags:l=[]}=a||{};return this.process.send({signer:this.signer,tags:[...l,{name:"Action",value:"Increase-Operator-Stake"},{name:"Quantity",value:r.increaseQty.valueOf().toString()}]})}async decreaseOperatorStake(r,a){let{tags:l=[]}=a||{};return this.process.send({signer:this.signer,tags:[...l,{name:"Action",value:"Decrease-Operator-Stake"},{name:"Quantity",value:r.decreaseQty.valueOf().toString()},{name:"Instant",value:`${r.instant||!1}`}]})}async saveObservations(r,a){let{tags:l=[]}=a||{};return this.process.send({signer:this.signer,tags:[...l,{name:"Action",value:"Save-Observations"},{name:"Report-Tx-Id",value:r.reportTxId},{name:"Failed-Gateways",value:r.failedGateways.join(",")}]})}async buyRecord(r,a){if(r.processId===void 0)try{r.processId=await j6.spawn({signer:this.signer,ao:this.process.ao,logger:this.logger,onSigningProgress:a?.onSigningProgress})}catch(c){throw this.logger.error("Failed to spawn ANT for name purchase.",{error:c}),c}if(a?.onSigningProgress?.("buying-name",{name:r.name,years:r.years,type:r.type,processId:r.processId,fundFrom:r.fundFrom,referrer:r.referrer}),r.fundFrom==="turbo"){if(!(this.paymentProvider instanceof Km))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Buy-Name",name:r.name,years:r.years,type:r.type,processId:r.processId,paidBy:r.paidBy})}let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Buy-Name"},{name:"Name",value:r.name},{name:"Years",value:r.years?.toString()??"1"},{name:"Process-Id",value:r.processId},{name:"Purchase-Type",value:r.type||"lease"},{name:"Fund-From",value:r.fundFrom},{name:"Referrer",value:r.referrer}];return this.process.send({signer:this.signer,tags:qa(i)})}async upgradeRecord(r,a){if(r.fundFrom==="turbo"){if(!(this.paymentProvider instanceof Km))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Upgrade-Name",name:r.name})}let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Upgrade-Name"},{name:"Name",value:r.name},{name:"Fund-From",value:r.fundFrom},{name:"Referrer",value:r.referrer}];return this.process.send({signer:this.signer,tags:qa(i)})}async extendLease(r,a){if(r.fundFrom==="turbo"){if(!(this.paymentProvider instanceof Km))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Extend-Lease",name:r.name,years:r.years})}let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Extend-Lease"},{name:"Name",value:r.name},{name:"Years",value:r.years.toString()},{name:"Fund-From",value:r.fundFrom},{name:"Referrer",value:r.referrer}];return this.process.send({signer:this.signer,tags:qa(i)})}async increaseUndernameLimit(r,a){if(r.fundFrom==="turbo"){if(!(this.paymentProvider instanceof Km))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Increase-Undername-Limit",quantity:r.increaseCount,name:r.name})}let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Increase-Undername-Limit"},{name:"Name",value:r.name},{name:"Quantity",value:r.increaseCount.toString()},{name:"Fund-From",value:r.fundFrom},{name:"Referrer",value:r.referrer}];return this.process.send({signer:this.signer,tags:qa(i)})}async cancelWithdrawal(r,a){let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Cancel-Withdrawal"},{name:"Vault-Id",value:r.vaultId},{name:"Address",value:r.gatewayAddress}];return this.process.send({signer:this.signer,tags:qa(i)})}async requestPrimaryName(r,a){if(r.fundFrom==="turbo")throw new Error("Turbo funding is not yet supported for primary name requests");let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Request-Primary-Name"},{name:"Name",value:r.name},{name:"Fund-From",value:r.fundFrom}];return this.process.send({signer:this.signer,tags:qa(i)})}async redelegateStake(r,a){let{tags:l=[]}=a||{},i=[...l,{name:"Action",value:"Redelegate-Stake"},{name:"Target",value:r.target},{name:"Source",value:r.source},{name:"Quantity",value:r.stakeQty.valueOf().toString()},{name:"Vault-Id",value:r.vaultId}];return this.process.send({signer:this.signer,tags:qa(i)})}};var RJe=async({address:e,registry:r=E1.init()})=>{let a=await r.accessControlList({address:e});return[...new Set([...a.Owned,...a.Controlled])]};function CUt(e,r){return new Promise((a,l)=>{let i=setTimeout(()=>{l(new Error("Timeout"))},e);r.then(c=>{clearTimeout(i),a(c)}).catch(c=>{clearTimeout(i),l(c)})})}var LUt=class extends Pnt.default{contract;timeoutMs;throttle;logger;strict;antAoClient;constructor({contract:r=Dw.init({processId:qf}),timeoutMs:a=6e4,concurrency:l=30,logger:i=To.default,strict:c=!1,antAoClient:b=jh({MODE:"legacy"})}={}){super(),this.contract=r,this.timeoutMs=a,this.throttle=Z$t(l),this.logger=i,this.strict=c,this.antAoClient=b}async fetchProcessesOwnedByWallet({address:r,pageSize:a,antRegistry:l=E1.init()}){let i={},c=await l.accessControlList({address:r}),b=new Set([...c.Owned,...c.Controlled]);await CUt(this.timeoutMs,Y8e({contract:this.contract,emitter:this,pageSize:a})).catch(M=>(this.emit("error",`Error getting ArNS records: ${M}`),this.logger.error("Error getting ArNS records",{message:M?.message,stack:M?.stack}),{})).then(M=>{Object.entries(M).forEach(([y,w])=>{b.has(w.processId)&&(i[w.processId]==null&&(i[w.processId]={state:void 0,names:{}}),i[w.processId].names[y]=w)})});let g=Object.keys(i).length;this.emit("progress",0,g),await Promise.all(Object.keys(i).map(async(M,y)=>this.throttle(async()=>{if(i[M].state!==void 0){this.emit("progress",y+1,g);return}let w=j6.init({process:new Ea({processId:M,ao:this.antAoClient}),strict:this.strict}),S=await CUt(this.timeoutMs,w.getState()).catch(_=>{this.emit("error",`Error getting state for process ${M}: ${_}`)});(S?.Owner===r||S?.Controllers.includes(r))&&(i[M].state=S,this.emit("process",M,i[M])),this.emit("progress",y+1,g)}))),this.emit("end",i)}},Y8e=async({contract:e=Dw.init({processId:qf}),emitter:r,logger:a=To.default,pageSize:l=1e3})=>{let i,c=Date.now(),b={};do{let g=await e.getArNSRecords({cursor:i,limit:l}).catch(M=>{a?.error("Error getting ArNS records",{message:M?.message,stack:M?.stack}),r?.emit("arns:error",`Error getting ArNS records: ${M}`)});if(!g)return{};g.items.forEach(M=>{let{name:y,...w}=M;b[y]=w}),a.debug("Fetched page of ArNS records",{totalRecordCount:g.totalItems,fetchedRecordCount:Object.keys(b).length,cursor:g.nextCursor}),r?.emit("arns:pageLoaded",{totalRecordCount:g.totalItems,fetchedRecordCount:Object.keys(b).length,records:g.items,cursor:g.nextCursor}),i=g.nextCursor}while(i!==void 0);return r?.emit("arns:end",b),a.debug("Fetched all ArNS records",{totalRecordCount:Object.keys(b).length,durationMs:Date.now()-c}),b};var Ea=class{logger;ao;processId;constructor({processId:r,ao:a=jh({MODE:"legacy"}),logger:l=To.default}){this.processId=r,this.logger=l,this.ao=a}isMessageDataEmpty(r){return r===void 0||r==="null"||r===""||r===null}async read({tags:r,retries:a=3,fromAddress:l}){this.logger.debug("Evaluating read interaction on process",{tags:r,processId:this.processId});let i={process:this.processId,tags:r};l!==void 0&&(i.Owner=l);let c=0,b;for(;c<a;)try{b=await this.ao.dryrun(i);break}catch(w){if(c++,this.logger.debug(`Read attempt ${c} failed`,{error:w?.message,stack:w?.stack,tags:r,processId:this.processId}),c>=a)throw this.logger.debug("Maximum read attempts exceeded",{error:w?.message,stack:w?.stack,tags:r,processId:this.processId,ao:JSON.stringify(this.ao)}),new Error(`Failed to evaluate dry-run on process ${this.processId}.`,{cause:w});await new Promise(S=>setTimeout(S,2**c*1e3))}if(b===void 0)throw new Error("Unexpected error when evaluating read interaction");this.logger.debug("Read interaction result",{result:b,processId:this.processId});let g=lP(b);if(g!==void 0)throw new Error(g);if(b.Messages===void 0||b.Messages.length===0)throw this.logger.debug(`Empty result - process ${this.processId} does not support provided action.`,{result:b,tags:r,processId:this.processId}),new Error(b.message||`Process ${this.processId} did not return a valid response. Response: ${JSON.stringify(b)}`);let M=b.Messages?.[0]?.Data;return this.isMessageDataEmpty(M)?void 0:Tnt(M)}async send({tags:r,data:a,signer:l,retries:i=3}){let c,b=F$t(32);try{this.logger.debug("Evaluating send interaction on contract",{tags:r,data:a,processId:this.processId}),c=await this.ao.message({process:this.processId,tags:[...r,{name:"AR-IO-SDK",value:D3}],data:a,signer:l,anchor:b}),this.logger.debug("Sent message to process",{messageId:c,processId:this.processId,anchor:b})}catch(S){throw this.logger.debug("Error sending message to process",{error:S?.message,stack:S?.stack,processId:this.processId,tags:r}),S}if(c===void 0)throw new Error("Failed to send message to process.");let g,M=0;for(;M<i;)try{g=await this.ao.result({message:c,process:this.processId}),this.logger.debug("Message result",{result:g,messageId:c,processId:this.processId});break}catch(S){if(M++,this.logger.debug("Retrying send interaction",{attempts:M,retries:i,error:S?.message,processId:this.processId}),M>=i)return this.logger.debug(`Message was sent to process ${this.processId} with id ${c} but result was not returned. Review transactions for more details.`,{error:S?.message,stack:S?.stack,tags:r,processId:this.processId,messageId:c}),{id:c};await new Promise(_=>setTimeout(_,2**M*2e3))}if(g===void 0)return this.logger.debug(`Message was sent to process ${this.processId} with id ${c} but the result was not returned. Review transactions for more details.`,{tags:r,processId:this.processId,messageId:c}),{id:c};let y=lP(g);if(y!==void 0)throw new OB(y);if(g.Messages?.length===0||g.Messages===void 0)return{id:c};if(this.isMessageDataEmpty(g.Messages[0].Data))return{id:c};let w=Tnt(g.Messages[0].Data);return this.logger.debug("Message result data",{resultData:w,messageId:c,processId:this.processId}),{id:c,result:w}}};var G3=class{static init(r){return r!==void 0&&"signer"in r?new Wat(r):new dP(r)}},dP=class{process;constructor(r){if(r===void 0||Object.keys(r).length===0)this.process=new Ea({processId:Fp});else if(Wm(r))this.process=r.process;else if(Gm(r))this.process=new Ea({processId:r.processId});else throw new Kd}async getANTVersions(){let r=await this.process.read({tags:[{name:"Action",value:"Get-Versions"}]});return Object.fromEntries(Object.entries(r).sort(([a],[l])=>a.localeCompare(l)))}async getLatestANTVersion(){let r=await this.getANTVersions(),a=Object.entries(r).at(-1);if(!a)throw new Error("No version found");return{version:a[0],...a[1]}}},Wat=class extends dP{signer;constructor({signer:r,...a}){super(a),this.signer=Zm(r)}async addVersion(r,a){let{version:l,moduleId:i,luaSourceId:c,notes:b}=r;return this.process.send({tags:qa([{name:"Action",value:"Add-Version"},{name:"Version",value:l},{name:"Module-Id",value:i},{name:"Lua-Source-Id",value:c},{name:"Notes",value:b},...a?.tags??[]]),signer:this.signer})}};var j6=class{static get versions(){return G3.init()}static spawn=DUt;static init(r){return r!==void 0&&"signer"in r?new Gat(r):new cP(r)}},cP=class{process;processId;strict;hyperbeamUrl;checkHyperBeamPromise;logger=To.default;constructor(r){if(this.strict=r.strict||!1,Wm(r))this.process=r.process;else if(Gm(r))this.process=new Ea({processId:r.processId});else throw new Kd;this.processId=this.process.processId,r.hyperbeamUrl!==void 0&&(this.hyperbeamUrl=new URL(r.hyperbeamUrl),this.logger.debug(`Using HyperBEAM node for process ${this.processId}`,{hyperbeamUrl:this.hyperbeamUrl}))}checkHyperBeamCompatibility(){return this.hyperbeamUrl===void 0?Promise.resolve(!1):this.checkHyperBeamPromise!==void 0?this.checkHyperBeamPromise:(this.checkHyperBeamPromise=fetch(`${this.hyperbeamUrl.toString()}${this.processId}~process@1.0/now/cache`,{method:"HEAD",signal:AbortSignal.timeout(5e3)}).then(r=>!!r.ok).catch(r=>(this.logger.debug("Failed to check HyperBeam compatibility",{cause:r}),!1)),this.checkHyperBeamPromise)}async getState({strict:r}={strict:this.strict}){if(await this.checkHyperBeamCompatibility()){let i=0;for(;i<3;)try{let c=await fetch(`${this.hyperbeamUrl}${this.processId}~process@1.0/compute/cache/serialize~json@1.0`,{method:"GET",redirect:"follow",mode:"cors",headers:{"Content-Type":"application/json"}});if(c.status!==200)throw new Error(`Failed to fetch ant state: ${c?.statusText??"Unknown error"}`);let b=await c.json();if(!L$t(b))break;return D$t(b)}catch(c){this.logger.error(`Failed to fetch process state from HyperBEAM (attempt ${i+1} / 3)`,{cause:c}),i++,await new Promise(b=>setTimeout(b,1e3*i**2))}}let a=[{name:"Action",value:"State"}],l=await this.process.read({tags:a});return r&&Zd(AZ.passthrough().and(kr.object({Records:kr.record(kr.string(),Ix.passthrough())})),l),l}async getInfo({strict:r}={strict:this.strict}){if(await this.checkHyperBeamCompatibility()){let i=await this.getState();return{Name:i.Name,Ticker:i.Ticker,Description:i.Description,Keywords:i.Keywords,Denomination:i.Denomination.toString(),Owner:i.Owner,Logo:i.Logo,"Total-Supply":i.TotalSupply.toString(),Handlers:[]}}let a=[{name:"Action",value:"Info"}],l=await this.process.read({tags:a});return r&&Zd(ZMt.passthrough(),l),l}async getLogo(){return(await this.getInfo()).Logo}async getRecord({undername:r},{strict:a}={strict:this.strict}){if(await this.checkHyperBeamCompatibility()){let c=(await this.getRecords())[r];if(c===void 0)throw new Error("Record not found");return c}let l=await this.process.read({tags:[{name:"Action",value:"Record"},{name:"Sub-Domain",value:r}]});return a&&Zd(Ix.passthrough(),l),l}async getRecords({strict:r}={strict:this.strict}){if(await this.checkHyperBeamCompatibility()){let i=await this.getState();return Int(i.Records)}let a=[{name:"Action",value:"Records"}],l=await this.process.read({tags:a});return r&&Zd(Tx,l),Int(l)}async getOwner({strict:r}={strict:this.strict}){return await this.checkHyperBeamCompatibility()?(await this.getState()).Owner:(await this.getInfo({strict:r})).Owner}async getControllers({strict:r}={strict:this.strict}){if(await this.checkHyperBeamCompatibility())return(await this.getState()).Controllers;let a=[{name:"Action",value:"Controllers"}],l=await this.process.read({tags:a});return r&&Zd(Bx,l),l}async getName({strict:r}={strict:this.strict}){return await this.checkHyperBeamCompatibility()?(await this.getState()).Name:(await this.getInfo({strict:r})).Name}async getTicker({strict:r}={strict:this.strict}){return await this.checkHyperBeamCompatibility()?(await this.getState()).Ticker:(await this.getInfo({strict:r})).Ticker}async getBalances({strict:r}={strict:this.strict}){let l=(await this.getState()).Balances;return r&&Zd(Px,l),l}async getBalance({address:r},{strict:a}={strict:this.strict}){if(await this.checkHyperBeamCompatibility())return(await this.getBalances())[r]??0;let l=[{name:"Action",value:"Balance"},{name:"Recipient",value:r}],i=await this.process.read({tags:l});return a&&Zd(kr.number(),i),i}async getHandlers(){if(await this.checkHyperBeamCompatibility())throw new Error("Handlers are not supported on HyperBeam");let r=await this.getInfo();return r.Handlers??r.HandlerNames}},Gat=class extends cP{signer;constructor({signer:r,...a}){super(a),this.signer=Zm(r)}async transfer({target:r},a){let l=[...a?.tags??[],{name:"Action",value:"Transfer"},{name:"Recipient",value:r}];return this.process.send({tags:l,signer:this.signer})}async addController({controller:r},a){let l=[...a?.tags??[],{name:"Action",value:"Add-Controller"},{name:"Controller",value:r}];return this.process.send({tags:l,signer:this.signer})}async removeController({controller:r},a){let l=[...a?.tags??[],{name:"Action",value:"Remove-Controller"},{name:"Controller",value:r}];return this.process.send({tags:l,signer:this.signer})}async setRecord({undername:r,transactionId:a,ttlSeconds:l},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:r},{name:"Transaction-Id",value:a},{name:"TTL-Seconds",value:l.toString()}],signer:this.signer})}async setBaseNameRecord({transactionId:r,ttlSeconds:a},l){return this.setRecord({transactionId:r,ttlSeconds:a,undername:"@"},l)}async setUndernameRecord({undername:r,transactionId:a,ttlSeconds:l},i){return this.setRecord({undername:r,transactionId:a,ttlSeconds:l},i)}async removeUndernameRecord({undername:r}){return this.removeRecord({undername:r})}async removeRecord({undername:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Remove-Record"},{name:"Sub-Domain",value:r}],signer:this.signer})}async setTicker({ticker:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Set-Ticker"},{name:"Ticker",value:r}],signer:this.signer})}async setName({name:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Set-Name"},{name:"Name",value:r}],signer:this.signer})}async setDescription({description:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Set-Description"},{name:"Description",value:r}],signer:this.signer})}async setKeywords({keywords:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Set-Keywords"},{name:"Keywords",value:JSON.stringify(r)}],signer:this.signer})}async setLogo({txId:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Set-Logo"},{name:"Logo",value:r}],signer:this.signer})}async releaseName({name:r,arioProcessId:a},l){return this.process.send({tags:[...l?.tags??[],{name:"Action",value:"Release-Name"},{name:"Name",value:r},{name:"IO-Process-Id",value:a},{name:"ARIO-Process-Id",value:a}],signer:this.signer})}async reassignName({name:r,arioProcessId:a,antProcessId:l},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Reassign-Name"},{name:"Name",value:r},{name:"IO-Process-Id",value:a},{name:"ARIO-Process-Id",value:a},{name:"Process-Id",value:l}],signer:this.signer})}async approvePrimaryNameRequest({name:r,address:a,arioProcessId:l},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Approve-Primary-Name"},{name:"Name",value:r},{name:"Recipient",value:a},{name:"IO-Process-Id",value:l},{name:"ARIO-Process-Id",value:l}],signer:this.signer})}async removePrimaryNames({names:r,arioProcessId:a,notifyOwners:l=!1},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Remove-Primary-Names"},{name:"Names",value:r.join(",")},{name:"IO-Process-Id",value:a},{name:"ARIO-Process-Id",value:a},{name:"Notify-Owners",value:l.toString()}],signer:this.signer})}};var E1=class{static init(r){return r!==void 0&&"signer"in r?new Vat(r):new pP(r)}},pP=class{process;hyperbeamUrl;checkHyperBeamPromise;logger;constructor(r){if(this.logger=r?.logger??To.default,r===void 0||Object.keys(r).length===0)this.process=new Ea({processId:Fp});else if(Wm(r))this.process=r.process;else if(Gm(r))this.process=new Ea({processId:r.processId});else throw new Kd;r?.hyperbeamUrl!==void 0&&(this.hyperbeamUrl=new URL(r.hyperbeamUrl).toString(),this.checkHyperBeamPromise=this.checkHyperBeamCompatibility())}async checkHyperBeamCompatibility(){return this.hyperbeamUrl===void 0?Promise.resolve(!1):this.checkHyperBeamPromise!==void 0?this.checkHyperBeamPromise:(this.logger.debug("Checking HyperBeam compatibility"),this.checkHyperBeamPromise=fetch(`${this.hyperbeamUrl.toString()}${this.process.processId}~process@1.0/now/cache/acl`,{method:"HEAD",signal:AbortSignal.timeout(5e3)}).then(r=>r.ok?(this.logger.debug("HyperBeam compatible"),!0):(this.logger.debug("HyperBeam not compatible"),!1)).catch(r=>(this.logger.debug("Failed to check HyperBeam compatibility",{cause:r}),!1)),this.checkHyperBeamPromise)}async accessControlList({address:r}){if(await this.checkHyperBeamCompatibility()){let a=0;for(;a<3;)try{this.logger.debug("Fetching ant registry acl for address from hyperbeam",r);let l=await fetch(`${this.hyperbeamUrl?.toString()}${this.process.processId}~process@1.0/now/cache/acl/${r}/serialize~json@1.0`);if(l.status!==200)throw this.logger.debug("Failed to fetch ant registry acl for address from hyperbeam",r,l.status,l.statusText),new Error(`Failed to fetch ant registry acl for address ${r}: ${l?.statusText??"Unknown error"}`);this.logger.debug("Fetched ant registry acl for address from hyperbeam",r);let i=await l.json();return{Owned:i.Owned,Controlled:i.Controlled}}catch{a++,this.logger.debug("Failed to fetch ant registry acl for address from hyperbeam",r,a),await new Promise(i=>setTimeout(i,1e3*a**2))}}return this.logger.debug("Fetching ant registry acl for address from process",r),this.process.read({tags:[{name:"Action",value:"Access-Control-List"},{name:"Address",value:r}]})}async getAntsForAddress({address:r}){return this.accessControlList({address:r})}},Vat=class extends pP{signer;constructor({signer:r,...a}){super(a),this.signer=Zm(r)}async register({processId:r}){return this.process.send({tags:[{name:"Action",value:"Register"},{name:"Process-Id",value:r}],signer:this.signer})}};async function DUt({signer:e,module:r,ao:a=jh({MODE:"legacy"}),scheduler:l=zMt,state:i,antRegistryId:c=Fp,logger:b=To.default,authority:g=jMt,onSigningProgress:M=(y,w)=>{b.debug("Signing progress",{name:y,payload:w})}}){i&&Zd(KMt,i);let y;if(r===void 0){let k=G3.init({process:new Ea({processId:c,ao:a,logger:b})}),{moduleId:B,version:P}=await k.getLatestANTVersion();b.debug("Spawning new ANT with latest module from ANT registry",{moduleId:B,version:P,antRegistryId:c}),r=B,y=P}M?.("spawning-ant",{moduleId:r,antRegistryId:c,version:y,state:i});let w=await a.spawn({module:r,scheduler:l,signer:e,data:i?JSON.stringify(i):void 0,tags:[{name:"Authority",value:g},{name:"ANT-Registry-Id",value:c}]});if(i!==void 0){let k,B=0;for(;B<5&&k===void 0;)try{k===void 0&&(k=await a.result({process:w,message:w}));break}catch(P){b.debug("Retrying ANT boot result fetch",{processId:w,module:r,scheduler:l,attempts:B,error:P}),B++,await new Promise(O=>setTimeout(O,1e3*B**2))}if(k===void 0||k.Messages?.some(P=>P?.Tags?.some(O=>O.value==="Invalid-Boot-Notice"))){if(k===void 0)throw new Error("Failed to get boot result");let P=lP(k);throw b.error("ANT failed to boot correctly",{processId:w,module:r,scheduler:l,bootRes:k,bootError:P}),new Error(`ANT failed to boot correctly: ${P}`)}}M?.("verifying-state",{processId:w,moduleId:r,antRegistryId:c});let S;try{let k=new Ea({processId:w,ao:a,logger:b}),{id:B}=await k.send({tags:[{name:"Action",value:"State"}],signer:e}),P=await a.result({process:w,message:B});if(P===void 0)throw new Error("Failed to get state result");let{Owner:O}=JSON.parse(P.Messages?.[0]?.Data??"{}");S=O,b.debug("Successfully spawned new ANT and validated owner",{processId:w,module:r,owner:S})}catch(k){throw b.error("Failed to validate owner of spawned ANT",{processId:w,module:r,error:k}),k}if(S===void 0)throw new Error(`Spawning ANT (${w}) failed to set owner`);M?.("registering-ant",{processId:w,antRegistryId:c,owner:S});let _=E1.init({signer:e,processId:c}),x=0,A=5;for(;x<A;)try{let k=await _.accessControlList({address:S});if(k===void 0)throw new Error("ACL not found for owner");let{Owned:B}=k;if(!B.includes(w))throw new Error(`Spawned ANT (${w}) not found in registry for owner ${S}`);return w}catch(k){b.debug("Retrying ANT registry access control list fetch",{owner:S,antRegistryId:c,attempts:x,error:k}),x++,await new Promise(B=>setTimeout(B,1e3*x**2))}return w}async function EQe({signer:e,processId:r,luaCodeTxId:a=UMt,ao:l=jh({MODE:"legacy"}),logger:i=To.default,arweave:c=HB}){let b=new Ea({processId:r,ao:l,logger:i});i.warn("Directly running an Eval on a process is not encouraged.");let{api:{host:g,port:M,protocol:y}}=c.getConfig(),w=await fetch(`${y}://${g}:${M}/${a}`).then(_=>_.text()),{id:S}=await b.send({tags:[{name:"Action",value:"Eval"},{name:"App-Name",value:"ArNS-ANT"},{name:"Source-Code-TX-ID",value:a}],data:w,signer:e});return i.debug("Evolved ANT",{processId:r,luaCodeTxId:a,evalMsgId:S}),S}function J8e(e){let r=kr.object({name:kr.string(),value:kr.union([kr.string(),kr.number()])}),a=kr.function().args(kr.object({data:kr.union([kr.string(),kr.instanceof(Kt)]),tags:kr.array(r).optional(),target:kr.string().optional(),anchor:kr.string().optional()})).returns(kr.promise(kr.object({id:kr.string(),raw:kr.instanceof(ArrayBuffer)})));try{return a.parse(e),!0}catch{return!1}}function Zm(e){return J8e(e)?e:"publicKey"in e?async({data:a,tags:l,target:i,anchor:c})=>{if(e.publicKey===void 0&&"setPublicKey"in e&&typeof e.setPublicKey=="function"&&await e.setPublicKey(),e instanceof al){let M=await e.signer.signDataItem({data:a,tags:l,target:i,anchor:c}),y=new vg(Kt.from(M));return{id:await y.id,raw:await y.getRaw()}}let b=b4(a,e,{tags:l,target:i,anchor:c});return b.sign(e).then(async()=>({id:await b.id,raw:await b.getRaw()}))}:k$t(e)}var X8e="-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI",Q8e="Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A";function AQe({owner:e,targetId:r,ttlSeconds:a=3600,keywords:l=[],controllers:i=[],description:c="",ticker:b="aos",name:g="ANT",logo:M=Q8e}){return{ticker:b,name:g,description:c,keywords:l,owner:e,controllers:[e,...i],balances:{[e]:1},records:{"@":{transactionId:r??X8e.toString(),ttlSeconds:a}},logo:M}}function Yat(e){return kr.object({startTimestamp:kr.number(),startHeight:kr.number(),distributions:kr.any(),endTimestamp:kr.number(),prescribedObservers:kr.any(),prescribedNames:kr.array(kr.string()),observations:kr.any(),epochIndex:kr.number()}).parse(e)}function lP(e){let a=e.Error??e.Messages?.[0]?.Tags?.find(l=>l.name==="Error")?.value;if(a!==void 0){let l=a.match(/\[string "(.+)"\]:(\d+):\s*(.*)/);if(l){let[,,i,c]=l;return`${$Ut(c).trim()} (line ${i.trim()})`.trim()}return $Ut(a)}}function $Ut(e){return e.replace(new RegExp("\x1B[\\[\\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]","g"),"").trim()}var qUt=e=>Rx.test(e);function qQe(e){return e!==void 0&&!isNaN(parseInt(e.toString()))}var qa=e=>e.filter(r=>r.value!==void 0&&r.value!==""),ff=e=>{let r=[{name:"Cursor",value:e?.cursor?.toString()},{name:"Limit",value:e?.limit?.toString()},{name:"Sort-By",value:e?.sortBy?.toString()},{name:"Sort-Order",value:e?.sortOrder?.toString()},...e?.filters?[{name:"Filters",value:JSON.stringify(e.filters)}]:[]];return qa(r)},tye=async({arweave:e,epochIndex:r,processId:a=qf,retries:l=3,gqlUrl:i="https://arweave-search.goldsky.com/graphql"})=>{let c=rye({epochIndex:r,processId:a});for(let b=0;b<l;b++)try{let g=await fetch(i,{method:"POST",body:c,headers:{"Content-Type":"application/json"}}).then(w=>w.json());if(g?.data?.transactions?.edges?.length===0)return;let M=g.data.transactions.edges[0].node.id,y=await e.api.get(M);return Yat(y.data)}catch(g){if(b===l-1)throw g;await new Promise(M=>setTimeout(M,Math.pow(2,b)*1e3))}},U6=async({arweave:e,ao:r,epochIndex:a,processId:l=qf})=>{let i=await tye({arweave:e,epochIndex:a,processId:l});if(i)return i;let c=await eye({ao:r,epochIndex:a,processId:l});if(c)return c},eye=async({ao:e,epochIndex:r,processId:a=qf,gqlUrl:l="https://arweave-search.goldsky.com/graphql"})=>{let i=iye({epochIndex:r,processId:a}),b=await(await fetch(l,{method:"POST",body:i,headers:{"Content-Type":"application/json"}})).json();if(b.data.transactions.edges.length!==0)for(let g of b.data.transactions.edges){let M=g.node.id,y=await e.result({message:M,process:a}).catch(()=>{});if(y)for(let w of y?.Messages??[]){let S=JSON.parse(w.Data),_=w.Tags;if(_.some(x=>x.name==="Action"&&x.value==="Epoch-Distribution-Notice")&&_.some(x=>x.name==="Epoch-Index"&&x.value===r.toString()))return Yat(S)}}},rye=({epochIndex:e,processId:r=qf,authorities:a=["fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY"]})=>JSON.stringify({query:`
152
152
  query {
153
153
  transactions(
154
154
  tags: [
@@ -74,13 +74,20 @@ class AoANTRegistryReadable {
74
74
  this.checkHyperBeamPromise = fetch(`${this.hyperbeamUrl.toString()}${this.process.processId}~process@1.0/now/cache/acl`, {
75
75
  method: 'HEAD',
76
76
  signal: AbortSignal.timeout(5000), // 5 second timeout
77
- }).then((res) => {
77
+ })
78
+ .then((res) => {
78
79
  if (res.ok) {
79
80
  this.logger.debug('HyperBeam compatible');
80
81
  return true;
81
82
  }
82
83
  this.logger.debug('HyperBeam not compatible');
83
84
  return false;
85
+ })
86
+ .catch((error) => {
87
+ this.logger.debug('Failed to check HyperBeam compatibility', {
88
+ cause: error,
89
+ });
90
+ return false;
84
91
  });
85
92
  return this.checkHyperBeamPromise;
86
93
  }
@@ -92,11 +92,18 @@ class AoANTReadable {
92
92
  this.checkHyperBeamPromise = fetch(`${this.hyperbeamUrl.toString()}${this.processId}~process@1.0/now/cache`, {
93
93
  method: 'HEAD',
94
94
  signal: AbortSignal.timeout(5000), // 5 second timeout
95
- }).then((res) => {
95
+ })
96
+ .then((res) => {
96
97
  if (res.ok) {
97
98
  return true;
98
99
  }
99
100
  return false;
101
+ })
102
+ .catch((error) => {
103
+ this.logger.debug('Failed to check HyperBeam compatibility', {
104
+ cause: error,
105
+ });
106
+ return false;
100
107
  });
101
108
  return this.checkHyperBeamPromise;
102
109
  }
@@ -101,12 +101,10 @@ class ARIOReadable {
101
101
  process;
102
102
  epochSettings;
103
103
  arweave;
104
- hyperbeamUrl;
105
104
  paymentProvider; // TODO: this could be an array/map of payment providers
106
105
  logger = logger_js_1.Logger.default;
107
106
  constructor(config) {
108
107
  this.arweave = config?.arweave ?? arweave_js_2.defaultArweave;
109
- this.hyperbeamUrl = config?.hyperbeamUrl;
110
108
  if (config === undefined || Object.keys(config).length === 0) {
111
109
  this.process = new ao_process_js_1.AOProcess({
112
110
  processId: constants_js_1.ARIO_MAINNET_PROCESS_ID,
@@ -686,7 +684,6 @@ class ARIOReadable {
686
684
  async getArNSRecordsForAddress(params) {
687
685
  const { antRegistryId = constants_js_1.ANT_REGISTRY_ID, address } = params;
688
686
  const antRegistry = ant_registry_js_1.ANTRegistry.init({
689
- hyperbeamUrl: this.hyperbeamUrl,
690
687
  process: new ao_process_js_1.AOProcess({
691
688
  ao: this.process.ao,
692
689
  processId: antRegistryId,
@@ -17,4 +17,4 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.version = void 0;
19
19
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
20
- exports.version = '3.17.2-alpha.1';
20
+ exports.version = '3.17.2';
@@ -70,13 +70,20 @@ export class AoANTRegistryReadable {
70
70
  this.checkHyperBeamPromise = fetch(`${this.hyperbeamUrl.toString()}${this.process.processId}~process@1.0/now/cache/acl`, {
71
71
  method: 'HEAD',
72
72
  signal: AbortSignal.timeout(5000), // 5 second timeout
73
- }).then((res) => {
73
+ })
74
+ .then((res) => {
74
75
  if (res.ok) {
75
76
  this.logger.debug('HyperBeam compatible');
76
77
  return true;
77
78
  }
78
79
  this.logger.debug('HyperBeam not compatible');
79
80
  return false;
81
+ })
82
+ .catch((error) => {
83
+ this.logger.debug('Failed to check HyperBeam compatibility', {
84
+ cause: error,
85
+ });
86
+ return false;
80
87
  });
81
88
  return this.checkHyperBeamPromise;
82
89
  }
@@ -88,11 +88,18 @@ export class AoANTReadable {
88
88
  this.checkHyperBeamPromise = fetch(`${this.hyperbeamUrl.toString()}${this.processId}~process@1.0/now/cache`, {
89
89
  method: 'HEAD',
90
90
  signal: AbortSignal.timeout(5000), // 5 second timeout
91
- }).then((res) => {
91
+ })
92
+ .then((res) => {
92
93
  if (res.ok) {
93
94
  return true;
94
95
  }
95
96
  return false;
97
+ })
98
+ .catch((error) => {
99
+ this.logger.debug('Failed to check HyperBeam compatibility', {
100
+ cause: error,
101
+ });
102
+ return false;
96
103
  });
97
104
  return this.checkHyperBeamPromise;
98
105
  }
@@ -97,12 +97,10 @@ export class ARIOReadable {
97
97
  process;
98
98
  epochSettings;
99
99
  arweave;
100
- hyperbeamUrl;
101
100
  paymentProvider; // TODO: this could be an array/map of payment providers
102
101
  logger = Logger.default;
103
102
  constructor(config) {
104
103
  this.arweave = config?.arweave ?? defaultArweave;
105
- this.hyperbeamUrl = config?.hyperbeamUrl;
106
104
  if (config === undefined || Object.keys(config).length === 0) {
107
105
  this.process = new AOProcess({
108
106
  processId: ARIO_MAINNET_PROCESS_ID,
@@ -682,7 +680,6 @@ export class ARIOReadable {
682
680
  async getArNSRecordsForAddress(params) {
683
681
  const { antRegistryId = ANT_REGISTRY_ID, address } = params;
684
682
  const antRegistry = ANTRegistry.init({
685
- hyperbeamUrl: this.hyperbeamUrl,
686
683
  process: new AOProcess({
687
684
  ao: this.process.ao,
688
685
  processId: antRegistryId,
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '3.17.2-alpha.1';
17
+ export const version = '3.17.2';
@@ -3,12 +3,8 @@ import { ARIOWithFaucet, AoARIORead, AoARIOWrite, AoAllDelegates, AoAllGatewayVa
3
3
  import { AOProcess } from './contracts/ao-process.js';
4
4
  import { Logger } from './logger.js';
5
5
  import { TurboArNSPaymentProviderAuthenticated, TurboArNSPaymentProviderUnauthenticated } from './turbo.js';
6
- type ARIOConfigNoSigner = OptionalPaymentUrl<OptionalArweave<ProcessConfiguration & {
7
- hyperbeamUrl?: string;
8
- }>>;
9
- type ARIOConfigWithSigner = WithSigner<OptionalPaymentUrl<OptionalArweave<ProcessConfiguration & {
10
- hyperbeamUrl?: string;
11
- }>>>;
6
+ type ARIOConfigNoSigner = OptionalPaymentUrl<OptionalArweave<ProcessConfiguration>>;
7
+ type ARIOConfigWithSigner = WithSigner<OptionalPaymentUrl<OptionalArweave<ProcessConfiguration>>>;
12
8
  export declare class ARIO {
13
9
  static init(): AoARIORead;
14
10
  static init(config: ARIOConfigWithSigner): AoARIOWrite;
@@ -28,7 +24,6 @@ export declare class ARIOReadable implements AoARIORead, ArNSNameResolver {
28
24
  readonly process: AOProcess;
29
25
  protected epochSettings: AoEpochSettings | undefined;
30
26
  protected arweave: Arweave;
31
- protected hyperbeamUrl: string | undefined;
32
27
  protected paymentProvider: TurboArNSPaymentProviderUnauthenticated;
33
28
  protected logger: Logger;
34
29
  constructor(config?: ARIOConfigNoSigner);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.17.2-alpha.1",
3
+ "version": "3.17.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"