@ar.io/sdk 3.11.1-alpha.1 → 3.12.0-alpha.1

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.
@@ -277,12 +277,12 @@ nonce: bundlr`),Zt.from(c))}},Mgt=class{_publicKey;ownerLength=Po[Qn.MULTIAPTOS]
277
277
  }
278
278
  }`,e=lr.object({data:lr.object({transactions:lr.object({edges:lr.array(lr.object({node:lr.record(lr.any())}))})})});return p=>ji(p).chain(Ta(d=>n(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:c,variables:{transactionIds:[d]}})}).then(async b=>{if(b.ok)return b.json();throw o('Error Encountered when querying gateway for transaction "%s"',d),new Error(`${b.status}: ${await b.text()}`)}).then(e.parse).then(XVe(["data","transactions","edges","0","node"])))).toPromise()}var hTr=un(kqe(),1),AXt=({fetch:n,locate:i})=>async({processId:o,from:c,to:e,limit:p})=>{let d=(await i(o)).url;return n(`${d}/${o}?from=${c}&to=${e}&limit=${p}`).then(b=>b.json())},RXt=({fetch:n,locate:i})=>async({processId:o,messageId:c})=>{let e=(await i(o)).url;return n(`${e}/${c}?process-id=${o}`).then(p=>p.json())},kXt=({fetch:n,locate:i})=>async({processId:o,since:c})=>{c||(c=10*60*1e3);let e=Date.now()-c,p=(await i(o)).url;return n(`${p}/${o}?process-id=${o}&limit=100&from=${e}`).then(d=>d.json()).then(d=>d.edges[d?.edges?.length-1]?.node?.assignment?.tags?.find(b=>b.name==="Nonce")?.value)},$Ye=lr.object({processId:lr.string(),from:lr.string(),to:lr.string(),limit:lr.string().default("1000").optional()}).passthrough();function TXt(n){let i=n.messages;return o=>(o=$Ye.parse(o),i(o))}var qYe=lr.object({processId:lr.string(),messageId:lr.string()}).passthrough();function IXt(n){let i=n.getMessageId;return o=>(o=qYe.parse(o),i(o))}var UYe=lr.object({processId:lr.string(),since:lr.number().optional()}).passthrough();function BXt(n){let i=n.processId;return o=>(o=UYe.parse(o),i(o))}function jYe(n,i){let o=i.match(/boundary="?([^";]+)"?/);if(!o)throw new Error("No boundary found in Content-Type");let c=o[1],e=new RegExp(`--${c}(?:--)?(\\r\\n|\\n)`),p=n.split(e).filter(b=>b!==`\r
279
279
  `),d=new Map;for(let b=0;b<p.length;b+=2){if(!p[b]||p[b].trim()==="")continue;let _=p[b].split(/\r\n|\n/),y={},w=0;for(;w<_.length&&_[w].trim()!=="";){let E=_[w],x=E.indexOf(":");if(x!==-1){let k=E.substring(0,x).trim().toLowerCase(),T=E.substring(x+1).trim();y[k]=T}w++}w++;let M=_.slice(w).join(`
