phala 1.1.10 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +29 -29
- package/dist/index.js +177 -174
- package/package.json +1 -1
package/dist/api/index.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
2
|
-
var
|
|
2
|
+
var Gi=Object.create;var qn=Object.defineProperty;var qi=Object.getOwnPropertyDescriptor;var Di=Object.getOwnPropertyNames;var Mi=Object.getPrototypeOf,Vi=Object.prototype.hasOwnProperty;var He=(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,t)=>()=>(e&&(t=e(e=0)),t);var fe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ki=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Di(t))!Vi.call(e,o)&&o!==r&&qn(e,o,{get:()=>t[o],enumerable:!(n=qi(t,o))||n.enumerable});return e};var At=(e,t,r)=>(r=e!=null?Gi(Mi(e)):{},Ki(t||!e||!e.__esModule?qn(r,"default",{value:e,enumerable:!0}):r,e));var Mn=fe((Bm,Dn)=>{var lt=1e3,ut=lt*60,pt=ut*60,Ye=pt*24,Wi=Ye*7,Xi=Ye*365.25;Dn.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Ji(e);if(r==="number"&&isFinite(e))return t.long?Yi(e):Zi(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Ji(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]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Xi;case"weeks":case"week":case"w":return r*Wi;case"days":case"day":case"d":return r*Ye;case"hours":case"hour":case"hrs":case"hr":case"h":return r*pt;case"minutes":case"minute":case"mins":case"min":case"m":return r*ut;case"seconds":case"second":case"secs":case"sec":case"s":return r*lt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Zi(e){var t=Math.abs(e);return t>=Ye?Math.round(e/Ye)+"d":t>=pt?Math.round(e/pt)+"h":t>=ut?Math.round(e/ut)+"m":t>=lt?Math.round(e/lt)+"s":e+"ms"}function Yi(e){var t=Math.abs(e);return t>=Ye?Zt(e,t,Ye,"day"):t>=pt?Zt(e,t,pt,"hour"):t>=ut?Zt(e,t,ut,"minute"):t>=lt?Zt(e,t,lt,"second"):e+" ms"}function Zt(e,t,r,n){var o=t>=r*1.5;return Math.round(e/r)+" "+n+(o?"s":"")}});var Gr=fe((jm,Vn)=>{function Qi(e){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=o,r.enabled=a,r.humanize=Mn(),r.destroy=u,Object.keys(e).forEach(p=>{r[p]=e[p]}),r.names=[],r.skips=[],r.formatters={};function t(p){let f=0;for(let h=0;h<p.length;h++)f=(f<<5)-f+p.charCodeAt(h),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(p){let f,h=null,g,_;function P(...z){if(!P.enabled)return;let G=P,Z=Number(new Date),K=Z-(f||Z);G.diff=K,G.prev=f,G.curr=Z,f=Z,z[0]=r.coerce(z[0]),typeof z[0]!="string"&&z.unshift("%O");let Y=0;z[0]=z[0].replace(/%([a-zA-Z%])/g,(pe,Jt)=>{if(pe==="%%")return"%";Y++;let Gn=r.formatters[Jt];if(typeof Gn=="function"){let Ni=z[Y];pe=Gn.call(G,Ni),z.splice(Y,1),Y--}return pe}),r.formatArgs.call(G,z),(G.log||r.log).apply(G,z)}return P.namespace=p,P.useColors=r.useColors(),P.color=r.selectColor(p),P.extend=n,P.destroy=r.destroy,Object.defineProperty(P,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(g!==r.namespaces&&(g=r.namespaces,_=r.enabled(p)),_),set:z=>{h=z}}),typeof r.init=="function"&&r.init(P),P}function n(p,f){let h=r(this.namespace+(typeof f>"u"?":":f)+p);return h.log=this.log,h}function o(p){r.save(p),r.namespaces=p,r.names=[],r.skips=[];let f=(typeof p=="string"?p:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let h of f)h[0]==="-"?r.skips.push(h.slice(1)):r.names.push(h)}function s(p,f){let h=0,g=0,_=-1,P=0;for(;h<p.length;)if(g<f.length&&(f[g]===p[h]||f[g]==="*"))f[g]==="*"?(_=g,P=h,g++):(h++,g++);else if(_!==-1)g=_+1,P++,h=P;else return!1;for(;g<f.length&&f[g]==="*";)g++;return g===f.length}function i(){let p=[...r.names,...r.skips.map(f=>"-"+f)].join(",");return r.enable(""),p}function a(p){for(let f of r.skips)if(s(p,f))return!1;for(let f of r.names)if(s(p,f))return!0;return!1}function l(p){return p instanceof Error?p.stack||p.message:p}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}Vn.exports=Qi});var Kn=fe((se,Yt)=>{se.formatArgs=ta;se.save=ra;se.load=na;se.useColors=ea;se.storage=oa();se.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`."))}})();se.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 ea(){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 ta(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Yt.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}se.log=console.debug||console.log||(()=>{});function ra(e){try{e?se.storage.setItem("debug",e):se.storage.removeItem("debug")}catch{}}function na(){let e;try{e=se.storage.getItem("debug")||se.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function oa(){try{return localStorage}catch{}}Yt.exports=Gr()(se);var{formatters:sa}=Yt.exports;sa.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Xn=fe((q,er)=>{var ia=He("tty"),Qt=He("util");q.init=ma;q.log=ua;q.formatArgs=ca;q.save=pa;q.load=fa;q.useColors=aa;q.destroy=Qt.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");q.colors=[6,2,3,4,5,1];try{let e=He("supports-color");e&&(e.stderr||e).level>=2&&(q.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{}q.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(o,s)=>s.toUpperCase()),n=process.env[t];return/^(yes|on|true|enabled)$/i.test(n)?n=!0:/^(no|off|false|disabled)$/i.test(n)?n=!1:n==="null"?n=null:n=Number(n),e[r]=n,e},{});function aa(){return"colors"in q.inspectOpts?!!q.inspectOpts.colors:ia.isatty(process.stderr.fd)}function ca(e){let{namespace:t,useColors:r}=this;if(r){let n=this.color,o="\x1B[3"+(n<8?n:"8;5;"+n),s=` ${o};1m${t} \x1B[0m`;e[0]=s+e[0].split(`
|
|
3
3
|
`).join(`
|
|
4
|
-
`+s),e.push(o+"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=n,this.docsPath=o,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=Gr}walk(t){return Zn(this,t)}}});var Yt,Qt,Dr=$(()=>{fe();Yt=class extends v{constructor({max:t,min:r,signed:n,size:o,value:s}){super(`Number "${s}" is not in safe ${o?`${o*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${r} to ${t})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}},Qt=class extends v{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function _e(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var ut=$(()=>{});function me(e){return _e(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var It=$(()=>{ut()});function At(e,{dir:t="left"}={}){let r=typeof e=="string"?e.replace("0x",""):e,n=0;for(let o=0;o<r.length-1&&r[t==="left"?o:r.length-o-1].toString()==="0";o++)n++;return r=t==="left"?r.slice(n):r.slice(0,r.length-n),typeof e=="string"?(r.length===1&&t==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}var Yn=$(()=>{});var Pt,$t,Mr=$(()=>{fe();Pt=class extends v{constructor({offset:t,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},$t=class extends v{constructor({size:t,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}});function Ue(e,{dir:t,size:r=32}={}){return typeof e=="string"?pa(e,{dir:t,size:r}):fa(e,{dir:t,size:r})}function pa(e,{dir:t,size:r=32}={}){if(r===null)return e;let n=e.replace("0x","");if(n.length>r*2)throw new $t({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function fa(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new $t({size:e.length,targetSize:r,type:"bytes"});let n=new Uint8Array(r);for(let o=0;o<r;o++){let s=t==="right";n[s?o:r-o-1]=e[s?o:e.length-o-1]}return n}var Vr=$(()=>{Mr()});function ge(e,t={}){return typeof e=="number"||typeof e=="bigint"?E(e,t):typeof e=="string"?ga(e,t):typeof e=="boolean"?da(e,t):oe(e,t)}function da(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(Fe(r,{size:t.size}),Ue(r,{size:t.size})):r}function oe(e,t={}){let r="";for(let o=0;o<e.length;o++)r+=ma[e[o]];let n=`0x${r}`;return typeof t.size=="number"?(Fe(n,{size:t.size}),Ue(n,{dir:"right",size:t.size})):n}function E(e,t={}){let{signed:r,size:n}=t,o=BigInt(e),s;n?r?s=(1n<<BigInt(n)*8n-1n)-1n:s=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));let i=typeof s=="bigint"&&r?-s-1n:0;if(s&&o>s||o<i){let l=typeof e=="bigint"?"n":"";throw new Yt({max:s?`${s}${l}`:void 0,min:`${i}${l}`,signed:r,size:n,value:`${e}${l}`})}let a=`0x${(r&&o<0?(1n<<BigInt(n*8))+BigInt(o):o).toString(16)}`;return n?Ue(a,{size:n}):a}function ga(e,t={}){let r=ha.encode(e);return oe(r,t)}var ma,ha,de=$(()=>{Dr();Vr();Ye();ma=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));ha=new TextEncoder});function er(e,t={}){return typeof e=="number"||typeof e=="bigint"?ya(e,t):typeof e=="boolean"?xa(e,t):_e(e)?be(e,t):Kr(e,t)}function xa(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(Fe(r,{size:t.size}),Ue(r,{size:t.size})):r}function Qn(e){if(e>=Le.zero&&e<=Le.nine)return e-Le.zero;if(e>=Le.A&&e<=Le.F)return e-(Le.A-10);if(e>=Le.a&&e<=Le.f)return e-(Le.a-10)}function be(e,t={}){let r=e;t.size&&(Fe(r,{size:t.size}),r=Ue(r,{dir:"right",size:t.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);let o=n.length/2,s=new Uint8Array(o);for(let i=0,a=0;i<o;i++){let l=Qn(n.charCodeAt(a++)),u=Qn(n.charCodeAt(a++));if(l===void 0||u===void 0)throw new v(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);s[i]=l*16+u}return s}function ya(e,t){let r=E(e,t);return be(r)}function Kr(e,t={}){let r=ba.encode(e);return typeof t.size=="number"?(Fe(r,{size:t.size}),Ue(r,{dir:"right",size:t.size})):r}var ba,Le,He=$(()=>{fe();ut();Vr();Ye();de();ba=new TextEncoder;Le={zero:48,nine:57,A:65,F:70,a:97,f:102}});function Fe(e,{size:t}){if(me(e)>t)throw new Qt({givenSize:me(e),maxSize:t})}function Qe(e,t={}){let{signed:r}=t;t.size&&Fe(e,{size:t.size});let n=BigInt(e);if(!r)return n;let o=(e.length-2)/2,s=(1n<<BigInt(o)*8n-1n)-1n;return n<=s?n:n-BigInt(`0x${"f".padStart(o*2,"f")}`)-1n}function et(e,t={}){return Number(Qe(e,t))}var Ye=$(()=>{Dr();It()});function pt(e,t){return({exclude:r,format:n})=>({exclude:r,format:(o,s)=>{let i=t(o,s);if(r)for(let a of r)delete i[a];return{...i,...n(o,s)}},type:e})}var tr=$(()=>{});var xd,yd,vd,wd,_d,Cd,kd,Sd,Ed,Td,Id,Ad,Pd,$d,Ld,zd,Bd,Rd,jd,Ud,Fd,Hd,Od,Nd,Gd,qd,Dd,Md,Vd,Kd,Wd,Xd,Jd,Zd,Yd,Qd,eh,th,rh,nh,oh,sh,ih,ah,ch,lh,uh,ph,fh,mh,dh,hh,gh,bh,xh,yh,vh,wh,_h,Ch,kh,Sh,Eh,Th,Ih,Ah,Ph,$h,Lh,zh,Bh,Rh,jh,Uh,Fh,Hh,Oh,Nh,Gh,qh,Dh,Mh,Vh,Kh,Wh,Xh,Jh,Zh,Yh,Qh,eg,tg,rg,ng,og,rr,oo=$(()=>{xd=2n**(8n-1n)-1n,yd=2n**(16n-1n)-1n,vd=2n**(24n-1n)-1n,wd=2n**(32n-1n)-1n,_d=2n**(40n-1n)-1n,Cd=2n**(48n-1n)-1n,kd=2n**(56n-1n)-1n,Sd=2n**(64n-1n)-1n,Ed=2n**(72n-1n)-1n,Td=2n**(80n-1n)-1n,Id=2n**(88n-1n)-1n,Ad=2n**(96n-1n)-1n,Pd=2n**(104n-1n)-1n,$d=2n**(112n-1n)-1n,Ld=2n**(120n-1n)-1n,zd=2n**(128n-1n)-1n,Bd=2n**(136n-1n)-1n,Rd=2n**(144n-1n)-1n,jd=2n**(152n-1n)-1n,Ud=2n**(160n-1n)-1n,Fd=2n**(168n-1n)-1n,Hd=2n**(176n-1n)-1n,Od=2n**(184n-1n)-1n,Nd=2n**(192n-1n)-1n,Gd=2n**(200n-1n)-1n,qd=2n**(208n-1n)-1n,Dd=2n**(216n-1n)-1n,Md=2n**(224n-1n)-1n,Vd=2n**(232n-1n)-1n,Kd=2n**(240n-1n)-1n,Wd=2n**(248n-1n)-1n,Xd=2n**(256n-1n)-1n,Jd=-(2n**(8n-1n)),Zd=-(2n**(16n-1n)),Yd=-(2n**(24n-1n)),Qd=-(2n**(32n-1n)),eh=-(2n**(40n-1n)),th=-(2n**(48n-1n)),rh=-(2n**(56n-1n)),nh=-(2n**(64n-1n)),oh=-(2n**(72n-1n)),sh=-(2n**(80n-1n)),ih=-(2n**(88n-1n)),ah=-(2n**(96n-1n)),ch=-(2n**(104n-1n)),lh=-(2n**(112n-1n)),uh=-(2n**(120n-1n)),ph=-(2n**(128n-1n)),fh=-(2n**(136n-1n)),mh=-(2n**(144n-1n)),dh=-(2n**(152n-1n)),hh=-(2n**(160n-1n)),gh=-(2n**(168n-1n)),bh=-(2n**(176n-1n)),xh=-(2n**(184n-1n)),yh=-(2n**(192n-1n)),vh=-(2n**(200n-1n)),wh=-(2n**(208n-1n)),_h=-(2n**(216n-1n)),Ch=-(2n**(224n-1n)),kh=-(2n**(232n-1n)),Sh=-(2n**(240n-1n)),Eh=-(2n**(248n-1n)),Th=-(2n**(256n-1n)),Ih=2n**8n-1n,Ah=2n**16n-1n,Ph=2n**24n-1n,$h=2n**32n-1n,Lh=2n**40n-1n,zh=2n**48n-1n,Bh=2n**56n-1n,Rh=2n**64n-1n,jh=2n**72n-1n,Uh=2n**80n-1n,Fh=2n**88n-1n,Hh=2n**96n-1n,Oh=2n**104n-1n,Nh=2n**112n-1n,Gh=2n**120n-1n,qh=2n**128n-1n,Dh=2n**136n-1n,Mh=2n**144n-1n,Vh=2n**152n-1n,Kh=2n**160n-1n,Wh=2n**168n-1n,Xh=2n**176n-1n,Jh=2n**184n-1n,Zh=2n**192n-1n,Yh=2n**200n-1n,Qh=2n**208n-1n,eg=2n**216n-1n,tg=2n**224n-1n,rg=2n**232n-1n,ng=2n**240n-1n,og=2n**248n-1n,rr=2n**256n-1n});function tt(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var Xr=$(()=>{});var zt,nr,or,so=$(()=>{fe();zt=class extends v{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},nr=class extends v{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},or=class extends v{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function sr(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(ka);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var ka,Jr=$(()=>{so();ka={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 or({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new nr({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new zt({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 zt({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 co,lo=$(()=>{co={ether:-9,wei:9}});function uo(e,t){let r=e.toString(),n=r.startsWith("-");n&&(r=r.slice(1)),r=r.padStart(t,"0");let[o,s]=[r.slice(0,r.length-t),r.slice(r.length-t)];return s=s.replace(/(0+)$/,""),`${n?"-":""}${o||"0"}${s?`.${s}`:""}`}var po=$(()=>{});function Bt(e,t="wei"){return uo(e,co[t])}var fo=$(()=>{lo();po()});function Ta(e){let t=Object.entries(e).map(([n,o])=>o===void 0||o===!1?null:[n,o]).filter(Boolean),r=t.reduce((n,[o])=>Math.max(n,o.length),0);return t.map(([n,o])=>` ${`${n}:`.padEnd(r+1)} ${o}`).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(jt,"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 gt,cn=$(()=>{gt=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 n=this.keys().next().value;n&&this.delete(n)}return this}}});function Ma(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){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],p=r[l+1],f=Bo(u,p,1)^r[a],h=Ro(u,p,1)^r[a+1];for(let g=0;g<50;g+=10)e[i+g]^=f,e[i+g+1]^=h}let o=e[2],s=e[3];for(let i=0;i<24;i++){let a=Uo[i],l=Bo(o,s,a),u=Ro(o,s,a),p=jo[i];o=e[p],s=e[p+1],e[p]=l,e[p+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]^=qa[n],e[1]^=Da[n]}Oe(r)}var Fa,Ut,Ha,Oa,Na,Ga,jo,Uo,Fo,Ho,qa,Da,Bo,Ro,ln,Va,Oo,No=$(()=>{ko();hr();Fa=BigInt(0),Ut=BigInt(1),Ha=BigInt(2),Oa=BigInt(7),Na=BigInt(256),Ga=BigInt(113),jo=[],Uo=[],Fo=[];for(let e=0,t=Ut,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],jo.push(2*(5*n+r)),Uo.push((e+1)*(e+2)/2%64);let o=Fa;for(let s=0;s<7;s++)t=(t<<Ut^(t>>Oa)*Ga)%Na,t&Ha&&(o^=Ut<<(Ut<<BigInt(s))-Ut);Fo.push(o)}Ho=yo(Fo,!0),qa=Ho[0],Da=Ho[1],Bo=(e,t,r)=>r>32?_o(e,t,r):vo(e,t,r),Ro=(e,t,r)=>r>32?Co(e,t,r):wo(e,t,r);ln=class e extends mt{constructor(t,r,n,o=!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=n,this.enableXOF=o,this.rounds=s,Zr(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=ho(this.state)}clone(){return this._cloneInto()}keccak(){Yr(this.state32),Ma(this.state32,this.rounds),Yr(this.state32),this.posOut=0,this.pos=0}update(t){dt(this),t=Rt(t),rt(t);let{blockLen:r,state:n}=this,o=t.length;for(let s=0;s<o;){let i=Math.min(r-this.pos,o-s);for(let a=0;a<i;a++)n[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:n,blockLen:o}=this;t[n]^=r,(r&128)!==0&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){dt(this,!1),rt(t),this.finish();let r=this.state,{blockLen:n}=this;for(let o=0,s=t.length;o<s;){this.posOut>=n&&this.keccak();let i=Math.min(n-this.posOut,s-o);t.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=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 Zr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(fr(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,Oe(this.state)}_cloneInto(t){let{blockLen:r,suffix:n,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new e(r,n,o,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}},Va=(e,t,r)=>dr(()=>new ln(t,e,r)),Oo=Va(1,136,256/8)});function Go(e,t){let r=t||"hex",n=Oo(_e(e,{strict:!1})?er(e):e);return r==="bytes"?n:ge(n)}var qo=$(()=>{No();ut();He();de()});function Do(e,t){if(un.has(`${e}.${t}`))return un.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),n=Go(Kr(r),"bytes"),o=(t?r.substring(`${t}0x`.length):r).split("");for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&o[i]&&(o[i]=o[i].toUpperCase()),(n[i>>1]&15)>=8&&o[i+1]&&(o[i+1]=o[i+1].toUpperCase());let s=`0x${o.join("")}`;return un.set(`${e}.${t}`,s),s}var un,Mo=$(()=>{He();qo();cn();un=new gt(8192)});function Ce(e,t){let{strict:r=!0}=t??{},n=`${e}.${r}`;if(pn.has(n))return pn.get(n);let o=Ka.test(e)?e.toLowerCase()===e?!0:r?Do(e)===e:!0:!1;return pn.set(n,o),o}var Ka,pn,kr=$(()=>{cn();Mo();Ka=/^0x[a-fA-F0-9]{40}$/,pn=new gt(8192)});function Vo(e,t,r,{strict:n}={}){return _e(e,{strict:!1})?Xa(e,t,r,{strict:n}):Wa(e,t,r,{strict:n})}function Ko(e,t){if(typeof t=="number"&&t>0&&t>me(e)-1)throw new Pt({offset:t,position:"start",size:me(e)})}function Wo(e,t,r){if(typeof t=="number"&&typeof r=="number"&&me(e)!==r-t)throw new Pt({offset:r,position:"end",size:me(e)})}function Wa(e,t,r,{strict:n}={}){Ko(e,t);let o=e.slice(t,r);return n&&Wo(o,t,r),o}function Xa(e,t,r,{strict:n}={}){Ko(e,t);let o=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return n&&Wo(o,t,r),o}var Xo=$(()=>{Mr();ut();It()});var hn=pe(Nt=>{"use strict";var ic=Nt&&Nt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Nt,"__esModule",{value:!0});Nt.encryptEnvVars=lc;var mn=je("@noble/curves/ed25519"),dn=ic(je("crypto"));function ac(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(n=>parseInt(n,16)))!==null&&r!==void 0?r:[])}function cc(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function lc(e,t){let r=JSON.stringify({env:e}),n=mn.x25519.utils.randomPrivateKey(),o=mn.x25519.getPublicKey(n),s=ac(t),i=mn.x25519.getSharedSecret(n,s),a=await dn.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=dn.default.getRandomValues(new Uint8Array(12)),u=await dn.default.subtle.encrypt({name:"AES-GCM",iv:l},a,new TextEncoder().encode(r)),p=new Uint8Array(o.length+l.length+u.byteLength);return p.set(o),p.set(l,o.length),p.set(new Uint8Array(u),o.length+l.length),cc(p)}});var ss=pe(Gt=>{"use strict";var uc=Gt&&Gt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Gt,"__esModule",{value:!0});Gt.getComposeHash=dc;var pc=uc(je("crypto"));function gn(e){return e==null?e:Array.isArray(e)?e.map(gn):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let n=e[r];return t[r]=gn(n),t},{}):e}function fc(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 mc(e){let t=gn(e);return JSON.stringify(t,(r,n)=>typeof n=="number"&&(isNaN(n)||!isFinite(n))?null:n)}function dc(e,t=!1){t&&(e=fc(e));let r=mc(e);return pc.default.createHash("sha256").update(r,"utf8").digest("hex")}});var Ts=pe(w=>{"use strict";Object.defineProperty(w,"__esModule",{value:!0});w.toBig=w.shrSL=w.shrSH=w.rotrSL=w.rotrSH=w.rotrBL=w.rotrBH=w.rotr32L=w.rotr32H=w.rotlSL=w.rotlSH=w.rotlBL=w.rotlBH=w.add5L=w.add5H=w.add4L=w.add4H=w.add3L=w.add3H=void 0;w.add=vs;w.fromBig=xn;w.split=is;var Ir=BigInt(2**32-1),bn=BigInt(32);function xn(e,t=!1){return t?{h:Number(e&Ir),l:Number(e>>bn&Ir)}:{h:Number(e>>bn&Ir)|0,l:Number(e&Ir)|0}}function is(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=xn(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var as=(e,t)=>BigInt(e>>>0)<<bn|BigInt(t>>>0);w.toBig=as;var cs=(e,t,r)=>e>>>r;w.shrSH=cs;var ls=(e,t,r)=>e<<32-r|t>>>r;w.shrSL=ls;var us=(e,t,r)=>e>>>r|t<<32-r;w.rotrSH=us;var ps=(e,t,r)=>e<<32-r|t>>>r;w.rotrSL=ps;var fs=(e,t,r)=>e<<64-r|t>>>r-32;w.rotrBH=fs;var ms=(e,t,r)=>e>>>r-32|t<<64-r;w.rotrBL=ms;var ds=(e,t)=>t;w.rotr32H=ds;var hs=(e,t)=>e;w.rotr32L=hs;var gs=(e,t,r)=>e<<r|t>>>32-r;w.rotlSH=gs;var bs=(e,t,r)=>t<<r|e>>>32-r;w.rotlSL=bs;var xs=(e,t,r)=>t<<r-32|e>>>64-r;w.rotlBH=xs;var ys=(e,t,r)=>e<<r-32|t>>>64-r;w.rotlBL=ys;function vs(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var ws=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);w.add3L=ws;var _s=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;w.add3H=_s;var Cs=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);w.add4L=Cs;var ks=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0;w.add4H=ks;var Ss=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0);w.add5L=Ss;var Es=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;w.add5H=Es;var hc={fromBig:xn,split:is,toBig:as,shrSH:cs,shrSL:ls,rotrSH:us,rotrSL:ps,rotrBH:fs,rotrBL:ms,rotr32H:ds,rotr32L:hs,rotlSH:gs,rotlSL:bs,rotlBH:xs,rotlBL:ys,add:vs,add3L:ws,add3H:_s,add4L:Cs,add4H:ks,add5H:Es,add5L:Ss};w.default=hc});var Is=pe(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.crypto=void 0;var Ge=je("crypto");Ar.crypto=Ge&&typeof Ge=="object"&&"webcrypto"in Ge?Ge.webcrypto:Ge&&typeof Ge=="object"&&"randomBytes"in Ge?Ge:void 0});var js=pe(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=yn;x.abytes=xt;x.ahash=gc;x.aexists=bc;x.aoutput=xc;x.u8=yc;x.u32=vc;x.clean=wc;x.createView=_c;x.rotr=Cc;x.rotl=kc;x.byteSwap=wn;x.byteSwap32=$s;x.bytesToHex=Ec;x.hexToBytes=Tc;x.asyncLoop=Ac;x.utf8ToBytes=_n;x.bytesToUtf8=Pc;x.toBytes=Pr;x.kdfInputToBytes=$c;x.concatBytes=Lc;x.checkOpts=zc;x.createHasher=zs;x.createOptHasher=Bs;x.createXOFer=Rs;x.randomBytes=Bc;var bt=Is();function Ps(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function yn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function xt(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 gc(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");yn(e.outputLen),yn(e.blockLen)}function bc(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 xc(e,t){xt(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function yc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function vc(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function wc(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function _c(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Cc(e,t){return e<<32-t|e>>>t}function kc(e,t){return e<<t|e>>>32-t>>>0}x.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function wn(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}x.swap8IfBE=x.isLE?e=>e:e=>wn(e);x.byteSwapIfBE=x.swap8IfBE;function $s(e){for(let t=0;t<e.length;t++)e[t]=wn(e[t]);return e}x.swap32IfBE=x.isLE?e=>e:$s;var Ls=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Sc=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ec(e){if(xt(e),Ls)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Sc[e[r]];return t}var Re={_0:48,_9:57,A:65,F:70,a:97,f:102};function As(e){if(e>=Re._0&&e<=Re._9)return e-Re._0;if(e>=Re.A&&e<=Re.F)return e-(Re.A-10);if(e>=Re.a&&e<=Re.f)return e-(Re.a-10)}function Tc(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Ls)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 n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=As(e.charCodeAt(s)),a=As(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)}n[o]=i*16+a}return n}var Ic=async()=>{};x.nextTick=Ic;async function Ac(e,t,r){let n=Date.now();for(let o=0;o<e;o++){r(o);let s=Date.now()-n;s>=0&&s<t||(await(0,x.nextTick)(),n+=s)}}function _n(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Pc(e){return new TextDecoder().decode(e)}function Pr(e){return typeof e=="string"&&(e=_n(e)),xt(e),e}function $c(e){return typeof e=="string"&&(e=_n(e)),xt(e),e}function Lc(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];xt(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}function zc(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 vn=class{};x.Hash=vn;function zs(e){let t=n=>e().update(Pr(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Bs(e){let t=(n,o)=>e(o).update(Pr(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function Rs(e){let t=(n,o)=>e(o).update(Pr(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}x.wrapConstructor=zs;x.wrapConstructorWithOpts=Bs;x.wrapXOFConstructorWithOpts=Rs;function Bc(e=32){if(bt.crypto&&typeof bt.crypto.getRandomValues=="function")return bt.crypto.getRandomValues(new Uint8Array(e));if(bt.crypto&&typeof bt.crypto.randomBytes=="function")return Uint8Array.from(bt.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var Ms=pe(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.shake256=R.shake128=R.keccak_512=R.keccak_384=R.keccak_256=R.keccak_224=R.sha3_512=R.sha3_384=R.sha3_256=R.sha3_224=R.Keccak=void 0;R.keccakP=qs;var Dt=Ts(),K=js(),Rc=BigInt(0),qt=BigInt(1),jc=BigInt(2),Uc=BigInt(7),Fc=BigInt(256),Hc=BigInt(113),Hs=[],Os=[],Ns=[];for(let e=0,t=qt,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Hs.push(2*(5*n+r)),Os.push((e+1)*(e+2)/2%64);let o=Rc;for(let s=0;s<7;s++)t=(t<<qt^(t>>Uc)*Hc)%Fc,t&jc&&(o^=qt<<(qt<<BigInt(s))-qt);Ns.push(o)}var Gs=(0,Dt.split)(Ns,!0),Oc=Gs[0],Nc=Gs[1],Us=(e,t,r)=>r>32?(0,Dt.rotlBH)(e,t,r):(0,Dt.rotlSH)(e,t,r),Fs=(e,t,r)=>r>32?(0,Dt.rotlBL)(e,t,r):(0,Dt.rotlSL)(e,t,r);function qs(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){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],p=r[l+1],f=Us(u,p,1)^r[a],h=Fs(u,p,1)^r[a+1];for(let g=0;g<50;g+=10)e[i+g]^=f,e[i+g+1]^=h}let o=e[2],s=e[3];for(let i=0;i<24;i++){let a=Os[i],l=Us(o,s,a),u=Fs(o,s,a),p=Hs[i];o=e[p],s=e[p+1],e[p]=l,e[p+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]^=Oc[n],e[1]^=Nc[n]}(0,K.clean)(r)}var Mt=class e extends K.Hash{constructor(t,r,n,o=!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=n,this.enableXOF=o,this.rounds=s,(0,K.anumber)(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,K.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,K.swap32IfBE)(this.state32),qs(this.state32,this.rounds),(0,K.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(t){(0,K.aexists)(this),t=(0,K.toBytes)(t),(0,K.abytes)(t);let{blockLen:r,state:n}=this,o=t.length;for(let s=0;s<o;){let i=Math.min(r-this.pos,o-s);for(let a=0;a<i;a++)n[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:n,blockLen:o}=this;t[n]^=r,(r&128)!==0&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){(0,K.aexists)(this,!1),(0,K.abytes)(t),this.finish();let r=this.state,{blockLen:n}=this;for(let o=0,s=t.length;o<s;){this.posOut>=n&&this.keccak();let i=Math.min(n-this.posOut,s-o);t.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=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,K.anumber)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,K.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,K.clean)(this.state)}_cloneInto(t){let{blockLen:r,suffix:n,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new e(r,n,o,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}};R.Keccak=Mt;var qe=(e,t,r)=>(0,K.createHasher)(()=>new Mt(t,e,r));R.sha3_224=qe(6,144,224/8);R.sha3_256=qe(6,136,256/8);R.sha3_384=qe(6,104,384/8);R.sha3_512=qe(6,72,512/8);R.keccak_224=qe(1,144,224/8);R.keccak_256=qe(1,136,256/8);R.keccak_384=qe(1,104,384/8);R.keccak_512=qe(1,72,512/8);var Ds=(e,t,r)=>(0,K.createXOFer)((n={})=>new Mt(t,e,n.dkLen===void 0?r:n.dkLen,!0));R.shake128=Ds(31,168,128/8);R.shake256=Ds(31,136,256/8)});var Vs=pe(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.verifyEnvEncryptPublicKey=Dc;var Gc=Ms(),qc=je("@noble/curves/secp256k1");function Dc(e,t,r){if(t.length!==65)return null;let n=Buffer.from("dstack-env-encrypt-pubkey","utf8"),o=r;r.startsWith("0x")&&(o=r.slice(2));let s=Buffer.from(o,"hex"),i=Buffer.from(":","utf8"),a=Buffer.concat([n,i,s,Buffer.from(e)]),l=(0,Gc.keccak_256)(a);try{let u=t.slice(0,32),p=t.slice(32,64),f=t[64],h=new Uint8Array(64);h.set(u,0),h.set(p,32);let g=qc.secp256k1.Signature.fromCompact(h).addRecoveryBit(f).recoverPublicKey(l);return"0x"+Buffer.from(g.toRawBytes(!0)).toString("hex")}catch(u){return console.error("signature verification failed:",u),null}}});var ei=Tt(Wn(),1);import{ofetch as Mc}from"ofetch";function Xn(e){return{all:e=e||new Map,on:function(t,r){var n=e.get(t);n?n.push(r):e.set(t,[r])},off:function(t,r){var n=e.get(t);n&&(r?n.splice(n.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var n=e.get(t);n&&n.slice().map(function(o){o(r)}),(n=e.get("*"))&&n.slice().map(function(o){o(t,r)})}}}import{z as D}from"zod";import{z as j}from"zod";import{z as De}from"zod";import{z as k}from"zod";import{z as Me}from"zod";function Ze(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}tr();Ye();tr();var Wr={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function Lt(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?et(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?et(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Wr[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=va(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 eo=pt("transaction",Lt);function va(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 wa(e,t){let r=(e.transactions??[]).map(n=>typeof n=="string"?n:Lt(n));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 to=pt("block",wa);function ro(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}:{}}}Ye();tr();var _a={"0x0":"reverted","0x1":"success"};function Ca(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(n=>ro(n)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?et(e.transactionIndex):null,status:e.status?_a[e.status]:null,type:e.type?Wr[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var no=pt("transactionReceipt",Ca);fe();Jr();He();de();function ze(e,t="hex"){let r=io(e),n=sr(new Uint8Array(r.length));return r.encode(n),t==="hex"?oe(n.bytes):n.bytes}function io(e){return Array.isArray(e)?Sa(e.map(t=>io(t))):Ea(e)}function Sa(e){let t=e.reduce((o,s)=>o+s.length,0),r=ao(t);return{length:t<=55?1+t:1+r+t,encode(o){t<=55?o.pushByte(192+t):(o.pushByte(247+r),r===1?o.pushUint8(t):r===2?o.pushUint16(t):r===3?o.pushUint24(t):o.pushUint32(t));for(let{encode:s}of e)s(o)}}}function Ea(e){let t=typeof e=="string"?be(e):e,r=ao(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length,encode(o){t.length===1&&t[0]<128?o.pushBytes(t):t.length<=55?(o.pushByte(128+t.length),o.pushBytes(t)):(o.pushByte(183+r),r===1?o.pushUint8(t.length):r===2?o.pushUint16(t.length):r===3?o.pushUint24(t.length):o.pushUint32(t.length),o.pushBytes(t))}}}function ao(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 v("Length is too large.")}lr();de();function mo(e){if(!e||e.length===0)return[];let t=[];for(let r of e){let{chainId:n,nonce:o,...s}=r,i=r.address;t.push([n?ge(n):"0x",i,o?ge(o):"0x",...ft({},s)])}return t}He();de();function ur(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(s=>be(s)):e.blobs,o=[];for(let s of n)o.push(Uint8Array.from(t.blobToKzgCommitment(s)));return r==="bytes"?o:o.map(s=>oe(s))}He();de();function pr(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(i=>be(i)):e.blobs,o=typeof e.commitments[0]=="string"?e.commitments.map(i=>be(i)):e.commitments,s=[];for(let i=0;i<n.length;i++){let a=n[i],l=o[i];s.push(Uint8Array.from(t.computeBlobKzgProof(a,l)))}return r==="bytes"?s:s.map(i=>oe(i))}de();hr();function za(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),a=Number(r&s),l=n?4:0,u=n?0:4;e.setUint32(t+l,i,n),e.setUint32(t+u,a,n)}function go(e,t,r){return e&t^~e&r}function bo(e,t,r){return e&t^e&r^t&r}var gr=class extends mt{constructor(t,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=mr(this.buffer)}update(t){dt(this),t=Rt(t),rt(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let l=mr(t);for(;o<=s-i;i+=o)this.process(l,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){dt(this),fr(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Oe(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let f=i;f<o;f++)r[f]=0;za(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=mr(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=l/4,p=this.get();if(u>p.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)a.setUint32(4*f,p[f],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Be=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);hr();var Ra=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]),Ne=new Uint32Array(64),xr=class extends gr{constructor(t=32){super(64,t,8,!1),this.A=Be[0]|0,this.B=Be[1]|0,this.C=Be[2]|0,this.D=Be[3]|0,this.E=Be[4]|0,this.F=Be[5]|0,this.G=Be[6]|0,this.H=Be[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:l}=this;return[t,r,n,o,s,i,a,l]}set(t,r,n,o,s,i,a,l){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=l|0}process(t,r){for(let f=0;f<16;f++,r+=4)Ne[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let h=Ne[f-15],g=Ne[f-2],_=xe(h,7)^xe(h,18)^h>>>3,P=xe(g,17)^xe(g,19)^g>>>10;Ne[f]=P+Ne[f-7]+_+Ne[f-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:l,G:u,H:p}=this;for(let f=0;f<64;f++){let h=xe(a,6)^xe(a,11)^xe(a,25),g=p+h+go(a,l,u)+Ra[f]+Ne[f]|0,P=(xe(n,2)^xe(n,13)^xe(n,22))+bo(n,o,s)|0;p=u,u=l,l=a,a=i+g|0,i=s,s=o,o=n,n=g+P|0}n=n+this.A|0,o=o+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,p=p+this.H|0,this.set(n,o,s,i,a,l,u,p)}roundClean(){Oe(Ne)}destroy(){this.set(0,0,0,0,0,0,0,0),Oe(this.buffer)}};var So=dr(()=>new xr);var Eo=So;ut();He();de();function To(e,t){let r=t||"hex",n=Eo(_e(e,{strict:!1})?er(e):e);return r==="bytes"?n:ge(n)}function Io(e){let{commitment:t,version:r=1}=e,n=e.to??(typeof t=="string"?"hex":"bytes"),o=To(t,"bytes");return o.set([r],0),n==="bytes"?o:oe(o)}function Ao(e){let{commitments:t,version:r}=e,n=e.to??(typeof t[0]=="string"?"hex":"bytes"),o=[];for(let s of t)o.push(Io({commitment:s,to:n,version:r}));return o}fe();var yr=class extends v{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},ht=class extends v{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},vr=class extends v{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},wr=class extends v{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};Jr();It();He();de();function Po(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?be(e.data):e.data,n=me(r);if(!n)throw new ht;if(n>761855)throw new yr({maxSize:761855,size:n});let o=[],s=!0,i=0;for(;s;){let a=sr(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}o.push(a)}return t==="bytes"?o.map(a=>a.bytes):o.map(a=>oe(a.bytes))}function $o(e){let{data:t,kzg:r,to:n}=e,o=e.blobs??Po({data:t,to:n}),s=e.commitments??ur({blobs:o,kzg:r,to:n}),i=e.proofs??pr({blobs:o,commitments:s,kzg:r,to:n}),a=[];for(let l=0;l<o.length;l++)a.push({blob:o[l],commitment:s[l],proof:i[l]});return a}Xr();Yn();de();oo();_r();fe();Lo();zo();kr();It();Xo();Ye();function Jo(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:n}=r,o=r.address;if(!Ce(o))throw new he({address:o});if(n<0)throw new nt({chainId:n})}Sr(e)}function Zo(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new ht;for(let r of t){let n=me(r),o=et(Vo(r,0,1));if(n!==32)throw new vr({hash:r,size:n});if(o!==1)throw new wr({hash:r,version:o})}}Sr(e)}function Sr(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:n,to:o}=e;if(t<=0)throw new nt({chainId:t});if(o&&!Ce(o))throw new he({address:o});if(n&&n>rr)throw new ot({maxFeePerGas:n});if(r&&n&&r>n)throw new jt({maxFeePerGas:n,maxPriorityFeePerGas:r})}function Yo(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:o,to:s}=e;if(t<=0)throw new nt({chainId:t});if(s&&!Ce(s))throw new he({address:s});if(r||o)throw new v("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(n&&n>rr)throw new ot({maxFeePerGas:n})}function Qo(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:o,to:s}=e;if(s&&!Ce(s))throw new he({address:s});if(typeof t<"u"&&t<=0)throw new nt({chainId:t});if(r||o)throw new v("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(n&&n>rr)throw new ot({maxFeePerGas:n})}lr();function es(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 ar({transaction:e})}_r();lr();kr();function Ft(e){if(!e||e.length===0)return[];let t=[];for(let r=0;r<e.length;r++){let{address:n,storageKeys:o}=e[r];for(let s=0;s<o.length;s++)if(o[s].length-2!==64)throw new cr({storageKey:o[s]});if(!Ce(n,{strict:!1}))throw new he({address:n});t.push([n,o])}return t}function ts(e,t){let r=es(e);return r==="eip1559"?Ya(e,t):r==="eip2930"?Qa(e,t):r==="eip4844"?Za(e,t):r==="eip7702"?Ja(e,t):ec(e,t)}function Ja(e,t){let{authorizationList:r,chainId:n,gas:o,nonce:s,to:i,value:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:p,data:f}=e;Jo(e);let h=Ft(p),g=mo(r);return tt(["0x04",ze([E(n),s?E(s):"0x",u?E(u):"0x",l?E(l):"0x",o?E(o):"0x",i??"0x",a?E(a):"0x",f??"0x",h,g,...ft(e,t)])])}function Za(e,t){let{chainId:r,gas:n,nonce:o,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:p,data:f}=e;Zo(e);let h=e.blobVersionedHashes,g=e.sidecars;if(e.blobs&&(typeof h>"u"||typeof g>"u")){let V=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(ue=>oe(ue)),Z=e.kzg,re=ur({blobs:V,kzg:Z});if(typeof h>"u"&&(h=Ao({commitments:re})),typeof g>"u"){let ue=pr({blobs:V,commitments:re,kzg:Z});g=$o({blobs:V,commitments:re,proofs:ue})}}let _=Ft(p),P=[E(r),o?E(o):"0x",u?E(u):"0x",l?E(l):"0x",n?E(n):"0x",s??"0x",i?E(i):"0x",f??"0x",_,a?E(a):"0x",h??[],...ft(e,t)],z=[],G=[],J=[];if(g)for(let V=0;V<g.length;V++){let{blob:Z,commitment:re,proof:ue}=g[V];z.push(Z),G.push(re),J.push(ue)}return tt(["0x03",g?ze([P,z,G,J]):ze(P)])}function Ya(e,t){let{chainId:r,gas:n,nonce:o,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:u,data:p}=e;Sr(e);let f=Ft(u),h=[E(r),o?E(o):"0x",l?E(l):"0x",a?E(a):"0x",n?E(n):"0x",s??"0x",i?E(i):"0x",p??"0x",f,...ft(e,t)];return tt(["0x02",ze(h)])}function Qa(e,t){let{chainId:r,gas:n,data:o,nonce:s,to:i,value:a,accessList:l,gasPrice:u}=e;Yo(e);let p=Ft(l),f=[E(r),s?E(s):"0x",u?E(u):"0x",n?E(n):"0x",i??"0x",a?E(a):"0x",o??"0x",p,...ft(e,t)];return tt(["0x01",ze(f)])}function ec(e,t){let{chainId:r=0,gas:n,data:o,nonce:s,to:i,value:a,gasPrice:l}=e;Qo(e);let u=[s?E(s):"0x",l?E(l):"0x",n?E(n):"0x",i??"0x",a?E(a):"0x",o??"0x"];if(t){let p=(()=>{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 g=27n+(t.v===27n?0n:1n);if(t.v!==g)throw new ir({v:t.v});return g})(),f=At(t.r),h=At(t.s);u=[...u,E(p),f==="0x00"?"0x":f,h==="0x00"?"0x":h]}else r>0&&(u=[...u,E(r),"0x","0x"]);return ze(u)}function ft(e,t){let r=t??e,{v:n,yParity:o}=r;if(typeof r.r>"u")return[];if(typeof r.s>"u")return[];if(typeof n>"u"&&typeof o>"u")return[];let s=At(r.r),i=At(r.s);return[typeof o=="number"?o?E(1):"0x":n===0n?"0x":n===1n?E(1):n===27n?"0x":E(1),s==="0x00"?"0x":s,i==="0x00"?"0x":i]}var rs={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};Ye();var ns={block:to({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let n=Lt(r);return n.typeHex==="0x7e"&&(n.isSystemTx=r.isSystemTx,n.mint=r.mint?Qe(r.mint):void 0,n.sourceHash=r.sourceHash,n.type="deposit"),n}),stateRoot:e.stateRoot}}}),transaction:eo({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Qe(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:no({format(e){return{l1GasPrice:e.l1GasPrice?Qe(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Qe(e.l1GasUsed):null,l1Fee:e.l1Fee?Qe(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};_r();kr();Xr();de();function tc(e,t){return nc(e)?rc(e):ts(e,t)}var os={transaction:tc};function rc(e){oc(e);let{sourceHash:t,data:r,from:n,gas:o,isSystemTx:s,mint:i,to:a,value:l}=e,u=[t,n,a??"0x",i?ge(i):"0x",l?ge(l):"0x",o?ge(o):"0x",s?"0x1":"0x",r??"0x"];return tt(["0x7e",ze(u)])}function nc(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function oc(e){let{from:t,to:r}=e;if(t&&!Ce(t))throw new he({address:t});if(r&&!Ce(r))throw new he({address:r})}var fn={blockTime:2e3,contracts:rs,formatters:ns,serializers:os};var Er=Ze({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 Ht=1,Ot=Ze({...fn,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:{...fn.contracts,disputeGameFactory:{[Ht]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[Ht]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[Ht]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[Ht]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:Ht}),sc=Ze({...Ot,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var Tr=Ze({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 O}from"zod";import{z as ie}from"zod";import{z as m}from"zod";import{z as d}from"zod";import{z as vt}from"zod";import{z as wt}from"zod";import{z as C}from"zod";import{z as W}from"zod";import{z as T}from"zod";import lu from"crypto";import{z as Ee}from"zod";import{z as ye}from"zod";import{z as M}from"zod";import{z as ae}from"zod";import{z as ce}from"zod";import{z as Nu}from"zod";import{z as Xs}from"zod";import{z as Te}from"zod";import{z as Et}from"zod";import{z as it}from"zod";import{z as B}from"zod";import{z as hp}from"zod";import{z as yp}from"zod";import{z as L}from"zod";import{z as Se}from"zod";import{z as Bp}from"zod";import{z as H}from"zod";import{z as y}from"zod";import{z as kt}from"zod";import{z as En}from"zod";import{z as X}from"zod";import{z as vi}from"zod";import{z as ke}from"zod";import{z as se}from"zod";import{z as Ve}from"zod";import{z as Tn}from"zod";import{z as An}from"zod";import{z as st}from"zod";import{z as b}from"zod";import{z as A}from"zod";import{z as I}from"zod";import{z as N}from"zod";var oy=Tt(hn(),1);import{z as F}from"zod";var Zf=Tt(hn(),1),Yf=Tt(ss(),1),Qf=Tt(Vs(),1);import{z as _t}from"zod";import{z as ve}from"zod";import{z as Ct}from"zod";import{z as Q}from"zod";import{z as Vt}from"zod";import{z as le}from"zod";import{z as Ys}from"zod";import{z as Qs}from"zod";import{z as $r}from"zod";import{z as Lr}from"zod";import{z as Y}from"zod";var Vc=D.object({detail:D.union([D.string(),D.array(D.object({msg:D.string(),type:D.string().optional(),ctx:D.record(D.unknown()).optional(),loc:D.array(D.union([D.string(),D.number()])).optional(),input:D.unknown().optional()}).passthrough()),D.record(D.unknown())]).optional(),type:D.string().optional(),code:D.string().optional()}),Ie=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)}},kn=class zr extends Ie{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=Vc.safeParse(t.data);return r.success?new zr(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 zr(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 zr(t.message,{request:r??void 0,detail:t.message})}},Kc=class extends Ie{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},Wc=class extends Ie{constructor(){super(...arguments),this.isAuthError=!0}},ti=class extends Ie{constructor(){super(...arguments),this.isBusinessError=!0}},Xc=class extends Ie{constructor(){super(...arguments),this.isServerError=!0}},Jc=class extends Ie{constructor(){super(...arguments),this.isUnknownError=!0}};function Zc(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 ri(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((o,s)=>{let i=Zc(o.loc),a=i;return i==="unknown"&&o.type&&(a=o.type==="missing"?"required field":o.type),{field:a,message:o.msg,type:o.type,context:o.ctx}}),r=t.length,n=r===1?`Validation failed: ${t[0].message}`:`Validation failed (${r} issue${r>1?"s":""})`;return{errors:t,message:n}}function Yc(e){return e===422?"validation":e===401||e===403?"auth":e>=400&&e<500?"business":e>=500?"server":"unknown"}function Qc(e,t,r){if(e===422&&Array.isArray(t)){let{message:n}=ri(t);return n}if(typeof t=="string")return t;if(t&&typeof t=="object"&&"message"in t){let n=t.message;if(typeof n=="string")return n}return r}function el(e){let t=e.status??0,r=e.statusText??"Unknown Error",n=e.detail,o=rl(n);if(o)return new tl(o.message,{status:t,statusText:r,detail:n,errorCode:o.error_code,structuredDetails:o.details,suggestions:o.suggestions,links:o.links});let s=Yc(t),i=Qc(t,n,e.message),a={status:t,statusText:r,detail:n};if(s==="validation"&&Array.isArray(n)){let{errors:l}=ri(n);return new Kc(i,{...a,validationErrors:l})}return s==="auth"?new Wc(i,a):s==="business"?new ti(i,a):s==="server"?new Xc(i,a):new Jc(i,a)}var tl=class extends ti{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 rl(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 Pn=["2025-10-28","2026-01-21"],nl="2026-01-21",yt=(0,ei.default)("phala::api-client");function ol(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
|
|
12
|
-
`)}function
|
|
4
|
+
`+s),e.push(o+"m+"+er.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=la()+t+" "+e[0]}function la(){return q.inspectOpts.hideDate?"":new Date().toISOString()+" "}function ua(...e){return process.stderr.write(Qt.formatWithOptions(q.inspectOpts,...e)+`
|
|
5
|
+
`)}function pa(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function fa(){return process.env.DEBUG}function ma(e){e.inspectOpts={};let t=Object.keys(q.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=q.inspectOpts[t[r]]}er.exports=Gr()(q);var{formatters:Wn}=er.exports;Wn.o=function(e){return this.inspectOpts.colors=this.useColors,Qt.inspect(e,this.inspectOpts).split(`
|
|
6
|
+
`).map(t=>t.trim()).join(" ")};Wn.O=function(e){return this.inspectOpts.colors=this.useColors,Qt.inspect(e,this.inspectOpts)}});var Jn=fe((Um,qr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?qr.exports=Kn():qr.exports=Xn()});var Dr,Yn=$(()=>{Dr="2.38.6"});function Qn(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Qn(e.cause,t):t?null:e}var Mr,v,me=$(()=>{Yn();Mr={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${Dr}`},v=class e extends Error{constructor(t,r={}){let n=r.cause instanceof e?r.cause.details:r.cause?.message?r.cause.message:r.details,o=r.cause instanceof e&&r.cause.docsPath||r.docsPath,s=Mr.getDocsUrl?.({...r,docsPath:o}),i=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...Mr.version?[`Version: ${Mr.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=n,this.docsPath=o,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=Dr}walk(t){return Qn(this,t)}}});var tr,rr,Vr=$(()=>{me();tr=class extends v{constructor({max:t,min:r,signed:n,size:o,value:s}){super(`Number "${s}" is not in safe ${o?`${o*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${r} to ${t})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}},rr=class extends v{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function Se(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var ft=$(()=>{});function de(e){return Se(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var Pt=$(()=>{ft()});function $t(e,{dir:t="left"}={}){let r=typeof e=="string"?e.replace("0x",""):e,n=0;for(let o=0;o<r.length-1&&r[t==="left"?o:r.length-o-1].toString()==="0";o++)n++;return r=t==="left"?r.slice(n):r.slice(0,r.length-n),typeof e=="string"?(r.length===1&&t==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}var eo=$(()=>{});var Lt,zt,Kr=$(()=>{me();Lt=class extends v{constructor({offset:t,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},zt=class extends v{constructor({size:t,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}});function Oe(e,{dir:t,size:r=32}={}){return typeof e=="string"?da(e,{dir:t,size:r}):ha(e,{dir:t,size:r})}function da(e,{dir:t,size:r=32}={}){if(r===null)return e;let n=e.replace("0x","");if(n.length>r*2)throw new zt({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function ha(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new zt({size:e.length,targetSize:r,type:"bytes"});let n=new Uint8Array(r);for(let o=0;o<r;o++){let s=t==="right";n[s?o:r-o-1]=e[s?o:e.length-o-1]}return n}var Wr=$(()=>{Kr()});function xe(e,t={}){return typeof e=="number"||typeof e=="bigint"?E(e,t):typeof e=="string"?ya(e,t):typeof e=="boolean"?ba(e,t):ie(e,t)}function ba(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(Ne(r,{size:t.size}),Oe(r,{size:t.size})):r}function ie(e,t={}){let r="";for(let o=0;o<e.length;o++)r+=ga[e[o]];let n=`0x${r}`;return typeof t.size=="number"?(Ne(n,{size:t.size}),Oe(n,{dir:"right",size:t.size})):n}function E(e,t={}){let{signed:r,size:n}=t,o=BigInt(e),s;n?r?s=(1n<<BigInt(n)*8n-1n)-1n:s=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));let i=typeof s=="bigint"&&r?-s-1n:0;if(s&&o>s||o<i){let l=typeof e=="bigint"?"n":"";throw new tr({max:s?`${s}${l}`:void 0,min:`${i}${l}`,signed:r,size:n,value:`${e}${l}`})}let a=`0x${(r&&o<0?(1n<<BigInt(n*8))+BigInt(o):o).toString(16)}`;return n?Oe(a,{size:n}):a}function ya(e,t={}){let r=xa.encode(e);return ie(r,t)}var ga,xa,he=$(()=>{Vr();Wr();et();ga=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));xa=new TextEncoder});function nr(e,t={}){return typeof e=="number"||typeof e=="bigint"?_a(e,t):typeof e=="boolean"?wa(e,t):Se(e)?ye(e,t):Xr(e,t)}function wa(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(Ne(r,{size:t.size}),Oe(r,{size:t.size})):r}function to(e){if(e>=Be.zero&&e<=Be.nine)return e-Be.zero;if(e>=Be.A&&e<=Be.F)return e-(Be.A-10);if(e>=Be.a&&e<=Be.f)return e-(Be.a-10)}function ye(e,t={}){let r=e;t.size&&(Ne(r,{size:t.size}),r=Oe(r,{dir:"right",size:t.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);let o=n.length/2,s=new Uint8Array(o);for(let i=0,a=0;i<o;i++){let l=to(n.charCodeAt(a++)),u=to(n.charCodeAt(a++));if(l===void 0||u===void 0)throw new v(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);s[i]=l*16+u}return s}function _a(e,t){let r=E(e,t);return ye(r)}function Xr(e,t={}){let r=va.encode(e);return typeof t.size=="number"?(Ne(r,{size:t.size}),Oe(r,{dir:"right",size:t.size})):r}var va,Be,Ge=$(()=>{me();ft();Wr();et();he();va=new TextEncoder;Be={zero:48,nine:57,A:65,F:70,a:97,f:102}});function Ne(e,{size:t}){if(de(e)>t)throw new rr({givenSize:de(e),maxSize:t})}function tt(e,t={}){let{signed:r}=t;t.size&&Ne(e,{size:t.size});let n=BigInt(e);if(!r)return n;let o=(e.length-2)/2,s=(1n<<BigInt(o)*8n-1n)-1n;return n<=s?n:n-BigInt(`0x${"f".padStart(o*2,"f")}`)-1n}function rt(e,t={}){return Number(tt(e,t))}var et=$(()=>{Vr();Pt()});function mt(e,t){return({exclude:r,format:n})=>({exclude:r,format:(o,s)=>{let i=t(o,s);if(r)for(let a of r)delete i[a];return{...i,...n(o,s)}},type:e})}var or=$(()=>{});var Ed,Td,Id,Ad,Pd,$d,Ld,zd,Rd,Bd,jd,Ud,Fd,Hd,Od,Nd,Gd,qd,Dd,Md,Vd,Kd,Wd,Xd,Jd,Zd,Yd,Qd,eh,th,rh,nh,oh,sh,ih,ah,ch,lh,uh,ph,fh,mh,dh,hh,gh,bh,xh,yh,vh,wh,_h,Ch,kh,Sh,Eh,Th,Ih,Ah,Ph,$h,Lh,zh,Rh,Bh,jh,Uh,Fh,Hh,Oh,Nh,Gh,qh,Dh,Mh,Vh,Kh,Wh,Xh,Jh,Zh,Yh,Qh,eg,tg,rg,ng,og,sg,ig,ag,cg,lg,ug,pg,fg,sr,io=$(()=>{Ed=2n**(8n-1n)-1n,Td=2n**(16n-1n)-1n,Id=2n**(24n-1n)-1n,Ad=2n**(32n-1n)-1n,Pd=2n**(40n-1n)-1n,$d=2n**(48n-1n)-1n,Ld=2n**(56n-1n)-1n,zd=2n**(64n-1n)-1n,Rd=2n**(72n-1n)-1n,Bd=2n**(80n-1n)-1n,jd=2n**(88n-1n)-1n,Ud=2n**(96n-1n)-1n,Fd=2n**(104n-1n)-1n,Hd=2n**(112n-1n)-1n,Od=2n**(120n-1n)-1n,Nd=2n**(128n-1n)-1n,Gd=2n**(136n-1n)-1n,qd=2n**(144n-1n)-1n,Dd=2n**(152n-1n)-1n,Md=2n**(160n-1n)-1n,Vd=2n**(168n-1n)-1n,Kd=2n**(176n-1n)-1n,Wd=2n**(184n-1n)-1n,Xd=2n**(192n-1n)-1n,Jd=2n**(200n-1n)-1n,Zd=2n**(208n-1n)-1n,Yd=2n**(216n-1n)-1n,Qd=2n**(224n-1n)-1n,eh=2n**(232n-1n)-1n,th=2n**(240n-1n)-1n,rh=2n**(248n-1n)-1n,nh=2n**(256n-1n)-1n,oh=-(2n**(8n-1n)),sh=-(2n**(16n-1n)),ih=-(2n**(24n-1n)),ah=-(2n**(32n-1n)),ch=-(2n**(40n-1n)),lh=-(2n**(48n-1n)),uh=-(2n**(56n-1n)),ph=-(2n**(64n-1n)),fh=-(2n**(72n-1n)),mh=-(2n**(80n-1n)),dh=-(2n**(88n-1n)),hh=-(2n**(96n-1n)),gh=-(2n**(104n-1n)),bh=-(2n**(112n-1n)),xh=-(2n**(120n-1n)),yh=-(2n**(128n-1n)),vh=-(2n**(136n-1n)),wh=-(2n**(144n-1n)),_h=-(2n**(152n-1n)),Ch=-(2n**(160n-1n)),kh=-(2n**(168n-1n)),Sh=-(2n**(176n-1n)),Eh=-(2n**(184n-1n)),Th=-(2n**(192n-1n)),Ih=-(2n**(200n-1n)),Ah=-(2n**(208n-1n)),Ph=-(2n**(216n-1n)),$h=-(2n**(224n-1n)),Lh=-(2n**(232n-1n)),zh=-(2n**(240n-1n)),Rh=-(2n**(248n-1n)),Bh=-(2n**(256n-1n)),jh=2n**8n-1n,Uh=2n**16n-1n,Fh=2n**24n-1n,Hh=2n**32n-1n,Oh=2n**40n-1n,Nh=2n**48n-1n,Gh=2n**56n-1n,qh=2n**64n-1n,Dh=2n**72n-1n,Mh=2n**80n-1n,Vh=2n**88n-1n,Kh=2n**96n-1n,Wh=2n**104n-1n,Xh=2n**112n-1n,Jh=2n**120n-1n,Zh=2n**128n-1n,Yh=2n**136n-1n,Qh=2n**144n-1n,eg=2n**152n-1n,tg=2n**160n-1n,rg=2n**168n-1n,ng=2n**176n-1n,og=2n**184n-1n,sg=2n**192n-1n,ig=2n**200n-1n,ag=2n**208n-1n,cg=2n**216n-1n,lg=2n**224n-1n,ug=2n**232n-1n,pg=2n**240n-1n,fg=2n**248n-1n,sr=2n**256n-1n});function nt(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var Zr=$(()=>{});var Bt,ir,ar,ao=$(()=>{me();Bt=class extends v{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},ir=class extends v{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},ar=class extends v{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function cr(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(Ta);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var Ta,Yr=$(()=>{ao();Ta={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 ar({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new ir({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Bt({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 Bt({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 uo,po=$(()=>{uo={ether:-9,wei:9}});function fo(e,t){let r=e.toString(),n=r.startsWith("-");n&&(r=r.slice(1)),r=r.padStart(t,"0");let[o,s]=[r.slice(0,r.length-t),r.slice(r.length-t)];return s=s.replace(/(0+)$/,""),`${n?"-":""}${o||"0"}${s?`.${s}`:""}`}var mo=$(()=>{});function jt(e,t="wei"){return fo(e,uo[t])}var ho=$(()=>{po();mo()});function Pa(e){let t=Object.entries(e).map(([n,o])=>o===void 0||o===!1?null:[n,o]).filter(Boolean),r=t.reduce((n,[o])=>Math.max(n,o.length),0);return t.map(([n,o])=>` ${`${n}:`.padEnd(r+1)} ${o}`).join(`
|
|
8
|
+
`)}var lr,ur,pr,fr=$(()=>{me();lr=class extends v{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}},ur=class extends v{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Pa(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"})}},pr=class extends v{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 $a(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 ot(e,...t){if(!$a(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 gt(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 hr(e,t){ot(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function bo(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function qe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function gr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ve(e,t){return e<<32-t|e>>>t}function za(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Ra(e){for(let t=0;t<e.length;t++)e[t]=za(e[t]);return e}function Ba(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Ut(e){return typeof e=="string"&&(e=Ba(e)),ot(e),e}function br(e){let t=n=>e().update(Ut(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}var La,en,ht,xr=$(()=>{La=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;en=La?e=>e:Ra;ht=class{}});function Ua(e,t=!1){return t?{h:Number(e&vr),l:Number(e>>vo&vr)}:{h:Number(e>>vo&vr)|0,l:Number(e&vr)|0}}function wo(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=Ua(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var vr,vo,_o,Co,ko,So,Eo=$(()=>{vr=BigInt(4294967295),vo=BigInt(32);_o=(e,t,r)=>e<<r|t>>>32-r,Co=(e,t,r)=>t<<r|e>>>32-r,ko=(e,t,r)=>t<<r-32|e>>>64-r,So=(e,t,r)=>e<<r-32|t>>>64-r});var ge,Sr=$(()=>{me();ge=class extends v{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 st,Ro=$(()=>{me();st=class extends v{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}});var Er,it,tn,rn,nn,on,sn,an,cn,ln,Ft,Bo=$(()=>{ho();me();Er=class extends v{constructor({cause:t,message:r}={}){let n=r?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}};Object.defineProperty(Er,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(Er,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});it=class extends v{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${jt(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}};Object.defineProperty(it,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});tn=class extends v{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${jt(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}};Object.defineProperty(tn,"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/});rn=class extends v{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(rn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});nn=class extends v{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(nn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});on=class extends v{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}};Object.defineProperty(on,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});sn=class extends v{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(sn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});an=class extends v{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(an,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});cn=class extends v{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(cn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});ln=class extends v{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}};Object.defineProperty(ln,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});Ft=class extends v{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${jt(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${jt(n)} gwei`:""}).`].join(`
|
|
11
|
+
`),{cause:t,name:"TipAboveFeeCapError"})}};Object.defineProperty(Ft,"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 xt,un=$(()=>{xt=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 n=this.keys().next().value;n&&this.delete(n)}return this}}});function Wa(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){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],p=r[l+1],f=jo(u,p,1)^r[a],h=Uo(u,p,1)^r[a+1];for(let g=0;g<50;g+=10)e[i+g]^=f,e[i+g+1]^=h}let o=e[2],s=e[3];for(let i=0;i<24;i++){let a=Ho[i],l=jo(o,s,a),u=Uo(o,s,a),p=Fo[i];o=e[p],s=e[p+1],e[p]=l,e[p+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]^=Va[n],e[1]^=Ka[n]}qe(r)}var Na,Ht,Ga,qa,Da,Ma,Fo,Ho,Oo,No,Va,Ka,jo,Uo,pn,Xa,Go,qo=$(()=>{Eo();xr();Na=BigInt(0),Ht=BigInt(1),Ga=BigInt(2),qa=BigInt(7),Da=BigInt(256),Ma=BigInt(113),Fo=[],Ho=[],Oo=[];for(let e=0,t=Ht,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Fo.push(2*(5*n+r)),Ho.push((e+1)*(e+2)/2%64);let o=Na;for(let s=0;s<7;s++)t=(t<<Ht^(t>>qa)*Ma)%Da,t&Ga&&(o^=Ht<<(Ht<<BigInt(s))-Ht);Oo.push(o)}No=wo(Oo,!0),Va=No[0],Ka=No[1],jo=(e,t,r)=>r>32?ko(e,t,r):_o(e,t,r),Uo=(e,t,r)=>r>32?So(e,t,r):Co(e,t,r);pn=class e extends ht{constructor(t,r,n,o=!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=n,this.enableXOF=o,this.rounds=s,Qr(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=bo(this.state)}clone(){return this._cloneInto()}keccak(){en(this.state32),Wa(this.state32,this.rounds),en(this.state32),this.posOut=0,this.pos=0}update(t){gt(this),t=Ut(t),ot(t);let{blockLen:r,state:n}=this,o=t.length;for(let s=0;s<o;){let i=Math.min(r-this.pos,o-s);for(let a=0;a<i;a++)n[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:n,blockLen:o}=this;t[n]^=r,(r&128)!==0&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){gt(this,!1),ot(t),this.finish();let r=this.state,{blockLen:n}=this;for(let o=0,s=t.length;o<s;){this.posOut>=n&&this.keccak();let i=Math.min(n-this.posOut,s-o);t.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=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 Qr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(hr(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,qe(this.state)}_cloneInto(t){let{blockLen:r,suffix:n,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new e(r,n,o,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}},Xa=(e,t,r)=>br(()=>new pn(t,e,r)),Go=Xa(1,136,256/8)});function Do(e,t){let r=t||"hex",n=Go(Se(e,{strict:!1})?nr(e):e);return r==="bytes"?n:xe(n)}var Mo=$(()=>{qo();ft();Ge();he()});function Vo(e,t){if(fn.has(`${e}.${t}`))return fn.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),n=Do(Xr(r),"bytes"),o=(t?r.substring(`${t}0x`.length):r).split("");for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&o[i]&&(o[i]=o[i].toUpperCase()),(n[i>>1]&15)>=8&&o[i+1]&&(o[i+1]=o[i+1].toUpperCase());let s=`0x${o.join("")}`;return fn.set(`${e}.${t}`,s),s}var fn,Ko=$(()=>{Ge();Mo();un();fn=new xt(8192)});function Ee(e,t){let{strict:r=!0}=t??{},n=`${e}.${r}`;if(mn.has(n))return mn.get(n);let o=Ja.test(e)?e.toLowerCase()===e?!0:r?Vo(e)===e:!0:!1;return mn.set(n,o),o}var Ja,mn,Tr=$(()=>{un();Ko();Ja=/^0x[a-fA-F0-9]{40}$/,mn=new xt(8192)});function Wo(e,t,r,{strict:n}={}){return Se(e,{strict:!1})?Ya(e,t,r,{strict:n}):Za(e,t,r,{strict:n})}function Xo(e,t){if(typeof t=="number"&&t>0&&t>de(e)-1)throw new Lt({offset:t,position:"start",size:de(e)})}function Jo(e,t,r){if(typeof t=="number"&&typeof r=="number"&&de(e)!==r-t)throw new Lt({offset:r,position:"end",size:de(e)})}function Za(e,t,r,{strict:n}={}){Xo(e,t);let o=e.slice(t,r);return n&&Jo(o,t,r),o}function Ya(e,t,r,{strict:n}={}){Xo(e,t);let o=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return n&&Jo(o,t,r),o}var Zo=$(()=>{Kr();ft();Pt()});var bn=fe(qt=>{"use strict";var lc=qt&&qt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(qt,"__esModule",{value:!0});qt.encryptEnvVars=fc;var hn=He("@noble/curves/ed25519"),gn=lc(He("crypto"));function uc(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(n=>parseInt(n,16)))!==null&&r!==void 0?r:[])}function pc(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function fc(e,t){let r=JSON.stringify({env:e}),n=hn.x25519.utils.randomPrivateKey(),o=hn.x25519.getPublicKey(n),s=uc(t),i=hn.x25519.getSharedSecret(n,s),a=await gn.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=gn.default.getRandomValues(new Uint8Array(12)),u=await gn.default.subtle.encrypt({name:"AES-GCM",iv:l},a,new TextEncoder().encode(r)),p=new Uint8Array(o.length+l.length+u.byteLength);return p.set(o),p.set(l,o.length),p.set(new Uint8Array(u),o.length+l.length),pc(p)}});var as=fe(Dt=>{"use strict";var mc=Dt&&Dt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Dt,"__esModule",{value:!0});Dt.getComposeHash=bc;var dc=mc(He("crypto"));function xn(e){return e==null?e:Array.isArray(e)?e.map(xn):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let n=e[r];return t[r]=xn(n),t},{}):e}function hc(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 gc(e){let t=xn(e);return JSON.stringify(t,(r,n)=>typeof n=="number"&&(isNaN(n)||!isFinite(n))?null:n)}function bc(e,t=!1){t&&(e=hc(e));let r=gc(e);return dc.default.createHash("sha256").update(r,"utf8").digest("hex")}});var As=fe(w=>{"use strict";Object.defineProperty(w,"__esModule",{value:!0});w.toBig=w.shrSL=w.shrSH=w.rotrSL=w.rotrSH=w.rotrBL=w.rotrBH=w.rotr32L=w.rotr32H=w.rotlSL=w.rotlSH=w.rotlBL=w.rotlBH=w.add5L=w.add5H=w.add4L=w.add4H=w.add3L=w.add3H=void 0;w.add=_s;w.fromBig=vn;w.split=cs;var $r=BigInt(2**32-1),yn=BigInt(32);function vn(e,t=!1){return t?{h:Number(e&$r),l:Number(e>>yn&$r)}:{h:Number(e>>yn&$r)|0,l:Number(e&$r)|0}}function cs(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=vn(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var ls=(e,t)=>BigInt(e>>>0)<<yn|BigInt(t>>>0);w.toBig=ls;var us=(e,t,r)=>e>>>r;w.shrSH=us;var ps=(e,t,r)=>e<<32-r|t>>>r;w.shrSL=ps;var fs=(e,t,r)=>e>>>r|t<<32-r;w.rotrSH=fs;var ms=(e,t,r)=>e<<32-r|t>>>r;w.rotrSL=ms;var ds=(e,t,r)=>e<<64-r|t>>>r-32;w.rotrBH=ds;var hs=(e,t,r)=>e>>>r-32|t<<64-r;w.rotrBL=hs;var gs=(e,t)=>t;w.rotr32H=gs;var bs=(e,t)=>e;w.rotr32L=bs;var xs=(e,t,r)=>e<<r|t>>>32-r;w.rotlSH=xs;var ys=(e,t,r)=>t<<r|e>>>32-r;w.rotlSL=ys;var vs=(e,t,r)=>t<<r-32|e>>>64-r;w.rotlBH=vs;var ws=(e,t,r)=>e<<r-32|t>>>64-r;w.rotlBL=ws;function _s(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Cs=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);w.add3L=Cs;var ks=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;w.add3H=ks;var Ss=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);w.add4L=Ss;var Es=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0;w.add4H=Es;var Ts=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0);w.add5L=Ts;var Is=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;w.add5H=Is;var xc={fromBig:vn,split:cs,toBig:ls,shrSH:us,shrSL:ps,rotrSH:fs,rotrSL:ms,rotrBH:ds,rotrBL:hs,rotr32H:gs,rotr32L:bs,rotlSH:xs,rotlSL:ys,rotlBH:vs,rotlBL:ws,add:_s,add3L:Cs,add3H:ks,add4L:Ss,add4H:Es,add5H:Is,add5L:Ts};w.default=xc});var Ps=fe(Lr=>{"use strict";Object.defineProperty(Lr,"__esModule",{value:!0});Lr.crypto=void 0;var Me=He("crypto");Lr.crypto=Me&&typeof Me=="object"&&"webcrypto"in Me?Me.webcrypto:Me&&typeof Me=="object"&&"randomBytes"in Me?Me:void 0});var Fs=fe(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=Ls;x.anumber=wn;x.abytes=vt;x.ahash=yc;x.aexists=vc;x.aoutput=wc;x.u8=_c;x.u32=Cc;x.clean=kc;x.createView=Sc;x.rotr=Ec;x.rotl=Tc;x.byteSwap=Cn;x.byteSwap32=zs;x.bytesToHex=Ac;x.hexToBytes=Pc;x.asyncLoop=Lc;x.utf8ToBytes=kn;x.bytesToUtf8=zc;x.toBytes=zr;x.kdfInputToBytes=Rc;x.concatBytes=Bc;x.checkOpts=jc;x.createHasher=Bs;x.createOptHasher=js;x.createXOFer=Us;x.randomBytes=Uc;var yt=Ps();function Ls(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function wn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function vt(e,...t){if(!Ls(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 yc(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");wn(e.outputLen),wn(e.blockLen)}function vc(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 wc(e,t){vt(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function _c(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Cc(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function kc(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Sc(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ec(e,t){return e<<32-t|e>>>t}function Tc(e,t){return e<<t|e>>>32-t>>>0}x.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Cn(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}x.swap8IfBE=x.isLE?e=>e:e=>Cn(e);x.byteSwapIfBE=x.swap8IfBE;function zs(e){for(let t=0;t<e.length;t++)e[t]=Cn(e[t]);return e}x.swap32IfBE=x.isLE?e=>e:zs;var Rs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Ic=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ac(e){if(vt(e),Rs)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Ic[e[r]];return t}var Fe={_0:48,_9:57,A:65,F:70,a:97,f:102};function $s(e){if(e>=Fe._0&&e<=Fe._9)return e-Fe._0;if(e>=Fe.A&&e<=Fe.F)return e-(Fe.A-10);if(e>=Fe.a&&e<=Fe.f)return e-(Fe.a-10)}function Pc(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Rs)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 n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=$s(e.charCodeAt(s)),a=$s(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)}n[o]=i*16+a}return n}var $c=async()=>{};x.nextTick=$c;async function Lc(e,t,r){let n=Date.now();for(let o=0;o<e;o++){r(o);let s=Date.now()-n;s>=0&&s<t||(await(0,x.nextTick)(),n+=s)}}function kn(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function zc(e){return new TextDecoder().decode(e)}function zr(e){return typeof e=="string"&&(e=kn(e)),vt(e),e}function Rc(e){return typeof e=="string"&&(e=kn(e)),vt(e),e}function Bc(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];vt(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}function jc(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 _n=class{};x.Hash=_n;function Bs(e){let t=n=>e().update(zr(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function js(e){let t=(n,o)=>e(o).update(zr(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function Us(e){let t=(n,o)=>e(o).update(zr(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}x.wrapConstructor=Bs;x.wrapConstructorWithOpts=js;x.wrapXOFConstructorWithOpts=Us;function Uc(e=32){if(yt.crypto&&typeof yt.crypto.getRandomValues=="function")return yt.crypto.getRandomValues(new Uint8Array(e));if(yt.crypto&&typeof yt.crypto.randomBytes=="function")return Uint8Array.from(yt.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var Ks=fe(j=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});j.shake256=j.shake128=j.keccak_512=j.keccak_384=j.keccak_256=j.keccak_224=j.sha3_512=j.sha3_384=j.sha3_256=j.sha3_224=j.Keccak=void 0;j.keccakP=Ms;var Vt=As(),W=Fs(),Fc=BigInt(0),Mt=BigInt(1),Hc=BigInt(2),Oc=BigInt(7),Nc=BigInt(256),Gc=BigInt(113),Ns=[],Gs=[],qs=[];for(let e=0,t=Mt,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Ns.push(2*(5*n+r)),Gs.push((e+1)*(e+2)/2%64);let o=Fc;for(let s=0;s<7;s++)t=(t<<Mt^(t>>Oc)*Gc)%Nc,t&Hc&&(o^=Mt<<(Mt<<BigInt(s))-Mt);qs.push(o)}var Ds=(0,Vt.split)(qs,!0),qc=Ds[0],Dc=Ds[1],Hs=(e,t,r)=>r>32?(0,Vt.rotlBH)(e,t,r):(0,Vt.rotlSH)(e,t,r),Os=(e,t,r)=>r>32?(0,Vt.rotlBL)(e,t,r):(0,Vt.rotlSL)(e,t,r);function Ms(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){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],p=r[l+1],f=Hs(u,p,1)^r[a],h=Os(u,p,1)^r[a+1];for(let g=0;g<50;g+=10)e[i+g]^=f,e[i+g+1]^=h}let o=e[2],s=e[3];for(let i=0;i<24;i++){let a=Gs[i],l=Hs(o,s,a),u=Os(o,s,a),p=Ns[i];o=e[p],s=e[p+1],e[p]=l,e[p+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]^=qc[n],e[1]^=Dc[n]}(0,W.clean)(r)}var Kt=class e extends W.Hash{constructor(t,r,n,o=!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=n,this.enableXOF=o,this.rounds=s,(0,W.anumber)(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,W.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,W.swap32IfBE)(this.state32),Ms(this.state32,this.rounds),(0,W.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(t){(0,W.aexists)(this),t=(0,W.toBytes)(t),(0,W.abytes)(t);let{blockLen:r,state:n}=this,o=t.length;for(let s=0;s<o;){let i=Math.min(r-this.pos,o-s);for(let a=0;a<i;a++)n[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:n,blockLen:o}=this;t[n]^=r,(r&128)!==0&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){(0,W.aexists)(this,!1),(0,W.abytes)(t),this.finish();let r=this.state,{blockLen:n}=this;for(let o=0,s=t.length;o<s;){this.posOut>=n&&this.keccak();let i=Math.min(n-this.posOut,s-o);t.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=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,W.anumber)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,W.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,W.clean)(this.state)}_cloneInto(t){let{blockLen:r,suffix:n,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new e(r,n,o,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}};j.Keccak=Kt;var Ve=(e,t,r)=>(0,W.createHasher)(()=>new Kt(t,e,r));j.sha3_224=Ve(6,144,224/8);j.sha3_256=Ve(6,136,256/8);j.sha3_384=Ve(6,104,384/8);j.sha3_512=Ve(6,72,512/8);j.keccak_224=Ve(1,144,224/8);j.keccak_256=Ve(1,136,256/8);j.keccak_384=Ve(1,104,384/8);j.keccak_512=Ve(1,72,512/8);var Vs=(e,t,r)=>(0,W.createXOFer)((n={})=>new Kt(t,e,n.dkLen===void 0?r:n.dkLen,!0));j.shake128=Vs(31,168,128/8);j.shake256=Vs(31,136,256/8)});var Ws=fe(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.verifyEnvEncryptPublicKey=Kc;var Mc=Ks(),Vc=He("@noble/curves/secp256k1");function Kc(e,t,r){if(t.length!==65)return null;let n=Buffer.from("dstack-env-encrypt-pubkey","utf8"),o=r;r.startsWith("0x")&&(o=r.slice(2));let s=Buffer.from(o,"hex"),i=Buffer.from(":","utf8"),a=Buffer.concat([n,i,s,Buffer.from(e)]),l=(0,Mc.keccak_256)(a);try{let u=t.slice(0,32),p=t.slice(32,64),f=t[64],h=new Uint8Array(64);h.set(u,0),h.set(p,32);let g=Vc.secp256k1.Signature.fromCompact(h).addRecoveryBit(f).recoverPublicKey(l);return"0x"+Buffer.from(g.toRawBytes(!0)).toString("hex")}catch(u){return console.error("signature verification failed:",u),null}}});var ri=At(Jn(),1);import{ofetch as Wc}from"ofetch";function Zn(e){return{all:e=e||new Map,on:function(t,r){var n=e.get(t);n?n.push(r):e.set(t,[r])},off:function(t,r){var n=e.get(t);n&&(r?n.splice(n.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var n=e.get(t);n&&n.slice().map(function(o){o(r)}),(n=e.get("*"))&&n.slice().map(function(o){o(t,r)})}}}import{z as D}from"zod";import{z as U}from"zod";import{z as Ke}from"zod";import{z as S}from"zod";import{z as We}from"zod";function Qe(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}or();et();or();var Jr={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function Rt(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?rt(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?rt(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Jr[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=Ca(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=mt("transaction",Rt);function Ca(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 ka(e,t){let r=(e.transactions??[]).map(n=>typeof n=="string"?n:Rt(n));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 no=mt("block",ka);function oo(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}:{}}}et();or();var Sa={"0x0":"reverted","0x1":"success"};function Ea(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(n=>oo(n)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?rt(e.transactionIndex):null,status:e.status?Sa[e.status]:null,type:e.type?Jr[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var so=mt("transactionReceipt",Ea);me();Yr();Ge();he();function je(e,t="hex"){let r=co(e),n=cr(new Uint8Array(r.length));return r.encode(n),t==="hex"?ie(n.bytes):n.bytes}function co(e){return Array.isArray(e)?Ia(e.map(t=>co(t))):Aa(e)}function Ia(e){let t=e.reduce((o,s)=>o+s.length,0),r=lo(t);return{length:t<=55?1+t:1+r+t,encode(o){t<=55?o.pushByte(192+t):(o.pushByte(247+r),r===1?o.pushUint8(t):r===2?o.pushUint16(t):r===3?o.pushUint24(t):o.pushUint32(t));for(let{encode:s}of e)s(o)}}}function Aa(e){let t=typeof e=="string"?ye(e):e,r=lo(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length,encode(o){t.length===1&&t[0]<128?o.pushBytes(t):t.length<=55?(o.pushByte(128+t.length),o.pushBytes(t)):(o.pushByte(183+r),r===1?o.pushUint8(t.length):r===2?o.pushUint16(t.length):r===3?o.pushUint24(t.length):o.pushUint32(t.length),o.pushBytes(t))}}}function lo(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 v("Length is too large.")}fr();he();function go(e){if(!e||e.length===0)return[];let t=[];for(let r of e){let{chainId:n,nonce:o,...s}=r,i=r.address;t.push([n?xe(n):"0x",i,o?xe(o):"0x",...dt({},s)])}return t}Ge();he();function mr(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(s=>ye(s)):e.blobs,o=[];for(let s of n)o.push(Uint8Array.from(t.blobToKzgCommitment(s)));return r==="bytes"?o:o.map(s=>ie(s))}Ge();he();function dr(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(i=>ye(i)):e.blobs,o=typeof e.commitments[0]=="string"?e.commitments.map(i=>ye(i)):e.commitments,s=[];for(let i=0;i<n.length;i++){let a=n[i],l=o[i];s.push(Uint8Array.from(t.computeBlobKzgProof(a,l)))}return r==="bytes"?s:s.map(i=>ie(i))}he();xr();function ja(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),a=Number(r&s),l=n?4:0,u=n?0:4;e.setUint32(t+l,i,n),e.setUint32(t+u,a,n)}function xo(e,t,r){return e&t^~e&r}function yo(e,t,r){return e&t^e&r^t&r}var yr=class extends ht{constructor(t,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=gr(this.buffer)}update(t){gt(this),t=Ut(t),ot(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let l=gr(t);for(;o<=s-i;i+=o)this.process(l,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){gt(this),hr(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,qe(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let f=i;f<o;f++)r[f]=0;ja(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=gr(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=l/4,p=this.get();if(u>p.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)a.setUint32(4*f,p[f],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Ue=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);xr();var Fa=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]),De=new Uint32Array(64),wr=class extends yr{constructor(t=32){super(64,t,8,!1),this.A=Ue[0]|0,this.B=Ue[1]|0,this.C=Ue[2]|0,this.D=Ue[3]|0,this.E=Ue[4]|0,this.F=Ue[5]|0,this.G=Ue[6]|0,this.H=Ue[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:l}=this;return[t,r,n,o,s,i,a,l]}set(t,r,n,o,s,i,a,l){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=l|0}process(t,r){for(let f=0;f<16;f++,r+=4)De[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let h=De[f-15],g=De[f-2],_=ve(h,7)^ve(h,18)^h>>>3,P=ve(g,17)^ve(g,19)^g>>>10;De[f]=P+De[f-7]+_+De[f-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:l,G:u,H:p}=this;for(let f=0;f<64;f++){let h=ve(a,6)^ve(a,11)^ve(a,25),g=p+h+xo(a,l,u)+Fa[f]+De[f]|0,P=(ve(n,2)^ve(n,13)^ve(n,22))+yo(n,o,s)|0;p=u,u=l,l=a,a=i+g|0,i=s,s=o,o=n,n=g+P|0}n=n+this.A|0,o=o+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,p=p+this.H|0,this.set(n,o,s,i,a,l,u,p)}roundClean(){qe(De)}destroy(){this.set(0,0,0,0,0,0,0,0),qe(this.buffer)}};var To=br(()=>new wr);var Io=To;ft();Ge();he();function Ao(e,t){let r=t||"hex",n=Io(Se(e,{strict:!1})?nr(e):e);return r==="bytes"?n:xe(n)}function Po(e){let{commitment:t,version:r=1}=e,n=e.to??(typeof t=="string"?"hex":"bytes"),o=Ao(t,"bytes");return o.set([r],0),n==="bytes"?o:ie(o)}function $o(e){let{commitments:t,version:r}=e,n=e.to??(typeof t[0]=="string"?"hex":"bytes"),o=[];for(let s of t)o.push(Po({commitment:s,to:n,version:r}));return o}me();var _r=class extends v{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},bt=class extends v{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},Cr=class extends v{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},kr=class extends v{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};Yr();Pt();Ge();he();function Lo(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?ye(e.data):e.data,n=de(r);if(!n)throw new bt;if(n>761855)throw new _r({maxSize:761855,size:n});let o=[],s=!0,i=0;for(;s;){let a=cr(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}o.push(a)}return t==="bytes"?o.map(a=>a.bytes):o.map(a=>ie(a.bytes))}function zo(e){let{data:t,kzg:r,to:n}=e,o=e.blobs??Lo({data:t,to:n}),s=e.commitments??mr({blobs:o,kzg:r,to:n}),i=e.proofs??dr({blobs:o,commitments:s,kzg:r,to:n}),a=[];for(let l=0;l<o.length;l++)a.push({blob:o[l],commitment:s[l],proof:i[l]});return a}Zr();eo();he();io();Sr();me();Ro();Bo();Tr();Pt();Zo();et();function Yo(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:n}=r,o=r.address;if(!Ee(o))throw new ge({address:o});if(n<0)throw new st({chainId:n})}Ir(e)}function Qo(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new bt;for(let r of t){let n=de(r),o=rt(Wo(r,0,1));if(n!==32)throw new Cr({hash:r,size:n});if(o!==1)throw new kr({hash:r,version:o})}}Ir(e)}function Ir(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:n,to:o}=e;if(t<=0)throw new st({chainId:t});if(o&&!Ee(o))throw new ge({address:o});if(n&&n>sr)throw new it({maxFeePerGas:n});if(r&&n&&r>n)throw new Ft({maxFeePerGas:n,maxPriorityFeePerGas:r})}function es(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:o,to:s}=e;if(t<=0)throw new st({chainId:t});if(s&&!Ee(s))throw new ge({address:s});if(r||o)throw new v("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(n&&n>sr)throw new it({maxFeePerGas:n})}function ts(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:o,to:s}=e;if(s&&!Ee(s))throw new ge({address:s});if(typeof t<"u"&&t<=0)throw new st({chainId:t});if(r||o)throw new v("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(n&&n>sr)throw new it({maxFeePerGas:n})}fr();function rs(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 ur({transaction:e})}Sr();fr();Tr();function Ot(e){if(!e||e.length===0)return[];let t=[];for(let r=0;r<e.length;r++){let{address:n,storageKeys:o}=e[r];for(let s=0;s<o.length;s++)if(o[s].length-2!==64)throw new pr({storageKey:o[s]});if(!Ee(n,{strict:!1}))throw new ge({address:n});t.push([n,o])}return t}function ns(e,t){let r=rs(e);return r==="eip1559"?tc(e,t):r==="eip2930"?rc(e,t):r==="eip4844"?ec(e,t):r==="eip7702"?Qa(e,t):nc(e,t)}function Qa(e,t){let{authorizationList:r,chainId:n,gas:o,nonce:s,to:i,value:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:p,data:f}=e;Yo(e);let h=Ot(p),g=go(r);return nt(["0x04",je([E(n),s?E(s):"0x",u?E(u):"0x",l?E(l):"0x",o?E(o):"0x",i??"0x",a?E(a):"0x",f??"0x",h,g,...dt(e,t)])])}function ec(e,t){let{chainId:r,gas:n,nonce:o,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:p,data:f}=e;Qo(e);let h=e.blobVersionedHashes,g=e.sidecars;if(e.blobs&&(typeof h>"u"||typeof g>"u")){let K=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(pe=>ie(pe)),Y=e.kzg,oe=mr({blobs:K,kzg:Y});if(typeof h>"u"&&(h=$o({commitments:oe})),typeof g>"u"){let pe=dr({blobs:K,commitments:oe,kzg:Y});g=zo({blobs:K,commitments:oe,proofs:pe})}}let _=Ot(p),P=[E(r),o?E(o):"0x",u?E(u):"0x",l?E(l):"0x",n?E(n):"0x",s??"0x",i?E(i):"0x",f??"0x",_,a?E(a):"0x",h??[],...dt(e,t)],z=[],G=[],Z=[];if(g)for(let K=0;K<g.length;K++){let{blob:Y,commitment:oe,proof:pe}=g[K];z.push(Y),G.push(oe),Z.push(pe)}return nt(["0x03",g?je([P,z,G,Z]):je(P)])}function tc(e,t){let{chainId:r,gas:n,nonce:o,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:u,data:p}=e;Ir(e);let f=Ot(u),h=[E(r),o?E(o):"0x",l?E(l):"0x",a?E(a):"0x",n?E(n):"0x",s??"0x",i?E(i):"0x",p??"0x",f,...dt(e,t)];return nt(["0x02",je(h)])}function rc(e,t){let{chainId:r,gas:n,data:o,nonce:s,to:i,value:a,accessList:l,gasPrice:u}=e;es(e);let p=Ot(l),f=[E(r),s?E(s):"0x",u?E(u):"0x",n?E(n):"0x",i??"0x",a?E(a):"0x",o??"0x",p,...dt(e,t)];return nt(["0x01",je(f)])}function nc(e,t){let{chainId:r=0,gas:n,data:o,nonce:s,to:i,value:a,gasPrice:l}=e;ts(e);let u=[s?E(s):"0x",l?E(l):"0x",n?E(n):"0x",i??"0x",a?E(a):"0x",o??"0x"];if(t){let p=(()=>{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 g=27n+(t.v===27n?0n:1n);if(t.v!==g)throw new lr({v:t.v});return g})(),f=$t(t.r),h=$t(t.s);u=[...u,E(p),f==="0x00"?"0x":f,h==="0x00"?"0x":h]}else r>0&&(u=[...u,E(r),"0x","0x"]);return je(u)}function dt(e,t){let r=t??e,{v:n,yParity:o}=r;if(typeof r.r>"u")return[];if(typeof r.s>"u")return[];if(typeof n>"u"&&typeof o>"u")return[];let s=$t(r.r),i=$t(r.s);return[typeof o=="number"?o?E(1):"0x":n===0n?"0x":n===1n?E(1):n===27n?"0x":E(1),s==="0x00"?"0x":s,i==="0x00"?"0x":i]}var os={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};et();var ss={block:no({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let n=Rt(r);return n.typeHex==="0x7e"&&(n.isSystemTx=r.isSystemTx,n.mint=r.mint?tt(r.mint):void 0,n.sourceHash=r.sourceHash,n.type="deposit"),n}),stateRoot:e.stateRoot}}}),transaction:ro({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?tt(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:so({format(e){return{l1GasPrice:e.l1GasPrice?tt(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?tt(e.l1GasUsed):null,l1Fee:e.l1Fee?tt(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};Sr();Tr();Zr();he();function oc(e,t){return ic(e)?sc(e):ns(e,t)}var is={transaction:oc};function sc(e){ac(e);let{sourceHash:t,data:r,from:n,gas:o,isSystemTx:s,mint:i,to:a,value:l}=e,u=[t,n,a??"0x",i?xe(i):"0x",l?xe(l):"0x",o?xe(o):"0x",s?"0x1":"0x",r??"0x"];return nt(["0x7e",je(u)])}function ic(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function ac(e){let{from:t,to:r}=e;if(t&&!Ee(t))throw new ge({address:t});if(r&&!Ee(r))throw new ge({address:r})}var dn={blockTime:2e3,contracts:os,formatters:ss,serializers:is};var Ar=Qe({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 Nt=1,Gt=Qe({...dn,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:{...dn.contracts,disputeGameFactory:{[Nt]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[Nt]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[Nt]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[Nt]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:Nt}),cc=Qe({...Gt,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var Pr=Qe({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 O}from"zod";import{z as te}from"zod";import{z as m}from"zod";import{z as d}from"zod";import{z as _t}from"zod";import{z as Ct}from"zod";import{z as k}from"zod";import{z as X}from"zod";import{z as T}from"zod";import fu from"crypto";import{z as Ae}from"zod";import{z as we}from"zod";import{z as V}from"zod";import{z as ce}from"zod";import{z as le}from"zod";import{z as Du}from"zod";import{z as Zs}from"zod";import{z as Pe}from"zod";import{z as It}from"zod";import{z as ct}from"zod";import{z as R}from"zod";import{z as xp}from"zod";import{z as _p}from"zod";import{z as L}from"zod";import{z as Ie}from"zod";import{z as Up}from"zod";import{z as H}from"zod";import{z as y}from"zod";import{z as Et}from"zod";import{z as In}from"zod";import{z as J}from"zod";import{z as _i}from"zod";import{z as Te}from"zod";import{z as ae}from"zod";import{z as Xe}from"zod";import{z as An}from"zod";import{z as $n}from"zod";import{z as at}from"zod";import{z as b}from"zod";import{z as A}from"zod";import{z as I}from"zod";import{z as N}from"zod";var fy=At(bn(),1);import{z as F}from"zod";var sm=At(bn(),1),im=At(as(),1),am=At(Ws(),1);import{z as kt}from"zod";import{z as Ce}from"zod";import{z as Xf}from"zod";import{z as St}from"zod";import{z as _e}from"zod";import{z as M}from"zod";import{z as ee}from"zod";import{z as Wt}from"zod";import{z as ue}from"zod";import{z as ei}from"zod";import{z as ti}from"zod";import{z as Rr}from"zod";import{z as Br}from"zod";import{z as Q}from"zod";var Xc=D.object({detail:D.union([D.string(),D.array(D.object({msg:D.string(),type:D.string().optional(),ctx:D.record(D.unknown()).optional(),loc:D.array(D.union([D.string(),D.number()])).optional(),input:D.unknown().optional()}).passthrough()),D.record(D.unknown())]).optional(),type:D.string().optional(),code:D.string().optional()}),$e=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)}},En=class jr extends $e{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 jr(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 jr(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 jr(t.message,{request:r??void 0,detail:t.message})}},Jc=class extends $e{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},Zc=class extends $e{constructor(){super(...arguments),this.isAuthError=!0}},ni=class extends $e{constructor(){super(...arguments),this.isBusinessError=!0}},Yc=class extends $e{constructor(){super(...arguments),this.isServerError=!0}},Qc=class extends $e{constructor(){super(...arguments),this.isUnknownError=!0}};function el(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 oi(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((o,s)=>{let i=el(o.loc),a=i;return i==="unknown"&&o.type&&(a=o.type==="missing"?"required field":o.type),{field:a,message:o.msg,type:o.type,context:o.ctx}}),r=t.length,n=r===1?`Validation failed: ${t[0].message}`:`Validation failed (${r} issue${r>1?"s":""})`;return{errors:t,message:n}}function tl(e){return e===422?"validation":e===401||e===403?"auth":e>=400&&e<500?"business":e>=500?"server":"unknown"}function rl(e,t,r){if(e===422&&Array.isArray(t)){let{message:n}=oi(t);return n}if(typeof t=="string")return t;if(t&&typeof t=="object"&&"message"in t){let n=t.message;if(typeof n=="string")return n}return r}function nl(e){let t=e.status??0,r=e.statusText??"Unknown Error",n=e.detail,o=sl(n);if(o)return new ol(o.message,{status:t,statusText:r,detail:n,errorCode:o.error_code,structuredDetails:o.details,suggestions:o.suggestions,links:o.links});let s=tl(t),i=rl(t,n,e.message),a={status:t,statusText:r,detail:n};if(s==="validation"&&Array.isArray(n)){let{errors:l}=oi(n);return new Jc(i,{...a,validationErrors:l})}return s==="auth"?new Zc(i,a):s==="business"?new ni(i,a):s==="server"?new Yc(i,a):new Qc(i,a)}var ol=class extends ni{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 sl(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 Ln=["2025-10-28","2026-01-21"],il="2026-01-21",wt=(0,ri.default)("phala::api-client");function al(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
|
|
12
|
+
`)}function cl(e){return e?` -d '${(typeof e=="string"?e:JSON.stringify(e,null,2)).replace(/'/g,"\\'")}'`:""}function Xs(e,t,r,n){let o=[];r.forEach((a,l)=>{o.push(`${l}: ${a}`)});let s=o.join(`
|
|
13
13
|
`),i=typeof n=="string"?n:JSON.stringify(n,null,2);return[`< HTTP/1.1 ${e} ${t}`,s?`< ${s.replace(/\n/g,`
|
|
14
14
|
< `)}`:"","",i].filter(Boolean).join(`
|
|
15
|
-
`)}var
|
|
16
|
-
`);
|
|
15
|
+
`)}var ll=class si{constructor(t={}){this.emitter=Zn();let r=t.apiKey||process?.env?.PHALA_CLOUD_API_KEY,n=t.baseURL||process?.env?.PHALA_CLOUD_API_PREFIX||"https://cloud-api.phala.com/api/v1",o=t.version&&Ln.includes(t.version)?t.version:il;this.config={...t,apiKey:r,baseURL:n,version:o};let{apiKey:s,baseURL:i,timeout:a,headers:l,useCookieAuth:u,onResponseError:p,...f}=this.config,h={"X-Phala-Version":o,"Content-Type":"application/json"};l&&typeof l=="object"&&Object.entries(l).forEach(([g,_])=>{typeof _=="string"&&(h[g]=_)}),!u&&s&&(h["X-API-Key"]=s),this.fetchInstance=Wc.create({baseURL:i,timeout:a||3e4,headers:h,...u?{credentials:"include"}:{},...f,onRequest({request:g,options:_}){if(wt.enabled){let P=_.method||"GET",z=typeof g=="string"?g:g.url,G=z.startsWith("http")?z:`${i}${z}`,Z={};_.headers&&typeof _.headers=="object"&&Object.entries(_.headers).forEach(([Y,oe])=>{typeof oe=="string"&&(Z[Y]=oe)});let K=[`> curl -X ${P} "${G}"`,al(Z),_.body?cl(_.body):""].filter(Boolean).join(`
|
|
16
|
+
`);wt(`
|
|
17
17
|
=== REQUEST ===
|
|
18
18
|
%s
|
|
19
|
-
`,
|
|
19
|
+
`,K)}},onResponse({request:g,response:_,options:P}){if(wt.enabled){let z=P.method||"GET",G=typeof g=="string"?g:g.url;wt(`
|
|
20
20
|
=== RESPONSE [%s %s] (%dms) ===
|
|
21
21
|
%s
|
|
22
|
-
`,z,G,_.headers.get("x-response-time")||"?",
|
|
22
|
+
`,z,G,_.headers.get("x-response-time")||"?",Xs(_.status,_.statusText,_.headers,_._data))}},onResponseError:({request:g,response:_,options:P})=>{if(wt.enabled){console.warn(`HTTP ${_.status}: ${_.url}`);let z=P.method||"GET",G=typeof g=="string"?g:g.url;wt(`
|
|
23
23
|
=== ERROR RESPONSE [%s %s] ===
|
|
24
24
|
%s
|
|
25
|
-
`,z,G,Ks(_.status,_.statusText,_.headers,_._data))}p&&p({request:g,response:_,options:P})}})}get raw(){return this.fetchInstance}on(t,r){this.emitter.on(t,r)}off(t,r){this.emitter.off(t,r)}once(t,r){let n=o=>{r(o),this.emitter.off(t,n)};this.emitter.on(t,n)}async request(t,r){try{let n=r?.method||"GET";return await this.fetchInstance(t,{...r,method:n})}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}async requestFull(t,r){try{let n=r?.method||"GET",o=await this.fetchInstance.raw(t,{...r,method:n,ignoreResponseError:!0});return{status:o.status,statusText:o.statusText,headers:o.headers,data:o._data,ok:o.ok}}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}async get(t,r){try{return await this.fetchInstance(t,{...r,method:"GET"})}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}async post(t,r,n){try{return await this.fetchInstance(t,{...n,method:"POST",body:r})}catch(o){let s=this.convertToRequestError(o);throw this.emitError(s)}}async put(t,r,n){try{return await this.fetchInstance(t,{...n,method:"PUT",body:r})}catch(o){let s=this.convertToRequestError(o);throw this.emitError(s)}}async patch(t,r,n){try{return await this.fetchInstance(t,{...n,method:"PATCH",body:r})}catch(o){let s=this.convertToRequestError(o);throw this.emitError(s)}}async delete(t,r){try{return await this.fetchInstance(t,{...r,method:"DELETE"})}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}convertToRequestError(t){return t&&typeof t=="object"&&"data"in t?kn.fromFetchError(t):t instanceof Error?kn.fromError(t):new kn("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(t){let r=el(t);return this.emitter.emit("error",r),r}async safeRequest(t){try{return{success:!0,data:await t()}}catch(r){if(r instanceof Ie)return{success:!1,error:r};let n=this.convertToRequestError(r);return this.emitError(n),{success:!1,error:n}}}async safeGet(t,r){return this.safeRequest(()=>this.get(t,r))}async safePost(t,r,n){return this.safeRequest(()=>this.post(t,r,n))}async safePut(t,r,n){return this.safeRequest(()=>this.put(t,r,n))}async safePatch(t,r,n){return this.safeRequest(()=>this.patch(t,r,n))}async safeDelete(t,r){return this.safeRequest(()=>this.delete(t,r))}async safeRequestMethod(t,r){return this.safeRequest(()=>this.request(t,r))}async safeRequestFull(t,r){return this.safeRequest(()=>this.requestFull(t,r))}withVersion(t){return new ni({...this.config,version:t})}extend(t){let r=typeof t=="function"?t(this):t,n=Object.create(this);for(let[o,s]of Object.entries(r))typeof s=="function"&&(n[o]=(...i)=>s(this,...i));return n}};function al(e={}){return new il(e)}var cl=j.object({username:j.string(),email:j.string(),role:j.enum(["admin","user"]),avatar:j.string(),email_verified:j.boolean(),totp_enabled:j.boolean(),has_backup_codes:j.boolean(),flag_has_password:j.boolean()}).passthrough(),ll=j.object({id:j.string(),name:j.string(),slug:j.string().nullable(),tier:j.string(),role:j.string(),avatar:j.string().nullable().optional()}).passthrough(),ul=j.object({balance:j.string().or(j.number()),granted_balance:j.string().or(j.number()),is_post_paid:j.boolean(),outstanding_amount:j.string().or(j.number()).nullable()}).passthrough(),pl=j.object({user:cl,workspace:ll,credits:ul}).passthrough(),fl=De.object({username:De.string(),email:De.string(),credits:De.number(),granted_credits:De.number(),avatar:De.string(),team_name:De.string(),team_tier:De.string()}).passthrough();function ml(e){return e==="2025-10-28"?fl:pl}async function oi(e,t){let r=await e.get("/auth/me");return t?.schema===!1?r:(t?.schema||ml(e.config.version)).parse(r)}async function dl(e,t){try{return{success:!0,data:await oi(e,t)}}catch(r){return r&&typeof r=="object"&&("status"in r||"issues"in r)?{success:!1,error:r}:{success:!1,error:{name:"Error",message:r instanceof Error?r.message:String(r)}}}}var hl={[Tr.id]:Tr,[Ot.id]:Ot,[Er.id]:Er},gl=Me.object({id:Me.string(),slug:Me.string().nullable(),url:Me.string(),version:Me.string(),chain_id:Me.number().nullable(),kms_contract_address:Me.string().nullable().transform(e=>e),gateway_app_id:Me.string().nullable().transform(e=>e)}).passthrough(),Ae=gl.transform(e=>{if(e.chain_id!=null){let t=hl[e.chain_id];if(t)return{...e,chain:t}}return e});function si(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 ii(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 ai(e,t){function r(i,a){return n(i,a)}async function n(i,a){si(a);let l=await t(i);return a?.schema===!1?l:(a?.schema||e).parse(l)}function o(i,a){return s(i,a)}async function s(i,a){let l=ii(a);if(l)return l;let u=await(async()=>{try{return{success:!0,data:await t(i)}}catch(f){return f&&typeof f=="object"&&"status"in f?{success:!1,error:f}:f&&typeof f=="object"&&"issues"in f?{success:!1,error:f}:{success:!1,error:{name:"Error",message:f instanceof Error?f.message:String(f)}}}})();return u.success?a?.schema===!1?{success:!0,data:u.data}:(a?.schema||e).safeParse(u.data):u}return{action:r,safeAction:o}}function S(e,t){function r(i,...a){let[l,u]=a;return n(i,l,u)}async function n(i,a,l){si(l);let u=await t(i,a);return l?.schema===!1?u:(l?.schema||e).parse(u)}function o(i,...a){let[l,u]=a;return s(i,l,u)}async function s(i,a,l){let u=ii(l);if(u)return u;let p=await(async()=>{try{return{success:!0,data:await t(i,a)}}catch(h){return h&&typeof h=="object"&&"status"in h?{success:!1,error:h}:h&&typeof h=="object"&&"issues"in h?{success:!1,error:h}:{success:!1,error:{name:"Error",message:h instanceof Error?h.message:String(h)}}}})();return p.success?l?.schema===!1?{success:!0,data:p.data}:(l?.schema||e).safeParse(p.data):p}return{action:r,safeAction:o}}var bl=k.object({name:k.string(),is_dev:k.boolean(),version:k.union([k.tuple([k.number(),k.number(),k.number()]),k.tuple([k.number(),k.number(),k.number(),k.number()])]),os_image_hash:k.string().nullable().optional()}).passthrough(),xl=k.object({teepod_id:k.number(),name:k.string(),listed:k.boolean(),resource_score:k.number(),remaining_vcpu:k.number(),remaining_memory:k.number(),remaining_cvm_slots:k.number(),images:k.array(bl),support_onchain_kms:k.boolean().optional(),fmspc:k.string().nullable().optional(),device_id:k.string().nullable().optional(),region_identifier:k.string().nullable().optional(),default_kms:k.string().nullable().optional(),kms_list:k.array(k.string()).default([])}).passthrough(),yl=k.object({max_instances:k.number().nullable().optional(),max_vcpu:k.number().nullable().optional(),max_memory:k.number().nullable().optional(),max_disk:k.number().nullable().optional()}).passthrough(),vl=k.object({tier:k.string(),capacity:yl,nodes:k.array(xl),kms_list:k.array(Ae)}).passthrough(),{action:wl,safeAction:_l}=ai(vl,async e=>await e.get("/teepods/available")),ci=O.object({id:O.string(),name:O.string(),description:O.string(),vcpu:O.number(),memory_mb:O.number(),hourly_rate:O.string(),requires_gpu:O.boolean(),default_disk_size_gb:O.number().default(20),family:O.string().nullable()}).passthrough(),Cl=O.object({name:O.string(),items:O.array(ci),total:O.number()}).strict(),kl=O.object({result:O.array(Cl)}).strict(),Sl=O.object({items:O.array(ci),total:O.number(),family:O.string()}).strict(),El=O.object({family:O.string()}).strict(),{action:Tl,safeAction:Il}=S(kl,async e=>await e.get("/instance-types")),{action:Al,safeAction:Pl}=S(Sl,async(e,t)=>{let r=El.parse(t);return await e.get(`/instance-types/${r.family}`)}),li=ie.object({id:ie.string(),name:ie.string(),slug:ie.string().nullable(),tier:ie.string(),role:ie.string(),is_default:ie.boolean(),created_at:ie.string()}).passthrough(),$l=ie.object({has_more:ie.boolean(),next_cursor:ie.string().nullable(),total:ie.number().nullable()}).passthrough(),Ll=ie.object({data:ie.array(li),pagination:$l}).passthrough(),{action:zl,safeAction:Bl}=S(Ll,async(e,t)=>{let r=new URLSearchParams;t?.cursor&&r.append("cursor",t.cursor),t?.limit&&r.append("limit",t.limit.toString());let n=r.toString()?`/workspaces?${r.toString()}`:"/workspaces";return await e.get(n)}),{action:Rl,safeAction:jl}=S(li,async(e,t)=>await e.get(`/workspaces/${t}`)),Ul=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()}),Fl=m.object({id:m.number(),username:m.string()}),ui=m.object({id:m.number(),name:m.string(),region_identifier:m.string().nullable().optional()}),$n=m.object({vcpu:m.number(),memory:m.number(),disk_size:m.number(),gpu_count:m.number().default(0)}),Ln=m.object({app:m.string(),instance:m.string()}),Hl=m.object({hosted:Ul,name:m.string(),managed_user:Fl.nullable(),node:ui.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:Ae.nullable(),vcpu:m.number().nullable(),memory:m.number().nullable(),disk_size:m.number().nullable(),gateway_domain:m.string().nullable(),public_urls:m.array(Ln),machine_info:$n.nullable().optional(),updated_at:m.string().nullable().optional()}),pi=m.object({id:m.number(),name:m.string(),status:m.string(),in_progress:m.boolean().optional().default(!1),teepod_id:m.number().nullable(),teepod:ui.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(),instance_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:Ae.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(Ln).optional().default([]),gateway_domain:m.string().optional().nullable(),machine_info:$n.optional().nullable(),updated_at:m.string().optional().nullable()}),Ol=m.object({items:m.array(Hl),total:m.number(),page:m.number(),page_size:m.number(),pages:m.number()}),Nl=d.enum(["skip","hourly","monthly"]),Gl=d.enum(["phala","ethereum","base","legacy"]),zn=d.object({object_type:d.literal("user"),id:d.string().nullable().optional(),username:d.string().nullable().optional(),avatar_url:d.string().nullable().optional()}),Bn=d.object({object_type:d.literal("workspace"),id:d.string(),name:d.string(),slug:d.string().nullable().optional(),avatar_url:d.string().nullable().optional()}),ql=d.object({instance_type:d.string().nullable().optional(),vcpu:d.number().int().nullable().optional(),memory_in_gb:d.number().nullable().optional(),disk_in_gb:d.number().int().nullable().optional(),gpus:d.number().int().nullable().optional(),compute_billing_price:d.string().nullable().optional(),billing_period:Nl.nullable().optional()}),Dl=d.object({name:d.string().nullable().optional(),version:d.string().nullable().optional(),is_dev:d.boolean().nullable().optional(),os_image_hash:d.string().nullable().optional()}),Ml=d.object({chain_id:d.number().int().nullable().optional(),dstack_kms_address:d.string().nullable().optional(),dstack_app_address:d.string().nullable().optional(),deployer_address:d.string().nullable().optional(),rpc_endpoint:d.string().nullable().optional(),encrypted_env_pubkey:d.string().nullable().optional()}),Vl=d.object({target:d.string().nullable().optional(),started_at:d.string().nullable().optional(),correlation_id:d.string().nullable().optional()}),Kl=d.object({base_domain:d.string().nullable().optional(),cname:d.string().nullable().optional()}),fi=d.object({object_type:d.literal("node"),id:d.number().int().nullable().optional(),name:d.string().nullable().optional(),region:d.string().nullable().optional(),device_id:d.string().nullable().optional(),ppid:d.string().nullable().optional(),status:d.string().nullable().optional(),version:d.string().nullable().optional()});var Br=d.object({id:d.string(),name:d.string(),app_id:d.string().nullable().optional(),vm_uuid:d.string().nullable().optional(),resource:ql,node_info:fi.nullable().optional(),os:Dl.nullable().optional(),kms_type:Gl.nullable().optional(),kms_info:Ml.nullable().optional(),status:d.string(),progress:Vl.nullable().optional(),compose_hash:d.string().nullable().optional(),gateway:Kl,services:d.array(d.record(d.any())).optional().default([]),endpoints:d.array(Ln).nullable().optional(),public_logs:d.boolean().optional(),public_sysinfo:d.boolean().optional(),public_tcbinfo:d.boolean().optional(),gateway_enabled:d.boolean().optional(),secure_time:d.boolean().optional(),storage_fs:d.string().optional(),workspace:Bn.nullable().optional(),creator:zn.nullable().optional()}),Wl=Br.extend({compose_file:d.union([d.record(d.any()),d.string()]).nullable().optional()}),Xl=d.object({items:d.array(Br),total:d.number(),page:d.number(),page_size:d.number(),pages:d.number()});function mi(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 Pe=vt.object({id:vt.string().optional(),uuid:vt.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:vt.string().optional(),instance_id:vt.string().optional(),name:vt.string().refine(mi,{message:"Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens"}).optional()}),Ke=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"}),Jl=Ke(Pe),U=Jl.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,n=/^[0-9a-f]{40}$/i,o;return r.test(t)?o=t.replace(/-/g,""):n.test(t)?o=`app_${t}`:o=t,{cvmId:o}}),Zl=U;function Yl(e){return e==="2025-10-28"?pi:Wl}async function di(e,t){let{cvmId:r}=Zl.parse(t),n=await e.get(`/cvms/${r}`);return Yl(e.config.version).parse(n)}async function Rr(e,t){try{return{success:!0,data:await di(e,t)}}catch(r){return r&&typeof r=="object"&&("status"in r||"issues"in r)?{success:!1,error:r}:{success:!1,error:{name:"Error",message:r instanceof Error?r.message:String(r)}}}}var Ql=wt.object({page:wt.number().int().min(1).optional(),page_size:wt.number().int().min(1).optional(),node_id:wt.number().int().min(1).optional(),teepod_id:wt.number().int().min(1).optional(),user_id:wt.string().optional()}).strict();function eu(e){return e==="2025-10-28"?Ol:Xl}async function hi(e,t){let r=Ql.parse(t??{}),n=await e.get("/cvms/paginated",{params:r});return eu(e.config.version).parse(n)}async function Rn(e,t){try{return{success:!0,data:await hi(e,t)}}catch(r){return r&&typeof r=="object"&&("status"in r||"issues"in r)?{success:!1,error:r}:{success:!1,error:{name:"Error",message:r instanceof Error?r.message:String(r)}}}}var Ws=200*1024;function gi(e,t,r){let n=new TextEncoder,o=e?n.encode(e).byteLength:0,s=t?n.encode(t).byteLength:0,i=o+s;if(i>Ws){let a=Ws/1024,l=Math.ceil(i/1024);r.addIssue({code:W.ZodIssueCode.custom,message:`Combined size of docker_compose_file and pre_launch_script must not exceed ${a}KB (current: ${l}KB)`})}}var bi=W.object({allowed_envs:W.array(W.string()).optional(),docker_compose_file:W.string(),features:W.array(W.string()).optional(),name:W.string().optional(),manifest_version:W.number().optional(),kms_enabled:W.boolean().optional(),public_logs:W.boolean().optional(),public_sysinfo:W.boolean().optional(),tproxy_enabled:W.boolean().optional(),pre_launch_script:W.string().optional(),env_pubkey:W.string().optional(),salt:W.string().optional().nullable()}).passthrough().superRefine((e,t)=>{gi(e.docker_compose_file,e.pre_launch_script,t)}),tu=C.object({app_id:C.string().nullable().optional(),app_env_encrypt_pubkey:C.string().nullable().optional(),compose_hash:C.string(),kms_info:Ae.nullable().optional(),fmspc:C.string().nullable().optional(),device_id:C.string().nullable().optional(),os_image_hash:C.string().nullable().optional(),instance_type:C.string().nullable().optional(),teepod_id:C.number().nullable().optional(),node_id:C.number().nullable().optional(),kms_id:C.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}),Sn="Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens",ru=C.object({node_id:C.number().optional(),teepod_id:C.number().optional(),region:C.string().optional(),name:C.string().min(5,Sn).max(63,Sn).refine(e=>mi(e),Sn),instance_type:C.string().optional(),image:C.string().optional(),vcpu:C.number().optional(),memory:C.number().optional(),disk_size:C.number().optional(),compose_file:C.object({allowed_envs:C.array(C.string()).optional(),pre_launch_script:C.string().optional(),docker_compose_file:C.string().optional(),name:C.string().optional().default(""),kms_enabled:C.boolean().optional(),public_logs:C.boolean().optional(),public_sysinfo:C.boolean().optional(),gateway_enabled:C.boolean().optional(),tproxy_enabled:C.boolean().optional()}).superRefine((e,t)=>{gi(e.docker_compose_file,e.pre_launch_script,t)}),listed:C.boolean().optional(),kms_id:C.string().optional(),kms:C.enum(["PHALA","ETHEREUM","BASE"]).optional(),kms_contract:C.string().optional(),env_keys:C.array(C.string()).optional(),nonce:C.number().optional(),app_id:C.string().optional()}).passthrough().transform(e=>!e.instance_type&&!e.vcpu&&!e.memory?{...e,instance_type:"tdx.small"}:e);function nu(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:ou,safeAction:su}=S(tu,async(e,t)=>{let r=ru.parse(t),n=nu(r),o={...n};return typeof n.node_id=="number"?(o={...n,teepod_id:n.node_id},delete o.node_id):typeof n.teepod_id=="number"&&console.warn("[phala/cloud] teepod_id is deprecated, please use node_id instead."),await e.post("/cvms/provision",o)}),iu=T.object({id:T.number(),name:T.string(),status:T.string(),teepod_id:T.number(),teepod:T.object({id:T.number(),name:T.string()}).nullable(),user_id:T.number().nullable(),app_id:T.string().nullable(),vm_uuid:T.string().nullable(),instance_id:T.string().nullable(),app_url:T.string().nullable().default(null),base_image:T.string().nullable(),vcpu:T.number(),memory:T.number(),disk_size:T.number(),manifest_version:T.number().nullable().default(2),version:T.string().nullable().default("1.0.0"),runner:T.string().nullable().default("docker-compose"),docker_compose_file:T.string().nullable(),features:T.array(T.string()).nullable().default(["kms","tproxy-net"]),created_at:T.string(),encrypted_env_pubkey:T.string().nullable().optional(),app_auth_contract_address:T.string().nullable().optional(),deployer_address:T.string().nullable().optional()}).passthrough(),vx=T.object({encrypted_env:T.string().optional().nullable(),app_id:T.string(),compose_hash:T.string(),kms_id:T.string().optional(),contract_address:T.string().optional(),deployer_address:T.string().optional(),env_keys:T.array(T.string()).optional().nullable()}).passthrough(),{action:au,safeAction:cu}=S(iu,async(e,t)=>await e.post("/cvms",t));function In(e){return e==null?e:Array.isArray(e)?e.map(In):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let n=e[r];return t[r]=In(n),t},{}):e}function xi(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 yi(e){let t=In(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function uu(e){let t=xi(e),r=yi(t);return lu.createHash("sha256").update(r,"utf8").digest("hex")}function pu(e){let t=e;return{...e,getHash:()=>uu(t),toString:()=>yi(xi(t))}}var fu=bi.transform(e=>pu(e)),mu=U,{action:du,safeAction:jn}=S(fu,async(e,t)=>{let{cvmId:r}=mu.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),hu=Ee.object({id:Ee.string().optional(),uuid:Ee.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:Ee.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:Ee.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:bi,update_env_vars:Ee.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})),gu=Ee.object({app_id:Ee.string().nullable(),device_id:Ee.string().nullable(),compose_hash:Ee.string(),kms_info:Ae.nullable().optional()}).passthrough(),{action:bu,safeAction:xu}=S(gu,async(e,t)=>{let r=hu.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),yu=ye.object({id:ye.string().optional(),uuid:ye.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:ye.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:ye.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:ye.string().min(1,"Compose hash is required"),encrypted_env:ye.string().optional(),env_keys:ye.array(ye.string()).optional(),update_env_vars:ye.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})),vu=ye.any().transform(()=>{}),{action:wu,safeAction:_u}=S(vu,async(e,t)=>{let r=yu.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})}),Cu=Ke(Pe.extend({encrypted_env:M.string().describe("Encrypted environment variables (hex string)"),env_keys:M.array(M.string()).optional().describe("List of allowed environment variable keys"),compose_hash:M.string().optional().describe("Compose hash for verification (Phase 2, required when env_keys changes)"),transaction_hash:M.string().optional().describe("On-chain transaction hash for verification (Phase 2, required when env_keys changes)")})).transform(e=>{let{cvmId:t}=U.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}}),ku=M.object({status:M.literal("in_progress"),message:M.string(),correlation_id:M.string(),allowed_envs_changed:M.boolean()}),Su=M.object({status:M.literal("precondition_required"),message:M.string(),compose_hash:M.string(),app_id:M.string(),device_id:M.string(),kms_info:Ae}),Eu=M.union([ku,Su]),{action:Tu,safeAction:Iu}=S(Eu,async(e,t)=>{let r=Cu.parse(t);try{return await e.patch(`/cvms/${r.cvmId}/envs`,r.request)}catch(n){if(n instanceof Ie&&n.status===465){let o=n.detail;if(o&&typeof o=="object"){let s=o;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 n}}),Au=Ke(Pe.extend({docker_compose_file:ae.string().describe("Docker Compose YAML content"),compose_hash:ae.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:ae.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=U.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}}),Pu=ae.object({status:ae.literal("in_progress"),message:ae.string(),correlation_id:ae.string()}),$u=ae.object({status:ae.literal("precondition_required"),message:ae.string(),compose_hash:ae.string(),app_id:ae.string(),device_id:ae.string(),kms_info:Ae}),Lu=ae.union([Pu,$u]),{action:zu,safeAction:Bu}=S(Lu,async(e,t)=>{let r=Au.parse(t),n={"Content-Type":"text/yaml"};r.request.compose_hash&&(n["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(n["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/docker-compose`,r.request.docker_compose_file,{headers:n})}catch(o){if(o instanceof Ie&&o.status===465){let s=o.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 o}}),Ru=Ke(Pe.extend({pre_launch_script:ce.string().describe("Pre-launch script content (shell script)"),compose_hash:ce.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:ce.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=U.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}}),ju=ce.object({status:ce.literal("in_progress"),message:ce.string(),correlation_id:ce.string()}),Uu=ce.object({status:ce.literal("precondition_required"),message:ce.string(),compose_hash:ce.string(),app_id:ce.string(),device_id:ce.string(),kms_info:Ae}),Fu=ce.union([ju,Uu]),{action:Hu,safeAction:Ou}=S(Fu,async(e,t)=>{let r=Ru.parse(t),n={"Content-Type":"text/plain"};r.request.compose_hash&&(n["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(n["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/pre-launch-script`,r.request.pre_launch_script,{headers:n})}catch(o){if(o instanceof Ie&&o.status===465){let s=o.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 o}}),Gu=U,{action:qu,safeAction:Du}=S(Nu.string(),async(e,t)=>{let{cvmId:r}=Gu.parse(t);return await e.get(`/cvms/${r}/pre-launch-script`)}),Mu=Xs.object({kms_id:Xs.string().min(1,"KMS ID is required")}),{action:Vu,safeAction:Ku}=S(Ae,async(e,t)=>{let r=Mu.parse(t);return await e.get(`/kms/${r.kms_id}`)}),Wu=Te.object({page:Te.number().int().min(1).optional(),page_size:Te.number().int().min(1).optional(),is_onchain:Te.boolean().optional()}).strict(),Xu=Te.object({items:Te.array(Ae),total:Te.number(),page:Te.number(),page_size:Te.number(),pages:Te.number()}).strict(),{action:Ju,safeAction:Zu}=S(Xu,async(e,t)=>{let r=Wu.parse(t??{});return await e.get("/kms",{params:r})}),Yu=Et.object({kms:Et.string().min(1,"KMS ID or slug is required"),app_id:Et.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(),Qu=Et.object({public_key:Et.string(),signature:Et.string()}).strict(),{action:ep,safeAction:tp}=S(Qu,async(e,t)=>{let r=Yu.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),rp=it.object({counts:it.number().int().min(1).max(20).optional().default(1)}).strict(),np=it.object({app_ids:it.array(it.object({app_id:it.string(),nonce:it.number().int().min(0)}))}).strict(),{action:op,safeAction:sp}=S(np,async(e,t)=>{let r=rp.parse(t??{}),n=new URLSearchParams;return n.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${n.toString()}`)}),jr=B.object({id:B.number(),name:B.string(),status:B.string(),teepod_id:B.number(),teepod:B.object({id:B.number(),name:B.string(),region_identifier:B.string().nullable().optional()}).optional().nullable(),user_id:B.number().optional().nullable(),app_id:B.string(),vm_uuid:B.string().nullable(),instance_id:B.string().nullable(),app_url:B.string().optional().nullable(),base_image:B.string().nullable(),vcpu:B.number(),memory:B.number(),disk_size:B.number(),manifest_version:B.number().optional().nullable(),version:B.string().optional().nullable(),runner:B.string().optional().nullable(),docker_compose_file:B.string().optional().nullable(),features:B.array(B.string()).optional().nullable(),created_at:B.string(),encrypted_env_pubkey:B.string().nullable()}),ip=U,{action:ap,safeAction:cp}=S(jr,async(e,t)=>{let{cvmId:r}=ip.parse(t);return await e.post(`/cvms/${r}/start`)}),lp=U,{action:up,safeAction:pp}=S(jr,async(e,t)=>{let{cvmId:r}=lp.parse(t);return await e.post(`/cvms/${r}/stop`)}),fp=U,{action:mp,safeAction:dp}=S(jr,async(e,t)=>{let{cvmId:r}=fp.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),gp=Ke(Pe.extend({force:hp.boolean().optional()})),{action:bp,safeAction:xp}=S(jr,async(e,t)=>{let r=gp.parse(t),{cvmId:n}=U.parse(r),{force:o=!1}=r;return await e.post(`/cvms/${n}/restart`,{force:o})}),vp=U,{action:wp,safeAction:_p}=S(yp.void(),async(e,t)=>{let{cvmId:r}=vp.parse(t);await e.delete(`/cvms/${r}`)}),Cp=L.object({name:L.string(),mount_point:L.string(),total_size:L.number(),free_size:L.number()}),kp=L.object({os_name:L.string(),os_version:L.string(),kernel_version:L.string(),cpu_model:L.string(),num_cpus:L.number(),total_memory:L.number(),available_memory:L.number(),used_memory:L.number(),free_memory:L.number(),total_swap:L.number(),used_swap:L.number(),free_swap:L.number(),uptime:L.number(),loadavg_one:L.number(),loadavg_five:L.number(),loadavg_fifteen:L.number(),disks:L.array(Cp)}),Sp=L.object({is_online:L.boolean(),is_public:L.boolean().default(!1),error:L.string().nullable(),sysinfo:kp.nullable(),status:L.string().nullable(),in_progress:L.boolean().default(!1),boot_progress:L.string().nullable(),boot_error:L.string().nullable()}),Ep=U,{action:Tp,safeAction:Ip}=S(Sp,async(e,t)=>{let{cvmId:r}=Ep.parse(t);return await e.get(`/cvms/${r}/stats`)}),Ap=Se.object({app:Se.string(),instance:Se.string()}),Pp=Se.object({is_online:Se.boolean(),is_public:Se.boolean().default(!0),error:Se.string().nullable(),internal_ip:Se.string().nullable(),latest_handshake:Se.string().nullable(),public_urls:Se.array(Ap).nullable()}),$p=U,{action:Lp,safeAction:zp}=S(Pp,async(e,t)=>{let{cvmId:r}=$p.parse(t);return await e.get(`/cvms/${r}/network`)}),Rp=U,{action:jp,safeAction:Up}=S(Bp.string(),async(e,t)=>{let{cvmId:r}=Rp.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),Fp=H.object({id:H.string(),names:H.array(H.string()),image:H.string(),image_id:H.string(),command:H.string().nullable().optional(),created:H.number(),state:H.string(),status:H.string(),log_endpoint:H.string().nullable()}),Hp=H.object({is_online:H.boolean(),is_public:H.boolean().default(!0),error:H.string().nullable(),docker_compose_file:H.string().nullable(),manifest_version:H.number().nullable(),version:H.string().nullable(),runner:H.string().nullable(),features:H.array(H.string()).nullable(),containers:H.array(Fp).nullable()}),Op=U,{action:Np,safeAction:Gp}=S(Hp,async(e,t)=>{let{cvmId:r}=Op.parse(t);return await e.get(`/cvms/${r}/composition`)}),qp=y.object({common_name:y.string().nullable(),organization:y.string().nullable(),country:y.string().nullable(),state:y.string().nullable(),locality:y.string().nullable()}),Dp=y.object({common_name:y.string().nullable(),organization:y.string().nullable(),country:y.string().nullable()}),Mp=y.object({subject:qp,issuer:Dp,serial_number:y.string(),not_before:y.string(),not_after:y.string(),version:y.string(),fingerprint:y.string(),signature_algorithm:y.string(),sans:y.array(y.string()).nullable(),is_ca:y.boolean(),position_in_chain:y.number().nullable(),quote:y.string().nullable(),app_id:y.string().nullable().optional(),cert_usage:y.string().nullable().optional()}),Vp=y.object({imr:y.number(),event_type:y.number(),digest:y.string(),event:y.string(),event_payload:y.string()}),Kp=y.object({mrtd:y.string(),rootfs_hash:y.string().nullable().optional(),rtmr0:y.string(),rtmr1:y.string(),rtmr2:y.string(),rtmr3:y.string(),event_log:y.array(Vp),app_compose:y.string()}),Wp=y.object({name:y.string().nullable(),is_online:y.boolean(),is_public:y.boolean().default(!0),error:y.string().nullable(),app_certificates:y.array(Mp).nullable(),tcb_info:Kp.nullable(),compose_file:y.string().nullable()}),Xp=U,{action:Jp,safeAction:Zp}=S(Wp,async(e,t)=>{let{cvmId:r}=Xp.parse(t);return await e.get(`/cvms/${r}/attestation`)}),Yp=Ke(Pe.extend({vcpu:kt.number().optional(),memory:kt.number().optional(),disk_size:kt.number().optional(),instance_type:kt.string().optional(),allow_restart:kt.boolean().optional()})),{action:Qp,safeAction:ef}=S(kt.void(),async(e,t)=>{let r=Yp.parse(t),{cvmId:n}=U.parse(r),{...o}=r;await e.patch(`/cvms/${n}/resources`,o)}),tf=Ke(Pe.extend({public_sysinfo:En.boolean(),public_logs:En.boolean(),public_tcbinfo:En.boolean().optional()})),{action:rf,safeAction:nf}=S(pi,async(e,t)=>{let r=tf.parse(t),{cvmId:n}=U.parse(r),{public_sysinfo:o,public_logs:s,public_tcbinfo:i}=r;return await e.patch(`/cvms/${n}/visibility`,{public_sysinfo:o,public_logs:s,public_tcbinfo:i})}),Js=X.object({name:X.string(),os_image_hash:X.string().nullable(),is_current:X.boolean()}),of=X.object({version:X.union([X.tuple([X.number(),X.number(),X.number(),X.number()]),X.tuple([X.number(),X.number(),X.number()])]),prod:Js.nullable(),dev:Js.nullable()}),sf=X.array(of),af=U,{action:cf,safeAction:lf}=S(sf,async(e,t)=>{let{cvmId:r}=af.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),uf=Ke(Pe.extend({os_image_name:vi.string().min(1,"OS image name is required")})),{action:pf,safeAction:ff}=S(vi.void(),async(e,t)=>{let r=uf.parse(t),{cvmId:n}=U.parse(r),{os_image_name:o}=r;await e.patch(`/cvms/${n}/os-image`,{os_image_name:o})}),mf=ke.object({id:ke.string().optional(),instance_id:ke.string().optional(),name:ke.string(),status:ke.string(),uptime:ke.string().optional(),exited_at:ke.string().optional(),boot_progress:ke.string().optional(),boot_error:ke.string().optional(),shutdown_progress:ke.string().optional()}),df=U,{action:hf,safeAction:gf}=S(mf,async(e,t)=>{let{cvmId:r}=df.parse(t);return await e.get(`/cvms/${r}/state`)}),wi=se.object({id:se.string(),user_id:se.string(),name:se.string(),public_key:se.string(),fingerprint:se.string(),key_type:se.string(),source:se.string(),key_metadata:se.record(se.unknown()).nullable().optional(),last_synced_at:se.string().nullable().optional(),created_at:se.string(),updated_at:se.string()}),bf=se.array(wi);async function _i(e){let t=await e.get("/user/ssh-keys");return bf.parse(t)}async function xf(e){try{return{success:!0,data:await _i(e)}}catch(t){return t&&typeof t=="object"&&("status"in t||"issues"in t)?{success:!1,error:t}:{success:!1,error:{name:"Error",message:t instanceof Error?t.message:String(t)}}}}var yf=Ve.object({github_username:Ve.string().min(1)}),vf=Ve.object({github_username:Ve.string(),keys_added:Ve.number().int(),keys_skipped:Ve.number().int(),errors:Ve.array(Ve.string()).default([])}),{action:wf,safeAction:_f}=S(vf,async(e,t)=>{let{github_username:r}=yf.parse(t);return await e.post("/user/ssh-keys/github-profile",{github_username:r})}),Cf=Tn.object({name:Tn.string().min(1),public_key:Tn.string().min(1)}),{action:kf,safeAction:Sf}=S(wi,async(e,t)=>{let{name:r,public_key:n}=Cf.parse(t);return await e.post("/user/ssh-keys",{name:r,public_key:n})}),Ef=An.object({keyId:An.string().min(1)}),{action:Tf,safeAction:If}=S(An.void(),async(e,t)=>{let{keyId:r}=Ef.parse(t);await e.delete(`/user/ssh-keys/${r}`)}),Af=st.object({synced_count:st.number().int(),keys_added:st.number().int(),keys_updated:st.number().int(),keys_removed:st.number().int(),errors:st.array(st.string()).default([])}),{action:Pf,safeAction:$f}=ai(Af,async e=>await e.post("/user/ssh-keys/github-sync",{}));function Ci(e={}){let t=al(e),r={getCurrentUser:oi,safeGetCurrentUser:dl,getAvailableNodes:wl,safeGetAvailableNodes:_l,listAllInstanceTypeFamilies:Tl,safeListAllInstanceTypeFamilies:Il,listFamilyInstanceTypes:Al,safeListFamilyInstanceTypes:Pl,listWorkspaces:zl,safeListWorkspaces:Bl,getWorkspace:Rl,safeGetWorkspace:jl,getCvmInfo:di,safeGetCvmInfo:Rr,getCvmList:hi,safeGetCvmList:Rn,provisionCvm:ou,safeProvisionCvm:su,commitCvmProvision:au,safeCommitCvmProvision:cu,getCvmComposeFile:du,safeGetCvmComposeFile:jn,provisionCvmComposeFileUpdate:bu,safeProvisionCvmComposeFileUpdate:xu,commitCvmComposeFileUpdate:wu,safeCommitCvmComposeFileUpdate:_u,updateCvmEnvs:Tu,safeUpdateCvmEnvs:Iu,updateDockerCompose:zu,safeUpdateDockerCompose:Bu,updatePreLaunchScript:Hu,safeUpdatePreLaunchScript:Ou,getCvmPreLaunchScript:qu,safeGetCvmPreLaunchScript:Du,startCvm:ap,safeStartCvm:cp,stopCvm:up,safeStopCvm:pp,shutdownCvm:mp,safeShutdownCvm:dp,restartCvm:bp,safeRestartCvm:xp,deleteCvm:wp,safeDeleteCvm:_p,getCvmStats:Tp,safeGetCvmStats:Ip,getCvmNetwork:Lp,safeGetCvmNetwork:zp,getCvmDockerCompose:jp,safeGetCvmDockerCompose:Up,getCvmContainersStats:Np,safeGetCvmContainersStats:Gp,getCvmAttestation:Jp,safeGetCvmAttestation:Zp,updateCvmResources:Qp,safeUpdateCvmResources:ef,updateCvmVisibility:rf,safeUpdateCvmVisibility:nf,getAvailableOsImages:cf,safeGetAvailableOsImages:lf,updateOsImage:pf,safeUpdateOsImage:ff,getKmsInfo:Vu,safeGetKmsInfo:Ku,getKmsList:Ju,safeGetKmsList:Zu,getAppEnvEncryptPubKey:ep,safeGetAppEnvEncryptPubKey:tp,nextAppIds:op,safeNextAppIds:sp,getCvmState:hf,safeGetCvmState:gf,listSshKeys:_i,safeListSshKeys:xf,importGithubProfileSshKeys:wf,safeImportGithubProfileSshKeys:_f,createSshKey:kf,safeCreateSshKey:Sf,deleteSshKey:Tf,safeDeleteSshKey:If,syncGithubSshKeys:Pf,safeSyncGithubSshKeys:$f};return t.extend(r)}var Zs=b.object({vm_uuid:b.string().nullable(),app_id:b.string(),name:b.string().default(""),status:b.string(),vcpu:b.number().int(),memory:b.number().int(),disk_size:b.number().int(),teepod_id:b.number().int(),teepod_name:b.string(),region_identifier:b.string().nullable().optional(),kms_type:b.string().nullable().optional(),instance_type:b.string().nullable().optional(),listed:b.boolean().nullable().optional(),base_image:b.string().nullable().optional(),kms_slug:b.string().nullable().optional(),kms_id:b.string().nullable().optional(),instance_id:b.string().nullable().optional(),machine_info:$n.nullable().optional(),updated_at:b.string().nullable().optional()}),Lf=b.object({display_name:b.string().nullable().optional(),avatar_url:b.string().nullable().optional(),description:b.string().nullable().optional(),custom_domain:b.string().nullable().optional()}),zf=b.object({id:b.string(),name:b.string(),app_id:b.string(),app_provision_type:b.string().nullable().optional(),app_icon_url:b.string().nullable().optional(),created_at:b.string(),kms_type:b.string(),profile:Lf.nullable().optional(),current_cvm:Zs.nullable().optional(),cvms:b.array(Zs).default([]),cvm_count:b.number().int().default(0)}),Bf=b.object({id:b.null().optional(),app_id:b.string(),name:b.null().optional(),app_provision_type:b.null().optional(),app_icon_url:b.null().optional(),created_at:b.null().optional(),kms_type:b.null().optional(),current_cvm:b.null().optional(),cvms:b.null().optional(),cvm_count:b.null().optional()}),Rf=b.union([zf,Bf]),Zx=b.object({dstack_apps:b.array(Rf),page:b.number().int(),page_size:b.number().int(),total:b.number().int(),total_pages:b.number().int()}),jf=A.object({id:A.string(),name:A.string(),app_id:A.string(),app_provision_type:A.string().nullable().optional(),app_icon_url:A.string().nullable().optional(),created_at:A.string(),kms_type:A.string(),profile:A.object({display_name:A.string().nullable().optional(),avatar_url:A.string().nullable().optional(),description:A.string().nullable().optional(),custom_domain:A.string().nullable().optional()}).nullable().optional(),current_cvm:Br.nullable().optional(),cvms:A.array(Br).default([]),cvm_count:A.number().int().default(0)}),Uf=A.object({id:A.null().optional(),app_id:A.string(),name:A.null().optional(),app_provision_type:A.null().optional(),app_icon_url:A.null().optional(),created_at:A.null().optional(),kms_type:A.null().optional(),current_cvm:A.null().optional(),cvms:A.null().optional(),cvm_count:A.null().optional()}),Ff=A.union([jf,Uf]),Qx=A.object({dstack_apps:A.array(Ff),page:A.number().int(),page_size:A.number().int(),total:A.number().int(),total_pages:A.number().int()}),ki=I.object({object_type:I.literal("cvm"),id:I.string().nullable().optional(),name:I.string().nullable().optional(),app_id:I.string().nullable().optional(),vm_uuid:I.string().nullable().optional()}),Hf=I.object({revision_id:I.string(),app_id:I.string(),vm_uuid:I.string(),compose_hash:I.string(),created_at:I.string(),trace_id:I.string().nullable().optional(),operation_type:I.string(),triggered_by:zn.nullable().optional(),cvm:ki.nullable().optional(),workspace:Bn.nullable().optional()}),ty=I.object({revision_id:I.string(),app_id:I.string(),vm_uuid:I.string(),compose_hash:I.string(),compose_file:I.union([I.record(I.any()),I.string()]).nullable().optional(),encrypted_env:I.string(),user_config:I.string(),created_at:I.string(),trace_id:I.string().nullable().optional(),operation_type:I.string(),triggered_by:zn.nullable().optional(),cvm:ki.nullable().optional(),workspace:Bn.nullable().optional()}),ry=I.object({revisions:I.array(Hf),total:I.number().int(),page:I.number().int(),page_size:I.number().int(),total_pages:I.number().int()});var Of=N.object({chain:N.unknown().optional(),rpcUrl:N.string().optional(),kmsContractAddress:N.string(),privateKey:N.string().optional(),walletClient:N.unknown().optional(),publicClient:N.unknown().optional(),allowAnyDevice:N.boolean().optional().default(!1),deviceId:N.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),composeHash:N.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),disableUpgrades:N.boolean().optional().default(!1),skipPrerequisiteChecks:N.boolean().optional().default(!1),minBalance:N.string().optional()}).passthrough(),iy=Of.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,n=!!e.chain;return t&&r?!0:n},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),ay=N.object({appId:N.string(),appAuthAddress:N.string(),deployer:N.string(),transactionHash:N.string(),blockNumber:N.bigint().optional(),gasUsed:N.bigint().optional()}).passthrough();var ly=F.object({chain:F.unknown().optional(),rpcUrl:F.string().optional(),appId:F.string(),composeHash:F.string(),privateKey:F.string().optional(),walletClient:F.unknown().optional(),publicClient:F.unknown().optional(),skipPrerequisiteChecks:F.boolean().optional().default(!1),minBalance:F.string().optional(),timeout:F.number().optional().default(12e4),retryOptions:F.unknown().optional(),signal:F.unknown().optional(),onTransactionStateChange:F.function().optional(),onTransactionSubmitted:F.function().optional(),onTransactionConfirmed:F.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,n=!!e.chain;return t&&r?!0:n},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),uy=F.object({composeHash:F.string(),appId:F.string(),transactionHash:F.string(),blockNumber:F.bigint().optional(),gasUsed:F.bigint().optional()}).passthrough();var Nf=fi;var Gf=_t.object({items:_t.array(Nf),total:_t.number(),page:_t.number(),page_size:_t.number(),pages:_t.number()}).passthrough(),{action:fy,safeAction:my}=S(Gf,async(e,t)=>{let{teamSlug:r,page:n,pageSize:o}=t,s=new URLSearchParams;n!==void 0&&s.append("page",n.toString()),o!==void 0&&s.append("page_size",o.toString());let i=s.toString()?`/workspaces/${r}/nodes?${s.toString()}`:`/workspaces/${r}/nodes`;return await e.get(i)}),St=ve.object({limit:ve.number(),remaining:ve.number()}).passthrough(),qf=ve.object({vm_slots:St,vcpu:St,memory_mb:St,disk_gb:St}).passthrough(),Df=ve.object({gpus:St,in_use:ve.number(),misconfigured:ve.number()}).passthrough(),Mf=ve.object({team_slug:ve.string(),tier:ve.string(),quotas:qf,reserved_nodes:St,reserved_gpu:Df,as_of:ve.string()}).passthrough(),{action:hy,safeAction:gy}=S(Mf,async(e,t)=>await e.get(`/workspaces/${t.teamSlug}/quotas`)),xy=Ct.object({target:Ct.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:Ct.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:Ct.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:Ct.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:Ct.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});var Vf=Q.object({vm_uuid:Q.string(),status:Q.string(),uptime:Q.string().nullable().optional(),in_progress:Q.boolean(),boot_progress:Q.string().nullable().optional(),boot_error:Q.string().nullable().optional(),operation_type:Q.string().nullable().optional(),operation_started_at:Q.string().nullable().optional(),correlation_id:Q.string().nullable().optional()}),Kf=Q.record(Q.string(),Vf),Wf=Q.object({vmUuids:Q.array(Q.string())}),{action:vy,safeAction:wy}=S(Kf,async(e,t)=>{let{vmUuids:r}=Wf.parse(t);return await e.post("/status/batch",{vm_uuids:r})}),Xf=Vt.object({hostname:Vt.string().nullable().optional(),ssh_authorized_keys:Vt.array(Vt.string()).default([]),default_gateway_domain:Vt.string().nullable().optional()}),Jf=U,{action:Cy,safeAction:ky}=S(Xf,async(e,t)=>{let{cvmId:r}=Jf.parse(t);return await e.get(`/cvms/${r}/user_config`)}),Ey=le.object({page:le.number().int().min(1).optional(),page_size:le.number().int().min(1).max(100).optional(),search:le.string().optional(),status:le.array(le.string()).optional(),listed:le.boolean().optional(),base_image:le.string().optional(),instance_type:le.string().optional(),kms_slug:le.string().optional(),kms_type:le.string().optional(),node:le.string().optional(),region:le.string().optional()}).strict();var Iy=Ys.object({appId:Ys.string().min(1)}).strict();var Py=Qs.object({appId:Qs.string().min(1)}).strict();var Ly=$r.object({appId:$r.string().min(1),page:$r.number().int().min(1).optional(),page_size:$r.number().int().min(1).max(1e3).optional()}).strict();var By=Lr.object({appId:Lr.string().min(1),revisionId:Lr.string().min(1),rawComposeFile:Lr.boolean().optional()}).strict();var jy=Y.object({statuses:Y.array(Y.string()),image_versions:Y.array(Y.string()),instance_types:Y.array(Y.string()),kms_slugs:Y.array(Y.string()),kms_types:Y.array(Y.string()),regions:Y.array(Y.string()),nodes:Y.array(Y.string())});import om from"path";import Un from"fs-extra";import sm from"@iarna/toml";import{z as $e}from"zod";import ee from"chalk";import tm from"ora";var em=!1;function we(){return em}function rm(e,t){let r=e.split(/\s+/),n=[],o="";for(let s of r){let i=o.length===0?s:`${o} ${s}`;i.length<=t?o=i:(o.length>0&&n.push(o),o=s)}return o.length>0&&n.push(o),n}function nm(e,t){if(e.length<=t)return[e];let r=[],n=0;for(;n<e.length;)r.push(e.slice(n,n+t)),n+=t;return r}function Si(e,t){let r=[];for(let n of e.split(`
|
|
26
|
-
`)){if(n.length<=t){r.push(n);continue}if(n.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
|
+
`,z,G,Xs(_.status,_.statusText,_.headers,_._data))}p&&p({request:g,response:_,options:P})}})}get raw(){return this.fetchInstance}on(t,r){this.emitter.on(t,r)}off(t,r){this.emitter.off(t,r)}once(t,r){let n=o=>{r(o),this.emitter.off(t,n)};this.emitter.on(t,n)}async request(t,r){try{let n=r?.method||"GET";return await this.fetchInstance(t,{...r,method:n})}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}async requestFull(t,r){try{let n=r?.method||"GET",o=await this.fetchInstance.raw(t,{...r,method:n,ignoreResponseError:!0});return{status:o.status,statusText:o.statusText,headers:o.headers,data:o._data,ok:o.ok}}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}async get(t,r){try{return await this.fetchInstance(t,{...r,method:"GET"})}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}async post(t,r,n){try{return await this.fetchInstance(t,{...n,method:"POST",body:r})}catch(o){let s=this.convertToRequestError(o);throw this.emitError(s)}}async put(t,r,n){try{return await this.fetchInstance(t,{...n,method:"PUT",body:r})}catch(o){let s=this.convertToRequestError(o);throw this.emitError(s)}}async patch(t,r,n){try{return await this.fetchInstance(t,{...n,method:"PATCH",body:r})}catch(o){let s=this.convertToRequestError(o);throw this.emitError(s)}}async delete(t,r){try{return await this.fetchInstance(t,{...r,method:"DELETE"})}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}convertToRequestError(t){return t&&typeof t=="object"&&"data"in t?En.fromFetchError(t):t instanceof Error?En.fromError(t):new En("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(t){let r=nl(t);return this.emitter.emit("error",r),r}async safeRequest(t){try{return{success:!0,data:await t()}}catch(r){if(r instanceof $e)return{success:!1,error:r};let n=this.convertToRequestError(r);return this.emitError(n),{success:!1,error:n}}}async safeGet(t,r){return this.safeRequest(()=>this.get(t,r))}async safePost(t,r,n){return this.safeRequest(()=>this.post(t,r,n))}async safePut(t,r,n){return this.safeRequest(()=>this.put(t,r,n))}async safePatch(t,r,n){return this.safeRequest(()=>this.patch(t,r,n))}async safeDelete(t,r){return this.safeRequest(()=>this.delete(t,r))}async safeRequestMethod(t,r){return this.safeRequest(()=>this.request(t,r))}async safeRequestFull(t,r){return this.safeRequest(()=>this.requestFull(t,r))}withVersion(t){return new si({...this.config,version:t})}extend(t){let r=typeof t=="function"?t(this):t,n=Object.create(this);for(let[o,s]of Object.entries(r))typeof s=="function"&&(n[o]=(...i)=>s(this,...i));return n}};function ul(e={}){return new ll(e)}var pl=U.object({username:U.string(),email:U.string(),role:U.enum(["admin","user"]),avatar:U.string(),email_verified:U.boolean(),totp_enabled:U.boolean(),has_backup_codes:U.boolean(),flag_has_password:U.boolean()}).passthrough(),fl=U.object({id:U.string(),name:U.string(),slug:U.string().nullable(),tier:U.string(),role:U.string(),avatar:U.string().nullable().optional()}).passthrough(),ml=U.object({balance:U.string().or(U.number()),granted_balance:U.string().or(U.number()),is_post_paid:U.boolean(),outstanding_amount:U.string().or(U.number()).nullable()}).passthrough(),dl=U.object({user:pl,workspace:fl,credits:ml}).passthrough(),hl=Ke.object({username:Ke.string(),email:Ke.string(),credits:Ke.number(),granted_credits:Ke.number(),avatar:Ke.string(),team_name:Ke.string(),team_tier:Ke.string()}).passthrough();function gl(e){return e==="2025-10-28"?hl:dl}async function ii(e,t){let r=await e.get("/auth/me");return t?.schema===!1?r:(t?.schema||gl(e.config.version)).parse(r)}async function bl(e,t){try{return{success:!0,data:await ii(e,t)}}catch(r){return r&&typeof r=="object"&&("status"in r||"issues"in r)?{success:!1,error:r}:{success:!1,error:{name:"Error",message:r instanceof Error?r.message:String(r)}}}}var xl={[Pr.id]:Pr,[Gt.id]:Gt,[Ar.id]:Ar},yl=We.object({id:We.string(),slug:We.string().nullable(),url:We.string(),version:We.string(),chain_id:We.number().nullable(),kms_contract_address:We.string().nullable().transform(e=>e),gateway_app_id:We.string().nullable().transform(e=>e)}).passthrough(),Le=yl.transform(e=>{if(e.chain_id!=null){let t=xl[e.chain_id];if(t)return{...e,chain:t}}return e});function ai(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 ci(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 li(e,t){function r(i,a){return n(i,a)}async function n(i,a){ai(a);let l=await t(i);return a?.schema===!1?l:(a?.schema||e).parse(l)}function o(i,a){return s(i,a)}async function s(i,a){let l=ci(a);if(l)return l;let u=await(async()=>{try{return{success:!0,data:await t(i)}}catch(f){return f&&typeof f=="object"&&"status"in f?{success:!1,error:f}:f&&typeof f=="object"&&"issues"in f?{success:!1,error:f}:{success:!1,error:{name:"Error",message:f instanceof Error?f.message:String(f)}}}})();return u.success?a?.schema===!1?{success:!0,data:u.data}:(a?.schema||e).safeParse(u.data):u}return{action:r,safeAction:o}}function C(e,t){function r(i,...a){let[l,u]=a;return n(i,l,u)}async function n(i,a,l){ai(l);let u=await t(i,a);return l?.schema===!1?u:(l?.schema||e).parse(u)}function o(i,...a){let[l,u]=a;return s(i,l,u)}async function s(i,a,l){let u=ci(l);if(u)return u;let p=await(async()=>{try{return{success:!0,data:await t(i,a)}}catch(h){return h&&typeof h=="object"&&"status"in h?{success:!1,error:h}:h&&typeof h=="object"&&"issues"in h?{success:!1,error:h}:{success:!1,error:{name:"Error",message:h instanceof Error?h.message:String(h)}}}})();return p.success?l?.schema===!1?{success:!0,data:p.data}:(l?.schema||e).safeParse(p.data):p}return{action:r,safeAction:o}}var vl=S.object({name:S.string(),is_dev:S.boolean(),version:S.union([S.tuple([S.number(),S.number(),S.number()]),S.tuple([S.number(),S.number(),S.number(),S.number()])]),os_image_hash:S.string().nullable().optional()}).passthrough(),wl=S.object({teepod_id:S.number(),name:S.string(),listed:S.boolean(),resource_score:S.number(),remaining_vcpu:S.number(),remaining_memory:S.number(),remaining_cvm_slots:S.number(),images:S.array(vl),support_onchain_kms:S.boolean().optional(),fmspc:S.string().nullable().optional(),device_id:S.string().nullable().optional(),region_identifier:S.string().nullable().optional(),default_kms:S.string().nullable().optional(),kms_list:S.array(S.string()).default([])}).passthrough(),_l=S.object({max_instances:S.number().nullable().optional(),max_vcpu:S.number().nullable().optional(),max_memory:S.number().nullable().optional(),max_disk:S.number().nullable().optional()}).passthrough(),Cl=S.object({tier:S.string(),capacity:_l,nodes:S.array(wl),kms_list:S.array(Le)}).passthrough(),{action:kl,safeAction:Sl}=li(Cl,async e=>await e.get("/teepods/available")),ui=O.object({id:O.string(),name:O.string(),description:O.string(),vcpu:O.number(),memory_mb:O.number(),hourly_rate:O.string(),requires_gpu:O.boolean(),default_disk_size_gb:O.number().default(20),family:O.string().nullable()}).passthrough(),El=O.object({name:O.string(),items:O.array(ui),total:O.number()}).strict(),Tl=O.object({result:O.array(El)}).strict(),Il=O.object({items:O.array(ui),total:O.number(),family:O.string()}).strict(),Al=O.object({family:O.string()}).strict(),{action:Pl,safeAction:$l}=C(Tl,async e=>await e.get("/instance-types")),{action:Ll,safeAction:zl}=C(Il,async(e,t)=>{let r=Al.parse(t);return await e.get(`/instance-types/${r.family}`)}),pi=te.object({id:te.string(),name:te.string(),slug:te.string().nullable(),tier:te.string(),role:te.string(),is_default:te.boolean(),created_at:te.string(),confidential_models_enabled:te.boolean().optional()}).passthrough(),Rl=te.object({has_more:te.boolean(),next_cursor:te.string().nullable(),total:te.number().nullable()}).passthrough(),Bl=te.object({data:te.array(pi),pagination:Rl}).passthrough(),{action:jl,safeAction:Ul}=C(Bl,async(e,t)=>{let r=new URLSearchParams;t?.cursor&&r.append("cursor",t.cursor),t?.limit&&r.append("limit",t.limit.toString());let n=r.toString()?`/workspaces?${r.toString()}`:"/workspaces";return await e.get(n)}),{action:Fl,safeAction:Hl}=C(pi,async(e,t)=>await e.get(`/workspaces/${t}`)),Ol=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()}),Nl=m.object({id:m.number(),username:m.string()}),fi=m.object({id:m.number(),name:m.string(),region_identifier:m.string().nullable().optional()}),zn=m.object({vcpu:m.number(),memory:m.number(),disk_size:m.number(),gpu_count:m.number().default(0)}),Rn=m.object({app:m.string(),instance:m.string()}),Gl=m.object({hosted:Ol,name:m.string(),managed_user:Nl.nullable(),node:fi.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:Le.nullable(),vcpu:m.number().nullable(),memory:m.number().nullable(),disk_size:m.number().nullable(),gateway_domain:m.string().nullable(),public_urls:m.array(Rn),machine_info:zn.nullable().optional(),updated_at:m.string().nullable().optional()}),mi=m.object({id:m.number(),name:m.string(),status:m.string(),in_progress:m.boolean().optional().default(!1),teepod_id:m.number().nullable(),teepod:fi.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(),instance_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:Le.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(Rn).optional().default([]),gateway_domain:m.string().optional().nullable(),machine_info:zn.optional().nullable(),updated_at:m.string().optional().nullable()}),ql=m.object({items:m.array(Gl),total:m.number(),page:m.number(),page_size:m.number(),pages:m.number()}),Dl=d.enum(["skip","hourly","monthly"]),Ml=d.enum(["phala","ethereum","base","legacy"]),Bn=d.object({object_type:d.literal("user"),id:d.string().nullable().optional(),username:d.string().nullable().optional(),avatar_url:d.string().nullable().optional()}),jn=d.object({object_type:d.literal("workspace"),id:d.string(),name:d.string(),slug:d.string().nullable().optional(),avatar_url:d.string().nullable().optional()}),Vl=d.object({instance_type:d.string().nullable().optional(),vcpu:d.number().int().nullable().optional(),memory_in_gb:d.number().nullable().optional(),disk_in_gb:d.number().int().nullable().optional(),gpus:d.number().int().nullable().optional(),compute_billing_price:d.string().nullable().optional(),billing_period:Dl.nullable().optional()}),Kl=d.object({name:d.string().nullable().optional(),version:d.string().nullable().optional(),is_dev:d.boolean().nullable().optional(),os_image_hash:d.string().nullable().optional()}),Wl=d.object({chain_id:d.number().int().nullable().optional(),dstack_kms_address:d.string().nullable().optional(),dstack_app_address:d.string().nullable().optional(),deployer_address:d.string().nullable().optional(),rpc_endpoint:d.string().nullable().optional(),encrypted_env_pubkey:d.string().nullable().optional()}),Xl=d.object({target:d.string().nullable().optional(),started_at:d.string().nullable().optional(),correlation_id:d.string().nullable().optional()}),Jl=d.object({base_domain:d.string().nullable().optional(),cname:d.string().nullable().optional()}),di=d.object({object_type:d.literal("node"),id:d.number().int().nullable().optional(),name:d.string().nullable().optional(),region:d.string().nullable().optional(),device_id:d.string().nullable().optional(),ppid:d.string().nullable().optional(),status:d.string().nullable().optional(),version:d.string().nullable().optional()});var Ur=d.object({id:d.string(),name:d.string(),app_id:d.string().nullable().optional(),vm_uuid:d.string().nullable().optional(),instance_id:d.string().nullable().optional(),resource:Vl,node_info:di.nullable().optional(),os:Kl.nullable().optional(),kms_type:Ml.nullable().optional(),kms_info:Wl.nullable().optional(),status:d.string(),progress:Xl.nullable().optional(),compose_hash:d.string().nullable().optional(),gateway:Jl,services:d.array(d.record(d.any())).optional().default([]),endpoints:d.array(Rn).nullable().optional(),public_logs:d.boolean().optional(),public_sysinfo:d.boolean().optional(),public_tcbinfo:d.boolean().optional(),gateway_enabled:d.boolean().optional(),secure_time:d.boolean().optional(),listed:d.boolean().optional().default(!1),storage_fs:d.string().optional(),workspace:jn.nullable().optional(),creator:Bn.nullable().optional()}),Zl=Ur.extend({compose_file:d.union([d.record(d.any()),d.string()]).nullable().optional()}),Yl=d.object({items:d.array(Ur),total:d.number(),page:d.number(),page_size:d.number(),pages:d.number()});function hi(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 be=_t.object({id:_t.string().optional(),uuid:_t.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:_t.string().optional(),instance_id:_t.string().optional(),name:_t.string().refine(hi,{message:"Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens"}).optional()}),ze=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"}),Ql=ze(be),B=Ql.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,n=/^[0-9a-f]{40}$/i,o;return r.test(t)?o=t.replace(/-/g,""):n.test(t)?o=`app_${t}`:o=t,{cvmId:o}}),eu=B;function tu(e){return e==="2025-10-28"?mi:Zl}async function gi(e,t){let{cvmId:r}=eu.parse(t),n=await e.get(`/cvms/${r}`);return tu(e.config.version).parse(n)}async function Fr(e,t){try{return{success:!0,data:await gi(e,t)}}catch(r){return r&&typeof r=="object"&&("status"in r||"issues"in r)?{success:!1,error:r}:{success:!1,error:{name:"Error",message:r instanceof Error?r.message:String(r)}}}}var ru=Ct.object({page:Ct.number().int().min(1).optional(),page_size:Ct.number().int().min(1).optional(),node_id:Ct.number().int().min(1).optional(),teepod_id:Ct.number().int().min(1).optional(),user_id:Ct.string().optional()}).strict();function nu(e){return e==="2025-10-28"?ql:Yl}async function bi(e,t){let r=ru.parse(t??{}),n=await e.get("/cvms/paginated",{params:r});return nu(e.config.version).parse(n)}async function Un(e,t){try{return{success:!0,data:await bi(e,t)}}catch(r){return r&&typeof r=="object"&&("status"in r||"issues"in r)?{success:!1,error:r}:{success:!1,error:{name:"Error",message:r instanceof Error?r.message:String(r)}}}}var Js=200*1024;function xi(e,t,r){let n=new TextEncoder,o=e?n.encode(e).byteLength:0,s=t?n.encode(t).byteLength:0,i=o+s;if(i>Js){let a=Js/1024,l=Math.ceil(i/1024);r.addIssue({code:X.ZodIssueCode.custom,message:`Combined size of docker_compose_file and pre_launch_script must not exceed ${a}KB (current: ${l}KB)`})}}var yi=X.object({allowed_envs:X.array(X.string()).optional(),docker_compose_file:X.string(),features:X.array(X.string()).optional(),name:X.string().optional(),manifest_version:X.number().optional(),kms_enabled:X.boolean().optional(),public_logs:X.boolean().optional(),public_sysinfo:X.boolean().optional(),tproxy_enabled:X.boolean().optional(),pre_launch_script:X.string().optional(),env_pubkey:X.string().optional(),salt:X.string().optional().nullable()}).passthrough().superRefine((e,t)=>{xi(e.docker_compose_file,e.pre_launch_script,t)}),ou=k.object({app_id:k.string().nullable().optional(),app_env_encrypt_pubkey:k.string().nullable().optional(),compose_hash:k.string(),kms_info:Le.nullable().optional(),fmspc:k.string().nullable().optional(),device_id:k.string().nullable().optional(),os_image_hash:k.string().nullable().optional(),instance_type:k.string().nullable().optional(),teepod_id:k.number().nullable().optional(),node_id:k.number().nullable().optional(),kms_id:k.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}),Tn="Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens",su=k.object({node_id:k.number().optional(),teepod_id:k.number().optional(),region:k.string().optional(),name:k.string().min(5,Tn).max(63,Tn).refine(e=>hi(e),Tn),instance_type:k.string().optional(),image:k.string().optional(),vcpu:k.number().optional(),memory:k.number().optional(),disk_size:k.number().optional(),compose_file:k.object({allowed_envs:k.array(k.string()).optional(),pre_launch_script:k.string().optional(),docker_compose_file:k.string().optional(),name:k.string().optional().default(""),kms_enabled:k.boolean().optional(),public_logs:k.boolean().optional(),public_sysinfo:k.boolean().optional(),gateway_enabled:k.boolean().optional(),tproxy_enabled:k.boolean().optional()}).superRefine((e,t)=>{xi(e.docker_compose_file,e.pre_launch_script,t)}),listed:k.boolean().optional(),kms_id:k.string().optional(),kms:k.enum(["PHALA","ETHEREUM","BASE"]).optional(),kms_contract:k.string().optional(),env_keys:k.array(k.string()).optional(),nonce:k.number().optional(),app_id:k.string().optional()}).passthrough().transform(e=>!e.instance_type&&!e.vcpu&&!e.memory?{...e,instance_type:"tdx.small"}:e);function iu(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:au,safeAction:cu}=C(ou,async(e,t)=>{let r=su.parse(t),n=iu(r),o={...n};return typeof n.node_id=="number"?(o={...n,teepod_id:n.node_id},delete o.node_id):typeof n.teepod_id=="number"&&console.warn("[phala/cloud] teepod_id is deprecated, please use node_id instead."),await e.post("/cvms/provision",o)}),lu=T.object({id:T.number(),name:T.string(),status:T.string(),teepod_id:T.number(),teepod:T.object({id:T.number(),name:T.string()}).nullable(),user_id:T.number().nullable(),app_id:T.string().nullable(),vm_uuid:T.string().nullable(),instance_id:T.string().nullable(),app_url:T.string().nullable().default(null),base_image:T.string().nullable(),vcpu:T.number(),memory:T.number(),disk_size:T.number(),manifest_version:T.number().nullable().default(2),version:T.string().nullable().default("1.0.0"),runner:T.string().nullable().default("docker-compose"),docker_compose_file:T.string().nullable(),features:T.array(T.string()).nullable().default(["kms","tproxy-net"]),created_at:T.string(),encrypted_env_pubkey:T.string().nullable().optional(),app_auth_contract_address:T.string().nullable().optional(),deployer_address:T.string().nullable().optional()}).passthrough(),Ix=T.object({encrypted_env:T.string().optional().nullable(),app_id:T.string(),compose_hash:T.string(),kms_id:T.string().optional(),contract_address:T.string().optional(),deployer_address:T.string().optional(),env_keys:T.array(T.string()).optional().nullable()}).passthrough(),{action:uu,safeAction:pu}=C(lu,async(e,t)=>await e.post("/cvms",t));function Pn(e){return e==null?e:Array.isArray(e)?e.map(Pn):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let n=e[r];return t[r]=Pn(n),t},{}):e}function vi(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 wi(e){let t=Pn(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function mu(e){let t=vi(e),r=wi(t);return fu.createHash("sha256").update(r,"utf8").digest("hex")}function du(e){let t=e;return{...e,getHash:()=>mu(t),toString:()=>wi(vi(t))}}var hu=yi.transform(e=>du(e)),gu=B,{action:bu,safeAction:Fn}=C(hu,async(e,t)=>{let{cvmId:r}=gu.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),xu=Ae.object({id:Ae.string().optional(),uuid:Ae.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:Ae.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:Ae.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:yi,update_env_vars:Ae.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})),yu=Ae.object({app_id:Ae.string().nullable(),device_id:Ae.string().nullable(),compose_hash:Ae.string(),kms_info:Le.nullable().optional()}).passthrough(),{action:vu,safeAction:wu}=C(yu,async(e,t)=>{let r=xu.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),_u=we.object({id:we.string().optional(),uuid:we.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:we.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:we.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:we.string().min(1,"Compose hash is required"),encrypted_env:we.string().optional(),env_keys:we.array(we.string()).optional(),update_env_vars:we.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})),Cu=we.any().transform(()=>{}),{action:ku,safeAction:Su}=C(Cu,async(e,t)=>{let r=_u.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})}),Eu=ze(be.extend({encrypted_env:V.string().describe("Encrypted environment variables (hex string)"),env_keys:V.array(V.string()).optional().describe("List of allowed environment variable keys"),compose_hash:V.string().optional().describe("Compose hash for verification (Phase 2, required when env_keys changes)"),transaction_hash:V.string().optional().describe("On-chain transaction hash for verification (Phase 2, required when env_keys changes)")})).transform(e=>{let{cvmId:t}=B.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}}),Tu=V.object({status:V.literal("in_progress"),message:V.string(),correlation_id:V.string(),allowed_envs_changed:V.boolean()}),Iu=V.object({status:V.literal("precondition_required"),message:V.string(),compose_hash:V.string(),app_id:V.string(),device_id:V.string(),kms_info:Le}),Au=V.union([Tu,Iu]),{action:Pu,safeAction:$u}=C(Au,async(e,t)=>{let r=Eu.parse(t);try{return await e.patch(`/cvms/${r.cvmId}/envs`,r.request)}catch(n){if(n instanceof $e&&n.status===465){let o=n.detail;if(o&&typeof o=="object"){let s=o;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 n}}),Lu=ze(be.extend({docker_compose_file:ce.string().describe("Docker Compose YAML content"),compose_hash:ce.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:ce.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=B.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}}),zu=ce.object({status:ce.literal("in_progress"),message:ce.string(),correlation_id:ce.string()}),Ru=ce.object({status:ce.literal("precondition_required"),message:ce.string(),compose_hash:ce.string(),app_id:ce.string(),device_id:ce.string(),kms_info:Le}),Bu=ce.union([zu,Ru]),{action:ju,safeAction:Uu}=C(Bu,async(e,t)=>{let r=Lu.parse(t),n={"Content-Type":"text/yaml"};r.request.compose_hash&&(n["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(n["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/docker-compose`,r.request.docker_compose_file,{headers:n})}catch(o){if(o instanceof $e&&o.status===465){let s=o.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 o}}),Fu=ze(be.extend({pre_launch_script:le.string().describe("Pre-launch script content (shell script)"),compose_hash:le.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:le.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=B.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}}),Hu=le.object({status:le.literal("in_progress"),message:le.string(),correlation_id:le.string()}),Ou=le.object({status:le.literal("precondition_required"),message:le.string(),compose_hash:le.string(),app_id:le.string(),device_id:le.string(),kms_info:Le}),Nu=le.union([Hu,Ou]),{action:Gu,safeAction:qu}=C(Nu,async(e,t)=>{let r=Fu.parse(t),n={"Content-Type":"text/plain"};r.request.compose_hash&&(n["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(n["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/pre-launch-script`,r.request.pre_launch_script,{headers:n})}catch(o){if(o instanceof $e&&o.status===465){let s=o.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 o}}),Mu=B,{action:Vu,safeAction:Ku}=C(Du.string(),async(e,t)=>{let{cvmId:r}=Mu.parse(t);return await e.get(`/cvms/${r}/pre-launch-script`)}),Wu=Zs.object({kms_id:Zs.string().min(1,"KMS ID is required")}),{action:Xu,safeAction:Ju}=C(Le,async(e,t)=>{let r=Wu.parse(t);return await e.get(`/kms/${r.kms_id}`)}),Zu=Pe.object({page:Pe.number().int().min(1).optional(),page_size:Pe.number().int().min(1).optional(),is_onchain:Pe.boolean().optional()}).strict(),Yu=Pe.object({items:Pe.array(Le),total:Pe.number(),page:Pe.number(),page_size:Pe.number(),pages:Pe.number()}).strict(),{action:Qu,safeAction:ep}=C(Yu,async(e,t)=>{let r=Zu.parse(t??{});return await e.get("/kms",{params:r})}),tp=It.object({kms:It.string().min(1,"KMS ID or slug is required"),app_id:It.string().refine(e=>e.length===40||e.startsWith("0x")&&e.length===42,"App ID must be exactly 40 characters or 42 characters with 0x prefix")}).strict(),rp=It.object({public_key:It.string(),signature:It.string()}).strict(),{action:np,safeAction:op}=C(rp,async(e,t)=>{let r=tp.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),sp=ct.object({counts:ct.number().int().min(1).max(20).optional().default(1)}).strict(),ip=ct.object({app_ids:ct.array(ct.object({app_id:ct.string(),nonce:ct.number().int().min(0)}))}).strict(),{action:ap,safeAction:cp}=C(ip,async(e,t)=>{let r=sp.parse(t??{}),n=new URLSearchParams;return n.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${n.toString()}`)}),Xt=R.object({id:R.number(),name:R.string(),status:R.string(),teepod_id:R.number(),teepod:R.object({id:R.number(),name:R.string(),region_identifier:R.string().nullable().optional()}).optional().nullable(),user_id:R.number().optional().nullable(),app_id:R.string(),vm_uuid:R.string().nullable(),instance_id:R.string().nullable(),app_url:R.string().optional().nullable(),base_image:R.string().optional().nullable(),vcpu:R.number(),memory:R.number(),disk_size:R.number(),manifest_version:R.number().optional().nullable(),version:R.string().optional().nullable(),runner:R.string().optional().nullable(),docker_compose_file:R.string().optional().nullable(),features:R.array(R.string()).optional().nullable(),created_at:R.string(),encrypted_env_pubkey:R.string().nullable()}),lp=B,{action:up,safeAction:pp}=C(Xt,async(e,t)=>{let{cvmId:r}=lp.parse(t);return await e.post(`/cvms/${r}/start`)}),fp=B,{action:mp,safeAction:dp}=C(Xt,async(e,t)=>{let{cvmId:r}=fp.parse(t);return await e.post(`/cvms/${r}/stop`)}),hp=B,{action:gp,safeAction:bp}=C(Xt,async(e,t)=>{let{cvmId:r}=hp.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),yp=ze(be.extend({force:xp.boolean().optional()})),{action:vp,safeAction:wp}=C(Xt,async(e,t)=>{let r=yp.parse(t),{cvmId:n}=B.parse(r),{force:o=!1}=r;return await e.post(`/cvms/${n}/restart`,{force:o})}),Cp=B,{action:kp,safeAction:Sp}=C(_p.void(),async(e,t)=>{let{cvmId:r}=Cp.parse(t);await e.delete(`/cvms/${r}`)}),Ep=L.object({name:L.string(),mount_point:L.string(),total_size:L.number(),free_size:L.number()}),Tp=L.object({os_name:L.string(),os_version:L.string(),kernel_version:L.string(),cpu_model:L.string(),num_cpus:L.number(),total_memory:L.number(),available_memory:L.number(),used_memory:L.number(),free_memory:L.number(),total_swap:L.number(),used_swap:L.number(),free_swap:L.number(),uptime:L.number(),loadavg_one:L.number(),loadavg_five:L.number(),loadavg_fifteen:L.number(),disks:L.array(Ep)}),Ip=L.object({is_online:L.boolean(),is_public:L.boolean().default(!1),error:L.string().nullable(),sysinfo:Tp.nullable(),status:L.string().nullable(),in_progress:L.boolean().default(!1),boot_progress:L.string().nullable(),boot_error:L.string().nullable()}),Ap=B,{action:Pp,safeAction:$p}=C(Ip,async(e,t)=>{let{cvmId:r}=Ap.parse(t);return await e.get(`/cvms/${r}/stats`)}),Lp=Ie.object({app:Ie.string(),instance:Ie.string()}),zp=Ie.object({is_online:Ie.boolean(),is_public:Ie.boolean().default(!0),error:Ie.string().nullable(),internal_ip:Ie.string().nullable(),latest_handshake:Ie.string().nullable(),public_urls:Ie.array(Lp).nullable()}),Rp=B,{action:Bp,safeAction:jp}=C(zp,async(e,t)=>{let{cvmId:r}=Rp.parse(t);return await e.get(`/cvms/${r}/network`)}),Fp=B,{action:Hp,safeAction:Op}=C(Up.string(),async(e,t)=>{let{cvmId:r}=Fp.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),Np=H.object({id:H.string(),names:H.array(H.string()),image:H.string(),image_id:H.string(),command:H.string().nullable().optional(),created:H.number(),state:H.string(),status:H.string(),log_endpoint:H.string().nullable()}),Gp=H.object({is_online:H.boolean(),is_public:H.boolean().default(!0),error:H.string().nullable(),docker_compose_file:H.string().nullable(),manifest_version:H.number().nullable(),version:H.string().nullable(),runner:H.string().nullable(),features:H.array(H.string()).nullable(),containers:H.array(Np).nullable()}),qp=B,{action:Dp,safeAction:Mp}=C(Gp,async(e,t)=>{let{cvmId:r}=qp.parse(t);return await e.get(`/cvms/${r}/composition`)}),Vp=y.object({common_name:y.string().nullable(),organization:y.string().nullable(),country:y.string().nullable(),state:y.string().nullable(),locality:y.string().nullable()}),Kp=y.object({common_name:y.string().nullable(),organization:y.string().nullable(),country:y.string().nullable()}),Wp=y.object({subject:Vp,issuer:Kp,serial_number:y.string(),not_before:y.string(),not_after:y.string(),version:y.string(),fingerprint:y.string(),signature_algorithm:y.string(),sans:y.array(y.string()).nullable(),is_ca:y.boolean(),position_in_chain:y.number().nullable(),quote:y.string().nullable(),app_id:y.string().nullable().optional(),cert_usage:y.string().nullable().optional()}),Xp=y.object({imr:y.number(),event_type:y.number(),digest:y.string(),event:y.string(),event_payload:y.string()}),Jp=y.object({mrtd:y.string(),rootfs_hash:y.string().nullable().optional(),rtmr0:y.string(),rtmr1:y.string(),rtmr2:y.string(),rtmr3:y.string(),event_log:y.array(Xp),app_compose:y.string()}),Zp=y.object({name:y.string().nullable(),is_online:y.boolean(),is_public:y.boolean().default(!0),error:y.string().nullable(),app_certificates:y.array(Wp).nullable(),tcb_info:Jp.nullable(),compose_file:y.string().nullable()}),Yp=B,{action:Qp,safeAction:ef}=C(Zp,async(e,t)=>{let{cvmId:r}=Yp.parse(t);return await e.get(`/cvms/${r}/attestation`)}),tf=ze(be.extend({vcpu:Et.number().optional(),memory:Et.number().optional(),disk_size:Et.number().optional(),instance_type:Et.string().optional(),allow_restart:Et.boolean().optional()})),{action:rf,safeAction:nf}=C(Et.void(),async(e,t)=>{let r=tf.parse(t),{cvmId:n}=B.parse(r),{...o}=r;await e.patch(`/cvms/${n}/resources`,o)}),of=ze(be.extend({public_sysinfo:In.boolean(),public_logs:In.boolean(),public_tcbinfo:In.boolean().optional()})),{action:sf,safeAction:af}=C(mi,async(e,t)=>{let r=of.parse(t),{cvmId:n}=B.parse(r),{public_sysinfo:o,public_logs:s,public_tcbinfo:i}=r;return await e.patch(`/cvms/${n}/visibility`,{public_sysinfo:o,public_logs:s,public_tcbinfo:i})}),Ys=J.object({name:J.string(),os_image_hash:J.string().nullable(),is_current:J.boolean()}),cf=J.object({version:J.union([J.tuple([J.number(),J.number(),J.number(),J.number()]),J.tuple([J.number(),J.number(),J.number()])]),prod:Ys.nullable(),dev:Ys.nullable()}),lf=J.array(cf),uf=B,{action:pf,safeAction:ff}=C(lf,async(e,t)=>{let{cvmId:r}=uf.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),mf=ze(be.extend({os_image_name:_i.string().min(1,"OS image name is required")})),{action:df,safeAction:hf}=C(_i.void(),async(e,t)=>{let r=mf.parse(t),{cvmId:n}=B.parse(r),{os_image_name:o}=r;await e.patch(`/cvms/${n}/os-image`,{os_image_name:o})}),gf=Te.object({id:Te.string().optional(),instance_id:Te.string().optional(),name:Te.string(),status:Te.string(),uptime:Te.string().optional(),exited_at:Te.string().optional(),boot_progress:Te.string().optional(),boot_error:Te.string().optional(),shutdown_progress:Te.string().optional()}),bf=B,{action:xf,safeAction:yf}=C(gf,async(e,t)=>{let{cvmId:r}=bf.parse(t);return await e.get(`/cvms/${r}/state`)}),Ci=ae.object({id:ae.string(),user_id:ae.string(),name:ae.string(),public_key:ae.string(),fingerprint:ae.string(),key_type:ae.string(),source:ae.string(),key_metadata:ae.record(ae.unknown()).nullable().optional(),last_synced_at:ae.string().nullable().optional(),created_at:ae.string(),updated_at:ae.string()}),vf=ae.array(Ci);async function ki(e){let t=await e.get("/user/ssh-keys");return vf.parse(t)}async function wf(e){try{return{success:!0,data:await ki(e)}}catch(t){return t&&typeof t=="object"&&("status"in t||"issues"in t)?{success:!1,error:t}:{success:!1,error:{name:"Error",message:t instanceof Error?t.message:String(t)}}}}var _f=Xe.object({github_username:Xe.string().min(1)}),Cf=Xe.object({github_username:Xe.string(),keys_added:Xe.number().int(),keys_skipped:Xe.number().int(),errors:Xe.array(Xe.string()).default([])}),{action:kf,safeAction:Sf}=C(Cf,async(e,t)=>{let{github_username:r}=_f.parse(t);return await e.post("/user/ssh-keys/github-profile",{github_username:r})}),Ef=An.object({name:An.string().min(1),public_key:An.string().min(1)}),{action:Tf,safeAction:If}=C(Ci,async(e,t)=>{let{name:r,public_key:n}=Ef.parse(t);return await e.post("/user/ssh-keys",{name:r,public_key:n})}),Af=$n.object({keyId:$n.string().min(1)}),{action:Pf,safeAction:$f}=C($n.void(),async(e,t)=>{let{keyId:r}=Af.parse(t);await e.delete(`/user/ssh-keys/${r}`)}),Lf=at.object({synced_count:at.number().int(),keys_added:at.number().int(),keys_updated:at.number().int(),keys_removed:at.number().int(),errors:at.array(at.string()).default([])}),{action:zf,safeAction:Rf}=li(Lf,async e=>await e.post("/user/ssh-keys/github-sync",{}));function Si(e={}){let t=ul(e),r={getCurrentUser:ii,safeGetCurrentUser:bl,getAvailableNodes:kl,safeGetAvailableNodes:Sl,listAllInstanceTypeFamilies:Pl,safeListAllInstanceTypeFamilies:$l,listFamilyInstanceTypes:Ll,safeListFamilyInstanceTypes:zl,listWorkspaces:jl,safeListWorkspaces:Ul,getWorkspace:Fl,safeGetWorkspace:Hl,getCvmInfo:gi,safeGetCvmInfo:Fr,getCvmList:bi,safeGetCvmList:Un,provisionCvm:au,safeProvisionCvm:cu,commitCvmProvision:uu,safeCommitCvmProvision:pu,getCvmComposeFile:bu,safeGetCvmComposeFile:Fn,provisionCvmComposeFileUpdate:vu,safeProvisionCvmComposeFileUpdate:wu,commitCvmComposeFileUpdate:ku,safeCommitCvmComposeFileUpdate:Su,updateCvmEnvs:Pu,safeUpdateCvmEnvs:$u,updateDockerCompose:ju,safeUpdateDockerCompose:Uu,updatePreLaunchScript:Gu,safeUpdatePreLaunchScript:qu,getCvmPreLaunchScript:Vu,safeGetCvmPreLaunchScript:Ku,startCvm:up,safeStartCvm:pp,stopCvm:mp,safeStopCvm:dp,shutdownCvm:gp,safeShutdownCvm:bp,restartCvm:vp,safeRestartCvm:wp,deleteCvm:kp,safeDeleteCvm:Sp,getCvmStats:Pp,safeGetCvmStats:$p,getCvmNetwork:Bp,safeGetCvmNetwork:jp,getCvmDockerCompose:Hp,safeGetCvmDockerCompose:Op,getCvmContainersStats:Dp,safeGetCvmContainersStats:Mp,getCvmAttestation:Qp,safeGetCvmAttestation:ef,updateCvmResources:rf,safeUpdateCvmResources:nf,updateCvmVisibility:sf,safeUpdateCvmVisibility:af,getAvailableOsImages:pf,safeGetAvailableOsImages:ff,updateOsImage:df,safeUpdateOsImage:hf,getKmsInfo:Xu,safeGetKmsInfo:Ju,getKmsList:Qu,safeGetKmsList:ep,getAppEnvEncryptPubKey:np,safeGetAppEnvEncryptPubKey:op,nextAppIds:ap,safeNextAppIds:cp,getCvmState:xf,safeGetCvmState:yf,listSshKeys:ki,safeListSshKeys:wf,importGithubProfileSshKeys:kf,safeImportGithubProfileSshKeys:Sf,createSshKey:Tf,safeCreateSshKey:If,deleteSshKey:Pf,safeDeleteSshKey:$f,syncGithubSshKeys:zf,safeSyncGithubSshKeys:Rf};return t.extend(r)}var Qs=b.object({vm_uuid:b.string().nullable(),app_id:b.string(),name:b.string().default(""),status:b.string(),vcpu:b.number().int(),memory:b.number().int(),disk_size:b.number().int(),teepod_id:b.number().int(),teepod_name:b.string(),region_identifier:b.string().nullable().optional(),kms_type:b.string().nullable().optional(),instance_type:b.string().nullable().optional(),listed:b.boolean().nullable().optional(),base_image:b.string().nullable().optional(),kms_slug:b.string().nullable().optional(),kms_id:b.string().nullable().optional(),instance_id:b.string().nullable().optional(),machine_info:zn.nullable().optional(),updated_at:b.string().nullable().optional()}),Bf=b.object({display_name:b.string().nullable().optional(),avatar_url:b.string().nullable().optional(),description:b.string().nullable().optional(),custom_domain:b.string().nullable().optional()}),jf=b.object({id:b.string(),name:b.string(),app_id:b.string(),app_provision_type:b.string().nullable().optional(),app_icon_url:b.string().nullable().optional(),created_at:b.string(),kms_type:b.string(),profile:Bf.nullable().optional(),current_cvm:Qs.nullable().optional(),cvms:b.array(Qs).default([]),cvm_count:b.number().int().default(0)}),Uf=b.object({id:b.null().optional(),app_id:b.string(),name:b.null().optional(),app_provision_type:b.null().optional(),app_icon_url:b.null().optional(),created_at:b.null().optional(),kms_type:b.null().optional(),current_cvm:b.null().optional(),cvms:b.null().optional(),cvm_count:b.null().optional()}),Ff=b.union([jf,Uf]),sy=b.object({dstack_apps:b.array(Ff),page:b.number().int(),page_size:b.number().int(),total:b.number().int(),total_pages:b.number().int()}),Hf=A.object({id:A.string(),name:A.string(),app_id:A.string(),app_provision_type:A.string().nullable().optional(),app_icon_url:A.string().nullable().optional(),created_at:A.string(),kms_type:A.string(),profile:A.object({display_name:A.string().nullable().optional(),avatar_url:A.string().nullable().optional(),description:A.string().nullable().optional(),custom_domain:A.string().nullable().optional()}).nullable().optional(),current_cvm:Ur.nullable().optional(),cvms:A.array(Ur).default([]),cvm_count:A.number().int().default(0)}),Of=A.object({id:A.null().optional(),app_id:A.string(),name:A.null().optional(),app_provision_type:A.null().optional(),app_icon_url:A.null().optional(),created_at:A.null().optional(),kms_type:A.null().optional(),current_cvm:A.null().optional(),cvms:A.null().optional(),cvm_count:A.null().optional()}),Nf=A.union([Hf,Of]),ay=A.object({dstack_apps:A.array(Nf),page:A.number().int(),page_size:A.number().int(),total:A.number().int(),total_pages:A.number().int()}),Ei=I.object({object_type:I.literal("cvm"),id:I.string().nullable().optional(),name:I.string().nullable().optional(),app_id:I.string().nullable().optional(),vm_uuid:I.string().nullable().optional()}),Gf=I.object({revision_id:I.string(),app_id:I.string(),vm_uuid:I.string(),compose_hash:I.string(),created_at:I.string(),trace_id:I.string().nullable().optional(),operation_type:I.string(),triggered_by:Bn.nullable().optional(),cvm:Ei.nullable().optional(),workspace:jn.nullable().optional()}),ly=I.object({revision_id:I.string(),app_id:I.string(),vm_uuid:I.string(),compose_hash:I.string(),compose_file:I.union([I.record(I.any()),I.string()]).nullable().optional(),encrypted_env:I.string(),user_config:I.string(),created_at:I.string(),trace_id:I.string().nullable().optional(),operation_type:I.string(),triggered_by:Bn.nullable().optional(),cvm:Ei.nullable().optional(),workspace:jn.nullable().optional()}),uy=I.object({revisions:I.array(Gf),total:I.number().int(),page:I.number().int(),page_size:I.number().int(),total_pages:I.number().int()});var qf=N.object({chain:N.unknown().optional(),rpcUrl:N.string().optional(),kmsContractAddress:N.string(),privateKey:N.string().optional(),walletClient:N.unknown().optional(),publicClient:N.unknown().optional(),allowAnyDevice:N.boolean().optional().default(!1),deviceId:N.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),composeHash:N.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),disableUpgrades:N.boolean().optional().default(!1),skipPrerequisiteChecks:N.boolean().optional().default(!1),minBalance:N.string().optional()}).passthrough(),dy=qf.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,n=!!e.chain;return t&&r?!0:n},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),hy=N.object({appId:N.string(),appAuthAddress:N.string(),deployer:N.string(),transactionHash:N.string(),blockNumber:N.bigint().optional(),gasUsed:N.bigint().optional()}).passthrough();var by=F.object({chain:F.unknown().optional(),rpcUrl:F.string().optional(),appId:F.string(),composeHash:F.string(),privateKey:F.string().optional(),walletClient:F.unknown().optional(),publicClient:F.unknown().optional(),skipPrerequisiteChecks:F.boolean().optional().default(!1),minBalance:F.string().optional(),timeout:F.number().optional().default(12e4),retryOptions:F.unknown().optional(),signal:F.unknown().optional(),onTransactionStateChange:F.function().optional(),onTransactionSubmitted:F.function().optional(),onTransactionConfirmed:F.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,n=!!e.chain;return t&&r?!0:n},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),xy=F.object({composeHash:F.string(),appId:F.string(),transactionHash:F.string(),blockNumber:F.bigint().optional(),gasUsed:F.bigint().optional()}).passthrough();var Df=di;var Mf=kt.object({items:kt.array(Df),total:kt.number(),page:kt.number(),page_size:kt.number(),pages:kt.number()}).passthrough(),{action:vy,safeAction:wy}=C(Mf,async(e,t)=>{let{teamSlug:r,page:n,pageSize:o}=t,s=new URLSearchParams;n!==void 0&&s.append("page",n.toString()),o!==void 0&&s.append("page_size",o.toString());let i=s.toString()?`/workspaces/${r}/nodes?${s.toString()}`:`/workspaces/${r}/nodes`;return await e.get(i)}),Tt=Ce.object({limit:Ce.number(),remaining:Ce.number()}).passthrough(),Vf=Ce.object({vm_slots:Tt,vcpu:Tt,memory_mb:Tt,disk_gb:Tt}).passthrough(),Kf=Ce.object({gpus:Tt,in_use:Ce.number(),misconfigured:Ce.number()}).passthrough(),Wf=Ce.object({team_slug:Ce.string(),tier:Ce.string(),quotas:Vf,reserved_nodes:Tt,reserved_gpu:Kf,as_of:Ce.string()}).passthrough(),{action:Cy,safeAction:ky}=C(Wf,async(e,t)=>await e.get(`/workspaces/${t.teamSlug}/quotas`)),Jf=ze(be.extend({node_id:Xf.number().optional()})),{action:Ey,safeAction:Ty}=C(Xt,async(e,t)=>{let r=Jf.parse(t),{cvmId:n}=B.parse(r),{node_id:o}=r;return await e.post(`/cvms/${n}/replicas`,{node_id:o})}),Ay=St.object({target:St.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:St.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:St.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:St.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:St.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});var Ti=_e.object({cvm_id:_e.number().int(),identifier:_e.string(),status:_e.enum(["updated","unchanged","skipped","conflict","error"]),old_instance_id:_e.string().nullable().optional(),new_instance_id:_e.string().nullable().optional(),source:_e.enum(["teepod_state","teepod_info","gateway","none"]),verified_with_gateway:_e.boolean(),reason:_e.string().nullable().optional()}),Zf=ze(be.extend({overwrite:_e.boolean().optional(),dry_run:_e.boolean().optional()})),{action:$y,safeAction:Ly}=C(Ti,async(e,t)=>{let r=Zf.parse(t),{cvmId:n}=B.parse(r),{overwrite:o,dry_run:s}=r;return await e.patch(`/cvms/${n}/instance-id`,{overwrite:o,dry_run:s})}),Yf=M.object({cvm_ids:M.array(M.string()).optional(),running_only:M.boolean().optional(),missing_only:M.boolean().optional(),overwrite:M.boolean().optional(),limit:M.number().int().min(1).max(500).optional(),dry_run:M.boolean().optional()}).strict(),Qf=M.object({total:M.number().int(),scanned:M.number().int(),updated:M.number().int(),unchanged:M.number().int(),skipped:M.number().int(),conflicts:M.number().int(),errors:M.number().int(),items:M.array(Ti)}),{action:Ry,safeAction:By}=C(Qf,async(e,t)=>{let r=Yf.parse(t);return await e.patch("/cvms/instance-ids",r)}),em=ee.object({vm_uuid:ee.string(),status:ee.string(),uptime:ee.string().nullable().optional(),in_progress:ee.boolean(),boot_progress:ee.string().nullable().optional(),boot_error:ee.string().nullable().optional(),operation_type:ee.string().nullable().optional(),operation_started_at:ee.string().nullable().optional(),correlation_id:ee.string().nullable().optional()}),tm=ee.record(ee.string(),em),rm=ee.object({vmUuids:ee.array(ee.string())}),{action:Uy,safeAction:Fy}=C(tm,async(e,t)=>{let{vmUuids:r}=rm.parse(t);return await e.post("/status/batch",{vm_uuids:r})}),nm=Wt.object({hostname:Wt.string().nullable().optional(),ssh_authorized_keys:Wt.array(Wt.string()).default([]),default_gateway_domain:Wt.string().nullable().optional()}),om=B,{action:Oy,safeAction:Ny}=C(nm,async(e,t)=>{let{cvmId:r}=om.parse(t);return await e.get(`/cvms/${r}/user_config`)}),qy=ue.object({page:ue.number().int().min(1).optional(),page_size:ue.number().int().min(1).max(100).optional(),search:ue.string().optional(),status:ue.array(ue.string()).optional(),listed:ue.boolean().optional(),base_image:ue.string().optional(),instance_type:ue.string().optional(),kms_slug:ue.string().optional(),kms_type:ue.string().optional(),node:ue.string().optional(),region:ue.string().optional()}).strict();var My=ei.object({appId:ei.string().min(1)}).strict();var Ky=ti.object({appId:ti.string().min(1)}).strict();var Xy=Rr.object({appId:Rr.string().min(1),page:Rr.number().int().min(1).optional(),page_size:Rr.number().int().min(1).max(1e3).optional()}).strict();var Zy=Br.object({appId:Br.string().min(1),revisionId:Br.string().min(1),rawComposeFile:Br.boolean().optional()}).strict();var Qy=Q.object({statuses:Q.array(Q.string()),image_versions:Q.array(Q.string()),instance_types:Q.array(Q.string()),kms_slugs:Q.array(Q.string()),kms_types:Q.array(Q.string()),regions:Q.array(Q.string()),nodes:Q.array(Q.string())});import fm from"path";import Hn from"fs-extra";import mm from"@iarna/toml";import{z as Re}from"zod";import re from"chalk";import lm from"ora";var cm=!1;function ke(){return cm}function um(e,t){let r=e.split(/\s+/),n=[],o="";for(let s of r){let i=o.length===0?s:`${o} ${s}`;i.length<=t?o=i:(o.length>0&&n.push(o),o=s)}return o.length>0&&n.push(o),n}function pm(e,t){if(e.length<=t)return[e];let r=[],n=0;for(;n<e.length;)r.push(e.slice(n,n+t)),n+=t;return r}function Ii(e,t){let r=[];for(let n of e.split(`
|
|
26
|
+
`)){if(n.length<=t){r.push(n);continue}if(n.indexOf(" ")===-1){r.push(...pm(n,t));continue}let o=um(n,t);r.push(...o)}if(r.length===0){let n=e.trim();r.push(n)}return r}var Je={error:(e,...t)=>{ke()||(process.stderr.write(`${re.red("\u2717")} ${re.red(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
27
|
+
`))},warn:(e,...t)=>{ke()||(process.stderr.write(`${re.yellow("\u26A0")} ${re.yellow(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
28
|
+
`))},info:(e,...t)=>{ke()||(process.stderr.write(`${re.blue("\u2139")} ${re.blue(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
29
|
+
`))},success:(e,...t)=>{ke()||(process.stderr.write(`${re.green("\u2713")} ${re.green(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
30
|
+
`))},debug:(e,...t)=>{ke()||process.env.DEBUG&&(process.stderr.write(`${re.gray("\u{1F50D}")} ${re.gray(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
31
|
+
`))},table:(e,t)=>{if(!ke()){if(e.length===0){console.log(re.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 n={};for(let i of r){let a=i.header||String(i.key);n[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)]??"");n[String(a.key)]=Math.max(n[String(a.key)],l.length)}let o=[];for(let i of r){let a=i.header||String(i.key);o.push(re.bold(a.padEnd(n[String(i.key)])))}console.log(o.join(" "));let s=[];for(let i of r)s.push("-".repeat(n[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(n[String(l.key)]))}console.log(a.join(" "))}}else{let r=e[0],n=Object.keys(r),o={};for(let a of n)o[a]=a.length;for(let a of e)for(let l of n){let u=String(a[l]??"");o[l]=Math.max(o[l],u.length)}let s=[];for(let a of n)s.push(re.bold(a.padEnd(o[a])));console.log(s.join(" "));let i=[];for(let a of n)i.push("-".repeat(o[a]));console.log(i.join(" "));for(let a of e){let l=[];for(let u of n){let p=String(a[u]??"");l.push(p.padEnd(o[u]))}console.log(l.join(" "))}}}},keyValueTable:(e,t)=>{if(ke())return;let{borderStyle:r="single",keyColor:n=re.blue,valueColor:o=re.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[_,P]of Object.entries(e)){l=Math.max(l,_.length);let z=String(P??"");u=Math.max(u,z.length)}let p=4,f=1,h=s-p-f;if(l+u>h){let _=l/(l+u);l=Math.floor(h*_),u=h-l}let g=l+u+p+f;r!=="none"&&console.log(a.topLeft+a.horizontal.repeat(g-2)+a.topRight);for(let[_,P]of Object.entries(e)){let z=_,G=String(P??""),Z=Ii(z,l),K=Ii(G,u),Y=Math.max(Z.length,K.length);for(;Z.length<Y;)Z.push("");for(;K.length<Y;)K.push("");for(let oe=0;oe<Y;oe++){let pe=Z[oe].padEnd(l),Jt=K[oe].padEnd(u);console.log(r!=="none"?`${a.vertical} ${n(pe)} ${a.vertical} ${o(Jt)} ${a.vertical}`:`${n(pe)} : ${o(Jt)}`)}}r!=="none"&&console.log(a.bottomLeft+a.horizontal.repeat(g-2)+a.bottomRight)},break:()=>{ke()||process.stderr.write(`
|
|
32
|
+
`)},startSpinner:e=>{if(ke())return{stop:()=>{}};let t=lm(e).start();return{stop:(r=!0,n)=>{n&&(t.text=n),r?t.succeed():t.fail()}}},logDetailedError(e,t){if(ke())return;let r=t?`[${t}] `:"",n=s=>s!==null&&typeof s=="object"&&"isRequestError"in s&&s.isRequestError===!0&&"status"in s&&"message"in s&&"data"in s,o=s=>s!==null&&typeof s=="object"&&"issues"in s&&Array.isArray(s.issues);if(n(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(o(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
|
|
38
|
-
Run 'phala init' to create one.`);try{let t=
|
|
37
|
+
`)}};var dm=be.extend({profile:Re.string().optional(),api_version:Re.enum(Ln).optional(),gateway_domain:Re.string().optional(),gateway_port:Re.number().int().positive().optional(),compose_file:Re.string().optional(),env_file:Re.string().optional(),public_logs:Re.boolean().optional(),public_sysinfo:Re.boolean().optional(),listed:Re.boolean().optional()}),On="phala.toml";function Ai(){return fm.join(process.cwd(),On)}function hm(){return Hn.existsSync(Ai())}function gm(){let e=Ai();if(!Hn.existsSync(e))throw new Error(`Project configuration file not found: ${On}
|
|
38
|
+
Run 'phala init' to create one.`);try{let t=Hn.readFileSync(e,"utf8"),r=mm.parse(t),n=dm.parse(r);if(n.id||n.uuid||n.app_id||n.instance_id||n.name){let{cvmId:o}=B.parse(n);return{...n,cvm_id:o}}return n}catch(t){if(t instanceof Re.ZodError){let r=t.issues.map(n=>` - ${n.path.join(".")}: ${n.message}`).join(`
|
|
39
39
|
`);throw new Error(`Invalid project configuration:
|
|
40
|
-
${r}`)}throw new Error(`Failed to parse ${
|
|
41
|
-
`})}return r}function
|
|
42
|
-
`)}return r}async function
|
|
40
|
+
${r}`)}throw new Error(`Failed to parse ${On}: ${t instanceof Error?t.message:String(t)}`)}}function Pi(){return hm()?gm():{}}import $i from"fs";import bm from"os";import zi from"path";var Li="https://cloud-api.phala.com/api/v1";function xm(){let e=process.env.PHALA_CLOUD_DIR;return typeof e=="string"&&e.trim().length>0?e:zi.join(bm.homedir(),".phala-cloud")}function ym(){return zi.join(xm(),"credentials.json")}function Hr(e){return typeof e=="string"&&e.trim().length>0}function vm(e){let t=e.trim();return t.length===0?"default":t}function wm(){try{let e=ym();if(!$i.existsSync(e))return null;let t=$i.readFileSync(e,"utf8"),r=JSON.parse(t);if(!r||typeof r!="object")return null;let n=r;return n.schema_version!==1||!Hr(n.current_profile)||!n.profiles||typeof n.profiles!="object"?null:n}catch(e){return Je.error("Failed to read credentials file:",e),null}}function Ri(e){let t=wm(),r=vm(e.profile||e.projectProfile||t?.current_profile||"default"),n=e.env.PHALA_CLOUD_API_PREFIX,o=t?.profiles?.[r]?.api_prefix,s=(n&&n.trim().length>0?n:o&&o.trim().length>0?o:Li)??Li,i=n?"env":o?"file":"default";if(Hr(e.apiToken))return{apiKey:e.apiToken,baseURL:s,profileName:r,tokenSource:"flag",apiPrefixSource:i};if(Hr(e.env.PHALA_CLOUD_API_KEY))return{apiKey:e.env.PHALA_CLOUD_API_KEY,baseURL:s,profileName:r,tokenSource:"env",apiPrefixSource:i};let a=t?.profiles?.[r]?.token;return Hr(a)?{apiKey:a,baseURL:s,profileName:r,tokenSource:"file",apiPrefixSource:i}:{apiKey:null,baseURL:s,profileName:r,tokenSource:"none",apiPrefixSource:i}}var _m="2026-01-21";function Cm(){return{env:process.env,projectConfig:Pi()}}function km(e,t){let r=e??Cm();return Ri({env:r.env,apiToken:t?.apiToken,profile:t?.profile,projectProfile:r.projectConfig.profile})}async function ne(e,t){let r=km(e,t);return Si({apiKey:r.apiKey??void 0,baseURL:r.baseURL,version:_m})}import{z as c}from"zod";var Sm=c.object({password:c.string(),registry:c.string().nullable(),username:c.string()}),Lv=c.object({docker_compose_file:c.string(),docker_config:Sm.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(),Bi=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()}),zv=c.object({key:c.string(),value:c.string()}),ji=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()}))}),Ui=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()}),Fi=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()}),Em=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()}),Rv=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(Em).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 Tm from"inquirer";async function Nv(e){let t=await ne(),r=e.replace(/^app_/,""),n=await Fr(t,{app_id:r});if(!n.success)throw new Error(n.error.message);return n.data}async function Gv(e){let t=await ne(),r=await Fn(t,{id:e});if(!r.success)throw new Error(r.error.message);return r.data}async function qv(e){let t=await ne(),r=e.replace(/^app_/,""),n=await t.get(`cvms/app_${r}/network`);return ji.parse(n)}async function Dv(){let e=Je.startSpinner("Fetching available CVMs"),t=await ne(),r=await Un(t);if(e.stop(!0),!r.success){Je.error(`Failed to fetch CVMs: ${r.error.message}`);return}let{items:n}=r.data;if(n.length===0){Je.info("No CVMs found for your account");return}let o=n.map(i=>({name:`${i.name} (${i.app_id??i.id}) - ${i.status}`,value:i.app_id??i.id})),{selectedCvm:s}=await Tm.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:o}]);return s}async function Mv(e){let t=await ne(),r=e.replace(/^app_/,""),n=await t.get(`cvms/app_${r}/attestation`);try{return Fi.parse(n)}catch(o){return Je.debug(`Validation error: ${o instanceof Error?o.message:String(o)}`),{is_online:!!n?.is_online,is_public:!!n?.is_public,error:typeof n?.error=="string"?n.error:null,app_certificates:Array.isArray(n?.app_certificates)?n.app_certificates:null,tcb_info:n?.tcb_info||null,compose_file:typeof n?.compose_file=="string"?n.compose_file:null}}}async function Vv(e,t){let r=await ne(),n=e.replace(/^app_/,""),o=await r.post(`cvms/app_${n}/replicas`,t);return Ui.parse(o)}async function Kv(e,t,r,n,o){let s=await ne(),i=e.replace(/^app_/,""),a={};if(t!==void 0&&(a.vcpu=t),r!==void 0&&(a.memory=r),n!==void 0&&(a.disk_size=n),o!==void 0&&(a.allow_restart=o),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 Wv(e){return await(await ne()).post("cvms/pubkey/from_cvm_configuration",e)}async function Xv(e){let r=await(await ne()).post("cvms/from_cvm_configuration",e);return Bi.parse(r)}async function Jv(e,t){let r=await ne(),n=e.replace(/^app_/,"");return await r.put(`cvms/app_${n}/compose`,t)}async function Zv(e=!1){let t=await ne(),r="teepods/available";return e&&(r+="?v03x_only=1"),await t.get(r)}function Ze(e,t){let r=[];t.since&&r.push(`since=${encodeURIComponent(t.since)}`),t.until&&r.push(`until=${encodeURIComponent(t.until)}`),t.follow&&r.push("follow"),t.text&&r.push("text"),t.bare&&r.push("bare"),t.tail!==void 0&&(r.push(`tail=${t.tail}`),r.push(`lines=${t.tail}`)),t.timestamps&&r.push("timestamps"),(t.ansi??!0)&&r.push("ansi");let n=e.includes("?")?"&":"?";return e+n+r.join("&")}async function Hi(e,t){let r=e.body?.getReader();if(!r)throw new Error("No response body available for streaming");let n=new TextDecoder;for(;;){let{done:o,value:s}=await r.read();if(o)break;t(n.decode(s,{stream:!0}))}}function Im(e){return!e||/\s/.test(e)||e.length%4!==0?!1:/^[A-Za-z0-9+/]+={0,2}$/.test(e)}function Am(e){if(!Im(e))return e;try{return Buffer.from(e,"base64").toString("utf-8")}catch{return e}}function Or(e){let t=e.trim();if(!t)return null;try{let r=JSON.parse(t);return typeof r.message!="string"?null:{channel:r.channel==="stderr"?"stderr":"stdout",message:Am(r.message)}}catch{return null}}function Pm(e){let t=e.split(/\r?\n/),r=[];for(let n of t){if(!n.trim())continue;let o=Or(n);if(o){r.push(o);continue}r.push({channel:"stdout",message:`${n}
|
|
41
|
+
`})}return r}function $m(e){let t=e.split(/\r?\n/),r="";for(let n of t){let o=Or(n);if(o){r+=o.message;continue}n.trim()&&(r+=`${n}
|
|
42
|
+
`)}return r}async function Lm(e,t){let r=e.body?.getReader();if(!r)throw new Error("No response body available for streaming");let n=new TextDecoder,o="",s="unknown",i=a=>{let l=Or(a);if(l){t(l.message);return}a.trim()&&t(`${a}
|
|
43
43
|
`)};for(;;){let{done:a,value:l}=await r.read();if(a)break;let u=n.decode(l,{stream:!0});if(s==="raw"){t(u);continue}if(o+=u,s==="unknown")if(o.trimStart().startsWith("{"))s="structured";else{s="raw",t(o),o="";continue}let p=o.indexOf(`
|
|
44
44
|
`);for(;p>=0;){let f=o.slice(0,p);o=o.slice(p+1),i(f),p=o.indexOf(`
|
|
45
|
-
`)}}s==="structured"&&o.trim()?i(o):s==="raw"&&o&&t(o)}async function
|
|
45
|
+
`)}}s==="structured"&&o.trim()?i(o):s==="raw"&&o&&t(o)}async function zm(e,t){let r=e.body?.getReader();if(!r)throw new Error("No response body available for streaming");let n=new TextDecoder,o="",s="unknown",i=a=>{let l=Or(a);if(l){t(l);return}a.trim()&&t({channel:"stdout",message:`${a}
|
|
46
46
|
`})};for(;;){let{done:a,value:l}=await r.read();if(a)break;let u=n.decode(l,{stream:!0});if(s==="raw"){t({channel:"stdout",message:u});continue}if(o+=u,s==="unknown")if(o.trimStart().startsWith("{"))s="structured";else{s="raw",t({channel:"stdout",message:o}),o="";continue}let p=o.indexOf(`
|
|
47
47
|
`);for(;p>=0;){let f=o.slice(0,p);o=o.slice(p+1),i(f),p=o.indexOf(`
|
|
48
|
-
`)}}s==="structured"&&o.trim()?i(o):s==="raw"&&o&&t({channel:"stdout",message:o})}async function
|
|
48
|
+
`)}}s==="structured"&&o.trim()?i(o):s==="raw"&&o&&t({channel:"stdout",message:o})}async function Nn(e,t){let n=await(await ne()).get(`cvms/${e}`,{headers:{"X-Phala-Version":"2025-10-28"}});if(!n.syslog_endpoint)throw new Error(`No syslog endpoint available for CVM '${e}'`);return`${n.syslog_endpoint}&ch=${t}`}async function Oi(e){return Nn(e,"serial")}async function Nr(e,t,r=!0){let o=await(await ne()).get(`cvms/${e}/composition`);if(!o.containers?.length)throw new Error(`No containers found for CVM '${e}'`);let s=o.containers;if(t&&(s=s.filter(a=>a.names.some(u=>u===t||u===`/${t}`)?!0:r?a.id.startsWith(t):!1),!s.length))throw new Error(`Container '${t}' not found in CVM '${e}'`);let i=s.find(a=>a.log_endpoint);if(!i?.log_endpoint)throw new Error(`No log endpoints available for CVM '${e}'`);return i.log_endpoint}async function Yv(e,t={}){let r=await Oi(e),n=Ze(r,t),o=await fetch(n);if(!o.ok)throw new Error(`Failed to fetch serial logs: ${o.status} ${o.statusText}`);return o.text()}async function Qv(e,t={}){let r=await Nr(e,t.container,t.matchContainerIdPrefix??!0),n=t.text??!0,o=t.bare??!0,s=Ze(r,{...t,text:n,bare:o}),i=await fetch(s);if(!i.ok)throw new Error(`Failed to fetch container logs: ${i.status} ${i.statusText}`);let a=await i.text();return a.trimStart().startsWith("{")?$m(a):a}async function ew(e,t={}){let r=await Nr(e,t.container,t.matchContainerIdPrefix??!0),n=Ze(r,{...t,text:!1,bare:!1}),o=await fetch(n);if(!o.ok)throw new Error(`Failed to fetch container logs: ${o.status} ${o.statusText}`);let s=await o.text();return s.trimStart().startsWith("{")?Pm(s):[{channel:"stdout",message:s}]}async function tw(e,t,r={},n){let o=await Nr(e,r.container,r.matchContainerIdPrefix??!0),s=Ze(o,{...r,follow:!0,text:!1,bare:!1}),i=await fetch(s,{signal:n});if(!i.ok)throw new Error(`Failed to stream container logs: ${i.status} ${i.statusText}`);await zm(i,t)}async function rw(e,t,r={},n){let o=await Oi(e),s=Ze(o,{...r,follow:!0}),i=await fetch(s,{signal:n});if(!i.ok)throw new Error(`Failed to stream serial logs: ${i.status} ${i.statusText}`);await Hi(i,t)}async function nw(e,t,r={},n){let o=await Nr(e,r.container,r.matchContainerIdPrefix??!0),s=r.text??!0,i=r.bare??!0,a=Ze(o,{...r,follow:!0,text:s,bare:i}),l=await fetch(a,{signal:n});if(!l.ok)throw new Error(`Failed to stream container logs: ${l.status} ${l.statusText}`);await Lm(l,t)}async function ow(e,t,r={}){let n=await Nn(e,t),o=Ze(n,r),s=await fetch(o);if(!s.ok)throw new Error(`Failed to fetch CVM ${t} logs: ${s.status} ${s.statusText}`);return s.text()}async function sw(e,t,r,n={},o){let s=await Nn(e,t),i=Ze(s,{...n,follow:!0}),a=await fetch(i,{signal:o});if(!a.ok)throw new Error(`Failed to stream CVM ${t} logs: ${a.status} ${a.statusText}`);await Hi(a,r)}async function iw(e){let t=await ne(),r=e.replace(/^app_/,""),n=await Fr(t,{app_id:r});if(!n.success)throw new Error(n.error.message);return n.data.status}export{Lv as composeFileSchema,Xv as createCvm,Fi as cvmAttestationResponseSchema,Sm as dockerConfigSchema,zv as encryptedEnvItemSchema,Qv as fetchContainerLogs,ew as fetchContainerLogsEntries,ow as fetchCvmChannelLogs,Yv as fetchSerialLogs,Mv as getCvmAttestation,Nv as getCvmByAppId,Gv as getCvmComposeConfig,Nn as getCvmLogEndpoint,qv as getCvmNetwork,ji as getCvmNetworkResponseSchema,iw as getCvmStatus,Wv as getPubkeyFromCvm,Zv as getTeepods,Em as imageSchema,Bi as postCvmResponseSchema,Vv as replicateCvm,Ui as replicateCvmResponseSchema,Kv as resizeCvm,Dv as selectCvm,nw as streamContainerLogs,tw as streamContainerLogsEntries,sw as streamCvmChannelLogs,rw as streamSerialLogs,Rv as teepodSchema,Jv as upgradeCvm};
|
|
49
49
|
/*! Bundled license information:
|
|
50
50
|
|
|
51
51
|
@noble/hashes/esm/utils.js:
|