@e2b/cli 1.4.2 → 1.4.3

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/index.js CHANGED
@@ -116,7 +116,7 @@ ${Pb}
116
116
  Try running with %s or get access `,ve.cyan("sudo"))+`
117
117
  to the local update config store via
118
118
  `+ve.cyan((0,ed.format)(" sudo chown -R $USER:$(id -gn $USER) %s ",Ds));on.default.on("exit",()=>{console.error(an(r,{textAlignment:"center"}))})}}check(){!this.config||this.config.get("optOut")||this.#r||(this.update=this.config.get("update"),this.update&&(this.update.current=this.#e,this.config.delete("update")),!(Date.now()-this.config.get("lastUpdateCheck")<this.#n)&&(0,SI.spawn)(on.default.execPath,[s1.default.join(NZ,"check.js"),JSON.stringify(this.#t)],{detached:!0,stdio:"ignore"}).unref())}async fetchInfo(){let{distTag:t}=this.#t,r=await PE(this._packageName,{version:t});return{latest:r,current:this.#e,type:Sf(this.#e,r)||t,name:this._packageName}}notify(t){let r=!this._shouldNotifyInNpmScript&&oO;if(!on.default.stdout.isTTY||r||!this.update||!bI.default.gt(this.update.latest,this.update.current))return this;t={isGlobal:CI.default,isYarnGlobal:yO(),...t};let n;t.isYarnGlobal?n=`yarn global add ${this._packageName}`:t.isGlobal?n=`npm i -g ${this._packageName}`:YE()?n=`yarn add ${this._packageName}`:n=`npm i ${this._packageName}`;let i="Update available "+ve.dim("{currentVersion}")+ve.reset(" \u2192 ")+ve.green("{latestVersion}")+`
119
- Run `+ve.cyan("{updateCommand}")+" to update",s=t.message||i;t.boxenOptions=t.boxenOptions||{padding:1,margin:1,textAlignment:"center",borderColor:"yellow",borderStyle:"round"};let a=an(i1(s,{packageName:this._packageName,currentVersion:this.update.current,latestVersion:this.update.latest,updateCommand:n}),t.boxenOptions);return t.defer===!1?console.error(a):(on.default.on("exit",()=>{console.error(a)}),on.default.on("SIGINT",()=>{console.error(""),on.default.exit()})),this}};function a1(e){let t=new tl(e);return t.check(),t}l();var BI=$(kI(),1),{program:RAe,createCommand:NAe,createArgument:AAe,createOption:OAe,CommanderError:IAe,InvalidArgumentError:vAe,InvalidOptionArgumentError:xAe,Command:Fe,Argument:wAe,Option:ai,Help:LAe}=BI.default;var T1={};XT(T1,{author:()=>QZ,bin:()=>iJ,bugs:()=>XZ,default:()=>oJ,dependencies:()=>sJ,description:()=>KZ,devDependencies:()=>rJ,engines:()=>aJ,files:()=>nJ,homepage:()=>WZ,keywords:()=>JZ,license:()=>zZ,name:()=>VZ,publishConfig:()=>ZZ,repository:()=>jZ,scripts:()=>tJ,sideEffects:()=>eJ,version:()=>b1});var VZ="@e2b/cli",b1="1.4.2",KZ="CLI for managing e2b sandbox templates",WZ="https://e2b.dev",zZ="MIT",QZ={name:"FoundryLabs, Inc.",email:"hello@e2b.dev",url:"https://e2b.dev"},XZ="https://github.com/e2b-dev/e2b/issues",jZ={type:"git",url:"https://github.com/e2b-dev/e2b",directory:"packages/cli"},ZZ={access:"public"},JZ=["e2b","ai-agents","agents","ai","code-interpreter","sandbox","code","cli","runtime","vm","nodejs","javascript","typescript"],eJ=!1,tJ={prepublishOnly:"pnpm build",build:"tsc --noEmit --skipLibCheck && tsup --minify",dev:"tsup --watch",lint:"eslint src",test:"pnpm build && cd testground/demo-basic && ../../dist/index.js template build","check-deps":"knip","update-deps":"ncu -u && pnpm i","generate-ref":"./scripts/generate_sdk_ref.sh"},rJ={"@types/command-exists":"^1.2.3","@types/inquirer":"^9.0.7","@types/json2md":"^1.5.4","@types/node":"^18.18.6","@types/update-notifier":"6.0.5",json2md:"^2.0.1",knip:"^5.43.6","npm-check-updates":"^16.14.6",tsup:"^8.4.0",typescript:"^5.2.2"},nJ=["dist","LICENSE","README","package.json"],iJ={e2b:"dist/index.js"},sJ={"@iarna/toml":"^2.2.5","async-listen":"^3.0.1",boxen:"^7.1.1",chalk:"^5.3.0","cli-highlight":"^2.1.11","command-exists":"^1.2.9",commander:"^11.1.0","console-table-printer":"^2.11.2",e2b:"^1.5.2",inquirer:"^9.2.12",open:"^9.1.0","strip-ansi":"^7.1.0","update-notifier":"^6.0.2",yup:"^1.3.2"},aJ={node:">=18"},oJ={name:VZ,version:b1,description:KZ,homepage:WZ,license:zZ,author:QZ,bugs:XZ,repository:jZ,publishConfig:ZZ,keywords:JZ,sideEffects:eJ,scripts:tJ,devDependencies:rJ,files:nJ,bin:iJ,dependencies:sJ,engines:aJ};l();l();var Xg=$(zk());l();var ha=$(require("path"));function _n(e){let t=process.cwd();return e?ha.isAbsolute(e)?e:ha.resolve(t,e):t}function Qk(e){return ha.relative(process.cwd(),e)}var mce="#FFB766";function c_(e){let t=be(e.email),r=e.teamName?be(e.teamName):pce("Log out and log in to get team name"),n=be(e.teamId||e.defaultTeamId);return`You are logged in as ${t},
119
+ Run `+ve.cyan("{updateCommand}")+" to update",s=t.message||i;t.boxenOptions=t.boxenOptions||{padding:1,margin:1,textAlignment:"center",borderColor:"yellow",borderStyle:"round"};let a=an(i1(s,{packageName:this._packageName,currentVersion:this.update.current,latestVersion:this.update.latest,updateCommand:n}),t.boxenOptions);return t.defer===!1?console.error(a):(on.default.on("exit",()=>{console.error(a)}),on.default.on("SIGINT",()=>{console.error(""),on.default.exit()})),this}};function a1(e){let t=new tl(e);return t.check(),t}l();var BI=$(kI(),1),{program:RAe,createCommand:NAe,createArgument:AAe,createOption:OAe,CommanderError:IAe,InvalidArgumentError:vAe,InvalidOptionArgumentError:xAe,Command:Fe,Argument:wAe,Option:ai,Help:LAe}=BI.default;var T1={};XT(T1,{author:()=>QZ,bin:()=>iJ,bugs:()=>XZ,default:()=>oJ,dependencies:()=>sJ,description:()=>KZ,devDependencies:()=>rJ,engines:()=>aJ,files:()=>nJ,homepage:()=>WZ,keywords:()=>JZ,license:()=>zZ,name:()=>VZ,publishConfig:()=>ZZ,repository:()=>jZ,scripts:()=>tJ,sideEffects:()=>eJ,version:()=>b1});var VZ="@e2b/cli",b1="1.4.3",KZ="CLI for managing e2b sandbox templates",WZ="https://e2b.dev",zZ="MIT",QZ={name:"FoundryLabs, Inc.",email:"hello@e2b.dev",url:"https://e2b.dev"},XZ="https://github.com/e2b-dev/e2b/issues",jZ={type:"git",url:"https://github.com/e2b-dev/e2b",directory:"packages/cli"},ZZ={access:"public"},JZ=["e2b","ai-agents","agents","ai","code-interpreter","sandbox","code","cli","runtime","vm","nodejs","javascript","typescript"],eJ=!1,tJ={prepublishOnly:"pnpm build",build:"tsc --noEmit --skipLibCheck && tsup --minify",dev:"tsup --watch",lint:"eslint src",test:"pnpm build && cd testground/demo-basic && ../../dist/index.js template build","check-deps":"knip","update-deps":"ncu -u && pnpm i","generate-ref":"./scripts/generate_sdk_ref.sh"},rJ={"@types/command-exists":"^1.2.3","@types/inquirer":"^9.0.7","@types/json2md":"^1.5.4","@types/node":"^18.18.6","@types/update-notifier":"6.0.5",json2md:"^2.0.1",knip:"^5.43.6","npm-check-updates":"^16.14.6",tsup:"^8.4.0",typescript:"^5.2.2"},nJ=["dist","LICENSE","README","package.json"],iJ={e2b:"dist/index.js"},sJ={"@iarna/toml":"^2.2.5","async-listen":"^3.0.1",boxen:"^7.1.1",chalk:"^5.3.0","cli-highlight":"^2.1.11","command-exists":"^1.2.9",commander:"^11.1.0","console-table-printer":"^2.11.2",e2b:"^1.5.2",inquirer:"^9.2.12",open:"^9.1.0","strip-ansi":"^7.1.0","update-notifier":"^6.0.2",yup:"^1.3.2"},aJ={node:">=18"},oJ={name:VZ,version:b1,description:KZ,homepage:WZ,license:zZ,author:QZ,bugs:XZ,repository:jZ,publishConfig:ZZ,keywords:JZ,sideEffects:eJ,scripts:tJ,devDependencies:rJ,files:nJ,bin:iJ,dependencies:sJ,engines:aJ};l();l();var Xg=$(zk());l();var ha=$(require("path"));function _n(e){let t=process.cwd();return e?ha.isAbsolute(e)?e:ha.resolve(t,e):t}function Qk(e){return ha.relative(process.cwd(),e)}var mce="#FFB766";function c_(e){let t=be(e.email),r=e.teamName?be(e.teamName):pce("Log out and log in to get team name"),n=be(e.teamId||e.defaultTeamId);return`You are logged in as ${t},
120
120
  Selected team: ${r} (${n})`}function Zk(e,t){let r=be(e.name),n=be(e.teamID),i=e.teamID==t?hr(" (currently selected team)"):"";return`${r} (${n})${i}`}function St(e,t){let r=Jg(e.aliases),n=r?be(r):"",i=t?fce(" <-> ")+Ft(t):"";return`${`${e.templateID} `}${n}${i}`.trim()}function pce(e){return ve.redBright(e)}function Fn(e,t){return ve.redBright(`${e?`${e}
121
121
  `:""}${t?t.stack:""}