280
- `).trim(),S=(y["content-disposition"]||"").match(/name="([^"]+)"/);if(S){let E=S[1],x=Object.assign({},y,{body:M}),k={};_.slice(w).forEach(T=>{if(T.trim()==="")return;let B=T.indexOf(":");if(B!==-1){let P=T.substring(0,B).trim(),O=T.substring(B+1).trim();k[P]=O}}),Object.keys(k).length>0&&(x.fields=k),d.set(E,x)}}return d}function FYe(n){return i=>ji(i).chain(zYe).chain(HYe(n)).map(WYe(n,i)).map(KYe).bimap(om,am).toPromise()}function zYe(n){let i=lr.object({path:lr.string().min(1,{message:"path is required"}),method:lr.string()}).passthrough();return ji(i.parse(n))}function KYe(n){let i={},o=n;return o.headers.get("content-type")&&o.headers.get("content-type").startsWith("multipart")?i=ZVe(i,Object.fromEntries(jYe(o.body,o.headers.get("content-type")))):i.body=o.body,o.headers.forEach((c,e)=>{i[e]=c}),i}function HYe(n){return Ta(n.request)}function WYe(n,i){return o=>(n.logger('Received response from message sent to path "%s" with res %O',i?.path??"/",o),o)}var ZYe=lr.object({id:lr.string().min(1,{message:"message is required to be a message id"}),processId:lr.string().min(1,{message:"process is required to be a process id"})});function VYe(){return n=>ji(n).map(ZYe.parse).map(()=>n)}var sw=lr.object({name:lr.string(),value:lr.any()}),GYe=lr.function().args(lr.object({Id:lr.string(),Target:lr.string(),Owner:lr.string(),Anchor:lr.string().optional(),Data:lr.any().default("1234"),Tags:lr.array(lr.object({name:lr.string(),value:lr.string()}))})).returns(lr.promise(lr.any())),YYe=lr.function().args(lr.object({id:lr.string().min(1,{message:"message id is required"}),processId:lr.string().min(1,{message:"process id is required"})})).returns(lr.promise(lr.any())),XYe=lr.function().args(lr.object({process:lr.string().min(1,{message:"process id is required"}),from:lr.string().optional(),to:lr.string().optional(),sort:lr.enum(["ASC","DESC"]).default("ASC"),limit:lr.number().optional()})).returns(lr.promise(lr.object({edges:lr.array(lr.object({cursor:lr.string(),node:lr.object({Output:lr.any().optional(),Messages:lr.array(lr.any()).optional(),Spawns:lr.array(lr.any()).optional(),Error:lr.any().optional()})}))}))),pue=lr.function().args(lr.object({processId:lr.string(),data:lr.any(),tags:lr.array(sw),anchor:lr.string().optional(),signer:lr.any().nullish()})).returns(lr.promise(lr.object({messageId:lr.string()}).passthrough())),JYe=lr.function().args(lr.object({processId:lr.string(),data:lr.any(),tags:lr.array(sw),anchor:lr.string().optional(),signer:lr.any().nullish()})).returns(lr.promise(lr.object({id:lr.string(),raw:lr.any()}).passthrough())),QYe=lr.function().args(lr.object({id:lr.string(),raw:lr.any()})).returns(lr.promise(lr.object({messageId:lr.string()}).passthrough())),tXe=lr.function().args(lr.object({data:lr.any(),tags:lr.array(sw),signer:lr.any().nullish()})).returns(lr.promise(lr.object({processId:lr.string()}).passthrough())),eXe=lr.function().args(lr.object({process:lr.string(),message:lr.string(),baseLayer:lr.boolean().optional(),exclude:lr.array(lr.string()).optional()})).returns(lr.promise(lr.object({assignmentId:lr.string()}).passthrough())),mue=pue,uTr=lr.function().args(lr.object({suUrl:lr.string().url(),processId:lr.string()})).returns(lr.promise(lr.object({tags:lr.array(sw)}).passthrough())),lTr=lr.function().args(lr.string()).returns(lr.promise(lr.object({url:lr.string()}))),rXe=lr.function().args(lr.string()).returns(lr.promise(lr.boolean())),iXe=lr.function().args(lr.string()).returns(lr.promise(lr.object({tags:lr.array(sw)}).passthrough())),sA=lr.function();function nXe({loadResult:n}){return n=Ta(YYe.implement(n)),i=>ji({id:i.id,processId:i.processId}).chain(n)}function aXe(n){let i=VYe(n),o=nXe(n);return({message:c,process:e})=>ji({id:c,processId:e}).chain(i).chain(o).map(n.logger.tap('readResult result for message "%s": %O',c)).map(p=>p).bimap(om,am).toPromise()}var d8=(...n)=>i=>n.reduce((o,c)=>c(o),i),Ggt=n=>i=>i??n,oXe=n=>i=>d8(o=>o&&o[i],Ggt(n)),sXe=n=>i=>{let o={};for(let c in i)i.hasOwnProperty(c)&&(o[c]=n(i[c],c,i));return o},fXe=n=>(...i)=>!n(...i),mF=n=>i=>{let o=i.findIndex(e=>e.name==="Data-Protocol"&&e.value===n);if(o===-1)return[0,0];let c=i.findIndex((e,p)=>p>o&&e.name==="Data-Protocol"&&e.value!==n);return c===-1&&(c=i.length),[o,c]},Ygt=n=>{let i=n.findIndex(o=>o.name==="Data-Protocol");return i===-1&&(i=n.length),i},vue=n=>i=>i.name===n,Xgt=(n,i)=>d8(mF(n),([o,c])=>i.slice(o,c))(i),gue=(n,i,o)=>d8(c=>Xgt(n,c),c=>c.filter(vue(i)))(o),hXe=(n,i,o)=>d8(c=>gue(n,i,c),c=>c[0])(o),vF=(n,i)=>(i=i.filter(o=>o.name!=="Data-Protocol"||o.value!==n),i.length?[{name:"Data-Protocol",value:n},...i]:[]),uXe=(n,i,o)=>{let[c,e]=mF(n)(o),[p,d,b]=[o.slice(0,c),o.slice(c,e),o.slice(e)];return d.length||(i=vF(n,i),p=b,b=[]),[p,d,i,b].flat(1)},lXe=(n,i)=>{let o=Ygt(i),[c,e]=[i.slice(0,o),i.slice(o)];return[c,n,e].flat(1)},bue=(n,i,o)=>{let[c,e]=mF(n)(o),[p,d]=[o.slice(0,c),o.slice(e)];return d.length===o.length&&(p=d,d=[]),[p,vF(n,i),d].flat(1)},cXe=(n,i)=>bue(n,[],i),dXe=(n,i,o)=>{let[c,e]=mF(n)(o),[p,d,b]=[o.slice(0,c),o.slice(c,e),o.slice(e)];return[p,vF(n,d.filter(fXe(vue(i)))),b].flat(1)},Jgt=(n,i=!1)=>d8(Ggt([]),o=>o.reduce((c,e)=>d8(oXe([])(e.name),p=>(p.push(e.value),p),p=>(c[e.name]=p,c))(c),{}),sXe(o=>i?o:o[0]))(n),yue=(n,i,o)=>d8(Ggt([]),c=>Xgt(n,c),c=>Jgt(c,o))(i),pXe=(n,i)=>yue(n,i,!0),mXe=(n,i)=>yue(n,i,!1),vXe=n=>{let i=Ygt(n);return Jgt(n.slice(0,i),!1)},gXe=n=>{let i=Ygt(n);return Jgt(n.slice(0,i),!0)},wue=n=>({findAll:i=>Xgt(n,i),findAllByName:(i,o)=>gue(n,i,o),findByName:(i,o)=>hXe(n,i,o),create:i=>vF(n,i),update:(i,o)=>bue(n,i,o),concat:(i,o)=>uXe(n,i,o),removeAll:i=>cXe(n,i),removeAllByName:(i,o)=>dXe(n,i,o),parse:i=>mXe(n,i),parseAll:i=>pXe(n,i),concatUnassoc:lXe,parseUnassoc:vXe,parseAllUnassoc:gXe}),Qgt=wue("ao"),PXt=ow(Qgt.removeAllByName),bXe=ow(Qgt.concat),OXt=ow(Qgt.concatUnassoc),yXe=lr.array(lr.object({name:lr.string(),value:lr.string()}));function _ue(){return n=>ji(n.tags).map(pF([])).map(PXt("Variant")).map(PXt("Type")).map(bXe([{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Message"}])).map(yXe.parse).map(gu("tags",H2,n))}function Mue({logger:n}){return i=>ji(i).chain(Uhe(Che(i.data),()=>o8(i),()=>o8(" ").map(gu("data",H2,i)).map(o=>Ug(u8("tags"),OXt([{name:"Content-Type",value:"text/plain"}]),gu("tags",H2,o))(o)).map(n.tap('added pseudo-random string as message "data"')))).map(o=>Ug(u8("tags"),OXt([{name:"SDK",value:"aoconnect"}]),gu("tags",H2,o))(o))}function wXe(n){let i=_ue(n),o=Mue(n),c=pue.implement(n.deployMessage);return e=>ji(e).chain(i).chain(o).chain(Ta(({id:p,data:d,tags:b,anchor:_,signer:y})=>c({processId:p,data:d,tags:b,anchor:_,signer:sA.implement(y||n.signer)}))).map(p=>gu("messageId",p.messageId,e))}function _Xe(n){let i=_ue(n),o=Mue(n),c=JYe.implement(n.signMessage);return e=>ji(e).chain(i).chain(o).chain(Ta(({id:p,data:d,tags:b,anchor:_,signer:y})=>c({processId:p,data:d,tags:b,anchor:_,signer:sA.implement(y||n.signer)}))).map(p=>p)}function MXe(n){let i=QYe.implement(n.sendSignedMessage);return o=>ji(o).chain(Ta(({id:c,raw:e})=>i({id:c,raw:e}))).map(c=>gu("messageId",c.messageId,o))}function SXe(n){let i=wXe(n);return({process:o,data:c,tags:e,anchor:p,signer:d})=>ji({id:o,data:c,tags:e,anchor:p,signer:d}).chain(i).map(b=>b.messageId).bimap(om,am).toPromise()}function EXe(n){let i=_Xe(n);return({process:o,data:c,tags:e,anchor:p,signer:d})=>ji({id:o,data:c,tags:e,anchor:p,signer:d}).chain(i).map(b=>b).bimap(om,am).toPromise()}function xXe(n){let i=MXe(n);return({id:o,raw:c})=>ji({id:o,raw:c}).chain(i).map(e=>e.messageId).bimap(om,am).toPromise()}var AS=(n,i,o)=>c=>i(c[n])?o8(c):Z2(`Tag '${n}': ${o}`);function AXe({loadTransactionMeta:n,logger:i}){return n=Ta(iXe.implement(n)),o=>ji(o).chain(n).map(u8("tags")).map(dYe).chain(AS("Data-Protocol",SXt("ao"),"value 'ao' was not found on module")).chain(AS("Type",SXt("Module"),"value 'Module' was not found on module")).chain(AS("Module-Format",Pst,"was not found on module")).chain(AS("Input-Encoding",Pst,"was not found on module")).chain(AS("Output-Encoding",Pst,"was not found on module")).bimap(i.tap("Verifying module source failed: %s"),i.tap("Verified module source"))}function RXe({logger:n,validateScheduler:i}){return i=Ta(rXe.implement(i)),o=>ji(o).chain(c=>i(c).chain(e=>e?o8(c):Z2(`Valid Scheduler-Location owned by ${c} not found`))).bimap(n.tap("Verifying scheduler failed: %s"),n.tap("Verified scheduler"))}function kXe({logger:n}){return i=>ji(i).map(n.tap("Checking for signer")).chain(o=>o?o8(o):Z2("signer not found"))}function TXe(n){let i=n.logger.child("verifyInput");n={...n,logger:i};let o=AXe(n),c=RXe(n),e=kXe(n);return p=>ji(p).chain(d=>o(d.module).map(()=>d)).bimap(i.tap("Error when verify input: %s"),i.tap("Successfully verified inputs"))}var tbt=wue("ao"),gO=ow(tbt.removeAllByName),IXe=ow(tbt.concat),NXt=ow(tbt.concatUnassoc),BXe=lr.array(sw);function PXe(){return n=>ji(n).map(u8("tags")).map(pF([])).map(gO("Variant")).map(gO("Type")).map(gO("Module")).map(gO("Scheduler")).map(IXe([{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Process"},{name:"Module",value:n.module},{name:"Scheduler",value:n.scheduler}])).map(BXe.parse).map(gu("tags",H2,n))}function OXe({logger:n}){return i=>ji(i).chain(Uhe(Che(i.data),()=>o8(i),()=>o8(" ").map(gu("data",H2,i)).map(o=>Ug(u8("tags"),NXt([{name:"Content-Type",value:"text/plain"}]),gu("tags",H2,o))(o)).map(n.tap('added pseudo-random string as process "data"')))).map(o=>Ug(u8("tags"),NXt([{name:"SDK",value:"aoconnect"}]),gu("tags",H2,o))(o))}function NXe(n){let i=n.logger.child("uploadProcess");n={...n,logger:i};let o=PXe(n),c=OXe(n),e=tXe.implement(n.deployProcess);return p=>ji(p).chain(o).chain(c).chain(Ta(({data:d,tags:b,signer:_})=>e({data:d,tags:b,signer:sA.implement(_||n.signer)}))).map(d=>gu("processId",d.processId,p))}function CXe(n){let i=TXe(n),o=NXe(n);return({module:c,scheduler:e,signer:p,tags:d,data:b})=>ji({module:c,scheduler:e,signer:p,tags:d,data:b}).chain(i).chain(o).map(_=>_.processId).bimap(om,am).toPromise()}function LXe(n){let i=mue.implement(n.deployMonitor);return o=>ji(o).chain(Ta(({id:c,signer:e})=>i({processId:c,signer:sA.implement(e||n.signer),data:" ",tags:[]}))).map(c=>gu("monitorId",c.messageId,o))}function DXe(n){let i=LXe(n);return({process:o,signer:c})=>ji({id:o,signer:c}).chain(i).map(e=>e.monitorId).bimap(om,am).toPromise()}function $Xe(n){let i=mue.implement(n.deployUnmonitor);return o=>ji(o).chain(Ta(({id:c,signer:e})=>i({processId:c,signer:sA.implement(e||n.signer),data:" ",tags:[]}))).map(c=>gu("monitorId",c.messageId,o))}function qXe(n){let i=$Xe(n);return({process:o,signer:c})=>ji({id:o,signer:c}).chain(i).map(e=>e.monitorId).bimap(om,am).toPromise()}var UXe=lr.object({process:lr.string().min(1,{message:"process identifier is required"}),from:lr.string().optional(),to:lr.string().optional(),sort:lr.enum(["ASC","DESC"]).default("ASC"),limit:lr.number().optional()});function jXe(){return n=>ji(n).map(UXe.parse).map(()=>n)}function FXe({queryResults:n}){return n=Ta(XYe.implement(n)),i=>ji({process:i.process,from:i.from,to:i.to,sort:i.sort,limit:i.limit}).chain(n)}function zXe(n){let i=jXe(n),o=FXe(n);return({process:c,from:e,to:p,sort:d,limit:b})=>ji({process:c,from:e,to:p,sort:d,limit:b}).chain(i).chain(o).map(n.logger.tap('readResults result for message "%s": %O',c)).map(_=>_).bimap(om,am).toPromise()}var KXe=lr.object({Id:lr.string(),Target:lr.string(),Owner:lr.string(),Anchor:lr.string().optional(),Data:lr.any().default("1234"),Tags:lr.array(lr.object({name:lr.string(),value:lr.string()}))});function HXe(){return n=>ji(n).map(KXe.parse).map(i=>(i.Tags=i.Tags.concat([{name:"Data-Protocol",value:"ao"},{name:"Type",value:"Message"},{name:"Variant",value:"ao.TN.1"}]),i))}function WXe({dryrunFetch:n}){return Ta(GYe.implement(n))}function ZXe(n){let i=HXe(n),o=WXe(n);return c=>ji(c).map(VXe).chain(i).chain(o).toPromise()}function VXe({process:n,data:i,tags:o,anchor:c,...e}){return{Id:"1234",Owner:"1234",...e,Target:n,Data:i||"1234",Tags:o||[],Anchor:c||"0"}}function GXe(n){let i=eXe.implement(n.deployAssign);return o=>ji(o).chain(Ta(({process:c,message:e,baseLayer:p,exclude:d})=>i({process:c,message:e,baseLayer:p,exclude:d}))).map(c=>gu("assignmentId",c.assignmentId,o))}function YXe(n){let i=GXe(n);return({process:o,message:c,baseLayer:e,exclude:p})=>ji({process:o,message:c,baseLayer:e,exclude:p}).chain(i).map(d=>d.assignmentId).bimap(om,am).toPromise()}var XXe="https://arweave.net",JXe="https://mu.ao-testnet.xyz",QXe="https://cu.ao-testnet.xyz",tJe="http://relay.ao-hb.xyz",eJe="http://cu.s451-comm3-main.xyz",rJe="http://mu.s451-comm3-main.xyz",iJe="relay@1.0",Cst=fetch;function nJe({createDataItemSigner:n,createSigner:i}){let o=fue();function c({MODE:d,GRAPHQL_URL:b,GRAPHQL_MAX_RETRIES:_,GRAPHQL_RETRY_BACKOFF:y,MU_URL:w=JXe,CU_URL:M=QXe,fetch:S=Cst,noLog:E}){let x=o.child("legacy");E||x("Mode Activated \u2139\uFE0F");let{validate:k}=Gse({cacheSize:100,GRAPHQL_URL:b,GRAPHQL_MAX_RETRIES:_,GRAPHQL_RETRY_BACKOFF:y}),T=x.child("result"),B=aXe({loadResult:CYe({fetch:S,CU_URL:M,logger:T}),logger:T}),P=x.child("message"),O=SXe({deployMessage:RYe({fetch:S,MU_URL:w,logger:P}),logger:P}),q=x.child("signMessage"),j=EXe({signMessage:kYe({logger:q}),logger:q}),Y=x.child("sendSignedMessage"),V=xXe({sendSignedMessage:TYe({fetch:S,MU_URL:w,logger:Y}),logger:Y}),K=x.child("spawn"),Q=CXe({loadTransactionMeta:DYe({fetch:S,GRAPHQL_URL:b,logger:K}),validateScheduler:k,deployProcess:IYe({fetch:S,MU_URL:w,logger:K}),logger:K}),h=x.child("monitor"),t=DXe({deployMonitor:BYe({fetch:S,MU_URL:w,logger:h}),logger:h}),r=x.child("unmonitor"),s=qXe({deployUnmonitor:PYe({fetch:S,MU_URL:w,logger:r}),logger:h}),u=x.child("results"),l=zXe({queryResults:LYe({fetch:S,CU_URL:M,logger:u}),logger:u}),v=x.child("dryrun"),m=ZXe({dryrunFetch:NYe({fetch:S,CU_URL:M,logger:v}),logger:v}),f=x.child("assign"),a=YXe({deployAssign:OYe({fetch:S,MU_URL:w,logger:f}),logger:P}),g=IXt({getMessageId:RXt({fetch:S,locate:G5})}),A=TXt({messages:AXt({fetch:S,locate:G5})}),R=BXt({processId:kXt({fetch:S,locate:G5})});return{MODE:d,result:B,results:l,message:O,spawn:Q,monitor:t,unmonitor:s,dryrun:m,assign:a,createDataItemSigner:n,signMessage:j,sendSignedMessage:V,getMessages:A,getLastSlot:R,getMessageById:g}}function e({MODE:d,signer:b,GRAPHQL_URL:_,device:y=iJe,URL:w=tJe,MU_URL:M=rJe,CU_URL:S=eJe,fetch:E=Cst}){let x=o.child("mainnet-process");if(x("Mode Activated %s","\u{1F432}"),!b)throw new Error("mainnet mode requires providing a signer to connect()");let k=b?()=>b:n,T=b?()=>b:i,B=IXt({getMessageId:RXt({fetch:E,locate:G5})}),P=TXt({messages:AXt({fetch:E,locate:G5})}),O=BXt({processId:kXt({fetch:E,locate:G5})}),q=x.child("request");return{MODE:"mainnet",request:FYe({signer:b,logger:q,MODE:d,method:"GET",request:hue({fetch:Cst,logger:q,HB_URL:w,signer:b})}),createSigner:T,createDataItemSigner:k,getMessages:P,getLastSlot:O,getMessageById:B}}function p(d={}){let{GRAPHQL_URL:b,GATEWAY_URL:_=XXe,...y}=d;b||(b=gj({url:_,path:"/graphql"}));let w=d.MODE||"legacy";if(w==="legacy")return c({...y,GRAPHQL_URL:b});if(w==="mainnet")return e({...y,GRAPHQL_URL:b});throw new Error(`Unrecognized MODE: ${w}`)}return p}var $x={};p8($x,{createDataItemSigner:()=>sJe,createSigner:()=>Sue});var ebt=un(_1(),1);globalThis.Buffer||(globalThis.Buffer=ebt.Buffer);function aJe(n){return async i=>n.connect(["SIGN_TRANSACTION"]).then(async()=>{let{data:o,tags:c,target:e,anchor:p}=await i({alg:"rsa-v1_5-sha256",passthrough:!0}),d=await n.signDataItem({data:o,tags:c,target:e,anchor:p});return await hZe(ebt.Buffer.from(d))})}function oJe(n){return async i=>n.connect(["ACCESS_ADDRESS","ACCESS_PUBLIC_KEY","SIGNATURE"]).then(async()=>{let[o,c]=await Promise.all([n.getActivePublicKey(),n.getActiveAddress()]);return{publicKey:o,address:c}}).then(async({publicKey:o,address:c})=>{let e=await i({type:1,publicKey:o,address:c,alg:"rsa-pss-sha512"}),p=await n.signMessage(e,{hashAlgorithm:"SHA-512"});return{signature:ebt.Buffer.from(p),address:c}})}function Sue(n){let i=aJe(n),o=oJe(n);return(c,e)=>{if(e===uue)return i(c);if(e===lue)return o(c);throw new Error(`signer kind unknown "${e}"`)}}var sJe=Sue,fJe=globalThis.GATEWAY_URL||void 0,hJe=globalThis.MU_URL||void 0,uJe=globalThis.CU_URL||void 0,lJe=globalThis.GRAPHQL_URL||void 0,cJe=globalThis.GRAPHQL_MAX_RETRIES||void 0,dJe=globalThis.GRAPHQL_RETRY_BACKOFF||void 0,pJe=globalThis.RELAY_URL||void 0,mJe=globalThis.AO_URL=void 0,sl=nJe({createDataItemSigner:$x.createDataItemSigner,createSigner:$x.createSigner}),Eue=$x.createDataItemSigner,cTr=$x.createSigner,{result:dTr,results:pTr,message:mTr,spawn:vTr,monitor:gTr,unmonitor:bTr,dryrun:yTr,assign:wTr}=sl({MODE:"legacy",GATEWAY_URL:fJe,MU_URL:hJe,CU_URL:uJe,RELAY_URL:pJe,AO_URL:mJe,GRAPHQL_URL:lJe,GRAPHQL_MAX_RETRIES:cJe,GRAPHQL_RETRY_BACKOFF:dJe,noLog:!0});Bt();Ot();Pt();var g0e=va(v0e(),1),xF=g0e.default.init({host:"arweave.net",port:443,protocol:"https"});Bt();Ot();Pt();Bt();Ot();Pt();var x1=class extends Error{constructor(i){super(i),this.name=this.constructor.name}},b0e=class extends x1{},y0e=class extends x1{},w0e=class extends x1{constructor(i,o){super(`Failed request: ${i}: ${o}`)}},_0e=class extends x1{},AF=class extends x1{},M0e=class extends x1{constructor(){super("Invalid signer. Please provide a valid signer to interact with the contract.")}},hm=class extends x1{constructor(){super("Invalid contract configuration")}},S0e=class extends x1{constructor(){super("Invalid process configuration")}},E0e=class extends x1{};Bt();Ot();Pt();var O1=va(N2e(),1);Bt();Ot();Pt();var Pw="3.11.0";var v0=class n{logger;silent=!1;static default=new n;constructor({level:i="info"}={}){i==="none"&&(this.silent=!0),typeof window<"u"?this.logger=console:this.logger=(0,O1.createLogger)({level:i,silent:this.silent,defaultMeta:{name:"ar-io-sdk",version:Pw},format:O1.format.combine(O1.format.timestamp(),O1.format.json()),transports:[new O1.transports.Console({format:O1.format.combine(O1.format.timestamp(),O1.format.json())})]})}info(i,...o){this.silent||this.logger.info(i,...o)}warn(i,...o){this.silent||this.logger.warn(i,...o)}error(i,...o){this.silent||this.logger.error(i,...o)}debug(i,...o){this.silent||this.logger.debug(i,...o)}setLogLevel(i){this.silent=i==="none","silent"in this.logger&&(this.logger.silent=i==="none"),"level"in this.logger&&(this.logger.level=i)}};Bt();Ot();Pt();Bt();Ot();Pt();var C2e=n=>{let i=Object.entries(n).sort(([o,c],[e,p])=>o==="@"?-1:e==="@"?1:"priority"in c&&!("priority"in p)?-1:!("priority"in c)&&"priority"in p?1:c.priority!==void 0&&p.priority!==void 0?c.priority===p.priority?o<e?-1:o>e?1:0:c.priority-p.priority:o<e?-1:o>e?1:0);return Object.fromEntries(i.map(([o,c],e)=>[o,{...c,index:e}]))};Bt();Ot();Pt();function mm(n,i){let o=n.safeParse(i);if(!o.success)throw new Error(JSON.stringify(o.error.format(),null,2));return o}Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();op();var L2e="+",D2e="/",$2e="-",q2e="_",U2e="=";function _cr(n){let i=n.length%4;return i&&(n+=U2e.repeat(4-i)),n.replaceAll($2e,L2e).replaceAll(q2e,D2e)}function Mcr(n){return n.replaceAll(L2e,$2e).replaceAll(D2e,q2e).replaceAll(U2e,"")}function eFr(n){let i=_cr(n);return Zt.from(i,"base64")}function Ow(n){let i=n.toString("base64");return Mcr(i)}function rFr(n){return Ow(Id("sha256").update(Uint8Array.from(n)).digest())}function j2e(n=32){let i=GQ(n);return Array.from(i,o=>o.toString(16).padStart(2,"0")).join("").slice(0,n)}Bt();Ot();Pt();Bt();Ot();Pt();function h8t(n){try{return JSON.parse(n)}catch{return n}}Bt();Ot();Pt();Bt();Ot();Pt();var l8t=va(z2e(),1);Bt();Ot();Pt();var xcr=Object.defineProperty,Acr=(n,i,o)=>i in n?xcr(n,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[i]=o,eR=(n,i,o)=>(Acr(n,typeof i!="symbol"?i+"":i,o),o),c8t=class{constructor(i){eR(this,"value"),eR(this,"next"),this.value=i}},d8t=class{constructor(){eR(this,"head"),eR(this,"tail"),eR(this,"_size",0),this.clear()}clear(){this.head=void 0,this.tail=void 0,this._size=0}push(i){let o=new c8t(i);return this.head&&this.tail?(this.tail.next=o,this.tail=o):(this.head=o,this.tail=o),this._size++,this._size}pop(){if(!this.head)return;let i=this.head;return this.head=this.head.next,this._size--,i.value}get size(){return this._size}*[Symbol.iterator](){let i=this.head;for(;i;)yield i.value,i=i.next}};function K2e(n){if(!((Number.isInteger(n)||n===1/0)&&n>0))throw new TypeError("Expected `concurrency` to be a number greater than 1");let i=new d8t,o=0,c=()=>{o--,i.size>0&&i.pop()()},e=async(b,_,y)=>{o++;let w=(async()=>b(...y))();_(w);try{await w}catch{}c()},p=(b,_,y)=>{i.push(e.bind(null,b,_,y)),(async()=>(await Promise.resolve(),o<n&&i.size>0&&i.pop()()))()},d=(b,..._)=>new Promise(y=>{p(b,y,_)});return Object.defineProperties(d,{activeCount:{get:()=>o},pendingCount:{get:()=>i.size},clearQueue:{value:()=>{i.clear()}}}),d}Bt();Ot();Pt();var rR=class{static init(i){return i!==void 0&&"signer"in i?new p8t(i):new Cz(i)}},Cz=class{process;constructor(i){if(i===void 0||Object.keys(i).length===0)this.process=new cs({processId:E5});else if(ob(i))this.process=i.process;else if(sb(i))this.process=new cs({processId:i.processId});else throw new hm}async accessControlList({address:i}){return this.process.read({tags:[{name:"Action",value:"Access-Control-List"},{name:"Address",value:i}]})}},p8t=class extends Cz{signer;constructor({signer:i,...o}){super(o),this.signer=ab(i)}async register({processId:i}){return this.process.send({tags:[{name:"Action",value:"Register"},{name:"Process-Id",value:i}],signer:this.signer})}};Bt();Ot();Pt();Bt();Ot();Pt();var Rcr="https://faucet.ario.permaweb.services";function v8t({arioInstance:n,faucetApiUrl:i=Rcr}){let o=new m8t({faucetUrl:i,processId:n.process.processId});return new Proxy(n,{get(e,p){if(p==="faucet")return o;if(p in e){let d=e[p];return typeof d=="function"?d.bind(e):d}}})}var m8t=class{faucetUrl;processId;constructor({faucetUrl:i,processId:o}){this.faucetUrl=i,this.processId=o}async captchaUrl(){let i=await fetch(`${this.faucetUrl}/api/captcha/url?process-id=${this.processId}`,{method:"GET"});if(!i.ok){let c=await i.json().catch(()=>({error:i.statusText}));throw new Error(c.error)}return await i.json()}async claimWithCaptchaResponse({captchaResponse:i,recipient:o,quantity:c}){let e=await fetch(`${this.faucetUrl}/api/claim/sync`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processId:this.processId,recipient:o,quantity:c,captchaResponse:i})});if(!e.ok){let d=await e.json().catch(()=>({error:e.statusText}));throw new Error(d.error)}return await e.json()}async requestAuthToken({captchaResponse:i}){let o=await fetch(`${this.faucetUrl}/api/captcha/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processId:this.processId,captchaResponse:i})});if(!o.ok){let e=await o.json().catch(()=>({error:o.statusText}));throw new Error(e.error)}return await o.json()}async claimWithAuthToken({authToken:i,recipient:o,quantity:c}){let e=await fetch(`${this.faucetUrl}/api/claim/async`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({recipient:o,qty:c,processId:this.processId})});if(!e.ok){let d=await e.json().catch(()=>({error:e.statusText}));throw new Error(d.error)}return await e.json()}async verifyAuthToken({authToken:i}){let o=await fetch(`${this.faucetUrl}/api/token/verify?process-id=${this.processId}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`}});if(!o.ok){let e=await o.json().catch(()=>({error:o.statusText}));throw new Error(e.error)}return await o.json()}};Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();var Sh=[];for(Lz=0;Lz<256;++Lz)Sh.push((Lz+256).toString(16).slice(1));var Lz;function H2e(n,i=0){return(Sh[n[i+0]]+Sh[n[i+1]]+Sh[n[i+2]]+Sh[n[i+3]]+"-"+Sh[n[i+4]]+Sh[n[i+5]]+"-"+Sh[n[i+6]]+Sh[n[i+7]]+"-"+Sh[n[i+8]]+Sh[n[i+9]]+"-"+Sh[n[i+10]]+Sh[n[i+11]]+Sh[n[i+12]]+Sh[n[i+13]]+Sh[n[i+14]]+Sh[n[i+15]]).toLowerCase()}Bt();Ot();Pt();var Dz,kcr=new Uint8Array(16);function g8t(){if(!Dz&&(Dz=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Dz))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Dz(kcr)}Bt();Ot();Pt();Bt();Ot();Pt();var Tcr=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),b8t={randomUUID:Tcr};function Icr(n,i,o){if(b8t.randomUUID&&!i&&!n)return b8t.randomUUID();n=n||{};var c=n.random||(n.rng||g8t)();if(c[6]=c[6]&15|64,c[8]=c[8]&63|128,i){o=o||0;for(var e=0;e<16;++e)i[o+e]=c[e];return i}return H2e(c)}var y8t=Icr;Bt();Ot();Pt();var w8t=class n{constructor(i){this.positiveFiniteInteger=i;if(!Number.isFinite(this.positiveFiniteInteger)||!Number.isInteger(this.positiveFiniteInteger)||this.positiveFiniteInteger<0)throw new Error(`Number must be a non-negative integer value! ${i}`)}[Symbol.toPrimitive](i){return i==="string"&&this.toString(),this.positiveFiniteInteger}plus(i){return new n(this.positiveFiniteInteger+i.positiveFiniteInteger)}minus(i){return new n(this.positiveFiniteInteger-i.positiveFiniteInteger)}isGreaterThan(i){return this.positiveFiniteInteger>i.positiveFiniteInteger}isGreaterThanOrEqualTo(i){return this.positiveFiniteInteger>=i.positiveFiniteInteger}isLessThan(i){return this.positiveFiniteInteger<i.positiveFiniteInteger}isLessThanOrEqualTo(i){return this.positiveFiniteInteger<=i.positiveFiniteInteger}toString(){return`${this.positiveFiniteInteger}`}valueOf(){return this.positiveFiniteInteger}toJSON(){return this.positiveFiniteInteger}equals(i){return this.positiveFiniteInteger===i.positiveFiniteInteger}},_8t=class{value;constructor(i){if(!Number.isFinite(i)||i<0)throw new Error("ARIOToken must be a non-negative finite number");this.value=+i.toFixed(6)}valueOf(){return this.value}toMARIO(){return new iR(Math.floor(this.value*lnt))}toString(){return`${this.value}`}},iR=class n extends w8t{constructor(i){super(i)}multiply(i){let o=Math.floor(this.valueOf()*i.valueOf());return new n(o)}divide(i){if(i.valueOf()===0)throw new Error("Cannot divide by zero");let o=Math.floor(this.valueOf()/i.valueOf());return new n(o)}plus(i){let o=super.plus(i);return new n(o.valueOf())}minus(i){let o=super.minus(i);return new n(o.valueOf())}toARIO(){return new _8t(this.valueOf()/lnt)}};Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();function nR(n,i){return function(){return n.apply(i,arguments)}}var{toString:Bcr}=Object.prototype,{getPrototypeOf:S8t}=Object,qz=(n=>i=>{let o=Bcr.call(i);return n[o]||(n[o]=o.slice(8,-1).toLowerCase())})(Object.create(null)),N1=n=>(n=n.toLowerCase(),i=>qz(i)===n),Uz=n=>i=>typeof i===n,{isArray:Nw}=Array,aR=Uz("undefined");function Pcr(n){return n!==null&&!aR(n)&&n.constructor!==null&&!aR(n.constructor)&&pl(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}var Z2e=N1("ArrayBuffer");function Ocr(n){let i;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?i=ArrayBuffer.isView(n):i=n&&n.buffer&&Z2e(n.buffer),i}var Ncr=Uz("string"),pl=Uz("function"),V2e=Uz("number"),jz=n=>n!==null&&typeof n=="object",Ccr=n=>n===!0||n===!1,$z=n=>{if(qz(n)!=="object")return!1;let i=S8t(n);return(i===null||i===Object.prototype||Object.getPrototypeOf(i)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)},Lcr=N1("Date"),Dcr=N1("File"),$cr=N1("Blob"),qcr=N1("FileList"),Ucr=n=>jz(n)&&pl(n.pipe),jcr=n=>{let i;return n&&(typeof FormData=="function"&&n instanceof FormData||pl(n.append)&&((i=qz(n))==="formdata"||i==="object"&&pl(n.toString)&&n.toString()==="[object FormData]"))},Fcr=N1("URLSearchParams"),[zcr,Kcr,Hcr,Wcr]=["ReadableStream","Request","Response","Headers"].map(N1),Zcr=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function oR(n,i,{allOwnKeys:o=!1}={}){if(n===null||typeof n>"u")return;let c,e;if(typeof n!="object"&&(n=[n]),Nw(n))for(c=0,e=n.length;c<e;c++)i.call(null,n[c],c,n);else{let p=o?Object.getOwnPropertyNames(n):Object.keys(n),d=p.length,b;for(c=0;c<d;c++)b=p[c],i.call(null,n[b],b,n)}}function G2e(n,i){i=i.toLowerCase();let o=Object.keys(n),c=o.length,e;for(;c-- >0;)if(e=o[c],i===e.toLowerCase())return e;return null}var N8=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Y2e=n=>!aR(n)&&n!==N8;function M8t(){let{caseless:n}=Y2e(this)&&this||{},i={},o=(c,e)=>{let p=n&&G2e(i,e)||e;$z(i[p])&&$z(c)?i[p]=M8t(i[p],c):$z(c)?i[p]=M8t({},c):Nw(c)?i[p]=c.slice():i[p]=c};for(let c=0,e=arguments.length;c<e;c++)arguments[c]&&oR(arguments[c],o);return i}var Vcr=(n,i,o,{allOwnKeys:c}={})=>(oR(i,(e,p)=>{o&&pl(e)?n[p]=nR(e,o):n[p]=e},{allOwnKeys:c}),n),Gcr=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),Ycr=(n,i,o,c)=>{n.prototype=Object.create(i.prototype,c),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:i.prototype}),o&&Object.assign(n.prototype,o)},Xcr=(n,i,o,c)=>{let e,p,d,b={};if(i=i||{},n==null)return i;do{for(e=Object.getOwnPropertyNames(n),p=e.length;p-- >0;)d=e[p],(!c||c(d,n,i))&&!b[d]&&(i[d]=n[d],b[d]=!0);n=o!==!1&&S8t(n)}while(n&&(!o||o(n,i))&&n!==Object.prototype);return i},Jcr=(n,i,o)=>{n=String(n),(o===void 0||o>n.length)&&(o=n.length),o-=i.length;let c=n.indexOf(i,o);return c!==-1&&c===o},Qcr=n=>{if(!n)return null;if(Nw(n))return n;let i=n.length;if(!V2e(i))return null;let o=new Array(i);for(;i-- >0;)o[i]=n[i];return o},tdr=(n=>i=>n&&i instanceof n)(typeof Uint8Array<"u"&&S8t(Uint8Array)),edr=(n,i)=>{let c=(n&&n[Symbol.iterator]).call(n),e;for(;(e=c.next())&&!e.done;){let p=e.value;i.call(n,p[0],p[1])}},rdr=(n,i)=>{let o,c=[];for(;(o=n.exec(i))!==null;)c.push(o);return c},idr=N1("HTMLFormElement"),ndr=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(o,c,e){return c.toUpperCase()+e}),W2e=(({hasOwnProperty:n})=>(i,o)=>n.call(i,o))(Object.prototype),adr=N1("RegExp"),X2e=(n,i)=>{let o=Object.getOwnPropertyDescriptors(n),c={};oR(o,(e,p)=>{let d;(d=i(e,p,n))!==!1&&(c[p]=d||e)}),Object.defineProperties(n,c)},odr=n=>{X2e(n,(i,o)=>{if(pl(n)&&["arguments","caller","callee"].indexOf(o)!==-1)return!1;let c=n[o];if(pl(c)){if(i.enumerable=!1,"writable"in i){i.writable=!1;return}i.set||(i.set=()=>{throw Error("Can not rewrite read-only method '"+o+"'")})}})},sdr=(n,i)=>{let o={},c=e=>{e.forEach(p=>{o[p]=!0})};return Nw(n)?c(n):c(String(n).split(i)),o},fdr=()=>{},hdr=(n,i)=>n!=null&&Number.isFinite(n=+n)?n:i;function udr(n){return!!(n&&pl(n.append)&&n[Symbol.toStringTag]==="FormData"&&n[Symbol.iterator])}var ldr=n=>{let i=new Array(10),o=(c,e)=>{if(jz(c)){if(i.indexOf(c)>=0)return;if(!("toJSON"in c)){i[e]=c;let p=Nw(c)?[]:{};return oR(c,(d,b)=>{let _=o(d,e+1);!aR(_)&&(p[b]=_)}),i[e]=void 0,p}}return c};return o(n,0)},cdr=N1("AsyncFunction"),ddr=n=>n&&(jz(n)||pl(n))&&pl(n.then)&&pl(n.catch),J2e=((n,i)=>n?setImmediate:i?((o,c)=>(N8.addEventListener("message",({source:e,data:p})=>{e===N8&&p===o&&c.length&&c.shift()()},!1),e=>{c.push(e),N8.postMessage(o,"*")}))(`axios@${Math.random()}`,[]):o=>setTimeout(o))(typeof setImmediate=="function",pl(N8.postMessage)),pdr=typeof queueMicrotask<"u"?queueMicrotask.bind(N8):typeof Yt<"u"&&Yt.nextTick||J2e,ur={isArray:Nw,isArrayBuffer:Z2e,isBuffer:Pcr,isFormData:jcr,isArrayBufferView:Ocr,isString:Ncr,isNumber:V2e,isBoolean:Ccr,isObject:jz,isPlainObject:$z,isReadableStream:zcr,isRequest:Kcr,isResponse:Hcr,isHeaders:Wcr,isUndefined:aR,isDate:Lcr,isFile:Dcr,isBlob:$cr,isRegExp:adr,isFunction:pl,isStream:Ucr,isURLSearchParams:Fcr,isTypedArray:tdr,isFileList:qcr,forEach:oR,merge:M8t,extend:Vcr,trim:Zcr,stripBOM:Gcr,inherits:Ycr,toFlatObject:Xcr,kindOf:qz,kindOfTest:N1,endsWith:Jcr,toArray:Qcr,forEachEntry:edr,matchAll:rdr,isHTMLForm:idr,hasOwnProperty:W2e,hasOwnProp:W2e,reduceDescriptors:X2e,freezeMethods:odr,toObjectSet:sdr,toCamelCase:ndr,noop:fdr,toFiniteNumber:hdr,findKey:G2e,global:N8,isContextDefined:Y2e,isSpecCompliantForm:udr,toJSONObject:ldr,isAsyncFn:cdr,isThenable:ddr,setImmediate:J2e,asap:pdr};Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();function Cw(n,i,o,c,e){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",i&&(this.code=i),o&&(this.config=o),c&&(this.request=c),e&&(this.response=e,this.status=e.status?e.status:null)}ur.inherits(Cw,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ur.toJSONObject(this.config),code:this.code,status:this.status}}});var Q2e=Cw.prototype,tve={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{tve[n]={value:n}});Object.defineProperties(Cw,tve);Object.defineProperty(Q2e,"isAxiosError",{value:!0});Cw.from=(n,i,o,c,e,p)=>{let d=Object.create(Q2e);return ur.toFlatObject(n,d,function(_){return _!==Error.prototype},b=>b!=="isAxiosError"),Cw.call(d,n.message,i,o,c,e),d.cause=n,d.name=n.name,p&&Object.assign(d,p),d};var Ti=Cw;Bt();Ot();Pt();var Fz=null;function E8t(n){return ur.isPlainObject(n)||ur.isArray(n)}function rve(n){return ur.endsWith(n,"[]")?n.slice(0,-2):n}function eve(n,i,o){return n?n.concat(i).map(function(e,p){return e=rve(e),!o&&p?"["+e+"]":e}).join(o?".":""):i}function mdr(n){return ur.isArray(n)&&!n.some(E8t)}var vdr=ur.toFlatObject(ur,{},null,function(i){return/^is[A-Z]/.test(i)});function gdr(n,i,o){if(!ur.isObject(n))throw new TypeError("target must be an object");i=i||new(Fz||FormData),o=ur.toFlatObject(o,{metaTokens:!0,dots:!1,indexes:!1},!1,function(k,T){return!ur.isUndefined(T[k])});let c=o.metaTokens,e=o.visitor||w,p=o.dots,d=o.indexes,_=(o.Blob||typeof Blob<"u"&&Blob)&&ur.isSpecCompliantForm(i);if(!ur.isFunction(e))throw new TypeError("visitor must be a function");function y(x){if(x===null)return"";if(ur.isDate(x))return x.toISOString();if(!_&&ur.isBlob(x))throw new Ti("Blob is not supported. Use a Buffer instead.");return ur.isArrayBuffer(x)||ur.isTypedArray(x)?_&&typeof Blob=="function"?new Blob([x]):Zt.from(x):x}function w(x,k,T){let B=x;if(x&&!T&&typeof x=="object"){if(ur.endsWith(k,"{}"))k=c?k:k.slice(0,-2),x=JSON.stringify(x);else if(ur.isArray(x)&&mdr(x)||(ur.isFileList(x)||ur.endsWith(k,"[]"))&&(B=ur.toArray(x)))return k=rve(k),B.forEach(function(O,q){!(ur.isUndefined(O)||O===null)&&i.append(d===!0?eve([k],q,p):d===null?k:k+"[]",y(O))}),!1}return E8t(x)?!0:(i.append(eve(T,k,p),y(x)),!1)}let M=[],S=Object.assign(vdr,{defaultVisitor:w,convertValue:y,isVisitable:E8t});function E(x,k){if(!ur.isUndefined(x)){if(M.indexOf(x)!==-1)throw Error("Circular reference detected in "+k.join("."));M.push(x),ur.forEach(x,function(B,P){(!(ur.isUndefined(B)||B===null)&&e.call(i,B,ur.isString(P)?P.trim():P,k,S))===!0&&E(B,k?k.concat(P):[P])}),M.pop()}}if(!ur.isObject(n))throw new TypeError("data must be an object");return E(n),i}var fb=gdr;function ive(n){let i={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(c){return i[c]})}function nve(n,i){this._pairs=[],n&&fb(n,this,i)}var ave=nve.prototype;ave.append=function(i,o){this._pairs.push([i,o])};ave.toString=function(i){let o=i?function(c){return i.call(this,c,ive)}:ive;return this._pairs.map(function(e){return o(e[0])+"="+o(e[1])},"").join("&")};var zz=nve;function bdr(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function sR(n,i,o){if(!i)return n;let c=o&&o.encode||bdr;ur.isFunction(o)&&(o={serialize:o});let e=o&&o.serialize,p;if(e?p=e(i,o):p=ur.isURLSearchParams(i)?i.toString():new zz(i,o).toString(c),p){let d=n.indexOf("#");d!==-1&&(n=n.slice(0,d)),n+=(n.indexOf("?")===-1?"?":"&")+p}return n}Bt();Ot();Pt();var x8t=class{constructor(){this.handlers=[]}use(i,o,c){return this.handlers.push({fulfilled:i,rejected:o,synchronous:c?c.synchronous:!1,runWhen:c?c.runWhen:null}),this.handlers.length-1}eject(i){this.handlers[i]&&(this.handlers[i]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(i){ur.forEach(this.handlers,function(c){c!==null&&i(c)})}},A8t=x8t;Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();var Kz={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();var ove=typeof URLSearchParams<"u"?URLSearchParams:zz;Bt();Ot();Pt();var sve=typeof FormData<"u"?FormData:null;Bt();Ot();Pt();var fve=typeof Blob<"u"?Blob:null;var hve={isBrowser:!0,classes:{URLSearchParams:ove,FormData:sve,Blob:fve},protocols:["http","https","file","blob","url","data"]};var T8t={};ru(T8t,{hasBrowserEnv:()=>k8t,hasStandardBrowserEnv:()=>ydr,hasStandardBrowserWebWorkerEnv:()=>wdr,navigator:()=>R8t,origin:()=>_dr});Bt();Ot();Pt();var k8t=typeof window<"u"&&typeof document<"u",R8t=typeof navigator=="object"&&navigator||void 0,ydr=k8t&&(!R8t||["ReactNative","NativeScript","NS"].indexOf(R8t.product)<0),wdr=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",_dr=k8t&&window.location.href||"http://localhost";var ds={...T8t,...hve};function I8t(n,i){return fb(n,new ds.classes.URLSearchParams,Object.assign({visitor:function(o,c,e,p){return ds.isNode&&ur.isBuffer(o)?(this.append(c,o.toString("base64")),!1):p.defaultVisitor.apply(this,arguments)}},i))}Bt();Ot();Pt();function Mdr(n){return ur.matchAll(/\w+|\[(\w*)]/g,n).map(i=>i[0]==="[]"?"":i[1]||i[0])}function Sdr(n){let i={},o=Object.keys(n),c,e=o.length,p;for(c=0;c<e;c++)p=o[c],i[p]=n[p];return i}function Edr(n){function i(o,c,e,p){let d=o[p++];if(d==="__proto__")return!0;let b=Number.isFinite(+d),_=p>=o.length;return d=!d&&ur.isArray(e)?e.length:d,_?(ur.hasOwnProp(e,d)?e[d]=[e[d],c]:e[d]=c,!b):((!e[d]||!ur.isObject(e[d]))&&(e[d]=[]),i(o,c,e[d],p)&&ur.isArray(e[d])&&(e[d]=Sdr(e[d])),!b)}if(ur.isFormData(n)&&ur.isFunction(n.entries)){let o={};return ur.forEachEntry(n,(c,e)=>{i(Mdr(c),e,o,0)}),o}return null}var Hz=Edr;function xdr(n,i,o){if(ur.isString(n))try{return(i||JSON.parse)(n),ur.trim(n)}catch(c){if(c.name!=="SyntaxError")throw c}return(o||JSON.stringify)(n)}var B8t={transitional:Kz,adapter:["xhr","http","fetch"],transformRequest:[function(i,o){let c=o.getContentType()||"",e=c.indexOf("application/json")>-1,p=ur.isObject(i);if(p&&ur.isHTMLForm(i)&&(i=new FormData(i)),ur.isFormData(i))return e?JSON.stringify(Hz(i)):i;if(ur.isArrayBuffer(i)||ur.isBuffer(i)||ur.isStream(i)||ur.isFile(i)||ur.isBlob(i)||ur.isReadableStream(i))return i;if(ur.isArrayBufferView(i))return i.buffer;if(ur.isURLSearchParams(i))return o.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),i.toString();let b;if(p){if(c.indexOf("application/x-www-form-urlencoded")>-1)return I8t(i,this.formSerializer).toString();if((b=ur.isFileList(i))||c.indexOf("multipart/form-data")>-1){let _=this.env&&this.env.FormData;return fb(b?{"files[]":i}:i,_&&new _,this.formSerializer)}}return p||e?(o.setContentType("application/json",!1),xdr(i)):i}],transformResponse:[function(i){let o=this.transitional||B8t.transitional,c=o&&o.forcedJSONParsing,e=this.responseType==="json";if(ur.isResponse(i)||ur.isReadableStream(i))return i;if(i&&ur.isString(i)&&(c&&!this.responseType||e)){let d=!(o&&o.silentJSONParsing)&&e;try{return JSON.parse(i)}catch(b){if(d)throw b.name==="SyntaxError"?Ti.from(b,Ti.ERR_BAD_RESPONSE,this,null,this.response):b}}return i}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ds.classes.FormData,Blob:ds.classes.Blob},validateStatus:function(i){return i>=200&&i<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ur.forEach(["delete","get","head","post","put","patch"],n=>{B8t.headers[n]={}});var Lw=B8t;Bt();Ot();Pt();Bt();Ot();Pt();var Adr=ur.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),uve=n=>{let i={},o,c,e;return n&&n.split(`
280
+ `).trim(),S=(y["content-disposition"]||"").match(/name="([^"]+)"/);if(S){let E=S[1],x=Object.assign({},y,{body:M}),k={};_.slice(w).forEach(T=>{if(T.trim()==="")return;let B=T.indexOf(":");if(B!==-1){let P=T.substring(0,B).trim(),O=T.substring(B+1).trim();k[P]=O}}),Object.keys(k).length>0&&(x.fields=k),d.set(E,x)}}return d}function FYe(n){return i=>ji(i).chain(zYe).chain(HYe(n)).map(WYe(n,i)).map(KYe).bimap(om,am).toPromise()}function zYe(n){let i=lr.object({path:lr.string().min(1,{message:"path is required"}),method:lr.string()}).passthrough();return ji(i.parse(n))}function KYe(n){let i={},o=n;return o.headers.get("content-type")&&o.headers.get("content-type").startsWith("multipart")?i=ZVe(i,Object.fromEntries(jYe(o.body,o.headers.get("content-type")))):i.body=o.body,o.headers.forEach((c,e)=>{i[e]=c}),i}function HYe(n){return Ta(n.request)}function WYe(n,i){return o=>(n.logger('Received response from message sent to path "%s" with res %O',i?.path??"/",o),o)}var ZYe=lr.object({id:lr.string().min(1,{message:"message is required to be a message id"}),processId:lr.string().min(1,{message:"process is required to be a process id"})});function VYe(){return n=>ji(n).map(ZYe.parse).map(()=>n)}var sw=lr.object({name:lr.string(),value:lr.any()}),GYe=lr.function().args(lr.object({Id:lr.string(),Target:lr.string(),Owner:lr.string(),Anchor:lr.string().optional(),Data:lr.any().default("1234"),Tags:lr.array(lr.object({name:lr.string(),value:lr.string()}))})).returns(lr.promise(lr.any())),YYe=lr.function().args(lr.object({id:lr.string().min(1,{message:"message id is required"}),processId:lr.string().min(1,{message:"process id is required"})})).returns(lr.promise(lr.any())),XYe=lr.function().args(lr.object({process:lr.string().min(1,{message:"process id is required"}),from:lr.string().optional(),to:lr.string().optional(),sort:lr.enum(["ASC","DESC"]).default("ASC"),limit:lr.number().optional()})).returns(lr.promise(lr.object({edges:lr.array(lr.object({cursor:lr.string(),node:lr.object({Output:lr.any().optional(),Messages:lr.array(lr.any()).optional(),Spawns:lr.array(lr.any()).optional(),Error:lr.any().optional()})}))}))),pue=lr.function().args(lr.object({processId:lr.string(),data:lr.any(),tags:lr.array(sw),anchor:lr.string().optional(),signer:lr.any().nullish()})).returns(lr.promise(lr.object({messageId:lr.string()}).passthrough())),JYe=lr.function().args(lr.object({processId:lr.string(),data:lr.any(),tags:lr.array(sw),anchor:lr.string().optional(),signer:lr.any().nullish()})).returns(lr.promise(lr.object({id:lr.string(),raw:lr.any()}).passthrough())),QYe=lr.function().args(lr.object({id:lr.string(),raw:lr.any()})).returns(lr.promise(lr.object({messageId:lr.string()}).passthrough())),tXe=lr.function().args(lr.object({data:lr.any(),tags:lr.array(sw),signer:lr.any().nullish()})).returns(lr.promise(lr.object({processId:lr.string()}).passthrough())),eXe=lr.function().args(lr.object({process:lr.string(),message:lr.string(),baseLayer:lr.boolean().optional(),exclude:lr.array(lr.string()).optional()})).returns(lr.promise(lr.object({assignmentId:lr.string()}).passthrough())),mue=pue,uTr=lr.function().args(lr.object({suUrl:lr.string().url(),processId:lr.string()})).returns(lr.promise(lr.object({tags:lr.array(sw)}).passthrough())),lTr=lr.function().args(lr.string()).returns(lr.promise(lr.object({url:lr.string()}))),rXe=lr.function().args(lr.string()).returns(lr.promise(lr.boolean())),iXe=lr.function().args(lr.string()).returns(lr.promise(lr.object({tags:lr.array(sw)}).passthrough())),sA=lr.function();function nXe({loadResult:n}){return n=Ta(YYe.implement(n)),i=>ji({id:i.id,processId:i.processId}).chain(n)}function aXe(n){let i=VYe(n),o=nXe(n);return({message:c,process:e})=>ji({id:c,processId:e}).chain(i).chain(o).map(n.logger.tap('readResult result for message "%s": %O',c)).map(p=>p).bimap(om,am).toPromise()}var d8=(...n)=>i=>n.reduce((o,c)=>c(o),i),Ggt=n=>i=>i??n,oXe=n=>i=>d8(o=>o&&o[i],Ggt(n)),sXe=n=>i=>{let o={};for(let c in i)i.hasOwnProperty(c)&&(o[c]=n(i[c],c,i));return o},fXe=n=>(...i)=>!n(...i),mF=n=>i=>{let o=i.findIndex(e=>e.name==="Data-Protocol"&&e.value===n);if(o===-1)return[0,0];let c=i.findIndex((e,p)=>p>o&&e.name==="Data-Protocol"&&e.value!==n);return c===-1&&(c=i.length),[o,c]},Ygt=n=>{let i=n.findIndex(o=>o.name==="Data-Protocol");return i===-1&&(i=n.length),i},vue=n=>i=>i.name===n,Xgt=(n,i)=>d8(mF(n),([o,c])=>i.slice(o,c))(i),gue=(n,i,o)=>d8(c=>Xgt(n,c),c=>c.filter(vue(i)))(o),hXe=(n,i,o)=>d8(c=>gue(n,i,c),c=>c[0])(o),vF=(n,i)=>(i=i.filter(o=>o.name!=="Data-Protocol"||o.value!==n),i.length?[{name:"Data-Protocol",value:n},...i]:[]),uXe=(n,i,o)=>{let[c,e]=mF(n)(o),[p,d,b]=[o.slice(0,c),o.slice(c,e),o.slice(e)];return d.length||(i=vF(n,i),p=b,b=[]),[p,d,i,b].flat(1)},lXe=(n,i)=>{let o=Ygt(i),[c,e]=[i.slice(0,o),i.slice(o)];return[c,n,e].flat(1)},bue=(n,i,o)=>{let[c,e]=mF(n)(o),[p,d]=[o.slice(0,c),o.slice(e)];return d.length===o.length&&(p=d,d=[]),[p,vF(n,i),d].flat(1)},cXe=(n,i)=>bue(n,[],i),dXe=(n,i,o)=>{let[c,e]=mF(n)(o),[p,d,b]=[o.slice(0,c),o.slice(c,e),o.slice(e)];return[p,vF(n,d.filter(fXe(vue(i)))),b].flat(1)},Jgt=(n,i=!1)=>d8(Ggt([]),o=>o.reduce((c,e)=>d8(oXe([])(e.name),p=>(p.push(e.value),p),p=>(c[e.name]=p,c))(c),{}),sXe(o=>i?o:o[0]))(n),yue=(n,i,o)=>d8(Ggt([]),c=>Xgt(n,c),c=>Jgt(c,o))(i),pXe=(n,i)=>yue(n,i,!0),mXe=(n,i)=>yue(n,i,!1),vXe=n=>{let i=Ygt(n);return Jgt(n.slice(0,i),!1)},gXe=n=>{let i=Ygt(n);return Jgt(n.slice(0,i),!0)},wue=n=>({findAll:i=>Xgt(n,i),findAllByName:(i,o)=>gue(n,i,o),findByName:(i,o)=>hXe(n,i,o),create:i=>vF(n,i),update:(i,o)=>bue(n,i,o),concat:(i,o)=>uXe(n,i,o),removeAll:i=>cXe(n,i),removeAllByName:(i,o)=>dXe(n,i,o),parse:i=>mXe(n,i),parseAll:i=>pXe(n,i),concatUnassoc:lXe,parseUnassoc:vXe,parseAllUnassoc:gXe}),Qgt=wue("ao"),PXt=ow(Qgt.removeAllByName),bXe=ow(Qgt.concat),OXt=ow(Qgt.concatUnassoc),yXe=lr.array(lr.object({name:lr.string(),value:lr.string()}));function _ue(){return n=>ji(n.tags).map(pF([])).map(PXt("Variant")).map(PXt("Type")).map(bXe([{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Message"}])).map(yXe.parse).map(gu("tags",H2,n))}function Mue({logger:n}){return i=>ji(i).chain(Uhe(Che(i.data),()=>o8(i),()=>o8(" ").map(gu("data",H2,i)).map(o=>Ug(u8("tags"),OXt([{name:"Content-Type",value:"text/plain"}]),gu("tags",H2,o))(o)).map(n.tap('added pseudo-random string as message "data"')))).map(o=>Ug(u8("tags"),OXt([{name:"SDK",value:"aoconnect"}]),gu("tags",H2,o))(o))}function wXe(n){let i=_ue(n),o=Mue(n),c=pue.implement(n.deployMessage);return e=>ji(e).chain(i).chain(o).chain(Ta(({id:p,data:d,tags:b,anchor:_,signer:y})=>c({processId:p,data:d,tags:b,anchor:_,signer:sA.implement(y||n.signer)}))).map(p=>gu("messageId",p.messageId,e))}function _Xe(n){let i=_ue(n),o=Mue(n),c=JYe.implement(n.signMessage);return e=>ji(e).chain(i).chain(o).chain(Ta(({id:p,data:d,tags:b,anchor:_,signer:y})=>c({processId:p,data:d,tags:b,anchor:_,signer:sA.implement(y||n.signer)}))).map(p=>p)}function MXe(n){let i=QYe.implement(n.sendSignedMessage);return o=>ji(o).chain(Ta(({id:c,raw:e})=>i({id:c,raw:e}))).map(c=>gu("messageId",c.messageId,o))}function SXe(n){let i=wXe(n);return({process:o,data:c,tags:e,anchor:p,signer:d})=>ji({id:o,data:c,tags:e,anchor:p,signer:d}).chain(i).map(b=>b.messageId).bimap(om,am).toPromise()}function EXe(n){let i=_Xe(n);return({process:o,data:c,tags:e,anchor:p,signer:d})=>ji({id:o,data:c,tags:e,anchor:p,signer:d}).chain(i).map(b=>b).bimap(om,am).toPromise()}function xXe(n){let i=MXe(n);return({id:o,raw:c})=>ji({id:o,raw:c}).chain(i).map(e=>e.messageId).bimap(om,am).toPromise()}var AS=(n,i,o)=>c=>i(c[n])?o8(c):Z2(`Tag '${n}': ${o}`);function AXe({loadTransactionMeta:n,logger:i}){return n=Ta(iXe.implement(n)),o=>ji(o).chain(n).map(u8("tags")).map(dYe).chain(AS("Data-Protocol",SXt("ao"),"value 'ao' was not found on module")).chain(AS("Type",SXt("Module"),"value 'Module' was not found on module")).chain(AS("Module-Format",Pst,"was not found on module")).chain(AS("Input-Encoding",Pst,"was not found on module")).chain(AS("Output-Encoding",Pst,"was not found on module")).bimap(i.tap("Verifying module source failed: %s"),i.tap("Verified module source"))}function RXe({logger:n,validateScheduler:i}){return i=Ta(rXe.implement(i)),o=>ji(o).chain(c=>i(c).chain(e=>e?o8(c):Z2(`Valid Scheduler-Location owned by ${c} not found`))).bimap(n.tap("Verifying scheduler failed: %s"),n.tap("Verified scheduler"))}function kXe({logger:n}){return i=>ji(i).map(n.tap("Checking for signer")).chain(o=>o?o8(o):Z2("signer not found"))}function TXe(n){let i=n.logger.child("verifyInput");n={...n,logger:i};let o=AXe(n),c=RXe(n),e=kXe(n);return p=>ji(p).chain(d=>o(d.module).map(()=>d)).bimap(i.tap("Error when verify input: %s"),i.tap("Successfully verified inputs"))}var tbt=wue("ao"),gO=ow(tbt.removeAllByName),IXe=ow(tbt.concat),NXt=ow(tbt.concatUnassoc),BXe=lr.array(sw);function PXe(){return n=>ji(n).map(u8("tags")).map(pF([])).map(gO("Variant")).map(gO("Type")).map(gO("Module")).map(gO("Scheduler")).map(IXe([{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Process"},{name:"Module",value:n.module},{name:"Scheduler",value:n.scheduler}])).map(BXe.parse).map(gu("tags",H2,n))}function OXe({logger:n}){return i=>ji(i).chain(Uhe(Che(i.data),()=>o8(i),()=>o8(" ").map(gu("data",H2,i)).map(o=>Ug(u8("tags"),NXt([{name:"Content-Type",value:"text/plain"}]),gu("tags",H2,o))(o)).map(n.tap('added pseudo-random string as process "data"')))).map(o=>Ug(u8("tags"),NXt([{name:"SDK",value:"aoconnect"}]),gu("tags",H2,o))(o))}function NXe(n){let i=n.logger.child("uploadProcess");n={...n,logger:i};let o=PXe(n),c=OXe(n),e=tXe.implement(n.deployProcess);return p=>ji(p).chain(o).chain(c).chain(Ta(({data:d,tags:b,signer:_})=>e({data:d,tags:b,signer:sA.implement(_||n.signer)}))).map(d=>gu("processId",d.processId,p))}function CXe(n){let i=TXe(n),o=NXe(n);return({module:c,scheduler:e,signer:p,tags:d,data:b})=>ji({module:c,scheduler:e,signer:p,tags:d,data:b}).chain(i).chain(o).map(_=>_.processId).bimap(om,am).toPromise()}function LXe(n){let i=mue.implement(n.deployMonitor);return o=>ji(o).chain(Ta(({id:c,signer:e})=>i({processId:c,signer:sA.implement(e||n.signer),data:" ",tags:[]}))).map(c=>gu("monitorId",c.messageId,o))}function DXe(n){let i=LXe(n);return({process:o,signer:c})=>ji({id:o,signer:c}).chain(i).map(e=>e.monitorId).bimap(om,am).toPromise()}function $Xe(n){let i=mue.implement(n.deployUnmonitor);return o=>ji(o).chain(Ta(({id:c,signer:e})=>i({processId:c,signer:sA.implement(e||n.signer),data:" ",tags:[]}))).map(c=>gu("monitorId",c.messageId,o))}function qXe(n){let i=$Xe(n);return({process:o,signer:c})=>ji({id:o,signer:c}).chain(i).map(e=>e.monitorId).bimap(om,am).toPromise()}var UXe=lr.object({process:lr.string().min(1,{message:"process identifier is required"}),from:lr.string().optional(),to:lr.string().optional(),sort:lr.enum(["ASC","DESC"]).default("ASC"),limit:lr.number().optional()});function jXe(){return n=>ji(n).map(UXe.parse).map(()=>n)}function FXe({queryResults:n}){return n=Ta(XYe.implement(n)),i=>ji({process:i.process,from:i.from,to:i.to,sort:i.sort,limit:i.limit}).chain(n)}function zXe(n){let i=jXe(n),o=FXe(n);return({process:c,from:e,to:p,sort:d,limit:b})=>ji({process:c,from:e,to:p,sort:d,limit:b}).chain(i).chain(o).map(n.logger.tap('readResults result for message "%s": %O',c)).map(_=>_).bimap(om,am).toPromise()}var KXe=lr.object({Id:lr.string(),Target:lr.string(),Owner:lr.string(),Anchor:lr.string().optional(),Data:lr.any().default("1234"),Tags:lr.array(lr.object({name:lr.string(),value:lr.string()}))});function HXe(){return n=>ji(n).map(KXe.parse).map(i=>(i.Tags=i.Tags.concat([{name:"Data-Protocol",value:"ao"},{name:"Type",value:"Message"},{name:"Variant",value:"ao.TN.1"}]),i))}function WXe({dryrunFetch:n}){return Ta(GYe.implement(n))}function ZXe(n){let i=HXe(n),o=WXe(n);return c=>ji(c).map(VXe).chain(i).chain(o).toPromise()}function VXe({process:n,data:i,tags:o,anchor:c,...e}){return{Id:"1234",Owner:"1234",...e,Target:n,Data:i||"1234",Tags:o||[],Anchor:c||"0"}}function GXe(n){let i=eXe.implement(n.deployAssign);return o=>ji(o).chain(Ta(({process:c,message:e,baseLayer:p,exclude:d})=>i({process:c,message:e,baseLayer:p,exclude:d}))).map(c=>gu("assignmentId",c.assignmentId,o))}function YXe(n){let i=GXe(n);return({process:o,message:c,baseLayer:e,exclude:p})=>ji({process:o,message:c,baseLayer:e,exclude:p}).chain(i).map(d=>d.assignmentId).bimap(om,am).toPromise()}var XXe="https://arweave.net",JXe="https://mu.ao-testnet.xyz",QXe="https://cu.ao-testnet.xyz",tJe="http://relay.ao-hb.xyz",eJe="http://cu.s451-comm3-main.xyz",rJe="http://mu.s451-comm3-main.xyz",iJe="relay@1.0",Cst=fetch;function nJe({createDataItemSigner:n,createSigner:i}){let o=fue();function c({MODE:d,GRAPHQL_URL:b,GRAPHQL_MAX_RETRIES:_,GRAPHQL_RETRY_BACKOFF:y,MU_URL:w=JXe,CU_URL:M=QXe,fetch:S=Cst,noLog:E}){let x=o.child("legacy");E||x("Mode Activated \u2139\uFE0F");let{validate:k}=Gse({cacheSize:100,GRAPHQL_URL:b,GRAPHQL_MAX_RETRIES:_,GRAPHQL_RETRY_BACKOFF:y}),T=x.child("result"),B=aXe({loadResult:CYe({fetch:S,CU_URL:M,logger:T}),logger:T}),P=x.child("message"),O=SXe({deployMessage:RYe({fetch:S,MU_URL:w,logger:P}),logger:P}),q=x.child("signMessage"),j=EXe({signMessage:kYe({logger:q}),logger:q}),Y=x.child("sendSignedMessage"),V=xXe({sendSignedMessage:TYe({fetch:S,MU_URL:w,logger:Y}),logger:Y}),K=x.child("spawn"),Q=CXe({loadTransactionMeta:DYe({fetch:S,GRAPHQL_URL:b,logger:K}),validateScheduler:k,deployProcess:IYe({fetch:S,MU_URL:w,logger:K}),logger:K}),h=x.child("monitor"),t=DXe({deployMonitor:BYe({fetch:S,MU_URL:w,logger:h}),logger:h}),r=x.child("unmonitor"),s=qXe({deployUnmonitor:PYe({fetch:S,MU_URL:w,logger:r}),logger:h}),u=x.child("results"),l=zXe({queryResults:LYe({fetch:S,CU_URL:M,logger:u}),logger:u}),v=x.child("dryrun"),m=ZXe({dryrunFetch:NYe({fetch:S,CU_URL:M,logger:v}),logger:v}),f=x.child("assign"),a=YXe({deployAssign:OYe({fetch:S,MU_URL:w,logger:f}),logger:P}),g=IXt({getMessageId:RXt({fetch:S,locate:G5})}),A=TXt({messages:AXt({fetch:S,locate:G5})}),R=BXt({processId:kXt({fetch:S,locate:G5})});return{MODE:d,result:B,results:l,message:O,spawn:Q,monitor:t,unmonitor:s,dryrun:m,assign:a,createDataItemSigner:n,signMessage:j,sendSignedMessage:V,getMessages:A,getLastSlot:R,getMessageById:g}}function e({MODE:d,signer:b,GRAPHQL_URL:_,device:y=iJe,URL:w=tJe,MU_URL:M=rJe,CU_URL:S=eJe,fetch:E=Cst}){let x=o.child("mainnet-process");if(x("Mode Activated %s","\u{1F432}"),!b)throw new Error("mainnet mode requires providing a signer to connect()");let k=b?()=>b:n,T=b?()=>b:i,B=IXt({getMessageId:RXt({fetch:E,locate:G5})}),P=TXt({messages:AXt({fetch:E,locate:G5})}),O=BXt({processId:kXt({fetch:E,locate:G5})}),q=x.child("request");return{MODE:"mainnet",request:FYe({signer:b,logger:q,MODE:d,method:"GET",request:hue({fetch:Cst,logger:q,HB_URL:w,signer:b})}),createSigner:T,createDataItemSigner:k,getMessages:P,getLastSlot:O,getMessageById:B}}function p(d={}){let{GRAPHQL_URL:b,GATEWAY_URL:_=XXe,...y}=d;b||(b=gj({url:_,path:"/graphql"}));let w=d.MODE||"legacy";if(w==="legacy")return c({...y,GRAPHQL_URL:b});if(w==="mainnet")return e({...y,GRAPHQL_URL:b});throw new Error(`Unrecognized MODE: ${w}`)}return p}var $x={};p8($x,{createDataItemSigner:()=>sJe,createSigner:()=>Sue});var ebt=un(_1(),1);globalThis.Buffer||(globalThis.Buffer=ebt.Buffer);function aJe(n){return async i=>n.connect(["SIGN_TRANSACTION"]).then(async()=>{let{data:o,tags:c,target:e,anchor:p}=await i({alg:"rsa-v1_5-sha256",passthrough:!0}),d=await n.signDataItem({data:o,tags:c,target:e,anchor:p});return await hZe(ebt.Buffer.from(d))})}function oJe(n){return async i=>n.connect(["ACCESS_ADDRESS","ACCESS_PUBLIC_KEY","SIGNATURE"]).then(async()=>{let[o,c]=await Promise.all([n.getActivePublicKey(),n.getActiveAddress()]);return{publicKey:o,address:c}}).then(async({publicKey:o,address:c})=>{let e=await i({type:1,publicKey:o,address:c,alg:"rsa-pss-sha512"}),p=await n.signMessage(e,{hashAlgorithm:"SHA-512"});return{signature:ebt.Buffer.from(p),address:c}})}function Sue(n){let i=aJe(n),o=oJe(n);return(c,e)=>{if(e===uue)return i(c);if(e===lue)return o(c);throw new Error(`signer kind unknown "${e}"`)}}var sJe=Sue,fJe=globalThis.GATEWAY_URL||void 0,hJe=globalThis.MU_URL||void 0,uJe=globalThis.CU_URL||void 0,lJe=globalThis.GRAPHQL_URL||void 0,cJe=globalThis.GRAPHQL_MAX_RETRIES||void 0,dJe=globalThis.GRAPHQL_RETRY_BACKOFF||void 0,pJe=globalThis.RELAY_URL||void 0,mJe=globalThis.AO_URL=void 0,sl=nJe({createDataItemSigner:$x.createDataItemSigner,createSigner:$x.createSigner}),Eue=$x.createDataItemSigner,cTr=$x.createSigner,{result:dTr,results:pTr,message:mTr,spawn:vTr,monitor:gTr,unmonitor:bTr,dryrun:yTr,assign:wTr}=sl({MODE:"legacy",GATEWAY_URL:fJe,MU_URL:hJe,CU_URL:uJe,RELAY_URL:pJe,AO_URL:mJe,GRAPHQL_URL:lJe,GRAPHQL_MAX_RETRIES:cJe,GRAPHQL_RETRY_BACKOFF:dJe,noLog:!0});Bt();Ot();Pt();var g0e=va(v0e(),1),xF=g0e.default.init({host:"arweave.net",port:443,protocol:"https"});Bt();Ot();Pt();Bt();Ot();Pt();var x1=class extends Error{constructor(i){super(i),this.name=this.constructor.name}},b0e=class extends x1{},y0e=class extends x1{},w0e=class extends x1{constructor(i,o){super(`Failed request: ${i}: ${o}`)}},_0e=class extends x1{},AF=class extends x1{},M0e=class extends x1{constructor(){super("Invalid signer. Please provide a valid signer to interact with the contract.")}},hm=class extends x1{constructor(){super("Invalid contract configuration")}},S0e=class extends x1{constructor(){super("Invalid process configuration")}},E0e=class extends x1{};Bt();Ot();Pt();var O1=va(N2e(),1);Bt();Ot();Pt();var Pw="3.11.1-alpha.1";var v0=class n{logger;silent=!1;static default=new n;constructor({level:i="info"}={}){i==="none"&&(this.silent=!0),typeof window<"u"?this.logger=console:this.logger=(0,O1.createLogger)({level:i,silent:this.silent,defaultMeta:{name:"ar-io-sdk",version:Pw},format:O1.format.combine(O1.format.timestamp(),O1.format.json()),transports:[new O1.transports.Console({format:O1.format.combine(O1.format.timestamp(),O1.format.json())})]})}info(i,...o){this.silent||this.logger.info(i,...o)}warn(i,...o){this.silent||this.logger.warn(i,...o)}error(i,...o){this.silent||this.logger.error(i,...o)}debug(i,...o){this.silent||this.logger.debug(i,...o)}setLogLevel(i){this.silent=i==="none","silent"in this.logger&&(this.logger.silent=i==="none"),"level"in this.logger&&(this.logger.level=i)}};Bt();Ot();Pt();Bt();Ot();Pt();var C2e=n=>{let i=Object.entries(n).sort(([o,c],[e,p])=>o==="@"?-1:e==="@"?1:"priority"in c&&!("priority"in p)?-1:!("priority"in c)&&"priority"in p?1:c.priority!==void 0&&p.priority!==void 0?c.priority===p.priority?o<e?-1:o>e?1:0:c.priority-p.priority:o<e?-1:o>e?1:0);return Object.fromEntries(i.map(([o,c],e)=>[o,{...c,index:e}]))};Bt();Ot();Pt();function mm(n,i){let o=n.safeParse(i);if(!o.success)throw new Error(JSON.stringify(o.error.format(),null,2));return o}Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();op();var L2e="+",D2e="/",$2e="-",q2e="_",U2e="=";function _cr(n){let i=n.length%4;return i&&(n+=U2e.repeat(4-i)),n.replaceAll($2e,L2e).replaceAll(q2e,D2e)}function Mcr(n){return n.replaceAll(L2e,$2e).replaceAll(D2e,q2e).replaceAll(U2e,"")}function eFr(n){let i=_cr(n);return Zt.from(i,"base64")}function Ow(n){let i=n.toString("base64");return Mcr(i)}function rFr(n){return Ow(Id("sha256").update(Uint8Array.from(n)).digest())}function j2e(n=32){let i=GQ(n);return Array.from(i,o=>o.toString(16).padStart(2,"0")).join("").slice(0,n)}Bt();Ot();Pt();Bt();Ot();Pt();function h8t(n){try{return JSON.parse(n)}catch{return n}}Bt();Ot();Pt();Bt();Ot();Pt();var l8t=va(z2e(),1);Bt();Ot();Pt();var xcr=Object.defineProperty,Acr=(n,i,o)=>i in n?xcr(n,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[i]=o,eR=(n,i,o)=>(Acr(n,typeof i!="symbol"?i+"":i,o),o),c8t=class{constructor(i){eR(this,"value"),eR(this,"next"),this.value=i}},d8t=class{constructor(){eR(this,"head"),eR(this,"tail"),eR(this,"_size",0),this.clear()}clear(){this.head=void 0,this.tail=void 0,this._size=0}push(i){let o=new c8t(i);return this.head&&this.tail?(this.tail.next=o,this.tail=o):(this.head=o,this.tail=o),this._size++,this._size}pop(){if(!this.head)return;let i=this.head;return this.head=this.head.next,this._size--,i.value}get size(){return this._size}*[Symbol.iterator](){let i=this.head;for(;i;)yield i.value,i=i.next}};function K2e(n){if(!((Number.isInteger(n)||n===1/0)&&n>0))throw new TypeError("Expected `concurrency` to be a number greater than 1");let i=new d8t,o=0,c=()=>{o--,i.size>0&&i.pop()()},e=async(b,_,y)=>{o++;let w=(async()=>b(...y))();_(w);try{await w}catch{}c()},p=(b,_,y)=>{i.push(e.bind(null,b,_,y)),(async()=>(await Promise.resolve(),o<n&&i.size>0&&i.pop()()))()},d=(b,..._)=>new Promise(y=>{p(b,y,_)});return Object.defineProperties(d,{activeCount:{get:()=>o},pendingCount:{get:()=>i.size},clearQueue:{value:()=>{i.clear()}}}),d}Bt();Ot();Pt();var rR=class{static init(i){return i!==void 0&&"signer"in i?new p8t(i):new Cz(i)}},Cz=class{process;constructor(i){if(i===void 0||Object.keys(i).length===0)this.process=new cs({processId:E5});else if(ob(i))this.process=i.process;else if(sb(i))this.process=new cs({processId:i.processId});else throw new hm}async accessControlList({address:i}){return this.process.read({tags:[{name:"Action",value:"Access-Control-List"},{name:"Address",value:i}]})}},p8t=class extends Cz{signer;constructor({signer:i,...o}){super(o),this.signer=ab(i)}async register({processId:i}){return this.process.send({tags:[{name:"Action",value:"Register"},{name:"Process-Id",value:i}],signer:this.signer})}};Bt();Ot();Pt();Bt();Ot();Pt();var Rcr="https://faucet.ario.permaweb.services";function v8t({arioInstance:n,faucetApiUrl:i=Rcr}){let o=new m8t({faucetUrl:i,processId:n.process.processId});return new Proxy(n,{get(e,p){if(p==="faucet")return o;if(p in e){let d=e[p];return typeof d=="function"?d.bind(e):d}}})}var m8t=class{faucetUrl;processId;constructor({faucetUrl:i,processId:o}){this.faucetUrl=i,this.processId=o}async captchaUrl(){let i=await fetch(`${this.faucetUrl}/api/captcha/url?process-id=${this.processId}`,{method:"GET"});if(!i.ok){let c=await i.json().catch(()=>({error:i.statusText}));throw new Error(c.error)}return await i.json()}async claimWithCaptchaResponse({captchaResponse:i,recipient:o,quantity:c}){let e=await fetch(`${this.faucetUrl}/api/claim/sync`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processId:this.processId,recipient:o,quantity:c,captchaResponse:i})});if(!e.ok){let d=await e.json().catch(()=>({error:e.statusText}));throw new Error(d.error)}return await e.json()}async requestAuthToken({captchaResponse:i}){let o=await fetch(`${this.faucetUrl}/api/captcha/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processId:this.processId,captchaResponse:i})});if(!o.ok){let e=await o.json().catch(()=>({error:o.statusText}));throw new Error(e.error)}return await o.json()}async claimWithAuthToken({authToken:i,recipient:o,quantity:c}){let e=await fetch(`${this.faucetUrl}/api/claim/async`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({recipient:o,qty:c,processId:this.processId})});if(!e.ok){let d=await e.json().catch(()=>({error:e.statusText}));throw new Error(d.error)}return await e.json()}async verifyAuthToken({authToken:i}){let o=await fetch(`${this.faucetUrl}/api/token/verify?process-id=${this.processId}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`}});if(!o.ok){let e=await o.json().catch(()=>({error:o.statusText}));throw new Error(e.error)}return await o.json()}};Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();var Sh=[];for(Lz=0;Lz<256;++Lz)Sh.push((Lz+256).toString(16).slice(1));var Lz;function H2e(n,i=0){return(Sh[n[i+0]]+Sh[n[i+1]]+Sh[n[i+2]]+Sh[n[i+3]]+"-"+Sh[n[i+4]]+Sh[n[i+5]]+"-"+Sh[n[i+6]]+Sh[n[i+7]]+"-"+Sh[n[i+8]]+Sh[n[i+9]]+"-"+Sh[n[i+10]]+Sh[n[i+11]]+Sh[n[i+12]]+Sh[n[i+13]]+Sh[n[i+14]]+Sh[n[i+15]]).toLowerCase()}Bt();Ot();Pt();var Dz,kcr=new Uint8Array(16);function g8t(){if(!Dz&&(Dz=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Dz))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Dz(kcr)}Bt();Ot();Pt();Bt();Ot();Pt();var Tcr=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),b8t={randomUUID:Tcr};function Icr(n,i,o){if(b8t.randomUUID&&!i&&!n)return b8t.randomUUID();n=n||{};var c=n.random||(n.rng||g8t)();if(c[6]=c[6]&15|64,c[8]=c[8]&63|128,i){o=o||0;for(var e=0;e<16;++e)i[o+e]=c[e];return i}return H2e(c)}var y8t=Icr;Bt();Ot();Pt();var w8t=class n{constructor(i){this.positiveFiniteInteger=i;if(!Number.isFinite(this.positiveFiniteInteger)||!Number.isInteger(this.positiveFiniteInteger)||this.positiveFiniteInteger<0)throw new Error(`Number must be a non-negative integer value! ${i}`)}[Symbol.toPrimitive](i){return i==="string"&&this.toString(),this.positiveFiniteInteger}plus(i){return new n(this.positiveFiniteInteger+i.positiveFiniteInteger)}minus(i){return new n(this.positiveFiniteInteger-i.positiveFiniteInteger)}isGreaterThan(i){return this.positiveFiniteInteger>i.positiveFiniteInteger}isGreaterThanOrEqualTo(i){return this.positiveFiniteInteger>=i.positiveFiniteInteger}isLessThan(i){return this.positiveFiniteInteger<i.positiveFiniteInteger}isLessThanOrEqualTo(i){return this.positiveFiniteInteger<=i.positiveFiniteInteger}toString(){return`${this.positiveFiniteInteger}`}valueOf(){return this.positiveFiniteInteger}toJSON(){return this.positiveFiniteInteger}equals(i){return this.positiveFiniteInteger===i.positiveFiniteInteger}},_8t=class{value;constructor(i){if(!Number.isFinite(i)||i<0)throw new Error("ARIOToken must be a non-negative finite number");this.value=+i.toFixed(6)}valueOf(){return this.value}toMARIO(){return new iR(Math.floor(this.value*lnt))}toString(){return`${this.value}`}},iR=class n extends w8t{constructor(i){super(i)}multiply(i){let o=Math.floor(this.valueOf()*i.valueOf());return new n(o)}divide(i){if(i.valueOf()===0)throw new Error("Cannot divide by zero");let o=Math.floor(this.valueOf()/i.valueOf());return new n(o)}plus(i){let o=super.plus(i);return new n(o.valueOf())}minus(i){let o=super.minus(i);return new n(o.valueOf())}toARIO(){return new _8t(this.valueOf()/lnt)}};Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();function nR(n,i){return function(){return n.apply(i,arguments)}}var{toString:Bcr}=Object.prototype,{getPrototypeOf:S8t}=Object,qz=(n=>i=>{let o=Bcr.call(i);return n[o]||(n[o]=o.slice(8,-1).toLowerCase())})(Object.create(null)),N1=n=>(n=n.toLowerCase(),i=>qz(i)===n),Uz=n=>i=>typeof i===n,{isArray:Nw}=Array,aR=Uz("undefined");function Pcr(n){return n!==null&&!aR(n)&&n.constructor!==null&&!aR(n.constructor)&&pl(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}var Z2e=N1("ArrayBuffer");function Ocr(n){let i;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?i=ArrayBuffer.isView(n):i=n&&n.buffer&&Z2e(n.buffer),i}var Ncr=Uz("string"),pl=Uz("function"),V2e=Uz("number"),jz=n=>n!==null&&typeof n=="object",Ccr=n=>n===!0||n===!1,$z=n=>{if(qz(n)!=="object")return!1;let i=S8t(n);return(i===null||i===Object.prototype||Object.getPrototypeOf(i)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)},Lcr=N1("Date"),Dcr=N1("File"),$cr=N1("Blob"),qcr=N1("FileList"),Ucr=n=>jz(n)&&pl(n.pipe),jcr=n=>{let i;return n&&(typeof FormData=="function"&&n instanceof FormData||pl(n.append)&&((i=qz(n))==="formdata"||i==="object"&&pl(n.toString)&&n.toString()==="[object FormData]"))},Fcr=N1("URLSearchParams"),[zcr,Kcr,Hcr,Wcr]=["ReadableStream","Request","Response","Headers"].map(N1),Zcr=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function oR(n,i,{allOwnKeys:o=!1}={}){if(n===null||typeof n>"u")return;let c,e;if(typeof n!="object"&&(n=[n]),Nw(n))for(c=0,e=n.length;c<e;c++)i.call(null,n[c],c,n);else{let p=o?Object.getOwnPropertyNames(n):Object.keys(n),d=p.length,b;for(c=0;c<d;c++)b=p[c],i.call(null,n[b],b,n)}}function G2e(n,i){i=i.toLowerCase();let o=Object.keys(n),c=o.length,e;for(;c-- >0;)if(e=o[c],i===e.toLowerCase())return e;return null}var N8=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Y2e=n=>!aR(n)&&n!==N8;function M8t(){let{caseless:n}=Y2e(this)&&this||{},i={},o=(c,e)=>{let p=n&&G2e(i,e)||e;$z(i[p])&&$z(c)?i[p]=M8t(i[p],c):$z(c)?i[p]=M8t({},c):Nw(c)?i[p]=c.slice():i[p]=c};for(let c=0,e=arguments.length;c<e;c++)arguments[c]&&oR(arguments[c],o);return i}var Vcr=(n,i,o,{allOwnKeys:c}={})=>(oR(i,(e,p)=>{o&&pl(e)?n[p]=nR(e,o):n[p]=e},{allOwnKeys:c}),n),Gcr=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),Ycr=(n,i,o,c)=>{n.prototype=Object.create(i.prototype,c),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:i.prototype}),o&&Object.assign(n.prototype,o)},Xcr=(n,i,o,c)=>{let e,p,d,b={};if(i=i||{},n==null)return i;do{for(e=Object.getOwnPropertyNames(n),p=e.length;p-- >0;)d=e[p],(!c||c(d,n,i))&&!b[d]&&(i[d]=n[d],b[d]=!0);n=o!==!1&&S8t(n)}while(n&&(!o||o(n,i))&&n!==Object.prototype);return i},Jcr=(n,i,o)=>{n=String(n),(o===void 0||o>n.length)&&(o=n.length),o-=i.length;let c=n.indexOf(i,o);return c!==-1&&c===o},Qcr=n=>{if(!n)return null;if(Nw(n))return n;let i=n.length;if(!V2e(i))return null;let o=new Array(i);for(;i-- >0;)o[i]=n[i];return o},tdr=(n=>i=>n&&i instanceof n)(typeof Uint8Array<"u"&&S8t(Uint8Array)),edr=(n,i)=>{let c=(n&&n[Symbol.iterator]).call(n),e;for(;(e=c.next())&&!e.done;){let p=e.value;i.call(n,p[0],p[1])}},rdr=(n,i)=>{let o,c=[];for(;(o=n.exec(i))!==null;)c.push(o);return c},idr=N1("HTMLFormElement"),ndr=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(o,c,e){return c.toUpperCase()+e}),W2e=(({hasOwnProperty:n})=>(i,o)=>n.call(i,o))(Object.prototype),adr=N1("RegExp"),X2e=(n,i)=>{let o=Object.getOwnPropertyDescriptors(n),c={};oR(o,(e,p)=>{let d;(d=i(e,p,n))!==!1&&(c[p]=d||e)}),Object.defineProperties(n,c)},odr=n=>{X2e(n,(i,o)=>{if(pl(n)&&["arguments","caller","callee"].indexOf(o)!==-1)return!1;let c=n[o];if(pl(c)){if(i.enumerable=!1,"writable"in i){i.writable=!1;return}i.set||(i.set=()=>{throw Error("Can not rewrite read-only method '"+o+"'")})}})},sdr=(n,i)=>{let o={},c=e=>{e.forEach(p=>{o[p]=!0})};return Nw(n)?c(n):c(String(n).split(i)),o},fdr=()=>{},hdr=(n,i)=>n!=null&&Number.isFinite(n=+n)?n:i;function udr(n){return!!(n&&pl(n.append)&&n[Symbol.toStringTag]==="FormData"&&n[Symbol.iterator])}var ldr=n=>{let i=new Array(10),o=(c,e)=>{if(jz(c)){if(i.indexOf(c)>=0)return;if(!("toJSON"in c)){i[e]=c;let p=Nw(c)?[]:{};return oR(c,(d,b)=>{let _=o(d,e+1);!aR(_)&&(p[b]=_)}),i[e]=void 0,p}}return c};return o(n,0)},cdr=N1("AsyncFunction"),ddr=n=>n&&(jz(n)||pl(n))&&pl(n.then)&&pl(n.catch),J2e=((n,i)=>n?setImmediate:i?((o,c)=>(N8.addEventListener("message",({source:e,data:p})=>{e===N8&&p===o&&c.length&&c.shift()()},!1),e=>{c.push(e),N8.postMessage(o,"*")}))(`axios@${Math.random()}`,[]):o=>setTimeout(o))(typeof setImmediate=="function",pl(N8.postMessage)),pdr=typeof queueMicrotask<"u"?queueMicrotask.bind(N8):typeof Yt<"u"&&Yt.nextTick||J2e,ur={isArray:Nw,isArrayBuffer:Z2e,isBuffer:Pcr,isFormData:jcr,isArrayBufferView:Ocr,isString:Ncr,isNumber:V2e,isBoolean:Ccr,isObject:jz,isPlainObject:$z,isReadableStream:zcr,isRequest:Kcr,isResponse:Hcr,isHeaders:Wcr,isUndefined:aR,isDate:Lcr,isFile:Dcr,isBlob:$cr,isRegExp:adr,isFunction:pl,isStream:Ucr,isURLSearchParams:Fcr,isTypedArray:tdr,isFileList:qcr,forEach:oR,merge:M8t,extend:Vcr,trim:Zcr,stripBOM:Gcr,inherits:Ycr,toFlatObject:Xcr,kindOf:qz,kindOfTest:N1,endsWith:Jcr,toArray:Qcr,forEachEntry:edr,matchAll:rdr,isHTMLForm:idr,hasOwnProperty:W2e,hasOwnProp:W2e,reduceDescriptors:X2e,freezeMethods:odr,toObjectSet:sdr,toCamelCase:ndr,noop:fdr,toFiniteNumber:hdr,findKey:G2e,global:N8,isContextDefined:Y2e,isSpecCompliantForm:udr,toJSONObject:ldr,isAsyncFn:cdr,isThenable:ddr,setImmediate:J2e,asap:pdr};Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();function Cw(n,i,o,c,e){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",i&&(this.code=i),o&&(this.config=o),c&&(this.request=c),e&&(this.response=e,this.status=e.status?e.status:null)}ur.inherits(Cw,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ur.toJSONObject(this.config),code:this.code,status:this.status}}});var Q2e=Cw.prototype,tve={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{tve[n]={value:n}});Object.defineProperties(Cw,tve);Object.defineProperty(Q2e,"isAxiosError",{value:!0});Cw.from=(n,i,o,c,e,p)=>{let d=Object.create(Q2e);return ur.toFlatObject(n,d,function(_){return _!==Error.prototype},b=>b!=="isAxiosError"),Cw.call(d,n.message,i,o,c,e),d.cause=n,d.name=n.name,p&&Object.assign(d,p),d};var Ti=Cw;Bt();Ot();Pt();var Fz=null;function E8t(n){return ur.isPlainObject(n)||ur.isArray(n)}function rve(n){return ur.endsWith(n,"[]")?n.slice(0,-2):n}function eve(n,i,o){return n?n.concat(i).map(function(e,p){return e=rve(e),!o&&p?"["+e+"]":e}).join(o?".":""):i}function mdr(n){return ur.isArray(n)&&!n.some(E8t)}var vdr=ur.toFlatObject(ur,{},null,function(i){return/^is[A-Z]/.test(i)});function gdr(n,i,o){if(!ur.isObject(n))throw new TypeError("target must be an object");i=i||new(Fz||FormData),o=ur.toFlatObject(o,{metaTokens:!0,dots:!1,indexes:!1},!1,function(k,T){return!ur.isUndefined(T[k])});let c=o.metaTokens,e=o.visitor||w,p=o.dots,d=o.indexes,_=(o.Blob||typeof Blob<"u"&&Blob)&&ur.isSpecCompliantForm(i);if(!ur.isFunction(e))throw new TypeError("visitor must be a function");function y(x){if(x===null)return"";if(ur.isDate(x))return x.toISOString();if(!_&&ur.isBlob(x))throw new Ti("Blob is not supported. Use a Buffer instead.");return ur.isArrayBuffer(x)||ur.isTypedArray(x)?_&&typeof Blob=="function"?new Blob([x]):Zt.from(x):x}function w(x,k,T){let B=x;if(x&&!T&&typeof x=="object"){if(ur.endsWith(k,"{}"))k=c?k:k.slice(0,-2),x=JSON.stringify(x);else if(ur.isArray(x)&&mdr(x)||(ur.isFileList(x)||ur.endsWith(k,"[]"))&&(B=ur.toArray(x)))return k=rve(k),B.forEach(function(O,q){!(ur.isUndefined(O)||O===null)&&i.append(d===!0?eve([k],q,p):d===null?k:k+"[]",y(O))}),!1}return E8t(x)?!0:(i.append(eve(T,k,p),y(x)),!1)}let M=[],S=Object.assign(vdr,{defaultVisitor:w,convertValue:y,isVisitable:E8t});function E(x,k){if(!ur.isUndefined(x)){if(M.indexOf(x)!==-1)throw Error("Circular reference detected in "+k.join("."));M.push(x),ur.forEach(x,function(B,P){(!(ur.isUndefined(B)||B===null)&&e.call(i,B,ur.isString(P)?P.trim():P,k,S))===!0&&E(B,k?k.concat(P):[P])}),M.pop()}}if(!ur.isObject(n))throw new TypeError("data must be an object");return E(n),i}var fb=gdr;function ive(n){let i={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(c){return i[c]})}function nve(n,i){this._pairs=[],n&&fb(n,this,i)}var ave=nve.prototype;ave.append=function(i,o){this._pairs.push([i,o])};ave.toString=function(i){let o=i?function(c){return i.call(this,c,ive)}:ive;return this._pairs.map(function(e){return o(e[0])+"="+o(e[1])},"").join("&")};var zz=nve;function bdr(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function sR(n,i,o){if(!i)return n;let c=o&&o.encode||bdr;ur.isFunction(o)&&(o={serialize:o});let e=o&&o.serialize,p;if(e?p=e(i,o):p=ur.isURLSearchParams(i)?i.toString():new zz(i,o).toString(c),p){let d=n.indexOf("#");d!==-1&&(n=n.slice(0,d)),n+=(n.indexOf("?")===-1?"?":"&")+p}return n}Bt();Ot();Pt();var x8t=class{constructor(){this.handlers=[]}use(i,o,c){return this.handlers.push({fulfilled:i,rejected:o,synchronous:c?c.synchronous:!1,runWhen:c?c.runWhen:null}),this.handlers.length-1}eject(i){this.handlers[i]&&(this.handlers[i]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(i){ur.forEach(this.handlers,function(c){c!==null&&i(c)})}},A8t=x8t;Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();var Kz={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();var ove=typeof URLSearchParams<"u"?URLSearchParams:zz;Bt();Ot();Pt();var sve=typeof FormData<"u"?FormData:null;Bt();Ot();Pt();var fve=typeof Blob<"u"?Blob:null;var hve={isBrowser:!0,classes:{URLSearchParams:ove,FormData:sve,Blob:fve},protocols:["http","https","file","blob","url","data"]};var T8t={};ru(T8t,{hasBrowserEnv:()=>k8t,hasStandardBrowserEnv:()=>ydr,hasStandardBrowserWebWorkerEnv:()=>wdr,navigator:()=>R8t,origin:()=>_dr});Bt();Ot();Pt();var k8t=typeof window<"u"&&typeof document<"u",R8t=typeof navigator=="object"&&navigator||void 0,ydr=k8t&&(!R8t||["ReactNative","NativeScript","NS"].indexOf(R8t.product)<0),wdr=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",_dr=k8t&&window.location.href||"http://localhost";var ds={...T8t,...hve};function I8t(n,i){return fb(n,new ds.classes.URLSearchParams,Object.assign({visitor:function(o,c,e,p){return ds.isNode&&ur.isBuffer(o)?(this.append(c,o.toString("base64")),!1):p.defaultVisitor.apply(this,arguments)}},i))}Bt();Ot();Pt();function Mdr(n){return ur.matchAll(/\w+|\[(\w*)]/g,n).map(i=>i[0]==="[]"?"":i[1]||i[0])}function Sdr(n){let i={},o=Object.keys(n),c,e=o.length,p;for(c=0;c<e;c++)p=o[c],i[p]=n[p];return i}function Edr(n){function i(o,c,e,p){let d=o[p++];if(d==="__proto__")return!0;let b=Number.isFinite(+d),_=p>=o.length;return d=!d&&ur.isArray(e)?e.length:d,_?(ur.hasOwnProp(e,d)?e[d]=[e[d],c]:e[d]=c,!b):((!e[d]||!ur.isObject(e[d]))&&(e[d]=[]),i(o,c,e[d],p)&&ur.isArray(e[d])&&(e[d]=Sdr(e[d])),!b)}if(ur.isFormData(n)&&ur.isFunction(n.entries)){let o={};return ur.forEachEntry(n,(c,e)=>{i(Mdr(c),e,o,0)}),o}return null}var Hz=Edr;function xdr(n,i,o){if(ur.isString(n))try{return(i||JSON.parse)(n),ur.trim(n)}catch(c){if(c.name!=="SyntaxError")throw c}return(o||JSON.stringify)(n)}var B8t={transitional:Kz,adapter:["xhr","http","fetch"],transformRequest:[function(i,o){let c=o.getContentType()||"",e=c.indexOf("application/json")>-1,p=ur.isObject(i);if(p&&ur.isHTMLForm(i)&&(i=new FormData(i)),ur.isFormData(i))return e?JSON.stringify(Hz(i)):i;if(ur.isArrayBuffer(i)||ur.isBuffer(i)||ur.isStream(i)||ur.isFile(i)||ur.isBlob(i)||ur.isReadableStream(i))return i;if(ur.isArrayBufferView(i))return i.buffer;if(ur.isURLSearchParams(i))return o.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),i.toString();let b;if(p){if(c.indexOf("application/x-www-form-urlencoded")>-1)return I8t(i,this.formSerializer).toString();if((b=ur.isFileList(i))||c.indexOf("multipart/form-data")>-1){let _=this.env&&this.env.FormData;return fb(b?{"files[]":i}:i,_&&new _,this.formSerializer)}}return p||e?(o.setContentType("application/json",!1),xdr(i)):i}],transformResponse:[function(i){let o=this.transitional||B8t.transitional,c=o&&o.forcedJSONParsing,e=this.responseType==="json";if(ur.isResponse(i)||ur.isReadableStream(i))return i;if(i&&ur.isString(i)&&(c&&!this.responseType||e)){let d=!(o&&o.silentJSONParsing)&&e;try{return JSON.parse(i)}catch(b){if(d)throw b.name==="SyntaxError"?Ti.from(b,Ti.ERR_BAD_RESPONSE,this,null,this.response):b}}return i}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ds.classes.FormData,Blob:ds.classes.Blob},validateStatus:function(i){return i>=200&&i<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ur.forEach(["delete","get","head","post","put","patch"],n=>{B8t.headers[n]={}});var Lw=B8t;Bt();Ot();Pt();Bt();Ot();Pt();var Adr=ur.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),uve=n=>{let i={},o,c,e;return n&&n.split(`
281
281
  `).forEach(function(d){e=d.indexOf(":"),o=d.substring(0,e).trim().toLowerCase(),c=d.substring(e+1).trim(),!(!o||i[o]&&Adr[o])&&(o==="set-cookie"?i[o]?i[o].push(c):i[o]=[c]:i[o]=i[o]?i[o]+", "+c:c)}),i};var lve=Symbol("internals");function fR(n){return n&&String(n).trim().toLowerCase()}function Wz(n){return n===!1||n==null?n:ur.isArray(n)?n.map(Wz):String(n)}function Rdr(n){let i=Object.create(null),o=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,c;for(;c=o.exec(n);)i[c[1]]=c[2];return i}var kdr=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function P8t(n,i,o,c,e){if(ur.isFunction(c))return c.call(this,i,o);if(e&&(i=o),!!ur.isString(i)){if(ur.isString(c))return i.indexOf(c)!==-1;if(ur.isRegExp(c))return c.test(i)}}function Tdr(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(i,o,c)=>o.toUpperCase()+c)}function Idr(n,i){let o=ur.toCamelCase(" "+i);["get","set","has"].forEach(c=>{Object.defineProperty(n,c+o,{value:function(e,p,d){return this[c].call(this,i,e,p,d)},configurable:!0})})}var Dw=class{constructor(i){i&&this.set(i)}set(i,o,c){let e=this;function p(b,_,y){let w=fR(_);if(!w)throw new Error("header name must be a non-empty string");let M=ur.findKey(e,w);(!M||e[M]===void 0||y===!0||y===void 0&&e[M]!==!1)&&(e[M||_]=Wz(b))}let d=(b,_)=>ur.forEach(b,(y,w)=>p(y,w,_));if(ur.isPlainObject(i)||i instanceof this.constructor)d(i,o);else if(ur.isString(i)&&(i=i.trim())&&!kdr(i))d(uve(i),o);else if(ur.isHeaders(i))for(let[b,_]of i.entries())p(_,b,c);else i!=null&&p(o,i,c);return this}get(i,o){if(i=fR(i),i){let c=ur.findKey(this,i);if(c){let e=this[c];if(!o)return e;if(o===!0)return Rdr(e);if(ur.isFunction(o))return o.call(this,e,c);if(ur.isRegExp(o))return o.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(i,o){if(i=fR(i),i){let c=ur.findKey(this,i);return!!(c&&this[c]!==void 0&&(!o||P8t(this,this[c],c,o)))}return!1}delete(i,o){let c=this,e=!1;function p(d){if(d=fR(d),d){let b=ur.findKey(c,d);b&&(!o||P8t(c,c[b],b,o))&&(delete c[b],e=!0)}}return ur.isArray(i)?i.forEach(p):p(i),e}clear(i){let o=Object.keys(this),c=o.length,e=!1;for(;c--;){let p=o[c];(!i||P8t(this,this[p],p,i,!0))&&(delete this[p],e=!0)}return e}normalize(i){let o=this,c={};return ur.forEach(this,(e,p)=>{let d=ur.findKey(c,p);if(d){o[d]=Wz(e),delete o[p];return}let b=i?Tdr(p):String(p).trim();b!==p&&delete o[p],o[b]=Wz(e),c[b]=!0}),this}concat(...i){return this.constructor.concat(this,...i)}toJSON(i){let o=Object.create(null);return ur.forEach(this,(c,e)=>{c!=null&&c!==!1&&(o[e]=i&&ur.isArray(c)?c.join(", "):c)}),o}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([i,o])=>i+": "+o).join(`
282
282
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(i){return i instanceof this?i:new this(i)}static concat(i,...o){let c=new this(i);return o.forEach(e=>c.set(e)),c}static accessor(i){let c=(this[lve]=this[lve]={accessors:{}}).accessors,e=this.prototype;function p(d){let b=fR(d);c[b]||(Idr(e,d),c[b]=!0)}return ur.isArray(i)?i.forEach(p):p(i),this}};Dw.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ur.reduceDescriptors(Dw.prototype,({value:n},i)=>{let o=i[0].toUpperCase()+i.slice(1);return{get:()=>n,set(c){this[o]=c}}});ur.freezeMethods(Dw);var Rf=Dw;function hR(n,i){let o=this||Lw,c=i||o,e=Rf.from(c.headers),p=c.data;return ur.forEach(n,function(b){p=b.call(o,p,e.normalize(),i?i.status:void 0)}),e.normalize(),p}Bt();Ot();Pt();function uR(n){return!!(n&&n.__CANCEL__)}Bt();Ot();Pt();function cve(n,i,o){Ti.call(this,n??"canceled",Ti.ERR_CANCELED,i,o),this.name="CanceledError"}ur.inherits(cve,Ti,{__CANCEL__:!0});var vm=cve;Bt();Ot();Pt();Bt();Ot();Pt();Bt();Ot();Pt();function lR(n,i,o){let c=o.config.validateStatus;!o.status||!c||c(o.status)?n(o):i(new Ti("Request failed with status code "+o.status,[Ti.ERR_BAD_REQUEST,Ti.ERR_BAD_RESPONSE][Math.floor(o.status/100)-4],o.config,o.request,o))}Bt();Ot();Pt();function O8t(n){let i=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return i&&i[1]||""}Bt();Ot();Pt();Bt();Ot();Pt();function Bdr(n,i){n=n||10;let o=new Array(n),c=new Array(n),e=0,p=0,d;return i=i!==void 0?i:1e3,function(_){let y=Date.now(),w=c[p];d||(d=y),o[e]=_,c[e]=y;let M=p,S=0;for(;M!==e;)S+=o[M++],M=M%n;if(e=(e+1)%n,e===p&&(p=(p+1)%n),y-d<i)return;let E=w&&y-w;return E?Math.round(S*1e3/E):void 0}}var dve=Bdr;Bt();Ot();Pt();function Pdr(n,i){let o=0,c=1e3/i,e,p,d=(y,w=Date.now())=>{o=w,e=null,p&&(clearTimeout(p),p=null),n.apply(null,y)};return[(...y)=>{let w=Date.now(),M=w-o;M>=c?d(y,w):(e=y,p||(p=setTimeout(()=>{p=null,d(e)},c-M)))},()=>e&&d(e)]}var pve=Pdr;var $w=(n,i,o=3)=>{let c=0,e=dve(50,250);return pve(p=>{let d=p.loaded,b=p.lengthComputable?p.total:void 0,_=d-c,y=e(_),w=d<=b;c=d;let M={loaded:d,total:b,progress:b?d/b:void 0,bytes:_,rate:y||void 0,estimated:y&&b&&w?(b-d)/y:void 0,event:p,lengthComputable:b!=null,[i?"download":"upload"]:!0};n(M)},o)},N8t=(n,i)=>{let o=n!=null;return[c=>i[0]({lengthComputable:o,total:n,loaded:c}),i[1]]},C8t=n=>(...i)=>ur.asap(()=>n(...i));Bt();Ot();Pt();Bt();Ot();Pt();var mve=ds.hasStandardBrowserEnv?((n,i)=>o=>(o=new URL(o,ds.origin),n.protocol===o.protocol&&n.host===o.host&&(i||n.port===o.port)))(new URL(ds.origin),ds.navigator&&/(msie|trident)/i.test(ds.navigator.userAgent)):()=>!0;Bt();Ot();Pt();var vve=ds.hasStandardBrowserEnv?{write(n,i,o,c,e,p){let d=[n+"="+encodeURIComponent(i)];ur.isNumber(o)&&d.push("expires="+new Date(o).toGMTString()),ur.isString(c)&&d.push("path="+c),ur.isString(e)&&d.push("domain="+e),p===!0&&d.push("secure"),document.cookie=d.join("; ")},read(n){let i=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return i?decodeURIComponent(i[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};Bt();Ot();Pt();Bt();Ot();Pt();function L8t(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}Bt();Ot();Pt();function D8t(n,i){return i?n.replace(/\/?\/$/,"")+"/"+i.replace(/^\/+/,""):n}function cR(n,i,o){let c=!L8t(i);return n&&(c||o==!1)?D8t(n,i):i}Bt();Ot();Pt();var gve=n=>n instanceof Rf?{...n}:n;function C1(n,i){i=i||{};let o={};function c(y,w,M,S){return ur.isPlainObject(y)&&ur.isPlainObject(w)?ur.merge.call({caseless:S},y,w):ur.isPlainObject(w)?ur.merge({},w):ur.isArray(w)?w.slice():w}function e(y,w,M,S){if(ur.isUndefined(w)){if(!ur.isUndefined(y))return c(void 0,y,M,S)}else return c(y,w,M,S)}function p(y,w){if(!ur.isUndefined(w))return c(void 0,w)}function d(y,w){if(ur.isUndefined(w)){if(!ur.isUndefined(y))return c(void 0,y)}else return c(void 0,w)}function b(y,w,M){if(M in i)return c(y,w);if(M in n)return c(void 0,y)}let _={url:p,method:p,data:p,baseURL:d,transformRequest:d,transformResponse:d,paramsSerializer:d,timeout:d,timeoutMessage:d,withCredentials:d,withXSRFToken:d,adapter:d,responseType:d,xsrfCookieName:d,xsrfHeaderName:d,onUploadProgress:d,onDownloadProgress:d,decompress:d,maxContentLength:d,maxBodyLength:d,beforeRedirect:d,transport:d,httpAgent:d,httpsAgent:d,cancelToken:d,socketPath:d,responseEncoding:d,validateStatus:b,headers:(y,w,M)=>e(gve(y),gve(w),M,!0)};return ur.forEach(Object.keys(Object.assign({},n,i)),function(w){let M=_[w]||e,S=M(n[w],i[w],w);ur.isUndefined(S)&&M!==b||(o[w]=S)}),o}var Zz=n=>{let i=C1({},n),{data:o,withXSRFToken:c,xsrfHeaderName:e,xsrfCookieName:p,headers:d,auth:b}=i;i.headers=d=Rf.from(d),i.url=sR(cR(i.baseURL,i.url,i.allowAbsoluteUrls),n.params,n.paramsSerializer),b&&d.set("Authorization","Basic "+btoa((b.username||"")+":"+(b.password?unescape(encodeURIComponent(b.password)):"")));let _;if(ur.isFormData(o)){if(ds.hasStandardBrowserEnv||ds.hasStandardBrowserWebWorkerEnv)d.setContentType(void 0);else if((_=d.getContentType())!==!1){let[y,...w]=_?_.split(";").map(M=>M.trim()).filter(Boolean):[];d.setContentType([y||"multipart/form-data",...w].join("; "))}}if(ds.hasStandardBrowserEnv&&(c&&ur.isFunction(c)&&(c=c(i)),c||c!==!1&&mve(i.url))){let y=e&&p&&vve.read(p);y&&d.set(e,y)}return i};var Odr=typeof XMLHttpRequest<"u",bve=Odr&&function(n){return new Promise(function(o,c){let e=Zz(n),p=e.data,d=Rf.from(e.headers).normalize(),{responseType:b,onUploadProgress:_,onDownloadProgress:y}=e,w,M,S,E,x;function k(){E&&E(),x&&x(),e.cancelToken&&e.cancelToken.unsubscribe(w),e.signal&&e.signal.removeEventListener("abort",w)}let T=new XMLHttpRequest;T.open(e.method.toUpperCase(),e.url,!0),T.timeout=e.timeout;function B(){if(!T)return;let O=Rf.from("getAllResponseHeaders"in T&&T.getAllResponseHeaders()),j={data:!b||b==="text"||b==="json"?T.responseText:T.response,status:T.status,statusText:T.statusText,headers:O,config:n,request:T};lR(function(V){o(V),k()},function(V){c(V),k()},j),T=null}"onloadend"in T?T.onloadend=B:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(B)},T.onabort=function(){T&&(c(new Ti("Request aborted",Ti.ECONNABORTED,n,T)),T=null)},T.onerror=function(){c(new Ti("Network Error",Ti.ERR_NETWORK,n,T)),T=null},T.ontimeout=function(){let q=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",j=e.transitional||Kz;e.timeoutErrorMessage&&(q=e.timeoutErrorMessage),c(new Ti(q,j.clarifyTimeoutError?Ti.ETIMEDOUT:Ti.ECONNABORTED,n,T)),T=null},p===void 0&&d.setContentType(null),"setRequestHeader"in T&&ur.forEach(d.toJSON(),function(q,j){T.setRequestHeader(j,q)}),ur.isUndefined(e.withCredentials)||(T.withCredentials=!!e.withCredentials),b&&b!=="json"&&(T.responseType=e.responseType),y&&([S,x]=$w(y,!0),T.addEventListener("progress",S)),_&&T.upload&&([M,E]=$w(_),T.upload.addEventListener("progress",M),T.upload.addEventListener("loadend",E)),(e.cancelToken||e.signal)&&(w=O=>{T&&(c(!O||O.type?new vm(null,n,T):O),T.abort(),T=null)},e.cancelToken&&e.cancelToken.subscribe(w),e.signal&&(e.signal.aborted?w():e.signal.addEventListener("abort",w)));let P=O8t(e.url);if(P&&ds.protocols.indexOf(P)===-1){c(new Ti("Unsupported protocol "+P+":",Ti.ERR_BAD_REQUEST,n));return}T.send(p||null)})};Bt();Ot();Pt();Bt();Ot();Pt();var Ndr=(n,i)=>{let{length:o}=n=n?n.filter(Boolean):[];if(i||o){let c=new AbortController,e,p=function(y){if(!e){e=!0,b();let w=y instanceof Error?y:this.reason;c.abort(w instanceof Ti?w:new vm(w instanceof Error?w.message:w))}},d=i&&setTimeout(()=>{d=null,p(new Ti(`timeout ${i} of ms exceeded`,Ti.ETIMEDOUT))},i),b=()=>{n&&(d&&clearTimeout(d),d=null,n.forEach(y=>{y.unsubscribe?y.unsubscribe(p):y.removeEventListener("abort",p)}),n=null)};n.forEach(y=>y.addEventListener("abort",p));let{signal:_}=c;return _.unsubscribe=()=>ur.asap(b),_}},yve=Ndr;Bt();Ot();Pt();var Cdr=function*(n,i){let o=n.byteLength;if(!i||o<i){yield n;return}let c=0,e;for(;c<o;)e=c+i,yield n.slice(c,e),c=e},Ldr=async function*(n,i){for await(let o of Ddr(n))yield*Cdr(o,i)},Ddr=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}let i=n.getReader();try{for(;;){let{done:o,value:c}=await i.read();if(o)break;yield c}}finally{await i.cancel()}},$8t=(n,i,o,c)=>{let e=Ldr(n,i),p=0,d,b=_=>{d||(d=!0,c&&c(_))};return new ReadableStream({async pull(_){try{let{done:y,value:w}=await e.next();if(y){b(),_.close();return}let M=w.byteLength;if(o){let S=p+=M;o(S)}_.enqueue(new Uint8Array(w))}catch(y){throw b(y),y}},cancel(_){return b(_),e.return()}},{highWaterMark:2})};var Gz=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",_ve=Gz&&typeof ReadableStream=="function",$dr=Gz&&(typeof TextEncoder=="function"?(n=>i=>n.encode(i))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),Mve=(n,...i)=>{try{return!!n(...i)}catch{return!1}},qdr=_ve&&Mve(()=>{let n=!1,i=new Request(ds.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!i}),wve=64*1024,q8t=_ve&&Mve(()=>ur.isReadableStream(new Response("").body)),Vz={stream:q8t&&(n=>n.body)};Gz&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(i=>{!Vz[i]&&(Vz[i]=ur.isFunction(n[i])?o=>o[i]():(o,c)=>{throw new Ti(`Response type '${i}' is not supported`,Ti.ERR_NOT_SUPPORT,c)})})})(new Response);var Udr=async n=>{if(n==null)return 0;if(ur.isBlob(n))return n.size;if(ur.isSpecCompliantForm(n))return(await new Request(ds.origin,{method:"POST",body:n}).arrayBuffer()).byteLength;if(ur.isArrayBufferView(n)||ur.isArrayBuffer(n))return n.byteLength;if(ur.isURLSearchParams(n)&&(n=n+""),ur.isString(n))return(await $dr(n)).byteLength},jdr=async(n,i)=>{let o=ur.toFiniteNumber(n.getContentLength());return o??Udr(i)},Sve=Gz&&(async n=>{let{url:i,method:o,data:c,signal:e,cancelToken:p,timeout:d,onDownloadProgress:b,onUploadProgress:_,responseType:y,headers:w,withCredentials:M="same-origin",fetchOptions:S}=Zz(n);y=y?(y+"").toLowerCase():"text";let E=yve([e,p&&p.toAbortSignal()],d),x,k=E&&E.unsubscribe&&(()=>{E.unsubscribe()}),T;try{if(_&&qdr&&o!=="get"&&o!=="head"&&(T=await jdr(w,c))!==0){let j=new Request(i,{method:"POST",body:c,duplex:"half"}),Y;if(ur.isFormData(c)&&(Y=j.headers.get("content-type"))&&w.setContentType(Y),j.body){let[V,K]=N8t(T,$w(C8t(_)));c=$8t(j.body,wve,V,K)}}ur.isString(M)||(M=M?"include":"omit");let B="credentials"in Request.prototype;x=new Request(i,{...S,signal:E,method:o.toUpperCase(),headers:w.normalize().toJSON(),body:c,duplex:"half",credentials:B?M:void 0});let P=await fetch(x),O=q8t&&(y==="stream"||y==="response");if(q8t&&(b||O&&k)){let j={};["status","statusText","headers"].forEach(Q=>{j[Q]=P[Q]});let Y=ur.toFiniteNumber(P.headers.get("content-length")),[V,K]=b&&N8t(Y,$w(C8t(b),!0))||[];P=new Response($8t(P.body,wve,V,()=>{K&&K(),k&&k()}),j)}y=y||"text";let q=await Vz[ur.findKey(Vz,y)||"text"](P,n);return!O&&k&&k(),await new Promise((j,Y)=>{lR(j,Y,{data:q,headers:Rf.from(P.headers),status:P.status,statusText:P.statusText,config:n,request:x})})}catch(B){throw k&&k(),B&&B.name==="TypeError"&&/fetch/i.test(B.message)?Object.assign(new Ti("Network Error",Ti.ERR_NETWORK,n,x),{cause:B.cause||B}):Ti.from(B,B&&B.code,n,x)}});var U8t={http:Fz,xhr:bve,fetch:Sve};ur.forEach(U8t,(n,i)=>{if(n){try{Object.defineProperty(n,"name",{value:i})}catch{}Object.defineProperty(n,"adapterName",{value:i})}});var Eve=n=>`- ${n}`,Fdr=n=>ur.isFunction(n)||n===null||n===!1,Yz={getAdapter:n=>{n=ur.isArray(n)?n:[n];let{length:i}=n,o,c,e={};for(let p=0;p<i;p++){o=n[p];let d;if(c=o,!Fdr(o)&&(c=U8t[(d=String(o)).toLowerCase()],c===void 0))throw new Ti(`Unknown adapter '${d}'`);if(c)break;e[d||"#"+p]=c}if(!c){let p=Object.entries(e).map(([b,_])=>`adapter ${b} `+(_===!1?"is not supported by the environment":"is not available in the build")),d=i?p.length>1?`since :
283
283
  `+p.map(Eve).join(`
284
284
  `):" "+Eve(p[0]):"as no adapter specified";throw new Ti("There is no suitable adapter to dispatch the request "+d,"ERR_NOT_SUPPORT")}return c},adapters:U8t};function j8t(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new vm(null,n)}function Xz(n){return j8t(n),n.headers=Rf.from(n.headers),n.data=hR.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Yz.getAdapter(n.adapter||Lw.adapter)(n).then(function(c){return j8t(n),c.data=hR.call(n,n.transformResponse,c),c.headers=Rf.from(c.headers),c},function(c){return uR(c)||(j8t(n),c&&c.response&&(c.response.data=hR.call(n,n.transformResponse,c.response),c.response.headers=Rf.from(c.response.headers))),Promise.reject(c)})}Bt();Ot();Pt();Bt();Ot();Pt();var Jz="1.8.4";var Qz={};["object","boolean","number","function","string","symbol"].forEach((n,i)=>{Qz[n]=function(c){return typeof c===n||"a"+(i<1?"n ":" ")+n}});var xve={};Qz.transitional=function(i,o,c){function e(p,d){return"[Axios v"+Jz+"] Transitional option '"+p+"'"+d+(c?". "+c:"")}return(p,d,b)=>{if(i===!1)throw new Ti(e(d," has been removed"+(o?" in "+o:"")),Ti.ERR_DEPRECATED);return o&&!xve[d]&&(xve[d]=!0,console.warn(e(d," has been deprecated since v"+o+" and will be removed in the near future"))),i?i(p,d,b):!0}};Qz.spelling=function(i){return(o,c)=>(console.warn(`${c} is likely a misspelling of ${i}`),!0)};function zdr(n,i,o){if(typeof n!="object")throw new Ti("options must be an object",Ti.ERR_BAD_OPTION_VALUE);let c=Object.keys(n),e=c.length;for(;e-- >0;){let p=c[e],d=i[p];if(d){let b=n[p],_=b===void 0||d(b,p,n);if(_!==!0)throw new Ti("option "+p+" must be "+_,Ti.ERR_BAD_OPTION_VALUE);continue}if(o!==!0)throw new Ti("Unknown option "+p,Ti.ERR_BAD_OPTION)}}var dR={assertOptions:zdr,validators:Qz};var gm=dR.validators,qw=class{constructor(i){this.defaults=i,this.interceptors={request:new A8t,response:new A8t}}async request(i,o){try{return await this._request(i,o)}catch(c){if(c instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;let p=e.stack?e.stack.replace(/^.+\n/,""):"";try{c.stack?p&&!String(c.stack).endsWith(p.replace(/^.+\n.+\n/,""))&&(c.stack+=`
285
- `+p):c.stack=p}catch{}}throw c}}_request(i,o){typeof i=="string"?(o=o||{},o.url=i):o=i||{},o=C1(this.defaults,o);let{transitional:c,paramsSerializer:e,headers:p}=o;c!==void 0&&dR.assertOptions(c,{silentJSONParsing:gm.transitional(gm.boolean),forcedJSONParsing:gm.transitional(gm.boolean),clarifyTimeoutError:gm.transitional(gm.boolean)},!1),e!=null&&(ur.isFunction(e)?o.paramsSerializer={serialize:e}:dR.assertOptions(e,{encode:gm.function,serialize:gm.function},!0)),o.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?o.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:o.allowAbsoluteUrls=!0),dR.assertOptions(o,{baseUrl:gm.spelling("baseURL"),withXsrfToken:gm.spelling("withXSRFToken")},!0),o.method=(o.method||this.defaults.method||"get").toLowerCase();let d=p&&ur.merge(p.common,p[o.method]);p&&ur.forEach(["delete","get","head","post","put","patch","common"],x=>{delete p[x]}),o.headers=Rf.concat(d,p);let b=[],_=!0;this.interceptors.request.forEach(function(k){typeof k.runWhen=="function"&&k.runWhen(o)===!1||(_=_&&k.synchronous,b.unshift(k.fulfilled,k.rejected))});let y=[];this.interceptors.response.forEach(function(k){y.push(k.fulfilled,k.rejected)});let w,M=0,S;if(!_){let x=[Xz.bind(this),void 0];for(x.unshift.apply(x,b),x.push.apply(x,y),S=x.length,w=Promise.resolve(o);M<S;)w=w.then(x[M++],x[M++]);return w}S=b.length;let E=o;for(M=0;M<S;){let x=b[M++],k=b[M++];try{E=x(E)}catch(T){k.call(this,T);break}}try{w=Xz.call(this,E)}catch(x){return Promise.reject(x)}for(M=0,S=y.length;M<S;)w=w.then(y[M++],y[M++]);return w}getUri(i){i=C1(this.defaults,i);let o=cR(i.baseURL,i.url,i.allowAbsoluteUrls);return sR(o,i.params,i.paramsSerializer)}};ur.forEach(["delete","get","head","options"],function(i){qw.prototype[i]=function(o,c){return this.request(C1(c||{},{method:i,url:o,data:(c||{}).data}))}});ur.forEach(["post","put","patch"],function(i){function o(c){return function(p,d,b){return this.request(C1(b||{},{method:i,headers:c?{"Content-Type":"multipart/form-data"}:{},url:p,data:d}))}}qw.prototype[i]=o(),qw.prototype[i+"Form"]=o(!0)});var pR=qw;Bt();Ot();Pt();var F8t=class n{constructor(i){if(typeof i!="function")throw new TypeError("executor must be a function.");let o;this.promise=new Promise(function(p){o=p});let c=this;this.promise.then(e=>{if(!c._listeners)return;let p=c._listeners.length;for(;p-- >0;)c._listeners[p](e);c._listeners=null}),this.promise.then=e=>{let p,d=new Promise(b=>{c.subscribe(b),p=b}).then(e);return d.cancel=function(){c.unsubscribe(p)},d},i(function(p,d,b){c.reason||(c.reason=new vm(p,d,b),o(c.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(i){if(this.reason){i(this.reason);return}this._listeners?this._listeners.push(i):this._listeners=[i]}unsubscribe(i){if(!this._listeners)return;let o=this._listeners.indexOf(i);o!==-1&&this._listeners.splice(o,1)}toAbortSignal(){let i=new AbortController,o=c=>{i.abort(c)};return this.subscribe(o),i.signal.unsubscribe=()=>this.unsubscribe(o),i.signal}static source(){let i;return{token:new n(function(e){i=e}),cancel:i}}},Ave=F8t;Bt();Ot();Pt();function z8t(n){return function(o){return n.apply(null,o)}}Bt();Ot();Pt();function K8t(n){return ur.isObject(n)&&n.isAxiosError===!0}Bt();Ot();Pt();var H8t={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(H8t).forEach(([n,i])=>{H8t[i]=n});var Rve=H8t;function kve(n){let i=new pR(n),o=nR(pR.prototype.request,i);return ur.extend(o,pR.prototype,i,{allOwnKeys:!0}),ur.extend(o,i,null,{allOwnKeys:!0}),o.create=function(e){return kve(C1(n,e))},o}var tf=kve(Lw);tf.Axios=pR;tf.CanceledError=vm;tf.CancelToken=Ave;tf.isCancel=uR;tf.VERSION=Jz;tf.toFormData=fb;tf.AxiosError=Ti;tf.Cancel=tf.CanceledError;tf.all=function(i){return Promise.all(i)};tf.spread=z8t;tf.isAxiosError=K8t;tf.mergeConfig=C1;tf.AxiosHeaders=Rf;tf.formToJSON=n=>Hz(ur.isHTMLForm(n)?new FormData(n):n);tf.getAdapter=Yz.getAdapter;tf.HttpStatusCode=Rve;tf.default=tf;var tK=tf;var{Axios:tGr,AxiosError:eGr,CanceledError:rGr,isCancel:iGr,CancelToken:nGr,VERSION:aGr,all:oGr,Cancel:sGr,isAxiosError:fGr,spread:hGr,toFormData:uGr,AxiosHeaders:lGr,HttpStatusCode:cGr,formToJSON:dGr,getAdapter:pGr,mergeConfig:mGr}=tK;Bt();Ot();Pt();var Pve=va(Ive(),1),W8t="axios-retry";function Ove(n){let i=["ERR_CANCELED","ECONNABORTED"];return n.response||!n.code||i.includes(n.code)?!1:(0,Pve.default)(n)}var Nve=["get","head","options"],Hdr=Nve.concat(["put","delete"]);function Z8t(n){return n.code!=="ECONNABORTED"&&(!n.response||n.response.status===429||n.response.status>=500&&n.response.status<=599)}function Wdr(n){return n.config?.method?Z8t(n)&&Nve.indexOf(n.config.method)!==-1:!1}function Cve(n){return n.config?.method?Z8t(n)&&Hdr.indexOf(n.config.method)!==-1:!1}function Lve(n){return Ove(n)||Cve(n)}function V8t(n=void 0){let i=n?.response?.headers["retry-after"];if(!i)return 0;let o=(Number(i)||0)*1e3;return o===0&&(o=(new Date(i).valueOf()||0)-Date.now()),Math.max(0,o)}function Zdr(n=0,i=void 0){return Math.max(0,V8t(i))}function Vdr(n=0,i=void 0,o=100){let c=2**n*o,e=Math.max(c,V8t(i)),p=e*.2*Math.random();return e+p}function Gdr(n=100){return(i=0,o=void 0)=>{let c=i*n;return Math.max(c,V8t(o))}}var Ydr={retries:3,retryCondition:Lve,retryDelay:Zdr,shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function Xdr(n,i){return{...Ydr,...i,...n[W8t]}}function Bve(n,i,o=!1){let c=Xdr(n,i||{});return c.retryCount=c.retryCount||0,(!c.lastRequestTime||o)&&(c.lastRequestTime=Date.now()),n[W8t]=c,c}function Jdr(n,i){n.defaults.agent===i.agent&&delete i.agent,n.defaults.httpAgent===i.httpAgent&&delete i.httpAgent,n.defaults.httpsAgent===i.httpsAgent&&delete i.httpsAgent}async function Qdr(n,i){let{retries:o,retryCondition:c}=n,e=(n.retryCount||0)<o&&c(i);if(typeof e=="object")try{return await e!==!1}catch{return!1}return e}async function t1r(n,i,o,c){i.retryCount+=1;let{retryDelay:e,shouldResetTimeout:p,onRetry:d}=i,b=e(i.retryCount,o);if(Jdr(n,c),!p&&c.timeout&&i.lastRequestTime){let _=Date.now()-i.lastRequestTime,y=c.timeout-_-b;if(y<=0)return Promise.reject(o);c.timeout=y}return c.transformRequest=[_=>_],await d(i.retryCount,o,c),c.signal?.aborted?Promise.resolve(n(c)):new Promise(_=>{let y=()=>{clearTimeout(w),_(n(c))},w=setTimeout(()=>{_(n(c)),c.signal?.removeEventListener&&c.signal.removeEventListener("abort",y)},b);c.signal?.addEventListener&&c.signal.addEventListener("abort",y,{once:!0})})}async function e1r(n,i){n.retryCount>=n.retries&&await n.onMaxRetryTimesExceeded(i,n.retryCount)}var hb=(n,i)=>{let o=n.interceptors.request.use(e=>(Bve(e,i,!0),e[W8t]?.validateResponse&&(e.validateStatus=()=>!1),e)),c=n.interceptors.response.use(null,async e=>{let{config:p}=e;if(!p)return Promise.reject(e);let d=Bve(p,i);return e.response&&d.validateResponse?.(e.response)?e.response:await Qdr(d,e)?t1r(n,d,e,p):(await e1r(d,e),Promise.reject(e))});return{requestInterceptorId:o,responseInterceptorId:c}};hb.isNetworkError=Ove;hb.isSafeRequestError=Wdr;hb.isIdempotentRequestError=Cve;hb.isNetworkOrIdempotentRequestError=Lve;hb.exponentialDelay=Vdr;hb.linearDelay=Gdr;hb.isRetryableError=Z8t;var eK=hb;var Dve=({axiosConfig:n={},logger:i=v0.default,retryConfig:o={retries:5,retryDelay:eK.exponentialDelay,retryCondition:c=>eK.isRetryableError(c),onRetry(c,e,p){i.error(`Retrying request ${p.url} attempt ${c}`,e)}}}={})=>{let c=tK.create({...n,maxRedirects:0,headers:{...n.headers,"x-source-version":`${Pw}`,"x-source-identifier":"ar-io-sdk"},validateStatus:()=>!0});return eK(c,o),c};Bt();Ot();Pt();var G8t=({baseUrl:n,params:i})=>{let o=new URL(n);return Object.entries(i).forEach(([c,e])=>{e!=null&&o.searchParams.set(c,e.toString())}),o.toString()};async function r1r({signer:n,nonce:i=y8t()}){let o,c,e=rK(n)?wi.ARWEAVE:n.signatureType;switch(rK(n)?o=Ow(Zt.from(await n.signMessage(Uint8Array.from(Zt.from(i))))):n instanceof Wd?o=Ow(Zt.from(await n.signer.signMessage(Uint8Array.from(Zt.from(i))))):(n instanceof Od||n instanceof ch||n instanceof M3)&&("setPublicKey"in n&&n.publicKey===void 0&&await n.setPublicKey(),o=Ow(Zt.from(await n.sign(Uint8Array.from(Zt.from(i)))))),e){case wi.ARWEAVE:rK(n)?c=await n.getActivePublicKey():"setPublicKey"in n&&(await n.setPublicKey(),c=Ow(n.publicKey));break;case wi.ETHEREUM:if("publicKey"in n)c="0x"+n.publicKey.toString("hex");else throw new Error("Public key not found");break;default:throw new Error(`Unsupported signer type for signing requests: ${e}`)}if(c===void 0||o===void 0)throw new Error("Public key or signature not found");return{"x-public-key":c,"x-nonce":i,"x-signature":o,"x-signature-type":e.toString()}}var mR=class{static init(i){let{signer:o,paymentUrl:c,axios:e,logger:p}=i??{};return o!==void 0?new ub({signer:o,paymentUrl:c,axios:e,logger:p}):new iK({paymentUrl:c,axios:e,logger:p})}},iK=class{paymentUrl;axios;logger;constructor({paymentUrl:i="https://payment.ardrive.io",axios:o=Dve(),logger:c=v0.default}){this.paymentUrl=i,this.axios=o,this.logger=c}async getArNSPriceDetails({intent:i,name:o,quantity:c,type:e,years:p}){let d=G8t({baseUrl:`${this.paymentUrl}/v1/arns/price/${i}/${o}`,params:{increaseQty:c,type:e,years:p}}),{data:b,status:_}=await this.axios.get(d);if(this.logger.debug("getArNSPriceDetails",{intent:i,name:o,quantity:c,type:e,years:p,data:b,status:_}),_!==200)throw new Error("Failed to get ArNS purchase price "+JSON.stringify(b));if(!b.winc||!b.mARIO)throw new Error("Invalid response from Turbo "+JSON.stringify(b));return{winc:b.winc,mARIO:new iR(+b.mARIO)}}async getPrice(i){let{winc:o}=await this.getArNSPriceDetails(i);return+o}},ub=class extends iK{signer;constructor({signer:i,...o}){if(super(o),!Y8t(i))throw new Error("Signer must be a TurboArNSSigner");this.signer=i}async initiateArNSPurchase({intent:i,name:o,quantity:c,type:e,processId:p,years:d}){let b=G8t({baseUrl:`${this.paymentUrl}/v1/arns/purchase/${i}/${o}`,params:{increaseQty:c,processId:p,type:e,years:d}}),_=await r1r({signer:this.signer}),{data:y,status:w}=await this.axios.post(b,null,{headers:_});if(this.logger.debug("Initiated ArNS purchase",{intent:i,name:o,quantity:c,processId:p,type:e,years:d,data:y,status:w}),w!==200)throw new Error("Failed to initiate ArNS purchase "+JSON.stringify(y));return{id:y.arioWriteResult.id,result:y.purchaseReceipt}}};function rK(n){return typeof n=="object"&&n!==null&&"signMessage"in n&&"getActivePublicKey"in n}function Y8t(n){let i=rK(n),o=n instanceof ch||n instanceof M3||n instanceof Od||n instanceof Wd;return i||o}var gR=class{static init(i){return i!==void 0&&"signer"in i?new vR(i):new Uw(i)}static mainnet(i){return i!==void 0&&"signer"in i?new vR({...i,process:new cs({processId:Fu,ao:sl({MODE:"legacy",CU_URL:"https://cu.ardrive.io",...i?.process?.ao})})}):new Uw({...i,process:new cs({processId:Fu,ao:sl({CU_URL:"https://cu.ardrive.io",MODE:"legacy",...i?.process?.ao})})})}static testnet(i){return i!==void 0&&"signer"in i?v8t({arioInstance:new vR({...i,process:new cs({processId:unt,ao:sl({MODE:"legacy",CU_URL:"https://cu.ardrive.io",...i?.process?.ao})})}),faucetApiUrl:i?.faucetUrl}):v8t({arioInstance:new Uw({...i,process:new cs({processId:unt,ao:sl({MODE:"legacy",CU_URL:"https://cu.ardrive.io",...i?.process?.ao})})}),faucetApiUrl:i?.faucetUrl})}},Uw=class{process;epochSettings;arweave;paymentProvider;constructor(i){if(this.arweave=i?.arweave??xF,i===void 0||Object.keys(i).length===0)this.process=new cs({processId:Fu});else if(ob(i))this.process=i.process;else if(sb(i))this.process=new cs({processId:i.processId});else throw new hm;this.paymentProvider=mR.init({paymentUrl:i?.paymentUrl})}async getInfo(){return this.process.read({tags:[{name:"Action",value:"Info"}]})}async getTokenSupply(){return this.process.read({tags:[{name:"Action",value:"Total-Token-Supply"}]})}async computeEpochIndexForTimestamp(i){let o=await this.getEpochSettings(),c=o.epochZeroStartTimestamp,e=o.durationMs;return Math.floor((i-c)/e)}async computeCurrentEpochIndex(){return this.computeEpochIndexForTimestamp(Date.now())}async computeEpochIndex(i){let o=i?.epochIndex;if(o!==void 0)return o;let c=i?.timestamp;if(c!==void 0)return this.computeEpochIndexForTimestamp(c)}async getEpochSettings(){return this.epochSettings??=await this.process.read({tags:[{name:"Action",value:"Epoch-Settings"}]})}async getEpoch(i){let o=await this.computeEpochIndex(i),c=await this.computeCurrentEpochIndex();if(o!==void 0&&o<c){let p=await C8({arweave:this.arweave,epochIndex:o,processId:this.process.processId,ao:this.process.ao});if(!p)throw new Error("Epoch data not found for epoch index "+o);return qve(p)}let e=[{name:"Action",value:"Epoch"},{name:"Epoch-Index",value:c.toString()}];return this.process.read({tags:Go(e)})}async getArNSRecord({name:i}){return this.process.read({tags:[{name:"Action",value:"Record"},{name:"Name",value:i}]})}async getArNSRecords(i){return this.process.read({tags:[{name:"Action",value:"Paginated-Records"},...eu(i)]})}async getArNSReservedNames(i){return this.process.read({tags:[{name:"Action",value:"Reserved-Names"},...eu(i)]})}async getArNSReservedName({name:i}){return this.process.read({tags:[{name:"Action",value:"Reserved-Name"},{name:"Name",value:i}]})}async getBalance({address:i}){return this.process.read({tags:[{name:"Action",value:"Balance"},{name:"Address",value:i}]})}async getBalances(i){return this.process.read({tags:[{name:"Action",value:"Paginated-Balances"},...eu(i)]})}async getVault({address:i,vaultId:o}){return this.process.read({tags:[{name:"Action",value:"Vault"},{name:"Address",value:i},{name:"Vault-Id",value:o}]})}async getVaults(i){return this.process.read({tags:[{name:"Action",value:"Paginated-Vaults"},...eu(i)]})}async getGateway({address:i}){return this.process.read({tags:[{name:"Action",value:"Gateway"},{name:"Address",value:i}]})}async getGatewayDelegates({address:i,...o}){return this.process.read({tags:[{name:"Action",value:"Paginated-Delegates"},{name:"Address",value:i},...eu(o)]})}async getGatewayDelegateAllowList({address:i,...o}){return this.process.read({tags:[{name:"Action",value:"Paginated-Allowed-Delegates"},{name:"Address",value:i},...eu(o)]})}async getGateways(i){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateways"},...eu(i)]})}async getCurrentEpoch(){return this.process.read({tags:[{name:"Action",value:"Epoch"}]})}async getPrescribedObservers(i){let o=await this.computeEpochIndex(i),c=await this.computeCurrentEpochIndex();if(o!==void 0&&o<c){let p=await C8({ao:this.process.ao,arweave:this.arweave,epochIndex:o,processId:this.process.processId});if(!p)throw new Error("Epoch data not found for epoch index "+o);return p.prescribedObservers}let e=[{name:"Action",value:"Epoch-Prescribed-Observers"},{name:"Epoch-Index",value:c.toString()}];return this.process.read({tags:Go(e)})}async getPrescribedNames(i){let o=await this.computeEpochIndex(i),c=await this.computeCurrentEpochIndex();if(o!==void 0&&o<c){let p=await C8({arweave:this.arweave,epochIndex:o,processId:this.process.processId,ao:this.process.ao});if(!p)throw new Error("Epoch data not found for epoch index "+o);return p.prescribedNames}let e=[{name:"Action",value:"Epoch-Prescribed-Names"},{name:"Epoch-Index",value:c.toString()}];return this.process.read({tags:Go(e)})}async getObservations(i){let o=await this.computeEpochIndex(i),c=await this.computeCurrentEpochIndex();if(o!==void 0&&o<c){let p=await C8({arweave:this.arweave,epochIndex:o,processId:this.process.processId,ao:this.process.ao});if(!p)throw new Error("Epoch data not found for epoch index "+o);return p.observations}let e=[{name:"Action",value:"Epoch-Observations"},{name:"Epoch-Index",value:c.toString()}];return this.process.read({tags:Go(e)})}async getDistributions(i){let o=await this.computeEpochIndex(i),c=await this.computeCurrentEpochIndex();if(o!==void 0&&o<c){let p=await C8({arweave:this.arweave,epochIndex:o,processId:this.process.processId,ao:this.process.ao});if(p===void 0)throw new Error("Epoch data not found for epoch index "+o);return p.distributions}let e=[{name:"Action",value:"Epoch-Distributions"},{name:"Epoch-Index",value:c.toString()}];return this.process.read({tags:Go(e)})}async getEligibleEpochRewards(i,o){let c=await this.computeEpochIndex(i),e=await this.computeCurrentEpochIndex();if(c!==void 0&&c<e){let d=await C8({arweave:this.arweave,epochIndex:c,processId:this.process.processId,ao:this.process.ao});if(!d)throw new Error("Epoch data not found for epoch index "+c);return $ve(d,o)}let p=[{name:"Action",value:"Epoch-Eligible-Rewards"},...eu(o)];return this.process.read({tags:Go(p)})}async getTokenCost({intent:i,type:o,years:c,name:e,quantity:p,fromAddress:d}){let _=[{name:"Action",value:"Token-Cost"},{name:"Intent",value:i==="Buy-Record"?"Buy-Name":i},{name:"Name",value:e},{name:"Years",value:c?.toString()},{name:"Quantity",value:p?.toString()},{name:"Purchase-Type",value:o}];return this.process.read({tags:Go(_),fromAddress:d})}async getCostDetails({intent:i,type:o,years:c,name:e,quantity:p,fromAddress:d,fundFrom:b}){let _=i==="Buy-Record"?"Buy-Name":i;if(b==="turbo"){let{mARIO:w,winc:M}=await this.paymentProvider.getArNSPriceDetails({intent:_,name:e,quantity:p,type:o,years:c});return{tokenCost:w.valueOf(),wincQty:M,discounts:[]}}let y=[{name:"Action",value:"Cost-Details"},{name:"Intent",value:_},{name:"Name",value:e},{name:"Years",value:c?.toString()},{name:"Quantity",value:p?.toString()},{name:"Purchase-Type",value:o},{name:"Fund-From",value:b}];return this.process.read({tags:Go(y),fromAddress:d})}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(i){return this.process.read({tags:[{name:"Action",value:"Returned-Names"},...eu(i)]})}async getArNSReturnedName({name:i}){let o=[{name:"Action",value:"Returned-Name"},{name:"Name",value:i}];return this.process.read({tags:o})}async getDelegations(i){let o=[{name:"Action",value:"Paginated-Delegations"},{name:"Address",value:i.address},...eu(i)];return this.process.read({tags:Go(o)})}async getAllowedDelegates(i){return this.getGatewayDelegateAllowList(i)}async getGatewayVaults(i){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateway-Vaults"},{name:"Address",value:i.address},...eu(i)]})}async getPrimaryNameRequest(i){let o=[{name:"Action",value:"Primary-Name-Request"},{name:"Initiator",value:i.initiator}];return this.process.read({tags:o})}async getPrimaryNameRequests(i){return this.process.read({tags:[{name:"Action",value:"Primary-Name-Requests"},...eu(i)]})}async getPrimaryName(i){let o=[{name:"Action",value:"Primary-Name"},{name:"Address",value:i?.address},{name:"Name",value:i?.name}];return this.process.read({tags:Go(o)})}async getPrimaryNames(i){return this.process.read({tags:[{name:"Action",value:"Primary-Names"},...eu(i)]})}async getRedelegationFee(i){return this.process.read({tags:[{name:"Action",value:"Redelegation-Fee"},{name:"Address",value:i.address}]})}async getGatewayRegistrySettings(){return this.process.read({tags:[{name:"Action",value:"Gateway-Registry-Settings"}]})}async getAllDelegates(i){return this.process.read({tags:[{name:"Action",value:"All-Paginated-Delegates"},...eu(i)]})}async getAllGatewayVaults(i){return this.process.read({tags:[{name:"Action",value:"All-Gateway-Vaults"},...eu(i)]})}async resolveArNSName({name:i}){let o=i.lastIndexOf("_"),c=o===-1?i:i.slice(o+1),e=o===-1?"@":i.slice(0,o),p=await this.getArNSRecord({name:c});if(p===void 0||p.processId===void 0)throw new Error(`Base ArNS name ${c} not found on ARIO contract (${this.process.processId}).`);let d=jw.init({process:new cs({ao:this.process.ao,processId:p.processId})}),[b,_]=await Promise.all([d.getOwner(),d.getRecord({undername:e})]);if(_===void 0)throw new Error(`Record for ${e} not found on ANT.`);if(_.ttlSeconds===void 0||_.transactionId===void 0)throw new Error(`Invalid record on ANT. Must have ttlSeconds and transactionId. Record: ${JSON.stringify(_)}`);return{name:i,owner:b,txId:_.transactionId,ttlSeconds:_.ttlSeconds,priority:_.priority,processId:p.processId,undernameLimit:p.undernameLimit,type:p.type}}},vR=class extends Uw{signer;paymentProvider;constructor({signer:i,paymentUrl:o,...c}){c===void 0?super({process:new cs({processId:Fu})}):super(c),this.signer=ab(i),this.paymentProvider=mR.init({signer:Y8t(i)?i:void 0,paymentUrl:o})}async transfer({target:i,qty:o},c){let{tags:e=[]}=c||{};return this.process.send({tags:[...e,{name:"Action",value:"Transfer"},{name:"Recipient",value:i},{name:"Quantity",value:o.valueOf().toString()}],signer:this.signer})}async vaultedTransfer({recipient:i,quantity:o,lockLengthMs:c,revokable:e=!1},p){let{tags:d=[]}=p||{};return this.process.send({tags:[...d,{name:"Action",value:"Vaulted-Transfer"},{name:"Recipient",value:i},{name:"Quantity",value:o.toString()},{name:"Lock-Length",value:c.toString()},{name:"Revokable",value:`${e}`}],signer:this.signer})}async revokeVault({vaultId:i,recipient:o},c){let{tags:e=[]}=c||{};return this.process.send({tags:[...e,{name:"Action",value:"Revoke-Vault"},{name:"Vault-Id",value:i},{name:"Recipient",value:o}],signer:this.signer})}async createVault({lockLengthMs:i,quantity:o},c){let{tags:e=[]}=c||{};return this.process.send({tags:[...e,{name:"Action",value:"Create-Vault"},{name:"Lock-Length",value:i.toString()},{name:"Quantity",value:o.toString()}],signer:this.signer})}async extendVault({vaultId:i,extendLengthMs:o},c){let{tags:e=[]}=c||{};return this.process.send({tags:[...e,{name:"Action",value:"Extend-Vault"},{name:"Vault-Id",value:i},{name:"Extend-Length",value:o.toString()}],signer:this.signer})}async increaseVault({vaultId:i,quantity:o},c){let{tags:e=[]}=c||{};return this.process.send({tags:[...e,{name:"Action",value:"Increase-Vault"},{name:"Vault-Id",value:i},{name:"Quantity",value:o.toString()}],signer:this.signer})}async joinNetwork({operatorStake:i,allowDelegatedStaking:o,allowedDelegates:c,delegateRewardShareRatio:e,fqdn:p,label:d,minDelegatedStake:b,note:_,port:y,properties:w,protocol:M,autoStake:S,observerAddress:E},x){let{tags:k=[]}=x||{},T=[...k,{name:"Action",value:"Join-Network"},{name:"Operator-Stake",value:i.valueOf().toString()},{name:"Allow-Delegated-Staking",value:o?.toString()},{name:"Allowed-Delegates",value:c?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:e?.toString()},{name:"FQDN",value:p},{name:"Label",value:d},{name:"Min-Delegated-Stake",value:b?.valueOf().toString()},{name:"Note",value:_},{name:"Port",value:y?.toString()},{name:"Properties",value:w},{name:"Protocol",value:M},{name:"Auto-Stake",value:S?.toString()},{name:"Observer-Address",value:E}];return this.process.send({signer:this.signer,tags:Go(T)})}async leaveNetwork(i){let{tags:o=[]}=i||{};return this.process.send({signer:this.signer,tags:[...o,{name:"Action",value:"Leave-Network"}]})}async updateGatewaySettings({allowDelegatedStaking:i,allowedDelegates:o,delegateRewardShareRatio:c,fqdn:e,label:p,minDelegatedStake:d,note:b,port:_,properties:y,protocol:w,autoStake:M,observerAddress:S},E){let{tags:x=[]}=E||{},k=[...x,{name:"Action",value:"Update-Gateway-Settings"},{name:"Label",value:p},{name:"Note",value:b},{name:"FQDN",value:e},{name:"Port",value:_?.toString()},{name:"Properties",value:y},{name:"Protocol",value:w},{name:"Observer-Address",value:S},{name:"Allow-Delegated-Staking",value:i?.toString()},{name:"Allowed-Delegates",value:o?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:c?.toString()},{name:"Min-Delegated-Stake",value:d?.valueOf().toString()},{name:"Auto-Stake",value:M?.toString()}];return this.process.send({signer:this.signer,tags:Go(k)})}async delegateStake(i,o){let{tags:c=[]}=o||{};return this.process.send({signer:this.signer,tags:[...c,{name:"Action",value:"Delegate-Stake"},{name:"Target",value:i.target},{name:"Quantity",value:i.stakeQty.valueOf().toString()}]})}async decreaseDelegateStake(i,o){let{tags:c=[]}=o||{};return this.process.send({signer:this.signer,tags:[...c,{name:"Action",value:"Decrease-Delegate-Stake"},{name:"Target",value:i.target},{name:"Quantity",value:i.decreaseQty.valueOf().toString()},{name:"Instant",value:`${i.instant||!1}`}]})}async instantWithdrawal(i,o){let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Instant-Withdrawal"},{name:"Vault-Id",value:i.vaultId},{name:"Address",value:i.gatewayAddress}];return this.process.send({signer:this.signer,tags:Go(e)})}async increaseOperatorStake(i,o){let{tags:c=[]}=o||{};return this.process.send({signer:this.signer,tags:[...c,{name:"Action",value:"Increase-Operator-Stake"},{name:"Quantity",value:i.increaseQty.valueOf().toString()}]})}async decreaseOperatorStake(i,o){let{tags:c=[]}=o||{};return this.process.send({signer:this.signer,tags:[...c,{name:"Action",value:"Decrease-Operator-Stake"},{name:"Quantity",value:i.decreaseQty.valueOf().toString()},{name:"Instant",value:`${i.instant||!1}`}]})}async saveObservations(i,o){let{tags:c=[]}=o||{};return this.process.send({signer:this.signer,tags:[...c,{name:"Action",value:"Save-Observations"},{name:"Report-Tx-Id",value:i.reportTxId},{name:"Failed-Gateways",value:i.failedGateways.join(",")}]})}async buyRecord(i,o){if(i.fundFrom==="turbo"){if(!(this.paymentProvider instanceof ub))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Buy-Name",name:i.name,years:i.years,type:i.type,processId:i.processId})}let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Buy-Name"},{name:"Name",value:i.name},{name:"Years",value:i.years?.toString()??"1"},{name:"Process-Id",value:i.processId},{name:"Purchase-Type",value:i.type||"lease"},{name:"Fund-From",value:i.fundFrom}];return this.process.send({signer:this.signer,tags:Go(e)})}async upgradeRecord(i,o){if(i.fundFrom==="turbo"){if(!(this.paymentProvider instanceof ub))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Upgrade-Name",name:i.name})}let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Upgrade-Name"},{name:"Name",value:i.name},{name:"Fund-From",value:i.fundFrom}];return this.process.send({signer:this.signer,tags:Go(e)})}async extendLease(i,o){if(i.fundFrom==="turbo"){if(!(this.paymentProvider instanceof ub))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Extend-Lease",name:i.name,years:i.years})}let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Extend-Lease"},{name:"Name",value:i.name},{name:"Years",value:i.years.toString()},{name:"Fund-From",value:i.fundFrom}];return this.process.send({signer:this.signer,tags:Go(e)})}async increaseUndernameLimit(i,o){if(i.fundFrom==="turbo"){if(!(this.paymentProvider instanceof ub))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Increase-Undername-Limit",quantity:i.increaseCount,name:i.name})}let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Increase-Undername-Limit"},{name:"Name",value:i.name},{name:"Quantity",value:i.increaseCount.toString()},{name:"Fund-From",value:i.fundFrom}];return this.process.send({signer:this.signer,tags:Go(e)})}async cancelWithdrawal(i,o){let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Cancel-Withdrawal"},{name:"Vault-Id",value:i.vaultId},{name:"Address",value:i.gatewayAddress}];return this.process.send({signer:this.signer,tags:Go(e)})}async requestPrimaryName(i,o){if(i.fundFrom==="turbo")throw new Error("Turbo funding is not yet supported for primary name requests");let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Request-Primary-Name"},{name:"Name",value:i.name},{name:"Fund-From",value:i.fundFrom}];return this.process.send({signer:this.signer,tags:Go(e)})}async redelegateStake(i,o){let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Redelegate-Stake"},{name:"Target",value:i.target},{name:"Source",value:i.source},{name:"Quantity",value:i.stakeQty.valueOf().toString()},{name:"Vault-Id",value:i.vaultId}];return this.process.send({signer:this.signer,tags:Go(e)})}};var qXr=async({address:n,registry:i=rR.init()})=>{let o=await i.accessControlList({address:n});return[...new Set([...o.Owned,...o.Controlled])]};function Uve(n,i){return new Promise((o,c)=>{let e=setTimeout(()=>{c(new Error("Timeout"))},n);i.then(p=>{clearTimeout(e),o(p)}).catch(p=>{clearTimeout(e),c(p)})})}var jve=class extends l8t.default{contract;timeoutMs;throttle;logger;strict;antAoClient;constructor({contract:i=gR.init({processId:Fu}),timeoutMs:o=6e4,concurrency:c=30,logger:e=v0.default,strict:p=!1,antAoClient:d=sl({MODE:"legacy"})}={}){super(),this.contract=i,this.timeoutMs=o,this.throttle=K2e(c),this.logger=e,this.strict=p,this.antAoClient=d}async fetchProcessesOwnedByWallet({address:i,pageSize:o,antRegistry:c=rR.init()}){let e={},p=await c.accessControlList({address:i}),d=new Set([...p.Owned,...p.Controlled]);await Uve(this.timeoutMs,i1r({contract:this.contract,emitter:this,pageSize:o})).catch(_=>(this.emit("error",`Error getting ArNS records: ${_}`),this.logger.error("Error getting ArNS records",{message:_?.message,stack:_?.stack}),{})).then(_=>{Object.entries(_).forEach(([y,w])=>{d.has(w.processId)&&(e[w.processId]==null&&(e[w.processId]={state:void 0,names:{}}),e[w.processId].names[y]=w)})});let b=Object.keys(e).length;this.emit("progress",0,b),await Promise.all(Object.keys(e).map(async(_,y)=>this.throttle(async()=>{if(e[_].state!==void 0){this.emit("progress",y+1,b);return}let w=jw.init({process:new cs({processId:_,ao:this.antAoClient}),strict:this.strict}),M=await Uve(this.timeoutMs,w.getState()).catch(S=>{this.emit("error",`Error getting state for process ${_}: ${S}`)});(M?.Owner===i||M?.Controllers.includes(i))&&(e[_].state=M,this.emit("process",_,e[_])),this.emit("progress",y+1,b)}))),this.emit("end",e)}},i1r=async({contract:n=gR.init({processId:Fu}),emitter:i,logger:o=v0.default,pageSize:c=1e3})=>{let e,p=Date.now(),d={};do{let b=await n.getArNSRecords({cursor:e,limit:c}).catch(_=>{o?.error("Error getting ArNS records",{message:_?.message,stack:_?.stack}),i?.emit("arns:error",`Error getting ArNS records: ${_}`)});if(!b)return{};b.items.forEach(_=>{let{name:y,...w}=_;d[y]=w}),o.debug("Fetched page of ArNS records",{totalRecordCount:b.totalItems,fetchedRecordCount:Object.keys(d).length,cursor:b.nextCursor}),i?.emit("arns:pageLoaded",{totalRecordCount:b.totalItems,fetchedRecordCount:Object.keys(d).length,records:b.items,cursor:b.nextCursor}),e=b.nextCursor}while(e!==void 0);return i?.emit("arns:end",d),o.debug("Fetched all ArNS records",{totalRecordCount:Object.keys(d).length,durationMs:Date.now()-p}),d};var cs=class{logger;ao;processId;constructor({processId:i,ao:o=sl({MODE:"legacy"}),logger:c=v0.default}){this.processId=i,this.logger=c,this.ao=o}isMessageDataEmpty(i){return i===void 0||i==="null"||i===""||i===null}async read({tags:i,retries:o=3,fromAddress:c}){this.logger.debug("Evaluating read interaction on process",{tags:i,processId:this.processId});let e={process:this.processId,tags:i};c!==void 0&&(e.Owner=c);let p=0,d;for(;p<o;)try{d=await this.ao.dryrun(e);break}catch(w){if(p++,this.logger.debug(`Read attempt ${p} failed`,{error:w?.message,stack:w?.stack,tags:i,processId:this.processId}),p>=o)throw this.logger.debug("Maximum read attempts exceeded",{error:w?.message,stack:w?.stack,tags:i,processId:this.processId,ao:JSON.stringify(this.ao)}),new Error(`Failed to evaluate a dry-run on process ${this.processId}.`);await new Promise(M=>setTimeout(M,2**p*1e3))}if(d===void 0)throw new Error("Unexpected error when evaluating read interaction");this.logger.debug("Read interaction result",{result:d,processId:this.processId});let b=nK(d);if(b!==void 0)throw new Error(b);if(d.Messages===void 0||d.Messages.length===0)throw this.logger.debug(`Empty result - process ${this.processId} does not support provided action.`,{result:d,tags:i,processId:this.processId}),new Error(d.message||`Process ${this.processId} did not return a valid response. Response: ${JSON.stringify(d)}`);let _=d.Messages?.[0]?.Data;return this.isMessageDataEmpty(_)?void 0:h8t(_)}async send({tags:i,data:o,signer:c,retries:e=3}){let p,d=j2e(32);try{this.logger.debug("Evaluating send interaction on contract",{tags:i,data:o,processId:this.processId}),p=await this.ao.message({process:this.processId,tags:[...i,{name:"AR-IO-SDK",value:Pw}],data:o,signer:c,anchor:d}),this.logger.debug("Sent message to process",{messageId:p,processId:this.processId,anchor:d})}catch(M){throw this.logger.debug("Error sending message to process",{error:M?.message,stack:M?.stack,processId:this.processId,tags:i}),M}if(p===void 0)throw new Error("Failed to send message to process.");let b,_=0;for(;_<e;)try{b=await this.ao.result({message:p,process:this.processId}),this.logger.debug("Message result",{result:b,messageId:p,processId:this.processId});break}catch(M){if(_++,this.logger.debug("Retrying send interaction",{attempts:_,retries:e,error:M?.message,processId:this.processId}),_>=e)return this.logger.debug(`Message was sent to process ${this.processId} with id ${p} but result was not returned. Review transactions for more details.`,{error:M?.message,stack:M?.stack,tags:i,processId:this.processId,messageId:p}),{id:p};await new Promise(S=>setTimeout(S,2**_*2e3))}if(b===void 0)return this.logger.debug(`Message was sent to process ${this.processId} with id ${p} but the result was not returned. Review transactions for more details.`,{tags:i,processId:this.processId,messageId:p}),{id:p};let y=nK(b);if(y!==void 0)throw new AF(y);if(b.Messages?.length===0||b.Messages===void 0)return{id:p};if(this.isMessageDataEmpty(b.Messages[0].Data))return{id:p};let w=h8t(b.Messages[0].Data);return this.logger.debug("Message result data",{resultData:w,messageId:p,processId:this.processId}),{id:p,result:w}}};var aK=class{static init(i){return i!==void 0&&"signer"in i?new X8t(i):new oK(i)}},oK=class{process;constructor(i){if(i===void 0||Object.keys(i).length===0)this.process=new cs({processId:E5});else if(ob(i))this.process=i.process;else if(sb(i))this.process=new cs({processId:i.processId});else throw new hm}async getANTVersions(){let i=await this.process.read({tags:[{name:"Action",value:"Get-Versions"}]});return Object.fromEntries(Object.entries(i).sort(([o],[c])=>o.localeCompare(c)))}async getLatestANTVersion(){let i=await this.getANTVersions(),o=Object.entries(i).at(-1);if(!o)throw new Error("No version found");return{version:o[0],...o[1]}}},X8t=class extends oK{signer;constructor({signer:i,...o}){super(o),this.signer=ab(i)}async addVersion(i,o){let{version:c,moduleId:e,luaSourceId:p,notes:d}=i;return this.process.send({tags:Go([{name:"Action",value:"Add-Version"},{name:"Version",value:c},{name:"Module-Id",value:e},{name:"Lua-Source-Id",value:p},{name:"Notes",value:d},...o?.tags??[]]),signer:this.signer})}};var jw=class{static versions=aK.init();static init(i){return i!==void 0&&"signer"in i?new J8t(i):new sK(i)}},sK=class{process;processId;strict;constructor(i){if(this.strict=i.strict||!1,ob(i))this.process=i.process;else if(sb(i))this.process=new cs({processId:i.processId});else throw new hm;this.processId=this.process.processId}async getState({strict:i}={strict:this.strict}){let o=[{name:"Action",value:"State"}],c=await this.process.read({tags:o});return i&&mm(dnt.passthrough().and(Xr.object({Records:Xr.record(Xr.string(),sP.passthrough())})),c),c}async getInfo({strict:i}={strict:this.strict}){let o=[{name:"Action",value:"Info"}],c=await this.process.read({tags:o});return i&&mm(Wjt.passthrough(),c),c}async getLogo(){return(await this.getInfo()).Logo}async getRecord({undername:i},{strict:o}={strict:this.strict}){let c=await this.process.read({tags:[{name:"Action",value:"Record"},{name:"Sub-Domain",value:i}]});return o&&mm(sP.passthrough(),c),c}async getRecords({strict:i}={strict:this.strict}){let o=[{name:"Action",value:"Records"}],c=await this.process.read({tags:o});return i&&mm(fP,c),C2e(c)}async getOwner({strict:i}={strict:this.strict}){return(await this.getInfo({strict:i})).Owner}async getControllers({strict:i}={strict:this.strict}){let o=[{name:"Action",value:"Controllers"}],c=await this.process.read({tags:o});return i&&mm(hP,c),c}async getName({strict:i}={strict:this.strict}){return(await this.getInfo({strict:i})).Name}async getTicker({strict:i}={strict:this.strict}){return(await this.getInfo({strict:i})).Ticker}async getBalances({strict:i}={strict:this.strict}){let o=[{name:"Action",value:"Balances"}],c=await this.process.read({tags:o});return i&&mm(uP,c),c}async getBalance({address:i},{strict:o}={strict:this.strict}){let c=[{name:"Action",value:"Balance"},{name:"Recipient",value:i}],e=await this.process.read({tags:c});return o&&mm(Xr.number(),e),e}async getHandlers(){let i=await this.getInfo();return i.Handlers??i.HandlerNames}},J8t=class extends sK{signer;constructor({signer:i,...o}){super(o),this.signer=ab(i)}async transfer({target:i},o){let c=[...o?.tags??[],{name:"Action",value:"Transfer"},{name:"Recipient",value:i}];return this.process.send({tags:c,signer:this.signer})}async addController({controller:i},o){let c=[...o?.tags??[],{name:"Action",value:"Add-Controller"},{name:"Controller",value:i}];return this.process.send({tags:c,signer:this.signer})}async removeController({controller:i},o){let c=[...o?.tags??[],{name:"Action",value:"Remove-Controller"},{name:"Controller",value:i}];return this.process.send({tags:c,signer:this.signer})}async setRecord({undername:i,transactionId:o,ttlSeconds:c},e){return this.process.send({tags:[...e?.tags??[],{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:i},{name:"Transaction-Id",value:o},{name:"TTL-Seconds",value:c.toString()}],signer:this.signer})}async setBaseNameRecord({transactionId:i,ttlSeconds:o},c){return this.setRecord({transactionId:i,ttlSeconds:o,undername:"@"},c)}async setUndernameRecord({undername:i,transactionId:o,ttlSeconds:c},e){return this.setRecord({undername:i,transactionId:o,ttlSeconds:c},e)}async removeUndernameRecord({undername:i}){return this.removeRecord({undername:i})}async removeRecord({undername:i},o){return this.process.send({tags:[...o?.tags??[],{name:"Action",value:"Remove-Record"},{name:"Sub-Domain",value:i}],signer:this.signer})}async setTicker({ticker:i},o){return this.process.send({tags:[...o?.tags??[],{name:"Action",value:"Set-Ticker"},{name:"Ticker",value:i}],signer:this.signer})}async setName({name:i},o){return this.process.send({tags:[...o?.tags??[],{name:"Action",value:"Set-Name"},{name:"Name",value:i}],signer:this.signer})}async setDescription({description:i},o){return this.process.send({tags:[...o?.tags??[],{name:"Action",value:"Set-Description"},{name:"Description",value:i}],signer:this.signer})}async setKeywords({keywords:i},o){return this.process.send({tags:[...o?.tags??[],{name:"Action",value:"Set-Keywords"},{name:"Keywords",value:JSON.stringify(i)}],signer:this.signer})}async setLogo({txId:i},o){return this.process.send({tags:[...o?.tags??[],{name:"Action",value:"Set-Logo"},{name:"Logo",value:i}],signer:this.signer})}async releaseName({name:i,arioProcessId:o},c){return this.process.send({tags:[...c?.tags??[],{name:"Action",value:"Release-Name"},{name:"Name",value:i},{name:"IO-Process-Id",value:o},{name:"ARIO-Process-Id",value:o}],signer:this.signer})}async reassignName({name:i,arioProcessId:o,antProcessId:c},e){return this.process.send({tags:[...e?.tags??[],{name:"Action",value:"Reassign-Name"},{name:"Name",value:i},{name:"IO-Process-Id",value:o},{name:"ARIO-Process-Id",value:o},{name:"Process-Id",value:c}],signer:this.signer})}async approvePrimaryNameRequest({name:i,address:o,arioProcessId:c},e){return this.process.send({tags:[...e?.tags??[],{name:"Action",value:"Approve-Primary-Name"},{name:"Name",value:i},{name:"Recipient",value:o},{name:"IO-Process-Id",value:c},{name:"ARIO-Process-Id",value:c}],signer:this.signer})}async removePrimaryNames({names:i,arioProcessId:o,notifyOwners:c=!1},e){return this.process.send({tags:[...e?.tags??[],{name:"Action",value:"Remove-Primary-Names"},{name:"Names",value:i.join(",")},{name:"IO-Process-Id",value:o},{name:"ARIO-Process-Id",value:o},{name:"Notify-Owners",value:c.toString()}],signer:this.signer})}};async function _Qr({signer:n,module:i=qjt,ao:o=sl({MODE:"legacy"}),scheduler:c=Fjt,state:e,antRegistryId:p=E5,logger:d=v0.default,authority:b=jjt}){e&&mm(Hjt,e);let _=await o.spawn({module:i,scheduler:c,signer:n,data:e?JSON.stringify(e):void 0,tags:[{name:"Authority",value:b},{name:"ANT-Registry-Id",value:p}]}),y,w=0;for(;w<5&&y===void 0;)try{y=await o.result({process:_,message:_});break}catch(M){d.debug("Retrying ANT boot result fetch",{processId:_,module:i,scheduler:c,attempts:w,error:M}),w++,await new Promise(S=>setTimeout(S,1e3*w**2))}if(y===void 0||y.Messages?.some(M=>M?.Tags?.some(S=>S.value==="Invalid-Boot-Notice"))){if(y===void 0)throw new Error("Failed to get boot result");let M=nK(y);throw d.error("ANT failed to boot correctly",{processId:_,module:i,scheduler:c,bootRes:y,bootError:M}),new Error(`ANT failed to boot correctly: ${M}`)}return d.debug("Spawned ANT",{processId:_,module:i,scheduler:c}),_}async function MQr({signer:n,processId:i,luaCodeTxId:o=Ujt,ao:c=sl({MODE:"legacy"}),logger:e=v0.default,arweave:p=xF}){let d=new cs({processId:i,ao:c,logger:e}),{api:{host:b,port:_,protocol:y}}=p.getConfig(),w=await fetch(`${y}://${b}:${_}/${o}`).then(S=>S.text()),{id:M}=await d.send({tags:[{name:"Action",value:"Eval"},{name:"App-Name",value:"ArNS-ANT"},{name:"Source-Code-TX-ID",value:o}],data:w,signer:n});return e.debug("Evolved ANT",{processId:i,luaCodeTxId:o,evalMsgId:M}),M}function n1r(n){let i=Xr.object({name:Xr.string(),value:Xr.union([Xr.string(),Xr.number()])}),o=Xr.function().args(Xr.object({data:Xr.union([Xr.string(),Xr.instanceof(Zt)]),tags:Xr.array(i).optional(),target:Xr.string().optional(),anchor:Xr.string().optional()})).returns(Xr.promise(Xr.object({id:Xr.string(),raw:Xr.instanceof(ArrayBuffer)})));try{return o.parse(n),!0}catch{return!1}}function ab(n){return n1r(n)?n:"publicKey"in n?async({data:o,tags:c,target:e,anchor:p})=>{if(n.publicKey===void 0&&"setPublicKey"in n&&typeof n.setPublicKey=="function"&&await n.setPublicKey(),n instanceof Wd){let _=await n.signer.signDataItem({data:o,tags:c,target:e,anchor:p}),y=new d5(Zt.from(_));return{id:await y.id,raw:await y.getRaw()}}let d=dM(o,n,{tags:c,target:e,anchor:p});return d.sign(n).then(async()=>({id:await d.id,raw:await d.getRaw()}))}:Eue(n)}var a1r="-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI",o1r="Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A";function SQr({owner:n,targetId:i,ttlSeconds:o=3600,keywords:c=[],controllers:e=[],description:p="",ticker:d="aos",name:b="ANT",logo:_=o1r}){return{ticker:d,name:b,description:p,keywords:c,owner:n,controllers:[n,...e],balances:{[n]:1},records:{"@":{transactionId:i??a1r.toString(),ttlSeconds:o}},logo:_}}function Q8t(n){return Xr.object({startTimestamp:Xr.number(),startHeight:Xr.number(),distributions:Xr.any(),endTimestamp:Xr.number(),prescribedObservers:Xr.any(),prescribedNames:Xr.array(Xr.string()),observations:Xr.any(),epochIndex:Xr.number()}).parse(n)}function nK(n){let o=n.Error??n.Messages?.[0]?.Tags?.find(c=>c.name==="Error")?.value;if(o!==void 0){let c=o.match(/\[string "aos"]:(\d+):\s*(.+)/);if(c){let[,e,p]=c;return`${Fve(p).trim()} (line ${e.trim()})`.trim()}return Fve(o)}}function Fve(n){let i="\x1B";return n.replace(new RegExp(`${i}[\\[\\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]`,"g"),"").trim()}var zve=n=>aP.test(n);function LQr(n){return n!==void 0&&!isNaN(parseInt(n.toString()))}var Go=n=>n.filter(i=>i.value!==void 0&&i.value!==""),eu=n=>{let i=[{name:"Cursor",value:n?.cursor?.toString()},{name:"Limit",value:n?.limit?.toString()},{name:"Sort-By",value:n?.sortBy?.toString()},{name:"Sort-Order",value:n?.sortOrder?.toString()}];return Go(i)},s1r=async({arweave:n,epochIndex:i,processId:o=Fu,retries:c=3,gqlUrl:e="https://arweave-search.goldsky.com/graphql"})=>{let p=h1r({epochIndex:i,processId:o});for(let d=0;d<c;d++)try{let b=await fetch(e,{method:"POST",body:p,headers:{"Content-Type":"application/json"}}).then(w=>w.json());if(b?.data?.transactions?.edges?.length===0)return;let _=b.data.transactions.edges[0].node.id,y=await n.api.get(_);return Q8t(y.data)}catch(b){if(d===c-1)throw b;await new Promise(_=>setTimeout(_,Math.pow(2,d)*1e3))}},C8=async({arweave:n,ao:i,epochIndex:o,processId:c=Fu})=>{let e=await s1r({arweave:n,epochIndex:o,processId:c});if(e)return e;let p=await f1r({ao:i,epochIndex:o,processId:c});if(p)return p},f1r=async({ao:n,epochIndex:i,processId:o=Fu,gqlUrl:c="https://arweave-search.goldsky.com/graphql"})=>{let e=u1r({epochIndex:i,processId:o}),d=await(await fetch(c,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})).json();if(d.data.transactions.edges.length!==0)for(let b of d.data.transactions.edges){let _=b.node.id,y=await n.result({message:_,process:o}).catch(()=>{});if(y)for(let w of y?.Messages??[]){let M=JSON.parse(w.Data),S=w.Tags;if(S.some(E=>E.name==="Action"&&E.value==="Epoch-Distribution-Notice")&&S.some(E=>E.name==="Epoch-Index"&&E.value===i.toString()))return Q8t(M)}}},h1r=({epochIndex:n,processId:i=Fu,authorities:o=["fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY"]})=>JSON.stringify({query:`
285
+ `+p):c.stack=p}catch{}}throw c}}_request(i,o){typeof i=="string"?(o=o||{},o.url=i):o=i||{},o=C1(this.defaults,o);let{transitional:c,paramsSerializer:e,headers:p}=o;c!==void 0&&dR.assertOptions(c,{silentJSONParsing:gm.transitional(gm.boolean),forcedJSONParsing:gm.transitional(gm.boolean),clarifyTimeoutError:gm.transitional(gm.boolean)},!1),e!=null&&(ur.isFunction(e)?o.paramsSerializer={serialize:e}:dR.assertOptions(e,{encode:gm.function,serialize:gm.function},!0)),o.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?o.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:o.allowAbsoluteUrls=!0),dR.assertOptions(o,{baseUrl:gm.spelling("baseURL"),withXsrfToken:gm.spelling("withXSRFToken")},!0),o.method=(o.method||this.defaults.method||"get").toLowerCase();let d=p&&ur.merge(p.common,p[o.method]);p&&ur.forEach(["delete","get","head","post","put","patch","common"],x=>{delete p[x]}),o.headers=Rf.concat(d,p);let b=[],_=!0;this.interceptors.request.forEach(function(k){typeof k.runWhen=="function"&&k.runWhen(o)===!1||(_=_&&k.synchronous,b.unshift(k.fulfilled,k.rejected))});let y=[];this.interceptors.response.forEach(function(k){y.push(k.fulfilled,k.rejected)});let w,M=0,S;if(!_){let x=[Xz.bind(this),void 0];for(x.unshift.apply(x,b),x.push.apply(x,y),S=x.length,w=Promise.resolve(o);M<S;)w=w.then(x[M++],x[M++]);return w}S=b.length;let E=o;for(M=0;M<S;){let x=b[M++],k=b[M++];try{E=x(E)}catch(T){k.call(this,T);break}}try{w=Xz.call(this,E)}catch(x){return Promise.reject(x)}for(M=0,S=y.length;M<S;)w=w.then(y[M++],y[M++]);return w}getUri(i){i=C1(this.defaults,i);let o=cR(i.baseURL,i.url,i.allowAbsoluteUrls);return sR(o,i.params,i.paramsSerializer)}};ur.forEach(["delete","get","head","options"],function(i){qw.prototype[i]=function(o,c){return this.request(C1(c||{},{method:i,url:o,data:(c||{}).data}))}});ur.forEach(["post","put","patch"],function(i){function o(c){return function(p,d,b){return this.request(C1(b||{},{method:i,headers:c?{"Content-Type":"multipart/form-data"}:{},url:p,data:d}))}}qw.prototype[i]=o(),qw.prototype[i+"Form"]=o(!0)});var pR=qw;Bt();Ot();Pt();var F8t=class n{constructor(i){if(typeof i!="function")throw new TypeError("executor must be a function.");let o;this.promise=new Promise(function(p){o=p});let c=this;this.promise.then(e=>{if(!c._listeners)return;let p=c._listeners.length;for(;p-- >0;)c._listeners[p](e);c._listeners=null}),this.promise.then=e=>{let p,d=new Promise(b=>{c.subscribe(b),p=b}).then(e);return d.cancel=function(){c.unsubscribe(p)},d},i(function(p,d,b){c.reason||(c.reason=new vm(p,d,b),o(c.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(i){if(this.reason){i(this.reason);return}this._listeners?this._listeners.push(i):this._listeners=[i]}unsubscribe(i){if(!this._listeners)return;let o=this._listeners.indexOf(i);o!==-1&&this._listeners.splice(o,1)}toAbortSignal(){let i=new AbortController,o=c=>{i.abort(c)};return this.subscribe(o),i.signal.unsubscribe=()=>this.unsubscribe(o),i.signal}static source(){let i;return{token:new n(function(e){i=e}),cancel:i}}},Ave=F8t;Bt();Ot();Pt();function z8t(n){return function(o){return n.apply(null,o)}}Bt();Ot();Pt();function K8t(n){return ur.isObject(n)&&n.isAxiosError===!0}Bt();Ot();Pt();var H8t={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(H8t).forEach(([n,i])=>{H8t[i]=n});var Rve=H8t;function kve(n){let i=new pR(n),o=nR(pR.prototype.request,i);return ur.extend(o,pR.prototype,i,{allOwnKeys:!0}),ur.extend(o,i,null,{allOwnKeys:!0}),o.create=function(e){return kve(C1(n,e))},o}var tf=kve(Lw);tf.Axios=pR;tf.CanceledError=vm;tf.CancelToken=Ave;tf.isCancel=uR;tf.VERSION=Jz;tf.toFormData=fb;tf.AxiosError=Ti;tf.Cancel=tf.CanceledError;tf.all=function(i){return Promise.all(i)};tf.spread=z8t;tf.isAxiosError=K8t;tf.mergeConfig=C1;tf.AxiosHeaders=Rf;tf.formToJSON=n=>Hz(ur.isHTMLForm(n)?new FormData(n):n);tf.getAdapter=Yz.getAdapter;tf.HttpStatusCode=Rve;tf.default=tf;var tK=tf;var{Axios:tGr,AxiosError:eGr,CanceledError:rGr,isCancel:iGr,CancelToken:nGr,VERSION:aGr,all:oGr,Cancel:sGr,isAxiosError:fGr,spread:hGr,toFormData:uGr,AxiosHeaders:lGr,HttpStatusCode:cGr,formToJSON:dGr,getAdapter:pGr,mergeConfig:mGr}=tK;Bt();Ot();Pt();var Pve=va(Ive(),1),W8t="axios-retry";function Ove(n){let i=["ERR_CANCELED","ECONNABORTED"];return n.response||!n.code||i.includes(n.code)?!1:(0,Pve.default)(n)}var Nve=["get","head","options"],Hdr=Nve.concat(["put","delete"]);function Z8t(n){return n.code!=="ECONNABORTED"&&(!n.response||n.response.status===429||n.response.status>=500&&n.response.status<=599)}function Wdr(n){return n.config?.method?Z8t(n)&&Nve.indexOf(n.config.method)!==-1:!1}function Cve(n){return n.config?.method?Z8t(n)&&Hdr.indexOf(n.config.method)!==-1:!1}function Lve(n){return Ove(n)||Cve(n)}function V8t(n=void 0){let i=n?.response?.headers["retry-after"];if(!i)return 0;let o=(Number(i)||0)*1e3;return o===0&&(o=(new Date(i).valueOf()||0)-Date.now()),Math.max(0,o)}function Zdr(n=0,i=void 0){return Math.max(0,V8t(i))}function Vdr(n=0,i=void 0,o=100){let c=2**n*o,e=Math.max(c,V8t(i)),p=e*.2*Math.random();return e+p}function Gdr(n=100){return(i=0,o=void 0)=>{let c=i*n;return Math.max(c,V8t(o))}}var Ydr={retries:3,retryCondition:Lve,retryDelay:Zdr,shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function Xdr(n,i){return{...Ydr,...i,...n[W8t]}}function Bve(n,i,o=!1){let c=Xdr(n,i||{});return c.retryCount=c.retryCount||0,(!c.lastRequestTime||o)&&(c.lastRequestTime=Date.now()),n[W8t]=c,c}function Jdr(n,i){n.defaults.agent===i.agent&&delete i.agent,n.defaults.httpAgent===i.httpAgent&&delete i.httpAgent,n.defaults.httpsAgent===i.httpsAgent&&delete i.httpsAgent}async function Qdr(n,i){let{retries:o,retryCondition:c}=n,e=(n.retryCount||0)<o&&c(i);if(typeof e=="object")try{return await e!==!1}catch{return!1}return e}async function t1r(n,i,o,c){i.retryCount+=1;let{retryDelay:e,shouldResetTimeout:p,onRetry:d}=i,b=e(i.retryCount,o);if(Jdr(n,c),!p&&c.timeout&&i.lastRequestTime){let _=Date.now()-i.lastRequestTime,y=c.timeout-_-b;if(y<=0)return Promise.reject(o);c.timeout=y}return c.transformRequest=[_=>_],await d(i.retryCount,o,c),c.signal?.aborted?Promise.resolve(n(c)):new Promise(_=>{let y=()=>{clearTimeout(w),_(n(c))},w=setTimeout(()=>{_(n(c)),c.signal?.removeEventListener&&c.signal.removeEventListener("abort",y)},b);c.signal?.addEventListener&&c.signal.addEventListener("abort",y,{once:!0})})}async function e1r(n,i){n.retryCount>=n.retries&&await n.onMaxRetryTimesExceeded(i,n.retryCount)}var hb=(n,i)=>{let o=n.interceptors.request.use(e=>(Bve(e,i,!0),e[W8t]?.validateResponse&&(e.validateStatus=()=>!1),e)),c=n.interceptors.response.use(null,async e=>{let{config:p}=e;if(!p)return Promise.reject(e);let d=Bve(p,i);return e.response&&d.validateResponse?.(e.response)?e.response:await Qdr(d,e)?t1r(n,d,e,p):(await e1r(d,e),Promise.reject(e))});return{requestInterceptorId:o,responseInterceptorId:c}};hb.isNetworkError=Ove;hb.isSafeRequestError=Wdr;hb.isIdempotentRequestError=Cve;hb.isNetworkOrIdempotentRequestError=Lve;hb.exponentialDelay=Vdr;hb.linearDelay=Gdr;hb.isRetryableError=Z8t;var eK=hb;var Dve=({axiosConfig:n={},logger:i=v0.default,retryConfig:o={retries:5,retryDelay:eK.exponentialDelay,retryCondition:c=>eK.isRetryableError(c),onRetry(c,e,p){i.error(`Retrying request ${p.url} attempt ${c}`,e)}}}={})=>{let c=tK.create({...n,maxRedirects:0,headers:{...n.headers,"x-source-version":`${Pw}`,"x-source-identifier":"ar-io-sdk"},validateStatus:()=>!0});return eK(c,o),c};Bt();Ot();Pt();var G8t=({baseUrl:n,params:i})=>{let o=new URL(n);return Object.entries(i).forEach(([c,e])=>{if(e!=null){if(Array.isArray(e)&&e.length>0)for(let p of e)p!=null&&o.searchParams.append(c,p.toString());o.searchParams.set(c,e.toString())}}),o.toString()};async function r1r({signer:n,nonce:i=y8t()}){let o,c,e=rK(n)?wi.ARWEAVE:n.signatureType;switch(rK(n)?o=Ow(Zt.from(await n.signMessage(Uint8Array.from(Zt.from(i))))):n instanceof Wd?o=Ow(Zt.from(await n.signer.signMessage(Uint8Array.from(Zt.from(i))))):(n instanceof Od||n instanceof ch||n instanceof M3)&&("setPublicKey"in n&&n.publicKey===void 0&&await n.setPublicKey(),o=Ow(Zt.from(await n.sign(Uint8Array.from(Zt.from(i)))))),e){case wi.ARWEAVE:rK(n)?c=await n.getActivePublicKey():"setPublicKey"in n&&(await n.setPublicKey(),c=Ow(n.publicKey));break;case wi.ETHEREUM:if("publicKey"in n)c="0x"+n.publicKey.toString("hex");else throw new Error("Public key not found");break;default:throw new Error(`Unsupported signer type for signing requests: ${e}`)}if(c===void 0||o===void 0)throw new Error("Public key or signature not found");return{"x-public-key":c,"x-nonce":i,"x-signature":o,"x-signature-type":e.toString()}}var mR=class{static init(i){let{signer:o,paymentUrl:c,axios:e,logger:p}=i??{};return o!==void 0?new ub({signer:o,paymentUrl:c,axios:e,logger:p}):new iK({paymentUrl:c,axios:e,logger:p})}},iK=class{paymentUrl;axios;logger;constructor({paymentUrl:i="https://payment.ardrive.io",axios:o=Dve(),logger:c=v0.default}){this.paymentUrl=i,this.axios=o,this.logger=c}async getArNSPriceDetails({intent:i,name:o,quantity:c,type:e,years:p}){let d=G8t({baseUrl:`${this.paymentUrl}/v1/arns/price/${i}/${o}`,params:{increaseQty:c,type:e,years:p}}),{data:b,status:_}=await this.axios.get(d);if(this.logger.debug("getArNSPriceDetails",{intent:i,name:o,quantity:c,type:e,years:p,data:b,status:_}),_!==200)throw new Error("Failed to get ArNS purchase price "+JSON.stringify(b));if(!b.winc||!b.mARIO)throw new Error("Invalid response from Turbo "+JSON.stringify(b));return{winc:b.winc,mARIO:new iR(+b.mARIO)}}async getPrice(i){let{winc:o}=await this.getArNSPriceDetails(i);return+o}},ub=class extends iK{signer;constructor({signer:i,...o}){if(super(o),!Y8t(i))throw new Error("Signer must be a TurboArNSSigner");this.signer=i}async initiateArNSPurchase({intent:i,name:o,quantity:c,type:e,processId:p,years:d,paidBy:b=[]}){let _=G8t({baseUrl:`${this.paymentUrl}/v1/arns/purchase/${i}/${o}`,params:{increaseQty:c,processId:p,type:e,years:d,paidBy:b}}),y=await r1r({signer:this.signer}),{data:w,status:M}=await this.axios.post(_,null,{headers:y});if(this.logger.debug("Initiated ArNS purchase",{intent:i,name:o,quantity:c,processId:p,type:e,years:d,data:w,status:M}),M!==200)throw new Error("Failed to initiate ArNS purchase "+JSON.stringify(w));return{id:w.arioWriteResult.id,result:w.purchaseReceipt}}};function rK(n){return typeof n=="object"&&n!==null&&"signMessage"in n&&"getActivePublicKey"in n}function Y8t(n){let i=rK(n),o=n instanceof ch||n instanceof M3||n instanceof Od||n instanceof Wd;return i||o}var gR=class{static init(i){return i!==void 0&&"signer"in i?new vR(i):new Uw(i)}static mainnet(i){return i!==void 0&&"signer"in i?new vR({...i,process:new cs({processId:Fu,ao:sl({MODE:"legacy",CU_URL:"https://cu.ardrive.io",...i?.process?.ao})})}):new Uw({...i,process:new cs({processId:Fu,ao:sl({CU_URL:"https://cu.ardrive.io",MODE:"legacy",...i?.process?.ao})})})}static testnet(i){return i!==void 0&&"signer"in i?v8t({arioInstance:new vR({...i,process:new cs({processId:unt,ao:sl({MODE:"legacy",CU_URL:"https://cu.ardrive.io",...i?.process?.ao})})}),faucetApiUrl:i?.faucetUrl}):v8t({arioInstance:new Uw({...i,process:new cs({processId:unt,ao:sl({MODE:"legacy",CU_URL:"https://cu.ardrive.io",...i?.process?.ao})})}),faucetApiUrl:i?.faucetUrl})}},Uw=class{process;epochSettings;arweave;paymentProvider;constructor(i){if(this.arweave=i?.arweave??xF,i===void 0||Object.keys(i).length===0)this.process=new cs({processId:Fu});else if(ob(i))this.process=i.process;else if(sb(i))this.process=new cs({processId:i.processId});else throw new hm;this.paymentProvider=mR.init({paymentUrl:i?.paymentUrl})}async getInfo(){return this.process.read({tags:[{name:"Action",value:"Info"}]})}async getTokenSupply(){return this.process.read({tags:[{name:"Action",value:"Total-Token-Supply"}]})}async computeEpochIndexForTimestamp(i){let o=await this.getEpochSettings(),c=o.epochZeroStartTimestamp,e=o.durationMs;return Math.floor((i-c)/e)}async computeCurrentEpochIndex(){return this.computeEpochIndexForTimestamp(Date.now())}async computeEpochIndex(i){let o=i?.epochIndex;if(o!==void 0)return o;let c=i?.timestamp;if(c!==void 0)return this.computeEpochIndexForTimestamp(c)}async getEpochSettings(){return this.epochSettings??=await this.process.read({tags:[{name:"Action",value:"Epoch-Settings"}]})}async getEpoch(i){let o=await this.computeEpochIndex(i),c=await this.computeCurrentEpochIndex();if(o!==void 0&&o<c){let p=await C8({arweave:this.arweave,epochIndex:o,processId:this.process.processId,ao:this.process.ao});if(!p)throw new Error("Epoch data not found for epoch index "+o);return qve(p)}let e=[{name:"Action",value:"Epoch"},{name:"Epoch-Index",value:c.toString()}];return this.process.read({tags:Go(e)})}async getArNSRecord({name:i}){return this.process.read({tags:[{name:"Action",value:"Record"},{name:"Name",value:i}]})}async getArNSRecords(i){return this.process.read({tags:[{name:"Action",value:"Paginated-Records"},...eu(i)]})}async getArNSReservedNames(i){return this.process.read({tags:[{name:"Action",value:"Reserved-Names"},...eu(i)]})}async getArNSReservedName({name:i}){return this.process.read({tags:[{name:"Action",value:"Reserved-Name"},{name:"Name",value:i}]})}async getBalance({address:i}){return this.process.read({tags:[{name:"Action",value:"Balance"},{name:"Address",value:i}]})}async getBalances(i){return this.process.read({tags:[{name:"Action",value:"Paginated-Balances"},...eu(i)]})}async getVault({address:i,vaultId:o}){return this.process.read({tags:[{name:"Action",value:"Vault"},{name:"Address",value:i},{name:"Vault-Id",value:o}]})}async getVaults(i){return this.process.read({tags:[{name:"Action",value:"Paginated-Vaults"},...eu(i)]})}async getGateway({address:i}){return this.process.read({tags:[{name:"Action",value:"Gateway"},{name:"Address",value:i}]})}async getGatewayDelegates({address:i,...o}){return this.process.read({tags:[{name:"Action",value:"Paginated-Delegates"},{name:"Address",value:i},...eu(o)]})}async getGatewayDelegateAllowList({address:i,...o}){return this.process.read({tags:[{name:"Action",value:"Paginated-Allowed-Delegates"},{name:"Address",value:i},...eu(o)]})}async getGateways(i){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateways"},...eu(i)]})}async getCurrentEpoch(){return this.process.read({tags:[{name:"Action",value:"Epoch"}]})}async getPrescribedObservers(i){let o=await this.computeEpochIndex(i),c=await this.computeCurrentEpochIndex();if(o!==void 0&&o<c){let p=await C8({ao:this.process.ao,arweave:this.arweave,epochIndex:o,processId:this.process.processId});if(!p)throw new Error("Epoch data not found for epoch index "+o);return p.prescribedObservers}let e=[{name:"Action",value:"Epoch-Prescribed-Observers"},{name:"Epoch-Index",value:c.toString()}];return this.process.read({tags:Go(e)})}async getPrescribedNames(i){let o=await this.computeEpochIndex(i),c=await this.computeCurrentEpochIndex();if(o!==void 0&&o<c){let p=await C8({arweave:this.arweave,epochIndex:o,processId:this.process.processId,ao:this.process.ao});if(!p)throw new Error("Epoch data not found for epoch index "+o);return p.prescribedNames}let e=[{name:"Action",value:"Epoch-Prescribed-Names"},{name:"Epoch-Index",value:c.toString()}];return this.process.read({tags:Go(e)})}async getObservations(i){let o=await this.computeEpochIndex(i),c=await this.computeCurrentEpochIndex();if(o!==void 0&&o<c){let p=await C8({arweave:this.arweave,epochIndex:o,processId:this.process.processId,ao:this.process.ao});if(!p)throw new Error("Epoch data not found for epoch index "+o);return p.observations}let e=[{name:"Action",value:"Epoch-Observations"},{name:"Epoch-Index",value:c.toString()}];return this.process.read({tags:Go(e)})}async getDistributions(i){let o=await this.computeEpochIndex(i),c=await this.computeCurrentEpochIndex();if(o!==void 0&&o<c){let p=await C8({arweave:this.arweave,epochIndex:o,processId:this.process.processId,ao:this.process.ao});if(p===void 0)throw new Error("Epoch data not found for epoch index "+o);return p.distributions}let e=[{name:"Action",value:"Epoch-Distributions"},{name:"Epoch-Index",value:c.toString()}];return this.process.read({tags:Go(e)})}async getEligibleEpochRewards(i,o){let c=await this.computeEpochIndex(i),e=await this.computeCurrentEpochIndex();if(c!==void 0&&c<e){let d=await C8({arweave:this.arweave,epochIndex:c,processId:this.process.processId,ao:this.process.ao});if(!d)throw new Error("Epoch data not found for epoch index "+c);return $ve(d,o)}let p=[{name:"Action",value:"Epoch-Eligible-Rewards"},...eu(o)];return this.process.read({tags:Go(p)})}async getTokenCost({intent:i,type:o,years:c,name:e,quantity:p,fromAddress:d}){let _=[{name:"Action",value:"Token-Cost"},{name:"Intent",value:i==="Buy-Record"?"Buy-Name":i},{name:"Name",value:e},{name:"Years",value:c?.toString()},{name:"Quantity",value:p?.toString()},{name:"Purchase-Type",value:o}];return this.process.read({tags:Go(_),fromAddress:d})}async getCostDetails({intent:i,type:o,years:c,name:e,quantity:p,fromAddress:d,fundFrom:b}){let _=i==="Buy-Record"?"Buy-Name":i;if(b==="turbo"){let{mARIO:w,winc:M}=await this.paymentProvider.getArNSPriceDetails({intent:_,name:e,quantity:p,type:o,years:c});return{tokenCost:w.valueOf(),wincQty:M,discounts:[]}}let y=[{name:"Action",value:"Cost-Details"},{name:"Intent",value:_},{name:"Name",value:e},{name:"Years",value:c?.toString()},{name:"Quantity",value:p?.toString()},{name:"Purchase-Type",value:o},{name:"Fund-From",value:b}];return this.process.read({tags:Go(y),fromAddress:d})}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(i){return this.process.read({tags:[{name:"Action",value:"Returned-Names"},...eu(i)]})}async getArNSReturnedName({name:i}){let o=[{name:"Action",value:"Returned-Name"},{name:"Name",value:i}];return this.process.read({tags:o})}async getDelegations(i){let o=[{name:"Action",value:"Paginated-Delegations"},{name:"Address",value:i.address},...eu(i)];return this.process.read({tags:Go(o)})}async getAllowedDelegates(i){return this.getGatewayDelegateAllowList(i)}async getGatewayVaults(i){return this.process.read({tags:[{name:"Action",value:"Paginated-Gateway-Vaults"},{name:"Address",value:i.address},...eu(i)]})}async getPrimaryNameRequest(i){let o=[{name:"Action",value:"Primary-Name-Request"},{name:"Initiator",value:i.initiator}];return this.process.read({tags:o})}async getPrimaryNameRequests(i){return this.process.read({tags:[{name:"Action",value:"Primary-Name-Requests"},...eu(i)]})}async getPrimaryName(i){let o=[{name:"Action",value:"Primary-Name"},{name:"Address",value:i?.address},{name:"Name",value:i?.name}];return this.process.read({tags:Go(o)})}async getPrimaryNames(i){return this.process.read({tags:[{name:"Action",value:"Primary-Names"},...eu(i)]})}async getRedelegationFee(i){return this.process.read({tags:[{name:"Action",value:"Redelegation-Fee"},{name:"Address",value:i.address}]})}async getGatewayRegistrySettings(){return this.process.read({tags:[{name:"Action",value:"Gateway-Registry-Settings"}]})}async getAllDelegates(i){return this.process.read({tags:[{name:"Action",value:"All-Paginated-Delegates"},...eu(i)]})}async getAllGatewayVaults(i){return this.process.read({tags:[{name:"Action",value:"All-Gateway-Vaults"},...eu(i)]})}async resolveArNSName({name:i}){let o=i.lastIndexOf("_"),c=o===-1?i:i.slice(o+1),e=o===-1?"@":i.slice(0,o),p=await this.getArNSRecord({name:c});if(p===void 0||p.processId===void 0)throw new Error(`Base ArNS name ${c} not found on ARIO contract (${this.process.processId}).`);let d=jw.init({process:new cs({ao:this.process.ao,processId:p.processId})}),[b,_]=await Promise.all([d.getOwner(),d.getRecord({undername:e})]);if(_===void 0)throw new Error(`Record for ${e} not found on ANT.`);if(_.ttlSeconds===void 0||_.transactionId===void 0)throw new Error(`Invalid record on ANT. Must have ttlSeconds and transactionId. Record: ${JSON.stringify(_)}`);return{name:i,owner:b,txId:_.transactionId,ttlSeconds:_.ttlSeconds,priority:_.priority,processId:p.processId,undernameLimit:p.undernameLimit,type:p.type}}},vR=class extends Uw{signer;paymentProvider;constructor({signer:i,paymentUrl:o,...c}){c===void 0?super({process:new cs({processId:Fu})}):super(c),this.signer=ab(i),this.paymentProvider=mR.init({signer:Y8t(i)?i:void 0,paymentUrl:o})}async transfer({target:i,qty:o},c){let{tags:e=[]}=c||{};return this.process.send({tags:[...e,{name:"Action",value:"Transfer"},{name:"Recipient",value:i},{name:"Quantity",value:o.valueOf().toString()}],signer:this.signer})}async vaultedTransfer({recipient:i,quantity:o,lockLengthMs:c,revokable:e=!1},p){let{tags:d=[]}=p||{};return this.process.send({tags:[...d,{name:"Action",value:"Vaulted-Transfer"},{name:"Recipient",value:i},{name:"Quantity",value:o.toString()},{name:"Lock-Length",value:c.toString()},{name:"Revokable",value:`${e}`}],signer:this.signer})}async revokeVault({vaultId:i,recipient:o},c){let{tags:e=[]}=c||{};return this.process.send({tags:[...e,{name:"Action",value:"Revoke-Vault"},{name:"Vault-Id",value:i},{name:"Recipient",value:o}],signer:this.signer})}async createVault({lockLengthMs:i,quantity:o},c){let{tags:e=[]}=c||{};return this.process.send({tags:[...e,{name:"Action",value:"Create-Vault"},{name:"Lock-Length",value:i.toString()},{name:"Quantity",value:o.toString()}],signer:this.signer})}async extendVault({vaultId:i,extendLengthMs:o},c){let{tags:e=[]}=c||{};return this.process.send({tags:[...e,{name:"Action",value:"Extend-Vault"},{name:"Vault-Id",value:i},{name:"Extend-Length",value:o.toString()}],signer:this.signer})}async increaseVault({vaultId:i,quantity:o},c){let{tags:e=[]}=c||{};return this.process.send({tags:[...e,{name:"Action",value:"Increase-Vault"},{name:"Vault-Id",value:i},{name:"Quantity",value:o.toString()}],signer:this.signer})}async joinNetwork({operatorStake:i,allowDelegatedStaking:o,allowedDelegates:c,delegateRewardShareRatio:e,fqdn:p,label:d,minDelegatedStake:b,note:_,port:y,properties:w,protocol:M,autoStake:S,observerAddress:E},x){let{tags:k=[]}=x||{},T=[...k,{name:"Action",value:"Join-Network"},{name:"Operator-Stake",value:i.valueOf().toString()},{name:"Allow-Delegated-Staking",value:o?.toString()},{name:"Allowed-Delegates",value:c?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:e?.toString()},{name:"FQDN",value:p},{name:"Label",value:d},{name:"Min-Delegated-Stake",value:b?.valueOf().toString()},{name:"Note",value:_},{name:"Port",value:y?.toString()},{name:"Properties",value:w},{name:"Protocol",value:M},{name:"Auto-Stake",value:S?.toString()},{name:"Observer-Address",value:E}];return this.process.send({signer:this.signer,tags:Go(T)})}async leaveNetwork(i){let{tags:o=[]}=i||{};return this.process.send({signer:this.signer,tags:[...o,{name:"Action",value:"Leave-Network"}]})}async updateGatewaySettings({allowDelegatedStaking:i,allowedDelegates:o,delegateRewardShareRatio:c,fqdn:e,label:p,minDelegatedStake:d,note:b,port:_,properties:y,protocol:w,autoStake:M,observerAddress:S},E){let{tags:x=[]}=E||{},k=[...x,{name:"Action",value:"Update-Gateway-Settings"},{name:"Label",value:p},{name:"Note",value:b},{name:"FQDN",value:e},{name:"Port",value:_?.toString()},{name:"Properties",value:y},{name:"Protocol",value:w},{name:"Observer-Address",value:S},{name:"Allow-Delegated-Staking",value:i?.toString()},{name:"Allowed-Delegates",value:o?.join(",")},{name:"Delegate-Reward-Share-Ratio",value:c?.toString()},{name:"Min-Delegated-Stake",value:d?.valueOf().toString()},{name:"Auto-Stake",value:M?.toString()}];return this.process.send({signer:this.signer,tags:Go(k)})}async delegateStake(i,o){let{tags:c=[]}=o||{};return this.process.send({signer:this.signer,tags:[...c,{name:"Action",value:"Delegate-Stake"},{name:"Target",value:i.target},{name:"Quantity",value:i.stakeQty.valueOf().toString()}]})}async decreaseDelegateStake(i,o){let{tags:c=[]}=o||{};return this.process.send({signer:this.signer,tags:[...c,{name:"Action",value:"Decrease-Delegate-Stake"},{name:"Target",value:i.target},{name:"Quantity",value:i.decreaseQty.valueOf().toString()},{name:"Instant",value:`${i.instant||!1}`}]})}async instantWithdrawal(i,o){let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Instant-Withdrawal"},{name:"Vault-Id",value:i.vaultId},{name:"Address",value:i.gatewayAddress}];return this.process.send({signer:this.signer,tags:Go(e)})}async increaseOperatorStake(i,o){let{tags:c=[]}=o||{};return this.process.send({signer:this.signer,tags:[...c,{name:"Action",value:"Increase-Operator-Stake"},{name:"Quantity",value:i.increaseQty.valueOf().toString()}]})}async decreaseOperatorStake(i,o){let{tags:c=[]}=o||{};return this.process.send({signer:this.signer,tags:[...c,{name:"Action",value:"Decrease-Operator-Stake"},{name:"Quantity",value:i.decreaseQty.valueOf().toString()},{name:"Instant",value:`${i.instant||!1}`}]})}async saveObservations(i,o){let{tags:c=[]}=o||{};return this.process.send({signer:this.signer,tags:[...c,{name:"Action",value:"Save-Observations"},{name:"Report-Tx-Id",value:i.reportTxId},{name:"Failed-Gateways",value:i.failedGateways.join(",")}]})}async buyRecord(i,o){if(i.fundFrom==="turbo"){if(!(this.paymentProvider instanceof ub))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Buy-Name",name:i.name,years:i.years,type:i.type,processId:i.processId,paidBy:i.paidBy})}let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Buy-Name"},{name:"Name",value:i.name},{name:"Years",value:i.years?.toString()??"1"},{name:"Process-Id",value:i.processId},{name:"Purchase-Type",value:i.type||"lease"},{name:"Fund-From",value:i.fundFrom}];return this.process.send({signer:this.signer,tags:Go(e)})}async upgradeRecord(i,o){if(i.fundFrom==="turbo"){if(!(this.paymentProvider instanceof ub))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Upgrade-Name",name:i.name})}let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Upgrade-Name"},{name:"Name",value:i.name},{name:"Fund-From",value:i.fundFrom}];return this.process.send({signer:this.signer,tags:Go(e)})}async extendLease(i,o){if(i.fundFrom==="turbo"){if(!(this.paymentProvider instanceof ub))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Extend-Lease",name:i.name,years:i.years})}let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Extend-Lease"},{name:"Name",value:i.name},{name:"Years",value:i.years.toString()},{name:"Fund-From",value:i.fundFrom}];return this.process.send({signer:this.signer,tags:Go(e)})}async increaseUndernameLimit(i,o){if(i.fundFrom==="turbo"){if(!(this.paymentProvider instanceof ub))throw new Error("Turbo funding is not supported for this payment provider");return this.paymentProvider.initiateArNSPurchase({intent:"Increase-Undername-Limit",quantity:i.increaseCount,name:i.name})}let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Increase-Undername-Limit"},{name:"Name",value:i.name},{name:"Quantity",value:i.increaseCount.toString()},{name:"Fund-From",value:i.fundFrom}];return this.process.send({signer:this.signer,tags:Go(e)})}async cancelWithdrawal(i,o){let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Cancel-Withdrawal"},{name:"Vault-Id",value:i.vaultId},{name:"Address",value:i.gatewayAddress}];return this.process.send({signer:this.signer,tags:Go(e)})}async requestPrimaryName(i,o){if(i.fundFrom==="turbo")throw new Error("Turbo funding is not yet supported for primary name requests");let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Request-Primary-Name"},{name:"Name",value:i.name},{name:"Fund-From",value:i.fundFrom}];return this.process.send({signer:this.signer,tags:Go(e)})}async redelegateStake(i,o){let{tags:c=[]}=o||{},e=[...c,{name:"Action",value:"Redelegate-Stake"},{name:"Target",value:i.target},{name:"Source",value:i.source},{name:"Quantity",value:i.stakeQty.valueOf().toString()},{name:"Vault-Id",value:i.vaultId}];return this.process.send({signer:this.signer,tags:Go(e)})}};var qXr=async({address:n,registry:i=rR.init()})=>{let o=await i.accessControlList({address:n});return[...new Set([...o.Owned,...o.Controlled])]};function Uve(n,i){return new Promise((o,c)=>{let e=setTimeout(()=>{c(new Error("Timeout"))},n);i.then(p=>{clearTimeout(e),o(p)}).catch(p=>{clearTimeout(e),c(p)})})}var jve=class extends l8t.default{contract;timeoutMs;throttle;logger;strict;antAoClient;constructor({contract:i=gR.init({processId:Fu}),timeoutMs:o=6e4,concurrency:c=30,logger:e=v0.default,strict:p=!1,antAoClient:d=sl({MODE:"legacy"})}={}){super(),this.contract=i,this.timeoutMs=o,this.throttle=K2e(c),this.logger=e,this.strict=p,this.antAoClient=d}async fetchProcessesOwnedByWallet({address:i,pageSize:o,antRegistry:c=rR.init()}){let e={},p=await c.accessControlList({address:i}),d=new Set([...p.Owned,...p.Controlled]);await Uve(this.timeoutMs,i1r({contract:this.contract,emitter:this,pageSize:o})).catch(_=>(this.emit("error",`Error getting ArNS records: ${_}`),this.logger.error("Error getting ArNS records",{message:_?.message,stack:_?.stack}),{})).then(_=>{Object.entries(_).forEach(([y,w])=>{d.has(w.processId)&&(e[w.processId]==null&&(e[w.processId]={state:void 0,names:{}}),e[w.processId].names[y]=w)})});let b=Object.keys(e).length;this.emit("progress",0,b),await Promise.all(Object.keys(e).map(async(_,y)=>this.throttle(async()=>{if(e[_].state!==void 0){this.emit("progress",y+1,b);return}let w=jw.init({process:new cs({processId:_,ao:this.antAoClient}),strict:this.strict}),M=await Uve(this.timeoutMs,w.getState()).catch(S=>{this.emit("error",`Error getting state for process ${_}: ${S}`)});(M?.Owner===i||M?.Controllers.includes(i))&&(e[_].state=M,this.emit("process",_,e[_])),this.emit("progress",y+1,b)}))),this.emit("end",e)}},i1r=async({contract:n=gR.init({processId:Fu}),emitter:i,logger:o=v0.default,pageSize:c=1e3})=>{let e,p=Date.now(),d={};do{let b=await n.getArNSRecords({cursor:e,limit:c}).catch(_=>{o?.error("Error getting ArNS records",{message:_?.message,stack:_?.stack}),i?.emit("arns:error",`Error getting ArNS records: ${_}`)});if(!b)return{};b.items.forEach(_=>{let{name:y,...w}=_;d[y]=w}),o.debug("Fetched page of ArNS records",{totalRecordCount:b.totalItems,fetchedRecordCount:Object.keys(d).length,cursor:b.nextCursor}),i?.emit("arns:pageLoaded",{totalRecordCount:b.totalItems,fetchedRecordCount:Object.keys(d).length,records:b.items,cursor:b.nextCursor}),e=b.nextCursor}while(e!==void 0);return i?.emit("arns:end",d),o.debug("Fetched all ArNS records",{totalRecordCount:Object.keys(d).length,durationMs:Date.now()-p}),d};var cs=class{logger;ao;processId;constructor({processId:i,ao:o=sl({MODE:"legacy"}),logger:c=v0.default}){this.processId=i,this.logger=c,this.ao=o}isMessageDataEmpty(i){return i===void 0||i==="null"||i===""||i===null}async read({tags:i,retries:o=3,fromAddress:c}){this.logger.debug("Evaluating read interaction on process",{tags:i,processId:this.processId});let e={process:this.processId,tags:i};c!==void 0&&(e.Owner=c);let p=0,d;for(;p<o;)try{d=await this.ao.dryrun(e);break}catch(w){if(p++,this.logger.debug(`Read attempt ${p} failed`,{error:w?.message,stack:w?.stack,tags:i,processId:this.processId}),p>=o)throw this.logger.debug("Maximum read attempts exceeded",{error:w?.message,stack:w?.stack,tags:i,processId:this.processId,ao:JSON.stringify(this.ao)}),new Error(`Failed to evaluate a dry-run on process ${this.processId}.`);await new Promise(M=>setTimeout(M,2**p*1e3))}if(d===void 0)throw new Error("Unexpected error when evaluating read interaction");this.logger.debug("Read interaction result",{result:d,processId:this.processId});let b=nK(d);if(b!==void 0)throw new Error(b);if(d.Messages===void 0||d.Messages.length===0)throw this.logger.debug(`Empty result - process ${this.processId} does not support provided action.`,{result:d,tags:i,processId:this.processId}),new Error(d.message||`Process ${this.processId} did not return a valid response. Response: ${JSON.stringify(d)}`);let _=d.Messages?.[0]?.Data;return this.isMessageDataEmpty(_)?void 0:h8t(_)}async send({tags:i,data:o,signer:c,retries:e=3}){let p,d=j2e(32);try{this.logger.debug("Evaluating send interaction on contract",{tags:i,data:o,processId:this.processId}),p=await this.ao.message({process:this.processId,tags:[...i,{name:"AR-IO-SDK",value:Pw}],data:o,signer:c,anchor:d}),this.logger.debug("Sent message to process",{messageId:p,processId:this.processId,anchor:d})}catch(M){throw this.logger.debug("Error sending message to process",{error:M?.message,stack:M?.stack,processId:this.processId,tags:i}),M}if(p===void 0)throw new Error("Failed to send message to process.");let b,_=0;for(;_<e;)try{b=await this.ao.result({message:p,process:this.processId}),this.logger.debug("Message result",{result:b,messageId:p,processId:this.processId});break}catch(M){if(_++,this.logger.debug("Retrying send interaction",{attempts:_,retries:e,error:M?.message,processId:this.processId}),_>=e)return this.logger.debug(`Message was sent to process ${this.processId} with id ${p} but result was not returned. Review transactions for more details.`,{error:M?.message,stack:M?.stack,tags:i,processId:this.processId,messageId:p}),{id:p};await new Promise(S=>setTimeout(S,2**_*2e3))}if(b===void 0)return this.logger.debug(`Message was sent to process ${this.processId} with id ${p} but the result was not returned. Review transactions for more details.`,{tags:i,processId:this.processId,messageId:p}),{id:p};let y=nK(b);if(y!==void 0)throw new AF(y);if(b.Messages?.length===0||b.Messages===void 0)return{id:p};if(this.isMessageDataEmpty(b.Messages[0].Data))return{id:p};let w=h8t(b.Messages[0].Data);return this.logger.debug("Message result data",{resultData:w,messageId:p,processId:this.processId}),{id:p,result:w}}};var aK=class{static init(i){return i!==void 0&&"signer"in i?new X8t(i):new oK(i)}},oK=class{process;constructor(i){if(i===void 0||Object.keys(i).length===0)this.process=new cs({processId:E5});else if(ob(i))this.process=i.process;else if(sb(i))this.process=new cs({processId:i.processId});else throw new hm}async getANTVersions(){let i=await this.process.read({tags:[{name:"Action",value:"Get-Versions"}]});return Object.fromEntries(Object.entries(i).sort(([o],[c])=>o.localeCompare(c)))}async getLatestANTVersion(){let i=await this.getANTVersions(),o=Object.entries(i).at(-1);if(!o)throw new Error("No version found");return{version:o[0],...o[1]}}},X8t=class extends oK{signer;constructor({signer:i,...o}){super(o),this.signer=ab(i)}async addVersion(i,o){let{version:c,moduleId:e,luaSourceId:p,notes:d}=i;return this.process.send({tags:Go([{name:"Action",value:"Add-Version"},{name:"Version",value:c},{name:"Module-Id",value:e},{name:"Lua-Source-Id",value:p},{name:"Notes",value:d},...o?.tags??[]]),signer:this.signer})}};var jw=class{static versions=aK.init();static init(i){return i!==void 0&&"signer"in i?new J8t(i):new sK(i)}},sK=class{process;processId;strict;constructor(i){if(this.strict=i.strict||!1,ob(i))this.process=i.process;else if(sb(i))this.process=new cs({processId:i.processId});else throw new hm;this.processId=this.process.processId}async getState({strict:i}={strict:this.strict}){let o=[{name:"Action",value:"State"}],c=await this.process.read({tags:o});return i&&mm(dnt.passthrough().and(Xr.object({Records:Xr.record(Xr.string(),sP.passthrough())})),c),c}async getInfo({strict:i}={strict:this.strict}){let o=[{name:"Action",value:"Info"}],c=await this.process.read({tags:o});return i&&mm(Wjt.passthrough(),c),c}async getLogo(){return(await this.getInfo()).Logo}async getRecord({undername:i},{strict:o}={strict:this.strict}){let c=await this.process.read({tags:[{name:"Action",value:"Record"},{name:"Sub-Domain",value:i}]});return o&&mm(sP.passthrough(),c),c}async getRecords({strict:i}={strict:this.strict}){let o=[{name:"Action",value:"Records"}],c=await this.process.read({tags:o});return i&&mm(fP,c),C2e(c)}async getOwner({strict:i}={strict:this.strict}){return(await this.getInfo({strict:i})).Owner}async getControllers({strict:i}={strict:this.strict}){let o=[{name:"Action",value:"Controllers"}],c=await this.process.read({tags:o});return i&&mm(hP,c),c}async getName({strict:i}={strict:this.strict}){return(await this.getInfo({strict:i})).Name}async getTicker({strict:i}={strict:this.strict}){return(await this.getInfo({strict:i})).Ticker}async getBalances({strict:i}={strict:this.strict}){let o=[{name:"Action",value:"Balances"}],c=await this.process.read({tags:o});return i&&mm(uP,c),c}async getBalance({address:i},{strict:o}={strict:this.strict}){let c=[{name:"Action",value:"Balance"},{name:"Recipient",value:i}],e=await this.process.read({tags:c});return o&&mm(Xr.number(),e),e}async getHandlers(){let i=await this.getInfo();return i.Handlers??i.HandlerNames}},J8t=class extends sK{signer;constructor({signer:i,...o}){super(o),this.signer=ab(i)}async transfer({target:i},o){let c=[...o?.tags??[],{name:"Action",value:"Transfer"},{name:"Recipient",value:i}];return this.process.send({tags:c,signer:this.signer})}async addController({controller:i},o){let c=[...o?.tags??[],{name:"Action",value:"Add-Controller"},{name:"Controller",value:i}];return this.process.send({tags:c,signer:this.signer})}async removeController({controller:i},o){let c=[...o?.tags??[],{name:"Action",value:"Remove-Controller"},{name:"Controller",value:i}];return this.process.send({tags:c,signer:this.signer})}async setRecord({undername:i,transactionId:o,ttlSeconds:c},e){return this.process.send({tags:[...e?.tags??[],{name:"Action",value:"Set-Record"},{name:"Sub-Domain",value:i},{name:"Transaction-Id",value:o},{name:"TTL-Seconds",value:c.toString()}],signer:this.signer})}async setBaseNameRecord({transactionId:i,ttlSeconds:o},c){return this.setRecord({transactionId:i,ttlSeconds:o,undername:"@"},c)}async setUndernameRecord({undername:i,transactionId:o,ttlSeconds:c},e){return this.setRecord({undername:i,transactionId:o,ttlSeconds:c},e)}async removeUndernameRecord({undername:i}){return this.removeRecord({undername:i})}async removeRecord({undername:i},o){return this.process.send({tags:[...o?.tags??[],{name:"Action",value:"Remove-Record"},{name:"Sub-Domain",value:i}],signer:this.signer})}async setTicker({ticker:i},o){return this.process.send({tags:[...o?.tags??[],{name:"Action",value:"Set-Ticker"},{name:"Ticker",value:i}],signer:this.signer})}async setName({name:i},o){return this.process.send({tags:[...o?.tags??[],{name:"Action",value:"Set-Name"},{name:"Name",value:i}],signer:this.signer})}async setDescription({description:i},o){return this.process.send({tags:[...o?.tags??[],{name:"Action",value:"Set-Description"},{name:"Description",value:i}],signer:this.signer})}async setKeywords({keywords:i},o){return this.process.send({tags:[...o?.tags??[],{name:"Action",value:"Set-Keywords"},{name:"Keywords",value:JSON.stringify(i)}],signer:this.signer})}async setLogo({txId:i},o){return this.process.send({tags:[...o?.tags??[],{name:"Action",value:"Set-Logo"},{name:"Logo",value:i}],signer:this.signer})}async releaseName({name:i,arioProcessId:o},c){return this.process.send({tags:[...c?.tags??[],{name:"Action",value:"Release-Name"},{name:"Name",value:i},{name:"IO-Process-Id",value:o},{name:"ARIO-Process-Id",value:o}],signer:this.signer})}async reassignName({name:i,arioProcessId:o,antProcessId:c},e){return this.process.send({tags:[...e?.tags??[],{name:"Action",value:"Reassign-Name"},{name:"Name",value:i},{name:"IO-Process-Id",value:o},{name:"ARIO-Process-Id",value:o},{name:"Process-Id",value:c}],signer:this.signer})}async approvePrimaryNameRequest({name:i,address:o,arioProcessId:c},e){return this.process.send({tags:[...e?.tags??[],{name:"Action",value:"Approve-Primary-Name"},{name:"Name",value:i},{name:"Recipient",value:o},{name:"IO-Process-Id",value:c},{name:"ARIO-Process-Id",value:c}],signer:this.signer})}async removePrimaryNames({names:i,arioProcessId:o,notifyOwners:c=!1},e){return this.process.send({tags:[...e?.tags??[],{name:"Action",value:"Remove-Primary-Names"},{name:"Names",value:i.join(",")},{name:"IO-Process-Id",value:o},{name:"ARIO-Process-Id",value:o},{name:"Notify-Owners",value:c.toString()}],signer:this.signer})}};async function _Qr({signer:n,module:i=qjt,ao:o=sl({MODE:"legacy"}),scheduler:c=Fjt,state:e,antRegistryId:p=E5,logger:d=v0.default,authority:b=jjt}){e&&mm(Hjt,e);let _=await o.spawn({module:i,scheduler:c,signer:n,data:e?JSON.stringify(e):void 0,tags:[{name:"Authority",value:b},{name:"ANT-Registry-Id",value:p}]}),y,w=0;for(;w<5&&y===void 0;)try{y=await o.result({process:_,message:_});break}catch(M){d.debug("Retrying ANT boot result fetch",{processId:_,module:i,scheduler:c,attempts:w,error:M}),w++,await new Promise(S=>setTimeout(S,1e3*w**2))}if(y===void 0||y.Messages?.some(M=>M?.Tags?.some(S=>S.value==="Invalid-Boot-Notice"))){if(y===void 0)throw new Error("Failed to get boot result");let M=nK(y);throw d.error("ANT failed to boot correctly",{processId:_,module:i,scheduler:c,bootRes:y,bootError:M}),new Error(`ANT failed to boot correctly: ${M}`)}return d.debug("Spawned ANT",{processId:_,module:i,scheduler:c}),_}async function MQr({signer:n,processId:i,luaCodeTxId:o=Ujt,ao:c=sl({MODE:"legacy"}),logger:e=v0.default,arweave:p=xF}){let d=new cs({processId:i,ao:c,logger:e}),{api:{host:b,port:_,protocol:y}}=p.getConfig(),w=await fetch(`${y}://${b}:${_}/${o}`).then(S=>S.text()),{id:M}=await d.send({tags:[{name:"Action",value:"Eval"},{name:"App-Name",value:"ArNS-ANT"},{name:"Source-Code-TX-ID",value:o}],data:w,signer:n});return e.debug("Evolved ANT",{processId:i,luaCodeTxId:o,evalMsgId:M}),M}function n1r(n){let i=Xr.object({name:Xr.string(),value:Xr.union([Xr.string(),Xr.number()])}),o=Xr.function().args(Xr.object({data:Xr.union([Xr.string(),Xr.instanceof(Zt)]),tags:Xr.array(i).optional(),target:Xr.string().optional(),anchor:Xr.string().optional()})).returns(Xr.promise(Xr.object({id:Xr.string(),raw:Xr.instanceof(ArrayBuffer)})));try{return o.parse(n),!0}catch{return!1}}function ab(n){return n1r(n)?n:"publicKey"in n?async({data:o,tags:c,target:e,anchor:p})=>{if(n.publicKey===void 0&&"setPublicKey"in n&&typeof n.setPublicKey=="function"&&await n.setPublicKey(),n instanceof Wd){let _=await n.signer.signDataItem({data:o,tags:c,target:e,anchor:p}),y=new d5(Zt.from(_));return{id:await y.id,raw:await y.getRaw()}}let d=dM(o,n,{tags:c,target:e,anchor:p});return d.sign(n).then(async()=>({id:await d.id,raw:await d.getRaw()}))}:Eue(n)}var a1r="-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI",o1r="Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A";function SQr({owner:n,targetId:i,ttlSeconds:o=3600,keywords:c=[],controllers:e=[],description:p="",ticker:d="aos",name:b="ANT",logo:_=o1r}){return{ticker:d,name:b,description:p,keywords:c,owner:n,controllers:[n,...e],balances:{[n]:1},records:{"@":{transactionId:i??a1r.toString(),ttlSeconds:o}},logo:_}}function Q8t(n){return Xr.object({startTimestamp:Xr.number(),startHeight:Xr.number(),distributions:Xr.any(),endTimestamp:Xr.number(),prescribedObservers:Xr.any(),prescribedNames:Xr.array(Xr.string()),observations:Xr.any(),epochIndex:Xr.number()}).parse(n)}function nK(n){let o=n.Error??n.Messages?.[0]?.Tags?.find(c=>c.name==="Error")?.value;if(o!==void 0){let c=o.match(/\[string "aos"]:(\d+):\s*(.+)/);if(c){let[,e,p]=c;return`${Fve(p).trim()} (line ${e.trim()})`.trim()}return Fve(o)}}function Fve(n){let i="\x1B";return n.replace(new RegExp(`${i}[\\[\\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]`,"g"),"").trim()}var zve=n=>aP.test(n);function LQr(n){return n!==void 0&&!isNaN(parseInt(n.toString()))}var Go=n=>n.filter(i=>i.value!==void 0&&i.value!==""),eu=n=>{let i=[{name:"Cursor",value:n?.cursor?.toString()},{name:"Limit",value:n?.limit?.toString()},{name:"Sort-By",value:n?.sortBy?.toString()},{name:"Sort-Order",value:n?.sortOrder?.toString()}];return Go(i)},s1r=async({arweave:n,epochIndex:i,processId:o=Fu,retries:c=3,gqlUrl:e="https://arweave-search.goldsky.com/graphql"})=>{let p=h1r({epochIndex:i,processId:o});for(let d=0;d<c;d++)try{let b=await fetch(e,{method:"POST",body:p,headers:{"Content-Type":"application/json"}}).then(w=>w.json());if(b?.data?.transactions?.edges?.length===0)return;let _=b.data.transactions.edges[0].node.id,y=await n.api.get(_);return Q8t(y.data)}catch(b){if(d===c-1)throw b;await new Promise(_=>setTimeout(_,Math.pow(2,d)*1e3))}},C8=async({arweave:n,ao:i,epochIndex:o,processId:c=Fu})=>{let e=await s1r({arweave:n,epochIndex:o,processId:c});if(e)return e;let p=await f1r({ao:i,epochIndex:o,processId:c});if(p)return p},f1r=async({ao:n,epochIndex:i,processId:o=Fu,gqlUrl:c="https://arweave-search.goldsky.com/graphql"})=>{let e=u1r({epochIndex:i,processId:o}),d=await(await fetch(c,{method:"POST",body:e,headers:{"Content-Type":"application/json"}})).json();if(d.data.transactions.edges.length!==0)for(let b of d.data.transactions.edges){let _=b.node.id,y=await n.result({message:_,process:o}).catch(()=>{});if(y)for(let w of y?.Messages??[]){let M=JSON.parse(w.Data),S=w.Tags;if(S.some(E=>E.name==="Action"&&E.value==="Epoch-Distribution-Notice")&&S.some(E=>E.name==="Epoch-Index"&&E.value===i.toString()))return Q8t(M)}}},h1r=({epochIndex:n,processId:i=Fu,authorities:o=["fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY"]})=>JSON.stringify({query:`
286
286
  query {
287
287
  transactions(
288
288
  tags: [
@@ -44,6 +44,7 @@ async function buyRecordCLICommand(o) {
44
44
  type,
45
45
  years,
46
46
  fundFrom: (0, utils_js_1.fundFromFromOptions)(o),
47
+ paidBy: (0, utils_js_1.stringArrayFromOptions)(o, 'paidBy'),
47
48
  }, (0, utils_js_1.customTagsFromOptions)(o));
48
49
  }
49
50
  async function upgradeRecordCLICommand(o) {
@@ -75,6 +76,7 @@ async function upgradeRecordCLICommand(o) {
75
76
  return ario.upgradeRecord({
76
77
  name,
77
78
  fundFrom,
79
+ paidBy: (0, utils_js_1.stringArrayFromOptions)(o, 'paidBy'),
78
80
  });
79
81
  }
80
82
  async function extendLeaseCLICommand(o) {
@@ -108,6 +110,7 @@ async function extendLeaseCLICommand(o) {
108
110
  return ario.extendLease({
109
111
  name,
110
112
  years,
113
+ paidBy: (0, utils_js_1.stringArrayFromOptions)(o, 'paidBy'),
111
114
  }, (0, utils_js_1.customTagsFromOptions)(o));
112
115
  }
113
116
  async function increaseUndernameLimitCLICommand(o) {
@@ -138,6 +141,7 @@ async function increaseUndernameLimitCLICommand(o) {
138
141
  return ario.increaseUndernameLimit({
139
142
  name,
140
143
  increaseCount,
144
+ paidBy: (0, utils_js_1.stringArrayFromOptions)(o, 'paidBy'),
141
145
  }, (0, utils_js_1.customTagsFromOptions)(o));
142
146
  }
143
147
  async function requestPrimaryNameCLICommand(o) {
@@ -162,5 +166,6 @@ async function requestPrimaryNameCLICommand(o) {
162
166
  return ario.requestPrimaryName({
163
167
  name,
164
168
  fundFrom,
169
+ paidBy: (0, utils_js_1.stringArrayFromOptions)(o, 'paidBy'),
165
170
  }, (0, utils_js_1.customTagsFromOptions)(o));
166
171
  }
@@ -281,6 +281,11 @@ exports.optionMap = {
281
281
  description: 'Crypto token type for wallet or action',
282
282
  default: 'arweave',
283
283
  },
284
+ paidBy: {
285
+ alias: '--paid-by <paidBy...>',
286
+ description: 'Addresses to pay for the interaction',
287
+ type: 'array',
288
+ },
284
289
  };
285
290
  exports.walletOptions = [
286
291
  exports.optionMap.walletFile,
@@ -302,6 +307,7 @@ exports.arnsPurchaseOptions = [
302
307
  ...exports.writeActionOptions,
303
308
  exports.optionMap.name,
304
309
  exports.optionMap.fundFrom,
310
+ exports.optionMap.paidBy,
305
311
  exports.optionMap.paymentUrl,
306
312
  ];
307
313
  exports.epochOptions = [exports.optionMap.epochIndex, exports.optionMap.timestamp];
@@ -39,6 +39,7 @@ exports.readANTFromOptions = readANTFromOptions;
39
39
  exports.writeANTFromOptions = writeANTFromOptions;
40
40
  exports.booleanFromOptions = booleanFromOptions;
41
41
  exports.requiredStringFromOptions = requiredStringFromOptions;
42
+ exports.stringArrayFromOptions = stringArrayFromOptions;
42
43
  exports.requiredStringArrayFromOptions = requiredStringArrayFromOptions;
43
44
  exports.positiveIntegerFromOptions = positiveIntegerFromOptions;
44
45
  exports.requiredPositiveIntegerFromOptions = requiredPositiveIntegerFromOptions;
@@ -352,6 +353,7 @@ function requiredMARIOFromOptions(options, key) {
352
353
  }
353
354
  async function assertEnoughBalanceForArNSPurchase({ ario, address, costDetailsParams, }) {
354
355
  if (costDetailsParams.fundFrom === 'turbo') {
356
+ // TODO: Get turbo balance and assert it is enough -- retain paid-by from balance result and pass to CLI logic
355
357
  return;
356
358
  }
357
359
  const costDetails = await ario.getCostDetails(costDetailsParams);
@@ -428,16 +430,23 @@ function requiredStringFromOptions(options, key) {
428
430
  }
429
431
  return value;
430
432
  }
431
- function requiredStringArrayFromOptions(options, key) {
433
+ function stringArrayFromOptions(options, key) {
432
434
  const value = options[key];
433
435
  if (value === undefined) {
434
- throw new Error(`--${key} is required`);
436
+ return undefined;
435
437
  }
436
438
  if (!Array.isArray(value)) {
437
439
  throw new Error(`--${key} must be an array`);
438
440
  }
439
441
  return value;
440
442
  }
443
+ function requiredStringArrayFromOptions(options, key) {
444
+ const value = stringArrayFromOptions(options, key);
445
+ if (value === undefined) {
446
+ throw new Error(`--${key} is required`);
447
+ }
448
+ return value;
449
+ }
441
450
  function positiveIntegerFromOptions(options, key) {
442
451
  const value = options[key];
443
452
  if (value === undefined) {
@@ -974,6 +974,7 @@ class ARIOWriteable extends ARIOReadable {
974
974
  years: params.years,
975
975
  type: params.type,
976
976
  processId: params.processId,
977
+ paidBy: params.paidBy,
977
978
  });
978
979
  }
979
980
  const { tags = [] } = options || {};
@@ -155,7 +155,7 @@ class TurboArNSPaymentProviderAuthenticated extends TurboArNSPaymentProviderUnau
155
155
  }
156
156
  this.signer = signer;
157
157
  }
158
- async initiateArNSPurchase({ intent, name, quantity, type, processId, years, }) {
158
+ async initiateArNSPurchase({ intent, name, quantity, type, processId, years, paidBy = [], }) {
159
159
  // Signer check is implicitly handled by requiring it in the constructor
160
160
  const url = (0, url_js_1.urlWithSearchParams)({
161
161
  baseUrl: `${this.paymentUrl}/v1/arns/purchase/${intent}/${name}`,
@@ -164,6 +164,7 @@ class TurboArNSPaymentProviderAuthenticated extends TurboArNSPaymentProviderUnau
164
164
  processId,
165
165
  type,
166
166
  years,
167
+ paidBy,
167
168
  },
168
169
  });
169
170
  const headers = await signedRequestHeadersFromSigner({
@@ -21,6 +21,13 @@ const urlWithSearchParams = ({ baseUrl, params, }) => {
21
21
  Object.entries(params).forEach(([key, value]) => {
22
22
  if (value === undefined || value === null)
23
23
  return;
24
+ if (Array.isArray(value) && value.length > 0) {
25
+ for (const v of value) {
26
+ if (v === undefined || v === null)
27
+ continue;
28
+ urlObj.searchParams.append(key, v.toString());
29
+ }
30
+ }
24
31
  urlObj.searchParams.set(key, value.toString());
25
32
  });
26
33
  return urlObj.toString();
@@ -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.11.1-alpha.1';
20
+ exports.version = '3.12.0-alpha.1';
@@ -1,4 +1,4 @@
1
- import { assertConfirmationPrompt, assertEnoughBalanceForArNSPurchase, customTagsFromOptions, fundFromFromOptions, positiveIntegerFromOptions, recordTypeFromOptions, requiredPositiveIntegerFromOptions, requiredStringFromOptions, writeARIOFromOptions, } from '../utils.js';
1
+ import { assertConfirmationPrompt, assertEnoughBalanceForArNSPurchase, customTagsFromOptions, fundFromFromOptions, positiveIntegerFromOptions, recordTypeFromOptions, requiredPositiveIntegerFromOptions, requiredStringFromOptions, stringArrayFromOptions, writeARIOFromOptions, } from '../utils.js';
2
2
  export async function buyRecordCLICommand(o) {
3
3
  const { ario, signerAddress } = writeARIOFromOptions(o);
4
4
  const name = requiredStringFromOptions(o, 'name');
@@ -37,6 +37,7 @@ export async function buyRecordCLICommand(o) {
37
37
  type,
38
38
  years,
39
39
  fundFrom: fundFromFromOptions(o),
40
+ paidBy: stringArrayFromOptions(o, 'paidBy'),
40
41
  }, customTagsFromOptions(o));
41
42
  }
42
43
  export async function upgradeRecordCLICommand(o) {
@@ -68,6 +69,7 @@ export async function upgradeRecordCLICommand(o) {
68
69
  return ario.upgradeRecord({
69
70
  name,
70
71
  fundFrom,
72
+ paidBy: stringArrayFromOptions(o, 'paidBy'),
71
73
  });
72
74
  }
73
75
  export async function extendLeaseCLICommand(o) {
@@ -101,6 +103,7 @@ export async function extendLeaseCLICommand(o) {
101
103
  return ario.extendLease({
102
104
  name,
103
105
  years,
106
+ paidBy: stringArrayFromOptions(o, 'paidBy'),
104
107
  }, customTagsFromOptions(o));
105
108
  }
106
109
  export async function increaseUndernameLimitCLICommand(o) {
@@ -131,6 +134,7 @@ export async function increaseUndernameLimitCLICommand(o) {
131
134
  return ario.increaseUndernameLimit({
132
135
  name,
133
136
  increaseCount,
137
+ paidBy: stringArrayFromOptions(o, 'paidBy'),
134
138
  }, customTagsFromOptions(o));
135
139
  }
136
140
  export async function requestPrimaryNameCLICommand(o) {
@@ -155,5 +159,6 @@ export async function requestPrimaryNameCLICommand(o) {
155
159
  return ario.requestPrimaryName({
156
160
  name,
157
161
  fundFrom,
162
+ paidBy: stringArrayFromOptions(o, 'paidBy'),
158
163
  }, customTagsFromOptions(o));
159
164
  }
@@ -278,6 +278,11 @@ export const optionMap = {
278
278
  description: 'Crypto token type for wallet or action',
279
279
  default: 'arweave',
280
280
  },
281
+ paidBy: {
282
+ alias: '--paid-by <paidBy...>',
283
+ description: 'Addresses to pay for the interaction',
284
+ type: 'array',
285
+ },
281
286
  };
282
287
  export const walletOptions = [
283
288
  optionMap.walletFile,
@@ -299,6 +304,7 @@ export const arnsPurchaseOptions = [
299
304
  ...writeActionOptions,
300
305
  optionMap.name,
301
306
  optionMap.fundFrom,
307
+ optionMap.paidBy,
302
308
  optionMap.paymentUrl,
303
309
  ];
304
310
  export const epochOptions = [optionMap.epochIndex, optionMap.timestamp];
@@ -304,6 +304,7 @@ export function requiredMARIOFromOptions(options, key) {
304
304
  }
305
305
  export async function assertEnoughBalanceForArNSPurchase({ ario, address, costDetailsParams, }) {
306
306
  if (costDetailsParams.fundFrom === 'turbo') {
307
+ // TODO: Get turbo balance and assert it is enough -- retain paid-by from balance result and pass to CLI logic
307
308
  return;
308
309
  }
309
310
  const costDetails = await ario.getCostDetails(costDetailsParams);
@@ -380,16 +381,23 @@ export function requiredStringFromOptions(options, key) {
380
381
  }
381
382
  return value;
382
383
  }
383
- export function requiredStringArrayFromOptions(options, key) {
384
+ export function stringArrayFromOptions(options, key) {
384
385
  const value = options[key];
385
386
  if (value === undefined) {
386
- throw new Error(`--${key} is required`);
387
+ return undefined;
387
388
  }
388
389
  if (!Array.isArray(value)) {
389
390
  throw new Error(`--${key} must be an array`);
390
391
  }
391
392
  return value;
392
393
  }
394
+ export function requiredStringArrayFromOptions(options, key) {
395
+ const value = stringArrayFromOptions(options, key);
396
+ if (value === undefined) {
397
+ throw new Error(`--${key} is required`);
398
+ }
399
+ return value;
400
+ }
393
401
  export function positiveIntegerFromOptions(options, key) {
394
402
  const value = options[key];
395
403
  if (value === undefined) {
@@ -969,6 +969,7 @@ export class ARIOWriteable extends ARIOReadable {
969
969
  years: params.years,
970
970
  type: params.type,
971
971
  processId: params.processId,
972
+ paidBy: params.paidBy,
972
973
  });
973
974
  }
974
975
  const { tags = [] } = options || {};
@@ -148,7 +148,7 @@ export class TurboArNSPaymentProviderAuthenticated extends TurboArNSPaymentProvi
148
148
  }
149
149
  this.signer = signer;
150
150
  }
151
- async initiateArNSPurchase({ intent, name, quantity, type, processId, years, }) {
151
+ async initiateArNSPurchase({ intent, name, quantity, type, processId, years, paidBy = [], }) {
152
152
  // Signer check is implicitly handled by requiring it in the constructor
153
153
  const url = urlWithSearchParams({
154
154
  baseUrl: `${this.paymentUrl}/v1/arns/purchase/${intent}/${name}`,
@@ -157,6 +157,7 @@ export class TurboArNSPaymentProviderAuthenticated extends TurboArNSPaymentProvi
157
157
  processId,
158
158
  type,
159
159
  years,
160
+ paidBy,
160
161
  },
161
162
  });
162
163
  const headers = await signedRequestHeadersFromSigner({
@@ -18,6 +18,13 @@ export const urlWithSearchParams = ({ baseUrl, params, }) => {
18
18
  Object.entries(params).forEach(([key, value]) => {
19
19
  if (value === undefined || value === null)
20
20
  return;
21
+ if (Array.isArray(value) && value.length > 0) {
22
+ for (const v of value) {
23
+ if (v === undefined || v === null)
24
+ continue;
25
+ urlObj.searchParams.append(key, v.toString());
26
+ }
27
+ }
21
28
  urlObj.searchParams.set(key, value.toString());
22
29
  });
23
30
  return urlObj.toString();
@@ -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.11.1-alpha.1';
17
+ export const version = '3.12.0-alpha.1';
@@ -274,6 +274,11 @@ export declare const optionMap: {
274
274
  description: string;
275
275
  default: string;
276
276
  };
277
+ paidBy: {
278
+ alias: string;
279
+ description: string;
280
+ type: string;
281
+ };
277
282
  };
278
283
  export declare const walletOptions: {
279
284
  alias: string;
@@ -75,6 +75,7 @@ export declare function readANTFromOptions(options: ProcessIdCLIOptions): AoANTR
75
75
  export declare function writeANTFromOptions(options: ProcessIdCLIOptions, signer?: ContractSigner): AoANTWrite;
76
76
  export declare function booleanFromOptions<O extends GlobalCLIOptions>(options: O, key: string): boolean;
77
77
  export declare function requiredStringFromOptions<O extends GlobalCLIOptions>(options: O, key: string): string;
78
+ export declare function stringArrayFromOptions<O extends GlobalCLIOptions>(options: O, key: string): string[] | undefined;
78
79
  export declare function requiredStringArrayFromOptions<O extends GlobalCLIOptions>(options: O, key: string): string[];
79
80
  export declare function positiveIntegerFromOptions<O extends GlobalCLIOptions>(options: O, key: string): number | undefined;
80
81
  export declare function requiredPositiveIntegerFromOptions<O extends GlobalCLIOptions>(options: O, key: string): number;
@@ -29,10 +29,12 @@ export interface ArNSPaymentProvider {
29
29
  mARIO: mARIOToken;
30
30
  }>;
31
31
  }
32
+ export interface TurboInitiateArNSPurchaseParams extends AoTokenCostParams {
33
+ processId?: TransactionId;
34
+ paidBy?: string | string[];
35
+ }
32
36
  export interface ArNSAuthenticatedPaymentProvider extends ArNSPaymentProvider {
33
- initiateArNSPurchase(params: AoTokenCostParams & {
34
- processId?: TransactionId;
35
- }): Promise<AoMessageResult<ArNSPurchaseReceipt>>;
37
+ initiateArNSPurchase(params: TurboInitiateArNSPurchaseParams): Promise<AoMessageResult<ArNSPurchaseReceipt>>;
36
38
  }
37
39
  export declare class TurboArNSPaymentFactory {
38
40
  static init(): TurboArNSPaymentProviderUnauthenticated;
@@ -55,8 +57,6 @@ export declare class TurboArNSPaymentProviderUnauthenticated implements ArNSPaym
55
57
  export declare class TurboArNSPaymentProviderAuthenticated extends TurboArNSPaymentProviderUnauthenticated implements ArNSAuthenticatedPaymentProvider {
56
58
  private readonly signer;
57
59
  constructor({ signer, ...restConfig }: TurboAuthenticatedConfig);
58
- initiateArNSPurchase({ intent, name, quantity, type, processId, years, }: AoTokenCostParams & {
59
- processId?: TransactionId;
60
- }): Promise<AoMessageResult<ArNSPurchaseReceipt>>;
60
+ initiateArNSPurchase({ intent, name, quantity, type, processId, years, paidBy, }: TurboInitiateArNSPurchaseParams): Promise<AoMessageResult<ArNSPurchaseReceipt>>;
61
61
  }
62
62
  export declare function isTurboArNSSigner(signer: unknown): signer is TurboArNSSigner;
@@ -346,6 +346,7 @@ export type AoGetVaultParams = {
346
346
  };
347
347
  export type AoArNSPurchaseParams = AoArNSNameParams & {
348
348
  fundFrom?: FundFrom;
349
+ paidBy?: WalletAddress | WalletAddress[];
349
350
  };
350
351
  export type AoBuyRecordParams = AoArNSPurchaseParams & {
351
352
  years?: number;
@@ -15,5 +15,5 @@
15
15
  */
16
16
  export declare const urlWithSearchParams: ({ baseUrl, params, }: {
17
17
  baseUrl: string;
18
- params: Record<string, string | number | boolean | null | undefined>;
18
+ params: Record<string, string | number | boolean | string[] | null | undefined>;
19
19
  }) => string;
@@ -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.11.0";
16
+ export declare const version = "3.11.1-alpha.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.11.1-alpha.1",
3
+ "version": "3.12.0-alpha.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"