@ar.io/sdk 3.4.0-alpha.1 → 3.4.0-alpha.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.
package/README.md CHANGED
@@ -91,6 +91,9 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
91
91
  - [`transfer({ target })`](#transfer-target-)
92
92
  - [`setController({ controller })`](#setcontroller-controller-)
93
93
  - [`removeController({ controller })`](#removecontroller-controller-)
94
+ - [`setBaseNameRecord({ transactionId, ttlSeconds })`](#setbasenamerecord-transactionid-ttlseconds-)
95
+ - [`setUndernameRecord({ undername, transactionId, ttlSeconds })`](#setundernamerecord-undername-transactionid-ttlseconds-)
96
+ - [`removeUndernameRecord({ undername })`](#removeundernamerecord-undername-)
94
97
  - [`setRecord({ undername, transactionId, ttlSeconds })`](#setrecord-undername-transactionid-ttlseconds-)
95
98
  - [`removeRecord({ undername })`](#removerecord-undername-)
96
99
  - [`setName({ name })`](#setname-name-)
@@ -2060,9 +2063,70 @@ const { id: txId } = await ant.removeController(
2060
2063
  );
2061
2064
  ```
2062
2065
 
2066
+ #### `setBaseNameRecord({ transactionId, ttlSeconds })`
2067
+
2068
+ Adds or updates the base name record for the ANT. This is the top level name of the ANT (e.g. ardrive.ar.io)
2069
+
2070
+ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
2071
+
2072
+ ```typescript
2073
+ // get the ant for the base name
2074
+ const arnsRecord = await ario.getArNSRecord({ name: 'ardrive' });
2075
+ const ant = await ANT.init({ processId: arnsName.processId });
2076
+ const { id: txId } = await ant.setBaseNameRecord({
2077
+ transactionId: '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM',
2078
+ ttlSeconds: 3600,
2079
+ });
2080
+
2081
+ // ardrive.ar.io will now resolve to the provided 432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM transaction id
2082
+ ```
2083
+
2084
+ #### `setUndernameRecord({ undername, transactionId, ttlSeconds })`
2085
+
2086
+ Adds or updates an undername record for the ANT. An undername is appended to the base name of the ANT (e.g. dapp_ardrive.ar.io)
2087
+
2088
+ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
2089
+
2090
+ > Records, or `undernames` are configured with the `transactionId` - the arweave transaction id the record resolves - and `ttlSeconds`, the Time To Live in the cache of client applications.
2091
+
2092
+ ```typescript
2093
+ const arnsRecord = await ario.getArNSRecord({ name: 'ardrive' });
2094
+ const ant = await ANT.init({ processId: arnsName.processId });
2095
+ const { id: txId } = await ant.setUndernameRecord(
2096
+ {
2097
+ undername: 'dapp',
2098
+ transactionId: '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM',
2099
+ ttlSeconds: 900,
2100
+ },
2101
+ // optional additional tags
2102
+ { tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
2103
+ );
2104
+
2105
+ // dapp_ardrive.ar.io will now resolve to the provided 432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM transaction id
2106
+ ```
2107
+
2108
+ #### `removeUndernameRecord({ undername })`
2109
+
2110
+ Removes an undername record from the ANT process.
2111
+
2112
+ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
2113
+
2114
+ ```typescript
2115
+ const { id: txId } = await ant.removeUndernameRecord(
2116
+ { undername: 'dapp' },
2117
+ // optional additional tags
2118
+ { tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
2119
+ );
2120
+
2121
+ // dapp_ardrive.ar.io will no longer resolve to the provided transaction id
2122
+ ```
2123
+
2063
2124
  #### `setRecord({ undername, transactionId, ttlSeconds })`
2064
2125
 
2065
- Updates or creates a record in the ANT process.
2126
+ > [!WARNING]
2127
+ > Deprecated: Use `setBaseNameRecord` or `setUndernameRecord` instead.
2128
+
2129
+ Adds or updates a record for the ANT process. The `undername` parameter is used to specify the record name. Use `@` for the base name record.
2066
2130
 
2067
2131
  _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
2068
2132
 
@@ -2082,16 +2146,23 @@ const { id: txId } = await ant.setRecord(
2082
2146
 
2083
2147
  #### `removeRecord({ undername })`
2084
2148
 
2149
+ > [!WARNING]
2150
+ > Deprecated: Use `removeUndernameRecord` instead.
2151
+
2085
2152
  Removes a record from the ANT process.
2086
2153
 
2087
2154
  _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
2088
2155
 
2089
2156
  ```typescript
2157
+ const arnsRecord = await ario.getArNSRecord({ name: 'ardrive' });
2158
+ const ant = await ANT.init({ processId: arnsName.processId });
2090
2159
  const { id: txId } = await ant.removeRecord(
2091
- { undername: 'remove-domemain' },
2160
+ { undername: 'dapp' },
2092
2161
  // optional additional tags
2093
2162
  { tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
2094
2163
  );
2164
+
2165
+ // dapp_ardrive.ar.io will no longer resolve to the provided transaction id
2095
2166
  ```
2096
2167
 
2097
2168
  #### `setName({ name })`
@@ -186,7 +186,7 @@ nonce: bundlr`),Me.from(i))}};ie();ae();ne();var Q0=class{_publicKey;ownerLength
186
186
  }
187
187
  }
188
188
  }
189
- }`,i=wt.object({data:wt.object({transactions:wt.object({edges:wt.array(wt.object({node:wt.record(wt.any())}))})})});return h=>jr(h).chain(Li(l=>t(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:a,variables:{transactionIds:[l]}})}).then(async p=>{if(p.ok)return p.json();throw r('Error Encountered when querying gateway for transaction "%s"',l),new Error(`${p.status}: ${await p.text()}`)}).then(i.parse).then(ixe(["data","transactions","edges","0","node"])))).toPromise()}var pSe=nI(M5e(),1),fte=(t="@permaweb/aoconnect")=>{let e=(0,pSe.default)(t);return e.child=r=>fte(`${e.namespace}:${r}`),e.tap=(r,...a)=>hxe((...i)=>e(r,...a,...i)),e},ute=({url:t,path:e})=>e?e.startsWith("/")?ute({url:t,path:e.slice(1)}):(t=new URL(t),t.pathname+=e,t.toString()):t;function vSe(t){return F1(M4([]),U1((e,r)=>F1(oxe([],r.name),wI(r.value),$s(r.name,Fh,e))(e),{}),w4(e=>e.length>1?e:e[0]))(t)}function Cs(t,e){return r=>Pee(vMe([NQ(t,"name"),MI(yI(e),NQ(e,"value"),mI)]),r)}function DQ(t){return jee([[Kg(String),k1(t)],[Kg(Array),VMe(t)],[mI,E9e]])}function Ad(t){let e;return Kg(Ls,t)?(e=new Error(mSe(t)),e.stack+=t.stack):Kg(Error,t)?e=t:HMe("message",t)?e=new Error(t.message):Kg(String,t)?e=new Error(t):e=new Error("An error occurred"),e}function mSe(t){return F1(e=>function r(a,i,h){return U1((l,p)=>F1(jee([[k1(Rt.invalid_arguments),()=>r(p.argumentsError,422,"Invalid Arguments")],[k1(Rt.invalid_return_type),()=>r(p.returnTypeError,500,"Invalid Return")],[k1(Rt.invalid_union),()=>BMe(b=>r(b,400,"Invalid Union"),p.unionErrors)],[mI,()=>[{...p,status:i,contextCode:h}]]]),_I(l))(p.code),[],a.issues)}(e,400,""),e=>U1((r,a)=>{let{message:i,path:h,contextCode:l}=a,p=h[1]||h[0],b=l?`${l} `:"";return r.push(`${b}'${p}': ${i}.`),r},[],e),exe(" | "))(t)}var gSe=wt.object({id:wt.string().min(1,{message:"message is required to be a message id"}),processId:wt.string().min(1,{message:"process is required to be a process id"})});function bSe(){return t=>jr(t).map(gSe.parse).map(()=>t)}var I2=wt.object({name:wt.string(),value:wt.string()}),ySe=wt.function().args(wt.object({Id:wt.string(),Target:wt.string(),Owner:wt.string(),Anchor:wt.string().optional(),Data:wt.any().default("1234"),Tags:wt.array(wt.object({name:wt.string(),value:wt.string()}))})).returns(wt.promise(wt.any())),wSe=wt.function().args(wt.object({id:wt.string().min(1,{message:"message id is required"}),processId:wt.string().min(1,{message:"process id is required"})})).returns(wt.promise(wt.any())),_Se=wt.function().args(wt.object({process:wt.string().min(1,{message:"process id is required"}),from:wt.string().optional(),to:wt.string().optional(),sort:wt.enum(["ASC","DESC"]).default("ASC"),limit:wt.number().optional()})).returns(wt.promise(wt.object({edges:wt.array(wt.object({cursor:wt.string(),node:wt.object({Output:wt.any().optional(),Messages:wt.array(wt.any()).optional(),Spawns:wt.array(wt.any()).optional(),Error:wt.any().optional()})}))}))),hte=wt.function().args(wt.object({processId:wt.string(),data:wt.any(),tags:wt.array(I2),anchor:wt.string().optional(),signer:wt.any()})).returns(wt.promise(wt.object({messageId:wt.string()}).passthrough())),MSe=wt.function().args(wt.object({data:wt.any(),tags:wt.array(I2),signer:wt.any()})).returns(wt.promise(wt.object({processId:wt.string()}).passthrough())),xSe=wt.function().args(wt.object({process:wt.string(),message:wt.string(),baseLayer:wt.boolean().optional(),exclude:wt.array(wt.string()).optional()})).returns(wt.promise(wt.object({assignmentId:wt.string()}).passthrough())),lte=hte,lut=wt.function().args(wt.object({suUrl:wt.string().url(),processId:wt.string()})).returns(wt.promise(wt.object({tags:wt.array(I2)}).passthrough())),cut=wt.function().args(wt.string()).returns(wt.promise(wt.object({url:wt.string()}))),SSe=wt.function().args(wt.string()).returns(wt.promise(wt.boolean())),ESe=wt.function().args(wt.string()).returns(wt.promise(wt.object({tags:wt.array(I2)}).passthrough())),x4=wt.function().args(wt.object({data:wt.any(),tags:wt.array(I2),target:wt.string().optional(),anchor:wt.string().optional()})).returns(wt.promise(wt.object({id:wt.string(),raw:wt.any()})));function ASe({loadResult:t}){return t=Li(wSe.implement(t)),e=>jr({id:e.id,processId:e.processId}).chain(t)}function RSe(t){let e=bSe(t),r=ASe(t);return({message:a,process:i})=>jr({id:a,processId:i}).chain(e).chain(r).map(t.logger.tap('readResult result for message "%s": %O',a)).map(h=>h).bimap(Ad,Ed).toPromise()}var TSe=wt.array(wt.object({name:wt.string(),value:wt.string()}));function ISe(){return t=>jr(t.tags).map(M4([])).map(Cs("Data-Protocol","ao")).map(Cs("Variant")).map(Cs("Type")).map(Cs("SDK")).map(_I(Fh,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Message"},{name:"SDK",value:"aoconnect"}])).map(TSe.parse).map($s("tags",Fh,t))}function kSe({logger:t}){return e=>jr(e).chain(MI(yI(e.data),()=>_d(e),()=>_d(Math.random().toString().slice(-4)).map($s("data",Fh,e)).map(r=>F1(Sd("tags"),Cs("Content-Type"),wI({name:"Content-Type",value:"text/plain"}),$s("tags",Fh,r))(r)).map(t.tap('added pseudo-random string as message "data"'))))}function BSe(t){let e=ISe(t),r=kSe(t),a=hte.implement(t.deployMessage);return i=>jr(i).chain(e).chain(r).chain(Li(({id:h,data:l,tags:p,anchor:b,signer:g})=>a({processId:h,data:l,tags:p,anchor:b,signer:x4.implement(g)}))).map(h=>$s("messageId",h.messageId,i))}function PSe(t){let e=BSe(t);return({process:r,data:a,tags:i,anchor:h,signer:l})=>jr({id:r,data:a,tags:i,anchor:h,signer:l}).chain(e).map(p=>p.messageId).bimap(Ad,Ed).toPromise()}var Lg=(t,e,r)=>a=>e(a[t])?_d(a):xc(`Tag '${t}': ${r}`);function OSe({loadTransactionMeta:t,logger:e}){return t=Li(ESe.implement(t)),r=>jr(r).chain(t).map(Sd("tags")).map(vSe).chain(Lg("Data-Protocol",DQ("ao"),"value 'ao' was not found on module")).chain(Lg("Type",DQ("Module"),"value 'Module' was not found on module")).chain(Lg("Module-Format",IT,"was not found on module")).chain(Lg("Input-Encoding",IT,"was not found on module")).chain(Lg("Output-Encoding",IT,"was not found on module")).bimap(e.tap("Verifying module source failed: %s"),e.tap("Verified module source"))}function NSe({logger:t,validateScheduler:e}){return e=Li(SSe.implement(e)),r=>jr(r).chain(a=>e(a).chain(i=>i?_d(a):xc(`Valid Scheduler-Location owned by ${a} not found`))).bimap(t.tap("Verifying scheduler failed: %s"),t.tap("Verified scheduler"))}function CSe({logger:t}){return e=>jr(e).map(t.tap("Checking for signer")).chain(r=>r?_d(r):xc("signer not found"))}function LSe(t){let e=t.logger.child("verifyInput");t={...t,logger:e};let r=OSe(t),a=NSe(t),i=CSe(t);return h=>jr(h).chain(l=>r(l.module).map(()=>l)).chain(l=>a(l.scheduler)).map(()=>h).chain(l=>i(l.signer).map(()=>l)).bimap(e.tap("Error when verify input: %s"),e.tap("Successfully verified inputs"))}var DSe=wt.array(wt.object({name:wt.string(),value:wt.string()}));function $Se(){return t=>jr(t).map(Sd("tags")).map(M4([])).map(Cs("Data-Protocol","ao")).map(Cs("Variant")).map(Cs("Type")).map(Cs("Module")).map(Cs("Scheduler")).map(Cs("SDK")).map(_I(Fh,[{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(DSe.parse).map($s("tags",Fh,t))}function qSe({logger:t}){return e=>jr(e).chain(MI(yI(e.data),()=>_d(e),()=>_d(Math.random().toString().slice(-4)).map($s("data",Fh,e)).map(r=>F1(Sd("tags"),Cs("Content-Type"),wI({name:"Content-Type",value:"text/plain"}),$s("tags",Fh,r))(r)).map(t.tap('added pseudo-random string as process "data"'))))}function USe(t){let e=t.logger.child("uploadProcess");t={...t,logger:e};let r=$Se(t),a=qSe(t),i=MSe.implement(t.deployProcess);return h=>jr(h).chain(r).chain(a).chain(Li(({data:l,tags:p,signer:b})=>i({data:l,tags:p,signer:x4.implement(b)}))).map(l=>$s("processId",l.processId,h))}function FSe(t){let e=LSe(t),r=USe(t);return({module:a,scheduler:i,signer:h,tags:l,data:p})=>jr({module:a,scheduler:i,signer:h,tags:l,data:p}).chain(e).chain(r).map(b=>b.processId).bimap(Ad,Ed).toPromise()}function jSe(t){let e=lte.implement(t.deployMonitor);return r=>jr(r).chain(Li(({id:a,signer:i})=>e({processId:a,signer:x4.implement(i),data:Math.random().toString().slice(-4),tags:[]}))).map(a=>$s("monitorId",a.messageId,r))}function zSe(t){let e=jSe(t);return({process:r,signer:a})=>jr({id:r,signer:a}).chain(e).map(i=>i.monitorId).bimap(Ad,Ed).toPromise()}function ZSe(t){let e=lte.implement(t.deployUnmonitor);return r=>jr(r).chain(Li(({id:a,signer:i})=>e({processId:a,signer:x4.implement(i),data:Math.random().toString().slice(-4),tags:[]}))).map(a=>$s("monitorId",a.messageId,r))}function HSe(t){let e=ZSe(t);return({process:r,signer:a})=>jr({id:r,signer:a}).chain(e).map(i=>i.monitorId).bimap(Ad,Ed).toPromise()}var KSe=wt.object({process:wt.string().min(1,{message:"process identifier is required"}),from:wt.string().optional(),to:wt.string().optional(),sort:wt.enum(["ASC","DESC"]).default("ASC"),limit:wt.number().optional()});function WSe(){return t=>jr(t).map(KSe.parse).map(()=>t)}function VSe({queryResults:t}){return t=Li(_Se.implement(t)),e=>jr({process:e.process,from:e.from,to:e.to,sort:e.sort,limit:e.limit}).chain(t)}function GSe(t){let e=WSe(t),r=VSe(t);return({process:a,from:i,to:h,sort:l,limit:p})=>jr({process:a,from:i,to:h,sort:l,limit:p}).chain(e).chain(r).map(t.logger.tap('readResults result for message "%s": %O',a)).map(b=>b).bimap(Ad,Ed).toPromise()}var YSe=wt.object({Id:wt.string(),Target:wt.string(),Owner:wt.string(),Anchor:wt.string().optional(),Data:wt.any().default("1234"),Tags:wt.array(wt.object({name:wt.string(),value:wt.string()}))});function JSe(){return t=>jr(t).map(YSe.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 XSe({dryrunFetch:t}){return Li(ySe.implement(t))}function QSe(t){let e=JSe(t),r=XSe(t);return a=>jr(a).map(eEe).chain(e).chain(r).toPromise()}function eEe({process:t,data:e,tags:r,anchor:a,...i}){return{Id:"1234",Owner:"1234",...i,Target:t,Data:e||"1234",Tags:r||[],Anchor:a||"0"}}function tEe(t){let e=xSe.implement(t.deployAssign);return r=>jr(r).chain(Li(({process:a,message:i,baseLayer:h,exclude:l})=>e({process:a,message:i,baseLayer:h,exclude:l}))).map(a=>$s("assignmentId",a.assignmentId,r))}function rEe(t){let e=tEe(t);return({process:r,message:a,baseLayer:i,exclude:h})=>jr({process:r,message:a,baseLayer:i,exclude:h}).chain(e).map(l=>l.assignmentId).bimap(Ad,Ed).toPromise()}var iEe="https://arweave.net",nEe="https://mu.ao-testnet.xyz",aEe="https://cu.ao-testnet.xyz";function Sc({GRAPHQL_URL:t,GATEWAY_URL:e=iEe,MU_URL:r=nEe,CU_URL:a=aEe}={}){let i=fte();t||(t=ute({url:e,path:"/graphql"}));let{validate:h}=Tee({cacheSize:100,GRAPHQL_URL:t}),l=x9e({MAX_SIZE:25}),p=i.child("result"),b=RSe({loadResult:w9e({fetch,CU_URL:a,logger:p}),logger:p}),g=i.child("message"),y=PSe({loadProcessMeta:AT({fetch,cache:l,logger:g}),deployMessage:p9e({fetch,MU_URL:r,logger:g}),logger:g}),M=i.child("spawn"),x=FSe({loadTransactionMeta:dSe({fetch,GRAPHQL_URL:t,logger:M}),validateScheduler:h,deployProcess:v9e({fetch,MU_URL:r,logger:M}),logger:M}),E=i.child("monitor"),A=zSe({loadProcessMeta:AT({fetch,cache:l,logger:E}),deployMonitor:m9e({fetch,MU_URL:r,logger:E}),logger:E}),I=i.child("unmonitor"),P=HSe({loadProcessMeta:AT({fetch,cache:l,logger:I}),deployUnmonitor:g9e({fetch,MU_URL:r,logger:I}),logger:E}),N=i.child("results"),L=GSe({queryResults:_9e({fetch,CU_URL:a,logger:N}),logger:N}),C=i.child("dryrun"),Y=QSe({dryrunFetch:y9e({fetch,CU_URL:a,logger:C}),logger:C}),G=i.child("assign"),ee=rEe({deployAssign:b9e({fetch,MU_URL:r,logger:G}),logger:g});return{result:b,results:L,message:y,spawn:x,monitor:A,unmonitor:P,dryrun:Y,assign:ee}}var cte={};UQ(cte,{createDataItemSigner:()=>kEe});var dte=nI(E5e(),1),pte={};UQ(pte,{AVSCTap:()=>k2,ArweaveSigner:()=>RI,DataItem:()=>E2,MAX_TAG_BYTES:()=>S4,MIN_BINARY_SIZE:()=>kI,SIG_CONFIG:()=>K1,SignatureConfig:()=>Ns,Signer:()=>bte,createData:()=>Mte,default:()=>REe,deserializeTags:()=>p4,indexToType:()=>TI,serializeTags:()=>II,tagsExceedLimit:()=>_te,warparbundles:()=>TEe});var oEe=Object.create,EI=Object.defineProperty,sEe=Object.getOwnPropertyDescriptor,fEe=Object.getOwnPropertyNames,uEe=Object.getPrototypeOf,hEe=Object.prototype.hasOwnProperty,zh=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),lEe=(t,e)=>{for(var r in e)EI(t,r,{get:e[r],enumerable:!0})},cEe=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of fEe(e))!hEe.call(t,i)&&i!==r&&EI(t,i,{get:()=>e[i],enumerable:!(a=sEe(e,i))||a.enumerable});return t},Rd=(t,e,r)=>(r=t!=null?oEe(uEe(t)):{},cEe(e||!t||!t.__esModule?EI(r,"default",{value:t,enumerable:!0}):r,t)),dEe=zh(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});function e(r){var a=4,i=r.length,h=i%a;if(!h)return r;var l=i,p=a-h,b=i+p,g=Me.alloc(b);for(g.write(r);p--;)g.write("=",l++);return g.toString()}t.default=e}),pEe=zh(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var e=dEe();function r(b,g){return g===void 0&&(g="utf8"),Me.isBuffer(b)?h(b.toString("base64")):h(Me.from(b,g).toString("base64"))}function a(b,g){return g===void 0&&(g="utf8"),Me.from(i(b),"base64").toString(g)}function i(b){return b=b.toString(),e.default(b).replace(/\-/g,"+").replace(/_/g,"/")}function h(b){return b.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function l(b){return Me.from(i(b),"base64")}var p=r;p.encode=r,p.decode=a,p.toBase64=i,p.fromBase64=h,p.toBuffer=l,t.default=p}),AI=zh((t,e)=>{e.exports=pEe().default,e.exports.default=e.exports}),vte=zh(t=>{"use strict";t.byteLength=b,t.toByteArray=y,t.fromByteArray=E;var e=[],r=[],a=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(h=0,l=i.length;h<l;++h)e[h]=i[h],r[i.charCodeAt(h)]=h;var h,l;r[45]=62,r[95]=63;function p(A){var I=A.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var P=A.indexOf("=");P===-1&&(P=I);var N=P===I?0:4-P%4;return[P,N]}function b(A){var I=p(A),P=I[0],N=I[1];return(P+N)*3/4-N}function g(A,I,P){return(I+P)*3/4-P}function y(A){var I,P=p(A),N=P[0],L=P[1],C=new a(g(A,N,L)),Y=0,G=L>0?N-4:N,ee;for(ee=0;ee<G;ee+=4)I=r[A.charCodeAt(ee)]<<18|r[A.charCodeAt(ee+1)]<<12|r[A.charCodeAt(ee+2)]<<6|r[A.charCodeAt(ee+3)],C[Y++]=I>>16&255,C[Y++]=I>>8&255,C[Y++]=I&255;return L===2&&(I=r[A.charCodeAt(ee)]<<2|r[A.charCodeAt(ee+1)]>>4,C[Y++]=I&255),L===1&&(I=r[A.charCodeAt(ee)]<<10|r[A.charCodeAt(ee+1)]<<4|r[A.charCodeAt(ee+2)]>>2,C[Y++]=I>>8&255,C[Y++]=I&255),C}function M(A){return e[A>>18&63]+e[A>>12&63]+e[A>>6&63]+e[A&63]}function x(A,I,P){for(var N,L=[],C=I;C<P;C+=3)N=(A[C]<<16&16711680)+(A[C+1]<<8&65280)+(A[C+2]&255),L.push(M(N));return L.join("")}function E(A){for(var I,P=A.length,N=P%3,L=[],C=16383,Y=0,G=P-N;Y<G;Y+=C)L.push(x(A,Y,Y+C>G?G:Y+C));return N===1?(I=A[P-1],L.push(e[I>>2]+e[I<<4&63]+"==")):N===2&&(I=(A[P-2]<<8)+A[P-1],L.push(e[I>>10]+e[I>>4&63]+e[I<<2&63]+"=")),L.join("")}}),mte=zh(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=vte();function r(x){let E=0;for(let P=0;P<x.length;P++)E+=x[P].byteLength;let A=new Uint8Array(E),I=0;A.set(new Uint8Array(x[0]),I),I+=x[0].byteLength;for(let P=1;P<x.length;P++)A.set(new Uint8Array(x[P]),I),I+=x[P].byteLength;return A}t.concatBuffers=r;function a(x){let E=p(x);return i(E)}t.b64UrlToString=a;function i(x){return new TextDecoder("utf-8",{fatal:!0}).decode(x)}t.bufferToString=i;function h(x){return new TextEncoder().encode(x)}t.stringToBuffer=h;function l(x){return g(h(x))}t.stringToB64Url=l;function p(x){return new Uint8Array(e.toByteArray(M(x)))}t.b64UrlToBuffer=p;function b(x){return e.fromByteArray(new Uint8Array(x))}t.bufferTob64=b;function g(x){return y(b(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 E;return x.length%4==0?E=0:E=4-x.length%4,x.concat("=".repeat(E))}t.b64UrlDecode=M}),vEe=zh(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var e=mte(),r=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 a=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),i=await this.driver.exportKey("jwk",a.privateKey);return{kty:i.kty,e:i.e,n:i.n,d:i.d,p:i.p,q:i.q,dp:i.dp,dq:i.dq,qi:i.qi}}async sign(a,i,{saltLength:h}={}){let l=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(a),i);return new Uint8Array(l)}async hash(a,i="SHA-256"){let h=await this.driver.digest(i,a);return new Uint8Array(h)}async verify(a,i,h){let l={kty:"RSA",e:"AQAB",n:a},p=await this.jwkToPublicCryptoKey(l),b=await this.driver.digest("SHA-256",i),g=await this.driver.verify({name:"RSA-PSS",saltLength:0},p,h,i),y=await this.driver.verify({name:"RSA-PSS",saltLength:32},p,h,i),M=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((p.algorithm.modulusLength-1)/8)-b.byteLength-2},p,h,i);return g||y||M}async jwkToCryptoKey(a){return this.driver.importKey("jwk",a,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(a){return this.driver.importKey("jwk",a,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let a=crypto?.subtle;return a===void 0?!1:["generateKey","importKey","exportKey","digest","sign"].every(i=>typeof a[i]=="function")}async encrypt(a,i,h){let l=await this.driver.importKey("raw",typeof i=="string"?e.stringToBuffer(i):i,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:h?e.stringToBuffer(h):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},l,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),b=new Uint8Array(16);crypto.getRandomValues(b);let g=await this.driver.encrypt({name:"AES-CBC",iv:b},p,a);return e.concatBuffers([b,g])}async decrypt(a,i,h){let l=await this.driver.importKey("raw",typeof i=="string"?e.stringToBuffer(i):i,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:h?e.stringToBuffer(h):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},l,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),b=a.slice(0,16),g=await this.driver.decrypt({name:"AES-CBC",iv:b},p,a.slice(16));return e.concatBuffers([g])}};t.default=r}),mEe=zh(t=>{t.read=function(e,r,a,i,h){var l,p,b=h*8-i-1,g=(1<<b)-1,y=g>>1,M=-7,x=a?h-1:0,E=a?-1:1,A=e[r+x];for(x+=E,l=A&(1<<-M)-1,A>>=-M,M+=b;M>0;l=l*256+e[r+x],x+=E,M-=8);for(p=l&(1<<-M)-1,l>>=-M,M+=i;M>0;p=p*256+e[r+x],x+=E,M-=8);if(l===0)l=1-y;else{if(l===g)return p?NaN:(A?-1:1)*(1/0);p=p+Math.pow(2,i),l=l-y}return(A?-1:1)*p*Math.pow(2,l-i)},t.write=function(e,r,a,i,h,l){var p,b,g,y=l*8-h-1,M=(1<<y)-1,x=M>>1,E=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=i?0:l-1,I=i?1:-1,P=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(b=isNaN(r)?1:0,p=M):(p=Math.floor(Math.log(r)/Math.LN2),r*(g=Math.pow(2,-p))<1&&(p--,g*=2),p+x>=1?r+=E/g:r+=E*Math.pow(2,1-x),r*g>=2&&(p++,g/=2),p+x>=M?(b=0,p=M):p+x>=1?(b=(r*g-1)*Math.pow(2,h),p=p+x):(b=r*Math.pow(2,x-1)*Math.pow(2,h),p=0));h>=8;e[a+A]=b&255,A+=I,b/=256,h-=8);for(p=p<<h|b,y+=h;y>0;e[a+A]=p&255,A+=I,p/=256,y-=8);e[a+A-I]|=P*128}}),tI=zh(t=>{"use strict";var e=vte(),r=mEe(),a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=p,t.SlowBuffer=L,t.INSPECT_MAX_BYTES=50;var i=2147483647;t.kMaxLength=i,p.TYPED_ARRAY_SUPPORT=h(),!p.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 h(){try{let T=new Uint8Array(1),k={foo:function(){return 42}};return Object.setPrototypeOf(k,Uint8Array.prototype),Object.setPrototypeOf(T,k),T.foo()===42}catch{return!1}}Object.defineProperty(p.prototype,"parent",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.buffer}}),Object.defineProperty(p.prototype,"offset",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.byteOffset}});function l(T){if(T>i)throw new RangeError('The value "'+T+'" is invalid for option "size"');let k=new Uint8Array(T);return Object.setPrototypeOf(k,p.prototype),k}function p(T,k,O){if(typeof T=="number"){if(typeof k=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return M(T)}return b(T,k,O)}p.poolSize=8192;function b(T,k,O){if(typeof T=="string")return x(T,k);if(ArrayBuffer.isView(T))return A(T);if(T==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T);if(ut(T,ArrayBuffer)||T&&ut(T.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ut(T,SharedArrayBuffer)||T&&ut(T.buffer,SharedArrayBuffer)))return I(T,k,O);if(typeof T=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let q=T.valueOf&&T.valueOf();if(q!=null&&q!==T)return p.from(q,k,O);let H=P(T);if(H)return H;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof T[Symbol.toPrimitive]=="function")return p.from(T[Symbol.toPrimitive]("string"),k,O);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T)}p.from=function(T,k,O){return b(T,k,O)},Object.setPrototypeOf(p.prototype,Uint8Array.prototype),Object.setPrototypeOf(p,Uint8Array);function g(T){if(typeof T!="number")throw new TypeError('"size" argument must be of type number');if(T<0)throw new RangeError('The value "'+T+'" is invalid for option "size"')}function y(T,k,O){return g(T),T<=0?l(T):k!==void 0?typeof O=="string"?l(T).fill(k,O):l(T).fill(k):l(T)}p.alloc=function(T,k,O){return y(T,k,O)};function M(T){return g(T),l(T<0?0:N(T)|0)}p.allocUnsafe=function(T){return M(T)},p.allocUnsafeSlow=function(T){return M(T)};function x(T,k){if((typeof k!="string"||k==="")&&(k="utf8"),!p.isEncoding(k))throw new TypeError("Unknown encoding: "+k);let O=C(T,k)|0,q=l(O),H=q.write(T,k);return H!==O&&(q=q.slice(0,H)),q}function E(T){let k=T.length<0?0:N(T.length)|0,O=l(k);for(let q=0;q<k;q+=1)O[q]=T[q]&255;return O}function A(T){if(ut(T,Uint8Array)){let k=new Uint8Array(T);return I(k.buffer,k.byteOffset,k.byteLength)}return E(T)}function I(T,k,O){if(k<0||T.byteLength<k)throw new RangeError('"offset" is outside of buffer bounds');if(T.byteLength<k+(O||0))throw new RangeError('"length" is outside of buffer bounds');let q;return k===void 0&&O===void 0?q=new Uint8Array(T):O===void 0?q=new Uint8Array(T,k):q=new Uint8Array(T,k,O),Object.setPrototypeOf(q,p.prototype),q}function P(T){if(p.isBuffer(T)){let k=N(T.length)|0,O=l(k);return O.length===0||T.copy(O,0,0,k),O}if(T.length!==void 0)return typeof T.length!="number"||Ze(T.length)?l(0):E(T);if(T.type==="Buffer"&&Array.isArray(T.data))return E(T.data)}function N(T){if(T>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return T|0}function L(T){return+T!=T&&(T=0),p.alloc(+T)}p.isBuffer=function(T){return T!=null&&T._isBuffer===!0&&T!==p.prototype},p.compare=function(T,k){if(ut(T,Uint8Array)&&(T=p.from(T,T.offset,T.byteLength)),ut(k,Uint8Array)&&(k=p.from(k,k.offset,k.byteLength)),!p.isBuffer(T)||!p.isBuffer(k))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(T===k)return 0;let O=T.length,q=k.length;for(let H=0,W=Math.min(O,q);H<W;++H)if(T[H]!==k[H]){O=T[H],q=k[H];break}return O<q?-1:q<O?1:0},p.isEncoding=function(T){switch(String(T).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}},p.concat=function(T,k){if(!Array.isArray(T))throw new TypeError('"list" argument must be an Array of Buffers');if(T.length===0)return p.alloc(0);let O;if(k===void 0)for(k=0,O=0;O<T.length;++O)k+=T[O].length;let q=p.allocUnsafe(k),H=0;for(O=0;O<T.length;++O){let W=T[O];if(ut(W,Uint8Array))H+W.length>q.length?(p.isBuffer(W)||(W=p.from(W)),W.copy(q,H)):Uint8Array.prototype.set.call(q,W,H);else if(p.isBuffer(W))W.copy(q,H);else throw new TypeError('"list" argument must be an Array of Buffers');H+=W.length}return q};function C(T,k){if(p.isBuffer(T))return T.length;if(ArrayBuffer.isView(T)||ut(T,ArrayBuffer))return T.byteLength;if(typeof T!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof T);let O=T.length,q=arguments.length>2&&arguments[2]===!0;if(!q&&O===0)return 0;let H=!1;for(;;)switch(k){case"ascii":case"latin1":case"binary":return O;case"utf8":case"utf-8":return oe(T).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O*2;case"hex":return O>>>1;case"base64":return ge(T).length;default:if(H)return q?-1:oe(T).length;k=(""+k).toLowerCase(),H=!0}}p.byteLength=C;function Y(T,k,O){let q=!1;if((k===void 0||k<0)&&(k=0),k>this.length||((O===void 0||O>this.length)&&(O=this.length),O<=0)||(O>>>=0,k>>>=0,O<=k))return"";for(T||(T="utf8");;)switch(T){case"hex":return o(this,k,O);case"utf8":case"utf-8":return u(this,k,O);case"ascii":return w(this,k,O);case"latin1":case"binary":return d(this,k,O);case"base64":return f(this,k,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,k,O);default:if(q)throw new TypeError("Unknown encoding: "+T);T=(T+"").toLowerCase(),q=!0}}p.prototype._isBuffer=!0;function G(T,k,O){let q=T[k];T[k]=T[O],T[O]=q}p.prototype.swap16=function(){let T=this.length;if(T%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let k=0;k<T;k+=2)G(this,k,k+1);return this},p.prototype.swap32=function(){let T=this.length;if(T%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let k=0;k<T;k+=4)G(this,k,k+3),G(this,k+1,k+2);return this},p.prototype.swap64=function(){let T=this.length;if(T%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let k=0;k<T;k+=8)G(this,k,k+7),G(this,k+1,k+6),G(this,k+2,k+5),G(this,k+3,k+4);return this},p.prototype.toString=function(){let T=this.length;return T===0?"":arguments.length===0?u(this,0,T):Y.apply(this,arguments)},p.prototype.toLocaleString=p.prototype.toString,p.prototype.equals=function(T){if(!p.isBuffer(T))throw new TypeError("Argument must be a Buffer");return this===T?!0:p.compare(this,T)===0},p.prototype.inspect=function(){let T="",k=t.INSPECT_MAX_BYTES;return T=this.toString("hex",0,k).replace(/(.{2})/g,"$1 ").trim(),this.length>k&&(T+=" ... "),"<Buffer "+T+">"},a&&(p.prototype[a]=p.prototype.inspect),p.prototype.compare=function(T,k,O,q,H){if(ut(T,Uint8Array)&&(T=p.from(T,T.offset,T.byteLength)),!p.isBuffer(T))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof T);if(k===void 0&&(k=0),O===void 0&&(O=T?T.length:0),q===void 0&&(q=0),H===void 0&&(H=this.length),k<0||O>T.length||q<0||H>this.length)throw new RangeError("out of range index");if(q>=H&&k>=O)return 0;if(q>=H)return-1;if(k>=O)return 1;if(k>>>=0,O>>>=0,q>>>=0,H>>>=0,this===T)return 0;let W=H-q,fe=O-k,st=Math.min(W,fe),ue=this.slice(q,H),me=T.slice(k,O);for(let pe=0;pe<st;++pe)if(ue[pe]!==me[pe]){W=ue[pe],fe=me[pe];break}return W<fe?-1:fe<W?1:0};function ee(T,k,O,q,H){if(T.length===0)return-1;if(typeof O=="string"?(q=O,O=0):O>2147483647?O=2147483647:O<-2147483648&&(O=-2147483648),O=+O,Ze(O)&&(O=H?0:T.length-1),O<0&&(O=T.length+O),O>=T.length){if(H)return-1;O=T.length-1}else if(O<0)if(H)O=0;else return-1;if(typeof k=="string"&&(k=p.from(k,q)),p.isBuffer(k))return k.length===0?-1:D(T,k,O,q,H);if(typeof k=="number")return k=k&255,typeof Uint8Array.prototype.indexOf=="function"?H?Uint8Array.prototype.indexOf.call(T,k,O):Uint8Array.prototype.lastIndexOf.call(T,k,O):D(T,[k],O,q,H);throw new TypeError("val must be string, number or Buffer")}function D(T,k,O,q,H){let W=1,fe=T.length,st=k.length;if(q!==void 0&&(q=String(q).toLowerCase(),q==="ucs2"||q==="ucs-2"||q==="utf16le"||q==="utf-16le")){if(T.length<2||k.length<2)return-1;W=2,fe/=2,st/=2,O/=2}function ue(pe,be){return W===1?pe[be]:pe.readUInt16BE(be*W)}let me;if(H){let pe=-1;for(me=O;me<fe;me++)if(ue(T,me)===ue(k,pe===-1?0:me-pe)){if(pe===-1&&(pe=me),me-pe+1===st)return pe*W}else pe!==-1&&(me-=me-pe),pe=-1}else for(O+st>fe&&(O=fe-st),me=O;me>=0;me--){let pe=!0;for(let be=0;be<st;be++)if(ue(T,me+be)!==ue(k,be)){pe=!1;break}if(pe)return me}return-1}p.prototype.includes=function(T,k,O){return this.indexOf(T,k,O)!==-1},p.prototype.indexOf=function(T,k,O){return ee(this,T,k,O,!0)},p.prototype.lastIndexOf=function(T,k,O){return ee(this,T,k,O,!1)};function U(T,k,O,q){O=Number(O)||0;let H=T.length-O;q?(q=Number(q),q>H&&(q=H)):q=H;let W=k.length;q>W/2&&(q=W/2);let fe;for(fe=0;fe<q;++fe){let st=parseInt(k.substr(fe*2,2),16);if(Ze(st))return fe;T[O+fe]=st}return fe}function V(T,k,O,q){return Se(oe(k,T.length-O),T,O,q)}function _(T,k,O,q){return Se(ce(k),T,O,q)}function n(T,k,O,q){return Se(ge(k),T,O,q)}function s(T,k,O,q){return Se(ot(k,T.length-O),T,O,q)}p.prototype.write=function(T,k,O,q){if(k===void 0)q="utf8",O=this.length,k=0;else if(O===void 0&&typeof k=="string")q=k,O=this.length,k=0;else if(isFinite(k))k=k>>>0,isFinite(O)?(O=O>>>0,q===void 0&&(q="utf8")):(q=O,O=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let H=this.length-k;if((O===void 0||O>H)&&(O=H),T.length>0&&(O<0||k<0)||k>this.length)throw new RangeError("Attempt to write outside buffer bounds");q||(q="utf8");let W=!1;for(;;)switch(q){case"hex":return U(this,T,k,O);case"utf8":case"utf-8":return V(this,T,k,O);case"ascii":case"latin1":case"binary":return _(this,T,k,O);case"base64":return n(this,T,k,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s(this,T,k,O);default:if(W)throw new TypeError("Unknown encoding: "+q);q=(""+q).toLowerCase(),W=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function f(T,k,O){return k===0&&O===T.length?e.fromByteArray(T):e.fromByteArray(T.slice(k,O))}function u(T,k,O){O=Math.min(T.length,O);let q=[],H=k;for(;H<O;){let W=T[H],fe=null,st=W>239?4:W>223?3:W>191?2:1;if(H+st<=O){let ue,me,pe,be;switch(st){case 1:W<128&&(fe=W);break;case 2:ue=T[H+1],(ue&192)===128&&(be=(W&31)<<6|ue&63,be>127&&(fe=be));break;case 3:ue=T[H+1],me=T[H+2],(ue&192)===128&&(me&192)===128&&(be=(W&15)<<12|(ue&63)<<6|me&63,be>2047&&(be<55296||be>57343)&&(fe=be));break;case 4:ue=T[H+1],me=T[H+2],pe=T[H+3],(ue&192)===128&&(me&192)===128&&(pe&192)===128&&(be=(W&15)<<18|(ue&63)<<12|(me&63)<<6|pe&63,be>65535&&be<1114112&&(fe=be))}}fe===null?(fe=65533,st=1):fe>65535&&(fe-=65536,q.push(fe>>>10&1023|55296),fe=56320|fe&1023),q.push(fe),H+=st}return m(q)}var c=4096;function m(T){let k=T.length;if(k<=c)return String.fromCharCode.apply(String,T);let O="",q=0;for(;q<k;)O+=String.fromCharCode.apply(String,T.slice(q,q+=c));return O}function w(T,k,O){let q="";O=Math.min(T.length,O);for(let H=k;H<O;++H)q+=String.fromCharCode(T[H]&127);return q}function d(T,k,O){let q="";O=Math.min(T.length,O);for(let H=k;H<O;++H)q+=String.fromCharCode(T[H]);return q}function o(T,k,O){let q=T.length;(!k||k<0)&&(k=0),(!O||O<0||O>q)&&(O=q);let H="";for(let W=k;W<O;++W)H+=Ge[T[W]];return H}function v(T,k,O){let q=T.slice(k,O),H="";for(let W=0;W<q.length-1;W+=2)H+=String.fromCharCode(q[W]+q[W+1]*256);return H}p.prototype.slice=function(T,k){let O=this.length;T=~~T,k=k===void 0?O:~~k,T<0?(T+=O,T<0&&(T=0)):T>O&&(T=O),k<0?(k+=O,k<0&&(k=0)):k>O&&(k=O),k<T&&(k=T);let q=this.subarray(T,k);return Object.setPrototypeOf(q,p.prototype),q};function R(T,k,O){if(T%1!==0||T<0)throw new RangeError("offset is not uint");if(T+k>O)throw new RangeError("Trying to access beyond buffer length")}p.prototype.readUintLE=p.prototype.readUIntLE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=this[T],H=1,W=0;for(;++W<k&&(H*=256);)q+=this[T+W]*H;return q},p.prototype.readUintBE=p.prototype.readUIntBE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=this[T+--k],H=1;for(;k>0&&(H*=256);)q+=this[T+--k]*H;return q},p.prototype.readUint8=p.prototype.readUInt8=function(T,k){return T=T>>>0,k||R(T,1,this.length),this[T]},p.prototype.readUint16LE=p.prototype.readUInt16LE=function(T,k){return T=T>>>0,k||R(T,2,this.length),this[T]|this[T+1]<<8},p.prototype.readUint16BE=p.prototype.readUInt16BE=function(T,k){return T=T>>>0,k||R(T,2,this.length),this[T]<<8|this[T+1]},p.prototype.readUint32LE=p.prototype.readUInt32LE=function(T,k){return T=T>>>0,k||R(T,4,this.length),(this[T]|this[T+1]<<8|this[T+2]<<16)+this[T+3]*16777216},p.prototype.readUint32BE=p.prototype.readUInt32BE=function(T,k){return T=T>>>0,k||R(T,4,this.length),this[T]*16777216+(this[T+1]<<16|this[T+2]<<8|this[T+3])},p.prototype.readBigUInt64LE=lt(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=k+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24,H=this[++T]+this[++T]*2**8+this[++T]*2**16+O*2**24;return BigInt(q)+(BigInt(H)<<BigInt(32))}),p.prototype.readBigUInt64BE=lt(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=k*2**24+this[++T]*2**16+this[++T]*2**8+this[++T],H=this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+O;return(BigInt(q)<<BigInt(32))+BigInt(H)}),p.prototype.readIntLE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=this[T],H=1,W=0;for(;++W<k&&(H*=256);)q+=this[T+W]*H;return H*=128,q>=H&&(q-=Math.pow(2,8*k)),q},p.prototype.readIntBE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=k,H=1,W=this[T+--q];for(;q>0&&(H*=256);)W+=this[T+--q]*H;return H*=128,W>=H&&(W-=Math.pow(2,8*k)),W},p.prototype.readInt8=function(T,k){return T=T>>>0,k||R(T,1,this.length),this[T]&128?(255-this[T]+1)*-1:this[T]},p.prototype.readInt16LE=function(T,k){T=T>>>0,k||R(T,2,this.length);let O=this[T]|this[T+1]<<8;return O&32768?O|4294901760:O},p.prototype.readInt16BE=function(T,k){T=T>>>0,k||R(T,2,this.length);let O=this[T+1]|this[T]<<8;return O&32768?O|4294901760:O},p.prototype.readInt32LE=function(T,k){return T=T>>>0,k||R(T,4,this.length),this[T]|this[T+1]<<8|this[T+2]<<16|this[T+3]<<24},p.prototype.readInt32BE=function(T,k){return T=T>>>0,k||R(T,4,this.length),this[T]<<24|this[T+1]<<16|this[T+2]<<8|this[T+3]},p.prototype.readBigInt64LE=lt(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=this[T+4]+this[T+5]*2**8+this[T+6]*2**16+(O<<24);return(BigInt(q)<<BigInt(32))+BigInt(k+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24)}),p.prototype.readBigInt64BE=lt(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=(k<<24)+this[++T]*2**16+this[++T]*2**8+this[++T];return(BigInt(q)<<BigInt(32))+BigInt(this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+O)}),p.prototype.readFloatLE=function(T,k){return T=T>>>0,k||R(T,4,this.length),r.read(this,T,!0,23,4)},p.prototype.readFloatBE=function(T,k){return T=T>>>0,k||R(T,4,this.length),r.read(this,T,!1,23,4)},p.prototype.readDoubleLE=function(T,k){return T=T>>>0,k||R(T,8,this.length),r.read(this,T,!0,52,8)},p.prototype.readDoubleBE=function(T,k){return T=T>>>0,k||R(T,8,this.length),r.read(this,T,!1,52,8)};function S(T,k,O,q,H,W){if(!p.isBuffer(T))throw new TypeError('"buffer" argument must be a Buffer instance');if(k>H||k<W)throw new RangeError('"value" argument is out of bounds');if(O+q>T.length)throw new RangeError("Index out of range")}p.prototype.writeUintLE=p.prototype.writeUIntLE=function(T,k,O,q){if(T=+T,k=k>>>0,O=O>>>0,!q){let fe=Math.pow(2,8*O)-1;S(this,T,k,O,fe,0)}let H=1,W=0;for(this[k]=T&255;++W<O&&(H*=256);)this[k+W]=T/H&255;return k+O},p.prototype.writeUintBE=p.prototype.writeUIntBE=function(T,k,O,q){if(T=+T,k=k>>>0,O=O>>>0,!q){let fe=Math.pow(2,8*O)-1;S(this,T,k,O,fe,0)}let H=O-1,W=1;for(this[k+H]=T&255;--H>=0&&(W*=256);)this[k+H]=T/W&255;return k+O},p.prototype.writeUint8=p.prototype.writeUInt8=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,1,255,0),this[k]=T&255,k+1},p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,65535,0),this[k]=T&255,this[k+1]=T>>>8,k+2},p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,65535,0),this[k]=T>>>8,this[k+1]=T&255,k+2},p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,4294967295,0),this[k+3]=T>>>24,this[k+2]=T>>>16,this[k+1]=T>>>8,this[k]=T&255,k+4},p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,4294967295,0),this[k]=T>>>24,this[k+1]=T>>>16,this[k+2]=T>>>8,this[k+3]=T&255,k+4};function B(T,k,O,q,H){j(k,q,H,T,O,7);let W=Number(k&BigInt(4294967295));T[O++]=W,W=W>>8,T[O++]=W,W=W>>8,T[O++]=W,W=W>>8,T[O++]=W;let fe=Number(k>>BigInt(32)&BigInt(4294967295));return T[O++]=fe,fe=fe>>8,T[O++]=fe,fe=fe>>8,T[O++]=fe,fe=fe>>8,T[O++]=fe,O}function F(T,k,O,q,H){j(k,q,H,T,O,7);let W=Number(k&BigInt(4294967295));T[O+7]=W,W=W>>8,T[O+6]=W,W=W>>8,T[O+5]=W,W=W>>8,T[O+4]=W;let fe=Number(k>>BigInt(32)&BigInt(4294967295));return T[O+3]=fe,fe=fe>>8,T[O+2]=fe,fe=fe>>8,T[O+1]=fe,fe=fe>>8,T[O]=fe,O+8}p.prototype.writeBigUInt64LE=lt(function(T,k=0){return B(this,T,k,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeBigUInt64BE=lt(function(T,k=0){return F(this,T,k,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeIntLE=function(T,k,O,q){if(T=+T,k=k>>>0,!q){let st=Math.pow(2,8*O-1);S(this,T,k,O,st-1,-st)}let H=0,W=1,fe=0;for(this[k]=T&255;++H<O&&(W*=256);)T<0&&fe===0&&this[k+H-1]!==0&&(fe=1),this[k+H]=(T/W>>0)-fe&255;return k+O},p.prototype.writeIntBE=function(T,k,O,q){if(T=+T,k=k>>>0,!q){let st=Math.pow(2,8*O-1);S(this,T,k,O,st-1,-st)}let H=O-1,W=1,fe=0;for(this[k+H]=T&255;--H>=0&&(W*=256);)T<0&&fe===0&&this[k+H+1]!==0&&(fe=1),this[k+H]=(T/W>>0)-fe&255;return k+O},p.prototype.writeInt8=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,1,127,-128),T<0&&(T=255+T+1),this[k]=T&255,k+1},p.prototype.writeInt16LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,32767,-32768),this[k]=T&255,this[k+1]=T>>>8,k+2},p.prototype.writeInt16BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,32767,-32768),this[k]=T>>>8,this[k+1]=T&255,k+2},p.prototype.writeInt32LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,2147483647,-2147483648),this[k]=T&255,this[k+1]=T>>>8,this[k+2]=T>>>16,this[k+3]=T>>>24,k+4},p.prototype.writeInt32BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,2147483647,-2147483648),T<0&&(T=4294967295+T+1),this[k]=T>>>24,this[k+1]=T>>>16,this[k+2]=T>>>8,this[k+3]=T&255,k+4},p.prototype.writeBigInt64LE=lt(function(T,k=0){return B(this,T,k,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),p.prototype.writeBigInt64BE=lt(function(T,k=0){return F(this,T,k,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function $(T,k,O,q,H,W){if(O+q>T.length)throw new RangeError("Index out of range");if(O<0)throw new RangeError("Index out of range")}function re(T,k,O,q,H){return k=+k,O=O>>>0,H||$(T,k,O,4,34028234663852886e22,-34028234663852886e22),r.write(T,k,O,q,23,4),O+4}p.prototype.writeFloatLE=function(T,k,O){return re(this,T,k,!0,O)},p.prototype.writeFloatBE=function(T,k,O){return re(this,T,k,!1,O)};function Q(T,k,O,q,H){return k=+k,O=O>>>0,H||$(T,k,O,8,17976931348623157e292,-17976931348623157e292),r.write(T,k,O,q,52,8),O+8}p.prototype.writeDoubleLE=function(T,k,O){return Q(this,T,k,!0,O)},p.prototype.writeDoubleBE=function(T,k,O){return Q(this,T,k,!1,O)},p.prototype.copy=function(T,k,O,q){if(!p.isBuffer(T))throw new TypeError("argument should be a Buffer");if(O||(O=0),!q&&q!==0&&(q=this.length),k>=T.length&&(k=T.length),k||(k=0),q>0&&q<O&&(q=O),q===O||T.length===0||this.length===0)return 0;if(k<0)throw new RangeError("targetStart out of bounds");if(O<0||O>=this.length)throw new RangeError("Index out of range");if(q<0)throw new RangeError("sourceEnd out of bounds");q>this.length&&(q=this.length),T.length-k<q-O&&(q=T.length-k+O);let H=q-O;return this===T&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(k,O,q):Uint8Array.prototype.set.call(T,this.subarray(O,q),k),H},p.prototype.fill=function(T,k,O,q){if(typeof T=="string"){if(typeof k=="string"?(q=k,k=0,O=this.length):typeof O=="string"&&(q=O,O=this.length),q!==void 0&&typeof q!="string")throw new TypeError("encoding must be a string");if(typeof q=="string"&&!p.isEncoding(q))throw new TypeError("Unknown encoding: "+q);if(T.length===1){let W=T.charCodeAt(0);(q==="utf8"&&W<128||q==="latin1")&&(T=W)}}else typeof T=="number"?T=T&255:typeof T=="boolean"&&(T=Number(T));if(k<0||this.length<k||this.length<O)throw new RangeError("Out of range index");if(O<=k)return this;k=k>>>0,O=O===void 0?this.length:O>>>0,T||(T=0);let H;if(typeof T=="number")for(H=k;H<O;++H)this[H]=T;else{let W=p.isBuffer(T)?T:p.from(T,q),fe=W.length;if(fe===0)throw new TypeError('The value "'+T+'" is invalid for argument "value"');for(H=0;H<O-k;++H)this[H+k]=W[H%fe]}return this};var Z={};function K(T,k,O){Z[T]=class extends O{constructor(){super(),Object.defineProperty(this,"message",{value:k.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${T}]`,this.stack,delete this.name}get code(){return T}set code(q){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:q,writable:!0})}toString(){return`${this.name} [${T}]: ${this.message}`}}}K("ERR_BUFFER_OUT_OF_BOUNDS",function(T){return T?`${T} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),K("ERR_INVALID_ARG_TYPE",function(T,k){return`The "${T}" argument must be of type number. Received type ${typeof k}`},TypeError),K("ERR_OUT_OF_RANGE",function(T,k,O){let q=`The value of "${T}" is out of range.`,H=O;return Number.isInteger(O)&&Math.abs(O)>2**32?H=le(String(O)):typeof O=="bigint"&&(H=String(O),(O>BigInt(2)**BigInt(32)||O<-(BigInt(2)**BigInt(32)))&&(H=le(H)),H+="n"),q+=` It must be ${k}. Received ${H}`,q},RangeError);function le(T){let k="",O=T.length,q=T[0]==="-"?1:0;for(;O>=q+4;O-=3)k=`_${T.slice(O-3,O)}${k}`;return`${T.slice(0,O)}${k}`}function te(T,k,O){J(k,"offset"),(T[k]===void 0||T[k+O]===void 0)&&X(k,T.length-(O+1))}function j(T,k,O,q,H,W){if(T>O||T<k){let fe=typeof k=="bigint"?"n":"",st;throw W>3?k===0||k===BigInt(0)?st=`>= 0${fe} and < 2${fe} ** ${(W+1)*8}${fe}`:st=`>= -(2${fe} ** ${(W+1)*8-1}${fe}) and < 2 ** ${(W+1)*8-1}${fe}`:st=`>= ${k}${fe} and <= ${O}${fe}`,new Z.ERR_OUT_OF_RANGE("value",st,T)}te(q,H,W)}function J(T,k){if(typeof T!="number")throw new Z.ERR_INVALID_ARG_TYPE(k,"number",T)}function X(T,k,O){throw Math.floor(T)!==T?(J(T,O),new Z.ERR_OUT_OF_RANGE(O||"offset","an integer",T)):k<0?new Z.ERR_BUFFER_OUT_OF_BOUNDS:new Z.ERR_OUT_OF_RANGE(O||"offset",`>= ${O?1:0} and <= ${k}`,T)}var he=/[^+/0-9A-Za-z-_]/g;function Te(T){if(T=T.split("=")[0],T=T.trim().replace(he,""),T.length<2)return"";for(;T.length%4!==0;)T=T+"=";return T}function oe(T,k){k=k||1/0;let O,q=T.length,H=null,W=[];for(let fe=0;fe<q;++fe){if(O=T.charCodeAt(fe),O>55295&&O<57344){if(!H){if(O>56319){(k-=3)>-1&&W.push(239,191,189);continue}else if(fe+1===q){(k-=3)>-1&&W.push(239,191,189);continue}H=O;continue}if(O<56320){(k-=3)>-1&&W.push(239,191,189),H=O;continue}O=(H-55296<<10|O-56320)+65536}else H&&(k-=3)>-1&&W.push(239,191,189);if(H=null,O<128){if((k-=1)<0)break;W.push(O)}else if(O<2048){if((k-=2)<0)break;W.push(O>>6|192,O&63|128)}else if(O<65536){if((k-=3)<0)break;W.push(O>>12|224,O>>6&63|128,O&63|128)}else if(O<1114112){if((k-=4)<0)break;W.push(O>>18|240,O>>12&63|128,O>>6&63|128,O&63|128)}else throw new Error("Invalid code point")}return W}function ce(T){let k=[];for(let O=0;O<T.length;++O)k.push(T.charCodeAt(O)&255);return k}function ot(T,k){let O,q,H,W=[];for(let fe=0;fe<T.length&&!((k-=2)<0);++fe)O=T.charCodeAt(fe),q=O>>8,H=O%256,W.push(H),W.push(q);return W}function ge(T){return e.toByteArray(Te(T))}function Se(T,k,O,q){let H;for(H=0;H<q&&!(H+O>=k.length||H>=T.length);++H)k[H+O]=T[H];return H}function ut(T,k){return T instanceof k||T!=null&&T.constructor!=null&&T.constructor.name!=null&&T.constructor.name===k.name}function Ze(T){return T!==T}var Ge=function(){let T="0123456789abcdef",k=new Array(256);for(let O=0;O<16;++O){let q=O*16;for(let H=0;H<16;++H)k[q+H]=T[O]+T[H]}return k}();function lt(T){return typeof BigInt>"u"?z:T}function z(){throw new Error("BigInt not supported")}}),gEe=zh((t,e)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,e.exports={Buffer:tI().Buffer,Crypto:window.crypto}):e.exports={Buffer:tI().Buffer,Crypto:crypto}}),gte={};lEe(gte,{AVSCTap:()=>k2,ArweaveSigner:()=>RI,DataItem:()=>E2,MAX_TAG_BYTES:()=>S4,MIN_BINARY_SIZE:()=>kI,SIG_CONFIG:()=>K1,SignatureConfig:()=>Ns,Signer:()=>bte,createData:()=>Mte,deserializeTags:()=>p4,indexToType:()=>TI,serializeTags:()=>II,tagsExceedLimit:()=>_te});var bte=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(t,e,r,a){throw new Error("You must implement verify method on child")}},bEe=Rd(AI(),1),kf=Rd(mte(),1);async function yte(t){if(Array.isArray(t)){let i=(0,kf.concatBuffers)([(0,kf.stringToBuffer)("list"),(0,kf.stringToBuffer)(t.length.toString())]);return await wte(t,await qh().hash(i,"SHA-384"))}let e=t,r=(0,kf.concatBuffers)([(0,kf.stringToBuffer)("blob"),(0,kf.stringToBuffer)(e.byteLength.toString())]),a=(0,kf.concatBuffers)([await qh().hash(r,"SHA-384"),await qh().hash(e,"SHA-384")]);return await qh().hash(a,"SHA-384")}async function wte(t,e){if(t.length<1)return e;let r=(0,kf.concatBuffers)([e,await yte(t[0])]),a=await qh().hash(r,"SHA-384");return await wte(t.slice(1),a)}var BT=Rd(vEe(),1),yEe=BT.default.default?BT.default.default:BT.default,wEe=class extends yEe{getPublicKey(t){throw new Error("Unimplemented")}},_Ee;function qh(){return _Ee??=new wEe}var Ns;(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"})(Ns||(Ns={}));var K1={[Ns.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[Ns.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[Ns.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[Ns.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[Ns.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[Ns.MULTIAPTOS]:{sigLength:64*32+4,pubLength:32*32+1,sigName:"multiAptos"},[Ns.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},RI=class{signatureType=1;ownerLength=K1[1].pubLength;signatureLength=K1[1].sigLength;jwk;pk;constructor(t){this.pk=t.n,this.jwk=t}get publicKey(){return bEe.default.toBuffer(this.pk)}sign(t){return qh().sign(this.jwk,t)}static async verify(t,e,r){return await qh().verify(t,e,r)}},TI={1:RI},Ou=Rd(AI(),1);async function rI(t){return yte([(0,kf.stringToBuffer)("dataitem"),(0,kf.stringToBuffer)("1"),(0,kf.stringToBuffer)(t.signatureType.toString()),t.rawOwner,t.rawTarget,t.rawAnchor,t.rawTags,t.rawData])}async function MEe(t,e){let r=await rI(t),a=await e.sign(r),i=await qh().hash(a);return{signature:Me.from(a),id:Me.from(i)}}async function xEe(t,e){let{signature:r,id:a}=await MEe(t,e);return t.getRaw().set(r,2),a}var k2=class{buf;pos;constructor(t=Me.alloc(S4),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,r;if(e)for(this.writeLong(e),r=0;r<e;r++){let a=t[r];if(a?.name===void 0||a?.value===void 0)throw new Error(`Invalid tag format for ${a}, expected {name:string, value: string}`);this.writeString(a.name),this.writeString(a.value)}this.writeLong(0)}toBuffer(){let t=Me.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,r,a;if(t>=-1073741824&&t<1073741824){a=t>=0?t<<1:~t<<1|1;do e[this.pos]=a&127,a>>=7;while(a&&(e[this.pos++]|=128))}else{r=t>=0?t*2:-t*2-1;do e[this.pos]=r&127,r/=128;while(r>=1&&(e[this.pos++]|=128))}this.pos++,this.buf=e}writeString(t){let e=Me.byteLength(t),r=this.buf;this.writeLong(e);let a=this.pos;if(this.pos+=e,!(this.pos>r.length)){if(e>64)this.buf.write(t,this.pos-e,e,"utf8");else{let i,h,l,p;for(i=0,h=e;i<h;i++)l=t.charCodeAt(i),l<128?r[a++]=l:l<2048?(r[a++]=l>>6|192,r[a++]=l&63|128):(l&64512)===55296&&((p=t.charCodeAt(i+1))&64512)===56320?(l=65536+((l&1023)<<10)+(p&1023),i++,r[a++]=l>>18|240,r[a++]=l>>12&63|128,r[a++]=l>>6&63|128,r[a++]=l&63|128):(r[a++]=l>>12|224,r[a++]=l>>6&63|128,r[a++]=l&63|128)}this.buf=r}}readLong(){let t=0,e=0,r=this.buf,a,i,h,l;do a=r[this.pos++],i=a&128,t|=(a&127)<<e,e+=7;while(i&&e<28);if(i){h=t,l=268435456;do a=r[this.pos++],h+=(a&127)*l,l*=128;while(a&128);return(h%2?-(h+1):h)/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 r=this.readString(),a=this.readString();t.push({name:r,value:a})}return t}readString(){let t=this.readLong(),e=this.pos,r=this.buf;if(this.pos+=t,!(this.pos>r.length))return this.buf.slice(e,e+t).toString()}};function II(t){let e=new k2;return e.writeTags(t),e.toBuffer()}function _te(t){let e=new k2;return e.writeTags(t),e.tagsExceedLimit()}function p4(t){return new k2(t).readTags()}function pc(t){let e=0;for(let r=t.length-1;r>=0;r--)e=e*256+t[r];return e}function SEe(t){if(t>29)throw new Error("Short too long");let e=[0,0];for(let r=0;r<e.length;r++){let a=t&255;e[r]=a,t=(t-a)/256}return Uint8Array.from(e)}function $Q(t){let e=[0,0,0,0,0,0,0,0];for(let r=0;r<e.length;r++){let a=t&255;e[r]=a,t=(t-a)/256}return Uint8Array.from(e)}var EEe=Rd(gEe(),1),A1=Rd(tI(),1),S4=4096,kI=80,E2=class{binary;_id;constructor(t){this.binary=t}static isDataItem(t){return t.binary!==void 0}get signatureType(){let t=pc(this.binary.subarray(0,2));if(Ns?.[t]!==void 0)return t;throw new Error("Unknown signature type: "+t)}async isValid(){return E2.verify(this.binary)}get id(){return(async()=>Ou.default.encode(await this.rawId))()}set id(t){this._id=Ou.default.toBuffer(t)}get rawId(){return(async()=>A1.Buffer.from(await EEe.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 Ou.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 K1[this.signatureType].sigLength}get owner(){return Ou.default.encode(this.rawOwner)}get ownerLength(){return K1[this.signatureType].pubLength}get rawTarget(){let t=this.getTargetStart();return this.binary[t]==1?this.binary.subarray(t+1,t+33):A1.Buffer.alloc(0)}get target(){return Ou.default.encode(this.rawTarget)}get rawAnchor(){let t=this.getAnchorStart();return this.binary[t]==1?this.binary.subarray(t+1,t+33):A1.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let t=this.getTagsStart(),e=pc(this.binary.subarray(t+8,t+16));return this.binary.subarray(t+16,t+16+e)}get tags(){let t=this.getTagsStart();if(pc(this.binary.subarray(t,t+8))==0)return[];let e=pc(this.binary.subarray(t+8,t+16));return p4(A1.Buffer.from(this.binary.subarray(t+16,t+16+e)))}get tagsB64Url(){return this.tags.map(t=>({name:Ou.default.encode(t.name),value:Ou.default.encode(t.value)}))}getStartOfData(){let t=this.getTagsStart(),e=this.binary.subarray(t+8,t+16),r=pc(e);return t+16+r}get rawData(){let t=this.getTagsStart(),e=this.binary.subarray(t+8,t+16),r=pc(e),a=t+16+r;return this.binary.subarray(a,this.binary.length)}get data(){return Ou.default.encode(this.rawData)}getRaw(){return this.binary}async sign(t){return this._id=await xEe(this,t),this.rawId}async setSignature(t){this.binary.set(t,2),this._id=A1.Buffer.from(await qh().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:Ou.default.encode(t.name),value:Ou.default.encode(t.value)})),data:this.data}}static async verify(t){if(t.byteLength<kI)return!1;let e=new E2(t),r=e.signatureType,a=e.getTagsStart(),i=pc(t.subarray(a,a+8)),h=t.subarray(a+8,a+16),l=pc(h);if(l>S4)return!1;if(i>0)try{if(p4(A1.Buffer.from(t.subarray(a+16,a+16+l))).length!==i)return!1}catch{return!1}let p=TI[r],b=await rI(e);return await p.verify(e.rawOwner,b,e.rawSignature)}async getSignatureData(){return rI(this)}getTagsStart(){let t=this.getTargetStart(),e=this.binary[t]==1,r=t+(e?33:1),a=this.binary[r]==1;return r+=a?33:1,r}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}},AEe=Rd(AI(),1);function Mte(t,e,r){let a=e.publicKey,i=r?.target?AEe.default.toBuffer(r.target):null,h=1+(i?.byteLength??0),l=r?.anchor?Me.from(r.anchor):null,p=1+(l?.byteLength??0),b=(r?.tags?.length??0)>0?II(r.tags):null,g=16+(b?b.byteLength:0),y=Me.from(t),M=y.byteLength,x=2+e.signatureLength+e.ownerLength+h+p+g+M,E=Me.alloc(x);if(E.set(SEe(e.signatureType),0),E.set(new Uint8Array(e.signatureLength).fill(0),2),a.byteLength!==e.ownerLength)throw new Error(`Owner must be ${e.ownerLength} bytes, but was incorrectly ${a.byteLength}`);E.set(a,2+e.signatureLength);let A=2+e.signatureLength+e.ownerLength;if(E[A]=i?1:0,i){if(i.byteLength!==32)throw new Error(`Target must be 32 bytes but was incorrectly ${i.byteLength}`);E.set(i,A+1)}let I=A+h,P=I+1;if(E[I]=l?1:0,l){if(P+=l.byteLength,l.byteLength!==32)throw new Error("Anchor must be 32 bytes");E.set(l,I+1)}E.set($Q(r?.tags?.length??0),P);let N=$Q(b?.byteLength??0);E.set(N,P+8),b&&E.set(b,P+16);let L=P+g;return E.set(y,L),new E2(E)}var BI={...gte};globalThis.arbundles??=BI;var REe=BI,TEe=BI;globalThis.Buffer||(globalThis.Buffer=dte.Buffer);var{DataItem:IEe}=pte;function kEe(t){return async({data:r,tags:a,target:i,anchor:h,createDataItem:l=p=>new IEe(p)})=>{let p=await t.signDataItem({data:r,tags:a,target:i,anchor:h}),b=l(dte.Buffer.from(p));return{id:await b.id,raw:await b.getRaw()}}}var BEe=globalThis.GATEWAY_URL||void 0,PEe=globalThis.MU_URL||void 0,OEe=globalThis.CU_URL||void 0,NEe=globalThis.GRAPHQL_URL||void 0,{result:dut,results:put,message:vut,spawn:mut,monitor:gut,unmonitor:but,dryrun:yut,assign:wut}=Sc({GATEWAY_URL:BEe,MU_URL:PEe,CU_URL:OEe,GRAPHQL_URL:NEe}),xte=cte.createDataItemSigner;ie();ae();ne();var mre=mi(vre(),1),O4=mre.default.init({host:"arweave.net",port:443,protocol:"https"});ie();ae();ne();ie();ae();ne();var Df=class extends Error{constructor(e){super(e),this.name=this.constructor.name}},gre=class extends Df{},bre=class extends Df{},yre=class extends Df{constructor(e,r){super(`Failed request: ${e}: ${r}`)}},wre=class extends Df{},N4=class extends Df{},_re=class extends Df{constructor(){super("Invalid signer. Please provide a valid signer to interact with the contract.")}},Rc=class extends Df{constructor(){super("Invalid contract configuration")}},Mre=class extends Df{constructor(){super("Invalid process configuration")}},xre=class extends Df{};ie();ae();ne();var Kf=mi(zfe(),1);ie();ae();ne();var Fw="3.3.1-alpha.4";var Wu=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,Kf.createLogger)({level:e,silent:this.silent,defaultMeta:{name:"ar-io-sdk",version:Fw},format:Kf.format.combine(Kf.format.timestamp(),Kf.format.json()),transports:[new Kf.transports.Console({format:Kf.format.combine(Kf.format.timestamp(),Kf.format.json())})]})}info(e,...r){this.silent||this.logger.info(e,...r)}warn(e,...r){this.silent||this.logger.warn(e,...r)}error(e,...r){this.silent||this.logger.error(e,...r)}debug(e,...r){this.silent||this.logger.debug(e,...r)}setLogLevel(e){this.silent=e==="none","silent"in this.logger&&(this.logger.silent=e==="none"),"level"in this.logger&&(this.logger.level=e)}};ie();ae();ne();ie();ae();ne();function Pc(t,e){let r=t.safeParse(e);if(!r.success)throw new Error(JSON.stringify(r.error.format(),null,2));return r}var jw=class{static init(e){return e!==void 0&&"signer"in e?new fP(e):new zw(e)}},zw=class{process;strict;constructor(e){if(this.strict=e.strict||!1,vv(e))this.process=e.process;else if(mv(e))this.process=new za({processId:e.processId});else throw new Rc}async getState({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"State"}],a=await this.process.read({tags:r});return e&&Pc(MT.passthrough().and(Qt.object({Records:Qt.record(Qt.string(),$8.passthrough())})),a),a}async getInfo({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"Info"}],a=await this.process.read({tags:r});return e&&Pc(dQ.passthrough(),a),a}async getLogo(){return(await this.getInfo()).Logo}async getRecord({undername:e},{strict:r}={strict:this.strict}){let a=[{name:"Sub-Domain",value:e},{name:"Action",value:"Record"}],i=await this.process.read({tags:a});return r&&Pc($8.passthrough(),i),i}async getRecords({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"Records"}],a=await this.process.read({tags:r});return e&&Pc(yT,a),a}async getOwner({strict:e}={strict:this.strict}){return(await this.getInfo({strict:e})).Owner}async getControllers({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"Controllers"}],a=await this.process.read({tags:r});return e&&Pc(wT,a),a}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 r=[{name:"Action",value:"Balances"}],a=await this.process.read({tags:r});return e&&Pc(_T,a),a}async getBalance({address:e},{strict:r}={strict:this.strict}){let a=[{name:"Action",value:"Balance"},{name:"Recipient",value:e}],i=await this.process.read({tags:a});return r&&Pc(Qt.number(),i),i}async getHandlers(){let e=await this.getInfo();return e.Handlers??e.HandlerNames}},fP=class extends zw{signer;constructor({signer:e,...r}){super(r),this.signer=pv(e)}async transfer({target:e},r){let a=[...r?.tags??[],{name:"Action",value:"Transfer"},{name:"Recipient",value:e}];return this.process.send({tags:a,signer:this.signer})}async addController({controller:e},r){let a=[...r?.tags??[],{name:"Action",value:"Add-Controller"},{name:"Controller",value:e}];return this.process.send({tags:a,signer:this.signer})}async removeController({controller:e},r){let a=[...r?.tags??[],{name:"Action",value:"Remove-Controller"},{name:"Controller",value:e}];return this.process.send({tags:a,signer:this.signer})}async setRecord({undername:e,transactionId:r,ttlSeconds:a},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:e},{name:"Transaction-Id",value:r},{name:"TTL-Seconds",value:a.toString()}],signer:this.signer})}async removeRecord({undername:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Remove-Record"},{name:"Sub-Domain",value:e}],signer:this.signer})}async setTicker({ticker:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Ticker"},{name:"Ticker",value:e}],signer:this.signer})}async setName({name:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Name"},{name:"Name",value:e}],signer:this.signer})}async setDescription({description:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Description"},{name:"Description",value:e}],signer:this.signer})}async setKeywords({keywords:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Keywords"},{name:"Keywords",value:JSON.stringify(e)}],signer:this.signer})}async setLogo({txId:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Logo"},{name:"Logo",value:e}],signer:this.signer})}async releaseName({name:e,arioProcessId:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Release-Name"},{name:"Name",value:e},{name:"IO-Process-Id",value:r},{name:"ARIO-Process-Id",value:r}],signer:this.signer})}async reassignName({name:e,arioProcessId:r,antProcessId:a},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Reassign-Name"},{name:"Name",value:e},{name:"IO-Process-Id",value:r},{name:"ARIO-Process-Id",value:r},{name:"Process-Id",value:a}],signer:this.signer})}async approvePrimaryNameRequest({name:e,address:r,arioProcessId:a},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Approve-Primary-Name"},{name:"Name",value:e},{name:"Recipient",value:r},{name:"IO-Process-Id",value:a},{name:"ARIO-Process-Id",value:a}],signer:this.signer})}async removePrimaryNames({names:e,arioProcessId:r,notifyOwners:a=!1},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Remove-Primary-Names"},{name:"Names",value:e.join(",")},{name:"IO-Process-Id",value:r},{name:"ARIO-Process-Id",value:r},{name:"Notify-Owners",value:a.toString()}],signer:this.signer})}};ie();ae();ne();var Sb=class{static init(e){return e!==void 0&&"signer"in e?new uP(e):new Zw(e)}},Zw=class{process;constructor(e){if(e===void 0||Object.keys(e).length===0)this.process=new za({processId:D8});else if(vv(e))this.process=e.process;else if(mv(e))this.process=new za({processId:e.processId});else throw new Rc}async accessControlList({address:e}){return this.process.read({tags:[{name:"Action",value:"Access-Control-List"},{name:"Address",value:e}]})}},uP=class extends Zw{signer;constructor({signer:e,...r}){super(r),this.signer=pv(e)}async register({processId:e}){return this.process.send({tags:[{name:"Action",value:"Register"},{name:"Process-Id",value:e}],signer:this.signer})}};ie();ae();ne();ie();ae();ne();ie();ae();ne();cu();var Zfe="+",Hfe="/",Kfe="-",Wfe="_",Vfe="=";function Qqe(t){let e=t.length%4;return e&&(t+=Vfe.repeat(4-e)),t.replaceAll(Kfe,Zfe).replaceAll(Wfe,Hfe)}function eUe(t){return t.replaceAll(Zfe,Kfe).replaceAll(Hfe,Wfe).replaceAll(Vfe,"")}function Gbt(t){let e=Qqe(t);return Me.from(e,"base64")}function tUe(t){let e=t.toString("base64");return eUe(e)}function Ybt(t){return tUe(df("sha256").update(Uint8Array.from(t)).digest())}function Gfe(t=32){let e=oE(t);return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("").slice(0,t)}ie();ae();ne();ie();ae();ne();function hP(t){try{return JSON.parse(t)}catch{return t}}ie();ae();ne();ie();ae();ne();var cP=mi(Jfe(),1);ie();ae();ne();var nUe=Object.defineProperty,aUe=(t,e,r)=>e in t?nUe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ab=(t,e,r)=>(aUe(t,typeof e!="symbol"?e+"":e,r),r),dP=class{constructor(e){Ab(this,"value"),Ab(this,"next"),this.value=e}},pP=class{constructor(){Ab(this,"head"),Ab(this,"tail"),Ab(this,"_size",0),this.clear()}clear(){this.head=void 0,this.tail=void 0,this._size=0}push(e){let r=new dP(e);return this.head&&this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),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 Xfe(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 pP,r=0,a=()=>{r--,e.size>0&&e.pop()()},i=async(p,b,g)=>{r++;let y=(async()=>p(...g))();b(y);try{await y}catch{}a()},h=(p,b,g)=>{e.push(i.bind(null,p,b,g)),(async()=>(await Promise.resolve(),r<t&&e.size>0&&e.pop()()))()},l=(p,...b)=>new Promise(g=>{h(p,g,b)});return Object.defineProperties(l,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),l}var Ryt=async({address:t,registry:e=Sb.init()})=>{let r=await e.accessControlList({address:t});return[...new Set([...r.Owned,...r.Controlled])]};function Qfe(t,e){return new Promise((r,a)=>{let i=setTimeout(()=>{a(new Error("Timeout"))},t);e.then(h=>{clearTimeout(i),r(h)}).catch(h=>{clearTimeout(i),a(h)})})}var eue=class extends cP.default{contract;timeoutMs;throttle;logger;strict;antAoClient;constructor({contract:e=Rb.init({processId:Lh}),timeoutMs:r=6e4,concurrency:a=30,logger:i=Wu.default,strict:h=!1,antAoClient:l=Sc()}={}){super(),this.contract=e,this.timeoutMs=r,this.throttle=Xfe(a),this.logger=i,this.strict=h,this.antAoClient=l}async fetchProcessesOwnedByWallet({address:e,pageSize:r,antRegistry:a=Sb.init()}){let i={},h=await a.accessControlList({address:e}),l=new Set([...h.Owned,...h.Controlled]);await Qfe(this.timeoutMs,oUe({contract:this.contract,emitter:this,pageSize:r})).catch(b=>(this.emit("error",`Error getting ArNS records: ${b}`),this.logger.error("Error getting ArNS records",{message:b?.message,stack:b?.stack}),{})).then(b=>{Object.entries(b).forEach(([g,y])=>{l.has(y.processId)&&(i[y.processId]==null&&(i[y.processId]={state:void 0,names:{}}),i[y.processId].names[g]=y)})});let p=Object.keys(i).length;this.emit("progress",0,p),await Promise.all(Object.keys(i).map(async(b,g)=>this.throttle(async()=>{if(i[b].state!==void 0){this.emit("progress",g+1,p);return}let y=jw.init({process:new za({processId:b,ao:this.antAoClient}),strict:this.strict}),M=await Qfe(this.timeoutMs,y.getState()).catch(x=>{this.emit("error",`Error getting state for process ${b}: ${x}`)});(M?.Owner===e||M?.Controllers.includes(e))&&(i[b].state=M,this.emit("process",b,i[b])),this.emit("progress",g+1,p)}))),this.emit("end",i)}},oUe=async({contract:t=Rb.init({processId:Lh}),emitter:e,logger:r=Wu.default,pageSize:a=5e4})=>{let i,h=Date.now(),l={};do{let p=await t.getArNSRecords({cursor:i,limit:a}).catch(b=>{r?.error("Error getting ArNS records",{message:b?.message,stack:b?.stack}),e?.emit("arns:error",`Error getting ArNS records: ${b}`)});if(!p)return{};p.items.forEach(b=>{let{name:g,...y}=b;l[g]=y}),r.debug("Fetched page of ArNS records",{totalRecordCount:p.totalItems,fetchedRecordCount:Object.keys(l).length,cursor:p.nextCursor}),e?.emit("arns:pageLoaded",{totalRecordCount:p.totalItems,fetchedRecordCount:Object.keys(l).length,records:p.items,cursor:p.nextCursor}),i=p.nextCursor}while(i!==void 0);return e?.emit("arns:end",l),r.debug("Fetched all ArNS records",{totalRecordCount:Object.keys(l).length,durationMs:Date.now()-h}),l};var za=class{logger;ao;processId;constructor({processId:e,ao:r=Sc(),logger:a=Wu.default}){this.processId=e,this.logger=a,this.ao=r}isMessageDataEmpty(e){return e===void 0||e==="null"||e===""||e===null}async read({tags:e,retries:r=3,fromAddress:a}){let i=0,h;for(;i<r;)try{this.logger.debug("Evaluating read interaction on process",{tags:e,processId:this.processId});let l={process:this.processId,tags:e};a!==void 0&&(l.Owner=a);let p=await this.ao.dryrun(l);this.logger.debug("Read interaction result",{result:p,processId:this.processId});let b=vP(p);if(b!==void 0)throw new Error(b);if(p.Messages===void 0||p.Messages.length===0)throw this.logger.debug(`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 g=p.Messages?.[0]?.Data;return this.isMessageDataEmpty(g)?void 0:hP(g)}catch(l){i++,this.logger.debug(`Read attempt ${i} failed`,{error:l?.message,stack:l?.stack,tags:e,processId:this.processId}),h=l,await new Promise(p=>setTimeout(p,2**i*1e3))}throw h}async send({tags:e,data:r,signer:a,retries:i=3}){let h=0,l;for(;h<i;)try{this.logger.debug("Evaluating send interaction on contract",{tags:e,data:r,processId:this.processId});let p=Gfe(32),b=await this.ao.message({process:this.processId,tags:[...e,{name:"AR-IO-SDK",value:Fw}],data:r,signer:a,anchor:p});this.logger.debug("Sent message to process",{messageId:b,processId:this.processId,anchor:p});let g=await this.ao.result({message:b,process:this.processId});this.logger.debug("Message result",{output:g,messageId:b,processId:this.processId});let y=vP(g);if(y!==void 0)throw new N4(y);if(g.Messages?.length===0||g.Messages===void 0)return{id:b};if(g.Messages.length===0)throw new Error(`Process ${this.processId} does not support provided action.`);if(this.isMessageDataEmpty(g.Messages[0].Data))return{id:b};let M=hP(g.Messages[0].Data);return this.logger.debug("Message result data",{resultData:M,messageId:b,processId:this.processId}),{id:b,result:M}}catch(p){if(this.logger.error("Error sending message to process",{error:p?.message,stack:p?.stack,processId:this.processId,tags:e}),p.message.includes("500"))this.logger.debug("Retrying send interaction",{attempts:h,retries:i,error:p?.message,processId:this.processId}),await new Promise(b=>setTimeout(b,2**h*2e3)),h++,l=p;else throw p}throw l}};var Rb=class{static init(e){return e!==void 0&&"signer"in e?new mP(e):new Ww(e)}},Ww=class{process;epochSettings;arweave;constructor(e){if(this.arweave=e?.arweave??O4,e===void 0||Object.keys(e).length===0)this.process=new za({processId:Lh});else if(vv(e))this.process=e.process;else if(mv(e))this.process=new za({processId:e.processId});else throw new Rc}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 r=await this.getEpochSettings(),a=r.epochZeroStartTimestamp,i=r.durationMs;return Math.floor((e-a)/i)}async computeCurrentEpochIndex(){let e=await this.getEpochSettings(),r=e.epochZeroStartTimestamp,a=e.durationMs,i=Date.now();return Math.floor((i-r)/a)}async computeEpochIndex(e){let r=e?.epochIndex;if(r!==void 0)return r.toString();let a=e?.timestamp;if(a!==void 0)return(await this.computeEpochIndexForTimestamp(a)).toString()}async getEpochSettings(){return this.epochSettings??=await this.process.read({tags:[{name:"Action",value:"Epoch-Settings"}]})}async getEpoch(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&+r<a)return await Kw({arweave:this.arweave,epochIndex:+r,processId:this.process.processId});let i=[{name:"Action",value:"Epoch"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(i)})}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"},...Ha(e)]})}async getArNSReservedNames(e){return this.process.read({tags:[{name:"Action",value:"Reserved-Names"},...Ha(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"},...Ha(e)]})}async getVault({address:e,vaultId:r}){return this.process.read({tags:[{name:"Action",value:"Vault"},{name:"Address",value:e},{name:"Vault-Id",value:r}]})}async getVaults(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Vaults"},...Ha(e)]})}async getGateway({address:e}){return this.process.read({tags:[{name:"Action",value:"Gateway"},{name:"Address",value:e}]})}async getGatewayDelegates({address:e,...r}){return this.process.read({tags:[{name:"Action",value:"Paginated-Delegates"},{name:"Address",value:e},...Ha(r)]})}async getGatewayDelegateAllowList({address:e,...r}){return this.process.read({tags:[{name:"Action",value:"Paginated-Allowed-Delegates"},{name:"Address",value:e},...Ha(r)]})}async getGateways(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateways"},...Ha(e)]})}async getCurrentEpoch(){return this.process.read({tags:[{name:"Action",value:"Epoch"}]})}async getPrescribedObservers(e){let r=[{name:"Action",value:"Epoch-Prescribed-Observers"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(r)})}async getPrescribedNames(e){let r=[{name:"Action",value:"Epoch-Prescribed-Names"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(r)})}async getObservations(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&+r<a)return(await Kw({arweave:this.arweave,epochIndex:+r,processId:this.process.processId}))?.observations;let i=[{name:"Action",value:"Epoch-Observations"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(i)})}async getDistributions(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&+r<a)return(await Kw({arweave:this.arweave,epochIndex:+r,processId:this.process.processId}))?.distributions;let i=[{name:"Action",value:"Epoch-Distributions"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(i)})}async getTokenCost({intent:e,type:r,years:a,name:i,quantity:h,fromAddress:l}){let p=[{name:"Action",value:"Token-Cost"},{name:"Intent",value:e},{name:"Name",value:i},{name:"Years",value:a?.toString()},{name:"Quantity",value:h?.toString()},{name:"Purchase-Type",value:r}];return this.process.read({tags:Sn(p),fromAddress:l})}async getCostDetails({intent:e,type:r,years:a,name:i,quantity:h,fromAddress:l,fundFrom:p}){let b=[{name:"Action",value:"Cost-Details"},{name:"Intent",value:e},{name:"Name",value:i},{name:"Years",value:a?.toString()},{name:"Quantity",value:h?.toString()},{name:"Purchase-Type",value:r},{name:"Fund-From",value:p}];return this.process.read({tags:Sn(b),fromAddress:l})}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"},...Ha(e)]})}async getArNSReturnedName({name:e}){let r=[{name:"Action",value:"Returned-Name"},{name:"Name",value:e}];return this.process.read({tags:r})}async getDelegations(e){let r=[{name:"Action",value:"Paginated-Delegations"},{name:"Address",value:e.address},...Ha(e)];return this.process.read({tags:Sn(r)})}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},...Ha(e)]})}async getPrimaryNameRequest(e){let r=[{name:"Action",value:"Primary-Name-Request"},{name:"Initiator",value:e.initiator}];return this.process.read({tags:r})}async getPrimaryNameRequests(e){return this.process.read({tags:[{name:"Action",value:"Primary-Name-Requests"},...Ha(e)]})}async getPrimaryName(e){let r=[{name:"Action",value:"Primary-Name"},{name:"Address",value:e?.address},{name:"Name",value:e?.name}];return this.process.read({tags:Sn(r)})}async getPrimaryNames(e){return this.process.read({tags:[{name:"Action",value:"Primary-Names"},...Ha(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"},...Ha(e)]})}async getAllGatewayVaults(e){return this.process.read({tags:[{name:"Action",value:"All-Gateway-Vaults"},...Ha(e)]})}},mP=class extends Ww{signer;constructor({signer:e,...r}){r===void 0?super({process:new za({processId:Lh})}):super(r),this.signer=pv(e)}async transfer({target:e,qty:r},a){let{tags:i=[]}=a||{};return this.process.send({tags:[...i,{name:"Action",value:"Transfer"},{name:"Recipient",value:e},{name:"Quantity",value:r.valueOf().toString()}],signer:this.signer})}async vaultedTransfer({recipient:e,quantity:r,lockLengthMs:a,revokable:i=!1},h){let{tags:l=[]}=h||{};return this.process.send({tags:[...l,{name:"Action",value:"Vaulted-Transfer"},{name:"Recipient",value:e},{name:"Quantity",value:r.toString()},{name:"Lock-Length",value:a.toString()},{name:"Revokable",value:`${i}`}],signer:this.signer})}async revokeVault({vaultId:e,recipient:r},a){let{tags:i=[]}=a||{};return this.process.send({tags:[...i,{name:"Action",value:"Revoke-Vault"},{name:"Vault-Id",value:e},{name:"Recipient",value:r}],signer:this.signer})}async joinNetwork({operatorStake:e,allowDelegatedStaking:r,allowedDelegates:a,delegateRewardShareRatio:i,fqdn:h,label:l,minDelegatedStake:p,note:b,port:g,properties:y,protocol:M,autoStake:x,observerAddress:E},A){let{tags:I=[]}=A||{},P=[...I,{name:"Action",value:"Join-Network"},{name:"Operator-Stake",value:e.valueOf().toString()},{name:"Allow-Delegated-Staking",value:r?.toString()},{name:"Allowed-Delegates",value:a?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:i?.toString()},{name:"FQDN",value:h},{name:"Label",value:l},{name:"Min-Delegated-Stake",value:p?.valueOf().toString()},{name:"Note",value:b},{name:"Port",value:g?.toString()},{name:"Properties",value:y},{name:"Protocol",value:M},{name:"Auto-Stake",value:x?.toString()},{name:"Observer-Address",value:E}];return this.process.send({signer:this.signer,tags:Sn(P)})}async leaveNetwork(e){let{tags:r=[]}=e||{};return this.process.send({signer:this.signer,tags:[...r,{name:"Action",value:"Leave-Network"}]})}async updateGatewaySettings({allowDelegatedStaking:e,allowedDelegates:r,delegateRewardShareRatio:a,fqdn:i,label:h,minDelegatedStake:l,note:p,port:b,properties:g,protocol:y,autoStake:M,observerAddress:x},E){let{tags:A=[]}=E||{},I=[...A,{name:"Action",value:"Update-Gateway-Settings"},{name:"Label",value:h},{name:"Note",value:p},{name:"FQDN",value:i},{name:"Port",value:b?.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:r?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:a?.toString()},{name:"Min-Delegated-Stake",value:l?.valueOf().toString()},{name:"Auto-Stake",value:M?.toString()}];return this.process.send({signer:this.signer,tags:Sn(I)})}async delegateStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Delegate-Stake"},{name:"Target",value:e.target},{name:"Quantity",value:e.stakeQty.valueOf().toString()}]})}async decreaseDelegateStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{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,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Instant-Withdrawal"},{name:"Vault-Id",value:e.vaultId},{name:"Address",value:e.gatewayAddress}];return this.process.send({signer:this.signer,tags:Sn(i)})}async increaseOperatorStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Increase-Operator-Stake"},{name:"Quantity",value:e.increaseQty.valueOf().toString()}]})}async decreaseOperatorStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Decrease-Operator-Stake"},{name:"Quantity",value:e.decreaseQty.valueOf().toString()},{name:"Instant",value:`${e.instant||!1}`}]})}async saveObservations(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Save-Observations"},{name:"Report-Tx-Id",value:e.reportTxId},{name:"Failed-Gateways",value:e.failedGateways.join(",")}]})}async buyRecord(e,r){let{tags:a=[]}=r||{},i=[...a,{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:Sn(i)})}async upgradeRecord(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Upgrade-Name"},{name:"Name",value:e.name},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Sn(i)})}async extendLease(e,r){let{tags:a=[]}=r||{},i=[...a,{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:Sn(i)})}async increaseUndernameLimit(e,r){let{tags:a=[]}=r||{},i=[...a,{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:Sn(i)})}async cancelWithdrawal(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Cancel-Withdrawal"},{name:"Vault-Id",value:e.vaultId},{name:"Address",value:e.gatewayAddress}];return this.process.send({signer:this.signer,tags:Sn(i)})}async requestPrimaryName(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Request-Primary-Name"},{name:"Name",value:e.name}];return this.process.send({signer:this.signer,tags:Sn(i)})}async redelegateStake(e,r){let{tags:a=[]}=r||{},i=[...a,{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:Sn(i)})}};async function t3t({signer:t,module:e=oQ,ao:r=Sc(),scheduler:a=uQ,state:i,antRegistryId:h=D8,logger:l=Wu.default,authority:p=fQ}){let b=await r.spawn({module:e,scheduler:a,signer:t,data:i?JSON.stringify(i):void 0,tags:[{name:"Authority",value:p},{name:"ANT-Registry-Id",value:h}]});return l.debug("Spawned ANT",{processId:b,module:e,scheduler:a}),b}async function r3t({signer:t,processId:e,luaCodeTxId:r=sQ,ao:a=Sc(),logger:i=Wu.default,arweave:h=O4}){let l=new za({processId:e,ao:a,logger:i}),p=await h.transactions.getData(r,{decode:!0,string:!0}),{id:b}=await l.send({tags:[{name:"Action",value:"Eval"},{name:"App-Name",value:"ArNS-ANT"},{name:"Source-Code-TX-ID",value:r}],data:p,signer:t});return i.debug("Evolved ANT",{processId:e,luaCodeTxId:r,evalMsgId:b}),b}function sUe(t){let e=Qt.object({name:Qt.string(),value:Qt.union([Qt.string(),Qt.number()])}),r=Qt.function().args(Qt.object({data:Qt.union([Qt.string(),Qt.instanceof(Me)]),tags:Qt.array(e).optional(),target:Qt.string().optional(),anchor:Qt.string().optional()})).returns(Qt.promise(Qt.object({id:Qt.string(),raw:Qt.instanceof(ArrayBuffer)})));try{return r.parse(t),!0}catch{return!1}}function pv(t){return sUe(t)?t:"publicKey"in t?async({data:r,tags:a,target:i,anchor:h})=>{if(t.publicKey===void 0&&"setPublicKey"in t&&typeof t.setPublicKey=="function"&&await t.setPublicKey(),t instanceof uc){let b=await t.signer.signDataItem({data:r,tags:a,target:i,anchor:h}),g=new v1(Me.from(b));return{id:await g.id,raw:await g.getRaw()}}let l=Ag(r,t,{tags:a,target:i,anchor:h});return l.sign(t).then(async()=>({id:await l.id,raw:await l.getRaw()}))}:xte(t)}var fUe="-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI";function i3t({owner:t,targetId:e,ttlSeconds:r=3600,keywords:a=[],controllers:i=[],description:h="",ticker:l="aos",name:p="ANT"}){return{ticker:l,name:p,description:h,keywords:a,owner:t,controllers:[t,...i],balances:{[t]:1},records:{"@":{transactionId:e??fUe.toString(),ttlSeconds:r}}}}function rue(t){return Qt.object({startTimestamp:Qt.number(),startHeight:Qt.number(),distributions:Qt.any(),endTimestamp:Qt.number(),prescribedObservers:Qt.any(),prescribedNames:Qt.array(Qt.string()),observations:Qt.any(),distributionTimestamp:Qt.number(),epochIndex:Qt.number()}).parse(t)}function vP(t){let r=t.Error??t.Messages?.[0]?.Tags?.find(a=>a.name==="Error")?.value;if(r!==void 0){let a=r.match(/\[string "aos"]:(\d+):\s*(.+)/);if(a){let[,i,h]=a;return`${tue(h).trim()} (line ${i.trim()})`.trim()}return tue(r)}}function tue(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 iue=t=>L8.test(t);function h3t(t){return t!==void 0&&!isNaN(parseInt(t.toString()))}var Sn=t=>t.filter(e=>e.value!==void 0&&e.value!==""),Ha=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 Sn(e)},Kw=async({arweave:t,epochIndex:e,processId:r=Lh,retries:a=3})=>{let i=uUe({epochIndex:e,processId:r});for(let h=0;h<a;h++)try{let l=await t.api.post("graphql",i);if(l.data?.data?.transactions?.edges?.length===0)return;let p=l.data.data.transactions.edges[0].node.id,b=await t.api.get(p);return rue(b.data)}catch(l){if(h===a-1)throw l;await new Promise(p=>setTimeout(p,Math.pow(2,h)*1e3))}},uUe=({epochIndex:t,processId:e=Lh})=>JSON.stringify({query:`
189
+ }`,i=wt.object({data:wt.object({transactions:wt.object({edges:wt.array(wt.object({node:wt.record(wt.any())}))})})});return h=>jr(h).chain(Li(l=>t(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:a,variables:{transactionIds:[l]}})}).then(async p=>{if(p.ok)return p.json();throw r('Error Encountered when querying gateway for transaction "%s"',l),new Error(`${p.status}: ${await p.text()}`)}).then(i.parse).then(ixe(["data","transactions","edges","0","node"])))).toPromise()}var pSe=nI(M5e(),1),fte=(t="@permaweb/aoconnect")=>{let e=(0,pSe.default)(t);return e.child=r=>fte(`${e.namespace}:${r}`),e.tap=(r,...a)=>hxe((...i)=>e(r,...a,...i)),e},ute=({url:t,path:e})=>e?e.startsWith("/")?ute({url:t,path:e.slice(1)}):(t=new URL(t),t.pathname+=e,t.toString()):t;function vSe(t){return F1(M4([]),U1((e,r)=>F1(oxe([],r.name),wI(r.value),$s(r.name,Fh,e))(e),{}),w4(e=>e.length>1?e:e[0]))(t)}function Cs(t,e){return r=>Pee(vMe([NQ(t,"name"),MI(yI(e),NQ(e,"value"),mI)]),r)}function DQ(t){return jee([[Kg(String),k1(t)],[Kg(Array),VMe(t)],[mI,E9e]])}function Ad(t){let e;return Kg(Ls,t)?(e=new Error(mSe(t)),e.stack+=t.stack):Kg(Error,t)?e=t:HMe("message",t)?e=new Error(t.message):Kg(String,t)?e=new Error(t):e=new Error("An error occurred"),e}function mSe(t){return F1(e=>function r(a,i,h){return U1((l,p)=>F1(jee([[k1(Rt.invalid_arguments),()=>r(p.argumentsError,422,"Invalid Arguments")],[k1(Rt.invalid_return_type),()=>r(p.returnTypeError,500,"Invalid Return")],[k1(Rt.invalid_union),()=>BMe(b=>r(b,400,"Invalid Union"),p.unionErrors)],[mI,()=>[{...p,status:i,contextCode:h}]]]),_I(l))(p.code),[],a.issues)}(e,400,""),e=>U1((r,a)=>{let{message:i,path:h,contextCode:l}=a,p=h[1]||h[0],b=l?`${l} `:"";return r.push(`${b}'${p}': ${i}.`),r},[],e),exe(" | "))(t)}var gSe=wt.object({id:wt.string().min(1,{message:"message is required to be a message id"}),processId:wt.string().min(1,{message:"process is required to be a process id"})});function bSe(){return t=>jr(t).map(gSe.parse).map(()=>t)}var I2=wt.object({name:wt.string(),value:wt.string()}),ySe=wt.function().args(wt.object({Id:wt.string(),Target:wt.string(),Owner:wt.string(),Anchor:wt.string().optional(),Data:wt.any().default("1234"),Tags:wt.array(wt.object({name:wt.string(),value:wt.string()}))})).returns(wt.promise(wt.any())),wSe=wt.function().args(wt.object({id:wt.string().min(1,{message:"message id is required"}),processId:wt.string().min(1,{message:"process id is required"})})).returns(wt.promise(wt.any())),_Se=wt.function().args(wt.object({process:wt.string().min(1,{message:"process id is required"}),from:wt.string().optional(),to:wt.string().optional(),sort:wt.enum(["ASC","DESC"]).default("ASC"),limit:wt.number().optional()})).returns(wt.promise(wt.object({edges:wt.array(wt.object({cursor:wt.string(),node:wt.object({Output:wt.any().optional(),Messages:wt.array(wt.any()).optional(),Spawns:wt.array(wt.any()).optional(),Error:wt.any().optional()})}))}))),hte=wt.function().args(wt.object({processId:wt.string(),data:wt.any(),tags:wt.array(I2),anchor:wt.string().optional(),signer:wt.any()})).returns(wt.promise(wt.object({messageId:wt.string()}).passthrough())),MSe=wt.function().args(wt.object({data:wt.any(),tags:wt.array(I2),signer:wt.any()})).returns(wt.promise(wt.object({processId:wt.string()}).passthrough())),xSe=wt.function().args(wt.object({process:wt.string(),message:wt.string(),baseLayer:wt.boolean().optional(),exclude:wt.array(wt.string()).optional()})).returns(wt.promise(wt.object({assignmentId:wt.string()}).passthrough())),lte=hte,lut=wt.function().args(wt.object({suUrl:wt.string().url(),processId:wt.string()})).returns(wt.promise(wt.object({tags:wt.array(I2)}).passthrough())),cut=wt.function().args(wt.string()).returns(wt.promise(wt.object({url:wt.string()}))),SSe=wt.function().args(wt.string()).returns(wt.promise(wt.boolean())),ESe=wt.function().args(wt.string()).returns(wt.promise(wt.object({tags:wt.array(I2)}).passthrough())),x4=wt.function().args(wt.object({data:wt.any(),tags:wt.array(I2),target:wt.string().optional(),anchor:wt.string().optional()})).returns(wt.promise(wt.object({id:wt.string(),raw:wt.any()})));function ASe({loadResult:t}){return t=Li(wSe.implement(t)),e=>jr({id:e.id,processId:e.processId}).chain(t)}function RSe(t){let e=bSe(t),r=ASe(t);return({message:a,process:i})=>jr({id:a,processId:i}).chain(e).chain(r).map(t.logger.tap('readResult result for message "%s": %O',a)).map(h=>h).bimap(Ad,Ed).toPromise()}var TSe=wt.array(wt.object({name:wt.string(),value:wt.string()}));function ISe(){return t=>jr(t.tags).map(M4([])).map(Cs("Data-Protocol","ao")).map(Cs("Variant")).map(Cs("Type")).map(Cs("SDK")).map(_I(Fh,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Message"},{name:"SDK",value:"aoconnect"}])).map(TSe.parse).map($s("tags",Fh,t))}function kSe({logger:t}){return e=>jr(e).chain(MI(yI(e.data),()=>_d(e),()=>_d(Math.random().toString().slice(-4)).map($s("data",Fh,e)).map(r=>F1(Sd("tags"),Cs("Content-Type"),wI({name:"Content-Type",value:"text/plain"}),$s("tags",Fh,r))(r)).map(t.tap('added pseudo-random string as message "data"'))))}function BSe(t){let e=ISe(t),r=kSe(t),a=hte.implement(t.deployMessage);return i=>jr(i).chain(e).chain(r).chain(Li(({id:h,data:l,tags:p,anchor:b,signer:g})=>a({processId:h,data:l,tags:p,anchor:b,signer:x4.implement(g)}))).map(h=>$s("messageId",h.messageId,i))}function PSe(t){let e=BSe(t);return({process:r,data:a,tags:i,anchor:h,signer:l})=>jr({id:r,data:a,tags:i,anchor:h,signer:l}).chain(e).map(p=>p.messageId).bimap(Ad,Ed).toPromise()}var Lg=(t,e,r)=>a=>e(a[t])?_d(a):xc(`Tag '${t}': ${r}`);function OSe({loadTransactionMeta:t,logger:e}){return t=Li(ESe.implement(t)),r=>jr(r).chain(t).map(Sd("tags")).map(vSe).chain(Lg("Data-Protocol",DQ("ao"),"value 'ao' was not found on module")).chain(Lg("Type",DQ("Module"),"value 'Module' was not found on module")).chain(Lg("Module-Format",IT,"was not found on module")).chain(Lg("Input-Encoding",IT,"was not found on module")).chain(Lg("Output-Encoding",IT,"was not found on module")).bimap(e.tap("Verifying module source failed: %s"),e.tap("Verified module source"))}function NSe({logger:t,validateScheduler:e}){return e=Li(SSe.implement(e)),r=>jr(r).chain(a=>e(a).chain(i=>i?_d(a):xc(`Valid Scheduler-Location owned by ${a} not found`))).bimap(t.tap("Verifying scheduler failed: %s"),t.tap("Verified scheduler"))}function CSe({logger:t}){return e=>jr(e).map(t.tap("Checking for signer")).chain(r=>r?_d(r):xc("signer not found"))}function LSe(t){let e=t.logger.child("verifyInput");t={...t,logger:e};let r=OSe(t),a=NSe(t),i=CSe(t);return h=>jr(h).chain(l=>r(l.module).map(()=>l)).chain(l=>a(l.scheduler)).map(()=>h).chain(l=>i(l.signer).map(()=>l)).bimap(e.tap("Error when verify input: %s"),e.tap("Successfully verified inputs"))}var DSe=wt.array(wt.object({name:wt.string(),value:wt.string()}));function $Se(){return t=>jr(t).map(Sd("tags")).map(M4([])).map(Cs("Data-Protocol","ao")).map(Cs("Variant")).map(Cs("Type")).map(Cs("Module")).map(Cs("Scheduler")).map(Cs("SDK")).map(_I(Fh,[{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(DSe.parse).map($s("tags",Fh,t))}function qSe({logger:t}){return e=>jr(e).chain(MI(yI(e.data),()=>_d(e),()=>_d(Math.random().toString().slice(-4)).map($s("data",Fh,e)).map(r=>F1(Sd("tags"),Cs("Content-Type"),wI({name:"Content-Type",value:"text/plain"}),$s("tags",Fh,r))(r)).map(t.tap('added pseudo-random string as process "data"'))))}function USe(t){let e=t.logger.child("uploadProcess");t={...t,logger:e};let r=$Se(t),a=qSe(t),i=MSe.implement(t.deployProcess);return h=>jr(h).chain(r).chain(a).chain(Li(({data:l,tags:p,signer:b})=>i({data:l,tags:p,signer:x4.implement(b)}))).map(l=>$s("processId",l.processId,h))}function FSe(t){let e=LSe(t),r=USe(t);return({module:a,scheduler:i,signer:h,tags:l,data:p})=>jr({module:a,scheduler:i,signer:h,tags:l,data:p}).chain(e).chain(r).map(b=>b.processId).bimap(Ad,Ed).toPromise()}function jSe(t){let e=lte.implement(t.deployMonitor);return r=>jr(r).chain(Li(({id:a,signer:i})=>e({processId:a,signer:x4.implement(i),data:Math.random().toString().slice(-4),tags:[]}))).map(a=>$s("monitorId",a.messageId,r))}function zSe(t){let e=jSe(t);return({process:r,signer:a})=>jr({id:r,signer:a}).chain(e).map(i=>i.monitorId).bimap(Ad,Ed).toPromise()}function ZSe(t){let e=lte.implement(t.deployUnmonitor);return r=>jr(r).chain(Li(({id:a,signer:i})=>e({processId:a,signer:x4.implement(i),data:Math.random().toString().slice(-4),tags:[]}))).map(a=>$s("monitorId",a.messageId,r))}function HSe(t){let e=ZSe(t);return({process:r,signer:a})=>jr({id:r,signer:a}).chain(e).map(i=>i.monitorId).bimap(Ad,Ed).toPromise()}var KSe=wt.object({process:wt.string().min(1,{message:"process identifier is required"}),from:wt.string().optional(),to:wt.string().optional(),sort:wt.enum(["ASC","DESC"]).default("ASC"),limit:wt.number().optional()});function WSe(){return t=>jr(t).map(KSe.parse).map(()=>t)}function VSe({queryResults:t}){return t=Li(_Se.implement(t)),e=>jr({process:e.process,from:e.from,to:e.to,sort:e.sort,limit:e.limit}).chain(t)}function GSe(t){let e=WSe(t),r=VSe(t);return({process:a,from:i,to:h,sort:l,limit:p})=>jr({process:a,from:i,to:h,sort:l,limit:p}).chain(e).chain(r).map(t.logger.tap('readResults result for message "%s": %O',a)).map(b=>b).bimap(Ad,Ed).toPromise()}var YSe=wt.object({Id:wt.string(),Target:wt.string(),Owner:wt.string(),Anchor:wt.string().optional(),Data:wt.any().default("1234"),Tags:wt.array(wt.object({name:wt.string(),value:wt.string()}))});function JSe(){return t=>jr(t).map(YSe.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 XSe({dryrunFetch:t}){return Li(ySe.implement(t))}function QSe(t){let e=JSe(t),r=XSe(t);return a=>jr(a).map(eEe).chain(e).chain(r).toPromise()}function eEe({process:t,data:e,tags:r,anchor:a,...i}){return{Id:"1234",Owner:"1234",...i,Target:t,Data:e||"1234",Tags:r||[],Anchor:a||"0"}}function tEe(t){let e=xSe.implement(t.deployAssign);return r=>jr(r).chain(Li(({process:a,message:i,baseLayer:h,exclude:l})=>e({process:a,message:i,baseLayer:h,exclude:l}))).map(a=>$s("assignmentId",a.assignmentId,r))}function rEe(t){let e=tEe(t);return({process:r,message:a,baseLayer:i,exclude:h})=>jr({process:r,message:a,baseLayer:i,exclude:h}).chain(e).map(l=>l.assignmentId).bimap(Ad,Ed).toPromise()}var iEe="https://arweave.net",nEe="https://mu.ao-testnet.xyz",aEe="https://cu.ao-testnet.xyz";function Sc({GRAPHQL_URL:t,GATEWAY_URL:e=iEe,MU_URL:r=nEe,CU_URL:a=aEe}={}){let i=fte();t||(t=ute({url:e,path:"/graphql"}));let{validate:h}=Tee({cacheSize:100,GRAPHQL_URL:t}),l=x9e({MAX_SIZE:25}),p=i.child("result"),b=RSe({loadResult:w9e({fetch,CU_URL:a,logger:p}),logger:p}),g=i.child("message"),y=PSe({loadProcessMeta:AT({fetch,cache:l,logger:g}),deployMessage:p9e({fetch,MU_URL:r,logger:g}),logger:g}),M=i.child("spawn"),x=FSe({loadTransactionMeta:dSe({fetch,GRAPHQL_URL:t,logger:M}),validateScheduler:h,deployProcess:v9e({fetch,MU_URL:r,logger:M}),logger:M}),E=i.child("monitor"),A=zSe({loadProcessMeta:AT({fetch,cache:l,logger:E}),deployMonitor:m9e({fetch,MU_URL:r,logger:E}),logger:E}),I=i.child("unmonitor"),P=HSe({loadProcessMeta:AT({fetch,cache:l,logger:I}),deployUnmonitor:g9e({fetch,MU_URL:r,logger:I}),logger:E}),N=i.child("results"),L=GSe({queryResults:_9e({fetch,CU_URL:a,logger:N}),logger:N}),C=i.child("dryrun"),Y=QSe({dryrunFetch:y9e({fetch,CU_URL:a,logger:C}),logger:C}),G=i.child("assign"),ee=rEe({deployAssign:b9e({fetch,MU_URL:r,logger:G}),logger:g});return{result:b,results:L,message:y,spawn:x,monitor:A,unmonitor:P,dryrun:Y,assign:ee}}var cte={};UQ(cte,{createDataItemSigner:()=>kEe});var dte=nI(E5e(),1),pte={};UQ(pte,{AVSCTap:()=>k2,ArweaveSigner:()=>RI,DataItem:()=>E2,MAX_TAG_BYTES:()=>S4,MIN_BINARY_SIZE:()=>kI,SIG_CONFIG:()=>K1,SignatureConfig:()=>Ns,Signer:()=>bte,createData:()=>Mte,default:()=>REe,deserializeTags:()=>p4,indexToType:()=>TI,serializeTags:()=>II,tagsExceedLimit:()=>_te,warparbundles:()=>TEe});var oEe=Object.create,EI=Object.defineProperty,sEe=Object.getOwnPropertyDescriptor,fEe=Object.getOwnPropertyNames,uEe=Object.getPrototypeOf,hEe=Object.prototype.hasOwnProperty,zh=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),lEe=(t,e)=>{for(var r in e)EI(t,r,{get:e[r],enumerable:!0})},cEe=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of fEe(e))!hEe.call(t,i)&&i!==r&&EI(t,i,{get:()=>e[i],enumerable:!(a=sEe(e,i))||a.enumerable});return t},Rd=(t,e,r)=>(r=t!=null?oEe(uEe(t)):{},cEe(e||!t||!t.__esModule?EI(r,"default",{value:t,enumerable:!0}):r,t)),dEe=zh(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});function e(r){var a=4,i=r.length,h=i%a;if(!h)return r;var l=i,p=a-h,b=i+p,g=Me.alloc(b);for(g.write(r);p--;)g.write("=",l++);return g.toString()}t.default=e}),pEe=zh(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var e=dEe();function r(b,g){return g===void 0&&(g="utf8"),Me.isBuffer(b)?h(b.toString("base64")):h(Me.from(b,g).toString("base64"))}function a(b,g){return g===void 0&&(g="utf8"),Me.from(i(b),"base64").toString(g)}function i(b){return b=b.toString(),e.default(b).replace(/\-/g,"+").replace(/_/g,"/")}function h(b){return b.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function l(b){return Me.from(i(b),"base64")}var p=r;p.encode=r,p.decode=a,p.toBase64=i,p.fromBase64=h,p.toBuffer=l,t.default=p}),AI=zh((t,e)=>{e.exports=pEe().default,e.exports.default=e.exports}),vte=zh(t=>{"use strict";t.byteLength=b,t.toByteArray=y,t.fromByteArray=E;var e=[],r=[],a=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(h=0,l=i.length;h<l;++h)e[h]=i[h],r[i.charCodeAt(h)]=h;var h,l;r[45]=62,r[95]=63;function p(A){var I=A.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var P=A.indexOf("=");P===-1&&(P=I);var N=P===I?0:4-P%4;return[P,N]}function b(A){var I=p(A),P=I[0],N=I[1];return(P+N)*3/4-N}function g(A,I,P){return(I+P)*3/4-P}function y(A){var I,P=p(A),N=P[0],L=P[1],C=new a(g(A,N,L)),Y=0,G=L>0?N-4:N,ee;for(ee=0;ee<G;ee+=4)I=r[A.charCodeAt(ee)]<<18|r[A.charCodeAt(ee+1)]<<12|r[A.charCodeAt(ee+2)]<<6|r[A.charCodeAt(ee+3)],C[Y++]=I>>16&255,C[Y++]=I>>8&255,C[Y++]=I&255;return L===2&&(I=r[A.charCodeAt(ee)]<<2|r[A.charCodeAt(ee+1)]>>4,C[Y++]=I&255),L===1&&(I=r[A.charCodeAt(ee)]<<10|r[A.charCodeAt(ee+1)]<<4|r[A.charCodeAt(ee+2)]>>2,C[Y++]=I>>8&255,C[Y++]=I&255),C}function M(A){return e[A>>18&63]+e[A>>12&63]+e[A>>6&63]+e[A&63]}function x(A,I,P){for(var N,L=[],C=I;C<P;C+=3)N=(A[C]<<16&16711680)+(A[C+1]<<8&65280)+(A[C+2]&255),L.push(M(N));return L.join("")}function E(A){for(var I,P=A.length,N=P%3,L=[],C=16383,Y=0,G=P-N;Y<G;Y+=C)L.push(x(A,Y,Y+C>G?G:Y+C));return N===1?(I=A[P-1],L.push(e[I>>2]+e[I<<4&63]+"==")):N===2&&(I=(A[P-2]<<8)+A[P-1],L.push(e[I>>10]+e[I>>4&63]+e[I<<2&63]+"=")),L.join("")}}),mte=zh(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=vte();function r(x){let E=0;for(let P=0;P<x.length;P++)E+=x[P].byteLength;let A=new Uint8Array(E),I=0;A.set(new Uint8Array(x[0]),I),I+=x[0].byteLength;for(let P=1;P<x.length;P++)A.set(new Uint8Array(x[P]),I),I+=x[P].byteLength;return A}t.concatBuffers=r;function a(x){let E=p(x);return i(E)}t.b64UrlToString=a;function i(x){return new TextDecoder("utf-8",{fatal:!0}).decode(x)}t.bufferToString=i;function h(x){return new TextEncoder().encode(x)}t.stringToBuffer=h;function l(x){return g(h(x))}t.stringToB64Url=l;function p(x){return new Uint8Array(e.toByteArray(M(x)))}t.b64UrlToBuffer=p;function b(x){return e.fromByteArray(new Uint8Array(x))}t.bufferTob64=b;function g(x){return y(b(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 E;return x.length%4==0?E=0:E=4-x.length%4,x.concat("=".repeat(E))}t.b64UrlDecode=M}),vEe=zh(t=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var e=mte(),r=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 a=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),i=await this.driver.exportKey("jwk",a.privateKey);return{kty:i.kty,e:i.e,n:i.n,d:i.d,p:i.p,q:i.q,dp:i.dp,dq:i.dq,qi:i.qi}}async sign(a,i,{saltLength:h}={}){let l=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(a),i);return new Uint8Array(l)}async hash(a,i="SHA-256"){let h=await this.driver.digest(i,a);return new Uint8Array(h)}async verify(a,i,h){let l={kty:"RSA",e:"AQAB",n:a},p=await this.jwkToPublicCryptoKey(l),b=await this.driver.digest("SHA-256",i),g=await this.driver.verify({name:"RSA-PSS",saltLength:0},p,h,i),y=await this.driver.verify({name:"RSA-PSS",saltLength:32},p,h,i),M=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((p.algorithm.modulusLength-1)/8)-b.byteLength-2},p,h,i);return g||y||M}async jwkToCryptoKey(a){return this.driver.importKey("jwk",a,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(a){return this.driver.importKey("jwk",a,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let a=crypto?.subtle;return a===void 0?!1:["generateKey","importKey","exportKey","digest","sign"].every(i=>typeof a[i]=="function")}async encrypt(a,i,h){let l=await this.driver.importKey("raw",typeof i=="string"?e.stringToBuffer(i):i,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:h?e.stringToBuffer(h):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},l,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),b=new Uint8Array(16);crypto.getRandomValues(b);let g=await this.driver.encrypt({name:"AES-CBC",iv:b},p,a);return e.concatBuffers([b,g])}async decrypt(a,i,h){let l=await this.driver.importKey("raw",typeof i=="string"?e.stringToBuffer(i):i,{name:"PBKDF2",length:32},!1,["deriveKey"]),p=await this.driver.deriveKey({name:"PBKDF2",salt:h?e.stringToBuffer(h):e.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},l,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),b=a.slice(0,16),g=await this.driver.decrypt({name:"AES-CBC",iv:b},p,a.slice(16));return e.concatBuffers([g])}};t.default=r}),mEe=zh(t=>{t.read=function(e,r,a,i,h){var l,p,b=h*8-i-1,g=(1<<b)-1,y=g>>1,M=-7,x=a?h-1:0,E=a?-1:1,A=e[r+x];for(x+=E,l=A&(1<<-M)-1,A>>=-M,M+=b;M>0;l=l*256+e[r+x],x+=E,M-=8);for(p=l&(1<<-M)-1,l>>=-M,M+=i;M>0;p=p*256+e[r+x],x+=E,M-=8);if(l===0)l=1-y;else{if(l===g)return p?NaN:(A?-1:1)*(1/0);p=p+Math.pow(2,i),l=l-y}return(A?-1:1)*p*Math.pow(2,l-i)},t.write=function(e,r,a,i,h,l){var p,b,g,y=l*8-h-1,M=(1<<y)-1,x=M>>1,E=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=i?0:l-1,I=i?1:-1,P=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(b=isNaN(r)?1:0,p=M):(p=Math.floor(Math.log(r)/Math.LN2),r*(g=Math.pow(2,-p))<1&&(p--,g*=2),p+x>=1?r+=E/g:r+=E*Math.pow(2,1-x),r*g>=2&&(p++,g/=2),p+x>=M?(b=0,p=M):p+x>=1?(b=(r*g-1)*Math.pow(2,h),p=p+x):(b=r*Math.pow(2,x-1)*Math.pow(2,h),p=0));h>=8;e[a+A]=b&255,A+=I,b/=256,h-=8);for(p=p<<h|b,y+=h;y>0;e[a+A]=p&255,A+=I,p/=256,y-=8);e[a+A-I]|=P*128}}),tI=zh(t=>{"use strict";var e=vte(),r=mEe(),a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=p,t.SlowBuffer=L,t.INSPECT_MAX_BYTES=50;var i=2147483647;t.kMaxLength=i,p.TYPED_ARRAY_SUPPORT=h(),!p.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 h(){try{let T=new Uint8Array(1),k={foo:function(){return 42}};return Object.setPrototypeOf(k,Uint8Array.prototype),Object.setPrototypeOf(T,k),T.foo()===42}catch{return!1}}Object.defineProperty(p.prototype,"parent",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.buffer}}),Object.defineProperty(p.prototype,"offset",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.byteOffset}});function l(T){if(T>i)throw new RangeError('The value "'+T+'" is invalid for option "size"');let k=new Uint8Array(T);return Object.setPrototypeOf(k,p.prototype),k}function p(T,k,O){if(typeof T=="number"){if(typeof k=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return M(T)}return b(T,k,O)}p.poolSize=8192;function b(T,k,O){if(typeof T=="string")return x(T,k);if(ArrayBuffer.isView(T))return A(T);if(T==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T);if(ut(T,ArrayBuffer)||T&&ut(T.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ut(T,SharedArrayBuffer)||T&&ut(T.buffer,SharedArrayBuffer)))return I(T,k,O);if(typeof T=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let q=T.valueOf&&T.valueOf();if(q!=null&&q!==T)return p.from(q,k,O);let H=P(T);if(H)return H;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof T[Symbol.toPrimitive]=="function")return p.from(T[Symbol.toPrimitive]("string"),k,O);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T)}p.from=function(T,k,O){return b(T,k,O)},Object.setPrototypeOf(p.prototype,Uint8Array.prototype),Object.setPrototypeOf(p,Uint8Array);function g(T){if(typeof T!="number")throw new TypeError('"size" argument must be of type number');if(T<0)throw new RangeError('The value "'+T+'" is invalid for option "size"')}function y(T,k,O){return g(T),T<=0?l(T):k!==void 0?typeof O=="string"?l(T).fill(k,O):l(T).fill(k):l(T)}p.alloc=function(T,k,O){return y(T,k,O)};function M(T){return g(T),l(T<0?0:N(T)|0)}p.allocUnsafe=function(T){return M(T)},p.allocUnsafeSlow=function(T){return M(T)};function x(T,k){if((typeof k!="string"||k==="")&&(k="utf8"),!p.isEncoding(k))throw new TypeError("Unknown encoding: "+k);let O=C(T,k)|0,q=l(O),H=q.write(T,k);return H!==O&&(q=q.slice(0,H)),q}function E(T){let k=T.length<0?0:N(T.length)|0,O=l(k);for(let q=0;q<k;q+=1)O[q]=T[q]&255;return O}function A(T){if(ut(T,Uint8Array)){let k=new Uint8Array(T);return I(k.buffer,k.byteOffset,k.byteLength)}return E(T)}function I(T,k,O){if(k<0||T.byteLength<k)throw new RangeError('"offset" is outside of buffer bounds');if(T.byteLength<k+(O||0))throw new RangeError('"length" is outside of buffer bounds');let q;return k===void 0&&O===void 0?q=new Uint8Array(T):O===void 0?q=new Uint8Array(T,k):q=new Uint8Array(T,k,O),Object.setPrototypeOf(q,p.prototype),q}function P(T){if(p.isBuffer(T)){let k=N(T.length)|0,O=l(k);return O.length===0||T.copy(O,0,0,k),O}if(T.length!==void 0)return typeof T.length!="number"||Ze(T.length)?l(0):E(T);if(T.type==="Buffer"&&Array.isArray(T.data))return E(T.data)}function N(T){if(T>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return T|0}function L(T){return+T!=T&&(T=0),p.alloc(+T)}p.isBuffer=function(T){return T!=null&&T._isBuffer===!0&&T!==p.prototype},p.compare=function(T,k){if(ut(T,Uint8Array)&&(T=p.from(T,T.offset,T.byteLength)),ut(k,Uint8Array)&&(k=p.from(k,k.offset,k.byteLength)),!p.isBuffer(T)||!p.isBuffer(k))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(T===k)return 0;let O=T.length,q=k.length;for(let H=0,W=Math.min(O,q);H<W;++H)if(T[H]!==k[H]){O=T[H],q=k[H];break}return O<q?-1:q<O?1:0},p.isEncoding=function(T){switch(String(T).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}},p.concat=function(T,k){if(!Array.isArray(T))throw new TypeError('"list" argument must be an Array of Buffers');if(T.length===0)return p.alloc(0);let O;if(k===void 0)for(k=0,O=0;O<T.length;++O)k+=T[O].length;let q=p.allocUnsafe(k),H=0;for(O=0;O<T.length;++O){let W=T[O];if(ut(W,Uint8Array))H+W.length>q.length?(p.isBuffer(W)||(W=p.from(W)),W.copy(q,H)):Uint8Array.prototype.set.call(q,W,H);else if(p.isBuffer(W))W.copy(q,H);else throw new TypeError('"list" argument must be an Array of Buffers');H+=W.length}return q};function C(T,k){if(p.isBuffer(T))return T.length;if(ArrayBuffer.isView(T)||ut(T,ArrayBuffer))return T.byteLength;if(typeof T!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof T);let O=T.length,q=arguments.length>2&&arguments[2]===!0;if(!q&&O===0)return 0;let H=!1;for(;;)switch(k){case"ascii":case"latin1":case"binary":return O;case"utf8":case"utf-8":return oe(T).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O*2;case"hex":return O>>>1;case"base64":return ge(T).length;default:if(H)return q?-1:oe(T).length;k=(""+k).toLowerCase(),H=!0}}p.byteLength=C;function Y(T,k,O){let q=!1;if((k===void 0||k<0)&&(k=0),k>this.length||((O===void 0||O>this.length)&&(O=this.length),O<=0)||(O>>>=0,k>>>=0,O<=k))return"";for(T||(T="utf8");;)switch(T){case"hex":return o(this,k,O);case"utf8":case"utf-8":return u(this,k,O);case"ascii":return w(this,k,O);case"latin1":case"binary":return d(this,k,O);case"base64":return f(this,k,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,k,O);default:if(q)throw new TypeError("Unknown encoding: "+T);T=(T+"").toLowerCase(),q=!0}}p.prototype._isBuffer=!0;function G(T,k,O){let q=T[k];T[k]=T[O],T[O]=q}p.prototype.swap16=function(){let T=this.length;if(T%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let k=0;k<T;k+=2)G(this,k,k+1);return this},p.prototype.swap32=function(){let T=this.length;if(T%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let k=0;k<T;k+=4)G(this,k,k+3),G(this,k+1,k+2);return this},p.prototype.swap64=function(){let T=this.length;if(T%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let k=0;k<T;k+=8)G(this,k,k+7),G(this,k+1,k+6),G(this,k+2,k+5),G(this,k+3,k+4);return this},p.prototype.toString=function(){let T=this.length;return T===0?"":arguments.length===0?u(this,0,T):Y.apply(this,arguments)},p.prototype.toLocaleString=p.prototype.toString,p.prototype.equals=function(T){if(!p.isBuffer(T))throw new TypeError("Argument must be a Buffer");return this===T?!0:p.compare(this,T)===0},p.prototype.inspect=function(){let T="",k=t.INSPECT_MAX_BYTES;return T=this.toString("hex",0,k).replace(/(.{2})/g,"$1 ").trim(),this.length>k&&(T+=" ... "),"<Buffer "+T+">"},a&&(p.prototype[a]=p.prototype.inspect),p.prototype.compare=function(T,k,O,q,H){if(ut(T,Uint8Array)&&(T=p.from(T,T.offset,T.byteLength)),!p.isBuffer(T))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof T);if(k===void 0&&(k=0),O===void 0&&(O=T?T.length:0),q===void 0&&(q=0),H===void 0&&(H=this.length),k<0||O>T.length||q<0||H>this.length)throw new RangeError("out of range index");if(q>=H&&k>=O)return 0;if(q>=H)return-1;if(k>=O)return 1;if(k>>>=0,O>>>=0,q>>>=0,H>>>=0,this===T)return 0;let W=H-q,fe=O-k,st=Math.min(W,fe),ue=this.slice(q,H),me=T.slice(k,O);for(let pe=0;pe<st;++pe)if(ue[pe]!==me[pe]){W=ue[pe],fe=me[pe];break}return W<fe?-1:fe<W?1:0};function ee(T,k,O,q,H){if(T.length===0)return-1;if(typeof O=="string"?(q=O,O=0):O>2147483647?O=2147483647:O<-2147483648&&(O=-2147483648),O=+O,Ze(O)&&(O=H?0:T.length-1),O<0&&(O=T.length+O),O>=T.length){if(H)return-1;O=T.length-1}else if(O<0)if(H)O=0;else return-1;if(typeof k=="string"&&(k=p.from(k,q)),p.isBuffer(k))return k.length===0?-1:D(T,k,O,q,H);if(typeof k=="number")return k=k&255,typeof Uint8Array.prototype.indexOf=="function"?H?Uint8Array.prototype.indexOf.call(T,k,O):Uint8Array.prototype.lastIndexOf.call(T,k,O):D(T,[k],O,q,H);throw new TypeError("val must be string, number or Buffer")}function D(T,k,O,q,H){let W=1,fe=T.length,st=k.length;if(q!==void 0&&(q=String(q).toLowerCase(),q==="ucs2"||q==="ucs-2"||q==="utf16le"||q==="utf-16le")){if(T.length<2||k.length<2)return-1;W=2,fe/=2,st/=2,O/=2}function ue(pe,be){return W===1?pe[be]:pe.readUInt16BE(be*W)}let me;if(H){let pe=-1;for(me=O;me<fe;me++)if(ue(T,me)===ue(k,pe===-1?0:me-pe)){if(pe===-1&&(pe=me),me-pe+1===st)return pe*W}else pe!==-1&&(me-=me-pe),pe=-1}else for(O+st>fe&&(O=fe-st),me=O;me>=0;me--){let pe=!0;for(let be=0;be<st;be++)if(ue(T,me+be)!==ue(k,be)){pe=!1;break}if(pe)return me}return-1}p.prototype.includes=function(T,k,O){return this.indexOf(T,k,O)!==-1},p.prototype.indexOf=function(T,k,O){return ee(this,T,k,O,!0)},p.prototype.lastIndexOf=function(T,k,O){return ee(this,T,k,O,!1)};function U(T,k,O,q){O=Number(O)||0;let H=T.length-O;q?(q=Number(q),q>H&&(q=H)):q=H;let W=k.length;q>W/2&&(q=W/2);let fe;for(fe=0;fe<q;++fe){let st=parseInt(k.substr(fe*2,2),16);if(Ze(st))return fe;T[O+fe]=st}return fe}function V(T,k,O,q){return Se(oe(k,T.length-O),T,O,q)}function _(T,k,O,q){return Se(ce(k),T,O,q)}function n(T,k,O,q){return Se(ge(k),T,O,q)}function s(T,k,O,q){return Se(ot(k,T.length-O),T,O,q)}p.prototype.write=function(T,k,O,q){if(k===void 0)q="utf8",O=this.length,k=0;else if(O===void 0&&typeof k=="string")q=k,O=this.length,k=0;else if(isFinite(k))k=k>>>0,isFinite(O)?(O=O>>>0,q===void 0&&(q="utf8")):(q=O,O=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let H=this.length-k;if((O===void 0||O>H)&&(O=H),T.length>0&&(O<0||k<0)||k>this.length)throw new RangeError("Attempt to write outside buffer bounds");q||(q="utf8");let W=!1;for(;;)switch(q){case"hex":return U(this,T,k,O);case"utf8":case"utf-8":return V(this,T,k,O);case"ascii":case"latin1":case"binary":return _(this,T,k,O);case"base64":return n(this,T,k,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s(this,T,k,O);default:if(W)throw new TypeError("Unknown encoding: "+q);q=(""+q).toLowerCase(),W=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function f(T,k,O){return k===0&&O===T.length?e.fromByteArray(T):e.fromByteArray(T.slice(k,O))}function u(T,k,O){O=Math.min(T.length,O);let q=[],H=k;for(;H<O;){let W=T[H],fe=null,st=W>239?4:W>223?3:W>191?2:1;if(H+st<=O){let ue,me,pe,be;switch(st){case 1:W<128&&(fe=W);break;case 2:ue=T[H+1],(ue&192)===128&&(be=(W&31)<<6|ue&63,be>127&&(fe=be));break;case 3:ue=T[H+1],me=T[H+2],(ue&192)===128&&(me&192)===128&&(be=(W&15)<<12|(ue&63)<<6|me&63,be>2047&&(be<55296||be>57343)&&(fe=be));break;case 4:ue=T[H+1],me=T[H+2],pe=T[H+3],(ue&192)===128&&(me&192)===128&&(pe&192)===128&&(be=(W&15)<<18|(ue&63)<<12|(me&63)<<6|pe&63,be>65535&&be<1114112&&(fe=be))}}fe===null?(fe=65533,st=1):fe>65535&&(fe-=65536,q.push(fe>>>10&1023|55296),fe=56320|fe&1023),q.push(fe),H+=st}return m(q)}var c=4096;function m(T){let k=T.length;if(k<=c)return String.fromCharCode.apply(String,T);let O="",q=0;for(;q<k;)O+=String.fromCharCode.apply(String,T.slice(q,q+=c));return O}function w(T,k,O){let q="";O=Math.min(T.length,O);for(let H=k;H<O;++H)q+=String.fromCharCode(T[H]&127);return q}function d(T,k,O){let q="";O=Math.min(T.length,O);for(let H=k;H<O;++H)q+=String.fromCharCode(T[H]);return q}function o(T,k,O){let q=T.length;(!k||k<0)&&(k=0),(!O||O<0||O>q)&&(O=q);let H="";for(let W=k;W<O;++W)H+=Ge[T[W]];return H}function v(T,k,O){let q=T.slice(k,O),H="";for(let W=0;W<q.length-1;W+=2)H+=String.fromCharCode(q[W]+q[W+1]*256);return H}p.prototype.slice=function(T,k){let O=this.length;T=~~T,k=k===void 0?O:~~k,T<0?(T+=O,T<0&&(T=0)):T>O&&(T=O),k<0?(k+=O,k<0&&(k=0)):k>O&&(k=O),k<T&&(k=T);let q=this.subarray(T,k);return Object.setPrototypeOf(q,p.prototype),q};function R(T,k,O){if(T%1!==0||T<0)throw new RangeError("offset is not uint");if(T+k>O)throw new RangeError("Trying to access beyond buffer length")}p.prototype.readUintLE=p.prototype.readUIntLE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=this[T],H=1,W=0;for(;++W<k&&(H*=256);)q+=this[T+W]*H;return q},p.prototype.readUintBE=p.prototype.readUIntBE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=this[T+--k],H=1;for(;k>0&&(H*=256);)q+=this[T+--k]*H;return q},p.prototype.readUint8=p.prototype.readUInt8=function(T,k){return T=T>>>0,k||R(T,1,this.length),this[T]},p.prototype.readUint16LE=p.prototype.readUInt16LE=function(T,k){return T=T>>>0,k||R(T,2,this.length),this[T]|this[T+1]<<8},p.prototype.readUint16BE=p.prototype.readUInt16BE=function(T,k){return T=T>>>0,k||R(T,2,this.length),this[T]<<8|this[T+1]},p.prototype.readUint32LE=p.prototype.readUInt32LE=function(T,k){return T=T>>>0,k||R(T,4,this.length),(this[T]|this[T+1]<<8|this[T+2]<<16)+this[T+3]*16777216},p.prototype.readUint32BE=p.prototype.readUInt32BE=function(T,k){return T=T>>>0,k||R(T,4,this.length),this[T]*16777216+(this[T+1]<<16|this[T+2]<<8|this[T+3])},p.prototype.readBigUInt64LE=lt(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=k+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24,H=this[++T]+this[++T]*2**8+this[++T]*2**16+O*2**24;return BigInt(q)+(BigInt(H)<<BigInt(32))}),p.prototype.readBigUInt64BE=lt(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=k*2**24+this[++T]*2**16+this[++T]*2**8+this[++T],H=this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+O;return(BigInt(q)<<BigInt(32))+BigInt(H)}),p.prototype.readIntLE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=this[T],H=1,W=0;for(;++W<k&&(H*=256);)q+=this[T+W]*H;return H*=128,q>=H&&(q-=Math.pow(2,8*k)),q},p.prototype.readIntBE=function(T,k,O){T=T>>>0,k=k>>>0,O||R(T,k,this.length);let q=k,H=1,W=this[T+--q];for(;q>0&&(H*=256);)W+=this[T+--q]*H;return H*=128,W>=H&&(W-=Math.pow(2,8*k)),W},p.prototype.readInt8=function(T,k){return T=T>>>0,k||R(T,1,this.length),this[T]&128?(255-this[T]+1)*-1:this[T]},p.prototype.readInt16LE=function(T,k){T=T>>>0,k||R(T,2,this.length);let O=this[T]|this[T+1]<<8;return O&32768?O|4294901760:O},p.prototype.readInt16BE=function(T,k){T=T>>>0,k||R(T,2,this.length);let O=this[T+1]|this[T]<<8;return O&32768?O|4294901760:O},p.prototype.readInt32LE=function(T,k){return T=T>>>0,k||R(T,4,this.length),this[T]|this[T+1]<<8|this[T+2]<<16|this[T+3]<<24},p.prototype.readInt32BE=function(T,k){return T=T>>>0,k||R(T,4,this.length),this[T]<<24|this[T+1]<<16|this[T+2]<<8|this[T+3]},p.prototype.readBigInt64LE=lt(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=this[T+4]+this[T+5]*2**8+this[T+6]*2**16+(O<<24);return(BigInt(q)<<BigInt(32))+BigInt(k+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24)}),p.prototype.readBigInt64BE=lt(function(T){T=T>>>0,J(T,"offset");let k=this[T],O=this[T+7];(k===void 0||O===void 0)&&X(T,this.length-8);let q=(k<<24)+this[++T]*2**16+this[++T]*2**8+this[++T];return(BigInt(q)<<BigInt(32))+BigInt(this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+O)}),p.prototype.readFloatLE=function(T,k){return T=T>>>0,k||R(T,4,this.length),r.read(this,T,!0,23,4)},p.prototype.readFloatBE=function(T,k){return T=T>>>0,k||R(T,4,this.length),r.read(this,T,!1,23,4)},p.prototype.readDoubleLE=function(T,k){return T=T>>>0,k||R(T,8,this.length),r.read(this,T,!0,52,8)},p.prototype.readDoubleBE=function(T,k){return T=T>>>0,k||R(T,8,this.length),r.read(this,T,!1,52,8)};function S(T,k,O,q,H,W){if(!p.isBuffer(T))throw new TypeError('"buffer" argument must be a Buffer instance');if(k>H||k<W)throw new RangeError('"value" argument is out of bounds');if(O+q>T.length)throw new RangeError("Index out of range")}p.prototype.writeUintLE=p.prototype.writeUIntLE=function(T,k,O,q){if(T=+T,k=k>>>0,O=O>>>0,!q){let fe=Math.pow(2,8*O)-1;S(this,T,k,O,fe,0)}let H=1,W=0;for(this[k]=T&255;++W<O&&(H*=256);)this[k+W]=T/H&255;return k+O},p.prototype.writeUintBE=p.prototype.writeUIntBE=function(T,k,O,q){if(T=+T,k=k>>>0,O=O>>>0,!q){let fe=Math.pow(2,8*O)-1;S(this,T,k,O,fe,0)}let H=O-1,W=1;for(this[k+H]=T&255;--H>=0&&(W*=256);)this[k+H]=T/W&255;return k+O},p.prototype.writeUint8=p.prototype.writeUInt8=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,1,255,0),this[k]=T&255,k+1},p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,65535,0),this[k]=T&255,this[k+1]=T>>>8,k+2},p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,65535,0),this[k]=T>>>8,this[k+1]=T&255,k+2},p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,4294967295,0),this[k+3]=T>>>24,this[k+2]=T>>>16,this[k+1]=T>>>8,this[k]=T&255,k+4},p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,4294967295,0),this[k]=T>>>24,this[k+1]=T>>>16,this[k+2]=T>>>8,this[k+3]=T&255,k+4};function B(T,k,O,q,H){j(k,q,H,T,O,7);let W=Number(k&BigInt(4294967295));T[O++]=W,W=W>>8,T[O++]=W,W=W>>8,T[O++]=W,W=W>>8,T[O++]=W;let fe=Number(k>>BigInt(32)&BigInt(4294967295));return T[O++]=fe,fe=fe>>8,T[O++]=fe,fe=fe>>8,T[O++]=fe,fe=fe>>8,T[O++]=fe,O}function F(T,k,O,q,H){j(k,q,H,T,O,7);let W=Number(k&BigInt(4294967295));T[O+7]=W,W=W>>8,T[O+6]=W,W=W>>8,T[O+5]=W,W=W>>8,T[O+4]=W;let fe=Number(k>>BigInt(32)&BigInt(4294967295));return T[O+3]=fe,fe=fe>>8,T[O+2]=fe,fe=fe>>8,T[O+1]=fe,fe=fe>>8,T[O]=fe,O+8}p.prototype.writeBigUInt64LE=lt(function(T,k=0){return B(this,T,k,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeBigUInt64BE=lt(function(T,k=0){return F(this,T,k,BigInt(0),BigInt("0xffffffffffffffff"))}),p.prototype.writeIntLE=function(T,k,O,q){if(T=+T,k=k>>>0,!q){let st=Math.pow(2,8*O-1);S(this,T,k,O,st-1,-st)}let H=0,W=1,fe=0;for(this[k]=T&255;++H<O&&(W*=256);)T<0&&fe===0&&this[k+H-1]!==0&&(fe=1),this[k+H]=(T/W>>0)-fe&255;return k+O},p.prototype.writeIntBE=function(T,k,O,q){if(T=+T,k=k>>>0,!q){let st=Math.pow(2,8*O-1);S(this,T,k,O,st-1,-st)}let H=O-1,W=1,fe=0;for(this[k+H]=T&255;--H>=0&&(W*=256);)T<0&&fe===0&&this[k+H+1]!==0&&(fe=1),this[k+H]=(T/W>>0)-fe&255;return k+O},p.prototype.writeInt8=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,1,127,-128),T<0&&(T=255+T+1),this[k]=T&255,k+1},p.prototype.writeInt16LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,32767,-32768),this[k]=T&255,this[k+1]=T>>>8,k+2},p.prototype.writeInt16BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,2,32767,-32768),this[k]=T>>>8,this[k+1]=T&255,k+2},p.prototype.writeInt32LE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,2147483647,-2147483648),this[k]=T&255,this[k+1]=T>>>8,this[k+2]=T>>>16,this[k+3]=T>>>24,k+4},p.prototype.writeInt32BE=function(T,k,O){return T=+T,k=k>>>0,O||S(this,T,k,4,2147483647,-2147483648),T<0&&(T=4294967295+T+1),this[k]=T>>>24,this[k+1]=T>>>16,this[k+2]=T>>>8,this[k+3]=T&255,k+4},p.prototype.writeBigInt64LE=lt(function(T,k=0){return B(this,T,k,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),p.prototype.writeBigInt64BE=lt(function(T,k=0){return F(this,T,k,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function $(T,k,O,q,H,W){if(O+q>T.length)throw new RangeError("Index out of range");if(O<0)throw new RangeError("Index out of range")}function re(T,k,O,q,H){return k=+k,O=O>>>0,H||$(T,k,O,4,34028234663852886e22,-34028234663852886e22),r.write(T,k,O,q,23,4),O+4}p.prototype.writeFloatLE=function(T,k,O){return re(this,T,k,!0,O)},p.prototype.writeFloatBE=function(T,k,O){return re(this,T,k,!1,O)};function Q(T,k,O,q,H){return k=+k,O=O>>>0,H||$(T,k,O,8,17976931348623157e292,-17976931348623157e292),r.write(T,k,O,q,52,8),O+8}p.prototype.writeDoubleLE=function(T,k,O){return Q(this,T,k,!0,O)},p.prototype.writeDoubleBE=function(T,k,O){return Q(this,T,k,!1,O)},p.prototype.copy=function(T,k,O,q){if(!p.isBuffer(T))throw new TypeError("argument should be a Buffer");if(O||(O=0),!q&&q!==0&&(q=this.length),k>=T.length&&(k=T.length),k||(k=0),q>0&&q<O&&(q=O),q===O||T.length===0||this.length===0)return 0;if(k<0)throw new RangeError("targetStart out of bounds");if(O<0||O>=this.length)throw new RangeError("Index out of range");if(q<0)throw new RangeError("sourceEnd out of bounds");q>this.length&&(q=this.length),T.length-k<q-O&&(q=T.length-k+O);let H=q-O;return this===T&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(k,O,q):Uint8Array.prototype.set.call(T,this.subarray(O,q),k),H},p.prototype.fill=function(T,k,O,q){if(typeof T=="string"){if(typeof k=="string"?(q=k,k=0,O=this.length):typeof O=="string"&&(q=O,O=this.length),q!==void 0&&typeof q!="string")throw new TypeError("encoding must be a string");if(typeof q=="string"&&!p.isEncoding(q))throw new TypeError("Unknown encoding: "+q);if(T.length===1){let W=T.charCodeAt(0);(q==="utf8"&&W<128||q==="latin1")&&(T=W)}}else typeof T=="number"?T=T&255:typeof T=="boolean"&&(T=Number(T));if(k<0||this.length<k||this.length<O)throw new RangeError("Out of range index");if(O<=k)return this;k=k>>>0,O=O===void 0?this.length:O>>>0,T||(T=0);let H;if(typeof T=="number")for(H=k;H<O;++H)this[H]=T;else{let W=p.isBuffer(T)?T:p.from(T,q),fe=W.length;if(fe===0)throw new TypeError('The value "'+T+'" is invalid for argument "value"');for(H=0;H<O-k;++H)this[H+k]=W[H%fe]}return this};var Z={};function K(T,k,O){Z[T]=class extends O{constructor(){super(),Object.defineProperty(this,"message",{value:k.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${T}]`,this.stack,delete this.name}get code(){return T}set code(q){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:q,writable:!0})}toString(){return`${this.name} [${T}]: ${this.message}`}}}K("ERR_BUFFER_OUT_OF_BOUNDS",function(T){return T?`${T} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),K("ERR_INVALID_ARG_TYPE",function(T,k){return`The "${T}" argument must be of type number. Received type ${typeof k}`},TypeError),K("ERR_OUT_OF_RANGE",function(T,k,O){let q=`The value of "${T}" is out of range.`,H=O;return Number.isInteger(O)&&Math.abs(O)>2**32?H=le(String(O)):typeof O=="bigint"&&(H=String(O),(O>BigInt(2)**BigInt(32)||O<-(BigInt(2)**BigInt(32)))&&(H=le(H)),H+="n"),q+=` It must be ${k}. Received ${H}`,q},RangeError);function le(T){let k="",O=T.length,q=T[0]==="-"?1:0;for(;O>=q+4;O-=3)k=`_${T.slice(O-3,O)}${k}`;return`${T.slice(0,O)}${k}`}function te(T,k,O){J(k,"offset"),(T[k]===void 0||T[k+O]===void 0)&&X(k,T.length-(O+1))}function j(T,k,O,q,H,W){if(T>O||T<k){let fe=typeof k=="bigint"?"n":"",st;throw W>3?k===0||k===BigInt(0)?st=`>= 0${fe} and < 2${fe} ** ${(W+1)*8}${fe}`:st=`>= -(2${fe} ** ${(W+1)*8-1}${fe}) and < 2 ** ${(W+1)*8-1}${fe}`:st=`>= ${k}${fe} and <= ${O}${fe}`,new Z.ERR_OUT_OF_RANGE("value",st,T)}te(q,H,W)}function J(T,k){if(typeof T!="number")throw new Z.ERR_INVALID_ARG_TYPE(k,"number",T)}function X(T,k,O){throw Math.floor(T)!==T?(J(T,O),new Z.ERR_OUT_OF_RANGE(O||"offset","an integer",T)):k<0?new Z.ERR_BUFFER_OUT_OF_BOUNDS:new Z.ERR_OUT_OF_RANGE(O||"offset",`>= ${O?1:0} and <= ${k}`,T)}var he=/[^+/0-9A-Za-z-_]/g;function Te(T){if(T=T.split("=")[0],T=T.trim().replace(he,""),T.length<2)return"";for(;T.length%4!==0;)T=T+"=";return T}function oe(T,k){k=k||1/0;let O,q=T.length,H=null,W=[];for(let fe=0;fe<q;++fe){if(O=T.charCodeAt(fe),O>55295&&O<57344){if(!H){if(O>56319){(k-=3)>-1&&W.push(239,191,189);continue}else if(fe+1===q){(k-=3)>-1&&W.push(239,191,189);continue}H=O;continue}if(O<56320){(k-=3)>-1&&W.push(239,191,189),H=O;continue}O=(H-55296<<10|O-56320)+65536}else H&&(k-=3)>-1&&W.push(239,191,189);if(H=null,O<128){if((k-=1)<0)break;W.push(O)}else if(O<2048){if((k-=2)<0)break;W.push(O>>6|192,O&63|128)}else if(O<65536){if((k-=3)<0)break;W.push(O>>12|224,O>>6&63|128,O&63|128)}else if(O<1114112){if((k-=4)<0)break;W.push(O>>18|240,O>>12&63|128,O>>6&63|128,O&63|128)}else throw new Error("Invalid code point")}return W}function ce(T){let k=[];for(let O=0;O<T.length;++O)k.push(T.charCodeAt(O)&255);return k}function ot(T,k){let O,q,H,W=[];for(let fe=0;fe<T.length&&!((k-=2)<0);++fe)O=T.charCodeAt(fe),q=O>>8,H=O%256,W.push(H),W.push(q);return W}function ge(T){return e.toByteArray(Te(T))}function Se(T,k,O,q){let H;for(H=0;H<q&&!(H+O>=k.length||H>=T.length);++H)k[H+O]=T[H];return H}function ut(T,k){return T instanceof k||T!=null&&T.constructor!=null&&T.constructor.name!=null&&T.constructor.name===k.name}function Ze(T){return T!==T}var Ge=function(){let T="0123456789abcdef",k=new Array(256);for(let O=0;O<16;++O){let q=O*16;for(let H=0;H<16;++H)k[q+H]=T[O]+T[H]}return k}();function lt(T){return typeof BigInt>"u"?z:T}function z(){throw new Error("BigInt not supported")}}),gEe=zh((t,e)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,e.exports={Buffer:tI().Buffer,Crypto:window.crypto}):e.exports={Buffer:tI().Buffer,Crypto:crypto}}),gte={};lEe(gte,{AVSCTap:()=>k2,ArweaveSigner:()=>RI,DataItem:()=>E2,MAX_TAG_BYTES:()=>S4,MIN_BINARY_SIZE:()=>kI,SIG_CONFIG:()=>K1,SignatureConfig:()=>Ns,Signer:()=>bte,createData:()=>Mte,deserializeTags:()=>p4,indexToType:()=>TI,serializeTags:()=>II,tagsExceedLimit:()=>_te});var bte=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(t,e,r,a){throw new Error("You must implement verify method on child")}},bEe=Rd(AI(),1),kf=Rd(mte(),1);async function yte(t){if(Array.isArray(t)){let i=(0,kf.concatBuffers)([(0,kf.stringToBuffer)("list"),(0,kf.stringToBuffer)(t.length.toString())]);return await wte(t,await qh().hash(i,"SHA-384"))}let e=t,r=(0,kf.concatBuffers)([(0,kf.stringToBuffer)("blob"),(0,kf.stringToBuffer)(e.byteLength.toString())]),a=(0,kf.concatBuffers)([await qh().hash(r,"SHA-384"),await qh().hash(e,"SHA-384")]);return await qh().hash(a,"SHA-384")}async function wte(t,e){if(t.length<1)return e;let r=(0,kf.concatBuffers)([e,await yte(t[0])]),a=await qh().hash(r,"SHA-384");return await wte(t.slice(1),a)}var BT=Rd(vEe(),1),yEe=BT.default.default?BT.default.default:BT.default,wEe=class extends yEe{getPublicKey(t){throw new Error("Unimplemented")}},_Ee;function qh(){return _Ee??=new wEe}var Ns;(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"})(Ns||(Ns={}));var K1={[Ns.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[Ns.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[Ns.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[Ns.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[Ns.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[Ns.MULTIAPTOS]:{sigLength:64*32+4,pubLength:32*32+1,sigName:"multiAptos"},[Ns.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},RI=class{signatureType=1;ownerLength=K1[1].pubLength;signatureLength=K1[1].sigLength;jwk;pk;constructor(t){this.pk=t.n,this.jwk=t}get publicKey(){return bEe.default.toBuffer(this.pk)}sign(t){return qh().sign(this.jwk,t)}static async verify(t,e,r){return await qh().verify(t,e,r)}},TI={1:RI},Ou=Rd(AI(),1);async function rI(t){return yte([(0,kf.stringToBuffer)("dataitem"),(0,kf.stringToBuffer)("1"),(0,kf.stringToBuffer)(t.signatureType.toString()),t.rawOwner,t.rawTarget,t.rawAnchor,t.rawTags,t.rawData])}async function MEe(t,e){let r=await rI(t),a=await e.sign(r),i=await qh().hash(a);return{signature:Me.from(a),id:Me.from(i)}}async function xEe(t,e){let{signature:r,id:a}=await MEe(t,e);return t.getRaw().set(r,2),a}var k2=class{buf;pos;constructor(t=Me.alloc(S4),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,r;if(e)for(this.writeLong(e),r=0;r<e;r++){let a=t[r];if(a?.name===void 0||a?.value===void 0)throw new Error(`Invalid tag format for ${a}, expected {name:string, value: string}`);this.writeString(a.name),this.writeString(a.value)}this.writeLong(0)}toBuffer(){let t=Me.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,r,a;if(t>=-1073741824&&t<1073741824){a=t>=0?t<<1:~t<<1|1;do e[this.pos]=a&127,a>>=7;while(a&&(e[this.pos++]|=128))}else{r=t>=0?t*2:-t*2-1;do e[this.pos]=r&127,r/=128;while(r>=1&&(e[this.pos++]|=128))}this.pos++,this.buf=e}writeString(t){let e=Me.byteLength(t),r=this.buf;this.writeLong(e);let a=this.pos;if(this.pos+=e,!(this.pos>r.length)){if(e>64)this.buf.write(t,this.pos-e,e,"utf8");else{let i,h,l,p;for(i=0,h=e;i<h;i++)l=t.charCodeAt(i),l<128?r[a++]=l:l<2048?(r[a++]=l>>6|192,r[a++]=l&63|128):(l&64512)===55296&&((p=t.charCodeAt(i+1))&64512)===56320?(l=65536+((l&1023)<<10)+(p&1023),i++,r[a++]=l>>18|240,r[a++]=l>>12&63|128,r[a++]=l>>6&63|128,r[a++]=l&63|128):(r[a++]=l>>12|224,r[a++]=l>>6&63|128,r[a++]=l&63|128)}this.buf=r}}readLong(){let t=0,e=0,r=this.buf,a,i,h,l;do a=r[this.pos++],i=a&128,t|=(a&127)<<e,e+=7;while(i&&e<28);if(i){h=t,l=268435456;do a=r[this.pos++],h+=(a&127)*l,l*=128;while(a&128);return(h%2?-(h+1):h)/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 r=this.readString(),a=this.readString();t.push({name:r,value:a})}return t}readString(){let t=this.readLong(),e=this.pos,r=this.buf;if(this.pos+=t,!(this.pos>r.length))return this.buf.slice(e,e+t).toString()}};function II(t){let e=new k2;return e.writeTags(t),e.toBuffer()}function _te(t){let e=new k2;return e.writeTags(t),e.tagsExceedLimit()}function p4(t){return new k2(t).readTags()}function pc(t){let e=0;for(let r=t.length-1;r>=0;r--)e=e*256+t[r];return e}function SEe(t){if(t>29)throw new Error("Short too long");let e=[0,0];for(let r=0;r<e.length;r++){let a=t&255;e[r]=a,t=(t-a)/256}return Uint8Array.from(e)}function $Q(t){let e=[0,0,0,0,0,0,0,0];for(let r=0;r<e.length;r++){let a=t&255;e[r]=a,t=(t-a)/256}return Uint8Array.from(e)}var EEe=Rd(gEe(),1),A1=Rd(tI(),1),S4=4096,kI=80,E2=class{binary;_id;constructor(t){this.binary=t}static isDataItem(t){return t.binary!==void 0}get signatureType(){let t=pc(this.binary.subarray(0,2));if(Ns?.[t]!==void 0)return t;throw new Error("Unknown signature type: "+t)}async isValid(){return E2.verify(this.binary)}get id(){return(async()=>Ou.default.encode(await this.rawId))()}set id(t){this._id=Ou.default.toBuffer(t)}get rawId(){return(async()=>A1.Buffer.from(await EEe.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 Ou.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 K1[this.signatureType].sigLength}get owner(){return Ou.default.encode(this.rawOwner)}get ownerLength(){return K1[this.signatureType].pubLength}get rawTarget(){let t=this.getTargetStart();return this.binary[t]==1?this.binary.subarray(t+1,t+33):A1.Buffer.alloc(0)}get target(){return Ou.default.encode(this.rawTarget)}get rawAnchor(){let t=this.getAnchorStart();return this.binary[t]==1?this.binary.subarray(t+1,t+33):A1.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let t=this.getTagsStart(),e=pc(this.binary.subarray(t+8,t+16));return this.binary.subarray(t+16,t+16+e)}get tags(){let t=this.getTagsStart();if(pc(this.binary.subarray(t,t+8))==0)return[];let e=pc(this.binary.subarray(t+8,t+16));return p4(A1.Buffer.from(this.binary.subarray(t+16,t+16+e)))}get tagsB64Url(){return this.tags.map(t=>({name:Ou.default.encode(t.name),value:Ou.default.encode(t.value)}))}getStartOfData(){let t=this.getTagsStart(),e=this.binary.subarray(t+8,t+16),r=pc(e);return t+16+r}get rawData(){let t=this.getTagsStart(),e=this.binary.subarray(t+8,t+16),r=pc(e),a=t+16+r;return this.binary.subarray(a,this.binary.length)}get data(){return Ou.default.encode(this.rawData)}getRaw(){return this.binary}async sign(t){return this._id=await xEe(this,t),this.rawId}async setSignature(t){this.binary.set(t,2),this._id=A1.Buffer.from(await qh().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:Ou.default.encode(t.name),value:Ou.default.encode(t.value)})),data:this.data}}static async verify(t){if(t.byteLength<kI)return!1;let e=new E2(t),r=e.signatureType,a=e.getTagsStart(),i=pc(t.subarray(a,a+8)),h=t.subarray(a+8,a+16),l=pc(h);if(l>S4)return!1;if(i>0)try{if(p4(A1.Buffer.from(t.subarray(a+16,a+16+l))).length!==i)return!1}catch{return!1}let p=TI[r],b=await rI(e);return await p.verify(e.rawOwner,b,e.rawSignature)}async getSignatureData(){return rI(this)}getTagsStart(){let t=this.getTargetStart(),e=this.binary[t]==1,r=t+(e?33:1),a=this.binary[r]==1;return r+=a?33:1,r}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}},AEe=Rd(AI(),1);function Mte(t,e,r){let a=e.publicKey,i=r?.target?AEe.default.toBuffer(r.target):null,h=1+(i?.byteLength??0),l=r?.anchor?Me.from(r.anchor):null,p=1+(l?.byteLength??0),b=(r?.tags?.length??0)>0?II(r.tags):null,g=16+(b?b.byteLength:0),y=Me.from(t),M=y.byteLength,x=2+e.signatureLength+e.ownerLength+h+p+g+M,E=Me.alloc(x);if(E.set(SEe(e.signatureType),0),E.set(new Uint8Array(e.signatureLength).fill(0),2),a.byteLength!==e.ownerLength)throw new Error(`Owner must be ${e.ownerLength} bytes, but was incorrectly ${a.byteLength}`);E.set(a,2+e.signatureLength);let A=2+e.signatureLength+e.ownerLength;if(E[A]=i?1:0,i){if(i.byteLength!==32)throw new Error(`Target must be 32 bytes but was incorrectly ${i.byteLength}`);E.set(i,A+1)}let I=A+h,P=I+1;if(E[I]=l?1:0,l){if(P+=l.byteLength,l.byteLength!==32)throw new Error("Anchor must be 32 bytes");E.set(l,I+1)}E.set($Q(r?.tags?.length??0),P);let N=$Q(b?.byteLength??0);E.set(N,P+8),b&&E.set(b,P+16);let L=P+g;return E.set(y,L),new E2(E)}var BI={...gte};globalThis.arbundles??=BI;var REe=BI,TEe=BI;globalThis.Buffer||(globalThis.Buffer=dte.Buffer);var{DataItem:IEe}=pte;function kEe(t){return async({data:r,tags:a,target:i,anchor:h,createDataItem:l=p=>new IEe(p)})=>{let p=await t.signDataItem({data:r,tags:a,target:i,anchor:h}),b=l(dte.Buffer.from(p));return{id:await b.id,raw:await b.getRaw()}}}var BEe=globalThis.GATEWAY_URL||void 0,PEe=globalThis.MU_URL||void 0,OEe=globalThis.CU_URL||void 0,NEe=globalThis.GRAPHQL_URL||void 0,{result:dut,results:put,message:vut,spawn:mut,monitor:gut,unmonitor:but,dryrun:yut,assign:wut}=Sc({GATEWAY_URL:BEe,MU_URL:PEe,CU_URL:OEe,GRAPHQL_URL:NEe}),xte=cte.createDataItemSigner;ie();ae();ne();var mre=mi(vre(),1),O4=mre.default.init({host:"arweave.net",port:443,protocol:"https"});ie();ae();ne();ie();ae();ne();var Df=class extends Error{constructor(e){super(e),this.name=this.constructor.name}},gre=class extends Df{},bre=class extends Df{},yre=class extends Df{constructor(e,r){super(`Failed request: ${e}: ${r}`)}},wre=class extends Df{},N4=class extends Df{},_re=class extends Df{constructor(){super("Invalid signer. Please provide a valid signer to interact with the contract.")}},Rc=class extends Df{constructor(){super("Invalid contract configuration")}},Mre=class extends Df{constructor(){super("Invalid process configuration")}},xre=class extends Df{};ie();ae();ne();var Kf=mi(zfe(),1);ie();ae();ne();var Fw="3.4.0-alpha.1";var Wu=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,Kf.createLogger)({level:e,silent:this.silent,defaultMeta:{name:"ar-io-sdk",version:Fw},format:Kf.format.combine(Kf.format.timestamp(),Kf.format.json()),transports:[new Kf.transports.Console({format:Kf.format.combine(Kf.format.timestamp(),Kf.format.json())})]})}info(e,...r){this.silent||this.logger.info(e,...r)}warn(e,...r){this.silent||this.logger.warn(e,...r)}error(e,...r){this.silent||this.logger.error(e,...r)}debug(e,...r){this.silent||this.logger.debug(e,...r)}setLogLevel(e){this.silent=e==="none","silent"in this.logger&&(this.logger.silent=e==="none"),"level"in this.logger&&(this.logger.level=e)}};ie();ae();ne();ie();ae();ne();function Pc(t,e){let r=t.safeParse(e);if(!r.success)throw new Error(JSON.stringify(r.error.format(),null,2));return r}var jw=class{static init(e){return e!==void 0&&"signer"in e?new fP(e):new zw(e)}},zw=class{process;strict;constructor(e){if(this.strict=e.strict||!1,vv(e))this.process=e.process;else if(mv(e))this.process=new za({processId:e.processId});else throw new Rc}async getState({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"State"}],a=await this.process.read({tags:r});return e&&Pc(MT.passthrough().and(Qt.object({Records:Qt.record(Qt.string(),$8.passthrough())})),a),a}async getInfo({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"Info"}],a=await this.process.read({tags:r});return e&&Pc(dQ.passthrough(),a),a}async getLogo(){return(await this.getInfo()).Logo}async getRecord({undername:e},{strict:r}={strict:this.strict}){let a=[{name:"Sub-Domain",value:e},{name:"Action",value:"Record"}],i=await this.process.read({tags:a});return r&&Pc($8.passthrough(),i),i}async getRecords({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"Records"}],a=await this.process.read({tags:r});return e&&Pc(yT,a),a}async getOwner({strict:e}={strict:this.strict}){return(await this.getInfo({strict:e})).Owner}async getControllers({strict:e}={strict:this.strict}){let r=[{name:"Action",value:"Controllers"}],a=await this.process.read({tags:r});return e&&Pc(wT,a),a}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 r=[{name:"Action",value:"Balances"}],a=await this.process.read({tags:r});return e&&Pc(_T,a),a}async getBalance({address:e},{strict:r}={strict:this.strict}){let a=[{name:"Action",value:"Balance"},{name:"Recipient",value:e}],i=await this.process.read({tags:a});return r&&Pc(Qt.number(),i),i}async getHandlers(){let e=await this.getInfo();return e.Handlers??e.HandlerNames}},fP=class extends zw{signer;constructor({signer:e,...r}){super(r),this.signer=pv(e)}async transfer({target:e},r){let a=[...r?.tags??[],{name:"Action",value:"Transfer"},{name:"Recipient",value:e}];return this.process.send({tags:a,signer:this.signer})}async addController({controller:e},r){let a=[...r?.tags??[],{name:"Action",value:"Add-Controller"},{name:"Controller",value:e}];return this.process.send({tags:a,signer:this.signer})}async removeController({controller:e},r){let a=[...r?.tags??[],{name:"Action",value:"Remove-Controller"},{name:"Controller",value:e}];return this.process.send({tags:a,signer:this.signer})}async setRecord({undername:e,transactionId:r,ttlSeconds:a},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:e},{name:"Transaction-Id",value:r},{name:"TTL-Seconds",value:a.toString()}],signer:this.signer})}async setBaseNameRecord({transactionId:e,ttlSeconds:r}){return this.process.send({tags:[{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:"@"},{name:"Transaction-Id",value:e},{name:"TTL-Seconds",value:r.toString()}],signer:this.signer})}async setUndernameRecord({undername:e,transactionId:r,ttlSeconds:a}){return this.setRecord({undername:e,transactionId:r,ttlSeconds:a})}async removeUndernameRecord({undername:e}){return this.removeRecord({undername:e})}async removeRecord({undername:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Remove-Record"},{name:"Sub-Domain",value:e}],signer:this.signer})}async setTicker({ticker:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Ticker"},{name:"Ticker",value:e}],signer:this.signer})}async setName({name:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Name"},{name:"Name",value:e}],signer:this.signer})}async setDescription({description:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Description"},{name:"Description",value:e}],signer:this.signer})}async setKeywords({keywords:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Keywords"},{name:"Keywords",value:JSON.stringify(e)}],signer:this.signer})}async setLogo({txId:e},r){return this.process.send({tags:[...r?.tags??[],{name:"Action",value:"Set-Logo"},{name:"Logo",value:e}],signer:this.signer})}async releaseName({name:e,arioProcessId:r},a){return this.process.send({tags:[...a?.tags??[],{name:"Action",value:"Release-Name"},{name:"Name",value:e},{name:"IO-Process-Id",value:r},{name:"ARIO-Process-Id",value:r}],signer:this.signer})}async reassignName({name:e,arioProcessId:r,antProcessId:a},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Reassign-Name"},{name:"Name",value:e},{name:"IO-Process-Id",value:r},{name:"ARIO-Process-Id",value:r},{name:"Process-Id",value:a}],signer:this.signer})}async approvePrimaryNameRequest({name:e,address:r,arioProcessId:a},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Approve-Primary-Name"},{name:"Name",value:e},{name:"Recipient",value:r},{name:"IO-Process-Id",value:a},{name:"ARIO-Process-Id",value:a}],signer:this.signer})}async removePrimaryNames({names:e,arioProcessId:r,notifyOwners:a=!1},i){return this.process.send({tags:[...i?.tags??[],{name:"Action",value:"Remove-Primary-Names"},{name:"Names",value:e.join(",")},{name:"IO-Process-Id",value:r},{name:"ARIO-Process-Id",value:r},{name:"Notify-Owners",value:a.toString()}],signer:this.signer})}};ie();ae();ne();var Sb=class{static init(e){return e!==void 0&&"signer"in e?new uP(e):new Zw(e)}},Zw=class{process;constructor(e){if(e===void 0||Object.keys(e).length===0)this.process=new za({processId:D8});else if(vv(e))this.process=e.process;else if(mv(e))this.process=new za({processId:e.processId});else throw new Rc}async accessControlList({address:e}){return this.process.read({tags:[{name:"Action",value:"Access-Control-List"},{name:"Address",value:e}]})}},uP=class extends Zw{signer;constructor({signer:e,...r}){super(r),this.signer=pv(e)}async register({processId:e}){return this.process.send({tags:[{name:"Action",value:"Register"},{name:"Process-Id",value:e}],signer:this.signer})}};ie();ae();ne();ie();ae();ne();ie();ae();ne();cu();var Zfe="+",Hfe="/",Kfe="-",Wfe="_",Vfe="=";function Qqe(t){let e=t.length%4;return e&&(t+=Vfe.repeat(4-e)),t.replaceAll(Kfe,Zfe).replaceAll(Wfe,Hfe)}function eUe(t){return t.replaceAll(Zfe,Kfe).replaceAll(Hfe,Wfe).replaceAll(Vfe,"")}function Gbt(t){let e=Qqe(t);return Me.from(e,"base64")}function tUe(t){let e=t.toString("base64");return eUe(e)}function Ybt(t){return tUe(df("sha256").update(Uint8Array.from(t)).digest())}function Gfe(t=32){let e=oE(t);return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("").slice(0,t)}ie();ae();ne();ie();ae();ne();function hP(t){try{return JSON.parse(t)}catch{return t}}ie();ae();ne();ie();ae();ne();var cP=mi(Jfe(),1);ie();ae();ne();var nUe=Object.defineProperty,aUe=(t,e,r)=>e in t?nUe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ab=(t,e,r)=>(aUe(t,typeof e!="symbol"?e+"":e,r),r),dP=class{constructor(e){Ab(this,"value"),Ab(this,"next"),this.value=e}},pP=class{constructor(){Ab(this,"head"),Ab(this,"tail"),Ab(this,"_size",0),this.clear()}clear(){this.head=void 0,this.tail=void 0,this._size=0}push(e){let r=new dP(e);return this.head&&this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),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 Xfe(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 pP,r=0,a=()=>{r--,e.size>0&&e.pop()()},i=async(p,b,g)=>{r++;let y=(async()=>p(...g))();b(y);try{await y}catch{}a()},h=(p,b,g)=>{e.push(i.bind(null,p,b,g)),(async()=>(await Promise.resolve(),r<t&&e.size>0&&e.pop()()))()},l=(p,...b)=>new Promise(g=>{h(p,g,b)});return Object.defineProperties(l,{activeCount:{get:()=>r},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),l}var Ryt=async({address:t,registry:e=Sb.init()})=>{let r=await e.accessControlList({address:t});return[...new Set([...r.Owned,...r.Controlled])]};function Qfe(t,e){return new Promise((r,a)=>{let i=setTimeout(()=>{a(new Error("Timeout"))},t);e.then(h=>{clearTimeout(i),r(h)}).catch(h=>{clearTimeout(i),a(h)})})}var eue=class extends cP.default{contract;timeoutMs;throttle;logger;strict;antAoClient;constructor({contract:e=Rb.init({processId:Lh}),timeoutMs:r=6e4,concurrency:a=30,logger:i=Wu.default,strict:h=!1,antAoClient:l=Sc()}={}){super(),this.contract=e,this.timeoutMs=r,this.throttle=Xfe(a),this.logger=i,this.strict=h,this.antAoClient=l}async fetchProcessesOwnedByWallet({address:e,pageSize:r,antRegistry:a=Sb.init()}){let i={},h=await a.accessControlList({address:e}),l=new Set([...h.Owned,...h.Controlled]);await Qfe(this.timeoutMs,oUe({contract:this.contract,emitter:this,pageSize:r})).catch(b=>(this.emit("error",`Error getting ArNS records: ${b}`),this.logger.error("Error getting ArNS records",{message:b?.message,stack:b?.stack}),{})).then(b=>{Object.entries(b).forEach(([g,y])=>{l.has(y.processId)&&(i[y.processId]==null&&(i[y.processId]={state:void 0,names:{}}),i[y.processId].names[g]=y)})});let p=Object.keys(i).length;this.emit("progress",0,p),await Promise.all(Object.keys(i).map(async(b,g)=>this.throttle(async()=>{if(i[b].state!==void 0){this.emit("progress",g+1,p);return}let y=jw.init({process:new za({processId:b,ao:this.antAoClient}),strict:this.strict}),M=await Qfe(this.timeoutMs,y.getState()).catch(x=>{this.emit("error",`Error getting state for process ${b}: ${x}`)});(M?.Owner===e||M?.Controllers.includes(e))&&(i[b].state=M,this.emit("process",b,i[b])),this.emit("progress",g+1,p)}))),this.emit("end",i)}},oUe=async({contract:t=Rb.init({processId:Lh}),emitter:e,logger:r=Wu.default,pageSize:a=5e4})=>{let i,h=Date.now(),l={};do{let p=await t.getArNSRecords({cursor:i,limit:a}).catch(b=>{r?.error("Error getting ArNS records",{message:b?.message,stack:b?.stack}),e?.emit("arns:error",`Error getting ArNS records: ${b}`)});if(!p)return{};p.items.forEach(b=>{let{name:g,...y}=b;l[g]=y}),r.debug("Fetched page of ArNS records",{totalRecordCount:p.totalItems,fetchedRecordCount:Object.keys(l).length,cursor:p.nextCursor}),e?.emit("arns:pageLoaded",{totalRecordCount:p.totalItems,fetchedRecordCount:Object.keys(l).length,records:p.items,cursor:p.nextCursor}),i=p.nextCursor}while(i!==void 0);return e?.emit("arns:end",l),r.debug("Fetched all ArNS records",{totalRecordCount:Object.keys(l).length,durationMs:Date.now()-h}),l};var za=class{logger;ao;processId;constructor({processId:e,ao:r=Sc(),logger:a=Wu.default}){this.processId=e,this.logger=a,this.ao=r}isMessageDataEmpty(e){return e===void 0||e==="null"||e===""||e===null}async read({tags:e,retries:r=3,fromAddress:a}){let i=0,h;for(;i<r;)try{this.logger.debug("Evaluating read interaction on process",{tags:e,processId:this.processId});let l={process:this.processId,tags:e};a!==void 0&&(l.Owner=a);let p=await this.ao.dryrun(l);this.logger.debug("Read interaction result",{result:p,processId:this.processId});let b=vP(p);if(b!==void 0)throw new Error(b);if(p.Messages===void 0||p.Messages.length===0)throw this.logger.debug(`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 g=p.Messages?.[0]?.Data;return this.isMessageDataEmpty(g)?void 0:hP(g)}catch(l){i++,this.logger.debug(`Read attempt ${i} failed`,{error:l?.message,stack:l?.stack,tags:e,processId:this.processId}),h=l,await new Promise(p=>setTimeout(p,2**i*1e3))}throw h}async send({tags:e,data:r,signer:a,retries:i=3}){let h=0,l;for(;h<i;)try{this.logger.debug("Evaluating send interaction on contract",{tags:e,data:r,processId:this.processId});let p=Gfe(32),b=await this.ao.message({process:this.processId,tags:[...e,{name:"AR-IO-SDK",value:Fw}],data:r,signer:a,anchor:p});this.logger.debug("Sent message to process",{messageId:b,processId:this.processId,anchor:p});let g=await this.ao.result({message:b,process:this.processId});this.logger.debug("Message result",{output:g,messageId:b,processId:this.processId});let y=vP(g);if(y!==void 0)throw new N4(y);if(g.Messages?.length===0||g.Messages===void 0)return{id:b};if(g.Messages.length===0)throw new Error(`Process ${this.processId} does not support provided action.`);if(this.isMessageDataEmpty(g.Messages[0].Data))return{id:b};let M=hP(g.Messages[0].Data);return this.logger.debug("Message result data",{resultData:M,messageId:b,processId:this.processId}),{id:b,result:M}}catch(p){if(this.logger.error("Error sending message to process",{error:p?.message,stack:p?.stack,processId:this.processId,tags:e}),p.message.includes("500"))this.logger.debug("Retrying send interaction",{attempts:h,retries:i,error:p?.message,processId:this.processId}),await new Promise(b=>setTimeout(b,2**h*2e3)),h++,l=p;else throw p}throw l}};var Rb=class{static init(e){return e!==void 0&&"signer"in e?new mP(e):new Ww(e)}},Ww=class{process;epochSettings;arweave;constructor(e){if(this.arweave=e?.arweave??O4,e===void 0||Object.keys(e).length===0)this.process=new za({processId:Lh});else if(vv(e))this.process=e.process;else if(mv(e))this.process=new za({processId:e.processId});else throw new Rc}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 r=await this.getEpochSettings(),a=r.epochZeroStartTimestamp,i=r.durationMs;return Math.floor((e-a)/i)}async computeCurrentEpochIndex(){let e=await this.getEpochSettings(),r=e.epochZeroStartTimestamp,a=e.durationMs,i=Date.now();return Math.floor((i-r)/a)}async computeEpochIndex(e){let r=e?.epochIndex;if(r!==void 0)return r.toString();let a=e?.timestamp;if(a!==void 0)return(await this.computeEpochIndexForTimestamp(a)).toString()}async getEpochSettings(){return this.epochSettings??=await this.process.read({tags:[{name:"Action",value:"Epoch-Settings"}]})}async getEpoch(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&+r<a)return await Kw({arweave:this.arweave,epochIndex:+r,processId:this.process.processId});let i=[{name:"Action",value:"Epoch"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(i)})}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"},...Ha(e)]})}async getArNSReservedNames(e){return this.process.read({tags:[{name:"Action",value:"Reserved-Names"},...Ha(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"},...Ha(e)]})}async getVault({address:e,vaultId:r}){return this.process.read({tags:[{name:"Action",value:"Vault"},{name:"Address",value:e},{name:"Vault-Id",value:r}]})}async getVaults(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Vaults"},...Ha(e)]})}async getGateway({address:e}){return this.process.read({tags:[{name:"Action",value:"Gateway"},{name:"Address",value:e}]})}async getGatewayDelegates({address:e,...r}){return this.process.read({tags:[{name:"Action",value:"Paginated-Delegates"},{name:"Address",value:e},...Ha(r)]})}async getGatewayDelegateAllowList({address:e,...r}){return this.process.read({tags:[{name:"Action",value:"Paginated-Allowed-Delegates"},{name:"Address",value:e},...Ha(r)]})}async getGateways(e){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateways"},...Ha(e)]})}async getCurrentEpoch(){return this.process.read({tags:[{name:"Action",value:"Epoch"}]})}async getPrescribedObservers(e){let r=[{name:"Action",value:"Epoch-Prescribed-Observers"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(r)})}async getPrescribedNames(e){let r=[{name:"Action",value:"Epoch-Prescribed-Names"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(r)})}async getObservations(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&+r<a)return(await Kw({arweave:this.arweave,epochIndex:+r,processId:this.process.processId}))?.observations;let i=[{name:"Action",value:"Epoch-Observations"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(i)})}async getDistributions(e){let r=await this.computeEpochIndex(e),a=await this.computeCurrentEpochIndex();if(r!==void 0&&+r<a)return(await Kw({arweave:this.arweave,epochIndex:+r,processId:this.process.processId}))?.distributions;let i=[{name:"Action",value:"Epoch-Distributions"},{name:"Epoch-Index",value:await this.computeEpochIndex(e)}];return this.process.read({tags:Sn(i)})}async getTokenCost({intent:e,type:r,years:a,name:i,quantity:h,fromAddress:l}){let p=[{name:"Action",value:"Token-Cost"},{name:"Intent",value:e},{name:"Name",value:i},{name:"Years",value:a?.toString()},{name:"Quantity",value:h?.toString()},{name:"Purchase-Type",value:r}];return this.process.read({tags:Sn(p),fromAddress:l})}async getCostDetails({intent:e,type:r,years:a,name:i,quantity:h,fromAddress:l,fundFrom:p}){let b=[{name:"Action",value:"Cost-Details"},{name:"Intent",value:e},{name:"Name",value:i},{name:"Years",value:a?.toString()},{name:"Quantity",value:h?.toString()},{name:"Purchase-Type",value:r},{name:"Fund-From",value:p}];return this.process.read({tags:Sn(b),fromAddress:l})}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"},...Ha(e)]})}async getArNSReturnedName({name:e}){let r=[{name:"Action",value:"Returned-Name"},{name:"Name",value:e}];return this.process.read({tags:r})}async getDelegations(e){let r=[{name:"Action",value:"Paginated-Delegations"},{name:"Address",value:e.address},...Ha(e)];return this.process.read({tags:Sn(r)})}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},...Ha(e)]})}async getPrimaryNameRequest(e){let r=[{name:"Action",value:"Primary-Name-Request"},{name:"Initiator",value:e.initiator}];return this.process.read({tags:r})}async getPrimaryNameRequests(e){return this.process.read({tags:[{name:"Action",value:"Primary-Name-Requests"},...Ha(e)]})}async getPrimaryName(e){let r=[{name:"Action",value:"Primary-Name"},{name:"Address",value:e?.address},{name:"Name",value:e?.name}];return this.process.read({tags:Sn(r)})}async getPrimaryNames(e){return this.process.read({tags:[{name:"Action",value:"Primary-Names"},...Ha(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"},...Ha(e)]})}async getAllGatewayVaults(e){return this.process.read({tags:[{name:"Action",value:"All-Gateway-Vaults"},...Ha(e)]})}},mP=class extends Ww{signer;constructor({signer:e,...r}){r===void 0?super({process:new za({processId:Lh})}):super(r),this.signer=pv(e)}async transfer({target:e,qty:r},a){let{tags:i=[]}=a||{};return this.process.send({tags:[...i,{name:"Action",value:"Transfer"},{name:"Recipient",value:e},{name:"Quantity",value:r.valueOf().toString()}],signer:this.signer})}async vaultedTransfer({recipient:e,quantity:r,lockLengthMs:a,revokable:i=!1},h){let{tags:l=[]}=h||{};return this.process.send({tags:[...l,{name:"Action",value:"Vaulted-Transfer"},{name:"Recipient",value:e},{name:"Quantity",value:r.toString()},{name:"Lock-Length",value:a.toString()},{name:"Revokable",value:`${i}`}],signer:this.signer})}async revokeVault({vaultId:e,recipient:r},a){let{tags:i=[]}=a||{};return this.process.send({tags:[...i,{name:"Action",value:"Revoke-Vault"},{name:"Vault-Id",value:e},{name:"Recipient",value:r}],signer:this.signer})}async joinNetwork({operatorStake:e,allowDelegatedStaking:r,allowedDelegates:a,delegateRewardShareRatio:i,fqdn:h,label:l,minDelegatedStake:p,note:b,port:g,properties:y,protocol:M,autoStake:x,observerAddress:E},A){let{tags:I=[]}=A||{},P=[...I,{name:"Action",value:"Join-Network"},{name:"Operator-Stake",value:e.valueOf().toString()},{name:"Allow-Delegated-Staking",value:r?.toString()},{name:"Allowed-Delegates",value:a?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:i?.toString()},{name:"FQDN",value:h},{name:"Label",value:l},{name:"Min-Delegated-Stake",value:p?.valueOf().toString()},{name:"Note",value:b},{name:"Port",value:g?.toString()},{name:"Properties",value:y},{name:"Protocol",value:M},{name:"Auto-Stake",value:x?.toString()},{name:"Observer-Address",value:E}];return this.process.send({signer:this.signer,tags:Sn(P)})}async leaveNetwork(e){let{tags:r=[]}=e||{};return this.process.send({signer:this.signer,tags:[...r,{name:"Action",value:"Leave-Network"}]})}async updateGatewaySettings({allowDelegatedStaking:e,allowedDelegates:r,delegateRewardShareRatio:a,fqdn:i,label:h,minDelegatedStake:l,note:p,port:b,properties:g,protocol:y,autoStake:M,observerAddress:x},E){let{tags:A=[]}=E||{},I=[...A,{name:"Action",value:"Update-Gateway-Settings"},{name:"Label",value:h},{name:"Note",value:p},{name:"FQDN",value:i},{name:"Port",value:b?.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:r?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:a?.toString()},{name:"Min-Delegated-Stake",value:l?.valueOf().toString()},{name:"Auto-Stake",value:M?.toString()}];return this.process.send({signer:this.signer,tags:Sn(I)})}async delegateStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Delegate-Stake"},{name:"Target",value:e.target},{name:"Quantity",value:e.stakeQty.valueOf().toString()}]})}async decreaseDelegateStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{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,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Instant-Withdrawal"},{name:"Vault-Id",value:e.vaultId},{name:"Address",value:e.gatewayAddress}];return this.process.send({signer:this.signer,tags:Sn(i)})}async increaseOperatorStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Increase-Operator-Stake"},{name:"Quantity",value:e.increaseQty.valueOf().toString()}]})}async decreaseOperatorStake(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Decrease-Operator-Stake"},{name:"Quantity",value:e.decreaseQty.valueOf().toString()},{name:"Instant",value:`${e.instant||!1}`}]})}async saveObservations(e,r){let{tags:a=[]}=r||{};return this.process.send({signer:this.signer,tags:[...a,{name:"Action",value:"Save-Observations"},{name:"Report-Tx-Id",value:e.reportTxId},{name:"Failed-Gateways",value:e.failedGateways.join(",")}]})}async buyRecord(e,r){let{tags:a=[]}=r||{},i=[...a,{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:Sn(i)})}async upgradeRecord(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Upgrade-Name"},{name:"Name",value:e.name},{name:"Fund-From",value:e.fundFrom}];return this.process.send({signer:this.signer,tags:Sn(i)})}async extendLease(e,r){let{tags:a=[]}=r||{},i=[...a,{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:Sn(i)})}async increaseUndernameLimit(e,r){let{tags:a=[]}=r||{},i=[...a,{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:Sn(i)})}async cancelWithdrawal(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Cancel-Withdrawal"},{name:"Vault-Id",value:e.vaultId},{name:"Address",value:e.gatewayAddress}];return this.process.send({signer:this.signer,tags:Sn(i)})}async requestPrimaryName(e,r){let{tags:a=[]}=r||{},i=[...a,{name:"Action",value:"Request-Primary-Name"},{name:"Name",value:e.name}];return this.process.send({signer:this.signer,tags:Sn(i)})}async redelegateStake(e,r){let{tags:a=[]}=r||{},i=[...a,{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:Sn(i)})}};async function t3t({signer:t,module:e=oQ,ao:r=Sc(),scheduler:a=uQ,state:i,antRegistryId:h=D8,logger:l=Wu.default,authority:p=fQ}){let b=await r.spawn({module:e,scheduler:a,signer:t,data:i?JSON.stringify(i):void 0,tags:[{name:"Authority",value:p},{name:"ANT-Registry-Id",value:h}]});return l.debug("Spawned ANT",{processId:b,module:e,scheduler:a}),b}async function r3t({signer:t,processId:e,luaCodeTxId:r=sQ,ao:a=Sc(),logger:i=Wu.default,arweave:h=O4}){let l=new za({processId:e,ao:a,logger:i}),p=await h.transactions.getData(r,{decode:!0,string:!0}),{id:b}=await l.send({tags:[{name:"Action",value:"Eval"},{name:"App-Name",value:"ArNS-ANT"},{name:"Source-Code-TX-ID",value:r}],data:p,signer:t});return i.debug("Evolved ANT",{processId:e,luaCodeTxId:r,evalMsgId:b}),b}function sUe(t){let e=Qt.object({name:Qt.string(),value:Qt.union([Qt.string(),Qt.number()])}),r=Qt.function().args(Qt.object({data:Qt.union([Qt.string(),Qt.instanceof(Me)]),tags:Qt.array(e).optional(),target:Qt.string().optional(),anchor:Qt.string().optional()})).returns(Qt.promise(Qt.object({id:Qt.string(),raw:Qt.instanceof(ArrayBuffer)})));try{return r.parse(t),!0}catch{return!1}}function pv(t){return sUe(t)?t:"publicKey"in t?async({data:r,tags:a,target:i,anchor:h})=>{if(t.publicKey===void 0&&"setPublicKey"in t&&typeof t.setPublicKey=="function"&&await t.setPublicKey(),t instanceof uc){let b=await t.signer.signDataItem({data:r,tags:a,target:i,anchor:h}),g=new v1(Me.from(b));return{id:await g.id,raw:await g.getRaw()}}let l=Ag(r,t,{tags:a,target:i,anchor:h});return l.sign(t).then(async()=>({id:await l.id,raw:await l.getRaw()}))}:xte(t)}var fUe="-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI";function i3t({owner:t,targetId:e,ttlSeconds:r=3600,keywords:a=[],controllers:i=[],description:h="",ticker:l="aos",name:p="ANT"}){return{ticker:l,name:p,description:h,keywords:a,owner:t,controllers:[t,...i],balances:{[t]:1},records:{"@":{transactionId:e??fUe.toString(),ttlSeconds:r}}}}function rue(t){return Qt.object({startTimestamp:Qt.number(),startHeight:Qt.number(),distributions:Qt.any(),endTimestamp:Qt.number(),prescribedObservers:Qt.any(),prescribedNames:Qt.array(Qt.string()),observations:Qt.any(),distributionTimestamp:Qt.number(),epochIndex:Qt.number()}).parse(t)}function vP(t){let r=t.Error??t.Messages?.[0]?.Tags?.find(a=>a.name==="Error")?.value;if(r!==void 0){let a=r.match(/\[string "aos"]:(\d+):\s*(.+)/);if(a){let[,i,h]=a;return`${tue(h).trim()} (line ${i.trim()})`.trim()}return tue(r)}}function tue(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 iue=t=>L8.test(t);function h3t(t){return t!==void 0&&!isNaN(parseInt(t.toString()))}var Sn=t=>t.filter(e=>e.value!==void 0&&e.value!==""),Ha=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 Sn(e)},Kw=async({arweave:t,epochIndex:e,processId:r=Lh,retries:a=3})=>{let i=uUe({epochIndex:e,processId:r});for(let h=0;h<a;h++)try{let l=await t.api.post("graphql",i);if(l.data?.data?.transactions?.edges?.length===0)return;let p=l.data.data.transactions.edges[0].node.id,b=await t.api.get(p);return rue(b.data)}catch(l){if(h===a-1)throw l;await new Promise(p=>setTimeout(p,Math.pow(2,h)*1e3))}},uUe=({epochIndex:t,processId:e=Lh})=>JSON.stringify({query:`
190
190
  query {
191
191
  transactions(
192
192
  tags: [
@@ -285,6 +285,9 @@ class AoANTWriteable extends AoANTReadable {
285
285
  });
286
286
  }
287
287
  /**
288
+ * Sets the transactionId and ttlSeconds of a record (for updating the top level name, use undername "@".)
289
+ *
290
+ * @deprecated Use setUndernameRecord instead for undernames, and setBaseNameRecord instead for the top level name (e.g. "@")
288
291
  * @param undername @type {string} The record you want to set the transactionId and ttlSeconds of.
289
292
  * @param transactionId @type {string} The transactionId of the record.
290
293
  * @param ttlSeconds @type {number} The time to live of the record.
@@ -307,11 +310,68 @@ class AoANTWriteable extends AoANTReadable {
307
310
  });
308
311
  }
309
312
  /**
313
+ * Sets the top level name of the ANT. This is the name that will be used to resolve the ANT (e.g. ardrive.ar.io)
314
+ *
315
+ * @param transactionId @type {string} The transactionId of the record.
316
+ * @param ttlSeconds @type {number} The time to live of the record.
317
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
318
+ * @example
319
+ * ```ts
320
+ * ant.setBaseNameRecord({ transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients
321
+ * ```
322
+ */
323
+ async setBaseNameRecord({ transactionId, ttlSeconds, }) {
324
+ return this.process.send({
325
+ tags: [
326
+ { name: 'Action', value: 'Set-Record' },
327
+ { name: 'Sub-Domain', value: '@' },
328
+ { name: 'Transaction-Id', value: transactionId },
329
+ { name: 'TTL-Seconds', value: ttlSeconds.toString() },
330
+ ],
331
+ signer: this.signer,
332
+ });
333
+ }
334
+ /**
335
+ * Adds or updates an undername of the ANT. An undername is appended to the base name of the ANT (e.g. ardrive.ar.io) to form a fully qualified name (e.g. dapp_ardrive.ar.io)
336
+ *
337
+ * @param undername @type {string} The undername of the ANT.
338
+ * @param transactionId @type {string} The transactionId of the record.
339
+ * @param ttlSeconds @type {number} The time to live of the record.
340
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
341
+ * @example
342
+ * ```ts
343
+ * ant.setUndernameRecord({ undername: "dapp", transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // dapp_ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients
344
+ * ```
345
+ */
346
+ async setUndernameRecord({ undername, transactionId, ttlSeconds, }) {
347
+ return this.setRecord({
348
+ undername,
349
+ transactionId,
350
+ ttlSeconds,
351
+ });
352
+ }
353
+ /**
354
+ * Removes an undername from the ANT. This will remove the undername from the ANT.
355
+ *
356
+ * @param undername @type {string} The undername you want to remove.
357
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
358
+ * @example
359
+ * ```ts
360
+ * ant.removeUndernameRecord({ undername: "dapp" }); // removes dapp_ardrive.ar.io
361
+ * ```
362
+ */
363
+ async removeUndernameRecord({ undername, }) {
364
+ return this.removeRecord({ undername });
365
+ }
366
+ /**
367
+ * Removes a record from the ANT. This will remove the record from the ANT. If '@' is provided, the top level name will be removed.
368
+ *
369
+ * @deprecated Use removeUndernameRecord instead.
310
370
  * @param undername @type {string} The record you want to remove.
311
371
  * @returns {Promise<AoMessageResult>} The result of the interaction.
312
372
  * @example
313
373
  * ```ts
314
- * ant.removeRecord({ subDomain: "shorts" });
374
+ * ant.removeRecord({ undername: "dapp" }); // removes dapp_ardrive.ar.io
315
375
  * ```
316
376
  */
317
377
  async removeRecord({ undername, }, options) {
@@ -325,6 +385,8 @@ class AoANTWriteable extends AoANTReadable {
325
385
  });
326
386
  }
327
387
  /**
388
+ * Sets the ticker of the ANT. This is the abbreviation displayed in ecosystem apps.
389
+ *
328
390
  * @param ticker @type {string} Sets the ANT Ticker.
329
391
  * @returns {Promise<AoMessageResult>} The result of the interaction.
330
392
  * @example
@@ -343,6 +405,8 @@ class AoANTWriteable extends AoANTReadable {
343
405
  });
344
406
  }
345
407
  /**
408
+ * Sets the name of the ANT. This is the display name of the ANT. This is NOT the base name record.
409
+ *
346
410
  * @param name @type {string} Sets the Name of the ANT.
347
411
  * @returns {Promise<AoMessageResult>} The result of the interaction.
348
412
  * @example
@@ -361,6 +425,8 @@ class AoANTWriteable extends AoANTReadable {
361
425
  });
362
426
  }
363
427
  /**
428
+ * Sets the description of the ANT. This is the description of the ANT displayed in ecosystem apps.
429
+ *
364
430
  * @param description @type {string} Sets the ANT Description.
365
431
  * @returns {Promise<AoMessageResult>} The result of the interaction.
366
432
  * @example
@@ -379,6 +445,8 @@ class AoANTWriteable extends AoANTReadable {
379
445
  });
380
446
  }
381
447
  /**
448
+ * Sets the keywords of the ANT. This is the keywords of the ANT displayed in ecosystem apps.
449
+ *
382
450
  * @param keywords @type {string[]} Sets the ANT Keywords.
383
451
  * @returns {Promise<AoMessageResult>} The result of the interaction.
384
452
  * @example
@@ -397,6 +465,8 @@ class AoANTWriteable extends AoANTReadable {
397
465
  });
398
466
  }
399
467
  /**
468
+ * Sets the logo of the ANT. This is the logo of the ANT displayed in ecosystem apps. Additionally, this logo is displayed for any primary names affiliated with the ANT.
469
+ *
400
470
  * @param txId @type {string} - Arweave transaction id of the logo we want to set
401
471
  * @param options @type {WriteOptions} - additional options to add to the write interaction (optional)
402
472
  * @returns {Promise<AoMessageResult>} The result of the interaction.
@@ -416,6 +486,9 @@ class AoANTWriteable extends AoANTReadable {
416
486
  });
417
487
  }
418
488
  /**
489
+ * Releases an ArNS name associated with the ANT. This will release the name to the public and allow anyone to register it. All primary names must be removed before the name can be released.
490
+ *
491
+ *
419
492
  * @param name @type {string} The name you want to release. The name will be put up for as a recently returned name on the ARIO contract. 50% of the winning bid will be distributed to the ANT owner at the time of purchase. If no purchase in the recently returned name period (14 epochs), the name will be released and can be reregistered by anyone.
420
493
  * @param arioProcessId @type {string} The processId of the ARIO contract. This is where the ANT will send the message to release the name.
421
494
  * @returns {Promise<AoMessageResult>} The result of the interaction.
@@ -437,7 +510,8 @@ class AoANTWriteable extends AoANTReadable {
437
510
  });
438
511
  }
439
512
  /**
440
- * Sends a message to the ARIO contract to reassign the name to a new ANT. This can only be done by the current owner of the ANT.
513
+ * Sends a message to the ARIO contract to reassign the the base ArNS name to a new ANT. This can only be done by the current owner of the ANT.
514
+ *
441
515
  * @param name @type {string} The name you want to reassign.
442
516
  * @param arioProcessId @type {string} The processId of the ARIO contract.
443
517
  * @param antProcessId @type {string} The processId of the ANT contract.
@@ -462,6 +536,15 @@ class AoANTWriteable extends AoANTReadable {
462
536
  }
463
537
  /**
464
538
  * Approves a primary name request for a given name or address.
539
+ *
540
+ * @param name @type {string} The name you want to approve.
541
+ * @param address @type {WalletAddress} The address you want to approve.
542
+ * @param arioProcessId @type {string} The processId of the ARIO contract.
543
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
544
+ * @example
545
+ * ```ts
546
+ * ant.approvePrimaryNameRequest({ name: "ardrive", address: "U7RXcpaVShG4u9nIcPVmm2FJSM5Gru9gQCIiRaIPV7f", arioProcessId: ARIO_TESTNET_PROCESS_ID }); // approves the request for ardrive.ar.io to be registered by the address
547
+ * ```
465
548
  */
466
549
  async approvePrimaryNameRequest({ name, address, arioProcessId, }, options) {
467
550
  return this.process.send({
@@ -476,6 +559,18 @@ class AoANTWriteable extends AoANTReadable {
476
559
  signer: this.signer,
477
560
  });
478
561
  }
562
+ /**
563
+ * Removes primary names from the ANT. This will remove the primary names associated with the base ArNS name controlled by this ANT. All primary names must be removed before the name can be released.
564
+ *
565
+ * @param names @type {string[]} The names you want to remove.
566
+ * @param arioProcessId @type {string} The processId of the ARIO contract.
567
+ * @param notifyOwners @type {boolean} Whether to notify the owners of the primary names.
568
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
569
+ * @example
570
+ * ```ts
571
+ * ant.removePrimaryNames({ names: ["ardrive", "dapp_ardrive"], arioProcessId: ARIO_TESTNET_PROCESS_ID, notifyOwners: true }); // removes the primary names and associated wallet addresses assigned to "ardrive" and "dapp_ardrive"
572
+ * ```
573
+ */
479
574
  async removePrimaryNames({ names, arioProcessId, notifyOwners = false, }, options) {
480
575
  return this.process.send({
481
576
  tags: [
@@ -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.4.0-alpha.1';
20
+ exports.version = '3.4.0-alpha.2';
@@ -280,6 +280,9 @@ export class AoANTWriteable extends AoANTReadable {
280
280
  });
281
281
  }
282
282
  /**
283
+ * Sets the transactionId and ttlSeconds of a record (for updating the top level name, use undername "@".)
284
+ *
285
+ * @deprecated Use setUndernameRecord instead for undernames, and setBaseNameRecord instead for the top level name (e.g. "@")
283
286
  * @param undername @type {string} The record you want to set the transactionId and ttlSeconds of.
284
287
  * @param transactionId @type {string} The transactionId of the record.
285
288
  * @param ttlSeconds @type {number} The time to live of the record.
@@ -302,11 +305,68 @@ export class AoANTWriteable extends AoANTReadable {
302
305
  });
303
306
  }
304
307
  /**
308
+ * Sets the top level name of the ANT. This is the name that will be used to resolve the ANT (e.g. ardrive.ar.io)
309
+ *
310
+ * @param transactionId @type {string} The transactionId of the record.
311
+ * @param ttlSeconds @type {number} The time to live of the record.
312
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
313
+ * @example
314
+ * ```ts
315
+ * ant.setBaseNameRecord({ transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients
316
+ * ```
317
+ */
318
+ async setBaseNameRecord({ transactionId, ttlSeconds, }) {
319
+ return this.process.send({
320
+ tags: [
321
+ { name: 'Action', value: 'Set-Record' },
322
+ { name: 'Sub-Domain', value: '@' },
323
+ { name: 'Transaction-Id', value: transactionId },
324
+ { name: 'TTL-Seconds', value: ttlSeconds.toString() },
325
+ ],
326
+ signer: this.signer,
327
+ });
328
+ }
329
+ /**
330
+ * Adds or updates an undername of the ANT. An undername is appended to the base name of the ANT (e.g. ardrive.ar.io) to form a fully qualified name (e.g. dapp_ardrive.ar.io)
331
+ *
332
+ * @param undername @type {string} The undername of the ANT.
333
+ * @param transactionId @type {string} The transactionId of the record.
334
+ * @param ttlSeconds @type {number} The time to live of the record.
335
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
336
+ * @example
337
+ * ```ts
338
+ * ant.setUndernameRecord({ undername: "dapp", transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // dapp_ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients
339
+ * ```
340
+ */
341
+ async setUndernameRecord({ undername, transactionId, ttlSeconds, }) {
342
+ return this.setRecord({
343
+ undername,
344
+ transactionId,
345
+ ttlSeconds,
346
+ });
347
+ }
348
+ /**
349
+ * Removes an undername from the ANT. This will remove the undername from the ANT.
350
+ *
351
+ * @param undername @type {string} The undername you want to remove.
352
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
353
+ * @example
354
+ * ```ts
355
+ * ant.removeUndernameRecord({ undername: "dapp" }); // removes dapp_ardrive.ar.io
356
+ * ```
357
+ */
358
+ async removeUndernameRecord({ undername, }) {
359
+ return this.removeRecord({ undername });
360
+ }
361
+ /**
362
+ * Removes a record from the ANT. This will remove the record from the ANT. If '@' is provided, the top level name will be removed.
363
+ *
364
+ * @deprecated Use removeUndernameRecord instead.
305
365
  * @param undername @type {string} The record you want to remove.
306
366
  * @returns {Promise<AoMessageResult>} The result of the interaction.
307
367
  * @example
308
368
  * ```ts
309
- * ant.removeRecord({ subDomain: "shorts" });
369
+ * ant.removeRecord({ undername: "dapp" }); // removes dapp_ardrive.ar.io
310
370
  * ```
311
371
  */
312
372
  async removeRecord({ undername, }, options) {
@@ -320,6 +380,8 @@ export class AoANTWriteable extends AoANTReadable {
320
380
  });
321
381
  }
322
382
  /**
383
+ * Sets the ticker of the ANT. This is the abbreviation displayed in ecosystem apps.
384
+ *
323
385
  * @param ticker @type {string} Sets the ANT Ticker.
324
386
  * @returns {Promise<AoMessageResult>} The result of the interaction.
325
387
  * @example
@@ -338,6 +400,8 @@ export class AoANTWriteable extends AoANTReadable {
338
400
  });
339
401
  }
340
402
  /**
403
+ * Sets the name of the ANT. This is the display name of the ANT. This is NOT the base name record.
404
+ *
341
405
  * @param name @type {string} Sets the Name of the ANT.
342
406
  * @returns {Promise<AoMessageResult>} The result of the interaction.
343
407
  * @example
@@ -356,6 +420,8 @@ export class AoANTWriteable extends AoANTReadable {
356
420
  });
357
421
  }
358
422
  /**
423
+ * Sets the description of the ANT. This is the description of the ANT displayed in ecosystem apps.
424
+ *
359
425
  * @param description @type {string} Sets the ANT Description.
360
426
  * @returns {Promise<AoMessageResult>} The result of the interaction.
361
427
  * @example
@@ -374,6 +440,8 @@ export class AoANTWriteable extends AoANTReadable {
374
440
  });
375
441
  }
376
442
  /**
443
+ * Sets the keywords of the ANT. This is the keywords of the ANT displayed in ecosystem apps.
444
+ *
377
445
  * @param keywords @type {string[]} Sets the ANT Keywords.
378
446
  * @returns {Promise<AoMessageResult>} The result of the interaction.
379
447
  * @example
@@ -392,6 +460,8 @@ export class AoANTWriteable extends AoANTReadable {
392
460
  });
393
461
  }
394
462
  /**
463
+ * Sets the logo of the ANT. This is the logo of the ANT displayed in ecosystem apps. Additionally, this logo is displayed for any primary names affiliated with the ANT.
464
+ *
395
465
  * @param txId @type {string} - Arweave transaction id of the logo we want to set
396
466
  * @param options @type {WriteOptions} - additional options to add to the write interaction (optional)
397
467
  * @returns {Promise<AoMessageResult>} The result of the interaction.
@@ -411,6 +481,9 @@ export class AoANTWriteable extends AoANTReadable {
411
481
  });
412
482
  }
413
483
  /**
484
+ * Releases an ArNS name associated with the ANT. This will release the name to the public and allow anyone to register it. All primary names must be removed before the name can be released.
485
+ *
486
+ *
414
487
  * @param name @type {string} The name you want to release. The name will be put up for as a recently returned name on the ARIO contract. 50% of the winning bid will be distributed to the ANT owner at the time of purchase. If no purchase in the recently returned name period (14 epochs), the name will be released and can be reregistered by anyone.
415
488
  * @param arioProcessId @type {string} The processId of the ARIO contract. This is where the ANT will send the message to release the name.
416
489
  * @returns {Promise<AoMessageResult>} The result of the interaction.
@@ -432,7 +505,8 @@ export class AoANTWriteable extends AoANTReadable {
432
505
  });
433
506
  }
434
507
  /**
435
- * Sends a message to the ARIO contract to reassign the name to a new ANT. This can only be done by the current owner of the ANT.
508
+ * Sends a message to the ARIO contract to reassign the the base ArNS name to a new ANT. This can only be done by the current owner of the ANT.
509
+ *
436
510
  * @param name @type {string} The name you want to reassign.
437
511
  * @param arioProcessId @type {string} The processId of the ARIO contract.
438
512
  * @param antProcessId @type {string} The processId of the ANT contract.
@@ -457,6 +531,15 @@ export class AoANTWriteable extends AoANTReadable {
457
531
  }
458
532
  /**
459
533
  * Approves a primary name request for a given name or address.
534
+ *
535
+ * @param name @type {string} The name you want to approve.
536
+ * @param address @type {WalletAddress} The address you want to approve.
537
+ * @param arioProcessId @type {string} The processId of the ARIO contract.
538
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
539
+ * @example
540
+ * ```ts
541
+ * ant.approvePrimaryNameRequest({ name: "ardrive", address: "U7RXcpaVShG4u9nIcPVmm2FJSM5Gru9gQCIiRaIPV7f", arioProcessId: ARIO_TESTNET_PROCESS_ID }); // approves the request for ardrive.ar.io to be registered by the address
542
+ * ```
460
543
  */
461
544
  async approvePrimaryNameRequest({ name, address, arioProcessId, }, options) {
462
545
  return this.process.send({
@@ -471,6 +554,18 @@ export class AoANTWriteable extends AoANTReadable {
471
554
  signer: this.signer,
472
555
  });
473
556
  }
557
+ /**
558
+ * Removes primary names from the ANT. This will remove the primary names associated with the base ArNS name controlled by this ANT. All primary names must be removed before the name can be released.
559
+ *
560
+ * @param names @type {string[]} The names you want to remove.
561
+ * @param arioProcessId @type {string} The processId of the ARIO contract.
562
+ * @param notifyOwners @type {boolean} Whether to notify the owners of the primary names.
563
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
564
+ * @example
565
+ * ```ts
566
+ * ant.removePrimaryNames({ names: ["ardrive", "dapp_ardrive"], arioProcessId: ARIO_TESTNET_PROCESS_ID, notifyOwners: true }); // removes the primary names and associated wallet addresses assigned to "ardrive" and "dapp_ardrive"
567
+ * ```
568
+ */
474
569
  async removePrimaryNames({ names, arioProcessId, notifyOwners = false, }, options) {
475
570
  return this.process.send({
476
571
  tags: [
@@ -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.4.0-alpha.1';
17
+ export const version = '3.4.0-alpha.2';
@@ -147,6 +147,9 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
147
147
  controller: string;
148
148
  }, options?: WriteOptions): Promise<AoMessageResult>;
149
149
  /**
150
+ * Sets the transactionId and ttlSeconds of a record (for updating the top level name, use undername "@".)
151
+ *
152
+ * @deprecated Use setUndernameRecord instead for undernames, and setBaseNameRecord instead for the top level name (e.g. "@")
150
153
  * @param undername @type {string} The record you want to set the transactionId and ttlSeconds of.
151
154
  * @param transactionId @type {string} The transactionId of the record.
152
155
  * @param ttlSeconds @type {number} The time to live of the record.
@@ -162,17 +165,67 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
162
165
  ttlSeconds: number;
163
166
  }, options?: WriteOptions): Promise<AoMessageResult>;
164
167
  /**
168
+ * Sets the top level name of the ANT. This is the name that will be used to resolve the ANT (e.g. ardrive.ar.io)
169
+ *
170
+ * @param transactionId @type {string} The transactionId of the record.
171
+ * @param ttlSeconds @type {number} The time to live of the record.
172
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
173
+ * @example
174
+ * ```ts
175
+ * ant.setBaseNameRecord({ transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients
176
+ * ```
177
+ */
178
+ setBaseNameRecord({ transactionId, ttlSeconds, }: {
179
+ transactionId: string;
180
+ ttlSeconds: number;
181
+ }): Promise<AoMessageResult>;
182
+ /**
183
+ * Adds or updates an undername of the ANT. An undername is appended to the base name of the ANT (e.g. ardrive.ar.io) to form a fully qualified name (e.g. dapp_ardrive.ar.io)
184
+ *
185
+ * @param undername @type {string} The undername of the ANT.
186
+ * @param transactionId @type {string} The transactionId of the record.
187
+ * @param ttlSeconds @type {number} The time to live of the record.
188
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
189
+ * @example
190
+ * ```ts
191
+ * ant.setUndernameRecord({ undername: "dapp", transactionId: "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM", ttlSeconds: 100 }); // dapp_ardrive.ar.io will resolve to the provided transaction id and be cached for 100 seconds by clients
192
+ * ```
193
+ */
194
+ setUndernameRecord({ undername, transactionId, ttlSeconds, }: {
195
+ undername: string;
196
+ transactionId: string;
197
+ ttlSeconds: number;
198
+ }): Promise<AoMessageResult>;
199
+ /**
200
+ * Removes an undername from the ANT. This will remove the undername from the ANT.
201
+ *
202
+ * @param undername @type {string} The undername you want to remove.
203
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
204
+ * @example
205
+ * ```ts
206
+ * ant.removeUndernameRecord({ undername: "dapp" }); // removes dapp_ardrive.ar.io
207
+ * ```
208
+ */
209
+ removeUndernameRecord({ undername, }: {
210
+ undername: string;
211
+ }): Promise<AoMessageResult>;
212
+ /**
213
+ * Removes a record from the ANT. This will remove the record from the ANT. If '@' is provided, the top level name will be removed.
214
+ *
215
+ * @deprecated Use removeUndernameRecord instead.
165
216
  * @param undername @type {string} The record you want to remove.
166
217
  * @returns {Promise<AoMessageResult>} The result of the interaction.
167
218
  * @example
168
219
  * ```ts
169
- * ant.removeRecord({ subDomain: "shorts" });
220
+ * ant.removeRecord({ undername: "dapp" }); // removes dapp_ardrive.ar.io
170
221
  * ```
171
222
  */
172
223
  removeRecord({ undername, }: {
173
224
  undername: string;
174
225
  }, options?: WriteOptions): Promise<AoMessageResult>;
175
226
  /**
227
+ * Sets the ticker of the ANT. This is the abbreviation displayed in ecosystem apps.
228
+ *
176
229
  * @param ticker @type {string} Sets the ANT Ticker.
177
230
  * @returns {Promise<AoMessageResult>} The result of the interaction.
178
231
  * @example
@@ -184,6 +237,8 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
184
237
  ticker: string;
185
238
  }, options?: WriteOptions): Promise<AoMessageResult>;
186
239
  /**
240
+ * Sets the name of the ANT. This is the display name of the ANT. This is NOT the base name record.
241
+ *
187
242
  * @param name @type {string} Sets the Name of the ANT.
188
243
  * @returns {Promise<AoMessageResult>} The result of the interaction.
189
244
  * @example
@@ -195,6 +250,8 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
195
250
  name: string;
196
251
  }, options?: WriteOptions): Promise<AoMessageResult>;
197
252
  /**
253
+ * Sets the description of the ANT. This is the description of the ANT displayed in ecosystem apps.
254
+ *
198
255
  * @param description @type {string} Sets the ANT Description.
199
256
  * @returns {Promise<AoMessageResult>} The result of the interaction.
200
257
  * @example
@@ -206,6 +263,8 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
206
263
  description: string;
207
264
  }, options?: WriteOptions): Promise<AoMessageResult>;
208
265
  /**
266
+ * Sets the keywords of the ANT. This is the keywords of the ANT displayed in ecosystem apps.
267
+ *
209
268
  * @param keywords @type {string[]} Sets the ANT Keywords.
210
269
  * @returns {Promise<AoMessageResult>} The result of the interaction.
211
270
  * @example
@@ -217,6 +276,8 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
217
276
  keywords: string[];
218
277
  }, options?: WriteOptions): Promise<AoMessageResult>;
219
278
  /**
279
+ * Sets the logo of the ANT. This is the logo of the ANT displayed in ecosystem apps. Additionally, this logo is displayed for any primary names affiliated with the ANT.
280
+ *
220
281
  * @param txId @type {string} - Arweave transaction id of the logo we want to set
221
282
  * @param options @type {WriteOptions} - additional options to add to the write interaction (optional)
222
283
  * @returns {Promise<AoMessageResult>} The result of the interaction.
@@ -229,6 +290,9 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
229
290
  txId: string;
230
291
  }, options?: WriteOptions): Promise<AoMessageResult>;
231
292
  /**
293
+ * Releases an ArNS name associated with the ANT. This will release the name to the public and allow anyone to register it. All primary names must be removed before the name can be released.
294
+ *
295
+ *
232
296
  * @param name @type {string} The name you want to release. The name will be put up for as a recently returned name on the ARIO contract. 50% of the winning bid will be distributed to the ANT owner at the time of purchase. If no purchase in the recently returned name period (14 epochs), the name will be released and can be reregistered by anyone.
233
297
  * @param arioProcessId @type {string} The processId of the ARIO contract. This is where the ANT will send the message to release the name.
234
298
  * @returns {Promise<AoMessageResult>} The result of the interaction.
@@ -242,7 +306,8 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
242
306
  arioProcessId: string;
243
307
  }, options?: WriteOptions): Promise<AoMessageResult>;
244
308
  /**
245
- * Sends a message to the ARIO contract to reassign the name to a new ANT. This can only be done by the current owner of the ANT.
309
+ * Sends a message to the ARIO contract to reassign the the base ArNS name to a new ANT. This can only be done by the current owner of the ANT.
310
+ *
246
311
  * @param name @type {string} The name you want to reassign.
247
312
  * @param arioProcessId @type {string} The processId of the ARIO contract.
248
313
  * @param antProcessId @type {string} The processId of the ANT contract.
@@ -259,12 +324,33 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
259
324
  }, options?: WriteOptions): Promise<AoMessageResult>;
260
325
  /**
261
326
  * Approves a primary name request for a given name or address.
327
+ *
328
+ * @param name @type {string} The name you want to approve.
329
+ * @param address @type {WalletAddress} The address you want to approve.
330
+ * @param arioProcessId @type {string} The processId of the ARIO contract.
331
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
332
+ * @example
333
+ * ```ts
334
+ * ant.approvePrimaryNameRequest({ name: "ardrive", address: "U7RXcpaVShG4u9nIcPVmm2FJSM5Gru9gQCIiRaIPV7f", arioProcessId: ARIO_TESTNET_PROCESS_ID }); // approves the request for ardrive.ar.io to be registered by the address
335
+ * ```
262
336
  */
263
337
  approvePrimaryNameRequest({ name, address, arioProcessId, }: {
264
338
  name: string;
265
339
  address: WalletAddress;
266
340
  arioProcessId: string;
267
341
  }, options?: WriteOptions): Promise<AoMessageResult>;
342
+ /**
343
+ * Removes primary names from the ANT. This will remove the primary names associated with the base ArNS name controlled by this ANT. All primary names must be removed before the name can be released.
344
+ *
345
+ * @param names @type {string[]} The names you want to remove.
346
+ * @param arioProcessId @type {string} The processId of the ARIO contract.
347
+ * @param notifyOwners @type {boolean} Whether to notify the owners of the primary names.
348
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
349
+ * @example
350
+ * ```ts
351
+ * ant.removePrimaryNames({ names: ["ardrive", "dapp_ardrive"], arioProcessId: ARIO_TESTNET_PROCESS_ID, notifyOwners: true }); // removes the primary names and associated wallet addresses assigned to "ardrive" and "dapp_ardrive"
352
+ * ```
353
+ */
268
354
  removePrimaryNames({ names, arioProcessId, notifyOwners, }: {
269
355
  names: string[];
270
356
  arioProcessId: string;
@@ -196,6 +196,18 @@ export interface AoANTWrite extends AoANTRead {
196
196
  removeRecord({ undername }: {
197
197
  undername: string;
198
198
  }, options?: WriteOptions): Promise<AoMessageResult>;
199
+ setBaseNameRecord({ transactionId, ttlSeconds, }: {
200
+ transactionId: string;
201
+ ttlSeconds: number;
202
+ }): Promise<AoMessageResult>;
203
+ setUndernameRecord({ undername, transactionId, ttlSeconds, }: {
204
+ undername: string;
205
+ transactionId: string;
206
+ ttlSeconds: number;
207
+ }): Promise<AoMessageResult>;
208
+ removeUndernameRecord({ undername, }: {
209
+ undername: string;
210
+ }): Promise<AoMessageResult>;
199
211
  setTicker({ ticker }: {
200
212
  ticker: string;
201
213
  }, options?: WriteOptions): Promise<AoMessageResult>;
@@ -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.3.1-alpha.4";
16
+ export declare const version = "3.4.0-alpha.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.4.0-alpha.1",
3
+ "version": "3.4.0-alpha.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"