@ar.io/sdk 3.10.1 → 3.10.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.
@@ -209,7 +209,7 @@ nonce: bundlr`),De.from(n))}};de();ve();pe();var Wp=class{_publicKey;ownerLength
209
209
  }
210
210
  }
211
211
  }
212
- }`,n=It.object({data:It.object({transactions:It.object({edges:It.array(It.object({node:It.record(It.any())}))})})});return l=>li(l).chain(vn(p=>t(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:f,variables:{transactionIds:[p]}})}).then(async v=>{if(v.ok)return v.json();throw i('Error Encountered when querying gateway for transaction "%s"',p),new Error(`${v.status}: ${await v.text()}`)}).then(n.parse).then(_qe(["data","transactions","edges","0","node"])))).toPromise()}var PUe=qC(UNe(),1),Mce=(t="@permaweb/aoconnect")=>{let e=(0,PUe.default)(t);return e.child=i=>Mce(`${e.namespace}:${i}`),e.tap=(i,...f)=>Tqe((...n)=>e(i,...f,...n)),e},xce=({url:t,path:e})=>e?e.startsWith("/")?xce({url:t,path:e.slice(1)}):(t=new URL(t),t.pathname+=e,t.toString()):t;function OUe(t){return Hm(x7([]),zm((e,i)=>Hm(Sqe([],i.name),t$(i.value),Jf(i.name,d0,e))(e),{}),_7(e=>e.length>1?e:e[0]))(t)}function Vf(t,e){return i=>K0e(ODe([Vle(t,"name"),i$(e$(e),Vle(e,"value"),JC)]),i)}function Jle(t){return rce([[py(String),Om(t)],[py(Array),cqe(t)],[JC,zLe]])}function b1(t){let e;return py(Gf,t)?(e=new Error(NUe(t)),e.stack+=t.stack):py(Error,t)?e=t:uqe("message",t)?e=new Error(t.message):py(String,t)?e=new Error(t):e=new Error("An error occurred"),e}function NUe(t){return Hm(e=>function i(f,n,l){return zm((p,v)=>Hm(rce([[Om(Gt.invalid_arguments),()=>i(v.argumentsError,422,"Invalid Arguments")],[Om(Gt.invalid_return_type),()=>i(v.returnTypeError,500,"Invalid Return")],[Om(Gt.invalid_union),()=>GDe(_=>i(_,400,"Invalid Union"),v.unionErrors)],[JC,()=>[{...v,status:n,contextCode:l}]]]),r$(p))(v.code),[],f.issues)}(e,400,""),e=>zm((i,f)=>{let{message:n,path:l,contextCode:p}=f,v=l[1]||l[0],_=p?`${p} `:"";return i.push(`${_}'${v}': ${n}.`),i},[],e),bqe(" | "))(t)}var CUe=It.object({id:It.string().min(1,{message:"message is required to be a message id"}),processId:It.string().min(1,{message:"process is required to be a process id"})});function $Ue(){return t=>li(t).map(CUe.parse).map(()=>t)}var Jy=It.object({name:It.string(),value:It.string()}),LUe=It.function().args(It.object({Id:It.string(),Target:It.string(),Owner:It.string(),Anchor:It.string().optional(),Data:It.any().default("1234"),Tags:It.array(It.object({name:It.string(),value:It.string()}))})).returns(It.promise(It.any())),DUe=It.function().args(It.object({id:It.string().min(1,{message:"message id is required"}),processId:It.string().min(1,{message:"process id is required"})})).returns(It.promise(It.any())),qUe=It.function().args(It.object({process:It.string().min(1,{message:"process id is required"}),from:It.string().optional(),to:It.string().optional(),sort:It.enum(["ASC","DESC"]).default("ASC"),limit:It.number().optional()})).returns(It.promise(It.object({edges:It.array(It.object({cursor:It.string(),node:It.object({Output:It.any().optional(),Messages:It.array(It.any()).optional(),Spawns:It.array(It.any()).optional(),Error:It.any().optional()})}))}))),Sce=It.function().args(It.object({processId:It.string(),data:It.any(),tags:It.array(Jy),anchor:It.string().optional(),signer:It.any()})).returns(It.promise(It.object({messageId:It.string()}).passthrough())),UUe=It.function().args(It.object({data:It.any(),tags:It.array(Jy),signer:It.any()})).returns(It.promise(It.object({processId:It.string()}).passthrough())),FUe=It.function().args(It.object({process:It.string(),message:It.string(),baseLayer:It.boolean().optional(),exclude:It.array(It.string()).optional()})).returns(It.promise(It.object({assignmentId:It.string()}).passthrough())),Ece=Sce,Pwt=It.function().args(It.object({suUrl:It.string().url(),processId:It.string()})).returns(It.promise(It.object({tags:It.array(Jy)}).passthrough())),Owt=It.function().args(It.string()).returns(It.promise(It.object({url:It.string()}))),jUe=It.function().args(It.string()).returns(It.promise(It.boolean())),zUe=It.function().args(It.string()).returns(It.promise(It.object({tags:It.array(Jy)}).passthrough())),S7=It.function().args(It.object({data:It.any(),tags:It.array(Jy),target:It.string().optional(),anchor:It.string().optional()})).returns(It.promise(It.object({id:It.string(),raw:It.any()})));function HUe({loadResult:t}){return t=vn(DUe.implement(t)),e=>li({id:e.id,processId:e.processId}).chain(t)}function WUe(t){let e=$Ue(t),i=HUe(t);return({message:f,process:n})=>li({id:f,processId:n}).chain(e).chain(i).map(t.logger.tap('readResult result for message "%s": %O',f)).map(l=>l).bimap(b1,g1).toPromise()}var KUe=It.array(It.object({name:It.string(),value:It.string()}));function ZUe(){return t=>li(t.tags).map(x7([])).map(Vf("Data-Protocol","ao")).map(Vf("Variant")).map(Vf("Type")).map(Vf("SDK")).map(r$(d0,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Message"},{name:"SDK",value:"aoconnect"}])).map(KUe.parse).map(Jf("tags",d0,t))}function VUe({logger:t}){return e=>li(e).chain(i$(e$(e.data),()=>d1(e),()=>d1(Math.random().toString().slice(-4)).map(Jf("data",d0,e)).map(i=>Hm(m1("tags"),Vf("Content-Type"),t$({name:"Content-Type",value:"text/plain"}),Jf("tags",d0,i))(i)).map(t.tap('added pseudo-random string as message "data"'))))}function GUe(t){let e=ZUe(t),i=VUe(t),f=Sce.implement(t.deployMessage);return n=>li(n).chain(e).chain(i).chain(vn(({id:l,data:p,tags:v,anchor:_,signer:g})=>f({processId:l,data:p,tags:v,anchor:_,signer:S7.implement(g)}))).map(l=>Jf("messageId",l.messageId,n))}function YUe(t){let e=GUe(t);return({process:i,data:f,tags:n,anchor:l,signer:p})=>li({id:i,data:f,tags:n,anchor:l,signer:p}).chain(e).map(v=>v.messageId).bimap(b1,g1).toPromise()}var ny=(t,e,i)=>f=>e(f[t])?d1(f):ad(`Tag '${t}': ${i}`);function JUe({loadTransactionMeta:t,logger:e}){return t=vn(zUe.implement(t)),i=>li(i).chain(t).map(m1("tags")).map(OUe).chain(ny("Data-Protocol",Jle("ao"),"value 'ao' was not found on module")).chain(ny("Type",Jle("Module"),"value 'Module' was not found on module")).chain(ny("Module-Format",hC,"was not found on module")).chain(ny("Input-Encoding",hC,"was not found on module")).chain(ny("Output-Encoding",hC,"was not found on module")).bimap(e.tap("Verifying module source failed: %s"),e.tap("Verified module source"))}function XUe({logger:t,validateScheduler:e}){return e=vn(jUe.implement(e)),i=>li(i).chain(f=>e(f).chain(n=>n?d1(f):ad(`Valid Scheduler-Location owned by ${f} not found`))).bimap(t.tap("Verifying scheduler failed: %s"),t.tap("Verified scheduler"))}function QUe({logger:t}){return e=>li(e).map(t.tap("Checking for signer")).chain(i=>i?d1(i):ad("signer not found"))}function eFe(t){let e=t.logger.child("verifyInput");t={...t,logger:e};let i=JUe(t),f=XUe(t),n=QUe(t);return l=>li(l).chain(p=>i(p.module).map(()=>p)).chain(p=>f(p.scheduler)).map(()=>l).chain(p=>n(p.signer).map(()=>p)).bimap(e.tap("Error when verify input: %s"),e.tap("Successfully verified inputs"))}var tFe=It.array(It.object({name:It.string(),value:It.string()}));function rFe(){return t=>li(t).map(m1("tags")).map(x7([])).map(Vf("Data-Protocol","ao")).map(Vf("Variant")).map(Vf("Type")).map(Vf("Module")).map(Vf("Scheduler")).map(Vf("SDK")).map(r$(d0,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Process"},{name:"Module",value:t.module},{name:"Scheduler",value:t.scheduler},{name:"SDK",value:"aoconnect"}])).map(tFe.parse).map(Jf("tags",d0,t))}function iFe({logger:t}){return e=>li(e).chain(i$(e$(e.data),()=>d1(e),()=>d1(Math.random().toString().slice(-4)).map(Jf("data",d0,e)).map(i=>Hm(m1("tags"),Vf("Content-Type"),t$({name:"Content-Type",value:"text/plain"}),Jf("tags",d0,i))(i)).map(t.tap('added pseudo-random string as process "data"'))))}function nFe(t){let e=t.logger.child("uploadProcess");t={...t,logger:e};let i=rFe(t),f=iFe(t),n=UUe.implement(t.deployProcess);return l=>li(l).chain(i).chain(f).chain(vn(({data:p,tags:v,signer:_})=>n({data:p,tags:v,signer:S7.implement(_)}))).map(p=>Jf("processId",p.processId,l))}function aFe(t){let e=eFe(t),i=nFe(t);return({module:f,scheduler:n,signer:l,tags:p,data:v})=>li({module:f,scheduler:n,signer:l,tags:p,data:v}).chain(e).chain(i).map(_=>_.processId).bimap(b1,g1).toPromise()}function oFe(t){let e=Ece.implement(t.deployMonitor);return i=>li(i).chain(vn(({id:f,signer:n})=>e({processId:f,signer:S7.implement(n),data:Math.random().toString().slice(-4),tags:[]}))).map(f=>Jf("monitorId",f.messageId,i))}function sFe(t){let e=oFe(t);return({process:i,signer:f})=>li({id:i,signer:f}).chain(e).map(n=>n.monitorId).bimap(b1,g1).toPromise()}function fFe(t){let e=Ece.implement(t.deployUnmonitor);return i=>li(i).chain(vn(({id:f,signer:n})=>e({processId:f,signer:S7.implement(n),data:Math.random().toString().slice(-4),tags:[]}))).map(f=>Jf("monitorId",f.messageId,i))}function uFe(t){let e=fFe(t);return({process:i,signer:f})=>li({id:i,signer:f}).chain(e).map(n=>n.monitorId).bimap(b1,g1).toPromise()}var hFe=It.object({process:It.string().min(1,{message:"process identifier is required"}),from:It.string().optional(),to:It.string().optional(),sort:It.enum(["ASC","DESC"]).default("ASC"),limit:It.number().optional()});function lFe(){return t=>li(t).map(hFe.parse).map(()=>t)}function cFe({queryResults:t}){return t=vn(qUe.implement(t)),e=>li({process:e.process,from:e.from,to:e.to,sort:e.sort,limit:e.limit}).chain(t)}function dFe(t){let e=lFe(t),i=cFe(t);return({process:f,from:n,to:l,sort:p,limit:v})=>li({process:f,from:n,to:l,sort:p,limit:v}).chain(e).chain(i).map(t.logger.tap('readResults result for message "%s": %O',f)).map(_=>_).bimap(b1,g1).toPromise()}var pFe=It.object({Id:It.string(),Target:It.string(),Owner:It.string(),Anchor:It.string().optional(),Data:It.any().default("1234"),Tags:It.array(It.object({name:It.string(),value:It.string()}))});function vFe(){return t=>li(t).map(pFe.parse).map(e=>(e.Tags=e.Tags.concat([{name:"Data-Protocol",value:"ao"},{name:"Type",value:"Message"},{name:"Variant",value:"ao.TN.1"}]),e))}function mFe({dryrunFetch:t}){return vn(LUe.implement(t))}function gFe(t){let e=vFe(t),i=mFe(t);return f=>li(f).map(bFe).chain(e).chain(i).toPromise()}function bFe({process:t,data:e,tags:i,anchor:f,...n}){return{Id:"1234",Owner:"1234",...n,Target:t,Data:e||"1234",Tags:i||[],Anchor:f||"0"}}function yFe(t){let e=FUe.implement(t.deployAssign);return i=>li(i).chain(vn(({process:f,message:n,baseLayer:l,exclude:p})=>e({process:f,message:n,baseLayer:l,exclude:p}))).map(f=>Jf("assignmentId",f.assignmentId,i))}function wFe(t){let e=yFe(t);return({process:i,message:f,baseLayer:n,exclude:l})=>li({process:i,message:f,baseLayer:n,exclude:l}).chain(e).map(p=>p.assignmentId).bimap(b1,g1).toPromise()}var _Fe="https://arweave.net",MFe="https://mu.ao-testnet.xyz",xFe="https://cu.ao-testnet.xyz";function Ls({GRAPHQL_URL:t,GATEWAY_URL:e=_Fe,MU_URL:i=MFe,CU_URL:f=xFe}={}){let n=Mce();t||(t=xce({url:e,path:"/graphql"}));let{validate:l}=j0e({cacheSize:100,GRAPHQL_URL:t}),p=FLe({MAX_SIZE:25}),v=n.child("result"),_=WUe({loadResult:DLe({fetch,CU_URL:f,logger:v}),logger:v}),g=n.child("message"),y=YUe({loadProcessMeta:sC({fetch,cache:p,logger:g}),deployMessage:PLe({fetch,MU_URL:i,logger:g}),logger:g}),M=n.child("spawn"),x=aFe({loadTransactionMeta:BUe({fetch,GRAPHQL_URL:t,logger:M}),validateScheduler:l,deployProcess:OLe({fetch,MU_URL:i,logger:M}),logger:M}),S=n.child("monitor"),R=sFe({loadProcessMeta:sC({fetch,cache:p,logger:S}),deployMonitor:NLe({fetch,MU_URL:i,logger:S}),logger:S}),T=n.child("unmonitor"),k=uFe({loadProcessMeta:sC({fetch,cache:p,logger:T}),deployUnmonitor:CLe({fetch,MU_URL:i,logger:T}),logger:S}),B=n.child("results"),C=dFe({queryResults:qLe({fetch,CU_URL:f,logger:B}),logger:B}),N=n.child("dryrun"),W=gFe({dryrunFetch:LLe({fetch,CU_URL:f,logger:N}),logger:N}),H=n.child("assign"),J=wFe({deployAssign:$Le({fetch,MU_URL:i,logger:H}),logger:g});return{result:_,results:C,message:y,spawn:x,monitor:R,unmonitor:k,dryrun:W,assign:J}}var Ace={};e0e(Ace,{createDataItemSigner:()=>VFe});var Rce=qC(zNe(),1),Tce={};e0e(Tce,{AVSCTap:()=>Xy,ArweaveSigner:()=>f$,DataItem:()=>Zy,MAX_TAG_BYTES:()=>E7,MIN_BINARY_SIZE:()=>l$,SIG_CONFIG:()=>Gm,SignatureConfig:()=>Zf,Signer:()=>Pce,createData:()=>$ce,default:()=>WFe,deserializeTags:()=>v7,indexToType:()=>u$,serializeTags:()=>h$,tagsExceedLimit:()=>Cce,warparbundles:()=>KFe});var SFe=Object.create,o$=Object.defineProperty,EFe=Object.getOwnPropertyDescriptor,AFe=Object.getOwnPropertyNames,RFe=Object.getPrototypeOf,TFe=Object.prototype.hasOwnProperty,v0=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),IFe=(t,e)=>{for(var i in e)o$(t,i,{get:e[i],enumerable:!0})},kFe=(t,e,i,f)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of AFe(e))!TFe.call(t,n)&&n!==i&&o$(t,n,{get:()=>e[n],enumerable:!(f=EFe(e,n))||f.enumerable});return t},y1=(t,e,i)=>(i=t!=null?SFe(RFe(t)):{},kFe(e||!t||!t.__esModule?o$(i,"default",{value:t,enumerable:!0}):i,t)),BFe=v0(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});function e(i){var f=4,n=i.length,l=n%f;if(!l)return i;var p=n,v=f-l,_=n+v,g=De.alloc(_);for(g.write(i);v--;)g.write("=",p++);return g.toString()}t.default=e}),PFe=v0(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var e=BFe();function i(_,g){return g===void 0&&(g="utf8"),De.isBuffer(_)?l(_.toString("base64")):l(De.from(_,g).toString("base64"))}function f(_,g){return g===void 0&&(g="utf8"),De.from(n(_),"base64").toString(g)}function n(_){return _=_.toString(),e.default(_).replace(/\-/g,"+").replace(/_/g,"/")}function l(_){return _.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function p(_){return De.from(n(_),"base64")}var v=i;v.encode=i,v.decode=f,v.toBase64=n,v.fromBase64=l,v.toBuffer=p,t.default=v}),s$=v0((t,e)=>{e.exports=PFe().default,e.exports.default=e.exports}),Ice=v0(t=>{"use strict";t.byteLength=_,t.toByteArray=y,t.fromByteArray=S;var e=[],i=[],f=typeof Uint8Array<"u"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(l=0,p=n.length;l<p;++l)e[l]=n[l],i[n.charCodeAt(l)]=l;var l,p;i[45]=62,i[95]=63;function v(R){var T=R.length;if(T%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=R.indexOf("=");k===-1&&(k=T);var B=k===T?0:4-k%4;return[k,B]}function _(R){var T=v(R),k=T[0],B=T[1];return(k+B)*3/4-B}function g(R,T,k){return(T+k)*3/4-k}function y(R){var T,k=v(R),B=k[0],C=k[1],N=new f(g(R,B,C)),W=0,H=C>0?B-4:B,J;for(J=0;J<H;J+=4)T=i[R.charCodeAt(J)]<<18|i[R.charCodeAt(J+1)]<<12|i[R.charCodeAt(J+2)]<<6|i[R.charCodeAt(J+3)],N[W++]=T>>16&255,N[W++]=T>>8&255,N[W++]=T&255;return C===2&&(T=i[R.charCodeAt(J)]<<2|i[R.charCodeAt(J+1)]>>4,N[W++]=T&255),C===1&&(T=i[R.charCodeAt(J)]<<10|i[R.charCodeAt(J+1)]<<4|i[R.charCodeAt(J+2)]>>2,N[W++]=T>>8&255,N[W++]=T&255),N}function M(R){return e[R>>18&63]+e[R>>12&63]+e[R>>6&63]+e[R&63]}function x(R,T,k){for(var B,C=[],N=T;N<k;N+=3)B=(R[N]<<16&16711680)+(R[N+1]<<8&65280)+(R[N+2]&255),C.push(M(B));return C.join("")}function S(R){for(var T,k=R.length,B=k%3,C=[],N=16383,W=0,H=k-B;W<H;W+=N)C.push(x(R,W,W+N>H?H:W+N));return B===1?(T=R[k-1],C.push(e[T>>2]+e[T<<4&63]+"==")):B===2&&(T=(R[k-2]<<8)+R[k-1],C.push(e[T>>10]+e[T>>4&63]+e[T<<2&63]+"=")),C.join("")}}),kce=v0(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64UrlDecode=t.b64UrlEncode=t.bufferTob64Url=t.bufferTob64=t.b64UrlToBuffer=t.stringToB64Url=t.stringToBuffer=t.bufferToString=t.b64UrlToString=t.concatBuffers=void 0;var e=Ice();function i(x){let S=0;for(let k=0;k<x.length;k++)S+=x[k].byteLength;let R=new Uint8Array(S),T=0;R.set(new Uint8Array(x[0]),T),T+=x[0].byteLength;for(let k=1;k<x.length;k++)R.set(new Uint8Array(x[k]),T),T+=x[k].byteLength;return R}t.concatBuffers=i;function f(x){let S=v(x);return n(S)}t.b64UrlToString=f;function n(x){return new TextDecoder("utf-8",{fatal:!0}).decode(x)}t.bufferToString=n;function l(x){return new TextEncoder().encode(x)}t.stringToBuffer=l;function p(x){return g(l(x))}t.stringToB64Url=p;function v(x){return new Uint8Array(e.toByteArray(M(x)))}t.b64UrlToBuffer=v;function _(x){return e.fromByteArray(new Uint8Array(x))}t.bufferTob64=_;function g(x){return y(_(x))}t.bufferTob64Url=g;function y(x){return x.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}t.b64UrlEncode=y;function M(x){x=x.replace(/\-/g,"+").replace(/\_/g,"/");let S;return x.length%4==0?S=0:S=4-x.length%4,x.concat("=".repeat(S))}t.b64UrlDecode=M}),OFe=v0(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var e=kce(),i=class{keyLength=4096;publicExponent=65537;hashAlgorithm="sha256";driver;constructor(){if(!this.detectWebCrypto())throw new Error("SubtleCrypto not available!");this.driver=crypto.subtle}async generateJWK(){let f=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),n=await this.driver.exportKey("jwk",f.privateKey);return{kty:n.kty,e:n.e,n:n.n,d:n.d,p:n.p,q:n.q,dp:n.dp,dq:n.dq,qi:n.qi}}async sign(f,n,{saltLength:l}={}){let p=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(f),n);return new Uint8Array(p)}async hash(f,n="SHA-256"){let l=await this.driver.digest(n,f);return new Uint8Array(l)}async verify(f,n,l){let p={kty:"RSA",e:"AQAB",n:f},v=await this.jwkToPublicCryptoKey(p),_=await this.driver.digest("SHA-256",n),g=await this.driver.verify({name:"RSA-PSS",saltLength:0},v,l,n),y=await this.driver.verify({name:"RSA-PSS",saltLength:32},v,l,n),M=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((v.algorithm.modulusLength-1)/8)-_.byteLength-2},v,l,n);return g||y||M}async jwkToCryptoKey(f){return this.driver.importKey("jwk",f,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(f){return this.driver.importKey("jwk",f,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let f=crypto?.subtle;return f===void 0?!1:["generateKey","importKey","exportKey","digest","sign"].every(n=>typeof f[n]=="function")}async encrypt(f,n,l){let p=await this.driver.importKey("raw",typeof n=="string"?e.stringToBuffer(n):n,{name:"PBKDF2",length:32},!1,["deriveKey"]),v=await this.driver.deriveKey({name:"PBKDF2",salt:l?e.stringToBuffer(l):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},p,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),_=new Uint8Array(16);crypto.getRandomValues(_);let g=await this.driver.encrypt({name:"AES-CBC",iv:_},v,f);return e.concatBuffers([_,g])}async decrypt(f,n,l){let p=await this.driver.importKey("raw",typeof n=="string"?e.stringToBuffer(n):n,{name:"PBKDF2",length:32},!1,["deriveKey"]),v=await this.driver.deriveKey({name:"PBKDF2",salt:l?e.stringToBuffer(l):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},p,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),_=f.slice(0,16),g=await this.driver.decrypt({name:"AES-CBC",iv:_},v,f.slice(16));return e.concatBuffers([g])}};t.default=i}),NFe=v0(t=>{t.read=function(e,i,f,n,l){var p,v,_=l*8-n-1,g=(1<<_)-1,y=g>>1,M=-7,x=f?l-1:0,S=f?-1:1,R=e[i+x];for(x+=S,p=R&(1<<-M)-1,R>>=-M,M+=_;M>0;p=p*256+e[i+x],x+=S,M-=8);for(v=p&(1<<-M)-1,p>>=-M,M+=n;M>0;v=v*256+e[i+x],x+=S,M-=8);if(p===0)p=1-y;else{if(p===g)return v?NaN:(R?-1:1)*(1/0);v=v+Math.pow(2,n),p=p-y}return(R?-1:1)*v*Math.pow(2,p-n)},t.write=function(e,i,f,n,l,p){var v,_,g,y=p*8-l-1,M=(1<<y)-1,x=M>>1,S=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,R=n?0:p-1,T=n?1:-1,k=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(_=isNaN(i)?1:0,v=M):(v=Math.floor(Math.log(i)/Math.LN2),i*(g=Math.pow(2,-v))<1&&(v--,g*=2),v+x>=1?i+=S/g:i+=S*Math.pow(2,1-x),i*g>=2&&(v++,g/=2),v+x>=M?(_=0,v=M):v+x>=1?(_=(i*g-1)*Math.pow(2,l),v=v+x):(_=i*Math.pow(2,x-1)*Math.pow(2,l),v=0));l>=8;e[f+R]=_&255,R+=T,_/=256,l-=8);for(v=v<<l|_,y+=l;y>0;e[f+R]=v&255,R+=T,v/=256,y-=8);e[f+R-T]|=k*128}}),$C=v0(t=>{"use strict";var e=Ice(),i=NFe(),f=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=v,t.SlowBuffer=C,t.INSPECT_MAX_BYTES=50;var n=2147483647;t.kMaxLength=n,v.TYPED_ARRAY_SUPPORT=l(),!v.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{let P=new Uint8Array(1),O={foo:function(){return 42}};return Object.setPrototypeOf(O,Uint8Array.prototype),Object.setPrototypeOf(P,O),P.foo()===42}catch{return!1}}Object.defineProperty(v.prototype,"parent",{enumerable:!0,get:function(){if(v.isBuffer(this))return this.buffer}}),Object.defineProperty(v.prototype,"offset",{enumerable:!0,get:function(){if(v.isBuffer(this))return this.byteOffset}});function p(P){if(P>n)throw new RangeError('The value "'+P+'" is invalid for option "size"');let O=new Uint8Array(P);return Object.setPrototypeOf(O,v.prototype),O}function v(P,O,$){if(typeof P=="number"){if(typeof O=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return M(P)}return _(P,O,$)}v.poolSize=8192;function _(P,O,$){if(typeof P=="string")return x(P,O);if(ArrayBuffer.isView(P))return R(P);if(P==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof P);if(dt(P,ArrayBuffer)||P&&dt(P.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(dt(P,SharedArrayBuffer)||P&&dt(P.buffer,SharedArrayBuffer)))return T(P,O,$);if(typeof P=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let Z=P.valueOf&&P.valueOf();if(Z!=null&&Z!==P)return v.from(Z,O,$);let te=k(P);if(te)return te;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof P[Symbol.toPrimitive]=="function")return v.from(P[Symbol.toPrimitive]("string"),O,$);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof P)}v.from=function(P,O,$){return _(P,O,$)},Object.setPrototypeOf(v.prototype,Uint8Array.prototype),Object.setPrototypeOf(v,Uint8Array);function g(P){if(typeof P!="number")throw new TypeError('"size" argument must be of type number');if(P<0)throw new RangeError('The value "'+P+'" is invalid for option "size"')}function y(P,O,$){return g(P),P<=0?p(P):O!==void 0?typeof $=="string"?p(P).fill(O,$):p(P).fill(O):p(P)}v.alloc=function(P,O,$){return y(P,O,$)};function M(P){return g(P),p(P<0?0:B(P)|0)}v.allocUnsafe=function(P){return M(P)},v.allocUnsafeSlow=function(P){return M(P)};function x(P,O){if((typeof O!="string"||O==="")&&(O="utf8"),!v.isEncoding(O))throw new TypeError("Unknown encoding: "+O);let $=N(P,O)|0,Z=p($),te=Z.write(P,O);return te!==$&&(Z=Z.slice(0,te)),Z}function S(P){let O=P.length<0?0:B(P.length)|0,$=p(O);for(let Z=0;Z<O;Z+=1)$[Z]=P[Z]&255;return $}function R(P){if(dt(P,Uint8Array)){let O=new Uint8Array(P);return T(O.buffer,O.byteOffset,O.byteLength)}return S(P)}function T(P,O,$){if(O<0||P.byteLength<O)throw new RangeError('"offset" is outside of buffer bounds');if(P.byteLength<O+($||0))throw new RangeError('"length" is outside of buffer bounds');let Z;return O===void 0&&$===void 0?Z=new Uint8Array(P):$===void 0?Z=new Uint8Array(P,O):Z=new Uint8Array(P,O,$),Object.setPrototypeOf(Z,v.prototype),Z}function k(P){if(v.isBuffer(P)){let O=B(P.length)|0,$=p(O);return $.length===0||P.copy($,0,0,O),$}if(P.length!==void 0)return typeof P.length!="number"||Me(P.length)?p(0):S(P);if(P.type==="Buffer"&&Array.isArray(P.data))return S(P.data)}function B(P){if(P>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return P|0}function C(P){return+P!=P&&(P=0),v.alloc(+P)}v.isBuffer=function(P){return P!=null&&P._isBuffer===!0&&P!==v.prototype},v.compare=function(P,O){if(dt(P,Uint8Array)&&(P=v.from(P,P.offset,P.byteLength)),dt(O,Uint8Array)&&(O=v.from(O,O.offset,O.byteLength)),!v.isBuffer(P)||!v.isBuffer(O))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(P===O)return 0;let $=P.length,Z=O.length;for(let te=0,X=Math.min($,Z);te<X;++te)if(P[te]!==O[te]){$=P[te],Z=O[te];break}return $<Z?-1:Z<$?1:0},v.isEncoding=function(P){switch(String(P).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},v.concat=function(P,O){if(!Array.isArray(P))throw new TypeError('"list" argument must be an Array of Buffers');if(P.length===0)return v.alloc(0);let $;if(O===void 0)for(O=0,$=0;$<P.length;++$)O+=P[$].length;let Z=v.allocUnsafe(O),te=0;for($=0;$<P.length;++$){let X=P[$];if(dt(X,Uint8Array))te+X.length>Z.length?(v.isBuffer(X)||(X=v.from(X)),X.copy(Z,te)):Uint8Array.prototype.set.call(Z,X,te);else if(v.isBuffer(X))X.copy(Z,te);else throw new TypeError('"list" argument must be an Array of Buffers');te+=X.length}return Z};function N(P,O){if(v.isBuffer(P))return P.length;if(ArrayBuffer.isView(P)||dt(P,ArrayBuffer))return P.byteLength;if(typeof P!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof P);let $=P.length,Z=arguments.length>2&&arguments[2]===!0;if(!Z&&$===0)return 0;let te=!1;for(;;)switch(O){case"ascii":case"latin1":case"binary":return $;case"utf8":case"utf-8":return ie(P).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $*2;case"hex":return $>>>1;case"base64":return he(P).length;default:if(te)return Z?-1:ie(P).length;O=(""+O).toLowerCase(),te=!0}}v.byteLength=N;function W(P,O,$){let Z=!1;if((O===void 0||O<0)&&(O=0),O>this.length||(($===void 0||$>this.length)&&($=this.length),$<=0)||($>>>=0,O>>>=0,$<=O))return"";for(P||(P="utf8");;)switch(P){case"hex":return a(this,O,$);case"utf8":case"utf-8":return u(this,O,$);case"ascii":return w(this,O,$);case"latin1":case"binary":return c(this,O,$);case"base64":return s(this,O,$);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d(this,O,$);default:if(Z)throw new TypeError("Unknown encoding: "+P);P=(P+"").toLowerCase(),Z=!0}}v.prototype._isBuffer=!0;function H(P,O,$){let Z=P[O];P[O]=P[$],P[$]=Z}v.prototype.swap16=function(){let P=this.length;if(P%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let O=0;O<P;O+=2)H(this,O,O+1);return this},v.prototype.swap32=function(){let P=this.length;if(P%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let O=0;O<P;O+=4)H(this,O,O+3),H(this,O+1,O+2);return this},v.prototype.swap64=function(){let P=this.length;if(P%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let O=0;O<P;O+=8)H(this,O,O+7),H(this,O+1,O+6),H(this,O+2,O+5),H(this,O+3,O+4);return this},v.prototype.toString=function(){let P=this.length;return P===0?"":arguments.length===0?u(this,0,P):W.apply(this,arguments)},v.prototype.toLocaleString=v.prototype.toString,v.prototype.equals=function(P){if(!v.isBuffer(P))throw new TypeError("Argument must be a Buffer");return this===P?!0:v.compare(this,P)===0},v.prototype.inspect=function(){let P="",O=t.INSPECT_MAX_BYTES;return P=this.toString("hex",0,O).replace(/(.{2})/g,"$1 ").trim(),this.length>O&&(P+=" ... "),"<Buffer "+P+">"},f&&(v.prototype[f]=v.prototype.inspect),v.prototype.compare=function(P,O,$,Z,te){if(dt(P,Uint8Array)&&(P=v.from(P,P.offset,P.byteLength)),!v.isBuffer(P))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof P);if(O===void 0&&(O=0),$===void 0&&($=P?P.length:0),Z===void 0&&(Z=0),te===void 0&&(te=this.length),O<0||$>P.length||Z<0||te>this.length)throw new RangeError("out of range index");if(Z>=te&&O>=$)return 0;if(Z>=te)return-1;if(O>=$)return 1;if(O>>>=0,$>>>=0,Z>>>=0,te>>>=0,this===P)return 0;let X=te-Z,ae=$-O,qe=Math.min(X,ae),ue=this.slice(Z,te),ge=P.slice(O,$);for(let xe=0;xe<qe;++xe)if(ue[xe]!==ge[xe]){X=ue[xe],ae=ge[xe];break}return X<ae?-1:ae<X?1:0};function J(P,O,$,Z,te){if(P.length===0)return-1;if(typeof $=="string"?(Z=$,$=0):$>2147483647?$=2147483647:$<-2147483648&&($=-2147483648),$=+$,Me($)&&($=te?0:P.length-1),$<0&&($=P.length+$),$>=P.length){if(te)return-1;$=P.length-1}else if($<0)if(te)$=0;else return-1;if(typeof O=="string"&&(O=v.from(O,Z)),v.isBuffer(O))return O.length===0?-1:q(P,O,$,Z,te);if(typeof O=="number")return O=O&255,typeof Uint8Array.prototype.indexOf=="function"?te?Uint8Array.prototype.indexOf.call(P,O,$):Uint8Array.prototype.lastIndexOf.call(P,O,$):q(P,[O],$,Z,te);throw new TypeError("val must be string, number or Buffer")}function q(P,O,$,Z,te){let X=1,ae=P.length,qe=O.length;if(Z!==void 0&&(Z=String(Z).toLowerCase(),Z==="ucs2"||Z==="ucs-2"||Z==="utf16le"||Z==="utf-16le")){if(P.length<2||O.length<2)return-1;X=2,ae/=2,qe/=2,$/=2}function ue(xe,be){return X===1?xe[be]:xe.readUInt16BE(be*X)}let ge;if(te){let xe=-1;for(ge=$;ge<ae;ge++)if(ue(P,ge)===ue(O,xe===-1?0:ge-xe)){if(xe===-1&&(xe=ge),ge-xe+1===qe)return xe*X}else xe!==-1&&(ge-=ge-xe),xe=-1}else for($+qe>ae&&($=ae-qe),ge=$;ge>=0;ge--){let xe=!0;for(let be=0;be<qe;be++)if(ue(P,ge+be)!==ue(O,be)){xe=!1;break}if(xe)return ge}return-1}v.prototype.includes=function(P,O,$){return this.indexOf(P,O,$)!==-1},v.prototype.indexOf=function(P,O,$){return J(this,P,O,$,!0)},v.prototype.lastIndexOf=function(P,O,$){return J(this,P,O,$,!1)};function z(P,O,$,Z){$=Number($)||0;let te=P.length-$;Z?(Z=Number(Z),Z>te&&(Z=te)):Z=te;let X=O.length;Z>X/2&&(Z=X/2);let ae;for(ae=0;ae<Z;++ae){let qe=parseInt(O.substr(ae*2,2),16);if(Me(qe))return ae;P[$+ae]=qe}return ae}function Y(P,O,$,Z){return ye(ie(O,P.length-$),P,$,Z)}function b(P,O,$,Z){return ye(oe(O),P,$,Z)}function r(P,O,$,Z){return ye(he(O),P,$,Z)}function o(P,O,$,Z){return ye(Be(O,P.length-$),P,$,Z)}v.prototype.write=function(P,O,$,Z){if(O===void 0)Z="utf8",$=this.length,O=0;else if($===void 0&&typeof O=="string")Z=O,$=this.length,O=0;else if(isFinite(O))O=O>>>0,isFinite($)?($=$>>>0,Z===void 0&&(Z="utf8")):(Z=$,$=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let te=this.length-O;if(($===void 0||$>te)&&($=te),P.length>0&&($<0||O<0)||O>this.length)throw new RangeError("Attempt to write outside buffer bounds");Z||(Z="utf8");let X=!1;for(;;)switch(Z){case"hex":return z(this,P,O,$);case"utf8":case"utf-8":return Y(this,P,O,$);case"ascii":case"latin1":case"binary":return b(this,P,O,$);case"base64":return r(this,P,O,$);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o(this,P,O,$);default:if(X)throw new TypeError("Unknown encoding: "+Z);Z=(""+Z).toLowerCase(),X=!0}},v.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function s(P,O,$){return O===0&&$===P.length?e.fromByteArray(P):e.fromByteArray(P.slice(O,$))}function u(P,O,$){$=Math.min(P.length,$);let Z=[],te=O;for(;te<$;){let X=P[te],ae=null,qe=X>239?4:X>223?3:X>191?2:1;if(te+qe<=$){let ue,ge,xe,be;switch(qe){case 1:X<128&&(ae=X);break;case 2:ue=P[te+1],(ue&192)===128&&(be=(X&31)<<6|ue&63,be>127&&(ae=be));break;case 3:ue=P[te+1],ge=P[te+2],(ue&192)===128&&(ge&192)===128&&(be=(X&15)<<12|(ue&63)<<6|ge&63,be>2047&&(be<55296||be>57343)&&(ae=be));break;case 4:ue=P[te+1],ge=P[te+2],xe=P[te+3],(ue&192)===128&&(ge&192)===128&&(xe&192)===128&&(be=(X&15)<<18|(ue&63)<<12|(ge&63)<<6|xe&63,be>65535&&be<1114112&&(ae=be))}}ae===null?(ae=65533,qe=1):ae>65535&&(ae-=65536,Z.push(ae>>>10&1023|55296),ae=56320|ae&1023),Z.push(ae),te+=qe}return m(Z)}var h=4096;function m(P){let O=P.length;if(O<=h)return String.fromCharCode.apply(String,P);let $="",Z=0;for(;Z<O;)$+=String.fromCharCode.apply(String,P.slice(Z,Z+=h));return $}function w(P,O,$){let Z="";$=Math.min(P.length,$);for(let te=O;te<$;++te)Z+=String.fromCharCode(P[te]&127);return Z}function c(P,O,$){let Z="";$=Math.min(P.length,$);for(let te=O;te<$;++te)Z+=String.fromCharCode(P[te]);return Z}function a(P,O,$){let Z=P.length;(!O||O<0)&&(O=0),(!$||$<0||$>Z)&&($=Z);let te="";for(let X=O;X<$;++X)te+=ke[P[X]];return te}function d(P,O,$){let Z=P.slice(O,$),te="";for(let X=0;X<Z.length-1;X+=2)te+=String.fromCharCode(Z[X]+Z[X+1]*256);return te}v.prototype.slice=function(P,O){let $=this.length;P=~~P,O=O===void 0?$:~~O,P<0?(P+=$,P<0&&(P=0)):P>$&&(P=$),O<0?(O+=$,O<0&&(O=0)):O>$&&(O=$),O<P&&(O=P);let Z=this.subarray(P,O);return Object.setPrototypeOf(Z,v.prototype),Z};function A(P,O,$){if(P%1!==0||P<0)throw new RangeError("offset is not uint");if(P+O>$)throw new RangeError("Trying to access beyond buffer length")}v.prototype.readUintLE=v.prototype.readUIntLE=function(P,O,$){P=P>>>0,O=O>>>0,$||A(P,O,this.length);let Z=this[P],te=1,X=0;for(;++X<O&&(te*=256);)Z+=this[P+X]*te;return Z},v.prototype.readUintBE=v.prototype.readUIntBE=function(P,O,$){P=P>>>0,O=O>>>0,$||A(P,O,this.length);let Z=this[P+--O],te=1;for(;O>0&&(te*=256);)Z+=this[P+--O]*te;return Z},v.prototype.readUint8=v.prototype.readUInt8=function(P,O){return P=P>>>0,O||A(P,1,this.length),this[P]},v.prototype.readUint16LE=v.prototype.readUInt16LE=function(P,O){return P=P>>>0,O||A(P,2,this.length),this[P]|this[P+1]<<8},v.prototype.readUint16BE=v.prototype.readUInt16BE=function(P,O){return P=P>>>0,O||A(P,2,this.length),this[P]<<8|this[P+1]},v.prototype.readUint32LE=v.prototype.readUInt32LE=function(P,O){return P=P>>>0,O||A(P,4,this.length),(this[P]|this[P+1]<<8|this[P+2]<<16)+this[P+3]*16777216},v.prototype.readUint32BE=v.prototype.readUInt32BE=function(P,O){return P=P>>>0,O||A(P,4,this.length),this[P]*16777216+(this[P+1]<<16|this[P+2]<<8|this[P+3])},v.prototype.readBigUInt64LE=gt(function(P){P=P>>>0,K(P,"offset");let O=this[P],$=this[P+7];(O===void 0||$===void 0)&&G(P,this.length-8);let Z=O+this[++P]*2**8+this[++P]*2**16+this[++P]*2**24,te=this[++P]+this[++P]*2**8+this[++P]*2**16+$*2**24;return BigInt(Z)+(BigInt(te)<<BigInt(32))}),v.prototype.readBigUInt64BE=gt(function(P){P=P>>>0,K(P,"offset");let O=this[P],$=this[P+7];(O===void 0||$===void 0)&&G(P,this.length-8);let Z=O*2**24+this[++P]*2**16+this[++P]*2**8+this[++P],te=this[++P]*2**24+this[++P]*2**16+this[++P]*2**8+$;return(BigInt(Z)<<BigInt(32))+BigInt(te)}),v.prototype.readIntLE=function(P,O,$){P=P>>>0,O=O>>>0,$||A(P,O,this.length);let Z=this[P],te=1,X=0;for(;++X<O&&(te*=256);)Z+=this[P+X]*te;return te*=128,Z>=te&&(Z-=Math.pow(2,8*O)),Z},v.prototype.readIntBE=function(P,O,$){P=P>>>0,O=O>>>0,$||A(P,O,this.length);let Z=O,te=1,X=this[P+--Z];for(;Z>0&&(te*=256);)X+=this[P+--Z]*te;return te*=128,X>=te&&(X-=Math.pow(2,8*O)),X},v.prototype.readInt8=function(P,O){return P=P>>>0,O||A(P,1,this.length),this[P]&128?(255-this[P]+1)*-1:this[P]},v.prototype.readInt16LE=function(P,O){P=P>>>0,O||A(P,2,this.length);let $=this[P]|this[P+1]<<8;return $&32768?$|4294901760:$},v.prototype.readInt16BE=function(P,O){P=P>>>0,O||A(P,2,this.length);let $=this[P+1]|this[P]<<8;return $&32768?$|4294901760:$},v.prototype.readInt32LE=function(P,O){return P=P>>>0,O||A(P,4,this.length),this[P]|this[P+1]<<8|this[P+2]<<16|this[P+3]<<24},v.prototype.readInt32BE=function(P,O){return P=P>>>0,O||A(P,4,this.length),this[P]<<24|this[P+1]<<16|this[P+2]<<8|this[P+3]},v.prototype.readBigInt64LE=gt(function(P){P=P>>>0,K(P,"offset");let O=this[P],$=this[P+7];(O===void 0||$===void 0)&&G(P,this.length-8);let Z=this[P+4]+this[P+5]*2**8+this[P+6]*2**16+($<<24);return(BigInt(Z)<<BigInt(32))+BigInt(O+this[++P]*2**8+this[++P]*2**16+this[++P]*2**24)}),v.prototype.readBigInt64BE=gt(function(P){P=P>>>0,K(P,"offset");let O=this[P],$=this[P+7];(O===void 0||$===void 0)&&G(P,this.length-8);let Z=(O<<24)+this[++P]*2**16+this[++P]*2**8+this[++P];return(BigInt(Z)<<BigInt(32))+BigInt(this[++P]*2**24+this[++P]*2**16+this[++P]*2**8+$)}),v.prototype.readFloatLE=function(P,O){return P=P>>>0,O||A(P,4,this.length),i.read(this,P,!0,23,4)},v.prototype.readFloatBE=function(P,O){return P=P>>>0,O||A(P,4,this.length),i.read(this,P,!1,23,4)},v.prototype.readDoubleLE=function(P,O){return P=P>>>0,O||A(P,8,this.length),i.read(this,P,!0,52,8)},v.prototype.readDoubleBE=function(P,O){return P=P>>>0,O||A(P,8,this.length),i.read(this,P,!1,52,8)};function E(P,O,$,Z,te,X){if(!v.isBuffer(P))throw new TypeError('"buffer" argument must be a Buffer instance');if(O>te||O<X)throw new RangeError('"value" argument is out of bounds');if($+Z>P.length)throw new RangeError("Index out of range")}v.prototype.writeUintLE=v.prototype.writeUIntLE=function(P,O,$,Z){if(P=+P,O=O>>>0,$=$>>>0,!Z){let ae=Math.pow(2,8*$)-1;E(this,P,O,$,ae,0)}let te=1,X=0;for(this[O]=P&255;++X<$&&(te*=256);)this[O+X]=P/te&255;return O+$},v.prototype.writeUintBE=v.prototype.writeUIntBE=function(P,O,$,Z){if(P=+P,O=O>>>0,$=$>>>0,!Z){let ae=Math.pow(2,8*$)-1;E(this,P,O,$,ae,0)}let te=$-1,X=1;for(this[O+te]=P&255;--te>=0&&(X*=256);)this[O+te]=P/X&255;return O+$},v.prototype.writeUint8=v.prototype.writeUInt8=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,1,255,0),this[O]=P&255,O+1},v.prototype.writeUint16LE=v.prototype.writeUInt16LE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,2,65535,0),this[O]=P&255,this[O+1]=P>>>8,O+2},v.prototype.writeUint16BE=v.prototype.writeUInt16BE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,2,65535,0),this[O]=P>>>8,this[O+1]=P&255,O+2},v.prototype.writeUint32LE=v.prototype.writeUInt32LE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,4,4294967295,0),this[O+3]=P>>>24,this[O+2]=P>>>16,this[O+1]=P>>>8,this[O]=P&255,O+4},v.prototype.writeUint32BE=v.prototype.writeUInt32BE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,4,4294967295,0),this[O]=P>>>24,this[O+1]=P>>>16,this[O+2]=P>>>8,this[O+3]=P&255,O+4};function I(P,O,$,Z,te){F(O,Z,te,P,$,7);let X=Number(O&BigInt(4294967295));P[$++]=X,X=X>>8,P[$++]=X,X=X>>8,P[$++]=X,X=X>>8,P[$++]=X;let ae=Number(O>>BigInt(32)&BigInt(4294967295));return P[$++]=ae,ae=ae>>8,P[$++]=ae,ae=ae>>8,P[$++]=ae,ae=ae>>8,P[$++]=ae,$}function D(P,O,$,Z,te){F(O,Z,te,P,$,7);let X=Number(O&BigInt(4294967295));P[$+7]=X,X=X>>8,P[$+6]=X,X=X>>8,P[$+5]=X,X=X>>8,P[$+4]=X;let ae=Number(O>>BigInt(32)&BigInt(4294967295));return P[$+3]=ae,ae=ae>>8,P[$+2]=ae,ae=ae>>8,P[$+1]=ae,ae=ae>>8,P[$]=ae,$+8}v.prototype.writeBigUInt64LE=gt(function(P,O=0){return I(this,P,O,BigInt(0),BigInt("0xffffffffffffffff"))}),v.prototype.writeBigUInt64BE=gt(function(P,O=0){return D(this,P,O,BigInt(0),BigInt("0xffffffffffffffff"))}),v.prototype.writeIntLE=function(P,O,$,Z){if(P=+P,O=O>>>0,!Z){let qe=Math.pow(2,8*$-1);E(this,P,O,$,qe-1,-qe)}let te=0,X=1,ae=0;for(this[O]=P&255;++te<$&&(X*=256);)P<0&&ae===0&&this[O+te-1]!==0&&(ae=1),this[O+te]=(P/X>>0)-ae&255;return O+$},v.prototype.writeIntBE=function(P,O,$,Z){if(P=+P,O=O>>>0,!Z){let qe=Math.pow(2,8*$-1);E(this,P,O,$,qe-1,-qe)}let te=$-1,X=1,ae=0;for(this[O+te]=P&255;--te>=0&&(X*=256);)P<0&&ae===0&&this[O+te+1]!==0&&(ae=1),this[O+te]=(P/X>>0)-ae&255;return O+$},v.prototype.writeInt8=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,1,127,-128),P<0&&(P=255+P+1),this[O]=P&255,O+1},v.prototype.writeInt16LE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,2,32767,-32768),this[O]=P&255,this[O+1]=P>>>8,O+2},v.prototype.writeInt16BE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,2,32767,-32768),this[O]=P>>>8,this[O+1]=P&255,O+2},v.prototype.writeInt32LE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,4,2147483647,-2147483648),this[O]=P&255,this[O+1]=P>>>8,this[O+2]=P>>>16,this[O+3]=P>>>24,O+4},v.prototype.writeInt32BE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,4,2147483647,-2147483648),P<0&&(P=4294967295+P+1),this[O]=P>>>24,this[O+1]=P>>>16,this[O+2]=P>>>8,this[O+3]=P&255,O+4},v.prototype.writeBigInt64LE=gt(function(P,O=0){return I(this,P,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),v.prototype.writeBigInt64BE=gt(function(P,O=0){return D(this,P,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function j(P,O,$,Z,te,X){if($+Z>P.length)throw new RangeError("Index out of range");if($<0)throw new RangeError("Index out of range")}function re(P,O,$,Z,te){return O=+O,$=$>>>0,te||j(P,O,$,4,34028234663852886e22,-34028234663852886e22),i.write(P,O,$,Z,23,4),$+4}v.prototype.writeFloatLE=function(P,O,$){return re(this,P,O,!0,$)},v.prototype.writeFloatBE=function(P,O,$){return re(this,P,O,!1,$)};function Q(P,O,$,Z,te){return O=+O,$=$>>>0,te||j(P,O,$,8,17976931348623157e292,-17976931348623157e292),i.write(P,O,$,Z,52,8),$+8}v.prototype.writeDoubleLE=function(P,O,$){return Q(this,P,O,!0,$)},v.prototype.writeDoubleBE=function(P,O,$){return Q(this,P,O,!1,$)},v.prototype.copy=function(P,O,$,Z){if(!v.isBuffer(P))throw new TypeError("argument should be a Buffer");if($||($=0),!Z&&Z!==0&&(Z=this.length),O>=P.length&&(O=P.length),O||(O=0),Z>0&&Z<$&&(Z=$),Z===$||P.length===0||this.length===0)return 0;if(O<0)throw new RangeError("targetStart out of bounds");if($<0||$>=this.length)throw new RangeError("Index out of range");if(Z<0)throw new RangeError("sourceEnd out of bounds");Z>this.length&&(Z=this.length),P.length-O<Z-$&&(Z=P.length-O+$);let te=Z-$;return this===P&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(O,$,Z):Uint8Array.prototype.set.call(P,this.subarray($,Z),O),te},v.prototype.fill=function(P,O,$,Z){if(typeof P=="string"){if(typeof O=="string"?(Z=O,O=0,$=this.length):typeof $=="string"&&(Z=$,$=this.length),Z!==void 0&&typeof Z!="string")throw new TypeError("encoding must be a string");if(typeof Z=="string"&&!v.isEncoding(Z))throw new TypeError("Unknown encoding: "+Z);if(P.length===1){let X=P.charCodeAt(0);(Z==="utf8"&&X<128||Z==="latin1")&&(P=X)}}else typeof P=="number"?P=P&255:typeof P=="boolean"&&(P=Number(P));if(O<0||this.length<O||this.length<$)throw new RangeError("Out of range index");if($<=O)return this;O=O>>>0,$=$===void 0?this.length:$>>>0,P||(P=0);let te;if(typeof P=="number")for(te=O;te<$;++te)this[te]=P;else{let X=v.isBuffer(P)?P:v.from(P,Z),ae=X.length;if(ae===0)throw new TypeError('The value "'+P+'" is invalid for argument "value"');for(te=0;te<$-O;++te)this[te+O]=X[te%ae]}return this};var L={};function U(P,O,$){L[P]=class extends ${constructor(){super(),Object.defineProperty(this,"message",{value:O.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${P}]`,this.stack,delete this.name}get code(){return P}set code(Z){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:Z,writable:!0})}toString(){return`${this.name} [${P}]: ${this.message}`}}}U("ERR_BUFFER_OUT_OF_BOUNDS",function(P){return P?`${P} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),U("ERR_INVALID_ARG_TYPE",function(P,O){return`The "${P}" argument must be of type number. Received type ${typeof O}`},TypeError),U("ERR_OUT_OF_RANGE",function(P,O,$){let Z=`The value of "${P}" is out of range.`,te=$;return Number.isInteger($)&&Math.abs($)>2**32?te=se(String($)):typeof $=="bigint"&&(te=String($),($>BigInt(2)**BigInt(32)||$<-(BigInt(2)**BigInt(32)))&&(te=se(te)),te+="n"),Z+=` It must be ${O}. Received ${te}`,Z},RangeError);function se(P){let O="",$=P.length,Z=P[0]==="-"?1:0;for(;$>=Z+4;$-=3)O=`_${P.slice($-3,$)}${O}`;return`${P.slice(0,$)}${O}`}function ee(P,O,$){K(O,"offset"),(P[O]===void 0||P[O+$]===void 0)&&G(O,P.length-($+1))}function F(P,O,$,Z,te,X){if(P>$||P<O){let ae=typeof O=="bigint"?"n":"",qe;throw X>3?O===0||O===BigInt(0)?qe=`>= 0${ae} and < 2${ae} ** ${(X+1)*8}${ae}`:qe=`>= -(2${ae} ** ${(X+1)*8-1}${ae}) and < 2 ** ${(X+1)*8-1}${ae}`:qe=`>= ${O}${ae} and <= ${$}${ae}`,new L.ERR_OUT_OF_RANGE("value",qe,P)}ee(Z,te,X)}function K(P,O){if(typeof P!="number")throw new L.ERR_INVALID_ARG_TYPE(O,"number",P)}function G(P,O,$){throw Math.floor(P)!==P?(K(P,$),new L.ERR_OUT_OF_RANGE($||"offset","an integer",P)):O<0?new L.ERR_BUFFER_OUT_OF_BOUNDS:new L.ERR_OUT_OF_RANGE($||"offset",`>= ${$?1:0} and <= ${O}`,P)}var ne=/[^+/0-9A-Za-z-_]/g;function Re(P){if(P=P.split("=")[0],P=P.trim().replace(ne,""),P.length<2)return"";for(;P.length%4!==0;)P=P+"=";return P}function ie(P,O){O=O||1/0;let $,Z=P.length,te=null,X=[];for(let ae=0;ae<Z;++ae){if($=P.charCodeAt(ae),$>55295&&$<57344){if(!te){if($>56319){(O-=3)>-1&&X.push(239,191,189);continue}else if(ae+1===Z){(O-=3)>-1&&X.push(239,191,189);continue}te=$;continue}if($<56320){(O-=3)>-1&&X.push(239,191,189),te=$;continue}$=(te-55296<<10|$-56320)+65536}else te&&(O-=3)>-1&&X.push(239,191,189);if(te=null,$<128){if((O-=1)<0)break;X.push($)}else if($<2048){if((O-=2)<0)break;X.push($>>6|192,$&63|128)}else if($<65536){if((O-=3)<0)break;X.push($>>12|224,$>>6&63|128,$&63|128)}else if($<1114112){if((O-=4)<0)break;X.push($>>18|240,$>>12&63|128,$>>6&63|128,$&63|128)}else throw new Error("Invalid code point")}return X}function oe(P){let O=[];for(let $=0;$<P.length;++$)O.push(P.charCodeAt($)&255);return O}function Be(P,O){let $,Z,te,X=[];for(let ae=0;ae<P.length&&!((O-=2)<0);++ae)$=P.charCodeAt(ae),Z=$>>8,te=$%256,X.push(te),X.push(Z);return X}function he(P){return e.toByteArray(Re(P))}function ye(P,O,$,Z){let te;for(te=0;te<Z&&!(te+$>=O.length||te>=P.length);++te)O[te+$]=P[te];return te}function dt(P,O){return P instanceof O||P!=null&&P.constructor!=null&&P.constructor.name!=null&&P.constructor.name===O.name}function Me(P){return P!==P}var ke=function(){let P="0123456789abcdef",O=new Array(256);for(let $=0;$<16;++$){let Z=$*16;for(let te=0;te<16;++te)O[Z+te]=P[$]+P[te]}return O}();function gt(P){return typeof BigInt>"u"?V:P}function V(){throw new Error("BigInt not supported")}}),CFe=v0((t,e)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,e.exports={Buffer:$C().Buffer,Crypto:window.crypto}):e.exports={Buffer:$C().Buffer,Crypto:crypto}}),Bce={};IFe(Bce,{AVSCTap:()=>Xy,ArweaveSigner:()=>f$,DataItem:()=>Zy,MAX_TAG_BYTES:()=>E7,MIN_BINARY_SIZE:()=>l$,SIG_CONFIG:()=>Gm,SignatureConfig:()=>Zf,Signer:()=>Pce,createData:()=>$ce,deserializeTags:()=>v7,indexToType:()=>u$,serializeTags:()=>h$,tagsExceedLimit:()=>Cce});var Pce=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(t,e,i,f){throw new Error("You must implement verify method on child")}},$Fe=y1(s$(),1),Hu=y1(kce(),1);async function Oce(t){if(Array.isArray(t)){let n=(0,Hu.concatBuffers)([(0,Hu.stringToBuffer)("list"),(0,Hu.stringToBuffer)(t.length.toString())]);return await Nce(t,await l0().hash(n,"SHA-384"))}let e=t,i=(0,Hu.concatBuffers)([(0,Hu.stringToBuffer)("blob"),(0,Hu.stringToBuffer)(e.byteLength.toString())]),f=(0,Hu.concatBuffers)([await l0().hash(i,"SHA-384"),await l0().hash(e,"SHA-384")]);return await l0().hash(f,"SHA-384")}async function Nce(t,e){if(t.length<1)return e;let i=(0,Hu.concatBuffers)([e,await Oce(t[0])]),f=await l0().hash(i,"SHA-384");return await Nce(t.slice(1),f)}var cC=y1(OFe(),1),LFe=cC.default.default?cC.default.default:cC.default,DFe=class extends LFe{getPublicKey(t){throw new Error("Unimplemented")}},qFe;function l0(){return qFe??=new DFe}var Zf;(function(t){t[t.ARWEAVE=1]="ARWEAVE",t[t.ED25519=2]="ED25519",t[t.ETHEREUM=3]="ETHEREUM",t[t.SOLANA=4]="SOLANA",t[t.INJECTEDAPTOS=5]="INJECTEDAPTOS",t[t.MULTIAPTOS=6]="MULTIAPTOS",t[t.TYPEDETHEREUM=7]="TYPEDETHEREUM"})(Zf||(Zf={}));var Gm={[Zf.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[Zf.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[Zf.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[Zf.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[Zf.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[Zf.MULTIAPTOS]:{sigLength:64*32+4,pubLength:32*32+1,sigName:"multiAptos"},[Zf.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},f$=class{signatureType=1;ownerLength=Gm[1].pubLength;signatureLength=Gm[1].sigLength;jwk;pk;constructor(t){this.pk=t.n,this.jwk=t}get publicKey(){return $Fe.default.toBuffer(this.pk)}sign(t){return l0().sign(this.jwk,t)}static async verify(t,e,i){return await l0().verify(t,e,i)}},u$={1:f$},el=y1(s$(),1);async function LC(t){return Oce([(0,Hu.stringToBuffer)("dataitem"),(0,Hu.stringToBuffer)("1"),(0,Hu.stringToBuffer)(t.signatureType.toString()),t.rawOwner,t.rawTarget,t.rawAnchor,t.rawTags,t.rawData])}async function UFe(t,e){let i=await LC(t),f=await e.sign(i),n=await l0().hash(f);return{signature:De.from(f),id:De.from(n)}}async function FFe(t,e){let{signature:i,id:f}=await UFe(t,e);return t.getRaw().set(i,2),f}var Xy=class{buf;pos;constructor(t=De.alloc(E7),e=0){this.buf=t,this.pos=e}writeTags(t){if(!Array.isArray(t))throw new Error("input must be array");let e=t.length,i;if(e)for(this.writeLong(e),i=0;i<e;i++){let f=t[i];if(f?.name===void 0||f?.value===void 0)throw new Error(`Invalid tag format for ${f}, expected {name:string, value: string}`);this.writeString(f.name),this.writeString(f.value)}this.writeLong(0)}toBuffer(){let t=De.alloc(this.pos);if(this.pos>this.buf.length)throw new Error(`Too many tag bytes (${this.pos} > ${this.buf.length})`);return this.buf.copy(t,0,0,this.pos),t}tagsExceedLimit(){return this.pos>this.buf.length}writeLong(t){let e=this.buf,i,f;if(t>=-1073741824&&t<1073741824){f=t>=0?t<<1:~t<<1|1;do e[this.pos]=f&127,f>>=7;while(f&&(e[this.pos++]|=128))}else{i=t>=0?t*2:-t*2-1;do e[this.pos]=i&127,i/=128;while(i>=1&&(e[this.pos++]|=128))}this.pos++,this.buf=e}writeString(t){let e=De.byteLength(t),i=this.buf;this.writeLong(e);let f=this.pos;if(this.pos+=e,!(this.pos>i.length)){if(e>64)this.buf.write(t,this.pos-e,e,"utf8");else{let n,l,p,v;for(n=0,l=e;n<l;n++)p=t.charCodeAt(n),p<128?i[f++]=p:p<2048?(i[f++]=p>>6|192,i[f++]=p&63|128):(p&64512)===55296&&((v=t.charCodeAt(n+1))&64512)===56320?(p=65536+((p&1023)<<10)+(v&1023),n++,i[f++]=p>>18|240,i[f++]=p>>12&63|128,i[f++]=p>>6&63|128,i[f++]=p&63|128):(i[f++]=p>>12|224,i[f++]=p>>6&63|128,i[f++]=p&63|128)}this.buf=i}}readLong(){let t=0,e=0,i=this.buf,f,n,l,p;do f=i[this.pos++],n=f&128,t|=(f&127)<<e,e+=7;while(n&&e<28);if(n){l=t,p=268435456;do f=i[this.pos++],l+=(f&127)*p,p*=128;while(f&128);return(l%2?-(l+1):l)/2}return t>>1^-(t&1)}skipLong(){let t=this.buf;for(;t[this.pos++]&128;);}readTags(){let t=[],e;for(;e=this.readLong();)for(e<0&&(e=-e,this.skipLong());e--;){let i=this.readString(),f=this.readString();t.push({name:i,value:f})}return t}readString(){let t=this.readLong(),e=this.pos,i=this.buf;if(this.pos+=t,!(this.pos>i.length))return this.buf.slice(e,e+t).toString()}};function h$(t){let e=new Xy;return e.writeTags(t),e.toBuffer()}function Cce(t){let e=new Xy;return e.writeTags(t),e.tagsExceedLimit()}function v7(t){return new Xy(t).readTags()}function Yc(t){let e=0;for(let i=t.length-1;i>=0;i--)e=e*256+t[i];return e}function jFe(t){if(t>29)throw new Error("Short too long");let e=[0,0];for(let i=0;i<e.length;i++){let f=t&255;e[i]=f,t=(t-f)/256}return Uint8Array.from(e)}function Xle(t){let e=[0,0,0,0,0,0,0,0];for(let i=0;i<e.length;i++){let f=t&255;e[i]=f,t=(t-f)/256}return Uint8Array.from(e)}var zFe=y1(CFe(),1),Im=y1($C(),1),E7=4096,l$=80,Zy=class{binary;_id;constructor(t){this.binary=t}static isDataItem(t){return t.binary!==void 0}get signatureType(){let t=Yc(this.binary.subarray(0,2));if(Zf?.[t]!==void 0)return t;throw new Error("Unknown signature type: "+t)}async isValid(){return Zy.verify(this.binary)}get id(){return(async()=>el.default.encode(await this.rawId))()}set id(t){this._id=el.default.toBuffer(t)}get rawId(){return(async()=>Im.Buffer.from(await zFe.Crypto.subtle.digest("SHA-256",this.rawSignature)))()}set rawId(t){this._id=t}get rawSignature(){return this.binary.subarray(2,2+this.signatureLength)}get signature(){return el.default.encode(this.rawSignature)}set rawOwner(t){if(t.byteLength!=this.ownerLength)throw new Error(`Expected raw owner (pubkey) to be ${this.ownerLength} bytes, got ${t.byteLength} bytes.`);this.binary.set(t,2+this.signatureLength)}get rawOwner(){return this.binary.subarray(2+this.signatureLength,2+this.signatureLength+this.ownerLength)}get signatureLength(){return Gm[this.signatureType].sigLength}get owner(){return el.default.encode(this.rawOwner)}get ownerLength(){return Gm[this.signatureType].pubLength}get rawTarget(){let t=this.getTargetStart();return this.binary[t]==1?this.binary.subarray(t+1,t+33):Im.Buffer.alloc(0)}get target(){return el.default.encode(this.rawTarget)}get rawAnchor(){let t=this.getAnchorStart();return this.binary[t]==1?this.binary.subarray(t+1,t+33):Im.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let t=this.getTagsStart(),e=Yc(this.binary.subarray(t+8,t+16));return this.binary.subarray(t+16,t+16+e)}get tags(){let t=this.getTagsStart();if(Yc(this.binary.subarray(t,t+8))==0)return[];let e=Yc(this.binary.subarray(t+8,t+16));return v7(Im.Buffer.from(this.binary.subarray(t+16,t+16+e)))}get tagsB64Url(){return this.tags.map(t=>({name:el.default.encode(t.name),value:el.default.encode(t.value)}))}getStartOfData(){let t=this.getTagsStart(),e=this.binary.subarray(t+8,t+16),i=Yc(e);return t+16+i}get rawData(){let t=this.getTagsStart(),e=this.binary.subarray(t+8,t+16),i=Yc(e),f=t+16+i;return this.binary.subarray(f,this.binary.length)}get data(){return el.default.encode(this.rawData)}getRaw(){return this.binary}async sign(t){return this._id=await FFe(this,t),this.rawId}async setSignature(t){this.binary.set(t,2),this._id=Im.Buffer.from(await l0().hash(t))}isSigned(){return(this._id?.length??0)>0}toJSON(){return{signature:this.signature,owner:this.owner,target:this.target,tags:this.tags.map(t=>({name:el.default.encode(t.name),value:el.default.encode(t.value)})),data:this.data}}static async verify(t){if(t.byteLength<l$)return!1;let e=new Zy(t),i=e.signatureType,f=e.getTagsStart(),n=Yc(t.subarray(f,f+8)),l=t.subarray(f+8,f+16),p=Yc(l);if(p>E7)return!1;if(n>0)try{if(v7(Im.Buffer.from(t.subarray(f+16,f+16+p))).length!==n)return!1}catch{return!1}let v=u$[i],_=await LC(e);return await v.verify(e.rawOwner,_,e.rawSignature)}async getSignatureData(){return LC(this)}getTagsStart(){let t=this.getTargetStart(),e=this.binary[t]==1,i=t+(e?33:1),f=this.binary[i]==1;return i+=f?33:1,i}getTargetStart(){return 2+this.signatureLength+this.ownerLength}getAnchorStart(){let t=this.getTargetStart()+1,e=this.binary[this.getTargetStart()]==1;return t+=e?32:0,t}},HFe=y1(s$(),1);function $ce(t,e,i){let f=e.publicKey,n=i?.target?HFe.default.toBuffer(i.target):null,l=1+(n?.byteLength??0),p=i?.anchor?De.from(i.anchor):null,v=1+(p?.byteLength??0),_=(i?.tags?.length??0)>0?h$(i.tags):null,g=16+(_?_.byteLength:0),y=De.from(t),M=y.byteLength,x=2+e.signatureLength+e.ownerLength+l+v+g+M,S=De.alloc(x);if(S.set(jFe(e.signatureType),0),S.set(new Uint8Array(e.signatureLength).fill(0),2),f.byteLength!==e.ownerLength)throw new Error(`Owner must be ${e.ownerLength} bytes, but was incorrectly ${f.byteLength}`);S.set(f,2+e.signatureLength);let R=2+e.signatureLength+e.ownerLength;if(S[R]=n?1:0,n){if(n.byteLength!==32)throw new Error(`Target must be 32 bytes but was incorrectly ${n.byteLength}`);S.set(n,R+1)}let T=R+l,k=T+1;if(S[T]=p?1:0,p){if(k+=p.byteLength,p.byteLength!==32)throw new Error("Anchor must be 32 bytes");S.set(p,T+1)}S.set(Xle(i?.tags?.length??0),k);let B=Xle(_?.byteLength??0);S.set(B,k+8),_&&S.set(_,k+16);let C=k+g;return S.set(y,C),new Zy(S)}var c$={...Bce};globalThis.arbundles??=c$;var WFe=c$,KFe=c$;globalThis.Buffer||(globalThis.Buffer=Rce.Buffer);var{DataItem:ZFe}=Tce;function VFe(t){return async({data:i,tags:f,target:n,anchor:l,createDataItem:p=v=>new ZFe(v)})=>{let v=await t.signDataItem({data:i,tags:f,target:n,anchor:l}),_=p(Rce.Buffer.from(v));return{id:await _.id,raw:await _.getRaw()}}}var GFe=globalThis.GATEWAY_URL||void 0,YFe=globalThis.MU_URL||void 0,JFe=globalThis.CU_URL||void 0,XFe=globalThis.GRAPHQL_URL||void 0,{result:Nwt,results:Cwt,message:$wt,spawn:Lwt,monitor:Dwt,unmonitor:qwt,dryrun:Uwt,assign:Fwt}=Ls({GATEWAY_URL:GFe,MU_URL:YFe,CU_URL:JFe,GRAPHQL_URL:XFe}),Lce=Ace.createDataItemSigner;de();ve();pe();var kde=Hi(Ide(),1),N7=kde.default.init({host:"arweave.net",port:443,protocol:"https"});de();ve();pe();de();ve();pe();var Ju=class extends Error{constructor(e){super(e),this.name=this.constructor.name}},Bde=class extends Ju{},Pde=class extends Ju{},Ode=class extends Ju{constructor(e,i){super(`Failed request: ${e}: ${i}`)}},Nde=class extends Ju{},C7=class extends Ju{},Cde=class extends Ju{constructor(){super("Invalid signer. Please provide a valid signer to interact with the contract.")}},fl=class extends Ju{constructor(){super("Invalid contract configuration")}},$de=class extends Ju{constructor(){super("Invalid process configuration")}},Lde=class extends Ju{};de();ve();pe();var ah=Hi(Wbe(),1);de();ve();pe();var z_="3.10.0";var pl=class t{logger;silent=!1;static default=new t;constructor({level:e="info"}={}){e==="none"&&(this.silent=!0),typeof window<"u"?this.logger=console:this.logger=(0,ah.createLogger)({level:e,silent:this.silent,defaultMeta:{name:"ar-io-sdk",version:z_},format:ah.format.combine(ah.format.timestamp(),ah.format.json()),transports:[new ah.transports.Console({format:ah.format.combine(ah.format.timestamp(),ah.format.json())})]})}info(e,...i){this.silent||this.logger.info(e,...i)}warn(e,...i){this.silent||this.logger.warn(e,...i)}error(e,...i){this.silent||this.logger.error(e,...i)}debug(e,...i){this.silent||this.logger.debug(e,...i)}setLogLevel(e){this.silent=e==="none","silent"in this.logger&&(this.logger.silent=e==="none"),"level"in this.logger&&(this.logger.level=e)}};de();ve();pe();de();ve();pe();var Kbe=t=>{let e=Object.entries(t).sort(([i,f],[n,l])=>i==="@"?-1:n==="@"?1:"priority"in f&&!("priority"in l)?-1:!("priority"in f)&&"priority"in l?1:f.priority!==void 0&&l.priority!==void 0?f.priority===l.priority?i<n?-1:i>n?1:0:f.priority-l.priority:i<n?-1:i>n?1:0);return Object.fromEntries(e.map(([i,f],n)=>[i,{...f,index:n}]))};de();ve();pe();function cd(t,e){let i=t.safeParse(e);if(!i.success)throw new Error(JSON.stringify(i.error.format(),null,2));return i}de();ve();pe();de();ve();pe();de();ve();pe();kh();var Zbe="+",Vbe="/",Gbe="-",Ybe="_",Jbe="=";function nit(t){let e=t.length%4;return e&&(t+=Jbe.repeat(4-e)),t.replaceAll(Gbe,Zbe).replaceAll(Ybe,Vbe)}function ait(t){return t.replaceAll(Zbe,Gbe).replaceAll(Vbe,Ybe).replaceAll(Jbe,"")}function pTt(t){let e=nit(t);return De.from(e,"base64")}function oit(t){let e=t.toString("base64");return ait(e)}function vTt(t){return oit(Au("sha256").update(Uint8Array.from(t)).digest())}function Xbe(t=32){let e=Lk(t);return Array.from(e,i=>i.toString(16).padStart(2,"0")).join("").slice(0,t)}de();ve();pe();de();ve();pe();function wq(t){try{return JSON.parse(t)}catch{return t}}de();ve();pe();de();ve();pe();var Mq=Hi(eye(),1);de();ve();pe();var uit=Object.defineProperty,hit=(t,e,i)=>e in t?uit(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,K6=(t,e,i)=>(hit(t,typeof e!="symbol"?e+"":e,i),i),xq=class{constructor(e){K6(this,"value"),K6(this,"next"),this.value=e}},Sq=class{constructor(){K6(this,"head"),K6(this,"tail"),K6(this,"_size",0),this.clear()}clear(){this.head=void 0,this.tail=void 0,this._size=0}push(e){let i=new xq(e);return this.head&&this.tail?(this.tail.next=i,this.tail=i):(this.head=i,this.tail=i),this._size++,this._size}pop(){if(!this.head)return;let e=this.head;return this.head=this.head.next,this._size--,e.value}get size(){return this._size}*[Symbol.iterator](){let e=this.head;for(;e;)yield e.value,e=e.next}};function tye(t){if(!((Number.isInteger(t)||t===1/0)&&t>0))throw new TypeError("Expected `concurrency` to be a number greater than 1");let e=new Sq,i=0,f=()=>{i--,e.size>0&&e.pop()()},n=async(v,_,g)=>{i++;let y=(async()=>v(...g))();_(y);try{await y}catch{}f()},l=(v,_,g)=>{e.push(n.bind(null,v,_,g)),(async()=>(await Promise.resolve(),i<t&&e.size>0&&e.pop()()))()},p=(v,..._)=>new Promise(g=>{l(v,g,_)});return Object.defineProperties(p,{activeCount:{get:()=>i},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),p}de();ve();pe();var Z6=class{static init(e){return e!==void 0&&"signer"in e?new Eq(e):new W_(e)}},W_=class{process;constructor(e){if(e===void 0||Object.keys(e).length===0)this.process=new ia({processId:Rm});else if(pd(e))this.process=e.process;else if(vd(e))this.process=new ia({processId:e.processId});else throw new fl}async accessControlList({address:e}){return this.process.read({tags:[{name:"Action",value:"Access-Control-List"},{name:"Address",value:e}]})}},Eq=class extends W_{signer;constructor({signer:e,...i}){super(i),this.signer=dd(e)}async register({processId:e}){return this.process.send({tags:[{name:"Action",value:"Register"},{name:"Process-Id",value:e}],signer:this.signer})}};de();ve();pe();de();ve();pe();var lit="https://faucet.ario.permaweb.services";function Rq({arioInstance:t,faucetApiUrl:e=lit}){let i=new Aq({faucetUrl:e,processId:t.process.processId});return new Proxy(t,{get(n,l){if(l==="faucet")return i;if(l in n){let p=n[l];return typeof p=="function"?p.bind(n):p}}})}var Aq=class{faucetUrl;processId;constructor({faucetUrl:e,processId:i}){this.faucetUrl=e,this.processId=i}async captchaUrl(){let e=await fetch(`${this.faucetUrl}/api/captcha/url?process-id=${this.processId}`,{method:"GET"});if(!e.ok){let f=await e.json().catch(()=>({error:e.statusText}));throw new Error(f.error)}return await e.json()}async claimWithCaptchaResponse({captchaResponse:e,recipient:i,quantity:f}){let n=await fetch(`${this.faucetUrl}/api/claim/sync`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processId:this.processId,recipient:i,quantity:f,captchaResponse:e})});if(!n.ok){let p=await n.json().catch(()=>({error:n.statusText}));throw new Error(p.error)}return await n.json()}async requestAuthToken({captchaResponse:e}){let i=await fetch(`${this.faucetUrl}/api/captcha/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processId:this.processId,captchaResponse:e})});if(!i.ok){let n=await i.json().catch(()=>({error:i.statusText}));throw new Error(n.error)}return await i.json()}async claimWithAuthToken({authToken:e,recipient:i,quantity:f}){let n=await fetch(`${this.faucetUrl}/api/claim/async`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({recipient:i,qty:f,processId:this.processId})});if(!n.ok){let p=await n.json().catch(()=>({error:n.statusText}));throw new Error(p.error)}return await n.json()}async verifyAuthToken({authToken:e}){let i=await fetch(`${this.faucetUrl}/api/token/verify?process-id=${this.processId}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}});if(!i.ok){let n=await i.json().catch(()=>({error:i.statusText}));throw new Error(n.error)}return await i.json()}};var G6=class{static init(e){return e!==void 0&&"signer"in e?new V6(e):new wg(e)}static mainnet(e){return e!==void 0&&"signer"in e?new V6({...e,process:new ia({processId:ns,ao:Ls({CU_URL:"https://cu.ardrive.io",...e?.process?.ao})})}):new wg({...e,process:new ia({processId:ns,ao:Ls({CU_URL:"https://cu.ardrive.io",...e?.process?.ao})})})}static testnet(e){return e!==void 0&&"signer"in e?Rq({arioInstance:new V6({...e,process:new ia({processId:JN,ao:Ls({CU_URL:"https://cu.ardrive.io",...e?.process?.ao})})}),faucetApiUrl:e?.faucetUrl}):Rq({arioInstance:new wg({...e,process:new ia({processId:JN,ao:Ls({CU_URL:"https://cu.ardrive.io",...e?.process?.ao})})}),faucetApiUrl:e?.faucetUrl})}},wg=class{process;epochSettings;arweave;constructor(e){if(this.arweave=e?.arweave??N7,e===void 0||Object.keys(e).length===0)this.process=new ia({processId:ns});else if(pd(e))this.process=e.process;else if(vd(e))this.process=new ia({processId:e.processId});else throw new fl}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(e){let i=await this.getEpochSettings(),f=i.epochZeroStartTimestamp,n=i.durationMs;return Math.floor((e-f)/n)}async computeCurrentEpochIndex(){return this.computeEpochIndexForTimestamp(Date.now())}async computeEpochIndex(e){let i=e?.epochIndex;if(i!==void 0)return i;let f=e?.timestamp;if(f!==void 0)return this.computeEpochIndexForTimestamp(f)}async getEpochSettings(){return this.epochSettings??=await this.process.read({tags:[{name:"Action",value:"Epoch-Settings"}]})}async getEpoch(e){let i=await this.computeEpochIndex(e),f=await this.computeCurrentEpochIndex();if(i!==void 0&&i<f){let l=await D1({arweave:this.arweave,epochIndex:i,processId:this.process.processId,ao:this.process.ao});if(!l)throw new Error("Epoch data not found for epoch index "+i);return iye(l)}let n=[{name:"Action",value:"Epoch"},{name:"Epoch-Index",value:f.toString()}];return this.process.read({tags:Ln(n)})}async getArNSRecord({name:e}){return this.process.read({tags:[{name:"Action",value:"Record"},{name:"Name",value:e}]})}async getArNSRecords(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Records"},...To(e)]})}async getArNSReservedNames(e){return this.process.read({tags:[{name:"Action",value:"Reserved-Names"},...To(e)]})}async getArNSReservedName({name:e}){return this.process.read({tags:[{name:"Action",value:"Reserved-Name"},{name:"Name",value:e}]})}async getBalance({address:e}){return this.process.read({tags:[{name:"Action",value:"Balance"},{name:"Address",value:e}]})}async getBalances(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Balances"},...To(e)]})}async getVault({address:e,vaultId:i}){return this.process.read({tags:[{name:"Action",value:"Vault"},{name:"Address",value:e},{name:"Vault-Id",value:i}]})}async getVaults(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Vaults"},...To(e)]})}async getGateway({address:e}){return this.process.read({tags:[{name:"Action",value:"Gateway"},{name:"Address",value:e}]})}async getGatewayDelegates({address:e,...i}){return this.process.read({tags:[{name:"Action",value:"Paginated-Delegates"},{name:"Address",value:e},...To(i)]})}async getGatewayDelegateAllowList({address:e,...i}){return this.process.read({tags:[{name:"Action",value:"Paginated-Allowed-Delegates"},{name:"Address",value:e},...To(i)]})}async getGateways(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateways"},...To(e)]})}async getCurrentEpoch(){return this.process.read({tags:[{name:"Action",value:"Epoch"}]})}async getPrescribedObservers(e){let i=await this.computeEpochIndex(e),f=await this.computeCurrentEpochIndex();if(i!==void 0&&i<f){let l=await D1({ao:this.process.ao,arweave:this.arweave,epochIndex:i,processId:this.process.processId});if(!l)throw new Error("Epoch data not found for epoch index "+i);return l.prescribedObservers}let n=[{name:"Action",value:"Epoch-Prescribed-Observers"},{name:"Epoch-Index",value:f.toString()}];return this.process.read({tags:Ln(n)})}async getPrescribedNames(e){let i=await this.computeEpochIndex(e),f=await this.computeCurrentEpochIndex();if(i!==void 0&&i<f){let l=await D1({arweave:this.arweave,epochIndex:i,processId:this.process.processId,ao:this.process.ao});if(!l)throw new Error("Epoch data not found for epoch index "+i);return l.prescribedNames}let n=[{name:"Action",value:"Epoch-Prescribed-Names"},{name:"Epoch-Index",value:f.toString()}];return this.process.read({tags:Ln(n)})}async getObservations(e){let i=await this.computeEpochIndex(e),f=await this.computeCurrentEpochIndex();if(i!==void 0&&i<f){let l=await D1({arweave:this.arweave,epochIndex:i,processId:this.process.processId,ao:this.process.ao});if(!l)throw new Error("Epoch data not found for epoch index "+i);return l.observations}let n=[{name:"Action",value:"Epoch-Observations"},{name:"Epoch-Index",value:f.toString()}];return this.process.read({tags:Ln(n)})}async getDistributions(e){let i=await this.computeEpochIndex(e),f=await this.computeCurrentEpochIndex();if(i!==void 0&&i<f){let l=await D1({arweave:this.arweave,epochIndex:i,processId:this.process.processId,ao:this.process.ao});if(l===void 0)throw new Error("Epoch data not found for epoch index "+i);return l.distributions}let n=[{name:"Action",value:"Epoch-Distributions"},{name:"Epoch-Index",value:f.toString()}];return this.process.read({tags:Ln(n)})}async getEligibleEpochRewards(e,i){let f=await this.computeEpochIndex(e),n=await this.computeCurrentEpochIndex();if(f!==void 0&&f<n){let p=await D1({arweave:this.arweave,epochIndex:f,processId:this.process.processId,ao:this.process.ao});if(!p)throw new Error("Epoch data not found for epoch index "+f);return rye(p,i)}let l=[{name:"Action",value:"Epoch-Eligible-Rewards"},...To(i)];return this.process.read({tags:Ln(l)})}async getTokenCost({intent:e,type:i,years:f,name:n,quantity:l,fromAddress:p}){let _=[{name:"Action",value:"Token-Cost"},{name:"Intent",value:e==="Buy-Record"?"Buy-Name":e},{name:"Name",value:n},{name:"Years",value:f?.toString()},{name:"Quantity",value:l?.toString()},{name:"Purchase-Type",value:i}];return this.process.read({tags:Ln(_),fromAddress:p})}async getCostDetails({intent:e,type:i,years:f,name:n,quantity:l,fromAddress:p,fundFrom:v}){let g=[{name:"Action",value:"Cost-Details"},{name:"Intent",value:e==="Buy-Record"?"Buy-Name":e},{name:"Name",value:n},{name:"Years",value:f?.toString()},{name:"Quantity",value:l?.toString()},{name:"Purchase-Type",value:i},{name:"Fund-From",value:v}];return this.process.read({tags:Ln(g),fromAddress:p})}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(e){return this.process.read({tags:[{name:"Action",value:"Returned-Names"},...To(e)]})}async getArNSReturnedName({name:e}){let i=[{name:"Action",value:"Returned-Name"},{name:"Name",value:e}];return this.process.read({tags:i})}async getDelegations(e){let i=[{name:"Action",value:"Paginated-Delegations"},{name:"Address",value:e.address},...To(e)];return this.process.read({tags:Ln(i)})}async getAllowedDelegates(e){return this.getGatewayDelegateAllowList(e)}async getGatewayVaults(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateway-Vaults"},{name:"Address",value:e.address},...To(e)]})}async getPrimaryNameRequest(e){let i=[{name:"Action",value:"Primary-Name-Request"},{name:"Initiator",value:e.initiator}];return this.process.read({tags:i})}async getPrimaryNameRequests(e){return this.process.read({tags:[{name:"Action",value:"Primary-Name-Requests"},...To(e)]})}async getPrimaryName(e){let i=[{name:"Action",value:"Primary-Name"},{name:"Address",value:e?.address},{name:"Name",value:e?.name}];return this.process.read({tags:Ln(i)})}async getPrimaryNames(e){return this.process.read({tags:[{name:"Action",value:"Primary-Names"},...To(e)]})}async getRedelegationFee(e){return this.process.read({tags:[{name:"Action",value:"Redelegation-Fee"},{name:"Address",value:e.address}]})}async getGatewayRegistrySettings(){return this.process.read({tags:[{name:"Action",value:"Gateway-Registry-Settings"}]})}async getAllDelegates(e){return this.process.read({tags:[{name:"Action",value:"All-Paginated-Delegates"},...To(e)]})}async getAllGatewayVaults(e){return this.process.read({tags:[{name:"Action",value:"All-Gateway-Vaults"},...To(e)]})}},V6=class extends wg{signer;constructor({signer:e,...i}){i===void 0?super({process:new ia({processId:ns})}):super(i),this.signer=dd(e)}async transfer({target:e,qty:i},f){let{tags:n=[]}=f||{};return this.process.send({tags:[...n,{name:"Action",value:"Transfer"},{name:"Recipient",value:e},{name:"Quantity",value:i.valueOf().toString()}],signer:this.signer})}async vaultedTransfer({recipient:e,quantity:i,lockLengthMs:f,revokable:n=!1},l){let{tags:p=[]}=l||{};return this.process.send({tags:[...p,{name:"Action",value:"Vaulted-Transfer"},{name:"Recipient",value:e},{name:"Quantity",value:i.toString()},{name:"Lock-Length",value:f.toString()},{name:"Revokable",value:`${n}`}],signer:this.signer})}async revokeVault({vaultId:e,recipient:i},f){let{tags:n=[]}=f||{};return this.process.send({tags:[...n,{name:"Action",value:"Revoke-Vault"},{name:"Vault-Id",value:e},{name:"Recipient",value:i}],signer:this.signer})}async createVault({lockLengthMs:e,quantity:i},f){let{tags:n=[]}=f||{};return this.process.send({tags:[...n,{name:"Action",value:"Create-Vault"},{name:"Lock-Length",value:e.toString()},{name:"Quantity",value:i.toString()}],signer:this.signer})}async extendVault({vaultId:e,extendLengthMs:i},f){let{tags:n=[]}=f||{};return this.process.send({tags:[...n,{name:"Action",value:"Extend-Vault"},{name:"Vault-Id",value:e},{name:"Extend-Length",value:i.toString()}],signer:this.signer})}async increaseVault({vaultId:e,quantity:i},f){let{tags:n=[]}=f||{};return this.process.send({tags:[...n,{name:"Action",value:"Increase-Vault"},{name:"Vault-Id",value:e},{name:"Quantity",value:i.toString()}],signer:this.signer})}async joinNetwork({operatorStake:e,allowDelegatedStaking:i,allowedDelegates:f,delegateRewardShareRatio:n,fqdn:l,label:p,minDelegatedStake:v,note:_,port:g,properties:y,protocol:M,autoStake:x,observerAddress:S},R){let{tags:T=[]}=R||{},k=[...T,{name:"Action",value:"Join-Network"},{name:"Operator-Stake",value:e.valueOf().toString()},{name:"Allow-Delegated-Staking",value:i?.toString()},{name:"Allowed-Delegates",value:f?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:n?.toString()},{name:"FQDN",value:l},{name:"Label",value:p},{name:"Min-Delegated-Stake",value:v?.valueOf().toString()},{name:"Note",value:_},{name:"Port",value:g?.toString()},{name:"Properties",value:y},{name:"Protocol",value:M},{name:"Auto-Stake",value:x?.toString()},{name:"Observer-Address",value:S}];return this.process.send({signer:this.signer,tags:Ln(k)})}async leaveNetwork(e){let{tags:i=[]}=e||{};return this.process.send({signer:this.signer,tags:[...i,{name:"Action",value:"Leave-Network"}]})}async updateGatewaySettings({allowDelegatedStaking:e,allowedDelegates:i,delegateRewardShareRatio:f,fqdn:n,label:l,minDelegatedStake:p,note:v,port:_,properties:g,protocol:y,autoStake:M,observerAddress:x},S){let{tags:R=[]}=S||{},T=[...R,{name:"Action",value:"Update-Gateway-Settings"},{name:"Label",value:l},{name:"Note",value:v},{name:"FQDN",value:n},{name:"Port",value:_?.toString()},{name:"Properties",value:g},{name:"Protocol",value:y},{name:"Observer-Address",value:x},{name:"Allow-Delegated-Staking",value:e?.toString()},{name:"Allowed-Delegates",value:i?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:f?.toString()},{name:"Min-Delegated-Stake",value:p?.valueOf().toString()},{name:"Auto-Stake",value:M?.toString()}];return this.process.send({signer:this.signer,tags:Ln(T)})}async delegateStake(e,i){let{tags:f=[]}=i||{};return this.process.send({signer:this.signer,tags:[...f,{name:"Action",value:"Delegate-Stake"},{name:"Target",value:e.target},{name:"Quantity",value:e.stakeQty.valueOf().toString()}]})}async decreaseDelegateStake(e,i){let{tags:f=[]}=i||{};return this.process.send({signer:this.signer,tags:[...f,{name:"Action",value:"Decrease-Delegate-Stake"},{name:"Target",value:e.target},{name:"Quantity",value:e.decreaseQty.valueOf().toString()},{name:"Instant",value:`${e.instant||!1}`}]})}async instantWithdrawal(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Instant-Withdrawal"},{name:"Vault-Id",value:e.vaultId},{name:"Address",value:e.gatewayAddress}];return this.process.send({signer:this.signer,tags:Ln(n)})}async increaseOperatorStake(e,i){let{tags:f=[]}=i||{};return this.process.send({signer:this.signer,tags:[...f,{name:"Action",value:"Increase-Operator-Stake"},{name:"Quantity",value:e.increaseQty.valueOf().toString()}]})}async decreaseOperatorStake(e,i){let{tags:f=[]}=i||{};return this.process.send({signer:this.signer,tags:[...f,{name:"Action",value:"Decrease-Operator-Stake"},{name:"Quantity",value:e.decreaseQty.valueOf().toString()},{name:"Instant",value:`${e.instant||!1}`}]})}async saveObservations(e,i){let{tags:f=[]}=i||{};return this.process.send({signer:this.signer,tags:[...f,{name:"Action",value:"Save-Observations"},{name:"Report-Tx-Id",value:e.reportTxId},{name:"Failed-Gateways",value:e.failedGateways.join(",")}]})}async buyRecord(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Buy-Name"},{name:"Name",value:e.name},{name:"Years",value:e.years?.toString()??"1"},{name:"Process-Id",value:e.processId},{name:"Purchase-Type",value:e.type||"lease"},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Ln(n)})}async upgradeRecord(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Upgrade-Name"},{name:"Name",value:e.name},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Ln(n)})}async extendLease(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Extend-Lease"},{name:"Name",value:e.name},{name:"Years",value:e.years.toString()},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Ln(n)})}async increaseUndernameLimit(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Increase-Undername-Limit"},{name:"Name",value:e.name},{name:"Quantity",value:e.increaseCount.toString()},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Ln(n)})}async cancelWithdrawal(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Cancel-Withdrawal"},{name:"Vault-Id",value:e.vaultId},{name:"Address",value:e.gatewayAddress}];return this.process.send({signer:this.signer,tags:Ln(n)})}async requestPrimaryName(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Request-Primary-Name"},{name:"Name",value:e.name},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Ln(n)})}async redelegateStake(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Redelegate-Stake"},{name:"Target",value:e.target},{name:"Source",value:e.source},{name:"Quantity",value:e.stakeQty.valueOf().toString()},{name:"Vault-Id",value:e.vaultId}];return this.process.send({signer:this.signer,tags:Ln(n)})}};var Tkt=async({address:t,registry:e=Z6.init()})=>{let i=await e.accessControlList({address:t});return[...new Set([...i.Owned,...i.Controlled])]};function nye(t,e){return new Promise((i,f)=>{let n=setTimeout(()=>{f(new Error("Timeout"))},t);e.then(l=>{clearTimeout(n),i(l)}).catch(l=>{clearTimeout(n),f(l)})})}var aye=class extends Mq.default{contract;timeoutMs;throttle;logger;strict;antAoClient;constructor({contract:e=G6.init({processId:ns}),timeoutMs:i=6e4,concurrency:f=30,logger:n=pl.default,strict:l=!1,antAoClient:p=Ls()}={}){super(),this.contract=e,this.timeoutMs=i,this.throttle=tye(f),this.logger=n,this.strict=l,this.antAoClient=p}async fetchProcessesOwnedByWallet({address:e,pageSize:i,antRegistry:f=Z6.init()}){let n={},l=await f.accessControlList({address:e}),p=new Set([...l.Owned,...l.Controlled]);await nye(this.timeoutMs,cit({contract:this.contract,emitter:this,pageSize:i})).catch(_=>(this.emit("error",`Error getting ArNS records: ${_}`),this.logger.error("Error getting ArNS records",{message:_?.message,stack:_?.stack}),{})).then(_=>{Object.entries(_).forEach(([g,y])=>{p.has(y.processId)&&(n[y.processId]==null&&(n[y.processId]={state:void 0,names:{}}),n[y.processId].names[g]=y)})});let v=Object.keys(n).length;this.emit("progress",0,v),await Promise.all(Object.keys(n).map(async(_,g)=>this.throttle(async()=>{if(n[_].state!==void 0){this.emit("progress",g+1,v);return}let y=K_.init({process:new ia({processId:_,ao:this.antAoClient}),strict:this.strict}),M=await nye(this.timeoutMs,y.getState()).catch(x=>{this.emit("error",`Error getting state for process ${_}: ${x}`)});(M?.Owner===e||M?.Controllers.includes(e))&&(n[_].state=M,this.emit("process",_,n[_])),this.emit("progress",g+1,v)}))),this.emit("end",n)}},cit=async({contract:t=G6.init({processId:ns}),emitter:e,logger:i=pl.default,pageSize:f=1e3})=>{let n,l=Date.now(),p={};do{let v=await t.getArNSRecords({cursor:n,limit:f}).catch(_=>{i?.error("Error getting ArNS records",{message:_?.message,stack:_?.stack}),e?.emit("arns:error",`Error getting ArNS records: ${_}`)});if(!v)return{};v.items.forEach(_=>{let{name:g,...y}=_;p[g]=y}),i.debug("Fetched page of ArNS records",{totalRecordCount:v.totalItems,fetchedRecordCount:Object.keys(p).length,cursor:v.nextCursor}),e?.emit("arns:pageLoaded",{totalRecordCount:v.totalItems,fetchedRecordCount:Object.keys(p).length,records:v.items,cursor:v.nextCursor}),n=v.nextCursor}while(n!==void 0);return e?.emit("arns:end",p),i.debug("Fetched all ArNS records",{totalRecordCount:Object.keys(p).length,durationMs:Date.now()-l}),p};var ia=class{logger;ao;processId;constructor({processId:e,ao:i=Ls(),logger:f=pl.default}){this.processId=e,this.logger=f,this.ao=i}isMessageDataEmpty(e){return e===void 0||e==="null"||e===""||e===null}async read({tags:e,retries:i=3,fromAddress:f}){this.logger.debug("Evaluating read interaction on process",{tags:e,processId:this.processId});let n={process:this.processId,tags:e};f!==void 0&&(n.Owner=f);let l=0,p;for(;l<i;)try{p=await this.ao.dryrun(n);break}catch(y){if(l++,this.logger.debug(`Read attempt ${l} failed`,{error:y?.message,stack:y?.stack,tags:e,processId:this.processId}),l>=i)throw this.logger.debug("Maximum read attempts exceeded",{error:y?.message,stack:y?.stack,tags:e,processId:this.processId,ao:JSON.stringify(this.ao)}),new Error(`Failed to evaluate a dry-run on process ${this.processId}.`);await new Promise(M=>setTimeout(M,2**l*1e3))}if(p===void 0)throw new Error("Unexpected error when evaluating read interaction");this.logger.debug("Read interaction result",{result:p,processId:this.processId});let v=Tq(p);if(v!==void 0)throw new Error(v);if(p.Messages===void 0||p.Messages.length===0)throw this.logger.debug(`Empty result - process ${this.processId} does not support provided action.`,{result:p,tags:e,processId:this.processId}),new Error(`Process ${this.processId} does not support provided action.`);let _=p.Messages?.[0]?.Data;return this.isMessageDataEmpty(_)?void 0:wq(_)}async send({tags:e,data:i,signer:f,retries:n=3}){let l,p=Xbe(32);try{this.logger.debug("Evaluating send interaction on contract",{tags:e,data:i,processId:this.processId}),l=await this.ao.message({process:this.processId,tags:[...e,{name:"AR-IO-SDK",value:z_}],data:i,signer:f,anchor:p}),this.logger.debug("Sent message to process",{messageId:l,processId:this.processId,anchor:p})}catch(M){throw this.logger.debug("Error sending message to process",{error:M?.message,stack:M?.stack,processId:this.processId,tags:e}),M}if(l===void 0)throw new Error("Failed to send message to process.");let v,_=0;for(;_<n;)try{v=await this.ao.result({message:l,process:this.processId}),this.logger.debug("Message result",{result:v,messageId:l,processId:this.processId});break}catch(M){if(_++,this.logger.debug("Retrying send interaction",{attempts:_,retries:n,error:M?.message,processId:this.processId}),_>=n)return this.logger.debug(`Message was sent to process ${this.processId} with id ${l} but result was not returned. Review transactions for more details.`,{error:M?.message,stack:M?.stack,tags:e,processId:this.processId,messageId:l}),{id:l};await new Promise(x=>setTimeout(x,2**_*2e3))}if(v===void 0)return this.logger.debug(`Message was sent to process ${this.processId} with id ${l} but the result was not returned. Review transactions for more details.`,{tags:e,processId:this.processId,messageId:l}),{id:l};let g=Tq(v);if(g!==void 0)throw new C7(g);if(v.Messages?.length===0||v.Messages===void 0)return{id:l};if(this.isMessageDataEmpty(v.Messages[0].Data))return{id:l};let y=wq(v.Messages[0].Data);return this.logger.debug("Message result data",{resultData:y,messageId:l,processId:this.processId}),{id:l,result:y}}};var Z_=class{static init(e){return e!==void 0&&"signer"in e?new Iq(e):new V_(e)}},V_=class{process;constructor(e){if(e===void 0||Object.keys(e).length===0)this.process=new ia({processId:Rm});else if(pd(e))this.process=e.process;else if(vd(e))this.process=new ia({processId:e.processId});else throw new fl}async getANTVersions(){let e=await this.process.read({tags:[{name:"Action",value:"Get-Versions"}]});return Object.fromEntries(Object.entries(e).sort(([i],[f])=>i.localeCompare(f)))}async getLatestANTVersion(){let e=await this.getANTVersions(),i=Object.entries(e).at(-1);if(!i)throw new Error("No version found");return{version:i[0],...i[1]}}},Iq=class extends V_{signer;constructor({signer:e,...i}){super(i),this.signer=dd(e)}async addVersion(e,{tags:i}){return this.process.send({tags:Ln([{name:"Action",value:"Add-Version"},{name:"Version",value:e.version},{name:"Module-Id",value:e.moduleId},{name:"Lua-Source-Id",value:e.luaSourceId},{name:"Notes",value:e.notes},...i??[]]),signer:this.signer})}};var K_=class{static versions=Z_.init();static init(e){return e!==void 0&&"signer"in e?new kq(e):new G_(e)}},G_=class{process;processId;strict;constructor(e){if(this.strict=e.strict||!1,pd(e))this.process=e.process;else if(vd(e))this.process=new ia({processId:e.processId});else throw new fl;this.processId=this.process.processId}async getState({strict:e}={strict:this.strict}){let i=[{name:"Action",value:"State"}],f=await this.process.read({tags:i});return e&&cd(iC.passthrough().and(vr.object({Records:vr.record(vr.string(),q5.passthrough())})),f),f}async getInfo({strict:e}={strict:this.strict}){let i=[{name:"Action",value:"Info"}],f=await this.process.read({tags:i});return e&&cd(Rle.passthrough(),f),f}async getLogo(){return(await this.getInfo()).Logo}async getRecord({undername:e},{strict:i}={strict:this.strict}){let f=[{name:"Sub-Domain",value:e},{name:"Action",value:"Record"}],n=await this.process.read({tags:f});return i&&cd(q5.passthrough(),n),n}async getRecords({strict:e}={strict:this.strict}){let i=[{name:"Action",value:"Records"}],f=await this.process.read({tags:i});return e&&cd(eC,f),Kbe(f)}async getOwner({strict:e}={strict:this.strict}){return(await this.getInfo({strict:e})).Owner}async getControllers({strict:e}={strict:this.strict}){let i=[{name:"Action",value:"Controllers"}],f=await this.process.read({tags:i});return e&&cd(tC,f),f}async getName({strict:e}={strict:this.strict}){return(await this.getInfo({strict:e})).Name}async getTicker({strict:e}={strict:this.strict}){return(await this.getInfo({strict:e})).Ticker}async getBalances({strict:e}={strict:this.strict}){let i=[{name:"Action",value:"Balances"}],f=await this.process.read({tags:i});return e&&cd(rC,f),f}async getBalance({address:e},{strict:i}={strict:this.strict}){let f=[{name:"Action",value:"Balance"},{name:"Recipient",value:e}],n=await this.process.read({tags:f});return i&&cd(vr.number(),n),n}async getHandlers(){let e=await this.getInfo();return e.Handlers??e.HandlerNames}},kq=class extends G_{signer;constructor({signer:e,...i}){super(i),this.signer=dd(e)}async transfer({target:e},i){let f=[...i?.tags??[],{name:"Action",value:"Transfer"},{name:"Recipient",value:e}];return this.process.send({tags:f,signer:this.signer})}async addController({controller:e},i){let f=[...i?.tags??[],{name:"Action",value:"Add-Controller"},{name:"Controller",value:e}];return this.process.send({tags:f,signer:this.signer})}async removeController({controller:e},i){let f=[...i?.tags??[],{name:"Action",value:"Remove-Controller"},{name:"Controller",value:e}];return this.process.send({tags:f,signer:this.signer})}async setRecord({undername:e,transactionId:i,ttlSeconds:f},n){return this.process.send({tags:[...n?.tags??[],{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:e},{name:"Transaction-Id",value:i},{name:"TTL-Seconds",value:f.toString()}],signer:this.signer})}async setBaseNameRecord({transactionId:e,ttlSeconds:i},f){return this.setRecord({transactionId:e,ttlSeconds:i,undername:"@"},f)}async setUndernameRecord({undername:e,transactionId:i,ttlSeconds:f},n){return this.setRecord({undername:e,transactionId:i,ttlSeconds:f},n)}async removeUndernameRecord({undername:e}){return this.removeRecord({undername:e})}async removeRecord({undername:e},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Remove-Record"},{name:"Sub-Domain",value:e}],signer:this.signer})}async setTicker({ticker:e},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Ticker"},{name:"Ticker",value:e}],signer:this.signer})}async setName({name:e},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Name"},{name:"Name",value:e}],signer:this.signer})}async setDescription({description:e},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Description"},{name:"Description",value:e}],signer:this.signer})}async setKeywords({keywords:e},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Keywords"},{name:"Keywords",value:JSON.stringify(e)}],signer:this.signer})}async setLogo({txId:e},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Logo"},{name:"Logo",value:e}],signer:this.signer})}async releaseName({name:e,arioProcessId:i},f){return this.process.send({tags:[...f?.tags??[],{name:"Action",value:"Release-Name"},{name:"Name",value:e},{name:"IO-Process-Id",value:i},{name:"ARIO-Process-Id",value:i}],signer:this.signer})}async reassignName({name:e,arioProcessId:i,antProcessId:f},n){return this.process.send({tags:[...n?.tags??[],{name:"Action",value:"Reassign-Name"},{name:"Name",value:e},{name:"IO-Process-Id",value:i},{name:"ARIO-Process-Id",value:i},{name:"Process-Id",value:f}],signer:this.signer})}async approvePrimaryNameRequest({name:e,address:i,arioProcessId:f},n){return this.process.send({tags:[...n?.tags??[],{name:"Action",value:"Approve-Primary-Name"},{name:"Name",value:e},{name:"Recipient",value:i},{name:"IO-Process-Id",value:f},{name:"ARIO-Process-Id",value:f}],signer:this.signer})}async removePrimaryNames({names:e,arioProcessId:i,notifyOwners:f=!1},n){return this.process.send({tags:[...n?.tags??[],{name:"Action",value:"Remove-Primary-Names"},{name:"Names",value:e.join(",")},{name:"IO-Process-Id",value:i},{name:"ARIO-Process-Id",value:i},{name:"Notify-Owners",value:f.toString()}],signer:this.signer})}};async function sPt({signer:t,module:e=wle,ao:i=Ls(),scheduler:f=xle,state:n,antRegistryId:l=Rm,logger:p=pl.default,authority:v=Mle}){let _=await i.spawn({module:e,scheduler:f,signer:t,data:n?JSON.stringify(n):void 0,tags:[{name:"Authority",value:v},{name:"ANT-Registry-Id",value:l}]});return p.debug("Spawned ANT",{processId:_,module:e,scheduler:f}),_}async function fPt({signer:t,processId:e,luaCodeTxId:i=_le,ao:f=Ls(),logger:n=pl.default,arweave:l=N7}){let p=new ia({processId:e,ao:f,logger:n}),{api:{host:v,port:_,protocol:g}}=l.getConfig(),y=await fetch(`${g}://${v}:${_}/${i}`).then(x=>x.text()),{id:M}=await p.send({tags:[{name:"Action",value:"Eval"},{name:"App-Name",value:"ArNS-ANT"},{name:"Source-Code-TX-ID",value:i}],data:y,signer:t});return n.debug("Evolved ANT",{processId:e,luaCodeTxId:i,evalMsgId:M}),M}function dit(t){let e=vr.object({name:vr.string(),value:vr.union([vr.string(),vr.number()])}),i=vr.function().args(vr.object({data:vr.union([vr.string(),vr.instanceof(De)]),tags:vr.array(e).optional(),target:vr.string().optional(),anchor:vr.string().optional()})).returns(vr.promise(vr.object({id:vr.string(),raw:vr.instanceof(ArrayBuffer)})));try{return i.parse(t),!0}catch{return!1}}function dd(t){return dit(t)?t:"publicKey"in t?async({data:i,tags:f,target:n,anchor:l})=>{if(t.publicKey===void 0&&"setPublicKey"in t&&typeof t.setPublicKey=="function"&&await t.setPublicKey(),t instanceof Wc){let _=await t.signer.signDataItem({data:i,tags:f,target:n,anchor:l}),g=new mm(De.from(_));return{id:await g.id,raw:await g.getRaw()}}let p=Kb(i,t,{tags:f,target:n,anchor:l});return p.sign(t).then(async()=>({id:await p.id,raw:await p.getRaw()}))}:Lce(t)}var pit="-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI",vit="Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A";function uPt({owner:t,targetId:e,ttlSeconds:i=3600,keywords:f=[],controllers:n=[],description:l="",ticker:p="aos",name:v="ANT",logo:_=vit}){return{ticker:p,name:v,description:l,keywords:f,owner:t,controllers:[t,...n],balances:{[t]:1},records:{"@":{transactionId:e??pit.toString(),ttlSeconds:i}},logo:_}}function Bq(t){return vr.object({startTimestamp:vr.number(),startHeight:vr.number(),distributions:vr.any(),endTimestamp:vr.number(),prescribedObservers:vr.any(),prescribedNames:vr.array(vr.string()),observations:vr.any(),epochIndex:vr.number()}).parse(t)}function Tq(t){let i=t.Error??t.Messages?.[0]?.Tags?.find(f=>f.name==="Error")?.value;if(i!==void 0){let f=i.match(/\[string "aos"]:(\d+):\s*(.+)/);if(f){let[,n,l]=f;return`${oye(l).trim()} (line ${n.trim()})`.trim()}return oye(i)}}function oye(t){let e="\x1B";return t.replace(new RegExp(`${e}[\\[\\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]`,"g"),"").trim()}var sye=t=>L5.test(t);function MPt(t){return t!==void 0&&!isNaN(parseInt(t.toString()))}var Ln=t=>t.filter(e=>e.value!==void 0&&e.value!==""),To=t=>{let e=[{name:"Cursor",value:t?.cursor?.toString()},{name:"Limit",value:t?.limit?.toString()},{name:"Sort-By",value:t?.sortBy?.toString()},{name:"Sort-Order",value:t?.sortOrder?.toString()}];return Ln(e)},mit=async({arweave:t,epochIndex:e,processId:i=ns,retries:f=3,gqlUrl:n="https://arweave-search.goldsky.com/graphql"})=>{let l=bit({epochIndex:e,processId:i});for(let p=0;p<f;p++)try{let v=await fetch(n,{method:"POST",body:l,headers:{"Content-Type":"application/json"}}).then(y=>y.json());if(v?.data?.transactions?.edges?.length===0)return;let _=v.data.transactions.edges[0].node.id,g=await t.api.get(_);return Bq(g.data)}catch(v){if(p===f-1)throw v;await new Promise(_=>setTimeout(_,Math.pow(2,p)*1e3))}},D1=async({arweave:t,ao:e,epochIndex:i,processId:f=ns})=>{let n=await mit({arweave:t,epochIndex:i,processId:f});if(n)return n;let l=await git({ao:e,epochIndex:i,processId:f});if(l)return l},git=async({ao:t,epochIndex:e,processId:i=ns,gqlUrl:f="https://arweave-search.goldsky.com/graphql"})=>{let n=yit({epochIndex:e,processId:i}),p=await(await fetch(f,{method:"POST",body:n,headers:{"Content-Type":"application/json"}})).json();if(p.data.transactions.edges.length!==0)for(let v of p.data.transactions.edges){let _=v.node.id,g=await t.result({message:_,process:i}).catch(()=>{});if(g)for(let y of g.Messages){let M=JSON.parse(y.Data),x=y.Tags;if(x.some(S=>S.name==="Action"&&S.value==="Epoch-Distribution-Notice")&&x.some(S=>S.name==="Epoch-Index"&&S.value===e.toString()))return Bq(M)}}},bit=({epochIndex:t,processId:e=ns,authorities:i=["fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY"]})=>JSON.stringify({query:`
212
+ }`,n=It.object({data:It.object({transactions:It.object({edges:It.array(It.object({node:It.record(It.any())}))})})});return l=>li(l).chain(vn(p=>t(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:f,variables:{transactionIds:[p]}})}).then(async v=>{if(v.ok)return v.json();throw i('Error Encountered when querying gateway for transaction "%s"',p),new Error(`${v.status}: ${await v.text()}`)}).then(n.parse).then(_qe(["data","transactions","edges","0","node"])))).toPromise()}var PUe=qC(UNe(),1),Mce=(t="@permaweb/aoconnect")=>{let e=(0,PUe.default)(t);return e.child=i=>Mce(`${e.namespace}:${i}`),e.tap=(i,...f)=>Tqe((...n)=>e(i,...f,...n)),e},xce=({url:t,path:e})=>e?e.startsWith("/")?xce({url:t,path:e.slice(1)}):(t=new URL(t),t.pathname+=e,t.toString()):t;function OUe(t){return Hm(x7([]),zm((e,i)=>Hm(Sqe([],i.name),t$(i.value),Jf(i.name,d0,e))(e),{}),_7(e=>e.length>1?e:e[0]))(t)}function Vf(t,e){return i=>K0e(ODe([Vle(t,"name"),i$(e$(e),Vle(e,"value"),JC)]),i)}function Jle(t){return rce([[py(String),Om(t)],[py(Array),cqe(t)],[JC,zLe]])}function b1(t){let e;return py(Gf,t)?(e=new Error(NUe(t)),e.stack+=t.stack):py(Error,t)?e=t:uqe("message",t)?e=new Error(t.message):py(String,t)?e=new Error(t):e=new Error("An error occurred"),e}function NUe(t){return Hm(e=>function i(f,n,l){return zm((p,v)=>Hm(rce([[Om(Gt.invalid_arguments),()=>i(v.argumentsError,422,"Invalid Arguments")],[Om(Gt.invalid_return_type),()=>i(v.returnTypeError,500,"Invalid Return")],[Om(Gt.invalid_union),()=>GDe(_=>i(_,400,"Invalid Union"),v.unionErrors)],[JC,()=>[{...v,status:n,contextCode:l}]]]),r$(p))(v.code),[],f.issues)}(e,400,""),e=>zm((i,f)=>{let{message:n,path:l,contextCode:p}=f,v=l[1]||l[0],_=p?`${p} `:"";return i.push(`${_}'${v}': ${n}.`),i},[],e),bqe(" | "))(t)}var CUe=It.object({id:It.string().min(1,{message:"message is required to be a message id"}),processId:It.string().min(1,{message:"process is required to be a process id"})});function $Ue(){return t=>li(t).map(CUe.parse).map(()=>t)}var Jy=It.object({name:It.string(),value:It.string()}),LUe=It.function().args(It.object({Id:It.string(),Target:It.string(),Owner:It.string(),Anchor:It.string().optional(),Data:It.any().default("1234"),Tags:It.array(It.object({name:It.string(),value:It.string()}))})).returns(It.promise(It.any())),DUe=It.function().args(It.object({id:It.string().min(1,{message:"message id is required"}),processId:It.string().min(1,{message:"process id is required"})})).returns(It.promise(It.any())),qUe=It.function().args(It.object({process:It.string().min(1,{message:"process id is required"}),from:It.string().optional(),to:It.string().optional(),sort:It.enum(["ASC","DESC"]).default("ASC"),limit:It.number().optional()})).returns(It.promise(It.object({edges:It.array(It.object({cursor:It.string(),node:It.object({Output:It.any().optional(),Messages:It.array(It.any()).optional(),Spawns:It.array(It.any()).optional(),Error:It.any().optional()})}))}))),Sce=It.function().args(It.object({processId:It.string(),data:It.any(),tags:It.array(Jy),anchor:It.string().optional(),signer:It.any()})).returns(It.promise(It.object({messageId:It.string()}).passthrough())),UUe=It.function().args(It.object({data:It.any(),tags:It.array(Jy),signer:It.any()})).returns(It.promise(It.object({processId:It.string()}).passthrough())),FUe=It.function().args(It.object({process:It.string(),message:It.string(),baseLayer:It.boolean().optional(),exclude:It.array(It.string()).optional()})).returns(It.promise(It.object({assignmentId:It.string()}).passthrough())),Ece=Sce,Pwt=It.function().args(It.object({suUrl:It.string().url(),processId:It.string()})).returns(It.promise(It.object({tags:It.array(Jy)}).passthrough())),Owt=It.function().args(It.string()).returns(It.promise(It.object({url:It.string()}))),jUe=It.function().args(It.string()).returns(It.promise(It.boolean())),zUe=It.function().args(It.string()).returns(It.promise(It.object({tags:It.array(Jy)}).passthrough())),S7=It.function().args(It.object({data:It.any(),tags:It.array(Jy),target:It.string().optional(),anchor:It.string().optional()})).returns(It.promise(It.object({id:It.string(),raw:It.any()})));function HUe({loadResult:t}){return t=vn(DUe.implement(t)),e=>li({id:e.id,processId:e.processId}).chain(t)}function WUe(t){let e=$Ue(t),i=HUe(t);return({message:f,process:n})=>li({id:f,processId:n}).chain(e).chain(i).map(t.logger.tap('readResult result for message "%s": %O',f)).map(l=>l).bimap(b1,g1).toPromise()}var KUe=It.array(It.object({name:It.string(),value:It.string()}));function ZUe(){return t=>li(t.tags).map(x7([])).map(Vf("Data-Protocol","ao")).map(Vf("Variant")).map(Vf("Type")).map(Vf("SDK")).map(r$(d0,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Message"},{name:"SDK",value:"aoconnect"}])).map(KUe.parse).map(Jf("tags",d0,t))}function VUe({logger:t}){return e=>li(e).chain(i$(e$(e.data),()=>d1(e),()=>d1(Math.random().toString().slice(-4)).map(Jf("data",d0,e)).map(i=>Hm(m1("tags"),Vf("Content-Type"),t$({name:"Content-Type",value:"text/plain"}),Jf("tags",d0,i))(i)).map(t.tap('added pseudo-random string as message "data"'))))}function GUe(t){let e=ZUe(t),i=VUe(t),f=Sce.implement(t.deployMessage);return n=>li(n).chain(e).chain(i).chain(vn(({id:l,data:p,tags:v,anchor:_,signer:g})=>f({processId:l,data:p,tags:v,anchor:_,signer:S7.implement(g)}))).map(l=>Jf("messageId",l.messageId,n))}function YUe(t){let e=GUe(t);return({process:i,data:f,tags:n,anchor:l,signer:p})=>li({id:i,data:f,tags:n,anchor:l,signer:p}).chain(e).map(v=>v.messageId).bimap(b1,g1).toPromise()}var ny=(t,e,i)=>f=>e(f[t])?d1(f):ad(`Tag '${t}': ${i}`);function JUe({loadTransactionMeta:t,logger:e}){return t=vn(zUe.implement(t)),i=>li(i).chain(t).map(m1("tags")).map(OUe).chain(ny("Data-Protocol",Jle("ao"),"value 'ao' was not found on module")).chain(ny("Type",Jle("Module"),"value 'Module' was not found on module")).chain(ny("Module-Format",hC,"was not found on module")).chain(ny("Input-Encoding",hC,"was not found on module")).chain(ny("Output-Encoding",hC,"was not found on module")).bimap(e.tap("Verifying module source failed: %s"),e.tap("Verified module source"))}function XUe({logger:t,validateScheduler:e}){return e=vn(jUe.implement(e)),i=>li(i).chain(f=>e(f).chain(n=>n?d1(f):ad(`Valid Scheduler-Location owned by ${f} not found`))).bimap(t.tap("Verifying scheduler failed: %s"),t.tap("Verified scheduler"))}function QUe({logger:t}){return e=>li(e).map(t.tap("Checking for signer")).chain(i=>i?d1(i):ad("signer not found"))}function eFe(t){let e=t.logger.child("verifyInput");t={...t,logger:e};let i=JUe(t),f=XUe(t),n=QUe(t);return l=>li(l).chain(p=>i(p.module).map(()=>p)).chain(p=>f(p.scheduler)).map(()=>l).chain(p=>n(p.signer).map(()=>p)).bimap(e.tap("Error when verify input: %s"),e.tap("Successfully verified inputs"))}var tFe=It.array(It.object({name:It.string(),value:It.string()}));function rFe(){return t=>li(t).map(m1("tags")).map(x7([])).map(Vf("Data-Protocol","ao")).map(Vf("Variant")).map(Vf("Type")).map(Vf("Module")).map(Vf("Scheduler")).map(Vf("SDK")).map(r$(d0,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Process"},{name:"Module",value:t.module},{name:"Scheduler",value:t.scheduler},{name:"SDK",value:"aoconnect"}])).map(tFe.parse).map(Jf("tags",d0,t))}function iFe({logger:t}){return e=>li(e).chain(i$(e$(e.data),()=>d1(e),()=>d1(Math.random().toString().slice(-4)).map(Jf("data",d0,e)).map(i=>Hm(m1("tags"),Vf("Content-Type"),t$({name:"Content-Type",value:"text/plain"}),Jf("tags",d0,i))(i)).map(t.tap('added pseudo-random string as process "data"'))))}function nFe(t){let e=t.logger.child("uploadProcess");t={...t,logger:e};let i=rFe(t),f=iFe(t),n=UUe.implement(t.deployProcess);return l=>li(l).chain(i).chain(f).chain(vn(({data:p,tags:v,signer:_})=>n({data:p,tags:v,signer:S7.implement(_)}))).map(p=>Jf("processId",p.processId,l))}function aFe(t){let e=eFe(t),i=nFe(t);return({module:f,scheduler:n,signer:l,tags:p,data:v})=>li({module:f,scheduler:n,signer:l,tags:p,data:v}).chain(e).chain(i).map(_=>_.processId).bimap(b1,g1).toPromise()}function oFe(t){let e=Ece.implement(t.deployMonitor);return i=>li(i).chain(vn(({id:f,signer:n})=>e({processId:f,signer:S7.implement(n),data:Math.random().toString().slice(-4),tags:[]}))).map(f=>Jf("monitorId",f.messageId,i))}function sFe(t){let e=oFe(t);return({process:i,signer:f})=>li({id:i,signer:f}).chain(e).map(n=>n.monitorId).bimap(b1,g1).toPromise()}function fFe(t){let e=Ece.implement(t.deployUnmonitor);return i=>li(i).chain(vn(({id:f,signer:n})=>e({processId:f,signer:S7.implement(n),data:Math.random().toString().slice(-4),tags:[]}))).map(f=>Jf("monitorId",f.messageId,i))}function uFe(t){let e=fFe(t);return({process:i,signer:f})=>li({id:i,signer:f}).chain(e).map(n=>n.monitorId).bimap(b1,g1).toPromise()}var hFe=It.object({process:It.string().min(1,{message:"process identifier is required"}),from:It.string().optional(),to:It.string().optional(),sort:It.enum(["ASC","DESC"]).default("ASC"),limit:It.number().optional()});function lFe(){return t=>li(t).map(hFe.parse).map(()=>t)}function cFe({queryResults:t}){return t=vn(qUe.implement(t)),e=>li({process:e.process,from:e.from,to:e.to,sort:e.sort,limit:e.limit}).chain(t)}function dFe(t){let e=lFe(t),i=cFe(t);return({process:f,from:n,to:l,sort:p,limit:v})=>li({process:f,from:n,to:l,sort:p,limit:v}).chain(e).chain(i).map(t.logger.tap('readResults result for message "%s": %O',f)).map(_=>_).bimap(b1,g1).toPromise()}var pFe=It.object({Id:It.string(),Target:It.string(),Owner:It.string(),Anchor:It.string().optional(),Data:It.any().default("1234"),Tags:It.array(It.object({name:It.string(),value:It.string()}))});function vFe(){return t=>li(t).map(pFe.parse).map(e=>(e.Tags=e.Tags.concat([{name:"Data-Protocol",value:"ao"},{name:"Type",value:"Message"},{name:"Variant",value:"ao.TN.1"}]),e))}function mFe({dryrunFetch:t}){return vn(LUe.implement(t))}function gFe(t){let e=vFe(t),i=mFe(t);return f=>li(f).map(bFe).chain(e).chain(i).toPromise()}function bFe({process:t,data:e,tags:i,anchor:f,...n}){return{Id:"1234",Owner:"1234",...n,Target:t,Data:e||"1234",Tags:i||[],Anchor:f||"0"}}function yFe(t){let e=FUe.implement(t.deployAssign);return i=>li(i).chain(vn(({process:f,message:n,baseLayer:l,exclude:p})=>e({process:f,message:n,baseLayer:l,exclude:p}))).map(f=>Jf("assignmentId",f.assignmentId,i))}function wFe(t){let e=yFe(t);return({process:i,message:f,baseLayer:n,exclude:l})=>li({process:i,message:f,baseLayer:n,exclude:l}).chain(e).map(p=>p.assignmentId).bimap(b1,g1).toPromise()}var _Fe="https://arweave.net",MFe="https://mu.ao-testnet.xyz",xFe="https://cu.ao-testnet.xyz";function Ls({GRAPHQL_URL:t,GATEWAY_URL:e=_Fe,MU_URL:i=MFe,CU_URL:f=xFe}={}){let n=Mce();t||(t=xce({url:e,path:"/graphql"}));let{validate:l}=j0e({cacheSize:100,GRAPHQL_URL:t}),p=FLe({MAX_SIZE:25}),v=n.child("result"),_=WUe({loadResult:DLe({fetch,CU_URL:f,logger:v}),logger:v}),g=n.child("message"),y=YUe({loadProcessMeta:sC({fetch,cache:p,logger:g}),deployMessage:PLe({fetch,MU_URL:i,logger:g}),logger:g}),M=n.child("spawn"),x=aFe({loadTransactionMeta:BUe({fetch,GRAPHQL_URL:t,logger:M}),validateScheduler:l,deployProcess:OLe({fetch,MU_URL:i,logger:M}),logger:M}),S=n.child("monitor"),R=sFe({loadProcessMeta:sC({fetch,cache:p,logger:S}),deployMonitor:NLe({fetch,MU_URL:i,logger:S}),logger:S}),T=n.child("unmonitor"),k=uFe({loadProcessMeta:sC({fetch,cache:p,logger:T}),deployUnmonitor:CLe({fetch,MU_URL:i,logger:T}),logger:S}),B=n.child("results"),C=dFe({queryResults:qLe({fetch,CU_URL:f,logger:B}),logger:B}),N=n.child("dryrun"),W=gFe({dryrunFetch:LLe({fetch,CU_URL:f,logger:N}),logger:N}),H=n.child("assign"),J=wFe({deployAssign:$Le({fetch,MU_URL:i,logger:H}),logger:g});return{result:_,results:C,message:y,spawn:x,monitor:R,unmonitor:k,dryrun:W,assign:J}}var Ace={};e0e(Ace,{createDataItemSigner:()=>VFe});var Rce=qC(zNe(),1),Tce={};e0e(Tce,{AVSCTap:()=>Xy,ArweaveSigner:()=>f$,DataItem:()=>Zy,MAX_TAG_BYTES:()=>E7,MIN_BINARY_SIZE:()=>l$,SIG_CONFIG:()=>Gm,SignatureConfig:()=>Zf,Signer:()=>Pce,createData:()=>$ce,default:()=>WFe,deserializeTags:()=>v7,indexToType:()=>u$,serializeTags:()=>h$,tagsExceedLimit:()=>Cce,warparbundles:()=>KFe});var SFe=Object.create,o$=Object.defineProperty,EFe=Object.getOwnPropertyDescriptor,AFe=Object.getOwnPropertyNames,RFe=Object.getPrototypeOf,TFe=Object.prototype.hasOwnProperty,v0=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),IFe=(t,e)=>{for(var i in e)o$(t,i,{get:e[i],enumerable:!0})},kFe=(t,e,i,f)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of AFe(e))!TFe.call(t,n)&&n!==i&&o$(t,n,{get:()=>e[n],enumerable:!(f=EFe(e,n))||f.enumerable});return t},y1=(t,e,i)=>(i=t!=null?SFe(RFe(t)):{},kFe(e||!t||!t.__esModule?o$(i,"default",{value:t,enumerable:!0}):i,t)),BFe=v0(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});function e(i){var f=4,n=i.length,l=n%f;if(!l)return i;var p=n,v=f-l,_=n+v,g=De.alloc(_);for(g.write(i);v--;)g.write("=",p++);return g.toString()}t.default=e}),PFe=v0(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var e=BFe();function i(_,g){return g===void 0&&(g="utf8"),De.isBuffer(_)?l(_.toString("base64")):l(De.from(_,g).toString("base64"))}function f(_,g){return g===void 0&&(g="utf8"),De.from(n(_),"base64").toString(g)}function n(_){return _=_.toString(),e.default(_).replace(/\-/g,"+").replace(/_/g,"/")}function l(_){return _.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function p(_){return De.from(n(_),"base64")}var v=i;v.encode=i,v.decode=f,v.toBase64=n,v.fromBase64=l,v.toBuffer=p,t.default=v}),s$=v0((t,e)=>{e.exports=PFe().default,e.exports.default=e.exports}),Ice=v0(t=>{"use strict";t.byteLength=_,t.toByteArray=y,t.fromByteArray=S;var e=[],i=[],f=typeof Uint8Array<"u"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(l=0,p=n.length;l<p;++l)e[l]=n[l],i[n.charCodeAt(l)]=l;var l,p;i[45]=62,i[95]=63;function v(R){var T=R.length;if(T%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=R.indexOf("=");k===-1&&(k=T);var B=k===T?0:4-k%4;return[k,B]}function _(R){var T=v(R),k=T[0],B=T[1];return(k+B)*3/4-B}function g(R,T,k){return(T+k)*3/4-k}function y(R){var T,k=v(R),B=k[0],C=k[1],N=new f(g(R,B,C)),W=0,H=C>0?B-4:B,J;for(J=0;J<H;J+=4)T=i[R.charCodeAt(J)]<<18|i[R.charCodeAt(J+1)]<<12|i[R.charCodeAt(J+2)]<<6|i[R.charCodeAt(J+3)],N[W++]=T>>16&255,N[W++]=T>>8&255,N[W++]=T&255;return C===2&&(T=i[R.charCodeAt(J)]<<2|i[R.charCodeAt(J+1)]>>4,N[W++]=T&255),C===1&&(T=i[R.charCodeAt(J)]<<10|i[R.charCodeAt(J+1)]<<4|i[R.charCodeAt(J+2)]>>2,N[W++]=T>>8&255,N[W++]=T&255),N}function M(R){return e[R>>18&63]+e[R>>12&63]+e[R>>6&63]+e[R&63]}function x(R,T,k){for(var B,C=[],N=T;N<k;N+=3)B=(R[N]<<16&16711680)+(R[N+1]<<8&65280)+(R[N+2]&255),C.push(M(B));return C.join("")}function S(R){for(var T,k=R.length,B=k%3,C=[],N=16383,W=0,H=k-B;W<H;W+=N)C.push(x(R,W,W+N>H?H:W+N));return B===1?(T=R[k-1],C.push(e[T>>2]+e[T<<4&63]+"==")):B===2&&(T=(R[k-2]<<8)+R[k-1],C.push(e[T>>10]+e[T>>4&63]+e[T<<2&63]+"=")),C.join("")}}),kce=v0(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64UrlDecode=t.b64UrlEncode=t.bufferTob64Url=t.bufferTob64=t.b64UrlToBuffer=t.stringToB64Url=t.stringToBuffer=t.bufferToString=t.b64UrlToString=t.concatBuffers=void 0;var e=Ice();function i(x){let S=0;for(let k=0;k<x.length;k++)S+=x[k].byteLength;let R=new Uint8Array(S),T=0;R.set(new Uint8Array(x[0]),T),T+=x[0].byteLength;for(let k=1;k<x.length;k++)R.set(new Uint8Array(x[k]),T),T+=x[k].byteLength;return R}t.concatBuffers=i;function f(x){let S=v(x);return n(S)}t.b64UrlToString=f;function n(x){return new TextDecoder("utf-8",{fatal:!0}).decode(x)}t.bufferToString=n;function l(x){return new TextEncoder().encode(x)}t.stringToBuffer=l;function p(x){return g(l(x))}t.stringToB64Url=p;function v(x){return new Uint8Array(e.toByteArray(M(x)))}t.b64UrlToBuffer=v;function _(x){return e.fromByteArray(new Uint8Array(x))}t.bufferTob64=_;function g(x){return y(_(x))}t.bufferTob64Url=g;function y(x){return x.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}t.b64UrlEncode=y;function M(x){x=x.replace(/\-/g,"+").replace(/\_/g,"/");let S;return x.length%4==0?S=0:S=4-x.length%4,x.concat("=".repeat(S))}t.b64UrlDecode=M}),OFe=v0(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var e=kce(),i=class{keyLength=4096;publicExponent=65537;hashAlgorithm="sha256";driver;constructor(){if(!this.detectWebCrypto())throw new Error("SubtleCrypto not available!");this.driver=crypto.subtle}async generateJWK(){let f=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),n=await this.driver.exportKey("jwk",f.privateKey);return{kty:n.kty,e:n.e,n:n.n,d:n.d,p:n.p,q:n.q,dp:n.dp,dq:n.dq,qi:n.qi}}async sign(f,n,{saltLength:l}={}){let p=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(f),n);return new Uint8Array(p)}async hash(f,n="SHA-256"){let l=await this.driver.digest(n,f);return new Uint8Array(l)}async verify(f,n,l){let p={kty:"RSA",e:"AQAB",n:f},v=await this.jwkToPublicCryptoKey(p),_=await this.driver.digest("SHA-256",n),g=await this.driver.verify({name:"RSA-PSS",saltLength:0},v,l,n),y=await this.driver.verify({name:"RSA-PSS",saltLength:32},v,l,n),M=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((v.algorithm.modulusLength-1)/8)-_.byteLength-2},v,l,n);return g||y||M}async jwkToCryptoKey(f){return this.driver.importKey("jwk",f,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(f){return this.driver.importKey("jwk",f,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let f=crypto?.subtle;return f===void 0?!1:["generateKey","importKey","exportKey","digest","sign"].every(n=>typeof f[n]=="function")}async encrypt(f,n,l){let p=await this.driver.importKey("raw",typeof n=="string"?e.stringToBuffer(n):n,{name:"PBKDF2",length:32},!1,["deriveKey"]),v=await this.driver.deriveKey({name:"PBKDF2",salt:l?e.stringToBuffer(l):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},p,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),_=new Uint8Array(16);crypto.getRandomValues(_);let g=await this.driver.encrypt({name:"AES-CBC",iv:_},v,f);return e.concatBuffers([_,g])}async decrypt(f,n,l){let p=await this.driver.importKey("raw",typeof n=="string"?e.stringToBuffer(n):n,{name:"PBKDF2",length:32},!1,["deriveKey"]),v=await this.driver.deriveKey({name:"PBKDF2",salt:l?e.stringToBuffer(l):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},p,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),_=f.slice(0,16),g=await this.driver.decrypt({name:"AES-CBC",iv:_},v,f.slice(16));return e.concatBuffers([g])}};t.default=i}),NFe=v0(t=>{t.read=function(e,i,f,n,l){var p,v,_=l*8-n-1,g=(1<<_)-1,y=g>>1,M=-7,x=f?l-1:0,S=f?-1:1,R=e[i+x];for(x+=S,p=R&(1<<-M)-1,R>>=-M,M+=_;M>0;p=p*256+e[i+x],x+=S,M-=8);for(v=p&(1<<-M)-1,p>>=-M,M+=n;M>0;v=v*256+e[i+x],x+=S,M-=8);if(p===0)p=1-y;else{if(p===g)return v?NaN:(R?-1:1)*(1/0);v=v+Math.pow(2,n),p=p-y}return(R?-1:1)*v*Math.pow(2,p-n)},t.write=function(e,i,f,n,l,p){var v,_,g,y=p*8-l-1,M=(1<<y)-1,x=M>>1,S=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,R=n?0:p-1,T=n?1:-1,k=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(_=isNaN(i)?1:0,v=M):(v=Math.floor(Math.log(i)/Math.LN2),i*(g=Math.pow(2,-v))<1&&(v--,g*=2),v+x>=1?i+=S/g:i+=S*Math.pow(2,1-x),i*g>=2&&(v++,g/=2),v+x>=M?(_=0,v=M):v+x>=1?(_=(i*g-1)*Math.pow(2,l),v=v+x):(_=i*Math.pow(2,x-1)*Math.pow(2,l),v=0));l>=8;e[f+R]=_&255,R+=T,_/=256,l-=8);for(v=v<<l|_,y+=l;y>0;e[f+R]=v&255,R+=T,v/=256,y-=8);e[f+R-T]|=k*128}}),$C=v0(t=>{"use strict";var e=Ice(),i=NFe(),f=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=v,t.SlowBuffer=C,t.INSPECT_MAX_BYTES=50;var n=2147483647;t.kMaxLength=n,v.TYPED_ARRAY_SUPPORT=l(),!v.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{let P=new Uint8Array(1),O={foo:function(){return 42}};return Object.setPrototypeOf(O,Uint8Array.prototype),Object.setPrototypeOf(P,O),P.foo()===42}catch{return!1}}Object.defineProperty(v.prototype,"parent",{enumerable:!0,get:function(){if(v.isBuffer(this))return this.buffer}}),Object.defineProperty(v.prototype,"offset",{enumerable:!0,get:function(){if(v.isBuffer(this))return this.byteOffset}});function p(P){if(P>n)throw new RangeError('The value "'+P+'" is invalid for option "size"');let O=new Uint8Array(P);return Object.setPrototypeOf(O,v.prototype),O}function v(P,O,$){if(typeof P=="number"){if(typeof O=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return M(P)}return _(P,O,$)}v.poolSize=8192;function _(P,O,$){if(typeof P=="string")return x(P,O);if(ArrayBuffer.isView(P))return R(P);if(P==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof P);if(dt(P,ArrayBuffer)||P&&dt(P.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(dt(P,SharedArrayBuffer)||P&&dt(P.buffer,SharedArrayBuffer)))return T(P,O,$);if(typeof P=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let Z=P.valueOf&&P.valueOf();if(Z!=null&&Z!==P)return v.from(Z,O,$);let te=k(P);if(te)return te;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof P[Symbol.toPrimitive]=="function")return v.from(P[Symbol.toPrimitive]("string"),O,$);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof P)}v.from=function(P,O,$){return _(P,O,$)},Object.setPrototypeOf(v.prototype,Uint8Array.prototype),Object.setPrototypeOf(v,Uint8Array);function g(P){if(typeof P!="number")throw new TypeError('"size" argument must be of type number');if(P<0)throw new RangeError('The value "'+P+'" is invalid for option "size"')}function y(P,O,$){return g(P),P<=0?p(P):O!==void 0?typeof $=="string"?p(P).fill(O,$):p(P).fill(O):p(P)}v.alloc=function(P,O,$){return y(P,O,$)};function M(P){return g(P),p(P<0?0:B(P)|0)}v.allocUnsafe=function(P){return M(P)},v.allocUnsafeSlow=function(P){return M(P)};function x(P,O){if((typeof O!="string"||O==="")&&(O="utf8"),!v.isEncoding(O))throw new TypeError("Unknown encoding: "+O);let $=N(P,O)|0,Z=p($),te=Z.write(P,O);return te!==$&&(Z=Z.slice(0,te)),Z}function S(P){let O=P.length<0?0:B(P.length)|0,$=p(O);for(let Z=0;Z<O;Z+=1)$[Z]=P[Z]&255;return $}function R(P){if(dt(P,Uint8Array)){let O=new Uint8Array(P);return T(O.buffer,O.byteOffset,O.byteLength)}return S(P)}function T(P,O,$){if(O<0||P.byteLength<O)throw new RangeError('"offset" is outside of buffer bounds');if(P.byteLength<O+($||0))throw new RangeError('"length" is outside of buffer bounds');let Z;return O===void 0&&$===void 0?Z=new Uint8Array(P):$===void 0?Z=new Uint8Array(P,O):Z=new Uint8Array(P,O,$),Object.setPrototypeOf(Z,v.prototype),Z}function k(P){if(v.isBuffer(P)){let O=B(P.length)|0,$=p(O);return $.length===0||P.copy($,0,0,O),$}if(P.length!==void 0)return typeof P.length!="number"||Me(P.length)?p(0):S(P);if(P.type==="Buffer"&&Array.isArray(P.data))return S(P.data)}function B(P){if(P>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return P|0}function C(P){return+P!=P&&(P=0),v.alloc(+P)}v.isBuffer=function(P){return P!=null&&P._isBuffer===!0&&P!==v.prototype},v.compare=function(P,O){if(dt(P,Uint8Array)&&(P=v.from(P,P.offset,P.byteLength)),dt(O,Uint8Array)&&(O=v.from(O,O.offset,O.byteLength)),!v.isBuffer(P)||!v.isBuffer(O))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(P===O)return 0;let $=P.length,Z=O.length;for(let te=0,X=Math.min($,Z);te<X;++te)if(P[te]!==O[te]){$=P[te],Z=O[te];break}return $<Z?-1:Z<$?1:0},v.isEncoding=function(P){switch(String(P).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},v.concat=function(P,O){if(!Array.isArray(P))throw new TypeError('"list" argument must be an Array of Buffers');if(P.length===0)return v.alloc(0);let $;if(O===void 0)for(O=0,$=0;$<P.length;++$)O+=P[$].length;let Z=v.allocUnsafe(O),te=0;for($=0;$<P.length;++$){let X=P[$];if(dt(X,Uint8Array))te+X.length>Z.length?(v.isBuffer(X)||(X=v.from(X)),X.copy(Z,te)):Uint8Array.prototype.set.call(Z,X,te);else if(v.isBuffer(X))X.copy(Z,te);else throw new TypeError('"list" argument must be an Array of Buffers');te+=X.length}return Z};function N(P,O){if(v.isBuffer(P))return P.length;if(ArrayBuffer.isView(P)||dt(P,ArrayBuffer))return P.byteLength;if(typeof P!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof P);let $=P.length,Z=arguments.length>2&&arguments[2]===!0;if(!Z&&$===0)return 0;let te=!1;for(;;)switch(O){case"ascii":case"latin1":case"binary":return $;case"utf8":case"utf-8":return ie(P).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $*2;case"hex":return $>>>1;case"base64":return he(P).length;default:if(te)return Z?-1:ie(P).length;O=(""+O).toLowerCase(),te=!0}}v.byteLength=N;function W(P,O,$){let Z=!1;if((O===void 0||O<0)&&(O=0),O>this.length||(($===void 0||$>this.length)&&($=this.length),$<=0)||($>>>=0,O>>>=0,$<=O))return"";for(P||(P="utf8");;)switch(P){case"hex":return a(this,O,$);case"utf8":case"utf-8":return u(this,O,$);case"ascii":return w(this,O,$);case"latin1":case"binary":return c(this,O,$);case"base64":return s(this,O,$);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d(this,O,$);default:if(Z)throw new TypeError("Unknown encoding: "+P);P=(P+"").toLowerCase(),Z=!0}}v.prototype._isBuffer=!0;function H(P,O,$){let Z=P[O];P[O]=P[$],P[$]=Z}v.prototype.swap16=function(){let P=this.length;if(P%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let O=0;O<P;O+=2)H(this,O,O+1);return this},v.prototype.swap32=function(){let P=this.length;if(P%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let O=0;O<P;O+=4)H(this,O,O+3),H(this,O+1,O+2);return this},v.prototype.swap64=function(){let P=this.length;if(P%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let O=0;O<P;O+=8)H(this,O,O+7),H(this,O+1,O+6),H(this,O+2,O+5),H(this,O+3,O+4);return this},v.prototype.toString=function(){let P=this.length;return P===0?"":arguments.length===0?u(this,0,P):W.apply(this,arguments)},v.prototype.toLocaleString=v.prototype.toString,v.prototype.equals=function(P){if(!v.isBuffer(P))throw new TypeError("Argument must be a Buffer");return this===P?!0:v.compare(this,P)===0},v.prototype.inspect=function(){let P="",O=t.INSPECT_MAX_BYTES;return P=this.toString("hex",0,O).replace(/(.{2})/g,"$1 ").trim(),this.length>O&&(P+=" ... "),"<Buffer "+P+">"},f&&(v.prototype[f]=v.prototype.inspect),v.prototype.compare=function(P,O,$,Z,te){if(dt(P,Uint8Array)&&(P=v.from(P,P.offset,P.byteLength)),!v.isBuffer(P))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof P);if(O===void 0&&(O=0),$===void 0&&($=P?P.length:0),Z===void 0&&(Z=0),te===void 0&&(te=this.length),O<0||$>P.length||Z<0||te>this.length)throw new RangeError("out of range index");if(Z>=te&&O>=$)return 0;if(Z>=te)return-1;if(O>=$)return 1;if(O>>>=0,$>>>=0,Z>>>=0,te>>>=0,this===P)return 0;let X=te-Z,ae=$-O,qe=Math.min(X,ae),ue=this.slice(Z,te),ge=P.slice(O,$);for(let xe=0;xe<qe;++xe)if(ue[xe]!==ge[xe]){X=ue[xe],ae=ge[xe];break}return X<ae?-1:ae<X?1:0};function J(P,O,$,Z,te){if(P.length===0)return-1;if(typeof $=="string"?(Z=$,$=0):$>2147483647?$=2147483647:$<-2147483648&&($=-2147483648),$=+$,Me($)&&($=te?0:P.length-1),$<0&&($=P.length+$),$>=P.length){if(te)return-1;$=P.length-1}else if($<0)if(te)$=0;else return-1;if(typeof O=="string"&&(O=v.from(O,Z)),v.isBuffer(O))return O.length===0?-1:q(P,O,$,Z,te);if(typeof O=="number")return O=O&255,typeof Uint8Array.prototype.indexOf=="function"?te?Uint8Array.prototype.indexOf.call(P,O,$):Uint8Array.prototype.lastIndexOf.call(P,O,$):q(P,[O],$,Z,te);throw new TypeError("val must be string, number or Buffer")}function q(P,O,$,Z,te){let X=1,ae=P.length,qe=O.length;if(Z!==void 0&&(Z=String(Z).toLowerCase(),Z==="ucs2"||Z==="ucs-2"||Z==="utf16le"||Z==="utf-16le")){if(P.length<2||O.length<2)return-1;X=2,ae/=2,qe/=2,$/=2}function ue(xe,be){return X===1?xe[be]:xe.readUInt16BE(be*X)}let ge;if(te){let xe=-1;for(ge=$;ge<ae;ge++)if(ue(P,ge)===ue(O,xe===-1?0:ge-xe)){if(xe===-1&&(xe=ge),ge-xe+1===qe)return xe*X}else xe!==-1&&(ge-=ge-xe),xe=-1}else for($+qe>ae&&($=ae-qe),ge=$;ge>=0;ge--){let xe=!0;for(let be=0;be<qe;be++)if(ue(P,ge+be)!==ue(O,be)){xe=!1;break}if(xe)return ge}return-1}v.prototype.includes=function(P,O,$){return this.indexOf(P,O,$)!==-1},v.prototype.indexOf=function(P,O,$){return J(this,P,O,$,!0)},v.prototype.lastIndexOf=function(P,O,$){return J(this,P,O,$,!1)};function z(P,O,$,Z){$=Number($)||0;let te=P.length-$;Z?(Z=Number(Z),Z>te&&(Z=te)):Z=te;let X=O.length;Z>X/2&&(Z=X/2);let ae;for(ae=0;ae<Z;++ae){let qe=parseInt(O.substr(ae*2,2),16);if(Me(qe))return ae;P[$+ae]=qe}return ae}function Y(P,O,$,Z){return ye(ie(O,P.length-$),P,$,Z)}function b(P,O,$,Z){return ye(oe(O),P,$,Z)}function r(P,O,$,Z){return ye(he(O),P,$,Z)}function o(P,O,$,Z){return ye(Be(O,P.length-$),P,$,Z)}v.prototype.write=function(P,O,$,Z){if(O===void 0)Z="utf8",$=this.length,O=0;else if($===void 0&&typeof O=="string")Z=O,$=this.length,O=0;else if(isFinite(O))O=O>>>0,isFinite($)?($=$>>>0,Z===void 0&&(Z="utf8")):(Z=$,$=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let te=this.length-O;if(($===void 0||$>te)&&($=te),P.length>0&&($<0||O<0)||O>this.length)throw new RangeError("Attempt to write outside buffer bounds");Z||(Z="utf8");let X=!1;for(;;)switch(Z){case"hex":return z(this,P,O,$);case"utf8":case"utf-8":return Y(this,P,O,$);case"ascii":case"latin1":case"binary":return b(this,P,O,$);case"base64":return r(this,P,O,$);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o(this,P,O,$);default:if(X)throw new TypeError("Unknown encoding: "+Z);Z=(""+Z).toLowerCase(),X=!0}},v.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function s(P,O,$){return O===0&&$===P.length?e.fromByteArray(P):e.fromByteArray(P.slice(O,$))}function u(P,O,$){$=Math.min(P.length,$);let Z=[],te=O;for(;te<$;){let X=P[te],ae=null,qe=X>239?4:X>223?3:X>191?2:1;if(te+qe<=$){let ue,ge,xe,be;switch(qe){case 1:X<128&&(ae=X);break;case 2:ue=P[te+1],(ue&192)===128&&(be=(X&31)<<6|ue&63,be>127&&(ae=be));break;case 3:ue=P[te+1],ge=P[te+2],(ue&192)===128&&(ge&192)===128&&(be=(X&15)<<12|(ue&63)<<6|ge&63,be>2047&&(be<55296||be>57343)&&(ae=be));break;case 4:ue=P[te+1],ge=P[te+2],xe=P[te+3],(ue&192)===128&&(ge&192)===128&&(xe&192)===128&&(be=(X&15)<<18|(ue&63)<<12|(ge&63)<<6|xe&63,be>65535&&be<1114112&&(ae=be))}}ae===null?(ae=65533,qe=1):ae>65535&&(ae-=65536,Z.push(ae>>>10&1023|55296),ae=56320|ae&1023),Z.push(ae),te+=qe}return m(Z)}var h=4096;function m(P){let O=P.length;if(O<=h)return String.fromCharCode.apply(String,P);let $="",Z=0;for(;Z<O;)$+=String.fromCharCode.apply(String,P.slice(Z,Z+=h));return $}function w(P,O,$){let Z="";$=Math.min(P.length,$);for(let te=O;te<$;++te)Z+=String.fromCharCode(P[te]&127);return Z}function c(P,O,$){let Z="";$=Math.min(P.length,$);for(let te=O;te<$;++te)Z+=String.fromCharCode(P[te]);return Z}function a(P,O,$){let Z=P.length;(!O||O<0)&&(O=0),(!$||$<0||$>Z)&&($=Z);let te="";for(let X=O;X<$;++X)te+=ke[P[X]];return te}function d(P,O,$){let Z=P.slice(O,$),te="";for(let X=0;X<Z.length-1;X+=2)te+=String.fromCharCode(Z[X]+Z[X+1]*256);return te}v.prototype.slice=function(P,O){let $=this.length;P=~~P,O=O===void 0?$:~~O,P<0?(P+=$,P<0&&(P=0)):P>$&&(P=$),O<0?(O+=$,O<0&&(O=0)):O>$&&(O=$),O<P&&(O=P);let Z=this.subarray(P,O);return Object.setPrototypeOf(Z,v.prototype),Z};function A(P,O,$){if(P%1!==0||P<0)throw new RangeError("offset is not uint");if(P+O>$)throw new RangeError("Trying to access beyond buffer length")}v.prototype.readUintLE=v.prototype.readUIntLE=function(P,O,$){P=P>>>0,O=O>>>0,$||A(P,O,this.length);let Z=this[P],te=1,X=0;for(;++X<O&&(te*=256);)Z+=this[P+X]*te;return Z},v.prototype.readUintBE=v.prototype.readUIntBE=function(P,O,$){P=P>>>0,O=O>>>0,$||A(P,O,this.length);let Z=this[P+--O],te=1;for(;O>0&&(te*=256);)Z+=this[P+--O]*te;return Z},v.prototype.readUint8=v.prototype.readUInt8=function(P,O){return P=P>>>0,O||A(P,1,this.length),this[P]},v.prototype.readUint16LE=v.prototype.readUInt16LE=function(P,O){return P=P>>>0,O||A(P,2,this.length),this[P]|this[P+1]<<8},v.prototype.readUint16BE=v.prototype.readUInt16BE=function(P,O){return P=P>>>0,O||A(P,2,this.length),this[P]<<8|this[P+1]},v.prototype.readUint32LE=v.prototype.readUInt32LE=function(P,O){return P=P>>>0,O||A(P,4,this.length),(this[P]|this[P+1]<<8|this[P+2]<<16)+this[P+3]*16777216},v.prototype.readUint32BE=v.prototype.readUInt32BE=function(P,O){return P=P>>>0,O||A(P,4,this.length),this[P]*16777216+(this[P+1]<<16|this[P+2]<<8|this[P+3])},v.prototype.readBigUInt64LE=gt(function(P){P=P>>>0,K(P,"offset");let O=this[P],$=this[P+7];(O===void 0||$===void 0)&&G(P,this.length-8);let Z=O+this[++P]*2**8+this[++P]*2**16+this[++P]*2**24,te=this[++P]+this[++P]*2**8+this[++P]*2**16+$*2**24;return BigInt(Z)+(BigInt(te)<<BigInt(32))}),v.prototype.readBigUInt64BE=gt(function(P){P=P>>>0,K(P,"offset");let O=this[P],$=this[P+7];(O===void 0||$===void 0)&&G(P,this.length-8);let Z=O*2**24+this[++P]*2**16+this[++P]*2**8+this[++P],te=this[++P]*2**24+this[++P]*2**16+this[++P]*2**8+$;return(BigInt(Z)<<BigInt(32))+BigInt(te)}),v.prototype.readIntLE=function(P,O,$){P=P>>>0,O=O>>>0,$||A(P,O,this.length);let Z=this[P],te=1,X=0;for(;++X<O&&(te*=256);)Z+=this[P+X]*te;return te*=128,Z>=te&&(Z-=Math.pow(2,8*O)),Z},v.prototype.readIntBE=function(P,O,$){P=P>>>0,O=O>>>0,$||A(P,O,this.length);let Z=O,te=1,X=this[P+--Z];for(;Z>0&&(te*=256);)X+=this[P+--Z]*te;return te*=128,X>=te&&(X-=Math.pow(2,8*O)),X},v.prototype.readInt8=function(P,O){return P=P>>>0,O||A(P,1,this.length),this[P]&128?(255-this[P]+1)*-1:this[P]},v.prototype.readInt16LE=function(P,O){P=P>>>0,O||A(P,2,this.length);let $=this[P]|this[P+1]<<8;return $&32768?$|4294901760:$},v.prototype.readInt16BE=function(P,O){P=P>>>0,O||A(P,2,this.length);let $=this[P+1]|this[P]<<8;return $&32768?$|4294901760:$},v.prototype.readInt32LE=function(P,O){return P=P>>>0,O||A(P,4,this.length),this[P]|this[P+1]<<8|this[P+2]<<16|this[P+3]<<24},v.prototype.readInt32BE=function(P,O){return P=P>>>0,O||A(P,4,this.length),this[P]<<24|this[P+1]<<16|this[P+2]<<8|this[P+3]},v.prototype.readBigInt64LE=gt(function(P){P=P>>>0,K(P,"offset");let O=this[P],$=this[P+7];(O===void 0||$===void 0)&&G(P,this.length-8);let Z=this[P+4]+this[P+5]*2**8+this[P+6]*2**16+($<<24);return(BigInt(Z)<<BigInt(32))+BigInt(O+this[++P]*2**8+this[++P]*2**16+this[++P]*2**24)}),v.prototype.readBigInt64BE=gt(function(P){P=P>>>0,K(P,"offset");let O=this[P],$=this[P+7];(O===void 0||$===void 0)&&G(P,this.length-8);let Z=(O<<24)+this[++P]*2**16+this[++P]*2**8+this[++P];return(BigInt(Z)<<BigInt(32))+BigInt(this[++P]*2**24+this[++P]*2**16+this[++P]*2**8+$)}),v.prototype.readFloatLE=function(P,O){return P=P>>>0,O||A(P,4,this.length),i.read(this,P,!0,23,4)},v.prototype.readFloatBE=function(P,O){return P=P>>>0,O||A(P,4,this.length),i.read(this,P,!1,23,4)},v.prototype.readDoubleLE=function(P,O){return P=P>>>0,O||A(P,8,this.length),i.read(this,P,!0,52,8)},v.prototype.readDoubleBE=function(P,O){return P=P>>>0,O||A(P,8,this.length),i.read(this,P,!1,52,8)};function E(P,O,$,Z,te,X){if(!v.isBuffer(P))throw new TypeError('"buffer" argument must be a Buffer instance');if(O>te||O<X)throw new RangeError('"value" argument is out of bounds');if($+Z>P.length)throw new RangeError("Index out of range")}v.prototype.writeUintLE=v.prototype.writeUIntLE=function(P,O,$,Z){if(P=+P,O=O>>>0,$=$>>>0,!Z){let ae=Math.pow(2,8*$)-1;E(this,P,O,$,ae,0)}let te=1,X=0;for(this[O]=P&255;++X<$&&(te*=256);)this[O+X]=P/te&255;return O+$},v.prototype.writeUintBE=v.prototype.writeUIntBE=function(P,O,$,Z){if(P=+P,O=O>>>0,$=$>>>0,!Z){let ae=Math.pow(2,8*$)-1;E(this,P,O,$,ae,0)}let te=$-1,X=1;for(this[O+te]=P&255;--te>=0&&(X*=256);)this[O+te]=P/X&255;return O+$},v.prototype.writeUint8=v.prototype.writeUInt8=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,1,255,0),this[O]=P&255,O+1},v.prototype.writeUint16LE=v.prototype.writeUInt16LE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,2,65535,0),this[O]=P&255,this[O+1]=P>>>8,O+2},v.prototype.writeUint16BE=v.prototype.writeUInt16BE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,2,65535,0),this[O]=P>>>8,this[O+1]=P&255,O+2},v.prototype.writeUint32LE=v.prototype.writeUInt32LE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,4,4294967295,0),this[O+3]=P>>>24,this[O+2]=P>>>16,this[O+1]=P>>>8,this[O]=P&255,O+4},v.prototype.writeUint32BE=v.prototype.writeUInt32BE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,4,4294967295,0),this[O]=P>>>24,this[O+1]=P>>>16,this[O+2]=P>>>8,this[O+3]=P&255,O+4};function I(P,O,$,Z,te){F(O,Z,te,P,$,7);let X=Number(O&BigInt(4294967295));P[$++]=X,X=X>>8,P[$++]=X,X=X>>8,P[$++]=X,X=X>>8,P[$++]=X;let ae=Number(O>>BigInt(32)&BigInt(4294967295));return P[$++]=ae,ae=ae>>8,P[$++]=ae,ae=ae>>8,P[$++]=ae,ae=ae>>8,P[$++]=ae,$}function D(P,O,$,Z,te){F(O,Z,te,P,$,7);let X=Number(O&BigInt(4294967295));P[$+7]=X,X=X>>8,P[$+6]=X,X=X>>8,P[$+5]=X,X=X>>8,P[$+4]=X;let ae=Number(O>>BigInt(32)&BigInt(4294967295));return P[$+3]=ae,ae=ae>>8,P[$+2]=ae,ae=ae>>8,P[$+1]=ae,ae=ae>>8,P[$]=ae,$+8}v.prototype.writeBigUInt64LE=gt(function(P,O=0){return I(this,P,O,BigInt(0),BigInt("0xffffffffffffffff"))}),v.prototype.writeBigUInt64BE=gt(function(P,O=0){return D(this,P,O,BigInt(0),BigInt("0xffffffffffffffff"))}),v.prototype.writeIntLE=function(P,O,$,Z){if(P=+P,O=O>>>0,!Z){let qe=Math.pow(2,8*$-1);E(this,P,O,$,qe-1,-qe)}let te=0,X=1,ae=0;for(this[O]=P&255;++te<$&&(X*=256);)P<0&&ae===0&&this[O+te-1]!==0&&(ae=1),this[O+te]=(P/X>>0)-ae&255;return O+$},v.prototype.writeIntBE=function(P,O,$,Z){if(P=+P,O=O>>>0,!Z){let qe=Math.pow(2,8*$-1);E(this,P,O,$,qe-1,-qe)}let te=$-1,X=1,ae=0;for(this[O+te]=P&255;--te>=0&&(X*=256);)P<0&&ae===0&&this[O+te+1]!==0&&(ae=1),this[O+te]=(P/X>>0)-ae&255;return O+$},v.prototype.writeInt8=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,1,127,-128),P<0&&(P=255+P+1),this[O]=P&255,O+1},v.prototype.writeInt16LE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,2,32767,-32768),this[O]=P&255,this[O+1]=P>>>8,O+2},v.prototype.writeInt16BE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,2,32767,-32768),this[O]=P>>>8,this[O+1]=P&255,O+2},v.prototype.writeInt32LE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,4,2147483647,-2147483648),this[O]=P&255,this[O+1]=P>>>8,this[O+2]=P>>>16,this[O+3]=P>>>24,O+4},v.prototype.writeInt32BE=function(P,O,$){return P=+P,O=O>>>0,$||E(this,P,O,4,2147483647,-2147483648),P<0&&(P=4294967295+P+1),this[O]=P>>>24,this[O+1]=P>>>16,this[O+2]=P>>>8,this[O+3]=P&255,O+4},v.prototype.writeBigInt64LE=gt(function(P,O=0){return I(this,P,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),v.prototype.writeBigInt64BE=gt(function(P,O=0){return D(this,P,O,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function j(P,O,$,Z,te,X){if($+Z>P.length)throw new RangeError("Index out of range");if($<0)throw new RangeError("Index out of range")}function re(P,O,$,Z,te){return O=+O,$=$>>>0,te||j(P,O,$,4,34028234663852886e22,-34028234663852886e22),i.write(P,O,$,Z,23,4),$+4}v.prototype.writeFloatLE=function(P,O,$){return re(this,P,O,!0,$)},v.prototype.writeFloatBE=function(P,O,$){return re(this,P,O,!1,$)};function Q(P,O,$,Z,te){return O=+O,$=$>>>0,te||j(P,O,$,8,17976931348623157e292,-17976931348623157e292),i.write(P,O,$,Z,52,8),$+8}v.prototype.writeDoubleLE=function(P,O,$){return Q(this,P,O,!0,$)},v.prototype.writeDoubleBE=function(P,O,$){return Q(this,P,O,!1,$)},v.prototype.copy=function(P,O,$,Z){if(!v.isBuffer(P))throw new TypeError("argument should be a Buffer");if($||($=0),!Z&&Z!==0&&(Z=this.length),O>=P.length&&(O=P.length),O||(O=0),Z>0&&Z<$&&(Z=$),Z===$||P.length===0||this.length===0)return 0;if(O<0)throw new RangeError("targetStart out of bounds");if($<0||$>=this.length)throw new RangeError("Index out of range");if(Z<0)throw new RangeError("sourceEnd out of bounds");Z>this.length&&(Z=this.length),P.length-O<Z-$&&(Z=P.length-O+$);let te=Z-$;return this===P&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(O,$,Z):Uint8Array.prototype.set.call(P,this.subarray($,Z),O),te},v.prototype.fill=function(P,O,$,Z){if(typeof P=="string"){if(typeof O=="string"?(Z=O,O=0,$=this.length):typeof $=="string"&&(Z=$,$=this.length),Z!==void 0&&typeof Z!="string")throw new TypeError("encoding must be a string");if(typeof Z=="string"&&!v.isEncoding(Z))throw new TypeError("Unknown encoding: "+Z);if(P.length===1){let X=P.charCodeAt(0);(Z==="utf8"&&X<128||Z==="latin1")&&(P=X)}}else typeof P=="number"?P=P&255:typeof P=="boolean"&&(P=Number(P));if(O<0||this.length<O||this.length<$)throw new RangeError("Out of range index");if($<=O)return this;O=O>>>0,$=$===void 0?this.length:$>>>0,P||(P=0);let te;if(typeof P=="number")for(te=O;te<$;++te)this[te]=P;else{let X=v.isBuffer(P)?P:v.from(P,Z),ae=X.length;if(ae===0)throw new TypeError('The value "'+P+'" is invalid for argument "value"');for(te=0;te<$-O;++te)this[te+O]=X[te%ae]}return this};var L={};function U(P,O,$){L[P]=class extends ${constructor(){super(),Object.defineProperty(this,"message",{value:O.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${P}]`,this.stack,delete this.name}get code(){return P}set code(Z){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:Z,writable:!0})}toString(){return`${this.name} [${P}]: ${this.message}`}}}U("ERR_BUFFER_OUT_OF_BOUNDS",function(P){return P?`${P} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),U("ERR_INVALID_ARG_TYPE",function(P,O){return`The "${P}" argument must be of type number. Received type ${typeof O}`},TypeError),U("ERR_OUT_OF_RANGE",function(P,O,$){let Z=`The value of "${P}" is out of range.`,te=$;return Number.isInteger($)&&Math.abs($)>2**32?te=se(String($)):typeof $=="bigint"&&(te=String($),($>BigInt(2)**BigInt(32)||$<-(BigInt(2)**BigInt(32)))&&(te=se(te)),te+="n"),Z+=` It must be ${O}. Received ${te}`,Z},RangeError);function se(P){let O="",$=P.length,Z=P[0]==="-"?1:0;for(;$>=Z+4;$-=3)O=`_${P.slice($-3,$)}${O}`;return`${P.slice(0,$)}${O}`}function ee(P,O,$){K(O,"offset"),(P[O]===void 0||P[O+$]===void 0)&&G(O,P.length-($+1))}function F(P,O,$,Z,te,X){if(P>$||P<O){let ae=typeof O=="bigint"?"n":"",qe;throw X>3?O===0||O===BigInt(0)?qe=`>= 0${ae} and < 2${ae} ** ${(X+1)*8}${ae}`:qe=`>= -(2${ae} ** ${(X+1)*8-1}${ae}) and < 2 ** ${(X+1)*8-1}${ae}`:qe=`>= ${O}${ae} and <= ${$}${ae}`,new L.ERR_OUT_OF_RANGE("value",qe,P)}ee(Z,te,X)}function K(P,O){if(typeof P!="number")throw new L.ERR_INVALID_ARG_TYPE(O,"number",P)}function G(P,O,$){throw Math.floor(P)!==P?(K(P,$),new L.ERR_OUT_OF_RANGE($||"offset","an integer",P)):O<0?new L.ERR_BUFFER_OUT_OF_BOUNDS:new L.ERR_OUT_OF_RANGE($||"offset",`>= ${$?1:0} and <= ${O}`,P)}var ne=/[^+/0-9A-Za-z-_]/g;function Re(P){if(P=P.split("=")[0],P=P.trim().replace(ne,""),P.length<2)return"";for(;P.length%4!==0;)P=P+"=";return P}function ie(P,O){O=O||1/0;let $,Z=P.length,te=null,X=[];for(let ae=0;ae<Z;++ae){if($=P.charCodeAt(ae),$>55295&&$<57344){if(!te){if($>56319){(O-=3)>-1&&X.push(239,191,189);continue}else if(ae+1===Z){(O-=3)>-1&&X.push(239,191,189);continue}te=$;continue}if($<56320){(O-=3)>-1&&X.push(239,191,189),te=$;continue}$=(te-55296<<10|$-56320)+65536}else te&&(O-=3)>-1&&X.push(239,191,189);if(te=null,$<128){if((O-=1)<0)break;X.push($)}else if($<2048){if((O-=2)<0)break;X.push($>>6|192,$&63|128)}else if($<65536){if((O-=3)<0)break;X.push($>>12|224,$>>6&63|128,$&63|128)}else if($<1114112){if((O-=4)<0)break;X.push($>>18|240,$>>12&63|128,$>>6&63|128,$&63|128)}else throw new Error("Invalid code point")}return X}function oe(P){let O=[];for(let $=0;$<P.length;++$)O.push(P.charCodeAt($)&255);return O}function Be(P,O){let $,Z,te,X=[];for(let ae=0;ae<P.length&&!((O-=2)<0);++ae)$=P.charCodeAt(ae),Z=$>>8,te=$%256,X.push(te),X.push(Z);return X}function he(P){return e.toByteArray(Re(P))}function ye(P,O,$,Z){let te;for(te=0;te<Z&&!(te+$>=O.length||te>=P.length);++te)O[te+$]=P[te];return te}function dt(P,O){return P instanceof O||P!=null&&P.constructor!=null&&P.constructor.name!=null&&P.constructor.name===O.name}function Me(P){return P!==P}var ke=function(){let P="0123456789abcdef",O=new Array(256);for(let $=0;$<16;++$){let Z=$*16;for(let te=0;te<16;++te)O[Z+te]=P[$]+P[te]}return O}();function gt(P){return typeof BigInt>"u"?V:P}function V(){throw new Error("BigInt not supported")}}),CFe=v0((t,e)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,e.exports={Buffer:$C().Buffer,Crypto:window.crypto}):e.exports={Buffer:$C().Buffer,Crypto:crypto}}),Bce={};IFe(Bce,{AVSCTap:()=>Xy,ArweaveSigner:()=>f$,DataItem:()=>Zy,MAX_TAG_BYTES:()=>E7,MIN_BINARY_SIZE:()=>l$,SIG_CONFIG:()=>Gm,SignatureConfig:()=>Zf,Signer:()=>Pce,createData:()=>$ce,deserializeTags:()=>v7,indexToType:()=>u$,serializeTags:()=>h$,tagsExceedLimit:()=>Cce});var Pce=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(t,e,i,f){throw new Error("You must implement verify method on child")}},$Fe=y1(s$(),1),Hu=y1(kce(),1);async function Oce(t){if(Array.isArray(t)){let n=(0,Hu.concatBuffers)([(0,Hu.stringToBuffer)("list"),(0,Hu.stringToBuffer)(t.length.toString())]);return await Nce(t,await l0().hash(n,"SHA-384"))}let e=t,i=(0,Hu.concatBuffers)([(0,Hu.stringToBuffer)("blob"),(0,Hu.stringToBuffer)(e.byteLength.toString())]),f=(0,Hu.concatBuffers)([await l0().hash(i,"SHA-384"),await l0().hash(e,"SHA-384")]);return await l0().hash(f,"SHA-384")}async function Nce(t,e){if(t.length<1)return e;let i=(0,Hu.concatBuffers)([e,await Oce(t[0])]),f=await l0().hash(i,"SHA-384");return await Nce(t.slice(1),f)}var cC=y1(OFe(),1),LFe=cC.default.default?cC.default.default:cC.default,DFe=class extends LFe{getPublicKey(t){throw new Error("Unimplemented")}},qFe;function l0(){return qFe??=new DFe}var Zf;(function(t){t[t.ARWEAVE=1]="ARWEAVE",t[t.ED25519=2]="ED25519",t[t.ETHEREUM=3]="ETHEREUM",t[t.SOLANA=4]="SOLANA",t[t.INJECTEDAPTOS=5]="INJECTEDAPTOS",t[t.MULTIAPTOS=6]="MULTIAPTOS",t[t.TYPEDETHEREUM=7]="TYPEDETHEREUM"})(Zf||(Zf={}));var Gm={[Zf.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[Zf.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[Zf.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[Zf.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[Zf.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[Zf.MULTIAPTOS]:{sigLength:64*32+4,pubLength:32*32+1,sigName:"multiAptos"},[Zf.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},f$=class{signatureType=1;ownerLength=Gm[1].pubLength;signatureLength=Gm[1].sigLength;jwk;pk;constructor(t){this.pk=t.n,this.jwk=t}get publicKey(){return $Fe.default.toBuffer(this.pk)}sign(t){return l0().sign(this.jwk,t)}static async verify(t,e,i){return await l0().verify(t,e,i)}},u$={1:f$},el=y1(s$(),1);async function LC(t){return Oce([(0,Hu.stringToBuffer)("dataitem"),(0,Hu.stringToBuffer)("1"),(0,Hu.stringToBuffer)(t.signatureType.toString()),t.rawOwner,t.rawTarget,t.rawAnchor,t.rawTags,t.rawData])}async function UFe(t,e){let i=await LC(t),f=await e.sign(i),n=await l0().hash(f);return{signature:De.from(f),id:De.from(n)}}async function FFe(t,e){let{signature:i,id:f}=await UFe(t,e);return t.getRaw().set(i,2),f}var Xy=class{buf;pos;constructor(t=De.alloc(E7),e=0){this.buf=t,this.pos=e}writeTags(t){if(!Array.isArray(t))throw new Error("input must be array");let e=t.length,i;if(e)for(this.writeLong(e),i=0;i<e;i++){let f=t[i];if(f?.name===void 0||f?.value===void 0)throw new Error(`Invalid tag format for ${f}, expected {name:string, value: string}`);this.writeString(f.name),this.writeString(f.value)}this.writeLong(0)}toBuffer(){let t=De.alloc(this.pos);if(this.pos>this.buf.length)throw new Error(`Too many tag bytes (${this.pos} > ${this.buf.length})`);return this.buf.copy(t,0,0,this.pos),t}tagsExceedLimit(){return this.pos>this.buf.length}writeLong(t){let e=this.buf,i,f;if(t>=-1073741824&&t<1073741824){f=t>=0?t<<1:~t<<1|1;do e[this.pos]=f&127,f>>=7;while(f&&(e[this.pos++]|=128))}else{i=t>=0?t*2:-t*2-1;do e[this.pos]=i&127,i/=128;while(i>=1&&(e[this.pos++]|=128))}this.pos++,this.buf=e}writeString(t){let e=De.byteLength(t),i=this.buf;this.writeLong(e);let f=this.pos;if(this.pos+=e,!(this.pos>i.length)){if(e>64)this.buf.write(t,this.pos-e,e,"utf8");else{let n,l,p,v;for(n=0,l=e;n<l;n++)p=t.charCodeAt(n),p<128?i[f++]=p:p<2048?(i[f++]=p>>6|192,i[f++]=p&63|128):(p&64512)===55296&&((v=t.charCodeAt(n+1))&64512)===56320?(p=65536+((p&1023)<<10)+(v&1023),n++,i[f++]=p>>18|240,i[f++]=p>>12&63|128,i[f++]=p>>6&63|128,i[f++]=p&63|128):(i[f++]=p>>12|224,i[f++]=p>>6&63|128,i[f++]=p&63|128)}this.buf=i}}readLong(){let t=0,e=0,i=this.buf,f,n,l,p;do f=i[this.pos++],n=f&128,t|=(f&127)<<e,e+=7;while(n&&e<28);if(n){l=t,p=268435456;do f=i[this.pos++],l+=(f&127)*p,p*=128;while(f&128);return(l%2?-(l+1):l)/2}return t>>1^-(t&1)}skipLong(){let t=this.buf;for(;t[this.pos++]&128;);}readTags(){let t=[],e;for(;e=this.readLong();)for(e<0&&(e=-e,this.skipLong());e--;){let i=this.readString(),f=this.readString();t.push({name:i,value:f})}return t}readString(){let t=this.readLong(),e=this.pos,i=this.buf;if(this.pos+=t,!(this.pos>i.length))return this.buf.slice(e,e+t).toString()}};function h$(t){let e=new Xy;return e.writeTags(t),e.toBuffer()}function Cce(t){let e=new Xy;return e.writeTags(t),e.tagsExceedLimit()}function v7(t){return new Xy(t).readTags()}function Yc(t){let e=0;for(let i=t.length-1;i>=0;i--)e=e*256+t[i];return e}function jFe(t){if(t>29)throw new Error("Short too long");let e=[0,0];for(let i=0;i<e.length;i++){let f=t&255;e[i]=f,t=(t-f)/256}return Uint8Array.from(e)}function Xle(t){let e=[0,0,0,0,0,0,0,0];for(let i=0;i<e.length;i++){let f=t&255;e[i]=f,t=(t-f)/256}return Uint8Array.from(e)}var zFe=y1(CFe(),1),Im=y1($C(),1),E7=4096,l$=80,Zy=class{binary;_id;constructor(t){this.binary=t}static isDataItem(t){return t.binary!==void 0}get signatureType(){let t=Yc(this.binary.subarray(0,2));if(Zf?.[t]!==void 0)return t;throw new Error("Unknown signature type: "+t)}async isValid(){return Zy.verify(this.binary)}get id(){return(async()=>el.default.encode(await this.rawId))()}set id(t){this._id=el.default.toBuffer(t)}get rawId(){return(async()=>Im.Buffer.from(await zFe.Crypto.subtle.digest("SHA-256",this.rawSignature)))()}set rawId(t){this._id=t}get rawSignature(){return this.binary.subarray(2,2+this.signatureLength)}get signature(){return el.default.encode(this.rawSignature)}set rawOwner(t){if(t.byteLength!=this.ownerLength)throw new Error(`Expected raw owner (pubkey) to be ${this.ownerLength} bytes, got ${t.byteLength} bytes.`);this.binary.set(t,2+this.signatureLength)}get rawOwner(){return this.binary.subarray(2+this.signatureLength,2+this.signatureLength+this.ownerLength)}get signatureLength(){return Gm[this.signatureType].sigLength}get owner(){return el.default.encode(this.rawOwner)}get ownerLength(){return Gm[this.signatureType].pubLength}get rawTarget(){let t=this.getTargetStart();return this.binary[t]==1?this.binary.subarray(t+1,t+33):Im.Buffer.alloc(0)}get target(){return el.default.encode(this.rawTarget)}get rawAnchor(){let t=this.getAnchorStart();return this.binary[t]==1?this.binary.subarray(t+1,t+33):Im.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let t=this.getTagsStart(),e=Yc(this.binary.subarray(t+8,t+16));return this.binary.subarray(t+16,t+16+e)}get tags(){let t=this.getTagsStart();if(Yc(this.binary.subarray(t,t+8))==0)return[];let e=Yc(this.binary.subarray(t+8,t+16));return v7(Im.Buffer.from(this.binary.subarray(t+16,t+16+e)))}get tagsB64Url(){return this.tags.map(t=>({name:el.default.encode(t.name),value:el.default.encode(t.value)}))}getStartOfData(){let t=this.getTagsStart(),e=this.binary.subarray(t+8,t+16),i=Yc(e);return t+16+i}get rawData(){let t=this.getTagsStart(),e=this.binary.subarray(t+8,t+16),i=Yc(e),f=t+16+i;return this.binary.subarray(f,this.binary.length)}get data(){return el.default.encode(this.rawData)}getRaw(){return this.binary}async sign(t){return this._id=await FFe(this,t),this.rawId}async setSignature(t){this.binary.set(t,2),this._id=Im.Buffer.from(await l0().hash(t))}isSigned(){return(this._id?.length??0)>0}toJSON(){return{signature:this.signature,owner:this.owner,target:this.target,tags:this.tags.map(t=>({name:el.default.encode(t.name),value:el.default.encode(t.value)})),data:this.data}}static async verify(t){if(t.byteLength<l$)return!1;let e=new Zy(t),i=e.signatureType,f=e.getTagsStart(),n=Yc(t.subarray(f,f+8)),l=t.subarray(f+8,f+16),p=Yc(l);if(p>E7)return!1;if(n>0)try{if(v7(Im.Buffer.from(t.subarray(f+16,f+16+p))).length!==n)return!1}catch{return!1}let v=u$[i],_=await LC(e);return await v.verify(e.rawOwner,_,e.rawSignature)}async getSignatureData(){return LC(this)}getTagsStart(){let t=this.getTargetStart(),e=this.binary[t]==1,i=t+(e?33:1),f=this.binary[i]==1;return i+=f?33:1,i}getTargetStart(){return 2+this.signatureLength+this.ownerLength}getAnchorStart(){let t=this.getTargetStart()+1,e=this.binary[this.getTargetStart()]==1;return t+=e?32:0,t}},HFe=y1(s$(),1);function $ce(t,e,i){let f=e.publicKey,n=i?.target?HFe.default.toBuffer(i.target):null,l=1+(n?.byteLength??0),p=i?.anchor?De.from(i.anchor):null,v=1+(p?.byteLength??0),_=(i?.tags?.length??0)>0?h$(i.tags):null,g=16+(_?_.byteLength:0),y=De.from(t),M=y.byteLength,x=2+e.signatureLength+e.ownerLength+l+v+g+M,S=De.alloc(x);if(S.set(jFe(e.signatureType),0),S.set(new Uint8Array(e.signatureLength).fill(0),2),f.byteLength!==e.ownerLength)throw new Error(`Owner must be ${e.ownerLength} bytes, but was incorrectly ${f.byteLength}`);S.set(f,2+e.signatureLength);let R=2+e.signatureLength+e.ownerLength;if(S[R]=n?1:0,n){if(n.byteLength!==32)throw new Error(`Target must be 32 bytes but was incorrectly ${n.byteLength}`);S.set(n,R+1)}let T=R+l,k=T+1;if(S[T]=p?1:0,p){if(k+=p.byteLength,p.byteLength!==32)throw new Error("Anchor must be 32 bytes");S.set(p,T+1)}S.set(Xle(i?.tags?.length??0),k);let B=Xle(_?.byteLength??0);S.set(B,k+8),_&&S.set(_,k+16);let C=k+g;return S.set(y,C),new Zy(S)}var c$={...Bce};globalThis.arbundles??=c$;var WFe=c$,KFe=c$;globalThis.Buffer||(globalThis.Buffer=Rce.Buffer);var{DataItem:ZFe}=Tce;function VFe(t){return async({data:i,tags:f,target:n,anchor:l,createDataItem:p=v=>new ZFe(v)})=>{let v=await t.signDataItem({data:i,tags:f,target:n,anchor:l}),_=p(Rce.Buffer.from(v));return{id:await _.id,raw:await _.getRaw()}}}var GFe=globalThis.GATEWAY_URL||void 0,YFe=globalThis.MU_URL||void 0,JFe=globalThis.CU_URL||void 0,XFe=globalThis.GRAPHQL_URL||void 0,{result:Nwt,results:Cwt,message:$wt,spawn:Lwt,monitor:Dwt,unmonitor:qwt,dryrun:Uwt,assign:Fwt}=Ls({GATEWAY_URL:GFe,MU_URL:YFe,CU_URL:JFe,GRAPHQL_URL:XFe}),Lce=Ace.createDataItemSigner;de();ve();pe();var kde=Hi(Ide(),1),N7=kde.default.init({host:"arweave.net",port:443,protocol:"https"});de();ve();pe();de();ve();pe();var Ju=class extends Error{constructor(e){super(e),this.name=this.constructor.name}},Bde=class extends Ju{},Pde=class extends Ju{},Ode=class extends Ju{constructor(e,i){super(`Failed request: ${e}: ${i}`)}},Nde=class extends Ju{},C7=class extends Ju{},Cde=class extends Ju{constructor(){super("Invalid signer. Please provide a valid signer to interact with the contract.")}},fl=class extends Ju{constructor(){super("Invalid contract configuration")}},$de=class extends Ju{constructor(){super("Invalid process configuration")}},Lde=class extends Ju{};de();ve();pe();var ah=Hi(Wbe(),1);de();ve();pe();var z_="3.10.1";var pl=class t{logger;silent=!1;static default=new t;constructor({level:e="info"}={}){e==="none"&&(this.silent=!0),typeof window<"u"?this.logger=console:this.logger=(0,ah.createLogger)({level:e,silent:this.silent,defaultMeta:{name:"ar-io-sdk",version:z_},format:ah.format.combine(ah.format.timestamp(),ah.format.json()),transports:[new ah.transports.Console({format:ah.format.combine(ah.format.timestamp(),ah.format.json())})]})}info(e,...i){this.silent||this.logger.info(e,...i)}warn(e,...i){this.silent||this.logger.warn(e,...i)}error(e,...i){this.silent||this.logger.error(e,...i)}debug(e,...i){this.silent||this.logger.debug(e,...i)}setLogLevel(e){this.silent=e==="none","silent"in this.logger&&(this.logger.silent=e==="none"),"level"in this.logger&&(this.logger.level=e)}};de();ve();pe();de();ve();pe();var Kbe=t=>{let e=Object.entries(t).sort(([i,f],[n,l])=>i==="@"?-1:n==="@"?1:"priority"in f&&!("priority"in l)?-1:!("priority"in f)&&"priority"in l?1:f.priority!==void 0&&l.priority!==void 0?f.priority===l.priority?i<n?-1:i>n?1:0:f.priority-l.priority:i<n?-1:i>n?1:0);return Object.fromEntries(e.map(([i,f],n)=>[i,{...f,index:n}]))};de();ve();pe();function cd(t,e){let i=t.safeParse(e);if(!i.success)throw new Error(JSON.stringify(i.error.format(),null,2));return i}de();ve();pe();de();ve();pe();de();ve();pe();kh();var Zbe="+",Vbe="/",Gbe="-",Ybe="_",Jbe="=";function nit(t){let e=t.length%4;return e&&(t+=Jbe.repeat(4-e)),t.replaceAll(Gbe,Zbe).replaceAll(Ybe,Vbe)}function ait(t){return t.replaceAll(Zbe,Gbe).replaceAll(Vbe,Ybe).replaceAll(Jbe,"")}function pTt(t){let e=nit(t);return De.from(e,"base64")}function oit(t){let e=t.toString("base64");return ait(e)}function vTt(t){return oit(Au("sha256").update(Uint8Array.from(t)).digest())}function Xbe(t=32){let e=Lk(t);return Array.from(e,i=>i.toString(16).padStart(2,"0")).join("").slice(0,t)}de();ve();pe();de();ve();pe();function wq(t){try{return JSON.parse(t)}catch{return t}}de();ve();pe();de();ve();pe();var Mq=Hi(eye(),1);de();ve();pe();var uit=Object.defineProperty,hit=(t,e,i)=>e in t?uit(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,K6=(t,e,i)=>(hit(t,typeof e!="symbol"?e+"":e,i),i),xq=class{constructor(e){K6(this,"value"),K6(this,"next"),this.value=e}},Sq=class{constructor(){K6(this,"head"),K6(this,"tail"),K6(this,"_size",0),this.clear()}clear(){this.head=void 0,this.tail=void 0,this._size=0}push(e){let i=new xq(e);return this.head&&this.tail?(this.tail.next=i,this.tail=i):(this.head=i,this.tail=i),this._size++,this._size}pop(){if(!this.head)return;let e=this.head;return this.head=this.head.next,this._size--,e.value}get size(){return this._size}*[Symbol.iterator](){let e=this.head;for(;e;)yield e.value,e=e.next}};function tye(t){if(!((Number.isInteger(t)||t===1/0)&&t>0))throw new TypeError("Expected `concurrency` to be a number greater than 1");let e=new Sq,i=0,f=()=>{i--,e.size>0&&e.pop()()},n=async(v,_,g)=>{i++;let y=(async()=>v(...g))();_(y);try{await y}catch{}f()},l=(v,_,g)=>{e.push(n.bind(null,v,_,g)),(async()=>(await Promise.resolve(),i<t&&e.size>0&&e.pop()()))()},p=(v,..._)=>new Promise(g=>{l(v,g,_)});return Object.defineProperties(p,{activeCount:{get:()=>i},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),p}de();ve();pe();var Z6=class{static init(e){return e!==void 0&&"signer"in e?new Eq(e):new W_(e)}},W_=class{process;constructor(e){if(e===void 0||Object.keys(e).length===0)this.process=new ia({processId:Rm});else if(pd(e))this.process=e.process;else if(vd(e))this.process=new ia({processId:e.processId});else throw new fl}async accessControlList({address:e}){return this.process.read({tags:[{name:"Action",value:"Access-Control-List"},{name:"Address",value:e}]})}},Eq=class extends W_{signer;constructor({signer:e,...i}){super(i),this.signer=dd(e)}async register({processId:e}){return this.process.send({tags:[{name:"Action",value:"Register"},{name:"Process-Id",value:e}],signer:this.signer})}};de();ve();pe();de();ve();pe();var lit="https://faucet.ario.permaweb.services";function Rq({arioInstance:t,faucetApiUrl:e=lit}){let i=new Aq({faucetUrl:e,processId:t.process.processId});return new Proxy(t,{get(n,l){if(l==="faucet")return i;if(l in n){let p=n[l];return typeof p=="function"?p.bind(n):p}}})}var Aq=class{faucetUrl;processId;constructor({faucetUrl:e,processId:i}){this.faucetUrl=e,this.processId=i}async captchaUrl(){let e=await fetch(`${this.faucetUrl}/api/captcha/url?process-id=${this.processId}`,{method:"GET"});if(!e.ok){let f=await e.json().catch(()=>({error:e.statusText}));throw new Error(f.error)}return await e.json()}async claimWithCaptchaResponse({captchaResponse:e,recipient:i,quantity:f}){let n=await fetch(`${this.faucetUrl}/api/claim/sync`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processId:this.processId,recipient:i,quantity:f,captchaResponse:e})});if(!n.ok){let p=await n.json().catch(()=>({error:n.statusText}));throw new Error(p.error)}return await n.json()}async requestAuthToken({captchaResponse:e}){let i=await fetch(`${this.faucetUrl}/api/captcha/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processId:this.processId,captchaResponse:e})});if(!i.ok){let n=await i.json().catch(()=>({error:i.statusText}));throw new Error(n.error)}return await i.json()}async claimWithAuthToken({authToken:e,recipient:i,quantity:f}){let n=await fetch(`${this.faucetUrl}/api/claim/async`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({recipient:i,qty:f,processId:this.processId})});if(!n.ok){let p=await n.json().catch(()=>({error:n.statusText}));throw new Error(p.error)}return await n.json()}async verifyAuthToken({authToken:e}){let i=await fetch(`${this.faucetUrl}/api/token/verify?process-id=${this.processId}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}});if(!i.ok){let n=await i.json().catch(()=>({error:i.statusText}));throw new Error(n.error)}return await i.json()}};var G6=class{static init(e){return e!==void 0&&"signer"in e?new V6(e):new wg(e)}static mainnet(e){return e!==void 0&&"signer"in e?new V6({...e,process:new ia({processId:ns,ao:Ls({CU_URL:"https://cu.ardrive.io",...e?.process?.ao})})}):new wg({...e,process:new ia({processId:ns,ao:Ls({CU_URL:"https://cu.ardrive.io",...e?.process?.ao})})})}static testnet(e){return e!==void 0&&"signer"in e?Rq({arioInstance:new V6({...e,process:new ia({processId:JN,ao:Ls({CU_URL:"https://cu.ardrive.io",...e?.process?.ao})})}),faucetApiUrl:e?.faucetUrl}):Rq({arioInstance:new wg({...e,process:new ia({processId:JN,ao:Ls({CU_URL:"https://cu.ardrive.io",...e?.process?.ao})})}),faucetApiUrl:e?.faucetUrl})}},wg=class{process;epochSettings;arweave;constructor(e){if(this.arweave=e?.arweave??N7,e===void 0||Object.keys(e).length===0)this.process=new ia({processId:ns});else if(pd(e))this.process=e.process;else if(vd(e))this.process=new ia({processId:e.processId});else throw new fl}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(e){let i=await this.getEpochSettings(),f=i.epochZeroStartTimestamp,n=i.durationMs;return Math.floor((e-f)/n)}async computeCurrentEpochIndex(){return this.computeEpochIndexForTimestamp(Date.now())}async computeEpochIndex(e){let i=e?.epochIndex;if(i!==void 0)return i;let f=e?.timestamp;if(f!==void 0)return this.computeEpochIndexForTimestamp(f)}async getEpochSettings(){return this.epochSettings??=await this.process.read({tags:[{name:"Action",value:"Epoch-Settings"}]})}async getEpoch(e){let i=await this.computeEpochIndex(e),f=await this.computeCurrentEpochIndex();if(i!==void 0&&i<f){let l=await D1({arweave:this.arweave,epochIndex:i,processId:this.process.processId,ao:this.process.ao});if(!l)throw new Error("Epoch data not found for epoch index "+i);return iye(l)}let n=[{name:"Action",value:"Epoch"},{name:"Epoch-Index",value:f.toString()}];return this.process.read({tags:Ln(n)})}async getArNSRecord({name:e}){return this.process.read({tags:[{name:"Action",value:"Record"},{name:"Name",value:e}]})}async getArNSRecords(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Records"},...To(e)]})}async getArNSReservedNames(e){return this.process.read({tags:[{name:"Action",value:"Reserved-Names"},...To(e)]})}async getArNSReservedName({name:e}){return this.process.read({tags:[{name:"Action",value:"Reserved-Name"},{name:"Name",value:e}]})}async getBalance({address:e}){return this.process.read({tags:[{name:"Action",value:"Balance"},{name:"Address",value:e}]})}async getBalances(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Balances"},...To(e)]})}async getVault({address:e,vaultId:i}){return this.process.read({tags:[{name:"Action",value:"Vault"},{name:"Address",value:e},{name:"Vault-Id",value:i}]})}async getVaults(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Vaults"},...To(e)]})}async getGateway({address:e}){return this.process.read({tags:[{name:"Action",value:"Gateway"},{name:"Address",value:e}]})}async getGatewayDelegates({address:e,...i}){return this.process.read({tags:[{name:"Action",value:"Paginated-Delegates"},{name:"Address",value:e},...To(i)]})}async getGatewayDelegateAllowList({address:e,...i}){return this.process.read({tags:[{name:"Action",value:"Paginated-Allowed-Delegates"},{name:"Address",value:e},...To(i)]})}async getGateways(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateways"},...To(e)]})}async getCurrentEpoch(){return this.process.read({tags:[{name:"Action",value:"Epoch"}]})}async getPrescribedObservers(e){let i=await this.computeEpochIndex(e),f=await this.computeCurrentEpochIndex();if(i!==void 0&&i<f){let l=await D1({ao:this.process.ao,arweave:this.arweave,epochIndex:i,processId:this.process.processId});if(!l)throw new Error("Epoch data not found for epoch index "+i);return l.prescribedObservers}let n=[{name:"Action",value:"Epoch-Prescribed-Observers"},{name:"Epoch-Index",value:f.toString()}];return this.process.read({tags:Ln(n)})}async getPrescribedNames(e){let i=await this.computeEpochIndex(e),f=await this.computeCurrentEpochIndex();if(i!==void 0&&i<f){let l=await D1({arweave:this.arweave,epochIndex:i,processId:this.process.processId,ao:this.process.ao});if(!l)throw new Error("Epoch data not found for epoch index "+i);return l.prescribedNames}let n=[{name:"Action",value:"Epoch-Prescribed-Names"},{name:"Epoch-Index",value:f.toString()}];return this.process.read({tags:Ln(n)})}async getObservations(e){let i=await this.computeEpochIndex(e),f=await this.computeCurrentEpochIndex();if(i!==void 0&&i<f){let l=await D1({arweave:this.arweave,epochIndex:i,processId:this.process.processId,ao:this.process.ao});if(!l)throw new Error("Epoch data not found for epoch index "+i);return l.observations}let n=[{name:"Action",value:"Epoch-Observations"},{name:"Epoch-Index",value:f.toString()}];return this.process.read({tags:Ln(n)})}async getDistributions(e){let i=await this.computeEpochIndex(e),f=await this.computeCurrentEpochIndex();if(i!==void 0&&i<f){let l=await D1({arweave:this.arweave,epochIndex:i,processId:this.process.processId,ao:this.process.ao});if(l===void 0)throw new Error("Epoch data not found for epoch index "+i);return l.distributions}let n=[{name:"Action",value:"Epoch-Distributions"},{name:"Epoch-Index",value:f.toString()}];return this.process.read({tags:Ln(n)})}async getEligibleEpochRewards(e,i){let f=await this.computeEpochIndex(e),n=await this.computeCurrentEpochIndex();if(f!==void 0&&f<n){let p=await D1({arweave:this.arweave,epochIndex:f,processId:this.process.processId,ao:this.process.ao});if(!p)throw new Error("Epoch data not found for epoch index "+f);return rye(p,i)}let l=[{name:"Action",value:"Epoch-Eligible-Rewards"},...To(i)];return this.process.read({tags:Ln(l)})}async getTokenCost({intent:e,type:i,years:f,name:n,quantity:l,fromAddress:p}){let _=[{name:"Action",value:"Token-Cost"},{name:"Intent",value:e==="Buy-Record"?"Buy-Name":e},{name:"Name",value:n},{name:"Years",value:f?.toString()},{name:"Quantity",value:l?.toString()},{name:"Purchase-Type",value:i}];return this.process.read({tags:Ln(_),fromAddress:p})}async getCostDetails({intent:e,type:i,years:f,name:n,quantity:l,fromAddress:p,fundFrom:v}){let g=[{name:"Action",value:"Cost-Details"},{name:"Intent",value:e==="Buy-Record"?"Buy-Name":e},{name:"Name",value:n},{name:"Years",value:f?.toString()},{name:"Quantity",value:l?.toString()},{name:"Purchase-Type",value:i},{name:"Fund-From",value:v}];return this.process.read({tags:Ln(g),fromAddress:p})}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(e){return this.process.read({tags:[{name:"Action",value:"Returned-Names"},...To(e)]})}async getArNSReturnedName({name:e}){let i=[{name:"Action",value:"Returned-Name"},{name:"Name",value:e}];return this.process.read({tags:i})}async getDelegations(e){let i=[{name:"Action",value:"Paginated-Delegations"},{name:"Address",value:e.address},...To(e)];return this.process.read({tags:Ln(i)})}async getAllowedDelegates(e){return this.getGatewayDelegateAllowList(e)}async getGatewayVaults(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateway-Vaults"},{name:"Address",value:e.address},...To(e)]})}async getPrimaryNameRequest(e){let i=[{name:"Action",value:"Primary-Name-Request"},{name:"Initiator",value:e.initiator}];return this.process.read({tags:i})}async getPrimaryNameRequests(e){return this.process.read({tags:[{name:"Action",value:"Primary-Name-Requests"},...To(e)]})}async getPrimaryName(e){let i=[{name:"Action",value:"Primary-Name"},{name:"Address",value:e?.address},{name:"Name",value:e?.name}];return this.process.read({tags:Ln(i)})}async getPrimaryNames(e){return this.process.read({tags:[{name:"Action",value:"Primary-Names"},...To(e)]})}async getRedelegationFee(e){return this.process.read({tags:[{name:"Action",value:"Redelegation-Fee"},{name:"Address",value:e.address}]})}async getGatewayRegistrySettings(){return this.process.read({tags:[{name:"Action",value:"Gateway-Registry-Settings"}]})}async getAllDelegates(e){return this.process.read({tags:[{name:"Action",value:"All-Paginated-Delegates"},...To(e)]})}async getAllGatewayVaults(e){return this.process.read({tags:[{name:"Action",value:"All-Gateway-Vaults"},...To(e)]})}},V6=class extends wg{signer;constructor({signer:e,...i}){i===void 0?super({process:new ia({processId:ns})}):super(i),this.signer=dd(e)}async transfer({target:e,qty:i},f){let{tags:n=[]}=f||{};return this.process.send({tags:[...n,{name:"Action",value:"Transfer"},{name:"Recipient",value:e},{name:"Quantity",value:i.valueOf().toString()}],signer:this.signer})}async vaultedTransfer({recipient:e,quantity:i,lockLengthMs:f,revokable:n=!1},l){let{tags:p=[]}=l||{};return this.process.send({tags:[...p,{name:"Action",value:"Vaulted-Transfer"},{name:"Recipient",value:e},{name:"Quantity",value:i.toString()},{name:"Lock-Length",value:f.toString()},{name:"Revokable",value:`${n}`}],signer:this.signer})}async revokeVault({vaultId:e,recipient:i},f){let{tags:n=[]}=f||{};return this.process.send({tags:[...n,{name:"Action",value:"Revoke-Vault"},{name:"Vault-Id",value:e},{name:"Recipient",value:i}],signer:this.signer})}async createVault({lockLengthMs:e,quantity:i},f){let{tags:n=[]}=f||{};return this.process.send({tags:[...n,{name:"Action",value:"Create-Vault"},{name:"Lock-Length",value:e.toString()},{name:"Quantity",value:i.toString()}],signer:this.signer})}async extendVault({vaultId:e,extendLengthMs:i},f){let{tags:n=[]}=f||{};return this.process.send({tags:[...n,{name:"Action",value:"Extend-Vault"},{name:"Vault-Id",value:e},{name:"Extend-Length",value:i.toString()}],signer:this.signer})}async increaseVault({vaultId:e,quantity:i},f){let{tags:n=[]}=f||{};return this.process.send({tags:[...n,{name:"Action",value:"Increase-Vault"},{name:"Vault-Id",value:e},{name:"Quantity",value:i.toString()}],signer:this.signer})}async joinNetwork({operatorStake:e,allowDelegatedStaking:i,allowedDelegates:f,delegateRewardShareRatio:n,fqdn:l,label:p,minDelegatedStake:v,note:_,port:g,properties:y,protocol:M,autoStake:x,observerAddress:S},R){let{tags:T=[]}=R||{},k=[...T,{name:"Action",value:"Join-Network"},{name:"Operator-Stake",value:e.valueOf().toString()},{name:"Allow-Delegated-Staking",value:i?.toString()},{name:"Allowed-Delegates",value:f?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:n?.toString()},{name:"FQDN",value:l},{name:"Label",value:p},{name:"Min-Delegated-Stake",value:v?.valueOf().toString()},{name:"Note",value:_},{name:"Port",value:g?.toString()},{name:"Properties",value:y},{name:"Protocol",value:M},{name:"Auto-Stake",value:x?.toString()},{name:"Observer-Address",value:S}];return this.process.send({signer:this.signer,tags:Ln(k)})}async leaveNetwork(e){let{tags:i=[]}=e||{};return this.process.send({signer:this.signer,tags:[...i,{name:"Action",value:"Leave-Network"}]})}async updateGatewaySettings({allowDelegatedStaking:e,allowedDelegates:i,delegateRewardShareRatio:f,fqdn:n,label:l,minDelegatedStake:p,note:v,port:_,properties:g,protocol:y,autoStake:M,observerAddress:x},S){let{tags:R=[]}=S||{},T=[...R,{name:"Action",value:"Update-Gateway-Settings"},{name:"Label",value:l},{name:"Note",value:v},{name:"FQDN",value:n},{name:"Port",value:_?.toString()},{name:"Properties",value:g},{name:"Protocol",value:y},{name:"Observer-Address",value:x},{name:"Allow-Delegated-Staking",value:e?.toString()},{name:"Allowed-Delegates",value:i?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:f?.toString()},{name:"Min-Delegated-Stake",value:p?.valueOf().toString()},{name:"Auto-Stake",value:M?.toString()}];return this.process.send({signer:this.signer,tags:Ln(T)})}async delegateStake(e,i){let{tags:f=[]}=i||{};return this.process.send({signer:this.signer,tags:[...f,{name:"Action",value:"Delegate-Stake"},{name:"Target",value:e.target},{name:"Quantity",value:e.stakeQty.valueOf().toString()}]})}async decreaseDelegateStake(e,i){let{tags:f=[]}=i||{};return this.process.send({signer:this.signer,tags:[...f,{name:"Action",value:"Decrease-Delegate-Stake"},{name:"Target",value:e.target},{name:"Quantity",value:e.decreaseQty.valueOf().toString()},{name:"Instant",value:`${e.instant||!1}`}]})}async instantWithdrawal(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Instant-Withdrawal"},{name:"Vault-Id",value:e.vaultId},{name:"Address",value:e.gatewayAddress}];return this.process.send({signer:this.signer,tags:Ln(n)})}async increaseOperatorStake(e,i){let{tags:f=[]}=i||{};return this.process.send({signer:this.signer,tags:[...f,{name:"Action",value:"Increase-Operator-Stake"},{name:"Quantity",value:e.increaseQty.valueOf().toString()}]})}async decreaseOperatorStake(e,i){let{tags:f=[]}=i||{};return this.process.send({signer:this.signer,tags:[...f,{name:"Action",value:"Decrease-Operator-Stake"},{name:"Quantity",value:e.decreaseQty.valueOf().toString()},{name:"Instant",value:`${e.instant||!1}`}]})}async saveObservations(e,i){let{tags:f=[]}=i||{};return this.process.send({signer:this.signer,tags:[...f,{name:"Action",value:"Save-Observations"},{name:"Report-Tx-Id",value:e.reportTxId},{name:"Failed-Gateways",value:e.failedGateways.join(",")}]})}async buyRecord(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Buy-Name"},{name:"Name",value:e.name},{name:"Years",value:e.years?.toString()??"1"},{name:"Process-Id",value:e.processId},{name:"Purchase-Type",value:e.type||"lease"},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Ln(n)})}async upgradeRecord(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Upgrade-Name"},{name:"Name",value:e.name},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Ln(n)})}async extendLease(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Extend-Lease"},{name:"Name",value:e.name},{name:"Years",value:e.years.toString()},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Ln(n)})}async increaseUndernameLimit(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Increase-Undername-Limit"},{name:"Name",value:e.name},{name:"Quantity",value:e.increaseCount.toString()},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Ln(n)})}async cancelWithdrawal(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Cancel-Withdrawal"},{name:"Vault-Id",value:e.vaultId},{name:"Address",value:e.gatewayAddress}];return this.process.send({signer:this.signer,tags:Ln(n)})}async requestPrimaryName(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Request-Primary-Name"},{name:"Name",value:e.name},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Ln(n)})}async redelegateStake(e,i){let{tags:f=[]}=i||{},n=[...f,{name:"Action",value:"Redelegate-Stake"},{name:"Target",value:e.target},{name:"Source",value:e.source},{name:"Quantity",value:e.stakeQty.valueOf().toString()},{name:"Vault-Id",value:e.vaultId}];return this.process.send({signer:this.signer,tags:Ln(n)})}};var Tkt=async({address:t,registry:e=Z6.init()})=>{let i=await e.accessControlList({address:t});return[...new Set([...i.Owned,...i.Controlled])]};function nye(t,e){return new Promise((i,f)=>{let n=setTimeout(()=>{f(new Error("Timeout"))},t);e.then(l=>{clearTimeout(n),i(l)}).catch(l=>{clearTimeout(n),f(l)})})}var aye=class extends Mq.default{contract;timeoutMs;throttle;logger;strict;antAoClient;constructor({contract:e=G6.init({processId:ns}),timeoutMs:i=6e4,concurrency:f=30,logger:n=pl.default,strict:l=!1,antAoClient:p=Ls()}={}){super(),this.contract=e,this.timeoutMs=i,this.throttle=tye(f),this.logger=n,this.strict=l,this.antAoClient=p}async fetchProcessesOwnedByWallet({address:e,pageSize:i,antRegistry:f=Z6.init()}){let n={},l=await f.accessControlList({address:e}),p=new Set([...l.Owned,...l.Controlled]);await nye(this.timeoutMs,cit({contract:this.contract,emitter:this,pageSize:i})).catch(_=>(this.emit("error",`Error getting ArNS records: ${_}`),this.logger.error("Error getting ArNS records",{message:_?.message,stack:_?.stack}),{})).then(_=>{Object.entries(_).forEach(([g,y])=>{p.has(y.processId)&&(n[y.processId]==null&&(n[y.processId]={state:void 0,names:{}}),n[y.processId].names[g]=y)})});let v=Object.keys(n).length;this.emit("progress",0,v),await Promise.all(Object.keys(n).map(async(_,g)=>this.throttle(async()=>{if(n[_].state!==void 0){this.emit("progress",g+1,v);return}let y=K_.init({process:new ia({processId:_,ao:this.antAoClient}),strict:this.strict}),M=await nye(this.timeoutMs,y.getState()).catch(x=>{this.emit("error",`Error getting state for process ${_}: ${x}`)});(M?.Owner===e||M?.Controllers.includes(e))&&(n[_].state=M,this.emit("process",_,n[_])),this.emit("progress",g+1,v)}))),this.emit("end",n)}},cit=async({contract:t=G6.init({processId:ns}),emitter:e,logger:i=pl.default,pageSize:f=1e3})=>{let n,l=Date.now(),p={};do{let v=await t.getArNSRecords({cursor:n,limit:f}).catch(_=>{i?.error("Error getting ArNS records",{message:_?.message,stack:_?.stack}),e?.emit("arns:error",`Error getting ArNS records: ${_}`)});if(!v)return{};v.items.forEach(_=>{let{name:g,...y}=_;p[g]=y}),i.debug("Fetched page of ArNS records",{totalRecordCount:v.totalItems,fetchedRecordCount:Object.keys(p).length,cursor:v.nextCursor}),e?.emit("arns:pageLoaded",{totalRecordCount:v.totalItems,fetchedRecordCount:Object.keys(p).length,records:v.items,cursor:v.nextCursor}),n=v.nextCursor}while(n!==void 0);return e?.emit("arns:end",p),i.debug("Fetched all ArNS records",{totalRecordCount:Object.keys(p).length,durationMs:Date.now()-l}),p};var ia=class{logger;ao;processId;constructor({processId:e,ao:i=Ls(),logger:f=pl.default}){this.processId=e,this.logger=f,this.ao=i}isMessageDataEmpty(e){return e===void 0||e==="null"||e===""||e===null}async read({tags:e,retries:i=3,fromAddress:f}){this.logger.debug("Evaluating read interaction on process",{tags:e,processId:this.processId});let n={process:this.processId,tags:e};f!==void 0&&(n.Owner=f);let l=0,p;for(;l<i;)try{p=await this.ao.dryrun(n);break}catch(y){if(l++,this.logger.debug(`Read attempt ${l} failed`,{error:y?.message,stack:y?.stack,tags:e,processId:this.processId}),l>=i)throw this.logger.debug("Maximum read attempts exceeded",{error:y?.message,stack:y?.stack,tags:e,processId:this.processId,ao:JSON.stringify(this.ao)}),new Error(`Failed to evaluate a dry-run on process ${this.processId}.`);await new Promise(M=>setTimeout(M,2**l*1e3))}if(p===void 0)throw new Error("Unexpected error when evaluating read interaction");this.logger.debug("Read interaction result",{result:p,processId:this.processId});let v=Tq(p);if(v!==void 0)throw new Error(v);if(p.Messages===void 0||p.Messages.length===0)throw this.logger.debug(`Empty result - process ${this.processId} does not support provided action.`,{result:p,tags:e,processId:this.processId}),new Error(`Process ${this.processId} does not support provided action.`);let _=p.Messages?.[0]?.Data;return this.isMessageDataEmpty(_)?void 0:wq(_)}async send({tags:e,data:i,signer:f,retries:n=3}){let l,p=Xbe(32);try{this.logger.debug("Evaluating send interaction on contract",{tags:e,data:i,processId:this.processId}),l=await this.ao.message({process:this.processId,tags:[...e,{name:"AR-IO-SDK",value:z_}],data:i,signer:f,anchor:p}),this.logger.debug("Sent message to process",{messageId:l,processId:this.processId,anchor:p})}catch(M){throw this.logger.debug("Error sending message to process",{error:M?.message,stack:M?.stack,processId:this.processId,tags:e}),M}if(l===void 0)throw new Error("Failed to send message to process.");let v,_=0;for(;_<n;)try{v=await this.ao.result({message:l,process:this.processId}),this.logger.debug("Message result",{result:v,messageId:l,processId:this.processId});break}catch(M){if(_++,this.logger.debug("Retrying send interaction",{attempts:_,retries:n,error:M?.message,processId:this.processId}),_>=n)return this.logger.debug(`Message was sent to process ${this.processId} with id ${l} but result was not returned. Review transactions for more details.`,{error:M?.message,stack:M?.stack,tags:e,processId:this.processId,messageId:l}),{id:l};await new Promise(x=>setTimeout(x,2**_*2e3))}if(v===void 0)return this.logger.debug(`Message was sent to process ${this.processId} with id ${l} but the result was not returned. Review transactions for more details.`,{tags:e,processId:this.processId,messageId:l}),{id:l};let g=Tq(v);if(g!==void 0)throw new C7(g);if(v.Messages?.length===0||v.Messages===void 0)return{id:l};if(this.isMessageDataEmpty(v.Messages[0].Data))return{id:l};let y=wq(v.Messages[0].Data);return this.logger.debug("Message result data",{resultData:y,messageId:l,processId:this.processId}),{id:l,result:y}}};var Z_=class{static init(e){return e!==void 0&&"signer"in e?new Iq(e):new V_(e)}},V_=class{process;constructor(e){if(e===void 0||Object.keys(e).length===0)this.process=new ia({processId:Rm});else if(pd(e))this.process=e.process;else if(vd(e))this.process=new ia({processId:e.processId});else throw new fl}async getANTVersions(){let e=await this.process.read({tags:[{name:"Action",value:"Get-Versions"}]});return Object.fromEntries(Object.entries(e).sort(([i],[f])=>i.localeCompare(f)))}async getLatestANTVersion(){let e=await this.getANTVersions(),i=Object.entries(e).at(-1);if(!i)throw new Error("No version found");return{version:i[0],...i[1]}}},Iq=class extends V_{signer;constructor({signer:e,...i}){super(i),this.signer=dd(e)}async addVersion(e,{tags:i}){return this.process.send({tags:Ln([{name:"Action",value:"Add-Version"},{name:"Version",value:e.version},{name:"Module-Id",value:e.moduleId},{name:"Lua-Source-Id",value:e.luaSourceId},{name:"Notes",value:e.notes},...i??[]]),signer:this.signer})}};var K_=class{static versions=Z_.init();static init(e){return e!==void 0&&"signer"in e?new kq(e):new G_(e)}},G_=class{process;processId;strict;constructor(e){if(this.strict=e.strict||!1,pd(e))this.process=e.process;else if(vd(e))this.process=new ia({processId:e.processId});else throw new fl;this.processId=this.process.processId}async getState({strict:e}={strict:this.strict}){let i=[{name:"Action",value:"State"}],f=await this.process.read({tags:i});return e&&cd(iC.passthrough().and(vr.object({Records:vr.record(vr.string(),q5.passthrough())})),f),f}async getInfo({strict:e}={strict:this.strict}){let i=[{name:"Action",value:"Info"}],f=await this.process.read({tags:i});return e&&cd(Rle.passthrough(),f),f}async getLogo(){return(await this.getInfo()).Logo}async getRecord({undername:e},{strict:i}={strict:this.strict}){let f=[{name:"Sub-Domain",value:e},{name:"Action",value:"Record"}],n=await this.process.read({tags:f});return i&&cd(q5.passthrough(),n),n}async getRecords({strict:e}={strict:this.strict}){let i=[{name:"Action",value:"Records"}],f=await this.process.read({tags:i});return e&&cd(eC,f),Kbe(f)}async getOwner({strict:e}={strict:this.strict}){return(await this.getInfo({strict:e})).Owner}async getControllers({strict:e}={strict:this.strict}){let i=[{name:"Action",value:"Controllers"}],f=await this.process.read({tags:i});return e&&cd(tC,f),f}async getName({strict:e}={strict:this.strict}){return(await this.getInfo({strict:e})).Name}async getTicker({strict:e}={strict:this.strict}){return(await this.getInfo({strict:e})).Ticker}async getBalances({strict:e}={strict:this.strict}){let i=[{name:"Action",value:"Balances"}],f=await this.process.read({tags:i});return e&&cd(rC,f),f}async getBalance({address:e},{strict:i}={strict:this.strict}){let f=[{name:"Action",value:"Balance"},{name:"Recipient",value:e}],n=await this.process.read({tags:f});return i&&cd(vr.number(),n),n}async getHandlers(){let e=await this.getInfo();return e.Handlers??e.HandlerNames}},kq=class extends G_{signer;constructor({signer:e,...i}){super(i),this.signer=dd(e)}async transfer({target:e},i){let f=[...i?.tags??[],{name:"Action",value:"Transfer"},{name:"Recipient",value:e}];return this.process.send({tags:f,signer:this.signer})}async addController({controller:e},i){let f=[...i?.tags??[],{name:"Action",value:"Add-Controller"},{name:"Controller",value:e}];return this.process.send({tags:f,signer:this.signer})}async removeController({controller:e},i){let f=[...i?.tags??[],{name:"Action",value:"Remove-Controller"},{name:"Controller",value:e}];return this.process.send({tags:f,signer:this.signer})}async setRecord({undername:e,transactionId:i,ttlSeconds:f},n){return this.process.send({tags:[...n?.tags??[],{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:e},{name:"Transaction-Id",value:i},{name:"TTL-Seconds",value:f.toString()}],signer:this.signer})}async setBaseNameRecord({transactionId:e,ttlSeconds:i},f){return this.setRecord({transactionId:e,ttlSeconds:i,undername:"@"},f)}async setUndernameRecord({undername:e,transactionId:i,ttlSeconds:f},n){return this.setRecord({undername:e,transactionId:i,ttlSeconds:f},n)}async removeUndernameRecord({undername:e}){return this.removeRecord({undername:e})}async removeRecord({undername:e},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Remove-Record"},{name:"Sub-Domain",value:e}],signer:this.signer})}async setTicker({ticker:e},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Ticker"},{name:"Ticker",value:e}],signer:this.signer})}async setName({name:e},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Name"},{name:"Name",value:e}],signer:this.signer})}async setDescription({description:e},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Description"},{name:"Description",value:e}],signer:this.signer})}async setKeywords({keywords:e},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Keywords"},{name:"Keywords",value:JSON.stringify(e)}],signer:this.signer})}async setLogo({txId:e},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Logo"},{name:"Logo",value:e}],signer:this.signer})}async releaseName({name:e,arioProcessId:i},f){return this.process.send({tags:[...f?.tags??[],{name:"Action",value:"Release-Name"},{name:"Name",value:e},{name:"IO-Process-Id",value:i},{name:"ARIO-Process-Id",value:i}],signer:this.signer})}async reassignName({name:e,arioProcessId:i,antProcessId:f},n){return this.process.send({tags:[...n?.tags??[],{name:"Action",value:"Reassign-Name"},{name:"Name",value:e},{name:"IO-Process-Id",value:i},{name:"ARIO-Process-Id",value:i},{name:"Process-Id",value:f}],signer:this.signer})}async approvePrimaryNameRequest({name:e,address:i,arioProcessId:f},n){return this.process.send({tags:[...n?.tags??[],{name:"Action",value:"Approve-Primary-Name"},{name:"Name",value:e},{name:"Recipient",value:i},{name:"IO-Process-Id",value:f},{name:"ARIO-Process-Id",value:f}],signer:this.signer})}async removePrimaryNames({names:e,arioProcessId:i,notifyOwners:f=!1},n){return this.process.send({tags:[...n?.tags??[],{name:"Action",value:"Remove-Primary-Names"},{name:"Names",value:e.join(",")},{name:"IO-Process-Id",value:i},{name:"ARIO-Process-Id",value:i},{name:"Notify-Owners",value:f.toString()}],signer:this.signer})}};async function sPt({signer:t,module:e=wle,ao:i=Ls(),scheduler:f=xle,state:n,antRegistryId:l=Rm,logger:p=pl.default,authority:v=Mle}){let _=await i.spawn({module:e,scheduler:f,signer:t,data:n?JSON.stringify(n):void 0,tags:[{name:"Authority",value:v},{name:"ANT-Registry-Id",value:l}]});return p.debug("Spawned ANT",{processId:_,module:e,scheduler:f}),_}async function fPt({signer:t,processId:e,luaCodeTxId:i=_le,ao:f=Ls(),logger:n=pl.default,arweave:l=N7}){let p=new ia({processId:e,ao:f,logger:n}),{api:{host:v,port:_,protocol:g}}=l.getConfig(),y=await fetch(`${g}://${v}:${_}/${i}`).then(x=>x.text()),{id:M}=await p.send({tags:[{name:"Action",value:"Eval"},{name:"App-Name",value:"ArNS-ANT"},{name:"Source-Code-TX-ID",value:i}],data:y,signer:t});return n.debug("Evolved ANT",{processId:e,luaCodeTxId:i,evalMsgId:M}),M}function dit(t){let e=vr.object({name:vr.string(),value:vr.union([vr.string(),vr.number()])}),i=vr.function().args(vr.object({data:vr.union([vr.string(),vr.instanceof(De)]),tags:vr.array(e).optional(),target:vr.string().optional(),anchor:vr.string().optional()})).returns(vr.promise(vr.object({id:vr.string(),raw:vr.instanceof(ArrayBuffer)})));try{return i.parse(t),!0}catch{return!1}}function dd(t){return dit(t)?t:"publicKey"in t?async({data:i,tags:f,target:n,anchor:l})=>{if(t.publicKey===void 0&&"setPublicKey"in t&&typeof t.setPublicKey=="function"&&await t.setPublicKey(),t instanceof Wc){let _=await t.signer.signDataItem({data:i,tags:f,target:n,anchor:l}),g=new mm(De.from(_));return{id:await g.id,raw:await g.getRaw()}}let p=Kb(i,t,{tags:f,target:n,anchor:l});return p.sign(t).then(async()=>({id:await p.id,raw:await p.getRaw()}))}:Lce(t)}var pit="-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI",vit="Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A";function uPt({owner:t,targetId:e,ttlSeconds:i=3600,keywords:f=[],controllers:n=[],description:l="",ticker:p="aos",name:v="ANT",logo:_=vit}){return{ticker:p,name:v,description:l,keywords:f,owner:t,controllers:[t,...n],balances:{[t]:1},records:{"@":{transactionId:e??pit.toString(),ttlSeconds:i}},logo:_}}function Bq(t){return vr.object({startTimestamp:vr.number(),startHeight:vr.number(),distributions:vr.any(),endTimestamp:vr.number(),prescribedObservers:vr.any(),prescribedNames:vr.array(vr.string()),observations:vr.any(),epochIndex:vr.number()}).parse(t)}function Tq(t){let i=t.Error??t.Messages?.[0]?.Tags?.find(f=>f.name==="Error")?.value;if(i!==void 0){let f=i.match(/\[string "aos"]:(\d+):\s*(.+)/);if(f){let[,n,l]=f;return`${oye(l).trim()} (line ${n.trim()})`.trim()}return oye(i)}}function oye(t){let e="\x1B";return t.replace(new RegExp(`${e}[\\[\\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]`,"g"),"").trim()}var sye=t=>L5.test(t);function MPt(t){return t!==void 0&&!isNaN(parseInt(t.toString()))}var Ln=t=>t.filter(e=>e.value!==void 0&&e.value!==""),To=t=>{let e=[{name:"Cursor",value:t?.cursor?.toString()},{name:"Limit",value:t?.limit?.toString()},{name:"Sort-By",value:t?.sortBy?.toString()},{name:"Sort-Order",value:t?.sortOrder?.toString()}];return Ln(e)},mit=async({arweave:t,epochIndex:e,processId:i=ns,retries:f=3,gqlUrl:n="https://arweave-search.goldsky.com/graphql"})=>{let l=bit({epochIndex:e,processId:i});for(let p=0;p<f;p++)try{let v=await fetch(n,{method:"POST",body:l,headers:{"Content-Type":"application/json"}}).then(y=>y.json());if(v?.data?.transactions?.edges?.length===0)return;let _=v.data.transactions.edges[0].node.id,g=await t.api.get(_);return Bq(g.data)}catch(v){if(p===f-1)throw v;await new Promise(_=>setTimeout(_,Math.pow(2,p)*1e3))}},D1=async({arweave:t,ao:e,epochIndex:i,processId:f=ns})=>{let n=await mit({arweave:t,epochIndex:i,processId:f});if(n)return n;let l=await git({ao:e,epochIndex:i,processId:f});if(l)return l},git=async({ao:t,epochIndex:e,processId:i=ns,gqlUrl:f="https://arweave-search.goldsky.com/graphql"})=>{let n=yit({epochIndex:e,processId:i}),p=await(await fetch(f,{method:"POST",body:n,headers:{"Content-Type":"application/json"}})).json();if(p.data.transactions.edges.length!==0)for(let v of p.data.transactions.edges){let _=v.node.id,g=await t.result({message:_,process:i}).catch(()=>{});if(g)for(let y of g?.Messages??[]){let M=JSON.parse(y.Data),x=y.Tags;if(x.some(S=>S.name==="Action"&&S.value==="Epoch-Distribution-Notice")&&x.some(S=>S.name==="Epoch-Index"&&S.value===e.toString()))return Bq(M)}}},bit=({epochIndex:t,processId:e=ns,authorities:i=["fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY"]})=>JSON.stringify({query:`
213
213
  query {
214
214
  transactions(
215
215
  tags: [
@@ -118,7 +118,7 @@ const getEpochDataFromGqlFallback = async ({ ao, epochIndex, processId = constan
118
118
  if (!messageResult) {
119
119
  continue;
120
120
  }
121
- for (const message of messageResult.Messages) {
121
+ for (const message of messageResult?.Messages ?? []) {
122
122
  const data = JSON.parse(message.Data);
123
123
  const tags = message.Tags;
124
124
  // check if the message results include epoch-distribution-notice for the requested epoch index
@@ -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.10.1';
20
+ exports.version = '3.10.2';
@@ -107,7 +107,7 @@ export const getEpochDataFromGqlFallback = async ({ ao, epochIndex, processId =
107
107
  if (!messageResult) {
108
108
  continue;
109
109
  }
110
- for (const message of messageResult.Messages) {
110
+ for (const message of messageResult?.Messages ?? []) {
111
111
  const data = JSON.parse(message.Data);
112
112
  const tags = message.Tags;
113
113
  // check if the message results include epoch-distribution-notice for the requested epoch index
@@ -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.10.1';
17
+ export const version = '3.10.2';
@@ -13,4 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const version = "3.10.0";
16
+ export declare const version = "3.10.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.10.1",
3
+ "version": "3.10.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"