phala 1.1.0-beta.8 → 1.1.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +23 -23
- package/dist/index.js +124 -123
- package/package.json +2 -2
package/dist/api/index.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
2
|
-
var
|
|
2
|
+
var Qs=Object.create;var uo=Object.defineProperty;var ei=Object.getOwnPropertyDescriptor;var ti=Object.getOwnPropertyNames;var ri=Object.getPrototypeOf,oi=Object.prototype.hasOwnProperty;var be=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var T=(e,t)=>()=>(e&&(t=e(e=0)),t);var W=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ni=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ti(t))!oi.call(e,n)&&n!==r&&uo(e,n,{get:()=>t[n],enumerable:!(o=ei(t,n))||o.enumerable});return e};var ut=(e,t,r)=>(r=e!=null?Qs(ri(e)):{},ni(t||!e||!e.__esModule?uo(r,"default",{value:e,enumerable:!0}):r,e));var mo=W((xu,fo)=>{var Ke=1e3,We=Ke*60,Xe=We*60,Ue=Xe*24,si=Ue*7,ii=Ue*365.25;fo.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return ai(e);if(r==="number"&&isFinite(e))return t.long?li(e):ci(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ai(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*ii;case"weeks":case"week":case"w":return r*si;case"days":case"day":case"d":return r*Ue;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Xe;case"minutes":case"minute":case"mins":case"min":case"m":return r*We;case"seconds":case"second":case"secs":case"sec":case"s":return r*Ke;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function ci(e){var t=Math.abs(e);return t>=Ue?Math.round(e/Ue)+"d":t>=Xe?Math.round(e/Xe)+"h":t>=We?Math.round(e/We)+"m":t>=Ke?Math.round(e/Ke)+"s":e+"ms"}function li(e){var t=Math.abs(e);return t>=Ue?Rt(e,t,Ue,"day"):t>=Xe?Rt(e,t,Xe,"hour"):t>=We?Rt(e,t,We,"minute"):t>=Ke?Rt(e,t,Ke,"second"):e+" ms"}function Rt(e,t,r,o){var n=t>=r*1.5;return Math.round(e/r)+" "+o+(n?"s":"")}});var vr=W((gu,ho)=>{function pi(e){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=n,r.enabled=a,r.humanize=mo(),r.destroy=u,Object.keys(e).forEach(f=>{r[f]=e[f]}),r.names=[],r.skips=[],r.formatters={};function t(f){let p=0;for(let d=0;d<f.length;d++)p=(p<<5)-p+f.charCodeAt(d),p|=0;return r.colors[Math.abs(p)%r.colors.length]}r.selectColor=t;function r(f){let p,d=null,h,I;function k(...P){if(!k.enabled)return;let V=k,K=Number(new Date),O=K-(p||K);V.diff=O,V.prev=p,V.curr=K,p=K,P[0]=r.coerce(P[0]),typeof P[0]!="string"&&P.unshift("%O");let Z=0;P[0]=P[0].replace(/%([a-zA-Z%])/g,(Q,Lt)=>{if(Q==="%%")return"%";Z++;let po=r.formatters[Lt];if(typeof po=="function"){let Ys=P[Z];Q=po.call(V,Ys),P.splice(Z,1),Z--}return Q}),r.formatArgs.call(V,P),(V.log||r.log).apply(V,P)}return k.namespace=f,k.useColors=r.useColors(),k.color=r.selectColor(f),k.extend=o,k.destroy=r.destroy,Object.defineProperty(k,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(h!==r.namespaces&&(h=r.namespaces,I=r.enabled(f)),I),set:P=>{d=P}}),typeof r.init=="function"&&r.init(k),k}function o(f,p){let d=r(this.namespace+(typeof p>"u"?":":p)+f);return d.log=this.log,d}function n(f){r.save(f),r.namespaces=f,r.names=[],r.skips=[];let p=(typeof f=="string"?f:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let d of p)d[0]==="-"?r.skips.push(d.slice(1)):r.names.push(d)}function s(f,p){let d=0,h=0,I=-1,k=0;for(;d<f.length;)if(h<p.length&&(p[h]===f[d]||p[h]==="*"))p[h]==="*"?(I=h,k=d,h++):(d++,h++);else if(I!==-1)h=I+1,k++,d=k;else return!1;for(;h<p.length&&p[h]==="*";)h++;return h===p.length}function i(){let f=[...r.names,...r.skips.map(p=>"-"+p)].join(",");return r.enable(""),f}function a(f){for(let p of r.skips)if(s(f,p))return!1;for(let p of r.names)if(s(f,p))return!0;return!1}function l(f){return f instanceof Error?f.stack||f.message:f}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}ho.exports=pi});var xo=W((X,Ut)=>{X.formatArgs=fi;X.save=mi;X.load=di;X.useColors=ui;X.storage=hi();X.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();X.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function ui(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function fi(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Ut.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(r++,n==="%c"&&(o=r))}),e.splice(o,0,t)}X.log=console.debug||console.log||(()=>{});function mi(e){try{e?X.storage.setItem("debug",e):X.storage.removeItem("debug")}catch{}}function di(){let e;try{e=X.storage.getItem("debug")||X.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function hi(){try{return localStorage}catch{}}Ut.exports=vr()(X);var{formatters:xi}=Ut.exports;xi.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var bo=W((bu,go)=>{"use strict";go.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",o=t.indexOf(r+e),n=t.indexOf("--");return o!==-1&&(n===-1||o<n)}});var wo=W((yu,vo)=>{"use strict";var gi=be("os"),yo=be("tty"),ee=bo(),{env:F}=process,ke;ee("no-color")||ee("no-colors")||ee("color=false")||ee("color=never")?ke=0:(ee("color")||ee("colors")||ee("color=true")||ee("color=always"))&&(ke=1);"FORCE_COLOR"in F&&(F.FORCE_COLOR==="true"?ke=1:F.FORCE_COLOR==="false"?ke=0:ke=F.FORCE_COLOR.length===0?1:Math.min(parseInt(F.FORCE_COLOR,10),3));function wr(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function _r(e,t){if(ke===0)return 0;if(ee("color=16m")||ee("color=full")||ee("color=truecolor"))return 3;if(ee("color=256"))return 2;if(e&&!t&&ke===void 0)return 0;let r=ke||0;if(F.TERM==="dumb")return r;if(process.platform==="win32"){let o=gi.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in F)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(o=>o in F)||F.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in F)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(F.TEAMCITY_VERSION)?1:0;if(F.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in F){let o=parseInt((F.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(F.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(F.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(F.TERM)||"COLORTERM"in F?1:r}function bi(e){let t=_r(e,e&&e.isTTY);return wr(t)}vo.exports={supportsColor:bi,stdout:wr(_r(!0,yo.isatty(1))),stderr:wr(_r(!0,yo.isatty(2)))}});var Co=W((z,zt)=>{var yi=be("tty"),Ft=be("util");z.init=Ei;z.log=Ci;z.formatArgs=wi;z.save=ki;z.load=Ti;z.useColors=vi;z.destroy=Ft.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");z.colors=[6,2,3,4,5,1];try{let e=wo();e&&(e.stderr||e).level>=2&&(z.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}z.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.toUpperCase()),o=process.env[t];return/^(yes|on|true|enabled)$/i.test(o)?o=!0:/^(no|off|false|disabled)$/i.test(o)?o=!1:o==="null"?o=null:o=Number(o),e[r]=o,e},{});function vi(){return"colors"in z.inspectOpts?!!z.inspectOpts.colors:yi.isatty(process.stderr.fd)}function wi(e){let{namespace:t,useColors:r}=this;if(r){let o=this.color,n="\x1B[3"+(o<8?o:"8;5;"+o),s=` ${n};1m${t} \x1B[0m`;e[0]=s+e[0].split(`
|
|
3
3
|
`).join(`
|
|
4
|
-
`+s),e.push(n+"m+"+
|
|
5
|
-
`)}function
|
|
6
|
-
`).map(t=>t.trim()).join(" ")};
|
|
7
|
-
`);super(i,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=o,this.docsPath=n,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=_r}walk(t){return Eo(this,t)}}});var zt,Ht,Tr=T(()=>{ee();zt=class extends b{constructor({max:t,min:r,signed:o,size:n,value:s}){super(`Number "${s}" is not in safe ${n?`${n*8}-bit ${o?"signed":"unsigned"} `:""}integer range ${t?`(${r} to ${t})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}},Ht=class extends b{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function ue(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var We=T(()=>{});function te(e){return ue(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var ut=T(()=>{We()});function ft(e,{dir:t="left"}={}){let r=typeof e=="string"?e.replace("0x",""):e,o=0;for(let n=0;n<r.length-1&&r[t==="left"?n:r.length-n-1].toString()==="0";n++)o++;return r=t==="left"?r.slice(o):r.slice(0,r.length-o),typeof e=="string"?(r.length===1&&t==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}var So=T(()=>{});var mt,dt,Er=T(()=>{ee();mt=class extends b{constructor({offset:t,position:r,size:o}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${o}).`,{name:"SliceOffsetOutOfBoundsError"})}},dt=class extends b{constructor({size:t,targetSize:r,type:o}){super(`${o.charAt(0).toUpperCase()}${o.slice(1).toLowerCase()} size (${t}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}});function ke(e,{dir:t,size:r=32}={}){return typeof e=="string"?Ei(e,{dir:t,size:r}):Si(e,{dir:t,size:r})}function Ei(e,{dir:t,size:r=32}={}){if(r===null)return e;let o=e.replace("0x","");if(o.length>r*2)throw new dt({size:Math.ceil(o.length/2),targetSize:r,type:"hex"});return`0x${o[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function Si(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new dt({size:e.length,targetSize:r,type:"bytes"});let o=new Uint8Array(r);for(let n=0;n<r;n++){let s=t==="right";o[s?n:r-n-1]=e[s?n:e.length-n-1]}return o}var Sr=T(()=>{Er()});function ie(e,t={}){return typeof e=="number"||typeof e=="bigint"?C(e,t):typeof e=="string"?Bi(e,t):typeof e=="boolean"?Ai(e,t):X(e,t)}function Ai(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(Te(r,{size:t.size}),ke(r,{size:t.size})):r}function X(e,t={}){let r="";for(let n=0;n<e.length;n++)r+=Ii[e[n]];let o=`0x${r}`;return typeof t.size=="number"?(Te(o,{size:t.size}),ke(o,{dir:"right",size:t.size})):o}function C(e,t={}){let{signed:r,size:o}=t,n=BigInt(e),s;o?r?s=(1n<<BigInt(o)*8n-1n)-1n:s=2n**(BigInt(o)*8n)-1n:typeof e=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));let i=typeof s=="bigint"&&r?-s-1n:0;if(s&&n>s||n<i){let l=typeof e=="bigint"?"n":"";throw new zt({max:s?`${s}${l}`:void 0,min:`${i}${l}`,signed:r,size:o,value:`${e}${l}`})}let a=`0x${(r&&n<0?(1n<<BigInt(o*8))+BigInt(n):n).toString(16)}`;return o?ke(a,{size:o}):a}function Bi(e,t={}){let r=Pi.encode(e);return X(r,t)}var Ii,Pi,re=T(()=>{Tr();Sr();Ue();Ii=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Pi=new TextEncoder});function Ot(e,t={}){return typeof e=="number"||typeof e=="bigint"?Ri(e,t):typeof e=="boolean"?$i(e,t):ue(e)?ae(e,t):Ir(e,t)}function $i(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(Te(r,{size:t.size}),ke(r,{size:t.size})):r}function Io(e){if(e>=ge.zero&&e<=ge.nine)return e-ge.zero;if(e>=ge.A&&e<=ge.F)return e-(ge.A-10);if(e>=ge.a&&e<=ge.f)return e-(ge.a-10)}function ae(e,t={}){let r=e;t.size&&(Te(r,{size:t.size}),r=ke(r,{dir:"right",size:t.size}));let o=r.slice(2);o.length%2&&(o=`0${o}`);let n=o.length/2,s=new Uint8Array(n);for(let i=0,a=0;i<n;i++){let l=Io(o.charCodeAt(a++)),u=Io(o.charCodeAt(a++));if(l===void 0||u===void 0)throw new b(`Invalid byte sequence ("${o[a-2]}${o[a-1]}" in "${o}").`);s[i]=l*16+u}return s}function Ri(e,t){let r=C(e,t);return ae(r)}function Ir(e,t={}){let r=Li.encode(e);return typeof t.size=="number"?(Te(r,{size:t.size}),ke(r,{dir:"right",size:t.size})):r}var Li,ge,Ee=T(()=>{ee();We();Sr();Ue();re();Li=new TextEncoder;ge={zero:48,nine:57,A:65,F:70,a:97,f:102}});function Te(e,{size:t}){if(te(e)>t)throw new Ht({givenSize:te(e),maxSize:t})}function Fe(e,t={}){let{signed:r}=t;t.size&&Te(e,{size:t.size});let o=BigInt(e);if(!r)return o;let n=(e.length-2)/2,s=(1n<<BigInt(n)*8n-1n)-1n;return o<=s?o:o-BigInt(`0x${"f".padStart(n*2,"f")}`)-1n}function ze(e,t={}){return Number(Fe(e,t))}var Ue=T(()=>{Tr();ut()});function Xe(e,t){return({exclude:r,format:o})=>({exclude:r,format:(n,s)=>{let i=t(n,s);if(r)for(let a of r)delete i[a];return{...i,...o(n,s)}},type:e})}var jt=T(()=>{});var rf,of,nf,sf,af,cf,lf,pf,uf,ff,mf,df,hf,xf,bf,gf,yf,wf,vf,Cf,_f,kf,Tf,Ef,Sf,If,Af,Pf,Bf,Lf,$f,Rf,Uf,Ff,zf,Hf,Of,jf,Nf,Gf,Df,Mf,qf,Vf,Kf,Wf,Xf,Jf,Zf,Yf,Qf,em,tm,rm,om,nm,sm,im,am,cm,lm,pm,um,fm,mm,dm,hm,xm,bm,gm,ym,wm,vm,Cm,_m,km,Tm,Em,Sm,Im,Am,Pm,Bm,Lm,$m,Rm,Um,Fm,zm,Hm,Om,jm,Nm,Gm,Dm,Nt,$o=T(()=>{rf=2n**(8n-1n)-1n,of=2n**(16n-1n)-1n,nf=2n**(24n-1n)-1n,sf=2n**(32n-1n)-1n,af=2n**(40n-1n)-1n,cf=2n**(48n-1n)-1n,lf=2n**(56n-1n)-1n,pf=2n**(64n-1n)-1n,uf=2n**(72n-1n)-1n,ff=2n**(80n-1n)-1n,mf=2n**(88n-1n)-1n,df=2n**(96n-1n)-1n,hf=2n**(104n-1n)-1n,xf=2n**(112n-1n)-1n,bf=2n**(120n-1n)-1n,gf=2n**(128n-1n)-1n,yf=2n**(136n-1n)-1n,wf=2n**(144n-1n)-1n,vf=2n**(152n-1n)-1n,Cf=2n**(160n-1n)-1n,_f=2n**(168n-1n)-1n,kf=2n**(176n-1n)-1n,Tf=2n**(184n-1n)-1n,Ef=2n**(192n-1n)-1n,Sf=2n**(200n-1n)-1n,If=2n**(208n-1n)-1n,Af=2n**(216n-1n)-1n,Pf=2n**(224n-1n)-1n,Bf=2n**(232n-1n)-1n,Lf=2n**(240n-1n)-1n,$f=2n**(248n-1n)-1n,Rf=2n**(256n-1n)-1n,Uf=-(2n**(8n-1n)),Ff=-(2n**(16n-1n)),zf=-(2n**(24n-1n)),Hf=-(2n**(32n-1n)),Of=-(2n**(40n-1n)),jf=-(2n**(48n-1n)),Nf=-(2n**(56n-1n)),Gf=-(2n**(64n-1n)),Df=-(2n**(72n-1n)),Mf=-(2n**(80n-1n)),qf=-(2n**(88n-1n)),Vf=-(2n**(96n-1n)),Kf=-(2n**(104n-1n)),Wf=-(2n**(112n-1n)),Xf=-(2n**(120n-1n)),Jf=-(2n**(128n-1n)),Zf=-(2n**(136n-1n)),Yf=-(2n**(144n-1n)),Qf=-(2n**(152n-1n)),em=-(2n**(160n-1n)),tm=-(2n**(168n-1n)),rm=-(2n**(176n-1n)),om=-(2n**(184n-1n)),nm=-(2n**(192n-1n)),sm=-(2n**(200n-1n)),im=-(2n**(208n-1n)),am=-(2n**(216n-1n)),cm=-(2n**(224n-1n)),lm=-(2n**(232n-1n)),pm=-(2n**(240n-1n)),um=-(2n**(248n-1n)),fm=-(2n**(256n-1n)),mm=2n**8n-1n,dm=2n**16n-1n,hm=2n**24n-1n,xm=2n**32n-1n,bm=2n**40n-1n,gm=2n**48n-1n,ym=2n**56n-1n,wm=2n**64n-1n,vm=2n**72n-1n,Cm=2n**80n-1n,_m=2n**88n-1n,km=2n**96n-1n,Tm=2n**104n-1n,Em=2n**112n-1n,Sm=2n**120n-1n,Im=2n**128n-1n,Am=2n**136n-1n,Pm=2n**144n-1n,Bm=2n**152n-1n,Lm=2n**160n-1n,$m=2n**168n-1n,Rm=2n**176n-1n,Um=2n**184n-1n,Fm=2n**192n-1n,zm=2n**200n-1n,Hm=2n**208n-1n,Om=2n**216n-1n,jm=2n**224n-1n,Nm=2n**232n-1n,Gm=2n**240n-1n,Dm=2n**248n-1n,Nt=2n**256n-1n});function He(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var Pr=T(()=>{});var xt,Gt,Dt,Ro=T(()=>{ee();xt=class extends b{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},Gt=class extends b{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},Dt=class extends b{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function Mt(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(Oi);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var Oi,Br=T(()=>{Ro();Oi={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new Dt({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Gt({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new xt({offset:e});let t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new xt({offset:e});let t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){let t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){let r=t??this.position;return this.assertPosition(r+e-1),this.bytes.subarray(r,r+e)},inspectUint8(e){let t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){let t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){let t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){let t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,e&255),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();let e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();let r=this.inspectBytes(e);return this.position+=t??e,r},readUint8(){this.assertReadLimit(),this._touch();let e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();let e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();let e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();let e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){let t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;let e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}}});var zo,Ho=T(()=>{zo={ether:-9,wei:9}});function Oo(e,t){let r=e.toString(),o=r.startsWith("-");o&&(r=r.slice(1)),r=r.padStart(t,"0");let[n,s]=[r.slice(0,r.length-t),r.slice(r.length-t)];return s=s.replace(/(0+)$/,""),`${o?"-":""}${n||"0"}${s?`.${s}`:""}`}var jo=T(()=>{});function bt(e,t="wei"){return Oo(e,zo[t])}var No=T(()=>{Ho();jo()});function Gi(e){let t=Object.entries(e).map(([o,n])=>n===void 0||n===!1?null:[o,n]).filter(Boolean),r=t.reduce((o,[n])=>Math.max(o,n.length),0);return t.map(([o,n])=>` ${`${o}:`.padEnd(r+1)} ${n}`).join(`
|
|
8
|
-
`)}var
|
|
9
|
-
`),{cause:t,name:"NonceTooLowError"})}};Object.defineProperty(
|
|
10
|
-
`),{cause:t,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}};Object.defineProperty(
|
|
11
|
-
`),{cause:t,name:"TipAboveFeeCapError"})}};Object.defineProperty(yt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/})});var et,Gr=T(()=>{et=class extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){let r=super.get(t);return super.has(t)&&r!==void 0&&(this.delete(t),super.set(t,r)),r}set(t,r){if(super.set(t,r),this.maxSize&&this.size>this.maxSize){let o=this.keys().next().value;o&&this.delete(o)}return this}}});function ia(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let i=0;i<10;i++)r[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){let a=(i+8)%10,l=(i+2)%10,u=r[l],f=r[l+1],p=ln(u,f,1)^r[a],d=pn(u,f,1)^r[a+1];for(let h=0;h<50;h+=10)e[i+h]^=p,e[i+h+1]^=d}let n=e[2],s=e[3];for(let i=0;i<24;i++){let a=fn[i],l=ln(n,s,a),u=pn(n,s,a),f=un[i];n=e[f],s=e[f+1],e[f]=l,e[f+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)r[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=na[o],e[1]^=sa[o]}Se(r)}var Qi,wt,ea,ta,ra,oa,un,fn,mn,dn,na,sa,ln,pn,vt,aa,hn,xn=T(()=>{Yo();er();Qi=BigInt(0),wt=BigInt(1),ea=BigInt(2),ta=BigInt(7),ra=BigInt(256),oa=BigInt(113),un=[],fn=[],mn=[];for(let e=0,t=wt,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],un.push(2*(5*o+r)),fn.push((e+1)*(e+2)/2%64);let n=Qi;for(let s=0;s<7;s++)t=(t<<wt^(t>>ta)*oa)%ra,t&ea&&(n^=wt<<(wt<<BigInt(s))-wt);mn.push(n)}dn=Ko(mn,!0),na=dn[0],sa=dn[1],ln=(e,t,r)=>r>32?Jo(e,t,r):Wo(e,t,r),pn=(e,t,r)=>r>32?Zo(e,t,r):Xo(e,t,r);vt=class extends Ze{constructor(t,r,o,n=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=r,this.outputLen=o,this.enableXOF=n,this.rounds=s,Lr(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Do(this.state)}clone(){return this._cloneInto()}keccak(){$r(this.state32),ia(this.state32,this.rounds),$r(this.state32),this.posOut=0,this.pos=0}update(t){Ye(this),t=gt(t),Oe(t);let{blockLen:r,state:o}=this,n=t.length;for(let s=0;s<n;){let i=Math.min(r-this.pos,n-s);for(let a=0;a<i;a++)o[this.pos++]^=t[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:r,pos:o,blockLen:n}=this;t[o]^=r,r&128&&o===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){Ye(this,!1),Oe(t),this.finish();let r=this.state,{blockLen:o}=this;for(let n=0,s=t.length;n<s;){this.posOut>=o&&this.keccak();let i=Math.min(o-this.posOut,s-n);t.set(r.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Lr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Zt(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Se(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new vt(r,o,n,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=o,t.outputLen=n,t.enableXOF=i,t.destroyed=this.destroyed,t}},aa=(e,t,r)=>Qt(()=>new vt(t,e,r)),hn=(()=>aa(1,136,256/8))()});function bn(e,t){let r=t||"hex",o=hn(ue(e,{strict:!1})?Ot(e):e);return r==="bytes"?o:ie(o)}var gn=T(()=>{xn();We();Ee();re()});function yn(e,t){if(Dr.has(`${e}.${t}`))return Dr.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),o=bn(Ir(r),"bytes"),n=(t?r.substring(`${t}0x`.length):r).split("");for(let i=0;i<40;i+=2)o[i>>1]>>4>=8&&n[i]&&(n[i]=n[i].toUpperCase()),(o[i>>1]&15)>=8&&n[i+1]&&(n[i+1]=n[i+1].toUpperCase());let s=`0x${n.join("")}`;return Dr.set(`${e}.${t}`,s),s}var Dr,wn=T(()=>{Ee();gn();Gr();Dr=new et(8192)});function fe(e,t){let{strict:r=!0}=t??{},o=`${e}.${r}`;if(Mr.has(o))return Mr.get(o);let n=(()=>ca.test(e)?e.toLowerCase()===e?!0:r?yn(e)===e:!0:!1)();return Mr.set(o,n),n}var ca,Mr,lr=T(()=>{Gr();wn();ca=/^0x[a-fA-F0-9]{40}$/,Mr=new et(8192)});function vn(e,t,r,{strict:o}={}){return ue(e,{strict:!1})?pa(e,t,r,{strict:o}):la(e,t,r,{strict:o})}function Cn(e,t){if(typeof t=="number"&&t>0&&t>te(e)-1)throw new mt({offset:t,position:"start",size:te(e)})}function _n(e,t,r){if(typeof t=="number"&&typeof r=="number"&&te(e)!==r-t)throw new mt({offset:r,position:"end",size:te(e)})}function la(e,t,r,{strict:o}={}){Cn(e,t);let n=e.slice(t,r);return o&&_n(n,t,r),n}function pa(e,t,r,{strict:o}={}){Cn(e,t);let n=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return o&&_n(n,t,r),n}var kn=T(()=>{Er();We();ut()});var Wr=K(Tt=>{"use strict";var va=Tt&&Tt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Tt,"__esModule",{value:!0});Tt.encryptEnvVars=ka;var Vr=be("@noble/curves/ed25519"),Kr=va(be("crypto"));function Ca(e){var t,r;return e=e.startsWith("0x")?e.slice(2):e,new Uint8Array((r=(t=e.match(/.{1,2}/g))===null||t===void 0?void 0:t.map(o=>parseInt(o,16)))!==null&&r!==void 0?r:[])}function _a(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function ka(e,t){let r=JSON.stringify({env:e}),o=Vr.x25519.utils.randomPrivateKey(),n=Vr.x25519.getPublicKey(o),s=Ca(t),i=Vr.x25519.getSharedSecret(o,s),a=await Kr.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=Kr.default.getRandomValues(new Uint8Array(12)),u=await Kr.default.subtle.encrypt({name:"AES-GCM",iv:l},a,new TextEncoder().encode(r)),f=new Uint8Array(n.length+l.length+u.byteLength);return f.set(n),f.set(l,n.length),f.set(new Uint8Array(u),n.length+l.length),_a(f)}});var Rn=K(Et=>{"use strict";var Ta=Et&&Et.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Et,"__esModule",{value:!0});Et.getComposeHash=Aa;var Ea=Ta(be("crypto"));function Xr(e){return e==null?e:Array.isArray(e)?e.map(Xr):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=Xr(o),t},{}):e}function Sa(e){let t={...e};return t.runner==="bash"&&"docker_compose_file"in t?delete t.docker_compose_file:t.runner==="docker-compose"&&"bash_script"in t&&delete t.bash_script,"pre_launch_script"in t&&!t.pre_launch_script&&delete t.pre_launch_script,t}function Ia(e){let t=Xr(e);return JSON.stringify(t,(r,o)=>typeof o=="number"&&(isNaN(o)||!isFinite(o))?null:o)}function Aa(e,t=!1){t&&(e=Sa(e));let r=Ia(e);return Ea.default.createHash("sha256").update(r,"utf8").digest("hex")}});var rs=K(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.toBig=y.shrSL=y.shrSH=y.rotrSL=y.rotrSH=y.rotrBL=y.rotrBH=y.rotr32L=y.rotr32H=y.rotlSL=y.rotlSH=y.rotlBL=y.rotlBH=y.add5L=y.add5H=y.add4L=y.add4H=y.add3L=y.add3H=void 0;y.add=Xn;y.fromBig=Zr;y.split=Un;var mr=BigInt(2**32-1),Jr=BigInt(32);function Zr(e,t=!1){return t?{h:Number(e&mr),l:Number(e>>Jr&mr)}:{h:Number(e>>Jr&mr)|0,l:Number(e&mr)|0}}function Un(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=Zr(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var Fn=(e,t)=>BigInt(e>>>0)<<Jr|BigInt(t>>>0);y.toBig=Fn;var zn=(e,t,r)=>e>>>r;y.shrSH=zn;var Hn=(e,t,r)=>e<<32-r|t>>>r;y.shrSL=Hn;var On=(e,t,r)=>e>>>r|t<<32-r;y.rotrSH=On;var jn=(e,t,r)=>e<<32-r|t>>>r;y.rotrSL=jn;var Nn=(e,t,r)=>e<<64-r|t>>>r-32;y.rotrBH=Nn;var Gn=(e,t,r)=>e>>>r-32|t<<64-r;y.rotrBL=Gn;var Dn=(e,t)=>t;y.rotr32H=Dn;var Mn=(e,t)=>e;y.rotr32L=Mn;var qn=(e,t,r)=>e<<r|t>>>32-r;y.rotlSH=qn;var Vn=(e,t,r)=>t<<r|e>>>32-r;y.rotlSL=Vn;var Kn=(e,t,r)=>t<<r-32|e>>>64-r;y.rotlBH=Kn;var Wn=(e,t,r)=>e<<r-32|t>>>64-r;y.rotlBL=Wn;function Xn(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/2**32|0)|0,l:n|0}}var Jn=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);y.add3L=Jn;var Zn=(e,t,r,o)=>t+r+o+(e/2**32|0)|0;y.add3H=Zn;var Yn=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0);y.add4L=Yn;var Qn=(e,t,r,o,n)=>t+r+o+n+(e/2**32|0)|0;y.add4H=Qn;var es=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0);y.add5L=es;var ts=(e,t,r,o,n,s)=>t+r+o+n+s+(e/2**32|0)|0;y.add5H=ts;var Pa={fromBig:Zr,split:Un,toBig:Fn,shrSH:zn,shrSL:Hn,rotrSH:On,rotrSL:jn,rotrBH:Nn,rotrBL:Gn,rotr32H:Dn,rotr32L:Mn,rotlSH:qn,rotlSL:Vn,rotlBH:Kn,rotlBL:Wn,add:Xn,add3L:Jn,add3H:Zn,add4L:Yn,add4H:Qn,add5H:ts,add5L:es};y.default=Pa});var os=K(dr=>{"use strict";Object.defineProperty(dr,"__esModule",{value:!0});dr.crypto=void 0;var Ae=be("node:crypto");dr.crypto=Ae&&typeof Ae=="object"&&"webcrypto"in Ae?Ae.webcrypto:Ae&&typeof Ae=="object"&&"randomBytes"in Ae?Ae:void 0});var us=K(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.wrapXOFConstructorWithOpts=x.wrapConstructorWithOpts=x.wrapConstructor=x.Hash=x.nextTick=x.swap32IfBE=x.byteSwapIfBE=x.swap8IfBE=x.isLE=void 0;x.isBytes=ss;x.anumber=Yr;x.abytes=rt;x.ahash=Ba;x.aexists=La;x.aoutput=$a;x.u8=Ra;x.u32=Ua;x.clean=Fa;x.createView=za;x.rotr=Ha;x.rotl=Oa;x.byteSwap=eo;x.byteSwap32=is;x.bytesToHex=Na;x.hexToBytes=Ga;x.asyncLoop=Ma;x.utf8ToBytes=to;x.bytesToUtf8=qa;x.toBytes=hr;x.kdfInputToBytes=Va;x.concatBytes=Ka;x.checkOpts=Wa;x.createHasher=cs;x.createOptHasher=ls;x.createXOFer=ps;x.randomBytes=Xa;var tt=os();function ss(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Yr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function rt(e,...t){if(!ss(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ba(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Yr(e.outputLen),Yr(e.blockLen)}function La(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function $a(e,t){rt(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ra(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Ua(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Fa(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function za(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ha(e,t){return e<<32-t|e>>>t}function Oa(e,t){return e<<t|e>>>32-t>>>0}x.isLE=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function eo(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}x.swap8IfBE=x.isLE?e=>e:e=>eo(e);x.byteSwapIfBE=x.swap8IfBE;function is(e){for(let t=0;t<e.length;t++)e[t]=eo(e[t]);return e}x.swap32IfBE=x.isLE?e=>e:is;var as=(()=>typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function")(),ja=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Na(e){if(rt(e),as)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=ja[e[r]];return t}var ve={_0:48,_9:57,A:65,F:70,a:97,f:102};function ns(e){if(e>=ve._0&&e<=ve._9)return e-ve._0;if(e>=ve.A&&e<=ve.F)return e-(ve.A-10);if(e>=ve.a&&e<=ve.f)return e-(ve.a-10)}function Ga(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(as)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){let i=ns(e.charCodeAt(s)),a=ns(e.charCodeAt(s+1));if(i===void 0||a===void 0){let l=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+s)}o[n]=i*16+a}return o}var Da=async()=>{};x.nextTick=Da;async function Ma(e,t,r){let o=Date.now();for(let n=0;n<e;n++){r(n);let s=Date.now()-o;s>=0&&s<t||(await(0,x.nextTick)(),o+=s)}}function to(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function qa(e){return new TextDecoder().decode(e)}function hr(e){return typeof e=="string"&&(e=to(e)),rt(e),e}function Va(e){return typeof e=="string"&&(e=to(e)),rt(e),e}function Ka(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];rt(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let s=e[o];r.set(s,n),n+=s.length}return r}function Wa(e,t){if(t!==void 0&&{}.toString.call(t)!=="[object Object]")throw new Error("options should be object or undefined");return Object.assign(e,t)}var Qr=class{};x.Hash=Qr;function cs(e){let t=o=>e().update(hr(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function ls(e){let t=(o,n)=>e(n).update(hr(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}function ps(e){let t=(o,n)=>e(n).update(hr(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}x.wrapConstructor=cs;x.wrapConstructorWithOpts=ls;x.wrapXOFConstructorWithOpts=ps;function Xa(e=32){if(tt.crypto&&typeof tt.crypto.getRandomValues=="function")return tt.crypto.getRandomValues(new Uint8Array(e));if(tt.crypto&&typeof tt.crypto.randomBytes=="function")return Uint8Array.from(tt.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var ws=K(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.shake256=A.shake128=A.keccak_512=A.keccak_384=A.keccak_256=A.keccak_224=A.sha3_512=A.sha3_384=A.sha3_256=A.sha3_224=A.Keccak=void 0;A.keccakP=gs;var It=rs(),N=us(),Ja=BigInt(0),St=BigInt(1),Za=BigInt(2),Ya=BigInt(7),Qa=BigInt(256),ec=BigInt(113),ds=[],hs=[],xs=[];for(let e=0,t=St,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],ds.push(2*(5*o+r)),hs.push((e+1)*(e+2)/2%64);let n=Ja;for(let s=0;s<7;s++)t=(t<<St^(t>>Ya)*ec)%Qa,t&Za&&(n^=St<<(St<<BigInt(s))-St);xs.push(n)}var bs=(0,It.split)(xs,!0),tc=bs[0],rc=bs[1],fs=(e,t,r)=>r>32?(0,It.rotlBH)(e,t,r):(0,It.rotlSH)(e,t,r),ms=(e,t,r)=>r>32?(0,It.rotlBL)(e,t,r):(0,It.rotlSL)(e,t,r);function gs(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let i=0;i<10;i++)r[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){let a=(i+8)%10,l=(i+2)%10,u=r[l],f=r[l+1],p=fs(u,f,1)^r[a],d=ms(u,f,1)^r[a+1];for(let h=0;h<50;h+=10)e[i+h]^=p,e[i+h+1]^=d}let n=e[2],s=e[3];for(let i=0;i<24;i++){let a=hs[i],l=fs(n,s,a),u=ms(n,s,a),f=ds[i];n=e[f],s=e[f+1],e[f]=l,e[f+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)r[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=tc[o],e[1]^=rc[o]}(0,N.clean)(r)}var Ge=class extends N.Hash{constructor(t,r,o,n=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=r,this.outputLen=o,this.enableXOF=n,this.rounds=s,(0,N.anumber)(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,N.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,N.swap32IfBE)(this.state32),gs(this.state32,this.rounds),(0,N.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(t){(0,N.aexists)(this),t=(0,N.toBytes)(t),(0,N.abytes)(t);let{blockLen:r,state:o}=this,n=t.length;for(let s=0;s<n;){let i=Math.min(r-this.pos,n-s);for(let a=0;a<i;a++)o[this.pos++]^=t[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:r,pos:o,blockLen:n}=this;t[o]^=r,r&128&&o===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){(0,N.aexists)(this,!1),(0,N.abytes)(t),this.finish();let r=this.state,{blockLen:o}=this;for(let n=0,s=t.length;n<s;){this.posOut>=o&&this.keccak();let i=Math.min(o-this.posOut,s-n);t.set(r.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return(0,N.anumber)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,N.aoutput)(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,(0,N.clean)(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new Ge(r,o,n,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=o,t.outputLen=n,t.enableXOF=i,t.destroyed=this.destroyed,t}};A.Keccak=Ge;var Pe=(e,t,r)=>(0,N.createHasher)(()=>new Ge(t,e,r));A.sha3_224=(()=>Pe(6,144,224/8))();A.sha3_256=(()=>Pe(6,136,256/8))();A.sha3_384=(()=>Pe(6,104,384/8))();A.sha3_512=(()=>Pe(6,72,512/8))();A.keccak_224=(()=>Pe(1,144,224/8))();A.keccak_256=(()=>Pe(1,136,256/8))();A.keccak_384=(()=>Pe(1,104,384/8))();A.keccak_512=(()=>Pe(1,72,512/8))();var ys=(e,t,r)=>(0,N.createXOFer)((o={})=>new Ge(t,e,o.dkLen===void 0?r:o.dkLen,!0));A.shake128=(()=>ys(31,168,128/8))();A.shake256=(()=>ys(31,136,256/8))()});var vs=K(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.verifyEnvEncryptPublicKey=sc;var oc=ws(),nc=be("@noble/curves/secp256k1");function sc(e,t,r){if(t.length!==65)return null;let o=Buffer.from("dstack-env-encrypt-pubkey","utf8"),n=r;r.startsWith("0x")&&(n=r.slice(2));let s=Buffer.from(n,"hex"),i=Buffer.from(":","utf8"),a=Buffer.concat([o,i,s,Buffer.from(e)]),l=(0,oc.keccak_256)(a);try{let u=t.slice(0,32),f=t.slice(32,64),p=t[64],d=new Uint8Array(64);d.set(u,0),d.set(f,32);let h=nc.secp256k1.Signature.fromCompact(d).addRecoveryBit(p).recoverPublicKey(l);return"0x"+Buffer.from(h.toRawBytes(!0)).toString("hex")}catch(u){return console.error("signature verification failed:",u),null}}});var Es=pt(_o(),1);import{ofetch as ic}from"ofetch";function ko(e){return{all:e=e||new Map,on:function(t,r){var o=e.get(t);o?o.push(r):e.set(t,[r])},off:function(t,r){var o=e.get(t);o&&(r?o.splice(o.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var o=e.get(t);o&&o.slice().map(function(n){n(r)}),(o=e.get("*"))&&o.slice().map(function(n){n(t,r)})}}}import{z}from"zod";import{z as Be}from"zod";import{z as v}from"zod";import{z as Le}from"zod";function Re(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}jt();Ue();jt();var Ar={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function ht(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?ze(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?ze(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Ar[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(r.authorizationList=Ui(e.authorizationList)),r.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof r.v=="bigint"){if(r.v===0n||r.v===27n)return 0;if(r.v===1n||r.v===28n)return 1;if(r.v>=35n)return r.v%2n===0n?1:0}})(),r.type==="legacy"&&(delete r.accessList,delete r.maxFeePerBlobGas,delete r.maxFeePerGas,delete r.maxPriorityFeePerGas,delete r.yParity),r.type==="eip2930"&&(delete r.maxFeePerBlobGas,delete r.maxFeePerGas,delete r.maxPriorityFeePerGas),r.type==="eip1559"&&delete r.maxFeePerBlobGas,r}var Ao=Xe("transaction",ht);function Ui(e){return e.map(t=>({address:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function Fi(e,t){let r=(e.transactions??[]).map(o=>typeof o=="string"?o:ht(o));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:r,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}var Po=Xe("block",Fi);function Bo(e,{args:t,eventName:r}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...r?{args:t,eventName:r}:{}}}Ue();jt();var zi={"0x0":"reverted","0x1":"success"};function Hi(e,t){let r={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(o=>Bo(o)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?ze(e.transactionIndex):null,status:e.status?zi[e.status]:null,type:e.type?Ar[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var Lo=Xe("transactionReceipt",Hi);ee();Br();Ee();re();function ye(e,t="hex"){let r=Uo(e),o=Mt(new Uint8Array(r.length));return r.encode(o),t==="hex"?X(o.bytes):o.bytes}function Uo(e){return Array.isArray(e)?ji(e.map(t=>Uo(t))):Ni(e)}function ji(e){let t=e.reduce((n,s)=>n+s.length,0),r=Fo(t);return{length:(()=>t<=55?1+t:1+r+t)(),encode(n){t<=55?n.pushByte(192+t):(n.pushByte(192+55+r),r===1?n.pushUint8(t):r===2?n.pushUint16(t):r===3?n.pushUint24(t):n.pushUint32(t));for(let{encode:s}of e)s(n)}}}function Ni(e){let t=typeof e=="string"?ae(e):e,r=Fo(t.length);return{length:(()=>t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length)(),encode(n){t.length===1&&t[0]<128?n.pushBytes(t):t.length<=55?(n.pushByte(128+t.length),n.pushBytes(t)):(n.pushByte(128+55+r),r===1?n.pushUint8(t.length):r===2?n.pushUint16(t.length):r===3?n.pushUint24(t.length):n.pushUint32(t.length),n.pushBytes(t))}}}function Fo(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new b("Length is too large.")}Wt();re();function Go(e){if(!e||e.length===0)return[];let t=[];for(let r of e){let{chainId:o,nonce:n,...s}=r,i=r.address;t.push([o?ie(o):"0x",i,n?ie(n):"0x",...Je({},s)])}return t}Ee();re();function Xt(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),o=typeof e.blobs[0]=="string"?e.blobs.map(s=>ae(s)):e.blobs,n=[];for(let s of o)n.push(Uint8Array.from(t.blobToKzgCommitment(s)));return r==="bytes"?n:n.map(s=>X(s))}Ee();re();function Jt(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),o=typeof e.blobs[0]=="string"?e.blobs.map(i=>ae(i)):e.blobs,n=typeof e.commitments[0]=="string"?e.commitments.map(i=>ae(i)):e.commitments,s=[];for(let i=0;i<o.length;i++){let a=o[i],l=n[i];s.push(Uint8Array.from(t.computeBlobKzgProof(a,l)))}return r==="bytes"?s:s.map(i=>X(i))}re();er();function Wi(e,t,r,o){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,o);let n=BigInt(32),s=BigInt(4294967295),i=Number(r>>n&s),a=Number(r&s),l=o?4:0,u=o?0:4;e.setUint32(t+l,i,o),e.setUint32(t+u,a,o)}function Mo(e,t,r){return e&t^~e&r}function qo(e,t,r){return e&t^e&r^t&r}var tr=class extends Ze{constructor(t,r,o,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(t),this.view=Yt(this.buffer)}update(t){Ye(this),t=gt(t),Oe(t);let{view:r,buffer:o,blockLen:n}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(n-this.pos,s-i);if(a===n){let l=Yt(t);for(;n<=s-i;i+=n)this.process(l,i);continue}o.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ye(this),Zt(t,this),this.finished=!0;let{buffer:r,view:o,blockLen:n,isLE:s}=this,{pos:i}=this;r[i++]=128,Se(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let p=i;p<n;p++)r[p]=0;Wi(o,n-8,BigInt(this.length*8),s),this.process(o,0);let a=Yt(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=l/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<u;p++)a.setUint32(4*p,f[p],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let o=t.slice(0,r);return this.destroy(),o}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:o,length:n,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=n,t.pos=a,n%r&&t.buffer.set(o),t}clone(){return this._cloneInto()}},we=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);er();var Ji=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ie=new Uint32Array(64),or=class extends tr{constructor(t=32){super(64,t,8,!1),this.A=we[0]|0,this.B=we[1]|0,this.C=we[2]|0,this.D=we[3]|0,this.E=we[4]|0,this.F=we[5]|0,this.G=we[6]|0,this.H=we[7]|0}get(){let{A:t,B:r,C:o,D:n,E:s,F:i,G:a,H:l}=this;return[t,r,o,n,s,i,a,l]}set(t,r,o,n,s,i,a,l){this.A=t|0,this.B=r|0,this.C=o|0,this.D=n|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=l|0}process(t,r){for(let p=0;p<16;p++,r+=4)Ie[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let d=Ie[p-15],h=Ie[p-2],I=ce(d,7)^ce(d,18)^d>>>3,k=ce(h,17)^ce(h,19)^h>>>10;Ie[p]=k+Ie[p-7]+I+Ie[p-16]|0}let{A:o,B:n,C:s,D:i,E:a,F:l,G:u,H:f}=this;for(let p=0;p<64;p++){let d=ce(a,6)^ce(a,11)^ce(a,25),h=f+d+Mo(a,l,u)+Ji[p]+Ie[p]|0,k=(ce(o,2)^ce(o,13)^ce(o,22))+qo(o,n,s)|0;f=u,u=l,l=a,a=i+h|0,i=s,s=n,n=o,o=h+k|0}o=o+this.A|0,n=n+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,l=l+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(o,n,s,i,a,l,u,f)}roundClean(){Se(Ie)}destroy(){this.set(0,0,0,0,0,0,0,0),Se(this.buffer)}};var Qo=Qt(()=>new or);var en=Qo;We();Ee();re();function tn(e,t){let r=t||"hex",o=en(ue(e,{strict:!1})?Ot(e):e);return r==="bytes"?o:ie(o)}function rn(e){let{commitment:t,version:r=1}=e,o=e.to??(typeof t=="string"?"hex":"bytes"),n=tn(t,"bytes");return n.set([r],0),o==="bytes"?n:X(n)}function on(e){let{commitments:t,version:r}=e,o=e.to??(typeof t[0]=="string"?"hex":"bytes"),n=[];for(let s of t)n.push(rn({commitment:s,to:o,version:r}));return n}ee();var nr=class extends b{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},Qe=class extends b{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},sr=class extends b{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},ir=class extends b{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};Br();ut();Ee();re();function nn(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?ae(e.data):e.data,o=te(r);if(!o)throw new Qe;if(o>761855)throw new nr({maxSize:761855,size:o});let n=[],s=!0,i=0;for(;s;){let a=Mt(new Uint8Array(131072)),l=0;for(;l<4096;){let u=r.slice(i,i+(32-1));if(a.pushByte(0),a.pushBytes(u),u.length<31){a.pushByte(128),s=!1;break}l++,i+=31}n.push(a)}return t==="bytes"?n.map(a=>a.bytes):n.map(a=>X(a.bytes))}function sn(e){let{data:t,kzg:r,to:o}=e,n=e.blobs??nn({data:t,to:o}),s=e.commitments??Xt({blobs:n,kzg:r,to:o}),i=e.proofs??Jt({blobs:n,commitments:s,kzg:r,to:o}),a=[];for(let l=0;l<n.length;l++)a.push({blob:n[l],commitment:s[l],proof:i[l]});return a}Pr();So();re();$o();ar();ee();an();cn();lr();ut();kn();Ue();function Tn(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:o}=r,n=r.address;if(!fe(n))throw new oe({address:n});if(o<0)throw new je({chainId:o})}pr(e)}function En(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new Qe;for(let r of t){let o=te(r),n=ze(vn(r,0,1));if(o!==32)throw new sr({hash:r,size:o});if(n!==1)throw new ir({hash:r,version:n})}}pr(e)}function pr(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:o,to:n}=e;if(t<=0)throw new je({chainId:t});if(n&&!fe(n))throw new oe({address:n});if(o&&o>Nt)throw new Ne({maxFeePerGas:o});if(r&&o&&r>o)throw new yt({maxFeePerGas:o,maxPriorityFeePerGas:r})}function Sn(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(t<=0)throw new je({chainId:t});if(s&&!fe(s))throw new oe({address:s});if(r||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(o&&o>Nt)throw new Ne({maxFeePerGas:o})}function In(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(s&&!fe(s))throw new oe({address:s});if(typeof t<"u"&&t<=0)throw new je({chainId:t});if(r||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(o&&o>Nt)throw new Ne({maxFeePerGas:o})}Wt();function An(e){if(e.type)return e.type;if(typeof e.authorizationList<"u")return"eip7702";if(typeof e.blobs<"u"||typeof e.blobVersionedHashes<"u"||typeof e.maxFeePerBlobGas<"u"||typeof e.sidecars<"u")return"eip4844";if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")return"eip1559";if(typeof e.gasPrice<"u")return typeof e.accessList<"u"?"eip2930":"legacy";throw new Vt({transaction:e})}ar();Wt();lr();function Ct(e){if(!e||e.length===0)return[];let t=[];for(let r=0;r<e.length;r++){let{address:o,storageKeys:n}=e[r];for(let s=0;s<n.length;s++)if(n[s].length-2!==64)throw new Kt({storageKey:n[s]});if(!fe(o,{strict:!1}))throw new oe({address:o});t.push([o,n])}return t}function Pn(e,t){let r=An(e);return r==="eip1559"?ma(e,t):r==="eip2930"?da(e,t):r==="eip4844"?fa(e,t):r==="eip7702"?ua(e,t):ha(e,t)}function ua(e,t){let{authorizationList:r,chainId:o,gas:n,nonce:s,to:i,value:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;Tn(e);let d=Ct(f),h=Go(r);return He(["0x04",ye([C(o),s?C(s):"0x",u?C(u):"0x",l?C(l):"0x",n?C(n):"0x",i??"0x",a?C(a):"0x",p??"0x",d,h,...Je(e,t)])])}function fa(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;En(e);let d=e.blobVersionedHashes,h=e.sidecars;if(e.blobs&&(typeof d>"u"||typeof h>"u")){let H=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(Y=>X(Y)),J=e.kzg,se=Xt({blobs:H,kzg:J});if(typeof d>"u"&&(d=on({commitments:se})),typeof h>"u"){let Y=Jt({blobs:H,commitments:se,kzg:J});h=sn({blobs:H,commitments:se,proofs:Y})}}let I=Ct(f),k=[C(r),n?C(n):"0x",u?C(u):"0x",l?C(l):"0x",o?C(o):"0x",s??"0x",i?C(i):"0x",p??"0x",I,a?C(a):"0x",d??[],...Je(e,t)],P=[],q=[],V=[];if(h)for(let H=0;H<h.length;H++){let{blob:J,commitment:se,proof:Y}=h[H];P.push(J),q.push(se),V.push(Y)}return He(["0x03",h?ye([k,P,q,V]):ye(k)])}function ma(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:u,data:f}=e;pr(e);let p=Ct(u),d=[C(r),n?C(n):"0x",l?C(l):"0x",a?C(a):"0x",o?C(o):"0x",s??"0x",i?C(i):"0x",f??"0x",p,...Je(e,t)];return He(["0x02",ye(d)])}function da(e,t){let{chainId:r,gas:o,data:n,nonce:s,to:i,value:a,accessList:l,gasPrice:u}=e;Sn(e);let f=Ct(l),p=[C(r),s?C(s):"0x",u?C(u):"0x",o?C(o):"0x",i??"0x",a?C(a):"0x",n??"0x",f,...Je(e,t)];return He(["0x01",ye(p)])}function ha(e,t){let{chainId:r=0,gas:o,data:n,nonce:s,to:i,value:a,gasPrice:l}=e;In(e);let u=[s?C(s):"0x",l?C(l):"0x",o?C(o):"0x",i??"0x",a?C(a):"0x",n??"0x"];if(t){let f=(()=>{if(t.v>=35n)return(t.v-35n)/2n>0?t.v:27n+(t.v===35n?0n:1n);if(r>0)return BigInt(r*2)+BigInt(35n+t.v-27n);let h=27n+(t.v===27n?0n:1n);if(t.v!==h)throw new qt({v:t.v});return h})(),p=ft(t.r),d=ft(t.s);u=[...u,C(f),p==="0x00"?"0x":p,d==="0x00"?"0x":d]}else r>0&&(u=[...u,C(r),"0x","0x"]);return ye(u)}function Je(e,t){let r=t??e,{v:o,yParity:n}=r;if(typeof r.r>"u")return[];if(typeof r.s>"u")return[];if(typeof o>"u"&&typeof n>"u")return[];let s=ft(r.r),i=ft(r.s);return[(()=>typeof n=="number"?n?C(1):"0x":o===0n?"0x":o===1n?C(1):o===27n?"0x":C(1))(),s==="0x00"?"0x":s,i==="0x00"?"0x":i]}var Bn={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};Ue();var Ln={block:Po({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let o=ht(r);return o.typeHex==="0x7e"&&(o.isSystemTx=r.isSystemTx,o.mint=r.mint?Fe(r.mint):void 0,o.sourceHash=r.sourceHash,o.type="deposit"),o}),stateRoot:e.stateRoot}}}),transaction:Ao({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Fe(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Lo({format(e){return{l1GasPrice:e.l1GasPrice?Fe(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Fe(e.l1GasUsed):null,l1Fee:e.l1Fee?Fe(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};ar();lr();Pr();re();function xa(e,t){return ga(e)?ba(e):Pn(e,t)}var $n={transaction:xa};function ba(e){ya(e);let{sourceHash:t,data:r,from:o,gas:n,isSystemTx:s,mint:i,to:a,value:l}=e,u=[t,o,a??"0x",i?ie(i):"0x",l?ie(l):"0x",n?ie(n):"0x",s?"0x1":"0x",r??"0x"];return He(["0x7e",ye(u)])}function ga(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function ya(e){let{from:t,to:r}=e;if(t&&!fe(t))throw new oe({address:t});if(r&&!fe(r))throw new oe({address:r})}var qr={blockTime:2e3,contracts:Bn,formatters:Ln,serializers:$n};var ur=Re({id:31337,name:"Anvil",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["http://127.0.0.1:8545"],webSocket:["ws://127.0.0.1:8545"]}}});var _t=1,kt=Re({...qr,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...qr.contracts,disputeGameFactory:{[_t]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[_t]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[_t]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[_t]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:_t}),wa=Re({...kt,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var fr=Re({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:12e3,rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:23085558},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}});import{z as $}from"zod";import{z as Z}from"zod";import{z as m}from"zod";import{z as At}from"zod";import{z as ne}from"zod";import{z as w}from"zod";import{z as _}from"zod";import{z as D}from"zod";import pl from"crypto";import{z as he}from"zod";import{z as le}from"zod";import{z as _s}from"zod";import{z as xe}from"zod";import{z as it}from"zod";import{z as De}from"zod";import{z as Wl}from"zod";import{z as Yl}from"zod";import{z as E}from"zod";import{z as de}from"zod";import{z as mp}from"zod";import{z as L}from"zod";import{z as g}from"zod";import{z as st}from"zod";import{z as ks}from"zod";import{z as G}from"zod";import{z as Os}from"zod";import{z as me}from"zod";import{z as R}from"zod";var kx=pt(Wr(),1);import{z as B}from"zod";var Jp=pt(Wr(),1),Zp=pt(Rn(),1),Yp=pt(vs(),1);import{z as nt}from"zod";var ac=z.object({detail:z.union([z.string(),z.array(z.object({msg:z.string(),type:z.string().optional(),ctx:z.record(z.unknown()).optional(),loc:z.array(z.union([z.string(),z.number()])).optional(),input:z.unknown().optional()}).passthrough()),z.record(z.unknown())]).optional(),type:z.string().optional(),code:z.string().optional()}),Me=class extends Error{constructor(e,t){super(e),this.name=this.constructor.name,this.status=t.status,this.statusText=t.statusText,this.detail=t.detail,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},oo=class xr extends Me{constructor(t,r){super(t,{status:r?.status??0,statusText:r?.statusText??"Unknown Error",detail:r?.detail||t}),this.name="RequestError",this.isRequestError=!0,this.data=r?.data,this.request=r?.request,this.response=r?.response,this.code=r?.code,this.type=r?.type}static fromFetchError(t){let r=ac.safeParse(t.data);return r.success?new xr(t.message,{status:t.status??void 0,statusText:t.statusText??void 0,data:t.data,request:t.request??void 0,response:t.response??void 0,detail:r.data.detail,code:r.data.code??void 0,type:r.data.type??void 0}):new xr(t.message,{status:t.status??void 0,statusText:t.statusText??void 0,data:t.data,request:t.request??void 0,response:t.response??void 0,detail:t.data?.detail||"Unknown API error",code:t.status?.toString()??void 0})}static fromError(t,r){return new xr(t.message,{request:r??void 0,detail:t.message})}},cc=class extends Me{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},lc=class extends Me{constructor(){super(...arguments),this.isAuthError=!0}},Ss=class extends Me{constructor(){super(...arguments),this.isBusinessError=!0}},pc=class extends Me{constructor(){super(...arguments),this.isServerError=!0}},uc=class extends Me{constructor(){super(...arguments),this.isUnknownError=!0}};function fc(e){if(!e||!Array.isArray(e))return"unknown";let t=e.filter(r=>typeof r=="string"?!["body","query","path","header"].includes(r):!0);return t.length>0?t.join("."):"unknown"}function Is(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((n,s)=>{let i=fc(n.loc),a=i;return i==="unknown"&&n.type&&(a=n.type==="missing"?"required field":n.type),{field:a,message:n.msg,type:n.type,context:n.ctx}}),r=t.length,o=r===1?`Validation failed: ${t[0].message}`:`Validation failed (${r} issue${r>1?"s":""})`;return{errors:t,message:o}}function mc(e){return e===422?"validation":e===401||e===403?"auth":e>=400&&e<500?"business":e>=500?"server":"unknown"}function dc(e,t,r){if(e===422&&Array.isArray(t)){let{message:o}=Is(t);return o}if(typeof t=="string")return t;if(t&&typeof t=="object"&&"message"in t){let o=t.message;if(typeof o=="string")return o}return r}function hc(e){let t=e.status??0,r=e.statusText??"Unknown Error",o=e.detail,n=bc(o);if(n)return new xc(n.message,{status:t,statusText:r,detail:o,errorCode:n.error_code,structuredDetails:n.details,suggestions:n.suggestions,links:n.links});let s=mc(t),i=dc(t,o,e.message),a={status:t,statusText:r,detail:o};if(s==="validation"&&Array.isArray(o)){let{errors:l}=Is(o);return new cc(i,{...a,validationErrors:l})}return s==="auth"?new lc(i,a):s==="business"?new Ss(i,a):s==="server"?new pc(i,a):new uc(i,a)}var xc=class extends Ss{constructor(e,t){super(e,t),this.isResourceError=!0,this.errorCode=t.errorCode,this.structuredDetails=t.structuredDetails,this.suggestions=t.suggestions,this.links=t.links}};function bc(e){if(!e||typeof e!="object")return null;let t=e;return t.error_code&&typeof t.error_code=="string"&&t.message&&typeof t.message=="string"?{error_code:t.error_code,message:t.message,details:t.details,suggestions:t.suggestions,links:t.links}:null}var no=["2025-05-31","2025-10-28"],ot=(0,Es.default)("phala::api-client");function gc(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
|
|
12
|
-
`)}function
|
|
4
|
+
`+s),e.push(n+"m+"+zt.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=_i()+t+" "+e[0]}function _i(){return z.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Ci(...e){return process.stderr.write(Ft.formatWithOptions(z.inspectOpts,...e)+`
|
|
5
|
+
`)}function ki(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function Ti(){return process.env.DEBUG}function Ei(e){e.inspectOpts={};let t=Object.keys(z.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=z.inspectOpts[t[r]]}zt.exports=vr()(z);var{formatters:_o}=zt.exports;_o.o=function(e){return this.inspectOpts.colors=this.useColors,Ft.inspect(e,this.inspectOpts).split(`
|
|
6
|
+
`).map(t=>t.trim()).join(" ")};_o.O=function(e){return this.inspectOpts.colors=this.useColors,Ft.inspect(e,this.inspectOpts)}});var ko=W((vu,Cr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Cr.exports=xo():Cr.exports=Co()});var kr,Eo=T(()=>{kr="2.38.6"});function So(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?So(e.cause,t):t?null:e}var Tr,g,te=T(()=>{Eo();Tr={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${kr}`},g=class extends Error{constructor(t,r={}){let o=(()=>r.cause instanceof g?r.cause.details:r.cause?.message?r.cause.message:r.details)(),n=(()=>r.cause instanceof g&&r.cause.docsPath||r.docsPath)(),s=Tr.getDocsUrl?.({...r,docsPath:n}),i=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...o?[`Details: ${o}`]:[],...Tr.version?[`Version: ${Tr.version}`]:[]].join(`
|
|
7
|
+
`);super(i,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=o,this.docsPath=n,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=kr}walk(t){return So(this,t)}}});var Ht,Ot,Er=T(()=>{te();Ht=class extends g{constructor({max:t,min:r,signed:o,size:n,value:s}){super(`Number "${s}" is not in safe ${n?`${n*8}-bit ${o?"signed":"unsigned"} `:""}integer range ${t?`(${r} to ${t})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}},Ot=class extends g{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function fe(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var Je=T(()=>{});function re(e){return fe(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var ft=T(()=>{Je()});function mt(e,{dir:t="left"}={}){let r=typeof e=="string"?e.replace("0x",""):e,o=0;for(let n=0;n<r.length-1&&r[t==="left"?n:r.length-n-1].toString()==="0";n++)o++;return r=t==="left"?r.slice(o):r.slice(0,r.length-o),typeof e=="string"?(r.length===1&&t==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}var Io=T(()=>{});var dt,ht,Sr=T(()=>{te();dt=class extends g{constructor({offset:t,position:r,size:o}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${o}).`,{name:"SliceOffsetOutOfBoundsError"})}},ht=class extends g{constructor({size:t,targetSize:r,type:o}){super(`${o.charAt(0).toUpperCase()}${o.slice(1).toLowerCase()} size (${t}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}});function Te(e,{dir:t,size:r=32}={}){return typeof e=="string"?Si(e,{dir:t,size:r}):Ii(e,{dir:t,size:r})}function Si(e,{dir:t,size:r=32}={}){if(r===null)return e;let o=e.replace("0x","");if(o.length>r*2)throw new ht({size:Math.ceil(o.length/2),targetSize:r,type:"hex"});return`0x${o[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function Ii(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new ht({size:e.length,targetSize:r,type:"bytes"});let o=new Uint8Array(r);for(let n=0;n<r;n++){let s=t==="right";o[s?n:r-n-1]=e[s?n:e.length-n-1]}return o}var Ir=T(()=>{Sr()});function ae(e,t={}){return typeof e=="number"||typeof e=="bigint"?_(e,t):typeof e=="string"?$i(e,t):typeof e=="boolean"?Pi(e,t):J(e,t)}function Pi(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(Ee(r,{size:t.size}),Te(r,{size:t.size})):r}function J(e,t={}){let r="";for(let n=0;n<e.length;n++)r+=Ai[e[n]];let o=`0x${r}`;return typeof t.size=="number"?(Ee(o,{size:t.size}),Te(o,{dir:"right",size:t.size})):o}function _(e,t={}){let{signed:r,size:o}=t,n=BigInt(e),s;o?r?s=(1n<<BigInt(o)*8n-1n)-1n:s=2n**(BigInt(o)*8n)-1n:typeof e=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));let i=typeof s=="bigint"&&r?-s-1n:0;if(s&&n>s||n<i){let l=typeof e=="bigint"?"n":"";throw new Ht({max:s?`${s}${l}`:void 0,min:`${i}${l}`,signed:r,size:o,value:`${e}${l}`})}let a=`0x${(r&&n<0?(1n<<BigInt(o*8))+BigInt(n):n).toString(16)}`;return o?Te(a,{size:o}):a}function $i(e,t={}){let r=Bi.encode(e);return J(r,t)}var Ai,Bi,oe=T(()=>{Er();Ir();ze();Ai=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Bi=new TextEncoder});function jt(e,t={}){return typeof e=="number"||typeof e=="bigint"?Ui(e,t):typeof e=="boolean"?Ri(e,t):fe(e)?ce(e,t):Ar(e,t)}function Ri(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(Ee(r,{size:t.size}),Te(r,{size:t.size})):r}function Ao(e){if(e>=ye.zero&&e<=ye.nine)return e-ye.zero;if(e>=ye.A&&e<=ye.F)return e-(ye.A-10);if(e>=ye.a&&e<=ye.f)return e-(ye.a-10)}function ce(e,t={}){let r=e;t.size&&(Ee(r,{size:t.size}),r=Te(r,{dir:"right",size:t.size}));let o=r.slice(2);o.length%2&&(o=`0${o}`);let n=o.length/2,s=new Uint8Array(n);for(let i=0,a=0;i<n;i++){let l=Ao(o.charCodeAt(a++)),u=Ao(o.charCodeAt(a++));if(l===void 0||u===void 0)throw new g(`Invalid byte sequence ("${o[a-2]}${o[a-1]}" in "${o}").`);s[i]=l*16+u}return s}function Ui(e,t){let r=_(e,t);return ce(r)}function Ar(e,t={}){let r=Li.encode(e);return typeof t.size=="number"?(Ee(r,{size:t.size}),Te(r,{dir:"right",size:t.size})):r}var Li,ye,Se=T(()=>{te();Je();Ir();ze();oe();Li=new TextEncoder;ye={zero:48,nine:57,A:65,F:70,a:97,f:102}});function Ee(e,{size:t}){if(re(e)>t)throw new Ot({givenSize:re(e),maxSize:t})}function He(e,t={}){let{signed:r}=t;t.size&&Ee(e,{size:t.size});let o=BigInt(e);if(!r)return o;let n=(e.length-2)/2,s=(1n<<BigInt(n)*8n-1n)-1n;return o<=s?o:o-BigInt(`0x${"f".padStart(n*2,"f")}`)-1n}function Oe(e,t={}){return Number(He(e,t))}var ze=T(()=>{Er();ft()});function Ze(e,t){return({exclude:r,format:o})=>({exclude:r,format:(n,s)=>{let i=t(n,s);if(r)for(let a of r)delete i[a];return{...i,...o(n,s)}},type:e})}var Nt=T(()=>{});var pf,uf,ff,mf,df,hf,xf,gf,bf,yf,vf,wf,_f,Cf,kf,Tf,Ef,Sf,If,Af,Pf,Bf,$f,Lf,Rf,Uf,Ff,zf,Hf,Of,jf,Nf,Gf,Df,Mf,qf,Vf,Kf,Wf,Xf,Jf,Zf,Yf,Qf,em,tm,rm,om,nm,sm,im,am,cm,lm,pm,um,fm,mm,dm,hm,xm,gm,bm,ym,vm,wm,_m,Cm,km,Tm,Em,Sm,Im,Am,Pm,Bm,$m,Lm,Rm,Um,Fm,zm,Hm,Om,jm,Nm,Gm,Dm,Mm,qm,Vm,Km,Wm,Xm,Jm,Gt,Ro=T(()=>{pf=2n**(8n-1n)-1n,uf=2n**(16n-1n)-1n,ff=2n**(24n-1n)-1n,mf=2n**(32n-1n)-1n,df=2n**(40n-1n)-1n,hf=2n**(48n-1n)-1n,xf=2n**(56n-1n)-1n,gf=2n**(64n-1n)-1n,bf=2n**(72n-1n)-1n,yf=2n**(80n-1n)-1n,vf=2n**(88n-1n)-1n,wf=2n**(96n-1n)-1n,_f=2n**(104n-1n)-1n,Cf=2n**(112n-1n)-1n,kf=2n**(120n-1n)-1n,Tf=2n**(128n-1n)-1n,Ef=2n**(136n-1n)-1n,Sf=2n**(144n-1n)-1n,If=2n**(152n-1n)-1n,Af=2n**(160n-1n)-1n,Pf=2n**(168n-1n)-1n,Bf=2n**(176n-1n)-1n,$f=2n**(184n-1n)-1n,Lf=2n**(192n-1n)-1n,Rf=2n**(200n-1n)-1n,Uf=2n**(208n-1n)-1n,Ff=2n**(216n-1n)-1n,zf=2n**(224n-1n)-1n,Hf=2n**(232n-1n)-1n,Of=2n**(240n-1n)-1n,jf=2n**(248n-1n)-1n,Nf=2n**(256n-1n)-1n,Gf=-(2n**(8n-1n)),Df=-(2n**(16n-1n)),Mf=-(2n**(24n-1n)),qf=-(2n**(32n-1n)),Vf=-(2n**(40n-1n)),Kf=-(2n**(48n-1n)),Wf=-(2n**(56n-1n)),Xf=-(2n**(64n-1n)),Jf=-(2n**(72n-1n)),Zf=-(2n**(80n-1n)),Yf=-(2n**(88n-1n)),Qf=-(2n**(96n-1n)),em=-(2n**(104n-1n)),tm=-(2n**(112n-1n)),rm=-(2n**(120n-1n)),om=-(2n**(128n-1n)),nm=-(2n**(136n-1n)),sm=-(2n**(144n-1n)),im=-(2n**(152n-1n)),am=-(2n**(160n-1n)),cm=-(2n**(168n-1n)),lm=-(2n**(176n-1n)),pm=-(2n**(184n-1n)),um=-(2n**(192n-1n)),fm=-(2n**(200n-1n)),mm=-(2n**(208n-1n)),dm=-(2n**(216n-1n)),hm=-(2n**(224n-1n)),xm=-(2n**(232n-1n)),gm=-(2n**(240n-1n)),bm=-(2n**(248n-1n)),ym=-(2n**(256n-1n)),vm=2n**8n-1n,wm=2n**16n-1n,_m=2n**24n-1n,Cm=2n**32n-1n,km=2n**40n-1n,Tm=2n**48n-1n,Em=2n**56n-1n,Sm=2n**64n-1n,Im=2n**72n-1n,Am=2n**80n-1n,Pm=2n**88n-1n,Bm=2n**96n-1n,$m=2n**104n-1n,Lm=2n**112n-1n,Rm=2n**120n-1n,Um=2n**128n-1n,Fm=2n**136n-1n,zm=2n**144n-1n,Hm=2n**152n-1n,Om=2n**160n-1n,jm=2n**168n-1n,Nm=2n**176n-1n,Gm=2n**184n-1n,Dm=2n**192n-1n,Mm=2n**200n-1n,qm=2n**208n-1n,Vm=2n**216n-1n,Km=2n**224n-1n,Wm=2n**232n-1n,Xm=2n**240n-1n,Jm=2n**248n-1n,Gt=2n**256n-1n});function je(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var Br=T(()=>{});var gt,Dt,Mt,Uo=T(()=>{te();gt=class extends g{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},Dt=class extends g{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},Mt=class extends g{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function qt(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(ji);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var ji,$r=T(()=>{Uo();ji={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new Mt({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Dt({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new gt({offset:e});let t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new gt({offset:e});let t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){let t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){let r=t??this.position;return this.assertPosition(r+e-1),this.bytes.subarray(r,r+e)},inspectUint8(e){let t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){let t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){let t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){let t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,e&255),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();let e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();let r=this.inspectBytes(e);return this.position+=t??e,r},readUint8(){this.assertReadLimit(),this._touch();let e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();let e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();let e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();let e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){let t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;let e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}}});var Ho,Oo=T(()=>{Ho={ether:-9,wei:9}});function jo(e,t){let r=e.toString(),o=r.startsWith("-");o&&(r=r.slice(1)),r=r.padStart(t,"0");let[n,s]=[r.slice(0,r.length-t),r.slice(r.length-t)];return s=s.replace(/(0+)$/,""),`${o?"-":""}${n||"0"}${s?`.${s}`:""}`}var No=T(()=>{});function bt(e,t="wei"){return jo(e,Ho[t])}var Go=T(()=>{Oo();No()});function Di(e){let t=Object.entries(e).map(([o,n])=>n===void 0||n===!1?null:[o,n]).filter(Boolean),r=t.reduce((o,[n])=>Math.max(o,n.length),0);return t.map(([o,n])=>` ${`${o}:`.padEnd(r+1)} ${n}`).join(`
|
|
8
|
+
`)}var Vt,Kt,Wt,Xt=T(()=>{te();Vt=class extends g{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}},Kt=class extends g{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Di(t),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}},Wt=class extends g{constructor({storageKey:t}){super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}});function Mi(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Lr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ne(e,...t){if(!Mi(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function et(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Yt(e,t){Ne(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Mo(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ie(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Qt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function le(e,t){return e<<32-t|e>>>t}function Vi(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Ki(e){for(let t=0;t<e.length;t++)e[t]=Vi(e[t]);return e}function Wi(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function yt(e){return typeof e=="string"&&(e=Wi(e)),Ne(e),e}function er(e){let t=o=>e().update(yt(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}var qi,Rr,Qe,tr=T(()=>{qi=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();Rr=qi?e=>e:Ki;Qe=class{}});function Ji(e,t=!1){return t?{h:Number(e&or),l:Number(e>>Ko&or)}:{h:Number(e>>Ko&or)|0,l:Number(e&or)|0}}function Wo(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=Ji(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var or,Ko,Xo,Jo,Zo,Yo,Qo=T(()=>{or=BigInt(4294967295),Ko=BigInt(32);Xo=(e,t,r)=>e<<r|t>>>32-r,Jo=(e,t,r)=>t<<r|e>>>32-r,Zo=(e,t,r)=>t<<r-32|e>>>64-r,Yo=(e,t,r)=>e<<r-32|t>>>64-r});var ne,cr=T(()=>{te();ne=class extends g{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}});var Ge,cn=T(()=>{te();Ge=class extends g{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}});var lr,De,Ur,Fr,zr,Hr,Or,jr,Nr,Gr,vt,ln=T(()=>{Go();te();lr=class extends g{constructor({cause:t,message:r}={}){let o=r?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${o?`with reason: ${o}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}};Object.defineProperty(lr,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(lr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});De=class extends g{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${bt(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}};Object.defineProperty(De,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});Ur=class extends g{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${bt(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}};Object.defineProperty(Ur,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});Fr=class extends g{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}is higher than the next one expected.`,{cause:t,name:"NonceTooHighError"})}};Object.defineProperty(Fr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});zr=class extends g{constructor({cause:t,nonce:r}={}){super([`Nonce provided for the transaction ${r?`(${r}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
|
|
9
|
+
`),{cause:t,name:"NonceTooLowError"})}};Object.defineProperty(zr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});Hr=class extends g{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}};Object.defineProperty(Hr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});Or=class extends g{constructor({cause:t}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
|
|
10
|
+
`),{cause:t,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}};Object.defineProperty(Or,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});jr=class extends g{constructor({cause:t,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:t,name:"IntrinsicGasTooHighError"})}};Object.defineProperty(jr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});Nr=class extends g{constructor({cause:t,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction is too low.`,{cause:t,name:"IntrinsicGasTooLowError"})}};Object.defineProperty(Nr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});Gr=class extends g{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}};Object.defineProperty(Gr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});vt=class extends g{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:o}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${bt(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${o?` = ${bt(o)} gwei`:""}).`].join(`
|
|
11
|
+
`),{cause:t,name:"TipAboveFeeCapError"})}};Object.defineProperty(vt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/})});var rt,Dr=T(()=>{rt=class extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){let r=super.get(t);return super.has(t)&&r!==void 0&&(this.delete(t),super.set(t,r)),r}set(t,r){if(super.set(t,r),this.maxSize&&this.size>this.maxSize){let o=this.keys().next().value;o&&this.delete(o)}return this}}});function aa(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let i=0;i<10;i++)r[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){let a=(i+8)%10,l=(i+2)%10,u=r[l],f=r[l+1],p=pn(u,f,1)^r[a],d=un(u,f,1)^r[a+1];for(let h=0;h<50;h+=10)e[i+h]^=p,e[i+h+1]^=d}let n=e[2],s=e[3];for(let i=0;i<24;i++){let a=mn[i],l=pn(n,s,a),u=un(n,s,a),f=fn[i];n=e[f],s=e[f+1],e[f]=l,e[f+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)r[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=sa[o],e[1]^=ia[o]}Ie(r)}var ea,wt,ta,ra,oa,na,fn,mn,dn,hn,sa,ia,pn,un,_t,ca,xn,gn=T(()=>{Qo();tr();ea=BigInt(0),wt=BigInt(1),ta=BigInt(2),ra=BigInt(7),oa=BigInt(256),na=BigInt(113),fn=[],mn=[],dn=[];for(let e=0,t=wt,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],fn.push(2*(5*o+r)),mn.push((e+1)*(e+2)/2%64);let n=ea;for(let s=0;s<7;s++)t=(t<<wt^(t>>ra)*na)%oa,t&ta&&(n^=wt<<(wt<<BigInt(s))-wt);dn.push(n)}hn=Wo(dn,!0),sa=hn[0],ia=hn[1],pn=(e,t,r)=>r>32?Zo(e,t,r):Xo(e,t,r),un=(e,t,r)=>r>32?Yo(e,t,r):Jo(e,t,r);_t=class extends Qe{constructor(t,r,o,n=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=r,this.outputLen=o,this.enableXOF=n,this.rounds=s,Lr(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Mo(this.state)}clone(){return this._cloneInto()}keccak(){Rr(this.state32),aa(this.state32,this.rounds),Rr(this.state32),this.posOut=0,this.pos=0}update(t){et(this),t=yt(t),Ne(t);let{blockLen:r,state:o}=this,n=t.length;for(let s=0;s<n;){let i=Math.min(r-this.pos,n-s);for(let a=0;a<i;a++)o[this.pos++]^=t[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:r,pos:o,blockLen:n}=this;t[o]^=r,r&128&&o===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){et(this,!1),Ne(t),this.finish();let r=this.state,{blockLen:o}=this;for(let n=0,s=t.length;n<s;){this.posOut>=o&&this.keccak();let i=Math.min(o-this.posOut,s-n);t.set(r.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Lr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Yt(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Ie(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new _t(r,o,n,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=o,t.outputLen=n,t.enableXOF=i,t.destroyed=this.destroyed,t}},ca=(e,t,r)=>er(()=>new _t(t,e,r)),xn=(()=>ca(1,136,256/8))()});function bn(e,t){let r=t||"hex",o=xn(fe(e,{strict:!1})?jt(e):e);return r==="bytes"?o:ae(o)}var yn=T(()=>{gn();Je();Se();oe()});function vn(e,t){if(Mr.has(`${e}.${t}`))return Mr.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),o=bn(Ar(r),"bytes"),n=(t?r.substring(`${t}0x`.length):r).split("");for(let i=0;i<40;i+=2)o[i>>1]>>4>=8&&n[i]&&(n[i]=n[i].toUpperCase()),(o[i>>1]&15)>=8&&n[i+1]&&(n[i+1]=n[i+1].toUpperCase());let s=`0x${n.join("")}`;return Mr.set(`${e}.${t}`,s),s}var Mr,wn=T(()=>{Se();yn();Dr();Mr=new rt(8192)});function me(e,t){let{strict:r=!0}=t??{},o=`${e}.${r}`;if(qr.has(o))return qr.get(o);let n=(()=>la.test(e)?e.toLowerCase()===e?!0:r?vn(e)===e:!0:!1)();return qr.set(o,n),n}var la,qr,pr=T(()=>{Dr();wn();la=/^0x[a-fA-F0-9]{40}$/,qr=new rt(8192)});function _n(e,t,r,{strict:o}={}){return fe(e,{strict:!1})?ua(e,t,r,{strict:o}):pa(e,t,r,{strict:o})}function Cn(e,t){if(typeof t=="number"&&t>0&&t>re(e)-1)throw new dt({offset:t,position:"start",size:re(e)})}function kn(e,t,r){if(typeof t=="number"&&typeof r=="number"&&re(e)!==r-t)throw new dt({offset:r,position:"end",size:re(e)})}function pa(e,t,r,{strict:o}={}){Cn(e,t);let n=e.slice(t,r);return o&&kn(n,t,r),n}function ua(e,t,r,{strict:o}={}){Cn(e,t);let n=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return o&&kn(n,t,r),n}var Tn=T(()=>{Sr();Je();ft()});var Xr=W(Et=>{"use strict";var _a=Et&&Et.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Et,"__esModule",{value:!0});Et.encryptEnvVars=Ta;var Kr=be("@noble/curves/ed25519"),Wr=_a(be("crypto"));function Ca(e){var t,r;return e=e.startsWith("0x")?e.slice(2):e,new Uint8Array((r=(t=e.match(/.{1,2}/g))===null||t===void 0?void 0:t.map(o=>parseInt(o,16)))!==null&&r!==void 0?r:[])}function ka(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Ta(e,t){let r=JSON.stringify({env:e}),o=Kr.x25519.utils.randomPrivateKey(),n=Kr.x25519.getPublicKey(o),s=Ca(t),i=Kr.x25519.getSharedSecret(o,s),a=await Wr.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=Wr.default.getRandomValues(new Uint8Array(12)),u=await Wr.default.subtle.encrypt({name:"AES-GCM",iv:l},a,new TextEncoder().encode(r)),f=new Uint8Array(n.length+l.length+u.byteLength);return f.set(n),f.set(l,n.length),f.set(new Uint8Array(u),n.length+l.length),ka(f)}});var Un=W(St=>{"use strict";var Ea=St&&St.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(St,"__esModule",{value:!0});St.getComposeHash=Pa;var Sa=Ea(be("crypto"));function Jr(e){return e==null?e:Array.isArray(e)?e.map(Jr):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=Jr(o),t},{}):e}function Ia(e){let t={...e};return t.runner==="bash"&&"docker_compose_file"in t?delete t.docker_compose_file:t.runner==="docker-compose"&&"bash_script"in t&&delete t.bash_script,"pre_launch_script"in t&&!t.pre_launch_script&&delete t.pre_launch_script,t}function Aa(e){let t=Jr(e);return JSON.stringify(t,(r,o)=>typeof o=="number"&&(isNaN(o)||!isFinite(o))?null:o)}function Pa(e,t=!1){t&&(e=Ia(e));let r=Aa(e);return Sa.default.createHash("sha256").update(r,"utf8").digest("hex")}});var os=W(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.toBig=y.shrSL=y.shrSH=y.rotrSL=y.rotrSH=y.rotrBL=y.rotrBH=y.rotr32L=y.rotr32H=y.rotlSL=y.rotlSH=y.rotlBL=y.rotlBH=y.add5L=y.add5H=y.add4L=y.add4H=y.add3L=y.add3H=void 0;y.add=Jn;y.fromBig=Yr;y.split=Fn;var dr=BigInt(2**32-1),Zr=BigInt(32);function Yr(e,t=!1){return t?{h:Number(e&dr),l:Number(e>>Zr&dr)}:{h:Number(e>>Zr&dr)|0,l:Number(e&dr)|0}}function Fn(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=Yr(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var zn=(e,t)=>BigInt(e>>>0)<<Zr|BigInt(t>>>0);y.toBig=zn;var Hn=(e,t,r)=>e>>>r;y.shrSH=Hn;var On=(e,t,r)=>e<<32-r|t>>>r;y.shrSL=On;var jn=(e,t,r)=>e>>>r|t<<32-r;y.rotrSH=jn;var Nn=(e,t,r)=>e<<32-r|t>>>r;y.rotrSL=Nn;var Gn=(e,t,r)=>e<<64-r|t>>>r-32;y.rotrBH=Gn;var Dn=(e,t,r)=>e>>>r-32|t<<64-r;y.rotrBL=Dn;var Mn=(e,t)=>t;y.rotr32H=Mn;var qn=(e,t)=>e;y.rotr32L=qn;var Vn=(e,t,r)=>e<<r|t>>>32-r;y.rotlSH=Vn;var Kn=(e,t,r)=>t<<r|e>>>32-r;y.rotlSL=Kn;var Wn=(e,t,r)=>t<<r-32|e>>>64-r;y.rotlBH=Wn;var Xn=(e,t,r)=>e<<r-32|t>>>64-r;y.rotlBL=Xn;function Jn(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/2**32|0)|0,l:n|0}}var Zn=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);y.add3L=Zn;var Yn=(e,t,r,o)=>t+r+o+(e/2**32|0)|0;y.add3H=Yn;var Qn=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0);y.add4L=Qn;var es=(e,t,r,o,n)=>t+r+o+n+(e/2**32|0)|0;y.add4H=es;var ts=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0);y.add5L=ts;var rs=(e,t,r,o,n,s)=>t+r+o+n+s+(e/2**32|0)|0;y.add5H=rs;var Ba={fromBig:Yr,split:Fn,toBig:zn,shrSH:Hn,shrSL:On,rotrSH:jn,rotrSL:Nn,rotrBH:Gn,rotrBL:Dn,rotr32H:Mn,rotr32L:qn,rotlSH:Vn,rotlSL:Kn,rotlBH:Wn,rotlBL:Xn,add:Jn,add3L:Zn,add3H:Yn,add4L:Qn,add4H:es,add5H:rs,add5L:ts};y.default=Ba});var ns=W(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.crypto=void 0;var Pe=be("node:crypto");hr.crypto=Pe&&typeof Pe=="object"&&"webcrypto"in Pe?Pe.webcrypto:Pe&&typeof Pe=="object"&&"randomBytes"in Pe?Pe:void 0});var fs=W(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.wrapXOFConstructorWithOpts=x.wrapConstructorWithOpts=x.wrapConstructor=x.Hash=x.nextTick=x.swap32IfBE=x.byteSwapIfBE=x.swap8IfBE=x.isLE=void 0;x.isBytes=is;x.anumber=Qr;x.abytes=nt;x.ahash=$a;x.aexists=La;x.aoutput=Ra;x.u8=Ua;x.u32=Fa;x.clean=za;x.createView=Ha;x.rotr=Oa;x.rotl=ja;x.byteSwap=to;x.byteSwap32=as;x.bytesToHex=Ga;x.hexToBytes=Da;x.asyncLoop=qa;x.utf8ToBytes=ro;x.bytesToUtf8=Va;x.toBytes=xr;x.kdfInputToBytes=Ka;x.concatBytes=Wa;x.checkOpts=Xa;x.createHasher=ls;x.createOptHasher=ps;x.createXOFer=us;x.randomBytes=Ja;var ot=ns();function is(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Qr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function nt(e,...t){if(!is(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function $a(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Qr(e.outputLen),Qr(e.blockLen)}function La(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ra(e,t){nt(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ua(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Fa(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function za(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ha(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Oa(e,t){return e<<32-t|e>>>t}function ja(e,t){return e<<t|e>>>32-t>>>0}x.isLE=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function to(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}x.swap8IfBE=x.isLE?e=>e:e=>to(e);x.byteSwapIfBE=x.swap8IfBE;function as(e){for(let t=0;t<e.length;t++)e[t]=to(e[t]);return e}x.swap32IfBE=x.isLE?e=>e:as;var cs=(()=>typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function")(),Na=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ga(e){if(nt(e),cs)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Na[e[r]];return t}var _e={_0:48,_9:57,A:65,F:70,a:97,f:102};function ss(e){if(e>=_e._0&&e<=_e._9)return e-_e._0;if(e>=_e.A&&e<=_e.F)return e-(_e.A-10);if(e>=_e.a&&e<=_e.f)return e-(_e.a-10)}function Da(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(cs)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){let i=ss(e.charCodeAt(s)),a=ss(e.charCodeAt(s+1));if(i===void 0||a===void 0){let l=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+s)}o[n]=i*16+a}return o}var Ma=async()=>{};x.nextTick=Ma;async function qa(e,t,r){let o=Date.now();for(let n=0;n<e;n++){r(n);let s=Date.now()-o;s>=0&&s<t||(await(0,x.nextTick)(),o+=s)}}function ro(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Va(e){return new TextDecoder().decode(e)}function xr(e){return typeof e=="string"&&(e=ro(e)),nt(e),e}function Ka(e){return typeof e=="string"&&(e=ro(e)),nt(e),e}function Wa(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];nt(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let s=e[o];r.set(s,n),n+=s.length}return r}function Xa(e,t){if(t!==void 0&&{}.toString.call(t)!=="[object Object]")throw new Error("options should be object or undefined");return Object.assign(e,t)}var eo=class{};x.Hash=eo;function ls(e){let t=o=>e().update(xr(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function ps(e){let t=(o,n)=>e(n).update(xr(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}function us(e){let t=(o,n)=>e(n).update(xr(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}x.wrapConstructor=ls;x.wrapConstructorWithOpts=ps;x.wrapXOFConstructorWithOpts=us;function Ja(e=32){if(ot.crypto&&typeof ot.crypto.getRandomValues=="function")return ot.crypto.getRandomValues(new Uint8Array(e));if(ot.crypto&&typeof ot.crypto.randomBytes=="function")return Uint8Array.from(ot.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var ws=W(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.shake256=A.shake128=A.keccak_512=A.keccak_384=A.keccak_256=A.keccak_224=A.sha3_512=A.sha3_384=A.sha3_256=A.sha3_224=A.Keccak=void 0;A.keccakP=ys;var At=os(),G=fs(),Za=BigInt(0),It=BigInt(1),Ya=BigInt(2),Qa=BigInt(7),ec=BigInt(256),tc=BigInt(113),hs=[],xs=[],gs=[];for(let e=0,t=It,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],hs.push(2*(5*o+r)),xs.push((e+1)*(e+2)/2%64);let n=Za;for(let s=0;s<7;s++)t=(t<<It^(t>>Qa)*tc)%ec,t&Ya&&(n^=It<<(It<<BigInt(s))-It);gs.push(n)}var bs=(0,At.split)(gs,!0),rc=bs[0],oc=bs[1],ms=(e,t,r)=>r>32?(0,At.rotlBH)(e,t,r):(0,At.rotlSH)(e,t,r),ds=(e,t,r)=>r>32?(0,At.rotlBL)(e,t,r):(0,At.rotlSL)(e,t,r);function ys(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let i=0;i<10;i++)r[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){let a=(i+8)%10,l=(i+2)%10,u=r[l],f=r[l+1],p=ms(u,f,1)^r[a],d=ds(u,f,1)^r[a+1];for(let h=0;h<50;h+=10)e[i+h]^=p,e[i+h+1]^=d}let n=e[2],s=e[3];for(let i=0;i<24;i++){let a=xs[i],l=ms(n,s,a),u=ds(n,s,a),f=hs[i];n=e[f],s=e[f+1],e[f]=l,e[f+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)r[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=rc[o],e[1]^=oc[o]}(0,G.clean)(r)}var Me=class extends G.Hash{constructor(t,r,o,n=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=r,this.outputLen=o,this.enableXOF=n,this.rounds=s,(0,G.anumber)(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,G.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,G.swap32IfBE)(this.state32),ys(this.state32,this.rounds),(0,G.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(t){(0,G.aexists)(this),t=(0,G.toBytes)(t),(0,G.abytes)(t);let{blockLen:r,state:o}=this,n=t.length;for(let s=0;s<n;){let i=Math.min(r-this.pos,n-s);for(let a=0;a<i;a++)o[this.pos++]^=t[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:r,pos:o,blockLen:n}=this;t[o]^=r,r&128&&o===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){(0,G.aexists)(this,!1),(0,G.abytes)(t),this.finish();let r=this.state,{blockLen:o}=this;for(let n=0,s=t.length;n<s;){this.posOut>=o&&this.keccak();let i=Math.min(o-this.posOut,s-n);t.set(r.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return(0,G.anumber)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,G.aoutput)(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,(0,G.clean)(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new Me(r,o,n,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=o,t.outputLen=n,t.enableXOF=i,t.destroyed=this.destroyed,t}};A.Keccak=Me;var Be=(e,t,r)=>(0,G.createHasher)(()=>new Me(t,e,r));A.sha3_224=(()=>Be(6,144,224/8))();A.sha3_256=(()=>Be(6,136,256/8))();A.sha3_384=(()=>Be(6,104,384/8))();A.sha3_512=(()=>Be(6,72,512/8))();A.keccak_224=(()=>Be(1,144,224/8))();A.keccak_256=(()=>Be(1,136,256/8))();A.keccak_384=(()=>Be(1,104,384/8))();A.keccak_512=(()=>Be(1,72,512/8))();var vs=(e,t,r)=>(0,G.createXOFer)((o={})=>new Me(t,e,o.dkLen===void 0?r:o.dkLen,!0));A.shake128=(()=>vs(31,168,128/8))();A.shake256=(()=>vs(31,136,256/8))()});var _s=W(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.verifyEnvEncryptPublicKey=ic;var nc=ws(),sc=be("@noble/curves/secp256k1");function ic(e,t,r){if(t.length!==65)return null;let o=Buffer.from("dstack-env-encrypt-pubkey","utf8"),n=r;r.startsWith("0x")&&(n=r.slice(2));let s=Buffer.from(n,"hex"),i=Buffer.from(":","utf8"),a=Buffer.concat([o,i,s,Buffer.from(e)]),l=(0,nc.keccak_256)(a);try{let u=t.slice(0,32),f=t.slice(32,64),p=t[64],d=new Uint8Array(64);d.set(u,0),d.set(f,32);let h=sc.secp256k1.Signature.fromCompact(d).addRecoveryBit(p).recoverPublicKey(l);return"0x"+Buffer.from(h.toRawBytes(!0)).toString("hex")}catch(u){return console.error("signature verification failed:",u),null}}});var Ss=ut(ko(),1);import{ofetch as ac}from"ofetch";function To(e){return{all:e=e||new Map,on:function(t,r){var o=e.get(t);o?o.push(r):e.set(t,[r])},off:function(t,r){var o=e.get(t);o&&(r?o.splice(o.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var o=e.get(t);o&&o.slice().map(function(n){n(r)}),(o=e.get("*"))&&o.slice().map(function(n){n(t,r)})}}}import{z as H}from"zod";import{z as $e}from"zod";import{z as w}from"zod";import{z as Le}from"zod";function Fe(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}Nt();ze();Nt();var Pr={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function xt(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Oe(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?Oe(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Pr[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(r.authorizationList=Fi(e.authorizationList)),r.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof r.v=="bigint"){if(r.v===0n||r.v===27n)return 0;if(r.v===1n||r.v===28n)return 1;if(r.v>=35n)return r.v%2n===0n?1:0}})(),r.type==="legacy"&&(delete r.accessList,delete r.maxFeePerBlobGas,delete r.maxFeePerGas,delete r.maxPriorityFeePerGas,delete r.yParity),r.type==="eip2930"&&(delete r.maxFeePerBlobGas,delete r.maxFeePerGas,delete r.maxPriorityFeePerGas),r.type==="eip1559"&&delete r.maxFeePerBlobGas,r}var Po=Ze("transaction",xt);function Fi(e){return e.map(t=>({address:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function zi(e,t){let r=(e.transactions??[]).map(o=>typeof o=="string"?o:xt(o));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:r,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}var Bo=Ze("block",zi);function $o(e,{args:t,eventName:r}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...r?{args:t,eventName:r}:{}}}ze();Nt();var Hi={"0x0":"reverted","0x1":"success"};function Oi(e,t){let r={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(o=>$o(o)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Oe(e.transactionIndex):null,status:e.status?Hi[e.status]:null,type:e.type?Pr[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var Lo=Ze("transactionReceipt",Oi);te();$r();Se();oe();function ve(e,t="hex"){let r=Fo(e),o=qt(new Uint8Array(r.length));return r.encode(o),t==="hex"?J(o.bytes):o.bytes}function Fo(e){return Array.isArray(e)?Ni(e.map(t=>Fo(t))):Gi(e)}function Ni(e){let t=e.reduce((n,s)=>n+s.length,0),r=zo(t);return{length:(()=>t<=55?1+t:1+r+t)(),encode(n){t<=55?n.pushByte(192+t):(n.pushByte(192+55+r),r===1?n.pushUint8(t):r===2?n.pushUint16(t):r===3?n.pushUint24(t):n.pushUint32(t));for(let{encode:s}of e)s(n)}}}function Gi(e){let t=typeof e=="string"?ce(e):e,r=zo(t.length);return{length:(()=>t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length)(),encode(n){t.length===1&&t[0]<128?n.pushBytes(t):t.length<=55?(n.pushByte(128+t.length),n.pushBytes(t)):(n.pushByte(128+55+r),r===1?n.pushUint8(t.length):r===2?n.pushUint16(t.length):r===3?n.pushUint24(t.length):n.pushUint32(t.length),n.pushBytes(t))}}}function zo(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new g("Length is too large.")}Xt();oe();function Do(e){if(!e||e.length===0)return[];let t=[];for(let r of e){let{chainId:o,nonce:n,...s}=r,i=r.address;t.push([o?ae(o):"0x",i,n?ae(n):"0x",...Ye({},s)])}return t}Se();oe();function Jt(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),o=typeof e.blobs[0]=="string"?e.blobs.map(s=>ce(s)):e.blobs,n=[];for(let s of o)n.push(Uint8Array.from(t.blobToKzgCommitment(s)));return r==="bytes"?n:n.map(s=>J(s))}Se();oe();function Zt(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),o=typeof e.blobs[0]=="string"?e.blobs.map(i=>ce(i)):e.blobs,n=typeof e.commitments[0]=="string"?e.commitments.map(i=>ce(i)):e.commitments,s=[];for(let i=0;i<o.length;i++){let a=o[i],l=n[i];s.push(Uint8Array.from(t.computeBlobKzgProof(a,l)))}return r==="bytes"?s:s.map(i=>J(i))}oe();tr();function Xi(e,t,r,o){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,o);let n=BigInt(32),s=BigInt(4294967295),i=Number(r>>n&s),a=Number(r&s),l=o?4:0,u=o?0:4;e.setUint32(t+l,i,o),e.setUint32(t+u,a,o)}function qo(e,t,r){return e&t^~e&r}function Vo(e,t,r){return e&t^e&r^t&r}var rr=class extends Qe{constructor(t,r,o,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(t),this.view=Qt(this.buffer)}update(t){et(this),t=yt(t),Ne(t);let{view:r,buffer:o,blockLen:n}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(n-this.pos,s-i);if(a===n){let l=Qt(t);for(;n<=s-i;i+=n)this.process(l,i);continue}o.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){et(this),Yt(t,this),this.finished=!0;let{buffer:r,view:o,blockLen:n,isLE:s}=this,{pos:i}=this;r[i++]=128,Ie(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let p=i;p<n;p++)r[p]=0;Xi(o,n-8,BigInt(this.length*8),s),this.process(o,0);let a=Qt(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=l/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<u;p++)a.setUint32(4*p,f[p],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let o=t.slice(0,r);return this.destroy(),o}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:o,length:n,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=n,t.pos=a,n%r&&t.buffer.set(o),t}clone(){return this._cloneInto()}},we=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);tr();var Zi=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ae=new Uint32Array(64),nr=class extends rr{constructor(t=32){super(64,t,8,!1),this.A=we[0]|0,this.B=we[1]|0,this.C=we[2]|0,this.D=we[3]|0,this.E=we[4]|0,this.F=we[5]|0,this.G=we[6]|0,this.H=we[7]|0}get(){let{A:t,B:r,C:o,D:n,E:s,F:i,G:a,H:l}=this;return[t,r,o,n,s,i,a,l]}set(t,r,o,n,s,i,a,l){this.A=t|0,this.B=r|0,this.C=o|0,this.D=n|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=l|0}process(t,r){for(let p=0;p<16;p++,r+=4)Ae[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let d=Ae[p-15],h=Ae[p-2],I=le(d,7)^le(d,18)^d>>>3,k=le(h,17)^le(h,19)^h>>>10;Ae[p]=k+Ae[p-7]+I+Ae[p-16]|0}let{A:o,B:n,C:s,D:i,E:a,F:l,G:u,H:f}=this;for(let p=0;p<64;p++){let d=le(a,6)^le(a,11)^le(a,25),h=f+d+qo(a,l,u)+Zi[p]+Ae[p]|0,k=(le(o,2)^le(o,13)^le(o,22))+Vo(o,n,s)|0;f=u,u=l,l=a,a=i+h|0,i=s,s=n,n=o,o=h+k|0}o=o+this.A|0,n=n+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,l=l+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(o,n,s,i,a,l,u,f)}roundClean(){Ie(Ae)}destroy(){this.set(0,0,0,0,0,0,0,0),Ie(this.buffer)}};var en=er(()=>new nr);var tn=en;Je();Se();oe();function rn(e,t){let r=t||"hex",o=tn(fe(e,{strict:!1})?jt(e):e);return r==="bytes"?o:ae(o)}function on(e){let{commitment:t,version:r=1}=e,o=e.to??(typeof t=="string"?"hex":"bytes"),n=rn(t,"bytes");return n.set([r],0),o==="bytes"?n:J(n)}function nn(e){let{commitments:t,version:r}=e,o=e.to??(typeof t[0]=="string"?"hex":"bytes"),n=[];for(let s of t)n.push(on({commitment:s,to:o,version:r}));return n}te();var sr=class extends g{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},tt=class extends g{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},ir=class extends g{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},ar=class extends g{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};$r();ft();Se();oe();function sn(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?ce(e.data):e.data,o=re(r);if(!o)throw new tt;if(o>761855)throw new sr({maxSize:761855,size:o});let n=[],s=!0,i=0;for(;s;){let a=qt(new Uint8Array(131072)),l=0;for(;l<4096;){let u=r.slice(i,i+(32-1));if(a.pushByte(0),a.pushBytes(u),u.length<31){a.pushByte(128),s=!1;break}l++,i+=31}n.push(a)}return t==="bytes"?n.map(a=>a.bytes):n.map(a=>J(a.bytes))}function an(e){let{data:t,kzg:r,to:o}=e,n=e.blobs??sn({data:t,to:o}),s=e.commitments??Jt({blobs:n,kzg:r,to:o}),i=e.proofs??Zt({blobs:n,commitments:s,kzg:r,to:o}),a=[];for(let l=0;l<n.length;l++)a.push({blob:n[l],commitment:s[l],proof:i[l]});return a}Br();Io();oe();Ro();cr();te();cn();ln();pr();ft();Tn();ze();function En(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:o}=r,n=r.address;if(!me(n))throw new ne({address:n});if(o<0)throw new Ge({chainId:o})}ur(e)}function Sn(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new tt;for(let r of t){let o=re(r),n=Oe(_n(r,0,1));if(o!==32)throw new ir({hash:r,size:o});if(n!==1)throw new ar({hash:r,version:n})}}ur(e)}function ur(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:o,to:n}=e;if(t<=0)throw new Ge({chainId:t});if(n&&!me(n))throw new ne({address:n});if(o&&o>Gt)throw new De({maxFeePerGas:o});if(r&&o&&r>o)throw new vt({maxFeePerGas:o,maxPriorityFeePerGas:r})}function In(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(t<=0)throw new Ge({chainId:t});if(s&&!me(s))throw new ne({address:s});if(r||n)throw new g("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(o&&o>Gt)throw new De({maxFeePerGas:o})}function An(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(s&&!me(s))throw new ne({address:s});if(typeof t<"u"&&t<=0)throw new Ge({chainId:t});if(r||n)throw new g("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(o&&o>Gt)throw new De({maxFeePerGas:o})}Xt();function Pn(e){if(e.type)return e.type;if(typeof e.authorizationList<"u")return"eip7702";if(typeof e.blobs<"u"||typeof e.blobVersionedHashes<"u"||typeof e.maxFeePerBlobGas<"u"||typeof e.sidecars<"u")return"eip4844";if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")return"eip1559";if(typeof e.gasPrice<"u")return typeof e.accessList<"u"?"eip2930":"legacy";throw new Kt({transaction:e})}cr();Xt();pr();function Ct(e){if(!e||e.length===0)return[];let t=[];for(let r=0;r<e.length;r++){let{address:o,storageKeys:n}=e[r];for(let s=0;s<n.length;s++)if(n[s].length-2!==64)throw new Wt({storageKey:n[s]});if(!me(o,{strict:!1}))throw new ne({address:o});t.push([o,n])}return t}function Bn(e,t){let r=Pn(e);return r==="eip1559"?da(e,t):r==="eip2930"?ha(e,t):r==="eip4844"?ma(e,t):r==="eip7702"?fa(e,t):xa(e,t)}function fa(e,t){let{authorizationList:r,chainId:o,gas:n,nonce:s,to:i,value:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;En(e);let d=Ct(f),h=Do(r);return je(["0x04",ve([_(o),s?_(s):"0x",u?_(u):"0x",l?_(l):"0x",n?_(n):"0x",i??"0x",a?_(a):"0x",p??"0x",d,h,...Ye(e,t)])])}function ma(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;Sn(e);let d=e.blobVersionedHashes,h=e.sidecars;if(e.blobs&&(typeof d>"u"||typeof h>"u")){let O=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(Q=>J(Q)),Z=e.kzg,ie=Jt({blobs:O,kzg:Z});if(typeof d>"u"&&(d=nn({commitments:ie})),typeof h>"u"){let Q=Zt({blobs:O,commitments:ie,kzg:Z});h=an({blobs:O,commitments:ie,proofs:Q})}}let I=Ct(f),k=[_(r),n?_(n):"0x",u?_(u):"0x",l?_(l):"0x",o?_(o):"0x",s??"0x",i?_(i):"0x",p??"0x",I,a?_(a):"0x",d??[],...Ye(e,t)],P=[],V=[],K=[];if(h)for(let O=0;O<h.length;O++){let{blob:Z,commitment:ie,proof:Q}=h[O];P.push(Z),V.push(ie),K.push(Q)}return je(["0x03",h?ve([k,P,V,K]):ve(k)])}function da(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:u,data:f}=e;ur(e);let p=Ct(u),d=[_(r),n?_(n):"0x",l?_(l):"0x",a?_(a):"0x",o?_(o):"0x",s??"0x",i?_(i):"0x",f??"0x",p,...Ye(e,t)];return je(["0x02",ve(d)])}function ha(e,t){let{chainId:r,gas:o,data:n,nonce:s,to:i,value:a,accessList:l,gasPrice:u}=e;In(e);let f=Ct(l),p=[_(r),s?_(s):"0x",u?_(u):"0x",o?_(o):"0x",i??"0x",a?_(a):"0x",n??"0x",f,...Ye(e,t)];return je(["0x01",ve(p)])}function xa(e,t){let{chainId:r=0,gas:o,data:n,nonce:s,to:i,value:a,gasPrice:l}=e;An(e);let u=[s?_(s):"0x",l?_(l):"0x",o?_(o):"0x",i??"0x",a?_(a):"0x",n??"0x"];if(t){let f=(()=>{if(t.v>=35n)return(t.v-35n)/2n>0?t.v:27n+(t.v===35n?0n:1n);if(r>0)return BigInt(r*2)+BigInt(35n+t.v-27n);let h=27n+(t.v===27n?0n:1n);if(t.v!==h)throw new Vt({v:t.v});return h})(),p=mt(t.r),d=mt(t.s);u=[...u,_(f),p==="0x00"?"0x":p,d==="0x00"?"0x":d]}else r>0&&(u=[...u,_(r),"0x","0x"]);return ve(u)}function Ye(e,t){let r=t??e,{v:o,yParity:n}=r;if(typeof r.r>"u")return[];if(typeof r.s>"u")return[];if(typeof o>"u"&&typeof n>"u")return[];let s=mt(r.r),i=mt(r.s);return[(()=>typeof n=="number"?n?_(1):"0x":o===0n?"0x":o===1n?_(1):o===27n?"0x":_(1))(),s==="0x00"?"0x":s,i==="0x00"?"0x":i]}var $n={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};ze();var Ln={block:Bo({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let o=xt(r);return o.typeHex==="0x7e"&&(o.isSystemTx=r.isSystemTx,o.mint=r.mint?He(r.mint):void 0,o.sourceHash=r.sourceHash,o.type="deposit"),o}),stateRoot:e.stateRoot}}}),transaction:Po({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?He(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Lo({format(e){return{l1GasPrice:e.l1GasPrice?He(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?He(e.l1GasUsed):null,l1Fee:e.l1Fee?He(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};cr();pr();Br();oe();function ga(e,t){return ya(e)?ba(e):Bn(e,t)}var Rn={transaction:ga};function ba(e){va(e);let{sourceHash:t,data:r,from:o,gas:n,isSystemTx:s,mint:i,to:a,value:l}=e,u=[t,o,a??"0x",i?ae(i):"0x",l?ae(l):"0x",n?ae(n):"0x",s?"0x1":"0x",r??"0x"];return je(["0x7e",ve(u)])}function ya(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function va(e){let{from:t,to:r}=e;if(t&&!me(t))throw new ne({address:t});if(r&&!me(r))throw new ne({address:r})}var Vr={blockTime:2e3,contracts:$n,formatters:Ln,serializers:Rn};var fr=Fe({id:31337,name:"Anvil",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["http://127.0.0.1:8545"],webSocket:["ws://127.0.0.1:8545"]}}});var kt=1,Tt=Fe({...Vr,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...Vr.contracts,disputeGameFactory:{[kt]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[kt]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[kt]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[kt]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:kt}),wa=Fe({...Tt,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var mr=Fe({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:12e3,rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:23085558},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}});import{z as L}from"zod";import{z as Y}from"zod";import{z as m}from"zod";import{z as Pt}from"zod";import{z as se}from"zod";import{z as v}from"zod";import{z as C}from"zod";import{z as M}from"zod";import ul from"crypto";import{z as xe}from"zod";import{z as pe}from"zod";import{z as R}from"zod";import{z as ks}from"zod";import{z as ge}from"zod";import{z as ct}from"zod";import{z as qe}from"zod";import{z as tp}from"zod";import{z as sp}from"zod";import{z as E}from"zod";import{z as he}from"zod";import{z as vp}from"zod";import{z as $}from"zod";import{z as b}from"zod";import{z as at}from"zod";import{z as Ts}from"zod";import{z as D}from"zod";import{z as js}from"zod";import{z as de}from"zod";import{z as U}from"zod";var $x=ut(Xr(),1);import{z as B}from"zod";var ou=ut(Xr(),1),nu=ut(Un(),1),su=ut(_s(),1);import{z as it}from"zod";var cc=H.object({detail:H.union([H.string(),H.array(H.object({msg:H.string(),type:H.string().optional(),ctx:H.record(H.unknown()).optional(),loc:H.array(H.union([H.string(),H.number()])).optional(),input:H.unknown().optional()}).passthrough()),H.record(H.unknown())]).optional(),type:H.string().optional(),code:H.string().optional()}),Re=class extends Error{constructor(e,t){super(e),this.name=this.constructor.name,this.status=t.status,this.statusText=t.statusText,this.detail=t.detail,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},no=class gr extends Re{constructor(t,r){super(t,{status:r?.status??0,statusText:r?.statusText??"Unknown Error",detail:r?.detail||t}),this.name="RequestError",this.isRequestError=!0,this.data=r?.data,this.request=r?.request,this.response=r?.response,this.code=r?.code,this.type=r?.type}static fromFetchError(t){let r=cc.safeParse(t.data);return r.success?new gr(t.message,{status:t.status??void 0,statusText:t.statusText??void 0,data:t.data,request:t.request??void 0,response:t.response??void 0,detail:r.data.detail,code:r.data.code??void 0,type:r.data.type??void 0}):new gr(t.message,{status:t.status??void 0,statusText:t.statusText??void 0,data:t.data,request:t.request??void 0,response:t.response??void 0,detail:t.data?.detail||"Unknown API error",code:t.status?.toString()??void 0})}static fromError(t,r){return new gr(t.message,{request:r??void 0,detail:t.message})}},lc=class extends Re{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},pc=class extends Re{constructor(){super(...arguments),this.isAuthError=!0}},Is=class extends Re{constructor(){super(...arguments),this.isBusinessError=!0}},uc=class extends Re{constructor(){super(...arguments),this.isServerError=!0}},fc=class extends Re{constructor(){super(...arguments),this.isUnknownError=!0}};function mc(e){if(!e||!Array.isArray(e))return"unknown";let t=e.filter(r=>typeof r=="string"?!["body","query","path","header"].includes(r):!0);return t.length>0?t.join("."):"unknown"}function As(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((n,s)=>{let i=mc(n.loc),a=i;return i==="unknown"&&n.type&&(a=n.type==="missing"?"required field":n.type),{field:a,message:n.msg,type:n.type,context:n.ctx}}),r=t.length,o=r===1?`Validation failed: ${t[0].message}`:`Validation failed (${r} issue${r>1?"s":""})`;return{errors:t,message:o}}function dc(e){return e===422?"validation":e===401||e===403?"auth":e>=400&&e<500?"business":e>=500?"server":"unknown"}function hc(e,t,r){if(e===422&&Array.isArray(t)){let{message:o}=As(t);return o}if(typeof t=="string")return t;if(t&&typeof t=="object"&&"message"in t){let o=t.message;if(typeof o=="string")return o}return r}function xc(e){let t=e.status??0,r=e.statusText??"Unknown Error",o=e.detail,n=bc(o);if(n)return new gc(n.message,{status:t,statusText:r,detail:o,errorCode:n.error_code,structuredDetails:n.details,suggestions:n.suggestions,links:n.links});let s=dc(t),i=hc(t,o,e.message),a={status:t,statusText:r,detail:o};if(s==="validation"&&Array.isArray(o)){let{errors:l}=As(o);return new lc(i,{...a,validationErrors:l})}return s==="auth"?new pc(i,a):s==="business"?new Is(i,a):s==="server"?new uc(i,a):new fc(i,a)}var gc=class extends Is{constructor(e,t){super(e,t),this.isResourceError=!0,this.errorCode=t.errorCode,this.structuredDetails=t.structuredDetails,this.suggestions=t.suggestions,this.links=t.links}};function bc(e){if(!e||typeof e!="object")return null;let t=e;return t.error_code&&typeof t.error_code=="string"&&t.message&&typeof t.message=="string"?{error_code:t.error_code,message:t.message,details:t.details,suggestions:t.suggestions,links:t.links}:null}var so=["2025-05-31","2025-10-28"],st=(0,Ss.default)("phala::api-client");function yc(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
|
|
12
|
+
`)}function vc(e){return e?` -d '${(typeof e=="string"?e:JSON.stringify(e,null,2)).replace(/'/g,"\\'")}'`:""}function Cs(e,t,r,o){let n=[];r.forEach((a,l)=>{n.push(`${l}: ${a}`)});let s=n.join(`
|
|
13
13
|
`),i=typeof o=="string"?o:JSON.stringify(o,null,2);return[`< HTTP/1.1 ${e} ${t}`,s?`< ${s.replace(/\n/g,`
|
|
14
14
|
< `)}`:"","",i].filter(Boolean).join(`
|
|
15
|
-
`)}var wc=class{constructor(e={}){this.emitter=
|
|
16
|
-
`);
|
|
15
|
+
`)}var wc=class{constructor(e={}){this.emitter=To();let t={...e,apiKey:e.apiKey||process?.env?.PHALA_CLOUD_API_KEY,baseURL:e.baseURL||process?.env?.PHALA_CLOUD_API_PREFIX||"https://cloud-api.phala.network/api/v1"},r=t.version&&so.includes(t.version)?t.version:so[so.length-1];this.config=t;let{apiKey:o,baseURL:n,timeout:s,headers:i,useCookieAuth:a,onResponseError:l,...u}=t,f={"X-Phala-Version":r,"Content-Type":"application/json"};i&&typeof i=="object"&&Object.entries(i).forEach(([p,d])=>{typeof d=="string"&&(f[p]=d)}),!a&&o&&(f["X-API-Key"]=o),this.fetchInstance=ac.create({baseURL:n,timeout:s||3e4,headers:f,...a?{credentials:"include"}:{},...u,onRequest({request:p,options:d}){if(st.enabled){let h=d.method||"GET",I=typeof p=="string"?p:p.url,k=I.startsWith("http")?I:`${n}${I}`,P={};d.headers&&typeof d.headers=="object"&&Object.entries(d.headers).forEach(([K,O])=>{typeof O=="string"&&(P[K]=O)});let V=[`> curl -X ${h} "${k}"`,yc(P),d.body?vc(d.body):""].filter(Boolean).join(`
|
|
16
|
+
`);st(`
|
|
17
17
|
=== REQUEST ===
|
|
18
18
|
%s
|
|
19
|
-
`,
|
|
19
|
+
`,V)}},onResponse({request:p,response:d,options:h}){if(st.enabled){let I=h.method||"GET",k=typeof p=="string"?p:p.url;st(`
|
|
20
20
|
=== RESPONSE [%s %s] (%dms) ===
|
|
21
21
|
%s
|
|
22
|
-
`,I,k,d.headers.get("x-response-time")||"?",Cs(d.status,d.statusText,d.headers,d._data))}},onResponseError:({request:p,response:d,options:h})=>{if(console.warn(`HTTP ${d.status}: ${d.url}`),
|
|
22
|
+
`,I,k,d.headers.get("x-response-time")||"?",Cs(d.status,d.statusText,d.headers,d._data))}},onResponseError:({request:p,response:d,options:h})=>{if(console.warn(`HTTP ${d.status}: ${d.url}`),st.enabled){let I=h.method||"GET",k=typeof p=="string"?p:p.url;st(`
|
|
23
23
|
=== ERROR RESPONSE [%s %s] ===
|
|
24
24
|
%s
|
|
25
|
-
`,I,k,Cs(d.status,d.statusText,d.headers,d._data))}l&&l({request:p,response:d,options:h})}})}get raw(){return this.fetchInstance}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}once(e,t){let r=o=>{t(o),this.emitter.off(e,r)};this.emitter.on(e,r)}async get(e,t){try{return await this.fetchInstance(e,{...t,method:"GET"})}catch(r){let o=this.convertToRequestError(r);throw this.emitError(o)}}async post(e,t,r){try{return await this.fetchInstance(e,{...r,method:"POST",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async put(e,t,r){try{return await this.fetchInstance(e,{...r,method:"PUT",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async patch(e,t,r){try{return await this.fetchInstance(e,{...r,method:"PATCH",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async delete(e,t){try{return await this.fetchInstance(e,{...t,method:"DELETE"})}catch(r){let o=this.convertToRequestError(r);throw this.emitError(o)}}convertToRequestError(e){return e&&typeof e=="object"&&"data"in e?oo.fromFetchError(e):e instanceof Error?oo.fromError(e):new oo("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(e){let t=hc(e);return this.emitter.emit("error",t),t}async safeRequest(e){try{return{success:!0,data:await e()}}catch(t){if(t instanceof Me)return{success:!1,error:t};let r=this.convertToRequestError(t);return this.emitError(r),{success:!1,error:r}}}async safeGet(e,t){return this.safeRequest(()=>this.get(e,t))}async safePost(e,t,r){return this.safeRequest(()=>this.post(e,t,r))}async safePut(e,t,r){return this.safeRequest(()=>this.put(e,t,r))}async safePatch(e,t,r){return this.safeRequest(()=>this.patch(e,t,r))}async safeDelete(e,t){return this.safeRequest(()=>this.delete(e,t))}extend(e){let t=typeof e=="function"?e(this):e,r=Object.create(this);for(let[o,n]of Object.entries(t))typeof n=="function"&&(r[o]=(...s)=>n(this,...s));return r}};function vc(e={}){return new wc(e)}function As(e){if(e?.schema!==void 0&&e?.schema!==!1&&(typeof e.schema!="object"||e.schema===null||!("parse"in e.schema)||typeof e.schema.parse!="function"))throw new Error("Invalid schema: must be a Zod schema object, false, or undefined")}function Ps(e){if(e?.schema!==void 0&&e?.schema!==!1&&(typeof e.schema!="object"||e.schema===null||!("parse"in e.schema)||typeof e.schema.parse!="function"))return{success:!1,error:{name:"ZodError",message:"Invalid schema: must be a Zod schema object, false, or undefined",issues:[{code:"invalid_type",expected:"object",received:typeof e.schema,path:["schema"],message:"Invalid schema: must be a Zod schema object, false, or undefined"}]}}}function Bs(e,t){function r(i,a){return o(i,a)}async function o(i,a){As(a);let l=await t(i);return a?.schema===!1?l:(a?.schema||e).parse(l)}function n(i,a){return s(i,a)}async function s(i,a){let l=Ps(a);if(l)return l;let u=await(async()=>{try{return{success:!0,data:await t(i)}}catch(p){return p&&typeof p=="object"&&"status"in p?{success:!1,error:p}:p&&typeof p=="object"&&"issues"in p?{success:!1,error:p}:{success:!1,error:{name:"Error",message:p instanceof Error?p.message:String(p)}}}})();return u.success?a?.schema===!1?{success:!0,data:u.data}:(a?.schema||e).safeParse(u.data):u}return{action:r,safeAction:n}}function S(e,t){function r(i,...a){let[l,u]=a;return o(i,l,u)}async function o(i,a,l){As(l);let u=await t(i,a);return l?.schema===!1?u:(l?.schema||e).parse(u)}function n(i,...a){let[l,u]=a;return s(i,l,u)}async function s(i,a,l){let u=Ps(l);if(u)return u;let f=await(async()=>{try{return{success:!0,data:await t(i,a)}}catch(d){return d&&typeof d=="object"&&"status"in d?{success:!1,error:d}:d&&typeof d=="object"&&"issues"in d?{success:!1,error:d}:{success:!1,error:{name:"Error",message:d instanceof Error?d.message:String(d)}}}})();return f.success?l?.schema===!1?{success:!0,data:f.data}:(l?.schema||e).safeParse(f.data):f}return{action:r,safeAction:n}}var Cc=Be.object({username:Be.string(),email:Be.string(),credits:Be.number(),granted_credits:Be.number(),avatar:Be.string(),team_name:Be.string(),team_tier:Be.string()}).passthrough(),{action:_c,safeAction:kc}=Bs(Cc,async e=>await e.get("/auth/me")),Tc={[fr.id]:fr,[kt.id]:kt,[ur.id]:ur},Ec=Le.object({id:Le.string(),slug:Le.string().nullable(),url:Le.string(),version:Le.string(),chain_id:Le.number().nullable(),kms_contract_address:Le.string().nullable().transform(e=>e),gateway_app_id:Le.string().nullable().transform(e=>e)}).passthrough(),at=Ec.transform(e=>{if(e.chain_id!=null){let t=Tc[e.chain_id];if(t)return{...e,chain:t}}return e}),Sc=v.object({name:v.string(),is_dev:v.boolean(),version:v.union([v.tuple([v.number(),v.number(),v.number()]),v.tuple([v.number(),v.number(),v.number(),v.number()])]),os_image_hash:v.string().nullable().optional()}).passthrough(),Ic=v.object({teepod_id:v.number(),name:v.string(),listed:v.boolean(),resource_score:v.number(),remaining_vcpu:v.number(),remaining_memory:v.number(),remaining_cvm_slots:v.number(),images:v.array(Sc),support_onchain_kms:v.boolean().optional(),fmspc:v.string().nullable().optional(),device_id:v.string().nullable().optional(),region_identifier:v.string().nullable().optional(),default_kms:v.string().nullable().optional(),kms_list:v.array(v.string()).default([])}).passthrough(),Ac=v.object({max_instances:v.number().nullable().optional(),max_vcpu:v.number().nullable().optional(),max_memory:v.number().nullable().optional(),max_disk:v.number().nullable().optional()}).passthrough(),Pc=v.object({tier:v.string(),capacity:Ac,nodes:v.array(Ic),kms_list:v.array(at)}).passthrough(),{action:Bc,safeAction:Lc}=Bs(Pc,async e=>await e.get("/teepods/available")),Ls=$.object({id:$.string(),name:$.string(),description:$.string(),vcpu:$.number(),memory_mb:$.number(),hourly_rate:$.string(),requires_gpu:$.boolean(),default_disk_size_gb:$.number().default(20),family:$.string().nullable()}).passthrough(),$c=$.object({name:$.string(),items:$.array(Ls),total:$.number()}).strict(),Rc=$.object({result:$.array($c)}).strict(),Uc=$.object({items:$.array(Ls),total:$.number(),family:$.string()}).strict(),Fc=$.object({family:$.string()}).strict(),{action:zc,safeAction:Hc}=S(Rc,async e=>await e.get("/instance-types")),{action:Oc,safeAction:jc}=S(Uc,async(e,t)=>{let r=Fc.parse(t);return await e.get(`/instance-types/${r.family}`)}),$s=Z.object({id:Z.string(),name:Z.string(),slug:Z.string().nullable(),tier:Z.string(),role:Z.string(),created_at:Z.string()}).passthrough(),Nc=Z.object({has_more:Z.boolean(),next_cursor:Z.string().nullable(),total:Z.number().nullable()}).passthrough(),Gc=Z.object({data:Z.array($s),pagination:Nc}).passthrough(),{action:Dc,safeAction:Mc}=S(Gc,async(e,t)=>{let r=new URLSearchParams;t?.cursor&&r.append("cursor",t.cursor),t?.limit&&r.append("limit",t.limit.toString());let o=r.toString()?`/workspaces?${r.toString()}`:"/workspaces";return await e.get(o)}),{action:qc,safeAction:Vc}=S($s,async(e,t)=>await e.get(`/workspaces/${t}`)),Kc=m.object({id:m.string(),name:m.string(),status:m.string(),uptime:m.string(),app_url:m.string().nullable(),app_id:m.string(),instance_id:m.string().nullable(),configuration:m.any().optional(),exited_at:m.string().nullable(),boot_progress:m.string().nullable(),boot_error:m.string().nullable(),shutdown_progress:m.string().nullable(),image_version:m.string().nullable()}),Wc=m.object({id:m.number(),username:m.string()}),io=m.object({id:m.number(),name:m.string(),region_identifier:m.string().nullable().optional()}),Rs=m.object({app:m.string(),instance:m.string()}),Xc=m.object({hosted:Kc,name:m.string(),managed_user:Wc.nullable(),node:io.nullable(),listed:m.boolean().default(!1),status:m.string(),in_progress:m.boolean().default(!1),dapp_dashboard_url:m.string().nullable(),syslog_endpoint:m.string().nullable(),allow_upgrade:m.boolean().default(!1),project_id:m.string().nullable(),project_type:m.string().nullable(),billing_period:m.string().nullable(),kms_info:at.nullable(),vcpu:m.number().nullable(),memory:m.number().nullable(),disk_size:m.number().nullable(),gateway_domain:m.string().nullable(),public_urls:m.array(Rs)}),Us=m.object({id:m.number(),name:m.string(),status:m.string(),in_progress:m.boolean().optional().default(!1),teepod_id:m.number().nullable(),teepod:io.optional().nullable(),app_id:m.string(),vm_uuid:m.string().nullable(),instance_id:m.string().nullable(),vcpu:m.number(),memory:m.number(),disk_size:m.number(),base_image:m.string().nullable(),encrypted_env_pubkey:m.string().nullable(),listed:m.boolean().optional().default(!1),project_id:m.string().optional().nullable(),project_type:m.string().optional().nullable(),public_sysinfo:m.boolean().optional().default(!1),public_logs:m.boolean().optional().default(!1),dapp_dashboard_url:m.string().optional().nullable(),syslog_endpoint:m.string().optional().nullable(),kms_info:at.optional().nullable(),contract_address:m.string().optional().nullable(),deployer_address:m.string().optional().nullable(),scheduled_delete_at:m.string().optional().nullable(),public_urls:m.array(Rs).optional().default([]),gateway_domain:m.string().optional().nullable()}),br=m.object({id:m.number(),name:m.string(),status:m.string(),teepod_id:m.number(),teepod:io.optional().nullable(),user_id:m.number().optional().nullable(),app_id:m.string(),vm_uuid:m.string().nullable(),instance_id:m.string().nullable(),app_url:m.string().optional().nullable(),base_image:m.string().nullable(),vcpu:m.number(),memory:m.number(),disk_size:m.number(),manifest_version:m.number().optional().nullable(),version:m.string().optional().nullable(),runner:m.string().optional().nullable(),docker_compose_file:m.string().optional().nullable(),features:m.array(m.string()).optional().nullable(),created_at:m.string(),encrypted_env_pubkey:m.string().nullable()}),Pt=At.object({id:At.string().optional(),uuid:At.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i,"Invalid UUID format").optional(),app_id:At.string().optional(),instance_id:At.string().optional()}),Bt=e=>e.refine(t=>{let r=t;return!!(r.id||r.uuid||r.app_id||r.instance_id)},{message:"One of id, uuid, app_id, or instance_id must be provided"}),Jc=Bt(Pt),O=Jc.transform(e=>{let t;if(e.id)t=e.id;else if(e.uuid)t=e.uuid;else if(e.app_id)t=e.app_id;else if(e.instance_id)t=e.instance_id;else throw new Error("No valid identifier provided");let r=/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i,o=/^[0-9a-f]{40}$/i,n;return r.test(t)?n=t.replace(/-/g,""):o.test(t)?n=`app_${t}`:n=t,{cvmId:n}}),Zc=O,{action:Yc,safeAction:ct}=S(Us,async(e,t)=>{let{cvmId:r}=Zc.parse(t);return await e.get(`/cvms/${r}`)}),Qc=ne.object({page:ne.number().int().min(1).optional(),page_size:ne.number().int().min(1).optional(),node_id:ne.number().int().min(1).optional(),teepod_id:ne.number().int().min(1).optional(),user_id:ne.string().optional()}).strict(),el=ne.object({items:ne.array(Xc),total:ne.number(),page:ne.number(),page_size:ne.number(),pages:ne.number()}).strict(),{action:tl,safeAction:gr}=S(el,async(e,t)=>{let r=Qc.parse(t??{});return await e.get("/cvms/paginated",{params:r})}),rl=w.object({app_id:w.string().nullable().optional(),app_env_encrypt_pubkey:w.string().nullable().optional(),compose_hash:w.string(),fmspc:w.string().nullable().optional(),device_id:w.string().nullable().optional(),os_image_hash:w.string().nullable().optional(),instance_type:w.string().nullable().optional(),teepod_id:w.number().nullable().optional(),node_id:w.number().nullable().optional(),kms_id:w.string().nullable().optional()}).passthrough().transform(e=>{if("teepod_id"in e&&e.teepod_id!==void 0){let{teepod_id:t,...r}=e;return{...r,node_id:t}}return e}),ol=w.object({node_id:w.number().optional(),teepod_id:w.number().optional(),region:w.string().optional(),name:w.string(),instance_type:w.string().default("tdx.small"),image:w.string().optional(),vcpu:w.number().optional(),memory:w.number().optional(),disk_size:w.number().optional(),compose_file:w.object({allowed_envs:w.array(w.string()).optional(),pre_launch_script:w.string().optional(),docker_compose_file:w.string().optional(),name:w.string().optional().default(""),kms_enabled:w.boolean().optional(),public_logs:w.boolean().optional(),public_sysinfo:w.boolean().optional(),gateway_enabled:w.boolean().optional(),tproxy_enabled:w.boolean().optional()}),listed:w.boolean().optional(),kms_id:w.string().optional(),kms:w.enum(["PHALA","ETHEREUM","BASE"]).optional(),kms_contract:w.string().optional(),env_keys:w.array(w.string()).optional(),nonce:w.number().optional(),app_id:w.string().optional()}).passthrough();function nl(e){if(!e.compose_file)return e;let t={...e.compose_file};return typeof t.gateway_enabled=="boolean"&&typeof t.tproxy_enabled=="boolean"?delete t.tproxy_enabled:typeof t.tproxy_enabled=="boolean"&&typeof t.gateway_enabled>"u"&&(t.gateway_enabled=t.tproxy_enabled,delete t.tproxy_enabled,(typeof window<"u"?window.console:globalThis.console)&&console.warn("[phala/cloud] tproxy_enabled is deprecated, please use gateway_enabled instead. See docs for migration.")),{...e,compose_file:t}}var{action:sl,safeAction:il}=S(rl,async(e,t)=>{let r=ol.parse(t),o=nl(r),n={...o};return typeof o.node_id=="number"?(n={...o,teepod_id:o.node_id},delete n.node_id):typeof o.teepod_id=="number"&&console.warn("[phala/cloud] teepod_id is deprecated, please use node_id instead."),await e.post("/cvms/provision",n)}),al=_.object({id:_.number(),name:_.string(),status:_.string(),teepod_id:_.number(),teepod:_.object({id:_.number(),name:_.string()}).nullable(),user_id:_.number().nullable(),app_id:_.string().nullable(),vm_uuid:_.string().nullable(),instance_id:_.string().nullable(),app_url:_.string().nullable(),base_image:_.string().nullable(),vcpu:_.number(),memory:_.number(),disk_size:_.number(),manifest_version:_.number().nullable(),version:_.string().nullable(),runner:_.string().nullable(),docker_compose_file:_.string().nullable(),features:_.array(_.string()).nullable(),created_at:_.string(),encrypted_env_pubkey:_.string().nullable().optional(),app_auth_contract_address:_.string().nullable().optional(),deployer_address:_.string().nullable().optional()}).passthrough(),rx=_.object({encrypted_env:_.string().optional().nullable(),app_id:_.string(),compose_hash:_.string(),kms_id:_.string().optional(),contract_address:_.string().optional(),deployer_address:_.string().optional(),env_keys:_.array(_.string()).optional().nullable()}).passthrough(),{action:cl,safeAction:ll}=S(al,async(e,t)=>await e.post("/cvms",t)),Fs=D.object({allowed_envs:D.array(D.string()).optional(),docker_compose_file:D.string(),features:D.array(D.string()).optional(),name:D.string().optional(),manifest_version:D.number().optional(),kms_enabled:D.boolean().optional(),public_logs:D.boolean().optional(),public_sysinfo:D.boolean().optional(),tproxy_enabled:D.boolean().optional(),pre_launch_script:D.string().optional(),env_pubkey:D.string().optional(),salt:D.string().optional().nullable()}).passthrough();function so(e){return e==null?e:Array.isArray(e)?e.map(so):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=so(o),t},{}):e}function zs(e){let t={...e};return t.runner==="bash"&&"docker_compose_file"in t?delete t.docker_compose_file:t.runner==="docker-compose"&&"bash_script"in t&&delete t.bash_script,"pre_launch_script"in t&&!t.pre_launch_script&&delete t.pre_launch_script,t}function Hs(e){let t=so(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function ul(e){let t=zs(e),r=Hs(t);return pl.createHash("sha256").update(r,"utf8").digest("hex")}function fl(e){let t=e;return{...e,getHash:()=>ul(t),toString:()=>Hs(zs(t))}}var ml=Fs.transform(e=>fl(e)),dl=O,{action:hl,safeAction:ao}=S(ml,async(e,t)=>{let{cvmId:r}=dl.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),xl=he.object({id:he.string().optional(),uuid:he.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),app_id:he.string().refine(e=>!e.startsWith("app_")&&e.length===40,"app_id should be 40 characters without prefix").transform(e=>e.startsWith("app_")?e:`app_${e}`).optional(),instance_id:he.string().refine(e=>!e.startsWith("instance_")&&e.length===40,"instance_id should be 40 characters without prefix").transform(e=>e.startsWith("instance_")?e:`instance_${e}`).optional(),app_compose:Fs,update_env_vars:he.boolean().optional().nullable()}).refine(e=>!!(e.id||e.uuid||e.app_id||e.instance_id),"One of id, uuid, app_id, or instance_id must be provided").transform(e=>({cvmId:e.id||e.uuid||e.app_id||e.instance_id,request:{...e.app_compose,update_env_vars:e.update_env_vars},_raw:e})),bl=he.object({app_id:he.string().nullable(),device_id:he.string().nullable(),compose_hash:he.string(),kms_info:at.nullable().optional()}).passthrough(),{action:gl,safeAction:yl}=S(bl,async(e,t)=>{let r=xl.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),wl=le.object({id:le.string().optional(),uuid:le.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),app_id:le.string().refine(e=>!e.startsWith("app_")&&e.length===40,"app_id should be 40 characters without prefix").transform(e=>e.startsWith("app_")?e:`app_${e}`).optional(),instance_id:le.string().refine(e=>!e.startsWith("instance_")&&e.length===40,"instance_id should be 40 characters without prefix").transform(e=>e.startsWith("instance_")?e:`instance_${e}`).optional(),compose_hash:le.string().min(1,"Compose hash is required"),encrypted_env:le.string().optional(),env_keys:le.array(le.string()).optional(),update_env_vars:le.boolean().optional().nullable()}).refine(e=>!!(e.id||e.uuid||e.app_id||e.instance_id),"One of id, uuid, app_id, or instance_id must be provided").transform(e=>({cvmId:e.id||e.uuid||e.app_id||e.instance_id,compose_hash:e.compose_hash,encrypted_env:e.encrypted_env,env_keys:e.env_keys,update_env_vars:!!e.update_env_vars,_raw:e})),vl=le.any().transform(()=>{}),{action:Cl,safeAction:_l}=S(vl,async(e,t)=>{let r=wl.parse(t);return await e.patch(`/cvms/${r.cvmId}/compose_file`,{compose_hash:r.compose_hash,encrypted_env:r.encrypted_env,env_keys:r.env_keys})}),kl=_s.object({kms_id:_s.string().min(1,"KMS ID is required")}),{action:Tl,safeAction:El}=S(at,async(e,t)=>{let r=kl.parse(t);return await e.get(`/kms/${r.kms_id}`)}),Sl=xe.object({page:xe.number().int().min(1).optional(),page_size:xe.number().int().min(1).optional(),is_onchain:xe.boolean().optional()}).strict(),Il=xe.object({items:xe.array(at),total:xe.number(),page:xe.number(),page_size:xe.number(),pages:xe.number()}).strict(),{action:Al,safeAction:Pl}=S(Il,async(e,t)=>{let r=Sl.parse(t??{});return await e.get("/kms",{params:r})}),Bl=it.object({kms:it.string().min(1,"KMS ID or slug is required"),app_id:it.string().refine(e=>e.length===40||e.startsWith("0x")&&e.length===42,"App ID must be exactly 40 characters or 42 characters with 0x prefix")}).strict(),Ll=it.object({public_key:it.string(),signature:it.string()}).strict(),{action:$l,safeAction:Rl}=S(Ll,async(e,t)=>{let r=Bl.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),Ul=De.object({counts:De.number().int().min(1).max(20).optional().default(1)}).strict(),Fl=De.object({app_ids:De.array(De.object({app_id:De.string(),nonce:De.number().int().min(0)}))}).strict(),{action:zl,safeAction:Hl}=S(Fl,async(e,t)=>{let r=Ul.parse(t??{}),o=new URLSearchParams;return o.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${o.toString()}`)}),Ol=O,{action:jl,safeAction:Nl}=S(br,async(e,t)=>{let{cvmId:r}=Ol.parse(t);return await e.post(`/cvms/${r}/start`)}),Gl=O,{action:Dl,safeAction:Ml}=S(br,async(e,t)=>{let{cvmId:r}=Gl.parse(t);return await e.post(`/cvms/${r}/stop`)}),ql=O,{action:Vl,safeAction:Kl}=S(br,async(e,t)=>{let{cvmId:r}=ql.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),Xl=Bt(Pt.extend({force:Wl.boolean().optional()})),{action:Jl,safeAction:Zl}=S(br,async(e,t)=>{let r=Xl.parse(t),{cvmId:o}=O.parse(r),{force:n=!1}=r;return await e.post(`/cvms/${o}/restart`,{force:n})}),Ql=O,{action:ep,safeAction:tp}=S(Yl.void(),async(e,t)=>{let{cvmId:r}=Ql.parse(t);await e.delete(`/cvms/${r}`)}),rp=E.object({name:E.string(),mount_point:E.string(),total_size:E.number(),free_size:E.number()}),op=E.object({os_name:E.string(),os_version:E.string(),kernel_version:E.string(),cpu_model:E.string(),num_cpus:E.number(),total_memory:E.number(),available_memory:E.number(),used_memory:E.number(),free_memory:E.number(),total_swap:E.number(),used_swap:E.number(),free_swap:E.number(),uptime:E.number(),loadavg_one:E.number(),loadavg_five:E.number(),loadavg_fifteen:E.number(),disks:E.array(rp)}),np=E.object({is_online:E.boolean(),is_public:E.boolean().default(!1),error:E.string().nullable(),sysinfo:op.nullable(),status:E.string().nullable(),in_progress:E.boolean().default(!1),boot_progress:E.string().nullable(),boot_error:E.string().nullable()}),sp=O,{action:ip,safeAction:ap}=S(np,async(e,t)=>{let{cvmId:r}=sp.parse(t);return await e.get(`/cvms/${r}/stats`)}),cp=de.object({app:de.string(),instance:de.string()}),lp=de.object({is_online:de.boolean(),is_public:de.boolean().default(!0),error:de.string().nullable(),internal_ip:de.string().nullable(),latest_handshake:de.string().nullable(),public_urls:de.array(cp).nullable()}),pp=O,{action:up,safeAction:fp}=S(lp,async(e,t)=>{let{cvmId:r}=pp.parse(t);return await e.get(`/cvms/${r}/network`)}),dp=O,{action:hp,safeAction:xp}=S(mp.string(),async(e,t)=>{let{cvmId:r}=dp.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),bp=L.object({id:L.string(),names:L.array(L.string()),image:L.string(),image_id:L.string(),command:L.string().nullable().optional(),created:L.number(),state:L.string(),status:L.string(),log_endpoint:L.string().nullable()}),gp=L.object({is_online:L.boolean(),is_public:L.boolean().default(!0),error:L.string().nullable(),docker_compose_file:L.string().nullable(),manifest_version:L.number().nullable(),version:L.string().nullable(),runner:L.string().nullable(),features:L.array(L.string()).nullable(),containers:L.array(bp).nullable()}),yp=O,{action:wp,safeAction:vp}=S(gp,async(e,t)=>{let{cvmId:r}=yp.parse(t);return await e.get(`/cvms/${r}/composition`)}),Cp=g.object({common_name:g.string().nullable(),organization:g.string().nullable(),country:g.string().nullable(),state:g.string().nullable(),locality:g.string().nullable()}),_p=g.object({common_name:g.string().nullable(),organization:g.string().nullable(),country:g.string().nullable()}),kp=g.object({subject:Cp,issuer:_p,serial_number:g.string(),not_before:g.string(),not_after:g.string(),version:g.string(),fingerprint:g.string(),signature_algorithm:g.string(),sans:g.array(g.string()).nullable(),is_ca:g.boolean(),position_in_chain:g.number().nullable(),quote:g.string().nullable(),app_id:g.string().nullable().optional(),cert_usage:g.string().nullable().optional()}),Tp=g.object({imr:g.number(),event_type:g.number(),digest:g.string(),event:g.string(),event_payload:g.string()}),Ep=g.object({mrtd:g.string(),rootfs_hash:g.string().nullable().optional(),rtmr0:g.string(),rtmr1:g.string(),rtmr2:g.string(),rtmr3:g.string(),event_log:g.array(Tp),app_compose:g.string()}),Sp=g.object({name:g.string().nullable(),is_online:g.boolean(),is_public:g.boolean().default(!0),error:g.string().nullable(),app_certificates:g.array(kp).nullable(),tcb_info:Ep.nullable(),compose_file:g.string().nullable()}),Ip=O,{action:Ap,safeAction:Pp}=S(Sp,async(e,t)=>{let{cvmId:r}=Ip.parse(t);return await e.get(`/cvms/${r}/attestation`)}),Bp=Bt(Pt.extend({vcpu:st.number().optional(),memory:st.number().optional(),disk_size:st.number().optional(),instance_type:st.string().optional(),allow_restart:st.boolean().optional()})),{action:Lp,safeAction:$p}=S(st.void(),async(e,t)=>{let r=Bp.parse(t),{cvmId:o}=O.parse(r),{...n}=r;await e.patch(`/cvms/${o}/resources`,n)}),Rp=Bt(Pt.extend({public_sysinfo:ks.boolean(),public_logs:ks.boolean()})),{action:Up,safeAction:Fp}=S(Us,async(e,t)=>{let r=Rp.parse(t),{cvmId:o}=O.parse(r),{public_sysinfo:n,public_logs:s}=r;return await e.patch(`/cvms/${o}/visibility`,{public_sysinfo:n,public_logs:s})}),Ts=G.object({name:G.string(),os_image_hash:G.string().nullable(),is_current:G.boolean()}),zp=G.object({version:G.union([G.tuple([G.number(),G.number(),G.number(),G.number()]),G.tuple([G.number(),G.number(),G.number()])]),prod:Ts.nullable(),dev:Ts.nullable()}),Hp=G.array(zp),Op=O,{action:jp,safeAction:Np}=S(Hp,async(e,t)=>{let{cvmId:r}=Op.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),Gp=Bt(Pt.extend({os_image_name:Os.string().min(1,"OS image name is required")})),{action:Dp,safeAction:Mp}=S(Os.void(),async(e,t)=>{let r=Gp.parse(t),{cvmId:o}=O.parse(r),{os_image_name:n}=r;await e.patch(`/cvms/${o}/os-image`,{os_image_name:n})}),qp=me.object({id:me.string().optional(),instance_id:me.string().optional(),name:me.string(),status:me.string(),uptime:me.string().optional(),exited_at:me.string().optional(),boot_progress:me.string().optional(),boot_error:me.string().optional(),shutdown_progress:me.string().optional()}),Vp=O,{action:Kp,safeAction:Wp}=S(qp,async(e,t)=>{let{cvmId:r}=Vp.parse(t);return await e.get(`/cvms/${r}/state`)});function js(e={}){let t=vc(e),r={getCurrentUser:_c,safeGetCurrentUser:kc,getAvailableNodes:Bc,safeGetAvailableNodes:Lc,listAllInstanceTypeFamilies:zc,safeListAllInstanceTypeFamilies:Hc,listFamilyInstanceTypes:Oc,safeListFamilyInstanceTypes:jc,listWorkspaces:Dc,safeListWorkspaces:Mc,getWorkspace:qc,safeGetWorkspace:Vc,getCvmInfo:Yc,safeGetCvmInfo:ct,getCvmList:tl,safeGetCvmList:gr,provisionCvm:sl,safeProvisionCvm:il,commitCvmProvision:cl,safeCommitCvmProvision:ll,getCvmComposeFile:hl,safeGetCvmComposeFile:ao,provisionCvmComposeFileUpdate:gl,safeProvisionCvmComposeFileUpdate:yl,commitCvmComposeFileUpdate:Cl,safeCommitCvmComposeFileUpdate:_l,startCvm:jl,safeStartCvm:Nl,stopCvm:Dl,safeStopCvm:Ml,shutdownCvm:Vl,safeShutdownCvm:Kl,restartCvm:Jl,safeRestartCvm:Zl,deleteCvm:ep,safeDeleteCvm:tp,getCvmStats:ip,safeGetCvmStats:ap,getCvmNetwork:up,safeGetCvmNetwork:fp,getCvmDockerCompose:hp,safeGetCvmDockerCompose:xp,getCvmContainersStats:wp,safeGetCvmContainersStats:vp,getCvmAttestation:Ap,safeGetCvmAttestation:Pp,updateCvmResources:Lp,safeUpdateCvmResources:$p,updateCvmVisibility:Up,safeUpdateCvmVisibility:Fp,getAvailableOsImages:jp,safeGetAvailableOsImages:Np,updateOsImage:Dp,safeUpdateOsImage:Mp,getKmsInfo:Tl,safeGetKmsInfo:El,getKmsList:Al,safeGetKmsList:Pl,getAppEnvEncryptPubKey:$l,safeGetAppEnvEncryptPubKey:Rl,nextAppIds:zl,safeNextAppIds:Hl,getCvmState:Kp,safeGetCvmState:Wp};return t.extend(r)}var Xp=R.object({chain:R.unknown().optional(),rpcUrl:R.string().optional(),kmsContractAddress:R.string(),privateKey:R.string().optional(),walletClient:R.unknown().optional(),publicClient:R.unknown().optional(),allowAnyDevice:R.boolean().optional().default(!1),deviceId:R.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),composeHash:R.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),disableUpgrades:R.boolean().optional().default(!1),skipPrerequisiteChecks:R.boolean().optional().default(!1),minBalance:R.string().optional()}).passthrough(),Ex=Xp.refine(e=>{let t=!!e.privateKey,r=!!e.walletClient;return t!==r},{message:"Either 'privateKey' or 'walletClient' must be provided, but not both",path:["privateKey","walletClient"]}).refine(e=>{let t=!!e.publicClient,r=!!e.walletClient,o=!!e.chain;return t&&r?!0:o},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),Sx=R.object({appId:R.string(),appAuthAddress:R.string(),deployer:R.string(),transactionHash:R.string(),blockNumber:R.bigint().optional(),gasUsed:R.bigint().optional()}).passthrough();var Ax=B.object({chain:B.unknown().optional(),rpcUrl:B.string().optional(),appId:B.string(),composeHash:B.string(),privateKey:B.string().optional(),walletClient:B.unknown().optional(),publicClient:B.unknown().optional(),skipPrerequisiteChecks:B.boolean().optional().default(!1),minBalance:B.string().optional(),timeout:B.number().optional().default(12e4),retryOptions:B.unknown().optional(),signal:B.unknown().optional(),onTransactionStateChange:B.function().optional(),onTransactionSubmitted:B.function().optional(),onTransactionConfirmed:B.function().optional()}).passthrough().refine(e=>{let t=!!e.privateKey,r=!!e.walletClient;return t!==r},{message:"Either 'privateKey' or 'walletClient' must be provided, but not both",path:["privateKey","walletClient"]}).refine(e=>{let t=!!e.publicClient,r=!!e.walletClient,o=!!e.chain;return t&&r?!0:o},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),Px=B.object({composeHash:B.string(),appId:B.string(),transactionHash:B.string(),blockNumber:B.bigint().optional(),gasUsed:B.bigint().optional()}).passthrough();var Lx=nt.object({target:nt.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:nt.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:nt.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:nt.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:nt.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});import Ms from"node:crypto";import Gs from"node:fs";import lt from"node:os";import co from"node:path";import M from"chalk";import eu from"ora";var Qp=!1;function pe(){return Qp}function tu(e,t){let r=e.split(/\s+/),o=[],n="";for(let s of r){let i=n.length===0?s:`${n} ${s}`;i.length<=t?n=i:(n.length>0&&o.push(n),n=s)}return n.length>0&&o.push(n),o}function ru(e,t){if(e.length<=t)return[e];let r=[],o=0;for(;o<e.length;)r.push(e.slice(o,o+t)),o+=t;return r}function Ns(e,t){let r=[];for(let o of e.split(`
|
|
26
|
-
`)){if(o.length<=t){r.push(o);continue}if(o.indexOf(" ")===-1){r.push(...
|
|
27
|
-
`))},warn:(e,...t)=>{
|
|
28
|
-
`))},info:(e,...t)=>{
|
|
29
|
-
`))},success:(e,...t)=>{
|
|
30
|
-
`))},debug:(e,...t)=>{
|
|
31
|
-
`))},table:(e,t)=>{if(!
|
|
32
|
-
`)},startSpinner:e=>{if(
|
|
25
|
+
`,I,k,Cs(d.status,d.statusText,d.headers,d._data))}l&&l({request:p,response:d,options:h})}})}get raw(){return this.fetchInstance}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}once(e,t){let r=o=>{t(o),this.emitter.off(e,r)};this.emitter.on(e,r)}async get(e,t){try{return await this.fetchInstance(e,{...t,method:"GET"})}catch(r){let o=this.convertToRequestError(r);throw this.emitError(o)}}async post(e,t,r){try{return await this.fetchInstance(e,{...r,method:"POST",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async put(e,t,r){try{return await this.fetchInstance(e,{...r,method:"PUT",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async patch(e,t,r){try{return await this.fetchInstance(e,{...r,method:"PATCH",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async delete(e,t){try{return await this.fetchInstance(e,{...t,method:"DELETE"})}catch(r){let o=this.convertToRequestError(r);throw this.emitError(o)}}convertToRequestError(e){return e&&typeof e=="object"&&"data"in e?no.fromFetchError(e):e instanceof Error?no.fromError(e):new no("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(e){let t=xc(e);return this.emitter.emit("error",t),t}async safeRequest(e){try{return{success:!0,data:await e()}}catch(t){if(t instanceof Re)return{success:!1,error:t};let r=this.convertToRequestError(t);return this.emitError(r),{success:!1,error:r}}}async safeGet(e,t){return this.safeRequest(()=>this.get(e,t))}async safePost(e,t,r){return this.safeRequest(()=>this.post(e,t,r))}async safePut(e,t,r){return this.safeRequest(()=>this.put(e,t,r))}async safePatch(e,t,r){return this.safeRequest(()=>this.patch(e,t,r))}async safeDelete(e,t){return this.safeRequest(()=>this.delete(e,t))}extend(e){let t=typeof e=="function"?e(this):e,r=Object.create(this);for(let[o,n]of Object.entries(t))typeof n=="function"&&(r[o]=(...s)=>n(this,...s));return r}};function _c(e={}){return new wc(e)}function Ps(e){if(e?.schema!==void 0&&e?.schema!==!1&&(typeof e.schema!="object"||e.schema===null||!("parse"in e.schema)||typeof e.schema.parse!="function"))throw new Error("Invalid schema: must be a Zod schema object, false, or undefined")}function Bs(e){if(e?.schema!==void 0&&e?.schema!==!1&&(typeof e.schema!="object"||e.schema===null||!("parse"in e.schema)||typeof e.schema.parse!="function"))return{success:!1,error:{name:"ZodError",message:"Invalid schema: must be a Zod schema object, false, or undefined",issues:[{code:"invalid_type",expected:"object",received:typeof e.schema,path:["schema"],message:"Invalid schema: must be a Zod schema object, false, or undefined"}]}}}function $s(e,t){function r(i,a){return o(i,a)}async function o(i,a){Ps(a);let l=await t(i);return a?.schema===!1?l:(a?.schema||e).parse(l)}function n(i,a){return s(i,a)}async function s(i,a){let l=Bs(a);if(l)return l;let u=await(async()=>{try{return{success:!0,data:await t(i)}}catch(p){return p&&typeof p=="object"&&"status"in p?{success:!1,error:p}:p&&typeof p=="object"&&"issues"in p?{success:!1,error:p}:{success:!1,error:{name:"Error",message:p instanceof Error?p.message:String(p)}}}})();return u.success?a?.schema===!1?{success:!0,data:u.data}:(a?.schema||e).safeParse(u.data):u}return{action:r,safeAction:n}}function S(e,t){function r(i,...a){let[l,u]=a;return o(i,l,u)}async function o(i,a,l){Ps(l);let u=await t(i,a);return l?.schema===!1?u:(l?.schema||e).parse(u)}function n(i,...a){let[l,u]=a;return s(i,l,u)}async function s(i,a,l){let u=Bs(l);if(u)return u;let f=await(async()=>{try{return{success:!0,data:await t(i,a)}}catch(d){return d&&typeof d=="object"&&"status"in d?{success:!1,error:d}:d&&typeof d=="object"&&"issues"in d?{success:!1,error:d}:{success:!1,error:{name:"Error",message:d instanceof Error?d.message:String(d)}}}})();return f.success?l?.schema===!1?{success:!0,data:f.data}:(l?.schema||e).safeParse(f.data):f}return{action:r,safeAction:n}}var Cc=$e.object({username:$e.string(),email:$e.string(),credits:$e.number(),granted_credits:$e.number(),avatar:$e.string(),team_name:$e.string(),team_tier:$e.string()}).passthrough(),{action:kc,safeAction:Tc}=$s(Cc,async e=>await e.get("/auth/me")),Ec={[mr.id]:mr,[Tt.id]:Tt,[fr.id]:fr},Sc=Le.object({id:Le.string(),slug:Le.string().nullable(),url:Le.string(),version:Le.string(),chain_id:Le.number().nullable(),kms_contract_address:Le.string().nullable().transform(e=>e),gateway_app_id:Le.string().nullable().transform(e=>e)}).passthrough(),Ve=Sc.transform(e=>{if(e.chain_id!=null){let t=Ec[e.chain_id];if(t)return{...e,chain:t}}return e}),Ic=w.object({name:w.string(),is_dev:w.boolean(),version:w.union([w.tuple([w.number(),w.number(),w.number()]),w.tuple([w.number(),w.number(),w.number(),w.number()])]),os_image_hash:w.string().nullable().optional()}).passthrough(),Ac=w.object({teepod_id:w.number(),name:w.string(),listed:w.boolean(),resource_score:w.number(),remaining_vcpu:w.number(),remaining_memory:w.number(),remaining_cvm_slots:w.number(),images:w.array(Ic),support_onchain_kms:w.boolean().optional(),fmspc:w.string().nullable().optional(),device_id:w.string().nullable().optional(),region_identifier:w.string().nullable().optional(),default_kms:w.string().nullable().optional(),kms_list:w.array(w.string()).default([])}).passthrough(),Pc=w.object({max_instances:w.number().nullable().optional(),max_vcpu:w.number().nullable().optional(),max_memory:w.number().nullable().optional(),max_disk:w.number().nullable().optional()}).passthrough(),Bc=w.object({tier:w.string(),capacity:Pc,nodes:w.array(Ac),kms_list:w.array(Ve)}).passthrough(),{action:$c,safeAction:Lc}=$s(Bc,async e=>await e.get("/teepods/available")),Ls=L.object({id:L.string(),name:L.string(),description:L.string(),vcpu:L.number(),memory_mb:L.number(),hourly_rate:L.string(),requires_gpu:L.boolean(),default_disk_size_gb:L.number().default(20),family:L.string().nullable()}).passthrough(),Rc=L.object({name:L.string(),items:L.array(Ls),total:L.number()}).strict(),Uc=L.object({result:L.array(Rc)}).strict(),Fc=L.object({items:L.array(Ls),total:L.number(),family:L.string()}).strict(),zc=L.object({family:L.string()}).strict(),{action:Hc,safeAction:Oc}=S(Uc,async e=>await e.get("/instance-types")),{action:jc,safeAction:Nc}=S(Fc,async(e,t)=>{let r=zc.parse(t);return await e.get(`/instance-types/${r.family}`)}),Rs=Y.object({id:Y.string(),name:Y.string(),slug:Y.string().nullable(),tier:Y.string(),role:Y.string(),created_at:Y.string()}).passthrough(),Gc=Y.object({has_more:Y.boolean(),next_cursor:Y.string().nullable(),total:Y.number().nullable()}).passthrough(),Dc=Y.object({data:Y.array(Rs),pagination:Gc}).passthrough(),{action:Mc,safeAction:qc}=S(Dc,async(e,t)=>{let r=new URLSearchParams;t?.cursor&&r.append("cursor",t.cursor),t?.limit&&r.append("limit",t.limit.toString());let o=r.toString()?`/workspaces?${r.toString()}`:"/workspaces";return await e.get(o)}),{action:Vc,safeAction:Kc}=S(Rs,async(e,t)=>await e.get(`/workspaces/${t}`)),Wc=m.object({id:m.string(),name:m.string(),status:m.string(),uptime:m.string(),app_url:m.string().nullable(),app_id:m.string(),instance_id:m.string().nullable(),configuration:m.any().optional(),exited_at:m.string().nullable(),boot_progress:m.string().nullable(),boot_error:m.string().nullable(),shutdown_progress:m.string().nullable(),image_version:m.string().nullable()}),Xc=m.object({id:m.number(),username:m.string()}),ao=m.object({id:m.number(),name:m.string(),region_identifier:m.string().nullable().optional()}),Us=m.object({app:m.string(),instance:m.string()}),Jc=m.object({hosted:Wc,name:m.string(),managed_user:Xc.nullable(),node:ao.nullable(),listed:m.boolean().default(!1),status:m.string(),in_progress:m.boolean().default(!1),dapp_dashboard_url:m.string().nullable(),syslog_endpoint:m.string().nullable(),allow_upgrade:m.boolean().default(!1),project_id:m.string().nullable(),project_type:m.string().nullable(),billing_period:m.string().nullable(),kms_info:Ve.nullable(),vcpu:m.number().nullable(),memory:m.number().nullable(),disk_size:m.number().nullable(),gateway_domain:m.string().nullable(),public_urls:m.array(Us)}),Fs=m.object({id:m.number(),name:m.string(),status:m.string(),in_progress:m.boolean().optional().default(!1),teepod_id:m.number().nullable(),teepod:ao.optional().nullable(),app_id:m.string(),vm_uuid:m.string().nullable(),instance_id:m.string().nullable(),vcpu:m.number(),memory:m.number(),disk_size:m.number(),base_image:m.string().nullable(),encrypted_env_pubkey:m.string().nullable(),listed:m.boolean().optional().default(!1),project_id:m.string().optional().nullable(),project_type:m.string().optional().nullable(),public_sysinfo:m.boolean().optional().default(!1),public_logs:m.boolean().optional().default(!1),dapp_dashboard_url:m.string().optional().nullable(),syslog_endpoint:m.string().optional().nullable(),kms_info:Ve.optional().nullable(),contract_address:m.string().optional().nullable(),deployer_address:m.string().optional().nullable(),scheduled_delete_at:m.string().optional().nullable(),public_urls:m.array(Us).optional().default([]),gateway_domain:m.string().optional().nullable()}),br=m.object({id:m.number(),name:m.string(),status:m.string(),teepod_id:m.number(),teepod:ao.optional().nullable(),user_id:m.number().optional().nullable(),app_id:m.string(),vm_uuid:m.string().nullable(),instance_id:m.string().nullable(),app_url:m.string().optional().nullable(),base_image:m.string().nullable(),vcpu:m.number(),memory:m.number(),disk_size:m.number(),manifest_version:m.number().optional().nullable(),version:m.string().optional().nullable(),runner:m.string().optional().nullable(),docker_compose_file:m.string().optional().nullable(),features:m.array(m.string()).optional().nullable(),created_at:m.string(),encrypted_env_pubkey:m.string().nullable()}),Bt=Pt.object({id:Pt.string().optional(),uuid:Pt.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i,"Invalid UUID format").optional(),app_id:Pt.string().optional(),instance_id:Pt.string().optional()}),$t=e=>e.refine(t=>{let r=t;return!!(r.id||r.uuid||r.app_id||r.instance_id)},{message:"One of id, uuid, app_id, or instance_id must be provided"}),Zc=$t(Bt),j=Zc.transform(e=>{let t;if(e.id)t=e.id;else if(e.uuid)t=e.uuid;else if(e.app_id)t=e.app_id;else if(e.instance_id)t=e.instance_id;else throw new Error("No valid identifier provided");let r=/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i,o=/^[0-9a-f]{40}$/i,n;return r.test(t)?n=t.replace(/-/g,""):o.test(t)?n=`app_${t}`:n=t,{cvmId:n}}),Yc=j,{action:Qc,safeAction:lt}=S(Fs,async(e,t)=>{let{cvmId:r}=Yc.parse(t);return await e.get(`/cvms/${r}`)}),el=se.object({page:se.number().int().min(1).optional(),page_size:se.number().int().min(1).optional(),node_id:se.number().int().min(1).optional(),teepod_id:se.number().int().min(1).optional(),user_id:se.string().optional()}).strict(),tl=se.object({items:se.array(Jc),total:se.number(),page:se.number(),page_size:se.number(),pages:se.number()}).strict(),{action:rl,safeAction:yr}=S(tl,async(e,t)=>{let r=el.parse(t??{});return await e.get("/cvms/paginated",{params:r})}),ol=v.object({app_id:v.string().nullable().optional(),app_env_encrypt_pubkey:v.string().nullable().optional(),compose_hash:v.string(),fmspc:v.string().nullable().optional(),device_id:v.string().nullable().optional(),os_image_hash:v.string().nullable().optional(),instance_type:v.string().nullable().optional(),teepod_id:v.number().nullable().optional(),node_id:v.number().nullable().optional(),kms_id:v.string().nullable().optional()}).passthrough().transform(e=>{if("teepod_id"in e&&e.teepod_id!==void 0){let{teepod_id:t,...r}=e;return{...r,node_id:t}}return e}),nl=v.object({node_id:v.number().optional(),teepod_id:v.number().optional(),region:v.string().optional(),name:v.string(),instance_type:v.string().default("tdx.small"),image:v.string().optional(),vcpu:v.number().optional(),memory:v.number().optional(),disk_size:v.number().optional(),compose_file:v.object({allowed_envs:v.array(v.string()).optional(),pre_launch_script:v.string().optional(),docker_compose_file:v.string().optional(),name:v.string().optional().default(""),kms_enabled:v.boolean().optional(),public_logs:v.boolean().optional(),public_sysinfo:v.boolean().optional(),gateway_enabled:v.boolean().optional(),tproxy_enabled:v.boolean().optional()}),listed:v.boolean().optional(),kms_id:v.string().optional(),kms:v.enum(["PHALA","ETHEREUM","BASE"]).optional(),kms_contract:v.string().optional(),env_keys:v.array(v.string()).optional(),nonce:v.number().optional(),app_id:v.string().optional()}).passthrough();function sl(e){if(!e.compose_file)return e;let t={...e.compose_file};return typeof t.gateway_enabled=="boolean"&&typeof t.tproxy_enabled=="boolean"?delete t.tproxy_enabled:typeof t.tproxy_enabled=="boolean"&&typeof t.gateway_enabled>"u"&&(t.gateway_enabled=t.tproxy_enabled,delete t.tproxy_enabled,(typeof window<"u"?window.console:globalThis.console)&&console.warn("[phala/cloud] tproxy_enabled is deprecated, please use gateway_enabled instead. See docs for migration.")),{...e,compose_file:t}}var{action:il,safeAction:al}=S(ol,async(e,t)=>{let r=nl.parse(t),o=sl(r),n={...o};return typeof o.node_id=="number"?(n={...o,teepod_id:o.node_id},delete n.node_id):typeof o.teepod_id=="number"&&console.warn("[phala/cloud] teepod_id is deprecated, please use node_id instead."),await e.post("/cvms/provision",n)}),cl=C.object({id:C.number(),name:C.string(),status:C.string(),teepod_id:C.number(),teepod:C.object({id:C.number(),name:C.string()}).nullable(),user_id:C.number().nullable(),app_id:C.string().nullable(),vm_uuid:C.string().nullable(),instance_id:C.string().nullable(),app_url:C.string().nullable(),base_image:C.string().nullable(),vcpu:C.number(),memory:C.number(),disk_size:C.number(),manifest_version:C.number().nullable(),version:C.string().nullable(),runner:C.string().nullable(),docker_compose_file:C.string().nullable(),features:C.array(C.string()).nullable(),created_at:C.string(),encrypted_env_pubkey:C.string().nullable().optional(),app_auth_contract_address:C.string().nullable().optional(),deployer_address:C.string().nullable().optional()}).passthrough(),lx=C.object({encrypted_env:C.string().optional().nullable(),app_id:C.string(),compose_hash:C.string(),kms_id:C.string().optional(),contract_address:C.string().optional(),deployer_address:C.string().optional(),env_keys:C.array(C.string()).optional().nullable()}).passthrough(),{action:ll,safeAction:pl}=S(cl,async(e,t)=>await e.post("/cvms",t)),zs=M.object({allowed_envs:M.array(M.string()).optional(),docker_compose_file:M.string(),features:M.array(M.string()).optional(),name:M.string().optional(),manifest_version:M.number().optional(),kms_enabled:M.boolean().optional(),public_logs:M.boolean().optional(),public_sysinfo:M.boolean().optional(),tproxy_enabled:M.boolean().optional(),pre_launch_script:M.string().optional(),env_pubkey:M.string().optional(),salt:M.string().optional().nullable()}).passthrough();function io(e){return e==null?e:Array.isArray(e)?e.map(io):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=io(o),t},{}):e}function Hs(e){let t={...e};return t.runner==="bash"&&"docker_compose_file"in t?delete t.docker_compose_file:t.runner==="docker-compose"&&"bash_script"in t&&delete t.bash_script,"pre_launch_script"in t&&!t.pre_launch_script&&delete t.pre_launch_script,t}function Os(e){let t=io(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function fl(e){let t=Hs(e),r=Os(t);return ul.createHash("sha256").update(r,"utf8").digest("hex")}function ml(e){let t=e;return{...e,getHash:()=>fl(t),toString:()=>Os(Hs(t))}}var dl=zs.transform(e=>ml(e)),hl=j,{action:xl,safeAction:co}=S(dl,async(e,t)=>{let{cvmId:r}=hl.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),gl=xe.object({id:xe.string().optional(),uuid:xe.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),app_id:xe.string().refine(e=>!e.startsWith("app_")&&e.length===40,"app_id should be 40 characters without prefix").transform(e=>e.startsWith("app_")?e:`app_${e}`).optional(),instance_id:xe.string().refine(e=>!e.startsWith("instance_")&&e.length===40,"instance_id should be 40 characters without prefix").transform(e=>e.startsWith("instance_")?e:`instance_${e}`).optional(),app_compose:zs,update_env_vars:xe.boolean().optional().nullable()}).refine(e=>!!(e.id||e.uuid||e.app_id||e.instance_id),"One of id, uuid, app_id, or instance_id must be provided").transform(e=>({cvmId:e.id||e.uuid||e.app_id||e.instance_id,request:{...e.app_compose,update_env_vars:e.update_env_vars},_raw:e})),bl=xe.object({app_id:xe.string().nullable(),device_id:xe.string().nullable(),compose_hash:xe.string(),kms_info:Ve.nullable().optional()}).passthrough(),{action:yl,safeAction:vl}=S(bl,async(e,t)=>{let r=gl.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),wl=pe.object({id:pe.string().optional(),uuid:pe.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),app_id:pe.string().refine(e=>!e.startsWith("app_")&&e.length===40,"app_id should be 40 characters without prefix").transform(e=>e.startsWith("app_")?e:`app_${e}`).optional(),instance_id:pe.string().refine(e=>!e.startsWith("instance_")&&e.length===40,"instance_id should be 40 characters without prefix").transform(e=>e.startsWith("instance_")?e:`instance_${e}`).optional(),compose_hash:pe.string().min(1,"Compose hash is required"),encrypted_env:pe.string().optional(),env_keys:pe.array(pe.string()).optional(),update_env_vars:pe.boolean().optional().nullable()}).refine(e=>!!(e.id||e.uuid||e.app_id||e.instance_id),"One of id, uuid, app_id, or instance_id must be provided").transform(e=>({cvmId:e.id||e.uuid||e.app_id||e.instance_id,compose_hash:e.compose_hash,encrypted_env:e.encrypted_env,env_keys:e.env_keys,update_env_vars:!!e.update_env_vars,_raw:e})),_l=pe.any().transform(()=>{}),{action:Cl,safeAction:kl}=S(_l,async(e,t)=>{let r=wl.parse(t);return await e.patch(`/cvms/${r.cvmId}/compose_file`,{compose_hash:r.compose_hash,encrypted_env:r.encrypted_env,env_keys:r.env_keys})}),Tl=R.object({id:R.string().optional(),uuid:R.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),app_id:R.string().refine(e=>!e.startsWith("app_")&&e.length===40,"app_id should be 40 characters without prefix").transform(e=>e.startsWith("app_")?e:`app_${e}`).optional(),instance_id:R.string().refine(e=>!e.startsWith("instance_")&&e.length===40,"instance_id should be 40 characters without prefix").transform(e=>e.startsWith("instance_")?e:`instance_${e}`).optional(),encrypted_env:R.string().describe("Encrypted environment variables (hex string)"),env_keys:R.array(R.string()).optional().describe("List of allowed environment variable keys"),compose_hash:R.string().optional().describe("Compose hash for verification (Phase 2, required when env_keys changes)"),transaction_hash:R.string().optional().describe("On-chain transaction hash for verification (Phase 2, required when env_keys changes)")}).refine(e=>!!(e.id||e.uuid||e.app_id||e.instance_id),"One of id, uuid, app_id, or instance_id must be provided").transform(e=>({cvmId:e.id||e.uuid||e.app_id||e.instance_id,request:{encrypted_env:e.encrypted_env,env_keys:e.env_keys,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e})),El=R.object({status:R.literal("in_progress"),message:R.string(),correlation_id:R.string(),allowed_envs_changed:R.boolean()}),Sl=R.object({status:R.literal("precondition_required"),message:R.string(),compose_hash:R.string(),app_id:R.string(),device_id:R.string(),kms_info:Ve}),Il=R.union([El,Sl]),{action:Al,safeAction:Pl}=S(Il,async(e,t)=>{let r=Tl.parse(t);try{return await e.patch(`/cvms/${r.cvmId}/envs`,r.request)}catch(o){if(o instanceof Re&&o.status===428){let n=o.detail;if(n&&typeof n=="object"){let s=n;return{status:"precondition_required",message:s.message||"Compose hash verification required",compose_hash:s.compose_hash,app_id:s.app_id,device_id:s.device_id,kms_info:s.kms_info}}}throw o}}),Bl=ks.object({kms_id:ks.string().min(1,"KMS ID is required")}),{action:$l,safeAction:Ll}=S(Ve,async(e,t)=>{let r=Bl.parse(t);return await e.get(`/kms/${r.kms_id}`)}),Rl=ge.object({page:ge.number().int().min(1).optional(),page_size:ge.number().int().min(1).optional(),is_onchain:ge.boolean().optional()}).strict(),Ul=ge.object({items:ge.array(Ve),total:ge.number(),page:ge.number(),page_size:ge.number(),pages:ge.number()}).strict(),{action:Fl,safeAction:zl}=S(Ul,async(e,t)=>{let r=Rl.parse(t??{});return await e.get("/kms",{params:r})}),Hl=ct.object({kms:ct.string().min(1,"KMS ID or slug is required"),app_id:ct.string().refine(e=>e.length===40||e.startsWith("0x")&&e.length===42,"App ID must be exactly 40 characters or 42 characters with 0x prefix")}).strict(),Ol=ct.object({public_key:ct.string(),signature:ct.string()}).strict(),{action:jl,safeAction:Nl}=S(Ol,async(e,t)=>{let r=Hl.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),Gl=qe.object({counts:qe.number().int().min(1).max(20).optional().default(1)}).strict(),Dl=qe.object({app_ids:qe.array(qe.object({app_id:qe.string(),nonce:qe.number().int().min(0)}))}).strict(),{action:Ml,safeAction:ql}=S(Dl,async(e,t)=>{let r=Gl.parse(t??{}),o=new URLSearchParams;return o.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${o.toString()}`)}),Vl=j,{action:Kl,safeAction:Wl}=S(br,async(e,t)=>{let{cvmId:r}=Vl.parse(t);return await e.post(`/cvms/${r}/start`)}),Xl=j,{action:Jl,safeAction:Zl}=S(br,async(e,t)=>{let{cvmId:r}=Xl.parse(t);return await e.post(`/cvms/${r}/stop`)}),Yl=j,{action:Ql,safeAction:ep}=S(br,async(e,t)=>{let{cvmId:r}=Yl.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),rp=$t(Bt.extend({force:tp.boolean().optional()})),{action:op,safeAction:np}=S(br,async(e,t)=>{let r=rp.parse(t),{cvmId:o}=j.parse(r),{force:n=!1}=r;return await e.post(`/cvms/${o}/restart`,{force:n})}),ip=j,{action:ap,safeAction:cp}=S(sp.void(),async(e,t)=>{let{cvmId:r}=ip.parse(t);await e.delete(`/cvms/${r}`)}),lp=E.object({name:E.string(),mount_point:E.string(),total_size:E.number(),free_size:E.number()}),pp=E.object({os_name:E.string(),os_version:E.string(),kernel_version:E.string(),cpu_model:E.string(),num_cpus:E.number(),total_memory:E.number(),available_memory:E.number(),used_memory:E.number(),free_memory:E.number(),total_swap:E.number(),used_swap:E.number(),free_swap:E.number(),uptime:E.number(),loadavg_one:E.number(),loadavg_five:E.number(),loadavg_fifteen:E.number(),disks:E.array(lp)}),up=E.object({is_online:E.boolean(),is_public:E.boolean().default(!1),error:E.string().nullable(),sysinfo:pp.nullable(),status:E.string().nullable(),in_progress:E.boolean().default(!1),boot_progress:E.string().nullable(),boot_error:E.string().nullable()}),fp=j,{action:mp,safeAction:dp}=S(up,async(e,t)=>{let{cvmId:r}=fp.parse(t);return await e.get(`/cvms/${r}/stats`)}),hp=he.object({app:he.string(),instance:he.string()}),xp=he.object({is_online:he.boolean(),is_public:he.boolean().default(!0),error:he.string().nullable(),internal_ip:he.string().nullable(),latest_handshake:he.string().nullable(),public_urls:he.array(hp).nullable()}),gp=j,{action:bp,safeAction:yp}=S(xp,async(e,t)=>{let{cvmId:r}=gp.parse(t);return await e.get(`/cvms/${r}/network`)}),wp=j,{action:_p,safeAction:Cp}=S(vp.string(),async(e,t)=>{let{cvmId:r}=wp.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),kp=$.object({id:$.string(),names:$.array($.string()),image:$.string(),image_id:$.string(),command:$.string().nullable().optional(),created:$.number(),state:$.string(),status:$.string(),log_endpoint:$.string().nullable()}),Tp=$.object({is_online:$.boolean(),is_public:$.boolean().default(!0),error:$.string().nullable(),docker_compose_file:$.string().nullable(),manifest_version:$.number().nullable(),version:$.string().nullable(),runner:$.string().nullable(),features:$.array($.string()).nullable(),containers:$.array(kp).nullable()}),Ep=j,{action:Sp,safeAction:Ip}=S(Tp,async(e,t)=>{let{cvmId:r}=Ep.parse(t);return await e.get(`/cvms/${r}/composition`)}),Ap=b.object({common_name:b.string().nullable(),organization:b.string().nullable(),country:b.string().nullable(),state:b.string().nullable(),locality:b.string().nullable()}),Pp=b.object({common_name:b.string().nullable(),organization:b.string().nullable(),country:b.string().nullable()}),Bp=b.object({subject:Ap,issuer:Pp,serial_number:b.string(),not_before:b.string(),not_after:b.string(),version:b.string(),fingerprint:b.string(),signature_algorithm:b.string(),sans:b.array(b.string()).nullable(),is_ca:b.boolean(),position_in_chain:b.number().nullable(),quote:b.string().nullable(),app_id:b.string().nullable().optional(),cert_usage:b.string().nullable().optional()}),$p=b.object({imr:b.number(),event_type:b.number(),digest:b.string(),event:b.string(),event_payload:b.string()}),Lp=b.object({mrtd:b.string(),rootfs_hash:b.string().nullable().optional(),rtmr0:b.string(),rtmr1:b.string(),rtmr2:b.string(),rtmr3:b.string(),event_log:b.array($p),app_compose:b.string()}),Rp=b.object({name:b.string().nullable(),is_online:b.boolean(),is_public:b.boolean().default(!0),error:b.string().nullable(),app_certificates:b.array(Bp).nullable(),tcb_info:Lp.nullable(),compose_file:b.string().nullable()}),Up=j,{action:Fp,safeAction:zp}=S(Rp,async(e,t)=>{let{cvmId:r}=Up.parse(t);return await e.get(`/cvms/${r}/attestation`)}),Hp=$t(Bt.extend({vcpu:at.number().optional(),memory:at.number().optional(),disk_size:at.number().optional(),instance_type:at.string().optional(),allow_restart:at.boolean().optional()})),{action:Op,safeAction:jp}=S(at.void(),async(e,t)=>{let r=Hp.parse(t),{cvmId:o}=j.parse(r),{...n}=r;await e.patch(`/cvms/${o}/resources`,n)}),Np=$t(Bt.extend({public_sysinfo:Ts.boolean(),public_logs:Ts.boolean()})),{action:Gp,safeAction:Dp}=S(Fs,async(e,t)=>{let r=Np.parse(t),{cvmId:o}=j.parse(r),{public_sysinfo:n,public_logs:s}=r;return await e.patch(`/cvms/${o}/visibility`,{public_sysinfo:n,public_logs:s})}),Es=D.object({name:D.string(),os_image_hash:D.string().nullable(),is_current:D.boolean()}),Mp=D.object({version:D.union([D.tuple([D.number(),D.number(),D.number(),D.number()]),D.tuple([D.number(),D.number(),D.number()])]),prod:Es.nullable(),dev:Es.nullable()}),qp=D.array(Mp),Vp=j,{action:Kp,safeAction:Wp}=S(qp,async(e,t)=>{let{cvmId:r}=Vp.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),Xp=$t(Bt.extend({os_image_name:js.string().min(1,"OS image name is required")})),{action:Jp,safeAction:Zp}=S(js.void(),async(e,t)=>{let r=Xp.parse(t),{cvmId:o}=j.parse(r),{os_image_name:n}=r;await e.patch(`/cvms/${o}/os-image`,{os_image_name:n})}),Yp=de.object({id:de.string().optional(),instance_id:de.string().optional(),name:de.string(),status:de.string(),uptime:de.string().optional(),exited_at:de.string().optional(),boot_progress:de.string().optional(),boot_error:de.string().optional(),shutdown_progress:de.string().optional()}),Qp=j,{action:eu,safeAction:tu}=S(Yp,async(e,t)=>{let{cvmId:r}=Qp.parse(t);return await e.get(`/cvms/${r}/state`)});function Ns(e={}){let t=_c(e),r={getCurrentUser:kc,safeGetCurrentUser:Tc,getAvailableNodes:$c,safeGetAvailableNodes:Lc,listAllInstanceTypeFamilies:Hc,safeListAllInstanceTypeFamilies:Oc,listFamilyInstanceTypes:jc,safeListFamilyInstanceTypes:Nc,listWorkspaces:Mc,safeListWorkspaces:qc,getWorkspace:Vc,safeGetWorkspace:Kc,getCvmInfo:Qc,safeGetCvmInfo:lt,getCvmList:rl,safeGetCvmList:yr,provisionCvm:il,safeProvisionCvm:al,commitCvmProvision:ll,safeCommitCvmProvision:pl,getCvmComposeFile:xl,safeGetCvmComposeFile:co,provisionCvmComposeFileUpdate:yl,safeProvisionCvmComposeFileUpdate:vl,commitCvmComposeFileUpdate:Cl,safeCommitCvmComposeFileUpdate:kl,updateCvmEnvs:Al,safeUpdateCvmEnvs:Pl,startCvm:Kl,safeStartCvm:Wl,stopCvm:Jl,safeStopCvm:Zl,shutdownCvm:Ql,safeShutdownCvm:ep,restartCvm:op,safeRestartCvm:np,deleteCvm:ap,safeDeleteCvm:cp,getCvmStats:mp,safeGetCvmStats:dp,getCvmNetwork:bp,safeGetCvmNetwork:yp,getCvmDockerCompose:_p,safeGetCvmDockerCompose:Cp,getCvmContainersStats:Sp,safeGetCvmContainersStats:Ip,getCvmAttestation:Fp,safeGetCvmAttestation:zp,updateCvmResources:Op,safeUpdateCvmResources:jp,updateCvmVisibility:Gp,safeUpdateCvmVisibility:Dp,getAvailableOsImages:Kp,safeGetAvailableOsImages:Wp,updateOsImage:Jp,safeUpdateOsImage:Zp,getKmsInfo:$l,safeGetKmsInfo:Ll,getKmsList:Fl,safeGetKmsList:zl,getAppEnvEncryptPubKey:jl,safeGetAppEnvEncryptPubKey:Nl,nextAppIds:Ml,safeNextAppIds:ql,getCvmState:eu,safeGetCvmState:tu};return t.extend(r)}var ru=U.object({chain:U.unknown().optional(),rpcUrl:U.string().optional(),kmsContractAddress:U.string(),privateKey:U.string().optional(),walletClient:U.unknown().optional(),publicClient:U.unknown().optional(),allowAnyDevice:U.boolean().optional().default(!1),deviceId:U.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),composeHash:U.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),disableUpgrades:U.boolean().optional().default(!1),skipPrerequisiteChecks:U.boolean().optional().default(!1),minBalance:U.string().optional()}).passthrough(),Rx=ru.refine(e=>{let t=!!e.privateKey,r=!!e.walletClient;return t!==r},{message:"Either 'privateKey' or 'walletClient' must be provided, but not both",path:["privateKey","walletClient"]}).refine(e=>{let t=!!e.publicClient,r=!!e.walletClient,o=!!e.chain;return t&&r?!0:o},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),Ux=U.object({appId:U.string(),appAuthAddress:U.string(),deployer:U.string(),transactionHash:U.string(),blockNumber:U.bigint().optional(),gasUsed:U.bigint().optional()}).passthrough();var zx=B.object({chain:B.unknown().optional(),rpcUrl:B.string().optional(),appId:B.string(),composeHash:B.string(),privateKey:B.string().optional(),walletClient:B.unknown().optional(),publicClient:B.unknown().optional(),skipPrerequisiteChecks:B.boolean().optional().default(!1),minBalance:B.string().optional(),timeout:B.number().optional().default(12e4),retryOptions:B.unknown().optional(),signal:B.unknown().optional(),onTransactionStateChange:B.function().optional(),onTransactionSubmitted:B.function().optional(),onTransactionConfirmed:B.function().optional()}).passthrough().refine(e=>{let t=!!e.privateKey,r=!!e.walletClient;return t!==r},{message:"Either 'privateKey' or 'walletClient' must be provided, but not both",path:["privateKey","walletClient"]}).refine(e=>{let t=!!e.publicClient,r=!!e.walletClient,o=!!e.chain;return t&&r?!0:o},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),Hx=B.object({composeHash:B.string(),appId:B.string(),transactionHash:B.string(),blockNumber:B.bigint().optional(),gasUsed:B.bigint().optional()}).passthrough();var jx=it.object({target:it.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:it.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:it.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:it.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:it.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});import qs from"node:crypto";import Ds from"node:fs";import pt from"node:os";import lo from"node:path";import q from"chalk";import au from"ora";var iu=!1;function ue(){return iu}function cu(e,t){let r=e.split(/\s+/),o=[],n="";for(let s of r){let i=n.length===0?s:`${n} ${s}`;i.length<=t?n=i:(n.length>0&&o.push(n),n=s)}return n.length>0&&o.push(n),o}function lu(e,t){if(e.length<=t)return[e];let r=[],o=0;for(;o<e.length;)r.push(e.slice(o,o+t)),o+=t;return r}function Gs(e,t){let r=[];for(let o of e.split(`
|
|
26
|
+
`)){if(o.length<=t){r.push(o);continue}if(o.indexOf(" ")===-1){r.push(...lu(o,t));continue}let n=cu(o,t);r.push(...n)}if(r.length===0){let o=e.trim();r.push(o)}return r}var Ce={error:(e,...t)=>{ue()||(process.stderr.write(`${q.red("\u2717")} ${q.red(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
27
|
+
`))},warn:(e,...t)=>{ue()||(process.stderr.write(`${q.yellow("\u26A0")} ${q.yellow(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
28
|
+
`))},info:(e,...t)=>{ue()||(process.stderr.write(`${q.blue("\u2139")} ${q.blue(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
29
|
+
`))},success:(e,...t)=>{ue()||(process.stderr.write(`${q.green("\u2713")} ${q.green(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
30
|
+
`))},debug:(e,...t)=>{ue()||process.env.DEBUG&&(process.stderr.write(`${q.gray("\u{1F50D}")} ${q.gray(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
31
|
+
`))},table:(e,t)=>{if(!ue()){if(e.length===0){console.log(q.yellow("No data to display"));return}if(t){let r;typeof t[0]=="string"?r=t.map(i=>({key:i,header:i})):r=t;let o={};for(let i of r){let a=i.header||String(i.key);o[String(i.key)]=a.length}for(let i of e)for(let a of r){let l=String(typeof a.key=="string"&&!(a.key in i)?"":i[String(a.key)]??"");o[String(a.key)]=Math.max(o[String(a.key)],l.length)}let n=[];for(let i of r){let a=i.header||String(i.key);n.push(q.bold(a.padEnd(o[String(i.key)])))}console.log(n.join(" "));let s=[];for(let i of r)s.push("-".repeat(o[String(i.key)]));console.log(s.join(" "));for(let i of e){let a=[];for(let l of r){let u=String(typeof l.key=="string"&&!(l.key in i)?"":i[String(l.key)]??"");a.push(u.padEnd(o[String(l.key)]))}console.log(a.join(" "))}}else{let r=e[0],o=Object.keys(r),n={};for(let a of o)n[a]=a.length;for(let a of e)for(let l of o){let u=String(a[l]??"");n[l]=Math.max(n[l],u.length)}let s=[];for(let a of o)s.push(q.bold(a.padEnd(n[a])));console.log(s.join(" "));let i=[];for(let a of o)i.push("-".repeat(n[a]));console.log(i.join(" "));for(let a of e){let l=[];for(let u of o){let f=String(a[u]??"");l.push(f.padEnd(n[u]))}console.log(l.join(" "))}}}},keyValueTable:(e,t)=>{if(ue())return;let{borderStyle:r="single",keyColor:o=q.blue,valueColor:n=q.white,maxWidth:s=process.stdout.columns||80}=t||{},a={single:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",leftT:"\u251C",rightT:"\u2524"},double:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551",cross:"\u256C",leftT:"\u2560",rightT:"\u2563"},rounded:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",leftT:"\u251C",rightT:"\u2524"},bold:{topLeft:"\u250F",topRight:"\u2513",bottomLeft:"\u2517",bottomRight:"\u251B",horizontal:"\u2501",vertical:"\u2503",cross:"\u254B",leftT:"\u2523",rightT:"\u252B"},none:{topLeft:"",topRight:"",bottomLeft:"",bottomRight:"",horizontal:"",vertical:"",cross:"",leftT:"",rightT:""}}[r],l=0,u=0;for(let[I,k]of Object.entries(e)){l=Math.max(l,I.length);let P=String(k??"");u=Math.max(u,P.length)}let f=4,p=1,d=s-f-p;if(l+u>d){let I=l/(l+u);l=Math.floor(d*I),u=d-l}let h=l+u+f+p;r!=="none"&&console.log(a.topLeft+a.horizontal.repeat(h-2)+a.topRight);for(let[I,k]of Object.entries(e)){let P=I,V=String(k??""),K=Gs(P,l),O=Gs(V,u),Z=Math.max(K.length,O.length);for(;K.length<Z;)K.push("");for(;O.length<Z;)O.push("");for(let ie=0;ie<Z;ie++){let Q=K[ie].padEnd(l),Lt=O[ie].padEnd(u);console.log(r!=="none"?`${a.vertical} ${o(Q)} ${a.vertical} ${n(Lt)} ${a.vertical}`:`${o(Q)} : ${n(Lt)}`)}}r!=="none"&&console.log(a.bottomLeft+a.horizontal.repeat(h-2)+a.bottomRight)},break:()=>{ue()||process.stderr.write(`
|
|
32
|
+
`)},startSpinner:e=>{if(ue())return{stop:()=>{}};let t=au(e).start();return{stop:(r=!0,o)=>{o&&(t.text=o),r?t.succeed():t.fail()}}},logDetailedError(e,t){if(ue())return;let r=t?`[${t}] `:"",o=s=>s!==null&&typeof s=="object"&&"isRequestError"in s&&s.isRequestError===!0&&"status"in s&&"message"in s&&"data"in s,n=s=>s!==null&&typeof s=="object"&&"issues"in s&&Array.isArray(s.issues);if(o(e)){process.stderr.write(`${r}HTTP ${e.status}: ${e.message}
|
|
33
33
|
`),e.data!==void 0&&e.data!==null&&process.stderr.write(`${JSON.stringify(e.data,null,2)}
|
|
34
34
|
`);return}if(n(e)){process.stderr.write(`${r}Validation error: ${JSON.stringify(e.issues)}
|
|
35
35
|
`);return}e instanceof Error?process.stderr.write(`${r}${e.message}
|
|
36
36
|
`):process.stderr.write(`${r}${String(e)}
|
|
37
|
-
`)}};var
|
|
37
|
+
`)}};var Vs=lo.join(pt.homedir(),".phala-cloud"),Ms=lo.join(Vs,"api-key"),cg=lo.join(Vs,"docker-credentials.json");function pu(){let e=[pt.hostname(),pt.platform(),pt.arch(),pt.cpus()[0]?.model||"",pt.userInfo().username],t=qs.createHash("sha256");return t.update(e.join("|")),t.digest()}function uu(e){try{let t=pu(),r=e.split(":");if(r.length!==2)throw new Error("Invalid encrypted format");let o=Buffer.from(r[0],"hex"),n=r[1],s=qs.createDecipheriv("aes-256-cbc",t.slice(0,32),o),i=s.update(n,"hex","utf8");return i+=s.final("utf8"),i}catch(t){throw Ce.error("Decryption failed:",t),new Error("Failed to decrypt data")}}function Ks(){try{if(process.env.PHALA_CLOUD_API_KEY)return process.env.PHALA_CLOUD_API_KEY;if(Ds.existsSync(Ms)){let e=Ds.readFileSync(Ms,"utf8").trim();return uu(e)}return null}catch(e){return Ce.error("Failed to read API key:",e),null}}async function N(){let e=Ks();return Ns({apiKey:e})}import{z as c}from"zod";var fu=c.object({password:c.string(),registry:c.string().nullable(),username:c.string()}),dg=c.object({docker_compose_file:c.string(),docker_config:fu.optional().nullable(),features:c.array(c.string()),kms_enabled:c.boolean(),manifest_version:c.number(),name:c.string(),public_logs:c.boolean(),public_sysinfo:c.boolean(),runner:c.string().optional(),salt:c.string().nullable().optional(),tproxy_enabled:c.boolean(),version:c.string().optional()}).passthrough(),Ws=c.object({id:c.number(),name:c.string(),status:c.string(),teepod_id:c.number().nullable(),teepod:c.object({id:c.number(),name:c.string()}).nullable(),user_id:c.number().nullable(),app_id:c.string(),vm_uuid:c.string().nullable(),instance_id:c.string().nullable(),app_url:c.string().nullable(),base_image:c.string().nullable(),vcpu:c.number(),memory:c.number(),disk_size:c.number(),manifest_version:c.number().nullable(),version:c.string().nullable(),runner:c.string().nullable(),docker_compose_file:c.string().nullable(),features:c.array(c.string()).nullable(),created_at:c.string(),encrypted_env_pubkey:c.string().nullable()}),hg=c.object({key:c.string(),value:c.string()}),Xs=c.object({is_online:c.boolean(),is_public:c.boolean(),error:c.string().nullable(),internal_ip:c.string(),latest_handshake:c.string(),public_urls:c.array(c.object({app:c.string(),instance:c.string()}))}),Js=c.object({id:c.number(),name:c.string(),status:c.string(),teepod_id:c.number(),teepod:c.object({id:c.number(),name:c.string()}),user_id:c.number().nullable(),app_id:c.string(),vm_uuid:c.string().nullable(),instance_id:c.string().nullable(),app_url:c.string().nullable(),base_image:c.string().nullable(),vcpu:c.number(),memory:c.number(),disk_size:c.number(),manifest_version:c.number().nullable(),version:c.string().nullable(),runner:c.string().nullable(),docker_compose_file:c.string().nullable(),features:c.array(c.string()).nullable(),created_at:c.string(),encrypted_env_pubkey:c.string().nullable()}),Zs=c.object({is_online:c.boolean(),is_public:c.boolean(),error:c.string().nullable(),app_certificates:c.array(c.object({subject:c.object({common_name:c.string().nullable(),organization:c.string().nullable(),country:c.string().nullable(),state:c.string().nullable().optional(),locality:c.string().nullable().optional()}),issuer:c.object({common_name:c.string().nullable(),organization:c.string().nullable(),country:c.string().nullable()}),serial_number:c.string(),not_before:c.string(),not_after:c.string(),version:c.string(),fingerprint:c.string(),signature_algorithm:c.string(),sans:c.string().nullable(),is_ca:c.boolean(),position_in_chain:c.number(),quote:c.string().nullable()})).nullable(),tcb_info:c.object({mrtd:c.string(),rootfs_hash:c.string(),rtmr0:c.string(),rtmr1:c.string(),rtmr2:c.string(),rtmr3:c.string(),event_log:c.array(c.object({imr:c.number(),event_type:c.number(),digest:c.string(),event:c.string(),event_payload:c.string()}))}).nullable(),compose_file:c.string().nullable()}),mu=c.object({name:c.string(),description:c.string().optional(),version:c.array(c.number()).optional(),is_dev:c.boolean().optional(),os_image_hash:c.string().nullable().optional(),rootfs_hash:c.string().optional(),shared_ro:c.boolean().optional(),cmdline:c.string().optional(),kernel:c.string().optional(),initrd:c.string().optional(),hda:c.string().nullable().optional(),rootfs:c.string().optional(),bios:c.string().optional()}),xg=c.object({teepod_id:c.number().nullable(),id:c.number().optional(),name:c.string(),listed:c.boolean().optional(),resource_score:c.number().optional(),remaining_vcpu:c.number().optional(),remaining_memory:c.number().optional(),remaining_cvm_slots:c.number().optional(),images:c.array(mu).optional(),region_identifier:c.string().optional(),dedicated_for_team_id:c.number().nullable().optional(),support_onchain_kms:c.boolean().optional(),fmspc:c.string().nullable().optional(),device_id:c.string().nullable().optional()});import du from"inquirer";async function Cg(e){let t=await N(),r=await yr(t);if(!r.success)throw new Error(`Failed to fetch CVMs: ${r.error.message}`);let o=e.replace(/^app_/,""),i=r.data.items.find(l=>l.hosted?.app_id===o);if(!i)throw new Error(`CVM with App ID app_${o} not found`);return Ce.success(`CVM with App ID app_${o} detected`),i.hosted?.app_id||""}async function kg(e){let t=await N(),r=e.replace(/^app_/,""),o=await lt(t,{app_id:r});if(!o.success)throw new Error(o.error.message);return o.data}async function Tg(e){let t=await N(),r=await co(t,{id:e});if(!r.success)throw new Error(r.error.message);return r.data}async function Eg(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/network`);return Xs.parse(o)}async function Sg(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.post(`cvms/app_${r}/start`);return(await lt(t,{app_id:r})).data}async function Ig(e){let t=await N(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/stop`),(await lt(t,{app_id:r})).data}async function Ag(e){let t=await N(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/restart`),(await lt(t,{app_id:r})).data}async function Pg(e){let t=await N(),r=e.replace(/^app_/,"");return await t.delete(`cvms/app_${r}`),!0}async function Bg(){let e=Ce.startSpinner("Fetching available CVMs"),t=await N(),r=await yr(t);if(e.stop(!0),!r.success){Ce.error(`Failed to fetch CVMs: ${r.error.message}`);return}let n=r.data.items;if(!n||n.length===0){Ce.info("No CVMs found for your account");return}let s=n.map(a=>{let l=a,u=l.hosted?.app_id||l.hosted?.id,f=l.name||l.hosted?.name,p=l.status||l.hosted?.status;return{name:`${f||"Unnamed"} (${u}) - Status: ${p||"Unknown"}`,value:u}}),{selectedCvm:i}=await du.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:s}]);return i}async function $g(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/attestation`);try{return Zs.parse(o)}catch(n){return Ce.debug(`Validation error: ${n instanceof Error?n.message:String(n)}`),{is_online:!!o?.is_online,is_public:!!o?.is_public,error:typeof o?.error=="string"?o.error:null,app_certificates:Array.isArray(o?.app_certificates)?o.app_certificates:null,tcb_info:o?.tcb_info||null,compose_file:typeof o?.compose_file=="string"?o.compose_file:null}}}async function Lg(e,t){let r=await N(),o=e.replace(/^app_/,""),n=await r.post(`cvms/app_${o}/replicas`,t);return Js.parse(n)}async function Rg(e,t,r,o,n){let s=await N(),i=e.replace(/^app_/,""),a={};if(t!==void 0&&(a.vcpu=t),r!==void 0&&(a.memory=r),o!==void 0&&(a.disk_size=o),n!==void 0&&(a.allow_restart=n),Object.keys(a).length===0)throw new Error("At least one resource parameter must be provided");return await s.patch(`cvms/app_${i}/resources`,a),!0}async function Ug(e){return await(await N()).post("cvms/pubkey/from_cvm_configuration",e)}async function Fg(e){let r=await(await N()).post("cvms/from_cvm_configuration",e);return Ws.parse(r)}async function zg(e,t){let r=await N(),o=e.replace(/^app_/,"");return await r.put(`cvms/app_${o}/compose`,t)}async function Hg(e=!1){let t=await N(),r="teepods/available";return e&&(r+="?v03x_only=1"),await t.get(r)}export{Cg as checkCvmExists,dg as composeFileSchema,Fg as createCvm,Zs as cvmAttestationResponseSchema,Pg as deleteCvm,fu as dockerConfigSchema,hg as encryptedEnvItemSchema,$g as getCvmAttestation,kg as getCvmByAppId,Tg as getCvmComposeConfig,Eg as getCvmNetwork,Xs as getCvmNetworkResponseSchema,Ug as getPubkeyFromCvm,Hg as getTeepods,mu as imageSchema,Ws as postCvmResponseSchema,Lg as replicateCvm,Js as replicateCvmResponseSchema,Rg as resizeCvm,Ag as restartCvm,Bg as selectCvm,Sg as startCvm,Ig as stopCvm,xg as teepodSchema,zg as upgradeCvm};
|
|
38
38
|
/*! Bundled license information:
|
|
39
39
|
|
|
40
40
|
@noble/hashes/esm/utils.js:
|