122
122
  `)}function fce(e){return ve.dim(e)}function be(e){return ve.bold(e)}function hr(e){return ve.hex(mce)(e)}function Jk(e){return ve.blue(e)}function Pt(e){return ve.blue(e)}function Ft(e){return e?Pt("./"+Qk(e)):""}function jg(e){return ve.blueBright(e)}function Zg(e){return ve.underline(e)}function Jg(e){if(e)return e.join(", ")}function e3(e){return Xg.default(e,{language:"typescript",ignoreIllegals:!0})}function t3(e){return Xg.default(e,{language:"python",ignoreIllegals:!0})}var Ece={topLeft:"",topRight:"",bottomLeft:"",bottomRight:"",top:"",bottom:"",left:"",right:""},Xk=2,jk=1;function eh(e,t,r){return an(e,{borderStyle:{...Ece,top:"\u2500",bottom:r?"\u2500":""},titleAlignment:"center",float:"left",title:t?be(t):void 0,margin:{top:0,bottom:0,left:1,right:0},fullscreen:n=>[n,0],padding:{bottom:r?jk:0,left:Xk,right:Xk,top:jk}})}l();l();var rc=$(require("fs")),Kn=$(require("path"));var kB=$(c3());l();async function Nl(e){return new Promise(t=>setTimeout(t,e))}l();l();l();l();var Rce={"Content-Type":"application/json"},Nce=/\{[^{}]+\}/g,ih=class extends Request{constructor(t,r){super(t,r);for(let n in r)n in this||(this[n]=r[n])}};function Al(e){let{baseUrl:t="",fetch:r=globalThis.fetch,querySerializer:n,bodySerializer:i,headers:s,...a}={...e};t.endsWith("/")&&(t=t.substring(0,t.length-1)),s=d3(Rce,s);let o=[];async function c(u,d){let{fetch:_=r,headers:f,params:m={},parseAs:h="json",querySerializer:S,bodySerializer:b=i??Oce,...y}=d||{},I=typeof n=="function"?n:u3(n);S&&(I=typeof S=="function"?S:u3({...typeof n=="object"?n:{},...S}));let A={redirect:"follow",...a,...y,headers:d3(s,f,m.header)};A.body&&(A.body=b(A.body)),A.body instanceof FormData&&A.headers.delete("Content-Type");let L=new ih(Ice(u,{baseUrl:t,params:m,querySerializer:I}),A),z={baseUrl:t,fetch:_,parseAs:h,querySerializer:I,bodySerializer:b};for(let B of o)if(B&&typeof B=="object"&&typeof B.onRequest=="function"){L.schemaPath=u,L.params=m;let C=await B.onRequest(L,z);if(C){if(!(C instanceof Request))throw new Error("Middleware must return new Request() when modifying the request");L=C}}let W=await _(L);for(let B=o.length-1;B>=0;B--){let C=o[B];if(C&&typeof C=="object"&&typeof C.onResponse=="function"){L.schemaPath=u,L.params=m;let H=await C.onResponse(W,z,L);if(H){if(!(H instanceof Response))throw new Error("Middleware must return new Response() when modifying the response");W=H}}}if(W.status===204||W.headers.get("Content-Length")==="0")return W.ok?{data:{},response:W}:{error:{},response:W};if(W.ok)return h==="stream"?{data:W.body,response:W}:{data:await W[h](),response:W};let X=await W.text();try{X=JSON.parse(X)}catch{}return{error:X,response:W}}return{async GET(u,d){return c(u,{...d,method:"GET"})},async PUT(u,d){return c(u,{...d,method:"PUT"})},async POST(u,d){return c(u,{...d,method:"POST"})},async DELETE(u,d){return c(u,{...d,method:"DELETE"})},async OPTIONS(u,d){return c(u,{...d,method:"OPTIONS"})},async HEAD(u,d){return c(u,{...d,method:"HEAD"})},async PATCH(u,d){return c(u,{...d,method:"PATCH"})},async TRACE(u,d){return c(u,{...d,method:"TRACE"})},use(...u){for(let d of u)if(d){if(typeof d!="object"||!("onRequest"in d||"onResponse"in d))throw new Error("Middleware must be an object with one of `onRequest()` or `onResponse()`");o.push(d)}},eject(...u){for(let d of u){let _=o.indexOf(d);_!==-1&&o.splice(_,1)}}}}function d_(e,t,r){if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${r?.allowReserved===!0?t:encodeURIComponent(t)}`}function _3(e,t,r){if(!t||typeof t!="object")return"";let n=[],i={simple:",",label:".",matrix:";"}[r.style]||"&";if(r.style!=="deepObject"&&r.explode===!1){for(let o in t)n.push(o,r.allowReserved===!0?t[o]:encodeURIComponent(t[o]));let a=n.join(",");switch(r.style){case"form":return`${e}=${a}`;case"label":return`.${a}`;case"matrix":return`;${e}=${a}`;default:return a}}for(let a in t){let o=r.style==="deepObject"?`${e}[${a}]`:a;n.push(d_(o,t[a],r))}let s=n.join(i);return r.style==="label"||r.style==="matrix"?`${i}${s}`:s}function m3(e,t,r){if(!Array.isArray(t))return"";if(r.explode===!1){let s={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[r.style]||",",a=(r.allowReserved===!0?t:t.map(o=>encodeURIComponent(o))).join(s);switch(r.style){case"simple":return a;case"label":return`.${a}`;case"matrix":return`;${e}=${a}`;default:return`${e}=${a}`}}let n={simple:",",label:".",matrix:";"}[r.style]||"&",i=[];for(let s of t)r.style==="simple"||r.style==="label"?i.push(r.allowReserved===!0?s:encodeURIComponent(s)):i.push(d_(e,s,r));return r.style==="label"||r.style==="matrix"?`${n}${i.join(n)}`:i.join(n)}function u3(e){return function(r){let n=[];if(r&&typeof r=="object")for(let i in r){let s=r[i];if(s!=null){if(Array.isArray(s)){n.push(m3(i,s,{style:"form",explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}));continue}if(typeof s=="object"){n.push(_3(i,s,{style:"deepObject",explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}));continue}n.push(d_(i,s,e))}}return n.join("&")}}function Ace(e,t){let r=e;for(let n of e.match(Nce)??[]){let i=n.substring(1,n.length-1),s=!1,a="simple";if(i.endsWith("*")&&(s=!0,i=i.substring(0,i.length-1)),i.startsWith(".")?(a="label",i=i.substring(1)):i.startsWith(";")&&(a="matrix",i=i.substring(1)),!t||t[i]===void 0||t[i]===null)continue;let o=t[i];if(Array.isArray(o)){r=r.replace(n,m3(i,o,{style:a,explode:s}));continue}if(typeof o=="object"){r=r.replace(n,_3(i,o,{style:a,explode:s}));continue}if(a==="matrix"){r=r.replace(n,`;${d_(i,o)}`);continue}r=r.replace(n,a==="label"?`.${o}`:o)}return r}function Oce(e){return JSON.stringify(e)}function Ice(e,t){let r=`${t.baseUrl}${e}`;t.params?.path&&(r=Ace(r,t.params.path));let n=t.querySerializer(t.params.query??{});return n.startsWith("?")&&(n=n.substring(1)),n&&(r+=`?${n}`),r}function d3(...e){let t=new Headers;for(let r of e){if(!r||typeof r!="object")continue;let n=r instanceof Headers?r.entries():Object.entries(r);for(let[i,s]of n)if(s===null)t.delete(i);else if(Array.isArray(s))for(let a of s)t.append(i,a);else s!==void 0&&t.set(i,s)}return t}l();var Il=$(p3());var f3="1.5.2";function xce(){return globalThis.Bun?{runtime:"bun",version:globalThis.Bun.version}:globalThis.Deno?{runtime:"deno",version:globalThis.Deno.version.deno}:globalThis.process?.release?.name==="node"?{runtime:"node",version:Il.default.version||"unknown"}:typeof EdgeRuntime=="string"?{runtime:"vercel-edge",version:"unknown"}:globalThis.navigator?.userAgent==="Cloudflare-Workers"?{runtime:"cloudflare-worker",version:"unknown"}:typeof window<"u"?{runtime:"browser",version:Il.default.version||"unknown"}:{runtime:"unknown",version:"unknown"}}var{runtime:m_,version:wce}=xce(),E3={browser:typeof window<"u"&&Il.default.name||"unknown",lang:"js",lang_version:wce,package_version:f3,publisher:"e2b",sdk_runtime:m_,system:Il.default.os?.family||"unknown"};function vl(e){return m_==="deno"?Deno.env.get(e):typeof process>"u"?"":process.env[e]}l();function E_(e){return new Ta(`${e}: This error is likely due to sandbox timeout. You can modify the sandbox timeout by passing 'timeoutMs' when starting the sandbox or calling '.setTimeout' on the sandbox with the desired timeout.`)}var Nt=class extends Error{constructor(t){super(t),this.name="SandboxError"}},Ta=class extends Nt{constructor(t){super(t),this.name="TimeoutError"}},gi=class extends Nt{constructor(t){super(t),this.name="InvalidArgumentError"}},p_=class extends Nt{constructor(t){super(t),this.name="NotEnoughSpaceError"}},hi=class extends Nt{constructor(t){super(t),this.name="NotFoundError"}},kn=class extends Nt{constructor(t){super(t),this.name="AuthenticationError"}},ba=class extends Nt{constructor(t){super(t),this.name="TemplateError"}},f_=class extends Nt{constructor(t){super(t),this.name="RateLimitError"}};l();function g3(e){return JSON.parse(JSON.stringify(e))}function h3(e){async function*t(r){for await(let n of r)e.debug?.("Response stream:",g3(n)),yield n}return r=>async n=>{e.info?.(`Request: POST ${n.url}`);let i=await r(n);return i.stream?{...i,message:t(i.message)}:(e.info?.("Response:",g3(i.message)),i)}}function g_(e){return{async onRequest(t){return e.info?.(`Request ${t.method} ${t.url}`),t},async onResponse(t){return t.status>=400?e.error?.("Response:",t.status,t.statusText):e.info?.("Response:",t.status,t.statusText),t}}}function Ca(e){if(!e.error)return;if(e.response.status===429)return new f_("Rate limit exceeded, please try again later.");let t=e.error?.message??e.error;return new Nt(`${e.response.status}: ${t}`)}var Dr=class{api;constructor(t,r={requireAccessToken:!1,requireApiKey:!0}){if(!r?.requireApiKey&&!t.apiKey)throw new kn("API key is required, please visit the Team tab at https://e2b.dev/dashboard to get your API key. You can either set the environment variable `E2B_API_KEY` or you can pass it directly to the sandbox like Sandbox.create({ apiKey: 'e2b_...' })");if(r?.requireAccessToken&&!t.accessToken)throw new kn("Access token is required, please visit the Personal tab at https://e2b.dev/dashboard to get your access token. You can set the environment variable `E2B_ACCESS_TOKEN` or pass the `accessToken` in options.");this.api=Al({baseUrl:t.apiUrl,headers:{...E3,...t.apiKey&&{"X-API-KEY":t.apiKey},...t.accessToken&&{Authorization:`Bearer ${t.accessToken}`},...t.headers}}),t.logger&&this.api.use(g_(t.logger))}};l();var Lce=3e4,ls=50,cs="Keepalive-Ping-Interval",$t=class e{debug;domain;apiUrl;logger;requestTimeoutMs;apiKey;accessToken;headers;constructor(t){this.apiKey=t?.apiKey||e.apiKey,this.debug=t?.debug||e.debug,this.domain=t?.domain||e.domain,this.accessToken=t?.accessToken||e.accessToken,this.requestTimeoutMs=t?.requestTimeoutMs??Lce,this.logger=t?.logger,this.headers=t?.headers,this.apiUrl=this.debug?"http://localhost:3000":`https://api.${this.domain}`}static get domain(){return vl("E2B_DOMAIN")||"e2b.app"}static get debug(){return(vl("E2B_DEBUG")||"false").toLowerCase()==="true"}static get apiKey(){return vl("E2B_API_KEY")}static get accessToken(){return vl("E2B_ACCESS_TOKEN")}getSignal(t){let r=t??this.requestTimeoutMs;return r?AbortSignal.timeout(r):void 0}},zr="user";l();var S3=$(require("crypto"));function sh({path:e,operation:t,user:r,expirationInSeconds:n,envdAccessToken:i}){if(!i)throw new Error("Access token is not set and signature cannot be generated!");let s=n?Math.floor(Date.now()/1e3)+n:null,a;s===null?a=`${e}:${t}:${r}:${i}`:a=`${e}:${t}:${r}:${i}:${s.toString()}`;let o=Buffer.from(a,"utf8");return{signature:"v1_"+S3.default.createHash("sha256").update(o).digest().toString("base64").replace(/=+$/,""),expiration:s}}l();l();l();l();var Ce;(function(e){e[e.Canceled=1]="Canceled",e[e.Unknown=2]="Unknown",e[e.InvalidArgument=3]="InvalidArgument",e[e.DeadlineExceeded=4]="DeadlineExceeded",e[e.NotFound=5]="NotFound",e[e.AlreadyExists=6]="AlreadyExists",e[e.PermissionDenied=7]="PermissionDenied",e[e.ResourceExhausted=8]="ResourceExhausted",e[e.FailedPrecondition=9]="FailedPrecondition",e[e.Aborted=10]="Aborted",e[e.OutOfRange=11]="OutOfRange",e[e.Unimplemented=12]="Unimplemented",e[e.Internal=13]="Internal",e[e.Unavailable=14]="Unavailable",e[e.DataLoss=15]="DataLoss",e[e.Unauthenticated=16]="Unauthenticated"})(Ce||(Ce={}));l();l();function xl(e,t){return e!==null&&typeof e=="object"&&"$typeName"in e&&typeof e.$typeName=="string"?t===void 0?!0:t.typeName===e.$typeName:!1}l();l();var k;(function(e){e[e.DOUBLE=1]="DOUBLE",e[e.FLOAT=2]="FLOAT",e[e.INT64=3]="INT64",e[e.UINT64=4]="UINT64",e[e.INT32=5]="INT32",e[e.FIXED64=6]="FIXED64",e[e.FIXED32=7]="FIXED32",e[e.BOOL=8]="BOOL",e[e.STRING=9]="STRING",e[e.BYTES=12]="BYTES",e[e.UINT32=13]="UINT32",e[e.SFIXED32=15]="SFIXED32",e[e.SFIXED64=16]="SFIXED64",e[e.SINT32=17]="SINT32",e[e.SINT64=18]="SINT64"})(k||(k={}));l();l();l();function b3(){let e=0,t=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(e|=(i&127)<<n,(i&128)==0)return this.assertBounds(),[e,t]}let r=this.buf[this.pos++];if(e|=(r&15)<<28,t=(r&112)>>4,(r&128)==0)return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(t|=(i&127)<<n,(i&128)==0)return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function S_(e,t,r){for(let s=0;s<28;s=s+7){let a=e>>>s,o=!(!(a>>>7)&&t==0),c=(o?a|128:a)&255;if(r.push(c),!o)return}let n=e>>>28&15|(t&7)<<4,i=t>>3!=0;if(r.push((i?n|128:n)&255),!!i){for(let s=3;s<31;s=s+7){let a=t>>>s,o=!!(a>>>7),c=(o?a|128:a)&255;if(r.push(c),!o)return}r.push(t>>>31&1)}}var h_=4294967296;function ah(e){let t=e[0]==="-";t&&(e=e.slice(1));let r=1e6,n=0,i=0;function s(a,o){let c=Number(e.slice(a,o));i*=r,n=n*r+c,n>=h_&&(i=i+(n/h_|0),n=n%h_)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),t?D3(n,i):lh(n,i)}function C3(e,t){let r=lh(e,t),n=r.hi&2147483648;n&&(r=D3(r.lo,r.hi));let i=oh(r.lo,r.hi);return n?"-"+i:i}function oh(e,t){if({lo:e,hi:t}=Mce(e,t),t<=2097151)return String(h_*t+e);let r=e&16777215,n=(e>>>24|t<<8)&16777215,i=t>>16&65535,s=r+n*6777216+i*6710656,a=n+i*8147497,o=i*2,c=1e7;return s>=c&&(a+=Math.floor(s/c),s%=c),a>=c&&(o+=Math.floor(a/c),a%=c),o.toString()+T3(a)+T3(s)}function Mce(e,t){return{lo:e>>>0,hi:t>>>0}}function lh(e,t){return{lo:e|0,hi:t|0}}function D3(e,t){return t=~t,e?e=~e+1:t+=1,lh(e,t)}var T3=e=>{let t=String(e);return"0000000".slice(t.length)+t};function ch(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e=e>>>7;t.push(e)}else{for(let r=0;r<9;r++)t.push(e&127|128),e=e>>7;t.push(1)}}function y3(){let e=this.buf[this.pos++],t=e&127;if((e&128)==0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<7,(e&128)==0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<14,(e&128)==0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<21,(e&128)==0)return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let r=5;(e&128)!==0&&r<10;r++)e=this.buf[this.pos++];if((e&128)!=0)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var qe=Pce();function Pce(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof e.getBigInt64=="function"&&typeof e.getBigUint64=="function"&&typeof e.setBigInt64=="function"&&typeof e.setBigUint64=="function"&&(typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let r=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),i=BigInt("0"),s=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(a){let o=typeof a=="bigint"?a:BigInt(a);if(o>n||o<r)throw new Error(`invalid int64: ${a}`);return o},uParse(a){let o=typeof a=="bigint"?a:BigInt(a);if(o>s||o<i)throw new Error(`invalid uint64: ${a}`);return o},enc(a){return e.setBigInt64(0,this.parse(a),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(a){return e.setBigInt64(0,this.uParse(a),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(a,o){return e.setInt32(0,a,!0),e.setInt32(4,o,!0),e.getBigInt64(0,!0)},uDec(a,o){return e.setInt32(0,a,!0),e.setInt32(4,o,!0),e.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),R3(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),N3(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),R3(r),ah(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),N3(r),ah(r)},dec(r,n){return C3(r,n)},uDec(r,n){return oh(r,n)}}}function R3(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function N3(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}function yr(e,t){switch(e){case k.STRING:return"";case k.BOOL:return!1;default:return 0;case k.DOUBLE:case k.FLOAT:return 0;case k.INT64:case k.UINT64:case k.SFIXED64:case k.FIXED64:case k.SINT64:return t?"0":qe.zero;case k.BYTES:return new Uint8Array(0)}}function A3(e,t){switch(e){case k.BOOL:return t===!1;case k.STRING:return t==="";case k.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return t==0}}l();var Fce=["FieldValueInvalidError","FieldListRangeError","ForeignFieldError"],At=class extends Error{constructor(t,r,n="FieldValueInvalidError"){super(r),this.name=n,this.field=()=>t}};function O3(e){return e instanceof Error&&Fce.includes(e.name)&&"field"in e&&typeof e.field=="function"}l();l();var I3=2,Qr=Symbol.for("reflect unsafe local");function T_(e,t){let r=e[t.localName].case;return r===void 0?r:t.fields.find(n=>n.localName===r)}function v3(e,t){let r=t.localName;if(t.oneof)return e[t.oneof.localName].case===r;if(t.presence!=I3)return e[r]!==void 0&&Object.prototype.hasOwnProperty.call(e,r);switch(t.fieldKind){case"list":return e[r].length>0;case"map":return Object.keys(e[r]).length>0;case"scalar":return!A3(t.scalar,e[r]);case"enum":return e[r]!==t.enum.values[0].number}throw new Error("message field with implicit presence")}function us(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==void 0}function b_(e,t){if(t.oneof){let r=e[t.oneof.localName];return r.case===t.localName?r.value:void 0}return e[t.localName]}function C_(e,t,r){t.oneof?e[t.oneof.localName]={case:t.localName,value:r}:e[t.localName]=r}function x3(e,t){let r=t.localName;if(t.oneof){let n=t.oneof.localName;e[n].case===r&&(e[n]={case:void 0})}else if(t.presence!=I3)delete e[r];else switch(t.fieldKind){case"map":e[r]={};break;case"list":e[r]=[];break;case"enum":e[r]=t.enum.values[0].number;break;case"scalar":e[r]=yr(t.scalar,t.longAsString);break}}function mn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function wl(e,t){var r,n,i,s;if(mn(e)&&Qr in e&&"add"in e&&"field"in e&&typeof e.field=="function"){if(t!==void 0){let a=t,o=e.field();return a.listKind==o.listKind&&a.scalar===o.scalar&&((r=a.message)===null||r===void 0?void 0:r.typeName)===((n=o.message)===null||n===void 0?void 0:n.typeName)&&((i=a.enum)===null||i===void 0?void 0:i.typeName)===((s=o.enum)===null||s===void 0?void 0:s.typeName)}return!0}return!1}function Ll(e,t){var r,n,i,s;if(mn(e)&&Qr in e&&"has"in e&&"field"in e&&typeof e.field=="function"){if(t!==void 0){let a=t,o=e.field();return a.mapKey===o.mapKey&&a.mapKind==o.mapKind&&a.scalar===o.scalar&&((r=a.message)===null||r===void 0?void 0:r.typeName)===((n=o.message)===null||n===void 0?void 0:n.typeName)&&((i=a.enum)===null||i===void 0?void 0:i.typeName)===((s=o.enum)===null||s===void 0?void 0:s.typeName)}return!0}return!1}function Ml(e,t){return mn(e)&&Qr in e&&"desc"in e&&mn(e.desc)&&e.desc.kind==="message"&&(t===void 0||e.desc.typeName==t.typeName)}l();function w3(e){return L3(e.$typeName)}function pn(e){let t=e.fields[0];return L3(e.typeName)&&t!==void 0&&t.fieldKind=="scalar"&&t.name=="value"&&t.number==1}function L3(e){return e.startsWith("google.protobuf.")&&["DoubleValue","FloatValue","Int64Value","UInt64Value","Int32Value","UInt32Value","BoolValue","StringValue","BytesValue"].includes(e.substring(16))}var kce=999,Bce=998,D_=2;function Vt(e,t){if(xl(t,e))return t;let r=qce(e);return t!==void 0&&Uce(e,r,t),r}function Uce(e,t,r){for(let n of e.members){let i=r[n.localName];if(i==null)continue;let s;if(n.kind=="oneof"){let a=T_(r,n);if(!a)continue;s=a,i=b_(r,a)}else s=n;switch(s.fieldKind){case"message":i=dh(s,i);break;case"scalar":i=F3(s,i);break;case"list":i=Hce(s,i);break;case"map":i=Gce(s,i);break}C_(t,s,i)}return t}function F3(e,t){return e.scalar==k.BYTES?_h(t):t}function Gce(e,t){if(mn(t)){if(e.scalar==k.BYTES)return M3(t,_h);if(e.mapKind=="message")return M3(t,r=>dh(e,r))}return t}function Hce(e,t){if(Array.isArray(t)){if(e.scalar==k.BYTES)return t.map(_h);if(e.listKind=="message")return t.map(r=>dh(e,r))}return t}function dh(e,t){if(e.fieldKind=="message"&&!e.oneof&&pn(e.message))return F3(e.message.fields[0],t);if(mn(t)){if(e.message.typeName=="google.protobuf.Struct"&&e.parent.typeName!=="google.protobuf.Value")return t;if(!xl(t,e.message))return Vt(e.message,t)}return t}function _h(e){return Array.isArray(e)?new Uint8Array(e):e}function M3(e,t){let r={};for(let n of Object.entries(e))r[n[0]]=t(n[1]);return r}var Yce=Symbol(),P3=new WeakMap;function qce(e){let t;if($ce(e)){let r=P3.get(e),n,i;if(r)({prototype:n,members:i}=r);else{n={},i=new Set;for(let s of e.members)s.kind!="oneof"&&(s.fieldKind!="scalar"&&s.fieldKind!="enum"||s.presence!=D_&&(i.add(s),n[s.localName]=uh(s)));P3.set(e,{prototype:n,members:i})}t=Object.create(n),t.$typeName=e.typeName;for(let s of e.members)i.has(s)||s.kind=="field"&&(s.fieldKind=="message"||(s.fieldKind=="scalar"||s.fieldKind=="enum")&&s.presence!=D_)||(t[s.localName]=uh(s))}else{t={$typeName:e.typeName};for(let r of e.members)(r.kind=="oneof"||r.presence==D_)&&(t[r.localName]=uh(r))}return t}function $ce(e){switch(e.file.edition){case kce:return!1;case Bce:return!0;default:return e.fields.some(t=>t.presence!=D_&&t.fieldKind!="message"&&!t.oneof)}}function uh(e){if(e.kind=="oneof")return{case:void 0};if(e.fieldKind=="list")return[];if(e.fieldKind=="map")return{};if(e.fieldKind=="message")return Yce;let t=e.getDefaultValue();return t!==void 0?e.fieldKind=="scalar"&&e.longAsString?t.toString():t:e.fieldKind=="scalar"?yr(e.scalar,e.longAsString):e.enum.values[0].number}l();l();l();l();var mh=Symbol.for("@bufbuild/protobuf/text-encoding");function Pl(){if(globalThis[mh]==null){let e=new globalThis.TextEncoder,t=new globalThis.TextDecoder;globalThis[mh]={encodeUtf8(r){return e.encode(r)},decodeUtf8(r){return t.decode(r)},checkUtf8(r){try{return encodeURIComponent(r),!0}catch{return!1}}}}return globalThis[mh]}var dt;(function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"})(dt||(dt={}));var fh=34028234663852886e22,Eh=-34028234663852886e22,gh=4294967295,hh=2147483647,Sh=-2147483648,Da=class{constructor(t=Pl().encodeUtf8){this.encodeUtf8=t,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let t=0;for(let i=0;i<this.chunks.length;i++)t+=this.chunks[i].length;let r=new Uint8Array(t),n=0;for(let i=0;i<this.chunks.length;i++)r.set(this.chunks[i],n),n+=this.chunks[i].length;return this.chunks=[],r}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let t=this.finish(),r=this.stack.pop();if(!r)throw new Error("invalid state, fork stack empty");return this.chunks=r.chunks,this.buf=r.buf,this.uint32(t.byteLength),this.raw(t)}tag(t,r){return this.uint32((t<<3|r)>>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(k3(t);t>127;)this.buf.push(t&127|128),t=t>>>7;return this.buf.push(t),this}int32(t){return ph(t),ch(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let r=this.encodeUtf8(t);return this.uint32(r.byteLength),this.raw(r)}float(t){Vce(t);let r=new Uint8Array(4);return new DataView(r.buffer).setFloat32(0,t,!0),this.raw(r)}double(t){let r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,t,!0),this.raw(r)}fixed32(t){k3(t);let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,t,!0),this.raw(r)}sfixed32(t){ph(t);let r=new Uint8Array(4);return new DataView(r.buffer).setInt32(0,t,!0),this.raw(r)}sint32(t){return ph(t),t=(t<<1^t>>31)>>>0,ch(t,this.buf),this}sfixed64(t){let r=new Uint8Array(8),n=new DataView(r.buffer),i=qe.enc(t);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(r)}fixed64(t){let r=new Uint8Array(8),n=new DataView(r.buffer),i=qe.uEnc(t);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(r)}int64(t){let r=qe.enc(t);return S_(r.lo,r.hi,this.buf),this}sint64(t){let r=qe.enc(t),n=r.hi>>31,i=r.lo<<1^n,s=(r.hi<<1|r.lo>>>31)^n;return S_(i,s,this.buf),this}uint64(t){let r=qe.uEnc(t);return S_(r.lo,r.hi,this.buf),this}},ds=class{constructor(t,r=Pl().decodeUtf8){this.decodeUtf8=r,this.varint64=b3,this.uint32=y3,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}tag(){let t=this.uint32(),r=t>>>3,n=t&7;if(r<=0||n<0||n>5)throw new Error("illegal tag: field no "+r+" wire type "+n);return[r,n]}skip(t,r){let n=this.pos;switch(t){case dt.Varint:for(;this.buf[this.pos++]&128;);break;case dt.Bit64:this.pos+=4;case dt.Bit32:this.pos+=4;break;case dt.LengthDelimited:let i=this.uint32();this.pos+=i;break;case dt.StartGroup:for(;;){let[s,a]=this.tag();if(a===dt.EndGroup){if(r!==void 0&&s!==r)throw new Error("invalid end group tag");break}this.skip(a,s)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return qe.dec(...this.varint64())}uint64(){return qe.uDec(...this.varint64())}sint64(){let[t,r]=this.varint64(),n=-(t&1);return t=(t>>>1|(r&1)<<31)^n,r=r>>>1^n,qe.dec(t,r)}bool(){let[t,r]=this.varint64();return t!==0||r!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return qe.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return qe.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),r=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(r,r+t)}string(){return this.decodeUtf8(this.bytes())}};function ph(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>hh||e<Sh)throw new Error("invalid int32: "+e)}function k3(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>gh||e<0)throw new Error("invalid uint32: "+e)}function Vce(e){if(typeof e=="string"){let t=e;if(e=Number(e),isNaN(e)&&t!=="NaN")throw new Error("invalid float32: "+t)}else if(typeof e!="number")throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>fh||e<Eh))throw new Error("invalid float32: "+e)}function Bn(e,t){let r=e.fieldKind=="list"?wl(t,e):e.fieldKind=="map"?Ll(t,e):bh(e,t);if(r===!0)return;let n;switch(e.fieldKind){case"list":n=`expected ${H3(e)}, got ${Tt(t)}`;break;case"map":n=`expected ${Y3(e)}, got ${Tt(t)}`;break;default:n=y_(e,t,r)}return new At(e,n)}function Th(e,t,r){let n=bh(e,r);if(n!==!0)return new At(e,`list item #${t+1}: ${y_(e,r,n)}`)}function B3(e,t,r){let n=U3(t,e.mapKey);if(n!==!0)return new At(e,`invalid map key: ${y_({scalar:e.mapKey},t,n)}`);let i=bh(e,r);if(i!==!0)return new At(e,`map entry ${Tt(t)}: ${y_(e,r,i)}`)}function bh(e,t){return e.scalar!==void 0?U3(t,e.scalar):e.enum!==void 0?e.enum.open?Number.isInteger(t):e.enum.values.some(r=>r.number===t):Ml(t,e.message)}function U3(e,t){switch(t){case k.DOUBLE:return typeof e=="number";case k.FLOAT:return typeof e!="number"?!1:Number.isNaN(e)||!Number.isFinite(e)?!0:e>fh||e<Eh?`${e.toFixed()} out of range`:!0;case k.INT32:case k.SFIXED32:case k.SINT32:return typeof e!="number"||!Number.isInteger(e)?!1:e>hh||e<Sh?`${e.toFixed()} out of range`:!0;case k.FIXED32:case k.UINT32:return typeof e!="number"||!Number.isInteger(e)?!1:e>gh||e<0?`${e.toFixed()} out of range`:!0;case k.BOOL:return typeof e=="boolean";case k.STRING:return typeof e!="string"?!1:Pl().checkUtf8(e)||"invalid UTF8";case k.BYTES:return e instanceof Uint8Array;case k.INT64:case k.SFIXED64:case k.SINT64:if(typeof e!="string"&&typeof e!="bigint"&&typeof e!="number")return!1;try{qe.parse(e)}catch{return`${e} out of range`}return!0;case k.FIXED64:case k.UINT64:if(typeof e!="string"&&typeof e!="bigint"&&typeof e!="number")return!1;try{qe.uParse(e)}catch{return`${e} out of range`}return!0}}function y_(e,t,r){return r=typeof r=="string"?`: ${r}`:`, got ${Tt(t)}`,e.scalar!==void 0?`expected ${Kce(e.scalar)}`+r:e.enum!==void 0?`expected ${e.enum.toString()}`+r:`expected ${G3(e.message)}`+r}function Tt(e){switch(typeof e){case"object":return e===null?"null":e instanceof Uint8Array?`Uint8Array(${e.length})`:Array.isArray(e)?`Array(${e.length})`:wl(e)?H3(e.field()):Ll(e)?Y3(e.field()):Ml(e)?G3(e.desc):xl(e)?`message ${e.$typeName}`:"object";case"string":return e.length>30?"string":`"${e.split('"').join('\\"')}"`;case"boolean":return String(e);case"number":return String(e);case"bigint":return String(e)+"n";default:return typeof e}}function G3(e){return`ReflectMessage (${e.typeName})`}function H3(e){switch(e.listKind){case"message":return`ReflectList (${e.message.toString()})`;case"enum":return`ReflectList (${e.enum.toString()})`;case"scalar":return`ReflectList (${k[e.scalar]})`}}function Y3(e){switch(e.mapKind){case"message":return`ReflectMap (${k[e.mapKey]}, ${e.message.toString()})`;case"enum":return`ReflectMap (${k[e.mapKey]}, ${e.enum.toString()})`;case"scalar":return`ReflectMap (${k[e.mapKey]}, ${k[e.scalar]})`}}function Kce(e){switch(e){case k.STRING:return"string";case k.BOOL:return"boolean";case k.INT64:case k.SINT64:case k.SFIXED64:return"bigint (int64)";case k.UINT64:case k.FIXED64:return"bigint (uint64)";case k.BYTES:return"Uint8Array";case k.DOUBLE:return"number (float64)";case k.FLOAT:return"number (float32)";case k.FIXED32:case k.UINT32:return"number (uint32)";case k.INT32:case k.SFIXED32:case k.SINT32:return"number (int32)"}}function Kt(e,t,r=!0){return new N_(e,t,r)}var N_=class{get sortedFields(){var t;return(t=this._sortedFields)!==null&&t!==void 0?t:this._sortedFields=this.desc.fields.concat().sort((r,n)=>r.number-n.number)}constructor(t,r,n=!0){this.lists=new Map,this.maps=new Map,this.check=n,this.desc=t,this.message=this[Qr]=r??Vt(t),this.fields=t.fields,this.oneofs=t.oneofs,this.members=t.members}findNumber(t){return this._fieldsByNumber||(this._fieldsByNumber=new Map(this.desc.fields.map(r=>[r.number,r]))),this._fieldsByNumber.get(t)}oneofCase(t){return Fl(this.message,t),T_(this.message,t)}isSet(t){return Fl(this.message,t),v3(this.message,t)}clear(t){Fl(this.message,t),x3(this.message,t)}get(t){Fl(this.message,t);let r=b_(this.message,t);switch(t.fieldKind){case"list":let n=this.lists.get(t);return(!n||n[Qr]!==r)&&this.lists.set(t,n=new yh(t,r,this.check)),n;case"map":let i=this.maps.get(t);return(!i||i[Qr]!==r)&&this.maps.set(t,i=new Rh(t,r,this.check)),i;case"message":return Ah(t,r,this.check);case"scalar":return r===void 0?yr(t.scalar,!1):Oh(t,r);case"enum":return r??t.enum.values[0].number}}set(t,r){if(Fl(this.message,t),this.check){let i=Bn(t,r);if(i)throw i}let n;t.fieldKind=="message"?n=Nh(t,r):Ll(r)||wl(r)?n=r[Qr]:n=Ih(t,r),C_(this.message,t,n)}getUnknown(){return this.message.$unknown}setUnknown(t){this.message.$unknown=t}};function Fl(e,t){if(t.parent.typeName!==e.$typeName)throw new At(t,`cannot use ${t.toString()} with message ${e.$typeName}`,"ForeignFieldError")}var yh=class{field(){return this._field}get size(){return this._arr.length}constructor(t,r,n){this._field=t,this._arr=this[Qr]=r,this.check=n}get(t){let r=this._arr[t];return r===void 0?void 0:Ch(this._field,r,this.check)}set(t,r){if(t<0||t>=this._arr.length)throw new At(this._field,`list item #${t+1}: out of range`);if(this.check){let n=Th(this._field,t,r);if(n)throw n}this._arr[t]=q3(this._field,r)}add(t){if(this.check){let r=Th(this._field,this._arr.length,t);if(r)throw r}this._arr.push(q3(this._field,t))}clear(){this._arr.splice(0,this._arr.length)}[Symbol.iterator](){return this.values()}keys(){return this._arr.keys()}*values(){for(let t of this._arr)yield Ch(this._field,t,this.check)}*entries(){for(let t=0;t<this._arr.length;t++)yield[t,Ch(this._field,this._arr[t],this.check)]}};var Rh=class{constructor(t,r,n=!0){this.obj=this[Qr]=r??{},this.check=n,this._field=t}field(){return this._field}set(t,r){if(this.check){let n=B3(this._field,t,r);if(n)throw n}return this.obj[R_(t)]=Wce(this._field,r),this}delete(t){let r=R_(t),n=Object.prototype.hasOwnProperty.call(this.obj,r);return n&&delete this.obj[r],n}clear(){for(let t of Object.keys(this.obj))delete this.obj[t]}get(t){let r=this.obj[R_(t)];return r!==void 0&&(r=Dh(this._field,r,this.check)),r}has(t){return Object.prototype.hasOwnProperty.call(this.obj,R_(t))}*keys(){for(let t of Object.keys(this.obj))yield $3(t,this._field.mapKey)}*entries(){for(let t of Object.entries(this.obj))yield[$3(t[0],this._field.mapKey),Dh(this._field,t[1],this.check)]}[Symbol.iterator](){return this.entries()}get size(){return Object.keys(this.obj).length}*values(){for(let t of Object.values(this.obj))yield Dh(this._field,t,this.check)}forEach(t,r){for(let n of this.entries())t.call(r,n[1],n[0],this)}};function Nh(e,t){return Ml(t)?w3(t.message)&&!e.oneof&&e.fieldKind=="message"?t.message.value:t.desc.typeName=="google.protobuf.Struct"&&e.parent.typeName!="google.protobuf.Value"?K3(t.message):t.message:t}function Ah(e,t,r){return t!==void 0&&(pn(e.message)&&!e.oneof&&e.fieldKind=="message"?t={$typeName:e.message.typeName,value:Oh(e.message.fields[0],t)}:e.message.typeName=="google.protobuf.Struct"&&e.parent.typeName!="google.protobuf.Value"&&mn(t)&&(t=V3(t))),new N_(e.message,t,r)}function q3(e,t){return e.listKind=="message"?Nh(e,t):Ih(e,t)}function Ch(e,t,r){return e.listKind=="message"?Ah(e,t,r):Oh(e,t)}function Wce(e,t){return e.mapKind=="message"?Nh(e,t):Ih(e,t)}function Dh(e,t,r){return e.mapKind=="message"?Ah(e,t,r):t}function R_(e){return typeof e=="string"||typeof e=="number"?e:String(e)}function $3(e,t){switch(t){case k.STRING:return e;case k.INT32:case k.FIXED32:case k.UINT32:case k.SFIXED32:case k.SINT32:{let r=Number.parseInt(e);if(Number.isFinite(r))return r;break}case k.BOOL:switch(e){case"true":return!0;case"false":return!1}break;case k.UINT64:case k.FIXED64:try{return qe.uParse(e)}catch{}break;default:try{return qe.parse(e)}catch{}break}return e}function Oh(e,t){switch(e.scalar){case k.INT64:case k.SFIXED64:case k.SINT64:"longAsString"in e&&e.longAsString&&typeof t=="string"&&(t=qe.parse(t));break;case k.FIXED64:case k.UINT64:"longAsString"in e&&e.longAsString&&typeof t=="string"&&(t=qe.uParse(t));break}return t}function Ih(e,t){switch(e.scalar){case k.INT64:case k.SFIXED64:case k.SINT64:"longAsString"in e&&e.longAsString?t=String(t):(typeof t=="string"||typeof t=="number")&&(t=qe.parse(t));break;case k.FIXED64:case k.UINT64:"longAsString"in e&&e.longAsString?t=String(t):(typeof t=="string"||typeof t=="number")&&(t=qe.uParse(t));break}return t}function V3(e){let t={$typeName:"google.protobuf.Struct",fields:{}};if(mn(e))for(let[r,n]of Object.entries(e))t.fields[r]=z3(n);return t}function K3(e){let t={};for(let[r,n]of Object.entries(e.fields))t[r]=W3(n);return t}function W3(e){switch(e.kind.case){case"structValue":return K3(e.kind.value);case"listValue":return e.kind.value.values.map(W3);case"nullValue":case void 0:return null;default:return e.kind.value}}function z3(e){let t={$typeName:"google.protobuf.Value",kind:{case:void 0}};switch(typeof e){case"number":t.kind={case:"numberValue",value:e};break;case"string":t.kind={case:"stringValue",value:e};break;case"boolean":t.kind={case:"boolValue",value:e};break;case"object":if(e===null)t.kind={case:"nullValue",value:0};else if(Array.isArray(e)){let r={$typeName:"google.protobuf.ListValue",values:[]};if(Array.isArray(e))for(let n of e)r.values.push(z3(n));t.kind={case:"listValue",value:r}}else t.kind={case:"structValue",value:V3(e)};break}return t}l();l();function Q3(e,t){let r=e.values.find(n=>n.name===t);if(!r)throw new Error(`cannot parse ${e} default value: ${t}`);return r.number}function X3(e,t){switch(e){case k.STRING:return t;case k.BYTES:{let r=zce(t);if(r===!1)throw new Error(`cannot parse ${k[e]} default value: ${t}`);return r}case k.INT64:case k.SFIXED64:case k.SINT64:return qe.parse(t);case k.UINT64:case k.FIXED64:return qe.uParse(t);case k.DOUBLE:case k.FLOAT:switch(t){case"inf":return Number.POSITIVE_INFINITY;case"-inf":return Number.NEGATIVE_INFINITY;case"nan":return Number.NaN;default:return parseFloat(t)}case k.BOOL:return t==="true";case k.INT32:case k.UINT32:case k.SINT32:case k.FIXED32:case k.SFIXED32:return parseInt(t,10)}}function zce(e){let t=[],r={tail:e,c:"",next(){return this.tail.length==0?!1:(this.c=this.tail[0],this.tail=this.tail.substring(1),!0)},take(n){if(this.tail.length>=n){let i=this.tail.substring(0,n);return this.tail=this.tail.substring(n),i}return!1}};for(;r.next();)switch(r.c){case"\\":if(r.next())switch(r.c){case"\\":t.push(r.c.charCodeAt(0));break;case"b":t.push(8);break;case"f":t.push(12);break;case"n":t.push(10);break;case"r":t.push(13);break;case"t":t.push(9);break;case"v":t.push(11);break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let n=r.c,i=r.take(2);if(i===!1)return!1;let s=parseInt(n+i,8);if(isNaN(s))return!1;t.push(s);break}case"x":{let n=r.c,i=r.take(2);if(i===!1)return!1;let s=parseInt(n+i,16);if(isNaN(s))return!1;t.push(s);break}case"u":{let n=r.c,i=r.take(4);if(i===!1)return!1;let s=parseInt(n+i,16);if(isNaN(s))return!1;let a=new Uint8Array(4);new DataView(a.buffer).setInt32(0,s,!0),t.push(a[0],a[1],a[2],a[3]);break}case"U":{let n=r.c,i=r.take(8);if(i===!1)return!1;let s=qe.uEnc(n+i),a=new Uint8Array(8),o=new DataView(a.buffer);o.setInt32(0,s.lo,!0),o.setInt32(4,s.hi,!0),t.push(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]);break}}break;default:t.push(r.c.charCodeAt(0))}return new Uint8Array(t)}l();function*A_(e){switch(e.kind){case"file":for(let t of e.messages)yield t,yield*A_(t);yield*e.enums,yield*e.services,yield*e.extensions;break;case"message":for(let t of e.nestedMessages)yield t,yield*A_(t);yield*e.nestedEnums,yield*e.nestedExtensions;break}}l();function Si(e){let t=!1,r=[];for(let n=0;n<e.length;n++){let i=e.charAt(n);switch(i){case"_":t=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":r.push(i),t=!1;break;default:t&&(t=!1,i=i.toUpperCase()),r.push(i);break}}return r.join("")}var Qce=new Set(["constructor","toString","toJSON","valueOf"]);function ya(e){return Qce.has(e)?e+"$":e}function I_(...e){let t=Xce();if(!e.length)return t;if("$typeName"in e[0]&&e[0].$typeName=="google.protobuf.FileDescriptorSet"){for(let n of e[0].file)J3(n,t);return t}if("$typeName"in e[0]){let a=function(o){let c=[];for(let u of o.dependency){if(t.getFile(u)!=null||s.has(u))continue;let d=i(u);if(!d)throw new Error(`Unable to resolve ${u}, imported by ${o.name}`);"kind"in d?t.addFile(d,!1,!0):(s.add(d.name),c.push(d))}return c.concat(...c.map(a))};var r=a;let n=e[0],i=e[1],s=new Set;for(let o of[n,...a(n)].reverse())J3(o,t)}else for(let n of e)for(let i of n.files)t.addFile(i);return t}function Xce(){let e=new Map,t=new Map,r=new Map;return{kind:"registry",types:e,extendees:t,[Symbol.iterator](){return e.values()},get files(){return r.values()},addFile(n,i,s){if(r.set(n.proto.name,n),!i)for(let a of A_(n))this.add(a);if(s)for(let a of n.dependencies)this.addFile(a,i,s)},add(n){if(n.kind=="extension"){let i=t.get(n.extendee.typeName);i||t.set(n.extendee.typeName,i=new Map),i.set(n.number,n)}e.set(n.typeName,n)},get(n){return e.get(n)},getFile(n){return r.get(n)},getMessage(n){let i=e.get(n);return i?.kind=="message"?i:void 0},getEnum(n){let i=e.get(n);return i?.kind=="enum"?i:void 0},getExtension(n){let i=e.get(n);return i?.kind=="extension"?i:void 0},getExtensionFor(n,i){var s;return(s=t.get(n.typeName))===null||s===void 0?void 0:s.get(i)},getService(n){let i=e.get(n);return i?.kind=="service"?i:void 0}}}var jce=998,Zce=999,Jce=9,O_=10,kl=11,eue=12,j3=14,Mh=3,tue=2,Z3=1,rue=0,vh=1,nue=2,iue=3,sue=1,aue=2,oue=1;var t4={998:{fieldPresence:1,enumType:2,repeatedFieldEncoding:2,utf8Validation:3,messageEncoding:1,jsonFormat:2},999:{fieldPresence:2,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1},1e3:{fieldPresence:1,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1}};function J3(e,t){var r,n;let i={kind:"file",proto:e,deprecated:(n=(r=e.options)===null||r===void 0?void 0:r.deprecated)!==null&&n!==void 0?n:!1,edition:due(e),name:e.name.replace(/\.proto$/,""),dependencies:_ue(e,t),enums:[],messages:[],extensions:[],services:[],toString(){return`file ${e.name}`}},s=new Map,a={get(o){return s.get(o)},add(o){var c;Xr(((c=o.proto.options)===null||c===void 0?void 0:c.mapEntry)===!0),s.set(o.typeName,o)}};for(let o of e.enumType)r4(o,i,void 0,t);for(let o of e.messageType)n4(o,i,void 0,t,a);for(let o of e.service)lue(o,i,t);xh(i,t);for(let o of s.values())wh(o,t,a);for(let o of i.messages)wh(o,t,a),xh(o,t);t.addFile(i,!0)}function xh(e,t){switch(e.kind){case"file":for(let r of e.proto.extension){let n=Lh(r,e,t);e.extensions.push(n),t.add(n)}break;case"message":for(let r of e.proto.extension){let n=Lh(r,e,t);e.nestedExtensions.push(n),t.add(n)}for(let r of e.nestedMessages)xh(r,t);break}}function wh(e,t,r){let n=e.proto.oneofDecl.map(s=>uue(s,e)),i=new Set;for(let s of e.proto.field){let a=fue(s,n),o=Lh(s,e,t,a,r);e.fields.push(o),e.field[o.localName]=o,a===void 0?e.members.push(o):(a.fields.push(o),i.has(a)||(i.add(a),e.members.push(a)))}for(let s of n.filter(a=>i.has(a)))e.oneofs.push(s);for(let s of e.nestedMessages)wh(s,t,r)}function r4(e,t,r,n){var i,s,a;let o=mue(e.name,e.value),c={kind:"enum",proto:e,deprecated:(s=(i=e.options)===null||i===void 0?void 0:i.deprecated)!==null&&s!==void 0?s:!1,file:t,parent:r,open:!0,name:e.name,typeName:v_(e,r,t),value:{},values:[],sharedPrefix:o,toString(){return`enum ${this.typeName}`}};c.open=Sue(c),n.add(c),e.value.forEach(u=>{var d,_;let f=u.name;c.values.push(c.value[u.number]={kind:"enum_value",proto:u,deprecated:(_=(d=u.options)===null||d===void 0?void 0:d.deprecated)!==null&&_!==void 0?_:!1,parent:c,name:f,localName:ya(o==null?f:f.substring(o.length)),number:u.number,toString(){return`enum value ${c.typeName}.${f}`}})}),((a=r?.nestedEnums)!==null&&a!==void 0?a:t.enums).push(c)}function n4(e,t,r,n,i){var s,a,o,c;let u={kind:"message",proto:e,deprecated:(a=(s=e.options)===null||s===void 0?void 0:s.deprecated)!==null&&a!==void 0?a:!1,file:t,parent:r,name:e.name,typeName:v_(e,r,t),fields:[],field:{},oneofs:[],members:[],nestedEnums:[],nestedMessages:[],nestedExtensions:[],toString(){return`message ${this.typeName}`}};((o=e.options)===null||o===void 0?void 0:o.mapEntry)===!0?i.add(u):(((c=r?.nestedMessages)!==null&&c!==void 0?c:t.messages).push(u),n.add(u));for(let d of e.enumType)r4(d,t,u,n);for(let d of e.nestedType)n4(d,t,u,n,i)}function lue(e,t,r){var n,i;let s={kind:"service",proto:e,deprecated:(i=(n=e.options)===null||n===void 0?void 0:n.deprecated)!==null&&i!==void 0?i:!1,file:t,name:e.name,typeName:v_(e,void 0,t),methods:[],method:{},toString(){return`service ${this.typeName}`}};t.services.push(s),r.add(s);for(let a of e.method){let o=cue(a,s,r);s.methods.push(o),s.method[o.localName]=o}}function cue(e,t,r){var n,i,s,a;let o;e.clientStreaming&&e.serverStreaming?o="bidi_streaming":e.clientStreaming?o="client_streaming":e.serverStreaming?o="server_streaming":o="unary";let c=r.getMessage(Un(e.inputType)),u=r.getMessage(Un(e.outputType));Xr(c,`invalid MethodDescriptorProto: input_type ${e.inputType} not found`),Xr(u,`invalid MethodDescriptorProto: output_type ${e.inputType} not found`);let d=e.name;return{kind:"rpc",proto:e,deprecated:(i=(n=e.options)===null||n===void 0?void 0:n.deprecated)!==null&&i!==void 0?i:!1,parent:t,name:d,localName:ya(d.length?ya(d[0].toLowerCase()+d.substring(1)):d),methodKind:o,input:c,output:u,idempotency:(a=(s=e.options)===null||s===void 0?void 0:s.idempotencyLevel)!==null&&a!==void 0?a:rue,toString(){return`rpc ${t.typeName}.${d}`}}}function uue(e,t){return{kind:"oneof",proto:e,deprecated:!1,parent:t,fields:[],name:e.name,localName:ya(Si(e.name)),toString(){return`oneof ${t.typeName}.${this.name}`}}}function Lh(e,t,r,n,i){var s,a,o;let c=i===void 0,u={kind:"field",proto:e,deprecated:(a=(s=e.options)===null||s===void 0?void 0:s.deprecated)!==null&&a!==void 0?a:!1,name:e.name,number:e.number,scalar:void 0,message:void 0,enum:void 0,presence:Eue(e,n,c,t),listKind:void 0,mapKind:void 0,mapKey:void 0,delimitedEncoding:void 0,packed:void 0,longAsString:!1,getDefaultValue:void 0};if(c){let m=t.kind=="file"?t:t.file,h=t.kind=="file"?void 0:t,S=v_(e,h,m);u.kind="extension",u.file=m,u.parent=h,u.oneof=void 0,u.typeName=S,u.jsonName=`[${S}]`,u.toString=()=>`extension ${S}`;let b=r.getMessage(Un(e.extendee));Xr(b,`invalid FieldDescriptorProto: extendee ${e.extendee} not found`),u.extendee=b}else{let m=t;Xr(m.kind=="message"),u.parent=m,u.oneof=n,u.localName=n?Si(e.name):ya(Si(e.name)),u.jsonName=e.jsonName,u.toString=()=>`field ${m.typeName}.${e.name}`}let d=e.label,_=e.type,f=(o=e.options)===null||o===void 0?void 0:o.jstype;if(d===Mh){let m=_==kl?i?.get(Un(e.typeName)):void 0;if(m){u.fieldKind="map";let{key:h,value:S}=hue(m);return u.mapKey=h.scalar,u.mapKind=S.fieldKind,u.message=S.message,u.delimitedEncoding=!1,u.enum=S.enum,u.scalar=S.scalar,u}switch(u.fieldKind="list",_){case kl:case O_:u.listKind="message",u.message=r.getMessage(Un(e.typeName)),Xr(u.message),u.delimitedEncoding=e4(e,t);break;case j3:u.listKind="enum",u.enum=r.getEnum(Un(e.typeName)),Xr(u.enum);break;default:u.listKind="scalar",u.scalar=_,u.longAsString=f==Z3;break}return u.packed=gue(e,t),u}switch(_){case kl:case O_:u.fieldKind="message",u.message=r.getMessage(Un(e.typeName)),Xr(u.message,`invalid FieldDescriptorProto: type_name ${e.typeName} not found`),u.delimitedEncoding=e4(e,t),u.getDefaultValue=()=>{};break;case j3:{let m=r.getEnum(Un(e.typeName));Xr(m!==void 0,`invalid FieldDescriptorProto: type_name ${e.typeName} not found`),u.fieldKind="enum",u.enum=r.getEnum(Un(e.typeName)),u.getDefaultValue=()=>us(e,"defaultValue")?Q3(m,e.defaultValue):void 0;break}default:{u.fieldKind="scalar",u.scalar=_,u.longAsString=f==Z3,u.getDefaultValue=()=>us(e,"defaultValue")?X3(_,e.defaultValue):void 0;break}}return u}function due(e){switch(e.syntax){case"":case"proto2":return jce;case"proto3":return Zce;case"editions":if(e.edition in t4)return e.edition;throw new Error(`${e.name}: unsupported edition`);default:throw new Error(`${e.name}: unsupported syntax "${e.syntax}"`)}}function _ue(e,t){return e.dependency.map(r=>{let n=t.getFile(r);if(!n)throw new Error(`Cannot find ${r}, imported by ${e.name}`);return n})}function mue(e,t){let r=pue(e)+"_";for(let n of t){if(!n.name.toLowerCase().startsWith(r))return;let i=n.name.substring(r.length);if(i.length==0||/^\d/.test(i))return}return r}function pue(e){return(e.substring(0,1)+e.substring(1).replace(/[A-Z]/g,t=>"_"+t)).toLowerCase()}function v_(e,t,r){let n;return t?n=`${t.typeName}.${e.name}`:r.proto.package.length>0?n=`${r.proto.package}.${e.name}`:n=`${e.name}`,n}function Un(e){return e.startsWith(".")?e.substring(1):e}function fue(e,t){if(!us(e,"oneofIndex")||e.proto3Optional)return;let r=t[e.oneofIndex];return Xr(r,`invalid FieldDescriptorProto: oneof #${e.oneofIndex} for field #${e.number} not found`),r}function Eue(e,t,r,n){return e.label==tue?iue:e.label==Mh?nue:t||e.proto3Optional||e.type==kl||r?vh:Ra("fieldPresence",{proto:e,parent:n})}function gue(e,t){if(e.label!=Mh)return!1;switch(e.type){case Jce:case eue:case O_:case kl:return!1}let r=e.options;return r&&us(r,"packed")?r.packed:sue==Ra("repeatedFieldEncoding",{proto:e,parent:t})}function hue(e){let t=e.fields.find(n=>n.number===1),r=e.fields.find(n=>n.number===2);return Xr(t&&t.fieldKind=="scalar"&&t.scalar!=k.BYTES&&t.scalar!=k.FLOAT&&t.scalar!=k.DOUBLE&&r&&r.fieldKind!="list"&&r.fieldKind!="map"),{key:t,value:r}}function Sue(e){var t;return oue==Ra("enumType",{proto:e.proto,parent:(t=e.parent)!==null&&t!==void 0?t:e.file})}function e4(e,t){return e.type==O_?!0:aue==Ra("messageEncoding",{proto:e,parent:t})}function Ra(e,t){var r,n;let i=(r=t.proto.options)===null||r===void 0?void 0:r.features;if(i){let s=i[e];if(s!=0)return s}if("kind"in t){if(t.kind=="message")return Ra(e,(n=t.parent)!==null&&n!==void 0?n:t.file);let s=t4[t.edition];if(!s)throw new Error(`feature default for edition ${t.edition} not found`);return s[e]}return Ra(e,t.parent)}function Xr(e,t){if(!e)throw new Error(t)}l();var Tue=3,i4={writeUnknownFields:!0};function bue(e){return e?Object.assign(Object.assign({},i4),e):i4}function Bl(e,t,r){return x_(new Da,bue(r),Kt(e,t)).finish()}function x_(e,t,r){var n;for(let i of r.sortedFields){if(!r.isSet(i)){if(i.presence==Tue)throw new Error(`cannot encode field ${r.desc.typeName}.${i.name} to binary: required field not set`);continue}Ph(e,t,r,i)}if(t.writeUnknownFields)for(let{no:i,wireType:s,data:a}of(n=r.getUnknown())!==null&&n!==void 0?n:[])e.tag(i,s).raw(a);return e}function Ph(e,t,r,n){var i;switch(n.fieldKind){case"scalar":case"enum":w_(e,(i=n.scalar)!==null&&i!==void 0?i:k.INT32,n.number,r.get(n));break;case"list":Cue(e,t,n,r.get(n));break;case"message":s4(e,t,n,r.get(n));break;case"map":for(let[s,a]of r.get(n))Due(e,t,n,s,a);break}}function w_(e,t,r,n){a4(e.tag(r,yue(t)),t,n)}function s4(e,t,r,n){r.delimitedEncoding?x_(e.tag(r.number,dt.StartGroup),t,n).tag(r.number,dt.EndGroup):x_(e.tag(r.number,dt.LengthDelimited).fork(),t,n).join()}function Cue(e,t,r,n){var i;if(r.listKind=="message"){for(let a of n)s4(e,t,r,a);return}let s=(i=r.scalar)!==null&&i!==void 0?i:k.INT32;if(r.packed){if(!n.size)return;e.tag(r.number,dt.LengthDelimited).fork();for(let a of n)a4(e,s,a);e.join();return}for(let a of n)w_(e,s,r.number,a)}function Due(e,t,r,n,i){var s;switch(e.tag(r.number,dt.LengthDelimited).fork(),w_(e,r.mapKey,1,n),r.mapKind){case"scalar":case"enum":w_(e,(s=r.scalar)!==null&&s!==void 0?s:k.INT32,2,i);break;case"message":x_(e.tag(2,dt.LengthDelimited).fork(),t,i).join();break}e.join()}function a4(e,t,r){switch(t){case k.STRING:e.string(r);break;case k.BOOL:e.bool(r);break;case k.DOUBLE:e.double(r);break;case k.FLOAT:e.float(r);break;case k.INT32:e.int32(r);break;case k.INT64:e.int64(r);break;case k.UINT64:e.uint64(r);break;case k.FIXED64:e.fixed64(r);break;case k.BYTES:e.bytes(r);break;case k.FIXED32:e.fixed32(r);break;case k.SFIXED32:e.sfixed32(r);break;case k.SFIXED64:e.sfixed64(r);break;case k.SINT64:e.sint64(r);break;case k.UINT32:e.uint32(r);break;case k.SINT32:e.sint32(r);break}}function yue(e){switch(e){case k.BYTES:case k.STRING:return dt.LengthDelimited;case k.DOUBLE:case k.FIXED64:case k.SFIXED64:return dt.Bit64;case k.FIXED32:case k.SFIXED32:case k.FLOAT:return dt.Bit32;default:return dt.Varint}}l();var o4={readUnknownFields:!0};function Rue(e){return e?Object.assign(Object.assign({},o4),e):o4}function Gn(e,t,r){let n=Kt(e,void 0,!1);return l4(n,new ds(t),Rue(r),!1,t.byteLength),n.message}function l4(e,t,r,n,i){var s;let a=n?t.len:t.pos+i,o,c,u=(s=e.getUnknown())!==null&&s!==void 0?s:[];for(;t.pos<a&&([o,c]=t.tag(),!(n&&c==dt.EndGroup));){let d=e.findNumber(o);if(!d){let _=t.skip(c,o);r.readUnknownFields&&u.push({no:o,wireType:c,data:_});continue}Fh(e,t,d,c,r)}if(n&&(c!=dt.EndGroup||o!==i))throw new Error("invalid end group tag");u.length>0&&e.setUnknown(u)}function Fh(e,t,r,n,i){switch(r.fieldKind){case"scalar":e.set(r,Na(t,r.scalar));break;case"enum":e.set(r,Na(t,k.INT32));break;case"message":e.set(r,kh(t,i,r,e.get(r)));break;case"list":Aue(t,n,e.get(r),i);break;case"map":Nue(t,e.get(r),i);break}}function Nue(e,t,r){let n=t.field(),i,s,a=e.pos+e.uint32();for(;e.pos<a;){let[o]=e.tag();switch(o){case 1:i=Na(e,n.mapKey);break;case 2:switch(n.mapKind){case"scalar":s=Na(e,n.scalar);break;case"enum":s=e.int32();break;case"message":s=kh(e,r,n);break}break}}if(i===void 0&&(i=yr(n.mapKey,!1)),s===void 0)switch(n.mapKind){case"scalar":s=yr(n.scalar,!1);break;case"enum":s=n.enum.values[0].number;break;case"message":s=Kt(n.message,void 0,!1);break}t.set(i,s)}function Aue(e,t,r,n){var i;let s=r.field();if(s.listKind==="message"){r.add(kh(e,n,s));return}let a=(i=s.scalar)!==null&&i!==void 0?i:k.INT32;if(!(t==dt.LengthDelimited&&a!=k.STRING&&a!=k.BYTES)){r.add(Na(e,a));return}let c=e.uint32()+e.pos;for(;e.pos<c;)r.add(Na(e,a))}function kh(e,t,r,n){let i=r.delimitedEncoding,s=n??Kt(r.message,void 0,!1);return l4(s,e,t,i,i?r.number:e.uint32()),s}function Na(e,t){switch(t){case k.STRING:return e.string();case k.BOOL:return e.bool();case k.DOUBLE:return e.double();case k.FLOAT:return e.float();case k.INT32:return e.int32();case k.INT64:return e.int64();case k.UINT64:return e.uint64();case k.FIXED64:return e.fixed64();case k.BYTES:return e.bytes();case k.FIXED32:return e.fixed32();case k.SFIXED32:return e.sfixed32();case k.SFIXED64:return e.sfixed64();case k.SINT64:return e.sint64();case k.UINT32:return e.uint32();case k.SINT32:return e.sint32()}}l();l();l();function Oa(e){let t=Oue(),r=e.length*3/4;e[e.length-2]=="="?r-=2:e[e.length-1]=="="&&(r-=1);let n=new Uint8Array(r),i=0,s=0,a,o=0;for(let c=0;c<e.length;c++){if(a=t[e.charCodeAt(c)],a===void 0)switch(e[c]){case"=":s=0;case`
@@ -142,7 +142,7 @@ attempted value: ${a}
142
142
  # import { Sandbox } from 'e2b'
143
143
  # const sandbox = await Sandbox.create('${e.template_name||e.template_id}')
144
144
 
145
- `}var IB=ES({template_id:Es().required(),template_name:Es().optional(),dockerfile:Es().required(),start_cmd:Es().optional(),cpu_count:Rm().integer().min(1).optional(),memory_mb:Rm().integer().min(128).optional(),team_id:Es().optional()}),j_e=[{from:"id",to:"template_id"},{from:"name",to:"template_name"}];function Z_e(e,t){for(let r of t){let n=r.from,i=r.to;e[n]&&(e[i]=e[n],delete e[n])}return e}async function Ri(e){let t=await Ba.readFile(e,"utf-8"),r=Lm.parse(t),n=Z_e(r,j_e);return await IB.validate(n)}async function vB(e,t,r){try{if(!r&&OB.existsSync(e))throw new Error(`Config already exists on path ${Ft(e)}`);let n=await IB.validate(t,{stripUnknown:!0}),i=Lm.stringify(n);await Ba.writeFile(e,X_e(t)+i)}catch(n){throw new Error(`E2B sandbox template config ${St({templateID:t.template_id},e)} cannot be saved: ${n.message}`)}}async function xB(e){await Ba.unlink(e)}function Ni(e,t){return t&&Mm.isAbsolute(t)?t:Mm.join(e,t||yi)}var Fm=$(require("child_process"));l();var yS=class extends Error{constructor(t){super(t),this.name="E2BRequestError"}};function kt(e,t){if(!e.error&&e.data!=null)return;let r="unknown error",n=e.error?.code??0;switch(n){case 400:r="bad request";break;case 401:r="unauthorized";break;case 403:r="forbidden";break;case 404:r="not found";break;case 500:r="internal server error";break}throw new yS(`${t&&`${t}: `}[${n}] ${r&&`${r}: `}${e.error?.message??"no message"}`)}l();var RS=$(require("child_process")),wB=$(require("http")),LB=$(require("url")),MB=$(require("https"));l();async function Ua(e,t=!1){return(await(await import("inquirer")).default.prompt([{name:"confirm",type:"confirm",default:t,message:e}])).confirm}var PB=$(require("fs")),Pm=49984;async function FB(e,t,r,n,i){e?.dockerProxySet||(console.log("There was an issue during Docker authentication. Please follow the workaround steps from https://e2b.dev/docs/troubleshooting/templates/build-authentication-error and then continue."),await Ua("Have you completed the steps from the https://e2b.dev/docs/troubleshooting/templates/build-authentication-error workaround guide?")||(console.log("Please follow the workaround steps from https://e2b.dev/docs/troubleshooting/templates/build-authentication-error and then try again."),process.exit(1)));let s,a=new Promise(d=>{s=d}),o=Buffer.from(`_e2b_access_token:${r}`).toString("base64"),c=await eme(t,n,o,s);await a,await J_e(t,n,i)||(console.error("Docker push failed"),process.exit(1)),e&&!e.dockerProxySet&&(e.dockerProxySet=!0,PB.writeFileSync(Sr,JSON.stringify(e,null,2))),c.close()}async function J_e(e,t,r){let n=process.platform==="linux"?"localhost":"host.docker.internal",i=!1;RS.default.execSync(`docker tag docker.${e.domain}/e2b/custom-envs/${t.templateID}:${t.buildID} ${n}:${Pm}/e2b/custom-envs/${t.templateID}:${t.buildID}`,{stdio:"inherit",cwd:r});let s,a=new Promise(c=>{s=c}),o=RS.default.spawn("docker",["push",`${n}:${Pm}/e2b/custom-envs/${t.templateID}:${t.buildID}`],{detached:!0,stdio:"inherit",cwd:r});return o.on("exit",c=>{c!==0&&(console.error("Docker push failed"),process.exit(1)),i=!0,s(c)}),o.on("error",c=>{console.error("Error",c),process.exit(1)}),await a,i}async function eme(e,t,r,n){let i=await fetch(`https://docker.${e.domain}/v2/token?account=_e2b_access_token&scope=repository%3Ae2b%2Fcustom-envs%2F${t.templateID}%3Apush%2Cpull`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Basic ${r}`}}),{token:s}=await i.json(),a=wB.createServer((o,c)=>{let u=new LB.URL(o.url||"/",`https://docker.${e.domain}`),d={protocol:"https:",hostname:u.hostname,method:o.method,path:u.pathname+u.search,headers:{...o.headers,host:u.hostname}};d.headers.Authorization||(u.pathname.startsWith("/v2/token")?d.headers.Authorization=`Basic ${r}`:u.pathname=="/v2/"||u.pathname=="/v2"?d.headers.Authorization=`Bearer ${r}`:u.pathname.startsWith("/artifacts-uploads/namespaces")||(d.headers.Authorization=`Bearer ${s}`));let _=MB.request(d,f=>{c.writeHead(f.statusCode||500,f.headers),f.pipe(c,{end:!0})});_.on("error",f=>{console.error("Proxy Request Error:",f),c.statusCode=500,c.end(`Proxy Error: ${f.message}`)}),o.pipe(_,{end:!0})});return a.on("error",o=>{console.error("Server Error:",o)}),a.listen(Pm,()=>{n(null),console.log(`Proxy server running on port ${Pm}`)}),a}var tme=500;async function rme({templateID:e,buildID:t,logsOffset:r}){let n=cr.getSignal(),i=await Wt.api.GET("/templates/{templateID}/builds/{buildID}/status",{signal:n,params:{path:{templateID:e,buildID:t},query:{logsOffset:r}}});return kt(i,"Error getting template build status"),i.data}async function nme(e){return await Wt.api.POST("/templates",{body:e})}async function ime(e,t){return await Wt.api.POST("/templates/{templateID}",{body:t,params:{path:{templateID:e}}})}async function sme(e,t){let r;for(let i=0;i<3;i++)try{r=await Wt.api.POST("/templates/{templateID}/builds/{buildID}",{params:{path:{templateID:e,buildID:t}}});break}catch(s){s instanceof TypeError&&s.cause?.code!=="UND_ERR_SOCKET"&&(console.error(s),console.log("Retrying..."))}if(!r)throw new Error("Error triggering template build");return kt(r,"Error triggering template build"),r.data}var BB=new Fe("build").description(`build sandbox template defined by ${Ft(Ci)} or ${Ft(cm)} in root directory. By default the root directory is the current working directory. This command also creates ${Pt(yi)} config.`).argument("[template]",`specify ${be("[template]")} to rebuild it. If you don's specify ${be("[template]")} and there is no ${Pt("e2b.toml")} a new sandbox template will be created.`).addOption(Zr).option("-d, --dockerfile <file>",`specify path to Dockerfile. By default E2B tries to find ${Pt(Ci)} or ${Pt(cm)} in root directory.`).option("-n, --name <template-name>","specify sandbox template name. You can use the template name to start the sandbox with SDK. The template name must be lowercase and contain only letters, numbers, dashes and underscores.").option("-c, --cmd <start-command>","specify command that will be executed when the sandbox is started.").addOption(Yn).addOption(Hn).option("--cpu-count <cpu-count>","specify the number of CPUs that will be used to run the sandbox. The default value is 2.",parseInt).option("--memory-mb <memory-mb>","specify the amount of memory in megabytes that will be used to run the sandbox. Must be an even number. The default value is 512.",parseInt).option("--build-arg <args...>","specify additional build arguments for the build command. The format should be <varname>=<value>.").option("--no-cache","skip cache when building the template.").alias("bd").action(async(e,t)=>{try{kB.default.sync("docker")||(console.error("Docker is required to build and push the sandbox template. Please install Docker and try again."),process.exit(1));let n={};t.buildArg&&t.buildArg.forEach(C=>{let[H,q]=C.split("=");n[H]=q});let i=Ma();process.stdout.write(`
145
+ `}var IB=ES({template_id:Es().required(),template_name:Es().optional(),dockerfile:Es().required(),start_cmd:Es().optional(),cpu_count:Rm().integer().min(1).optional(),memory_mb:Rm().integer().min(128).optional(),team_id:Es().optional()}),j_e=[{from:"id",to:"template_id"},{from:"name",to:"template_name"}];function Z_e(e,t){for(let r of t){let n=r.from,i=r.to;e[n]&&(e[i]=e[n],delete e[n])}return e}async function Ri(e){let t=await Ba.readFile(e,"utf-8"),r=Lm.parse(t),n=Z_e(r,j_e);return await IB.validate(n)}async function vB(e,t,r){try{if(!r&&OB.existsSync(e))throw new Error(`Config already exists on path ${Ft(e)}`);let n=await IB.validate(t,{stripUnknown:!0}),i=Lm.stringify(n);await Ba.writeFile(e,X_e(t)+i)}catch(n){throw new Error(`E2B sandbox template config ${St({templateID:t.template_id},e)} cannot be saved: ${n.message}`)}}async function xB(e){await Ba.unlink(e)}function Ni(e,t){return t&&Mm.isAbsolute(t)?t:Mm.join(e,t||yi)}var Fm=$(require("child_process"));l();var yS=class extends Error{constructor(t){super(t),this.name="E2BRequestError"}};function kt(e,t){if(!e.error)return;let r="unknown error",n=e.error?.code??0;switch(n){case 400:r="bad request";break;case 401:r="unauthorized";break;case 403:r="forbidden";break;case 404:r="not found";break;case 500:r="internal server error";break}throw new yS(`${t&&`${t}: `}[${n}] ${r&&`${r}: `}${e.error?.message??"no message"}`)}l();var RS=$(require("child_process")),wB=$(require("http")),LB=$(require("url")),MB=$(require("https"));l();async function Ua(e,t=!1){return(await(await import("inquirer")).default.prompt([{name:"confirm",type:"confirm",default:t,message:e}])).confirm}var PB=$(require("fs")),Pm=49984;async function FB(e,t,r,n,i){e?.dockerProxySet||(console.log("There was an issue during Docker authentication. Please follow the workaround steps from https://e2b.dev/docs/troubleshooting/templates/build-authentication-error and then continue."),await Ua("Have you completed the steps from the https://e2b.dev/docs/troubleshooting/templates/build-authentication-error workaround guide?")||(console.log("Please follow the workaround steps from https://e2b.dev/docs/troubleshooting/templates/build-authentication-error and then try again."),process.exit(1)));let s,a=new Promise(d=>{s=d}),o=Buffer.from(`_e2b_access_token:${r}`).toString("base64"),c=await eme(t,n,o,s);await a,await J_e(t,n,i)||(console.error("Docker push failed"),process.exit(1)),e&&!e.dockerProxySet&&(e.dockerProxySet=!0,PB.writeFileSync(Sr,JSON.stringify(e,null,2))),c.close()}async function J_e(e,t,r){let n=process.platform==="linux"?"localhost":"host.docker.internal",i=!1;RS.default.execSync(`docker tag docker.${e.domain}/e2b/custom-envs/${t.templateID}:${t.buildID} ${n}:${Pm}/e2b/custom-envs/${t.templateID}:${t.buildID}`,{stdio:"inherit",cwd:r});let s,a=new Promise(c=>{s=c}),o=RS.default.spawn("docker",["push",`${n}:${Pm}/e2b/custom-envs/${t.templateID}:${t.buildID}`],{detached:!0,stdio:"inherit",cwd:r});return o.on("exit",c=>{c!==0&&(console.error("Docker push failed"),process.exit(1)),i=!0,s(c)}),o.on("error",c=>{console.error("Error",c),process.exit(1)}),await a,i}async function eme(e,t,r,n){let i=await fetch(`https://docker.${e.domain}/v2/token?account=_e2b_access_token&scope=repository%3Ae2b%2Fcustom-envs%2F${t.templateID}%3Apush%2Cpull`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Basic ${r}`}}),{token:s}=await i.json(),a=wB.createServer((o,c)=>{let u=new LB.URL(o.url||"/",`https://docker.${e.domain}`),d={protocol:"https:",hostname:u.hostname,method:o.method,path:u.pathname+u.search,headers:{...o.headers,host:u.hostname}};d.headers.Authorization||(u.pathname.startsWith("/v2/token")?d.headers.Authorization=`Basic ${r}`:u.pathname=="/v2/"||u.pathname=="/v2"?d.headers.Authorization=`Bearer ${r}`:u.pathname.startsWith("/artifacts-uploads/namespaces")||(d.headers.Authorization=`Bearer ${s}`));let _=MB.request(d,f=>{c.writeHead(f.statusCode||500,f.headers),f.pipe(c,{end:!0})});_.on("error",f=>{console.error("Proxy Request Error:",f),c.statusCode=500,c.end(`Proxy Error: ${f.message}`)}),o.pipe(_,{end:!0})});return a.on("error",o=>{console.error("Server Error:",o)}),a.listen(Pm,()=>{n(null),console.log(`Proxy server running on port ${Pm}`)}),a}var tme=500;async function rme({templateID:e,buildID:t,logsOffset:r}){let n=cr.getSignal(),i=await Wt.api.GET("/templates/{templateID}/builds/{buildID}/status",{signal:n,params:{path:{templateID:e,buildID:t},query:{logsOffset:r}}});return kt(i,"Error getting template build status"),i.data}async function nme(e){return await Wt.api.POST("/templates",{body:e})}async function ime(e,t){return await Wt.api.POST("/templates/{templateID}",{body:t,params:{path:{templateID:e}}})}async function sme(e,t){let r;for(let i=0;i<3;i++)try{r=await Wt.api.POST("/templates/{templateID}/builds/{buildID}",{params:{path:{templateID:e,buildID:t}}});break}catch(s){s instanceof TypeError&&s.cause?.code!=="UND_ERR_SOCKET"&&(console.error(s),console.log("Retrying..."))}if(!r)throw new Error("Error triggering template build");return kt(r,"Error triggering template build"),r.data}var BB=new Fe("build").description(`build sandbox template defined by ${Ft(Ci)} or ${Ft(cm)} in root directory. By default the root directory is the current working directory. This command also creates ${Pt(yi)} config.`).argument("[template]",`specify ${be("[template]")} to rebuild it. If you don's specify ${be("[template]")} and there is no ${Pt("e2b.toml")} a new sandbox template will be created.`).addOption(Zr).option("-d, --dockerfile <file>",`specify path to Dockerfile. By default E2B tries to find ${Pt(Ci)} or ${Pt(cm)} in root directory.`).option("-n, --name <template-name>","specify sandbox template name. You can use the template name to start the sandbox with SDK. The template name must be lowercase and contain only letters, numbers, dashes and underscores.").option("-c, --cmd <start-command>","specify command that will be executed when the sandbox is started.").addOption(Yn).addOption(Hn).option("--cpu-count <cpu-count>","specify the number of CPUs that will be used to run the sandbox. The default value is 2.",parseInt).option("--memory-mb <memory-mb>","specify the amount of memory in megabytes that will be used to run the sandbox. Must be an even number. The default value is 512.",parseInt).option("--build-arg <args...>","specify additional build arguments for the build command. The format should be <varname>=<value>.").option("--no-cache","skip cache when building the template.").alias("bd").action(async(e,t)=>{try{kB.default.sync("docker")||(console.error("Docker is required to build and push the sandbox template. Please install Docker and try again."),process.exit(1));let n={};t.buildArg&&t.buildArg.forEach(C=>{let[H,q]=C.split("=");n[H]=q});let i=Ma();process.stdout.write(`
146
146
  `);let s=t.name?.trim();s&&!/[a-z0-9-_]+/.test(s)&&(console.error(`Name ${Pt(s)} is not valid. Name can only contain lowercase letters, numbers, dashes and underscores.`),process.exit(1));let a=t.dockerfile,o=t.cmd,c=t.cpuCount,u=t.memoryMb,d=t.team,_=_n(t.path),f=Ni(_,t.config),m=rc.existsSync(f)?await Ri(f):void 0,h=Kn.relative(_,f);m&&(console.log(`Found sandbox template ${St({templateID:m.template_id,aliases:m.template_name?[m.template_name]:void 0},h)}`),e=m.template_id,a=t.dockerfile||m.dockerfile,o=t.cmd||m.start_cmd,c=t.cpuCount||m.cpu_count,u=t.memoryMb||m.memory_mb,d=t.team||m.team_id);let S=lr();S&&(d=d||S.teamId),m&&e&&m.template_id!==e&&(console.error("You can't specify different ID than the one in config. If you want to build a new sandbox template remove the config file."),process.exit(1)),s&&m?.template_name&&s!==m?.template_name&&console.log(`The sandbox template name will be changed from ${Pt(m.template_name)} to ${Pt(s)}.`);let b=s||m?.template_name,{dockerfileContent:y,dockerfileRelativePath:I}=ome(_,a);console.log(`Found ${Ft(I)} that will be used to build the sandbox template.`);let A={alias:b,startCmd:o,cpuCount:c,memoryMB:u,dockerfile:y,teamID:d};t.memoryMb&&t.memoryMb%2!==0&&(console.error(`The memory in megabytes must be an even number. You provided ${Pt(t.memoryMb.toFixed(0))}.`),process.exit(1));let L=await lme(A,e);e=L.templateID,console.log(`Requested build for the sandbox template ${St(L)} `),await vB(f,{template_id:L.templateID,dockerfile:I,template_name:b,start_cmd:o,cpu_count:c,memory_mb:u,team_id:d},!0);try{Fm.execSync(`echo "${i}" | docker login docker.${cr.domain} -u _e2b_access_token --password-stdin`,{stdio:"inherit",cwd:_})}catch{console.error("Docker login failed. Please try to log in with `e2b auth login` and try again."),process.exit(1)}process.stdout.write(`
147
147
  `);let z=Object.entries(n).map(([C,H])=>`--build-arg "${C}=${H}"`).join(" "),W=t.noCache?"--no-cache":"",X=["docker build",`-f ${I}`,"--pull --platform linux/amd64",`-t docker.${cr.domain}/e2b/custom-envs/${e}:${L.buildID}`,z,W,"."].join(" ");console.log(`Building docker image with the following command:
148
148
  ${be(X)}