phala 1.1.9 → 1.1.10
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 +165 -165
- package/package.json +2 -2
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 Hi=Object.create;var Nn=Object.defineProperty;var Oi=Object.getOwnPropertyDescriptor;var Ni=Object.getOwnPropertyNames;var Gi=Object.getPrototypeOf,qi=Object.prototype.hasOwnProperty;var je=(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 pe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Di=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ni(t))!qi.call(e,o)&&o!==r&&Nn(e,o,{get:()=>t[o],enumerable:!(n=Oi(t,o))||n.enumerable});return e};var Tt=(e,t,r)=>(r=e!=null?Hi(Gi(e)):{},Di(t||!e||!e.__esModule?Nn(r,"default",{value:e,enumerable:!0}):r,e));var qn=pe((Tm,Gn)=>{var at=1e3,ct=at*60,lt=ct*60,Je=lt*24,Mi=Je*7,Vi=Je*365.25;Gn.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Ki(e);if(r==="number"&&isFinite(e))return t.long?Xi(e):Wi(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Ki(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*Vi;case"weeks":case"week":case"w":return r*Mi;case"days":case"day":case"d":return r*Je;case"hours":case"hour":case"hrs":case"hr":case"h":return r*lt;case"minutes":case"minute":case"mins":case"min":case"m":return r*ct;case"seconds":case"second":case"secs":case"sec":case"s":return r*at;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Wi(e){var t=Math.abs(e);return t>=Je?Math.round(e/Je)+"d":t>=lt?Math.round(e/lt)+"h":t>=ct?Math.round(e/ct)+"m":t>=at?Math.round(e/at)+"s":e+"ms"}function Xi(e){var t=Math.abs(e);return t>=Je?Wt(e,t,Je,"day"):t>=lt?Wt(e,t,lt,"hour"):t>=ct?Wt(e,t,ct,"minute"):t>=at?Wt(e,t,at,"second"):e+" ms"}function Wt(e,t,r,n){var o=t>=r*1.5;return Math.round(e/r)+" "+n+(o?"s":"")}});var Or=pe((Im,Dn)=>{function Ji(e){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=o,r.enabled=a,r.humanize=qn(),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,J=Number(new Date),V=J-(f||J);G.diff=V,G.prev=f,G.curr=J,f=J,z[0]=r.coerce(z[0]),typeof z[0]!="string"&&z.unshift("%O");let Z=0;z[0]=z[0].replace(/%([a-zA-Z%])/g,(ue,Kt)=>{if(ue==="%%")return"%";Z++;let On=r.formatters[Kt];if(typeof On=="function"){let Fi=z[Z];ue=On.call(G,Fi),z.splice(Z,1),Z--}return ue}),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}Dn.exports=Ji});var Mn=pe((ne,Xt)=>{ne.formatArgs=Yi;ne.save=Qi;ne.load=ea;ne.useColors=Zi;ne.storage=ta();ne.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`."))}})();ne.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 Zi(){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 Yi(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Xt.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)}ne.log=console.debug||console.log||(()=>{});function Qi(e){try{e?ne.storage.setItem("debug",e):ne.storage.removeItem("debug")}catch{}}function ea(){let e;try{e=ne.storage.getItem("debug")||ne.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function ta(){try{return localStorage}catch{}}Xt.exports=Or()(ne);var{formatters:ra}=Xt.exports;ra.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Kn=pe((q,Zt)=>{var na=je("tty"),Jt=je("util");q.init=ua;q.log=aa;q.formatArgs=sa;q.save=ca;q.load=la;q.useColors=oa;q.destroy=Jt.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=je("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 oa(){return"colors"in q.inspectOpts?!!q.inspectOpts.colors:na.isatty(process.stderr.fd)}function sa(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=Fr}walk(t){return Mn(this,t)}}});var Wt,Xt,Or=L(()=>{pe();Wt=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"})}},Xt=class extends v{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function we(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var at=L(()=>{});function fe(e){return we(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var St=L(()=>{at()});function Et(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 Vn=L(()=>{});var Tt,It,Nr=L(()=>{pe();Tt=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"})}},It=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 je(e,{dir:t,size:r=32}={}){return typeof e=="string"?ra(e,{dir:t,size:r}):na(e,{dir:t,size:r})}function ra(e,{dir:t,size:r=32}={}){if(r===null)return e;let n=e.replace("0x","");if(n.length>r*2)throw new It({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function na(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new It({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 Gr=L(()=>{Nr()});function he(e,t={}){return typeof e=="number"||typeof e=="bigint"?S(e,t):typeof e=="string"?aa(e,t):typeof e=="boolean"?sa(e,t):oe(e,t)}function sa(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(Ue(r,{size:t.size}),je(r,{size:t.size})):r}function oe(e,t={}){let r="";for(let o=0;o<e.length;o++)r+=oa[e[o]];let n=`0x${r}`;return typeof t.size=="number"?(Ue(n,{size:t.size}),je(n,{dir:"right",size:t.size})):n}function S(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 Wt({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?je(a,{size:n}):a}function aa(e,t={}){let r=ia.encode(e);return oe(r,t)}var oa,ia,me=L(()=>{Or();Gr();Je();oa=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));ia=new TextEncoder});function Jt(e,t={}){return typeof e=="number"||typeof e=="bigint"?ua(e,t):typeof e=="boolean"?la(e,t):we(e)?ge(e,t):Dr(e,t)}function la(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(Ue(r,{size:t.size}),je(r,{size:t.size})):r}function Kn(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 ge(e,t={}){let r=e;t.size&&(Ue(r,{size:t.size}),r=je(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=Kn(n.charCodeAt(a++)),u=Kn(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 ua(e,t){let r=S(e,t);return ge(r)}function Dr(e,t={}){let r=ca.encode(e);return typeof t.size=="number"?(Ue(r,{size:t.size}),je(r,{dir:"right",size:t.size})):r}var ca,Le,Fe=L(()=>{pe();at();Gr();Je();me();ca=new TextEncoder;Le={zero:48,nine:57,A:65,F:70,a:97,f:102}});function Ue(e,{size:t}){if(fe(e)>t)throw new Xt({givenSize:fe(e),maxSize:t})}function Ze(e,t={}){let{signed:r}=t;t.size&&Ue(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 Ye(e,t={}){return Number(Ze(e,t))}var Je=L(()=>{Or();St()});function ct(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 Zt=L(()=>{});var Km,Wm,Xm,Jm,Zm,Ym,Qm,ed,td,rd,nd,od,sd,id,ad,cd,ld,ud,pd,fd,md,dd,hd,gd,xd,bd,yd,vd,wd,_d,Cd,kd,Sd,Ed,Td,Id,Ad,Pd,Ld,$d,Bd,zd,Rd,jd,Ud,Fd,Hd,Od,Nd,Gd,Dd,qd,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,xh,bh,yh,vh,wh,_h,Ch,kh,Sh,Eh,Th,Ih,Ah,Ph,Lh,$h,Bh,Yt,Yn=L(()=>{Km=2n**(8n-1n)-1n,Wm=2n**(16n-1n)-1n,Xm=2n**(24n-1n)-1n,Jm=2n**(32n-1n)-1n,Zm=2n**(40n-1n)-1n,Ym=2n**(48n-1n)-1n,Qm=2n**(56n-1n)-1n,ed=2n**(64n-1n)-1n,td=2n**(72n-1n)-1n,rd=2n**(80n-1n)-1n,nd=2n**(88n-1n)-1n,od=2n**(96n-1n)-1n,sd=2n**(104n-1n)-1n,id=2n**(112n-1n)-1n,ad=2n**(120n-1n)-1n,cd=2n**(128n-1n)-1n,ld=2n**(136n-1n)-1n,ud=2n**(144n-1n)-1n,pd=2n**(152n-1n)-1n,fd=2n**(160n-1n)-1n,md=2n**(168n-1n)-1n,dd=2n**(176n-1n)-1n,hd=2n**(184n-1n)-1n,gd=2n**(192n-1n)-1n,xd=2n**(200n-1n)-1n,bd=2n**(208n-1n)-1n,yd=2n**(216n-1n)-1n,vd=2n**(224n-1n)-1n,wd=2n**(232n-1n)-1n,_d=2n**(240n-1n)-1n,Cd=2n**(248n-1n)-1n,kd=2n**(256n-1n)-1n,Sd=-(2n**(8n-1n)),Ed=-(2n**(16n-1n)),Td=-(2n**(24n-1n)),Id=-(2n**(32n-1n)),Ad=-(2n**(40n-1n)),Pd=-(2n**(48n-1n)),Ld=-(2n**(56n-1n)),$d=-(2n**(64n-1n)),Bd=-(2n**(72n-1n)),zd=-(2n**(80n-1n)),Rd=-(2n**(88n-1n)),jd=-(2n**(96n-1n)),Ud=-(2n**(104n-1n)),Fd=-(2n**(112n-1n)),Hd=-(2n**(120n-1n)),Od=-(2n**(128n-1n)),Nd=-(2n**(136n-1n)),Gd=-(2n**(144n-1n)),Dd=-(2n**(152n-1n)),qd=-(2n**(160n-1n)),Md=-(2n**(168n-1n)),Vd=-(2n**(176n-1n)),Kd=-(2n**(184n-1n)),Wd=-(2n**(192n-1n)),Xd=-(2n**(200n-1n)),Jd=-(2n**(208n-1n)),Zd=-(2n**(216n-1n)),Yd=-(2n**(224n-1n)),Qd=-(2n**(232n-1n)),eh=-(2n**(240n-1n)),th=-(2n**(248n-1n)),rh=-(2n**(256n-1n)),nh=2n**8n-1n,oh=2n**16n-1n,sh=2n**24n-1n,ih=2n**32n-1n,ah=2n**40n-1n,ch=2n**48n-1n,lh=2n**56n-1n,uh=2n**64n-1n,ph=2n**72n-1n,fh=2n**80n-1n,mh=2n**88n-1n,dh=2n**96n-1n,hh=2n**104n-1n,gh=2n**112n-1n,xh=2n**120n-1n,bh=2n**128n-1n,yh=2n**136n-1n,vh=2n**144n-1n,wh=2n**152n-1n,_h=2n**160n-1n,Ch=2n**168n-1n,kh=2n**176n-1n,Sh=2n**184n-1n,Eh=2n**192n-1n,Th=2n**200n-1n,Ih=2n**208n-1n,Ah=2n**216n-1n,Ph=2n**224n-1n,Lh=2n**232n-1n,$h=2n**240n-1n,Bh=2n**248n-1n,Yt=2n**256n-1n});function Qe(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var Mr=L(()=>{});var Pt,Qt,er,Qn=L(()=>{pe();Pt=class extends v{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},Qt=class extends v{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},er=class extends v{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function tr(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(ha);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var ha,Vr=L(()=>{Qn();ha={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 er({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Qt({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Pt({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 Pt({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 ro,no=L(()=>{ro={ether:-9,wei:9}});function oo(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 so=L(()=>{});function Lt(e,t="wei"){return oo(e,ro[t])}var io=L(()=>{no();so()});function ba(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(Bt,"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 mt,nn=L(()=>{mt=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 ja(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=Io(u,p,1)^r[a],h=Ao(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=Lo[i],l=Io(o,s,a),u=Ao(o,s,a),p=Po[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]^=za[n],e[1]^=Ra[n]}He(r)}var Aa,zt,Pa,La,$a,Ba,Po,Lo,$o,Bo,za,Ra,Io,Ao,on,Ua,zo,Ro=L(()=>{bo();pr();Aa=BigInt(0),zt=BigInt(1),Pa=BigInt(2),La=BigInt(7),$a=BigInt(256),Ba=BigInt(113),Po=[],Lo=[],$o=[];for(let e=0,t=zt,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Po.push(2*(5*n+r)),Lo.push((e+1)*(e+2)/2%64);let o=Aa;for(let s=0;s<7;s++)t=(t<<zt^(t>>La)*Ba)%$a,t&Pa&&(o^=zt<<(zt<<BigInt(s))-zt);$o.push(o)}Bo=fo($o,!0),za=Bo[0],Ra=Bo[1],Io=(e,t,r)=>r>32?go(e,t,r):mo(e,t,r),Ao=(e,t,r)=>r>32?xo(e,t,r):ho(e,t,r);on=class e extends ut{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,Kr(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=co(this.state)}clone(){return this._cloneInto()}keccak(){Wr(this.state32),ja(this.state32,this.rounds),Wr(this.state32),this.posOut=0,this.pos=0}update(t){pt(this),t=$t(t),et(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){pt(this,!1),et(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 Kr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(cr(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,He(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}},Ua=(e,t,r)=>ur(()=>new on(t,e,r)),zo=Ua(1,136,256/8)});function jo(e,t){let r=t||"hex",n=zo(we(e,{strict:!1})?Jt(e):e);return r==="bytes"?n:he(n)}var Uo=L(()=>{Ro();at();Fe();me()});function Fo(e,t){if(sn.has(`${e}.${t}`))return sn.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),n=jo(Dr(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 sn.set(`${e}.${t}`,s),s}var sn,Ho=L(()=>{Fe();Uo();nn();sn=new mt(8192)});function _e(e,t){let{strict:r=!0}=t??{},n=`${e}.${r}`;if(an.has(n))return an.get(n);let o=Fa.test(e)?e.toLowerCase()===e?!0:r?Fo(e)===e:!0:!1;return an.set(n,o),o}var Fa,an,vr=L(()=>{nn();Ho();Fa=/^0x[a-fA-F0-9]{40}$/,an=new mt(8192)});function Oo(e,t,r,{strict:n}={}){return we(e,{strict:!1})?Oa(e,t,r,{strict:n}):Ha(e,t,r,{strict:n})}function No(e,t){if(typeof t=="number"&&t>0&&t>fe(e)-1)throw new Tt({offset:t,position:"start",size:fe(e)})}function Go(e,t,r){if(typeof t=="number"&&typeof r=="number"&&fe(e)!==r-t)throw new Tt({offset:r,position:"end",size:fe(e)})}function Ha(e,t,r,{strict:n}={}){No(e,t);let o=e.slice(t,r);return n&&Go(o,t,r),o}function Oa(e,t,r,{strict:n}={}){No(e,t);let o=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return n&&Go(o,t,r),o}var Do=L(()=>{Nr();at();St()});var pn=ue(Ft=>{"use strict";var Za=Ft&&Ft.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ft,"__esModule",{value:!0});Ft.encryptEnvVars=ec;var ln=Re("@noble/curves/ed25519"),un=Za(Re("crypto"));function Ya(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 Qa(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function ec(e,t){let r=JSON.stringify({env:e}),n=ln.x25519.utils.randomPrivateKey(),o=ln.x25519.getPublicKey(n),s=Ya(t),i=ln.x25519.getSharedSecret(n,s),a=await un.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=un.default.getRandomValues(new Uint8Array(12)),u=await un.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),Qa(p)}});var Qo=ue(Ht=>{"use strict";var tc=Ht&&Ht.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ht,"__esModule",{value:!0});Ht.getComposeHash=sc;var rc=tc(Re("crypto"));function fn(e){return e==null?e:Array.isArray(e)?e.map(fn):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let n=e[r];return t[r]=fn(n),t},{}):e}function nc(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 oc(e){let t=fn(e);return JSON.stringify(t,(r,n)=>typeof n=="number"&&(isNaN(n)||!isFinite(n))?null:n)}function sc(e,t=!1){t&&(e=nc(e));let r=oc(e);return rc.default.createHash("sha256").update(r,"utf8").digest("hex")}});var ws=ue(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=ds;w.fromBig=dn;w.split=es;var kr=BigInt(2**32-1),mn=BigInt(32);function dn(e,t=!1){return t?{h:Number(e&kr),l:Number(e>>mn&kr)}:{h:Number(e>>mn&kr)|0,l:Number(e&kr)|0}}function es(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}=dn(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var ts=(e,t)=>BigInt(e>>>0)<<mn|BigInt(t>>>0);w.toBig=ts;var rs=(e,t,r)=>e>>>r;w.shrSH=rs;var ns=(e,t,r)=>e<<32-r|t>>>r;w.shrSL=ns;var os=(e,t,r)=>e>>>r|t<<32-r;w.rotrSH=os;var ss=(e,t,r)=>e<<32-r|t>>>r;w.rotrSL=ss;var is=(e,t,r)=>e<<64-r|t>>>r-32;w.rotrBH=is;var as=(e,t,r)=>e>>>r-32|t<<64-r;w.rotrBL=as;var cs=(e,t)=>t;w.rotr32H=cs;var ls=(e,t)=>e;w.rotr32L=ls;var us=(e,t,r)=>e<<r|t>>>32-r;w.rotlSH=us;var ps=(e,t,r)=>t<<r|e>>>32-r;w.rotlSL=ps;var fs=(e,t,r)=>t<<r-32|e>>>64-r;w.rotlBH=fs;var ms=(e,t,r)=>e<<r-32|t>>>64-r;w.rotlBL=ms;function ds(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var hs=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);w.add3L=hs;var gs=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;w.add3H=gs;var xs=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);w.add4L=xs;var bs=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0;w.add4H=bs;var ys=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0);w.add5L=ys;var vs=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;w.add5H=vs;var ic={fromBig:dn,split:es,toBig:ts,shrSH:rs,shrSL:ns,rotrSH:os,rotrSL:ss,rotrBH:is,rotrBL:as,rotr32H:cs,rotr32L:ls,rotlSH:us,rotlSL:ps,rotlBH:fs,rotlBL:ms,add:ds,add3L:hs,add3H:gs,add4L:xs,add4H:bs,add5H:vs,add5L:ys};w.default=ic});var _s=ue(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.crypto=void 0;var Ne=Re("crypto");Sr.crypto=Ne&&typeof Ne=="object"&&"webcrypto"in Ne?Ne.webcrypto:Ne&&typeof Ne=="object"&&"randomBytes"in Ne?Ne:void 0});var Ps=ue(b=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0});b.wrapXOFConstructorWithOpts=b.wrapConstructorWithOpts=b.wrapConstructor=b.Hash=b.nextTick=b.swap32IfBE=b.byteSwapIfBE=b.swap8IfBE=b.isLE=void 0;b.isBytes=ks;b.anumber=hn;b.abytes=ht;b.ahash=ac;b.aexists=cc;b.aoutput=lc;b.u8=uc;b.u32=pc;b.clean=fc;b.createView=mc;b.rotr=dc;b.rotl=hc;b.byteSwap=xn;b.byteSwap32=Ss;b.bytesToHex=xc;b.hexToBytes=bc;b.asyncLoop=vc;b.utf8ToBytes=bn;b.bytesToUtf8=wc;b.toBytes=Er;b.kdfInputToBytes=_c;b.concatBytes=Cc;b.checkOpts=kc;b.createHasher=Ts;b.createOptHasher=Is;b.createXOFer=As;b.randomBytes=Sc;var dt=_s();function ks(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function hn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ht(e,...t){if(!ks(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 ac(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");hn(e.outputLen),hn(e.blockLen)}function cc(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 lc(e,t){ht(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function uc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function pc(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function fc(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function mc(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function dc(e,t){return e<<32-t|e>>>t}function hc(e,t){return e<<t|e>>>32-t>>>0}b.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function xn(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}b.swap8IfBE=b.isLE?e=>e:e=>xn(e);b.byteSwapIfBE=b.swap8IfBE;function Ss(e){for(let t=0;t<e.length;t++)e[t]=xn(e[t]);return e}b.swap32IfBE=b.isLE?e=>e:Ss;var Es=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",gc=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function xc(e){if(ht(e),Es)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=gc[e[r]];return t}var ze={_0:48,_9:57,A:65,F:70,a:97,f:102};function Cs(e){if(e>=ze._0&&e<=ze._9)return e-ze._0;if(e>=ze.A&&e<=ze.F)return e-(ze.A-10);if(e>=ze.a&&e<=ze.f)return e-(ze.a-10)}function bc(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Es)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=Cs(e.charCodeAt(s)),a=Cs(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 yc=async()=>{};b.nextTick=yc;async function vc(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,b.nextTick)(),n+=s)}}function bn(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function wc(e){return new TextDecoder().decode(e)}function Er(e){return typeof e=="string"&&(e=bn(e)),ht(e),e}function _c(e){return typeof e=="string"&&(e=bn(e)),ht(e),e}function Cc(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ht(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 kc(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 gn=class{};b.Hash=gn;function Ts(e){let t=n=>e().update(Er(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Is(e){let t=(n,o)=>e(o).update(Er(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function As(e){let t=(n,o)=>e(o).update(Er(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}b.wrapConstructor=Ts;b.wrapConstructorWithOpts=Is;b.wrapXOFConstructorWithOpts=As;function Sc(e=32){if(dt.crypto&&typeof dt.crypto.getRandomValues=="function")return dt.crypto.getRandomValues(new Uint8Array(e));if(dt.crypto&&typeof dt.crypto.randomBytes=="function")return Uint8Array.from(dt.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var Hs=ue(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=Us;var Nt=ws(),K=Ps(),Ec=BigInt(0),Ot=BigInt(1),Tc=BigInt(2),Ic=BigInt(7),Ac=BigInt(256),Pc=BigInt(113),Bs=[],zs=[],Rs=[];for(let e=0,t=Ot,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Bs.push(2*(5*n+r)),zs.push((e+1)*(e+2)/2%64);let o=Ec;for(let s=0;s<7;s++)t=(t<<Ot^(t>>Ic)*Pc)%Ac,t&Tc&&(o^=Ot<<(Ot<<BigInt(s))-Ot);Rs.push(o)}var js=(0,Nt.split)(Rs,!0),Lc=js[0],$c=js[1],Ls=(e,t,r)=>r>32?(0,Nt.rotlBH)(e,t,r):(0,Nt.rotlSH)(e,t,r),$s=(e,t,r)=>r>32?(0,Nt.rotlBL)(e,t,r):(0,Nt.rotlSL)(e,t,r);function Us(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=Ls(u,p,1)^r[a],h=$s(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=zs[i],l=Ls(o,s,a),u=$s(o,s,a),p=Bs[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]^=Lc[n],e[1]^=$c[n]}(0,K.clean)(r)}var Gt=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),Us(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=Gt;var Ge=(e,t,r)=>(0,K.createHasher)(()=>new Gt(t,e,r));R.sha3_224=Ge(6,144,224/8);R.sha3_256=Ge(6,136,256/8);R.sha3_384=Ge(6,104,384/8);R.sha3_512=Ge(6,72,512/8);R.keccak_224=Ge(1,144,224/8);R.keccak_256=Ge(1,136,256/8);R.keccak_384=Ge(1,104,384/8);R.keccak_512=Ge(1,72,512/8);var Fs=(e,t,r)=>(0,K.createXOFer)((n={})=>new Gt(t,e,n.dkLen===void 0?r:n.dkLen,!0));R.shake128=Fs(31,168,128/8);R.shake256=Fs(31,136,256/8)});var Os=ue(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.verifyEnvEncryptPublicKey=Rc;var Bc=Hs(),zc=Re("@noble/curves/secp256k1");function Rc(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,Bc.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=zc.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 Ws=kt(Gn(),1);import{ofetch as jc}from"ofetch";function Dn(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 q}from"zod";import{z as j}from"zod";import{z as De}from"zod";import{z as k}from"zod";import{z as qe}from"zod";function Xe(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}Zt();Je();Zt();var qr={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function At(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Ye(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?Ye(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?qr[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=pa(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 Wn=ct("transaction",At);function pa(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 fa(e,t){let r=(e.transactions??[]).map(n=>typeof n=="string"?n:At(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 Xn=ct("block",fa);function Jn(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}:{}}}Je();Zt();var ma={"0x0":"reverted","0x1":"success"};function da(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=>Jn(n)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Ye(e.transactionIndex):null,status:e.status?ma[e.status]:null,type:e.type?qr[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var Zn=ct("transactionReceipt",da);pe();Vr();Fe();me();function $e(e,t="hex"){let r=eo(e),n=tr(new Uint8Array(r.length));return r.encode(n),t==="hex"?oe(n.bytes):n.bytes}function eo(e){return Array.isArray(e)?ga(e.map(t=>eo(t))):xa(e)}function ga(e){let t=e.reduce((o,s)=>o+s.length,0),r=to(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 xa(e){let t=typeof e=="string"?ge(e):e,r=to(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 to(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.")}sr();me();function ao(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?he(n):"0x",i,o?he(o):"0x",...lt({},s)])}return t}Fe();me();function ir(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=>ge(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))}Fe();me();function ar(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=>ge(i)):e.blobs,o=typeof e.commitments[0]=="string"?e.commitments.map(i=>ge(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))}me();pr();function ka(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 lo(e,t,r){return e&t^~e&r}function uo(e,t,r){return e&t^e&r^t&r}var fr=class extends ut{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=lr(this.buffer)}update(t){pt(this),t=$t(t),et(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=lr(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){pt(this),cr(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,He(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let f=i;f<o;f++)r[f]=0;ka(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=lr(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]);pr();var Ea=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]),Oe=new Uint32Array(64),dr=class extends fr{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)Oe[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let h=Oe[f-15],g=Oe[f-2],_=xe(h,7)^xe(h,18)^h>>>3,P=xe(g,17)^xe(g,19)^g>>>10;Oe[f]=P+Oe[f-7]+_+Oe[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+lo(a,l,u)+Ea[f]+Oe[f]|0,P=(xe(n,2)^xe(n,13)^xe(n,22))+uo(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(){He(Oe)}destroy(){this.set(0,0,0,0,0,0,0,0),He(this.buffer)}};var yo=ur(()=>new dr);var vo=yo;at();Fe();me();function wo(e,t){let r=t||"hex",n=vo(we(e,{strict:!1})?Jt(e):e);return r==="bytes"?n:he(n)}function _o(e){let{commitment:t,version:r=1}=e,n=e.to??(typeof t=="string"?"hex":"bytes"),o=wo(t,"bytes");return o.set([r],0),n==="bytes"?o:oe(o)}function Co(e){let{commitments:t,version:r}=e,n=e.to??(typeof t[0]=="string"?"hex":"bytes"),o=[];for(let s of t)o.push(_o({commitment:s,to:n,version:r}));return o}pe();var hr=class extends v{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},ft=class extends v{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},gr=class extends v{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},xr=class extends v{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};Vr();St();Fe();me();function ko(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?ge(e.data):e.data,n=fe(r);if(!n)throw new ft;if(n>761855)throw new hr({maxSize:761855,size:n});let o=[],s=!0,i=0;for(;s;){let a=tr(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 So(e){let{data:t,kzg:r,to:n}=e,o=e.blobs??ko({data:t,to:n}),s=e.commitments??ir({blobs:o,kzg:r,to:n}),i=e.proofs??ar({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}Mr();Vn();me();Yn();br();pe();Eo();To();vr();St();Do();Je();function qo(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:n}=r,o=r.address;if(!_e(o))throw new de({address:o});if(n<0)throw new tt({chainId:n})}wr(e)}function Mo(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new ft;for(let r of t){let n=fe(r),o=Ye(Oo(r,0,1));if(n!==32)throw new gr({hash:r,size:n});if(o!==1)throw new xr({hash:r,version:o})}}wr(e)}function wr(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:n,to:o}=e;if(t<=0)throw new tt({chainId:t});if(o&&!_e(o))throw new de({address:o});if(n&&n>Yt)throw new rt({maxFeePerGas:n});if(r&&n&&r>n)throw new Bt({maxFeePerGas:n,maxPriorityFeePerGas:r})}function Vo(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:o,to:s}=e;if(t<=0)throw new tt({chainId:t});if(s&&!_e(s))throw new de({address:s});if(r||o)throw new v("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(n&&n>Yt)throw new rt({maxFeePerGas:n})}function Ko(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:o,to:s}=e;if(s&&!_e(s))throw new de({address:s});if(typeof t<"u"&&t<=0)throw new tt({chainId:t});if(r||o)throw new v("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(n&&n>Yt)throw new rt({maxFeePerGas:n})}sr();function Wo(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 nr({transaction:e})}br();sr();vr();function Rt(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 or({storageKey:o[s]});if(!_e(n,{strict:!1}))throw new de({address:n});t.push([n,o])}return t}function Xo(e,t){let r=Wo(e);return r==="eip1559"?Da(e,t):r==="eip2930"?qa(e,t):r==="eip4844"?Ga(e,t):r==="eip7702"?Na(e,t):Ma(e,t)}function Na(e,t){let{authorizationList:r,chainId:n,gas:o,nonce:s,to:i,value:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:p,data:f}=e;qo(e);let h=Rt(p),g=ao(r);return Qe(["0x04",$e([S(n),s?S(s):"0x",u?S(u):"0x",l?S(l):"0x",o?S(o):"0x",i??"0x",a?S(a):"0x",f??"0x",h,g,...lt(e,t)])])}function Ga(e,t){let{chainId:r,gas:n,nonce:o,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:p,data:f}=e;Mo(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(le=>oe(le)),Z=e.kzg,re=ir({blobs:V,kzg:Z});if(typeof h>"u"&&(h=Co({commitments:re})),typeof g>"u"){let le=ar({blobs:V,commitments:re,kzg:Z});g=So({blobs:V,commitments:re,proofs:le})}}let _=Rt(p),P=[S(r),o?S(o):"0x",u?S(u):"0x",l?S(l):"0x",n?S(n):"0x",s??"0x",i?S(i):"0x",f??"0x",_,a?S(a):"0x",h??[],...lt(e,t)],B=[],G=[],J=[];if(g)for(let V=0;V<g.length;V++){let{blob:Z,commitment:re,proof:le}=g[V];B.push(Z),G.push(re),J.push(le)}return Qe(["0x03",g?$e([P,B,G,J]):$e(P)])}function Da(e,t){let{chainId:r,gas:n,nonce:o,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:u,data:p}=e;wr(e);let f=Rt(u),h=[S(r),o?S(o):"0x",l?S(l):"0x",a?S(a):"0x",n?S(n):"0x",s??"0x",i?S(i):"0x",p??"0x",f,...lt(e,t)];return Qe(["0x02",$e(h)])}function qa(e,t){let{chainId:r,gas:n,data:o,nonce:s,to:i,value:a,accessList:l,gasPrice:u}=e;Vo(e);let p=Rt(l),f=[S(r),s?S(s):"0x",u?S(u):"0x",n?S(n):"0x",i??"0x",a?S(a):"0x",o??"0x",p,...lt(e,t)];return Qe(["0x01",$e(f)])}function Ma(e,t){let{chainId:r=0,gas:n,data:o,nonce:s,to:i,value:a,gasPrice:l}=e;Ko(e);let u=[s?S(s):"0x",l?S(l):"0x",n?S(n):"0x",i??"0x",a?S(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 rr({v:t.v});return g})(),f=Et(t.r),h=Et(t.s);u=[...u,S(p),f==="0x00"?"0x":f,h==="0x00"?"0x":h]}else r>0&&(u=[...u,S(r),"0x","0x"]);return $e(u)}function lt(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=Et(r.r),i=Et(r.s);return[typeof o=="number"?o?S(1):"0x":n===0n?"0x":n===1n?S(1):n===27n?"0x":S(1),s==="0x00"?"0x":s,i==="0x00"?"0x":i]}var Jo={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};Je();var Zo={block:Xn({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let n=At(r);return n.typeHex==="0x7e"&&(n.isSystemTx=r.isSystemTx,n.mint=r.mint?Ze(r.mint):void 0,n.sourceHash=r.sourceHash,n.type="deposit"),n}),stateRoot:e.stateRoot}}}),transaction:Wn({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Ze(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Zn({format(e){return{l1GasPrice:e.l1GasPrice?Ze(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Ze(e.l1GasUsed):null,l1Fee:e.l1Fee?Ze(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};br();vr();Mr();me();function Va(e,t){return Wa(e)?Ka(e):Xo(e,t)}var Yo={transaction:Va};function Ka(e){Xa(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?he(i):"0x",l?he(l):"0x",o?he(o):"0x",s?"0x1":"0x",r??"0x"];return Qe(["0x7e",$e(u)])}function Wa(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function Xa(e){let{from:t,to:r}=e;if(t&&!_e(t))throw new de({address:t});if(r&&!_e(r))throw new de({address:r})}var cn={blockTime:2e3,contracts:Jo,formatters:Zo,serializers:Yo};var _r=Xe({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 jt=1,Ut=Xe({...cn,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:{...cn.contracts,disputeGameFactory:{[jt]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[jt]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[jt]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[jt]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:jt}),Ja=Xe({...Ut,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var Cr=Xe({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 se}from"zod";import{z as m}from"zod";import{z as d}from"zod";import{z as xt}from"zod";import{z as bt}from"zod";import{z as C}from"zod";import{z as W}from"zod";import{z as E}from"zod";import tu from"crypto";import{z as Se}from"zod";import{z as be}from"zod";import{z as M}from"zod";import{z as ie}from"zod";import{z as ae}from"zod";import{z as Bu}from"zod";import{z as Ds}from"zod";import{z as Ee}from"zod";import{z as Ct}from"zod";import{z as nt}from"zod";import{z}from"zod";import{z as ap}from"zod";import{z as pp}from"zod";import{z as $}from"zod";import{z as ke}from"zod";import{z as Ep}from"zod";import{z as H}from"zod";import{z as y}from"zod";import{z as wt}from"zod";import{z as _n}from"zod";import{z as X}from"zod";import{z as mi}from"zod";import{z as Ce}from"zod";import{z as x}from"zod";import{z as A}from"zod";import{z as I}from"zod";import{z as N}from"zod";var Ib=kt(pn(),1);import{z as F}from"zod";var Ef=kt(pn(),1),Tf=kt(Qo(),1),If=kt(Os(),1);import{z as yt}from"zod";import{z as ye}from"zod";import{z as vt}from"zod";import{z as Q}from"zod";import{z as ce}from"zod";import{z as Vs}from"zod";import{z as Ks}from"zod";import{z as Tr}from"zod";import{z as Ir}from"zod";import{z as Y}from"zod";var Uc=q.object({detail:q.union([q.string(),q.array(q.object({msg:q.string(),type:q.string().optional(),ctx:q.record(q.unknown()).optional(),loc:q.array(q.union([q.string(),q.number()])).optional(),input:q.unknown().optional()}).passthrough()),q.record(q.unknown())]).optional(),type:q.string().optional(),code:q.string().optional()}),Te=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)}},vn=class Ar extends Te{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=Uc.safeParse(t.data);return r.success?new Ar(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 Ar(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 Ar(t.message,{request:r??void 0,detail:t.message})}},Fc=class extends Te{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},Hc=class extends Te{constructor(){super(...arguments),this.isAuthError=!0}},Xs=class extends Te{constructor(){super(...arguments),this.isBusinessError=!0}},Oc=class extends Te{constructor(){super(...arguments),this.isServerError=!0}},Nc=class extends Te{constructor(){super(...arguments),this.isUnknownError=!0}};function Gc(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 Js(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((o,s)=>{let i=Gc(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 Dc(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}=Js(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 Mc(e){let t=e.status??0,r=e.statusText??"Unknown Error",n=e.detail,o=Kc(n);if(o)return new Vc(o.message,{status:t,statusText:r,detail:n,errorCode:o.error_code,structuredDetails:o.details,suggestions:o.suggestions,links:o.links});let s=Dc(t),i=qc(t,n,e.message),a={status:t,statusText:r,detail:n};if(s==="validation"&&Array.isArray(n)){let{errors:l}=Js(n);return new Fc(i,{...a,validationErrors:l})}return s==="auth"?new Hc(i,a):s==="business"?new Xs(i,a):s==="server"?new Oc(i,a):new Nc(i,a)}var Vc=class extends Xs{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 Kc(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 kn=["2025-10-28","2026-01-21"],Wc="2026-01-21",gt=(0,Ws.default)("phala::api-client");function Xc(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
|
|
12
|
-
`)}function
|
|
4
|
+
`+s),e.push(o+"m+"+Zt.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=ia()+t+" "+e[0]}function ia(){return q.inspectOpts.hideDate?"":new Date().toISOString()+" "}function aa(...e){return process.stderr.write(Jt.formatWithOptions(q.inspectOpts,...e)+`
|
|
5
|
+
`)}function ca(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function la(){return process.env.DEBUG}function ua(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]]}Zt.exports=Or()(q);var{formatters:Vn}=Zt.exports;Vn.o=function(e){return this.inspectOpts.colors=this.useColors,Jt.inspect(e,this.inspectOpts).split(`
|
|
6
|
+
`).map(t=>t.trim()).join(" ")};Vn.O=function(e){return this.inspectOpts.colors=this.useColors,Jt.inspect(e,this.inspectOpts)}});var Wn=pe((Am,Nr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Nr.exports=Mn():Nr.exports=Kn()});var Gr,Jn=$(()=>{Gr="2.38.6"});function Zn(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Zn(e.cause,t):t?null:e}var qr,v,fe=$(()=>{Jn();qr={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${Gr}`},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=qr.getDocsUrl?.({...r,docsPath:o}),i=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...qr.version?[`Version: ${qr.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=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 ir,ar,cr,lr=$(()=>{fe();ir=class extends v{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}},ar=class extends v{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Ta(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"})}},cr=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 Ia(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Zr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function rt(e,...t){if(!Ia(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 dt(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 fr(e,t){rt(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function ho(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Oe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function mr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function xe(e,t){return e<<32-t|e>>>t}function Pa(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function $a(e){for(let t=0;t<e.length;t++)e[t]=Pa(e[t]);return e}function La(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Rt(e){return typeof e=="string"&&(e=La(e)),rt(e),e}function dr(e){let t=n=>e().update(Rt(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}var Aa,Yr,mt,hr=$(()=>{Aa=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;Yr=Aa?e=>e:$a;mt=class{}});function Ba(e,t=!1){return t?{h:Number(e&br),l:Number(e>>xo&br)}:{h:Number(e>>xo&br)|0,l:Number(e&br)|0}}function yo(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}=Ba(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var br,xo,vo,wo,_o,Co,ko=$(()=>{br=BigInt(4294967295),xo=BigInt(32);vo=(e,t,r)=>e<<r|t>>>32-r,wo=(e,t,r)=>t<<r|e>>>32-r,_o=(e,t,r)=>t<<r-32|e>>>64-r,Co=(e,t,r)=>e<<r-32|t>>>64-r});var he,_r=$(()=>{fe();he=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 nt,Lo=$(()=>{fe();nt=class extends v{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}});var Cr,ot,Qr,en,tn,rn,nn,on,sn,an,jt,zo=$(()=>{fo();fe();Cr=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(Cr,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(Cr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});ot=class extends v{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${Bt(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}};Object.defineProperty(ot,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});Qr=class extends v{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${Bt(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}};Object.defineProperty(Qr,"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/});en=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(en,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});tn=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(tn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});rn=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(rn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});nn=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(nn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});on=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(on,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});sn=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(sn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});an=class extends v{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}};Object.defineProperty(an,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});jt=class extends v{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${Bt(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Bt(n)} gwei`:""}).`].join(`
|
|
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 sl(e){return e?` -d '${(typeof e=="string"?e:JSON.stringify(e,null,2)).replace(/'/g,"\\'")}'`:""}function Ks(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 il=class ni{constructor(t={}){this.emitter=Xn();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&&Pn.includes(t.version)?t.version:nl;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=Mc.create({baseURL:i,timeout:a||3e4,headers:h,...u?{credentials:"include"}:{},...f,onRequest({request:g,options:_}){if(yt.enabled){let P=_.method||"GET",z=typeof g=="string"?g:g.url,G=z.startsWith("http")?z:`${i}${z}`,J={};_.headers&&typeof _.headers=="object"&&Object.entries(_.headers).forEach(([Z,re])=>{typeof re=="string"&&(J[Z]=re)});let V=[`> curl -X ${P} "${G}"`,ol(J),_.body?sl(_.body):""].filter(Boolean).join(`
|
|
16
|
+
`);yt(`
|
|
17
17
|
=== REQUEST ===
|
|
18
18
|
%s
|
|
19
|
-
`,V)}},onResponse({request:g,response:_,options:P}){if(
|
|
19
|
+
`,V)}},onResponse({request:g,response:_,options:P}){if(yt.enabled){let z=P.method||"GET",G=typeof g=="string"?g:g.url;yt(`
|
|
20
20
|
=== RESPONSE [%s %s] (%dms) ===
|
|
21
21
|
%s
|
|
22
|
-
`,
|
|
22
|
+
`,z,G,_.headers.get("x-response-time")||"?",Ks(_.status,_.statusText,_.headers,_._data))}},onResponseError:({request:g,response:_,options:P})=>{if(yt.enabled){console.warn(`HTTP ${_.status}: ${_.url}`);let z=P.method||"GET",G=typeof g=="string"?g:g.url;yt(`
|
|
23
23
|
=== ERROR RESPONSE [%s %s] ===
|
|
24
24
|
%s
|
|
25
|
-
`,B,G,Ns(_.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?vn.fromFetchError(t):t instanceof Error?vn.fromError(t):new vn("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(t){let r=Mc(t);return this.emitter.emit("error",r),r}async safeRequest(t){try{return{success:!0,data:await t()}}catch(r){if(r instanceof Te)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 Zs({...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 Yc(e={}){return new Zc(e)}var Qc=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(),el=j.object({id:j.string(),name:j.string(),slug:j.string().nullable(),tier:j.string(),role:j.string(),avatar:j.string().nullable().optional()}).passthrough(),tl=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(),rl=j.object({user:Qc,workspace:el,credits:tl}).passthrough(),nl=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 ol(e){return e==="2025-10-28"?nl:rl}async function Ys(e,t){let r=await e.get("/auth/me");return t?.schema===!1?r:(t?.schema||ol(e.config.version)).parse(r)}async function sl(e,t){try{return{success:!0,data:await Ys(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 il={[Cr.id]:Cr,[Ut.id]:Ut,[_r.id]:_r},al=qe.object({id:qe.string(),slug:qe.string().nullable(),url:qe.string(),version:qe.string(),chain_id:qe.number().nullable(),kms_contract_address:qe.string().nullable().transform(e=>e),gateway_app_id:qe.string().nullable().transform(e=>e)}).passthrough(),Ie=al.transform(e=>{if(e.chain_id!=null){let t=il[e.chain_id];if(t)return{...e,chain:t}}return e});function Qs(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 ei(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 cl(e,t){function r(i,a){return n(i,a)}async function n(i,a){Qs(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=ei(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 T(e,t){function r(i,...a){let[l,u]=a;return n(i,l,u)}async function n(i,a,l){Qs(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=ei(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 ll=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(),ul=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(ll),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(),pl=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(),fl=k.object({tier:k.string(),capacity:pl,nodes:k.array(ul),kms_list:k.array(Ie)}).passthrough(),{action:ml,safeAction:dl}=cl(fl,async e=>await e.get("/teepods/available")),ti=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(),hl=O.object({name:O.string(),items:O.array(ti),total:O.number()}).strict(),gl=O.object({result:O.array(hl)}).strict(),xl=O.object({items:O.array(ti),total:O.number(),family:O.string()}).strict(),bl=O.object({family:O.string()}).strict(),{action:yl,safeAction:vl}=T(gl,async e=>await e.get("/instance-types")),{action:wl,safeAction:_l}=T(xl,async(e,t)=>{let r=bl.parse(t);return await e.get(`/instance-types/${r.family}`)}),ri=se.object({id:se.string(),name:se.string(),slug:se.string().nullable(),tier:se.string(),role:se.string(),is_default:se.boolean(),created_at:se.string()}).passthrough(),Cl=se.object({has_more:se.boolean(),next_cursor:se.string().nullable(),total:se.number().nullable()}).passthrough(),kl=se.object({data:se.array(ri),pagination:Cl}).passthrough(),{action:Sl,safeAction:El}=T(kl,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:Tl,safeAction:Il}=T(ri,async(e,t)=>await e.get(`/workspaces/${t}`)),Al=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()}),Pl=m.object({id:m.number(),username:m.string()}),ni=m.object({id:m.number(),name:m.string(),region_identifier:m.string().nullable().optional()}),Sn=m.object({vcpu:m.number(),memory:m.number(),disk_size:m.number(),gpu_count:m.number().default(0)}),En=m.object({app:m.string(),instance:m.string()}),Ll=m.object({hosted:Al,name:m.string(),managed_user:Pl.nullable(),node:ni.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:Ie.nullable(),vcpu:m.number().nullable(),memory:m.number().nullable(),disk_size:m.number().nullable(),gateway_domain:m.string().nullable(),public_urls:m.array(En),machine_info:Sn.nullable().optional(),updated_at:m.string().nullable().optional()}),oi=m.object({id:m.number(),name:m.string(),status:m.string(),in_progress:m.boolean().optional().default(!1),teepod_id:m.number().nullable(),teepod:ni.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:Ie.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(En).optional().default([]),gateway_domain:m.string().optional().nullable(),machine_info:Sn.optional().nullable(),updated_at:m.string().optional().nullable()}),$l=m.object({items:m.array(Ll),total:m.number(),page:m.number(),page_size:m.number(),pages:m.number()}),Bl=d.enum(["skip","hourly","monthly"]),zl=d.enum(["phala","ethereum","base","legacy"]),Tn=d.object({object_type:d.literal("user"),id:d.string().nullable().optional(),username:d.string().nullable().optional(),avatar_url:d.string().nullable().optional()}),In=d.object({object_type:d.literal("workspace"),id:d.string(),name:d.string(),slug:d.string().nullable().optional(),avatar_url:d.string().nullable().optional()}),Rl=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:Bl.nullable().optional()}),jl=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()}),Ul=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()}),Fl=d.object({target:d.string().nullable().optional(),started_at:d.string().nullable().optional(),correlation_id:d.string().nullable().optional()}),Hl=d.object({base_domain:d.string().nullable().optional(),cname:d.string().nullable().optional()}),si=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 Pr=d.object({id:d.string(),name:d.string(),app_id:d.string().nullable().optional(),vm_uuid:d.string().nullable().optional(),resource:Rl,node_info:si.nullable().optional(),os:jl.nullable().optional(),kms_type:zl.nullable().optional(),kms_info:Ul.nullable().optional(),status:d.string(),progress:Fl.nullable().optional(),compose_hash:d.string().nullable().optional(),gateway:Hl,services:d.array(d.record(d.any())).optional().default([]),endpoints:d.array(En).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:In.nullable().optional(),creator:Tn.nullable().optional()}),Ol=Pr.extend({compose_file:d.union([d.record(d.any()),d.string()]).nullable().optional()}),Nl=d.object({items:d.array(Pr),total:d.number(),page:d.number(),page_size:d.number(),pages:d.number()});function ii(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 Ae=xt.object({id:xt.string().optional(),uuid:xt.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:xt.string().optional(),instance_id:xt.string().optional(),name:xt.string().refine(ii,{message:"Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens"}).optional()}),Me=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"}),Gl=Me(Ae),U=Gl.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}}),Dl=U;function ql(e){return e==="2025-10-28"?oi:Ol}async function ai(e,t){let{cvmId:r}=Dl.parse(t),n=await e.get(`/cvms/${r}`);return ql(e.config.version).parse(n)}async function Lr(e,t){try{return{success:!0,data:await ai(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 Ml=bt.object({page:bt.number().int().min(1).optional(),page_size:bt.number().int().min(1).optional(),node_id:bt.number().int().min(1).optional(),teepod_id:bt.number().int().min(1).optional(),user_id:bt.string().optional()}).strict();function Vl(e){return e==="2025-10-28"?$l:Nl}async function ci(e,t){let r=Ml.parse(t??{}),n=await e.get("/cvms/paginated",{params:r});return Vl(e.config.version).parse(n)}async function An(e,t){try{return{success:!0,data:await ci(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 Gs=200*1024;function li(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>Gs){let a=Gs/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 ui=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)=>{li(e.docker_compose_file,e.pre_launch_script,t)}),Kl=C.object({app_id:C.string().nullable().optional(),app_env_encrypt_pubkey:C.string().nullable().optional(),compose_hash:C.string(),kms_info:Ie.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}),wn="Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens",Wl=C.object({node_id:C.number().optional(),teepod_id:C.number().optional(),region:C.string().optional(),name:C.string().min(5,wn).max(63,wn).refine(e=>ii(e),wn),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)=>{li(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 Xl(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:Jl,safeAction:Zl}=T(Kl,async(e,t)=>{let r=Wl.parse(t),n=Xl(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)}),Yl=E.object({id:E.number(),name:E.string(),status:E.string(),teepod_id:E.number(),teepod:E.object({id:E.number(),name:E.string()}).nullable(),user_id:E.number().nullable(),app_id:E.string().nullable(),vm_uuid:E.string().nullable(),instance_id:E.string().nullable(),app_url:E.string().nullable().default(null),base_image:E.string().nullable(),vcpu:E.number(),memory:E.number(),disk_size:E.number(),manifest_version:E.number().nullable().default(2),version:E.string().nullable().default("1.0.0"),runner:E.string().nullable().default("docker-compose"),docker_compose_file:E.string().nullable(),features:E.array(E.string()).nullable().default(["kms","tproxy-net"]),created_at:E.string(),encrypted_env_pubkey:E.string().nullable().optional(),app_auth_contract_address:E.string().nullable().optional(),deployer_address:E.string().nullable().optional()}).passthrough(),Xx=E.object({encrypted_env:E.string().optional().nullable(),app_id:E.string(),compose_hash:E.string(),kms_id:E.string().optional(),contract_address:E.string().optional(),deployer_address:E.string().optional(),env_keys:E.array(E.string()).optional().nullable()}).passthrough(),{action:Ql,safeAction:eu}=T(Yl,async(e,t)=>await e.post("/cvms",t));function Cn(e){return e==null?e:Array.isArray(e)?e.map(Cn):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let n=e[r];return t[r]=Cn(n),t},{}):e}function pi(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 fi(e){let t=Cn(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function ru(e){let t=pi(e),r=fi(t);return tu.createHash("sha256").update(r,"utf8").digest("hex")}function nu(e){let t=e;return{...e,getHash:()=>ru(t),toString:()=>fi(pi(t))}}var ou=ui.transform(e=>nu(e)),su=U,{action:iu,safeAction:Pn}=T(ou,async(e,t)=>{let{cvmId:r}=su.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),au=Se.object({id:Se.string().optional(),uuid:Se.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:Se.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:Se.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:ui,update_env_vars:Se.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})),cu=Se.object({app_id:Se.string().nullable(),device_id:Se.string().nullable(),compose_hash:Se.string(),kms_info:Ie.nullable().optional()}).passthrough(),{action:lu,safeAction:uu}=T(cu,async(e,t)=>{let r=au.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),pu=be.object({id:be.string().optional(),uuid:be.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),app_id:be.string().refine(e=>!e.startsWith("app_")&&e.length===40,"app_id should be 40 characters without prefix").transform(e=>e.startsWith("app_")?e:`app_${e}`).optional(),instance_id:be.string().refine(e=>!e.startsWith("instance_")&&e.length===40,"instance_id should be 40 characters without prefix").transform(e=>e.startsWith("instance_")?e:`instance_${e}`).optional(),compose_hash:be.string().min(1,"Compose hash is required"),encrypted_env:be.string().optional(),env_keys:be.array(be.string()).optional(),update_env_vars:be.boolean().optional().nullable()}).refine(e=>!!(e.id||e.uuid||e.app_id||e.instance_id),"One of id, uuid, app_id, or instance_id must be provided").transform(e=>({cvmId:e.id||e.uuid||e.app_id||e.instance_id,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})),fu=be.any().transform(()=>{}),{action:mu,safeAction:du}=T(fu,async(e,t)=>{let r=pu.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})}),hu=Me(Ae.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}}),gu=M.object({status:M.literal("in_progress"),message:M.string(),correlation_id:M.string(),allowed_envs_changed:M.boolean()}),xu=M.object({status:M.literal("precondition_required"),message:M.string(),compose_hash:M.string(),app_id:M.string(),device_id:M.string(),kms_info:Ie}),bu=M.union([gu,xu]),{action:yu,safeAction:vu}=T(bu,async(e,t)=>{let r=hu.parse(t);try{return await e.patch(`/cvms/${r.cvmId}/envs`,r.request)}catch(n){if(n instanceof Te&&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}}),wu=Me(Ae.extend({docker_compose_file:ie.string().describe("Docker Compose YAML content"),compose_hash:ie.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:ie.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}}),_u=ie.object({status:ie.literal("in_progress"),message:ie.string(),correlation_id:ie.string()}),Cu=ie.object({status:ie.literal("precondition_required"),message:ie.string(),compose_hash:ie.string(),app_id:ie.string(),device_id:ie.string(),kms_info:Ie}),ku=ie.union([_u,Cu]),{action:Su,safeAction:Eu}=T(ku,async(e,t)=>{let r=wu.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 Te&&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}}),Tu=Me(Ae.extend({pre_launch_script:ae.string().describe("Pre-launch script content (shell script)"),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:{pre_launch_script:e.pre_launch_script,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Iu=ae.object({status:ae.literal("in_progress"),message:ae.string(),correlation_id:ae.string()}),Au=ae.object({status:ae.literal("precondition_required"),message:ae.string(),compose_hash:ae.string(),app_id:ae.string(),device_id:ae.string(),kms_info:Ie}),Pu=ae.union([Iu,Au]),{action:Lu,safeAction:$u}=T(Pu,async(e,t)=>{let r=Tu.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 Te&&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}}),zu=U,{action:Ru,safeAction:ju}=T(Bu.string(),async(e,t)=>{let{cvmId:r}=zu.parse(t);return await e.get(`/cvms/${r}/pre-launch-script`)}),Uu=Ds.object({kms_id:Ds.string().min(1,"KMS ID is required")}),{action:Fu,safeAction:Hu}=T(Ie,async(e,t)=>{let r=Uu.parse(t);return await e.get(`/kms/${r.kms_id}`)}),Ou=Ee.object({page:Ee.number().int().min(1).optional(),page_size:Ee.number().int().min(1).optional(),is_onchain:Ee.boolean().optional()}).strict(),Nu=Ee.object({items:Ee.array(Ie),total:Ee.number(),page:Ee.number(),page_size:Ee.number(),pages:Ee.number()}).strict(),{action:Gu,safeAction:Du}=T(Nu,async(e,t)=>{let r=Ou.parse(t??{});return await e.get("/kms",{params:r})}),qu=Ct.object({kms:Ct.string().min(1,"KMS ID or slug is required"),app_id:Ct.string().refine(e=>e.length===40||e.startsWith("0x")&&e.length===42,"App ID must be exactly 40 characters or 42 characters with 0x prefix")}).strict(),Mu=Ct.object({public_key:Ct.string(),signature:Ct.string()}).strict(),{action:Vu,safeAction:Ku}=T(Mu,async(e,t)=>{let r=qu.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),Wu=nt.object({counts:nt.number().int().min(1).max(20).optional().default(1)}).strict(),Xu=nt.object({app_ids:nt.array(nt.object({app_id:nt.string(),nonce:nt.number().int().min(0)}))}).strict(),{action:Ju,safeAction:Zu}=T(Xu,async(e,t)=>{let r=Wu.parse(t??{}),n=new URLSearchParams;return n.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${n.toString()}`)}),$r=z.object({id:z.number(),name:z.string(),status:z.string(),teepod_id:z.number(),teepod:z.object({id:z.number(),name:z.string(),region_identifier:z.string().nullable().optional()}).optional().nullable(),user_id:z.number().optional().nullable(),app_id:z.string(),vm_uuid:z.string().nullable(),instance_id:z.string().nullable(),app_url:z.string().optional().nullable(),base_image:z.string().nullable(),vcpu:z.number(),memory:z.number(),disk_size:z.number(),manifest_version:z.number().optional().nullable(),version:z.string().optional().nullable(),runner:z.string().optional().nullable(),docker_compose_file:z.string().optional().nullable(),features:z.array(z.string()).optional().nullable(),created_at:z.string(),encrypted_env_pubkey:z.string().nullable()}),Yu=U,{action:Qu,safeAction:ep}=T($r,async(e,t)=>{let{cvmId:r}=Yu.parse(t);return await e.post(`/cvms/${r}/start`)}),tp=U,{action:rp,safeAction:np}=T($r,async(e,t)=>{let{cvmId:r}=tp.parse(t);return await e.post(`/cvms/${r}/stop`)}),op=U,{action:sp,safeAction:ip}=T($r,async(e,t)=>{let{cvmId:r}=op.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),cp=Me(Ae.extend({force:ap.boolean().optional()})),{action:lp,safeAction:up}=T($r,async(e,t)=>{let r=cp.parse(t),{cvmId:n}=U.parse(r),{force:o=!1}=r;return await e.post(`/cvms/${n}/restart`,{force:o})}),fp=U,{action:mp,safeAction:dp}=T(pp.void(),async(e,t)=>{let{cvmId:r}=fp.parse(t);await e.delete(`/cvms/${r}`)}),hp=$.object({name:$.string(),mount_point:$.string(),total_size:$.number(),free_size:$.number()}),gp=$.object({os_name:$.string(),os_version:$.string(),kernel_version:$.string(),cpu_model:$.string(),num_cpus:$.number(),total_memory:$.number(),available_memory:$.number(),used_memory:$.number(),free_memory:$.number(),total_swap:$.number(),used_swap:$.number(),free_swap:$.number(),uptime:$.number(),loadavg_one:$.number(),loadavg_five:$.number(),loadavg_fifteen:$.number(),disks:$.array(hp)}),xp=$.object({is_online:$.boolean(),is_public:$.boolean().default(!1),error:$.string().nullable(),sysinfo:gp.nullable(),status:$.string().nullable(),in_progress:$.boolean().default(!1),boot_progress:$.string().nullable(),boot_error:$.string().nullable()}),bp=U,{action:yp,safeAction:vp}=T(xp,async(e,t)=>{let{cvmId:r}=bp.parse(t);return await e.get(`/cvms/${r}/stats`)}),wp=ke.object({app:ke.string(),instance:ke.string()}),_p=ke.object({is_online:ke.boolean(),is_public:ke.boolean().default(!0),error:ke.string().nullable(),internal_ip:ke.string().nullable(),latest_handshake:ke.string().nullable(),public_urls:ke.array(wp).nullable()}),Cp=U,{action:kp,safeAction:Sp}=T(_p,async(e,t)=>{let{cvmId:r}=Cp.parse(t);return await e.get(`/cvms/${r}/network`)}),Tp=U,{action:Ip,safeAction:Ap}=T(Ep.string(),async(e,t)=>{let{cvmId:r}=Tp.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),Pp=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()}),Lp=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(Pp).nullable()}),$p=U,{action:Bp,safeAction:zp}=T(Lp,async(e,t)=>{let{cvmId:r}=$p.parse(t);return await e.get(`/cvms/${r}/composition`)}),Rp=y.object({common_name:y.string().nullable(),organization:y.string().nullable(),country:y.string().nullable(),state:y.string().nullable(),locality:y.string().nullable()}),jp=y.object({common_name:y.string().nullable(),organization:y.string().nullable(),country:y.string().nullable()}),Up=y.object({subject:Rp,issuer:jp,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()}),Fp=y.object({imr:y.number(),event_type:y.number(),digest:y.string(),event:y.string(),event_payload:y.string()}),Hp=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(Fp),app_compose:y.string()}),Op=y.object({name:y.string().nullable(),is_online:y.boolean(),is_public:y.boolean().default(!0),error:y.string().nullable(),app_certificates:y.array(Up).nullable(),tcb_info:Hp.nullable(),compose_file:y.string().nullable()}),Np=U,{action:Gp,safeAction:Dp}=T(Op,async(e,t)=>{let{cvmId:r}=Np.parse(t);return await e.get(`/cvms/${r}/attestation`)}),qp=Me(Ae.extend({vcpu:wt.number().optional(),memory:wt.number().optional(),disk_size:wt.number().optional(),instance_type:wt.string().optional(),allow_restart:wt.boolean().optional()})),{action:Mp,safeAction:Vp}=T(wt.void(),async(e,t)=>{let r=qp.parse(t),{cvmId:n}=U.parse(r),{...o}=r;await e.patch(`/cvms/${n}/resources`,o)}),Kp=Me(Ae.extend({public_sysinfo:_n.boolean(),public_logs:_n.boolean(),public_tcbinfo:_n.boolean().optional()})),{action:Wp,safeAction:Xp}=T(oi,async(e,t)=>{let r=Kp.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})}),qs=X.object({name:X.string(),os_image_hash:X.string().nullable(),is_current:X.boolean()}),Jp=X.object({version:X.union([X.tuple([X.number(),X.number(),X.number(),X.number()]),X.tuple([X.number(),X.number(),X.number()])]),prod:qs.nullable(),dev:qs.nullable()}),Zp=X.array(Jp),Yp=U,{action:Qp,safeAction:ef}=T(Zp,async(e,t)=>{let{cvmId:r}=Yp.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),tf=Me(Ae.extend({os_image_name:mi.string().min(1,"OS image name is required")})),{action:rf,safeAction:nf}=T(mi.void(),async(e,t)=>{let r=tf.parse(t),{cvmId:n}=U.parse(r),{os_image_name:o}=r;await e.patch(`/cvms/${n}/os-image`,{os_image_name:o})}),of=Ce.object({id:Ce.string().optional(),instance_id:Ce.string().optional(),name:Ce.string(),status:Ce.string(),uptime:Ce.string().optional(),exited_at:Ce.string().optional(),boot_progress:Ce.string().optional(),boot_error:Ce.string().optional(),shutdown_progress:Ce.string().optional()}),sf=U,{action:af,safeAction:cf}=T(of,async(e,t)=>{let{cvmId:r}=sf.parse(t);return await e.get(`/cvms/${r}/state`)});function di(e={}){let t=Yc(e),r={getCurrentUser:Ys,safeGetCurrentUser:sl,getAvailableNodes:ml,safeGetAvailableNodes:dl,listAllInstanceTypeFamilies:yl,safeListAllInstanceTypeFamilies:vl,listFamilyInstanceTypes:wl,safeListFamilyInstanceTypes:_l,listWorkspaces:Sl,safeListWorkspaces:El,getWorkspace:Tl,safeGetWorkspace:Il,getCvmInfo:ai,safeGetCvmInfo:Lr,getCvmList:ci,safeGetCvmList:An,provisionCvm:Jl,safeProvisionCvm:Zl,commitCvmProvision:Ql,safeCommitCvmProvision:eu,getCvmComposeFile:iu,safeGetCvmComposeFile:Pn,provisionCvmComposeFileUpdate:lu,safeProvisionCvmComposeFileUpdate:uu,commitCvmComposeFileUpdate:mu,safeCommitCvmComposeFileUpdate:du,updateCvmEnvs:yu,safeUpdateCvmEnvs:vu,updateDockerCompose:Su,safeUpdateDockerCompose:Eu,updatePreLaunchScript:Lu,safeUpdatePreLaunchScript:$u,getCvmPreLaunchScript:Ru,safeGetCvmPreLaunchScript:ju,startCvm:Qu,safeStartCvm:ep,stopCvm:rp,safeStopCvm:np,shutdownCvm:sp,safeShutdownCvm:ip,restartCvm:lp,safeRestartCvm:up,deleteCvm:mp,safeDeleteCvm:dp,getCvmStats:yp,safeGetCvmStats:vp,getCvmNetwork:kp,safeGetCvmNetwork:Sp,getCvmDockerCompose:Ip,safeGetCvmDockerCompose:Ap,getCvmContainersStats:Bp,safeGetCvmContainersStats:zp,getCvmAttestation:Gp,safeGetCvmAttestation:Dp,updateCvmResources:Mp,safeUpdateCvmResources:Vp,updateCvmVisibility:Wp,safeUpdateCvmVisibility:Xp,getAvailableOsImages:Qp,safeGetAvailableOsImages:ef,updateOsImage:rf,safeUpdateOsImage:nf,getKmsInfo:Fu,safeGetKmsInfo:Hu,getKmsList:Gu,safeGetKmsList:Du,getAppEnvEncryptPubKey:Vu,safeGetAppEnvEncryptPubKey:Ku,nextAppIds:Ju,safeNextAppIds:Zu,getCvmState:af,safeGetCvmState:cf};return t.extend(r)}var Ms=x.object({vm_uuid:x.string().nullable(),app_id:x.string(),name:x.string().default(""),status:x.string(),vcpu:x.number().int(),memory:x.number().int(),disk_size:x.number().int(),teepod_id:x.number().int(),teepod_name:x.string(),region_identifier:x.string().nullable().optional(),kms_type:x.string().nullable().optional(),instance_type:x.string().nullable().optional(),listed:x.boolean().nullable().optional(),base_image:x.string().nullable().optional(),kms_slug:x.string().nullable().optional(),kms_id:x.string().nullable().optional(),instance_id:x.string().nullable().optional(),machine_info:Sn.nullable().optional(),updated_at:x.string().nullable().optional()}),lf=x.object({display_name:x.string().nullable().optional(),avatar_url:x.string().nullable().optional(),description:x.string().nullable().optional(),custom_domain:x.string().nullable().optional()}),uf=x.object({id:x.string(),name:x.string(),app_id:x.string(),app_provision_type:x.string().nullable().optional(),app_icon_url:x.string().nullable().optional(),created_at:x.string(),kms_type:x.string(),profile:lf.nullable().optional(),current_cvm:Ms.nullable().optional(),cvms:x.array(Ms).default([]),cvm_count:x.number().int().default(0)}),pf=x.object({id:x.null().optional(),app_id:x.string(),name:x.null().optional(),app_provision_type:x.null().optional(),app_icon_url:x.null().optional(),created_at:x.null().optional(),kms_type:x.null().optional(),current_cvm:x.null().optional(),cvms:x.null().optional(),cvm_count:x.null().optional()}),ff=x.union([uf,pf]),wb=x.object({dstack_apps:x.array(ff),page:x.number().int(),page_size:x.number().int(),total:x.number().int(),total_pages:x.number().int()}),mf=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:Pr.nullable().optional(),cvms:A.array(Pr).default([]),cvm_count:A.number().int().default(0)}),df=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()}),hf=A.union([mf,df]),Cb=A.object({dstack_apps:A.array(hf),page:A.number().int(),page_size:A.number().int(),total:A.number().int(),total_pages:A.number().int()}),hi=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:Tn.nullable().optional(),cvm:hi.nullable().optional(),workspace:In.nullable().optional()}),Sb=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:Tn.nullable().optional(),cvm:hi.nullable().optional(),workspace:In.nullable().optional()}),Eb=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 xf=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(),Pb=xf.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"]}),Lb=N.object({appId:N.string(),appAuthAddress:N.string(),deployer:N.string(),transactionHash:N.string(),blockNumber:N.bigint().optional(),gasUsed:N.bigint().optional()}).passthrough();var Bb=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"]}),zb=F.object({composeHash:F.string(),appId:F.string(),transactionHash:F.string(),blockNumber:F.bigint().optional(),gasUsed:F.bigint().optional()}).passthrough();var bf=si;var yf=yt.object({items:yt.array(bf),total:yt.number(),page:yt.number(),page_size:yt.number(),pages:yt.number()}).passthrough(),{action:jb,safeAction:Ub}=T(yf,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)}),_t=ye.object({limit:ye.number(),remaining:ye.number()}).passthrough(),vf=ye.object({vm_slots:_t,vcpu:_t,memory_mb:_t,disk_gb:_t}).passthrough(),wf=ye.object({gpus:_t,in_use:ye.number(),misconfigured:ye.number()}).passthrough(),_f=ye.object({team_slug:ye.string(),tier:ye.string(),quotas:vf,reserved_nodes:_t,reserved_gpu:wf,as_of:ye.string()}).passthrough(),{action:Hb,safeAction:Ob}=T(_f,async(e,t)=>await e.get(`/workspaces/${t.teamSlug}/quotas`)),Gb=vt.object({target:vt.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:vt.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:vt.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:vt.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:vt.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});var Cf=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(),Cf),Sf=Q.object({vmUuids:Q.array(Q.string())}),{action:qb,safeAction:Mb}=T(kf,async(e,t)=>{let{vmUuids:r}=Sf.parse(t);return await e.post("/status/batch",{vm_uuids:r})}),Kb=ce.object({page:ce.number().int().min(1).optional(),page_size:ce.number().int().min(1).max(100).optional(),search:ce.string().optional(),status:ce.array(ce.string()).optional(),listed:ce.boolean().optional(),base_image:ce.string().optional(),instance_type:ce.string().optional(),kms_slug:ce.string().optional(),kms_type:ce.string().optional(),node:ce.string().optional(),region:ce.string().optional()}).strict();var Xb=Vs.object({appId:Vs.string().min(1)}).strict();var Zb=Ks.object({appId:Ks.string().min(1)}).strict();var Qb=Tr.object({appId:Tr.string().min(1),page:Tr.number().int().min(1).optional(),page_size:Tr.number().int().min(1).max(1e3).optional()}).strict();var ty=Ir.object({appId:Ir.string().min(1),revisionId:Ir.string().min(1),rawComposeFile:Ir.boolean().optional()}).strict();var ny=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 Bf from"path";import Ln from"fs-extra";import zf from"@iarna/toml";import{z as Pe}from"zod";import ee from"chalk";import Pf from"ora";var Af=!1;function ve(){return Af}function Lf(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 $f(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 gi(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,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(...nm(n,t));continue}let o=rm(n,t);r.push(...o)}if(r.length===0){let n=e.trim();r.push(n)}return r}var We={error:(e,...t)=>{we()||(process.stderr.write(`${ee.red("\u2717")} ${ee.red(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
27
|
+
`))},warn:(e,...t)=>{we()||(process.stderr.write(`${ee.yellow("\u26A0")} ${ee.yellow(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
28
|
+
`))},info:(e,...t)=>{we()||(process.stderr.write(`${ee.blue("\u2139")} ${ee.blue(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
29
|
+
`))},success:(e,...t)=>{we()||(process.stderr.write(`${ee.green("\u2713")} ${ee.green(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
30
|
+
`))},debug:(e,...t)=>{we()||process.env.DEBUG&&(process.stderr.write(`${ee.gray("\u{1F50D}")} ${ee.gray(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
|
|
31
|
+
`))},table:(e,t)=>{if(!we()){if(e.length===0){console.log(ee.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(ee.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(ee.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(we())return;let{borderStyle:r="single",keyColor:n=ee.blue,valueColor:o=ee.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??""),J=Si(z,l),V=Si(G,u),Z=Math.max(J.length,V.length);for(;J.length<Z;)J.push("");for(;V.length<Z;)V.push("");for(let re=0;re<Z;re++){let ue=J[re].padEnd(l),Kt=V[re].padEnd(u);console.log(r!=="none"?`${a.vertical} ${n(ue)} ${a.vertical} ${o(Kt)} ${a.vertical}`:`${n(ue)} : ${o(Kt)}`)}}r!=="none"&&console.log(a.bottomLeft+a.horizontal.repeat(g-2)+a.bottomRight)},break:()=>{we()||process.stderr.write(`
|
|
32
|
+
`)},startSpinner:e=>{if(we())return{stop:()=>{}};let t=tm(e).start();return{stop:(r=!0,n)=>{n&&(t.text=n),r?t.succeed():t.fail()}}},logDetailedError(e,t){if(we())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 im=Pe.extend({profile:$e.string().optional(),api_version:$e.enum(Pn).optional(),gateway_domain:$e.string().optional(),gateway_port:$e.number().int().positive().optional(),compose_file:$e.string().optional(),env_file:$e.string().optional(),public_logs:$e.boolean().optional(),public_sysinfo:$e.boolean().optional(),listed:$e.boolean().optional()}),Fn="phala.toml";function Ei(){return om.join(process.cwd(),Fn)}function am(){return Un.existsSync(Ei())}function cm(){let e=Ei();if(!Un.existsSync(e))throw new Error(`Project configuration file not found: ${Fn}
|
|
38
|
+
Run 'phala init' to create one.`);try{let t=Un.readFileSync(e,"utf8"),r=sm.parse(t),n=im.parse(r);if(n.id||n.uuid||n.app_id||n.instance_id||n.name){let{cvmId:o}=U.parse(n);return{...n,cvm_id:o}}return n}catch(t){if(t instanceof $e.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 ${Fn}: ${t instanceof Error?t.message:String(t)}`)}}function Ti(){return am()?cm():{}}import Ii from"fs";import lm from"os";import Pi from"path";var Ai="https://cloud-api.phala.com/api/v1";function um(){let e=process.env.PHALA_CLOUD_DIR;return typeof e=="string"&&e.trim().length>0?e:Pi.join(lm.homedir(),".phala-cloud")}function pm(){return Pi.join(um(),"credentials.json")}function Ur(e){return typeof e=="string"&&e.trim().length>0}function fm(e){let t=e.trim();return t.length===0?"default":t}function mm(){try{let e=pm();if(!Ii.existsSync(e))return null;let t=Ii.readFileSync(e,"utf8"),r=JSON.parse(t);if(!r||typeof r!="object")return null;let n=r;return n.schema_version!==1||!Ur(n.current_profile)||!n.profiles||typeof n.profiles!="object"?null:n}catch(e){return We.error("Failed to read credentials file:",e),null}}function $i(e){let t=mm(),r=fm(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:Ai)??Ai,i=n?"env":o?"file":"default";if(Ur(e.apiToken))return{apiKey:e.apiToken,baseURL:s,profileName:r,tokenSource:"flag",apiPrefixSource:i};if(Ur(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 Ur(a)?{apiKey:a,baseURL:s,profileName:r,tokenSource:"file",apiPrefixSource:i}:{apiKey:null,baseURL:s,profileName:r,tokenSource:"none",apiPrefixSource:i}}var dm="2026-01-21";function hm(){return{env:process.env,projectConfig:Ti()}}function gm(e,t){let r=e??hm();return $i({env:r.env,apiToken:t?.apiToken,profile:t?.profile,projectProfile:r.projectConfig.profile})}async function te(e,t){let r=gm(e,t);return Ci({apiKey:r.apiKey??void 0,baseURL:r.baseURL,version:dm})}import{z as c}from"zod";var bm=c.object({password:c.string(),registry:c.string().nullable(),username:c.string()}),hv=c.object({docker_compose_file:c.string(),docker_config:bm.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(),Li=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()}),gv=c.object({key:c.string(),value:c.string()}),zi=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()}))}),Bi=c.object({id:c.number(),name:c.string(),status:c.string(),teepod_id:c.number(),teepod:c.object({id:c.number(),name:c.string()}),user_id:c.number().nullable(),app_id:c.string(),vm_uuid:c.string().nullable(),instance_id:c.string().nullable(),app_url:c.string().nullable(),base_image:c.string().nullable(),vcpu:c.number(),memory:c.number(),disk_size:c.number(),manifest_version:c.number().nullable(),version:c.string().nullable(),runner:c.string().nullable(),docker_compose_file:c.string().nullable(),features:c.array(c.string()).nullable(),created_at:c.string(),encrypted_env_pubkey:c.string().nullable()}),Ri=c.object({is_online:c.boolean(),is_public:c.boolean(),error:c.string().nullable(),app_certificates:c.array(c.object({subject:c.object({common_name:c.string().nullable(),organization:c.string().nullable(),country:c.string().nullable(),state:c.string().nullable().optional(),locality:c.string().nullable().optional()}),issuer:c.object({common_name:c.string().nullable(),organization:c.string().nullable(),country:c.string().nullable()}),serial_number:c.string(),not_before:c.string(),not_after:c.string(),version:c.string(),fingerprint:c.string(),signature_algorithm:c.string(),sans:c.string().nullable(),is_ca:c.boolean(),position_in_chain:c.number(),quote:c.string().nullable()})).nullable(),tcb_info:c.object({mrtd:c.string(),rootfs_hash:c.string(),rtmr0:c.string(),rtmr1:c.string(),rtmr2:c.string(),rtmr3:c.string(),event_log:c.array(c.object({imr:c.number(),event_type:c.number(),digest:c.string(),event:c.string(),event_payload:c.string()}))}).nullable(),compose_file:c.string().nullable()}),xm=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()}),bv=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(xm).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 ym from"inquirer";async function kv(e){let t=await te(),r=e.replace(/^app_/,""),n=await Rr(t,{app_id:r});if(!n.success)throw new Error(n.error.message);return n.data}async function Sv(e){let t=await te(),r=await jn(t,{id:e});if(!r.success)throw new Error(r.error.message);return r.data}async function Ev(e){let t=await te(),r=e.replace(/^app_/,""),n=await t.get(`cvms/app_${r}/network`);return zi.parse(n)}async function Tv(){let e=We.startSpinner("Fetching available CVMs"),t=await te(),r=await Rn(t);if(e.stop(!0),!r.success){We.error(`Failed to fetch CVMs: ${r.error.message}`);return}let{items:n}=r.data;if(n.length===0){We.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 ym.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:o}]);return s}async function Iv(e){let t=await te(),r=e.replace(/^app_/,""),n=await t.get(`cvms/app_${r}/attestation`);try{return Ri.parse(n)}catch(o){return We.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 Av(e,t){let r=await te(),n=e.replace(/^app_/,""),o=await r.post(`cvms/app_${n}/replicas`,t);return Bi.parse(o)}async function Pv(e,t,r,n,o){let s=await te(),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 $v(e){return await(await te()).post("cvms/pubkey/from_cvm_configuration",e)}async function Lv(e){let r=await(await te()).post("cvms/from_cvm_configuration",e);return Li.parse(r)}async function zv(e,t){let r=await te(),n=e.replace(/^app_/,"");return await r.put(`cvms/app_${n}/compose`,t)}async function Bv(e=!1){let t=await te(),r="teepods/available";return e&&(r+="?v03x_only=1"),await t.get(r)}function Xe(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 ji(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 vm(e){return!e||/\s/.test(e)||e.length%4!==0?!1:/^[A-Za-z0-9+/]+={0,2}$/.test(e)}function wm(e){if(!vm(e))return e;try{return Buffer.from(e,"base64").toString("utf-8")}catch{return e}}function Fr(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:wm(r.message)}}catch{return null}}function _m(e){let t=e.split(/\r?\n/),r=[];for(let n of t){if(!n.trim())continue;let o=Fr(n);if(o){r.push(o);continue}r.push({channel:"stdout",message:`${n}
|
|
41
|
+
`})}return r}function Cm(e){let t=e.split(/\r?\n/),r="";for(let n of t){let o=Fr(n);if(o){r+=o.message;continue}n.trim()&&(r+=`${n}
|
|
42
|
+
`)}return r}async function km(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=Fr(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 Sm(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=Fr(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 Hn(e,t){let n=await(await te()).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 Ui(e){return Hn(e,"serial")}async function Hr(e,t,r=!0){let o=await(await te()).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 Rv(e,t={}){let r=await Ui(e),n=Xe(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 jv(e,t={}){let r=await Hr(e,t.container,t.matchContainerIdPrefix??!0),n=t.text??!0,o=t.bare??!0,s=Xe(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("{")?Cm(a):a}async function Uv(e,t={}){let r=await Hr(e,t.container,t.matchContainerIdPrefix??!0),n=Xe(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("{")?_m(s):[{channel:"stdout",message:s}]}async function Fv(e,t,r={},n){let o=await Hr(e,r.container,r.matchContainerIdPrefix??!0),s=Xe(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 Sm(i,t)}async function Hv(e,t,r={},n){let o=await Ui(e),s=Xe(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 ji(i,t)}async function Ov(e,t,r={},n){let o=await Hr(e,r.container,r.matchContainerIdPrefix??!0),s=r.text??!0,i=r.bare??!0,a=Xe(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 km(l,t)}async function Nv(e,t,r={}){let n=await Hn(e,t),o=Xe(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 Gv(e,t,r,n={},o){let s=await Hn(e,t),i=Xe(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 ji(a,r)}async function qv(e){let t=await te(),r=e.replace(/^app_/,""),n=await Rr(t,{app_id:r});if(!n.success)throw new Error(n.error.message);return n.data.status}export{hv as composeFileSchema,Lv as createCvm,Ri as cvmAttestationResponseSchema,bm as dockerConfigSchema,gv as encryptedEnvItemSchema,jv as fetchContainerLogs,Uv as fetchContainerLogsEntries,Nv as fetchCvmChannelLogs,Rv as fetchSerialLogs,Iv as getCvmAttestation,kv as getCvmByAppId,Sv as getCvmComposeConfig,Hn as getCvmLogEndpoint,Ev as getCvmNetwork,zi as getCvmNetworkResponseSchema,qv as getCvmStatus,$v as getPubkeyFromCvm,Bv as getTeepods,xm as imageSchema,Li as postCvmResponseSchema,Av as replicateCvm,Bi as replicateCvmResponseSchema,Pv as resizeCvm,Tv as selectCvm,Ov as streamContainerLogs,Fv as streamContainerLogsEntries,Gv as streamCvmChannelLogs,Hv as streamSerialLogs,bv as teepodSchema,zv as upgradeCvm};
|
|
49
49
|
/*! Bundled license information:
|
|
50
50
|
|
|
51
51
|
@noble/hashes/esm/utils.js:
|