phala 1.1.0-beta.9 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +198 -10
- package/README.md +34 -0
- package/dist/api/index.d.ts +24 -8
- package/dist/api/index.js +23 -25
- package/dist/index.d.ts +0 -0
- package/dist/index.js +151 -138
- package/package.json +3 -2
package/dist/api/index.js
CHANGED
|
@@ -1,45 +1,43 @@
|
|
|
1
1
|
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
2
|
-
var
|
|
2
|
+
var ai=Object.create;var xo=Object.defineProperty;var ci=Object.getOwnPropertyDescriptor;var li=Object.getOwnPropertyNames;var pi=Object.getPrototypeOf,ui=Object.prototype.hasOwnProperty;var we=(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 Error('Dynamic require of "'+e+'" is not supported')});var E=(e,t)=>()=>(e&&(t=e(e=0)),t);var W=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var fi=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of li(t))!ui.call(e,n)&&n!==r&&xo(e,n,{get:()=>t[n],enumerable:!(o=ci(t,n))||o.enumerable});return e};var ht=(e,t,r)=>(r=e!=null?ai(pi(e)):{},fi(t||!e||!e.__esModule?xo(r,"default",{value:e,enumerable:!0}):r,e));var bo=W((Nu,go)=>{var Je=1e3,Ze=Je*60,Ye=Ze*60,je=Ye*24,mi=je*7,di=je*365.25;go.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return hi(e);if(r==="number"&&isFinite(e))return t.long?gi(e):xi(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function hi(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*di;case"weeks":case"week":case"w":return r*mi;case"days":case"day":case"d":return r*je;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Ye;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ze;case"seconds":case"second":case"secs":case"sec":case"s":return r*Je;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function xi(e){var t=Math.abs(e);return t>=je?Math.round(e/je)+"d":t>=Ye?Math.round(e/Ye)+"h":t>=Ze?Math.round(e/Ze)+"m":t>=Je?Math.round(e/Je)+"s":e+"ms"}function gi(e){var t=Math.abs(e);return t>=je?Ut(e,t,je,"day"):t>=Ye?Ut(e,t,Ye,"hour"):t>=Ze?Ut(e,t,Ze,"minute"):t>=Je?Ut(e,t,Je,"second"):e+" ms"}function Ut(e,t,r,o){var n=t>=r*1.5;return Math.round(e/r)+" "+o+(n?"s":"")}});var wr=W((Mu,yo)=>{function bi(e){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=n,r.enabled=a,r.humanize=bo(),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 T(...P){if(!T.enabled)return;let V=T,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 Q=0;P[0]=P[0].replace(/%([a-zA-Z%])/g,(te,Rt)=>{if(te==="%%")return"%";Q++;let ho=r.formatters[Rt];if(typeof ho=="function"){let ii=P[Q];te=ho.call(V,ii),P.splice(Q,1),Q--}return te}),r.formatArgs.call(V,P),(V.log||r.log).apply(V,P)}return T.namespace=f,T.useColors=r.useColors(),T.color=r.selectColor(f),T.extend=o,T.destroy=r.destroy,Object.defineProperty(T,"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(T),T}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,T=0;for(;d<f.length;)if(h<p.length&&(p[h]===f[d]||p[h]==="*"))p[h]==="*"?(I=h,T=d,h++):(d++,h++);else if(I!==-1)h=I+1,T++,d=T;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}yo.exports=bi});var vo=W((X,zt)=>{X.formatArgs=vi;X.save=wi;X.load=_i;X.useColors=yi;X.storage=Ci();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 yi(){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 vi(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+zt.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 wi(e){try{e?X.storage.setItem("debug",e):X.storage.removeItem("debug")}catch{}}function _i(){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 Ci(){try{return localStorage}catch{}}zt.exports=wr()(X);var{formatters:ki}=zt.exports;ki.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var _o=W((Gu,wo)=>{"use strict";wo.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 To=W((Du,ko)=>{"use strict";var Ti=we("os"),Co=we("tty"),re=_o(),{env:z}=process,Se;re("no-color")||re("no-colors")||re("color=false")||re("color=never")?Se=0:(re("color")||re("colors")||re("color=true")||re("color=always"))&&(Se=1);"FORCE_COLOR"in z&&(z.FORCE_COLOR==="true"?Se=1:z.FORCE_COLOR==="false"?Se=0:Se=z.FORCE_COLOR.length===0?1:Math.min(parseInt(z.FORCE_COLOR,10),3));function _r(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Cr(e,t){if(Se===0)return 0;if(re("color=16m")||re("color=full")||re("color=truecolor"))return 3;if(re("color=256"))return 2;if(e&&!t&&Se===void 0)return 0;let r=Se||0;if(z.TERM==="dumb")return r;if(process.platform==="win32"){let o=Ti.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in z)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(o=>o in z)||z.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in z)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(z.TEAMCITY_VERSION)?1:0;if(z.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in z){let o=parseInt((z.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(z.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(z.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(z.TERM)||"COLORTERM"in z?1:r}function Ei(e){let t=Cr(e,e&&e.isTTY);return _r(t)}ko.exports={supportsColor:Ei,stdout:_r(Cr(!0,Co.isatty(1))),stderr:_r(Cr(!0,Co.isatty(2)))}});var So=W((F,Ht)=>{var Si=we("tty"),Ft=we("util");F.init=Ri;F.log=Bi;F.formatArgs=Ai;F.save=$i;F.load=Li;F.useColors=Ii;F.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`.");F.colors=[6,2,3,4,5,1];try{let e=To();e&&(e.stderr||e).level>=2&&(F.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{}F.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 Ii(){return"colors"in F.inspectOpts?!!F.inspectOpts.colors:Si.isatty(process.stderr.fd)}function Ai(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=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
|
|
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(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
|
|
4
|
+
`+s),e.push(n+"m+"+Ht.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=Pi()+t+" "+e[0]}function Pi(){return F.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Bi(...e){return process.stderr.write(Ft.formatWithOptions(F.inspectOpts,...e)+`
|
|
5
|
+
`)}function $i(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function Li(){return process.env.DEBUG}function Ri(e){e.inspectOpts={};let t=Object.keys(F.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=F.inspectOpts[t[r]]}Ht.exports=wr()(F);var{formatters:Eo}=Ht.exports;Eo.o=function(e){return this.inspectOpts.colors=this.useColors,Ft.inspect(e,this.inspectOpts).split(`
|
|
6
|
+
`).map(t=>t.trim()).join(" ")};Eo.O=function(e){return this.inspectOpts.colors=this.useColors,Ft.inspect(e,this.inspectOpts)}});var Io=W((qu,kr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?kr.exports=vo():kr.exports=So()});var Tr,Po=E(()=>{Tr="2.38.6"});function Bo(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Bo(e.cause,t):t?null:e}var Er,b,oe=E(()=>{Po();Er={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${Tr}`},b=class e extends Error{constructor(t,r={}){let o=r.cause instanceof e?r.cause.details:r.cause?.message?r.cause.message:r.details,n=r.cause instanceof e&&r.cause.docsPath||r.docsPath,s=Er.getDocsUrl?.({...r,docsPath:n}),i=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...o?[`Details: ${o}`]:[],...Er.version?[`Version: ${Er.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=Tr}walk(t){return Bo(this,t)}}});var Ot,jt,Sr=E(()=>{oe();Ot=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"})}},jt=class extends b{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function de(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var Qe=E(()=>{});function ne(e){return de(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var xt=E(()=>{Qe()});function gt(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 $o=E(()=>{});var bt,yt,Ir=E(()=>{oe();bt=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"})}},yt=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 Ie(e,{dir:t,size:r=32}={}){return typeof e=="string"?Ui(e,{dir:t,size:r}):zi(e,{dir:t,size:r})}function Ui(e,{dir:t,size:r=32}={}){if(r===null)return e;let o=e.replace("0x","");if(o.length>r*2)throw new yt({size:Math.ceil(o.length/2),targetSize:r,type:"hex"});return`0x${o[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function zi(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new yt({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 Ar=E(()=>{Ir()});function le(e,t={}){return typeof e=="number"||typeof e=="bigint"?_(e,t):typeof e=="string"?ji(e,t):typeof e=="boolean"?Hi(e,t):J(e,t)}function Hi(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(Ae(r,{size:t.size}),Ie(r,{size:t.size})):r}function J(e,t={}){let r="";for(let n=0;n<e.length;n++)r+=Fi[e[n]];let o=`0x${r}`;return typeof t.size=="number"?(Ae(o,{size:t.size}),Ie(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 Ot({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?Ie(a,{size:o}):a}function ji(e,t={}){let r=Oi.encode(e);return J(r,t)}var Fi,Oi,se=E(()=>{Sr();Ar();Me();Fi=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Oi=new TextEncoder});function Nt(e,t={}){return typeof e=="number"||typeof e=="bigint"?Gi(e,t):typeof e=="boolean"?Mi(e,t):de(e)?pe(e,t):Pr(e,t)}function Mi(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(Ae(r,{size:t.size}),Ie(r,{size:t.size})):r}function Lo(e){if(e>=_e.zero&&e<=_e.nine)return e-_e.zero;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 pe(e,t={}){let r=e;t.size&&(Ae(r,{size:t.size}),r=Ie(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=Lo(o.charCodeAt(a++)),u=Lo(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 Gi(e,t){let r=_(e,t);return pe(r)}function Pr(e,t={}){let r=Ni.encode(e);return typeof t.size=="number"?(Ae(r,{size:t.size}),Ie(r,{dir:"right",size:t.size})):r}var Ni,_e,Pe=E(()=>{oe();Qe();Ar();Me();se();Ni=new TextEncoder;_e={zero:48,nine:57,A:65,F:70,a:97,f:102}});function Ae(e,{size:t}){if(ne(e)>t)throw new jt({givenSize:ne(e),maxSize:t})}function Ge(e,t={}){let{signed:r}=t;t.size&&Ae(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 De(e,t={}){return Number(Ge(e,t))}var Me=E(()=>{Sr();xt()});function et(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 Mt=E(()=>{});var Uf,zf,Ff,Hf,Of,jf,Nf,Mf,Gf,Df,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,zm,Fm,Hm,Om,jm,Nm,Mm,Gm,Dm,qm,Vm,Km,Wm,Xm,Jm,Zm,Ym,Qm,ed,td,rd,od,nd,sd,id,ad,cd,ld,pd,ud,fd,md,dd,hd,xd,gd,bd,yd,vd,wd,Gt,Ho=E(()=>{Uf=2n**(8n-1n)-1n,zf=2n**(16n-1n)-1n,Ff=2n**(24n-1n)-1n,Hf=2n**(32n-1n)-1n,Of=2n**(40n-1n)-1n,jf=2n**(48n-1n)-1n,Nf=2n**(56n-1n)-1n,Mf=2n**(64n-1n)-1n,Gf=2n**(72n-1n)-1n,Df=2n**(80n-1n)-1n,qf=2n**(88n-1n)-1n,Vf=2n**(96n-1n)-1n,Kf=2n**(104n-1n)-1n,Wf=2n**(112n-1n)-1n,Xf=2n**(120n-1n)-1n,Jf=2n**(128n-1n)-1n,Zf=2n**(136n-1n)-1n,Yf=2n**(144n-1n)-1n,Qf=2n**(152n-1n)-1n,em=2n**(160n-1n)-1n,tm=2n**(168n-1n)-1n,rm=2n**(176n-1n)-1n,om=2n**(184n-1n)-1n,nm=2n**(192n-1n)-1n,sm=2n**(200n-1n)-1n,im=2n**(208n-1n)-1n,am=2n**(216n-1n)-1n,cm=2n**(224n-1n)-1n,lm=2n**(232n-1n)-1n,pm=2n**(240n-1n)-1n,um=2n**(248n-1n)-1n,fm=2n**(256n-1n)-1n,mm=-(2n**(8n-1n)),dm=-(2n**(16n-1n)),hm=-(2n**(24n-1n)),xm=-(2n**(32n-1n)),gm=-(2n**(40n-1n)),bm=-(2n**(48n-1n)),ym=-(2n**(56n-1n)),vm=-(2n**(64n-1n)),wm=-(2n**(72n-1n)),_m=-(2n**(80n-1n)),Cm=-(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)),$m=-(2n**(160n-1n)),Lm=-(2n**(168n-1n)),Rm=-(2n**(176n-1n)),Um=-(2n**(184n-1n)),zm=-(2n**(192n-1n)),Fm=-(2n**(200n-1n)),Hm=-(2n**(208n-1n)),Om=-(2n**(216n-1n)),jm=-(2n**(224n-1n)),Nm=-(2n**(232n-1n)),Mm=-(2n**(240n-1n)),Gm=-(2n**(248n-1n)),Dm=-(2n**(256n-1n)),qm=2n**8n-1n,Vm=2n**16n-1n,Km=2n**24n-1n,Wm=2n**32n-1n,Xm=2n**40n-1n,Jm=2n**48n-1n,Zm=2n**56n-1n,Ym=2n**64n-1n,Qm=2n**72n-1n,ed=2n**80n-1n,td=2n**88n-1n,rd=2n**96n-1n,od=2n**104n-1n,nd=2n**112n-1n,sd=2n**120n-1n,id=2n**128n-1n,ad=2n**136n-1n,cd=2n**144n-1n,ld=2n**152n-1n,pd=2n**160n-1n,ud=2n**168n-1n,fd=2n**176n-1n,md=2n**184n-1n,dd=2n**192n-1n,hd=2n**200n-1n,xd=2n**208n-1n,gd=2n**216n-1n,bd=2n**224n-1n,yd=2n**232n-1n,vd=2n**240n-1n,wd=2n**248n-1n,Gt=2n**256n-1n});function qe(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var $r=E(()=>{});var wt,Dt,qt,Oo=E(()=>{oe();wt=class extends b{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},Dt=class extends b{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},qt=class extends b{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function Vt(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(Wi);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var Wi,Lr=E(()=>{Oo();Wi={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 qt({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 wt({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 wt({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 Mo,Go=E(()=>{Mo={ether:-9,wei:9}});function Do(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 qo=E(()=>{});function _t(e,t="wei"){return Do(e,Mo[t])}var Vo=E(()=>{Go();qo()});function Zi(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 Kt,Wt,Xt,Jt=E(()=>{oe();Kt=class extends b{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}},Wt=class extends b{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Zi(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"})}},Xt=class extends b{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 Yi(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Rr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ve(e,...t){if(!Yi(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 ot(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 Qt(e,t){Ve(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Wo(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Be(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function er(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ue(e,t){return e<<32-t|e>>>t}function ea(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function ta(e){for(let t=0;t<e.length;t++)e[t]=ea(e[t]);return e}function ra(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Ct(e){return typeof e=="string"&&(e=ra(e)),Ve(e),e}function tr(e){let t=o=>e().update(Ct(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}var Qi,Ur,rt,rr=E(()=>{Qi=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;Ur=Qi?e=>e:ta;rt=class{}});function na(e,t=!1){return t?{h:Number(e&nr),l:Number(e>>Zo&nr)}:{h:Number(e>>Zo&nr)|0,l:Number(e&nr)|0}}function Yo(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}=na(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var nr,Zo,Qo,en,tn,rn,on=E(()=>{nr=BigInt(4294967295),Zo=BigInt(32);Qo=(e,t,r)=>e<<r|t>>>32-r,en=(e,t,r)=>t<<r|e>>>32-r,tn=(e,t,r)=>t<<r-32|e>>>64-r,rn=(e,t,r)=>e<<r-32|t>>>64-r});var ie,lr=E(()=>{oe();ie=class extends b{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 Ke,fn=E(()=>{oe();Ke=class extends b{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}});var pr,We,zr,Fr,Hr,Or,jr,Nr,Mr,Gr,kt,mn=E(()=>{Vo();oe();pr=class extends b{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(pr,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(pr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});We=class extends b{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${_t(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}};Object.defineProperty(We,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});zr=class extends b{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${_t(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}};Object.defineProperty(zr,"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 b{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/});Hr=class extends b{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(Hr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});Or=class extends b{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}};Object.defineProperty(Or,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});jr=class extends b{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(jr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});Nr=class extends b{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(Nr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});Mr=class extends b{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(Mr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});Gr=class extends b{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/});kt=class extends b{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:o}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${_t(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${o?` = ${_t(o)} gwei`:""}).`].join(`
|
|
11
|
+
`),{cause:t,name:"TipAboveFeeCapError"})}};Object.defineProperty(kt,"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 st,Dr=E(()=>{st=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 ha(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=dn(u,f,1)^r[a],d=hn(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=gn[i],l=dn(n,s,a),u=hn(n,s,a),f=xn[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]^=ma[o],e[1]^=da[o]}Be(r)}var ca,Tt,la,pa,ua,fa,xn,gn,bn,yn,ma,da,dn,hn,qr,xa,vn,wn=E(()=>{on();rr();ca=BigInt(0),Tt=BigInt(1),la=BigInt(2),pa=BigInt(7),ua=BigInt(256),fa=BigInt(113),xn=[],gn=[],bn=[];for(let e=0,t=Tt,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],xn.push(2*(5*o+r)),gn.push((e+1)*(e+2)/2%64);let n=ca;for(let s=0;s<7;s++)t=(t<<Tt^(t>>pa)*fa)%ua,t&la&&(n^=Tt<<(Tt<<BigInt(s))-Tt);bn.push(n)}yn=Yo(bn,!0),ma=yn[0],da=yn[1],dn=(e,t,r)=>r>32?tn(e,t,r):Qo(e,t,r),hn=(e,t,r)=>r>32?rn(e,t,r):en(e,t,r);qr=class e extends rt{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,Rr(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Wo(this.state)}clone(){return this._cloneInto()}keccak(){Ur(this.state32),ha(this.state32,this.rounds),Ur(this.state32),this.posOut=0,this.pos=0}update(t){ot(this),t=Ct(t),Ve(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)!==0&&o===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){ot(this,!1),Ve(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 Rr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Qt(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,Be(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new e(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}},xa=(e,t,r)=>tr(()=>new qr(t,e,r)),vn=xa(1,136,256/8)});function _n(e,t){let r=t||"hex",o=vn(de(e,{strict:!1})?Nt(e):e);return r==="bytes"?o:le(o)}var Cn=E(()=>{wn();Qe();Pe();se()});function kn(e,t){if(Vr.has(`${e}.${t}`))return Vr.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),o=_n(Pr(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 Vr.set(`${e}.${t}`,s),s}var Vr,Tn=E(()=>{Pe();Cn();Dr();Vr=new st(8192)});function he(e,t){let{strict:r=!0}=t??{},o=`${e}.${r}`;if(Kr.has(o))return Kr.get(o);let n=ga.test(e)?e.toLowerCase()===e?!0:r?kn(e)===e:!0:!1;return Kr.set(o,n),n}var ga,Kr,ur=E(()=>{Dr();Tn();ga=/^0x[a-fA-F0-9]{40}$/,Kr=new st(8192)});function En(e,t,r,{strict:o}={}){return de(e,{strict:!1})?ya(e,t,r,{strict:o}):ba(e,t,r,{strict:o})}function Sn(e,t){if(typeof t=="number"&&t>0&&t>ne(e)-1)throw new bt({offset:t,position:"start",size:ne(e)})}function In(e,t,r){if(typeof t=="number"&&typeof r=="number"&&ne(e)!==r-t)throw new bt({offset:r,position:"end",size:ne(e)})}function ba(e,t,r,{strict:o}={}){Sn(e,t);let n=e.slice(t,r);return o&&In(n,t,r),n}function ya(e,t,r,{strict:o}={}){Sn(e,t);let n=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return o&&In(n,t,r),n}var An=E(()=>{Ir();Qe();xt()});var Zr=W(At=>{"use strict";var Pa=At&&At.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(At,"__esModule",{value:!0});At.encryptEnvVars=La;var Xr=we("@noble/curves/ed25519"),Jr=Pa(we("crypto"));function Ba(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 La(e,t){let r=JSON.stringify({env:e}),o=Xr.x25519.utils.randomPrivateKey(),n=Xr.x25519.getPublicKey(o),s=Ba(t),i=Xr.x25519.getSharedSecret(o,s),a=await Jr.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=Jr.default.getRandomValues(new Uint8Array(12)),u=await Jr.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 On=W(Pt=>{"use strict";var Ra=Pt&&Pt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Pt,"__esModule",{value:!0});Pt.getComposeHash=Ha;var Ua=Ra(we("crypto"));function Yr(e){return e==null?e:Array.isArray(e)?e.map(Yr):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=Yr(o),t},{}):e}function za(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 Fa(e){let t=Yr(e);return JSON.stringify(t,(r,o)=>typeof o=="number"&&(isNaN(o)||!isFinite(o))?null:o)}function Ha(e,t=!1){t&&(e=za(e));let r=Fa(e);return Ua.default.createHash("sha256").update(r,"utf8").digest("hex")}});var as=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=es;y.fromBig=eo;y.split=jn;var hr=BigInt(2**32-1),Qr=BigInt(32);function eo(e,t=!1){return t?{h:Number(e&hr),l:Number(e>>Qr&hr)}:{h:Number(e>>Qr&hr)|0,l:Number(e&hr)|0}}function jn(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}=eo(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var Nn=(e,t)=>BigInt(e>>>0)<<Qr|BigInt(t>>>0);y.toBig=Nn;var Mn=(e,t,r)=>e>>>r;y.shrSH=Mn;var Gn=(e,t,r)=>e<<32-r|t>>>r;y.shrSL=Gn;var Dn=(e,t,r)=>e>>>r|t<<32-r;y.rotrSH=Dn;var qn=(e,t,r)=>e<<32-r|t>>>r;y.rotrSL=qn;var Vn=(e,t,r)=>e<<64-r|t>>>r-32;y.rotrBH=Vn;var Kn=(e,t,r)=>e>>>r-32|t<<64-r;y.rotrBL=Kn;var Wn=(e,t)=>t;y.rotr32H=Wn;var Xn=(e,t)=>e;y.rotr32L=Xn;var Jn=(e,t,r)=>e<<r|t>>>32-r;y.rotlSH=Jn;var Zn=(e,t,r)=>t<<r|e>>>32-r;y.rotlSL=Zn;var Yn=(e,t,r)=>t<<r-32|e>>>64-r;y.rotlBH=Yn;var Qn=(e,t,r)=>e<<r-32|t>>>64-r;y.rotlBL=Qn;function es(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/2**32|0)|0,l:n|0}}var ts=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);y.add3L=ts;var rs=(e,t,r,o)=>t+r+o+(e/2**32|0)|0;y.add3H=rs;var os=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0);y.add4L=os;var ns=(e,t,r,o,n)=>t+r+o+n+(e/2**32|0)|0;y.add4H=ns;var ss=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0);y.add5L=ss;var is=(e,t,r,o,n,s)=>t+r+o+n+s+(e/2**32|0)|0;y.add5H=is;var Oa={fromBig:eo,split:jn,toBig:Nn,shrSH:Mn,shrSL:Gn,rotrSH:Dn,rotrSL:qn,rotrBH:Vn,rotrBL:Kn,rotr32H:Wn,rotr32L:Xn,rotlSH:Jn,rotlSL:Zn,rotlBH:Yn,rotlBL:Qn,add:es,add3L:ts,add3H:rs,add4L:os,add4H:ns,add5H:is,add5L:ss};y.default=Oa});var cs=W(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.crypto=void 0;var Le=we("crypto");xr.crypto=Le&&typeof Le=="object"&&"webcrypto"in Le?Le.webcrypto:Le&&typeof Le=="object"&&"randomBytes"in Le?Le:void 0});var xs=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=ps;x.anumber=to;x.abytes=at;x.ahash=ja;x.aexists=Na;x.aoutput=Ma;x.u8=Ga;x.u32=Da;x.clean=qa;x.createView=Va;x.rotr=Ka;x.rotl=Wa;x.byteSwap=oo;x.byteSwap32=us;x.bytesToHex=Ja;x.hexToBytes=Za;x.asyncLoop=Qa;x.utf8ToBytes=no;x.bytesToUtf8=ec;x.toBytes=gr;x.kdfInputToBytes=tc;x.concatBytes=rc;x.checkOpts=oc;x.createHasher=ms;x.createOptHasher=ds;x.createXOFer=hs;x.randomBytes=nc;var it=cs();function ps(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function to(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function at(e,...t){if(!ps(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 ja(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");to(e.outputLen),to(e.blockLen)}function Na(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 Ma(e,t){at(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ga(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Da(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function qa(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Va(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ka(e,t){return e<<32-t|e>>>t}function Wa(e,t){return e<<t|e>>>32-t>>>0}x.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function oo(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}x.swap8IfBE=x.isLE?e=>e:e=>oo(e);x.byteSwapIfBE=x.swap8IfBE;function us(e){for(let t=0;t<e.length;t++)e[t]=oo(e[t]);return e}x.swap32IfBE=x.isLE?e=>e:us;var fs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Xa=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ja(e){if(at(e),fs)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Xa[e[r]];return t}var Te={_0:48,_9:57,A:65,F:70,a:97,f:102};function ls(e){if(e>=Te._0&&e<=Te._9)return e-Te._0;if(e>=Te.A&&e<=Te.F)return e-(Te.A-10);if(e>=Te.a&&e<=Te.f)return e-(Te.a-10)}function Za(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(fs)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=ls(e.charCodeAt(s)),a=ls(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 Ya=async()=>{};x.nextTick=Ya;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 no(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function ec(e){return new TextDecoder().decode(e)}function gr(e){return typeof e=="string"&&(e=no(e)),at(e),e}function tc(e){return typeof e=="string"&&(e=no(e)),at(e),e}function rc(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];at(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 oc(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 ro=class{};x.Hash=ro;function ms(e){let t=o=>e().update(gr(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function ds(e){let t=(o,n)=>e(n).update(gr(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}function hs(e){let t=(o,n)=>e(n).update(gr(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}x.wrapConstructor=ms;x.wrapConstructorWithOpts=ds;x.wrapXOFConstructorWithOpts=hs;function nc(e=32){if(it.crypto&&typeof it.crypto.getRandomValues=="function")return it.crypto.getRandomValues(new Uint8Array(e));if(it.crypto&&typeof it.crypto.randomBytes=="function")return Uint8Array.from(it.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var Ts=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=Cs;var $t=as(),M=xs(),sc=BigInt(0),Bt=BigInt(1),ic=BigInt(2),ac=BigInt(7),cc=BigInt(256),lc=BigInt(113),ys=[],vs=[],ws=[];for(let e=0,t=Bt,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],ys.push(2*(5*o+r)),vs.push((e+1)*(e+2)/2%64);let n=sc;for(let s=0;s<7;s++)t=(t<<Bt^(t>>ac)*lc)%cc,t&ic&&(n^=Bt<<(Bt<<BigInt(s))-Bt);ws.push(n)}var _s=(0,$t.split)(ws,!0),pc=_s[0],uc=_s[1],gs=(e,t,r)=>r>32?(0,$t.rotlBH)(e,t,r):(0,$t.rotlSH)(e,t,r),bs=(e,t,r)=>r>32?(0,$t.rotlBL)(e,t,r):(0,$t.rotlSL)(e,t,r);function Cs(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=gs(u,f,1)^r[a],d=bs(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=vs[i],l=gs(n,s,a),u=bs(n,s,a),f=ys[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]^=pc[o],e[1]^=uc[o]}(0,M.clean)(r)}var Lt=class e extends M.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,M.anumber)(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,M.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,M.swap32IfBE)(this.state32),Cs(this.state32,this.rounds),(0,M.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(t){(0,M.aexists)(this),t=(0,M.toBytes)(t),(0,M.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)!==0&&o===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){(0,M.aexists)(this,!1),(0,M.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,M.anumber)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,M.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,M.clean)(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new e(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=Lt;var Re=(e,t,r)=>(0,M.createHasher)(()=>new Lt(t,e,r));A.sha3_224=Re(6,144,224/8);A.sha3_256=Re(6,136,256/8);A.sha3_384=Re(6,104,384/8);A.sha3_512=Re(6,72,512/8);A.keccak_224=Re(1,144,224/8);A.keccak_256=Re(1,136,256/8);A.keccak_384=Re(1,104,384/8);A.keccak_512=Re(1,72,512/8);var ks=(e,t,r)=>(0,M.createXOFer)((o={})=>new Lt(t,e,o.dkLen===void 0?r:o.dkLen,!0));A.shake128=ks(31,168,128/8);A.shake256=ks(31,136,256/8)});var Es=W(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.verifyEnvEncryptPublicKey=dc;var fc=Ts(),mc=we("@noble/curves/secp256k1");function dc(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,fc.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=mc.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 Bs=ht(Io(),1);import{ofetch as hc}from"ofetch";function Ao(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 Ue}from"zod";import{z as w}from"zod";import{z as ze}from"zod";function Ne(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}Mt();Me();Mt();var Br={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function vt(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?De(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?De(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Br[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=Di(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 Ro=et("transaction",vt);function Di(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 qi(e,t){let r=(e.transactions??[]).map(o=>typeof o=="string"?o:vt(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 Uo=et("block",qi);function zo(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}:{}}}Me();Mt();var Vi={"0x0":"reverted","0x1":"success"};function Ki(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=>zo(o)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?De(e.transactionIndex):null,status:e.status?Vi[e.status]:null,type:e.type?Br[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var Fo=et("transactionReceipt",Ki);oe();Lr();Pe();se();function Ce(e,t="hex"){let r=jo(e),o=Vt(new Uint8Array(r.length));return r.encode(o),t==="hex"?J(o.bytes):o.bytes}function jo(e){return Array.isArray(e)?Xi(e.map(t=>jo(t))):Ji(e)}function Xi(e){let t=e.reduce((n,s)=>n+s.length,0),r=No(t);return{length:t<=55?1+t:1+r+t,encode(n){t<=55?n.pushByte(192+t):(n.pushByte(247+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 Ji(e){let t=typeof e=="string"?pe(e):e,r=No(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(183+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 No(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.")}Jt();se();function Ko(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?le(o):"0x",i,n?le(n):"0x",...tt({},s)])}return t}Pe();se();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(s=>pe(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))}Pe();se();function Yt(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=>pe(i)):e.blobs,n=typeof e.commitments[0]=="string"?e.commitments.map(i=>pe(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))}se();rr();function oa(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 Xo(e,t,r){return e&t^~e&r}function Jo(e,t,r){return e&t^e&r^t&r}var or=class extends rt{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=er(this.buffer)}update(t){ot(this),t=Ct(t),Ve(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=er(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){ot(this),Qt(t,this),this.finished=!0;let{buffer:r,view:o,blockLen:n,isLE:s}=this,{pos:i}=this;r[i++]=128,Be(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let p=i;p<n;p++)r[p]=0;oa(o,n-8,BigInt(this.length*8),s),this.process(o,0);let a=er(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()}},ke=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);rr();var sa=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]),$e=new Uint32Array(64),sr=class extends or{constructor(t=32){super(64,t,8,!1),this.A=ke[0]|0,this.B=ke[1]|0,this.C=ke[2]|0,this.D=ke[3]|0,this.E=ke[4]|0,this.F=ke[5]|0,this.G=ke[6]|0,this.H=ke[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)$e[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let d=$e[p-15],h=$e[p-2],I=ue(d,7)^ue(d,18)^d>>>3,T=ue(h,17)^ue(h,19)^h>>>10;$e[p]=T+$e[p-7]+I+$e[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=ue(a,6)^ue(a,11)^ue(a,25),h=f+d+Xo(a,l,u)+sa[p]+$e[p]|0,T=(ue(o,2)^ue(o,13)^ue(o,22))+Jo(o,n,s)|0;f=u,u=l,l=a,a=i+h|0,i=s,s=n,n=o,o=h+T|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(){Be($e)}destroy(){this.set(0,0,0,0,0,0,0,0),Be(this.buffer)}};var nn=tr(()=>new sr);var sn=nn;Qe();Pe();se();function an(e,t){let r=t||"hex",o=sn(de(e,{strict:!1})?Nt(e):e);return r==="bytes"?o:le(o)}function cn(e){let{commitment:t,version:r=1}=e,o=e.to??(typeof t=="string"?"hex":"bytes"),n=an(t,"bytes");return n.set([r],0),o==="bytes"?n:J(n)}function ln(e){let{commitments:t,version:r}=e,o=e.to??(typeof t[0]=="string"?"hex":"bytes"),n=[];for(let s of t)n.push(cn({commitment:s,to:o,version:r}));return n}oe();var ir=class extends b{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},nt=class extends b{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},ar=class extends b{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},cr=class extends b{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};Lr();xt();Pe();se();function pn(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?pe(e.data):e.data,o=ne(r);if(!o)throw new nt;if(o>761855)throw new ir({maxSize:761855,size:o});let n=[],s=!0,i=0;for(;s;){let a=Vt(new Uint8Array(131072)),l=0;for(;l<4096;){let u=r.slice(i,i+31);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 un(e){let{data:t,kzg:r,to:o}=e,n=e.blobs??pn({data:t,to:o}),s=e.commitments??Zt({blobs:n,kzg:r,to:o}),i=e.proofs??Yt({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}$r();$o();se();Ho();lr();oe();fn();mn();ur();xt();An();Me();function Pn(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:o}=r,n=r.address;if(!he(n))throw new ie({address:n});if(o<0)throw new Ke({chainId:o})}fr(e)}function Bn(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new nt;for(let r of t){let o=ne(r),n=De(En(r,0,1));if(o!==32)throw new ar({hash:r,size:o});if(n!==1)throw new cr({hash:r,version:n})}}fr(e)}function fr(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:o,to:n}=e;if(t<=0)throw new Ke({chainId:t});if(n&&!he(n))throw new ie({address:n});if(o&&o>Gt)throw new We({maxFeePerGas:o});if(r&&o&&r>o)throw new kt({maxFeePerGas:o,maxPriorityFeePerGas:r})}function $n(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(t<=0)throw new Ke({chainId:t});if(s&&!he(s))throw new ie({address:s});if(r||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(o&&o>Gt)throw new We({maxFeePerGas:o})}function Ln(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(s&&!he(s))throw new ie({address:s});if(typeof t<"u"&&t<=0)throw new Ke({chainId:t});if(r||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(o&&o>Gt)throw new We({maxFeePerGas:o})}Jt();function Rn(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 Wt({transaction:e})}lr();Jt();ur();function Et(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 Xt({storageKey:n[s]});if(!he(o,{strict:!1}))throw new ie({address:o});t.push([o,n])}return t}function Un(e,t){let r=Rn(e);return r==="eip1559"?_a(e,t):r==="eip2930"?Ca(e,t):r==="eip4844"?wa(e,t):r==="eip7702"?va(e,t):ka(e,t)}function va(e,t){let{authorizationList:r,chainId:o,gas:n,nonce:s,to:i,value:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;Pn(e);let d=Et(f),h=Ko(r);return qe(["0x04",Ce([_(o),s?_(s):"0x",u?_(u):"0x",l?_(l):"0x",n?_(n):"0x",i??"0x",a?_(a):"0x",p??"0x",d,h,...tt(e,t)])])}function wa(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;Bn(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(te=>J(te)),Q=e.kzg,ce=Zt({blobs:O,kzg:Q});if(typeof d>"u"&&(d=ln({commitments:ce})),typeof h>"u"){let te=Yt({blobs:O,commitments:ce,kzg:Q});h=un({blobs:O,commitments:ce,proofs:te})}}let I=Et(f),T=[_(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??[],...tt(e,t)],P=[],V=[],K=[];if(h)for(let O=0;O<h.length;O++){let{blob:Q,commitment:ce,proof:te}=h[O];P.push(Q),V.push(ce),K.push(te)}return qe(["0x03",h?Ce([T,P,V,K]):Ce(T)])}function _a(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:u,data:f}=e;fr(e);let p=Et(u),d=[_(r),n?_(n):"0x",l?_(l):"0x",a?_(a):"0x",o?_(o):"0x",s??"0x",i?_(i):"0x",f??"0x",p,...tt(e,t)];return qe(["0x02",Ce(d)])}function Ca(e,t){let{chainId:r,gas:o,data:n,nonce:s,to:i,value:a,accessList:l,gasPrice:u}=e;$n(e);let f=Et(l),p=[_(r),s?_(s):"0x",u?_(u):"0x",o?_(o):"0x",i??"0x",a?_(a):"0x",n??"0x",f,...tt(e,t)];return qe(["0x01",Ce(p)])}function ka(e,t){let{chainId:r=0,gas:o,data:n,nonce:s,to:i,value:a,gasPrice:l}=e;Ln(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 Kt({v:t.v});return h})(),p=gt(t.r),d=gt(t.s);u=[...u,_(f),p==="0x00"?"0x":p,d==="0x00"?"0x":d]}else r>0&&(u=[...u,_(r),"0x","0x"]);return Ce(u)}function tt(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=gt(r.r),i=gt(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 zn={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};Me();var Fn={block:Uo({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let o=vt(r);return o.typeHex==="0x7e"&&(o.isSystemTx=r.isSystemTx,o.mint=r.mint?Ge(r.mint):void 0,o.sourceHash=r.sourceHash,o.type="deposit"),o}),stateRoot:e.stateRoot}}}),transaction:Ro({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Ge(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Fo({format(e){return{l1GasPrice:e.l1GasPrice?Ge(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Ge(e.l1GasUsed):null,l1Fee:e.l1Fee?Ge(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};lr();ur();$r();se();function Ta(e,t){return Sa(e)?Ea(e):Un(e,t)}var Hn={transaction:Ta};function Ea(e){Ia(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?le(i):"0x",l?le(l):"0x",n?le(n):"0x",s?"0x1":"0x",r??"0x"];return qe(["0x7e",Ce(u)])}function Sa(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function Ia(e){let{from:t,to:r}=e;if(t&&!he(t))throw new ie({address:t});if(r&&!he(r))throw new ie({address:r})}var Wr={blockTime:2e3,contracts:zn,formatters:Fn,serializers:Hn};var mr=Ne({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 St=1,It=Ne({...Wr,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:{...Wr.contracts,disputeGameFactory:{[St]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[St]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[St]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[St]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:St}),Aa=Ne({...It,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var dr=Ne({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 ee}from"zod";import{z as m}from"zod";import{z as lt}from"zod";import{z as ae}from"zod";import{z as v}from"zod";import{z as C}from"zod";import{z as D}from"zod";import yl from"crypto";import{z as be}from"zod";import{z as fe}from"zod";import{z as j}from"zod";import{z as Z}from"zod";import{z as Y}from"zod";import{z as Zl}from"zod";import{z as Is}from"zod";import{z as ye}from"zod";import{z as ft}from"zod";import{z as Xe}from"zod";import{z as Tp}from"zod";import{z as Ap}from"zod";import{z as S}from"zod";import{z as ge}from"zod";import{z as Dp}from"zod";import{z as $}from"zod";import{z as g}from"zod";import{z as ut}from"zod";import{z as As}from"zod";import{z as G}from"zod";import{z as qs}from"zod";import{z as xe}from"zod";import{z as U}from"zod";var ig=ht(Zr(),1);import{z as B}from"zod";var Su=ht(Zr(),1),Iu=ht(On(),1),Au=ht(Es(),1);import{z as pt}from"zod";var xc=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()}),ve=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)}},io=class br extends ve{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=xc.safeParse(t.data);return r.success?new br(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 br(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 br(t.message,{request:r??void 0,detail:t.message})}},gc=class extends ve{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},bc=class extends ve{constructor(){super(...arguments),this.isAuthError=!0}},$s=class extends ve{constructor(){super(...arguments),this.isBusinessError=!0}},yc=class extends ve{constructor(){super(...arguments),this.isServerError=!0}},vc=class extends ve{constructor(){super(...arguments),this.isUnknownError=!0}};function wc(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 Ls(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((n,s)=>{let i=wc(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 _c(e){return e===422?"validation":e===401||e===403?"auth":e>=400&&e<500?"business":e>=500?"server":"unknown"}function Cc(e,t,r){if(e===422&&Array.isArray(t)){let{message:o}=Ls(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 kc(e){let t=e.status??0,r=e.statusText??"Unknown Error",o=e.detail,n=Ec(o);if(n)return new Tc(n.message,{status:t,statusText:r,detail:o,errorCode:n.error_code,structuredDetails:n.details,suggestions:n.suggestions,links:n.links});let s=_c(t),i=Cc(t,o,e.message),a={status:t,statusText:r,detail:o};if(s==="validation"&&Array.isArray(o)){let{errors:l}=Ls(o);return new gc(i,{...a,validationErrors:l})}return s==="auth"?new bc(i,a):s==="business"?new $s(i,a):s==="server"?new yc(i,a):new vc(i,a)}var Tc=class extends $s{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 Ec(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 ao=["2025-05-31","2025-10-28"],ct=(0,Bs.default)("phala::api-client");function Sc(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
|
|
12
|
+
`)}function Ic(e){return e?` -d '${(typeof e=="string"?e:JSON.stringify(e,null,2)).replace(/'/g,"\\'")}'`:""}function Ss(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
|
|
16
|
-
`);
|
|
15
|
+
`)}var Ac=class{constructor(e={}){this.emitter=Ao();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&&ao.includes(t.version)?t.version:ao[ao.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=hc.create({baseURL:n,timeout:s||3e4,headers:f,...a?{credentials:"include"}:{},...u,onRequest({request:p,options:d}){if(ct.enabled){let h=d.method||"GET",I=typeof p=="string"?p:p.url,T=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} "${T}"`,Sc(P),d.body?Ic(d.body):""].filter(Boolean).join(`
|
|
16
|
+
`);ct(`
|
|
17
17
|
=== REQUEST ===
|
|
18
18
|
%s
|
|
19
|
-
`,V)}},onResponse({request:p,response:d,options:h}){if(
|
|
19
|
+
`,V)}},onResponse({request:p,response:d,options:h}){if(ct.enabled){let I=h.method||"GET",T=typeof p=="string"?p:p.url;ct(`
|
|
20
20
|
=== RESPONSE [%s %s] (%dms) ===
|
|
21
21
|
%s
|
|
22
|
-
`,I,
|
|
22
|
+
`,I,T,d.headers.get("x-response-time")||"?",Ss(d.status,d.statusText,d.headers,d._data))}},onResponseError:({request:p,response:d,options:h})=>{if(console.warn(`HTTP ${d.status}: ${d.url}`),ct.enabled){let I=h.method||"GET",T=typeof p=="string"?p:p.url;ct(`
|
|
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?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(...
|
|
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,T,Ss(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?io.fromFetchError(e):e instanceof Error?io.fromError(e):new io("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(e){let t=kc(e);return this.emitter.emit("error",t),t}async safeRequest(e){try{return{success:!0,data:await e()}}catch(t){if(t instanceof ve)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 Pc(e={}){return new Ac(e)}function Rs(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 Us(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 zs(e,t){function r(i,a){return o(i,a)}async function o(i,a){Rs(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=Us(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 k(e,t){function r(i,...a){let[l,u]=a;return o(i,l,u)}async function o(i,a,l){Rs(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=Us(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 Bc=Ue.object({username:Ue.string(),email:Ue.string(),credits:Ue.number(),granted_credits:Ue.number(),avatar:Ue.string(),team_name:Ue.string(),team_tier:Ue.string()}).passthrough(),{action:$c,safeAction:Lc}=zs(Bc,async e=>await e.get("/auth/me")),Rc={[dr.id]:dr,[It.id]:It,[mr.id]:mr},Uc=ze.object({id:ze.string(),slug:ze.string().nullable(),url:ze.string(),version:ze.string(),chain_id:ze.number().nullable(),kms_contract_address:ze.string().nullable().transform(e=>e),gateway_app_id:ze.string().nullable().transform(e=>e)}).passthrough(),Ee=Uc.transform(e=>{if(e.chain_id!=null){let t=Rc[e.chain_id];if(t)return{...e,chain:t}}return e}),zc=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(),Fc=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(zc),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(),Hc=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(),Oc=w.object({tier:w.string(),capacity:Hc,nodes:w.array(Fc),kms_list:w.array(Ee)}).passthrough(),{action:jc,safeAction:Nc}=zs(Oc,async e=>await e.get("/teepods/available")),Fs=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(),Mc=L.object({name:L.string(),items:L.array(Fs),total:L.number()}).strict(),Gc=L.object({result:L.array(Mc)}).strict(),Dc=L.object({items:L.array(Fs),total:L.number(),family:L.string()}).strict(),qc=L.object({family:L.string()}).strict(),{action:Vc,safeAction:Kc}=k(Gc,async e=>await e.get("/instance-types")),{action:Wc,safeAction:Xc}=k(Dc,async(e,t)=>{let r=qc.parse(t);return await e.get(`/instance-types/${r.family}`)}),Hs=ee.object({id:ee.string(),name:ee.string(),slug:ee.string().nullable(),tier:ee.string(),role:ee.string(),created_at:ee.string()}).passthrough(),Jc=ee.object({has_more:ee.boolean(),next_cursor:ee.string().nullable(),total:ee.number().nullable()}).passthrough(),Zc=ee.object({data:ee.array(Hs),pagination:Jc}).passthrough(),{action:Yc,safeAction:Qc}=k(Zc,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:el,safeAction:tl}=k(Hs,async(e,t)=>await e.get(`/workspaces/${t}`)),rl=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()}),ol=m.object({id:m.number(),username:m.string()}),po=m.object({id:m.number(),name:m.string(),region_identifier:m.string().nullable().optional()}),Os=m.object({app:m.string(),instance:m.string()}),nl=m.object({hosted:rl,name:m.string(),managed_user:ol.nullable(),node:po.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:Ee.nullable(),vcpu:m.number().nullable(),memory:m.number().nullable(),disk_size:m.number().nullable(),gateway_domain:m.string().nullable(),public_urls:m.array(Os)}),js=m.object({id:m.number(),name:m.string(),status:m.string(),in_progress:m.boolean().optional().default(!1),teepod_id:m.number().nullable(),teepod:po.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:Ee.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(Os).optional().default([]),gateway_domain:m.string().optional().nullable()}),yr=m.object({id:m.number(),name:m.string(),status:m.string(),teepod_id:m.number(),teepod:po.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()});function Ns(e){return typeof e!="string"||e.length<5||e.length>63?!1:/^[a-zA-Z](?!.*--)([a-zA-Z0-9-]*[a-zA-Z0-9])?$/.test(e)}var Fe=lt.object({id:lt.string().optional(),uuid:lt.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:lt.string().optional(),instance_id:lt.string().optional(),name:lt.string().refine(Ns,{message:"Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens"}).optional()}),He=e=>e.refine(t=>{let r=t;return!!(r.id||r.uuid||r.app_id||r.instance_id||r.name)},{message:"One of id, uuid, app_id, instance_id, or name must be provided"}),sl=He(Fe),R=sl.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{if(e.name)return{cvmId:e.name};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}}),il=R,{action:al,safeAction:mt}=k(js,async(e,t)=>{let{cvmId:r}=il.parse(t);return await e.get(`/cvms/${r}`)}),cl=ae.object({page:ae.number().int().min(1).optional(),page_size:ae.number().int().min(1).optional(),node_id:ae.number().int().min(1).optional(),teepod_id:ae.number().int().min(1).optional(),user_id:ae.string().optional()}).strict(),ll=ae.object({items:ae.array(nl),total:ae.number(),page:ae.number(),page_size:ae.number(),pages:ae.number()}).strict(),{action:pl,safeAction:uo}=k(ll,async(e,t)=>{let r=cl.parse(t??{});return await e.get("/cvms/paginated",{params:r})}),ul=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}),co="Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens",fl=v.object({node_id:v.number().optional(),teepod_id:v.number().optional(),region:v.string().optional(),name:v.string().min(5,co).max(63,co).refine(e=>Ns(e),co),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 ml(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:dl,safeAction:hl}=k(ul,async(e,t)=>{let r=fl.parse(t),o=ml(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)}),xl=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(),Rx=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:gl,safeAction:bl}=k(xl,async(e,t)=>await e.post("/cvms",t)),Ms=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 lo(e){return e==null?e:Array.isArray(e)?e.map(lo):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=lo(o),t},{}):e}function Gs(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 Ds(e){let t=lo(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function vl(e){let t=Gs(e),r=Ds(t);return yl.createHash("sha256").update(r,"utf8").digest("hex")}function wl(e){let t=e;return{...e,getHash:()=>vl(t),toString:()=>Ds(Gs(t))}}var _l=Ms.transform(e=>wl(e)),Cl=R,{action:kl,safeAction:fo}=k(_l,async(e,t)=>{let{cvmId:r}=Cl.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),Tl=be.object({id:be.string().optional(),uuid:be.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:be.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:be.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:Ms,update_env_vars:be.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})),El=be.object({app_id:be.string().nullable(),device_id:be.string().nullable(),compose_hash:be.string(),kms_info:Ee.nullable().optional()}).passthrough(),{action:Sl,safeAction:Il}=k(El,async(e,t)=>{let r=Tl.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),Al=fe.object({id:fe.string().optional(),uuid:fe.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:fe.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:fe.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:fe.string().min(1,"Compose hash is required"),encrypted_env:fe.string().optional(),env_keys:fe.array(fe.string()).optional(),update_env_vars:fe.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??void 0,_raw:e})),Pl=fe.any().transform(()=>{}),{action:Bl,safeAction:$l}=k(Pl,async(e,t)=>{let r=Al.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,update_env_vars:r.update_env_vars})}),Ll=He(Fe.extend({encrypted_env:j.string().describe("Encrypted environment variables (hex string)"),env_keys:j.array(j.string()).optional().describe("List of allowed environment variable keys"),compose_hash:j.string().optional().describe("Compose hash for verification (Phase 2, required when env_keys changes)"),transaction_hash:j.string().optional().describe("On-chain transaction hash for verification (Phase 2, required when env_keys changes)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{encrypted_env:e.encrypted_env,env_keys:e.env_keys,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Rl=j.object({status:j.literal("in_progress"),message:j.string(),correlation_id:j.string(),allowed_envs_changed:j.boolean()}),Ul=j.object({status:j.literal("precondition_required"),message:j.string(),compose_hash:j.string(),app_id:j.string(),device_id:j.string(),kms_info:Ee}),zl=j.union([Rl,Ul]),{action:Fl,safeAction:Hl}=k(zl,async(e,t)=>{let r=Ll.parse(t);try{return await e.patch(`/cvms/${r.cvmId}/envs`,r.request)}catch(o){if(o instanceof ve&&o.status===465){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}}),Ol=He(Fe.extend({docker_compose_file:Z.string().describe("Docker Compose YAML content"),compose_hash:Z.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:Z.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{docker_compose_file:e.docker_compose_file,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),jl=Z.object({status:Z.literal("in_progress"),message:Z.string(),correlation_id:Z.string()}),Nl=Z.object({status:Z.literal("precondition_required"),message:Z.string(),compose_hash:Z.string(),app_id:Z.string(),device_id:Z.string(),kms_info:Ee}),Ml=Z.union([jl,Nl]),{action:Gl,safeAction:Dl}=k(Ml,async(e,t)=>{let r=Ol.parse(t),o={"Content-Type":"text/yaml"};r.request.compose_hash&&(o["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(o["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/docker-compose`,r.request.docker_compose_file,{headers:o})}catch(n){if(n instanceof ve&&n.status===465){let s=n.detail;if(s&&typeof s=="object"){let i=s;return{status:"precondition_required",message:i.message||"Compose hash verification required",compose_hash:i.compose_hash,app_id:i.app_id,device_id:i.device_id,kms_info:i.kms_info}}}throw n}}),ql=He(Fe.extend({pre_launch_script:Y.string().describe("Pre-launch script content (shell script)"),compose_hash:Y.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:Y.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{pre_launch_script:e.pre_launch_script,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Vl=Y.object({status:Y.literal("in_progress"),message:Y.string(),correlation_id:Y.string()}),Kl=Y.object({status:Y.literal("precondition_required"),message:Y.string(),compose_hash:Y.string(),app_id:Y.string(),device_id:Y.string(),kms_info:Ee}),Wl=Y.union([Vl,Kl]),{action:Xl,safeAction:Jl}=k(Wl,async(e,t)=>{let r=ql.parse(t),o={"Content-Type":"text/plain"};r.request.compose_hash&&(o["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(o["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/pre-launch-script`,r.request.pre_launch_script,{headers:o})}catch(n){if(n instanceof ve&&n.status===465){let s=n.detail;if(s&&typeof s=="object"){let i=s;return{status:"precondition_required",message:i.message||"Compose hash verification required",compose_hash:i.compose_hash,app_id:i.app_id,device_id:i.device_id,kms_info:i.kms_info}}}throw n}}),Yl=R,{action:Ql,safeAction:ep}=k(Zl.string(),async(e,t)=>{let{cvmId:r}=Yl.parse(t);return await e.get(`/cvms/${r}/pre-launch-script`)}),tp=Is.object({kms_id:Is.string().min(1,"KMS ID is required")}),{action:rp,safeAction:op}=k(Ee,async(e,t)=>{let r=tp.parse(t);return await e.get(`/kms/${r.kms_id}`)}),np=ye.object({page:ye.number().int().min(1).optional(),page_size:ye.number().int().min(1).optional(),is_onchain:ye.boolean().optional()}).strict(),sp=ye.object({items:ye.array(Ee),total:ye.number(),page:ye.number(),page_size:ye.number(),pages:ye.number()}).strict(),{action:ip,safeAction:ap}=k(sp,async(e,t)=>{let r=np.parse(t??{});return await e.get("/kms",{params:r})}),cp=ft.object({kms:ft.string().min(1,"KMS ID or slug is required"),app_id:ft.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(),lp=ft.object({public_key:ft.string(),signature:ft.string()}).strict(),{action:pp,safeAction:up}=k(lp,async(e,t)=>{let r=cp.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),fp=Xe.object({counts:Xe.number().int().min(1).max(20).optional().default(1)}).strict(),mp=Xe.object({app_ids:Xe.array(Xe.object({app_id:Xe.string(),nonce:Xe.number().int().min(0)}))}).strict(),{action:dp,safeAction:hp}=k(mp,async(e,t)=>{let r=fp.parse(t??{}),o=new URLSearchParams;return o.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${o.toString()}`)}),xp=R,{action:gp,safeAction:bp}=k(yr,async(e,t)=>{let{cvmId:r}=xp.parse(t);return await e.post(`/cvms/${r}/start`)}),yp=R,{action:vp,safeAction:wp}=k(yr,async(e,t)=>{let{cvmId:r}=yp.parse(t);return await e.post(`/cvms/${r}/stop`)}),_p=R,{action:Cp,safeAction:kp}=k(yr,async(e,t)=>{let{cvmId:r}=_p.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),Ep=He(Fe.extend({force:Tp.boolean().optional()})),{action:Sp,safeAction:Ip}=k(yr,async(e,t)=>{let r=Ep.parse(t),{cvmId:o}=R.parse(r),{force:n=!1}=r;return await e.post(`/cvms/${o}/restart`,{force:n})}),Pp=R,{action:Bp,safeAction:$p}=k(Ap.void(),async(e,t)=>{let{cvmId:r}=Pp.parse(t);await e.delete(`/cvms/${r}`)}),Lp=S.object({name:S.string(),mount_point:S.string(),total_size:S.number(),free_size:S.number()}),Rp=S.object({os_name:S.string(),os_version:S.string(),kernel_version:S.string(),cpu_model:S.string(),num_cpus:S.number(),total_memory:S.number(),available_memory:S.number(),used_memory:S.number(),free_memory:S.number(),total_swap:S.number(),used_swap:S.number(),free_swap:S.number(),uptime:S.number(),loadavg_one:S.number(),loadavg_five:S.number(),loadavg_fifteen:S.number(),disks:S.array(Lp)}),Up=S.object({is_online:S.boolean(),is_public:S.boolean().default(!1),error:S.string().nullable(),sysinfo:Rp.nullable(),status:S.string().nullable(),in_progress:S.boolean().default(!1),boot_progress:S.string().nullable(),boot_error:S.string().nullable()}),zp=R,{action:Fp,safeAction:Hp}=k(Up,async(e,t)=>{let{cvmId:r}=zp.parse(t);return await e.get(`/cvms/${r}/stats`)}),Op=ge.object({app:ge.string(),instance:ge.string()}),jp=ge.object({is_online:ge.boolean(),is_public:ge.boolean().default(!0),error:ge.string().nullable(),internal_ip:ge.string().nullable(),latest_handshake:ge.string().nullable(),public_urls:ge.array(Op).nullable()}),Np=R,{action:Mp,safeAction:Gp}=k(jp,async(e,t)=>{let{cvmId:r}=Np.parse(t);return await e.get(`/cvms/${r}/network`)}),qp=R,{action:Vp,safeAction:Kp}=k(Dp.string(),async(e,t)=>{let{cvmId:r}=qp.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),Wp=$.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()}),Xp=$.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(Wp).nullable()}),Jp=R,{action:Zp,safeAction:Yp}=k(Xp,async(e,t)=>{let{cvmId:r}=Jp.parse(t);return await e.get(`/cvms/${r}/composition`)}),Qp=g.object({common_name:g.string().nullable(),organization:g.string().nullable(),country:g.string().nullable(),state:g.string().nullable(),locality:g.string().nullable()}),eu=g.object({common_name:g.string().nullable(),organization:g.string().nullable(),country:g.string().nullable()}),tu=g.object({subject:Qp,issuer:eu,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()}),ru=g.object({imr:g.number(),event_type:g.number(),digest:g.string(),event:g.string(),event_payload:g.string()}),ou=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(ru),app_compose:g.string()}),nu=g.object({name:g.string().nullable(),is_online:g.boolean(),is_public:g.boolean().default(!0),error:g.string().nullable(),app_certificates:g.array(tu).nullable(),tcb_info:ou.nullable(),compose_file:g.string().nullable()}),su=R,{action:iu,safeAction:au}=k(nu,async(e,t)=>{let{cvmId:r}=su.parse(t);return await e.get(`/cvms/${r}/attestation`)}),cu=He(Fe.extend({vcpu:ut.number().optional(),memory:ut.number().optional(),disk_size:ut.number().optional(),instance_type:ut.string().optional(),allow_restart:ut.boolean().optional()})),{action:lu,safeAction:pu}=k(ut.void(),async(e,t)=>{let r=cu.parse(t),{cvmId:o}=R.parse(r),{...n}=r;await e.patch(`/cvms/${o}/resources`,n)}),uu=He(Fe.extend({public_sysinfo:As.boolean(),public_logs:As.boolean()})),{action:fu,safeAction:mu}=k(js,async(e,t)=>{let r=uu.parse(t),{cvmId:o}=R.parse(r),{public_sysinfo:n,public_logs:s}=r;return await e.patch(`/cvms/${o}/visibility`,{public_sysinfo:n,public_logs:s})}),Ps=G.object({name:G.string(),os_image_hash:G.string().nullable(),is_current:G.boolean()}),du=G.object({version:G.union([G.tuple([G.number(),G.number(),G.number(),G.number()]),G.tuple([G.number(),G.number(),G.number()])]),prod:Ps.nullable(),dev:Ps.nullable()}),hu=G.array(du),xu=R,{action:gu,safeAction:bu}=k(hu,async(e,t)=>{let{cvmId:r}=xu.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),yu=He(Fe.extend({os_image_name:qs.string().min(1,"OS image name is required")})),{action:vu,safeAction:wu}=k(qs.void(),async(e,t)=>{let r=yu.parse(t),{cvmId:o}=R.parse(r),{os_image_name:n}=r;await e.patch(`/cvms/${o}/os-image`,{os_image_name:n})}),_u=xe.object({id:xe.string().optional(),instance_id:xe.string().optional(),name:xe.string(),status:xe.string(),uptime:xe.string().optional(),exited_at:xe.string().optional(),boot_progress:xe.string().optional(),boot_error:xe.string().optional(),shutdown_progress:xe.string().optional()}),Cu=R,{action:ku,safeAction:Tu}=k(_u,async(e,t)=>{let{cvmId:r}=Cu.parse(t);return await e.get(`/cvms/${r}/state`)});function Vs(e={}){let t=Pc(e),r={getCurrentUser:$c,safeGetCurrentUser:Lc,getAvailableNodes:jc,safeGetAvailableNodes:Nc,listAllInstanceTypeFamilies:Vc,safeListAllInstanceTypeFamilies:Kc,listFamilyInstanceTypes:Wc,safeListFamilyInstanceTypes:Xc,listWorkspaces:Yc,safeListWorkspaces:Qc,getWorkspace:el,safeGetWorkspace:tl,getCvmInfo:al,safeGetCvmInfo:mt,getCvmList:pl,safeGetCvmList:uo,provisionCvm:dl,safeProvisionCvm:hl,commitCvmProvision:gl,safeCommitCvmProvision:bl,getCvmComposeFile:kl,safeGetCvmComposeFile:fo,provisionCvmComposeFileUpdate:Sl,safeProvisionCvmComposeFileUpdate:Il,commitCvmComposeFileUpdate:Bl,safeCommitCvmComposeFileUpdate:$l,updateCvmEnvs:Fl,safeUpdateCvmEnvs:Hl,updateDockerCompose:Gl,safeUpdateDockerCompose:Dl,updatePreLaunchScript:Xl,safeUpdatePreLaunchScript:Jl,getCvmPreLaunchScript:Ql,safeGetCvmPreLaunchScript:ep,startCvm:gp,safeStartCvm:bp,stopCvm:vp,safeStopCvm:wp,shutdownCvm:Cp,safeShutdownCvm:kp,restartCvm:Sp,safeRestartCvm:Ip,deleteCvm:Bp,safeDeleteCvm:$p,getCvmStats:Fp,safeGetCvmStats:Hp,getCvmNetwork:Mp,safeGetCvmNetwork:Gp,getCvmDockerCompose:Vp,safeGetCvmDockerCompose:Kp,getCvmContainersStats:Zp,safeGetCvmContainersStats:Yp,getCvmAttestation:iu,safeGetCvmAttestation:au,updateCvmResources:lu,safeUpdateCvmResources:pu,updateCvmVisibility:fu,safeUpdateCvmVisibility:mu,getAvailableOsImages:gu,safeGetAvailableOsImages:bu,updateOsImage:vu,safeUpdateOsImage:wu,getKmsInfo:rp,safeGetKmsInfo:op,getKmsList:ip,safeGetKmsList:ap,getAppEnvEncryptPubKey:pp,safeGetAppEnvEncryptPubKey:up,nextAppIds:dp,safeNextAppIds:hp,getCvmState:ku,safeGetCvmState:Tu};return t.extend(r)}var Eu=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(),cg=Eu.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"]}),lg=U.object({appId:U.string(),appAuthAddress:U.string(),deployer:U.string(),transactionHash:U.string(),blockNumber:U.bigint().optional(),gasUsed:U.bigint().optional()}).passthrough();var ug=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"]}),fg=B.object({composeHash:B.string(),appId:B.string(),transactionHash:B.string(),blockNumber:B.bigint().optional(),gasUsed:B.bigint().optional()}).passthrough();var dg=pt.object({target:pt.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:pt.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:pt.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:pt.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:pt.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});import Js from"crypto";import Ws from"fs";import dt from"os";import mo from"path";import q from"chalk";import Bu from"ora";var Pu=!1;function me(){return Pu}function $u(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 Ks(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=$u(o,t);r.push(...n)}if(r.length===0){let o=e.trim();r.push(o)}return r}var Oe={error:(e,...t)=>{me()||(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)=>{me()||(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)=>{me()||(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)=>{me()||(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)=>{me()||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(!me()){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(me())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,T]of Object.entries(e)){l=Math.max(l,I.length);let P=String(T??"");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,T]of Object.entries(e)){let P=I,V=String(T??""),K=Ks(P,l),O=Ks(V,u),Q=Math.max(K.length,O.length);for(;K.length<Q;)K.push("");for(;O.length<Q;)O.push("");for(let ce=0;ce<Q;ce++){let te=K[ce].padEnd(l),Rt=O[ce].padEnd(u);console.log(r!=="none"?`${a.vertical} ${o(te)} ${a.vertical} ${n(Rt)} ${a.vertical}`:`${o(te)} : ${n(Rt)}`)}}r!=="none"&&console.log(a.bottomLeft+a.horizontal.repeat(h-2)+a.bottomRight)},break:()=>{me()||process.stderr.write(`
|
|
32
|
+
`)},startSpinner:e=>{if(me())return{stop:()=>{}};let t=Bu(e).start();return{stop:(r=!0,o)=>{o&&(t.text=o),r?t.succeed():t.fail()}}},logDetailedError(e,t){if(me())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 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};
|
|
37
|
+
`)}};var Zs=mo.join(dt.homedir(),".phala-cloud"),Xs=mo.join(Zs,"api-key"),zg=mo.join(Zs,"docker-credentials.json");function Ru(){let e=[dt.hostname(),dt.platform(),dt.arch(),dt.cpus()[0]?.model||"",dt.userInfo().username],t=Js.createHash("sha256");return t.update(e.join("|")),t.digest()}function Uu(e){try{let t=Ru(),r=e.split(":");if(r.length!==2)throw new Error("Invalid encrypted format");let o=Buffer.from(r[0],"hex"),n=r[1],s=Js.createDecipheriv("aes-256-cbc",t.slice(0,32),o),i=s.update(n,"hex","utf8");return i+=s.final("utf8"),i}catch(t){throw Oe.error("Decryption failed:",t),new Error("Failed to decrypt data")}}function Ys(){try{if(process.env.PHALA_CLOUD_API_KEY)return process.env.PHALA_CLOUD_API_KEY;if(Ws.existsSync(Xs)){let e=Ws.readFileSync(Xs,"utf8").trim();return Uu(e)}return null}catch(e){return Oe.error("Failed to read API key:",e),null}}async function N(){let e=Ys();return Vs({apiKey:e})}import{z as c}from"zod";var zu=c.object({password:c.string(),registry:c.string().nullable(),username:c.string()}),Mg=c.object({docker_compose_file:c.string(),docker_config:zu.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(),Qs=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()}),Gg=c.object({key:c.string(),value:c.string()}),ei=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()}))}),ti=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()}),ri=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()}),Fu=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()}),Dg=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(Fu).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 Hu from"inquirer";async function Ou(e){let t=await N(),r=e.replace(/^app_/,""),o=await mt(t,{app_id:r});if(!o.success)throw new Error(o.error.message);return o.data}async function Zg(e){let t=await N(),r=await fo(t,{id:e});if(!r.success)throw new Error(r.error.message);return r.data}async function Yg(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/network`);return ei.parse(o)}async function Qg(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.post(`cvms/app_${r}/start`);return(await mt(t,{app_id:r})).data}async function eb(e){let t=await N(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/stop`),(await mt(t,{app_id:r})).data}async function tb(e){let t=await N(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/restart`),(await mt(t,{app_id:r})).data}async function rb(e){let t=await N(),r=e.replace(/^app_/,"");return await t.delete(`cvms/app_${r}`),!0}async function ob(){let e=Oe.startSpinner("Fetching available CVMs"),t=await N(),r=await uo(t);if(e.stop(!0),!r.success){Oe.error(`Failed to fetch CVMs: ${r.error.message}`);return}let n=r.data.items;if(!n||n.length===0){Oe.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 Hu.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:s}]);return i}async function nb(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/attestation`);try{return ri.parse(o)}catch(n){return Oe.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 sb(e,t){let r=await N(),o=e.replace(/^app_/,""),n=await r.post(`cvms/app_${o}/replicas`,t);return ti.parse(n)}async function ib(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 ab(e){return await(await N()).post("cvms/pubkey/from_cvm_configuration",e)}async function cb(e){let r=await(await N()).post("cvms/from_cvm_configuration",e);return Qs.parse(r)}async function lb(e,t){let r=await N(),o=e.replace(/^app_/,"");return await r.put(`cvms/app_${o}/compose`,t)}async function pb(e=!1){let t=await N(),r="teepods/available";return e&&(r+="?v03x_only=1"),await t.get(r)}function vr(e,t){let r=[];t.follow&&r.push("follow"),t.tail&&r.push(`lines=${t.tail}`),t.timestamps&&r.push("timestamps"),r.push("ansi");let o=e.includes("?")?"&":"?";return e+o+r.join("&")}async function oi(e,t){let r=e.body?.getReader();if(!r)throw new Error("No response body available for streaming");let o=new TextDecoder;for(;;){let{done:n,value:s}=await r.read();if(n)break;t(o.decode(s,{stream:!0}))}}async function ni(e){let t=await Ou(e);if(!t.syslog_endpoint)throw new Error(`No syslog endpoint available for CVM '${e}'`);return`${t.syslog_endpoint}&ch=serial`}async function si(e,t){let o=await(await N()).get(`cvms/${e}/composition`);if(!o.containers?.length)throw new Error(`No containers found for CVM '${e}'`);let n=o.containers;if(t&&(n=n.filter(i=>i.names.some(a=>a===t||a===`/${t}`)||i.id.startsWith(t)),!n.length))throw new Error(`Container '${t}' not found in CVM '${e}'`);let s=n.find(i=>i.log_endpoint);if(!s?.log_endpoint)throw new Error(`No log endpoints available for CVM '${e}'`);return s.log_endpoint}async function ub(e,t={}){let r=await ni(e),o=vr(r,t),n=await fetch(o);if(!n.ok)throw new Error(`Failed to fetch serial logs: ${n.status} ${n.statusText}`);return n.text()}async function fb(e,t={}){let r=await si(e,t.container),o=vr(r,t),n=await fetch(o);if(!n.ok)throw new Error(`Failed to fetch container logs: ${n.status} ${n.statusText}`);return n.text()}async function mb(e,t,r={},o){let n=await ni(e),s=vr(n,{...r,follow:!0}),i=await fetch(s,{signal:o});if(!i.ok)throw new Error(`Failed to stream serial logs: ${i.status} ${i.statusText}`);await oi(i,t)}async function db(e,t,r={},o){let n=await si(e,r.container),s=vr(n,{...r,follow:!0}),i=await fetch(s,{signal:o});if(!i.ok)throw new Error(`Failed to stream container logs: ${i.status} ${i.statusText}`);await oi(i,t)}export{Mg as composeFileSchema,cb as createCvm,ri as cvmAttestationResponseSchema,rb as deleteCvm,zu as dockerConfigSchema,Gg as encryptedEnvItemSchema,fb as fetchContainerLogs,ub as fetchSerialLogs,nb as getCvmAttestation,Ou as getCvmByAppId,Zg as getCvmComposeConfig,Yg as getCvmNetwork,ei as getCvmNetworkResponseSchema,ab as getPubkeyFromCvm,pb as getTeepods,Fu as imageSchema,Qs as postCvmResponseSchema,sb as replicateCvm,ti as replicateCvmResponseSchema,ib as resizeCvm,tb as restartCvm,ob as selectCvm,Qg as startCvm,eb as stopCvm,db as streamContainerLogs,mb as streamSerialLogs,Dg as teepodSchema,lb as upgradeCvm};
|
|
38
38
|
/*! Bundled license information:
|
|
39
39
|
|
|
40
40
|
@noble/hashes/esm/utils.js:
|
|
41
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
42
|
-
|
|
43
41
|
@noble/hashes/utils.js:
|
|
44
42
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
45
43
|
*/
|