phala 1.1.1 → 1.1.3-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api/index.js CHANGED
@@ -1,40 +1,40 @@
1
1
  import { createRequire } from 'module';const require = createRequire(import.meta.url);
2
- var ai=Object.create;var xo=Object.defineProperty;var ci=Object.getOwnPropertyDescriptor;var li=Object.getOwnPropertyNames;var pi=Object.getPrototypeOf,ui=Object.prototype.hasOwnProperty;var we=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var E=(e,t)=>()=>(e&&(t=e(e=0)),t);var W=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var fi=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of li(t))!ui.call(e,n)&&n!==r&&xo(e,n,{get:()=>t[n],enumerable:!(o=ci(t,n))||o.enumerable});return e};var ht=(e,t,r)=>(r=e!=null?ai(pi(e)):{},fi(t||!e||!e.__esModule?xo(r,"default",{value:e,enumerable:!0}):r,e));var bo=W((Nu,go)=>{var Je=1e3,Ze=Je*60,Ye=Ze*60,je=Ye*24,mi=je*7,di=je*365.25;go.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return hi(e);if(r==="number"&&isFinite(e))return t.long?gi(e):xi(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function hi(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*di;case"weeks":case"week":case"w":return r*mi;case"days":case"day":case"d":return r*je;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Ye;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ze;case"seconds":case"second":case"secs":case"sec":case"s":return r*Je;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function xi(e){var t=Math.abs(e);return t>=je?Math.round(e/je)+"d":t>=Ye?Math.round(e/Ye)+"h":t>=Ze?Math.round(e/Ze)+"m":t>=Je?Math.round(e/Je)+"s":e+"ms"}function gi(e){var t=Math.abs(e);return t>=je?Ut(e,t,je,"day"):t>=Ye?Ut(e,t,Ye,"hour"):t>=Ze?Ut(e,t,Ze,"minute"):t>=Je?Ut(e,t,Je,"second"):e+" ms"}function Ut(e,t,r,o){var n=t>=r*1.5;return Math.round(e/r)+" "+o+(n?"s":"")}});var wr=W((Mu,yo)=>{function bi(e){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=n,r.enabled=a,r.humanize=bo(),r.destroy=u,Object.keys(e).forEach(f=>{r[f]=e[f]}),r.names=[],r.skips=[],r.formatters={};function t(f){let p=0;for(let d=0;d<f.length;d++)p=(p<<5)-p+f.charCodeAt(d),p|=0;return r.colors[Math.abs(p)%r.colors.length]}r.selectColor=t;function r(f){let p,d=null,h,I;function T(...P){if(!T.enabled)return;let V=T,K=Number(new Date),O=K-(p||K);V.diff=O,V.prev=p,V.curr=K,p=K,P[0]=r.coerce(P[0]),typeof P[0]!="string"&&P.unshift("%O");let Q=0;P[0]=P[0].replace(/%([a-zA-Z%])/g,(te,Rt)=>{if(te==="%%")return"%";Q++;let ho=r.formatters[Rt];if(typeof ho=="function"){let ii=P[Q];te=ho.call(V,ii),P.splice(Q,1),Q--}return te}),r.formatArgs.call(V,P),(V.log||r.log).apply(V,P)}return T.namespace=f,T.useColors=r.useColors(),T.color=r.selectColor(f),T.extend=o,T.destroy=r.destroy,Object.defineProperty(T,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(h!==r.namespaces&&(h=r.namespaces,I=r.enabled(f)),I),set:P=>{d=P}}),typeof r.init=="function"&&r.init(T),T}function o(f,p){let d=r(this.namespace+(typeof p>"u"?":":p)+f);return d.log=this.log,d}function n(f){r.save(f),r.namespaces=f,r.names=[],r.skips=[];let p=(typeof f=="string"?f:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let d of p)d[0]==="-"?r.skips.push(d.slice(1)):r.names.push(d)}function s(f,p){let d=0,h=0,I=-1,T=0;for(;d<f.length;)if(h<p.length&&(p[h]===f[d]||p[h]==="*"))p[h]==="*"?(I=h,T=d,h++):(d++,h++);else if(I!==-1)h=I+1,T++,d=T;else return!1;for(;h<p.length&&p[h]==="*";)h++;return h===p.length}function i(){let f=[...r.names,...r.skips.map(p=>"-"+p)].join(",");return r.enable(""),f}function a(f){for(let p of r.skips)if(s(f,p))return!1;for(let p of r.names)if(s(f,p))return!0;return!1}function l(f){return f instanceof Error?f.stack||f.message:f}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}yo.exports=bi});var vo=W((X,zt)=>{X.formatArgs=vi;X.save=wi;X.load=_i;X.useColors=yi;X.storage=Ci();X.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();X.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function yi(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function vi(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+zt.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(r++,n==="%c"&&(o=r))}),e.splice(o,0,t)}X.log=console.debug||console.log||(()=>{});function wi(e){try{e?X.storage.setItem("debug",e):X.storage.removeItem("debug")}catch{}}function _i(){let e;try{e=X.storage.getItem("debug")||X.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function Ci(){try{return localStorage}catch{}}zt.exports=wr()(X);var{formatters:ki}=zt.exports;ki.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var _o=W((Gu,wo)=>{"use strict";wo.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",o=t.indexOf(r+e),n=t.indexOf("--");return o!==-1&&(n===-1||o<n)}});var To=W((Du,ko)=>{"use strict";var Ti=we("os"),Co=we("tty"),re=_o(),{env:z}=process,Se;re("no-color")||re("no-colors")||re("color=false")||re("color=never")?Se=0:(re("color")||re("colors")||re("color=true")||re("color=always"))&&(Se=1);"FORCE_COLOR"in z&&(z.FORCE_COLOR==="true"?Se=1:z.FORCE_COLOR==="false"?Se=0:Se=z.FORCE_COLOR.length===0?1:Math.min(parseInt(z.FORCE_COLOR,10),3));function _r(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Cr(e,t){if(Se===0)return 0;if(re("color=16m")||re("color=full")||re("color=truecolor"))return 3;if(re("color=256"))return 2;if(e&&!t&&Se===void 0)return 0;let r=Se||0;if(z.TERM==="dumb")return r;if(process.platform==="win32"){let o=Ti.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in z)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(o=>o in z)||z.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in z)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(z.TEAMCITY_VERSION)?1:0;if(z.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in z){let o=parseInt((z.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(z.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(z.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(z.TERM)||"COLORTERM"in z?1:r}function Ei(e){let t=Cr(e,e&&e.isTTY);return _r(t)}ko.exports={supportsColor:Ei,stdout:_r(Cr(!0,Co.isatty(1))),stderr:_r(Cr(!0,Co.isatty(2)))}});var So=W((F,Ht)=>{var Si=we("tty"),Ft=we("util");F.init=Ri;F.log=Bi;F.formatArgs=Ai;F.save=$i;F.load=Li;F.useColors=Ii;F.destroy=Ft.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");F.colors=[6,2,3,4,5,1];try{let e=To();e&&(e.stderr||e).level>=2&&(F.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}F.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.toUpperCase()),o=process.env[t];return/^(yes|on|true|enabled)$/i.test(o)?o=!0:/^(no|off|false|disabled)$/i.test(o)?o=!1:o==="null"?o=null:o=Number(o),e[r]=o,e},{});function Ii(){return"colors"in F.inspectOpts?!!F.inspectOpts.colors:Si.isatty(process.stderr.fd)}function Ai(e){let{namespace:t,useColors:r}=this;if(r){let o=this.color,n="\x1B[3"+(o<8?o:"8;5;"+o),s=` ${n};1m${t} \x1B[0m`;e[0]=s+e[0].split(`
2
+ var li=Object.create;var go=Object.defineProperty;var pi=Object.getOwnPropertyDescriptor;var ui=Object.getOwnPropertyNames;var fi=Object.getPrototypeOf,mi=Object.prototype.hasOwnProperty;var _e=(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 S=(e,t)=>()=>(e&&(t=e(e=0)),t);var X=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var di=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ui(t))!mi.call(e,n)&&n!==r&&go(e,n,{get:()=>t[n],enumerable:!(o=pi(t,n))||o.enumerable});return e};var xt=(e,t,r)=>(r=e!=null?li(fi(e)):{},di(t||!e||!e.__esModule?go(r,"default",{value:e,enumerable:!0}):r,e));var yo=X((Vu,bo)=>{var Ze=1e3,Ye=Ze*60,Qe=Ye*60,Ne=Qe*24,hi=Ne*7,xi=Ne*365.25;bo.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return gi(e);if(r==="number"&&isFinite(e))return t.long?yi(e):bi(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function gi(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*xi;case"weeks":case"week":case"w":return r*hi;case"days":case"day":case"d":return r*Ne;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Qe;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ye;case"seconds":case"second":case"secs":case"sec":case"s":return r*Ze;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function bi(e){var t=Math.abs(e);return t>=Ne?Math.round(e/Ne)+"d":t>=Qe?Math.round(e/Qe)+"h":t>=Ye?Math.round(e/Ye)+"m":t>=Ze?Math.round(e/Ze)+"s":e+"ms"}function yi(e){var t=Math.abs(e);return t>=Ne?zt(e,t,Ne,"day"):t>=Qe?zt(e,t,Qe,"hour"):t>=Ye?zt(e,t,Ye,"minute"):t>=Ze?zt(e,t,Ze,"second"):e+" ms"}function zt(e,t,r,o){var n=t>=r*1.5;return Math.round(e/r)+" "+o+(n?"s":"")}});var _r=X((Ku,vo)=>{function vi(e){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=n,r.enabled=a,r.humanize=yo(),r.destroy=f,Object.keys(e).forEach(m=>{r[m]=e[m]}),r.names=[],r.skips=[],r.formatters={};function t(m){let p=0;for(let d=0;d<m.length;d++)p=(p<<5)-p+m.charCodeAt(d),p|=0;return r.colors[Math.abs(p)%r.colors.length]}r.selectColor=t;function r(m){let p,d=null,h,I;function T(...P){if(!T.enabled)return;let K=T,W=Number(new Date),O=W-(p||W);K.diff=O,K.prev=p,K.curr=W,p=W,P[0]=r.coerce(P[0]),typeof P[0]!="string"&&P.unshift("%O");let ee=0;P[0]=P[0].replace(/%([a-zA-Z%])/g,(re,Ut)=>{if(re==="%%")return"%";ee++;let xo=r.formatters[Ut];if(typeof xo=="function"){let ci=P[ee];re=xo.call(K,ci),P.splice(ee,1),ee--}return re}),r.formatArgs.call(K,P),(K.log||r.log).apply(K,P)}return T.namespace=m,T.useColors=r.useColors(),T.color=r.selectColor(m),T.extend=o,T.destroy=r.destroy,Object.defineProperty(T,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(h!==r.namespaces&&(h=r.namespaces,I=r.enabled(m)),I),set:P=>{d=P}}),typeof r.init=="function"&&r.init(T),T}function o(m,p){let d=r(this.namespace+(typeof p>"u"?":":p)+m);return d.log=this.log,d}function n(m){r.save(m),r.namespaces=m,r.names=[],r.skips=[];let p=(typeof m=="string"?m:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let d of p)d[0]==="-"?r.skips.push(d.slice(1)):r.names.push(d)}function s(m,p){let d=0,h=0,I=-1,T=0;for(;d<m.length;)if(h<p.length&&(p[h]===m[d]||p[h]==="*"))p[h]==="*"?(I=h,T=d,h++):(d++,h++);else if(I!==-1)h=I+1,T++,d=T;else return!1;for(;h<p.length&&p[h]==="*";)h++;return h===p.length}function i(){let m=[...r.names,...r.skips.map(p=>"-"+p)].join(",");return r.enable(""),m}function a(m){for(let p of r.skips)if(s(m,p))return!1;for(let p of r.names)if(s(m,p))return!0;return!1}function l(m){return m instanceof Error?m.stack||m.message:m}function f(){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}vo.exports=vi});var wo=X((J,Ft)=>{J.formatArgs=_i;J.save=Ci;J.load=ki;J.useColors=wi;J.storage=Ti();J.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`."))}})();J.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 wi(){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 _i(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Ft.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(r++,n==="%c"&&(o=r))}),e.splice(o,0,t)}J.log=console.debug||console.log||(()=>{});function Ci(e){try{e?J.storage.setItem("debug",e):J.storage.removeItem("debug")}catch{}}function ki(){let e;try{e=J.storage.getItem("debug")||J.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function Ti(){try{return localStorage}catch{}}Ft.exports=_r()(J);var{formatters:Si}=Ft.exports;Si.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Co=X((Wu,_o)=>{"use strict";_o.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",o=t.indexOf(r+e),n=t.indexOf("--");return o!==-1&&(n===-1||o<n)}});var So=X((Xu,To)=>{"use strict";var Ei=_e("os"),ko=_e("tty"),oe=Co(),{env:z}=process,Ie;oe("no-color")||oe("no-colors")||oe("color=false")||oe("color=never")?Ie=0:(oe("color")||oe("colors")||oe("color=true")||oe("color=always"))&&(Ie=1);"FORCE_COLOR"in z&&(z.FORCE_COLOR==="true"?Ie=1:z.FORCE_COLOR==="false"?Ie=0:Ie=z.FORCE_COLOR.length===0?1:Math.min(parseInt(z.FORCE_COLOR,10),3));function Cr(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function kr(e,t){if(Ie===0)return 0;if(oe("color=16m")||oe("color=full")||oe("color=truecolor"))return 3;if(oe("color=256"))return 2;if(e&&!t&&Ie===void 0)return 0;let r=Ie||0;if(z.TERM==="dumb")return r;if(process.platform==="win32"){let o=Ei.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in z)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(o=>o in z)||z.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in z)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(z.TEAMCITY_VERSION)?1:0;if(z.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in z){let o=parseInt((z.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(z.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(z.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(z.TERM)||"COLORTERM"in z?1:r}function Ii(e){let t=kr(e,e&&e.isTTY);return Cr(t)}To.exports={supportsColor:Ii,stdout:Cr(kr(!0,ko.isatty(1))),stderr:Cr(kr(!0,ko.isatty(2)))}});var Io=X((F,Ot)=>{var Ai=_e("tty"),Ht=_e("util");F.init=zi;F.log=Li;F.formatArgs=Bi;F.save=Ri;F.load=Ui;F.useColors=Pi;F.destroy=Ht.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");F.colors=[6,2,3,4,5,1];try{let e=So();e&&(e.stderr||e).level>=2&&(F.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}F.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.toUpperCase()),o=process.env[t];return/^(yes|on|true|enabled)$/i.test(o)?o=!0:/^(no|off|false|disabled)$/i.test(o)?o=!1:o==="null"?o=null:o=Number(o),e[r]=o,e},{});function Pi(){return"colors"in F.inspectOpts?!!F.inspectOpts.colors:Ai.isatty(process.stderr.fd)}function Bi(e){let{namespace:t,useColors:r}=this;if(r){let o=this.color,n="\x1B[3"+(o<8?o:"8;5;"+o),s=` ${n};1m${t} \x1B[0m`;e[0]=s+e[0].split(`
3
3
  `).join(`
4
- `+s),e.push(n+"m+"+Ht.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=Pi()+t+" "+e[0]}function Pi(){return F.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Bi(...e){return process.stderr.write(Ft.formatWithOptions(F.inspectOpts,...e)+`
5
- `)}function $i(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function Li(){return process.env.DEBUG}function Ri(e){e.inspectOpts={};let t=Object.keys(F.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=F.inspectOpts[t[r]]}Ht.exports=wr()(F);var{formatters:Eo}=Ht.exports;Eo.o=function(e){return this.inspectOpts.colors=this.useColors,Ft.inspect(e,this.inspectOpts).split(`
6
- `).map(t=>t.trim()).join(" ")};Eo.O=function(e){return this.inspectOpts.colors=this.useColors,Ft.inspect(e,this.inspectOpts)}});var Io=W((qu,kr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?kr.exports=vo():kr.exports=So()});var Tr,Po=E(()=>{Tr="2.38.6"});function Bo(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Bo(e.cause,t):t?null:e}var Er,b,oe=E(()=>{Po();Er={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${Tr}`},b=class e extends Error{constructor(t,r={}){let o=r.cause instanceof e?r.cause.details:r.cause?.message?r.cause.message:r.details,n=r.cause instanceof e&&r.cause.docsPath||r.docsPath,s=Er.getDocsUrl?.({...r,docsPath:n}),i=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...o?[`Details: ${o}`]:[],...Er.version?[`Version: ${Er.version}`]:[]].join(`
7
- `);super(i,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=o,this.docsPath=n,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=Tr}walk(t){return Bo(this,t)}}});var Ot,jt,Sr=E(()=>{oe();Ot=class extends b{constructor({max:t,min:r,signed:o,size:n,value:s}){super(`Number "${s}" is not in safe ${n?`${n*8}-bit ${o?"signed":"unsigned"} `:""}integer range ${t?`(${r} to ${t})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}},jt=class extends b{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function de(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var Qe=E(()=>{});function ne(e){return de(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var xt=E(()=>{Qe()});function gt(e,{dir:t="left"}={}){let r=typeof e=="string"?e.replace("0x",""):e,o=0;for(let n=0;n<r.length-1&&r[t==="left"?n:r.length-n-1].toString()==="0";n++)o++;return r=t==="left"?r.slice(o):r.slice(0,r.length-o),typeof e=="string"?(r.length===1&&t==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}var $o=E(()=>{});var bt,yt,Ir=E(()=>{oe();bt=class extends b{constructor({offset:t,position:r,size:o}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${o}).`,{name:"SliceOffsetOutOfBoundsError"})}},yt=class extends b{constructor({size:t,targetSize:r,type:o}){super(`${o.charAt(0).toUpperCase()}${o.slice(1).toLowerCase()} size (${t}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}});function Ie(e,{dir:t,size:r=32}={}){return typeof e=="string"?Ui(e,{dir:t,size:r}):zi(e,{dir:t,size:r})}function Ui(e,{dir:t,size:r=32}={}){if(r===null)return e;let o=e.replace("0x","");if(o.length>r*2)throw new yt({size:Math.ceil(o.length/2),targetSize:r,type:"hex"});return`0x${o[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function zi(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new yt({size:e.length,targetSize:r,type:"bytes"});let o=new Uint8Array(r);for(let n=0;n<r;n++){let s=t==="right";o[s?n:r-n-1]=e[s?n:e.length-n-1]}return o}var Ar=E(()=>{Ir()});function le(e,t={}){return typeof e=="number"||typeof e=="bigint"?_(e,t):typeof e=="string"?ji(e,t):typeof e=="boolean"?Hi(e,t):J(e,t)}function Hi(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(Ae(r,{size:t.size}),Ie(r,{size:t.size})):r}function J(e,t={}){let r="";for(let n=0;n<e.length;n++)r+=Fi[e[n]];let o=`0x${r}`;return typeof t.size=="number"?(Ae(o,{size:t.size}),Ie(o,{dir:"right",size:t.size})):o}function _(e,t={}){let{signed:r,size:o}=t,n=BigInt(e),s;o?r?s=(1n<<BigInt(o)*8n-1n)-1n:s=2n**(BigInt(o)*8n)-1n:typeof e=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));let i=typeof s=="bigint"&&r?-s-1n:0;if(s&&n>s||n<i){let l=typeof e=="bigint"?"n":"";throw new Ot({max:s?`${s}${l}`:void 0,min:`${i}${l}`,signed:r,size:o,value:`${e}${l}`})}let a=`0x${(r&&n<0?(1n<<BigInt(o*8))+BigInt(n):n).toString(16)}`;return o?Ie(a,{size:o}):a}function ji(e,t={}){let r=Oi.encode(e);return J(r,t)}var Fi,Oi,se=E(()=>{Sr();Ar();Me();Fi=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Oi=new TextEncoder});function Nt(e,t={}){return typeof e=="number"||typeof e=="bigint"?Gi(e,t):typeof e=="boolean"?Mi(e,t):de(e)?pe(e,t):Pr(e,t)}function Mi(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(Ae(r,{size:t.size}),Ie(r,{size:t.size})):r}function Lo(e){if(e>=_e.zero&&e<=_e.nine)return e-_e.zero;if(e>=_e.A&&e<=_e.F)return e-(_e.A-10);if(e>=_e.a&&e<=_e.f)return e-(_e.a-10)}function pe(e,t={}){let r=e;t.size&&(Ae(r,{size:t.size}),r=Ie(r,{dir:"right",size:t.size}));let o=r.slice(2);o.length%2&&(o=`0${o}`);let n=o.length/2,s=new Uint8Array(n);for(let i=0,a=0;i<n;i++){let l=Lo(o.charCodeAt(a++)),u=Lo(o.charCodeAt(a++));if(l===void 0||u===void 0)throw new b(`Invalid byte sequence ("${o[a-2]}${o[a-1]}" in "${o}").`);s[i]=l*16+u}return s}function Gi(e,t){let r=_(e,t);return pe(r)}function Pr(e,t={}){let r=Ni.encode(e);return typeof t.size=="number"?(Ae(r,{size:t.size}),Ie(r,{dir:"right",size:t.size})):r}var Ni,_e,Pe=E(()=>{oe();Qe();Ar();Me();se();Ni=new TextEncoder;_e={zero:48,nine:57,A:65,F:70,a:97,f:102}});function Ae(e,{size:t}){if(ne(e)>t)throw new jt({givenSize:ne(e),maxSize:t})}function Ge(e,t={}){let{signed:r}=t;t.size&&Ae(e,{size:t.size});let o=BigInt(e);if(!r)return o;let n=(e.length-2)/2,s=(1n<<BigInt(n)*8n-1n)-1n;return o<=s?o:o-BigInt(`0x${"f".padStart(n*2,"f")}`)-1n}function De(e,t={}){return Number(Ge(e,t))}var Me=E(()=>{Sr();xt()});function et(e,t){return({exclude:r,format:o})=>({exclude:r,format:(n,s)=>{let i=t(n,s);if(r)for(let a of r)delete i[a];return{...i,...o(n,s)}},type:e})}var Mt=E(()=>{});var Uf,zf,Ff,Hf,Of,jf,Nf,Mf,Gf,Df,qf,Vf,Kf,Wf,Xf,Jf,Zf,Yf,Qf,em,tm,rm,om,nm,sm,im,am,cm,lm,pm,um,fm,mm,dm,hm,xm,gm,bm,ym,vm,wm,_m,Cm,km,Tm,Em,Sm,Im,Am,Pm,Bm,$m,Lm,Rm,Um,zm,Fm,Hm,Om,jm,Nm,Mm,Gm,Dm,qm,Vm,Km,Wm,Xm,Jm,Zm,Ym,Qm,ed,td,rd,od,nd,sd,id,ad,cd,ld,pd,ud,fd,md,dd,hd,xd,gd,bd,yd,vd,wd,Gt,Ho=E(()=>{Uf=2n**(8n-1n)-1n,zf=2n**(16n-1n)-1n,Ff=2n**(24n-1n)-1n,Hf=2n**(32n-1n)-1n,Of=2n**(40n-1n)-1n,jf=2n**(48n-1n)-1n,Nf=2n**(56n-1n)-1n,Mf=2n**(64n-1n)-1n,Gf=2n**(72n-1n)-1n,Df=2n**(80n-1n)-1n,qf=2n**(88n-1n)-1n,Vf=2n**(96n-1n)-1n,Kf=2n**(104n-1n)-1n,Wf=2n**(112n-1n)-1n,Xf=2n**(120n-1n)-1n,Jf=2n**(128n-1n)-1n,Zf=2n**(136n-1n)-1n,Yf=2n**(144n-1n)-1n,Qf=2n**(152n-1n)-1n,em=2n**(160n-1n)-1n,tm=2n**(168n-1n)-1n,rm=2n**(176n-1n)-1n,om=2n**(184n-1n)-1n,nm=2n**(192n-1n)-1n,sm=2n**(200n-1n)-1n,im=2n**(208n-1n)-1n,am=2n**(216n-1n)-1n,cm=2n**(224n-1n)-1n,lm=2n**(232n-1n)-1n,pm=2n**(240n-1n)-1n,um=2n**(248n-1n)-1n,fm=2n**(256n-1n)-1n,mm=-(2n**(8n-1n)),dm=-(2n**(16n-1n)),hm=-(2n**(24n-1n)),xm=-(2n**(32n-1n)),gm=-(2n**(40n-1n)),bm=-(2n**(48n-1n)),ym=-(2n**(56n-1n)),vm=-(2n**(64n-1n)),wm=-(2n**(72n-1n)),_m=-(2n**(80n-1n)),Cm=-(2n**(88n-1n)),km=-(2n**(96n-1n)),Tm=-(2n**(104n-1n)),Em=-(2n**(112n-1n)),Sm=-(2n**(120n-1n)),Im=-(2n**(128n-1n)),Am=-(2n**(136n-1n)),Pm=-(2n**(144n-1n)),Bm=-(2n**(152n-1n)),$m=-(2n**(160n-1n)),Lm=-(2n**(168n-1n)),Rm=-(2n**(176n-1n)),Um=-(2n**(184n-1n)),zm=-(2n**(192n-1n)),Fm=-(2n**(200n-1n)),Hm=-(2n**(208n-1n)),Om=-(2n**(216n-1n)),jm=-(2n**(224n-1n)),Nm=-(2n**(232n-1n)),Mm=-(2n**(240n-1n)),Gm=-(2n**(248n-1n)),Dm=-(2n**(256n-1n)),qm=2n**8n-1n,Vm=2n**16n-1n,Km=2n**24n-1n,Wm=2n**32n-1n,Xm=2n**40n-1n,Jm=2n**48n-1n,Zm=2n**56n-1n,Ym=2n**64n-1n,Qm=2n**72n-1n,ed=2n**80n-1n,td=2n**88n-1n,rd=2n**96n-1n,od=2n**104n-1n,nd=2n**112n-1n,sd=2n**120n-1n,id=2n**128n-1n,ad=2n**136n-1n,cd=2n**144n-1n,ld=2n**152n-1n,pd=2n**160n-1n,ud=2n**168n-1n,fd=2n**176n-1n,md=2n**184n-1n,dd=2n**192n-1n,hd=2n**200n-1n,xd=2n**208n-1n,gd=2n**216n-1n,bd=2n**224n-1n,yd=2n**232n-1n,vd=2n**240n-1n,wd=2n**248n-1n,Gt=2n**256n-1n});function qe(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var $r=E(()=>{});var wt,Dt,qt,Oo=E(()=>{oe();wt=class extends b{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},Dt=class extends b{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},qt=class extends b{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function Vt(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(Wi);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var Wi,Lr=E(()=>{Oo();Wi={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new qt({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Dt({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new wt({offset:e});let t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new wt({offset:e});let t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){let t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){let r=t??this.position;return this.assertPosition(r+e-1),this.bytes.subarray(r,r+e)},inspectUint8(e){let t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){let t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){let t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){let t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,e&255),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();let e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();let r=this.inspectBytes(e);return this.position+=t??e,r},readUint8(){this.assertReadLimit(),this._touch();let e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();let e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();let e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();let e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){let t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;let e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}}});var Mo,Go=E(()=>{Mo={ether:-9,wei:9}});function Do(e,t){let r=e.toString(),o=r.startsWith("-");o&&(r=r.slice(1)),r=r.padStart(t,"0");let[n,s]=[r.slice(0,r.length-t),r.slice(r.length-t)];return s=s.replace(/(0+)$/,""),`${o?"-":""}${n||"0"}${s?`.${s}`:""}`}var qo=E(()=>{});function _t(e,t="wei"){return Do(e,Mo[t])}var Vo=E(()=>{Go();qo()});function Zi(e){let t=Object.entries(e).map(([o,n])=>n===void 0||n===!1?null:[o,n]).filter(Boolean),r=t.reduce((o,[n])=>Math.max(o,n.length),0);return t.map(([o,n])=>` ${`${o}:`.padEnd(r+1)} ${n}`).join(`
8
- `)}var Kt,Wt,Xt,Jt=E(()=>{oe();Kt=class extends b{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}},Wt=class extends b{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Zi(t),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}},Xt=class extends b{constructor({storageKey:t}){super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}});function Yi(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Rr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ve(e,...t){if(!Yi(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ot(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Qt(e,t){Ve(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Wo(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Be(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function er(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ue(e,t){return e<<32-t|e>>>t}function ea(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function ta(e){for(let t=0;t<e.length;t++)e[t]=ea(e[t]);return e}function ra(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Ct(e){return typeof e=="string"&&(e=ra(e)),Ve(e),e}function tr(e){let t=o=>e().update(Ct(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}var Qi,Ur,rt,rr=E(()=>{Qi=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;Ur=Qi?e=>e:ta;rt=class{}});function na(e,t=!1){return t?{h:Number(e&nr),l:Number(e>>Zo&nr)}:{h:Number(e>>Zo&nr)|0,l:Number(e&nr)|0}}function Yo(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=na(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var nr,Zo,Qo,en,tn,rn,on=E(()=>{nr=BigInt(4294967295),Zo=BigInt(32);Qo=(e,t,r)=>e<<r|t>>>32-r,en=(e,t,r)=>t<<r|e>>>32-r,tn=(e,t,r)=>t<<r-32|e>>>64-r,rn=(e,t,r)=>e<<r-32|t>>>64-r});var ie,lr=E(()=>{oe();ie=class extends b{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}});var Ke,fn=E(()=>{oe();Ke=class extends b{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}});var pr,We,zr,Fr,Hr,Or,jr,Nr,Mr,Gr,kt,mn=E(()=>{Vo();oe();pr=class extends b{constructor({cause:t,message:r}={}){let o=r?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${o?`with reason: ${o}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}};Object.defineProperty(pr,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(pr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});We=class extends b{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${_t(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}};Object.defineProperty(We,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});zr=class extends b{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${_t(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}};Object.defineProperty(zr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});Fr=class extends b{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}is higher than the next one expected.`,{cause:t,name:"NonceTooHighError"})}};Object.defineProperty(Fr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});Hr=class extends b{constructor({cause:t,nonce:r}={}){super([`Nonce provided for the transaction ${r?`(${r}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
9
- `),{cause:t,name:"NonceTooLowError"})}};Object.defineProperty(Hr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});Or=class extends b{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}};Object.defineProperty(Or,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});jr=class extends b{constructor({cause:t}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
10
- `),{cause:t,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}};Object.defineProperty(jr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});Nr=class extends b{constructor({cause:t,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:t,name:"IntrinsicGasTooHighError"})}};Object.defineProperty(Nr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});Mr=class extends b{constructor({cause:t,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction is too low.`,{cause:t,name:"IntrinsicGasTooLowError"})}};Object.defineProperty(Mr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});Gr=class extends b{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}};Object.defineProperty(Gr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});kt=class extends b{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:o}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${_t(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${o?` = ${_t(o)} gwei`:""}).`].join(`
11
- `),{cause:t,name:"TipAboveFeeCapError"})}};Object.defineProperty(kt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/})});var st,Dr=E(()=>{st=class extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){let r=super.get(t);return super.has(t)&&r!==void 0&&(this.delete(t),super.set(t,r)),r}set(t,r){if(super.set(t,r),this.maxSize&&this.size>this.maxSize){let o=this.keys().next().value;o&&this.delete(o)}return this}}});function ha(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let i=0;i<10;i++)r[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){let a=(i+8)%10,l=(i+2)%10,u=r[l],f=r[l+1],p=dn(u,f,1)^r[a],d=hn(u,f,1)^r[a+1];for(let h=0;h<50;h+=10)e[i+h]^=p,e[i+h+1]^=d}let n=e[2],s=e[3];for(let i=0;i<24;i++){let a=gn[i],l=dn(n,s,a),u=hn(n,s,a),f=xn[i];n=e[f],s=e[f+1],e[f]=l,e[f+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)r[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=ma[o],e[1]^=da[o]}Be(r)}var ca,Tt,la,pa,ua,fa,xn,gn,bn,yn,ma,da,dn,hn,qr,xa,vn,wn=E(()=>{on();rr();ca=BigInt(0),Tt=BigInt(1),la=BigInt(2),pa=BigInt(7),ua=BigInt(256),fa=BigInt(113),xn=[],gn=[],bn=[];for(let e=0,t=Tt,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],xn.push(2*(5*o+r)),gn.push((e+1)*(e+2)/2%64);let n=ca;for(let s=0;s<7;s++)t=(t<<Tt^(t>>pa)*fa)%ua,t&la&&(n^=Tt<<(Tt<<BigInt(s))-Tt);bn.push(n)}yn=Yo(bn,!0),ma=yn[0],da=yn[1],dn=(e,t,r)=>r>32?tn(e,t,r):Qo(e,t,r),hn=(e,t,r)=>r>32?rn(e,t,r):en(e,t,r);qr=class e extends rt{constructor(t,r,o,n=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=r,this.outputLen=o,this.enableXOF=n,this.rounds=s,Rr(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Wo(this.state)}clone(){return this._cloneInto()}keccak(){Ur(this.state32),ha(this.state32,this.rounds),Ur(this.state32),this.posOut=0,this.pos=0}update(t){ot(this),t=Ct(t),Ve(t);let{blockLen:r,state:o}=this,n=t.length;for(let s=0;s<n;){let i=Math.min(r-this.pos,n-s);for(let a=0;a<i;a++)o[this.pos++]^=t[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:r,pos:o,blockLen:n}=this;t[o]^=r,(r&128)!==0&&o===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){ot(this,!1),Ve(t),this.finish();let r=this.state,{blockLen:o}=this;for(let n=0,s=t.length;n<s;){this.posOut>=o&&this.keccak();let i=Math.min(o-this.posOut,s-n);t.set(r.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Rr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Qt(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Be(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new e(r,o,n,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=o,t.outputLen=n,t.enableXOF=i,t.destroyed=this.destroyed,t}},xa=(e,t,r)=>tr(()=>new qr(t,e,r)),vn=xa(1,136,256/8)});function _n(e,t){let r=t||"hex",o=vn(de(e,{strict:!1})?Nt(e):e);return r==="bytes"?o:le(o)}var Cn=E(()=>{wn();Qe();Pe();se()});function kn(e,t){if(Vr.has(`${e}.${t}`))return Vr.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),o=_n(Pr(r),"bytes"),n=(t?r.substring(`${t}0x`.length):r).split("");for(let i=0;i<40;i+=2)o[i>>1]>>4>=8&&n[i]&&(n[i]=n[i].toUpperCase()),(o[i>>1]&15)>=8&&n[i+1]&&(n[i+1]=n[i+1].toUpperCase());let s=`0x${n.join("")}`;return Vr.set(`${e}.${t}`,s),s}var Vr,Tn=E(()=>{Pe();Cn();Dr();Vr=new st(8192)});function he(e,t){let{strict:r=!0}=t??{},o=`${e}.${r}`;if(Kr.has(o))return Kr.get(o);let n=ga.test(e)?e.toLowerCase()===e?!0:r?kn(e)===e:!0:!1;return Kr.set(o,n),n}var ga,Kr,ur=E(()=>{Dr();Tn();ga=/^0x[a-fA-F0-9]{40}$/,Kr=new st(8192)});function En(e,t,r,{strict:o}={}){return de(e,{strict:!1})?ya(e,t,r,{strict:o}):ba(e,t,r,{strict:o})}function Sn(e,t){if(typeof t=="number"&&t>0&&t>ne(e)-1)throw new bt({offset:t,position:"start",size:ne(e)})}function In(e,t,r){if(typeof t=="number"&&typeof r=="number"&&ne(e)!==r-t)throw new bt({offset:r,position:"end",size:ne(e)})}function ba(e,t,r,{strict:o}={}){Sn(e,t);let n=e.slice(t,r);return o&&In(n,t,r),n}function ya(e,t,r,{strict:o}={}){Sn(e,t);let n=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return o&&In(n,t,r),n}var An=E(()=>{Ir();Qe();xt()});var Zr=W(At=>{"use strict";var Pa=At&&At.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(At,"__esModule",{value:!0});At.encryptEnvVars=La;var Xr=we("@noble/curves/ed25519"),Jr=Pa(we("crypto"));function Ba(e){var t,r;return e=e.startsWith("0x")?e.slice(2):e,new Uint8Array((r=(t=e.match(/.{1,2}/g))===null||t===void 0?void 0:t.map(o=>parseInt(o,16)))!==null&&r!==void 0?r:[])}function $a(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function La(e,t){let r=JSON.stringify({env:e}),o=Xr.x25519.utils.randomPrivateKey(),n=Xr.x25519.getPublicKey(o),s=Ba(t),i=Xr.x25519.getSharedSecret(o,s),a=await Jr.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=Jr.default.getRandomValues(new Uint8Array(12)),u=await Jr.default.subtle.encrypt({name:"AES-GCM",iv:l},a,new TextEncoder().encode(r)),f=new Uint8Array(n.length+l.length+u.byteLength);return f.set(n),f.set(l,n.length),f.set(new Uint8Array(u),n.length+l.length),$a(f)}});var On=W(Pt=>{"use strict";var Ra=Pt&&Pt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Pt,"__esModule",{value:!0});Pt.getComposeHash=Ha;var Ua=Ra(we("crypto"));function Yr(e){return e==null?e:Array.isArray(e)?e.map(Yr):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=Yr(o),t},{}):e}function za(e){let t={...e};return t.runner==="bash"&&"docker_compose_file"in t?delete t.docker_compose_file:t.runner==="docker-compose"&&"bash_script"in t&&delete t.bash_script,"pre_launch_script"in t&&!t.pre_launch_script&&delete t.pre_launch_script,t}function Fa(e){let t=Yr(e);return JSON.stringify(t,(r,o)=>typeof o=="number"&&(isNaN(o)||!isFinite(o))?null:o)}function Ha(e,t=!1){t&&(e=za(e));let r=Fa(e);return Ua.default.createHash("sha256").update(r,"utf8").digest("hex")}});var as=W(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.toBig=y.shrSL=y.shrSH=y.rotrSL=y.rotrSH=y.rotrBL=y.rotrBH=y.rotr32L=y.rotr32H=y.rotlSL=y.rotlSH=y.rotlBL=y.rotlBH=y.add5L=y.add5H=y.add4L=y.add4H=y.add3L=y.add3H=void 0;y.add=es;y.fromBig=eo;y.split=jn;var hr=BigInt(2**32-1),Qr=BigInt(32);function eo(e,t=!1){return t?{h:Number(e&hr),l:Number(e>>Qr&hr)}:{h:Number(e>>Qr&hr)|0,l:Number(e&hr)|0}}function jn(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=eo(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var Nn=(e,t)=>BigInt(e>>>0)<<Qr|BigInt(t>>>0);y.toBig=Nn;var Mn=(e,t,r)=>e>>>r;y.shrSH=Mn;var Gn=(e,t,r)=>e<<32-r|t>>>r;y.shrSL=Gn;var Dn=(e,t,r)=>e>>>r|t<<32-r;y.rotrSH=Dn;var qn=(e,t,r)=>e<<32-r|t>>>r;y.rotrSL=qn;var Vn=(e,t,r)=>e<<64-r|t>>>r-32;y.rotrBH=Vn;var Kn=(e,t,r)=>e>>>r-32|t<<64-r;y.rotrBL=Kn;var Wn=(e,t)=>t;y.rotr32H=Wn;var Xn=(e,t)=>e;y.rotr32L=Xn;var Jn=(e,t,r)=>e<<r|t>>>32-r;y.rotlSH=Jn;var Zn=(e,t,r)=>t<<r|e>>>32-r;y.rotlSL=Zn;var Yn=(e,t,r)=>t<<r-32|e>>>64-r;y.rotlBH=Yn;var Qn=(e,t,r)=>e<<r-32|t>>>64-r;y.rotlBL=Qn;function es(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/2**32|0)|0,l:n|0}}var ts=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);y.add3L=ts;var rs=(e,t,r,o)=>t+r+o+(e/2**32|0)|0;y.add3H=rs;var os=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0);y.add4L=os;var ns=(e,t,r,o,n)=>t+r+o+n+(e/2**32|0)|0;y.add4H=ns;var ss=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0);y.add5L=ss;var is=(e,t,r,o,n,s)=>t+r+o+n+s+(e/2**32|0)|0;y.add5H=is;var Oa={fromBig:eo,split:jn,toBig:Nn,shrSH:Mn,shrSL:Gn,rotrSH:Dn,rotrSL:qn,rotrBH:Vn,rotrBL:Kn,rotr32H:Wn,rotr32L:Xn,rotlSH:Jn,rotlSL:Zn,rotlBH:Yn,rotlBL:Qn,add:es,add3L:ts,add3H:rs,add4L:os,add4H:ns,add5H:is,add5L:ss};y.default=Oa});var cs=W(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.crypto=void 0;var Le=we("crypto");xr.crypto=Le&&typeof Le=="object"&&"webcrypto"in Le?Le.webcrypto:Le&&typeof Le=="object"&&"randomBytes"in Le?Le:void 0});var xs=W(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.wrapXOFConstructorWithOpts=x.wrapConstructorWithOpts=x.wrapConstructor=x.Hash=x.nextTick=x.swap32IfBE=x.byteSwapIfBE=x.swap8IfBE=x.isLE=void 0;x.isBytes=ps;x.anumber=to;x.abytes=at;x.ahash=ja;x.aexists=Na;x.aoutput=Ma;x.u8=Ga;x.u32=Da;x.clean=qa;x.createView=Va;x.rotr=Ka;x.rotl=Wa;x.byteSwap=oo;x.byteSwap32=us;x.bytesToHex=Ja;x.hexToBytes=Za;x.asyncLoop=Qa;x.utf8ToBytes=no;x.bytesToUtf8=ec;x.toBytes=gr;x.kdfInputToBytes=tc;x.concatBytes=rc;x.checkOpts=oc;x.createHasher=ms;x.createOptHasher=ds;x.createXOFer=hs;x.randomBytes=nc;var it=cs();function ps(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function to(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function at(e,...t){if(!ps(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ja(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");to(e.outputLen),to(e.blockLen)}function Na(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ma(e,t){at(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ga(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Da(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function qa(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Va(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ka(e,t){return e<<32-t|e>>>t}function Wa(e,t){return e<<t|e>>>32-t>>>0}x.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function oo(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}x.swap8IfBE=x.isLE?e=>e:e=>oo(e);x.byteSwapIfBE=x.swap8IfBE;function us(e){for(let t=0;t<e.length;t++)e[t]=oo(e[t]);return e}x.swap32IfBE=x.isLE?e=>e:us;var fs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Xa=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ja(e){if(at(e),fs)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Xa[e[r]];return t}var Te={_0:48,_9:57,A:65,F:70,a:97,f:102};function ls(e){if(e>=Te._0&&e<=Te._9)return e-Te._0;if(e>=Te.A&&e<=Te.F)return e-(Te.A-10);if(e>=Te.a&&e<=Te.f)return e-(Te.a-10)}function Za(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(fs)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){let i=ls(e.charCodeAt(s)),a=ls(e.charCodeAt(s+1));if(i===void 0||a===void 0){let l=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+s)}o[n]=i*16+a}return o}var Ya=async()=>{};x.nextTick=Ya;async function Qa(e,t,r){let o=Date.now();for(let n=0;n<e;n++){r(n);let s=Date.now()-o;s>=0&&s<t||(await(0,x.nextTick)(),o+=s)}}function no(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function ec(e){return new TextDecoder().decode(e)}function gr(e){return typeof e=="string"&&(e=no(e)),at(e),e}function tc(e){return typeof e=="string"&&(e=no(e)),at(e),e}function rc(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];at(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let s=e[o];r.set(s,n),n+=s.length}return r}function oc(e,t){if(t!==void 0&&{}.toString.call(t)!=="[object Object]")throw new Error("options should be object or undefined");return Object.assign(e,t)}var ro=class{};x.Hash=ro;function ms(e){let t=o=>e().update(gr(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function ds(e){let t=(o,n)=>e(n).update(gr(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}function hs(e){let t=(o,n)=>e(n).update(gr(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}x.wrapConstructor=ms;x.wrapConstructorWithOpts=ds;x.wrapXOFConstructorWithOpts=hs;function nc(e=32){if(it.crypto&&typeof it.crypto.getRandomValues=="function")return it.crypto.getRandomValues(new Uint8Array(e));if(it.crypto&&typeof it.crypto.randomBytes=="function")return Uint8Array.from(it.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var Ts=W(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.shake256=A.shake128=A.keccak_512=A.keccak_384=A.keccak_256=A.keccak_224=A.sha3_512=A.sha3_384=A.sha3_256=A.sha3_224=A.Keccak=void 0;A.keccakP=Cs;var $t=as(),M=xs(),sc=BigInt(0),Bt=BigInt(1),ic=BigInt(2),ac=BigInt(7),cc=BigInt(256),lc=BigInt(113),ys=[],vs=[],ws=[];for(let e=0,t=Bt,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],ys.push(2*(5*o+r)),vs.push((e+1)*(e+2)/2%64);let n=sc;for(let s=0;s<7;s++)t=(t<<Bt^(t>>ac)*lc)%cc,t&ic&&(n^=Bt<<(Bt<<BigInt(s))-Bt);ws.push(n)}var _s=(0,$t.split)(ws,!0),pc=_s[0],uc=_s[1],gs=(e,t,r)=>r>32?(0,$t.rotlBH)(e,t,r):(0,$t.rotlSH)(e,t,r),bs=(e,t,r)=>r>32?(0,$t.rotlBL)(e,t,r):(0,$t.rotlSL)(e,t,r);function Cs(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let i=0;i<10;i++)r[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){let a=(i+8)%10,l=(i+2)%10,u=r[l],f=r[l+1],p=gs(u,f,1)^r[a],d=bs(u,f,1)^r[a+1];for(let h=0;h<50;h+=10)e[i+h]^=p,e[i+h+1]^=d}let n=e[2],s=e[3];for(let i=0;i<24;i++){let a=vs[i],l=gs(n,s,a),u=bs(n,s,a),f=ys[i];n=e[f],s=e[f+1],e[f]=l,e[f+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)r[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=pc[o],e[1]^=uc[o]}(0,M.clean)(r)}var Lt=class e extends M.Hash{constructor(t,r,o,n=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=r,this.outputLen=o,this.enableXOF=n,this.rounds=s,(0,M.anumber)(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,M.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,M.swap32IfBE)(this.state32),Cs(this.state32,this.rounds),(0,M.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(t){(0,M.aexists)(this),t=(0,M.toBytes)(t),(0,M.abytes)(t);let{blockLen:r,state:o}=this,n=t.length;for(let s=0;s<n;){let i=Math.min(r-this.pos,n-s);for(let a=0;a<i;a++)o[this.pos++]^=t[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:r,pos:o,blockLen:n}=this;t[o]^=r,(r&128)!==0&&o===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){(0,M.aexists)(this,!1),(0,M.abytes)(t),this.finish();let r=this.state,{blockLen:o}=this;for(let n=0,s=t.length;n<s;){this.posOut>=o&&this.keccak();let i=Math.min(o-this.posOut,s-n);t.set(r.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return(0,M.anumber)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,M.aoutput)(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,(0,M.clean)(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new e(r,o,n,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=o,t.outputLen=n,t.enableXOF=i,t.destroyed=this.destroyed,t}};A.Keccak=Lt;var Re=(e,t,r)=>(0,M.createHasher)(()=>new Lt(t,e,r));A.sha3_224=Re(6,144,224/8);A.sha3_256=Re(6,136,256/8);A.sha3_384=Re(6,104,384/8);A.sha3_512=Re(6,72,512/8);A.keccak_224=Re(1,144,224/8);A.keccak_256=Re(1,136,256/8);A.keccak_384=Re(1,104,384/8);A.keccak_512=Re(1,72,512/8);var ks=(e,t,r)=>(0,M.createXOFer)((o={})=>new Lt(t,e,o.dkLen===void 0?r:o.dkLen,!0));A.shake128=ks(31,168,128/8);A.shake256=ks(31,136,256/8)});var Es=W(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.verifyEnvEncryptPublicKey=dc;var fc=Ts(),mc=we("@noble/curves/secp256k1");function dc(e,t,r){if(t.length!==65)return null;let o=Buffer.from("dstack-env-encrypt-pubkey","utf8"),n=r;r.startsWith("0x")&&(n=r.slice(2));let s=Buffer.from(n,"hex"),i=Buffer.from(":","utf8"),a=Buffer.concat([o,i,s,Buffer.from(e)]),l=(0,fc.keccak_256)(a);try{let u=t.slice(0,32),f=t.slice(32,64),p=t[64],d=new Uint8Array(64);d.set(u,0),d.set(f,32);let h=mc.secp256k1.Signature.fromCompact(d).addRecoveryBit(p).recoverPublicKey(l);return"0x"+Buffer.from(h.toRawBytes(!0)).toString("hex")}catch(u){return console.error("signature verification failed:",u),null}}});var Bs=ht(Io(),1);import{ofetch as hc}from"ofetch";function Ao(e){return{all:e=e||new Map,on:function(t,r){var o=e.get(t);o?o.push(r):e.set(t,[r])},off:function(t,r){var o=e.get(t);o&&(r?o.splice(o.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var o=e.get(t);o&&o.slice().map(function(n){n(r)}),(o=e.get("*"))&&o.slice().map(function(n){n(t,r)})}}}import{z as H}from"zod";import{z as Ue}from"zod";import{z as w}from"zod";import{z as ze}from"zod";function Ne(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}Mt();Me();Mt();var Br={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function vt(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?De(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?De(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Br[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(r.authorizationList=Di(e.authorizationList)),r.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof r.v=="bigint"){if(r.v===0n||r.v===27n)return 0;if(r.v===1n||r.v===28n)return 1;if(r.v>=35n)return r.v%2n===0n?1:0}})(),r.type==="legacy"&&(delete r.accessList,delete r.maxFeePerBlobGas,delete r.maxFeePerGas,delete r.maxPriorityFeePerGas,delete r.yParity),r.type==="eip2930"&&(delete r.maxFeePerBlobGas,delete r.maxFeePerGas,delete r.maxPriorityFeePerGas),r.type==="eip1559"&&delete r.maxFeePerBlobGas,r}var Ro=et("transaction",vt);function Di(e){return e.map(t=>({address:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function qi(e,t){let r=(e.transactions??[]).map(o=>typeof o=="string"?o:vt(o));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:r,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}var Uo=et("block",qi);function zo(e,{args:t,eventName:r}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...r?{args:t,eventName:r}:{}}}Me();Mt();var Vi={"0x0":"reverted","0x1":"success"};function Ki(e,t){let r={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(o=>zo(o)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?De(e.transactionIndex):null,status:e.status?Vi[e.status]:null,type:e.type?Br[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var Fo=et("transactionReceipt",Ki);oe();Lr();Pe();se();function Ce(e,t="hex"){let r=jo(e),o=Vt(new Uint8Array(r.length));return r.encode(o),t==="hex"?J(o.bytes):o.bytes}function jo(e){return Array.isArray(e)?Xi(e.map(t=>jo(t))):Ji(e)}function Xi(e){let t=e.reduce((n,s)=>n+s.length,0),r=No(t);return{length:t<=55?1+t:1+r+t,encode(n){t<=55?n.pushByte(192+t):(n.pushByte(247+r),r===1?n.pushUint8(t):r===2?n.pushUint16(t):r===3?n.pushUint24(t):n.pushUint32(t));for(let{encode:s}of e)s(n)}}}function Ji(e){let t=typeof e=="string"?pe(e):e,r=No(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length,encode(n){t.length===1&&t[0]<128?n.pushBytes(t):t.length<=55?(n.pushByte(128+t.length),n.pushBytes(t)):(n.pushByte(183+r),r===1?n.pushUint8(t.length):r===2?n.pushUint16(t.length):r===3?n.pushUint24(t.length):n.pushUint32(t.length),n.pushBytes(t))}}}function No(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new b("Length is too large.")}Jt();se();function Ko(e){if(!e||e.length===0)return[];let t=[];for(let r of e){let{chainId:o,nonce:n,...s}=r,i=r.address;t.push([o?le(o):"0x",i,n?le(n):"0x",...tt({},s)])}return t}Pe();se();function Zt(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),o=typeof e.blobs[0]=="string"?e.blobs.map(s=>pe(s)):e.blobs,n=[];for(let s of o)n.push(Uint8Array.from(t.blobToKzgCommitment(s)));return r==="bytes"?n:n.map(s=>J(s))}Pe();se();function Yt(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),o=typeof e.blobs[0]=="string"?e.blobs.map(i=>pe(i)):e.blobs,n=typeof e.commitments[0]=="string"?e.commitments.map(i=>pe(i)):e.commitments,s=[];for(let i=0;i<o.length;i++){let a=o[i],l=n[i];s.push(Uint8Array.from(t.computeBlobKzgProof(a,l)))}return r==="bytes"?s:s.map(i=>J(i))}se();rr();function oa(e,t,r,o){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,o);let n=BigInt(32),s=BigInt(4294967295),i=Number(r>>n&s),a=Number(r&s),l=o?4:0,u=o?0:4;e.setUint32(t+l,i,o),e.setUint32(t+u,a,o)}function Xo(e,t,r){return e&t^~e&r}function Jo(e,t,r){return e&t^e&r^t&r}var or=class extends rt{constructor(t,r,o,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(t),this.view=er(this.buffer)}update(t){ot(this),t=Ct(t),Ve(t);let{view:r,buffer:o,blockLen:n}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(n-this.pos,s-i);if(a===n){let l=er(t);for(;n<=s-i;i+=n)this.process(l,i);continue}o.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ot(this),Qt(t,this),this.finished=!0;let{buffer:r,view:o,blockLen:n,isLE:s}=this,{pos:i}=this;r[i++]=128,Be(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let p=i;p<n;p++)r[p]=0;oa(o,n-8,BigInt(this.length*8),s),this.process(o,0);let a=er(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=l/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<u;p++)a.setUint32(4*p,f[p],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let o=t.slice(0,r);return this.destroy(),o}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:o,length:n,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=n,t.pos=a,n%r&&t.buffer.set(o),t}clone(){return this._cloneInto()}},ke=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);rr();var sa=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),$e=new Uint32Array(64),sr=class extends or{constructor(t=32){super(64,t,8,!1),this.A=ke[0]|0,this.B=ke[1]|0,this.C=ke[2]|0,this.D=ke[3]|0,this.E=ke[4]|0,this.F=ke[5]|0,this.G=ke[6]|0,this.H=ke[7]|0}get(){let{A:t,B:r,C:o,D:n,E:s,F:i,G:a,H:l}=this;return[t,r,o,n,s,i,a,l]}set(t,r,o,n,s,i,a,l){this.A=t|0,this.B=r|0,this.C=o|0,this.D=n|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=l|0}process(t,r){for(let p=0;p<16;p++,r+=4)$e[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let d=$e[p-15],h=$e[p-2],I=ue(d,7)^ue(d,18)^d>>>3,T=ue(h,17)^ue(h,19)^h>>>10;$e[p]=T+$e[p-7]+I+$e[p-16]|0}let{A:o,B:n,C:s,D:i,E:a,F:l,G:u,H:f}=this;for(let p=0;p<64;p++){let d=ue(a,6)^ue(a,11)^ue(a,25),h=f+d+Xo(a,l,u)+sa[p]+$e[p]|0,T=(ue(o,2)^ue(o,13)^ue(o,22))+Jo(o,n,s)|0;f=u,u=l,l=a,a=i+h|0,i=s,s=n,n=o,o=h+T|0}o=o+this.A|0,n=n+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,l=l+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(o,n,s,i,a,l,u,f)}roundClean(){Be($e)}destroy(){this.set(0,0,0,0,0,0,0,0),Be(this.buffer)}};var nn=tr(()=>new sr);var sn=nn;Qe();Pe();se();function an(e,t){let r=t||"hex",o=sn(de(e,{strict:!1})?Nt(e):e);return r==="bytes"?o:le(o)}function cn(e){let{commitment:t,version:r=1}=e,o=e.to??(typeof t=="string"?"hex":"bytes"),n=an(t,"bytes");return n.set([r],0),o==="bytes"?n:J(n)}function ln(e){let{commitments:t,version:r}=e,o=e.to??(typeof t[0]=="string"?"hex":"bytes"),n=[];for(let s of t)n.push(cn({commitment:s,to:o,version:r}));return n}oe();var ir=class extends b{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},nt=class extends b{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},ar=class extends b{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},cr=class extends b{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};Lr();xt();Pe();se();function pn(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?pe(e.data):e.data,o=ne(r);if(!o)throw new nt;if(o>761855)throw new ir({maxSize:761855,size:o});let n=[],s=!0,i=0;for(;s;){let a=Vt(new Uint8Array(131072)),l=0;for(;l<4096;){let u=r.slice(i,i+31);if(a.pushByte(0),a.pushBytes(u),u.length<31){a.pushByte(128),s=!1;break}l++,i+=31}n.push(a)}return t==="bytes"?n.map(a=>a.bytes):n.map(a=>J(a.bytes))}function un(e){let{data:t,kzg:r,to:o}=e,n=e.blobs??pn({data:t,to:o}),s=e.commitments??Zt({blobs:n,kzg:r,to:o}),i=e.proofs??Yt({blobs:n,commitments:s,kzg:r,to:o}),a=[];for(let l=0;l<n.length;l++)a.push({blob:n[l],commitment:s[l],proof:i[l]});return a}$r();$o();se();Ho();lr();oe();fn();mn();ur();xt();An();Me();function Pn(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:o}=r,n=r.address;if(!he(n))throw new ie({address:n});if(o<0)throw new Ke({chainId:o})}fr(e)}function Bn(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new nt;for(let r of t){let o=ne(r),n=De(En(r,0,1));if(o!==32)throw new ar({hash:r,size:o});if(n!==1)throw new cr({hash:r,version:n})}}fr(e)}function fr(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:o,to:n}=e;if(t<=0)throw new Ke({chainId:t});if(n&&!he(n))throw new ie({address:n});if(o&&o>Gt)throw new We({maxFeePerGas:o});if(r&&o&&r>o)throw new kt({maxFeePerGas:o,maxPriorityFeePerGas:r})}function $n(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(t<=0)throw new Ke({chainId:t});if(s&&!he(s))throw new ie({address:s});if(r||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(o&&o>Gt)throw new We({maxFeePerGas:o})}function Ln(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(s&&!he(s))throw new ie({address:s});if(typeof t<"u"&&t<=0)throw new Ke({chainId:t});if(r||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(o&&o>Gt)throw new We({maxFeePerGas:o})}Jt();function Rn(e){if(e.type)return e.type;if(typeof e.authorizationList<"u")return"eip7702";if(typeof e.blobs<"u"||typeof e.blobVersionedHashes<"u"||typeof e.maxFeePerBlobGas<"u"||typeof e.sidecars<"u")return"eip4844";if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")return"eip1559";if(typeof e.gasPrice<"u")return typeof e.accessList<"u"?"eip2930":"legacy";throw new Wt({transaction:e})}lr();Jt();ur();function Et(e){if(!e||e.length===0)return[];let t=[];for(let r=0;r<e.length;r++){let{address:o,storageKeys:n}=e[r];for(let s=0;s<n.length;s++)if(n[s].length-2!==64)throw new Xt({storageKey:n[s]});if(!he(o,{strict:!1}))throw new ie({address:o});t.push([o,n])}return t}function Un(e,t){let r=Rn(e);return r==="eip1559"?_a(e,t):r==="eip2930"?Ca(e,t):r==="eip4844"?wa(e,t):r==="eip7702"?va(e,t):ka(e,t)}function va(e,t){let{authorizationList:r,chainId:o,gas:n,nonce:s,to:i,value:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;Pn(e);let d=Et(f),h=Ko(r);return qe(["0x04",Ce([_(o),s?_(s):"0x",u?_(u):"0x",l?_(l):"0x",n?_(n):"0x",i??"0x",a?_(a):"0x",p??"0x",d,h,...tt(e,t)])])}function wa(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;Bn(e);let d=e.blobVersionedHashes,h=e.sidecars;if(e.blobs&&(typeof d>"u"||typeof h>"u")){let O=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(te=>J(te)),Q=e.kzg,ce=Zt({blobs:O,kzg:Q});if(typeof d>"u"&&(d=ln({commitments:ce})),typeof h>"u"){let te=Yt({blobs:O,commitments:ce,kzg:Q});h=un({blobs:O,commitments:ce,proofs:te})}}let I=Et(f),T=[_(r),n?_(n):"0x",u?_(u):"0x",l?_(l):"0x",o?_(o):"0x",s??"0x",i?_(i):"0x",p??"0x",I,a?_(a):"0x",d??[],...tt(e,t)],P=[],V=[],K=[];if(h)for(let O=0;O<h.length;O++){let{blob:Q,commitment:ce,proof:te}=h[O];P.push(Q),V.push(ce),K.push(te)}return qe(["0x03",h?Ce([T,P,V,K]):Ce(T)])}function _a(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:u,data:f}=e;fr(e);let p=Et(u),d=[_(r),n?_(n):"0x",l?_(l):"0x",a?_(a):"0x",o?_(o):"0x",s??"0x",i?_(i):"0x",f??"0x",p,...tt(e,t)];return qe(["0x02",Ce(d)])}function Ca(e,t){let{chainId:r,gas:o,data:n,nonce:s,to:i,value:a,accessList:l,gasPrice:u}=e;$n(e);let f=Et(l),p=[_(r),s?_(s):"0x",u?_(u):"0x",o?_(o):"0x",i??"0x",a?_(a):"0x",n??"0x",f,...tt(e,t)];return qe(["0x01",Ce(p)])}function ka(e,t){let{chainId:r=0,gas:o,data:n,nonce:s,to:i,value:a,gasPrice:l}=e;Ln(e);let u=[s?_(s):"0x",l?_(l):"0x",o?_(o):"0x",i??"0x",a?_(a):"0x",n??"0x"];if(t){let f=(()=>{if(t.v>=35n)return(t.v-35n)/2n>0?t.v:27n+(t.v===35n?0n:1n);if(r>0)return BigInt(r*2)+BigInt(35n+t.v-27n);let h=27n+(t.v===27n?0n:1n);if(t.v!==h)throw new Kt({v:t.v});return h})(),p=gt(t.r),d=gt(t.s);u=[...u,_(f),p==="0x00"?"0x":p,d==="0x00"?"0x":d]}else r>0&&(u=[...u,_(r),"0x","0x"]);return Ce(u)}function tt(e,t){let r=t??e,{v:o,yParity:n}=r;if(typeof r.r>"u")return[];if(typeof r.s>"u")return[];if(typeof o>"u"&&typeof n>"u")return[];let s=gt(r.r),i=gt(r.s);return[typeof n=="number"?n?_(1):"0x":o===0n?"0x":o===1n?_(1):o===27n?"0x":_(1),s==="0x00"?"0x":s,i==="0x00"?"0x":i]}var zn={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};Me();var Fn={block:Uo({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let o=vt(r);return o.typeHex==="0x7e"&&(o.isSystemTx=r.isSystemTx,o.mint=r.mint?Ge(r.mint):void 0,o.sourceHash=r.sourceHash,o.type="deposit"),o}),stateRoot:e.stateRoot}}}),transaction:Ro({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Ge(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Fo({format(e){return{l1GasPrice:e.l1GasPrice?Ge(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Ge(e.l1GasUsed):null,l1Fee:e.l1Fee?Ge(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};lr();ur();$r();se();function Ta(e,t){return Sa(e)?Ea(e):Un(e,t)}var Hn={transaction:Ta};function Ea(e){Ia(e);let{sourceHash:t,data:r,from:o,gas:n,isSystemTx:s,mint:i,to:a,value:l}=e,u=[t,o,a??"0x",i?le(i):"0x",l?le(l):"0x",n?le(n):"0x",s?"0x1":"0x",r??"0x"];return qe(["0x7e",Ce(u)])}function Sa(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function Ia(e){let{from:t,to:r}=e;if(t&&!he(t))throw new ie({address:t});if(r&&!he(r))throw new ie({address:r})}var Wr={blockTime:2e3,contracts:zn,formatters:Fn,serializers:Hn};var mr=Ne({id:31337,name:"Anvil",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["http://127.0.0.1:8545"],webSocket:["ws://127.0.0.1:8545"]}}});var St=1,It=Ne({...Wr,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...Wr.contracts,disputeGameFactory:{[St]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[St]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[St]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[St]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:St}),Aa=Ne({...It,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var dr=Ne({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:12e3,rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:23085558},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}});import{z as L}from"zod";import{z as ee}from"zod";import{z as m}from"zod";import{z as lt}from"zod";import{z as ae}from"zod";import{z as v}from"zod";import{z as C}from"zod";import{z as D}from"zod";import yl from"crypto";import{z as be}from"zod";import{z as fe}from"zod";import{z as j}from"zod";import{z as Z}from"zod";import{z as Y}from"zod";import{z as Zl}from"zod";import{z as Is}from"zod";import{z as ye}from"zod";import{z as ft}from"zod";import{z as Xe}from"zod";import{z as Tp}from"zod";import{z as Ap}from"zod";import{z as S}from"zod";import{z as ge}from"zod";import{z as Dp}from"zod";import{z as $}from"zod";import{z as g}from"zod";import{z as ut}from"zod";import{z as As}from"zod";import{z as G}from"zod";import{z as qs}from"zod";import{z as xe}from"zod";import{z as U}from"zod";var ig=ht(Zr(),1);import{z as B}from"zod";var Su=ht(Zr(),1),Iu=ht(On(),1),Au=ht(Es(),1);import{z as pt}from"zod";var xc=H.object({detail:H.union([H.string(),H.array(H.object({msg:H.string(),type:H.string().optional(),ctx:H.record(H.unknown()).optional(),loc:H.array(H.union([H.string(),H.number()])).optional(),input:H.unknown().optional()}).passthrough()),H.record(H.unknown())]).optional(),type:H.string().optional(),code:H.string().optional()}),ve=class extends Error{constructor(e,t){super(e),this.name=this.constructor.name,this.status=t.status,this.statusText=t.statusText,this.detail=t.detail,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},io=class br extends ve{constructor(t,r){super(t,{status:r?.status??0,statusText:r?.statusText??"Unknown Error",detail:r?.detail||t}),this.name="RequestError",this.isRequestError=!0,this.data=r?.data,this.request=r?.request,this.response=r?.response,this.code=r?.code,this.type=r?.type}static fromFetchError(t){let r=xc.safeParse(t.data);return r.success?new br(t.message,{status:t.status??void 0,statusText:t.statusText??void 0,data:t.data,request:t.request??void 0,response:t.response??void 0,detail:r.data.detail,code:r.data.code??void 0,type:r.data.type??void 0}):new br(t.message,{status:t.status??void 0,statusText:t.statusText??void 0,data:t.data,request:t.request??void 0,response:t.response??void 0,detail:t.data?.detail||"Unknown API error",code:t.status?.toString()??void 0})}static fromError(t,r){return new br(t.message,{request:r??void 0,detail:t.message})}},gc=class extends ve{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},bc=class extends ve{constructor(){super(...arguments),this.isAuthError=!0}},$s=class extends ve{constructor(){super(...arguments),this.isBusinessError=!0}},yc=class extends ve{constructor(){super(...arguments),this.isServerError=!0}},vc=class extends ve{constructor(){super(...arguments),this.isUnknownError=!0}};function wc(e){if(!e||!Array.isArray(e))return"unknown";let t=e.filter(r=>typeof r=="string"?!["body","query","path","header"].includes(r):!0);return t.length>0?t.join("."):"unknown"}function Ls(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((n,s)=>{let i=wc(n.loc),a=i;return i==="unknown"&&n.type&&(a=n.type==="missing"?"required field":n.type),{field:a,message:n.msg,type:n.type,context:n.ctx}}),r=t.length,o=r===1?`Validation failed: ${t[0].message}`:`Validation failed (${r} issue${r>1?"s":""})`;return{errors:t,message:o}}function _c(e){return e===422?"validation":e===401||e===403?"auth":e>=400&&e<500?"business":e>=500?"server":"unknown"}function Cc(e,t,r){if(e===422&&Array.isArray(t)){let{message:o}=Ls(t);return o}if(typeof t=="string")return t;if(t&&typeof t=="object"&&"message"in t){let o=t.message;if(typeof o=="string")return o}return r}function kc(e){let t=e.status??0,r=e.statusText??"Unknown Error",o=e.detail,n=Ec(o);if(n)return new Tc(n.message,{status:t,statusText:r,detail:o,errorCode:n.error_code,structuredDetails:n.details,suggestions:n.suggestions,links:n.links});let s=_c(t),i=Cc(t,o,e.message),a={status:t,statusText:r,detail:o};if(s==="validation"&&Array.isArray(o)){let{errors:l}=Ls(o);return new gc(i,{...a,validationErrors:l})}return s==="auth"?new bc(i,a):s==="business"?new $s(i,a):s==="server"?new yc(i,a):new vc(i,a)}var Tc=class extends $s{constructor(e,t){super(e,t),this.isResourceError=!0,this.errorCode=t.errorCode,this.structuredDetails=t.structuredDetails,this.suggestions=t.suggestions,this.links=t.links}};function Ec(e){if(!e||typeof e!="object")return null;let t=e;return t.error_code&&typeof t.error_code=="string"&&t.message&&typeof t.message=="string"?{error_code:t.error_code,message:t.message,details:t.details,suggestions:t.suggestions,links:t.links}:null}var ao=["2025-05-31","2025-10-28"],ct=(0,Bs.default)("phala::api-client");function Sc(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
12
- `)}function Ic(e){return e?` -d '${(typeof e=="string"?e:JSON.stringify(e,null,2)).replace(/'/g,"\\'")}'`:""}function Ss(e,t,r,o){let n=[];r.forEach((a,l)=>{n.push(`${l}: ${a}`)});let s=n.join(`
4
+ `+s),e.push(n+"m+"+Ot.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=$i()+t+" "+e[0]}function $i(){return F.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Li(...e){return process.stderr.write(Ht.formatWithOptions(F.inspectOpts,...e)+`
5
+ `)}function Ri(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function Ui(){return process.env.DEBUG}function zi(e){e.inspectOpts={};let t=Object.keys(F.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=F.inspectOpts[t[r]]}Ot.exports=_r()(F);var{formatters:Eo}=Ot.exports;Eo.o=function(e){return this.inspectOpts.colors=this.useColors,Ht.inspect(e,this.inspectOpts).split(`
6
+ `).map(t=>t.trim()).join(" ")};Eo.O=function(e){return this.inspectOpts.colors=this.useColors,Ht.inspect(e,this.inspectOpts)}});var Ao=X((Ju,Tr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Tr.exports=wo():Tr.exports=Io()});var Sr,Bo=S(()=>{Sr="2.38.6"});function $o(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?$o(e.cause,t):t?null:e}var Er,b,ne=S(()=>{Bo();Er={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${Sr}`},b=class e extends Error{constructor(t,r={}){let o=r.cause instanceof e?r.cause.details:r.cause?.message?r.cause.message:r.details,n=r.cause instanceof e&&r.cause.docsPath||r.docsPath,s=Er.getDocsUrl?.({...r,docsPath:n}),i=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...o?[`Details: ${o}`]:[],...Er.version?[`Version: ${Er.version}`]:[]].join(`
7
+ `);super(i,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=o,this.docsPath=n,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=Sr}walk(t){return $o(this,t)}}});var jt,Nt,Ir=S(()=>{ne();jt=class extends b{constructor({max:t,min:r,signed:o,size:n,value:s}){super(`Number "${s}" is not in safe ${n?`${n*8}-bit ${o?"signed":"unsigned"} `:""}integer range ${t?`(${r} to ${t})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}},Nt=class extends b{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function he(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var et=S(()=>{});function se(e){return he(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var gt=S(()=>{et()});function bt(e,{dir:t="left"}={}){let r=typeof e=="string"?e.replace("0x",""):e,o=0;for(let n=0;n<r.length-1&&r[t==="left"?n:r.length-n-1].toString()==="0";n++)o++;return r=t==="left"?r.slice(o):r.slice(0,r.length-o),typeof e=="string"?(r.length===1&&t==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}var Lo=S(()=>{});var yt,vt,Ar=S(()=>{ne();yt=class extends b{constructor({offset:t,position:r,size:o}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${o}).`,{name:"SliceOffsetOutOfBoundsError"})}},vt=class extends b{constructor({size:t,targetSize:r,type:o}){super(`${o.charAt(0).toUpperCase()}${o.slice(1).toLowerCase()} size (${t}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}});function Ae(e,{dir:t,size:r=32}={}){return typeof e=="string"?Fi(e,{dir:t,size:r}):Hi(e,{dir:t,size:r})}function Fi(e,{dir:t,size:r=32}={}){if(r===null)return e;let o=e.replace("0x","");if(o.length>r*2)throw new vt({size:Math.ceil(o.length/2),targetSize:r,type:"hex"});return`0x${o[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function Hi(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new vt({size:e.length,targetSize:r,type:"bytes"});let o=new Uint8Array(r);for(let n=0;n<r;n++){let s=t==="right";o[s?n:r-n-1]=e[s?n:e.length-n-1]}return o}var Pr=S(()=>{Ar()});function pe(e,t={}){return typeof e=="number"||typeof e=="bigint"?_(e,t):typeof e=="string"?Mi(e,t):typeof e=="boolean"?ji(e,t):Z(e,t)}function ji(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(Pe(r,{size:t.size}),Ae(r,{size:t.size})):r}function Z(e,t={}){let r="";for(let n=0;n<e.length;n++)r+=Oi[e[n]];let o=`0x${r}`;return typeof t.size=="number"?(Pe(o,{size:t.size}),Ae(o,{dir:"right",size:t.size})):o}function _(e,t={}){let{signed:r,size:o}=t,n=BigInt(e),s;o?r?s=(1n<<BigInt(o)*8n-1n)-1n:s=2n**(BigInt(o)*8n)-1n:typeof e=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));let i=typeof s=="bigint"&&r?-s-1n:0;if(s&&n>s||n<i){let l=typeof e=="bigint"?"n":"";throw new jt({max:s?`${s}${l}`:void 0,min:`${i}${l}`,signed:r,size:o,value:`${e}${l}`})}let a=`0x${(r&&n<0?(1n<<BigInt(o*8))+BigInt(n):n).toString(16)}`;return o?Ae(a,{size:o}):a}function Mi(e,t={}){let r=Ni.encode(e);return Z(r,t)}var Oi,Ni,ie=S(()=>{Ir();Pr();Ge();Oi=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Ni=new TextEncoder});function Mt(e,t={}){return typeof e=="number"||typeof e=="bigint"?qi(e,t):typeof e=="boolean"?Di(e,t):he(e)?ue(e,t):Br(e,t)}function Di(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(Pe(r,{size:t.size}),Ae(r,{size:t.size})):r}function Ro(e){if(e>=Ce.zero&&e<=Ce.nine)return e-Ce.zero;if(e>=Ce.A&&e<=Ce.F)return e-(Ce.A-10);if(e>=Ce.a&&e<=Ce.f)return e-(Ce.a-10)}function ue(e,t={}){let r=e;t.size&&(Pe(r,{size:t.size}),r=Ae(r,{dir:"right",size:t.size}));let o=r.slice(2);o.length%2&&(o=`0${o}`);let n=o.length/2,s=new Uint8Array(n);for(let i=0,a=0;i<n;i++){let l=Ro(o.charCodeAt(a++)),f=Ro(o.charCodeAt(a++));if(l===void 0||f===void 0)throw new b(`Invalid byte sequence ("${o[a-2]}${o[a-1]}" in "${o}").`);s[i]=l*16+f}return s}function qi(e,t){let r=_(e,t);return ue(r)}function Br(e,t={}){let r=Gi.encode(e);return typeof t.size=="number"?(Pe(r,{size:t.size}),Ae(r,{dir:"right",size:t.size})):r}var Gi,Ce,Be=S(()=>{ne();et();Pr();Ge();ie();Gi=new TextEncoder;Ce={zero:48,nine:57,A:65,F:70,a:97,f:102}});function Pe(e,{size:t}){if(se(e)>t)throw new Nt({givenSize:se(e),maxSize:t})}function De(e,t={}){let{signed:r}=t;t.size&&Pe(e,{size:t.size});let o=BigInt(e);if(!r)return o;let n=(e.length-2)/2,s=(1n<<BigInt(n)*8n-1n)-1n;return o<=s?o:o-BigInt(`0x${"f".padStart(n*2,"f")}`)-1n}function qe(e,t={}){return Number(De(e,t))}var Ge=S(()=>{Ir();gt()});function tt(e,t){return({exclude:r,format:o})=>({exclude:r,format:(n,s)=>{let i=t(n,s);if(r)for(let a of r)delete i[a];return{...i,...o(n,s)}},type:e})}var Gt=S(()=>{});var jf,Nf,Mf,Gf,Df,qf,Vf,Kf,Wf,Xf,Jf,Zf,Yf,Qf,em,tm,rm,om,nm,sm,im,am,cm,lm,pm,um,fm,mm,dm,hm,xm,gm,bm,ym,vm,wm,_m,Cm,km,Tm,Sm,Em,Im,Am,Pm,Bm,$m,Lm,Rm,Um,zm,Fm,Hm,Om,jm,Nm,Mm,Gm,Dm,qm,Vm,Km,Wm,Xm,Jm,Zm,Ym,Qm,ed,td,rd,od,nd,sd,id,ad,cd,ld,pd,ud,fd,md,dd,hd,xd,gd,bd,yd,vd,wd,_d,Cd,kd,Td,Sd,Dt,Oo=S(()=>{jf=2n**(8n-1n)-1n,Nf=2n**(16n-1n)-1n,Mf=2n**(24n-1n)-1n,Gf=2n**(32n-1n)-1n,Df=2n**(40n-1n)-1n,qf=2n**(48n-1n)-1n,Vf=2n**(56n-1n)-1n,Kf=2n**(64n-1n)-1n,Wf=2n**(72n-1n)-1n,Xf=2n**(80n-1n)-1n,Jf=2n**(88n-1n)-1n,Zf=2n**(96n-1n)-1n,Yf=2n**(104n-1n)-1n,Qf=2n**(112n-1n)-1n,em=2n**(120n-1n)-1n,tm=2n**(128n-1n)-1n,rm=2n**(136n-1n)-1n,om=2n**(144n-1n)-1n,nm=2n**(152n-1n)-1n,sm=2n**(160n-1n)-1n,im=2n**(168n-1n)-1n,am=2n**(176n-1n)-1n,cm=2n**(184n-1n)-1n,lm=2n**(192n-1n)-1n,pm=2n**(200n-1n)-1n,um=2n**(208n-1n)-1n,fm=2n**(216n-1n)-1n,mm=2n**(224n-1n)-1n,dm=2n**(232n-1n)-1n,hm=2n**(240n-1n)-1n,xm=2n**(248n-1n)-1n,gm=2n**(256n-1n)-1n,bm=-(2n**(8n-1n)),ym=-(2n**(16n-1n)),vm=-(2n**(24n-1n)),wm=-(2n**(32n-1n)),_m=-(2n**(40n-1n)),Cm=-(2n**(48n-1n)),km=-(2n**(56n-1n)),Tm=-(2n**(64n-1n)),Sm=-(2n**(72n-1n)),Em=-(2n**(80n-1n)),Im=-(2n**(88n-1n)),Am=-(2n**(96n-1n)),Pm=-(2n**(104n-1n)),Bm=-(2n**(112n-1n)),$m=-(2n**(120n-1n)),Lm=-(2n**(128n-1n)),Rm=-(2n**(136n-1n)),Um=-(2n**(144n-1n)),zm=-(2n**(152n-1n)),Fm=-(2n**(160n-1n)),Hm=-(2n**(168n-1n)),Om=-(2n**(176n-1n)),jm=-(2n**(184n-1n)),Nm=-(2n**(192n-1n)),Mm=-(2n**(200n-1n)),Gm=-(2n**(208n-1n)),Dm=-(2n**(216n-1n)),qm=-(2n**(224n-1n)),Vm=-(2n**(232n-1n)),Km=-(2n**(240n-1n)),Wm=-(2n**(248n-1n)),Xm=-(2n**(256n-1n)),Jm=2n**8n-1n,Zm=2n**16n-1n,Ym=2n**24n-1n,Qm=2n**32n-1n,ed=2n**40n-1n,td=2n**48n-1n,rd=2n**56n-1n,od=2n**64n-1n,nd=2n**72n-1n,sd=2n**80n-1n,id=2n**88n-1n,ad=2n**96n-1n,cd=2n**104n-1n,ld=2n**112n-1n,pd=2n**120n-1n,ud=2n**128n-1n,fd=2n**136n-1n,md=2n**144n-1n,dd=2n**152n-1n,hd=2n**160n-1n,xd=2n**168n-1n,gd=2n**176n-1n,bd=2n**184n-1n,yd=2n**192n-1n,vd=2n**200n-1n,wd=2n**208n-1n,_d=2n**216n-1n,Cd=2n**224n-1n,kd=2n**232n-1n,Td=2n**240n-1n,Sd=2n**248n-1n,Dt=2n**256n-1n});function Ve(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var Lr=S(()=>{});var _t,qt,Vt,jo=S(()=>{ne();_t=class extends b{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},qt=class extends b{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},Vt=class extends b{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function Kt(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(Ji);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var Ji,Rr=S(()=>{jo();Ji={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new Vt({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 _t({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 _t({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 Go,Do=S(()=>{Go={ether:-9,wei:9}});function qo(e,t){let r=e.toString(),o=r.startsWith("-");o&&(r=r.slice(1)),r=r.padStart(t,"0");let[n,s]=[r.slice(0,r.length-t),r.slice(r.length-t)];return s=s.replace(/(0+)$/,""),`${o?"-":""}${n||"0"}${s?`.${s}`:""}`}var Vo=S(()=>{});function Ct(e,t="wei"){return qo(e,Go[t])}var Ko=S(()=>{Do();Vo()});function Qi(e){let t=Object.entries(e).map(([o,n])=>n===void 0||n===!1?null:[o,n]).filter(Boolean),r=t.reduce((o,[n])=>Math.max(o,n.length),0);return t.map(([o,n])=>` ${`${o}:`.padEnd(r+1)} ${n}`).join(`
8
+ `)}var Wt,Xt,Jt,Zt=S(()=>{ne();Wt=class extends b{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}},Xt=class extends b{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Qi(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"})}},Jt=class extends b{constructor({storageKey:t}){super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}});function ea(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ur(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ke(e,...t){if(!ea(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 nt(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 er(e,t){Ke(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Xo(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function $e(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function tr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function fe(e,t){return e<<32-t|e>>>t}function ra(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function oa(e){for(let t=0;t<e.length;t++)e[t]=ra(e[t]);return e}function na(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function kt(e){return typeof e=="string"&&(e=na(e)),Ke(e),e}function rr(e){let t=o=>e().update(kt(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}var ta,zr,ot,or=S(()=>{ta=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;zr=ta?e=>e:oa;ot=class{}});function ia(e,t=!1){return t?{h:Number(e&sr),l:Number(e>>Yo&sr)}:{h:Number(e>>Yo&sr)|0,l:Number(e&sr)|0}}function Qo(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=ia(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var sr,Yo,en,tn,rn,on,nn=S(()=>{sr=BigInt(4294967295),Yo=BigInt(32);en=(e,t,r)=>e<<r|t>>>32-r,tn=(e,t,r)=>t<<r|e>>>32-r,rn=(e,t,r)=>t<<r-32|e>>>64-r,on=(e,t,r)=>e<<r-32|t>>>64-r});var ae,pr=S(()=>{ne();ae=class extends b{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}});var We,mn=S(()=>{ne();We=class extends b{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}});var ur,Xe,Fr,Hr,Or,jr,Nr,Mr,Gr,Dr,Tt,dn=S(()=>{Ko();ne();ur=class extends b{constructor({cause:t,message:r}={}){let o=r?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${o?`with reason: ${o}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}};Object.defineProperty(ur,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(ur,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});Xe=class extends b{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${Ct(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}};Object.defineProperty(Xe,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});Fr=class extends b{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${Ct(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}};Object.defineProperty(Fr,"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/});Hr=class extends b{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}is higher than the next one expected.`,{cause:t,name:"NonceTooHighError"})}};Object.defineProperty(Hr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});Or=class extends b{constructor({cause:t,nonce:r}={}){super([`Nonce provided for the transaction ${r?`(${r}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
9
+ `),{cause:t,name:"NonceTooLowError"})}};Object.defineProperty(Or,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});jr=class extends b{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}};Object.defineProperty(jr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});Nr=class extends b{constructor({cause:t}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
10
+ `),{cause:t,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}};Object.defineProperty(Nr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});Mr=class extends b{constructor({cause:t,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:t,name:"IntrinsicGasTooHighError"})}};Object.defineProperty(Mr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});Gr=class extends b{constructor({cause:t,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction is too low.`,{cause:t,name:"IntrinsicGasTooLowError"})}};Object.defineProperty(Gr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});Dr=class extends b{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}};Object.defineProperty(Dr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});Tt=class extends b{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:o}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${Ct(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${o?` = ${Ct(o)} gwei`:""}).`].join(`
11
+ `),{cause:t,name:"TipAboveFeeCapError"})}};Object.defineProperty(Tt,"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 it,qr=S(()=>{it=class extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){let r=super.get(t);return super.has(t)&&r!==void 0&&(this.delete(t),super.set(t,r)),r}set(t,r){if(super.set(t,r),this.maxSize&&this.size>this.maxSize){let o=this.keys().next().value;o&&this.delete(o)}return this}}});function ga(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let i=0;i<10;i++)r[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){let a=(i+8)%10,l=(i+2)%10,f=r[l],m=r[l+1],p=hn(f,m,1)^r[a],d=xn(f,m,1)^r[a+1];for(let h=0;h<50;h+=10)e[i+h]^=p,e[i+h+1]^=d}let n=e[2],s=e[3];for(let i=0;i<24;i++){let a=bn[i],l=hn(n,s,a),f=xn(n,s,a),m=gn[i];n=e[m],s=e[m+1],e[m]=l,e[m+1]=f}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]^=ha[o],e[1]^=xa[o]}$e(r)}var pa,St,ua,fa,ma,da,gn,bn,yn,vn,ha,xa,hn,xn,Vr,ba,wn,_n=S(()=>{nn();or();pa=BigInt(0),St=BigInt(1),ua=BigInt(2),fa=BigInt(7),ma=BigInt(256),da=BigInt(113),gn=[],bn=[],yn=[];for(let e=0,t=St,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],gn.push(2*(5*o+r)),bn.push((e+1)*(e+2)/2%64);let n=pa;for(let s=0;s<7;s++)t=(t<<St^(t>>fa)*da)%ma,t&ua&&(n^=St<<(St<<BigInt(s))-St);yn.push(n)}vn=Qo(yn,!0),ha=vn[0],xa=vn[1],hn=(e,t,r)=>r>32?rn(e,t,r):en(e,t,r),xn=(e,t,r)=>r>32?on(e,t,r):tn(e,t,r);Vr=class e extends ot{constructor(t,r,o,n=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=r,this.outputLen=o,this.enableXOF=n,this.rounds=s,Ur(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Xo(this.state)}clone(){return this._cloneInto()}keccak(){zr(this.state32),ga(this.state32,this.rounds),zr(this.state32),this.posOut=0,this.pos=0}update(t){nt(this),t=kt(t),Ke(t);let{blockLen:r,state:o}=this,n=t.length;for(let s=0;s<n;){let i=Math.min(r-this.pos,n-s);for(let a=0;a<i;a++)o[this.pos++]^=t[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:r,pos:o,blockLen:n}=this;t[o]^=r,(r&128)!==0&&o===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){nt(this,!1),Ke(t),this.finish();let r=this.state,{blockLen:o}=this;for(let n=0,s=t.length;n<s;){this.posOut>=o&&this.keccak();let i=Math.min(o-this.posOut,s-n);t.set(r.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Ur(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(er(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,$e(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new e(r,o,n,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=o,t.outputLen=n,t.enableXOF=i,t.destroyed=this.destroyed,t}},ba=(e,t,r)=>rr(()=>new Vr(t,e,r)),wn=ba(1,136,256/8)});function Cn(e,t){let r=t||"hex",o=wn(he(e,{strict:!1})?Mt(e):e);return r==="bytes"?o:pe(o)}var kn=S(()=>{_n();et();Be();ie()});function Tn(e,t){if(Kr.has(`${e}.${t}`))return Kr.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),o=Cn(Br(r),"bytes"),n=(t?r.substring(`${t}0x`.length):r).split("");for(let i=0;i<40;i+=2)o[i>>1]>>4>=8&&n[i]&&(n[i]=n[i].toUpperCase()),(o[i>>1]&15)>=8&&n[i+1]&&(n[i+1]=n[i+1].toUpperCase());let s=`0x${n.join("")}`;return Kr.set(`${e}.${t}`,s),s}var Kr,Sn=S(()=>{Be();kn();qr();Kr=new it(8192)});function xe(e,t){let{strict:r=!0}=t??{},o=`${e}.${r}`;if(Wr.has(o))return Wr.get(o);let n=ya.test(e)?e.toLowerCase()===e?!0:r?Tn(e)===e:!0:!1;return Wr.set(o,n),n}var ya,Wr,fr=S(()=>{qr();Sn();ya=/^0x[a-fA-F0-9]{40}$/,Wr=new it(8192)});function En(e,t,r,{strict:o}={}){return he(e,{strict:!1})?wa(e,t,r,{strict:o}):va(e,t,r,{strict:o})}function In(e,t){if(typeof t=="number"&&t>0&&t>se(e)-1)throw new yt({offset:t,position:"start",size:se(e)})}function An(e,t,r){if(typeof t=="number"&&typeof r=="number"&&se(e)!==r-t)throw new yt({offset:r,position:"end",size:se(e)})}function va(e,t,r,{strict:o}={}){In(e,t);let n=e.slice(t,r);return o&&An(n,t,r),n}function wa(e,t,r,{strict:o}={}){In(e,t);let n=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return o&&An(n,t,r),n}var Pn=S(()=>{Ar();et();gt()});var Yr=X(Pt=>{"use strict";var $a=Pt&&Pt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Pt,"__esModule",{value:!0});Pt.encryptEnvVars=Ua;var Jr=_e("@noble/curves/ed25519"),Zr=$a(_e("crypto"));function La(e){var t,r;return e=e.startsWith("0x")?e.slice(2):e,new Uint8Array((r=(t=e.match(/.{1,2}/g))===null||t===void 0?void 0:t.map(o=>parseInt(o,16)))!==null&&r!==void 0?r:[])}function Ra(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Ua(e,t){let r=JSON.stringify({env:e}),o=Jr.x25519.utils.randomPrivateKey(),n=Jr.x25519.getPublicKey(o),s=La(t),i=Jr.x25519.getSharedSecret(o,s),a=await Zr.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=Zr.default.getRandomValues(new Uint8Array(12)),f=await Zr.default.subtle.encrypt({name:"AES-GCM",iv:l},a,new TextEncoder().encode(r)),m=new Uint8Array(n.length+l.length+f.byteLength);return m.set(n),m.set(l,n.length),m.set(new Uint8Array(f),n.length+l.length),Ra(m)}});var jn=X(Bt=>{"use strict";var za=Bt&&Bt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Bt,"__esModule",{value:!0});Bt.getComposeHash=ja;var Fa=za(_e("crypto"));function Qr(e){return e==null?e:Array.isArray(e)?e.map(Qr):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=Qr(o),t},{}):e}function Ha(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 Oa(e){let t=Qr(e);return JSON.stringify(t,(r,o)=>typeof o=="number"&&(isNaN(o)||!isFinite(o))?null:o)}function ja(e,t=!1){t&&(e=Ha(e));let r=Oa(e);return Fa.default.createHash("sha256").update(r,"utf8").digest("hex")}});var cs=X(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.toBig=y.shrSL=y.shrSH=y.rotrSL=y.rotrSH=y.rotrBL=y.rotrBH=y.rotr32L=y.rotr32H=y.rotlSL=y.rotlSH=y.rotlBL=y.rotlBH=y.add5L=y.add5H=y.add4L=y.add4H=y.add3L=y.add3H=void 0;y.add=ts;y.fromBig=to;y.split=Nn;var xr=BigInt(2**32-1),eo=BigInt(32);function to(e,t=!1){return t?{h:Number(e&xr),l:Number(e>>eo&xr)}:{h:Number(e>>eo&xr)|0,l:Number(e&xr)|0}}function Nn(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=to(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var Mn=(e,t)=>BigInt(e>>>0)<<eo|BigInt(t>>>0);y.toBig=Mn;var Gn=(e,t,r)=>e>>>r;y.shrSH=Gn;var Dn=(e,t,r)=>e<<32-r|t>>>r;y.shrSL=Dn;var qn=(e,t,r)=>e>>>r|t<<32-r;y.rotrSH=qn;var Vn=(e,t,r)=>e<<32-r|t>>>r;y.rotrSL=Vn;var Kn=(e,t,r)=>e<<64-r|t>>>r-32;y.rotrBH=Kn;var Wn=(e,t,r)=>e>>>r-32|t<<64-r;y.rotrBL=Wn;var Xn=(e,t)=>t;y.rotr32H=Xn;var Jn=(e,t)=>e;y.rotr32L=Jn;var Zn=(e,t,r)=>e<<r|t>>>32-r;y.rotlSH=Zn;var Yn=(e,t,r)=>t<<r|e>>>32-r;y.rotlSL=Yn;var Qn=(e,t,r)=>t<<r-32|e>>>64-r;y.rotlBH=Qn;var es=(e,t,r)=>e<<r-32|t>>>64-r;y.rotlBL=es;function ts(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/2**32|0)|0,l:n|0}}var rs=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);y.add3L=rs;var os=(e,t,r,o)=>t+r+o+(e/2**32|0)|0;y.add3H=os;var ns=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0);y.add4L=ns;var ss=(e,t,r,o,n)=>t+r+o+n+(e/2**32|0)|0;y.add4H=ss;var is=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0);y.add5L=is;var as=(e,t,r,o,n,s)=>t+r+o+n+s+(e/2**32|0)|0;y.add5H=as;var Na={fromBig:to,split:Nn,toBig:Mn,shrSH:Gn,shrSL:Dn,rotrSH:qn,rotrSL:Vn,rotrBH:Kn,rotrBL:Wn,rotr32H:Xn,rotr32L:Jn,rotlSH:Zn,rotlSL:Yn,rotlBH:Qn,rotlBL:es,add:ts,add3L:rs,add3H:os,add4L:ns,add4H:ss,add5H:as,add5L:is};y.default=Na});var ls=X(gr=>{"use strict";Object.defineProperty(gr,"__esModule",{value:!0});gr.crypto=void 0;var Re=_e("crypto");gr.crypto=Re&&typeof Re=="object"&&"webcrypto"in Re?Re.webcrypto:Re&&typeof Re=="object"&&"randomBytes"in Re?Re:void 0});var gs=X(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=us;x.anumber=ro;x.abytes=ct;x.ahash=Ma;x.aexists=Ga;x.aoutput=Da;x.u8=qa;x.u32=Va;x.clean=Ka;x.createView=Wa;x.rotr=Xa;x.rotl=Ja;x.byteSwap=no;x.byteSwap32=fs;x.bytesToHex=Ya;x.hexToBytes=Qa;x.asyncLoop=tc;x.utf8ToBytes=so;x.bytesToUtf8=rc;x.toBytes=br;x.kdfInputToBytes=oc;x.concatBytes=nc;x.checkOpts=sc;x.createHasher=ds;x.createOptHasher=hs;x.createXOFer=xs;x.randomBytes=ic;var at=ls();function us(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ro(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ct(e,...t){if(!us(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 Ma(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");ro(e.outputLen),ro(e.blockLen)}function Ga(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 Da(e,t){ct(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function qa(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Va(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ka(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Wa(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Xa(e,t){return e<<32-t|e>>>t}function Ja(e,t){return e<<t|e>>>32-t>>>0}x.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function no(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}x.swap8IfBE=x.isLE?e=>e:e=>no(e);x.byteSwapIfBE=x.swap8IfBE;function fs(e){for(let t=0;t<e.length;t++)e[t]=no(e[t]);return e}x.swap32IfBE=x.isLE?e=>e:fs;var ms=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Za=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ya(e){if(ct(e),ms)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Za[e[r]];return t}var Se={_0:48,_9:57,A:65,F:70,a:97,f:102};function ps(e){if(e>=Se._0&&e<=Se._9)return e-Se._0;if(e>=Se.A&&e<=Se.F)return e-(Se.A-10);if(e>=Se.a&&e<=Se.f)return e-(Se.a-10)}function Qa(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(ms)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){let i=ps(e.charCodeAt(s)),a=ps(e.charCodeAt(s+1));if(i===void 0||a===void 0){let l=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+s)}o[n]=i*16+a}return o}var ec=async()=>{};x.nextTick=ec;async function tc(e,t,r){let o=Date.now();for(let n=0;n<e;n++){r(n);let s=Date.now()-o;s>=0&&s<t||(await(0,x.nextTick)(),o+=s)}}function so(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function rc(e){return new TextDecoder().decode(e)}function br(e){return typeof e=="string"&&(e=so(e)),ct(e),e}function oc(e){return typeof e=="string"&&(e=so(e)),ct(e),e}function nc(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];ct(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let s=e[o];r.set(s,n),n+=s.length}return r}function sc(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 oo=class{};x.Hash=oo;function ds(e){let t=o=>e().update(br(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function hs(e){let t=(o,n)=>e(n).update(br(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}function xs(e){let t=(o,n)=>e(n).update(br(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}x.wrapConstructor=ds;x.wrapConstructorWithOpts=hs;x.wrapXOFConstructorWithOpts=xs;function ic(e=32){if(at.crypto&&typeof at.crypto.getRandomValues=="function")return at.crypto.getRandomValues(new Uint8Array(e));if(at.crypto&&typeof at.crypto.randomBytes=="function")return Uint8Array.from(at.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var Ss=X(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.shake256=A.shake128=A.keccak_512=A.keccak_384=A.keccak_256=A.keccak_224=A.sha3_512=A.sha3_384=A.sha3_256=A.sha3_224=A.Keccak=void 0;A.keccakP=ks;var Lt=cs(),M=gs(),ac=BigInt(0),$t=BigInt(1),cc=BigInt(2),lc=BigInt(7),pc=BigInt(256),uc=BigInt(113),vs=[],ws=[],_s=[];for(let e=0,t=$t,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],vs.push(2*(5*o+r)),ws.push((e+1)*(e+2)/2%64);let n=ac;for(let s=0;s<7;s++)t=(t<<$t^(t>>lc)*uc)%pc,t&cc&&(n^=$t<<($t<<BigInt(s))-$t);_s.push(n)}var Cs=(0,Lt.split)(_s,!0),fc=Cs[0],mc=Cs[1],bs=(e,t,r)=>r>32?(0,Lt.rotlBH)(e,t,r):(0,Lt.rotlSH)(e,t,r),ys=(e,t,r)=>r>32?(0,Lt.rotlBL)(e,t,r):(0,Lt.rotlSL)(e,t,r);function ks(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let i=0;i<10;i++)r[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){let a=(i+8)%10,l=(i+2)%10,f=r[l],m=r[l+1],p=bs(f,m,1)^r[a],d=ys(f,m,1)^r[a+1];for(let h=0;h<50;h+=10)e[i+h]^=p,e[i+h+1]^=d}let n=e[2],s=e[3];for(let i=0;i<24;i++){let a=ws[i],l=bs(n,s,a),f=ys(n,s,a),m=vs[i];n=e[m],s=e[m+1],e[m]=l,e[m+1]=f}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]^=fc[o],e[1]^=mc[o]}(0,M.clean)(r)}var Rt=class e extends M.Hash{constructor(t,r,o,n=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=r,this.outputLen=o,this.enableXOF=n,this.rounds=s,(0,M.anumber)(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,M.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,M.swap32IfBE)(this.state32),ks(this.state32,this.rounds),(0,M.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(t){(0,M.aexists)(this),t=(0,M.toBytes)(t),(0,M.abytes)(t);let{blockLen:r,state:o}=this,n=t.length;for(let s=0;s<n;){let i=Math.min(r-this.pos,n-s);for(let a=0;a<i;a++)o[this.pos++]^=t[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:r,pos:o,blockLen:n}=this;t[o]^=r,(r&128)!==0&&o===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){(0,M.aexists)(this,!1),(0,M.abytes)(t),this.finish();let r=this.state,{blockLen:o}=this;for(let n=0,s=t.length;n<s;){this.posOut>=o&&this.keccak();let i=Math.min(o-this.posOut,s-n);t.set(r.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return(0,M.anumber)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,M.aoutput)(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,(0,M.clean)(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new e(r,o,n,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=o,t.outputLen=n,t.enableXOF=i,t.destroyed=this.destroyed,t}};A.Keccak=Rt;var Ue=(e,t,r)=>(0,M.createHasher)(()=>new Rt(t,e,r));A.sha3_224=Ue(6,144,224/8);A.sha3_256=Ue(6,136,256/8);A.sha3_384=Ue(6,104,384/8);A.sha3_512=Ue(6,72,512/8);A.keccak_224=Ue(1,144,224/8);A.keccak_256=Ue(1,136,256/8);A.keccak_384=Ue(1,104,384/8);A.keccak_512=Ue(1,72,512/8);var Ts=(e,t,r)=>(0,M.createXOFer)((o={})=>new Rt(t,e,o.dkLen===void 0?r:o.dkLen,!0));A.shake128=Ts(31,168,128/8);A.shake256=Ts(31,136,256/8)});var Es=X(io=>{"use strict";Object.defineProperty(io,"__esModule",{value:!0});io.verifyEnvEncryptPublicKey=xc;var dc=Ss(),hc=_e("@noble/curves/secp256k1");function xc(e,t,r){if(t.length!==65)return null;let o=Buffer.from("dstack-env-encrypt-pubkey","utf8"),n=r;r.startsWith("0x")&&(n=r.slice(2));let s=Buffer.from(n,"hex"),i=Buffer.from(":","utf8"),a=Buffer.concat([o,i,s,Buffer.from(e)]),l=(0,dc.keccak_256)(a);try{let f=t.slice(0,32),m=t.slice(32,64),p=t[64],d=new Uint8Array(64);d.set(f,0),d.set(m,32);let h=hc.secp256k1.Signature.fromCompact(d).addRecoveryBit(p).recoverPublicKey(l);return"0x"+Buffer.from(h.toRawBytes(!0)).toString("hex")}catch(f){return console.error("signature verification failed:",f),null}}});var $s=xt(Ao(),1);import{ofetch as gc}from"ofetch";function Po(e){return{all:e=e||new Map,on:function(t,r){var o=e.get(t);o?o.push(r):e.set(t,[r])},off:function(t,r){var o=e.get(t);o&&(r?o.splice(o.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var o=e.get(t);o&&o.slice().map(function(n){n(r)}),(o=e.get("*"))&&o.slice().map(function(n){n(t,r)})}}}import{z as H}from"zod";import{z as ze}from"zod";import{z as w}from"zod";import{z as Fe}from"zod";function Me(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}Gt();Ge();Gt();var $r={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function wt(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?qe(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?qe(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?$r[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=Vi(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 Uo=tt("transaction",wt);function Vi(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 Ki(e,t){let r=(e.transactions??[]).map(o=>typeof o=="string"?o:wt(o));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:r,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}var zo=tt("block",Ki);function Fo(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}:{}}}Ge();Gt();var Wi={"0x0":"reverted","0x1":"success"};function Xi(e,t){let r={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(o=>Fo(o)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?qe(e.transactionIndex):null,status:e.status?Wi[e.status]:null,type:e.type?$r[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var Ho=tt("transactionReceipt",Xi);ne();Rr();Be();ie();function ke(e,t="hex"){let r=No(e),o=Kt(new Uint8Array(r.length));return r.encode(o),t==="hex"?Z(o.bytes):o.bytes}function No(e){return Array.isArray(e)?Zi(e.map(t=>No(t))):Yi(e)}function Zi(e){let t=e.reduce((n,s)=>n+s.length,0),r=Mo(t);return{length:t<=55?1+t:1+r+t,encode(n){t<=55?n.pushByte(192+t):(n.pushByte(247+r),r===1?n.pushUint8(t):r===2?n.pushUint16(t):r===3?n.pushUint24(t):n.pushUint32(t));for(let{encode:s}of e)s(n)}}}function Yi(e){let t=typeof e=="string"?ue(e):e,r=Mo(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length,encode(n){t.length===1&&t[0]<128?n.pushBytes(t):t.length<=55?(n.pushByte(128+t.length),n.pushBytes(t)):(n.pushByte(183+r),r===1?n.pushUint8(t.length):r===2?n.pushUint16(t.length):r===3?n.pushUint24(t.length):n.pushUint32(t.length),n.pushBytes(t))}}}function Mo(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new b("Length is too large.")}Zt();ie();function Wo(e){if(!e||e.length===0)return[];let t=[];for(let r of e){let{chainId:o,nonce:n,...s}=r,i=r.address;t.push([o?pe(o):"0x",i,n?pe(n):"0x",...rt({},s)])}return t}Be();ie();function Yt(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),o=typeof e.blobs[0]=="string"?e.blobs.map(s=>ue(s)):e.blobs,n=[];for(let s of o)n.push(Uint8Array.from(t.blobToKzgCommitment(s)));return r==="bytes"?n:n.map(s=>Z(s))}Be();ie();function Qt(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),o=typeof e.blobs[0]=="string"?e.blobs.map(i=>ue(i)):e.blobs,n=typeof e.commitments[0]=="string"?e.commitments.map(i=>ue(i)):e.commitments,s=[];for(let i=0;i<o.length;i++){let a=o[i],l=n[i];s.push(Uint8Array.from(t.computeBlobKzgProof(a,l)))}return r==="bytes"?s:s.map(i=>Z(i))}ie();or();function sa(e,t,r,o){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,o);let n=BigInt(32),s=BigInt(4294967295),i=Number(r>>n&s),a=Number(r&s),l=o?4:0,f=o?0:4;e.setUint32(t+l,i,o),e.setUint32(t+f,a,o)}function Jo(e,t,r){return e&t^~e&r}function Zo(e,t,r){return e&t^e&r^t&r}var nr=class extends ot{constructor(t,r,o,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(t),this.view=tr(this.buffer)}update(t){nt(this),t=kt(t),Ke(t);let{view:r,buffer:o,blockLen:n}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(n-this.pos,s-i);if(a===n){let l=tr(t);for(;n<=s-i;i+=n)this.process(l,i);continue}o.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){nt(this),er(t,this),this.finished=!0;let{buffer:r,view:o,blockLen:n,isLE:s}=this,{pos:i}=this;r[i++]=128,$e(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let p=i;p<n;p++)r[p]=0;sa(o,n-8,BigInt(this.length*8),s),this.process(o,0);let a=tr(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=l/4,m=this.get();if(f>m.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<f;p++)a.setUint32(4*p,m[p],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let o=t.slice(0,r);return this.destroy(),o}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:o,length:n,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=n,t.pos=a,n%r&&t.buffer.set(o),t}clone(){return this._cloneInto()}},Te=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);or();var aa=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]),Le=new Uint32Array(64),ir=class extends nr{constructor(t=32){super(64,t,8,!1),this.A=Te[0]|0,this.B=Te[1]|0,this.C=Te[2]|0,this.D=Te[3]|0,this.E=Te[4]|0,this.F=Te[5]|0,this.G=Te[6]|0,this.H=Te[7]|0}get(){let{A:t,B:r,C:o,D:n,E:s,F:i,G:a,H:l}=this;return[t,r,o,n,s,i,a,l]}set(t,r,o,n,s,i,a,l){this.A=t|0,this.B=r|0,this.C=o|0,this.D=n|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=l|0}process(t,r){for(let p=0;p<16;p++,r+=4)Le[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let d=Le[p-15],h=Le[p-2],I=fe(d,7)^fe(d,18)^d>>>3,T=fe(h,17)^fe(h,19)^h>>>10;Le[p]=T+Le[p-7]+I+Le[p-16]|0}let{A:o,B:n,C:s,D:i,E:a,F:l,G:f,H:m}=this;for(let p=0;p<64;p++){let d=fe(a,6)^fe(a,11)^fe(a,25),h=m+d+Jo(a,l,f)+aa[p]+Le[p]|0,T=(fe(o,2)^fe(o,13)^fe(o,22))+Zo(o,n,s)|0;m=f,f=l,l=a,a=i+h|0,i=s,s=n,n=o,o=h+T|0}o=o+this.A|0,n=n+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,l=l+this.F|0,f=f+this.G|0,m=m+this.H|0,this.set(o,n,s,i,a,l,f,m)}roundClean(){$e(Le)}destroy(){this.set(0,0,0,0,0,0,0,0),$e(this.buffer)}};var sn=rr(()=>new ir);var an=sn;et();Be();ie();function cn(e,t){let r=t||"hex",o=an(he(e,{strict:!1})?Mt(e):e);return r==="bytes"?o:pe(o)}function ln(e){let{commitment:t,version:r=1}=e,o=e.to??(typeof t=="string"?"hex":"bytes"),n=cn(t,"bytes");return n.set([r],0),o==="bytes"?n:Z(n)}function pn(e){let{commitments:t,version:r}=e,o=e.to??(typeof t[0]=="string"?"hex":"bytes"),n=[];for(let s of t)n.push(ln({commitment:s,to:o,version:r}));return n}ne();var ar=class extends b{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},st=class extends b{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},cr=class extends b{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},lr=class extends b{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};Rr();gt();Be();ie();function un(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?ue(e.data):e.data,o=se(r);if(!o)throw new st;if(o>761855)throw new ar({maxSize:761855,size:o});let n=[],s=!0,i=0;for(;s;){let a=Kt(new Uint8Array(131072)),l=0;for(;l<4096;){let f=r.slice(i,i+31);if(a.pushByte(0),a.pushBytes(f),f.length<31){a.pushByte(128),s=!1;break}l++,i+=31}n.push(a)}return t==="bytes"?n.map(a=>a.bytes):n.map(a=>Z(a.bytes))}function fn(e){let{data:t,kzg:r,to:o}=e,n=e.blobs??un({data:t,to:o}),s=e.commitments??Yt({blobs:n,kzg:r,to:o}),i=e.proofs??Qt({blobs:n,commitments:s,kzg:r,to:o}),a=[];for(let l=0;l<n.length;l++)a.push({blob:n[l],commitment:s[l],proof:i[l]});return a}Lr();Lo();ie();Oo();pr();ne();mn();dn();fr();gt();Pn();Ge();function Bn(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:o}=r,n=r.address;if(!xe(n))throw new ae({address:n});if(o<0)throw new We({chainId:o})}mr(e)}function $n(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new st;for(let r of t){let o=se(r),n=qe(En(r,0,1));if(o!==32)throw new cr({hash:r,size:o});if(n!==1)throw new lr({hash:r,version:n})}}mr(e)}function mr(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:o,to:n}=e;if(t<=0)throw new We({chainId:t});if(n&&!xe(n))throw new ae({address:n});if(o&&o>Dt)throw new Xe({maxFeePerGas:o});if(r&&o&&r>o)throw new Tt({maxFeePerGas:o,maxPriorityFeePerGas:r})}function Ln(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(t<=0)throw new We({chainId:t});if(s&&!xe(s))throw new ae({address:s});if(r||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(o&&o>Dt)throw new Xe({maxFeePerGas:o})}function Rn(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(s&&!xe(s))throw new ae({address:s});if(typeof t<"u"&&t<=0)throw new We({chainId:t});if(r||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(o&&o>Dt)throw new Xe({maxFeePerGas:o})}Zt();function Un(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 Xt({transaction:e})}pr();Zt();fr();function Et(e){if(!e||e.length===0)return[];let t=[];for(let r=0;r<e.length;r++){let{address:o,storageKeys:n}=e[r];for(let s=0;s<n.length;s++)if(n[s].length-2!==64)throw new Jt({storageKey:n[s]});if(!xe(o,{strict:!1}))throw new ae({address:o});t.push([o,n])}return t}function zn(e,t){let r=Un(e);return r==="eip1559"?ka(e,t):r==="eip2930"?Ta(e,t):r==="eip4844"?Ca(e,t):r==="eip7702"?_a(e,t):Sa(e,t)}function _a(e,t){let{authorizationList:r,chainId:o,gas:n,nonce:s,to:i,value:a,maxFeePerGas:l,maxPriorityFeePerGas:f,accessList:m,data:p}=e;Bn(e);let d=Et(m),h=Wo(r);return Ve(["0x04",ke([_(o),s?_(s):"0x",f?_(f):"0x",l?_(l):"0x",n?_(n):"0x",i??"0x",a?_(a):"0x",p??"0x",d,h,...rt(e,t)])])}function Ca(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:f,accessList:m,data:p}=e;$n(e);let d=e.blobVersionedHashes,h=e.sidecars;if(e.blobs&&(typeof d>"u"||typeof h>"u")){let O=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(re=>Z(re)),ee=e.kzg,le=Yt({blobs:O,kzg:ee});if(typeof d>"u"&&(d=pn({commitments:le})),typeof h>"u"){let re=Qt({blobs:O,commitments:le,kzg:ee});h=fn({blobs:O,commitments:le,proofs:re})}}let I=Et(m),T=[_(r),n?_(n):"0x",f?_(f):"0x",l?_(l):"0x",o?_(o):"0x",s??"0x",i?_(i):"0x",p??"0x",I,a?_(a):"0x",d??[],...rt(e,t)],P=[],K=[],W=[];if(h)for(let O=0;O<h.length;O++){let{blob:ee,commitment:le,proof:re}=h[O];P.push(ee),K.push(le),W.push(re)}return Ve(["0x03",h?ke([T,P,K,W]):ke(T)])}function ka(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:f,data:m}=e;mr(e);let p=Et(f),d=[_(r),n?_(n):"0x",l?_(l):"0x",a?_(a):"0x",o?_(o):"0x",s??"0x",i?_(i):"0x",m??"0x",p,...rt(e,t)];return Ve(["0x02",ke(d)])}function Ta(e,t){let{chainId:r,gas:o,data:n,nonce:s,to:i,value:a,accessList:l,gasPrice:f}=e;Ln(e);let m=Et(l),p=[_(r),s?_(s):"0x",f?_(f):"0x",o?_(o):"0x",i??"0x",a?_(a):"0x",n??"0x",m,...rt(e,t)];return Ve(["0x01",ke(p)])}function Sa(e,t){let{chainId:r=0,gas:o,data:n,nonce:s,to:i,value:a,gasPrice:l}=e;Rn(e);let f=[s?_(s):"0x",l?_(l):"0x",o?_(o):"0x",i??"0x",a?_(a):"0x",n??"0x"];if(t){let m=(()=>{if(t.v>=35n)return(t.v-35n)/2n>0?t.v:27n+(t.v===35n?0n:1n);if(r>0)return BigInt(r*2)+BigInt(35n+t.v-27n);let h=27n+(t.v===27n?0n:1n);if(t.v!==h)throw new Wt({v:t.v});return h})(),p=bt(t.r),d=bt(t.s);f=[...f,_(m),p==="0x00"?"0x":p,d==="0x00"?"0x":d]}else r>0&&(f=[...f,_(r),"0x","0x"]);return ke(f)}function rt(e,t){let r=t??e,{v:o,yParity:n}=r;if(typeof r.r>"u")return[];if(typeof r.s>"u")return[];if(typeof o>"u"&&typeof n>"u")return[];let s=bt(r.r),i=bt(r.s);return[typeof n=="number"?n?_(1):"0x":o===0n?"0x":o===1n?_(1):o===27n?"0x":_(1),s==="0x00"?"0x":s,i==="0x00"?"0x":i]}var Fn={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};Ge();var Hn={block:zo({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let o=wt(r);return o.typeHex==="0x7e"&&(o.isSystemTx=r.isSystemTx,o.mint=r.mint?De(r.mint):void 0,o.sourceHash=r.sourceHash,o.type="deposit"),o}),stateRoot:e.stateRoot}}}),transaction:Uo({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?De(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Ho({format(e){return{l1GasPrice:e.l1GasPrice?De(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?De(e.l1GasUsed):null,l1Fee:e.l1Fee?De(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};pr();fr();Lr();ie();function Ea(e,t){return Aa(e)?Ia(e):zn(e,t)}var On={transaction:Ea};function Ia(e){Pa(e);let{sourceHash:t,data:r,from:o,gas:n,isSystemTx:s,mint:i,to:a,value:l}=e,f=[t,o,a??"0x",i?pe(i):"0x",l?pe(l):"0x",n?pe(n):"0x",s?"0x1":"0x",r??"0x"];return Ve(["0x7e",ke(f)])}function Aa(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function Pa(e){let{from:t,to:r}=e;if(t&&!xe(t))throw new ae({address:t});if(r&&!xe(r))throw new ae({address:r})}var Xr={blockTime:2e3,contracts:Fn,formatters:Hn,serializers:On};var dr=Me({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 It=1,At=Me({...Xr,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:{...Xr.contracts,disputeGameFactory:{[It]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[It]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[It]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[It]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:It}),Ba=Me({...At,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var hr=Me({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:12e3,rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:23085558},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}});import{z as L}from"zod";import{z as te}from"zod";import{z as u}from"zod";import{z as pt}from"zod";import{z as ce}from"zod";import{z as v}from"zod";import{z as C}from"zod";import{z as D}from"zod";import wl from"crypto";import{z as ye}from"zod";import{z as me}from"zod";import{z as j}from"zod";import{z as Y}from"zod";import{z as Q}from"zod";import{z as Ql}from"zod";import{z as As}from"zod";import{z as ve}from"zod";import{z as mt}from"zod";import{z as Je}from"zod";import{z as Ep}from"zod";import{z as Bp}from"zod";import{z as E}from"zod";import{z as be}from"zod";import{z as Vp}from"zod";import{z as $}from"zod";import{z as g}from"zod";import{z as ft}from"zod";import{z as Ps}from"zod";import{z as G}from"zod";import{z as Ks}from"zod";import{z as ge}from"zod";import{z as U}from"zod";var ug=xt(Yr(),1);import{z as B}from"zod";var $u=xt(Yr(),1),Lu=xt(jn(),1),Ru=xt(Es(),1);import{z as ut}from"zod";import{z as q}from"zod";var bc=H.object({detail:H.union([H.string(),H.array(H.object({msg:H.string(),type:H.string().optional(),ctx:H.record(H.unknown()).optional(),loc:H.array(H.union([H.string(),H.number()])).optional(),input:H.unknown().optional()}).passthrough()),H.record(H.unknown())]).optional(),type:H.string().optional(),code:H.string().optional()}),we=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)}},ao=class yr extends we{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=bc.safeParse(t.data);return r.success?new yr(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 yr(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 yr(t.message,{request:r??void 0,detail:t.message})}},yc=class extends we{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},vc=class extends we{constructor(){super(...arguments),this.isAuthError=!0}},Ls=class extends we{constructor(){super(...arguments),this.isBusinessError=!0}},wc=class extends we{constructor(){super(...arguments),this.isServerError=!0}},_c=class extends we{constructor(){super(...arguments),this.isUnknownError=!0}};function Cc(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 Rs(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((n,s)=>{let i=Cc(n.loc),a=i;return i==="unknown"&&n.type&&(a=n.type==="missing"?"required field":n.type),{field:a,message:n.msg,type:n.type,context:n.ctx}}),r=t.length,o=r===1?`Validation failed: ${t[0].message}`:`Validation failed (${r} issue${r>1?"s":""})`;return{errors:t,message:o}}function kc(e){return e===422?"validation":e===401||e===403?"auth":e>=400&&e<500?"business":e>=500?"server":"unknown"}function Tc(e,t,r){if(e===422&&Array.isArray(t)){let{message:o}=Rs(t);return o}if(typeof t=="string")return t;if(t&&typeof t=="object"&&"message"in t){let o=t.message;if(typeof o=="string")return o}return r}function Sc(e){let t=e.status??0,r=e.statusText??"Unknown Error",o=e.detail,n=Ic(o);if(n)return new Ec(n.message,{status:t,statusText:r,detail:o,errorCode:n.error_code,structuredDetails:n.details,suggestions:n.suggestions,links:n.links});let s=kc(t),i=Tc(t,o,e.message),a={status:t,statusText:r,detail:o};if(s==="validation"&&Array.isArray(o)){let{errors:l}=Rs(o);return new yc(i,{...a,validationErrors:l})}return s==="auth"?new vc(i,a):s==="business"?new Ls(i,a):s==="server"?new wc(i,a):new _c(i,a)}var Ec=class extends Ls{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 Ic(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 co=["2025-05-31","2025-10-28"],lt=(0,$s.default)("phala::api-client");function Ac(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
12
+ `)}function Pc(e){return e?` -d '${(typeof e=="string"?e:JSON.stringify(e,null,2)).replace(/'/g,"\\'")}'`:""}function Is(e,t,r,o){let n=[];r.forEach((a,l)=>{n.push(`${l}: ${a}`)});let s=n.join(`
13
13
  `),i=typeof o=="string"?o:JSON.stringify(o,null,2);return[`< HTTP/1.1 ${e} ${t}`,s?`< ${s.replace(/\n/g,`
14
14
  < `)}`:"","",i].filter(Boolean).join(`
15
- `)}var Ac=class{constructor(e={}){this.emitter=Ao();let t={...e,apiKey:e.apiKey||process?.env?.PHALA_CLOUD_API_KEY,baseURL:e.baseURL||process?.env?.PHALA_CLOUD_API_PREFIX||"https://cloud-api.phala.network/api/v1"},r=t.version&&ao.includes(t.version)?t.version:ao[ao.length-1];this.config=t;let{apiKey:o,baseURL:n,timeout:s,headers:i,useCookieAuth:a,onResponseError:l,...u}=t,f={"X-Phala-Version":r,"Content-Type":"application/json"};i&&typeof i=="object"&&Object.entries(i).forEach(([p,d])=>{typeof d=="string"&&(f[p]=d)}),!a&&o&&(f["X-API-Key"]=o),this.fetchInstance=hc.create({baseURL:n,timeout:s||3e4,headers:f,...a?{credentials:"include"}:{},...u,onRequest({request:p,options:d}){if(ct.enabled){let h=d.method||"GET",I=typeof p=="string"?p:p.url,T=I.startsWith("http")?I:`${n}${I}`,P={};d.headers&&typeof d.headers=="object"&&Object.entries(d.headers).forEach(([K,O])=>{typeof O=="string"&&(P[K]=O)});let V=[`> curl -X ${h} "${T}"`,Sc(P),d.body?Ic(d.body):""].filter(Boolean).join(`
16
- `);ct(`
15
+ `)}var Bc=class{constructor(e={}){this.emitter=Po();let t={...e,apiKey:e.apiKey||process?.env?.PHALA_CLOUD_API_KEY,baseURL:e.baseURL||process?.env?.PHALA_CLOUD_API_PREFIX||"https://cloud-api.phala.network/api/v1"},r=t.version&&co.includes(t.version)?t.version:co[co.length-1];this.config=t;let{apiKey:o,baseURL:n,timeout:s,headers:i,useCookieAuth:a,onResponseError:l,...f}=t,m={"X-Phala-Version":r,"Content-Type":"application/json"};i&&typeof i=="object"&&Object.entries(i).forEach(([p,d])=>{typeof d=="string"&&(m[p]=d)}),!a&&o&&(m["X-API-Key"]=o),this.fetchInstance=gc.create({baseURL:n,timeout:s||3e4,headers:m,...a?{credentials:"include"}:{},...f,onRequest({request:p,options:d}){if(lt.enabled){let h=d.method||"GET",I=typeof p=="string"?p:p.url,T=I.startsWith("http")?I:`${n}${I}`,P={};d.headers&&typeof d.headers=="object"&&Object.entries(d.headers).forEach(([W,O])=>{typeof O=="string"&&(P[W]=O)});let K=[`> curl -X ${h} "${T}"`,Ac(P),d.body?Pc(d.body):""].filter(Boolean).join(`
16
+ `);lt(`
17
17
  === REQUEST ===
18
18
  %s
19
- `,V)}},onResponse({request:p,response:d,options:h}){if(ct.enabled){let I=h.method||"GET",T=typeof p=="string"?p:p.url;ct(`
19
+ `,K)}},onResponse({request:p,response:d,options:h}){if(lt.enabled){let I=h.method||"GET",T=typeof p=="string"?p:p.url;lt(`
20
20
  === RESPONSE [%s %s] (%dms) ===
21
21
  %s
22
- `,I,T,d.headers.get("x-response-time")||"?",Ss(d.status,d.statusText,d.headers,d._data))}},onResponseError:({request:p,response:d,options:h})=>{if(console.warn(`HTTP ${d.status}: ${d.url}`),ct.enabled){let I=h.method||"GET",T=typeof p=="string"?p:p.url;ct(`
22
+ `,I,T,d.headers.get("x-response-time")||"?",Is(d.status,d.statusText,d.headers,d._data))}},onResponseError:({request:p,response:d,options:h})=>{if(console.warn(`HTTP ${d.status}: ${d.url}`),lt.enabled){let I=h.method||"GET",T=typeof p=="string"?p:p.url;lt(`
23
23
  === ERROR RESPONSE [%s %s] ===
24
24
  %s
25
- `,I,T,Ss(d.status,d.statusText,d.headers,d._data))}l&&l({request:p,response:d,options:h})}})}get raw(){return this.fetchInstance}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}once(e,t){let r=o=>{t(o),this.emitter.off(e,r)};this.emitter.on(e,r)}async get(e,t){try{return await this.fetchInstance(e,{...t,method:"GET"})}catch(r){let o=this.convertToRequestError(r);throw this.emitError(o)}}async post(e,t,r){try{return await this.fetchInstance(e,{...r,method:"POST",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async put(e,t,r){try{return await this.fetchInstance(e,{...r,method:"PUT",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async patch(e,t,r){try{return await this.fetchInstance(e,{...r,method:"PATCH",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async delete(e,t){try{return await this.fetchInstance(e,{...t,method:"DELETE"})}catch(r){let o=this.convertToRequestError(r);throw this.emitError(o)}}convertToRequestError(e){return e&&typeof e=="object"&&"data"in e?io.fromFetchError(e):e instanceof Error?io.fromError(e):new io("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(e){let t=kc(e);return this.emitter.emit("error",t),t}async safeRequest(e){try{return{success:!0,data:await e()}}catch(t){if(t instanceof ve)return{success:!1,error:t};let r=this.convertToRequestError(t);return this.emitError(r),{success:!1,error:r}}}async safeGet(e,t){return this.safeRequest(()=>this.get(e,t))}async safePost(e,t,r){return this.safeRequest(()=>this.post(e,t,r))}async safePut(e,t,r){return this.safeRequest(()=>this.put(e,t,r))}async safePatch(e,t,r){return this.safeRequest(()=>this.patch(e,t,r))}async safeDelete(e,t){return this.safeRequest(()=>this.delete(e,t))}extend(e){let t=typeof e=="function"?e(this):e,r=Object.create(this);for(let[o,n]of Object.entries(t))typeof n=="function"&&(r[o]=(...s)=>n(this,...s));return r}};function Pc(e={}){return new Ac(e)}function Rs(e){if(e?.schema!==void 0&&e?.schema!==!1&&(typeof e.schema!="object"||e.schema===null||!("parse"in e.schema)||typeof e.schema.parse!="function"))throw new Error("Invalid schema: must be a Zod schema object, false, or undefined")}function Us(e){if(e?.schema!==void 0&&e?.schema!==!1&&(typeof e.schema!="object"||e.schema===null||!("parse"in e.schema)||typeof e.schema.parse!="function"))return{success:!1,error:{name:"ZodError",message:"Invalid schema: must be a Zod schema object, false, or undefined",issues:[{code:"invalid_type",expected:"object",received:typeof e.schema,path:["schema"],message:"Invalid schema: must be a Zod schema object, false, or undefined"}]}}}function zs(e,t){function r(i,a){return o(i,a)}async function o(i,a){Rs(a);let l=await t(i);return a?.schema===!1?l:(a?.schema||e).parse(l)}function n(i,a){return s(i,a)}async function s(i,a){let l=Us(a);if(l)return l;let u=await(async()=>{try{return{success:!0,data:await t(i)}}catch(p){return p&&typeof p=="object"&&"status"in p?{success:!1,error:p}:p&&typeof p=="object"&&"issues"in p?{success:!1,error:p}:{success:!1,error:{name:"Error",message:p instanceof Error?p.message:String(p)}}}})();return u.success?a?.schema===!1?{success:!0,data:u.data}:(a?.schema||e).safeParse(u.data):u}return{action:r,safeAction:n}}function k(e,t){function r(i,...a){let[l,u]=a;return o(i,l,u)}async function o(i,a,l){Rs(l);let u=await t(i,a);return l?.schema===!1?u:(l?.schema||e).parse(u)}function n(i,...a){let[l,u]=a;return s(i,l,u)}async function s(i,a,l){let u=Us(l);if(u)return u;let f=await(async()=>{try{return{success:!0,data:await t(i,a)}}catch(d){return d&&typeof d=="object"&&"status"in d?{success:!1,error:d}:d&&typeof d=="object"&&"issues"in d?{success:!1,error:d}:{success:!1,error:{name:"Error",message:d instanceof Error?d.message:String(d)}}}})();return f.success?l?.schema===!1?{success:!0,data:f.data}:(l?.schema||e).safeParse(f.data):f}return{action:r,safeAction:n}}var Bc=Ue.object({username:Ue.string(),email:Ue.string(),credits:Ue.number(),granted_credits:Ue.number(),avatar:Ue.string(),team_name:Ue.string(),team_tier:Ue.string()}).passthrough(),{action:$c,safeAction:Lc}=zs(Bc,async e=>await e.get("/auth/me")),Rc={[dr.id]:dr,[It.id]:It,[mr.id]:mr},Uc=ze.object({id:ze.string(),slug:ze.string().nullable(),url:ze.string(),version:ze.string(),chain_id:ze.number().nullable(),kms_contract_address:ze.string().nullable().transform(e=>e),gateway_app_id:ze.string().nullable().transform(e=>e)}).passthrough(),Ee=Uc.transform(e=>{if(e.chain_id!=null){let t=Rc[e.chain_id];if(t)return{...e,chain:t}}return e}),zc=w.object({name:w.string(),is_dev:w.boolean(),version:w.union([w.tuple([w.number(),w.number(),w.number()]),w.tuple([w.number(),w.number(),w.number(),w.number()])]),os_image_hash:w.string().nullable().optional()}).passthrough(),Fc=w.object({teepod_id:w.number(),name:w.string(),listed:w.boolean(),resource_score:w.number(),remaining_vcpu:w.number(),remaining_memory:w.number(),remaining_cvm_slots:w.number(),images:w.array(zc),support_onchain_kms:w.boolean().optional(),fmspc:w.string().nullable().optional(),device_id:w.string().nullable().optional(),region_identifier:w.string().nullable().optional(),default_kms:w.string().nullable().optional(),kms_list:w.array(w.string()).default([])}).passthrough(),Hc=w.object({max_instances:w.number().nullable().optional(),max_vcpu:w.number().nullable().optional(),max_memory:w.number().nullable().optional(),max_disk:w.number().nullable().optional()}).passthrough(),Oc=w.object({tier:w.string(),capacity:Hc,nodes:w.array(Fc),kms_list:w.array(Ee)}).passthrough(),{action:jc,safeAction:Nc}=zs(Oc,async e=>await e.get("/teepods/available")),Fs=L.object({id:L.string(),name:L.string(),description:L.string(),vcpu:L.number(),memory_mb:L.number(),hourly_rate:L.string(),requires_gpu:L.boolean(),default_disk_size_gb:L.number().default(20),family:L.string().nullable()}).passthrough(),Mc=L.object({name:L.string(),items:L.array(Fs),total:L.number()}).strict(),Gc=L.object({result:L.array(Mc)}).strict(),Dc=L.object({items:L.array(Fs),total:L.number(),family:L.string()}).strict(),qc=L.object({family:L.string()}).strict(),{action:Vc,safeAction:Kc}=k(Gc,async e=>await e.get("/instance-types")),{action:Wc,safeAction:Xc}=k(Dc,async(e,t)=>{let r=qc.parse(t);return await e.get(`/instance-types/${r.family}`)}),Hs=ee.object({id:ee.string(),name:ee.string(),slug:ee.string().nullable(),tier:ee.string(),role:ee.string(),created_at:ee.string()}).passthrough(),Jc=ee.object({has_more:ee.boolean(),next_cursor:ee.string().nullable(),total:ee.number().nullable()}).passthrough(),Zc=ee.object({data:ee.array(Hs),pagination:Jc}).passthrough(),{action:Yc,safeAction:Qc}=k(Zc,async(e,t)=>{let r=new URLSearchParams;t?.cursor&&r.append("cursor",t.cursor),t?.limit&&r.append("limit",t.limit.toString());let o=r.toString()?`/workspaces?${r.toString()}`:"/workspaces";return await e.get(o)}),{action:el,safeAction:tl}=k(Hs,async(e,t)=>await e.get(`/workspaces/${t}`)),rl=m.object({id:m.string(),name:m.string(),status:m.string(),uptime:m.string(),app_url:m.string().nullable(),app_id:m.string(),instance_id:m.string().nullable(),configuration:m.any().optional(),exited_at:m.string().nullable(),boot_progress:m.string().nullable(),boot_error:m.string().nullable(),shutdown_progress:m.string().nullable(),image_version:m.string().nullable()}),ol=m.object({id:m.number(),username:m.string()}),po=m.object({id:m.number(),name:m.string(),region_identifier:m.string().nullable().optional()}),Os=m.object({app:m.string(),instance:m.string()}),nl=m.object({hosted:rl,name:m.string(),managed_user:ol.nullable(),node:po.nullable(),listed:m.boolean().default(!1),status:m.string(),in_progress:m.boolean().default(!1),dapp_dashboard_url:m.string().nullable(),syslog_endpoint:m.string().nullable(),allow_upgrade:m.boolean().default(!1),project_id:m.string().nullable(),project_type:m.string().nullable(),billing_period:m.string().nullable(),kms_info:Ee.nullable(),vcpu:m.number().nullable(),memory:m.number().nullable(),disk_size:m.number().nullable(),gateway_domain:m.string().nullable(),public_urls:m.array(Os)}),js=m.object({id:m.number(),name:m.string(),status:m.string(),in_progress:m.boolean().optional().default(!1),teepod_id:m.number().nullable(),teepod:po.optional().nullable(),app_id:m.string(),vm_uuid:m.string().nullable(),instance_id:m.string().nullable(),vcpu:m.number(),memory:m.number(),disk_size:m.number(),base_image:m.string().nullable(),encrypted_env_pubkey:m.string().nullable(),listed:m.boolean().optional().default(!1),project_id:m.string().optional().nullable(),project_type:m.string().optional().nullable(),public_sysinfo:m.boolean().optional().default(!1),public_logs:m.boolean().optional().default(!1),dapp_dashboard_url:m.string().optional().nullable(),syslog_endpoint:m.string().optional().nullable(),kms_info:Ee.optional().nullable(),contract_address:m.string().optional().nullable(),deployer_address:m.string().optional().nullable(),scheduled_delete_at:m.string().optional().nullable(),public_urls:m.array(Os).optional().default([]),gateway_domain:m.string().optional().nullable()}),yr=m.object({id:m.number(),name:m.string(),status:m.string(),teepod_id:m.number(),teepod:po.optional().nullable(),user_id:m.number().optional().nullable(),app_id:m.string(),vm_uuid:m.string().nullable(),instance_id:m.string().nullable(),app_url:m.string().optional().nullable(),base_image:m.string().nullable(),vcpu:m.number(),memory:m.number(),disk_size:m.number(),manifest_version:m.number().optional().nullable(),version:m.string().optional().nullable(),runner:m.string().optional().nullable(),docker_compose_file:m.string().optional().nullable(),features:m.array(m.string()).optional().nullable(),created_at:m.string(),encrypted_env_pubkey:m.string().nullable()});function Ns(e){return typeof e!="string"||e.length<5||e.length>63?!1:/^[a-zA-Z](?!.*--)([a-zA-Z0-9-]*[a-zA-Z0-9])?$/.test(e)}var Fe=lt.object({id:lt.string().optional(),uuid:lt.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i,"Invalid UUID format").optional(),app_id:lt.string().optional(),instance_id:lt.string().optional(),name:lt.string().refine(Ns,{message:"Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens"}).optional()}),He=e=>e.refine(t=>{let r=t;return!!(r.id||r.uuid||r.app_id||r.instance_id||r.name)},{message:"One of id, uuid, app_id, instance_id, or name must be provided"}),sl=He(Fe),R=sl.transform(e=>{let t;if(e.id)t=e.id;else if(e.uuid)t=e.uuid;else if(e.app_id)t=e.app_id;else if(e.instance_id)t=e.instance_id;else{if(e.name)return{cvmId:e.name};throw new Error("No valid identifier provided")}let r=/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i,o=/^[0-9a-f]{40}$/i,n;return r.test(t)?n=t.replace(/-/g,""):o.test(t)?n=`app_${t}`:n=t,{cvmId:n}}),il=R,{action:al,safeAction:mt}=k(js,async(e,t)=>{let{cvmId:r}=il.parse(t);return await e.get(`/cvms/${r}`)}),cl=ae.object({page:ae.number().int().min(1).optional(),page_size:ae.number().int().min(1).optional(),node_id:ae.number().int().min(1).optional(),teepod_id:ae.number().int().min(1).optional(),user_id:ae.string().optional()}).strict(),ll=ae.object({items:ae.array(nl),total:ae.number(),page:ae.number(),page_size:ae.number(),pages:ae.number()}).strict(),{action:pl,safeAction:uo}=k(ll,async(e,t)=>{let r=cl.parse(t??{});return await e.get("/cvms/paginated",{params:r})}),ul=v.object({app_id:v.string().nullable().optional(),app_env_encrypt_pubkey:v.string().nullable().optional(),compose_hash:v.string(),fmspc:v.string().nullable().optional(),device_id:v.string().nullable().optional(),os_image_hash:v.string().nullable().optional(),instance_type:v.string().nullable().optional(),teepod_id:v.number().nullable().optional(),node_id:v.number().nullable().optional(),kms_id:v.string().nullable().optional()}).passthrough().transform(e=>{if("teepod_id"in e&&e.teepod_id!==void 0){let{teepod_id:t,...r}=e;return{...r,node_id:t}}return e}),co="Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens",fl=v.object({node_id:v.number().optional(),teepod_id:v.number().optional(),region:v.string().optional(),name:v.string().min(5,co).max(63,co).refine(e=>Ns(e),co),instance_type:v.string().default("tdx.small"),image:v.string().optional(),vcpu:v.number().optional(),memory:v.number().optional(),disk_size:v.number().optional(),compose_file:v.object({allowed_envs:v.array(v.string()).optional(),pre_launch_script:v.string().optional(),docker_compose_file:v.string().optional(),name:v.string().optional().default(""),kms_enabled:v.boolean().optional(),public_logs:v.boolean().optional(),public_sysinfo:v.boolean().optional(),gateway_enabled:v.boolean().optional(),tproxy_enabled:v.boolean().optional()}),listed:v.boolean().optional(),kms_id:v.string().optional(),kms:v.enum(["PHALA","ETHEREUM","BASE"]).optional(),kms_contract:v.string().optional(),env_keys:v.array(v.string()).optional(),nonce:v.number().optional(),app_id:v.string().optional()}).passthrough();function ml(e){if(!e.compose_file)return e;let t={...e.compose_file};return typeof t.gateway_enabled=="boolean"&&typeof t.tproxy_enabled=="boolean"?delete t.tproxy_enabled:typeof t.tproxy_enabled=="boolean"&&typeof t.gateway_enabled>"u"&&(t.gateway_enabled=t.tproxy_enabled,delete t.tproxy_enabled,(typeof window<"u"?window.console:globalThis.console)&&console.warn("[phala/cloud] tproxy_enabled is deprecated, please use gateway_enabled instead. See docs for migration.")),{...e,compose_file:t}}var{action:dl,safeAction:hl}=k(ul,async(e,t)=>{let r=fl.parse(t),o=ml(r),n={...o};return typeof o.node_id=="number"?(n={...o,teepod_id:o.node_id},delete n.node_id):typeof o.teepod_id=="number"&&console.warn("[phala/cloud] teepod_id is deprecated, please use node_id instead."),await e.post("/cvms/provision",n)}),xl=C.object({id:C.number(),name:C.string(),status:C.string(),teepod_id:C.number(),teepod:C.object({id:C.number(),name:C.string()}).nullable(),user_id:C.number().nullable(),app_id:C.string().nullable(),vm_uuid:C.string().nullable(),instance_id:C.string().nullable(),app_url:C.string().nullable(),base_image:C.string().nullable(),vcpu:C.number(),memory:C.number(),disk_size:C.number(),manifest_version:C.number().nullable(),version:C.string().nullable(),runner:C.string().nullable(),docker_compose_file:C.string().nullable(),features:C.array(C.string()).nullable(),created_at:C.string(),encrypted_env_pubkey:C.string().nullable().optional(),app_auth_contract_address:C.string().nullable().optional(),deployer_address:C.string().nullable().optional()}).passthrough(),Rx=C.object({encrypted_env:C.string().optional().nullable(),app_id:C.string(),compose_hash:C.string(),kms_id:C.string().optional(),contract_address:C.string().optional(),deployer_address:C.string().optional(),env_keys:C.array(C.string()).optional().nullable()}).passthrough(),{action:gl,safeAction:bl}=k(xl,async(e,t)=>await e.post("/cvms",t)),Ms=D.object({allowed_envs:D.array(D.string()).optional(),docker_compose_file:D.string(),features:D.array(D.string()).optional(),name:D.string().optional(),manifest_version:D.number().optional(),kms_enabled:D.boolean().optional(),public_logs:D.boolean().optional(),public_sysinfo:D.boolean().optional(),tproxy_enabled:D.boolean().optional(),pre_launch_script:D.string().optional(),env_pubkey:D.string().optional(),salt:D.string().optional().nullable()}).passthrough();function lo(e){return e==null?e:Array.isArray(e)?e.map(lo):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=lo(o),t},{}):e}function Gs(e){let t={...e};return t.runner==="bash"&&"docker_compose_file"in t?delete t.docker_compose_file:t.runner==="docker-compose"&&"bash_script"in t&&delete t.bash_script,"pre_launch_script"in t&&!t.pre_launch_script&&delete t.pre_launch_script,t}function Ds(e){let t=lo(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function vl(e){let t=Gs(e),r=Ds(t);return yl.createHash("sha256").update(r,"utf8").digest("hex")}function wl(e){let t=e;return{...e,getHash:()=>vl(t),toString:()=>Ds(Gs(t))}}var _l=Ms.transform(e=>wl(e)),Cl=R,{action:kl,safeAction:fo}=k(_l,async(e,t)=>{let{cvmId:r}=Cl.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),Tl=be.object({id:be.string().optional(),uuid:be.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),app_id:be.string().refine(e=>!e.startsWith("app_")&&e.length===40,"app_id should be 40 characters without prefix").transform(e=>e.startsWith("app_")?e:`app_${e}`).optional(),instance_id:be.string().refine(e=>!e.startsWith("instance_")&&e.length===40,"instance_id should be 40 characters without prefix").transform(e=>e.startsWith("instance_")?e:`instance_${e}`).optional(),app_compose:Ms,update_env_vars:be.boolean().optional().nullable()}).refine(e=>!!(e.id||e.uuid||e.app_id||e.instance_id),"One of id, uuid, app_id, or instance_id must be provided").transform(e=>({cvmId:e.id||e.uuid||e.app_id||e.instance_id,request:{...e.app_compose,update_env_vars:e.update_env_vars},_raw:e})),El=be.object({app_id:be.string().nullable(),device_id:be.string().nullable(),compose_hash:be.string(),kms_info:Ee.nullable().optional()}).passthrough(),{action:Sl,safeAction:Il}=k(El,async(e,t)=>{let r=Tl.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),Al=fe.object({id:fe.string().optional(),uuid:fe.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),app_id:fe.string().refine(e=>!e.startsWith("app_")&&e.length===40,"app_id should be 40 characters without prefix").transform(e=>e.startsWith("app_")?e:`app_${e}`).optional(),instance_id:fe.string().refine(e=>!e.startsWith("instance_")&&e.length===40,"instance_id should be 40 characters without prefix").transform(e=>e.startsWith("instance_")?e:`instance_${e}`).optional(),compose_hash:fe.string().min(1,"Compose hash is required"),encrypted_env:fe.string().optional(),env_keys:fe.array(fe.string()).optional(),update_env_vars:fe.boolean().optional().nullable()}).refine(e=>!!(e.id||e.uuid||e.app_id||e.instance_id),"One of id, uuid, app_id, or instance_id must be provided").transform(e=>({cvmId:e.id||e.uuid||e.app_id||e.instance_id,compose_hash:e.compose_hash,encrypted_env:e.encrypted_env,env_keys:e.env_keys,update_env_vars:e.update_env_vars??void 0,_raw:e})),Pl=fe.any().transform(()=>{}),{action:Bl,safeAction:$l}=k(Pl,async(e,t)=>{let r=Al.parse(t);return await e.patch(`/cvms/${r.cvmId}/compose_file`,{compose_hash:r.compose_hash,encrypted_env:r.encrypted_env,env_keys:r.env_keys,update_env_vars:r.update_env_vars})}),Ll=He(Fe.extend({encrypted_env:j.string().describe("Encrypted environment variables (hex string)"),env_keys:j.array(j.string()).optional().describe("List of allowed environment variable keys"),compose_hash:j.string().optional().describe("Compose hash for verification (Phase 2, required when env_keys changes)"),transaction_hash:j.string().optional().describe("On-chain transaction hash for verification (Phase 2, required when env_keys changes)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{encrypted_env:e.encrypted_env,env_keys:e.env_keys,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Rl=j.object({status:j.literal("in_progress"),message:j.string(),correlation_id:j.string(),allowed_envs_changed:j.boolean()}),Ul=j.object({status:j.literal("precondition_required"),message:j.string(),compose_hash:j.string(),app_id:j.string(),device_id:j.string(),kms_info:Ee}),zl=j.union([Rl,Ul]),{action:Fl,safeAction:Hl}=k(zl,async(e,t)=>{let r=Ll.parse(t);try{return await e.patch(`/cvms/${r.cvmId}/envs`,r.request)}catch(o){if(o instanceof ve&&o.status===465){let n=o.detail;if(n&&typeof n=="object"){let s=n;return{status:"precondition_required",message:s.message||"Compose hash verification required",compose_hash:s.compose_hash,app_id:s.app_id,device_id:s.device_id,kms_info:s.kms_info}}}throw o}}),Ol=He(Fe.extend({docker_compose_file:Z.string().describe("Docker Compose YAML content"),compose_hash:Z.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:Z.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{docker_compose_file:e.docker_compose_file,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),jl=Z.object({status:Z.literal("in_progress"),message:Z.string(),correlation_id:Z.string()}),Nl=Z.object({status:Z.literal("precondition_required"),message:Z.string(),compose_hash:Z.string(),app_id:Z.string(),device_id:Z.string(),kms_info:Ee}),Ml=Z.union([jl,Nl]),{action:Gl,safeAction:Dl}=k(Ml,async(e,t)=>{let r=Ol.parse(t),o={"Content-Type":"text/yaml"};r.request.compose_hash&&(o["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(o["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/docker-compose`,r.request.docker_compose_file,{headers:o})}catch(n){if(n instanceof ve&&n.status===465){let s=n.detail;if(s&&typeof s=="object"){let i=s;return{status:"precondition_required",message:i.message||"Compose hash verification required",compose_hash:i.compose_hash,app_id:i.app_id,device_id:i.device_id,kms_info:i.kms_info}}}throw n}}),ql=He(Fe.extend({pre_launch_script:Y.string().describe("Pre-launch script content (shell script)"),compose_hash:Y.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:Y.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{pre_launch_script:e.pre_launch_script,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Vl=Y.object({status:Y.literal("in_progress"),message:Y.string(),correlation_id:Y.string()}),Kl=Y.object({status:Y.literal("precondition_required"),message:Y.string(),compose_hash:Y.string(),app_id:Y.string(),device_id:Y.string(),kms_info:Ee}),Wl=Y.union([Vl,Kl]),{action:Xl,safeAction:Jl}=k(Wl,async(e,t)=>{let r=ql.parse(t),o={"Content-Type":"text/plain"};r.request.compose_hash&&(o["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(o["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/pre-launch-script`,r.request.pre_launch_script,{headers:o})}catch(n){if(n instanceof ve&&n.status===465){let s=n.detail;if(s&&typeof s=="object"){let i=s;return{status:"precondition_required",message:i.message||"Compose hash verification required",compose_hash:i.compose_hash,app_id:i.app_id,device_id:i.device_id,kms_info:i.kms_info}}}throw n}}),Yl=R,{action:Ql,safeAction:ep}=k(Zl.string(),async(e,t)=>{let{cvmId:r}=Yl.parse(t);return await e.get(`/cvms/${r}/pre-launch-script`)}),tp=Is.object({kms_id:Is.string().min(1,"KMS ID is required")}),{action:rp,safeAction:op}=k(Ee,async(e,t)=>{let r=tp.parse(t);return await e.get(`/kms/${r.kms_id}`)}),np=ye.object({page:ye.number().int().min(1).optional(),page_size:ye.number().int().min(1).optional(),is_onchain:ye.boolean().optional()}).strict(),sp=ye.object({items:ye.array(Ee),total:ye.number(),page:ye.number(),page_size:ye.number(),pages:ye.number()}).strict(),{action:ip,safeAction:ap}=k(sp,async(e,t)=>{let r=np.parse(t??{});return await e.get("/kms",{params:r})}),cp=ft.object({kms:ft.string().min(1,"KMS ID or slug is required"),app_id:ft.string().refine(e=>e.length===40||e.startsWith("0x")&&e.length===42,"App ID must be exactly 40 characters or 42 characters with 0x prefix")}).strict(),lp=ft.object({public_key:ft.string(),signature:ft.string()}).strict(),{action:pp,safeAction:up}=k(lp,async(e,t)=>{let r=cp.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),fp=Xe.object({counts:Xe.number().int().min(1).max(20).optional().default(1)}).strict(),mp=Xe.object({app_ids:Xe.array(Xe.object({app_id:Xe.string(),nonce:Xe.number().int().min(0)}))}).strict(),{action:dp,safeAction:hp}=k(mp,async(e,t)=>{let r=fp.parse(t??{}),o=new URLSearchParams;return o.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${o.toString()}`)}),xp=R,{action:gp,safeAction:bp}=k(yr,async(e,t)=>{let{cvmId:r}=xp.parse(t);return await e.post(`/cvms/${r}/start`)}),yp=R,{action:vp,safeAction:wp}=k(yr,async(e,t)=>{let{cvmId:r}=yp.parse(t);return await e.post(`/cvms/${r}/stop`)}),_p=R,{action:Cp,safeAction:kp}=k(yr,async(e,t)=>{let{cvmId:r}=_p.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),Ep=He(Fe.extend({force:Tp.boolean().optional()})),{action:Sp,safeAction:Ip}=k(yr,async(e,t)=>{let r=Ep.parse(t),{cvmId:o}=R.parse(r),{force:n=!1}=r;return await e.post(`/cvms/${o}/restart`,{force:n})}),Pp=R,{action:Bp,safeAction:$p}=k(Ap.void(),async(e,t)=>{let{cvmId:r}=Pp.parse(t);await e.delete(`/cvms/${r}`)}),Lp=S.object({name:S.string(),mount_point:S.string(),total_size:S.number(),free_size:S.number()}),Rp=S.object({os_name:S.string(),os_version:S.string(),kernel_version:S.string(),cpu_model:S.string(),num_cpus:S.number(),total_memory:S.number(),available_memory:S.number(),used_memory:S.number(),free_memory:S.number(),total_swap:S.number(),used_swap:S.number(),free_swap:S.number(),uptime:S.number(),loadavg_one:S.number(),loadavg_five:S.number(),loadavg_fifteen:S.number(),disks:S.array(Lp)}),Up=S.object({is_online:S.boolean(),is_public:S.boolean().default(!1),error:S.string().nullable(),sysinfo:Rp.nullable(),status:S.string().nullable(),in_progress:S.boolean().default(!1),boot_progress:S.string().nullable(),boot_error:S.string().nullable()}),zp=R,{action:Fp,safeAction:Hp}=k(Up,async(e,t)=>{let{cvmId:r}=zp.parse(t);return await e.get(`/cvms/${r}/stats`)}),Op=ge.object({app:ge.string(),instance:ge.string()}),jp=ge.object({is_online:ge.boolean(),is_public:ge.boolean().default(!0),error:ge.string().nullable(),internal_ip:ge.string().nullable(),latest_handshake:ge.string().nullable(),public_urls:ge.array(Op).nullable()}),Np=R,{action:Mp,safeAction:Gp}=k(jp,async(e,t)=>{let{cvmId:r}=Np.parse(t);return await e.get(`/cvms/${r}/network`)}),qp=R,{action:Vp,safeAction:Kp}=k(Dp.string(),async(e,t)=>{let{cvmId:r}=qp.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),Wp=$.object({id:$.string(),names:$.array($.string()),image:$.string(),image_id:$.string(),command:$.string().nullable().optional(),created:$.number(),state:$.string(),status:$.string(),log_endpoint:$.string().nullable()}),Xp=$.object({is_online:$.boolean(),is_public:$.boolean().default(!0),error:$.string().nullable(),docker_compose_file:$.string().nullable(),manifest_version:$.number().nullable(),version:$.string().nullable(),runner:$.string().nullable(),features:$.array($.string()).nullable(),containers:$.array(Wp).nullable()}),Jp=R,{action:Zp,safeAction:Yp}=k(Xp,async(e,t)=>{let{cvmId:r}=Jp.parse(t);return await e.get(`/cvms/${r}/composition`)}),Qp=g.object({common_name:g.string().nullable(),organization:g.string().nullable(),country:g.string().nullable(),state:g.string().nullable(),locality:g.string().nullable()}),eu=g.object({common_name:g.string().nullable(),organization:g.string().nullable(),country:g.string().nullable()}),tu=g.object({subject:Qp,issuer:eu,serial_number:g.string(),not_before:g.string(),not_after:g.string(),version:g.string(),fingerprint:g.string(),signature_algorithm:g.string(),sans:g.array(g.string()).nullable(),is_ca:g.boolean(),position_in_chain:g.number().nullable(),quote:g.string().nullable(),app_id:g.string().nullable().optional(),cert_usage:g.string().nullable().optional()}),ru=g.object({imr:g.number(),event_type:g.number(),digest:g.string(),event:g.string(),event_payload:g.string()}),ou=g.object({mrtd:g.string(),rootfs_hash:g.string().nullable().optional(),rtmr0:g.string(),rtmr1:g.string(),rtmr2:g.string(),rtmr3:g.string(),event_log:g.array(ru),app_compose:g.string()}),nu=g.object({name:g.string().nullable(),is_online:g.boolean(),is_public:g.boolean().default(!0),error:g.string().nullable(),app_certificates:g.array(tu).nullable(),tcb_info:ou.nullable(),compose_file:g.string().nullable()}),su=R,{action:iu,safeAction:au}=k(nu,async(e,t)=>{let{cvmId:r}=su.parse(t);return await e.get(`/cvms/${r}/attestation`)}),cu=He(Fe.extend({vcpu:ut.number().optional(),memory:ut.number().optional(),disk_size:ut.number().optional(),instance_type:ut.string().optional(),allow_restart:ut.boolean().optional()})),{action:lu,safeAction:pu}=k(ut.void(),async(e,t)=>{let r=cu.parse(t),{cvmId:o}=R.parse(r),{...n}=r;await e.patch(`/cvms/${o}/resources`,n)}),uu=He(Fe.extend({public_sysinfo:As.boolean(),public_logs:As.boolean()})),{action:fu,safeAction:mu}=k(js,async(e,t)=>{let r=uu.parse(t),{cvmId:o}=R.parse(r),{public_sysinfo:n,public_logs:s}=r;return await e.patch(`/cvms/${o}/visibility`,{public_sysinfo:n,public_logs:s})}),Ps=G.object({name:G.string(),os_image_hash:G.string().nullable(),is_current:G.boolean()}),du=G.object({version:G.union([G.tuple([G.number(),G.number(),G.number(),G.number()]),G.tuple([G.number(),G.number(),G.number()])]),prod:Ps.nullable(),dev:Ps.nullable()}),hu=G.array(du),xu=R,{action:gu,safeAction:bu}=k(hu,async(e,t)=>{let{cvmId:r}=xu.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),yu=He(Fe.extend({os_image_name:qs.string().min(1,"OS image name is required")})),{action:vu,safeAction:wu}=k(qs.void(),async(e,t)=>{let r=yu.parse(t),{cvmId:o}=R.parse(r),{os_image_name:n}=r;await e.patch(`/cvms/${o}/os-image`,{os_image_name:n})}),_u=xe.object({id:xe.string().optional(),instance_id:xe.string().optional(),name:xe.string(),status:xe.string(),uptime:xe.string().optional(),exited_at:xe.string().optional(),boot_progress:xe.string().optional(),boot_error:xe.string().optional(),shutdown_progress:xe.string().optional()}),Cu=R,{action:ku,safeAction:Tu}=k(_u,async(e,t)=>{let{cvmId:r}=Cu.parse(t);return await e.get(`/cvms/${r}/state`)});function Vs(e={}){let t=Pc(e),r={getCurrentUser:$c,safeGetCurrentUser:Lc,getAvailableNodes:jc,safeGetAvailableNodes:Nc,listAllInstanceTypeFamilies:Vc,safeListAllInstanceTypeFamilies:Kc,listFamilyInstanceTypes:Wc,safeListFamilyInstanceTypes:Xc,listWorkspaces:Yc,safeListWorkspaces:Qc,getWorkspace:el,safeGetWorkspace:tl,getCvmInfo:al,safeGetCvmInfo:mt,getCvmList:pl,safeGetCvmList:uo,provisionCvm:dl,safeProvisionCvm:hl,commitCvmProvision:gl,safeCommitCvmProvision:bl,getCvmComposeFile:kl,safeGetCvmComposeFile:fo,provisionCvmComposeFileUpdate:Sl,safeProvisionCvmComposeFileUpdate:Il,commitCvmComposeFileUpdate:Bl,safeCommitCvmComposeFileUpdate:$l,updateCvmEnvs:Fl,safeUpdateCvmEnvs:Hl,updateDockerCompose:Gl,safeUpdateDockerCompose:Dl,updatePreLaunchScript:Xl,safeUpdatePreLaunchScript:Jl,getCvmPreLaunchScript:Ql,safeGetCvmPreLaunchScript:ep,startCvm:gp,safeStartCvm:bp,stopCvm:vp,safeStopCvm:wp,shutdownCvm:Cp,safeShutdownCvm:kp,restartCvm:Sp,safeRestartCvm:Ip,deleteCvm:Bp,safeDeleteCvm:$p,getCvmStats:Fp,safeGetCvmStats:Hp,getCvmNetwork:Mp,safeGetCvmNetwork:Gp,getCvmDockerCompose:Vp,safeGetCvmDockerCompose:Kp,getCvmContainersStats:Zp,safeGetCvmContainersStats:Yp,getCvmAttestation:iu,safeGetCvmAttestation:au,updateCvmResources:lu,safeUpdateCvmResources:pu,updateCvmVisibility:fu,safeUpdateCvmVisibility:mu,getAvailableOsImages:gu,safeGetAvailableOsImages:bu,updateOsImage:vu,safeUpdateOsImage:wu,getKmsInfo:rp,safeGetKmsInfo:op,getKmsList:ip,safeGetKmsList:ap,getAppEnvEncryptPubKey:pp,safeGetAppEnvEncryptPubKey:up,nextAppIds:dp,safeNextAppIds:hp,getCvmState:ku,safeGetCvmState:Tu};return t.extend(r)}var Eu=U.object({chain:U.unknown().optional(),rpcUrl:U.string().optional(),kmsContractAddress:U.string(),privateKey:U.string().optional(),walletClient:U.unknown().optional(),publicClient:U.unknown().optional(),allowAnyDevice:U.boolean().optional().default(!1),deviceId:U.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),composeHash:U.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),disableUpgrades:U.boolean().optional().default(!1),skipPrerequisiteChecks:U.boolean().optional().default(!1),minBalance:U.string().optional()}).passthrough(),cg=Eu.refine(e=>{let t=!!e.privateKey,r=!!e.walletClient;return t!==r},{message:"Either 'privateKey' or 'walletClient' must be provided, but not both",path:["privateKey","walletClient"]}).refine(e=>{let t=!!e.publicClient,r=!!e.walletClient,o=!!e.chain;return t&&r?!0:o},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),lg=U.object({appId:U.string(),appAuthAddress:U.string(),deployer:U.string(),transactionHash:U.string(),blockNumber:U.bigint().optional(),gasUsed:U.bigint().optional()}).passthrough();var ug=B.object({chain:B.unknown().optional(),rpcUrl:B.string().optional(),appId:B.string(),composeHash:B.string(),privateKey:B.string().optional(),walletClient:B.unknown().optional(),publicClient:B.unknown().optional(),skipPrerequisiteChecks:B.boolean().optional().default(!1),minBalance:B.string().optional(),timeout:B.number().optional().default(12e4),retryOptions:B.unknown().optional(),signal:B.unknown().optional(),onTransactionStateChange:B.function().optional(),onTransactionSubmitted:B.function().optional(),onTransactionConfirmed:B.function().optional()}).passthrough().refine(e=>{let t=!!e.privateKey,r=!!e.walletClient;return t!==r},{message:"Either 'privateKey' or 'walletClient' must be provided, but not both",path:["privateKey","walletClient"]}).refine(e=>{let t=!!e.publicClient,r=!!e.walletClient,o=!!e.chain;return t&&r?!0:o},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),fg=B.object({composeHash:B.string(),appId:B.string(),transactionHash:B.string(),blockNumber:B.bigint().optional(),gasUsed:B.bigint().optional()}).passthrough();var dg=pt.object({target:pt.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:pt.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:pt.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:pt.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:pt.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});import Js from"crypto";import Ws from"fs";import dt from"os";import mo from"path";import q from"chalk";import Bu from"ora";var Pu=!1;function me(){return Pu}function $u(e,t){let r=e.split(/\s+/),o=[],n="";for(let s of r){let i=n.length===0?s:`${n} ${s}`;i.length<=t?n=i:(n.length>0&&o.push(n),n=s)}return n.length>0&&o.push(n),o}function Lu(e,t){if(e.length<=t)return[e];let r=[],o=0;for(;o<e.length;)r.push(e.slice(o,o+t)),o+=t;return r}function Ks(e,t){let r=[];for(let o of e.split(`
26
- `)){if(o.length<=t){r.push(o);continue}if(o.indexOf(" ")===-1){r.push(...Lu(o,t));continue}let n=$u(o,t);r.push(...n)}if(r.length===0){let o=e.trim();r.push(o)}return r}var Oe={error:(e,...t)=>{me()||(process.stderr.write(`${q.red("\u2717")} ${q.red(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
27
- `))},warn:(e,...t)=>{me()||(process.stderr.write(`${q.yellow("\u26A0")} ${q.yellow(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
28
- `))},info:(e,...t)=>{me()||(process.stderr.write(`${q.blue("\u2139")} ${q.blue(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
29
- `))},success:(e,...t)=>{me()||(process.stderr.write(`${q.green("\u2713")} ${q.green(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
30
- `))},debug:(e,...t)=>{me()||process.env.DEBUG&&(process.stderr.write(`${q.gray("\u{1F50D}")} ${q.gray(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
31
- `))},table:(e,t)=>{if(!me()){if(e.length===0){console.log(q.yellow("No data to display"));return}if(t){let r;typeof t[0]=="string"?r=t.map(i=>({key:i,header:i})):r=t;let o={};for(let i of r){let a=i.header||String(i.key);o[String(i.key)]=a.length}for(let i of e)for(let a of r){let l=String(typeof a.key=="string"&&!(a.key in i)?"":i[String(a.key)]??"");o[String(a.key)]=Math.max(o[String(a.key)],l.length)}let n=[];for(let i of r){let a=i.header||String(i.key);n.push(q.bold(a.padEnd(o[String(i.key)])))}console.log(n.join(" "));let s=[];for(let i of r)s.push("-".repeat(o[String(i.key)]));console.log(s.join(" "));for(let i of e){let a=[];for(let l of r){let u=String(typeof l.key=="string"&&!(l.key in i)?"":i[String(l.key)]??"");a.push(u.padEnd(o[String(l.key)]))}console.log(a.join(" "))}}else{let r=e[0],o=Object.keys(r),n={};for(let a of o)n[a]=a.length;for(let a of e)for(let l of o){let u=String(a[l]??"");n[l]=Math.max(n[l],u.length)}let s=[];for(let a of o)s.push(q.bold(a.padEnd(n[a])));console.log(s.join(" "));let i=[];for(let a of o)i.push("-".repeat(n[a]));console.log(i.join(" "));for(let a of e){let l=[];for(let u of o){let f=String(a[u]??"");l.push(f.padEnd(n[u]))}console.log(l.join(" "))}}}},keyValueTable:(e,t)=>{if(me())return;let{borderStyle:r="single",keyColor:o=q.blue,valueColor:n=q.white,maxWidth:s=process.stdout.columns||80}=t||{},a={single:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",leftT:"\u251C",rightT:"\u2524"},double:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551",cross:"\u256C",leftT:"\u2560",rightT:"\u2563"},rounded:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",leftT:"\u251C",rightT:"\u2524"},bold:{topLeft:"\u250F",topRight:"\u2513",bottomLeft:"\u2517",bottomRight:"\u251B",horizontal:"\u2501",vertical:"\u2503",cross:"\u254B",leftT:"\u2523",rightT:"\u252B"},none:{topLeft:"",topRight:"",bottomLeft:"",bottomRight:"",horizontal:"",vertical:"",cross:"",leftT:"",rightT:""}}[r],l=0,u=0;for(let[I,T]of Object.entries(e)){l=Math.max(l,I.length);let P=String(T??"");u=Math.max(u,P.length)}let f=4,p=1,d=s-f-p;if(l+u>d){let I=l/(l+u);l=Math.floor(d*I),u=d-l}let h=l+u+f+p;r!=="none"&&console.log(a.topLeft+a.horizontal.repeat(h-2)+a.topRight);for(let[I,T]of Object.entries(e)){let P=I,V=String(T??""),K=Ks(P,l),O=Ks(V,u),Q=Math.max(K.length,O.length);for(;K.length<Q;)K.push("");for(;O.length<Q;)O.push("");for(let ce=0;ce<Q;ce++){let te=K[ce].padEnd(l),Rt=O[ce].padEnd(u);console.log(r!=="none"?`${a.vertical} ${o(te)} ${a.vertical} ${n(Rt)} ${a.vertical}`:`${o(te)} : ${n(Rt)}`)}}r!=="none"&&console.log(a.bottomLeft+a.horizontal.repeat(h-2)+a.bottomRight)},break:()=>{me()||process.stderr.write(`
32
- `)},startSpinner:e=>{if(me())return{stop:()=>{}};let t=Bu(e).start();return{stop:(r=!0,o)=>{o&&(t.text=o),r?t.succeed():t.fail()}}},logDetailedError(e,t){if(me())return;let r=t?`[${t}] `:"",o=s=>s!==null&&typeof s=="object"&&"isRequestError"in s&&s.isRequestError===!0&&"status"in s&&"message"in s&&"data"in s,n=s=>s!==null&&typeof s=="object"&&"issues"in s&&Array.isArray(s.issues);if(o(e)){process.stderr.write(`${r}HTTP ${e.status}: ${e.message}
25
+ `,I,T,Is(d.status,d.statusText,d.headers,d._data))}l&&l({request:p,response:d,options:h})}})}get raw(){return this.fetchInstance}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}once(e,t){let r=o=>{t(o),this.emitter.off(e,r)};this.emitter.on(e,r)}async get(e,t){try{return await this.fetchInstance(e,{...t,method:"GET"})}catch(r){let o=this.convertToRequestError(r);throw this.emitError(o)}}async post(e,t,r){try{return await this.fetchInstance(e,{...r,method:"POST",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async put(e,t,r){try{return await this.fetchInstance(e,{...r,method:"PUT",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async patch(e,t,r){try{return await this.fetchInstance(e,{...r,method:"PATCH",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async delete(e,t){try{return await this.fetchInstance(e,{...t,method:"DELETE"})}catch(r){let o=this.convertToRequestError(r);throw this.emitError(o)}}convertToRequestError(e){return e&&typeof e=="object"&&"data"in e?ao.fromFetchError(e):e instanceof Error?ao.fromError(e):new ao("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(e){let t=Sc(e);return this.emitter.emit("error",t),t}async safeRequest(e){try{return{success:!0,data:await e()}}catch(t){if(t instanceof we)return{success:!1,error:t};let r=this.convertToRequestError(t);return this.emitError(r),{success:!1,error:r}}}async safeGet(e,t){return this.safeRequest(()=>this.get(e,t))}async safePost(e,t,r){return this.safeRequest(()=>this.post(e,t,r))}async safePut(e,t,r){return this.safeRequest(()=>this.put(e,t,r))}async safePatch(e,t,r){return this.safeRequest(()=>this.patch(e,t,r))}async safeDelete(e,t){return this.safeRequest(()=>this.delete(e,t))}extend(e){let t=typeof e=="function"?e(this):e,r=Object.create(this);for(let[o,n]of Object.entries(t))typeof n=="function"&&(r[o]=(...s)=>n(this,...s));return r}};function $c(e={}){return new Bc(e)}function Us(e){if(e?.schema!==void 0&&e?.schema!==!1&&(typeof e.schema!="object"||e.schema===null||!("parse"in e.schema)||typeof e.schema.parse!="function"))throw new Error("Invalid schema: must be a Zod schema object, false, or undefined")}function zs(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 Fs(e,t){function r(i,a){return o(i,a)}async function o(i,a){Us(a);let l=await t(i);return a?.schema===!1?l:(a?.schema||e).parse(l)}function n(i,a){return s(i,a)}async function s(i,a){let l=zs(a);if(l)return l;let f=await(async()=>{try{return{success:!0,data:await t(i)}}catch(p){return p&&typeof p=="object"&&"status"in p?{success:!1,error:p}:p&&typeof p=="object"&&"issues"in p?{success:!1,error:p}:{success:!1,error:{name:"Error",message:p instanceof Error?p.message:String(p)}}}})();return f.success?a?.schema===!1?{success:!0,data:f.data}:(a?.schema||e).safeParse(f.data):f}return{action:r,safeAction:n}}function k(e,t){function r(i,...a){let[l,f]=a;return o(i,l,f)}async function o(i,a,l){Us(l);let f=await t(i,a);return l?.schema===!1?f:(l?.schema||e).parse(f)}function n(i,...a){let[l,f]=a;return s(i,l,f)}async function s(i,a,l){let f=zs(l);if(f)return f;let m=await(async()=>{try{return{success:!0,data:await t(i,a)}}catch(d){return d&&typeof d=="object"&&"status"in d?{success:!1,error:d}:d&&typeof d=="object"&&"issues"in d?{success:!1,error:d}:{success:!1,error:{name:"Error",message:d instanceof Error?d.message:String(d)}}}})();return m.success?l?.schema===!1?{success:!0,data:m.data}:(l?.schema||e).safeParse(m.data):m}return{action:r,safeAction:n}}var Lc=ze.object({username:ze.string(),email:ze.string(),credits:ze.number(),granted_credits:ze.number(),avatar:ze.string(),team_name:ze.string(),team_tier:ze.string()}).passthrough(),{action:Rc,safeAction:Uc}=Fs(Lc,async e=>await e.get("/auth/me")),zc={[hr.id]:hr,[At.id]:At,[dr.id]:dr},Fc=Fe.object({id:Fe.string(),slug:Fe.string().nullable(),url:Fe.string(),version:Fe.string(),chain_id:Fe.number().nullable(),kms_contract_address:Fe.string().nullable().transform(e=>e),gateway_app_id:Fe.string().nullable().transform(e=>e)}).passthrough(),Ee=Fc.transform(e=>{if(e.chain_id!=null){let t=zc[e.chain_id];if(t)return{...e,chain:t}}return e}),Hc=w.object({name:w.string(),is_dev:w.boolean(),version:w.union([w.tuple([w.number(),w.number(),w.number()]),w.tuple([w.number(),w.number(),w.number(),w.number()])]),os_image_hash:w.string().nullable().optional()}).passthrough(),Oc=w.object({teepod_id:w.number(),name:w.string(),listed:w.boolean(),resource_score:w.number(),remaining_vcpu:w.number(),remaining_memory:w.number(),remaining_cvm_slots:w.number(),images:w.array(Hc),support_onchain_kms:w.boolean().optional(),fmspc:w.string().nullable().optional(),device_id:w.string().nullable().optional(),region_identifier:w.string().nullable().optional(),default_kms:w.string().nullable().optional(),kms_list:w.array(w.string()).default([])}).passthrough(),jc=w.object({max_instances:w.number().nullable().optional(),max_vcpu:w.number().nullable().optional(),max_memory:w.number().nullable().optional(),max_disk:w.number().nullable().optional()}).passthrough(),Nc=w.object({tier:w.string(),capacity:jc,nodes:w.array(Oc),kms_list:w.array(Ee)}).passthrough(),{action:Mc,safeAction:Gc}=Fs(Nc,async e=>await e.get("/teepods/available")),Hs=L.object({id:L.string(),name:L.string(),description:L.string(),vcpu:L.number(),memory_mb:L.number(),hourly_rate:L.string(),requires_gpu:L.boolean(),default_disk_size_gb:L.number().default(20),family:L.string().nullable()}).passthrough(),Dc=L.object({name:L.string(),items:L.array(Hs),total:L.number()}).strict(),qc=L.object({result:L.array(Dc)}).strict(),Vc=L.object({items:L.array(Hs),total:L.number(),family:L.string()}).strict(),Kc=L.object({family:L.string()}).strict(),{action:Wc,safeAction:Xc}=k(qc,async e=>await e.get("/instance-types")),{action:Jc,safeAction:Zc}=k(Vc,async(e,t)=>{let r=Kc.parse(t);return await e.get(`/instance-types/${r.family}`)}),Os=te.object({id:te.string(),name:te.string(),slug:te.string().nullable(),tier:te.string(),role:te.string(),created_at:te.string()}).passthrough(),Yc=te.object({has_more:te.boolean(),next_cursor:te.string().nullable(),total:te.number().nullable()}).passthrough(),Qc=te.object({data:te.array(Os),pagination:Yc}).passthrough(),{action:el,safeAction:tl}=k(Qc,async(e,t)=>{let r=new URLSearchParams;t?.cursor&&r.append("cursor",t.cursor),t?.limit&&r.append("limit",t.limit.toString());let o=r.toString()?`/workspaces?${r.toString()}`:"/workspaces";return await e.get(o)}),{action:rl,safeAction:ol}=k(Os,async(e,t)=>await e.get(`/workspaces/${t}`)),nl=u.object({id:u.string(),name:u.string(),status:u.string(),uptime:u.string(),app_url:u.string().nullable(),app_id:u.string(),instance_id:u.string().nullable(),configuration:u.any().optional(),exited_at:u.string().nullable(),boot_progress:u.string().nullable(),boot_error:u.string().nullable(),shutdown_progress:u.string().nullable(),image_version:u.string().nullable()}),sl=u.object({id:u.number(),username:u.string()}),uo=u.object({id:u.number(),name:u.string(),region_identifier:u.string().nullable().optional()}),js=u.object({vcpu:u.number(),memory:u.number(),disk_size:u.number(),gpu_count:u.number().default(0)}),Ns=u.object({app:u.string(),instance:u.string()}),il=u.object({hosted:nl,name:u.string(),managed_user:sl.nullable(),node:uo.nullable(),listed:u.boolean().default(!1),status:u.string(),in_progress:u.boolean().default(!1),dapp_dashboard_url:u.string().nullable(),syslog_endpoint:u.string().nullable(),allow_upgrade:u.boolean().default(!1),project_id:u.string().nullable(),project_type:u.string().nullable(),billing_period:u.string().nullable(),kms_info:Ee.nullable(),vcpu:u.number().nullable(),memory:u.number().nullable(),disk_size:u.number().nullable(),gateway_domain:u.string().nullable(),public_urls:u.array(Ns),machine_info:js.nullable().optional(),updated_at:u.string().nullable().optional()}),Ms=u.object({id:u.number(),name:u.string(),status:u.string(),in_progress:u.boolean().optional().default(!1),teepod_id:u.number().nullable(),teepod:uo.optional().nullable(),app_id:u.string(),vm_uuid:u.string().nullable(),instance_id:u.string().nullable(),vcpu:u.number(),memory:u.number(),disk_size:u.number(),base_image:u.string().nullable(),encrypted_env_pubkey:u.string().nullable(),listed:u.boolean().optional().default(!1),project_id:u.string().optional().nullable(),project_type:u.string().optional().nullable(),instance_type:u.string().optional().nullable(),public_sysinfo:u.boolean().optional().default(!1),public_logs:u.boolean().optional().default(!1),dapp_dashboard_url:u.string().optional().nullable(),syslog_endpoint:u.string().optional().nullable(),kms_info:Ee.optional().nullable(),contract_address:u.string().optional().nullable(),deployer_address:u.string().optional().nullable(),scheduled_delete_at:u.string().optional().nullable(),public_urls:u.array(Ns).optional().default([]),gateway_domain:u.string().optional().nullable(),machine_info:js.optional().nullable(),updated_at:u.string().optional().nullable()}),vr=u.object({id:u.number(),name:u.string(),status:u.string(),teepod_id:u.number(),teepod:uo.optional().nullable(),user_id:u.number().optional().nullable(),app_id:u.string(),vm_uuid:u.string().nullable(),instance_id:u.string().nullable(),app_url:u.string().optional().nullable().default(null),base_image:u.string().nullable(),vcpu:u.number(),memory:u.number(),disk_size:u.number(),manifest_version:u.number().optional().nullable().default(2),version:u.string().optional().nullable().default("1.0.0"),runner:u.string().optional().nullable().default("docker-compose"),docker_compose_file:u.string().optional().nullable(),features:u.array(u.string()).optional().nullable().default(["kms","tproxy-net"]),created_at:u.string(),encrypted_env_pubkey:u.string().nullable()});function Gs(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 He=pt.object({id:pt.string().optional(),uuid:pt.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i,"Invalid UUID format").optional(),app_id:pt.string().optional(),instance_id:pt.string().optional(),name:pt.string().refine(Gs,{message:"Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens"}).optional()}),Oe=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"}),al=Oe(He),R=al.transform(e=>{let t;if(e.id)t=e.id;else if(e.uuid)t=e.uuid;else if(e.app_id)t=e.app_id;else if(e.instance_id)t=e.instance_id;else{if(e.name)return{cvmId:e.name};throw new Error("No valid identifier provided")}let r=/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i,o=/^[0-9a-f]{40}$/i,n;return r.test(t)?n=t.replace(/-/g,""):o.test(t)?n=`app_${t}`:n=t,{cvmId:n}}),cl=R,{action:ll,safeAction:dt}=k(Ms,async(e,t)=>{let{cvmId:r}=cl.parse(t);return await e.get(`/cvms/${r}`)}),pl=ce.object({page:ce.number().int().min(1).optional(),page_size:ce.number().int().min(1).optional(),node_id:ce.number().int().min(1).optional(),teepod_id:ce.number().int().min(1).optional(),user_id:ce.string().optional()}).strict(),ul=ce.object({items:ce.array(il),total:ce.number(),page:ce.number(),page_size:ce.number(),pages:ce.number()}).strict(),{action:fl,safeAction:fo}=k(ul,async(e,t)=>{let r=pl.parse(t??{});return await e.get("/cvms/paginated",{params:r})}),ml=v.object({app_id:v.string().nullable().optional(),app_env_encrypt_pubkey:v.string().nullable().optional(),compose_hash:v.string(),fmspc:v.string().nullable().optional(),device_id:v.string().nullable().optional(),os_image_hash:v.string().nullable().optional(),instance_type:v.string().nullable().optional(),teepod_id:v.number().nullable().optional(),node_id:v.number().nullable().optional(),kms_id:v.string().nullable().optional()}).passthrough().transform(e=>{if("teepod_id"in e&&e.teepod_id!==void 0){let{teepod_id:t,...r}=e;return{...r,node_id:t}}return e}),lo="Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens",dl=v.object({node_id:v.number().optional(),teepod_id:v.number().optional(),region:v.string().optional(),name:v.string().min(5,lo).max(63,lo).refine(e=>Gs(e),lo),instance_type:v.string().optional(),image:v.string().optional(),vcpu:v.number().optional(),memory:v.number().optional(),disk_size:v.number().optional(),compose_file:v.object({allowed_envs:v.array(v.string()).optional(),pre_launch_script:v.string().optional(),docker_compose_file:v.string().optional(),name:v.string().optional().default(""),kms_enabled:v.boolean().optional(),public_logs:v.boolean().optional(),public_sysinfo:v.boolean().optional(),gateway_enabled:v.boolean().optional(),tproxy_enabled:v.boolean().optional()}),listed:v.boolean().optional(),kms_id:v.string().optional(),kms:v.enum(["PHALA","ETHEREUM","BASE"]).optional(),kms_contract:v.string().optional(),env_keys:v.array(v.string()).optional(),nonce:v.number().optional(),app_id:v.string().optional()}).passthrough().transform(e=>!e.instance_type&&!e.vcpu&&!e.memory?{...e,instance_type:"tdx.small"}:e);function hl(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:xl,safeAction:gl}=k(ml,async(e,t)=>{let r=dl.parse(t),o=hl(r),n={...o};return typeof o.node_id=="number"?(n={...o,teepod_id:o.node_id},delete n.node_id):typeof o.teepod_id=="number"&&console.warn("[phala/cloud] teepod_id is deprecated, please use node_id instead."),await e.post("/cvms/provision",n)}),bl=C.object({id:C.number(),name:C.string(),status:C.string(),teepod_id:C.number(),teepod:C.object({id:C.number(),name:C.string()}).nullable(),user_id:C.number().nullable(),app_id:C.string().nullable(),vm_uuid:C.string().nullable(),instance_id:C.string().nullable(),app_url:C.string().nullable().default(null),base_image:C.string().nullable(),vcpu:C.number(),memory:C.number(),disk_size:C.number(),manifest_version:C.number().nullable().default(2),version:C.string().nullable().default("1.0.0"),runner:C.string().nullable().default("docker-compose"),docker_compose_file:C.string().nullable(),features:C.array(C.string()).nullable().default(["kms","tproxy-net"]),created_at:C.string(),encrypted_env_pubkey:C.string().nullable().optional(),app_auth_contract_address:C.string().nullable().optional(),deployer_address:C.string().nullable().optional()}).passthrough(),Ox=C.object({encrypted_env:C.string().optional().nullable(),app_id:C.string(),compose_hash:C.string(),kms_id:C.string().optional(),contract_address:C.string().optional(),deployer_address:C.string().optional(),env_keys:C.array(C.string()).optional().nullable()}).passthrough(),{action:yl,safeAction:vl}=k(bl,async(e,t)=>await e.post("/cvms",t)),Ds=D.object({allowed_envs:D.array(D.string()).optional(),docker_compose_file:D.string(),features:D.array(D.string()).optional(),name:D.string().optional(),manifest_version:D.number().optional(),kms_enabled:D.boolean().optional(),public_logs:D.boolean().optional(),public_sysinfo:D.boolean().optional(),tproxy_enabled:D.boolean().optional(),pre_launch_script:D.string().optional(),env_pubkey:D.string().optional(),salt:D.string().optional().nullable()}).passthrough();function po(e){return e==null?e:Array.isArray(e)?e.map(po):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=po(o),t},{}):e}function qs(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 Vs(e){let t=po(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function _l(e){let t=qs(e),r=Vs(t);return wl.createHash("sha256").update(r,"utf8").digest("hex")}function Cl(e){let t=e;return{...e,getHash:()=>_l(t),toString:()=>Vs(qs(t))}}var kl=Ds.transform(e=>Cl(e)),Tl=R,{action:Sl,safeAction:mo}=k(kl,async(e,t)=>{let{cvmId:r}=Tl.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),El=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(),app_compose:Ds,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,request:{...e.app_compose,update_env_vars:e.update_env_vars},_raw:e})),Il=ye.object({app_id:ye.string().nullable(),device_id:ye.string().nullable(),compose_hash:ye.string(),kms_info:Ee.nullable().optional()}).passthrough(),{action:Al,safeAction:Pl}=k(Il,async(e,t)=>{let r=El.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),Bl=me.object({id:me.string().optional(),uuid:me.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:me.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:me.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:me.string().min(1,"Compose hash is required"),encrypted_env:me.string().optional(),env_keys:me.array(me.string()).optional(),update_env_vars:me.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})),$l=me.any().transform(()=>{}),{action:Ll,safeAction:Rl}=k($l,async(e,t)=>{let r=Bl.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})}),Ul=Oe(He.extend({encrypted_env:j.string().describe("Encrypted environment variables (hex string)"),env_keys:j.array(j.string()).optional().describe("List of allowed environment variable keys"),compose_hash:j.string().optional().describe("Compose hash for verification (Phase 2, required when env_keys changes)"),transaction_hash:j.string().optional().describe("On-chain transaction hash for verification (Phase 2, required when env_keys changes)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{encrypted_env:e.encrypted_env,env_keys:e.env_keys,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),zl=j.object({status:j.literal("in_progress"),message:j.string(),correlation_id:j.string(),allowed_envs_changed:j.boolean()}),Fl=j.object({status:j.literal("precondition_required"),message:j.string(),compose_hash:j.string(),app_id:j.string(),device_id:j.string(),kms_info:Ee}),Hl=j.union([zl,Fl]),{action:Ol,safeAction:jl}=k(Hl,async(e,t)=>{let r=Ul.parse(t);try{return await e.patch(`/cvms/${r.cvmId}/envs`,r.request)}catch(o){if(o instanceof we&&o.status===465){let n=o.detail;if(n&&typeof n=="object"){let s=n;return{status:"precondition_required",message:s.message||"Compose hash verification required",compose_hash:s.compose_hash,app_id:s.app_id,device_id:s.device_id,kms_info:s.kms_info}}}throw o}}),Nl=Oe(He.extend({docker_compose_file:Y.string().describe("Docker Compose YAML content"),compose_hash:Y.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:Y.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{docker_compose_file:e.docker_compose_file,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Ml=Y.object({status:Y.literal("in_progress"),message:Y.string(),correlation_id:Y.string()}),Gl=Y.object({status:Y.literal("precondition_required"),message:Y.string(),compose_hash:Y.string(),app_id:Y.string(),device_id:Y.string(),kms_info:Ee}),Dl=Y.union([Ml,Gl]),{action:ql,safeAction:Vl}=k(Dl,async(e,t)=>{let r=Nl.parse(t),o={"Content-Type":"text/yaml"};r.request.compose_hash&&(o["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(o["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/docker-compose`,r.request.docker_compose_file,{headers:o})}catch(n){if(n instanceof we&&n.status===465){let s=n.detail;if(s&&typeof s=="object"){let i=s;return{status:"precondition_required",message:i.message||"Compose hash verification required",compose_hash:i.compose_hash,app_id:i.app_id,device_id:i.device_id,kms_info:i.kms_info}}}throw n}}),Kl=Oe(He.extend({pre_launch_script:Q.string().describe("Pre-launch script content (shell script)"),compose_hash:Q.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:Q.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{pre_launch_script:e.pre_launch_script,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Wl=Q.object({status:Q.literal("in_progress"),message:Q.string(),correlation_id:Q.string()}),Xl=Q.object({status:Q.literal("precondition_required"),message:Q.string(),compose_hash:Q.string(),app_id:Q.string(),device_id:Q.string(),kms_info:Ee}),Jl=Q.union([Wl,Xl]),{action:Zl,safeAction:Yl}=k(Jl,async(e,t)=>{let r=Kl.parse(t),o={"Content-Type":"text/plain"};r.request.compose_hash&&(o["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(o["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/pre-launch-script`,r.request.pre_launch_script,{headers:o})}catch(n){if(n instanceof we&&n.status===465){let s=n.detail;if(s&&typeof s=="object"){let i=s;return{status:"precondition_required",message:i.message||"Compose hash verification required",compose_hash:i.compose_hash,app_id:i.app_id,device_id:i.device_id,kms_info:i.kms_info}}}throw n}}),ep=R,{action:tp,safeAction:rp}=k(Ql.string(),async(e,t)=>{let{cvmId:r}=ep.parse(t);return await e.get(`/cvms/${r}/pre-launch-script`)}),op=As.object({kms_id:As.string().min(1,"KMS ID is required")}),{action:np,safeAction:sp}=k(Ee,async(e,t)=>{let r=op.parse(t);return await e.get(`/kms/${r.kms_id}`)}),ip=ve.object({page:ve.number().int().min(1).optional(),page_size:ve.number().int().min(1).optional(),is_onchain:ve.boolean().optional()}).strict(),ap=ve.object({items:ve.array(Ee),total:ve.number(),page:ve.number(),page_size:ve.number(),pages:ve.number()}).strict(),{action:cp,safeAction:lp}=k(ap,async(e,t)=>{let r=ip.parse(t??{});return await e.get("/kms",{params:r})}),pp=mt.object({kms:mt.string().min(1,"KMS ID or slug is required"),app_id:mt.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(),up=mt.object({public_key:mt.string(),signature:mt.string()}).strict(),{action:fp,safeAction:mp}=k(up,async(e,t)=>{let r=pp.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),dp=Je.object({counts:Je.number().int().min(1).max(20).optional().default(1)}).strict(),hp=Je.object({app_ids:Je.array(Je.object({app_id:Je.string(),nonce:Je.number().int().min(0)}))}).strict(),{action:xp,safeAction:gp}=k(hp,async(e,t)=>{let r=dp.parse(t??{}),o=new URLSearchParams;return o.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${o.toString()}`)}),bp=R,{action:yp,safeAction:vp}=k(vr,async(e,t)=>{let{cvmId:r}=bp.parse(t);return await e.post(`/cvms/${r}/start`)}),wp=R,{action:_p,safeAction:Cp}=k(vr,async(e,t)=>{let{cvmId:r}=wp.parse(t);return await e.post(`/cvms/${r}/stop`)}),kp=R,{action:Tp,safeAction:Sp}=k(vr,async(e,t)=>{let{cvmId:r}=kp.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),Ip=Oe(He.extend({force:Ep.boolean().optional()})),{action:Ap,safeAction:Pp}=k(vr,async(e,t)=>{let r=Ip.parse(t),{cvmId:o}=R.parse(r),{force:n=!1}=r;return await e.post(`/cvms/${o}/restart`,{force:n})}),$p=R,{action:Lp,safeAction:Rp}=k(Bp.void(),async(e,t)=>{let{cvmId:r}=$p.parse(t);await e.delete(`/cvms/${r}`)}),Up=E.object({name:E.string(),mount_point:E.string(),total_size:E.number(),free_size:E.number()}),zp=E.object({os_name:E.string(),os_version:E.string(),kernel_version:E.string(),cpu_model:E.string(),num_cpus:E.number(),total_memory:E.number(),available_memory:E.number(),used_memory:E.number(),free_memory:E.number(),total_swap:E.number(),used_swap:E.number(),free_swap:E.number(),uptime:E.number(),loadavg_one:E.number(),loadavg_five:E.number(),loadavg_fifteen:E.number(),disks:E.array(Up)}),Fp=E.object({is_online:E.boolean(),is_public:E.boolean().default(!1),error:E.string().nullable(),sysinfo:zp.nullable(),status:E.string().nullable(),in_progress:E.boolean().default(!1),boot_progress:E.string().nullable(),boot_error:E.string().nullable()}),Hp=R,{action:Op,safeAction:jp}=k(Fp,async(e,t)=>{let{cvmId:r}=Hp.parse(t);return await e.get(`/cvms/${r}/stats`)}),Np=be.object({app:be.string(),instance:be.string()}),Mp=be.object({is_online:be.boolean(),is_public:be.boolean().default(!0),error:be.string().nullable(),internal_ip:be.string().nullable(),latest_handshake:be.string().nullable(),public_urls:be.array(Np).nullable()}),Gp=R,{action:Dp,safeAction:qp}=k(Mp,async(e,t)=>{let{cvmId:r}=Gp.parse(t);return await e.get(`/cvms/${r}/network`)}),Kp=R,{action:Wp,safeAction:Xp}=k(Vp.string(),async(e,t)=>{let{cvmId:r}=Kp.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),Jp=$.object({id:$.string(),names:$.array($.string()),image:$.string(),image_id:$.string(),command:$.string().nullable().optional(),created:$.number(),state:$.string(),status:$.string(),log_endpoint:$.string().nullable()}),Zp=$.object({is_online:$.boolean(),is_public:$.boolean().default(!0),error:$.string().nullable(),docker_compose_file:$.string().nullable(),manifest_version:$.number().nullable(),version:$.string().nullable(),runner:$.string().nullable(),features:$.array($.string()).nullable(),containers:$.array(Jp).nullable()}),Yp=R,{action:Qp,safeAction:eu}=k(Zp,async(e,t)=>{let{cvmId:r}=Yp.parse(t);return await e.get(`/cvms/${r}/composition`)}),tu=g.object({common_name:g.string().nullable(),organization:g.string().nullable(),country:g.string().nullable(),state:g.string().nullable(),locality:g.string().nullable()}),ru=g.object({common_name:g.string().nullable(),organization:g.string().nullable(),country:g.string().nullable()}),ou=g.object({subject:tu,issuer:ru,serial_number:g.string(),not_before:g.string(),not_after:g.string(),version:g.string(),fingerprint:g.string(),signature_algorithm:g.string(),sans:g.array(g.string()).nullable(),is_ca:g.boolean(),position_in_chain:g.number().nullable(),quote:g.string().nullable(),app_id:g.string().nullable().optional(),cert_usage:g.string().nullable().optional()}),nu=g.object({imr:g.number(),event_type:g.number(),digest:g.string(),event:g.string(),event_payload:g.string()}),su=g.object({mrtd:g.string(),rootfs_hash:g.string().nullable().optional(),rtmr0:g.string(),rtmr1:g.string(),rtmr2:g.string(),rtmr3:g.string(),event_log:g.array(nu),app_compose:g.string()}),iu=g.object({name:g.string().nullable(),is_online:g.boolean(),is_public:g.boolean().default(!0),error:g.string().nullable(),app_certificates:g.array(ou).nullable(),tcb_info:su.nullable(),compose_file:g.string().nullable()}),au=R,{action:cu,safeAction:lu}=k(iu,async(e,t)=>{let{cvmId:r}=au.parse(t);return await e.get(`/cvms/${r}/attestation`)}),pu=Oe(He.extend({vcpu:ft.number().optional(),memory:ft.number().optional(),disk_size:ft.number().optional(),instance_type:ft.string().optional(),allow_restart:ft.boolean().optional()})),{action:uu,safeAction:fu}=k(ft.void(),async(e,t)=>{let r=pu.parse(t),{cvmId:o}=R.parse(r),{...n}=r;await e.patch(`/cvms/${o}/resources`,n)}),mu=Oe(He.extend({public_sysinfo:Ps.boolean(),public_logs:Ps.boolean()})),{action:du,safeAction:hu}=k(Ms,async(e,t)=>{let r=mu.parse(t),{cvmId:o}=R.parse(r),{public_sysinfo:n,public_logs:s}=r;return await e.patch(`/cvms/${o}/visibility`,{public_sysinfo:n,public_logs:s})}),Bs=G.object({name:G.string(),os_image_hash:G.string().nullable(),is_current:G.boolean()}),xu=G.object({version:G.union([G.tuple([G.number(),G.number(),G.number(),G.number()]),G.tuple([G.number(),G.number(),G.number()])]),prod:Bs.nullable(),dev:Bs.nullable()}),gu=G.array(xu),bu=R,{action:yu,safeAction:vu}=k(gu,async(e,t)=>{let{cvmId:r}=bu.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),wu=Oe(He.extend({os_image_name:Ks.string().min(1,"OS image name is required")})),{action:_u,safeAction:Cu}=k(Ks.void(),async(e,t)=>{let r=wu.parse(t),{cvmId:o}=R.parse(r),{os_image_name:n}=r;await e.patch(`/cvms/${o}/os-image`,{os_image_name:n})}),ku=ge.object({id:ge.string().optional(),instance_id:ge.string().optional(),name:ge.string(),status:ge.string(),uptime:ge.string().optional(),exited_at:ge.string().optional(),boot_progress:ge.string().optional(),boot_error:ge.string().optional(),shutdown_progress:ge.string().optional()}),Tu=R,{action:Su,safeAction:Eu}=k(ku,async(e,t)=>{let{cvmId:r}=Tu.parse(t);return await e.get(`/cvms/${r}/state`)});function Ws(e={}){let t=$c(e),r={getCurrentUser:Rc,safeGetCurrentUser:Uc,getAvailableNodes:Mc,safeGetAvailableNodes:Gc,listAllInstanceTypeFamilies:Wc,safeListAllInstanceTypeFamilies:Xc,listFamilyInstanceTypes:Jc,safeListFamilyInstanceTypes:Zc,listWorkspaces:el,safeListWorkspaces:tl,getWorkspace:rl,safeGetWorkspace:ol,getCvmInfo:ll,safeGetCvmInfo:dt,getCvmList:fl,safeGetCvmList:fo,provisionCvm:xl,safeProvisionCvm:gl,commitCvmProvision:yl,safeCommitCvmProvision:vl,getCvmComposeFile:Sl,safeGetCvmComposeFile:mo,provisionCvmComposeFileUpdate:Al,safeProvisionCvmComposeFileUpdate:Pl,commitCvmComposeFileUpdate:Ll,safeCommitCvmComposeFileUpdate:Rl,updateCvmEnvs:Ol,safeUpdateCvmEnvs:jl,updateDockerCompose:ql,safeUpdateDockerCompose:Vl,updatePreLaunchScript:Zl,safeUpdatePreLaunchScript:Yl,getCvmPreLaunchScript:tp,safeGetCvmPreLaunchScript:rp,startCvm:yp,safeStartCvm:vp,stopCvm:_p,safeStopCvm:Cp,shutdownCvm:Tp,safeShutdownCvm:Sp,restartCvm:Ap,safeRestartCvm:Pp,deleteCvm:Lp,safeDeleteCvm:Rp,getCvmStats:Op,safeGetCvmStats:jp,getCvmNetwork:Dp,safeGetCvmNetwork:qp,getCvmDockerCompose:Wp,safeGetCvmDockerCompose:Xp,getCvmContainersStats:Qp,safeGetCvmContainersStats:eu,getCvmAttestation:cu,safeGetCvmAttestation:lu,updateCvmResources:uu,safeUpdateCvmResources:fu,updateCvmVisibility:du,safeUpdateCvmVisibility:hu,getAvailableOsImages:yu,safeGetAvailableOsImages:vu,updateOsImage:_u,safeUpdateOsImage:Cu,getKmsInfo:np,safeGetKmsInfo:sp,getKmsList:cp,safeGetKmsList:lp,getAppEnvEncryptPubKey:fp,safeGetAppEnvEncryptPubKey:mp,nextAppIds:xp,safeNextAppIds:gp,getCvmState:Su,safeGetCvmState:Eu};return t.extend(r)}var Iu=U.object({chain:U.unknown().optional(),rpcUrl:U.string().optional(),kmsContractAddress:U.string(),privateKey:U.string().optional(),walletClient:U.unknown().optional(),publicClient:U.unknown().optional(),allowAnyDevice:U.boolean().optional().default(!1),deviceId:U.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),composeHash:U.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),disableUpgrades:U.boolean().optional().default(!1),skipPrerequisiteChecks:U.boolean().optional().default(!1),minBalance:U.string().optional()}).passthrough(),mg=Iu.refine(e=>{let t=!!e.privateKey,r=!!e.walletClient;return t!==r},{message:"Either 'privateKey' or 'walletClient' must be provided, but not both",path:["privateKey","walletClient"]}).refine(e=>{let t=!!e.publicClient,r=!!e.walletClient,o=!!e.chain;return t&&r?!0:o},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),dg=U.object({appId:U.string(),appAuthAddress:U.string(),deployer:U.string(),transactionHash:U.string(),blockNumber:U.bigint().optional(),gasUsed:U.bigint().optional()}).passthrough();var xg=B.object({chain:B.unknown().optional(),rpcUrl:B.string().optional(),appId:B.string(),composeHash:B.string(),privateKey:B.string().optional(),walletClient:B.unknown().optional(),publicClient:B.unknown().optional(),skipPrerequisiteChecks:B.boolean().optional().default(!1),minBalance:B.string().optional(),timeout:B.number().optional().default(12e4),retryOptions:B.unknown().optional(),signal:B.unknown().optional(),onTransactionStateChange:B.function().optional(),onTransactionSubmitted:B.function().optional(),onTransactionConfirmed:B.function().optional()}).passthrough().refine(e=>{let t=!!e.privateKey,r=!!e.walletClient;return t!==r},{message:"Either 'privateKey' or 'walletClient' must be provided, but not both",path:["privateKey","walletClient"]}).refine(e=>{let t=!!e.publicClient,r=!!e.walletClient,o=!!e.chain;return t&&r?!0:o},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),gg=B.object({composeHash:B.string(),appId:B.string(),transactionHash:B.string(),blockNumber:B.bigint().optional(),gasUsed:B.bigint().optional()}).passthrough();var yg=ut.object({target:ut.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:ut.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:ut.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:ut.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:ut.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});var Au=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()}),Pu=q.record(q.string(),Au),Bu=q.object({vmUuids:q.array(q.string())}),{action:wg,safeAction:_g}=k(Pu,async(e,t)=>{let{vmUuids:r}=Bu.parse(t);return await e.post("/status/batch",{vm_uuids:r})});import Ys from"crypto";import Js from"fs";import ht from"os";import ho from"path";import V from"chalk";import zu from"ora";var Uu=!1;function de(){return Uu}function Fu(e,t){let r=e.split(/\s+/),o=[],n="";for(let s of r){let i=n.length===0?s:`${n} ${s}`;i.length<=t?n=i:(n.length>0&&o.push(n),n=s)}return n.length>0&&o.push(n),o}function Hu(e,t){if(e.length<=t)return[e];let r=[],o=0;for(;o<e.length;)r.push(e.slice(o,o+t)),o+=t;return r}function Xs(e,t){let r=[];for(let o of e.split(`
26
+ `)){if(o.length<=t){r.push(o);continue}if(o.indexOf(" ")===-1){r.push(...Hu(o,t));continue}let n=Fu(o,t);r.push(...n)}if(r.length===0){let o=e.trim();r.push(o)}return r}var je={error:(e,...t)=>{de()||(process.stderr.write(`${V.red("\u2717")} ${V.red(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
27
+ `))},warn:(e,...t)=>{de()||(process.stderr.write(`${V.yellow("\u26A0")} ${V.yellow(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
28
+ `))},info:(e,...t)=>{de()||(process.stderr.write(`${V.blue("\u2139")} ${V.blue(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
29
+ `))},success:(e,...t)=>{de()||(process.stderr.write(`${V.green("\u2713")} ${V.green(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
30
+ `))},debug:(e,...t)=>{de()||process.env.DEBUG&&(process.stderr.write(`${V.gray("\u{1F50D}")} ${V.gray(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
31
+ `))},table:(e,t)=>{if(!de()){if(e.length===0){console.log(V.yellow("No data to display"));return}if(t){let r;typeof t[0]=="string"?r=t.map(i=>({key:i,header:i})):r=t;let o={};for(let i of r){let a=i.header||String(i.key);o[String(i.key)]=a.length}for(let i of e)for(let a of r){let l=String(typeof a.key=="string"&&!(a.key in i)?"":i[String(a.key)]??"");o[String(a.key)]=Math.max(o[String(a.key)],l.length)}let n=[];for(let i of r){let a=i.header||String(i.key);n.push(V.bold(a.padEnd(o[String(i.key)])))}console.log(n.join(" "));let s=[];for(let i of r)s.push("-".repeat(o[String(i.key)]));console.log(s.join(" "));for(let i of e){let a=[];for(let l of r){let f=String(typeof l.key=="string"&&!(l.key in i)?"":i[String(l.key)]??"");a.push(f.padEnd(o[String(l.key)]))}console.log(a.join(" "))}}else{let r=e[0],o=Object.keys(r),n={};for(let a of o)n[a]=a.length;for(let a of e)for(let l of o){let f=String(a[l]??"");n[l]=Math.max(n[l],f.length)}let s=[];for(let a of o)s.push(V.bold(a.padEnd(n[a])));console.log(s.join(" "));let i=[];for(let a of o)i.push("-".repeat(n[a]));console.log(i.join(" "));for(let a of e){let l=[];for(let f of o){let m=String(a[f]??"");l.push(m.padEnd(n[f]))}console.log(l.join(" "))}}}},keyValueTable:(e,t)=>{if(de())return;let{borderStyle:r="single",keyColor:o=V.blue,valueColor:n=V.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,f=0;for(let[I,T]of Object.entries(e)){l=Math.max(l,I.length);let P=String(T??"");f=Math.max(f,P.length)}let m=4,p=1,d=s-m-p;if(l+f>d){let I=l/(l+f);l=Math.floor(d*I),f=d-l}let h=l+f+m+p;r!=="none"&&console.log(a.topLeft+a.horizontal.repeat(h-2)+a.topRight);for(let[I,T]of Object.entries(e)){let P=I,K=String(T??""),W=Xs(P,l),O=Xs(K,f),ee=Math.max(W.length,O.length);for(;W.length<ee;)W.push("");for(;O.length<ee;)O.push("");for(let le=0;le<ee;le++){let re=W[le].padEnd(l),Ut=O[le].padEnd(f);console.log(r!=="none"?`${a.vertical} ${o(re)} ${a.vertical} ${n(Ut)} ${a.vertical}`:`${o(re)} : ${n(Ut)}`)}}r!=="none"&&console.log(a.bottomLeft+a.horizontal.repeat(h-2)+a.bottomRight)},break:()=>{de()||process.stderr.write(`
32
+ `)},startSpinner:e=>{if(de())return{stop:()=>{}};let t=zu(e).start();return{stop:(r=!0,o)=>{o&&(t.text=o),r?t.succeed():t.fail()}}},logDetailedError(e,t){if(de())return;let r=t?`[${t}] `:"",o=s=>s!==null&&typeof s=="object"&&"isRequestError"in s&&s.isRequestError===!0&&"status"in s&&"message"in s&&"data"in s,n=s=>s!==null&&typeof s=="object"&&"issues"in s&&Array.isArray(s.issues);if(o(e)){process.stderr.write(`${r}HTTP ${e.status}: ${e.message}
33
33
  `),e.data!==void 0&&e.data!==null&&process.stderr.write(`${JSON.stringify(e.data,null,2)}
34
34
  `);return}if(n(e)){process.stderr.write(`${r}Validation error: ${JSON.stringify(e.issues)}
35
35
  `);return}e instanceof Error?process.stderr.write(`${r}${e.message}
36
36
  `):process.stderr.write(`${r}${String(e)}
37
- `)}};var Zs=mo.join(dt.homedir(),".phala-cloud"),Xs=mo.join(Zs,"api-key"),zg=mo.join(Zs,"docker-credentials.json");function Ru(){let e=[dt.hostname(),dt.platform(),dt.arch(),dt.cpus()[0]?.model||"",dt.userInfo().username],t=Js.createHash("sha256");return t.update(e.join("|")),t.digest()}function Uu(e){try{let t=Ru(),r=e.split(":");if(r.length!==2)throw new Error("Invalid encrypted format");let o=Buffer.from(r[0],"hex"),n=r[1],s=Js.createDecipheriv("aes-256-cbc",t.slice(0,32),o),i=s.update(n,"hex","utf8");return i+=s.final("utf8"),i}catch(t){throw Oe.error("Decryption failed:",t),new Error("Failed to decrypt data")}}function Ys(){try{if(process.env.PHALA_CLOUD_API_KEY)return process.env.PHALA_CLOUD_API_KEY;if(Ws.existsSync(Xs)){let e=Ws.readFileSync(Xs,"utf8").trim();return Uu(e)}return null}catch(e){return Oe.error("Failed to read API key:",e),null}}async function N(){let e=Ys();return Vs({apiKey:e})}import{z as c}from"zod";var zu=c.object({password:c.string(),registry:c.string().nullable(),username:c.string()}),Mg=c.object({docker_compose_file:c.string(),docker_config:zu.optional().nullable(),features:c.array(c.string()),kms_enabled:c.boolean(),manifest_version:c.number(),name:c.string(),public_logs:c.boolean(),public_sysinfo:c.boolean(),runner:c.string().optional(),salt:c.string().nullable().optional(),tproxy_enabled:c.boolean(),version:c.string().optional()}).passthrough(),Qs=c.object({id:c.number(),name:c.string(),status:c.string(),teepod_id:c.number().nullable(),teepod:c.object({id:c.number(),name:c.string()}).nullable(),user_id:c.number().nullable(),app_id:c.string(),vm_uuid:c.string().nullable(),instance_id:c.string().nullable(),app_url:c.string().nullable(),base_image:c.string().nullable(),vcpu:c.number(),memory:c.number(),disk_size:c.number(),manifest_version:c.number().nullable(),version:c.string().nullable(),runner:c.string().nullable(),docker_compose_file:c.string().nullable(),features:c.array(c.string()).nullable(),created_at:c.string(),encrypted_env_pubkey:c.string().nullable()}),Gg=c.object({key:c.string(),value:c.string()}),ei=c.object({is_online:c.boolean(),is_public:c.boolean(),error:c.string().nullable(),internal_ip:c.string(),latest_handshake:c.string(),public_urls:c.array(c.object({app:c.string(),instance:c.string()}))}),ti=c.object({id:c.number(),name:c.string(),status:c.string(),teepod_id:c.number(),teepod:c.object({id:c.number(),name:c.string()}),user_id:c.number().nullable(),app_id:c.string(),vm_uuid:c.string().nullable(),instance_id:c.string().nullable(),app_url:c.string().nullable(),base_image:c.string().nullable(),vcpu:c.number(),memory:c.number(),disk_size:c.number(),manifest_version:c.number().nullable(),version:c.string().nullable(),runner:c.string().nullable(),docker_compose_file:c.string().nullable(),features:c.array(c.string()).nullable(),created_at:c.string(),encrypted_env_pubkey:c.string().nullable()}),ri=c.object({is_online:c.boolean(),is_public:c.boolean(),error:c.string().nullable(),app_certificates:c.array(c.object({subject:c.object({common_name:c.string().nullable(),organization:c.string().nullable(),country:c.string().nullable(),state:c.string().nullable().optional(),locality:c.string().nullable().optional()}),issuer:c.object({common_name:c.string().nullable(),organization:c.string().nullable(),country:c.string().nullable()}),serial_number:c.string(),not_before:c.string(),not_after:c.string(),version:c.string(),fingerprint:c.string(),signature_algorithm:c.string(),sans:c.string().nullable(),is_ca:c.boolean(),position_in_chain:c.number(),quote:c.string().nullable()})).nullable(),tcb_info:c.object({mrtd:c.string(),rootfs_hash:c.string(),rtmr0:c.string(),rtmr1:c.string(),rtmr2:c.string(),rtmr3:c.string(),event_log:c.array(c.object({imr:c.number(),event_type:c.number(),digest:c.string(),event:c.string(),event_payload:c.string()}))}).nullable(),compose_file:c.string().nullable()}),Fu=c.object({name:c.string(),description:c.string().optional(),version:c.array(c.number()).optional(),is_dev:c.boolean().optional(),os_image_hash:c.string().nullable().optional(),rootfs_hash:c.string().optional(),shared_ro:c.boolean().optional(),cmdline:c.string().optional(),kernel:c.string().optional(),initrd:c.string().optional(),hda:c.string().nullable().optional(),rootfs:c.string().optional(),bios:c.string().optional()}),Dg=c.object({teepod_id:c.number().nullable(),id:c.number().optional(),name:c.string(),listed:c.boolean().optional(),resource_score:c.number().optional(),remaining_vcpu:c.number().optional(),remaining_memory:c.number().optional(),remaining_cvm_slots:c.number().optional(),images:c.array(Fu).optional(),region_identifier:c.string().optional(),dedicated_for_team_id:c.number().nullable().optional(),support_onchain_kms:c.boolean().optional(),fmspc:c.string().nullable().optional(),device_id:c.string().nullable().optional()});import Hu from"inquirer";async function Ou(e){let t=await N(),r=e.replace(/^app_/,""),o=await mt(t,{app_id:r});if(!o.success)throw new Error(o.error.message);return o.data}async function Zg(e){let t=await N(),r=await fo(t,{id:e});if(!r.success)throw new Error(r.error.message);return r.data}async function Yg(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/network`);return ei.parse(o)}async function Qg(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.post(`cvms/app_${r}/start`);return(await mt(t,{app_id:r})).data}async function eb(e){let t=await N(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/stop`),(await mt(t,{app_id:r})).data}async function tb(e){let t=await N(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/restart`),(await mt(t,{app_id:r})).data}async function rb(e){let t=await N(),r=e.replace(/^app_/,"");return await t.delete(`cvms/app_${r}`),!0}async function ob(){let e=Oe.startSpinner("Fetching available CVMs"),t=await N(),r=await uo(t);if(e.stop(!0),!r.success){Oe.error(`Failed to fetch CVMs: ${r.error.message}`);return}let n=r.data.items;if(!n||n.length===0){Oe.info("No CVMs found for your account");return}let s=n.map(a=>{let l=a,u=l.hosted?.app_id||l.hosted?.id,f=l.name||l.hosted?.name,p=l.status||l.hosted?.status;return{name:`${f||"Unnamed"} (${u}) - Status: ${p||"Unknown"}`,value:u}}),{selectedCvm:i}=await Hu.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:s}]);return i}async function nb(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/attestation`);try{return ri.parse(o)}catch(n){return Oe.debug(`Validation error: ${n instanceof Error?n.message:String(n)}`),{is_online:!!o?.is_online,is_public:!!o?.is_public,error:typeof o?.error=="string"?o.error:null,app_certificates:Array.isArray(o?.app_certificates)?o.app_certificates:null,tcb_info:o?.tcb_info||null,compose_file:typeof o?.compose_file=="string"?o.compose_file:null}}}async function sb(e,t){let r=await N(),o=e.replace(/^app_/,""),n=await r.post(`cvms/app_${o}/replicas`,t);return ti.parse(n)}async function ib(e,t,r,o,n){let s=await N(),i=e.replace(/^app_/,""),a={};if(t!==void 0&&(a.vcpu=t),r!==void 0&&(a.memory=r),o!==void 0&&(a.disk_size=o),n!==void 0&&(a.allow_restart=n),Object.keys(a).length===0)throw new Error("At least one resource parameter must be provided");return await s.patch(`cvms/app_${i}/resources`,a),!0}async function ab(e){return await(await N()).post("cvms/pubkey/from_cvm_configuration",e)}async function cb(e){let r=await(await N()).post("cvms/from_cvm_configuration",e);return Qs.parse(r)}async function lb(e,t){let r=await N(),o=e.replace(/^app_/,"");return await r.put(`cvms/app_${o}/compose`,t)}async function pb(e=!1){let t=await N(),r="teepods/available";return e&&(r+="?v03x_only=1"),await t.get(r)}function vr(e,t){let r=[];t.follow&&r.push("follow"),t.tail&&r.push(`lines=${t.tail}`),t.timestamps&&r.push("timestamps"),r.push("ansi");let o=e.includes("?")?"&":"?";return e+o+r.join("&")}async function oi(e,t){let r=e.body?.getReader();if(!r)throw new Error("No response body available for streaming");let o=new TextDecoder;for(;;){let{done:n,value:s}=await r.read();if(n)break;t(o.decode(s,{stream:!0}))}}async function ni(e){let t=await Ou(e);if(!t.syslog_endpoint)throw new Error(`No syslog endpoint available for CVM '${e}'`);return`${t.syslog_endpoint}&ch=serial`}async function si(e,t){let o=await(await N()).get(`cvms/${e}/composition`);if(!o.containers?.length)throw new Error(`No containers found for CVM '${e}'`);let n=o.containers;if(t&&(n=n.filter(i=>i.names.some(a=>a===t||a===`/${t}`)||i.id.startsWith(t)),!n.length))throw new Error(`Container '${t}' not found in CVM '${e}'`);let s=n.find(i=>i.log_endpoint);if(!s?.log_endpoint)throw new Error(`No log endpoints available for CVM '${e}'`);return s.log_endpoint}async function ub(e,t={}){let r=await ni(e),o=vr(r,t),n=await fetch(o);if(!n.ok)throw new Error(`Failed to fetch serial logs: ${n.status} ${n.statusText}`);return n.text()}async function fb(e,t={}){let r=await si(e,t.container),o=vr(r,t),n=await fetch(o);if(!n.ok)throw new Error(`Failed to fetch container logs: ${n.status} ${n.statusText}`);return n.text()}async function mb(e,t,r={},o){let n=await ni(e),s=vr(n,{...r,follow:!0}),i=await fetch(s,{signal:o});if(!i.ok)throw new Error(`Failed to stream serial logs: ${i.status} ${i.statusText}`);await oi(i,t)}async function db(e,t,r={},o){let n=await si(e,r.container),s=vr(n,{...r,follow:!0}),i=await fetch(s,{signal:o});if(!i.ok)throw new Error(`Failed to stream container logs: ${i.status} ${i.statusText}`);await oi(i,t)}export{Mg as composeFileSchema,cb as createCvm,ri as cvmAttestationResponseSchema,rb as deleteCvm,zu as dockerConfigSchema,Gg as encryptedEnvItemSchema,fb as fetchContainerLogs,ub as fetchSerialLogs,nb as getCvmAttestation,Ou as getCvmByAppId,Zg as getCvmComposeConfig,Yg as getCvmNetwork,ei as getCvmNetworkResponseSchema,ab as getPubkeyFromCvm,pb as getTeepods,Fu as imageSchema,Qs as postCvmResponseSchema,sb as replicateCvm,ti as replicateCvmResponseSchema,ib as resizeCvm,tb as restartCvm,ob as selectCvm,Qg as startCvm,eb as stopCvm,db as streamContainerLogs,mb as streamSerialLogs,Dg as teepodSchema,lb as upgradeCvm};
37
+ `)}};var Qs=ho.join(ht.homedir(),".phala-cloud"),Zs=ho.join(Qs,"api-key"),Dg=ho.join(Qs,"docker-credentials.json");function Ou(){let e=[ht.hostname(),ht.platform(),ht.arch(),ht.cpus()[0]?.model||"",ht.userInfo().username],t=Ys.createHash("sha256");return t.update(e.join("|")),t.digest()}function ju(e){try{let t=Ou(),r=e.split(":");if(r.length!==2)throw new Error("Invalid encrypted format");let o=Buffer.from(r[0],"hex"),n=r[1],s=Ys.createDecipheriv("aes-256-cbc",t.slice(0,32),o),i=s.update(n,"hex","utf8");return i+=s.final("utf8"),i}catch(t){throw je.error("Decryption failed:",t),new Error("Failed to decrypt data")}}function ei(){try{if(process.env.PHALA_CLOUD_API_KEY)return process.env.PHALA_CLOUD_API_KEY;if(Js.existsSync(Zs)){let e=Js.readFileSync(Zs,"utf8").trim();return ju(e)}return null}catch(e){return je.error("Failed to read API key:",e),null}}async function N(){let e=ei();return Ws({apiKey:e})}import{z as c}from"zod";var Nu=c.object({password:c.string(),registry:c.string().nullable(),username:c.string()}),Jg=c.object({docker_compose_file:c.string(),docker_config:Nu.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(),ti=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()}),Zg=c.object({key:c.string(),value:c.string()}),ri=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()}))}),oi=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()}),ni=c.object({is_online:c.boolean(),is_public:c.boolean(),error:c.string().nullable(),app_certificates:c.array(c.object({subject:c.object({common_name:c.string().nullable(),organization:c.string().nullable(),country:c.string().nullable(),state:c.string().nullable().optional(),locality:c.string().nullable().optional()}),issuer:c.object({common_name:c.string().nullable(),organization:c.string().nullable(),country:c.string().nullable()}),serial_number:c.string(),not_before:c.string(),not_after:c.string(),version:c.string(),fingerprint:c.string(),signature_algorithm:c.string(),sans:c.string().nullable(),is_ca:c.boolean(),position_in_chain:c.number(),quote:c.string().nullable()})).nullable(),tcb_info:c.object({mrtd:c.string(),rootfs_hash:c.string(),rtmr0:c.string(),rtmr1:c.string(),rtmr2:c.string(),rtmr3:c.string(),event_log:c.array(c.object({imr:c.number(),event_type:c.number(),digest:c.string(),event:c.string(),event_payload:c.string()}))}).nullable(),compose_file:c.string().nullable()}),Mu=c.object({name:c.string(),description:c.string().optional(),version:c.array(c.number()).optional(),is_dev:c.boolean().optional(),os_image_hash:c.string().nullable().optional(),rootfs_hash:c.string().optional(),shared_ro:c.boolean().optional(),cmdline:c.string().optional(),kernel:c.string().optional(),initrd:c.string().optional(),hda:c.string().nullable().optional(),rootfs:c.string().optional(),bios:c.string().optional()}),Yg=c.object({teepod_id:c.number().nullable(),id:c.number().optional(),name:c.string(),listed:c.boolean().optional(),resource_score:c.number().optional(),remaining_vcpu:c.number().optional(),remaining_memory:c.number().optional(),remaining_cvm_slots:c.number().optional(),images:c.array(Mu).optional(),region_identifier:c.string().optional(),dedicated_for_team_id:c.number().nullable().optional(),support_onchain_kms:c.boolean().optional(),fmspc:c.string().nullable().optional(),device_id:c.string().nullable().optional()});import Gu from"inquirer";async function Du(e){let t=await N(),r=e.replace(/^app_/,""),o=await dt(t,{app_id:r});if(!o.success)throw new Error(o.error.message);return o.data}async function sb(e){let t=await N(),r=await mo(t,{id:e});if(!r.success)throw new Error(r.error.message);return r.data}async function ib(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/network`);return ri.parse(o)}async function ab(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.post(`cvms/app_${r}/start`);return(await dt(t,{app_id:r})).data}async function cb(e){let t=await N(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/stop`),(await dt(t,{app_id:r})).data}async function lb(e){let t=await N(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/restart`),(await dt(t,{app_id:r})).data}async function pb(e){let t=await N(),r=e.replace(/^app_/,"");return await t.delete(`cvms/app_${r}`),!0}async function ub(){let e=je.startSpinner("Fetching available CVMs"),t=await N(),r=await fo(t);if(e.stop(!0),!r.success){je.error(`Failed to fetch CVMs: ${r.error.message}`);return}let n=r.data.items;if(!n||n.length===0){je.info("No CVMs found for your account");return}let s=n.map(a=>{let l=a,f=l.hosted?.app_id||l.hosted?.id,m=l.name||l.hosted?.name,p=l.status||l.hosted?.status;return{name:`${m||"Unnamed"} (${f}) - Status: ${p||"Unknown"}`,value:f}}),{selectedCvm:i}=await Gu.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:s}]);return i}async function fb(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/attestation`);try{return ni.parse(o)}catch(n){return je.debug(`Validation error: ${n instanceof Error?n.message:String(n)}`),{is_online:!!o?.is_online,is_public:!!o?.is_public,error:typeof o?.error=="string"?o.error:null,app_certificates:Array.isArray(o?.app_certificates)?o.app_certificates:null,tcb_info:o?.tcb_info||null,compose_file:typeof o?.compose_file=="string"?o.compose_file:null}}}async function mb(e,t){let r=await N(),o=e.replace(/^app_/,""),n=await r.post(`cvms/app_${o}/replicas`,t);return oi.parse(n)}async function db(e,t,r,o,n){let s=await N(),i=e.replace(/^app_/,""),a={};if(t!==void 0&&(a.vcpu=t),r!==void 0&&(a.memory=r),o!==void 0&&(a.disk_size=o),n!==void 0&&(a.allow_restart=n),Object.keys(a).length===0)throw new Error("At least one resource parameter must be provided");return await s.patch(`cvms/app_${i}/resources`,a),!0}async function hb(e){return await(await N()).post("cvms/pubkey/from_cvm_configuration",e)}async function xb(e){let r=await(await N()).post("cvms/from_cvm_configuration",e);return ti.parse(r)}async function gb(e,t){let r=await N(),o=e.replace(/^app_/,"");return await r.put(`cvms/app_${o}/compose`,t)}async function bb(e=!1){let t=await N(),r="teepods/available";return e&&(r+="?v03x_only=1"),await t.get(r)}function wr(e,t){let r=[];t.follow&&r.push("follow"),t.tail&&r.push(`lines=${t.tail}`),t.timestamps&&r.push("timestamps"),r.push("ansi");let o=e.includes("?")?"&":"?";return e+o+r.join("&")}async function si(e,t){let r=e.body?.getReader();if(!r)throw new Error("No response body available for streaming");let o=new TextDecoder;for(;;){let{done:n,value:s}=await r.read();if(n)break;t(o.decode(s,{stream:!0}))}}async function ii(e){let t=await Du(e);if(!t.syslog_endpoint)throw new Error(`No syslog endpoint available for CVM '${e}'`);return`${t.syslog_endpoint}&ch=serial`}async function ai(e,t){let o=await(await N()).get(`cvms/${e}/composition`);if(!o.containers?.length)throw new Error(`No containers found for CVM '${e}'`);let n=o.containers;if(t&&(n=n.filter(i=>i.names.some(a=>a===t||a===`/${t}`)||i.id.startsWith(t)),!n.length))throw new Error(`Container '${t}' not found in CVM '${e}'`);let s=n.find(i=>i.log_endpoint);if(!s?.log_endpoint)throw new Error(`No log endpoints available for CVM '${e}'`);return s.log_endpoint}async function yb(e,t={}){let r=await ii(e),o=wr(r,t),n=await fetch(o);if(!n.ok)throw new Error(`Failed to fetch serial logs: ${n.status} ${n.statusText}`);return n.text()}async function vb(e,t={}){let r=await ai(e,t.container),o=wr(r,t),n=await fetch(o);if(!n.ok)throw new Error(`Failed to fetch container logs: ${n.status} ${n.statusText}`);return n.text()}async function wb(e,t,r={},o){let n=await ii(e),s=wr(n,{...r,follow:!0}),i=await fetch(s,{signal:o});if(!i.ok)throw new Error(`Failed to stream serial logs: ${i.status} ${i.statusText}`);await si(i,t)}async function _b(e,t,r={},o){let n=await ai(e,r.container),s=wr(n,{...r,follow:!0}),i=await fetch(s,{signal:o});if(!i.ok)throw new Error(`Failed to stream container logs: ${i.status} ${i.statusText}`);await si(i,t)}export{Jg as composeFileSchema,xb as createCvm,ni as cvmAttestationResponseSchema,pb as deleteCvm,Nu as dockerConfigSchema,Zg as encryptedEnvItemSchema,vb as fetchContainerLogs,yb as fetchSerialLogs,fb as getCvmAttestation,Du as getCvmByAppId,sb as getCvmComposeConfig,ib as getCvmNetwork,ri as getCvmNetworkResponseSchema,hb as getPubkeyFromCvm,bb as getTeepods,Mu as imageSchema,ti as postCvmResponseSchema,mb as replicateCvm,oi as replicateCvmResponseSchema,db as resizeCvm,lb as restartCvm,ub as selectCvm,ab as startCvm,cb as stopCvm,_b as streamContainerLogs,wb as streamSerialLogs,Yg as teepodSchema,gb as upgradeCvm};
38
38
  /*! Bundled license information:
39
39
 
40
40
  @noble/hashes/esm/utils.js: